Please make InstantSearch.js work on my site (vanilla)

Followed all the tutorials for InstantSearch.js vanilla JavaScript and while the search bar appears, it doesn’t work on this platform.

Could you please point out what I am doing wrong?

I get this browser console error:

Uncaught ReferenceError: searchBox is not defined at (index):2107:144

The platform won’t let me put custom HTML in the sitewide header element – only the HEAD tag, the top of BODY tag, and elements below the sitewide header.

It uses its own code for a search bar, which is wrapped inside a DIV with classname “search-wrapper”. I have to use another script to modify that DIV at runtime, so it is instead Algolia searchbar.

Attached is a screenshot of my code implementation. (I couldn’t direct copy-paste due to 403 error.) You can use Blackbox on VS Code to OCR it into text.

Could you please tell me what I am doing wrong in my code?

P.S. For privacy I have left out my API, App ID and index name, which elsewhere I’ve successfully authenticated and set requests to.

Please view this test site to see an example of how I am deploying this.

This gives the full context of other scripts that may potentially delay or interfere with this whole process.

What do you see in here that I am doing wrong?