import{aD as a,co as u}from"./app-B-4i4xU3.js";var p={baidu:"http://cang.baidu.com/do/add?iu=@u&it=@t",bluesky:"https://bsky.app/intent/compose?text=@t%0A@u",buffer:"https://bufferapp.com/add?text=@t&url=@u",email:"mailto:?subject=@t&body=@u%0D%0A@d",evernote:"https://www.evernote.com/clip.action?url=@u&title=@t",facebook:"https://www.facebook.com/sharer/sharer.php?u=@u&title=@t&description=@d&quote=@q&hashtag=@h",flipboard:"https://share.flipboard.com/bookmarklet/popout?v=2&url=@u&title=@t",hackernews:"https://news.ycombinator.com/submitlink?u=@u&t=@t",instapaper:"http://www.instapaper.com/edit?url=@u&title=@t&description=@d",line:"http://line.me/R/msg/text/?@t%0D%0A@u%0D%0A@d",linkedin:"https://www.linkedin.com/sharing/share-offsite/?url=@u",messenger:"fb-messenger://share/?link=@u",odnoklassniki:"https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=@u&st.comments=@t",pinterest:"https://pinterest.com/pin/create/button/?url=@u&media=@m&description=@t",pocket:"https://getpocket.com/save?url=@u&title=@t",quora:"https://www.quora.com/share?url=@u&title=@t",reddit:"https://www.reddit.com/submit?url=@u&title=@t",skype:"https://web.skype.com/share?url=@t%0D%0A@u%0D%0A@d",sms:"sms:?body=@t%0D%0A@u%0D%0A@d",stumbleupon:"https://www.stumbleupon.com/submit?url=@u&title=@t",telegram:"https://t.me/share/url?url=@u&text=@t%0D%0A@d",tumblr:"https://www.tumblr.com/share/link?url=@u&name=@t&description=@d",twitter:"https://twitter.com/intent/tweet?text=@t&url=@u&hashtags=@h&via=@tu",x:"https://x.com/intent/post?text=@t&url=@u&hashtags=@h&via=@tu",viber:"viber://forward?text=@t%0D%0A@u%0D%0A@d",vk:"https://vk.com/share.php?url=@u&title=@t&image=@m&noparse=true",weibo:"http://service.weibo.com/share/share.php?url=@u&title=@t&pic=@m",whatsapp:"https://api.whatsapp.com/send?text=@t%0D%0A@u%0D%0A@d",wordpress:"https://wordpress.com/press-this.php?u=@u&t=@t&s=@d&i=@m",xing:"https://www.xing.com/social/share/spi?op=share&url=@u&title=@t",yammer:"https://www.yammer.com/messages/new?login=true&status=@t%0D%0A@u%0D%0A@d",threads:"https://www.threads.net/intent/post?url=@u&text=@t"},l=(e,t)=>{let r=window.navigator.userAgent.toLowerCase();return e==="sms"&&(r.includes("iphone")||r.includes("ipad"))?t[e].replace(":?",":&"):t[e]},h=(e,t)=>t==="facebook"&&e&&e.length>0?`%23${e.split(",")[0]}`:e,w=()=>({network:"",url:"",title:"",description:"",quote:"",hashtags:"",twitterUser:"",media:""}),c=e=>{let t=w();return Object.fromEntries(Object.keys(t).map(r=>{let s=u(e[r])||t[r];return s=r==="hashtags"?h(s,r):encodeURIComponent(s),[r,s]}))},d=(e,t)=>e.replace(/@tu/g,t.twitterUser).replace(/@u/g,t.url).replace(/@t/g,t.title).replace(/@d/g,t.description).replace(/@q/g,t.quote).replace(/@h/g,t.hashtags).replace(/@m/g,t.media),n=()=>typeof window<"u",m=(e,t)=>{if(!n())return null;let r=window.innerWidth||document.documentElement.clientWidth||window.screenX,s=window.innerHeight||document.documentElement.clientHeight||window.screenY,i=r/window.screen.availWidth,o=(r-e)/2/i+(window.screenLeft===void 0?window.screenX:window.screenLeft);return{top:(s-t)/2/i+(window.screenTop===void 0?window.screenY:window.screenTop),left:o,width:e,height:t}},g=e=>Object.entries(e).map(([t,r])=>r?`${t}=${r}`:"").filter(t=>t).join(","),b=e=>{if(!n())return null;if(e.substring(0,4)!=="http")return window.open(e,"_blank");let t=m(500,500);return t?window.open(e,"sharer",g(t)):null},f=()=>{let e=Object.assign({},p,a("share-networks",{})),t=r=>{let s=c(r);if(!s.network||!e[s.network])throw Error(`Network ${s.network} does not exist`);let i=l(s.network,e);return s.network==="twitter"&&(s.hashtags.length||(i=i.replace("&hashtags=@h","")),s.twitterUser.length||(i=i.replace("&via=@tu",""))),d(i,s)};return{getSharingLink:t,shareLink:r=>b(t(r))}};export{f as m};
