"use client"; import { FC } from "react"; import { Box, Button, Tooltip } from "../../../components"; import { shareLink } from "./ShareTooltip.styles"; // @ts-ignore - mof overrides import mofConfig from "/mofConfig"; const shareIcons = mofConfig.shareIcons || {}; const ShareTooltip: FC = ({ data }) => { const handleGetLink = (link: string, id: string) => { let newLink = link; if ( id === "email" && !link.includes("subject=") && data?.emailSharingSubject ) { newLink = link.replace("?", `?subject=${data?.emailSharingSubject}`); } if (id === "copy" && navigator) { navigator.clipboard.writeText(link); } else { if (typeof window !== undefined) { window.open(newLink, "_blank"); } } }; const availLinks = Object.entries(data).filter(([key]) => { return key?.includes("SharingLink"); }); if (shareIcons?.copy) { const hasCopySharingLink = availLinks.some( ([key]) => key === "copySharingLink", ); if (!hasCopySharingLink) { availLinks.push(["copySharingLink", window.location.href]); } } const renderShareLinks = availLinks.map(([key, value]) => { const shareKey = key.replace("SharingLink", ""); const icon = shareIcons[shareKey]; return ( handleGetLink(value as string, shareKey)} {...shareLink(shareKey)} > {icon} ); }); return (