import{z as u,j as c,F as m,L as v,r as f}from"./vendor-CT-JknSv.chunk.js";import{a5 as o,i as S,a8 as y,aF as k,aG as L,aH as w,aI as W}from"./index-DDZqnj79.js";function B({to:n="",image:t,size:e,name:a,tabIndex:s}){return n===""?c("div",{css:h.link,children:m(y,{children:[c(o,{name:a,image:t,widths:o.AVATAR_WIDTHS,widthDefinition:`${e}px`,style:{gridArea:"avatar"},css:h.image}),c("div",{css:o.insetBorderOverlayCSS})]})}):c(v,{css:h.link,to:n,tabIndex:s,children:m(y,{children:[c(o,{name:a,image:t,widthDefinition:`${e}px`,widths:o.AVATAR_WIDTHS,css:h.image}),c("div",{css:o.insetBorderOverlayCSS})]})})}const h={link:u({display:"flex",alignItems:"center",gridArea:"avatar",height:"100%",width:"100%",[o.borderRadius]:"60px",position:"relative"}),image:u({[o.fallbackSelector]:{height:"auto",width:"100%",backgroundColor:S.systemBackground}})};function x({addSuccess:n,removeSuccess:t,addError:e,removeError:a}){const{notify:s,dismiss:l}=k();f.useEffect(()=>{n&&(l(),s("Added to Watch Later"))},[n,s,l]),f.useEffect(()=>{t&&(l(),s("Removed from Watch Later"))},[t,s,l]),f.useEffect(()=>{var i,r;if(e){const d=((r=(i=e==null?void 0:e.response)==null?void 0:i.data)==null?void 0:r.message)||"Network error";s(`Adding failed: ${d}`,{type:"error"})}},[e,s]),f.useEffect(()=>{var i,r;if(a){const d=((r=(i=a==null?void 0:a.response)==null?void 0:i.data)==null?void 0:r.message)||"Network error";s(`Removing failed: ${d}`,{type:"error"})}},[a,s])}function D({bookmarked:n,id:t,tooltipEnabled:e=!0,...a}){const{add:s,isLoading:l,error:i,isSuccess:r}=L({id:t,playlistSlug:"watch-later"}),{remove:d,isLoading:p,error:g,isSuccess:A}=w({id:t,playlistSlug:"watch-later"});return x({addSuccess:r,removeSuccess:A,addError:i,removeError:g}),c(W,{isLoading:l||p,addToPlaylist:s,removeFromPlaylist:d,error:i||g,titleWhenBookmarked:"Remove from Watch Later",initialTitle:"Add to Watch Later",bookmarked:n,tooltipEnabled:e,...a})}export{B as C,D as W};