document.addEventListener('DOMContentLoaded', ()=>{
    const menuButton = document.querySelector('.hamburger_menu__js');
    const mobileMenu = document.querySelector('.mobile_menu_wrapper__js');
    console.log(window.location.host);
    menuButton.addEventListener('click', (e)=>{
        console.log('click');
        e.currentTarget.classList.toggle('is-active');
        mobileMenu.classList.toggle('is-active');
    });

    const sdkForm = document.querySelector('.sdk_form__js');
    if(sdkForm){
        fetch(sdkForm.dataset.url)
        .then((response)=>{
            return response.text();
        })
        .then((data) =>{
            // console.log(data);
            let parser = new DOMParser();
            let form = parser.parseFromString(data, "text/html");
            // sdkForm.insertAdjacentHTML('beforeend', data);
            // sdkForm.innerHTML = data;
            let sdkFormScript = form.querySelector('script').textContent;
            // console.log(sdkFormScript);
            form.querySelector('script').remove();
            sdkForm.insertAdjacentHTML('beforeend',form.body.innerHTML);
            let newSdkFormScript = document.createElement('script');
            newSdkFormScript.type = 'text/javascript';
            newSdkFormScript.textContent = sdkFormScript;
            sdkForm.appendChild(newSdkFormScript);
            // console.log(typeof form);
            // for (const node in form.body){
            //     console.log(node);
            //     // sdkForm.appendChild()
            // }
        })
        .catch((error)=>{
            console.log(error);
        })
    }
});