9remote 3.0.30 → 3.0.32

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.
Files changed (212) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.cjs +128 -108
  3. package/dist/ptyDaemon.cjs +7 -7
  4. package/dist/server.cjs +505 -216
  5. package/dist/ui/assets/index--4F7rf4t.js +8 -0
  6. package/dist/ui/index.html +1 -1
  7. package/dist/web/404.html +1 -1
  8. package/dist/web/__next.__PAGE__.txt +2 -2
  9. package/dist/web/__next._full.txt +20 -19
  10. package/dist/web/__next._head.txt +1 -1
  11. package/dist/web/__next._index.txt +7 -6
  12. package/dist/web/__next._tree.txt +2 -2
  13. package/dist/web/_next/static/chunks/{8669-9e059733295a6fc1.js → 1050-b9af41e8856b58c0.js} +1 -1
  14. package/dist/web/_next/static/chunks/4300-fb55814d743e1313.js +1 -0
  15. package/dist/web/_next/static/chunks/5788-d574869f0879e799.js +1 -0
  16. package/dist/web/_next/static/chunks/8669-8d1fb8dce08c886d.js +11 -0
  17. package/dist/web/_next/static/chunks/8762-62e9a4a001d3e204.js +1 -0
  18. package/dist/web/_next/static/chunks/app/download/page-2811ea822a1e586a.js +1 -0
  19. package/dist/web/_next/static/chunks/app/layout-444afebe5b95afff.js +1 -0
  20. package/dist/web/_next/static/chunks/app/login/{page-a2d6ff37be787acd.js → page-80cc1994a494dfed.js} +1 -1
  21. package/dist/web/_next/static/chunks/app/{page-bb1a7719eaabad49.js → page-f416e79015c32480.js} +3 -3
  22. package/dist/web/_next/static/chunks/app/workspace/layout-a1024034aa67994d.js +15 -0
  23. package/dist/web/_next/static/css/630ce3b502aeea55.css +1 -0
  24. package/dist/web/_not-found/__next._full.txt +18 -17
  25. package/dist/web/_not-found/__next._head.txt +1 -1
  26. package/dist/web/_not-found/__next._index.txt +7 -6
  27. package/dist/web/_not-found/__next._not-found.__PAGE__.txt +1 -1
  28. package/dist/web/_not-found/__next._not-found.txt +1 -1
  29. package/dist/web/_not-found/__next._tree.txt +2 -2
  30. package/dist/web/_not-found.html +1 -1
  31. package/dist/web/_not-found.txt +18 -17
  32. package/dist/web/admin/__next._full.txt +22 -21
  33. package/dist/web/admin/__next._head.txt +1 -1
  34. package/dist/web/admin/__next._index.txt +7 -6
  35. package/dist/web/admin/__next._tree.txt +2 -2
  36. package/dist/web/admin/__next.admin.__PAGE__.txt +1 -1
  37. package/dist/web/admin/__next.admin.txt +1 -1
  38. package/dist/web/admin/access/__next._full.txt +22 -21
  39. package/dist/web/admin/access/__next._head.txt +1 -1
  40. package/dist/web/admin/access/__next._index.txt +7 -6
  41. package/dist/web/admin/access/__next._tree.txt +2 -2
  42. package/dist/web/admin/access/__next.admin.access.__PAGE__.txt +1 -1
  43. package/dist/web/admin/access/__next.admin.access.txt +1 -1
  44. package/dist/web/admin/access/__next.admin.txt +1 -1
  45. package/dist/web/admin/access.html +1 -1
  46. package/dist/web/admin/access.txt +22 -21
  47. package/dist/web/admin/login/__next._full.txt +22 -21
  48. package/dist/web/admin/login/__next._head.txt +1 -1
  49. package/dist/web/admin/login/__next._index.txt +7 -6
  50. package/dist/web/admin/login/__next._tree.txt +2 -2
  51. package/dist/web/admin/login/__next.admin.login.__PAGE__.txt +1 -1
  52. package/dist/web/admin/login/__next.admin.login.txt +1 -1
  53. package/dist/web/admin/login/__next.admin.txt +1 -1
  54. package/dist/web/admin/login.html +1 -1
  55. package/dist/web/admin/login.txt +22 -21
  56. package/dist/web/admin/ota/__next._full.txt +22 -21
  57. package/dist/web/admin/ota/__next._head.txt +1 -1
  58. package/dist/web/admin/ota/__next._index.txt +7 -6
  59. package/dist/web/admin/ota/__next._tree.txt +2 -2
  60. package/dist/web/admin/ota/__next.admin.ota.__PAGE__.txt +1 -1
  61. package/dist/web/admin/ota/__next.admin.ota.txt +1 -1
  62. package/dist/web/admin/ota/__next.admin.txt +1 -1
  63. package/dist/web/admin/ota.html +1 -1
  64. package/dist/web/admin/ota.txt +22 -21
  65. package/dist/web/admin/turn/__next._full.txt +22 -21
  66. package/dist/web/admin/turn/__next._head.txt +1 -1
  67. package/dist/web/admin/turn/__next._index.txt +7 -6
  68. package/dist/web/admin/turn/__next._tree.txt +2 -2
  69. package/dist/web/admin/turn/__next.admin.turn.__PAGE__.txt +1 -1
  70. package/dist/web/admin/turn/__next.admin.turn.txt +1 -1
  71. package/dist/web/admin/turn/__next.admin.txt +1 -1
  72. package/dist/web/admin/turn.html +1 -1
  73. package/dist/web/admin/turn.txt +22 -21
  74. package/dist/web/admin.html +1 -1
  75. package/dist/web/admin.txt +22 -21
  76. package/dist/web/dev/question/__next._full.txt +22 -21
  77. package/dist/web/dev/question/__next._head.txt +1 -1
  78. package/dist/web/dev/question/__next._index.txt +7 -6
  79. package/dist/web/dev/question/__next._tree.txt +2 -2
  80. package/dist/web/dev/question/__next.dev.question.__PAGE__.txt +1 -1
  81. package/dist/web/dev/question/__next.dev.question.txt +1 -1
  82. package/dist/web/dev/question/__next.dev.txt +1 -1
  83. package/dist/web/dev/question.html +1 -1
  84. package/dist/web/dev/question.txt +22 -21
  85. package/dist/web/download/__next._full.txt +19 -18
  86. package/dist/web/download/__next._head.txt +1 -1
  87. package/dist/web/download/__next._index.txt +7 -6
  88. package/dist/web/download/__next._tree.txt +2 -2
  89. package/dist/web/download/__next.download.__PAGE__.txt +2 -2
  90. package/dist/web/download/__next.download.txt +1 -1
  91. package/dist/web/download.html +1 -1
  92. package/dist/web/download.txt +19 -18
  93. package/dist/web/index.html +1 -1
  94. package/dist/web/index.txt +20 -19
  95. package/dist/web/login/__next._full.txt +22 -21
  96. package/dist/web/login/__next._head.txt +1 -1
  97. package/dist/web/login/__next._index.txt +7 -6
  98. package/dist/web/login/__next._tree.txt +2 -2
  99. package/dist/web/login/__next.login.__PAGE__.txt +2 -2
  100. package/dist/web/login/__next.login.txt +1 -1
  101. package/dist/web/login.html +1 -1
  102. package/dist/web/login.txt +22 -21
  103. package/dist/web/workspace/__next._full.txt +19 -18
  104. package/dist/web/workspace/__next._head.txt +1 -1
  105. package/dist/web/workspace/__next._index.txt +7 -6
  106. package/dist/web/workspace/__next._tree.txt +2 -2
  107. package/dist/web/workspace/__next.workspace.__PAGE__.txt +1 -1
  108. package/dist/web/workspace/__next.workspace.txt +2 -2
  109. package/dist/web/workspace/browse/__next._full.txt +21 -20
  110. package/dist/web/workspace/browse/__next._head.txt +1 -1
  111. package/dist/web/workspace/browse/__next._index.txt +7 -6
  112. package/dist/web/workspace/browse/__next._tree.txt +2 -2
  113. package/dist/web/workspace/browse/__next.workspace.browse.__PAGE__.txt +1 -1
  114. package/dist/web/workspace/browse/__next.workspace.browse.txt +1 -1
  115. package/dist/web/workspace/browse/__next.workspace.txt +2 -2
  116. package/dist/web/workspace/browse.html +1 -1
  117. package/dist/web/workspace/browse.txt +21 -20
  118. package/dist/web/workspace/editor/__next._full.txt +21 -20
  119. package/dist/web/workspace/editor/__next._head.txt +1 -1
  120. package/dist/web/workspace/editor/__next._index.txt +7 -6
  121. package/dist/web/workspace/editor/__next._tree.txt +2 -2
  122. package/dist/web/workspace/editor/__next.workspace.editor.__PAGE__.txt +1 -1
  123. package/dist/web/workspace/editor/__next.workspace.editor.txt +1 -1
  124. package/dist/web/workspace/editor/__next.workspace.txt +2 -2
  125. package/dist/web/workspace/editor.html +1 -1
  126. package/dist/web/workspace/editor.txt +21 -20
  127. package/dist/web/workspace/files/__next._full.txt +21 -20
  128. package/dist/web/workspace/files/__next._head.txt +1 -1
  129. package/dist/web/workspace/files/__next._index.txt +7 -6
  130. package/dist/web/workspace/files/__next._tree.txt +2 -2
  131. package/dist/web/workspace/files/__next.workspace.files.__PAGE__.txt +1 -1
  132. package/dist/web/workspace/files/__next.workspace.files.txt +1 -1
  133. package/dist/web/workspace/files/__next.workspace.txt +2 -2
  134. package/dist/web/workspace/files.html +1 -1
  135. package/dist/web/workspace/files.txt +21 -20
  136. package/dist/web/workspace/git/__next._full.txt +21 -20
  137. package/dist/web/workspace/git/__next._head.txt +1 -1
  138. package/dist/web/workspace/git/__next._index.txt +7 -6
  139. package/dist/web/workspace/git/__next._tree.txt +2 -2
  140. package/dist/web/workspace/git/__next.workspace.git.__PAGE__.txt +1 -1
  141. package/dist/web/workspace/git/__next.workspace.git.txt +1 -1
  142. package/dist/web/workspace/git/__next.workspace.txt +2 -2
  143. package/dist/web/workspace/git.html +1 -1
  144. package/dist/web/workspace/git.txt +21 -20
  145. package/dist/web/workspace/mobile/__next._full.txt +21 -20
  146. package/dist/web/workspace/mobile/__next._head.txt +1 -1
  147. package/dist/web/workspace/mobile/__next._index.txt +7 -6
  148. package/dist/web/workspace/mobile/__next._tree.txt +2 -2
  149. package/dist/web/workspace/mobile/__next.workspace.mobile.__PAGE__.txt +1 -1
  150. package/dist/web/workspace/mobile/__next.workspace.mobile.txt +1 -1
  151. package/dist/web/workspace/mobile/__next.workspace.txt +2 -2
  152. package/dist/web/workspace/mobile.html +1 -1
  153. package/dist/web/workspace/mobile.txt +21 -20
  154. package/dist/web/workspace/pair/__next._full.txt +21 -20
  155. package/dist/web/workspace/pair/__next._head.txt +1 -1
  156. package/dist/web/workspace/pair/__next._index.txt +7 -6
  157. package/dist/web/workspace/pair/__next._tree.txt +2 -2
  158. package/dist/web/workspace/pair/__next.workspace.pair.__PAGE__.txt +1 -1
  159. package/dist/web/workspace/pair/__next.workspace.pair.txt +1 -1
  160. package/dist/web/workspace/pair/__next.workspace.txt +2 -2
  161. package/dist/web/workspace/pair.html +1 -1
  162. package/dist/web/workspace/pair.txt +21 -20
  163. package/dist/web/workspace/remote/__next._full.txt +21 -20
  164. package/dist/web/workspace/remote/__next._head.txt +1 -1
  165. package/dist/web/workspace/remote/__next._index.txt +7 -6
  166. package/dist/web/workspace/remote/__next._tree.txt +2 -2
  167. package/dist/web/workspace/remote/__next.workspace.remote.__PAGE__.txt +1 -1
  168. package/dist/web/workspace/remote/__next.workspace.remote.txt +1 -1
  169. package/dist/web/workspace/remote/__next.workspace.txt +2 -2
  170. package/dist/web/workspace/remote.html +1 -1
  171. package/dist/web/workspace/remote.txt +21 -20
  172. package/dist/web/workspace/terminal/default/__next._full.txt +23 -22
  173. package/dist/web/workspace/terminal/default/__next._head.txt +1 -1
  174. package/dist/web/workspace/terminal/default/__next._index.txt +7 -6
  175. package/dist/web/workspace/terminal/default/__next._tree.txt +2 -2
  176. package/dist/web/workspace/terminal/default/__next.workspace.terminal.$d$sessionId.__PAGE__.txt +1 -1
  177. package/dist/web/workspace/terminal/default/__next.workspace.terminal.$d$sessionId.txt +1 -1
  178. package/dist/web/workspace/terminal/default/__next.workspace.terminal.txt +1 -1
  179. package/dist/web/workspace/terminal/default/__next.workspace.txt +2 -2
  180. package/dist/web/workspace/terminal/default.html +1 -1
  181. package/dist/web/workspace/terminal/default.txt +23 -22
  182. package/dist/web/workspace/welcome/__next._full.txt +21 -20
  183. package/dist/web/workspace/welcome/__next._head.txt +1 -1
  184. package/dist/web/workspace/welcome/__next._index.txt +7 -6
  185. package/dist/web/workspace/welcome/__next._tree.txt +2 -2
  186. package/dist/web/workspace/welcome/__next.workspace.txt +2 -2
  187. package/dist/web/workspace/welcome/__next.workspace.welcome.__PAGE__.txt +1 -1
  188. package/dist/web/workspace/welcome/__next.workspace.welcome.txt +1 -1
  189. package/dist/web/workspace/welcome.html +1 -1
  190. package/dist/web/workspace/welcome.txt +21 -20
  191. package/dist/web/workspace/workspaces/__next._full.txt +21 -20
  192. package/dist/web/workspace/workspaces/__next._head.txt +1 -1
  193. package/dist/web/workspace/workspaces/__next._index.txt +7 -6
  194. package/dist/web/workspace/workspaces/__next._tree.txt +2 -2
  195. package/dist/web/workspace/workspaces/__next.workspace.txt +2 -2
  196. package/dist/web/workspace/workspaces/__next.workspace.workspaces.__PAGE__.txt +1 -1
  197. package/dist/web/workspace/workspaces/__next.workspace.workspaces.txt +1 -1
  198. package/dist/web/workspace/workspaces.html +1 -1
  199. package/dist/web/workspace/workspaces.txt +21 -20
  200. package/dist/web/workspace.html +1 -1
  201. package/dist/web/workspace.txt +19 -18
  202. package/package.json +2 -2
  203. package/dist/ui/assets/index-efgSOMyZ.js +0 -8
  204. package/dist/web/_next/static/chunks/2097-4937b5f90f482cf8.js +0 -1
  205. package/dist/web/_next/static/chunks/4732-76a574510722b2c3.js +0 -11
  206. package/dist/web/_next/static/chunks/5788-a6716c825d4a7fc3.js +0 -1
  207. package/dist/web/_next/static/chunks/app/download/page-33ffe95ce3abb566.js +0 -1
  208. package/dist/web/_next/static/chunks/app/layout-ec53a1a0c4b3e99e.js +0 -1
  209. package/dist/web/_next/static/chunks/app/workspace/layout-0753f643f5ed4893.js +0 -15
  210. package/dist/web/_next/static/css/7e8c7b663586bab9.css +0 -1
  211. /package/dist/web/_next/static/{NEXFR4gbx_Fw8QgP6HAJw → nx78GyCTuW2V1ns5cZIT_}/_buildManifest.js +0 -0
  212. /package/dist/web/_next/static/{NEXFR4gbx_Fw8QgP6HAJw → nx78GyCTuW2V1ns5cZIT_}/_ssgManifest.js +0 -0
package/dist/cli.cjs CHANGED
@@ -1,54 +1,54 @@
1
1
  #!/usr/bin/env node
2
2
  const __importMetaUrl = require('url').pathToFileURL(__filename).href;
3
- var qa=Object.create;var Yr=Object.defineProperty;var Qa=Object.getOwnPropertyDescriptor;var Ja=Object.getOwnPropertyNames;var Za=Object.getPrototypeOf,za=Object.prototype.hasOwnProperty;var ec=(e,t)=>()=>(e&&(t=e(e=0)),t);var ge=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),tc=(e,t)=>{for(var r in t)Yr(e,r,{get:t[r],enumerable:!0})},nc=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ja(t))!za.call(e,n)&&n!==r&&Yr(e,n,{get:()=>t[n],enumerable:!(o=Qa(t,n))||o.enumerable});return e};var R=(e,t,r)=>(r=e!=null?qa(Za(e)):{},nc(t||!e||!e.__esModule?Yr(r,"default",{value:e,enumerable:!0}):r,e));var ci=ge((Ln,Qr)=>{(function(e,t){typeof Ln=="object"&&typeof Qr=="object"?Qr.exports=t(require("child_process"),require("crypto")):typeof define=="function"&&define.amd?define(["child_process","crypto"],t):typeof Ln=="object"?Ln["electron-machine-id"]=t(require("child_process"),require("crypto")):e["electron-machine-id"]=t(e.child_process,e.crypto)})(Ln,function(e,t){return(function(r){function o(i){if(n[i])return n[i].exports;var s=n[i]={exports:{},id:i,loaded:!1};return r[i].call(s.exports,s,s.exports,o),s.loaded=!0,s.exports}var n={};return o.m=r,o.c=n,o.p="",o(0)})([function(r,o,n){r.exports=n(34)},function(r,o,n){var i=n(29)("wks"),s=n(33),a=n(2).Symbol,c=typeof a=="function",l=r.exports=function(u){return i[u]||(i[u]=c&&a[u]||(c?a:s)("Symbol."+u))};l.store=i},function(r,o){var n=r.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=n)},function(r,o,n){var i=n(9);r.exports=function(s){if(!i(s))throw TypeError(s+" is not an object!");return s}},function(r,o,n){r.exports=!n(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(r,o,n){var i=n(12),s=n(17);r.exports=n(4)?function(a,c,l){return i.f(a,c,s(1,l))}:function(a,c,l){return a[c]=l,a}},function(r,o){var n=r.exports={version:"2.4.0"};typeof __e=="number"&&(__e=n)},function(r,o,n){var i=n(14);r.exports=function(s,a,c){if(i(s),a===void 0)return s;switch(c){case 1:return function(l){return s.call(a,l)};case 2:return function(l,u){return s.call(a,l,u)};case 3:return function(l,u,f){return s.call(a,l,u,f)}}return function(){return s.apply(a,arguments)}}},function(r,o){var n={}.hasOwnProperty;r.exports=function(i,s){return n.call(i,s)}},function(r,o){r.exports=function(n){return typeof n=="object"?n!==null:typeof n=="function"}},function(r,o){r.exports={}},function(r,o){var n={}.toString;r.exports=function(i){return n.call(i).slice(8,-1)}},function(r,o,n){var i=n(3),s=n(26),a=n(32),c=Object.defineProperty;o.f=n(4)?Object.defineProperty:function(l,u,f){if(i(l),u=a(u,!0),i(f),s)try{return c(l,u,f)}catch{}if("get"in f||"set"in f)throw TypeError("Accessors not supported!");return"value"in f&&(l[u]=f.value),l}},function(r,o,n){var i=n(42),s=n(15);r.exports=function(a){return i(s(a))}},function(r,o){r.exports=function(n){if(typeof n!="function")throw TypeError(n+" is not a function!");return n}},function(r,o){r.exports=function(n){if(n==null)throw TypeError("Can't call method on "+n);return n}},function(r,o,n){var i=n(9),s=n(2).document,a=i(s)&&i(s.createElement);r.exports=function(c){return a?s.createElement(c):{}}},function(r,o){r.exports=function(n,i){return{enumerable:!(1&n),configurable:!(2&n),writable:!(4&n),value:i}}},function(r,o,n){var i=n(12).f,s=n(8),a=n(1)("toStringTag");r.exports=function(c,l,u){c&&!s(c=u?c:c.prototype,a)&&i(c,a,{configurable:!0,value:l})}},function(r,o,n){var i=n(29)("keys"),s=n(33);r.exports=function(a){return i[a]||(i[a]=s(a))}},function(r,o){var n=Math.ceil,i=Math.floor;r.exports=function(s){return isNaN(s=+s)?0:(s>0?i:n)(s)}},function(r,o,n){var i=n(11),s=n(1)("toStringTag"),a=i((function(){return arguments})())=="Arguments",c=function(l,u){try{return l[u]}catch{}};r.exports=function(l){var u,f,p;return l===void 0?"Undefined":l===null?"Null":typeof(f=c(u=Object(l),s))=="string"?f:a?i(u):(p=i(u))=="Object"&&typeof u.callee=="function"?"Arguments":p}},function(r,o){r.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(r,o,n){var i=n(2),s=n(6),a=n(7),c=n(5),l="prototype",u=function(f,p,d){var h,w,E,O=f&u.F,T=f&u.G,A=f&u.S,k=f&u.P,C=f&u.B,g=f&u.W,b=T?s:s[p]||(s[p]={}),_=b[l],$=T?i:A?i[p]:(i[p]||{})[l];T&&(d=p);for(h in d)w=!O&&$&&$[h]!==void 0,w&&h in b||(E=w?$[h]:d[h],b[h]=T&&typeof $[h]!="function"?d[h]:C&&w?a(E,i):g&&$[h]==E?(function(X){var ae=function(Ee,ce,Be){if(this instanceof X){switch(arguments.length){case 0:return new X;case 1:return new X(Ee);case 2:return new X(Ee,ce)}return new X(Ee,ce,Be)}return X.apply(this,arguments)};return ae[l]=X[l],ae})(E):k&&typeof E=="function"?a(Function.call,E):E,k&&((b.virtual||(b.virtual={}))[h]=E,f&u.R&&_&&!_[h]&&c(_,h,E)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,r.exports=u},function(r,o){r.exports=function(n){try{return!!n()}catch{return!0}}},function(r,o,n){r.exports=n(2).document&&document.documentElement},function(r,o,n){r.exports=!n(4)&&!n(24)(function(){return Object.defineProperty(n(16)("div"),"a",{get:function(){return 7}}).a!=7})},function(r,o,n){"use strict";var i=n(28),s=n(23),a=n(57),c=n(5),l=n(8),u=n(10),f=n(45),p=n(18),d=n(52),h=n(1)("iterator"),w=!([].keys&&"next"in[].keys()),E="@@iterator",O="keys",T="values",A=function(){return this};r.exports=function(k,C,g,b,_,$,X){f(g,C,b);var ae,Ee,ce,Be=function(v){if(!w&&v in le)return le[v];switch(v){case O:return function(){return new g(this,v)};case T:return function(){return new g(this,v)}}return function(){return new g(this,v)}},Kt=C+" Iterator",vt=_==T,An=!1,le=k.prototype,tt=le[h]||le[E]||_&&le[_],pe=tt||Be(_),xn=_?vt?Be("entries"):pe:void 0,y=C=="Array"&&le.entries||tt;if(y&&(ce=d(y.call(new k)),ce!==Object.prototype&&(p(ce,Kt,!0),i||l(ce,h)||c(ce,h,A))),vt&&tt&&tt.name!==T&&(An=!0,pe=function(){return tt.call(this)}),i&&!X||!w&&!An&&le[h]||c(le,h,pe),u[C]=pe,u[Kt]=A,_)if(ae={values:vt?pe:Be(T),keys:$?pe:Be(O),entries:xn},X)for(Ee in ae)Ee in le||a(le,Ee,ae[Ee]);else s(s.P+s.F*(w||An),C,ae);return ae}},function(r,o){r.exports=!0},function(r,o,n){var i=n(2),s="__core-js_shared__",a=i[s]||(i[s]={});r.exports=function(c){return a[c]||(a[c]={})}},function(r,o,n){var i,s,a,c=n(7),l=n(41),u=n(25),f=n(16),p=n(2),d=p.process,h=p.setImmediate,w=p.clearImmediate,E=p.MessageChannel,O=0,T={},A="onreadystatechange",k=function(){var g=+this;if(T.hasOwnProperty(g)){var b=T[g];delete T[g],b()}},C=function(g){k.call(g.data)};h&&w||(h=function(g){for(var b=[],_=1;arguments.length>_;)b.push(arguments[_++]);return T[++O]=function(){l(typeof g=="function"?g:Function(g),b)},i(O),O},w=function(g){delete T[g]},n(11)(d)=="process"?i=function(g){d.nextTick(c(k,g,1))}:E?(s=new E,a=s.port2,s.port1.onmessage=C,i=c(a.postMessage,a,1)):p.addEventListener&&typeof postMessage=="function"&&!p.importScripts?(i=function(g){p.postMessage(g+"","*")},p.addEventListener("message",C,!1)):i=A in f("script")?function(g){u.appendChild(f("script"))[A]=function(){u.removeChild(this),k.call(g)}}:function(g){setTimeout(c(k,g,1),0)}),r.exports={set:h,clear:w}},function(r,o,n){var i=n(20),s=Math.min;r.exports=function(a){return a>0?s(i(a),9007199254740991):0}},function(r,o,n){var i=n(9);r.exports=function(s,a){if(!i(s))return s;var c,l;if(a&&typeof(c=s.toString)=="function"&&!i(l=c.call(s))||typeof(c=s.valueOf)=="function"&&!i(l=c.call(s))||!a&&typeof(c=s.toString)=="function"&&!i(l=c.call(s)))return l;throw TypeError("Can't convert object to primitive value")}},function(r,o){var n=0,i=Math.random();r.exports=function(s){return"Symbol(".concat(s===void 0?"":s,")_",(++n+i).toString(36))}},function(r,o,n){"use strict";function i(A){return A&&A.__esModule?A:{default:A}}function s(){return process.platform!=="win32"?"":process.arch==="ia32"&&process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")?"mixed":"native"}function a(A){return(0,h.createHash)("sha256").update(A).digest("hex")}function c(A){switch(E){case"darwin":return A.split("IOPlatformUUID")[1].split(`
4
- `)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return A.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return A.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return A.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function l(A){var k=c((0,d.execSync)(T[E]).toString());return A?k:a(k)}function u(A){return new p.default(function(k,C){return(0,d.exec)(T[E],{},function(g,b,_){if(g)return C(new Error("Error while obtaining machine id: "+g.stack));var $=c(b.toString());return k(A?$:a($))})})}Object.defineProperty(o,"__esModule",{value:!0});var f=n(35),p=i(f);o.machineIdSync=l,o.machineId=u;var d=n(70),h=n(71),w=process,E=w.platform,O={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},T={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:O[s()]+"\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid",linux:"( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :",freebsd:"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid"}},function(r,o,n){r.exports={default:n(36),__esModule:!0}},function(r,o,n){n(66),n(68),n(69),n(67),r.exports=n(6).Promise},function(r,o){r.exports=function(){}},function(r,o){r.exports=function(n,i,s,a){if(!(n instanceof i)||a!==void 0&&a in n)throw TypeError(s+": incorrect invocation!");return n}},function(r,o,n){var i=n(13),s=n(31),a=n(62);r.exports=function(c){return function(l,u,f){var p,d=i(l),h=s(d.length),w=a(f,h);if(c&&u!=u){for(;h>w;)if(p=d[w++],p!=p)return!0}else for(;h>w;w++)if((c||w in d)&&d[w]===u)return c||w||0;return!c&&-1}}},function(r,d,n){var i=n(7),s=n(44),a=n(43),c=n(3),l=n(31),u=n(64),f={},p={},d=r.exports=function(h,w,E,O,T){var A,k,C,g,b=T?function(){return h}:u(h),_=i(E,O,w?2:1),$=0;if(typeof b!="function")throw TypeError(h+" is not iterable!");if(a(b)){for(A=l(h.length);A>$;$++)if(g=w?_(c(k=h[$])[0],k[1]):_(h[$]),g===f||g===p)return g}else for(C=b.call(h);!(k=C.next()).done;)if(g=s(C,_,k.value,w),g===f||g===p)return g};d.BREAK=f,d.RETURN=p},function(r,o){r.exports=function(n,i,s){var a=s===void 0;switch(i.length){case 0:return a?n():n.call(s);case 1:return a?n(i[0]):n.call(s,i[0]);case 2:return a?n(i[0],i[1]):n.call(s,i[0],i[1]);case 3:return a?n(i[0],i[1],i[2]):n.call(s,i[0],i[1],i[2]);case 4:return a?n(i[0],i[1],i[2],i[3]):n.call(s,i[0],i[1],i[2],i[3])}return n.apply(s,i)}},function(r,o,n){var i=n(11);r.exports=Object("z").propertyIsEnumerable(0)?Object:function(s){return i(s)=="String"?s.split(""):Object(s)}},function(r,o,n){var i=n(10),s=n(1)("iterator"),a=Array.prototype;r.exports=function(c){return c!==void 0&&(i.Array===c||a[s]===c)}},function(r,o,n){var i=n(3);r.exports=function(s,a,c,l){try{return l?a(i(c)[0],c[1]):a(c)}catch(f){var u=s.return;throw u!==void 0&&i(u.call(s)),f}}},function(r,o,n){"use strict";var i=n(49),s=n(17),a=n(18),c={};n(5)(c,n(1)("iterator"),function(){return this}),r.exports=function(l,u,f){l.prototype=i(c,{next:s(1,f)}),a(l,u+" Iterator")}},function(r,o,n){var i=n(1)("iterator"),s=!1;try{var a=[7][i]();a.return=function(){s=!0},Array.from(a,function(){throw 2})}catch{}r.exports=function(c,l){if(!l&&!s)return!1;var u=!1;try{var f=[7],p=f[i]();p.next=function(){return{done:u=!0}},f[i]=function(){return p},c(f)}catch{}return u}},function(r,o){r.exports=function(n,i){return{value:i,done:!!n}}},function(r,o,n){var i=n(2),s=n(30).set,a=i.MutationObserver||i.WebKitMutationObserver,c=i.process,l=i.Promise,u=n(11)(c)=="process";r.exports=function(){var f,p,d,h=function(){var T,A;for(u&&(T=c.domain)&&T.exit();f;){A=f.fn,f=f.next;try{A()}catch(k){throw f?d():p=void 0,k}}p=void 0,T&&T.enter()};if(u)d=function(){c.nextTick(h)};else if(a){var w=!0,E=document.createTextNode("");new a(h).observe(E,{characterData:!0}),d=function(){E.data=w=!w}}else if(l&&l.resolve){var O=l.resolve();d=function(){O.then(h)}}else d=function(){s.call(i,h)};return function(T){var A={fn:T,next:void 0};p&&(p.next=A),f||(f=A,d()),p=A}}},function(r,o,n){var i=n(3),s=n(50),a=n(22),c=n(19)("IE_PROTO"),l=function(){},u="prototype",f=function(){var p,d=n(16)("iframe"),h=a.length,w=">";for(d.style.display="none",n(25).appendChild(d),d.src="javascript:",p=d.contentWindow.document,p.open(),p.write("<script>document.F=Object</script"+w),p.close(),f=p.F;h--;)delete f[u][a[h]];return f()};r.exports=Object.create||function(p,d){var h;return p!==null?(l[u]=i(p),h=new l,l[u]=null,h[c]=p):h=f(),d===void 0?h:s(h,d)}},function(r,o,n){var i=n(12),s=n(3),a=n(54);r.exports=n(4)?Object.defineProperties:function(c,l){s(c);for(var u,f=a(l),p=f.length,d=0;p>d;)i.f(c,u=f[d++],l[u]);return c}},function(r,o,n){var i=n(55),s=n(17),a=n(13),c=n(32),l=n(8),u=n(26),f=Object.getOwnPropertyDescriptor;o.f=n(4)?f:function(p,d){if(p=a(p),d=c(d,!0),u)try{return f(p,d)}catch{}if(l(p,d))return s(!i.f.call(p,d),p[d])}},function(r,o,n){var i=n(8),s=n(63),a=n(19)("IE_PROTO"),c=Object.prototype;r.exports=Object.getPrototypeOf||function(l){return l=s(l),i(l,a)?l[a]:typeof l.constructor=="function"&&l instanceof l.constructor?l.constructor.prototype:l instanceof Object?c:null}},function(r,o,n){var i=n(8),s=n(13),a=n(39)(!1),c=n(19)("IE_PROTO");r.exports=function(l,u){var f,p=s(l),d=0,h=[];for(f in p)f!=c&&i(p,f)&&h.push(f);for(;u.length>d;)i(p,f=u[d++])&&(~a(h,f)||h.push(f));return h}},function(r,o,n){var i=n(53),s=n(22);r.exports=Object.keys||function(a){return i(a,s)}},function(r,o){o.f={}.propertyIsEnumerable},function(r,o,n){var i=n(5);r.exports=function(s,a,c){for(var l in a)c&&s[l]?s[l]=a[l]:i(s,l,a[l]);return s}},function(r,o,n){r.exports=n(5)},function(r,o,n){var i=n(9),s=n(3),a=function(c,l){if(s(c),!i(l)&&l!==null)throw TypeError(l+": can't set as prototype!")};r.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(c,l,u){try{u=n(7)(Function.call,n(51).f(Object.prototype,"__proto__").set,2),u(c,[]),l=!(c instanceof Array)}catch{l=!0}return function(f,p){return a(f,p),l?f.__proto__=p:u(f,p),f}})({},!1):void 0),check:a}},function(r,o,n){"use strict";var i=n(2),s=n(6),a=n(12),c=n(4),l=n(1)("species");r.exports=function(u){var f=typeof s[u]=="function"?s[u]:i[u];c&&f&&!f[l]&&a.f(f,l,{configurable:!0,get:function(){return this}})}},function(r,o,n){var i=n(3),s=n(14),a=n(1)("species");r.exports=function(c,l){var u,f=i(c).constructor;return f===void 0||(u=i(f)[a])==null?l:s(u)}},function(r,o,n){var i=n(20),s=n(15);r.exports=function(a){return function(c,l){var u,f,p=String(s(c)),d=i(l),h=p.length;return d<0||d>=h?a?"":void 0:(u=p.charCodeAt(d),u<55296||u>56319||d+1===h||(f=p.charCodeAt(d+1))<56320||f>57343?a?p.charAt(d):u:a?p.slice(d,d+2):(u-55296<<10)+(f-56320)+65536)}}},function(r,o,n){var i=n(20),s=Math.max,a=Math.min;r.exports=function(c,l){return c=i(c),c<0?s(c+l,0):a(c,l)}},function(r,o,n){var i=n(15);r.exports=function(s){return Object(i(s))}},function(r,o,n){var i=n(21),s=n(1)("iterator"),a=n(10);r.exports=n(6).getIteratorMethod=function(c){if(c!=null)return c[s]||c["@@iterator"]||a[i(c)]}},function(r,o,n){"use strict";var i=n(37),s=n(47),a=n(10),c=n(13);r.exports=n(27)(Array,"Array",function(l,u){this._t=c(l),this._i=0,this._k=u},function(){var l=this._t,u=this._k,f=this._i++;return!l||f>=l.length?(this._t=void 0,s(1)):u=="keys"?s(0,f):u=="values"?s(0,l[f]):s(0,[f,l[f]])},"values"),a.Arguments=a.Array,i("keys"),i("values"),i("entries")},function(r,o){},function(r,o,n){"use strict";var i,s,a,c=n(28),l=n(2),u=n(7),f=n(21),p=n(23),d=n(9),h=(n(3),n(14)),w=n(38),E=n(40),O=(n(58).set,n(60)),T=n(30).set,A=n(48)(),k="Promise",C=l.TypeError,b=l.process,g=l[k],b=l.process,_=f(b)=="process",$=function(){},X=!!(function(){try{var y=g.resolve(1),v=(y.constructor={})[n(1)("species")]=function(x){x($,$)};return(_||typeof PromiseRejectionEvent=="function")&&y.then($)instanceof v}catch{}})(),ae=function(y,v){return y===v||y===g&&v===a},Ee=function(y){var v;return!(!d(y)||typeof(v=y.then)!="function")&&v},ce=function(y){return ae(g,y)?new Be(y):new s(y)},Be=s=function(y){var v,x;this.promise=new y(function(D,te){if(v!==void 0||x!==void 0)throw C("Bad Promise constructor");v=D,x=te}),this.resolve=h(v),this.reject=h(x)},Kt=function(y){try{y()}catch(v){return{error:v}}},vt=function(y,v){if(!y._n){y._n=!0;var x=y._c;A(function(){for(var D=y._v,te=y._s==1,Et=0,Ht=function(nt){var ke,lr,Rn=te?nt.ok:nt.fail,kn=nt.resolve,Wt=nt.reject,ur=nt.domain;try{Rn?(te||(y._h==2&&tt(y),y._h=1),Rn===!0?ke=D:(ur&&ur.enter(),ke=Rn(D),ur&&ur.exit()),ke===nt.promise?Wt(C("Promise-chain cycle")):(lr=Ee(ke))?lr.call(ke,kn,Wt):kn(ke)):Wt(D)}catch(Xa){Wt(Xa)}};x.length>Et;)Ht(x[Et++]);y._c=[],y._n=!1,v&&!y._h&&An(y)})}},An=function(y){T.call(l,function(){var v,x,D,te=y._v;if(le(y)&&(v=Kt(function(){_?b.emit("unhandledRejection",te,y):(x=l.onunhandledrejection)?x({promise:y,reason:te}):(D=l.console)&&D.error&&D.error("Unhandled promise rejection",te)}),y._h=_||le(y)?2:1),y._a=void 0,v)throw v.error})},le=function(y){if(y._h==1)return!1;for(var v,x=y._a||y._c,D=0;x.length>D;)if(v=x[D++],v.fail||!le(v.promise))return!1;return!0},tt=function(y){T.call(l,function(){var v;_?b.emit("rejectionHandled",y):(v=l.onrejectionhandled)&&v({promise:y,reason:y._v})})},pe=function(y){var v=this;v._d||(v._d=!0,v=v._w||v,v._v=y,v._s=2,v._a||(v._a=v._c.slice()),vt(v,!0))},xn=function(y){var v,x=this;if(!x._d){x._d=!0,x=x._w||x;try{if(x===y)throw C("Promise can't be resolved itself");(v=Ee(y))?A(function(){var D={_w:x,_d:!1};try{v.call(y,u(xn,D,1),u(pe,D,1))}catch(te){pe.call(D,te)}}):(x._v=y,x._s=1,vt(x,!1))}catch(D){pe.call({_w:x,_d:!1},D)}}};X||(g=function(y){w(this,g,k,"_h"),h(y),i.call(this);try{y(u(xn,this,1),u(pe,this,1))}catch(v){pe.call(this,v)}},i=function(y){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},i.prototype=n(56)(g.prototype,{then:function(y,v){var x=ce(O(this,g));return x.ok=typeof y!="function"||y,x.fail=typeof v=="function"&&v,x.domain=_?b.domain:void 0,this._c.push(x),this._a&&this._a.push(x),this._s&&vt(this,!1),x.promise},catch:function(y){return this.then(void 0,y)}}),Be=function(){var y=new i;this.promise=y,this.resolve=u(xn,y,1),this.reject=u(pe,y,1)}),p(p.G+p.W+p.F*!X,{Promise:g}),n(18)(g,k),n(59)(k),a=n(6)[k],p(p.S+p.F*!X,k,{reject:function(y){var v=ce(this),x=v.reject;return x(y),v.promise}}),p(p.S+p.F*(c||!X),k,{resolve:function(y){if(y instanceof g&&ae(y.constructor,this))return y;var v=ce(this),x=v.resolve;return x(y),v.promise}}),p(p.S+p.F*!(X&&n(46)(function(y){g.all(y).catch($)})),k,{all:function(y){var v=this,x=ce(v),D=x.resolve,te=x.reject,Et=Kt(function(){var Ht=[],nt=0,ke=1;E(y,!1,function(lr){var Rn=nt++,kn=!1;Ht.push(void 0),ke++,v.resolve(lr).then(function(Wt){kn||(kn=!0,Ht[Rn]=Wt,--ke||D(Ht))},te)}),--ke||D(Ht)});return Et&&te(Et.error),x.promise},race:function(y){var v=this,x=ce(v),D=x.reject,te=Kt(function(){E(y,!1,function(Et){v.resolve(Et).then(x.resolve,D)})});return te&&D(te.error),x.promise}})},function(r,o,n){"use strict";var i=n(61)(!0);n(27)(String,"String",function(s){this._t=String(s),this._i=0},function(){var s,a=this._t,c=this._i;return c>=a.length?{value:void 0,done:!0}:(s=i(a,c),this._i+=s.length,{value:s,done:!1})})},function(r,o,n){n(65);for(var i=n(2),s=n(5),a=n(10),c=n(1)("toStringTag"),l=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var f=l[u],p=i[f],d=p&&p.prototype;d&&!d[c]&&s(d,c,f),a[f]=a.Array}},function(r,o){r.exports=require("child_process")},function(r,o){r.exports=require("crypto")}])})});var ra={};tc(ra,{initTray:()=>or,killTray:()=>Mt,openBrowser:()=>Ct,showTrayNotification:()=>$o,updateTrayTooltip:()=>wn});function qs(e){for(let t of e)try{if(gn.default.existsSync(t))return t}catch{}return null}function Hl(){if(process.platform==="win32"){for(let e of ea)try{if(gn.default.existsSync(e))return gn.default.readFileSync(e).toString("base64")}catch{}return Xs}return Xs}function Wl(){if(process.env.NREMOTE_DESKTOP)return!1;let e=process.platform;return!(!["darwin","win32","linux"].includes(e)||e==="linux"&&!process.env.DISPLAY)}function ta(){let{port:e,tunnelUrl:t,running:r}=yn,o=r?t?"Tunnel ON":"Local only":"Idle",n=`http://localhost:${e}`;return`9Remote \u2022 ${o}
5
- Local: ${n}
6
- Right-click to open / quit`}function na(){let{port:e,tunnelUrl:t}=yn,r=process.platform==="win32",o=t?`9Remote (Port ${e}) \u2022 Tunnel ON`:`9Remote (Port ${e}) \u2022 Local only`;return{icon:Hl(),title:r?`9Remote - Port ${e}`:"",tooltip:ta(),items:[{title:o,tooltip:t||`http://localhost:${e}`,checked:!1,enabled:!1},{title:"Open Web UI",tooltip:`Open http://localhost:${e} in your browser`,checked:!1,enabled:!0},{title:"Shutdown",tooltip:"Stop 9Remote server, tunnel and quit",checked:!1,enabled:!0}]}}function jl(){try{let e=require($e.default.join(zs,"systray2"));return e.default?.default||e.default||e}catch{return null}}function Gl({port:e,onQuit:t,onOpenUI:r}){let o=qs(ea),n=qs(Kl);if(!o||!n)return null;let i;try{i=(0,qe.spawn)("powershell.exe",["-NoProfile","-ExecutionPolicy","Bypass","-WindowStyle","Hidden","-InputFormat","Text","-OutputFormat","Text","-File",n,"-IconPath",o,"-Tooltip",`9Remote - Port ${e}`],{windowsHide:!0,stdio:["pipe","pipe","pipe"]})}catch{return null}let s=c=>{try{i.stdin.writable&&i.stdin.write(`${JSON.stringify(c)}
7
- `,"utf8")}catch{}};return Qs.default.createInterface({input:i.stdout}).on("line",c=>{try{let l=JSON.parse(c);if(l.type!=="click")return;l.index===0?r?.():l.index===1&&(t?.(),Mt(),setTimeout(()=>process.exit(0),500))}catch{}}),i.on("error",()=>{}),i.stderr.on("data",()=>{}),["Open Web UI","Shutdown"].forEach((c,l)=>s({action:"add-item",index:l,title:c,enabled:!0})),{_isWin:!0,_setTooltip(c){s({action:"set-tooltip",text:c})},sendAction(){},kill(){try{s({action:"kill"})}catch{}setTimeout(()=>{try{i&&!i.killed&&i.kill()}catch{}},300)}}}async function or({port:e,onQuit:t,onOpenUI:r}){if(!Wl())return null;if(process.platform==="win32")return yn={port:e,tunnelUrl:"",running:!0},oe=Gl({port:e,onQuit:t,onOpenUI:r}),oe;try{let o=jl();if(!o)return null;let i={darwin:"tray_darwin_release",win32:"tray_windows_release.exe",linux:"tray_linux_release"}[process.platform];if(!i)return null;let s=$e.default.join(zs,"systray2","traybin",i);if(!gn.default.existsSync(s))return null;if(process.platform!=="win32")try{gn.default.chmodSync(s,493)}catch{}if(yn={port:e,tunnelUrl:"",running:!0},oe=new o({menu:na(),debug:!1,copyDir:!0}),oe.onClick(a=>{let c=a.item?.title||a.item;c==="Open Web UI"?r?.():c==="Shutdown"&&(t?.(),Mt(),setTimeout(()=>process.exit(0),500))}),typeof oe.ready=="function")try{await oe.ready()}catch{return oe=null,null}else oe.onReady(()=>{}),oe.onError(()=>{});return oe}catch{return null}}function wn({tunnelUrl:e,running:t}={}){if(e!==void 0&&(yn.tunnelUrl=e),t!==void 0&&(yn.running=t),!!oe){if(oe._isWin){oe._setTooltip?.(ta());return}try{oe.sendAction({type:"update-menu",menu:na(),seq_id:-1})?.catch?.(()=>{})}catch{}}}function Mt(){let e=oe;if(oe=null,e)try{e.kill(!0)}catch{}}function $o({title:e="9Remote",message:t}){let r=process.platform;if(t){if(r==="win32"){let o=c=>String(c).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;"),n=c=>String(c).replace(/'/g,"''"),i="9Remote",s=`<toast><visual><binding template="ToastText02"><text id="1">${o(e)}</text><text id="2">${o(t)}</text></binding></visual></toast>`,a=["try {","[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType=WindowsRuntime] > $null;","[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType=WindowsRuntime] > $null;","$xml = New-Object Windows.Data.Xml.Dom.XmlDocument;",`$xml.LoadXml('${n(s)}');`,"$toast = [Windows.UI.Notifications.ToastNotification]::new($xml);",`[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('${n(i)}').Show($toast);`,"} catch {","Add-Type -AssemblyName System.Windows.Forms;","$n = New-Object System.Windows.Forms.NotifyIcon;","$n.Icon = [System.Drawing.SystemIcons]::Information;",`$n.BalloonTipTitle = '${n(e)}';`,`$n.BalloonTipText = '${n(t)}';`,"$n.Visible = $true;","$n.ShowBalloonTip(5000);","Start-Sleep -Seconds 6;","$n.Dispose();","}"].join(" ");try{(0,qe.spawn)("powershell.exe",["-NoProfile","-WindowStyle","Hidden","-Command",a],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(r==="darwin"){try{let o=s=>String(s).replace(/"/g,'\\"'),n=`display notification "${o(t)}" with title "${o(e)}"`;(0,qe.spawn)("osascript",["-e",n],{detached:!0,stdio:"ignore"}).unref()}catch{}return}try{(0,qe.spawn)("notify-send",[e,t],{detached:!0,stdio:"ignore"}).unref()}catch{}}}function Ct(e){let t=process.platform;if(t==="win32"){try{(0,qe.spawn)("rundll32.exe",["url.dll,FileProtocolHandler",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref();return}catch{}try{(0,qe.spawn)("cmd.exe",["/d","/s","/c","start","",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(t==="darwin"){try{(0,qe.spawn)("open",[e],{detached:!0,stdio:"ignore"}).unref()}catch{}return}let r=[["setsid",["--fork","xdg-open",e]],["setsid",["xdg-open",e]],["xdg-open",[e]],["gio",["open",e]],["sensible-browser",[e]],["x-www-browser",[e]]];for(let[o,n]of r)try{(0,qe.spawn)(o,n,{detached:!0,stdio:"ignore",env:{...process.env}}).unref();return}catch{}}var qe,Qs,gn,$e,Js,Zs,zs,oe,yn,Br,Xs,ea,Kl,$t=ec(()=>{qe=require("child_process"),Qs=R(require("readline"),1),gn=R(require("fs"),1),$e=R(require("path"),1),Js=R(require("os"),1),Zs=require("url"),zs=(0,$e.join)(Js.default.homedir(),".9remote","runtime","node_modules"),oe=null,yn={port:0,tunnelUrl:"",running:!1},Br=$e.default.dirname((0,Zs.fileURLToPath)(__importMetaUrl)),Xs="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",ea=[$e.default.join(Br,"assets","trayIcon.ico"),$e.default.join(Br,"..","assets","trayIcon.ico")],Kl=[$e.default.join(Br,"assets","tray.ps1"),$e.default.join(Br,"..","assets","tray.ps1")]});var Ho=ge((Np,fa)=>{fa.exports={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}});var ma=ge((Dp,da)=>{var ql=Ho();function pa(e){this.mode=ql.MODE_8BIT_BYTE,this.data=e}pa.prototype={getLength:function(){return this.data.length},write:function(e){for(var t=0;t<this.data.length;t++)e.put(this.data.charCodeAt(t),8)}};da.exports=pa});var Wo=ge((Bp,ha)=>{var Re={glog:function(e){if(e<1)throw new Error("glog("+e+")");return Re.LOG_TABLE[e]},gexp:function(e){for(;e<0;)e+=255;for(;e>=256;)e-=255;return Re.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(G=0;G<8;G++)Re.EXP_TABLE[G]=1<<G;var G;for(G=8;G<256;G++)Re.EXP_TABLE[G]=Re.EXP_TABLE[G-4]^Re.EXP_TABLE[G-5]^Re.EXP_TABLE[G-6]^Re.EXP_TABLE[G-8];var G;for(G=0;G<255;G++)Re.LOG_TABLE[Re.EXP_TABLE[G]]=G;var G;ha.exports=Re});var jo=ge((Up,ga)=>{var Ut=Wo();function Hr(e,t){if(e.length===void 0)throw new Error(e.length+"/"+t);for(var r=0;r<e.length&&e[r]===0;)r++;this.num=new Array(e.length-r+t);for(var o=0;o<e.length-r;o++)this.num[o]=e[o+r]}Hr.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var t=new Array(this.getLength()+e.getLength()-1),r=0;r<this.getLength();r++)for(var o=0;o<e.getLength();o++)t[r+o]^=Ut.gexp(Ut.glog(this.get(r))+Ut.glog(e.get(o)));return new Hr(t,0)},mod:function(e){if(this.getLength()-e.getLength()<0)return this;for(var t=Ut.glog(this.get(0))-Ut.glog(e.get(0)),r=new Array(this.getLength()),o=0;o<this.getLength();o++)r[o]=this.get(o);for(var n=0;n<e.getLength();n++)r[n]^=Ut.gexp(Ut.glog(e.get(n))+t);return new Hr(r,0).mod(e)}};ga.exports=Hr});var wa=ge((Fp,ya)=>{ya.exports={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7}});var Sa=ge((Kp,Ea)=>{var ve=Ho(),va=jo(),Ql=Wo(),gt=wa(),ee={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(e){for(var t=e<<10;ee.getBCHDigit(t)-ee.getBCHDigit(ee.G15)>=0;)t^=ee.G15<<ee.getBCHDigit(t)-ee.getBCHDigit(ee.G15);return(e<<10|t)^ee.G15_MASK},getBCHTypeNumber:function(e){for(var t=e<<12;ee.getBCHDigit(t)-ee.getBCHDigit(ee.G18)>=0;)t^=ee.G18<<ee.getBCHDigit(t)-ee.getBCHDigit(ee.G18);return e<<12|t},getBCHDigit:function(e){for(var t=0;e!==0;)t++,e>>>=1;return t},getPatternPosition:function(e){return ee.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,t,r){switch(e){case gt.PATTERN000:return(t+r)%2===0;case gt.PATTERN001:return t%2===0;case gt.PATTERN010:return r%3===0;case gt.PATTERN011:return(t+r)%3===0;case gt.PATTERN100:return(Math.floor(t/2)+Math.floor(r/3))%2===0;case gt.PATTERN101:return t*r%2+t*r%3===0;case gt.PATTERN110:return(t*r%2+t*r%3)%2===0;case gt.PATTERN111:return(t*r%3+(t+r)%2)%2===0;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var t=new va([1],0),r=0;r<e;r++)t=t.multiply(new va([1,Ql.gexp(r)],0));return t},getLengthInBits:function(e,t){if(1<=t&&t<10)switch(e){case ve.MODE_NUMBER:return 10;case ve.MODE_ALPHA_NUM:return 9;case ve.MODE_8BIT_BYTE:return 8;case ve.MODE_KANJI:return 8;default:throw new Error("mode:"+e)}else if(t<27)switch(e){case ve.MODE_NUMBER:return 12;case ve.MODE_ALPHA_NUM:return 11;case ve.MODE_8BIT_BYTE:return 16;case ve.MODE_KANJI:return 10;default:throw new Error("mode:"+e)}else if(t<41)switch(e){case ve.MODE_NUMBER:return 14;case ve.MODE_ALPHA_NUM:return 13;case ve.MODE_8BIT_BYTE:return 16;case ve.MODE_KANJI:return 12;default:throw new Error("mode:"+e)}else throw new Error("type:"+t)},getLostPoint:function(e){var t=e.getModuleCount(),r=0,o=0,n=0;for(o=0;o<t;o++)for(n=0;n<t;n++){for(var i=0,s=e.isDark(o,n),a=-1;a<=1;a++)if(!(o+a<0||t<=o+a))for(var c=-1;c<=1;c++)n+c<0||t<=n+c||a===0&&c===0||s===e.isDark(o+a,n+c)&&i++;i>5&&(r+=3+i-5)}for(o=0;o<t-1;o++)for(n=0;n<t-1;n++){var l=0;e.isDark(o,n)&&l++,e.isDark(o+1,n)&&l++,e.isDark(o,n+1)&&l++,e.isDark(o+1,n+1)&&l++,(l===0||l===4)&&(r+=3)}for(o=0;o<t;o++)for(n=0;n<t-6;n++)e.isDark(o,n)&&!e.isDark(o,n+1)&&e.isDark(o,n+2)&&e.isDark(o,n+3)&&e.isDark(o,n+4)&&!e.isDark(o,n+5)&&e.isDark(o,n+6)&&(r+=40);for(n=0;n<t;n++)for(o=0;o<t-6;o++)e.isDark(o,n)&&!e.isDark(o+1,n)&&e.isDark(o+2,n)&&e.isDark(o+3,n)&&e.isDark(o+4,n)&&!e.isDark(o+5,n)&&e.isDark(o+6,n)&&(r+=40);var u=0;for(n=0;n<t;n++)for(o=0;o<t;o++)e.isDark(o,n)&&u++;var f=Math.abs(100*u/t/t-50)/5;return r+=f*10,r}};Ea.exports=ee});var Go=ge((Hp,Ta)=>{Ta.exports={L:1,M:0,Q:3,H:2}});var Aa=ge((Wp,ba)=>{var Wr=Go();function Ne(e,t){this.totalCount=e,this.dataCount=t}Ne.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];Ne.getRSBlocks=function(e,t){var r=Ne.getRsBlockTable(e,t);if(r===void 0)throw new Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+t);for(var o=r.length/3,n=[],i=0;i<o;i++)for(var s=r[i*3+0],a=r[i*3+1],c=r[i*3+2],l=0;l<s;l++)n.push(new Ne(a,c));return n};Ne.getRsBlockTable=function(e,t){switch(t){case Wr.L:return Ne.RS_BLOCK_TABLE[(e-1)*4+0];case Wr.M:return Ne.RS_BLOCK_TABLE[(e-1)*4+1];case Wr.Q:return Ne.RS_BLOCK_TABLE[(e-1)*4+2];case Wr.H:return Ne.RS_BLOCK_TABLE[(e-1)*4+3];default:return}};ba.exports=Ne});var ka=ge((jp,Ra)=>{function xa(){this.buffer=[],this.length=0}xa.prototype={get:function(e){var t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(var r=0;r<t;r++)this.putBit((e>>>t-r-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};Ra.exports=xa});var La=ge((Gp,Ia)=>{var Jl=ma(),yt=Sa(),Zl=jo(),Pa=Aa(),Oa=ka();function De(e,t){this.typeNumber=e,this.errorCorrectLevel=t,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}De.prototype={addData:function(e){var t=new Jl(e);this.dataList.push(t),this.dataCache=null},isDark:function(e,t){if(e<0||this.moduleCount<=e||t<0||this.moduleCount<=t)throw new Error(e+","+t);return this.modules[e][t]},getModuleCount:function(){return this.moduleCount},make:function(){if(this.typeNumber<1){var e=1;for(e=1;e<40;e++){for(var t=Pa.getRSBlocks(e,this.errorCorrectLevel),r=new Oa,o=0,n=0;n<t.length;n++)o+=t[n].dataCount;for(var i=0;i<this.dataList.length;i++){var s=this.dataList[i];r.put(s.mode,4),r.put(s.getLength(),yt.getLengthInBits(s.mode,e)),s.write(r)}if(r.getLengthInBits()<=o*8)break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,t){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var r=0;r<this.moduleCount;r++){this.modules[r]=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++)this.modules[r][o]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(e,t),this.typeNumber>=7&&this.setupTypeNumber(e),this.dataCache===null&&(this.dataCache=De.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(e,t){for(var r=-1;r<=7;r++)if(!(e+r<=-1||this.moduleCount<=e+r))for(var o=-1;o<=7;o++)t+o<=-1||this.moduleCount<=t+o||(0<=r&&r<=6&&(o===0||o===6)||0<=o&&o<=6&&(r===0||r===6)||2<=r&&r<=4&&2<=o&&o<=4?this.modules[e+r][t+o]=!0:this.modules[e+r][t+o]=!1)},getBestMaskPattern:function(){for(var e=0,t=0,r=0;r<8;r++){this.makeImpl(!0,r);var o=yt.getLostPoint(this);(r===0||e>o)&&(e=o,t=r)}return t},createMovieClip:function(e,t,r){var o=e.createEmptyMovieClip(t,r),n=1;this.make();for(var i=0;i<this.modules.length;i++)for(var s=i*n,a=0;a<this.modules[i].length;a++){var c=a*n,l=this.modules[i][a];l&&(o.beginFill(0,100),o.moveTo(c,s),o.lineTo(c+n,s),o.lineTo(c+n,s+n),o.lineTo(c,s+n),o.endFill())}return o},setupTimingPattern:function(){for(var e=8;e<this.moduleCount-8;e++)this.modules[e][6]===null&&(this.modules[e][6]=e%2===0);for(var t=8;t<this.moduleCount-8;t++)this.modules[6][t]===null&&(this.modules[6][t]=t%2===0)},setupPositionAdjustPattern:function(){for(var e=yt.getPatternPosition(this.typeNumber),t=0;t<e.length;t++)for(var r=0;r<e.length;r++){var o=e[t],n=e[r];if(this.modules[o][n]===null)for(var i=-2;i<=2;i++)for(var s=-2;s<=2;s++)Math.abs(i)===2||Math.abs(s)===2||i===0&&s===0?this.modules[o+i][n+s]=!0:this.modules[o+i][n+s]=!1}},setupTypeNumber:function(e){for(var t=yt.getBCHTypeNumber(this.typeNumber),r,o=0;o<18;o++)r=!e&&(t>>o&1)===1,this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3]=r;for(var n=0;n<18;n++)r=!e&&(t>>n&1)===1,this.modules[n%3+this.moduleCount-8-3][Math.floor(n/3)]=r},setupTypeInfo:function(e,t){for(var r=this.errorCorrectLevel<<3|t,o=yt.getBCHTypeInfo(r),n,i=0;i<15;i++)n=!e&&(o>>i&1)===1,i<6?this.modules[i][8]=n:i<8?this.modules[i+1][8]=n:this.modules[this.moduleCount-15+i][8]=n;for(var s=0;s<15;s++)n=!e&&(o>>s&1)===1,s<8?this.modules[8][this.moduleCount-s-1]=n:s<9?this.modules[8][15-s-1+1]=n:this.modules[8][15-s-1]=n;this.modules[this.moduleCount-8][8]=!e},mapData:function(e,t){for(var r=-1,o=this.moduleCount-1,n=7,i=0,s=this.moduleCount-1;s>0;s-=2)for(s===6&&s--;;){for(var a=0;a<2;a++)if(this.modules[o][s-a]===null){var c=!1;i<e.length&&(c=(e[i]>>>n&1)===1);var l=yt.getMask(t,o,s-a);l&&(c=!c),this.modules[o][s-a]=c,n--,n===-1&&(i++,n=7)}if(o+=r,o<0||this.moduleCount<=o){o-=r,r=-r;break}}}};De.PAD0=236;De.PAD1=17;De.createData=function(e,t,r){for(var o=Pa.getRSBlocks(e,t),n=new Oa,i=0;i<r.length;i++){var s=r[i];n.put(s.mode,4),n.put(s.getLength(),yt.getLengthInBits(s.mode,e)),s.write(n)}for(var a=0,c=0;c<o.length;c++)a+=o[c].dataCount;if(n.getLengthInBits()>a*8)throw new Error("code length overflow. ("+n.getLengthInBits()+">"+a*8+")");for(n.getLengthInBits()+4<=a*8&&n.put(0,4);n.getLengthInBits()%8!==0;)n.putBit(!1);for(;!(n.getLengthInBits()>=a*8||(n.put(De.PAD0,8),n.getLengthInBits()>=a*8));)n.put(De.PAD1,8);return De.createBytes(n,o)};De.createBytes=function(e,t){for(var r=0,o=0,n=0,i=new Array(t.length),s=new Array(t.length),a=0;a<t.length;a++){var c=t[a].dataCount,l=t[a].totalCount-c;o=Math.max(o,c),n=Math.max(n,l),i[a]=new Array(c);for(var u=0;u<i[a].length;u++)i[a][u]=255&e.buffer[u+r];r+=c;var f=yt.getErrorCorrectPolynomial(l),p=new Zl(i[a],f.getLength()-1),d=p.mod(f);s[a]=new Array(f.getLength()-1);for(var h=0;h<s[a].length;h++){var w=h+d.getLength()-s[a].length;s[a][h]=w>=0?d.get(w):0}}for(var E=0,O=0;O<t.length;O++)E+=t[O].totalCount;for(var T=new Array(E),A=0,k=0;k<o;k++)for(var C=0;C<t.length;C++)k<i[C].length&&(T[A++]=i[C][k]);for(var g=0;g<n;g++)for(var b=0;b<t.length;b++)g<s[b].length&&(T[A++]=s[b][g]);return T};Ia.exports=De});var Ca=ge((Vp,Ma)=>{var zl=La(),_a=Go(),eu="\x1B[40m \x1B[0m",jr="\x1B[47m \x1B[0m",tu=function(e){return e?eu:jr},Vo=function(e){return{times:function(t){return new Array(t).join(e)}}},nu=function(e,t){for(var r=new Array(e),o=0;o<e;o++)r[o]=t;return r};Ma.exports={error:_a.L,generate:function(e,t,r){typeof t=="function"&&(r=t,t={});var o=new zl(-1,this.error);o.addData(e),o.make();var n="";if(t&&t.small){var i=!0,s=!1,a=o.getModuleCount(),c=o.modules.slice(),l=a%2===1;l&&c.push(nu(a,s));var u={WHITE_ALL:"\u2588",WHITE_BLACK:"\u2580",BLACK_WHITE:"\u2584",BLACK_ALL:" "},f=Vo(u.BLACK_WHITE).times(a+3),p=Vo(u.WHITE_BLACK).times(a+3);n+=f+`
8
- `;for(var d=0;d<a;d+=2){n+=u.WHITE_ALL;for(var h=0;h<a;h++)c[d][h]===s&&c[d+1][h]===s?n+=u.WHITE_ALL:c[d][h]===s&&c[d+1][h]===i?n+=u.WHITE_BLACK:c[d][h]===i&&c[d+1][h]===s?n+=u.BLACK_WHITE:n+=u.BLACK_ALL;n+=u.WHITE_ALL+`
9
- `}l||(n+=p)}else{var w=Vo(jr).times(o.getModuleCount()+3);n+=w+`
10
- `,o.modules.forEach(function(E){n+=jr,n+=E.map(tu).join(""),n+=jr+`
11
- `}),n+=w}r?r(n):console.log(n)},setErrorLevel:function(e){this.error=_a[e]||this.error}}});var pr=require("fs"),In=require("path"),si=require("url"),ai=R(require("os"),1);var fr=R(require("dns"),1),Se=R(require("path"),1),zo=R(require("os"),1),ie="9remote",qr=process.env.NREMOTE_REGISTRY||`https://registry.npmjs.org/${ie}/latest`,Ue=`${ie}@latest`,Pe=process.env.NREMOTE_HOME||Se.default.join(zo.default.homedir(),".9remote"),V={ROOT:Pe,LOGS:Se.default.join(Pe,"logs"),STATE:Se.default.join(Pe,"state"),CONFIG:Se.default.join(Pe,"config"),BIN:Se.default.join(Pe,"bin"),PIDS:Se.default.join(Pe,"pids"),BUFFERS:Se.default.join(Pe,"buffers"),DAEMON:Se.default.join(Pe,"daemon"),AI_SESSIONS:Se.default.join(Pe,"ai-sessions"),BACKGROUNDS:Se.default.join(Pe,"backgrounds")},Pn=new fr.default.promises.Resolver;Pn.setServers(["1.1.1.1","1.0.0.1","8.8.8.8"]);var Xr=fr.default.lookup,rc=/^(\d{1,3}\.){3}\d{1,3}$|^::1$|^[0-9a-f:]+$/i;fr.default.lookup=(e,t,r)=>{if(typeof t=="function"&&(r=t,t={}),e==="localhost"||rc.test(e))return Xr(e,t,r);(async()=>{if(t.family===6)return{addrs:await Pn.resolve6(e),family:6};if(t.family===4)return{addrs:await Pn.resolve4(e),family:4};let[n,i]=await Promise.allSettled([Pn.resolve4(e),Pn.resolve6(e)]);return n.status==="fulfilled"&&n.value?.length?{addrs:n.value,family:4}:i.status==="fulfilled"&&i.value?.length?{addrs:i.value,family:6}:null})().then(n=>{if(!n?.addrs?.length)return Xr(e,t,r);t.all?r(null,n.addrs.map(i=>({address:i,family:n.family}))):r(null,n.addrs[0],n.family)}).catch(()=>Xr(e,t,r))};var P=2208,ei=process.execPath,ti=(e=process.env)=>process.versions.electron?{...e,ELECTRON_RUN_AS_NODE:"1"}:{...e};var Jo=5173,Zo=3e3;var bu=[`http://localhost:${P}`,`http://127.0.0.1:${P}`,`http://localhost:${Jo}`,`http://127.0.0.1:${Jo}`,`http://localhost:${Zo}`,`http://127.0.0.1:${Zo}`],On={fileName:"agent.log",rotatedName:"agent.log.1",maxBytes:2*1024*1024,cleanupAfterDays:7},ni=60,I={STOPPED:0,PREPARING:1,CONNECTING:2,TUNNELING:3,VERIFYING:4,READY:5},ri={showTunnelUrlInMenu:!1};var oi={CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN:"1"};var ii={checkIntervalMs:3e4,requestTimeoutMs:5e3},de={server:{strategy:"exp",baseMs:1e3,maxMs:6e4},tunnelRestart:{strategy:"exp",baseMs:2e3,maxMs:3e5},tunnelSpawn:{strategy:"linear",baseMs:5e3,maxMs:6e4},tunnelRateLimit:{strategy:"exp",baseMs:6e4,maxMs:9e5},internet:{strategy:"linear",baseMs:3e3,maxMs:6e4},sse:{strategy:"linear",baseMs:2e3,maxMs:2e3},urlSync:{strategy:"linear",baseMs:5e3,maxMs:6e4}},oc={Accept:"application/json, text/plain, */*","Accept-Language":"en-US,en;q=0.9","Cache-Control":"no-cache",Pragma:"no-cache","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"};function H(e,t={}){return fetch(e,{...t,headers:{...oc,...t.headers}})}var ic=(0,In.dirname)((0,si.fileURLToPath)(__importMetaUrl)),sc=[(0,In.join)(ai.default.homedir(),".9remote",".env"),(0,In.join)(ic,"..",".env")];function ac(e){for(let t of e.split(`
12
- `)){let r=t.trim();if(!r||r.startsWith("#"))continue;let o=r.match(/^([A-Z_][A-Z0-9_]*)\s*=\s*"?(.*?)"?$/);o&&!process.env[o[1]]&&(process.env[o[1]]=o[2])}}for(let e of sc)if((0,pr.existsSync)(e))try{ac((0,pr.readFileSync)(e,"utf8"))}catch{}for(let[e,t]of Object.entries(oi))process.env[e]||(process.env[e]=t);var yo=R(require("path"),1),fs=R(require("fs"),1),ps=require("url");var li=R(ci(),1),Jr=R(require("crypto"),1),{machineIdSync:cc}=li.default;async function jt(e=null){let t=e||process.env.MACHINE_ID_SALT||"9remote-salt";try{let r=cc();return Jr.default.createHash("sha256").update(r+t).digest("hex").substring(0,16)}catch(r){return console.error("Error getting machine ID:",r),Jr.default.randomUUID().replace(/-/g,"").substring(0,16)}}var pi=R(require("crypto"),1),ui="abcdefghijklmnpqrstuvwxyz123456789",lc=8;function fi(){let e="";for(let t=0;t<lc;t++)e+=ui[pi.default.randomInt(ui.length)];return e}function St(e){return`sk-${(e||"").slice(0,8).toLowerCase()}-${fi()}-${fi()}`}function Zr(e){return/^sk-[a-z0-9]{8}-[a-np-z1-9]{8}-[a-np-z1-9]{8}$/.test(e||"")}function Y(e){if(!Zr(e))return e||null;let t=e.split("-");return`${t[0]}-${t[1]}-${t[2]}`}function di(e){return typeof e!="string"||!e?!1:/^sk-[a-z0-9]{8}-[a-z0-9]{4}-[0-9a-f]{6}$/.test(e.trim().toLowerCase())}function dr(e){return!e||e.length<8?"sk-***":`${e.slice(0,3)}***${e.slice(-4)}`}var ue=R(require("fs"),1),Mn=R(require("path"),1);var me=require("fs"),mi=require("path"),uc=0;function Fe(e,t,r={}){let{mode:o=384,spaces:n=2}=r;(0,me.mkdirSync)((0,mi.dirname)(e),{recursive:!0});let i=`${e}.${process.pid}.${++uc}.tmp`;try{(0,me.writeFileSync)(i,JSON.stringify(t,null,n),{mode:o}),(0,me.renameSync)(i,e)}catch(s){try{(0,me.existsSync)(i)&&(0,me.unlinkSync)(i)}catch{}throw s}}function hi(e,t=null){try{return(0,me.existsSync)(e)?JSON.parse((0,me.readFileSync)(e,"utf8")):t}catch{return t}}var Lu=V.STATE,_n=Mn.default.join(V.STATE,"state.json"),zr=Mn.default.join(V.ROOT,"keys.json"),mr=Mn.default.join(V.STATE,"cmd.json"),gi=Mn.default.join(V.STATE,"settings.json");function Gt(){for(let e of[V.ROOT,V.STATE])ue.default.existsSync(e)||ue.default.mkdirSync(e,{recursive:!0})}function yi(){try{return Gt(),ue.default.existsSync(_n)?JSON.parse(ue.default.readFileSync(_n,"utf8")):null}catch{return null}}function Cn(e){try{Gt(),Fe(_n,e)}catch(t){console.error("Error saving state:",t)}}function wi(){try{ue.default.existsSync(_n)&&ue.default.unlinkSync(_n)}catch{}}function j(){try{return Gt(),ue.default.existsSync(gi)?JSON.parse(ue.default.readFileSync(gi,"utf8"))||{}:{}}catch{return{}}}function $n(){try{return Gt(),ue.default.existsSync(zr)?JSON.parse(ue.default.readFileSync(zr,"utf8")):{machineId:null,key:null,name:"Default",createdAt:null}}catch{return{machineId:null,key:null,name:"Default",createdAt:null}}}function Vt(e){try{Gt(),Fe(mr,{cmd:e,ts:Date.now()},{spaces:0})}catch{}}function vi(){try{if(!ue.default.existsSync(mr))return null;let e=JSON.parse(ue.default.readFileSync(mr,"utf8"));return ue.default.unlinkSync(mr),e.cmd}catch{return null}}function Ke(e,t,r="Default"){try{Gt();let o={machineId:e,key:t,name:r,createdAt:new Date().toISOString()};return Fe(zr,o),o}catch(o){return console.error("Error saving key:",o),null}}var Oe=R(require("fs"),1),eo=R(require("path"),1);var gr=V.LOGS,Nn=eo.default.join(gr,On.fileName),yr=eo.default.join(gr,On.rotatedName),Ei=!1,Si=null;function fc(){Oe.default.existsSync(gr)||Oe.default.mkdirSync(gr,{recursive:!0})}function pc(){try{if(Oe.default.statSync(Nn).size<On.maxBytes)return;try{Oe.default.rmSync(yr,{force:!0})}catch{}Oe.default.renameSync(Nn,yr)}catch{}}function dc(){try{let e=Oe.default.statSync(yr);Date.now()-e.mtimeMs>On.cleanupAfterDays*864e5&&Oe.default.rmSync(yr,{force:!0})}catch{}}function to(e){try{pc(),Oe.default.appendFileSync(Nn,e+`
13
- `)}catch{}}function hr(e){return e.map(t=>{if(t instanceof Error)return t.stack||t.message;if(typeof t=="object")try{return JSON.stringify(t)}catch{return String(t)}return String(t)}).join(" ")}var mc=/\x1b\[[0-9;]*m/g,hc=/https?:\/\/[^\s]+/g;function gc(e){return String(e).replace(mc,"").replace(hc,"").replace(/\s+$/g,"")}function Yt(e,t,r){let o=gc(r);if(!o)return;let n=`${new Date().toISOString()} ${t.toUpperCase()} [${e}] ${o}`;if(to(n),Si)try{Si(n)}catch{}}function yc(){process.on("uncaughtException",e=>Yt("crash","error",`uncaughtException: ${e?.stack||e?.message||e}`)),process.on("unhandledRejection",e=>{let t=e instanceof Error?e.stack||e.message:String(e);Yt("crash","error",`unhandledRejection: ${t}`)}),process.on("exit",e=>to(`${new Date().toISOString()} INFO [exit] code=${e} pid=${process.pid}`))}function Ti(){Ei||(Ei=!0,fc(),dc(),to(`
14
- === SESSION ${new Date().toISOString()} pid=${process.pid} argv=${process.argv.slice(2).join(" ")} ===`),yc())}function bi(e=60){try{return Oe.default.readFileSync(Nn,"utf8").split(`
15
- `).filter(Boolean).slice(-e)}catch{return[]}}var wc=process.env.NODE_ENV==="development"||process.env.AGENT_DEBUG==="1";function B(e){return{debug:(...t)=>{wc&&Yt(e,"debug",hr(t))},info:(...t)=>Yt(e,"info",hr(t)),warn:(...t)=>Yt(e,"warn",hr(t)),error:(...t)=>Yt(e,"error",hr(t))}}var Dn=Nn;var rt=R(require("crypto"),1),qt=require("fs");var Ai=require("path");var $u=Buffer.from("302a300506032b656e","hex");var wr=(0,Ai.join)(V.CONFIG,"hostKey.json"),Ku=Buffer.from("302a300506032b6570032100","hex"),Xt=null;function no(){if(Xt)return Xt;try{if((0,qt.existsSync)(wr)){let s=JSON.parse((0,qt.readFileSync)(wr,"utf8")),a=Buffer.from(s.publicKey,"base64");if(!s.x25519PrivateKey){let l=rt.default.generateKeyPairSync("x25519");s.x25519PrivateKey=l.privateKey.export({type:"pkcs8",format:"der"}).toString("base64"),s.x25519PublicKey=l.publicKey.export({type:"spki",format:"der"}).toString("base64"),Fe(wr,s)}let c=Buffer.from(s.x25519PublicKey,"base64");return Xt={privateKey:rt.default.createPrivateKey({key:Buffer.from(s.privateKey,"base64"),format:"der",type:"pkcs8"}),publicKey:rt.default.createPublicKey({key:a,format:"der",type:"spki"}),publicKeyB64:a.subarray(-32).toString("base64"),x25519PrivateKey:rt.default.createPrivateKey({key:Buffer.from(s.x25519PrivateKey,"base64"),format:"der",type:"pkcs8"}),x25519PublicKeyB64:c.subarray(-32).toString("base64")},Xt}}catch{}(0,qt.mkdirSync)(V.CONFIG,{recursive:!0});let{privateKey:e,publicKey:t}=rt.default.generateKeyPairSync("ed25519"),r=t.export({type:"spki",format:"der"}).toString("base64"),o=e.export({type:"pkcs8",format:"der"}).toString("base64"),n=rt.default.generateKeyPairSync("x25519"),i=n.publicKey.export({type:"spki",format:"der"}).toString("base64");return Fe(wr,{privateKey:o,publicKey:r,x25519PrivateKey:n.privateKey.export({type:"pkcs8",format:"der"}).toString("base64"),x25519PublicKey:i}),Xt={privateKey:e,publicKey:t,publicKeyB64:Buffer.from(r,"base64").subarray(-32).toString("base64"),x25519PrivateKey:n.privateKey,x25519PublicKeyB64:Buffer.from(i,"base64").subarray(-32).toString("base64")},Xt}function ot(){return no().publicKeyB64}function it(){return no().x25519PublicKeyB64}var vc="9remote-session-v1";function Ec({apiKey:e,tunnelUrl:t,localIp:r,expiryMinutes:o,ts:n}){let i=a=>{let c=a==null?"":String(a);return`${c.length}:${c}`},s=`${vc}|${i(e)}${i(t)}${i(r)}${i(o)}${i(n)}`;return rt.default.sign(null,Buffer.from(s,"utf8"),no().privateKey).toString("base64")}function Tt(e){let t=Date.now();return{ts:t,sig:Ec({...e,ts:t})}}var Ri=R(require("crypto"),1),ki=require("path");var Sc=B("pairing"),Pi=(0,ki.join)(V.STATE,"pairing.json"),xi="ABCDEFGHIJKLMNPQRSTUVWXYZ123456789",Tc=2;function Oi(){let e="";for(let t=0;t<Tc;t++)e+=xi[Ri.default.randomInt(xi.length)];return e}function bc(){let e=hi(Pi,null);return!e||Date.now()>e.expiresAt?null:e}function Ac(e){try{Fe(Pi,e)}catch(t){Sc.error(`persist pairing state: ${t.message}`)}}function Ii(e,t,r,o=null){Ac({tempKey:e,tail:t,expiresAt:r,workerUrl:o})}function Li(){let e=bc();return e?{tempKey:e.tempKey,tail:e.tail,expiresAt:e.expiresAt}:null}var ro=B("session"),xc=10;async function Bn(e,t){let r=async()=>{let o=await H(`${t}/api/temp-key/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((()=>{let n={apiKey:Y(e),expiryMinutes:xc};return{...n,...Tt(n)}})())});if(!o.ok){let n=await o.json().catch(()=>null);throw new Error(n?.error||`HTTP ${o.status}`)}return o.json()};try{let o;try{o=await r()}catch(i){if(ro.warn(`Temp key creation failed (${i.message}) \u2014 re-registering session`),!await bt(e,t))throw i;o=await r()}let n=Oi();return Ii(o.tempKey,n,o.expiresAt,t),{...o,oneTimeKey:`${o.tempKey}${n}`}}catch(o){return ro.error(`Temp key creation failed: ${o?.message||o}`),null}}function Un(e,t){return t?.tempKey?`${e}/login?k=${t.tempKey}#${t.oneTimeKey}`:`${e}/login`}async function bt(e,t,r,o){try{let n=await H(`${t}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:Y(e),hostPublicKey:ot(),hostX25519Key:it(),tempKey:Li()?.tempKey||void 0})});if(!n.ok)throw new Error(`HTTP ${n.status}`);return r&&await H(`${t}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:Y(e),tunnelUrl:r,...Tt({apiKey:Y(e),tunnelUrl:r})})}).catch(()=>{}),o&&Y(o)!==Y(e)&&await H(`${t}/api/session/delete`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:Y(o),...Tt({apiKey:Y(o)})})}).catch(()=>{}),!0}catch(n){return ro.error(`Session registration failed: ${n?.message||n}`),!1}}var ji=R(require("os"),1);var br=R(require("readline"),1),Mi=R(require("http"),1);var oo=require("child_process"),Rc={screenRecording:"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture",accessibility:"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"};function vr(e){let t=Rc[e];t&&process.platform==="darwin"&&(0,oo.exec)(`open "${t}"`,()=>{})}function Te({strategy:e,baseMs:t,maxMs:r},o){let n=Math.max(1,o),i=e==="exp"?t*Math.pow(2,n-1):t*n;return Math.min(i,r)}async function Er({config:e,task:t,label:r="task",log:o=()=>{},ctx:n={}}){let i=0;for(;!n.cancelled;){i++;try{if(await t(i))return!0}catch(a){o(`\u274C ${r} attempt ${i} error: ${a?.message||a}`)}if(n.cancelled)return!1;let s=Te(e,i);o(`\u{1F504} ${r} retry in ${s}ms (attempt ${i})`),await new Promise(a=>setTimeout(a,s))}return!1}var S={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",orange:"\x1B[38;2;230;138;110m",green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",white:"\x1B[37m"},Ci=()=>Math.min(44,process.stdout.columns||44);function so(e,t=null){let o=Ci()-2,n=(a="")=>{let c=a.replace(/\x1b\[[0-9;]*m/g,""),l=Math.max(0,o-c.length);return S.orange+"\u2551"+S.reset+a+" ".repeat(l)+S.orange+"\u2551"+S.reset},i=(a,c=l=>l)=>{let l=a.replace(/\x1b\[[0-9;]*m/g,""),u=Math.floor((o-l.length)/2),f=o-l.length-u;return S.orange+"\u2551"+S.reset+" ".repeat(u)+c(a)+" ".repeat(f)+S.orange+"\u2551"+S.reset},s=["",S.orange+"\u2554"+"\u2550".repeat(o)+"\u2557"+S.reset,n(),i(`\u{1F680} 9Remote v${e}`,a=>S.bold+S.orange+a+S.reset),i("Remote terminal access from anywhere",a=>S.dim+a+S.reset),n()];return t&&(s.push(i(`\u2B06 New version v${t} available!`,a=>S.yellow+S.bold+a+S.reset)),s.push(i(`Run: npm i -g ${Ue}`,a=>S.dim+a+S.reset)),s.push(n())),s.push(S.orange+"\u255A"+"\u2550".repeat(o)+"\u255D"+S.reset),s.push(""),s.join(`
16
- `)}function Jt(e,t=null){console.log(so(e,t))}var _i=["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"],io=[{label:"Preparing",desc:"Checking dependencies"},{label:"Connecting",desc:"Creating session"},{label:"Starting tunnel",desc:"Spawning tunnel"},{label:"Verifying tunnel",desc:"Health check"},{label:"Ready",desc:"Tunnel is live"}],kc=process.platform==="win32",Pc=kc?120:80;process.on("exit",()=>process.stdout.write("\x1B[?25h"));var $i=(e,t)=>{process.stdout.write("\x1B[?25h"),process.listenerCount(e)<=1&&process.exit(t)};process.on("SIGINT",()=>$i("SIGINT",130));process.on("SIGTERM",()=>$i("SIGTERM",143));var He=0,At=null,Sr=0,Ie=-1,Fn=null,Qt=null,Tr=!1;function Ni(){let e=[],t=Ie===io.length-1;return io.forEach((r,o)=>{let n=o===Ie&&Fn?Fn:r.desc;if(o<Ie||t&&o===Ie)e.push(` ${S.green}\u2713${S.reset} ${S.dim}${r.label}${S.reset}`),Qt&&o===Qt.afterIdx&&e.push(` ${S.green}\u2713${S.reset} ${S.cyan}${Qt.text}${S.reset}`);else if(o===Ie){let i=_i[Sr%_i.length];e.push(` ${S.orange}${i}${S.reset} ${S.bold}${r.label}${S.reset} ${S.dim}${n}${S.reset}`)}else e.push(` ${S.dim}\u25CB ${r.label}${S.reset}`)}),e}function Di(){let e=Ni();He>0&&process.stdout.write(`\x1B[${He}A\x1B[0J`),process.stdout.write(e.join(`
3
+ var tc=Object.create;var Jr=Object.defineProperty;var nc=Object.getOwnPropertyDescriptor;var rc=Object.getOwnPropertyNames;var oc=Object.getPrototypeOf,ic=Object.prototype.hasOwnProperty;var sc=(e,n)=>()=>(e&&(n=e(e=0)),n);var we=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),ac=(e,n)=>{for(var r in n)Jr(e,r,{get:n[r],enumerable:!0})},cc=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of rc(n))!ic.call(e,t)&&t!==r&&Jr(e,t,{get:()=>n[t],enumerable:!(o=nc(n,t))||o.enumerable});return e};var x=(e,n,r)=>(r=e!=null?tc(oc(e)):{},cc(n||!e||!e.__esModule?Jr(r,"default",{value:e,enumerable:!0}):r,e));var fi=we((Mn,eo)=>{(function(e,n){typeof Mn=="object"&&typeof eo=="object"?eo.exports=n(require("child_process"),require("crypto")):typeof define=="function"&&define.amd?define(["child_process","crypto"],n):typeof Mn=="object"?Mn["electron-machine-id"]=n(require("child_process"),require("crypto")):e["electron-machine-id"]=n(e.child_process,e.crypto)})(Mn,function(e,n){return(function(r){function o(i){if(t[i])return t[i].exports;var s=t[i]={exports:{},id:i,loaded:!1};return r[i].call(s.exports,s,s.exports,o),s.loaded=!0,s.exports}var t={};return o.m=r,o.c=t,o.p="",o(0)})([function(r,o,t){r.exports=t(34)},function(r,o,t){var i=t(29)("wks"),s=t(33),a=t(2).Symbol,c=typeof a=="function",l=r.exports=function(u){return i[u]||(i[u]=c&&a[u]||(c?a:s)("Symbol."+u))};l.store=i},function(r,o){var t=r.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=t)},function(r,o,t){var i=t(9);r.exports=function(s){if(!i(s))throw TypeError(s+" is not an object!");return s}},function(r,o,t){r.exports=!t(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(r,o,t){var i=t(12),s=t(17);r.exports=t(4)?function(a,c,l){return i.f(a,c,s(1,l))}:function(a,c,l){return a[c]=l,a}},function(r,o){var t=r.exports={version:"2.4.0"};typeof __e=="number"&&(__e=t)},function(r,o,t){var i=t(14);r.exports=function(s,a,c){if(i(s),a===void 0)return s;switch(c){case 1:return function(l){return s.call(a,l)};case 2:return function(l,u){return s.call(a,l,u)};case 3:return function(l,u,f){return s.call(a,l,u,f)}}return function(){return s.apply(a,arguments)}}},function(r,o){var t={}.hasOwnProperty;r.exports=function(i,s){return t.call(i,s)}},function(r,o){r.exports=function(t){return typeof t=="object"?t!==null:typeof t=="function"}},function(r,o){r.exports={}},function(r,o){var t={}.toString;r.exports=function(i){return t.call(i).slice(8,-1)}},function(r,o,t){var i=t(3),s=t(26),a=t(32),c=Object.defineProperty;o.f=t(4)?Object.defineProperty:function(l,u,f){if(i(l),u=a(u,!0),i(f),s)try{return c(l,u,f)}catch{}if("get"in f||"set"in f)throw TypeError("Accessors not supported!");return"value"in f&&(l[u]=f.value),l}},function(r,o,t){var i=t(42),s=t(15);r.exports=function(a){return i(s(a))}},function(r,o){r.exports=function(t){if(typeof t!="function")throw TypeError(t+" is not a function!");return t}},function(r,o){r.exports=function(t){if(t==null)throw TypeError("Can't call method on "+t);return t}},function(r,o,t){var i=t(9),s=t(2).document,a=i(s)&&i(s.createElement);r.exports=function(c){return a?s.createElement(c):{}}},function(r,o){r.exports=function(t,i){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:i}}},function(r,o,t){var i=t(12).f,s=t(8),a=t(1)("toStringTag");r.exports=function(c,l,u){c&&!s(c=u?c:c.prototype,a)&&i(c,a,{configurable:!0,value:l})}},function(r,o,t){var i=t(29)("keys"),s=t(33);r.exports=function(a){return i[a]||(i[a]=s(a))}},function(r,o){var t=Math.ceil,i=Math.floor;r.exports=function(s){return isNaN(s=+s)?0:(s>0?i:t)(s)}},function(r,o,t){var i=t(11),s=t(1)("toStringTag"),a=i((function(){return arguments})())=="Arguments",c=function(l,u){try{return l[u]}catch{}};r.exports=function(l){var u,f,p;return l===void 0?"Undefined":l===null?"Null":typeof(f=c(u=Object(l),s))=="string"?f:a?i(u):(p=i(u))=="Object"&&typeof u.callee=="function"?"Arguments":p}},function(r,o){r.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(r,o,t){var i=t(2),s=t(6),a=t(7),c=t(5),l="prototype",u=function(f,p,d){var h,w,E,O=f&u.F,b=f&u.G,A=f&u.S,k=f&u.P,M=f&u.B,g=f&u.W,T=b?s:s[p]||(s[p]={}),_=T[l],C=b?i:A?i[p]:(i[p]||{})[l];b&&(d=p);for(h in d)w=!O&&C&&C[h]!==void 0,w&&h in T||(E=w?C[h]:d[h],T[h]=b&&typeof C[h]!="function"?d[h]:M&&w?a(E,i):g&&C[h]==E?(function(Q){var le=function(be,ue,Fe){if(this instanceof Q){switch(arguments.length){case 0:return new Q;case 1:return new Q(be);case 2:return new Q(be,ue)}return new Q(be,ue,Fe)}return Q.apply(this,arguments)};return le[l]=Q[l],le})(E):k&&typeof E=="function"?a(Function.call,E):E,k&&((T.virtual||(T.virtual={}))[h]=E,f&u.R&&_&&!_[h]&&c(_,h,E)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,r.exports=u},function(r,o){r.exports=function(t){try{return!!t()}catch{return!0}}},function(r,o,t){r.exports=t(2).document&&document.documentElement},function(r,o,t){r.exports=!t(4)&&!t(24)(function(){return Object.defineProperty(t(16)("div"),"a",{get:function(){return 7}}).a!=7})},function(r,o,t){"use strict";var i=t(28),s=t(23),a=t(57),c=t(5),l=t(8),u=t(10),f=t(45),p=t(18),d=t(52),h=t(1)("iterator"),w=!([].keys&&"next"in[].keys()),E="@@iterator",O="keys",b="values",A=function(){return this};r.exports=function(k,M,g,T,_,C,Q){f(g,M,T);var le,be,ue,Fe=function(v){if(!w&&v in fe)return fe[v];switch(v){case O:return function(){return new g(this,v)};case b:return function(){return new g(this,v)}}return function(){return new g(this,v)}},Wt=M+" Iterator",St=_==b,kn=!1,fe=k.prototype,rt=fe[h]||fe[E]||_&&fe[_],me=rt||Fe(_),Pn=_?St?Fe("entries"):me:void 0,y=M=="Array"&&fe.entries||rt;if(y&&(ue=d(y.call(new k)),ue!==Object.prototype&&(p(ue,Wt,!0),i||l(ue,h)||c(ue,h,A))),St&&rt&&rt.name!==b&&(kn=!0,me=function(){return rt.call(this)}),i&&!Q||!w&&!kn&&fe[h]||c(fe,h,me),u[M]=me,u[Wt]=A,_)if(le={values:St?me:Fe(b),keys:C?me:Fe(O),entries:Pn},Q)for(be in le)be in fe||a(fe,be,le[be]);else s(s.P+s.F*(w||kn),M,le);return le}},function(r,o){r.exports=!0},function(r,o,t){var i=t(2),s="__core-js_shared__",a=i[s]||(i[s]={});r.exports=function(c){return a[c]||(a[c]={})}},function(r,o,t){var i,s,a,c=t(7),l=t(41),u=t(25),f=t(16),p=t(2),d=p.process,h=p.setImmediate,w=p.clearImmediate,E=p.MessageChannel,O=0,b={},A="onreadystatechange",k=function(){var g=+this;if(b.hasOwnProperty(g)){var T=b[g];delete b[g],T()}},M=function(g){k.call(g.data)};h&&w||(h=function(g){for(var T=[],_=1;arguments.length>_;)T.push(arguments[_++]);return b[++O]=function(){l(typeof g=="function"?g:Function(g),T)},i(O),O},w=function(g){delete b[g]},t(11)(d)=="process"?i=function(g){d.nextTick(c(k,g,1))}:E?(s=new E,a=s.port2,s.port1.onmessage=M,i=c(a.postMessage,a,1)):p.addEventListener&&typeof postMessage=="function"&&!p.importScripts?(i=function(g){p.postMessage(g+"","*")},p.addEventListener("message",M,!1)):i=A in f("script")?function(g){u.appendChild(f("script"))[A]=function(){u.removeChild(this),k.call(g)}}:function(g){setTimeout(c(k,g,1),0)}),r.exports={set:h,clear:w}},function(r,o,t){var i=t(20),s=Math.min;r.exports=function(a){return a>0?s(i(a),9007199254740991):0}},function(r,o,t){var i=t(9);r.exports=function(s,a){if(!i(s))return s;var c,l;if(a&&typeof(c=s.toString)=="function"&&!i(l=c.call(s))||typeof(c=s.valueOf)=="function"&&!i(l=c.call(s))||!a&&typeof(c=s.toString)=="function"&&!i(l=c.call(s)))return l;throw TypeError("Can't convert object to primitive value")}},function(r,o){var t=0,i=Math.random();r.exports=function(s){return"Symbol(".concat(s===void 0?"":s,")_",(++t+i).toString(36))}},function(r,o,t){"use strict";function i(A){return A&&A.__esModule?A:{default:A}}function s(){return process.platform!=="win32"?"":process.arch==="ia32"&&process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")?"mixed":"native"}function a(A){return(0,h.createHash)("sha256").update(A).digest("hex")}function c(A){switch(E){case"darwin":return A.split("IOPlatformUUID")[1].split(`
4
+ `)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return A.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return A.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return A.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function l(A){var k=c((0,d.execSync)(b[E]).toString());return A?k:a(k)}function u(A){return new p.default(function(k,M){return(0,d.exec)(b[E],{},function(g,T,_){if(g)return M(new Error("Error while obtaining machine id: "+g.stack));var C=c(T.toString());return k(A?C:a(C))})})}Object.defineProperty(o,"__esModule",{value:!0});var f=t(35),p=i(f);o.machineIdSync=l,o.machineId=u;var d=t(70),h=t(71),w=process,E=w.platform,O={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},b={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:O[s()]+"\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid",linux:"( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :",freebsd:"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid"}},function(r,o,t){r.exports={default:t(36),__esModule:!0}},function(r,o,t){t(66),t(68),t(69),t(67),r.exports=t(6).Promise},function(r,o){r.exports=function(){}},function(r,o){r.exports=function(t,i,s,a){if(!(t instanceof i)||a!==void 0&&a in t)throw TypeError(s+": incorrect invocation!");return t}},function(r,o,t){var i=t(13),s=t(31),a=t(62);r.exports=function(c){return function(l,u,f){var p,d=i(l),h=s(d.length),w=a(f,h);if(c&&u!=u){for(;h>w;)if(p=d[w++],p!=p)return!0}else for(;h>w;w++)if((c||w in d)&&d[w]===u)return c||w||0;return!c&&-1}}},function(r,d,t){var i=t(7),s=t(44),a=t(43),c=t(3),l=t(31),u=t(64),f={},p={},d=r.exports=function(h,w,E,O,b){var A,k,M,g,T=b?function(){return h}:u(h),_=i(E,O,w?2:1),C=0;if(typeof T!="function")throw TypeError(h+" is not iterable!");if(a(T)){for(A=l(h.length);A>C;C++)if(g=w?_(c(k=h[C])[0],k[1]):_(h[C]),g===f||g===p)return g}else for(M=T.call(h);!(k=M.next()).done;)if(g=s(M,_,k.value,w),g===f||g===p)return g};d.BREAK=f,d.RETURN=p},function(r,o){r.exports=function(t,i,s){var a=s===void 0;switch(i.length){case 0:return a?t():t.call(s);case 1:return a?t(i[0]):t.call(s,i[0]);case 2:return a?t(i[0],i[1]):t.call(s,i[0],i[1]);case 3:return a?t(i[0],i[1],i[2]):t.call(s,i[0],i[1],i[2]);case 4:return a?t(i[0],i[1],i[2],i[3]):t.call(s,i[0],i[1],i[2],i[3])}return t.apply(s,i)}},function(r,o,t){var i=t(11);r.exports=Object("z").propertyIsEnumerable(0)?Object:function(s){return i(s)=="String"?s.split(""):Object(s)}},function(r,o,t){var i=t(10),s=t(1)("iterator"),a=Array.prototype;r.exports=function(c){return c!==void 0&&(i.Array===c||a[s]===c)}},function(r,o,t){var i=t(3);r.exports=function(s,a,c,l){try{return l?a(i(c)[0],c[1]):a(c)}catch(f){var u=s.return;throw u!==void 0&&i(u.call(s)),f}}},function(r,o,t){"use strict";var i=t(49),s=t(17),a=t(18),c={};t(5)(c,t(1)("iterator"),function(){return this}),r.exports=function(l,u,f){l.prototype=i(c,{next:s(1,f)}),a(l,u+" Iterator")}},function(r,o,t){var i=t(1)("iterator"),s=!1;try{var a=[7][i]();a.return=function(){s=!0},Array.from(a,function(){throw 2})}catch{}r.exports=function(c,l){if(!l&&!s)return!1;var u=!1;try{var f=[7],p=f[i]();p.next=function(){return{done:u=!0}},f[i]=function(){return p},c(f)}catch{}return u}},function(r,o){r.exports=function(t,i){return{value:i,done:!!t}}},function(r,o,t){var i=t(2),s=t(30).set,a=i.MutationObserver||i.WebKitMutationObserver,c=i.process,l=i.Promise,u=t(11)(c)=="process";r.exports=function(){var f,p,d,h=function(){var b,A;for(u&&(b=c.domain)&&b.exit();f;){A=f.fn,f=f.next;try{A()}catch(k){throw f?d():p=void 0,k}}p=void 0,b&&b.enter()};if(u)d=function(){c.nextTick(h)};else if(a){var w=!0,E=document.createTextNode("");new a(h).observe(E,{characterData:!0}),d=function(){E.data=w=!w}}else if(l&&l.resolve){var O=l.resolve();d=function(){O.then(h)}}else d=function(){s.call(i,h)};return function(b){var A={fn:b,next:void 0};p&&(p.next=A),f||(f=A,d()),p=A}}},function(r,o,t){var i=t(3),s=t(50),a=t(22),c=t(19)("IE_PROTO"),l=function(){},u="prototype",f=function(){var p,d=t(16)("iframe"),h=a.length,w=">";for(d.style.display="none",t(25).appendChild(d),d.src="javascript:",p=d.contentWindow.document,p.open(),p.write("<script>document.F=Object</script"+w),p.close(),f=p.F;h--;)delete f[u][a[h]];return f()};r.exports=Object.create||function(p,d){var h;return p!==null?(l[u]=i(p),h=new l,l[u]=null,h[c]=p):h=f(),d===void 0?h:s(h,d)}},function(r,o,t){var i=t(12),s=t(3),a=t(54);r.exports=t(4)?Object.defineProperties:function(c,l){s(c);for(var u,f=a(l),p=f.length,d=0;p>d;)i.f(c,u=f[d++],l[u]);return c}},function(r,o,t){var i=t(55),s=t(17),a=t(13),c=t(32),l=t(8),u=t(26),f=Object.getOwnPropertyDescriptor;o.f=t(4)?f:function(p,d){if(p=a(p),d=c(d,!0),u)try{return f(p,d)}catch{}if(l(p,d))return s(!i.f.call(p,d),p[d])}},function(r,o,t){var i=t(8),s=t(63),a=t(19)("IE_PROTO"),c=Object.prototype;r.exports=Object.getPrototypeOf||function(l){return l=s(l),i(l,a)?l[a]:typeof l.constructor=="function"&&l instanceof l.constructor?l.constructor.prototype:l instanceof Object?c:null}},function(r,o,t){var i=t(8),s=t(13),a=t(39)(!1),c=t(19)("IE_PROTO");r.exports=function(l,u){var f,p=s(l),d=0,h=[];for(f in p)f!=c&&i(p,f)&&h.push(f);for(;u.length>d;)i(p,f=u[d++])&&(~a(h,f)||h.push(f));return h}},function(r,o,t){var i=t(53),s=t(22);r.exports=Object.keys||function(a){return i(a,s)}},function(r,o){o.f={}.propertyIsEnumerable},function(r,o,t){var i=t(5);r.exports=function(s,a,c){for(var l in a)c&&s[l]?s[l]=a[l]:i(s,l,a[l]);return s}},function(r,o,t){r.exports=t(5)},function(r,o,t){var i=t(9),s=t(3),a=function(c,l){if(s(c),!i(l)&&l!==null)throw TypeError(l+": can't set as prototype!")};r.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(c,l,u){try{u=t(7)(Function.call,t(51).f(Object.prototype,"__proto__").set,2),u(c,[]),l=!(c instanceof Array)}catch{l=!0}return function(f,p){return a(f,p),l?f.__proto__=p:u(f,p),f}})({},!1):void 0),check:a}},function(r,o,t){"use strict";var i=t(2),s=t(6),a=t(12),c=t(4),l=t(1)("species");r.exports=function(u){var f=typeof s[u]=="function"?s[u]:i[u];c&&f&&!f[l]&&a.f(f,l,{configurable:!0,get:function(){return this}})}},function(r,o,t){var i=t(3),s=t(14),a=t(1)("species");r.exports=function(c,l){var u,f=i(c).constructor;return f===void 0||(u=i(f)[a])==null?l:s(u)}},function(r,o,t){var i=t(20),s=t(15);r.exports=function(a){return function(c,l){var u,f,p=String(s(c)),d=i(l),h=p.length;return d<0||d>=h?a?"":void 0:(u=p.charCodeAt(d),u<55296||u>56319||d+1===h||(f=p.charCodeAt(d+1))<56320||f>57343?a?p.charAt(d):u:a?p.slice(d,d+2):(u-55296<<10)+(f-56320)+65536)}}},function(r,o,t){var i=t(20),s=Math.max,a=Math.min;r.exports=function(c,l){return c=i(c),c<0?s(c+l,0):a(c,l)}},function(r,o,t){var i=t(15);r.exports=function(s){return Object(i(s))}},function(r,o,t){var i=t(21),s=t(1)("iterator"),a=t(10);r.exports=t(6).getIteratorMethod=function(c){if(c!=null)return c[s]||c["@@iterator"]||a[i(c)]}},function(r,o,t){"use strict";var i=t(37),s=t(47),a=t(10),c=t(13);r.exports=t(27)(Array,"Array",function(l,u){this._t=c(l),this._i=0,this._k=u},function(){var l=this._t,u=this._k,f=this._i++;return!l||f>=l.length?(this._t=void 0,s(1)):u=="keys"?s(0,f):u=="values"?s(0,l[f]):s(0,[f,l[f]])},"values"),a.Arguments=a.Array,i("keys"),i("values"),i("entries")},function(r,o){},function(r,o,t){"use strict";var i,s,a,c=t(28),l=t(2),u=t(7),f=t(21),p=t(23),d=t(9),h=(t(3),t(14)),w=t(38),E=t(40),O=(t(58).set,t(60)),b=t(30).set,A=t(48)(),k="Promise",M=l.TypeError,T=l.process,g=l[k],T=l.process,_=f(T)=="process",C=function(){},Q=!!(function(){try{var y=g.resolve(1),v=(y.constructor={})[t(1)("species")]=function(R){R(C,C)};return(_||typeof PromiseRejectionEvent=="function")&&y.then(C)instanceof v}catch{}})(),le=function(y,v){return y===v||y===g&&v===a},be=function(y){var v;return!(!d(y)||typeof(v=y.then)!="function")&&v},ue=function(y){return le(g,y)?new Fe(y):new s(y)},Fe=s=function(y){var v,R;this.promise=new y(function(D,te){if(v!==void 0||R!==void 0)throw M("Bad Promise constructor");v=D,R=te}),this.resolve=h(v),this.reject=h(R)},Wt=function(y){try{y()}catch(v){return{error:v}}},St=function(y,v){if(!y._n){y._n=!0;var R=y._c;A(function(){for(var D=y._v,te=y._s==1,bt=0,Gt=function(ot){var Oe,pr,On=te?ot.ok:ot.fail,In=ot.resolve,Vt=ot.reject,dr=ot.domain;try{On?(te||(y._h==2&&rt(y),y._h=1),On===!0?Oe=D:(dr&&dr.enter(),Oe=On(D),dr&&dr.exit()),Oe===ot.promise?Vt(M("Promise-chain cycle")):(pr=be(Oe))?pr.call(Oe,In,Vt):In(Oe)):Vt(D)}catch(ec){Vt(ec)}};R.length>bt;)Gt(R[bt++]);y._c=[],y._n=!1,v&&!y._h&&kn(y)})}},kn=function(y){b.call(l,function(){var v,R,D,te=y._v;if(fe(y)&&(v=Wt(function(){_?T.emit("unhandledRejection",te,y):(R=l.onunhandledrejection)?R({promise:y,reason:te}):(D=l.console)&&D.error&&D.error("Unhandled promise rejection",te)}),y._h=_||fe(y)?2:1),y._a=void 0,v)throw v.error})},fe=function(y){if(y._h==1)return!1;for(var v,R=y._a||y._c,D=0;R.length>D;)if(v=R[D++],v.fail||!fe(v.promise))return!1;return!0},rt=function(y){b.call(l,function(){var v;_?T.emit("rejectionHandled",y):(v=l.onrejectionhandled)&&v({promise:y,reason:y._v})})},me=function(y){var v=this;v._d||(v._d=!0,v=v._w||v,v._v=y,v._s=2,v._a||(v._a=v._c.slice()),St(v,!0))},Pn=function(y){var v,R=this;if(!R._d){R._d=!0,R=R._w||R;try{if(R===y)throw M("Promise can't be resolved itself");(v=be(y))?A(function(){var D={_w:R,_d:!1};try{v.call(y,u(Pn,D,1),u(me,D,1))}catch(te){me.call(D,te)}}):(R._v=y,R._s=1,St(R,!1))}catch(D){me.call({_w:R,_d:!1},D)}}};Q||(g=function(y){w(this,g,k,"_h"),h(y),i.call(this);try{y(u(Pn,this,1),u(me,this,1))}catch(v){me.call(this,v)}},i=function(y){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},i.prototype=t(56)(g.prototype,{then:function(y,v){var R=ue(O(this,g));return R.ok=typeof y!="function"||y,R.fail=typeof v=="function"&&v,R.domain=_?T.domain:void 0,this._c.push(R),this._a&&this._a.push(R),this._s&&St(this,!1),R.promise},catch:function(y){return this.then(void 0,y)}}),Fe=function(){var y=new i;this.promise=y,this.resolve=u(Pn,y,1),this.reject=u(me,y,1)}),p(p.G+p.W+p.F*!Q,{Promise:g}),t(18)(g,k),t(59)(k),a=t(6)[k],p(p.S+p.F*!Q,k,{reject:function(y){var v=ue(this),R=v.reject;return R(y),v.promise}}),p(p.S+p.F*(c||!Q),k,{resolve:function(y){if(y instanceof g&&le(y.constructor,this))return y;var v=ue(this),R=v.resolve;return R(y),v.promise}}),p(p.S+p.F*!(Q&&t(46)(function(y){g.all(y).catch(C)})),k,{all:function(y){var v=this,R=ue(v),D=R.resolve,te=R.reject,bt=Wt(function(){var Gt=[],ot=0,Oe=1;E(y,!1,function(pr){var On=ot++,In=!1;Gt.push(void 0),Oe++,v.resolve(pr).then(function(Vt){In||(In=!0,Gt[On]=Vt,--Oe||D(Gt))},te)}),--Oe||D(Gt)});return bt&&te(bt.error),R.promise},race:function(y){var v=this,R=ue(v),D=R.reject,te=Wt(function(){E(y,!1,function(bt){v.resolve(bt).then(R.resolve,D)})});return te&&D(te.error),R.promise}})},function(r,o,t){"use strict";var i=t(61)(!0);t(27)(String,"String",function(s){this._t=String(s),this._i=0},function(){var s,a=this._t,c=this._i;return c>=a.length?{value:void 0,done:!0}:(s=i(a,c),this._i+=s.length,{value:s,done:!1})})},function(r,o,t){t(65);for(var i=t(2),s=t(5),a=t(10),c=t(1)("toStringTag"),l=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var f=l[u],p=i[f],d=p&&p.prototype;d&&!d[c]&&s(d,c,f),a[f]=a.Array}},function(r,o){r.exports=require("child_process")},function(r,o){r.exports=require("crypto")}])})});var sa={};ac(sa,{initTray:()=>ar,killTray:()=>Ct,openBrowser:()=>Nt,showTrayNotification:()=>Uo,updateTrayTooltip:()=>Sn});function Zs(e){for(let n of e)try{if(vn.default.existsSync(n))return n}catch{}return null}function Xl(){if(process.platform==="win32"){for(let e of ra)try{if(vn.default.existsSync(e))return vn.default.readFileSync(e).toString("base64")}catch{}return Js}return Js}function ql(){if(process.env.NREMOTE_DESKTOP)return!1;let e=process.platform;return!(!["darwin","win32","linux"].includes(e)||e==="linux"&&!process.env.DISPLAY)}function oa(){let{port:e,tunnelUrl:n,running:r}=En,o=r?n?"Tunnel ON":"Local only":"Idle",t=`http://localhost:${e}`;return`9Remote \u2022 ${o}
5
+ Local: ${t}
6
+ Right-click to open / quit`}function ia(){let{port:e,tunnelUrl:n}=En,r=process.platform==="win32",o=n?`9Remote (Port ${e}) \u2022 Tunnel ON`:`9Remote (Port ${e}) \u2022 Local only`;return{icon:Xl(),title:r?`9Remote - Port ${e}`:"",tooltip:oa(),items:[{title:o,tooltip:n||`http://localhost:${e}`,checked:!1,enabled:!1},{title:"Open Web UI",tooltip:`Open http://localhost:${e} in your browser`,checked:!1,enabled:!0},{title:"Shutdown",tooltip:"Stop 9Remote server, tunnel and quit",checked:!1,enabled:!0}]}}function Ql(){try{let e=require(De.default.join(na,"systray2"));return e.default?.default||e.default||e}catch{return null}}function Jl({port:e,onQuit:n,onOpenUI:r}){let o=Zs(ra),t=Zs(Yl);if(!o||!t)return null;let i;try{i=(0,Je.spawn)("powershell.exe",["-NoProfile","-ExecutionPolicy","Bypass","-WindowStyle","Hidden","-InputFormat","Text","-OutputFormat","Text","-File",t,"-IconPath",o,"-Tooltip",`9Remote - Port ${e}`],{windowsHide:!0,stdio:["pipe","pipe","pipe"]})}catch{return null}let s=c=>{try{i.stdin.writable&&i.stdin.write(`${JSON.stringify(c)}
7
+ `,"utf8")}catch{}};return zs.default.createInterface({input:i.stdout}).on("line",c=>{try{let l=JSON.parse(c);if(l.type!=="click")return;l.index===0?r?.():l.index===1&&(n?.(),Ct(),setTimeout(()=>process.exit(0),500))}catch{}}),i.on("error",()=>{}),i.stderr.on("data",()=>{}),["Open Web UI","Shutdown"].forEach((c,l)=>s({action:"add-item",index:l,title:c,enabled:!0})),{_isWin:!0,_setTooltip(c){s({action:"set-tooltip",text:c})},sendAction(){},kill(){try{s({action:"kill"})}catch{}setTimeout(()=>{try{i&&!i.killed&&i.kill()}catch{}},300)}}}async function ar({port:e,onQuit:n,onOpenUI:r}){if(!ql())return null;if(process.platform==="win32")return En={port:e,tunnelUrl:"",running:!0},oe=Jl({port:e,onQuit:n,onOpenUI:r}),oe;try{let o=Ql();if(!o)return null;let i={darwin:"tray_darwin_release",win32:"tray_windows_release.exe",linux:"tray_linux_release"}[process.platform];if(!i)return null;let s=De.default.join(na,"systray2","traybin",i);if(!vn.default.existsSync(s))return null;if(process.platform!=="win32")try{vn.default.chmodSync(s,493)}catch{}if(En={port:e,tunnelUrl:"",running:!0},oe=new o({menu:ia(),debug:!1,copyDir:!0}),oe.onClick(a=>{let c=a.item?.title||a.item;c==="Open Web UI"?r?.():c==="Shutdown"&&(n?.(),Ct(),setTimeout(()=>process.exit(0),500))}),typeof oe.ready=="function")try{await oe.ready()}catch{return oe=null,null}else oe.onReady(()=>{}),oe.onError(()=>{});return oe}catch{return null}}function Sn({tunnelUrl:e,running:n}={}){if(e!==void 0&&(En.tunnelUrl=e),n!==void 0&&(En.running=n),!!oe){if(oe._isWin){oe._setTooltip?.(oa());return}try{oe.sendAction({type:"update-menu",menu:ia(),seq_id:-1})?.catch?.(()=>{})}catch{}}}function Ct(){let e=oe;if(oe=null,e)try{e.kill(!0)}catch{}}function Uo({title:e="9Remote",message:n}){let r=process.platform;if(n){if(r==="win32"){let o=c=>String(c).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;"),t=c=>String(c).replace(/'/g,"''"),i="9Remote",s=`<toast><visual><binding template="ToastText02"><text id="1">${o(e)}</text><text id="2">${o(n)}</text></binding></visual></toast>`,a=["try {","[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType=WindowsRuntime] > $null;","[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType=WindowsRuntime] > $null;","$xml = New-Object Windows.Data.Xml.Dom.XmlDocument;",`$xml.LoadXml('${t(s)}');`,"$toast = [Windows.UI.Notifications.ToastNotification]::new($xml);",`[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('${t(i)}').Show($toast);`,"} catch {","Add-Type -AssemblyName System.Windows.Forms;","$n = New-Object System.Windows.Forms.NotifyIcon;","$n.Icon = [System.Drawing.SystemIcons]::Information;",`$n.BalloonTipTitle = '${t(e)}';`,`$n.BalloonTipText = '${t(n)}';`,"$n.Visible = $true;","$n.ShowBalloonTip(5000);","Start-Sleep -Seconds 6;","$n.Dispose();","}"].join(" ");try{(0,Je.spawn)("powershell.exe",["-NoProfile","-WindowStyle","Hidden","-Command",a],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(r==="darwin"){try{let o=s=>String(s).replace(/"/g,'\\"'),t=`display notification "${o(n)}" with title "${o(e)}"`;(0,Je.spawn)("osascript",["-e",t],{detached:!0,stdio:"ignore"}).unref()}catch{}return}try{(0,Je.spawn)("notify-send",[e,n],{detached:!0,stdio:"ignore"}).unref()}catch{}}}function Nt(e){let n=process.platform;if(n==="win32"){try{(0,Je.spawn)("rundll32.exe",["url.dll,FileProtocolHandler",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref();return}catch{}try{(0,Je.spawn)("cmd.exe",["/d","/s","/c","start","",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(n==="darwin"){try{(0,Je.spawn)("open",[e],{detached:!0,stdio:"ignore"}).unref()}catch{}return}let r=[["setsid",["--fork","xdg-open",e]],["setsid",["xdg-open",e]],["xdg-open",[e]],["gio",["open",e]],["sensible-browser",[e]],["x-www-browser",[e]]];for(let[o,t]of r)try{(0,Je.spawn)(o,t,{detached:!0,stdio:"ignore",env:{...process.env}}).unref();return}catch{}}var Je,zs,vn,De,ea,ta,na,oe,En,Kr,Js,ra,Yl,Dt=sc(()=>{Je=require("child_process"),zs=x(require("readline"),1),vn=x(require("fs"),1),De=x(require("path"),1),ea=x(require("os"),1),ta=require("url"),na=(0,De.join)(ea.default.homedir(),".9remote","runtime","node_modules"),oe=null,En={port:0,tunnelUrl:"",running:!1},Kr=De.default.dirname((0,ta.fileURLToPath)(__importMetaUrl)),Js="iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAHhlWElmTU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAIdpAAQAAAABAAAATgAAAAAAAAEsAAAAAQAAASwAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAAECgAwAEAAAAAQAAAEAAAAAAEz0GrAAAAAlwSFlzAAAuIwAALiMBeKU/dgAAGNhJREFUeAHVm1lsncd1x8/dF5IiJZmSbMlUJFuWE8l2FMdNlDSrYANugSLphqZ9KZo8JECbti/tQ1HA701fkj4VyWMTBAhaBEGBJM2CpLHj2nVtI5LtWLaszRIlUiTF5e5L/78z39z7kbxXko2+dMi5s505c/5nzpxZLpmx24dpkTyieDKbzX5B6f1ju2TMMv2M9fWjrPUzmZCqzG9SGHSnNdCSqlmd+n31pTNtyicF76qKwMP7iYSyt5AOcm/0er2vq/is4kuKNxXfVTisXl9RPKfICIMoAQf5dH0i1+i2VP9NfWL9OJ6xPZWOHT9Fk4zxllIw3Kd4xwH9f1lxQfHdgfk/6vcOgN5OTrD8paLbltKxoaSWbyjejuH/13awgXFkyKp2AH6r9jOZzHbQI8x2K53WOQ5he9+Ukr0P/CMdacyn6CTfoB75to4lf3HLcbx/wAhWD2mT+AvVfDWpH3iUWNaAwedQoXxwb7E1ppIvckzSWEy60dW1MaxXziuRfdiWRhIb3Od5gY8hh0GVMu44aU0E2VpmBPFhiX+NfpHLIeVfUNyZSEPbyBD4xm6BxCdLVV7LR5JPsthAUucU3slzfATcXhezPoYKPTX2EpII3lO1BdohPxikwZKPu4wz3/yxpOKjiudzSf3fK/10kr9lEjUbiJIZlxwudJJiXzlJmJUIWTVksoqZbMhDo7LX08aPyjDgh/qcaJV48FrQqqwd1utjW6DgMxC7bDRGbQ0JtuYqqugq/pCeOxRPK96reIsgUcI4ThOWWzI09YokWYCL0EmpS/IOJJCpzVuTzzibpP2gtFzGegLR6fU8BQ86oA4l9CgkoS8TGRYD32gJkWZMelH1D+X18X7FTeAROs0kDRxmA/CMp5gkEl55ZltpeoZRiisioaVH5AEgRyAajDYv8HkxajE/vax1MlICNGrNKoMyWHLUAVzGEjIkVChE+UkJm7EMsM2p6REU8FGI0mFzB1oYMnwOlAFvRcbfBFAEXqdGloCbfiBQ3rvQLXSOiZjHE2FZ6HMi7Pc7WkeilBLcF0hTPfgAHq0JrfuHhKcrRs6m7xrVOImgaSwMt6X8UcmXfaPf6409KQU+UWQJwIChqFlOwLOmxZxBcwBX6j+qBAx09HN6bwk8EjbBpCV8VtM5USi4smutltW7PdOvuZknSuqJrgt4rQPAdMUEtfCBEjxlsCRsARyrPRX4N4Q/K/zocnsIQAMztwFlQ10y8+oCaAADLseckxdwB0udYl4VUUFhaaAPfkJwufVRzGVtR6lgjU7X1lptq3U68gOigYBEvLvSSFsaARiA8QssB0egMnVERvAQCpFFqEs+hd1YAiNDNKHQKI7ip/FDqsStWigdvMqAz3o50DHzRaEPFhDohnkUKAW4jC6tW8FkMW/T5bwt1XvyBVkrCFkCwxXaFWlPdTlfDgF8RuWsQPqqgDiIqgS+qtAg461A/iaOAOBI6PnQXZ/pjLMUWKUJWBSAQFlVMuvMOLGgAjMPaGLey4nC1B6sRhlft/DN2Gy1aOVCzjbaXSsodsQ0x9KAsfBgGViXq4+ZVRuR2c+KAL+poQJ0Nen3tkEWEMgieHoM8mJGIEmyYUwVQl0CXgICGlAFCVgAuGJRMe/gwzLAw3sbdPBA2iTQf7Za8rGrmv0N8ewrBRF8WzL9TEYKoAtKADW2rzzy+g4hLFR5cFi3V0HebWeErqJskR9MqcN0EQLhcXieSghmGfDMeiGXs5KISgKAKTP75AFWUSyqf5E+GheFFOX51zt92zdRspVG22krhbz49KVIrXs5vFa368pk28MvdJQS+jhDycFOkZUl9t0qVI/gt8c/3gc4dz4Am6SMSR7QBT+thXWM+QqXgwE8W1lZFeV83v0AoKdVt7dgdqCatd3Tkza9c8aqVR3INHsba2tW39gQbc5O3+jaTS2DrhwzTg+FLtZaruCi+FEPXPw2OwLWgSNU4oYBZpYCgqKL2+lgrBMMUJPuMPcBAuDgYDTbsltMV3rX7DDbOasIaCWPEnI2WczZtMDsyWfsfTuLduzRE3bvxx63yaMnrLBrn2WKZUmora62Zu3rl6x2+pc287P/sOor5+ytjaL7gNVWx1ak3Ir4dOQFG8IGYKxHic+0z7xosAZAEyTWHViB6OVgtA1u1lNYm6FOE+Dc8ipSj0Nyx6YhckJfFWC2L0JBTmtSgk7Im5POVgr23smcPXz4bjv0e39mez7xGStO6b7FNuZbbxxX/TUQdRuXX7dL//rPdvk/f2y/Xm7Z6aWa3Wh2rAb4dkcOsmfNXtdacohN1XWkhS6pFNJ1vloeKEfyqKgPFBZkR8aBf1M+6042k30qXQkRiDEpj5INbfp6V56ZZt2ytr1dbZjuRLGgZRFMdocUsFv7+fHpgr3/6EHb//m/s3s/9VnLc8jp6oTn4BP+DKdyX6CQuDyzx6oPfURjtqxy+VVbXG/rsBPubMLuAADkAPUZ5i7sYMDGKgikyO1BmVgfq0g5pQpX5qmtrQALBEFI5pe1hkNCAcw86xpTx9vDnPL+ybJbQ1ntRyaL9uGj+23mj/7Kjnz8Sct028KHycl/FEvu1ev1prXl0Yrlki8fDmQoolwqW+nww7a2NG+zi+flIE0WoAMQ614gcYqadAdPmfE9BrFVCBl3hLFuRIoCtDoH9CNIQhU0HqUElgF5lkJRCgA4ykGCm1qv+7SXH1B8eFfJZh7/Azvyid+yfqfpAuZEiwd/+t+/a0svP2OV5rrMuGvtnfvswU//jh0/ccLazYZ1Om2bmpq0ud/9kk0svW3Xnnnello50fbUP2etXM9a4pMlJrIhT74v/uyPCCgtBOsgPz4MzgGbSeCg2dJnjGFbkWpVobG8Ha2z/mfKMn9V+lLSqPfo1e3oB0/Y7k9+RiaGxw6HGcB//xv/ZMs/+pZdunLdFjaablUHdlRs9cWf2+qf/o19+NTj1tE9gLh7335rfPL37dDrr9il+rqt6orIlooPQgQUX9Q6zurG2JYscguyIFmkyq5xxEwCc4TwW5e7FEBLYjOQBEqo3YsmWFVPjX8k1IEZd/aOAO7SEXZ3uWi7tPbnqj2bOfmETczMWqfdxtNq/ZfsmR993659/1/suV9ftDPLTWtoWEBMX6vZSW113W9+zeYePGb79u6xNr6i3bKZh05a79hDNnv1GVuQY11ptn1rrCqP72lp/CbIZUlsf+4H/BN5N4et4KHGgjaFQDRUCI1eQljlhUVqCIogxQrYlljLtO+t5u2RI3dbce5B68qUuxKsp3XdaLbsxotP2+sXrtpLNxq2qklaV581xQUdgn7x9qrVLp2zCy89pwFkNyhW/XPlCZs69iGb0jYE/+mSFF0p2s5KSY43545X1b608A0DkAgdIwQjg5bNyPpYKQbOA7yKHDMll46owRYKcnac4jjuQsdxtaFbnFUmrT+x07o++6JVe6NZs8zKdbu4UvO9vK5ZYwsjdLV2OVidv75ij1y7JGV2XHEoD8eZP3DEDuyetBuZts3XOrZQk/XowtSS8uDDHQFLTAefIv9QLTjCUGkSz/sTw7badAUdEwZ+9ZRA3MfbGpDjKeaPT0AZHIwmdB7Ge7SlDGa+K1PuiC4vh1nQSW5VCkIYzJWHja5H9nOzVZn3Tp0SOe0BnogvMC2luf17bEa867okrehcsCbaGhemBLhbZrROgEvpaSWoODIEfzayKalURxxgogel8q5SNlsSXhmB1uT9ucG1tTe5prstq62u+NLoMjuaUdbOXXOHrKwRsQisRmcwrWeiLyabmajY7nsPud9AcV0sgWWUL+tUWLYb6w1blwKZCHyHO0TxZXve/iP5JfcY3APEHPC2BUCgMU/V6uD9YK1zt1Lu35p4n+WGbmjspRyUCta0K7rmLc4vWv7yOZvaf0gA5ANEn9EpbvLw++y+2Z329uUVv+mhBMYpyvx3Zzv2wKGDltl1j3XZBUTv/oOtT4otloo2zdFaTrapwTkFtt0C9WQm/n42kKTMqB+HSVmu29BtrpDyMk8NHEeqDcH06wKSwQFRpsIfM1SChgFDK7PPza1nO3ry1Dt32q5jj2n2tY51woMsMzljpfqKLZ89Yxs6BLF1VtSwU7v3x+7fZx/83BfsrgdPWC9ZNlEJnA0qZ5+1pesLtigXUxPPhhTTliI64i1XEJaNxlC1H5aYPJ841Xl+hCb8IKT2sYE+jk8ZHGBGnGDWlYrRMuuXbUiwXRFZOalruq28tty33a++YFffOmt75w77EmCWiuWKHf/cl2zf/Q/YuWd/bpcvXLKijtAPHD9u95w8ZdMP6rsK+Y1WsntgPe4LWk3LK892t6713/DlBnAi1iifkcgGmMGEIjwgFJgsZN8ahrvAJuJhgT7eOWEAE7k3/WSlbVYe8y8FyKvhiPLyB29umL3n3FtW+9F3bPqPv6z+opLwbGv5SsUO6F5w+NRntG3UJV/GOoWytfyc27Vr1+YdwOTklLW1iwCm2ahZvt6Q05USZTX4JEcmWZAnAvZ6b9OHGjwL6digW6WEeyoySNMhM4HEsxqIOi8rQ55rKBk1KYTzOWuxqZlZqnfsQH3BajqpzcwdcSFxhsxqWzPakBevS2l1AW8IXL+n3aJZt//5wb/Zjtl7LK/7Agro9btWv7lspTNP28WFmzbfkBWIT/ABYRm0BTa8FGOVsghJIzFcLleQy7f9g4kZqwDIAZlOQe9OJlFLaA7KgNbLKESDN6WcpZsbVpk/a7XaulX3zVlelxzf2lCElISX5wpM343lG3bxB9+2PatvW+m9HwqWoXa20uaNa5Y984y9ubhqV6TYNR2JUQD3CKyC8wRLIa5/VbnCUUSYHMoBS/rTd6MR9WmaYT6gdUbRBHuSnF2fReDbo7JtCZzRSUlvOnZeB5zVs9ftA2vfsd7bb9rMwyetevCIlaZ36XjMNUSefGPN1i6+rlPiL+zqfz9rx5/4bf9uoCnHxxM4t8fW0nXr1HWAEiK2P1ZLABxnPsw6kgQ8SBPzQwijciNvg2gmLAtQB2YJ/iEPKhR9IH1ARZ7rcokDiRTRF4B1aev5Kzft3MLP7J7nXrC7daCpzuy2bKniPmFjZdmuXrlqFxfXbF8lbx9/4Jg/drR0dMZaStr2OEEurG7YosyfMwejcQ3mKh480hCwzzSCxJDOx7pBylF4CzLAD8Pm3umSU2k03GBGhxlS9vWi4kG9BXzwvv3+MsSZgcDn4s1V+8FL57SFveF1rN025iQ/UVLygcN7bGLuAbuyUfPlofWhGdd3BEuX7Vq9bYuKa9oB2ALxNZg/uwu8h6MkZQQMlT7W6A8dwrYSpR0isqMPT+EAU0WSdAEa6rimTshkT+6ftic+/0Ur+YVIM6bGbC5v9Rd/auf/8av2ei1jddasGHOmKMqk95e69hsf/01bzlbkFFddeI7PGwvzNjV/3q7L/hvyF5wBOAIDviUeDh4liAfXbiUhqAG5aR8fNGm3JtjcFZDxlAVnPxyBXgHwVT1lH5yp2myhb2+efllOb5/27o6v25zuAQfvO2FPPPqgLT592hblHzhB8Li5Sy8bp44ftqlHT9mllXWdBPH+Pd0dKpadf9PaK0t2RQoAMI7OZ1957iLcSTiPoAqwABrYwzzlccGf3Udvg+ku7vmFE6wRtJa6A+MlpqRL0LTeAWf1rs/7f07b1716DG0fOOogeRPoSRH1XMnump2193SXrdKu27Redo7fNWFPfvhhO3Dqs3atMmvtBi9CHalGwulEef/1F21l/pq9fKNpy/J+KAEnyAMIFsQS8odRFANw1QPfLcGVEZWSRhTyvgtsrwZodIIBtNOEiU56KhENP3z/N6GZ53nMb2eaoh2ZgmUXr1r73MuWPfKYrrdtKStra/IBtZk5O/gnf22Pddesox2gr/v+SuUuu1Jra0fYEABJLTMrl6o2feMN6557za639eo0WbX5Vk2mzuUn7ydDbpk5nYO7WhLaCKUBhJR7jMApJvkg+NZPLFAHoUGPre0qM+vw8aiPaAHxdbik9wC8MUdizJMnsrIUkpdwh7Nrtlje7dteSxccPwPokrPS1InPKnajMGNXOjm7sVrTtbfp7dwbyno9zq/oQfSVn9gvX5+3Cy15inzBunKWdRaN8hnRWLZgfY3NbKM4f0SRHDISB+7WgD4RfkRgorlJPhU1NoJmqAAxgRHLga+VecDgOkrgTE4ORUgfTtfRGj9azdiB3LpdaBetuGPGPTaXIw5A7WZTR1yZO8uDLVM8CrIieDbOn7E9p39sL7163t5o5uxmL289fYkyoeNxoVI1052iWK7qhliRYtSmaY4HLJaDW5GAuyJcwtEfyRJA9PF2Elscqj6C4WNofrx3UIBGBazJhrwzX140dM17bb1vD5y/aO9bW7W31t5rnb1HLFedFBPsKATpTArTDEsJneV5y196xWYv/MpevLpsr9U147pu7zm4z/7wi39u0zNSosbhRZjTHjKwvL79rW/a9777XbEVH8mIzFHuZJixychdwH0ALCIn0Dv4wMf3Xr9sSx14c9G5QxIITmoIhxs7s7RhF1azdmy1ZYdX162vNb02c7dtTM5at1C1rGYvoztAvqEj8+o1y119yxavXrefLNZsXt9+NqSclvjtldIe+9TjVp2Q8kaE55/7LylDM4+cCJoEV4ZXAmRUkPzSmpYduhwdUAaa8JlSjpL8nh9R+XM2TlJ8UUId5lvRS+3sRFlboqTXuFN6vZ3RDrFTXwffO5G3I7sqeiGW2UowFIn5r+mlZ2GjYRfX2nZJp72bWJBE6uvswHqf2nWXHT123KpTO3SeYM3r/om18VVZrWavvnrG3jyn22e9rlulXpDkGJkUhz0Ou3Dw1ZjwD/9EJmhMLVsC9QD3VBkMmJn2LyNQgLSDgjgJ8oXolI6vPGayJfLtUfjCVH//o/xefWmC965LeN4XeAusCTAvxBx06kp5amOr62HS7vCk5pwcY6GoFIuTlcnMmjL/DfmRpvxJQ060qWf0tnaE8PdDUkAKvFt1ugIMUsDwPUBA0qfAtA7oB3gCPLEXfxxRpsvXdlgQX0iIG4cUHjf5kxmqmamWvs0BWJ1vdFTmQYMyFxGet3jZ4XbIBYfHVN4WOSb3WGYq93hpzvH9QpORgwzQ6qrcliKZdXxBTzyRNUy90lQYjY2j8CCk1DWoG2ZiKydBlpVEU1CBDCahPO+C/GUXjyNF/XEDPxxUANiUBlvyloLis88Jju7q4sABj5C8//nBBgWouceuIaKeXpsYiCMvL1I8ybCEMHdXnpQhFuLJqOnAzG2uSbemFDCsZrbFZxCiH6DOLUGpfJ8LiEL863UBBlRHr0SyUg3JEVUaVhlwHJUBhjJ4SXb+jKNR6O9fbatAH9pI/c2AdhSAvlTH0xxt7oihUeQngIcmio2Dg9egwmVPFZ12pAIii5gyAHokMBDbPzNBJd5XK1VPeQKnATGGvrTDQJocOUaOtOHpm/OaX2LkA6JYCEg+AAr86Ct2Phbj4U9QEL2g9T7eHhQSQSET7YRYF0rhc2sdk6ldIKM/lOzflyYcl/fZVyPKGOSFGNDhGxZpnbIaUYpHytIYFsArMMpj1ggDgQBD2evCbMa8VpTD9m0OOjopQo81OA8nDjxUPeRL4RZB4M9yGZsQzalb0HlTOBsE8JHWlYA8qiASpAIvxH2ZGaSR2aEOJ4llAMxnWfRu7qKhDlOHxmnVlTRah7NKwIc8I4o3/EP2jsEH8v5XWAJPJ30Hyagtg0bAYX4A9wH1MVCC6sKMhGWgos8SFxu2Layhr8uK8DkPFZ2f/9F0Ir0DhTfRUUWTFy+VIYsxIk6Dh2OgUDImbMH2ND34c/lfKc7FPluIAuBESGgcdEIMg3Q5AAt1OEjaWRLYflCWKkHoHWGieucdAFITwAfQlF2xXk8pBICjBO+arkvyIWGQIcUWXBfV+BC7OJvrAcWPKIZAvzsIm4CLPt1tOGwUIUiLQ3MnJvoAAuABPGWWgC8f8tAkMeKgTN5T8grOJ2TfyefXRfy9KPMhFZJ/mXknPAQ6clC3QVaZmKcdYUmpQ1hv84J/hMYE0jZgsUJpKvtuQUdw2/5lZkUtNcUnI8WdpA4uSkUHRxZ6xmpPk0KcKVZA8AUBVKR1h5kMHGlBTXuk8TQWEtp3kfyt+vxwaz92s28o4uVu/y9p4V8+omyBPpxSB3Vb+WgNOt3WFDopT/1ol4dI8/a22B50Efu7rFE/6T6xbnQKRrCODPxT4dddmATMJmFGM9ws8Bga8Q2KuYWgiTscKjD2uU16JzIm47Pux/7jpNo8YMhfVlwYqekRwrwDAd4xOMnxjvsIwNY+/OssmFKLVKXbhMNq/wfFc4pjZ/mOwLsZbxPKhcTk4e/LYLvgm4EkyyTQI9MYnkM+yH7Lf56+E42k/n0+83kdH4+Ew1AYnU/37Js4qTZ6Ma/nCEUItORwoC6+Z6jx1qRu+1Slx0jnQ8/QLTDpn9XlinV+R/8+/7/EshPRLVmq9wAAAABJRU5ErkJggg==",ra=[De.default.join(Kr,"assets","trayIcon.ico"),De.default.join(Kr,"..","assets","trayIcon.ico")],Yl=[De.default.join(Kr,"assets","tray.ps1"),De.default.join(Kr,"..","assets","tray.ps1")]});var Vo=we((Yp,ma)=>{ma.exports={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}});var ya=we((Xp,ga)=>{var tu=Vo();function ha(e){this.mode=tu.MODE_8BIT_BYTE,this.data=e}ha.prototype={getLength:function(){return this.data.length},write:function(e){for(var n=0;n<this.data.length;n++)e.put(this.data.charCodeAt(n),8)}};ga.exports=ha});var Yo=we((qp,wa)=>{var Pe={glog:function(e){if(e<1)throw new Error("glog("+e+")");return Pe.LOG_TABLE[e]},gexp:function(e){for(;e<0;)e+=255;for(;e>=256;)e-=255;return Pe.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(Y=0;Y<8;Y++)Pe.EXP_TABLE[Y]=1<<Y;var Y;for(Y=8;Y<256;Y++)Pe.EXP_TABLE[Y]=Pe.EXP_TABLE[Y-4]^Pe.EXP_TABLE[Y-5]^Pe.EXP_TABLE[Y-6]^Pe.EXP_TABLE[Y-8];var Y;for(Y=0;Y<255;Y++)Pe.LOG_TABLE[Pe.EXP_TABLE[Y]]=Y;var Y;wa.exports=Pe});var Xo=we((Qp,va)=>{var Kt=Yo();function Gr(e,n){if(e.length===void 0)throw new Error(e.length+"/"+n);for(var r=0;r<e.length&&e[r]===0;)r++;this.num=new Array(e.length-r+n);for(var o=0;o<e.length-r;o++)this.num[o]=e[o+r]}Gr.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var n=new Array(this.getLength()+e.getLength()-1),r=0;r<this.getLength();r++)for(var o=0;o<e.getLength();o++)n[r+o]^=Kt.gexp(Kt.glog(this.get(r))+Kt.glog(e.get(o)));return new Gr(n,0)},mod:function(e){if(this.getLength()-e.getLength()<0)return this;for(var n=Kt.glog(this.get(0))-Kt.glog(e.get(0)),r=new Array(this.getLength()),o=0;o<this.getLength();o++)r[o]=this.get(o);for(var t=0;t<e.getLength();t++)r[t]^=Kt.gexp(Kt.glog(e.get(t))+n);return new Gr(r,0).mod(e)}};va.exports=Gr});var Sa=we((Jp,Ea)=>{Ea.exports={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7}});var Aa=we((Zp,Ta)=>{var Se=Vo(),ba=Xo(),nu=Yo(),wt=Sa(),ee={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(e){for(var n=e<<10;ee.getBCHDigit(n)-ee.getBCHDigit(ee.G15)>=0;)n^=ee.G15<<ee.getBCHDigit(n)-ee.getBCHDigit(ee.G15);return(e<<10|n)^ee.G15_MASK},getBCHTypeNumber:function(e){for(var n=e<<12;ee.getBCHDigit(n)-ee.getBCHDigit(ee.G18)>=0;)n^=ee.G18<<ee.getBCHDigit(n)-ee.getBCHDigit(ee.G18);return e<<12|n},getBCHDigit:function(e){for(var n=0;e!==0;)n++,e>>>=1;return n},getPatternPosition:function(e){return ee.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,n,r){switch(e){case wt.PATTERN000:return(n+r)%2===0;case wt.PATTERN001:return n%2===0;case wt.PATTERN010:return r%3===0;case wt.PATTERN011:return(n+r)%3===0;case wt.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2===0;case wt.PATTERN101:return n*r%2+n*r%3===0;case wt.PATTERN110:return(n*r%2+n*r%3)%2===0;case wt.PATTERN111:return(n*r%3+(n+r)%2)%2===0;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var n=new ba([1],0),r=0;r<e;r++)n=n.multiply(new ba([1,nu.gexp(r)],0));return n},getLengthInBits:function(e,n){if(1<=n&&n<10)switch(e){case Se.MODE_NUMBER:return 10;case Se.MODE_ALPHA_NUM:return 9;case Se.MODE_8BIT_BYTE:return 8;case Se.MODE_KANJI:return 8;default:throw new Error("mode:"+e)}else if(n<27)switch(e){case Se.MODE_NUMBER:return 12;case Se.MODE_ALPHA_NUM:return 11;case Se.MODE_8BIT_BYTE:return 16;case Se.MODE_KANJI:return 10;default:throw new Error("mode:"+e)}else if(n<41)switch(e){case Se.MODE_NUMBER:return 14;case Se.MODE_ALPHA_NUM:return 13;case Se.MODE_8BIT_BYTE:return 16;case Se.MODE_KANJI:return 12;default:throw new Error("mode:"+e)}else throw new Error("type:"+n)},getLostPoint:function(e){var n=e.getModuleCount(),r=0,o=0,t=0;for(o=0;o<n;o++)for(t=0;t<n;t++){for(var i=0,s=e.isDark(o,t),a=-1;a<=1;a++)if(!(o+a<0||n<=o+a))for(var c=-1;c<=1;c++)t+c<0||n<=t+c||a===0&&c===0||s===e.isDark(o+a,t+c)&&i++;i>5&&(r+=3+i-5)}for(o=0;o<n-1;o++)for(t=0;t<n-1;t++){var l=0;e.isDark(o,t)&&l++,e.isDark(o+1,t)&&l++,e.isDark(o,t+1)&&l++,e.isDark(o+1,t+1)&&l++,(l===0||l===4)&&(r+=3)}for(o=0;o<n;o++)for(t=0;t<n-6;t++)e.isDark(o,t)&&!e.isDark(o,t+1)&&e.isDark(o,t+2)&&e.isDark(o,t+3)&&e.isDark(o,t+4)&&!e.isDark(o,t+5)&&e.isDark(o,t+6)&&(r+=40);for(t=0;t<n;t++)for(o=0;o<n-6;o++)e.isDark(o,t)&&!e.isDark(o+1,t)&&e.isDark(o+2,t)&&e.isDark(o+3,t)&&e.isDark(o+4,t)&&!e.isDark(o+5,t)&&e.isDark(o+6,t)&&(r+=40);var u=0;for(t=0;t<n;t++)for(o=0;o<n;o++)e.isDark(o,t)&&u++;var f=Math.abs(100*u/n/n-50)/5;return r+=f*10,r}};Ta.exports=ee});var qo=we((zp,xa)=>{xa.exports={L:1,M:0,Q:3,H:2}});var ka=we((ed,Ra)=>{var Vr=qo();function Be(e,n){this.totalCount=e,this.dataCount=n}Be.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];Be.getRSBlocks=function(e,n){var r=Be.getRsBlockTable(e,n);if(r===void 0)throw new Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+n);for(var o=r.length/3,t=[],i=0;i<o;i++)for(var s=r[i*3+0],a=r[i*3+1],c=r[i*3+2],l=0;l<s;l++)t.push(new Be(a,c));return t};Be.getRsBlockTable=function(e,n){switch(n){case Vr.L:return Be.RS_BLOCK_TABLE[(e-1)*4+0];case Vr.M:return Be.RS_BLOCK_TABLE[(e-1)*4+1];case Vr.Q:return Be.RS_BLOCK_TABLE[(e-1)*4+2];case Vr.H:return Be.RS_BLOCK_TABLE[(e-1)*4+3];default:return}};Ra.exports=Be});var Ia=we((td,Oa)=>{function Pa(){this.buffer=[],this.length=0}Pa.prototype={get:function(e){var n=Math.floor(e/8);return(this.buffer[n]>>>7-e%8&1)==1},put:function(e,n){for(var r=0;r<n;r++)this.putBit((e>>>n-r-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){var n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),e&&(this.buffer[n]|=128>>>this.length%8),this.length++}};Oa.exports=Pa});var Ma=we((nd,$a)=>{var ru=ya(),vt=Aa(),ou=Xo(),La=ka(),_a=Ia();function Ue(e,n){this.typeNumber=e,this.errorCorrectLevel=n,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}Ue.prototype={addData:function(e){var n=new ru(e);this.dataList.push(n),this.dataCache=null},isDark:function(e,n){if(e<0||this.moduleCount<=e||n<0||this.moduleCount<=n)throw new Error(e+","+n);return this.modules[e][n]},getModuleCount:function(){return this.moduleCount},make:function(){if(this.typeNumber<1){var e=1;for(e=1;e<40;e++){for(var n=La.getRSBlocks(e,this.errorCorrectLevel),r=new _a,o=0,t=0;t<n.length;t++)o+=n[t].dataCount;for(var i=0;i<this.dataList.length;i++){var s=this.dataList[i];r.put(s.mode,4),r.put(s.getLength(),vt.getLengthInBits(s.mode,e)),s.write(r)}if(r.getLengthInBits()<=o*8)break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,n){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var r=0;r<this.moduleCount;r++){this.modules[r]=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++)this.modules[r][o]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(e,n),this.typeNumber>=7&&this.setupTypeNumber(e),this.dataCache===null&&(this.dataCache=Ue.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,n)},setupPositionProbePattern:function(e,n){for(var r=-1;r<=7;r++)if(!(e+r<=-1||this.moduleCount<=e+r))for(var o=-1;o<=7;o++)n+o<=-1||this.moduleCount<=n+o||(0<=r&&r<=6&&(o===0||o===6)||0<=o&&o<=6&&(r===0||r===6)||2<=r&&r<=4&&2<=o&&o<=4?this.modules[e+r][n+o]=!0:this.modules[e+r][n+o]=!1)},getBestMaskPattern:function(){for(var e=0,n=0,r=0;r<8;r++){this.makeImpl(!0,r);var o=vt.getLostPoint(this);(r===0||e>o)&&(e=o,n=r)}return n},createMovieClip:function(e,n,r){var o=e.createEmptyMovieClip(n,r),t=1;this.make();for(var i=0;i<this.modules.length;i++)for(var s=i*t,a=0;a<this.modules[i].length;a++){var c=a*t,l=this.modules[i][a];l&&(o.beginFill(0,100),o.moveTo(c,s),o.lineTo(c+t,s),o.lineTo(c+t,s+t),o.lineTo(c,s+t),o.endFill())}return o},setupTimingPattern:function(){for(var e=8;e<this.moduleCount-8;e++)this.modules[e][6]===null&&(this.modules[e][6]=e%2===0);for(var n=8;n<this.moduleCount-8;n++)this.modules[6][n]===null&&(this.modules[6][n]=n%2===0)},setupPositionAdjustPattern:function(){for(var e=vt.getPatternPosition(this.typeNumber),n=0;n<e.length;n++)for(var r=0;r<e.length;r++){var o=e[n],t=e[r];if(this.modules[o][t]===null)for(var i=-2;i<=2;i++)for(var s=-2;s<=2;s++)Math.abs(i)===2||Math.abs(s)===2||i===0&&s===0?this.modules[o+i][t+s]=!0:this.modules[o+i][t+s]=!1}},setupTypeNumber:function(e){for(var n=vt.getBCHTypeNumber(this.typeNumber),r,o=0;o<18;o++)r=!e&&(n>>o&1)===1,this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3]=r;for(var t=0;t<18;t++)r=!e&&(n>>t&1)===1,this.modules[t%3+this.moduleCount-8-3][Math.floor(t/3)]=r},setupTypeInfo:function(e,n){for(var r=this.errorCorrectLevel<<3|n,o=vt.getBCHTypeInfo(r),t,i=0;i<15;i++)t=!e&&(o>>i&1)===1,i<6?this.modules[i][8]=t:i<8?this.modules[i+1][8]=t:this.modules[this.moduleCount-15+i][8]=t;for(var s=0;s<15;s++)t=!e&&(o>>s&1)===1,s<8?this.modules[8][this.moduleCount-s-1]=t:s<9?this.modules[8][15-s-1+1]=t:this.modules[8][15-s-1]=t;this.modules[this.moduleCount-8][8]=!e},mapData:function(e,n){for(var r=-1,o=this.moduleCount-1,t=7,i=0,s=this.moduleCount-1;s>0;s-=2)for(s===6&&s--;;){for(var a=0;a<2;a++)if(this.modules[o][s-a]===null){var c=!1;i<e.length&&(c=(e[i]>>>t&1)===1);var l=vt.getMask(n,o,s-a);l&&(c=!c),this.modules[o][s-a]=c,t--,t===-1&&(i++,t=7)}if(o+=r,o<0||this.moduleCount<=o){o-=r,r=-r;break}}}};Ue.PAD0=236;Ue.PAD1=17;Ue.createData=function(e,n,r){for(var o=La.getRSBlocks(e,n),t=new _a,i=0;i<r.length;i++){var s=r[i];t.put(s.mode,4),t.put(s.getLength(),vt.getLengthInBits(s.mode,e)),s.write(t)}for(var a=0,c=0;c<o.length;c++)a+=o[c].dataCount;if(t.getLengthInBits()>a*8)throw new Error("code length overflow. ("+t.getLengthInBits()+">"+a*8+")");for(t.getLengthInBits()+4<=a*8&&t.put(0,4);t.getLengthInBits()%8!==0;)t.putBit(!1);for(;!(t.getLengthInBits()>=a*8||(t.put(Ue.PAD0,8),t.getLengthInBits()>=a*8));)t.put(Ue.PAD1,8);return Ue.createBytes(t,o)};Ue.createBytes=function(e,n){for(var r=0,o=0,t=0,i=new Array(n.length),s=new Array(n.length),a=0;a<n.length;a++){var c=n[a].dataCount,l=n[a].totalCount-c;o=Math.max(o,c),t=Math.max(t,l),i[a]=new Array(c);for(var u=0;u<i[a].length;u++)i[a][u]=255&e.buffer[u+r];r+=c;var f=vt.getErrorCorrectPolynomial(l),p=new ou(i[a],f.getLength()-1),d=p.mod(f);s[a]=new Array(f.getLength()-1);for(var h=0;h<s[a].length;h++){var w=h+d.getLength()-s[a].length;s[a][h]=w>=0?d.get(w):0}}for(var E=0,O=0;O<n.length;O++)E+=n[O].totalCount;for(var b=new Array(E),A=0,k=0;k<o;k++)for(var M=0;M<n.length;M++)k<i[M].length&&(b[A++]=i[M][k]);for(var g=0;g<t;g++)for(var T=0;T<n.length;T++)g<s[T].length&&(b[A++]=s[T][g]);return b};$a.exports=Ue});var Da=we((rd,Na)=>{var iu=Ma(),Ca=qo(),su="\x1B[40m \x1B[0m",Yr="\x1B[47m \x1B[0m",au=function(e){return e?su:Yr},Qo=function(e){return{times:function(n){return new Array(n).join(e)}}},cu=function(e,n){for(var r=new Array(e),o=0;o<e;o++)r[o]=n;return r};Na.exports={error:Ca.L,generate:function(e,n,r){typeof n=="function"&&(r=n,n={});var o=new iu(-1,this.error);o.addData(e),o.make();var t="";if(n&&n.small){var i=!0,s=!1,a=o.getModuleCount(),c=o.modules.slice(),l=a%2===1;l&&c.push(cu(a,s));var u={WHITE_ALL:"\u2588",WHITE_BLACK:"\u2580",BLACK_WHITE:"\u2584",BLACK_ALL:" "},f=Qo(u.BLACK_WHITE).times(a+3),p=Qo(u.WHITE_BLACK).times(a+3);t+=f+`
8
+ `;for(var d=0;d<a;d+=2){t+=u.WHITE_ALL;for(var h=0;h<a;h++)c[d][h]===s&&c[d+1][h]===s?t+=u.WHITE_ALL:c[d][h]===s&&c[d+1][h]===i?t+=u.WHITE_BLACK:c[d][h]===i&&c[d+1][h]===s?t+=u.BLACK_WHITE:t+=u.BLACK_ALL;t+=u.WHITE_ALL+`
9
+ `}l||(t+=p)}else{var w=Qo(Yr).times(o.getModuleCount()+3);t+=w+`
10
+ `,o.modules.forEach(function(E){t+=Yr,t+=E.map(au).join(""),t+=Yr+`
11
+ `}),t+=w}r?r(t):console.log(t)},setErrorLevel:function(e){this.error=Ca[e]||this.error}}});var hr=require("fs"),$n=require("path"),li=require("url"),ui=x(require("os"),1);var mr=x(require("dns"),1),Te=x(require("path"),1),ni=x(require("os"),1),ae="9remote",zr=process.env.NREMOTE_REGISTRY||`https://registry.npmjs.org/${ae}/latest`,Ke=`${ae}@latest`,Ie=process.env.NREMOTE_HOME||Te.default.join(ni.default.homedir(),".9remote"),X={ROOT:Ie,LOGS:Te.default.join(Ie,"logs"),STATE:Te.default.join(Ie,"state"),CONFIG:Te.default.join(Ie,"config"),BIN:Te.default.join(Ie,"bin"),PIDS:Te.default.join(Ie,"pids"),BUFFERS:Te.default.join(Ie,"buffers"),DAEMON:Te.default.join(Ie,"daemon"),AI_SESSIONS:Te.default.join(Ie,"ai-sessions"),BACKGROUNDS:Te.default.join(Ie,"backgrounds")},Ln=new mr.default.promises.Resolver;Ln.setServers(["1.1.1.1","1.0.0.1","8.8.8.8"]);var Zr=mr.default.lookup,lc=/^(\d{1,3}\.){3}\d{1,3}$|^::1$|^[0-9a-f:]+$/i;mr.default.lookup=(e,n,r)=>{if(typeof n=="function"&&(r=n,n={}),e==="localhost"||lc.test(e))return Zr(e,n,r);(async()=>{if(n.family===6)return{addrs:await Ln.resolve6(e),family:6};if(n.family===4)return{addrs:await Ln.resolve4(e),family:4};let[t,i]=await Promise.allSettled([Ln.resolve4(e),Ln.resolve6(e)]);return t.status==="fulfilled"&&t.value?.length?{addrs:t.value,family:4}:i.status==="fulfilled"&&i.value?.length?{addrs:i.value,family:6}:null})().then(t=>{if(!t?.addrs?.length)return Zr(e,n,r);n.all?r(null,t.addrs.map(i=>({address:i,family:t.family}))):r(null,t.addrs[0],t.family)}).catch(()=>Zr(e,n,r))};var P=2208,ri=process.execPath,oi=(e=process.env)=>process.versions.electron?{...e,ELECTRON_RUN_AS_NODE:"1"}:{...e};var ei=5173,ti=3e3;var Mu=[`http://localhost:${P}`,`http://127.0.0.1:${P}`,`http://localhost:${ei}`,`http://127.0.0.1:${ei}`,`http://localhost:${ti}`,`http://127.0.0.1:${ti}`],_n={fileName:"agent.log",rotatedName:"agent.log.1",maxBytes:2*1024*1024,cleanupAfterDays:7},ii=60,I={STOPPED:0,PREPARING:1,CONNECTING:2,TUNNELING:3,VERIFYING:4,READY:5},si={showTunnelUrlInMenu:!1};var ai={CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN:"1"};var ci={checkIntervalMs:3e4,requestTimeoutMs:5e3},he={server:{strategy:"exp",baseMs:1e3,maxMs:6e4},tunnelRestart:{strategy:"exp",baseMs:2e3,maxMs:3e5},tunnelSpawn:{strategy:"linear",baseMs:5e3,maxMs:6e4},tunnelRateLimit:{strategy:"exp",baseMs:6e4,maxMs:9e5},internet:{strategy:"linear",baseMs:3e3,maxMs:6e4},sse:{strategy:"linear",baseMs:2e3,maxMs:2e3},urlSync:{strategy:"linear",baseMs:5e3,maxMs:6e4}},uc={Accept:"application/json, text/plain, */*","Accept-Language":"en-US,en;q=0.9","Cache-Control":"no-cache",Pragma:"no-cache","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"};function H(e,n={}){return fetch(e,{...n,headers:{...uc,...n.headers}})}var fc=(0,$n.dirname)((0,li.fileURLToPath)(__importMetaUrl)),pc=[(0,$n.join)(ui.default.homedir(),".9remote",".env"),(0,$n.join)(fc,"..",".env")];function dc(e){for(let n of e.split(`
12
+ `)){let r=n.trim();if(!r||r.startsWith("#"))continue;let o=r.match(/^([A-Z_][A-Z0-9_]*)\s*=\s*"?(.*?)"?$/);o&&!process.env[o[1]]&&(process.env[o[1]]=o[2])}}for(let e of pc)if((0,hr.existsSync)(e))try{dc((0,hr.readFileSync)(e,"utf8"))}catch{}for(let[e,n]of Object.entries(ai))process.env[e]||(process.env[e]=n);var So=x(require("path"),1),ms=x(require("fs"),1),hs=require("url");var pi=x(fi(),1),to=x(require("crypto"),1),{machineIdSync:mc}=pi.default;async function Yt(e=null){let n=e||process.env.MACHINE_ID_SALT||"9remote-salt";try{let r=mc();return to.default.createHash("sha256").update(r+n).digest("hex").substring(0,16)}catch(r){return console.error("Error getting machine ID:",r),to.default.randomUUID().replace(/-/g,"").substring(0,16)}}var hi=x(require("crypto"),1),di="abcdefghijklmnpqrstuvwxyz123456789",hc=8;function mi(){let e="";for(let n=0;n<hc;n++)e+=di[hi.default.randomInt(di.length)];return e}function Tt(e){return`sk-${(e||"").slice(0,8).toLowerCase()}-${mi()}-${mi()}`}function no(e){return/^sk-[a-z0-9]{8}-[a-np-z1-9]{8}-[a-np-z1-9]{8}$/.test(e||"")}function q(e){if(!no(e))return e||null;let n=e.split("-");return`${n[0]}-${n[1]}-${n[2]}`}function gi(e){return typeof e!="string"||!e?!1:/^sk-[a-z0-9]{8}-[a-z0-9]{4}-[0-9a-f]{6}$/.test(e.trim().toLowerCase())}function gr(e){return!e||e.length<8?"sk-***":`${e.slice(0,3)}***${e.slice(-4)}`}var pe=x(require("fs"),1),Nn=x(require("path"),1);var ge=require("fs"),yi=require("path"),gc=0;function He(e,n,r={}){let{mode:o=384,spaces:t=2}=r;(0,ge.mkdirSync)((0,yi.dirname)(e),{recursive:!0});let i=`${e}.${process.pid}.${++gc}.tmp`;try{(0,ge.writeFileSync)(i,JSON.stringify(n,null,t),{mode:o}),(0,ge.renameSync)(i,e)}catch(s){try{(0,ge.existsSync)(i)&&(0,ge.unlinkSync)(i)}catch{}throw s}}function wi(e,n=null){try{return(0,ge.existsSync)(e)?JSON.parse((0,ge.readFileSync)(e,"utf8")):n}catch{return n}}var Hu=X.STATE,Cn=Nn.default.join(X.STATE,"state.json"),ro=Nn.default.join(X.ROOT,"keys.json"),yr=Nn.default.join(X.STATE,"cmd.json"),vi=Nn.default.join(X.STATE,"settings.json");function Xt(){for(let e of[X.ROOT,X.STATE])pe.default.existsSync(e)||pe.default.mkdirSync(e,{recursive:!0})}function Ei(){try{return Xt(),pe.default.existsSync(Cn)?JSON.parse(pe.default.readFileSync(Cn,"utf8")):null}catch{return null}}function Dn(e){try{Xt(),He(Cn,e)}catch(n){console.error("Error saving state:",n)}}function Si(){try{pe.default.existsSync(Cn)&&pe.default.unlinkSync(Cn)}catch{}}function W(){try{return Xt(),pe.default.existsSync(vi)?JSON.parse(pe.default.readFileSync(vi,"utf8"))||{}:{}}catch{return{}}}function Bn(){try{return Xt(),pe.default.existsSync(ro)?JSON.parse(pe.default.readFileSync(ro,"utf8")):{machineId:null,key:null,name:"Default",createdAt:null}}catch{return{machineId:null,key:null,name:"Default",createdAt:null}}}function qt(e){try{Xt(),He(yr,{cmd:e,ts:Date.now()},{spaces:0})}catch{}}function bi(){try{if(!pe.default.existsSync(yr))return null;let e=JSON.parse(pe.default.readFileSync(yr,"utf8"));return pe.default.unlinkSync(yr),e.cmd}catch{return null}}function je(e,n,r="Default"){try{Xt();let o={machineId:e,key:n,name:r,createdAt:new Date().toISOString()};return He(ro,o),o}catch(o){return console.error("Error saving key:",o),null}}var Le=x(require("fs"),1),oo=x(require("path"),1);var vr=X.LOGS,Un=oo.default.join(vr,_n.fileName),Er=oo.default.join(vr,_n.rotatedName),Ti=!1,Ai=null;function yc(){Le.default.existsSync(vr)||Le.default.mkdirSync(vr,{recursive:!0})}function wc(){try{if(Le.default.statSync(Un).size<_n.maxBytes)return;try{Le.default.rmSync(Er,{force:!0})}catch{}Le.default.renameSync(Un,Er)}catch{}}function vc(){try{let e=Le.default.statSync(Er);Date.now()-e.mtimeMs>_n.cleanupAfterDays*864e5&&Le.default.rmSync(Er,{force:!0})}catch{}}function io(e){try{wc(),Le.default.appendFileSync(Un,e+`
13
+ `)}catch{}}function wr(e){return e.map(n=>{if(n instanceof Error)return n.stack||n.message;if(typeof n=="object")try{return JSON.stringify(n)}catch{return String(n)}return String(n)}).join(" ")}var Ec=/\x1b\[[0-9;]*m/g,Sc=/https?:\/\/[^\s]+/g;function bc(e){return String(e).replace(Ec,"").replace(Sc,"").replace(/\s+$/g,"")}function Qt(e,n,r){let o=bc(r);if(!o)return;let t=`${new Date().toISOString()} ${n.toUpperCase()} [${e}] ${o}`;if(io(t),Ai)try{Ai(t)}catch{}}function Tc(){process.on("uncaughtException",e=>Qt("crash","error",`uncaughtException: ${e?.stack||e?.message||e}`)),process.on("unhandledRejection",e=>{let n=e instanceof Error?e.stack||e.message:String(e);Qt("crash","error",`unhandledRejection: ${n}`)}),process.on("exit",e=>io(`${new Date().toISOString()} INFO [exit] code=${e} pid=${process.pid}`))}function xi(){Ti||(Ti=!0,yc(),vc(),io(`
14
+ === SESSION ${new Date().toISOString()} pid=${process.pid} argv=${process.argv.slice(2).join(" ")} ===`),Tc())}function Ri(e=60){try{return Le.default.readFileSync(Un,"utf8").split(`
15
+ `).filter(Boolean).slice(-e)}catch{return[]}}var Ac=process.env.NODE_ENV==="development"||process.env.AGENT_DEBUG==="1";function B(e){return{debug:(...n)=>{Ac&&Qt(e,"debug",wr(n))},info:(...n)=>Qt(e,"info",wr(n)),warn:(...n)=>Qt(e,"warn",wr(n)),error:(...n)=>Qt(e,"error",wr(n))}}var Fn=Un;var it=x(require("crypto"),1),Zt=require("fs");var ki=require("path");var Vu=Buffer.from("302a300506032b656e","hex");var Sr=(0,ki.join)(X.CONFIG,"hostKey.json"),Zu=Buffer.from("302a300506032b6570032100","hex"),Jt=null;function so(){if(Jt)return Jt;try{if((0,Zt.existsSync)(Sr)){let s=JSON.parse((0,Zt.readFileSync)(Sr,"utf8")),a=Buffer.from(s.publicKey,"base64");if(!s.x25519PrivateKey){let l=it.default.generateKeyPairSync("x25519");s.x25519PrivateKey=l.privateKey.export({type:"pkcs8",format:"der"}).toString("base64"),s.x25519PublicKey=l.publicKey.export({type:"spki",format:"der"}).toString("base64"),He(Sr,s)}let c=Buffer.from(s.x25519PublicKey,"base64");return Jt={privateKey:it.default.createPrivateKey({key:Buffer.from(s.privateKey,"base64"),format:"der",type:"pkcs8"}),publicKey:it.default.createPublicKey({key:a,format:"der",type:"spki"}),publicKeyB64:a.subarray(-32).toString("base64"),x25519PrivateKey:it.default.createPrivateKey({key:Buffer.from(s.x25519PrivateKey,"base64"),format:"der",type:"pkcs8"}),x25519PublicKeyB64:c.subarray(-32).toString("base64")},Jt}}catch{}(0,Zt.mkdirSync)(X.CONFIG,{recursive:!0});let{privateKey:e,publicKey:n}=it.default.generateKeyPairSync("ed25519"),r=n.export({type:"spki",format:"der"}).toString("base64"),o=e.export({type:"pkcs8",format:"der"}).toString("base64"),t=it.default.generateKeyPairSync("x25519"),i=t.publicKey.export({type:"spki",format:"der"}).toString("base64");return He(Sr,{privateKey:o,publicKey:r,x25519PrivateKey:t.privateKey.export({type:"pkcs8",format:"der"}).toString("base64"),x25519PublicKey:i}),Jt={privateKey:e,publicKey:n,publicKeyB64:Buffer.from(r,"base64").subarray(-32).toString("base64"),x25519PrivateKey:t.privateKey,x25519PublicKeyB64:Buffer.from(i,"base64").subarray(-32).toString("base64")},Jt}function st(){return so().publicKeyB64}function at(){return so().x25519PublicKeyB64}var xc="9remote-session-v1";function Rc({apiKey:e,tunnelUrl:n,localIp:r,expiryMinutes:o,ts:t}){let i=a=>{let c=a==null?"":String(a);return`${c.length}:${c}`},s=`${xc}|${i(e)}${i(n)}${i(r)}${i(o)}${i(t)}`;return it.default.sign(null,Buffer.from(s,"utf8"),so().privateKey).toString("base64")}function At(e){let n=Date.now();return{ts:n,sig:Rc({...e,ts:n})}}var Oi=x(require("crypto"),1),Ii=require("path");var kc=B("pairing"),Li=(0,Ii.join)(X.STATE,"pairing.json"),Pi="ABCDEFGHIJKLMNPQRSTUVWXYZ123456789",Pc=2;function _i(){let e="";for(let n=0;n<Pc;n++)e+=Pi[Oi.default.randomInt(Pi.length)];return e}function Oc(){let e=wi(Li,null);return!e||Date.now()>e.expiresAt?null:e}function Ic(e){try{He(Li,e)}catch(n){kc.error(`persist pairing state: ${n.message}`)}}function $i(e,n,r,o=null){Ic({tempKey:e,tail:n,expiresAt:r,workerUrl:o})}function Mi(){let e=Oc();return e?{tempKey:e.tempKey,tail:e.tail,expiresAt:e.expiresAt}:null}var ao=B("session"),Lc=10;async function Kn(e,n){let r=async()=>{let o=await H(`${n}/api/temp-key/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((()=>{let t={apiKey:q(e),expiryMinutes:Lc};return{...t,...At(t)}})())});if(!o.ok){let t=await o.json().catch(()=>null);throw new Error(t?.error||`HTTP ${o.status}`)}return o.json()};try{let o;try{o=await r()}catch(i){if(ao.warn(`Temp key creation failed (${i.message}) \u2014 re-registering session`),!await xt(e,n))throw i;o=await r()}let t=_i();return $i(o.tempKey,t,o.expiresAt,n),{...o,oneTimeKey:`${o.tempKey}${t}`}}catch(o){return ao.error(`Temp key creation failed: ${o?.message||o}`),null}}function Hn(e,n){return n?.tempKey?`${e}/login?k=${n.tempKey}#${n.oneTimeKey}`:`${e}/login`}async function xt(e,n,r,o){try{let t=await H(`${n}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:q(e),hostPublicKey:st(),hostX25519Key:at(),tempKey:Mi()?.tempKey||void 0})});if(!t.ok)throw new Error(`HTTP ${t.status}`);return r&&await H(`${n}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:q(e),tunnelUrl:r,...At({apiKey:q(e),tunnelUrl:r})})}).catch(()=>{}),o&&q(o)!==q(e)&&await H(`${n}/api/session/delete`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:q(o),...At({apiKey:q(o)})})}).catch(()=>{}),!0}catch(t){return ao.error(`Session registration failed: ${t?.message||t}`),!1}}var Yi=x(require("os"),1);var Rr=x(require("readline"),1),Ni=x(require("http"),1);var co=require("child_process"),_c={screenRecording:"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture",accessibility:"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"};function br(e){let n=_c[e];n&&process.platform==="darwin"&&(0,co.exec)(`open "${n}"`,()=>{})}function Ae({strategy:e,baseMs:n,maxMs:r},o){let t=Math.max(1,o),i=e==="exp"?n*Math.pow(2,t-1):n*t;return Math.min(i,r)}async function Tr({config:e,task:n,label:r="task",log:o=()=>{},ctx:t={}}){let i=0;for(;!t.cancelled;){i++;try{if(await n(i))return!0}catch(a){o(`\u274C ${r} attempt ${i} error: ${a?.message||a}`)}if(t.cancelled)return!1;let s=Ae(e,i);o(`\u{1F504} ${r} retry in ${s}ms (attempt ${i})`),await new Promise(a=>setTimeout(a,s))}return!1}var S={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",orange:"\x1B[38;2;230;138;110m",green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",white:"\x1B[37m"},Di=()=>Math.min(44,process.stdout.columns||44);function uo(e,n=null){let o=Di()-2,t=(a="")=>{let c=a.replace(/\x1b\[[0-9;]*m/g,""),l=Math.max(0,o-c.length);return S.orange+"\u2551"+S.reset+a+" ".repeat(l)+S.orange+"\u2551"+S.reset},i=(a,c=l=>l)=>{let l=a.replace(/\x1b\[[0-9;]*m/g,""),u=Math.floor((o-l.length)/2),f=o-l.length-u;return S.orange+"\u2551"+S.reset+" ".repeat(u)+c(a)+" ".repeat(f)+S.orange+"\u2551"+S.reset},s=["",S.orange+"\u2554"+"\u2550".repeat(o)+"\u2557"+S.reset,t(),i(`\u{1F680} 9Remote v${e}`,a=>S.bold+S.orange+a+S.reset),i("Remote terminal access from anywhere",a=>S.dim+a+S.reset),t()];return n&&(s.push(i(`\u2B06 New version v${n} available!`,a=>S.yellow+S.bold+a+S.reset)),s.push(i(`Run: npm i -g ${Ke}`,a=>S.dim+a+S.reset)),s.push(t())),s.push(S.orange+"\u255A"+"\u2550".repeat(o)+"\u255D"+S.reset),s.push(""),s.join(`
16
+ `)}function en(e,n=null){console.log(uo(e,n))}var Ci=["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"],lo=[{label:"Preparing",desc:"Checking dependencies"},{label:"Connecting",desc:"Creating session"},{label:"Starting tunnel",desc:"Spawning tunnel"},{label:"Verifying tunnel",desc:"Health check"},{label:"Ready",desc:"Tunnel is live"}],$c=process.platform==="win32",Mc=$c?120:80;process.on("exit",()=>process.stdout.write("\x1B[?25h"));var Bi=(e,n)=>{process.stdout.write("\x1B[?25h"),process.listenerCount(e)<=1&&process.exit(n)};process.on("SIGINT",()=>Bi("SIGINT",130));process.on("SIGTERM",()=>Bi("SIGTERM",143));var We=0,Rt=null,Ar=0,_e=-1,jn=null,zt=null,xr=!1;function Ui(){let e=[],n=_e===lo.length-1;return lo.forEach((r,o)=>{let t=o===_e&&jn?jn:r.desc;if(o<_e||n&&o===_e)e.push(` ${S.green}\u2713${S.reset} ${S.dim}${r.label}${S.reset}`),zt&&o===zt.afterIdx&&e.push(` ${S.green}\u2713${S.reset} ${S.cyan}${zt.text}${S.reset}`);else if(o===_e){let i=Ci[Ar%Ci.length];e.push(` ${S.orange}${i}${S.reset} ${S.bold}${r.label}${S.reset} ${S.dim}${t}${S.reset}`)}else e.push(` ${S.dim}\u25CB ${r.label}${S.reset}`)}),e}function Fi(){let e=Ui();We>0&&process.stdout.write(`\x1B[${We}A\x1B[0J`),process.stdout.write(e.join(`
17
17
  `)+`
18
- `),He=e.length}function Bi(){if(He===0||Ie<0)return;let e=Ni();if(e.length!==He){Di();return}let t=Ie+(Qt&&Qt.afterIdx<Ie?1:0),r=He-t;process.stdout.write(`\x1B[${r}A\r\x1B[2K${e[t]}\x1B[${r}B\r`)}function Oc(){Tr||(process.stdout.write("\x1B[?25l"),Tr=!0)}function Ui(){Tr&&(process.stdout.write("\x1B[?25h"),Tr=!1)}function Fi(e,t=!1,r=null){At&&(clearInterval(At),At=null),Ie=e,Fn=r,Sr=0,t||(He=0),Di(),e>=0&&e<io.length-1?(Oc(),At=setInterval(()=>{Sr++,Bi()},Pc)):Ui()}function Zt(e){Fn=e,He>0&&Bi()}function Ki(){At&&(clearInterval(At),At=null),Ui(),He=0,Ie=-1,Fn=null,Qt=null,Sr=0}function Le(e,t,r=0,o="",n=null,i=null){return new Promise(s=>{let a=r,c=!0,l=!0,u=process.platform==="win32",f=()=>{if(!c)return;process.stdout.write(l?"\x1B[2J\x1B[H":"\x1B[H"),l=!1;let w=typeof o=="function"?o():o;if(w)for(let E of w.split(`
18
+ `),We=e.length}function Ki(){if(We===0||_e<0)return;let e=Ui();if(e.length!==We){Fi();return}let n=_e+(zt&&zt.afterIdx<_e?1:0),r=We-n;process.stdout.write(`\x1B[${r}A\r\x1B[2K${e[n]}\x1B[${r}B\r`)}function Cc(){xr||(process.stdout.write("\x1B[?25l"),xr=!0)}function Hi(){xr&&(process.stdout.write("\x1B[?25h"),xr=!1)}function ji(e,n=!1,r=null){Rt&&(clearInterval(Rt),Rt=null),_e=e,jn=r,Ar=0,n||(We=0),Fi(),e>=0&&e<lo.length-1?(Cc(),Rt=setInterval(()=>{Ar++,Ki()},Mc)):Hi()}function tn(e){jn=e,We>0&&Ki()}function Wi(){Rt&&(clearInterval(Rt),Rt=null),Hi(),We=0,_e=-1,jn=null,zt=null,Ar=0}function $e(e,n,r=0,o="",t=null,i=null){return new Promise(s=>{let a=r,c=!0,l=!0,u=process.platform==="win32",f=()=>{if(!c)return;process.stdout.write(l?"\x1B[2J\x1B[H":"\x1B[H"),l=!1;let w=typeof o=="function"?o():o;if(w)for(let E of w.split(`
19
19
  `))process.stdout.write(E+`\x1B[K
20
20
  `);e&&process.stdout.write(`${S.dim}${e}${S.reset}\x1B[K
21
21
  \x1B[K
22
- `),t.forEach((E,O)=>{let T=O===a?u?">":"\u2605":u?" ":"\u2606",A=O===a?` \x1B[7m${S.bold}${T} ${E.label}${S.reset}`:` ${T} ${E.label}`;process.stdout.write(A+`\x1B[K
23
- `)}),process.stdout.write("\x1B[J")},p=()=>{if(c){if(c=!1,process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.removeListener("keypress",d),process.stdin.pause()}},d=(w,E)=>{!c||!E||(E.name==="up"?(a=(a-1+t.length)%t.length,f()):E.name==="down"?(a=(a+1)%t.length,f()):E.name==="return"?(p(),s(a)):E.name==="escape"?(p(),s(-1)):E.ctrl&&E.name==="c"&&(p(),i&&i(),process.exit(0)))};if(process.stdin.removeAllListeners("keypress"),br.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{s(-1);return}process.stdin.on("keypress",d),process.stdin.resume(),f(),n&&n(f,()=>{c&&(p(),s(-2))})})}function ao(e){return new Promise(t=>{if(process.stdin.removeAllListeners("keypress"),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}if(process.stdin.pause(),process.stdout.write(`${e} (y/N): `),br.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{}process.stdin.resume();let r=(o,n)=>{if(!n)return;if(process.stdin.removeListener("keypress",r),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),n.ctrl&&n.name==="c"&&(process.stdout.write(`
24
- `),process.exit(0));let i=(n.name||"").toLowerCase()==="y";process.stdout.write((i?"y":"n")+`
25
- `),t(i)};process.stdin.on("keypress",r)})}function Hi(e,t){return new Promise(r=>{let o=e?e.slice(0,8):"unknown",n=Ci(),i=process.stdin.listeners("keypress").slice();if(process.stdin.removeAllListeners("keypress"),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause();let s=`${S.orange}${"\u2550".repeat(n)}${S.reset}`;if(process.stdout.write(`\x1B[2J\x1B[H
22
+ `),n.forEach((E,O)=>{let b=O===a?u?">":"\u2605":u?" ":"\u2606",A=O===a?` \x1B[7m${S.bold}${b} ${E.label}${S.reset}`:` ${b} ${E.label}`;process.stdout.write(A+`\x1B[K
23
+ `)}),process.stdout.write("\x1B[J")},p=()=>{if(c){if(c=!1,process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.removeListener("keypress",d),process.stdin.pause()}},d=(w,E)=>{!c||!E||(E.name==="up"?(a=(a-1+n.length)%n.length,f()):E.name==="down"?(a=(a+1)%n.length,f()):E.name==="return"?(p(),s(a)):E.name==="escape"?(p(),s(-1)):E.ctrl&&E.name==="c"&&(p(),i&&i(),process.exit(0)))};if(process.stdin.removeAllListeners("keypress"),Rr.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{s(-1);return}process.stdin.on("keypress",d),process.stdin.resume(),f(),t&&t(f,()=>{c&&(p(),s(-2))})})}function fo(e){return new Promise(n=>{if(process.stdin.removeAllListeners("keypress"),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}if(process.stdin.pause(),process.stdout.write(`${e} (y/N): `),Rr.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{}process.stdin.resume();let r=(o,t)=>{if(!t)return;if(process.stdin.removeListener("keypress",r),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),t.ctrl&&t.name==="c"&&(process.stdout.write(`
24
+ `),process.exit(0));let i=(t.name||"").toLowerCase()==="y";process.stdout.write((i?"y":"n")+`
25
+ `),n(i)};process.stdin.on("keypress",r)})}function Gi(e,n){return new Promise(r=>{let o=e?e.slice(0,8):"unknown",t=Di(),i=process.stdin.listeners("keypress").slice();if(process.stdin.removeAllListeners("keypress"),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause();let s=`${S.orange}${"\u2550".repeat(t)}${S.reset}`;if(process.stdout.write(`\x1B[2J\x1B[H
26
26
  ${s}
27
27
  ${S.orange}${S.bold} \u{1F514} New Device Connection${S.reset}
28
28
  ${s}
29
29
  Device: ${S.cyan}${o}...${S.reset}
30
- IP: ${S.cyan}${t}${S.reset}
30
+ IP: ${S.cyan}${n}${S.reset}
31
31
  ${s}
32
32
 
33
- Allow this device? ${S.dim}(y/n)${S.reset} `),br.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{}process.stdin.resume();let a=()=>{for(let l of i)process.stdin.on("keypress",l);if(i.length>0){if(process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{}process.stdin.resume()}},c=(l,u)=>{if(!u)return;let f=(u.name||"").toLowerCase(),p=f==="y"||u.name==="return",d=f==="n"||u.name==="escape",h=u.ctrl&&u.name==="c";if(!p&&!d&&!h)return;try{if(process.stdin.removeListener("keypress",c),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause()}catch{}h&&process.exit(0);let w=p,E=w?`${S.green}y${S.reset}
33
+ Allow this device? ${S.dim}(y/n)${S.reset} `),Rr.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{}process.stdin.resume();let a=()=>{for(let l of i)process.stdin.on("keypress",l);if(i.length>0){if(process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{}process.stdin.resume()}},c=(l,u)=>{if(!u)return;let f=(u.name||"").toLowerCase(),p=f==="y"||u.name==="return",d=f==="n"||u.name==="escape",h=u.ctrl&&u.name==="c";if(!p&&!d&&!h)return;try{if(process.stdin.removeListener("keypress",c),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause()}catch{}h&&process.exit(0);let w=p,E=w?`${S.green}y${S.reset}
34
34
 
35
35
  ${S.green}\u2713 Device approved${S.reset}
36
36
  `:`${S.red}n${S.reset}
37
37
 
38
38
  ${S.red}\u2717 Device rejected${S.reset}
39
- `;process.stdout.write(E),setTimeout(()=>{try{a()}catch{}r(w)},500)};process.stdin.on("keypress",c)})}function Wi(e,t){let r=null,o=!1,n=null,i=45e3,s=()=>{n&&clearTimeout(n),n=setTimeout(()=>{try{r?.destroy()}catch{}},i)},a=async()=>{if(o)return;let c=await zt();r=Mi.default.get(`http://${c}:${e}/api/ui/events`,l=>{let u="";s(),l.on("data",f=>{s(),u+=f.toString();let p=u.split(`
40
- `);u=p.pop();let d="";for(let h of p)if(h.startsWith("data: "))d=h.slice(6);else if(h===""&&d){try{let w=JSON.parse(d);Promise.resolve(t(w.type,w)).catch(()=>{})}catch{}d=""}}),l.on("end",()=>{n&&clearTimeout(n),o||setTimeout(a,Te(de.sse,1))})}),r.on("error",()=>{n&&clearTimeout(n),o||setTimeout(a,Te(de.sse,1))})};return a(),()=>{o=!0,n&&clearTimeout(n),r?.destroy()}}var co=!1;function Gi(e){co=e}var Kn=null;async function zt(){if(Kn)return Kn;let e=o=>fetch(`http://${o}:${P}/api/health`,{signal:AbortSignal.timeout(2e3)}).then(n=>n.ok?o:Promise.reject()),r=(await Promise.allSettled(["localhost","127.0.0.1"].map(e))).map((o,n)=>o.status==="fulfilled"?["localhost","127.0.0.1"][n]:null);return Kn=r.find(o=>o==="localhost")||r.find(Boolean)||null,Kn||"127.0.0.1"}function Vi(){Kn=null}async function q(e,t){let r=await zt();try{return await fetch(`http://${r}:${P}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{return Vi(),null}}async function Z(e){let t=await zt();try{let r=await fetch(`http://${t}:${P}${e}`);return r.ok?await r.json():null}catch{return Vi(),null}}async function K(e){await q("/api/ui/state",e)}async function M(e,t={}){co&&Fi(e-1,e>I.PREPARING),await K({step:e,stepDesc:"",...t})}function Ar({phase:e,percent:t}){let r=e==="download"?`Downloading tunnel binary ${t??0}%`:"Extracting tunnel binary";co&&Zt(r),K({stepDesc:r})}async function Q(){return!!await Z("/api/health")}async function lo(){let[e,t,r,o]=await Promise.all([Z("/api/ui/state"),Z("/api/device/auto-approve"),Z("/api/autostart"),Z("/api/sleep-inhibit")]);return{desktopEnabled:!!e?.desktopEnabled,remoteAvailable:!!e?.remoteAvailable,autoApprove:!!t?.enabled,autoStart:!!r?.enabled,sleepInhibitMode:o?.mode||"never",sleepInhibitActive:!!o?.active,sleepInhibitPresets:Array.isArray(o?.presets)?o.presets:[]}}function Yi(){let e=ji.default.networkInterfaces();for(let t of Object.values(e))for(let r of t)if(r.family==="IPv4"&&!r.internal)return r.address;return null}var Xi=(e=0)=>t=>`\x1B[${t+e}m`,qi=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Qi=(e=0)=>(t,r,o)=>`\x1B[${38+e};2;${t};${r};${o}m`,U={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},ff=Object.keys(U.modifier),Ic=Object.keys(U.color),Lc=Object.keys(U.bgColor),pf=[...Ic,...Lc];function _c(){let e=new Map;for(let[t,r]of Object.entries(U)){for(let[o,n]of Object.entries(r))U[o]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},r[o]=U[o],e.set(n[0],n[1]);Object.defineProperty(U,t,{value:r,enumerable:!1})}return Object.defineProperty(U,"codes",{value:e,enumerable:!1}),U.color.close="\x1B[39m",U.bgColor.close="\x1B[49m",U.color.ansi=Xi(),U.color.ansi256=qi(),U.color.ansi16m=Qi(),U.bgColor.ansi=Xi(10),U.bgColor.ansi256=qi(10),U.bgColor.ansi16m=Qi(10),Object.defineProperties(U,{rgbToAnsi256:{value(t,r,o){return t===r&&r===o?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[o]=r;o.length===3&&(o=[...o].map(i=>i+i).join(""));let n=Number.parseInt(o,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:t=>U.rgbToAnsi256(...U.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,o,n;if(t>=232)r=((t-232)*10+8)/255,o=r,n=r;else{t-=16;let a=t%36;r=Math.floor(t/36)/5,o=Math.floor(a/6)/5,n=a%6/5}let i=Math.max(r,o,n)*2;if(i===0)return 30;let s=30+(Math.round(n)<<2|Math.round(o)<<1|Math.round(r));return i===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(t,r,o)=>U.ansi256ToAnsi(U.rgbToAnsi256(t,r,o)),enumerable:!1},hexToAnsi:{value:t=>U.ansi256ToAnsi(U.hexToAnsi256(t)),enumerable:!1}}),U}var Mc=_c(),be=Mc;var Rr=R(require("node:process"),1),Zi=R(require("node:os"),1),uo=R(require("node:tty"),1);function ye(e,t=globalThis.Deno?globalThis.Deno.args:Rr.default.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",o=t.indexOf(r+e),n=t.indexOf("--");return o!==-1&&(n===-1||o<n)}var{env:F}=Rr.default,xr;ye("no-color")||ye("no-colors")||ye("color=false")||ye("color=never")?xr=0:(ye("color")||ye("colors")||ye("color=true")||ye("color=always"))&&(xr=1);function Cc(){if("FORCE_COLOR"in F)return F.FORCE_COLOR==="true"?1:F.FORCE_COLOR==="false"?0:F.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(F.FORCE_COLOR,10),3)}function $c(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Nc(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let o=Cc();o!==void 0&&(xr=o);let n=r?xr:o;if(n===0)return 0;if(r){if(ye("color=16m")||ye("color=full")||ye("color=truecolor"))return 3;if(ye("color=256"))return 2}if("TF_BUILD"in F&&"AGENT_NAME"in F)return 1;if(e&&!t&&n===void 0)return 0;let i=n||0;if(F.TERM==="dumb")return i;if(Rr.default.platform==="win32"){let s=Zi.default.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in F)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in F)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in F)||F.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in F)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(F.TEAMCITY_VERSION)?1:0;if(F.COLORTERM==="truecolor"||F.TERM==="xterm-kitty"||F.TERM==="xterm-ghostty"||F.TERM==="wezterm")return 3;if("TERM_PROGRAM"in F){let s=Number.parseInt((F.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(F.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(F.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(F.TERM)||"COLORTERM"in F?1:i}function Ji(e,t={}){let r=Nc(e,{streamIsTTY:e&&e.isTTY,...t});return $c(r)}var Dc={stdout:Ji({isTTY:uo.default.isatty(1)}),stderr:Ji({isTTY:uo.default.isatty(2)})},zi=Dc;function es(e,t,r){let o=e.indexOf(t);if(o===-1)return e;let n=t.length,i=0,s="";do s+=e.slice(i,o)+t+r,i=o+n,o=e.indexOf(t,i);while(o!==-1);return s+=e.slice(i),s}function ts(e,t,r,o){let n=0,i="";do{let s=e[o-1]==="\r";i+=e.slice(n,s?o-1:o)+t+(s?`\r
39
+ `;process.stdout.write(E),setTimeout(()=>{try{a()}catch{}r(w)},500)};process.stdin.on("keypress",c)})}function Vi(e,n){let r=null,o=!1,t=null,i=45e3,s=()=>{t&&clearTimeout(t),t=setTimeout(()=>{try{r?.destroy()}catch{}},i)},a=async()=>{if(o)return;let c=await nn();r=Ni.default.get(`http://${c}:${e}/api/ui/events`,l=>{let u="";s(),l.on("data",f=>{s(),u+=f.toString();let p=u.split(`
40
+ `);u=p.pop();let d="";for(let h of p)if(h.startsWith("data: "))d=h.slice(6);else if(h===""&&d){try{let w=JSON.parse(d);Promise.resolve(n(w.type,w)).catch(()=>{})}catch{}d=""}}),l.on("end",()=>{t&&clearTimeout(t),o||setTimeout(a,Ae(he.sse,1))})}),r.on("error",()=>{t&&clearTimeout(t),o||setTimeout(a,Ae(he.sse,1))})};return a(),()=>{o=!0,t&&clearTimeout(t),r?.destroy()}}var po=!1;function Xi(e){po=e}var Wn=null;async function nn(){if(Wn)return Wn;let e=o=>fetch(`http://${o}:${P}/api/health`,{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok?o:Promise.reject()),r=(await Promise.allSettled(["localhost","127.0.0.1"].map(e))).map((o,t)=>o.status==="fulfilled"?["localhost","127.0.0.1"][t]:null);return Wn=r.find(o=>o==="localhost")||r.find(Boolean)||null,Wn||"127.0.0.1"}function qi(){Wn=null}async function G(e,n){let r=await nn();try{return await fetch(`http://${r}:${P}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch{return qi(),null}}async function Z(e){let n=await nn();try{let r=await fetch(`http://${n}:${P}${e}`);return r.ok?await r.json():null}catch{return qi(),null}}async function K(e){await G("/api/ui/state",e)}async function $(e,n={}){po&&ji(e-1,e>I.PREPARING),await K({step:e,stepDesc:"",...n})}function kr({phase:e,percent:n}){let r=e==="download"?`Downloading tunnel binary ${n??0}%`:"Extracting tunnel binary";po&&tn(r),K({stepDesc:r})}async function V(){return!!await Z("/api/health")}async function mo(){let[e,n,r,o]=await Promise.all([Z("/api/ui/state"),Z("/api/device/auto-approve"),Z("/api/autostart"),Z("/api/sleep-inhibit")]);return{desktopEnabled:!!e?.desktopEnabled,remoteAvailable:!!e?.remoteAvailable,autoApprove:!!n?.enabled,autoStart:!!r?.enabled,sleepInhibitMode:o?.mode||"never",sleepInhibitActive:!!o?.active,sleepInhibitPresets:Array.isArray(o?.presets)?o.presets:[]}}function Qi(){let e=Yi.default.networkInterfaces();for(let n of Object.values(e))for(let r of n)if(r.family==="IPv4"&&!r.internal)return r.address;return null}var Ji=(e=0)=>n=>`\x1B[${n+e}m`,Zi=(e=0)=>n=>`\x1B[${38+e};5;${n}m`,zi=(e=0)=>(n,r,o)=>`\x1B[${38+e};2;${n};${r};${o}m`,U={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},bf=Object.keys(U.modifier),Nc=Object.keys(U.color),Dc=Object.keys(U.bgColor),Tf=[...Nc,...Dc];function Bc(){let e=new Map;for(let[n,r]of Object.entries(U)){for(let[o,t]of Object.entries(r))U[o]={open:`\x1B[${t[0]}m`,close:`\x1B[${t[1]}m`},r[o]=U[o],e.set(t[0],t[1]);Object.defineProperty(U,n,{value:r,enumerable:!1})}return Object.defineProperty(U,"codes",{value:e,enumerable:!1}),U.color.close="\x1B[39m",U.bgColor.close="\x1B[49m",U.color.ansi=Ji(),U.color.ansi256=Zi(),U.color.ansi16m=zi(),U.bgColor.ansi=Ji(10),U.bgColor.ansi256=Zi(10),U.bgColor.ansi16m=zi(10),Object.defineProperties(U,{rgbToAnsi256:{value(n,r,o){return n===r&&r===o?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(n){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!r)return[0,0,0];let[o]=r;o.length===3&&(o=[...o].map(i=>i+i).join(""));let t=Number.parseInt(o,16);return[t>>16&255,t>>8&255,t&255]},enumerable:!1},hexToAnsi256:{value:n=>U.rgbToAnsi256(...U.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value(n){if(n<8)return 30+n;if(n<16)return 90+(n-8);let r,o,t;if(n>=232)r=((n-232)*10+8)/255,o=r,t=r;else{n-=16;let a=n%36;r=Math.floor(n/36)/5,o=Math.floor(a/6)/5,t=a%6/5}let i=Math.max(r,o,t)*2;if(i===0)return 30;let s=30+(Math.round(t)<<2|Math.round(o)<<1|Math.round(r));return i===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(n,r,o)=>U.ansi256ToAnsi(U.rgbToAnsi256(n,r,o)),enumerable:!1},hexToAnsi:{value:n=>U.ansi256ToAnsi(U.hexToAnsi256(n)),enumerable:!1}}),U}var Uc=Bc(),xe=Uc;var Or=x(require("node:process"),1),ts=x(require("node:os"),1),ho=x(require("node:tty"),1);function ve(e,n=globalThis.Deno?globalThis.Deno.args:Or.default.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",o=n.indexOf(r+e),t=n.indexOf("--");return o!==-1&&(t===-1||o<t)}var{env:F}=Or.default,Pr;ve("no-color")||ve("no-colors")||ve("color=false")||ve("color=never")?Pr=0:(ve("color")||ve("colors")||ve("color=true")||ve("color=always"))&&(Pr=1);function Fc(){if("FORCE_COLOR"in F)return F.FORCE_COLOR==="true"?1:F.FORCE_COLOR==="false"?0:F.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(F.FORCE_COLOR,10),3)}function Kc(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Hc(e,{streamIsTTY:n,sniffFlags:r=!0}={}){let o=Fc();o!==void 0&&(Pr=o);let t=r?Pr:o;if(t===0)return 0;if(r){if(ve("color=16m")||ve("color=full")||ve("color=truecolor"))return 3;if(ve("color=256"))return 2}if("TF_BUILD"in F&&"AGENT_NAME"in F)return 1;if(e&&!n&&t===void 0)return 0;let i=t||0;if(F.TERM==="dumb")return i;if(Or.default.platform==="win32"){let s=ts.default.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in F)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in F)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in F)||F.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in F)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(F.TEAMCITY_VERSION)?1:0;if(F.COLORTERM==="truecolor"||F.TERM==="xterm-kitty"||F.TERM==="xterm-ghostty"||F.TERM==="wezterm")return 3;if("TERM_PROGRAM"in F){let s=Number.parseInt((F.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(F.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(F.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(F.TERM)||"COLORTERM"in F?1:i}function es(e,n={}){let r=Hc(e,{streamIsTTY:e&&e.isTTY,...n});return Kc(r)}var jc={stdout:es({isTTY:ho.default.isatty(1)}),stderr:es({isTTY:ho.default.isatty(2)})},ns=jc;function rs(e,n,r){let o=e.indexOf(n);if(o===-1)return e;let t=n.length,i=0,s="";do s+=e.slice(i,o)+n+r,i=o+t,o=e.indexOf(n,i);while(o!==-1);return s+=e.slice(i),s}function os(e,n,r,o){let t=0,i="";do{let s=e[o-1]==="\r";i+=e.slice(t,s?o-1:o)+n+(s?`\r
41
41
  `:`
42
- `)+r,n=o+1,o=e.indexOf(`
43
- `,n)}while(o!==-1);return i+=e.slice(n),i}var{stdout:ns,stderr:rs}=zi,fo=Symbol("GENERATOR"),en=Symbol("STYLER"),Hn=Symbol("IS_EMPTY"),os=["ansi","ansi","ansi256","ansi16m"],tn=Object.create(null),Bc=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=ns?ns.level:0;e.level=t.level===void 0?r:t.level};var Uc=e=>{let t=(...r)=>r.join(" ");return Bc(t,e),Object.setPrototypeOf(t,Wn.prototype),t};function Wn(e){return Uc(e)}Object.setPrototypeOf(Wn.prototype,Function.prototype);for(let[e,t]of Object.entries(be))tn[e]={get(){let r=kr(this,mo(t.open,t.close,this[en]),this[Hn]);return Object.defineProperty(this,e,{value:r}),r}};tn.visible={get(){let e=kr(this,this[en],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var po=(e,t,r,...o)=>e==="rgb"?t==="ansi16m"?be[r].ansi16m(...o):t==="ansi256"?be[r].ansi256(be.rgbToAnsi256(...o)):be[r].ansi(be.rgbToAnsi(...o)):e==="hex"?po("rgb",t,r,...be.hexToRgb(...o)):be[r][e](...o),Fc=["rgb","hex","ansi256"];for(let e of Fc){tn[e]={get(){let{level:r}=this;return function(...o){let n=mo(po(e,os[r],"color",...o),be.color.close,this[en]);return kr(this,n,this[Hn])}}};let t="bg"+e[0].toUpperCase()+e.slice(1);tn[t]={get(){let{level:r}=this;return function(...o){let n=mo(po(e,os[r],"bgColor",...o),be.bgColor.close,this[en]);return kr(this,n,this[Hn])}}}}var Kc=Object.defineProperties(()=>{},{...tn,level:{enumerable:!0,get(){return this[fo].level},set(e){this[fo].level=e}}}),mo=(e,t,r)=>{let o,n;return r===void 0?(o=e,n=t):(o=r.openAll+e,n=t+r.closeAll),{open:e,close:t,openAll:o,closeAll:n,parent:r}},kr=(e,t,r)=>{let o=(...n)=>Hc(o,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(o,Kc),o[fo]=e,o[en]=t,o[Hn]=r,o},Hc=(e,t)=>{if(e.level<=0||!t)return e[Hn]?"":t;let r=e[en];if(r===void 0)return t;let{openAll:o,closeAll:n}=r;if(t.includes("\x1B"))for(;r!==void 0;)t=es(t,r.close,r.open),r=r.parent;let i=t.indexOf(`
44
- `);return i!==-1&&(t=ts(t,n,o,i)),o+t+n};Object.defineProperties(Wn.prototype,tn);var Wc=Wn(),vf=Wn({level:rs?rs.level:0});var m=Wc;var Tf=process.env.NODE_ENV==="development";var L=process.env.NREMOTE_WORKER_URL||"https://9remote.cc",is=3e4,ss=500,ho=300,Ae={cmdMs:1e3,pendingApprovalMs:3e3,statsMs:5e3,serverReadyIntervalMs:200,serverReadyTimeoutMs:5e3,bgServerReadyTimeoutMs:15e3,bgServerReadyIntervalMs:300},st={intervalMs:2e3,timeoutMs:12e4,fetchTimeoutMs:5e3,dnsTimeoutMs:2e3,maxLogEntries:80,postReadyHoldMs:2e3},ne={killCloudflaredMs:500,killCloudflaredTuiMs:300,serverBootMs:2e3,guestRecheckMs:3e3,trayReadyMs:1e3,postReadyHoldMs:2e3,bgSpawnFlushMs:400};var We={maxLogLines:200,headerWidth:44},xt={checkIntervalMs:36e5,connectCheckDebounceMs:9e5,maxRetry:3,retryDelayMs:3e3,verifyTimeoutMs:15e3,lockTtlMs:3e5,lockFile:"update.lock",gateTimeoutMs:6e4},as=5e3,go=12e4,Pr=1500,cs=2,ls=3e4,fe={orange:m.rgb(230,138,110),orangeDim:m.rgb(200,120,95)};function us(){return process.env.CODESPACES==="true"}var jc=yo.default.dirname((0,ps.fileURLToPath)(__importMetaUrl));async function at(){let e=await jt();if(us()&&process.env.NREMOTE_API_KEY)return Ke(e,process.env.NREMOTE_API_KEY,"Codespace");let t=$n();if(t.key)di(t.key)&&(t=await Gc(e,t));else{let r=St(e);t=Ke(e,r,"Default")}return t}async function Gc(e,t){if(await Q())return t;let r=St(e);if(j().remoteEnabled===!1)return Ke(e,r,t.name||"Default");await bt(r,L,null,t.key);let o=$n();return Zr(o.key)?o:Ke(e,r,t.name||"Default")}function _e(){return"3.0.30"}var J=require("fs"),As=require("url"),Vn=require("child_process"),xe=R(require("path"),1),It=R(require("os"),1);var nn=R(require("fs"),1),wo=R(require("path"),1),ds=R(require("os"),1),ms=require("child_process"),Or=wo.default.join(ds.default.homedir(),".9remote","pids");function Vc(){try{nn.default.existsSync(Or)||nn.default.mkdirSync(Or,{recursive:!0})}catch{}}function vo(e){return wo.default.join(Or,`${e}.pid`)}function Me(e,t){if(t)try{Vc(),nn.default.writeFileSync(vo(e),String(t))}catch{}}function jn(e){try{let t=nn.default.readFileSync(vo(e),"utf8").trim(),r=parseInt(t,10);return Number.isFinite(r)&&r>0?r:null}catch{return null}}function je(e){try{nn.default.unlinkSync(vo(e))}catch{}}function Eo(e){if(!e)return!1;try{return process.kill(e,0),!0}catch{return!1}}function Yc(e){let t=jn(e);if(je(e),!t)return!1;try{process.platform==="win32"?(0,ms.execSync)(`taskkill /F /T /PID ${t}`,{stdio:"ignore",windowsHide:!0}):process.kill(t,"SIGKILL")}catch{}return!0}var Xc=["cloudflared","agent"];function hs(){for(let e of Xc)Yc(e)}function gs(){return Or}var Pt=require("child_process"),N=require("fs"),Rt=require("path"),To=R(require("os"),1),kt=R(require("path"),1),ws=require("url");var Lr=(0,Rt.join)(V.LOGS,"autostart.log"),Ir="cc.9remote.agent",_r="9Remote",Mr=["--tray","--skip-update","--start"],Gn=To.default.homedir(),ys=kt.default.dirname((0,ws.fileURLToPath)(__importMetaUrl)),re={darwin:(0,Rt.join)(Gn,"Library","LaunchAgents",`${Ir}.plist`),linux:(0,Rt.join)(Gn,".config","autostart",`${Ir}.desktop`),linuxSystemd:(0,Rt.join)(Gn,".config","systemd","user",`${Ir}.service`),win:(0,Rt.join)(process.env.APPDATA||"","Microsoft","Windows","Start Menu","Programs","Startup",`${_r}.vbs`)};function ct(){for(let e=ys,t=null;e!==t;t=e,e=kt.default.dirname(e)){let r=kt.default.join(e,"package.json");if((0,N.existsSync)(r)){try{let o=JSON.parse((0,N.readFileSync)(r,"utf8"));if(o.name!==ie)continue;let n=typeof o.bin=="string"?o.bin:o.bin?.[ie];if(n){let i=kt.default.resolve(e,n);if((0,N.existsSync)(i))return i}}catch{}break}}return process.argv[1]||kt.default.resolve(ys,"..","index.js")}function Ce(){return process.execPath}function vs(){return process.versions.electron?"env ELECTRON_RUN_AS_NODE=1 ":""}function Es(e){let t=Ce(),r=ct();if(process.platform==="win32"){let n=e.join(" "),i=(0,Rt.join)(To.default.tmpdir(),`${ie}-launch.vbs`);return(0,N.writeFileSync)(i,`CreateObject("WScript.Shell").Run """${t}"" ""${r}"" ${n}", 0, False
45
- `),(0,Pt.execFile)("wscript.exe",[i],{windowsHide:!0}).unref?.(),null}let o=(0,Pt.spawn)(t,[r,...e],{detached:!0,stdio:"ignore"});return o.unref(),o.pid||null}function Ss(){let e=kt.default.dirname(Ce()),t=["/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin","/opt/homebrew/bin"];return t.includes(e)||t.unshift(e),t.join(":")}function So(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function qc(e,t){let r=[e,t,...Mr].map(o=>` <string>${So(o)}</string>`).join(`
42
+ `)+r,t=o+1,o=e.indexOf(`
43
+ `,t)}while(o!==-1);return i+=e.slice(t),i}var{stdout:is,stderr:ss}=ns,go=Symbol("GENERATOR"),rn=Symbol("STYLER"),Gn=Symbol("IS_EMPTY"),as=["ansi","ansi","ansi256","ansi16m"],on=Object.create(null),Wc=(e,n={})=>{if(n.level&&!(Number.isInteger(n.level)&&n.level>=0&&n.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=is?is.level:0;e.level=n.level===void 0?r:n.level};var Gc=e=>{let n=(...r)=>r.join(" ");return Wc(n,e),Object.setPrototypeOf(n,Vn.prototype),n};function Vn(e){return Gc(e)}Object.setPrototypeOf(Vn.prototype,Function.prototype);for(let[e,n]of Object.entries(xe))on[e]={get(){let r=Ir(this,wo(n.open,n.close,this[rn]),this[Gn]);return Object.defineProperty(this,e,{value:r}),r}};on.visible={get(){let e=Ir(this,this[rn],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var yo=(e,n,r,...o)=>e==="rgb"?n==="ansi16m"?xe[r].ansi16m(...o):n==="ansi256"?xe[r].ansi256(xe.rgbToAnsi256(...o)):xe[r].ansi(xe.rgbToAnsi(...o)):e==="hex"?yo("rgb",n,r,...xe.hexToRgb(...o)):xe[r][e](...o),Vc=["rgb","hex","ansi256"];for(let e of Vc){on[e]={get(){let{level:r}=this;return function(...o){let t=wo(yo(e,as[r],"color",...o),xe.color.close,this[rn]);return Ir(this,t,this[Gn])}}};let n="bg"+e[0].toUpperCase()+e.slice(1);on[n]={get(){let{level:r}=this;return function(...o){let t=wo(yo(e,as[r],"bgColor",...o),xe.bgColor.close,this[rn]);return Ir(this,t,this[Gn])}}}}var Yc=Object.defineProperties(()=>{},{...on,level:{enumerable:!0,get(){return this[go].level},set(e){this[go].level=e}}}),wo=(e,n,r)=>{let o,t;return r===void 0?(o=e,t=n):(o=r.openAll+e,t=n+r.closeAll),{open:e,close:n,openAll:o,closeAll:t,parent:r}},Ir=(e,n,r)=>{let o=(...t)=>Xc(o,t.length===1?""+t[0]:t.join(" "));return Object.setPrototypeOf(o,Yc),o[go]=e,o[rn]=n,o[Gn]=r,o},Xc=(e,n)=>{if(e.level<=0||!n)return e[Gn]?"":n;let r=e[rn];if(r===void 0)return n;let{openAll:o,closeAll:t}=r;if(n.includes("\x1B"))for(;r!==void 0;)n=rs(n,r.close,r.open),r=r.parent;let i=n.indexOf(`
44
+ `);return i!==-1&&(n=os(n,t,o,i)),o+n+t};Object.defineProperties(Vn.prototype,on);var qc=Vn(),If=Vn({level:ss?ss.level:0});var m=qc;var $f=process.env.NODE_ENV==="development";var L=process.env.NREMOTE_WORKER_URL||"https://9remote.cc",cs=3e4,ls=500,vo=300,Re={cmdMs:1e3,pendingApprovalMs:3e3,statsMs:5e3,serverReadyIntervalMs:200,serverReadyTimeoutMs:5e3,bgServerReadyTimeoutMs:15e3,bgServerReadyIntervalMs:300},ct={intervalMs:2e3,timeoutMs:12e4,fetchTimeoutMs:5e3,dnsTimeoutMs:2e3,maxLogEntries:80,postReadyHoldMs:2e3},ne={killCloudflaredMs:500,killCloudflaredTuiMs:300,serverBootMs:2e3,guestRecheckMs:3e3,trayReadyMs:1e3,postReadyHoldMs:2e3,bgSpawnFlushMs:400};var Ge={maxLogLines:200,headerWidth:44},kt={checkIntervalMs:36e5,connectCheckDebounceMs:9e5,maxRetry:3,retryDelayMs:3e3,verifyTimeoutMs:15e3,lockTtlMs:3e5,lockFile:"update.lock",gateTimeoutMs:6e4},us=5e3,Eo=12e4,Lr=1500,fs=2,ps=3e4,de={orange:m.rgb(230,138,110),orangeDim:m.rgb(200,120,95)};function ds(){return process.env.CODESPACES==="true"}var Qc=So.default.dirname((0,hs.fileURLToPath)(__importMetaUrl));async function lt(){let e=await Yt();if(ds()&&process.env.NREMOTE_API_KEY)return je(e,process.env.NREMOTE_API_KEY,"Codespace");let n=Bn();if(n.key)gi(n.key)&&(n=await Jc(e,n));else{let r=Tt(e);n=je(e,r,"Default")}return n}async function Jc(e,n){if(await V())return n;let r=Tt(e);if(W().remoteEnabled===!1)return je(e,r,n.name||"Default");await xt(r,L,null,n.key);let o=Bn();return no(o.key)?o:je(e,r,n.name||"Default")}function Me(){return"3.0.32"}var J=require("fs"),ks=require("url"),qn=require("child_process"),ke=x(require("path"),1),_t=x(require("os"),1);var sn=x(require("fs"),1),bo=x(require("path"),1),gs=x(require("os"),1),ys=require("child_process"),_r=bo.default.join(gs.default.homedir(),".9remote","pids");function Zc(){try{sn.default.existsSync(_r)||sn.default.mkdirSync(_r,{recursive:!0})}catch{}}function To(e){return bo.default.join(_r,`${e}.pid`)}function Ce(e,n){if(n)try{Zc(),sn.default.writeFileSync(To(e),String(n))}catch{}}function Yn(e){try{let n=sn.default.readFileSync(To(e),"utf8").trim(),r=parseInt(n,10);return Number.isFinite(r)&&r>0?r:null}catch{return null}}function Ve(e){try{sn.default.unlinkSync(To(e))}catch{}}function Ao(e){if(!e)return!1;try{return process.kill(e,0),!0}catch{return!1}}function zc(e){let n=Yn(e);if(Ve(e),!n)return!1;try{process.platform==="win32"?(0,ys.execSync)(`taskkill /F /T /PID ${n}`,{stdio:"ignore",windowsHide:!0}):process.kill(n,"SIGKILL")}catch{}return!0}var el=["cloudflared","agent"];function ws(){for(let e of el)zc(e)}function vs(){return _r}var It=require("child_process"),N=require("fs"),Pt=require("path"),Ro=x(require("os"),1),Ot=x(require("path"),1),Ss=require("url");var Mr=(0,Pt.join)(X.LOGS,"autostart.log"),$r="cc.9remote.agent",Cr="9Remote",Nr=["--tray","--skip-update","--start"],Xn=Ro.default.homedir(),Es=Ot.default.dirname((0,Ss.fileURLToPath)(__importMetaUrl)),re={darwin:(0,Pt.join)(Xn,"Library","LaunchAgents",`${$r}.plist`),linux:(0,Pt.join)(Xn,".config","autostart",`${$r}.desktop`),linuxSystemd:(0,Pt.join)(Xn,".config","systemd","user",`${$r}.service`),win:(0,Pt.join)(process.env.APPDATA||"","Microsoft","Windows","Start Menu","Programs","Startup",`${Cr}.vbs`)};function ut(){for(let e=Es,n=null;e!==n;n=e,e=Ot.default.dirname(e)){let r=Ot.default.join(e,"package.json");if((0,N.existsSync)(r)){try{let o=JSON.parse((0,N.readFileSync)(r,"utf8"));if(o.name!==ae)continue;let t=typeof o.bin=="string"?o.bin:o.bin?.[ae];if(t){let i=Ot.default.resolve(e,t);if((0,N.existsSync)(i))return i}}catch{}break}}return process.argv[1]||Ot.default.resolve(Es,"..","index.js")}function Ne(){return process.execPath}function bs(){return process.versions.electron?"env ELECTRON_RUN_AS_NODE=1 ":""}function Ts(e){let n=Ne(),r=ut();if(process.platform==="win32"){let t=e.join(" "),i=(0,Pt.join)(Ro.default.tmpdir(),`${ae}-launch.vbs`);return(0,N.writeFileSync)(i,`CreateObject("WScript.Shell").Run """${n}"" ""${r}"" ${t}", 0, False
45
+ `),(0,It.execFile)("wscript.exe",[i],{windowsHide:!0}).unref?.(),null}let o=(0,It.spawn)(n,[r,...e],{detached:!0,stdio:"ignore"});return o.unref(),o.pid||null}function As(){let e=Ot.default.dirname(Ne()),n=["/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin","/opt/homebrew/bin"];return n.includes(e)||n.unshift(e),n.join(":")}function xo(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function tl(e,n){let r=[e,n,...Nr].map(o=>` <string>${xo(o)}</string>`).join(`
46
46
  `);return`<?xml version="1.0" encoding="UTF-8"?>
47
47
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
48
48
  <plist version="1.0">
49
49
  <dict>
50
50
  <key>Label</key>
51
- <string>${Ir}</string>
51
+ <string>${$r}</string>
52
52
  <key>ProgramArguments</key>
53
53
  <array>
54
54
  ${r}
@@ -60,45 +60,45 @@ ${r}
60
60
  <key>EnvironmentVariables</key>
61
61
  <dict>
62
62
  <key>PATH</key>
63
- <string>${So(Ss())}</string>
63
+ <string>${xo(As())}</string>
64
64
  <key>HOME</key>
65
- <string>${So(Gn)}</string>
65
+ <string>${xo(Xn)}</string>
66
66
  </dict>
67
67
  <key>StandardOutPath</key>
68
- <string>${Lr}</string>
68
+ <string>${Mr}</string>
69
69
  <key>StandardErrorPath</key>
70
- <string>${Lr}</string>
70
+ <string>${Mr}</string>
71
71
  </dict>
72
72
  </plist>
73
- `}function Qc(){return(0,N.existsSync)(re.darwin)}function Jc(){let e=Mr.join(" ");return`Set WshShell = CreateObject("WScript.Shell")
74
- WshShell.Run """${Ce()}"" ""${ct()}"" ${e}", 0, False
75
- `}function Zc(){try{(0,Pt.execFileSync)("reg",["DELETE","HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run","/V",_r,"/F"],{windowsHide:!0,stdio:"ignore"})}catch{}}function zc(){return(0,N.existsSync)(re.win)}function el(){let e=`${Ce()} ${ct()} ${Mr.join(" ")}`;return`[Desktop Entry]
73
+ `}function nl(){return(0,N.existsSync)(re.darwin)}function rl(){let e=Nr.join(" ");return`Set WshShell = CreateObject("WScript.Shell")
74
+ WshShell.Run """${Ne()}"" ""${ut()}"" ${e}", 0, False
75
+ `}function ol(){try{(0,It.execFileSync)("reg",["DELETE","HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run","/V",Cr,"/F"],{windowsHide:!0,stdio:"ignore"})}catch{}}function il(){return(0,N.existsSync)(re.win)}function sl(){let e=`${Ne()} ${ut()} ${Nr.join(" ")}`;return`[Desktop Entry]
76
76
  Type=Application
77
- Name=${_r}
77
+ Name=${Cr}
78
78
  Exec=${e}
79
79
  X-GNOME-Autostart-enabled=true
80
80
  NoDisplay=false
81
81
  Terminal=false
82
- `}function tl(){let e=Mr.map(t=>`'${t}'`).join(" ");return`[Unit]
83
- Description=${_r} Host
82
+ `}function al(){let e=Nr.map(n=>`'${n}'`).join(" ");return`[Unit]
83
+ Description=${Cr} Host
84
84
  After=network-online.target
85
85
  Wants=network-online.target
86
86
 
87
87
  [Service]
88
88
  Type=simple
89
- ExecStart=${Ce()} ${ct()} ${e}
89
+ ExecStart=${Ne()} ${ut()} ${e}
90
90
  Restart=always
91
91
  RestartSec=10
92
- Environment=PATH=${Ss()}
93
- Environment=HOME=${Gn}
94
- StandardOutput=append:${Lr}
95
- StandardError=append:${Lr}
92
+ Environment=PATH=${As()}
93
+ Environment=HOME=${Xn}
94
+ StandardOutput=append:${Mr}
95
+ StandardError=append:${Mr}
96
96
 
97
97
  [Install]
98
98
  WantedBy=default.target
99
- `}function nl(e){try{return(0,Pt.execFileSync)("systemctl",["--user",...e],{stdio:"ignore"}),!0}catch{return!1}}function rl(){return(0,N.existsSync)(re.linux)||(0,N.existsSync)(re.linuxSystemd)}async function ol(){try{if(process.platform==="darwin")return Qc();if(process.platform==="win32")return await zc();if(process.platform==="linux")return rl()}catch{}return!1}async function Ts(){try{if(process.platform==="win32"&&Zc(),!await ol())return!1;if(process.platform==="darwin"){let e=qc(Ce(),ct());return((0,N.existsSync)(re.darwin)?(0,N.readFileSync)(re.darwin,"utf8"):"")===e?!1:((0,N.writeFileSync)(re.darwin,e),!0)}if(process.platform==="win32"){let e=Jc();return((0,N.existsSync)(re.win)?(0,N.readFileSync)(re.win,"utf8"):"")===e?!1:((0,N.writeFileSync)(re.win,e),!0)}if(process.platform==="linux"){if((0,N.existsSync)(re.linuxSystemd)){let e=tl();return(0,N.readFileSync)(re.linuxSystemd,"utf8")===e?!1:((0,N.writeFileSync)(re.linuxSystemd,e),nl(["daemon-reload"]),!0)}if((0,N.existsSync)(re.linux)){let e=el();return(0,N.readFileSync)(re.linux,"utf8")===e?!1:((0,N.writeFileSync)(re.linux,e),!0)}}}catch{}return!1}var rn=B("update"),il=xe.default.dirname((0,As.fileURLToPath)(__importMetaUrl)),xs=8e3;var Ot=2208,bo=xe.default.join(It.default.homedir(),".9remote","cloudflared.pid");function sl(){try{hs()}catch{}try{if((0,J.existsSync)(bo)){let e=parseInt((0,J.readFileSync)(bo,"utf8"));if(Number.isFinite(e))try{process.kill(e)}catch{}try{(0,J.unlinkSync)(bo)}catch{}}}catch{}try{process.platform==="win32"?(0,Vn.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${Ot}') do taskkill /F /PID %a`,{stdio:"ignore",windowsHide:!0}):(0,Vn.execSync)(`lsof -ti:${Ot} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}if(process.platform==="win32"){let e=Date.now()+1500;for(;Date.now()<e;);}}function Rs(){return"3.0.30"}function ks(e,t){let r=e.split(".").map(Number),o=t.split(".").map(Number);for(let n=0;n<3;n++){if(o[n]>r[n])return!0;if(o[n]<r[n])return!1}return!1}function al(){return process.env.CODESPACES==="true"||process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN?"GitHub Codespaces":(0,J.existsSync)("/.dockerenv")?"Docker":null}function $r(){sl()}async function Ps(){try{let e=Rs();if(!e)return null;let t=await H(qr,{signal:AbortSignal.timeout(xs)});if(!t.ok)return null;let{version:r}=await t.json();return r&&ks(e,r)?{current:e,latest:r}:null}catch{return null}}var Cr=xe.default.join(V.STATE,xt.lockFile);function cl(){try{if((0,J.existsSync)(Cr)){let{pid:e,ts:t}=JSON.parse((0,J.readFileSync)(Cr,"utf8")),r=Date.now()-t<xt.lockTtlMs,o=!1;try{process.kill(e,0),o=!0}catch{}if(r&&o)return!1}}catch{}try{(0,J.writeFileSync)(Cr,JSON.stringify({pid:process.pid,ts:Date.now()}))}catch{}return!0}async function ll(){try{let e=await H(qr,{signal:AbortSignal.timeout(xs)});if(!e.ok)return null;let{version:t}=await e.json();return t||null}catch{return null}}function ul(){try{if(process.env.NREMOTE_REGISTRY)return`--registry ${new URL(process.env.NREMOTE_REGISTRY).origin}`}catch{}return""}function fl(){let e=ct(),t=xe.default.sep,r=`${t}lib${t}node_modules${t}`,o=e.indexOf(r);return o>0?{global:"-g",prefix:`--prefix "${e.slice(0,o)}"`}:(o=e.indexOf(`${t}node_modules${t}`),o>0?{global:"",prefix:`--prefix "${e.slice(0,o)}"`}:{global:"-g",prefix:""})}function bs(){let e=process.argv.slice(2).filter(n=>n!=="--skip-update"),r=e.includes("ui")||e.includes("start")||e.some(n=>["--tray","--auto","--start"].includes(n))?e.join(" "):"--tray";return`${r.includes("--start")||r.includes("start")?r:`${r} --start`} --skip-update`}function pl(){let e=process.env.NREMOTE_NPM_CLI;return e&&(0,J.existsSync)(e)?process.platform==="win32"?`"${Ce()}" "${e}"`:`env ELECTRON_RUN_AS_NODE=1 "${Ce()}" "${e}"`:"npm"}function dl(e,t){let r=xe.default.join(It.default.tmpdir(),`${ie}-gate.cjs`),o=`const http = require("http");
99
+ `}function cl(e){try{return(0,It.execFileSync)("systemctl",["--user",...e],{stdio:"ignore"}),!0}catch{return!1}}function ll(){return(0,N.existsSync)(re.linux)||(0,N.existsSync)(re.linuxSystemd)}async function ul(){try{if(process.platform==="darwin")return nl();if(process.platform==="win32")return await il();if(process.platform==="linux")return ll()}catch{}return!1}async function xs(){try{if(process.platform==="win32"&&ol(),!await ul())return!1;if(process.platform==="darwin"){let e=tl(Ne(),ut());return((0,N.existsSync)(re.darwin)?(0,N.readFileSync)(re.darwin,"utf8"):"")===e?!1:((0,N.writeFileSync)(re.darwin,e),!0)}if(process.platform==="win32"){let e=rl();return((0,N.existsSync)(re.win)?(0,N.readFileSync)(re.win,"utf8"):"")===e?!1:((0,N.writeFileSync)(re.win,e),!0)}if(process.platform==="linux"){if((0,N.existsSync)(re.linuxSystemd)){let e=al();return(0,N.readFileSync)(re.linuxSystemd,"utf8")===e?!1:((0,N.writeFileSync)(re.linuxSystemd,e),cl(["daemon-reload"]),!0)}if((0,N.existsSync)(re.linux)){let e=sl();return(0,N.readFileSync)(re.linux,"utf8")===e?!1:((0,N.writeFileSync)(re.linux,e),!0)}}}catch{}return!1}var an=B("update"),fl=ke.default.dirname((0,ks.fileURLToPath)(__importMetaUrl)),Ps=8e3;var Lt=2208,ko=ke.default.join(_t.default.homedir(),".9remote","cloudflared.pid");function pl(){try{ws()}catch{}try{if((0,J.existsSync)(ko)){let e=parseInt((0,J.readFileSync)(ko,"utf8"));if(Number.isFinite(e))try{process.kill(e)}catch{}try{(0,J.unlinkSync)(ko)}catch{}}}catch{}try{process.platform==="win32"?(0,qn.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${Lt}') do taskkill /F /PID %a`,{stdio:"ignore",windowsHide:!0}):(0,qn.execSync)(`lsof -ti:${Lt} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}if(process.platform==="win32"){let e=Date.now()+1500;for(;Date.now()<e;);}}function Os(){return"3.0.32"}function Is(e,n){let r=e.split(".").map(Number),o=n.split(".").map(Number);for(let t=0;t<3;t++){if(o[t]>r[t])return!0;if(o[t]<r[t])return!1}return!1}function dl(){return process.env.CODESPACES==="true"||process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN?"GitHub Codespaces":(0,J.existsSync)("/.dockerenv")?"Docker":null}function Br(){pl()}async function Ls(){try{let e=Os();if(!e)return null;let n=await H(zr,{signal:AbortSignal.timeout(Ps)});if(!n.ok)return null;let{version:r}=await n.json();return r&&Is(e,r)?{current:e,latest:r}:null}catch{return null}}var Dr=ke.default.join(X.STATE,kt.lockFile);function ml(){try{if((0,J.existsSync)(Dr)){let{pid:e,ts:n}=JSON.parse((0,J.readFileSync)(Dr,"utf8")),r=Date.now()-n<kt.lockTtlMs,o=!1;try{process.kill(e,0),o=!0}catch{}if(r&&o)return!1}}catch{}try{(0,J.writeFileSync)(Dr,JSON.stringify({pid:process.pid,ts:Date.now()}))}catch{}return!0}async function hl(){try{let e=await H(zr,{signal:AbortSignal.timeout(Ps)});if(!e.ok)return null;let{version:n}=await e.json();return n||null}catch{return null}}function gl(){try{if(process.env.NREMOTE_REGISTRY)return`--registry ${new URL(process.env.NREMOTE_REGISTRY).origin}`}catch{}return""}function yl(){let e=ut(),n=ke.default.sep,r=`${n}lib${n}node_modules${n}`,o=e.indexOf(r);return o>0?{global:"-g",prefix:`--prefix "${e.slice(0,o)}"`}:(o=e.indexOf(`${n}node_modules${n}`),o>0?{global:"",prefix:`--prefix "${e.slice(0,o)}"`}:{global:"-g",prefix:""})}function Rs(){let e=process.argv.slice(2).filter(t=>t!=="--skip-update"),r=e.includes("ui")||e.includes("start")||e.some(t=>["--tray","--auto","--start"].includes(t))?e.join(" "):"--tray";return`${r.includes("--start")||r.includes("start")?r:`${r} --start`} --skip-update`}function wl(){let e=process.env.NREMOTE_NPM_CLI;return e&&(0,J.existsSync)(e)?process.platform==="win32"?`"${Ne()}" "${e}"`:`env ELECTRON_RUN_AS_NODE=1 "${Ne()}" "${e}"`:"npm"}function vl(e,n){let r=ke.default.join(_t.default.tmpdir(),`${ae}-gate.cjs`),o=`const http = require("http");
100
100
  const PORT = ${e};
101
- const EXIT_MS = ${t};
101
+ const EXIT_MS = ${n};
102
102
  const HTML = '<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>9Remote</title><style>body{margin:0;height:100vh;display:flex;align-items:center;justify-content:center;background:#101218;color:#c9ced6;font-family:system-ui,-apple-system,sans-serif}.spin{width:26px;height:26px;border:3px solid #2a2f3a;border-top-color:#e68a6e;border-radius:50%;animation:r 1s linear infinite;margin:0 auto 14px}@keyframes r{to{transform:rotate(360deg)}}</style></head><body><div><div class="spin"></div><div>9Remote is updating\u2026</div></div><script>setInterval(function(){fetch("/api/health",{cache:"no-store"}).then(function(r){if(r.ok)location.reload()}).catch(function(){})},1500)</script></body></html>';
103
103
  function handler(req, res) {
104
104
  if (req.url.startsWith("/api/health")) { res.writeHead(503, { "Content-Type": "text/plain" }); return res.end("updating"); }
@@ -115,7 +115,7 @@ function bind(host, attempt) {
115
115
  bind("127.0.0.1", 0);
116
116
  bind("::1", 0);
117
117
  setTimeout(() => process.exit(0), EXIT_MS);
118
- `;return(0,J.writeFileSync)(r,o),r}function ml({currentVersion:e,latest:t,agentPid:r}){let o=gs(),n=ul(),i=Ce(),s=dl(Ot,xt.gateTimeoutMs),a=vs(),c=ct(),l=Cr,{global:u,prefix:f}=fl(),p=`${u} --prefer-online --no-audit --no-fund ${n} ${f}`.trim(),d=pl();if(process.platform==="win32"){let E=xe.default.join(It.default.tmpdir(),`${ie}-restart.vbs`),O=`@echo off
118
+ `;return(0,J.writeFileSync)(r,o),r}function El({currentVersion:e,latest:n,agentPid:r}){let o=vs(),t=gl(),i=Ne(),s=vl(Lt,kt.gateTimeoutMs),a=bs(),c=ut(),l=Dr,{global:u,prefix:f}=yl(),p=`${u} --prefer-online --no-audit --no-fund ${t} ${f}`.trim(),d=wl();if(process.platform==="win32"){let E=ke.default.join(_t.default.tmpdir(),`${ae}-restart.vbs`),O=`@echo off
119
119
  setlocal EnableDelayedExpansion
120
120
  set "NODE=${i}"
121
121
  set "CLI=${c}"
@@ -134,7 +134,7 @@ for %%N in (cloudflared agent) do (
134
134
  del /f /q "${o}\\%%N.pid" >nul 2>&1
135
135
  )
136
136
  )
137
- for /f "tokens=5" %%a in ('netstat -aon ^| findstr :${Ot}') do taskkill /F /PID %%a >nul 2>&1
137
+ for /f "tokens=5" %%a in ('netstat -aon ^| findstr :${Lt}') do taskkill /F /PID %%a >nul 2>&1
138
138
  timeout /t 3 /nobreak >nul
139
139
 
140
140
  REM Loading gate: hold the port with an updating page during reinstall
@@ -143,10 +143,10 @@ start "" /b "%NODE%" "${s}"
143
143
  set ATTEMPT=0
144
144
  :installloop
145
145
  set /a ATTEMPT+=1
146
- call ${d} install ${Ue} ${p} >nul 2>&1
146
+ call ${d} install ${Ke} ${p} >nul 2>&1
147
147
  if !ERRORLEVEL! EQU 0 goto verify
148
- if !ATTEMPT! GEQ ${xt.maxRetry} (
149
- call ${d} install ${Ue} ${p} --omit=optional >nul 2>&1
148
+ if !ATTEMPT! GEQ ${kt.maxRetry} (
149
+ call ${d} install ${Ke} ${p} --omit=optional >nul 2>&1
150
150
  goto verify
151
151
  )
152
152
  timeout /t 3 /nobreak >nul
@@ -154,7 +154,7 @@ goto installloop
154
154
 
155
155
  :verify
156
156
  set "NEWVER="
157
- set "VERFILE=%TEMP%\\${ie}-ver.txt"
157
+ set "VERFILE=%TEMP%\\${ae}-ver.txt"
158
158
  "%NODE%" "%CLI%" --version > "%VERFILE%" 2>nul
159
159
  REM Read first line + strip surrounding whitespace/CR via for/f tokens
160
160
  for /f "usebackq tokens=* delims= " %%V in ("%VERFILE%") do (
@@ -164,19 +164,19 @@ for /f "usebackq tokens=* delims= " %%V in ("%VERFILE%") do (
164
164
  :gotver
165
165
  del /f /q "%VERFILE%" >nul 2>&1
166
166
  if defined NEWVER set "NEWVER=!NEWVER: =!"
167
- if not "!NEWVER!"=="${t}" (
168
- call ${d} install ${ie}@${e} ${p} >nul 2>&1
167
+ if not "!NEWVER!"=="${n}" (
168
+ call ${d} install ${ae}@${e} ${p} >nul 2>&1
169
169
  )
170
170
  del /f /q "${l}" >nul 2>&1
171
171
 
172
172
  REM Free the port for the new agent (kills the loading gate)
173
- for /f "tokens=5" %%a in ('netstat -aon ^| findstr :${Ot}') do taskkill /F /PID %%a >nul 2>&1
173
+ for /f "tokens=5" %%a in ('netstat -aon ^| findstr :${Lt}') do taskkill /F /PID %%a >nul 2>&1
174
174
  timeout /t 1 /nobreak >nul
175
175
 
176
176
  wscript "${E}"
177
177
  exit /b 0
178
- `,T=xe.default.join(It.default.tmpdir(),`${ie}-update.bat`);(0,J.writeFileSync)(T,O),(0,J.writeFileSync)(E,`CreateObject("WScript.Shell").Run """%NODE%"" ""%CLI%"" ${bs()}", 0, False`.replace("%NODE%",i).replace("%CLI%",c)+`
179
- `);let A=xe.default.join(It.default.tmpdir(),`${ie}-update.vbs`);return(0,J.writeFileSync)(A,`CreateObject("WScript.Shell").Run "cmd /c ""${T}""", 0, False
178
+ `,b=ke.default.join(_t.default.tmpdir(),`${ae}-update.bat`);(0,J.writeFileSync)(b,O),(0,J.writeFileSync)(E,`CreateObject("WScript.Shell").Run """%NODE%"" ""%CLI%"" ${Rs()}", 0, False`.replace("%NODE%",i).replace("%CLI%",c)+`
179
+ `);let A=ke.default.join(_t.default.tmpdir(),`${ae}-update.vbs`);return(0,J.writeFileSync)(A,`CreateObject("WScript.Shell").Run "cmd /c ""${b}""", 0, False
180
180
  `),{shellCmd:["wscript.exe",[A]],windowsVerbatim:!1}}let h=`#!/bin/bash
181
181
  # Wait for agent to exit so it releases the cli.cjs file lock
182
182
  while kill -0 ${r} 2>/dev/null; do sleep 1; done
@@ -190,19 +190,19 @@ for name in cloudflared agent; do
190
190
  rm -f "$f"
191
191
  fi
192
192
  done
193
- lsof -ti:${Ot} | xargs kill -9 2>/dev/null || true
193
+ lsof -ti:${Lt} | xargs kill -9 2>/dev/null || true
194
194
  sleep 2
195
195
 
196
196
  # Loading gate holds the port so webview reloads show "updating", not black
197
197
  (${a}"${i}" "${s}" >/dev/null 2>&1 &)
198
198
 
199
199
  attempt=0
200
- while [ $attempt -lt ${xt.maxRetry} ]; do
200
+ while [ $attempt -lt ${kt.maxRetry} ]; do
201
201
  attempt=$((attempt+1))
202
202
  echo "Installing (attempt $attempt)..."
203
- if ${d} install ${Ue} ${p}; then break; fi
204
- if [ $attempt -eq ${xt.maxRetry} ]; then
205
- ${d} install ${Ue} ${p} --omit=optional || true
203
+ if ${d} install ${Ke} ${p}; then break; fi
204
+ if [ $attempt -eq ${kt.maxRetry} ]; then
205
+ ${d} install ${Ke} ${p} --omit=optional || true
206
206
  fi
207
207
  sleep 3
208
208
  done
@@ -210,85 +210,105 @@ done
210
210
  # Verify version == latest; roll back if the new binary is broken/wrong (R2)
211
211
  # Take first line + strip ANSI escapes so trailing cursor codes don't corrupt compare
212
212
  NEWVER=$(${a}"${i}" "${c}" --version 2>/dev/null | head -1 | sed 's/\x1B[[0-9;?]*[a-zA-Z]//g' | tr -d '[:space:]')
213
- if [ "$NEWVER" != "${t}" ]; then
214
- echo "Verify failed (got $NEWVER, want ${t}), rolling back to ${e}..."
215
- ${d} install ${ie}@${e} ${p} || true
213
+ if [ "$NEWVER" != "${n}" ]; then
214
+ echo "Verify failed (got $NEWVER, want ${n}), rolling back to ${e}..."
215
+ ${d} install ${ae}@${e} ${p} || true
216
216
  fi
217
217
 
218
218
  # Free the port for the new agent (kills the loading gate)
219
- lsof -ti:${Ot} | xargs kill -9 2>/dev/null || true
219
+ lsof -ti:${Lt} | xargs kill -9 2>/dev/null || true
220
220
  sleep 1
221
221
 
222
222
  rm -f "${l}"
223
223
  ${process.env.NREMOTE_REGISTRY?`export NREMOTE_REGISTRY="${process.env.NREMOTE_REGISTRY}"
224
- `:""}${a}"${i}" "${c}" ${bs()}
225
- `,w=xe.default.join(It.default.tmpdir(),`${ie}-update.sh`);return(0,J.writeFileSync)(w,h,{mode:493}),{shellCmd:["sh",[w]],windowsVerbatim:!1}}async function Os(){let e=Rs();if(!e)return rn.warn("update skipped: no version (source run?)"),!1;let t=al();if(t)return rn.warn(`update skipped: restricted env (${t})`),!1;let r=await ll();if(!r)return rn.warn("update skipped: registry unreachable"),!1;if(!ks(e,r))return rn.info(`update skipped: ${e} >= registry ${r}`),!1;if(!cl())return rn.warn("update skipped: lock held by another run"),!1;rn.info(`update go: ${e} -> ${r}`);let{shellCmd:o,windowsVerbatim:n}=ml({currentVersion:e,latest:r,agentPid:process.pid});return(0,Vn.spawn)(o[0],o[1],{detached:!0,stdio:"ignore",windowsHide:!0,windowsVerbatimArguments:n}).unref(),setTimeout(()=>process.exit(0),500),!0}var sr=require("child_process"),ar=R(require("path"),1),Ko=R(require("fs"),1),ca=require("url");var W=R(require("fs"),1),ut=R(require("path"),1),Co=R(require("https"),1),ft=R(require("os"),1),Ks=R(require("net"),1),Ye=require("child_process");var Is=R(require("dns"),1),Ls=require("child_process");var hl=2e3,gl=5e3,Ao=new Is.default.promises.Resolver;Ao.setServers(["1.1.1.1","1.0.0.1","8.8.8.8"]);function on(){process.platform==="win32"&&(0,Ls.execFile)("ipconfig",["/flushdns"],{windowsHide:!0},()=>{})}async function xo(e,t=hl){let r=Date.now();try{let o=async()=>{let[i,s]=await Promise.allSettled([Ao.resolve4(e),Ao.resolve6(e)]);if(i.status==="fulfilled"&&i.value?.length)return i.value;if(s.status==="fulfilled"&&s.value?.length)return s.value;throw i.reason||s.reason||Object.assign(new Error("DNS query failed"),{code:"ENOTFOUND"})};return{ok:!0,addrs:await Promise.race([o(),new Promise((i,s)=>setTimeout(()=>s(Object.assign(new Error("DNS timeout"),{code:"ETIMEOUT"})),t))]),elapsedMs:Date.now()-r}}catch(o){return{ok:!1,code:o.code||o.message,elapsedMs:Date.now()-r}}}async function sn(e,{flushDns:t=!1}={}){let r=Date.now(),o=null;try{o=new URL(e).hostname}catch{}if(t&&on(),o){let n=await xo(o);if(!n.ok)return on(),{ok:!1,dnsCode:n.code,elapsedMs:Date.now()-r}}try{let n=await H(`${e}/api/health`,{signal:AbortSignal.timeout(gl)});return{ok:n.ok,httpStatus:n.status,elapsedMs:Date.now()-r}}catch(n){return{ok:!1,dnsCode:n.cause?.code||n.code||n.message,elapsedMs:Date.now()-r}}}var yl=B("tunnel"),Yn=null,Xn=null,an=null,Lt=null,lt=0,ko=!1;async function Po(e){try{let t=await zt();await fetch(`http://${t}:${P}/api/ui/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch{}}var Ro=!1;async function _s(){if(!(!Xn||ko||Ro)){Ro=!0;try{await wl()}finally{Ro=!1}}}async function wl(){let e=await sn(Xn),t=e.ok?"healthy":"unreachable";if(t===an){Lt=null,lt=0;return}if(t!==Lt){Lt=t,lt=1;return}lt++,!(lt<cs)&&(yl.info(`${an??"init"} \u2192 ${t}${e.ok?"":` (http=${e.httpStatus??"-"} dns=${e.dnsCode??"-"})`}`),an=t,Lt=null,lt=0,await Po({tunnelHealth:{status:t,checkedAt:Date.now()}}))}function Ms(e){if(!e)return qn();e!==Xn&&(Xn=e,an=null,Lt=null,lt=0,on(),Yn||(Yn=setInterval(_s,ii.checkIntervalMs)),_s())}var Cs=Ms,cn=Ms;function $s(){ko=!0}function Ns(){ko=!1}function _t(e){an=e,Lt=null,lt=0,Po({tunnelHealth:{status:e,checkedAt:Date.now()}})}function qn(){Yn&&(clearInterval(Yn),Yn=null),Xn=null,an=null,Lt=null,lt=0,Po({tunnelHealth:{status:"unknown",checkedAt:null}})}var z=B("tunnel"),Ge={networkCheckIntervalMs:5e3,networkRestoreDelayMs:2500,internetCheckTimeoutMs:3e3,internetCheckHost:"1.1.1.1",internetCheckPort:443,edgeProbeIntervalMs:15e3,edgeProbeFailureThreshold:3,readyTimeoutMs:1500},vl=[20241,20242,20243,20244,20245],fn=null;async function El(e,t){try{let o=await(await fetch(`http://localhost:${e}/ready`,{signal:AbortSignal.timeout(t)})).json();return typeof o?.readyConnections=="number"?o:null}catch{return null}}async function Ds(e,t){let r=await El(e,t);if(!r)return null;let o=await Tl(e,t);return o&&we&&!we.includes(o)?null:r.readyConnections}async function Sl(e){if(fn!==null){let o=await Ds(fn,e);if(o!==null)return o;fn=null}let r=(await Promise.all(vl.map(async o=>({port:o,conns:await Ds(o,e)})))).find(o=>o.conns!==null);return r?(fn=r.port,r.conns):null}async function Tl(e,t){try{return(await(await fetch(`http://localhost:${e}/quicktunnel`,{signal:AbortSignal.timeout(t)})).json())?.hostname||null}catch{return null}}var bl=3e4,Oo=0,Zn=null,Nr=null,pn=null,tr=null,dn=!1,Qn=0,Mo=!1,we=null,mn=0,Io=0,Lo=!1,nr=0,Ve=0,Bs=3e4,Al=5e3,Jn=ut.default.join(ft.default.homedir(),".9remote","bin"),Us="cloudflared",hn=ft.default.platform()==="win32",xl=hn?`${Us}.exe`:Us,ln=ut.default.join(Jn,xl),_o=ut.default.join(ft.default.homedir(),".9remote","cloudflared.pid"),zn=!1,un=null,Rl="2026.6.1",Hs=`https://github.com/cloudflare/cloudflared/releases/download/${Rl}`;function Ws(){return new Promise(e=>{let t=new Ks.default.Socket,r=!1,o=n=>{if(!r){r=!0;try{t.destroy()}catch{}e(n)}};t.setTimeout(Ge.internetCheckTimeoutMs),t.once("connect",()=>o(!0)),t.once("timeout",()=>o(!1)),t.once("error",()=>o(!1));try{t.connect(Ge.internetCheckPort,Ge.internetCheckHost)}catch{o(!1)}})}async function kl(){Mo=!0;try{let e=0;for(;;){if(e++,await Ws())return;await new Promise(t=>setTimeout(t,Te(de.internet,e)))}}finally{Mo=!1}}async function er(e,t){if(!tr){z.warn("No restartCallback registered \u2014 skip");return}if(!dn&&!(Date.now()-Io<Al)){Io=Date.now(),dn=!0;try{await kl();let r=Te(de.tunnelRestart,Qn+1);await new Promise(o=>setTimeout(o,r)),await tr(e),Qn=0,Io=0}catch(r){Qn++,z.error(`restart failed (#${Qn}): ${r?.message||r}`),setImmediate(()=>{dn=!1,er(e,"retry after fail")});return}finally{dn=!1}}}var Pl={darwin:{x64:"cloudflared-darwin-amd64.tgz",arm64:"cloudflared-darwin-arm64.tgz"},win32:{x64:"cloudflared-windows-amd64.exe"},linux:{x64:"cloudflared-linux-amd64",arm64:"cloudflared-linux-arm64"}};function Ol(){let e=ft.default.platform(),t=ft.default.arch(),r=Pl[e];if(!r)throw new Error(`Unsupported platform: ${e}`);let o=r[t];if(!o)throw new Error(`Unsupported architecture: ${t} for platform ${e}`);return`${Hs}/${o}`}var Il=150;async function js(e,t,r){return new Promise((o,n)=>{let i=W.default.createWriteStream(t);Co.default.get(e,s=>{if([301,302].includes(s.statusCode)){i.close(),W.default.unlinkSync(t),js(s.headers.location,t,r).then(o).catch(n);return}if(s.statusCode!==200){i.close(),W.default.unlinkSync(t),n(new Error(`Download failed with status ${s.statusCode}`));return}let a=parseInt(s.headers["content-length"]||"0",10),c=0,l=0,u=-1;s.on("data",f=>{if(c+=f.length,!r||!a)return;let p=Date.now(),d=Math.min(100,Math.floor(c/a*100));d!==u&&p-l>=Il&&(l=p,u=d,r(d))}),s.pipe(i),i.on("finish",()=>{r&&a&&r(100),i.close(()=>o(t))}),i.on("error",f=>{i.close(),W.default.unlinkSync(t),n(f)})}).on("error",s=>{i.close(),W.default.existsSync(t)&&W.default.unlinkSync(t),n(s)})})}async function rr(e){if(W.default.existsSync(Jn)||W.default.mkdirSync(Jn,{recursive:!0}),W.default.existsSync(ln))return hn||W.default.chmodSync(ln,"755"),ln;let t=Ol(),r=t.endsWith(".tgz"),o=r?ut.default.join(Jn,"cloudflared.tgz"):ln;try{return e?.({phase:"download",percent:0}),await js(t,o,n=>{e?.({phase:"download",percent:n})}),await Ll(t,o),r&&(e?.({phase:"extract"}),(0,Ye.execSync)(`tar -xzf "${o}" -C "${Jn}"`,{stdio:"pipe",windowsHide:!0}),W.default.unlinkSync(o)),hn||W.default.chmodSync(ln,"755"),ln}catch(n){try{W.default.existsSync(o)&&W.default.unlinkSync(o)}catch{}throw console.error("Failed to download cloudflared:",n.message),n}}function Gs(e){return new Promise((t,r)=>{Co.default.get(e,o=>{if([301,302].includes(o.statusCode))return Gs(o.headers.location).then(t).catch(r);if(o.statusCode!==200)return r(new Error(`HTTP ${o.statusCode}`));let n="";o.on("data",i=>n+=i),o.on("end",()=>t(n))}).on("error",r)})}async function Ll(e,t){let r=ut.default.basename(e),o;try{o=await Gs(`${Hs}/sha256sum.txt`)}catch(c){z.warn(`sha256 manifest unavailable (${c.message}), skipping verify`);return}let n=o.split(`
226
- `).find(c=>c.includes(r));if(!n){z.warn(`No sha256 entry for ${r}, skipping verify`);return}let i=n.trim().split(/\s+/)[0],{createHash:s}=await import("crypto"),a=s("sha256").update(W.default.readFileSync(t)).digest("hex");if(a!==i)throw new Error(`Integrity check failed: SHA256 mismatch (expected ${i}, got ${a})`)}function _l(e){let t=/https:\/\/([a-z0-9-]+)\.trycloudflare\.com/gi,r=[];for(let o of e.matchAll(t))o[1]!=="api"&&r.push(`https://${o[1]}.trycloudflare.com`);return r.length?r[r.length-1]:null}async function Xe(e,t=null,r=null){let o=await rr();Nl(o),r&&(tr=r),pn=e;let n=W.default.mkdtempSync(ut.default.join(ft.default.tmpdir(),"9remote-quick-")),i=ut.default.join(n,"config.yml");W.default.writeFileSync(i,`# quick-tunnel
227
- `,"utf8");let s=!1,a=()=>{if(!s){s=!0;try{W.default.rmSync(n,{recursive:!0,force:!0})}catch{}}},c=(0,Ye.spawn)(o,["tunnel","--url",`http://localhost:${e}`,"--config",i,"--no-autoupdate","--protocol","http2"],{detached:!1,windowsHide:!0,stdio:["ignore","pipe","pipe"]});return Me("cloudflared",c.pid),un=c.pid,zn=!1,new Promise((l,u)=>{let f=!1,p=null,d="",h=setTimeout(()=>{if(!f){f=!0,a(),un===c.pid&&(un=null);try{c.kill("SIGKILL")}catch{}je("cloudflared"),u(new Error("Quick tunnel timed out after 90s"))}},9e4),w=E=>{let O=E.toString();d+=O,d.length>4096&&(d=d.slice(-4096));let T=_l(O);if(T){if(!f){f=!0,p=T,we=T,mn=Date.now(),Ve=0,nr=0,fn=null,clearTimeout(h),a(),Ul(),z.info(`tunnel ready: ${T}`),l({child:c,tunnelUrl:T});return}T!==p&&(z.info(`URL rotated: ${T}`),p=T,we=T,mn=Date.now(),Ve=0,nr=0,t?.(T))}};c.stdout.on("data",w),c.stderr.on("data",w),c.on("error",E=>{f||(f=!0,clearTimeout(h),a(),u(E))}),c.on("exit",(E,O)=>{a();let T=un!==c.pid,A=zn||T;if(z.info(`cloudflared exited (intentional=${zn} superseded=${T})`),A||_t("unreachable"),!f){f=!0,clearTimeout(h);let k=d.trim().split(`
228
- `).slice(-5).join(" | ");un=null,u(new Error(`cloudflared exited (code=${E}, signal=${O}) output: ${k||"(empty)"}`));return}A||er(e,`quick tunnel exit code ${E}`)})})}function Dr(e){if(hn)try{(0,Ye.execSync)(`taskkill /PID ${e} /T /F`,{windowsHide:!0,stdio:"ignore"})}catch{}else try{process.kill(e,"SIGKILL")}catch{}}function Ml(e){return e?e.split(`
229
- `).flatMap(t=>{let r=t.match(/^\s*(\d+)\s+(.+)$/);return r?[{pid:Number(r[1]),args:r[2].trim()}]:[]}):[]}function Cl(e,t){return Array.isArray(e)?e.filter(r=>{if(!r?.args||typeof r.pid!="number")return!1;let o=r.args.split(/\s+/);return o.includes(t)&&o.includes("tunnel")}).map(r=>r.pid):[]}function $l(e){try{let t=hn?(0,Ye.execSync)(`powershell -NoProfile -Command "Get-CimInstance Win32_Process -Filter 'Name=\\'cloudflared.exe\\'' | ForEach-Object { \\"$($_.ProcessId) $($_.CommandLine)\\"" }"`,{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}):(0,Ye.execSync)("ps -eo pid=,args=",{encoding:"utf8",stdio:["ignore","pipe","ignore"]});return Cl(Ml(t),e)}catch{return[]}}function Nl(e){let t=$l(e);for(let r of t)r!==process.pid&&(z.info(`killing leftover cloudflared pid=${r}`),Dr(r));return t}function Dl(e){try{let t=[];if(hn){let r=`Get-NetTCPConnection -LocalPort ${e} -State Established -ErrorAction SilentlyContinue | Where-Object { (Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).Name -eq 'cloudflared' } | Select-Object -ExpandProperty OwningProcess -Unique`;t=(0,Ye.execSync)(`powershell -NoProfile -Command "${r}"`,{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}).split(/\r?\n/).map(n=>+n.trim()).filter(Boolean)}else t=(0,Ye.execSync)(`lsof -nP -iTCP:${e} -sTCP:ESTABLISHED 2>/dev/null | awk '/cloudflar/ {print $2}' | sort -u`,{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).split(`
230
- `).map(o=>+o.trim()).filter(Boolean);for(let r of new Set(t))Dr(r)}catch{}}function se(){if(!Lo){Lo=!0;try{try{if(W.default.existsSync(_o)){let t=parseInt(W.default.readFileSync(_o,"utf8"));Number.isFinite(t)&&(zn=!0,Dr(t)),W.default.unlinkSync(_o)}}catch{}let e=jn("cloudflared");zn=!0,un=null,e&&(Dr(e),je("cloudflared")),Dl(P)}finally{setTimeout(()=>{Lo=!1},2e3)}}}function Vs(){if(!we)return!1;let e=jn("cloudflared");return!!e&&Eo(e)}function Ys(){Qn=0,dn=!1,tr=null,pn=null,we=null,Ve=0,nr=0,fn=null,Fl()}var Bl=/^(utun|awdl|llw|anpi|bridge|gif|stf|ipsec|ap|tun|tap|vmnet|veth|docker)/i;function Fs(){let e=ft.default.networkInterfaces(),t=[];for(let[r,o]of Object.entries(e))if(o&&!Bl.test(r))for(let n of o)!n.internal&&n.family==="IPv4"&&t.push(`${r}:${n.address}`);return t.sort().join("|")}function Ul(){Zn||(Nr=Fs(),Oo=Date.now(),Zn=setInterval(async()=>{try{let e=Date.now(),t=e-Oo;if(Oo=e,Mo||dn||!tr||pn==null)return;if(t>bl){if(z.info(`Sleep/wake detected (gap=${t}ms)`),we){let s=!1;for(let a=0;a<3;a++){if((await sn(we)).ok){s=!0;break}a<2&&await new Promise(l=>setTimeout(l,3e3))}if(s)return;z.info("tunnel unresponsive after sleep \u2192 restarting")}_t("unreachable"),se(),er(pn,"woke from sleep");return}let r=Fs(),o=r!==Nr;Nr=r;let n=jn("cloudflared"),i=!n||!Eo(n);if(!o&&!i){if(we&&mn&&Date.now()-mn>Bs&&e-nr>=Ge.edgeProbeIntervalMs){nr=e;let s=await sn(we);if(s.ok)Ve=0;else if(++Ve>=Ge.edgeProbeFailureThreshold){let a=await Sl(Ge.readyTimeoutMs);if(a>0){z.info(`edge probe failing but cloudflared holds ${a} connection(s) \u2014 not restarting`),Ve=0;return}z.warn(`tunnel unreachable but cloudflared alive \u2014 edge lost after ${Ve} probes (ready=${a??"unknown"}), restarting`),Ve=0,_t("unreachable"),se(),er(pn,"tunnel unreachable (edge lost)")}else z.debug(`edge probe failed (${Ve}/${Ge.edgeProbeFailureThreshold}) \u2014 ${s.dnsCode??s.httpStatus??"no response"}`)}return}if(o&&!i&&mn&&Date.now()-mn<Bs||(o&&z.info("Network change detected"),i&&z.warn("cloudflared not alive \u2014 watchdog"),_t("unreachable"),await new Promise(s=>setTimeout(s,Ge.networkRestoreDelayMs)),!await Ws()))return;if(o&&!i&&we){let s=!1;for(let a=0;a<2;a++){if((await sn(we)).ok){s=!0;break}a===0&&await new Promise(l=>setTimeout(l,2e3))}if(s){z.info("Tunnel survived network change, skip restart");return}}o&&!i&&se(),er(pn,o?"network change":"liveness watchdog")}catch(e){z.error(`network monitor tick failed: ${e?.message||e}`)}},Ge.networkCheckIntervalMs))}function Fl(){Zn&&(clearInterval(Zn),Zn=null),Nr=null}$t();async function pt(e,t={}){let r=t.intervalMs??st.intervalMs,o=t.timeoutMs??st.timeoutMs,n=`${e}/api/health`,i=(()=>{try{return new URL(e).hostname}catch{return null}})(),s=Date.now(),a=0,c=[];await K({healthCheck:{running:!0,timeoutMs:o,startedAt:s,logs:[]}});let l=u=>{c.push(u);let f=c.length>st.maxLogEntries?c.slice(-st.maxLogEntries):c;K({healthCheck:{running:!0,timeoutMs:o,startedAt:s,logs:f}})};for(;Date.now()-s<o;){if(a++,on(),i){let f=await xo(i,st.dnsTimeoutMs);if(!f.ok){let p=f.code==="ENOTFOUND"||f.code==="ETIMEOUT"||f.code==="ESERVFAIL",d=p?"connecting...":f.code;Zt(`#${a} \u2192 ${d}`),l({attempt:a,status:d,elapsedMs:f.elapsedMs,ok:!1,waiting:p,time:Date.now()}),await new Promise(h=>setTimeout(h,r));continue}}let u=Date.now();try{let f=await H(n,{signal:AbortSignal.timeout(st.fetchTimeoutMs)}),p=Date.now()-u;if(Zt(`#${a} \u2192 ${f.status}`),l({attempt:a,status:String(f.status),elapsedMs:p,ok:f.ok,time:Date.now()}),f.ok)return await K({healthCheck:{running:!1,timeoutMs:0,startedAt:null,logs:[]}}),await new Promise(d=>setTimeout(d,st.postReadyHoldMs)),!0}catch(f){let p=Date.now()-u,d=f.cause?.code||f.code||f.message,h=d==="ENOTFOUND",w=h?"connecting...":d;Zt(`#${a} \u2192 ${w}`),l({attempt:a,status:w,elapsedMs:p,ok:!1,waiting:h,time:Date.now()})}await new Promise(f=>setTimeout(f,r))}return await K({healthCheck:{running:!1,timeoutMs:o,startedAt:s,logs:c}}),!1}var Qe=B("tunnel"),No=null,oa=null,ia=0;async function Nt(e,t){if(Qe.debug(`updateTunnelUrl: key=${e?.slice(0,8)} url=${t}`),j().remoteEnabled===!1)return;if(Dt(e),t&&t===oa&&Date.now()-ia<as){Qe.debug("updateTunnelUrl: skipped (debounce, same URL)");return}No&&(No.cancelled=!0);let r={cancelled:!1};No=r;let o=Yi();Er({config:de.urlSync,label:`urlSync ${t}`,log:n=>Qe.warn(n),ctx:r,task:async()=>{let n=await H(`${L}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((()=>{let s={apiKey:Y(e),tunnelUrl:t,localIp:o?`${o}:${P}`:null};return{...s,...Tt(s)}})())});if(r.cancelled)return!0;if(n.ok)return oa=t,ia=Date.now(),Qe.debug(`urlSync OK: pushed ${t} to server`),Vl(t),!0;let i=await n.text().catch(()=>"");return Qe.warn(`urlSync HTTP ${n.status}: ${i.slice(0,200)}`),!1}}),t&&Cs(t)}var vn=null,En=null,Do=!1,Uo=0;async function Fo(e,t){let r={apiKey:e,online:t},o=await H(`${L}/api/session/heartbeat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...Tt(r)})});return o.ok||Qe.warn(`heartbeat online=${t} HTTP ${o.status}`),o.ok}async function Bo(){if(!(Do||!En)){Do=!0;try{await Fo(En,!0),Uo=Date.now()}catch(e){Qe.debug(`heartbeat failed: ${e?.message||e}`)}finally{Do=!1}}}function Dt(e){let t=Y(e);if(t&&j().remoteEnabled!==!1){if(vn&&En===t){Date.now()-Uo>=go&&Bo();return}Ur(),En=t,Bo(),vn=setInterval(Bo,go),vn.unref?.()}}function Ur({offline:e=!1}={}){vn&&(clearInterval(vn),vn=null);let t=En;return En=null,Uo=0,!e||!t?null:Fo(t,!1).catch(r=>Qe.debug(`goodbye failed: ${r?.message||r}`))}function dt(e){let t=Y(e);if(!t)return Promise.resolve(!1);Ur();let r=Fo(t,!1).catch(o=>(Qe.debug(`offline mark failed: ${o?.message||o}`),!1));return Promise.race([r,new Promise(o=>setTimeout(()=>o(!1),Pr))])}var ir=null;async function Vl(e){if(ir?.url===e)return;let t={url:e};ir=t,$s();try{let r=await pt(e,{timeoutMs:ls});if(ir!==t)return;r&&_t("healthy")}catch{}finally{ir===t&&(ir=null),Ns()}}var Je=B("server"),la=ar.default.dirname((0,ca.fileURLToPath)(__importMetaUrl)),Yl=ar.default.resolve(la,"./server.cjs"),sa=ar.default.resolve(la,"../../index.js");function Fr(e){try{process.platform==="win32"?(0,sr.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${e}') do taskkill /F /PID %a`,{stdio:"ignore",windowsHide:!0}):(0,sr.execSync)(`lsof -ti:${e} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}}function mt(e,t,r){let o=null,n=!1,i=!1,s=!0,a=0,c=null,l=()=>{s&&(Fr(P),s=!1);let u=process.env.NODE_ENV==="development"&&Ko.default.existsSync(sa),f=u?sa:Yl;Ko.default.existsSync(f)||(Je.error(`Server not found: ${f}`),process.exit(1));let p={...process.env,PORT:String(P)};u||delete p.NODE_ENV,o=(0,sr.spawn)(ei,[f],{cwd:ar.default.dirname(f),stdio:["ignore","inherit","inherit"],detached:!1,windowsHide:!0,env:ti(p)}),c&&clearTimeout(c),c=setTimeout(()=>{a=0},is),o.on("exit",(d,h)=>{if(c&&(clearTimeout(c),c=null),n)return;if(i){i=!1,Je.info("Restarting server (requested)..."),setTimeout(()=>{l(),r?.()},500);return}Je.error(`Server exited unexpectedly (code: ${d}, signal: ${h})`),a++;let w=Te(de.server,a);Je.warn(`Restarting server in ${w}ms (fail#${a})`),t&&t(),setTimeout(()=>{l(),r?.()},w)}),o.on("error",d=>{Je.error(`Server error: ${d.message}`)}),e?.(o)};return l(),{getProcess:()=>o,shutdown:()=>{if(n=!0,!!o){try{o.kill("SIGTERM")}catch{}setTimeout(()=>{try{o&&o.kill("SIGKILL")}catch{}},2e3)}},restart:()=>{if(!o)return!1;i=!0;try{o.kill("SIGTERM")}catch{}return setTimeout(()=>{try{o&&i&&o.kill("SIGKILL")}catch{}},2e3),!0}}}function ua(e){return e?.restart?e.restart():!1}function Ze({serverManager:e,tunnelProcess:t,exit:r=!0,code:o=0}={}){try{qn()}catch{}try{e?.shutdown?.()}catch{}try{t?.kill?.()}catch{}try{se()}catch{}try{Mt()}catch{}try{Fr(P)}catch{}try{Ys()}catch{}try{wi()}catch{}try{je("agent")}catch{}try{je("cloudflared")}catch{}let n=Ur({offline:!0});if(r){let i=new Promise(a=>setTimeout(a,ss)),s=n?Promise.race([n,new Promise(a=>setTimeout(a,Pr))]):null;Promise.all([i,s]).finally(()=>process.exit(o))}}var aa=!1;function ht(e,t){if(aa)return;aa=!0;let r=!1,o=n=>{r||(r=!0,Je.info(`Stopping 9Remote (${n})...`),Ze({serverManager:e,tunnelProcess:t}),Je.info("Server stopped"))};if(process.on("SIGINT",()=>o("SIGINT")),process.on("SIGTERM",()=>o("SIGTERM")),process.on("SIGHUP",()=>o("SIGHUP")),process.platform==="win32"){process.on("SIGBREAK",()=>o("SIGBREAK"));try{import("readline").then(({createInterface:n})=>{n({input:process.stdin,output:process.stdout}).on("SIGINT",()=>o("SIGINT")),process.stdin.isTTY&&process.stdin.unref?.()}).catch(()=>{})}catch{}}process.on("uncaughtException",n=>{Je.error(`Uncaught exception: ${n?.stack||n?.message||n}`),o("uncaughtException"),setTimeout(()=>process.exit(1),ho)}),process.on("unhandledRejection",n=>{Je.error(`Unhandled rejection: ${n?.stack||n?.message||n}`),o("unhandledRejection"),setTimeout(()=>process.exit(1),ho)})}$t();var Bt=B("tunnel");async function Xl(e,t,r,o){let n=0;for(;;){n++;try{return await Xe(e,t,r)}catch(i){let s=Te(de.tunnelSpawn,n);Bt.warn(`spawn attempt ${n} failed: ${i?.message||i} \u2014 retry in ${s}ms`),o?.({attempt:n,delay:s}),await new Promise(a=>setTimeout(a,s))}}}function ze({onUrlUpdate:e,setTunnel:t,onRetry:r}){return async o=>{try{let n=await Xl(o,e,null,r);et(),t(n.child),await e(n.tunnelUrl),Bt.info(`Tunnel restarted: ${n.tunnelUrl}`)}catch(n){Bt.error(`Tunnel restart failed: ${n?.message||n}`)}}}var Kr=null;function et(){Kr&&(Kr.cancelled=!0,Kr=null)}function Sn(e,{onUrlUpdate:t,onRestart:r,setActiveTunnel:o,onReady:n}){et();let i={cancelled:!1};return Kr=i,Er({config:de.tunnelRateLimit,task:async()=>{if(i.cancelled)return!0;if(Vs())return Bt.info("bg-tunnel: a tunnel is already live \u2014 standing down"),!0;let s=await Xe(e,t,r);if(i.cancelled){try{se()}catch{}return!0}try{o?.(s.child),await t?.(s.tunnelUrl),await n?.(s),Bt.info(`bg tunnel up: ${s.tunnelUrl}`)}catch(a){Bt.error(`bg tunnel post-spawn failed: ${a?.message||a}`)}return!0},label:"bg-tunnel",log:s=>Bt.info(s),ctx:i}),i}var Yo=R(Ca(),1);var ru=B("session");function ou(e,t="\u{1F4F1} Scan QR to connect:"){console.log(fe.orange(`
231
- ${t}`)),Yo.default.generate(e,{small:!0,type:"terminal",margin:0},r=>{console.log(r.trim())})}function iu(e){return new Promise(t=>{Yo.default.generate(e,{small:!0,type:"terminal",margin:0},r=>{t(fe.orangeDim("\u{1F4F1} Scan QR to connect:")+`
232
- `+r.trim())})})}async function Gr(e,t){let r=await Bn(e,L),o=Math.min(We.headerWidth,process.stdout.columns||55);if(!r){ru.warn("Temp key creation failed \u2014 showing UI without a QR"),await M(I.READY,{tunnelUrl:t,permanentKey:e,workerUrl:L}),console.log(m.red(`
233
- \u274C Failed to create one-time key \u2014 generate a new one from the menu`)),console.log(fe.orange("\u2550".repeat(o))),console.log(m.white("App URL".padEnd(14))+m.gray(`${L}/login`)),console.log(m.white("Key".padEnd(14))+m.gray(e)),console.log(fe.orange("\u2550".repeat(o)));return}let n=Un(L,r);await M(I.READY,{tunnelUrl:t,oneTimeKey:r.oneTimeKey,oneTimeKeyExpiresAt:r.expiresAt,permanentKey:e,qrUrl:n,workerUrl:L}),ou(n),console.log(m.gray(`
224
+ `:""}${a}"${i}" "${c}" ${Rs()}
225
+ `,w=ke.default.join(_t.default.tmpdir(),`${ae}-update.sh`);return(0,J.writeFileSync)(w,h,{mode:493}),{shellCmd:["sh",[w]],windowsVerbatim:!1}}async function _s(){let e=Os();if(!e)return an.warn("update skipped: no version (source run?)"),!1;let n=dl();if(n)return an.warn(`update skipped: restricted env (${n})`),!1;let r=await hl();if(!r)return an.warn("update skipped: registry unreachable"),!1;if(!Is(e,r))return an.info(`update skipped: ${e} >= registry ${r}`),!1;if(!ml())return an.warn("update skipped: lock held by another run"),!1;an.info(`update go: ${e} -> ${r}`);let{shellCmd:o,windowsVerbatim:t}=El({currentVersion:e,latest:r,agentPid:process.pid});return(0,qn.spawn)(o[0],o[1],{detached:!0,stdio:"ignore",windowsHide:!0,windowsVerbatimArguments:t}).unref(),setTimeout(()=>process.exit(0),500),!0}var lr=require("child_process"),ur=x(require("path"),1),Go=x(require("fs"),1),fa=require("url");var j=x(require("fs"),1),pt=x(require("path"),1),Bo=x(require("https"),1),dt=x(require("os"),1),Ws=x(require("net"),1),qe=require("child_process");var $s=x(require("dns"),1),Ms=require("child_process");var Sl=2e3,bl=5e3,Po=new $s.default.promises.Resolver;Po.setServers(["1.1.1.1","1.0.0.1","8.8.8.8"]);function cn(){process.platform==="win32"&&(0,Ms.execFile)("ipconfig",["/flushdns"],{windowsHide:!0},()=>{})}async function Oo(e,n=Sl){let r=Date.now();try{let o=async()=>{let[i,s]=await Promise.allSettled([Po.resolve4(e),Po.resolve6(e)]);if(i.status==="fulfilled"&&i.value?.length)return i.value;if(s.status==="fulfilled"&&s.value?.length)return s.value;throw i.reason||s.reason||Object.assign(new Error("DNS query failed"),{code:"ENOTFOUND"})};return{ok:!0,addrs:await Promise.race([o(),new Promise((i,s)=>setTimeout(()=>s(Object.assign(new Error("DNS timeout"),{code:"ETIMEOUT"})),n))]),elapsedMs:Date.now()-r}}catch(o){return{ok:!1,code:o.code||o.message,elapsedMs:Date.now()-r}}}async function ln(e,{flushDns:n=!1}={}){let r=Date.now(),o=null;try{o=new URL(e).hostname}catch{}if(n&&cn(),o){let t=await Oo(o);if(!t.ok)return cn(),{ok:!1,dnsCode:t.code,elapsedMs:Date.now()-r}}try{let t=await H(`${e}/api/health`,{signal:AbortSignal.timeout(bl)});return{ok:t.ok,httpStatus:t.status,elapsedMs:Date.now()-r}}catch(t){return{ok:!1,dnsCode:t.cause?.code||t.code||t.message,elapsedMs:Date.now()-r}}}var Tl=B("tunnel"),Qn=null,Jn=null,un=null,$t=null,ft=0,Lo=!1;async function _o(e){try{let n=await nn();await fetch(`http://${n}:${P}/api/ui/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch{}}var Io=!1;async function Cs(){if(!(!Jn||Lo||Io)){Io=!0;try{await Al()}finally{Io=!1}}}async function Al(){let e=await ln(Jn),n=e.ok?"healthy":"unreachable";if(n===un){$t=null,ft=0;return}if(n!==$t){$t=n,ft=1;return}ft++,!(ft<fs)&&(Tl.info(`${un??"init"} \u2192 ${n}${e.ok?"":` (http=${e.httpStatus??"-"} dns=${e.dnsCode??"-"})`}`),un=n,$t=null,ft=0,await _o({tunnelHealth:{status:n,checkedAt:Date.now()}}))}function Ns(e){if(!e)return Zn();e!==Jn&&(Jn=e,un=null,$t=null,ft=0,cn(),Qn||(Qn=setInterval(Cs,ci.checkIntervalMs)),Cs())}var Ds=Ns,fn=Ns;function Bs(){Lo=!0}function Us(){Lo=!1}function Mt(e){un=e,$t=null,ft=0,_o({tunnelHealth:{status:e,checkedAt:Date.now()}})}function Zn(){Qn&&(clearInterval(Qn),Qn=null),Jn=null,un=null,$t=null,ft=0,_o({tunnelHealth:{status:"unknown",checkedAt:null}})}var z=B("tunnel"),Ye={networkCheckIntervalMs:5e3,networkRestoreDelayMs:2500,internetCheckTimeoutMs:3e3,internetCheckHost:"1.1.1.1",internetCheckPort:443,edgeProbeIntervalMs:15e3,edgeProbeFailureThreshold:3,readyTimeoutMs:1500},xl=[20241,20242,20243,20244,20245],mn=null;async function Rl(e,n){try{let o=await(await fetch(`http://localhost:${e}/ready`,{signal:AbortSignal.timeout(n)})).json();return typeof o?.readyConnections=="number"?o:null}catch{return null}}async function Fs(e,n){let r=await Rl(e,n);if(!r)return null;let o=await Pl(e,n);return o&&Ee&&!Ee.includes(o)?null:r.readyConnections}async function kl(e){if(mn!==null){let o=await Fs(mn,e);if(o!==null)return o;mn=null}let r=(await Promise.all(xl.map(async o=>({port:o,conns:await Fs(o,e)})))).find(o=>o.conns!==null);return r?(mn=r.port,r.conns):null}async function Pl(e,n){try{return(await(await fetch(`http://localhost:${e}/quicktunnel`,{signal:AbortSignal.timeout(n)})).json())?.hostname||null}catch{return null}}var Ol=3e4,$o=0,tr=null,Ur=null,hn=null,or=null,gn=!1,zn=0,Do=!1,Ee=null,yn=0,Mo=0,Co=!1,ir=0,Xe=0,Ks=3e4,Il=5e3,er=pt.default.join(dt.default.homedir(),".9remote","bin"),Hs="cloudflared",wn=dt.default.platform()==="win32",Ll=wn?`${Hs}.exe`:Hs,pn=pt.default.join(er,Ll),No=pt.default.join(dt.default.homedir(),".9remote","cloudflared.pid"),nr=!1,dn=null,_l="2026.6.1",Gs=`https://github.com/cloudflare/cloudflared/releases/download/${_l}`;function Vs(){return new Promise(e=>{let n=new Ws.default.Socket,r=!1,o=t=>{if(!r){r=!0;try{n.destroy()}catch{}e(t)}};n.setTimeout(Ye.internetCheckTimeoutMs),n.once("connect",()=>o(!0)),n.once("timeout",()=>o(!1)),n.once("error",()=>o(!1));try{n.connect(Ye.internetCheckPort,Ye.internetCheckHost)}catch{o(!1)}})}async function $l(){Do=!0;try{let e=0;for(;;){if(e++,await Vs())return;await new Promise(n=>setTimeout(n,Ae(he.internet,e)))}}finally{Do=!1}}async function rr(e,n){if(!or){z.warn("No restartCallback registered \u2014 skip");return}if(!gn&&!(Date.now()-Mo<Il)){Mo=Date.now(),gn=!0;try{await $l();let r=Ae(he.tunnelRestart,zn+1);await new Promise(o=>setTimeout(o,r)),await or(e),zn=0,Mo=0}catch(r){zn++,z.error(`restart failed (#${zn}): ${r?.message||r}`),setImmediate(()=>{gn=!1,rr(e,"retry after fail")});return}finally{gn=!1}}}var Ml={darwin:{x64:"cloudflared-darwin-amd64.tgz",arm64:"cloudflared-darwin-arm64.tgz"},win32:{x64:"cloudflared-windows-amd64.exe"},linux:{x64:"cloudflared-linux-amd64",arm64:"cloudflared-linux-arm64"}};function Cl(){let e=dt.default.platform(),n=dt.default.arch(),r=Ml[e];if(!r)throw new Error(`Unsupported platform: ${e}`);let o=r[n];if(!o)throw new Error(`Unsupported architecture: ${n} for platform ${e}`);return`${Gs}/${o}`}var Nl=150;async function Ys(e,n,r){return new Promise((o,t)=>{let i=j.default.createWriteStream(n);Bo.default.get(e,s=>{if([301,302].includes(s.statusCode)){i.close(),j.default.unlinkSync(n),Ys(s.headers.location,n,r).then(o).catch(t);return}if(s.statusCode!==200){i.close(),j.default.unlinkSync(n),t(new Error(`Download failed with status ${s.statusCode}`));return}let a=parseInt(s.headers["content-length"]||"0",10),c=0,l=0,u=-1;s.on("data",f=>{if(c+=f.length,!r||!a)return;let p=Date.now(),d=Math.min(100,Math.floor(c/a*100));d!==u&&p-l>=Nl&&(l=p,u=d,r(d))}),s.pipe(i),i.on("finish",()=>{r&&a&&r(100),i.close(()=>o(n))}),i.on("error",f=>{i.close(),j.default.unlinkSync(n),t(f)})}).on("error",s=>{i.close(),j.default.existsSync(n)&&j.default.unlinkSync(n),t(s)})})}async function sr(e){if(j.default.existsSync(er)||j.default.mkdirSync(er,{recursive:!0}),j.default.existsSync(pn))return wn||j.default.chmodSync(pn,"755"),pn;let n=Cl(),r=n.endsWith(".tgz"),o=r?pt.default.join(er,"cloudflared.tgz"):pn;try{return e?.({phase:"download",percent:0}),await Ys(n,o,t=>{e?.({phase:"download",percent:t})}),await Dl(n,o),r&&(e?.({phase:"extract"}),(0,qe.execSync)(`tar -xzf "${o}" -C "${er}"`,{stdio:"pipe",windowsHide:!0}),j.default.unlinkSync(o)),wn||j.default.chmodSync(pn,"755"),pn}catch(t){try{j.default.existsSync(o)&&j.default.unlinkSync(o)}catch{}throw console.error("Failed to download cloudflared:",t.message),t}}function Xs(e){return new Promise((n,r)=>{Bo.default.get(e,o=>{if([301,302].includes(o.statusCode))return Xs(o.headers.location).then(n).catch(r);if(o.statusCode!==200)return r(new Error(`HTTP ${o.statusCode}`));let t="";o.on("data",i=>t+=i),o.on("end",()=>n(t))}).on("error",r)})}async function Dl(e,n){let r=pt.default.basename(e),o;try{o=await Xs(`${Gs}/sha256sum.txt`)}catch(c){z.warn(`sha256 manifest unavailable (${c.message}), skipping verify`);return}let t=o.split(`
226
+ `).find(c=>c.includes(r));if(!t){z.warn(`No sha256 entry for ${r}, skipping verify`);return}let i=t.trim().split(/\s+/)[0],{createHash:s}=await import("crypto"),a=s("sha256").update(j.default.readFileSync(n)).digest("hex");if(a!==i)throw new Error(`Integrity check failed: SHA256 mismatch (expected ${i}, got ${a})`)}function Bl(e){let n=/https:\/\/([a-z0-9-]+)\.trycloudflare\.com/gi,r=[];for(let o of e.matchAll(n))o[1]!=="api"&&r.push(`https://${o[1]}.trycloudflare.com`);return r.length?r[r.length-1]:null}async function Qe(e,n=null,r=null){let o=await sr();Hl(o),r&&(or=r),hn=e;let t=j.default.mkdtempSync(pt.default.join(dt.default.tmpdir(),"9remote-quick-")),i=pt.default.join(t,"config.yml");j.default.writeFileSync(i,`# quick-tunnel
227
+ `,"utf8");let s=!1,a=()=>{if(!s){s=!0;try{j.default.rmSync(t,{recursive:!0,force:!0})}catch{}}},c=(0,qe.spawn)(o,["tunnel","--url",`http://localhost:${e}`,"--config",i,"--no-autoupdate","--protocol","http2"],{detached:!1,windowsHide:!0,stdio:["ignore","pipe","pipe"]});return Ce("cloudflared",c.pid),dn=c.pid,nr=!1,new Promise((l,u)=>{let f=!1,p=null,d="",h=setTimeout(()=>{if(!f){f=!0,a(),dn===c.pid&&(dn=null);try{c.kill("SIGKILL")}catch{}Ve("cloudflared"),u(new Error("Quick tunnel timed out after 90s"))}},9e4),w=E=>{let O=E.toString();d+=O,d.length>4096&&(d=d.slice(-4096));let b=Bl(O);if(b){if(!f){f=!0,p=b,Ee=b,yn=Date.now(),Xe=0,ir=0,mn=null,clearTimeout(h),a(),Gl(),z.info(`tunnel ready: ${b}`),l({child:c,tunnelUrl:b});return}b!==p&&(z.info(`URL rotated: ${b}`),p=b,Ee=b,yn=Date.now(),Xe=0,ir=0,n?.(b))}};c.stdout.on("data",w),c.stderr.on("data",w),c.on("error",E=>{f||(f=!0,clearTimeout(h),a(),u(E))}),c.on("exit",(E,O)=>{a();let b=dn!==c.pid,A=nr||b;if(z.info(`cloudflared exited (intentional=${nr} superseded=${b})`),A||Mt("unreachable"),!f){f=!0,clearTimeout(h);let k=d.trim().split(`
228
+ `).slice(-5).join(" | ");dn=null,u(new Error(`cloudflared exited (code=${E}, signal=${O}) output: ${k||"(empty)"}`));return}A||rr(e,`quick tunnel exit code ${E}`)})})}function Fr(e){if(wn)try{(0,qe.execSync)(`taskkill /PID ${e} /T /F`,{windowsHide:!0,stdio:"ignore"})}catch{}else try{process.kill(e,"SIGKILL")}catch{}}function Ul(e){return e?e.split(`
229
+ `).flatMap(n=>{let r=n.match(/^\s*(\d+)\s+(.+)$/);return r?[{pid:Number(r[1]),args:r[2].trim()}]:[]}):[]}function Fl(e,n){return Array.isArray(e)?e.filter(r=>{if(!r?.args||typeof r.pid!="number")return!1;let o=r.args.split(/\s+/);return o.includes(n)&&o.includes("tunnel")}).map(r=>r.pid):[]}function Kl(e){try{let n=wn?(0,qe.execSync)(`powershell -NoProfile -Command "Get-CimInstance Win32_Process -Filter 'Name=\\'cloudflared.exe\\'' | ForEach-Object { \\"$($_.ProcessId) $($_.CommandLine)\\"" }"`,{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}):(0,qe.execSync)("ps -eo pid=,args=",{encoding:"utf8",stdio:["ignore","pipe","ignore"]});return Fl(Ul(n),e)}catch{return[]}}function Hl(e){let n=Kl(e);for(let r of n)r!==process.pid&&(z.info(`killing leftover cloudflared pid=${r}`),Fr(r));return n}function jl(e){try{let n=[];if(wn){let r=`Get-NetTCPConnection -LocalPort ${e} -State Established -ErrorAction SilentlyContinue | Where-Object { (Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).Name -eq 'cloudflared' } | Select-Object -ExpandProperty OwningProcess -Unique`;n=(0,qe.execSync)(`powershell -NoProfile -Command "${r}"`,{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}).split(/\r?\n/).map(t=>+t.trim()).filter(Boolean)}else n=(0,qe.execSync)(`lsof -nP -iTCP:${e} -sTCP:ESTABLISHED 2>/dev/null | awk '/cloudflar/ {print $2}' | sort -u`,{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).split(`
230
+ `).map(o=>+o.trim()).filter(Boolean);for(let r of new Set(n))Fr(r)}catch{}}function ce(){if(!Co){Co=!0;try{try{if(j.default.existsSync(No)){let n=parseInt(j.default.readFileSync(No,"utf8"));Number.isFinite(n)&&(nr=!0,Fr(n)),j.default.unlinkSync(No)}}catch{}let e=Yn("cloudflared");nr=!0,dn=null,e&&(Fr(e),Ve("cloudflared")),jl(P)}finally{setTimeout(()=>{Co=!1},2e3)}}}function qs(){if(!Ee)return!1;let e=Yn("cloudflared");return!!e&&Ao(e)}function Qs(){zn=0,gn=!1,or=null,hn=null,Ee=null,Xe=0,ir=0,mn=null,Vl()}var Wl=/^(utun|awdl|llw|anpi|bridge|gif|stf|ipsec|ap|tun|tap|vmnet|veth|docker)/i;function js(){let e=dt.default.networkInterfaces(),n=[];for(let[r,o]of Object.entries(e))if(o&&!Wl.test(r))for(let t of o)!t.internal&&t.family==="IPv4"&&n.push(`${r}:${t.address}`);return n.sort().join("|")}function Gl(){tr||(Ur=js(),$o=Date.now(),tr=setInterval(async()=>{try{let e=Date.now(),n=e-$o;if($o=e,Do||gn||!or||hn==null)return;if(n>Ol){if(z.info(`Sleep/wake detected (gap=${n}ms)`),Ee){let s=!1;for(let a=0;a<3;a++){if((await ln(Ee)).ok){s=!0;break}a<2&&await new Promise(l=>setTimeout(l,3e3))}if(s)return;z.info("tunnel unresponsive after sleep \u2192 restarting")}Mt("unreachable"),ce(),rr(hn,"woke from sleep");return}let r=js(),o=r!==Ur;Ur=r;let t=Yn("cloudflared"),i=!t||!Ao(t);if(!o&&!i){if(Ee&&yn&&Date.now()-yn>Ks&&e-ir>=Ye.edgeProbeIntervalMs){ir=e;let s=await ln(Ee);if(s.ok)Xe=0;else if(++Xe>=Ye.edgeProbeFailureThreshold){let a=await kl(Ye.readyTimeoutMs);if(a>0){z.info(`edge probe failing but cloudflared holds ${a} connection(s) \u2014 not restarting`),Xe=0;return}z.warn(`tunnel unreachable but cloudflared alive \u2014 edge lost after ${Xe} probes (ready=${a??"unknown"}), restarting`),Xe=0,Mt("unreachable"),ce(),rr(hn,"tunnel unreachable (edge lost)")}else z.debug(`edge probe failed (${Xe}/${Ye.edgeProbeFailureThreshold}) \u2014 ${s.dnsCode??s.httpStatus??"no response"}`)}return}if(o&&!i&&yn&&Date.now()-yn<Ks||(o&&z.info("Network change detected"),i&&z.warn("cloudflared not alive \u2014 watchdog"),Mt("unreachable"),await new Promise(s=>setTimeout(s,Ye.networkRestoreDelayMs)),!await Vs()))return;if(o&&!i&&Ee){let s=!1;for(let a=0;a<2;a++){if((await ln(Ee)).ok){s=!0;break}a===0&&await new Promise(l=>setTimeout(l,2e3))}if(s){z.info("Tunnel survived network change, skip restart");return}}o&&!i&&ce(),rr(hn,o?"network change":"liveness watchdog")}catch(e){z.error(`network monitor tick failed: ${e?.message||e}`)}},Ye.networkCheckIntervalMs))}function Vl(){tr&&(clearInterval(tr),tr=null),Ur=null}Dt();async function mt(e,n={}){let r=n.intervalMs??ct.intervalMs,o=n.timeoutMs??ct.timeoutMs,t=`${e}/api/health`,i=(()=>{try{return new URL(e).hostname}catch{return null}})(),s=Date.now(),a=0,c=[];await K({healthCheck:{running:!0,timeoutMs:o,startedAt:s,logs:[]}});let l=u=>{c.push(u);let f=c.length>ct.maxLogEntries?c.slice(-ct.maxLogEntries):c;K({healthCheck:{running:!0,timeoutMs:o,startedAt:s,logs:f}})};for(;Date.now()-s<o;){if(a++,cn(),i){let f=await Oo(i,ct.dnsTimeoutMs);if(!f.ok){let p=f.code==="ENOTFOUND"||f.code==="ETIMEOUT"||f.code==="ESERVFAIL",d=p?"connecting...":f.code;tn(`#${a} \u2192 ${d}`),l({attempt:a,status:d,elapsedMs:f.elapsedMs,ok:!1,waiting:p,time:Date.now()}),await new Promise(h=>setTimeout(h,r));continue}}let u=Date.now();try{let f=await H(t,{signal:AbortSignal.timeout(ct.fetchTimeoutMs)}),p=Date.now()-u;if(tn(`#${a} \u2192 ${f.status}`),l({attempt:a,status:String(f.status),elapsedMs:p,ok:f.ok,time:Date.now()}),f.ok)return await K({healthCheck:{running:!1,timeoutMs:0,startedAt:null,logs:[]}}),await new Promise(d=>setTimeout(d,ct.postReadyHoldMs)),!0}catch(f){let p=Date.now()-u,d=f.cause?.code||f.code||f.message,h=d==="ENOTFOUND",w=h?"connecting...":d;tn(`#${a} \u2192 ${w}`),l({attempt:a,status:w,elapsedMs:p,ok:!1,waiting:h,time:Date.now()})}await new Promise(f=>setTimeout(f,r))}return await K({healthCheck:{running:!1,timeoutMs:o,startedAt:s,logs:c}}),!1}var Ze=B("tunnel"),Fo=null,aa=null,ca=0;async function Bt(e,n){if(Ze.debug(`updateTunnelUrl: key=${e?.slice(0,8)} url=${n}`),W().remoteEnabled===!1)return;if(Ut(e),n&&n===aa&&Date.now()-ca<us){Ze.debug("updateTunnelUrl: skipped (debounce, same URL)");return}Fo&&(Fo.cancelled=!0);let r={cancelled:!1};Fo=r;let o=Qi();Tr({config:he.urlSync,label:`urlSync ${n}`,log:t=>Ze.warn(t),ctx:r,task:async()=>{let t=await H(`${L}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((()=>{let s={apiKey:q(e),tunnelUrl:n,localIp:o?`${o}:${P}`:null};return{...s,...At(s)}})())});if(r.cancelled)return!0;if(t.ok)return aa=n,ca=Date.now(),Ze.debug(`urlSync OK: pushed ${n} to server`),Zl(n),!0;let i=await t.text().catch(()=>"");return Ze.warn(`urlSync HTTP ${t.status}: ${i.slice(0,200)}`),!1}}),n&&Ds(n)}var bn=null,Tn=null,Ko=!1,jo=0;async function Wo(e,n){let r={apiKey:e,online:n},o=await H(`${L}/api/session/heartbeat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...At(r)})});return o.ok||Ze.warn(`heartbeat online=${n} HTTP ${o.status}`),o.ok}async function Ho(){if(!(Ko||!Tn)){Ko=!0;try{await Wo(Tn,!0),jo=Date.now()}catch(e){Ze.debug(`heartbeat failed: ${e?.message||e}`)}finally{Ko=!1}}}function Ut(e){let n=q(e);if(n&&W().remoteEnabled!==!1){if(bn&&Tn===n){Date.now()-jo>=Eo&&Ho();return}Hr(),Tn=n,Ho(),bn=setInterval(Ho,Eo),bn.unref?.()}}function Hr({offline:e=!1}={}){bn&&(clearInterval(bn),bn=null);let n=Tn;return Tn=null,jo=0,!e||!n?null:Wo(n,!1).catch(r=>Ze.debug(`goodbye failed: ${r?.message||r}`))}function ht(e){let n=q(e);if(!n)return Promise.resolve(!1);Hr();let r=Wo(n,!1).catch(o=>(Ze.debug(`offline mark failed: ${o?.message||o}`),!1));return Promise.race([r,new Promise(o=>setTimeout(()=>o(!1),Lr))])}var cr=null;async function Zl(e){if(cr?.url===e)return;let n={url:e};cr=n,Bs();try{let r=await mt(e,{timeoutMs:ps});if(cr!==n)return;r&&Mt("healthy")}catch{}finally{cr===n&&(cr=null),Us()}}var ze=B("server"),pa=ur.default.dirname((0,fa.fileURLToPath)(__importMetaUrl)),zl=ur.default.resolve(pa,"./server.cjs"),la=ur.default.resolve(pa,"../../index.js");function jr(e){try{process.platform==="win32"?(0,lr.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${e}') do taskkill /F /PID %a`,{stdio:"ignore",windowsHide:!0}):(0,lr.execSync)(`lsof -ti:${e} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}}function gt(e,n,r){let o=null,t=!1,i=!1,s=!0,a=0,c=null,l=()=>{s&&(jr(P),s=!1);let u=process.env.NODE_ENV==="development"&&Go.default.existsSync(la),f=u?la:zl;Go.default.existsSync(f)||(ze.error(`Server not found: ${f}`),process.exit(1));let p={...process.env,PORT:String(P)};u||delete p.NODE_ENV,o=(0,lr.spawn)(ri,[f],{cwd:ur.default.dirname(f),stdio:["ignore","inherit","inherit"],detached:!1,windowsHide:!0,env:oi(p)}),c&&clearTimeout(c),c=setTimeout(()=>{a=0},cs),o.on("exit",(d,h)=>{if(c&&(clearTimeout(c),c=null),t)return;if(i){i=!1,ze.info("Restarting server (requested)..."),setTimeout(()=>{l(),r?.()},500);return}ze.error(`Server exited unexpectedly (code: ${d}, signal: ${h})`),a++;let w=Ae(he.server,a);ze.warn(`Restarting server in ${w}ms (fail#${a})`),n&&n(),setTimeout(()=>{l(),r?.()},w)}),o.on("error",d=>{ze.error(`Server error: ${d.message}`)}),e?.(o)};return l(),{getProcess:()=>o,shutdown:()=>{if(t=!0,!!o){try{o.kill("SIGTERM")}catch{}setTimeout(()=>{try{o&&o.kill("SIGKILL")}catch{}},2e3)}},restart:()=>{if(!o)return!1;i=!0;try{o.kill("SIGTERM")}catch{}return setTimeout(()=>{try{o&&i&&o.kill("SIGKILL")}catch{}},2e3),!0}}}function da(e){return e?.restart?e.restart():!1}function et({serverManager:e,tunnelProcess:n,exit:r=!0,code:o=0}={}){try{Zn()}catch{}try{e?.shutdown?.()}catch{}try{n?.kill?.()}catch{}try{ce()}catch{}try{Ct()}catch{}try{jr(P)}catch{}try{Qs()}catch{}try{Si()}catch{}try{Ve("agent")}catch{}try{Ve("cloudflared")}catch{}let t=Hr({offline:!0});if(r){let i=new Promise(a=>setTimeout(a,ls)),s=t?Promise.race([t,new Promise(a=>setTimeout(a,Lr))]):null;Promise.all([i,s]).finally(()=>process.exit(o))}}var ua=!1;function yt(e,n){if(ua)return;ua=!0;let r=!1,o=t=>{r||(r=!0,ze.info(`Stopping 9Remote (${t})...`),et({serverManager:e,tunnelProcess:n}),ze.info("Server stopped"))};if(process.on("SIGINT",()=>o("SIGINT")),process.on("SIGTERM",()=>o("SIGTERM")),process.on("SIGHUP",()=>o("SIGHUP")),process.platform==="win32"){process.on("SIGBREAK",()=>o("SIGBREAK"));try{import("readline").then(({createInterface:t})=>{t({input:process.stdin,output:process.stdout}).on("SIGINT",()=>o("SIGINT")),process.stdin.isTTY&&process.stdin.unref?.()}).catch(()=>{})}catch{}}process.on("uncaughtException",t=>{ze.error(`Uncaught exception: ${t?.stack||t?.message||t}`),o("uncaughtException"),setTimeout(()=>process.exit(1),vo)}),process.on("unhandledRejection",t=>{ze.error(`Unhandled rejection: ${t?.stack||t?.message||t}`),o("unhandledRejection"),setTimeout(()=>process.exit(1),vo)})}Dt();var Ft=B("tunnel");async function eu(e,n,r,o){let t=0;for(;;){t++;try{return await Qe(e,n,r)}catch(i){let s=Ae(he.tunnelSpawn,t);Ft.warn(`spawn attempt ${t} failed: ${i?.message||i} \u2014 retry in ${s}ms`),o?.({attempt:t,delay:s}),await new Promise(a=>setTimeout(a,s))}}}function tt({onUrlUpdate:e,setTunnel:n,onRetry:r}){return async o=>{try{let t=await eu(o,e,null,r);nt(),n(t.child),await e(t.tunnelUrl),Ft.info(`Tunnel restarted: ${t.tunnelUrl}`)}catch(t){Ft.error(`Tunnel restart failed: ${t?.message||t}`)}}}var Wr=null;function nt(){Wr&&(Wr.cancelled=!0,Wr=null)}function An(e,{onUrlUpdate:n,onRestart:r,setActiveTunnel:o,onReady:t}){nt();let i={cancelled:!1};return Wr=i,Tr({config:he.tunnelRateLimit,task:async()=>{if(i.cancelled)return!0;if(qs())return Ft.info("bg-tunnel: a tunnel is already live \u2014 standing down"),!0;let s=await Qe(e,n,r);if(i.cancelled){try{ce()}catch{}return!0}try{o?.(s.child),await n?.(s.tunnelUrl),await t?.(s),Ft.info(`bg tunnel up: ${s.tunnelUrl}`)}catch(a){Ft.error(`bg tunnel post-spawn failed: ${a?.message||a}`)}return!0},label:"bg-tunnel",log:s=>Ft.info(s),ctx:i}),i}var Jo=x(Da(),1);var lu=B("session");function uu(e,n="\u{1F4F1} Scan QR to connect:"){console.log(de.orange(`
231
+ ${n}`)),Jo.default.generate(e,{small:!0,type:"terminal",margin:0},r=>{console.log(r.trim())})}function fu(e){return new Promise(n=>{Jo.default.generate(e,{small:!0,type:"terminal",margin:0},r=>{n(de.orangeDim("\u{1F4F1} Scan QR to connect:")+`
232
+ `+r.trim())})})}async function Xr(e,n){let r=await Kn(e,L),o=Math.min(Ge.headerWidth,process.stdout.columns||55);if(!r){lu.warn("Temp key creation failed \u2014 showing UI without a QR"),await $(I.READY,{tunnelUrl:n,permanentKey:e,workerUrl:L}),console.log(m.red(`
233
+ \u274C Failed to create one-time key \u2014 generate a new one from the menu`)),console.log(de.orange("\u2550".repeat(o))),console.log(m.white("App URL".padEnd(14))+m.gray(`${L}/login`)),console.log(m.white("Key".padEnd(14))+m.gray(e)),console.log(de.orange("\u2550".repeat(o)));return}let t=Hn(L,r);await $(I.READY,{tunnelUrl:n,oneTimeKey:r.oneTimeKey,oneTimeKeyExpiresAt:r.expiresAt,permanentKey:e,qrUrl:t,workerUrl:L}),uu(t),console.log(m.gray(`
234
234
  QR will expire in 10 minutes (one-time use)
235
- `)),console.log(fe.orange("\u2550".repeat(o))),console.log(m.white("App URL".padEnd(14))+m.gray(`${L}/login`)),console.log(m.white("One-Time Key".padEnd(14))+fe.orange.bold(r.oneTimeKey)),console.log(m.white("Key".padEnd(14))+m.gray(e)),console.log(fe.orange("\u2550".repeat(o)))}async function Tn(e,t,r,o=""){let n=Math.min(We.headerWidth,process.stdout.columns||We.headerWidth),i=[];return e&&r?(i.push(await iu(r)),i.push(m.gray(`
235
+ `)),console.log(de.orange("\u2550".repeat(o))),console.log(m.white("App URL".padEnd(14))+m.gray(`${L}/login`)),console.log(m.white("One-Time Key".padEnd(14))+de.orange.bold(r.oneTimeKey)),console.log(m.white("Key".padEnd(14))+m.gray(e)),console.log(de.orange("\u2550".repeat(o)))}async function xn(e,n,r,o=""){let t=Math.min(Ge.headerWidth,process.stdout.columns||Ge.headerWidth),i=[];return e&&r?(i.push(await fu(r)),i.push(m.gray(`
236
236
  QR expires in 30 minutes (one-time use)
237
237
  `))):i.push(m.gray(`
238
238
  (One-time key used \u2014 generate a new one from menu)
239
- `)),i.push(fe.orange("\u2550".repeat(n)),m.white("App URL".padEnd(14))+m.gray(`${L}/login`)),ri.showTunnelUrlInMenu&&i.push(m.white("Tunnel".padEnd(14))+(o?m.cyan(o):m.gray("\u2014"))),i.push(m.white("One-Time Key".padEnd(14))+(e?fe.orange.bold(e)+m.dim(" (expires in 30m)"):m.gray("\u2014")),m.white("Key".padEnd(14))+m.dim(t),fe.orange("\u2550".repeat(n))),i.join(`
240
- `)}var he=B("cmd");function wt(e,t,r,o){let n=!1;setInterval(async()=>{if(n)return;let i=vi();if(i){n=!0;try{if(i==="stop-tunnel")await $a(e,t,r);else if(i==="restart-tunnel")await $a(e,t,r),await Na(e,t,r);else if(i==="start-tunnel"){if(await Na(e,t,r)==="alreadyRunning"){n=!1;return}}else if(i==="regenerate-key")await su();else if(i==="shutdown")au(e,t);else if(i==="update"){let s=await Os();he.info(`cmd update -> ${s?"started":"SKIPPED (see reasons above)"}`)}else i==="restart"&&ua(o?.())}catch(s){he.error(`cmd "${i}" failed: ${s?.message||s}`)}finally{n=!1}}},Ae.cmdMs)}async function $a(e,t,r){et(),qn();let o=e();o&&(o.kill(),t(null),he.info("Tunnel stopped")),r&&await dt(r),await M(I.STOPPED,{tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null,qrUrl:""}),wn({tunnelUrl:"",running:!0})}async function Na(e,t,r){if(j().remoteEnabled===!1){he.info("Start skipped \u2014 remote is disabled");return}let o=e();if(o)if(o.killed||o.exitCode!=null)t(null);else{let n=await Z("/api/ui/state");return await M(I.READY,{tunnelUrl:n?.tunnelUrl||""}),"alreadyRunning"}et(),he.info("Starting...");try{await M(I.PREPARING),await rr(Ar),await M(I.CONNECTING);let n=await H(`${L}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:Y(r),hostPublicKey:ot(),hostX25519Key:it()})});if(!n.ok)throw new Error(`Session create failed: ${n.status}`);await q("/api/signaling/retry",{}),Dt(r),await M(I.TUNNELING);let i=async l=>{await Nt(r,l),await K({tunnelUrl:l}),cn(l),wn({tunnelUrl:l,running:!0})},s=({attempt:l,delay:u})=>{K({tunnelRetry:{attempt:l,delay:u,at:Date.now()}})},a=null;try{a=await Xe(P,i,ze({onUrlUpdate:i,setTunnel:l=>t(l),onRetry:s}))}catch(l){he.error(`Tunnel spawn failed: ${l?.message||l} \u2014 QR RTC-only, bg retry`)}K({tunnelRetry:null});let c="";a&&(t(a.child),c=a.tunnelUrl,await M(I.VERIFYING),await pt(c)||(he.warn("Tunnel health check timed out \u2014 bg reconnect"),c="",t(null),a=null)),await Gr(r,c),await M(I.READY,{tunnelUrl:c}),a||Sn(P,{onUrlUpdate:i,onRestart:ze({onUrlUpdate:i,setTunnel:l=>t(l),onRetry:s}),setActiveTunnel:t,onReady:async l=>{await M(I.READY,{tunnelUrl:l.tunnelUrl})}})}catch(n){he.error(`Failed to start: ${n.message}`),await M(I.STOPPED)}}async function su(){if(j().remoteEnabled===!1){he.info("Key regeneration skipped \u2014 remote is disabled");return}let e=await jt(),t=St(e),r=$n();if(!await bt(t,L,yi()?.tunnelUrl,r?.key)){he.error("Key regeneration aborted \u2014 could not register the new key");return}Ke(e,t,r?.name||"Default"),await K({permanentKey:t,oneTimeKey:"",oneTimeKeyExpiresAt:null,qrUrl:"",pairingUsed:!0}),he.info(`Key regenerated: ${dr(t)}`)}function au(e,t){et(),he.info("Shutting down 9Remote completely...");let r=e();t(null),Ze({tunnelProcess:r}),he.info("9Remote stopped")}$t();async function Da(){if(await Q()&&(await new Promise(a=>setTimeout(a,ne.guestRecheckMs)),await Q())){console.log(m.green(`
241
- \u{1F310} UI already served at http://localhost:${P}`));return}Me("agent",process.pid),Jt(_e());let e=await at(),t=process.argv.find(a=>a.startsWith("--theme=")),r=t?t.split("=")[1]:null;try{se(),await new Promise(a=>setTimeout(a,ne.killCloudflaredMs))}catch{}let o=mt(null,null);await new Promise(a=>setTimeout(a,ne.serverBootMs));let n=`http://localhost:${P}`;console.log(m.green(`
242
- \u{1F310} UI ready at ${n}`));let i=null;j().remoteEnabled===!1&&await dt(e.key),await K({permanentKey:e.key,step:I.STOPPED,theme:r}),ht(o,null),wt(()=>i,a=>{i=a},e.key,()=>o),await or({port:P,onQuit:()=>{let a=i;i=null,Ze({serverManager:o,tunnelProcess:a,exit:!1}),Mt(),setTimeout(()=>process.exit(0),500)},onOpenUI:()=>Ct(n)}),wn({tunnelUrl:"",running:!0}),(process.argv.includes("--start")||process.argv.includes("--skip-update"))&&j().remoteEnabled!==!1&&Vt("start-tunnel"),await new Promise(()=>{})}$t();async function Ba(){if(await Q()&&(await new Promise(l=>setTimeout(l,ne.guestRecheckMs)),await Q())){console.log(`
243
- \u{1F310} 9Remote already running at http://localhost:${P}`);return}Me("agent",process.pid),Ts().catch(()=>{});let e=await at(),t=process.argv.find(l=>l.startsWith("--theme=")),r=t?t.split("=")[1]:null;try{se(),await new Promise(l=>setTimeout(l,ne.killCloudflaredMs))}catch{}let o=mt(null,null);await new Promise(l=>setTimeout(l,ne.serverBootMs));let n=`http://localhost:${P}`,i=null;await K({permanentKey:e.key,step:I.STOPPED,theme:r});let s=()=>{let l=i;i=null,Ze({serverManager:o,tunnelProcess:l,exit:!1})};ht(o,null),wt(()=>i,l=>{i=l},e.key,()=>o);try{je("cloudflared")}catch{}(process.argv.includes("--start")||process.argv.includes("--skip-update"))&&j().remoteEnabled!==!1&&Vt("start-tunnel"),await or({port:P,onQuit:s,onOpenUI:()=>Ct(n)})&&$o({title:"9Remote is running",message:`Open ${n} or use the tray icon to manage.`}),await new Promise(()=>{})}var Ft=B("mode");async function cu(e){Ft.info("Starting server..."),await M(I.PREPARING);try{se(),await new Promise(l=>setTimeout(l,ne.killCloudflaredMs))}catch{}let t=j().remoteEnabled===!1,r=!t;if(t&&await dt(e),r)try{let l=await H(`${L}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:Y(e),hostPublicKey:ot(),hostX25519Key:it()})});if(!l.ok)throw new Error(`Session create failed: ${l.status}`);Dt(e)}catch(l){Ft.error(`Session create failed: ${l.message} \u2014 local-only, retry from Web UI`),r=!1}let o=await Q(),n=o?{getProcess:()=>null,shutdown:()=>{}}:mt(null,null);o||await new Promise(l=>setTimeout(l,ne.serverBootMs)),Ft.info("Starting tunnel..."),await M(I.CONNECTING);let i={current:null},s="",a=async l=>{Ft.info(`Tunnel URL rotated: ${l}`),await Nt(e,l),K({tunnelUrl:l}),cn(l)},c=null;if(r)try{c=await Xe(P,a,ze({onUrlUpdate:a,setTunnel:l=>{i.current=l}}))}catch(l){Ft.error(`Tunnel spawn failed: ${l.message} \u2014 RTC-only, bg retry`)}return c&&(i.current=c.child,s=c.tunnelUrl,await pt(s)||(Ft.warn("Tunnel health check timed out \u2014 bg reconnect"),i.current=null,s="",c=null)),!c&&r&&Sn(P,{onUrlUpdate:a,onRestart:ze({onUrlUpdate:a,setTunnel:l=>{i.current=l}}),setActiveTunnel:l=>{i.current=l},onReady:async l=>{await M(I.READY,{tunnelUrl:l.tunnelUrl})}}),s&&await Nt(e,s),r?await M(I.READY,{tunnelUrl:s}):await M(I.STOPPED,{tunnelUrl:""}),Cn({apiKey:e,tunnelUrl:s,serverPid:n.getProcess()?.pid,tunnelPid:i.current?.pid}),{serverManager:n,tunnelRef:i,tunnelUrl:s,remoteOnline:r}}async function Ua(){Jt(_e());let e=await at();Ft.info(`Using key: ${dr(e.key)} (${e.name})`);let{serverManager:t,tunnelRef:r,tunnelUrl:o,remoteOnline:n}=await cu(e.key);n?await Gr(e.key,o):console.log(`\u26A0 ${j().remoteEnabled===!1?"Remote is disabled \u2014 enable it in Web UI settings":'Remote not connected \u2014 tap "remote \xB7 offline" in the Web UI to retry'}. Local mode.`),ht(t,r.current),wt(()=>r.current,s=>{r.current=s},e.key);let i=Date.now();setInterval(()=>{let s=Math.floor((Date.now()-i)/1e3),a=Math.floor(s/3600),c=Math.floor(s%3600/60),l=s%60;K({uptime:`${a}:${String(c).padStart(2,"0")}:${String(l).padStart(2,"0")}`})},Ae.statsMs),await new Promise(()=>{})}var Fa=R(require("path"),1),Ka=R(require("fs"),1);$t();async function Ha(){let e=`http://localhost:${P}`;await Q()&&(Fr(P),await new Promise(c=>setTimeout(c,500)));let t=["--tray"],r=process.argv.find(c=>c.startsWith("--theme="));r&&t.push(r);let o=Dn;try{Ka.default.mkdirSync(Fa.default.dirname(o),{recursive:!0})}catch{}let n=null;try{n=Es(t),n&&Me("agent",n)}catch(c){console.log(m.red(`
244
- \u274C Failed to launch background: ${c.message}`)),process.exit(1)}let i=Date.now()+Ae.bgServerReadyTimeoutMs,s=!1;for(;Date.now()<i;){if(await Q()){s=!0;break}await new Promise(c=>setTimeout(c,Ae.bgServerReadyIntervalMs))}s||(console.log(m.red(`
239
+ `)),i.push(de.orange("\u2550".repeat(t)),m.white("App URL".padEnd(14))+m.gray(`${L}/login`)),si.showTunnelUrlInMenu&&i.push(m.white("Tunnel".padEnd(14))+(o?m.cyan(o):m.gray("\u2014"))),i.push(m.white("One-Time Key".padEnd(14))+(e?de.orange.bold(e)+m.dim(" (expires in 30m)"):m.gray("\u2014")),m.white("Key".padEnd(14))+m.dim(n),de.orange("\u2550".repeat(t))),i.join(`
240
+ `)}var ye=B("cmd");function Et(e,n,r,o){let t=!1;setInterval(async()=>{if(t)return;let i=bi();if(i){t=!0;try{if(i==="stop-tunnel")await Ba(e,n,r);else if(i==="restart-tunnel")await Ba(e,n,r),await Ua(e,n,r);else if(i==="start-tunnel"){if(await Ua(e,n,r)==="alreadyRunning"){t=!1;return}}else if(i==="regenerate-key")await pu();else if(i==="shutdown")du(e,n);else if(i==="update"){let s=await _s();ye.info(`cmd update -> ${s?"started":"SKIPPED (see reasons above)"}`)}else i==="restart"&&da(o?.())}catch(s){ye.error(`cmd "${i}" failed: ${s?.message||s}`)}finally{t=!1}}},Re.cmdMs)}async function Ba(e,n,r){nt(),Zn();let o=e();o&&(o.kill(),n(null),ye.info("Tunnel stopped")),r&&await ht(r),await $(I.STOPPED,{tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null,qrUrl:""}),Sn({tunnelUrl:"",running:!0})}async function Ua(e,n,r){if(W().remoteEnabled===!1){ye.info("Start skipped \u2014 remote is disabled");return}let o=e();if(o)if(o.killed||o.exitCode!=null)n(null);else{let t=await Z("/api/ui/state");return await $(I.READY,{tunnelUrl:t?.tunnelUrl||""}),"alreadyRunning"}nt(),ye.info("Starting...");try{await $(I.PREPARING),await sr(kr),await $(I.CONNECTING);let t=await H(`${L}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:q(r),hostPublicKey:st(),hostX25519Key:at()})});if(!t.ok)throw new Error(`Session create failed: ${t.status}`);await G("/api/signaling/retry",{}),Ut(r),await $(I.TUNNELING);let i=async l=>{await Bt(r,l),await K({tunnelUrl:l}),fn(l),Sn({tunnelUrl:l,running:!0})},s=({attempt:l,delay:u})=>{K({tunnelRetry:{attempt:l,delay:u,at:Date.now()}})},a=null;try{a=await Qe(P,i,tt({onUrlUpdate:i,setTunnel:l=>n(l),onRetry:s}))}catch(l){ye.error(`Tunnel spawn failed: ${l?.message||l} \u2014 QR RTC-only, bg retry`)}K({tunnelRetry:null});let c="";a&&(n(a.child),c=a.tunnelUrl,await $(I.VERIFYING),await mt(c)||(ye.warn("Tunnel health check timed out \u2014 bg reconnect"),c="",n(null),a=null)),await Xr(r,c),await $(I.READY,{tunnelUrl:c}),a||An(P,{onUrlUpdate:i,onRestart:tt({onUrlUpdate:i,setTunnel:l=>n(l),onRetry:s}),setActiveTunnel:n,onReady:async l=>{await $(I.READY,{tunnelUrl:l.tunnelUrl})}})}catch(t){ye.error(`Failed to start: ${t.message}`),await $(I.STOPPED)}}async function pu(){if(W().remoteEnabled===!1){ye.info("Key regeneration skipped \u2014 remote is disabled");return}let e=await Yt(),n=Tt(e),r=Bn();if(!await xt(n,L,Ei()?.tunnelUrl,r?.key)){ye.error("Key regeneration aborted \u2014 could not register the new key");return}je(e,n,r?.name||"Default"),await K({permanentKey:n,oneTimeKey:"",oneTimeKeyExpiresAt:null,qrUrl:"",pairingUsed:!0}),ye.info(`Key regenerated: ${gr(n)}`)}function du(e,n){nt(),ye.info("Shutting down 9Remote completely...");let r=e();n(null),et({tunnelProcess:r}),ye.info("9Remote stopped")}Dt();async function Fa(){if(await V()&&(await new Promise(a=>setTimeout(a,ne.guestRecheckMs)),await V())){console.log(m.green(`
241
+ \u{1F310} UI already served at http://localhost:${P}`));return}Ce("agent",process.pid),en(Me());let e=await lt(),n=process.argv.find(a=>a.startsWith("--theme=")),r=n?n.split("=")[1]:null;try{ce(),await new Promise(a=>setTimeout(a,ne.killCloudflaredMs))}catch{}let o=gt(null,null);await new Promise(a=>setTimeout(a,ne.serverBootMs));let t=`http://localhost:${P}`;console.log(m.green(`
242
+ \u{1F310} UI ready at ${t}`));let i=null;W().remoteEnabled===!1&&await ht(e.key),await K({permanentKey:e.key,step:I.STOPPED,theme:r}),yt(o,null),Et(()=>i,a=>{i=a},e.key,()=>o),await ar({port:P,onQuit:()=>{let a=i;i=null,et({serverManager:o,tunnelProcess:a,exit:!1}),Ct(),setTimeout(()=>process.exit(0),500)},onOpenUI:()=>Nt(t)}),Sn({tunnelUrl:"",running:!0}),(process.argv.includes("--start")||process.argv.includes("--skip-update"))&&W().remoteEnabled!==!1&&qt("start-tunnel"),await new Promise(()=>{})}Dt();async function Ka(){if(await V()&&(await new Promise(l=>setTimeout(l,ne.guestRecheckMs)),await V())){console.log(`
243
+ \u{1F310} 9Remote already running at http://localhost:${P}`);return}Ce("agent",process.pid),xs().catch(()=>{});let e=await lt(),n=process.argv.find(l=>l.startsWith("--theme=")),r=n?n.split("=")[1]:null;try{ce(),await new Promise(l=>setTimeout(l,ne.killCloudflaredMs))}catch{}let o=gt(null,null);await new Promise(l=>setTimeout(l,ne.serverBootMs));let t=`http://localhost:${P}`,i=null;await K({permanentKey:e.key,step:I.STOPPED,theme:r});let s=()=>{let l=i;i=null,et({serverManager:o,tunnelProcess:l,exit:!1})};yt(o,null),Et(()=>i,l=>{i=l},e.key,()=>o);try{Ve("cloudflared")}catch{}(process.argv.includes("--start")||process.argv.includes("--skip-update"))&&W().remoteEnabled!==!1&&qt("start-tunnel"),await ar({port:P,onQuit:s,onOpenUI:()=>Nt(t)})&&Uo({title:"9Remote is running",message:`Open ${t} or use the tray icon to manage.`}),await new Promise(()=>{})}var Ht=B("mode");async function mu(e){Ht.info("Starting server..."),await $(I.PREPARING);try{ce(),await new Promise(l=>setTimeout(l,ne.killCloudflaredMs))}catch{}let n=W().remoteEnabled===!1,r=!n;if(n&&await ht(e),r)try{let l=await H(`${L}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:q(e),hostPublicKey:st(),hostX25519Key:at()})});if(!l.ok)throw new Error(`Session create failed: ${l.status}`);Ut(e)}catch(l){Ht.error(`Session create failed: ${l.message} \u2014 local-only, retry from Web UI`),r=!1}let o=await V(),t=o?{getProcess:()=>null,shutdown:()=>{}}:gt(null,null);o||await new Promise(l=>setTimeout(l,ne.serverBootMs)),Ht.info("Starting tunnel..."),await $(I.CONNECTING);let i={current:null},s="",a=async l=>{Ht.info(`Tunnel URL rotated: ${l}`),await Bt(e,l),K({tunnelUrl:l}),fn(l)},c=null;if(r)try{c=await Qe(P,a,tt({onUrlUpdate:a,setTunnel:l=>{i.current=l}}))}catch(l){Ht.error(`Tunnel spawn failed: ${l.message} \u2014 RTC-only, bg retry`)}return c&&(i.current=c.child,s=c.tunnelUrl,await mt(s)||(Ht.warn("Tunnel health check timed out \u2014 bg reconnect"),i.current=null,s="",c=null)),!c&&r&&An(P,{onUrlUpdate:a,onRestart:tt({onUrlUpdate:a,setTunnel:l=>{i.current=l}}),setActiveTunnel:l=>{i.current=l},onReady:async l=>{await $(I.READY,{tunnelUrl:l.tunnelUrl})}}),s&&await Bt(e,s),r?await $(I.READY,{tunnelUrl:s}):await $(I.STOPPED,{tunnelUrl:""}),Dn({apiKey:e,tunnelUrl:s,serverPid:t.getProcess()?.pid,tunnelPid:i.current?.pid}),{serverManager:t,tunnelRef:i,tunnelUrl:s,remoteOnline:r}}async function Ha(){en(Me());let e=await lt();Ht.info(`Using key: ${gr(e.key)} (${e.name})`);let{serverManager:n,tunnelRef:r,tunnelUrl:o,remoteOnline:t}=await mu(e.key);t?await Xr(e.key,o):console.log(`\u26A0 ${W().remoteEnabled===!1?"Remote is disabled \u2014 enable it in Web UI settings":'Remote not connected \u2014 tap "remote \xB7 offline" in the Web UI to retry'}. Local mode.`),yt(n,r.current),Et(()=>r.current,s=>{r.current=s},e.key);let i=Date.now();setInterval(()=>{let s=Math.floor((Date.now()-i)/1e3),a=Math.floor(s/3600),c=Math.floor(s%3600/60),l=s%60;K({uptime:`${a}:${String(c).padStart(2,"0")}:${String(l).padStart(2,"0")}`})},Re.statsMs),await new Promise(()=>{})}var ja=x(require("path"),1),Wa=x(require("fs"),1);Dt();async function Ga(){let e=`http://localhost:${P}`;await V()&&(jr(P),await new Promise(c=>setTimeout(c,500)));let n=["--tray"],r=process.argv.find(c=>c.startsWith("--theme="));r&&n.push(r);let o=Fn;try{Wa.default.mkdirSync(ja.default.dirname(o),{recursive:!0})}catch{}let t=null;try{t=Ts(n),t&&Ce("agent",t)}catch(c){console.log(m.red(`
244
+ \u274C Failed to launch background: ${c.message}`)),process.exit(1)}let i=Date.now()+Re.bgServerReadyTimeoutMs,s=!1;for(;Date.now()<i;){if(await V()){s=!0;break}await new Promise(c=>setTimeout(c,Re.bgServerReadyIntervalMs))}s||(console.log(m.red(`
245
245
  \u274C Background server failed to start.`)),console.log(m.gray(` Check log: ${o}
246
- `)),process.exit(1)),Vt("start-tunnel"),Ct(e);let a=n?` (PID: ${n})`:"";console.log(m.green(`
246
+ `)),process.exit(1)),qt("start-tunnel"),Nt(e);let a=t?` (PID: ${t})`:"";console.log(m.green(`
247
247
  \u{1F310} 9Remote running at ${e}${a}`)),console.log(m.gray(`\u{1F4A1} Log: ${o}
248
- `)),await new Promise(c=>setTimeout(c,ne.bgSpawnFlushMs)),process.exit(0)}var Wa=R(require("readline"),1);var Vr=B("mode"),bn=null;async function ja(){Me("agent",process.pid),console.clear(),Ki(),Gi(!0),await M(I.PREPARING);let e=await at(),t=null,r={getProcess:()=>null,shutdown:()=>{}};if(!await Q()){r=mt(null,null,()=>{if(process.stdin.isTTY){try{process.stdin.setRawMode(!1)}catch{}try{process.stdin.setRawMode(!0),process.stdin.resume()}catch{}}try{Wa.default.emitKeypressEvents(process.stdin)}catch{}t?.()});let g=Date.now()+Ae.serverReadyTimeoutMs;for(;Date.now()<g&&!await Q();)await new Promise(b=>setTimeout(b,Ae.serverReadyIntervalMs))}try{se(),await new Promise(g=>setTimeout(g,ne.killCloudflaredTuiMs))}catch{}try{await rr(Ar)}catch(g){Vr.error(`cloudflared setup failed: ${g?.message||g} \u2014 retry from Web UI`)}await M(I.CONNECTING);let n=j().remoteEnabled===!1,i=!n;if(n&&await dt(e.key),i)try{let g=await H(`${L}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:Y(e.key),hostPublicKey:ot(),hostX25519Key:it()})});if(!g.ok)throw new Error(`Session create failed: ${g.status}`);await q("/api/signaling/retry",{}),Dt(e.key)}catch(g){Vr.error(`Failed to connect: ${g.message}`),i=!1}await M(I.TUNNELING);let s=i?await Bn(e.key,L):null,a=Un(L,s),c=s?.oneTimeKey||"",l=a,u="",f=null,p={current:null},d=async g=>{u=g,await Nt(e.key,g),await K({tunnelUrl:g}),cn(g),f!==null&&(f=await Tn(c,e.key,l,u),t?.())},h=null;if(i)try{h=await Xe(P,d,ze({onUrlUpdate:d,setTunnel:g=>{p.current=g}}))}catch(g){Vr.error(`Tunnel spawn failed: ${g?.message||g} \u2014 QR RTC-only, bg retry`)}h&&(p.current=h.child,u=h.tunnelUrl,Cn({apiKey:e.key,tunnelUrl:h.tunnelUrl,tunnelPid:h.child?.pid}),await M(I.VERIFYING),await pt(h.tunnelUrl)?await d(h.tunnelUrl):(Vr.warn("Tunnel health check timed out \u2014 bg reconnect"),p.current=null,u="",h=null)),!h&&i&&Sn(P,{onUrlUpdate:d,onRestart:ze({onUrlUpdate:d,setTunnel:g=>{p.current=g}}),setActiveTunnel:g=>{p.current=g},onReady:async g=>{Cn({apiKey:e.key,tunnelUrl:g.tunnelUrl,tunnelPid:g.child?.pid}),await M(I.READY,{tunnelUrl:g.tunnelUrl})}}),i?await M(I.READY,{tunnelUrl:u,oneTimeKey:s?.oneTimeKey||"",oneTimeKeyExpiresAt:s?.expiresAt||null,permanentKey:e.key,qrUrl:a,workerUrl:L}):(await M(I.STOPPED,{tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null,permanentKey:e.key,qrUrl:"",workerUrl:L}),console.log(m.red(`
249
- \u26A0 ${n?"Remote is disabled \u2014 enable it in Web UI settings":'Remote not connected \u2014 tap "remote \xB7 offline" in the Web UI to retry'}. Local mode.
250
- `))),await new Promise(g=>setTimeout(g,ne.trayReadyMs)),f=await Tn(c,e.key,l,u);let w=[],E=!1,O=()=>{E||t?.()},T=async(g,b,_)=>{if(!E){E=!0;try{let $=await Hi(b,_);await q(`/api/device/${$?"approve":"reject"}`,{socketId:g})}catch{}finally{E=!1,t?.()}}},A=Wi(P,async(g,b)=>{if(g==="log"&&b.message)w.push(b.message),w.length>We.maxLogLines&&w.shift();else if(g==="state"){let _=b.permanentKey||e.key,$=b.oneTimeKey!==void 0?b.oneTimeKey:c,X=b.qrUrl!==void 0?b.qrUrl:l,ae=b.tunnelUrl!==void 0?b.tunnelUrl:u;($!==c||_!==e.key||ae!==u)&&(c=$,l=X,u=ae,b.permanentKey&&(e={...e,key:b.permanentKey}),f=await Tn(c,e.key,l,u),O())}else g==="permissions"?(E||Promise.resolve(bn?.()).catch(()=>{}),O()):g==="autostart"||g==="sleepInhibit"?(E||Promise.resolve(bn?.()).catch(()=>{}),O()):g==="deviceApproval"&&b.action==="pending"&&await T(b.socketId,b.deviceId,b.ip)}),k=setInterval(async()=>{if(!E)try{let b=(await Z("/api/device/pending"))?.pending?.[0];b&&await T(b.socketId,b.deviceId,b.ip)}catch{}},Ae.pendingApprovalMs);ht({getProcess:r.getProcess,shutdown:()=>{et(),r.shutdown();try{p.current?.kill()}catch{}A(),clearInterval(k)}}),wt(()=>p.current,g=>{p.current=g},e.key,()=>r),await lu(e,u,()=>f,g=>{f=g},g=>{t=g},()=>{et();try{A()}catch{}try{clearInterval(k)}catch{}Ze({serverManager:r,tunnelProcess:p.current,exit:!1})},w)}async function lu(e,t,r,o,n,i,s){for(;;){let{desktopEnabled:a,remoteAvailable:c,autoApprove:l}=await lo(),u=[{label:"Open Web UI",action:"webui"}];j().remoteEnabled!==!1&&u.push({label:"Keys \u25B6",action:"keys"}),c&&u.push({label:`Remote Desktop: ${a?m.green("ON"):m.gray("OFF")} \u25B6`,action:"desktop"}),u.push({label:`Manage Devices \u25B6 ${m.dim("(Auto-approve:")} ${l?m.green("ON"):m.gray("OFF")}${m.dim(")")}`,action:"devices"},{label:"Settings \u25B6",action:"settings"},{label:"View Logs",action:"logs"},{label:m.gray("Exit"),action:"exit"});let f=null;n(()=>f?.());let p=await Le("",u,0,r,h=>{f=h},i),d=p>=0?u[p].action:"exit";if(d==="webui"){let h=`http://localhost:${P}`,{openBrowser:w}=await Promise.resolve().then(()=>($t(),ra));w(h),console.log(m.green(`
248
+ `)),await new Promise(c=>setTimeout(c,ne.bgSpawnFlushMs)),process.exit(0)}var Va=x(require("readline"),1);var qr=B("mode"),Rn=null;async function Ya(){Ce("agent",process.pid),console.clear(),Wi(),Xi(!0),await $(I.PREPARING);let e=await lt(),n=null,r={getProcess:()=>null,shutdown:()=>{}};if(!await V()){r=gt(null,null,()=>{if(process.stdin.isTTY){try{process.stdin.setRawMode(!1)}catch{}try{process.stdin.setRawMode(!0),process.stdin.resume()}catch{}}try{Va.default.emitKeypressEvents(process.stdin)}catch{}n?.()});let g=Date.now()+Re.serverReadyTimeoutMs;for(;Date.now()<g&&!await V();)await new Promise(T=>setTimeout(T,Re.serverReadyIntervalMs))}try{ce(),await new Promise(g=>setTimeout(g,ne.killCloudflaredTuiMs))}catch{}try{await sr(kr)}catch(g){qr.error(`cloudflared setup failed: ${g?.message||g} \u2014 retry from Web UI`)}await $(I.CONNECTING);let t=W().remoteEnabled===!1,i=!t;if(t&&await ht(e.key),i)try{let g=await H(`${L}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:q(e.key),hostPublicKey:st(),hostX25519Key:at()})});if(!g.ok)throw new Error(`Session create failed: ${g.status}`);await G("/api/signaling/retry",{}),Ut(e.key)}catch(g){qr.error(`Failed to connect: ${g.message}`),i=!1}await $(I.TUNNELING);let s=i?await Kn(e.key,L):null,a=Hn(L,s),c=s?.oneTimeKey||"",l=a,u="",f=null,p={current:null},d=async g=>{u=g,await Bt(e.key,g),await K({tunnelUrl:g}),fn(g),f!==null&&(f=await xn(c,e.key,l,u),n?.())},h=null;if(i)try{h=await Qe(P,d,tt({onUrlUpdate:d,setTunnel:g=>{p.current=g}}))}catch(g){qr.error(`Tunnel spawn failed: ${g?.message||g} \u2014 QR RTC-only, bg retry`)}h&&(p.current=h.child,u=h.tunnelUrl,Dn({apiKey:e.key,tunnelUrl:h.tunnelUrl,tunnelPid:h.child?.pid}),await $(I.VERIFYING),await mt(h.tunnelUrl)?await d(h.tunnelUrl):(qr.warn("Tunnel health check timed out \u2014 bg reconnect"),p.current=null,u="",h=null)),!h&&i&&An(P,{onUrlUpdate:d,onRestart:tt({onUrlUpdate:d,setTunnel:g=>{p.current=g}}),setActiveTunnel:g=>{p.current=g},onReady:async g=>{Dn({apiKey:e.key,tunnelUrl:g.tunnelUrl,tunnelPid:g.child?.pid}),await $(I.READY,{tunnelUrl:g.tunnelUrl})}}),i?await $(I.READY,{tunnelUrl:u,oneTimeKey:s?.oneTimeKey||"",oneTimeKeyExpiresAt:s?.expiresAt||null,permanentKey:e.key,qrUrl:a,workerUrl:L}):(await $(I.STOPPED,{tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null,permanentKey:e.key,qrUrl:"",workerUrl:L}),console.log(m.red(`
249
+ \u26A0 ${t?"Remote is disabled \u2014 enable it in Web UI settings":'Remote not connected \u2014 tap "remote \xB7 offline" in the Web UI to retry'}. Local mode.
250
+ `))),await new Promise(g=>setTimeout(g,ne.trayReadyMs)),f=await xn(c,e.key,l,u);let w=[],E=!1,O=()=>{E||n?.()},b=async(g,T,_)=>{if(!E){E=!0;try{let C=await Gi(T,_);await G(`/api/device/${C?"approve":"reject"}`,{socketId:g})}catch{}finally{E=!1,n?.()}}},A=Vi(P,async(g,T)=>{if(g==="log"&&T.message)w.push(T.message),w.length>Ge.maxLogLines&&w.shift();else if(g==="state"){let _=T.permanentKey||e.key,C=T.oneTimeKey!==void 0?T.oneTimeKey:c,Q=T.qrUrl!==void 0?T.qrUrl:l,le=T.tunnelUrl!==void 0?T.tunnelUrl:u;(C!==c||_!==e.key||le!==u)&&(c=C,l=Q,u=le,T.permanentKey&&(e={...e,key:T.permanentKey}),f=await xn(c,e.key,l,u),O())}else g==="permissions"?(E||Promise.resolve(Rn?.()).catch(()=>{}),O()):g==="autostart"||g==="sleepInhibit"?(E||Promise.resolve(Rn?.()).catch(()=>{}),O()):g==="deviceApproval"&&T.action==="pending"&&await b(T.socketId,T.deviceId,T.ip)}),k=setInterval(async()=>{if(!E)try{let T=(await Z("/api/device/pending"))?.pending?.[0];T&&await b(T.socketId,T.deviceId,T.ip)}catch{}},Re.pendingApprovalMs);yt({getProcess:r.getProcess,shutdown:()=>{nt(),r.shutdown();try{p.current?.kill()}catch{}A(),clearInterval(k)}}),Et(()=>p.current,g=>{p.current=g},e.key,()=>r),await hu(e,u,()=>f,g=>{f=g},g=>{n=g},()=>{nt();try{A()}catch{}try{clearInterval(k)}catch{}et({serverManager:r,tunnelProcess:p.current,exit:!1})},w)}async function hu(e,n,r,o,t,i,s){for(;;){let{desktopEnabled:a,remoteAvailable:c,autoApprove:l}=await mo(),u=[{label:"Open Web UI",action:"webui"}];W().remoteEnabled!==!1&&u.push({label:"Keys \u25B6",action:"keys"}),c&&u.push({label:`Remote Desktop: ${a?m.green("ON"):m.gray("OFF")} \u25B6`,action:"desktop"}),u.push({label:`Manage Devices \u25B6 ${m.dim("(Auto-approve:")} ${l?m.green("ON"):m.gray("OFF")}${m.dim(")")}`,action:"devices"},{label:"Settings \u25B6",action:"settings"},{label:"View Logs",action:"logs"},{label:m.gray("Exit"),action:"exit"});let f=null;t(()=>f?.());let p=await $e("",u,0,r,h=>{f=h},i),d=p>=0?u[p].action:"exit";if(d==="webui"){let h=`http://localhost:${P}`,{openBrowser:w}=await Promise.resolve().then(()=>(Dt(),sa));w(h),console.log(m.green(`
251
251
  \u{1F310} Opening ${h}
252
- `))}else if(d==="keys")await uu(e,t,o,r);else if(d==="desktop")await du();else if(d==="devices")await mu();else if(d==="settings")await pu();else if(d==="logs")await hu();else{try{i?.()}catch{}console.log(m.gray(`
252
+ `))}else if(d==="keys")await gu(e,n,o,r);else if(d==="desktop")await vu();else if(d==="devices")await Eu();else if(d==="settings")await wu();else if(d==="logs")await Su();else{try{i?.()}catch{}console.log(m.gray(`
253
253
  Goodbye!
254
- `)),process.exit(0)}}}async function uu(e,t,r,o){let n=j().remoteEnabled===!1?[{label:m.gray("Remote access is off \u2014 enable it in the Web UI"),action:"back"}]:[{label:"New One-Time Key",action:"otk"},{label:"Regenerate Permanent Key",action:"regen"},{label:m.gray("\u2190 Back"),action:"back"}],i=await Le("Keys",n,0,o),s=i>=0?n[i].action:"back";if(s==="otk"){let a=await Bn(e.key,L);if(a){let c=Un(L,a);r(await Tn(a.oneTimeKey,e.key,c,t)),await K({oneTimeKey:a.oneTimeKey,oneTimeKeyExpiresAt:a.expiresAt,qrUrl:c})}}else if(s==="regen"&&await ao(m.yellow("Replace current key and disconnect all sessions? Continue?"))){let c=await jt(),l=St(c);if(!await bt(l,L,t,e.key)){r(m.red("Key regeneration failed \u2014 could not reach the server"));return}let u=Ke(c,l,e.name||"Default");Object.assign(e,u),r(await Tn("",e.key,"",t)),await K({permanentKey:e.key,oneTimeKey:"",oneTimeKeyExpiresAt:null,qrUrl:"",pairingUsed:!0})}}var Xo={none:"Off","30m":"Off after 30 min idle","1h":"Off after 1 hour idle","2h":"Off after 2 hours idle","4h":"Off after 4 hours idle","24h":"Off after 24 hours idle",never:"Never off"};async function fu(e,t){let r=t.map(s=>({label:Xo[s]||s,action:s}));r.push({label:m.gray("\u2190 Back"),action:"back"});let o=Math.max(0,t.indexOf(e)),n=await Le("Prevent sleep",r,o),i=n>=0?r[n].action:"back";i!=="back"&&await q("/api/sleep-inhibit",{mode:i})}async function pu(){for(;;){let e=!1,t="never",r=[],o=()=>[{label:`Launch on system startup: ${e?m.green("ON"):m.gray("OFF")}`,action:"autostart"},{label:`Prevent sleep: ${t==="none"?m.gray(Xo.none):m.green(Xo[t]||t)} \u25B6`,action:"sleep"},{label:m.gray("\u2190 Back"),action:"back"}],n=o(),i=null,s=async()=>{let l=await lo();e=!!l.autoStart,t=l.sleepInhibitMode||"never",r=l.sleepInhibitPresets||[],n=o(),i?.()};await s(),bn=s;let a=await Le("Settings",n,0,"",l=>{i=l});bn=null;let c=a>=0?n[a].action:"back";if(c==="autostart")await q("/api/autostart",{enabled:!e});else if(c==="sleep")await fu(t,r);else return}}async function du(){for(;;){let e=!1,t={screenRecording:!1,accessibility:!1},r=()=>({toggle:`Toggle: ${e?m.green("ON \u2192 turn OFF"):m.gray("OFF \u2192 turn ON")}`,sr:`Screen Recording ${t.screenRecording?m.green("\u2713"):m.red("\u2717 (click to grant)")}`,ax:`Mouse & Keyboard control ${t.accessibility?m.green("\u2713"):m.red("\u2717 (click to grant)")}`}),o=[{label:""},{label:""},{label:""},{label:m.gray("\u2190 Back")}],n=null,i=async()=>{let a=await Z("/api/ui/state")||{};e=!!a.desktopEnabled,t={screenRecording:!!a.screenRecording,accessibility:!!a.accessibility};let c=r();o[0].label=c.toggle,o[1].label=c.sr,o[2].label=c.ax,n?.()};await i(),bn=i;let s=await Le("Remote Desktop",o,0,"",a=>{n=a});if(bn=null,s===0)await q("/api/desktop/toggle",{enabled:!e});else if(s===1&&!t.screenRecording)await q("/api/permissions/request",{type:"screenRecording"})||vr("screenRecording");else if(s===2&&!t.accessibility)await q("/api/permissions/request",{type:"accessibility"})||vr("accessibility");else if(s===3||s===-1)return}}async function mu(){for(;;){let[e,t]=await Promise.all([Z("/api/device/approved"),Z("/api/device/auto-approve")]),r=e?.devices||[],o=!!t?.enabled,n=[{label:`Auto-approve new devices: ${o?m.green("ON"):m.gray("OFF")}`,action:"toggle"},...r.map(a=>{let c=a.deviceId.slice(0,8),l=a.approvedAt?new Date(a.approvedAt).toLocaleString():"unknown";return{label:`${c}... ${m.dim(l)}`,action:"remove",deviceId:a.deviceId}}),{label:m.gray("\u2190 Back"),action:"back"}],i=await Le(`Approved Devices (${r.length})`,n,0);if(i===-1)return;let s=n[i];if(s.action==="back")return;if(s.action==="toggle"){await q("/api/device/auto-approve",{enabled:!o});continue}s.action==="remove"&&await ao(m.yellow(`Remove device ${s.deviceId.slice(0,8)}...?`))&&await q("/api/device/remove",{deviceId:s.deviceId})}}async function hu(){let e=bi(ni),t=e.length?e.join(`
254
+ `)),process.exit(0)}}}async function gu(e,n,r,o){let t=W().remoteEnabled===!1?[{label:m.gray("Remote access is off \u2014 enable it in the Web UI"),action:"back"}]:[{label:"New One-Time Key",action:"otk"},{label:"Regenerate Permanent Key",action:"regen"},{label:m.gray("\u2190 Back"),action:"back"}],i=await $e("Keys",t,0,o),s=i>=0?t[i].action:"back";if(s==="otk"){let a=await Kn(e.key,L);if(a){let c=Hn(L,a);r(await xn(a.oneTimeKey,e.key,c,n)),await K({oneTimeKey:a.oneTimeKey,oneTimeKeyExpiresAt:a.expiresAt,qrUrl:c})}}else if(s==="regen"&&await fo(m.yellow("Replace current key and disconnect all sessions? Continue?"))){let c=await Yt(),l=Tt(c);if(!await xt(l,L,n,e.key)){r(m.red("Key regeneration failed \u2014 could not reach the server"));return}let u=je(c,l,e.name||"Default");Object.assign(e,u),r(await xn("",e.key,"",n)),await K({permanentKey:e.key,oneTimeKey:"",oneTimeKeyExpiresAt:null,qrUrl:"",pairingUsed:!0})}}var Zo={none:"Off","30m":"Off after 30 min idle","1h":"Off after 1 hour idle","2h":"Off after 2 hours idle","4h":"Off after 4 hours idle","24h":"Off after 24 hours idle",never:"Never off"};async function yu(e,n){let r=n.map(s=>({label:Zo[s]||s,action:s}));r.push({label:m.gray("\u2190 Back"),action:"back"});let o=Math.max(0,n.indexOf(e)),t=await $e("Prevent sleep",r,o),i=t>=0?r[t].action:"back";i!=="back"&&await G("/api/sleep-inhibit",{mode:i})}async function wu(){for(;;){let e=!1,n="never",r=[],o=()=>[{label:`Launch on system startup: ${e?m.green("ON"):m.gray("OFF")}`,action:"autostart"},{label:`Prevent sleep: ${n==="none"?m.gray(Zo.none):m.green(Zo[n]||n)} \u25B6`,action:"sleep"},{label:m.gray("\u2190 Back"),action:"back"}],t=o(),i=null,s=async()=>{let l=await mo();e=!!l.autoStart,n=l.sleepInhibitMode||"never",r=l.sleepInhibitPresets||[],t=o(),i?.()};await s(),Rn=s;let a=await $e("Settings",t,0,"",l=>{i=l});Rn=null;let c=a>=0?t[a].action:"back";if(c==="autostart")await G("/api/autostart",{enabled:!e});else if(c==="sleep")await yu(n,r);else return}}async function vu(){for(;;){let e=!1,n={screenRecording:!1,accessibility:!1},r=()=>({toggle:`Toggle: ${e?m.green("ON \u2192 turn OFF"):m.gray("OFF \u2192 turn ON")}`,sr:`Screen Recording ${n.screenRecording?m.green("\u2713"):m.red("\u2717 (click to grant)")}`,ax:`Mouse & Keyboard control ${n.accessibility?m.green("\u2713"):m.red("\u2717 (click to grant)")}`}),o=[{label:""},{label:""},{label:""},{label:m.gray("\u2190 Back")}],t=null,i=async()=>{let a=await Z("/api/ui/state")||{};e=!!a.desktopEnabled,n={screenRecording:!!a.screenRecording,accessibility:!!a.accessibility};let c=r();o[0].label=c.toggle,o[1].label=c.sr,o[2].label=c.ax,t?.()};await i(),Rn=i;let s=await $e("Remote Desktop",o,0,"",a=>{t=a});if(Rn=null,s===0)await G("/api/desktop/toggle",{enabled:!e});else if(s===1&&!n.screenRecording)await G("/api/permissions/request",{type:"screenRecording"})||br("screenRecording");else if(s===2&&!n.accessibility)await G("/api/permissions/request",{type:"accessibility"})||br("accessibility");else if(s===3||s===-1)return}}async function Eu(){for(;;){let[e,n]=await Promise.all([Z("/api/device/approved"),Z("/api/device/auto-approve")]),r=e?.devices||[],o=!!n?.enabled,t=[{label:`Auto-approve new devices: ${o?m.green("ON"):m.gray("OFF")}`,action:"toggle"},...r.map(a=>{let c=a.deviceId.slice(0,8),l=a.approvedAt?new Date(a.approvedAt).toLocaleString():"unknown";return{label:`${c}... ${m.dim(l)}`,action:"remove",deviceId:a.deviceId}}),{label:m.gray("\u2190 Back"),action:"back"}],i=await $e(`Approved Devices (${r.length})`,t,0);if(i===-1)return;let s=t[i];if(s.action==="back")return;if(s.action==="toggle"){await G("/api/device/auto-approve",{enabled:!o});continue}s.action==="remove"&&await fo(m.yellow(`Remove device ${s.deviceId.slice(0,8)}...?`))&&await G("/api/device/remove",{deviceId:s.deviceId})}}async function Su(){let e=Ri(ii),n=e.length?e.join(`
255
255
  `):m.gray(" No logs yet"),r=`
256
- ${m.dim("Log file:")} ${m.cyan(Dn)}
257
- ${m.dim(`Tail: tail -f ${Dn}`)}`;await Le("Logs",[{label:m.gray("\u2190 Back")}],0,t+r)}async function Ga(){let e=_e(),t=await Ps(),r=so(e,t?.latest??null),o=[];t?.latest&&o.push({label:m.yellow(`Update to v${t.latest}`),action:"update"}),o.push({label:"Open Web UI (background)",action:"ui"},{label:"Terminal UI",action:"tui"},{label:m.gray("Exit"),action:"exit"});let n=await Le("",o,0,r),i=n>=0?o[n].action:"exit";if(i==="update"){let s=Math.min(We.headerWidth,process.stdout.columns||We.headerWidth);$r(),console.log(fe.orange(`
256
+ ${m.dim("Log file:")} ${m.cyan(Fn)}
257
+ ${m.dim(`Tail: tail -f ${Fn}`)}`;await $e("Logs",[{label:m.gray("\u2190 Back")}],0,n+r)}async function Xa(){let e=Me(),n=await Ls(),r=uo(e,n?.latest??null),o=[];n?.latest&&o.push({label:m.yellow(`Update to v${n.latest}`),action:"update"}),o.push({label:"Open Web UI (background)",action:"ui"},{label:"Terminal UI",action:"tui"},{label:m.gray("Exit"),action:"exit"});let t=await $e("",o,0,r),i=t>=0?o[t].action:"exit";if(i==="update"){let s=Math.min(Ge.headerWidth,process.stdout.columns||Ge.headerWidth);Br(),console.log(de.orange(`
258
258
  `+"\u2550".repeat(s))),console.log(m.gray(` \u2713 Stopped running instances
259
259
  `)),console.log(m.yellow(` \u2B06 Run this command to update:
260
- `)),console.log(m.white.bold(` npm i -g ${Ue}
261
- `)),console.log(fe.orange("\u2550".repeat(s))+`
262
- `),process.exit(0)}else i==="ui"?await Ha():i==="tui"?await ja():process.exit(0)}var Va=[["9remote","Interactive menu (TUI). Falls back to help with no TTY."],["9remote start","Run server + tunnel in foreground (headless)."],["9remote key","Show permanent key + connect URL."],["9remote key --new","Regenerate the permanent key."],["9remote otk","Create a fresh one-time connect key + URL."],["9remote devices","List approved devices."],["9remote auto-approve <on|off>","Toggle device auto-approve."],["9remote approve <socketId>","Approve a pending device."],["9remote help","Show this help."]];function qo(){Jt(_e()),console.log(m.white.bold(`
260
+ `)),console.log(m.white.bold(` npm i -g ${Ke}
261
+ `)),console.log(de.orange("\u2550".repeat(s))+`
262
+ `),process.exit(0)}else i==="ui"?await Ga():i==="tui"?await Ya():process.exit(0)}var Qa=x(require("node:fs"),1);var bu=["--profile","-p"];function Tu(e){let n=[],r={};for(let o=0;o<e.length;o++){let t=e[o];if(bu.includes(t)){r.profile=e[++o];continue}if(t==="--url"){r.url=e[++o];continue}if(t==="--max-steps"){r.maxSteps=Number(e[++o]);continue}if(t==="--attach"){r.mode="attach";continue}if(t==="--no-headless"){r.headless=!1;continue}if(t==="--enter"){r.enter=!0;continue}if(t==="--only"){r.only=e[++o];continue}if(t==="--expect-text"){(r.expectText||=[]).push(e[++o]);continue}if(t==="--expect-url"){r.expectUrl=e[++o];continue}if(t==="--expect-title"){r.expectTitle=e[++o];continue}if(t==="--tail"){r.tail=!0;continue}n.push(t)}return{positional:n,opts:r}}async function ie(e,n){await V()||(console.error("9remote server is not running \u2014 start it first (9remote ui / start)"),process.exit(1));let r=await G("/api/browser-use",{action:e,payload:n});return r||(console.error("Local API unreachable"),process.exit(1)),r.json()}function se(e){return e?.ok||(console.error(e?.error||"Request failed"),process.exit(1)),e}function jt(e){console.log(`${e.url}`),console.log(`${e.title||""} \xB7 ${e.actions?.length??0} elements \xB7 ${e.w}x${e.h}`);for(let n of(e.actions||[]).slice(0,40)){let r=n.kind==="fill"&&n.value?` = ${n.value.slice(0,30)}`:"";console.log(` [${n.id}] ${n.kind.padEnd(6)} ${String(n.label).slice(0,60)}${r}`)}}function Au(e){let n=[],r="",o=null;for(let t of e){if(o){r+=t,t===o&&(o=null);continue}if(t==='"'||t==="'"){o=t,r+=t;continue}if(t===";"){n.push(r.trim()),r="";continue}r+=t}return r.trim()&&n.push(r.trim()),n.filter(Boolean)}function xu(e){let n=e.match(/^(click|select|type|enter|scroll|wait|run)\b\s*(.*)$/);if(!n)throw new Error(`Cannot parse step: ${e}`);let[,r,o]=n,t=o.match(/"[^"]*"|'[^']*'|\S+/g)||[],i=s=>String(s).replace(/^["']|["']$/g,"");switch(r){case"click":case"select":return{op:r,id:i(t[0])};case"type":{let s=t.includes("--enter"),a=t.filter(c=>c!=="--enter");return{op:r,id:i(a[0]),text:i(a.slice(1).join(" ")),enter:s}}case"enter":return{op:r};case"scroll":return{op:r,direction:i(t[0])||"down"};case"wait":{let s=t[0];return s&&/^["']/.test(s)?{op:r,text:i(s)}:{op:r,ms:Number(s)||300}}default:{let s=t.indexOf("--only");return{op:"run",goal:i(t.filter((c,l)=>l!==s&&l!==s+1).join(" ")),only:s>=0?i(t[s+1]):void 0}}}}function Ru(e){for(let n of e.steps||[]){let r=[`#${n.seq}`,n.operation,n.targetIndex?`[${n.targetIndex}]`:"",n.label||""].filter(Boolean).join(" ");console.log(` ${r} \xB7 ${n.result}`)}console.log(`outcome: ${e.outcome}${e.reason?` \u2014 ${e.reason}`:""}`),console.log(`metrics: ${e.metrics?.steps??0} steps \xB7 ${e.metrics?.modelCalls??0} jev calls \xB7 ${Math.round((e.metrics?.elapsedMs??0)/100)/10}s`),console.log(`url: ${e.url||""}`),e.outcome==="needs_verification"&&console.log("element table below \u2014 verify before claiming success (shot for visual).")}var qa=`9remote browser \u2014 agent-driven Chrome via the host engine
263
+
264
+ 9remote browser open <url> [--profile N] [--attach] [--no-headless]
265
+ # opens AND prints the element table
266
+ 9remote browser state [--profile N] numbered element table
267
+ 9remote browser read [--tail] [--profile N] filtered page TEXT (cheaper than shot)
268
+ 9remote browser run "<sub-goal>" [--url URL] [--max-steps N] [--only REGEX] [--profile N]
269
+ # --only: Jev sees only matching element labels
270
+ # --expect-text "..." (repeatable) / --expect-url / --expect-title:
271
+ # engine verifies them on a fresh read \u2014 only PASSED is success
272
+ 9remote browser click <id> [options] click table id (e3)
273
+ 9remote browser type <id> "<text>" [--enter] type exact text (+ Enter) into field
274
+ 9remote browser chain "click e1; type e2 'hi' --enter; wait 'result'" # many steps, ONE call
275
+ 9remote browser enter press Enter
276
+ 9remote browser shot [--profile N] writes /tmp/9remote-shot-*.jpg, prints the path
277
+ 9remote browser close [--profile N]
278
+ 9remote browser profiles list|create <name>|delete <name>
279
+ 9remote browser attach check real-browser attach status
280
+ 9remote browser status config + sessions`;async function Ja(e){let{positional:n,opts:r}=Tu(e),[o,...t]=n,i=(s={})=>({profile:r.profile,...r,...s});switch(o){case void 0:case"help":console.log(qa);return;case"open":{let s=se(await ie("open",i({url:t[0]})));console.log(`opened ${t[0]} (profile ${r.profile||"default"})`),s.state&&jt(s.state);return}case"state":{let s=se(await ie("state",i()));jt(s);return}case"read":{let s=se(await ie("state",i())),a=(s.headings||[]).join(" \u203A ");a&&console.log(`## ${a}`);let c=s.text||"";console.log(r.tail?c.slice(Math.floor(c.length/2)):c),c.trim()||console.log("(no readable text in view \u2014 scroll or open an article first)");return}case"run":{let s=se(await ie("run",i({goal:t.join(" ")})));if(Ru(s),s.verification){console.log(`verification: ${s.verification.passed?"PASSED \u2014 independently verified, safe to report success":"FAILED"}`);for(let[a,c]of Object.entries(s.verification.checks))c||console.log(` not met: ${a}`)}s.state&&jt(s.state);return}case"click":{let s=se(await ie("click",i({id:t[0]})));console.log(`clicked ${t[0]}`),s.state&&jt(s.state);return}case"type":{let s=se(await ie("type",i({id:t[0],text:t.slice(1).join(" "),enter:!!r.enter})));console.log(`typed into ${t[0]}${r.enter?" + enter":""}`),s.state&&jt(s.state);return}case"enter":{let s=se(await ie("enter",i()));console.log("enter pressed"),s.state&&jt(s.state);return}case"shot":{let s=se(await ie("shot",i())),a=`/tmp/9remote-shot-${Date.now()}.jpg`;Qa.default.writeFileSync(a,Buffer.from(s.image,"base64")),console.log(a);return}case"chain":{let s=Au(t.join(" ")).map(xu),a=await ie("chain",i({steps:s}));if(!a?.results){se(a);return}for(let c of a.results)console.log(` ${c.ok?"ok":"FAIL"} #${c.step} ${c.summary||c.op}${c.error?` \u2014 ${c.error}`:""}`);a.failedStep&&console.error(`chain stopped at step ${a.failedStep}`),a.state&&jt(a.state);return}case"close":se(await ie("close",i())),console.log("closed");return;case"profiles":{if(t[0]==="create"){se(await ie("profiles.create",{name:t[1]})),console.log(`created ${t[1]}`);return}if(t[0]==="delete"){se(await ie("profiles.delete",{name:t[1]})),console.log(`deleted ${t[1]}`);return}if(t[0]==="rename"){se(await ie("profiles.rename",{from:t[1],to:t[2]})),console.log(`renamed ${t[1]} -> ${t[2]}`);return}let s=se(await ie("profiles.list",{}));console.log((s.profiles||[]).map(a=>a.name).join(`
281
+ `));return}case"attach":{let s=se(await ie("attach.status",{}));s.available?console.log(`attached (port ${s.port})`):(console.log("not attached:"),(s.guide||[]).forEach((a,c)=>console.log(` ${c+1}. ${a}`)));return}case"status":{let s=se(await ie("status",{}));console.log(JSON.stringify(s,null,2));return}default:console.error(`Unknown browser subcommand: ${o}
282
+ `),console.log(qa),process.exit(1)}}var Za=[["9remote","Interactive menu (TUI). Falls back to help with no TTY."],["9remote start","Run server + tunnel in foreground (headless)."],["9remote key","Show permanent key + connect URL."],["9remote key --new","Regenerate the permanent key."],["9remote otk","Create a fresh one-time connect key + URL."],["9remote devices","List approved devices."],["9remote auto-approve <on|off>","Toggle device auto-approve."],["9remote approve <socketId>","Approve a pending device."],["9remote help","Show this help."]];function Qr(){en(Me()),console.log(m.white.bold(`
263
283
  Usage:
264
- `));let e=Math.max(...Va.map(([t])=>t.length))+2;for(let[t,r]of Va)console.log(" "+m.cyan(t.padEnd(e))+m.gray(r));console.log()}async function cr(){return await Q()?!0:(console.log(m.red(`
284
+ `));let e=Math.max(...Za.map(([n])=>n.length))+2;for(let[n,r]of Za)console.log(" "+m.cyan(n.padEnd(e))+m.gray(r));console.log()}async function fr(){return await V()?!0:(console.log(m.red(`
265
285
  \u2717 Server not running. Start it first: `)+m.cyan("9remote start")+`
266
- `),!1)}async function gu(e){if(!await cr())return;if(e){let r=await q("/api/key/regenerate"),o=r&&r.ok?await r.json():null;if(!o?.permanentKey){console.log(m.red(`
286
+ `),!1)}async function ku(e){if(!await fr())return;if(e){let r=await G("/api/key/regenerate"),o=r&&r.ok?await r.json():null;if(!o?.permanentKey){console.log(m.red(`
267
287
  \u2717 Regenerate failed
268
288
  `));return}console.log(m.green(`
269
289
  \u2713 New key: `)+m.white.bold(o.permanentKey)+`
270
- `);return}let t=await Z("/api/ui/state")||{};if(!t.permanentKey){console.log(m.red(`
290
+ `);return}let n=await Z("/api/ui/state")||{};if(!n.permanentKey){console.log(m.red(`
271
291
  \u2717 No key yet. Run: `)+m.cyan("9remote start")+`
272
292
  `);return}console.log(m.white(`
273
- Key`.padEnd(14))+m.white.bold(t.permanentKey)),t.qrUrl&&console.log(m.white("Connect URL".padEnd(14))+m.cyan(t.qrUrl)),console.log(m.white("App URL".padEnd(14))+m.gray(`${L}/login`)+`
274
- `)}async function yu(){if(!await cr())return;let e=await q("/api/key/one-time"),t=e&&e.ok?await e.json():null;if(!t?.qrUrl){console.log(m.red(`
293
+ Key`.padEnd(14))+m.white.bold(n.permanentKey)),n.qrUrl&&console.log(m.white("Connect URL".padEnd(14))+m.cyan(n.qrUrl)),console.log(m.white("App URL".padEnd(14))+m.gray(`${L}/login`)+`
294
+ `)}async function Pu(){if(!await fr())return;let e=await G("/api/key/one-time"),n=e&&e.ok?await e.json():null;if(!n?.qrUrl){console.log(m.red(`
275
295
  \u2717 Failed to create one-time key
276
296
  `));return}console.log(m.green(`
277
- \u2713 One-time key (30 min): `)+m.white.bold(t.oneTimeKey)),console.log(m.white("Connect URL ")+m.cyan(t.qrUrl)+`
278
- `)}async function wu(){if(!await cr())return;let t=(await Z("/api/device/approved")||{}).devices||[],r=await Z("/api/device/auto-approve")||{};if(console.log(m.white(`
279
- Auto-approve: `)+(r.enabled?m.green("ON"):m.gray("OFF"))),!t.length){console.log(m.gray(`No approved devices
280
- `));return}console.log(m.white(`Approved devices (${t.length}):`));for(let o of t)console.log(" "+m.cyan(o.deviceId));console.log()}async function vu(e){if(!await cr())return;let t=e==="on";if(e!=="on"&&e!=="off"){console.log(m.red(`
297
+ \u2713 One-time key (30 min): `)+m.white.bold(n.oneTimeKey)),console.log(m.white("Connect URL ")+m.cyan(n.qrUrl)+`
298
+ `)}async function Ou(){if(!await fr())return;let n=(await Z("/api/device/approved")||{}).devices||[],r=await Z("/api/device/auto-approve")||{};if(console.log(m.white(`
299
+ Auto-approve: `)+(r.enabled?m.green("ON"):m.gray("OFF"))),!n.length){console.log(m.gray(`No approved devices
300
+ `));return}console.log(m.white(`Approved devices (${n.length}):`));for(let o of n)console.log(" "+m.cyan(o.deviceId));console.log()}async function Iu(e){if(!await fr())return;let n=e==="on";if(e!=="on"&&e!=="off"){console.log(m.red(`
281
301
  \u2717 Usage: 9remote auto-approve <on|off>
282
- `));return}let r=await q("/api/device/auto-approve",{enabled:t}),o=r&&r.ok?await r.json():null;console.log(m.green(`
302
+ `));return}let r=await G("/api/device/auto-approve",{enabled:n}),o=r&&r.ok?await r.json():null;console.log(m.green(`
283
303
  \u2713 Auto-approve: `)+(o?.enabled?m.green("ON"):m.gray("OFF"))+`
284
- `)}async function Eu(e){if(!await cr())return;if(!e){let n=(await Z("/api/device/pending")||{}).pending||[];if(!n.length){console.log(m.gray(`
304
+ `)}async function Lu(e){if(!await fr())return;if(!e){let t=(await Z("/api/device/pending")||{}).pending||[];if(!t.length){console.log(m.gray(`
285
305
  No pending devices
286
306
  `));return}console.log(m.white(`
287
- Pending devices (${n.length}):`));for(let i of n)console.log(" "+m.cyan(i.socketId)+m.gray(` ${i.deviceId?.slice(0,8)||""} ${i.ip||""}`));console.log(m.gray(`
307
+ Pending devices (${t.length}):`));for(let i of t)console.log(" "+m.cyan(i.socketId)+m.gray(` ${i.deviceId?.slice(0,8)||""} ${i.ip||""}`));console.log(m.gray(`
288
308
  Approve with: `)+m.cyan("9remote approve <socketId>")+`
289
- `);return}let t=await q("/api/device/approve",{socketId:e}),r=t&&t.ok?await t.json():null;console.log(r?.ok?m.green(`
309
+ `);return}let n=await G("/api/device/approve",{socketId:e}),r=n&&n.ok?await n.json():null;console.log(r?.ok?m.green(`
290
310
  \u2713 Approved
291
311
  `):m.red(`
292
312
  \u2717 Approve failed (invalid socketId?)
293
- `))}async function Ya(e){let t=e[2],r=e.slice(3);switch(t){case"help":case"-h":case"--help":return qo(),!0;case"key":return await gu(r.includes("--new")),!0;case"otk":return await yu(),!0;case"devices":return await wu(),!0;case"auto-approve":return await vu(r[0]),!0;case"approve":return await Eu(r[0]),!0;default:return!1}}var Qo=process.argv[2];(Qo==="version"||Qo==="--version"||Qo==="-v")&&(process.stdout.write(_e()+`
294
- `),process.exit(0));Ti();async function Su(){let e=process.argv[2];if(await Ya(process.argv))return;process.argv.includes("--tray")||process.argv.includes("--auto")||process.argv.includes("--start")||$r(),e==="ui"?await Da():e==="start"||process.argv.includes("--auto")?await Ua():process.argv.includes("--tray")||process.argv.includes("--start")?await Ba():process.stdin.isTTY?await Ga():qo()}Su().catch(console.error);
313
+ `))}async function za(e){let n=e[2],r=e.slice(3);switch(n){case"help":case"-h":case"--help":return Qr(),!0;case"key":return await ku(r.includes("--new")),!0;case"otk":return await Pu(),!0;case"devices":return await Ou(),!0;case"browser":return await Ja(r),!0;case"auto-approve":return await Iu(r[0]),!0;case"approve":return await Lu(r[0]),!0;default:return!1}}var zo=process.argv[2];(zo==="version"||zo==="--version"||zo==="-v")&&(process.stdout.write(Me()+`
314
+ `),process.exit(0));xi();async function _u(){let e=process.argv[2];if(await za(process.argv))return;let n=process.argv.includes("--tray")||process.argv.includes("--auto")||process.argv.includes("--start"),r=["ui","start","help","-h","--help"].includes(e);if(e&&!e.startsWith("--")&&!r&&!n){Qr();return}n||Br(),e==="ui"?await Fa():e==="start"||process.argv.includes("--auto")?await Ha():process.argv.includes("--tray")||process.argv.includes("--start")?await Ka():process.stdin.isTTY?await Xa():Qr()}_u().catch(console.error);