document.addEventListener("DOMContentLoaded",(()=>{const t=document.querySelectorAll("[data-state-trigger]"),e=document.querySelectorAll("[data-show-if], [data-hide-if]");if(!t.length&&!e.length)return;const a={};function n(t){const{name:e,value:n}=function(t){const e=t.indexOf(":");return-1===e?{name:t,value:null}:{name:t.substring(0,e),value:t.substring(e+1)}}(t);return null!==n?a[e]===n:!!a[e]}function s(){e.forEach((t=>{const{showIf:e}=t.dataset,{hideIf:a}=t.dataset;e&&t.toggleAttribute("hidden",!n(e)),a&&t.toggleAttribute("hidden",n(a))}))}function r(){t.forEach((t=>{const e=t.dataset.stateTrigger;let n=!1;n="set"===(t.dataset.stateAction||"toggle")?a[e]===(t.dataset.stateValue||""):!!a[e],n?t.setAttribute("data-active",""):t.removeAttribute("data-active")}))}t.forEach((t=>{if(!t.hasAttribute("data-state-default"))return;const e=t.dataset.stateTrigger,n=t.dataset.stateAction||"toggle";a[e]="set"!==n||t.dataset.stateValue||""})),t.forEach((t=>{t.addEventListener("click",(e=>{e.preventDefault();const n=t.dataset.stateTrigger,d=t.dataset.stateAction||"toggle";a[n]="set"===d?t.dataset.stateValue||"":!a[n],r(),s()}))})),r(),s()}));