1var k=new Set([0,24,48,168]);function q(e){return typeof e=="object"&&e!==null&&"status"in e&&e.status==="ok"&&"enabled"in e&&typeof e.enabled=="boolean"&&"newsTabEnabled"in e&&typeof e.newsTabEnabled=="boolean"&&"newsExpiryHours"in e&&typeof e.newsExpiryHours=="number"&&k.has(e.newsExpiryHours)}function _(e=document){const t=e.querySelector("[data-notifications-settings]");if(!t||t.dataset.notificationsReady==="true")return;t.dataset.notificationsReady="true";const o=t.querySelector("[data-notifications-toggle]"),r=t.querySelector("[data-notifications-tab-toggle]"),c=t.querySelector("[data-notifications-expiry]"),y=t.querySelector("[data-notifications-save]"),s=t.querySelector("[data-notifications-settings-status]"),p=t.dataset.endpoint??"",g=t.dataset.csrfToken??"",H=t.dataset.saved??"",m=t.dataset.saveError??"";if(!o||!r||!c||!y||p===""||g==="")return;const i=o,d=r,u=c,w=y,E=h();if(!E)return;let b=E,a=!1;l(),t.addEventListener("change",n=>{a||n.target!==i&&n.target!==d&&n.target!==u||(l(),s&&(s.hidden=!0))}),w.addEventListener("click",()=>{if(a)return;const n=h();if(!n){S(b),l(),T(!1);return}a=!0,l(),s&&(s.hidden=!0),L(p,g,n).then(f=>{const x=f!==null&&R(f,n);x&&f&&(b=f),S(b),a=!1,l(),T(x)})});function h(){const n=Number(u.value);return k.has(n)?{enabled:i.checked,newsTabEnabled:d.checked,newsExpiryHours:n}:null}function S(n){i.checked=n.enabled,d.checked=n.newsTabEnabled,u.value=String(n.newsExpiryHours)}function l(){i.disabled=a,d.disabled=a||!i.checked,u.disabled=a||!i.checked||!d.checked,w.disabled=a}function T(n){s&&(s.textContent=n?H:m,s.hidden=!1,s.classList.toggle("settings__embed-consent-status--error",!n))}}function R(e,t){return e.enabled===t.enabled&&e.newsTabEnabled===t.newsTabEnabled&&e.newsExpiryHours===t.newsExpiryHours}async function L(e,t,o){try{const r=await fetch(e,{method:"POST",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8","X-Requested-With":"XMLHttpRequest"},body:new URLSearchParams({_csrf_token:t,enabled:o.enabled?"1":"0",newsTabEnabled:o.newsTabEnabled?"1":"0",newsExpiryHours:String(o.newsExpiryHours)})});if(!r.ok)return null;const c=await r.json();return q(c)?c:null}catch{return null}}export{_ as initNotificationsSettings};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.