(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var c in n)e.o(n,c)&&!e.o(t,c)&&Object.defineProperty(t,c,{enumerable:!0,get:n[c]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=cockpit;var n=e.n(t);document.addEventListener("DOMContentLoaded",(()=>{function e(){document.getElementById("nav").innerHTML="";const e=["top"].concat(n().location.path),t=document.getElementById("nav");e.forEach(((c,o)=>{if(o<e.length-1){const r=document.createElement("a");r.setAttribute("tabindex","0"),r.textContent=c,r.addEventListener("click",(()=>n().location.go(e.slice(1,o+1)))),t.append(r," >> ")}else{const e=document.createElement("span");e.textContent=c,t.appendChild(e)}}))}document.getElementById("hammer").addEventListener("click",(e=>e.target.setAttribute("hidden","hidden"))),document.querySelector(".cockpit-internal-reauthorize .pf-c-button").addEventListener("click",(()=>{document.querySelector(".cockpit-internal-reauthorize span").textContent="checking...",n().script("pkcheck --action-id org.freedesktop.policykit.exec --process $$ -u 2>&1",{superuser:"try"}).stream((e=>console.debug(e))).then((()=>{document.querySelector(".cockpit-internal-reauthorize span").textContent="result: authorized"})).catch((()=>{document.querySelector(".cockpit-internal-reauthorize span").textContent="result: access-denied"}))})),document.querySelector(".super-channel .pf-c-button").addEventListener("click",(()=>{document.querySelector(".super-channel span").textContent="checking...",n().spawn(["id"],{superuser:!0}).then((e=>{console.log("done"),document.querySelector(".super-channel span").textContent="result: "+e})).catch((e=>{console.log("fail"),document.querySelector(".super-channel span").textContent="result: "+e.problem}))})),document.querySelector(".lock-channel .pf-c-button").addEventListener("click",(()=>{document.querySelector(".lock-channel span").textContent="locking...",n().spawn(["flock","-o","/tmp/playground-test-lock","-c","echo locked; sleep infinity"],{superuser:"try",err:"message"}).stream((e=>{document.querySelector(".lock-channel span").textContent=e})).catch((e=>{document.querySelector(".lock-channel span").textContent="failed: "+e.toString()}))})),n().addEventListener("locationchanged",e),e(),document.getElementById("go-down").addEventListener("click",(()=>{const e=n().location.path.length;n().location.go(n().location.path.concat(e.toString()),{length:e.toString()})}));const t=n().file("/tmp/counter",{syntax:JSON});function c(e){return(e=e||{}).counter=e.counter||0,e}function o(e){document.getElementById("file-error").textContent=e.toString()}function r(){n().file("/tmp/counter").read().then((e=>{document.getElementById("edit-file").value=e}))}function d(){document.getElementById("hidden").textContent=n().hidden?"hidden":"visible"}t.watch((function(e,t,n){if(n)return o(n);document.getElementById("file-content").textContent=c(e).counter,document.getElementById("file-error").innerHTML=""})),document.getElementById("modify-file").addEventListener("click",(()=>{t.modify((e=>((e=c(e)).counter+=1,e))).catch(o)})),document.getElementById("load-file").addEventListener("click",r),document.getElementById("save-file").addEventListener("click",(function(){n().file("/tmp/counter").replace(document.getElementById("edit-file").value)})),r(),document.getElementById("delete-file").addEventListener("click",(()=>n().spawn(["rm","-f","/tmp/counter"]))),document.body.removeAttribute("hidden"),n().addEventListener("visibilitychange",d),d()}))})();