1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[31357],{16549:(e,t,r)=>{r.d(t,{F:()=>n});let n=()=>{try{localStorage.removeItem("customModels"),localStorage.removeItem("rgo-model-selection-v2"),localStorage.removeItem("agent-selection-storage"),localStorage.removeItem("auth-tracking-storage"),localStorage.removeItem("pendingAgentPrompt"),localStorage.removeItem("rgo_upgrade_dialog_displayed"),Object.keys(localStorage).forEach(e=>{e.startsWith("maintenance-dismissed-")&&localStorage.removeItem(e)}),console.log("â
Local storage cleared on logout")}catch(e){console.error("â Error clearing local storage:",e)}}},32537:(e,t,r)=>{r.d(t,{f:()=>l});var n=r(68432),a=r(76524),i=r(67118);function l(e){let{limit:t=50,offset:r=0,days:l,startDate:o,endDate:u}=e;return(0,n.I)({queryKey:[...i.lu.all,"thread-usage",t,r,l,null==o?void 0:o.toISOString(),null==u?void 0:u.toISOString()],queryFn:async()=>{let e=new URLSearchParams({limit:t.toString(),offset:r.toString()});o&&u?(e.append("start_date",o.toISOString()),e.append("end_date",u.toISOString())):l&&e.append("days",l.toString());let n=await a.H.get("/billing/credit-usage-by-thread?".concat(e.toString()));if(n.error)throw Error(n.error.message);return n.data},staleTime:3e4})}},35284:(e,t,r)=>{r.d(t,{A:()=>g,AuthProvider:()=>d});var n=r(78542),a=r(18558),i=r(23590),l=r(16549),o=r(40570),u=r(67638);let s=(0,a.createContext)(void 0);function c(e){var t;let{children:r}=e,{data:c,status:d,update:g}=(0,i.useSession)();(0,u.G)({session:c,status:d,update:g}),(0,a.useEffect)(()=>{var e;(0,o.ki)(null!=(e=null==c?void 0:c.accessToken)?e:null)},[null==c?void 0:c.accessToken]);let p=async()=>{try{await (0,i.signOut)({redirect:!1}),(0,l.F)()}catch(e){console.error("Error signing out:",e)}},f={session:null!=c?c:null,user:null!=(t=null==c?void 0:c.user)?t:null,isLoading:"loading"===d,signOut:p,accessToken:null==c?void 0:c.accessToken};return(0,n.jsx)(s.Provider,{value:f,children:r})}let d=e=>{let{children:t}=e;return(0,n.jsx)(i.SessionProvider,{children:(0,n.jsx)(c,{children:t})})},g=()=>{let e=(0,a.useContext)(s);if(void 0===e)throw Error("useAuth must be used within an AuthProvider");return e}},38994:(e,t,r)=>{r.d(t,{WO:()=>l,Wn:()=>u,qt:()=>o});var n=r(68432),a=r(76524),i=r(67118);function l(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return(0,n.I)({queryKey:[...i.lu.all,"daily-usage"],queryFn:async()=>{let e=await a.H.get("/billing/daily-usage",{showErrors:!1});if(e.error)throw Error(e.error.message);return e.data},enabled:e,staleTime:3e4,retry:1})}function o(e,t,r){let n=e=>Number.isInteger(e)?String(e):e.toFixed(1);return"minutes"===r?"".concat(n(e)," of ").concat(n(t)," min"):"".concat(n(e)," of ").concat(n(t))}function u(e){if(e<60)return"in about ".concat(e," minute").concat(1===e?"":"s");let t=Math.round(e/60);return"in about ".concat(t," hour").concat(1===t?"":"s")}},57570:(e,t,r)=>{r.d(t,{lu:()=>n.lu,rh:()=>n.rh,_A:()=>n._A,Wn:()=>c.Wn,u4:()=>n.u4,Rn:()=>d.Rn,RB:()=>d.RB,VQ:()=>d.VQ,xG:()=>n.xG,Xi:()=>n.Xi,sI:()=>n.sI,WO:()=>c.WO,Qg:()=>s,Hq:()=>d.Hq,l4:()=>n.l4,KM:()=>n.KM,M5:()=>n.M5,Rp:()=>i,c6:()=>n.c6,Uy:()=>d.Uy});var n=r(67118),a=r(18558);function i(e,t,r,i){let l=!(arguments.length>4)||void 0===arguments[4]||arguments[4],o=(0,a.useRef)("idle"),u=(0,n.u4)({enabled:l}),s=n.rh.canRun(u.data),c=(0,a.useCallback)(async()=>{try{let e=await u.refetch();if(e.data&&!n.rh.canRun(e.data))return i&&i(),!0;return!1}catch(e){return console.error("Error checking billing status:",e),!1}},[u,i]);return(0,a.useEffect)(()=>{"running"===o.current&&"idle"===t&&c(),o.current=t},[t,c]),(0,a.useEffect)(()=>{e&&r&&!u.data&&c()},[e,c,r,u.data]),{checkBillingLimits:c,canRun:s,hasState:!!u.data,isLoading:u.isLoading}}r(62386);var l=r(60204),o=r(47155),u=r(36987);function s(e){var t,r;let n=(0,l.SX)(e=>e.accountState),{openPricingModal:i}=(0,o.s)(),s=(null==n?void 0:n.subscription)&&("free"===n.subscription.tier_key||"none"===n.subscription.tier_key||!n.subscription.tier_key),c=null!=(r=null==n||null==(t=n.free_tier_overrides)?void 0:t.downloads_enabled)&&r,d=s&&!c,g=(0,a.useCallback)(()=>{let t=(null==e?void 0:e.featureName)||"files";u.o.error("Upgrade to download ".concat(t),{description:"Downloads are available on paid plans.",position:"top-center",duration:5e3}),i({isAlert:!0,alertTitle:"Upgrade to Download",alertSubtitle:"Export and download features are available on paid plans. Upgrade now to download your ".concat(t," and more.")})},[i,null==e?void 0:e.featureName]),p=(0,a.useCallback)(e=>function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return d?void g():e(...r)},[d,g]);return{isRestricted:d,withRestrictionCheck:p,showUpgradePrompt:g,openUpgradeModal:g}}r(76524),r(32537);var c=r(38994),d=r(95912)},60204:(e,t,r)=>{r.d(t,{SX:()=>s,UO:()=>c,_A:()=>d});
1var n=r(78542),a=r(18558),i=r(67211),l=r(16699),o=r(57570),u=r(35284);let s=(0,i.v)()((0,l.lt)((e,t)=>({accountState:null,isLoading:!1,error:null,setAccountState:t=>e({accountState:t}),setLoading:t=>e({isLoading:t}),setError:t=>e({error:t}),setRefetchCallback:t=>{e({_refetchAccountState:t})},refetch:()=>{var e,r;null==(e=(r=t())._refetchAccountState)||e.call(r)}}),{name:"subscription-store"}));function c(e){let{children:t}=e;return!function(){let{user:e}=(0,u.A)(),{data:t,isLoading:r,error:n,refetch:i}=(0,o.u4)({enabled:!!e}),l=s(e=>e.setAccountState),c=s(e=>e.setLoading),d=s(e=>e.setError),g=s(e=>e.setRefetchCallback);(0,a.useEffect)(()=>{l(t||null)},[t,l]),(0,a.useEffect)(()=>{c(r)},[r,c]),(0,a.useEffect)(()=>{d(n)},[n,d]),(0,a.useEffect)(()=>{g(()=>i())},[i,g])}(),(0,n.jsx)(n.Fragment,{children:t})}function d(){let e=s();return{data:function(){var e,t,r,n,a,i,l,o,u,c,d,g,p,f,h,v;let m=s();return{subscriptionData:(null==(e=m.accountState)?void 0:e.subscription)?{status:m.accountState.subscription.status,plan_name:m.accountState.subscription.tier_display_name,tier_key:m.accountState.subscription.tier_key,subscription:m.accountState.subscription.subscription_id?{id:m.accountState.subscription.subscription_id,status:m.accountState.subscription.status,tier_key:m.accountState.subscription.tier_key,current_period_end:m.accountState.subscription.current_period_end||0,cancel_at:m.accountState.subscription.cancellation_effective_date,cancel_at_period_end:m.accountState.subscription.cancel_at_period_end}:null,tier:{name:m.accountState.subscription.tier_key,credits:null!=(c=null==(t=m.accountState.tier)?void 0:t.monthly_credits)?c:0},credits:{balance:null!=(d=null==(r=m.accountState.credits)?void 0:r.total)?d:0,tier_credits:null!=(g=null==(n=m.accountState.tier)?void 0:n.monthly_credits)?g:0,lifetime_granted:0,lifetime_purchased:0,lifetime_used:0,can_purchase_credits:m.accountState.subscription.can_purchase_credits}}:null,creditBalance:(null==(a=m.accountState)?void 0:a.subscription)?{balance:null!=(p=null==(i=m.accountState.credits)?void 0:i.total)?p:0,expiring_credits:(null!=(f=null==(l=m.accountState.credits)?void 0:l.daily)?f:0)+(null!=(h=null==(o=m.accountState.credits)?void 0:o.monthly)?h:0),non_expiring_credits:null!=(v=null==(u=m.accountState.credits)?void 0:u.extra)?v:0,tier:m.accountState.subscription.tier_key,can_purchase_credits:m.accountState.subscription.can_purchase_credits}:null,isLoading:m.isLoading,error:m.error,refetch:m.refetch,refetchBalance:m.refetch}}().subscriptionData,isLoading:e.isLoading,error:e.error,refetch:e.refetch}}},62386:(e,t,r)=>{r.d(t,{Q:()=>i});var n=r(18558),a=r(65514);function i(){let[e,t]=(0,n.useState)(!1),[r,i]=(0,n.useState)(!1);return{showModal:e,creditsExhausted:r,openModal:(0,n.useCallback)(e=>{let r=!1;if(e instanceof a.Ey){var n,l;let t=(null==(l=e.detail)||null==(n=l.message)?void 0:n.toLowerCase())||"";r=t.includes("credit")||t.includes("balance")||t.includes("insufficient")||t.includes("out of credits")||t.includes("no credits")}else a.rN,r=!1;i(r),t(!0)},[]),closeModal:(0,n.useCallback)(()=>{t(!1),i(!1)},[])}}},67118:(e,t,r)=>{r.d(t,{KM:()=>y,M5:()=>S,Xi:()=>v,_A:()=>p,c6:()=>_,l4:()=>m,lu:()=>s,rh:()=>w,sI:()=>h,u4:()=>f,xG:()=>b});var n=r(68432),a=r(87107),i=r(14333),l=r(36987),o=r(55536),u=r(73048);let s={all:["account-state"],state:()=>[...s.all,"state"],usageHistory:e=>[...s.all,"usage-history",{days:e}],transactions:(e,t)=>[...s.all,"transactions",{limit:e,offset:t}],trial:()=>[...s.all,"trial"]},c=null,d=!1,g=null;function p(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e.invalidateQueries({queryKey:s.state()}),t&&(r&&(d=!0),g||(c&&clearTimeout(c),c=setTimeout(()=>{let t=d;d=!1,c=null,g=(async()=>{try{if(t){let t=await u.cp.getAccountState(!0);e.setQueryData(s.state(),t)}else await e.refetchQueries({queryKey:s.state(),type:"active"})}catch(e){console.warn("[AccountState] Background refetch failed; keeping cached state:",e)}finally{g=null}})()},200)))}function f(e){var t,r,a,i;let l=null==(t=null==e?void 0:e.enabled)||t;return(0,n.I)({queryKey:s.state(),queryFn:()=>{var t;return u.cp.getAccountState(null!=(t=null==e?void 0:e.skipCache)&&t)},enabled:l,staleTime:null!=(r=null==e?void 0:e.staleTime)?r:12e4,gcTime:9e5,refetchOnWindowFocus:null==(a=null==e?void 0:e.refetchOnWindowFocus)||a,refetchOnMount:null!=(i=null==e?void 0:e.refetchOnMount)&&i,refetchOnReconnect:!0,structuralSharing:!0,retry:!!l&&((e,t)=>{let r=t.message||"";return!(r.includes("401")||r.includes("403"))&&e<2})})}function h(){return(0,a.n)({mutationFn:e=>u.cp.createPortalSession(e),onSuccess:e=>{let t=(null==e?void 0:e.portal_url)||(null==e?void 0:e.url);t?window.location.href=t:l.o.error("Failed to create portal session. Please try again.")},onError:e=>{l.o.error((null==e?void 0:e.message)||"Failed to open subscription portal. Please try again.")}})}function v(){let e=(0,i.jE)();return(0,a.n)({mutationFn:e=>u.cp.cancelSubscription(e),onSuccess:t=>{p(e,!0),t.success?l.o.success(t.message):l.o.error(t.message)},onError:e=>{l.o.error(e.message||"Failed to cancel subscription")}})}function m(){let e=(0,i.jE)();return(0,a.n)({mutationFn:()=>u.cp.reactivateSubscription(),onSuccess:t=>{p(e,!0),t.success?l.o.success(t.message):l.o.error(t.message)},onError:e=>{l.o.error(e.message||"Failed to reactivate subscription")}})}function y(){let e=(0,i.jE)();return(0,a.n)({mutationFn:e=>u.cp.scheduleDowngrade(e),onSuccess:t=>{p(e,!0),t.success?l.o.success(t.message):l.o.error(t.message)},onError:e=>{l.o.error(e.message||"Failed to schedule downgrade")}})}function b(){let e=(0,i.jE)();return(0,a.n)({mutationFn:()=>u.cp.cancelScheduledChange(),onSuccess:t=>{p(e,!0),t.success?l.o.success(t.message):l.o.error(t.message)},onError:e=>{l.o.error(e.message||"Failed to cancel scheduled change")}})}function _(e){var t;return(0,n.I)({queryKey:s.trial(),queryFn:()=>u.cp.getTrialStatus(),enabled:null==(t=null==e?void 0:e.enabled)||t,staleTime:3e5})}function S(){let e=(0,i.jE)();return(0,a.n)({mutationFn:e=>u.cp.startTrial(e),onSuccess:t=>{p(e),t.checkout_url&&(window.location.href=t.checkout_url)}})}let w={canRun:e=>{var t,r;return null!=(r=null==e||null==(t=e.credits)?void 0:t.can_run)&&r},totalCredits:e=>{var t,r;return null!=(r=null==e||null==(t=e.credits)?void 0:t.total)?r:0},tierKey:e=>{var t,r;
1return null!=(r=null==e||null==(t=e.subscription)?void 0:t.tier_key)?r:"none"},tierDisplayName:e=>{var t,r;return null!=(r=null==e||null==(t=e.subscription)?void 0:t.tier_display_name)?r:"No Plan"},planName:e=>{var t;if(!(null==e?void 0:e.subscription))return"Basic";let r=e.subscription.tier_key||(null==(t=e.tier)?void 0:t.name);if(!r||"none"===r||"free"===r)return"Basic";if("enterprise"===r||r.startsWith("enterprise"))return"Enterprise";let n=o.C.cloudPricingItems.find(e=>e.tierKey===r);return(null==n?void 0:n.name)||"Basic"},isTrial:e=>{var t,r;return null!=(r=null==e||null==(t=e.subscription)?void 0:t.is_trial)&&r},isCancelled:e=>{var t,r;return null!=(r=null==e||null==(t=e.subscription)?void 0:t.is_cancelled)&&r},allowedModels:e=>{var t,r;return null!=(r=null==e||null==(t=e.models)?void 0:t.filter(e=>e.allowed))?r:[]},isModelAllowed:(e,t)=>{var r,n,a;return null!=(a=null==e||null==(n=e.models)||null==(r=n.find(e=>e.id===t))?void 0:r.allowed)&&a},scheduledChange:e=>{var t;return null==e||null==(t=e.subscription)?void 0:t.scheduled_change},hasScheduledChange:e=>{var t,r;return null!=(r=null==e||null==(t=e.subscription)?void 0:t.has_scheduled_change)&&r},canPurchaseCredits:e=>{var t,r;return null!=(r=null==e||null==(t=e.subscription)?void 0:t.can_purchase_credits)&&r},dailyCreditsInfo:e=>{var t;return null==e||null==(t=e.credits)?void 0:t.daily_refresh},isEnterprise:e=>{var t,r;return null!=(r=null==e||null==(t=e.enterprise)?void 0:t.is_enterprise)&&r},enterpriseOrgName:e=>{var t,r;return null!=(r=null==e||null==(t=e.enterprise)?void 0:t.org_name)?r:null}}},67638:(e,t,r)=>{r.d(t,{G:()=>g,U:()=>o});var n=r(18558),a=r(23590),i=r(40570),l=r(16549);let o="rgo_session_expired_at";async function u(){try{let e=await fetch("/api/auth/session",{cache:"no-store",credentials:"same-origin"});if(!e.ok)return"unknown";let t=await e.json();return(null==t?void 0:t.user)&&t.accessToken?"alive":"expired"}catch(e){return"unknown"}}let s=!1,c=[5e3,15e3,3e4,6e4];async function d(e,t){if(!s){s=!0,console.warn("[auth] Session expired; signing out",{reason:t,returnTo:e}),(0,i.ki)(null),(0,l.F)();try{sessionStorage.setItem(o,String(Date.now()))}catch(e){}try{await (0,a.signOut)({callbackUrl:e})}catch(t){console.error("[auth] signOut failed after session expiry; reloading instead",t),window.location.assign(e)}}}function g(e){let{session:t,status:r,update:a}=e,l=(0,n.useRef)(!1),o=(0,n.useRef)(!1),s=(0,n.useRef)(r),g=(0,n.useRef)(a),p=(0,n.useRef)(!!(null==t?void 0:t.accessToken)),f=(0,n.useRef)(null),h=(0,n.useRef)(0),v=(0,n.useRef)(async()=>{});s.current=r,g.current=a,p.current=!!(null==t?void 0:t.accessToken);let m=(0,n.useCallback)(()=>{f.current&&clearTimeout(f.current),f.current=null},[]),y=(0,n.useCallback)(e=>{if(f.current||h.current>=10)return;let t=c[Math.min(h.current,c.length-1)];h.current+=1,console.debug("[auth] Session route unreachable; checking again",{reason:e,inMs:t,attempt:h.current}),f.current=setTimeout(()=>{f.current=null,v.current("".concat(e,":recheck"))},t)},[]),b=(0,n.useCallback)(async e=>{if(!l.current||o.current)return;let t=window.location.pathname+window.location.search;o.current=!0;try{let r=await u();console.debug("[auth] Session check",{reason:e,state:r}),"expired"===r?(m(),await d(t,e)):"alive"===r?(m(),h.current=0,"unauthenticated"===s.current&&await g.current()):"unauthenticated"!==s.current&&p.current||y(e)}finally{o.current=!1}},[m,y]);v.current=b,(0,n.useEffect)(()=>{"authenticated"===r?(l.current=!0,(null==t?void 0:t.accessToken)?(m(),h.current=0):b("authenticated-without-backend-token")):"unauthenticated"===r&&b("session-became-unauthenticated")},[r,null==t?void 0:t.accessToken,b,m]),(0,n.useEffect)(()=>(0,i.np)(()=>void b("token-refresh-returned-no-session")),[b]),(0,n.useEffect)(()=>{let e=e=>{let t="unauthenticated"===s.current||!p.current;l.current&&t&&(m(),h.current=0,v.current(e))},t=()=>e("browser-back-online"),r=()=>{"visible"===document.visibilityState&&e("tab-visible-again")};return window.addEventListener("online",t),document.addEventListener("visibilitychange",r),()=>{window.removeEventListener("online",t),document.removeEventListener("visibilitychange",r),m()}},[m])}},95912:(e,t,r)=>{r.d(t,{Hq:()=>s,RB:()=>c,Rn:()=>u,Uy:()=>l,VQ:()=>o});var n=r(76524),a=r(68432),i=r(87107);function l(e){return(0,a.I)({queryKey:["admin","billing","user",e],queryFn:async()=>
1{if(!e)return null;let t=await n.H.get("/admin/billing/user/".concat(e,"/summary"));if(t.error)throw Error(t.error.message);return t.data},enabled:!!e})}function o(e){return(0,a.I)({queryKey:["admin","billing","transactions",e.userId,e.page,e.page_size,e.type_filter],queryFn:async()=>{let t=new URLSearchParams;e.page&&t.append("page",e.page.toString()),e.page_size&&t.append("page_size",e.page_size.toString()),e.type_filter&&t.append("type_filter",e.type_filter);let r=await n.H.get("/admin/billing/user/".concat(e.userId,"/transactions?").concat(t.toString()));if(r.error)throw Error(r.error.message);return r.data},enabled:!!e.userId,staleTime:3e4})}function u(){return(0,i.n)({mutationFn:async e=>{let t=await n.H.post("/admin/billing/credits/adjust",e);if(t.error)throw Error(t.error.message);return t.data}})}function s(){return(0,i.n)({mutationFn:async e=>{let t=await n.H.post("/admin/billing/refund",e);if(t.error)throw Error(t.error.message);return t.data}})}function c(e){return(0,a.I)({queryKey:["admin","billing","thread-usage",e.userId,e.page,e.page_size,e.days],queryFn:async()=>{let t=new URLSearchParams;e.page&&t.append("page",e.page.toString()),e.page_size&&t.append("page_size",e.page_size.toString()),e.days&&t.append("days",e.days.toString());let r=await n.H.get("/admin/billing/user/".concat(e.userId,"/thread-usage?").concat(t.toString()));if(r.error)throw Error(r.error.message);return r.data},enabled:!!e.userId,staleTime:3e4})}}}]);
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.