1import{k as A,r as L,j as e,S as $,B as D,L as l,f as u}from"./index-DSd_KA67.js";import{u as p}from"./useQuery-DI1zqRFq.js";import{a as x}from"./api-DEjVNANO.js";import{C as M}from"./ConversationViewDialog-BcLDIsPU.js";import{c as z}from"./createLucideIcon-BC48Drc1.js";import{A as i}from"./index-B-2pgCUr.js";import{E as F}from"./eye-kvAxFjmq.js";import{C as m}from"./index-DU87hghX.js";import{C as V}from"./index-BDCF4RGH.js";import"./use_paginated_query-BRxdp19C.js";import"./index-BcV1WcSQ.js";import"./Dialog-ChwbEPk_.js";import"./Modal-DNKE2hrT.js";import"./surface-CXiMNM_t.js";import"./ban-CR4U0QKw.js";import"./x-DEPUe6e3.js";import"./arrow-left-gte9njEQ.js";import"./arrow-right-DeQur32B.js";const W=[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z",key:"s09mg5"}]],E=z("cloud-sun",W);function H(){const{data:t,isLoading:a}=p(u(x.admin.getAdminStats,{})),{data:n,isLoading:o}=p(u(x.admin.getAdminDashboardFeed,{})),{data:j}=p(u(x.admin.getMostViewedServices,{}));return{stats:t,feed:n,topServices:j,isLoading:a||o}}function Z(){const{stats:t,feed:a,topServices:n,isLoading:o}=H(),j=A(x.admin.triggerWeatherRefresh),[P,g]=L.useState(!1),[R,v]=L.useState(null),T=async()=>{g(!0);try{await j({})}finally{g(!1)}};if(o)return e.jsx("div",{className:"min-h-dvh flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx($,{size:"xl"}),e.jsx("p",{className:"text-sm text-muted",children:"Loading dashboard..."})]})});const N=a?.latestUsers??[],w=a?.latestReports??[],b=a?.latestListings??[],y=a?.latestServices??[],k=a?.latestReviews??[],C=a?.latestSessions??[],S=a?.latestTickets??[],I=a?.latestConversations??[];return e.jsxs("main",{className:"w-full flex flex-col gap-6 px-4 py-6 sm:px-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Dashboard"}),e.jsx("p",{className:"text-sm text-muted mt-0.5",children:"Platform overview and recent activity"})]}),e.jsxs(D,{size:"sm",variant:"secondary",isPending:P,onPress:T,children:[e.jsx(E,{size:16}),"Refresh Weather"]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"rounded-xl border border-muted/20 bg-surface p-5",children:[e.jsx("h2",{className:"text-sm font-medium text-muted uppercase tracking-wide mb-4",children:"Platform"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(r,{label:"Users",value:t?.totalUsers??0}),e.jsx(r,{label:"Services",value:t?.totalServices??0}),e.jsx(r,{label:"Active Listings",value:t?.activeListings??0}),e.jsx(r,{label:"Conversations",value:t?.totalConversations??0}),e.jsx("div",{className:"border-t border-muted/10 my-1"}),e.jsx(l,{to:"/admin/reports",className:"hover:opacity-80 transition-opacity",children:e.jsx(r,{label:"Pending Reports",value:t?.pendingReports??0,colorClass:"text-warning"})}),e.jsx(l,{to:"/admin/tickets",className:"hover:opacity-80 transition-opacity",children:e.jsx(r,{label:"Pending Tickets",value:t?.pendingTickets??0,colorClass:"text-warning"})})]})]}),e.jsxs("div",{className:"rounded-xl border border-muted/20 bg-surface p-5",children:[e.jsx("h2",{className:"text-sm font-medium text-muted uppercase tracking-wide mb-4",children:"Subscriptions"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(h,{label:"Paying"}),e.jsx(r,{label:"Pro",value:t?.payingProCount??0,colorClass:"text-accent"}),e.jsx(r,{label:"Pro+",value:t?.payingProplusCount??0,colorClass:"text-accent"}),e.jsx(h,{label:"Free"}),e.jsx(r,{label:"Users",value:t?.freeCount??0}),e.jsx(h,{label:"Admin Granted"}),e.jsx(r,{label:"Founders",value:t?.adminFoundersCount??0,colorClass:"text-warning"}),e.jsx(r,{label:"Pro",value:t?.adminProCount??0,muted:!0}),e.jsx(r,{label:"Pro+",value:t?.adminProplusCount??0,muted:!0}),e.jsx(h,{label:"Promo"}),e.jsx(r,{label:"Pro",value:t?.promoProCount??0,muted:!0}
1),e.jsx(r,{label:"Pro+",value:t?.promoProplusCount??0,muted:!0})]})]})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-medium text-muted mb-3 uppercase tracking-wide",children:"Recent Activity"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsx(c,{title:"Latest Users",href:"/admin/users",empty:N.length===0,children:N.map(s=>e.jsxs(l,{to:"/admin/users/$userId",params:{userId:s._id},search:{expandedServiceId:void 0,from:void 0},className:"py-2 flex items-center justify-between gap-2 text-sm px-1 -mx-1 rounded-lg hover:bg-surface-secondary/40 transition-colors",children:[e.jsxs("div",{className:"min-w-0 flex items-center gap-3",children:[e.jsxs(i,{size:"sm",color:"accent",className:"shrink-0",children:[s.imageUrl&&e.jsx(i.Image,{src:s.imageUrl,alt:s.name}),e.jsx(i.Fallback,{children:s.name?.charAt(0)?.toUpperCase()??"?"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:s.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted truncate",children:s.email})]})]}),e.jsx("span",{className:"text-xs text-muted whitespace-nowrap",children:d(s._creationTime)})]},s._id))}),e.jsx(c,{title:"Latest Reports",href:"/admin/reports",empty:w.length===0,children:w.map(s=>e.jsxs(f,{children:[e.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[e.jsx("span",{className:"truncate capitalize",children:s.targetType}),e.jsx(_,{status:s.status})]}),e.jsx("span",{className:"text-xs text-muted whitespace-nowrap",children:d(s._creationTime)})]},s._id))}),e.jsx(c,{title:"Latest Listings",empty:b.length===0,children:b.map(s=>e.jsxs(f,{children:[e.jsxs("div",{className:"min-w-0 flex items-center gap-3",children:[s.imageUrl?e.jsx("img",{src:s.imageUrl,alt:s.title,className:"w-10 h-10 rounded-lg object-cover shrink-0 bg-surface-secondary"}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-surface-secondary shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:s.title}),e.jsxs("p",{className:"text-xs text-muted truncate",children:["$",s.price.toLocaleString()," · ",s.sellerName]})]})]}),e.jsx("span",{className:"text-xs text-muted whitespace-nowrap",children:d(s._creationTime)})]},s._id))}),e.jsx(c,{title:"Latest Services",empty:y.length===0,children:y.map(s=>{const U=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-w-0 flex items-center gap-3",children:[s.imageUrl?e.jsx("img",{src:s.imageUrl,alt:s.name,className:"w-10 h-10 rounded-lg object-cover shrink-0 bg-surface-secondary"}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-surface-secondary shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:s.name}),e.jsxs("p",{className:"text-xs text-muted truncate capitalize",children:[s.type.replace(/([A-Z])/g," $1").trim()," · ",s.vendorName]})]})]}),e.jsx("span",{className:"text-xs text-muted whitespace-nowrap",children:d(s._creationTime)})]});return s.vendorUserId?e.jsx(l,{to:"/admin/users/$userId",params:{userId:s.vendorUserId},search:{expandedServiceId:s._id,from:"dashboard"},className:"py-2 flex items-center justify-between gap-2 text-sm px-1 -mx-1 rounded-lg hover:bg-surface-secondary/40 transition-colors",children:U},s._id):e.jsx("div",{className:"py-2 flex items-center justify-between gap-2 text-sm",children:U},s._id)})}),e.jsx(c,{title:"Most Viewed Services",children:n===void 0?null:n.length===0?e.jsx("p",{className:"text-xs text-muted py-2",children:"No views recorded yet"}):n.map(s=>e.jsxs(l,{to:"/admin/users/$userId",params:{userId:s.vendorUserId},search:{expandedServiceId:s.serviceId,from:"dashboard"},className:"py-2 flex items-center justify-between gap-2 text-sm px-1 -mx-1 rounded-lg hover:bg-surface-secondary/40 transition-colors",children:[e.jsxs("div",{className:"min-w-0 flex items-center gap-3",children:[s.firstImageUrl?e.jsx("img",{src:s.firstImageUrl,alt:s.serviceName,className:"w-10 h-10 rounded-lg object-cover shrink-0 bg-surface-secondary"}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-surface-secondary shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:s.serviceName}),e.jsxs("p",{className:"text-xs text-muted truncate capitalize",children:[s.serviceType.replace(/([A-Z])/g," $1").trim()," · ",s.vendorName]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0 tabular-nums text-xs text-muted",children:[e.jsx(F,{className:"size-3.5"}
1),s.views.toLocaleString()]})]},s.serviceId))}),e.jsx(c,{title:"Latest Reviews",href:"/admin/reviews",empty:k.length===0,children:k.map(s=>e.jsxs(l,{to:"/admin/reviews/$reviewId",params:{reviewId:s._id},search:{from:"dashboard"},className:"py-2 flex flex-col gap-1.5 px-1 -mx-1 rounded-lg hover:bg-surface-secondary/40 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-medium truncate min-w-0",children:s.serviceName}),e.jsxs("span",{className:"text-xs text-warning whitespace-nowrap shrink-0 tabular-nums",children:[Math.round(s.overallRating)," â
"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(i,{size:"sm",color:"accent",className:"shrink-0",children:[s.authorImageUrl&&e.jsx(i.Image,{src:s.authorImageUrl,alt:s.authorName}),e.jsx(i.Fallback,{children:s.authorName.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-xs text-muted truncate flex-1 min-w-0",children:s.authorName}),e.jsx("span",{className:"text-xs text-muted whitespace-nowrap ml-8 shrink-0",children:d(s._creationTime)})]})]},s._id))}),e.jsx(c,{title:"Latest Sessions",empty:C.length===0,children:C.map(s=>e.jsxs(f,{children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium truncate",children:["Session ",s.sessionNumber,s.sessionType&&e.jsxs("span",{className:"text-muted font-normal",children:[" · ",s.sessionType]})]}),e.jsxs("p",{className:"text-xs text-muted truncate",children:[s.userName," â ",s.dayTitle,s.bestLap&&e.jsxs("span",{children:[" · ",s.bestLap]})]})]}),e.jsx("span",{className:"text-xs text-muted whitespace-nowrap",children:d(s._creationTime)})]},s._id))}),e.jsx(c,{title:"Latest Tickets",href:"/admin/tickets",empty:S.length===0,children:S.map(s=>e.jsxs(l,{to:"/admin/tickets/$ticketId",params:{ticketId:s._id},search:{from:void 0},className:"py-2 flex items-center justify-between gap-2 text-sm px-1 -mx-1 rounded-lg hover:bg-surface-secondary/40 transition-colors",children:[e.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[e.jsx("span",{className:"truncate",children:s.title}),e.jsx(_,{status:s.status})]}),e.jsx("span",{className:"text-xs text-muted whitespace-nowrap",children:d(s.createdAt)})]},s._id))}),e.jsxs("div",{className:"rounded-xl border border-muted/20 bg-surface p-4 flex flex-col gap-3",style:{height:450},children:[e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Latest Conversations"}),e.jsx(l,{to:"/admin/conversations",className:"text-xs text-muted hover:text-foreground transition-colors",children:"View all â"})]}),I.length===0?e.jsx("p",{className:"text-xs text-muted py-2",children:"Nothing yet"}):e.jsx("div",{className:"flex flex-col gap-2 overflow-y-auto min-h-0 pr-1 scrollbar-discreet",children:I.map(s=>e.jsxs(m,{variant:"secondary",className:"cursor-pointer shrink-0",onClick:()=>v(s._id),children:[e.jsx(m.Header,{children:e.jsxs("div",{className:"flex items-start justify-between gap-2 w-full",children:[e.jsx(m.Title,{className:"text-xs truncate flex-1",children:s.contextName??s.initialSubject}),e.jsx("span",{className:"text-xs text-muted whitespace-nowrap shrink-0",children:d(s.lastMessageAt)})]})}),e.jsxs(m.Content,{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[e.jsxs(i,{size:"sm",color:"accent",className:"shrink-0",children:[s.initiatorImageUrl&&e.jsx(i.Image,{src:s.initiatorImageUrl,alt:""}),e.jsx(i.Fallback,{children:(s.initiatorName??"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm truncate",children:s.initiatorName??"Unknown"})]}),e.jsx("span",{className:"text-muted/30 shrink-0 text-xs select-none",children:"|"}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1 justify-end",children:[e.jsx("span",{className:"text-sm text-muted overflow-hidden whitespace-nowrap flex-1",style:{direction:"rtl",textOverflow:"ellipsis"},children:s.vendorDisplayName??"Unknown"}),e.jsxs(i,{size:"sm",color:"default",className:"shrink-0",children:[s.vendorDisplayImageUrl&&e.jsx(i.Image,{src:s.vendorDisplayImageUrl,alt:""}),e.jsx(i.Fallback,{children:(s.vendorDisplayName??"?").charAt(0).toUpperCase()})]})]})]}),e.jsx(m.Description,{className:"truncate",children:s.initialSubject})]})]},s._id))})]})]})]}),e.jsx(Q,{conversationId:R,onClose:()=>v(null)})]})}function r({label:t,value:a,colorClass:n,muted:o}){return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:`text-sm ${o?"text-muted":"text-foreground"}`,children:t}),e.jsx("span",{className:`text-sm font-semibold tabular-nums ${n??"text-foreground"}
1`,children:a.toLocaleString()})]})}function h({label:t}){return e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-xs text-muted uppercase tracking-wide",children:t}),e.jsx("div",{className:"flex-1 border-t border-muted/10"})]})}function c({title:t,href:a,empty:n,children:o}){return e.jsxs("div",{className:"rounded-xl border border-muted/20 bg-surface p-4 flex flex-col gap-3",style:{height:450},children:[e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsx("h3",{className:"text-sm font-semibold",children:t}),a&&e.jsx(l,{to:a,className:"text-xs text-muted hover:text-foreground transition-colors",children:"View all â"})]}),n?e.jsx("p",{className:"text-xs text-muted py-2",children:"Nothing yet"}):e.jsx("div",{className:"flex flex-col divide-y divide-muted/10 overflow-y-auto min-h-0 pr-1 scrollbar-discreet",children:o})]})}function f({children:t,onClick:a}){return e.jsx("div",{className:`py-2 flex items-center justify-between gap-2 text-sm${a?" cursor-pointer hover:bg-surface-secondary/40 rounded-lg px-1 -mx-1 transition-colors":""}`,onClick:a,children:t})}const B={pending:"warning",completed:"success",reviewed:"success",active:"success",dismissed:"default",closed:"default",archived:"default",sold:"accent",expired:"danger",deleted:"danger"};function _({status:t}){return e.jsx(V,{color:B[t]??"default",variant:"soft",size:"sm",className:"shrink-0",children:t})}function d(t){const a=Date.now()-t;return a<6e4?"just now":a<36e5?`${Math.floor(a/6e4)}m ago`:a<864e5?`${Math.floor(a/36e5)}h ago`:`${Math.floor(a/864e5)}d ago`}function Q({conversationId:t,onClose:a}){const{data:n}=p(u(x.admin.getConversationAdmin,t?{conversationId:t}:"skip"));return e.jsx(M,{conversationId:t,conversation:n??void 0,onClose:a})}const me=Z;export{me as component};
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.