1import{j as e}from"./vendor-query-DoHIXVj8.js";import{r as l,f as G}from"./vendor-react-B1CyA2bu.js";import{u as H,s as u,B as d,C,a as B,b as E,d as L,e as U}from"./index-Cn6nJhWG.js";import{B as h}from"./badge-BQ5YkzSG.js";import{u as J}from"./useSubscription-BnXf106d.js";import{u as V}from"./useFeatureAccess-BA-EGnXy.js";import{F as X}from"./FeatureGate-I7UfgdEi.js";import{D as K,a as O,b as Q,c as Z,d as ee,e as se}from"./dialog-BAdzqCSX.js";import{S as te,a as ae,b as re,c as ie,d as oe}from"./select-DRYI-3RU.js";import{T as ne}from"./textarea-BcrZnnCX.js";import{L as q}from"./label-RPqHGtRV.js";import{U as le}from"./user-DPas8mRY.js";import{H as ce}from"./heart-CEw_tAcA.js";import{L as F}from"./loader-circle-Lrf5ROOc.js";import{S as de,R as me}from"./index-Fsh_W-mS.js";import{d as xe}from"./EmptyStates-CC9wceuD.js";import{P as ue}from"./PageSeo-CoI4SHMX.js";import{P as Y}from"./plus-eVwobIJm.js";import{C as z}from"./calendar-DJPhrUD7.js";import{M as A}from"./map-pin-B1BtCxI6.js";import{S as W}from"./save-DDtajKhP.js";import{C as he}from"./circle-check-big-DmcUwc3l.js";import{C as pe}from"./circle-x-6LkAfR4g.js";import{C as ge}from"./clock-f_fY8OtY.js";import{E as fe}from"./external-link-D6FwjmNX.js";import{U as je}from"./user-check-BWMZZsjO.js";import{T as ye}from"./tag-DxvHueel.js";import{f as _}from"./format-DefBTZ8D.js";import"./vendor-supabase-Bxjw3GPQ.js";import"./vendor-ui-Dv9JeOyV.js";import"./crown-BSApa5M1.js";import"./star-CnTIotYq.js";import"./lock-Di89_IEl.js";import"./index-BuWUcE7h.js";import"./index-DHIvYiq8.js";import"./index-BBjTSBt-.js";import"./index-BhIhkUGe.js";import"./index-CQ5kx8W4.js";import"./index-BYGYe9DC.js";import"./index-DzzFT5Tm.js";import"./check-CEjPdstu.js";import"./skeleton-BlYdckzN.js";import"./vendor-motion-BtzdRAwI.js";import"./compass-CcPLoFDB.js";import"./users-DG4jYnw5.js";import"./sparkles-BK2JkoPv.js";import"./en-US-Cp1tQuIh.js";typeof globalThis.require!="function"&&(globalThis.require=function(){return null},window.require=globalThis.require);function Ne({open:p,onOpenChange:v,retreat:a,userId:g}){const[r,y]=l.useState("solo"),[i,S]=l.useState([]),[c,k]=l.useState(""),[R,M]=l.useState(""),[N,b]=l.useState(!1),[T,m]=l.useState(!1),{toast:w}=H(),o=r==="for_two"?a.price*2:a.price;l.useEffect(()=>{p&&r==="for_two"&&$()},[p,r]);const $=async()=>{m(!0);try{const{data:t,error:f}=await u.from("matches").select("id, user1_id, user2_id").or(`user1_id.eq.${g},user2_id.eq.${g}`).eq("is_mutual",!0);if(f)throw f;const x=[];for(const s of t||[]){const n=s.user1_id===g?s.user2_id:s.user1_id,{data:j}=await u.from("profiles").select("display_name").eq("user_id",n).single();x.push({match_id:s.id,partner_id:n,partner_name:(j==null?void 0:j.display_name)||"Unknown"})}S(x)}catch(t){console.error("Error fetching matches:",t)}finally{m(!1)}},D=async()=>{b(!0);try{const t=i.find(s=>s.match_id===c),{error:f}=await u.from("retreat_bookings").insert({retreat_id:a.id,booker_user_id:g,partner_user_id:r==="for_two"?t==null?void 0:t.partner_id:null,match_id:r==="for_two"?c:null,booking_type:r,total_price:o,paid_by:"booker",booker_amount:o,partner_amount:0,notes:R||null,payment_status:"pending"});if(f)throw f;const{data:{user:x}}=await u.auth.getUser();await u.functions.invoke("notify-retreat-activity",{body:{action:"booked",retreatTitle:a.title,retreatLocation:a.location,retreatPrice:o,userEmail:(x==null?void 0:x.email)||"unknown",retreatId:a.id,retreatContactEmail:a.contact_email||null,retreatExternalUrl:a.external_url||null,bookerUserId:g,partnerUserId:r==="for_two"?t==null?void 0:t.partner_id:null,partnerName:r==="for_two"?t==null?void 0:t.partner_name:null,changes:r==="for_two"?`Booked for two (with ${t==null?void 0:t.partner_name}). Total: $${o}`:`Solo booking. Total: $${o}`}}),w({title:"Retreat Booked!",description:r==="for_two"?`You've booked "${a.title}" for you and ${t==null?void 0:t.partner_name}. Total: $${o}`:`You've booked "${a.title}". Total: $${o}`}),v(!1),y("solo"),k(""),M("")}catch(t){console.error("Booking error:",t),w({title:"Booking Failed",description:t.message||"Could not complete the booking",variant:"destructive"})}finally{b(!1)}};return e.jsx(K,{open:p,onOpenChange:v,children:e.jsxs(O,{className:"sm:max-w-md",children:[e.jsxs(Q,{children:[e.jsx(Z,{children:"Book Retreat"}),e.jsxs(ee,{children:[a.title," â ",a.location]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(q,{children:"Booking type"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(d,{variant:r==="solo"?"default":"outline",size:"sm",onClick:()=>y("solo"),className:"flex-1",children:[e.jsx(le,{className:"h-4 w-4 mr-1"})," Just Me"]}),e.jsxs(d,{variant:r==="for_two"?"default":"outline",size:"sm",onClick:()=>y("for_two"),className:"flex-1",children:[e.jsx(ce,{className:"h-4 w-4 mr-1"})," For Two"]})]})]}),r==="for_two"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(q,{children:"Select your match"}),T?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(F,{className:"h-4 w-4 animate-spin"})," Loading matches..."]}):i.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"You don't have any mutual matches yet. Match with someone first!"}):e.jsxs(te,{value:c,onValueChange:k,children:[e.jsx(ae,{children:e.jsx(re,{placeholder:"Choose a match..."})}),e.jsx(ie,{children:i.map(t=>e.jsx(oe,{value:t.match_id,children:t.partner_name},t.match_id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(q,{children:"Notes (optional)"}),e.jsx(ne,{value:R,onChange:t=>M(t.target.value),placeholder:"Any special requests or dietary needs...",rows:2})]}),e.jsxs("div",{className:"rounded-lg bg-muted p-3 space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Per person"}),e.jsxs("span",{children:["$",a.price]})]}),r==="for_two"&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Ã 2 people"}),e.jsx("span",{children:"You pay for both"})]}),e.jsxs("div",{className:"flex justify-between font-semibold text-base border-t border-border pt-1 mt-1",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{className:"text-primary",children:["$",o]})]})]}),e.jsx("div",{className:"rounded-lg border border-border bg-muted/50 p-3",children:e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("strong",{children:"ð³ Payment Note:"})," Payment is coordinated directly with the retreat organizer after booking. The retreat company will receive your contact email and reach out to finalize payment and details."]})})]}),e.jsxs(se,{children:[e.jsx(d,{variant:"outline",onClick:()=>v(!1),children:"Cancel"}),e.jsxs(d,{onClick:D,disabled:N||r==="for_two"&&!c,children:[N&&e.jsx(F,{className:"h-4 w-4 mr-2 animate-spin"}),r==="for_two"?"Book for Two":"Book Retreat"]})]})]})})}function hs(){const[p,v]=l.useState([]),[a,g]=l.useState([]),[r,y]=l.useState(!0),[i,S]=l.useState(null),[c,k]=l.useState(null),[R,M]=l.useState(!1),[N,b]=l.useState(null),{toast:T}
1=H(),m=J(i),w=V(i),o=G();l.useEffect(()=>{(async()=>{const{data:{user:n}}=await u.auth.getUser();S(n)})()},[]),l.useEffect(()=>{i&&!m.loading&&($(),m.subscribed&&m.tier==="wanderlust"?(D(),t()):y(!1))},[i,m.subscribed,m.tier,m.loading]);const $=async()=>{if(i)try{const{data:s,error:n}=await u.from("retreats").select("*").eq("claimed_by",i.id).order("start_date",{ascending:!0});!n&&s&&g(s)}catch(s){console.error("Error fetching my retreats:",s)}},D=async()=>{try{console.log("Fetching retreats...");const{data:s,error:n}=await u.from("retreats").select("*").eq("is_active",!0).order("start_date",{ascending:!0});if(n)throw console.error("Retreats fetch error:",n),n;console.log("Retreats fetched:",s),v(s||[])}catch(s){console.error("Error fetching retreats:",s),T({title:"Error",description:"Failed to load retreats",variant:"destructive"})}finally{y(!1)}},t=async()=>{try{const{data:s,error:n}=await u.from("sync_logs").select("*").in("sync_type",["bookretreat_retreats","retreatguru_retreats","eventbrite_retreats"]).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(n){console.error("Sync log fetch error:",n);return}k(s)}catch(s){console.error("Error fetching sync logs:",s)}},f=s=>{b(s)};if(m.loading||r)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-background to-primary/5 safe-area-top",children:e.jsxs("div",{className:"container mx-auto px-4 py-8 pt-4 space-y-8",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-10 w-64 bg-muted animate-pulse rounded"}),e.jsx("div",{className:"h-5 w-96 bg-muted animate-pulse rounded"}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx("div",{className:"h-6 w-32 bg-muted animate-pulse rounded-full"}),e.jsx("div",{className:"h-6 w-28 bg-muted animate-pulse rounded-full"})]})]}),e.jsx(de,{count:6,className:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:e.jsx(me,{})})]})});if(!i)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-background to-primary/5 flex items-center justify-center",children:e.jsxs(C,{className:"max-w-md mx-auto text-center",children:[e.jsxs(B,{children:[e.jsx(E,{children:"Sign In Required"}),e.jsx(L,{children:"Please sign in to view yoga retreats"})]}),e.jsx(U,{children:e.jsx(d,{onClick:()=>o("/auth"),children:"Sign In"})})]})});const x=w.hasAccess("retreat_access");return!x&&a.length===0?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-background to-primary/5 safe-area-top",children:e.jsxs("div",{className:"container mx-auto px-4 py-8 pt-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-4xl font-bold text-foreground mb-2",children:"Yoga Retreats"}),e.jsx("p",{className:"text-muted-foreground",children:"Submit your own retreat or upgrade to browse all listings"})]}),e.jsxs(d,{onClick:()=>o("/retreat-manage"),className:"gap-2",children:[e.jsx(Y,{className:"h-4 w-4"}),"Submit a Retreat"]})]}),e.jsx(X,{hasAccess:!1,requiredTier:"wanderlust",loading:w.loading,children:e.jsx("div",{})})]})}):!x&&a.length>0?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-background to-primary/5 safe-area-top",children:e.jsxs("div",{className:"container mx-auto px-4 py-8 pt-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-4xl font-bold text-foreground mb-2",children:"My Retreats"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage your retreat listings. Upgrade to Wanderlust to browse all retreats."}),e.jsxs(h,{variant:"secondary",className:"mt-2",children:[a.length," owned retreats"]})]}),e.jsxs("div",{className:"flex flex-col gap-2 items-end",children:[e.jsxs(d,{onClick:()=>o("/retreat-manage"),className:"gap-2",children:[e.jsx(Y,{className:"h-4 w-4"}),"Submit a Retreat"]}),e.jsx(d,{variant:"outline",size:"sm",onClick:()=>o("/payment"),children:"Upgrade to Wanderlust"})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:a.map(s=>{const n=new Date(s.start_date),j=new Date(s.end_date);return e.jsxs(C,{className:"overflow-hidden hover:shadow-lg transition-shadow border-primary/20",children:[s.image_url&&e.jsx("div",{className:"aspect-video bg-muted overflow-hidden",children:e.jsx("img",{src:s.image_url,alt:s.title,className:"w-full h-full object-cover"})}),e.jsxs(B,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{className:"line-clamp-2 flex-1",children:s.title}),e.jsx(h,{variant:"outline",className:"text-xs shrink-0",children:"Owner"})]}),e.jsx(L,{className:"line-clamp-2",children:s.description||"Your retreat listing."})]}),e.jsx(U,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(z,{className:"h-4 w-4"}),e.jsxs("span",{children:[_(n,"MMM d")," - ",_(j,"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsx("span",{children:s.location})]}),e.jsxs("p",{className:"text-2xl font-bold text-primary pt-1",children:["$",s.price]}),e.jsxs(d,{variant:"outline",className:"w-full gap-2",onClick:()=>o(`/retreat-manage?id=${s.id}`),children:[e.jsx(W,{className:"h-4 w-4"})," Edit Retreat"]})]})})]},s.id)})})]})}):e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-background via-background to-primary/5 safe-area-top",children:[e.jsx(ue,{title:"Yoga Retreats Worldwide | YogiCurious",description:"Discover curated yoga retreats around the world. Wanderlust members can book a getaway for two with their match.",path:"/retreats",jsonLd:{"@context":"https://schema.org","@type":"CollectionPage",name:"Yoga Retreats",description:"Curated yoga retreats on YogiCurious.",url:"https://yogicurious.com/retreats"}}),e.jsxs("div",{className:"container mx-auto px-4 py-8 pt-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-4xl font-bold text-foreground mb-2",children:"Yoga Retreats"}),e.jsx("p",{className:"text-muted-foreground",children:"Discover transformative yoga retreat experiences exclusively for Wanderlust members"}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-3",children:[e.jsxs(h,{variant:"secondary",children:[p.length," retreats available"]}),c&&e.jsxs("div",{className:"flex items-center gap-2",children:[c.status==="success"&&e.jsxs(h,{variant:"outline",className:"flex items-center gap-1 text-green-600",children:[e.jsx(he,{className:"h-3 w-3"}),"Auto-sync active"]}),c.status==="error"&&e.jsxs(h,{variant:"outline",className:"flex items-center gap-1 text-red-600",children:[e.jsx(pe,{className:"h-3 w-3"}),"Sync error"]}),c.status==="running"&&e.jsxs(h,{variant:"outline",className:"flex items-center gap-1 text-blue-600",children:[e.jsx(F,{className:"h-3 w-3 animate-spin"}),"Syncing now"]})]})]}),c&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2 flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4"}
1),"Last sync: ",_(new Date(c.created_at),"MMM d, yyyy h:mm a"),c.synced_count>0&&` ⢠${c.synced_count} retreats updated`]})]}),e.jsxs("div",{className:"flex flex-col gap-2 items-end",children:[e.jsxs(d,{onClick:()=>o("/retreat-manage"),className:"gap-2",children:[e.jsx(Y,{className:"h-4 w-4"}),"Submit a Retreat"]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Curated by admins ⢠Updated regularly"})]})]}),p.length===0?e.jsx(C,{children:e.jsx(xe,{})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:p.map(s=>{const n=new Date(s.start_date),j=new Date(s.end_date);return e.jsxs(C,{className:"overflow-hidden hover:shadow-lg transition-shadow",children:[s.image_url&&e.jsx("div",{className:"aspect-video bg-muted overflow-hidden",children:e.jsx("img",{src:s.image_url,alt:s.title,className:"w-full h-full object-cover"})}),e.jsxs(B,{children:[e.jsx(E,{className:"line-clamp-2",children:s.title}),e.jsx(L,{className:"line-clamp-3",children:s.description||"Join us for a transformative yoga retreat experience."})]}),e.jsx(U,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(z,{className:"h-4 w-4"}),e.jsxs("span",{children:[_(n,"MMM d")," - ",_(j,"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsx("span",{children:s.location})]}),e.jsx("div",{className:"pt-2",children:e.jsxs("p",{className:"text-2xl font-bold text-primary",children:["$",s.price]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(d,{onClick:()=>f(s),className:"flex-1 flex items-center gap-2",children:[e.jsx(fe,{className:"h-4 w-4"}),"Book Retreat"]}),!s.is_claimed&&i&&e.jsx(d,{variant:"outline",size:"icon",onClick:()=>o(`/retreat-manage?claim=${s.id}`),title:"Claim this retreat",children:e.jsx(je,{className:"h-4 w-4"})}),s.claimed_by===(i==null?void 0:i.id)&&e.jsx(d,{variant:"outline",size:"icon",onClick:()=>o(`/retreat-manage?id=${s.id}`),title:"Edit your retreat",children:e.jsx(W,{className:"h-4 w-4"})})]}),s.perks&&s.perks.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:s.perks.slice(0,3).map((I,P)=>e.jsx(h,{variant:"outline",className:"text-xs",children:I},P))}),s.discount_code&&e.jsxs(h,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(ye,{className:"h-3 w-3"}),"Code: ",s.discount_code," (",s.discount_percentage,"% off)"]})]})})]},s.id)})}),N&&i&&e.jsx(Ne,{open:!!N,onOpenChange:s=>!s&&b(null),retreat:N,userId:i.id})]})]})}export{hs 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.