1import{r as m,f as ke,j as e}from"./vendor-react-C5PewRsl.js";import{gK as De,ck as en,g as Pe,d as ie,C as le,aj as Re,ag as ce,Y as nn,Z as an,gL as sn,Q as I,a1 as pe,a2 as ee,fF as xe,bd as fe,eo as ye,aD as Se,bo as tn,bm as ne,cu as rn,d4 as Oe,b8 as Le,a as _e,E as ae,ap as se,gM as Ae,gN as on,cD as ln,cE as cn,cF as de,cG as ue,cH as Ce,dM as me,at as g,a4 as $,cI as ge,ch as ze,i as Z,aG as Y,a0 as dn,e9 as ve,aA as re,e8 as je,gO as un,gh as Fe,ge as Me,cB as mn,fC as gn,fD as hn,fE as pn,cC as xn,dO as fn,g7 as yn,fJ as Be,e as K,fH as Ue,gP as Ge,gQ as W,co as bn,bN as vn,bO as jn,a8 as kn,a7 as Cn,b2 as wn,ac as Te,fl as En,gR as Nn,gS as In,bR as Sn,bT as On,ab as An}from"./main-DoxpiNgY.js";import{u as Tn}from"./useUserActions-B-mReVCv.js";import{u as Dn}from"./useEmailForwardingConnections-fHoNEjpk.js";import{u as Pn}from"./useHasEmailOrCalendarConnection-1oWzoJM-.js";import{u as Rn}from"./useIntegrationAccessGuard-DzM4Q1Tu.js";import{u as Ln,f as _n}from"./vendor-misc-DVk-0spb.js";import{s as zn,a as Fn,e as Mn}from"./index-FFROJYLR.js";import{S as Bn}from"./Select-BLE_rNy5.js";import{T as Un}from"./Textarea-DPee92Vl.js";import{i as Gn}from"./isOn2026PricingPackaging-BoexYMk1.js";import{P as Hn}from"./CheckoutSession-Uyh4QRnw.js";import{I as oe}from"./Input-D0OfI1DR.js";import{c as be}from"./vendor-sentry-SKD9L_Jy.js";import"./vendor-runtime-DG-GlVKR.js";import"./vendor-ui-BKWhI8D_.js";import"./vendor-icons-Nh3lIdcn.js";import"./vendor-analytics-aNB2-Vwh.js";import"./useConnectedMailboxLimit-BrXuCs1P.js";import"./pricing2026Copy-ClCi7IQW.js";import"./trials-CfKKyfjt.js";import"./connectedMailboxLimit-HTcz_Mju.js";import"./integrationSettingKey-wfe_NT02.js";try{let a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new a.Error().stack;r&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[r]="103d5b24-e80e-463f-84a4-3a438e5b35a5",a._sentryDebugIdIdentifier="sentry-dbid-103d5b24-e80e-463f-84a4-3a438e5b35a5")}catch{}const Yn=()=>{const{memberships:a}=De(),[r,p]=m.useState(!1),[d,u]=m.useState(!0),o=en(a.map(t=>t.data().organisationId)).join(",");return m.useEffect(()=>{let t=!1;u(!0);const l=o?o.split(","):[];return Promise.all(l.map(n=>Pe(ie(le.Organisation,n)))).then(n=>{t||(p(n.some(k=>Re(k.data()))),u(!1))}).catch(()=>{t||u(!1)}),()=>{t=!0}},[o]),{isEnterpriseMember:r,isLoading:d}},He=()=>{const a=ke(),r=ce();return Ln({mutationFn:async()=>{await r.account.delete(),await zn(Fn)},onSuccess:()=>{nn.session.string(an.ALGOLIA_SECURED_API_KEYS).remove(),sn(),I.info({title:"Account deleted",description:"Your account was deleted successfully"}),a("/auth/sign-up")}})},Wn=[{value:"not-satisfied-email-drafts",label:"Not satisfied with email drafts"},{value:"not-satisfied-email-org",label:"Not satisfied with email organization"},{value:"not-satisfied-meeting-notetaker",label:"Not satisfied with meeting notetaker"},{value:"issues-pricing",label:"Issues with pricing"},{value:"issues-teams-users",label:"Issues with teams & multiple users"},{value:"support-technical-issues",label:"I have a support or technical issue"},{value:"other",label:"Other"}],te=800,$n=()=>{const{memberships:a}=De(),[r,p]=m.useState(!1),[d,u]=m.useState(null),o=m.useCallback(async()=>{var R;p(!0);const l=Date.now(),n=Array.from(new Set(a.map(i=>i.data().organisationId).filter(i=>!!i)));if(n.length===0){const i={orgs:[],primaryBlocker:null,churnkeyOrg:null,warningOrgs:[],canProceed:!0},E=Date.now()-l;return E<te&&await new Promise(v=>setTimeout(v,te-E)),u(i),p(!1),i}const k=await Promise.all(n.map(async i=>{const E=pe(xe(ye,fe.MEMBERSHIP),ee("organisationId","==",i)),v=await Se(E);return[i,v.data().count]})),C=Object.fromEntries(k),c=[];for(const i of n)try{const E=await Pe(ie(le.Organisation,i));if(!E.exists())continue;const v=E.data(),z=(v==null?void 0:v.name)??"Unknown Organization",q=(R=v==null?void 0:v.stripe)==null?void 0:R.customerId,L=(await tn(pe(xe(ye,fe.SUBSCRIPTION),ee("organisationId","==",i)))).docs.find(G=>{const X=G.data();return![ne.CANCELLED,ne.DELETED].includes(X.status)}),s=L==null?void 0:L.data(),j=s?{status:s.status,seatCount:s.seatCount,customerId:q,subscriptionId:s.providerId,paymentProvider:s.paymentProvider,planId:s.planId}:null,T=a.find(G=>G.data().organisationId===i),P=T==null?void 0:T.data().role;if(!P)continue;const F=pe(xe(ye,fe.MEMBERSHIP),ee("organisationId","==",i),ee("role","in",rn())),M=(await Se(F)).data().count,N=Oe(P)&&M===1,D=C[i]??0,B=D>1,Q=j&&![ne.CANCELLED,ne.DELETED].includes(j.status),V=Re(v),he=(j==null?void 0:j.paymentProvider)===Hn.MICROSOFT;let O,U=null;V?(O="block",U="enterprise-managed"):Oe(P)?B&&N?(O="block",U="sole-admin-multi-seat"):!B&&Q&&!he?O="churnkey":B?O=Q?"warn-co-admin":"safe-leave":O="safe-leave":O="safe-leave",c.push({organisationId:i,name:z,role:P,memberCount:D,adminCount:M,subscription:j,action:O,blockingReason:U})}catch(E){console.error("Error analyzing organization:",i,E)}const h=c.filter(i=>i.action==="churnkey");if(h.length>1)for(const i of h)i.action="block",i.blockingReason="multiple-single-seat";const x=c.filter(i=>i.action==="block"),b=c.filter(i=>i.action==="warn-co-admin"),f=c.find(i=>i.action==="churnkey")??null,y=["enterprise-managed","sole-admin-multi-seat","multiple-single-seat","single-seat-active-subscription"],w=[...x].sort((i,E)=>{const v=i.blockingReason?y.indexOf(i.blockingReason):999,z=E.blockingReason?y.indexOf(E.blockingReason):999;return v-z}),H={orgs:c,primaryBlocker:w[0]??null,churnkeyOrg:x.length===0?f:null,warningOrgs:b,canProceed:x.length===0},_=Date.now()-l;return _<te&&await new Promise(i=>setTimeout(i,te-_)),u(H),p(!1),H}
1,[a]),t=m.useCallback(()=>{u(null)},[]);return{analyze:o,result:d,isLoading:r,reset:t}},S=({variant:a,...r})=>ze()?e.jsx(Z,{variant:a==="primary"?"primary":"outline",size:"md",...r}):e.jsx(Y,{variant:a,...r}),Kn=({deleteReason:a,otherText:r,onReasonChange:p,onOtherTextChange:d,onContinue:u,onCancel:o})=>{const t=a!==""&&(a!=="other"||r.trim().length>0);return e.jsxs(e.Fragment,{children:[e.jsxs(de,{children:[e.jsx(ue,{children:"We're sorry to see you go"}),e.jsx(Ce,{children:"Before you leave, help us understand what we could do better."})]}),e.jsx(me,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Bn,{label:"What's your main reason for leaving?",options:Wn,value:a,onChange:l=>p(l),placeholder:"Select a reason..."}),a==="other"&&e.jsx(Un,{value:r,onChange:l=>d(l.target.value),placeholder:"What could we have done differently?",rows:3})]})}),e.jsxs(ge,{children:[e.jsx(S,{variant:"secondary",label:"Cancel",onClick:o}),e.jsx(S,{variant:"primary",label:"Continue",icon:"ArrowRight",iconDir:"right",onClick:u,disabled:!t})]})]})},qn=()=>e.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[e.jsx("div",{className:"relative mb-5",children:e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-[3px] border-rb-gray-neutral border-t-rb-black"})}),e.jsx(g,{level:"h4",weight:500,children:"Checking your account..."}),e.jsx(g,{level:"p",color:"secondary-dark",className:"mt-1",children:"This will only take a moment"})]}),Qn=({blocker:a,remainingBlockers:r,onRecheck:p,onCancel:d,onSupport:u})=>{const o=ke(),l=(()=>{switch(a.blockingReason){case"sole-admin-multi-seat":return{title:"One thing to resolve",description:`You're the only admin of ${a.name}, which has ${a.memberCount-1} other team member${a.memberCount-1===1?"":"s"}.`,explanation:"To protect your team's access, please either promote another admin or remove team members first.",actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{variant:"secondary",icon:"Users",iconDir:"left",label:"Manage Team",onClick:()=>{d(),o(`/org/${a.organisationId}/settings/team`)}}),e.jsx(S,{variant:"secondary",icon:"CurrencyCircleDollar",iconDir:"left",label:"Cancel Subscription",onClick:()=>{d(),o(`/org/${a.organisationId}/settings/billing`)}})]})};case"multiple-single-seat":return{title:"Multiple subscriptions found",description:"You have active subscriptions on multiple organizations that need to be cancelled individually.",explanation:"Please cancel your subscription for each organization from their billing settings before deleting your account.",actions:e.jsx(S,{variant:"secondary",icon:"CurrencyCircleDollar",iconDir:"left",label:`Go to ${a.name} Billing`,onClick:()=>{d(),o(`/org/${a.organisationId}/settings/billing`)}})};case"single-seat-active-subscription":return{title:"Active subscription",description:`Your subscription for ${a.name} needs to be cancelled first.`,explanation:"Please cancel your subscription from the billing settings before deleting your account.",actions:e.jsx(S,{variant:"secondary",icon:"CurrencyCircleDollar",iconDir:"left",label:"Cancel Subscription",onClick:()=>{d(),o(`/org/${a.organisationId}/settings/billing`)}})};case"enterprise-managed":return{title:"Your account is managed by your organization",description:`${a.name} is an enterprise organization, so accounts can't be deleted here.`,explanation:"Please get in touch with your Fyxer Account Manager or with Fyxer Support.",actions:null};default:return{title:"Unable to delete account",description:"There's an issue preventing account deletion.",explanation:"Please contact support for assistance.",actions:null}}})();return e.jsxs(e.Fragment,{children:[e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-rb-orange-neutral/10",children:e.jsx($,{name:"WarningDiamond",size:18,color:"orange"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(ue,{children:l.title}),r>0&&e.jsxs(g,{level:"label",color:"secondary-dark",className:"mt-0.5",children:["+",r," more issue",r===1?"":"s"," to resolve"]})]})]})}),e.jsx(me,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-rb-gray-neutral bg-rb-parchment p-4",children:[e.jsx(g,{level:"h4",weight:500,children:a.name}),e.jsx(g,{level:"p",color:"secondary-dark",className:"mt-1",children:l.description}),e.jsx(g,{level:"p",color:"secondary-dark",className:"mt-2",children:l.explanation})]}),l.actions&&e.jsx("div",{children:l.actions}),e.jsxs(g,{level:"p",color:"secondary-dark",className:"text-center",children:["Have questions?"," ",e.jsx("button",{onClick:u,className:"text-rb-black underline underline-offset-2 hover:no-underline",children:"Talk to support"})]})]})}),e.jsxs(ge,{children:[e.jsx(S,{variant:"secondary",label:"Cancel",onClick:d}),e.jsx(S,{variant:"secondary",label:"Check Again",icon:"ArrowClockwise",iconDir:"right",onClick:p})]})]})},Vn=({org:a,warningOrgs:r,onContinue:p,onCancel:d,onBack:u})=>{var o,t;return e.jsxs(e.Fragment,{children:[e.jsxs(de,{children:[e.jsx(ue,{children:"Before you go..."}),e.jsx(Ce,{children:"We'd love the chance to make things right before you leave."})]}),e.jsx(me,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"rounded-lg border border-rb-orange-neutral/30 bg-rb-orange-neutral/5 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-rb-orange-neutral/10",children:e.jsx($,{name:"CurrencyCircleDollar",size:18,color:"orange"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(g,{level:"h4",weight:500,children:a.name}),e.jsxs(g,{level:"label",color:"orange",children:[((o=a.subscription)==null?void 0:o.seatCount)??1," seat",(((t=a.subscription)==null?void 0:t.seatCount)??1)===1?"":"s"," · Will be cancelled"]})]})]})}),r.length>0&&e.jsx("div",{className:"rounded-lg border border-rb-gray-neutral bg-rb-parchment p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx($,{name:"Info",size:16,color:"secondary-dark",className:"mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx(g,{level:"h4",weight:500,children:"Other organizations"}),e.jsxs(g,{level:"p",color:"secondary-dark",className:"mt-0.5",children:["You'll leave ",r.map(l=>
1l.name).join(", ")," but their subscriptions will stay active under other admins."]})]})]})})]})}),e.jsxs(ge,{children:[e.jsx(S,{variant:"secondary",label:"Back",icon:"ArrowLeft",iconDir:"left",onClick:u,className:"mr-auto"}),e.jsx(S,{variant:"secondary",label:"Cancel",onClick:d}),e.jsx(S,{variant:"primary",label:"Continue",icon:"ArrowRight",iconDir:"right",onClick:p})]})]})},Zn=({warningOrgs:a,hasChurnkeyOrg:r,onConfirm:p,onCancel:d,onBack:u,isDeleting:o})=>e.jsxs(e.Fragment,{children:[e.jsxs(de,{children:[e.jsx(ue,{children:"Ready to delete your account"}),e.jsx(Ce,{children:"This action is permanent and cannot be undone."})]}),e.jsx(me,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-rb-gray-neutral bg-rb-parchment p-4",children:[e.jsx(g,{level:"h4",weight:500,children:"You'll lose access to:"}),e.jsx("ul",{className:"mt-2 space-y-1.5",children:["All your organizations","Email drafts and preferences","Meeting notes and recordings"].map(t=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-1 w-1 rounded-full bg-rb-secondary-dark"}),e.jsx(g,{level:"p",color:"secondary-dark",children:t})]},t))})]}),a.length>0&&e.jsx("div",{className:"rounded-lg border border-rb-gray-neutral bg-rb-parchment p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx($,{name:"Info",size:16,color:"secondary-dark",className:"mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx(g,{level:"h4",weight:500,children:"Other organizations"}),e.jsxs(g,{level:"p",color:"secondary-dark",className:"mt-0.5",children:["You'll leave ",a.map(t=>t.name).join(", ")," but their subscriptions will stay active under other admins."]})]})]})}),e.jsx(g,{level:"p",color:"secondary-dark",children:"You can create a new account later, but you'll need to be re-invited to any teams."})]})}),e.jsxs(ge,{children:[!r&&e.jsx(S,{variant:"secondary",label:"Back",icon:"ArrowLeft",iconDir:"left",onClick:u,className:"mr-auto"}),e.jsx(S,{variant:"secondary",label:"Cancel",onClick:d,disabled:o}),e.jsx(S,{variant:"primary",label:o?"Deleting...":"Delete Account",onClick:p,disabled:o,className:"bg-red-500 hover:bg-red-600"})]})]}),Jn=({isOpen:a,onClose:r})=>{var L;const p=ce(),{userId:d}=Le(),{logButtonPress:u,logEvent:o}=_e(),t=He(),{analyze:l,result:n,isLoading:k,reset:C}=$n(),[c,h]=m.useState("intent"),[x,b]=m.useState(""),[f,y]=m.useState("");m.useEffect(()=>{if(!a){const s=setTimeout(()=>{h("intent"),b(""),y(""),C()},200);return()=>clearTimeout(s)}},[a,C]),m.useEffect(()=>{a&&c!=="analyzing"&&c!=="deleting"&&o(ae.VIEW_PAGE,{page:`delete_account_wizard_${c}`,deleteReason:x||void 0,hasBlocker:(n==null?void 0:n.primaryBlocker)!==null,hasChurnkeyOrg:(n==null?void 0:n.churnkeyOrg)!==null})},[c,a,o,x,n]);const w=m.useCallback(async()=>{u(se.DELETE_ACCOUNT,{step:"intent_continue",deleteReason:x,otherText:f||void 0,userId:d}),h("analyzing");try{const s=await l();!s.canProceed&&s.primaryBlocker?h("blocker"):s.churnkeyOrg?h("churnkey-handoff"):h("confirm")}catch(s){console.error("Account analysis failed",s),I.error({title:"Something went wrong",description:"Please try again or contact support."}),h("intent")}},[l,x,u,f,d]),H=m.useCallback(async()=>{u(se.DELETE_ACCOUNT,{step:"recheck",userId:d}),h("analyzing");try{const s=await l();!s.canProceed&&s.primaryBlocker?h("blocker"):s.churnkeyOrg?h("churnkey-handoff"):h("confirm")}catch(s){console.error("Account recheck failed",s),I.error({title:"Something went wrong",description:"Please try again or contact support."}),h("intent")}},[l,u,d]),_=m.useCallback(()=>{var s,j,T;o(ae.DELETE_WIZARD_SUPPORT_REQUEST,{organisationId:((s=n==null?void 0:n.primaryBlocker)==null?void 0:s.organisationId)??null,blockingReason:(j=n==null?void 0:n.primaryBlocker)==null?void 0:j.blockingReason}),Ae({organisationId:((T=n==null?void 0:n.primaryBlocker)==null?void 0:T.organisationId)??void 0}),r()},[o,r,n==null?void 0:n.primaryBlocker]),R=m.useCallback(async()=>{var P;const s=n==null?void 0:n.churnkeyOrg;if(!s||!((P=s.subscription)!=null&&P.customerId))return!1;if(!window.churnkey)return console.error("ChurnKey script not loaded"),I.error({title:"Unable to load cancellation flow",de
1scription:"Please try again or contact support."}),!1;const j=Mn().CHURNKEY_APP_ID,T=on();try{const F=await p.churnkey.getAuthHash(s.organisationId);return o(ae.CANCEL_FLOW_TRIGGERED,{source:"delete_wizard",organisationId:s.organisationId,subscriptionId:s.subscription.subscriptionId,seatCount:s.subscription.seatCount??null,reason:x}),s.subscription.subscriptionId&&p.organisations.id(s.organisationId).cancellationIntent.send({orgName:s.name,subscriptionId:s.subscription.subscriptionId,seatCount:s.subscription.seatCount??0,cancellationContext:null,source:"delete-wizard",reason:x,reasonDetail:f||null,csmName:null,csmEmail:null,hubspotUrl:null,adminUserEmail:null,stripeSubscriptionId:s.subscription.subscriptionId??null}).catch(()=>{}),window.churnkey.init("show",{appId:j,provider:"stripe",mode:T,customerId:s.subscription.customerId,subscriptionId:s.subscription.subscriptionId,authHash:F,customerAttributes:{...s.subscription.seatCount!==void 0?{stripe_item_quantity:s.subscription.seatCount}:{},cancellation_source:"Delete Button",pricing_packaging_2026:Gn(s.subscription)},onCancel:(A,M)=>{var N,D;(D=(N=window.churnkey)==null?void 0:N.hide)==null||D.call(N),t.isPending||t.mutate(void 0,{onError:()=>{I.error({title:"Failed to delete account",description:"Please try again or contact support."}),h("confirm")}})},handleSupportRequest:A=>{var N,D;const M=typeof A=="string"?A:A==null?void 0:A.id;o(ae.CHURNKEY_SUPPORT_REQUEST,{source:"delete_wizard_churnkey",customerId:M,organisationId:s.organisationId}),Ae({organisationId:s.organisationId}),(D=(N=window.churnkey)==null?void 0:N.hide)==null||D.call(N)}}),!0}catch(F){return console.error("Error initializing ChurnKey",F),I.error({title:"Unable to process account deletion",description:"Please try again or contact support."}),!1}},[p,t,x,o,f,n==null?void 0:n.churnkeyOrg]),i=m.useCallback(async()=>{var j;u(se.DELETE_ACCOUNT,{step:"churnkey_continue",userId:d,organisationId:(j=n==null?void 0:n.churnkeyOrg)==null?void 0:j.organisationId}),await R()&&r()},[R,u,r,(L=n==null?void 0:n.churnkeyOrg)==null?void 0:L.organisationId,d]),E=m.useCallback(()=>{u(se.DELETE_ACCOUNT,{step:"confirm_delete",deleteReason:x,otherText:f||void 0,userId:d,hadChurnkeyOrg:(n==null?void 0:n.churnkeyOrg)!==null}),h("deleting"),t.mutate(void 0,{onError:()=>{I.error({title:"Failed to delete account",description:"Please try again or contact support."}),h("confirm")}})},[t,x,u,f,n==null?void 0:n.churnkeyOrg,d]),v=m.useCallback(()=>{(c==="churnkey-handoff"||c==="confirm")&&h("intent")},[c]),z=m.useMemo(()=>{if(!n)return 0;const s=n.orgs.filter(j=>j.action==="block");return Math.max(0,s.length-1)},[n]);m.useEffect(()=>{(c==="blocker"&&!(n!=null&&n.primaryBlocker)||c==="churnkey-handoff"&&!(n!=null&&n.churnkeyOrg))&&h("confirm")},[c,n]);const q=()=>{switch(c){case"intent":return e.jsx(Kn,{deleteReason:x,otherText:f,onReasonChange:b,onOtherTextChange:y,onContinue:w,onCancel:r});case"analyzing":return e.jsx(qn,{});case"blocker":return n!=null&&n.primaryBlocker?e.jsx(Qn,{blocker:n.primaryBlocker,remainingBlockers:z,onRecheck:H,onCancel:r,onSupport:_}):null;case"churnkey-handoff":return n!=null&&n.churnkeyOrg?e.jsx(Vn,{org:n.churnkeyOrg,warningOrgs:n.warningOrgs,onContinue:i,onCancel:r,onBack:v}):null;case"confirm":case"deleting":return e.jsx(Zn,{warningOrgs:(n==null?void 0:n.warningOrgs)??[],hasChurnkeyOrg:(n==null?void 0:n.churnkeyOrg)!==null,onConfirm:E,onCancel:r,onBack:v,isDeleting:c==="deleting"||t.isPending});default:return null}},J=m.useCallback(s=>{!s&&(k||c==="deleting"||t.isPending)||s||r()},[k,r,c,t.isPending]);return e.jsx(ln,{open:a,onOpenChange:J,children:e.jsx(cn,{showCloseButton:c!=="analyzing"&&c!=="deleting"&&!t.isPending,children:q()})})};var Ye=(a=>(a.GRANTED="granted",a))(Ye||{});const We=({userId:a,threadStyle:r})=>{const p=ce(),[d,u]=m.useState(null),[o,t]=m.useState(!1);m.useEffect(()=>{if(!a)return;const b=dn(ie(le.ImpersonationConsent,a),f=>{const y=f.data(),w=(y==null?void 0:y.status)===Ye.GRANTED&&(y==null?void 0:y.expireAt)instanceof Date&&y.expireAt.getTime()>Date.now();u(w?y.expireAt:null)},f=>{be(f,{tags:{feature:"impersonation-consent"}}),u(null)});return()=>b()},[a]);const l=d!==null,n=async()=>{t(!0);try{await p.impersonationConsent.grant(),I.info({title:"Access granted"})}catch(b){be(b,{tags:{feature:"impersonation-consent"}}),I.error({title:"Something went wrong",description:"We couldn't grant support access. Please try again."})}finally{t(!1)}},k=async()=>{t(!0);try{await p.impersonationConsent.revoke(),I.info({title:"Access revoked"})}catch(b){be(b,{tags:{feature:"impersonation-consent"}}),I.error({title:"Something went wrong",description:"We couldn't revoke support access. Please try again."})}finally{t(!1)}},C="Give Fyxer access to your account",c=l?`Fyxer can currently access your account. Access will expire on ${_n(d,"PPP 'at' p")}. You can revoke it at any time.`:"We may need temporary access to your account to diagnose and resolve support issues. This will give Fyxer access to your account for 5 days, after which access will expire automatically. You can manually revoke access at any time.",h=l?"Revoke Access":"Grant Access",x=l?k:n;return r?e.jsxs(re,{children:[e.jsx(je,{title:C}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(g,{level:"p",color:"primary-dark",children:c}),e.jsx(Z,{variant:l?"outline":"primary",size:"md",label:h,disabled:o,onClick:x})]})]}):e.jsx(ve,{title:C,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(g,{level:"p",color:"primary-dark",children:c}),e.jsx(Y,{variant:l?"secondary":"primary",label:h,disabled:o,onClick:x})]})})},$e=({checked:a,disabled:r,lockedBy:p,onPersonalChange:d,showOrgControl:u,orgEnforced:o,onOrgEnforcedChange:t,organisationName:l,threadStyle:n})=>{const k=f=>n?e.jsx(Fe,{className:"mt-px",...f}):e.jsx(Me,{...f}),C="Allow Fyxer to use my data to train and improve its AI models",c="Helps us tailor and improve the product for you.",h=`Opt everyone in ${l} out of model training`,x="All members will be opted out of model training while it's enforced.",b=n?"flex items-start gap-3":"flex items-center gap-3";return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:b,children:[k({checked:a,onChecked:d,disabled:r,"aria-label":C}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx(g,{level:"p",color:"primary-dark",children:C}),e.jsx(g,{level:"label",color:"secondary-dark",children:c}),p&&e.jsx(g,{level:"label",color:"secondary-dark",children:p}),e.jsx(un,{className:"mt-1 text-xs text-rb-secondary-dark underline underline-offset-2 hover:text-rb-darkbtn"})]})]}),u&&e.jsxs("div",{className:b,children:[k({checked:o,onChecked:t,"aria-label":h}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx(g,{level:"p",color:"primary-dark",children:h}),e.jsx(g,{level:"label",color:"secondary-dark",children:x})]})]})]})},Xn=({formName:a,setFormName:r,email:p,formMarketingConsent:d,setFormMarketingConsent:u,modelTraining:o,isSaving:t,handleSave:l,showConnectPrompt:n,showGmail:k,showOutlook:C,connectIntegration:c,showEmailForwardingCta:h,hasExistingForwardingConnection:x,canCloseA
1ccount:b,handleDeleteClick:f,userId:y})=>e.jsxs(mn,{className:"h-full",children:[e.jsxs(gn,{children:[e.jsx(hn,{children:"Your profile"}),e.jsx(pn,{children:e.jsx(Y,{variant:"primary",label:t?"Saving...":"Save changes",onClick:l,disabled:t})})]}),e.jsx(xn,{children:e.jsxs("div",{className:"mx-auto max-w-2xl space-y-4",children:[n&&e.jsx(fn,{className:"border-rb-orange-neutral/20 bg-rb-orange-neutral/5",children:e.jsx(yn,{children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 rounded-md bg-rb-orange-neutral/10 p-2",children:e.jsx($,{name:"Envelope",size:18,color:"orange"})}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[e.jsx(g,{level:"h4",weight:500,color:"orange",children:"Connect your email to unlock Fyxer AI"}),e.jsx(g,{level:"p",className:"text-rb-orange-neutral/80",children:"Organize your inbox, get highâquality draft replies, and make scheduling effortless."}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[k&&e.jsx(Y,{variant:"secondary",onClick:()=>c(K.GMAIL),label:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("img",{src:Be,className:"size-5",alt:""})," Gmail"]})}),C&&e.jsx(Y,{variant:"secondary",onClick:()=>c(K.MICROSOFT_OUTLOOK_EMAIL),label:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("img",{src:Ue,className:"size-5",alt:""})," Outlook"]})})]})]})]})})}),(h||x)&&e.jsx(Ge,{}),e.jsx(ve,{title:"Your Account",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(oe,{label:"Name",value:a,onChange:w=>r(w.target.value)}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(oe,{label:"Email",value:p,disabled:!0}),b&&e.jsx(g,{level:"label",color:"secondary-dark",children:"To change your email, create another account and delete this one."})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[e.jsx(Me,{checked:d===W.ACCEPTED,onChecked:w=>u(w?W.ACCEPTED:W.DECLINED)}),e.jsx(g,{level:"p",color:"primary-dark",children:"Receive news of product updates and promotions"})]}),e.jsx($e,{...o,threadStyle:!1})]})}),b&&e.jsx(ve,{title:"Account options",children:e.jsxs(g,{level:"p",color:"secondary-dark",children:["Need to make changes to your account? We can help with plan updates, pauses, and data questions. You can also"," ",e.jsx(Y,{variant:"plain",label:"close your account",textColor:"secondary-dark",onClick:f,className:"h-auto px-0 py-0 underline underline-offset-2"}),"."]})}),y&&e.jsx(We,{userId:y,threadStyle:!1})]})})]}),ea=({formName:a,setFormName:r,email:p,formMarketingConsent:d,setFormMarketingConsent:u,modelTraining:o,isSaving:t,handleSave:l,showConnectPrompt:n,showGmail:k,showOutlook:C,connectIntegration:c,showEmailForwardingCta:h,hasExistingForwardingConnection:x,canCloseAccount:b,handleDeleteClick:f,userId:y})=>e.jsxs("div",{className:"flex min-h-full flex-col bg-rb-canvas",children:[e.jsx("div",{className:"sticky top-0 z-20 shrink-0 bg-rb-canvas px-4 pt-4 pb-3 sm:px-6 sm:pt-6 sm:pb-4 xl:px-8",children:e.jsx(bn,{title:"Manage your account",actions:e.jsx(Z,{variant:"primary",size:"md",label:t?"Saving...":"Save changes",onClick:l,disabled:t})})}),e.jsx("div",{className:"px-4 pb-4 sm:px-6 sm:pb-6 xl:px-8",children:e.jsxs("div",{className:"mx-auto w-full max-w-2xl space-y-4",children:[n&&e.jsx(re,{className:"border-rb-orange-neutral/20 bg-rb-orange-neutral/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 rounded-md bg-rb-orange-neutral/10 p-2",children:e.jsx($,{name:"Envelope",size:18,color:"orange"})}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[e.jsx(g,{level:"h4",weight:500,color:"orange",children:"Connect your email to unlock Fyxer AI"}),e.jsx(g,{level:"p",className:"text-rb-orange-neutral/80",children:"Organize your inbox, get highâquality draft replies, and make scheduling effortless."}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[k&&e.jsx(Z,{variant:"outline",size:"md",onClick:()=>c(K.GMAIL),label:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("img",{src:Be,className:"size-5",alt:""})," Gmail"]})}),C&&e.jsx(Z,{variant:"outline",size:"md",onClick:()=>c(K.MICROSOFT_OUTLOOK_EMAIL),label:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("img",{src:Ue,className:"size-5",alt:""})," Outlook"]})})]})]})]})}),(h||x)&&e.jsx(Ge,{}),e.jsxs(re,{children:[e.jsx(je,{title:"Your Account"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(oe,{label:"Name",value:a,onChange:w=>r(w.target.value)}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(oe,{label:"Email",value:p,disabled:!0}),b&&e.jsx(g,{level:"label",color:"secondary-dark",children:"To change your email, create another account and delete this one."})]}),e.jsxs("div",{className:"flex items-start gap-3 pt-2",children:[e.jsx(Fe,{className:"mt-px",checked:d===W.ACCEPTED,onChecked:w=>u(w?W.ACCEPTED:W.DECLINED)}),e.jsx(g,{level:"p",color:"primary-dark",children:"Receive news of product updates and promotions"})]}),e.jsx($e,{...o,threadStyle:!0})]})]}),b&&e.jsxs(re,{children:[e.jsx(je,{title:"Account options"}),e.jsxs(g,{level:"p",color:"secondary-dark",children:["Need to make changes to your account? We can help with plan updates, pauses, and data questions. You can also"," ",e.jsx("button",{type:"button",onClick:f,className:"underline underline-offset-2",children:"close your account"}),"."]})]}),y&&e.jsx(We,{userId:y,threadStyle:!0})]})})]}),na="Your browser's Global Privacy Control setting turned this off for you.",Ea=()=>{var Ne,Ie;vn(jn.PROFILE);const{logFormSubmit:a}=_e(),r=ke(),[p,d]=m.useState(!1),u=ze(),{user:o,userId:t}=Le(),{organisationId:l,userMembership:n,organisation:k,isAdmin:C}=kn(),c=ce(),{canEdit:h,getLockedBy:x,resolved:b}=Cn(),{isEnterpriseMember:f,isLoading:y}=Yn(),w=!y&&!f,{data:H}=Pn(t),{isConnectionAllowed:_}=Rn(),R=_(K.GMAIL),i=_(K.MICROSOFT_OUTLOOK_EMAIL),v=H===!1&&!!t&&(R||i),z=wn({isEligible:v}),{activeForCurrentUser:q,pendingForCurrentUser:J}=Dn(),L=!!q||!!J,{name:s,email:j,marketingConsentStatus:T}=o,{update:P}=Tn(),F=He(),[A,M]=m.useState(s),[N,D]=m.useState(T),[B,Q]=m.useState((n==null?void 0:n.data().isModelTrainingAllowed)??!0),V=h("modelTraining"),he=V?B:((Ne=b.modelTraining)==null?void 0:Ne.value)??B,O=(Ie=k.managedSettings)==null?void 0:Ie.modelTraining,U=(O==null?void 0:O.controlMode)===Te.ORGANISATION_LOCKED&&O.value===!1,[G,X]=m.useState(U),[Ke,qe]=m.useState(n==null?void 0:n.id);(n==null?void 0:n.id)!==Ke&&(qe(n==null?void 0:n.id),Q((n==null?void 0:n.data().isModelTrainingAllowed)??!0),X(U));const[Qe,we]=m.useState(!1),Ve=Xe=>{r(`/org/${l}/connect/${Xe}`)},Ze=m.useCallback(()=>{d(!0)},[]),Je=async()=>
1{if(In(A)){I.error({title:"Invalid name",description:"URLs are not allowed in names"});return}we(!0);try{a(Sn.UPDATE_PROFILE),await P({name:A,email:j,marketingConsentStatus:N}),n&&V&&await On(ie(le.Membership,n.id),{isModelTrainingAllowed:B}),C&&G!==U&&await(G?c.organisations.id(l).managedSettings.put("modelTraining",{controlMode:Te.ORGANISATION_LOCKED,visibility:An.VISIBLE,value:!1}):c.organisations.id(l).managedSettings.delete("modelTraining")),I.info({title:"Profile updated",description:"Your edits were saved successfully"})}catch{I.error({title:"Error",description:"Failed to update profile"})}finally{we(!1)}};if(F.isPending)return e.jsx(En,{});const Ee={formName:A,setFormName:M,email:j,formMarketingConsent:N,setFormMarketingConsent:D,modelTraining:{checked:he,disabled:!V,lockedBy:x("modelTraining")??(Nn()?na:void 0),onPersonalChange:Q,showOrgControl:C,orgEnforced:G,onOrgEnforcedChange:X,organisationName:k.name},isSaving:Qe,handleSave:Je,showConnectPrompt:v,showGmail:R,showOutlook:i,connectIntegration:Ve,showEmailForwardingCta:z,hasExistingForwardingConnection:L,canCloseAccount:w,handleDeleteClick:Ze,userId:t};return e.jsxs(e.Fragment,{children:[u?e.jsx(ea,{...Ee}):e.jsx(Xn,{...Ee}),e.jsx(Jn,{isOpen:p,onClose:()=>d(!1)})]})};export{Ea as ProfileRoute};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.