1import{c as D,b as S,r as n,s as u,j as e,G as L,L as f,F as $,y as E,C as T,au as R,f as q,K as W,h as G}from"./index-DocTL6Xp.js";import{A as O,b as B,c as H,d as I,e as V,f as U,g as X,h as K}from"./alert-dialog-BL-rbCI7.js";import{c as P}from"./gxScore-CsXoMpRE.js";import{C as z}from"./circle-check-conwmP9q.js";import{T as J}from"./trash-2-Bcoczq4e.js";const s={bg:"#FAF9F5",surface:"#FFFFFF",ink:"#1A1A1A",inkMuted:"#6B6B68",accent:"#C96442",border:"#E8E5DD"};function Q(a){if(!a)return null;const o=a.replace(/[$,\s]/g,"").split(/[-ââ]/)[0],i=parseFloat(o);return Number.isFinite(i)&&i>0?i:null}function C(a){if(a.liquidity_score!==null&&a.liquidity_score!==void 0)return Number(a.liquidity_score);const o=Q(a.retail_range);return o===null?null:Math.min(10,Number((Math.log10(o)*2-4).toFixed(1)))}function w(a){if(a.gx_score!==null&&a.gx_score!==void 0)return Number(a.gx_score);const o=P({wholesaleRange:a.wholesale_range,retailRange:a.retail_range,moonshotValue:a.moonshot_value});return o==="N/A"?null:parseFloat(o)}function le(){var k;const a=D(),{toast:o}=S(),[i,g]=n.useState(null),[F,y]=n.useState(!0),[x,p]=n.useState([]),[_,b]=n.useState(!0),[d,A]=n.useState(""),[j,N]=n.useState(null),[m,h]=n.useState({open:!1,row:null});n.useEffect(()=>{document.title="Appraisal history - GoExpired.com"},[]),n.useEffect(()=>{let t=!0;u.auth.getSession().then(({data:{session:l}})=>{if(t){if(!(l!=null&&l.user)){a("/auth");return}g(l.user),y(!1)}});const{data:{subscription:r}}=u.auth.onAuthStateChange((l,c)=>{t&&(c!=null&&c.user?(g(c.user),y(!1)):a("/auth"))});return()=>{t=!1,r.unsubscribe()}},[a]),n.useEffect(()=>{if(!(i!=null&&i.id))return;let t=!1;return(async()=>{b(!0);const{data:r,error:l}=await u.from("user_advanced_appraisals").select("id, domain, retail_range, wholesale_range, moonshot_value, recommended_buy_price, confidence, summary, strengths, risks, gx_score, liquidity_score, created_at").eq("user_id",i.id).order("created_at",{ascending:!1});t||(l?(o({title:"Could not load appraisals",description:l.message,variant:"destructive"}),p([])):p(r||[]),b(!1))})(),()=>{t=!0}},[i==null?void 0:i.id,o]);const v=n.useMemo(()=>{const t=d.trim().toLowerCase();return t?x.filter(r=>r.domain.toLowerCase().includes(t)):x},[x,d]),M=async()=>{const t=m.row;if(!t)return;const{error:r}=await u.from("user_advanced_appraisals").delete().eq("id",t.id);r?o({title:"Delete failed",description:r.message,variant:"destructive"}):(p(l=>l.filter(c=>c.id!==t.id)),j===t.id&&N(null),o({title:"Appraisal removed",description:`${t.domain} was deleted from your history.`})),h({open:!1,row:null})};return F?e.jsx("div",{style:{backgroundColor:s.bg,color:s.inkMuted},className:"min-h-screen flex items-center justify-center",children:"Loadingâ¦"}):e.jsxs("div",{style:{backgroundColor:s.bg,color:s.ink,fontFamily:"'Inter', system-ui, sans-serif"},className:"min-h-screen",children:[e.jsx(L,{activeLink:"resources"}),e.jsxs("main",{children:[e.jsxs("section",{className:"max-w-4xl mx-auto px-6 md:px-8 pt-16 md:pt-20 pb-10",children:[e.jsx("h1",{className:"text-5xl md:text-6xl leading-[1.05] tracking-tight mb-4",style:{fontFamily:"'Cormorant', serif",fontWeight:600},children:"Appraisal History"}),e.jsx("p",{className:"text-lg max-w-2xl mb-3",style:{color:s.inkMuted,fontFamily:"'Cormorant', serif",fontWeight:500},children:"Every domain you've appraised with the advanced tool. Click any row to expand the full breakdown."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-2",children:[e.jsx(f,{to:"/appraise-your-domain",className:"text-sm font-medium underline underline-offset-4 transition-colors hover:opacity-80",style:{color:"#2563EB"},children:"Appraise a new domain â"}),e.jsx(f,{to:"/saved-appraisals",className:"text-sm underline underline-offset-4 transition-colors hover:opacity-80",style:{color:s.inkMuted},children:"Looking for your older appraisals from the simple tool? Find them here â"})]})]}),e.jsxs("section",{className:"max-w-4xl mx-auto px-6 md:px-8 pb-24",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 rounded-full mb-6",style:{backgroundColor:s.surface,border:`1px solid ${s.border}`},children:[e.jsx($,{className:"w-4 h-4",style:{color:s.inkMuted}}),e.jsx("input",{type:"text",value:d,onChange:t=>A(t.target.value),placeholder:"Search by domainâ¦",className:"bg-transparent outline-none text-sm flex-1",style:{color:s.ink}})]}),_?e.jsxs("div",{className:"flex items-center justify-center py-20",style:{color:s.inkMuted},children:[e.jsx(E,{className:"w-5 h-5 animate-spin mr-2"}),"Loading your appraisalsâ¦"]}):v.length===0?e.jsxs("div",{className:"text-center py-20 rounded-2xl",style:{backgroundColor:s.surface,border:`1px solid ${s.border}`},children:[e.jsx("h3",{className:"text-2xl mb-2",style:{fontFamily:"'Cormorant', serif",fontWeight:600},children:d?"No matching appraisals":"No appraisals yet"}),e.jsx("p",{className:"text-sm mb-6",style:{color:s.inkMuted},children:d?`Nothing found for "${d}".`:"Once you appraise a domain with the advanced tool, it will show up here."}),!d&&e.jsx(f,{to:"/appraise-your-domain",children:e.jsx("button",{className:"px-6 py-3 rounded-full text-sm font-medium transition-all hover:-translate-y-[1px]",style:{backgroundColor:"#2563EB",color:"#FFFFFF",boxShadow:"0 4px 14px -4px rgba(37, 99, 235, 0.45), inset 0 1px 0 rgba(255,255,255,0.25)"},children:"Appraise a domain"})})]}):e.jsx("ul",{className:"flex flex-col gap-3",children:v.map(t=>{const r=j===t.id;return e.jsxs("li",{className:"rounded-2xl overflow-hidden transition-all",style:{backgroundColor:s.surface,border:`1px solid ${s.border}`,boxShadow:"0 1px 2px rgba(26,26,26,0.04)"},children:[e.jsxs("button",{type:"button",onClick:()=>N(r?null:t.id),className:"w-full flex items-center gap-4 px-5 py-4 text-left transition-colors","aria-expanded":r,children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xl md:text-2xl tracking-tight truncate",style:{fontFamily:"'Cormorant', serif",fontWeight:600},title:t.domain,children:t.domain.toLowerCase()}),e.jsxs("div",{className:"flex items-center gap-2 text-xs mt-1",style:{color:s.inkMuted},children:[e.jsx(T,{className:"w-3 h-3"}),R(new Date(t.created_at),{addSuffix:!0})]})]}),e.jsxs("div",{className:"hidden sm:flex flex-col items-end mr-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide",style:{color:s.inkMuted},children:"Retail estimate"}),e.jsx("div",{className:"text-lg",style:{fontFamily:"'Cormorant', serif",fontWeight:600,color:s.accent},children:t.retail_range||"â"})]}),e.jsx(q,{className:"w-5 h-5 shrink-0 transition-transform",style:{color:s.inkMuted,transform:r?"rotate(180deg)":"rotate(0deg)"}})]}),e.jsxs("div",{className:"sm:hidden px-5 -mt-2 pb-3 flex items-center justify-between text-sm",style:{color:s.inkMuted},children:[e.jsx("span",{children:"Retail estimate"}),e.jsx("span",{style:{fontFamily:"'Cormorant', serif",fontWeight:600,color:s.accent},children:t.retail_range||"â"})]}),r&&e.jsxs("div",{className:"px-5 pb-5 pt-1 space-y-5",style:{borderTop:`1px solid ${s.border}`},children:[e.jsxs("div",{className:"pt-4 flex flex-wrap items-center gap-2",children:[t.confidence&&e.jsxs("span",{className:"text-xs px-3 py-1 rounded-full",style:{backgroundColor:s.bg,border:`1px solid ${s.border}`,color:s.inkMuted},children:[t.confidence.charAt(0).toUpperCase()+t.confidence.slice(1)," confidence"]}),w(t)!==null&&e.jsxs("span",{className:"text-xs px-3 py-1 rounded-full font-medium",style:{backgroundColor:s.bg,border:`1px solid ${s.border}`,color:s.ink},children:["GX Score ",w(t).toFixed(1)," / 10"]}),C(t)!==null&&e.jsxs("span",{className:"text-xs px-3 py-1 rounded-full font-medium",style:{backgroundColor:s.bg,border:`1px solid ${s.border}`,color:s.ink},children:["Liquidity Score ",C(t).toFixed(1)," / 10"]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[{label:"Wholesale Value",value:t.wholesale_range},{label:"Retail Value",value:t.retail_range},{label:"Moonshot Value",value:t.moonshot_value},{label:"Recommended Buy Price",value:t.recommended_buy_price}].map(l=>e.jsxs("div",{className:"rounded-xl p-4",style:{backgroundColor:s.bg,border:`1px solid ${s.border}`},children:[e.jsx("div",{className:"text-xs mb-1.5",style:{color:s.inkMuted},children:l.label}),e.jsx("div",{className:"text-xl",style:{fontFamily:"'Cormorant', serif",fontWeight:600},children:l.value||"â"})]},l.label))}),t.summary&&e.jsxs("div",{className:"rounded-xl p-4",style:{backgroundColor:s.bg,border:`1px solid ${s.border}`},children:[e.jsx("h4",{className:"text-xs mb-2",style:{color:s.inkMuted},children:"Summary"}),e.jsx("p",{className:"leading-relaxed text-sm",style:{color:s.ink},children:t.summary})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.strengths&&t.strengths.length>0&&e.jsxs("div",{className:"rounded-xl p-4",style:{backgroundColor:s.bg,border:`1px solid ${s.border}`},children:[e.jsxs("h4",{className:"text-xs mb-2 flex items-center gap-1.5",style:{color:s.inkMuted},children:[e.jsx(z,{className:"h-3.5 w-3.5"}),"Strengths"]}),e.jsx("ul",{className:"space-y-1.5",children:t.strengths.map((l,c)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",style:{color:s.ink},children:[e.jsx("span",{style:{color:s.accent},children:"â¢"}),l]},c))})]}),t.risks&&t.risks.length>0&&e.jsxs("div",{className:"rounded-xl p-4",style:{backgroundColor:s.bg,border:`1px solid ${s.border}`},children:[e.jsxs("h4",{className:"text-xs mb-2 flex items-center gap-1.5",style:{color:s.inkMuted},children:[e.jsx(W,{className:"h-3.5 w-3.5"}),"Risks"]}),e.jsx("ul",{className:"space-y-1.5",children:t.risks.map((l,c)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",style:{color:s.ink},children:[e.jsx("span",{style:{color:s.accent},children:"â¢"}),l]},c))})]})]}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsxs("button",{onClick:()=>h({open:!0,row:t}),className:"inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-full transition-colors",style:{color:s.inkMuted,border:`1px solid ${s.border}`},onMouseEnter:l=>l.currentTarget.style.color=s.accent,onMouseLeave:l=>l.currentTarget.style.color=s.inkMuted,"aria-label":"Delete appraisal",children:[e.jsx(J,{className:"w-3.5 h-3.5"}),"Delete"]})})]})]},t.id)})})]})]}),e.jsx(G,{}),e.jsx(O,{open:m.open,onOpenChange:t=>h({open:t,row:t?m.row:null}
1),children:e.jsxs(B,{children:[e.jsxs(H,{children:[e.jsx(I,{children:"Delete appraisal?"}),e.jsxs(V,{children:["This will permanently remove"," ",e.jsx("span",{className:"font-medium",children:(k=m.row)==null?void 0:k.domain})," from your appraisal history."]})]}),e.jsxs(U,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(K,{onClick:M,children:"Delete"})]})]})})]})}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.