{"version":3,"file":"Outseta.CWNd3ffy.mjs","names":["user","useState"],"sources":["https:/framerusercontent.com/modules/gkef1zdBsvObttsXafvK/wFiCmDV3nsFGJHuyu4xS/Outseta.js"],"sourcesContent":["/// VERSION 0.0.2\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\"});};}/////////////////// Visibility Overrides\nexport function showForAuthenticated(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\"});};}export function showForAnonymous(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,\"data-o-anonymous\":\"1\"});};}/////////// Visibility Overrides Based on Plan Uid\nexport function showForSinglePlan_aWxYEbmV(Component){const validPlanUid=\"aWxYEbmV\";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;}};}/////////// Visibility Based on an Account Custom Property\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 a Person Custom Property\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);}/**\n * ✅ حجم المحفظة الاستثمارية\n * يقرأ القيمة من Account.Size_wallet\n * يرجّع الرقم/النص بدون كلمة العملة\n * ويخلي الخط Bold\n */export function withWalletSize(Component){const PROPERTY_KEY=\"Account.Size_wallet\";return props=>{const user=useUser();if(!user)return null;const raw=user[PROPERTY_KEY];const baseStyle={...props.style,fontWeight:700};if(raw===undefined||raw===null||raw===\"\"){return /*#__PURE__*/_jsx(Component,{...props,text:\"\",style:baseStyle});}let valueStr=String(raw);// نحذف الأقواس، الفواصل، الأقواس المربعة، علامات الاقتباس... إلخ\nvalueStr=valueStr.replace(/[\\[\\]\"',]/g,\" \");// نشيل كلمات العملة الشائعة\nvalueStr=valueStr.replace(/sar/gi,\"\").replace(/ر\\.?س/g,\"\").replace(/ريال/g,\"\");// توحيد المسافات\nconst cleaned=valueStr.replace(/\\s+/g,\" \").trim();if(!cleaned){return /*#__PURE__*/_jsx(Component,{...props,text:\"\",style:baseStyle});}return /*#__PURE__*/_jsx(Component,{...props,text:cleaned,style:baseStyle});};}/**\n * ✅ نوع النشاط (BusinessType)\n * من Account.BusinessType\n */export function withBusinessType(Component){const PROPERTY_KEY=\"Account.BusinessType\";return props=>{const user=useUser();if(!user)return null;const raw=user[PROPERTY_KEY];const baseStyle={...props.style,fontWeight:700};if(raw===undefined||raw===null){return /*#__PURE__*/_jsx(Component,{...props,text:\"\",style:baseStyle});}const valueStr=String(raw).trim();return /*#__PURE__*/_jsx(Component,{...props,text:valueStr,style:baseStyle});};}/**\n * ✅ مرحلة البايبلاين (DealPipelineStage)\n * من Deals[0].DealPipelineStage\n * يعرض المرحلة كـ نص عادي بخط Bold\n */export function DealPipelineStage(Component){const PROPERTY_KEY=\"Deal.DealPipelineStage\";return props=>{const user=useUser();if(!user)return null;// تشيك بسيط في الـ console لو حاب تتأكد من المفاتيح الراجعة\nlog(\"DealPipelineStage keys\",Object.keys(user||{}));const raw=user[PROPERTY_KEY];const baseStyle={...props.style,fontWeight:700};if(raw===undefined||raw===null||raw===\"\"){return /*#__PURE__*/_jsx(Component,{...props,text:\"\",style:baseStyle});}const valueStr=String(raw).trim();return /*#__PURE__*/_jsx(Component,{...props,text:valueStr,style:baseStyle});};}/**\n * ✅ القطاعات (Sectors)\n * الحقل عندك راجع كقائمة (Array) أو نص JSON مثل:\n * [\"قطاع النقل\",\"قطاع الخدمات\",\"قطاع التقنية\"]\n *\n * النتيجة النهائية:\n * \"قطاع النقل، قطاع الخدمات، قطاع التقنية\"\n * مع خط Bold\n */export function withSectors(Component){const PROPERTY_KEY=\"Account.Sectors\";return props=>{const user=useUser();if(!user)return null;const raw=user[PROPERTY_KEY];const baseStyle={...props.style,fontWeight:700};if(raw===undefined||raw===null||raw===\"\"){return /*#__PURE__*/_jsx(Component,{...props,text:\"\",style:baseStyle});}let display=\"\";try{if(Array.isArray(raw)){// لو راجع Array فعلي من Outseta\ndisplay=raw.join(\"، \");}else if(typeof raw===\"string\"){const trimmed=raw.trim();// لو النص شكله JSON Array\nif(trimmed.startsWith(\"[\")&&trimmed.endsWith(\"]\")){const parsed=JSON.parse(trimmed);if(Array.isArray(parsed)){display=parsed.join(\"، \");}else{display=parsed.toString();}}else{// نص عادي\ndisplay=trimmed;}}else{display=String(raw);}}catch(e){// في حال فشل الـ JSON.parse نرجع النص كما هو بعد تنظيف خفيف\ndisplay=String(raw);}// إزالة الاقتباسات الزائدة لو بقيت\ndisplay=display.replace(/\"/g,\"\").trim();return /*#__PURE__*/_jsx(Component,{...props,text:display,style:baseStyle});};}/////////////////// 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;// 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[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 🙏`);}else{// Server side\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){return /*#__PURE__*/_jsx(Component,{...props});}else{return null;}};}function log(...props){getOutseta()?.debug(\"outseta.framer.override.user\",...props);}function flattenObject(obj,parent=\"\",res={}){for(const key in obj){const 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\":{\"showForSinglePlan_aWxYEbmV\":{\"type\":\"reactHoc\",\"name\":\"showForSinglePlan_aWxYEbmV\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForAnonymous\":{\"type\":\"reactHoc\",\"name\":\"showForAnonymous\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionUid\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionUid\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withBusinessType\":{\"type\":\"reactHoc\",\"name\":\"withBusinessType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionName\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountName\":{\"type\":\"reactHoc\",\"name\":\"withAccountName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserAvatar\":{\"type\":\"reactHoc\",\"name\":\"withUserAvatar\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSectors\":{\"type\":\"reactHoc\",\"name\":\"withSectors\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"asLogoutButton\":{\"type\":\"reactHoc\",\"name\":\"asLogoutButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserLastName\":{\"type\":\"reactHoc\",\"name\":\"withUserLastName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"asProfilePopupButton\":{\"type\":\"reactHoc\",\"name\":\"asProfilePopupButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserFullName\":{\"type\":\"reactHoc\",\"name\":\"withUserFullName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"DealPipelineStage\":{\"type\":\"reactHoc\",\"name\":\"DealPipelineStage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"subscribe\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserFirstName\":{\"type\":\"reactHoc\",\"name\":\"withUserFirstName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForPartyAccounts\":{\"type\":\"reactHoc\",\"name\":\"showForPartyAccounts\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getUser\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRegisterPopup\":{\"type\":\"reactHoc\",\"name\":\"withRegisterPopup\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForAuthenticated\":{\"type\":\"reactHoc\",\"name\":\"showForAuthenticated\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForPartyPeople\":{\"type\":\"reactHoc\",\"name\":\"showForPartyPeople\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withWalletSize\":{\"type\":\"reactHoc\",\"name\":\"withWalletSize\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserEmail\":{\"type\":\"reactHoc\",\"name\":\"withUserEmail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionDescription\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionDescription\",\"annotations\":{\"framerContractVersion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