import{j as e}from"./ui-vendor-CJlQk0Tq.js";import{L as t,r as s}from"./react-vendor-f6QdChhz.js";import{N as r,fa as i,a,fi as n,B as l,aa as o}from"./index-BzXujQ-F.js";import{g as c,C as d}from"./ColorSection-CG--mthy.js";import{A as m}from"./aspect-ratio-BAn1PH2M.js";import{u}from"./useOptimizedImage--gpLIsCW.js";import{S as x}from"./SocialShareButton-mvbNhE3x.js";const g=({price:t,discountPrice:s,originalPrice:a,discountAmount:n,discountPercentage:l,rentToOwn:o,className:c="",alignment:d="left",status:m,sale:u})=>{const x=(()=>{if(u&&u.price)return u.price;if("discount"===m&&a&&a>0){if(n&&n>0)return a-n;if(l&&l>0)return a-a*l/100}return s&&s>0?s:t})(),g=!!u||"discount"===m&&a&&a>0&&x&&x<a,h=(null==u?void 0:u.originalPrice)||a;return!x||x<=0?null:e.jsxs("div",{className:r(c,"center"===d?"text-center":"text-left"),children:[e.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[e.jsxs("span",{className:r("text-xl font-bold",g?"text-green-600":"text-primary"),children:["$",i(x)]}),g&&h&&e.jsxs("span",{className:"text-sm text-gray-500 line-through",children:["$",i(h)]}),u&&g&&u.originalPrice&&e.jsxs("span",{className:"text-sm font-medium text-red-600",children:[u.label," - Save $",i(u.originalPrice-u.price)]}),!u&&g&&n&&n>0&&e.jsxs("span",{className:"text-xs font-medium bg-green-100 text-green-800 px-2 py-1 rounded",children:["Save $",i(n)]}),!u&&g&&l&&l>0&&!n&&e.jsxs("span",{className:"text-xs font-medium bg-red-100 text-red-800 px-2 py-1 rounded",children:[l,"% Off"]})]}),o&&e.jsxs("p",{className:"text-sm text-blue-600 mt-1",children:["Rent-to-Own: ",o]})]})},h=({imageSrc:s,images:i,altText:n,link:l,itemNumber:o,inDiscountSection:c,discountPercentage:d,soldOut:x,availableNow:g,isInsideLink:h=!1,isGalleryCard:b=!1,sale:p})=>{const f=u(s),j=e.jsxs(m,{ratio:4/3,className:"relative group",children:[e.jsx("img",{src:f.src,srcSet:f.srcSet,sizes:f.sizes,alt:n,width:800,height:600,className:"w-full h-full object-cover transition-transform duration-300 hover:scale-105",loading:"lazy",decoding:"async"}),!x&&g&&e.jsx(a,{className:"absolute top-2 left-2 bg-green-500 hover:bg-green-600 text-white",children:"Available Now"}),x&&e.jsx(a,{className:r("absolute top-2 left-2 text-white",b?"bg-green-600 hover:bg-green-700":"bg-orange-600 hover:bg-orange-700"),children:b?"✓ Completed Project":"Sold Out - Order Custom"}),p&&!x&&e.jsx(a,{className:"absolute top-2 right-2 bg-red-500 hover:bg-red-600 text-white",children:p.label}),!p&&d&&d>0&&!x&&e.jsxs(a,{className:"absolute top-2 right-2 bg-red-500 hover:bg-red-600 text-white",children:[d,"% Off"]}),o&&e.jsxs(a,{className:"absolute bottom-2 left-2 bg-blue-500 hover:bg-blue-600 text-white text-xs",children:["#",o]}),l&&e.jsx("div",{className:"absolute inset-0 bg-black/30 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center",children:e.jsx("div",{className:"bg-white/90 hover:bg-white text-gray-900 px-4 py-2 rounded-full text-sm font-medium shadow-md",children:"View Details"})})]});return l&&!h?e.jsx(t,{to:l,className:"block",children:j}):j},b=s.memo(({id:s,title:i,subtitle:m,description:u,shortDescription:b,useShortDescription:p=!1,imageSrc:f,images:j,altText:N,link:v,price:w,discountPrice:y,colors:S,badges:P=[],className:k,imageClassName:C,children:O,textAlignment:D="left",colorsSectionTitle:T,onClick:z,buttonText:A="View Details",hideButton:L=!1,isStock:$,originalPrice:B,discountAmount:G,discountPercentage:I,dimensions:V,availableNow:F,inventoryCount:H,rentToOwn:M,itemNumber:R,soldOut:U,inDiscountSection:W,tags:Z,sale:q,isGalleryCard:E})=>{const{openSearch:J}=n(),K=p&&b?b:u,Q=q?c({sale:q}):null,X=U?"sold-out":Q||W||B&&B>0&&(G&&G>0||I&&I>0)?"discount":"regular",Y=(()=>{const e=[];return U||1!==H||e.push({text:"Last One!",className:"bg-red-500 text-white animate-pulse"}),!U&&((null==Z?void 0:Z.includes("featured"))||H&&H<=3&&H>1)&&e.push({text:"High Demand",className:"bg-orange-500 text-white"}),F&&!U&&e.push({text:"Fast Delivery",className:"bg-blue-500 text-white"}),e})(),_=e.jsxs("div",{className:r("overflow-hidden bg-background",!v&&k),children:[f&&e.jsx(h,{imageSrc:f,images:j,altText:N||i,link:v,itemNumber:R,inDiscountSection:W,discountPercentage:I,soldOut:U,availableNow:F,isInsideLink:!!v,isGalleryCard:E,sale:Q}),e.jsxs("div",{className:r("p-4","center"===D?"text-center":"text-left"),children:[i&&e.jsx("h3",{className:"text-lg font-semibold text-gray-800",children:i}),m&&e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:m}),Y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:Y.map((t,s)=>e.jsx(a,{className:t.className,children:t.text},s))}),K&&e.jsx("p",{className:"text-sm text-gray-600 mt-1 line-clamp-2",children:K}),U&&e.jsx("div",{className:r("mt-2 p-2 rounded-md",E?"bg-primary/5 border border-primary/20":"bg-orange-50 border border-orange-200"),children:e.jsx("p",{className:r("text-xs font-medium",E?"text-primary":"text-orange-700"),children:E?"Love this design? We can build it for you!":"Available as custom order with same specifications"})}),e.jsx(g,{price:w,discountPrice:y,originalPrice:B,discountAmount:G,discountPercentage:I,rentToOwn:M,status:X,sale:Q,className:"mt-3",alignment:D}),S&&e.jsx(d,{colors:S,title:T,className:"mt-3",alignment:D}),O&&e.jsx("div",{className:"mt-3",children:O}),!L&&e.jsx("div",{className:r("mt-4 flex items-center gap-2","center"===D?"justify-center":"justify-start"),children:e.jsx(l,{variant:U?"default":"outline",size:"sm",className:r(U?"bg-orange-600 hover:bg-orange-700 text-white":"bg-white hover:bg-gray-50 text-primary hover:text-primary-dark"),onClick:z,children:U?"View Details & Order Custom":A})})]})]}),ee=!L&&e.jsxs("div",{className:"px-3 py-1.5 bg-muted/50 border-t border-border flex items-center justify-between",children:[e.jsx(x,{title:i,description:K,url:v||`/structure/${s}`,itemNumber:R,pageType:"structure",imageUrl:f,size:"sm",variant:"ghost",showText:!0}),e.jsxs(l,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-8",onClick:e=>{e.stopPropagation(),J()},children:[e.jsx(o,{className:"h-4 w-4 mr-1"}),"Search"]})]});return e.jsxs("div",{className:r("rounded-lg overflow-hidden shadow-sm hover:shadow-md transition-shadow duration-300 bg-background border",!v&&k),children:[v?e.jsx(t,{to:v,className:"no-underline text-inherit block",onClick:e=>e.stopPropagation(),children:_}):_,ee]})});export{b as S};