  Superluminous supernovae are among the most energetic stellar explosions in
the Universe, but their energy sources remain an open question. Here we present
long-term observations of one of the closest examples of the hydrogen-poor
subclass (SLSNe-I), SN~2017egm, revealing the most complicated known luminosity
evolution of SLSNe-I. Three distinct post-peak bumps were recorded in its light
curve collected at about $100$--350\,days after maximum brightness, challenging
current popular power models such as magnetar, fallback accretion, and
interaction between ejecta and a circumstellar shell. However, the complex
light curve can be well modelled by successive interactions with multiple
circumstellar shells with a total mass of about $6.8$--7.7\,M$_\odot$. In this
scenario, large energy deposition from interaction-induced reverse shocks
results in ionization of neutral oxygen in the supernova ejecta and hence a
much lower nebular-phase line ratio of [O\,\textsc{i}]
$\lambda6300$/([Ca\,\textsc{ii}] + [O\,\textsc{ii}]) $\lambda7300$ ($\sim 0.2$)
compared with that derived for other superluminous and normal stripped-envelope
SNe. The pre-existing multiple shells indicate that the progenitor of
SN~2017egm experienced pulsational mass ejections triggered by pair instability
within 2 years before explosion, in robust agreement with theoretical
predictions for a pre-pulsation helium-core mass of 48--51\,M$_{\odot}$.
Finally, this work shows that the final explosion product may be a black hole
with about 40\,M$_{\odot}$, and has significant implication for the formation
of such heavy black holes that have been recently observed by LIGO-Virgo
gravitational wave detectors.
