import React, { memo, type TeactNode, useMemo } from '../../../lib/teact/teact';
import { getActions } from '../../../global';
import type { ApiPaidMedia } from '../../../api/types';
import { STARS_ICON_PLACEHOLDER } from '../../../config';
import buildClassName from '../../../util/buildClassName';
import { formatStarsAsIcon } from '../../../util/localization/format';
import { replaceWithTeact } from '../../../util/replaceWithTeact';
import stopEvent from '../../../util/stopEvent';
import useLang from '../../../hooks/useLang';
import useLastCallback from '../../../hooks/useLastCallback';
import useOldLang from '../../../hooks/useOldLang';
import StarIcon from '../../common/icons/StarIcon';
import Button from '../../ui/Button';
import styles from './PaidMediaOverlay.module.scss';
type OwnProps = {
paidMedia: ApiPaidMedia;
chatId: string;
messageId: number;
isOutgoing?: boolean;
children?: TeactNode;
};
const PaidMediaOverlay = ({
paidMedia,
chatId,
messageId,
isOutgoing,
children,
}: OwnProps) => {
const { openInvoice } = getActions();
const oldLang = useOldLang();
const lang = useLang();
const isClickable = !paidMedia.isBought;
const buttonText = useMemo(() => {
const value = oldLang('UnlockPaidContent', paidMedia.starsAmount);
return replaceWithTeact(
value, STARS_ICON_PLACEHOLDER,