I am struggling with the maximization of the following profit function in a New-Keynesian model. Here there is the FOC.
$$\frac{\delta}{\delta Y_t(i)} P_tY_t- \int_0^1 P_t(i)Y_t(i)di = \frac{\delta}{\delta Y_t(i)} P_t\left[\int_0^1 {Y_t(i)}^{\frac{\epsilon-1}{\epsilon}} di\right]^{\frac{\epsilon}{\epsilon-1}} - \int_0^1 P_t(i)Y_t(i)di = 0 $$
$Y_t(i)$ is the demand for the intermediate good and $Y_t$ is the demand for the final good. The solution should be:
$$ \frac{\epsilon}{\epsilon -1} P_t \frac{Y_t}{Y_t^\frac{\epsilon -1}{\epsilon}} \frac{\epsilon -1}{\epsilon} Y_t(i)^{-\frac{1}{\epsilon}} = P_t(i) $$
I tried to apply the Leibniz integral rule. However, I cannot understand how to behave when taking a derivative of an integral function.
May anyone explain to me the steps (and the mathematical theory) in order to get the correct solution?
Thank you in advance for your patience and your support.