/* Shared show/hide toggle for the "More Actions" style drawers.
   An anchor carrying data-po-toggle="<panel id>" toggles that panel's
   .show class, swaps its .po-toggle-label between data-closed-label /
   data-open-label, and flips the .pv-more-chevron arrow. Replaces the
   old inline onclick handlers that rebuilt innerHTML. */
(function () {
  document.addEventListener('click', function (e) {
    var t = e.target && e.target.closest ? e.target.closest('[data-po-toggle]') : null;
    if (!t) { return; }
    e.preventDefault();
    var panel = document.getElementById(t.getAttribute('data-po-toggle'));
    if (!panel) { return; }
    var open = panel.classList.toggle('show');
    var label = t.querySelector('.po-toggle-label');
    var openLabel = t.getAttribute('data-open-label');
    var closedLabel = t.getAttribute('data-closed-label');
    if (label && openLabel && closedLabel) {
      label.textContent = open ? openLabel : closedLabel;
    }
    var chev = t.querySelector('.pv-more-chevron');
    if (chev) { chev.innerHTML = open ? '&#9652;' : '&#9662;'; }
  });
})();
