"use strict";!function(){const e=new Set(["kern","user","mail","daemon","auth","syslog","lpr","news","uucp","cron","authpriv","ftp","ntp","security","console","local0","local1","local2","local3","local4","local5","local6","local7","unknown"]),t=new Set(["emerg","alert","crit","err","warn","notice","info","debug"]),n={emerg:"crit",alert:"crit",crit:"crit",err:"err",warn:"warn",notice:"notice",info:"info",debug:"debug"};function o(e){const t=e.match(/^([A-Za-z0-9_.\/-]+(?:\[\d+\])?):\s+([\s\S]*)$/);return t?{tag:t[1],msg:t[2]}:{tag:"",msg:e}}function l(n){let l=n.match(/^\[(.+?)\]\s+(\w+)\.(\w+):\s+([\s\S]*)$/);return l&&e.has(l[2])&&t.has(l[3])?{time:`[${l[1]}]`,fac:l[2],sev:l[3],sevTok:`${l[2]}.${l[3]}:`,...o(l[4])}:(l=n.match(/^(\w{3} \w{3} +\d{1,2} \d{2}:\d{2}:\d{2} \d{4}) (\w+)\.(\w+) ([\s\S]*)$/),l&&e.has(l[2])&&t.has(l[3])?{time:l[1],fac:l[2],sev:l[3],sevTok:`${l[2]}.${l[3]}`,...o(l[4])}:null)}function s(e){const t=e.match(/^(\[\s*\d+\.\d+\])\s?([\s\S]*)$/);return t?{time:t[1],fac:"",sev:"",sevTok:"",tag:"",msg:t[2]}:null}function c(e,t){const n=(e?e.split(/\n/):[]).map(e=>({line:e,parsed:t(e)})),o=n.reduce((e,t)=>e+(t.parsed?1:0),0);return{rows:n,ratio:n.length?o/n.length:1}}if("undefined"!=typeof module&&module.exports&&(module.exports={parseSyslogLine:l,parseDmesgLine:s,splitTag:o,evaluate:c,PARSE_GATE:.8}),"undefined"==typeof document)return;let a=l,r=null,d=null,i=null,u=null;function m(e,t,n){const o=document.createElement("span");return o.className=e,o.textContent=t,n&&(o.title=n),o}function g(e){const t=document.createElement("div");if(!e.parsed)return t.className="log-row",t.textContent=e.line,t;const o=e.parsed;return t.className="log-row"+(o.sev?` lv-${n[o.sev]}`:""),t.appendChild(m("log-time",o.time)),o.sevTok&&(t.appendChild(document.createTextNode(" ")),t.appendChild(m("log-sev",o.sevTok))),o.tag&&(t.appendChild(document.createTextNode(" ")),t.appendChild(m("log-tag",o.tag+":"))),t.appendChild(document.createTextNode(" ")),t.appendChild(m("log-msg",o.msg)),t}function p(e){i&&i.remove(),i=null,e.classList.remove("log-enhanced")}function f(){const e=document.getElementById("syslog"),t=document.getElementById("content_syslog");if(!e||!t)return;const n=e.value;if(n===u)return;if(i&&function(e){const t=window.getSelection&&window.getSelection();return!(!t||t.isCollapsed)&&(e.contains(t.anchorNode)||e.contains(t.focusNode))}(i))return;u=n;const{rows:o,ratio:l}=c(n,a);if(l>=.8){const n=document.getElementById("maincontent"),l=i&&n&&n.scrollTop+n.clientHeight>=n.scrollHeight-40;!function(e,t,n){i||(i=document.createElement("div"),i.className="syslog-view",i.tabIndex=0,i.addEventListener("keydown",function(e){if((e.ctrlKey||e.metaKey)&&"a"===e.key.toLowerCase()){e.preventDefault();const t=window.getSelection();t.removeAllRanges();const n=document.createRange();n.selectNodeContents(i),t.addRange(n)}}),e.insertAdjacentElement("afterend",i),t.classList.add("log-enhanced"));const o=document.createDocumentFragment();for(const e of n)o.appendChild(g(e));i.replaceChildren(o)}(e,t,o),l&&(n.scrollTop=n.scrollHeight)}else p(t)}function h(){if(r)return;const e=document.body?.dataset?.page||"";a=/(^|-)dmesg(-|$)/.test(e)?s:l,u=null,r=setInterval(f,1e3),document.getElementById("syslog")?f():(d=new MutationObserver(function(){document.getElementById("syslog")&&(d.disconnect(),d=null,f())}),d.observe(document.documentElement,{childList:!0,subtree:!0}))}(window.luciPatches??={})["admin-status-logs"]={mount:h,unmount:function(){clearInterval(r),r=null,d?.disconnect(),d=null;const e=document.getElementById("content_syslog");e&&p(e),i=null}},h()}();