import{j as t}from"./query-vendor-CZu0EHPe.js";import{a as w}from"./index-CwGgW-mc.js";import{r as f}from"./react-vendor-0bvDbF03.js";import{u as b}from"./i18n-vendor-Cl4-lKeC.js";const h="https://pldrgdplxacehsmcyjnx.supabase.co/functions/v1/og-share";function k(n){try{const o=new URL(n).pathname.replace(/^\/(bn|es|zh|ja)\//,"/"),a=o.match(/^\/story\/([0-9a-f-]{36})$/i);if(a)return`${h}?type=story&id=${a[1]}`;const e=o.match(/^\/blog\/([^/]+)$/);if(e)return`${h}?type=blog&slug=${e[1]}`}catch{}return n}const j=({title:n,description:r,url:o=window.location.href,className:a=""})=>{const{t:e}=b("story-reader"),{toast:d}=w(),[p,c]=f.useState(!1),i=k(o),m=async()=>{if(navigator.share)try{await navigator.share({title:n,text:r,url:o})}catch{console.log("Share cancelled")}else l()},l=async()=>{try{await navigator.clipboard.writeText(o),c(!0),setTimeout(()=>c(!1),2e3)}catch{d({title:e("sharing.copyFailed"),description:e("sharing.copyFailedDescription"),variant:"destructive"})}},g=()=>{const s=`https://twitter.com/intent/tweet?text=${encodeURIComponent(`${n} - ${r}`)}&url=${encodeURIComponent(i)}`;window.open(s,"_blank","width=600,height=400")},x=()=>{const s=`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(i)}`;window.open(s,"_blank","width=600,height=400")},y=()=>{const s=`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(i)}`;window.open(s,"_blank","width=600,height=400")},u=()=>{const s=`https://api.whatsapp.com/send?text=${encodeURIComponent(`${n} - ${o}`)}`;window.open(s,"_blank","width=600,height=400")};return t.jsxs("div",{className:`flex flex-wrap gap-6 justify-center ${a}`,children:[t.jsxs("button",{onClick:m,className:"flex flex-col items-center gap-2 hover:opacity-80 transition-opacity",children:[t.jsx("img",{src:"https://cdn.storysparkle.org/ui_elements/Share%20Story%20Buttons/ShareButton.webp",alt:"Share",width:48,height:48,loading:"lazy",decoding:"async",fetchPriority:"low",className:"w-12 h-12 hover:scale-110 transition-transform"}),t.jsx("span",{className:"text-sm text-foreground",children:e("sharing.shareButton")})]}),t.jsxs("button",{onClick:l,className:"flex flex-col items-center gap-2 hover:opacity-80 transition-opacity",children:[t.jsx("img",{src:"https://cdn.storysparkle.org/ui_elements/Share%20Story%20Buttons/CopyLinkButton.webp",alt:"Copy Link",width:48,height:48,loading:"lazy",decoding:"async",fetchPriority:"low",className:"w-12 h-12 hover:scale-110 transition-transform"}),t.jsx("span",{className:"text-sm text-foreground",children:e(p?"sharing.copied":"sharing.copyLink")})]}),t.jsxs("button",{onClick:g,className:"flex flex-col items-center gap-2 hover:opacity-80 transition-opacity",children:[t.jsx("img",{src:"https://cdn.storysparkle.org/ui_elements/Share%20Story%20Buttons/XButton.webp",alt:"X",width:48,height:48,loading:"lazy",decoding:"async",fetchPriority:"low",className:"w-12 h-12 hover:scale-110 transition-transform"}),t.jsx("span",{className:"text-sm text-foreground",children:"X"})]}),t.jsxs("button",{onClick:x,className:"flex flex-col items-center gap-2 hover:opacity-80 transition-opacity",children:[t.jsx("img",{src:"https://cdn.storysparkle.org/ui_elements/Share%20Story%20Buttons/FacebookButton.webp",alt:"Facebook",width:48,height:48,loading:"lazy",decoding:"async",fetchPriority:"low",className:"w-12 h-12 hover:scale-110 transition-transform"}),t.jsx("span",{className:"text-sm text-foreground",children:"Facebook"})]}),t.jsxs("button",{onClick:y,className:"flex flex-col items-center gap-2 hover:opacity-80 transition-opacity",children:[t.jsx("img",{src:"https://cdn.storysparkle.org/ui_elements/Share%20Story%20Buttons/LinkedInButton.webp",alt:"LinkedIn",width:48,height:48,loading:"lazy",decoding:"async",fetchPriority:"low",className:"w-12 h-12 hover:scale-110 transition-transform"}),t.jsx("span",{className:"text-sm text-foreground",children:e("sharing.linkedin")})]}),t.jsxs("button",{onClick:u,className:"flex flex-col items-center gap-2 hover:opacity-80 transition-opacity",children:[t.jsx("img",{src:"https://cdn.storysparkle.org/ui_elements/Share%20Story%20Buttons/WhatsappButton.webp",alt:"WhatsApp",width:48,height:48,loading:"lazy",decoding:"async",fetchPriority:"low",className:"w-12 h-12 hover:scale-110 transition-transform"}),t.jsx("span",{className:"text-sm text-foreground",children:e("sharing.whatsapp")})]})]})},$=({heading:n,subheading:r,title:o,description:a,url:e})=>t.jsxs("div",{className:"p-6 bg-background rounded-xl shadow-md border border-border/40",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:n}),t.jsx("p",{className:"text-muted-foreground mb-4",children:r}),t.jsx(j,{title:o,description:a,url:e})]});export{$ as S};
//# sourceMappingURL=ShareCard-CASs-O6e.js.map