(()=>{"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 i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=cockpit;var n=e.n(t);let i,o;function r(e,t){e.wait((function(){e.valid&&t()}))}function s(e,t){const s={exists:null,state:null,enabled:null,wait:function(e){c.promise.then(e)},start:function(){return m("StartUnit",[e,"replace"])},stop:function(){return m("StopUnit",[e,"replace"])},restart:function(){return m("RestartUnit",[e,"replace"])},tryRestart:function(){return m("TryRestartUnit",[e,"replace"])},enable:function(){return y("EnableUnitFiles",[[e],!1,!1])},disable:function(){return y("DisableUnitFiles",[[e],!1])}};let a,d;n().event_target(s);const c=n().defer();function l(){s.exists="not-found"!=a.LoadState||"inactive"!=a.ActiveState,"activating"==a.ActiveState?s.state="starting":"deactivating"==a.ActiveState?s.state="stopping":"active"==a.ActiveState||"reloading"==a.ActiveState?s.state="running":"failed"==a.ActiveState?s.state="failed":"inactive"==a.ActiveState&&s.exists?s.state="stopped":s.state=void 0,"enabled"==a.UnitFileState||"linked"==a.UnitFileState?s.enabled=!0:"disabled"==a.UnitFileState||"masked"==a.UnitFileState?s.enabled=!1:s.enabled=void 0,s.unit=a,s.dispatchEvent("changed"),c.resolve()}function u(){s.details=d,s.service=d,s.dispatchEvent("changed")}var f;function v(){function e(e,t){i.call(e,"org.freedesktop.DBus.Properties","GetAll",[t]).fail((function(e){console.log(e)})).done((function(e){const n={};for(const t in e[0])n[t]=e[0][t].v;const o={};o[t]=n;const r={};r[a.path]=o,i.notify(r)}))}a&&d&&(e(a.path,"org.freedesktop.systemd1.Unit"),e(d.path,"org.freedesktop.systemd1."+t))}function p(t,n,i,o,r){o==e&&v()}-1==e.indexOf(".")&&(e+=".service"),void 0===t&&(t="Service"),f=function(){o.LoadUnit(e).done((function(e){a=i.proxy("org.freedesktop.systemd1.Unit",e),a.addEventListener("changed",l),r(a,l),d=i.proxy("org.freedesktop.systemd1."+t,e),d.addEventListener("changed",u),r(d,u)})).fail((function(){s.exists=!1,s.dispatchEvent("changed")}))},o||(i=n().dbus("org.freedesktop.systemd1",{superuser:"try"}),o=i.proxy("org.freedesktop.systemd1.Manager","/org/freedesktop/systemd1"),r(o,(function(){o.Subscribe().fail((function(e){"org.freedesktop.systemd1.AlreadySubscribed"!=e.name&&"org.freedesktop.DBus.Error.FileExists"!=e.name&&console.warn("Subscribing to systemd signals failed",e)}))}))),r(o,f),o.addEventListener("Reloading",(function(e,t){t||v()})),o.addEventListener("JobNew",p),o.addEventListener("JobRemoved",p);const g={};function b(e,t){return i.call("/org/freedesktop/systemd1","org.freedesktop.systemd1.Manager",e,t)}function m(e,t){const i=n().defer();return b(e,t).done((function(e){const t=e[0];g[t]=i})).fail((function(e){i.reject(e)})),i.promise()}function y(e,t){return b(e,t).then((function(){const e=n().defer();return b("Reload",[]).done((function(){e.resolve()})).fail((function(t){"org.freedesktop.DBus.Error.NoReply"===t.name?(v(),e.resolve()):e.reject(t)})),e.promise()}))}return o.addEventListener("JobRemoved",(function(e,t,n,i,o){g[n]&&("done"==o?g[n].resolve():g[n].reject(o),delete g[n])})),s}document.addEventListener("DOMContentLoaded",(()=>{let e;function t(){function t(){function t(t){document.getElementById(t).textContent=JSON.stringify(e[t])}t("exists"),t("state"),t("enabled")}e=s(n().location.path[0]||""),e.addEventListener("changed",t),t(),document.body.removeAttribute("hidden")}function i(t){document.getElementById(t).addEventListener("click",(()=>{e[t]().catch((e=>console.error("action",t,"failed:",JSON.stringify(e))))}))}i("start"),i("stop"),i("enable"),i("disable"),n().addEventListener("locationchanged",t),t()}))})();