They calculate the value of assets, including all capital gains and losses. The dividends and interest from stocks and bonds and all expenses including management fees, marketing fees, etc., sales charges, are all added together. They cannot lie or fib as they are audited and highly regulated.
The gains aren’t realized or unrealized at that point. Its just a measurement of the value difference between starting and ending time.
Don’t judge by the fund’s NAV, it’s misleading.