1import{a as o,j as e}from"./query-Ban24u4e.js";import{b as ie,d as le,F as x,B as k,L as $,H as ce,m as Q,P as de,a as J,M as me,e as ue,S as xe}from"./index-jvhwSSW_.js";import{g as W,a as I,b as pe,c as ge,d as be,S as u,C as he}from"./catalog-subgraph-D0LzZVVf.js";import{C as fe}from"./circle-alert-BHEc1-J8.js";import{C as je}from"./check-Dcx7_PRd.js";import"./radix-ui-DdasXo-Q.js";const c="https://ctvcam.com",ye={bullet:"/airo-assets/images/products/bullet-camera-dvr"};function P(a){if(!a)return null;const b=(a.label??a.name??"").toLowerCase();for(const[h,t]of Object.entries(ye))if(b.includes(h))return t;return null}function T(a){return a==null?"":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(a/100)}function Ie(){var U,R,E,H,M;const{id:a}=ie(),{addItem:b,loading:h}=le(),[t,X]=o.useState(null),[l,f]=o.useState(null),[Y,O]=o.useState(!0),[j,Z]=o.useState({}),[ee,K]=o.useState(null),[A,F]=o.useState(1),[y,B]=o.useState(!1),[z,v]=o.useState(null);o.useEffect(()=>{if(!a)return;O(!0),v(null);const s=new URLSearchParams;Object.values(j).forEach(r=>s.append("attributeValues",r)),fetch(`/api/commerce/products/${a}?${s.toString()}`).then(r=>r.json()).then(r=>{X(r.skuGroup??null),r.skuGroup||v("Product not found.");const m=W(r.skuGroup)??P(r.skuGroup??null);K(m)}).catch(()=>v("Failed to load product.")).finally(()=>O(!1))},[a,j]),o.useEffect(()=>{if(!t)return;const s=I(t);if(!s){f(null);return}fetch(`/api/commerce/skus/${s}`).then(r=>r.json()).then(r=>f(r.sku??null)).catch(()=>f(null))},[t]);const te=(s,r)=>{Z(m=>({...m,[s]:r}))},se=async()=>{if(!t)return;const s=(l==null?void 0:l.id)??I(t);if(!s)return;const r=W(l??t)??P(t)??void 0;await b(s,t.label??t.name??"Product",A,r),B(!0),setTimeout(()=>B(!1),2500)},N=pe(t),C=ge(t),re=P(t),p=ee??C[0]??re??null,g=be(l)===0,L=I(t),ae=!!L&&!g,d=(U=t==null?void 0:t.priceRange)==null?void 0:U.min,_=(R=t==null?void 0:t.priceRange)==null?void 0:R.max,ne=d?d===_?T(d):`${T(d)} â ${T(_)}`:"Contact for price",i=(t==null?void 0:t.label)??(t==null?void 0:t.name)??"Product";if(Y)return e.jsx("main",{className:"pt-20 min-h-screen bg-background",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10",children:[e.jsx(u,{className:"h-4 w-32 mb-8"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12",children:[e.jsx(u,{className:"aspect-square rounded-xl"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(u,{className:"h-8 w-3/4"}),e.jsx(u,{className:"h-6 w-1/3"}),e.jsx(u,{className:"h-24 w-full"}),e.jsx(u,{className:"h-12 w-full"})]})]})]})});if(z||!t)return e.jsx("main",{className:"pt-20 min-h-screen bg-background flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(fe,{size:48,className:"text-muted-foreground/30 mx-auto mb-4"}),e.jsx("h2",{className:"text-foreground font-semibold text-xl mb-2",children:e.jsx(x,{devId:"ba4341",guard:{file:"src/pages/products/[id].tsx",tagName:"h2",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:8f0a73247f99c48c32589603788b4b75a6c9014afa2b748677ffc7638f8c636f"},children:z??"Product not found"})}),e.jsx(k,{asChild:!0,variant:"outline",className:"mt-4 border-border text-foreground hover:border-primary hover:text-primary",children:e.jsx($,{to:"/products",children:"Back to Products"})})]})});const oe={"@context":"https://schema.org","@type":"Product",name:i,description:t.description??`Commercial-grade ${i} from CTVCam. Professional installation available.`,url:`${c}/products/${a}`,brand:{"@type":"Brand",name:"CTVCam"},offers:{"@type":"Offer",priceCurrency:"USD",price:d?(d/100).toFixed(2):void 0,availability:g?"https://schema.org/OutOfStock":"https://schema.org/InStock",url:`${c}/products/${a}`,seller:{"@id":`${c}/#organization`}}},D=(()=>{const s=p;return s?s.startsWith("http")?s:`${c}${s}`:`${c}/og-image.png`})(),w=((E=t.description)==null?void 0:E.slice(0,160))??`Buy ${i} from CTVCam. Commercial-grade security systems with professional installation available in Texas.`;return e.jsxs(e.Fragment,{children:[e.jsxs(ce,{children:[e.jsxs("title",{children:[i," â CTVCam"]}),e.jsx("meta",{name:"description",content:w}),e.jsx("link",{rel:"canonical",href:`${c}/products/${a}`}),e.jsx("meta",{property:"og:title",content:`${i} â CTVCam`}),e.jsx("meta",{property:"og:description",content:w}),e.jsx("meta",{property:"og:type",content:"product"}),e.jsx("meta",{property:"og:url",content:`${c}/products/${a}`}),e.jsx("meta",{property:"og:image",content:D}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:`${i} â CTVCam`}),e.jsx("meta",{name:"twitter:description",content:w}),e.jsx("meta",{name:"twitter:image",content:D}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(oe)})]}),e.jsx("main",{className:"pt-20 min-h-screen bg-background",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[e.jsx("nav",{"aria-label":"Breadcrumb",className:"mb-8",children:e.jsxs($,{to:"/products",className:"inline-flex items-center gap-1.5 text-muted-foreground hover:text-primary text-sm transition-colors",children:[e.jsx(he,{size:15}),"Back to Products"]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12","data-dev-source-origin":"commerce","data-dev-commerce-product-id":t.id??"","data-dev-commerce-sku-id":(l==null?void 0:l.id)??void 0,children:[e.jsxs(Q.div,{initial:{opacity:0,x:-20}
1,animate:{opacity:1,x:0},transition:{duration:.4,ease:"easeOut"},children:[e.jsx("div",{className:"rounded-xl overflow-hidden border border-border/60 bg-card aspect-square mb-4",children:p?e.jsx("img",{src:p,alt:i,className:"w-full h-full object-cover",loading:"eager",fetchPriority:"high",width:600,height:600}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(de,{size:64,className:"text-muted-foreground/30"})})}),C.length>1&&e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:C.slice(0,6).map((s,r)=>e.jsx("button",{onClick:()=>K(s),className:`shrink-0 w-16 h-16 rounded-lg overflow-hidden border-2 transition-all ${p===s?"border-primary":"border-border/60 hover:border-border"}`,children:e.jsx("img",{src:s,alt:`${i} view ${r+1}`,className:"w-full h-full object-cover",loading:"lazy",width:64,height:64})},r))})]}),e.jsxs(Q.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},transition:{duration:.4,ease:"easeOut"},className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(J,{className:"bg-primary/10 text-primary border border-primary/30 text-xs",children:"Security System"}),g&&e.jsx(J,{variant:"destructive",className:"text-xs",children:"Out of Stock"})]}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold text-foreground mb-4 leading-tight",children:e.jsx(x,{devId:"dce50d",guard:{file:"src/pages/products/[id].tsx",tagName:"h1",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:1aca80e8b55c802f7b43740da2990e1b5735bbb323d93eb5ebda8395b04025e2"},children:i})}),e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-3xl font-bold text-primary",children:e.jsx(x,{devId:"e51619",guard:{file:"src/pages/products/[id].tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:59d3d5f6b39bdfd9ab5aa4ed690b99e56bac55644aca6fe058e5510828cd84ce"},children:ne})}),((H=t.priceRange)==null?void 0:H.min)!==((M=t.priceRange)==null?void 0:M.max)&&e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Price varies by configuration"})]}),t.description&&(()=>{const r=t.description.split(/\r?\n|\\n/).map(n=>n.trim()).filter(Boolean),m=r.length===1&&r[0].includes("â¢")?r[0].split("â¢").map(n=>n.trim()).filter(Boolean).map((n,S)=>S===0?n:"⢠"+n):r,V=n=>/^[â¢\-â]/.test(n),q=m.filter(V),G=m.filter(n=>!V(n));return e.jsxs("div",{className:"mb-6 p-4 rounded-lg bg-card border border-border/40",children:[G.length>0&&e.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed mb-3",children:e.jsx(x,{devId:"f72e9a",guard:{file:"src/pages/products/[id].tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:e14a6a139b35f52e7b75c29c9a401641383b5abb400f7ebe5aad52189fe986df"},children:G.join(" ")})}),q.length>0&&e.jsx("ul",{className:"flex flex-col gap-1.5",children:q.map((n,S)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{className:"mt-0.5 shrink-0 w-4 h-4 rounded-full bg-primary/10 border border-primary/30 flex items-center justify-center",children:e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary block"})}),e.jsx("span",{children:n.replace(/^[â¢\-â]\s*/,"")})]},S))})]})})(),N.length>0&&e.jsx("div",{className:"mb-6 flex flex-col gap-4",children:N.map(s=>e.jsxs("div",{children:[e.jsx("p",{className:"text-foreground text-sm font-semibold mb-2",children:s.label}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.values.map(r=>e.jsx("button",{onClick:()=>te(s.id,r.id),className:`px-3 py-1.5 rounded-md text-sm border transition-all duration-200 ${j[s.id]===r.id?"bg-primary text-primary-foreground border-primary":"bg-card text-muted-foreground border-border/60 hover:border-primary/50 hover:text-foreground"}`,children:r.label},r.id))})]},s.id))}),e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsxs("div",{className:"flex items-center border border-border/60 rounded-lg overflow-hidden bg-card",children:[e.jsx("button",{onClick:()=>F(s=>Math.max(1,s-1)),className:"px-3 py-2.5 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors","aria-label":"Decrease quantity",children:e.jsx(me,{size:14})}),e.jsx("span",{className:"px-4 py-2.5 text-foreground font-medium text-sm min-w-[3rem] text-center border-x border-border/60",children:e.jsx(x,{devId:"f4a392",guard:{file:"src/pages/products/[id].tsx",tagName:"span",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionH
1ash:"sha256:1a7b308d8df661bad4338cb6acfa57891ac9d97b434d315b993214248ca3ddb2"},children:A})}),e.jsx("button",{onClick:()=>F(s=>s+1),className:"px-3 py-2.5 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors","aria-label":"Increase quantity",children:e.jsx(ue,{size:14})})]}),e.jsx(k,{onClick:se,disabled:!ae||h||y,size:"lg",className:`flex-1 font-semibold transition-all duration-300 ${y?"bg-green-600 hover:bg-green-600 text-white":"bg-primary hover:bg-primary/90 text-primary-foreground shadow-[0_0_20px_hsl(var(--primary)/0.3)] hover:shadow-[0_0_30px_hsl(var(--primary)/0.5)]"}`,children:y?e.jsxs(e.Fragment,{children:[e.jsx(je,{size:16,className:"mr-2"}),"Added to Cart"]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{size:16,className:"mr-2"}),g?"Out of Stock":N.length>0&&!L?"Select Options":"Add to Cart"]})})]}),e.jsx(k,{asChild:!0,variant:"outline",size:"lg",className:"border-border text-foreground hover:border-primary hover:text-primary w-full",children:e.jsx($,{to:"/services",children:"Request Professional Installation Quote"})}),e.jsx("div",{className:"mt-6 pt-6 border-t border-border/40 grid grid-cols-3 gap-4 text-center",children:[{label:"Licensed & Insured",sub:"Certified install team"},{label:"Free Consultation",sub:"On-site assessment"},{label:"24/7 Support",sub:"After-install care"}].map(s=>e.jsxs("div",{children:[e.jsx("p",{className:"text-foreground text-xs font-semibold",children:s.label}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:s.sub})]},s.label))})]})]})]})})]})}export{Ie 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.