1import{aS as m,l as p,o as w,I as y,s as c,h,d as N,c as F,F as I,g as S,t as _,f as b,i as k,e as B,m as d,_ as C}from"./DVPCUeIP.js";const T={__name:"OutletFavoriteButton",props:{outletId:{type:[String,Number],required:!0},outletName:{type:String,default:"outlet"},size:{type:String,default:"sm"},iconOnly:{type:Boolean,default:!1},suppressToasts:{type:Boolean,default:!1}},emits:["favorited","unfavorited"],setup(l,{emit:f}){const t=l,{user:i}=m(),a=p(),s=d(!1),e=d(!1),r=f,n=async()=>{try{const{data:o}=await $fetch("/api/outlet-favorites");o&&(e.value=o.some(u=>u.outlet?.id===Number(t.outletId)))}catch{e.value=!1}},v=async()=>{if(!i.value){a.add({title:"Authentication Required",description:"Please sign in to follow outlets",color:"orange"});return}s.value=!0;try{e.value?(await $fetch("/api/outlet-favorites",{method:"DELETE",body:{outletId:Number(t.outletId)}}),e.value=!1,r("unfavorited",t.outletId),t.suppressToasts||a.add({title:"Success",description:`Unfollowed ${t.outletName}`,color:"green"})):(await $fetch("/api/outlet-favorites",{method:"POST",body:{outletId:Number(t.outletId)}}),e.value=!0,r("favorited",t.outletId),t.suppressToasts||a.add({title:"Success",description:`Now following ${t.outletName}`,color:"green"}))}catch(o){o.statusCode===409?(a.add({title:"Already Following",description:`Already following ${t.outletName}`,color:"orange"}),e.value=!0):o.statusCode===400&&o.statusMessage?.includes("follow up to 10")?a.add({title:"Limit Reached",description:"You can only follow up to 10 outlets. Please unfollow one first.",color:"orange"}):o.statusCode===404&&e.value?(a.add({title:"Not Following",description:`Not following ${t.outletName}`,color:"orange"}),e.value=!1):a.add({title:"Error",description:"Something went wrong. Please try again.",color:"red"})}finally{s.value=!1}};return w(()=>{n()}),y(i,o=>{o?n():e.value=!1},{immediate:!1}),(o,u)=>{const g=C;return c(),h(g,{onClick:v,loading:s.value,disabled:!B(i)||s.value,variant:e.value?"solid":"outline",color:e.value?"red":"gray",icon:e.value?"i-heroicons-heart-solid":"i-heroicons-heart",size:l.size,class:k(["transition-all duration-200",l.iconOnly&&"aspect-square"]),title:e.value?"Unfollow outlet":"Follow outlet"},{default:N(()=>[l.iconOnly?b("",!0):(c(),F(I,{key:0},[S(_(e.value?"Following":"Follow"),1)],64))]),_:1},8,["loading","disabled","variant","color","icon","size","class","title"])}}};export{T as _};
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.