Impurity in a bosonic Josephson junction: Swallowtail loops, chaos, self-trapping, and Dicke model