1import{c as y,r as f,j as e,i as j,L as $,a as L,S,C as P}from"./main-BGPPHxHM.js";import{B as k}from"./badge-zEFINaEp.js";import{C as N}from"./check-Cx29d-FE.js";import{G as T}from"./gauge-BjZ0J16D.js";import{C as I}from"./chevron-right-ChkK1bCk.js";const D=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],E=y("chevron-left",D);const F=[["path",{d:"M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 4 0v-6.998a2 2 0 0 0-.59-1.42L18 5",key:"1wtuz0"}],["path",{d:"M14 21V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v16",key:"e09ifn"}],["path",{d:"M2 21h13",key:"1x0fut"}],["path",{d:"M3 9h11",key:"1p7c0w"}]],O=y("fuel",F);const R=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],B=y("settings-2",R);const q=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],_=y("share-2",q),z={lat:52.4951,lng:-1.909};let x=null,p="idle";const v=new Set;function g(){v.forEach(t=>t())}function G(){if(!(p==="loading"||p==="granted")){if(typeof navigator>"u"||!navigator.geolocation){p="unavailable",g();return}p="loading",g(),navigator.geolocation.getCurrentPosition(t=>{x={lat:t.coords.latitude,lng:t.coords.longitude},p="granted";try{localStorage.setItem("pc_user_coords",JSON.stringify(x))}catch{}g()},()=>{p="denied",g()},{enableHighAccuracy:!1,timeout:1e4,maximumAge:6e5})}}function A(){const[,t]=f.useState(0);return f.useEffect(()=>{const n=()=>t(s=>s+1);if(v.add(n),x===null&&p==="idle")try{const s=localStorage.getItem("pc_user_coords");s&&(x=JSON.parse(s),p="granted")}catch{}return()=>{v.delete(n)}},[]),{coords:x,status:p,request:G}}function X(t,n){const a=d=>d*Math.PI/180,l=a(n.lat-t.lat),o=a(n.lng-t.lng),r=a(t.lat),i=a(n.lat),c=Math.sin(l/2)**2+Math.cos(r)*Math.cos(i)*Math.sin(o/2)**2;return 2*3958.8*Math.asin(Math.sqrt(c))}function H(){const{coords:t,status:n,request:s}=A();return{miles:t?X(t,z):null,status:n,request:s}}function J({title:t,text:n,path:s,className:a,variant:l="icon",label:o="Share"}){const[r,i]=f.useState(!1),c=async d=>{d.preventDefault(),d.stopPropagation();const m=typeof window<"u"?new URL(s,window.location.origin).toString():s;try{if(typeof navigator<"u"&&navigator.share){await navigator.share({title:t,text:n??t,url:m});return}}catch{}try{await navigator.clipboard.writeText(m),i(!0),setTimeout(()=>i(!1),1800)}catch{window.prompt("Copy link",m)}};return l==="button"?e.jsxs("button",{type:"button",onClick:c,"aria-label":o,className:j("inline-flex items-center gap-2 rounded-full border border-border bg-background px-4 py-2 text-sm font-medium shadow-sm transition hover:bg-accent",a),children:[r?e.jsx(N,{className:"h-4 w-4"}):e.jsx(_,{className:"h-4 w-4"}),r?"Link copied":o]}):e.jsx("button",{type:"button",onClick:c,"aria-label":o,title:o,className:j("inline-flex items-center justify-center rounded-full bg-background/85 p-2 text-foreground shadow backdrop-blur transition hover:bg-background",a),children:r?e.jsx(N,{className:"h-4 w-4"}):e.jsx(_,{className:"h-4 w-4"})})}const b=t=>new Intl.NumberFormat("en-GB",{style:"currency",currency:"GBP",maximumFractionDigits:0}).format(t);function U(t){if(!t.offer_active)return null;const n=Number(t.price??0),s=Number(t.market_price??0),a=s>n?s-n:0,l=s>0&&a>0?Math.round(a/s*100):0,o=t.offer_expires_at?new Date(t.offer_expires_at):null,r=Date.now(),i=o?o.getTime()<r:!1;if(i)return null;const c=o?o.getTime()-r:null,d=a>0?`Save ${b(a)}`:"Special Offer";return{active:!0,label:t.offer_label?.trim()||d,savings:a,percent:l,marketPrice:s,expiresAt:o,expired:i,expiresInMs:c}}function V(t){const[,n]=f.useState(0);if(f.useEffect(()=>{if(!t)return;const i=setInterval(()=>n(c=>c+1),6e4);return()=>clearInterval(i)},[t]),!t)return null;const s=t.getTime()-Date.now();if(s<=0)return"Ending now";const a=Math.floor(s/6e4),l=Math.floor(a/1440),o=Math.floor(a%1440/60),r=a%60;return l>0?`${l}d ${o}h left`:o>0?`${o}h ${r}m left`:`${r}m left`}function Y({offer:t}){const n=V(t.expiresAt);return e.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 flex items-start justify-between gap-1 p-2",children:[t.percent>0?e.jsxs("div",{className:"inline-flex items-center rounded-full bg-gradient-to-r from-destructive to-orange-500 px-2 py-0.5 text-[11px] font-bold text-white shadow ring-1 ring-white/20",children:[e.jsx(S,{className:"mr-1 h-3 w-3"}),"â",t.percent,"%"]}):e.jsx("span",{}),n&&e.jsxs("div",{className:"inline-flex items-center gap-1 rounded-full bg-foreground
1/85 px-2 py-0.5 text-[10px] font-medium text-background shadow backdrop-blur",children:[e.jsx(P,{className:"h-3 w-3"})," ",n]})]})}function K({offer:t}){const n=f.useRef(null),[s,a]=f.useState("hidden");if(f.useEffect(()=>{const o=n.current;if(!o)return;let r,i;const c=new IntersectionObserver(d=>{d.forEach(m=>{m.isIntersecting&&s==="hidden"&&(a("in"),r=setTimeout(()=>a("out"),2200),i=setTimeout(()=>a("done"),2900),c.disconnect())})},{threshold:.35});return c.observe(o),()=>{c.disconnect(),clearTimeout(r),clearTimeout(i)}},[s]),s==="done")return null;const l=s==="in";return e.jsxs("div",{ref:n,className:"pointer-events-none absolute inset-0 z-30 overflow-hidden","aria-hidden":"true",children:[e.jsx("style",{children:` 2 @keyframes cloud-pop { 3 0% { transform: scale(0.5) rotate(-6deg); opacity: 0; filter: blur(6px); } 4 60% { transform: scale(1.08) rotate(2deg); opacity: 1; filter: blur(0); } 5 100% { transform: scale(1) rotate(0deg); opacity: 1; filter: blur(0); } 6 } 7 @keyframes cloud-out { 8 0% { opacity: 1; filter: blur(0); } 9 100% { opacity: 0; filter: blur(4px); transform: translate(var(--tx,0), -12px) scale(1.1); } 10 } 11 @keyframes cloud-orbit { 12 0% { top: 6%; left: 6%; } 13 20% { top: 4%; left: 55%; } 14 40% { top: 42%; left: 68%; } 15 60% { top: 78%; left: 55%; } 16 80% { top: 82%; left: 8%; } 17 100% { top: 6%; left: 6%; } 18 } 19 @keyframes sparkle-twinkle { 20 0%,100% { transform: scale(0.8); opacity: 0.3; } 21 50% { transform: scale(1.2); opacity: 1; } 22 } 23 `}),e.jsx("div",{className:"absolute",style:{top:"6%",left:"6%",animation:l?"cloud-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both, cloud-orbit 2.4s ease-in-out 0.55s 1 forwards":"cloud-out 0.55s ease-in forwards"},children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute -inset-3 rounded-[999px] bg-white/70 blur-md dark:bg-white/40"}),e.jsx("div",{className:"absolute -left-4 top-1 h-6 w-6 rounded-full bg-white/80 blur-[2px] dark:bg-white/60"}),e.jsx("div",{className:"absolute -right-3 -top-1 h-5 w-5 rounded-full bg-white/80 blur-[2px] dark:bg-white/60"}),e.jsx("div",{className:"absolute -bottom-2 left-6 h-4 w-4 rounded-full bg-white/80 blur-[2px] dark:bg-white/60"}),e.jsx("span",{className:"absolute -left-5 -top-3 text-yellow-400",style:{animation:"sparkle-twinkle 1.4s ease-in-out infinite"},children:"â¦"}),e.jsx("span",{className:"absolute -right-4 top-4 text-pink-400",style:{animation:"sparkle-twinkle 1.6s ease-in-out 0.3s infinite"},children:"â§"}),e.jsx("span",{className:"absolute -bottom-3 right-8 text-orange-400",style:{animation:"sparkle-twinkle 1.8s ease-in-out 0.6s infinite"},children:"â¦"}),e.jsxs("div",{className:"relative flex items-center gap-1.5 rounded-full bg-gradient-to-r from-fuchsia-500 via-rose-500 to-orange-500 px-3.5 py-1.5 text-white shadow-[0_10px_30px_-8px_rgba(244,63,94,0.6)] ring-1 ring-white/40",children:[e.jsx(S,{className:"h-3.5 w-3.5 drop-shadow"}),e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wide drop-shadow-sm",children:t.label})]})]})})]})}function Q({images:t,alt:n,featured:s,status:a,sharePath:l,shareTitle:o}){const[r,i]=f.useState(0),c=f.useRef(null),d=t.length,m=u=>{d!==0&&i((u%d+d)%d)},C=u=>{c.current=u.touches[0].clientX},M=u=>{if(c.current===null)return;const h=u.changedTouches[0].clientX-c.current;Math.abs(h)>40&&m(h<0?r+1:r-1),c.current=null},w=u=>{u.preventDefault(),u.stopPropagation()};return e.jsxs("div",{className:"relative aspect-[16/10] overflow-hidden bg-muted select-none",onTouchStart:C,onTouchEnd:M,children:[d===0?e.jsx("div",{className:"flex h-full w-full items-center justify-center text-muted-foreground",children:"No image"}):e.jsx("div",{className:"flex h-full w-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${r*100}%)`},children:t.map((u,h)=>e.jsx("img",{src:u,alt:`${n} â photo ${h+1}`,loading:h===0?"eager":"lazy",draggable:!1,className:"h-full w-full flex-shrink-0 object-cover"},h))}),s&&e.jsx(k,{className:"pointer-events-none absolute left-3 top-3 bg-gradient-hero text-primary-foreground shadow",children:"Featured"}),a!=="available"&&e.jsx(k,{variant:"secondary",className:"pointer-events-none absolute right-3 top-3 capitalize",children:a}),e.jsx(J,{path:l,title:o,text:`Check out this ${o} at Pulse Cars`,className:`absolute ${a!=="available"?"top-12":"top-3"} right-3 z-10`,label:"Share this car"}),d>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Previous photo",onClick:u=>{w(u),m(r-1)},className:"absolute left-2 top-1/2 hidden -translate-y-1/2 items-center justify-center rounded-full bg-background/80 p-1.5 text-foreground shadow backdrop-blur transition hover:bg-background sm:flex",children:e.jsx(E,{className:"h-4 w-4"})}
23),e.jsx("button",{type:"button","aria-label":"Next photo",onClick:u=>{w(u),m(r+1)},className:"absolute right-2 top-1/2 hidden -translate-y-1/2 items-center justify-center rounded-full bg-background/80 p-1.5 text-foreground shadow backdrop-blur transition hover:bg-background sm:flex",children:e.jsx(I,{className:"h-4 w-4"})}),e.jsx("div",{className:"pointer-events-none absolute bottom-2 left-1/2 flex -translate-x-1/2 gap-1.5 rounded-full bg-background/70 px-2 py-1 backdrop-blur",children:t.map((u,h)=>e.jsx("span",{className:`h-1.5 rounded-full transition-all ${h===r?"w-4 bg-primary":"w-1.5 bg-foreground/40"}`},h))}),e.jsxs("div",{className:"pointer-events-none absolute right-3 bottom-3 rounded-full bg-background/80 px-2 py-0.5 text-[10px] font-medium text-foreground shadow backdrop-blur",children:[r+1,"/",d]})]})]})}function ne({car:t}){const{miles:n,status:s,request:a}=H(),l=U(t),o=f.useMemo(()=>[...t.image_url?[t.image_url]:[],...(t.gallery_urls??[]).filter(i=>i&&i!==t.image_url)],[t.image_url,t.gallery_urls]);return e.jsx($,{to:"/car/$id",params:{id:t.id},className:"group block overflow-hidden rounded-2xl border border-border bg-card shadow-card transition-all hover:-translate-y-1 hover:shadow-elegant",children:e.jsxs("article",{className:"relative",children:[e.jsxs("div",{className:"relative",children:[l&&e.jsx(Y,{offer:l}),e.jsx(Q,{images:o,alt:`${t.year} ${t.make} ${t.model}`,featured:t.featured,status:t.status,sharePath:`/car/${t.id}`,shareTitle:`${t.year} ${t.make} ${t.model}`})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-display text-lg font-semibold leading-tight",children:[t.make," ",t.model]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.year," · ",t.body_type,t.stock_number&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"font-medium text-foreground/80",children:["#",t.stock_number]})]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-display text-xl font-bold text-primary",children:b(Number(t.price))}),l&&l.savings>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-muted-foreground line-through",children:b(l.marketPrice)}),e.jsxs("div",{className:"text-[11px] font-semibold text-destructive",children:["You save ",b(l.savings)]})]})]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(T,{className:"h-3.5 w-3.5"}),t.mileage.toLocaleString()," mi"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(O,{className:"h-3.5 w-3.5"}),t.fuel_type]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(B,{className:"h-3.5 w-3.5"}),t.transmission]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(L,{className:"h-3.5 w-3.5"}),n!==null?e.jsxs(e.Fragment,{children:[n<10?n.toFixed(1):Math.round(n)," mi away"]}):s==="loading"?"Locatingâ¦":s==="denied"||s==="unavailable"?"Birmingham B19":e.jsx("button",{type:"button",onClick:r=>{r.preventDefault(),r.stopPropagation(),a()},className:"underline-offset-2 hover:text-primary hover:underline",children:"Show distance"})]})]}),t.description&&e.jsx("p",{className:"mt-3 line-clamp-2 text-sm text-muted-foreground",children:t.description})]}),l&&e.jsx(K,{offer:l})]})})}export{ne as C,O as F,Y as O,J as S,B as a,E as b,U as g,H as u};
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.