Fundamental group of a compact branched cover My problem originates from the following classical result, proved, as far as I know, by Grauert and Remmert:

Theorem. Let $Y$ be a compact complex manifold, $B \subset Y$ be a connected submanifold of codimension one and $G$ a finite group. Then isomorphism classes of connected analytic Galois covers $$f \colon X  \longrightarrow Y,$$ with Galois group $G$ and branched at most over $B$, correspond to group epimorphisms $$\varphi \colon \pi_1(Y - B) \longrightarrow  G,$$
up to automorphisms of $G$.

I would be glad to have a reference answering the following very basic topological question:

Question. How can we compute the fundamental group $\pi_1(X)$ in terms of the algebraic data above? For instance, in terms of the epimorphism $\varphi$ and of the homomorphism $\iota_* \colon \pi_1(Y-B) \to \pi_1(Y)$?

Elementary remark. If $D=f^{-1}(B)$, then $\pi_1(X-D)$ is isomorphic to $\ker \varphi$.
 A: Consider a small complex 1-dimensional disk $D\subset Y$ transversal to $B$ and let $c$ denote the image in $\pi=\pi_1(Y-B)$ of the oriented loop $\partial D$. Let $n$ denote the order of the image of $c$ under $\varphi$. Now, form a complex orbifold ${\mathcal O}$ (a stack in your language) with the underlying space $Y$ and orbi-data ${\mathbb Z}/n$ along $B$.
(I am sure, you know what I mean.) Then
$$
\pi_1({\mathcal O})\cong \pi/ \langle c^n\rangle^{\pi}, 
$$
where $\langle c^n \rangle^{\pi}$ denotes the normal closure of the subgroup $\langle c^n \rangle$ in $\pi$.
The homomorphism $\varphi$  descends to a homomorphsm
$$
\psi: \pi_1({\mathcal O})\to G. 
$$
Then $\pi_1(X)$ is isomorphic to the kernel of $\psi$.
In fact, this works in much greater generality, as the divisor $B$ need not be a smooth submanifold and need not be connected, but instead of a single disk $D$ you have to take a collection of disks transversal to the components of the smooth locus of $B$.
A: Ciao Francesco.
The more general version of this Theorem that I know is in
Fox, Ralph H.
Covering spaces with singularities  1957 A symposium in honor of S. Lefschetz pp. 243–257 Princeton University Press, Princeton, N.J.
see the Theorem at page 254, for branched covering of topological spaces.
The proof follows the same lines of the answer by Moishe Kohan.
