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.hidden=!n(e)),a&&(t.hidden=n(a))}))}function d(){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,r=t.dataset.stateAction||"toggle";a[n]="set"===r?t.dataset.stateValue||"":!a[n],d(),s()}))})),d(),s()}));