{"version":3,"file":"OutSeta_Auth.DWIFyMSJ.mjs","names":["user","useState"],"sources":["https:/framerusercontent.com/modules/9uDUvMVNcRNQ3MFFcTUC/L3Yuot0ZV76NUt3oSe7e/OutSeta_Auth.js"],"sourcesContent":["/// VERSION 0.0.4\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";/////////////////// Button Overrides\nexport function withRegisterPopup(Component){return props=>{return /*#__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=>{return /*#__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=>{return /*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\",\"data-o-profile\":\"1\",\"data-mode\":\"popup\"});};}export function asLogoutButton(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\",\"data-o-logout-link\":\"1\"});};}// Кнопка \"Upgrade / Get Paid\", яка:\n// - якщо юзер без акаунта → signup + платний план\n// - якщо юзер з free планом → профіль на вкладці Plan (апгрейд)\n// - якщо юзер вже на paid → профіль на вкладці Billing (керування підпискою)\nexport function asUpgradeOrSignupForPaid_A93RE1Q0(Component){const paidPlanUid=\"A93RE1Q0\"// твій платний plan uid\n;return props=>{const user=useUser();// 1) Немає юзера → signup + одразу платний план\nif(!user){return /*#__PURE__*/_jsx(Component,{...props,\"data-o-anonymous\":\"1\",\"data-o-auth\":\"1\",\"data-mode\":\"popup\",\"data-widget-mode\":\"register\",\"data-plan-uid\":paidPlanUid});}const currentPlanUid=user[\"Account.CurrentSubscription.Plan.Uid\"];// 2) Юзер уже на paid плані → відкриваємо billing таб\nif(currentPlanUid===paidPlanUid){return /*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\",\"data-o-profile\":\"1\",\"data-mode\":\"popup\",\"data-tab\":\"billing\"});}// 3) Юзер залогінений, але ще НЕ на paid (тобто free) → вкладка Plan для апгрейду\nreturn /*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\",\"data-o-profile\":\"1\",\"data-mode\":\"popup\",\"data-tab\":\"plan\"});};}/////////////////// Visibility Overrides\n// Загальний HOC: показати для будь-якого автентифікованого юзера\nexport function showForAuthenticated(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\"});};}// Показати тільки для анонімних\nexport function showForAnonymous(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,\"data-o-anonymous\":\"1\"});};}// Показати для анонімних АБО автентифікованих без paid-плану A93RE1Q0\nexport function showForAnonymousAndAuthenticatedWithoutPaid_A93RE1Q0(Component){const paidPlanUids=[\"A93RE1Q0\"];return props=>{try{const user=useUser();// 1) Якщо юзер анонімний — показуємо\nif(!user){return /*#__PURE__*/_jsx(Component,{...props,\"data-o-anonymous\":\"1\"});}// 2) Якщо є юзер — перевіряємо план\nconst value=user[\"Account.CurrentSubscription.Plan.Uid\"];// Якщо є paid-план — ховаємо компонент\nif(value&&paidPlanUids.includes(value)){return null;}// 3) Залогінений, але без цього paid-плану → показуємо\nreturn /*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\"});}catch(error){log(\"error in showForAnonymousAndAuthenticatedWithoutPaid_A93RE1Q0\",paidPlanUids.join(\",\"),error.message);return null;}};}/////////// Visibility Overrides Based on Plan Uid\n/////// Instruction\n// 1. Find the plan uid on the plan page in Outseta\n// 2. Replace A93RE1Q0 in function name and arrays with your plan uid if needed\n// 3. Duplicate functions for additional plans\n// ТІЛЬКИ для юзерів з конкретним платним планом (A93RE1Q0)\nexport function showForSinglePlan_A93RE1Q0(Component){const validPlanUids=[\"A93RE1Q0\"];return props=>{try{const user=useUser();const value=user&&user[\"Account.CurrentSubscription.Plan.Uid\"];if(value&&validPlanUids.includes(value)){return /*#__PURE__*/_jsx(Component,{...props});}return null;}catch(error){log(\"error in showForSinglePlan_A93RE1Q0\",validPlanUids.join(\",\"),error.message);return null;}};}// ДЛЯ автентифікованих, але БЕЗ цього paid плану\nexport function showForAuthenticatedWithoutPaid_A93RE1Q0(Component){const paidPlanUids=[\"A93RE1Q0\"];return props=>{try{const user=useUser();// якщо не залогінений — нічого не показуємо\nif(!user)return null;const value=user[\"Account.CurrentSubscription.Plan.Uid\"];// якщо є paid план — ховаємо компонент\nif(value&&paidPlanUids.includes(value)){return null;}// залогінений, але НЕ на цьому paid плані\nreturn /*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\"});}catch(error){log(\"error in showForAuthenticatedWithoutPaid_A93RE1Q0\",paidPlanUids.join(\",\"),error.message);return null;}};}/////////// Visibility Based on an Account Custom Property\n/////// Instruction\n// 1. Give the function as useful name\n// 2. Replace the \"PARTY\" value of validPropertyValue with the uppercase version of the value you want\n// 3. Replace MyCustomAccountProperty with the system name of your custom account property\n// Duplicate the functions for additional account properties and/or values\nexport 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;}};}/////////// Visibility Based on an Person Custom Property\n/////// Instruction\n// 1. Give the function a useful name\n// 2. Replace the \"PARTY\" value of validPropertyValue with the uppercase version of the value you want\n// 3. Replace MyCustomPersonProperty with the system name of your custom person property\n// Duplicate the functions for additional account properties and/or values\nexport 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;// Possible race condition that an earlier\nlog(\"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;// Listen to global events that might change the user\nconst outsetaFetchUserEvents=[\"accessToken.set\",\"profile.update\",\"account.update\"];outsetaFetchUserEvents.forEach(event=>{getOutseta()?.on(event,()=>fetchUser(event));});// Listen to global events that should clear the user\nconst outsetaClearUserEvents=[\"logout\"];outsetaClearUserEvents.forEach(event=>{getOutseta()?.on(event,()=>clearUser(event));});/////////////////// User Hook\nfunction useUser(){const[user,setUser]=useState(getUser());useEffect(()=>{const updateData=newData=>setUser(newData);const unsubscribe=subscribe(updateData);return()=>{unsubscribe();};},[]);return user;}function getOutseta(){if(window&&window[\"Outseta\"]){return window[\"Outseta\"];}else if(window){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 🙏`);}else{// Rendering on the server\n}}/////////////////// 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];log(\"avatar source\",user[property]);if(imageSrc){return /*#__PURE__*/_jsx(Component,{...props,background:{...props.background,src:imageSrc,srcSet:undefined}});}else if(props.background?.src){// Component has image set, use as fallback\nreturn /*#__PURE__*/_jsx(Component,{...props});}else{// Component has no image set, remove\nreturn null;}};}function log(...props){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,index)=>{flattenObject(item,`${propName}[${index}]`,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\":{\"showForPartyAccounts\":{\"type\":\"reactHoc\",\"name\":\"showForPartyAccounts\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForAnonymous\":{\"type\":\"reactHoc\",\"name\":\"showForAnonymous\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionName\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForAuthenticated\":{\"type\":\"reactHoc\",\"name\":\"showForAuthenticated\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserLastName\":{\"type\":\"reactHoc\",\"name\":\"withUserLastName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForSinglePlan_A93RE1Q0\":{\"type\":\"reactHoc\",\"name\":\"showForSinglePlan_A93RE1Q0\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"asLogoutButton\":{\"type\":\"reactHoc\",\"name\":\"asLogoutButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"asProfilePopupButton\":{\"type\":\"reactHoc\",\"name\":\"asProfilePopupButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForAuthenticatedWithoutPaid_A93RE1Q0\":{\"type\":\"reactHoc\",\"name\":\"showForAuthenticatedWithoutPaid_A93RE1Q0\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRegisterPopup\":{\"type\":\"reactHoc\",\"name\":\"withRegisterPopup\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserFullName\":{\"type\":\"reactHoc\",\"name\":\"withUserFullName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForPartyPeople\":{\"type\":\"reactHoc\",\"name\":\"showForPartyPeople\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionUid\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionUid\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForAnonymousAndAuthenticatedWithoutPaid_A93RE1Q0\":{\"type\":\"reactHoc\",\"name\":\"showForAnonymousAndAuthenticatedWithoutPaid_A93RE1Q0\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"asLoginPopupButton\":{\"type\":\"reactHoc\",\"name\":\"asLoginPopupButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getUser\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionDescription\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionDescription\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserEmail\":{\"type\":\"reactHoc\",\"name\":\"withUserEmail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserFirstName\":{\"type\":\"reactHoc\",\"name\":\"withUserFirstName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"subscribe\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserAvatar\":{\"type\":\"reactHoc\",\"name\":\"withUserAvatar\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountName\":{\"type\":\"reactHoc\",\"name\":\"withAccountName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"asUpgradeOrSignupForPaid_A93RE1Q0\":{\"type\":\"reactHoc\",\"name\":\"asUpgradeOrSignupForPaid_A93RE1Q0\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./OutSeta_Auth.map"],"mappings":"uIAEA,SAAgB,EAAkB,EAAU,CAAC,MAAO,IAA4B,EAAK,EAAU,CAAC,GAAG,EAAM,mBAAmB,IAAI,cAAc,IAAI,YAAY,QAAQ,mBAAmB,WAAW,CAAC,CAAI,SAAgB,EAAmB,EAAU,CAAC,MAAO,IAA4B,EAAK,EAAU,CAAC,GAAG,EAAM,mBAAmB,IAAI,cAAc,IAAI,YAAY,QAAQ,mBAAmB,QAAQ,CAAC,CAI5Y,SAAgB,EAAkC,EAAU,CAAC,IAAM,EAAY,WAC9E,MAAO,IAAO,CAAC,IAAMA,EAAK,GAAS,CAGpC,OAFIA,EAAkMA,EAAK,0CACvL,EAAiC,EAAK,EAAU,CAAC,GAAG,EAAM,uBAAuB,IAAI,iBAAiB,IAAI,YAAY,QAAQ,WAAW,UAAU,CAAC,CACpJ,EAAK,EAAU,CAAC,GAAG,EAAM,uBAAuB,IAAI,iBAAiB,IAAI,YAAY,QAAQ,WAAW,OAAO,CAAC,CAFtG,EAAK,EAAU,CAAC,GAAG,EAAM,mBAAmB,IAAI,cAAc,IAAI,YAAY,QAAQ,mBAAmB,WAAW,gBAAgB,EAAY,CAAC,EAI/K,SAAgB,EAAqB,EAAU,CAAC,MAAO,IAA4B,EAAK,EAAU,CAAC,GAAG,EAAM,uBAAuB,IAAI,CAAC,CACxI,SAAgB,EAAiB,EAAU,CAAC,MAAO,IAA4B,EAAK,EAAU,CAAC,GAAG,EAAM,mBAAmB,IAAI,CAAC,CAChI,SAAgB,EAAqD,EAAU,CAAC,IAAM,EAAa,CAAC,WAAW,CAAC,MAAO,IAAO,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