const x8230d9cg = document.querySelector("[data-search]");

window.onbeforeunload = function () {
  window.scrollTo(0, 0);
}

x8230d9cg.addEventListener("input", e => {

  setTimeout(() => {
    bc93bc49r()
  }, 150); 

  setTimeout(() => {
    k30397210()
  }, 450);

});

  window.addEventListener('scroll', function() {

    let sqifn = window.scrollY;
    let sq0j9q98 = -0.05; 

    const sq0qppiq = document.querySelector('.shape1');
    sq0qppiq.style.top = (32 * 16 ) + sqifn * sq0j9q98 + 'px';

    const s0hwq0dqh = document.querySelector('.shape2');
    s0hwq0dqh.style.top = (88 * 16 ) + sqifn * sq0j9q98 + 'px';

    const sqpvmeoz = document.querySelector('.shape3');
    sqpvmeoz.style.top = (140 * 16 ) + sqifn * sq0j9q98 + 'px';

    const s10918j = document.querySelector('.shape4');
    s10918j.style.top = (190 * 16 ) + sqifn * sq0j9q98 + 'px';

    const s190h8q = document.querySelector('.shape5');
    s190h8q.style.top = (240 * 16 ) + sqifn * sq0j9q98 + 'px';

    setTimeout(() => {
    k30397210()
    }, 450);
  });

  function bd837db387g(event) {
    const kf4904f2 = event.target;
    const kf409kg5t = kf4904f2.getAttribute('data-lm-button');
    const kg09kgt = document.getElementById(`lm${kf409kg5t}t`);
    const kg054g95 = document.getElementById(`lm${kf409kg5t}d`);
    const kg50g8 = kf4904f2.closest('.mais-container');
    const kf408gh58 = kg50g8.querySelector('.mais-text');
    const kf498g = kg50g8.querySelector('.mais-arrow');

    if (kg054g95.style.display === "none") {
      kg054g95.style.display = "inline";
      kf408gh58.textContent = "mais";
      kg09kgt.style.display = "none";
      kf498g.classList.remove('active');

    } else {
      kg054g95.style.display = "none";
      kf408gh58.textContent = "menos";
      kg09kgt.style.display = "inline";
      kf498g.classList.add('active');
    }
  }

  document.querySelectorAll('[data-lm-button]').forEach(element => {
    element.addEventListener('click', showId_2);
  });

  document.addEventListener("DOMContentLoaded", function () {
    const kr490585 = document.getElementById("searchbar");
    const k4304343 = document.getElementById("clear-button");

    kr490585.addEventListener("input", () => {
        k4304343.style.display = kr490585.value ? "block" : "none";
    });

    k4304343.addEventListener("click", () => {
        kr490585.value = "";
        k4304343.style.display = "none";

        kr490585.dispatchEvent(new Event("input"));
    });
});

function k3204975() {
  const k34290f = document.querySelector('.searchbar input');
  const k238ry3 = k34290f.offsetWidth;

  const fontSize = k238ry3 / 17.5; 
  k34290f.style.fontSize = `${fontSize}px`;
}

window.addEventListener('resize', k3204975);

k3204975();

let debounceTimer;

document.getElementById('searchbar').addEventListener('input', () => {
  clearTimeout(debounceTimer);
  debounceTimer = setTimeout(k30397210, 500); 
});

function k30397210() {
  const dbn398rg = document.getElementById('searchbar').value.trim().toLowerCase();
  if (!dbn398rg) {
    fbr4ug94b();
    return;
  }

  const f0384y432 = document.querySelectorAll(".title, .artists, .place");
  f0384y432.forEach(element => {

    vnfr040(element);

    const g29891hq = element.textContent.toLowerCase();
    if (g29891hq.includes(dbn398rg)) {
      btr94b40(element, dbn398rg);
    }
  });
}

function fbr4ug94b() {
  const nf30487 = document.querySelectorAll(".title, .artists, .place");
  nf30487.forEach(vnfr040);
}

function btr94b40(element, query) {

  const dfh384 = element.cloneNode(true);

  const k32907 = dfh384.querySelector('.mais-button');
  const k329826 = dfh384.querySelector('.mais-text-hidden');
  const k3203d = dfh384.querySelector('.mais-dots');

  const k323096 = new RegExp(`(${query})`, 'gi');

  function k09747t(node) {
    if (node.nodeType === Node.TEXT_NODE) {
      const k21097r = node.parentNode;
      if (k21097r.nodeName !== 'SPAN' || !k21097r.classList.contains('highlight')) {
        const k13223 = document.createDocumentFragment();
        const k13983r1 = node.textContent.split(k323096);

        k13983r1.forEach(part => {
          if (k323096.test(part)) {
            const d9732g43 = document.createElement('span');
            d9732g43.classList.add('highlight');
            d9732g43.textContent = part;
            k13223.appendChild(d9732g43);
          } else {
            k13223.appendChild(document.createTextNode(part));
          }
        });

        k21097r.replaceChild(k13223, node);
      }
    } else if (node.childNodes && node.childNodes.length > 0) {

      Array.from(node.childNodes).forEach(childNode => {
        if (childNode.nodeName !== 'SPAN' || !childNode.classList.contains('highlight')) {
          k09747t(childNode);
        }
      });
    }
  }

  k09747t(dfh384);

  if (k32907) dfh384.appendChild(k32907);
  if (k329826) dfh384.appendChild(k329826);
  if (k3203d) dfh384.appendChild(k3203d);

  element.innerHTML = dfh384.innerHTML;
}

function vnfr040(element) {

  const m280937 = element.cloneNode(true);

  const w87226 = m280937.querySelector('.mais-button');
  const q28279 = m280937.querySelector('.mais-text-hidden');
  const u50tgvht = m280937.querySelector('.mais-dots');

  m280937.querySelectorAll('.highlight').forEach(highlight => {
    const gf94go = document.createTextNode(highlight.textContent);
    highlight.parentNode.replaceChild(gf94go, highlight);
  });

  if (w87226) m280937.appendChild(w87226);
  if (q28279) m280937.appendChild(q28279);
  if (u50tgvht) m280937.appendChild(u50tgvht);

  element.innerHTML = m280937.innerHTML;
}

document.addEventListener('htmx:afterRequest', function(evt) {
  clearTimeout(debounceTimer);
  debounceTimer = setTimeout(k30397210, 500); 
});

function s25n03(node) {
  let l4092 = [];
  if (node.nodeType === Node.TEXT_NODE) {
    l4092.push(node);
  } else {
    const v398fs = node.childNodes;
    for (let i = 0; i < v398fs.length; i++) {
      l4092.push(...s25n03(v398fs[i]));
    }
  }
  return l4092;
}

function mfn408(element, className) {
  element.classList.toggle(className);
}

function a21098h(dropdownId, arrowId, otherDropdownId, otherArrowId) {
  const djqqaka = document.getElementById(dropdownId);
  const dhqwqoqp = document.getElementById(arrowId);
  const djw0dho = document.getElementById(otherDropdownId);
  const dhwodhw = document.getElementById(otherArrowId);

  if (djw0dho.classList.contains('active')) {
    mfn408(djw0dho, 'active');
    mfn408(dhwodhw, 'active');

    setTimeout(() => {
      mfn408(djqqaka, 'active');
      mfn408(dhqwqoqp, 'active');
    }, 350);
  } else {
    mfn408(djqqaka, 'active');
    mfn408(dhqwqoqp, 'active');
  }
}

function f0wjwe0f(target) {
  if (target.classList.contains('ne-row0')) {
    target.classList.replace('ne-row0', 'ne-row1');
  } else if (target.classList.contains('ne-row1')) {
    target.classList.replace('ne-row1', 'ne-row0');
  } else if (target.classList.contains('en-row0')) {
    target.classList.replace('en-row0', 'en-row1');
  } else if (target.classList.contains('en-row1')) {
    target.classList.replace('en-row1', 'en-row0');
  }
}

document.addEventListener('click', e => {
  const k3209721 = e.target;

  if (k3209721.matches("[data-ne-button]")) {
    a21098h('ne-drop', 'ne-arrowid', 'en-drop', 'en-arrowid');
  } else if (k3209721.matches("[data-en-button]")) {
    a21098h('en-drop', 'en-arrowid', 'ne-drop', 'ne-arrowid');
  }

  if (k3209721.classList.contains('ne-row0') || k3209721.classList.contains('ne-row1') ||
      k3209721.classList.contains('en-row0') || k3209721.classList.contains('en-row1')) {
    setTimeout(() => f0wjwe0f(k3209721), 100);
  }

  if (k3209721.matches("[data-lm-button]")) {
    bd837db387g(event)
  }

  setTimeout(k30397210, 500);
  setTimeout(bc93bc49r, 200);
});

async function bc93bc49r() {
  await v492387(() => document.getElementById('loaded'));
  document.getElementById('loaded').remove();

  const l3d3g = document.getElementById("results");
  const l23387 = document.getElementById("noresults");
  const l3397r = document.getElementById('noexpo');
  l3397r.classList.add("hide");

  setTimeout(() => {
    if (document.getElementById("id_card2")) {
      l3d3g.style.display = "none";
      document.querySelectorAll("#idloadmore").forEach(el => el.setAttribute('hx-trigger', ''));
      document.querySelectorAll("#idloadmoref").forEach(el => el.setAttribute('hx-trigger', 'revealed'));
    } else if (!l23387) {
      l3d3g.style.display = "block";
      document.querySelectorAll("#idloadmore").forEach(el => el.setAttribute('hx-trigger', 'revealed'));
      document.querySelectorAll("#idloadmoref").forEach(el => el.setAttribute('hx-trigger', ''));
    } else if (l23387) {
      l3d3g.style.display = "none";
      l3397r.classList.remove("hide");
      l3397r.classList.add("noexpoCss");
    }
  }, 450);
}

const v492387 = async (condition, pollInterval = 50, timeoutAfter) => {
  const cb94r4r79b = Date.now();
  while (true) {
    if (typeof timeoutAfter === 'number' && Date.now() > cb94r4r79b + timeoutAfter) {
      throw 'Condition not met before timeout';
    }
    const grf34097 = await condition();
    if (grf34097) return grf34097;
    await new Promise(r => setTimeout(r, pollInterval));
  }
};