1import{$ as E,r as n,V as l,j as e,S as T,W as S,h as $,B,F as D,Y as R,a0 as q}from"./index-DI7_N6HT.js";import{C as Y}from"./CartDrawer-CCddz6Qb.js";import{A as _}from"./arrow-left-pwUuoiYt.js";import{L as C}from"./trash-2-C-FRpB3g.js";import"./leptin-hero-tablet-CVFLss-Q.js";import"./insulin3d-jiHmT57p.js";import"./cortisol3d-CRiM5h7F.js";import"./estrogen3d-Cdb0Gwls.js";import"./metabolism-hero-tablet-Gl_Wbgs8.js";import"./shield-check-knD55rmA.js";import"./leptin-bottle-single-PvjEmkgi.js";import"./insulin-bottle-single-BbOGA2sx.js";import"./estrogen-bottle-single-BEOQta20.js";import"./metabolism-bottle-single-DAsKtAyu.js";const re=()=>{var x,u,h,f,g,b,j,v,y,N;const{handle:i}=E(),[t,k]=n.useState(null),[I,L]=n.useState(!0),[m,P]=n.useState(0),[d,O]=n.useState(0),F=l(s=>s.addItem),p=l(s=>s.isLoading);n.useEffect(()=>{i&&(async()=>{var a;try{const o=await R(q,{handle:i});(a=o==null?void 0:o.data)!=null&&a.product&&k(o.data.product)}catch(o){console.error("Failed to fetch product:",o)}finally{L(!1)}})()},[i]);const H=async()=>{var a;if(!t)return;const s=(a=t.variants.edges[m])==null?void 0:a.node;s&&(await F({product:{node:t},variantId:s.id,variantTitle:s.title,price:s.price,quantity:1,selectedOptions:s.selectedOptions||[]}),l.getState().openCart())},r=(x=t==null?void 0:t.variants.edges[m])==null?void 0:x.node;return e.jsxs("div",{className:"min-h-screen bg-background font-body",children:[e.jsx(T,{title:t?`${t.title} | Hormeticsâ¢`:"Product | Hormeticsâ¢",description:(t==null?void 0:t.description)||"Hormetics product",canonical:`https://hormetics.health/product/${i||""}`,ogType:"product",schemaJson:t?{"@context":"https://schema.org","@type":"Product",name:t.title,description:t.description,image:(g=(f=(h=(u=t.images)==null?void 0:u.edges)==null?void 0:h[0])==null?void 0:f.node)==null?void 0:g.url,offers:(y=(v=(j=(b=t.variants)==null?void 0:b.edges)==null?void 0:j[0])==null?void 0:v.node)!=null&&y.price?{"@type":"Offer",price:t.variants.edges[0].node.price.amount,priceCurrency:t.variants.edges[0].node.price.currencyCode,availability:"https://schema.org/InStock",url:`https://hormetics.health/product/${i||""}`}:void 0}:void 0}),e.jsxs("nav",{className:"w-full py-4 px-6 md:px-12 flex items-center justify-between border-b border-border/30",children:[e.jsx(S,{to:"/",children:e.jsx("img",{src:$,alt:"Hormetics â Hormones, Metabolism, Genetics",className:"h-[48px] w-auto"})}),e.jsx(Y,{})]}),e.jsxs("div",{className:"max-w-6xl mx-auto px-6 md:px-12 py-8",children:[e.jsxs(S,{to:"/shop",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-primary mb-6",children:[e.jsx(_,{className:"w-4 h-4"})," Back to Shop"]}),I?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(C,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):t?e.jsxs("div",{className:"grid md:grid-cols-2 gap-10",children:[e.jsxs("div",{children:[e.jsx("div",{className:"aspect-square bg-muted rounded-xl overflow-hidden mb-4",children:((N=t.images.edges[d])==null?void 0:N.node)&&e.jsx("img",{src:t.images.edges[d].node.url,alt:t.images.edges[d].node.altText||t.title,className:"w-full h-full object-cover"})}),t.images.edges.length>1&&e.jsx("div",{className:"flex gap-2 overflow-x-auto",children:t.images.edges.map((s,a)=>e.jsx("button",{onClick:()=>O(a),className:`w-16 h-16 rounded-md overflow-hidden flex-shrink-0 border-2 ${a===d?"border-primary":"border-transparent"}`,children:e.jsx("img",{src:s.node.url,alt:s.node.altText||"",className:"w-full h-full object-cover"})},a))})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-heading font-bold text-primary mb-4",children:t.title}),e.jsxs("p",{className:"text-2xl font-bold text-primary mb-6",children:[r==null?void 0:r.price.currencyCode," ",parseFloat((r==null?void 0:r.price.amount)||"0").toFixed(2)]}),e.jsx("p",{className:"text-foreground leading-relaxed mb-8",children:t.description}),t.variants.edges.length>1&&e.jsx("div",{className:"mb-6",children:t.options.map(s=>e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"text-sm font-medium text-primary mb-2 block",children:s.name}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.values.map(a=>{const o=t.variants.edges.findIndex(c=>c.node.selectedOptions.some(w=>w.name===s.name&&w.value===a)),A=r==null?void 0:r.selectedOptions.some(c=>c.name===s.name&&c.value===a);return e.jsx("button",{onClick:()=>o>=0&&P(o),className:`px-4 py-2 rounded-md border text-sm font-medium transition-colors ${A?"border-primary bg-primary text-primary-foreground":"border-border hover:border-primary"}`,children:a},a)})})]},s.name))}),e.jsx(B,{size:"lg",className:"w-full bg-gradient-to-r from-action to-action-dark hover:brightness-110 text-action-foreground font-heading font-semibold animate-pulse-subtle",onClick:H,disabled:p||!(r!=null&&r.availableForSale),children:r!=null&&r.availableForSale?p?e.jsx(C,{className:"w-4 h-4 animate-spin"}):"Add to Cart":"Out of Stock"})]})]}):e.jsx("p",{className:"text-center py-20 text-muted-foreground",children:"Product not found"})]}),e.jsx(D,{})]})};export{re 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.