1import{a as l,j as e}from"./vendor-react-5BUW_FQY.js";import{u as X}from"./use-seo-CxNse_hl.js";import{u as Y}from"./index-D6Bj_eiE.js";import{L as Z}from"./vendor-router-B8lZ4E-e.js";import{f as H,aA as g,aI as U,au as G,aP as W,L as j,ax as ee,q as te,a1 as se,r as ae,e as J,aJ as le,C as ie,aY as ne,aL as re,l as de,aZ as oe,a_ as ce}from"./vendor-icons-C_vOXKuu.js";import{A as F,m as f}from"./vendor-motion-BMdIFYxW.js";import"./vendor-query-25OakG25.js";import"./vendor-clerk-DfvZ0u2Z.js";import"./vendor-radix-DRKF9-Iq.js";import"./vendor-charts-P5q2ppjw.js";const p=async(i,r)=>{const a=await fetch(`/api/appstore${i}`,{credentials:"include",headers:{"Content-Type":"application/json",...r?.headers??{}},...r});if(!a.ok){const x=await a.json().catch(()=>({error:a.statusText}));throw new Error(x.error??a.statusText)}return a.json()};function N({icon:i,label:r,value:a,sub:x,color:d}){return e.jsxs("div",{className:"rounded-xl border border-white/[0.07] bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`w-7 h-7 rounded-lg ${d} flex items-center justify-center`,children:e.jsx(i,{className:"w-3.5 h-3.5 text-white"})}),e.jsx("span",{className:"text-[11px] text-muted-foreground/60 font-medium uppercase tracking-wide",children:r})]}),e.jsx("p",{className:"text-2xl font-bold text-white",children:a}),x&&e.jsx("p",{className:"text-[11px] text-muted-foreground/40 mt-0.5",children:x})]})}function xe({status:i}){const r={sent:"text-emerald-400 bg-emerald-500/10 border-emerald-500/20",manual:"text-sky-400 bg-sky-500/10 border-sky-500/20",pending:"text-yellow-400 bg-yellow-500/10 border-yellow-500/20",failed:"text-red-400 bg-red-500/10 border-red-500/20"};return e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded-full border capitalize ${r[i]??"text-muted-foreground"}`,children:i})}function me({message:i,onConfirm:r,onCancel:a}){return e.jsx(f.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.75)",backdropFilter:"blur(12px)"},children:e.jsxs(f.div,{initial:{scale:.9},animate:{scale:1},exit:{scale:.9},className:"rounded-2xl p-6 max-w-sm w-full text-center",style:{background:"rgba(14,14,20,0.98)",border:"1px solid rgba(255,255,255,0.1)"},children:[e.jsx(ce,{className:"w-8 h-8 text-yellow-400 mx-auto mb-3"}),e.jsx("p",{className:"text-sm font-semibold text-white mb-5",children:i}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:a,className:"flex-1 py-2 rounded-xl text-sm font-medium text-muted-foreground border border-white/[0.08] hover:text-white transition-all",children:"Cancel"}),e.jsx("button",{onClick:r,className:"flex-1 py-2 rounded-xl text-sm font-bold text-white hover:opacity-90 transition-all",style:{background:"linear-gradient(135deg, #e11d48, #be123c)"},children:"Confirm"})]})]})})}function ve(){X({title:"App Store Admin â Kairobot Internal Review Dashboard",description:"Internal admin dashboard for reviewing and approving Kairobot App Store submissions.",noIndex:!0});const{isAuthenticated:i,login:r}=Y(),[a,x]=l.useState(null),[d,w]=l.useState([]),[v,K]=l.useState([]),[b,D]=l.useState([]),[k,E]=l.useState(!0),[P,R]=l.useState(!1),[S,T]=l.useState(null),[$,I]=l.useState(null),[y,L]=l.useState(null),[C,o]=l.useState(null),[_,q]=l.useState(!1),[u,O]=l.useState(null);function c(t,s){L({type:t,msg:s}),setTimeout(()=>L(null),5e3)}const h=l.useCallback(async()=>{E(!0);try{const[t,s,n]=await Promise.all([p("/admin/stats"),p("/admin/payouts"),p("/admin/pending")]);x(t),w((s.developers??[]).map(A=>({...A,selected:!0}))),K(s.history??[]),D(n.apps??[])}catch(t){c("error",t.message)}finally{E(!1)}},[]);l.useEffect(()=>{i&&h()},[i,h]);function Q(t){w(s=>s.map(n=>n.id===t?{...n,selected:!n.selected}:n))}const m=d.filter(t=>t.selected),M=m.reduce((t,s)=>t+parseFloat(s.pendingPayout),0);async function B(t){R(!0),O(null);try{const s=await p("/admin/payouts/send",{method:"POST",body:JSON.stringify({developerIds:t})});O(s),c("success",`Sent $${s.totalPaid} to ${s.payouts.length} developer(s) via PayPal!`),h()}catch(s){c("error",s.message)}finally{R(!1)}}async function V(t){T(t);try{await p(`/admin/payouts/manual/${t}`,{method:"POST"}),c("success","Marked as manually paid"),h()}catch(s){c("error",s.message)}finally{T(null)}}async function z(t,s){I(t);try{await p(`/admin/apps/${t}/${s}`,{method:"POST"}),c("success",`App ${s}d`),D(n=>n.filter(A=>A.id!==t))}catch(n){c("error",n.message)}finally{I(null)}}return i?e.jsxs("div",{className:"min-h-screen px-4 py-8 max-w-5xl mx-auto",children:[e.jsx(F,{children:y&&e.jsxs(f.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:`fixed top-20 left-1/2 -translate-x-1/2 z-50 px-4 py-3 rounded-xl shadow-2xl text-sm font-medium flex items-center gap-2 ${y.type==="success"?"bg-emerald-900/90 text-emerald-200 border border-emerald-700/50":"bg-red-900/90 text-red-200 border border-red-700/50"}`,children:[y.type==="success"?e.jsx(g,{className:"w-4 h-4"}):e.jsx(U,{className:"w-4 h-4"}),y.msg]})}),e.jsx(F,{children:C&&e.jsx(me,{message:C.msg,onConfirm:()=>{C.onConfirm(),o(null)},onCancel:()=>o(null)})}),e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{children:[e.jsxs(Z,{href:"/app-store",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground/60 hover:text-white mb-2 transition-all",children:[e.jsx(G,{className:"w-4 h-4"})," Back to Store"]}),e.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[e.jsx(H,{className:"w-6 h-6 text-red-400"}),"Admin Panel"]}),e.jsx("p",{className:"text-sm text-muted-foreground/50 mt-0.5",children:"Platform revenue, payouts, and app approvals"})]}),e.jsx("button",{onClick:h,disabled:k,className:"p-2 rounded-xl border border-white/[0.08] text-muted-foreground hover:text-white hover:border-white/[0.15] transition-all",children:e.jsx(W,{className:`w-4 h-4 ${k?"animate-spin":""}`})})]}),k?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(j,{className:"w-8 h-8 animate-spin text-red-400"})}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground
1/40 mb-4",children:"Platform Revenue"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(N,{icon:ee,label:"Platform Revenue",color:"bg-blue-600",value:`$${(a?.platformRevenue??0).toFixed(2)}`,sub:`${a?.totalTransactions??0} transactions`}),e.jsx(N,{icon:te,label:"App Sales",color:"bg-sky-600",value:`$${(a?.purchaseRevenue??0).toFixed(2)}`,sub:`${a?.totalPurchases??0} purchases`}),e.jsx(N,{icon:se,label:"Subscriptions",color:"bg-emerald-600",value:`$${(a?.subscriptionRevenue??0).toFixed(2)}`,sub:`${a?.activeSubscriptions??0} active`}),e.jsx(N,{icon:ae,label:"Total Apps",color:"bg-orange-600",value:String(a?.totalApps??0),sub:`${a?.approvedApps??0} live · ${a?.pendingApps??0} pending`})]})]}),e.jsxs("section",{children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("h2",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground/40",children:["Developer Payouts",d.length>0&&e.jsxs("span",{className:"ml-2 text-yellow-400 normal-case",children:[d.length," pending"]})]})}),d.length===0?e.jsxs("div",{className:"rounded-2xl p-6 text-center",style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx(g,{className:"w-8 h-8 text-emerald-400 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground/60",children:"All developers are paid up â no pending balances."})]}):e.jsxs("div",{className:"rounded-2xl overflow-hidden",style:{border:"1px solid rgba(255,255,255,0.07)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/[0.06]",style:{background:"rgba(255,255,255,0.02)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:m.length===d.length,onChange:t=>w(s=>s.map(n=>({...n,selected:t.target.checked}))),className:"w-4 h-4 accent-blue-500 rounded cursor-pointer"}),e.jsxs("span",{className:"text-xs text-muted-foreground/60",children:[m.length," of ",d.length," selected · ",e.jsxs("span",{className:"text-white font-semibold",children:["$",M.toFixed(2)]})," total"]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("button",{disabled:m.length===0||P,onClick:()=>o({msg:`Send $${M.toFixed(2)} to ${m.length} developer(s) via PayPal?`,onConfirm:()=>B(m.map(t=>t.id))}),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-xs font-bold text-white hover:opacity-90 disabled:opacity-40 transition-all",style:{background:"linear-gradient(135deg, #e11d48, #be123c)"},children:[P?e.jsx(j,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(J,{className:"w-3.5 h-3.5"}),"Send via PayPal"]})})]}),e.jsx("div",{className:"divide-y divide-white/[0.04]",children:d.map(t=>e.jsxs("div",{className:"flex items-center gap-4 px-5 py-4",children:[e.jsx("input",{type:"checkbox",checked:!!t.selected,onChange:()=>Q(t.id),className:"w-4 h-4 accent-blue-500 rounded cursor-pointer shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-semibold text-white truncate",children:t.displayName}),t.isVerified&&e.jsx(g,{className:"w-3 h-3 text-red-400 shrink-0"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground/50 truncate",children:t.email}),t.paypalEmail?e.jsx("p",{className:"text-[10px] text-emerald-400/70 truncate",children:t.paypalEmail}):e.jsx("p",{className:"text-[10px] text-orange-400/80",children:"No PayPal email â can't auto-pay"})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsxs("p",{className:"text-sm font-bold text-white",children:["$",parseFloat(t.pendingPayout).toFixed(2)]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground/40",children:["$",parseFloat(t.totalEarned).toFixed(2)," lifetime"]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 justify-end",children:[t.paypalEmail&&e.jsxs("button",{disabled:P||S===t.id,onClick:()=>o({msg:`Send $${parseFloat(t.pendingPayout).toFixed(2)} to ${t.displayName} (${t.paypalEmail}) via PayPal?`,onConfirm:()=>B([t.id])}),className:"flex items-center gap-1 px-2 py-1 rounded-lg text-[10px] font-bold text-white hover:opacity-80 disabled:opacity-40 transition-all",style:{background:"rgba(225,29,72,0.5)"},children:[S===t.id?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(J,{className:"w-3 h-3"}),"Pay"]}),e.jsx("button",{disabled:S===t.id,onClick:()=>o({msg:`Mark $${parseFloat(t.pendingPayout).toFixed(2)}
1 for ${t.displayName} as manually paid?`,onConfirm:()=>V(t.id)}),className:"flex items-center gap-1 px-2 py-1 rounded-lg text-[10px] font-medium text-muted-foreground/60 hover:text-white border border-white/[0.08] transition-all",children:"Manual"})]})]})]},t.id))})]}),u&&e.jsxs(f.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"mt-3 rounded-xl p-4",style:{background:"rgba(5,150,105,0.1)",border:"1px solid rgba(5,150,105,0.25)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(g,{className:"w-4 h-4 text-emerald-400"}),e.jsxs("p",{className:"text-sm font-semibold text-emerald-300",children:["PayPal batch sent â $",u.totalPaid," to ",u.payouts.length," developer(s)"]})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground/50",children:["Batch ID: ",u.batchId]}),e.jsx("div",{className:"mt-2 space-y-1",children:u.payouts.map((t,s)=>e.jsxs("p",{className:"text-[11px] text-muted-foreground/60",children:["â ",t.developer," (",t.paypalEmail,") â ",e.jsxs("span",{className:"text-white",children:["$",t.amount.toFixed(2)]})]},s))})]})]}),e.jsxs("section",{children:[e.jsxs("h2",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground/40 mb-4",children:["App Review Queue",b.length>0&&e.jsxs("span",{className:"ml-2 text-yellow-400 normal-case",children:[b.length," waiting"]})]}),b.length===0?e.jsxs("div",{className:"rounded-2xl p-6 text-center",style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx(g,{className:"w-8 h-8 text-emerald-400 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground/60",children:"No apps waiting for review â all clear."})]}):e.jsx("div",{className:"rounded-2xl overflow-hidden divide-y divide-white/[0.04]",style:{border:"1px solid rgba(255,255,255,0.07)"},children:b.map(t=>e.jsxs("div",{className:"flex items-center gap-4 px-5 py-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-white truncate",children:t.name}),e.jsxs("p",{className:"text-[11px] text-muted-foreground/50 capitalize truncate",children:[t.category," · ",t.pricing," · by ",t.devName??t.devEmail]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground/30",children:["Submitted ",new Date(t.createdAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("a",{href:"#",className:"p-1.5 rounded-lg text-muted-foreground/50 hover:text-white border border-white/[0.07] transition-all",children:e.jsx(le,{className:"w-3.5 h-3.5"})}),e.jsxs("button",{disabled:$===t.id,onClick:()=>o({msg:`Approve "${t.name}"?`,onConfirm:()=>z(t.id,"approve")}),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-[11px] font-bold text-emerald-400 hover:bg-emerald-500/10 border border-emerald-500/20 transition-all disabled:opacity-50",children:[$===t.id?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(ie,{className:"w-3 h-3"}),"Approve"]}),e.jsxs("button",{disabled:$===t.id,onClick:()=>o({msg:`Reject "${t.name}"?`,onConfirm:()=>z(t.id,"reject")}),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-[11px] font-bold text-red-400 hover:bg-red-500/10 border border-red-500/20 transition-all disabled:opacity-50",children:[e.jsx(U,{className:"w-3 h-3"}),"Reject"]})]})]},t.id))})]}),e.jsxs("section",{children:[e.jsxs("button",{onClick:()=>q(t=>!t),className:"flex items-center gap-2 text-xs font-bold uppercase tracking-widest text-muted-foreground/40 hover:text-muted-foreground/70 transition-all mb-4",children:[e.jsx(ne,{className:"w-3.5 h-3.5"}),"Payout History (",v.length,")",_?e.jsx(re,{className:"w-3.5 h-3.5"}):e.jsx(de,{className:"w-3.5 h-3.5"})]}),e.jsx(F,{children:_&&e.jsx(f.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:v.length===0?e.jsx("p",{className:"text-sm text-muted-foreground/40 py-4",children:"No payout history yet."}):e.jsx("div",{className:"rounded-2xl overflow-hidden divide-y divide-white/[0.04]",style:{border:"1px solid rgba(255,255,255,0.07)"},children:v.map(t=>e.jsxs("div",{className:"flex items-center gap-4 px-5 py-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-white truncate",children:t.display_name}
1),e.jsx("p",{className:"text-[10px] text-muted-foreground/50 truncate",children:t.paypal_email})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsxs("p",{className:"text-sm font-bold text-white",children:["$",parseFloat(t.amount).toFixed(2)]}),e.jsxs("div",{className:"flex items-center gap-2 justify-end mt-0.5",children:[e.jsx(xe,{status:t.status}),e.jsx("span",{className:"text-[10px] text-muted-foreground/30",children:new Date(t.created_at).toLocaleDateString()})]}),t.paypal_batch_id&&e.jsx("p",{className:"text-[9px] text-muted-foreground/20 truncate max-w-[160px]",children:t.paypal_batch_id})]})]},t.id))})})})]}),e.jsxs("div",{className:"rounded-xl p-4 flex gap-3",style:{background:"rgba(225,29,72,0.06)",border:"1px solid rgba(225,29,72,0.12)"},children:[e.jsx(oe,{className:"w-4 h-4 text-red-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs text-muted-foreground/50 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-green-400 font-medium",children:"PayPal live mode is active"})," â payouts process in real time using your live PayPal credentials."]}),e.jsx("p",{children:"Payouts use the PayPal Mass Payouts API. Each developer must have a PayPal email registered in their Developer Profile to receive automatic payouts."}),e.jsx("p",{children:'Use "Manual" to mark a payout as paid if you handle it outside the platform (bank transfer, check, etc.).'})]})]})]})]}):e.jsx("div",{className:"min-h-screen flex items-center justify-center px-4",children:e.jsxs("div",{className:"text-center max-w-sm",children:[e.jsx(H,{className:"w-10 h-10 text-red-400 mx-auto mb-3"}),e.jsx("h2",{className:"text-xl font-bold text-white mb-2",children:"Admin Panel"}),e.jsx("p",{className:"text-sm text-muted-foreground/60 mb-5",children:"Sign in to access the admin panel."}),e.jsx("button",{onClick:r,className:"px-5 py-2.5 rounded-xl text-sm font-bold text-white hover:opacity-90 transition-all",style:{background:"linear-gradient(135deg, #e11d48, #be123c)"},children:"Sign In"})]})})}export{ve 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.