@overlayed/app 1.3.7 → 1.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -400,18 +400,18 @@ declare function module(): {
400
400
  readonly events: _$arktype.Module<{
401
401
  event: {
402
402
  game: "siege" | "tft";
403
- type: "logged_in";
403
+ type: "module_loaded";
404
404
  creation_time: number;
405
405
  content: {
406
- account_id: string;
406
+ game_version: string;
407
+ process_hash: string;
407
408
  };
408
409
  } | {
409
410
  game: "siege" | "tft";
410
- type: "module_loaded";
411
+ type: "logged_in";
411
412
  creation_time: number;
412
413
  content: {
413
- game_version: string;
414
- process_hash: string;
414
+ account_id: string;
415
415
  };
416
416
  } | {
417
417
  game: "siege" | "tft";
package/dist/index.mjs CHANGED
@@ -6,6 +6,6 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
6
6
  `;break;default:e+=String.fromCharCode(n)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else ++this.pos}},V.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case`\\`:++this.pos;break;case`$`:if(this.input[this.pos+1]!==`{`)break;case"`":return this.finishToken(b.invalidTemplate,this.input.slice(this.start,this.pos));case`\r`:this.input[this.pos+1]===`
7
7
  `&&++this.pos;case`
8
8
  `:case`\u2028`:case`\u2029`:++this.curLine,this.lineStart=this.pos+1}this.raise(this.start,`Unterminated template`)},V.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
9
- `;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return le(this.readCodePoint());case 116:return` `;case 98:return`\b`;case 118:return`\v`;case 102:return`\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),r===`0`&&t!==56&&t!==57||!this.strict&&!e||this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return ne(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},V.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},V.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(m(i,r))this.pos+=i<=65535?1:2;else{if(i!==92)break;this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\uXXXX`),++this.pos;var o=this.readCodePoint();(t?p:m)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=le(o),n=this.pos}t=!1}return e+this.input.slice(n,this.pos)},V.readWord=function(){var e=this.readWord1(),t=b.name;return this.keywords.test(e)&&(t=ee[e]),this.finishToken(t,e)},k.acorn={Parser:k,version:`8.15.0`,defaultOptions:me,Position:de,SourceLocation:fe,getLineInfo:pe,Node:Pe,TokenType:h,tokTypes:b,keywordTypes:ee,TokContext:P,tokContexts:F,isIdentifierChar:m,isIdentifierStart:p,Token:st,isNewLine:ne,lineBreak:x,lineBreakG:te,nonASCIIwhitespace:ie};let ut=E(`node:module`),H=E(`node:fs`);String.fromCharCode;let dt=/\/$|\/\?|\/#/,ft=/^\.?\//;function pt(e=``,t){return t?dt.test(e):e.endsWith(`/`)}function mt(e=``,t){if(!t)return e.endsWith(`/`)?e:e+`/`;if(pt(e,!0))return e||`/`;let n=e,r=``,i=e.indexOf(`#`);if(i!==-1&&(n=e.slice(0,i),r=e.slice(i),!n))return r;let[a,...o]=n.split(`?`);return a+`/`+(o.length>0?`?${o.join(`?`)}`:``)+r}function ht(e){return e&&e!==`/`}function gt(e,...t){let n=e||``;for(let e of t.filter(e=>ht(e)))if(n){let t=e.replace(ft,``);n=mt(n)+t}else n=e;return n}let _t=/^[A-Za-z]:\//;function vt(e=``){return e&&e.replace(/\\/g,`/`).replace(_t,e=>e.toUpperCase())}let yt=/^[/\\]{2}/,bt=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,xt=/^[A-Za-z]:$/,St=/.(\.[^./]+|\.)$/,Ct=function(e){if(e.length===0)return`.`;let t=(e=vt(e)).match(yt),n=U(e),r=e[e.length-1]===`/`;return(e=Dt(e,!n)).length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),xt.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!U(e)?`/${e}`:e)},wt=function(...e){let t=``;for(let n of e)if(n)if(t.length>0){let e=t[t.length-1]===`/`,r=n[0]===`/`;t+=e&&r?n.slice(1):e||r?n:`/${n}`}else t+=n;return Ct(t)};function Tt(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}let Et=function(...e){let t=``,n=!1;for(let r=(e=e.map(e=>vt(e))).length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:Tt();i&&i.length!==0&&(t=`${i}/${t}`,n=U(i))}return t=Dt(t,!n),n&&!U(t)?`/${t}`:t.length>0?t:`.`};function Dt(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else{if(o===`/`)break;o=`/`}if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}let U=function(e){return bt.test(e)},Ot=function(e){if(e===`..`)return``;let t=St.exec(vt(e));return t&&t[1]||``},kt=function(e){let t=vt(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&xt.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(U(e)?`/`:`.`)},At=function(e,t){let n=vt(e).split(`/`),r=``;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){r=t;break}}return t&&r.endsWith(t)?r.slice(0,-t.length):r},W=E(`node:url`),G=E(`node:assert`),K=E(`node:process`),jt=E(`node:path`),Mt=E(`node:v8`),Nt=E(`node:util`),Pt=new Set(ut.builtinModules);function Ft(e){return e.replace(/\\/g,`/`)}let It={}.hasOwnProperty,q=/^([A-Z][a-z\d]*)+$/,Lt=new Set([`string`,`function`,`number`,`object`,`Function`,`Object`,`boolean`,`bigint`,`symbol`]),J={};function Rt(e,t=`and`){return e.length<3?e.join(` ${t} `):`${e.slice(0,-1).join(`, `)}, ${t} ${e[e.length-1]}`}let zt=new Map,Bt;function Y(e,t,n){return zt.set(e,t),function(e,t){return n;function n(...n){let r=Error.stackTraceLimit;Vt()&&(Error.stackTraceLimit=0);let i=new e;Vt()&&(Error.stackTraceLimit=r);let a=function(e,t,n){let r=zt.get(e);if(G(r!==void 0,"expected `message` to be found"),typeof r==`function`)return G(r.length<=t.length,`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${r.length}).`),Reflect.apply(r,n,t);let i=/%[dfijoOs]/g,a=0;for(;i.exec(r)!==null;)a++;return G(a===t.length,`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${a}).`),t.length===0?r:(t.unshift(r),Reflect.apply(Nt.format,null,t))}(t,n,i);return Object.defineProperties(i,{message:{value:a,enumerable:!1,writable:!0,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},enumerable:!1,writable:!0,configurable:!0}}),Ht(i),i.code=t,i}}(n,e)}function Vt(){try{if(Mt.startupSnapshot.isBuildingSnapshot())return!1}catch{}let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):It.call(e,`writable`)&&e.writable!==void 0?e.writable:e.set!==void 0}J.ERR_INVALID_ARG_TYPE=Y(`ERR_INVALID_ARG_TYPE`,(e,t,n)=>{G(typeof e==`string`,`'name' must be a string`),Array.isArray(t)||(t=[t]);let r=`The `;if(e.endsWith(` argument`))r+=`${e} `;else{let t=e.includes(`.`)?`property`:`argument`;r+=`"${e}" ${t} `}r+=`must be `;let i=[],a=[],o=[];for(let e of t)G(typeof e==`string`,`All expected entries have to be of type string`),Lt.has(e)?i.push(e.toLowerCase()):q.exec(e)===null?(G(e!==`object`,`The value "object" should be written as "Object"`),o.push(e)):a.push(e);if(a.length>0){let e=i.indexOf(`object`);e!==-1&&(i.slice(e,1),a.push(`Object`))}return i.length>0&&(r+=`${i.length>1?`one of type`:`of type`} ${Rt(i,`or`)}`,(a.length>0||o.length>0)&&(r+=` or `)),a.length>0&&(r+=`an instance of ${Rt(a,`or`)}`,o.length>0&&(r+=` or `)),o.length>0&&(o.length>1?r+=`one of ${Rt(o,`or`)}`:(o[0].toLowerCase()!==o[0]&&(r+=`an `),r+=`${o[0]}`)),r+=`. Received ${function(e){if(e==null)return String(e);if(typeof e==`function`&&e.name)return`function ${e.name}`;if(typeof e==`object`)return e.constructor&&e.constructor.name?`an instance of ${e.constructor.name}`:`${(0,Nt.inspect)(e,{depth:-1})}`;let t=(0,Nt.inspect)(e,{colors:!1});return t.length>28&&(t=`${t.slice(0,25)}...`),`type ${typeof e} (${t})`}(n)}`,r},TypeError),J.ERR_INVALID_MODULE_SPECIFIER=Y(`ERR_INVALID_MODULE_SPECIFIER`,(e,t,n=void 0)=>`Invalid module "${e}" ${t}${n?` imported from ${n}`:``}`,TypeError),J.ERR_INVALID_PACKAGE_CONFIG=Y(`ERR_INVALID_PACKAGE_CONFIG`,(e,t,n)=>`Invalid package config ${e}${t?` while importing ${t}`:``}${n?`. ${n}`:``}`,Error),J.ERR_INVALID_PACKAGE_TARGET=Y(`ERR_INVALID_PACKAGE_TARGET`,(e,t,n,r=!1,i=void 0)=>{let a=typeof n==`string`&&!r&&n.length>0&&!n.startsWith(`./`);return t===`.`?(G(!1===r),`Invalid "exports" main target ${JSON.stringify(n)} defined in the package config ${e}package.json${i?` imported from ${i}`:``}${a?`; targets must start with "./"`:``}`):`Invalid "${r?`imports`:`exports`}" target ${JSON.stringify(n)} defined for '${t}' in the package config ${e}package.json${i?` imported from ${i}`:``}${a?`; targets must start with "./"`:``}`},Error),J.ERR_MODULE_NOT_FOUND=Y(`ERR_MODULE_NOT_FOUND`,(e,t,n=!1)=>`Cannot find ${n?`module`:`package`} '${e}' imported from ${t}`,Error),J.ERR_NETWORK_IMPORT_DISALLOWED=Y(`ERR_NETWORK_IMPORT_DISALLOWED`,`import of '%s' by %s is not supported: %s`,Error),J.ERR_PACKAGE_IMPORT_NOT_DEFINED=Y(`ERR_PACKAGE_IMPORT_NOT_DEFINED`,(e,t,n)=>`Package import specifier "${e}" is not defined${t?` in package ${t}package.json`:``} imported from ${n}`,TypeError),J.ERR_PACKAGE_PATH_NOT_EXPORTED=Y(`ERR_PACKAGE_PATH_NOT_EXPORTED`,(e,t,n=void 0)=>t===`.`?`No "exports" main defined in ${e}package.json${n?` imported from ${n}`:``}`:`Package subpath '${t}' is not defined by "exports" in ${e}package.json${n?` imported from ${n}`:``}`,Error),J.ERR_UNSUPPORTED_DIR_IMPORT=Y(`ERR_UNSUPPORTED_DIR_IMPORT`,`Directory import '%s' is not supported resolving ES modules imported from %s`,Error),J.ERR_UNSUPPORTED_RESOLVE_REQUEST=Y(`ERR_UNSUPPORTED_RESOLVE_REQUEST`,`Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.`,TypeError),J.ERR_UNKNOWN_FILE_EXTENSION=Y(`ERR_UNKNOWN_FILE_EXTENSION`,(e,t)=>`Unknown file extension "${e}" for ${t}`,TypeError),J.ERR_INVALID_ARG_VALUE=Y(`ERR_INVALID_ARG_VALUE`,(e,t,n=`is invalid`)=>{let r=(0,Nt.inspect)(t);return r.length>128&&(r=`${r.slice(0,128)}...`),`The ${e.includes(`.`)?`property`:`argument`} '${e}' ${n}. Received ${r}`},TypeError);let Ht=function(e){let t=`__node_internal_`+e.name;return Object.defineProperty(e,`name`,{value:t}),e}(function(e){let t=Vt();return t&&(Bt=Error.stackTraceLimit,Error.stackTraceLimit=1/0),Error.captureStackTrace(e),t&&(Error.stackTraceLimit=Bt),e}),Ut={}.hasOwnProperty,{ERR_INVALID_PACKAGE_CONFIG:Wt}=J,Gt=new Map;function Kt(e,{base:t,specifier:n}){let r=Gt.get(e);if(r)return r;let i;try{i=H.readFileSync(jt.toNamespacedPath(e),`utf8`)}catch(e){let t=e;if(t.code!==`ENOENT`)throw t}let a={exists:!1,pjsonPath:e,main:void 0,name:void 0,type:`none`,exports:void 0,imports:void 0};if(i!==void 0){let r;try{r=JSON.parse(i)}catch(r){let i=r,a=new Wt(e,(t?`"${n}" from `:``)+(0,W.fileURLToPath)(t||n),i.message);throw a.cause=i,a}a.exists=!0,Ut.call(r,`name`)&&typeof r.name==`string`&&(a.name=r.name),Ut.call(r,`main`)&&typeof r.main==`string`&&(a.main=r.main),Ut.call(r,`exports`)&&(a.exports=r.exports),Ut.call(r,`imports`)&&(a.imports=r.imports),!Ut.call(r,`type`)||r.type!==`commonjs`&&r.type!==`module`||(a.type=r.type)}return Gt.set(e,a),a}function qt(e){let t=new URL(`package.json`,e);for(;!t.pathname.endsWith(`node_modules/package.json`);){let n=Kt((0,W.fileURLToPath)(t),{specifier:e});if(n.exists)return n;let r=t;if(t=new URL(`../package.json`,t),t.pathname===r.pathname)break}return{pjsonPath:(0,W.fileURLToPath)(t),exists:!1,type:`none`}}function Jt(e){return qt(e).type}let{ERR_UNKNOWN_FILE_EXTENSION:Yt}=J,Xt={}.hasOwnProperty,Zt={__proto__:null,".cjs":`commonjs`,".js":`module`,".json":`json`,".mjs":`module`},Qt={__proto__:null,"data:":function(e){let{1:t}=/^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(e.pathname)||[null,null,null];return function(e){return e&&/\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(e)?`module`:e===`application/json`?`json`:null}(t)},"file:":function(e,t,n){let r=function(e){let t=e.pathname,n=t.length;for(;n--;){let e=t.codePointAt(n);if(e===47)return``;if(e===46)return t.codePointAt(n-1)===47?``:t.slice(n)}return``}(e);if(r===`.js`){let t=Jt(e);return t===`none`?`commonjs`:t}if(r===``){let t=Jt(e);return t===`none`||t===`commonjs`?`commonjs`:`module`}let i=Zt[r];if(i)return i;if(!n)throw new Yt(r,(0,W.fileURLToPath)(e))},"http:":$t,"https:":$t,"node:":()=>`builtin`};function $t(){}let X=RegExp.prototype[Symbol.replace],{ERR_INVALID_MODULE_SPECIFIER:en,ERR_INVALID_PACKAGE_CONFIG:tn,ERR_INVALID_PACKAGE_TARGET:nn,ERR_MODULE_NOT_FOUND:rn,ERR_PACKAGE_IMPORT_NOT_DEFINED:an,ERR_PACKAGE_PATH_NOT_EXPORTED:on,ERR_UNSUPPORTED_DIR_IMPORT:sn,ERR_UNSUPPORTED_RESOLVE_REQUEST:cn}=J,ln={}.hasOwnProperty,un=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i,dn=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i,fn=/^\.|%|\\/,pn=/\*/g,mn=/%2f|%5c/i,hn=new Set,gn=/[/\\]{2}/;function _n(e,t,n,r,i,a,o){if(K.noDeprecation)return;let s=(0,W.fileURLToPath)(r),c=gn.exec(o?e:t)!==null;K.emitWarning(`Use of deprecated ${c?`double slash`:`leading or trailing slash matching`} resolving "${e}" for module request "${t}" ${t===n?``:`matched to "${n}" `}in the "${i?`imports`:`exports`}" field module resolution of the package at ${s}${a?` imported from ${(0,W.fileURLToPath)(a)}`:``}.`,`DeprecationWarning`,`DEP0166`)}function vn(e,t,n,r){if(K.noDeprecation||function(e,t){let n=e.protocol;return Xt.call(Qt,n)&&Qt[n](e,t,!0)||null}(e,{parentURL:n.href})!==`module`)return;let i=(0,W.fileURLToPath)(e.href),a=(0,W.fileURLToPath)(new W.URL(`.`,t)),o=(0,W.fileURLToPath)(n);r?jt.resolve(a,r)!==i&&K.emitWarning(`Package ${a} has a "main" field set to "${r}", excluding the full filename and extension to the resolved file at "${i.slice(a.length)}", imported from ${o}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`,`DeprecationWarning`,`DEP0151`):K.emitWarning(`No "main" or "exports" field defined in the package.json for ${a} resolving the main entry point "${i.slice(a.length)}", imported from ${o}.\nDefault "index" lookups for the main are deprecated for ES modules.`,`DeprecationWarning`,`DEP0151`)}function yn(e){try{return(0,H.statSync)(e)}catch{}}function bn(e){let t=(0,H.statSync)(e,{throwIfNoEntry:!1}),n=t?t.isFile():void 0;return n!=null&&n}function xn(e,t,n){let r;if(t.main!==void 0){if(r=new W.URL(t.main,e),bn(r))return r;let i=[`./${t.main}.js`,`./${t.main}.json`,`./${t.main}.node`,`./${t.main}/index.js`,`./${t.main}/index.json`,`./${t.main}/index.node`],a=-1;for(;++a<i.length&&(r=new W.URL(i[a],e),!bn(r));)r=void 0;if(r)return vn(r,e,n,t.main),r}let i=[`./index.js`,`./index.json`,`./index.node`],a=-1;for(;++a<i.length&&(r=new W.URL(i[a],e),!bn(r));)r=void 0;if(r)return vn(r,e,n,t.main),r;throw new rn((0,W.fileURLToPath)(new W.URL(`.`,e)),(0,W.fileURLToPath)(n))}function Sn(e,t,n){return new on((0,W.fileURLToPath)(new W.URL(`.`,t)),e,n&&(0,W.fileURLToPath)(n))}function Cn(e,t,n,r,i){return t=typeof t==`object`&&t?JSON.stringify(t,null,``):`${t}`,new nn((0,W.fileURLToPath)(new W.URL(`.`,n)),e,t,r,i&&(0,W.fileURLToPath)(i))}function wn(e,t,n,r,i,a,o,s,c){if(t!==``&&!a&&e[e.length-1]!==`/`)throw Cn(n,e,r,o,i);if(!e.startsWith(`./`)){if(o&&!e.startsWith(`../`)&&!e.startsWith(`/`)){let n=!1;try{new W.URL(e),n=!0}catch{}if(!n)return An(a?X.call(pn,e,()=>t):e+t,r,c)}throw Cn(n,e,r,o,i)}if(un.exec(e.slice(2))!==null){if(dn.exec(e.slice(2))!==null)throw Cn(n,e,r,o,i);if(!s){let s=a?n.replace(`*`,()=>t):n+t;_n(a?X.call(pn,e,()=>t):e,s,n,r,o,i,!0)}}let l=new W.URL(e,r),u=l.pathname,d=new W.URL(`.`,r).pathname;if(!u.startsWith(d))throw Cn(n,e,r,o,i);if(t===``)return l;if(un.exec(t)!==null){let c=a?n.replace(`*`,()=>t):n+t;dn.exec(t)===null?s||_n(a?X.call(pn,e,()=>t):e,c,n,r,o,i,!1):(function(e,t,n,r,i){throw new en(e,`request is not a valid match in pattern "${t}" for the "${r?`imports`:`exports`}" resolution of ${(0,W.fileURLToPath)(n)}`,i&&(0,W.fileURLToPath)(i))})(c,n,r,o,i)}return a?new W.URL(X.call(pn,l.href,()=>t)):new W.URL(t,l)}function Tn(e){let t=Number(e);return`${t}`===e&&t>=0&&t<4294967295}function En(e,t,n,r,i,a,o,s,c){if(typeof t==`string`)return wn(t,n,r,e,i,a,o,s,c);if(Array.isArray(t)){let l=t;if(l.length===0)return null;let u,d=-1;for(;++d<l.length;){let t=l[d],f;try{f=En(e,t,n,r,i,a,o,s,c)}catch(e){if(u=e,e.code===`ERR_INVALID_PACKAGE_TARGET`)continue;throw e}if(f!==void 0){if(f!==null)return f;u=null}}if(u==null)return null;throw u}if(typeof t==`object`&&t){let l=Object.getOwnPropertyNames(t),u=-1;for(;++u<l.length;)if(Tn(l[u]))throw new tn((0,W.fileURLToPath)(e),i,`"exports" cannot contain numeric property keys.`);for(u=-1;++u<l.length;){let d=l[u];if(d===`default`||c&&c.has(d)){let l=En(e,t[d],n,r,i,a,o,s,c);if(l===void 0)continue;return l}}return null}if(t===null)return null;throw Cn(r,t,e,o,i)}function Dn(e,t,n){if(K.noDeprecation)return;let r=(0,W.fileURLToPath)(t);hn.has(r+`|`+e)||(hn.add(r+`|`+e),K.emitWarning(`Use of deprecated trailing slash pattern mapping "${e}" in the "exports" field module resolution of the package at ${r}${n?` imported from ${(0,W.fileURLToPath)(n)}`:``}. Mapping specifiers ending in "/" is no longer supported.`,`DeprecationWarning`,`DEP0155`))}function Z(e,t,n,r,i){let a=n.exports;if(function(e,t,n){if(typeof e==`string`||Array.isArray(e))return!0;if(typeof e!=`object`||!e)return!1;let r=Object.getOwnPropertyNames(e),i=!1,a=0,o=-1;for(;++o<r.length;){let e=r[o],s=e===``||e[0]!==`.`;if(a++===0)i=s;else if(i!==s)throw new tn((0,W.fileURLToPath)(t),n,`"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`)}return i}(a,e,r)&&(a={".":a}),ln.call(a,t)&&!t.includes(`*`)&&!t.endsWith(`/`)){let n=En(e,a[t],``,t,r,!1,!1,!1,i);if(n==null)throw Sn(t,e,r);return n}let o=``,s=``,c=Object.getOwnPropertyNames(a),l=-1;for(;++l<c.length;){let n=c[l],i=n.indexOf(`*`);if(i!==-1&&t.startsWith(n.slice(0,i))){t.endsWith(`/`)&&Dn(t,e,r);let a=n.slice(i+1);t.length>=n.length&&t.endsWith(a)&&On(o,n)===1&&n.lastIndexOf(`*`)===i&&(o=n,s=t.slice(i,t.length-a.length))}}if(o){let n=En(e,a[o],s,o,r,!0,!1,t.endsWith(`/`),i);if(n==null)throw Sn(t,e,r);return n}throw Sn(t,e,r)}function On(e,t){let n=e.indexOf(`*`),r=t.indexOf(`*`),i=n===-1?e.length:n+1,a=r===-1?t.length:r+1;return i>a?-1:a>i||n===-1?1:r===-1||e.length>t.length?-1:+(t.length>e.length)}function kn(e,t,n){if(e===`#`||e.startsWith(`#/`)||e.endsWith(`/`))throw new en(e,`is not a valid internal imports specifier name`,(0,W.fileURLToPath)(t));let r,i=qt(t);if(i.exists){r=(0,W.pathToFileURL)(i.pjsonPath);let a=i.imports;if(a)if(ln.call(a,e)&&!e.includes(`*`)){let i=En(r,a[e],``,e,t,!1,!0,!1,n);if(i!=null)return i}else{let i=``,o=``,s=Object.getOwnPropertyNames(a),c=-1;for(;++c<s.length;){let t=s[c],n=t.indexOf(`*`);if(n!==-1&&e.startsWith(t.slice(0,-1))){let r=t.slice(n+1);e.length>=t.length&&e.endsWith(r)&&On(i,t)===1&&t.lastIndexOf(`*`)===n&&(i=t,o=e.slice(n,e.length-r.length))}}if(i){let e=En(r,a[i],o,i,t,!0,!0,!1,n);if(e!=null)return e}}}throw function(e,t,n){return new an(e,t&&(0,W.fileURLToPath)(new W.URL(`.`,t)),(0,W.fileURLToPath)(n))}(e,r,t)}function An(e,t,n){if(ut.builtinModules.includes(e))return new W.URL(`node:`+e);let{packageName:r,packageSubpath:i,isScoped:a}=function(e,t){let n=e.indexOf(`/`),r=!0,i=!1;e[0]===`@`&&(i=!0,n===-1||e.length===0?r=!1:n=e.indexOf(`/`,n+1));let a=n===-1?e:e.slice(0,n);if(fn.exec(a)!==null&&(r=!1),!r)throw new en(e,`is not a valid package name`,(0,W.fileURLToPath)(t));return{packageName:a,packageSubpath:`.`+(n===-1?``:e.slice(n)),isScoped:i}}(e,t),o=qt(t);if(o.exists){let e=(0,W.pathToFileURL)(o.pjsonPath);if(o.name===r&&o.exports!==void 0&&o.exports!==null)return Z(e,i,o,t,n)}let s,c=new W.URL(`./node_modules/`+r+`/package.json`,t),l=(0,W.fileURLToPath)(c);do{let o=yn(l.slice(0,-13));if(!o||!o.isDirectory()){s=l,c=new W.URL((a?`../../../../node_modules/`:`../../../node_modules/`)+r+`/package.json`,c),l=(0,W.fileURLToPath)(c);continue}let u=Kt(l,{base:t,specifier:e});return u.exports!==void 0&&u.exports!==null?Z(c,i,u,t,n):i===`.`?xn(c,u,t):new W.URL(i,c)}while(l.length!==s.length);throw new rn(r,(0,W.fileURLToPath)(t),!1)}function jn(e,t,n,r){let i=t.protocol,a=i===`data:`||i===`http:`||i===`https:`,o;if(function(e){return e!==``&&(e[0]===`/`||function(e){return e[0]===`.`&&(e.length===1||e[1]===`/`||e[1]===`.`&&(e.length===2||e[2]===`/`))}(e))}(e))try{o=new W.URL(e,t)}catch(n){let r=new cn(e,t);throw r.cause=n,r}else if(i===`file:`&&e[0]===`#`)o=kn(e,t,n);else try{o=new W.URL(e)}catch(r){if(a&&!ut.builtinModules.includes(e)){let n=new cn(e,t);throw n.cause=r,n}o=An(e,t,n)}return G(o!==void 0,`expected to be defined`),o.protocol===`file:`?function(e,t){if(mn.exec(e.pathname)!==null)throw new en(e.pathname,`must not include encoded "/" or "\\" characters`,(0,W.fileURLToPath)(t));let n;try{n=(0,W.fileURLToPath)(e)}catch(n){let r=n;throw Object.defineProperty(r,`input`,{value:String(e)}),Object.defineProperty(r,`module`,{value:String(t)}),r}let r=yn(n.endsWith(`/`)?n.slice(-1):n);if(r&&r.isDirectory()){let r=new sn(n,(0,W.fileURLToPath)(t));throw r.url=String(e),r}if(!r||!r.isFile()){let r=new rn(n||e.pathname,t&&(0,W.fileURLToPath)(t),!0);throw r.url=String(e),r}{let t=(0,H.realpathSync)(n),{search:r,hash:i}=e;(e=(0,W.pathToFileURL)(t+(n.endsWith(jt.sep)?`/`:``))).search=r,e.hash=i}return e}(o,t):o}function Mn(e){return typeof e!=`string`||e.startsWith(`file://`)?Ft((0,W.fileURLToPath)(e)):Ft(e)}function Nn(e){return(0,W.pathToFileURL)(Mn(e)).toString()}let Pn=new Set([`node`,`import`]),Fn=[`.mjs`,`.cjs`,`.js`,`.json`],In=new Set([`ERR_MODULE_NOT_FOUND`,`ERR_UNSUPPORTED_DIR_IMPORT`,`MODULE_NOT_FOUND`,`ERR_PACKAGE_PATH_NOT_EXPORTED`]);function Ln(e,t,n){try{return jn(e,t,n)}catch(e){if(!In.has(e?.code))throw e}}function Rn(e,t={}){if(typeof e!=`string`){if(!(e instanceof URL))throw TypeError("input must be a `string` or `URL`");e=Mn(e)}if(/(?:node|data|http|https):/.test(e))return e;if(Pt.has(e))return`node:`+e;if(e.startsWith(`file://`)&&(e=Mn(e)),U(e))try{if((0,H.statSync)(e).isFile())return Nn(e)}catch(e){if(e?.code!==`ENOENT`)throw e}let n=t.conditions?new Set(t.conditions):Pn,r=(Array.isArray(t.url)?t.url:[t.url]).filter(Boolean).map(e=>new URL(function(e){return typeof e!=`string`&&(e=e.toString()),/(?:node|data|http|https|file):/.test(e)?e:Pt.has(e)?`node:`+e:`file://`+encodeURI(Ft(e))}(e.toString())));r.length===0&&r.push(new URL(Nn(process.cwd())));let i=[...r];for(let e of r)e.protocol===`file:`&&i.push(new URL(`./`,e),new URL(gt(e.pathname,`_index.js`),e),new URL(`node_modules`,e));let a;for(let r of i){if(a=Ln(e,r,n),a)break;for(let i of[``,`/index`]){for(let o of t.extensions||Fn)if(a=Ln(gt(e,i)+o,r,n),a)break;if(a)break}if(a)break}if(!a){let t=Error(`Cannot find module ${e} imported from ${i.join(`, `)}`);throw t.code=`ERR_MODULE_NOT_FOUND`,t}return Nn(a)}function zn(e,t){return Rn(e,t)}function Bn(e,t){return Mn(zn(e,t))}let Vn=/(?:[\s;]|^)(?:import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m,Hn=/\/\*.+?\*\/|\/\/.*(?=[nr])/g;function Un(e,t={}){return t.stripComments&&(e=e.replace(Hn,``)),Vn.test(e)}function Wn(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}let Gn=new Set([`/`,`\\`,void 0]),Kn=Symbol.for(`pathe:normalizedAlias`),qn=/[/\\]/;function Jn(e){if(e[Kn])return e;let t=Object.fromEntries(Object.entries(e).sort(([e],[t])=>function(e,t){return t.split(`/`).length-e.split(`/`).length}(e,t)));for(let e in t)for(let n in t)n===e||e.startsWith(n)||t[e]?.startsWith(n)&&Gn.has(t[e][n.length])&&(t[e]=t[n]+t[e].slice(n.length));return Object.defineProperty(t,Kn,{value:!0,enumerable:!1}),t}function Yn(e=`/`){let t=e[e.length-1];return t===`/`||t===`\\`}var Xn={rE:`2.6.1`};let Zn=E(`node:crypto`);var Qn=r.n(Zn);let $n=Object.create(null),er=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?$n:globalThis),tr=new Proxy($n,{get:(e,t)=>er()[t]??$n[t],has:(e,t)=>t in er()||t in $n,set:(e,t,n)=>(er(!0)[t]=n,!0),deleteProperty(e,t){return t?(delete er(!0)[t],!0):!1},ownKeys(){let e=er(!0);return Object.keys(e)}}),nr=typeof process<`u`&&process.env&&process.env.NODE_ENV||``,rr=[[`APPVEYOR`],[`AWS_AMPLIFY`,`AWS_APP_ID`,{ci:!0}],[`AZURE_PIPELINES`,`SYSTEM_TEAMFOUNDATIONCOLLECTIONURI`],[`AZURE_STATIC`,`INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN`],[`APPCIRCLE`,`AC_APPCIRCLE`],[`BAMBOO`,`bamboo_planKey`],[`BITBUCKET`,`BITBUCKET_COMMIT`],[`BITRISE`,`BITRISE_IO`],[`BUDDY`,`BUDDY_WORKSPACE_ID`],[`BUILDKITE`],[`CIRCLE`,`CIRCLECI`],[`CIRRUS`,`CIRRUS_CI`],[`CLOUDFLARE_PAGES`,`CF_PAGES`,{ci:!0}],[`CLOUDFLARE_WORKERS`,`WORKERS_CI`,{ci:!0}],[`CODEBUILD`,`CODEBUILD_BUILD_ARN`],[`CODEFRESH`,`CF_BUILD_ID`],[`DRONE`],[`DRONE`,`DRONE_BUILD_EVENT`],[`DSARI`],[`GITHUB_ACTIONS`],[`GITLAB`,`GITLAB_CI`],[`GITLAB`,`CI_MERGE_REQUEST_ID`],[`GOCD`,`GO_PIPELINE_LABEL`],[`LAYERCI`],[`HUDSON`,`HUDSON_URL`],[`JENKINS`,`JENKINS_URL`],[`MAGNUM`],[`NETLIFY`],[`NETLIFY`,`NETLIFY_LOCAL`,{ci:!1}],[`NEVERCODE`],[`RENDER`],[`SAIL`,`SAILCI`],[`SEMAPHORE`],[`SCREWDRIVER`],[`SHIPPABLE`],[`SOLANO`,`TDDIUM`],[`STRIDER`],[`TEAMCITY`,`TEAMCITY_VERSION`],[`TRAVIS`],[`VERCEL`,`NOW_BUILDER`],[`VERCEL`,`VERCEL`,{ci:!1}],[`VERCEL`,`VERCEL_ENV`,{ci:!1}],[`APPCENTER`,`APPCENTER_BUILD_ID`],[`CODESANDBOX`,`CODESANDBOX_SSE`,{ci:!1}],[`CODESANDBOX`,`CODESANDBOX_HOST`,{ci:!1}],[`STACKBLITZ`],[`STORMKIT`],[`CLEAVR`],[`ZEABUR`],[`CODESPHERE`,`CODESPHERE_APP_ID`,{ci:!0}],[`RAILWAY`,`RAILWAY_PROJECT_ID`],[`RAILWAY`,`RAILWAY_SERVICE_ID`],[`DENO-DEPLOY`,`DENO_DEPLOYMENT_ID`],[`FIREBASE_APP_HOSTING`,`FIREBASE_APP_HOSTING`,{ci:!0}]],ir=function(){if(globalThis.process?.env)for(let e of rr){let t=e[1]||e[0];if(globalThis.process?.env[t])return{name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL===`/bin/jsh`&&globalThis.process?.versions?.webcontainer?{name:`stackblitz`,ci:!1}:{name:``,ci:!1}}();ir.name;function ar(e){return!!e&&e!==`false`}let or=globalThis.process?.platform||``;ar(tr.CI)||ir.ci;let sr=ar(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY);tr.DEBUG,nr===`test`||tr.TEST;let cr=(tr.MINIMAL,/^win/i.test(or)),lr=(/^linux/i.test(or),/^darwin/i.test(or),!ar(tr.NO_COLOR)&&(ar(tr.FORCE_COLOR)||(sr||cr)&&tr.TERM),(globalThis.process?.versions?.node||``).replace(/^v/,``)||null),ur=(Number(lr?.split(`.`)[0]),globalThis.process||Object.create(null)),dr={versions:{}},fr=(new Proxy(ur,{get:(e,t)=>t===`env`?tr:t in e?e[t]:t in dr?dr[t]:void 0}),globalThis.process?.release?.name===`node`),pr=!!globalThis.Bun||!!globalThis.process?.versions?.bun,mr=!!globalThis.Deno,hr=!!globalThis.fastly,gr=[[!!globalThis.Netlify,`netlify`],[!!globalThis.EdgeRuntime,`edge-light`],[globalThis.navigator?.userAgent===`Cloudflare-Workers`,`workerd`],[hr,`fastly`],[mr,`deno`],[pr,`bun`],[fr,`node`]];(function(){let e=gr.find(e=>e[0]);e&&e[1]})();let _r=E(`node:tty`)?.WriteStream?.prototype?.hasColors?.()??!1,Q=(e,t)=>{if(!_r)return e=>e;let n=`[${e}m`,r=`[${t}m`;return e=>{let i=e+``,a=i.indexOf(r);if(a===-1)return n+i+r;let o=n,s=0,c=(t===22?r:``)+n;for(;a!==-1;)o+=i.slice(s,a)+c,s=a+r.length,a=i.indexOf(r,s);return o+=i.slice(s)+r,o}},vr=(Q(0,0),Q(1,22),Q(2,22),Q(3,23),Q(4,24),Q(53,55),Q(7,27),Q(8,28),Q(9,29),Q(30,39),Q(31,39)),yr=Q(32,39),br=Q(33,39),xr=Q(34,39),Sr=(Q(35,39),Q(36,39)),Cr=(Q(37,39),Q(90,39));Q(40,49),Q(41,49),Q(42,49),Q(43,49),Q(44,49),Q(45,49),Q(46,49),Q(47,49),Q(100,49),Q(91,39),Q(92,39),Q(93,39),Q(94,39),Q(95,39),Q(96,39),Q(97,39),Q(101,49),Q(102,49),Q(103,49),Q(104,49),Q(105,49),Q(106,49),Q(107,49);function wr(e){if(typeof e!=`string`||e.startsWith(`file://`))return!1;try{return(0,H.lstatSync)(e).isDirectory()}catch{return!1}}function Tr(e,t=8){return(function(){if(Or!==void 0)return Or;try{return Or=!!Qn().getFips?.(),Or}catch{return Or=!1,Or}}()?Qn().createHash(`sha256`):Qn().createHash(`md5`)).update(e).digest(`hex`).slice(0,t)}let Er={true:yr(`true`),false:br(`false`),"[rebuild]":br(`[rebuild]`),"[esm]":xr(`[esm]`),"[cjs]":yr(`[cjs]`),"[import]":xr(`[import]`),"[require]":yr(`[require]`),"[native]":Sr(`[native]`),"[transpile]":br(`[transpile]`),"[fallback]":vr(`[fallback]`),"[unknown]":vr(`[unknown]`),"[hit]":yr(`[hit]`),"[miss]":br(`[miss]`),"[json]":yr(`[json]`),"[data]":yr(`[data]`)};function $(e,...t){if(!e.opts.debug)return;let n=process.cwd();console.log(Cr([`[jiti]`,...t.map(e=>e in Er?Er[e]:typeof e==`string`?e.replace(n,`.`):JSON.stringify(e))].join(` `)))}function Dr(e,t){return e.opts.interopDefault?function(e){let t=typeof e;if(e===null||t!==`object`&&t!==`function`)return e;let n=e.default,r=typeof n,i=n==null,a=r===`object`||r===`function`;return i&&e instanceof Promise?e:new Proxy(e,{get(t,r,o){if(r===`__esModule`)return!0;if(r===`default`)return i?e:typeof n?.default==`function`&&e.__esModule?n.default:n;if(Reflect.has(t,r))return Reflect.get(t,r,o);if(a&&!(n instanceof Promise)){let e=Reflect.get(n,r,o);return typeof e==`function`&&(e=e.bind(n)),e}},apply:(e,t,i)=>typeof e==`function`?Reflect.apply(e,t,i):r===`function`?Reflect.apply(n,t,i):void 0})}(t):t}let Or;function kr(e,t){return!!Ar(e,t)}function Ar(e,t){let n=process.env[e];if(!(e in process.env))return t;try{return JSON.parse(n)}catch{return t}}let jr=/\.(c|m)?j(sx?)$/,Mr=/\.(c|m)?t(sx?)$/;function Nr(e,t,n){let r,i;if(e.isNativeRe.test(t))return t;e.alias&&(t=function(e,t){let n=vt(e);t=Jn(t);for(let[e,r]of Object.entries(t))if(n.startsWith(e)&&Yn(n[(Yn(e)?e.slice(0,-1):e).length]))return wt(r,n.slice(e.length));return n}(t,e.alias));let a=n?.parentURL||e.url;wr(a)&&(a=wt(a,`_index.js`));let o=(n?.async?[n?.conditions,[`node`,`import`],[`node`,`require`]]:[n?.conditions,[`node`,`require`],[`node`,`import`]]).filter(Boolean);for(let n of o){try{r=Bn(t,{url:a,conditions:n,extensions:e.opts.extensions})}catch(e){i=e}if(r)return r}try{return e.nativeRequire.resolve(t,{paths:n.paths})}catch(e){i=e}for(let i of e.additionalExts)if(r=Pr(e,t+i,a,n)||Pr(e,t+`/index`+i,a,n),r||(Mr.test(e.filename)||Mr.test(e.parentModule?.filename||``)||jr.test(t))&&(r=Pr(e,t.replace(jr,`.$1t$2`),a,n),r))return r;if(!n?.try)throw i}function Pr(e,t,n,r){try{return e.nativeRequire.resolve(t,{...r,paths:[kt(Mn(n)),...r?.paths||[]]})}catch{}}let Fr=E(`node:perf_hooks`),Ir=E(`node:vm`);var Lr=r.n(Ir);function Rr(e,t,n){let r=e.parentCache||{};if(t.startsWith(`node:`))return zr(e,t,n.async);if(t.startsWith(`file:`))t=(0,W.fileURLToPath)(t);else if(t.startsWith(`data:`)){if(!n.async)throw Error("`data:` URLs are only supported in ESM context. Use `import` or `jiti.import` instead.");return $(e,`[native]`,`[data]`,`[import]`,t),zr(e,t,!0)}if(ut.builtinModules.includes(t)||t===`.pnp.js`)return zr(e,t,n.async);if(e.opts.tryNative&&!e.opts.transformOptions)try{if(!(t=Nr(e,t,n))&&n.try)return;if($(e,`[try-native]`,n.async&&e.nativeImport?`[import]`:`[require]`,t),n.async&&e.nativeImport)return e.nativeImport(t).then(n=>(!1===e.opts.moduleCache&&delete e.nativeRequire.cache[t],Dr(e,n)));{let n=e.nativeRequire(t);return!1===e.opts.moduleCache&&delete e.nativeRequire.cache[t],Dr(e,n)}}catch(n){$(e,`[try-native] Using fallback for ${t} because of an error:`,n)}let i=Nr(e,t,n);if(!i&&n.try)return;let a=Ot(i);if(a===`.json`){$(e,`[json]`,i);let t=e.nativeRequire(i);return t&&!(`default`in t)&&Object.defineProperty(t,`default`,{value:t,enumerable:!1}),t}if(a&&!e.opts.extensions.includes(a))return $(e,`[native]`,`[unknown]`,n.async?`[import]`:`[require]`,i),zr(e,i,n.async);if(e.isNativeRe.test(i))return $(e,`[native]`,n.async?`[import]`:`[require]`,i),zr(e,i,n.async);if(r[i])return Dr(e,r[i]?.exports);if(e.opts.moduleCache){let t=e.nativeRequire.cache[i];if(t?.loaded)return Dr(e,t.exports)}return Ur(e,(0,H.readFileSync)(i,`utf8`),{id:t,filename:i,ext:a,cache:r,async:n.async})}function zr(e,t,n){return n&&e.nativeImport?e.nativeImport(function(e){return cr&&U(e)?Nn(e):e}(t)).then(t=>Dr(e,t)):Dr(e,e.nativeRequire(t))}function Br(e,t,n){if(!e.opts.fsCache||!t.filename)return n();let r=` /* v9-${Tr(t.source,16)} */\n`,i=`${At(kt(t.filename))}-${function(e){let t=e.split(qn).pop();if(!t)return;let n=t.lastIndexOf(`.`);return n<=0?t:t.slice(0,n)}(t.filename)}`+(e.opts.sourceMaps?`+map`:``)+(t.interopDefault?`.i`:``)+`.${Tr(t.filename)}`+(t.async?`.mjs`:`.cjs`);t.jsx&&t.filename.endsWith(`x`)&&(i+=`x`);let a=e.opts.fsCache,o=wt(a,i);if(!e.opts.rebuildFsCache&&(0,H.existsSync)(o)){let n=(0,H.readFileSync)(o,`utf8`);if(n.endsWith(r))return $(e,`[cache]`,`[hit]`,t.filename,`~>`,o),n}$(e,`[cache]`,`[miss]`,t.filename);let s=n();return s.includes(`__JITI_ERROR__`)||((0,H.writeFileSync)(o,s+r,`utf8`),$(e,`[cache]`,`[store]`,t.filename,`~>`,o)),s}function Vr(t){if(!0===t.opts.fsCache&&(t.opts.fsCache=function(t){let n=t.filename&&Et(t.filename,`../node_modules`);if(n&&(0,H.existsSync)(n))return wt(n,`.cache/jiti`);let r=(0,e.tmpdir)();if(process.env.TMPDIR&&r===process.cwd()&&!process.env.JITI_RESPECT_TMPDIR_ENV){let t=process.env.TMPDIR;delete process.env.TMPDIR,r=(0,e.tmpdir)(),process.env.TMPDIR=t}return wt(r,`jiti`)}(t)),t.opts.fsCache)try{if((0,H.mkdirSync)(t.opts.fsCache,{recursive:!0}),!function(e){try{return(0,H.accessSync)(e,H.constants.W_OK),!0}catch{return!1}}(t.opts.fsCache))throw Error(`directory is not writable!`)}catch(e){$(t,`Error creating cache directory at `,t.opts.fsCache,e),t.opts.fsCache=!1}}function Hr(e,t){let n=Br(e,t,()=>{let n=e.opts.transform({...e.opts.transformOptions,babel:{...e.opts.sourceMaps?{sourceFileName:t.filename,sourceMaps:`inline`}:{},...e.opts.transformOptions?.babel},interopDefault:e.opts.interopDefault,...t});return n.error&&e.opts.debug&&$(e,n.error),n.code});return n.startsWith(`#!`)&&(n=`// `+n),n}function Ur(e,t,n={}){let r=n.id||(n.filename?At(n.filename):`_jitiEval.${n.ext||(n.async?`mjs`:`js`)}`),i=n.filename||Nr(e,r,{async:n.async}),a=n.ext||Ot(i),o=n.cache||e.parentCache||{},s=/\.[cm]?tsx?$/.test(a),c=a===`.mjs`||a===`.js`&&function(e){for(;e&&e!==`.`&&e!==`/`;){e=wt(e,`..`);try{let t=(0,H.readFileSync)(wt(e,`package.json`),`utf8`);try{return JSON.parse(t)}catch{}break}catch{}}}(i)?.type===`module`,l=a===`.cjs`,u=n.forceTranspile??(!l&&!(c&&n.async)&&(s||c||e.isTransformRe.test(i)||Un(t))),d=Fr.performance.now();if(u){t=Hr(e,{filename:i,source:t,ts:s,async:n.async??!1,jsx:e.opts.jsx});let r=Math.round(1e3*(Fr.performance.now()-d))/1e3;$(e,`[transpile]`,n.async?`[esm]`:`[cjs]`,i,`(${r}ms)`)}else{if($(e,`[native]`,n.async?`[import]`:`[require]`,i),n.async)return Promise.resolve(zr(e,i,n.async)).catch(r=>($(e,`Native import error:`,r),$(e,`[fallback]`,i),Ur(e,t,{...n,forceTranspile:!0})));try{return zr(e,i,n.async)}catch(r){$(e,`Native require error:`,r),$(e,`[fallback]`,i),t=Hr(e,{filename:i,source:t,ts:s,async:n.async??!1,jsx:e.opts.jsx})}}let f=new ut.Module(i);f.filename=i,e.parentModule&&(f.parent=e.parentModule,Array.isArray(e.parentModule.children)&&!e.parentModule.children.includes(f)&&e.parentModule.children.push(f));let p=Gr(i,e.opts,{parentModule:f,parentCache:o,nativeImport:e.nativeImport,onError:e.onError,createRequire:e.createRequire},!0),m;f.require=p,f.path=kt(i),f.paths=ut.Module._nodeModulePaths(f.path),o[i]=f,e.opts.moduleCache&&(e.nativeRequire.cache[i]=f);let h=function(e,t){return`(${t?.async?`async `:``}function (exports, require, module, __filename, __dirname, jitiImport, jitiESMResolve) { ${e}\n});`}(t,{async:n.async});try{m=Lr().runInThisContext(h,{filename:i,lineOffset:0,displayErrors:!1})}catch(t){t.name===`SyntaxError`&&n.async&&e.nativeImport?($(e,`[esm]`,`[import]`,`[fallback]`,i),m=function(e,t){let n=`data:text/javascript;base64,${Buffer.from(`export default ${e}`).toString(`base64`)}`;return(...e)=>t(n).then(t=>t.default(...e))}(h,e.nativeImport)):(e.opts.moduleCache&&delete e.nativeRequire.cache[i],e.onError(t))}let g;try{g=m(f.exports,f.require,f,f.filename,kt(f.filename),p.import,p.esmResolve)}catch(t){e.opts.moduleCache&&delete e.nativeRequire.cache[i],e.onError(t)}function _(){if(f.exports&&f.exports.__JITI_ERROR__){let{filename:t,line:n,column:r,code:i,message:a}=f.exports.__JITI_ERROR__,o=Error(`${i}: ${a} \n ${`${t}:${n}:${r}`}`);Error.captureStackTrace(o,Rr),e.onError(o)}return f.loaded=!0,Dr(e,f.exports)}return n.async?Promise.resolve(g).then(_):_()}let Wr=(0,e.platform)()===`win32`;function Gr(e,t={},n,r=!1){let i=r?t:function(e){let t={fsCache:kr(`JITI_FS_CACHE`,kr(`JITI_CACHE`,!0)),rebuildFsCache:kr(`JITI_REBUILD_FS_CACHE`,!1),moduleCache:kr(`JITI_MODULE_CACHE`,kr(`JITI_REQUIRE_CACHE`,!0)),debug:kr(`JITI_DEBUG`,!1),sourceMaps:kr(`JITI_SOURCE_MAPS`,!1),interopDefault:kr(`JITI_INTEROP_DEFAULT`,!0),extensions:Ar(`JITI_EXTENSIONS`,[`.js`,`.mjs`,`.cjs`,`.ts`,`.tsx`,`.mts`,`.cts`,`.mtsx`,`.ctsx`]),alias:Ar(`JITI_ALIAS`,{}),nativeModules:Ar(`JITI_NATIVE_MODULES`,[]),transformModules:Ar(`JITI_TRANSFORM_MODULES`,[]),tryNative:Ar(`JITI_TRY_NATIVE`,`Bun`in globalThis),jsx:kr(`JITI_JSX`,!1)};t.jsx&&t.extensions.push(`.jsx`,`.tsx`);let n={};return e.cache!==void 0&&(n.fsCache=e.cache),e.requireCache!==void 0&&(n.moduleCache=e.requireCache),{...t,...n,...e}}(t),a=i.alias&&Object.keys(i.alias).length>0?Jn(i.alias||{}):void 0,o=[`typescript`,`jiti`,...i.nativeModules||[]],s=RegExp(`node_modules/(${o.map(e=>Wn(e)).join(`|`)})/`),c=[...i.transformModules||[]],l=RegExp(`node_modules/(${c.map(e=>Wn(e)).join(`|`)})/`);e||=process.cwd(),!r&&wr(e)&&(e=wt(e,`_index.js`));let u=Nn(e),d=[...i.extensions].filter(e=>e!==`.js`),f=n.createRequire(Wr?e.replace(/\//g,`\\`):e),p={filename:e,url:u,opts:i,alias:a,nativeModules:o,transformModules:c,isNativeRe:s,isTransformRe:l,additionalExts:d,nativeRequire:f,onError:n.onError,parentModule:n.parentModule,parentCache:n.parentCache,nativeImport:n.nativeImport,createRequire:n.createRequire};return r||$(p,`[init]`,...[[`version:`,Xn.rE],[`module-cache:`,i.moduleCache],[`fs-cache:`,i.fsCache],[`rebuild-fs-cache:`,i.rebuildFsCache],[`interop-defaults:`,i.interopDefault]].flat()),r||Vr(p),Object.assign(function(e){return Rr(p,e,{async:!1})},{cache:i.moduleCache?f.cache:Object.create(null),extensions:f.extensions,main:f.main,options:i,resolve:Object.assign(function(e){return Nr(p,e,{async:!1})},{paths:f.resolve.paths}),transform:e=>Hr(p,e),evalModule:(e,t)=>Ur(p,e,t),async import(e,t){let n=await Rr(p,e,{...t,async:!0});return t?.default?n?.default??n:n},esmResolve(e,t){typeof t==`string`&&(t={parentURL:t});let n=Nr(p,e,{parentURL:u,...t,async:!0});return!n||typeof n!=`string`||n.startsWith(`file://`)?n:Nn(n)}})}})(),t.exports=i.default})()}))();var ge=class{emitter;constructor(){this.emitter=r()}on(e,t){pe(e).forEach(e=>{this.emitter.on(e,t)})}off(e,t){pe(e).forEach(e=>{this.emitter.off(e,t)})}emit(e,t){pe(e).forEach(e=>{this.emitter.emit(e,t)})}removeAllListeners(){this.emitter.all.clear()}},_e=class{listeners;constructor(){this.listeners=new Map}on(e,t){pe(e).forEach(e=>{let n=this.listeners.get(e)||new Set;n.add(t),this.listeners.set(e,n)})}off(e,t){pe(e).forEach(e=>{let n=this.listeners.get(e);n&&n.delete(t)})}async emit(e,...t){let n=pe(e).flatMap(e=>{let t=this.listeners.get(e)||new Set,n=this.listeners.get(`*`)||new Set;return[...Array.from(t),...Array.from(n)]});return n.length===0?[]:await Promise.all(n.map(async n=>{try{let e=n(...t);return e instanceof Promise?await e:e}catch(t){console.error(`Error in event listener for ${String(e)}:`,t);return}}))}removeAllListeners(){this.listeners.clear()}};function D(e,...t){return class extends e{static _instance;static getInstance(){return this._instance||=new e(...t),this._instance}static clearInstance(){this._instance=void 0}}}const O=D(class extends ge{destroy(){this.removeAllListeners()}fatal(e,t,n){this.emit(`fatal`,{code:t,message:e,data:n,timestamp:Date.now()})}error(e,t,n){this.emit(`error`,{code:t,message:e,data:n,timestamp:Date.now()})}warn(e,t,n){this.emit(`warning`,{code:t,message:e,data:n,timestamp:Date.now()})}});var k=class{data;_schema;_defaultValue;_path;constructor(e){let{schema:t,default:n,path:r}=e;this._schema=t,this._defaultValue=n,this._path=r}set(e){let t=this._schema[`~standard`].validate(e);if(t instanceof Promise)throw Error(`StructuredConfigFile does not support async validation`);if(t.issues)throw this.reportInvalidConfigFile(t.issues),Error(`Invalid config data for ${this._path}: ${t.issues.map(e=>e.message).join(`; `)}`);this.data=this.onBeforeSave(e),this.save(e)}get(e={}){return this.data?this.data:this.load(e)}getKey(e,t={}){return this.get(t)[e]}save(e){let t=this.onBeforeSave(e);try{d(this.getFilePath()),i.writeFileSync(this.getFilePath(),JSON.stringify(t,void 0,2))}catch{return}return this.data=t}load(e={}){let{createIfMissing:t=!0}=e;if(!this.fileExists(this.getFilePath())||!this.canReadWriteFile(this.getFilePath())){t&&this.save(this._defaultValue);let e=this.onAfterLoad(this._defaultValue);return t&&(this.data=e),e}try{let e=i.readFileSync(this.getFilePath(),`utf8`),t=this.onAfterLoad(this.parseStoredData(e));return this.data=t,t}catch{return this.data=this._defaultValue}}onBeforeSave(e){return e}onAfterLoad(e){return e}getFilePath(){return this._path}parseStoredData(e){try{let t=n(`string.json.parse`).to(`object`)(e);if(t instanceof n.errors)return this._defaultValue;let r=this._schema[`~standard`].validate(t);if(r instanceof Promise)throw Error(`StructuredConfigFile does not support async validation`);return r.issues?this.migrate(t,this._defaultValue):this.migrate(r.value,this._defaultValue)}catch{return this._defaultValue}}canReadWriteFile(e){try{return i.accessSync(e,i.constants.R_OK|i.constants.W_OK),!0}catch{return!1}}fileExists(e){try{return i.accessSync(e,i.constants.F_OK),!0}catch{return!1}}migrate(e,t){let n={...e};for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(r in e?e[r]!==null&&t[r]!==null&&typeof e[r]==`object`&&typeof t[r]==`object`&&!Array.isArray(e[r])&&!Array.isArray(t[r])?n[r]=this.migrate(e[r],t[r]):Array.isArray(t[r])&&(n[r]=e[r]):n[r]=t[r]);return n}reportInvalidConfigFile(e){O.getInstance().error(`Invalid config file`,`INVALID_CONFIG_FILE`,{issues:e.map(e=>e.message),filePath:this._path,data:this.data})}};function ve(e,t,n){return typeof e!=`object`||!e?String(e):e instanceof Error?JSON.stringify(e,(e,t)=>{if(t instanceof Error){let e={};for(let n of Object.getOwnPropertyNames(t))e[n]=t[n];return e}return t},n):e instanceof Map?JSON.stringify(Object.fromEntries(e.entries()),t,n):e instanceof Set?JSON.stringify(Array.from(e),t,n):JSON.stringify(e,t,n)}const A=/\x1b\[[0-9;]*m/g;function ye(e){return e.replace(A,``)}var be=class e extends ge{stream;logPath;baseFileName;currentDate;rotationCheckInterval;isRotating=!1;constructor(e,t){super(),this.logPath=e,this.baseFileName=t.replace(`.log`,``),this.currentDate=this.getDateString(new Date),this.ensureLogDirectory(),this.ensureLogFile(),this.stream=this.createStream(),this.rotationCheckInterval=this.startRotationCheck(),this.cleanupOldLogs()}static scope(t,n){return new e(t,n)}log(...e){this.write(`info`,...e)}error(...e){this.write(`error`,...e)}warn(...e){this.write(`warn`,...e)}info(...e){this.write(`info`,...e)}debug(...e){this.write(`debug`,...e)}async close(){clearInterval(this.rotationCheckInterval),await new Promise(e=>{this.stream.end(()=>e())})}getCurrentFileName(){return this.getFileName(this.currentDate)}static getMessageElements(e,...t){let n=new Date;return{timestamp:n.toISOString().replace(`T`,` `).replace(/\.\d+Z$/,``)+`.${n.getUTCMilliseconds().toString().padStart(3,`0`)}`,level:e,message:t.map(e=>ve(e)).join(` `)}}getFileName(e){return`${this.baseFileName}-${e}.log`}ensureLogDirectory(){try{s(this.logPath,{recursive:!0})}catch(e){throw console.error(`Failed to create log directory ${this.logPath}:`,e),e}}ensureLogFile(){let e=p(this.logPath,this.getFileName(this.currentDate));if(!o(e))try{u(e,``,`utf8`)}catch(t){throw console.error(`Failed to create log file ${e}:`,t),t}}getDateString(e){return`${e.getUTCFullYear()}-${(e.getUTCMonth()+1).toString().padStart(2,`0`)}-${e.getUTCDate().toString().padStart(2,`0`)}`}createStream(){return a(p(this.logPath,this.getFileName(this.currentDate)),{flags:`a`,encoding:`utf8`})}async rotateLogs(){if(this.isRotating)return;this.isRotating=!0;let e=this.getDateString(new Date);e!==this.currentDate&&await new Promise(t=>{this.stream.end(()=>{this.currentDate=e,this.stream=this.createStream(),this.cleanupOldLogs(),t()})}),this.isRotating=!1}startRotationCheck(){return setInterval(()=>this.rotateLogs(),6e4)}cleanupOldLogs(){let e=c(this.logPath),t=new Date,n=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()-7));e.filter(e=>e.startsWith(this.baseFileName)&&e.endsWith(`.log`)).filter(e=>{let[t,r,i]=e.replace(`${this.baseFileName}-`,``).replace(`.log`,``).split(`-`).map(Number);return new Date(Date.UTC(t,r-1,i))<=n}).forEach(e=>{try{l(p(this.logPath,e))}catch(t){console.error(`Failed to delete old log file ${e}:`,t)}})}ensureStreamValid(){if(!this.stream.writable||this.stream.destroyed)try{this.stream=this.createStream()}catch(e){this.emit(`error`,e instanceof Error?e:Error(String(e)))}}write(t,...n){let{timestamp:r,message:i}=e.getMessageElements(t,...n),a=`[${r}] [${t}] ${ye(i)}\n`;this.ensureStreamValid(),this.stream.write(a,e=>{if(e)if(e.code===`ERR_STREAM_WRITE_AFTER_END`||!this.stream.writable)try{this.stream=this.createStream(),this.stream.write(a,e=>{e?this.emit(`error`,e):this.emit(`write`,a)})}catch(e){this.emit(`error`,e instanceof Error?e:Error(String(e)))}else this.emit(`error`,e);else this.emit(`write`,a)})}};const j=()=>h.join(process.env.APPDATA??``,`overlayed`),xe=()=>h.join(j(),`logs`),Se=e=>h.join(j(),`apps`,e),Ce=e=>h.join(Se(e),`logs`),we=()=>h.join(j(),`meta.json`),Te=()=>h.join(j(),`crash-dumps`);var Ee=class{fileLogger;path;appId;messageQueue=new he;fileName;_debug=!1;silent=!1;forceSilent=!1;constructor(e){this.fileName=e}init(e,t=!1,n=!1,r=!1){this.appId=e,this._debug=t,this.silent=n,this.forceSilent=r,this.path=Ce(e),this.fileLogger=new be(this.path,this.fileName),this.messageQueue.flush().forEach(e=>{this.fileLogger?.[e.type](...e.args)})}scope(e){if(!this.appId||!this.path)throw Error(`Logger not initialized`);let t=v.cyan(`[${e}]`);return{scope:e=>this.scope(e),error:(...e)=>this.error(t,...e),warn:(...e)=>this.warn(t,...e),info:(...e)=>this.info(t,...e),log:(...e)=>this.log(t,...e),debug:(...e)=>this.debug(t,...e)}}error(...e){this.handle(`error`,...e)}warn(...e){this.handle(`warn`,...e)}info(...e){this.handle(`log`,...e)}debug(...e){this._debug&&this.handle(`debug`,...e)}log(...e){this.handle(`log`,...e)}handle(e,...t){this.logToConsole(e,...t),this.fileLogger?this.fileLogger[e](...t):this.messageQueue.add({type:e,args:t})}logToConsole(e,...t){let n={error:v.red,warn:v.yellow,debug:v.blue,log:v.white};if(this.forceSilent||this.silent&&!this._debug)return;let{timestamp:r,message:i}=be.getMessageElements(e,...t),a=console[e],o=n[e];a(`${v.gray(r)} ${o(i)}`)}};const M=D(Ee,`overlayed.log`);var N=class extends ee{blob;chunkSizeMb;maxConcurrent;shouldStop=!1;constructor(e,t){super(),this.blob=e,this.chunkSizeMb=t.chunkSizeMb,this.maxConcurrent=t.maxConcurrent??3}get totalChunks(){return Math.ceil(this.blob.size/(this.chunkSizeMb*1024*1024))}async chunk(e){let t=this.chunkSizeMb*1024*1024,n=this.totalChunks;if(n===0)return;let r=new Map,i=new Set,a=new Set,o=[];for(let e=0;e<n;e++)o.push(e);let s=async n=>{let s=n*t,c=Math.min(s+t,this.blob.size),l=this.blob.slice(s,c);try{await e(l,n),a.add(n),this.emit(`chunkComplete`,n),i.delete(n)}catch(e){let t=r.get(n)||0;t<5?(r.set(n,t+1),await new Promise(e=>setTimeout(e,(t+1)*1e3)),o.push(n)):(a.add(n),this.emit(`error`,e),this.shouldStop=!0,i.delete(n))}},c=[],l=async()=>{for(;(o.length>0||i.size>0)&&!this.shouldStop;){if(o.length===0){await new Promise(e=>setTimeout(e,10));continue}let e=o.shift();a.has(e)||i.has(e)||(i.add(e),await s(e))}};for(let e=0;e<this.maxConcurrent;e++)c.push(l());await Promise.all(c)}};function P(e,t){let{recursive:n}=F(t);return te(e)?n?De(e).map(t=>[e,t]):ie(e).map(t=>[e,t]):[]}function F(e){return{recursive:e?.recursive??!0}}function De(e){return ie(e,{withFileTypes:!0}).flatMap(t=>{let n=h.join(e,t.name);return t.isDirectory()?De(n):[n]})}function I(e){return Oe(e),e}function Oe(e){if(!me(e.applicationId))throw Error(`Invalid applicationId, must be a valid ULID.`)}function ke(e,t){let n=t?.cwd??process.cwd(),r=m.join(n,`.overlayed`);y.existsSync(r)||y.mkdirSync(r,{recursive:!0});let i={application:{id:e.id,name:e.name,slug:e.slug,siteUrl:e.siteUrl},release:{id:null,channel:`local`,version:`0.0.0`}},a=m.join(r,`meta.json`);return y.writeFileSync(a,JSON.stringify(i,null,2)),i}const{PipeEventServer:Ae,PipeEventClient:je,PipeEventBase:Me,ProcessMonitor:Ne,Process:Pe,HardwareInterface:Fe}=e(import.meta.url)(`@overlayed/app/dist/native-interface/build/overlayed_native_interface_x64.node`),Ie=D(class extends ge{server=null;_hasConnection=!1;pipeId;get hasConnection(){return this._hasConnection}constructor(e){super(),this.pipeId=e,this.init()}destroy(){this.server&&=(this._hasConnection=!1,this.server?.removeAllListeners(),null)}init(){this.server=new Ae(this.pipeId,{clientCount:1,access:1}),this.server.on(`event`,e=>{try{let t=JSON.parse(e);this.emit(`data`,[t])}catch(e){this.emit(`error`,e)}}),this.server.on(`connected`,()=>{this._hasConnection=!0,this.emit(`connected`,void 0)}),this.server.on(`disconnected`,()=>{this._hasConnection=!1,this.emit(`disconnected`,void 0)})}},`overlayed-event-server`),{RenderInterface:Le,renderHookPath:Re}=e(import.meta.url)(`@overlayed/app/dist/render-interface/build/overlayed_render_interface_x64.node`);let ze=function(e){return e[e.LeftButton=1]=`LeftButton`,e[e.RightButton=2]=`RightButton`,e[e.Cancel=3]=`Cancel`,e[e.MiddleButton=4]=`MiddleButton`,e[e.ExtraButton1=5]=`ExtraButton1`,e[e.ExtraButton2=6]=`ExtraButton2`,e[e.Back=8]=`Back`,e[e.Tab=9]=`Tab`,e[e.Clear=12]=`Clear`,e[e.Return=13]=`Return`,e[e.Shift=16]=`Shift`,e[e.Control=17]=`Control`,e[e.Menu=18]=`Menu`,e[e.Pause=19]=`Pause`,e[e.CapsLock=20]=`CapsLock`,e[e.Kana=21]=`Kana`,e[e.Hangeul=21]=`Hangeul`,e[e.Hangul=21]=`Hangul`,e[e.Junja=23]=`Junja`,e[e.Final=24]=`Final`,e[e.Hanja=25]=`Hanja`,e[e.Kanji=25]=`Kanji`,e[e.Escape=27]=`Escape`,e[e.Convert=28]=`Convert`,e[e.NonConvert=29]=`NonConvert`,e[e.Accept=30]=`Accept`,e[e.ModeChange=31]=`ModeChange`,e[e.Space=32]=`Space`,e[e.Prior=33]=`Prior`,e[e.Next=34]=`Next`,e[e.End=35]=`End`,e[e.Home=36]=`Home`,e[e.Left=37]=`Left`,e[e.Up=38]=`Up`,e[e.Right=39]=`Right`,e[e.Down=40]=`Down`,e[e.Select=41]=`Select`,e[e.Print=42]=`Print`,e[e.Execute=43]=`Execute`,e[e.Snapshot=44]=`Snapshot`,e[e.Insert=45]=`Insert`,e[e.Delete=46]=`Delete`,e[e.Help=47]=`Help`,e[e.N0=48]=`N0`,e[e.N1=49]=`N1`,e[e.N2=50]=`N2`,e[e.N3=51]=`N3`,e[e.N4=52]=`N4`,e[e.N5=53]=`N5`,e[e.N6=54]=`N6`,e[e.N7=55]=`N7`,e[e.N8=56]=`N8`,e[e.N9=57]=`N9`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.LeftWindows=91]=`LeftWindows`,e[e.RightWindows=92]=`RightWindows`,e[e.Application=93]=`Application`,e[e.Sleep=95]=`Sleep`,e[e.Numpad0=96]=`Numpad0`,e[e.Numpad1=97]=`Numpad1`,e[e.Numpad2=98]=`Numpad2`,e[e.Numpad3=99]=`Numpad3`,e[e.Numpad4=100]=`Numpad4`,e[e.Numpad5=101]=`Numpad5`,e[e.Numpad6=102]=`Numpad6`,e[e.Numpad7=103]=`Numpad7`,e[e.Numpad8=104]=`Numpad8`,e[e.Numpad9=105]=`Numpad9`,e[e.Multiply=106]=`Multiply`,e[e.Add=107]=`Add`,e[e.Separator=108]=`Separator`,e[e.Subtract=109]=`Subtract`,e[e.Decimal=110]=`Decimal`,e[e.Divide=111]=`Divide`,e[e.F1=112]=`F1`,e[e.F2=113]=`F2`,e[e.F3=114]=`F3`,e[e.F4=115]=`F4`,e[e.F5=116]=`F5`,e[e.F6=117]=`F6`,e[e.F7=118]=`F7`,e[e.F8=119]=`F8`,e[e.F9=120]=`F9`,e[e.F10=121]=`F10`,e[e.F11=122]=`F11`,e[e.F12=123]=`F12`,e[e.F13=124]=`F13`,e[e.F14=125]=`F14`,e[e.F15=126]=`F15`,e[e.F16=127]=`F16`,e[e.F17=128]=`F17`,e[e.F18=129]=`F18`,e[e.F19=130]=`F19`,e[e.F20=131]=`F20`,e[e.F21=132]=`F21`,e[e.F22=133]=`F22`,e[e.F23=134]=`F23`,e[e.F24=135]=`F24`,e[e.NumLock=144]=`NumLock`,e[e.ScrollLock=145]=`ScrollLock`,e[e.NEC_Equal=146]=`NEC_Equal`,e[e.Fujitsu_Jisho=146]=`Fujitsu_Jisho`,e[e.Fujitsu_Masshou=147]=`Fujitsu_Masshou`,e[e.Fujitsu_Touroku=148]=`Fujitsu_Touroku`,e[e.Fujitsu_Loya=149]=`Fujitsu_Loya`,e[e.Fujitsu_Roya=150]=`Fujitsu_Roya`,e[e.LeftShift=160]=`LeftShift`,e[e.RightShift=161]=`RightShift`,e[e.LeftControl=162]=`LeftControl`,e[e.RightControl=163]=`RightControl`,e[e.LeftMenu=164]=`LeftMenu`,e[e.RightMenu=165]=`RightMenu`,e[e.BrowserBack=166]=`BrowserBack`,e[e.BrowserForward=167]=`BrowserForward`,e[e.BrowserRefresh=168]=`BrowserRefresh`,e[e.BrowserStop=169]=`BrowserStop`,e[e.BrowserSearch=170]=`BrowserSearch`,e[e.BrowserFavorites=171]=`BrowserFavorites`,e[e.BrowserHome=172]=`BrowserHome`,e[e.VolumeMute=173]=`VolumeMute`,e[e.VolumeDown=174]=`VolumeDown`,e[e.VolumeUp=175]=`VolumeUp`,e[e.MediaNextTrack=176]=`MediaNextTrack`,e[e.MediaPrevTrack=177]=`MediaPrevTrack`,e[e.MediaStop=178]=`MediaStop`,e[e.MediaPlayPause=179]=`MediaPlayPause`,e[e.LaunchMail=180]=`LaunchMail`,e[e.LaunchMediaSelect=181]=`LaunchMediaSelect`,e[e.LaunchApplication1=182]=`LaunchApplication1`,e[e.LaunchApplication2=183]=`LaunchApplication2`,e[e.OEM1=186]=`OEM1`,e[e.OEMPlus=187]=`OEMPlus`,e[e.OEMComma=188]=`OEMComma`,e[e.OEMMinus=189]=`OEMMinus`,e[e.OEMPeriod=190]=`OEMPeriod`,e[e.OEM2=191]=`OEM2`,e[e.OEM3=192]=`OEM3`,e[e.OEM4=219]=`OEM4`,e[e.OEM5=220]=`OEM5`,e[e.OEM6=221]=`OEM6`,e[e.OEM7=222]=`OEM7`,e[e.OEM8=223]=`OEM8`,e[e.OEMAX=225]=`OEMAX`,e[e.OEM102=226]=`OEM102`,e[e.ICOHelp=227]=`ICOHelp`,e[e.ICO00=228]=`ICO00`,e[e.ProcessKey=229]=`ProcessKey`,e[e.ICOClear=230]=`ICOClear`,e[e.Packet=231]=`Packet`,e[e.OEMReset=233]=`OEMReset`,e[e.OEMJump=234]=`OEMJump`,e[e.OEMPA1=235]=`OEMPA1`,e[e.OEMPA2=236]=`OEMPA2`,e[e.OEMPA3=237]=`OEMPA3`,e[e.OEMWSCtrl=238]=`OEMWSCtrl`,e[e.OEMCUSel=239]=`OEMCUSel`,e[e.OEMATTN=240]=`OEMATTN`,e[e.OEMFinish=241]=`OEMFinish`,e[e.OEMCopy=242]=`OEMCopy`,e[e.OEMAuto=243]=`OEMAuto`,e[e.OEMENLW=244]=`OEMENLW`,e[e.OEMBackTab=245]=`OEMBackTab`,e[e.ATTN=246]=`ATTN`,e[e.CRSel=247]=`CRSel`,e[e.EXSel=248]=`EXSel`,e[e.EREOF=249]=`EREOF`,e[e.Play=250]=`Play`,e[e.Zoom=251]=`Zoom`,e[e.Noname=252]=`Noname`,e[e.PA1=253]=`PA1`,e[e.OEMClear=254]=`OEMClear`,e}({});const Be=n({game:`string`,type:`string`,creation_time:`number`}).and({game:`'siege' | 'tft'`}),Ve=t({"#event1":`logged_in | module_loaded | module_unloaded | unsupported_game_version`,event:`event1`,logged_in:Be.and({type:`'logged_in'`,content:{account_id:`string`}}),module_loaded:Be.and({type:`'module_loaded'`,content:{game_version:`string`,process_hash:`string`}}),module_unloaded:Be.and({type:`'module_unloaded'`}),unsupported_game_version:Be.and({type:`'unsupported_game_version'`,content:{game_version:`string`,process_hash:`string`}})}).export(),He=Object.keys(Ve).filter(e=>e!==`event`);function Ue(){return{key:`universal`,events:Ve}}var We=class{options=null;logger;initialized=!1;constructor(e){this.logger=M.getInstance().scope(e)}init(e){this.logger.log(`Initializing`),this.options=e||null,this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1}},L=class extends ge{options=null;logger;initialized=!1;constructor(e){super(),this.logger=M.getInstance().scope(e)}init(e){this.logger.log(`Initializing`),this.options=e||null,this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1,this.removeAllListeners()}},Ge=class extends _e{options=null;logger;initialized=!1;constructor(e){super(),this.logger=M.getInstance().scope(e)}init(e){this.logger.log(`Initializing`),this.options=e||null,this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1,this.removeAllListeners()}};const Ke=import.meta.env.VITE_API_BASE_URL,R=se.create({baseURL:Ke,headers:{Accept:`application/json`,"Accept-Encoding":`gzip, deflate, br`}});let qe;function Je(e){qe=e}let Ye;function Xe(e){Ye=e}function z(e){return`overlayed/app (${Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `)})`}R.interceptors.request.use(e=>{let t=qe?.();e.headers??={},t&&(e.headers[`X-Api-Key`]=t);let n=Ye?.();return n&&(e.headers[`User-Agent`]=z(n)),e});function Ze(e,t){if(t<=0)throw Error(`Chunk size must be greater than 0`);if(e.length===0)return[];let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function B(e){return e}function Qe(e){return e?t=>(e(t),t):B}const $e=Qe();function et(e){return R.get(`/v1/public/applications/${e}`)}function tt(e,t){return R.get(`/v1/public/applications/${e}/releases/check`,{params:t})}function nt(e,t){return R.post(`/v1/public/applications/${e}/game-crash-reports`,t)}function rt(e,t,n){return R.post(`/v1/public/applications/${e}/game-crash-reports/${t}/confirm`,n)}function it(e,t){let n=new FormData;return n.append(`file`,new Blob([t.file],{type:`application/zip`}),`logs.zip`),n.append(`data`,JSON.stringify(t.data)),R.post(`/v1/public/applications/${e}/feedbacks`,n)}function at(e,t){return R.get(`/v1/public/applications/${e}/feature-flags`,{params:t})}function ot(e,t){return R.get(`/v1/public/applications/${e}/notices`,{params:t})}const st=Qe();function V(e,t){return R.get(`/v1/public/modules/${e}/release`,{params:{cortex_user_id:t}})}function ct(e,t,n){return R.post(`/v1/public/modules/${e}/releases/${t}/download`,n)}async function lt(e,t){if(e.method!==`GET`)throw Error(`Unsupported presigned request method: ${e.method}`);let n=await fetch(e.url,{method:e.method,headers:e.headers,signal:t?.signal});if(!n.ok){let e=await H(n);throw Error(`Presigned download failed (${n.status} ${n.statusText})${e?`: ${e}`:``}`)}let r=await n.arrayBuffer();return new Uint8Array(r)}async function ut(e,t){if(e.method!==`PUT`)throw Error(`Unsupported presigned request method: ${e.method}`);let n=await fetch(e.url,{method:e.method,headers:{...e.headers,"Content-Length":t.byteLength.toString()},body:t});if(!n.ok){let e=await H(n);throw Error(`Presigned upload failed (${n.status} ${n.statusText})${e?`: ${e}`:``}`)}}async function H(e){try{let t=(await e.text()).trim();if(t.length===0)return;let n=2048;return t.length>n?`${t.slice(0,n)}…`:t}catch{return}}function dt(){return R.get(`/v1/public/raven/config`)}const ft=Qe();function pt(e,t){return R.get(`/v1/public/raven/games/${e}/builds/${t}`)}function mt(e,t){return R.post(`/v1/public/raven/games/${e}/builds/upload`,null,{params:t})}function ht(e,t){let n=new FormData;return n.append(`file`,t.chunk),R.patch(`/v1/public/raven/games/${e}/builds/upload`,n,{params:t})}function gt(e){let t=Date.now(),n=e.messages.filter(e=>t-e.created_at.getTime()<6e5),r=e.messages.length-n.length;r>0&&console.warn(`Dropped ${r} cortex event(s) older than 600s`);let i=Ze(n.map(e=>_t(t,e)),50),a=Promise.all(i.map(async t=>R.post(`/v1/public/cortex/events`,{...e,messages:t})));return a.catch(e=>{let t=e?.response?.data||e?.message||e;console.error(`Failed to submit cortex events`,t)}),a}function _t(e,t){let n=e-t.created_at.getTime(),r=Math.max(0,Math.floor(n/1e3));return{properties:t.properties,type:t.type,seconds_offset:r}}function vt(e){return e instanceof Error&&(e.name===`XiorError`||e.name===`XiorTimeoutError`)}function yt(e){return!!(e&&`kind`in e.data&&`message`in e.data)}const{PipeEventServer:bt,PipeEventClient:xt,PipeEventBase:St,ProcessMonitor:Ct,Process:wt,HardwareInterface:Tt}=e(import.meta.url)(`@overlayed/app/dist/native-interface/build/overlayed_native_interface_x64.node`);function Et(e=[]){return h.normalize(h.join(Se(global.OVERLAYED.APPLICATION_ID),...e))}const Dt=n({game:`string`,type:`string`,creation_time:`number`}),U=new k({path:we(),schema:n({userId:`string | undefined`,sessionId:`string | undefined`,sessionLastUsed:`number | undefined`,accessToken:`string | undefined`,"debug?":{"ri_disabled?":`boolean`,"gm_disabled?":`boolean`}}),default:{userId:void 0,sessionId:void 0,sessionLastUsed:void 0,accessToken:void 0}});function Ot(){let{debug:e}=U.get();return e?{ri_disabled:e.ri_disabled??!1,gm_disabled:e.gm_disabled??!1}:{ri_disabled:!1,gm_disabled:!1}}function kt(){let e=U.get().userId;if(e)return e;let t=jt();return U.set({...U.get(),userId:t}),t}function At(){let e=U.get();if(e.sessionId&&typeof e.sessionLastUsed==`number`&&Date.now()-e.sessionLastUsed<=300*1e3)return e.sessionId;let t=crypto.randomUUID();return U.set({...e,sessionId:t,sessionLastUsed:Date.now()}),t}function W(){try{let e=U.get();U.set({...e,sessionLastUsed:Date.now()})}catch(e){M.getInstance().log(`Failed to update sessionLastUsed`,e)}}function G(){return U.get().accessToken}function K(e){try{let t=U.get();U.set({...t,accessToken:e??void 0})}catch(e){M.getInstance().log(`Failed to set accessToken`,e)}}function jt(){try{return Tt.generateUniqueIdentifier()}catch{return crypto.randomUUID()}}const Mt=D(class extends L{UPDATE_CHECK_INTERVAL_MS=1e3*60*5;targetDir;updateInterval;constructor(){super(`NativeModuleManager`),this.targetDir=h.join(j(),`resources`),this.logger.log(`Target directory`,this.targetDir)}async initWithDlls(e){super.init(),await C.mkdir(this.targetDir,{recursive:!0}),await this.checkForUpdates(e),clearInterval(this.updateInterval),this.updateInterval=setInterval(()=>this.checkForUpdates(e),this.UPDATE_CHECK_INTERVAL_MS)}destroy(){this.updateInterval&&=(clearInterval(this.updateInterval),void 0),super.destroy()}async getDllFile(e){let t=await this.getCurrentBuildInfo(e);if(!t){this.logger.error(`No build found for module`,{moduleId:e});return}let n=this.getBuildPath(e,t.buildId);if(!te(n)){this.logger.error(`No build file found for module`,{moduleId:e});return}let r=h.join(n,t.buildFileName);if(!te(r)){this.logger.error(`No DLL file found for module`,{moduleId:e});return}return r}async getCurrentBuildInfo(e){try{let t=h.join(this.targetDir,e,`build.json`),n=await C.readFile(t,`utf-8`);return JSON.parse(n)}catch{return null}}getModulePath(e){return h.join(this.targetDir,e)}getBuildPath(e,t){return h.join(this.getModulePath(e),t)}async checkForUpdates(e){this.logger.log(`Checking for updates`);let t=kt();if(!t){this.logger.error(`Failed to resolve cortex user id`);return}this.logger.log(`Cortex User ID`,t);for(let n of e)try{let{data:e}=await V(n,t);this.logger.log(`Release`,e);let r=(await this.getCurrentBuildInfo(n))?.buildId||null;this.logger.log(`${n} > Performing update check. current: ${r}, requested: ${e.build_id}`),e.build_id!==r||await this.isDownloadCorrupted(this.getBuildPath(n,e.build_id),e)?(this.logger.log(`${n} > Update found. current: ${r}, requested: ${e.build_id}`),this.logger.log(`${n} > Downloading and extracting DLLs`),await this.downloadAndExtractDll(n,e),this.logger.log(`${n} > Cleaning up other builds`),await this.cleanupExistingBuilds(n,e.build_id),this.emit(`dllUpdated`,{moduleId:n,buildId:e.build_id,releaseId:e.release_id})):this.logger.log(`${n} > No update found`)}catch(e){this.logger.error(`${n} > Error checking/updating`,e)}}async downloadAndExtractDll(e,t){this.logger.log(`${e} > Requesting download for build ${t.build_id}`);let n=kt();if(!n){this.logger.error(`Failed to resolve cortex user id`);return}let{data:r}=await ct(e,t.release_id,{download_token:t.download_token,cortex_user_id:n});this.logger.log(`${e} > Downloading DLLs for build ${t.build_id}`);let i=await lt(r,{signal:AbortSignal.timeout(1e3*60*5)});this.logger.log(`${e} > Downloaded zip file for build ${t.build_id}`);let a=this.getBuildPath(e,t.build_id);await C.mkdir(a,{recursive:!0});let o=new ce;await o.loadAsync(i);let s=Object.keys(o.files).map(e=>({name:e,file:o.files[e]})).filter(({file:e})=>!e.dir);if(s.length!==1){this.logger.error(`${e} > Zip must contain exactly 1 file, got ${s.length}`);return}let c=s[0],l=h.basename(c.name),u=h.normalize(l),d=h.isAbsolute(u),f=u.startsWith(`..`)||u.includes(`..${h.sep}`);if(l===``||l===`.`||l===`..`){this.logger.error(`${e} > Zip contained an invalid file name: ${c.name}`);return}if(!l.toLowerCase().endsWith(`.dll`)){this.logger.error(`${e} > Zip contained a non-dll file: ${c.name}`);return}if(d||f){this.logger.error(`${e} > Zip entry path is unsafe: ${c.name}`);return}let p=h.join(a,u),m=await c.file.async(`nodebuffer`);await C.writeFile(p,m),this.logger.log(`${e} > Extracted 1 file to ${p}`);let g={buildId:t.build_id,buildFileName:t.build_file_name},_=h.join(this.getModulePath(e),`build.json`);await C.writeFile(_,JSON.stringify(g),`utf-8`),this.logger.log(`${e} > Saved buildId to file: ${t.build_id}`)}async cleanupExistingBuilds(e,t){let n=this.getModulePath(e),r=this.getBuildPath(e,t),i=await C.readdir(n,{withFileTypes:!0});for(let t of i)t.isDirectory()&&h.join(n,t.name)!==r&&(await C.rm(h.join(n,t.name),{recursive:!0,force:!0}),this.logger.log(`${e} > Cleaned up build: ${t.name}`))}async hasPathAccess(e){try{return await C.access(e,C.constants.F_OK),!0}catch{return!1}}async isDownloadCorrupted(e,t){if(!await this.hasPathAccess(e))return this.logger.error(`Download is corrupted. Path does not exist: ${e}`),!0;let n=t.build_file_name,r=h.join(e,n);if(!te(r))return this.logger.error(`Download is corrupted. Build file not found: ${r}`),!0;if(t.build_hash){let e=await C.readFile(r),i=oe(`sha256`).update(e).digest(`hex`);if(i.toLowerCase()!==t.build_hash.toLowerCase())return this.logger.error(`Download is corrupted. Build file hash mismatch: ${n} ${i.toLowerCase()} !== ${t.build_hash.toLowerCase()}`),!0}return!1}}),Nt=D(class extends L{REFETCH_INTERVAL=1e3*60*5;FAILED_REFETCH_INTERVAL=1e3*30;_ravenConfig;_executableToGameMap=new Map;_executablesArray=[];_refetchIntervalHandler=null;_failedRefetchTimeoutHandler=null;constructor(){super(`RavenManager`)}init(){super.init(),this.fetchRavenConfig(),this._refetchIntervalHandler=setInterval(()=>{this._failedRefetchTimeoutHandler&&=(clearTimeout(this._failedRefetchTimeoutHandler),null),this.fetchRavenConfig()},this.REFETCH_INTERVAL)}getExecutableData(e){return this._executableToGameMap.get(e.toLowerCase())??null}get executables(){return this._executablesArray}get executablesMap(){return this._executableToGameMap}destroy(){this._refetchIntervalHandler&&clearInterval(this._refetchIntervalHandler),this._failedRefetchTimeoutHandler&&clearTimeout(this._failedRefetchTimeoutHandler),Mt.getInstance().destroy(),super.destroy()}async fetchRavenConfig(){try{let e={games:(await dt()).data.games};this._ravenConfig=e,this.resetState();let t=new Set;for(let e of this._ravenConfig.games){for(let t of e.executables){let n=t.toLowerCase();this._executableToGameMap.set(n,e),this._executablesArray.push(n)}e.modules.forEach(e=>t.add(e))}await Mt.getInstance().initWithDlls(Array.from(t)),this.logger.log(`Raven updated, monitoring ${this._executableToGameMap.size} executables`),this.emit(`executablesUpdated`,{executables:this.executables,map:this._executableToGameMap})}catch(e){this.logger.error(`Failed to fetch Raven config`,e),this._failedRefetchTimeoutHandler=setTimeout(()=>this.fetchRavenConfig(),this.FAILED_REFETCH_INTERVAL)}}resetState(){this._executableToGameMap.clear(),this._executablesArray=[]}}),Pt=D(class extends L{_processMonitor;_processes=new Map;boundOnRavenManagerExecutablesUpdated=this.onRavenManagerExecutablesUpdated.bind(this);constructor(){super(`ProcessManager`),this._processMonitor=new Ct}get hasAnyActiveProcesses(){return this.activeProcesses.length>0}get activeProcesses(){return Array.from(this._processes.values()).flat().filter(e=>!e.destroyedAt)}init(){super.init(),Nt.getInstance().on(`executablesUpdated`,this.boundOnRavenManagerExecutablesUpdated),this._processMonitor.on(`create`,e=>{this.logger.log(`Process created`,e),this.addProcess(e),this.logger.log(`Active Process Count: ${this._processes.size}`),this.emit(`create`,{process:e})}),this._processMonitor.on(`destroy`,e=>{this.logger.log(`Process destroyed`,e),this.deleteProcess(e),this.logger.log(`Active Process Count: ${this._processes.size}`),this.emit(`destroy`,{process:e})})}destroy(){Nt.getInstance().off(`executablesUpdated`,this.boundOnRavenManagerExecutablesUpdated),this._processes.clear(),this._processMonitor.removeAllListeners(),super.destroy()}isProcessRunning(e){return this._processes.get(e)?.some(e=>!e.destroyedAt)??!1}onRavenManagerExecutablesUpdated(e){this.logger.log(`Monitoring ${e.executables.length} processes`),e.executables.forEach(e=>{this._processMonitor.isProcessRegistered(e)||this._processMonitor.registerProcess(e)})}addProcess(e){if(!e.name)return;let t=this._processes.get(e.name);if(!t){this._processes.set(e.name,[e]);return}this._processes.set(e.name,t.concat(e))}deleteProcess(e){if(!e.name)return;let t=this._processes.get(e.name)?.filter(t=>t.id!==e.id)??[];t.length===0?this._processes.delete(e.name):this._processes.set(e.name,t)}});var Ft=class{_instance;_resolution;boundOnResolutionChanged=this.onResolutionChanged.bind(this);constructor(e){this._instance=e,this._resolution={width:0,height:0},this._instance.on(`resolution`,this.boundOnResolutionChanged)}destroy(){this._instance.off(`resolution`,this.boundOnResolutionChanged)}get instance(){return this._instance}get resolution(){return this._resolution}onResolutionChanged(e,t){this._resolution={width:e,height:t}}};const It=D(class{interfaces={};constructor(){}createInterface(e){return this.interfaces[e]||(this.interfaces[e]=new Ft(new Le(e,{access:1}))),this.interfaces[e]}getInterface(e){return this.interfaces[e]?this.interfaces[e]:this.createInterface(e)}}),q=D(class{options;eventQueue;meta=null;enabled=!0;constructor(e){this.options=this.resolveOptions(e),this.eventQueue=new he,this.setupFlushInterval()}track(e,t){this.enabled&&this.eventQueue.add({type:e,properties:t,created_at:new Date})}flush(){if(!this.enabled)return[];let e=Array.from(this.eventQueue.flush()).concat({type:`ping`,properties:{},created_at:new Date});if(!this.meta)throw Error(`Tried to flush Cortex events before meta was set`);try{gt({...this.meta,messages:e})}catch{}return e}setupFlushInterval(){this.enabled&&setInterval(()=>{this.flush()},this.options.batchIntervalSeconds*1e3)}resolveOptions(e){return{batchIntervalSeconds:e?.batchIntervalSeconds??15}}}),Lt=e(import.meta.url),J=Lt.resolve(`@overlayed/app/dist/render-interface/build/overlayed_render_hook_x64.dll`),Rt=Lt.resolve(`@overlayed/app/dist/render-interface/build/overlayed_render_hook_x86.dll`),zt=Lt.resolve(`@overlayed/app/dist/native-interface/build/overlayed_injector_x64.exe`),Bt=Lt.resolve(`@overlayed/app/dist/native-interface/build/overlayed_injector_x86.exe`),Y=D(class extends Ge{boundOnProcessCreate=this.onProcessCreate.bind(this);boundOnProcessDestroy=this.onProcessDestroy.bind(this);subscribedGames=new Set;_activeReadyRavenGames={};get isInGame(){return Object.keys(this._activeReadyRavenGames).length>0}constructor(){super(`GameLaunchManager`)}setSubscribedGames(e){this.subscribedGames=new Set(e)}getActiveGames(){return Object.keys(this._activeReadyRavenGames)}init(){super.init(),It.getInstance().createInterface(`OGG_SIEGE`),Pt.getInstance().on(`create`,this.boundOnProcessCreate),Pt.getInstance().on(`destroy`,this.boundOnProcessDestroy)}destroy(){Pt.getInstance().off(`create`,this.boundOnProcessCreate),Pt.getInstance().off(`destroy`,this.boundOnProcessDestroy),super.destroy()}on(e,t){super.on(e,t);let n=pe(e);if(!(n.includes(`gameReady`)||n.includes(`*`))||Object.keys(this._activeReadyRavenGames).length===0)return;let r=t;for(let e of Object.values(this._activeReadyRavenGames))this.logger.log(`Late calling gameReady callback for game`,e.game),r(e)}async onProcessCreate({process:e}){this.logger.log(`On process create`,e);let t=this.getRavenGame(e);if(!t)return;if(this.logger.log(`Raven game found`,t),t.command_line_regex){this.logger.log(`Performing command line regex check`,{regex:t.command_line_regex});try{let n=e.commandLine;this.logger.log(`Process command line`,n);let r=new RegExp(t.command_line_regex);if(!e.commandLine||!r.test(e.commandLine)){this.logger.log(`Process command line does not match regex, skipping`,{commandLine:e.commandLine,regex:t.command_line_regex});return}}catch(e){this.logger.error(`Failed to check command line`,e);return}}if(q.getInstance().track(`game_launch`,{game:t.identifier}),this.subscribedGames.size===0){this.logger.warn(`No subscribed games, skipping`);return}if(!this.subscribedGames.has(t.identifier)&&!this.subscribedGames.has(`*`))return;let n=new AbortController;if(await this.emit(`gameLaunch`,{game:t.identifier,reject:()=>n.abort()}),n.signal.aborted)return;let r=wt.currentProcess;if(this.logger.log(`Game Launched`,t),this.logger.log(`Process is elevated: `,e.isElevated),this.logger.log(`Current process is elevated: `,r.isElevated),e.isElevated&&!r.isElevated){O.getInstance().fatal(`Game is elevated but the App is not`,`ELEVATION_MISMATCH`,{appElevated:!!r.isElevated,gameElevated:!!e.isElevated}),this.logger.log(`Game elevated but App is not`,{appElevated:r.isElevated,gameElevated:e.isElevated});return}let i=e.createdAt||new Date,a=Math.floor((new Date().getTime()-i.getTime())/1e3);this.logger.log(`Process created ${a}s ago`),a<30&&(this.logger.log(`Delaying injection for 45 seconds to allow game to be ready`),await new Promise(e=>setTimeout(e,1e3*45)));let{ri_disabled:o,gm_disabled:s}=Ot(),c=!1;!o&&t.has_render_support&&t.allow_dll_injections?c=await this.injectRenderInterface(e):this.logger.log(`Skipping render interface injection`,{has_render_support:t.has_render_support,allow_dll_injections:t.allow_dll_injections,ri_disabled:o}),!s&&t.allow_dll_injections?await this.injectGameModules(t,e):this.logger.log(`Skipping game module(s) injection`,{allow_dll_injections:t.allow_dll_injections,gm_disabled:s});let l={game:t.identifier,inGameRenderingSupported:c};this._activeReadyRavenGames[t.identifier]=l,this.logger.debug(`Active ready raven games`,Object.keys(this._activeReadyRavenGames).join(`, `)),this.logger.log(`Game Ready`),this.emit(`gameReadyInternal`,{ravenGame:t,process:e}),this.emit(`gameReady`,l),q.getInstance().track(`game_ready`,{game:t.identifier})}copyInjectors(){let e=this.copyDll(zt),t=this.copyDll(Bt);return!e||!t?(this.logger.error(`Failed to copy injector executables`),!1):h.dirname(e)}copyDll(e){let t=h.basename(e),n=_(e),r=h.join(j(),`resources`),i=h.join(r,t);this.logger.info(`Copying`,n,`to`,i);try{te(r)||ne(r,{recursive:!0}),S(i,re(n)),b(n,i)}catch(e){return e.code===`EBUSY`?i:(this.logger.error(`Failed to copy`,e),this.logger.error(`Failed to copy`,{originalPath:n,targetPath:i}),!1)}return i}async injectRenderInterface(e){this.logger.log(`Injecting render interface`,{is32Bit:e.is32Bit,process:e});let t=e.is32Bit?Rt:J;this.logger.log(`Render hook path`,t);let n=this.copyDll(t);if(!n)return this.logger.error(`Failed to copy render hook DLL`,{renderHookPath:t}),!1;let r=this.copyInjectors();if(!r)return!1;this.logger.log(`Resolved injector path`,r);try{return this.logger.log(`Injecting render interface`,n),await e.injectDll(n,r),this.logger.log(`Render Interface Injection Successful`,n),!0}catch(e){return this.logger.error(`Render Interface Injection Failed`,e),this.logger.error(`Render Interface Injection Failed`,{renderHookPathCopied:n}),!1}}async injectGameModules(e,t){let n=this.copyInjectors();if(n){this.logger.log(`Resolved injector path`,n);for(let r of e.modules){let e=await Mt.getInstance().getDllFile(r);if(!e){this.logger.error(`No DLL file found for module`,{moduleId:r});continue}try{this.logger.log(`Injecting game module`,e),await t.injectDll(e,n),this.logger.log(`Injection Successful`,e)}catch(t){this.logger.error(`Injection Failed`,{dllFile:e},t)}}}}onProcessDestroy({process:e}){let t=this.getRavenGame(e);t&&(delete this._activeReadyRavenGames[t.identifier],this.logger.debug(`Active ready raven games`,Object.keys(this._activeReadyRavenGames).join(`, `)),this.emit(`gameCloseInternal`,{ravenGame:t,process:e}),this.emit(`gameClose`,{game:t.identifier}),q.getInstance().track(`game_close`,{game:t.identifier}))}getRavenGame(e){if(!e.name)return;let t=Nt.getInstance().getExecutableData(e.name);if(!t){this.logger.error(`No raven game found for process`,{process:e});return}return t}}),Vt=D(class extends We{boundOnGameLaunch=this.onGameLaunch.bind(this);constructor(){super(`GameBuildManager`)}init(){super.init(),Y.getInstance().on(`gameReadyInternal`,this.boundOnGameLaunch)}destroy(){Y.getInstance().off(`gameReadyInternal`,this.boundOnGameLaunch),super.destroy()}async onGameLaunch(...e){let[{ravenGame:t,process:n}]=e;if(!n.path||!n.name){this.logger.error(`Process path or name not found, could not check for build hash`,void 0,n);return}let r=re(n.path),i=oe(`sha256`).update(r).digest(`hex`);this.logger.log(`Process Path`,n.path),this.logger.log(`Process Name`,n.name),this.logger.log(`Build Hash`,i);let a=!1;try{a=(await pt(t.identifier,i)).data.upload}catch(e){this.logger.error(`Error checking game build hash`,e);return}if(!a){this.logger.log(`Build hash already exists, skipping upload`);return}let o=new ce;o.file(n.name,r);let s=await o.generateAsync({type:`blob`});try{this.logger.log(`Uploading build (size: `,s.size,` bytes)`);let e=new N(s,{chunkSizeMb:25,maxConcurrent:1}),n=await mt(t.identifier,{build_hash:i,chunk_count:e.totalChunks,file_size_bytes:s.size});await e.chunk(async(e,r)=>{this.logger.log(`Uploading chunk`,r),await ht(t.identifier,{chunk:e,build_hash:i,chunk_index:r,upload_token:n.data.upload_token})}),this.logger.log(`Build uploaded successfully`)}catch(e){vt(e)?yt(e.response)?this.logger.error(`Error uploading build hash, api error`,e):this.logger.error(`Error uploading build hash, request error`,e):this.logger.error(`Error uploading build hash, unknown error`,e)}}}),Ht=D(class extends We{constructor(){super(`CampaignManager`)}async check(e){let t=h.join(Se(e),`campaign_code.txt`);try{let e=(await w.readFile(t,`utf-8`)).trim().replace(/ \(\d+\)/g,``);e&&(this.logger.log(`UTM campaign code found`,e),q.getInstance().track(`utm_attribution`,{campaign_code:e}),q.getInstance().flush())}catch{}}}),Ut=new k({path:f.normalize(`${process.env.APPDATA||process.env.HOME||`.`}/.overlayed/config.json`),default:void 0,schema:t({Account:n({email:`string`,apiKey:`string`,"applicationId?":`string`,"baseUrl?":`string`})}).type({currentAccount:`Account | undefined`,accounts:`Account[]`}).or(`undefined`)});function Wt(e,t){let n=t.applicationId===void 0||e.applicationId===void 0||e.applicationId===t.applicationId,r=(e.baseUrl??`https://api.overlayed.gg`)===t.baseUrl;return n&&r}function Gt(e){let{currentAccount:t,accounts:n,expected:r}=e;if(t&&Wt(t,r))return{account:t,source:`current`};let i=n.find(e=>Wt(e,r));if(i)return{account:i,source:`other`}}function Kt(e,t){return`${e}:${t}`}function qt(e,t,n){return e.reduce((e,r)=>{let i=r.key;return e[i]={on(e,n){let r=Kt(i,e),a=t.get(r)??new Set;a.add(n),t.set(r,a)},onAny(e){let n=Kt(i,`*`),r=t.get(n)??new Set;r.add(e),t.set(n,r)},off(e,n){let r=Kt(i,e),a=t.get(r);a&&(a.delete(n),a.size===0&&t.delete(r))},offAny(e){let n=Kt(i,`*`),r=t.get(n);r&&(r.delete(e),r.size===0&&t.delete(n))},readyForGameEvents:()=>{n.emit(`flushEvents`,i)}},e},{})}function Jt(){let e=O.getInstance(),t=Y.getInstance();return{on:(n,r)=>{switch(n){case`fatal`:e.on(`fatal`,r);break;case`error`:e.on(`error`,r);break;case`warning`:e.on(`warning`,r);break;case`gameLaunch`:t.on(`gameLaunch`,r);break;case`gameClose`:t.on(`gameClose`,r);break;case`gameReady`:t.on(`gameReady`,r);break;default:throw Error(`Event type not implemented ${n}`,{cause:[n,r]})}},off:(n,r)=>{switch(n){case`fatal`:e.off(`fatal`,r);break;case`error`:e.off(`error`,r);break;case`warning`:e.off(`warning`,r);break;case`gameLaunch`:t.off(`gameLaunch`,r);break;case`gameClose`:t.off(`gameClose`,r);break;case`gameReady`:t.off(`gameReady`,r);break;default:throw Error(`Event type not implemented ${n}`,{cause:[n,r]})}}}}const Yt=new Map([[1,`LeftButton`],[2,`RightButton`],[3,`Cancel`],[4,`MiddleButton`],[5,`ExtraButton1`],[6,`ExtraButton2`],[8,`Backspace`],[9,`Tab`],[12,`Clear`],[13,`Enter`],[16,`ShiftLeft`],[17,`ControlLeft`],[18,`AltLeft`],[19,`Pause`],[20,`CapsLock`],[21,`KanaMode`],[23,`JunjaMode`],[24,`Finalize`],[25,`HanjaMode`],[27,`Escape`],[28,`Convert`],[29,`NonConvert`],[30,`Accept`],[31,`ModeChange`],[32,`Space`],[33,`PageUp`],[34,`PageDown`],[35,`End`],[36,`Home`],[37,`ArrowLeft`],[38,`ArrowUp`],[39,`ArrowRight`],[40,`ArrowDown`],[41,`Select`],[42,`PrintScreen`],[43,`Execute`],[44,`Snapshot`],[45,`Insert`],[46,`Delete`],[47,`Help`],[48,`Digit0`],[49,`Digit1`],[50,`Digit2`],[51,`Digit3`],[52,`Digit4`],[53,`Digit5`],[54,`Digit6`],[55,`Digit7`],[56,`Digit8`],[57,`Digit9`],[65,`KeyA`],[66,`KeyB`],[67,`KeyC`],[68,`KeyD`],[69,`KeyE`],[70,`KeyF`],[71,`KeyG`],[72,`KeyH`],[73,`KeyI`],[74,`KeyJ`],[75,`KeyK`],[76,`KeyL`],[77,`KeyM`],[78,`KeyN`],[79,`KeyO`],[80,`KeyP`],[81,`KeyQ`],[82,`KeyR`],[83,`KeyS`],[84,`KeyT`],[85,`KeyU`],[86,`KeyV`],[87,`KeyW`],[88,`KeyX`],[89,`KeyY`],[90,`KeyZ`],[91,`MetaLeft`],[92,`MetaRight`],[93,`ContextMenu`],[95,`Sleep`],[96,`Numpad0`],[97,`Numpad1`],[98,`Numpad2`],[99,`Numpad3`],[100,`Numpad4`],[101,`Numpad5`],[102,`Numpad6`],[103,`Numpad7`],[104,`Numpad8`],[105,`Numpad9`],[106,`NumpadMultiply`],[107,`NumpadAdd`],[108,`NumpadSeparator`],[109,`NumpadSubtract`],[110,`NumpadDecimal`],[111,`NumpadDivide`],[112,`F1`],[113,`F2`],[114,`F3`],[115,`F4`],[116,`F5`],[117,`F6`],[118,`F7`],[119,`F8`],[120,`F9`],[121,`F10`],[122,`F11`],[123,`F12`],[124,`F13`],[125,`F14`],[126,`F15`],[127,`F16`],[128,`F17`],[129,`F18`],[130,`F19`],[131,`F20`],[132,`F21`],[133,`F22`],[134,`F23`],[135,`F24`],[144,`NumLock`],[145,`ScrollLock`],[146,`NEC_Equal`],[147,`Fujitsu_Masshou`],[148,`Fujitsu_Touroku`],[149,`Fujitsu_Loya`],[150,`Fujitsu_Roya`],[160,`ShiftLeft`],[161,`ShiftRight`],[162,`ControlLeft`],[163,`ControlRight`],[164,`AltLeft`],[165,`AltRight`],[166,`BrowserBack`],[167,`BrowserForward`],[168,`BrowserRefresh`],[169,`BrowserStop`],[170,`BrowserSearch`],[171,`BrowserFavorites`],[172,`BrowserHome`],[173,`VolumeMute`],[174,`VolumeDown`],[175,`VolumeUp`],[176,`MediaTrackNext`],[177,`MediaTrackPrevious`],[178,`MediaStop`],[179,`MediaPlayPause`],[180,`LaunchMail`],[181,`LaunchMediaSelect`],[182,`LaunchApplication1`],[183,`LaunchApplication2`],[186,`OEM_1`],[187,`Equal`],[188,`Comma`],[189,`Minus`],[190,`Period`],[191,`Slash`],[192,`Backquote`],[219,`BracketLeft`],[220,`Backslash`],[221,`BracketRight`],[222,`Quote`],[223,`IntlRo`],[225,`OEM_AX`],[226,`IntlBackslash`],[227,`ICO_HELP`],[228,`ICO_00`],[229,`Process`],[230,`ICO_CLEAR`],[231,`Packet`],[233,`OEM_Reset`],[234,`OEM_Jump`],[235,`OEM_PA1`],[236,`OEM_PA2`],[237,`OEM_PA3`],[238,`OEM_WS_Ctrl`],[239,`OEM_CU_Sel`],[240,`OEM_ATTN`],[241,`OEM_Finish`],[242,`OEM_Copy`],[243,`OEM_Auto`],[244,`OEM_ENLW`],[245,`BackTab`],[246,`ATTN`],[247,`CRSel`],[248,`EXSel`],[249,`EREOF`],[250,`MediaPlay`],[251,`Zoom`],[252,`Noname`],[253,`PA1`],[254,`OEM_Clear`]]),Xt=new Map(Yt.entries().map(([e,t])=>[t,e])),Zt=n({"[string]":{keys:`string[]`,mode:n(`'toggle' | 'hold'`).pipe(e=>e??`toggle`)}});var Qt=class extends L{preferencesKeybindToCallbacks=new Map;pressedKeys=new Set;activeKeybinds=new Set;triggeredToggleKeybinds=new Set;boundHandleKeyboardFocus=this.handleKeyboardFocus.bind(this);boundHandleKeyDown=this.handleKeyDown.bind(this);boundHandleKeyUp=this.handleKeyUp.bind(this);keybindsFile;keybindListeningPaused=!1;constructor(e){super(`KeybindManager`),this.keybindsFile=new k({path:Et([`keybinds.json`]),schema:Zt,default:e})}init(){super.init();let e=It.getInstance().getInterface(`OGG_SIEGE`);e.instance.on(`keyboardFocus`,this.boundHandleKeyboardFocus),e.instance.on(`keyDown`,this.boundHandleKeyDown),e.instance.on(`keyUp`,this.boundHandleKeyUp)}async onKeybindToggled(e,t){let n=this.preferencesKeybindToCallbacks.get(e)??{toggle:[],down:[],up:[]};n.toggle.push(t),this.preferencesKeybindToCallbacks.set(e,n)}async onKeybindDown(e,t){let n=this.preferencesKeybindToCallbacks.get(e)??{toggle:[],down:[],up:[]};n.down.push(t),this.preferencesKeybindToCallbacks.set(e,n)}async onKeybindUp(e,t){let n=this.preferencesKeybindToCallbacks.get(e)??{toggle:[],down:[],up:[]};n.up.push(t),this.preferencesKeybindToCallbacks.set(e,n)}async updateKeybind(e,t){this.keybindsFile.set({[e]:t})}async updateKeybinds(e){let t=Object.fromEntries(Object.entries(e).filter(([e,t])=>t!==void 0));this.keybindsFile.set({...this.keybindsFile.get(),...t})}getConfig(){return this.keybindsFile.get()}destroy(){let e=It.getInstance().getInterface(`OGG_SIEGE`);e.instance.off(`keyboardFocus`,this.boundHandleKeyboardFocus),e.instance.off(`keyDown`,this.boundHandleKeyDown),e.instance.off(`keyUp`,this.boundHandleKeyUp),super.destroy()}handleKeyDown(e){if(this.keybindListeningPaused)return;let t=Yt.get(e.key);if(!t){this.logger.error(`Unknown key down`,e);return}this.pressedKeys.add(t),this.checkKeybindings()}handleKeyboardFocus(){this.pressedKeys.clear(),this.activeKeybinds.clear(),this.triggeredToggleKeybinds.clear()}async handleKeyUp(e){if(this.keybindListeningPaused)return;let t=Yt.get(e.key);if(!t)return;this.pressedKeys.delete(t);let n=this.keybindsFile.get();for(let[e]of this.preferencesKeybindToCallbacks.entries())n[e].keys.includes(t)&&this.triggeredToggleKeybinds.delete(e);this.checkKeybindUps()}async checkKeybindUps(){let e=this.keybindsFile.get();for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){if(!n.up||n.up.length===0)continue;let r=e[t];if(this.activeKeybinds.has(t)&&r.keys.some(e=>!this.pressedKeys.has(e))){this.activeKeybinds.delete(t);for(let e of n.up)e();this.logger.log(`Keybind up triggered`,this.getKeybindToString(r))}}}async checkKeybindings(){let e=this.keybindsFile.get();for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){let r=e[t];if(r.keys.length===this.pressedKeys.size&&r.keys.every(e=>Xt.has(e)?this.pressedKeys.has(e):!1)){this.triggerKeybind(r,n,t);return}}for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){let r=e[t];r.keys.every(e=>Xt.has(e)?this.pressedKeys.has(e):(this.logger.error(`Unknown key`,e,r),!1))&&this.triggerKeybind(r,n,t)}}triggerKeybind(e,t,n){let r=e.mode;if(r===`toggle`&&t.toggle&&t.toggle.length>0&&!this.triggeredToggleKeybinds.has(n)){let r;for(let e of t.toggle){let t=e();typeof t==`string`&&r===void 0&&(r=t)}this.triggeredToggleKeybinds.add(n),this.logger.log(r?`Keybind pressed rejected: ${r}`:`Keybind pressed accepted`,this.getKeybindToString(e))}if(r===`hold`&&t.down&&t.down.length>0&&!this.activeKeybinds.has(n)){let r;for(let e of t.down){let t=e();if(typeof t==`string`){r=t;break}}r?this.logger.log(`Keybind down rejected: ${r}`,this.getKeybindToString(e)):(this.activeKeybinds.add(n),this.logger.log(`Keybind down accepted`,this.getKeybindToString(e)))}}getKeybindToString(e){return`(${e.keys.join(`+`)}${e.mode?` ${e.mode}`:``})`}};function $t(e){let t=new Qt(e),n={};for(let r in e)n[r]={on:(e,n)=>{switch(e){case`down`:t.onKeybindDown(r,n);break;case`up`:t.onKeybindUp(r,n);break;case`toggle`:t.onKeybindToggled(r,n);break;default:throw Error(`Event type not implemented ${e}`,{cause:[e,n]})}}};let r={...n,getConfig:()=>t.getConfig(),pauseKeybindListening:()=>{t.keybindListeningPaused=!0},resumeKeybindListening:()=>{t.keybindListeningPaused=!1},updateKeybind:(e,n)=>{t.updateKeybind(e,n)},updateKeybinds:e=>{t.updateKeybinds(e)}};return t.init(),T.on(`quit`,()=>{t.destroy()}),r}function X(){return It.getInstance().getInterface(`OGG_SIEGE`)}function en(){let e=Y.getInstance(),t=O.getInstance(),n=q.getInstance();if(!T.isPackaged){M.getInstance().info(`Cortex is disabled in development`),n.enabled=!1;return}try{n.meta=tn()}catch(e){M.getInstance().error(`Failed to setup cortex`,e);return}e.on([`gameReady`,`gameClose`],()=>{n.meta||=tn(),n.meta.in_game=e.isInGame}),t.on(`fatal`,e=>{n.track(`fatal`,{message:e.message,code:e.code,data:JSON.stringify(e.data)})}),t.on(`error`,e=>{n.track(`error`,{code:e.code,message:e.message,data:JSON.stringify(e.data)})}),t.on(`warning`,e=>{n.track(`warning`,{message:e.message,code:e.code,data:JSON.stringify(e.data)})})}function tn(){if(!global.OVERLAYED_META.release.id)throw Error(`Release ID is required`);return{app_id:global.OVERLAYED.APPLICATION_ID,user_id:kt(),release_id:global.OVERLAYED_META.release.id,app_channel:global.OVERLAYED.APP_BUILD_CHANNEL,app_version:global.OVERLAYED.APP_VERSION,package_version:global.OVERLAYED.PACKAGE_VERSION,frontend_version:global.OVERLAYED.FRONTEND_VERSION,frontend_release_id:global.OVERLAYED.FRONTEND_RELEASE_ID,session_id:global.OVERLAYED.sessionId,in_game:!1}}const nn=D(class extends L{CHECK_INTERVAL=1e3*60*15;RETRY_INTERVAL=1e3*15;_updateCheckInterval=null;_latestCheckResponse=null;_activeCheckResponse=null;initialReleaseId=null;get manualUpdatesEnabled(){return this.options?.manualUpdates??!1}get activeReleaseId(){return this._activeCheckResponse?.release_id??this.initialReleaseId}constructor(){super(`SiteManager`)}init(e){super.init(e),e?.manualUpdates&&this.enableManualUpdates()}destroy(){super.destroy(),this._updateCheckInterval&&=(clearInterval(this._updateCheckInterval),null)}allowSiteUpdateOnNextLoad(){if(!this.options?.manualUpdates){this.logger.warn(`allowSiteUpdateOnNextLoad called but manual updates are disabled`);return}if(!this._latestCheckResponse){this.logger.warn(`allowSiteUpdateOnNextLoad called but no update has been checked yet`);return}if(this._activeCheckResponse?.release_id===this._latestCheckResponse.release_id){this.logger.warn(`allowSiteUpdateOnNextLoad called but theres no update available`);return}this._activeCheckResponse=this._latestCheckResponse,q.getInstance().track(`site_update_applied`,{version:this._latestCheckResponse.version,release_id:this._latestCheckResponse.release_id}),this.setFrontendCortexMeta(this._latestCheckResponse.release_id,this._latestCheckResponse.version)}setFrontendCortexMeta(e,t){let n=q.getInstance();n.meta||=tn(),e&&(global.OVERLAYED.FRONTEND_RELEASE_ID=e,n.meta.frontend_release_id=e),t&&(global.OVERLAYED.FRONTEND_VERSION=t,n.meta.frontend_version=t),e&&t&&n.track(`frontend_version_changed`,{version:t,release_id:e})}enableManualUpdates(){this.logger.log(`Enabling manual site updates`),this.checkForUpdates(),this._updateCheckInterval=setInterval(()=>{this.checkForUpdates(!0)},this.CHECK_INTERVAL)}async checkForUpdates(e=!1){let t=global.OVERLAYED_META?.application?.siteUrl;if(!t){this.logger.log(`No siteUrl configured, skipping check`);return}q.getInstance().track(`site_check_for_update`,{});try{let n=new URL(`/check`,t).toString();this.logger.log(`Checking site URL`,n);let r={"Overlayed-User-Agent":z({package_version:global.OVERLAYED.PACKAGE_VERSION,application_id:global.OVERLAYED.APPLICATION_ID,application_version:global.OVERLAYED.APP_VERSION}),"Overlayed-Cortex-User-Id":global.OVERLAYED_RUNTIME.userId},i=G();i&&(r[`Overlayed-Access-Token`]=i);let a=global.OVERLAYED_META.release.channelId;a&&(r[`Overlayed-Channel-Id`]=a);let o=await fetch(n,{headers:r});if(!o.ok){this.logger.warn(`Site check failed with status`,o.status),q.getInstance().track(`site_check_error`,{status:o.status}),e&&this.scheduleRetry();return}let s=await o.json();if(this.logger.log(`Site check response`,s),!s.release_id){this.logger.error(`Site check response missing release_id`);return}if(!this._latestCheckResponse){this._latestCheckResponse=s;return}return this._latestCheckResponse.release_id===s.release_id?void 0:(this.logger.log(`New site version detected`,s),this._latestCheckResponse=s,q.getInstance().track(`site_update_ready`,{version:s.version,release_id:s.release_id}),this.emit(`siteUpdateReady`,{releaseId:s.release_id,version:s.version}),s)}catch(e){let t=e instanceof Error?e.message:String(e);q.getInstance().track(`site_check_error`,{message:t}),this.logger.error(`Site check failed`,{error:e,message:t}),this.scheduleRetry()}}scheduleRetry(){setTimeout(()=>{this.checkForUpdates()},this.RETRY_INTERVAL)}}),rn=D(Ee,`browser-windows.log`);let an;function on(){return an||(an=class e extends global.OVERLAYED.electron.BrowserWindow{static session=void 0;constructor(t){let n=e.resolveCustomOptions(t);super(n)}static resolveCustomOptions(t){let n=global.OVERLAYED_META,r=global.OVERLAYED_RUNTIME;return{...t,webPreferences:{...t.webPreferences,session:e.getSession(),additionalArguments:[...t.webPreferences?.additionalArguments||[],...global.OVERLAYED.electron.app.isPackaged?[]:[`--overlayed-meta=${JSON.stringify(n)}`],`--overlayed-runtime=${JSON.stringify(r)}`]}}}static getSession(){if(!global.OVERLAYED_META?.application?.siteUrl)return;if(e.session)return e.session;e.session=global.OVERLAYED.electron.session.fromPartition(`persist:overlayed-${global.OVERLAYED.APPLICATION_ID}`);let t=nn.getInstance(),n=z({package_version:global.OVERLAYED.PACKAGE_VERSION,application_id:global.OVERLAYED.APPLICATION_ID,application_version:global.OVERLAYED.APP_VERSION}),r={urls:[global.OVERLAYED_META.application.siteUrl+`/*`]},i=global.OVERLAYED_RUNTIME.userId;return e.session.webRequest.onBeforeSendHeaders(r,(e,r)=>{let a=G();a&&(e.requestHeaders[`Overlayed-Access-Token`]=a);let o=global.OVERLAYED_META.release.channelId;o&&(e.requestHeaders[`Overlayed-Channel-Id`]=o),t.manualUpdatesEnabled&&t.activeReleaseId&&(e.requestHeaders[`Overlayed-Release-Id`]=t.activeReleaseId),e.requestHeaders[`Overlayed-Cortex-User-Id`]=i,e.requestHeaders[`Overlayed-User-Agent`]=n,r({requestHeaders:e.requestHeaders})}),t.manualUpdatesEnabled&&e.session.webRequest.onHeadersReceived(r,(e,n)=>{if(t.initialReleaseId){n(e);return}let r=e.responseHeaders?.[`Overlayed-Release-Id`]?.[0];r&&(t.initialReleaseId=st(r));let i=e.responseHeaders?.[`Overlayed-Release-Version`]?.[0];t.setFrontendCortexMeta(r,i),n(e)}),e.session}},an)}function sn(){function e(e,t){let n=rn.getInstance();return e.once(`closed`,()=>{e.isDestroyed()||q.getInstance().track(`window_closed`,{url:e.webContents.getURL(),in_game:t})}),e.on(`unresponsive`,()=>{e.isDestroyed()||q.getInstance().track(`window_unresponsive`,{url:e.webContents.getURL(),in_game:t})}),e.webContents.on(`console-message`,(t,r,i,a,o)=>{let s=e.isDestroyed()?`destroyed`:e.webContents.getURL();n[r===3?`error`:r===2?`warn`:`log`](`[${s}] [${o}:${a}] ${i}`)}),q.getInstance().track(`window_created`,{url:e.webContents.getURL(),in_game:t}),e}return{getProductionSiteUrl:()=>{let e=global.OVERLAYED_META.application.siteUrl;return URL.canParse(e)?new URL(e):new URL(`https://default.overlayedapps.com`)},createWindow:t=>e(new(on())(t),!1),createInGameWindow:t=>{let n=on();return e(X().instance.newWindowInternal(n,t),!0)},on:(e,t)=>X().instance.on(e,t),off:(e,t)=>X().instance.off(e,t),once:(e,t)=>X().instance.once(e,t),addListener:(e,t)=>X().instance.addListener(e,t),removeListener:(e,t)=>X().instance.removeListener(e,t),removeAllListeners:()=>X().instance.removeAllListeners(),prependListener:(e,t)=>X().instance.prependListener(e,t),prependOnceListener:(e,t)=>X().instance.prependOnceListener(e,t),getActiveGameInfo:()=>{let e=X(),t=Ie.getInstance();return{resolution:e.resolution,isConnected:t.hasConnection}}}}const cn=D(class extends We{renderInterface;globalCursorOverrideCount=new Set;globalMouseBlockCount=new Set;globalKeyboardBlockCount=new Set;keyInputBlocks={};constructor(e){super(`OverridesManager`),this.renderInterface=It.getInstance().getInterface(e)}scope(e){return{setGlobalCursorOverride:t=>this.setGlobalCursorOverride(e,t),setGlobalMouseBlock:t=>this.setGlobalMouseBlock(e,t),setGlobalKeyboardBlock:t=>this.setGlobalKeyboardBlock(e,t),setKeyInputBlock:(t,n)=>this.setKeyInputBlock(e,t,n)}}setGlobalCursorOverride(e,t){t?this.globalCursorOverrideCount.add(e):this.globalCursorOverrideCount.delete(e),t&&this.globalCursorOverrideCount.size===1?this.renderInterface.instance.setGlobalCursorOverride(!0):!t&&this.globalCursorOverrideCount.size===0&&this.renderInterface.instance.setGlobalCursorOverride(!1)}setGlobalMouseBlock(e,t){t?this.globalMouseBlockCount.add(e):this.globalMouseBlockCount.delete(e),t&&this.globalMouseBlockCount.size===1?this.renderInterface.instance.setGlobalMouseBlock(!0):!t&&this.globalMouseBlockCount.size===0&&this.renderInterface.instance.setGlobalMouseBlock(!1)}setGlobalKeyboardBlock(e,t){t?this.globalKeyboardBlockCount.add(e):this.globalKeyboardBlockCount.delete(e),t&&this.globalKeyboardBlockCount.size===1?this.renderInterface.instance.setGlobalKeyboardBlock(!0):!t&&this.globalKeyboardBlockCount.size===0&&this.renderInterface.instance.setGlobalKeyboardBlock(!1)}setKeyInputBlock(e,t,n){this.keyInputBlocks[t]||(this.keyInputBlocks[t]=new Set),n?this.keyInputBlocks[t].add(e):this.keyInputBlocks[t].delete(e),n&&this.keyInputBlocks[t].size===1?this.renderInterface.instance.setKeyInputBlock(t,!0):!n&&this.keyInputBlocks[t].size===0&&this.renderInterface.instance.setKeyInputBlock(t,!1)}},`OGG_SIEGE`);function ln(){return{scope:e=>cn.getInstance().scope(e),raw:{setGlobalMouseBlock:e=>X().instance.setGlobalMouseBlock(e),setGlobalKeyboardBlock:e=>X().instance.setGlobalKeyboardBlock(e),setGlobalCursorOverride:e=>X().instance.setGlobalCursorOverride(e),setKeyInputBlock:(e,t)=>X().instance.setKeyInputBlock(e,t),getGlobalMouseBlock:()=>X().instance.getGlobalMouseBlock(),getGlobalKeyboardBlock:()=>X().instance.getGlobalKeyboardBlock(),getGlobalCursorOverride:()=>X().instance.getGlobalCursorOverride(),getKeyInputBlock:e=>X().instance.getKeyInputBlock(e)}}}function un(){return{track:(e,t)=>{q.getInstance().track(`custom__${String(e)}`,t)}}}function dn(){return{registerWindow:()=>{}}}const fn=/(\d{4})-(\d{2})-(\d{2})\.log$/;function pn(e){let t=e.match(fn);if(!t)return!1;let[,n,r,i]=t,a=Number(n),o=Number(r),s=Number(i);if(o<1||o>12||s<1||s>31)return!1;let c=new Date(a,o-1,s);if(isNaN(c.getTime())||c.getFullYear()!==a||c.getMonth()!==o-1||c.getDate()!==s)return!1;let l=new Date;return l.setDate(l.getDate()-7),l.setHours(0,0,0,0),c>=l}function mn(e){let{silent:t=!1,additionalFiles:n}=e??{},r=Ce(global.OVERLAYED.APPLICATION_ID),i=P(r,{recursive:!0}),a=xe(),o=P(a,{recursive:!0});t||(M.getInstance().info(`Logs path: `,r),M.getInstance().info(`Overlayed logs path: `,a));let s=new ce;return i.forEach(([e,n])=>{t||M.getInstance().info(`Zipping: `,n);let r=x(n);s.file(g(n),r,{compression:`DEFLATE`})}),o.forEach(([e,n])=>{if(!pn(g(n))){t||M.getInstance().info(`Skipping old/unrecognized log: `,n);return}t||M.getInstance().info(`Zipping: `,n);let r=x(n);s.file(g(n),r,{compression:`DEFLATE`})}),n&&Object.entries(n).forEach(([e,n])=>{t||M.getInstance().info(`Zipping extra file: `,e),s.file(e,n,{compression:`DEFLATE`})}),s}async function hn(e,t,n){let r=global.OVERLAYED_META.release.id?st(global.OVERLAYED_META.release.id):void 0,i=kt();return it(global.OVERLAYED.APPLICATION_ID,{file:Buffer.from(n,`base64`),data:{release_id:r,type:e,cortex_user_id:i,...t}}).then(e=>(M.getInstance().info(`Feedback submitted`,e),e.data.id)).catch(e=>{console.error(JSON.stringify(e,null,2)),M.getInstance().error(`Failed to submit feedback`,e)})}function gn(e){let t=new Ee(`app.log`);return t.init(global.OVERLAYED.APPLICATION_ID,e.debug),{scope:e=>t.scope(e),info:e=>t.info(e),warn:e=>t.warn(e),error:e=>t.error(e),debug:e=>t.debug(e),submitFeedback:async(e,t,n)=>{let r=global.OVERLAYED_META.release.id?st(global.OVERLAYED_META.release.id):void 0;return r&&T.isPackaged&&q.getInstance().track(e===`bug_report`?`bug_report_submitted`:`suggestion_submitted`,{release_id:r}),await hn(e,t,await mn(n).generateAsync({type:`base64`}))},getLogsZip:e=>mn(e)}}const _n=1e3;function vn(e,t,r,i,a){let o=Ie.getInstance(),s=M.getInstance().scope(`SetupPipeServer`);s.log(`Initializing`);function c(e,t){let n=r.get(t);if(!n)r.set(t,[e]);else{if(n.length>=_n){O.getInstance().warn(`Event buffer full, removing oldest event`,`EVENT_BUFFER_FULL`,{summary:`Event buffer overflow for module ${t}. Buffer size: ${n.length}, max: ${_n}`});return}n.push(e)}}function l(r){s.info(r);let i=Dt(r);if(i instanceof n.errors){q.getInstance().track(`invalid_game_event`,{}),O.getInstance().warn(`Invalid event`,`INVALID_EVENT`,{summary:i.summary});return}let o=He.includes(i.type),l=e.modules.find(e=>e.key===`universal`),u=o?l:e.modules.find(e=>e.key===i.game);if(!u){s.warn(`Invalid module`,{module:o?`universal`:i.game});return}let d=u.events.event,f=d(r);if(f instanceof n.errors){if(`type`in f.byPath)return;s.warn(`Invalid event`,{summary:f.summary}),q.getInstance().track(`invalid_game_event`,{game:i.game,type:i.type,summary:f.summary}),O.getInstance().warn(`Invalid event`,`INVALID_EVENT`,{summary:f.summary});return}if(!a[u.key]){c(f,u.key);return}if(f.type===`unsupported_game_version`){let{content:e}=f;q.getInstance().track(`unsupported_game_version`,{game:f.game,hash:e.process_hash,version:e.game_version})}let p=Kt(u.key,f.type),m=Kt(u.key,`*`),h=t.get(p),g=t.get(m),_=[...Array.from(h??[]),...Array.from(g??[])];if(_.length===0){s.info(`No handlers found for event`,{event:f});return}_.forEach(e=>{e(f)})}return i.on(`flushEvents`,e=>{if(a[e])return;a[e]=!0;let t=r.get(e);t&&(M.getInstance().info(`Flushing ${t.length} events for module ${e}`),t.forEach(e=>l(e)),r.delete(e))}),o.on(`data`,e=>e.forEach(l)),o.on(`error`,e=>{s.error(`Pipe server error`,e),O.getInstance().error(`Pipe server error`,`PIPE_SERVER_ERROR`,{error:e})}),o.on(`connected`,()=>{s.log(`Pipe server connected`)}),o.on(`disconnected`,()=>{s.log(`Pipe server disconnected`)}),o}const yn=D(class extends L{FETCH_INTERVAL=1e3*60*10;_fetchInterval=null;_flags=new Map;_overrides=new Map;_defaults=new Map;_boundOnGameReady=this.onGameEvent.bind(this);_boundOnGameClose=this.onGameEvent.bind(this);_readyResolve;ready;constructor(){super(`FeatureFlagManager`),this.ready=new Promise(e=>{this._readyResolve=e}),this.fetchFlags(),this.setupInterval(),Y.getInstance().on(`gameReady`,this._boundOnGameReady),Y.getInstance().on(`gameClose`,this._boundOnGameClose)}destroy(){this._fetchInterval&&=(clearInterval(this._fetchInterval),null),Y.getInstance().off(`gameReady`,this._boundOnGameReady),Y.getInstance().off(`gameClose`,this._boundOnGameClose),super.destroy()}setDefaults(e){this._defaults=new Map(Object.entries(e))}async refresh(){await this.fetchFlags()}override(e,t){let n=this.get(e);this._overrides.set(e,t),n!==t&&(this.emit(e,t),this.emit(`updated`,!0))}clearOverride(e){if(!this._overrides.has(e))return;let t=this.get(e);this._overrides.delete(e);let n=this.get(e);t!==n&&(this.emit(e,n),this.emit(`updated`,!0))}clearOverrides(){if(this._overrides.size===0)return;let e=new Map;for(let t of this._overrides.keys())e.set(t,this.get(t));this._overrides.clear();let t=!1;for(let[n,r]of e){let e=this.get(n);r!==e&&(this.emit(n,e),t=!0)}t&&this.emit(`updated`,!0)}isOverridden(e){return this._overrides.has(e)}getAllOverrides(){return Object.fromEntries(this._overrides)}inspect(e){let t=this._overrides.get(e),n=this._flags.get(e),r=this._defaults.get(e);return{effective:t??n??r??!1,override:t,actual:n,default:r}}get(e){let t=this._overrides.get(e),n=this._flags.get(e),r=this._defaults.get(e);return t??n??r??!1}getAll(){let e=Object.fromEntries(this._defaults);for(let[t,n]of this._flags)e[t]=n;for(let[t,n]of this._overrides)e[t]=n;return e}onGameEvent(){this.fetchFlags()}setupInterval(){this._fetchInterval=setInterval(()=>{this.fetchFlags()},this.FETCH_INTERVAL)}async fetchFlags(){try{let e=Y.getInstance().getActiveGames(),{data:t}=await at(global.OVERLAYED.APPLICATION_ID,{cortex_user_id:global.OVERLAYED_RUNTIME.userId,release_id:global.OVERLAYED_META.release.id??void 0,channel_id:global.OVERLAYED_META.release.channelId??void 0,active_games:e.map(e=>e.toString())??void 0}),n=new Map;for(let e of t)n.set(e.name,e.enabled);for(let[e,t]of n){if(this._overrides.has(e))continue;let n=this._flags.get(e);n!==void 0&&n!==t&&this.emit(e,t)}for(let[e]of this._flags)this._overrides.has(e)||n.has(e)||this.emit(e,this._defaults.get(e)??!1);this._flags=n;for(let e of this._defaults.keys())this._flags.has(e)||this.logger.warn(`Registered feature flag "${e}" was not found in the API response`);this.emit(`updated`,!0)}catch(e){this.logger.error(`Failed to fetch feature flags`,e)}finally{this._readyResolve()}}});function bn(e){let t=yn.getInstance();return e&&t.setDefaults(e),{on:(e,n)=>t.on(e,n),off:(e,n)=>t.off(e,n),ready:t.ready,get:e=>t.get(e),getAll:()=>t.getAll(),refresh:()=>t.refresh(),override:(e,n)=>t.override(e,n),clearOverride:e=>t.clearOverride(e),clearOverrides:()=>t.clearOverrides(),isOverridden:e=>t.isOverridden(e),getAllOverrides:()=>t.getAllOverrides(),inspect:e=>t.inspect(e)}}function xn(){let e=nn.getInstance();return{on:(t,n)=>{e.on(t,n)},off:(t,n)=>{e.off(t,n)},allowSiteUpdateOnNextLoad:()=>{e.allowSiteUpdateOnNextLoad()}}}const Sn=n({dismissedNotices:fe(n.string).array()}),Cn=D(class extends L{NOTICE_FETCH_INTERVAL=1e3*60*10;MAX_DISMISSED_NOTICES=100;_noticeFetchInterval=null;_notices=[];_noticesFile;_boundOnGameReady=this.onGameReady.bind(this);get notices(){let e=this._noticesFile.get().dismissedNotices;return this._notices.filter(t=>!e.includes(t.id))}constructor(){super(`NoticeManager`),this._noticesFile=this.getNoticesFile(),this._noticesFile.load(),this.fetchNotices(),this.setupNoticeInterval(),Y.getInstance().on(`gameReady`,this._boundOnGameReady)}destroy(){this._noticeFetchInterval&&=(clearInterval(this._noticeFetchInterval),null),Y.getInstance().off(`gameReady`,this._boundOnGameReady),super.destroy()}dismissNotice(e){let t=this._notices.find(t=>t.id===e);if(!t||!t.dismissible)return;let n=this._noticesFile.get().dismissedNotices;n.unshift(e),this._noticesFile.set({dismissedNotices:n.slice(0,this.MAX_DISMISSED_NOTICES)}),this.emitNoticesUpdated()}onGameReady(){this.fetchNotices()}setupNoticeInterval(){this._noticeFetchInterval=setInterval(()=>{this.fetchNotices()},this.NOTICE_FETCH_INTERVAL)}getNoticesFile(){return new k({path:Et([`notices.json`]),schema:Sn,default:{dismissedNotices:[]}})}async fetchNotices(){let e=Y.getInstance().getActiveGames();try{let{data:t}=await ot(global.OVERLAYED.APPLICATION_ID,{release_id:global.OVERLAYED_META.release.id?st(global.OVERLAYED_META.release.id):void 0,channel:global.OVERLAYED_META.release.channel,version:global.OVERLAYED_META.release.version,games:e});this._notices=t,this.emitNoticesUpdated()}catch(e){this.logger.error(`Failed to fetch notices`,e)}}emitNoticesUpdated(){this.emit(`noticesUpdated`,{notices:this.notices})}});function wn(){let e=Cn.getInstance();return{on:(t,n)=>{e.on(t,n)},off:(t,n)=>{e.off(t,n)},dismissNotice:t=>{e.dismissNotice(t)},getNotices:()=>e.notices}}const{Provider:Tn}=ue;var En=class extends Tn{logger=M.getInstance().scope(`OverlayedProvider`);constructor(e,t,n){super(n),this.options=e,this.updater=t}async getLatestVersion(){try{let e=await tt(this.options.application_id,{release_id:this.options.release_id,cortex_user_id:this.options.cortex_user_id,access_token:this.options.access_token,requested_channel:this.options.requested_channel});return this.logger.log(`checkApplicationRelease response`,e.data),q.getInstance().track(`update_release_check_success`,{version:e.data.release.version,channel:e.data.release.channel,fallback:!!e.data.fallback}),e.data.fallback&&this.logger.warn(`Update fallback detected, switching to default channel`),{path:``,sha512:e.data.download_hash??``,version:`${e.data.release.version}-${e.data.release.channel}`,releaseName:e.data.release.id,releaseDate:e.data.release.created_at,files:[{url:e.data.download_url,sha512:e.data.download_hash??``}]}}catch(e){let t=e instanceof Error?e.stack||e.message:String(e);throw q.getInstance().track(`update_release_check_error`,{message:t}),Error(`Unable to find the latest version (${this.options.release_id}), please ensure release exists. ${t}`)}}resolveFiles(e){return[{info:e.files[0],url:new URL(e.files[0].url)}]}};function Dn(e){return{provider:`custom`,updateProvider:En,...e}}function Z(){return ue.autoUpdater}const On=D(class extends L{DEFAULT_CHANNEL=`public`;TOKEN_REFRESH_INTERVAL=1e3*60*15;accessTokenFetcher=void 0;_tokenRefreshInterval=null;_downloadStarted=!1;constructor(){super(`UpdateManager`)}init(){super.init(),this.registerListenerForwarders(),this.setupTokenRefreshInterval(),Z().disableDifferentialDownload=!0}destroy(){Z().removeAllListeners(),this._tokenRefreshInterval&&=(clearInterval(this._tokenRefreshInterval),null),super.destroy()}setupTokenRefreshInterval(){this._tokenRefreshInterval=setInterval(()=>{this.checkAndRefreshToken()},this.TOKEN_REFRESH_INTERVAL)}async checkAndRefreshToken(){let e=global.OVERLAYED_META.release.channel;e!==this.DEFAULT_CHANNEL&&(this.logger.log(`Refreshing access token for channel`,e),await this.setAndGetLatestAccessToken(e))}async checkForUpdates(e){this.logger.log(`Starting checkForUpdates`);let t=e??global.OVERLAYED_META.release.channel;return q.getInstance().track(`check_for_update`,{channel:t}),this._downloadStarted=!1,await this.setAndGetLatestAccessToken(t),e?(Z().allowDowngrade=!0,Z().channel=e,this.setFeedUrl({requestedChannel:e})):(Z().allowDowngrade=!1,Z().channel=global.OVERLAYED_META.release.channel,this.setFeedUrl({})),this.logger.log(`Checking for updates`),Z().checkForUpdates()}async switchChannel(e){return this.logger.log(`Switching channel`,e),q.getInstance().track(`update_channel_switch`,{from_channel:global.OVERLAYED_META.release.channel,to_channel:e}),this._downloadStarted=!1,await this.setAndGetLatestAccessToken(e),Z().allowDowngrade=!0,Z().channel=e,this.setFeedUrl({requestedChannel:e}),Z().checkForUpdates()}quitAndInstall(e,t){this.logger.log(`quitAndInstall`,{isSilent:e,isForceRunAfter:t});let[n,r]=this.canUpdate();if(!n)throw this.logger.warn(`Cannot update`,{denialReason:r}),q.getInstance().track(`update_install_blocked`,{reason:r}),Error(r);return this.logger.log(`Quitting and installing`),q.getInstance().track(`update_install`,{}),Z().quitAndInstall(e,t)}canUpdate(){return Y.getInstance().isInGame?[!1,`User is in game`]:[!0,null]}downloadUpdate(e){return Z().downloadUpdate(e)}setAccessTokenFetcher(e){this.accessTokenFetcher=e}async setAndGetLatestAccessToken(e){if(this.logger.log(`Fetching new token`),!this.accessTokenFetcher)return this.logger.warn(`accessTokenFetcher is not set, private channels will not work.`),K(null),null;if(this.logger.log(`Setting and getting latest access token for channel`,e),e===this.DEFAULT_CHANNEL)return this.logger.log(`Default channel, skipping`),K(null),null;if(e!==global.OVERLAYED_META.release.channel)return this.forceFetchNewAccessToken(e);this.logger.log(`Access token exists, checking expiration`);let t=G();if(t){let e=this.getAccessTokenExpirationDate(t);if(!e)this.logger.log(`Invalid token, setting to null`),K(null);else if(e.getTime()>=Date.now()+300*1e3)return this.logger.log(`Token is not expired, using it.`),t}return this.forceFetchNewAccessToken(e)}async forceFetchNewAccessToken(e){this.accessTokenFetcher||this.logger.warn(`accessTokenFetcher is not set [2], private channels will not work.`);try{let t=await this.accessTokenFetcher?.(e)??null;this.logger.log(`New token fetched`,t?.slice(0,5)+`...`);let n=G();if(t==null||n===t){q.getInstance().track(`update_token_invalid`,{channel:e}),this.emit(`authTokenInvalid`,{}),K(null);return}return K(t),t}catch(e){let t=e instanceof Error?e.message:String(e);return q.getInstance().track(`update_token_fetch_error`,{message:t}),this.logger.error(`Error fetching new token`,{error:e,message:t}),K(null),null}}setFeedUrl(e){if(!global.OVERLAYED_META.release.id){this.logger.warn(`Tried to set feed URL in development mode`);return}Z().setFeedURL(Dn({application_id:global.OVERLAYED.APPLICATION_ID,release_id:global.OVERLAYED_META.release.id,cortex_user_id:global.OVERLAYED_RUNTIME.userId,access_token:G(),requested_channel:e.requestedChannel}))}registerListenerForwarders(){Z().on(`checking-for-update`,()=>{this.logger.info(`Checking for updates`),this.emit(`checkingForUpdates`,{})}),Z().on(`download-progress`,e=>{this._downloadStarted||(this._downloadStarted=!0,q.getInstance().track(`update_download_started`,{version:Z().currentVersion?.version??``})),this.emit(`downloadProgress`,{info:e});let t=`Download speed: ${e.bytesPerSecond} - Downloaded ${e.percent}%`;t+=` (${e.transferred}/${e.total})`,this.logger.log(t)}),Z().on(`error`,(e,t)=>{this.logger.error(`Error`,e,t),q.getInstance().track(`update_download_error`,{message:t??e.message}),this.emit(`error`,{error:e,message:t})}),Z().on(`update-not-available`,e=>{this.logger.info(`Update not available`,e),q.getInstance().track(`update_not_available`,{version:e.version}),this.emit(`updateNotAvailable`,{info:e})}),Z().on(`update-available`,e=>{this.logger.info(`Update available`,e),q.getInstance().track(`update_available`,{version:e.version,channel:Z().channel??``}),this.emit(`updateAvailable`,{info:e})}),Z().on(`update-downloaded`,e=>{this.logger.info(`Update downloaded`,e),q.getInstance().track(`update_download_complete`,{version:e.version}),this.emit(`updateDownloaded`,{event:e})}),Z().on(`update-cancelled`,e=>{this.logger.info(`Update cancelled`,e),q.getInstance().track(`update_cancelled`,{version:e.version}),this.emit(`updateCancelled`,{info:e})})}getAccessTokenExpirationDate(e){try{let t=e.split(`.`)[1];if(!t)return null;let n=atob(t.replace(/-/g,`+`).replace(/_/g,`/`)),r=JSON.parse(n);return r.exp?new Date(r.exp*1e3):null}catch{return null}}});function kn(){let e=On.getInstance();return{site:xn(),on:(t,n)=>{e.on(t,n)},off:(t,n)=>{e.off(t,n)},setAccessTokenFetcher:t=>e.setAccessTokenFetcher(t),checkForUpdates:()=>e.checkForUpdates(),switchChannel:t=>e.checkForUpdates(t),quitAndInstall:(t,n)=>e.quitAndInstall(t,n),canUpdate:()=>e.canUpdate(),downloadUpdate:t=>e.downloadUpdate(t)}}function An(){return{getChannel:()=>global.OVERLAYED_META.release.channel,getVersion:()=>global.OVERLAYED_META.release.version,getReleaseId:()=>global.OVERLAYED_META.release.id}}const jn=D(class extends L{_knownModificationTimes=new Map;_confirmedDumps=new Set;_pendingReports=new Map;_snapshotTimestamp=0;boundOnGameReady=this.onGameReady.bind(this);boundOnGameClose=this.onGameClose.bind(this);constructor(){super(`CrashDumpManager`)}init(){super.init(),this.logger.debug(`init() registering game event listeners`),Y.getInstance().on(`gameReadyInternal`,this.boundOnGameReady),Y.getInstance().on(`gameCloseInternal`,this.boundOnGameClose),this.logger.debug(`init() complete`)}destroy(){this.logger.debug(`destroy() called`,{pendingReports:this._pendingReports.size,confirmedDumps:this._confirmedDumps.size,knownModificationTimes:this._knownModificationTimes.size}),Y.getInstance().off(`gameReadyInternal`,this.boundOnGameReady),Y.getInstance().off(`gameCloseInternal`,this.boundOnGameClose),this._knownModificationTimes.clear(),this._confirmedDumps.clear(),this._pendingReports.clear(),this._snapshotTimestamp=0,this.logger.debug(`destroy() cleanup complete`),super.destroy()}async submit(e){this.logger.debug(`submit() called`,{id:e,pendingCount:this._pendingReports.size});let t=this._pendingReports.get(e);if(!t){this.logger.warn(`submit called with unknown id`,e);return}let{response:n,dumpPath:r}=t;this.logger.debug(`Resolved pending report for submission`,{id:e,dumpPath:r});let i=global.OVERLAYED.APPLICATION_ID,a=kt();if(this.logger.debug(`Resolved identifiers for submission`,{applicationId:i,cortexUserId:a}),n.crash_dump_upload_request)try{this.logger.debug(`Reading crash dump file`,{dumpPath:r});let t=await w.readFile(r);this.logger.debug(`Uploading crash dump`,{dumpPath:r,size:t.byteLength}),await ut(n.crash_dump_upload_request,new Uint8Array(t)),this.logger.debug(`Crash dump uploaded, confirming`,{id:e}),await rt(i,e,{cortex_user_id:a,file_type:`crash_dump`}),this.logger.debug(`Crash dump confirmed`,{id:e})}catch(e){this.logger.error(`Failed to upload crash dump`,{dumpPath:r,error:e})}else this.logger.warn(`No crash dump upload request in response`,{id:e});this._pendingReports.delete(e),this._confirmedDumps.add(r),this.logger.debug(`Report state updated, attempting dump file cleanup`,{id:e,dumpPath:r});try{await w.unlink(r),this.logger.debug(`Dump file cleaned up successfully`,{dumpPath:r})}catch(e){this.logger.warn(`Failed to clean up dump file after submission`,{dumpPath:r,error:e})}this.logger.log(`Crash report submitted successfully`,r)}async onGameReady({ravenGame:e}){this.logger.debug(`onGameReady() fired`,{game:e.identifier}),await this.snapshotModificationTimes(),this.logger.debug(`onGameReady() snapshot complete`,{game:e.identifier})}async onGameClose({ravenGame:e}){this.logger.debug(`onGameClose() fired`,{game:e.identifier}),await this.scanForNewDumps(ft(e.identifier)),this.logger.debug(`onGameClose() scan complete`,{game:e.identifier})}async snapshotModificationTimes(){let e=Te();this._snapshotTimestamp=Date.now(),this.logger.debug(`snapshotModificationTimes() called`,{crashDumpsPath:e,snapshotTimestamp:this._snapshotTimestamp});try{await w.access(e)}catch{this.logger.debug(`Crash dumps directory does not exist, skipping snapshot`,{crashDumpsPath:e});return}let t=await this.findAllDumps(e);this.logger.debug(`Found dumps for snapshot`,{count:t.length});for(let e of t)try{let t=await w.stat(e);if(t.mtimeMs>=this._snapshotTimestamp-3e4){this.logger.debug(`Skipping recent dump from snapshot`,{dumpPath:e,mtimeMs:t.mtimeMs,snapshotTimestamp:this._snapshotTimestamp});continue}this._knownModificationTimes.set(e,t.mtimeMs),this.logger.debug(`Recorded modification time`,{dumpPath:e,mtimeMs:t.mtimeMs})}catch(t){this.logger.warn(`Failed to stat dump file during snapshot`,{dumpPath:e,error:t})}this.logger.debug(`Snapshot complete`,{totalTracked:this._knownModificationTimes.size})}async scanForNewDumps(e){let t=Te();this.logger.debug(`scanForNewDumps() called`,{game:e,crashDumpsPath:t});try{await w.access(t)}catch{this.logger.debug(`Crash dumps directory does not exist, skipping scan`,{crashDumpsPath:t});return}let n=new Set([...this._pendingReports.values()].map(e=>e.dumpPath)),r=await this.findAllDumps(t);this.logger.debug(`Scan found dumps`,{total:r.length,pendingCount:n.size,confirmedCount:this._confirmedDumps.size});for(let t of r){if(this._confirmedDumps.has(t)){this.logger.debug(`Skipping already confirmed dump`,{dumpPath:t});continue}if(n.has(t)){this.logger.debug(`Skipping already pending dump`,{dumpPath:t});continue}let r;try{r=await w.stat(t)}catch(e){this.logger.warn(`Failed to stat dump file during scan`,{dumpPath:t,error:e});continue}let i=r.mtimeMs,a=this._knownModificationTimes.get(t);if(this.logger.debug(`Comparing modification times`,{dumpPath:t,modificationTime:i,knownModificationTime:a}),a===void 0||i>a){this.logger.debug(`Dump is new or modified`,{dumpPath:t,isNew:a===void 0});try{let n=r.size,i=m.basename(m.dirname(t)),a=m.basename(t,m.extname(t));this.logger.debug(`Preparing crash report`,{dumpPath:t,crashDumpSize:n,crashSource:i});let o=(await mn().generateAsync({type:`uint8array`})).byteLength,s=global.OVERLAYED.APPLICATION_ID,c=kt(),l=global.OVERLAYED_META.release.id;this.logger.debug(`Creating game crash report via API`,{applicationId:s,cortexUserId:c,game:e,crashSource:i,crashDumpSize:n,logsSize:o});let{data:u}=await nt(s,{cortex_user_id:c,game:e,crash_source:i,crash_identifier:a,release_id:l,logs_size:o,crash_dump_size:n});this._pendingReports.set(u.id,{response:u,dumpPath:t}),this.logger.debug(`Crash report created, emitting 'new' event`,{id:u.id,game:e}),this.logger.log(`New crash dump detected`,{dumpPath:t,game:e,id:u.id}),this.emit(`new`,{id:u.id,game:e})}catch(e){this.logger.error(`Failed to create game crash report`,{dumpPath:t,error:e})}}else this.logger.debug(`Dump unchanged, skipping`,{dumpPath:t});this._knownModificationTimes.set(t,i)}this.logger.debug(`scanForNewDumps() complete`,{game:e,pendingReports:this._pendingReports.size})}async findAllDumps(e){this.logger.debug(`findAllDumps() called`,{basePath:e});let t=[],n;try{n=await w.readdir(e,{withFileTypes:!0})}catch(n){return this.logger.warn(`Failed to read crash dumps directory`,{basePath:e,error:n}),t}this.logger.debug(`Top-level entries in crash dumps directory`,{count:n.length,directories:n.filter(e=>e.isDirectory()).map(e=>e.name)});for(let r of n)if(r.isDirectory()){let n=m.join(e,r.name),i;try{i=await w.readdir(n,{withFileTypes:!0})}catch(e){this.logger.warn(`Failed to read crash dump subdirectory`,{subPath:n,error:e});continue}let a=i.filter(e=>e.isFile()&&e.name.endsWith(`.dmp`));this.logger.debug(`Scanned subdirectory`,{subPath:n,totalEntries:i.length,dmpCount:a.length});for(let e of a)t.push(m.join(n,e.name))}return this.logger.debug(`findAllDumps() complete`,{totalFound:t.length}),t}});let Mn=!1,Nn={},Pn,Fn=new ge,In;function Ln(e){zn(e);let t=Rn(e),{init:n=!0,debug:r=!1,silent:i=!0}=t;if(Bn(e),M.getInstance().init(e.applicationId,r,i),rn.getInstance().init(e.applicationId,r,!0,!0),Un($e(e.applicationId),!1).catch(()=>{}),Mn)return Pn;function a(){if(Mn){M.getInstance().warn(`Overlayed already initialized`);return}en();let n=Ut.get({createIfMissing:!1});if(n){let t=Gt({currentAccount:n.currentAccount,accounts:n.accounts,expected:{applicationId:e.applicationId,baseUrl:Ke}});t&&Je(()=>t.account.apiKey)}let r=new Map,i=new Map,o=kn(),s=qt(t.modules,r,Fn),c=Jt(),l=$t(t.keybinds),u=sn(),d=ln(),f=dn(),p=un(),m=gn(t),h=wn(),g=bn(t.featureFlags),_=An();M.getInstance().log(`Overlayed initialized`),Vn(t),vn(t,r,i,Fn,Nn),Mn=!0,Pn={...s,...c,ads:f,keybinds:l,windows:u,input:d,cortex:p,hasAnyActiveProcesses:()=>Pt.getInstance().hasAnyActiveProcesses,hasAnyActiveGames:()=>Y.getInstance().isInGame,init:a,log:m,initialized:Mn,notices:h,featureFlags:g,updater:o,application:_,crashDumps:{on:(e,t)=>jn.getInstance().on(e,t),off:(e,t)=>jn.getInstance().off(e,t),submit:e=>jn.getInstance().submit(e)}},Pn.universal.on(`logged_in`,e=>{q.getInstance().track(`account_id`,{account_id:e.content.account_id,game:e.game})})}return n?(a(),Pn):new Proxy({init:a},{get:(e,t)=>{if(t!==`init`&&!Mn)throw Error(`overlayed was called before initialized: ${t}`);return t===`init`?e[t]:Pn[t]}})}function Rn(e){return{...e,modules:[...e.modules,Ue()]}}global.OVERLAYED=new Proxy({},{get:()=>{throw Error(`function overlayed was not called`)}});function zn(e){if(!me(e.applicationId))throw Error(`Invalid applicationId, must be a valid ULID.`)}function Bn(e){let t=Hn(),n=`1.3.7`,r=$e(e.applicationId);function i(){return{package_version:n,application_id:r,application_version:t?.release.version??`0.0.0`}}if(M.getInstance().log(`ua object`,i()),Xe(()=>i()),t===null){Un(r,!0);return}global.OVERLAYED={APPLICATION_ID:r,APP_BUILD_CHANNEL:t.release.channel,APP_VERSION:t.release.version,PACKAGE_VERSION:n,FRONTEND_VERSION:`0.0.0`,sessionId:At(),electron:e.electron},global.OVERLAYED_META=t,global.OVERLAYED_RUNTIME={userId:kt()},M.getInstance().log(`meta`,t)}function Vn(e){M.getInstance().warn(`Bootstrapping`);let t=e.universal?[`*`]:e.modules.map(e=>e.key);Y.getInstance().setSubscribedGames(t),M.getInstance().warn(`Initializing update manager`),On.getInstance().init(),M.getInstance().warn(`Initialized update manager`),nn.getInstance().init({manualUpdates:e.site?.manualUpdates??!1}),Vt.getInstance().init(),Y.getInstance().init(),jn.getInstance().init(),Pt.getInstance().init(),Nt.getInstance().init(),q.getInstance().track(`start`,{}),Ht.getInstance().check(e.applicationId);try{In&&clearInterval(In),In=setInterval(()=>{try{W()}catch{}},3e4),In.unref()}catch(e){M.getInstance().log(`failed to start sessionLastUsed interval`,e)}async function n(){let e={};e.os=ae.platform().trim(),e.os_version=process.getSystemVersion().trim(),e.architecture=ae.arch().trim();let t=ae.cpus();t.length>0?(e.cpu=t[0].model.trim(),e.cpu_cores=t.length,e.cpu_speed=t[0].speed):M.getInstance().warn(`Failed to collect CPU info`);let n=await le.graphics();M.getInstance().info(`GPU info`,n);let r=n.controllers.sort((e,t)=>(t.vram??0)-(e.vram??0))[0];r?(e.gpu=r.model.trim(),e.gpu_memory=r.vram??0):M.getInstance().warn(`Failed to find primary GPU`),e.display_count=n.displays.length;let i=n.displays.find(e=>e.main)??n.displays[0];i?(e.primary_display_resolution_x=i.resolutionX??void 0,e.primary_display_resolution_y=i.resolutionY??void 0,e.primary_display_refresh_rate=i.currentRefreshRate??void 0):M.getInstance().warn(`Failed to find main display`),e.ram=process.getSystemMemoryInfo().total;let a=ae.homedir(),o=await w.statfs(a);return o&&`blocks`in o&&`bsize`in o&&`bavail`in o?(e.disk=o.blocks*o.bsize,e.disk_free=o.bavail*o.bsize):M.getInstance().warn(`Failed to collect disk info`),M.getInstance().log(`Retrieved system information`,e),e}T.on(`ready`,()=>{n().then(e=>{q.getInstance().track(`system_info`,e)}).catch(e=>{M.getInstance().log(`Failed to retrieve system information`,e)})}),T.on(`quit`,()=>{q.getInstance().track(`electron_quit`,{}),Wn()}),process.on(`exit`,()=>{q.getInstance().track(`exit`,{}),Wn()})}function Hn(){if(T.isPackaged)try{let e=m.join(process.resourcesPath,`meta.json`);return JSON.parse(y.readFileSync(e,`utf-8`))}catch(e){throw Error(`Failed to read application metadata from resources/meta.json`,{cause:e})}else{let e=m.join(process.cwd(),`.overlayed`,`meta.json`);return y.existsSync(e)?JSON.parse(y.readFileSync(e,`utf-8`)):null}}async function Un(e,t=!1){if(!T.isPackaged)try{M.getInstance().log(`Fetching application metadata from API...`);let n=ke({...(await et(e)).data,siteUrl:``});t&&(M.getInstance().log(v.yellowBright(`Uninitialized development environment detected. Created .overlayed folder. In the future, run ${v.bold(`overlayed init`)} to do so. \n\nThe process will now exit to load the cached metadata.\n\n${v.italic(`Note: This will never happen in a packaged application, and will only happen once in local development so long as the .overlayed folder exists.`)}`)),process.exit(0)),global.OVERLAYED_META=n}catch(e){M.getInstance().error(`Failed to fetch application meta`,e),t&&(console.error(`
9
+ `;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return le(this.readCodePoint());case 116:return` `;case 98:return`\b`;case 118:return`\v`;case 102:return`\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),r===`0`&&t!==56&&t!==57||!this.strict&&!e||this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return ne(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},V.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},V.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(m(i,r))this.pos+=i<=65535?1:2;else{if(i!==92)break;this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\uXXXX`),++this.pos;var o=this.readCodePoint();(t?p:m)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=le(o),n=this.pos}t=!1}return e+this.input.slice(n,this.pos)},V.readWord=function(){var e=this.readWord1(),t=b.name;return this.keywords.test(e)&&(t=ee[e]),this.finishToken(t,e)},k.acorn={Parser:k,version:`8.15.0`,defaultOptions:me,Position:de,SourceLocation:fe,getLineInfo:pe,Node:Pe,TokenType:h,tokTypes:b,keywordTypes:ee,TokContext:P,tokContexts:F,isIdentifierChar:m,isIdentifierStart:p,Token:st,isNewLine:ne,lineBreak:x,lineBreakG:te,nonASCIIwhitespace:ie};let ut=E(`node:module`),H=E(`node:fs`);String.fromCharCode;let dt=/\/$|\/\?|\/#/,ft=/^\.?\//;function pt(e=``,t){return t?dt.test(e):e.endsWith(`/`)}function mt(e=``,t){if(!t)return e.endsWith(`/`)?e:e+`/`;if(pt(e,!0))return e||`/`;let n=e,r=``,i=e.indexOf(`#`);if(i!==-1&&(n=e.slice(0,i),r=e.slice(i),!n))return r;let[a,...o]=n.split(`?`);return a+`/`+(o.length>0?`?${o.join(`?`)}`:``)+r}function ht(e){return e&&e!==`/`}function gt(e,...t){let n=e||``;for(let e of t.filter(e=>ht(e)))if(n){let t=e.replace(ft,``);n=mt(n)+t}else n=e;return n}let _t=/^[A-Za-z]:\//;function vt(e=``){return e&&e.replace(/\\/g,`/`).replace(_t,e=>e.toUpperCase())}let yt=/^[/\\]{2}/,bt=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,xt=/^[A-Za-z]:$/,St=/.(\.[^./]+|\.)$/,Ct=function(e){if(e.length===0)return`.`;let t=(e=vt(e)).match(yt),n=U(e),r=e[e.length-1]===`/`;return(e=Dt(e,!n)).length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),xt.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!U(e)?`/${e}`:e)},wt=function(...e){let t=``;for(let n of e)if(n)if(t.length>0){let e=t[t.length-1]===`/`,r=n[0]===`/`;t+=e&&r?n.slice(1):e||r?n:`/${n}`}else t+=n;return Ct(t)};function Tt(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}let Et=function(...e){let t=``,n=!1;for(let r=(e=e.map(e=>vt(e))).length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:Tt();i&&i.length!==0&&(t=`${i}/${t}`,n=U(i))}return t=Dt(t,!n),n&&!U(t)?`/${t}`:t.length>0?t:`.`};function Dt(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else{if(o===`/`)break;o=`/`}if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}let U=function(e){return bt.test(e)},Ot=function(e){if(e===`..`)return``;let t=St.exec(vt(e));return t&&t[1]||``},kt=function(e){let t=vt(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&xt.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(U(e)?`/`:`.`)},At=function(e,t){let n=vt(e).split(`/`),r=``;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){r=t;break}}return t&&r.endsWith(t)?r.slice(0,-t.length):r},W=E(`node:url`),G=E(`node:assert`),K=E(`node:process`),jt=E(`node:path`),Mt=E(`node:v8`),Nt=E(`node:util`),Pt=new Set(ut.builtinModules);function Ft(e){return e.replace(/\\/g,`/`)}let It={}.hasOwnProperty,q=/^([A-Z][a-z\d]*)+$/,Lt=new Set([`string`,`function`,`number`,`object`,`Function`,`Object`,`boolean`,`bigint`,`symbol`]),J={};function Rt(e,t=`and`){return e.length<3?e.join(` ${t} `):`${e.slice(0,-1).join(`, `)}, ${t} ${e[e.length-1]}`}let zt=new Map,Bt;function Y(e,t,n){return zt.set(e,t),function(e,t){return n;function n(...n){let r=Error.stackTraceLimit;Vt()&&(Error.stackTraceLimit=0);let i=new e;Vt()&&(Error.stackTraceLimit=r);let a=function(e,t,n){let r=zt.get(e);if(G(r!==void 0,"expected `message` to be found"),typeof r==`function`)return G(r.length<=t.length,`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${r.length}).`),Reflect.apply(r,n,t);let i=/%[dfijoOs]/g,a=0;for(;i.exec(r)!==null;)a++;return G(a===t.length,`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${a}).`),t.length===0?r:(t.unshift(r),Reflect.apply(Nt.format,null,t))}(t,n,i);return Object.defineProperties(i,{message:{value:a,enumerable:!1,writable:!0,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},enumerable:!1,writable:!0,configurable:!0}}),Ht(i),i.code=t,i}}(n,e)}function Vt(){try{if(Mt.startupSnapshot.isBuildingSnapshot())return!1}catch{}let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):It.call(e,`writable`)&&e.writable!==void 0?e.writable:e.set!==void 0}J.ERR_INVALID_ARG_TYPE=Y(`ERR_INVALID_ARG_TYPE`,(e,t,n)=>{G(typeof e==`string`,`'name' must be a string`),Array.isArray(t)||(t=[t]);let r=`The `;if(e.endsWith(` argument`))r+=`${e} `;else{let t=e.includes(`.`)?`property`:`argument`;r+=`"${e}" ${t} `}r+=`must be `;let i=[],a=[],o=[];for(let e of t)G(typeof e==`string`,`All expected entries have to be of type string`),Lt.has(e)?i.push(e.toLowerCase()):q.exec(e)===null?(G(e!==`object`,`The value "object" should be written as "Object"`),o.push(e)):a.push(e);if(a.length>0){let e=i.indexOf(`object`);e!==-1&&(i.slice(e,1),a.push(`Object`))}return i.length>0&&(r+=`${i.length>1?`one of type`:`of type`} ${Rt(i,`or`)}`,(a.length>0||o.length>0)&&(r+=` or `)),a.length>0&&(r+=`an instance of ${Rt(a,`or`)}`,o.length>0&&(r+=` or `)),o.length>0&&(o.length>1?r+=`one of ${Rt(o,`or`)}`:(o[0].toLowerCase()!==o[0]&&(r+=`an `),r+=`${o[0]}`)),r+=`. Received ${function(e){if(e==null)return String(e);if(typeof e==`function`&&e.name)return`function ${e.name}`;if(typeof e==`object`)return e.constructor&&e.constructor.name?`an instance of ${e.constructor.name}`:`${(0,Nt.inspect)(e,{depth:-1})}`;let t=(0,Nt.inspect)(e,{colors:!1});return t.length>28&&(t=`${t.slice(0,25)}...`),`type ${typeof e} (${t})`}(n)}`,r},TypeError),J.ERR_INVALID_MODULE_SPECIFIER=Y(`ERR_INVALID_MODULE_SPECIFIER`,(e,t,n=void 0)=>`Invalid module "${e}" ${t}${n?` imported from ${n}`:``}`,TypeError),J.ERR_INVALID_PACKAGE_CONFIG=Y(`ERR_INVALID_PACKAGE_CONFIG`,(e,t,n)=>`Invalid package config ${e}${t?` while importing ${t}`:``}${n?`. ${n}`:``}`,Error),J.ERR_INVALID_PACKAGE_TARGET=Y(`ERR_INVALID_PACKAGE_TARGET`,(e,t,n,r=!1,i=void 0)=>{let a=typeof n==`string`&&!r&&n.length>0&&!n.startsWith(`./`);return t===`.`?(G(!1===r),`Invalid "exports" main target ${JSON.stringify(n)} defined in the package config ${e}package.json${i?` imported from ${i}`:``}${a?`; targets must start with "./"`:``}`):`Invalid "${r?`imports`:`exports`}" target ${JSON.stringify(n)} defined for '${t}' in the package config ${e}package.json${i?` imported from ${i}`:``}${a?`; targets must start with "./"`:``}`},Error),J.ERR_MODULE_NOT_FOUND=Y(`ERR_MODULE_NOT_FOUND`,(e,t,n=!1)=>`Cannot find ${n?`module`:`package`} '${e}' imported from ${t}`,Error),J.ERR_NETWORK_IMPORT_DISALLOWED=Y(`ERR_NETWORK_IMPORT_DISALLOWED`,`import of '%s' by %s is not supported: %s`,Error),J.ERR_PACKAGE_IMPORT_NOT_DEFINED=Y(`ERR_PACKAGE_IMPORT_NOT_DEFINED`,(e,t,n)=>`Package import specifier "${e}" is not defined${t?` in package ${t}package.json`:``} imported from ${n}`,TypeError),J.ERR_PACKAGE_PATH_NOT_EXPORTED=Y(`ERR_PACKAGE_PATH_NOT_EXPORTED`,(e,t,n=void 0)=>t===`.`?`No "exports" main defined in ${e}package.json${n?` imported from ${n}`:``}`:`Package subpath '${t}' is not defined by "exports" in ${e}package.json${n?` imported from ${n}`:``}`,Error),J.ERR_UNSUPPORTED_DIR_IMPORT=Y(`ERR_UNSUPPORTED_DIR_IMPORT`,`Directory import '%s' is not supported resolving ES modules imported from %s`,Error),J.ERR_UNSUPPORTED_RESOLVE_REQUEST=Y(`ERR_UNSUPPORTED_RESOLVE_REQUEST`,`Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.`,TypeError),J.ERR_UNKNOWN_FILE_EXTENSION=Y(`ERR_UNKNOWN_FILE_EXTENSION`,(e,t)=>`Unknown file extension "${e}" for ${t}`,TypeError),J.ERR_INVALID_ARG_VALUE=Y(`ERR_INVALID_ARG_VALUE`,(e,t,n=`is invalid`)=>{let r=(0,Nt.inspect)(t);return r.length>128&&(r=`${r.slice(0,128)}...`),`The ${e.includes(`.`)?`property`:`argument`} '${e}' ${n}. Received ${r}`},TypeError);let Ht=function(e){let t=`__node_internal_`+e.name;return Object.defineProperty(e,`name`,{value:t}),e}(function(e){let t=Vt();return t&&(Bt=Error.stackTraceLimit,Error.stackTraceLimit=1/0),Error.captureStackTrace(e),t&&(Error.stackTraceLimit=Bt),e}),Ut={}.hasOwnProperty,{ERR_INVALID_PACKAGE_CONFIG:Wt}=J,Gt=new Map;function Kt(e,{base:t,specifier:n}){let r=Gt.get(e);if(r)return r;let i;try{i=H.readFileSync(jt.toNamespacedPath(e),`utf8`)}catch(e){let t=e;if(t.code!==`ENOENT`)throw t}let a={exists:!1,pjsonPath:e,main:void 0,name:void 0,type:`none`,exports:void 0,imports:void 0};if(i!==void 0){let r;try{r=JSON.parse(i)}catch(r){let i=r,a=new Wt(e,(t?`"${n}" from `:``)+(0,W.fileURLToPath)(t||n),i.message);throw a.cause=i,a}a.exists=!0,Ut.call(r,`name`)&&typeof r.name==`string`&&(a.name=r.name),Ut.call(r,`main`)&&typeof r.main==`string`&&(a.main=r.main),Ut.call(r,`exports`)&&(a.exports=r.exports),Ut.call(r,`imports`)&&(a.imports=r.imports),!Ut.call(r,`type`)||r.type!==`commonjs`&&r.type!==`module`||(a.type=r.type)}return Gt.set(e,a),a}function qt(e){let t=new URL(`package.json`,e);for(;!t.pathname.endsWith(`node_modules/package.json`);){let n=Kt((0,W.fileURLToPath)(t),{specifier:e});if(n.exists)return n;let r=t;if(t=new URL(`../package.json`,t),t.pathname===r.pathname)break}return{pjsonPath:(0,W.fileURLToPath)(t),exists:!1,type:`none`}}function Jt(e){return qt(e).type}let{ERR_UNKNOWN_FILE_EXTENSION:Yt}=J,Xt={}.hasOwnProperty,Zt={__proto__:null,".cjs":`commonjs`,".js":`module`,".json":`json`,".mjs":`module`},Qt={__proto__:null,"data:":function(e){let{1:t}=/^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(e.pathname)||[null,null,null];return function(e){return e&&/\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(e)?`module`:e===`application/json`?`json`:null}(t)},"file:":function(e,t,n){let r=function(e){let t=e.pathname,n=t.length;for(;n--;){let e=t.codePointAt(n);if(e===47)return``;if(e===46)return t.codePointAt(n-1)===47?``:t.slice(n)}return``}(e);if(r===`.js`){let t=Jt(e);return t===`none`?`commonjs`:t}if(r===``){let t=Jt(e);return t===`none`||t===`commonjs`?`commonjs`:`module`}let i=Zt[r];if(i)return i;if(!n)throw new Yt(r,(0,W.fileURLToPath)(e))},"http:":$t,"https:":$t,"node:":()=>`builtin`};function $t(){}let X=RegExp.prototype[Symbol.replace],{ERR_INVALID_MODULE_SPECIFIER:en,ERR_INVALID_PACKAGE_CONFIG:tn,ERR_INVALID_PACKAGE_TARGET:nn,ERR_MODULE_NOT_FOUND:rn,ERR_PACKAGE_IMPORT_NOT_DEFINED:an,ERR_PACKAGE_PATH_NOT_EXPORTED:on,ERR_UNSUPPORTED_DIR_IMPORT:sn,ERR_UNSUPPORTED_RESOLVE_REQUEST:cn}=J,ln={}.hasOwnProperty,un=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i,dn=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i,fn=/^\.|%|\\/,pn=/\*/g,mn=/%2f|%5c/i,hn=new Set,gn=/[/\\]{2}/;function _n(e,t,n,r,i,a,o){if(K.noDeprecation)return;let s=(0,W.fileURLToPath)(r),c=gn.exec(o?e:t)!==null;K.emitWarning(`Use of deprecated ${c?`double slash`:`leading or trailing slash matching`} resolving "${e}" for module request "${t}" ${t===n?``:`matched to "${n}" `}in the "${i?`imports`:`exports`}" field module resolution of the package at ${s}${a?` imported from ${(0,W.fileURLToPath)(a)}`:``}.`,`DeprecationWarning`,`DEP0166`)}function vn(e,t,n,r){if(K.noDeprecation||function(e,t){let n=e.protocol;return Xt.call(Qt,n)&&Qt[n](e,t,!0)||null}(e,{parentURL:n.href})!==`module`)return;let i=(0,W.fileURLToPath)(e.href),a=(0,W.fileURLToPath)(new W.URL(`.`,t)),o=(0,W.fileURLToPath)(n);r?jt.resolve(a,r)!==i&&K.emitWarning(`Package ${a} has a "main" field set to "${r}", excluding the full filename and extension to the resolved file at "${i.slice(a.length)}", imported from ${o}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`,`DeprecationWarning`,`DEP0151`):K.emitWarning(`No "main" or "exports" field defined in the package.json for ${a} resolving the main entry point "${i.slice(a.length)}", imported from ${o}.\nDefault "index" lookups for the main are deprecated for ES modules.`,`DeprecationWarning`,`DEP0151`)}function yn(e){try{return(0,H.statSync)(e)}catch{}}function bn(e){let t=(0,H.statSync)(e,{throwIfNoEntry:!1}),n=t?t.isFile():void 0;return n!=null&&n}function xn(e,t,n){let r;if(t.main!==void 0){if(r=new W.URL(t.main,e),bn(r))return r;let i=[`./${t.main}.js`,`./${t.main}.json`,`./${t.main}.node`,`./${t.main}/index.js`,`./${t.main}/index.json`,`./${t.main}/index.node`],a=-1;for(;++a<i.length&&(r=new W.URL(i[a],e),!bn(r));)r=void 0;if(r)return vn(r,e,n,t.main),r}let i=[`./index.js`,`./index.json`,`./index.node`],a=-1;for(;++a<i.length&&(r=new W.URL(i[a],e),!bn(r));)r=void 0;if(r)return vn(r,e,n,t.main),r;throw new rn((0,W.fileURLToPath)(new W.URL(`.`,e)),(0,W.fileURLToPath)(n))}function Sn(e,t,n){return new on((0,W.fileURLToPath)(new W.URL(`.`,t)),e,n&&(0,W.fileURLToPath)(n))}function Cn(e,t,n,r,i){return t=typeof t==`object`&&t?JSON.stringify(t,null,``):`${t}`,new nn((0,W.fileURLToPath)(new W.URL(`.`,n)),e,t,r,i&&(0,W.fileURLToPath)(i))}function wn(e,t,n,r,i,a,o,s,c){if(t!==``&&!a&&e[e.length-1]!==`/`)throw Cn(n,e,r,o,i);if(!e.startsWith(`./`)){if(o&&!e.startsWith(`../`)&&!e.startsWith(`/`)){let n=!1;try{new W.URL(e),n=!0}catch{}if(!n)return An(a?X.call(pn,e,()=>t):e+t,r,c)}throw Cn(n,e,r,o,i)}if(un.exec(e.slice(2))!==null){if(dn.exec(e.slice(2))!==null)throw Cn(n,e,r,o,i);if(!s){let s=a?n.replace(`*`,()=>t):n+t;_n(a?X.call(pn,e,()=>t):e,s,n,r,o,i,!0)}}let l=new W.URL(e,r),u=l.pathname,d=new W.URL(`.`,r).pathname;if(!u.startsWith(d))throw Cn(n,e,r,o,i);if(t===``)return l;if(un.exec(t)!==null){let c=a?n.replace(`*`,()=>t):n+t;dn.exec(t)===null?s||_n(a?X.call(pn,e,()=>t):e,c,n,r,o,i,!1):(function(e,t,n,r,i){throw new en(e,`request is not a valid match in pattern "${t}" for the "${r?`imports`:`exports`}" resolution of ${(0,W.fileURLToPath)(n)}`,i&&(0,W.fileURLToPath)(i))})(c,n,r,o,i)}return a?new W.URL(X.call(pn,l.href,()=>t)):new W.URL(t,l)}function Tn(e){let t=Number(e);return`${t}`===e&&t>=0&&t<4294967295}function En(e,t,n,r,i,a,o,s,c){if(typeof t==`string`)return wn(t,n,r,e,i,a,o,s,c);if(Array.isArray(t)){let l=t;if(l.length===0)return null;let u,d=-1;for(;++d<l.length;){let t=l[d],f;try{f=En(e,t,n,r,i,a,o,s,c)}catch(e){if(u=e,e.code===`ERR_INVALID_PACKAGE_TARGET`)continue;throw e}if(f!==void 0){if(f!==null)return f;u=null}}if(u==null)return null;throw u}if(typeof t==`object`&&t){let l=Object.getOwnPropertyNames(t),u=-1;for(;++u<l.length;)if(Tn(l[u]))throw new tn((0,W.fileURLToPath)(e),i,`"exports" cannot contain numeric property keys.`);for(u=-1;++u<l.length;){let d=l[u];if(d===`default`||c&&c.has(d)){let l=En(e,t[d],n,r,i,a,o,s,c);if(l===void 0)continue;return l}}return null}if(t===null)return null;throw Cn(r,t,e,o,i)}function Dn(e,t,n){if(K.noDeprecation)return;let r=(0,W.fileURLToPath)(t);hn.has(r+`|`+e)||(hn.add(r+`|`+e),K.emitWarning(`Use of deprecated trailing slash pattern mapping "${e}" in the "exports" field module resolution of the package at ${r}${n?` imported from ${(0,W.fileURLToPath)(n)}`:``}. Mapping specifiers ending in "/" is no longer supported.`,`DeprecationWarning`,`DEP0155`))}function Z(e,t,n,r,i){let a=n.exports;if(function(e,t,n){if(typeof e==`string`||Array.isArray(e))return!0;if(typeof e!=`object`||!e)return!1;let r=Object.getOwnPropertyNames(e),i=!1,a=0,o=-1;for(;++o<r.length;){let e=r[o],s=e===``||e[0]!==`.`;if(a++===0)i=s;else if(i!==s)throw new tn((0,W.fileURLToPath)(t),n,`"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`)}return i}(a,e,r)&&(a={".":a}),ln.call(a,t)&&!t.includes(`*`)&&!t.endsWith(`/`)){let n=En(e,a[t],``,t,r,!1,!1,!1,i);if(n==null)throw Sn(t,e,r);return n}let o=``,s=``,c=Object.getOwnPropertyNames(a),l=-1;for(;++l<c.length;){let n=c[l],i=n.indexOf(`*`);if(i!==-1&&t.startsWith(n.slice(0,i))){t.endsWith(`/`)&&Dn(t,e,r);let a=n.slice(i+1);t.length>=n.length&&t.endsWith(a)&&On(o,n)===1&&n.lastIndexOf(`*`)===i&&(o=n,s=t.slice(i,t.length-a.length))}}if(o){let n=En(e,a[o],s,o,r,!0,!1,t.endsWith(`/`),i);if(n==null)throw Sn(t,e,r);return n}throw Sn(t,e,r)}function On(e,t){let n=e.indexOf(`*`),r=t.indexOf(`*`),i=n===-1?e.length:n+1,a=r===-1?t.length:r+1;return i>a?-1:a>i||n===-1?1:r===-1||e.length>t.length?-1:+(t.length>e.length)}function kn(e,t,n){if(e===`#`||e.startsWith(`#/`)||e.endsWith(`/`))throw new en(e,`is not a valid internal imports specifier name`,(0,W.fileURLToPath)(t));let r,i=qt(t);if(i.exists){r=(0,W.pathToFileURL)(i.pjsonPath);let a=i.imports;if(a)if(ln.call(a,e)&&!e.includes(`*`)){let i=En(r,a[e],``,e,t,!1,!0,!1,n);if(i!=null)return i}else{let i=``,o=``,s=Object.getOwnPropertyNames(a),c=-1;for(;++c<s.length;){let t=s[c],n=t.indexOf(`*`);if(n!==-1&&e.startsWith(t.slice(0,-1))){let r=t.slice(n+1);e.length>=t.length&&e.endsWith(r)&&On(i,t)===1&&t.lastIndexOf(`*`)===n&&(i=t,o=e.slice(n,e.length-r.length))}}if(i){let e=En(r,a[i],o,i,t,!0,!0,!1,n);if(e!=null)return e}}}throw function(e,t,n){return new an(e,t&&(0,W.fileURLToPath)(new W.URL(`.`,t)),(0,W.fileURLToPath)(n))}(e,r,t)}function An(e,t,n){if(ut.builtinModules.includes(e))return new W.URL(`node:`+e);let{packageName:r,packageSubpath:i,isScoped:a}=function(e,t){let n=e.indexOf(`/`),r=!0,i=!1;e[0]===`@`&&(i=!0,n===-1||e.length===0?r=!1:n=e.indexOf(`/`,n+1));let a=n===-1?e:e.slice(0,n);if(fn.exec(a)!==null&&(r=!1),!r)throw new en(e,`is not a valid package name`,(0,W.fileURLToPath)(t));return{packageName:a,packageSubpath:`.`+(n===-1?``:e.slice(n)),isScoped:i}}(e,t),o=qt(t);if(o.exists){let e=(0,W.pathToFileURL)(o.pjsonPath);if(o.name===r&&o.exports!==void 0&&o.exports!==null)return Z(e,i,o,t,n)}let s,c=new W.URL(`./node_modules/`+r+`/package.json`,t),l=(0,W.fileURLToPath)(c);do{let o=yn(l.slice(0,-13));if(!o||!o.isDirectory()){s=l,c=new W.URL((a?`../../../../node_modules/`:`../../../node_modules/`)+r+`/package.json`,c),l=(0,W.fileURLToPath)(c);continue}let u=Kt(l,{base:t,specifier:e});return u.exports!==void 0&&u.exports!==null?Z(c,i,u,t,n):i===`.`?xn(c,u,t):new W.URL(i,c)}while(l.length!==s.length);throw new rn(r,(0,W.fileURLToPath)(t),!1)}function jn(e,t,n,r){let i=t.protocol,a=i===`data:`||i===`http:`||i===`https:`,o;if(function(e){return e!==``&&(e[0]===`/`||function(e){return e[0]===`.`&&(e.length===1||e[1]===`/`||e[1]===`.`&&(e.length===2||e[2]===`/`))}(e))}(e))try{o=new W.URL(e,t)}catch(n){let r=new cn(e,t);throw r.cause=n,r}else if(i===`file:`&&e[0]===`#`)o=kn(e,t,n);else try{o=new W.URL(e)}catch(r){if(a&&!ut.builtinModules.includes(e)){let n=new cn(e,t);throw n.cause=r,n}o=An(e,t,n)}return G(o!==void 0,`expected to be defined`),o.protocol===`file:`?function(e,t){if(mn.exec(e.pathname)!==null)throw new en(e.pathname,`must not include encoded "/" or "\\" characters`,(0,W.fileURLToPath)(t));let n;try{n=(0,W.fileURLToPath)(e)}catch(n){let r=n;throw Object.defineProperty(r,`input`,{value:String(e)}),Object.defineProperty(r,`module`,{value:String(t)}),r}let r=yn(n.endsWith(`/`)?n.slice(-1):n);if(r&&r.isDirectory()){let r=new sn(n,(0,W.fileURLToPath)(t));throw r.url=String(e),r}if(!r||!r.isFile()){let r=new rn(n||e.pathname,t&&(0,W.fileURLToPath)(t),!0);throw r.url=String(e),r}{let t=(0,H.realpathSync)(n),{search:r,hash:i}=e;(e=(0,W.pathToFileURL)(t+(n.endsWith(jt.sep)?`/`:``))).search=r,e.hash=i}return e}(o,t):o}function Mn(e){return typeof e!=`string`||e.startsWith(`file://`)?Ft((0,W.fileURLToPath)(e)):Ft(e)}function Nn(e){return(0,W.pathToFileURL)(Mn(e)).toString()}let Pn=new Set([`node`,`import`]),Fn=[`.mjs`,`.cjs`,`.js`,`.json`],In=new Set([`ERR_MODULE_NOT_FOUND`,`ERR_UNSUPPORTED_DIR_IMPORT`,`MODULE_NOT_FOUND`,`ERR_PACKAGE_PATH_NOT_EXPORTED`]);function Ln(e,t,n){try{return jn(e,t,n)}catch(e){if(!In.has(e?.code))throw e}}function Rn(e,t={}){if(typeof e!=`string`){if(!(e instanceof URL))throw TypeError("input must be a `string` or `URL`");e=Mn(e)}if(/(?:node|data|http|https):/.test(e))return e;if(Pt.has(e))return`node:`+e;if(e.startsWith(`file://`)&&(e=Mn(e)),U(e))try{if((0,H.statSync)(e).isFile())return Nn(e)}catch(e){if(e?.code!==`ENOENT`)throw e}let n=t.conditions?new Set(t.conditions):Pn,r=(Array.isArray(t.url)?t.url:[t.url]).filter(Boolean).map(e=>new URL(function(e){return typeof e!=`string`&&(e=e.toString()),/(?:node|data|http|https|file):/.test(e)?e:Pt.has(e)?`node:`+e:`file://`+encodeURI(Ft(e))}(e.toString())));r.length===0&&r.push(new URL(Nn(process.cwd())));let i=[...r];for(let e of r)e.protocol===`file:`&&i.push(new URL(`./`,e),new URL(gt(e.pathname,`_index.js`),e),new URL(`node_modules`,e));let a;for(let r of i){if(a=Ln(e,r,n),a)break;for(let i of[``,`/index`]){for(let o of t.extensions||Fn)if(a=Ln(gt(e,i)+o,r,n),a)break;if(a)break}if(a)break}if(!a){let t=Error(`Cannot find module ${e} imported from ${i.join(`, `)}`);throw t.code=`ERR_MODULE_NOT_FOUND`,t}return Nn(a)}function zn(e,t){return Rn(e,t)}function Bn(e,t){return Mn(zn(e,t))}let Vn=/(?:[\s;]|^)(?:import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m,Hn=/\/\*.+?\*\/|\/\/.*(?=[nr])/g;function Un(e,t={}){return t.stripComments&&(e=e.replace(Hn,``)),Vn.test(e)}function Wn(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}let Gn=new Set([`/`,`\\`,void 0]),Kn=Symbol.for(`pathe:normalizedAlias`),qn=/[/\\]/;function Jn(e){if(e[Kn])return e;let t=Object.fromEntries(Object.entries(e).sort(([e],[t])=>function(e,t){return t.split(`/`).length-e.split(`/`).length}(e,t)));for(let e in t)for(let n in t)n===e||e.startsWith(n)||t[e]?.startsWith(n)&&Gn.has(t[e][n.length])&&(t[e]=t[n]+t[e].slice(n.length));return Object.defineProperty(t,Kn,{value:!0,enumerable:!1}),t}function Yn(e=`/`){let t=e[e.length-1];return t===`/`||t===`\\`}var Xn={rE:`2.6.1`};let Zn=E(`node:crypto`);var Qn=r.n(Zn);let $n=Object.create(null),er=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?$n:globalThis),tr=new Proxy($n,{get:(e,t)=>er()[t]??$n[t],has:(e,t)=>t in er()||t in $n,set:(e,t,n)=>(er(!0)[t]=n,!0),deleteProperty(e,t){return t?(delete er(!0)[t],!0):!1},ownKeys(){let e=er(!0);return Object.keys(e)}}),nr=typeof process<`u`&&process.env&&process.env.NODE_ENV||``,rr=[[`APPVEYOR`],[`AWS_AMPLIFY`,`AWS_APP_ID`,{ci:!0}],[`AZURE_PIPELINES`,`SYSTEM_TEAMFOUNDATIONCOLLECTIONURI`],[`AZURE_STATIC`,`INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN`],[`APPCIRCLE`,`AC_APPCIRCLE`],[`BAMBOO`,`bamboo_planKey`],[`BITBUCKET`,`BITBUCKET_COMMIT`],[`BITRISE`,`BITRISE_IO`],[`BUDDY`,`BUDDY_WORKSPACE_ID`],[`BUILDKITE`],[`CIRCLE`,`CIRCLECI`],[`CIRRUS`,`CIRRUS_CI`],[`CLOUDFLARE_PAGES`,`CF_PAGES`,{ci:!0}],[`CLOUDFLARE_WORKERS`,`WORKERS_CI`,{ci:!0}],[`CODEBUILD`,`CODEBUILD_BUILD_ARN`],[`CODEFRESH`,`CF_BUILD_ID`],[`DRONE`],[`DRONE`,`DRONE_BUILD_EVENT`],[`DSARI`],[`GITHUB_ACTIONS`],[`GITLAB`,`GITLAB_CI`],[`GITLAB`,`CI_MERGE_REQUEST_ID`],[`GOCD`,`GO_PIPELINE_LABEL`],[`LAYERCI`],[`HUDSON`,`HUDSON_URL`],[`JENKINS`,`JENKINS_URL`],[`MAGNUM`],[`NETLIFY`],[`NETLIFY`,`NETLIFY_LOCAL`,{ci:!1}],[`NEVERCODE`],[`RENDER`],[`SAIL`,`SAILCI`],[`SEMAPHORE`],[`SCREWDRIVER`],[`SHIPPABLE`],[`SOLANO`,`TDDIUM`],[`STRIDER`],[`TEAMCITY`,`TEAMCITY_VERSION`],[`TRAVIS`],[`VERCEL`,`NOW_BUILDER`],[`VERCEL`,`VERCEL`,{ci:!1}],[`VERCEL`,`VERCEL_ENV`,{ci:!1}],[`APPCENTER`,`APPCENTER_BUILD_ID`],[`CODESANDBOX`,`CODESANDBOX_SSE`,{ci:!1}],[`CODESANDBOX`,`CODESANDBOX_HOST`,{ci:!1}],[`STACKBLITZ`],[`STORMKIT`],[`CLEAVR`],[`ZEABUR`],[`CODESPHERE`,`CODESPHERE_APP_ID`,{ci:!0}],[`RAILWAY`,`RAILWAY_PROJECT_ID`],[`RAILWAY`,`RAILWAY_SERVICE_ID`],[`DENO-DEPLOY`,`DENO_DEPLOYMENT_ID`],[`FIREBASE_APP_HOSTING`,`FIREBASE_APP_HOSTING`,{ci:!0}]],ir=function(){if(globalThis.process?.env)for(let e of rr){let t=e[1]||e[0];if(globalThis.process?.env[t])return{name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL===`/bin/jsh`&&globalThis.process?.versions?.webcontainer?{name:`stackblitz`,ci:!1}:{name:``,ci:!1}}();ir.name;function ar(e){return!!e&&e!==`false`}let or=globalThis.process?.platform||``;ar(tr.CI)||ir.ci;let sr=ar(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY);tr.DEBUG,nr===`test`||tr.TEST;let cr=(tr.MINIMAL,/^win/i.test(or)),lr=(/^linux/i.test(or),/^darwin/i.test(or),!ar(tr.NO_COLOR)&&(ar(tr.FORCE_COLOR)||(sr||cr)&&tr.TERM),(globalThis.process?.versions?.node||``).replace(/^v/,``)||null),ur=(Number(lr?.split(`.`)[0]),globalThis.process||Object.create(null)),dr={versions:{}},fr=(new Proxy(ur,{get:(e,t)=>t===`env`?tr:t in e?e[t]:t in dr?dr[t]:void 0}),globalThis.process?.release?.name===`node`),pr=!!globalThis.Bun||!!globalThis.process?.versions?.bun,mr=!!globalThis.Deno,hr=!!globalThis.fastly,gr=[[!!globalThis.Netlify,`netlify`],[!!globalThis.EdgeRuntime,`edge-light`],[globalThis.navigator?.userAgent===`Cloudflare-Workers`,`workerd`],[hr,`fastly`],[mr,`deno`],[pr,`bun`],[fr,`node`]];(function(){let e=gr.find(e=>e[0]);e&&e[1]})();let _r=E(`node:tty`)?.WriteStream?.prototype?.hasColors?.()??!1,Q=(e,t)=>{if(!_r)return e=>e;let n=`[${e}m`,r=`[${t}m`;return e=>{let i=e+``,a=i.indexOf(r);if(a===-1)return n+i+r;let o=n,s=0,c=(t===22?r:``)+n;for(;a!==-1;)o+=i.slice(s,a)+c,s=a+r.length,a=i.indexOf(r,s);return o+=i.slice(s)+r,o}},vr=(Q(0,0),Q(1,22),Q(2,22),Q(3,23),Q(4,24),Q(53,55),Q(7,27),Q(8,28),Q(9,29),Q(30,39),Q(31,39)),yr=Q(32,39),br=Q(33,39),xr=Q(34,39),Sr=(Q(35,39),Q(36,39)),Cr=(Q(37,39),Q(90,39));Q(40,49),Q(41,49),Q(42,49),Q(43,49),Q(44,49),Q(45,49),Q(46,49),Q(47,49),Q(100,49),Q(91,39),Q(92,39),Q(93,39),Q(94,39),Q(95,39),Q(96,39),Q(97,39),Q(101,49),Q(102,49),Q(103,49),Q(104,49),Q(105,49),Q(106,49),Q(107,49);function wr(e){if(typeof e!=`string`||e.startsWith(`file://`))return!1;try{return(0,H.lstatSync)(e).isDirectory()}catch{return!1}}function Tr(e,t=8){return(function(){if(Or!==void 0)return Or;try{return Or=!!Qn().getFips?.(),Or}catch{return Or=!1,Or}}()?Qn().createHash(`sha256`):Qn().createHash(`md5`)).update(e).digest(`hex`).slice(0,t)}let Er={true:yr(`true`),false:br(`false`),"[rebuild]":br(`[rebuild]`),"[esm]":xr(`[esm]`),"[cjs]":yr(`[cjs]`),"[import]":xr(`[import]`),"[require]":yr(`[require]`),"[native]":Sr(`[native]`),"[transpile]":br(`[transpile]`),"[fallback]":vr(`[fallback]`),"[unknown]":vr(`[unknown]`),"[hit]":yr(`[hit]`),"[miss]":br(`[miss]`),"[json]":yr(`[json]`),"[data]":yr(`[data]`)};function $(e,...t){if(!e.opts.debug)return;let n=process.cwd();console.log(Cr([`[jiti]`,...t.map(e=>e in Er?Er[e]:typeof e==`string`?e.replace(n,`.`):JSON.stringify(e))].join(` `)))}function Dr(e,t){return e.opts.interopDefault?function(e){let t=typeof e;if(e===null||t!==`object`&&t!==`function`)return e;let n=e.default,r=typeof n,i=n==null,a=r===`object`||r===`function`;return i&&e instanceof Promise?e:new Proxy(e,{get(t,r,o){if(r===`__esModule`)return!0;if(r===`default`)return i?e:typeof n?.default==`function`&&e.__esModule?n.default:n;if(Reflect.has(t,r))return Reflect.get(t,r,o);if(a&&!(n instanceof Promise)){let e=Reflect.get(n,r,o);return typeof e==`function`&&(e=e.bind(n)),e}},apply:(e,t,i)=>typeof e==`function`?Reflect.apply(e,t,i):r===`function`?Reflect.apply(n,t,i):void 0})}(t):t}let Or;function kr(e,t){return!!Ar(e,t)}function Ar(e,t){let n=process.env[e];if(!(e in process.env))return t;try{return JSON.parse(n)}catch{return t}}let jr=/\.(c|m)?j(sx?)$/,Mr=/\.(c|m)?t(sx?)$/;function Nr(e,t,n){let r,i;if(e.isNativeRe.test(t))return t;e.alias&&(t=function(e,t){let n=vt(e);t=Jn(t);for(let[e,r]of Object.entries(t))if(n.startsWith(e)&&Yn(n[(Yn(e)?e.slice(0,-1):e).length]))return wt(r,n.slice(e.length));return n}(t,e.alias));let a=n?.parentURL||e.url;wr(a)&&(a=wt(a,`_index.js`));let o=(n?.async?[n?.conditions,[`node`,`import`],[`node`,`require`]]:[n?.conditions,[`node`,`require`],[`node`,`import`]]).filter(Boolean);for(let n of o){try{r=Bn(t,{url:a,conditions:n,extensions:e.opts.extensions})}catch(e){i=e}if(r)return r}try{return e.nativeRequire.resolve(t,{paths:n.paths})}catch(e){i=e}for(let i of e.additionalExts)if(r=Pr(e,t+i,a,n)||Pr(e,t+`/index`+i,a,n),r||(Mr.test(e.filename)||Mr.test(e.parentModule?.filename||``)||jr.test(t))&&(r=Pr(e,t.replace(jr,`.$1t$2`),a,n),r))return r;if(!n?.try)throw i}function Pr(e,t,n,r){try{return e.nativeRequire.resolve(t,{...r,paths:[kt(Mn(n)),...r?.paths||[]]})}catch{}}let Fr=E(`node:perf_hooks`),Ir=E(`node:vm`);var Lr=r.n(Ir);function Rr(e,t,n){let r=e.parentCache||{};if(t.startsWith(`node:`))return zr(e,t,n.async);if(t.startsWith(`file:`))t=(0,W.fileURLToPath)(t);else if(t.startsWith(`data:`)){if(!n.async)throw Error("`data:` URLs are only supported in ESM context. Use `import` or `jiti.import` instead.");return $(e,`[native]`,`[data]`,`[import]`,t),zr(e,t,!0)}if(ut.builtinModules.includes(t)||t===`.pnp.js`)return zr(e,t,n.async);if(e.opts.tryNative&&!e.opts.transformOptions)try{if(!(t=Nr(e,t,n))&&n.try)return;if($(e,`[try-native]`,n.async&&e.nativeImport?`[import]`:`[require]`,t),n.async&&e.nativeImport)return e.nativeImport(t).then(n=>(!1===e.opts.moduleCache&&delete e.nativeRequire.cache[t],Dr(e,n)));{let n=e.nativeRequire(t);return!1===e.opts.moduleCache&&delete e.nativeRequire.cache[t],Dr(e,n)}}catch(n){$(e,`[try-native] Using fallback for ${t} because of an error:`,n)}let i=Nr(e,t,n);if(!i&&n.try)return;let a=Ot(i);if(a===`.json`){$(e,`[json]`,i);let t=e.nativeRequire(i);return t&&!(`default`in t)&&Object.defineProperty(t,`default`,{value:t,enumerable:!1}),t}if(a&&!e.opts.extensions.includes(a))return $(e,`[native]`,`[unknown]`,n.async?`[import]`:`[require]`,i),zr(e,i,n.async);if(e.isNativeRe.test(i))return $(e,`[native]`,n.async?`[import]`:`[require]`,i),zr(e,i,n.async);if(r[i])return Dr(e,r[i]?.exports);if(e.opts.moduleCache){let t=e.nativeRequire.cache[i];if(t?.loaded)return Dr(e,t.exports)}return Ur(e,(0,H.readFileSync)(i,`utf8`),{id:t,filename:i,ext:a,cache:r,async:n.async})}function zr(e,t,n){return n&&e.nativeImport?e.nativeImport(function(e){return cr&&U(e)?Nn(e):e}(t)).then(t=>Dr(e,t)):Dr(e,e.nativeRequire(t))}function Br(e,t,n){if(!e.opts.fsCache||!t.filename)return n();let r=` /* v9-${Tr(t.source,16)} */\n`,i=`${At(kt(t.filename))}-${function(e){let t=e.split(qn).pop();if(!t)return;let n=t.lastIndexOf(`.`);return n<=0?t:t.slice(0,n)}(t.filename)}`+(e.opts.sourceMaps?`+map`:``)+(t.interopDefault?`.i`:``)+`.${Tr(t.filename)}`+(t.async?`.mjs`:`.cjs`);t.jsx&&t.filename.endsWith(`x`)&&(i+=`x`);let a=e.opts.fsCache,o=wt(a,i);if(!e.opts.rebuildFsCache&&(0,H.existsSync)(o)){let n=(0,H.readFileSync)(o,`utf8`);if(n.endsWith(r))return $(e,`[cache]`,`[hit]`,t.filename,`~>`,o),n}$(e,`[cache]`,`[miss]`,t.filename);let s=n();return s.includes(`__JITI_ERROR__`)||((0,H.writeFileSync)(o,s+r,`utf8`),$(e,`[cache]`,`[store]`,t.filename,`~>`,o)),s}function Vr(t){if(!0===t.opts.fsCache&&(t.opts.fsCache=function(t){let n=t.filename&&Et(t.filename,`../node_modules`);if(n&&(0,H.existsSync)(n))return wt(n,`.cache/jiti`);let r=(0,e.tmpdir)();if(process.env.TMPDIR&&r===process.cwd()&&!process.env.JITI_RESPECT_TMPDIR_ENV){let t=process.env.TMPDIR;delete process.env.TMPDIR,r=(0,e.tmpdir)(),process.env.TMPDIR=t}return wt(r,`jiti`)}(t)),t.opts.fsCache)try{if((0,H.mkdirSync)(t.opts.fsCache,{recursive:!0}),!function(e){try{return(0,H.accessSync)(e,H.constants.W_OK),!0}catch{return!1}}(t.opts.fsCache))throw Error(`directory is not writable!`)}catch(e){$(t,`Error creating cache directory at `,t.opts.fsCache,e),t.opts.fsCache=!1}}function Hr(e,t){let n=Br(e,t,()=>{let n=e.opts.transform({...e.opts.transformOptions,babel:{...e.opts.sourceMaps?{sourceFileName:t.filename,sourceMaps:`inline`}:{},...e.opts.transformOptions?.babel},interopDefault:e.opts.interopDefault,...t});return n.error&&e.opts.debug&&$(e,n.error),n.code});return n.startsWith(`#!`)&&(n=`// `+n),n}function Ur(e,t,n={}){let r=n.id||(n.filename?At(n.filename):`_jitiEval.${n.ext||(n.async?`mjs`:`js`)}`),i=n.filename||Nr(e,r,{async:n.async}),a=n.ext||Ot(i),o=n.cache||e.parentCache||{},s=/\.[cm]?tsx?$/.test(a),c=a===`.mjs`||a===`.js`&&function(e){for(;e&&e!==`.`&&e!==`/`;){e=wt(e,`..`);try{let t=(0,H.readFileSync)(wt(e,`package.json`),`utf8`);try{return JSON.parse(t)}catch{}break}catch{}}}(i)?.type===`module`,l=a===`.cjs`,u=n.forceTranspile??(!l&&!(c&&n.async)&&(s||c||e.isTransformRe.test(i)||Un(t))),d=Fr.performance.now();if(u){t=Hr(e,{filename:i,source:t,ts:s,async:n.async??!1,jsx:e.opts.jsx});let r=Math.round(1e3*(Fr.performance.now()-d))/1e3;$(e,`[transpile]`,n.async?`[esm]`:`[cjs]`,i,`(${r}ms)`)}else{if($(e,`[native]`,n.async?`[import]`:`[require]`,i),n.async)return Promise.resolve(zr(e,i,n.async)).catch(r=>($(e,`Native import error:`,r),$(e,`[fallback]`,i),Ur(e,t,{...n,forceTranspile:!0})));try{return zr(e,i,n.async)}catch(r){$(e,`Native require error:`,r),$(e,`[fallback]`,i),t=Hr(e,{filename:i,source:t,ts:s,async:n.async??!1,jsx:e.opts.jsx})}}let f=new ut.Module(i);f.filename=i,e.parentModule&&(f.parent=e.parentModule,Array.isArray(e.parentModule.children)&&!e.parentModule.children.includes(f)&&e.parentModule.children.push(f));let p=Gr(i,e.opts,{parentModule:f,parentCache:o,nativeImport:e.nativeImport,onError:e.onError,createRequire:e.createRequire},!0),m;f.require=p,f.path=kt(i),f.paths=ut.Module._nodeModulePaths(f.path),o[i]=f,e.opts.moduleCache&&(e.nativeRequire.cache[i]=f);let h=function(e,t){return`(${t?.async?`async `:``}function (exports, require, module, __filename, __dirname, jitiImport, jitiESMResolve) { ${e}\n});`}(t,{async:n.async});try{m=Lr().runInThisContext(h,{filename:i,lineOffset:0,displayErrors:!1})}catch(t){t.name===`SyntaxError`&&n.async&&e.nativeImport?($(e,`[esm]`,`[import]`,`[fallback]`,i),m=function(e,t){let n=`data:text/javascript;base64,${Buffer.from(`export default ${e}`).toString(`base64`)}`;return(...e)=>t(n).then(t=>t.default(...e))}(h,e.nativeImport)):(e.opts.moduleCache&&delete e.nativeRequire.cache[i],e.onError(t))}let g;try{g=m(f.exports,f.require,f,f.filename,kt(f.filename),p.import,p.esmResolve)}catch(t){e.opts.moduleCache&&delete e.nativeRequire.cache[i],e.onError(t)}function _(){if(f.exports&&f.exports.__JITI_ERROR__){let{filename:t,line:n,column:r,code:i,message:a}=f.exports.__JITI_ERROR__,o=Error(`${i}: ${a} \n ${`${t}:${n}:${r}`}`);Error.captureStackTrace(o,Rr),e.onError(o)}return f.loaded=!0,Dr(e,f.exports)}return n.async?Promise.resolve(g).then(_):_()}let Wr=(0,e.platform)()===`win32`;function Gr(e,t={},n,r=!1){let i=r?t:function(e){let t={fsCache:kr(`JITI_FS_CACHE`,kr(`JITI_CACHE`,!0)),rebuildFsCache:kr(`JITI_REBUILD_FS_CACHE`,!1),moduleCache:kr(`JITI_MODULE_CACHE`,kr(`JITI_REQUIRE_CACHE`,!0)),debug:kr(`JITI_DEBUG`,!1),sourceMaps:kr(`JITI_SOURCE_MAPS`,!1),interopDefault:kr(`JITI_INTEROP_DEFAULT`,!0),extensions:Ar(`JITI_EXTENSIONS`,[`.js`,`.mjs`,`.cjs`,`.ts`,`.tsx`,`.mts`,`.cts`,`.mtsx`,`.ctsx`]),alias:Ar(`JITI_ALIAS`,{}),nativeModules:Ar(`JITI_NATIVE_MODULES`,[]),transformModules:Ar(`JITI_TRANSFORM_MODULES`,[]),tryNative:Ar(`JITI_TRY_NATIVE`,`Bun`in globalThis),jsx:kr(`JITI_JSX`,!1)};t.jsx&&t.extensions.push(`.jsx`,`.tsx`);let n={};return e.cache!==void 0&&(n.fsCache=e.cache),e.requireCache!==void 0&&(n.moduleCache=e.requireCache),{...t,...n,...e}}(t),a=i.alias&&Object.keys(i.alias).length>0?Jn(i.alias||{}):void 0,o=[`typescript`,`jiti`,...i.nativeModules||[]],s=RegExp(`node_modules/(${o.map(e=>Wn(e)).join(`|`)})/`),c=[...i.transformModules||[]],l=RegExp(`node_modules/(${c.map(e=>Wn(e)).join(`|`)})/`);e||=process.cwd(),!r&&wr(e)&&(e=wt(e,`_index.js`));let u=Nn(e),d=[...i.extensions].filter(e=>e!==`.js`),f=n.createRequire(Wr?e.replace(/\//g,`\\`):e),p={filename:e,url:u,opts:i,alias:a,nativeModules:o,transformModules:c,isNativeRe:s,isTransformRe:l,additionalExts:d,nativeRequire:f,onError:n.onError,parentModule:n.parentModule,parentCache:n.parentCache,nativeImport:n.nativeImport,createRequire:n.createRequire};return r||$(p,`[init]`,...[[`version:`,Xn.rE],[`module-cache:`,i.moduleCache],[`fs-cache:`,i.fsCache],[`rebuild-fs-cache:`,i.rebuildFsCache],[`interop-defaults:`,i.interopDefault]].flat()),r||Vr(p),Object.assign(function(e){return Rr(p,e,{async:!1})},{cache:i.moduleCache?f.cache:Object.create(null),extensions:f.extensions,main:f.main,options:i,resolve:Object.assign(function(e){return Nr(p,e,{async:!1})},{paths:f.resolve.paths}),transform:e=>Hr(p,e),evalModule:(e,t)=>Ur(p,e,t),async import(e,t){let n=await Rr(p,e,{...t,async:!0});return t?.default?n?.default??n:n},esmResolve(e,t){typeof t==`string`&&(t={parentURL:t});let n=Nr(p,e,{parentURL:u,...t,async:!0});return!n||typeof n!=`string`||n.startsWith(`file://`)?n:Nn(n)}})}})(),t.exports=i.default})()}))();var ge=class{emitter;constructor(){this.emitter=r()}on(e,t){pe(e).forEach(e=>{this.emitter.on(e,t)})}off(e,t){pe(e).forEach(e=>{this.emitter.off(e,t)})}emit(e,t){pe(e).forEach(e=>{this.emitter.emit(e,t)})}removeAllListeners(){this.emitter.all.clear()}},_e=class{listeners;constructor(){this.listeners=new Map}on(e,t){pe(e).forEach(e=>{let n=this.listeners.get(e)||new Set;n.add(t),this.listeners.set(e,n)})}off(e,t){pe(e).forEach(e=>{let n=this.listeners.get(e);n&&n.delete(t)})}async emit(e,...t){let n=pe(e).flatMap(e=>{let t=this.listeners.get(e)||new Set,n=this.listeners.get(`*`)||new Set;return[...Array.from(t),...Array.from(n)]});return n.length===0?[]:await Promise.all(n.map(async n=>{try{let e=n(...t);return e instanceof Promise?await e:e}catch(t){console.error(`Error in event listener for ${String(e)}:`,t);return}}))}removeAllListeners(){this.listeners.clear()}};function D(e,...t){return class extends e{static _instance;static getInstance(){return this._instance||=new e(...t),this._instance}static clearInstance(){this._instance=void 0}}}const O=D(class extends ge{destroy(){this.removeAllListeners()}fatal(e,t,n){this.emit(`fatal`,{code:t,message:e,data:n,timestamp:Date.now()})}error(e,t,n){this.emit(`error`,{code:t,message:e,data:n,timestamp:Date.now()})}warn(e,t,n){this.emit(`warning`,{code:t,message:e,data:n,timestamp:Date.now()})}});var k=class{data;_schema;_defaultValue;_path;constructor(e){let{schema:t,default:n,path:r}=e;this._schema=t,this._defaultValue=n,this._path=r}set(e){let t=this._schema[`~standard`].validate(e);if(t instanceof Promise)throw Error(`StructuredConfigFile does not support async validation`);if(t.issues)throw this.reportInvalidConfigFile(t.issues),Error(`Invalid config data for ${this._path}: ${t.issues.map(e=>e.message).join(`; `)}`);this.data=this.onBeforeSave(e),this.save(e)}get(e={}){return this.data?this.data:this.load(e)}getKey(e,t={}){return this.get(t)[e]}save(e){let t=this.onBeforeSave(e);try{d(this.getFilePath()),i.writeFileSync(this.getFilePath(),JSON.stringify(t,void 0,2))}catch{return}return this.data=t}load(e={}){let{createIfMissing:t=!0}=e;if(!this.fileExists(this.getFilePath())||!this.canReadWriteFile(this.getFilePath())){t&&this.save(this._defaultValue);let e=this.onAfterLoad(this._defaultValue);return t&&(this.data=e),e}try{let e=i.readFileSync(this.getFilePath(),`utf8`),t=this.onAfterLoad(this.parseStoredData(e));return this.data=t,t}catch{return this.data=this._defaultValue}}onBeforeSave(e){return e}onAfterLoad(e){return e}getFilePath(){return this._path}parseStoredData(e){try{let t=n(`string.json.parse`).to(`object`)(e);if(t instanceof n.errors)return this._defaultValue;let r=this._schema[`~standard`].validate(t);if(r instanceof Promise)throw Error(`StructuredConfigFile does not support async validation`);return r.issues?this.migrate(t,this._defaultValue):this.migrate(r.value,this._defaultValue)}catch{return this._defaultValue}}canReadWriteFile(e){try{return i.accessSync(e,i.constants.R_OK|i.constants.W_OK),!0}catch{return!1}}fileExists(e){try{return i.accessSync(e,i.constants.F_OK),!0}catch{return!1}}migrate(e,t){let n={...e};for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(r in e?e[r]!==null&&t[r]!==null&&typeof e[r]==`object`&&typeof t[r]==`object`&&!Array.isArray(e[r])&&!Array.isArray(t[r])?n[r]=this.migrate(e[r],t[r]):Array.isArray(t[r])&&(n[r]=e[r]):n[r]=t[r]);return n}reportInvalidConfigFile(e){O.getInstance().error(`Invalid config file`,`INVALID_CONFIG_FILE`,{issues:e.map(e=>e.message),filePath:this._path,data:this.data})}};function ve(e,t,n){return typeof e!=`object`||!e?String(e):e instanceof Error?JSON.stringify(e,(e,t)=>{if(t instanceof Error){let e={};for(let n of Object.getOwnPropertyNames(t))e[n]=t[n];return e}return t},n):e instanceof Map?JSON.stringify(Object.fromEntries(e.entries()),t,n):e instanceof Set?JSON.stringify(Array.from(e),t,n):JSON.stringify(e,t,n)}const A=/\x1b\[[0-9;]*m/g;function ye(e){return e.replace(A,``)}var be=class e extends ge{stream;logPath;baseFileName;currentDate;rotationCheckInterval;isRotating=!1;constructor(e,t){super(),this.logPath=e,this.baseFileName=t.replace(`.log`,``),this.currentDate=this.getDateString(new Date),this.ensureLogDirectory(),this.ensureLogFile(),this.stream=this.createStream(),this.rotationCheckInterval=this.startRotationCheck(),this.cleanupOldLogs()}static scope(t,n){return new e(t,n)}log(...e){this.write(`info`,...e)}error(...e){this.write(`error`,...e)}warn(...e){this.write(`warn`,...e)}info(...e){this.write(`info`,...e)}debug(...e){this.write(`debug`,...e)}async close(){clearInterval(this.rotationCheckInterval),await new Promise(e=>{this.stream.end(()=>e())})}getCurrentFileName(){return this.getFileName(this.currentDate)}static getMessageElements(e,...t){let n=new Date;return{timestamp:n.toISOString().replace(`T`,` `).replace(/\.\d+Z$/,``)+`.${n.getUTCMilliseconds().toString().padStart(3,`0`)}`,level:e,message:t.map(e=>ve(e)).join(` `)}}getFileName(e){return`${this.baseFileName}-${e}.log`}ensureLogDirectory(){try{s(this.logPath,{recursive:!0})}catch(e){throw console.error(`Failed to create log directory ${this.logPath}:`,e),e}}ensureLogFile(){let e=p(this.logPath,this.getFileName(this.currentDate));if(!o(e))try{u(e,``,`utf8`)}catch(t){throw console.error(`Failed to create log file ${e}:`,t),t}}getDateString(e){return`${e.getUTCFullYear()}-${(e.getUTCMonth()+1).toString().padStart(2,`0`)}-${e.getUTCDate().toString().padStart(2,`0`)}`}createStream(){return a(p(this.logPath,this.getFileName(this.currentDate)),{flags:`a`,encoding:`utf8`})}async rotateLogs(){if(this.isRotating)return;this.isRotating=!0;let e=this.getDateString(new Date);e!==this.currentDate&&await new Promise(t=>{this.stream.end(()=>{this.currentDate=e,this.stream=this.createStream(),this.cleanupOldLogs(),t()})}),this.isRotating=!1}startRotationCheck(){return setInterval(()=>this.rotateLogs(),6e4)}cleanupOldLogs(){let e=c(this.logPath),t=new Date,n=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()-7));e.filter(e=>e.startsWith(this.baseFileName)&&e.endsWith(`.log`)).filter(e=>{let[t,r,i]=e.replace(`${this.baseFileName}-`,``).replace(`.log`,``).split(`-`).map(Number);return new Date(Date.UTC(t,r-1,i))<=n}).forEach(e=>{try{l(p(this.logPath,e))}catch(t){console.error(`Failed to delete old log file ${e}:`,t)}})}ensureStreamValid(){if(!this.stream.writable||this.stream.destroyed)try{this.stream=this.createStream()}catch(e){this.emit(`error`,e instanceof Error?e:Error(String(e)))}}write(t,...n){let{timestamp:r,message:i}=e.getMessageElements(t,...n),a=`[${r}] [${t}] ${ye(i)}\n`;this.ensureStreamValid(),this.stream.write(a,e=>{if(e)if(e.code===`ERR_STREAM_WRITE_AFTER_END`||!this.stream.writable)try{this.stream=this.createStream(),this.stream.write(a,e=>{e?this.emit(`error`,e):this.emit(`write`,a)})}catch(e){this.emit(`error`,e instanceof Error?e:Error(String(e)))}else this.emit(`error`,e);else this.emit(`write`,a)})}};const j=()=>h.join(process.env.APPDATA??``,`overlayed`),xe=()=>h.join(j(),`logs`),Se=e=>h.join(j(),`apps`,e),Ce=e=>h.join(Se(e),`logs`),we=()=>h.join(j(),`meta.json`),Te=()=>h.join(j(),`crash-dumps`);var Ee=class{fileLogger;path;appId;messageQueue=new he;fileName;_debug=!1;silent=!1;forceSilent=!1;constructor(e){this.fileName=e}init(e,t=!1,n=!1,r=!1){this.appId=e,this._debug=t,this.silent=n,this.forceSilent=r,this.path=Ce(e),this.fileLogger=new be(this.path,this.fileName),this.messageQueue.flush().forEach(e=>{this.fileLogger?.[e.type](...e.args)})}scope(e){if(!this.appId||!this.path)throw Error(`Logger not initialized`);let t=v.cyan(`[${e}]`);return{scope:e=>this.scope(e),error:(...e)=>this.error(t,...e),warn:(...e)=>this.warn(t,...e),info:(...e)=>this.info(t,...e),log:(...e)=>this.log(t,...e),debug:(...e)=>this.debug(t,...e)}}error(...e){this.handle(`error`,...e)}warn(...e){this.handle(`warn`,...e)}info(...e){this.handle(`log`,...e)}debug(...e){this._debug&&this.handle(`debug`,...e)}log(...e){this.handle(`log`,...e)}handle(e,...t){this.logToConsole(e,...t),this.fileLogger?this.fileLogger[e](...t):this.messageQueue.add({type:e,args:t})}logToConsole(e,...t){let n={error:v.red,warn:v.yellow,debug:v.blue,log:v.white};if(this.forceSilent||this.silent&&!this._debug)return;let{timestamp:r,message:i}=be.getMessageElements(e,...t),a=console[e],o=n[e];a(`${v.gray(r)} ${o(i)}`)}};const M=D(Ee,`overlayed.log`);var N=class extends ee{blob;chunkSizeMb;maxConcurrent;shouldStop=!1;constructor(e,t){super(),this.blob=e,this.chunkSizeMb=t.chunkSizeMb,this.maxConcurrent=t.maxConcurrent??3}get totalChunks(){return Math.ceil(this.blob.size/(this.chunkSizeMb*1024*1024))}async chunk(e){let t=this.chunkSizeMb*1024*1024,n=this.totalChunks;if(n===0)return;let r=new Map,i=new Set,a=new Set,o=[];for(let e=0;e<n;e++)o.push(e);let s=async n=>{let s=n*t,c=Math.min(s+t,this.blob.size),l=this.blob.slice(s,c);try{await e(l,n),a.add(n),this.emit(`chunkComplete`,n),i.delete(n)}catch(e){let t=r.get(n)||0;t<5?(r.set(n,t+1),await new Promise(e=>setTimeout(e,(t+1)*1e3)),o.push(n)):(a.add(n),this.emit(`error`,e),this.shouldStop=!0,i.delete(n))}},c=[],l=async()=>{for(;(o.length>0||i.size>0)&&!this.shouldStop;){if(o.length===0){await new Promise(e=>setTimeout(e,10));continue}let e=o.shift();a.has(e)||i.has(e)||(i.add(e),await s(e))}};for(let e=0;e<this.maxConcurrent;e++)c.push(l());await Promise.all(c)}};function P(e,t){let{recursive:n}=F(t);return te(e)?n?De(e).map(t=>[e,t]):ie(e).map(t=>[e,t]):[]}function F(e){return{recursive:e?.recursive??!0}}function De(e){return ie(e,{withFileTypes:!0}).flatMap(t=>{let n=h.join(e,t.name);return t.isDirectory()?De(n):[n]})}function I(e){return Oe(e),e}function Oe(e){if(!me(e.applicationId))throw Error(`Invalid applicationId, must be a valid ULID.`)}function ke(e,t){let n=t?.cwd??process.cwd(),r=m.join(n,`.overlayed`);y.existsSync(r)||y.mkdirSync(r,{recursive:!0});let i={application:{id:e.id,name:e.name,slug:e.slug,siteUrl:e.siteUrl},release:{id:null,channel:`local`,version:`0.0.0`}},a=m.join(r,`meta.json`);return y.writeFileSync(a,JSON.stringify(i,null,2)),i}const{PipeEventServer:Ae,PipeEventClient:je,PipeEventBase:Me,ProcessMonitor:Ne,Process:Pe,HardwareInterface:Fe}=e(import.meta.url)(`@overlayed/app/dist/native-interface/build/overlayed_native_interface_x64.node`),Ie=D(class extends ge{server=null;_hasConnection=!1;pipeId;get hasConnection(){return this._hasConnection}constructor(e){super(),this.pipeId=e,this.init()}destroy(){this.server&&=(this._hasConnection=!1,this.server?.removeAllListeners(),null)}init(){this.server=new Ae(this.pipeId,{clientCount:1,access:1}),this.server.on(`event`,e=>{try{let t=JSON.parse(e);this.emit(`data`,[t])}catch(e){this.emit(`error`,e)}}),this.server.on(`connected`,()=>{this._hasConnection=!0,this.emit(`connected`,void 0)}),this.server.on(`disconnected`,()=>{this._hasConnection=!1,this.emit(`disconnected`,void 0)})}},`overlayed-event-server`),{RenderInterface:Le,renderHookPath:Re}=e(import.meta.url)(`@overlayed/app/dist/render-interface/build/overlayed_render_interface_x64.node`);let ze=function(e){return e[e.LeftButton=1]=`LeftButton`,e[e.RightButton=2]=`RightButton`,e[e.Cancel=3]=`Cancel`,e[e.MiddleButton=4]=`MiddleButton`,e[e.ExtraButton1=5]=`ExtraButton1`,e[e.ExtraButton2=6]=`ExtraButton2`,e[e.Back=8]=`Back`,e[e.Tab=9]=`Tab`,e[e.Clear=12]=`Clear`,e[e.Return=13]=`Return`,e[e.Shift=16]=`Shift`,e[e.Control=17]=`Control`,e[e.Menu=18]=`Menu`,e[e.Pause=19]=`Pause`,e[e.CapsLock=20]=`CapsLock`,e[e.Kana=21]=`Kana`,e[e.Hangeul=21]=`Hangeul`,e[e.Hangul=21]=`Hangul`,e[e.Junja=23]=`Junja`,e[e.Final=24]=`Final`,e[e.Hanja=25]=`Hanja`,e[e.Kanji=25]=`Kanji`,e[e.Escape=27]=`Escape`,e[e.Convert=28]=`Convert`,e[e.NonConvert=29]=`NonConvert`,e[e.Accept=30]=`Accept`,e[e.ModeChange=31]=`ModeChange`,e[e.Space=32]=`Space`,e[e.Prior=33]=`Prior`,e[e.Next=34]=`Next`,e[e.End=35]=`End`,e[e.Home=36]=`Home`,e[e.Left=37]=`Left`,e[e.Up=38]=`Up`,e[e.Right=39]=`Right`,e[e.Down=40]=`Down`,e[e.Select=41]=`Select`,e[e.Print=42]=`Print`,e[e.Execute=43]=`Execute`,e[e.Snapshot=44]=`Snapshot`,e[e.Insert=45]=`Insert`,e[e.Delete=46]=`Delete`,e[e.Help=47]=`Help`,e[e.N0=48]=`N0`,e[e.N1=49]=`N1`,e[e.N2=50]=`N2`,e[e.N3=51]=`N3`,e[e.N4=52]=`N4`,e[e.N5=53]=`N5`,e[e.N6=54]=`N6`,e[e.N7=55]=`N7`,e[e.N8=56]=`N8`,e[e.N9=57]=`N9`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.LeftWindows=91]=`LeftWindows`,e[e.RightWindows=92]=`RightWindows`,e[e.Application=93]=`Application`,e[e.Sleep=95]=`Sleep`,e[e.Numpad0=96]=`Numpad0`,e[e.Numpad1=97]=`Numpad1`,e[e.Numpad2=98]=`Numpad2`,e[e.Numpad3=99]=`Numpad3`,e[e.Numpad4=100]=`Numpad4`,e[e.Numpad5=101]=`Numpad5`,e[e.Numpad6=102]=`Numpad6`,e[e.Numpad7=103]=`Numpad7`,e[e.Numpad8=104]=`Numpad8`,e[e.Numpad9=105]=`Numpad9`,e[e.Multiply=106]=`Multiply`,e[e.Add=107]=`Add`,e[e.Separator=108]=`Separator`,e[e.Subtract=109]=`Subtract`,e[e.Decimal=110]=`Decimal`,e[e.Divide=111]=`Divide`,e[e.F1=112]=`F1`,e[e.F2=113]=`F2`,e[e.F3=114]=`F3`,e[e.F4=115]=`F4`,e[e.F5=116]=`F5`,e[e.F6=117]=`F6`,e[e.F7=118]=`F7`,e[e.F8=119]=`F8`,e[e.F9=120]=`F9`,e[e.F10=121]=`F10`,e[e.F11=122]=`F11`,e[e.F12=123]=`F12`,e[e.F13=124]=`F13`,e[e.F14=125]=`F14`,e[e.F15=126]=`F15`,e[e.F16=127]=`F16`,e[e.F17=128]=`F17`,e[e.F18=129]=`F18`,e[e.F19=130]=`F19`,e[e.F20=131]=`F20`,e[e.F21=132]=`F21`,e[e.F22=133]=`F22`,e[e.F23=134]=`F23`,e[e.F24=135]=`F24`,e[e.NumLock=144]=`NumLock`,e[e.ScrollLock=145]=`ScrollLock`,e[e.NEC_Equal=146]=`NEC_Equal`,e[e.Fujitsu_Jisho=146]=`Fujitsu_Jisho`,e[e.Fujitsu_Masshou=147]=`Fujitsu_Masshou`,e[e.Fujitsu_Touroku=148]=`Fujitsu_Touroku`,e[e.Fujitsu_Loya=149]=`Fujitsu_Loya`,e[e.Fujitsu_Roya=150]=`Fujitsu_Roya`,e[e.LeftShift=160]=`LeftShift`,e[e.RightShift=161]=`RightShift`,e[e.LeftControl=162]=`LeftControl`,e[e.RightControl=163]=`RightControl`,e[e.LeftMenu=164]=`LeftMenu`,e[e.RightMenu=165]=`RightMenu`,e[e.BrowserBack=166]=`BrowserBack`,e[e.BrowserForward=167]=`BrowserForward`,e[e.BrowserRefresh=168]=`BrowserRefresh`,e[e.BrowserStop=169]=`BrowserStop`,e[e.BrowserSearch=170]=`BrowserSearch`,e[e.BrowserFavorites=171]=`BrowserFavorites`,e[e.BrowserHome=172]=`BrowserHome`,e[e.VolumeMute=173]=`VolumeMute`,e[e.VolumeDown=174]=`VolumeDown`,e[e.VolumeUp=175]=`VolumeUp`,e[e.MediaNextTrack=176]=`MediaNextTrack`,e[e.MediaPrevTrack=177]=`MediaPrevTrack`,e[e.MediaStop=178]=`MediaStop`,e[e.MediaPlayPause=179]=`MediaPlayPause`,e[e.LaunchMail=180]=`LaunchMail`,e[e.LaunchMediaSelect=181]=`LaunchMediaSelect`,e[e.LaunchApplication1=182]=`LaunchApplication1`,e[e.LaunchApplication2=183]=`LaunchApplication2`,e[e.OEM1=186]=`OEM1`,e[e.OEMPlus=187]=`OEMPlus`,e[e.OEMComma=188]=`OEMComma`,e[e.OEMMinus=189]=`OEMMinus`,e[e.OEMPeriod=190]=`OEMPeriod`,e[e.OEM2=191]=`OEM2`,e[e.OEM3=192]=`OEM3`,e[e.OEM4=219]=`OEM4`,e[e.OEM5=220]=`OEM5`,e[e.OEM6=221]=`OEM6`,e[e.OEM7=222]=`OEM7`,e[e.OEM8=223]=`OEM8`,e[e.OEMAX=225]=`OEMAX`,e[e.OEM102=226]=`OEM102`,e[e.ICOHelp=227]=`ICOHelp`,e[e.ICO00=228]=`ICO00`,e[e.ProcessKey=229]=`ProcessKey`,e[e.ICOClear=230]=`ICOClear`,e[e.Packet=231]=`Packet`,e[e.OEMReset=233]=`OEMReset`,e[e.OEMJump=234]=`OEMJump`,e[e.OEMPA1=235]=`OEMPA1`,e[e.OEMPA2=236]=`OEMPA2`,e[e.OEMPA3=237]=`OEMPA3`,e[e.OEMWSCtrl=238]=`OEMWSCtrl`,e[e.OEMCUSel=239]=`OEMCUSel`,e[e.OEMATTN=240]=`OEMATTN`,e[e.OEMFinish=241]=`OEMFinish`,e[e.OEMCopy=242]=`OEMCopy`,e[e.OEMAuto=243]=`OEMAuto`,e[e.OEMENLW=244]=`OEMENLW`,e[e.OEMBackTab=245]=`OEMBackTab`,e[e.ATTN=246]=`ATTN`,e[e.CRSel=247]=`CRSel`,e[e.EXSel=248]=`EXSel`,e[e.EREOF=249]=`EREOF`,e[e.Play=250]=`Play`,e[e.Zoom=251]=`Zoom`,e[e.Noname=252]=`Noname`,e[e.PA1=253]=`PA1`,e[e.OEMClear=254]=`OEMClear`,e}({});const Be=n({game:`string`,type:`string`,creation_time:`number`}).and({game:`'siege' | 'tft'`}),Ve=t({"#event1":`logged_in | module_loaded | module_unloaded | unsupported_game_version`,event:`event1`,logged_in:Be.and({type:`'logged_in'`,content:{account_id:`string`}}),module_loaded:Be.and({type:`'module_loaded'`,content:{game_version:`string`,process_hash:`string`}}),module_unloaded:Be.and({type:`'module_unloaded'`}),unsupported_game_version:Be.and({type:`'unsupported_game_version'`,content:{game_version:`string`,process_hash:`string`}})}).export(),He=Object.keys(Ve).filter(e=>e!==`event`);function Ue(){return{key:`universal`,events:Ve}}var We=class{options=null;logger;initialized=!1;constructor(e){this.logger=M.getInstance().scope(e)}init(e){this.logger.log(`Initializing`),this.options=e||null,this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1}},L=class extends ge{options=null;logger;initialized=!1;constructor(e){super(),this.logger=M.getInstance().scope(e)}init(e){this.logger.log(`Initializing`),this.options=e||null,this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1,this.removeAllListeners()}},Ge=class extends _e{options=null;logger;initialized=!1;constructor(e){super(),this.logger=M.getInstance().scope(e)}init(e){this.logger.log(`Initializing`),this.options=e||null,this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1,this.removeAllListeners()}};const Ke=import.meta.env.VITE_API_BASE_URL,R=se.create({baseURL:Ke,headers:{Accept:`application/json`,"Accept-Encoding":`gzip, deflate, br`}});let qe;function Je(e){qe=e}let Ye;function Xe(e){Ye=e}function z(e){return`overlayed/app (${Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `)})`}R.interceptors.request.use(e=>{let t=qe?.();e.headers??={},t&&(e.headers[`X-Api-Key`]=t);let n=Ye?.();return n&&(e.headers[`User-Agent`]=z(n)),e});function Ze(e,t){if(t<=0)throw Error(`Chunk size must be greater than 0`);if(e.length===0)return[];let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function B(e){return e}function Qe(e){return e?t=>(e(t),t):B}const $e=Qe();function et(e){return R.get(`/v1/public/applications/${e}`)}function tt(e,t){return R.get(`/v1/public/applications/${e}/releases/check`,{params:t})}function nt(e,t){return R.post(`/v1/public/applications/${e}/game-crash-reports`,t)}function rt(e,t,n){return R.post(`/v1/public/applications/${e}/game-crash-reports/${t}/confirm`,n)}function it(e,t){let n=new FormData;return n.append(`file`,new Blob([t.file],{type:`application/zip`}),`logs.zip`),n.append(`data`,JSON.stringify(t.data)),R.post(`/v1/public/applications/${e}/feedbacks`,n)}function at(e,t){return R.get(`/v1/public/applications/${e}/feature-flags`,{params:t})}function ot(e,t){return R.get(`/v1/public/applications/${e}/notices`,{params:t})}const st=Qe();function V(e,t){return R.get(`/v1/public/modules/${e}/release`,{params:{cortex_user_id:t}})}function ct(e,t,n){return R.post(`/v1/public/modules/${e}/releases/${t}/download`,n)}async function lt(e,t){if(e.method!==`GET`)throw Error(`Unsupported presigned request method: ${e.method}`);let n=await fetch(e.url,{method:e.method,headers:e.headers,signal:t?.signal});if(!n.ok){let e=await H(n);throw Error(`Presigned download failed (${n.status} ${n.statusText})${e?`: ${e}`:``}`)}let r=await n.arrayBuffer();return new Uint8Array(r)}async function ut(e,t){if(e.method!==`PUT`)throw Error(`Unsupported presigned request method: ${e.method}`);let n=await fetch(e.url,{method:e.method,headers:{...e.headers,"Content-Length":t.byteLength.toString()},body:t});if(!n.ok){let e=await H(n);throw Error(`Presigned upload failed (${n.status} ${n.statusText})${e?`: ${e}`:``}`)}}async function H(e){try{let t=(await e.text()).trim();if(t.length===0)return;let n=2048;return t.length>n?`${t.slice(0,n)}…`:t}catch{return}}function dt(){return R.get(`/v1/public/raven/config`)}const ft=Qe();function pt(e,t){return R.get(`/v1/public/raven/games/${e}/builds/${t}`)}function mt(e,t){return R.post(`/v1/public/raven/games/${e}/builds/upload`,null,{params:t})}function ht(e,t){let n=new FormData;return n.append(`file`,t.chunk),R.patch(`/v1/public/raven/games/${e}/builds/upload`,n,{params:t})}function gt(e){let t=Date.now(),n=e.messages.filter(e=>t-e.created_at.getTime()<6e5),r=e.messages.length-n.length;r>0&&console.warn(`Dropped ${r} cortex event(s) older than 600s`);let i=Ze(n.map(e=>_t(t,e)),50),a=Promise.all(i.map(async t=>R.post(`/v1/public/cortex/events`,{...e,messages:t})));return a.catch(e=>{let t=e?.response?.data||e?.message||e;console.error(`Failed to submit cortex events`,t)}),a}function _t(e,t){let n=e-t.created_at.getTime(),r=Math.max(0,Math.floor(n/1e3));return{properties:t.properties,type:t.type,seconds_offset:r}}function vt(e){return e instanceof Error&&(e.name===`XiorError`||e.name===`XiorTimeoutError`)}function yt(e){return!!(e&&`kind`in e.data&&`message`in e.data)}const{PipeEventServer:bt,PipeEventClient:xt,PipeEventBase:St,ProcessMonitor:Ct,Process:wt,HardwareInterface:Tt}=e(import.meta.url)(`@overlayed/app/dist/native-interface/build/overlayed_native_interface_x64.node`);function Et(e=[]){return h.normalize(h.join(Se(global.OVERLAYED.APPLICATION_ID),...e))}const Dt=n({game:`string`,type:`string`,creation_time:`number`}),U=new k({path:we(),schema:n({userId:`string | undefined`,sessionId:`string | undefined`,sessionLastUsed:`number | undefined`,accessToken:`string | undefined`,"debug?":{"ri_disabled?":`boolean`,"gm_disabled?":`boolean`}}),default:{userId:void 0,sessionId:void 0,sessionLastUsed:void 0,accessToken:void 0}});function Ot(){let{debug:e}=U.get();return e?{ri_disabled:e.ri_disabled??!1,gm_disabled:e.gm_disabled??!1}:{ri_disabled:!1,gm_disabled:!1}}function kt(){let e=U.get().userId;if(e)return e;let t=jt();return U.set({...U.get(),userId:t}),t}function At(){let e=U.get();if(e.sessionId&&typeof e.sessionLastUsed==`number`&&Date.now()-e.sessionLastUsed<=300*1e3)return e.sessionId;let t=crypto.randomUUID();return U.set({...e,sessionId:t,sessionLastUsed:Date.now()}),t}function W(){try{let e=U.get();U.set({...e,sessionLastUsed:Date.now()})}catch(e){M.getInstance().log(`Failed to update sessionLastUsed`,e)}}function G(){return U.get().accessToken}function K(e){try{let t=U.get();U.set({...t,accessToken:e??void 0})}catch(e){M.getInstance().log(`Failed to set accessToken`,e)}}function jt(){try{return Tt.generateUniqueIdentifier()}catch{return crypto.randomUUID()}}const Mt=D(class extends L{UPDATE_CHECK_INTERVAL_MS=1e3*60*5;targetDir;updateInterval;constructor(){super(`NativeModuleManager`),this.targetDir=h.join(j(),`resources`),this.logger.log(`Target directory`,this.targetDir)}async initWithDlls(e){super.init(),await C.mkdir(this.targetDir,{recursive:!0}),await this.checkForUpdates(e),clearInterval(this.updateInterval),this.updateInterval=setInterval(()=>this.checkForUpdates(e),this.UPDATE_CHECK_INTERVAL_MS)}destroy(){this.updateInterval&&=(clearInterval(this.updateInterval),void 0),super.destroy()}async getDllFile(e){let t=await this.getCurrentBuildInfo(e);if(!t){this.logger.error(`No build found for module`,{moduleId:e});return}let n=this.getBuildPath(e,t.buildId);if(!te(n)){this.logger.error(`No build file found for module`,{moduleId:e});return}let r=h.join(n,t.buildFileName);if(!te(r)){this.logger.error(`No DLL file found for module`,{moduleId:e});return}return r}async getCurrentBuildInfo(e){try{let t=h.join(this.targetDir,e,`build.json`),n=await C.readFile(t,`utf-8`);return JSON.parse(n)}catch{return null}}getModulePath(e){return h.join(this.targetDir,e)}getBuildPath(e,t){return h.join(this.getModulePath(e),t)}async checkForUpdates(e){this.logger.log(`Checking for updates`);let t=kt();if(!t){this.logger.error(`Failed to resolve cortex user id`);return}this.logger.log(`Cortex User ID`,t);for(let n of e)try{let{data:e}=await V(n,t);this.logger.log(`Release`,e);let r=(await this.getCurrentBuildInfo(n))?.buildId||null;this.logger.log(`${n} > Performing update check. current: ${r}, requested: ${e.build_id}`),e.build_id!==r||await this.isDownloadCorrupted(this.getBuildPath(n,e.build_id),e)?(this.logger.log(`${n} > Update found. current: ${r}, requested: ${e.build_id}`),this.logger.log(`${n} > Downloading and extracting DLLs`),await this.downloadAndExtractDll(n,e),this.logger.log(`${n} > Cleaning up other builds`),await this.cleanupExistingBuilds(n,e.build_id),this.emit(`dllUpdated`,{moduleId:n,buildId:e.build_id,releaseId:e.release_id})):this.logger.log(`${n} > No update found`)}catch(e){this.logger.error(`${n} > Error checking/updating`,e)}}async downloadAndExtractDll(e,t){this.logger.log(`${e} > Requesting download for build ${t.build_id}`);let n=kt();if(!n){this.logger.error(`Failed to resolve cortex user id`);return}let{data:r}=await ct(e,t.release_id,{download_token:t.download_token,cortex_user_id:n});this.logger.log(`${e} > Downloading DLLs for build ${t.build_id}`);let i=await lt(r,{signal:AbortSignal.timeout(1e3*60*5)});this.logger.log(`${e} > Downloaded zip file for build ${t.build_id}`);let a=this.getBuildPath(e,t.build_id);await C.mkdir(a,{recursive:!0});let o=new ce;await o.loadAsync(i);let s=Object.keys(o.files).map(e=>({name:e,file:o.files[e]})).filter(({file:e})=>!e.dir);if(s.length!==1){this.logger.error(`${e} > Zip must contain exactly 1 file, got ${s.length}`);return}let c=s[0],l=h.basename(c.name),u=h.normalize(l),d=h.isAbsolute(u),f=u.startsWith(`..`)||u.includes(`..${h.sep}`);if(l===``||l===`.`||l===`..`){this.logger.error(`${e} > Zip contained an invalid file name: ${c.name}`);return}if(!l.toLowerCase().endsWith(`.dll`)){this.logger.error(`${e} > Zip contained a non-dll file: ${c.name}`);return}if(d||f){this.logger.error(`${e} > Zip entry path is unsafe: ${c.name}`);return}let p=h.join(a,u),m=await c.file.async(`nodebuffer`);await C.writeFile(p,m),this.logger.log(`${e} > Extracted 1 file to ${p}`);let g={buildId:t.build_id,buildFileName:t.build_file_name},_=h.join(this.getModulePath(e),`build.json`);await C.writeFile(_,JSON.stringify(g),`utf-8`),this.logger.log(`${e} > Saved buildId to file: ${t.build_id}`)}async cleanupExistingBuilds(e,t){let n=this.getModulePath(e),r=this.getBuildPath(e,t),i=await C.readdir(n,{withFileTypes:!0});for(let t of i)t.isDirectory()&&h.join(n,t.name)!==r&&(await C.rm(h.join(n,t.name),{recursive:!0,force:!0}),this.logger.log(`${e} > Cleaned up build: ${t.name}`))}async hasPathAccess(e){try{return await C.access(e,C.constants.F_OK),!0}catch{return!1}}async isDownloadCorrupted(e,t){if(!await this.hasPathAccess(e))return this.logger.error(`Download is corrupted. Path does not exist: ${e}`),!0;let n=t.build_file_name,r=h.join(e,n);if(!te(r))return this.logger.error(`Download is corrupted. Build file not found: ${r}`),!0;if(t.build_hash){let e=await C.readFile(r),i=oe(`sha256`).update(e).digest(`hex`);if(i.toLowerCase()!==t.build_hash.toLowerCase())return this.logger.error(`Download is corrupted. Build file hash mismatch: ${n} ${i.toLowerCase()} !== ${t.build_hash.toLowerCase()}`),!0}return!1}}),Nt=D(class extends L{REFETCH_INTERVAL=1e3*60*5;FAILED_REFETCH_INTERVAL=1e3*30;_ravenConfig;_executableToGameMap=new Map;_executablesArray=[];_refetchIntervalHandler=null;_failedRefetchTimeoutHandler=null;constructor(){super(`RavenManager`)}init(){super.init(),this.fetchRavenConfig(),this._refetchIntervalHandler=setInterval(()=>{this._failedRefetchTimeoutHandler&&=(clearTimeout(this._failedRefetchTimeoutHandler),null),this.fetchRavenConfig()},this.REFETCH_INTERVAL)}getExecutableData(e){return this._executableToGameMap.get(e.toLowerCase())??null}get executables(){return this._executablesArray}get executablesMap(){return this._executableToGameMap}destroy(){this._refetchIntervalHandler&&clearInterval(this._refetchIntervalHandler),this._failedRefetchTimeoutHandler&&clearTimeout(this._failedRefetchTimeoutHandler),Mt.getInstance().destroy(),super.destroy()}async fetchRavenConfig(){try{let e={games:(await dt()).data.games};this._ravenConfig=e,this.resetState();let t=new Set;for(let e of this._ravenConfig.games){for(let t of e.executables){let n=t.toLowerCase();this._executableToGameMap.set(n,e),this._executablesArray.push(n)}e.modules.forEach(e=>t.add(e))}await Mt.getInstance().initWithDlls(Array.from(t)),this.logger.log(`Raven updated, monitoring ${this._executableToGameMap.size} executables`),this.emit(`executablesUpdated`,{executables:this.executables,map:this._executableToGameMap})}catch(e){this.logger.error(`Failed to fetch Raven config`,e),this._failedRefetchTimeoutHandler=setTimeout(()=>this.fetchRavenConfig(),this.FAILED_REFETCH_INTERVAL)}}resetState(){this._executableToGameMap.clear(),this._executablesArray=[]}}),Pt=D(class extends L{_processMonitor;_processes=new Map;boundOnRavenManagerExecutablesUpdated=this.onRavenManagerExecutablesUpdated.bind(this);constructor(){super(`ProcessManager`),this._processMonitor=new Ct}get hasAnyActiveProcesses(){return this.activeProcesses.length>0}get activeProcesses(){return Array.from(this._processes.values()).flat().filter(e=>!e.destroyedAt)}init(){super.init(),Nt.getInstance().on(`executablesUpdated`,this.boundOnRavenManagerExecutablesUpdated),this._processMonitor.on(`create`,e=>{this.logger.log(`Process created`,e),this.addProcess(e),this.logger.log(`Active Process Count: ${this._processes.size}`),this.emit(`create`,{process:e})}),this._processMonitor.on(`destroy`,e=>{this.logger.log(`Process destroyed`,e),this.deleteProcess(e),this.logger.log(`Active Process Count: ${this._processes.size}`),this.emit(`destroy`,{process:e})})}destroy(){Nt.getInstance().off(`executablesUpdated`,this.boundOnRavenManagerExecutablesUpdated),this._processes.clear(),this._processMonitor.removeAllListeners(),super.destroy()}isProcessRunning(e){return this._processes.get(e)?.some(e=>!e.destroyedAt)??!1}onRavenManagerExecutablesUpdated(e){this.logger.log(`Monitoring ${e.executables.length} processes`),e.executables.forEach(e=>{this._processMonitor.isProcessRegistered(e)||this._processMonitor.registerProcess(e)})}addProcess(e){if(!e.name)return;let t=this._processes.get(e.name);if(!t){this._processes.set(e.name,[e]);return}this._processes.set(e.name,t.concat(e))}deleteProcess(e){if(!e.name)return;let t=this._processes.get(e.name)?.filter(t=>t.id!==e.id)??[];t.length===0?this._processes.delete(e.name):this._processes.set(e.name,t)}});var Ft=class{_instance;_resolution;boundOnResolutionChanged=this.onResolutionChanged.bind(this);constructor(e){this._instance=e,this._resolution={width:0,height:0},this._instance.on(`resolution`,this.boundOnResolutionChanged)}destroy(){this._instance.off(`resolution`,this.boundOnResolutionChanged)}get instance(){return this._instance}get resolution(){return this._resolution}onResolutionChanged(e,t){this._resolution={width:e,height:t}}};const It=D(class{interfaces={};constructor(){}createInterface(e){return this.interfaces[e]||(this.interfaces[e]=new Ft(new Le(e,{access:1}))),this.interfaces[e]}getInterface(e){return this.interfaces[e]?this.interfaces[e]:this.createInterface(e)}}),q=D(class{options;eventQueue;meta=null;enabled=!0;constructor(e){this.options=this.resolveOptions(e),this.eventQueue=new he,this.setupFlushInterval()}track(e,t){this.enabled&&this.eventQueue.add({type:e,properties:t,created_at:new Date})}flush(){if(!this.enabled)return[];let e=Array.from(this.eventQueue.flush()).concat({type:`ping`,properties:{},created_at:new Date});if(!this.meta)throw Error(`Tried to flush Cortex events before meta was set`);try{gt({...this.meta,messages:e})}catch{}return e}setupFlushInterval(){this.enabled&&setInterval(()=>{this.flush()},this.options.batchIntervalSeconds*1e3)}resolveOptions(e){return{batchIntervalSeconds:e?.batchIntervalSeconds??15}}}),Lt=e(import.meta.url),J=Lt.resolve(`@overlayed/app/dist/render-interface/build/overlayed_render_hook_x64.dll`),Rt=Lt.resolve(`@overlayed/app/dist/render-interface/build/overlayed_render_hook_x86.dll`),zt=Lt.resolve(`@overlayed/app/dist/native-interface/build/overlayed_injector_x64.exe`),Bt=Lt.resolve(`@overlayed/app/dist/native-interface/build/overlayed_injector_x86.exe`),Y=D(class extends Ge{boundOnProcessCreate=this.onProcessCreate.bind(this);boundOnProcessDestroy=this.onProcessDestroy.bind(this);subscribedGames=new Set;_activeReadyRavenGames={};get isInGame(){return Object.keys(this._activeReadyRavenGames).length>0}constructor(){super(`GameLaunchManager`)}setSubscribedGames(e){this.subscribedGames=new Set(e)}getActiveGames(){return Object.keys(this._activeReadyRavenGames)}init(){super.init(),It.getInstance().createInterface(`OGG_SIEGE`),Pt.getInstance().on(`create`,this.boundOnProcessCreate),Pt.getInstance().on(`destroy`,this.boundOnProcessDestroy)}destroy(){Pt.getInstance().off(`create`,this.boundOnProcessCreate),Pt.getInstance().off(`destroy`,this.boundOnProcessDestroy),super.destroy()}on(e,t){super.on(e,t);let n=pe(e);if(!(n.includes(`gameReady`)||n.includes(`*`))||Object.keys(this._activeReadyRavenGames).length===0)return;let r=t;for(let e of Object.values(this._activeReadyRavenGames))this.logger.log(`Late calling gameReady callback for game`,e.game),r(e)}async onProcessCreate({process:e}){this.logger.log(`On process create`,e);let t=this.getRavenGame(e);if(!t)return;if(this.logger.log(`Raven game found`,t),t.command_line_regex){this.logger.log(`Performing command line regex check`,{regex:t.command_line_regex});try{let n=e.commandLine;this.logger.log(`Process command line`,n);let r=new RegExp(t.command_line_regex);if(!e.commandLine||!r.test(e.commandLine)){this.logger.log(`Process command line does not match regex, skipping`,{commandLine:e.commandLine,regex:t.command_line_regex});return}}catch(e){this.logger.error(`Failed to check command line`,e);return}}if(q.getInstance().track(`game_launch`,{game:t.identifier}),this.subscribedGames.size===0){this.logger.warn(`No subscribed games, skipping`);return}if(!this.subscribedGames.has(t.identifier)&&!this.subscribedGames.has(`*`))return;let n=new AbortController;if(await this.emit(`gameLaunch`,{game:t.identifier,reject:()=>n.abort()}),n.signal.aborted)return;let r=wt.currentProcess;if(this.logger.log(`Game Launched`,t),this.logger.log(`Process is elevated: `,e.isElevated),this.logger.log(`Current process is elevated: `,r.isElevated),e.isElevated&&!r.isElevated){O.getInstance().fatal(`Game is elevated but the App is not`,`ELEVATION_MISMATCH`,{appElevated:!!r.isElevated,gameElevated:!!e.isElevated}),this.logger.log(`Game elevated but App is not`,{appElevated:r.isElevated,gameElevated:e.isElevated});return}let i=e.createdAt||new Date,a=Math.floor((new Date().getTime()-i.getTime())/1e3);this.logger.log(`Process created ${a}s ago`),a<30&&(this.logger.log(`Delaying injection for 45 seconds to allow game to be ready`),await new Promise(e=>setTimeout(e,1e3*45)));let{ri_disabled:o,gm_disabled:s}=Ot(),c=!1;!o&&t.has_render_support&&t.allow_dll_injections?c=await this.injectRenderInterface(e):this.logger.log(`Skipping render interface injection`,{has_render_support:t.has_render_support,allow_dll_injections:t.allow_dll_injections,ri_disabled:o}),!s&&t.allow_dll_injections?await this.injectGameModules(t,e):this.logger.log(`Skipping game module(s) injection`,{allow_dll_injections:t.allow_dll_injections,gm_disabled:s});let l={game:t.identifier,inGameRenderingSupported:c};this._activeReadyRavenGames[t.identifier]=l,this.logger.debug(`Active ready raven games`,Object.keys(this._activeReadyRavenGames).join(`, `)),this.logger.log(`Game Ready`),this.emit(`gameReadyInternal`,{ravenGame:t,process:e}),this.emit(`gameReady`,l),q.getInstance().track(`game_ready`,{game:t.identifier})}copyInjectors(){let e=this.copyDll(zt),t=this.copyDll(Bt);return!e||!t?(this.logger.error(`Failed to copy injector executables`),!1):h.dirname(e)}copyDll(e){let t=h.basename(e),n=_(e),r=h.join(j(),`resources`),i=h.join(r,t);this.logger.info(`Copying`,n,`to`,i);try{te(r)||ne(r,{recursive:!0}),S(i,re(n)),b(n,i)}catch(e){return e.code===`EBUSY`?i:(this.logger.error(`Failed to copy`,e),this.logger.error(`Failed to copy`,{originalPath:n,targetPath:i}),!1)}return i}async injectRenderInterface(e){this.logger.log(`Injecting render interface`,{is32Bit:e.is32Bit,process:e});let t=e.is32Bit?Rt:J;this.logger.log(`Render hook path`,t);let n=this.copyDll(t);if(!n)return this.logger.error(`Failed to copy render hook DLL`,{renderHookPath:t}),!1;let r=this.copyInjectors();if(!r)return!1;this.logger.log(`Resolved injector path`,r);try{return this.logger.log(`Injecting render interface`,n),await e.injectDll(n,r),this.logger.log(`Render Interface Injection Successful`,n),!0}catch(e){return this.logger.error(`Render Interface Injection Failed`,e),this.logger.error(`Render Interface Injection Failed`,{renderHookPathCopied:n}),!1}}async injectGameModules(e,t){let n=this.copyInjectors();if(n){this.logger.log(`Resolved injector path`,n);for(let r of e.modules){let e=await Mt.getInstance().getDllFile(r);if(!e){this.logger.error(`No DLL file found for module`,{moduleId:r});continue}try{this.logger.log(`Injecting game module`,e),await t.injectDll(e,n),this.logger.log(`Injection Successful`,e)}catch(t){this.logger.error(`Injection Failed`,{dllFile:e},t)}}}}onProcessDestroy({process:e}){let t=this.getRavenGame(e);t&&(delete this._activeReadyRavenGames[t.identifier],this.logger.debug(`Active ready raven games`,Object.keys(this._activeReadyRavenGames).join(`, `)),this.emit(`gameCloseInternal`,{ravenGame:t,process:e}),this.emit(`gameClose`,{game:t.identifier}),q.getInstance().track(`game_close`,{game:t.identifier}))}getRavenGame(e){if(!e.name)return;let t=Nt.getInstance().getExecutableData(e.name);if(!t){this.logger.error(`No raven game found for process`,{process:e});return}return t}}),Vt=D(class extends We{boundOnGameLaunch=this.onGameLaunch.bind(this);constructor(){super(`GameBuildManager`)}init(){super.init(),Y.getInstance().on(`gameReadyInternal`,this.boundOnGameLaunch)}destroy(){Y.getInstance().off(`gameReadyInternal`,this.boundOnGameLaunch),super.destroy()}async onGameLaunch(...e){let[{ravenGame:t,process:n}]=e;if(!n.path||!n.name){this.logger.error(`Process path or name not found, could not check for build hash`,void 0,n);return}let r=re(n.path),i=oe(`sha256`).update(r).digest(`hex`);this.logger.log(`Process Path`,n.path),this.logger.log(`Process Name`,n.name),this.logger.log(`Build Hash`,i);let a=!1;try{a=(await pt(t.identifier,i)).data.upload}catch(e){this.logger.error(`Error checking game build hash`,e);return}if(!a){this.logger.log(`Build hash already exists, skipping upload`);return}let o=new ce;o.file(n.name,r);let s=await o.generateAsync({type:`blob`});try{this.logger.log(`Uploading build (size: `,s.size,` bytes)`);let e=new N(s,{chunkSizeMb:25,maxConcurrent:1}),n=await mt(t.identifier,{build_hash:i,chunk_count:e.totalChunks,file_size_bytes:s.size});await e.chunk(async(e,r)=>{this.logger.log(`Uploading chunk`,r),await ht(t.identifier,{chunk:e,build_hash:i,chunk_index:r,upload_token:n.data.upload_token})}),this.logger.log(`Build uploaded successfully`)}catch(e){vt(e)?yt(e.response)?this.logger.error(`Error uploading build hash, api error`,e):this.logger.error(`Error uploading build hash, request error`,e):this.logger.error(`Error uploading build hash, unknown error`,e)}}}),Ht=D(class extends We{constructor(){super(`CampaignManager`)}async check(e){let t=h.join(Se(e),`campaign_code.txt`);try{let e=(await w.readFile(t,`utf-8`)).trim().replace(/ \(\d+\)/g,``);e&&(this.logger.log(`UTM campaign code found`,e),q.getInstance().track(`utm_attribution`,{campaign_code:e}),q.getInstance().flush())}catch{}}}),Ut=new k({path:f.normalize(`${process.env.APPDATA||process.env.HOME||`.`}/.overlayed/config.json`),default:void 0,schema:t({Account:n({email:`string`,apiKey:`string`,"applicationId?":`string`,"baseUrl?":`string`})}).type({currentAccount:`Account | undefined`,accounts:`Account[]`}).or(`undefined`)});function Wt(e,t){let n=t.applicationId===void 0||e.applicationId===void 0||e.applicationId===t.applicationId,r=(e.baseUrl??`https://api.overlayed.gg`)===t.baseUrl;return n&&r}function Gt(e){let{currentAccount:t,accounts:n,expected:r}=e;if(t&&Wt(t,r))return{account:t,source:`current`};let i=n.find(e=>Wt(e,r));if(i)return{account:i,source:`other`}}function Kt(e,t){return`${e}:${t}`}function qt(e,t,n){return e.reduce((e,r)=>{let i=r.key;return e[i]={on(e,n){let r=Kt(i,e),a=t.get(r)??new Set;a.add(n),t.set(r,a)},onAny(e){let n=Kt(i,`*`),r=t.get(n)??new Set;r.add(e),t.set(n,r)},off(e,n){let r=Kt(i,e),a=t.get(r);a&&(a.delete(n),a.size===0&&t.delete(r))},offAny(e){let n=Kt(i,`*`),r=t.get(n);r&&(r.delete(e),r.size===0&&t.delete(n))},readyForGameEvents:()=>{n.emit(`flushEvents`,i)}},e},{})}function Jt(){let e=O.getInstance(),t=Y.getInstance();return{on:(n,r)=>{switch(n){case`fatal`:e.on(`fatal`,r);break;case`error`:e.on(`error`,r);break;case`warning`:e.on(`warning`,r);break;case`gameLaunch`:t.on(`gameLaunch`,r);break;case`gameClose`:t.on(`gameClose`,r);break;case`gameReady`:t.on(`gameReady`,r);break;default:throw Error(`Event type not implemented ${n}`,{cause:[n,r]})}},off:(n,r)=>{switch(n){case`fatal`:e.off(`fatal`,r);break;case`error`:e.off(`error`,r);break;case`warning`:e.off(`warning`,r);break;case`gameLaunch`:t.off(`gameLaunch`,r);break;case`gameClose`:t.off(`gameClose`,r);break;case`gameReady`:t.off(`gameReady`,r);break;default:throw Error(`Event type not implemented ${n}`,{cause:[n,r]})}}}}const Yt=new Map([[1,`LeftButton`],[2,`RightButton`],[3,`Cancel`],[4,`MiddleButton`],[5,`ExtraButton1`],[6,`ExtraButton2`],[8,`Backspace`],[9,`Tab`],[12,`Clear`],[13,`Enter`],[16,`ShiftLeft`],[17,`ControlLeft`],[18,`AltLeft`],[19,`Pause`],[20,`CapsLock`],[21,`KanaMode`],[23,`JunjaMode`],[24,`Finalize`],[25,`HanjaMode`],[27,`Escape`],[28,`Convert`],[29,`NonConvert`],[30,`Accept`],[31,`ModeChange`],[32,`Space`],[33,`PageUp`],[34,`PageDown`],[35,`End`],[36,`Home`],[37,`ArrowLeft`],[38,`ArrowUp`],[39,`ArrowRight`],[40,`ArrowDown`],[41,`Select`],[42,`PrintScreen`],[43,`Execute`],[44,`Snapshot`],[45,`Insert`],[46,`Delete`],[47,`Help`],[48,`Digit0`],[49,`Digit1`],[50,`Digit2`],[51,`Digit3`],[52,`Digit4`],[53,`Digit5`],[54,`Digit6`],[55,`Digit7`],[56,`Digit8`],[57,`Digit9`],[65,`KeyA`],[66,`KeyB`],[67,`KeyC`],[68,`KeyD`],[69,`KeyE`],[70,`KeyF`],[71,`KeyG`],[72,`KeyH`],[73,`KeyI`],[74,`KeyJ`],[75,`KeyK`],[76,`KeyL`],[77,`KeyM`],[78,`KeyN`],[79,`KeyO`],[80,`KeyP`],[81,`KeyQ`],[82,`KeyR`],[83,`KeyS`],[84,`KeyT`],[85,`KeyU`],[86,`KeyV`],[87,`KeyW`],[88,`KeyX`],[89,`KeyY`],[90,`KeyZ`],[91,`MetaLeft`],[92,`MetaRight`],[93,`ContextMenu`],[95,`Sleep`],[96,`Numpad0`],[97,`Numpad1`],[98,`Numpad2`],[99,`Numpad3`],[100,`Numpad4`],[101,`Numpad5`],[102,`Numpad6`],[103,`Numpad7`],[104,`Numpad8`],[105,`Numpad9`],[106,`NumpadMultiply`],[107,`NumpadAdd`],[108,`NumpadSeparator`],[109,`NumpadSubtract`],[110,`NumpadDecimal`],[111,`NumpadDivide`],[112,`F1`],[113,`F2`],[114,`F3`],[115,`F4`],[116,`F5`],[117,`F6`],[118,`F7`],[119,`F8`],[120,`F9`],[121,`F10`],[122,`F11`],[123,`F12`],[124,`F13`],[125,`F14`],[126,`F15`],[127,`F16`],[128,`F17`],[129,`F18`],[130,`F19`],[131,`F20`],[132,`F21`],[133,`F22`],[134,`F23`],[135,`F24`],[144,`NumLock`],[145,`ScrollLock`],[146,`NEC_Equal`],[147,`Fujitsu_Masshou`],[148,`Fujitsu_Touroku`],[149,`Fujitsu_Loya`],[150,`Fujitsu_Roya`],[160,`ShiftLeft`],[161,`ShiftRight`],[162,`ControlLeft`],[163,`ControlRight`],[164,`AltLeft`],[165,`AltRight`],[166,`BrowserBack`],[167,`BrowserForward`],[168,`BrowserRefresh`],[169,`BrowserStop`],[170,`BrowserSearch`],[171,`BrowserFavorites`],[172,`BrowserHome`],[173,`VolumeMute`],[174,`VolumeDown`],[175,`VolumeUp`],[176,`MediaTrackNext`],[177,`MediaTrackPrevious`],[178,`MediaStop`],[179,`MediaPlayPause`],[180,`LaunchMail`],[181,`LaunchMediaSelect`],[182,`LaunchApplication1`],[183,`LaunchApplication2`],[186,`OEM_1`],[187,`Equal`],[188,`Comma`],[189,`Minus`],[190,`Period`],[191,`Slash`],[192,`Backquote`],[219,`BracketLeft`],[220,`Backslash`],[221,`BracketRight`],[222,`Quote`],[223,`IntlRo`],[225,`OEM_AX`],[226,`IntlBackslash`],[227,`ICO_HELP`],[228,`ICO_00`],[229,`Process`],[230,`ICO_CLEAR`],[231,`Packet`],[233,`OEM_Reset`],[234,`OEM_Jump`],[235,`OEM_PA1`],[236,`OEM_PA2`],[237,`OEM_PA3`],[238,`OEM_WS_Ctrl`],[239,`OEM_CU_Sel`],[240,`OEM_ATTN`],[241,`OEM_Finish`],[242,`OEM_Copy`],[243,`OEM_Auto`],[244,`OEM_ENLW`],[245,`BackTab`],[246,`ATTN`],[247,`CRSel`],[248,`EXSel`],[249,`EREOF`],[250,`MediaPlay`],[251,`Zoom`],[252,`Noname`],[253,`PA1`],[254,`OEM_Clear`]]),Xt=new Map(Yt.entries().map(([e,t])=>[t,e])),Zt=n({"[string]":{keys:`string[]`,mode:n(`'toggle' | 'hold'`).pipe(e=>e??`toggle`)}});var Qt=class extends L{preferencesKeybindToCallbacks=new Map;pressedKeys=new Set;activeKeybinds=new Set;triggeredToggleKeybinds=new Set;boundHandleKeyboardFocus=this.handleKeyboardFocus.bind(this);boundHandleKeyDown=this.handleKeyDown.bind(this);boundHandleKeyUp=this.handleKeyUp.bind(this);keybindsFile;keybindListeningPaused=!1;constructor(e){super(`KeybindManager`),this.keybindsFile=new k({path:Et([`keybinds.json`]),schema:Zt,default:e})}init(){super.init();let e=It.getInstance().getInterface(`OGG_SIEGE`);e.instance.on(`keyboardFocus`,this.boundHandleKeyboardFocus),e.instance.on(`keyDown`,this.boundHandleKeyDown),e.instance.on(`keyUp`,this.boundHandleKeyUp)}async onKeybindToggled(e,t){let n=this.preferencesKeybindToCallbacks.get(e)??{toggle:[],down:[],up:[]};n.toggle.push(t),this.preferencesKeybindToCallbacks.set(e,n)}async onKeybindDown(e,t){let n=this.preferencesKeybindToCallbacks.get(e)??{toggle:[],down:[],up:[]};n.down.push(t),this.preferencesKeybindToCallbacks.set(e,n)}async onKeybindUp(e,t){let n=this.preferencesKeybindToCallbacks.get(e)??{toggle:[],down:[],up:[]};n.up.push(t),this.preferencesKeybindToCallbacks.set(e,n)}async updateKeybind(e,t){this.keybindsFile.set({[e]:t})}async updateKeybinds(e){let t=Object.fromEntries(Object.entries(e).filter(([e,t])=>t!==void 0));this.keybindsFile.set({...this.keybindsFile.get(),...t})}getConfig(){return this.keybindsFile.get()}destroy(){let e=It.getInstance().getInterface(`OGG_SIEGE`);e.instance.off(`keyboardFocus`,this.boundHandleKeyboardFocus),e.instance.off(`keyDown`,this.boundHandleKeyDown),e.instance.off(`keyUp`,this.boundHandleKeyUp),super.destroy()}handleKeyDown(e){if(this.keybindListeningPaused)return;let t=Yt.get(e.key);if(!t){this.logger.error(`Unknown key down`,e);return}this.pressedKeys.add(t),this.checkKeybindings()}handleKeyboardFocus(){this.pressedKeys.clear(),this.activeKeybinds.clear(),this.triggeredToggleKeybinds.clear()}async handleKeyUp(e){if(this.keybindListeningPaused)return;let t=Yt.get(e.key);if(!t)return;this.pressedKeys.delete(t);let n=this.keybindsFile.get();for(let[e]of this.preferencesKeybindToCallbacks.entries())n[e].keys.includes(t)&&this.triggeredToggleKeybinds.delete(e);this.checkKeybindUps()}async checkKeybindUps(){let e=this.keybindsFile.get();for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){if(!n.up||n.up.length===0)continue;let r=e[t];if(this.activeKeybinds.has(t)&&r.keys.some(e=>!this.pressedKeys.has(e))){this.activeKeybinds.delete(t);for(let e of n.up)e();this.logger.log(`Keybind up triggered`,this.getKeybindToString(r))}}}async checkKeybindings(){let e=this.keybindsFile.get();for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){let r=e[t];if(r.keys.length===this.pressedKeys.size&&r.keys.every(e=>Xt.has(e)?this.pressedKeys.has(e):!1)){this.triggerKeybind(r,n,t);return}}for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){let r=e[t];r.keys.every(e=>Xt.has(e)?this.pressedKeys.has(e):(this.logger.error(`Unknown key`,e,r),!1))&&this.triggerKeybind(r,n,t)}}triggerKeybind(e,t,n){let r=e.mode;if(r===`toggle`&&t.toggle&&t.toggle.length>0&&!this.triggeredToggleKeybinds.has(n)){let r;for(let e of t.toggle){let t=e();typeof t==`string`&&r===void 0&&(r=t)}this.triggeredToggleKeybinds.add(n),this.logger.log(r?`Keybind pressed rejected: ${r}`:`Keybind pressed accepted`,this.getKeybindToString(e))}if(r===`hold`&&t.down&&t.down.length>0&&!this.activeKeybinds.has(n)){let r;for(let e of t.down){let t=e();if(typeof t==`string`){r=t;break}}r?this.logger.log(`Keybind down rejected: ${r}`,this.getKeybindToString(e)):(this.activeKeybinds.add(n),this.logger.log(`Keybind down accepted`,this.getKeybindToString(e)))}}getKeybindToString(e){return`(${e.keys.join(`+`)}${e.mode?` ${e.mode}`:``})`}};function $t(e){let t=new Qt(e),n={};for(let r in e)n[r]={on:(e,n)=>{switch(e){case`down`:t.onKeybindDown(r,n);break;case`up`:t.onKeybindUp(r,n);break;case`toggle`:t.onKeybindToggled(r,n);break;default:throw Error(`Event type not implemented ${e}`,{cause:[e,n]})}}};let r={...n,getConfig:()=>t.getConfig(),pauseKeybindListening:()=>{t.keybindListeningPaused=!0},resumeKeybindListening:()=>{t.keybindListeningPaused=!1},updateKeybind:(e,n)=>{t.updateKeybind(e,n)},updateKeybinds:e=>{t.updateKeybinds(e)}};return t.init(),T.on(`quit`,()=>{t.destroy()}),r}function X(){return It.getInstance().getInterface(`OGG_SIEGE`)}function en(){let e=Y.getInstance(),t=O.getInstance(),n=q.getInstance();if(!T.isPackaged){M.getInstance().info(`Cortex is disabled in development`),n.enabled=!1;return}try{n.meta=tn()}catch(e){M.getInstance().error(`Failed to setup cortex`,e);return}e.on([`gameReady`,`gameClose`],()=>{n.meta||=tn(),n.meta.in_game=e.isInGame}),t.on(`fatal`,e=>{n.track(`fatal`,{message:e.message,code:e.code,data:JSON.stringify(e.data)})}),t.on(`error`,e=>{n.track(`error`,{code:e.code,message:e.message,data:JSON.stringify(e.data)})}),t.on(`warning`,e=>{n.track(`warning`,{message:e.message,code:e.code,data:JSON.stringify(e.data)})})}function tn(){if(!global.OVERLAYED_META.release.id)throw Error(`Release ID is required`);return{app_id:global.OVERLAYED.APPLICATION_ID,user_id:kt(),release_id:global.OVERLAYED_META.release.id,app_channel:global.OVERLAYED.APP_BUILD_CHANNEL,app_version:global.OVERLAYED.APP_VERSION,package_version:global.OVERLAYED.PACKAGE_VERSION,frontend_version:global.OVERLAYED.FRONTEND_VERSION,frontend_release_id:global.OVERLAYED.FRONTEND_RELEASE_ID,session_id:global.OVERLAYED.sessionId,in_game:!1}}const nn=D(class extends L{CHECK_INTERVAL=1e3*60*15;RETRY_INTERVAL=1e3*15;_updateCheckInterval=null;_latestCheckResponse=null;_activeCheckResponse=null;initialReleaseId=null;get manualUpdatesEnabled(){return this.options?.manualUpdates??!1}get activeReleaseId(){return this._activeCheckResponse?.release_id??this.initialReleaseId}constructor(){super(`SiteManager`)}init(e){super.init(e),e?.manualUpdates&&this.enableManualUpdates()}destroy(){super.destroy(),this._updateCheckInterval&&=(clearInterval(this._updateCheckInterval),null)}allowSiteUpdateOnNextLoad(){if(!this.options?.manualUpdates){this.logger.warn(`allowSiteUpdateOnNextLoad called but manual updates are disabled`);return}if(!this._latestCheckResponse){this.logger.warn(`allowSiteUpdateOnNextLoad called but no update has been checked yet`);return}if(this._activeCheckResponse?.release_id===this._latestCheckResponse.release_id){this.logger.warn(`allowSiteUpdateOnNextLoad called but theres no update available`);return}this._activeCheckResponse=this._latestCheckResponse,q.getInstance().track(`site_update_applied`,{version:this._latestCheckResponse.version,release_id:this._latestCheckResponse.release_id}),this.setFrontendCortexMeta(this._latestCheckResponse.release_id,this._latestCheckResponse.version)}setFrontendCortexMeta(e,t){let n=q.getInstance();n.meta||=tn(),e&&(global.OVERLAYED.FRONTEND_RELEASE_ID=e,n.meta.frontend_release_id=e),t&&(global.OVERLAYED.FRONTEND_VERSION=t,n.meta.frontend_version=t),e&&t&&n.track(`frontend_version_changed`,{version:t,release_id:e})}enableManualUpdates(){this.logger.log(`Enabling manual site updates`),this.checkForUpdates(),this._updateCheckInterval=setInterval(()=>{this.checkForUpdates(!0)},this.CHECK_INTERVAL)}async checkForUpdates(e=!1){let t=global.OVERLAYED_META?.application?.siteUrl;if(!t){this.logger.log(`No siteUrl configured, skipping check`);return}q.getInstance().track(`site_check_for_update`,{});try{let n=new URL(`/check`,t).toString();this.logger.log(`Checking site URL`,n);let r={"Overlayed-User-Agent":z({package_version:global.OVERLAYED.PACKAGE_VERSION,application_id:global.OVERLAYED.APPLICATION_ID,application_version:global.OVERLAYED.APP_VERSION}),"Overlayed-Cortex-User-Id":global.OVERLAYED_RUNTIME.userId},i=G();i&&(r[`Overlayed-Access-Token`]=i);let a=global.OVERLAYED_META.release.channelId;a&&(r[`Overlayed-Channel-Id`]=a);let o=await fetch(n,{headers:r});if(!o.ok){this.logger.warn(`Site check failed with status`,o.status),q.getInstance().track(`site_check_error`,{status:o.status}),e&&this.scheduleRetry();return}let s=await o.json();if(this.logger.log(`Site check response`,s),!s.release_id){this.logger.error(`Site check response missing release_id`);return}if(!this._latestCheckResponse){this._latestCheckResponse=s;return}return this._latestCheckResponse.release_id===s.release_id?void 0:(this.logger.log(`New site version detected`,s),this._latestCheckResponse=s,q.getInstance().track(`site_update_ready`,{version:s.version,release_id:s.release_id}),this.emit(`siteUpdateReady`,{releaseId:s.release_id,version:s.version}),s)}catch(e){let t=e instanceof Error?e.message:String(e);q.getInstance().track(`site_check_error`,{message:t}),this.logger.error(`Site check failed`,{error:e,message:t}),this.scheduleRetry()}}scheduleRetry(){setTimeout(()=>{this.checkForUpdates()},this.RETRY_INTERVAL)}}),rn=D(Ee,`browser-windows.log`);let an;function on(){return an||(an=class e extends global.OVERLAYED.electron.BrowserWindow{static session=void 0;constructor(t){let n=e.resolveCustomOptions(t);super(n)}static resolveCustomOptions(t){let n=global.OVERLAYED_META,r=global.OVERLAYED_RUNTIME;return{...t,webPreferences:{...t.webPreferences,session:e.getSession(),additionalArguments:[...t.webPreferences?.additionalArguments||[],...global.OVERLAYED.electron.app.isPackaged?[]:[`--overlayed-meta=${JSON.stringify(n)}`],`--overlayed-runtime=${JSON.stringify(r)}`]}}}static getSession(){if(!global.OVERLAYED_META?.application?.siteUrl)return;if(e.session)return e.session;e.session=global.OVERLAYED.electron.session.fromPartition(`persist:overlayed-${global.OVERLAYED.APPLICATION_ID}`);let t=nn.getInstance(),n=z({package_version:global.OVERLAYED.PACKAGE_VERSION,application_id:global.OVERLAYED.APPLICATION_ID,application_version:global.OVERLAYED.APP_VERSION}),r={urls:[global.OVERLAYED_META.application.siteUrl+`/*`]},i=global.OVERLAYED_RUNTIME.userId;return e.session.webRequest.onBeforeSendHeaders(r,(e,r)=>{let a=G();a&&(e.requestHeaders[`Overlayed-Access-Token`]=a);let o=global.OVERLAYED_META.release.channelId;o&&(e.requestHeaders[`Overlayed-Channel-Id`]=o),t.manualUpdatesEnabled&&t.activeReleaseId&&(e.requestHeaders[`Overlayed-Release-Id`]=t.activeReleaseId),e.requestHeaders[`Overlayed-Cortex-User-Id`]=i,e.requestHeaders[`Overlayed-User-Agent`]=n,r({requestHeaders:e.requestHeaders})}),t.manualUpdatesEnabled&&e.session.webRequest.onHeadersReceived(r,(e,n)=>{if(t.initialReleaseId){n(e);return}let r=e.responseHeaders?.[`Overlayed-Release-Id`]?.[0];r&&(t.initialReleaseId=st(r));let i=e.responseHeaders?.[`Overlayed-Release-Version`]?.[0];t.setFrontendCortexMeta(r,i),n(e)}),e.session}},an)}function sn(){function e(e,t){let n=rn.getInstance();return e.once(`closed`,()=>{e.isDestroyed()||q.getInstance().track(`window_closed`,{url:e.webContents.getURL(),in_game:t})}),e.on(`unresponsive`,()=>{e.isDestroyed()||q.getInstance().track(`window_unresponsive`,{url:e.webContents.getURL(),in_game:t})}),e.webContents.on(`console-message`,(t,r,i,a,o)=>{let s=e.isDestroyed()?`destroyed`:e.webContents.getURL();n[r===3?`error`:r===2?`warn`:`log`](`[${s}] [${o}:${a}] ${i}`)}),q.getInstance().track(`window_created`,{url:e.webContents.getURL(),in_game:t}),e}return{getProductionSiteUrl:()=>{let e=global.OVERLAYED_META.application.siteUrl;return URL.canParse(e)?new URL(e):new URL(`https://default.overlayedapps.com`)},createWindow:t=>e(new(on())(t),!1),createInGameWindow:t=>{let n=on();return e(X().instance.newWindowInternal(n,t),!0)},on:(e,t)=>X().instance.on(e,t),off:(e,t)=>X().instance.off(e,t),once:(e,t)=>X().instance.once(e,t),addListener:(e,t)=>X().instance.addListener(e,t),removeListener:(e,t)=>X().instance.removeListener(e,t),removeAllListeners:()=>X().instance.removeAllListeners(),prependListener:(e,t)=>X().instance.prependListener(e,t),prependOnceListener:(e,t)=>X().instance.prependOnceListener(e,t),getActiveGameInfo:()=>{let e=X(),t=Ie.getInstance();return{resolution:e.resolution,isConnected:t.hasConnection}}}}const cn=D(class extends We{renderInterface;globalCursorOverrideCount=new Set;globalMouseBlockCount=new Set;globalKeyboardBlockCount=new Set;keyInputBlocks={};constructor(e){super(`OverridesManager`),this.renderInterface=It.getInstance().getInterface(e)}scope(e){return{setGlobalCursorOverride:t=>this.setGlobalCursorOverride(e,t),setGlobalMouseBlock:t=>this.setGlobalMouseBlock(e,t),setGlobalKeyboardBlock:t=>this.setGlobalKeyboardBlock(e,t),setKeyInputBlock:(t,n)=>this.setKeyInputBlock(e,t,n)}}setGlobalCursorOverride(e,t){t?this.globalCursorOverrideCount.add(e):this.globalCursorOverrideCount.delete(e),t&&this.globalCursorOverrideCount.size===1?this.renderInterface.instance.setGlobalCursorOverride(!0):!t&&this.globalCursorOverrideCount.size===0&&this.renderInterface.instance.setGlobalCursorOverride(!1)}setGlobalMouseBlock(e,t){t?this.globalMouseBlockCount.add(e):this.globalMouseBlockCount.delete(e),t&&this.globalMouseBlockCount.size===1?this.renderInterface.instance.setGlobalMouseBlock(!0):!t&&this.globalMouseBlockCount.size===0&&this.renderInterface.instance.setGlobalMouseBlock(!1)}setGlobalKeyboardBlock(e,t){t?this.globalKeyboardBlockCount.add(e):this.globalKeyboardBlockCount.delete(e),t&&this.globalKeyboardBlockCount.size===1?this.renderInterface.instance.setGlobalKeyboardBlock(!0):!t&&this.globalKeyboardBlockCount.size===0&&this.renderInterface.instance.setGlobalKeyboardBlock(!1)}setKeyInputBlock(e,t,n){this.keyInputBlocks[t]||(this.keyInputBlocks[t]=new Set),n?this.keyInputBlocks[t].add(e):this.keyInputBlocks[t].delete(e),n&&this.keyInputBlocks[t].size===1?this.renderInterface.instance.setKeyInputBlock(t,!0):!n&&this.keyInputBlocks[t].size===0&&this.renderInterface.instance.setKeyInputBlock(t,!1)}},`OGG_SIEGE`);function ln(){return{scope:e=>cn.getInstance().scope(e),raw:{setGlobalMouseBlock:e=>X().instance.setGlobalMouseBlock(e),setGlobalKeyboardBlock:e=>X().instance.setGlobalKeyboardBlock(e),setGlobalCursorOverride:e=>X().instance.setGlobalCursorOverride(e),setKeyInputBlock:(e,t)=>X().instance.setKeyInputBlock(e,t),getGlobalMouseBlock:()=>X().instance.getGlobalMouseBlock(),getGlobalKeyboardBlock:()=>X().instance.getGlobalKeyboardBlock(),getGlobalCursorOverride:()=>X().instance.getGlobalCursorOverride(),getKeyInputBlock:e=>X().instance.getKeyInputBlock(e)}}}function un(){return{track:(e,t)=>{q.getInstance().track(`custom__${String(e)}`,t)}}}function dn(){return{registerWindow:()=>{}}}const fn=/(\d{4})-(\d{2})-(\d{2})\.log$/;function pn(e){let t=e.match(fn);if(!t)return!1;let[,n,r,i]=t,a=Number(n),o=Number(r),s=Number(i);if(o<1||o>12||s<1||s>31)return!1;let c=new Date(a,o-1,s);if(isNaN(c.getTime())||c.getFullYear()!==a||c.getMonth()!==o-1||c.getDate()!==s)return!1;let l=new Date;return l.setDate(l.getDate()-7),l.setHours(0,0,0,0),c>=l}function mn(e){let{silent:t=!1,additionalFiles:n}=e??{},r=Ce(global.OVERLAYED.APPLICATION_ID),i=P(r,{recursive:!0}),a=xe(),o=P(a,{recursive:!0});t||(M.getInstance().info(`Logs path: `,r),M.getInstance().info(`Overlayed logs path: `,a));let s=new ce;return i.forEach(([e,n])=>{t||M.getInstance().info(`Zipping: `,n);let r=x(n);s.file(g(n),r,{compression:`DEFLATE`})}),o.forEach(([e,n])=>{if(!pn(g(n))){t||M.getInstance().info(`Skipping old/unrecognized log: `,n);return}t||M.getInstance().info(`Zipping: `,n);let r=x(n);s.file(g(n),r,{compression:`DEFLATE`})}),n&&Object.entries(n).forEach(([e,n])=>{t||M.getInstance().info(`Zipping extra file: `,e),s.file(e,n,{compression:`DEFLATE`})}),s}async function hn(e,t,n){let r=global.OVERLAYED_META.release.id?st(global.OVERLAYED_META.release.id):void 0,i=kt();return it(global.OVERLAYED.APPLICATION_ID,{file:Buffer.from(n,`base64`),data:{release_id:r,type:e,cortex_user_id:i,...t}}).then(e=>(M.getInstance().info(`Feedback submitted`,e),e.data.id)).catch(e=>{console.error(JSON.stringify(e,null,2)),M.getInstance().error(`Failed to submit feedback`,e)})}function gn(e){let t=new Ee(`app.log`);return t.init(global.OVERLAYED.APPLICATION_ID,e.debug),{scope:e=>t.scope(e),info:e=>t.info(e),warn:e=>t.warn(e),error:e=>t.error(e),debug:e=>t.debug(e),submitFeedback:async(e,t,n)=>{let r=global.OVERLAYED_META.release.id?st(global.OVERLAYED_META.release.id):void 0;return r&&T.isPackaged&&q.getInstance().track(e===`bug_report`?`bug_report_submitted`:`suggestion_submitted`,{release_id:r}),await hn(e,t,await mn(n).generateAsync({type:`base64`}))},getLogsZip:e=>mn(e)}}const _n=1e3;function vn(e,t,r,i,a){let o=Ie.getInstance(),s=M.getInstance().scope(`SetupPipeServer`);s.log(`Initializing`);function c(e,t){let n=r.get(t);if(!n)r.set(t,[e]);else{if(n.length>=_n){O.getInstance().warn(`Event buffer full, removing oldest event`,`EVENT_BUFFER_FULL`,{summary:`Event buffer overflow for module ${t}. Buffer size: ${n.length}, max: ${_n}`});return}n.push(e)}}function l(r){s.info(r);let i=Dt(r);if(i instanceof n.errors){q.getInstance().track(`invalid_game_event`,{}),O.getInstance().warn(`Invalid event`,`INVALID_EVENT`,{summary:i.summary});return}let o=He.includes(i.type),l=e.modules.find(e=>e.key===`universal`),u=o?l:e.modules.find(e=>e.key===i.game);if(!u){s.warn(`Invalid module`,{module:o?`universal`:i.game});return}let d=u.events.event,f=d(r);if(f instanceof n.errors){if(`type`in f.byPath)return;s.warn(`Invalid event`,{summary:f.summary}),q.getInstance().track(`invalid_game_event`,{game:i.game,type:i.type,summary:f.summary}),O.getInstance().warn(`Invalid event`,`INVALID_EVENT`,{summary:f.summary});return}if(!a[u.key]){c(f,u.key);return}if(f.type===`unsupported_game_version`){let{content:e}=f;q.getInstance().track(`unsupported_game_version`,{game:f.game,hash:e.process_hash,version:e.game_version})}let p=Kt(u.key,f.type),m=Kt(u.key,`*`),h=t.get(p),g=t.get(m),_=[...Array.from(h??[]),...Array.from(g??[])];if(_.length===0){s.info(`No handlers found for event`,{event:f});return}_.forEach(e=>{e(f)})}return i.on(`flushEvents`,e=>{if(a[e])return;a[e]=!0;let t=r.get(e);t&&(M.getInstance().info(`Flushing ${t.length} events for module ${e}`),t.forEach(e=>l(e)),r.delete(e))}),o.on(`data`,e=>e.forEach(l)),o.on(`error`,e=>{s.error(`Pipe server error`,e),O.getInstance().error(`Pipe server error`,`PIPE_SERVER_ERROR`,{error:e})}),o.on(`connected`,()=>{s.log(`Pipe server connected`)}),o.on(`disconnected`,()=>{s.log(`Pipe server disconnected`)}),o}const yn=D(class extends L{FETCH_INTERVAL=1e3*60*10;_fetchInterval=null;_flags=new Map;_overrides=new Map;_defaults=new Map;_boundOnGameReady=this.onGameEvent.bind(this);_boundOnGameClose=this.onGameEvent.bind(this);_readyResolve;ready;constructor(){super(`FeatureFlagManager`),this.ready=new Promise(e=>{this._readyResolve=e}),this.fetchFlags(),this.setupInterval(),Y.getInstance().on(`gameReady`,this._boundOnGameReady),Y.getInstance().on(`gameClose`,this._boundOnGameClose)}destroy(){this._fetchInterval&&=(clearInterval(this._fetchInterval),null),Y.getInstance().off(`gameReady`,this._boundOnGameReady),Y.getInstance().off(`gameClose`,this._boundOnGameClose),super.destroy()}setDefaults(e){this._defaults=new Map(Object.entries(e))}async refresh(){await this.fetchFlags()}override(e,t){let n=this.get(e);this._overrides.set(e,t),n!==t&&(this.emit(e,t),this.emit(`updated`,!0))}clearOverride(e){if(!this._overrides.has(e))return;let t=this.get(e);this._overrides.delete(e);let n=this.get(e);t!==n&&(this.emit(e,n),this.emit(`updated`,!0))}clearOverrides(){if(this._overrides.size===0)return;let e=new Map;for(let t of this._overrides.keys())e.set(t,this.get(t));this._overrides.clear();let t=!1;for(let[n,r]of e){let e=this.get(n);r!==e&&(this.emit(n,e),t=!0)}t&&this.emit(`updated`,!0)}isOverridden(e){return this._overrides.has(e)}getAllOverrides(){return Object.fromEntries(this._overrides)}inspect(e){let t=this._overrides.get(e),n=this._flags.get(e),r=this._defaults.get(e);return{effective:t??n??r??!1,override:t,actual:n,default:r}}get(e){let t=this._overrides.get(e),n=this._flags.get(e),r=this._defaults.get(e);return t??n??r??!1}getAll(){let e=Object.fromEntries(this._defaults);for(let[t,n]of this._flags)e[t]=n;for(let[t,n]of this._overrides)e[t]=n;return e}onGameEvent(){this.fetchFlags()}setupInterval(){this._fetchInterval=setInterval(()=>{this.fetchFlags()},this.FETCH_INTERVAL)}async fetchFlags(){try{let e=Y.getInstance().getActiveGames(),{data:t}=await at(global.OVERLAYED.APPLICATION_ID,{cortex_user_id:global.OVERLAYED_RUNTIME.userId,release_id:global.OVERLAYED_META.release.id??void 0,channel_id:global.OVERLAYED_META.release.channelId??void 0,active_games:e.map(e=>e.toString())??void 0}),n=new Map;for(let e of t)n.set(e.name,e.enabled);for(let[e,t]of n){if(this._overrides.has(e))continue;let n=this._flags.get(e);n!==void 0&&n!==t&&this.emit(e,t)}for(let[e]of this._flags)this._overrides.has(e)||n.has(e)||this.emit(e,this._defaults.get(e)??!1);this._flags=n;for(let e of this._defaults.keys())this._flags.has(e)||this.logger.warn(`Registered feature flag "${e}" was not found in the API response`);this.emit(`updated`,!0)}catch(e){this.logger.error(`Failed to fetch feature flags`,e)}finally{this._readyResolve()}}});function bn(e){let t=yn.getInstance();return e&&t.setDefaults(e),{on:(e,n)=>t.on(e,n),off:(e,n)=>t.off(e,n),ready:t.ready,get:e=>t.get(e),getAll:()=>t.getAll(),refresh:()=>t.refresh(),override:(e,n)=>t.override(e,n),clearOverride:e=>t.clearOverride(e),clearOverrides:()=>t.clearOverrides(),isOverridden:e=>t.isOverridden(e),getAllOverrides:()=>t.getAllOverrides(),inspect:e=>t.inspect(e)}}function xn(){let e=nn.getInstance();return{on:(t,n)=>{e.on(t,n)},off:(t,n)=>{e.off(t,n)},allowSiteUpdateOnNextLoad:()=>{e.allowSiteUpdateOnNextLoad()}}}const Sn=n({dismissedNotices:fe(n.string).array()}),Cn=D(class extends L{NOTICE_FETCH_INTERVAL=1e3*60*10;MAX_DISMISSED_NOTICES=100;_noticeFetchInterval=null;_notices=[];_noticesFile;_boundOnGameReady=this.onGameReady.bind(this);get notices(){let e=this._noticesFile.get().dismissedNotices;return this._notices.filter(t=>!e.includes(t.id))}constructor(){super(`NoticeManager`),this._noticesFile=this.getNoticesFile(),this._noticesFile.load(),this.fetchNotices(),this.setupNoticeInterval(),Y.getInstance().on(`gameReady`,this._boundOnGameReady)}destroy(){this._noticeFetchInterval&&=(clearInterval(this._noticeFetchInterval),null),Y.getInstance().off(`gameReady`,this._boundOnGameReady),super.destroy()}dismissNotice(e){let t=this._notices.find(t=>t.id===e);if(!t||!t.dismissible)return;let n=this._noticesFile.get().dismissedNotices;n.unshift(e),this._noticesFile.set({dismissedNotices:n.slice(0,this.MAX_DISMISSED_NOTICES)}),this.emitNoticesUpdated()}onGameReady(){this.fetchNotices()}setupNoticeInterval(){this._noticeFetchInterval=setInterval(()=>{this.fetchNotices()},this.NOTICE_FETCH_INTERVAL)}getNoticesFile(){return new k({path:Et([`notices.json`]),schema:Sn,default:{dismissedNotices:[]}})}async fetchNotices(){let e=Y.getInstance().getActiveGames();try{let{data:t}=await ot(global.OVERLAYED.APPLICATION_ID,{release_id:global.OVERLAYED_META.release.id?st(global.OVERLAYED_META.release.id):void 0,channel:global.OVERLAYED_META.release.channel,version:global.OVERLAYED_META.release.version,games:e});this._notices=t,this.emitNoticesUpdated()}catch(e){this.logger.error(`Failed to fetch notices`,e)}}emitNoticesUpdated(){this.emit(`noticesUpdated`,{notices:this.notices})}});function wn(){let e=Cn.getInstance();return{on:(t,n)=>{e.on(t,n)},off:(t,n)=>{e.off(t,n)},dismissNotice:t=>{e.dismissNotice(t)},getNotices:()=>e.notices}}const{Provider:Tn}=ue;var En=class extends Tn{logger=M.getInstance().scope(`OverlayedProvider`);constructor(e,t,n){super(n),this.options=e,this.updater=t}async getLatestVersion(){try{let e=await tt(this.options.application_id,{release_id:this.options.release_id,cortex_user_id:this.options.cortex_user_id,access_token:this.options.access_token,requested_channel:this.options.requested_channel});return this.logger.log(`checkApplicationRelease response`,e.data),q.getInstance().track(`update_release_check_success`,{version:e.data.release.version,channel:e.data.release.channel,fallback:!!e.data.fallback}),e.data.fallback&&this.logger.warn(`Update fallback detected, switching to default channel`),{path:``,sha512:e.data.download_hash??``,version:`${e.data.release.version}-${e.data.release.channel}`,releaseName:e.data.release.id,releaseDate:e.data.release.created_at,files:[{url:e.data.download_url,sha512:e.data.download_hash??``}]}}catch(e){let t=e instanceof Error?e.stack||e.message:String(e);throw q.getInstance().track(`update_release_check_error`,{message:t}),Error(`Unable to find the latest version (${this.options.release_id}), please ensure release exists. ${t}`)}}resolveFiles(e){return[{info:e.files[0],url:new URL(e.files[0].url)}]}};function Dn(e){return{provider:`custom`,updateProvider:En,...e}}function Z(){return ue.autoUpdater}const On=D(class extends L{DEFAULT_CHANNEL=`public`;TOKEN_REFRESH_INTERVAL=1e3*60*15;accessTokenFetcher=void 0;_tokenRefreshInterval=null;_downloadStarted=!1;constructor(){super(`UpdateManager`)}init(){super.init(),this.registerListenerForwarders(),this.setupTokenRefreshInterval(),Z().disableDifferentialDownload=!0}destroy(){Z().removeAllListeners(),this._tokenRefreshInterval&&=(clearInterval(this._tokenRefreshInterval),null),super.destroy()}setupTokenRefreshInterval(){this._tokenRefreshInterval=setInterval(()=>{this.checkAndRefreshToken()},this.TOKEN_REFRESH_INTERVAL)}async checkAndRefreshToken(){let e=global.OVERLAYED_META.release.channel;e!==this.DEFAULT_CHANNEL&&(this.logger.log(`Refreshing access token for channel`,e),await this.setAndGetLatestAccessToken(e))}async checkForUpdates(e){this.logger.log(`Starting checkForUpdates`);let t=e??global.OVERLAYED_META.release.channel;return q.getInstance().track(`check_for_update`,{channel:t}),this._downloadStarted=!1,await this.setAndGetLatestAccessToken(t),e?(Z().allowDowngrade=!0,Z().channel=e,this.setFeedUrl({requestedChannel:e})):(Z().allowDowngrade=!1,Z().channel=global.OVERLAYED_META.release.channel,this.setFeedUrl({})),this.logger.log(`Checking for updates`),Z().checkForUpdates()}async switchChannel(e){return this.logger.log(`Switching channel`,e),q.getInstance().track(`update_channel_switch`,{from_channel:global.OVERLAYED_META.release.channel,to_channel:e}),this._downloadStarted=!1,await this.setAndGetLatestAccessToken(e),Z().allowDowngrade=!0,Z().channel=e,this.setFeedUrl({requestedChannel:e}),Z().checkForUpdates()}quitAndInstall(e,t){this.logger.log(`quitAndInstall`,{isSilent:e,isForceRunAfter:t});let[n,r]=this.canUpdate();if(!n)throw this.logger.warn(`Cannot update`,{denialReason:r}),q.getInstance().track(`update_install_blocked`,{reason:r}),Error(r);return this.logger.log(`Quitting and installing`),q.getInstance().track(`update_install`,{}),Z().quitAndInstall(e,t)}canUpdate(){return Y.getInstance().isInGame?[!1,`User is in game`]:[!0,null]}downloadUpdate(e){return Z().downloadUpdate(e)}setAccessTokenFetcher(e){this.accessTokenFetcher=e}async setAndGetLatestAccessToken(e){if(this.logger.log(`Fetching new token`),!this.accessTokenFetcher)return this.logger.warn(`accessTokenFetcher is not set, private channels will not work.`),K(null),null;if(this.logger.log(`Setting and getting latest access token for channel`,e),e===this.DEFAULT_CHANNEL)return this.logger.log(`Default channel, skipping`),K(null),null;if(e!==global.OVERLAYED_META.release.channel)return this.forceFetchNewAccessToken(e);this.logger.log(`Access token exists, checking expiration`);let t=G();if(t){let e=this.getAccessTokenExpirationDate(t);if(!e)this.logger.log(`Invalid token, setting to null`),K(null);else if(e.getTime()>=Date.now()+300*1e3)return this.logger.log(`Token is not expired, using it.`),t}return this.forceFetchNewAccessToken(e)}async forceFetchNewAccessToken(e){this.accessTokenFetcher||this.logger.warn(`accessTokenFetcher is not set [2], private channels will not work.`);try{let t=await this.accessTokenFetcher?.(e)??null;this.logger.log(`New token fetched`,t?.slice(0,5)+`...`);let n=G();if(t==null||n===t){q.getInstance().track(`update_token_invalid`,{channel:e}),this.emit(`authTokenInvalid`,{}),K(null);return}return K(t),t}catch(e){let t=e instanceof Error?e.message:String(e);return q.getInstance().track(`update_token_fetch_error`,{message:t}),this.logger.error(`Error fetching new token`,{error:e,message:t}),K(null),null}}setFeedUrl(e){if(!global.OVERLAYED_META.release.id){this.logger.warn(`Tried to set feed URL in development mode`);return}Z().setFeedURL(Dn({application_id:global.OVERLAYED.APPLICATION_ID,release_id:global.OVERLAYED_META.release.id,cortex_user_id:global.OVERLAYED_RUNTIME.userId,access_token:G(),requested_channel:e.requestedChannel}))}registerListenerForwarders(){Z().on(`checking-for-update`,()=>{this.logger.info(`Checking for updates`),this.emit(`checkingForUpdates`,{})}),Z().on(`download-progress`,e=>{this._downloadStarted||(this._downloadStarted=!0,q.getInstance().track(`update_download_started`,{version:Z().currentVersion?.version??``})),this.emit(`downloadProgress`,{info:e});let t=`Download speed: ${e.bytesPerSecond} - Downloaded ${e.percent}%`;t+=` (${e.transferred}/${e.total})`,this.logger.log(t)}),Z().on(`error`,(e,t)=>{this.logger.error(`Error`,e,t),q.getInstance().track(`update_download_error`,{message:t??e.message}),this.emit(`error`,{error:e,message:t})}),Z().on(`update-not-available`,e=>{this.logger.info(`Update not available`,e),q.getInstance().track(`update_not_available`,{version:e.version}),this.emit(`updateNotAvailable`,{info:e})}),Z().on(`update-available`,e=>{this.logger.info(`Update available`,e),q.getInstance().track(`update_available`,{version:e.version,channel:Z().channel??``}),this.emit(`updateAvailable`,{info:e})}),Z().on(`update-downloaded`,e=>{this.logger.info(`Update downloaded`,e),q.getInstance().track(`update_download_complete`,{version:e.version}),this.emit(`updateDownloaded`,{event:e})}),Z().on(`update-cancelled`,e=>{this.logger.info(`Update cancelled`,e),q.getInstance().track(`update_cancelled`,{version:e.version}),this.emit(`updateCancelled`,{info:e})})}getAccessTokenExpirationDate(e){try{let t=e.split(`.`)[1];if(!t)return null;let n=atob(t.replace(/-/g,`+`).replace(/_/g,`/`)),r=JSON.parse(n);return r.exp?new Date(r.exp*1e3):null}catch{return null}}});function kn(){let e=On.getInstance();return{site:xn(),on:(t,n)=>{e.on(t,n)},off:(t,n)=>{e.off(t,n)},setAccessTokenFetcher:t=>e.setAccessTokenFetcher(t),checkForUpdates:()=>e.checkForUpdates(),switchChannel:t=>e.checkForUpdates(t),quitAndInstall:(t,n)=>e.quitAndInstall(t,n),canUpdate:()=>e.canUpdate(),downloadUpdate:t=>e.downloadUpdate(t)}}function An(){return{getChannel:()=>global.OVERLAYED_META.release.channel,getVersion:()=>global.OVERLAYED_META.release.version,getReleaseId:()=>global.OVERLAYED_META.release.id}}const jn=D(class extends L{_knownModificationTimes=new Map;_confirmedDumps=new Set;_pendingReports=new Map;_snapshotTimestamp=0;boundOnGameReady=this.onGameReady.bind(this);boundOnGameClose=this.onGameClose.bind(this);constructor(){super(`CrashDumpManager`)}init(){super.init(),this.logger.debug(`init() registering game event listeners`),Y.getInstance().on(`gameReadyInternal`,this.boundOnGameReady),Y.getInstance().on(`gameCloseInternal`,this.boundOnGameClose),this.logger.debug(`init() complete`)}destroy(){this.logger.debug(`destroy() called`,{pendingReports:this._pendingReports.size,confirmedDumps:this._confirmedDumps.size,knownModificationTimes:this._knownModificationTimes.size}),Y.getInstance().off(`gameReadyInternal`,this.boundOnGameReady),Y.getInstance().off(`gameCloseInternal`,this.boundOnGameClose),this._knownModificationTimes.clear(),this._confirmedDumps.clear(),this._pendingReports.clear(),this._snapshotTimestamp=0,this.logger.debug(`destroy() cleanup complete`),super.destroy()}async submit(e){this.logger.debug(`submit() called`,{id:e,pendingCount:this._pendingReports.size});let t=this._pendingReports.get(e);if(!t){this.logger.warn(`submit called with unknown id`,e);return}let{response:n,dumpPath:r}=t;this.logger.debug(`Resolved pending report for submission`,{id:e,dumpPath:r});let i=global.OVERLAYED.APPLICATION_ID,a=kt();if(this.logger.debug(`Resolved identifiers for submission`,{applicationId:i,cortexUserId:a}),n.crash_dump_upload_request)try{this.logger.debug(`Reading crash dump file`,{dumpPath:r});let t=await w.readFile(r);this.logger.debug(`Uploading crash dump`,{dumpPath:r,size:t.byteLength}),await ut(n.crash_dump_upload_request,new Uint8Array(t)),this.logger.debug(`Crash dump uploaded, confirming`,{id:e}),await rt(i,e,{cortex_user_id:a,file_type:`crash_dump`}),this.logger.debug(`Crash dump confirmed`,{id:e})}catch(e){this.logger.error(`Failed to upload crash dump`,{dumpPath:r,error:e})}else this.logger.warn(`No crash dump upload request in response`,{id:e});this._pendingReports.delete(e),this._confirmedDumps.add(r),this.logger.debug(`Report state updated, attempting dump file cleanup`,{id:e,dumpPath:r});try{await w.unlink(r),this.logger.debug(`Dump file cleaned up successfully`,{dumpPath:r})}catch(e){this.logger.warn(`Failed to clean up dump file after submission`,{dumpPath:r,error:e})}this.logger.log(`Crash report submitted successfully`,r)}async onGameReady({ravenGame:e}){this.logger.debug(`onGameReady() fired`,{game:e.identifier}),await this.snapshotModificationTimes(),this.logger.debug(`onGameReady() snapshot complete`,{game:e.identifier})}async onGameClose({ravenGame:e}){this.logger.debug(`onGameClose() fired`,{game:e.identifier}),await this.scanForNewDumps(ft(e.identifier)),this.logger.debug(`onGameClose() scan complete`,{game:e.identifier})}async snapshotModificationTimes(){let e=Te();this._snapshotTimestamp=Date.now(),this.logger.debug(`snapshotModificationTimes() called`,{crashDumpsPath:e,snapshotTimestamp:this._snapshotTimestamp});try{await w.access(e)}catch{this.logger.debug(`Crash dumps directory does not exist, skipping snapshot`,{crashDumpsPath:e});return}let t=await this.findAllDumps(e);this.logger.debug(`Found dumps for snapshot`,{count:t.length});for(let e of t)try{let t=await w.stat(e);if(t.mtimeMs>=this._snapshotTimestamp-3e4){this.logger.debug(`Skipping recent dump from snapshot`,{dumpPath:e,mtimeMs:t.mtimeMs,snapshotTimestamp:this._snapshotTimestamp});continue}this._knownModificationTimes.set(e,t.mtimeMs),this.logger.debug(`Recorded modification time`,{dumpPath:e,mtimeMs:t.mtimeMs})}catch(t){this.logger.warn(`Failed to stat dump file during snapshot`,{dumpPath:e,error:t})}this.logger.debug(`Snapshot complete`,{totalTracked:this._knownModificationTimes.size})}async scanForNewDumps(e){let t=Te();this.logger.debug(`scanForNewDumps() called`,{game:e,crashDumpsPath:t});try{await w.access(t)}catch{this.logger.debug(`Crash dumps directory does not exist, skipping scan`,{crashDumpsPath:t});return}let n=new Set([...this._pendingReports.values()].map(e=>e.dumpPath)),r=await this.findAllDumps(t);this.logger.debug(`Scan found dumps`,{total:r.length,pendingCount:n.size,confirmedCount:this._confirmedDumps.size});for(let t of r){if(this._confirmedDumps.has(t)){this.logger.debug(`Skipping already confirmed dump`,{dumpPath:t});continue}if(n.has(t)){this.logger.debug(`Skipping already pending dump`,{dumpPath:t});continue}let r;try{r=await w.stat(t)}catch(e){this.logger.warn(`Failed to stat dump file during scan`,{dumpPath:t,error:e});continue}let i=r.mtimeMs,a=this._knownModificationTimes.get(t);if(this.logger.debug(`Comparing modification times`,{dumpPath:t,modificationTime:i,knownModificationTime:a}),a===void 0||i>a){this.logger.debug(`Dump is new or modified`,{dumpPath:t,isNew:a===void 0});try{let n=r.size,i=m.basename(m.dirname(t)),a=m.basename(t,m.extname(t));this.logger.debug(`Preparing crash report`,{dumpPath:t,crashDumpSize:n,crashSource:i});let o=(await mn().generateAsync({type:`uint8array`})).byteLength,s=global.OVERLAYED.APPLICATION_ID,c=kt(),l=global.OVERLAYED_META.release.id;this.logger.debug(`Creating game crash report via API`,{applicationId:s,cortexUserId:c,game:e,crashSource:i,crashDumpSize:n,logsSize:o});let{data:u}=await nt(s,{cortex_user_id:c,game:e,crash_source:i,crash_identifier:a,release_id:l,logs_size:o,crash_dump_size:n});this._pendingReports.set(u.id,{response:u,dumpPath:t}),this.logger.debug(`Crash report created, emitting 'new' event`,{id:u.id,game:e}),this.logger.log(`New crash dump detected`,{dumpPath:t,game:e,id:u.id}),this.emit(`new`,{id:u.id,game:e})}catch(e){this.logger.error(`Failed to create game crash report`,{dumpPath:t,error:e})}}else this.logger.debug(`Dump unchanged, skipping`,{dumpPath:t});this._knownModificationTimes.set(t,i)}this.logger.debug(`scanForNewDumps() complete`,{game:e,pendingReports:this._pendingReports.size})}async findAllDumps(e){this.logger.debug(`findAllDumps() called`,{basePath:e});let t=[],n;try{n=await w.readdir(e,{withFileTypes:!0})}catch(n){return this.logger.warn(`Failed to read crash dumps directory`,{basePath:e,error:n}),t}this.logger.debug(`Top-level entries in crash dumps directory`,{count:n.length,directories:n.filter(e=>e.isDirectory()).map(e=>e.name)});for(let r of n)if(r.isDirectory()){let n=m.join(e,r.name),i;try{i=await w.readdir(n,{withFileTypes:!0})}catch(e){this.logger.warn(`Failed to read crash dump subdirectory`,{subPath:n,error:e});continue}let a=i.filter(e=>e.isFile()&&e.name.endsWith(`.dmp`));this.logger.debug(`Scanned subdirectory`,{subPath:n,totalEntries:i.length,dmpCount:a.length});for(let e of a)t.push(m.join(n,e.name))}return this.logger.debug(`findAllDumps() complete`,{totalFound:t.length}),t}});let Mn=!1,Nn={},Pn,Fn=new ge,In;function Ln(e){zn(e);let t=Rn(e),{init:n=!0,debug:r=!1,silent:i=!0}=t,a=Vn(e);if(M.getInstance().init(e.applicationId,r,i),rn.getInstance().init(e.applicationId,r,!0,!0),a&&Wn($e(e.applicationId),!1).catch(()=>{}),Mn)return Pn;function o(){if(Mn){M.getInstance().warn(`Overlayed already initialized`);return}en();let n=Ut.get({createIfMissing:!1});if(n){let t=Gt({currentAccount:n.currentAccount,accounts:n.accounts,expected:{applicationId:e.applicationId,baseUrl:Ke}});t&&Je(()=>t.account.apiKey)}let r=new Map,i=new Map,a=kn(),s=qt(t.modules,r,Fn),c=Jt(),l=$t(t.keybinds),u=sn(),d=ln(),f=dn(),p=un(),m=gn(t),h=wn(),g=bn(t.featureFlags),_=An();M.getInstance().log(`Overlayed initialized`),Hn(t),vn(t,r,i,Fn,Nn),Mn=!0,Pn={...s,...c,ads:f,keybinds:l,windows:u,input:d,cortex:p,hasAnyActiveProcesses:()=>Pt.getInstance().hasAnyActiveProcesses,hasAnyActiveGames:()=>Y.getInstance().isInGame,init:o,log:m,initialized:Mn,notices:h,featureFlags:g,updater:a,application:_,crashDumps:{on:(e,t)=>jn.getInstance().on(e,t),off:(e,t)=>jn.getInstance().off(e,t),submit:e=>jn.getInstance().submit(e)}},Pn.universal.on(`logged_in`,e=>{q.getInstance().track(`account_id`,{account_id:e.content.account_id,game:e.game})})}return n&&a?(o(),Pn):new Proxy({init:o},{get:(e,t)=>{if(t===`init`)return e[t];if(!Mn)throw Error(a?`overlayed was called before initialized: ${t}`:Bn);return Pn[t]}})}function Rn(e){return{...e,modules:[...e.modules,Ue()]}}global.OVERLAYED=new Proxy({},{get:()=>{throw Error(`function overlayed was not called`)}});function zn(e){if(!me(e.applicationId))throw Error(`Invalid applicationId, must be a valid ULID.`)}const Bn="Overlayed metadata has not been initialized yet. Run `overlayed init` to set up your local development environment.";function Vn(e){let t=Un(),n=`1.3.9`,r=$e(e.applicationId);function i(){return{package_version:n,application_id:r,application_version:t?.release.version??`0.0.0`}}return M.getInstance().log(`ua object`,i()),Xe(()=>i()),t===null?(global.OVERLAYED=new Proxy({},{get:()=>{throw Error(Bn)}}),Wn(r,!0),!1):(global.OVERLAYED={APPLICATION_ID:r,APP_BUILD_CHANNEL:t.release.channel,APP_VERSION:t.release.version,PACKAGE_VERSION:n,FRONTEND_VERSION:`0.0.0`,sessionId:At(),electron:e.electron},global.OVERLAYED_META=t,global.OVERLAYED_RUNTIME={userId:kt()},M.getInstance().log(`meta`,t),!0)}function Hn(e){M.getInstance().warn(`Bootstrapping`);let t=e.universal?[`*`]:e.modules.map(e=>e.key);Y.getInstance().setSubscribedGames(t),M.getInstance().warn(`Initializing update manager`),On.getInstance().init(),M.getInstance().warn(`Initialized update manager`),nn.getInstance().init({manualUpdates:e.site?.manualUpdates??!1}),Vt.getInstance().init(),Y.getInstance().init(),jn.getInstance().init(),Pt.getInstance().init(),Nt.getInstance().init(),q.getInstance().track(`start`,{}),Ht.getInstance().check(e.applicationId);try{In&&clearInterval(In),In=setInterval(()=>{try{W()}catch{}},3e4),In.unref()}catch(e){M.getInstance().log(`failed to start sessionLastUsed interval`,e)}async function n(){let e={};e.os=ae.platform().trim(),e.os_version=process.getSystemVersion().trim(),e.architecture=ae.arch().trim();let t=ae.cpus();t.length>0?(e.cpu=t[0].model.trim(),e.cpu_cores=t.length,e.cpu_speed=t[0].speed):M.getInstance().warn(`Failed to collect CPU info`);let n=await le.graphics();M.getInstance().info(`GPU info`,n);let r=n.controllers.sort((e,t)=>(t.vram??0)-(e.vram??0))[0];r?(e.gpu=r.model.trim(),e.gpu_memory=r.vram??0):M.getInstance().warn(`Failed to find primary GPU`),e.display_count=n.displays.length;let i=n.displays.find(e=>e.main)??n.displays[0];i?(e.primary_display_resolution_x=i.resolutionX??void 0,e.primary_display_resolution_y=i.resolutionY??void 0,e.primary_display_refresh_rate=i.currentRefreshRate??void 0):M.getInstance().warn(`Failed to find main display`),e.ram=process.getSystemMemoryInfo().total;let a=ae.homedir(),o=await w.statfs(a);return o&&`blocks`in o&&`bsize`in o&&`bavail`in o?(e.disk=o.blocks*o.bsize,e.disk_free=o.bavail*o.bsize):M.getInstance().warn(`Failed to collect disk info`),M.getInstance().log(`Retrieved system information`,e),e}T.on(`ready`,()=>{n().then(e=>{q.getInstance().track(`system_info`,e)}).catch(e=>{M.getInstance().log(`Failed to retrieve system information`,e)})}),T.on(`quit`,()=>{q.getInstance().track(`electron_quit`,{}),Gn()}),process.on(`exit`,()=>{q.getInstance().track(`exit`,{}),Gn()})}function Un(){if(T.isPackaged)try{let e=m.join(process.resourcesPath,`meta.json`);return JSON.parse(y.readFileSync(e,`utf-8`))}catch(e){throw Error(`Failed to read application metadata from resources/meta.json`,{cause:e})}else{let e=m.join(process.cwd(),`.overlayed`,`meta.json`);return y.existsSync(e)?JSON.parse(y.readFileSync(e,`utf-8`)):null}}async function Wn(e,t=!1){if(!T.isPackaged)try{M.getInstance().log(`Fetching application metadata from API...`);let n=ke({...(await et(e)).data,siteUrl:``});t&&(M.getInstance().log(v.yellowBright(`Uninitialized development environment detected. Created .overlayed folder. In the future, run ${v.bold(`overlayed init`)} to do so. \n\nThe process will now exit to load the cached metadata.\n\n${v.italic(`Note: This will never happen in a packaged application, and will only happen once in local development so long as the .overlayed folder exists.`)}`)),process.exit(0)),global.OVERLAYED_META=n}catch(e){M.getInstance().error(`Failed to fetch application meta`,e),t&&(console.error(`
10
10
  Failed to fetch application metadata. Please ensure you're authenticated with 'overlayed login'.
11
- `),process.exit(1))}}async function Wn(){try{W()}catch{}try{In&&clearInterval(In),In=void 0}catch{}q.getInstance().flush(),Nt.getInstance().destroy(),jn.getInstance().destroy(),Y.getInstance().destroy(),Vt.getInstance().destroy(),Pt.getInstance().destroy(),It.getInstance().getInterface(`OGG_SIEGE`).destroy(),Ie.getInstance().destroy(),O.getInstance().destroy(),On.getInstance().destroy(),nn.getInstance().destroy(),yn.getInstance().destroy()}export{Le as RenderInterface,ze as VirtualKey,I as defineConfig,Ln as overlayed};
11
+ `),process.exit(1))}}async function Gn(){try{W()}catch{}try{In&&clearInterval(In),In=void 0}catch{}q.getInstance().flush(),Nt.getInstance().destroy(),jn.getInstance().destroy(),Y.getInstance().destroy(),Vt.getInstance().destroy(),Pt.getInstance().destroy(),It.getInstance().getInterface(`OGG_SIEGE`).destroy(),Ie.getInstance().destroy(),O.getInstance().destroy(),On.getInstance().destroy(),nn.getInstance().destroy(),yn.getInstance().destroy()}export{Le as RenderInterface,ze as VirtualKey,I as defineConfig,Ln as overlayed};
package/dist/siege.d.ts CHANGED
@@ -522,6 +522,7 @@ declare const SIEGE_MAP_TO_ID: Readonly<{
522
522
  readonly stadiumBravo: SiegeMapNameId;
523
523
  readonly muteCommTower: SiegeMapNameId;
524
524
  readonly doktorsLab: SiegeMapNameId;
525
+ readonly calypsoCasino: SiegeMapNameId;
525
526
  }>;
526
527
  declare const SIEGE_MAP_LABELS: Record<SiegeMapNameId, string>;
527
528
  declare const SIEGE_ROUND_STATES_TO_ID: Readonly<{
@@ -579,21 +580,6 @@ declare function module(): {
579
580
  };
580
581
  };
581
582
  event: {
582
- game: "siege";
583
- type: "player_side_changed";
584
- creation_time: number;
585
- content: {
586
- player_id: SiegePlayerId;
587
- side: "attacker" | "both" | "defender" | "invalid" | (string & {});
588
- };
589
- } | {
590
- game: "siege";
591
- type: "defuser_sabotaged";
592
- creation_time: number;
593
- content: {
594
- player_id: SiegePlayerId;
595
- };
596
- } | {
597
583
  game: "siege";
598
584
  type: "started_queuing";
599
585
  creation_time: number;
@@ -775,6 +761,14 @@ declare function module(): {
775
761
  player_id: SiegePlayerId;
776
762
  location_name: string;
777
763
  };
764
+ } | {
765
+ game: "siege";
766
+ type: "player_side_changed";
767
+ creation_time: number;
768
+ content: {
769
+ player_id: SiegePlayerId;
770
+ side: "attacker" | "both" | "defender" | "invalid" | (string & {});
771
+ };
778
772
  } | {
779
773
  game: "siege";
780
774
  type: "player_score_changed";
@@ -822,6 +816,13 @@ declare function module(): {
822
816
  content: {
823
817
  player_id: SiegePlayerId;
824
818
  };
819
+ } | {
820
+ game: "siege";
821
+ type: "defuser_sabotaged";
822
+ creation_time: number;
823
+ content: {
824
+ player_id: SiegePlayerId;
825
+ };
825
826
  } | {
826
827
  game: "siege";
827
828
  type: "defuser_picked_up";
@@ -1939,21 +1940,6 @@ declare const siegeEvents: _$arktype.Module<{
1939
1940
  };
1940
1941
  };
1941
1942
  event: {
1942
- game: "siege";
1943
- type: "player_side_changed";
1944
- creation_time: number;
1945
- content: {
1946
- player_id: SiegePlayerId;
1947
- side: "attacker" | "both" | "defender" | "invalid" | (string & {});
1948
- };
1949
- } | {
1950
- game: "siege";
1951
- type: "defuser_sabotaged";
1952
- creation_time: number;
1953
- content: {
1954
- player_id: SiegePlayerId;
1955
- };
1956
- } | {
1957
1943
  game: "siege";
1958
1944
  type: "started_queuing";
1959
1945
  creation_time: number;
@@ -2135,6 +2121,14 @@ declare const siegeEvents: _$arktype.Module<{
2135
2121
  player_id: SiegePlayerId;
2136
2122
  location_name: string;
2137
2123
  };
2124
+ } | {
2125
+ game: "siege";
2126
+ type: "player_side_changed";
2127
+ creation_time: number;
2128
+ content: {
2129
+ player_id: SiegePlayerId;
2130
+ side: "attacker" | "both" | "defender" | "invalid" | (string & {});
2131
+ };
2138
2132
  } | {
2139
2133
  game: "siege";
2140
2134
  type: "player_score_changed";
@@ -2182,6 +2176,13 @@ declare const siegeEvents: _$arktype.Module<{
2182
2176
  content: {
2183
2177
  player_id: SiegePlayerId;
2184
2178
  };
2179
+ } | {
2180
+ game: "siege";
2181
+ type: "defuser_sabotaged";
2182
+ creation_time: number;
2183
+ content: {
2184
+ player_id: SiegePlayerId;
2185
+ };
2185
2186
  } | {
2186
2187
  game: "siege";
2187
2188
  type: "defuser_picked_up";
package/dist/siege.js CHANGED
@@ -1 +1 @@
1
- import{scope as e,type as t}from"arktype";function n(e){return e}function r(e){return e}function i(e){return e?t=>(e(t),t):r}const a=i(),o=i(),s=i(),c=i(),l=i(),u=i(),d=i(),f=i(),p=i(),m=i(),h=i(),g=i(),_=`00000000-0000-0000-0000-000000000000`,ee=[`intro`,`planning`,`prep`,`action`,`results`,`invalid`,`first`],v=t(`string`),y=[0,1],b=t(`===`,...y),x=[`attacker`,`defender`,`both`,`invalid`],S=t(`string`),te=[`normal`,`overhealed`,`low_health`,`downed`,`dead`,`respawning`],C=t(`string`),w=[`pc`,`xbox`,`playstation`,`invalid`],T=t(`string`),E=`bullet.melee.explosive.falling.regeneration.unknown.debris.projectile.downed.gas.thermal_explosion.melee_gadget.barbed_wire.electric.reinforcement.frag.paralyzed.emp.break.cleanup.interrogation.melee-finisher.toxic.toxic-explosion.pneumatic.body-contact.contact-explosion.flash.parasite-spike.laser.concussion.blowtorch.taser-shield.reverse-friendly-fire.self-destroyed.area-control.fire.breach-kick.break-wall.blade-mine.melee-pushback.supressive-fire.gas-pipe-fire.invalid`.split(`.`),D=t(`string`),ne=[`unknown`,`enemy`,`friendly`,`invalid`],O=t(`string`),re=[`invalid`,`head`,`left_upper_arm`,`right_upper_arm`,`left_forearm`,`right_forearm`,`left_hand`,`right_hand`,`upper_torso`,`lower_torso`,`crotch`,`left_thigh`,`right_thigh`,`left_calf`,`right_calf`,`left_foot`,`right_foot`,`neck`,`clothing`],k=t(`string`),A=Object.freeze({teamDeathmatch:h(`TEAM DEATHMATCH`),goldenGun:h(`GOLDEN GUN`),freeForAll:h(`FREE FOR ALL`),weaponRoulette:h(`WEAPON ROULETTE`),dualFront:h(`DUAL FRONT`),bomb:h(`BOMB`),versusAi:h(`VERSUS AI`),hostage:h(`HOSTAGE`),threeVsThreeSecureArea:h(`3 VS 3 SECURE AREA`),targetDrill:h(`TARGET DRILL`),rengoku:h(`RENGOKU`),hideAndSeek:h(`HIDE AND SEEK`)}),j=Object.freeze({[A.teamDeathmatch]:`Team Deathmatch`,[A.goldenGun]:`Golden Gun`,[A.freeForAll]:`Free For All`,[A.weaponRoulette]:`Weapon Roulette`,[A.dualFront]:`Dual Front`,[A.bomb]:`Bomb`,[A.versusAi]:`Versus AI`,[A.hostage]:`Hostage`,[A.threeVsThreeSecureArea]:`3v3 Secure Area`,[A.targetDrill]:`Target Drill`,[A.rengoku]:`Rengoku`,[A.hideAndSeek]:`Hide and Seek`}),M=Object.freeze({ranked:a(205379),quickMatch:a(138115),customGame:a(62008),versusAi:a(397300),standard:a(393930),arcade:a(320109),siegeCup:a(414089),dualFront:a(420611),showdown:a(305544),trainingGrounds:a(-1),unranked:a(310813),deathmatch:a(420611),rengoku:a(359430),muteProtocol:a(368421),fieldTraining:a(423927),hideAndSeek:a(310854)}),N=Object.freeze({[M.quickMatch]:`Quick Match`,[M.ranked]:`Ranked`,[M.customGame]:`Custom Game`,[M.versusAi]:`Versus AI`,[M.standard]:`Standard`,[M.arcade]:`Arcade`,[M.siegeCup]:`Siege Cup`,[M.dualFront]:`Dual Front`,[M.showdown]:`Showdown`,[M.trainingGrounds]:`Training Grounds`,[M.unranked]:`Unranked`,[M.deathmatch]:`Deathmatch`,[M.rengoku]:`Rengoku`,[M.muteProtocol]:`M.U.T.E Protocol`,[M.fieldTraining]:`Field Training`,[M.hideAndSeek]:`Hide and Seek`}),P=Object.freeze({glaz:o(62242),blitz:o(62243),buck:o(62244),sledge:o(62245),ash:o(62246),thermite:o(62247),castle:o(62248),rook:o(62249),pulse:o(62250),doc:o(62251),mute:o(62252),smoke:o(62253),recruit:o(62555),thatcher:o(65143),twitch:o(65156),montagne:o(65159),bandit:o(65165),fuze:o(65168),kapkan:o(65171),tachanka:o(65174),jager:o(113049),iq:o(113052),frost:o(186159),blackbeard:o(187249),valkyrie:o(187252),caveira:o(207671),capitao:o(207674),echo:o(209180),hibana:o(209183),mira:o(222172),jackal:o(222182),ying:o(239334),lesion:o(239337),ela:o(254595),zofia:o(254606),dokkaebi:o(273652),vigil:o(273663),finka:o(281457),lion:o(281463),alibi:o(282399),maestro:o(285888),maverick:o(288504),clash:o(288526),nomad:o(293435),kaid:o(293436),gridlock:o(298589),mozzie:o(298616),nokk:o(299657),warden:o(299668),goyo:o(304196),amaru:o(308469),kali:o(310757),wamai:o(310768),oryx:o(317965),iana:o(317976),melusi:o(320062),ace:o(320073),zero:o(328927),aruni:o(328940),flores:o(334086),thunderbird:o(336466),osa:o(344493),thorn:o(349405),azami:o(354314),sens:o(357386),grim:o(365404),solis:o(376836),brava:o(382419),fenrir:o(386388),ram:o(392904),tubarao:o(395594),deimos:o(400504),striker:o(404278),sentry:o(404290),skopos:o(408405),rauora:o(421052),denari:o(2437779699),solidSnake:o(3786633270)}),F=Object.freeze({[P.glaz]:`glaz`,[P.blitz]:`blitz`,[P.buck]:`buck`,[P.sledge]:`sledge`,[P.ash]:`ash`,[P.thermite]:`thermite`,[P.castle]:`castle`,[P.rook]:`rook`,[P.pulse]:`pulse`,[P.doc]:`doc`,[P.mute]:`mute`,[P.smoke]:`smoke`,[P.recruit]:`recruit`,[P.thatcher]:`thatcher`,[P.twitch]:`twitch`,[P.montagne]:`montagne`,[P.bandit]:`bandit`,[P.fuze]:`fuze`,[P.kapkan]:`kapkan`,[P.tachanka]:`tachanka`,[P.jager]:`jager`,[P.iq]:`iq`,[P.frost]:`frost`,[P.blackbeard]:`blackbeard`,[P.valkyrie]:`valkyrie`,[P.caveira]:`caveira`,[P.capitao]:`capitao`,[P.echo]:`echo`,[P.hibana]:`hibana`,[P.mira]:`mira`,[P.jackal]:`jackal`,[P.ying]:`ying`,[P.lesion]:`lesion`,[P.ela]:`ela`,[P.zofia]:`zofia`,[P.dokkaebi]:`dokkaebi`,[P.vigil]:`vigil`,[P.finka]:`finka`,[P.lion]:`lion`,[P.alibi]:`alibi`,[P.maestro]:`maestro`,[P.maverick]:`maverick`,[P.clash]:`clash`,[P.nomad]:`nomad`,[P.kaid]:`kaid`,[P.gridlock]:`gridlock`,[P.mozzie]:`mozzie`,[P.nokk]:`nokk`,[P.warden]:`warden`,[P.goyo]:`goyo`,[P.amaru]:`amaru`,[P.kali]:`kali`,[P.wamai]:`wamai`,[P.oryx]:`oryx`,[P.iana]:`iana`,[P.melusi]:`melusi`,[P.ace]:`ace`,[P.zero]:`zero`,[P.aruni]:`aruni`,[P.flores]:`flores`,[P.thunderbird]:`thunderbird`,[P.osa]:`osa`,[P.thorn]:`thorn`,[P.azami]:`azami`,[P.sens]:`sens`,[P.grim]:`grim`,[P.solis]:`solis`,[P.brava]:`brava`,[P.fenrir]:`fenrir`,[P.ram]:`ram`,[P.tubarao]:`tubarao`,[P.deimos]:`deimos`,[P.striker]:`striker`,[P.sentry]:`sentry`,[P.skopos]:`skopos`,[P.rauora]:`rauora`,[P.solidSnake]:`solid snake`,[P.denari]:`denari`}),I=Object.freeze({[P.striker]:{name:`Striker`,role:`attacker`},[P.sledge]:{name:`Sledge`,role:`attacker`},[P.thatcher]:{name:`Thatcher`,role:`attacker`},[P.ash]:{name:`Ash`,role:`attacker`},[P.thermite]:{name:`Thermite`,role:`attacker`},[P.twitch]:{name:`Twitch`,role:`attacker`},[P.montagne]:{name:`Montagne`,role:`attacker`},[P.glaz]:{name:`Glaz`,role:`attacker`},[P.fuze]:{name:`Fuze`,role:`attacker`},[P.blitz]:{name:`Blitz`,role:`attacker`},[P.iq]:{name:`IQ`,role:`attacker`},[P.buck]:{name:`Buck`,role:`attacker`},[P.blackbeard]:{name:`Blackbeard`,role:`attacker`},[P.capitao]:{name:`Capitão`,role:`attacker`},[P.hibana]:{name:`Hibana`,role:`attacker`},[P.jackal]:{name:`Jackal`,role:`attacker`},[P.ying]:{name:`Ying`,role:`attacker`},[P.zofia]:{name:`Zofia`,role:`attacker`},[P.dokkaebi]:{name:`Dokkaebi`,role:`attacker`},[P.lion]:{name:`Lion`,role:`attacker`},[P.finka]:{name:`Finka`,role:`attacker`},[P.maverick]:{name:`Maverick`,role:`attacker`},[P.nomad]:{name:`Nomad`,role:`attacker`},[P.gridlock]:{name:`Gridlock`,role:`attacker`},[P.nokk]:{name:`Nøkk`,role:`attacker`},[P.amaru]:{name:`Amaru`,role:`attacker`},[P.kali]:{name:`Kali`,role:`attacker`},[P.iana]:{name:`Iana`,role:`attacker`},[P.ace]:{name:`Ace`,role:`attacker`},[P.zero]:{name:`Zero`,role:`attacker`},[P.flores]:{name:`Flores`,role:`attacker`},[P.osa]:{name:`Osa`,role:`attacker`},[P.sens]:{name:`Sens`,role:`attacker`},[P.grim]:{name:`Grim`,role:`attacker`},[P.brava]:{name:`Brava`,role:`attacker`},[P.ram]:{name:`Ram`,role:`attacker`},[P.deimos]:{name:`Deimos`,role:`attacker`},[P.rauora]:{name:`Rauora`,role:`attacker`},[P.sentry]:{name:`Sentry`,role:`defender`},[P.smoke]:{name:`Smoke`,role:`defender`},[P.mute]:{name:`Mute`,role:`defender`},[P.castle]:{name:`Castle`,role:`defender`},[P.pulse]:{name:`Pulse`,role:`defender`},[P.doc]:{name:`Doc`,role:`defender`},[P.rook]:{name:`Rook`,role:`defender`},[P.kapkan]:{name:`Kapkan`,role:`defender`},[P.tachanka]:{name:`Tachanka`,role:`defender`},[P.jager]:{name:`Jäger`,role:`defender`},[P.bandit]:{name:`Bandit`,role:`defender`},[P.frost]:{name:`Frost`,role:`defender`},[P.valkyrie]:{name:`Valkyrie`,role:`defender`},[P.caveira]:{name:`Caveira`,role:`defender`},[P.echo]:{name:`Echo`,role:`defender`},[P.mira]:{name:`Mira`,role:`defender`},[P.lesion]:{name:`Lesion`,role:`defender`},[P.ela]:{name:`Ela`,role:`defender`},[P.vigil]:{name:`Vigil`,role:`defender`},[P.alibi]:{name:`Alibi`,role:`defender`},[P.maestro]:{name:`Maestro`,role:`defender`},[P.clash]:{name:`Clash`,role:`defender`},[P.kaid]:{name:`Kaid`,role:`defender`},[P.mozzie]:{name:`Mozzie`,role:`defender`},[P.warden]:{name:`Warden`,role:`defender`},[P.goyo]:{name:`Goyo`,role:`defender`},[P.wamai]:{name:`Wamai`,role:`defender`},[P.oryx]:{name:`Oryx`,role:`defender`},[P.melusi]:{name:`Melusi`,role:`defender`},[P.aruni]:{name:`Aruni`,role:`defender`},[P.thunderbird]:{name:`Thunderbird`,role:`defender`},[P.thorn]:{name:`Thorn`,role:`defender`},[P.azami]:{name:`Azami`,role:`defender`},[P.solis]:{name:`Solis`,role:`defender`},[P.fenrir]:{name:`Fenrir`,role:`defender`},[P.tubarao]:{name:`Tubarao`,role:`defender`},[P.skopos]:{name:`Skopós`,role:`defender`},[P.denari]:{name:`Denari`,role:`defender`},[P.solidSnake]:{name:`Solid Snake`,role:`attacker`}}),L=Object.freeze({attacker:Object.entries(I).filter(([e,t])=>t.role===`attacker`).map(([e])=>({...I[o(Number(e))],id:o(Number(e))})),defender:Object.entries(I).filter(([e,t])=>t.role===`defender`).map(([e])=>({...I[o(Number(e))],id:o(Number(e))}))}),R=Object.freeze({favela:s(202283),fortress:s(293334),villa:s(286407),neighborhood:s(333785),themePark:s(229325),stadium:s(338641),outback:s(299534),yacht:s(62226),emeraldPlains:s(358871),chalet:s(62230),coastline:s(217482),bank:s(62228),consulate:s(62227),tower:s(255669),nighthavenLabs:s(375492),presidentialPlane:s(62225),house:s(62221),kafeDostoyevsky:s(62232),border:s(201746),closeQuarter:s(365400),lair:s(396234),herefordBase:s(62223),skyscraper:s(208094),cqbBasics:s(196157),oregon:s(62222),fortTruth:s(307723),kanal:s(62229),stadium2020:s(357300),clubhouse:s(62224),district:s(1193341205),shinden:s(359432),stadiumBravo:s(376421),muteCommTower:s(328922),doktorsLab:s(560244830)}),z=Object.freeze({[R.favela]:`Favela`,[R.fortress]:`Fortress`,[R.villa]:`Villa`,[R.neighborhood]:`Neighborhood`,[R.themePark]:`Theme Park`,[R.stadium]:`Stadium`,[R.outback]:`Outback`,[R.yacht]:`Yacht`,[R.emeraldPlains]:`Emerald Plains`,[R.chalet]:`Chalet`,[R.coastline]:`Coastline`,[R.bank]:`Bank`,[R.consulate]:`Consulate`,[R.tower]:`Tower`,[R.nighthavenLabs]:`Nighthaven Labs`,[R.presidentialPlane]:`Presidential Plane`,[R.house]:`House`,[R.kafeDostoyevsky]:`Kafe Dostoyevsky`,[R.border]:`Border`,[R.closeQuarter]:`Close Quarter`,[R.outback]:`Outback`,[R.lair]:`Lair`,[R.herefordBase]:`Hereford Base`,[R.skyscraper]:`Skyscraper`,[R.cqbBasics]:`CQB Basics`,[R.oregon]:`Oregon`,[R.outback]:`Outback`,318512:`Stadium`,[R.fortTruth]:`Fort Truth`,[R.kanal]:`Kanal`,[R.cqbBasics]:`CQB Basics`,[R.stadium2020]:`Stadium 2020`,[R.clubhouse]:`Clubhouse`,[R.district]:`District`,[R.shinden]:`Shinden`,[R.stadiumBravo]:`Stadium Bravo`,[R.muteCommTower]:`M.U.T.E Comm Tower`,[R.doktorsLab]:`Doktor's Lab`}),B=Object.freeze({notPlayed:c(0),inProgress:c(1),lost:c(2),enemiesEliminated:c(3),objectiveComplete:c(4),timeRanOut:c(5),enemiesSurrendered:c(6),unknownReason:c(7),matchCancelled:c(8)}),V=Object.freeze({[B.notPlayed]:`Not Played`,[B.inProgress]:`In Progress`,[B.lost]:`Lost`,[B.enemiesEliminated]:`Enemies Eliminated`,[B.objectiveComplete]:`Objective Complete`,[B.timeRanOut]:`Time ran out`,[B.enemiesSurrendered]:`Enemies Surrendered`,[B.unknownReason]:`Unknown Reason`,[B.matchCancelled]:`Match Cancelled`}),H=Object.freeze({day:g(177839),night:g(177840)}),U=Object.freeze({[H.day]:`Day`,[H.night]:`Night`}),W=()=>t({id:`number`,value:`string`}),G=t({kills:`number`,deaths:`number`,assists:`number`,game_mode_actions:`number`,score:`number`}),K=t({instigator_player_id:n(t.number),receiver_player_id:n(t.number),damage_amount:`number`,remaining_health:`number`,pre_damage_health:`number`,max_health:`number`,damage_type:D,damage_team_type:O,damage_hit_zone:k,damage_source_id:n(t.number).or(`null`),damage_item_id:n(t.number).or(`null`),damage_item_instance_id:n(t.number).or(`null`),damage_time:`number`}),q=t({index:`number`,rounds_until_next_segment:`number`,segment_size:`number`,segment_index:`number`,team_0:{role:S,state:n(t.number)},team_1:{role:S,state:n(t.number)}}),J=t({name:W(),time_of_day:W()}),Y=t({player_id:n(t.number),final_health:`number`,final_life_state:C,operator_name:W()}),X=t({round_data:q,damage_events:K.array(),players:Y.array()}),Z=t({game:`string`,type:`string`,creation_time:`number`}),ie=[B.enemiesEliminated,B.objectiveComplete,B.timeRanOut,B.enemiesSurrendered,B.unknownReason];function ae(e){return ie.includes(e)}const oe=[B.notPlayed,B.inProgress];function se(e){return!oe.includes(e)}const Q=Z.and({game:`'siege'`}),ce=Q.and({type:`'match_started'`,content:{game_mode:n(t.string),game_type:W(),match_type:n(t.string),match_id:n(t.string),map:J,is_round_based:`boolean`,current_round_index:`number`,rounds:q.array()}}),le=Q.and({type:`'started_queuing'`,content:{game_mode:n(t.string),game_type:W(),match_type:n(t.string)}}),ue=Q.and({type:`'stopped_queuing'`}),de=Q.and({type:`'match_ended'`}),fe=Q.and({type:`'map_changed'`,content:{map:J}}),pe=Q.and({type:`'operator_ban_voting_started'`,content:{team:b,index:`number`,side:S}}),me=Q.and({type:`'operator_banned'`,content:{team:b,index:`number`,side:S,operator_name:W().or(`null`)}}),he=Q.and({type:`'operator_ban_cleared'`,content:{team:b,index:`number`}}),ge=Q.and({type:`'round_ended'`,content:X}),_e=Q.and({type:`'phase_changed'`,content:{phase:v}}),ve=Q.and({type:`'player_joined'`,content:{player_id:n(t.number),username:`string`,pc_username:`string | null`,profile_id:n(t.string),is_bot:`boolean`,is_enemy:`boolean`,is_squad_member:`boolean`,is_local_player:`boolean`,side:S,team:b,platform:T,is_privacy_username:`boolean`,has_avatar_hidden:`boolean`,has_commend_streak:`boolean`,ping_id:`number`,match_stats:G,life_state:C,ping:`number`}}).pipe(e=>({...e,content:{...e.content,starting_side:e.content.side}})),ye=Q.and({type:`'player_left'`,content:{player_id:n(t.number)}}),be=Q.and({type:`'player_operator_changed'`,content:{player_id:n(t.number),operator_name:W()}}),xe=Q.and({type:`'player_location_changed'`,content:{player_id:n(t.number),location_name:`string`}}),Se=Q.and({type:`'player_side_changed'`,content:{player_id:n(t.number),side:S}}),Ce=Q.and({type:`'player_score_changed'`,content:{player_id:n(t.number),score:`number`}}),we=Q.and({type:`'player_kills_changed'`,content:{player_id:n(t.number),kills:`number`}}),Te=Q.and({type:`'player_deaths_changed'`,content:{player_id:n(t.number),deaths:`number`}}),$=Q.and({type:`'player_assists_changed'`,content:{player_id:n(t.number),assists:`number`}}),Ee=Q.and({type:`'player_game_mode_actions_changed'`,content:{player_id:n(t.number),game_mode_actions:`number`}}),De=Q.and({type:`'player_ping_updated'`,content:{player_id:n(t.number),ping:`number`}}),Oe=e({"#event1":`started_queuing | stopped_queuing | match_started | match_ended | map_changed | operator_ban_voting_started | operator_banned | operator_ban_cleared | round_ended | phase_changed | player_joined | player_left | player_operator_changed`,"#event2":`player_location_changed | player_side_changed | player_score_changed | player_kills_changed | player_deaths_changed | player_assists_changed | player_game_mode_actions_changed | player_life_state_changed | player_died | player_downed | player_ping_id_changed | player_team_changed | defuser_planted | defuser_sabotaged | defuser_picked_up | defuser_dropped | player_ping_updated`,event:`event1 | event2`,started_queuing:le,stopped_queuing:ue,match_started:ce,match_ended:de,map_changed:fe,operator_ban_voting_started:pe,operator_banned:me,operator_ban_cleared:he,round_ended:ge,phase_changed:_e,player_joined:ve,player_left:ye,player_operator_changed:be,player_location_changed:xe,player_side_changed:Se,player_score_changed:Ce,player_kills_changed:we,player_deaths_changed:Te,player_assists_changed:$,player_game_mode_actions_changed:Ee,defuser_planted:Q.and({type:`'defuser_planted'`,content:{player_id:n(t.number)}}),defuser_sabotaged:Q.and({type:`'defuser_sabotaged'`,content:{player_id:n(t.number)}}),defuser_picked_up:Q.and({type:`'defuser_picked_up'`,content:{player_id:n(t.number),initial:`boolean`}}),defuser_dropped:Q.and({type:`'defuser_dropped'`,content:{player_id:n(t.number)}}),player_ping_updated:De,player_life_state_changed:Q.and({type:`'player_life_state_changed'`,content:{player_id:n(t.number),life_state:C}}),player_died:Q.and({type:`'player_died'`,content:{player_id:n(t.number),instigator_player_id:n(t.number),headshot:`boolean`}}),player_downed:Q.and({type:`'player_downed'`,content:{player_id:n(t.number),instigator_player_id:n(t.number)}}),player_ping_id_changed:Q.and({type:`'player_ping_id_changed'`,content:{player_id:n(t.number),ping_id:`number`}}),player_team_changed:Q.and({type:`'player_team_changed'`,content:{player_id:n(t.number),team:b}})}).export();function ke(){return{key:`siege`,events:Oe}}export{Z as BaseEvent,_ as SIEGE_BOT_ID,re as SIEGE_DAMAGE_HIT_ZONES,ne as SIEGE_DAMAGE_TEAM_TYPES,E as SIEGE_DAMAGE_TYPES,A as SIEGE_GAME_MODES_TO_ID,j as SIEGE_GAME_MODE_LABELS,ee as SIEGE_GAME_MODE_PHASES,M as SIEGE_GAME_MODE_TYPES_TO_ID,N as SIEGE_GAME_MODE_TYPE_LABELS,z as SIEGE_MAP_LABELS,R as SIEGE_MAP_TO_ID,F as SIEGE_OPERATOR_LABELS,I as SIEGE_OPERATOR_META,P as SIEGE_OPERATOR_TO_ID,te as SIEGE_PLAYER_LIFE_STATES,w as SIEGE_PROFILE_PLATFORMS,B as SIEGE_ROUND_STATES_TO_ID,V as SIEGE_ROUND_STATE_LABELS,x as SIEGE_SIDES,L as SIEGE_SIDE_OPERATORS,y as SIEGE_TEAMS,U as SIEGE_TIME_OF_DAY_LABELS,H as SIEGE_TIME_OF_DAY_TO_ID,k as SiegeDamageHitZoneSchema,p as SiegeDamageSourceId,O as SiegeDamageTeamTypeSchema,D as SiegeDamageTypeSchema,h as SiegeGameMode,v as SiegeGameModePhaseSchema,a as SiegeGameModeTypeNameId,f as SiegeItemObjectId,s as SiegeMapNameId,l as SiegeMatchId,m as SiegeMatchType,o as SiegeOperatorNameId,u as SiegePlayerId,C as SiegePlayerLifeStateSchema,d as SiegeProfileId,T as SiegeProfilePlatformSchema,c as SiegeRoundState,S as SiegeSideSchema,b as SiegeTeamSchema,g as SiegeTimeOfDay,se as isSiegeRoundStateCompleted,ae as isSiegeRoundStateVictory,ke as module};
1
+ import{scope as e,type as t}from"arktype";function n(e){return e}function r(e){return e}function i(e){return e?t=>(e(t),t):r}const a=i(),o=i(),s=i(),c=i(),l=i(),u=i(),d=i(),f=i(),p=i(),m=i(),h=i(),g=i(),_=`00000000-0000-0000-0000-000000000000`,ee=[`intro`,`planning`,`prep`,`action`,`results`,`invalid`,`first`],v=t(`string`),y=[0,1],b=t(`===`,...y),x=[`attacker`,`defender`,`both`,`invalid`],S=t(`string`),te=[`normal`,`overhealed`,`low_health`,`downed`,`dead`,`respawning`],C=t(`string`),w=[`pc`,`xbox`,`playstation`,`invalid`],T=t(`string`),E=`bullet.melee.explosive.falling.regeneration.unknown.debris.projectile.downed.gas.thermal_explosion.melee_gadget.barbed_wire.electric.reinforcement.frag.paralyzed.emp.break.cleanup.interrogation.melee-finisher.toxic.toxic-explosion.pneumatic.body-contact.contact-explosion.flash.parasite-spike.laser.concussion.blowtorch.taser-shield.reverse-friendly-fire.self-destroyed.area-control.fire.breach-kick.break-wall.blade-mine.melee-pushback.supressive-fire.gas-pipe-fire.invalid`.split(`.`),D=t(`string`),ne=[`unknown`,`enemy`,`friendly`,`invalid`],O=t(`string`),re=[`invalid`,`head`,`left_upper_arm`,`right_upper_arm`,`left_forearm`,`right_forearm`,`left_hand`,`right_hand`,`upper_torso`,`lower_torso`,`crotch`,`left_thigh`,`right_thigh`,`left_calf`,`right_calf`,`left_foot`,`right_foot`,`neck`,`clothing`],k=t(`string`),A=Object.freeze({teamDeathmatch:h(`TEAM DEATHMATCH`),goldenGun:h(`GOLDEN GUN`),freeForAll:h(`FREE FOR ALL`),weaponRoulette:h(`WEAPON ROULETTE`),dualFront:h(`DUAL FRONT`),bomb:h(`BOMB`),versusAi:h(`VERSUS AI`),hostage:h(`HOSTAGE`),threeVsThreeSecureArea:h(`3 VS 3 SECURE AREA`),targetDrill:h(`TARGET DRILL`),rengoku:h(`RENGOKU`),hideAndSeek:h(`HIDE AND SEEK`)}),j=Object.freeze({[A.teamDeathmatch]:`Team Deathmatch`,[A.goldenGun]:`Golden Gun`,[A.freeForAll]:`Free For All`,[A.weaponRoulette]:`Weapon Roulette`,[A.dualFront]:`Dual Front`,[A.bomb]:`Bomb`,[A.versusAi]:`Versus AI`,[A.hostage]:`Hostage`,[A.threeVsThreeSecureArea]:`3v3 Secure Area`,[A.targetDrill]:`Target Drill`,[A.rengoku]:`Rengoku`,[A.hideAndSeek]:`Hide and Seek`}),M=Object.freeze({ranked:a(205379),quickMatch:a(138115),customGame:a(62008),versusAi:a(397300),standard:a(393930),arcade:a(320109),siegeCup:a(414089),dualFront:a(420611),showdown:a(305544),trainingGrounds:a(-1),unranked:a(310813),deathmatch:a(420611),rengoku:a(359430),muteProtocol:a(368421),fieldTraining:a(423927),hideAndSeek:a(310854)}),N=Object.freeze({[M.quickMatch]:`Quick Match`,[M.ranked]:`Ranked`,[M.customGame]:`Custom Game`,[M.versusAi]:`Versus AI`,[M.standard]:`Standard`,[M.arcade]:`Arcade`,[M.siegeCup]:`Siege Cup`,[M.dualFront]:`Dual Front`,[M.showdown]:`Showdown`,[M.trainingGrounds]:`Training Grounds`,[M.unranked]:`Unranked`,[M.deathmatch]:`Deathmatch`,[M.rengoku]:`Rengoku`,[M.muteProtocol]:`M.U.T.E Protocol`,[M.fieldTraining]:`Field Training`,[M.hideAndSeek]:`Hide and Seek`}),P=Object.freeze({glaz:o(62242),blitz:o(62243),buck:o(62244),sledge:o(62245),ash:o(62246),thermite:o(62247),castle:o(62248),rook:o(62249),pulse:o(62250),doc:o(62251),mute:o(62252),smoke:o(62253),recruit:o(62555),thatcher:o(65143),twitch:o(65156),montagne:o(65159),bandit:o(65165),fuze:o(65168),kapkan:o(65171),tachanka:o(65174),jager:o(113049),iq:o(113052),frost:o(186159),blackbeard:o(187249),valkyrie:o(187252),caveira:o(207671),capitao:o(207674),echo:o(209180),hibana:o(209183),mira:o(222172),jackal:o(222182),ying:o(239334),lesion:o(239337),ela:o(254595),zofia:o(254606),dokkaebi:o(273652),vigil:o(273663),finka:o(281457),lion:o(281463),alibi:o(282399),maestro:o(285888),maverick:o(288504),clash:o(288526),nomad:o(293435),kaid:o(293436),gridlock:o(298589),mozzie:o(298616),nokk:o(299657),warden:o(299668),goyo:o(304196),amaru:o(308469),kali:o(310757),wamai:o(310768),oryx:o(317965),iana:o(317976),melusi:o(320062),ace:o(320073),zero:o(328927),aruni:o(328940),flores:o(334086),thunderbird:o(336466),osa:o(344493),thorn:o(349405),azami:o(354314),sens:o(357386),grim:o(365404),solis:o(376836),brava:o(382419),fenrir:o(386388),ram:o(392904),tubarao:o(395594),deimos:o(400504),striker:o(404278),sentry:o(404290),skopos:o(408405),rauora:o(421052),denari:o(2437779699),solidSnake:o(3786633270)}),F=Object.freeze({[P.glaz]:`glaz`,[P.blitz]:`blitz`,[P.buck]:`buck`,[P.sledge]:`sledge`,[P.ash]:`ash`,[P.thermite]:`thermite`,[P.castle]:`castle`,[P.rook]:`rook`,[P.pulse]:`pulse`,[P.doc]:`doc`,[P.mute]:`mute`,[P.smoke]:`smoke`,[P.recruit]:`recruit`,[P.thatcher]:`thatcher`,[P.twitch]:`twitch`,[P.montagne]:`montagne`,[P.bandit]:`bandit`,[P.fuze]:`fuze`,[P.kapkan]:`kapkan`,[P.tachanka]:`tachanka`,[P.jager]:`jager`,[P.iq]:`iq`,[P.frost]:`frost`,[P.blackbeard]:`blackbeard`,[P.valkyrie]:`valkyrie`,[P.caveira]:`caveira`,[P.capitao]:`capitao`,[P.echo]:`echo`,[P.hibana]:`hibana`,[P.mira]:`mira`,[P.jackal]:`jackal`,[P.ying]:`ying`,[P.lesion]:`lesion`,[P.ela]:`ela`,[P.zofia]:`zofia`,[P.dokkaebi]:`dokkaebi`,[P.vigil]:`vigil`,[P.finka]:`finka`,[P.lion]:`lion`,[P.alibi]:`alibi`,[P.maestro]:`maestro`,[P.maverick]:`maverick`,[P.clash]:`clash`,[P.nomad]:`nomad`,[P.kaid]:`kaid`,[P.gridlock]:`gridlock`,[P.mozzie]:`mozzie`,[P.nokk]:`nokk`,[P.warden]:`warden`,[P.goyo]:`goyo`,[P.amaru]:`amaru`,[P.kali]:`kali`,[P.wamai]:`wamai`,[P.oryx]:`oryx`,[P.iana]:`iana`,[P.melusi]:`melusi`,[P.ace]:`ace`,[P.zero]:`zero`,[P.aruni]:`aruni`,[P.flores]:`flores`,[P.thunderbird]:`thunderbird`,[P.osa]:`osa`,[P.thorn]:`thorn`,[P.azami]:`azami`,[P.sens]:`sens`,[P.grim]:`grim`,[P.solis]:`solis`,[P.brava]:`brava`,[P.fenrir]:`fenrir`,[P.ram]:`ram`,[P.tubarao]:`tubarao`,[P.deimos]:`deimos`,[P.striker]:`striker`,[P.sentry]:`sentry`,[P.skopos]:`skopos`,[P.rauora]:`rauora`,[P.solidSnake]:`solid snake`,[P.denari]:`denari`}),I=Object.freeze({[P.striker]:{name:`Striker`,role:`attacker`},[P.sledge]:{name:`Sledge`,role:`attacker`},[P.thatcher]:{name:`Thatcher`,role:`attacker`},[P.ash]:{name:`Ash`,role:`attacker`},[P.thermite]:{name:`Thermite`,role:`attacker`},[P.twitch]:{name:`Twitch`,role:`attacker`},[P.montagne]:{name:`Montagne`,role:`attacker`},[P.glaz]:{name:`Glaz`,role:`attacker`},[P.fuze]:{name:`Fuze`,role:`attacker`},[P.blitz]:{name:`Blitz`,role:`attacker`},[P.iq]:{name:`IQ`,role:`attacker`},[P.buck]:{name:`Buck`,role:`attacker`},[P.blackbeard]:{name:`Blackbeard`,role:`attacker`},[P.capitao]:{name:`Capitão`,role:`attacker`},[P.hibana]:{name:`Hibana`,role:`attacker`},[P.jackal]:{name:`Jackal`,role:`attacker`},[P.ying]:{name:`Ying`,role:`attacker`},[P.zofia]:{name:`Zofia`,role:`attacker`},[P.dokkaebi]:{name:`Dokkaebi`,role:`attacker`},[P.lion]:{name:`Lion`,role:`attacker`},[P.finka]:{name:`Finka`,role:`attacker`},[P.maverick]:{name:`Maverick`,role:`attacker`},[P.nomad]:{name:`Nomad`,role:`attacker`},[P.gridlock]:{name:`Gridlock`,role:`attacker`},[P.nokk]:{name:`Nøkk`,role:`attacker`},[P.amaru]:{name:`Amaru`,role:`attacker`},[P.kali]:{name:`Kali`,role:`attacker`},[P.iana]:{name:`Iana`,role:`attacker`},[P.ace]:{name:`Ace`,role:`attacker`},[P.zero]:{name:`Zero`,role:`attacker`},[P.flores]:{name:`Flores`,role:`attacker`},[P.osa]:{name:`Osa`,role:`attacker`},[P.sens]:{name:`Sens`,role:`attacker`},[P.grim]:{name:`Grim`,role:`attacker`},[P.brava]:{name:`Brava`,role:`attacker`},[P.ram]:{name:`Ram`,role:`attacker`},[P.deimos]:{name:`Deimos`,role:`attacker`},[P.rauora]:{name:`Rauora`,role:`attacker`},[P.sentry]:{name:`Sentry`,role:`defender`},[P.smoke]:{name:`Smoke`,role:`defender`},[P.mute]:{name:`Mute`,role:`defender`},[P.castle]:{name:`Castle`,role:`defender`},[P.pulse]:{name:`Pulse`,role:`defender`},[P.doc]:{name:`Doc`,role:`defender`},[P.rook]:{name:`Rook`,role:`defender`},[P.kapkan]:{name:`Kapkan`,role:`defender`},[P.tachanka]:{name:`Tachanka`,role:`defender`},[P.jager]:{name:`Jäger`,role:`defender`},[P.bandit]:{name:`Bandit`,role:`defender`},[P.frost]:{name:`Frost`,role:`defender`},[P.valkyrie]:{name:`Valkyrie`,role:`defender`},[P.caveira]:{name:`Caveira`,role:`defender`},[P.echo]:{name:`Echo`,role:`defender`},[P.mira]:{name:`Mira`,role:`defender`},[P.lesion]:{name:`Lesion`,role:`defender`},[P.ela]:{name:`Ela`,role:`defender`},[P.vigil]:{name:`Vigil`,role:`defender`},[P.alibi]:{name:`Alibi`,role:`defender`},[P.maestro]:{name:`Maestro`,role:`defender`},[P.clash]:{name:`Clash`,role:`defender`},[P.kaid]:{name:`Kaid`,role:`defender`},[P.mozzie]:{name:`Mozzie`,role:`defender`},[P.warden]:{name:`Warden`,role:`defender`},[P.goyo]:{name:`Goyo`,role:`defender`},[P.wamai]:{name:`Wamai`,role:`defender`},[P.oryx]:{name:`Oryx`,role:`defender`},[P.melusi]:{name:`Melusi`,role:`defender`},[P.aruni]:{name:`Aruni`,role:`defender`},[P.thunderbird]:{name:`Thunderbird`,role:`defender`},[P.thorn]:{name:`Thorn`,role:`defender`},[P.azami]:{name:`Azami`,role:`defender`},[P.solis]:{name:`Solis`,role:`defender`},[P.fenrir]:{name:`Fenrir`,role:`defender`},[P.tubarao]:{name:`Tubarao`,role:`defender`},[P.skopos]:{name:`Skopós`,role:`defender`},[P.denari]:{name:`Denari`,role:`defender`},[P.solidSnake]:{name:`Solid Snake`,role:`attacker`}}),L=Object.freeze({attacker:Object.entries(I).filter(([e,t])=>t.role===`attacker`).map(([e])=>({...I[o(Number(e))],id:o(Number(e))})),defender:Object.entries(I).filter(([e,t])=>t.role===`defender`).map(([e])=>({...I[o(Number(e))],id:o(Number(e))}))}),R=Object.freeze({favela:s(202283),fortress:s(293334),villa:s(286407),neighborhood:s(333785),themePark:s(229325),stadium:s(338641),outback:s(299534),yacht:s(62226),emeraldPlains:s(358871),chalet:s(62230),coastline:s(217482),bank:s(62228),consulate:s(62227),tower:s(255669),nighthavenLabs:s(375492),presidentialPlane:s(62225),house:s(62221),kafeDostoyevsky:s(62232),border:s(201746),closeQuarter:s(365400),lair:s(396234),herefordBase:s(62223),skyscraper:s(208094),cqbBasics:s(196157),oregon:s(62222),fortTruth:s(307723),kanal:s(62229),stadium2020:s(357300),clubhouse:s(62224),district:s(1193341205),shinden:s(359432),stadiumBravo:s(376421),muteCommTower:s(328922),doktorsLab:s(560244830),calypsoCasino:s(1913017857)}),z=Object.freeze({[R.favela]:`Favela`,[R.fortress]:`Fortress`,[R.villa]:`Villa`,[R.neighborhood]:`Neighborhood`,[R.themePark]:`Theme Park`,[R.stadium]:`Stadium`,[R.outback]:`Outback`,[R.yacht]:`Yacht`,[R.emeraldPlains]:`Emerald Plains`,[R.chalet]:`Chalet`,[R.coastline]:`Coastline`,[R.bank]:`Bank`,[R.consulate]:`Consulate`,[R.tower]:`Tower`,[R.nighthavenLabs]:`Nighthaven Labs`,[R.presidentialPlane]:`Presidential Plane`,[R.house]:`House`,[R.kafeDostoyevsky]:`Kafe Dostoyevsky`,[R.border]:`Border`,[R.closeQuarter]:`Close Quarter`,[R.outback]:`Outback`,[R.lair]:`Lair`,[R.herefordBase]:`Hereford Base`,[R.skyscraper]:`Skyscraper`,[R.cqbBasics]:`CQB Basics`,[R.oregon]:`Oregon`,[R.outback]:`Outback`,318512:`Stadium`,[R.fortTruth]:`Fort Truth`,[R.kanal]:`Kanal`,[R.cqbBasics]:`CQB Basics`,[R.stadium2020]:`Stadium 2020`,[R.clubhouse]:`Clubhouse`,[R.district]:`District`,[R.shinden]:`Shinden`,[R.stadiumBravo]:`Stadium Bravo`,[R.muteCommTower]:`M.U.T.E Comm Tower`,[R.doktorsLab]:`Doktor's Lab`,[R.calypsoCasino]:`Calypso Casino`}),B=Object.freeze({notPlayed:c(0),inProgress:c(1),lost:c(2),enemiesEliminated:c(3),objectiveComplete:c(4),timeRanOut:c(5),enemiesSurrendered:c(6),unknownReason:c(7),matchCancelled:c(8)}),V=Object.freeze({[B.notPlayed]:`Not Played`,[B.inProgress]:`In Progress`,[B.lost]:`Lost`,[B.enemiesEliminated]:`Enemies Eliminated`,[B.objectiveComplete]:`Objective Complete`,[B.timeRanOut]:`Time ran out`,[B.enemiesSurrendered]:`Enemies Surrendered`,[B.unknownReason]:`Unknown Reason`,[B.matchCancelled]:`Match Cancelled`}),H=Object.freeze({day:g(177839),night:g(177840)}),U=Object.freeze({[H.day]:`Day`,[H.night]:`Night`}),W=()=>t({id:`number`,value:`string`}),G=t({kills:`number`,deaths:`number`,assists:`number`,game_mode_actions:`number`,score:`number`}),K=t({instigator_player_id:n(t.number),receiver_player_id:n(t.number),damage_amount:`number`,remaining_health:`number`,pre_damage_health:`number`,max_health:`number`,damage_type:D,damage_team_type:O,damage_hit_zone:k,damage_source_id:n(t.number).or(`null`),damage_item_id:n(t.number).or(`null`),damage_item_instance_id:n(t.number).or(`null`),damage_time:`number`}),q=t({index:`number`,rounds_until_next_segment:`number`,segment_size:`number`,segment_index:`number`,team_0:{role:S,state:n(t.number)},team_1:{role:S,state:n(t.number)}}),J=t({name:W(),time_of_day:W()}),Y=t({player_id:n(t.number),final_health:`number`,final_life_state:C,operator_name:W()}),X=t({round_data:q,damage_events:K.array(),players:Y.array()}),Z=t({game:`string`,type:`string`,creation_time:`number`}),ie=[B.enemiesEliminated,B.objectiveComplete,B.timeRanOut,B.enemiesSurrendered,B.unknownReason];function ae(e){return ie.includes(e)}const oe=[B.notPlayed,B.inProgress];function se(e){return!oe.includes(e)}const Q=Z.and({game:`'siege'`}),ce=Q.and({type:`'match_started'`,content:{game_mode:n(t.string),game_type:W(),match_type:n(t.string),match_id:n(t.string),map:J,is_round_based:`boolean`,current_round_index:`number`,rounds:q.array()}}),le=Q.and({type:`'started_queuing'`,content:{game_mode:n(t.string),game_type:W(),match_type:n(t.string)}}),ue=Q.and({type:`'stopped_queuing'`}),de=Q.and({type:`'match_ended'`}),fe=Q.and({type:`'map_changed'`,content:{map:J}}),pe=Q.and({type:`'operator_ban_voting_started'`,content:{team:b,index:`number`,side:S}}),me=Q.and({type:`'operator_banned'`,content:{team:b,index:`number`,side:S,operator_name:W().or(`null`)}}),he=Q.and({type:`'operator_ban_cleared'`,content:{team:b,index:`number`}}),ge=Q.and({type:`'round_ended'`,content:X}),_e=Q.and({type:`'phase_changed'`,content:{phase:v}}),ve=Q.and({type:`'player_joined'`,content:{player_id:n(t.number),username:`string`,pc_username:`string | null`,profile_id:n(t.string),is_bot:`boolean`,is_enemy:`boolean`,is_squad_member:`boolean`,is_local_player:`boolean`,side:S,team:b,platform:T,is_privacy_username:`boolean`,has_avatar_hidden:`boolean`,has_commend_streak:`boolean`,ping_id:`number`,match_stats:G,life_state:C,ping:`number`}}).pipe(e=>({...e,content:{...e.content,starting_side:e.content.side}})),ye=Q.and({type:`'player_left'`,content:{player_id:n(t.number)}}),be=Q.and({type:`'player_operator_changed'`,content:{player_id:n(t.number),operator_name:W()}}),xe=Q.and({type:`'player_location_changed'`,content:{player_id:n(t.number),location_name:`string`}}),Se=Q.and({type:`'player_side_changed'`,content:{player_id:n(t.number),side:S}}),Ce=Q.and({type:`'player_score_changed'`,content:{player_id:n(t.number),score:`number`}}),we=Q.and({type:`'player_kills_changed'`,content:{player_id:n(t.number),kills:`number`}}),Te=Q.and({type:`'player_deaths_changed'`,content:{player_id:n(t.number),deaths:`number`}}),$=Q.and({type:`'player_assists_changed'`,content:{player_id:n(t.number),assists:`number`}}),Ee=Q.and({type:`'player_game_mode_actions_changed'`,content:{player_id:n(t.number),game_mode_actions:`number`}}),De=Q.and({type:`'player_ping_updated'`,content:{player_id:n(t.number),ping:`number`}}),Oe=e({"#event1":`started_queuing | stopped_queuing | match_started | match_ended | map_changed | operator_ban_voting_started | operator_banned | operator_ban_cleared | round_ended | phase_changed | player_joined | player_left | player_operator_changed`,"#event2":`player_location_changed | player_side_changed | player_score_changed | player_kills_changed | player_deaths_changed | player_assists_changed | player_game_mode_actions_changed | player_life_state_changed | player_died | player_downed | player_ping_id_changed | player_team_changed | defuser_planted | defuser_sabotaged | defuser_picked_up | defuser_dropped | player_ping_updated`,event:`event1 | event2`,started_queuing:le,stopped_queuing:ue,match_started:ce,match_ended:de,map_changed:fe,operator_ban_voting_started:pe,operator_banned:me,operator_ban_cleared:he,round_ended:ge,phase_changed:_e,player_joined:ve,player_left:ye,player_operator_changed:be,player_location_changed:xe,player_side_changed:Se,player_score_changed:Ce,player_kills_changed:we,player_deaths_changed:Te,player_assists_changed:$,player_game_mode_actions_changed:Ee,defuser_planted:Q.and({type:`'defuser_planted'`,content:{player_id:n(t.number)}}),defuser_sabotaged:Q.and({type:`'defuser_sabotaged'`,content:{player_id:n(t.number)}}),defuser_picked_up:Q.and({type:`'defuser_picked_up'`,content:{player_id:n(t.number),initial:`boolean`}}),defuser_dropped:Q.and({type:`'defuser_dropped'`,content:{player_id:n(t.number)}}),player_ping_updated:De,player_life_state_changed:Q.and({type:`'player_life_state_changed'`,content:{player_id:n(t.number),life_state:C}}),player_died:Q.and({type:`'player_died'`,content:{player_id:n(t.number),instigator_player_id:n(t.number),headshot:`boolean`}}),player_downed:Q.and({type:`'player_downed'`,content:{player_id:n(t.number),instigator_player_id:n(t.number)}}),player_ping_id_changed:Q.and({type:`'player_ping_id_changed'`,content:{player_id:n(t.number),ping_id:`number`}}),player_team_changed:Q.and({type:`'player_team_changed'`,content:{player_id:n(t.number),team:b}})}).export();function ke(){return{key:`siege`,events:Oe}}export{Z as BaseEvent,_ as SIEGE_BOT_ID,re as SIEGE_DAMAGE_HIT_ZONES,ne as SIEGE_DAMAGE_TEAM_TYPES,E as SIEGE_DAMAGE_TYPES,A as SIEGE_GAME_MODES_TO_ID,j as SIEGE_GAME_MODE_LABELS,ee as SIEGE_GAME_MODE_PHASES,M as SIEGE_GAME_MODE_TYPES_TO_ID,N as SIEGE_GAME_MODE_TYPE_LABELS,z as SIEGE_MAP_LABELS,R as SIEGE_MAP_TO_ID,F as SIEGE_OPERATOR_LABELS,I as SIEGE_OPERATOR_META,P as SIEGE_OPERATOR_TO_ID,te as SIEGE_PLAYER_LIFE_STATES,w as SIEGE_PROFILE_PLATFORMS,B as SIEGE_ROUND_STATES_TO_ID,V as SIEGE_ROUND_STATE_LABELS,x as SIEGE_SIDES,L as SIEGE_SIDE_OPERATORS,y as SIEGE_TEAMS,U as SIEGE_TIME_OF_DAY_LABELS,H as SIEGE_TIME_OF_DAY_TO_ID,k as SiegeDamageHitZoneSchema,p as SiegeDamageSourceId,O as SiegeDamageTeamTypeSchema,D as SiegeDamageTypeSchema,h as SiegeGameMode,v as SiegeGameModePhaseSchema,a as SiegeGameModeTypeNameId,f as SiegeItemObjectId,s as SiegeMapNameId,l as SiegeMatchId,m as SiegeMatchType,o as SiegeOperatorNameId,u as SiegePlayerId,C as SiegePlayerLifeStateSchema,d as SiegeProfileId,T as SiegeProfilePlatformSchema,c as SiegeRoundState,S as SiegeSideSchema,b as SiegeTeamSchema,g as SiegeTimeOfDay,se as isSiegeRoundStateCompleted,ae as isSiegeRoundStateVictory,ke as module};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overlayed/app",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "Overlayed app",
5
5
  "keywords": [
6
6
  "typescript"