import{_ as V}from"./B1u-MKiH.js";import{x as D,f as E,h as H,r as a,j as O,c as o,b as u,k as s,a as t,t as B,m as x,F as k,l as _,Z as T,w,_ as z,$ as A,s as f,o as r,d as N,I as C}from"./D3n9Vtz8.js";import{u as F,S as W,_ as G}from"./BJtCafpw.js";import{_ as I}from"./CSRueqOF.js";const Q={class:"flex min-h-screen flex-col"},Z={class:"mx-auto w-full max-w-6xl flex-1 px-4 pt-8 sm:px-6 lg:px-8"},q={key:0,class:"mb-4 rounded-2xl border border-amber-200 bg-amber-50 p-4 text-amber-900"},J={key:1,class:"rounded-2xl border border-red-200 bg-red-50 p-4 text-red-800"},K={key:2,class:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3"},U={key:3,class:"rounded-2xl border border-[var(--line)] bg-[var(--surface)] p-8 text-center"},X={key:4},Y={key:0,class:"relative mb-10 overflow-hidden rounded-[2rem] border border-[var(--line)] bg-stone-900 text-white"},ee={class:"relative grid min-h-[360px] gap-8 px-6 py-10 sm:px-8 lg:grid-cols-[minmax(0,1.2fr)_280px] lg:px-12 lg:py-14"},te={class:"flex max-w-2xl flex-col justify-end"},se={class:"mt-6 flex flex-wrap gap-3 text-sm"},re={class:"mb-8"},oe={class:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3"},le={key:1},ne={class:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3"},ae={class:"w-full max-w-xl rounded-2xl border border-[var(--line)] bg-[var(--surface)] p-6 shadow-2xl"},ie={class:"mt-4"},de={class:"mt-6 flex justify-end"},xe={__name:"index",setup(ue){D({description:"Minimal NIP-99 webshop with Gamma market checkout flow."});const M=F(),{ensureBootstrap:j,bootstrapState:h}=E(),{setShopDebug:R}=H(),P=a(!0),c=a(""),m=a(""),g=a(h.value.identity?.merchantNpub||""),i=a(h.value.products||[]),p=a(h.value.merchantProfile||null),v=a(!1),b=a(!1),$=f(()=>i.value.slice(0,3)),S=f(()=>i.value.slice(3,15)),y=f(()=>p.value?.banner||""),L=f(()=>!!y.value);return O(async()=>{try{const d=await j(),e=d.identity,l=d.relayMap;g.value=e?.merchantNpub||"",p.value=d.merchantProfile||null,i.value=d.products||[],v.value=!0,b.value=i.value.length===0,R({merchantNpub:e?.merchantNpub||"",merchantPubkey:e?.merchantPubkey||"",identitySource:e?.source||"",relaySource:l?.sources?.merchant||"",themeSource:d.merchantThemeSource||"none",merchantOutbox:l?.merchantOutbox||[],merchantInbox:l?.merchantInbox||[],paymentListenRelays:l?.paymentListenRelays||[],orderPublishRelays:l?.orderPublishRelays||[],lastPage:"index",details:{productsLoaded:i.value.length,noProductsConfirmed:i.value.length===0}})}catch{m.value="Relay connection failed while loading products. Please retry once relays are reachable.",c.value=""}finally{P.value=!1}}),(d,e)=>{const l=V;return r(),o("div",Q,[u(W,{"item-count":s(M).totalItems,"merchant-profile":s(p),"merchant-npub":s(g)},null,8,["item-count","merchant-profile","merchant-npub"]),t("main",Z,[s(m)?(r(),o("section",q,B(s(m)),1)):x("",!0),s(c)?(r(),o("section",J,B(s(c)),1)):s(P)?(r(),o("section",K,[(r(),o(k,null,_(6,n=>t("div",{key:n,class:"h-72 animate-pulse rounded-2xl border border-[var(--line)] bg-[var(--surface)]"})),64))])):s(v)&&s(i).length===0?(r(),o("section",U,[...e[2]||(e[2]=[t("p",{class:"text-lg font-semibold"},"No products found for this merchant.",-1),t("p",{class:"mt-2 text-sm text-[var(--muted)]"},"This npub currently has no published listings.",-1)])])):(r(),o("section",X,[s(L)?(r(),o("section",Y,[t("div",{class:"absolute inset-0 bg-cover bg-center",style:T(s(y)?{backgroundImage:`url(${s(y)})`}:void 0)},null,4),e[6]||(e[6]=t("div",{class:"absolute inset-0 bg-gradient-to-r from-black/80 via-black/60 to-black/35"},null,-1)),e[7]||(e[7]=t("div",{class:"absolute inset-x-0 bottom-0 h-32 bg-gradient-to-t from-black/50 to-transparent"},null,-1)),t("div",ee,[t("div",te,[e[5]||(e[5]=t("p",{class:"text-xs font-semibold uppercase tracking-[0.22em] text-white/70"},"Welcome to the shop !",-1)),t("div",se,[u(l,{to:"/products",class:"inline-flex items-center rounded-full bg-white px-5 py-2.5 font-semibold !text-black transition hover:bg-stone-100 dark:!text-black"},{default:w(()=>[...e[3]||(e[3]=[N(" Browse inventory ",-1)])]),_:1}),u(l,{to:"/categories",class:"inline-flex items-center rounded-full border border-white/30 bg-black px-5 py-2.5 font-semibold !text-white transition hover:bg-black/85 dark:!text-white"},{default:w(()=>[...e[4]||(e[4]=[N(" Explore categories ",-1)])]),_:1})])])])])):x("",!0),t("div",re,[e[8]||(e[8]=t("div",{class:"mb-3 flex items-end justify-between gap-3"},[t("h2",{class:"text-xl font-semibold tracking-tight"},"New Arrivals")],-1)),t("div",oe,[(r(!0),o(k,null,_(s($),n=>(r(),C(I,{key:n.id,product:n},null,8,["product"]))),128))])]),s(S).length?(r(),o("div",le,[e[9]||(e[9]=t("div",{class:"mb-3 flex items-end justify-between gap-3"},[t("h2",{class:"text-xl font-semibold tracking-tight"},"Inventory"),t("p",{class:"text-xs text-[var(--muted)]"},"Everything else in stock")],-1)),t("div",ne,[(r(!0),o(k,null,_(s(S),n=>(r(),C(I,{key:n.id,product:n},null,8,["product"]))),128))])])):x("",!0)]))]),u(G,{"merchant-profile":s(p),"merchant-npub":s(g)},null,8,["merchant-profile","merchant-npub"]),s(b)&&s(v)&&!s(m)&&!s(c)?(r(),o("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 px-4",onClick:e[1]||(e[1]=z(n=>b.value=!1,["self"]))},[t("div",ae,[e[11]||(e[11]=t("h2",{class:"text-2xl font-bold"},"No products yet",-1)),e[12]||(e[12]=t("p",{class:"mt-3 text-sm text-[var(--muted)]"}," Hey! Ready to start listing your first products? ",-1)),t("div",ie,[u(l,{to:"/portal",class:"inline-flex items-center rounded-lg bg-purple-600 px-4 py-2 text-sm font-semibold text-white transition hover:bg-purple-700"},{default:w(()=>[...e[10]||(e[10]=[N(" Open Merchant Portal ",-1)])]),_:1})]),e[13]||(e[13]=A('<p class="mt-2 text-sm text-[var(--muted)]"> Alternatively visit one of these marketplaces to publish your first listings: </p><div class="mt-4 flex flex-wrap gap-2"><a href="https://plebeian.market" target="_blank" rel="noopener noreferrer" class="rounded-full border border-[var(--line)] px-3 py-1 text-sm">plebeian.market</a><a href="https://shopstr.store" target="_blank" rel="noopener noreferrer" class="rounded-full border border-[var(--line)] px-3 py-1 text-sm">shopstr.store</a><a href="https://conduit.market" target="_blank" rel="noopener noreferrer" class="rounded-full border border-[var(--line)] px-3 py-1 text-sm">conduit.market</a></div>',2)),t("div",de,[t("button",{class:"rounded-lg border border-[var(--line)] px-4 py-2 text-sm",onClick:e[0]||(e[0]=n=>b.value=!1)}," Close ")])])])):x("",!0)])}}};export{xe as default};
