var y=Object.create;var u=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var C=(e,n)=>{for(var s in n)u(e,s,{get:n[s],enumerable:!0})},m=(e,n,s,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of x(n))!S.call(e,i)&&i!==s&&u(e,i,{get:()=>n[i],enumerable:!(r=R(n,i))||r.enumerable});return e};var h=(e,n,s)=>(s=e!=null?y(A(e)):{},m(n||!e||!e.__esModule?u(s,"default",{value:e,enumerable:!0}):s,e)),I=e=>m(u({},"__esModule",{value:!0}),e);var $={};C($,{commonCatches:()=>v,default:()=>k});module.exports=I($);var o=require("electron/main"),g=h(require("@spacingbat3/kolor")),b=require("util"),w=require("path");let E=Promise.resolve();const v={print:e=>{e instanceof Error?console.error(`[ERROR/${e.name}] ${e.message}`):e?.constructor===String?console.error(`[ERROR] ${e}`):console.error(`[ERROR/${e?.constructor?.name||"N/A"}] %s`,e)},throw:e=>{if(e instanceof Error)throw e;if(typeof e=="string")throw new Error(e)}};async function P(e,n,s,r,i,a){o.app.isReady()||await o.app.whenReady();let p=["Abort","Ignore"];new Date().getMonth()===3&&new Date().getDate()===1&&(p=["Abort, abort!","Not today, Satan!"]),e&&console.error(`
`+g.default.red(g.default.bold(n))+g.default.blue(s)+i);let d;try{d=(await import("../../common/modules/client.js")).getBuildInfo().type==="devel"?o.dialog.showMessageBox.bind(o.dialog):o.dialog.showMessageBoxSync.bind(o.dialog)}catch{d=o.dialog.showMessageBoxSync.bind(o.dialog)}const c=await d({title:n,message:a.message+r,type:"error",buttons:p,cancelId:0,defaultId:0});let t;switch(a.name){case"Error":a.errno!==void 0||a.code!==void 0||a.syscall!==void 0||a.path!==void 0?t=99:t=101;break;case"TypeError":t=102;break;case"SyntaxError":t=103;break;case"RangeError":t=104;break;case"EvalError":t=105;break;case"ReferenceError":t=106;break;case"URIError":t=107;break;case"AggregateError":t=108;break;default:t=100}(typeof c=="number"?c:c.response)===0?(process.removeAllListeners("uncaughtException"),console.error(`
Application crashed (Error code: `+t.toString()+(a.errno!==void 0?", ERRNO: "+a.errno.toString():"")+`)
`),o.app.exit(t)):console.warn(["Ignored an unhandled error. This may lead to undesirable consequences.","You do this at your own risk!"].join(`
`))}function k(){process.removeAllListeners("uncaughtException").on("uncaughtException",(e,n)=>{let s=!1;o.app.isReady()&&(s=!0);let r="",i="",a="";const p=`${(n[0]?.toLocaleUpperCase()??"")+n.substring(1)}: ${o.app.getName()} threw '${e.name}'.`;if(e.message!==""&&(i=`

`+e.message),e.stack!==void 0){r=`
`+e.stack.replace(e.name+": "+e.message,""),a=r;const d=r.split(/\r\n|\n|\r/),c=[],t=[],f=o.app.getAppPath()+w.sep;for(let l of d)/^\s*at/.exec(l)&&l.includes(f)?(l=l.replace(f,""),c.push(l),t.push(l)):t.push(g.default.gray(l));e.message!==""?r=`

`+c.join(`
`):r=c.join(`
`),a=t.join(`
`),r.includes("at")||(r=(0,b.stripVTControlCharacters)(a))}E=E.then(()=>P(s,p,i,r,a,e).catch(()=>o.app.exit(200)))})}0&&(module.exports={commonCatches});
