import{c9 as r}from"./index-Daf0Yezg.js";function o(e){try{const i=(typeof e=="string"?e.split("?")[0]:"").split("/").pop()??"";return((i.includes("-")?i.slice(i.lastIndexOf("-")+1):i)||i).toLowerCase()}catch{return e}}async function b(e){return r(`/venues/${e}`)}async function h(e,t){return r(`/venues/${e}/draft`,{method:"PATCH",body:JSON.stringify(t)})}async function v(e){return r(`/listings/${e}/managers`)}async function S(e,t){return r(`/listings/${e}/managers/invite`,{method:"POST",body:JSON.stringify({email:t})})}async function m(e,t){return r(`/listings/${e}/managers/${encodeURIComponent(t)}`,{method:"DELETE"})}async function T(e){return r(`/listings/managers/accept/${e}`)}async function L(e){return r(`/listings/managers/accept/${e}`,{method:"POST"})}async function w(e,t){return r(`/venues/${e}/media/upload-url`,{method:"POST",body:JSON.stringify(t)})}async function M(e){const t=new URLSearchParams;e!=null&&e.listingKind&&t.set("listingKind",e.listingKind),e!=null&&e.serviceType&&t.set("serviceType",e.serviceType),e!=null&&e.city&&t.set("city",e.city),e!=null&&e.state&&t.set("state",e.state),e!=null&&e.date&&t.set("date",e.date),e!=null&&e.limit&&t.set("limit",String(e.limit)),e!=null&&e.cursor&&t.set("cursor",e.cursor),e!=null&&e.bounds&&(t.set("boundsNeLat",String(e.bounds.ne.lat)),t.set("boundsNeLng",String(e.bounds.ne.lng)),t.set("boundsSwLat",String(e.bounds.sw.lat)),t.set("boundsSwLng",String(e.bounds.sw.lng)));const i=t.toString(),n=i?`/public/venues?${i}`:"/public/venues";return r(n)}async function O(e){var t,i;try{return await r(`/public/venues/${e}`)}catch(n){const c=n instanceof Error?n.message:typeof n=="string"?n:"";if(c&&(c.includes("Cannot GET /public/venues")||c.includes("404"))){try{const l=new URLSearchParams({listingId:e,limit:"1"}),f=(t=(await r(`/public/venues?${l.toString()}`)).items)==null?void 0:t.find(a=>a.listingId===e);if(f)return f}catch{}let s,g=0;const y=10;for(;g<y;){const l=new URLSearchParams;l.set("limit","100"),s&&l.set("cursor",s);const u=await r(`/public/venues?${l.toString()}`),f=(i=u.items)==null?void 0:i.find(a=>a.listingId===e);if(f)return f;if(!u.nextCursor)break;s=u.nextCursor,g++}throw new Error(`Listing ${e} not found`)}throw n}}async function $(e){const t={};if(t.query=e.query||"",e.listingKind&&(t.listingKind=e.listingKind),e.serviceType&&(t.serviceType=e.serviceType),e.sort&&(t.sort=e.sort),e.page&&(t.page=e.page),e.limit&&(t.limit=e.limit),e.filters){const i={};if(e.filters.location){const n={};e.filters.location.city&&(n.city=e.filters.location.city),e.filters.location.radiusMiles!==void 0&&(n.radiusMiles=e.filters.location.radiusMiles),e.filters.location.lat!==void 0&&e.filters.location.lng!==void 0&&(n.coordinates={lat:e.filters.location.lat,lng:e.filters.location.lng}),Object.keys(n).length>0&&(i.location=n)}e.filters.priceMin!==void 0&&(i.priceMin=e.filters.priceMin),e.filters.priceMax!==void 0&&(i.priceMax=e.filters.priceMax),e.filters.venueType&&(i.venueType=e.filters.venueType),e.filters.venueSubTypes&&(i.venueSubTypes=e.filters.venueSubTypes),e.filters.amenities&&(i.amenities=e.filters.amenities),e.filters.packages&&(i.packages=e.filters.packages),e.filters.ageRestriction&&(i.ageRestriction=e.filters.ageRestriction),e.filters.capacity&&(i.capacity=e.filters.capacity),Object.keys(i).length>0&&(t.filters=i)}return r("/search/venues",{method:"POST",body:JSON.stringify(t)})}async function P(e,t,i){if(!e||e.trim().length===0)return{suggestions:[]};const c={query:e.trim()};t&&typeof t.lat=="number"&&typeof t.lng=="number"&&(c.location={lat:t.lat,lng:t.lng});try{return await r("/search/autocomplete",{method:"POST",body:JSON.stringify(c),signal:i==null?void 0:i.signal})}catch(s){throw s instanceof Error&&s.name!=="AbortError"&&console.error("[getAutocompleteSuggestions] API call failed:",s),s}}export{M as a,b,O as c,o as d,v as e,w as f,P as g,T as h,S as i,L as j,m as r,$ as s,h as u};