(()=>{var e={"./sdk/index.js":function(e,r,s){let n=s("./sdk/ipc.js"),t=s("./sdk/screenEvents.js"),i=s("./sdk/services/appOwnershipService.js");t.initScreenEvents(),n.handle("check-app-ownership",()=>i.checkAppOwnership()),e.exports={IPC:n}},"./sdk/ipc.js":function(e,r,s){let{ipcMain:n}=s("electron");e.exports=new class{subscribe(e,r){let s=(e,...s)=>{let n=e.reply;e.reply=(e,r)=>{try{n(e,r)}catch(t){let s;pm.logger.error("IPC Main: Bad usage of IPC",{channel:e,data:r,err:t});try{s=JSON.parse(JSON.stringify(r)),n(e,s)}catch(r){pm.logger.error("IPC Main: Bad usage of IPC, cannot stringify circular/BigInt referenced object",{channel:e,newData:s,error:r})}}},r(e,...s)};return n.on(e,s),function(){n.removeListener(e,s)}}handle(e,r){n.handle(e,r)}}},"./sdk/screenEvents.js":function(e,r,s){let{BrowserWindow:n,powerMonitor:t}=s("electron"),i=s("os");function o(e){pm.logger.info("Emitting screen event on main process",e),n.getAllWindows().forEach(r=>{r.webContents.send("screen-event",{event:e,os:{platform:i.platform(),release:i.release(),arch:i.arch(),type:i.type()},timestamp:new Date().toISOString()})})}e.exports={initScreenEvents:function(){t.on("lock-screen",()=>o("lock-screen")),t.on("unlock-screen",()=>o("unlock-screen"))}}},"./sdk/services/appOwnershipService.js":function(e,r,s){let{app:n}=s("electron"),t=s("fs"),i=s("path"),{exec:o}=s("child_process"),{promisify:c}=s("util"),p=s("os"),u=c(o);e.exports=new class{async checkAppOwnership(){try{let e,r,s,o=i.resolve(n.getAppPath(),"..","..",".."),c=t.statSync(o),p="win32"===process.platform;if(p)r=await this.isElevatedOnWindows(),e=await this.isCurrentUserOwnerOnWindows(o)||await this.checkWindowsOwnershipWithIcacls(o),s=r,pm.logger.info("App Ownership Service: Windows ownership check",{appPath:o,isCurrentUser:e,isElevated:r,isRoot:s});else{let n="function"==typeof process.geteuid?process.geteuid():null,t="function"==typeof process.getuid?process.getuid():null;s=0===c.uid,e=null!==t?c.uid===t:null,r=null!==n?n!==t:null,pm.logger.info("App Ownership Service: Unix ownership check",{appPath:o,uid:c.uid,gid:c.gid,euid:n,isCurrentUser:e,isElevated:r,isRoot:s})}return{appPath:o,isRoot:s,isCurrentUser:e,isElevated:r,uid:p?null:c.uid,gid:p?null:c.gid,euid:p?null:"function"==typeof process.geteuid?process.geteuid():null}}catch(e){return pm.logger.error("App Ownership Service: Error checking ownership",e),{error:e.message}}}async isElevatedOnWindows(){try{return await u("fsutil dirty query %systemdrive%",{timeout:3e3}),!0}catch(e){return!1}}async isCurrentUserOwnerOnWindows(e){try{let r=p.userInfo().username,s=`dir "${e}" /Q`,{stdout:n}=await u(s,{timeout:3e3});for(let s of n.split("\n"))if(s.includes("<DIR>")&&s.includes(i.basename(e)))return s.toLowerCase().includes(r.toLowerCase());return!1}catch(e){return pm.logger.error("App Ownership Service: Error checking Windows ownership",e),!1}}async checkWindowsOwnershipWithIcacls(e){try{let r=p.userInfo().username,s=`icacls "${e}"`,{stdout:n}=await u(s,{timeout:3e3});return RegExp(`${r}.*\\((F|OI|CI)`,"i").test(n)}catch(e){return pm.logger.error("App Ownership Service: Error checking Windows ownership with icacls",e),!1}}}},child_process:function(e){"use strict";e.exports=require("child_process")},electron:function(e){"use strict";e.exports=require("electron")},fs:function(e){"use strict";e.exports=require("fs")},os:function(e){"use strict";e.exports=require("os")},path:function(e){"use strict";e.exports=require("path")},util:function(e){"use strict";e.exports=require("util")}},r={};function s(n){var t=r[n];if(void 0!==t)return t.exports;var i=r[n]={exports:{}};return e[n](i,i.exports,s),i.exports}s.ab=__dirname+"/node_modules/native_modules/",global.pm=global.pm||{},pm.logger=console,pm.logger.getContext=function(e,r){return{api:e,domain:r}},pm.sdk=s("./sdk/index.js"),module.exports={}})();