import{_ as e,d as t,f as n,h as r,i,m as a,r as o,t as s,v as c}from"./index-DOJOKqWn.js";import{t as l}from"./ProductCard-CKE7M369.js";var u=c(e(),1),d=t();function f(){let{collectionId:e}=r(),{products:t,loading:c}=o(),f=a(),[p,m]=(0,u.useState)(null),[h,g]=(0,u.useState)(!0),[_,v]=(0,u.useState)(null);(0,u.useEffect)(()=>{async function t(){g(!0),v(null);try{let t=await i.getCollection(e);t&&t.success&&t.collection?m(t.collection):v(`Collection not found.`)}catch(e){console.error(`Failed to load collection details:`,e),v(e.message||`Failed to load collection.`)}finally{g(!1)}}t()},[e]);let y=t.filter(t=>t.collection_id&&t.collection_id.toLowerCase()===e.toLowerCase()),b=y.length>0?y[0].image:``;if(h||c)return(0,d.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-obsidian py-24`,children:(0,d.jsx)(s,{})});if(_||!p)return(0,d.jsxs)(`div`,{className:`min-h-screen flex flex-col items-center justify-center bg-obsidian text-center px-4 py-24`,children:[(0,d.jsx)(`h1`,{className:`font-cinzel text-3xl text-gold mb-4`,children:`Collection Not Found`}),(0,d.jsx)(`p`,{className:`text-text-secondary mb-8`,children:`The collection you are trying to view does not exist or has been archived.`}),(0,d.jsx)(n,{to:`/shop`,className:`px-6 py-3 border border-gold text-gold hover:bg-gold hover:text-obsidian transition-all duration-300 font-cinzel tracking-wider`,children:`Return to Treasury`})]});let x=p.name||p.slug.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `);return(0,d.jsxs)(`main`,{className:`min-h-screen bg-obsidian text-parchment pb-24`,style:{direction:`ltr`},children:[(0,d.jsx)(`div`,{className:`max-w-7xl mx-auto px-6 pt-6 mb-4`,children:(0,d.jsx)(`button`,{onClick:()=>f(-1),className:`btn-seal btn-seal-ghost`,style:{padding:`8px 20px`,fontSize:`9px`,letterSpacing:`0.2em`},children:`← Back`})}),(0,d.jsxs)(`div`,{className:`relative w-full h-[50vh] md:h-[60vh] flex items-center justify-center overflow-hidden border-b border-border`,children:[(0,d.jsxs)(`div`,{className:`absolute inset-0 z-0`,children:[(0,d.jsx)(`img`,{src:p.banner||`/api/image.php?path=collections/${p.slug}/banner.png`,alt:x,className:`w-full h-full object-cover scale-105 filter brightness-[0.55] contrast-[1.1] blur-[1px]`,onError:e=>{b&&!e.target.dataset.triedFallback?(e.target.dataset.triedFallback=`true`,e.target.src=b):(e.target.onerror=null,e.target.style.display=`none`)}}),(0,d.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-t from-obsidian via-transparent to-obsidian opacity-70`}),(0,d.jsx)(`div`,{className:`absolute inset-0 bg-radial-gradient from-transparent to-obsidian opacity-40`})]}),(0,d.jsxs)(`div`,{className:`relative z-10 max-w-4xl mx-auto text-center px-6 mt-12`,children:[(0,d.jsx)(`span`,{className:`font-cinzel text-xs text-gold tracking-[0.3em] uppercase block mb-4 animate-fade-in`,children:`Heritage Collection`}),(0,d.jsx)(`h1`,{className:`font-cinzel text-4xl md:text-6xl font-medium tracking-[0.12em] text-parchment mb-4 drop-shadow-[0_4px_12px_rgba(0,0,0,0.8)]`,children:x}),(0,d.jsx)(`div`,{className:`ornament mb-6`,children:(0,d.jsx)(`div`,{className:`ornament-diamond`})}),(0,d.jsx)(`p`,{className:`font-display text-lg md:text-xl text-text-secondary italic max-w-2xl mx-auto leading-relaxed drop-shadow-[0_2px_4px_rgba(0,0,0,0.6)]`,children:p.description||`Distilled using ancient ancestral methods passed down through generations of Al-Faras master perfumers.`})]})]}),(0,d.jsxs)(`div`,{className:`max-w-7xl mx-auto px-6 mt-16`,children:[(0,d.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-end justify-between border-b border-border pb-6 mb-12`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h2`,{className:`font-cinzel text-xl text-gold tracking-widest uppercase mb-2`,children:`Available Formulations`}),(0,d.jsxs)(`p`,{className:`text-sm text-text-muted`,children:[`Discover `,y.length,` sovereign artifact`,y.length===1?``:`s`,` in this collection.`]})]}),(0,d.jsx)(n,{to:`/shop`,className:`text-xs text-gold font-cinzel hover:text-gold-bright tracking-widest uppercase transition-all duration-300 mt-4 md:mt-0 flex items-center gap-2`,children:`← Browse All Collections`})]}),y.length===0?(0,d.jsxs)(`div`,{className:`text-center py-20 border border-dashed border-border rounded-lg bg-obsidian-2`,children:[(0,d.jsx)(`p`,{className:`text-text-muted italic mb-6`,children:`No products are currently cataloged under this collection.`}),(0,d.jsx)(n,{to:`/shop`,className:`px-6 py-2 border border-gold text-xs text-gold hover:bg-gold hover:text-obsidian transition-all duration-300 font-cinzel tracking-wider`,children:`Explore Main Treasury`})]}):(0,d.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-12`,children:y.map(e=>(0,d.jsx)(l,{product:e},e.id))})]})]})}export{f as default};