PageSourceSearch

https://carbidder-connect.lovable.app/assets/CustomerDashboardNew-eDdZsFZx.js

js carbidder-connect.lovable.app collected 2026-10-03 03:23:56 UTC 351,540 bytes, 39 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/heicConvert-DY3Boxu8.js","assets/index-C7rjTsh5.js","assets/index-EB7w1C8P.css","assets/heicBackfill-C6tHs8Ax.js"])))=>i.map(i=>d[i]);
2import{f as pr,j as e,b as Ie,a8 as Ba,D as rt,B as I,v as Rt,aU as Vt,X as hs,e as Ts,a1 as Ws,a2 as Ps,t as bt,a3 as Es,F as jt,T as it,J as W,r as h,s as g,o as dt,a as oe,at as Bs,C as ps,ay as qt,ct as Ma,w as _e,Q as Vs,V as cs,ab as Ye,M as Ms,K as qs,n as ur,c as gr,av as fr,q as ns,d as As,am as br,cu as jr,ch as Nr,u as vr,x as wr,as as kr,an as yr,cv as _r,cw as Sr,H as Cr,ao as wa,aC as Pt,a7 as ka,aD as Lr,aE as $r,aF as Ir}from"./index-C7rjTsh5.js";import{B as Lt}from"./badge-Be4waKn8.js";import{C as Br}from"./CounterOfferModal-C0wwkhAj.js";import{A as Mr}from"./arrow-right-mXq7YWQr.js";import{D as It,a as Bt,b as Aa,c as Ht,d as zt,e as us}from"./drawer-CArnCDaH.js";import{D as Ve,a as qe,b as Nt,c as Ze,e as $t}from"./dialog-BqIQ1XMZ.js";import{C as Ar}from"./ConditionDetailsDisplay-DL4tkEE0.js";import{I as Dr}from"./InDepthVehicleDetails-DJFuuBYO.js";import{C as Or}from"./copy-BlVyKajD.js";import{C as Tr}from"./clipboard-list-DJBLe6KG.js";import{A as Wr}from"./AppointmentRequestForm-C4pyjSVQ.js";import{C as ae}from"./circle-check-DEXR_owX.js";import{P as vt}from"./phone-1rmp-Pye.js";import{M as Re}from"./map-pin-BETJqwiW.js";import{C as nt}from"./credit-card-DgssLN4T.js";import{L as at}from"./label-DEMqrK65.js";import{T as Da}from"./textarea-DyriSEbd.js";import{g as Pr,b as Er,i as Vr}from"./businessHoursUtils-CbTx11uY.js";import{a as Et}from"./ghlSync-CMbnb_1I.js";import{S as Ge}from"./shield-check-Li8bt6ZA.js";import{G as Oa}from"./globe-BZrldG4I.js";import{H as qr}from"./hash-DuV6wm4S.js";import{a as tt}from"./addDays-DreZceOU.js";import{b as is,f as lt}from"./format-iV6bfs-r.js";import{i as $s}from"./isAfter-DPiBggda.js";import{a as Rr}from"./addMonths-CaKDpDTk.js";import{i as ya}from"./isSameDay-DXIqTHHv.js";import{E as ms}from"./external-link-CiiRVpIH.js";import{C as Hr}from"./CustomerRescheduleModal-C5lz_tl5.js";import zr from"./CustomerMessagesPage-hPYRsPhH.js";import{g as Fr}from"./bidDisplayUtils-DD-Z-ILp.js";import{P as Ur}from"./progress-hpFiwHuf.js";import{P as Yr}from"./paintbrush-DY9z_qcF.js";import{C as Gr}from"./camera-DceGg4Xk.js";import{P as Zr}from"./plus-DZ7xOdh4.js";import{U as Ds}from"./upload-CdCxnhIS.js";import{A as Xr,a as Kr}from"./alert-De4v_MUd.js";import{C as Qr}from"./checkbox-DBElXt-B.js";import{C as Jr}from"./CustomerSaleDocuments-HvyQjbSY.js";import{T as Ta}from"./trending-up-BZYvG5qV.js";import{L as os}from"./lock-DNbrhs6-.js";import{T as el}from"./trophy-Bc25_xil.js";import{E as _a}from"./eye-BmsYy3rY.js";import{T as tl}from"./tag-Btm0rj85.js";import{H as Sa}from"./headphones-B4CKPR3l.js";import{B as sl}from"./badge-check-pbpK1YTW.js";import"./index-K0EsK_ep.js";import"./triangle-alert-CCELUU2A.js";import"./wrench-CuLhvuJZ.js";import"./save-O9juW0e-.js";import"./index.esm-CpkDilhm.js";import"./calendar-_wtWX_Fc.js";import"./differenceInCalendarMonths-Co0AoNEe.js";import"./en-US-BzMcWhXf.js";import"./toDate-2Nz3Yi75.js";import"./startOfMonth-DPSnM_sz.js";import"./endOfWeek-fiXeJP-f.js";import"./subDays-Def1FjWy.js";import"./endOfMonth-kYWVrrlH.js";import"./isSameMonth-bsMTW3bo.js";import"./popover-DBvi-PqK.js";import"./arrow-left-BnYBGNnB.js";import"./sparkles-CDP5Yay2.js";import"./formatDistanceToNow-Ddtzr5X4.js";import"./image-BNr4Yxyk.js";import"./trash-2-Dmi-p3qr.js";/**
3 * @license lucide-react v0.555.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const al=[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]],Wa=pr("navigation",al),xs=l=>l?l.replace(/\s*[-–—]?\s*Processed from email lead\s*\.?\s*/gi," ").replace(/\s{2,}/g," ").trim():"",Ca=({customerCounterAmount:l,customerCounterTimestamp:C,dealerCounterAmount:n,dealerCounterTimestamp:b,dealerName:j,dealerLogo:N,carStatus:P,onAcceptDealerCounter:D,onCounterAgain:d})=>{const E=C?new Date(C):null,r=b?new Date(b):null,y=P==="dealer_counter"||n&&r&&(!E||r>E);return P==="on_offer"||!y&&l&&E&&(!r||E>r)?e.jsx("div",{className:"max-md:mb-0 mb-6",children:e.jsxs("div",{className:"relative overflow-hidden max-md:rounded-none max-md:border-0 rounded-2xl border border-amber-200 dark:border-amber-800/50 bg-gradient-to-b from-amber-50 to-white dark:from-amber-950/20 dark:to-gray-900",children:[e.jsx("div",{className:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-amber-400/10 to-transparent roun
7ded-bl-full"}),e.jsxs("div",{className:"relative p-5 md:p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/40",children:e.jsx(Ie,{className:"w-5 h-5 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.15em] text-amber-600/80 dark:text-amber-400/80 font-medium",children:"Counter Offer Submitted"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground tracking-tight",children:"Waiting for Response"})]})]}),e.jsxs("div",{className:"mb-4 pb-4 border-b border-amber-200/50 dark:border-amber-800/30",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1 font-light",children:"Your Counter Offer"}),e.jsx("div",{className:"flex items-baseline gap-2",children:e.jsxs("span",{className:"text-3xl md:text-4xl font-light text-foreground tracking-tight",children:["$",l==null?void 0:l.toLocaleString()]})}),j&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2 font-light",children:["Sent to ",e.jsx("span",{className:"font-medium text-foreground",children:j})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"relative flex h-2.5 w-2.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-amber-500"})]}),e.jsx("span",{className:"text-sm text-amber-700 dark:text-amber-400 font-medium",children:"Waiting for dealer response..."})]})]})]})}):y?e.jsx("div",{className:"max-md:mb-0 mb-6",children:e.jsxs("div",{className:"relative overflow-hidden max-md:rounded-none max-md:border-0 max-md:shadow-none rounded-2xl border-2 border-blue-400 dark:border-blue-500 bg-gradient-to-b from-blue-50 to-white dark:from-blue-950/20 dark:to-gray-900 shadow-lg shadow-blue-500/10",children:[e.jsx("div",{className:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-blue-400/15 to-transparent rounded-bl-full"}),e.jsx("div",{className:"bg-blue-500 text-white text-center py-1.5 px-3 rounded-none -mt-px",children:e.jsxs("span",{className:"inline-flex items-center justify-center gap-1.5 text-xs font-semibold animate-pulse",children:[e.jsx(Ba,{className:"w-3 h-3"}),"ACTION REQUIRED"]})}),e.jsxs("div",{className:"relative p-5 md:p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-blue-100 dark:bg-blue-900/40",children:e.jsx(rt,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.15em] text-blue-600/80 dark:text-blue-400/80 font-medium",children:"Dealer Response Received"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground tracking-tight",children:n===l?"Dealer Holding Firm":"Dealer Counter Offer"})]})]}),e.jsxs("div",{className:"mb-5 pb-5 border-b border-blue-200/50 dark:border-blue-800/30",children:[(j||N)&&e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[N?e.jsx("img",{src:N,alt:j||"Dealer",className:"w-10 h-10 rounded-lg object-contain bg-background border border-border/50 p-1"}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center text-blue-700 dark:text-blue-400 font-medium text-lg",children:(j||"D").charAt(0)}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:j})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1 font-light",children:"Their Counter Offer"}),e.jsx("div",{className:"flex items-baseline gap-2",children:e.jsxs("span",{className:"text-3xl md:text-4xl font-light text-blue-600 dark:text-blue-400 tracking-tight",children:["$",n==null?void 0:n.toLocaleString()]})}),l&&e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Your counter was"}),e.jsxs("span",{className:"font-medium text-foreground",children:["$",l.toLocaleStr
7ing()]}),e.jsx(Mr,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-blue-600 dark:text-blue-400",children:["$",n==null?void 0:n.toLocaleString()]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(I,{onClick:D,size:"lg",className:"w-full h-12 text-base font-medium tracking-wide bg-gradient-to-r from-emerald-600 to-emerald-700 hover:from-emerald-700 hover:to-emerald-800 text-white shadow-lg shadow-emerald-900/20 border-0",children:["Accept Counter - $",n==null?void 0:n.toLocaleString()]}),e.jsx(I,{onClick:d,variant:"outline",size:"sm",className:"w-full h-9 text-sm font-medium border-2 border-amber-400 text-amber-600 dark:text-amber-400 hover:bg-amber-50 dark:hover:bg-amber-950/30",children:"Counter Again"})]})]})]})}):null},rl=({isOpen:l,onClose:C,car:n})=>{const b=Rt(),[j,N]=Vt.useState(!1),[P,D]=Vt.useState(!1);if(!n)return null;const d=n,E=d.windowStickerUrl||d.window_sticker_url||d.windowstickerurl,r=d.kbbBooksheetUrl||d.kbb_booksheet_url||d.kbbbooksheeturl,y=async()=>{await navigator.clipboard.writeText(n.vin),N(!0),W.success("VIN copied!"),setTimeout(()=>N(!1),2e3)},L=()=>{var K,A,z,X,T;return e.jsxs("div",{className:"space-y-4 md:space-y-6",children:[e.jsxs("div",{className:"relative bg-gradient-to-br from-slate-100 via-slate-50 to-white dark:from-slate-900 dark:via-slate-800 dark:to-slate-900 rounded-2xl p-5 md:p-6 overflow-hidden border border-slate-200 dark:border-transparent",children:[e.jsx("div",{className:"absolute inset-0 opacity-5 dark:opacity-5",children:e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 2px 2px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-slate-500 dark:text-slate-400 mb-1",children:"Your Vehicle"}),e.jsxs("h2",{className:"text-xl md:text-2xl font-bold text-slate-900 dark:text-white",children:[n.year," ",n.make]}),e.jsx("h3",{className:"text-lg md:text-xl font-light text-slate-700 dark:text-white/90",children:n.model}),n.trim&&e.jsx("p",{className:"text-sm text-green-700 dark:text-green-500 font-medium mt-1",children:n.trim})]}),e.jsx(Lt,{className:`
8                ${n.status==="active"?"bg-emerald-500/20 text-emerald-700 dark:text-emerald-300 border-emerald-500/30":""}
9                ${n.status==="sold"?"bg-blue-500/20 text-blue-700 dark:text-blue-300 border-blue-500/30":""}
10                ${n.status==="ended"?"bg-slate-500/20 text-slate-700 dark:text-slate-300 border-slate-500/30":""}
11                border
12              `,children:((K=n.status)==null?void 0:K.charAt(0).toUpperCase())+((A=n.status)==null?void 0:A.slice(1))})]}),e.jsx("div",{className:"bg-slate-200/50 dark:bg-black/30 backdrop-blur-sm rounded-xl p-3 mt-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 dark:text-slate-500 mb-1",children:"VIN"}),e.jsx("p",{className:"font-mono text-sm text-slate-800 dark:text-white/90",children:n.vin})]}),e.jsx("button",{onClick:y,className:"p-2 rounded-lg bg-slate-300/50 hover:bg-slate-300 dark:bg-white/10 dark:hover:bg-white/20 transition-colors",children:j?e.jsx(Ts,{className:"h-4 w-4 text-emerald-500 dark:text-emerald-400"}):e.jsx(Or,{className:"h-4 w-4 text-slate-600 dark:text-white/70"})})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 md:gap-3",children:[e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800 rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 dark:text-slate-400 mb-1",children:"Mileage"}),e.jsx("p",{className:"text-base md:text-lg font-bold text-slate-900 dark:text-white",children:(z=n.mileage)==null?void 0:z.toLocaleString()})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800 rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 dark:text-slate-400 mb-1",children:"Color"}),e.jsx("p",{className:"text-base md:text-lg font-bold text-slate-900 dark:text-white capitalize",children:n.color})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800 rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 dark:text-slate-400 mb-1",children:"Condition"}),e.jsx("p",{className:"text-base md:text-lg font-bold text-slate-900 dark:text-white capitalize",children:n.condition})]})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-slate-100 dar
12k:border-slate-800",children:e.jsx("h4",{className:"text-sm font-semibold text-slate-900 dark:text-white",children:"Specifications"})}),e.jsxs("div",{className:"divide-y divide-slate-100 dark:divide-slate-800",children:[n.engine&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"text-sm text-slate-500 dark:text-slate-400",children:"Engine"}),e.jsx("span",{className:"text-sm font-medium text-slate-900 dark:text-white",children:n.engine})]}),n.transmission&&e.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3",children:[e.jsx("span",{className:"text-sm text-slate-500 dark:text-slate-400 shrink-0",children:"Transmission"}),e.jsx("span",{className:"text-sm font-medium text-slate-900 dark:text-white text-right",children:n.transmission})]}),n.fuelType&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"text-sm text-slate-500 dark:text-slate-400",children:"Fuel Type"}),e.jsx("span",{className:"text-sm font-medium text-slate-900 dark:text-white capitalize",children:n.fuelType})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"text-sm text-slate-500 dark:text-slate-400",children:"Year"}),e.jsx("span",{className:"text-sm font-medium text-slate-900 dark:text-white",children:n.year})]})]})]}),(n.marketValueLow||n.marketValueHigh)&&e.jsxs("div",{className:"bg-gradient-to-br from-emerald-50 to-teal-50 dark:from-emerald-900/20 dark:to-teal-900/20 rounded-xl p-4 border border-emerald-200 dark:border-emerald-800",children:[e.jsx("h4",{className:"text-sm font-semibold text-emerald-900 dark:text-emerald-300 mb-3",children:"Market Value Range"}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.marketValueLow&&e.jsxs("div",{className:"flex-1 text-center",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-emerald-600 dark:text-emerald-400 mb-1",children:"Low"}),e.jsxs("p",{className:"text-lg font-bold text-emerald-800 dark:text-emerald-200",children:["$",n.marketValueLow.toLocaleString()]})]}),n.marketValueLow&&n.marketValueHigh&&e.jsxs("div",{className:"flex-1 text-center border-x border-emerald-200 dark:border-emerald-700",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-emerald-600 dark:text-emerald-400 mb-1",children:"Average"}),e.jsxs("p",{className:"text-lg font-bold text-emerald-800 dark:text-emerald-200",children:["$",Math.round((n.marketValueLow+n.marketValueHigh)/2).toLocaleString()]})]}),n.marketValueHigh&&e.jsxs("div",{className:"flex-1 text-center",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-emerald-600 dark:text-emerald-400 mb-1",children:"High"}),e.jsxs("p",{className:"text-lg font-bold text-emerald-800 dark:text-emerald-200",children:["$",n.marketValueHigh.toLocaleString()]})]})]})]}),(n.currentBid||n.bidCount!==void 0)&&e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-slate-100 dark:border-slate-800",children:e.jsx("h4",{className:"text-sm font-semibold text-slate-900 dark:text-white",children:"Auction Status"})}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[n.currentBid&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-1",children:"Current High Bid"}),e.jsxs("p",{className:"text-2xl font-bold text-green-700 dark:text-green-500",children:["$",n.currentBid.toLocaleString()]})]}),n.bidCount!==void 0&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-1",children:"Total Bids"}),e.jsx("p",{className:"text-2xl font-bold text-slate-900 dark:text-white",children:n.bidCount})]})]}),(d.customer_display_offer||d.customerDisplayOffer)&&e.jsxs("div",{className:"pt-3 border-t border-slate-100 dark:border-slate-800",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-1",children:"Current High Direct Offer"}),e.jsxs("p",{className:"text-2xl font-bold text-emerald-600 dark:text-emerald-400",children:["$",(d.customer_display_offer||d.customerDisplayOffer).toLocaleStr
12ing()]})]})]})]}),(()=>{const Q=xs(n.description);return Q?e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800/50 rounded-xl p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-slate-900 dark:text-white mb-2",children:"Description"}),e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-300 leading-relaxed",children:Q})]}):null})(),(n.features&&n.features.length>0||n.options&&n.options.length>0)&&e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-700 p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-slate-900 dark:text-white mb-3",children:"Features & Options"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[(X=n.features)==null?void 0:X.map((Q,se)=>e.jsx(Lt,{variant:"secondary",className:"text-xs",children:Q},`feature-${se}`)),(T=n.options)==null?void 0:T.map((Q,se)=>e.jsx(Lt,{variant:"outline",className:"text-xs",children:Q},`option-${se}`))]})]}),e.jsxs(Ws,{open:P,onOpenChange:D,children:[e.jsxs(Ps,{className:"w-full flex items-center justify-between bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-700 p-4 hover:border-primary transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-indigo-100 dark:bg-indigo-900/30 rounded-lg flex items-center justify-center",children:e.jsx(Tr,{className:"h-5 w-5 text-indigo-600 dark:text-indigo-400"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-white",children:"In-Depth Vehicle Details"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Full specifications & condition report"})]})]}),e.jsx(bt,{className:`h-5 w-5 text-slate-400 transition-transform duration-200 ${P?"rotate-180":""}`})]}),e.jsx(Es,{className:"mt-2",children:e.jsx("div",{className:"bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden",children:e.jsx("div",{className:"p-4 max-h-[400px] overflow-y-auto",children:e.jsx(Dr,{car:n,hideInternalFields:!0})})})})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-slate-100 dark:border-slate-800",children:e.jsx("h4",{className:"text-sm font-semibold text-slate-900 dark:text-white",children:"Condition Report"})}),e.jsx("div",{className:"p-4",children:e.jsx(Ar,{tiresGood:d.tiresGood??d.tires_good??d.tiresGood,titleStatus:d.titleStatus??d.title_status??d.titlestatus,hasDamage:d.hasDamage??d.has_damage??d.hasdamage,damageDescription:d.damageDescription??d.damage_description??d.damagedescription,carfaxClean:d.carfaxClean??d.carfax_clean??d.carfaxclean,carfaxIssueDescription:d.carfaxIssueDescription??d.carfax_issue_description??d.carfaxissuedescription,ownersCount:d.ownersCount??d.owners_count??d.ownerscount,tiresNeedReplacement:d.tiresNeedReplacement??d.tires_need_replacement??d.tiresneedreplacement,hasDingsOrScratches:d.hasDingsOrScratches??d.has_dings_or_scratches??d.hasdingsorscratches,dingsDescription:d.dingsDescription??d.dings_description??d.dingsdescription,hasMechanicalIssues:d.hasMechanicalIssues??d.has_mechanical_issues??d.hasmechanicalissues,mechanicalDescription:d.mechanicalDescription??d.mechanical_description??d.mechanicaldescription,titleInHand:d.titleInHand??d.title_in_hand??d.titleinhand,carfaxReports:d.carfaxReports??d.carfax_reports??d.carfaxreports,windshieldCondition:d.windshieldCondition??d.windshield_condition??d.windshieldcondition,keysCount:d.keysCount??d.keys_count??d.keyscount,tiresCondition:d.tiresCondition??d.tires_condition??d.tirescondition,hasDents:d.hasDents??d.has_dents??d.hasdents,dentsDescription:d.dents
12Description??d.dents_description??d.dentsdescription,hasScrapes:d.hasScrapes??d.has_scrapes??d.hasscrapes,scrapesDescription:d.scrapesDescription??d.scrapes_description??d.scrapesdescription,cosmeticCondition:d.cosmeticCondition??d.cosmetic_condition,cosmeticDescription:d.cosmeticDescription??d.dings_description??d.dings_description,mechanicalCondition:d.mechanicalCondition??d.mechanical_condition,mechanicalConditionDescription:d.mechanicalConditionDescription??d.mechanical_description??d.mechanical_description,interiorIssues:d.interiorIssues??d.interior_issues,interiorIssueDescription:d.interiorIssueDescription??d.interior_issue_description,engineIssues:d.engineIssues??d.engine_issues,warningLights:d.warningLights??d.warning_lights,paintDamage:d.paintDamage??d.paint_damage,paintDamageDescription:d.paintDamageDescription??d.paint_damage_description,bumperDamage:d.bumperDamage??d.bumper_damage})})]}),(E||r)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-sm font-semibold text-slate-900 dark:text-white px-1",children:"Documents"}),E&&e.jsxs("button",{onClick:()=>window.open(E,"_blank"),className:"w-full flex items-center justify-between bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-700 p-4 hover:border-primary transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/30 rounded-lg flex items-center justify-center",children:e.jsx(jt,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-white",children:"Window Sticker"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Original manufacturer sticker"})]})]}),e.jsx(it,{className:"h-5 w-5 text-slate-400"})]}),r&&e.jsxs("button",{onClick:()=>window.open(r,"_blank"),className:"w-full flex items-center justify-between bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-700 p-4 hover:border-primary transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-emerald-100 dark:bg-emerald-900/30 rounded-lg flex items-center justify-center",children:e.jsx(jt,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-white",children:"KBB Booksheet"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Kelley Blue Book valuation"})]})]}),e.jsx(it,{className:"h-5 w-5 text-slate-400"})]})]})]})};return b?e.jsx(It,{open:l,onOpenChange:C,shouldScaleBackground:!1,children:e.jsxs(Bt,{className:"max-h-[95vh] bg-slate-100 dark:bg-slate-950",children:[e.jsx("div",{className:"absolute right-4 top-4 z-10",children:e.jsx(Aa,{asChild:!0,children:e.jsx("button",{className:"p-2 rounded-full bg-white/80 dark:bg-slate-800/80 backdrop-blur-sm shadow-sm",children:e.jsx(hs,{className:"h-5 w-5 text-slate-600 dark:text-slate-300"})})})}),e.jsx("div",{className:"overflow-y-auto max-h-[90vh] px-4 pb-8 pt-2","data-vaul-no-drag":!0,children:e.jsx(L,{})})]})}):e.jsx(Ve,{open:l,onOpenChange:C,children:e.jsxs(qe,{className:"max-w-2xl max-h-[90vh] overflow-y-auto bg-slate-50 dark:bg-slate-950",children:[e.jsx(Nt,{children:e.jsx(Ze,{className:"sr-only",children:"Vehicle Details"})}),e.jsx(L,{})]})})};function ll({isOpen:l,onClose:C,car:n,appointment:b,onAppointmentSuccess:j}){const[N,P]=h.useState(null),[D,d]=h.useState(!1),E=Rt();h.useEffect(()=>{l&&(n!=null&&n.highBidderId)&&r()},[l,n==null?void 0:n.highBidderId]);const r=async()=>{if(n!=null&&n.highBidderId)try{d(!0);const{data:A}=await g.from("dealership_users").select(`
13          dealership_id,
14          dealerships:dealership_id (
15            id, name, address, phone, website, logo_url
16          )
17        `).eq("user_id",n.highBidderId),z=(A??[]).map(Q=>Q.dealerships).filter(Boolean);if(z.length>0){const Q=(n.highBidderName||n.high_bidder_name||"").trim().toLowerCase(),se=z.find(he=>((he==null?void 0:he.name)||"").trim().toLowerCase()===Q)||z[0];P({dealership_name:se.name,logo_url:se.logo_url,dealership_address:se.address,dealership_phone:se.phone,dealership_website:se.website});return}const{data:X}=await g.from("dealership_profiles").select("dealership_name, logo_url, address, website, phone").eq("dealer_id",n.highBidderId).maybeSingle();if(X){P({dealership_name:X.dealership_name,logo_url:X.logo_url,dealership_address:X.address,dealership_website:X.website,dealership_phone:X.phone});return}const{data:T}=await g.from("users").select("name, business_name, business_phone, business_address").eq("id",n.highBidderId).maybeSingle();T&&P({dealership_name:T.business_name||T.name,dealership_address:T.business_address,dealership_phone:T.business_phone})}catch(A){console.error("Error loading dealer:",A)}finally{d(!1)}},y=()=>{W.success("Appointment request sent successfully!"),j()};if(!n)return null;const L=n.sale_stage||"accepted_pending_appointment",K=()=>e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-emerald-50 via-white to-emerald-50/50 dark:from-emerald-950/30 dark:via-gray-900 dark:to-emerald-950/20 border border-emerald-200/60 dark:border-emerald-800/30",children:[e.jsx("div",{className:"absolute top-0 right-0 w-40 h-40 bg-gradient-to-bl from-emerald-200/30 dark:from-emerald-800/10 to-transparent roun
17ded-full -translate-y-1/2 translate-x-1/4"}),e.jsxs("div",{className:"grid md:grid-cols-[180px_1fr] gap-0",children:[e.jsx("div",{className:"relative h-36 md:h-full md:min-h-[200px]",children:n.images&&n.images.length>0?e.jsx("img",{src:n.coverPhoto||n.images[0],alt:`${n.year} ${n.make} ${n.model}`,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full bg-emerald-100 dark:bg-emerald-900/20 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-emerald-600 dark:text-emerald-400",children:"No image"})})}),e.jsxs("div",{className:"relative p-5 flex flex-col justify-center space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-emerald-500 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-500/20 flex-shrink-0",children:e.jsx(ae,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-lg md:text-xl font-bold text-slate-900 dark:text-white",children:"Congratulations! 🎉"}),e.jsx("p",{className:"text-sm text-emerald-700 dark:text-emerald-400 font-medium",children:"Appointment to Finalize Deal is Confirmed"})]})]}),e.jsx("div",{className:"py-3 border-t border-emerald-200/50 dark:border-emerald-800/30 space-y-3",children:e.jsxs("div",{className:"flex flex-col xs:flex-row xs:items-start xs:justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.15em] text-emerald-600 dark:text-emerald-500 font-semibold",children:"Vehicle"}),e.jsxs("p",{className:"text-base font-semibold text-slate-900 dark:text-white",children:[n.year," ",n.make," ",n.model]}),e.jsxs("p",{className:"text-xs text-slate-500 dark:text-gray-400 font-mono",children:["VIN: ",n.vin]})]}),e.jsxs("div",{className:"space-y-1 xs:text-right flex-shrink-0 bg-emerald-100/50 dark:bg-emerald-900/20 rounded-lg px-4 py-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.15em] text-emerald-600 dark:text-emerald-500 font-semibold",children:"Sale Price"}),e.jsxs("p",{className:"text-2xl font-bold text-emerald-700 dark:text-emerald-400",children:["$",(n.sale_price||n.currentBid||n.startingBid||0).toLocaleString()]})]})]})}),N&&e.jsxs("div",{className:"pt-3 border-t border-emerald-200/50 dark:border-emerald-800/30 space-y-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.15em] text-emerald-600 dark:text-emerald-500 font-semibold",children:"Purchased By"}),e.jsxs("div",{className:"flex items-start gap-3",children:[N.logo_url?e.jsx("img",{src:N.logo_url,alt:`${N.dealership_name||N.business_name} logo`,className:"w-12 h-12 rounded-xl object-contain bg-white dark:bg-gray-800 border border-emerald-200/50 dark:border-emerald-800/30 flex-shrink-0 p-1"}):e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-emerald-100 to-emerald-50 dark:from-emerald-900/40 dark:to-emerald-900/20 border border-emerald-200/50 dark:border-emerald-800/30 flex items-center justify-center flex-shrink-0",children:e.jsx(dt,{className:"h-6 w-6 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-bold text-slate-900 dark:text-white truncate",children:N.dealership_name||N.business_name||N.name}),N.dealership_address&&e.jsx("p",{className:"text-xs text-slate-500 dark:text-gray-400 line-clamp-1",children:N.dealership_address}),e.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-xs",children:[N.dealership_phone&&e.jsxs("a",{href:`tel:${N.dealership_phone}`,className:"text-emerald-600 dark:text-emerald-400 hover:underline flex items-center gap-1",children:[e.jsx(vt,{className:"h-3 w-3"}),N.dealership_phone]}),N.dealership_website&&e.jsx("a",{href:N.dealership_website.startsWith("http")?N.dealership_website:`https://${N.dealership_website}`,target:"_blank",rel:"noopener noreferrer",className:"text-emerald-600 dark:text-emerald-400 hover:underline",children:"Visit Website"})]})]})]})]})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-slate-200 dark:border-gray-800 p-4 md:p-5",children:[e.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-[0.15em] text-slate-500 dark:text-gray-400 mb-4",children:"Sale Progress"}),(()=>{const A=!!b,z=A&&(b.status==="pending"||b.status==="requested"),X=A&&b.status==="confirmed",T=z||X||L==="appointment_requested"||L==="appointment_c
17onfirmed",Q=X||L==="appointment_confirmed";return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-col items-center flex-1",children:[e.jsx("div",{className:"w-10 h-10 md:w-12 md:h-12 rounded-xl bg-gradient-to-br from-emerald-500 to-emerald-600 flex items-center justify-center text-white shadow-lg shadow-emerald-500/20 mb-2",children:e.jsx(ae,{className:"h-5 w-5 md:h-6 md:w-6"})}),e.jsx("span",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-400",children:"Accepted"})]}),e.jsx("div",{className:"flex-1 h-0.5 bg-gradient-to-r from-emerald-500 to-emerald-400 rounded-full"}),e.jsxs("div",{className:"flex flex-col items-center flex-1",children:[e.jsx("div",{className:`w-10 h-10 md:w-12 md:h-12 rounded-xl flex items-center justify-center mb-2 transition-all ${T?"bg-gradient-to-br from-emerald-500 to-emerald-600 text-white shadow-lg shadow-emerald-500/20":"bg-slate-100 dark:bg-gray-800 text-slate-400 dark:text-gray-500"}`,children:e.jsx(oe,{className:"h-5 w-5 md:h-6 md:w-6"})}),e.jsx("span",{className:`text-xs font-medium ${T?"text-emerald-700 dark:text-emerald-400":"text-slate-400 dark:text-gray-500"}`,children:"Scheduled"})]}),e.jsx("div",{className:`flex-1 h-0.5 rounded-full ${Q?"bg-gradient-to-r from-emerald-400 to-emerald-500":"bg-slate-200 dark:bg-gray-700"}`}),e.jsxs("div",{className:"flex flex-col items-center flex-1",children:[e.jsx("div",{className:`w-10 h-10 md:w-12 md:h-12 rounded-xl flex items-center justify-center mb-2 transition-all ${Q?"bg-gradient-to-br from-emerald-500 to-emerald-600 text-white shadow-lg shadow-emerald-500/20":"bg-slate-100 dark:bg-gray-800 text-slate-400 dark:text-gray-500"}`,children:e.jsx(ae,{className:"h-5 w-5 md:h-6 md:w-6"})}),e.jsx("span",{className:`text-xs font-medium ${Q?"text-emerald-700 dark:text-emerald-400":"text-slate-400 dark:text-gray-500"}`,children:"Confirmed"})]})]})})()]}),!b&&(!L||L==="pending_acceptance"||L==="accepted_pending_appointment")&&e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-slate-200 dark:border-gray-800 p-4 md:p-5",children:[e.jsx("h3",{className:"text-sm md:text-base font-semibold text-slate-900 dark:text-white mb-1",children:"Schedule Your Appointment"}),e.jsxs("p",{className:"text-xs text-slate-500 dark:text-gray-400 mb-4",children:["Choose a convenient time to meet with ",(N==null?void 0:N.business_name)||(N==null?void 0:N.name)||"the dealer"]}),e.jsx(Wr,{carId:n.id,dealerId:n.highBidderId||"",onSuccess:y})]}),b&&(b.status==="pending"||b.status==="requested")&&e.jsxs("div",{className:"bg-gradient-to-br from-amber-50 to-orange-50/50 dark:from-amber-950/20 dark:to-orange-950/10 rounded-xl border border-amber-200/60 dark:border-amber-800/30 p-4 md:p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center",children:e.jsx(Ie,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-amber-900 dark:text-amber-100",children:"Appointment Request Sent"}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"Waiting for dealer confirmation"})]})]}),e.jsxs("div",{className:"space-y-2 ml-10",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-amber-800 dark:text-amber-200 mb-1",children:"Requested Date & Time:"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-700 dark:text-amber-300",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsxs("span",{children:[b.date," at ",b.time]})]})]}),b.customer_notes&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-amber-800 dark:text-amber-200 mb-1",children:"Your Notes:"}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:b.customer_notes})]})]})]}),b&&b.status==="confirmed"&&e.jsxs("div",{className:"bg-gradient-to-br from-emerald-50 to-teal-50/50 dark:from-emerald-950/20 dark:to-teal-950/10 rounded-xl border border-emerald-200/60 dark:border-emerald-800/30 p-4 md:p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-emerald-100 dark:bg-emerald-900/30 flex items-center justify-center",children:e.jsx(ae,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-emerald-900 dark:text-emerald-100",children:"Appointment Confirmed!"}),e.jsx("p",{className:"text-xs text-emerald-700 dark:text-emerald-300",children:"Your sale appointment has been confirmed"})]})]}),e.jsxs("div",{className:"space-y-3 ml-10",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(oe,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"}),e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-emerald-700 dark:text-emerald-300",children:"When"})]}),e.jsxs("p",{className:"text-sm text-emerald-800 dark:text-emerald-200 ml-6 font-medium",children:[b.date," at ",b.time]})]}),(N==null?void 0:N.dealership_address)&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Re,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"}),e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-emerald-700 dark:text-emerald-300",children:"Where"})]}),e.jsx("p",{className:"text-sm text-emerald-800 dark:text-emerald-200 ml-6",children:N.dealership_address}),e.jsxs("div",{className:"flex gap-2 ml-6 mt-2",children:[e.jsx("a",{href:`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(N.dealership_address)}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400 hover:underline font-medium",children:"Google Maps"}),e.jsx("span",{className:"text-emerald-400 dark:text-emerald-600",children:"•"}),e.jsx("a",{href:`https://maps.apple.com/?q=${encodeURIComponent(N.dealership_address)}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400 hover:underline font-medium",children:"Apple Maps"})]})]})]})]}),e.jsxs("div",{className:"bg-gradient-to-br from-amber-50/80 to-orange-50/50 dark:from-amber-950/15 dark:to-orange-950/10 rounded-xl border border-amber-200/50 dark:border-amber-800/20 p-4 md:p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-amber-100 dar
17k:bg-amber-900/30 flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-amber-600 dark:text-amber-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})})}),e.jsx("h3",{className:"text-sm font-semibold text-amber-900 dark:text-amber-100",children:"What to Bring"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 md:gap-3 ml-10",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-800 dark:text-amber-200",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-amber-500 rounded-full flex-shrink-0"}),e.jsx("span",{children:"Vehicle title"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-800 dark:text-amber-200",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-amber-500 rounded-full flex-shrink-0"}),e.jsx("span",{children:"Valid photo ID"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-800 dark:text-amber-200",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-amber-500 rounded-full flex-shrink-0"}),e.jsx("span",{children:"All keys & remotes"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-800 dark:text-amber-200",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-amber-500 rounded-full flex-shrink-0"}),e.jsx("span",{children:"Maintenance records"})]})]})]})]});return E?e.jsx(It,{open:l,onOpenChange:A=>!A&&C(),children:e.jsxs(Bt,{className:"max-h-[85vh] flex flex-col",children:[e.jsx(Ht,{className:"border-b pb-3 flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:"Sale Details"}),e.jsx(Aa,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(hs,{className:"h-4 w-4"})})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 overscroll-contain",children:e.jsx(K,{})})]})}):e.jsx(Ve,{open:l,onOpenChange:A=>!A&&C(),children:e.jsxs(qe,{className:"max-w-2xl max-h-[90vh] flex flex-col p-0",children:[e.jsx(Nt,{className:"p-4 md:p-6 pb-0 flex-shrink-0",children:e.jsx(Ze,{children:"Sale Details"})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 md:p-6 pt-4",children:e.jsx(K,{})})]})})}const dl=()=>["sunday","monday","tuesday","wednesday","thursday","friday","saturday"][new Date().getDay()],il=({isOpen:l,onClose:C,offerType:n,amount:b,dealerId:j,dealerName:N,vehicle:P,onAcceptAndSchedule:D})=>{const[d,E]=h.useState(null),[r,y]=h.useState(!1),L=Rt();h.useEffect(()=>{(async()=>{if(!(!j||!l)){y(!0);try{let z=null,X=null,T=null,Q=null,se=null,he=null,me=null,w=null,ee=null,F=null,ne=null,u=null,k="",o=N;const{data:ve}=await g.from("dealership_users").select("dealership_id").eq("user_id",j).maybeSingle();if(ve!=null&&ve.dealership_id){const{data:B}=await g.from("dealerships").select("id, name, logo_url, address, website, phone, payment_types, pickup_options, title_in_hand_payment, loan_payoff_options, preferred_contacts").eq("id",ve.dealership_id).maybeSingle();if(B&&(z=B.name,X=B.logo_url,T=B.address,Q=B.website,se=B.phone,he=B.payment_types,me=B.pickup_options,w=B.title_in_hand_payment,ee=B.loan_payoff_options,B.preferred_contacts)){const _=B.preferred_contacts[dl()];if(_){const{data:U}=await g.from("users").select("name, email, phone").eq("id",_).maybeSingle();U&&(F=U.name,ne=U.phone,u=U.email)}}}if(!z){const{data:B}=await g.from("dealership_profiles").select("dealer_id, dealership_name, logo_url, address, website, phone, payment_types, pickup_options, title_in_hand_payment, loan_payoff_options").eq("dealer_id",j).maybeSingle();B&&(z=B.dealership_name,X=B.logo_url,T=B.address,Q=B.website,se=B.phone,he=B.payment_types,me=B.pickup_options,w=B.title_in_hand_payment,ee=B.loan_payoff_options)}if(!z){const{data:B}=await g.from("dealerships").select("id, name, logo_url, address, website, phone, payment_types, pickup_options, title_in_hand_payment, loan_payoff_options").eq("id",j).maybeSingle();B&&(z=B.name,X=B.logo_url,T=B.address,Q=B.website,se=B.phone,he=B.payment_types,me=B.pickup_options,w=B.title_in_hand_payment,ee=B.loan_payoff_options)}const{data:pe}=await g.from("users").select("id, name, email, phone").eq("id",j).maybeSingle();
17pe&&(o=pe.name||N,k=pe.email||"",se||(se=pe.phone||"")),E({name:o,email:k,phone:se||"",dealershipName:z||N,dealershipLogo:X,address:T,website:Q,paymentTypes:he,pickupOptions:me,titleInHandPayment:w,loanPayoffOptions:ee,preferredContactName:F,preferredContactPhone:ne,preferredContactEmail:u})}catch(z){console.error("Error fetching dealer info:",z),E({name:N,email:"",phone:"",dealershipName:N,dealershipLogo:null,address:null,website:null,paymentTypes:null,pickupOptions:null,titleInHandPayment:null,loanPayoffOptions:null,preferredContactName:null,preferredContactPhone:null,preferredContactEmail:null})}finally{y(!1)}}})()},[j,N,l]);const K=()=>e.jsxs("div",{className:"space-y-6 px-1",children:[e.jsxs("div",{className:"text-center py-8 relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-primary/5 via-transparent to-transparent dark:from-primary/10 dark:via-transparent rounded-2xl"}),e.jsxs("div",{className:"relative",children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-primary/70 dark:text-primary/70 mb-3 font-medium",children:n==="bid"?"Winning Bid":"Lock In Your Offer"}),e.jsxs("div",{className:"text-5xl sm:text-6xl font-light text-foreground tracking-tight",children:["$",b.toLocaleString()]}),e.jsxs("div",{className:"mt-4 flex items-center justify-center gap-2",children:[e.jsx("div",{className:"h-px w-8 bg-gradient-to-r from-transparent to-primary/50 dark:to-primary/50"}),e.jsxs("p",{className:"text-sm text-muted-foreground font-light tracking-wide",children:[P.year," ",P.make," ",P.model]}),e.jsx("div",{className:"h-px w-8 bg-gradient-to-l from-transparent to-primary/50 dark:to-primary/50"})]})]})]}),e.jsxs("div",{className:"rounded-xl overflow-hidden bg-gradient-to-b from-muted/20 to-muted/5 dark:from-zinc-800/40 dark:to-zinc-900/20 border border-border/50 dark:border-zinc-700/50",children:[e.jsx("div",{className:"px-5 py-3 border-b border-border/30 dark:border-zinc-700/30",children:e.jsx("p",{className:"text-[11px] font-medium text-primary/80 dark:text-primary/80 uppercase tracking-[0.15em]",children:"Purchasing Dealer"})}),r?e.jsxs("div",{className:"p-5 animate-pulse space-y-4",children:[e.jsx("div",{className:"h-12 bg-muted/50 dark:bg-zinc-800/50 rounded-lg"}),e.jsx("div",{className:"h-6 bg-muted/50 dark:bg-zinc-800/50 rounded-lg w-3/4"})]}):e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-5",children:[d!=null&&d.dealershipLogo?e.jsx("img",{src:d.dealershipLogo,alt:d.dealershipName,className:"w-14 h-14 rounded-xl object-contain bg-background dark:bg-zinc-800 border border-border/50 dark:border-zinc-700/50 p-1.5 shadow-sm"}):e.jsx("div",{className:"w-14 h-14 rounded-xl bg-gradient-to-br from-primary/10 to-primary/5 dark:from-primary/15 dark:to-primary/10 flex items-center justify-center text-primary dark:text-primary font-light text-2xl border border-primary/20 dark:border-primary/20",children:((d==null?void 0:d.dealershipName)||N).charAt(0)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-medium text-lg text-foreground truncate tracking-tight",children:(d==null?void 0:d.dealershipName)||N}),(d==null?void 0:d.name)&&e.jsx("p",{className:"text-sm text-muted-foreground truncate font-light",children:d.name})]})]}),(d==null?void 0:d.preferredContactName)&&e.jsxs("div",{className:"mx-5 mb-4 p-4 rounded-lg bg-gradient-to-r from-blue-50/50 to-transparent dark:from-blue-950/20 dark:to-transparent border border-blue-100/50 dark:border-blue-900/30",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-3",children:[e.jsx(dt,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"text-xs font-medium text-blue-700 dark:text-blue-300 uppercase tracking-wide",children:"Your Contact Today"})]}),e.jsx("p",{className:"text-sm font-medium text-foreground mb-2",children:d.preferredContactName}),e.jsxs("div",{className:"space-y-1.5",children:[d.preferredContactPhone&&e.jsxs("a",{href:`tel:${d.preferredContactPhone}`,className:"flex items-center gap-2 text-sm text-blue-700 dark:text-blue-300 hover:text-blue-800 dark:hover:text-blue-200 transition-colors",children:[e.jsx(vt,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:d.preferredContactPhone})]}),d.preferredContactEmail&&e.jsxs("a",{href:`mailto:${d.preferredContactEmail}`,className:"flex items-center gap-2 text-sm text-blue-700 dark:text-blue-300 hover:text-blue-800 dark:hover:text-blue-200 transition-colors",children:[e.jsx(Bs,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"truncate",children:d.preferredContactEmail})]})]})]}),d&&e.jsxs("div",{className:"space-y-2 pt-4 border-t border-border/30 dark:border-zinc-700/30",children:[d.phone&&e.jsxs("a",{href:`tel:${d.phone}
17`,className:"flex items-center gap-3 text-sm text-foreground/80 hover:text-primary dark:hover:text-white transition-colors py-1.5",children:[e.jsx(vt,{className:"h-4 w-4 text-primary/50 dark:text-primary/50 flex-shrink-0"}),e.jsx("span",{className:"font-light",children:d.phone})]}),d.email&&e.jsxs("a",{href:`mailto:${d.email}`,className:"flex items-center gap-3 text-sm text-foreground/80 hover:text-primary dark:hover:text-white transition-colors py-1.5",children:[e.jsx(Bs,{className:"h-4 w-4 text-primary/50 dark:text-primary/50 flex-shrink-0"}),e.jsx("span",{className:"truncate font-light",children:d.email})]}),d.address&&e.jsxs("div",{className:"flex items-start gap-3 text-sm text-foreground/80 py-1.5",children:[e.jsx(Re,{className:"h-4 w-4 text-primary/50 dark:text-primary/50 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"font-light",children:d.address})]})]})]})]}),e.jsxs("div",{className:"rounded-xl overflow-hidden bg-gradient-to-b from-muted/20 to-muted/5 dark:from-zinc-800/40 dark:to-zinc-900/20 border border-border/50 dark:border-zinc-700/50",children:[e.jsx("div",{className:"px-5 py-3 border-b border-border/30 dark:border-zinc-700/30",children:e.jsx("p",{className:"text-[11px] font-medium text-primary/80 dark:text-primary/80 uppercase tracking-[0.15em]",children:"Transaction Details"})}),e.jsxs("div",{className:"divide-y divide-border/30 dark:divide-zinc-700/30",children:[e.jsxs("div",{className:"px-5 py-4 flex justify-between items-start",children:[e.jsxs("div",{className:"flex items-center gap-2.5 text-sm text-muted-foreground",children:[e.jsx(ps,{className:"h-4 w-4 text-primary/50 dark:text-primary/50"}),e.jsx("span",{className:"font-light",children:"Vehicle"})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-medium text-foreground",children:[P.year," ",P.make," ",P.model]}),e.jsx("p",{className:"text-xs text-muted-foreground/70 font-mono mt-0.5",children:P.vin})]})]}),e.jsxs("div",{className:"px-5 py-4 flex justify-between items-center bg-gradient-to-r from-primary/5 to-transparent dark:from-primary/10 dark:to-transparent",children:[e.jsxs("div",{className:"flex items-center gap-2.5 text-sm text-muted-foreground",children:[e.jsx(rt,{className:"h-4 w-4 text-primary/50 dark:text-primary/50"}),e.jsx("span",{className:"font-light",children:n==="bid"?"Winning Bid":"Offer Amount"})]}),e.jsxs("p",{className:"text-xl font-medium text-primary dark:text-primary",children:["$",b.toLocaleString()]})]}),(d==null?void 0:d.paymentTypes)&&d.paymentTypes.length>0&&e.jsxs("div",{className:"px-5 py-4 flex justify-between items-start",children:[e.jsxs("div",{className:"flex items-center gap-2.5 text-sm text-muted-foreground",children:[e.jsx(nt,{className:"h-4 w-4 text-primary/50 dark:text-primary/50"}),e.jsx("span",{className:"font-light",children:"Payment"})]}),e.jsx("div",{className:"flex flex-wrap gap-2 justify-end max-w-[60%]",children:d.paymentTypes.map((A,z)=>e.jsx("span",{className:"text-xs bg-primary/5 dark:bg-primary/10 px-2.5 py-1 rounded-full text-primary dark:text-primary border border-primary/20 dark:border-primary/20 font-light",children:A},z))})]}),(d==null?void 0:d.pickupOptions)&&d.pickupOptions.length>0&&e.jsxs("div",{className:"px-5 py-4 flex justify-between items-start",children:[e.jsxs("div",{className:"flex items-center gap-2.5 text-sm text-muted-foreground",children:[e.jsx(qt,{className:"h-4 w-4 text-primary/50 dark:text-primary/50"}),e.jsx("span",{className:"font-light",children:"Location"})]}),e.jsx("div",{className:"flex flex-wrap gap-2 justify-end max-w-[60%]",children:d.pickupOptions.map((A,z)=>e.jsx("span",{className:"text-xs bg-muted/50 dark:bg-zinc-800 px-2.5 py-1 rounded-full text-foreground/80 border border-border/50 dark:border-zinc-700 font-light",children:A},z))})]}),(d==null?void 0:d.titleInHandPayment)&&e.jsxs("div",{className:"px-5 py-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5 text-sm text-muted-foreground",children:[e.jsx(nt,{className:"h-4 w-4 text-primary/50 dark:text-primary/50"}),e.jsx("span",{className:"font-light",children:"Same Day Payment for Title"})]}
17),e.jsx("p",{className:"text-sm text-foreground/80 font-light pl-6",children:d.titleInHandPayment==="No"?"Next Business Day":d.titleInHandPayment})]}),(d==null?void 0:d.loanPayoffOptions)&&d.loanPayoffOptions.length>0&&e.jsxs("div",{className:"px-5 py-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5 text-sm text-muted-foreground",children:[e.jsx(rt,{className:"h-4 w-4 text-primary/50 dark:text-primary/50"}),e.jsxs("span",{className:"font-light",children:["Payoff Process ",e.jsx("span",{className:"text-xs text-muted-foreground/70",children:"(If you have an Active loan)"})]})]}),e.jsx("div",{className:"flex flex-col gap-1.5 pl-6",children:d.loanPayoffOptions.map((A,z)=>e.jsxs("p",{className:"text-sm text-foreground/80 font-light break-words",children:["• ",A]},z))})]})]})]}),e.jsxs("div",{className:"space-y-3 pt-3 pb-2",children:[e.jsxs(I,{onClick:D,size:"lg",className:"w-full h-14 text-base font-semibold tracking-wide bg-gradient-to-b from-primary via-primary/90 to-primary/80 hover:from-primary/90 hover:via-primary/80 hover:to-primary/70 text-white shadow-[0_4px_20px_-4px] shadow-primary/40 hover:shadow-[0_6px_24px_-4px] hover:shadow-primary/50 border border-primary/30 rounded-xl transition-all duration-200 hover:scale-[1.02] active:scale-[0.98]",children:[e.jsx(oe,{className:"mr-2.5 h-5 w-5"}),"Accept and Schedule Appointment"]}),e.jsx(I,{onClick:C,variant:"ghost",size:"lg",className:"w-full h-11 text-muted-foreground hover:text-foreground font-light tracking-wide",children:"Not Now"})]})]});return L?e.jsx(It,{open:l,onOpenChange:C,children:e.jsxs(Bt,{className:"max-h-[90vh]",children:[e.jsxs(Ht,{className:"text-left pb-2",children:[e.jsx(zt,{className:"text-xl font-light tracking-tight",children:"Offer Details"}),e.jsx(us,{className:"text-sm font-light",children:"Review the offer details before accepting"})]}),e.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:e.jsx(K,{})})]})}):e.jsx(Ve,{open:l,onOpenChange:C,children:e.jsxs(qe,{className:"max-w-lg max-h-[85vh] flex flex-col overflow-hidden",children:[e.jsxs(Nt,{className:"text-left flex-shrink-0",children:[e.jsx(Ze,{className:"text-2xl font-light tracking-tight",children:"Offer Details"}),e.jsx($t,{className:"font-light",children:"Review the offer details before accepting"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto overscroll-contain -mx-6 px-6",children:e.jsx(K,{})})]})})};function nl(l){const[C,n]=h.useState(!1);return h.useEffect(()=>{const b=window.matchMedia(l);n(b.matches);const j=N=>{n(N.matches)};return b.addEventListener("change",j),()=>{b.removeEventListener("change",j)}},[l]),C}const La="#0b2545",ft=({winningDealer:l,offers:C=[],displayBestAmount:n,bidderCount:b,vin:j,className:N="",expandable:P=!0})=>{const[D,d]=h.useState(!1),r=h.useMemo(()=>[...C].sort((T,Q)=>Q.amount-T.amount),[C])[0];if(!l&&!r)return null;const y=(l==null?void 0:l.dealership_name)||(r==null?void 0:r.dealerName)||"Verified Dealer",L=(l==null?void 0:l.dealership_address)||(r==null?void 0:r.dealerAddress)||(r!=null&&r.dealerCity&&(r!=null&&r.dealerState)?`${r.dealerCity}, ${r.dealerState}`:null),K=(l==null?void 0:l.dealership_phone)||(r==null?void 0:r.dealerPhone),A=(l==null?void 0:l.dealership_website)||(r==null?void 0:r.dealerWebsite),z=j?j.slice(-9):"",X=e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-full bg-white shadow-sm overflow-hidden",children:l!=null&&l.logo_url?e.jsx("img",{src:l.logo_url,alt:y,className:"h-full w-full object-contain"}):e.jsx(Ma,{className:"h-6 w-6 text-slate-400"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] font-bold tracking-wider text-slate-500 uppercase",children:"Winning Dealer"}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-full bg-emerald-50 text-emerald-700 text-[10px] font-bold shrink-0",children:[e.jsx(Ge,{className:"w-3 h-3"}),"Verified"]})]}),e.jsx("p",{className:"text-sm font-bold break-words whitespace-normal",style:{color:La},children:y}),L&&e.jsxs("p",{className:"text-xs text-slate-500 flex items-start gap-1 break-words whitespace-normal",children:[e.jsx(Re,{className:"w-3 h-3 mt-0.5 shrink-0"}),L]})]}),P&&e.jsx(bt,{className:`w-4 h-4 text-slate-400 shrink-0 transition-transform mt-1 ${D?"rotate-180":""}`})]});return e.jsx("div",{className:`mt-3 ${N}`,children:P?e.jsxs("button",{type:"button",onClick:()=>d(T=>!T),"aria-expanded":D,className:"w-full rounded-xl bg-slate-50 border border-slate-100 p-3 text-left transition-colors hover:bg-slate-100 focus:outline-none focus:ring-2 focus:ring-emerald-400/40",children:[X,D&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-slate-200 space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold tracking-wider text-slate-500 uppercase mb-1.5",children:"Dealer Details"}),e.jsxs("div",{className:"space-y-1.5 text-xs text-slate-700",children:[L&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Re,{className:"w-3.5 h-3.5 mt-0.5 text-slate-400 shrink-0"}),e.jsx("span",{className:"flex-1",children:L})]}),K&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vt,{className:"w-3.5 h-3.5 text-slate-400 shrink-0"}),e.jsx("a",{href:`tel:${K}`,onClick:T=>T.stopPropagation(),className:"text-emerald-700 font-medium hover:underline",children:K})]}),A&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oa,{className:"w-3.5 h-3.5 text-slate-400 shrink-0"}),e.jsx("a",{href:A.startsWith("http")?A:`https://${A}`,target:"_blank",rel:"noopener noreferrer",onClick:T=>T.stopPropagation(),className:"text-emerald-700 font-medium hover:underline truncate",children:A.replace(/^https?:\/\//,"")})]}),L&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx("a",{href:`https://maps.apple.com/?q=${encodeURIComponent(L)}`,target:"_blank",rel:"noopener noreferrer",onClick:T=>T.stopPropagation(),className:"flex-1 flex items-center justify-center gap-1 rounded-lg bg-white border border-slate-200 px-2 py-1.5 text-[11px] font-medium text-slate-700 hover:bg-slate-50",children:"Apple Maps"}),e.jsx("a",{href:`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(L)}`,target:"_blank",rel:"noopener noreferrer",onClick:T=>T.stopPropagation(),className:"flex-1 flex items-center justify-center gap-1 rounded-lg bg-white border border-slate-200 px-2 py-1.5 text-[11px] font-medium text-slate-700 hover:bg-slate-50",children:"Google Maps"})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold tracking-wider text-slate-500 uppercase mb-1.5",children:"Transaction Details"}),e.jsxs("div",{className:"space-y-1.5 text-xs",children:[typeof n=="number"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Offer Amount"}),e.jsxs("span",{className:"font-bold",style:{color:La}
17,children:["$",n.toLocaleString()]})]}),typeof b=="number"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Competing Bidders"}),e.jsx("span",{className:"font-semibold text-slate-700",children:b})]}),(r==null?void 0:r.timestamp)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Offer Placed"}),e.jsx("span",{className:"font-semibold text-slate-700",children:new Date(r.timestamp).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})})]}),(r==null?void 0:r.paymentTypes)&&r.paymentTypes.length>0&&e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("span",{className:"text-slate-500 flex items-center gap-1",children:[e.jsx(nt,{className:"w-3 h-3"}),"Payment"]}),e.jsx("span",{className:"font-semibold text-slate-700 text-right",children:r.paymentTypes.join(", ")})]}),(r==null?void 0:r.pickupOptions)&&r.pickupOptions.length>0&&e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("span",{className:"text-slate-500 flex items-center gap-1",children:[e.jsx(qt,{className:"w-3 h-3"}),"Pickup"]}),e.jsx("span",{className:"font-semibold text-slate-700 text-right",children:r.pickupOptions.join(", ")})]}),z&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-slate-500 flex items-center gap-1",children:[e.jsx(qr,{className:"w-3 h-3"}),"VIN"]}),e.jsxs("span",{className:"font-mono font-semibold text-slate-700",children:["…",z]})]})]})]})]})]}):e.jsx("div",{className:"w-full rounded-xl bg-slate-50 border border-slate-100 p-3",children:X})})},ol=({isOpen:l,onClose:C,vehicle:n,dealerId:b,dealerName:j,acceptedOfferId:N,dealershipId:P,salePrice:D,customerInfo:d,onScheduled:E})=>{const[r,y]=h.useState(null),[L,K]=h.useState(""),[A,z]=h.useState((d==null?void 0:d.name)||""),[X,T]=h.useState((d==null?void 0:d.phone)||""),[Q,se]=h.useState((d==null?void 0:d.email)||""),[he,me]=h.useState(""),[w,ee]=h.useState(!1),[F,ne]=h.useState(!1),[u,k]=h.useState(null),[o,ve]=h.useState(!0),[pe,B]=h.useState(()=>tt(is(new Date),1)),[_,U]=h.useState(null),[we,He]=h.useState(b),[ot,Mt]=h.useState(P||null),ct=nl("(max-width: 640px)");h.useEffect(()=>{(we||b)&&l&&(async()=>{ve(!0);const be=await Er(we||b);k(be),ve(!1)})()},[b,l,we]),h.useEffect(()=>{const q=Y=>({dealership_name:(Y==null?void 0:Y.name)??void 0,dealership_address:(Y==null?void 0:Y.address)??void 0,dealership_phone:(Y==null?void 0:Y.phone)??void 0,dealership_website:(Y==null?void 0:Y.website)??void 0,logo_url:(Y==null?void 0:Y.logo_url)??void 0});b&&l&&(async()=>{let Y=b,ke=j,Te=P;if(N){const{data:x}=await g.from("direct_offers").select("dealer_id, dealer_name, dealership_id").eq("id",N).maybeSingle();x&&(Y=x.dealer_id||Y,ke=x.dealer_name||ke,Te=x.dealership_id||Te)}else if(n!=null&&n.id||n!=null&&n.vin){let x=null;if(n.id){const{data:Xe}=await g.from("direct_offers").select("dealer_id, dealer_name, dealership_id").eq("vehicle_id",n.id).eq("status","accepted").order("created_at",{ascending:!1}).limit(1).maybeSingle();x=Xe}if(!x&&n.vin){const{data:Xe}=await g.from("direct_offers").select("dealer_id, dealer_name, dealership_id").eq("vin",n.vin).eq("status","accepted").order("created_at",{ascending:!1}).limit(1).maybeSingle();x=Xe}x&&(Y=x.dealer_id||Y,ke=x.dealer_name||ke,Te=x.dealership_id||Te)}if(He(Y),Mt(Te||null),Te){const{data:x}=await g.from("dealerships").select("name, address, phone, website, logo_url").eq("id",Te).maybeSingle();if(x){U(q(x));return}}const{data:Me}=await g.from("dealerships").select("name, address, phone, website, logo_url").eq("id",Y).maybeSingle();if(Me){U(q(Me));return}const{data:ze}=await g.from("dealership_users").select("dealership_id").eq("user_id",Y),$e=[...new Set((ze||[]).map(x=>x.dealership_id).filter(Boolean))];if($e.length>0){const{data:x}=await g.from("dealerships").select("name, address, phone, website, logo_url").in("id",$e),Xe=(ke||"").trim().toLowerCase(),Zt=(x||[]).find(Xt=>(Xt.name||"").trim().toLowerCase()===Xe)||(x==null?void 0:x[0]);if(Zt){U(q(Zt));return}}const{data:Ce}=await g.from("dealership_profiles").select("dealership_name, logo_url, address, website, phone").eq("dealer_id",Y).maybeSingle();if(Ce){U({dealership_name:Ce.dealership_name||ke,dealership_address:Ce.address??void 0,dealership_phone:Ce.ph
17one??void 0,dealership_website:Ce.website??void 0,logo_url:Ce.logo_url??void 0});return}U({dealership_name:ke})})()},[N,b,j,P,l,n.id,n.vin]),h.useEffect(()=>{l&&(y(null),K(""),B(tt(is(new Date),1)))},[l]);const Be=h.useMemo(()=>{const q=[],be=ct?5:7;for(let Y=0;Y<be;Y++)q.push(tt(pe,Y));return q},[pe,ct]),Ft=h.useMemo(()=>r?Pr(u,r,30):[],[r,u]),Oe=q=>Vr(u,q),Ut=$s(pe,tt(is(new Date),1)),wt=$s(Rr(new Date,2),tt(pe,7)),At=()=>{const q=tt(pe,ct?-5:-7),be=tt(is(new Date),1);$s(q,be)||ya(q,be)?B(q):B(be)},gs=()=>{B(tt(pe,ct?5:7))},fs=q=>{Oe(q)||(y(q),K(""))},kt=async q=>{if(q.preventDefault(),!r||!L){W.error("Please select a date and time");return}ee(!0);try{const be=lt(r,"yyyy-MM-dd"),{data:Y}=await g.from("appointments").select("id").eq("car_id",n.id).maybeSingle(),ke=we||b,Te=ot||P||null,Me={car_id:n.id,vin:n.vin,dealer_id:ke,dealership_id:Te,high_bidder_id:ke,date:be,time:L,status:"requested",customer_name:A,customer_phone:X,customer_email:Q,customer_notes:he||null};let ze;if(Y){const{error:Ce}=await g.from("appointments").update(Me).eq("id",Y.id);ze=Ce}else{const{error:Ce}=await g.from("appointments").insert(Me);ze=Ce}if(ze)throw ze;const{error:$e}=await g.rpc("update_car_appointment_status",{p_car_id:n.id,p_new_status:"appointment_requested",p_new_appointment_status:"requested",p_sale_stage:"appointment_requested",p_appointment_date:be,p_appointment_time:L});if($e)throw $e;console.log("[CustomerAppointmentScheduler] Triggering GHL soldAppointmentScheduled for car:",n.id);try{await Et(n.id,"soldAppointmentScheduled"),console.log("[CustomerAppointmentScheduler] GHL soldAppointmentScheduled triggered successfully")}catch(Ce){console.warn("[CustomerAppointmentScheduler] GHL trigger failed (non-blocking):",Ce)}ne(!0),W.success("Appointment request sent!"),setTimeout(()=>{E(),ne(!1),C()},2e3)}catch(be){console.error("Error scheduling appointment:",be),W.error("Failed to schedule appointment. Please try again.")}finally{ee(!1)}},Yt=()=>{w||(ne(!1),C())},mt=()=>e.jsxs("div",{className:"py-8 px-4 text-center space-y-6",children:[e.jsx("div",{className:"w-20 h-20 mx-auto rounded-full bg-gradient-to-br from-emerald-500 to-teal-600 flex items-center justify-center shadow-lg shadow-emerald-500/30 animate-scale-in",children:e.jsx(ae,{className:"h-10 w-10 text-white"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-2xl font-bold text-slate-900 dark:text-white",children:"Request Sent!"}),e.jsxs("p",{className:"text-muted-foreground max-w-xs mx-auto",children:["Your appointment request has been sent to ",e.jsx("span",{className:"font-medium text-slate-700 dark:text-slate-300",children:(_==null?void 0:_.dealership_name)||j}),". They will confirm shortly."]})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-900/50 rounded-2xl p-5 max-w-xs mx-auto border border-slate-200 dark:border-slate-800",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-emerald-100 dark:bg-emerald-900/40 flex items-center justify-center",children:e.jsx(oe,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"Date"}),e.jsx("p",{className:"font-semibold text-slate-900 dark:text-white",children:r?lt(r,"EEEE, MMMM d"):""})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-emerald-100 dark:bg-emerald-900/40 flex items-center justify-center",children:e.jsx(Ie,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"Time"}),e.jsx("p",{className:"font-semibold text-slate-900 dark:text-white",children:L})]})]})]})]}),Gt=()=>e.jsxs("form",{onSubmit:kt,className:"space-y-5 pb-safe",children:[e.jsx("div",{className:"bg-gradient-to-r from-emerald-50 to-teal-50 dark:from-emerald-950/40 dark:to-teal-950/30 rounded-xl p-4 border border-emerald-200/60 dark:border-emerald-800/40",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-emerald-500 to-teal-600 flex items-center justify-center shadow-lg shadow-emerald-500/20",children:e.jsx(ps,{className:"h-6 w-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-bold text-slate-900 dark:text-white truncate",children:[n.year," ",n.make," ",n.model]}),e.jsxs("div",{className:"text-lg font-bold text-emerald-600 dark:text-emerald-400",children:["$",D.toLocaleStr
17ing()]})]})]})}),e.jsx(ft,{winningDealer:_,displayBestAmount:D,vin:n.vin,expandable:!0}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(at,{className:"text-sm font-semibold text-slate-700 dark:text-slate-300 flex items-center gap-2",children:[e.jsx(oe,{className:"h-4 w-4 text-emerald-600"}),"Select a Date"]}),e.jsx("div",{className:"relative",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:At,disabled:!Ut,className:_e("flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center transition-all",Ut?"bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-700 dark:text-slate-300":"bg-slate-50 dark:bg-slate-900 text-slate-300 dark:text-slate-600 cursor-not-allowed"),children:e.jsx(Vs,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1 flex gap-1.5 sm:gap-2 overflow-hidden",children:Be.map(q=>{const be=Oe(q),Y=r&&ya(q,r);return e.jsxs("button",{type:"button",onClick:()=>fs(q),disabled:be,className:_e("flex-1 min-w-0 py-2.5 px-1 rounded-xl transition-all duration-200 flex flex-col items-center gap-0.5",Y?"bg-gradient-to-br from-emerald-500 to-teal-600 text-white shadow-lg shadow-emerald-500/30 scale-105":be?"bg-slate-100 dark:bg-slate-800/50 text-slate-400 dark:text-slate-600 cursor-not-allowed":"bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 hover:border-emerald-400 dark:hover:border-emerald-600 hover:shadow-md"),children:[e.jsx("span",{className:_e("text-[10px] font-medium uppercase tracking-wide",Y?"text-white/80":"text-slate-500 dark:text-slate-400"),children:lt(q,"EEE")}),e.jsx("span",{className:_e("text-lg font-bold",Y?"text-white":"text-slate-900 dark:text-white"),children:lt(q,"d")}),e.jsx("span",{className:_e("text-[9px] font-medium",Y?"text-white/70":"text-slate-400 dark:text-slate-500"),children:lt(q,"MMM")})]},q.toISOString())})}),e.jsx("button",{type:"button",onClick:gs,disabled:!wt,className:_e("flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center transition-all",wt?"bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-700 dark:text-slate-300":"bg-slate-50 dark:bg-slate-900 text-slate-300 dark:text-slate-600 cursor-not-allowed"),children:e.jsx(it,{className:"h-4 w-4"})})]})}),r&&Oe(r)&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-xl animate-fade-in",children:[e.jsx(Ba,{className:"h-4 w-4 text-amber-600 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-amber-700 dark:text-amber-400",children:"Dealership is closed. Please select another date."})]})]}),r&&!Oe(r)&&e.jsxs("div",{className:"space-y-3 animate-fade-in",children:[e.jsxs(at,{className:"text-sm font-semibold text-slate-700 dark:text-slate-300 flex items-center gap-2",children:[e.jsx(Ie,{className:"h-4 w-4 text-emerald-600"}),"Select a Time"]}),o?e.jsxs("div",{className:"flex items-center justify-center py-6 bg-slate-50 dark:bg-slate-900/50 rounded-xl",children:[e.jsx(cs,{className:"h-5 w-5 animate-spin text-emerald-600"}),e.jsx("span",{className:"ml-2 text-sm text-slate-500",children:"Loading times..."})]}):Ft.length===0?e.jsxs("div",{className:"text-center py-6 bg-slate-50 dark:bg-slate-900/50 rounded-xl",children:[e.jsx(Ie,{className:"h-8 w-8 text-slate-300 dark:text-slate-600 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-slate-500",children:"No available times for this day"})]}):e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2",children:Ft.map(q=>e.jsx("button",{type:"button",onClick:()=>K(q),className:_e("px-2 py-2.5 text-sm font-medium rounded-xl border transition-all duration-200",L===q?"bg-gradient-to-br from-emerald-500 to-teal-600 text-white border-transparent shadow-lg shadow-emerald-500/20":"bg-white dark:bg-slate-800 border-slate-200 dark:border-slate-700 hover:border-emerald-400 dark:hover:border-emerald-600 text-slate-700 dark:text-slate-300 hover:shadow-md"),children:q},q))})]}),e.jsxs("div",{className:_e("space-y-4 pt-4 border-t border-slate-200 dark:border-slate-800 transition-all",!r&&"opacity-50"),children:[e.jsxs("h4",{className:"font-semibold text-sm text-slate-700 dark:text-slate-300 flex items-center gap-2",children:[e.jsx(dt,{className:"h-4 w-4 text-emerald-600"}),"Your Contact Info"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(at,{htmlFor:"name",className:"text-xs font-medium text-slate-500 flex items-center gap-1.5",children:[e.jsx(dt,{className:"h-3 w-3"}),"Name"]}),e.jsx(Ye,{id:"name",type:"text",placeholder:"Your name",value:A,onChange:q=>z(q.target.value),className:"h-11 rounded-xl border-slate-200 dark:border-slate-700 focus:border-emerald-400"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(at,{htmlFor:"phone",className:"text-xs font-medium text-slate-500 flex items-center gap-1.5",children:[e.jsx(vt,{className:"h-3 w-3"}),"Phone"]}),e.jsx(Ye,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:X,onChange:q=>T(q.target.value),className:"h-11 rounded-xl border-slate-200 dark:border-slate-700 focus:border-emerald-400"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(at,{htmlFor:"email",className:"text-xs font-medium text-slate-500 flex items-center gap-1.5",children:[e.jsx(Bs,{className:"h-3 w-3"}),"Email"]}),e.jsx(Ye,{id:"email",type:"email",placeholder:"[email protected]",value:Q,onChange:q=>se(q.target.value),className:"h-11 rounded-xl border-slate-200 dark:border-slate-700 focus:border-emerald-400"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(at,{htmlFor:"notes",className:"text-xs font-medium text-slate-500 flex items-center gap-1.5",children:[e.jsx(Ms,{className:"h-3 w-3"}),"Notes (optional)"]}),e.jsx(Da,{id:"notes",placeholder:"Any special requests or notes...",value:he,onCh
17ange:q=>me(q.target.value),className:"min-h-[80px] rounded-xl border-slate-200 dark:border-slate-700 focus:border-emerald-400 resize-none"})]})]}),e.jsxs("div",{className:"pt-2 sticky bottom-0 bg-white dark:bg-slate-950 pb-2 -mx-4 px-4 sm:mx-0 sm:px-0 sm:static",children:[e.jsx(I,{type:"submit",disabled:w||!r||!L,size:"lg",className:_e("w-full font-bold shadow-lg h-14 rounded-xl text-base transition-all duration-300",r&&L?"bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-600 hover:to-teal-700 text-white shadow-emerald-500/30":"bg-slate-200 dark:bg-slate-800 text-slate-400 dark:text-slate-500"),children:w?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"mr-2 h-5 w-5 animate-spin"}),"Sending Request..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"mr-2 h-5 w-5"}),"Request Appointment"]})}),e.jsx("p",{className:"text-xs text-center text-muted-foreground mt-3",children:"The dealer will confirm your appointment shortly"})]})]});return ct?e.jsx(It,{open:l,onOpenChange:Yt,children:e.jsx(Bt,{className:"max-h-[95vh] px-4",children:F?mt():e.jsxs(e.Fragment,{children:[e.jsxs(Ht,{className:"pb-2 pt-4",children:[e.jsxs(zt,{className:"text-xl font-bold flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-600 flex items-center justify-center",children:e.jsx(oe,{className:"h-4 w-4 text-white"})}),"Schedule Appointment"]}),e.jsx(us,{className:"text-slate-500",children:"Pick a date and time for your vehicle pickup"})]}),e.jsx("div",{className:"overflow-y-auto overscroll-contain max-h-[calc(95vh-100px)] px-1",children:Gt()})]})})}):e.jsx(Ve,{open:l,onOpenChange:Yt,children:e.jsx(qe,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:F?mt():e.jsxs(e.Fragment,{children:[e.jsxs(Nt,{className:"pb-2",children:[e.jsxs(Ze,{className:"text-xl font-bold flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-emerald-500 to-teal-600 flex items-center justify-center shadow-lg shadow-emerald-500/20",children:e.jsx(oe,{className:"h-5 w-5 text-white"})}),"Schedule Your Appointment"]}),e.jsx($t,{className:"text-slate-500",children:"Pick a convenient date and time for vehicle pickup"})]}),Gt()]})})})},Is=l=>{const C=/^(\d{4})-(\d{2})-(\d{2})/.exec(l);return C?new Date(Number(C[1]),Number(C[2])-1,Number(C[3])):new Date(l)},$a=l=>{const C=encodeURIComponent(l);return{apple:`https://maps.apple.com/?q=${C}`,google:`https://www.google.com/maps/search/?api=1&query=${C}`}};function cl({isOpen:l,onClose:C,car:n,appointment:b,dealer:j}){const N=Rt(),P={requested:{label:"Pending Confirmation",description:"Waiting for dealer to confirm",badgeClass:"bg-amber-100 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300 border-amber-200 dark:border-amber-800",icon:Ie},waiting:{label:"Pending Confirmation",description:"Waiting for dealer to confirm",badgeClass:"bg-amber-100 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300 border-amber-200 dark:border-amber-800",icon:Ie},confirmed:{label:"Confirmed",description:"Your appointment is confirmed",badgeClass:"bg-emerald-100 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300 border-emerald-200 dark:border-emerald-800",icon:ae},completed:{label:"Completed",description:"Transaction complete",badgeClass:"bg-blue-100 text-blue-700 dark:bg-blue-950/40 dark:text-blue-300 border-blue-200 dark:border-blue-800",icon:ae}},D=P[b==null?void 0:b.status]||P.requested,d=D.icon,E=(b==null?void 0:b.date)||(b==null?void 0:b.appointment_date),r=(b==null?void 0:b.time)||(b==null?void 0:b.appointment_time),y=()=>e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"rounded-xl border border-border/50 bg-card overflow-hidden",children:[e.jsx("div",{className:"px-5 py-3 border-b border-border/30 bg-muted/30",children:e.jsx("p",{className:"text-[11px] font-medium text-primary/80 uppercase tracking-[0.15em]",children:"Vehicle Details"})}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground truncate tracking-tight",children:[n.year," ",n.make," ",n.model]}),e.jsxs("p",{className:"text-xs text-muted-foreground font-mono mt-1",children:["VIN: ",n.vin]})]}),e.jsxs("div",{className:_e("flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-medium border shrink-0",D.badgeClass),children:[e.jsx(d,{className:"h-3.5 w-3.5"}),D.label]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-border/30",children:[e.jsx("p",{className:"text-[11px] font-medium text-primary/80 uppercase tracking-[0.15em] mb-1.5",children:"Sale Price"}),e.jsxs("p",{className:"text-3xl font-semibold text-primary tracking-tight",children:["$",(n.sale_price||n.currentBid||0).toLocaleStr
17ing()]})]})]})]}),E&&e.jsxs("div",{className:"rounded-xl border border-border/50 bg-card overflow-hidden",children:[e.jsx("div",{className:"px-5 py-3 border-b border-border/30 bg-muted/30",children:e.jsx("p",{className:"text-[11px] font-medium text-primary/80 uppercase tracking-[0.15em]",children:"Appointment"})}),e.jsx("div",{className:"p-5",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"w-14 h-14 rounded-xl flex flex-col items-center justify-center bg-primary text-primary-foreground shadow-sm shrink-0",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider opacity-90",children:lt(Is(E),"MMM")}),e.jsx("span",{className:"text-xl font-bold leading-none",children:lt(Is(E),"d")})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-foreground",children:lt(Is(E),"EEEE")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:D.description}),r&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5",children:[e.jsx(Ie,{className:"h-4 w-4 text-primary/70"}),e.jsx("span",{className:"font-medium text-foreground",children:r})]})]})]})})]}),j&&e.jsxs("div",{className:"rounded-xl border border-border/50 bg-card overflow-hidden",children:[e.jsx("div",{className:"px-5 py-3 border-b border-border/30 bg-muted/30",children:e.jsx("p",{className:"text-[11px] font-medium text-primary/80 uppercase tracking-[0.15em]",children:"Dealership"})}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-5",children:[j.logo_url?e.jsx("img",{src:j.logo_url,alt:j.dealership_name||j.business_name||"",className:"w-14 h-14 rounded-xl object-contain bg-background border border-border/50 p-1.5 shadow-sm shrink-0"}):e.jsx("div",{className:"w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-primary font-light text-2xl border border-primary/20 shrink-0",children:(j.dealership_name||j.business_name||j.name||"D").charAt(0)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-foreground whitespace-normal break-words",children:j.dealership_name||j.business_name||j.name}),j.dealership_address&&e.jsxs("p",{className:"text-sm text-muted-foreground flex items-start gap-1 mt-0.5",children:[e.jsx(Re,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),e.jsx("span",{className:"line-clamp-2",children:j.dealership_address})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[j.dealership_phone&&e.jsx(I,{variant:"outline",size:"sm",className:"flex-1 h-10 rounded-xl hover:bg-primary/5 hover:border-primary/30 transition-colors",asChild:!0,children:e.jsxs("a",{href:`tel:${j.dealership_phone}`,children:[e.jsx(vt,{className:"h-4 w-4 mr-2 text-primary/70"}),"Call"]})}),j.dealership_website&&e.jsx(I,{variant:"outline",size:"sm",className:"flex-1 h-10 rounded-xl hover:bg-primary/5 hover:border-primary/30 transition-colors",asChild:!0,children:e.jsxs("a",{href:j.dealership_website.startsWith("http")?j.dealership_website:`https://${j.dealership_website}`,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ms,{className:"h-4 w-4 mr-2 text-primary/70"}),"Website"]})})]}),j.dealership_address&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(I,{size:"sm",className:"flex-1 h-10 rounded-xl bg-slate-800 hover:bg-slate-700 text-white",asChild:!0,children:e.jsxs("a",{href:$a(j.dealership_address).apple,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Wa,{className:"h-4 w-4 mr-2"}),"Apple Maps"]})}),e.jsx(I,{size:"sm",className:"flex-1 h-10 rounded-xl bg-blue-600 hover:bg-blue-700 text-white",asChild:!0,children:e.jsxs("a",{href:$a(j.dealership_address).google,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Re,{className:"h-4 w-4 mr-2"}),"Google Maps"]})})]})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-border/50 bg-card overflow-hidden",children:[e.jsx("div",{className:"px-5 py-3 border-b border-border/30 bg-muted/30",children:e.jsx("p",{className:"text-[11px] font-medium text-primary/80 uppercase tracking-[0.15em]",children:"What to Bring"})}),e.jsx("div",{className:"p-5",children:e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{icon:jt,label:"Vehicle Title"},{icon:nt,label:"Valid Photo ID"},{icon:qs,label:"All Keys & Remotes"},{icon:jt,label:"Service Records"}].map((L,K)=>e.jsxs("div",{className:"flex items-center gap-2 bg-muted/40 rounded-lg px-3 py-2.5 border border-border/30",children:[e.jsx(L.icon,{className:"h-4 w-4 text-primary/70 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:L.label})]},K))})})]}),e.jsxs("div",{className:"rounded-xl border border-border/50 bg-card overflow-hidden",children:[e.jsx("div",{className:"px-5 py-3 border-b border-border/30 bg-muted/30",children:e.jsx("p",{className:"text-[11px] font-medium text-primary/80 uppercase tracking-[0.15em]",children:"What to Expect"})}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsx("ol",{className:"space-y-3",children:["Upon arrival, the car will have a brief 30-minute inspection to confirm vehicle condition.","If the car passes inspection, sale and DMV documents will be signed and the sale completed.","The dealer will either issue a check or handle loan payoff and finalize the deal."].map((L,K)=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary border border-primary/20",children:K+1}),e.jsx("span",{className:"text-sm text-foreground leading-snug",children:L})]},K))}),e.jsxs("div",{className:"flex items-start gap-3 rounded-lg bg-primary/5 border border-primary/10 p-3",children:[e.jsx(Ge,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}
17),e.jsx("p",{className:"text-xs text-foreground/90 leading-relaxed",children:"The CarSolve Offer is guaranteed pending visual and mechanical inspection. The dealer is only allowed to negotiate for verifiably undisclosed vehicle damage or mechanical issues."})]})]})]}),e.jsx(I,{onClick:C,variant:"ghost",className:"w-full h-11 text-muted-foreground hover:text-foreground font-light tracking-wide",children:"Close"})]});return N?e.jsx(It,{open:l,onOpenChange:L=>!L&&C(),children:e.jsxs(Bt,{className:"max-h-[95vh]",children:[e.jsxs(Ht,{className:"text-left pb-2 pt-4 px-4",children:[e.jsxs(zt,{className:"text-xl font-light tracking-tight flex items-center gap-2.5",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-primary/10 flex items-center justify-center border border-primary/20",children:e.jsx(oe,{className:"h-4.5 w-4.5 text-primary"})}),"Appointment Details"]}),e.jsx(us,{className:"text-sm font-light sr-only",children:"View your appointment information"})]}),e.jsx("div",{className:"px-4 pb-6 pt-2 overflow-y-auto overscroll-contain",children:e.jsx(y,{})})]})}):e.jsx(Ve,{open:l,onOpenChange:L=>!L&&C(),children:e.jsxs(qe,{className:"sm:max-w-md p-0 overflow-hidden","aria-describedby":"appointment-details-description",children:[e.jsxs(Nt,{className:"p-5 pb-2",children:[e.jsxs(Ze,{className:"text-xl font-light tracking-tight flex items-center gap-2.5",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-primary/10 flex items-center justify-center border border-primary/20",children:e.jsx(oe,{className:"h-4.5 w-4.5 text-primary"})}),"Appointment Details"]}),e.jsx($t,{id:"appointment-details-description",className:"sr-only",children:"View your appointment information including vehicle details, dealership contact, and location."})]}),e.jsx("div",{className:"p-5 pt-2 max-h-[75vh] overflow-y-auto",children:e.jsx(y,{})})]})})}const ml=({isOpen:l,onClose:C,selectedCarId:n,viewingCustomer:b,customerId:j,isAdminViewing:N})=>e.jsx(Ve,{open:l,onOpenChange:P=>!P&&C(),children:e.jsxs(qe,{className:"max-w-2xl w-[95vw] max-h-[85vh] p-0 gap-0 overflow-hidden bg-background border-border rounded-2xl shadow-2xl",children:[e.jsx(Ze,{className:"sr-only",children:"Messages"}),e.jsx(I,{variant:"ghost",size:"icon",onClick:C,className:"absolute right-3 top-3 z-50 h-8 w-8 rounded-full bg-muted/80 hover:bg-muted",children:e.jsx(hs,{className:"h-4 w-4"})}),e.jsx(ur,{className:"h-[85vh] max-h-[85vh]",children:e.jsx("div",{className:"min-h-full",children:e.jsx(zr,{isPopup:!0,onClose:C,popupSelectedCarId:n,popupViewingCustomer:b,popupCu
17stomerId:j,popupIsAdminViewing:N})})})]})}),Se=({value:l,onChange:C,yesLabel:n="YES",noLabel:b="NO"})=>{const j=l===!0,N=l===!1;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{type:"button",onClick:()=>C(!0),className:_e("flex-1 min-h-[52px] md:min-h-[48px] rounded-xl text-sm font-bold md:font-semibold border-2 transition-all active:scale-95",j?"bg-primary text-primary-foreground border-primary shadow-lg shadow-primary/25":"bg-white md:bg-muted/50 text-foreground md:text-muted-foreground border-slate-200 md:border-border hover:border-primary/50"),children:n}),e.jsx("button",{type:"button",onClick:()=>C(!1),className:_e("flex-1 min-h-[52px] md:min-h-[48px] rounded-xl text-sm font-bold md:font-semibold border-2 transition-all active:scale-95",N?"bg-primary text-primary-foreground border-primary shadow-lg shadow-primary/25":"bg-white md:bg-muted/50 text-foreground md:text-muted-foreground border-slate-200 md:border-border hover:border-primary/50"),children:b})]})},gt=({options:l,selectedValue:C,onChange:n,columns:b=2})=>e.jsx("div",{className:_e("grid gap-2",b===2?"grid-cols-2":b===3?"grid-cols-3":"grid-cols-4"),children:l.map(j=>e.jsx("button",{type:"button",onClick:()=>n(j.value),className:_e("min-h-[52px] md:min-h-[48px] rounded-xl text-sm font-bold md:font-medium border-2 transition-all active:scale-95 px-3",(C==null?void 0:C.toLowerCase())===j.value.toLowerCase()?"bg-primary text-primary-foreground border-primary shadow-lg shadow-primary/25":"bg-white md:bg-muted/50 text-foreground md:text-muted-foreground border-slate-200 md:border-border hover:border-primary/50"),children:j.label},j.value))}),xl=({options:l,selectedValues:C,onChange:n})=>{const b=j=>{const N=C.some(P=>P.toLowerCase()===j.toLowerCase());n(N?C.filter(P=>P.toLowerCase()!==j.toLowerCase()):[...C,j])};return e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(j=>{const N=C.some(P=>P.toLowerCase()===j.value.toLowerCase());return e.jsxs("button",{type:"button",onClick:()=>b(j.value),className:_e("flex items-center gap-2 min-h-[44px] px-4 rounded-xl text-sm border-2 transition-all active:scale-95",N?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border text-muted-foreground hover:border-primary/50"),children:[e.jsx("div",{className:_e("w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors",N?"bg-primary border-primary":"border-border bg-transparent"),children:N&&e.jsx(Ts,{className:"w-3 h-3 text-primary-foreground"})}),e.jsx("span",{className:"font-medium",children:j.label})]},j.value)})})},re=({children:l,required:C=!0})=>e.jsxs("label",{className:"text-sm font-semibold md:font-medium text-muted-foreground md:text-foreground mb-2 block",children:[l,C&&e.jsx("span",{className:"text-destructive ml-1 md:inline hidden",children:"*"})]}),Ue=[{id:"basics",title:"Vehicle Basics",icon:ps,description:"Engine, fuel, transmission",subtitle:"Quick facts about the powertrain."},{id:"exterior",title:"Exterior & Interior",icon:Yr,description:"Colors and options",subtitle:"Colors, options, and modifications."},{id:"title",title:"Title & Ownership",icon:jt,description:"Title status and history",subtitle:"Ownership details and title status."},{id:"condition",title:"Condition Report",icon:gr,description:"Body and mechanical",subtitle:"Body and mechanical condition."},{id:"final",title:"Final Details",icon:qs,description:"Keys, tires, and photos",subtitle:"Keys, tires, and vehicle photos."}],Os=h.forwardRef(({car:l,onUpdate:C,onComplete:n,onCancel:b,onUploadPhotos:j,isSubmitting:N=!1},P)=>{var he,me,w,ee;const[D,d]=h.useState(0),E=l,[r,y]=h.useState({engine:E.engine||"",fuel_type:l.fuelType||"gasoline",transmission:E.transmission||"automatic",condition:l.condition||"good",reserve_price:E.reserve_price||"",color:l.color||"",interior_color:E.interior_color||"",options:l.options||[],aftermarket_modifications:E.aftermarket_modifications??!1,title_present:((he=l.titleDetails)==null?void 0:he.present)??!0,title_issues:E.title_issues??!1,title_type:E.title_type||"clean",title_owned_outright:((me=l.titleDetails)==null?void 0:me.ownedOutright)??!0,owners_count:l.ownersCount||"",has_body_damage:(l.hasDents||l.hasScrapes||l.hasDingsOrScratches)??!1,dents_description:E.dents_description||"",frame_damage:E.frame_damage??!1,rust_damage:E.rust_damage??!1,windshield_issues:E.windshield_condition==="cracked"||E.windshield_condition==="needs_replacement",interior_issues:E.interior_issues??!1,has_mechanical_issues:l.hasMechanicalIssues??!1,mechanical_description:E.mechanical_description||"",engine_issues:E.engine_issues??!1,warning_lights:E.warning_lights??!1,airbag_deployed:E.airbag_deployed??!1,is_non_runner:E.is_non_runner??!1,keys_count:l.keysCount??1,tires_condition:E.tires_condition||"90%",tires_need_replacement:l.tiresNeedReplacement??!1,buying_another_vehicle:E.buying_another_vehicle??!1}),[L,K]=h.useState(!1),A=async()=>{K(!0);try{const{error:F}=await g.from("cars").update({engine:r.engine||null,fuel_type:r.fuel_type,transmission:r.transmission,condition:r.condition,reserve_price:r.reserve_price?Number(r.reserve_price):null,color:r.color,interior_color:r.interior_color||null,options:r.options,aftermarket_modifications:r.aftermarket_modifications,title_present:r.t
17itle_present,title_issues:r.title_issues,title_type:r.title_type,title_owned_outright:r.title_owned_outright,owners_count:r.owners_count||null,has_dents:r.has_body_damage,has_scrapes:r.has_body_damage,has_dings_or_scratches:r.has_body_damage,dents_description:r.dents_description||null,frame_damage:r.frame_damage,rust_damage:r.rust_damage,windshield_condition:r.windshield_issues?"cracked":"good",interior_issues:r.interior_issues,has_mechanical_issues:r.has_mechanical_issues,mechanical_description:r.mechanical_description||null,engine_issues:r.engine_issues,warning_lights:r.warning_lights,airbag_deployed:r.airbag_deployed,is_non_runner:r.is_non_runner,keys_count:r.keys_count,tires_condition:r.tires_condition,tires_need_replacement:r.tires_need_replacement,buying_another_vehicle:r.buying_another_vehicle}).eq("id",l.id);if(F)throw F;C==null||C({...l,...r})}catch(F){throw console.error("Error saving vehicle details:",F),W.error("Failed to save vehicle details"),F}finally{K(!1)}};h.useImperativeHandle(P,()=>({save:A}));const z=()=>{D<Ue.length-1&&d(F=>F+1)},X=()=>{D>0&&d(F=>F-1)},T=(D+1)/Ue.length*100,Q=[{value:"homelink",label:"Homelink"},{value:"leather",label:"Leather"},{value:"navigation",label:"Navigation"},{value:"sunroof",label:"Sunroof"},{value:"heated_seats",label:"Heated Seats"},{value:"backup_camera",label:"Backup Camera"}],se=()=>{var F,ne;switch(D){case 0:return e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsxs("div",{children:[e.jsx(re,{required:!1,children:"Desired Selling Price"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-muted-foreground",children:"$"}),e.jsx(Ye,{type:"number",value:r.reserve_price,onChange:u=>y(k=>({...k,reserve_price:u.target.value})),className:"h-12 text-base rounded-xl pl-8",placeholder:"25,000"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This is your minimum acceptable price (optional)"})]}),e.jsxs("div",{children:[e.jsx(re,{required:!1,children:"Engine"}),e.jsx(Ye,{value:r.engine,onChange:u=>y(k=>({...k,engine:u.target.value})),className:"h-12 text-base rounded-xl",placeholder:"e.g., 2.0L Turbo 4-Cylinder"})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Fuel Type"}),e.jsx(gt,{options:[{value:"gasoline",label:"Gas"},{value:"diesel",label:"Diesel"},{value:"hybrid",label:"Hybrid"},{value:"electric",label:"EV"}],selectedValue:r.fuel_type,onChange:u=>y(k=>({...k,fuel_type:u}))})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Transmission"}),e.jsx(gt,{options:[{value:"automatic",label:"Auto"},{value:"manual",label:"Manual"},{value:"cvt",label:"CVT"}],selectedValue:r.transmission,onChange:u=>y(k=>({...k,transmission:u})),columns:3})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Overall Condition"}),e.jsx(gt,{options:[{value:"excellent",label:"Excellent"},{value:"good",label:"Good"},{value:"fair",label:"Fair"},{value:"poor",label:"Poor"}],selectedValue:r.condition,onChange:u=>y(k=>({...k,condition:u}))})]})]});case 1:return e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsxs("div",{children:[e.jsx(re,{children:"Exterior Color"}),e.jsx(Ye,{value:r.color,onChange:u=>y(k=>({...k,color:u.target.value})),className:"h-12 text-base rounded-xl",placeholder:"e.g., Silver Metallic"})]}),e.jsxs("div",{children:[e.jsx(re,{required:!1,children:"Interior Color"}),e.jsx(Ye,{value:r.interior_color,onChange:u=>y(k=>({...k,interior_color:u.target.value})),className:"h-12 text-base rounded-xl",placeholder:"e.g., Black Leather"})]}),e.jsxs("div",{children:[e.jsx(re,{required:!1,children:"Vehicle Options"}),e.jsx(xl,{options:Q,selectedValues:r.options,onChange:u=>y(k=>({...k,options:u}))})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Aftermarket Modifications?"}),e.jsx(Se,{value:r.aftermarket_modifications,onChange:u=>y(k=>({...k,aftermarket_modifications:u}))})]})]});case 2:return e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsxs("div",{children:[e.jsx(re,{children:"Do you have the title?"}),e.jsx(Se,{value:r.title_present,onChange:u=>y(k=>({...k,title_present:u}))})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Any title issues (liens, brands)?"}),e.jsx(Se,{value:r.title_issues,onChange:u=>y(k=>({...k,title_issues:u}))})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Title Type"}),e.jsx(gt,{options:[{value:"clean",label:"Clean"},{value:"salvage",label:"Salvage"},{value:"rebuilt",label:"Rebuilt"},{value:"lemon",label:"Lemon"}
17],selectedValue:r.title_type,onChange:u=>y(k=>({...k,title_type:u}))})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Is the vehicle owned outright?"}),e.jsx(Se,{value:r.title_owned_outright,onChange:u=>y(k=>({...k,title_owned_outright:u})),yesLabel:"Yes, paid off",noLabel:"No, has loan"})]}),e.jsxs("div",{children:[e.jsx(re,{required:!1,children:"Number of Previous Owners"}),e.jsx(gt,{options:[{value:"1",label:"1"},{value:"2",label:"2"},{value:"3",label:"3"},{value:"4+",label:"4+"}],selectedValue:r.owners_count,onChange:u=>y(k=>({...k,owners_count:u})),columns:4})]})]});case 3:return e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsxs("div",{children:[e.jsx(re,{children:"Any body damage (dents, scrapes, scratches)?"}),e.jsx(Se,{value:r.has_body_damage,onChange:u=>y(k=>({...k,has_body_damage:u}))}),r.has_body_damage&&e.jsx(Ye,{value:r.dents_description,onChange:u=>y(k=>({...k,dents_description:u.target.value})),className:"h-12 text-base rounded-xl mt-3",placeholder:"Describe the damage..."})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Frame damage?"}),e.jsx(Se,{value:r.frame_damage,onChange:u=>y(k=>({...k,frame_damage:u}))})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Rust damage?"}),e.jsx(Se,{value:r.rust_damage,onChange:u=>y(k=>({...k,rust_damage:u}))})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Windshield cracks or chips?"}),e.jsx(Se,{value:r.windshield_issues,onChange:u=>y(k=>({...k,windshield_issues:u}))})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Interior issues (tears, stains, damage)?"}),e.jsx(Se,{value:r.interior_issues,onChange:u=>y(k=>({...k,interior_issues:u}))})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Any mechanical issues?"}),e.jsx(Se,{value:r.has_mechanical_issues,onChange:u=>y(k=>({...k,has_mechanical_issues:u}))}),r.has_mechanical_issues&&e.jsx(Ye,{value:r.mechanical_description,onChange:u=>y(k=>({...k,mechanical_description:u.target.value})),className:"h-12 text-base rounded-xl mt-3",placeholder:"Describe the issues..."})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Engine issues?"}),e.jsx(Se,{value:r.engine_issues,onChange:u=>y(k=>({...k,engine_issues:u}))})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Warning lights on dashboard?"}),e.jsx(Se,{value:r.warning_lights,onChange:u=>y(k=>({...k,warning_lights:u}))})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Airbags deployed?"}),e.jsx(Se,{value:r.airbag_deployed,onChange:u=>y(k=>({...k,airbag_deployed:u}))})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Is the vehicle a non-runner?"}),e.jsx(Se,{value:r.is_non_runner,onChange:u=>y(k=>({...k,is_non_runner:u}))})]})]});case 4:return e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsxs("div",{children:[e.jsx(re,{children:"How many keys?"}),e.jsx(gt,{options:[{value:"0",label:"0"},{value:"1",label:"1"},{value:"2",label:"2"},{value:"3",label:"3+"}],selectedValue:String(r.keys_count),onChange:u=>y(k=>({...k,keys_count:parseInt(u)||1})),columns:4})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Tire Condition"}),e.jsx(gt,{options:[{value:"good",label:"Good"},{value:"needs_replacement",label:"Needs Replacement"}],selectedValue:r.tires_condition==="needs_replacement"||r.tires_condition==="under 50%"||r.tires_need_replacement?"needs_replacement":"good",onChange:u=>y(k=>({...k,tires_condition:u,tires_need_replacement:u==="needs_replacement"}))})]}),e.jsxs("div",{children:[e.jsx(re,{children:"Are you buying another vehicle?"}),e.jsx(Se,{value:r.buying_another_vehicle,onChange:u=>y(k=>({...k,buying_another_vehicle:u}))})]}),e.jsxs("div",{className:"space-y-4 bg-muted/50 rounded-2xl p-4 border border-border/50",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gr,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"font-semibold text-foreground",children:"Vehicle Photos"})]}),e.jsxs(Lt,{variant:"outline",className:"text-xs",children:[((F=l.images)==null?void 0:F.length)||0," uploaded"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Photos help dealers make better offers. Try to capture these angles:"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{label:"Vehicle front",view:"front"},{label:"Front left corner",view:"front-corner"},{label:"Driver side",view:"side"},{label:"Back left corner",view:"back-corner"},{label:"Vehicle rear",view:"rear"},{label:"Dashboard",view:"dashboard"},{label:"Interior seats",view:"interior"},{label:"Odometer",view:"odometer"},{label:"Any damage",view:"damage"}].map((u,k)=>e.jsxs("div",{className:"relative flex flex-col bg-muted/30 rounded-lg border border-border/50 overflow-hidden",children:[e.jsx("div",{className:"absolute top-1 right-1",children:e.jsx(Zr,{className:"w-3 h-3 text-muted-foreground
17/50"})}),e.jsxs("div",{className:"h-16 flex items-center justify-center p-2",children:[u.view==="front"&&e.jsxs("svg",{viewBox:"0 0 80 55",className:"w-full h-full text-muted-foreground/70",children:[e.jsx("path",{d:"M15 38 L15 28 L20 20 L25 14 L55 14 L60 20 L65 28 L65 38 L60 42 L20 42 L15 38 Z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),e.jsx("path",{d:"M25 20 L28 14 L52 14 L55 20 L25 20 Z",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("ellipse",{cx:"22",cy:"28",rx:"4",ry:"3",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("ellipse",{cx:"58",cy:"28",rx:"4",ry:"3",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("rect",{x:"30",y:"26",width:"20",height:"8",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("line",{x1:"35",y1:"26",x2:"35",y2:"34",stroke:"currentColor",strokeWidth:"0.5"}),e.jsx("line",{x1:"40",y1:"26",x2:"40",y2:"34",stroke:"currentColor",strokeWidth:"0.5"}),e.jsx("line",{x1:"45",y1:"26",x2:"45",y2:"34",stroke:"currentColor",strokeWidth:"0.5"}),e.jsx("ellipse",{cx:"22",cy:"42",rx:"6",ry:"2",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("ellipse",{cx:"58",cy:"42",rx:"6",ry:"2",fill:"none",stroke:"currentColor",strokeWidth:"1"})]}),u.view==="front-corner"&&e.jsxs("svg",{viewBox:"0 0 80 55",className:"w-full h-full text-muted-foreground/70",children:[e.jsx("path",{d:"M8 40 L12 32 L18 24 L28 18 L45 16 L62 18 L70 26 L72 40 Z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),e.jsx("path",{d:"M28 24 L32 18 L52 16 L56 22 L28 24 Z",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("path",{d:"M18 30 L28 24",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("ellipse",{cx:"16",cy:"34",rx:"4",ry:"2.5",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("ellipse",{cx:"22",cy:"44",rx:"8",ry:"4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("ellipse",{cx:"22",cy:"44",rx:"5",ry:"2.5",fill:"none",stroke:"currentColor",strokeWidth:"0.6"}),e.jsx("ellipse",{cx:"60",cy:"44",rx:"7",ry:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("ellipse",{cx:"60",cy:"44",rx:"4",ry:"2",fill:"none",stroke:"currentColor",strokeWidth:"0.6"}),e.jsx("path",{d:"M40 22 L42 40",stroke:"currentColor",strokeWidth:"0.6"})]}),u.view==="side"&&e.jsxs("svg",{viewBox:"0 0 80 55",className:"w-full h-full text-muted-foreground/70",children:[e.jsx("path",{d:"M5 38 L8 38 L10 30 L18 22 L30 16 L50 16 L58 22 L68 30 L72 38 L75 38",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),e.jsx("path",{d:"M22 22 L30 16 L50 16 L56 22",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("path",{d:"M24 24 L30 18 L42 18 L42 24 Z",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("path",{d:"M44 24 L44 18 L50 18 L54 24 Z",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("line",{x1:"35",y1:"28",x2:"38",y2:"28",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("line",{x1:"52",y1:"28",x2:"55",y2:"28",stroke:"currentColor",strokeWidth:"0.8"}
17),e.jsx("circle",{cx:"18",cy:"40",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("circle",{cx:"18",cy:"40",r:"5",fill:"none",stroke:"currentColor",strokeWidth:"0.6"}),e.jsx("circle",{cx:"18",cy:"40",r:"2",fill:"none",stroke:"currentColor",strokeWidth:"0.5"}),e.jsx("circle",{cx:"62",cy:"40",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("circle",{cx:"62",cy:"40",r:"5",fill:"none",stroke:"currentColor",strokeWidth:"0.6"}),e.jsx("circle",{cx:"62",cy:"40",r:"2",fill:"none",stroke:"currentColor",strokeWidth:"0.5"}),e.jsx("path",{d:"M12 34 L68 34",stroke:"currentColor",strokeWidth:"0.5"})]}),u.view==="back-corner"&&e.jsxs("svg",{viewBox:"0 0 80 55",className:"w-full h-full text-muted-foreground/70",children:[e.jsx("path",{d:"M8 40 L10 26 L18 18 L35 16 L52 18 L62 24 L68 32 L72 40 Z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),e.jsx("path",{d:"M24 22 L35 18 L50 20 L52 26 L24 26 Z",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("rect",{x:"12",y:"30",width:"6",height:"4",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("path",{d:"M15 28 L22 22",stroke:"currentColor",strokeWidth:"0.6"}),e.jsx("ellipse",{cx:"20",cy:"44",rx:"8",ry:"4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("ellipse",{cx:"20",cy:"44",rx:"5",ry:"2.5",fill:"none",stroke:"currentColor",strokeWidth:"0.6"}),e.jsx("ellipse",{cx:"58",cy:"44",rx:"7",ry:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("ellipse",{cx:"58",cy:"44",rx:"4",ry:"2",fill:"none",stroke:"currentColor",strokeWidth:"0.6"}),e.jsx("path",{d:"M42 22 L44 40",stroke:"currentColor",strokeWidth:"0.6"})]}),u.view==="rear"&&e.jsxs("svg",{viewBox:"0 0 80 55",className:"w-full h-full text-muted-foreground/70",children:[e.jsx("path",{d:"M15 38 L15 26 L20 18 L25 14 L55 14 L60 18 L65 26 L65 38 L60 42 L20 42 L15 38 Z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),e.jsx("path",{d:"M24 18 L28 14 L52 14 L56 18 L24 18 Z",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("rect",{x:"17",y:"26",width:"8",height:"5",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("rect",{x:"55",y:"26",width:"8",height:"5",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("rect",{x:"30",y:"32",width:"20",height:"6",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("path",{d:"M18 38 L62 38",stroke:"currentColor",strokeWidth:"0.6"}),e.jsx("ellipse",{cx:"22",cy:"42",rx:"6",ry:"2",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("ellipse",{cx:"58",cy:"42",rx:"6",ry:"2",fill:"none",stroke:"currentColor",strokeWidth:"1"})]}),u.view==="dashboard"&&e.jsxs("svg",{viewBox:"0 0 80 55",className:"w-full h-full text-muted-foreground/70",children:[e.jsx("rect",{x:"5",y:"10",width:"70",height:"35",rx:"3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("path",{d:"M8 10 L40 6 L72 10",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("circle",{cx:"22",cy:"28",r:"10",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("circle",{cx:"22",cy:"28",r:"6",fill:"none",stroke:"currentColor",strokeWidth:"0.5"}),e.jsx("line",{x1:"22",y1:"28",x2:"26",y2:"22",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("rect",{x:"35",y:"18",width:"18",height:"14",rx:"2",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("path",{d:"M15 42 L22 38 L28 42",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("rect",{x:"56",y:"22",width:"12",height:"4",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"0.6"}),e.jsx("rect",{x:"56",y:"30",width:"12",height:"4",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"0.6"})]}),u.view==="interior"&&e.jsxs("svg",{viewBox:"0 0 80 55",className:"w-full h-full text-muted-foreground/70",children:[e.jsx("rect",{x:"8",y:"6",width:"28",height:"42",rx:"4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("rect",{x:"44",y:"6",width:"28",height:"42",rx:"4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("rect",{x:"14",y:"8",width:"16",height:"10",rx:"3",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("rect",{x:"50",y:"8",width:"16",height:"10",rx:"3",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("path",{d:"M12 30 L32 30",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("path",{d:"M48 30 L68 30",stroke:"currentColor",strokeWidth:"0.8"}
17),e.jsx("rect",{x:"36",y:"20",width:"8",height:"24",rx:"2",fill:"none",stroke:"currentColor",strokeWidth:"0.6"})]}),u.view==="odometer"&&e.jsxs("svg",{viewBox:"0 0 80 55",className:"w-full h-full text-muted-foreground/70",children:[e.jsx("circle",{cx:"40",cy:"28",r:"22",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("circle",{cx:"40",cy:"28",r:"18",fill:"none",stroke:"currentColor",strokeWidth:"0.6"}),e.jsx("line",{x1:"40",y1:"10",x2:"40",y2:"14",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("line",{x1:"22",y1:"28",x2:"26",y2:"28",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("line",{x1:"54",y1:"28",x2:"58",y2:"28",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("line",{x1:"28",y1:"16",x2:"30",y2:"18",stroke:"currentColor",strokeWidth:"0.6"}),e.jsx("line",{x1:"52",y1:"16",x2:"50",y2:"18",stroke:"currentColor",strokeWidth:"0.6"}),e.jsx("line",{x1:"40",y1:"28",x2:"50",y2:"18",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("circle",{cx:"40",cy:"28",r:"3",fill:"none",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("rect",{x:"30",y:"36",width:"20",height:"6",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"0.6"})]}),u.view==="damage"&&e.jsxs("svg",{viewBox:"0 0 80 55",className:"w-full h-full text-muted-foreground/70",children:[e.jsx("path",{d:"M10 38 L12 30 L18 24 L28 20 L52 20 L58 24 L64 30 L68 38",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("circle",{cx:"22",cy:"40",r:"6",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("circle",{cx:"56",cy:"40",r:"6",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("circle",{cx:"40",cy:"30",r:"6",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("line",{x1:"40",y1:"22",x2:"40",y2:"26",stroke:"currentColor",strokeWidth:"1"}),e.jsx("line",{x1:"40",y1:"34",x2:"40",y2:"38",stroke:"currentColor",strokeWidth:"1"}),e.jsx("line",{x1:"32",y1:"30",x2:"36",y2:"30",stroke:"currentColor",strokeWidth:"1"}),e.jsx("line",{x1:"44",y1:"30",x2:"48",y2:"30",stroke:"currentColor",strokeWidth:"1"}),e.jsx("line",{x1:"34",y1:"24",x2:"37",y2:"27",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("line",{x1:"46",y1:"24",x2:"43",y2:"27",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("line",{x1:"34",y1:"36",x2:"37",y2:"33",stroke:"currentColor",strokeWidth:"0.8"}),e.jsx("line",{x1:"46",y1:"36",x2:"43",y2:"33",stroke:"currentColor",strokeWidth:"0.8"})]})]}),e.jsx("div",{className:"px-1.5 pb-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight block text-center",children:u.label})})]},k))}),l.images&&l.images.length>0&&e.jsxs("div",{className:"pt-2 border-t border-border/50",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Your photos:"}),e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[l.images.slice(0,4).map((u,k)=>e.jsx("img",{src:u,alt:`Vehicle photo ${k+1}`,className:"w-16 h-16 rounded-xl object-cover flex-shrink-0 border border-border"},k)),l.images.length>4&&e.jsx("div",{className:"w-16 h-16 rounded-xl bg-muted flex items-center justify-center flex-shrink-0 border border-border",children:e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",l.images.length-4]})})]})]}),e.jsxs(I,{variant:"outline",onClick:j,className:"w-full h-12 rounded-xl",children:[e.jsx(Ds,{className:"w-4 h-4 mr-2"}),(ne=l.images)!=null&&ne.length?"Add More Photos":"Upload Photos"]})]}),e.jsxs("div",{className:"space-y-3 bg-emerald-50 dark:bg-emerald-900/20 rounded-2xl p-4 border border-emerald-200 dark:border-emerald-800",children:[e.jsx("h5",{className:"font-semibold text-emerald-800 dark:text-emerald-300",children:"What happens next:"}),e.jsx("div",{className:"space-y-2",children:["Your vehicle will be listed for 72 hours","Local dealers will compete to buy your car","You can accept any offer or negotiate","No obligation to sell"].map((u,k)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-700 dark:text-emerald-400",children:[e.jsx(ae,{className:"w-4 h-4 text-emerald-500 flex-shrink-0"}),e.jsx("span",{children:u})]},k))})]})]});default:return null}};return e.jsxs("div",{className:"flex flex-col h-full min-h-0 p-3 sm:p-6 md:p-8",children:[e.jsxs("div",{className:"flex-shrink-0 pb-4 md:border-b md:border-border",children:[e.jsxs("div",{className:"hidden md:flex gap-3 mb-4",children:[(w=l.images)!=null&&w[0]?e.jsx("img",{src:l.images[0],alt:`${l.year} ${l.make} ${l.model}`,className:"w-20 h-14 object-cover rounded-xl"}):e.jsx("div",{className:"w-20 h-14 bg-muted rounded-xl flex items-center justify-center",children:e.jsx(ps,{className:"w-6 h-6 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h4",{className:"font-bold text-foreground truncate",children:[l.year," ",l.make," ",l.model]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(ee=l.mileage)==null?void 0:ee.toLocaleStr
17ing()," miles • ",l.color]})]})]}),e.jsxs("div",{className:"hidden md:block space-y-2",children:[e.jsx(Ur,{value:T,className:"h-2"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[Vt.createElement(Ue[D].icon,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:Ue[D].title})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Step ",D+1," of ",Ue.length]})]})]}),e.jsxs("div",{className:"md:hidden",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-xs font-bold tracking-[0.15em] text-slate-500 uppercase",children:["Step ",D+1," of ",Ue.length]}),e.jsxs("span",{className:"text-sm font-bold text-emerald-600",children:[Math.round(T),"%"]})]}),e.jsx("div",{className:"h-1.5 w-full rounded-full bg-slate-200 overflow-hidden",children:e.jsx("div",{className:"h-full bg-emerald-500 rounded-full transition-all duration-500",style:{width:`${T}%`}})}),e.jsx("h2",{className:"mt-5 text-[28px] leading-tight font-extrabold text-slate-900 tracking-tight",children:Ue[D].title}),e.jsx("p",{className:"mt-1 text-[15px] text-slate-500",children:Ue[D].subtitle})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-4 min-h-0 overscroll-contain scrollbar-hide",children:e.jsx("div",{className:"px-4",children:se()})}),e.jsx("div",{className:"flex-shrink-0 pt-4 border-t border-border bg-background",children:e.jsxs("div",{className:"flex gap-3",children:[D===0?e.jsx(I,{variant:"outline",onClick:b,className:"flex-1 h-12 rounded-xl",disabled:N,children:"Cancel"}):e.jsxs(I,{variant:"outline",onClick:X,className:"flex-1 h-12 rounded-xl gap-1",disabled:N,children:[e.jsx(Vs,{className:"w-4 h-4"}),"Back"]}),D<Ue.length-1?e.jsxs(I,{onClick:z,className:"flex-1 h-12 rounded-xl bg-primary gap-1",children:["Next",e.jsx(it,{className:"w-4 h-4"})]}):e.jsx(I,{onClick:n,disabled:N,className:"flex-1 h-12 rounded-xl bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 text-white",children:N?"Submitting...":"Submit for Review"})]})})]})});Os.displayName="StartSaleWizard";const hl=({carId:l,customerId:C,customerName:n,customerEmail:b,variant:j="standalone"})=>{const[N,P]=h.useState(!1),[D,d]=h.useState([]),[E,r]=h.useState(!1),[y,L]=h.useState([]),[K,A]=h.useState(""),[z,X]=h.useState(!1),[T,Q]=h.useState(!1);h.useEffect(()=>{N&&D.length===0&&se()},[N]);const se=async()=>{try{r(!0);const{data:w,error:ee}=await g.from("dealerships").select("id, name, logo_url, address, description, website").eq("show_on_trade_in",!0).order("name");if(ee)throw ee;const F=(w||[]).sort((ne,u)=>{const k=pe=>{const B=(pe.address||"").toUpperCase();return B.includes(", WA")||B.includes(", OR")?0:1},o=k(ne),ve=k(u);return o!==ve?o-ve:ne.name.localeCompare(u.name)}
17);d(F)}catch(w){console.error("Error fetching dealerships:",w)}finally{r(!1)}},he=w=>{L(ee=>ee.includes(w)?ee.filter(F=>F!==w):[...ee,w])},me=async()=>{if(y.length===0){W.error("Please select at least one dealership.");return}try{X(!0);const w=y.map(F=>({car_id:l,customer_id:C,customer_name:n||null,customer_email:b||null,dealership_id:F,notes:K.trim()||null,status:"pending"})),{error:ee}=await g.from("dealer_offer_requests").insert(w);if(ee)throw ee;Q(!0),W.success("Your offer request has been submitted! Our team will follow up with you shortly."),L([]),A("")}catch(w){console.error("Error submitting offer request:",w),W.error("Failed to submit your request. Please try again.")}finally{X(!1)}};return e.jsx(Ws,{open:N,onOpenChange:P,children:e.jsxs("div",{className:j==="connected"?"bg-white dark:bg-gray-900":"bg-white dark:bg-gray-900 rounded-xl shadow-sm border border-slate-200 dark:border-gray-800",children:[e.jsx(Ps,{className:j==="connected"?"w-full p-4 md:p-6 bg-gradient-to-r from-amber-50 to-white dark:from-amber-950/10 dark:to-transparent":"w-full p-4 md:p-6 border-b border-slate-100 dark:border-gray-800 bg-gradient-to-r from-amber-50 to-white dark:from-amber-950/10 dark:to-transparent rounded-t-xl",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center",children:e.jsx(fr,{className:"w-4 h-4 text-amber-600 dark:text-amber-400"})}),e.jsx("h2",{className:"text-lg md:text-xl font-bold text-slate-800 dark:text-white",children:"Offer Request"}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-400",children:"New"})]}),N?e.jsx(ns,{className:"w-5 h-5 text-slate-400"}):e.jsx(bt,{className:"w-5 h-5 text-slate-400"})]})}),e.jsx(Es,{children:e.jsxs("div",{className:"p-4 md:p-6 space-y-5",children:[e.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/20 border border-amber-100 dark:border-amber-900/30 rounded-xl p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-100 dark:bg-amber-900/40 flex items-center justify-center shrink-0 mt-0.5",children:e.jsx(As,{className:"w-4 h-4 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-slate-800 dark:text-white mb-1",children:"Want an offer from a specific dealership partner?"}),e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400 leading-relaxed",children:"Review the list of our Top 5 star dealer partners and select the preferred dealer you would like to receive an offer from!"})]})]})}),T?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-100 dark:bg-emerald-900/30 flex items-center justify-center",children:e.jsx(ae,{className:"w-7 h-7 text-emerald-600 dark:text-emerald-400"})}),e.jsx("p",{className:"text-base font-semibold text-slate-800 dark:text-white",children:"Request Submitted!"}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 text-center max-w-xs",children:"Our team will reach out to your selected dealerships and follow up with you shortly."}),e.jsx(I,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>Q(!1),children:"Submit Another Request"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(at,{className:"text-sm font-semibold text-slate-700 dark:text-slate-300 mb-3 block",children:"Select dealership(s):"}),E?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(cs,{className:"h-5 w-5 animate-spin text-primary"}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Loading dealerships..."})]}):D.length===0?e.jsx("div",{className:"text-center py-6 text-sm text-slate-500 dark:text-slate-400",children:"No partner dealerships available at this time."}):e.jsx("div",{className:"space-y-3",children:D.map(w=>{const ee=y.includes(w.id);return e.jsxs("div",{onClick:()=>he(w.id),className:`w-full rounded-xl border-2 transition-all cursor-pointer ${ee?"border-amber-400 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-500":"border-slate-200 dark:border-gray-700 hover:border-amber-300 dark:hover:border-amber-600 bg-white dark:bg-gray-900"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 pb-2",children:[e.jsx(Qr,{checked:ee,className:"shrink-0",onCheckedChange:()=>he(w.id)}),w.logo_url?e.jsx("img",{src:w.logo_url,alt:w.name,className:"w-14 h-14 roun
17ded-lg object-contain bg-white border border-slate-100 dark:border-gray-700 p-1 shrink-0"}):e.jsx("div",{className:"w-14 h-14 rounded-lg bg-gradient-to-br from-amber-500 to-orange-500 flex items-center justify-center text-white font-bold text-lg shrink-0",children:w.name.charAt(0)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-bold text-slate-800 dark:text-white leading-tight",children:w.name}),e.jsxs("div",{className:"flex items-center gap-0.5 mt-1",children:[[...Array(5)].map((F,ne)=>e.jsx(As,{className:"w-3 h-3 fill-amber-400 text-amber-400"},ne)),e.jsx("span",{className:"text-xs text-amber-600 dark:text-amber-400 ml-1 font-medium",children:"5-Star Partner"})]})]})]}),(w.address||w.website)&&e.jsxs("div",{className:"px-3 pb-3 flex flex-col gap-2 border-t border-slate-100 dark:border-gray-800 pt-2.5 mt-0.5",onClick:F=>F.stopPropagation(),children:[w.address&&e.jsxs("a",{href:`https://maps.google.com/?q=${encodeURIComponent(w.address)}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-start gap-1.5 text-xs text-slate-500 dark:text-slate-400 hover:text-amber-600 dark:hover:text-amber-400 transition-colors",children:[e.jsx(Re,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{className:"leading-relaxed",children:w.address})]}),w.website&&e.jsxs("a",{href:w.website.startsWith("http")?w.website:`https://${w.website}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full px-3 py-2 rounded-lg bg-amber-500 hover:bg-amber-600 text-white text-xs font-semibold transition-colors",children:[e.jsx(Oa,{className:"w-3.5 h-3.5 shrink-0"}),"Visit Dealer Website",e.jsx(ms,{className:"w-3 h-3 shrink-0"})]})]})]},w.id)})})]}),e.jsxs("div",{children:[e.jsxs(at,{className:"text-sm font-semibold text-slate-700 dark:text-slate-300 mb-2 block",children:["Additional notes ",e.jsx("span",{className:"font-normal text-slate-400",children:"(optional)"})]}),e.jsx(Da,{placeholder:"Any specific preferences or questions for the dealership...",value:K,onChange:w=>A(w.target.value),className:"resize-none h-20"})]}),e.jsx(I,{className:"w-full gap-2",onClick:me,disabled:z||y.length===0,children:z?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 animate-spin"}),"Submitting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(br,{className:"w-4 h-4"}),"Submit Offer Request",y.length>0&&` (${y.length} dealer${y.length>1?"s":""})`]})})]})]})})]})})},pl=l=>{const[C,n]=h.useState(()=>Date.now());if(h.useEffect(()=>{const d=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(d)},[]),!l)return{hrs:18,min:43,sec:14};const b=new Date(l).getTime()+24*60*60*1e3,j=Math.max(0,b-C),N=Math.floor(j/36e5),P=Math.floor(j%36e5/6e4),D=Math.floor(j%6e4/1e3);return{hrs:N,min:P,sec:D}},ul=l=>l.toString().padStart(2,"0"),st=[{id:1,title:"2020 Subaru WRX",price:20200,delta:3200,review:{name:"Verified Seller",quote:"Way over what the first dealer offered."}},{id:2,title:"2018 Ford F-150",price:23750,delta:3150,review:{name:"Verified Seller",quote:"Multiple dealers bid it up fast."}},{id:3,title:"2017 Toyota Corolla",price:12e3,delta:2500,review:{name:"Verified Seller",quote:"Sold same day, no haggling."}},{id:4,title:"2020 Jeep Wrangler Unlimited",price:25500,delta:2e3,review:{name:"Verified Seller",quote:"Got top dollar without lifting a finger."}}],gl=({car:l,realOffers:C,displayBestAmount:n,bidderCount:b,endTime:j,winningDealer:N,onAcceptBest:P,onCounter:D,onAskQuestion:d,onOpenVehicleInfo:E,onWalkAway:r,onSelectOffer:y})=>{const{hrs:L,min:K,sec:A}=pl(j),z=h.useMemo(()=>{const _=l.images&&l.images.length>0?l.images:[];return l.coverPhoto&&_.includes(l.coverPhoto)?[l.coverPhoto,..._.filter(U=>U!==l.coverPhoto)]:_},[l.images,l.coverPhoto]),[X,T]=h.useState(!1),[Q,se]=h.useState(0),he=()=>se(_=>z.length?(_+1)%z.length:0),me=h.useMemo(()=>[...C].sort((_,U)=>U.amount-_.amount),[C]),[w,ee]=h.useState(!1),F=w?me:me.slice(0,3),ne=Vt.useRef(null),[u,k]=h.useState(0),o=()=>{const _=ne.current;if(!_)return;const we=Math.round(_.scrollLeft/158);k(Math.max(0,Math.min(st.length-1,we)))},ve=_=>{const U=ne.current;if(!U)return;const we=158,He=Math.max(0,Math.min(st.length-1,_));U.scrollTo({left:He*we,behavior:"smooth"})},pe=l.vin||"";pe&&pe.slice(-9);const B="#0b2545";return e.jsxs("div",{className:"min-h-screen bg-[#f6f4f1]",children:[e.jsx("div",{className:"bg-slate-950 px-4 pt-6 pb-0",children:e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsxs("div",{className:"pt-4 pb-6 text-center flex flex-col items-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-7 h-7 rounded-full bg-emerald-500 shadow-md shrink-0",children:e.jsx(Ts,{className:"w-4 h-4 text-white",strokeWidth:3})}),e.jsx("h1",{className:"text-2xl font-serif font-bold text-white drop-shadow-md",style:{fontFamily:"Georgia, serif"},children:"Auction Complete!"})]}),e.jsx("p",{className:"text-sm text-white/90 max-w-xs mx-auto leading-snug drop-shadow mt-2",children:"Dealers competed and the strongest offer has been selected for you."})]}),e.jsxs("div",{className:"relative rounded-t-2xl shadow-xl shadow-black/20 overflow-hidden max-md:border max-md:border-white",children:[z[Q]&&e.jsx("div",{className:"w-full aspect-[16/10] overflow-hidden bg-[#0b2545]",children:e.jsx("img",{src:z[Q],alt:`${l.year} ${l.make} ${l.model}`,className:"w-full h-full object-cover"})}),X&&z.length>
171&&e.jsx("button",{onClick:he,"aria-label":"Next photo",className:"absolute bottom-3 right-3 h-9 w-9 rounded-full bg-black/55 hover:bg-black/70 backdrop-blur-sm text-white flex items-center justify-center shadow-lg transition-colors",children:e.jsx(it,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"md:hidden",children:e.jsxs("div",{className:"bg-white rounded-2xl max-md:rounded-none shadow-xl shadow-slate-900/5 overflow-hidden max-md:border-x max-md:border-white",children:[e.jsxs("div",{className:"p-5 max-md:pb-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("h2",{className:"text-[16px] font-bold leading-[1.2]",style:{color:"#0a2e2e"},children:[l.year," ",l.make," ",l.model]}),e.jsx("button",{onClick:()=>T(_=>!_),"aria-expanded":X,className:"shrink-0 px-3.5 py-1.5 rounded-full bg-white border border-slate-300 text-[10px] font-bold tracking-[0.18em] uppercase text-slate-700 hover:bg-slate-50 transition-colors",children:X?"Hide Info":"Vehicle Info"})]}),(l.trim||l.mileage)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:[l.trim?`${l.trim} · `:"",l.mileage?`${l.mileage.toLocaleString()} mi`:""]}),pe&&e.jsxs("p",{className:"text-[11px] text-muted-foreground/70 mt-1.5 font-mono tracking-wide",children:["VIN ",pe]})]}),e.jsx("div",{className:`grid transition-all duration-500 ease-out ${X?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"}`,children:e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"px-5 pb-5",children:e.jsxs("div",{className:"bg-background border border-border rounded-xl p-3 space-y-2",children:[(()=>{const _=[["Year",l.year],["Make",l.make],["Model",l.model],["Trim",l.trim],["Mileage",l.mileage?`${l.mileage.toLocaleString()} mi`:null],["Transmission",l.transmission],["Drivetrain",l.drivetrain],["Engine",l.engine],["Color",l.color],["Fuel",l.fuelType],["VIN",l.vin],["Title",l.titleStatus||"Clean"],["Condition",l.condition]].filter(([,U])=>U);return e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-0",children:_.map(([U,we])=>e.jsxs("div",{className:"flex items-center justify-between gap-2 py-1 border-b border-border last:border-b-0 sm:[&:nth-last-child(-n+2)]:border-b-0",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground",children:U}),e.jsx("span",{className:"text-xs font-bold text-foreground text-right truncate",children:we})]},U))})})(),(()=>{const _=xs(l.description);return _?e.jsxs("div",{className:"pt-2 border-t border-border",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground mb-1",children:"Description"}),e.jsx("p",{className:"text-xs text-foreground leading-relaxed",children:_})]}):null})(),e.jsx("div",{className:"flex justify-center",children:e.jsx("button",{onClick:()=>T(!1),className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full bg-background border border-border text-muted-foreground text-[11px] font-medium hover:bg-muted transition-colors",children:"Hide Vehicle Info"})})]})})})})]})})]})}),e.jsx("div",{className:"px-4 pt-0 pb-12 max-w-md mx-auto",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white rounded-2xl max-md:rounded-t-none shadow-xl shadow-slate-900/5 overflow-hidden mt-4 max-md:mt-0",children:[e.jsxs("div",{className:"px-5 pt-4 pb-2 text-center",children:[e.jsx("p",{className:"text-[11px] font-bold tracking-[0.25em] text-slate-500 uppercase",children:"Your Best Offer"}),e.jsxs("p",{className:"text-5xl font-extrabold mt-1",style:{color:B},children:["$",n.toLocaleString()]}),b>0&&e.jsxs("div",{className:"inline-flex items-center gap-1.5 mt-2 px-3 py-1 bg-emerald-50 text-emerald-700 rounded-full text-xs font-semibold",children:[e.jsx(Ta,{className:"w-3.5 h-3.5"}),"Top offer from ",b," active bidder",b===1?"":"s"]})]}),e.jsx("div",{className:"px-5",children:e.jsx(ft,{winningDealer:N,offers:me,displayBestAmount:n,bidderCount:b,vin:l.vin})}),e.jsx("div",{className:"px-5 mt-4",children:e.jsx("div",{className:"border-t border-slate-200"})}),e.jsxs("div",{className:"px-5 pt-4 text-center",children:[e.jsx("p",{className:"text-[11px] font-bold tracking-[0.25em] text-slate-500 uppercase mb-3",children:"Offer Expires In"}),e.jsx("div",{className:"flex items-center justify-center gap-3",children:[{v:L,l:"HRS"},{v:K,l:"MIN"},{v:A,l:"SEC"}
17].map((_,U)=>e.jsxs(Vt.Fragment,{children:[e.jsxs("div",{className:"w-16 h-16 rounded-2xl bg-slate-100 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-2xl font-extrabold leading-none",style:{color:B},children:ul(_.v)}),e.jsx("span",{className:"text-[9px] font-bold text-slate-500 tracking-widest mt-1",children:_.l})]}),U<2&&e.jsx("span",{className:"text-2xl font-bold text-slate-300",children:":"})]},_.l))})]}),e.jsxs("div",{className:"px-5 pt-5",children:[e.jsxs("button",{onClick:P,className:"w-full h-14 rounded-full bg-emerald-600 hover:bg-emerald-700 active:scale-[0.99] transition-all text-white font-bold text-base flex items-center justify-center gap-2 shadow-lg shadow-emerald-600/30",children:[e.jsx(os,{className:"w-4 h-4"}),"Accept $",n.toLocaleString()]}),e.jsx("p",{className:"text-[11px] text-slate-500 text-center mt-2",children:"Tap to lock · Reversible for 60 seconds"})]}),e.jsxs("div",{className:"px-5 pt-3 pb-4 flex items-center justify-center gap-4 text-[11px] font-semibold text-slate-600",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ge,{className:"w-3.5 h-3.5 text-emerald-600"}),"Verified dealer"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ge,{className:"w-3.5 h-3.5 text-emerald-600"}),"Secure transaction"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qt,{className:"w-3.5 h-3.5 text-emerald-600"}),"Offer guaranteed pending inspection"]})]}),e.jsxs("div",{className:"px-5 pb-5 grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:D,className:"h-11 rounded-full border border-emerald-600 text-emerald-700 font-semibold text-sm flex items-center justify-center gap-1.5 hover:bg-emerald-50",children:[e.jsx(jr,{className:"w-4 h-4"}),"Counter Offer"]}),e.jsxs("button",{onClick:d,className:"h-11 rounded-full border border-blue-600 text-blue-700 font-semibold text-sm flex items-center justify-center gap-1.5 hover:bg-blue-50",children:[e.jsx(Nr,{className:"w-4 h-4"}),"Ask a Question"]})]}),e.jsx("div",{className:"px-5 pb-5 text-center",children:e.jsx("button",{onClick:r,className:"text-blue-600 text-sm font-semibold hover:underline",children:"Walk away"})})]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl shadow-slate-900/5 p-5",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-bold tracking-[0.25em] text-slate-500 uppercase",children:"Direct Offers"}),e.jsx("h3",{className:"text-xl font-extrabold mt-0.5",style:{color:B},children:"From dealers"})]}),me.length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-blue-50 text-blue-700 text-xs font-semibold",children:[e.jsx(Ge,{className:"w-3.5 h-3.5"}),me.length," verified"]})]}),me.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-slate-300 bg-slate-50/60 p-5 text-center",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700",children:"No direct offers yet"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Verified dealer offers will appear here as they come in."})]}):e.jsxs("div",{className:"space-y-2.5",children:[F.map(_=>{const U=_.paymentTypes&&_.paymentTypes.length>0?_.paymentTypes.map(ot=>({ach:"ACH Transfer",check:"Check",wire:"Wire Transfer",cash:"Cash",cashiers_check:"Cashier's Check"})[ot.toLowerCase()]||ot).join(", "):null,we=_.pickupOptions&&_.pickupOptions.length>0?_.pickupOptions.includes("pickup")?"Buyer picks up":_.pickupOptions.includes("delivery")?"Delivery offered":_.pickupOptions.join(", "):null,He=_.timestamp?new Date(new Date(_.timestamp).getTime()+7*24*60*60*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric"}):null;return e.jsx("button",{onClick:()=>y==null?void 0:y(_.id),className:"w-full p-4 rounded-xl border border-slate-200 hover:border-emerald-400 hover:bg-emerald-50/30 transition-all text-left",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"shrink-0 w-12 h-12 rounded-lg bg-white border border-slate-200 overflow-hidden flex items-center justify-center",children:_.dealerLogo?e.jsx("img",{src:_.dealerLogo,alt:`${_.dealerName} logo`,className:"w-full h-full object-contain p-1"}):_.dealerName?e.jsx("span",{className:"text-lg font-bold text-slate-500",children:_.dealerName.charAt(0)}):e.jsx(Ma,{className:"w-6 h-6 text-slate-400"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"font-bold text-sm leading-tight break-words",style:{color:B},children:_.dealerName||"Verified Dealer"}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs("span",{className:"text-lg font-extrabold leading-none",style:{color:B}
17,children:["$",_.amount.toLocaleString()]}),e.jsx(it,{className:"w-4 h-4 text-slate-400"})]})]}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-x-3 gap-y-1 text-[10px] text-slate-500",children:[U&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nt,{className:"w-3 h-3"}),U]}),we&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(qt,{className:"w-3 h-3"}),we]}),He&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(oe,{className:"w-3 h-3"}),"Close ",He]})]})]})]})},_.id)}),me.length>3&&e.jsx("button",{onClick:()=>ee(_=>!_),className:"w-full mt-4 h-11 rounded-full border border-slate-300 font-bold text-xs tracking-[0.2em] text-slate-700 hover:bg-slate-50",children:w?"SHOW LESS":"VIEW ALL OFFERS"})]})]})]})}),e.jsx("div",{className:"bg-white px-4 py-4 pb-12",children:e.jsx("div",{className:"max-w-md mx-auto",children:e.jsxs("div",{className:"rounded-2xl p-3 relative overflow-hidden",style:{background:"linear-gradient(180deg, #e8f5ee 0%, #f3faf6 100%)"},children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 mb-2",children:[e.jsx(el,{className:"w-3.5 h-3.5 text-emerald-700"}),e.jsx("p",{className:"text-[10px] font-bold tracking-[0.2em] text-emerald-800 uppercase",children:"Top Wins · Last 30 Days"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>ve(u-1),disabled:u===0,className:"absolute left-0 top-1/2 -translate-y-1/2 -translate-x-1 z-10 w-7 h-7 rounded-full bg-white shadow-md flex items-center justify-center text-emerald-700 disabled:opacity-30 disabled:cursor-not-allowed active:scale-95 transition-all","aria-label":"Previous seller win",children:e.jsx(Vs,{className:"w-3.5 h-3.5"})}),e.jsx("div",{ref:ne,onScroll:o,className:"flex gap-2 overflow-x-auto scrollbar-hide pb-1 -mx-1 px-1 snap-x snap-mandatory scroll-smooth",children:st.map((_,U)=>e.jsxs("div",{className:`flex-shrink-0 w-[150px] bg-white rounded-xl p-2.5 shadow-sm snap-center transition-opacity ${U===u?"opacity-100":"opacity-60"}`,children:[e.jsx("p",{className:"text-xs font-bold text-center leading-tight min-h-[2rem] flex items-center justify-center",style:{color:B},children:_.title}),e.jsx("p",{className:"text-[9px] font-bold tracking-wider text-slate-500 text-center mt-1",children:"SOLD FOR"}),e.jsxs("p",{className:"text-lg font-extrabold text-center leading-tight",style:{color:B},children:["$",_.price.toLocaleString()]}),e.jsxs("div",{className:"mt-1.5 mx-auto inline-flex w-full justify-center px-2 py-0.5 rounded-full bg-emerald-100 text-emerald-700 text-[9px] font-bold",children:["+$",_.delta.toLocaleString()," over start"]})]},_.id))}),e.jsx("button",{onClick:()=>ve(u+1),disabled:u===st.length-1,className:"absolute right-0 top-1/2 -translate-y-1/2 translate-x-1 z-10 w-7 h-7 rounded-full bg-white shadow-md flex items-center justify-center text-emerald-700 disabled:opacity-30 disabled:cursor-not-allowed active:scale-95 transition-all","aria-label":"Next seller win",children:e.jsx(it,{className:"w-3.5 h-3.5"})})]}),e.jsx("div",{className:"flex justify-center gap-1 mt-1.5 mb-1.5",children:st.map((_,U)=>e.jsx("span",{className:`h-1 rounded-full transition-all ${U===u?"w-3 bg-emerald-600":"w-1 bg-emerald-200"}`},U))}),e.jsxs("div",{className:"mt-1.5 bg-white rounded-lg p-2.5 shadow-sm animate-fade-in",children:[e.jsx("div",{className:"flex gap-0.5 mb-0.5",children:[0,1,2,3,4].map(_=>e.jsx(As,{className:"w-3 h-3 fill-amber-400 text-amber-400"},_))}),e.jsx("p",{className:"text-[11px] font-bold",style:{color:B},children:st[u].review.name}),e.jsxs("p",{className:"text-[11px] text-slate-700 italic mt-0.5 leading-snug",children:['"',st[u].review.quote,'"']})]},st[u].id)]})})})]})},Ia=()=>["sunday","monday","tuesday","wednesday","thursday","friday","saturday"][new Date().getDay()],fl=()=>{const{isDarkMode:l,toggleTheme:C}=Lr();return e.jsxs("button",{onClick:C,className:"flex items-center gap-0.5 rounded-full border border-slate-200 dark:border-gray-700 bg-slate-100 dark:bg-gray-800 p-0.5 shadow-sm","aria-label":"Toggle light/dark mode",children:[e.jsxs("span",{className:`flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-semibold transition-all duration-200 ${l?"text-slate-400 dark:text-gray-500":"bg-white text-slate-800 shadow-sm"}`,children:[e.jsx($r,{className:"w-3 h-3"}),"Light"]}),e.jsxs("span",{className:`flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-semibold transition-all duration-200 ${l?"bg-gray-700 text-white shadow-sm":"text-slate-400"}`,children:[e.jsx(Ir,{className:"w-3 h-3"}),"Dark"]}
17)]})},Bd=()=>{var Js,ea,ta,sa,aa,ra,la,da,ia,na,oa,ca,ma,ss,xa,as,ha,pa,ua,ga,fa,ba,ja;const{user:l}=vr(),C=wr(),n=kr(),{customerId:b}=yr(),j=_r(),N=(j==null?void 0:j.selectedVehicleId)||null,[P,D]=h.useState([]),[d,E]=h.useState(!0),[r,y]=h.useState(null),[L,K]=h.useState([]),[A,z]=h.useState([]),[X,T]=h.useState(!1),[Q,se]=h.useState(!1),[he,me]=h.useState(!1),[w,ee]=h.useState("my-cars"),[F,ne]=h.useState(null),[u,k]=h.useState(null),[o,ve]=h.useState(null),[pe,B]=h.useState(!1),[_,U]=h.useState([]),[we,He]=h.useState(!1),[ot,Mt]=h.useState(!1),[ct,Be]=h.useState(!1),[Ft,Oe]=h.useState(!1),[Ut,wt]=h.useState(!1),[At,gs]=h.useState(!1),[fs,kt]=h.useState(!1),[Yt,mt]=h.useState(!1),[Gt,q]=h.useState(!1),[be,Y]=h.useState(!1),[ke,Te]=h.useState(null),[Me,ze]=h.useState(!0),[$e,Ce]=h.useState({}),[x,Xe]=h.useState(null),[Zt,Xt]=h.useState(!1),[Pa,Rs]=h.useState(!1),[Ea,bs]=h.useState(!1),[js,Ns]=h.useState(!1),[Hs,Va]=h.useState(!1),[zs,Ke]=h.useState(!1),[Fs,Kt]=h.useState(!1),[qa,Ra]=h.useState(!1),[Ha,za]=h.useState(()=>Date.now());h.useEffect(()=>{const s=setInterval(()=>za(Date.now()),1e3);return()=>clearInterval(s)},[]),h.useState({tiresNeedReplacement:!1,keysCount:1,hasDents:!1,dentsDescription:"",hasScrapes:!1,scrapesDescription:"",windshieldCondition:"good",hasMechanicalIssues:!1,mechanicalDescription:""});const[te,vs]=h.useState(null),[le,Qt]=h.useState(null),[m,Fa]=h.useState(null),[ue,Le]=h.useState(null),[yt,Ua]=h.useState(null),We=Rt(),[bl,Ya]=h.useState(()=>typeof window<"u"?window.innerWidth<1024:!1);h.useEffect(()=>{const s=window.matchMedia("(max-width: 1023px)"),a=()=>Ya(window.innerWidth<1024);return s.addEventListener("change",a),a(),()=>s.removeEventListener("change",a)},[]),h.useEffect(()=>{Ns(!We)},[We]);const ws=h.useRef(!1),Us=h.useRef(null),Ys=h.useRef([]),Qe=(Js=n.state)==null?void 0:Js.carData,ks=new URLSearchParams(n.search),Gs=ks.get("preview")==="true",Jt=((ea=n.state)==null?void 0:ea.fromAdmin)||ks.get("adminView")==="1"||Gs,ys=((ta=n.state)==null?void 0:ta.selectedCarId)||ks.get("carId")||void 0,xt=!Gs&&Sr(l==null?void 0:l.role)&&b;h.useEffect(()=>{l&&l.role!=="customer"&&!Jt&&!xt&&C("/")},[l,C,Jt,xt]);const Je=s=>{let a=s.images||[];const i=s.cover_photo;return i&&a.includes(i)&&(a=[i,...a.filter(c=>c!==i)]),{id:s.id,make:s.make,model:s.model,year:s.year,mileage:s.mileage,vin:s.vin,color:s.color,condition:s.condition,description:s.description,images:a,coverPhoto:i,features:s.features||[],options:s.options||[],startingBid:s.starting_bid,currentBid:s.current_bid,bidCount:s.bid_count||0,endTime:s.end_time,status:s.status,highBidderId:s.high_bidder_id,highBidderName:s.high_bidder_name,seller:{id:s.seller_id,name:s.seller_name},counterOffer:s.counter_offer,last_customer_counter:s.last_customer_counter,reservePrice:s.reserve_price,reserveMet:s.reserve_met||!1,sale_price:s.sale_price,fuelType:s.fuel_type,titleDetails:{present:s.title_present,type:s.title_type||"Clean",inSellerPossession:s.title_in_seller_possession,ownedOutright:s.title_owned_outright},generalDamage:s.general_damage,keysCount:s.keys_count||1,tiresCondition:s.tires_condition,engine:s.engine,transmission:s.transmission,appointmentDate:s.appointment_date,appointmentTime:s.appointment_time,appointmentStatus:s.appointment_status,customerName:s.customer_name,customerEmail:s.customer_email,customerPhone:s.customer_phone,marketValueLow:s.market_value_low,marketValueHigh:s.market_value_high,marketValueOptimal:s.market_value_optimal,trim:s.trim,customerDisplayBid:s.customer_display_bid,customerDisplayBidDealerId:s.customer_display_bid_dealer_id,customerDisplayBidDealerName:s.customer_display_bid_dealer_name,customerDisplayOffer:s.customer_display_offer,customerDisplayOfferDealerId:s.customer_display_offer_dealer_id,customerDisplayOfferDealerName:s.customer_display_offer_dealer_name,useCustomCustomerDisplay:s.use_custom_customer_display,clearCarMid:s.clear_car_mid,clearCarLow:s.clear_car_low,clearCarHigh:s.clear_car_high,suggestedSellingPrice:s.suggested_selling_price,sale_stage:s.sale_stage,tiresGood:s.tires_good,tiresNeedReplacement:s.tires_need_replacement,hasDamage:s.has_damage,damageDescription:s.damage_description,hasDents:s.has_dents,dentsDescription:s.dents_description,hasDingsOrScratches:s.has_dings_or_scratches,dingsDescription:s.dings_description,hasScrapes:s.has_scrapes,scrapesDescription:s.scrapes_description,hasMechanicalIssues:s.has_mechanical_issues,mechanicalDescription:s.mechanical_description,carfaxClean:s.carfax_clean,carfaxIssueDescription:s.carfax_issue_description,carfaxReports:s.carfax_reports,ownersCount:s.owners_count,titleInHand:s.title_in_hand,titleStatus:s.title_status,windshieldCondition:s.windshield_condition,interiorIssues:s.interior_issues,interiorIssueDescription:s.interior_issue_description,engineIssues:s.engine_issues,warningLights:s.warning_lights,paintDamage:s.paint_damage,paintDamageDescription:s.paint_damage_description,bumperDamage:s.bumper_damage,bumperDamageDescription:s.bumper_damage_description,cosmeticCondition:s.cosmetic_condition,cosmeticDescription:s.dings_description,mechanicalCondition:s.mechanical_condition,mechanicalConditionDescription:s.mechanical_description}};h.useEffect(()=>{(async()=>{E(!0);try{if(Jt&&Qe)D([Qe]),y(Qe),await Pe(Qe.id,Qe.vin,Qe.highBidderId||Qe.high_bi
17dder_id);else if(ys){const{data:a,error:i}=await g.from("cars").select("*").eq("id",ys).single();if(i)console.error("Error loading vehicle:",i),W.error("Failed to load vehicle data");else if(a){const c=Je(a);D([c]),y(c),await Pe(a.id,a.vin,a.high_bidder_id)}}else if(xt&&b){const{data:a,error:i}=await g.from("users").select("id, name, email").eq("id",b).single();if(i)console.error("Error loading customer:",i),W.error("Failed to load customer data");else if(a){k(a);const{data:c,error:p}=await g.from("cars").select("*").eq("seller_id",b).order("created_at",{ascending:!1});if(p)console.error("Error loading customer cars:",p),W.error("Failed to load customer vehicles");else if(c&&c.length>0){const f=c.map(Je);D(f),y(f[0]),await Pe(c[0].id,c[0].vin,c[0].high_bidder_id)}}}else{const{data:a,error:i}=await g.from("cars").select("*").eq("customer_email",l==null?void 0:l.email).order("created_at",{ascending:!1});if(i)console.error("Error loading user cars:",i),W.error("Failed to load your vehicles");else if(a&&a.length>0){const c=a.map(Je);D(c);const p=N&&c.find($=>$.id===N)||c[0];y(p);const f=a.find($=>$.id===p.id)||a[0];await Pe(f.id,f.vin,f.high_bidder_id)}}}catch(a){console.error("Error loading vehicle data:",a),W.error("Failed to load vehicle data")}finally{E(!1)}})()},[Jt,Qe,ys,l==null?void 0:l.email,xt,b,N]),h.useEffect(()=>{(async()=>{try{const{data:a}=await g.from("auction_settings").select("setting_value").eq("setting_key","instant_cash_offer_dealers").maybeSingle();if(a!=null&&a.setting_value){const c=a.setting_value.dealers||[];if(c.length>0){const{data:p}=await g.from("dealerships").select("id, name").eq("id",c[0]).maybeSingle();p&&Ua({id:p.id,name:p.name})}}}catch(a){console.error("Error fetching instant cash offer dealer:",a)}})()},[]),h.useEffect(()=>{if(!(r!=null&&r.id))return;const s=g.channel(`car-updates-${r.id}`).on("postgres_changes",{event:"UPDATE",schema:"public",table:"cars",filter:`id=eq.${r.id}`},a=>{const i=Je(a.new);y(i),D(c=>c.map(p=>p.id===i.id?i:p)),W.success("Price updated!",{duration:2e3})}).subscribe();return()=>{g.removeChannel(s)}},[r==null?void 0:r.id]),h.useEffect(()=>{if(!(r!=null&&r.id))return;const s=g.channel(`bids-${r.id}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"bids",filter:`car_id=eq.${r.id}`},a=>{z(i=>[a.new,...i]),W.success("New bid placed!",{duration:2e3})}).subscribe();return()=>{g.removeChannel(s)}},[r==null?void 0:r.id]),h.useEffect(()=>{if(!(r!=null&&r.id))return;const s=g.channel(`appointment-updates-${r.id}`).on("postgres_changes",{event:"*",schema:"public",table:"appointments",filter:`car_id=eq.${r.id}`},a=>{var i;if(a.eventType==="UPDATE"||a.eventType==="INSERT"){const c=String(((i=a.new)==null?void 0:i.status)||"").toLowerCase();ve(["cancelled","canceled","no_sale","declined","rejected"].includes(c)?null:a.new),a.new.status==="confirmed"&&W.success("Your appointment has been confirmed!",{duration:4e3})}}).subscribe();return()=>{g.removeChannel(s)}},[r==null?void 0:r.id]),h.useEffect(()=>{if(!(r!=null&&r.id)||!(r!=null&&r.vin))return;const s=g.channel(`direct-offers-${r.id}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"direct_offers",filter:`vehicle_id=eq.${r.id}`},async a=>{console.log("New direct offer received:",a.new);const i=a.new;let c=null,p=null,f=null,$=null,S=null;const{data:R}=await g.from("dealership_users").select("dealership_id").eq("user_id",i.dealer_id).maybeSingle();if(R!=null&&R.dealership_id){const{data:O}=await g.from("dealerships").select("name, logo_url, address, website, phone").eq("id",R.dealership_id).maybeSingle();c=(O==null?void 0:O.name)||null,p=(O==null?void 0:O.logo_url)||null,f=(O==null?void 0:O.address)||null,$=(O==null?void 0:O.website)||null,S=(O==null?void 0:O.phone)||null}if(!c){const{data:O}=await g.from("dealership_profiles").select("dealership_name, logo_url, address, website, phone").eq("dealer_id",i.dealer_id).maybeSingle();c=(O==null?void 0:O.dealership_name)||null,p=(O==null?void 0:O.logo_url)||null,f=(O==null?void 0:O.address)||null,$=(O==null?void 0:O.website)||null,S=(O==null?void 0:O.phone)||null}const M={id:i.id,dealerName:c||i.dealer_name,dealerId:i.dealer_id,dealerLogo:p,dealerAddress:f,dealerWebsite:$,dealerPhone:S,amount:i.offer_amount,message:i.offer_message,status:i.status,expiresAt:i.expires_at,createdAt:i.created_at};K(O=>[M,...O]),W.success(`New offer received: $${i.offer_amount.toLocaleStr
17ing()}!`,{duration:4e3})}).on("postgres_changes",{event:"UPDATE",schema:"public",table:"direct_offers",filter:`vehicle_id=eq.${r.id}`},a=>{console.log("Direct offer updated:",a.new);const i=a.new;K(c=>c.map(p=>p.id===i.id?{...p,status:i.status,amount:i.offer_amount}:p))}).subscribe();return()=>{g.removeChannel(s)}},[r==null?void 0:r.id,r==null?void 0:r.vin]),h.useEffect(()=>{if(!(l!=null&&l.email))return;const s=g.channel(`trade-in-requests-${l.email}`).on("postgres_changes",{event:"UPDATE",schema:"public",table:"trade_in_requests",filter:`customer_email=eq.${l.email}`},async a=>{console.log("Trade-in request updated:",a.new);const i=a.new;if(i.status==="quoted"&&i.quote_amount){const{data:c}=await g.from("dealerships").select("name, logo_url, address, website, phone").eq("id",i.dealership_id).maybeSingle(),p={id:i.id,dealerName:(c==null?void 0:c.name)||"Dealership",dealerId:i.dealership_id,dealerLogo:c==null?void 0:c.logo_url,dealerAddress:c==null?void 0:c.address,dealerWebsite:c==null?void 0:c.website,dealerPhone:c==null?void 0:c.phone,amount:i.quote_amount,message:i.dealer_notes,timestamp:i.dealer_responded_at,type:"trade_in",status:"active",vehicleInfo:`${i.year} ${i.make} ${i.model}`,isTradeIn:!0};K(f=>{const $=f.filter(S=>S.id!==i.id);return[p,...$]}),W.success(`New trade-in quote received: $${i.quote_amount.toLocaleString()}!`,{duration:4e3})}}).subscribe();return()=>{g.removeChannel(s)}},[l==null?void 0:l.id]),h.useEffect(()=>{if(!(r!=null&&r.id))return;const s=g.channel(`counter-offers-${r.id}`).on("postgres_changes",{event:"*",schema:"public",table:"counter_offers",filter:`vehicle_id=eq.${r.id}`},async a=>{if(console.log("Counter offer update:",a),await es(r.id),a.eventType==="INSERT"||a.eventType==="UPDATE"){const i=a.new;i.counter_bid_amount&&W.info(`Dealer has countered with $${i.counter_bid_amount.toLocaleString()}!`,{duration:5e3})}}).subscribe();return()=>{g.removeChannel(s)}},[r==null?void 0:r.id]),h.useEffect(()=>{if(!(r!=null&&r.id))return;const s=g.channel(`customer-counter-offers-${r.id}`).on("postgres_changes",{event:"*",schema:"public",table:"customer_counter_offers",filter:`vehicle_id=eq.${r.id}`},async a=>{var i;if(console.log("Customer counter offer update:",a),await es(r.id),a.eventType==="INSERT"){const c=a.new;W.success(`Your counter offer of $${(i=c.counter_amount)==null?void 0:i.toLocaleString()} has been submitted!`,{duration:4e3})}}).subscribe();return()=>{g.removeChannel(s)}},[r==null?void 0:r.id]),h.useEffect(()=>{if(!(r!=null&&r.id))return;const s=g.channel(`cars-offers-${r.id}`).on("postgres_changes",{event:"UPDATE",schema:"public",table:"cars",filter:`id=eq.${r.id}`},async a=>{const i=a.new,c=a.old;(i.current_bid!==(c==null?void 0:c.current_bid)||i.high_bidder_id!==(c==null?void 0:c.high_bidder_id)||i.customer_display_bid!==(c==null?void 0:c.customer_display_bid)||i.customer_display_offer!==(c==null?void 0:c.customer_display_offer)||i.counter_offer!==(c==null?void 0:c.counter_offer)||i.status!==(c==null?void 0:c.status))&&(console.log("Car offer-related fields or status updated:",i),y(p=>p&&{...p,status:i.status}),D(p=>p.map(f=>f.id===i.id?{...f,status:i.status}:f)),r.vin&&await Pe(r.id,r.vin,i.high_bidder_id),i.status!==(c==null?void 0:c.status)&&i.status==="dealer_counter"&&(console.log("Status changed to dealer_counter, reloading counter offer history"),await es(r.id)))}).subscribe();return()=>{g.removeChannel(s)}},[r==null?void 0:r.id,r==null?void 0:r.vin]);const es=async s=>{try{const{data:a,error:i}=await g.from("counter_offers").select("counter_bid_amount, created_at, dealer_id, status").eq("vehicle_id",s).order("created_at",{ascending:!1}).limit(1);if(!i&&a&&a.length>0){const f=a[0];let $=null,S=null;const{data:R}=await g.from("dealership_users").select("dealership_id").eq("user_id",f.dealer_id).maybeSingle();if(R!=null&&R.dealership_id){const{data:M}=await g.from("dealerships").select("name, logo_url").eq("id",R.dealership_id).maybeSingle();$=(M==null?void 0:M.name)||null,S=(M==null?void 0:M.logo_url)||null}if(!$){const{data:M}=await g.from("dealership_profiles").select("dealership_name, logo_url").eq("dealer_id",f.dealer_id).maybeSingle();$=(M==null?void 0:M.dealership_name)||null,S=(M==null?void 0:M.logo_url)||null}vs({amount:f.counter_bid_amount,timestamp:f.created_at,dealerName:$,dealerLogo:S}
17)}else{const{data:f}=await g.from("cars").select("counter_offer, high_bidder_id, high_bidder_name, updated_at").eq("id",s).maybeSingle();if(f!=null&&f.counter_offer){let $=f.high_bidder_name,S=null;if(f.high_bidder_id){const{data:R}=await g.from("dealership_users").select("dealership_id").eq("user_id",f.high_bidder_id).maybeSingle();if(R!=null&&R.dealership_id){const{data:M}=await g.from("dealerships").select("name, logo_url").eq("id",R.dealership_id).maybeSingle();$=(M==null?void 0:M.name)||$,S=(M==null?void 0:M.logo_url)||null}if(!S){const{data:M}=await g.from("dealership_profiles").select("dealership_name, logo_url").eq("dealer_id",f.high_bidder_id).maybeSingle();$=$||(M==null?void 0:M.dealership_name)||null,S=(M==null?void 0:M.logo_url)||null}}vs({amount:f.counter_offer,timestamp:f.updated_at||new Date().toISOString(),dealerName:$,dealerLogo:S})}else vs(null)}const{data:c,error:p}=await g.from("customer_counter_offers").select("counter_amount, created_at").eq("vehicle_id",s).order("created_at",{ascending:!1}).limit(1);if(!p&&c&&c.length>0)Qt({amount:c[0].counter_amount,timestamp:c[0].created_at});else{const{data:f}=await g.from("cars").select("last_customer_counter, updated_at").eq("id",s).single();f!=null&&f.last_customer_counter?Qt({amount:f.last_customer_counter,timestamp:f.updated_at||new Date().toISOString()}):Qt(null)}}catch(a){console.error("Error loading counter offer history:",a)}},Pe=async(s,a,i)=>{var c;try{const p=await Cr(s);z(p||[]);const f=[...new Set((p||[]).map(Z=>Z.dealership_id).filter(Boolean))];if(f.length>0){const Z={},{data:Ee}=await g.from("dealerships").select("id, logo_url").in("id",f);(Ee||[]).forEach(ce=>{ce.logo_url&&(Z[ce.id]=ce.logo_url)});const Ae=f.filter(ce=>!Z[ce]);if(Ae.length>0){const{data:ce}=await g.from("dealership_profiles").select("dealer_id, logo_url").in("dealer_id",Ae);(ce||[]).forEach(De=>{De.logo_url&&(Z[De.dealer_id]=De.logo_url)})}Ce(Z)}await es(s);const{data:$,error:S}=await g.from("appointments").select("*").eq("car_id",s).order("created_at",{ascending:!1}).limit(1).maybeSingle();!S&&$&&!["cancelled","canceled","no_sale","declined","rejected"].includes(String($.status||"").toLowerCase())?ve($):ve(null);const M=async(Z,Ee)=>{const{data:Ae}=await g.from("users").select("id, name, email, phone, business_name, business_phone, business_address").eq("id",Z).single();if(!Ae)return null;let ce=null,De=null,St=null,et=null,Ct=null,Tt=null,ls=null,ut=null;const Wt=async ie=>{if(!ie)return;const G=ie[Ia()];if(G){const{data:fe}=await g.from("users").select("name, email, phone").eq("id",G).maybeSingle();fe&&(Tt=fe.name,ls=fe.phone,ut=fe.email)}};if(Ee){const{data:ie}=await g.from("dealerships").select("name, logo_url, address, website, phone, preferred_contacts").eq("id",Ee).maybeSingle();ie&&(ce=ie.name,De=ie.logo_url,St=ie.address,et=ie.website,Ct=ie.phone,await Wt(ie.preferred_contacts))}if(!ce){const{data:ie}=await g.from("dealership_users").select("dealership_id").eq("user_id",Z).limit(1),G=ie==null?void 0:ie[0];if(G!=null&&G.dealership_id){const{data:fe}=await g.from("dealerships").select("name, logo_url, address, website, phone, preferred_contacts").eq("id",G.dealership_id).maybeSingle();fe&&(ce=fe.name,De=fe.logo_url,St=fe.address,et=fe.website,Ct=fe.phone,await Wt(fe.preferred_contacts))}}if(!ce){const{data:ie}=await g.from("dealership_profiles").select("dealership_name, logo_url, address, website, phone, preferred_contacts").eq("dealer_id",Z).maybeSingle();ie&&(ce=ie.dealership_name,De=ie.logo_url,St=ie.address,et=ie.website,Ct=ie.phone,await Wt(ie.preferred_contacts))}return{...Ae,dealership_name:ce||Ae.business_name,logo_url:De,dealership_address:St||Ae.business_address,dealership_website:et,dealership_phone:Ct||Ae.business_phone,preferred_contact_name:Tt,preferred_contact_phone:ls,preferred_contact_email:ut}};let O=($==null?void 0:$.dealer_id)||($==null?void 0:$.high_bidder_id),H=$==null?void 0:$.dealership_id;if(!O){const{data:Z}=await g.from("direct_offers").select("dealer_id, dealership_id").eq("vin",a).eq("status","accepted").order("created_at",{ascending:!1}).limit(1).maybeSingle();Z!=null&&Z.dealer_id&&(O=Z.dealer_id,H=H||Z.dealership_id)}if(O||(O=i),!H&&O){const{data:Z}=await g.from("bids").select("dealership_id").eq("car_id",s).eq("user_id",O).not("dealership_id","is",null).order("amount",{ascending:!1}).limit(1);(c=Z==null?void 0:Z[0])!=null&&c.dealership_id&&(H=Z[0].dealership_id)}if(O){const Z=await M(O,H);console.log("[winningDealer] resolved:",{effectiveDealerId:O,effectiveDealershipId:H,dayOfWeek:Ia(),dealership_name:Z==null?void 0:Z.dealership_name,preferred_contact_name:Z==null?void 0:Z.preferred_contact_name,preferred_contact_phone:Z==null?void 0:Z.preferred_contact_phone}),Z&&Fa(Z)}const{data:Ne,error:pt}=await g.from("direct_offers").select("*").eq("vin",a).order("created_at",{ascending:!1});if(pt)console.error("Error loading direct offers:",pt);else{const Z=[...new Set((Ne||[]).map(G=>G.dealer_id))],{data:Ee}=await g.from("dealership_users").select("user_id, dealership_id").in("user_id",Z),Ae=[...new Set((Ee||[]).map(G=>G.dealership_id))],{data:ce}=await g.from("dealerships").select("id, name, logo_url, address, website, phone, payment_types, pickup_options").in("id",Ae),De=new Map;
17(Ee||[]).forEach(G=>{const fe=De.get(G.user_id)||[];fe.push(G.dealership_id),De.set(G.user_id,fe)});const St=new Map((ce==null?void 0:ce.map(G=>[G.id,G]))||[]),{data:et}=await g.from("dealership_profiles").select("dealer_id, logo_url, dealership_name, address, website, phone, payment_types, pickup_options").in("dealer_id",Z),Ct=new Map((et==null?void 0:et.map(G=>[G.dealer_id,G]))||[]),Tt=(Ne||[]).map(G=>{const ds=(De.get(G.dealer_id)||[]).map(Ls=>St.get(Ls)).filter(Boolean),ye=(G.dealer_name||"").trim().toLowerCase(),V=ds.find(Ls=>(Ls.name||"").trim().toLowerCase()===ye)||ds[0]||null,xe=Ct.get(G.dealer_id),Na=(V==null?void 0:V.name)||(xe==null?void 0:xe.dealership_name)||G.dealer_name,va=(V==null?void 0:V.logo_url)||(xe==null?void 0:xe.logo_url),or=(V==null?void 0:V.address)||(xe==null?void 0:xe.address),cr=(V==null?void 0:V.website)||(xe==null?void 0:xe.website),mr=(V==null?void 0:V.phone)||(xe==null?void 0:xe.phone),xr=(V==null?void 0:V.payment_types)||(xe==null?void 0:xe.payment_types)||[],hr=(V==null?void 0:V.pickup_options)||(xe==null?void 0:xe.pickup_options)||[];return console.log("Offer from:",Na,"Logo:",va),{id:G.id,dealerName:Na,dealerId:G.dealer_id,dealershipId:G.dealership_id||(V==null?void 0:V.id)||null,dealerLogo:va,dealerAddress:or,dealerWebsite:cr,dealerPhone:mr,paymentTypes:xr,pickupOptions:hr,amount:G.offer_amount,message:G.offer_message,timestamp:G.created_at,type:"direct",status:G.status==="pending"?"active":G.status,vehicleId:G.vehicle_id,expiresAt:G.expires_at}});console.log("Mapped offers with dealership info:",Tt);const ls=(r==null?void 0:r.customerEmail)||(l==null?void 0:l.email),{data:ut,error:Wt}=await g.from("trade_in_requests").select(`
18            id,
19            quote_amount,
20            dealer_notes,
21            dealer_responded_at,
22            status,
23            year,
24            make,
25            model,
26            dealership_id,
27            customer_email
28          `).eq("customer_email",ls).eq("status","quoted").order("dealer_responded_at",{ascending:!1});let ie=[];if(!Wt&&ut&&ut.length>0){const G=[...new Set(ut.map(ye=>ye.dealership_id))],{data:fe}=await g.from("dealerships").select("id, name, logo_url, address, website, phone, payment_types, pickup_options").in("id",G),ds=new Map((fe==null?void 0:fe.map(ye=>[ye.id,ye]))||[]);ie=ut.map(ye=>{const V=ds.get(ye.dealership_id);return{id:ye.id,dealerName:(V==null?void 0:V.name)||"Dealership",dealerId:ye.dealership_id,dealershipId:ye.dealership_id,dealerLogo:V==null?void 0:V.logo_url,dealerAddress:V==null?void 0:V.address,dealerWebsite:V==null?void 0:V.website,dealerPhone:V==null?void 0:V.phone,paymentTypes:(V==null?void 0:V.payment_types)||[],pickupOptions:(V==null?void 0:V.pickup_options)||[],amount:ye.quote_amount,message:ye.dealer_notes,timestamp:ye.dealer_responded_at,type:"trade_in",status:"active",vehicleInfo:`${ye.year} ${ye.make} ${ye.model}`,isTradeIn:!0}})}K([...Tt,...ie])}const rs=g.channel("customer-direct-offers").on("postgres_changes",{event:"*",schema:"public",table:"direct_offers",filter:`vin=eq.${a}`},()=>{Pe(s,a)}).subscribe();return()=>{g.removeChannel(rs)}}catch(p){console.error("Error loading bids and offers:",p)}},Ga=async s=>{if(!t)return;const a=L.find(i=>i.id===s);if(!a){W.error("Offer not found");return}Le({type:"offer",amount:a.amount,dealerId:a.dealerId,dealerName:a.dealerName,acceptedOfferId:a.id,dealershipId:a.dealershipId||null}),Be(!0)},Za=async s=>{try{const{error:a}=await g.rpc("update_direct_offer_status",{p_offer_id:s,p_status:"declined"});a?(console.error("Error declining offer:",a),W.error("Failed to decline offer")):(W.success("Offer declined"),r&&await Pe(r.id,r.vin))}catch(a){console.error("Error declining offer:",a),W.error("Failed to decline offer")}},_s=async s=>{const a=s.dealership_name||s.dealershipName||"Dealership",i=A.filter(S=>s.dealership_id&&S.dealership_id===s.dealership_id||!s.dealership_id&&(S.dealership_name||S.dealershipName)===a),c=i.length,p=i.reduce((S,R)=>Math.max(S,R.amount||0),0),f=i.reduce((S,R)=>!S||new Date(R.timestamp)<new Date(S)?R.timestamp:S,null),$=i.reduce((S,R)=>!S||new Date(R.timestamp)>new Date(S)?R.timestamp:S,null);if(Xe({name:a,logo:s.dealership_id?$e[s.dealership_id]:null,amount:s.amount,timestamp:s.timestamp,totalBids:c,highestBid:p,firstBidTime:f,lastBidTime:$,address:null,phone:null,website:null,paymentTypes:null,pickupOptions:null,titleInHandPayment:null,loanPayoffOptions:null}),Xt(!0),!!s.dealership_id){Rs(!0);try{let S={};const{data:R}=await g.from("dealerships").select("name, logo_url, address, phone, website, payment_types, pickup_options, title_in_hand_payment, loan_payoff_options").eq("id",s.dealership_id).maybeSingle();if(R)S={name:R.name,logo:R.logo_url,address:R.address,phone:R.phone,website:R.website,paymentTypes:R.payment_types,pickupOptions:R.pickup_options,titleInHandPayment:R.title_in_hand_payment,loanPayoffOptions:R.loan_payoff_options};else{const{data:M}=await g.from("dealership_profiles").select("dealership_name, logo_url, dealership_address, phone, website, payment_types, pickup_options, title_in_hand_payment, loan_payoff_options").eq("dealer_id",s.dealership_id).maybeSingle();M&&(S={name:M.dealership_name,logo:M.logo_url,address:M.dealership_address,phone:M.p
28hone,website:M.website,paymentTypes:M.payment_types,pickupOptions:M.pickup_options,titleInHandPayment:M.title_in_hand_payment,loanPayoffOptions:M.loan_payoff_options})}Xe(M=>M&&{...M,name:S.name||M.name,logo:S.logo||M.logo,address:S.address||null,phone:S.phone||null,website:S.website||null,paymentTypes:S.paymentTypes||null,pickupOptions:S.pickupOptions||null,titleInHandPayment:S.titleInHandPayment||null,loanPayoffOptions:S.loanPayoffOptions||null})}catch(S){console.error("Error loading dealership details for bid:",S)}finally{Rs(!1)}}},_t=async()=>{if(!t)return;const s=t.useCustomCustomerDisplay&&t.customerDisplayOfferDealerId?t.customerDisplayOfferDealerId:v==null?void 0:v.dealerId,a=je||(v==null?void 0:v.dealerName)||"Dealer";s&&(Le({type:"offer",amount:ge,dealerId:s,dealerName:a,acceptedOfferId:v==null?void 0:v.id,dealershipId:(v==null?void 0:v.dealershipId)||null}),Be(!0))},Dt=async()=>{if(!t)return;let s=null,a=null,i=null;try{const{data:S}=await g.from("cars").select("current_bid, high_bidder_id, high_bidder_name").eq("id",t.id).maybeSingle();S&&(s=typeof S.current_bid=="number"?S.current_bid:null,a=S.high_bidder_id||null,i=S.high_bidder_name||null)}catch(S){console.warn("Could not refresh live bid before accept:",S)}const c=!!(t.useCustomCustomerDisplay&&t.customerDisplayBidDealerId),p=c?t.customerDisplayBidDealerId:a||t.highBidderId,f=c?ts||t.highBidderName||"Winning Bidder":i||ts||t.highBidderName||"Winning Bidder",$=s??de;p&&(s!==null&&s!==de&&W.info(`The winning bid updated to $${s.toLocaleString()}. Please review and confirm.`),Le({type:"bid",amount:$,dealerId:p,dealerName:f}),Be(!0))},Xa=async()=>{var s,a;if(!(!t||!ue))try{if(ue.type==="offer"){const H=ue.acceptedOfferId||(v==null?void 0:v.id);if(!H){W.error("Unable to identify the accepted offer. Please contact support.");return}const{error:Ne}=await g.rpc("update_direct_offer_status",{p_offer_id:H,p_status:"accepted"});if(Ne)throw Ne}let i=null,c=null,p=null;try{const{data:H}=await g.from("cars").select("current_bid, high_bidder_id, high_bidder_name").eq("id",t.id).maybeSingle();H&&(i=typeof H.current_bid=="number"?H.current_bid:null,c=H.high_bidder_id||null,p=H.high_bidder_name||null)}catch(H){console.warn("Could not re-verify car before accept:",H)}const f=ue.type==="bid";if(f&&i!==null&&i!==ue.amount){Le(H=>H&&{...H,amount:i,dealerId:c||H.dealerId,dealerName:p||H.dealerName}),W.warning(`The winning bid is now $${i.toLocaleString()}. Please confirm the updated amount.`);return}const $=c||t.highBidderId||t.high_bidder_id||((s=t.highBidder)==null?void 0:s.id)||(A.length>0?(a=A[0])==null?void 0:a.user_id:null),S=f?i??ue.amount:ue.amount,R=f&&p||ue.dealerName;if(!$){console.error("Cannot accept offer: No valid high bidder ID found",{activeCar:t,realBidsCount:A.length}),W.error("Unable to identify the winning bidder. Please contact support.");return}const{error:M}=await g.rpc("update_car_appointment_status",{p_car_id:t.id,p_new_status:"sold_waiting",p_new_appointment_status:"waiting",p_sale_stage:"accepted_pending_appointment",p_sale_price:S,p_high_bidder_id:$,p_high_bidder_name:R});if(M)throw M;try{await Et(t.id,"soldWaitingAppointment")}catch(H){console.warn("[GHL] soldWaitingAppointment trigger failed (non-blocking):",H)}try{await g.functions.invoke("dealer-notification-orchestrator",{body:{event_type:"offer_accepted",car_id:t.id}})}catch(H){console.warn("[Make.com] offer_accepted trigger failed (non-blocking):",H)}try{await g.functions.invoke("admin-notification-orchestrator",{body:{event_type:"admin_car_sold",car_id:t.id}})}catch(H){console.warn("[Make.com] admin_car_sold trigger failed (non-blocking):",H)}const O={status:"sold_waiting",sale_stage:"accepted_pending_appointment",sale_price:S,high_bidder_id:$,highBidderName:R};r&&r.id===t.id&&y(H=>H?{...H,...O}:null),D(H=>H.map(Ne=>Ne.id===t.id?{...Ne,...O}:Ne)),ws.current=!0,Be(!1),Oe(!0),setTimeout(()=>{ws.current=!1},0)}catch(i){console.error("Error accepting offer:",i),W.error("Failed to accept offer. Please try again.")}},Ka=async()=>{Oe(!1),me(!0),t&&await Pe(t.id,t.vin)},Qa=async s=>{if(t)try{const{data:a,error:i}=await g.rpc("submit_counter_offer",{p_vehicle_id:t.id,p_counter_amount:s,p_recipient_type:"dealer"});if(i)throw i;if(a&&!a.success){a.error_code==="EXCEEDS_RESERVE"?W.error(a.error):W.error(a.error||"Failed to submit c
28ounter offer");return}Qt({amount:s,timestamp:new Date().toISOString()}),W.success(`Counter offer of $${s.toLocaleString()} has been submitted.`);try{console.log("[GHL] Customer counter offer - triggering sellerCounterOffer for car:",t.id),await Et(t.id,"sellerCounterOffer")}catch(c){console.warn("[GHL] sellerCounterOffer trigger failed (non-blocking):",c)}T(!1),t&&await Pe(t.id,t.vin)}catch(a){console.error("Error submitting counter offer:",a),W.error("Failed to submit counter offer. Please try again.")}},Zs=async()=>{if(!t||!te)return;const s=t.highBidderId,a=te.dealerName||t.highBidderName||"Dealer";if(!s){W.error("Unable to identify the dealer");return}Le({type:"bid",amount:te.amount,dealerId:s,dealerName:a}),Be(!0)},Xs=()=>{T(!0)};h.useRef(null);const Ot=h.useRef(null),Ja=s=>{if(s.target.files){const a=Array.from(s.target.files),i=10*1024*1024,c=100*1024*1024,p=[],f=[];a.forEach($=>{const S=$.type.startsWith("video/"),R=S?c:i;if($.size>R){const M=($.size/1048576).toFixed(1),O=S?"100":"10";f.push(`${$.name} (${M}MB exceeds ${O}MB limit)`)}else p.push($)}),f.length>0&&W.error(`Files too large: ${f.join(", ")}`),p.length>0&&U($=>[...$,...p])}},er=s=>{U(a=>a.filter((i,c)=>c!==s))},tr=async()=>{if(!t||_.length===0)return;const s=10*1024*1024,a=100*1024*1024,i=_.filter(c=>{const f=c.type.startsWith("video/")?a:s;return c.size>f});if(i.length>0){const c=i.map(p=>{const f=(p.size/1048576).toFixed(1),S=p.type.startsWith("video/")?"100":"10";return`${p.name} (${f}MB, limit: ${S}MB)`}).join(", ");W.error(`Some files are too large: ${c}`);return}He(!0);try{const{convertHeicIfNeeded:c,isHeicFile:p}=await wa(async()=>{const{convertHeicIfNeeded:H,isHeicFile:Ne}=await import("./heicConvert-DY3Boxu8.js");return{convertHeicIfNeeded:H,isHeicFile:Ne}},__vite__mapDeps([0,1,2])),f=[];for(const H of _){let Ne=H;if(p(H))try{Ne=await c(H)}catch(ce){console.error("HEIC conversion failed:",ce),W.error(ce instanceof Error?ce.message:"HEIC conversion failed");continue}const pt=Ne.name.split(".").pop(),rs=`${t.id}/${Date.now()}-${Math.random().toString(36).substring(7)}.${pt}`,{data:Z,error:Ee}=await g.storage.from("vehicle-media").upload(rs,Ne,{contentType:Ne.type});if(Ee)throw Ee;const{data:{publicUrl:Ae}}=g.storage.from("vehicle-media").getPublicUrl(rs);f.push(Ae)}const S=[...t.images||[],...f],{data:R,error:M}=await g.rpc("update_car_images",{p_car_id:t.id,p_images:S});if(M)throw M;W.success(`Successfully uploaded ${_.length} file(s)!`),U([]),B(!1);const{data:O}=await g.from("cars").select("*").eq("id",t.id).single();if(O){const H=Je(O);y(H),D(Ne=>Ne.map(pt=>pt.id===H.id?H:pt))}}catch(c){console.error("Error uploading media:",c),W.error("Failed to upload media. Please try again.")}finally{He(!1)}};if(h.useEffect(()=>{var $;const s=r||P[0],a=s!=null&&s.coverPhoto&&(($=s==null?void 0:s.images)!=null&&$.includes(s.coverPhoto))?[s.coverPhoto,...s.images.filter(S=>S!==s.coverPhoto)]:(s==null?void 0:s.images)||[],i=F||a[0],c=a.indexOf(i),p=Ys.current[c],f=Us.current;if(p&&f){const S=f.getBoundingClientRect(),R=p.getBoundingClientRect(),M=p.offsetLeft-S.width/2+R.width/2;f.scrollTo({left:Math.max(0,M),behavior:"smooth"})}},[F,r,P]),d)return e.jsx("div",{className:"min-h-screen bg-slate-50 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("p",{className:"text-slate-600",children:"Loading your dashboard..."})]})});const t=r||P[0],J=t!=null&&t.coverPhoto&&((sa=t==null?void 0:t.images)!=null&&sa.includes(t.coverPhoto))?[t.coverPhoto,...t.images.filter(s=>s!==t.coverPhoto)]:(t==null?void 0:t.images)||[],ht=Math.max((t==null?void 0:t.currentBid)||0,(t==null?void 0:t.startingBid)||0,...L.map(s=>s.amount)||[]),v=L.length>0?L.reduce((s,a)=>s.amount>a.amount?s:a):null,de=t!=null&&t.useCustomCustomerDisplay&&(t!=null&&t.customerDisplayBid)?t.customerDisplayBid:Fr(t==null?void 0:t.currentBid,t==null?void 0:t.startingBid,t==null?void 0:t.bidCount),ts=t!=null&&t.useCustomCustomerDisplay&&(t!=null&&t.customerDisplayBid
28DealerName)?t.customerDisplayBidDealerName:(m==null?void 0:m.dealership_name)||null,ge=t!=null&&t.useCustomCustomerDisplay&&(t!=null&&t.customerDisplayOffer)?t.customerDisplayOffer:(v==null?void 0:v.amount)||0,je=t!=null&&t.useCustomCustomerDisplay&&(t!=null&&t.customerDisplayOfferDealerName)?t.customerDisplayOfferDealerName:(v==null?void 0:v.dealerName)||(m==null?void 0:m.dealership_name)||null,Ss=t==null?void 0:t.useCustomCustomerDisplay,Fe=(t==null?void 0:t.status)==="review_submission"||(t==null?void 0:t.status)==="pending_review",Cs=(t==null?void 0:t.sale_stage)==="customer_confirmed_ready",sr=()=>{if(!t)return 0;const{status:s,sale_stage:a}=t;return s==="sold"?4:s==="sold_waiting"||a==="customer_confirmed_ready"?3:s==="active"||s==="ended"||s==="on_offer"||s==="dealer_counter"?2:s==="review_submission"||s==="pending_review"?1:0},Ks=[{label:"Submitted",icon:"📋"},{label:"In Review",icon:"🔍"},{label:"Offers In",icon:"💰"},{label:"Offer Accepted",icon:"🤝"},{label:"Sold!",icon:"🎉"}],ar=()=>{const s=sr();return e.jsx("div",{className:"px-4 py-3 bg-white dark:bg-gray-900 border-b border-slate-100 dark:border-gray-800",children:e.jsxs("div",{className:"flex items-center justify-between relative",children:[e.jsx("div",{className:"absolute left-0 right-0 top-3.5 mx-4 h-[2px] bg-slate-200 dark:bg-gray-700 z-0"}),e.jsx("div",{className:"absolute left-0 top-3.5 mx-4 h-[2px] bg-emerald-500 z-0 transition-all duration-700",style:{width:`calc(${s/(Ks.length-1)*100}% - 2rem)`}}),Ks.map((a,i)=>{const c=i<s,p=i===s;return e.jsxs("div",{className:"flex flex-col items-center z-10 flex-1",children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center text-xs font-bold border-2 transition-all duration-300 ${c?"bg-emerald-500 border-emerald-500 text-white":p?"bg-white dark:bg-gray-900 border-emerald-500 text-emerald-600 dark:text-emerald-400 ring-2 ring-emerald-200 dark:ring-emerald-900":"bg-white dark:bg-gray-900 border-slate-200 dark:border-gray-700 text-slate-300 dark:text-gray-600"}`,children:c?e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})}):e.jsx("span",{children:i+1})}),e.jsx("span",{className:`text-[9px] mt-1 font-medium text-center leading-tight max-w-[44px] ${p?"text-emerald-600 dark:text-emerald-400":c?"text-emerald-500 dark:text-emerald-500":"text-slate-400 dark:text-gray-600"}`,children:a.label})]},i)})]})})},rr=()=>e.jsx("div",{className:"flex items-center justify-around px-4 py-2 bg-emerald-50 dark:bg-emerald-950/30 border-b border-emerald-100 dark:border-emerald-900/30",children:[{icon:"✓",text:"Verified Dealers"},{icon:"✓",text:"More Money"},{icon:"✓",text:"Secure Process"}].map((s,a)=>e.jsxs("span",{className:"flex items-center gap-1 text-[10px] font-semibold text-emerald-700 dark:text-emerald-400",children:[e.jsx("span",{className:"text-emerald-500 font-bold",children:s.icon}),s.text]},a))}),Qs=(s="md")=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden md:block relative bg-white dark:bg-gray-900 rounded-2xl border-2 border-emerald-500 dark:border-emerald-600 shadow-sm dark:shadow-lg overflow-hidden",children:[e.jsx("div",{className:"bg-emerald-500 dark:bg-emerald-600 px-4 py-1.5",children:e.jsx("span",{className:"text-xs font-bold text-white uppercase tracking-wider",children:"Live"})}),e.jsxs("div",{className:"p-5 md:p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"w-5 h-5 rounded-full bg-emerald-600 flex items-center justify-center flex-shrink-0",children:e.jsx(ae,{className:"w-3.5 h-3.5 text-white",strokeWidth:3})}),e.jsx("span",{className:"text-[15px] font-bold text-slate-900 dark:text-white leading-tight",children:"Top Verified Live Dealer Offer"})]}),t.status==="active"&&t.endTime&&e.jsxs("div",{className:"flex items-center gap-1 border border-emerald-200 dark:border-emerald-800 bg-white dark:bg-transparent roun
28ded-full px-2.5 py-1 flex-shrink-0",children:[e.jsx(Ie,{className:"w-3 h-3 text-emerald-600 dark:text-emerald-400"}),e.jsx("span",{className:"text-[10px] font-semibold text-emerald-700 dark:text-emerald-400 whitespace-nowrap",children:(()=>{const a=new Date(t.endTime).getTime()-Date.now();if(a<=0)return"Ended";const i=Math.floor(a/864e5),c=Math.floor(a%864e5/36e5),p=Math.floor(a%36e5/6e4),f=Math.floor(a%6e4/1e3);return i>0?`Ends in ${i}d ${c}h ${p}m ${f}s`:c>0?`Ends in ${c}h ${p}m ${f}s`:p>0?`Ends in ${p}m ${f}s`:`Ends in ${f}s`})()})]})]}),e.jsxs("div",{className:"text-[44px] md:text-[52px] font-black text-slate-900 dark:text-white leading-none tracking-tight mb-3",children:["$",de.toLocaleString()]}),e.jsxs("div",{className:"inline-flex items-center gap-1.5 bg-emerald-50 dark:bg-emerald-950/40 border border-emerald-100 dark:border-emerald-900 rounded-full px-3 py-1.5 mb-5",children:[e.jsx(ae,{className:"w-3.5 h-3.5 text-emerald-600"}),e.jsx("span",{className:"text-[12px] font-medium text-emerald-700 dark:text-emerald-400",children:t.bidCount>0?`Live bid from ${t.bidCount} Verified Local ${t.bidCount===1?"Dealer":"Dealers"}`:"Real bid from a verified local dealer"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 pb-4 border-b border-slate-100 dark:border-gray-800",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(Ge,{className:"w-4 h-4 text-emerald-600"}),e.jsx("div",{className:"text-[11px] font-semibold text-slate-900 dark:text-white leading-tight",children:"Verified buyer"}),e.jsx("div",{className:"text-[10px] text-slate-500 dark:text-gray-400 leading-tight",children:"Carsolve verified dealer"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(os,{className:"w-4 h-4 text-emerald-600"}),e.jsx("div",{className:"text-[11px] font-semibold text-slate-900 dark:text-white leading-tight",children:"Secure Transaction"}),e.jsx("div",{className:"text-[10px] text-slate-500 dark:text-gray-400 leading-tight",children:"Safe & Guranteed"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(Sa,{className:"w-4 h-4 text-emerald-600"}),e.jsx("div",{className:"text-[11px] font-semibold text-slate-900 dark:text-white leading-tight",children:"CarSolve support"}),e.jsx("div",{className:"text-[10px] text-slate-500 dark:text-gray-400 leading-tight",children:"Here to help"})]})]}),t.reservePrice&&t.reservePrice>0&&e.jsxs("div",{className:"grid grid-cols-2 gap-3 py-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] text-slate-500 dark:text-gray-400 mb-1",children:"Your reserve price"}),e.jsxs("div",{className:"text-[17px] font-bold text-slate-900 dark:text-white leading-tight",children:["$",t.reservePrice.toLocaleString()]})]}),e.jsxs("div",{className:"border-l border-slate-100 dark:border-gray-800 pl-3",children:[e.jsx("div",{className:"text-[11px] text-slate-500 dark:text-gray-400 mb-1",children:"Current bid is"}),e.jsx("div",{className:`text-[15px] font-bold leading-tight ${de>=t.reservePrice?"text-emerald-600":"text-slate-900 dark:text-white"}`,children:de>=t.reservePrice?"Reserve met":`$${(t.reservePrice-de).toLocaleString()} below reserve`})]})]}),t.reservePrice&&t.reservePrice>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"relative w-full h-1.5 bg-slate-200 dark:bg-gray-700 rounded-full",children:[e.jsx("div",{className:"absolute top-0 left-0 h-full bg-emerald-500 rounded-full transition-all duration-500",style:{width:`${Math.min(100,Math.round(de/t.reservePrice*100))}%`}}),e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 w-4 h-4 rounded-full bg-white border-2 border-emerald-500 shadow-md",style:{left:`calc(${Math.min(100,Math.round(de/t.reservePrice*100))}% - 8px)`}})]}),e.jsxs("div",{className:"flex justify-between mt-2",children:[e.jsxs("span",{className:"text-[10px] text-slate-500 dark:text-gray-400",children:["$",de.toLocaleString()," Bid"]}),e.jsxs("span",{className:"text-[10px] text-slate-500 dark:text-gray-400",children:["$",t.reservePrice.toLocaleString()," Reserve"]})]})]}),s!=="lg"&&A.length>0&&e.jsxs("button",{onClick:()=>ze(!Me),className:"w-full mb-3 flex items-center justify-center gap-1.5 text-[11px] font-semibold text-emerald-600 dark:text-emerald-400 hover:text-emerald-700 transition-colors py-1",children:[e.jsx(ka,{className:"w-3 h-3"}),Me?"Hide Bid History":"See Bid History",e.jsx(ns,{className:`w-3 h-3 transition-transform duration-300 ${Me?"rotate-180":""}`})]}),t.highBidderId&&de>0&&e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsxs(I,{onClick:Dt,className:"w-full h-12 text-[15px] font-bold bg-emerald-600 hover:bg-emerald-700 text-white border-0 shadow-sm rounded-lg group",children:[e.jsxs("span",{children:["Accept $",de.toLocaleStr
28ing()," Bid"]}),e.jsx(it,{className:"w-4 h-4 ml-1 group-hover:translate-x-0.5 transition-transform"})]}),e.jsxs(I,{onClick:()=>T(!0),variant:"outline",className:"w-full h-12 text-[14px] font-semibold border border-emerald-600/40 bg-transparent text-emerald-700 dark:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-950/30 hover:border-emerald-600 rounded-lg",children:[e.jsx("span",{children:"Request Higher Bid"}),e.jsx(Ta,{className:"w-4 h-4 ml-1.5"})]}),s==="lg"&&e.jsxs(I,{onClick:()=>{const a=document.getElementById("all-offers-section");a&&a.scrollIntoView({behavior:"smooth",block:"start"})},variant:"ghost",className:"w-full h-11 text-[13px] font-semibold text-slate-700 dark:text-gray-300 hover:bg-slate-100 dark:hover:bg-gray-800 rounded-lg",children:["View All Offers",e.jsx(bt,{className:"w-4 h-4 ml-1.5"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 mt-1",children:[e.jsx(os,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-[10px] text-slate-500 dark:text-gray-400",children:"No obligation · You're in control"})]})]})]}),s!=="lg"&&e.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${Me?"max-h-64":"max-h-0"}`,children:e.jsx("div",{className:"border-t border-emerald-100 dark:border-emerald-900/50 bg-slate-50/50 dark:bg-gray-800/50",children:e.jsx("div",{className:"p-3 max-h-56 overflow-y-auto scrollbar-hide",children:e.jsx("div",{className:"space-y-2",children:(()=>{const a=Math.max(...A.map(i=>Number(i.amount)||0));return A.slice(0,10).map((i,c)=>{var p;return e.jsxs("button",{type:"button",onClick:()=>_s(i),className:"w-full flex items-center justify-between py-1.5 px-2 rounded-lg bg-white dark:bg-gray-900/50 border border-slate-100 dark:border-gray-700 hover:border-emerald-300 dark:hover:border-emerald-600 hover:bg-emerald-50/40 dark:hover:bg-emerald-950/20 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[$e[i.dealership_id]?e.jsx("img",{src:$e[i.dealership_id],alt:"Dealership",className:"w-6 h-6 rounded-full object-cover"}):e.jsx("div",{className:"w-6 h-6 rounded-full bg-slate-900 flex items-center justify-center text-white text-[8px] font-bold",children:(i.dealership_name||i.dealershipName||"D").charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-medium text-slate-700 dark:text-gray-300",children:i.dealership_name||i.dealershipName||"Dealership"}),e.jsx("div",{className:"text-[9px] text-slate-400 dark:text-gray-500",children:new Date(i.timestamp).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"text-xs font-bold text-slate-900 dark:text-white",children:["$",(p=i.amount)==null?void 0:p.toLocaleString()]}),(Number(i.amount)||0)===a&&a>0&&e.jsx("span",{className:"text-[8px] px-1.5 py-0.5 rounded-full bg-emerald-100 text-emerald-700 dark:bg-emerald-900/50 dark:text-emerald-400 font-medium",children:"HIGH"})]})]},i.id||c)})})()})})})})]}),s!=="lg"&&e.jsx("div",{className:`hidden md:block bg-white dark:bg-gray-900 rounded-xl border shadow-sm dark:shadow-lg overflow-hidden ${v?"border-amber-200 dark:border-amber-400":"border-slate-200 dark:border-gray-700"}`,children:e.jsxs("div",{className:`p-3 md:p-5 ${v?"bg-gradient-to-br from-amber-50/50 to-white dark:from-transparent dark:to-transparent":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 md:mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 bg-amber-500 rounded-full animate-pulse"}),e.jsx("span",{className:"text-[10px] md:text-xs font-bold text-slate-500 dark:text-gray-400 uppercase tracking-wider",children:"Direct Offer High"})]}),v&&e.jsxs("div",{className:"flex items-center gap-1 bg-amber-100 text-amber-700 px-2 py-0.5 rounded-full text-[10px] md:text-xs font-bold",children:[e.jsx("svg",{className:"w-2.5 h-2.5",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})}),"TOP"]})]}),e.jsxs("div",{className:"mb-2 md:mb-3",children:[e.jsxs("div",{className:"text-2xl md:text-3xl lg:text-4xl font-bold text-slate-900 dark:text-white mb-0.5",children:["$",ge.toLocaleStr
28ing()]}),e.jsx("div",{className:"text-[10px] md:text-xs text-slate-500 dark:text-gray-400",children:ge>0?"Highest direct offer":"No offers yet"})]}),(v||Ss&&ge>0)&&e.jsx("div",{className:"bg-slate-50 dark:bg-gray-800 rounded-lg p-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[v!=null&&v.dealerLogo?e.jsx("img",{src:v.dealerLogo,alt:je||v.dealerName,className:"w-8 h-8 rounded-lg object-contain bg-white border border-slate-200 p-0.5"}):e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center text-white font-bold text-sm",children:(je||(v==null?void 0:v.dealerName)||"D").charAt(0)}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-xs text-slate-900 dark:text-white",children:je||(v==null?void 0:v.dealerName)||"Dealer"}),e.jsx("div",{className:"text-[10px] text-slate-500",children:"Verified Dealer"})]})]})}),ge>0&&e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[e.jsx(I,{onClick:_t,size:"sm",className:"w-full h-10 text-sm font-semibold bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800 text-white shadow-md shadow-blue-900/20 border-0",children:"Accept Offer"}),e.jsx(I,{onClick:()=>T(!0),variant:"outline",size:"sm",className:"w-full h-9 text-xs font-medium border border-amber-400/50 bg-transparent text-amber-700 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-300 hover:bg-amber-50 dark:hover:bg-amber-950/30 hover:border-amber-500",children:"Counter Offer"})]})]})})]}),lr=()=>e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-2xl border border-slate-200 dark:border-gray-800 shadow-xl shadow-slate-900/5 overflow-hidden",children:e.jsxs("div",{className:"p-6 md:p-8",children:[e.jsxs("div",{className:"flex items-start gap-4 mb-5",children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 md:w-16 md:h-16 bg-gradient-to-br from-emerald-500 to-emerald-600 dark:from-emerald-600 dark:to-emerald-700 rounded-2xl flex items-center justify-center shadow-lg shadow-emerald-500/25 dark:shadow-emerald-900/40",children:e.jsx(ae,{className:"w-7 h-7 md:w-8 md:h-8 text-white"})}),e.jsxs("div",{className:"pt-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"text-xs font-semibold tracking-[0.15em] uppercase text-emerald-700 dark:text-emerald-400",children:"Offer Accepted"}),e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-medium bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300 border border-emerald-200/50 dark:border-emerald-800/50",children:"Action Required"})]}),e.jsxs("p",{className:"text-base md:text-lg font-light text-slate-600 dark:text-gray-300 leading-relaxed",children:["Congratulations! Your offer from"," ",e.jsx("span",{className:"font-medium text-slate-800 dark:text-white",children:t.highBidderName||"the dealer"})," ","has been accepted"]})]})]}),e.jsxs("div",{className:"mb-5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500 dark:text-emerald-400/70 mb-2 font-medium",children:"Sale Price"}),e.jsxs("p",{className:"text-3xl md:text-4xl font-light tracking-tight text-emerald-600 dark:text-emerald-400",children:["$",(t.sale_price||t.currentBid||0).toLocaleString()]})]}),e.jsx(ft,{winningDealer:m,offers:L,displayBestAmount:t.sale_price||t.currentBid||0,bidderCount:t.bidCount||L.length||0,vin:t.vin}),e.jsxs("div",{className:"mt-5 flex flex-col sm:flex-row items-center gap-4 p-4 md:p-5 rounded-xl bg-emerald-50/50 dark:bg-emerald-950/20 border border-emerald-100 dark:border-emerald-800/40",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 md:w-12 md:h-12 bg-white dark:bg-emerald-900/40 rounded-xl flex items-center justify-center border border-emerald-200/50 dark:border-emerald-800/30",children:e.jsx(oe,{className:"w-5 h-5 md:w-6 md:h-6 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{className:"flex-1 min-w-0 text-center sm:text-left",children:[e.jsx("p",{className:"text-sm font-medium text-slate-800 dark:text-white mb-0.5",children:"Schedule Your Appointment"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-gray-400",children:"Select a convenient time to complete the sale at the dealership"})]}),e.jsxs(I,{onClick:()=>
28{Le({type:"bid",amount:t.sale_price||t.currentBid||0,dealerId:t.highBidderId||t.high_bidder_id||"",dealerName:t.highBidderName||"Dealer"}),Oe(!0)},size:"lg",className:"flex-shrink-0 h-11 px-6 text-sm font-semibold bg-gradient-to-r from-emerald-600 to-emerald-700 hover:from-emerald-700 hover:to-emerald-800 text-white shadow-lg shadow-emerald-600/20 border-0 rounded-xl",children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),"Schedule Appointment"]})]})]})}),dr=()=>e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-2xl shadow-xl shadow-slate-900/5 overflow-hidden",children:e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-emerald-50 via-white to-emerald-50/50 dark:from-emerald-950/30 dark:via-gray-900 dark:to-emerald-950/20 border border-emerald-200/60 dark:border-emerald-800/30",children:[e.jsx("div",{className:"absolute top-0 right-0 w-48 h-48 bg-gradient-to-bl from-emerald-200/30 dark:from-emerald-800/10 to-transparent rounded-full -translate-y-1/2 translate-x-1/4"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-32 h-32 bg-gradient-to-tr from-emerald-200/20 dark:from-emerald-800/5 to-transparent rounded-full translate-y-1/2 -translate-x-1/4"}),e.jsxs("div",{className:"relative p-5 md:p-8",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-5",children:[e.jsx("div",{className:"w-12 h-12 md:w-14 md:h-14 rounded-2xl bg-gradient-to-br from-emerald-500 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-500/20 flex-shrink-0",children:e.jsx(ae,{className:"h-6 w-6 md:h-7 md:w-7 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-xl md:text-2xl font-bold text-slate-900 dark:text-white",children:"Congratulations! 🎉"}),e.jsx("p",{className:"text-sm text-emerald-700 dark:text-emerald-400 font-medium mt-0.5",children:"Your vehicle sale is complete"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 py-4 border-t border-emerald-200/50 dark:border-emerald-800/30",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.15em] text-emerald-600 dark:text-emerald-500 font-semibold",children:"Vehicle Sold"}),e.jsxs("p",{className:"text-base md:text-lg font-semibold text-slate-900 dark:text-white",children:[t.year," ",t.make," ",t.model]})]}),e.jsxs("div",{className:"bg-emerald-100/50 dark:bg-emerald-900/20 rounded-xl px-5 py-3 flex-shrink-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.15em] text-emerald-600 dark:text-emerald-500 font-semibold",children:"Sale Price"}),e.jsxs("p",{className:"text-2xl md:text-3xl font-bold text-emerald-700 dark:text-emerald-400",children:["$",(t.sale_price||t.currentBid||t.startingBid||0).toLocaleString()]})]})]}),((m==null?void 0:m.dealership_name)||(t==null?void 0:t.highBidderName))&&e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl bg-slate-50 dark:bg-gray-800/50 border border-slate-100 dark:border-gray-700/50",children:[m!=null&&m.logo_url?e.jsx("img",{src:m.logo_url,alt:m.dealership_name||"Dealer",className:"w-12 h-12 rounded-xl object-contain bg-white dark:bg-gray-900 border border-emerald-200/50 dark:border-emerald-800/30 flex-shrink-0 p-1"}):e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-emerald-100 to-emerald-50 dark:from-emerald-900/40 dark:to-emerald-900/20 border border-emerald-200/50 dark:border-emerald-800/30 flex items-center justify-center flex-shrink-0",children:e.jsx(dt,{className:"h-6 w-6 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs text-slate-500 dark:text-gray-400",children:"Purchased By"}),e.jsx("p",{className:"text-sm font-bold text-slate-900 dark:text-white truncate",children:(m==null?void 0:m.dealership_name)||(t==null?void 0:t.highBidderName)})]})]}),e.jsx("div",{className:"pt-3 border-t border-emerald-200/50 dark:border-emerald-800/30",children:e.jsxs("p",{className:"text-sm text-slate-600 dark:text-gray-400 text-center",children:["Thank you for using ",e.jsx("span",{className:"font-semibold text-emerald-700 dark:text-emerald-400",children:"CarSolve"}),"! We hope your experience was seamless."]})})]})]})]})}),ir=()=>e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-2xl shadow-xl shadow-slate-900/5 overflow-hidden",children:e.jsxs("div",{className:"p-5 md:p-6 space-y-4",children:[t.highBidderId&&de>0&&e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-emerald-500/20 dark:border-emerald-400/20 bg-gradient-to-br from-white via-emerald-50/30 to-white dark:from-gray-900 dark:via-emerald-950/20 dark:to-gray-900",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-emerald-500 via-emerald-400 to-teal-500"}),e.jsxs("div",{className:"relative p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex items-center justify-center w-11 h-11 rounded-full bg-gradient-to-br from-emerald-500 to-emerald-600 shadow-md shadow-emerald-500/30",children:e.jsx(ae,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.18em] text-emerald-600 dark:text-emerald-400 font-bold",children:"Auction Complete"}),e.jsx("h3",{className:"text-lg font-bold text-foreground tracking-tight",children:"Winning Bid Ready"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded-full bg-emerald-100 dark:bg-emerald-900/40",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),e.jsx("span",{className:"text-[10px] font-semibold text-emerald-700 dark:text-emerald-300 uppercase tracking-wider",children:"Live"})]})]}),(()=>{const s=ts||(m==null?void 0:m.dealership_name)||t.highBidderName||"W
28inning Bidder",a=m==null?void 0:m.logo_url;return e.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 rounded-xl bg-white/70 dark:bg-gray-800/50 border border-border/40 backdrop-blur-sm",children:[a?e.jsx("img",{src:a,alt:s,className:"w-10 h-10 rounded-lg object-contain bg-white border border-slate-200 p-1 flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-600 flex items-center justify-center text-white font-bold text-sm flex-shrink-0 shadow-sm",children:s.charAt(0).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:"Highest Bidder"}),e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:s})]})]})})(),e.jsxs("div",{className:"mb-4 pb-4 border-b border-dashed border-border/60",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1 font-medium",children:"Highest Offer"}),e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-2xl font-light text-emerald-600 dark:text-emerald-400",children:"$"}),e.jsx("span",{className:"text-4xl font-bold bg-gradient-to-r from-emerald-600 to-emerald-700 dark:from-emerald-400 dark:to-emerald-500 bg-clip-text text-transparent tracking-tight",children:de.toLocaleString()})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(I,{onClick:Dt,size:"lg",className:"w-full h-12 text-base font-semibold tracking-wide bg-gradient-to-r from-emerald-600 to-emerald-700 hover:from-emerald-700 hover:to-emerald-800 text-white shadow-lg shadow-emerald-900/20 border-0",children:"Review Offer"}),e.jsx(I,{onClick:()=>T(!0),variant:"outline",size:"sm",className:"w-full h-10 text-sm font-medium border border-amber-400/50 bg-transparent text-amber-700 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-300 hover:bg-amber-50 dark:hover:bg-amber-950/30 hover:border-amber-500",children:"Counter Offer"})]})]})]}),ge>0&&e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-blue-500/20 dark:border-blue-400/20 bg-gradient-to-br from-white via-blue-50/30 to-white dark:from-gray-900 dark:via-blue-950/20 dark:to-gray-900",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-blue-500 via-indigo-400 to-blue-600"}),e.jsxs("div",{className:"relative p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex items-center justify-center w-11 h-11 rounded-full bg-gradient-to-br from-blue-500 to-blue-600 shadow-md shadow-blue-500/30",children:e.jsx(rt,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.18em] text-blue-600 dark:text-blue-400 font-bold",children:"Direct Offer"}),e.jsx("h3",{className:"text-lg font-bold text-foreground tracking-tight",children:"Offer Available"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded-full bg-blue-100 dark:bg-blue-900/40",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-500 animate-pulse"}),e.jsx("span",{className:"text-[10px] font-semibold text-blue-700 dark:text-blue-300 uppercase tracking-wider",children:"New"})]})]}),je&&e.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 rounded-xl bg-white/70 dark:bg-gray-800/50 border border-border/40 backdrop-blur-sm",children:[v!=null&&v.dealerLogo?e.jsx("img",{src:v.dealerLogo,alt:je,className:"w-10 h-10 rounded-lg object-contain bg-white border border-slate-200 p-1 flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-blue-500 to-indigo-600 flex items-center justify-center text-white font-bold text-sm flex-shrink-0 shadow-sm",children:je.charAt(0).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:"From Dealership"}),e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:je})]})]}),e.jsxs("div",{className:"mb-4 pb-4 border-b border-dashed border-border/60",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1 font-medium",children:"Offer Amount"}),e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-2xl font-light text-blue-600 dar
28k:text-blue-400",children:"$"}),e.jsx("span",{className:"text-4xl font-bold bg-gradient-to-r from-blue-600 to-indigo-700 dark:from-blue-400 dark:to-indigo-400 bg-clip-text text-transparent tracking-tight",children:ge.toLocaleString()})]})]}),e.jsx(I,{onClick:_t,size:"lg",className:"w-full h-12 text-base font-semibold tracking-wide bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800 text-white shadow-lg shadow-blue-900/20 border-0",children:"Review Offer"})]})]})]})}),nr=()=>e.jsxs("div",{className:"relative overflow-hidden",children:[e.jsxs("div",{className:"relative bg-gradient-to-br from-white via-slate-50 to-emerald-50/30 dark:from-gray-900 dark:via-gray-900 dark:to-emerald-950/20 rounded-2xl max-md:rounded-t-none border border-slate-200/80 dark:border-emerald-900/30 shadow-xl dark:shadow-emerald-950/20",children:[e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-gradient-to-bl from-emerald-100/40 dark:from-emerald-900/10 to-transparent rounded-full -translate-y-1/2 translate-x-1/2"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-48 h-48 bg-gradient-to-tr from-emerald-100/30 dark:from-emerald-900/10 to-transparent rounded-full translate-y-1/2 -translate-x-1/2"}),e.jsx("div",{className:"relative p-6 md:p-8",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-6",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 md:w-16 md:h-16 bg-emerald-600 dark:bg-emerald-500 rounded-2xl flex items-center justify-center shadow-lg shadow-emerald-500/25 dark:shadow-emerald-900/40",children:e.jsx(ae,{className:"w-7 h-7 md:w-8 md:h-8 text-white"})}),e.jsxs("div",{className:"pt-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"text-xs font-semibold tracking-[0.15em] uppercase text-emerald-700 dark:text-emerald-500",children:"Offer Accepted"}),e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-medium bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300 border border-emerald-200/50 dark:border-emerald-800/50",children:"Confirmed"})]}),e.jsx("p",{className:"text-base md:text-lg font-light text-slate-600 dark:text-gray-300 leading-relaxed",children:(o==null?void 0:o.status)==="confirmed"?"Appointment to Finalize Sale Successfully Confirmed and Scheduled":"Appointment Successfully Requested – Waiting for Confirmation from Buyer"})]})]}),e.jsxs("div",{className:"flex-shrink-0 bg-white/60 dark:bg-gray-800/40 backdrop-blur-sm rounded-xl p-5 md:p-6 border border-slate-200/50 dark:border-emerald-900/30",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500 dark:text-slate-300 mb-2 font-medium text-center md:text-right",children:"Sale Price"}),e.jsxs("p",{className:"text-3xl md:text-4xl font-bold tracking-tight text-emerald-700 dark:text-emerald-500 text-center md:text-right",children:["$",(t.sale_price||ht).toLocaleString()]}),e.jsx("p",{className:"text-[10px] text-slate-500 dark:text-slate-300 text-center md:text-right mt-1",children:"*Offer is Guaranteed Pending Inspection"})]})]})})]}),((o==null?void 0:o.status)==="requested"||(o==null?void 0:o.status)==="waiting")&&e.jsx("div",{className:"mt-4 bg-white/80 dark:bg-gray-900/60 backdrop-blur-sm border border-amber-200/60 dark:border-amber-800/40 rounded-xl p-4 md:p-5",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 md:w-12 md:h-12 bg-gradient-to-br from-amber-100 to-amber-50 dark:from-amber-900/40 dark:to-amber-900/20 rounded-xl flex items-center justify-center border border-amber-200/50 dark:border-amber-800/30",children:e.jsx(Ie,{className:"w-5 h-5 md:w-6 md:h-6 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-800 dark:text-white mb-0.5",children:"Appointment Requested"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-gray-400",children:o.date&&o.time?`${o.date} at ${o.time} • Awaiting confirmation`:"Awaiting dealer confirmation"})]}),e.jsx(I,{variant:"outline",size:"sm",onClick:()=>wt(!0),className:"flex-shrink-0 border-slate-200 dark:border-gray-700 text-slate-600 dar
28k:text-gray-300 hover:bg-slate-50 dark:hover:bg-gray-800 text-xs font-medium",children:"View Details"})]})}),(o==null?void 0:o.status)==="confirmed"&&e.jsx("div",{className:"mt-6 relative overflow-hidden",children:e.jsxs("div",{className:"relative bg-gradient-to-br from-white via-slate-50 to-emerald-50/20 dark:from-gray-900 dark:via-gray-900 dark:to-emerald-950/10 rounded-2xl border border-slate-200/80 dark:border-emerald-900/20 shadow-xl dark:shadow-emerald-950/10",children:[e.jsx("div",{className:"absolute top-0 right-0 w-80 h-80 bg-gradient-to-bl from-emerald-100/30 dark:from-emerald-900/5 to-transparent rounded-full -translate-y-1/2 translate-x-1/3"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-64 h-64 bg-gradient-to-tr from-emerald-100/20 dark:from-emerald-900/5 to-transparent rounded-full translate-y-1/2 -translate-x-1/3"}),e.jsxs("div",{className:"relative p-6 md:p-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"flex-shrink-0 w-12 h-12 md:w-14 md:h-14 bg-emerald-600 dark:bg-emerald-500 rounded-2xl flex items-center justify-center shadow-lg shadow-emerald-500/20 dark:shadow-emerald-900/30",children:e.jsx(ae,{className:"w-6 h-6 md:w-7 md:h-7 text-white"})}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-lg font-semibold tracking-[0.15em] uppercase text-emerald-700 dark:text-emerald-500",children:"Appointment Confirmed"}),e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300 border border-emerald-200/50 dark:border-emerald-800/50",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-emerald-500 rounded-full mr-1.5 animate-pulse"}),"Ready"]})]})})]}),((m==null?void 0:m.dealership_name)||(t==null?void 0:t.highBidderName))&&e.jsxs("div",{className:"flex items-center gap-3 mb-5 p-3 rounded-xl bg-slate-50 dark:bg-gray-800/50 border border-slate-100 dark:border-gray-700/50",children:[m!=null&&m.logo_url?e.jsx("img",{src:m.logo_url,alt:m.dealership_name||"Dealer",className:"w-11 h-11 rounded-lg object-contain bg-white dark:bg-gray-900 border border-slate-200 dark:border-gray-700 flex-shrink-0 p-0.5"}):e.jsx("div",{className:"w-11 h-11 rounded-lg bg-primary/10 dark:bg-primary/20 flex items-center justify-center text-primary font-bold text-sm flex-shrink-0",children:((m==null?void 0:m.dealership_name)||(t==null?void 0:t.highBidderName)||"D").slice(0,2).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs text-slate-500 dark:text-gray-400",children:"Purchasing Dealer"}),e.jsx("p",{className:"text-sm font-semibold text-slate-800 dark:text-white truncate",children:(m==null?void 0:m.dealership_name)||(t==null?void 0:t.highBidderName)})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-emerald-100 dark:bg-emerald-900/30 flex items-center justify-center",children:e.jsx(oe,{className:"w-5 h-5 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500 dark:text-gray-400 mb-0.5",children:"Scheduled For"}),e.jsxs("p",{className:"text-base md:text-lg font-semibold text-slate-900 dark:text-white",children:[o==null?void 0:o.date," at ",o==null?void 0:o.time]})]})]}),e.jsxs(I,{onClick:()=>bs(!0),variant:"outline",size:"sm",className:"border-emerald-200 dark:border-emerald-800 bg-emerald-600 dark:bg-emerald-500 text-white hover:bg-emerald-700 dark:hover:bg-emerald-600",children:[e.jsx(_a,{className:"w-4 h-4 mr-2"}),"Details"]})]}),e.jsxs("div",{className:"mt-5 pt-4 border-t border-slate-200/70 dark:border-gray-800 flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs text-slate-500 dark:text-gray-400",children:"Need a different time?"}),e.jsxs(I,{variant:"ghost",size:"sm",onClick:()=>kt(!0),className:"text-emerald-700 dark:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-950/30 text-xs font-medium",children:[e.jsx(oe,{className:"w-3.5 h-3.5 mr-1.5"}),"Reschedule Appointment"]})]})]})]})})]});return e.jsxs("div",{className:"min-h-screen bg-slate-50 dark:bg-gray-950 flex flex-col md:flex-row",children:[xt&&u&&e.jsxs(Xr,{className:"fixed top-0 left-0 right-0 z-50 rounded-none border-l-4 border-l-blue-600 bg-blue-50 shadow-md",children:[e.jsx(_a,{className:"h-4 w-4 text-blue-600"}),e.jsxs(Kr,{className:"text-blue-900 font-medium flex items-center flex-wrap gap-2",children:[e.jsxs("span",{children:["Admin View: Viewing dashboard for ",u.name||u.email]}),e.jsx(I,{variant:"link",size:"sm",onClick:()=>C("/admin"),className:"text-blue-700 underline",children:"Return to Admin Dashboard"}),(t==null?void 0:t.id)&&((aa=t==null?void 0:t.images)==null?void 0:aa.some(s=>/\.(heic|heif)(\?|$)/i.test(s)))&&e.jsx(I,{variant:"outline",size:"sm",className:"border-amber-500 text-amber-700 hover:bg-amber-50",disabled:ot,onClick:async()=>
28{if(!(t!=null&&t.id))return;Mt(!0);const s=W.loading("Converting HEIC photos…");try{const{backfillHeicPhotosForCar:a}=await wa(async()=>{const{backfillHeicPhotosForCar:p}=await import("./heicBackfill-C6tHs8Ax.js");return{backfillHeicPhotosForCar:p}},__vite__mapDeps([3,1,2,0])),i=await a(t.id,p=>{W.loading(`Converting ${p.index+1}/${p.total}…`,{id:s})});W.success(`Converted ${i.converted}/${i.total} photos${i.failed.length?` · ${i.failed.length} failed`:""}`,{id:s});const{data:c}=await g.from("cars").select("*").eq("id",t.id).single();if(c){const p=Je(c);y(p),D(f=>f.map($=>$.id===p.id?p:$))}}catch(a){console.error(a),W.error(a instanceof Error?a.message:"Backfill failed",{id:s})}finally{Mt(!1)}},children:ot?"Converting…":"Fix HEIC photos"})]})]}),e.jsxs("div",{className:`w-full ${xt?"pt-16":""}`,children:[!We&&e.jsx("div",{className:"w-full bg-white dark:bg-gray-900 border-b border-slate-200 dark:border-gray-800 sticky top-16 z-40 shadow-sm",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 md:px-6 lg:px-8",children:e.jsxs("div",{className:"flex items-center justify-between h-14",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:()=>ee("my-cars"),className:`flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-all ${w==="my-cars"?"bg-emerald-100 dark:bg-emerald-900/50 text-emerald-600 dark:text-emerald-400":"text-slate-600 dark:text-gray-400 hover:bg-slate-100 dark:hover:bg-gray-800"}`,children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),e.jsx("span",{className:"text-sm",children:"My Cars"})]}),e.jsxs("button",{onClick:()=>ee("offers"),className:`flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-all relative ${w==="offers"?"bg-emerald-100 dark:bg-emerald-900/50 text-emerald-600 dark:text-emerald-400":"text-slate-600 dark:text-gray-400 hover:bg-slate-100 dark:hover:bg-gray-800"}`,children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"text-sm",children:"Offers"}),L.length>0&&e.jsx("span",{className:"bg-red-500 text-white text-xs px-1.5 py-0.5 rounded-full",children:L.length})]}),e.jsxs("button",{onClick:()=>q(!0),className:"flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-all text-slate-600 dark:text-gray-400 hover:bg-slate-100 dark:hover:bg-gray-800",children:[e.jsx(Ms,{className:"w-5 h-5"}),e.jsx("span",{className:"text-sm",children:"Message"})]}),e.jsxs("button",{onClick:()=>mt(!0),className:"flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-all text-slate-600 dark:text-gray-400 hover:bg-slate-100 dark:hover:bg-gray-800",children:[e.jsx(Pt,{className:"w-5 h-5"}),e.jsx("span",{className:"text-sm",children:"How It Works"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"text-right",children:e.jsx("div",{className:"text-sm font-medium text-slate-900 dark:text-white",children:(l==null?void 0:l.name)||((ra=l==null?void 0:l.email)==null?void 0:ra.split("@")[0])||"Guest"})}),e.jsx("div",{className:"w-10 h-10 bg-slate-200 dark:bg-gray-700 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5 text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})})]})]})})}),e.jsx("div",{className:We&&t&&w==="my-cars"&&t.status==="ended"&&!(o!=null&&o.status)&&!be?"flex-1":"flex-1 pb-20 md:pb-0 md:max-w-5xl md:mx-auto max-md:bg-[#f6f4f1] dark:max-md:bg-gray-950",children:We&&t&&w==="my-cars"&&t.status==="ended"&&!(o!=null&&o.status)&&!be?e.jsx(gl,{car:t,realOffers:L.map(s=>({id:s.id,dealerName:s.dealerName,dealerCity:s.dealerCity,dealerState:s.dealerState,dealerLogo:s.dealerLogo,dealerAddress:s.dealerAddress,dealerPhone:s.dealerPhone,dealerWebsite:s.dealerWebsite,paymentTypes:s.paymentTypes,pickupOptions:s.pickupOptions,timestamp:s.timestamp||s.createdAt,isTradeIn:s.isTradeIn,type:s.type,amount:s.amount,perk:s.perk}
28)),displayBestAmount:Math.max(de||0,ge||0),bidderCount:t.bidCount||L.length||0,endTime:t.endTime||t.end_time,winningDealer:m,onAcceptBest:()=>{(ge||0)>=(de||0)&&ge>0?_t():Dt()},onCounter:()=>T(!0),onAskQuestion:()=>q(!0),onOpenVehicleInfo:()=>se(!0),onWalkAway:()=>Y(!0)}):e.jsxs(e.Fragment,{children:[t&&w==="my-cars"&&We&&Fe&&e.jsx(rr,{}),t&&w==="my-cars"&&e.jsxs("div",{className:`relative bg-slate-950 px-4 md:px-8 lg:px-12 pt-8 md:pt-12 pb-0 md:pb-12 lg:pb-16 md:w-screen md:mx-[calc(50%-50vw)] ${Fe?"":"max-md:before:content-[''] max-md:before:absolute max-md:before:inset-x-0 max-md:before:-top-12 max-md:before:h-12 max-md:before:bg-slate-950"}`,children:[!We&&e.jsx("div",{className:"absolute top-4 right-4 md:top-6 md:right-6 z-20",children:e.jsx(fl,{})}),e.jsx("div",{className:"max-w-md md:max-w-2xl mx-auto text-center mb-6 md:mb-10",children:t.status==="sold"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block text-emerald-400 text-[10px] font-bold tracking-[0.2em] uppercase",children:"Sale Complete"}),e.jsx("h1",{className:"mt-4 text-white font-serif text-[34px] md:text-[44px] lg:text-[56px] leading-[1.05] tracking-tight font-bold",children:"Congratulations!"}),e.jsx("p",{className:"mt-3 text-slate-300 text-sm md:text-base lg:text-lg leading-relaxed px-4 md:px-0",children:"Your vehicle sale is complete. Thank you for using CarSolve."})]}):(o==null?void 0:o.status)==="confirmed"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block text-emerald-400 text-[10px] font-bold tracking-[0.2em] uppercase",children:"Appointment Confirmed"}),e.jsx("h1",{className:"mt-4 text-white font-serif text-[34px] md:text-[44px] lg:text-[56px] leading-[1.05] tracking-tight font-bold",children:"You're All Set!"}),e.jsx("p",{className:"mt-3 text-slate-300 text-sm md:text-base lg:text-lg leading-relaxed px-4 md:px-0",children:"Your appointment is confirmed. Show up at the dealership at your scheduled time to complete the sale."})]}):t.status==="sold_waiting"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block text-emerald-400 text-[10px] font-bold tracking-[0.2em] uppercase",children:"Sale Accepted · Schedule Now"}),e.jsx("h1",{className:"mt-4 text-white font-serif text-[34px] md:text-[44px] lg:text-[56px] leading-[1.05] tracking-tight font-bold",children:"Schedule Your Appointment"}),e.jsx("p",{className:"mt-3 text-slate-300 text-sm md:text-base lg:text-lg leading-relaxed px-4 md:px-0",children:"Your offer has been accepted. Pick a date and time to complete the sale at the dealership."})]}):Fe?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block text-emerald-400 text-[10px] font-bold tracking-[0.2em] uppercase",children:"Instant Offer Available · Start Your Sale"}),e.jsx("h1",{className:"mt-4 text-white font-serif text-[34px] md:text-[44px] lg:text-[56px] leading-[1.05] tracking-tight font-bold",children:"Choose Your Next Step"}),e.jsx("p",{className:"mt-3 text-slate-300 text-sm md:text-base lg:text-lg leading-relaxed px-4 md:px-0",children:"Accept your instant offer now, or start your sale by submitting photos and confirming your vehicle's condition."})]}):(t.status==="dealer_counter"||t.status==="on_offer")&&(le||te)?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block text-amber-400 text-[10px] font-bold tracking-[0.2em] uppercase",children:t.status==="dealer_counter"?"Auction Ended · Counter Offer Received":"Auction Ended · Counter Offer Sent"}),e.jsx("h1",{className:"mt-4 text-white font-serif text-[34px] md:text-[44px] lg:text-[56px] leading-[1.05] tracking-tight font-bold",children:t.status==="dealer_counter"?"Counter Offer Received":"Counter Offer Sent"}),e.jsx("p",{className:"mt-3 text-slate-300 text-sm md:text-base lg:text-lg leading-relaxed px-4 md:px-0",children:t.status==="dealer_counter"?"The auction has ended and a dealer has responded to your counter offer. Review and accept or counter again.":"The auction has ended and your counter offer has been sent to the dealer. Waiting for their response."})]}):t.status==="ended"&&!(o!=null&&o.status)?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block text-slate-300 text-[10px] font-bold tracking-[0.2em] uppercase",children:"Auction Ended · Review Your Offers"}),e.jsx("h1",{className:"mt-4 text-white font-serif text-[34px] md:text-[44px] lg:text-[56px] leading-[1.05] tracking-tight font-bold",children:"Auction Complete"}),e.jsx("p",{className:"mt-3 text-slate-300 text-sm md:text-base lg:text-lg leading-relaxed px-4 md:px-0",children:"Your auction has ended. Review the highest offer and choose your next step."})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block text-emerald-400 text-[10px] font-bold tracking-[0.2em] uppercase",children:"LIVE OFFERS · BIDDING NOW"}),e.jsx("h1",{className:"mt-4 text-white font-serif text-[34px] md:text-[44px] lg:text-[56px] leading-[1.05] tracking-tight font-bold",children:"Your Listing is Live!"}),e.jsx("p",{className:"mt-3 text-slate-300 text-sm md:text-base lg:text-lg leading-relaxed px-4 md:px-0",children:"Dealers in our network are competing for your vehicle right now."})]})}),e.jsxs("div",{className:"max-w-md md:max-w-6xl lg:max-w-7xl mx-auto lg:grid lg:grid-cols-2 lg:gap-8 pb-0 md:pb-16 lg:pb-8",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"relative w-full",children:[e.jsxs("div",{className:`relative w-full aspect-[16/10] md:aspect-[21/9] lg:aspect-[16/9.5] overflow-hidden bg-gray-950 md:bg-black group border border-white max-md:rounded-t-2xl max-md:rounded-b-none md:rounded-lg max-md:shadow-xl max-md:shadow-black/30 ${J.length>1?"lg:rounded-b-none lg:border-b-0":""}`,onTouchStart:s=>{const a=s.touches[0];s.currentTarget._touchStartX=a.clientX},onTouchEnd:s=>
28{const a=s.currentTarget._touchStartX??0,i=s.changedTouches[0].clientX,c=a-i;if(Math.abs(c)<40)return;const p=J.indexOf(F||J[0]);if(c>0){const f=p>=J.length-1?0:p+1;ne(J[f])}else{const f=p<=0?J.length-1:p-1;ne(J[f])}},children:[!t.images||t.images.length===0?e.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:qa?e.jsx("img",{src:"/carsolve-placeholder.jpg",alt:"CarSolve - Empowering Sellers in the Digital Age",className:"w-full h-full object-cover"}):e.jsx("video",{src:"/carsolve-animation.mov",autoPlay:!0,muted:!0,playsInline:!0,onEnded:()=>Ra(!0),className:"w-full h-full object-cover"})}):(()=>{const s=F||J[0];return/\.(mp4|webm|ogg|mov)$/i.test(s)||s.includes("video")?e.jsx("video",{src:s,controls:!0,playsInline:!0,className:"w-full h-full object-cover cursor-pointer",onClick:i=>i.stopPropagation()}):e.jsx("img",{src:s,alt:`${t.year} ${t.make} ${t.model}`,className:"w-full h-full object-cover cursor-pointer transition-all duration-1000 ease-out group-hover:scale-[1.03]",onClick:()=>window.open(s,"_blank")})})(),t.images&&t.images.length>0&&e.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none mix-blend-overlay",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E")`}}),J.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:s=>{s.stopPropagation();const a=J.indexOf(F||J[0]),i=a<=0?J.length-1:a-1;ne(J[i])},className:"absolute left-2 md:left-6 top-1/2 -translate-y-1/2 w-10 h-10 md:w-14 md:h-14 rounded-full bg-black/40 backdrop-blur-md border border-white/20 flex items-center justify-center text-white/80 hover:text-white hover:bg-black/60 hover:border-white/40 transition-all duration-300 opacity-0 group-hover:opacity-100 z-20",children:e.jsx("svg",{className:"w-5 h-5 md:w-6 md:h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsx("button",{onClick:s=>{s.stopPropagation();const a=J.indexOf(F||J[0]),i=a>=J.length-1?0:a+1;ne(J[i])},className:"absolute right-2 md:right-6 top-1/2 -translate-y-1/2 w-10 h-10 md:w-14 md:h-14 rounded-full bg-black/40 backdrop-blur-md border border-white/20 flex items-center justify-center text-white/80 hover:text-white hover:bg-black/60 hover:border-white/40 transition-all duration-300 opacity-0 group-hover:opacity-100 z-20",children:e.jsx("svg",{className:"w-5 h-5 md:w-6 md:h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 p-10 lg:p-14 z-10 hidden",children:e.jsxs("div",{className:"max-w-5xl",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 mb-2 md:mb-3",children:[e.jsx("div",{className:"w-8 md:w-12 h-[2px] bg-gradient-to-r from-emerald-400 to-emerald-600"}),e.jsx("p",{className:"text-[10px] md:text-xs uppercase tracking-[0.4em] text-emerald-400/90 font-semibold",children:"Your Vehicle"})]}),e.jsxs("h2",{className:"text-2xl md:text-5xl lg:text-6xl font-bold text-white tracking-tight mb-1 md:mb-3",style:{textShadow:"0 4px 30px rgba(0,0,0,0.8)"},children:[t.year," ",t.make," ",t.model]}),t.trim&&e.jsx("p",{className:"text-sm md:text-xl text-white/60 font-light tracking-wide",children:t.trim})]})}),J.length>0&&e.jsx("div",{className:`absolute top-6 md:top-10 right-3 md:right-8 ${Fe?"hidden lg:flex":"hidden md:flex"} items-center gap-3 z-20`,children:e.jsxs("div",{className:"flex items-center gap-2 bg-black/60 backdrop-blur-md rounded-full px-4 py-2 border border-white/10",children:[e.jsxs("div",{className:"flex gap-1",children:[J.slice(0,5).map((s,a)=>e.jsx("div",{className:`w-1.5 h-1.5 rounded-full transition-all duration-300 ${J.indexOf(F||J[0])===a?"bg-white w-4":"bg-white/40"}`},a)),J.length>5&&e.jsxs("span",{className:"text-white/40 text-xs ml-1",children:["+",J.length-5]})]}),e.jsxs("span",{className:"text-white/60 text-xs font-medium",children:[J.indexOf(F||J[0])+1,"/",J.length]})]})})]}),t&&w==="my-cars"&&e.jsx("div",{className:`md:hidden max-w-md mx-auto ${t.status==="sold_waiting"||t.status==="sold"||(o==null?void 0:o.status)==="requested"||(o==null?void 0:o.status)==="waiting"||(o==null?void 0:o.status)==="confirmed"?"max-md:pb-4":""}`,children:e.jsxs("div",{className:`bg-white rounded-2xl md:shadow-xl md:shadow-slate-900/5 overflow-hidden max-md:border-x max-md:border-white max-md:pb-0 pb-4 max-md:rounded-t-none ${t.status==="sold_waiting"||t.status==="sold"||(o==null?void 0:o.status)==="requested"||(o==null?void 0:o.status)==="waiting"||(o==null?void 0:o.status)==="confirmed"?"max-md:rounded-b-2xl max-md:border-b max-md:border-b-white":"max-md:rounded-b-none"}`,children:[e.jsxs("div",{className:"p-5 max-md:pb-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("h2",{className:"text-[16px] font-bold leading-[1.2]",style:{color:"#0a2e2e"},children:[t.year," ",t.make," ",t.model]}),e.jsx("button",{onClick:()=>Ns(s=>!s),"aria-expanded":js,className:"shrink-0 px-3.5 py-1.5 rounded-full bg-white border border-slate-300 text-[10px] font-bold tracking-[0.18em] uppercase text-slate-700 hover:bg-slate-50 transition-colors",children:js?"Hide Info":"Vehicle Info"})]}),(t.trim||t.mileage)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:[t.trim?`${t.trim}
28 · `:"",t.mileage?`${Number(t.mileage).toLocaleString()} mi`:""]}),t.vin&&e.jsxs("p",{className:"text-[11px] text-muted-foreground/70 mt-1.5 font-mono tracking-wide",children:["VIN ",t.vin]})]}),e.jsx("div",{className:`grid transition-all duration-500 ease-out ${js?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"}`,children:e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"px-5 pb-5",children:e.jsxs("div",{className:"bg-background border border-border rounded-xl p-3 space-y-2",children:[(()=>{const s=[["Year",t.year],["Make",t.make],["Model",t.model],["Trim",t.trim],["Mileage",t.mileage?`${Number(t.mileage).toLocaleString()} mi`:null],["Transmission",t.transmission],["Drivetrain",t.drivetrain],["Engine",t.engine],["Color",t.color],["Fuel",t.fuelType],["VIN",t.vin],["Title",t.titleStatus||"Clean"],["Condition",t.condition]].filter(([,a])=>a);return e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-0",children:s.map(([a,i])=>e.jsxs("div",{className:"flex items-center justify-between gap-2 py-1 border-b border-border last:border-b-0 sm:[&:nth-last-child(-n+2)]:border-b-0",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground",children:a}),e.jsx("span",{className:"text-xs font-bold text-foreground text-right truncate",children:i})]},a))})})(),(()=>{const s=xs(t.description);return s?e.jsxs("div",{className:"pt-2 border-t border-border",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground mb-1",children:"Description"}),e.jsx("p",{className:"text-xs text-foreground leading-relaxed",children:s})]}):null})(),e.jsx("div",{className:"flex justify-center",children:e.jsx("button",{onClick:()=>Ns(!1),className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full bg-background border border-border text-muted-foreground text-[11px] font-medium hover:bg-muted transition-colors",children:"Hide Vehicle Info"})})]})})})}),Fe&&(Cs?e.jsxs("div",{className:"px-5 py-5 border-t border-slate-100",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-emerald-500 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-500/25",children:e.jsx(ae,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold tracking-[0.15em] uppercase text-emerald-700",children:"Submitted for Review"}),e.jsx("p",{className:"text-[10px] text-slate-500 font-medium",children:"Pending Admin Review"})]})]}),e.jsx("p",{className:"text-sm text-slate-600 leading-relaxed mb-4",children:"Your vehicle information has been submitted. Our team is reviewing your details and will start your sale soon."}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-full bg-emerald-50 text-emerald-700 text-xs font-medium",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"Pending Admin Review"]})]}):e.jsxs("div",{className:"px-5 py-5 border-t border-slate-100 space-y-4",children:[e.jsx("h3",{className:"font-bold text-slate-800 dark:text-white text-xl",children:"Your Instant Cash Offer"}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-2xl border-2 border-emerald-500 shadow-lg shadow-emerald-500/10 overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-emerald-500 to-teal-500 px-4 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-white/20 flex items-center justify-center",children:e.jsx(rt,{className:"w-4 h-4 text-white"})}),e.jsx("span",{className:"text-white font-semibold text-sm uppercase tracking-wide",children:"Clear Car Instant Offer"})]})}),e.jsxs("div",{className:"p-5 relative",children:[e.jsx("span",{className:"absolute top-2 right-2 px-2 py-1 text-[10px] font-bold uppercase tracking-wide bg-emerald-100 text-emerald-700 dark:bg-emerald-900/50 dark:text-emerald-300 rounded-full animate-pulse shadow-sm",children:"Fast, Easy, Hassle-Free"}),t.suggestedSellingPrice||t.clearCarMid?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-4xl font-bold text-emerald-600 dark:text-emerald-400 mt-5 mb-2",children:["$",(t.suggestedSellingPrice||t.clearCarMid).toLocaleStr
28ing()]}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-gray-400 mb-4",children:"Based on your vehicle's condition and market data"}),!t.suggestedSellingPrice&&t.clearCarLow&&t.clearCarHigh&&e.jsx("div",{className:"flex items-center gap-3 text-xs text-slate-400 dark:text-gray-500 mb-4",children:e.jsxs("span",{children:["Range: $",t.clearCarLow.toLocaleString()," - $",t.clearCarHigh.toLocaleString()]})}),yt&&e.jsx(I,{onClick:()=>{Le({type:"instant_cash",amount:t.suggestedSellingPrice||t.clearCarMid,dealerId:yt.id,dealerName:yt.name}),Be(!0)},className:"w-full h-12 text-base font-bold bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-700 hover:to-teal-700 text-white shadow-lg shadow-emerald-600/30",children:"Accept Instant Cash Offer"})]}):e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"text-slate-400 dark:text-gray-500 mb-2",children:"No instant offer available"}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-gray-400",children:"Start your sale to get offers from dealers"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-2xl border-2 border-blue-500 shadow-lg shadow-blue-500/10 overflow-hidden flex flex-col",children:[e.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-indigo-500 px-4 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-white/20 flex items-center justify-center",children:e.jsx(ae,{className:"w-4 h-4 text-white"})}),e.jsx("span",{className:"text-white font-semibold text-sm uppercase tracking-wide",children:"Take the CarSolve Challenge"})]})}),e.jsxs("div",{className:"p-5 flex flex-col flex-1 relative",children:[e.jsx("span",{className:"absolute top-2 right-2 px-2 py-1 text-[10px] font-bold uppercase tracking-wide bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300 rounded-full animate-pulse shadow-sm",children:"24-48 hrs • Get the Most Money"}),e.jsx("p",{className:"text-slate-700 dark:text-gray-300 mb-4 flex-1 mt-6",children:"We believe our dealer network will beat any instant offer. Start your auction and let dealers compete for your vehicle!"}),e.jsx(I,{onClick:()=>Ke(!0),size:"lg",className:"w-full h-14 text-lg font-bold bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 text-white shadow-xl shadow-blue-600/30",children:"Start Your Sale"})]})]})]})),t.status==="sold_waiting"&&!(o!=null&&o.status)&&(le?e.jsxs("div",{className:"px-5 py-5 border-t border-slate-100",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-emerald-500 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-500/25",children:e.jsx(ae,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold tracking-[0.15em] uppercase text-emerald-700",children:"Counter Offer Accepted"}),e.jsx("p",{className:"text-[10px] text-slate-500 font-medium",children:"Action Required"})]})]}),e.jsxs("p",{className:"text-sm text-slate-600 leading-relaxed mb-4",children:[e.jsx("span",{className:"font-medium text-slate-800",children:(m==null?void 0:m.dealership_name)||t.highBidderName||"The dealer"})," ","accepted your counter offer"]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500 mb-1 font-medium",children:"Agreed Sale Price"}),e.jsxs("p",{className:"text-2xl font-light tracking-tight text-emerald-600",children:["$",(t.sale_price||le.amount).toLocaleString()]})]}),e.jsx(ft,{winningDealer:m,offers:L,displayBestAmount:t.sale_price||le.amount,bidderCount:t.bidCount||L.length||0,vin:t.vin}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl bg-emerald-50/50 border border-emerald-100",children:[e.jsx(oe,{className:"w-5 h-5 text-emerald-600"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-800",children:"Ready to Finalize Your Sale"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Review details and schedule your appointment"})]}),e.jsx(I,{onClick:()=>
28{Le({type:"bid",amount:t.sale_price||le.amount,dealerId:t.highBidderId||"",dealerName:(m==null?void 0:m.dealership_name)||t.highBidderName||"Dealer"}),Be(!0)},size:"sm",className:"flex-shrink-0 bg-emerald-600 hover:bg-emerald-700 text-white",children:"Schedule"})]})]}):e.jsxs("div",{className:"px-5 py-5 border-t border-slate-100",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-emerald-500 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-500/25",children:e.jsx(ae,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold tracking-[0.15em] uppercase text-emerald-700",children:"Offer Accepted"}),e.jsx("p",{className:"text-[10px] text-slate-500 font-medium",children:"Action Required"})]})]}),e.jsxs("p",{className:"text-sm text-slate-600 leading-relaxed mb-4",children:["Congratulations! Your offer from"," ",e.jsx("span",{className:"font-medium text-slate-800",children:t.highBidderName||"the dealer"})," ","has been accepted"]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500 mb-1 font-medium",children:"Sale Price"}),e.jsxs("p",{className:"text-2xl font-light tracking-tight text-emerald-600",children:["$",(t.sale_price||t.currentBid||0).toLocaleString()]})]}),e.jsx(ft,{winningDealer:m,offers:L,displayBestAmount:t.sale_price||t.currentBid||0,bidderCount:t.bidCount||L.length||0,vin:t.vin}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl bg-emerald-50/50 border border-emerald-100 mt-3",children:[e.jsx(oe,{className:"w-5 h-5 text-emerald-600"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-800",children:"Schedule Your Appointment"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Select a convenient time to complete the sale"})]}),e.jsx(I,{onClick:()=>{Le({type:"bid",amount:t.sale_price||t.currentBid||0,dealerId:t.highBidderId||t.high_bidder_id||"",dealerName:t.highBidderName||"Dealer"}),Oe(!0)},size:"sm",className:"flex-shrink-0 bg-emerald-600 hover:bg-emerald-700 text-white",children:"Schedule"})]})]})),!["ended","archived","cancelled"].includes(t.status)&&((o==null?void 0:o.status)==="requested"||(o==null?void 0:o.status)==="waiting"||(o==null?void 0:o.status)==="confirmed")&&e.jsxs("div",{className:"px-5 py-5 border-t border-slate-100",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-emerald-500 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-500/25",children:e.jsx(ae,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold tracking-[0.15em] uppercase text-emerald-700",children:"Offer Accepted"}),e.jsx("p",{className:"text-[10px] text-slate-500 font-medium",children:(o==null?void 0:o.status)==="confirmed"?"Confirmed":"Pending"})]})]}),e.jsx("p",{className:"text-sm text-slate-600 leading-relaxed mb-4",children:(o==null?void 0:o.status)==="confirmed"?"Appointment to Finalize Sale Successfully Confirmed and Scheduled":"Appointment Successfully Requested – Waiting for Confirmation from Buyer"}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500 mb-1 font-medium",children:"Sale Price"}),e.jsxs("p",{className:"text-2xl font-light tracking-tight text-emerald-600",children:["$",(t.sale_price||ht).toLocaleString()]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"*Offer is Guaranteed Pending Inspection"})]}),(o==null?void 0:o.status)==="confirmed"?e.jsxs("div",{className:"space-y-3",children:[(()=>{const s=o==null?void 0:o.date;if(!s)return null;const[a,i,c]=s.split("-").map(Number),p=new Date(a,i-1,c),f=p.toLocaleDateString("en-US",{month:"short"}).toUpperCase(),$=p.getDate(),S=p.toLocaleDateString("en-US",{weekday:"long"}),R=p.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"});return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl bg-emerald-50/50 border border-emerald-100",children:[e.jsxs("div",{className:"w-12 h-12 rounded-xl bg-white border border-emerald-200 flex flex-col items-center justify-center shadow-sm shrink-0",children:[e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider text-emerald-600 leading-none",children:f}),e.jsx("span",{className:"text-lg font-bold text-slate-900 leading-none mt-0.5",children:$})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Scheduled For"}),e.jsxs("p",{className:"text-sm font-semibold text-slate-800 truncate",children:[S,", ",R]}),e.jsx("p",{className:"text-xs font-medium text-emerald-700 mt-0.5",children:o==null?void 0:o.time})]})]})})(),((m==null?void 0:m.dealership_name)||(t==null?void 0:t.highBidderName))&&e.jsxs("div",{className:"p-3 rounded-xl bg-slate-50 border border-slate-100",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[m!=null&&m.logo_url?e.jsx("img",{src:m.logo_url,alt:m.dealership_name||"Dealer",className:"w-10 h-10 rounded-lg object-contain bg-white border border-slate-200 p-0.5 flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center text-primary font-bold text-sm flex-shrink-0",children:((m==null?void 0:m.dealership_name)||(t==null?void 0:t.highBidderName)||"D").slice(0,2).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Purchasing Dealer"}),e.jsx("p",{className:"text-sm font-semibold text-slate-800 leading-snug",children:(m==null?void 0:m.dealership_name)||(t==null?void 0:t.highBidderName)}),(m==null?void 0:m.dealership_address)&&e.jsxs("p",{className:"text-xs text-slate-600 mt-1 flex items-start gap-1",children:[e.jsx(Re,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-slate-400"}),e.jsx("span",{className:"leading-snug",children:m.dealership_address})]}),(m==null?void 0:m.preferred_contact_name)&&e.jsxs("p",{className:"text-xs text-slate-600 mt-1 flex items-start gap-1",children:[e.jsx(dt,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-slate-400"}),e.jsxs("span",{className:"leading-snug",children:["Ask for: ",m.preferred_contact_name]})]})]})]}),(m==null?void 0:m.dealership_address)&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs("a",{href:`https://maps.apple.com/?q=${encodeURIComponent(m.dealership_address)}`,target:"_blank",rel:"noopener noreferrer",className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-white border border-slate-200 px-3 py-2 text-xs font-medium text-slate-700 hover:bg-slate-50 transition-colors",children:[e.jsx(Wa,{className:"w-3.5 h-3.5 text-slate-500"}),"Apple Maps"]}),e.jsxs("a",{href:`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(m.dealership_address)}`,target:"_blank",rel:"noopener noreferrer",className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-white border border-slate-200 px-3 py-2 text-xs font-medium text-slate-700 hover:bg-slate-50 transition-colors",children:[e.jsx(Re,{className:"w-3.5 h-3.5 text-slate-500"}),"Google Maps"]})]}),e.jsxs("button",{onClick:()=>gs(s=>
28!s),className:"mt-2 w-full flex items-center justify-center gap-1.5 rounded-lg bg-white border border-slate-200 px-3 py-2 text-xs font-medium text-slate-700 hover:bg-slate-50 transition-colors",children:[e.jsx(oe,{className:"w-3.5 h-3.5 text-slate-500"}),At?"Hide Details":"Appointment Details",At?e.jsx(ns,{className:"w-3.5 h-3.5 text-slate-500"}):e.jsx(bt,{className:"w-3.5 h-3.5 text-slate-500"})]}),e.jsx("div",{className:`grid transition-all duration-300 ease-out ${At?"grid-rows-[1fr] opacity-100 mt-3":"grid-rows-[0fr] opacity-0"}`,children:e.jsxs("div",{className:"overflow-hidden space-y-3",children:[e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white overflow-hidden",children:[e.jsx("div",{className:"px-3 py-2 bg-slate-50 border-b border-slate-200",children:e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Vehicle & Transaction"})}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-slate-600",children:[t.year," ",t.make," ",t.model]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-emerald-100 text-emerald-700 text-[10px] font-bold",children:[e.jsx(ae,{className:"w-3 h-3"}),"Confirmed"]})]}),e.jsxs("p",{className:"text-[10px] text-slate-500 font-mono",children:["VIN: ",t.vin]}),e.jsxs("div",{className:"pt-2 border-t border-slate-100",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-0.5",children:"Sale Price"}),e.jsxs("p",{className:"text-xl font-semibold text-emerald-600",children:["$",(t.sale_price||ht).toLocaleString()]})]})]})]}),((m==null?void 0:m.dealership_phone)||(m==null?void 0:m.dealership_website))&&e.jsxs("div",{className:"flex gap-2",children:[(m==null?void 0:m.dealership_phone)&&e.jsxs("a",{href:`tel:${m.dealership_phone}`,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-white border border-slate-200 px-3 py-2 text-xs font-medium text-slate-700 hover:bg-slate-50 transition-colors",children:[e.jsx(vt,{className:"w-3.5 h-3.5 text-slate-500"}),"Call"]}),(m==null?void 0:m.dealership_website)&&e.jsxs("a",{href:m.dealership_website.startsWith("http")?m.dealership_website:`https://${m.dealership_website}`,target:"_blank",rel:"noopener noreferrer",className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-white border border-slate-200 px-3 py-2 text-xs font-medium text-slate-700 hover:bg-slate-50 transition-colors",children:[e.jsx(ms,{className:"w-3.5 h-3.5 text-slate-500"}),"Website"]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white overflow-hidden",children:[e.jsx("div",{className:"px-3 py-2 bg-slate-50 border-b border-slate-200",children:e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"What to Expect"})}),e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("ol",{className:"space-y-2",children:["Upon arrival, the car will have a brief 30-minute inspection to confirm vehicle condition.","If the car passes inspection, sale and DMV documents will be signed and the sale completed.","The dealer will either issue a check or handle loan payoff and finalize the deal."].map((s,a)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-emerald-100 text-[9px] font-semibold text-emerald-700 border border-emerald-200",children:a+1}),e.jsx("span",{className:"text-xs text-slate-700 leading-snug",children:s})]},a))}),e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-emerald-50/50 border border-emerald-100 p-2.5",children:[e.jsx(Ge,{className:"w-3.5 h-3.5 text-emerald-600 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:"The CarSolve Offer is guaranteed pending visual and mechanical inspection. The dealer is only allowed to negotiate for verifiably undisclosed vehicle damage or mechanical issues."})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white overflow-hidden",children:[e.jsx("div",{className:"px-3 py-2 bg-slate-50 border-b border-slate-200",children:e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"What to Bring"})}),e.jsx("div",{className:"p-3 grid grid-cols-2 gap-2",children:[{icon:jt,label:"Vehicle Title"},{icon:nt,label:"Valid Photo ID"},{icon:qs,label:"All Keys & Remotes"},{icon:jt,label:"Service Records"}].map((s,a)=>e.jsxs("div",{className:"flex items-center gap-2 bg-slate-50 rounded-lg px-2.5 py-2 border border-slate-100",children:[e.jsx(s.icon,{className:"w-3.5 h-3.5 text-slate-500 flex-shrink-0"}),e.jsx("span",{className:"text-[11px] font-medium text-slate-700",children:s.label})]},a))})]})]})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 pt-2 border-t border-slate-100",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Need a different time?"}),e.jsxs(I,{variant:"ghost",size:"sm",onClick:()=>kt(!0),className:"text-emerald-700 hover:bg-emerald-50 text-xs font-medium",children:[e.jsx(oe,{className:"w-3.5 h-3.5 mr-1.5"}),"Reschedule"]})]})]}):e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl bg-amber-50/50 border border-amber-100",children:[e.jsx(Ie,{className:"w-5 h-5 text-amber-600"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-800",children:"Appointment Requested"}),e.jsx("p",{className:"text-xs text-slate-500",children:o!=null&&o.date&&(o!=null&&o.time)?`${o.date} at ${o.time} • Awaiting confirmation`:"Awaiting dealer confirmation"})]}),e.jsx(I,{variant:"outline",size:"sm",onClick:()=>wt(!0),className:"flex-shrink-0 border-slate-200 text-slate-600 hover:bg-slate-50 text-xs font-medium",children:"Details"})]})]})]})})]}),J.length>1&&e.jsxs("div",{className:`relative ${Fe?"hidden lg:block":"hidden md:block"} md:bg-gradient-to-b md:from-black md:via-zinc-950 md:to-zinc-900 dark:bg-gray-950 dark:md:to-gray-950 mt-4 lg:mt-0 rounded-lg lg:rou
28nded-t-none lg:border lg:border-white overflow-hidden`,children:[e.jsx("div",{className:"absolute inset-0 hidden md:block bg-[radial-gradient(ellipse_at_center,rgba(16,185,129,0.03),transparent_70%)]"}),e.jsx("div",{className:"relative py-2 md:py-3",children:e.jsx("div",{ref:Us,className:"flex gap-2 md:gap-4 overflow-x-auto pb-2 scrollbar-hide justify-start items-center",children:J.map((s,a)=>{const i=/\.(mp4|webm|ogg|mov)$/i.test(s)||s.includes("video");return e.jsxs("button",{ref:c=>{Ys.current[a]=c},onClick:()=>ne(s),className:`group/thumb relative flex-shrink-0 rounded-lg md:rounded-xl overflow-hidden transition-opacity duration-300 ${(F||J[0])===s?"w-16 h-11 md:w-28 md:h-20 lg:w-32 lg:h-22 ring-2 ring-emerald-500/80 shadow-lg shadow-emerald-500/20":"w-16 h-11 md:w-28 md:h-20 lg:w-32 lg:h-22 opacity-40 hover:opacity-80 grayscale hover:grayscale-0"}`,children:[i?e.jsx("video",{src:s,className:"w-full h-full object-cover",muted:!0}):e.jsx("img",{src:s,alt:`View ${a+1}`,className:"w-full h-full object-cover"}),e.jsx("div",{className:`absolute inset-0 transition-opacity duration-300 ${(F||J[0])===s?"bg-gradient-to-t from-emerald-500/20 to-transparent":"bg-black/20 group-hover/thumb:bg-transparent"}`}),i&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-6 h-6 md:w-8 md:h-8 rounded-full bg-black/60 flex items-center justify-center",children:e.jsx("svg",{className:"w-3 h-3 md:w-4 md:h-4 text-white ml-0.5",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M8 5v14l11-7z"})})})}),(F||J[0])===s&&e.jsx("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 w-6 h-1 bg-emerald-500 rounded-full"})]},a)})})})]}),e.jsx("div",{className:"hidden lg:block mt-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-2xl border border-white shadow-xl shadow-slate-900/5 overflow-hidden",children:e.jsx("div",{className:"p-5",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-bold text-slate-900 dark:text-white leading-tight",children:[t.year," ",t.make," ",t.model]}),(t.trim||t.mileage)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[t.trim?`${t.trim} · `:"",t.mileage?`${Number(t.mileage).toLocaleString()} mi`:""]}),t.vin&&e.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1 font-mono tracking-wide",children:["VIN ",t.vin]})]}),e.jsx("button",{onClick:()=>se(!0),className:"shrink-0 px-3.5 py-1.5 rounded-full bg-white border border-slate-300 text-[10px] font-bold tracking-[0.18em] uppercase text-slate-700 hover:bg-slate-50 transition-colors",children:"Vehicle Info"})]})})})})]}),e.jsx("div",{className:"hidden lg:flex lg:flex-col lg:gap-4",children:(o==null?void 0:o.status)==="requested"||(o==null?void 0:o.status)==="waiting"||(o==null?void 0:o.status)==="confirmed"?nr():t.status==="sold"?dr():(t.status==="on_offer"||t.status==="dealer_counter")&&(le||te)&&!(o!=null&&o.status)?e.jsx(Ca,{carStatus:t.status,customerCounterAmount:le==null?void 0:le.amount,customerCounterTimestamp:le==null?void 0:le.timestamp,dealerCounterAmount:te==null?void 0:te.amount,dealerCounterTimestamp:te==null?void 0:te.timestamp,dealerName:(te==null?void 0:te.dealerName)||(m==null?void 0:m.dealership_name)||t.highBidderName,dealerLogo:(te==null?void 0:te.dealerLogo)||(m==null?void 0:m.logo_url),onAcceptDealerCounter:Zs,onCounterAgain:Xs}
28):t.status==="active"&&de>0?Qs("lg"):t.status==="sold_waiting"&&!le&&!(o!=null&&o.status)?lr():t.status==="ended"&&!(o!=null&&o.status)?ir():Fe||Cs?e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-2xl shadow-xl shadow-slate-900/5 overflow-hidden p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-emerald-500 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-500/25",children:e.jsx(ae,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold tracking-[0.15em] uppercase text-emerald-700",children:"Submitted for Review"}),e.jsx("p",{className:"text-[10px] text-slate-500 font-medium",children:"Pending Admin Review"})]})]}),e.jsx("p",{className:"text-sm text-slate-600 dark:text-gray-300 leading-relaxed mb-4",children:"Your vehicle information has been submitted. Our team is reviewing your details and will start your sale soon."}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-full bg-emerald-50 text-emerald-700 text-xs font-medium",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"Pending Admin Review"]})]}):null})]})]}),e.jsxs("div",{className:"max-md:px-4",children:[t&&w==="my-cars"&&t.status==="ended"&&!(o!=null&&o.status)&&e.jsxs("div",{className:"md:px-6 lg:px-8 py-4 md:py-6 max-md:pt-3 max-md:max-w-md max-md:mx-auto max-md:bg-transparent md:bg-gradient-to-b md:from-zinc-900 md:to-slate-50 dark:bg-gray-950 dark:md:from-zinc-900 dark:md:to-gray-950 lg:hidden",children:[e.jsx("h3",{className:"hidden md:block font-bold text-slate-800 md:text-white dark:text-white mb-3 md:mb-4 text-xl md:text-2xl",children:"Auction Complete"}),e.jsxs("div",{className:"max-md:bg-white max-md:rounded-b-2xl max-md:rounded-t-none max-md:shadow-xl max-md:shadow-slate-900/5 max-md:border max-md:border-slate-100 max-md:border-t-0 max-md:overflow-hidden space-y-4 max-md:p-3",children:[t.highBidderId&&de>0&&e.jsxs("div",{className:"group relative overflow-hidden rounded-2xl border border-emerald-500/20 dark:border-emerald-400/20 bg-gradient-to-br from-white via-emerald-50/30 to-white dark:from-gray-900 dark:via-emerald-950/20 dark:to-gray-900 shadow-lg shadow-emerald-500/5 hover:shadow-xl hover:shadow-emerald-500/10 transition-all duration-500",children:[e.jsx("div",{className:"absolute -top-20 -right-20 w-64 h-64 bg-gradient-to-br from-emerald-400/20 to-transparent rounded-full blur-3xl"}),e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-emerald-500 via-emerald-400 to-teal-500"}),e.jsxs("div",{className:"relative p-5 md:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex items-center justify-center w-11 h-11 rounded-full bg-gradient-to-br from-emerald-500 to-emerald-600 shadow-md shadow-emerald-500/30",children:e.jsx(ae,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.18em] text-emerald-600 dark:text-emerald-400 font-bold",children:"Auction Complete"}),e.jsx("h3",{className:"text-lg font-bold text-foreground tracking-tight",children:"Winning Bid Ready"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded-full bg-emerald-100 dark:bg-emerald-900/40",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),e.jsx("span",{className:"text-[10px] font-semibold text-emerald-700 dark:text-emerald-300 uppercase tracking-wider",children:"Live"})]})]}),(()=>{const s=ts||(m==null?void 0:m.dealership_name)||t.highBidderName||"Winning Bidder",a=m==null?void 0:m.logo_url;return e.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 rounded-xl bg-white/70 dark:bg-gray-800/50 border border-border/40 backdrop-blur-sm",children:[a?e.jsx("img",{src:a,alt:s,className:"w-10 h-10 rounded-lg object-contain bg-white border border-slate-200 p-1 flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-600 flex items-center justify-center text-white font-bold text-sm flex-shrink-0 shadow-sm",children:s.charAt(0).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:"Highe
28st Bidder"}),e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:s})]})]})})(),e.jsxs("div",{className:"mb-5 pb-5 border-b border-dashed border-border/60",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1 font-medium",children:"Highest Offer"}),e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-2xl font-light text-emerald-600 dark:text-emerald-400",children:"$"}),e.jsx("span",{className:"text-4xl md:text-5xl font-bold bg-gradient-to-r from-emerald-600 to-emerald-700 dark:from-emerald-400 dark:to-emerald-500 bg-clip-text text-transparent tracking-tight",children:de.toLocaleString()})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(I,{onClick:Dt,size:"lg",className:"w-full h-12 text-base font-semibold tracking-wide bg-gradient-to-r from-emerald-600 to-emerald-700 hover:from-emerald-700 hover:to-emerald-800 text-white shadow-lg shadow-emerald-900/20 border-0",children:"Review Offer"}),e.jsx(I,{onClick:()=>T(!0),variant:"outline",size:"sm",className:"w-full h-10 text-sm font-medium border border-amber-400/50 bg-transparent text-amber-700 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-300 hover:bg-amber-50 dark:hover:bg-amber-950/30 hover:border-amber-500",children:"Counter Offer"})]})]})]}),ge>0&&e.jsxs("div",{className:"group relative overflow-hidden rounded-2xl border border-blue-500/20 dark:border-blue-400/20 bg-gradient-to-br from-white via-blue-50/30 to-white dark:from-gray-900 dark:via-blue-950/20 dark:to-gray-900 shadow-lg shadow-blue-500/5 hover:shadow-xl hover:shadow-blue-500/10 transition-all duration-500",children:[e.jsx("div",{className:"absolute -top-20 -right-20 w-64 h-64 bg-gradient-to-br from-blue-400/20 to-transparent rounded-full blur-3xl"}),e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-blue-500 via-indigo-400 to-blue-600"}),e.jsxs("div",{className:"relative p-5 md:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex items-center justify-center w-11 h-11 rounded-full bg-gradient-to-br from-blue-500 to-blue-600 shadow-md shadow-blue-500/30",children:e.jsx(rt,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.18em] text-blue-600 dark:text-blue-400 font-bold",children:"Direct Offer"}),e.jsx("h3",{className:"text-lg font-bold text-foreground tracking-tight",children:"Offer Available"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded-full bg-blue-100 dark:bg-blue-900/40",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-500 animate-pulse"}),e.jsx("span",{className:"text-[10px] font-semibold text-blue-700 dark:text-blue-300 uppercase tracking-wider",children:"New"})]})]}),je&&e.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 rounded-xl bg-white/70 dark:bg-gray-800/50 border border-border/40 backdrop-blur-sm",children:[v!=null&&v.dealerLogo?e.jsx("img",{src:v.dealerLogo,alt:je,className:"w-10 h-10 rounded-lg object-contain bg-white border border-slate-200 p-1 flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-blue-500 to-indigo-600 flex items-center justify-center text-white font-bold text-sm flex-shrink-0 shadow-sm",children:je.charAt(0).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:"From Dealership"}),e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:je})]})]}),e.jsxs("div",{className:"mb-5 pb-5 border-b border-dashed border-border/60",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1 font-medium",children:"Offer Amount"}),e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-2xl font-light text-blue-600 dark:text-blue-400",children:"$"}),e.jsx("span",{className:"text-4xl md:text-5xl font-bold bg-gradient-to-r from-blue-600 to-indigo-700 dark:from-blue-400 dark:to-indigo-400 bg-clip-text text-transparent tracking-tight",children:ge.toLocaleStr
28ing()})]})]}),e.jsx(I,{onClick:_t,size:"lg",className:"w-full h-12 text-base font-semibold tracking-wide bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800 text-white shadow-lg shadow-blue-900/20 border-0",children:"Review Offer"})]})]})]})]}),t&&w==="my-cars"&&Fe&&e.jsx("div",{className:"hidden md:block px-4 md:px-6 lg:px-8 py-4 md:py-6 md:bg-gradient-to-br md:from-emerald-50 md:via-white md:to-blue-50 dark:from-gray-900 dark:via-gray-950 dark:to-gray-900",children:Cs?e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-2xl border-2 border-emerald-500 shadow-lg shadow-emerald-500/10 overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-emerald-500 to-teal-500 px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-white/20 flex items-center justify-center",children:e.jsx(ae,{className:"w-5 h-5 text-white"})}),e.jsx("span",{className:"text-white font-bold text-lg",children:"Submitted for Review"})]})}),e.jsxs("div",{className:"p-6 text-center",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-emerald-100 dark:bg-emerald-900/40 flex items-center justify-center",children:e.jsx(Ie,{className:"w-8 h-8 text-emerald-600 dark:text-emerald-400"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-800 dark:text-white mb-2",children:"Your Vehicle is in Queue"}),e.jsx("p",{className:"text-slate-600 dark:text-gray-400 mb-4 max-w-md mx-auto",children:"Thank you for submitting your vehicle information! Our team is reviewing your details and will start your sale soon. You'll be notified when your vehicle goes live."}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-emerald-50 dark:bg-emerald-900/30 text-emerald-700 dark:text-emerald-300 text-sm font-medium",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse"}),"Pending Admin Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"font-bold text-slate-800 dark:text-white mb-3 md:mb-4 text-xl md:text-2xl",children:"Your Instant Cash Offer"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-2xl border-2 border-emerald-500 shadow-lg shadow-emerald-500/10 overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-emerald-500 to-teal-500 px-4 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-white/20 flex items-center justify-center",children:e.jsx(rt,{className:"w-4 h-4 text-white"})}),e.jsx("span",{className:"text-white font-semibold text-sm uppercase tracking-wide",children:"Clear Car Instant Offer"})]})}),e.jsxs("div",{className:"p-5 relative",children:[e.jsx("span",{className:"absolute top-2 right-2 px-2 py-1 text-[10px] font-bold uppercase tracking-wide bg-emerald-100 text-emerald-700 dark:bg-emerald-900/50 dark:text-emerald-300 rounded-full animate-pulse shadow-sm",children:"Fast, Easy, Hassle-Free"}),t.suggestedSellingPrice||t.clearCarMid?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-4xl md:text-5xl font-bold text-emerald-600 dark:text-emerald-400 mb-2",children:["$",(t.suggestedSellingPrice||t.clearCarMid).toLocaleString()]}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-gray-400 mb-4",children:"Based on your vehicle's condition and market data"}),!t.suggestedSellingPrice&&t.clearCarLow&&t.clearCarHigh&&e.jsx("div",{className:"flex items-center gap-3 text-xs text-slate-400 dark:text-gray-500 mb-4",children:e.jsxs("span",{children:["Range: $",t.clearCarLow.toLocaleString()," - $",t.clearCarHigh.toLocaleString()]})}),yt&&e.jsx(I,{onClick:()=>{Le({type:"instant_cash",amount:t.suggestedSellingPrice||t.clearCarMid,dealerId:yt.id,dealerName:yt.name}),Be(!0)},className:"w-full h-12 text-base font-bold bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-700 hover:to-teal-700 text-white shadow-lg shadow-emerald-600/30",children:"Accept Instant Cash Offer"})]}):e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"text-slate-400 dark:text-gray-500 mb-2",children:"No instant offer available"}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-gray-400",children:"Start your sale to get offers from dealers"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-2xl border-2 border-blue-500 shadow-lg shadow-blue-500/10 overflow-hidden flex flex-col",children:[e.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-indigo-500 px-4 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-white/20 flex items-center justify-center",children:e.jsx(ae,{className:"w-4 h-4 text-white"})}),e.jsx("span",{className:"text-white font-semibold text-sm uppercase tracking-wide",children:"Take the CarSolve Challenge"})]})}),e.jsxs("div",{className:"p-5 flex flex-col flex-1 relative",children:[e.jsx("span",{className:"absolute top-2 right-2 px-2 py-1 text-[10px] font-bold uppercase tracking-wide bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300 rounded-full animate-pulse shadow-sm",children:"24-48 hrs • Get the Most Money"}),e.jsx("p",{className:"text-slate-700 dark:text-gray-300 mb-4 flex-1 mt-6",children:"We believe our dealer network will beat any instant offer. Start your auction and let dealers compete for your vehicle!"}),e.jsx(I,{onClick:()=>Ke(!0),size:"lg",className:"w-full h-14 text-lg font-bold bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 text-white shadow-xl shadow-blue-600/30",children:"Start Your Sale"})]})]})]})]})}),t&&w==="my-cars"&&t.status==="sold"&&e.jsx("div",{className:"px-4 md:px-6 lg:px-8 py-4 md:py-6 max-md:pt-0 max-md:pb-4 max-md:max-w-md max-md:mx-auto bg-white rounded-b-2xl shadow-xl shadow-slate-900/5 lg:hidden",children:e.jsxs("div",{className:"relative overflow-hidden rounded-2xl max-md:rounded-t-none bg-gradient-to-br from-emerald-50 via-white to-emerald-50/50 dark:from-emerald-950/30 dark:via-gray-900 dark:to-emerald-950/20 border border-emerald-200/60 dark:border-emerald-800/30 max-md:border-t-0 shadow-xl",children:[e.jsx("div",{className:"absolute top-0 right-0 w-48 h-48 bg-gradient-to-bl from-emerald-200/30 dark:from-emerald-800/10 to-transparent roun
28ded-full -translate-y-1/2 translate-x-1/4"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-32 h-32 bg-gradient-to-tr from-emerald-200/20 dark:from-emerald-800/5 to-transparent rounded-full translate-y-1/2 -translate-x-1/4"}),e.jsxs("div",{className:"relative p-5 md:p-8",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-5",children:[e.jsx("div",{className:"w-12 h-12 md:w-14 md:h-14 rounded-2xl bg-gradient-to-br from-emerald-500 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-500/20 flex-shrink-0",children:e.jsx(ae,{className:"h-6 w-6 md:h-7 md:w-7 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-xl md:text-2xl font-bold text-slate-900 dark:text-white",children:"Congratulations! 🎉"}),e.jsx("p",{className:"text-sm text-emerald-700 dark:text-emerald-400 font-medium mt-0.5",children:"Your vehicle sale is complete"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 py-4 border-t border-emerald-200/50 dark:border-emerald-800/30",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.15em] text-emerald-600 dark:text-emerald-500 font-semibold",children:"Vehicle Sold"}),e.jsxs("p",{className:"text-base md:text-lg font-semibold text-slate-900 dark:text-white",children:[t.year," ",t.make," ",t.model]})]}),e.jsxs("div",{className:"bg-emerald-100/50 dark:bg-emerald-900/20 rounded-xl px-5 py-3 flex-shrink-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.15em] text-emerald-600 dark:text-emerald-500 font-semibold",children:"Sale Price"}),e.jsxs("p",{className:"text-2xl md:text-3xl font-bold text-emerald-700 dark:text-emerald-400",children:["$",(t.sale_price||t.currentBid||t.startingBid||0).toLocaleString()]})]})]}),((m==null?void 0:m.dealership_name)||(t==null?void 0:t.highBidderName))&&e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl bg-slate-50 dark:bg-gray-800/50 border border-slate-100 dark:border-gray-700/50",children:[m!=null&&m.logo_url?e.jsx("img",{src:m.logo_url,alt:m.dealership_name||"Dealer",className:"w-12 h-12 rounded-xl object-contain bg-white dark:bg-gray-900 border border-emerald-200/50 dark:border-emerald-800/30 flex-shrink-0 p-1"}):e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-emerald-100 to-emerald-50 dark:from-emerald-900/40 dark:to-emerald-900/20 border border-emerald-200/50 dark:border-emerald-800/30 flex items-center justify-center flex-shrink-0",children:e.jsx(dt,{className:"h-6 w-6 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs text-slate-500 dark:text-gray-400",children:"Purchased By"}),e.jsx("p",{className:"text-sm font-bold text-slate-900 dark:text-white truncate",children:(m==null?void 0:m.dealership_name)||(t==null?void 0:t.highBidderName)})]})]}),e.jsx("div",{className:"pt-3 border-t border-emerald-200/50 dark:border-emerald-800/30",children:e.jsxs("p",{className:"text-sm text-slate-600 dark:text-gray-400 text-center",children:["Thank you for using ",e.jsx("span",{className:"font-semibold text-emerald-700 dark:text-emerald-400",children:"CarSolve"}),"! We hope your experience was seamless."]})})]})]})]})}),t&&w==="my-cars"&&!Fe&&t.status!=="sold_waiting"&&t.status!=="sold"&&(o==null?void 0:o.status)!=="requested"&&(o==null?void 0:o.status)!=="waiting"&&(o==null?void 0:o.status)!=="confirmed"&&e.jsxs("div",{className:"md:px-6 lg:px-8 py-4 md:py-6 max-md:pt-0 max-md:max-w-md max-md:mx-auto max-md:bg-transparent md:bg-gradient-to-b md:from-zinc-900 md:to-slate-50 dark:bg-gray-950 dark:md:from-zinc-900 dark:md:to-gray-950 lg:hidden",children:[e.jsx("h3",{className:"hidden md:block font-bold text-slate-800 md:text-white dark:text-white mb-3 md:mb-4 text-xl md:text-2xl",children:"Current Offers"}),e.jsxs("div",{className:"max-md:bg-white max-md:rounded-b-2xl max-md:rounded-t-none max-md:border max-md:border-slate-100 max-md:border-t-0 max-md:overflow-hidden",children:[(t.status==="on_offer"||t.status==="dealer_counter")&&(le||te)&&!(o!=null&&o.status)&&e.jsx("div",{children:e.jsx(Ca,{carStatus:t.status,customerCounterAmount:le==null?void 0:le.amount,customerCounterTimestamp:le==null?void 0:le.timestamp,dealerCounterAmount:te==null?void 0:te.amount,dealerCounterTimestamp:te==null?void 0:te.timestamp,dealerName:(te==null?void 0:te.dealerName)||(m==null?void 0:m.dealership_name)||t.highBidderName,dealerLogo:(te==null?void 0:te.dealerLogo)||(m==null?void 0:m.logo_url),onAcceptDealerCounter:Zs,onCounterAgain:Xs}
28)}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 md:gap-4 max-md:px-3 max-md:pt-4 max-md:pb-3 lg:hidden",children:[e.jsxs("div",{className:"md:hidden bg-white dark:bg-gray-900 rounded-2xl border border-slate-200 dark:border-gray-700 px-5 pb-5 pt-10 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ge,{className:"w-4 h-4 text-emerald-600 flex-shrink-0",strokeWidth:2.5}),e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-[0.08em] text-emerald-700 dark:text-emerald-400 truncate",children:"Top Verified Dealer Offer"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 border border-emerald-500/60 rounded-full pl-2 pr-2.5 py-0.5 flex-shrink-0",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),e.jsx("span",{className:"text-[11px] font-bold text-emerald-600 dark:text-emerald-400 tracking-wide",children:"LIVE"})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-2 min-w-0",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"text-[34px] font-black text-slate-900 dark:text-white leading-none tracking-tight truncate",children:["$",de.toLocaleString()]})}),t.endTime&&(()=>{const s=new Date(t.endTime).getTime()-Ha;if(s<=0)return null;const a=Math.floor(s/36e5),i=Math.floor(s%36e5/6e4),c=Math.floor(s%6e4/1e3),f=new Date(t.endTime).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"});return e.jsxs("div",{className:"flex-shrink-0 border border-slate-200 dark:border-gray-700 rounded-lg px-2.5 py-1.5 text-center",children:[e.jsxs("div",{className:"flex items-center gap-1 justify-center mb-0.5",children:[e.jsx(Ie,{className:"w-3 h-3 text-slate-700 dark:text-gray-300 flex-shrink-0"}),e.jsx("span",{className:"text-[11px] font-bold text-slate-900 dark:text-white",children:a>0?`${a}h ${i}m ${c}s left`:i>0?`${i}m ${c}s left`:`${c}s left`})]}),e.jsxs("div",{className:"text-[10px] text-slate-500 dark:text-gray-400 whitespace-nowrap",children:["Auction ends ",f]})]})})()]}),e.jsx("p",{className:"text-[13px] text-slate-500 dark:text-gray-400 leading-snug mb-4",children:"Bidding is active. Most offers and bids arrive the last hour of the listing."}),t.reservePrice&&t.reservePrice>0&&(()=>{const s=Math.min(100,Math.round(de/t.reservePrice*100)),a=t.reservePrice-de;return e.jsxs("div",{className:"border border-slate-200 dark:border-gray-700 rounded-xl p-4 mb-3",children:[e.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500 dark:text-gray-400 mb-3",children:"Offer vs. Target"}),e.jsxs("div",{className:"relative w-full h-1.5 bg-slate-200 dark:bg-gray-700 rounded-full mb-3",children:[e.jsx("div",{className:"absolute top-0 left-0 h-full bg-emerald-500 rounded-full transition-all duration-500",style:{width:`${s}%`}}),e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 w-4 h-4 rounded-full bg-white border-2 border-emerald-500 shadow-md",style:{left:`calc(${s}% - 8px)`}})]}),e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-[14px] font-bold text-slate-900 dark:text-white leading-tight",children:["$",de.toLocaleString()]}),e.jsx("div",{className:"text-[11px] text-slate-500 dark:text-gray-400",children:"Current Offer"})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"text-[14px] font-bold text-slate-900 dark:text-white leading-tight",children:["$",t.reservePrice.toLocaleString()]}),e.jsx("div",{className:"text-[11px] text-slate-500 dark:text-gray-400",children:"Your Target"})]})]}),a>0&&e.jsxs("div",{className:"text-center mt-2 text-[12px] font-medium text-emerald-600 dark:text-emerald-400",children:["$",a.toLocaleString()," below target"]})]})})(),e.jsxs("div",{className:"border border-slate-200 dark:border-gray-700 rounded-xl p-4 mb-4",children:[e.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500 dark:text-gray-400 mb-2",children:"Live Market Pulse"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("svg",{viewBox:"0 0 120 40",className:"w-1/2 h-10 flex-shrink-0",preserveAspectRatio:"none",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"pulseFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgb(16,185,129)",
28stopOpacity:"0.3"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(16,185,129)",stopOpacity:"0"})]})}),e.jsx("path",{d:"M0,30 L10,28 L20,32 L30,25 L40,27 L50,20 L60,22 L70,15 L80,18 L90,12 L100,14 L110,8 L120,10 L120,40 L0,40 Z",fill:"url(#pulseFill)"}),e.jsx("path",{d:"M0,30 L10,28 L20,32 L30,25 L40,27 L50,20 L60,22 L70,15 L80,18 L90,12 L100,14 L110,8 L120,10",fill:"none",stroke:"rgb(16,185,129)",strokeWidth:"1.5"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] font-semibold text-slate-900 dark:text-white leading-tight",children:"Buyer activity"}),e.jsxs("div",{className:"text-[11px] text-slate-500 dark:text-gray-400",children:[Math.max(t.bidCount||0,A.length,1)," dealer",Math.max(t.bidCount||0,A.length,1)===1?"":"s"," bidding"]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 mb-5",children:[e.jsxs("div",{className:"flex flex-col items-center text-center gap-1",children:[e.jsx(Ge,{className:"w-4 h-4 text-emerald-600"}),e.jsx("div",{className:"text-[10px] font-semibold text-slate-900 dark:text-white leading-tight",children:"Verified Dealers"}),e.jsx("div",{className:"text-[9px] text-slate-500 dark:text-gray-400 leading-tight",children:"Thoroughly vetted"})]}),e.jsxs("div",{className:"flex flex-col items-center text-center gap-1",children:[e.jsx(os,{className:"w-4 h-4 text-emerald-600"}),e.jsx("div",{className:"text-[10px] font-semibold text-slate-900 dark:text-white leading-tight",children:"Secure Process"}),e.jsx("div",{className:"text-[9px] text-slate-500 dark:text-gray-400 leading-tight",children:"Your info is safe"})]}),e.jsxs("div",{className:"flex flex-col items-center text-center gap-1",children:[e.jsx(tl,{className:"w-4 h-4 text-emerald-600"}),e.jsx("div",{className:"text-[10px] font-semibold text-slate-900 dark:text-white leading-tight",children:"No Fees Until Sold"}),e.jsx("div",{className:"text-[9px] text-slate-500 dark:text-gray-400 leading-tight",children:"You pay $0 upfront"})]}),e.jsxs("div",{className:"flex flex-col items-center text-center gap-1",children:[e.jsx(Sa,{className:"w-4 h-4 text-emerald-600"}),e.jsx("div",{className:"text-[10px] font-semibold text-slate-900 dark:text-white leading-tight",children:"Dedicated Support"}),e.jsx("div",{className:"text-[9px] text-slate-500 dark:text-gray-400 leading-tight",children:"We're here to help"})]})]}),t.highBidderId&&de>0&&e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsxs(I,{onClick:Dt,className:"w-full h-12 text-[15px] font-bold bg-emerald-600 hover:bg-emerald-700 text-white border-0 rounded-lg",children:["Accept $",de.toLocaleString()," Offer"]}),e.jsx(I,{onClick:()=>ze(s=>!s),variant:"outline",className:"w-full h-12 text-[14px] font-semibold border border-emerald-600 bg-transparent text-emerald-700 dark:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-950/30 rounded-lg",children:Me?"Hide Bid History":"Wait for More Bids"})]}),A.length>0&&e.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${Me?"max-h-64 mt-3":"max-h-0"}`,children:e.jsx("div",{className:"border border-slate-200 dark:border-gray-700 rounded-xl bg-slate-50/50 dark:bg-gray-800/50 p-3 max-h-56 overflow-y-auto scrollbar-hide space-y-2",children:(()=>{const s=Math.max(...A.map(a=>Number(a.amount)||0));return A.slice(0,10).map((a,i)=>{var c;return e.jsxs("button",{type:"button",onClick:()=>_s(a),className:"w-full flex items-center justify-between gap-2 py-2 px-2 rounded-lg bg-white dark:bg-gray-900/50 border border-slate-100 dark:border-gray-700 hover:border-emerald-300 dark:hover:border-emerald-600 hover:bg-emerald-50/40 dark:hover:bg-emerald-950/20 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[$e[a.dealership_id]?e.jsx("img",{src:$e[a.dealership_id],alt:"Dealership",className:"w-7 h-7 rounded-full object-contain bg-white border border-slate-200 flex-shrink-0"}):e.jsx("div",{className:"w-7 h-7 rounded-full bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center text-white text-[10px] font-bold flex-shrink-0",children:(a.dealership_name||a.dealershipName||"D").charAt(0).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[12px] font-semibold text-slate-800 dark:text-gray-200 leading-tight break-words",children:a.dealership_name||a.dealershipName||"Dealership"}),a.timestamp&&e.jsx("div",{className:"text-[9px] text-slate-400 dark:text-gray-500 leading-tight",children:new Date(a.timestamp).toLocaleStr
28ing("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})})]})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsxs("div",{className:"text-xs font-bold text-slate-900 dark:text-white",children:["$",(c=a.amount)==null?void 0:c.toLocaleString()]}),(Number(a.amount)||0)===s&&s>0&&e.jsx("span",{className:"text-[8px] px-1.5 py-0.5 rounded-full bg-emerald-100 text-emerald-700 dark:bg-emerald-900/50 dark:text-emerald-400 font-medium",children:"HIGH"})]})]},a.id||i)})})()})})]}),e.jsxs("div",{className:`md:hidden bg-white dark:bg-gray-900 rounded-2xl border shadow-sm p-5 overflow-hidden ${v?"border-amber-200 dark:border-amber-400":"border-slate-200 dark:border-gray-700"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full animate-pulse ${v?"bg-amber-500":"bg-slate-300 dark:bg-gray-600"}`}),e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-amber-700 dark:text-amber-400",children:"Direct Offer"})]}),v&&e.jsxs("div",{className:"flex items-center gap-1 bg-amber-100 text-amber-700 px-2 py-0.5 rounded-full text-[10px] font-bold",children:[e.jsx("svg",{className:"w-2.5 h-2.5",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})}),"TOP"]})]}),e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"text-[32px] font-black text-slate-900 dark:text-white leading-none tracking-tight",children:["$",ge.toLocaleString()]}),e.jsx("div",{className:"text-[12px] text-slate-500 dark:text-gray-400",children:ge>0?"Highest direct offer":"No offers yet"})]}),(v||Ss&&ge>0)&&e.jsx("div",{className:"bg-slate-50 dark:bg-gray-800 rounded-lg p-2 mb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[v!=null&&v.dealerLogo?e.jsx("img",{src:v.dealerLogo,alt:je||v.dealerName,className:"w-8 h-8 rounded-lg object-contain bg-white border border-slate-200 p-0.5"}):e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center text-white font-bold text-sm",children:(je||(v==null?void 0:v.dealerName)||"D").charAt(0)}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-xs text-slate-900 dark:text-white",children:je||(v==null?void 0:v.dealerName)||"Dealer"}),e.jsx("div",{className:"text-[10px] text-slate-500",children:"Verified Dealer"})]})]})}),ge>0&&e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx(I,{onClick:_t,className:"w-full h-12 text-[15px] font-bold bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800 text-white border-0 rounded-lg",children:"Accept Offer"}),e.jsx(I,{onClick:()=>T(!0),variant:"outline",className:"w-full h-12 text-[14px] font-semibold border border-amber-400/50 bg-transparent text-amber-700 dark:text-amber-400 hover:bg-amber-50 dark:hover:bg-amber-950/30 hover:border-amber-500 rounded-lg",children:"Counter Offer"})]})]}),Qs()]})]})]})]}),e.jsx("div",{className:`p-4 md:p-6 lg:p-8 max-md:bg-transparent md:bg-slate-50 dark:bg-gray-950 ${w==="my-cars"&&t?"max-md:pt-0":""}`,children:t?e.jsxs("div",{className:"space-y-6",children:[w==="my-cars"&&t.status==="sold_waiting"&&le&&!(o!=null&&o.status)&&e.jsx("div",{className:"hidden md:block px-4 max-w-md mx-auto md:px-0 md:max-w-none md:mx-0",children:e.jsxs("div",{className:"relative overflow-hidden bg-white max-md:rounded-t-none rounded-2xl",children:[e.jsxs("div",{className:"relative bg-gradient-to-br from-white via-slate-50 to-emerald-50/30 dark:from-gray-900 dark:via-gray-900 dark:to-emerald-950/20 rounded-2xl max-md:rounded-t-none border border-slate-200/80 dark:border-emerald-900/30 shadow-xl dark:shadow-emerald-950/20",children:[e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-gradient-to-bl from-emerald-100/40 dark:from-emerald-900/10 to-transparent roun
28ded-full -translate-y-1/2 translate-x-1/2"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-48 h-48 bg-gradient-to-tr from-emerald-100/30 dark:from-emerald-900/10 to-transparent rounded-full translate-y-1/2 -translate-x-1/2"}),e.jsx("div",{className:"relative p-6 md:p-8",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-6",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 md:w-16 md:h-16 bg-gradient-to-br from-emerald-500 to-emerald-600 dark:from-emerald-600 dark:to-emerald-700 rounded-2xl flex items-center justify-center shadow-lg shadow-emerald-500/25 dark:shadow-emerald-900/40",children:e.jsx(ae,{className:"w-7 h-7 md:w-8 md:h-8 text-white"})}),e.jsxs("div",{className:"pt-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"text-xs font-semibold tracking-[0.15em] uppercase text-emerald-700 dark:text-emerald-400",children:"Counter Offer Accepted"}),e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-medium bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300 border border-emerald-200/50 dark:border-emerald-800/50",children:"Action Required"})]}),e.jsxs("p",{className:"text-base md:text-lg font-light text-slate-600 dark:text-gray-300 leading-relaxed",children:[e.jsx("span",{className:"font-medium text-slate-800 dark:text-white",children:(m==null?void 0:m.dealership_name)||t.highBidderName||"The dealer"})," ","accepted your counter offer"]})]})]}),e.jsxs("div",{className:"flex-shrink-0 bg-white/60 dark:bg-gray-800/40 backdrop-blur-sm rounded-xl p-5 md:p-6 border border-slate-200/50 dark:border-emerald-900/30",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500 dark:text-emerald-400/70 mb-2 font-medium text-center md:text-right",children:"Agreed Sale Price"}),e.jsxs("p",{className:"text-3xl md:text-4xl font-light tracking-tight text-emerald-600 dark:text-emerald-400 text-center md:text-right",children:["$",(t.sale_price||le.amount).toLocaleString()]})]})]})})]}),e.jsx(ft,{winningDealer:m,offers:L,displayBestAmount:t.sale_price||le.amount,bidderCount:t.bidCount||L.length||0,vin:t.vin}),e.jsx("div",{className:"mt-4 bg-gradient-to-r from-emerald-50 to-white dark:from-emerald-950/30 dark:to-gray-900/60 backdrop-blur-sm border border-emerald-200/60 dark:border-emerald-800/40 rounded-xl p-4 md:p-5",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 md:w-12 md:h-12 bg-gradient-to-br from-emerald-100 to-emerald-50 dark:from-emerald-900/40 dark:to-emerald-900/20 rounded-xl flex items-center justify-center border border-emerald-200/50 dark:border-emerald-800/30",children:e.jsx(oe,{className:"w-5 h-5 md:w-6 md:h-6 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{className:"flex-1 min-w-0 text-center sm:text-left",children:[e.jsx("p",{className:"text-sm font-medium text-slate-800 dark:text-white mb-0.5",children:"Ready to Finalize Your Sale"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-gray-400",children:"Review details and schedule your appointment to complete the transaction"})]}),e.jsxs(I,{onClick:()=>{Le({type:"bid",amount:t.sale_price||le.amount,dealerId:t.highBidderId||"",dealerName:(m==null?void 0:m.dealership_name)||t.highBidderName||"Dealer"}),Be(!0)},size:"lg",className:"flex-shrink-0 h-11 px-6 text-sm font-semibold bg-gradient-to-r from-emerald-600 to-emerald-700 hover:from-emerald-700 hover:to-emerald-800 text-white shadow-lg shadow-emerald-600/20 border-0 rounded-xl",children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),"Finalize Sale & Schedule"]})]})})]})}),w==="my-cars"&&t.status==="sold_waiting"&&!le&&!(o!=null&&o.status)&&e.jsx("div",{className:"hidden md:block lg:hidden px-4 max-w-md mx-auto md:px-0 md:max-w-none md:mx-0",children:e.jsxs("div",{className:"relative overflow-hidden bg-white max-md:rounded-t-none rounded-2xl",children:[e.jsxs("div",{className:"relative bg-gradient-to-br from-white via-slate-50 to-emerald-50/30 dark:from-gray-900 dark:via-gray-900 dark:to-emerald-950/20 rounded-2xl max-md:rounded-t-none border border-slate-200/80 dark:border-emerald-900/30 shadow-xl dark:shadow-emerald-950/20",children:[e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-gradient-to-bl from-emerald-100/40 dark:from-emerald-900/10 to-transparent roun
28ded-full -translate-y-1/2 translate-x-1/2"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-48 h-48 bg-gradient-to-tr from-emerald-100/30 dark:from-emerald-900/10 to-transparent rounded-full translate-y-1/2 -translate-x-1/2"}),e.jsx("div",{className:"relative p-6 md:p-8",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-6",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 md:w-16 md:h-16 bg-gradient-to-br from-emerald-500 to-emerald-600 dark:from-emerald-600 dark:to-emerald-700 rounded-2xl flex items-center justify-center shadow-lg shadow-emerald-500/25 dark:shadow-emerald-900/40",children:e.jsx(ae,{className:"w-7 h-7 md:w-8 md:h-8 text-white"})}),e.jsxs("div",{className:"pt-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"text-xs font-semibold tracking-[0.15em] uppercase text-emerald-700 dark:text-emerald-400",children:"Offer Accepted"}),e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-medium bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300 border border-emerald-200/50 dark:border-emerald-800/50",children:"Action Required"})]}),e.jsxs("p",{className:"text-base md:text-lg font-light text-slate-600 dark:text-gray-300 leading-relaxed",children:["Congratulations! Your offer from"," ",e.jsx("span",{className:"font-medium text-slate-800 dark:text-white",children:t.highBidderName||"the dealer"})," ","has been accepted"]})]})]}),e.jsxs("div",{className:"flex-shrink-0 bg-white/60 dark:bg-gray-800/40 backdrop-blur-sm rounded-xl p-5 md:p-6 border border-slate-200/50 dark:border-emerald-900/30",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500 dark:text-emerald-400/70 mb-2 font-medium text-center md:text-right",children:"Sale Price"}),e.jsxs("p",{className:"text-3xl md:text-4xl font-light tracking-tight text-emerald-600 dark:text-emerald-400 text-center md:text-right",children:["$",(t.sale_price||t.currentBid||0).toLocaleString()]})]})]})})]}),e.jsx(ft,{winningDealer:m,offers:L,displayBestAmount:t.sale_price||t.currentBid||0,bidderCount:t.bidCount||L.length||0,vin:t.vin}),e.jsx("div",{className:"mt-4 bg-gradient-to-r from-emerald-50 to-white dark:from-emerald-950/30 dark:to-gray-900/60 backdrop-blur-sm border border-emerald-200/60 dark:border-emerald-800/40 rounded-xl p-4 md:p-5",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 md:w-12 md:h-12 bg-gradient-to-br from-emerald-100 to-emerald-50 dark:from-emerald-900/40 dark:to-emerald-900/20 rounded-xl flex items-center justify-center border border-emerald-200/50 dark:border-emerald-800/30",children:e.jsx(oe,{className:"w-5 h-5 md:w-6 md:h-6 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{className:"flex-1 min-w-0 text-center sm:text-left",children:[e.jsx("p",{className:"text-sm font-medium text-slate-800 dark:text-white mb-0.5",children:"Schedule Your Appointment"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-gray-400",children:"Select a convenient time to complete the sale at the dealership"})]}),e.jsxs(I,{onClick:()=>{Le({type:"bid",amount:t.sale_price||t.currentBid||0,dealerId:t.highBidderId||t.high_bidder_id||"",dealerName:t.highBidderName||"Dealer"}),Oe(!0)},size:"lg",className:"flex-shrink-0 h-11 px-6 text-sm font-semibold bg-gradient-to-r from-emerald-600 to-emerald-700 hover:from-emerald-700 hover:to-emerald-800 text-white shadow-lg shadow-emerald-600/20 border-0 rounded-xl",children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),"Schedule Appointment"]})]})})]})}),w==="my-cars"&&t&&t.status==="active"&&de>0&&e.jsxs("div",{id:"all-offers-section",className:"hidden lg:block scroll-mt-24 space-y-4",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-2xl border border-slate-200 dark:border-gray-800 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-slate-100 dar
28k:border-gray-800 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400"}),e.jsx("h3",{className:"text-sm font-bold text-slate-900 dark:text-white",children:"All Dealer Bids"})]}),e.jsxs("span",{className:"text-xs font-medium text-slate-500 dark:text-gray-400",children:[A.length," ",A.length===1?"bid":"bids"]})]}),e.jsx("div",{className:"p-3",children:A.length>0?e.jsx("div",{className:"space-y-2",children:(()=>{const s=Math.max(...A.map(a=>Number(a.amount)||0));return A.map((a,i)=>{var c;return e.jsxs("button",{type:"button",onClick:()=>_s(a),className:"w-full flex items-center justify-between py-2.5 px-3 rounded-lg bg-slate-50/60 dark:bg-gray-800/50 border border-slate-100 dark:border-gray-700 hover:border-emerald-300 dark:hover:border-emerald-600 hover:bg-emerald-50/40 dark:hover:bg-emerald-950/20 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[$e[a.dealership_id]?e.jsx("img",{src:$e[a.dealership_id],alt:"Dealership",className:"w-9 h-9 rounded-full object-cover"}):e.jsx("div",{className:"w-9 h-9 rounded-full bg-slate-900 flex items-center justify-center text-white text-xs font-bold",children:(a.dealership_name||a.dealershipName||"D").charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-slate-800 dark:text-gray-100",children:a.dealership_name||a.dealershipName||"Dealership"}),e.jsx("div",{className:"text-[11px] text-slate-500 dark:text-gray-500",children:new Date(a.timestamp).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})})]})]}),e.jsxs("div",{className:"text-right flex items-center gap-2",children:[e.jsxs("div",{className:"text-base font-bold text-slate-900 dark:text-white",children:["$",(c=a.amount)==null?void 0:c.toLocaleString()]}),(Number(a.amount)||0)===s&&s>0&&e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-emerald-100 text-emerald-700 dark:bg-emerald-900/50 dark:text-emerald-400 font-bold uppercase tracking-wide",children:"High"})]})]},a.id||i)})})()}):e.jsx("div",{className:"py-8 text-center text-sm text-slate-500 dark:text-gray-400",children:"No dealer bids yet."})})]}),e.jsx("div",{className:`bg-white dark:bg-gray-900 rounded-2xl border shadow-sm overflow-hidden ${v?"border-amber-200 dark:border-amber-400":"border-slate-200 dark:border-gray-700"}`,children:e.jsxs("div",{className:`p-5 ${v?"bg-gradient-to-br from-amber-50/50 to-white dark:from-transparent dark:to-transparent":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 bg-amber-500 rounded-full animate-pulse"}),e.jsx("span",{className:"text-xs font-bold text-slate-500 dark:text-gray-400 uppercase tracking-wider",children:"Direct Offer High"})]}),v&&e.jsxs("div",{className:"flex items-center gap-1 bg-amber-100 text-amber-700 px-2 py-0.5 rounded-full text-xs font-bold",children:[e.jsx("svg",{className:"w-2.5 h-2.5",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})}),"TOP"]})]}),e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"text-3xl font-bold text-slate-900 dark:text-white mb-0.5",children:["$",ge.toLocaleString()]}),e.jsx("div",{className:"text-xs text-slate-500 dark:text-gray-400",children:ge>0?"Highest direct offer":"No direct offers yet"})]}),(v||Ss&&ge>0)&&e.jsx("div",{className:"bg-slate-50 dark:bg-gray-800 rounded-lg p-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[v!=null&&v.dealerLogo?e.jsx("img",{src:v.dealerLogo,alt:je||v.dealerName,className:"w-9 h-9 rounded-lg object-contain bg-white border border-slate-200 p-0.5"}):e.jsx("div",{className:"w-9 h-9 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center text-white font-bold text-sm",children:(je||(v==null?void 0:v.dealerName)||"D").charAt(0)}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-sm text-slate-900 dark:text-white",children:je||(v==null?void 0:v.dealerName)||"Dealer"}),e.jsx("div",{className:"text-[10px] text-slate-500",children:"Verified Dealer"})]})]})}),ge>0&&e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[e.jsx(I,{onClick:_t,size:"sm",className:"w-full h-10 text-sm font-semibold bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800 text-white shadow-md shadow-blue-900/20 border-0",children:"Accept Offer"}),e.jsx(I,{onClick:()=>T(!0),variant:"outline",size:"sm",className:"w-full h-9 text-xs font-medium border border-amber-400/50 bg-transparent text-amber-700 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-300 hover:bg-amber-50 dark:hover:bg-amber-950/30 hover:border-amber-500",children:"Counter Offer"})]})]})})]}),w==="my-cars"&&e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-t-2xl rounded-b-2xl md:rounded-2xl border border-slate-200 dark:border-gray-800 overflow-hidden shadow-sm max-md:mt-8",children:[w==="my-cars"&&t&&(t.clearCarLow||t.clearCarHigh||t.clearCarMid||t.suggestedSellingPrice)&&e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-emerald-100 dark:bg-emerald-900/40 flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-slate-900 dark:text-white text-base",children:"Instant Offer Value Range"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-gray-400",children:"Based on your vehicle's market data"})]})]}),e.jsxs("div",{className:"relative mb-5",children:[e.jsxs("div",{className:"flex justify-between items-end mb-1.5",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-400 dark:text-gray-500 uppercase tracking-wide font-medium mb-0.5",children:"Low"}),e.jsx("div",{className:"text-sm font-bold text-red-500 dark:text-red-400",children:t.clearCarLow?`$${t.clearCarLow.toLocaleStr
28ing()}`:"—"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-400 dark:text-gray-500 uppercase tracking-wide font-medium mb-0.5",children:"Mid"}),e.jsx("div",{className:"text-base font-bold text-amber-600 dark:text-amber-400",children:t.clearCarMid||t.suggestedSellingPrice?`$${(t.clearCarMid||t.suggestedSellingPrice).toLocaleString()}`:"—"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-400 dark:text-gray-500 uppercase tracking-wide font-medium mb-0.5",children:"High"}),e.jsx("div",{className:"text-sm font-bold text-emerald-600 dark:text-emerald-400",children:t.clearCarHigh?`$${t.clearCarHigh.toLocaleString()}`:"—"})]})]}),e.jsx("div",{className:"h-3 rounded-full bg-gradient-to-r from-red-400 via-amber-400 to-emerald-400 relative shadow-sm",children:e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-4 h-4 rounded-full bg-white border-2 border-amber-500 shadow-md"})})]}),e.jsx("div",{className:"bg-slate-50 dark:bg-gray-800 rounded-xl p-3.5 border border-slate-200 dark:border-gray-700",children:e.jsxs("p",{className:"text-xs text-slate-600 dark:text-gray-300 leading-relaxed",children:[e.jsx("span",{className:"font-semibold text-slate-800 dark:text-white",children:"Your vehicle's instant offer value range"})," is based on real market data. Dealers in our network compete to beat these values — the more bids, the higher your final offer!"]})})]}),w==="my-cars"&&e.jsx(Ws,{open:Hs,onOpenChange:Va,children:e.jsxs("div",{children:[e.jsx(Ps,{className:"w-full p-4 md:p-6 bg-gradient-to-r from-slate-50 to-white dark:from-transparent dark:to-transparent",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg md:text-xl font-bold text-slate-800 dark:text-white",children:"Vehicle Details"}),t&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${t.status==="active"?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-400":"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400"}`,children:((la=t.status)==null?void 0:la.charAt(0).toUpperCase())+((da=t.status)==null?void 0:da.slice(1).replace("_"," "))})]}),Hs?e.jsx(ns,{className:"w-5 h-5 text-slate-400"}):e.jsx(bt,{className:"w-5 h-5 text-slate-400"})]})}),e.jsx(Es,{children:e.jsxs("div",{className:"bg-white dark:bg-gray-950",children:[e.jsx(ar,{}),e.jsxs("div",{className:"p-4 md:p-6",children:[e.jsxs("div",{className:"mb-4 md:mb-6",children:[e.jsxs("div",{className:"relative bg-gradient-to-br from-slate-100 via-slate-50 to-white dark:from-slate-900 dark:via-slate-800 dark:to-slate-900 rounded-2xl p-5 mb-4 overflow-hidden md:hidden border border-slate-200 dark:border-transparent",children:[e.jsx("div",{className:"absolute inset-0 opacity-5 dark:opacity-5",children:e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 2px 2px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-start md:justify-between mb-4",children:[e.jsx("div",{className:"flex justify-center md:hidden mb-3",children:e.jsx(Lt,{className:`
29                                  ${t.status==="active"?"bg-emerald-500/20 text-emerald-700 dark:text-emerald-300 border-emerald-500/30":""}
30                                  ${t.status==="sold"?"bg-blue-500/20 text-blue-700 dark:text-blue-300 border-blue-500/30":""}
31                                  ${t.status==="ended"?"bg-slate-500/20 text-slate-700 dark:text-slate-300 border-slate-500/30":""}
32                                  border
33                                `,children:((ia=t.status)==null?void 0:ia.charAt(0).toUpperCase())+((na=t.status)==null?void 0:na.slice(1))})}),e.jsxs("div",{className:"w-full md:w-auto",children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-slate-500 dark:text-slate-400 mb-1",children:"Your Vehicle"}),e.jsxs("h2",{className:"text-xl font-bold text-slate-900 dark:text-white",children:[t.year," ",t.make]}),e.jsx("h3",{className:"text-lg font-light text-slate-700 dark:text-white/90",children:t.model}),t.trim&&e.jsx("p",{className:"text-sm text-green-700 dark:text-green-500 font-medium mt
33-1",children:t.trim})]}),e.jsx(Lt,{className:`
34                                  hidden md:inline-flex
35                                  ${t.status==="active"?"bg-emerald-500/20 text-emerald-700 dark:text-emerald-300 border-emerald-500/30":""}
36                                  ${t.status==="sold"?"bg-blue-500/20 text-blue-700 dark:text-blue-300 border-blue-500/30":""}
37                                  ${t.status==="ended"?"bg-slate-500/20 text-slate-700 dark:text-slate-300 border-slate-500/30":""}
38                                  border
39                                `,children:((oa=t.status)==null?void 0:oa.charAt(0).toUpperCase())+((ca=t.status)==null?void 0:ca.slice(1))})]}),e.jsx("div",{className:"bg-slate-200/50 dark:bg-black/30 backdrop-blur-sm rounded-xl p-3 mt-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 dark:text-slate-500 mb-1",children:"VIN"}),e.jsx("p",{className:"font-mono text-sm text-slate-800 dark:text-white/90",children:t.vin})]}),e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(t.vin),W.success("VIN copied!")},className:"p-2 rounded-lg bg-slate-300/50 hover:bg-slate-300 dark:bg-white/10 dark:hover:bg-white/20 transition-colors",children:e.jsx("svg",{className:"w-4 h-4 text-slate-600 dark:text-white/70",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})})]})]}),e.jsxs("div",{className:"hidden md:block bg-slate-900 dark:bg-gray-800 rounded-xl p-4 mb-4",children:[e.jsxs("h3",{className:"text-lg font-bold text-white mb-1",children:[t.year," ",t.make," ",t.model]}),t.trim&&e.jsx("p",{className:"text-sm text-slate-300 mb-3",children:t.trim}),e.jsx("div",{className:"border-t border-slate-700 my-3"}),e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-medium",children:"VIN"}),e.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(t.vin),W.success("VIN copied!")},className:"text-xs text-primary hover:text-primary/80 font-medium flex items-center gap-1",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})}),"Copy"]})]}),e.jsx("div",{className:"font-mono text-sm text-white/90 tracking-wide",children:t.vin})]}),e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-slate-200 dark:border-gray-700 overflow-hidden mb-4",children:e.jsxs("div",{className:"divide-y divide-slate-100 dark:divide-gray-800",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"text-sm text-slate-500 dark:text-gray-400",children:"Mileage"}),e.jsxs("span",{className:"text-sm font-semibold text-slate-900 dark:text-white",children:[(ma=t.mileage)==null?void 0:ma.toLocaleString()," mi"]})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"text-sm text-slate-500 dark:text-gray-400",children:"Condition"}),e.jsx("span",{className:"text-sm font-semibold text-slate-900 dark:text-white capitalize",children:t.condition})]}),e.jsxs("div",{className:"flex items-start justify-between px-4 py-3 gap-4",children:[e.jsx("span",{className:"text-sm text-slate-500 dark:text-gray-400 shrink-0",children:"Exterior Color"}),e.jsx("span",{className:"text-sm font-semibold text-slate-900 dark:text-white capitalize text-right",children:t.color})]}),t.engine&&e.jsxs("div",{className:"flex items-start justify-between px-4 py-3 gap-4",children:[e.jsx("span",{className:"text-sm text-slate-500 dark:text-gray-400 shrink-0",children:"Engine"}),e.jsx("span",{className:"text-sm font-semibold text-slate-900 dark:text-white text-right",children:t.engine})]}),t.transmission&&e.jsxs("div",{className:"flex items-start justify-between px-4 py-3 gap-4",children:[e.jsx("span",{className:"text-sm text-slate-500 dark:text-gray-400 shrink-0",children:"Transmission"}),e.jsx("span",{className:"text-sm font-semibold text-slate-900 dark:text-white text-right",children:t.transmission})]}),t.fuelType&&e.jsxs("div",{className:"flex items-start justify-between px-4 py-3 gap-4",children:[e.jsx("span",{className:"text-sm text-slate-500 dark:text-gray-400 shrink-0",children:"Fuel Type"}),e.jsx("span",{className:"text-sm font-semibold text-slate-900 dark:text-white capitalize text-right",children:t.fuelType})]})]})}),(()=>{const s=xs(t.description);return s?e.jsxs("div",{className:"bg-slate-50 dark:bg-gray-800/50 rounded-xl p-4 mb-4",children:[e.jsx("h4",{className:"text-xs uppercase tracking-wider text-slate-500 dark:text-gray-400 font-medium mb-2",children:"Description"}),e.jsx("p",{className:"text-sm text-slate-700 dark:text-gray-300 leading-relaxed",children:s})]}):null})(),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(I,{variant:"default",size:"lg",className:"w-full bg-primary hover:bg-primary/90 font-medium",onClick:()=>se(!0),children:"View Details"}),e.jsxs(I,{variant:"outline",size:"lg",onClick:()=>B(!0),className:"w-full gap-2 font-medium",children:[e.jsx(Ds,{className:"h-4 w-4"}),"Add Media"]})]}),e.jsxs(I,{variant:"ghost",size:"lg",onClick:()=>
39mt(!0),className:"w-full gap-2 text-slate-600 dark:text-gray-400 hover:text-primary hover:bg-primary/5 font-medium mt-2",children:[e.jsx(Pt,{className:"h-4 w-4"}),"How It Works"]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(Jr,{carId:t.id,mode:"customer",title:"Secure Sale Documents"})}),t.marketValueLow&&t.marketValueHigh&&e.jsxs("div",{className:"mt-4 md:mt-6 bg-gradient-to-br from-slate-50 to-slate-100 rounded-xl p-4 md:p-6 border-2 border-slate-200",children:[e.jsxs("h4",{className:"text-base md:text-lg font-bold text-slate-900 mb-3 md:mb-4 flex items-center gap-2",children:[e.jsx("svg",{className:"w-5 h-5 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),"Market Value Range"]}),e.jsxs("div",{className:"space-y-3 md:space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 md:gap-4",children:[e.jsxs("div",{className:"bg-white rounded-lg p-2 md:p-4 text-center border border-slate-200 shadow-sm",children:[e.jsx("div",{className:"text-xs text-slate-500 font-semibold mb-1",children:"LOW"}),e.jsxs("div",{className:"text-sm md:text-2xl font-bold text-orange-600",children:["$",t.marketValueLow.toLocaleString()]})]}),e.jsxs("div",{className:"bg-white rounded-lg p-2 md:p-4 text-center border-2 border-blue-400 shadow-md",children:[e.jsx("div",{className:"text-xs text-blue-600 font-semibold mb-1",children:"AVG"}),e.jsxs("div",{className:"text-sm md:text-2xl font-bold text-blue-600",children:["$",((t.marketValueLow+t.marketValueHigh)/2).toLocaleString()]})]}),e.jsxs("div",{className:"bg-white rounded-lg p-2 md:p-4 text-center border border-slate-200 shadow-sm",children:[e.jsx("div",{className:"text-xs text-slate-500 font-semibold mb-1",children:"HIGH"}),e.jsxs("div",{className:"text-sm md:text-2xl font-bold text-emerald-600",children:["$",t.marketValueHigh.toLocaleString()]})]})]}),e.jsxs("div",{className:"relative pt-2 pb-4",children:[e.jsx("div",{className:"h-3 bg-gradient-to-r from-orange-400 via-blue-500 to-emerald-500 rounded-full shadow-inner"}),e.jsx("div",{className:"absolute top-0 -translate-x-1/2",style:{left:`${Math.min(100,Math.max(0,(ht-t.marketValueLow)/(t.marketValueHigh-t.marketValueLow)*100))}%`},children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("div",{className:"bg-cyan-500 text-white text-xs font-bold px-2 md:px-3 py-1 rounded-full shadow-lg mb-1 whitespace-nowrap",children:["$",ht.toLocaleString()]}),e.jsx("div",{className:"w-1 h-6 bg-cyan-500 rounded-full"}),e.jsx("div",{className:"w-3 h-3 bg-cyan-500 rounded-full border-2 border-white shadow-lg"})]})})]}),e.jsx("div",{className:"text-sm text-slate-600 bg-blue-50 rounded-lg p-3 border border-blue-200",children:e.jsxs("p",{className:"font-medium",children:["💡 This range represents the current market value for your vehicle based on condition, mileage, and market demand.",e.jsxs("span",{className:"block mt-1 text-blue-700 font-semibold",children:["Your current high bid is at"," ",(ht/((t.marketValueLow+t.marketValueHigh)/2)*100).toFixed(0),"% of market average."]})]})})]})]})]}),t.marketValueLow&&t.marketValueHigh&&e.jsxs("div",{className:"p-6 border-t border-slate-200 bg-slate-50",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900 mb-4",children:"Market Analysis"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-white p-4 rounded-lg border border-slate-200",children:[e.jsx("div",{className:"text-xs text-slate-600 mb-1",children:"Market Low"}),e.jsxs("div",{className:"text-xl font-bold text-red-600",children:["$",t.marketValueLow.toLocaleString()]})]}),e.jsxs("div",{className:"bg-white p-4 rounded-lg border border-slate-200",children:[e.jsx("div",{className:"text-xs text-slate-600 mb-1",children:"Market Average"}),e.jsxs("div",{className:"text-xl font-bold text-blue-600",children:["$",((t.marketValueLow+t.marketValueHigh)/2).toLocaleStr
39ing()]})]}),e.jsxs("div",{className:"bg-white p-4 rounded-lg border border-slate-200",children:[e.jsx("div",{className:"text-xs text-slate-600 mb-1",children:"Market High"}),e.jsxs("div",{className:"text-xl font-bold text-green-600",children:["$",t.marketValueHigh.toLocaleString()]})]})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx("div",{className:"relative h-8 bg-gradient-to-r from-red-200 via-yellow-200 via-green-200 to-emerald-300 rounded-full",children:e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2",style:{left:`${Math.min(100,Math.max(0,(ht-t.marketValueLow)/(t.marketValueHigh-t.marketValueLow)*100))}%`},children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-4 h-4 bg-blue-600 border-2 border-white rounded-full shadow-lg"}),e.jsx("div",{className:"absolute -top-8 left-1/2 -translate-x-1/2 whitespace-nowrap bg-blue-600 text-white text-xs px-2 py-1 rounded shadow-lg font-bold",children:"Your Highest Bid"})]})})}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-600 mt-2",children:[e.jsx("span",{children:"Low Value"}),e.jsx("span",{children:"High Value"})]})]})]})]})})]})}),w==="my-cars"&&t&&e.jsx(hl,{variant:"connected",carId:t.id,customerId:(l==null?void 0:l.id)||"",customerName:(l==null?void 0:l.name)||"",customerEmail:(l==null?void 0:l.email)||""})]}),w==="offers"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"mb-4 md:mb-6",children:[e.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-slate-900 dark:text-white mb-2",children:"Your Offers"}),e.jsx("p",{className:"text-sm md:text-base text-slate-600 dark:text-slate-400",children:"Review offers from verified dealers"})]}),L.length>0?e.jsx("div",{className:"space-y-4",children:[...L].sort((s,a)=>a.amount-s.amount).map(s=>{const a=s.expiresAt&&new Date>new Date(s.expiresAt),i=s.id===(v==null?void 0:v.id),c=t.marketValueLow&&t.marketValueHigh?(t.marketValueLow+t.marketValueHigh)/2:null,p=c?(s.amount/c*100).toFixed(0):null,f=s.expiresAt?Math.ceil((new Date(s.expiresAt).getTime()-new Date().getTime())/(1e3*60*60*24)):null;return e.jsx("div",{className:`bg-white rounded-xl md:rounded-2xl border-2 transition-all ${i?"border-yellow-400 shadow-lg":"border-slate-200 shadow-sm hover:shadow-md"} overflow-hidden`,children:e.jsxs("div",{className:"p-4 md:p-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3 md:mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[s.dealerLogo?e.jsx("img",{src:s.dealerLogo,alt:`${s.dealerName} logo`,className:"w-16 h-16 md:w-24 md:h-24 lg:w-28 lg:h-28 rounded-lg object-contain shadow-lg border-2 border-slate-200 bg-white p-1 md:p-2"}):e.jsx("div",{className:"w-16 h-16 md:w-24 md:h-24 lg:w-28 lg:h-28 rounded-lg bg-gradient-to-br from-blue-500 to-cyan-500 flex items-center justify-center text-white font-bold text-xl md:text-2xl lg:text-3xl shadow-lg",children:s.dealerName.charAt(0)}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-sm md:text-base lg:text-lg text-slate-900",children:s.dealerName}),e.jsx("div",{className:"text-xs text-slate-500",children:"Verified Dealer"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 items-end",children:[s.isTradeIn&&e.jsxs("div",{className:"flex items-center gap-1.5 bg-purple-100 text-purple-800 px-3 py-1.5 rounded-full text-xs font-bold",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})}),"TRADE-IN OFFER"]}),i&&e.jsxs("div",{className:"flex items-center gap-2 bg-yellow-100 text-yellow-800 px-3 py-1.5 rounded-full text-xs font-bold",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})}),"TOP OFFER"]})]})]}),e.jsxs("div",{className:"mb-3 md:mb-4",children:[e.jsxs("div",{className:"text-3xl md:text-4xl lg:text-5xl font-bold text-green-700 mb-1 md:mb-2",children:["$",s.amount.toLocaleStr
39ing()]}),p&&e.jsxs("div",{className:"text-xs md:text-sm text-slate-600",children:[p,"% of market average •"," ",parseFloat(p)>=100?"Above market value":parseFloat(p)>=95?"Near market value":"Below market value"]})]}),e.jsxs("div",{className:"bg-slate-50 rounded-xl p-3 md:p-4 mb-3 md:mb-4 space-y-2",children:[e.jsx("div",{className:"text-xs font-semibold text-slate-900 mb-2",children:"Transaction Details"}),e.jsxs("div",{className:"text-xs md:text-sm text-slate-700",children:[e.jsxs("span",{children:["Appointment Location:"," "]}),e.jsx("span",{className:"font-semibold",children:s.pickupOptions&&s.pickupOptions.length>0?s.pickupOptions.includes("pickup")?"The buyer will pick the car up from your location":s.pickupOptions.includes("delivery")?"The buyer offers delivery service":s.pickupOptions.join(", "):"Contact dealer for pickup arrangements"})]}),e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-1 md:gap-0 text-xs text-slate-600",children:[e.jsxs("span",{children:["Payment Type:"," ",e.jsx("span",{className:"font-semibold",children:s.paymentTypes&&s.paymentTypes.length>0?s.paymentTypes.map($=>({ach:"ACH Transfer",check:"Check",wire:"Wire Transfer",cash:"Cash",cashiers_check:"Cashier's Check"})[$.toLowerCase()]||$).join(", "):"Contact dealer"})]}),e.jsxs("span",{children:["Est. Close:"," ",e.jsx("span",{className:"font-semibold",children:new Date(new Date(s.timestamp).getTime()+7*24*60*60*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})]})]})]}),(s.dealerAddress||s.dealerWebsite||s.dealerPhone)&&e.jsxs("div",{className:"bg-blue-50 rounded-xl p-3 md:p-4 mb-3 md:mb-4 space-y-2",children:[e.jsx("div",{className:"text-xs font-semibold text-blue-900 mb-2",children:"Dealership Information"}),e.jsxs("div",{className:"space-y-1.5",children:[s.dealerAddress&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-slate-700",children:[e.jsxs("svg",{className:"w-4 h-4 text-blue-600 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}),e.jsx("span",{children:s.dealerAddress})]}),s.dealerPhone&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-700",children:[e.jsx("svg",{className:"w-4 h-4 text-blue-600 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"})}),e.jsx("a",{href:`tel:${s.dealerPhone}`,className:"hover:text-blue-600 font-medium",children:s.dealerPhone})]}),s.dealerWebsite&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-700",children:[e.jsx("svg",{className:"w-4 h-4 text-blue-600 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}),e.jsx("a",{href:s.dealerWebsite.startsWith("http")?s.dealerWebsite:`https://${s.dealerWebsite}`,target:"_blank",rel:"noopener noreferrer",className:"hover:text-blue-600 font-medium hover:underline",children:"Visit Website"})]})]})]}),s.message&&e.jsxs("div",{className:"bg-blue-50 border-l-4 border-blue-400 rounded-r-lg p-4 mb-4",children:[e.jsx("div",{className:"text-xs font-semibold text-blue-900 mb-1",children:"Dealer Message"}),e.jsxs("div",{className:"text-sm text-blue-800",children:['"',s.message,'"']})]}),e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3 md:gap-0 pt-3 md:pt-4 border-t border-slate-200",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx("span",{className:`inline-flex items-center px-3 py-1.5 rounded-full text-xs font-bold ${a?"bg-gray-100 text-gray-700":s.status==="active"?"bg-orange-100 text-orange-700":s.status==="accepted"?"bg-green-100 text-green-700":"bg-red-100 text-red-700"}`,children:a?"EXPIRED":s.status==="active"?"PENDING REVIEW":s.status.toUpperCase()}),!a&&f!==null&&e.jsx("div",{className:`text-xs font-semibold ${f<=1?"text-red-600":"text-orange-600"}`,children:f<=0?"Expires today":`Expires in ${f} day${f!==1?"s":""}`})]}),!a&&s.status==="active"&&e.jsxs("div",{className:"flex gap-2 w-full md:w-auto",children:[e.jsx(I,{onClick:()=>Za(s.id),variant:"outline",size:We?"sm":"default",className:"flex-1 md:flex-initial border-slate-300 text-slate-100 bg-red-500 hover:bg-red-400",children:"Decline"}),e.jsx(I,{onClick:()=>Ga(s.id),size:We?"sm":"default",className:"flex-1 md:flex-initial bg-gradient-to-r from-blue-600 to-cyan-600 hover:from-blue-700 hover:to-cyan-700 text-white shadow-md",children:"Accept Offer"})]})]})]})},s.id)})}):e.jsx("div",{className:"bg-white dark:bg-slate-900 rounded-2xl shadow-sm border-2 border-dashed border-slate-300 p-12 text-center",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"w-20 h-20 bg-slate-100 rounded-full flex items-center justify-center mb-4",children:e.jsx("svg",{className:"w-10 h-10 text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("h3",{className:"text-xl font-bold text-slate-900 dark:text-white mb-2",children:"No Offers Yet"}
39),e.jsx("p",{className:"text-slate-600 dark:text-slate-400 max-w-md",children:"Verified dealers are reviewing your vehicle. You'll receive notifications when offers come in."})]})})]})]}):e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 p-12 text-center",children:[e.jsx("svg",{className:"w-16 h-16 text-slate-300 mx-auto mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),e.jsx("h2",{className:"text-2xl font-bold text-slate-900 mb-2",children:"No Active Listings"}),e.jsx("p",{className:"text-slate-600 mb-6",children:"You don't have any active vehicle listings at the moment."}),e.jsx(I,{className:"bg-blue-600 hover:bg-blue-700",children:"List Your Vehicle"})]})})]})}),We&&e.jsx("div",{className:"fixed bottom-0 left-0 right-0 bg-white dark:bg-gray-900 border-t border-slate-200 dark:border-gray-800 shadow-2xl z-50",style:{paddingBottom:"env(safe-area-inset-bottom)"},children:e.jsxs("div",{className:"flex justify-around items-center px-1 pt-1 pb-1",children:[e.jsxs("button",{onClick:()=>ee("my-cars"),className:`flex flex-col items-center gap-0.5 flex-1 py-2 rounded-xl transition-all relative ${w==="my-cars"?"text-emerald-600 dark:text-emerald-400":"text-slate-400 dark:text-gray-500"}`,children:[w==="my-cars"&&e.jsx("span",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-8 h-0.5 bg-emerald-500 rounded-full"}),e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:w==="my-cars"?2.5:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),e.jsx("span",{className:`text-[10px] font-semibold ${w==="my-cars"?"text-emerald-600 dark:text-emerald-400":"text-slate-400"}`,children:"My Cars"})]}),e.jsxs("button",{onClick:()=>ee("offers"),className:`flex flex-col items-center gap-0.5 flex-1 py-2 rounded-xl transition-all relative ${w==="offers"?"text-emerald-600 dark:text-emerald-400":"text-slate-400 dark:text-gray-500"}`,children:[w==="offers"&&e.jsx("span",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-8 h-0.5 bg-emerald-500 rounded-full"}),e.jsxs("div",{className:"relative",children:[e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:w==="offers"?2.5:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),L.length>0&&e.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 bg-red-500 text-white text-[9px] font-bold px-1 rounded-full flex items-center justify-center animate-pulse",children:L.length})]}),e.jsx("span",{className:`text-[10px] font-semibold ${w==="offers"?"text-emerald-600 dark:text-emerald-400":"text-slate-400"}`,children:"Offers"})]}),e.jsxs("button",{onClick:()=>mt(!0),className:"flex flex-col items-center gap-0.5 flex-1 py-2 rounded-xl transition-all text-slate-400 dark:text-gray-500",children:[e.jsx(Pt,{className:"w-6 h-6"}),e.jsx("span",{className:"text-[10px] font-semibold text-slate-400",children:"Guide"})]}),e.jsxs("button",{onClick:()=>q(!0),className:"flex flex-col items-center gap-0.5 flex-1 py-2 rounded-xl transition-all text-slate-400 dark:text-gray-500",children:[e.jsx(Ms,{className:"w-6 h-6"}),e.jsx("span",{className:"text-[10px] font-semibold text-slate-400",children:"Message"})]})]})}),X&&t&&e.jsx(Br,{car:t,currentOffer:t.currentBid||t.startingBid,isOpen:X,onClose:()=>T(!1),onSubmit:Qa}),e.jsx(rl,{isOpen:Q,onClose:()=>se(!1),car:t}),e.jsx(Ve,{open:Zt,onOpenChange:Xt,children:e.jsxs(qe,{className:"w-[95vw] max-w-[440px] p-0 overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-br from-emerald-600 to-teal-600 px-5 pt-5 pb-4 text-white",children:[e.jsxs(Nt,{className:"space-y-0",children:[e.jsx(Ze,{className:"text-xs font-bold uppercase tracking-wider text-emerald-100",children:"Bidding Dealer"}),e.jsx($t,{className:"sr-only",children:"Dealer bid details"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-3",children:[x!=null&&x.logo?e.jsx("img",{src:x.logo,alt:x.name,className:"w-14 h-14 roun
39ded-xl object-contain bg-white border border-white/40 p-1 flex-shrink-0"}):e.jsx("div",{className:"w-14 h-14 rounded-xl bg-white/20 flex items-center justify-center text-white text-xl font-bold flex-shrink-0",children:((x==null?void 0:x.name)||"D").charAt(0).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-lg font-bold leading-tight break-words",children:(x==null?void 0:x.name)||"Dealership"}),e.jsxs("div",{className:"text-[11px] text-emerald-100 flex items-center gap-1 mt-0.5",children:[e.jsx(sl,{className:"w-3 h-3"})," Verified Dealer"]})]})]})]}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-800/50 p-3",children:[e.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500 dark:text-gray-400 mb-1",children:"This Bid"}),e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs("div",{className:"text-2xl font-black text-slate-900 dark:text-white",children:["$",((xa=(ss=x==null?void 0:x.amount)==null?void 0:ss.toLocaleString)==null?void 0:xa.call(ss))||"—"]}),(x==null?void 0:x.timestamp)&&e.jsx("div",{className:"text-[11px] text-slate-500 dark:text-gray-400",children:new Date(x.timestamp).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"rounded-lg border border-slate-200 dark:border-gray-700 p-2.5",children:[e.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-slate-500 dark:text-gray-400",children:"Bids on this vehicle"}),e.jsx("div",{className:"text-lg font-bold text-slate-900 dark:text-white mt-0.5",children:(x==null?void 0:x.totalBids)??0})]}),e.jsxs("div",{className:"rounded-lg border border-slate-200 dark:border-gray-700 p-2.5",children:[e.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-slate-500 dark:text-gray-400",children:"Their highest"}),e.jsxs("div",{className:"text-lg font-bold text-emerald-600 dark:text-emerald-400 mt-0.5",children:["$",((ha=(as=x==null?void 0:x.highestBid)==null?void 0:as.toLocaleString)==null?void 0:ha.call(as))||"—"]})]})]}),((x==null?void 0:x.firstBidTime)||(x==null?void 0:x.lastBidTime))&&e.jsxs("div",{className:"rounded-lg border border-slate-200 dark:border-gray-700 p-2.5 space-y-1.5",children:[(x==null?void 0:x.firstBidTime)&&e.jsxs("div",{className:"flex items-center justify-between text-[11px]",children:[e.jsx("span",{className:"text-slate-500 dark:text-gray-400",children:"First bid"}),e.jsx("span",{className:"font-semibold text-slate-800 dark:text-gray-200",children:new Date(x.firstBidTime).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})})]}),(x==null?void 0:x.lastBidTime)&&e.jsxs("div",{className:"flex items-center justify-between text-[11px]",children:[e.jsx("span",{className:"text-slate-500 dark:text-gray-400",children:"Most recent bid"}),e.jsx("span",{className:"font-semibold text-slate-800 dark:text-gray-200",children:new Date(x.lastBidTime).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})})]})]}),((x==null?void 0:x.address)||(x==null?void 0:x.phone)||(x==null?void 0:x.website))&&e.jsxs("div",{className:"rounded-lg border border-slate-200 dark:border-gray-700 p-3 space-y-2",children:[(x==null?void 0:x.address)&&e.jsxs("div",{className:"flex items-start gap-2 text-[12px] text-slate-700 dark:text-gray-300",children:[e.jsx(Re,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-slate-400"}),e.jsx("span",{className:"break-words",children:x.address})]}),(x==null?void 0:x.phone)&&e.jsxs("a",{href:`tel:${x.phone}`,className:"flex items-center gap-2 text-[12px] text-emerald-700 dark:text-emerald-400 hover:underline",children:[e.jsx(dt,{className:"w-3.5 h-3.5 flex-shrink-0"}),x.phone]}),(x==null?void 0:x.website)&&e.jsxs("a",{href:x.website.startsWith("http")?x.website:`https://${x.website}`,target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-[12px] text-emerald-700 dark:text-emerald-400 hover:underline",children:[e.jsx(ms,{className:"w-3.5 h-3.5 flex-shrink-0"}),x.website]})]}),(pa=x==null?void 0:x.paymentTypes)!=null&&pa.length||(ua=x==null?void 0:x.pickupOptions)!=null&&ua.length||x!=null&&x.titleInHandPayment||(ga=x==null?void 0:x.loanPayoffOptions)!=null&&ga.length?e.jsxs("div",{className:"rounded-xl border border-slate-200 dark:border-gray-700 overflow-hidden",children:[e.jsx("div",{className:"px-3 py-2 border-b border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-800/50",children:e.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500 dark:text-gray-400",children:"Transaction Details"})}),e.jsxs("div",{className:"divide-y divide-slate-200 dark:divide-gray-700",children:[((fa=x==null?void 0:x.paymentTypes)==null?void 0:fa.length)>0&&e.jsxs("div",{className:"px-3 py-2.5 flex justify-between items-start gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-slate-500 dark:text-gray-400",children:[e.jsx(nt,{className:"w-3.5 h-3.5"})," Payment"]}),e.jsx("div",{className:"flex flex-wrap gap-1 justify-end max-w-[65%]",children:x.paymentTypes.map((s,a)=>e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-emerald-50 dark:bg-emerald-500/10 text-emerald-700 dark:text-emerald-400 border border-emerald-200 dark:border-emerald-500/20",children:s},a))})]}),((ba=x==null?void 0:x.pickupOptions)==null?void 0:ba.length)>0&&e.jsxs("div",{className:"px-3 py-2.5 flex justify-between items-start gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-slate-500 dark:text-gray-400",children:[e.jsx(qt,{className:"w-3.5 h-3.5"})," Location"]}),e.jsx("div",{className:"flex flex-wrap gap-1 justify-end max-w-[65%]",children:x.pickupOptions.map((s,a)=>e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-slate-100 dar
39k:bg-gray-800 text-slate-700 dark:text-gray-300 border border-slate-200 dark:border-gray-700",children:s},a))})]}),(x==null?void 0:x.titleInHandPayment)&&e.jsxs("div",{className:"px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-slate-500 dark:text-gray-400 mb-1",children:[e.jsx(nt,{className:"w-3.5 h-3.5"})," Same Day Payment for Title"]}),e.jsx("div",{className:"text-[12px] text-slate-800 dark:text-gray-200 pl-5",children:x.titleInHandPayment==="No"?"Next Business Day":x.titleInHandPayment})]}),((ja=x==null?void 0:x.loanPayoffOptions)==null?void 0:ja.length)>0&&e.jsxs("div",{className:"px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-slate-500 dark:text-gray-400 mb-1",children:[e.jsx(rt,{className:"w-3.5 h-3.5"})," Payoff Process ",e.jsx("span",{className:"text-[10px] text-slate-400",children:"(if active loan)"})]}),e.jsx("div",{className:"pl-5 space-y-0.5",children:x.loanPayoffOptions.map((s,a)=>e.jsxs("div",{className:"text-[12px] text-slate-800 dark:text-gray-200 break-words",children:["• ",s]},a))})]})]})]}):null,Pa&&e.jsx("div",{className:"text-center text-[11px] text-slate-400",children:"Loading dealer details…"})]})]})}),e.jsx(Ve,{open:pe,onOpenChange:B,children:e.jsxs(qe,{className:"w-[95vw] max-w-[500px] max-h-[90vh] overflow-hidden flex flex-col p-4 sm:p-6",children:[e.jsxs(Nt,{className:"pb-2",children:[e.jsx(Ze,{className:"text-lg sm:text-xl",children:"Add Photos or Videos"}),e.jsx($t,{className:"text-xs sm:text-sm",children:"Upload additional photos or videos to enhance your vehicle listing"})]}),e.jsxs("div",{className:"space-y-3 sm:space-y-4 flex-1 overflow-y-auto",children:[e.jsxs("div",{className:"border-2 border-dashed border-slate-300 dark:border-slate-600 rounded-lg p-4 sm:p-8 text-center hover:border-primary transition-colors",children:[e.jsx("input",{type:"file",id:"media-upload",className:"hidden",accept:"image/*,video/*",multiple:!0,onChange:Ja}),e.jsxs("label",{htmlFor:"media-upload",className:"cursor-pointer",children:[e.jsx(Ds,{className:"h-8 w-8 sm:h-12 sm:w-12 mx-auto text-slate-400 mb-2 sm:mb-3"}),e.jsx("p",{className:"text-xs sm:text-sm font-medium text-slate-700 dark:text-slate-300 mb-1",children:"Click to upload photos or videos"}),e.jsx("p",{className:"text-[10px] sm:text-xs text-slate-500 dark:text-slate-400",children:"Supports JPG, PNG, MP4, MOV (max 20MB per file)"})]})]}),_.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs sm:text-sm font-medium text-slate-700 dark:text-slate-300",children:["Selected Files (",_.length,")"]}),e.jsx("div",{className:"space-y-2 max-h-40 sm:max-h-60 overflow-y-auto",children:_.map((s,a)=>e.jsxs("div",{className:"flex items-center justify-between bg-slate-50 dark:bg-slate-800 p-2 sm:p-3 rounded-lg gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-1 min-w-0",children:[s.type.startsWith("image/")?e.jsx("img",{src:URL.createObjectURL(s),alt:s.name,className:"w-10 h-10 sm:w-12 sm:h-12 object-cover rounded flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 sm:w-12 sm:h-12 bg-slate-200 dark:bg-slate-700 rounded flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5 sm:w-6 sm:h-6 text-slate-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs sm:text-sm font-medium text-slate-900 dark:text-slate-100 truncate",children:s.name}),e.jsxs("p",{className:"text-[10px] sm:text-xs text-slate-500 dark:text-slate-400",children:[(s.size/1024/1024).toFixed(2)," MB"]})]})]}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>er(a),className:"flex-shrink-0 h-8 w-8 p-0",children:e.jsx(hs,{className:"h-4 w-4"})})]},a))})]}),e.jsxs("div",{className:"flex gap-2 sm:gap-3 pt-2 sm:pt-4 sticky bottom-0 bg-background",children:[e.jsx(I,{variant:"outline",onClick:()=>{B(!1),U([])},disabled:we,className:"flex-1 h-10 sm:h-11 text-sm",children:"Cancel"}),e.jsx(I,{onClick:tr,disabled:_.length===0||we,className:"flex-1 h-10 sm:h-11 text-sm bg-primary hover:bg-primary/90",children:we?"Uploading...":`Upload ${_.length>0?`(${_.length})`:""}`})]})]})]})}),t&&ue&&e.jsx(il,{isOpen:ct,onClose:()=>{Be(!1),ws.current||Le(null)},offerType:ue.type,amount:ue.amount,dealerId:ue.dealerId,dealerName:ue.dealerName,vehicle:{id:t.
39id,year:t.year,make:t.make,model:t.model,vin:t.vin,trim:t.trim},onAcceptAndSchedule:Xa}),t&&ue&&e.jsx(ol,{isOpen:Ft,onClose:()=>{Oe(!1),Le(null)},vehicle:{id:t.id,year:t.year,make:t.make,model:t.model,vin:t.vin},dealerId:ue.dealerId,dealerName:ue.dealerName,acceptedOfferId:ue.acceptedOfferId,dealershipId:ue.dealershipId||null,salePrice:ue.amount,customerInfo:{name:t.customerName,email:t.customerEmail,phone:t.customerPhone},onScheduled:Ka}),t&&e.jsx(cl,{isOpen:Ut,onClose:()=>wt(!1),car:{year:t.year,make:t.make,model:t.model,vin:t.vin,sale_price:t.sale_price,currentBid:t.currentBid,images:t.images},appointment:o,dealer:m}),t&&o&&(o.dealer_id||t.highBidderId)&&e.jsx(Hr,{isOpen:fs,onClose:()=>kt(!1),appointment:{id:o.id,car_id:o.car_id,date:o.date,time:o.time},vehicle:{id:t.id,year:t.year,make:t.make,model:t.model},dealerId:o.dealer_id||t.highBidderId,onRescheduled:()=>{kt(!1),Pe(t.id,t.vin,t.highBidderId)}}),t&&e.jsx(ll,{isOpen:Ea,onClose:()=>bs(!1),car:t,appointment:o,onAppointmentSuccess:()=>{bs(!1),Pe(t.id,t.vin,t.highBidderId)}}),e.jsx(Ve,{open:Yt,onOpenChange:mt,children:e.jsxs(qe,{className:"max-w-2xl max-h-[90vh] overflow-hidden p-0 rounded-3xl border-0 shadow-2xl",children:[e.jsxs("div",{className:"relative bg-gradient-to-br from-emerald-600 via-emerald-700 to-emerald-900 px-7 pt-8 pb-10 overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",style:{backgroundImage:"radial-gradient(circle at 70% 50%, white 0%, transparent 60%)"}}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-2xl bg-white/20 backdrop-blur-sm flex items-center justify-center",children:e.jsx(Pt,{className:"h-5 w-5 text-white"})}),e.jsx(Ze,{className:"text-2xl font-bold text-white tracking-tight",children:"How CarSolve Works"})]}),e.jsx($t,{className:"text-emerald-100/80 text-sm ml-[52px]",children:"Everything you need to know about selling your vehicle through CarSolve"})]})]}),e.jsxs("div",{className:"overflow-y-auto max-h-[calc(90vh-180px)] px-6 py-5 space-y-2 bg-background",children:[[{question:"How does the auction work?",answer:"Once your vehicle is approved, it goes live in our dealer auction. Licensed dealers can place bids on your vehicle during the auction period. You can see the current high bid and number of bidders in real-time on your dashboard. The auction runs for a set period, and you'll be notified of all bid activity."},{question:"Who are the buyers placing bids and offers on my vehicle?",answer:"All buyers on the CarSolve platform are thoroughly vetted, licensed automotive dealers. Before gaining access to our marketplace, every dealer must verify their active dealer license with their state licensing authority, provide proof of surety bond and insurance, and pass a compliance review confirming they are in good standing with state and federal agencies. Our dealer network is made up predominantly of large, well-known dealership groups and franchise dealers — the same trusted names you see on major roads across the country. These are established businesses with reputations to uphold, not anonymous buyers. When you receive a bid or offer on CarSolve, you can trust it's coming from a serious, credentialed professional."},{question:"What are Direct Offers?",answer:"Direct Offers are immediate purchase offers from dealers who want to buy your vehicle without waiting for the auction to end. These offers are separate from auction bids and typically expire within a set timeframe. You can accept a direct offer at any time, even while the auction is still running."},{question:"What's the difference between Auction Bids and Direct Offers?",answer:"Auction Bids are competitive bids placed during the auction period - dealers compete against each other and the highest bid wins when the auction ends. Direct Offers are firm purchase prices from dealers who want to buy immediately. You can accept either type of offer to sell your vehicle."},{question:"How do I accept an offer?",answer:"When you're ready to accept an offer (either the high auction bid or a direct offer), click on the offer card to view details. You'll see information about the dealer making the offer. Click 'Accept and Schedule Appointment' to proceed. This will update your vehicle status and open the appointment scheduler."},{question:"How do I schedule an appointment?",answer:"After accepting an offer, you'll be prompted to schedule an appointment. Select your preferred date and time, and the dealer will be notified of your request. Once they confirm, you'll see the appointment details including the dealership location and contact information."},{question:"What happens after I schedule an appointment?",answer:"The dealer will review and confirm your appointment request. Once confirmed, you'll see the confirmed date, time, and location on your dashboard. On the appointment day, bring your vehicle, title, and keys to the dealership to complete the sale and receive payment."},{question:"Can I counter an offer?",answer:"Yes! If you receive an offer that's close but not quite what you're looking for, you can submit a counter offer. The dealer will be notified and can accept, reject, or counter back. This negotiation continues until you reach an agreement or decide to wait for other offers."},{question:"Is the offer guaranteed once I accept it?",answer:"Yes — once you accept an offer, it is a binding commitment from the dealer, provided your vehicle matches the condition represented in your listing. All accepted offers are subject to a brief on-site inspection at your appointment. The inspection is straightforward and primarily focuses on verifying the engine and transmission are in working order with no major mechanical failures, and that the overall condition is consistent with what was disclosed. There are no surprise deductions for normal wear or cosmetic items already noted in your listing. As long as your vehicle is as described, the offer stands."},{question:"How do I get paid?",answer:"Payment is handled directly by the purchasing dealer at your appointment. Most Certified Dealers pay by check. If you have a loan on the vehicle, the dealer can work with your lender to handle the payoff. All payment details will be confirmed before your appointment."}].map((s,a)=>e.jsxs("div",{className:`rounded-2xl overflow-hidden border transition-all duration-200 ${ke===a?"border-emerald-200 dark:border-emerald-800/60 shadow-sm":"border-border/60 hover:border-border"}`,children:[e.jsxs("button",{onClick:()=>Te(ke===a?null:a),className:`w-full flex items-center justify-between px-5 py-4 text-left transition-colors ${ke===a?"bg-emerald-50 dark:bg-emerald-950/30":"bg-card hover:bg-muted/40"}`,children:[e.jsx("span",{className:`font-semibold pr-4 text-sm ${ke===a?"text-emerald-700 dark:text-emerald-400":"text-foreground"}`,children:s.question}),e.jsx("div",{className:`flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center transition-all ${ke===a?"bg-emerald-500 text-white rotate-180":"bg-muted text-muted-foreground"}`,children:e.jsx(bt,{className:"h-3.5 w-3.5"})})]}),ke===a&&e.jsx("div",{className:"px-5 pb-5 pt-3 text-sm text-muted-foreground leading-relaxed bg-card border-t border-emerald-100 dark:border-emerald-900/30",children:s.answer})]},a)),e.jsx("div",{className:"mt-4 p-5 bg-gradient-to-r from-primary/5 to-emerald-500/5 rounded-2xl border border-primary/10",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Pt,{className:"h-4 w-4 text-primary"})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:"Still have questions?"})," Contact our support team and we'll guide you through every step of the process."]})]})})]})]})}),We?e.jsx(It,{open:zs,onOpenChange:Ke,children:e.jsxs(Bt,{className:"h-[92vh] px-4 pb-safe",children:[e.jsxs(Ht,{className:"sr-only",children:[e.jsx(zt,{children:"Start Your Vehicle Sale"}),e.jsx(us,{children:"Answer a few questions about your vehicle"})]}),t&&e.jsx(Os,{ref:Ot,car:t,onUpdate:s=>{y(s),D(a=>a.map(i=>i.id===s.id?s:i))},onComplete:async()=>{try{Kt(!0),Ot.current&&await Ot.current.save();const{error:s}=await g.rpc("update_car_sale_stage",{p_car_id:t.id,p_sale_stage:"customer_confirmed_ready"});if(s)throw s;W.success("Your vehicle information has been submitted for review!"),Ke(!1);try{console.log("[GHL] Customer submitted for review - triggering vehicleProfileComplete"),await Et(t.id,"vehicleProfileComplete")}catch(i){console.warn("[GHL] vehicleProfileComplete failed (non-blocking):",i)}const{data:a}=await g.from("cars").select("*").eq("id",t.id).single();if(a){const i=Je(a);y(i),D(c=>c.map(p=>p.id===i.id?i:p))}}catch(s){console.error("Error submitting vehicle:",s),W.error("Failed to submit vehicle for review")}finally{Kt(!1)}},onCancel:()=>Ke(!1),onUploadPhotos:()=>B(!0),isSubmitting:Fs})]})}):e.jsx(Ve,{open:zs,onOpenChange:Ke,children:e.jsx(qe,{className:"sm:max-w-xl md:max-w-2xl h-[85vh] max-h-[85vh] p-0 overflow-hidden flex flex-col",children:t&&e.jsx(Os,{ref:Ot,car:t,onUpdate:s=>{y(s),D(a=>a.map(i=>i.id===s.id?s:i))},onComplete:async()=>{var s;try{Kt(!0),await((s=Ot.current)==null?void 0:s.save());const{error:a}=await g.rpc("update_car_sale_stage",{p_car_id:t.id,p_sale_stage:"customer_confirmed_ready"});if(a)throw a;W.success("Vehicle submitted for review!"),Ke(!1);try{console.log("[GHL] Customer submitted for review - triggering vehicleProfileComplete"),await Et(t.id,"vehicleProfileComplete")}catch(c){console.warn("[GHL] vehicleProfileComplete failed (non-blocking):",c)}const i=Je({...t,sale_stage:"customer_confirmed_ready"});i&&(y(i),D(c=>c.map(p=>p.id===i.id?i:p)))}catch(a){console.error("Error submitting vehicle:",a),W.error("Failed to submit vehicle for review")}finally{Kt(!1)}},onCancel:()=>Ke(!1),onUploadPhotos:()=>B(!0),isSubmitting:Fs})})}),e.jsx(ml,{isOpen:Gt,onClose:()=>q(!1),selectedCarId:r==null?void 0:r.id,viewingCustomer:u,customerId:b,isAdminViewing:!!xt})]})]})};export{Bd 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.