1import{a as y,u as M,r as c,j as e,B as m,s as C,e as d,t as k}from"./index-CvEPeg3_.js";import{T as D,a as V,b as g,c as j}from"./tabs-PHKJ489b.js";import{L as $}from"./loader-circle-B6Zrtwc3.js";import{A as R}from"./arrow-left-right-BG92ZzFQ.js";import{P as I}from"./plus-DftMvCUB.js";import{A as B}from"./arrow-right-dA4x6MUF.js";import{H as P}from"./heart-Bzlf6whz.js";import{E as v}from"./eye-DPTcPsPm.js";import{S as K}from"./star-BocNYY0q.js";import{C as U}from"./circle-check-big-AeiHTj9R.js";import"./index-DYWxs8U7.js";import"./index-DquPUldy.js";const _={open:"bg-green-500/20 text-green-400",pending:"bg-yellow-500/20 text-yellow-400",active:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",cancelled:"bg-red-500/20 text-red-400",disputed:"bg-orange-500/20 text-orange-400"};function q({swap:t,interests:i,onView:o,onManage:x}){const{t:a}=y(),p=i.filter(r=>r.swap_id===t.id&&r.status==="pending").length;return e.jsx("div",{className:"p-4 rounded-2xl border border-border bg-card hover:border-purple-500/30 transition-all",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("span",{className:`text-xs font-bold px-2 py-0.5 rounded-full ${_[t.status]||"bg-muted text-muted-foreground"}`,children:t.status}),t.is_featured&&e.jsxs("span",{className:"text-xs font-bold text-yellow-400",children:["â
",a("ms.featured")]}),t.is_urgent&&e.jsxs("span",{className:"text-xs font-bold text-red-400",children:["â¡ ",a("ms.urgent")]})]}),e.jsx("h3",{className:"font-bold text-sm truncate",children:t.offered_title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["â ",t.open_to_offers?a("ms.openToOffers"):t.requested_title]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[e.jsx(v,{className:"w-3 h-3 inline mr-0.5"}),t.view_count||0," ",a("ms.views")]}),e.jsxs("span",{children:[e.jsx(P,{className:"w-3 h-3 inline mr-0.5"}),t.interest_count||0," ",a("ms.interested")]}),p>0&&e.jsx("span",{className:"text-purple-400 font-bold",children:a("ms.pendingReview",{n:p})})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 flex-shrink-0",children:[e.jsxs(m,{size:"sm",variant:"outline",onClick:()=>o(t.id),className:"text-xs gap-1",children:[e.jsx(v,{className:"w-3 h-3"})," ",a("ms.view")]}),t.status==="open"&&e.jsx(m,{size:"sm",onClick:()=>x(t.id),className:"text-xs gap-1 bg-purple-600 hover:bg-purple-500 text-white",children:a("ms.manage")})]})]})})}function le(){const{t}=y(),i=M(),[o,x]=c.useState(null),[a,p]=c.useState([]),[r,b]=c.useState([]),[u,T]=c.useState([]),[f,S]=c.useState([]),[L,A]=c.useState(!0);c.useEffect(()=>{(async()=>{const l=await d.auth.me();x(l);const[n,E,O]=await Promise.all([d.entities.ServiceSwap.filter({creator_email:l.email},"-created_date"),d.entities.SwapRoom.list("-created_date"),d.entities.SwapInterest.filter({interested_user_email:l.email},"-created_date")]);if(p(n),b(E.filter(h=>h.initiator_email===l.email||h.partner_email===l.email)),T(O),n.length){const h=n.map(w=>w.id),z=await d.entities.SwapInterest.list("-created_date",100);S(z.filter(w=>h.includes(w.swap_id)))}A(!1)})()},[]);const N={open:a.filter(s=>s.status==="open"),active:a.filter(s=>s.status==="active"||s.status==="pending"),completed:a.filter(s=>s.status==="completed"),other:a.filter(s=>["cancelled","disputed"].includes(s.status))};return L?e.jsx("div",{className:"pt-24 flex items-center justify-center min-h-screen",children:e.jsx($,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"pb-24 min-h-screen",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-black flex items-center gap-2",children:[e.jsx(R,{className:"w-6 h-6 text-purple-400"})," ",t("ms.title")]}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:t("ms.subtitle")})]}),e.jsxs(m,{onClick:()=>i("/swaps/create"),className:"bg-gradient-to-r from-purple-600 to-pink-600 text-white gap-2",children:[e.jsx(I,{className:"w-4 h-4"})," ",t("ms.newSwap")]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 mb-8",children:[{labelKey:"ms.stat.active",value:N.active.length,color:"text-blue-400"},{labelKey:"ms.stat.open",value:N.open.length,color:"text-green-400"},{labelKey:"ms.stat.completed",value:N.completed.length,color:"text-purple-400"},{labelKey:"ms.stat.pendingReplies",value:f.filter(s=>s.status==="pending").length,color:"text-yellow-400"}].map(({labelKey:s,value:l,color:n})=>e.jsxs("div",{className:"rounded-xl border border-border bg-card p-4 text-center",children:[e.jsx("p",{className:`text-2xl font-black ${n}`,children:l}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t(s)})]},s))}),e.jsxs(D,{defaultValue:"my_offers",children:[e.jsxs(V,{className:"mb-6 w-full",children:[e.jsxs(g,{value:"my_offers",className:"flex-1",children:[t("ms.tab.myOffers")," (",a.length,")"]}),e.jsxs(g,{value:"rooms",className:"flex-1",children:[t("ms.tab.rooms")," (",r.length,")"]}),e.jsxs(g,{value:"interests",className:"flex-1",children:[t("ms.tab.interests")," (",u.length,")"]}),e.jsxs(g,{value:"received",className:"flex-1",children:[t("ms.tab.received")," (",f.filter(s=>s.status==="pending").length,")"]})]}),e.jsx(j,{value:"my_offers",children:a.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(R,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4 opacity-40"}),e.jsx("p",{className:"font-semibold mb-2",children:t("ms.noOffers")}),e.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:t("ms.noOffersDesc")}),e.jsxs(m,{onClick:()=>i("/swaps/create"),className:"bg-gradient-to-r from-purple-600 to-pink-600 text-white gap-2",children:[e.jsx(I,{className:"w-4 h-4"})," ",t("ms.createSwapOffer")]})]}):e.jsx("div",{className:"space-y-3",children:a.map(s=>e.jsx(q,{swap:s,interests:f,onView:l=>i(`/swaps/${l}`),onManage:l=>i(`/swaps/manage/${l}`)},s.id))})}),e.jsx(j,{value:"rooms",children:r.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(C,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4 opacity-40"}),e.jsx("p",{className:"font-semibold mb-2",children:t("ms.noRooms")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:t("ms.noRoomsDesc")})]}):e.jsx("div",{className:"space-y-3",children:r.map(s=>e.jsx("div",{className:"p-4 rounded-2xl border border-border bg-card hover:border-purple-500/30 transition-all cursor-pointer",onClick:()=>i(`/swaps/room/${s.id}`),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:`text-xs font-bold px-2 py-0.5 rounded-full ${_[s.status]||"bg-muted text-muted-foreground"}`,children:s.status}),e.jsx("p",{className:"text-sm font-bold mt-1",children:t("ms.withEmail",{email:s.initiator_email===(o==null?void 0:o.email)?s.partner_email:s.initiator_email})}),e.jsx("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:s.initiator_fee_paid&&s.partner_fee_paid?e.jsxs("span",{className:"text-green-400",children:["â ",t("ms.feesPaid")]}):e.jsxs("span",{className:"text-yellow-400",children:["â ",t("ms.feesPending")]})})]}),e.jsx(B,{className:"w-4 h-4 text-muted-foreground"})]})},s.id))})}),e.jsx(j,{value:"interests",children:u.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(P,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4 opacity-40"}),e.jsx("p",{className:"font-semibold mb-2",children:t("ms.noInterests")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:t("ms.noInterestsDesc")}),e.jsx(m,{onClick:()=>i("/swaps"),className:"mt-4 gap-2",children:t("ms.browseSwaps")})]}):e.jsx("div",{className:"space-y-3",children:u.map(s=>e.jsxs("div",{className:"p-4 rounded-2xl border border-border bg-card",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:`text-xs font-bold px-2 py-0.5 rounded-full ${_[s.status]||"bg-muted text-muted-foreground"}`,children:s.status}),e.jsx("p",{className:"text-sm font-bold mt-1 line-clamp-1",children:s.offered_service_description}),s.offered_value&&e.jsx("p",{className:"text-xs text-muted-foreground",children:t("ms.estValue",{value:s.offered_value})})]}),e.jsxs(m,{size:"sm",variant:"outline",onClick:()=>i(`/swaps/${s.swap_id}`),className:"gap-1 text-xs",children:[e.jsx(v,{className:"w-3 h-3"})," ",t("ms.view")]})]}),s.room_id&&e.jsxs(m,{size:"sm",onClick:()=>i(`/swaps/room/${s.room_id}`),className:"mt-3 w-full bg-purple-600 hover:bg-purple-500 text-white gap-1 text-xs",children:[e.jsx(C,{className:"w-3 h-3"})," ",t("ms.openRoom")]})]},s.id))})}),e.jsx(j,{value:"received",children:f.filter(s=>s.status==="pending").length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(K,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4 opacity-40"}),e.jsx("p",{className:"font-semibold mb-2",children:t("ms.noPending")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:t("ms.noPendingDesc")})]}):e.jsx("div",{className:"space-y-3",children:f.filter(s=>s.status==="pending").map(s=>e.jsx(H,{interest:s,onAccept:async()=>{a.find(n=>n.id===s.swap_id);const l=await d.entities.SwapRoom.create({swap_id:s.swap_id,initiator_email:s.interested_user_email,partner_email:o.email,status:"negotiating"});await d.entities.SwapInterest.update(s.id,{status:"accepted",room_id:l.id}),await d.entities.ServiceSwap.update(s.swap_id,{status:"pending"}),k.success(t("ms.toast.accepted")),i(`/swaps/room/${l.id}`)},onDecline:async()=>{await d.entities.SwapInterest.update(s.id,{status:"declined"}),S(l=>l.map(n=>n.id===s.id?{...n,status:"declined"}:n)),k.info(t("ms.toast.declined"))}},s.id))})})]})]})})}function H({interest:t,onAccept:i,onDecline:o}){const{t:x}=y(),[a,p]=c.useState(!1),[r,b]=c.useState(null);return c.useEffect(()=>{d.entities.Profile.filter({user_email:t.interested_user_email}).then(u=>{u.length&&b(u[0])})},[t.interested_user_email]),e.jsxs("div",{className:"p-4 rounded-2xl border border-purple-500/20 bg-purple-500/5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center flex-shrink-0",children:r!=null&&r.avatar_url?e.jsx("img",{src:r.avatar_url,alt:"",className:"w-full h-full object-cover rounded-full"}):e.jsx("span",{className:"text-white text-xs font-bold",children:t.interested_user_email[0].toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-bold text-sm",children:(r==null?void 0:r.display_name)||t.interested_user_email.split("@")[0]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.offered_service_description}),t.offered_value&&e.jsx("p",{className:"text-xs text-purple-300 mt-1 font-bold",children:x("ms.estValueLabel",{value:t.offered_value})}),t.message&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-2 italic",children:['"',t.message,'"']})]})]}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx(m,{size:"sm",variant:"outline",onClick:o,className:"flex-1 text-xs border-red-500/30 text-red-400 hover:bg-red-500/10",children:x("ms.decline")}),e.jsxs(m,{size:"sm",onClick:async()=>{p(!0),await i(),p(!1)},disabled:a,className:"flex-1 text-xs bg-purple-600 hover:bg-purple-500 text-white gap-1",children:[a?e.jsx($,{className:"w-3 h-3 animate-spin"}):e.jsx(U,{className:"w-3 h-3"}),x("ms.accept")]})]})]})}export{le 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.