$(document).ready(function() {
	// inject btn after #row-loginmenu
  if (typeof btns_after_row_loginmenu !== 'undefined') {
  	let inject_html = '<div id="row-injected-after-loginmenu" class="d-flex flex-column gap-3">';    
    for (let i = 0; i < btns_after_row_loginmenu.length; i++) {
      const btn = btns_after_row_loginmenu[i];
      inject_html += '<a href="'+btn[2]+'" class="btn btn-lg flex-fill '+btn[3]+'" id="'+btn[0]+'">'+btn[1]+'</a>';
    }
  	inject_html += '</div>';
  	$('#row-loginmenu').after(inject_html);
  }

  // inject btn after #member-status-panel
  if (typeof btns_after_member_status_panel !== 'undefined') {
    let inject_html = '<div id="row-injected-after-member-status-panel" class="d-flex flex-column gap-3">';
    for (let i = 0; i < btns_after_member_status_panel.length; i++) {
      const btn = btns_after_member_status_panel[i];
      inject_html += '<a href="'+btn[2]+'" class="btn btn-lg flex-fill '+btn[3]+'" id="'+btn[0]+'">'+btn[1]+'</a>';
    }
    inject_html += '</div>';
    $('#member-status-panel').after(inject_html);
  }


  // inject download apk
  if (typeof download_apk_link !== 'undefined') {
    if (navigator.userAgent.match(/Android/i)) {
      let line1 = 'download APK';
      let line2 = 'server mantap';      
      if (typeof download_apk_line1 !== 'undefined') line1 = download_apk_line1;
      if (typeof download_apk_line2 !== 'undefined') line2 = download_apk_line2;
      let html = '<div id="container-apk">';
      html += '<div id="container-apk-button">';
      html += '<a id="apk-button" href="'+download_apk_link+'">';
      // android logo
      html += '<img src="https://ompong.tomswickpbn.com/ompong188/nxt/img/android.png" height="20" /> ';
      html += 'klik di sini';
      html += '</a>';
      html += '</div>';
      html += '<div id="container-apk-a">'+line1+'</div>';
      html += '<div id="container-apk-b">'+line2+'</div>';
      html += '</div>';
      $('#navbar-top-wrapper').prepend(html);

      // margin top of content need to be 123
      $('#content').css('margin-top', '123px');
    }
  }
});


//BUAT TAMPILAN NAVBAR

document.addEventListener("DOMContentLoaded", function () {
  const navbarMjMegaScatter = document.getElementById("category-navbar");

  if (navbarMjMegaScatter) {
    const containerMjMegaScatter = document.createElement("div");
    containerMjMegaScatter.style.display = "flex";
    containerMjMegaScatter.style.flexDirection = "column";
    containerMjMegaScatter.style.alignItems = "center";
    containerMjMegaScatter.style.marginLeft = "0px";

    const linkMjMegaScatter = document.createElement("a");
    linkMjMegaScatter.href = "/game?provider=1003&category=101";

    const iconMjMegaScatter = document.createElement("img");
    iconMjMegaScatter.src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhORlyxsZ-JrXv3-WGm_wrTp1Hmb_mzsKBmdmEpOSS1PmQ5GeAj5bfVz7Xoix76xH-CWXH-ciRkd3TG_fnOjVLHh-A_j4UiTw-Twmv_p35DEoNQFO3Z9N_wXwU-RCds6yjs5CGxTMLpKAopxeaYmmMIZsicTxvFBUhT8l3dsS2W6gNqG-yEeLt4KZM1N1u0/s280/navbar-mega-scatter.gif";
    iconMjMegaScatter.alt = "MJ Mega Scatter";
    iconMjMegaScatter.style.width = "35px";
    iconMjMegaScatter.style.height = "35px";

    linkMjMegaScatter.appendChild(iconMjMegaScatter);
    containerMjMegaScatter.appendChild(linkMjMegaScatter);

    const labelMjMegaScatter = document.createElement("span");
    labelMjMegaScatter.textContent = "MJ Mega Scatter";
    labelMjMegaScatter.style.marginTop = "0px";
    labelMjMegaScatter.style.fontSize = "11px";
    labelMjMegaScatter.style.textAlign = "center";

    containerMjMegaScatter.appendChild(labelMjMegaScatter);

    if (navbarMjMegaScatter.children.length >= 3) {
      navbarMjMegaScatter.insertBefore(containerMjMegaScatter, navbarMjMegaScatter.children[3]);
    } else {
      navbarMjMegaScatter.appendChild(containerMjMegaScatter);
    }
  } else {
    console.error("Elemen dengan id 'category-navbar' tidak ditemukan.");
  }
});

document.addEventListener("DOMContentLoaded", function () {
    // Pilih elemen dengan id 'category-navbar'
    const navbar = document.getElementById("category-navbar");

    if (navbar) {
        // Buat elemen container untuk ikon dan label
        const container = document.createElement("div");
        container.style.display = "flex";
        container.style.flexDirection = "column";
        container.style.alignItems = "center";
        container.style.marginLeft = "0px"; // Atur jarak dari elemen lain

        // Buat elemen anchor untuk link
        const link = document.createElement("a");
        link.href = "/game?provider=1003&category=101"; // Ganti dengan URL tujuan
        //link.target = "_blank"; // Membuka link di tab baru (opsional)

        // Buat elemen gambar baru
        const icon = document.createElement("img");
        icon.src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFNC39huPnzSeOdmoehvI-ri3_b4oQTwgx9Q9Sw-lMLarsIyMLz6jMCuAf0UCK3DcJo2Z4F4qKttFXJ7_XBfXfHpUfXYB0fA4IgE2XUBsw7GCyqFHEdKMOJ_e_TFjw4DZarw9R6PjS2bqPnKb8XTPEQhKzry582VS0AZAbgJzcwAUO02o8g47udEBYHJcU/s260/NAVBAR_SCATTERJACKPOT.gif"; // Ganti dengan URL gambar ikon Anda
        icon.alt = "MJ Scatter Jackpot";
        icon.style.width = "35px";
        icon.style.height = "35px";

        // Tambahkan ikon ke dalam elemen anchor
        link.appendChild(icon);

        // Tambahkan elemen anchor (yang berisi ikon) ke dalam container
        container.appendChild(link);

        // Buat elemen label untuk nama ikon
        const label = document.createElement("span");
        label.textContent = "MJ Scatter Jackpot"; // Ganti dengan nama label yang sesuai
        label.style.marginTop = "0px"; // Tambahkan jarak antara ikon dan label
        label.style.fontSize = "11px";
        label.style.textAlign = "center";

        // Tambahkan label ke dalam container
        container.appendChild(label);

        // Sisipkan elemen container di urutan keempat dalam elemen navbar
        if (navbar.children.length >= 4) {
            navbar.insertBefore(container, navbar.children[4]);
        } else {
            navbar.appendChild(container);
        }
    } else {
        console.error("Elemen dengan id 'category-navbar' tidak ditemukan.");
    }
});


/*
document.addEventListener("DOMContentLoaded", function () {
    // Pilih elemen dengan id 'category-navbar'
    const navbar = document.getElementById("category-navbar");

    if (navbar) {
        // Buat elemen container untuk ikon dan label
        const container = document.createElement("div");
        container.style.display = "flex";
        container.style.flexDirection = "column";
        container.style.alignItems = "center";
        container.style.marginLeft = "0px"; // Atur jarak dari elemen lain

        // Buat elemen anchor untuk link
        const link = document.createElement("a");
        link.href = "/game?provider=1003&category=101"; // Ganti dengan URL tujuan
        //link.target = "_blank"; // Membuka link di tab baru (opsional)

        // Buat elemen gambar baru
        const icon = document.createElement("img");
        icon.src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPOyrgr-vEr-q7wv2EbdY7-xBB3txzDAl1BflSKw6N3PJDBHFGueDA7YtSrs3Synf1Z3ZQhwDmyp9ZE5rOX8HiSfrfmtDm9N_bX5jsjp4j0hphooh2jHNQR5YpfhSpiW1tSjj1nihRxUDICUtFifhhGk_pUo1wslei8Pfb1dOlco-bp1TfWzKC3Q876r2c/s300/NAVBAR_SCATTERROYALGIFT.gif"; // Ganti dengan URL gambar ikon Anda
        icon.alt = "MJ Gift Scatter";
        icon.style.width = "35px";
        icon.style.height = "35px";

        // Tambahkan ikon ke dalam elemen anchor
        link.appendChild(icon);

        // Tambahkan elemen anchor (yang berisi ikon) ke dalam container
        container.appendChild(link);

        // Buat elemen label untuk nama ikon
        const label = document.createElement("span");
        label.textContent = "MJ Gift Scatter"; // Ganti dengan nama label yang sesuai
        label.style.marginTop = "0px"; // Tambahkan jarak antara ikon dan label
        label.style.fontSize = "11px";
        label.style.textAlign = "center";

        // Tambahkan label ke dalam container
        container.appendChild(label);

        // Sisipkan elemen container di urutan keempat dalam elemen navbar
        if (navbar.children.length >= 4) {
            navbar.insertBefore(container, navbar.children[4]);
        } else {
            navbar.appendChild(container);
        }
    } else {
        console.error("Elemen dengan id 'category-navbar' tidak ditemukan.");
    }
});

*/


/*

document.addEventListener("DOMContentLoaded", function () {
    // Pilih elemen dengan id 'category-navbar'
    const navbar = document.getElementById("category-navbar");

    if (navbar) {
        // Buat elemen container untuk ikon dan label
        const container = document.createElement("div");
        container.style.display = "flex";
        container.style.flexDirection = "column";
        container.style.alignItems = "center";
        container.style.marginLeft = "0px"; // Atur jarak dari elemen lain

        // Buat elemen anchor untuk link
        const link = document.createElement("a");
        link.href = "/game?provider=1003&category=101"; // Ganti dengan URL tujuan
        //link.target = "_blank"; // Membuka link di tab baru (opsional)

        // Buat elemen gambar baru
        const icon = document.createElement("img");
        icon.src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuu3E1zmar_FS2qIzBLloABNFgdslspHSQL_bt3i-czzH5a6jG3t7mg1sN04x_nOOBZMjI4uez2cRJNjQZi1MkeVxafjDnmQFWAnJipWkyEuMFL0PhnSsomVSuz5no4JOoNeWO5ufmCHKxbuLNwXjwf3Tyy-PUnCiHfaI_ivOAFdClE8Y_EgP6G2eRRmSK/s84/NAVBAR_KOTAKKEJUT.gif"; // Ganti dengan URL gambar ikon Anda
        icon.alt = "MJ Harta Karun";
        icon.style.width = "35px";
        icon.style.height = "35px";

        // Tambahkan ikon ke dalam elemen anchor
        link.appendChild(icon);

        // Tambahkan elemen anchor (yang berisi ikon) ke dalam container
        container.appendChild(link);

        // Buat elemen label untuk nama ikon
        const label = document.createElement("span");
        label.textContent = "MJ HARTA KARUN"; // Ganti dengan nama label yang sesuai
        label.style.marginTop = "0px"; // Tambahkan jarak antara ikon dan label
        label.style.fontSize = "11px";
        label.style.textAlign = "center";

        // Tambahkan label ke dalam container
        container.appendChild(label);

        // Sisipkan elemen container di urutan keempat dalam elemen navbar
        if (navbar.children.length >= 5) {
            navbar.insertBefore(container, navbar.children[5]);
        } else {
            navbar.appendChild(container);
        }
    } else {
        console.error("Elemen dengan id 'category-navbar' tidak ditemukan.");
    }
});
*/

document.addEventListener("DOMContentLoaded", function () {
    // Pilih elemen dengan id 'category-navbar'
    const navbar = document.getElementById("category-navbar");

    if (navbar) {
        // Buat elemen container untuk ikon dan label
        const container = document.createElement("div");
        container.style.display = "flex";
        container.style.flexDirection = "column";
        container.style.alignItems = "center";
        container.style.marginLeft = "0px"; // Atur jarak dari elemen lain

        // Buat elemen anchor untuk link
        const link = document.createElement("a");
        link.href = "/game?provider=1001&category=101"; // Ganti dengan URL tujuan
        //link.target = "_blank"; // Membuka link di tab baru (opsional)

        // Buat elemen gambar baru
        const icon = document.createElement("img");
        icon.src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6caniZJ3YLrHJfQQyl3ncEFEmW47r4FGyhdKSq-LvtQ87DEfyXLlIhV6cEoQQXAFHUW3daGMoO9qqUPKcMVEbEzfpwLoLiUHS-wBkh_qWfe2rfU-5ep75Z-i4HXBDQDf0fqNbC4THb0y93HQ4lVCygG61RIXPj5MLQPmT1a1_SmWLYJdMoH45gEUvo09j/s200/NAVBAR_KELIPATANPERKALIAN.gif"; // Ganti dengan URL gambar ikon Anda
        icon.alt = "Olympus Perkalian Ganda";
        icon.style.width = "35px";
        icon.style.height = "35px";

        // Tambahkan ikon ke dalam elemen anchor
        link.appendChild(icon);

        // Tambahkan elemen anchor (yang berisi ikon) ke dalam container
        container.appendChild(link);

        // Buat elemen label untuk nama ikon
        const label = document.createElement("span");
        label.textContent = "Olympus Perkalian Ganda"; // Ganti dengan nama label yang sesuai
        label.style.marginTop = "0px"; // Tambahkan jarak antara ikon dan label
        label.style.fontSize = "11px";
        label.style.textAlign = "center";

        // Tambahkan label ke dalam container
        container.appendChild(label);

        // Sisipkan elemen container di urutan keempat dalam elemen navbar
        if (navbar.children.length >= 5) {
            navbar.insertBefore(container, navbar.children[5]);
        } else {
            navbar.appendChild(container);
        }
    } else {
        console.error("Elemen dengan id 'category-navbar' tidak ditemukan.");
    }
});

/*
document.addEventListener("DOMContentLoaded", function () {
    // Pilih elemen dengan id 'category-navbar'
    const navbar = document.getElementById("category-navbar");

    if (navbar) {
        // Buat elemen container untuk ikon dan label
        const container = document.createElement("div");
        container.style.display = "flex";
        container.style.flexDirection = "column";
        container.style.alignItems = "center";
        container.style.marginLeft = "0px"; // Atur jarak dari elemen lain

        // Buat elemen anchor untuk link
        const link = document.createElement("a");
        link.href = "/game?provider=1003&category=101"; // Ganti dengan URL tujuan
        //link.target = "_blank"; // Membuka link di tab baru (opsional)

        // Buat elemen gambar baru
        const icon = document.createElement("img");
        icon.src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_kyBtTVgIqDZpI-50DUKMKhScuq8wY88JSqt3eL8PFJ-5GLPMzhHdRGc67l-_it-v-DlgcAIPrZefPmG1a37lqqWxBcBx7VUr5RXgclI0rvxPY1Qr-5T8GyL3DKxck9aJV_MEav6T99lA61mkxucZc1DXUAf1381TtKelTPHemMKzej8RH1JQ3RCy1Ntj/s250/gif-neko.gif"; // Ganti dengan URL gambar ikon Anda
        icon.alt = "Scatter Lucky Neko Icon";
        icon.style.width = "35p";
        icon.style.height = "35px";

        // Tambahkan ikon ke dalam elemen anchor
        link.appendChild(icon);

        // Tambahkan elemen anchor (yang berisi ikon) ke dalam container
        container.appendChild(link);

        // Buat elemen label untuk nama ikon
        const label = document.createElement("span");
        label.textContent = "SCATTER LUCKY NEKO"; // Ganti dengan nama label yang sesuai
        label.style.marginTop = "0px"; // Tambahkan jarak antara ikon dan label
        label.style.fontSize = "11px";
        label.style.textAlign = "center";

        // Tambahkan label ke dalam container
        container.appendChild(label);

        // Sisipkan elemen container di urutan keempat dalam elemen navbar
        if (navbar.children.length >= 5) {
            navbar.insertBefore(container, navbar.children[5]);
        } else {
            navbar.appendChild(container);
        }
    } else {
        console.error("Elemen dengan id 'category-navbar' tidak ditemukan.");
    }
});
*/


/* -----------------------------------------------------
   MAHJONG WAYS MEGA SCATTER
----------------------------------------------------- */

document.addEventListener("DOMContentLoaded", function () {

  document.querySelectorAll("a[target]").forEach(a => a.removeAttribute("target"));

  /* -----------------------------------------------------
     TARGET GAME
  ----------------------------------------------------- */
  const allImagesMjmegascatter = document.querySelectorAll("img[alt='Mahjong Ways']");
  if (allImagesMjmegascatter.length === 0) return;

  const targetImgMjmegascatter = allImagesMjmegascatter[0];
  const targetDivMjmegascatter = targetImgMjmegascatter.closest(".col-4.col-md-4.col-lg-3.col-xl-2");
  if (!targetDivMjmegascatter) return;

  /* -----------------------------------------------------
     IFRAME
  ----------------------------------------------------- */
  const iframePopupMjmegascatter = document.getElementById("game-iframe-popup-mj-mega-scatter");
  const gameIframeMjmegascatter = document.getElementById("game-iframe-mj-mega-scatter");
  const iframeLoadingMjmegascatter = document.getElementById("iframe-loading-mj-mega-scatter");
  const iframeErrorMjmegascatter = document.getElementById("iframe-error-mj-mega-scatter");
  let countdownTimeoutMjmegascatter = null;

  if (!iframePopupMjmegascatter || !gameIframeMjmegascatter) {
    console.error("Element iframe popup / iframe game tidak ditemukan.");
    return;
  }

  /* -----------------------------------------------------
     GAME LIST
  ----------------------------------------------------- */
  const gamesMjmegascatter = [
    {
      href: "/launch-pg-soft/65",
      loading: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiHsCmMEpyR1Sr3oTXt2lCDv6hVDXm7qz5skuUU0UHS4wosR0VYfy69i8FEW6Co8h5CvufFGo7wLFbV8tPVkE1O7HtXcvhPQynZQoQS8f128AQgUG2osnVX8mmW5rR1dWEqrPhQuTTi4_eOU0nUYJQobzB5GT2_FhoNyyL-TAJTyUbiT3AL890ot5q1kmk/s652/popup-mega-scatter.gif",
      img: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrAkdSRllZSSZ8qPom0bmnQ_BCOt6y9LC6cZ1Vdx2SLiV9Q-LZb5I4b6veOUUxadLW68Lhyq9Phi9IVnqo8fgLqj03KORp8itSncTxZ-eIy1DkBSMIwXmMN-ckNn9tb4BUuo-dU3l1JI0O9KtGj46B-Gd126px6HkD5vaRCi_cQyWQr4lSLnMOb8veYiDP/s165/GIFT%20GAME%20MH%201.gif",
      alt: "MJ Mega Scatter",
      timer: 3
    },
    {
      href: "/launch-pg-soft/74",
      loading: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiHsCmMEpyR1Sr3oTXt2lCDv6hVDXm7qz5skuUU0UHS4wosR0VYfy69i8FEW6Co8h5CvufFGo7wLFbV8tPVkE1O7HtXcvhPQynZQoQS8f128AQgUG2osnVX8mmW5rR1dWEqrPhQuTTi4_eOU0nUYJQobzB5GT2_FhoNyyL-TAJTyUbiT3AL890ot5q1kmk/s652/popup-mega-scatter.gif",
      img: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjprcjMqvZXsWnapQyfFBXek-xfN27Q2zQ8NNtWZCK0A0QC2Sfsb5DnDL7XT2WUiDILFkyHrc-nm2hOUneICJSREkf5hMjUf-PxLRnXkRa-vh8CuODtCO-_Ef7zzM9h_FmZJ8TIGL4rMZlpK488tSdHPFf5rPXfFkwE8jiEsQWBN-Vva4fg0H5tjurfHNlD/s165/GIFT%20GAME%20MJ%202.gif",
      alt: "MJ 2 Mega Scatter",
      timer: 3
    },
    {
      href: "/launch-pg-soft/39",
      img: "https://fffiiillleee.com/open-img-pub/games/pgsoft/39.jpg",
      alt: "Piggy Gold",
      timer: 3
    }
  ];

  gamesMjmegascatter.forEach((game) => {
    const divMjmegascatter = document.createElement("div");
    divMjmegascatter.className = "col-4 col-md-4 col-lg-3 col-xl-2";
    divMjmegascatter.innerHTML = `
      <div>
        <a href="${game.href}" class="custom-launch-mjmegascatter" data-loading="${game.loading || ""}">
          <img src="${game.img}" alt="${game.alt}" width="100%">
        </a>
      </div>`;
    targetDivMjmegascatter.before(divMjmegascatter);
  });

  /* -----------------------------------------------------
     CLICK
  ----------------------------------------------------- */
  document.querySelectorAll("a.custom-launch-mjmegascatter").forEach((link) => {
    link.addEventListener("click", function (e) {
      e.preventDefault();
      e.stopPropagation();
      e.stopImmediatePropagation();

      const urlMjmegascatter = this.getAttribute("href");
      const loadingSrcMjmegascatter = this.dataset.loading || "";
      const gameMatchMjmegascatter = gamesMjmegascatter.find(g => g.href === urlMjmegascatter);
      const timerValueMjmegascatter = gameMatchMjmegascatter?.timer || 5;

      startTimedLoadingMjmegascatter(urlMjmegascatter, loadingSrcMjmegascatter, timerValueMjmegascatter);
    }, true);
  });

  /* -----------------------------------------------------
     TIMER
  ----------------------------------------------------- */
  function startTimedLoadingMjmegascatter(url, loadingSrc, duration) {
    if (countdownTimeoutMjmegascatter) {
      clearTimeout(countdownTimeoutMjmegascatter);
      countdownTimeoutMjmegascatter = null;
    }

    if (iframeErrorMjmegascatter) iframeErrorMjmegascatter.style.display = "none";
    if (iframeLoadingMjmegascatter) iframeLoadingMjmegascatter.style.display = "flex";
    iframePopupMjmegascatter.style.display = "flex";
    gameIframeMjmegascatter.style.display = "none";
    gameIframeMjmegascatter.src = "about:blank";

    let overlayMjmegascatter = document.getElementById("custom-loading-mjmegascatter-mj-mega-scatter");
    let imageMjmegascatter;
    let textMjmegascatter;

    if (!overlayMjmegascatter) {
      overlayMjmegascatter = document.createElement("div");
      overlayMjmegascatter.id = "custom-loading-mjmegascatter-mj-mega-scatter";
      overlayMjmegascatter.style = `
        position:fixed;
        top:0;
        left:0;
        width:100%;
        height:100%;
        background:rgba(0,0,0,0.85);
        display:flex;
        flex-direction:column;
        justify-content:center;
        align-items:center;
        z-index:999999;
      `;

      imageMjmegascatter = document.createElement("img");
      imageMjmegascatter.id = "custom-loading-image-mjmegascatter-mj-mega-scatter";
      imageMjmegascatter.style = "max-width:350px; border-radius:12px; margin-bottom:20px;";
      overlayMjmegascatter.appendChild(imageMjmegascatter);

      textMjmegascatter = document.createElement("div");
      textMjmegascatter.id = "countdown-text-mjmegascatter-mj-mega-scatter";
      textMjmegascatter.style = "color:white; font-size:22px; font-weight:bold; text-align:center;";
      overlayMjmegascatter.appendChild(textMjmegascatter);

      document.body.appendChild(overlayMjmegascatter);
    }

    imageMjmegascatter = document.getElementById("custom-loading-image-mjmegascatter-mj-mega-scatter");
    textMjmegascatter = document.getElementById("countdown-text-mjmegascatter-mj-mega-scatter");

    if (imageMjmegascatter) {
      if (loadingSrc) {
        imageMjmegascatter.src = loadingSrc;
        imageMjmegascatter.style.display = "block";
      } else {
        imageMjmegascatter.removeAttribute("src");
        imageMjmegascatter.style.display = "none";
      }
    }

    let tMjmegascatter = duration;
    overlayMjmegascatter.style.display = "flex";
    if (textMjmegascatter) {
      textMjmegascatter.innerHTML = `Memuat game dalam ${tMjmegascatter} detik...`;
    }

    const countdownMjmegascatter = setInterval(() => {
      tMjmegascatter--;

      if (textMjmegascatter) {
        textMjmegascatter.innerHTML = `Memuat game dalam ${tMjmegascatter} detik...`;
      }

      if (tMjmegascatter <= 0) {
        clearInterval(countdownMjmegascatter);
        overlayMjmegascatter.style.display = "none";
        openIframeMjmegascatter(url);
      }
    }, 1000);
  }

  /* -----------------------------------------------------
     OPEN IFRAME
  ----------------------------------------------------- */
  function openIframeMjmegascatter(url) {
    if (iframeLoadingMjmegascatter) iframeLoadingMjmegascatter.style.display = "flex";
    if (iframeErrorMjmegascatter) iframeErrorMjmegascatter.style.display = "none";

    gameIframeMjmegascatter.onload = function () {
      if (iframeLoadingMjmegascatter) iframeLoadingMjmegascatter.style.display = "none";
      gameIframeMjmegascatter.style.display = "block";
    };

    gameIframeMjmegascatter.onerror = function () {
      if (iframeLoadingMjmegascatter) iframeLoadingMjmegascatter.style.display = "none";
      if (iframeErrorMjmegascatter) iframeErrorMjmegascatter.style.display = "flex";
    };

    gameIframeMjmegascatter.src = url;
  }

});


/* -----------------------------------------------------
   SCATTER JACKPOT
----------------------------------------------------- */

document.addEventListener("DOMContentLoaded", function () {
  console.log("✅ GIMMIK BOOST + MJ SCATTER AKTIF");

  /* =====================================================
     SAFE CALL
  ===================================================== */
  function safeCall(fn, ...args) {
    if (typeof fn === "function") fn(...args);
  }

  /* =====================================================
     BOOST ELEMENT
  ===================================================== */
  const boostPopup = document.getElementById("boost-popup");
  const boostBall  = document.getElementById("floating-glow-ball");

  let isBoostOpen = false;

  if (boostBall) boostBall.style.display = "none";
  if (boostPopup) boostPopup.style.display = "none";

  if (boostBall && boostPopup) {
    boostBall.addEventListener("click", (e) => {
      e.stopPropagation();
      isBoostOpen = !isBoostOpen;
      boostPopup.style.display = isBoostOpen ? "block" : "none";
    });
  }

  document.addEventListener("click", (e) => {
    if (isBoostOpen &&
        boostPopup &&
        boostBall &&
        !boostPopup.contains(e.target) &&
        !boostBall.contains(e.target)
    ) {
      boostPopup.style.display = "none";
      isBoostOpen = false;
    }
  });

  document.querySelectorAll(".boost-option").forEach(btn => {
    if (btn.dataset.gif) {
      btn.style.backgroundImage = `url(${btn.dataset.gif})`;
      btn.style.backgroundSize = "cover";
    }
    btn.addEventListener("click", (e) => {
      e.stopPropagation();
      const type = btn.dataset.type;
      sessionStorage.setItem("user_boost", type);
      if (boostPopup) boostPopup.style.display = "none";
      isBoostOpen = false;
      safeCall(window.applyBoostEffect, type);
      safeCall(window.showBoostConfirm, type);
    });
  });

  /* =====================================================
     MJ POPUP SCATTER GIF (VARIABEL UNIK)
  ===================================================== */
  const scatterGifList = [
    "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpaZBSRLOtDNYQFiHo0b5ORJepaIDDxTg9eJGWUCJq7sc3nh0sMyeytPehGh0jUqjK1uxdrUmVQFxa23tzZG42HPALGCKnLLQ-Ooo3KjCc_5EE8eHwpQ9sW5dZU7l57Ua_FePibC7zoNdXJfn48LmxJ7jjJSA_zc6DIpdMvDzmStDaeKbU-6dejz-GqEXi/s516/GIF-SELAMAT_SCATTERJACKPOT2.gif"
  ];

  const randomScatterGif = scatterGifList[Math.floor(Math.random() * scatterGifList.length)];

  const scatterGifPopup = document.createElement("div");
  scatterGifPopup.id = "scatter-popup-gif";
  scatterGifPopup.style = `
    display:none; position:fixed; top:0; left:0; width:100%; height:100%;
    background:rgba(0,0,0,0.9); z-index:1000000;
    text-align:center; padding-top:180px; cursor:pointer;
  `;
  scatterGifPopup.innerHTML = `
    <img src="${randomScatterGif}" style="width:300px; border-radius:15px;">
    <p style="color:white; font-size:22px; margin-top:15px;">
      Selamat bermain!<br><small>(Ketuk di mana saja untuk menutup)</small>
    </p>
  `;
  document.body.appendChild(scatterGifPopup);

  scatterGifPopup.addEventListener("click", () => {
    scatterGifPopup.style.display = "none";
  });

  /* =====================================================
     TARGET MAHJONG
  ===================================================== */
  const mjTargetImages = document.querySelectorAll("img[alt='Mahjong Ways']");
  if (!mjTargetImages.length) return;

  const mjTargetDiv = mjTargetImages[0].closest(".col-4.col-md-4.col-lg-3.col-xl-2");
  if (!mjTargetDiv) return;

  /* =====================================================
     IFRAME ELEMENTS
  ===================================================== */
  const mjIframePopup   = document.getElementById("game-iframe-popup");
  const mjGameIframe    = document.getElementById("game-iframe");
  const mjIframeLoading = document.getElementById("iframe-loading");
  const mjIframeError   = document.getElementById("iframe-error");

  /* =====================================================
     MJ SCATTER GAME DATA
  ===================================================== */
  const mjScatterGame = [
    {
      href: "/launch-pg-soft/65",
      loading: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSwS-vp4hszdMr0NTuCc74_OSASJhryB9rGDrDSuxWaSokXIViGcOUOJ7gbGPNhDJdO_Q1yHFz0FccSXyRUF7_1vbNwuzR82N20uGtsQwtc817QUZ7MI27jwkdlbOUG2sQmunmKLeYe9_DCqRnDwVqD2Rtavayic56L_a3buGAMuguyoibfBt73jspepBZ/s492/INFOEVENT_SCATTERJACKPOT.gif",
      img: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEile0gx64tbAhJ8CYT3iYL0NTD3F0y6CWyV3rHN1ZTu2kJKXmQBgtUloY7-nLYQAS0oqNoWUj60l_udHuosyTWZu_2xaiSkaR0O2CnE79S0dOYvvQpJJNiwJ_im_SqFXvnOd-NQ3Vqy86SvsX85t6kIHaU65LlsQnnxuxi3DFqo-Fg7hgX7s75tvs_G9dI9/s165/ICON_SCATTERJACKPOT.gif",
      alt: "MJ Scatter Jackpot",
      timer: 3
    },
    {
      href: "/launch-pg-soft/74",
      loading: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSwS-vp4hszdMr0NTuCc74_OSASJhryB9rGDrDSuxWaSokXIViGcOUOJ7gbGPNhDJdO_Q1yHFz0FccSXyRUF7_1vbNwuzR82N20uGtsQwtc817QUZ7MI27jwkdlbOUG2sQmunmKLeYe9_DCqRnDwVqD2Rtavayic56L_a3buGAMuguyoibfBt73jspepBZ/s492/INFOEVENT_SCATTERJACKPOT.gif",
      img: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR5DHtDYHR2Nrw5hSpSRIBC7KEFrHdvC83CorRATGjgUDHYqQHU22h-WCY9DKh_1LND0B-mL-DjyiC3v_ZEdHlrCYHmK_8Y6GNWXYjagyxaMCcDilnPmXhpIWuYbpYdylCOMXGm8iZ9Q5Y_oXK3jOqj74QAXKUA1pRhrg2aucQHT4bvCuyACvS3Apww-9V/s165/ICON_SCATTERJACKPOT2.gif",
      alt: "MJ 2 Scatter Jackpot",
      timer: 3
    },
    {
      href: "/launch-pg-soft/89",
      loading: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibicZRY62GB7moELD86vDac3Jwp_GjDIpmdQ400BHnqY3bw3rtP50kGZ8SxXzGv5diAMVxCOEEQJjbXzGGWn_dlEktBrXvjJqAKOnIFxYWBX_Se4y_JIf-_8h7in0XXxaE8knr7g0AWJm-Nudzl9LX2vEwAaHWbRj7k2GXMSWKDOH8b1b9s3Wta8ShEKs/s800/loading-ln.gif",
      img: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgazdpFn2VchUnEcdShejHyFRYdaV35qsdlSvMX23ES4I7wZzLNURlPuaXjuOq8XWoXEwBo0fDy2si-5OgolXruUkXtbg9CkLvERBQipA7jK0eCVyIKGG2ZmbcM52Qx13gVqIC_PkUCv_vqriV_HyZX-UZnNlNYDfPlgui7rcxddYgarZ5_T5jeWje2o70n/s300/89.jpg",
      alt: "Lucky Neko",
      timer: 3
    }
  ];

  mjScatterGame.forEach(game => {
    const div = document.createElement("div");
    div.className = "col-4 col-md-4 col-lg-3 col-xl-2";
    div.innerHTML = `
      <a href="${game.href}" class="custom-launch" data-loading="${game.loading}">
        <img src="${game.img}" alt="${game.alt}" width="100%">
      </a>`;
    mjTargetDiv.before(div);
  });

  document.querySelectorAll("a.custom-launch").forEach(link => {
    link.addEventListener("click", function (e) {
      e.preventDefault();
      e.stopPropagation();
      const url = this.getAttribute("href");
      const loading = this.dataset.loading;
      const game = mjScatterGame.find(g => g.href === url);
      startMjLoading(url, loading, game?.timer || 3);
    }, true);
  });

  function startMjLoading(url, img, duration) {
    mjIframePopup.style.display = "flex";
    mjIframeLoading.style.display = "flex";
    mjGameIframe.style.display = "none";
    mjIframeError.style.display = "none";

    showLoading(img);

    let t = duration;
    const cd = setInterval(() => {
      t--;
      if (t <= 0) {
        clearInterval(cd);
        removeLoading();
        openIframe(url);
      }
    }, 1000);
  }

  function openIframe(url) {
    mjGameIframe.src = url;

    mjGameIframe.onload = () => {
      mjIframeLoading.style.display = "none";
      mjGameIframe.style.display = "block";
      if (boostBall) boostBall.style.display = "block";
    };

    mjGameIframe.onerror = () => {
      if (mjIframeError) mjIframeError.style.display = "flex";
      if (boostBall) boostBall.style.display = "none";
    };
  }

  function showLoading(src) {
    const o = document.createElement("div");
    o.id = "custom-loading";
    o.style = `
      position:fixed;top:0;left:0;width:100%;height:100%;
      background:rgba(0,0,0,.85);display:flex;
      justify-content:center;align-items:center;z-index:999999;
    `;
    o.innerHTML = `<img src="${src}" style="max-width:350px;border-radius:12px">`;
    document.body.appendChild(o);
  }

  function removeLoading() {
    document.getElementById("custom-loading")?.remove();
  }

});





//NEW GATES OF OLYMPUS
document.addEventListener("DOMContentLoaded", function () {

  let pragmaticPopupNXT = document.createElement("div");
  pragmaticPopupNXT.id = "pragmatic-popup-gif-nxt";
  pragmaticPopupNXT.style = `
    display:none; position:fixed; top:0; left:0;
    width:100%; height:100%; background:rgba(0,0,0,0.9);
    z-index:10000000; text-align:center; padding-top:180px;
    cursor:pointer;
  `;
  pragmaticPopupNXT.innerHTML = `
    <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr5ElA7LuMp9HPavKdI3Bx1Y30-ykJmiK7GJJvzeNSyzNiy2D8Qt8N9alKVpYI-NGYC8eJO42ZuzW6CTm7cma9n53OlfzRO5Ge6gLt2pIjmgtOElrPdsQKafjoPn9amorv8FO2Zg799Qm72AnLDt6gILcC9K4530BP-PdAaWShSWzHck4wl5bPHJmgcW_B/s320/popup-pp.gif"
         style="width:300px; height:auto; border-radius:15px;">
    <p style="color:white; font-size:22px; margin-top:15px;">
      Selamat bermain! ðŸŽ‰<br><small>(Ketuk di mana saja untuk menutup)</small>
    </p>
  `;
  document.body.appendChild(pragmaticPopupNXT);

  const scatterImages = document.querySelectorAll("img[alt='Gates of Olympus Super Scatter']");
  if (!scatterImages.length) return;

  const refImg = scatterImages[0];
  const refCol = refImg.closest(".col-4.col-md-4.col-lg-3.col-xl-2");
  if (!refCol) return;

  function createGameCard(url, loadingGif, img, alt, id, timer = 5) {
    const d = document.createElement("div");
    d.className = "col-4 col-md-4 col-lg-3 col-xl-2";
    d.innerHTML = `
      <div>
        <a href="${url}" class="custom-launch" 
           data-loading="${loadingGif}"
           data-delay="${timer}">
          <div style="position: relative; display: inline-block;">
            <img src="${img}" alt="${alt}" width="100%" height="100%">
            <span class="game-favorite" data-id="${id}"
              style="position: absolute; top: 80px; right:8px;
              width:30px; height:30px; background:white; color:gray;
              display:flex; justify-content:center; align-items:center;
              border-radius:50%; cursor:pointer;">
              <i class="fas fa-star"></i>
            </span>
          </div>
        </a>
      </div>
    `;
    return d;
  }

  const gameData = [
    {
      url: "/launch-pragmatic/vs20olympx",
      loading: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqhqR07ihj92GdJ1A2xrM8mRnFD41eyOWtWiMlAe6jn_359j7lv9XYdwbapa9KV-mhfSV6q7um78kpJEkwPQ9ssov-SzR-dOyU6lII7FTj2Y5CNhLfc9qv_1wrL8USljBzwy5I3sE3qU65SWwswfD5dw7NPIx40YQp6BmRAYK_qNfLm3MmXSDthKfKDCwR/s250/VERIFIKASIPRAGMATIC_OMPONG.gif",
      thumb: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH8rxVcEB1LX2TwT67U0x-NLiLrCVg7HyeehyphenhyphenEGV1jc-s9YKekQFol3YmEWkyQ1vF59IQEoviyGNG1dSvwXfxfjzTR9A04y7ZOzlFJ7t820ST0oc-u-FFhKhw2C-__Dm8fFjRN1np1ae2G7VNvpajs206-gHmlhwXPTuVXj4ho3mFViPs_9SyZ98TrDhf3/s165/ICON-ZEUS.gif",
      alt: "New Gates of Olympus",
      id: 9101,
      timer: 3
    }
  ];

  gameData.forEach(g => {
    refCol.before(
      createGameCard(g.url, g.loading, g.thumb, g.alt, g.id, g.timer)
    );
  });

  const iframePopup   = document.getElementById("game-iframe-popup");
  const gameIframe    = document.getElementById("game-iframe");
  const iframeLoading = document.getElementById("iframe-loading");
  const iframeError   = document.getElementById("iframe-error");

  function showLoadingOverlay(src, timer) {
    let o = document.createElement("div");
    o.id = "custom-loading";
    o.style = `
      position:fixed; top:0; left:0;
      width:100%; height:100%;
      background:rgba(0,0,0,0.85);
      display:flex; justify-content:center; align-items:center;
      z-index:999999;
      flex-direction:column;
      color:white;
      font-size:22px;
      font-weight:bold;
    `;

    const img = document.createElement("img");
    img.src = src;
    img.style = "max-width:400px; border-radius:12px; margin-bottom:20px;";
    o.appendChild(img);

    const timerText = document.createElement("div");
    timerText.id = "delay-timer-text";
    timerText.innerHTML = `Memuat game dalam ${timer} detik...`;
    o.appendChild(timerText);

    document.body.appendChild(o);

    let t = timer;
    let interval = setInterval(() => {
      t--;
      timerText.innerHTML = `Memuat game dalam ${t} detik...`;

      if (t <= 0) {
        clearInterval(interval);
        removeLoadingOverlay();
        finishIframeLoad();
      }
    }, 1000);

    function finishIframeLoad() {
      gameIframe.src = o.dataset.url;
    }
  }

  function removeLoadingOverlay() {
    const x = document.getElementById("custom-loading");
    if (x) x.remove();
  }

  function showGifPopup() {
    pragmaticPopupNXT.style.display = "block";
    pragmaticPopupNXT.addEventListener("click", function close() {
      pragmaticPopupNXT.style.display = "none";
      pragmaticPopupNXT.removeEventListener("click", close);
    });
  }

  document.querySelectorAll("a.custom-launch").forEach((link) => {
    link.addEventListener("click", function (e) {
      e.preventDefault();
      e.stopPropagation();

      this.removeAttribute("target");

      const url      = this.getAttribute("href");
      const loading  = this.dataset.loading || "";
      const delaySec = parseInt(this.dataset.delay || "5");

      iframePopup.style.display = "flex";
      iframeLoading.style.display = "none";
      iframeError.style.display = "none";
      gameIframe.style.display = "none";

      // tampilkan overlay + timer
      let overlay = showLoadingOverlay(loading, delaySec);
      document.getElementById("custom-loading").dataset.url = url;

      // setelah iframe load â†’ popup GIF
      gameIframe.onload = () => {
        gameIframe.style.display = "block";
        setTimeout(showGifPopup, 10000);
      };

    });
  });

});


    
    
//SCRIPT BUTTON WIDGET
document.addEventListener("DOMContentLoaded", function () {
    // Buat elemen <script>
    const script = document.createElement("script");
    
    // Tentukan atribut src untuk file eksternal
    script.src = "https://ompong.tomswickpbn.com/ompong188/nxt/button-menu/assets/database/menu/js/jquery-3.7.1.min.js";
    
    // Pastikan script dimuat setelah DOM
    script.defer = true;

    // Tambahkan elemen <script> ke dalam <head> atau <body>
    document.head.appendChild(script);

    script.onload = function () {
        console.log("Script berhasil dimuat: " + script.src);
    };

    script.onerror = function () {
        console.error("Gagal memuat script: " + script.src);
    };
});

document.addEventListener("DOMContentLoaded", function () {
    // Pastikan elemen dengan id 'row-togel' ada
    const rowTogel = document.getElementById("row-togel");

    if (rowTogel) {
        // Buat elemen <iframe>
        const iframe = document.createElement("iframe");
        iframe.src = "https://ompong.tomswickpbn.com/ompong188/nxt/button-menu/assets/database/menu/NY.html";
        iframe.height = "435px";
        iframe.width = "100%";
        iframe.frameBorder = "0";
        iframe.style.display = "block";
        iframe.style.border = "none"; // Menghilangkan border untuk tampilan bersih
        iframe.style.margin = "10px 0"; // Menambahkan margin untuk memberikan ruang

        // Responsivitas tambahan untuk layar kecil
        iframe.style.maxWidth = "100%"; // Pastikan tidak melewati lebar layar
        iframe.style.height = "calc(100vw * 0.9)"; // Penyesuaian dinamis berdasarkan lebar layar

        // Sisipkan iframe di atas elemen dengan id 'row-togel'
        rowTogel.parentNode.insertBefore(iframe, rowTogel);
        console.log("Iframe berhasil disisipkan di atas id 'row-togel'.");
    } else {
        console.error("Elemen dengan id 'row-togel' tidak ditemukan.");
    }
});

 
//SCRIPT BUTTON WIDGET
(function () {

    const items = [
        { img: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRDY6vCba1muTDeqV_-OpN34urmAowyq-4jmZIqkphxGiXeLQ3CbtLSANwPWyTvHoitxodwSBZ397TvD0Fkx2tNThR80bDYIbz15TxJk0lTv8uPfIXojFT0KrRmU25UmvB30mQgvde5HXyCaB-17N8P5bgT2ZmfNjJYb_Hi7kxSBTs7fq2-LdXmsT7Le3w/s250/WIDGET_PIALADUNIA_OMPONG.gif", link: "https://cutt.ly/worldcupompong" },
        { img: "https://blogger.googleusercontent.com/img/a/AVvXsEj4WfbbFbc8Yi7xsZaKICXxXh1rTvo5snAQW7pBXG4CCWAkX3waxDZnRmZQVOMAVK3amWmapFsoyuPllA8Z0xJ76lmRtVJPWOzP1TF5zPeQw311Ynizix8fONLBsZ7typNmXSp2MLO9RLLTB2sdGs26Jh72KVrniks35SC_A-nZ6FEFzYPTZV-c02vZM-s", link: "https://t.me/ompong188" }
    ];

    const SIZE = 52;
    const GAP = 10;
    const STEP = SIZE + GAP;
    const ITEM_COUNT = items.length;
    const TOGGLE_TOP = ITEM_COUNT * STEP;

    const css = document.createElement("style");
    css.innerHTML = `
    .bottom-widget-menu{
        position:fixed;
        left:8px;
        bottom:70px;
        z-index:999999;
        width:105px;
        height:${TOGGLE_TOP + SIZE + 10}px;
        pointer-events:none;
    }

    .bottom-widget-item,
    .bottom-widget-toggle{
        width:${SIZE}px;
        height:${SIZE}px;
        border-radius:14px;
        border:2px solid #ffd400;
        position:absolute;
        left:0;
        overflow:hidden;
        display:flex;
        align-items:center;
        justify-content:center;
        cursor:pointer;
        text-decoration:none;
        pointer-events:auto;
        background:linear-gradient(145deg,#050505,#171717,#000);
        box-shadow:
            inset 0 1px 0 rgba(255,255,255,.18),
            inset 0 -10px 16px rgba(0,0,0,.75),
            0 0 12px rgba(255,212,0,.8),
            0 12px 24px rgba(0,0,0,.65);
        transition:
            transform .95s cubic-bezier(.25,.9,.25,1),
            opacity .55s ease,
            filter .55s ease,
            box-shadow .35s ease;
        will-change:transform,opacity,filter;
    }

    .bottom-widget-item img{
        width:100%;
        height:100%;
        object-fit:cover;
        border-radius:11px;
    }

    .bottom-widget-toggle{
        top:${TOGGLE_TOP}px;
    }

    .bottom-widget-toggle span{
        position:absolute;
        width:28px;
        height:4px;
        border-radius:20px;
        background:linear-gradient(90deg,#fff,#ffd400,#fff);
        box-shadow:0 0 8px rgba(255,212,0,.8);
        transition:.45s ease;
        z-index:5;
    }

    .bottom-widget-toggle span:nth-child(1){transform:rotate(45deg);}
    .bottom-widget-toggle span:nth-child(2){opacity:0;transform:scaleX(0);}
    .bottom-widget-toggle span:nth-child(3){transform:rotate(-45deg);}

    .bottom-widget-menu.hide .bottom-widget-toggle span:nth-child(1){
        transform:translateY(-8px);
    }

    .bottom-widget-menu.hide .bottom-widget-toggle span:nth-child(2){
        opacity:1;
        transform:scaleX(1);
    }

    .bottom-widget-menu.hide .bottom-widget-toggle span:nth-child(3){
        transform:translateY(8px);
    }

    .bottom-widget-menu.hide .bottom-widget-item{
        opacity:0;
        filter:blur(4px);
        pointer-events:none;
        transform:translateY(var(--close-y)) scale(.15) rotate(var(--close-rotate));
    }

    .bottom-widget-menu:not(.hide) .bottom-widget-item{
        opacity:1;
        filter:blur(0);
        transform:translateY(0) scale(1) rotate(0);
    }

    .bottom-widget-notice{
        position:absolute;
        left:48px;
        top:${Math.max(0, TOGGLE_TOP - 10)}px;
        width:46px;
        height:46px;
        border-radius:50%;
        border:2px solid #ffd400;
        background:linear-gradient(145deg,#ff2b2b,#e00000 52%,#8b0000);
        color:#fff;
        font-size:8px;
        font-weight:1000;
        line-height:1.05;
        text-align:center;
        display:flex;
        align-items:center;
        justify-content:center;
        padding:5px;
        box-sizing:border-box;
        cursor:pointer;
        pointer-events:auto;
        overflow:hidden;
        z-index:30;
        box-shadow:
            inset 0 1px 0 rgba(255,255,255,.55),
            inset 0 -8px 10px rgba(70,0,0,.45),
            0 0 10px rgba(255,212,0,.9),
            0 0 26px rgba(255,212,0,.8),
            0 8px 14px rgba(0,0,0,.45);
        animation:noticePulse 1.55s ease-in-out infinite;
        transition:.35s ease;
    }

    .bottom-widget-notice::before{
        content:"";
        position:absolute;
        inset:0;
        background:linear-gradient(115deg,transparent 20%,rgba(255,255,255,.75) 45%,transparent 70%);
        transform:translateX(-120%);
        animation:noticeShine 2.4s ease-in-out infinite;
        z-index:1;
    }

    .bottom-widget-notice::after{
        content:"";
        position:absolute;
        inset:-5px;
        border-radius:50%;
        border:2px solid #ffd400;
        box-shadow:
            0 0 10px #ffd400,
            0 0 24px rgba(255,212,0,.9),
            0 0 42px rgba(255,170,0,.7);
        animation:goldGlow 1.4s ease-in-out infinite;
        z-index:2;
        pointer-events:none;
    }

    .bottom-widget-notice span{
        position:relative;
        z-index:3;
        text-shadow:
            0 2px 2px rgba(0,0,0,.75),
            0 0 8px rgba(255,255,255,.55);
    }

    .bottom-widget-menu:not(.hide) .bottom-widget-notice{
        opacity:0;
        transform:scale(.65) translateX(-8px);
        pointer-events:none;
    }

    .bottom-widget-item:hover,
    .bottom-widget-toggle:hover{
        transform:scale(1.06);
        box-shadow:
            inset 0 1px 0 rgba(255,255,255,.22),
            inset 0 -10px 16px rgba(0,0,0,.8),
            0 0 18px rgba(255,212,0,1),
            0 14px 26px rgba(0,0,0,.7);
    }

    @keyframes noticePulse{
        0%,100%{transform:scale(1);}
        50%{transform:scale(1.08);}
    }

    @keyframes noticeShine{
        0%,45%{transform:translateX(-120%);opacity:0;}
        55%{opacity:.85;}
        78%{transform:translateX(120%);opacity:.45;}
        100%{transform:translateX(120%);opacity:0;}
    }

    @keyframes goldGlow{
        0%,100%{opacity:.65;transform:scale(.95);}
        50%{opacity:1;transform:scale(1.18);}
    }
    `;
    document.head.appendChild(css);

    const wrapper = document.createElement("div");
    wrapper.className = "bottom-widget-menu hide";

    function createItem(item, index) {
        const a = document.createElement("a");
        a.className = "bottom-widget-item";
        a.href = item.link;

        const top = index * STEP;
        const closeY = TOGGLE_TOP - top;
        const rotate = (index - (ITEM_COUNT - 1) / 2) * 14;

        a.style.top = top + "px";
        a.style.setProperty("--close-y", closeY + "px");
        a.style.setProperty("--close-rotate", rotate + "deg");

        const openDelay = (ITEM_COUNT - 1 - index) * 0.07;
        const closeDelay = index * 0.07;

        a.style.transitionDelay = "0s";

        a.dataset.openDelay = openDelay + "s";
        a.dataset.closeDelay = closeDelay + "s";

        const img = document.createElement("img");
        img.src = item.img;
        a.appendChild(img);

        return a;
    }

    const toggle = document.createElement("button");
    toggle.className = "bottom-widget-toggle";
    toggle.type = "button";
    toggle.innerHTML = `<span></span><span></span><span></span>`;

    const notice = document.createElement("button");
    notice.className = "bottom-widget-notice";
    notice.type = "button";
    notice.innerHTML = "<span>EVENT<br>BARU!</span>";

    let opened = false;
    let busy = false;

    function setDelays(mode) {
        const buttons = wrapper.querySelectorAll(".bottom-widget-item");
        buttons.forEach(function (btn) {
            btn.style.transitionDelay = mode === "open" ? btn.dataset.openDelay : btn.dataset.closeDelay;
        });
    }

    function openWidget() {
        if (busy || opened) return;
        busy = true;

        setDelays("open");
        wrapper.classList.remove("hide");

        setTimeout(function () {
            opened = true;
            busy = false;
        }, 1150 + ITEM_COUNT * 70);
    }

    function closeWidget() {
        if (busy || !opened) return;
        busy = true;

        setDelays("close");
        wrapper.classList.add("hide");

        setTimeout(function () {
            opened = false;
            busy = false;
        }, 1150 + ITEM_COUNT * 70);
    }

    toggle.onclick = function () {
        opened ? closeWidget() : openWidget();
    };

    notice.onclick = openWidget;

    items.forEach(function(item, index){
        wrapper.appendChild(createItem(item, index));
    });

    wrapper.appendChild(toggle);
    wrapper.appendChild(notice);

    document.body.appendChild(wrapper);

})();

// HIDE LOBBY + WIDGET SAAT GAME DIBUKA
(function () {

    const HIDE_SELECTORS = [
        '.row.mb-3.g-1',
        '.col-4.col-md-4.col-lg-3.col-xl-2',
        '.provider-games',
        '.games-list',
        '.game-list',
        '.game-container',
        '.bottom-widget-menu',
        '.bottom-widget-toggle',
        '.bottom-widget-notice'
    ];

    function hideElements() {
        HIDE_SELECTORS.forEach(function(selector){
            document.querySelectorAll(selector).forEach(function(el){
                el.style.setProperty('display','none','important');
                el.style.setProperty('visibility','hidden','important');
                el.style.setProperty('opacity','0','important');
                el.style.setProperty('pointer-events','none','important');
            });
        });
    }

    function showElements() {
        HIDE_SELECTORS.forEach(function(selector){
            document.querySelectorAll(selector).forEach(function(el){
                el.style.removeProperty('display');
                el.style.removeProperty('visibility');
                el.style.removeProperty('opacity');
                el.style.removeProperty('pointer-events');
            });
        });
    }

    function isVisible(id){
        const el=document.getElementById(id);
        if(!el) return false;

        const style=getComputedStyle(el);

        return (
            style.display!=="none" &&
            style.visibility!=="hidden" &&
            style.opacity!=="0"
        );
    }

    function isGameOpened(){

        if(/\/launch-/i.test(location.pathname)){
            return true;
        }

        if(isVisible('game-iframe-popup')) return true;

        if(isVisible('game-iframe-popup-mj-mega-scatter')) return true;

        if(isVisible('custom-loading')) return true;

        if(isVisible('custom-loading-mjmegascatter-mj-mega-scatter')) return true;

        return false;
    }

    function check(){

        if(isGameOpened()){
            hideElements();
        }else{
            showElements();
        }

    }

    check();

    // monitor perubahan
    setInterval(check,150);

})();





// CUSTOM POPUP NEW
(function () {
    "use strict";

    /*
     * ==========================================================
     * KONFIGURASI ISI POPUP
     * ==========================================================
     *
     * Edit semua tulisan, URL, dan nama tombol hanya di bagian
     * ini. Bentuk serta CSS popup tidak perlu diubah.
     */

    var NEW_CUSTOM_POPUP_CONTENT = {
        /*
         * Judul utama popup.
         */
        title: "INFORMASI PENTING",

        /*
         * Caption informasi pertama.
         *
         * Gunakan:
         * <br> untuk pindah satu baris.
         * <br><br> untuk memberikan jarak.
         * <b>teks</b> untuk tulisan kuning tebal.
         */
        informationCaption: `
            Kami Sarankan Untuk Seluruh Member Setia<br>
            <b>OMPONG188</b><br><br>

            Agar Men-Download Aplikasi<br>
            OMPONG188 Dan Menyimpan Nomor WhatsApp Kami<br><br>

            Supaya Jika Mengalami Kendala<br>
            Atau Kesulitan Akses Dapat Kami Bantu<br>
            Secepat Mungkin
        `,

        /*
         * Tulisan sebelum link aplikasi.
         */
        applicationLabel:
            "Link Download App Klik Di Sini : ",

        /*
         * URL aplikasi.
         */
        applicationUrl:
            "https://cuttlink.live/s/apkompong",

        /*
         * Tulisan link aplikasi.
         */
        applicationLinkText:
            "APP OMPONG188",

        /*
         * Judul bagian komunitas.
         */
        communityTitle: `
            JOIN GROUP KOMUNITAS<br>
            OMPONG188
        `,

        /*
         * Caption informasi komunitas.
         */
        communityCaption: `
            Join Group Komunitas OMPONG188 &amp; Claim<br>
            Berbagai Macam Event Menarik Yang Tersedia<br>
            Event Scatter | Freespin | Garansi Kekalahan<br>
            Everyday &amp; Masih Banyak Lagi Event Menarik Lainnya
        `,

        /*
         * Tulisan sebelum link grup.
         */
        groupLabel:
            "Link Join Group : ",

        /*
         * URL grup.
         */
        groupUrl:
            "https://cuttlink.live/s/grupompong",

        /*
         * Tulisan link grup.
         */
        groupLinkText:
            "GRUP KOMUNITAS OMPONG188",

        /*
         * Tulisan bagian bawah.
         */
        footerText:
            "TERIMA KASIH",

        /*
         * Tulisan pada tombol.
         */
        buttonText:
            "OK",

        /*
         * Kunci penyimpanan status popup.
         *
         * Popup tidak muncul kembali setelah ditutup.
         * Ganti v1 menjadi v2 untuk menampilkan pengumuman baru
         * kepada semua pengunjung tanpa menghapus localStorage.
         */
        storageKey:
            "new_custom_popup_OMPONG188_sudah_ditutup_v1"
    };

    /*
     * ==========================================================
     * PEMERIKSAAN STATUS POPUP
     * ==========================================================
     */

    function newCustomPopupSudahDitutup() {
        try {
            return localStorage.getItem(
                NEW_CUSTOM_POPUP_CONTENT.storageKey
            ) === "1";
        } catch (error) {
            return false;
        }
    }

    /*
     * Simpan status ketika tombol OK atau X ditekan.
     */
    function simpanStatusNewCustomPopup() {
        try {
            localStorage.setItem(
                NEW_CUSTOM_POPUP_CONTENT.storageKey,
                "1"
            );
        } catch (error) {
            /*
             * Popup tetap dapat ditutup jika localStorage
             * diblokir oleh browser.
             */
        }
    }

    /*
     * ==========================================================
     * FUNGSI MENAMPILKAN POPUP
     * ==========================================================
     */

    function tampilkanNewCustomPopup(forceTampil) {
        /*
         * Jangan tampilkan popup apabila sebelumnya sudah ditutup.
         */
        if (
            forceTampil !== true &&
            newCustomPopupSudahDitutup()
        ) {
            return;
        }

        /*
         * Hapus popup lama supaya tidak terjadi duplikasi.
         */
        var popupLama = document.getElementById(
            "new-custom-popup-host"
        );

        if (popupLama) {
            popupLama.remove();
        }

        /*
         * Tunggu sampai elemen body tersedia.
         */
        if (!document.body) {
            setTimeout(function () {
                tampilkanNewCustomPopup(forceTampil);
            }, 100);

            return;
        }

        /*
         * Container utama popup.
         */
        var host = document.createElement("div");

        host.id = "new-custom-popup-host";

        host.style.setProperty(
            "position",
            "fixed",
            "important"
        );

        host.style.setProperty(
            "top",
            "0",
            "important"
        );

        host.style.setProperty(
            "right",
            "0",
            "important"
        );

        host.style.setProperty(
            "bottom",
            "0",
            "important"
        );

        host.style.setProperty(
            "left",
            "0",
            "important"
        );

        host.style.setProperty(
            "width",
            "100vw",
            "important"
        );

        host.style.setProperty(
            "height",
            "100vh",
            "important"
        );

        host.style.setProperty(
            "display",
            "block",
            "important"
        );

        host.style.setProperty(
            "visibility",
            "visible",
            "important"
        );

        host.style.setProperty(
            "opacity",
            "1",
            "important"
        );

        host.style.setProperty(
            "z-index",
            "2147483647",
            "important"
        );

        host.style.setProperty(
            "pointer-events",
            "auto",
            "important"
        );

        host.style.setProperty(
            "transition",
            "opacity 0.18s ease",
            "important"
        );

        document.body.appendChild(host);

        /*
         * Gunakan Shadow DOM agar CSS website tidak mengubah
         * bentuk popup.
         */
        var root;

        if (typeof host.attachShadow === "function") {
            root = host.attachShadow({
                mode: "open"
            });
        } else {
            root = host;
        }

        /*
         * ======================================================
         * CSS POPUP
         * BENTUK ASLI TETAP DIPERTAHANKAN
         * ======================================================
         */

        var style = document.createElement("style");

        style.textContent = `
            :host {
                all: initial !important;
            }

            *,
            *::before,
            *::after {
                box-sizing: border-box !important;
            }

            #new-custom-popup-overlay {
                position: fixed !important;
                inset: 0 !important;

                width: 100vw !important;
                height: 100vh !important;
                min-height: 100vh !important;

                display: flex !important;
                align-items: center !important;
                justify-content: center !important;

                padding: 15px !important;
                margin: 0 !important;

                overflow-x: hidden !important;
                overflow-y: auto !important;

                visibility: visible !important;
                opacity: 1 !important;

                background:
                    rgba(0, 0, 0, 0.86) !important;

                z-index: 2147483647 !important;

                font-family:
                    Arial,
                    Helvetica,
                    sans-serif !important;

                -webkit-font-smoothing:
                    antialiased !important;

                text-rendering:
                    optimizeLegibility !important;
            }

            #new-custom-popup-box {
                position: relative !important;

                display: block !important;

                width: 350px !important;
                max-width: 100% !important;
                max-height:
                    calc(100vh - 30px) !important;

                margin: auto !important;

                padding:
                    18px
                    18px
                    15px !important;

                overflow-x: hidden !important;
                overflow-y: auto !important;

                color: #ffffff !important;
                text-align: center !important;

                background:
                    radial-gradient(
                        circle at 50% 0,
                        rgba(255, 238, 0, 0.18),
                        transparent 34%
                    ),
                    #050505 !important;

                border:
                    1px solid
                    rgba(255, 238, 0, 0.22) !important;

                border-radius: 5px !important;

                box-shadow:
                    0 22px 70px
                    rgba(0, 0, 0, 0.90),

                    0 0 25px
                    rgba(255, 238, 0, 0.14) !important;

                visibility: visible !important;
                opacity: 1 !important;

                animation:
                    newCustomPopupMuncul
                    0.28s
                    ease-out
                    both !important;

                scrollbar-width: thin !important;

                scrollbar-color:
                    #ffea00
                    #111111 !important;
            }

            #new-custom-popup-box::-webkit-scrollbar {
                width: 5px !important;
            }

            #new-custom-popup-box::-webkit-scrollbar-track {
                background: #111111 !important;
            }

            #new-custom-popup-box::-webkit-scrollbar-thumb {
                background: #ffea00 !important;
                border-radius: 10px !important;
            }

            @keyframes newCustomPopupMuncul {
                from {
                    opacity: 0;

                    transform:
                        translateY(18px)
                        scale(0.94);
                }

                to {
                    opacity: 1;

                    transform:
                        translateY(0)
                        scale(1);
                }
            }

            #new-custom-popup-close {
                position: absolute !important;

                top: 5px !important;
                right: 8px !important;

                width: 29px !important;
                height: 29px !important;

                display: flex !important;
                align-items: center !important;
                justify-content: center !important;

                padding: 0 !important;
                margin: 0 !important;

                border: 0 !important;
                outline: 0 !important;

                border-radius: 50% !important;

                color: #ffffff !important;
                background: transparent !important;

                font-family:
                    Arial,
                    sans-serif !important;

                font-size: 23px !important;
                font-weight: 400 !important;
                line-height: 1 !important;

                text-align: center !important;
                cursor: pointer !important;

                opacity: 0.88 !important;

                transition:
                    color 0.2s ease,
                    background 0.2s ease,
                    opacity 0.2s ease,
                    transform 0.2s ease !important;
            }

            #new-custom-popup-close:hover {
                color: #ffef00 !important;

                background:
                    rgba(
                        255,
                        239,
                        0,
                        0.12
                    ) !important;

                opacity: 1 !important;

                transform:
                    rotate(90deg) !important;
            }

            #new-custom-popup-close:focus {
                outline:
                    2px solid
                    rgba(
                        255,
                        239,
                        0,
                        0.75
                    ) !important;

                outline-offset: 1px !important;
            }

            #new-custom-popup-title {
                display: block !important;

                margin:
                    0
                    25px
                    15px !important;

                padding: 0 !important;

                color: #fff200 !important;
                background: transparent !important;

                font-family:
                    Arial,
                    sans-serif !important;

                font-size: 18px !important;
                font-weight: 900 !important;
                line-height: 1.25 !important;

                letter-spacing: 0.3px !important;

                text-align: center !important;
                text-transform: uppercase !important;

                text-shadow:
                    0 0 12px
                    rgba(
                        255,
                        242,
                        0,
                        0.38
                    ) !important;
            }

            #new-custom-popup-box p {
                display: block !important;

                margin:
                    0
                    0
                    11px !important;

                padding: 0 !important;

                color: #ffffff !important;
                background: transparent !important;

                font-family:
                    Arial,
                    sans-serif !important;

                font-size: 11px !important;
                font-weight: 700 !important;
                line-height: 1.42 !important;

                letter-spacing: 0 !important;

                text-align: center !important;
                text-transform: none !important;
            }

            #new-custom-popup-box b,
            #new-custom-popup-box strong {
                color: #fff200 !important;
                font-weight: 900 !important;
            }

            #new-custom-popup-box a {
                display: inline !important;

                padding: 0 !important;
                margin: 0 !important;

                color: #fff200 !important;
                background: transparent !important;

                font-family:
                    Arial,
                    sans-serif !important;

                font-size: inherit !important;
                font-weight: 900 !important;
                line-height: inherit !important;

                text-decoration: none !important;
                text-transform: uppercase !important;

                cursor: pointer !important;

                transition:
                    color 0.2s ease,
                    text-shadow 0.2s ease !important;
            }

            #new-custom-popup-box a:hover {
                color: #fff86b !important;

                text-decoration:
                    underline !important;

                text-shadow:
                    0 0 10px
                    rgba(
                        255,
                        242,
                        0,
                        0.55
                    ) !important;
            }

            #new-custom-popup-box a:focus {
                outline:
                    1px solid
                    rgba(
                        255,
                        242,
                        0,
                        0.85
                    ) !important;

                outline-offset: 2px !important;
            }

            #new-custom-popup-community-title {
                display: block !important;

                margin:
                    15px
                    0
                    8px !important;

                padding: 0 !important;

                color: #ffffff !important;
                background: transparent !important;

                font-family:
                    Arial,
                    sans-serif !important;

                font-size: 16px !important;
                font-weight: 900 !important;
                line-height: 1.25 !important;

                text-align: center !important;
                text-transform: uppercase !important;
            }

            #new-custom-popup-thanks {
                display: block !important;

                margin:
                    14px
                    0
                    12px !important;

                padding: 0 !important;

                color: #fff200 !important;
                background: transparent !important;

                font-family:
                    Arial,
                    sans-serif !important;

                font-size: 13px !important;
                font-weight: 900 !important;
                line-height: 1.3 !important;

                text-align: center !important;
                text-transform: uppercase !important;

                text-shadow:
                    0 0 11px
                    rgba(
                        255,
                        242,
                        0,
                        0.40
                    ) !important;
            }

            #new-custom-popup-ok {
                display: inline-flex !important;

                align-items: center !important;
                justify-content: center !important;

                min-width: 100px !important;
                min-height: 35px !important;

                margin: 0 auto !important;

                padding:
                    9px
                    24px !important;

                border:
                    1px solid
                    rgba(
                        255,
                        255,
                        255,
                        0.18
                    ) !important;

                outline: 0 !important;
                border-radius: 3px !important;

                color: #111111 !important;

                background:
                    linear-gradient(
                        180deg,
                        #ffff63 0%,
                        #fff200 45%,
                        #e5c900 100%
                    ) !important;

                box-shadow:
                    0 6px 18px
                    rgba(
                        255,
                        230,
                        0,
                        0.38
                    ),

                    inset
                    0
                    1px
                    0
                    rgba(
                        255,
                        255,
                        255,
                        0.65
                    ) !important;

                font-family:
                    Arial,
                    sans-serif !important;

                font-size: 12px !important;
                font-weight: 900 !important;
                line-height: 1 !important;

                text-align: center !important;
                text-transform: uppercase !important;

                cursor: pointer !important;

                transition:
                    filter 0.2s ease,
                    transform 0.15s ease,
                    box-shadow 0.2s ease !important;
            }

            #new-custom-popup-ok:hover {
                filter:
                    brightness(1.10) !important;

                box-shadow:
                    0 8px 22px
                    rgba(
                        255,
                        230,
                        0,
                        0.52
                    ),

                    inset
                    0
                    1px
                    0
                    rgba(
                        255,
                        255,
                        255,
                        0.75
                    ) !important;
            }

            #new-custom-popup-ok:focus {
                outline:
                    2px solid
                    rgba(
                        255,
                        242,
                        0,
                        0.85
                    ) !important;

                outline-offset: 2px !important;
            }

            #new-custom-popup-ok:active {
                transform:
                    translateY(1px) !important;
            }

            @media screen and (max-width: 480px) {
                #new-custom-popup-overlay {
                    align-items: center !important;
                    padding: 8px !important;
                }

                #new-custom-popup-box {
                    width: 100% !important;

                    max-height:
                        calc(
                            100vh - 16px
                        ) !important;

                    padding:
                        15px
                        14px
                        13px !important;
                }

                #new-custom-popup-title {
                    margin-bottom: 13px !important;
                    font-size: 16px !important;
                }

                #new-custom-popup-community-title {
                    font-size: 15px !important;
                }

                #new-custom-popup-box p {
                    font-size: 10.5px !important;
                }
            }

            @media screen and (max-height: 600px) {
                #new-custom-popup-overlay {
                    align-items: flex-start !important;

                    padding-top: 8px !important;
                    padding-bottom: 8px !important;
                }

                #new-custom-popup-box {
                    max-height:
                        calc(
                            100vh - 16px
                        ) !important;
                }
            }
        `;

        /*
         * ======================================================
         * MEMBUAT STRUKTUR POPUP
         * ======================================================
         */

        var overlay = document.createElement("div");

        overlay.id = "new-custom-popup-overlay";

        overlay.setAttribute(
            "role",
            "dialog"
        );

        overlay.setAttribute(
            "aria-modal",
            "true"
        );

        overlay.setAttribute(
            "aria-labelledby",
            "new-custom-popup-title"
        );

        /*
         * Box popup.
         */
        var box = document.createElement("div");

        box.id = "new-custom-popup-box";

        /*
         * Tombol X.
         */
        var tombolTutup =
            document.createElement("button");

        tombolTutup.id =
            "new-custom-popup-close";

        tombolTutup.type =
            "button";

        tombolTutup.setAttribute(
            "aria-label",
            "Tutup popup"
        );

        tombolTutup.textContent =
            "×";

        /*
         * Judul popup.
         */
        var judul =
            document.createElement("h2");

        judul.id =
            "new-custom-popup-title";

        judul.textContent =
            NEW_CUSTOM_POPUP_CONTENT.title;

        /*
         * Caption informasi utama.
         */
        var informasi =
            document.createElement("p");

        informasi.innerHTML =
            NEW_CUSTOM_POPUP_CONTENT.informationCaption;

        /*
         * Wrapper link aplikasi.
         */
        var linkAplikasiWrapper =
            document.createElement("p");

        linkAplikasiWrapper.appendChild(
            document.createTextNode(
                NEW_CUSTOM_POPUP_CONTENT.applicationLabel
            )
        );

        /*
         * Link aplikasi.
         */
        var linkAplikasi =
            document.createElement("a");

        linkAplikasi.href =
            NEW_CUSTOM_POPUP_CONTENT.applicationUrl;

        linkAplikasi.target =
            "_blank";

        linkAplikasi.rel =
            "noopener noreferrer";

        linkAplikasi.textContent =
            NEW_CUSTOM_POPUP_CONTENT.applicationLinkText;

        linkAplikasiWrapper.appendChild(
            linkAplikasi
        );

        /*
         * Judul komunitas.
         */
        var judulKomunitas =
            document.createElement("div");

        judulKomunitas.id =
            "new-custom-popup-community-title";

        judulKomunitas.innerHTML =
            NEW_CUSTOM_POPUP_CONTENT.communityTitle;

        /*
         * Caption komunitas.
         */
        var informasiKomunitas =
            document.createElement("p");

        informasiKomunitas.innerHTML =
            NEW_CUSTOM_POPUP_CONTENT.communityCaption;

        /*
         * Wrapper link grup.
         */
        var linkGrupWrapper =
            document.createElement("p");

        linkGrupWrapper.appendChild(
            document.createTextNode(
                NEW_CUSTOM_POPUP_CONTENT.groupLabel
            )
        );

        /*
         * Link grup.
         */
        var linkGrup =
            document.createElement("a");

        linkGrup.href =
            NEW_CUSTOM_POPUP_CONTENT.groupUrl;

        linkGrup.target =
            "_blank";

        linkGrup.rel =
            "noopener noreferrer";

        linkGrup.textContent =
            NEW_CUSTOM_POPUP_CONTENT.groupLinkText;

        linkGrupWrapper.appendChild(
            linkGrup
        );

        /*
         * Tulisan terima kasih.
         */
        var terimaKasih =
            document.createElement("div");

        terimaKasih.id =
            "new-custom-popup-thanks";

        terimaKasih.textContent =
            NEW_CUSTOM_POPUP_CONTENT.footerText;

        /*
         * Tombol OK.
         */
        var tombolOk =
            document.createElement("button");

        tombolOk.id =
            "new-custom-popup-ok";

        tombolOk.type =
            "button";

        tombolOk.textContent =
            NEW_CUSTOM_POPUP_CONTENT.buttonText;

        /*
         * Susun seluruh elemen popup.
         */
        box.appendChild(
            tombolTutup
        );

        box.appendChild(
            judul
        );

        box.appendChild(
            informasi
        );

        box.appendChild(
            linkAplikasiWrapper
        );

        box.appendChild(
            judulKomunitas
        );

        box.appendChild(
            informasiKomunitas
        );

        box.appendChild(
            linkGrupWrapper
        );

        box.appendChild(
            terimaKasih
        );

        box.appendChild(
            tombolOk
        );

        overlay.appendChild(
            box
        );

        root.appendChild(
            style
        );

        root.appendChild(
            overlay
        );

        /*
         * ======================================================
         * KUNCI SCROLL HALAMAN
         * ======================================================
         */

        var scrollBodyLama =
            document.body.style.overflow;

        var scrollHtmlLama =
            document.documentElement.style.overflow;

        document.body.style.setProperty(
            "overflow",
            "hidden",
            "important"
        );

        document.documentElement.style.setProperty(
            "overflow",
            "hidden",
            "important"
        );

        var sedangDitutup =
            false;

        /*
         * ======================================================
         * FUNGSI MENUTUP POPUP
         * ======================================================
         */

        function tutupNewCustomPopupPermanen() {
            if (sedangDitutup) {
                return;
            }

            sedangDitutup =
                true;

            /*
             * Simpan status ke localStorage.
             */
            simpanStatusNewCustomPopup();

            /*
             * Kembalikan scroll halaman.
             */
            document.body.style.overflow =
                scrollBodyLama;

            document.documentElement.style.overflow =
                scrollHtmlLama;

            /*
             * Animasi menghilang.
             */
            host.style.setProperty(
                "opacity",
                "0",
                "important"
            );

            host.style.setProperty(
                "pointer-events",
                "none",
                "important"
            );

            /*
             * Hapus popup.
             */
            setTimeout(function () {
                if (
                    host &&
                    host.parentNode
                ) {
                    host.parentNode.removeChild(
                        host
                    );
                }
            }, 180);
        }

        /*
         * Tombol X menyimpan status dan menutup popup.
         */
        tombolTutup.addEventListener(
            "click",
            tutupNewCustomPopupPermanen
        );

        /*
         * Tombol OK menyimpan status dan menutup popup.
         */
        tombolOk.addEventListener(
            "click",
            tutupNewCustomPopupPermanen
        );

        /*
         * Mencegah event klik box diteruskan.
         */
        box.addEventListener(
            "click",
            function (event) {
                event.stopPropagation();
            }
        );

        /*
         * Klik overlay tidak menutup popup.
         */
        overlay.addEventListener(
            "click",
            function (event) {
                event.preventDefault();
            }
        );

        /*
         * Tombol Escape tidak menutup popup.
         */
        function cegahEscape(event) {
            if (event.key === "Escape") {
                event.preventDefault();

                try {
                    tombolOk.focus();
                } catch (error) {
                    /*
                     * Abaikan jika focus gagal.
                     */
                }
            }
        }

        document.addEventListener(
            "keydown",
            cegahEscape
        );

        /*
         * Fokus otomatis ke tombol OK.
         */
        setTimeout(function () {
            try {
                tombolOk.focus();
            } catch (error) {
                /*
                 * Abaikan jika focus gagal.
                 */
            }
        }, 100);
    }

    /*
     * ==========================================================
     * JALANKAN POPUP SETELAH DOM SIAP
     * ==========================================================
     */

    if (document.readyState === "loading") {
        document.addEventListener(
            "DOMContentLoaded",
            function () {
                tampilkanNewCustomPopup(false);
            },
            {
                once: true
            }
        );
    } else {
        tampilkanNewCustomPopup(false);
    }

    /*
     * ==========================================================
     * FUNGSI GLOBAL
     * ==========================================================
     */

    /*
     * Tampilkan popup secara paksa:
     *
     * tampilkanNewCustomPopup(true);
     */
    window.tampilkanNewCustomPopup =
        tampilkanNewCustomPopup;

    /*
     * Hapus status popup dan refresh halaman:
     *
     * resetNewCustomPopup();
     */
    window.resetNewCustomPopup =
        function () {
            try {
                localStorage.removeItem(
                    NEW_CUSTOM_POPUP_CONTENT.storageKey
                );

                location.reload();

                return true;
            } catch (error) {
                return false;
            }
        };
})();