PageSourceSearch

https://calabash.app/assets/EnterprisePortalGate-C_C-yV5y.js

js calabash.app collected 2026-10-04 08:05:01 UTC 4,778 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PortalLanding-DANBJmmu.js","assets/index-DyMEJKlS.js","assets/syncfusion-charts-DlApThQX.js","assets/index-DiU7DONS.css","assets/ForgotPasswordForm-BbgxLXAE.js","assets/auth-retry-5CUh5m4w.js","assets/input-rdMtSQPj.js","assets/password-input-BHUBlb0F.js","assets/check-CgDD1As6.js","assets/lock-BYH4eWQF.js","assets/eye-off-DSPLCM4q.js","assets/eye-B6bBOq2L.js","assets/label-ClVmu0SU.js","assets/ReCaptchaV2-5o_oUKYe.js","assets/recaptcha-loader-BTQEDyfk.js","assets/circle-check-big-DoZsDENA.js","assets/recaptcha-Ddje9DpL.js","assets/useTenantPortalBranding-CLHjzoOY.js","assets/tenant-supplier-branding-6DtX88Fj.js","assets/building-2-DjOoXQ9-.js","assets/loader-circle-Cnqj8Yqk.js","assets/page-loading-skeleton-4D6bqyxN.js","assets/skeleton-SzYbfBe8.js"])))=>i.map(i=>d[i]);
2import{s as p,r as j,a5 as k,m as b,a4 as z,n as L,b as q,a8 as F,bl as w,bm as B,bn as x,bo as V,bh as T,a2 as $,j as d,$ as E,bp as N,bq as K,br as Y,_ as H}from"./index-DyMEJKlS.js";import{k as e}from"./syncfusion-charts-DlApThQX.js";import{P as A}from"./page-loading-skeleton-4D6bqyxN.js";const W=L("useRepAuth");async function M(t){const{data:g,error:s}=await p.from("sales_reps").select("id, name, email, timezone, is_manager, referral_code").eq("user_id",t.id).eq("is_active",!0).maybeSingle();if(s)throw s;if(g){const l=g;return{...l,referral_code:l.referral_code??null,isManager:!!l.is_manager}}if(!t.email)return null;const a=t.email.toLowerCase(),{data:o,error:f}=await p.from("sales_reps").select("id, name, email, timezone, is_manager, referral_code").is("user_id",null).eq("is_active",!0);if(f)throw f;const c=(o==null?void 0:o.find(l=>l.email.toLowerCase()===a))??null;return c?{...c,referral_code:c.referral_code??null,isManager:!!c.is_manager}:null}const J=e.createContext(null);function ae(){const t=e.useContext(J);if(!t)throw new Error("useRepIdentity must be used inside RepAuthGuard");return t}function ne(){const[t,g]=e.useState(null),[s,a]=e.useState(null),[o,f]=e.useState(!0),c=j();e.useEffect(()=>{let n=!1;const _=async r=>{if(!r){n||(a(null),f(!1));return}try{const u=await M(r);n||a(u)}catch(u){W.error("Error resolving sales rep identity:",u),n||a(null)}finally{n||f(!1)}},{data:{subscription:m}}=p.auth.onAuthStateChange((r,u)=>{if(g((u==null?void 0:u.user)??null),u!=null&&u.user){const R=u.user;setTimeout(()=>{_(R)},0)}else a(null)});return p.auth.getSession().then(({data:{session:r}})=>{g((r==null?void 0:r.user)??null),_((r==null?void 0:r.user)??null)}),()=>{n=!0,m.unsubscribe()}},[]);const l=async()=>{try{localStorage.removeItem(k),await p.auth.signOut(),a(null),c("/auth?mode=signin"),b.success("Signed out successfully")}catch(n){b.error("Error signing out",{description:z(n)})}};return{user:t,rep:s,repId:(s==null?void 0:s.id)??null,loading:o,isRep:!!s,signOut:l}}const Q=e.lazy(()=>H(()=>import("./PortalLanding-DANBJmmu.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),X=L("EnterprisePortalGate");function Z({module:t,tenantSubdomain:g}){var U;const{loading:s,isAuthenticated:a,user:o}=q(),f=j(),[c,l]=F(),n=e.useRef(c.get(w)===B).current,_=e.useRef(c.get(x)===V).current,[m]=e.useState(()=>{const i=new URLSearchParams(c);return i.delete(w),i.delete(x),i.toString()}),[r,u]=e.useState(n),R=n||_,[h,C]=e.useState(!n),y=e.useRef(l);y.current=l;const P=e.useRef(!1);e.useEffect(()=>{if(!R||s||P.current)return;P.current=!0;let i=!1;return(async()=>{if(n&&a)try{const{error:S}=await p.auth.signOut({scope:"local"});S&&localStorage.removeItem(T)}catch{try{localStorage.removeItem(T)}catch{}}i||(y.current(new URLSearchParams(m),{replace:!0}),u(!1))})(),()=>{i=!0}},[n,R,a,s,m]),e.useEffect(()=>{h||r||a||C(!0)},[r,a,h]);const v=!t&&a&&h&&!s&&!r,O=e.useRef(!1),[G,D]=e.useState(!1);if(e.useEffect(()=>{if(!v||O.current||!o)return;O.current=!0;let i=!1;return(async()=>{try{const S=await M(o).catch(()=>null);if(i)return;if(S){f("/rep",{replace:!0});return}await $(o.id,f)}catch(S){if(i)return;X.error("Could not resolve the tenant root destination:",S),b.error("Unable to open your workspace",{description:S instanceof Error?S.message:"We could not verify your workspace access. Please sign in again."}),D(!0)}})(),()=>{i=!0}},[f,v,o]),s||r)return d.jsx(A,{});if(G)return d.jsx(E,{to:N(t),replace:!0});if(a&&h)return t?d.jsx(E,{to:K[t],replace:!0}):d.jsx(A,{});const I=g??((U=Y())==null?void 0:U.tenantSubdomain)??null;return I?d.jsx(e.Suspense,{fallback:d.jsx(A,{}),children:d.jsx(Q,{module:t,subdomain:I,justSignedOut:n,signOutUnconfirmed:_})}):d.jsx(E,{to:N(t),replace:!0})}const se=Object.freeze(Object.defineProperty({__proto__:null,EnterprisePortalGate:Z},Symbol.toStringTag,{value:"Module"}));
2export{Z as E,J as R,ae as a,se as b,M as f,ne as u};

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.