{"version":3,"file":"AccountManager.mnGev2GF.mjs","names":["React"],"sources":["https:/framerusercontent.com/modules/d0QJmNDrg2IaiUFU8Rkc/EfOEiWtSFMwc3ZH6DGnv/AccountManager.js"],"sourcesContent":["//@ts-ignore\nimport{jsx as _jsx}from\"react/jsx-runtime\";import React from\"react\";const getOutsetaModule=()=>{if(typeof window===\"undefined\")return null;return window.__outsetaFramerModule||null;};function useOutsetaUser(){const[user,setUser]=React.useState(()=>getOutsetaModule()?.getUser?.()??null);React.useEffect(()=>{const module=getOutsetaModule();if(!module?.subscribe)return;const unsubscribe=module.subscribe(data=>setUser(data));return()=>{unsubscribe?.();};},[]);return user;}const ACCOUNT_STAGE_LABELS={1:\"Demo\",2:\"Trialing\",3:\"Subscribing\",4:\"Cancelling\",5:\"Expired\",6:\"Trial Expired\",7:\"Past Due\"};const BILLING_RENEWAL_TERM_LABELS={1:\"Monthly\",2:\"Annual\",3:\"Quarterly\",4:\"Lifetime\"};function formatDateValue(value,options){if(!value)return\"\";const date=new Date(value);if(Number.isNaN(date.getTime()))return\"\";return date.toLocaleDateString(undefined,options??{year:\"numeric\",month:\"short\",day:\"numeric\"});}function formatCurrencyValue(value,currency=\"USD\"){if(value===null||value===undefined||value===\"\")return\"\";const number=Number(value);if(Number.isNaN(number))return String(value);return new Intl.NumberFormat(undefined,{style:\"currency\",currency}).format(number);}function composeAddress(user,baseKeys){const parts=[];baseKeys.forEach(key=>{const value=user[key];if(typeof value===\"string\"&&value.trim().length>0){parts.push(value.trim());}});return parts.join(\", \");}function getAccountStageInfo(user){if(!user)return{number:null,label:\"\"};const stageValue=user[\"Account.AccountStage\"]??user[\"AccountStage\"];const number=typeof stageValue===\"number\"?stageValue:Number(stageValue);const labelCandidate=user[\"AccountStageLabel\"];const label=typeof labelCandidate===\"string\"&&labelCandidate.trim()||ACCOUNT_STAGE_LABELS[number]||\"\";return{number:Number.isFinite(number)?number:null,label};}function createVisibilityOverride(predicate){return Component=>{return props=>{const user=useOutsetaUser();const visible=predicate(user);return renderWithVisibility(Component,props,visible);};};}function withFormattedUserProperty(field,formatter){return Component=>{return props=>{const user=useOutsetaUser();if(!user)return null;const value=user[field];const text=formatter(value,user)??\"\";return /*#__PURE__*/_jsx(Component,{...props,text:text});};};}function renderWithVisibility(Component,props,isVisible){return isVisible?/*#__PURE__*/_jsx(Component,{...props}):hideComponent(Component,props);}function hideComponent(Component,props){const{style,...rest}=props;return /*#__PURE__*/_jsx(Component,{...rest,style:{...style??{},display:\"none\",opacity:0,pointerEvents:\"none\"}});}function withUserProperty(property,Component){return props=>{const user=useOutsetaUser();if(!user)return null;return /*#__PURE__*/_jsx(Component,{...props,text:user[property]});};}function withUserImageProperty(property,Component){return props=>{const user=useOutsetaUser();if(!user)return null;const imageSrc=user[property];if(imageSrc){return /*#__PURE__*/_jsx(Component,{...props,background:{...props.background,src:imageSrc,srcSet:undefined}});}if(props.background?.src){return /*#__PURE__*/_jsx(Component,{...props});}return null;};}export function showWithLinkedGarage61(Component){return props=>{const user=useOutsetaUser();const hasGarage61=!!user&&(!!user[\"Garage61Username\"]||!!user[\"Garage61Id\"]);return renderWithVisibility(Component,props,hasGarage61);};}export function showWithLinkediRacing(Component){return props=>{const user=useOutsetaUser();const hasiRacing=!!user&&(!!user[\"iRacingUsername\"]||!!user[\"iRacingId\"]);return renderWithVisibility(Component,props,hasiRacing);};}export function showWithLinkedDiscord(Component){return props=>{const user=useOutsetaUser();const hasDiscord=!!user&&(!!user[\"DiscordUsername\"]||!!user[\"DiscordId\"]);return renderWithVisibility(Component,props,hasDiscord);};}export function showWithLinkedGoogle(Component){return props=>{const user=useOutsetaUser();const hasGoogle=!!user&&!!user[\"GoogleId\"];return renderWithVisibility(Component,props,hasGoogle);};}export function withAccountName(Component){return withUserProperty(\"Account.Name\",Component);}export function withAccountSubscriptionUid(Component){return withUserProperty(\"Account.CurrentSubscription.Plan.Uid\",Component);}export function withAccountSubscriptionName(Component){return withUserProperty(\"Account.CurrentSubscription.Plan.Name\",Component);}export function withAccountSubscriptionDescription(Component){return withUserProperty(\"Account.CurrentSubscription.Plan.Description\",Component);}export function withGarage61Username(Component){return withUserProperty(\"Garage61Username\",Component);}export function withiRacingId(Component){return withUserProperty(\"iRacingId\",Component);}export function withiRacingUsername(Component){return withUserProperty(\"iRacingUsername\",Component);}export function withDiscordUsername(Component){return withUserProperty(\"DiscordUsername\",Component);}export function withDiscordHandle(Component){return props=>{const user=useOutsetaUser();if(!user)return null;const username=typeof user[\"DiscordUsername\"]===\"string\"?user[\"DiscordUsername\"].trim():\"\";const fallbackId=typeof user[\"DiscordId\"]===\"string\"?user[\"DiscordId\"].trim():\"\";const text=username||fallbackId;if(!text)return null;return /*#__PURE__*/_jsx(Component,{...props,text:text});};}export function withGoogleId(Component){return withUserProperty(\"GoogleId\",Component);}export function withGoogleEmail(Component){return withUserProperty(\"GoogleEmail\",Component);}export function withUserFirstName(Component){return withUserProperty(\"FirstName\",Component);}export function withUserLastName(Component){return withUserProperty(\"LastName\",Component);}export function withUserFullName(Component){return withUserProperty(\"FullName\",Component);}export function withUserEmail(Component){return withUserProperty(\"Email\",Component);}export function withUserAvatar(Component){return withUserImageProperty(\"ProfileImageS3Url\",Component);}export function withUserPhoneMobile(Component){return withUserProperty(\"PhoneMobile\",Component);}export function withUserPhoneWork(Component){return withUserProperty(\"PhoneWork\",Component);}export function withUserTimezone(Component){return withUserProperty(\"Timezone\",Component);}export function withUserMailingAddress(Component){return props=>{const user=useOutsetaUser();if(!user)return null;const personAddress=composeAddress(user,[\"MailingAddress.AddressLine1\",\"MailingAddress.AddressLine2\",\"MailingAddress.City\",\"MailingAddress.State\",\"MailingAddress.PostalCode\"]);const accountAddress=composeAddress(user,[\"Account.MailingAddress.AddressLine1\",\"Account.MailingAddress.AddressLine2\",\"Account.MailingAddress.City\",\"Account.MailingAddress.State\",\"Account.MailingAddress.PostalCode\"]);const text=personAddress||accountAddress||\"\";return /*#__PURE__*/_jsx(Component,{...props,text:text});};}export function withAccountBillingAddress(Component){return props=>{const user=useOutsetaUser();if(!user)return null;const text=composeAddress(user,[\"Account.BillingAddress.AddressLine1\",\"Account.BillingAddress.AddressLine2\",\"Account.BillingAddress.City\",\"Account.BillingAddress.State\",\"Account.BillingAddress.PostalCode\"]);return /*#__PURE__*/_jsx(Component,{...props,text:text});};}export function withAccountStage(Component){return withFormattedUserProperty(\"Account.AccountStage\",value=>{if(value===null||value===undefined)return\"\";return String(value);})(Component);}export function withAccountStageLabel(Component){return props=>{const user=useOutsetaUser();if(!user)return null;const{label}=getAccountStageInfo(user);return /*#__PURE__*/_jsx(Component,{...props,text:label});};}export function withAccountUid(Component){return withUserProperty(\"Account.Uid\",Component);}export function withAccountCreatedDate(Component){return withFormattedUserProperty(\"Account.Created\",value=>formatDateValue(value))(Component);}export function withAccountRenewalDate(Component){return withFormattedUserProperty(\"Account.CurrentSubscription.RenewalDate\",value=>formatDateValue(value))(Component);}export function withAccountPlanMonthlyRate(Component){return withFormattedUserProperty(\"Account.CurrentSubscription.Plan.MonthlyRate\",value=>formatCurrencyValue(value))(Component);}export function withAccountPlanAnnualRate(Component){return withFormattedUserProperty(\"Account.CurrentSubscription.Plan.AnnualRate\",value=>formatCurrencyValue(value))(Component);}export function withAccountBillingRenewalTerm(Component){return withFormattedUserProperty(\"Account.CurrentSubscription.BillingRenewalTerm\",value=>{const termNumber=typeof value===\"number\"?value:Number(value);return BILLING_RENEWAL_TERM_LABELS[termNumber]||\"\";})(Component);}export function withAccountCurrentAddOns(Component){return props=>{const user=useOutsetaUser();if(!user)return null;const addOns=Array.isArray(user.CurrentAddOnUids)?user.CurrentAddOnUids:[];const text=addOns.join(\", \");return /*#__PURE__*/_jsx(Component,{...props,text:text});};}export function withEmailOptInStatus(Component){return withFormattedUserProperty(\"OptInEmail\",value=>value?\"Subscribed\":\"Unsubscribed\")(Component);}export const showWhenEmailOptedIn=createVisibilityOverride(user=>!!user?.OptInEmail);export const showWhenEmailOptedOut=createVisibilityOverride(user=>!user?.OptInEmail);export const showWhenAccountIsTrialing=createVisibilityOverride(user=>getAccountStageInfo(user).number===2);export const showWhenAccountIsSubscribing=createVisibilityOverride(user=>getAccountStageInfo(user).number===3);export const showWhenAccountIsPastDue=createVisibilityOverride(user=>getAccountStageInfo(user).number===7);export const showWhenAccountIsCancelled=createVisibilityOverride(user=>getAccountStageInfo(user).number===5||getAccountStageInfo(user).number===4);export const showWhenHasPaidPlan=createVisibilityOverride(user=>!!user?.HasAnyPaidPlan);export const showWhenOnlyOnFreePlan=createVisibilityOverride(user=>!!user&&!!user.HasFreePlan&&!user.HasAnyPaidPlan);export const showWhenPasswordMustChange=createVisibilityOverride(user=>!!user?.PasswordMustChange);export const showWhenHasLinkedAccounts=createVisibilityOverride(user=>!!user?.Garage61Id||!!user?.iRacingId||!!user?.GoogleId||!!user?.DiscordUsername);\nexport const __FramerMetadata__ = {\"exports\":{\"withAccountSubscriptionDescription\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionDescription\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWithLinkedGoogle\":{\"type\":\"reactHoc\",\"name\":\"showWithLinkedGoogle\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withGarage61Username\":{\"type\":\"reactHoc\",\"name\":\"withGarage61Username\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenAccountIsPastDue\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserTimezone\":{\"type\":\"reactHoc\",\"name\":\"withUserTimezone\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenOnlyOnFreePlan\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserEmail\":{\"type\":\"reactHoc\",\"name\":\"withUserEmail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountUid\":{\"type\":\"reactHoc\",\"name\":\"withAccountUid\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWithLinkedGarage61\":{\"type\":\"reactHoc\",\"name\":\"showWithLinkedGarage61\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserFirstName\":{\"type\":\"reactHoc\",\"name\":\"withUserFirstName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withDiscordHandle\":{\"type\":\"reactHoc\",\"name\":\"withDiscordHandle\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserLastName\":{\"type\":\"reactHoc\",\"name\":\"withUserLastName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountName\":{\"type\":\"reactHoc\",\"name\":\"withAccountName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountCurrentAddOns\":{\"type\":\"reactHoc\",\"name\":\"withAccountCurrentAddOns\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountPlanAnnualRate\":{\"type\":\"reactHoc\",\"name\":\"withAccountPlanAnnualRate\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenAccountIsTrialing\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenEmailOptedOut\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withGoogleId\":{\"type\":\"reactHoc\",\"name\":\"withGoogleId\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserAvatar\":{\"type\":\"reactHoc\",\"name\":\"withUserAvatar\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionName\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withEmailOptInStatus\":{\"type\":\"reactHoc\",\"name\":\"withEmailOptInStatus\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withDiscordUsername\":{\"type\":\"reactHoc\",\"name\":\"withDiscordUsername\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenPasswordMustChange\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserPhoneMobile\":{\"type\":\"reactHoc\",\"name\":\"withUserPhoneMobile\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenHasPaidPlan\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenAccountIsSubscribing\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountStage\":{\"type\":\"reactHoc\",\"name\":\"withAccountStage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withiRacingUsername\":{\"type\":\"reactHoc\",\"name\":\"withiRacingUsername\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenEmailOptedIn\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withGoogleEmail\":{\"type\":\"reactHoc\",\"name\":\"withGoogleEmail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountBillingRenewalTerm\":{\"type\":\"reactHoc\",\"name\":\"withAccountBillingRenewalTerm\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenHasLinkedAccounts\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWithLinkedDiscord\":{\"type\":\"reactHoc\",\"name\":\"showWithLinkedDiscord\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWithLinkediRacing\":{\"type\":\"reactHoc\",\"name\":\"showWithLinkediRacing\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountCreatedDate\":{\"type\":\"reactHoc\",\"name\":\"withAccountCreatedDate\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountPlanMonthlyRate\":{\"type\":\"reactHoc\",\"name\":\"withAccountPlanMonthlyRate\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenAccountIsCancelled\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserFullName\":{\"type\":\"reactHoc\",\"name\":\"withUserFullName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountBillingAddress\":{\"type\":\"reactHoc\",\"name\":\"withAccountBillingAddress\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withiRacingId\":{\"type\":\"reactHoc\",\"name\":\"withiRacingId\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountRenewalDate\":{\"type\":\"reactHoc\",\"name\":\"withAccountRenewalDate\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserMailingAddress\":{\"type\":\"reactHoc\",\"name\":\"withUserMailingAddress\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountStageLabel\":{\"type\":\"reactHoc\",\"name\":\"withAccountStageLabel\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionUid\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionUid\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserPhoneWork\":{\"type\":\"reactHoc\",\"name\":\"withUserPhoneWork\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AccountManager.map"],"mappings":"gIACuL,SAAS,GAAgB,CAAC,GAAK,CAAC,EAAK,GAASA,EAAM,aAAa,GAAkB,EAAE,WAAW,EAAE,KAAK,CAA8K,OAA7K,EAAM,cAAc,CAAC,IAAM,EAAO,GAAkB,CAAC,GAAG,CAAC,GAAQ,UAAU,OAAO,IAAM,EAAY,EAAO,UAAU,GAAM,EAAQ,EAAK,CAAC,CAAC,UAAU,CAAC,KAAe,GAAK,EAAE,CAAC,CAAQ,EAAqvD,SAAS,EAAqB,EAAU,EAAM,EAAU,CAAC,OAAO,EAAuB,EAAK,EAAU,CAAC,GAAG,EAAM,CAAC,CAAC,EAAc,EAAU,EAAM,CAAE,SAAS,EAAc,EAAU,EAAM,CAAC,GAAK,CAAC,QAAM,GAAG,GAAM,EAAM,OAAoB,EAAK,EAAU,CAAC,GAAG,EAAK,MAAM,CAAC,GAAG,GAAO,EAAE,CAAC,QAAQ,OAAO,QAAQ,EAAE,cAAc,OAAO,CAAC,CAAC,CAAE,SAAS,EAAiB,EAAS,EAAU,C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