1import{c as de,r as x,j as e,f as y,b as N,I as E,J as $,K as W,T as U,g as C,m as O,ae as me,af as xe,ag as he,O as T,B as g,C as ue,a7 as pe,d as je,Q as M,i as fe,A as Y,U as le,u as ge,ac as ve,S as Ne}from"./index-CxTzo_i5.js";import{I as re}from"./input-CcS2mpyJ.js";import{T as q,a as J,b as A}from"./tabs-D8v4uTkL.js";import{u as be}from"./use-affiliators-CF1AKN5N.js";import{V as we}from"./virtual-data-table-CXBWhM2E.js";import{B as ye}from"./batch-actions-bar-CASSUgsC.js";import{P as Ce}from"./progress--Fn6TLYa.js";import{T as B}from"./trophy-BDLqm10e.js";import{V as G}from"./video-CbDDEhxj.js";import{S as X}from"./shopping-cart-CxxcDby_.js";import{F as ie}from"./flame-PW6z41Ej.js";import{T as ke}from"./target-DkPc2QVM.js";import{M as ee}from"./medal-TaII8LQU.js";import{L as Se}from"./label-u97y7T5C.js";import{T as Re,a as Te,b as se,c as S,d as Ae,e as R}from"./table-DceSb92m.js";import{C as te}from"./checkbox-B1zCQAo8.js";import{C as oe}from"./calculator-CP2WiGuN.js";import{D as ce}from"./download-W1WbOpl9.js";import{P as Me}from"./percent-B5HGMmEt.js";import{C as Le}from"./circle-alert-DmapXqas.js";import{M as ae}from"./mail-ne6v6G0L.js";import{E as Fe}from"./enhanced-import-dialog-BvrSG64O.js";import{F as Ie}from"./filter-presets-BSUrq0Ct.js";import{A as z}from"./animated-number-DTaJiCpw.js";import{u as Pe}from"./useTranslation-BsXlF-II.js";import{E as Ve}from"./external-link-Ddpd7fdt.js";import{F as Be}from"./filter-dH9Hqqjl.js";import"./useQuery-BujisQX_.js";import"./sliders-horizontal-COCJX3yU.js";import"./grip-vertical-DhBU7bxQ.js";import"./chevron-up-DNE74ONe.js";import"./ellipsis-CddaOB9h.js";import"./eye-DtgkDt4i.js";import"./square-pen-C_jxPBCs.js";import"./circle-check-big-Buxx_3Mw.js";import"./user-plus-BMgqCCAW.js";import"./index-BG_NryTU.js";import"./import-validators-Cq1nZDEL.js";import"./xlsx-B6sNpj_1.js";import"./types-vOKYguEV.js";import"./upload-LfYqZTGw.js";import"./file-spreadsheet-hnOja5yS.js";import"./bookmark-BfTQsTAQ.js";import"./plus-BTi1u4UK.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const De=de("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]),He=r=>r===1?{icon:B,color:"text-amber-500",bg:"bg-amber-500/10"}:r===2?{icon:ee,color:"text-slate-400",bg:"bg-slate-400/10"}:r===3?{icon:ee,color:"text-amber-700",bg:"bg-amber-700/10"}:{icon:null,color:"text-muted-foreground",bg:"bg-muted/50"},_=r=>r>=1e9?`Rp ${(r/1e9).toFixed(1)}B`:r>=1e6?`Rp ${(r/1e6).toFixed(1)}M`:r>=1e3?`Rp ${(r/1e3).toFixed(0)}K`:`Rp ${r.toLocaleString("id-ID")}`,ze={"Top Seller":{icon:B,color:"text-amber-500"},"Video Star":{icon:G,color:"text-purple-500"},Converter:{icon:X,color:"text-emerald-500"},"On Fire":{icon:ie,color:"text-orange-500"}};function Oe({data:r,isLoading:l=!1,className:p}){const[v,n]=x.useState("monthly"),[u,h]=x.useState("gmv"),b=[...r].sort((t,d)=>u==="gmv"?d.value-t.value:u==="videos"?d.videoCount-t.videoCount:d.conversionRate-t.conversionRate).map((t,d)=>({...t,rank:d+1}));return e.jsxs(y,{className:N("overflow-hidden",p),children:[e.jsxs(E,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs($,{className:"flex items-center gap-2",children:[e.jsx(B,{className:"h-5 w-5 text-amber-500"}),"Affiliate Leaderboard"]}),e.jsx(W,{children:"Top performing affiliates"})]}),e.jsx(q,{value:v,onValueChange:t=>n(t),children:e.jsxs(J,{className:"h-8",children:[e.jsx(A,{value:"weekly",className:"text-xs px-2",children:"Weekly"}),e.jsx(A,{value:"monthly",className:"text-xs px-2",children:"Monthly"}),e.jsx(A,{value:"all",className:"text-xs px-2",children:"All Time"})]})})]}),e.jsx(q,{value:u,onValueChange:t=>h(t),className:"mt-2",children:e.jsxs(J,{className:"grid w-full grid-cols-3 h-9",children:[e.jsxs(A,{value:"gmv",className:"text-xs",children:[e.jsx(U,{className:"h-3 w-3 mr-1"}),"GMV"]}),e.jsxs(A,{value:"videos",className:"text-xs",children:[e.jsx(G,{className:"h-3 w-3 mr-1"}),"Videos"]}),e.jsxs(A,{value:"conversion",className:"text-xs",children:[e.jsx(X,{className:"h-3 w-3 mr-1"}),"Conversion"]})]})})]}),e.jsxs(C,{className:"space-y-3",children:[b.map((t,d)=>{const j=He(t.rank),i=j.icon,m=t.target?Math.min(t.value/t.target*100,100):0;return e.jsxs(O.div,{initial:{opacity:0,x:-20}
6,animate:{opacity:1,x:0},transition:{delay:.05*d},className:N("p-4 rounded-lg border transition-colors",t.rank<=3?j.bg:"bg-muted/30","hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:N("w-10 h-10 rounded-full flex items-center justify-center font-bold",t.rank<=3?j.bg:"bg-muted"),children:i?e.jsx(i,{className:N("h-5 w-5",j.color)}):e.jsxs("span",{className:"text-sm text-muted-foreground",children:["#",t.rank]})}),e.jsxs(me,{className:"h-10 w-10",children:[e.jsx(xe,{src:t.profileImage}),e.jsx(he,{children:t.name.slice(0,2).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-semibold truncate",children:t.name}),t.streak&&t.streak>=3&&e.jsxs(T,{variant:"outline",className:"text-xs text-orange-500 border-orange-500/30",children:[e.jsx(ie,{className:"h-3 w-3 mr-1"}),t.streak," day streak"]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["@",t.tiktokHandle]}),t.badges&&t.badges.length>0&&e.jsx("div",{className:"flex gap-1 mt-1",children:t.badges.map(I=>{const k=ze[I];if(!k)return null;const P=k.icon;return e.jsx(T,{variant:"outline",className:"text-xs px-1.5 py-0",children:e.jsx(P,{className:N("h-3 w-3",k.color)})},I)})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold",children:_(t.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"GMV"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold",children:t.videoCount}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-lg font-bold",children:[t.conversionRate,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Conv."})]})]})]}),t.target&&e.jsxs("div",{className:"mt-3 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ke,{className:"h-3 w-3"}),"Monthly Target"]}),e.jsxs("span",{className:"font-medium",children:[_(t.value)," / ",_(t.target)]})]}),e.jsx(Ce,{value:m,className:"h-1.5"})]})]},t.id)}),r.length===0&&!l&&e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"No data available"})]})]})}const Ee={Diamond:{base:15,bonus:5},Platinum:{base:12,bonus:4},Gold:{base:10,bonus:3},Silver:{base:8,bonus:2},Bronze:{base:5,bonus:1}},F=r=>`Rp ${r.toLocaleString("id-ID")}`,$e=[{id:"1",affiliateName:"Sarah Beauty",gmv:15e6,tier:"Gold",baseRate:10,bonusRate:3,totalRate:13,commission:195e4},{id:"2",affiliateName:"Tech Master",gmv:85e5,tier:"Silver",baseRate:8,bonusRate:2,totalRate:10,commission:85e4},{id:"3",affiliateName:"Food Lover",gmv:22e6,tier:"Platinum",baseRate:12,bonusRate:4,totalRate:16,commission:352e4},{id:"4",affiliateName:"Fashion Queen",gmv:5e6,tier:"Bronze",baseRate:5,bonusRate:1,totalRate:6,commission:3e5},{id:"5",affiliateName:"Travel Guy",gmv:12e6,tier:"Gold",baseRate:10,bonusRate:3,totalRate:13,commission:156e4}];function Ue({items:r=$e,onProcess:l,className:p}){const[v,n]=x.useState(r.map(a=>({...a,selected:!1}))),[u,h]=x.useState("1"),[b,t]=x.useState(!1),[d,j]=x.useState(!1),i=v.filter(a=>a.selected),m=i.reduce((a,o)=>a+o.gmv,0),k=i.reduce((a,o)=>a+o.commission,0)*parseFloat(u||"1"),P=a=>{n(o=>o.map(f=>f.id===a?{...f,selected:!f.selected}:f))},V=()=>{const a=v.every(o=>o.selected);n(o=>o.map(f=>({...f,selected:!a})))},L=()=>{const a=parseFloat(u||"1");n(o=>o.map(f=>{const s=Ee[f.tier]||{base:5,bonus:1},c=s.base+s.bonus*a,K=f.gmv*(c/100);return{...f,baseRate:s.base,bonusRate:s.bonus*a,totalRate:c,commission:K}})),M.success("Commissions recalculated")},D=async()=>{if(i.length===0){M.error("Select at least one item to process");return}t(!0);try{await(l==null?void 0:l(i)),M.success(`${i.length} commissions processed successfully`),n(a=>a.map(o=>({...o,selected:!1})))}catch{M.error("Failed to process commissions")}finally{t(!1)}},H=()=>{M.success("Commission data exported")};return e.jsxs(y,{className:N("overflow-hidden",p),children:[e.jsx(E,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs($,{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5 text-primary"}),"Commission Calculator"]}),e.jsx(W,{children:"Calculate and process bulk commissions"})]}),e.jsxs(g,{variant:"outline",size:"sm",onClick:H,children:[e.jsx(ce,{className:"h-4 w-4 mr-2"}),"Export"]})]})}),e.jsxs(C,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 p-4 rounded-lg bg-muted/30 border",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Se,{children:"Bonus Multiplier"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{type:"number",value:u,onChange:a=>h(a.target.value),className:"w-20",min:"0",max:"10",step:"0.5"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"x"}),e.jsx(g,{variant:"outline",size:"sm",onClick:L,children:"Recalculate"})]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs(g,{variant:"outline",onClick:()=>j(!d),disabled:i.length===0,children:["Preview (",i.length,")"]}),e.jsx(g,{onClick:D,disabled:i.length===0||b,children:b?e.jsx(e.Fragment,{children:"Processing..."}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-4 w-4 mr-2"}),"Process Selected"]})})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(pe,{className:"h-4 w-4"}),"Total GMV"]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:F(m)})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-primary/10",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(Me,{className:"h-4 w-4"}),"Total Commission"]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-primary",children:F(k)})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(U,{className:"h-4 w-4"}),"Avg Rate"]}),e.jsxs("p",{className:"text-2xl font-bold mt-1",children:[i.length>0?(i.reduce((a,o)=>a+o.totalRate,0)/i.length).toFixed(1):0,"%"]})]})]}),e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs(Re,{children:[e.jsx(Te,{children:e.jsxs(se,{children:[e.jsx(S,{className:"w-12",children:e.jsx(te,{checked:v.every(a=>a.selected),onCheckedChange:V})}),e.jsx(S,{children:"Affiliate"}),e.jsx(S,{children:"Tier"}),e.jsx(S,{className:"text-right",children:"GMV"}),e.jsx(S,{className:"text-center",children:"Base %"}),e.jsx(S,{className:"text-center",children:"Bonus %"}),e.jsx(S,{className:"text-center",children:"Total %"}),e.jsx(S,{className:"text-right",children:"Commission"})]})}),e.jsx(Ae,{children:v.map(a=>e.jsxs(se,{className:N(a.selected&&"bg-primary/5"),children:[e.jsx(R,{children:e.jsx(te,{checked:a.selected,onCheckedChange:()=>P(a.id)})}),e.jsx(R,{className:"font-medium",children:a.affiliateName}),e.jsx(R,{children:e.jsx(T,{variant:"outline",children:a.tier})}),e.jsx(R,{className:"text-right",children:F(a.gmv)}),e.jsxs(R,{className:"text-center",children:[a.baseRate,"%"]}),e.jsxs(R,{className:"text-center text-emerald-600",children:["+",a.bonus
6Rate.toFixed(1),"%"]}),e.jsxs(R,{className:"text-center font-medium",children:[a.totalRate.toFixed(1),"%"]}),e.jsx(R,{className:"text-right font-bold text-primary",children:F(a.commission)})]},a.id))})]})}),e.jsx(je,{children:d&&i.length>0&&e.jsx(O.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"overflow-hidden",children:e.jsxs("div",{className:"p-4 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Le,{className:"h-5 w-5 text-amber-500"}),e.jsxs("h4",{className:"font-semibold",children:["Preview: ",i.length," items to process"]})]}),e.jsxs("div",{className:"space-y-2 text-sm",children:[i.map(a=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:a.affiliateName}),e.jsx("span",{className:"font-medium",children:F(a.commission)})]},a.id)),e.jsxs("div",{className:"pt-2 border-t flex items-center justify-between font-bold",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{className:"text-primary",children:F(k)})]})]})]})})})]})]})}const Ge=[{id:"registered",name:"Registered",count:1250,percentage:100,icon:le,color:"text-blue-500"},{id:"active",name:"Active",count:890,percentage:71.2,dropOff:28.8,icon:De,color:"text-emerald-500"},{id:"producing",name:"Producing",count:456,percentage:36.5,dropOff:48.8,icon:G,color:"text-purple-500"},{id:"converting",name:"Converting",count:234,percentage:18.7,dropOff:48.7,icon:X,color:"text-amber-500"},{id:"top_performer",name:"Top Performer",count:45,percentage:3.6,dropOff:80.8,icon:U,color:"text-rose-500"}];function Ke({data:r=Ge,onSendCampaign:l,className:p}){var n,u,h,b;const v=Math.max(...r.map(t=>t.count));return e.jsxs(y,{className:N("overflow-hidden",p),children:[e.jsx(E,{className:"pb-3",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs($,{className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-5 w-5 text-primary"}),"Activation Funnel"]}),e.jsx(W,{children:"Track affiliate progression through stages"})]})})}),e.jsxs(C,{className:"space-y-4",children:[e.jsx("div",{className:"space-y-3",children:r.map((t,d)=>{const j=t.icon,i=t.count/v*100,m=d===r.length-1;return e.jsxs(O.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:d*.1},children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"w-32 flex items-center gap-2",children:[e.jsx("div",{className:N("w-8 h-8 rounded-full flex items-center justify-center",t.color.replace("text-","bg-")+"/10"),children:e.jsx(j,{className:N("h-4 w-4",t.color)})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.percentage,"%"]})]})]}),e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"relative h-10 bg-muted/30 rounded-lg overflow-hidden",children:[e.jsx(O.div,{className:N("absolute inset-y-0 left-0 rounded-lg",t.color.replace("text-","bg-")+"/20"),initial:{width:0},animate:{width:`${i}%`},transition:{duration:.5,delay:d*.1}}),e.jsx("div",{className:"absolute inset-0 flex items-center px-4",children:e.jsx("span",{className:"font-bold",children:t.count.toLocaleString()})})]})}),e.jsxs(g,{variant:"outline",size:"sm",className:"w-28",onClick:()=>l==null?void 0:l(t.id),children:[e.jsx(ae,{className:"h-3 w-3 mr-1"}),"Campaign"]})]}),t.dropOff&&!m&&e.jsxs("div",{className:"ml-36 flex items-center gap-2 py-2",children:[e.jsx(fe,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(T,{variant:"outline",className:"text-xs text-destructive border-destructive/20",children:["-",t.dropOff,"% drop-off"]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(t.count*t.dropOff/100)," users left"]})]})]},t.id)})}),e.jsxs("div",{className:"grid grid-cols-4 gap-3 pt-4 border-t",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-2xl font-bold",children:(n=r[0])==null?void 0:n.count.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Registered"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-2xl font-bold text-emerald-500",children:[(u=r[r.length-1])==null?void 0:u.percentage,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Conversion Rate"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-amber-500",children:(h=r[2])==null?void 0:h.count.toLocaleStr
6ing()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Producers"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-rose-500",children:(b=r[r.length-1])==null?void 0:b.count}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Top Performers"})]})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-muted/30 border",children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4 text-primary"}),"Re-activation Opportunities"]}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Inactive users (30+ days)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{variant:"outline",children:"360 users"}),e.jsxs(g,{variant:"ghost",size:"sm",children:["Send Campaign ",e.jsx(Y,{className:"h-3 w-3 ml-1"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"No video posted (active)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{variant:"outline",children:"434 users"}),e.jsxs(g,{variant:"ghost",size:"sm",children:["Send Tips ",e.jsx(Y,{className:"h-3 w-3 ml-1"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"No sales (producing)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{variant:"outline",children:"222 users"}),e.jsxs(g,{variant:"ghost",size:"sm",children:["Offer Support ",e.jsx(Y,{className:"h-3 w-3 ml-1"})]})]})]})]})]})]})]})}const ne=new Date().getFullYear(),Qe=Array.from({length:5},(r,l)=>ne+l);function Ds(){const r=ge(),{t:l}=Pe(),[p,v]=x.useState(ne),[n,u]=x.useState(""),[h,b]=x.useState(new Set),[t,d]=x.useState(!1),[j,i]=x.useState(!1),{data:m=[],isLoading:I}=be(p),k={year:p,search:n},P=s=>{s.year&&v(s.year),s.search&&u(s.search)},V=x.useMemo(()=>{if(!n.trim())return m;const s=n.toLowerCase();return m.filter(c=>c.name.toLowerCase().includes(s)||c.tiktokHandle.toLowerCase().includes(s))},[m,n]),L=m.length,D=m.reduce((s,c)=>s+c.videoStats.total,0),H=s=>{r(`/affiliators/${encodeURIComponent(s)}`)},a=x.useMemo(()=>[{id:"name",header:l("common.name"),accessorKey:"name",width:180,cell:s=>e.jsx("div",{className:"font-medium truncate",children:s.name})},{id:"tiktok",header:"TikTok",accessorKey:"tiktokHandle",width:140,cell:s=>e.jsxs("span",{className:"text-primary",children:["@",s.tiktokHandle.replace("@","")]})},{id:"followers",header:l("common.follower"),accessorKey:"followers",width:100,cell:s=>s.followers.toLocaleString("id-ID")},{id:"phone",header:l("common.phone"),accessorKey:"noHp",width:120,cell:s=>s.noHp||"-"},{id:"jan",header:l("months.jan"),width:50,cell:s=>s.videoStats.january||"-"},{id:"feb",header:l("months.feb"),width:50,cell:s=>s.videoStats.february||"-"},{id:"mar",header:l("months.mar"),width:50,cell:s=>s.videoStats.march||"-"},{id:"apr",header:l("months.apr"),width:50,cell:s=>s.videoStats.april||"-"},{id:"may",header:l("months.may"),width:50,cell:s=>s.videoStats.may||"-"},{id:"jun",header:l("months.jun"),width:50,cell:s=>s.videoStats.june||"-"},{id:"jul",header:l("months.jul"),width:50,cell:s=>s.videoStats.july||"-"},{id:"aug",header:l("months.aug"),width:50,cell:s=>s.videoStats.august||"-"},{id:"sep",header:l("months.sep"),width:50,cell:s=>s.videoStats.september||"-"},{id:"oct",header:l("months.oct"),width:50,cell:s=>s.videoStats.october||"-"},{id:"nov",header:l("months.nov"),width:50,cell:s=>s.videoStats.november||"-"},{id:"dec",header:l("months.dec"),width:50,cell:s=>s.videoStats.december||"-"},{id:"total",header:l("common.total"),width:70,cell:s=>e.jsx("span",{className:"font-bold",children:s.videoStats.total})},{id:"actions",header:"",accessorKey:"id",width:50,cell:s=>e.jsx(g,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),H(s.tiktokHandle)},children:e.jsx(Ve,{className:"h-4 w-4"})})}],[l]),o=x.useCallback(()=>{const s=m.filter(w=>h.has(w.id)),c=[["Name","TikTok","Followers","Phone","Total Videos"],...s.map(w=>[w.name,w.tiktokHandle,w.followers,w.noHp||"",w.videoStats.total])].map(w=>w.join(",")).join(`
7`),K=new Blob([c],{type:"text/csv"}),Z=URL.createObjectURL(K),Q=document.createElement("a");Q.href=Z,Q.download=`affiliators-${p}.csv`,Q.click(),URL.revokeObjectURL(Z),M.success(`Exported ${s.length} affiliators`)},[m,h,p]),f=x.useMemo(()=>m.sort((s,c)=>c.videoStats.total-s.videoStats.total).slice(0,20).map((s,c)=>({id:s.id,rank:c+1,name:s.name,tiktokHandle:s.tiktokHandle,value:s.videoStats.total*5e5,videoCount:s.videoStats.total,conversionRate:Math.random()*10})),[m]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:l("affiliators.title")}),e.jsx("p",{className:"text-muted-foreground",children:l("affiliators.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ie,{storageKey:"affiliators",currentFilters:k,onLoadPreset:P}),e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>d(!t),children:[e.jsx(B,{className:"h-4 w-4 mr-2"}),"Leaderboard"]}),e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>i(!j),children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),"Calculator"]}),e.jsx(Fe,{open:!1,onOpenChange:()=>{},onImportAffiliators:async s=>{console.log("Importing",s.length,"affiliators"),M.success(`Imported ${s.length} affiliators`)}}),e.jsxs(g,{variant:"outline",size:"sm",onClick:o,disabled:h.size===0,children:[e.jsx(ce,{className:"h-4 w-4 mr-2"}),"Export ",h.size>0&&`(${h.size})`]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(y,{children:e.jsx(C,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-lg bg-primary/10",children:e.jsx(le,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:l("affiliators.totalAffiliator")}),e.jsx("p",{className:"text-2xl font-bold",children:e.jsx(z,{value:L})})]})]})})}),e.jsx(y,{children:e.jsx(C,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-lg bg-primary/10",children:e.jsx(G,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[l("affiliators.totalVideo")," ",p]}),e.jsx("p",{className:"text-2xl font-bold",children:e.jsx(z,{value:D})})]})]})})}),e.jsx(y,{children:e.jsx(C,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-lg bg-emerald-500/10",children:e.jsx(B,{className:"h-6 w-6 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active This Month"}),e.jsx("p",{className:"text-2xl font-bold",children:e.jsx(z,{value:Math.floor(L*.7)})})]})]})})}),e.jsx(y,{children:e.jsx(C,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-lg bg-amber-500/10",children:e.jsx(Be,{className:"h-6 w-6 text-amber-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Avg Videos/Month"}),e.jsx("p",{className:"text-2xl font-bold",children:e.jsx(z,{value:L>0?Math.round(D/12/L):0})})]})]})})})]}),e.jsx(Ke,{}),(t||j)&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[t&&e.jsx(Oe,{data:f}),j&&e.jsx(Ue,{})]}),e.jsx(q,{value:p.toString(),onValueChange:s=>v(parseInt(s)),children:e.jsx(J,{children:Qe.map(s=>e.jsx(A,{value:s.toString(),children:s},s))})}),e.jsx(y,{children:e.jsx(C,{className:"pt-6",children:e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(ve,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(re,{placeholder:l("affiliators.searchPlaceholder"),value:n,onChange:s=>u(s.target.value),className:"pl-10"})]})})}),e.jsx(ye,{selectedCount:h.size,onClear:()=>b(new Set),onExport:o}),e.jsxs(y,{children:[e.jsx(E,{children:e.jsxs($,{className:"flex items-center justify-between",children:[e.jsxs("span",{children:["Affiliators (",V.length,")"]}),V.length>100&&e.jsx(T,{variant:"secondary",children:"Virtual Scroll Enabled"})]})}),e.jsx(C,{children:I?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,c)=>e.jsx(Ne,{className:"h-12 w-full"},c))}):e.jsx(we,{data:V,columns:a,rowHeight:48,selectedIds:h,onSelectionChange:b,onRowClick:s=>H(s.tiktokHandle),emptyMessage:l(n?"affiliators.noSearchResults":"affiliators.noAffiliators")})})]})]})}export{Ds as default};
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.