PageSourceSearch

https://realastrology.ai/assets/AdminPowerUsers-DV1QnGVA.js

js realastrology.ai collected 2026-10-05 15:14:07 UTC 13,928 bytes, 5 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="db4a0dd1-ff06-5814-b88c-2b90c7abd9a6")}catch(e){}}();
3import{j as e}from"./radix-Dv40WeBR.js";import{r as n}from"./react-vendor-DMCBMKwH.js";import{u as ee,aw as se,D as re,B as z,R as ae,A as y,C as P,d as M,e as I,f as L,g as K,a1 as g,aC as U,U as b,cx as te,ax as le,ay as oe,az as ne,a6 as ie}from"./index-DY-XyNlk.js";import{a as E}from"./admin-Cbo6ic1-.js";import{U as ce,S as de}from"./UserDetailDrawer-CtrUgNHG.js";import{A as H,a as O}from"./alert-BNJPzo3Z.js";import{T as ue,a as me,b as V,c as m,d as xe,e as u}from"./table-YQocBhyF.js";import{u as pe}from"./i18n-CRxfqRtU.js";import{R as fe,B as he,C as je,X as ge,Y as be,T as we,f as Ne}from"./charts-D11ksbhN.js";import"./routes-dVq0rzGe.js";import"./separator-CCE0lALX.js";import"./ConfirmationDialog-DsntwvpB.js";import"./select-B9S8iUvM.js";import"./chevron-up-C2raBI82.js";import"./progress-C_fmLmeR.js";import"./infinity-0wqhOXs8.js";import"./plus-CC_0Lk5l.js";import"./arrow-up-circle-B-PdZrTR.js";import"./switch-BC19EXg0.js";import"./calendar-x-DNfGAIfS.js";import"./calendar-clock-0qWsHRtM.js";import"./check-circle-BpV_Inty.js";import"./eye-DJRQgASG.js";import"./eye-off-5PMchPIT.js";import"./calendar-BRCMettl.js";import"./bar-chart-3-BowaNWDy.js";function $(s,r){return new Intl.NumberFormat(r,{style:"currency",currency:"BRL"}).format(s/100)}function ve(s,r){return s(`admin.usage.featureTypes.${r}`,{defaultValue:r.replace(/_/g," ")})}function Ze(){const{t:s,i18n:r}=pe(),{user:i}=ee(),[a,c]=n.useState(null),[o,d]=n.useState(null),[_,C]=n.useState(null),[W,S]=n.useState(null),[w,k]=n.useState(!0),[R,T]=n.useState(!1),[x,q]=n.useState("score"),[J,Q]=n.useState(null),[Z,D]=n.useState(!1),B=n.useRef(!1),N=n.useRef(!0),h=n.useCallback(async()=>{T(!0),B.current||k(!0);const[t,l]=await Promise.allSettled([E.getPowerUsers(100),E.getPowerUserCohortSummary()]);N.current&&(t.status==="fulfilled"?(c(t.value),C(null)):C(s("admin.powerUsers.errors.list",{defaultValue:"Failed to load power users"})),l.status==="fulfilled"?(d(l.value),S(null)):S(s("admin.powerUsers.errors.cohort",{defaultValue:"Failed to load cohort summary"})),B.current=!0,k(!1),T(!1))},[s]);n.useEffect(()=>(N.current=!0,h(),()=>{N.current=!1}),[h]);const j=n.useMemo(()=>{const t=(a==null?void 0:a.items)??[];return x==="cooling"?[...t].sort((l,f)=>Number(f.cooling_off)-Number(l.cooling_off)||f.score-l.score):x==="nearcap"?[...t].sort((l,f)=>Number(f.near_cap)-Number(l.near_cap)||f.score-l.score):t},[a,x]),p=(a==null?void 0:a.cohort_size)??0,A=x==="score"&&p>0&&p<j.length,F=t=>{Q(t),D(!0)};return e.jsx(se,{children:e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(re,{className:"h-6 w-6 text-primary"}),s("admin.powerUsers.title",{defaultValue:"Power Users"})]}),e.jsx("p",{className:"text-sm sm:text-base text-muted-foreground mt-1",children:s("admin.powerUsers.subtitle",{defaultValue:"Most engaged users by action volume, feature breadth and recency. Revenue/plan shown for context, not scored."})})]}),e.jsxs(z,{variant:"outline",size:"sm",onClick:h,disabled:R,children:[e.jsx(ae,{className:y("h-4 w-4 mr-1",R&&"animate-spin")}),s("admin.refresh",{defaultValue:"Refresh"})]})]}),e.jsx(_e,{data:o,loading:w,error:W,t:s}),_&&e.jsx(H,{variant:"destructive",children:e.jsx(O,{children:_})}),e.jsxs(P,{children:[e.jsxs(M,{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx(I,{children:s("admin.powerUsers.ranking.title",{defaultValue:"Ranking"})}),e.jsx(L,{children:w?"":s("admin.powerUsers.ranking.poolMeta",{defaultValue:"{{total}} eligible · top {{cohort}} are power users",total:(a==null?void 0:a.total)??0,cohort:p})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["score","cooling","nearcap"].map(t=>e.jsxs(z,{variant:x===t?"default":"outline",size:"sm",onClick:()=>q(t),children:[t==="score"&&s("admin.powerUsers.sort.score",{defaultValue:"Score"}),t==="cooling"&&s("admin.powerUsers.sort.cooling",{defaultValue:"🧊 Cooling off"}),t==="nearcap"&&s("admin.powerUsers.sort.nearcap",{defaultValue:"📈 Near cap"})]},t))})]}),e.jsx(K,{className:"p-0 sm:p-0",children:w?e.jsx("div",{className:"p-4 space-y-3",children:Array.from({length:6}).map((t,l)=>e.jsx(g,{className:"h-10 w-full"},l))}):j.length===0?e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:s("admin.powerUsers.empty",{defaultValue:"No power users yet — no users with activity in the last 90 days."})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block overflow-x-auto",children:e.jsxs(ue,{children:[e.jsx(me,{children:e.jsxs(V,{children:[e.jsx(m,{className:"w-12",children:"#"}),e.jsx(m,{children:s("admin.powerUsers.col.user",{defaultValue:"User"})}),e.jsx(m,{className:"text-right",children:s("admin.powerUsers.col.score",{defaultValue:"Score"})}),e.jsx(m,{children:s("admin.powerUsers.col.flags",{defaultValue:"Flags"})}),e.jsx(m,{children:s("admin.powerUsers.col.plan",{defaultValue:"Plan"})}),e.jsx(m,{className:"text-right",children:s("admin.powerUsers.col.revenue",{defaultValue:"Revenue"})}),e.jsx(m,{children:s("admin.powerUsers.col.lastActive",{defaultValue:"Last active"})})]})}),e.jsx(xe,{children:j.map((t,l)=>e.jsx(Ue,{item:t,rank:l+1,lang:r.language,t:s,onClick:()=>F(t.user_id),showDividerBefore:A&&l===p},t.user_id))})]})}),e.jsx("div",{className:"md:hidden",children:j.map((t,l)=>e.jsx(Ve,{item:t,rank:l+1,lang:r.language,t:s,onClick:()=>F(t.user_id),showDividerBefore:A&&l===p},t.user_id))})]})})]}),e.jsx(ce,{userId:J,open:Z,onOpenChange:D,currentAdminId:i==null?void 0:i.id,onUserUpdated:h})]})})}function X({item:s,t:r}){return!s.cooling_off&&!s.near_cap?e.jsx("span",{className:"text-muted-foreground",children:"—"}):e.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.cooling_off&&e.jsxs(b,{variant:"outline",className:"gap-1 text-sky-600 border-sky-500/50",children:[e.jsx(de,{className:"h-3 w-3"}),r("admin.powerUsers.flags.cooling",{defaultValue:"Cooling off"})]}),s.near_cap&&e.jsxs(b,{variant:"outline",className:"gap-1 text-amber-600 border-amber-500/50",children:[e.jsx(ie,{className:"h-3 w-3"}),r("admin.powerUsers.flags.nearcap",{defaultValue:"Near cap"})]})]})}function Y({item:s,t:r}){return e.jsxs(le,{children:[e.jsx(oe,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":r("admin.powerUsers.tooltip.scoreAria",{defaultValue:"Score breakdown"}),onClick:i=>i.stopPropagation(),className:"font-semibold tabular-nums cursor-help underline decoration-dotted decoration-muted-foreground
3/40 underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded",children:s.score.toFixed(0)})}),e.jsx(ne,{children:e.jsxs("div",{className:"text-xs space-y-0.5",children:[e.jsxs("p",{children:[r("admin.powerUsers.tooltip.volume",{defaultValue:"Volume"}),":"," ",s.volume_percentile.toFixed(0),r("admin.powerUsers.tooltip.pctile",{defaultValue:"th pct"})," (",s.volume,")"]}),e.jsxs("p",{children:[r("admin.powerUsers.tooltip.breadth",{defaultValue:"Breadth"}),":"," ",s.breadth_percentile.toFixed(0),r("admin.powerUsers.tooltip.pctile",{defaultValue:"th pct"})," (",s.breadth,")"]}),e.jsxs("p",{children:[r("admin.powerUsers.tooltip.recency",{defaultValue:"Recency"}),":"," ",s.recency_percentile.toFixed(0),r("admin.powerUsers.tooltip.pctile",{defaultValue:"th pct"})," (",s.days_since_last_action,r("admin.powerUsers.tooltip.daysAgo",{defaultValue:"d ago"}),")"]})]})})]})}function G({plan:s}){return e.jsx(b,{variant:"outline",className:"capitalize",children:s})}function ye({t:s,cols:r}){return e.jsx(V,{className:"hover:bg-transparent",children:e.jsx(u,{colSpan:r,className:"py-1",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"h-px flex-1 bg-border"}),e.jsx(U,{className:"h-3 w-3 text-primary"}),s("admin.powerUsers.cohortBoundary",{defaultValue:"Top 10% boundary"}),e.jsx("span",{className:"h-px flex-1 bg-border"})]})})})}function Ue({item:s,rank:r,lang:i,t:a,onClick:c,showDividerBefore:o}){return e.jsxs(e.Fragment,{children:[o&&e.jsx(ye,{t:a,cols:7}),e.jsxs(V,{className:y("cursor-pointer hover:bg-muted/50",s.is_power_user&&"bg-primary/5"),role:"button",tabIndex:0,onClick:c,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),c())},children:[e.jsx(u,{className:"text-muted-foreground tabular-nums",children:r}),e.jsxs(u,{children:[e.jsx("p",{className:"font-medium text-foreground truncate max-w-[220px]",children:s.full_name||e.jsx("span",{className:"text-muted-foreground italic",children:a("admin.users.noName",{defaultValue:"No name"})})}),e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[220px]",children:s.email})]}),e.jsx(u,{className:"text-right",children:e.jsx(Y,{item:s,t:a})}),e.jsx(u,{children:e.jsx(X,{item:s,t:a})}),e.jsx(u,{children:e.jsx(G,{plan:s.plan})}),e.jsx(u,{className:"text-right tabular-nums",children:$(s.revenue_cents,i)}),e.jsx(u,{className:"text-muted-foreground text-sm",children:s.last_activity_at?te(s.last_activity_at,i):"—"})]})]})}function Ve({item:s,rank:r,lang:i,t:a,onClick:c,showDividerBefore:o}){return e.jsxs(e.Fragment,{children:[o&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"h-px flex-1 bg-border"}),e.jsx(U,{className:"h-3 w-3 text-primary"}),a("admin.powerUsers.cohortBoundary",{defaultValue:"Top 10% boundary"}),e.jsx("span",{className:"h-px flex-1 bg-border"})]}),e.jsxs("div",{className:y("p-4 cursor-pointer hover:bg-muted/50 border-b border-border last:border-b-0",s.is_power_user&&"bg-primary/5"),role:"button",tabIndex:0,onClick:c,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),c())},children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-foreground truncate",children:[e.jsxs("span",{className:"text-muted-foreground mr-1",children:["#",r]}),s.full_name||s.email]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.email})]}),e.jsx(Y,{item:s,t:a})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-3",children:[e.jsx(G,{plan:s.plan}),e.jsx(X,{item:s,t:a}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:$(s.revenue_cents,i)})]})]})]})}function _e({data:s,loading:r,error:i,t:a}){if(i)return e.jsx(H,{variant:"destructive",children:e.jsx(O,{children:i})});const c=((s==null?void 0:s.feature_mix)??[]).map(o=>({...o,label:ve(a,o.feature_type)}));return e.jsxs(P,{children:[e.jsxs(M,{children:[e.jsxs(I,{className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-5 w-5 text-primary"}),a("admin.powerUsers.cohort.title",{defaultValue:"Power-user cohort (top 10%)"})]}),e.jsx(L,{children:a("admin.powerUsers.cohort.subtitle",{defaultValue:"What the most engaged users collectively do."})})]}),e.jsxs(K,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:[e.jsx(v,{label:a("admin.powerUsers.cohort.size",{defaultValue:"Cohort size"}),value:r?null:String((s==null?void 0:s.cohort_size)??0)}),e.jsx(v,{label:a("admin.powerUsers.cohort.pool",{defaultValue:"Eligible pool"}),value:r?null:String((s==null?void 0:s.pool_size)??0)}),e.jsx(v,{label:a("admin.powerUsers.cohort.median",{defaultValue:"Median score"}),value:r?null:((s==null?void 0:s.median_score)??0).toFixed(0)})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold mb-3",children:a("admin.powerUsers.cohort.featureMix",{defaultValue:"Feature mix"})}),r?e.jsx(g,{className:"h-[220px] w-full"}):c.length===0?e.jsx("div",{className:"flex h-[120px] items-center justify-center rounded-lg border border-dashed text-sm text-muted-foreground",children:a("admin.powerUsers.cohort.featureMixEmpty",{defaultValue:"No premium feature usage in the cohort yet."})}):e.jsx("div",{className:"h-[260px]",children:e.jsx(fe,{width:"100%",height:"100%",children:e.jsxs(he,{data:c,layout:"vertical",children:[e.jsx(je,{strokeDasharray:"3 3",className:"stroke-border"}),e.jsx(ge,{type:"number",tick:{fontSize:10},className:"text-muted-foreground",unit:"%"}),e.jsx(be,{type:"category",dataKey:"label",tick:{fontSize:10},className:"text-muted-foreground",width:120}
3),e.jsx(we,{contentStyle:{backgroundColor:"hsl(var(--card))",borderColor:"hsl(var(--border))",borderRadius:"8px",color:"hsl(var(--foreground))"},formatter:o=>[`${o}%`,""]}),e.jsx(Ne,{dataKey:"pct",fill:"hsl(var(--primary))",radius:[0,4,4,0]})]})})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold mb-3",children:a("admin.powerUsers.cohort.planDistribution",{defaultValue:"Plan distribution"})}),r?e.jsx(g,{className:"h-8 w-full"}):((s==null?void 0:s.plan_distribution)??[]).length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"—"}):e.jsx("div",{className:"flex flex-wrap gap-2",children:s.plan_distribution.map(o=>e.jsxs(b,{variant:"secondary",className:"capitalize gap-1",children:[o.plan,e.jsxs("span",{className:"text-muted-foreground",children:["· ",o.count]})]},o.plan))})]})]})]})}function v({label:s,value:r}){return e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s}),r===null?e.jsx(g,{className:"h-7 w-12 mt-1"}):e.jsx("p",{className:"text-2xl font-bold tabular-nums",children:r})]})}export{Ze as AdminPowerUsers};
4
5//# debugId=db4a0dd1-ff06-5814-b88c-2b90c7abd9a6

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.