1import{c as b,at as L,u as _,r as v,a as S,aG as D,j as e,L as x,P as A,y as M,aD as T,n as y}from"./index-BUCFbuLp.js";import{f as I}from"./format-CRbf4Bhs.js";import{I as z}from"./input-Bqhs6Nqo.js";import{S as $}from"./store-0eX-45yJ.js";const E=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]],Q=b("file-check",E);const R=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],U=b("file-up",R);function j(i){if(!i)return"";const t=String(i).trim();if(!t)return"";let s=new Date(t);if(Number.isNaN(s.getTime())){const a=t.match(/^(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?/);if(a)s=new Date(Date.UTC(+a[1],+a[2]-1,+a[3],+(a[4]??0),+(a[5]??0),+(a[6]??0)));else{const r=t.match(/^(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2,4})$/);if(r){let n=+r[3];n<100&&(n+=2e3),s=new Date(Date.UTC(n,+r[2]-1,+r[1]))}}}return Number.isNaN(s.getTime())?"":s.toLocaleDateString()}function B(){const i=L(),{isAuthenticated:t}=_(),[s,a]=v.useState("all"),[r,n]=v.useState(""),{data:d,isLoading:w,isError:k,error:C}=S({...D(200),enabled:t});if(!t)return e.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-16 text-center md:px-6",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Sign in to see your listings"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"You need an account to track your sales."}),e.jsx(x,{to:"/login",className:"mt-6 inline-block rounded-full brand-gradient px-5 py-2.5 text-sm font-semibold text-primary-foreground",children:"Sign in"})]});const f=d?.active_preview??[],p=d?.inactive_preview??[],c=d?.active_count??0,m=d?.inactive_count??0,h=s==="active"?f:s==="inactive"?p:[...f,...p],o=r.trim().toLowerCase(),g=o?h.filter(l=>l.title?.toLowerCase().includes(o)||l.description?.toLowerCase().includes(o)||l.condition?.toLowerCase().includes(o)):h;return e.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-8 md:px-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"My listings"}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:"Manage your active and inactive listings."})]}),e.jsxs(x,{to:"/sell",className:"inline-flex items-center gap-1.5 rounded-full brand-gradient px-5 py-2.5 text-sm font-semibold text-primary-foreground shadow-soft",children:[e.jsx(A,{className:"h-4 w-4"})," New listing"]})]}),e.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-3",children:[e.jsx(N,{icon:e.jsx(U,{className:"h-4 w-4"}),label:"Active",value:c}),e.jsx(N,{icon:e.jsx(Q,{className:"h-4 w-4"}),label:"Inactive",value:m})]}),e.jsxs("div",{className:"mt-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"inline-flex rounded-full bg-muted p-1 text-sm font-medium",children:[e.jsxs(u,{active:s==="all",onClick:()=>a("all"),children:["All (",c+m,")"]}),e.jsxs(u,{active:s==="active",onClick:()=>a("active"),children:["Active (",c,")"]}),e.jsxs(u,{active:s==="inactive",onClick:()=>a("inactive"),children:["Inactive (",m,")"]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-xs",children:[e.jsx(M,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(z,{value:r,onChange:l=>n(l.target.value),placeholder:"Search your listings",className:"pl-9"})]})]}),w?e.jsx("div",{className:"mt-12 text-center text-muted-foreground",children:"Loading your listingsâ¦"}):k?e.jsxs("div",{className:"mt-12 text-center",children:[e.jsx("p",{className:"text-destructive",children:C?.message??"Could not load listings."}),e.jsx("button",{onClick:()=>i.invalidate(),className:"mt-3 rounded-full border border-border px-4 py-2 text-sm font-medium hover:bg-muted",children:"Retry"})]}):c===0&&m===0?e.jsxs("div",{className:"mt-16 text-center",children:[e.jsx("div",{className:"mx-auto grid h-20 w-20 place-items-center rounded-full brand-gradient-soft",children:e.jsx($,{className:"h-8 w-8 text-primary"})}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"You haven't posted anything yet."}),e.jsx(x,{to:"/sell",className:"mt-4 inline-block rounded-full brand-gradient px-5 py-2.5 text-sm font-semibold text-primary-foreground",children:"Create your first listing"})]}):g.length===0?e.jsxs("div",{className:"mt-10 flex flex-col items-center justify-center gap-2 rounded-2xl border border-border bg-card py-10 text-center",children:[e.jsx(T,{className:"h-6 w-6 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o?`No listings match "${r}"`:"No listings here yet"})]}):e.jsx(q,{items:g})]})}function u({active:i,onClick:t,children:s}
1){return e.jsx("button",{onClick:t,className:y("rounded-full px-4 py-1.5 transition",i?"bg-background text-foreground shadow-soft":"text-muted-foreground hover:text-foreground"),children:s})}function q({items:i}){return e.jsx("ul",{className:"mt-6 space-y-3",children:i.map(t=>e.jsxs("li",{className:"flex flex-wrap items-center gap-4 rounded-2xl border border-border bg-card p-3",children:[e.jsxs(x,{to:"/item/$id",params:{id:t.id},className:"contents",children:[e.jsx("img",{src:t.image_url??"",alt:"",className:"h-20 w-20 rounded-xl object-cover bg-muted"}),e.jsxs("div",{className:"flex-1 min-w-[180px]",children:[e.jsx("p",{className:"font-semibold",children:t.title}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[I(Number(t.price)||0)," · ",t.condition]}),e.jsx("div",{className:"mt-1 flex items-center gap-3 text-xs text-muted-foreground",children:j(t.display_date)?e.jsx("span",{children:j(t.display_date)}):null})]})]}),e.jsx("span",{className:y("rounded-full px-3 py-1 text-xs font-semibold",t.is_active?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:t.is_active?"Active":"Inactive"})]},t.id))})}function N({icon:i,label:t,value:s}){return e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[i," ",t]}),e.jsx("p",{className:"mt-1 text-2xl font-bold",children:s})]})}export{B 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.