import{bR as a}from"./index-DXdAv5n3.js";import{f as r}from"./vendor-amplify-BttVyssp.js";async function o(){var n,s;try{const t=(s=(n=(await r()).tokens)==null?void 0:n.idToken)==null?void 0:s.toString();return t?{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}:{"Content-Type":"application/json"}}catch(e){return console.warn("No auth session found",e),{"Content-Type":"application/json"}}}async function d(n){const s=await o(),e=await fetch(a("/users/saved-venues"),{method:"POST",headers:s,credentials:"include",body:JSON.stringify({listingId:n})});if(!e.ok){const t=await e.json().catch(()=>({message:"Failed to save venue"}));throw new Error(t.message||"Failed to save venue")}}async function v(n){const s=await o(),e=await fetch(a(`/users/saved-venues/${n}`),{method:"DELETE",headers:s,credentials:"include"});if(!e.ok){const t=await e.json().catch(()=>({message:"Failed to unsave venue"}));throw new Error(t.message||"Failed to unsave venue")}}async function h(n){try{return(await i()).some(e=>e.listingId===n)}catch(s){return console.warn("Error checking if venue is saved:",s),!1}}async function i(){const n=await o(),s=await fetch(a("/users/saved-venues"),{method:"GET",headers:n,credentials:"include"});if(!s.ok)throw new Error("Failed to fetch saved venues");const e=await s.json();return Array.isArray(e)?e:e.items||[]}export{i as g,h as i,d as s,v as u};