9remote 3.0.32 → 3.0.34

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 (233) hide show
  1. package/dist/cli.cjs +169 -127
  2. package/dist/extension/background.js +225 -0
  3. package/dist/extension/icons/icon128.png +0 -0
  4. package/dist/extension/icons/icon16.png +0 -0
  5. package/dist/extension/icons/icon48.png +0 -0
  6. package/dist/extension/manifest.json +11 -0
  7. package/dist/extension/popup.html +58 -0
  8. package/dist/extension/popup.js +23 -0
  9. package/dist/ptyDaemon.cjs +9 -9
  10. package/dist/server.cjs +400 -288
  11. package/dist/ui/assets/index-DbuftNJF.js +8 -0
  12. package/dist/ui/index.html +1 -1
  13. package/dist/web/404.html +1 -1
  14. package/dist/web/__next.__PAGE__.txt +2 -2
  15. package/dist/web/__next._full.txt +8 -8
  16. package/dist/web/__next._head.txt +1 -1
  17. package/dist/web/__next._index.txt +7 -7
  18. package/dist/web/__next._tree.txt +2 -2
  19. package/dist/web/_next/static/chunks/1750.09ca4eade7a6e5d3.js +1 -0
  20. package/dist/web/_next/static/chunks/{4300-fb55814d743e1313.js → 4300-7d6c9b3328075562.js} +1 -1
  21. package/dist/web/_next/static/chunks/5788-d4b8dc2ab68396b6.js +1 -0
  22. package/dist/web/_next/static/chunks/{6552-f908d82b4c4161ed.js → 6552-cebe84e4399a184f.js} +1 -1
  23. package/dist/web/_next/static/chunks/6739.22a05398bfd34922.js +1 -0
  24. package/dist/web/_next/static/chunks/8207-45554e2570bc59e6.js +1 -0
  25. package/dist/web/_next/static/chunks/8762-cb470d05070f5ead.js +1 -0
  26. package/dist/web/_next/static/chunks/8922-8660f73e9cd42406.js +1 -0
  27. package/dist/web/_next/static/chunks/{9871-9cd97efc98617c33.js → 9871-c277aedb0437cb82.js} +1 -1
  28. package/dist/web/_next/static/chunks/app/admin/access/{page-3a49e3c597eea658.js → page-65febd13b3d1fc91.js} +1 -1
  29. package/dist/web/_next/static/chunks/app/admin/login/page-8ff8150184b7ccaa.js +1 -0
  30. package/dist/web/_next/static/chunks/app/admin/ota/{page-406ff48a5882efa4.js → page-d8766baa3680522d.js} +1 -1
  31. package/dist/web/_next/static/chunks/app/admin/{page-434461c255fd088a.js → page-6237b1487c05f33e.js} +1 -1
  32. package/dist/web/_next/static/chunks/app/admin/turn/{page-dd7552f387e08b36.js → page-6a6b695b67d59451.js} +1 -1
  33. package/dist/web/_next/static/chunks/app/dev/question/page-bdedfcfce7a3c516.js +1 -0
  34. package/dist/web/_next/static/chunks/app/layout-a0e78c8427f97e4f.js +1 -0
  35. package/dist/web/_next/static/chunks/app/login/{page-80cc1994a494dfed.js → page-edc7457ddecf9262.js} +1 -1
  36. package/dist/web/_next/static/chunks/app/{page-f416e79015c32480.js → page-b76772608a876c23.js} +2 -2
  37. package/dist/web/_next/static/chunks/app/workspace/layout-0fd9ea03182e9c89.js +15 -0
  38. package/dist/web/_next/static/chunks/{webpack-b56d3361b185b0cb.js → webpack-f3500fd1fae71c88.js} +1 -1
  39. package/dist/web/_next/static/css/1b307dedbb687210.css +1 -0
  40. package/dist/web/_not-found/__next._full.txt +7 -7
  41. package/dist/web/_not-found/__next._head.txt +1 -1
  42. package/dist/web/_not-found/__next._index.txt +7 -7
  43. package/dist/web/_not-found/__next._not-found.__PAGE__.txt +1 -1
  44. package/dist/web/_not-found/__next._not-found.txt +1 -1
  45. package/dist/web/_not-found/__next._tree.txt +2 -2
  46. package/dist/web/_not-found.html +1 -1
  47. package/dist/web/_not-found.txt +7 -7
  48. package/dist/web/admin/__next._full.txt +8 -8
  49. package/dist/web/admin/__next._head.txt +1 -1
  50. package/dist/web/admin/__next._index.txt +7 -7
  51. package/dist/web/admin/__next._tree.txt +2 -2
  52. package/dist/web/admin/__next.admin.__PAGE__.txt +2 -2
  53. package/dist/web/admin/__next.admin.txt +1 -1
  54. package/dist/web/admin/access/__next._full.txt +8 -8
  55. package/dist/web/admin/access/__next._head.txt +1 -1
  56. package/dist/web/admin/access/__next._index.txt +7 -7
  57. package/dist/web/admin/access/__next._tree.txt +2 -2
  58. package/dist/web/admin/access/__next.admin.access.__PAGE__.txt +2 -2
  59. package/dist/web/admin/access/__next.admin.access.txt +1 -1
  60. package/dist/web/admin/access/__next.admin.txt +1 -1
  61. package/dist/web/admin/access.html +1 -1
  62. package/dist/web/admin/access.txt +8 -8
  63. package/dist/web/admin/login/__next._full.txt +8 -8
  64. package/dist/web/admin/login/__next._head.txt +1 -1
  65. package/dist/web/admin/login/__next._index.txt +7 -7
  66. package/dist/web/admin/login/__next._tree.txt +2 -2
  67. package/dist/web/admin/login/__next.admin.login.__PAGE__.txt +2 -2
  68. package/dist/web/admin/login/__next.admin.login.txt +1 -1
  69. package/dist/web/admin/login/__next.admin.txt +1 -1
  70. package/dist/web/admin/login.html +1 -1
  71. package/dist/web/admin/login.txt +8 -8
  72. package/dist/web/admin/ota/__next._full.txt +8 -8
  73. package/dist/web/admin/ota/__next._head.txt +1 -1
  74. package/dist/web/admin/ota/__next._index.txt +7 -7
  75. package/dist/web/admin/ota/__next._tree.txt +2 -2
  76. package/dist/web/admin/ota/__next.admin.ota.__PAGE__.txt +2 -2
  77. package/dist/web/admin/ota/__next.admin.ota.txt +1 -1
  78. package/dist/web/admin/ota/__next.admin.txt +1 -1
  79. package/dist/web/admin/ota.html +1 -1
  80. package/dist/web/admin/ota.txt +8 -8
  81. package/dist/web/admin/turn/__next._full.txt +8 -8
  82. package/dist/web/admin/turn/__next._head.txt +1 -1
  83. package/dist/web/admin/turn/__next._index.txt +7 -7
  84. package/dist/web/admin/turn/__next._tree.txt +2 -2
  85. package/dist/web/admin/turn/__next.admin.turn.__PAGE__.txt +2 -2
  86. package/dist/web/admin/turn/__next.admin.turn.txt +1 -1
  87. package/dist/web/admin/turn/__next.admin.txt +1 -1
  88. package/dist/web/admin/turn.html +1 -1
  89. package/dist/web/admin/turn.txt +8 -8
  90. package/dist/web/admin.html +1 -1
  91. package/dist/web/admin.txt +8 -8
  92. package/dist/web/dev/question/__next._full.txt +8 -8
  93. package/dist/web/dev/question/__next._head.txt +1 -1
  94. package/dist/web/dev/question/__next._index.txt +7 -7
  95. package/dist/web/dev/question/__next._tree.txt +2 -2
  96. package/dist/web/dev/question/__next.dev.question.__PAGE__.txt +2 -2
  97. package/dist/web/dev/question/__next.dev.question.txt +1 -1
  98. package/dist/web/dev/question/__next.dev.txt +1 -1
  99. package/dist/web/dev/question.html +1 -1
  100. package/dist/web/dev/question.txt +8 -8
  101. package/dist/web/download/__next._full.txt +8 -8
  102. package/dist/web/download/__next._head.txt +1 -1
  103. package/dist/web/download/__next._index.txt +7 -7
  104. package/dist/web/download/__next._tree.txt +2 -2
  105. package/dist/web/download/__next.download.__PAGE__.txt +2 -2
  106. package/dist/web/download/__next.download.txt +1 -1
  107. package/dist/web/download.html +1 -1
  108. package/dist/web/download.txt +8 -8
  109. package/dist/web/index.html +1 -1
  110. package/dist/web/index.txt +8 -8
  111. package/dist/web/login/__next._full.txt +8 -8
  112. package/dist/web/login/__next._head.txt +1 -1
  113. package/dist/web/login/__next._index.txt +7 -7
  114. package/dist/web/login/__next._tree.txt +2 -2
  115. package/dist/web/login/__next.login.__PAGE__.txt +2 -2
  116. package/dist/web/login/__next.login.txt +1 -1
  117. package/dist/web/login.html +1 -1
  118. package/dist/web/login.txt +8 -8
  119. package/dist/web/sw.js +2 -8
  120. package/dist/web/workspace/__next._full.txt +8 -8
  121. package/dist/web/workspace/__next._head.txt +1 -1
  122. package/dist/web/workspace/__next._index.txt +7 -7
  123. package/dist/web/workspace/__next._tree.txt +2 -2
  124. package/dist/web/workspace/__next.workspace.__PAGE__.txt +1 -1
  125. package/dist/web/workspace/__next.workspace.txt +2 -2
  126. package/dist/web/workspace/browse/__next._full.txt +8 -8
  127. package/dist/web/workspace/browse/__next._head.txt +1 -1
  128. package/dist/web/workspace/browse/__next._index.txt +7 -7
  129. package/dist/web/workspace/browse/__next._tree.txt +2 -2
  130. package/dist/web/workspace/browse/__next.workspace.browse.__PAGE__.txt +1 -1
  131. package/dist/web/workspace/browse/__next.workspace.browse.txt +1 -1
  132. package/dist/web/workspace/browse/__next.workspace.txt +2 -2
  133. package/dist/web/workspace/browse.html +1 -1
  134. package/dist/web/workspace/browse.txt +8 -8
  135. package/dist/web/workspace/editor/__next._full.txt +8 -8
  136. package/dist/web/workspace/editor/__next._head.txt +1 -1
  137. package/dist/web/workspace/editor/__next._index.txt +7 -7
  138. package/dist/web/workspace/editor/__next._tree.txt +2 -2
  139. package/dist/web/workspace/editor/__next.workspace.editor.__PAGE__.txt +1 -1
  140. package/dist/web/workspace/editor/__next.workspace.editor.txt +1 -1
  141. package/dist/web/workspace/editor/__next.workspace.txt +2 -2
  142. package/dist/web/workspace/editor.html +1 -1
  143. package/dist/web/workspace/editor.txt +8 -8
  144. package/dist/web/workspace/files/__next._full.txt +8 -8
  145. package/dist/web/workspace/files/__next._head.txt +1 -1
  146. package/dist/web/workspace/files/__next._index.txt +7 -7
  147. package/dist/web/workspace/files/__next._tree.txt +2 -2
  148. package/dist/web/workspace/files/__next.workspace.files.__PAGE__.txt +1 -1
  149. package/dist/web/workspace/files/__next.workspace.files.txt +1 -1
  150. package/dist/web/workspace/files/__next.workspace.txt +2 -2
  151. package/dist/web/workspace/files.html +1 -1
  152. package/dist/web/workspace/files.txt +8 -8
  153. package/dist/web/workspace/git/__next._full.txt +8 -8
  154. package/dist/web/workspace/git/__next._head.txt +1 -1
  155. package/dist/web/workspace/git/__next._index.txt +7 -7
  156. package/dist/web/workspace/git/__next._tree.txt +2 -2
  157. package/dist/web/workspace/git/__next.workspace.git.__PAGE__.txt +1 -1
  158. package/dist/web/workspace/git/__next.workspace.git.txt +1 -1
  159. package/dist/web/workspace/git/__next.workspace.txt +2 -2
  160. package/dist/web/workspace/git.html +1 -1
  161. package/dist/web/workspace/git.txt +8 -8
  162. package/dist/web/workspace/mobile/__next._full.txt +8 -8
  163. package/dist/web/workspace/mobile/__next._head.txt +1 -1
  164. package/dist/web/workspace/mobile/__next._index.txt +7 -7
  165. package/dist/web/workspace/mobile/__next._tree.txt +2 -2
  166. package/dist/web/workspace/mobile/__next.workspace.mobile.__PAGE__.txt +1 -1
  167. package/dist/web/workspace/mobile/__next.workspace.mobile.txt +1 -1
  168. package/dist/web/workspace/mobile/__next.workspace.txt +2 -2
  169. package/dist/web/workspace/mobile.html +1 -1
  170. package/dist/web/workspace/mobile.txt +8 -8
  171. package/dist/web/workspace/pair/__next._full.txt +8 -8
  172. package/dist/web/workspace/pair/__next._head.txt +1 -1
  173. package/dist/web/workspace/pair/__next._index.txt +7 -7
  174. package/dist/web/workspace/pair/__next._tree.txt +2 -2
  175. package/dist/web/workspace/pair/__next.workspace.pair.__PAGE__.txt +1 -1
  176. package/dist/web/workspace/pair/__next.workspace.pair.txt +1 -1
  177. package/dist/web/workspace/pair/__next.workspace.txt +2 -2
  178. package/dist/web/workspace/pair.html +1 -1
  179. package/dist/web/workspace/pair.txt +8 -8
  180. package/dist/web/workspace/remote/__next._full.txt +8 -8
  181. package/dist/web/workspace/remote/__next._head.txt +1 -1
  182. package/dist/web/workspace/remote/__next._index.txt +7 -7
  183. package/dist/web/workspace/remote/__next._tree.txt +2 -2
  184. package/dist/web/workspace/remote/__next.workspace.remote.__PAGE__.txt +1 -1
  185. package/dist/web/workspace/remote/__next.workspace.remote.txt +1 -1
  186. package/dist/web/workspace/remote/__next.workspace.txt +2 -2
  187. package/dist/web/workspace/remote.html +1 -1
  188. package/dist/web/workspace/remote.txt +8 -8
  189. package/dist/web/workspace/terminal/default/__next._full.txt +8 -8
  190. package/dist/web/workspace/terminal/default/__next._head.txt +1 -1
  191. package/dist/web/workspace/terminal/default/__next._index.txt +7 -7
  192. package/dist/web/workspace/terminal/default/__next._tree.txt +2 -2
  193. package/dist/web/workspace/terminal/default/__next.workspace.terminal.$d$sessionId.__PAGE__.txt +1 -1
  194. package/dist/web/workspace/terminal/default/__next.workspace.terminal.$d$sessionId.txt +1 -1
  195. package/dist/web/workspace/terminal/default/__next.workspace.terminal.txt +1 -1
  196. package/dist/web/workspace/terminal/default/__next.workspace.txt +2 -2
  197. package/dist/web/workspace/terminal/default.html +1 -1
  198. package/dist/web/workspace/terminal/default.txt +8 -8
  199. package/dist/web/workspace/welcome/__next._full.txt +8 -8
  200. package/dist/web/workspace/welcome/__next._head.txt +1 -1
  201. package/dist/web/workspace/welcome/__next._index.txt +7 -7
  202. package/dist/web/workspace/welcome/__next._tree.txt +2 -2
  203. package/dist/web/workspace/welcome/__next.workspace.txt +2 -2
  204. package/dist/web/workspace/welcome/__next.workspace.welcome.__PAGE__.txt +1 -1
  205. package/dist/web/workspace/welcome/__next.workspace.welcome.txt +1 -1
  206. package/dist/web/workspace/welcome.html +1 -1
  207. package/dist/web/workspace/welcome.txt +8 -8
  208. package/dist/web/workspace/workspaces/__next._full.txt +8 -8
  209. package/dist/web/workspace/workspaces/__next._head.txt +1 -1
  210. package/dist/web/workspace/workspaces/__next._index.txt +7 -7
  211. package/dist/web/workspace/workspaces/__next._tree.txt +2 -2
  212. package/dist/web/workspace/workspaces/__next.workspace.txt +2 -2
  213. package/dist/web/workspace/workspaces/__next.workspace.workspaces.__PAGE__.txt +1 -1
  214. package/dist/web/workspace/workspaces/__next.workspace.workspaces.txt +1 -1
  215. package/dist/web/workspace/workspaces.html +1 -1
  216. package/dist/web/workspace/workspaces.txt +8 -8
  217. package/dist/web/workspace.html +1 -1
  218. package/dist/web/workspace.txt +8 -8
  219. package/package.json +5 -2
  220. package/dist/ui/assets/index--4F7rf4t.js +0 -8
  221. package/dist/web/_next/static/chunks/1750.2cbe0f722b879a3b.js +0 -1
  222. package/dist/web/_next/static/chunks/5788-d574869f0879e799.js +0 -1
  223. package/dist/web/_next/static/chunks/6669-178477b6a852b251.js +0 -1
  224. package/dist/web/_next/static/chunks/6739.82570eba0a02cb26.js +0 -1
  225. package/dist/web/_next/static/chunks/8762-62e9a4a001d3e204.js +0 -1
  226. package/dist/web/_next/static/chunks/8922-6961d48ca52e1c93.js +0 -1
  227. package/dist/web/_next/static/chunks/app/admin/login/page-c7bdfdfbcc763df4.js +0 -1
  228. package/dist/web/_next/static/chunks/app/dev/question/page-ab488886d05baea5.js +0 -1
  229. package/dist/web/_next/static/chunks/app/layout-444afebe5b95afff.js +0 -1
  230. package/dist/web/_next/static/chunks/app/workspace/layout-a1024034aa67994d.js +0 -15
  231. package/dist/web/_next/static/css/630ce3b502aeea55.css +0 -1
  232. /package/dist/web/_next/static/{nx78GyCTuW2V1ns5cZIT_ → DdbafQkcX_ZaKRMjMeNKp}/_buildManifest.js +0 -0
  233. /package/dist/web/_next/static/{nx78GyCTuW2V1ns5cZIT_ → DdbafQkcX_ZaKRMjMeNKp}/_ssgManifest.js +0 -0
package/dist/cli.cjs CHANGED
@@ -1,57 +1,57 @@
1
1
  #!/usr/bin/env node
2
2
  const __importMetaUrl = require('url').pathToFileURL(__filename).href;
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}
3
+ var pc=Object.create;var zr=Object.defineProperty;var dc=Object.getOwnPropertyDescriptor;var mc=Object.getOwnPropertyNames;var hc=Object.getPrototypeOf,gc=Object.prototype.hasOwnProperty;var yc=(e,r)=>()=>(e&&(r=e(e=0)),r);var ve=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),wc=(e,r)=>{for(var n in r)zr(e,n,{get:r[n],enumerable:!0})},vc=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of mc(r))!gc.call(e,t)&&t!==n&&zr(e,t,{get:()=>r[t],enumerable:!(o=dc(r,t))||o.enumerable});return e};var A=(e,r,n)=>(n=e!=null?pc(hc(e)):{},vc(r||!e||!e.__esModule?zr(n,"default",{value:e,enumerable:!0}):n,e));var hi=ve((Nn,no)=>{(function(e,r){typeof Nn=="object"&&typeof no=="object"?no.exports=r(require("child_process"),require("crypto")):typeof define=="function"&&define.amd?define(["child_process","crypto"],r):typeof Nn=="object"?Nn["electron-machine-id"]=r(require("child_process"),require("crypto")):e["electron-machine-id"]=r(e.child_process,e.crypto)})(Nn,function(e,r){return(function(n){function o(i){if(t[i])return t[i].exports;var s=t[i]={exports:{},id:i,loaded:!1};return n[i].call(s.exports,s,s.exports,o),s.loaded=!0,s.exports}var t={};return o.m=n,o.c=t,o.p="",o(0)})([function(n,o,t){n.exports=t(34)},function(n,o,t){var i=t(29)("wks"),s=t(33),a=t(2).Symbol,c=typeof a=="function",l=n.exports=function(u){return i[u]||(i[u]=c&&a[u]||(c?a:s)("Symbol."+u))};l.store=i},function(n,o){var t=n.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=t)},function(n,o,t){var i=t(9);n.exports=function(s){if(!i(s))throw TypeError(s+" is not an object!");return s}},function(n,o,t){n.exports=!t(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(n,o,t){var i=t(12),s=t(17);n.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(n,o){var t=n.exports={version:"2.4.0"};typeof __e=="number"&&(__e=t)},function(n,o,t){var i=t(14);n.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(n,o){var t={}.hasOwnProperty;n.exports=function(i,s){return t.call(i,s)}},function(n,o){n.exports=function(t){return typeof t=="object"?t!==null:typeof t=="function"}},function(n,o){n.exports={}},function(n,o){var t={}.toString;n.exports=function(i){return t.call(i).slice(8,-1)}},function(n,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(n,o,t){var i=t(42),s=t(15);n.exports=function(a){return i(s(a))}},function(n,o){n.exports=function(t){if(typeof t!="function")throw TypeError(t+" is not a function!");return t}},function(n,o){n.exports=function(t){if(t==null)throw TypeError("Can't call method on "+t);return t}},function(n,o,t){var i=t(9),s=t(2).document,a=i(s)&&i(s.createElement);n.exports=function(c){return a?s.createElement(c):{}}},function(n,o){n.exports=function(t,i){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:i}}},function(n,o,t){var i=t(12).f,s=t(8),a=t(1)("toStringTag");n.exports=function(c,l,u){c&&!s(c=u?c:c.prototype,a)&&i(c,a,{configurable:!0,value:l})}},function(n,o,t){var i=t(29)("keys"),s=t(33);n.exports=function(a){return i[a]||(i[a]=s(a))}},function(n,o){var t=Math.ceil,i=Math.floor;n.exports=function(s){return isNaN(s=+s)?0:(s>0?i:t)(s)}},function(n,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{}};n.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(n,o){n.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(n,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,v,P=f&u.F,S=f&u.G,x=f&u.S,R=f&u.P,M=f&u.B,g=f&u.W,T=S?s:s[p]||(s[p]={}),L=T[l],C=S?i:x?i[p]:(i[p]||{})[l];S&&(d=p);for(h in d)w=!P&&C&&C[h]!==void 0,w&&h in T||(v=w?C[h]:d[h],T[h]=S&&typeof C[h]!="function"?d[h]:M&&w?a(v,i):g&&C[h]==v?(function(z){var ue=function(xe,fe,He){if(this instanceof z){switch(arguments.length){case 0:return new z;case 1:return new z(xe);case 2:return new z(xe,fe)}return new z(xe,fe,He)}return z.apply(this,arguments)};return ue[l]=z[l],ue})(v):R&&typeof v=="function"?a(Function.call,v):v,R&&((T.virtual||(T.virtual={}))[h]=v,f&u.R&&L&&!L[h]&&c(L,h,v)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,n.exports=u},function(n,o){n.exports=function(t){try{return!!t()}catch{return!0}}},function(n,o,t){n.exports=t(2).document&&document.documentElement},function(n,o,t){n.exports=!t(4)&&!t(24)(function(){return Object.defineProperty(t(16)("div"),"a",{get:function(){return 7}}).a!=7})},function(n,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()),v="@@iterator",P="keys",S="values",x=function(){return this};n.exports=function(R,M,g,T,L,C,z){f(g,M,T);var ue,xe,fe,He=function(b){if(!w&&b in pe)return pe[b];switch(b){case P:return function(){return new g(this,b)};case S:return function(){return new g(this,b)}}return function(){return new g(this,b)}},Vt=M+" Iterator",xt=L==S,$n=!1,pe=R.prototype,st=pe[h]||pe[v]||L&&pe[L],he=st||He(L),On=L?xt?He("entries"):he:void 0,y=M=="Array"&&pe.entries||st;if(y&&(fe=d(y.call(new R)),fe!==Object.prototype&&(p(fe,Vt,!0),i||l(fe,h)||c(fe,h,x))),xt&&st&&st.name!==S&&($n=!0,he=function(){return st.call(this)}),i&&!z||!w&&!$n&&pe[h]||c(pe,h,he),u[M]=he,u[Vt]=x,L)if(ue={values:xt?he:He(S),keys:C?he:He(P),entries:On},z)for(xe in ue)xe in pe||a(pe,xe,ue[xe]);else s(s.P+s.F*(w||$n),M,ue);return ue}},function(n,o){n.exports=!0},function(n,o,t){var i=t(2),s="__core-js_shared__",a=i[s]||(i[s]={});n.exports=function(c){return a[c]||(a[c]={})}},function(n,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,v=p.MessageChannel,P=0,S={},x="onreadystatechange",R=function(){var g=+this;if(S.hasOwnProperty(g)){var T=S[g];delete S[g],T()}},M=function(g){R.call(g.data)};h&&w||(h=function(g){for(var T=[],L=1;arguments.length>L;)T.push(arguments[L++]);return S[++P]=function(){l(typeof g=="function"?g:Function(g),T)},i(P),P},w=function(g){delete S[g]},t(11)(d)=="process"?i=function(g){d.nextTick(c(R,g,1))}:v?(s=new v,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=x in f("script")?function(g){u.appendChild(f("script"))[x]=function(){u.removeChild(this),R.call(g)}}:function(g){setTimeout(c(R,g,1),0)}),n.exports={set:h,clear:w}},function(n,o,t){var i=t(20),s=Math.min;n.exports=function(a){return a>0?s(i(a),9007199254740991):0}},function(n,o,t){var i=t(9);n.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(n,o){var t=0,i=Math.random();n.exports=function(s){return"Symbol(".concat(s===void 0?"":s,")_",(++t+i).toString(36))}},function(n,o,t){"use strict";function i(x){return x&&x.__esModule?x:{default:x}}function s(){return process.platform!=="win32"?"":process.arch==="ia32"&&process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")?"mixed":"native"}function a(x){return(0,h.createHash)("sha256").update(x).digest("hex")}function c(x){switch(v){case"darwin":return x.split("IOPlatformUUID")[1].split(`
4
+ `)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return x.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return x.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return x.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function l(x){var R=c((0,d.execSync)(S[v]).toString());return x?R:a(R)}function u(x){return new p.default(function(R,M){return(0,d.exec)(S[v],{},function(g,T,L){if(g)return M(new Error("Error while obtaining machine id: "+g.stack));var C=c(T.toString());return R(x?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,v=w.platform,P={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},S={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:P[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(n,o,t){n.exports={default:t(36),__esModule:!0}},function(n,o,t){t(66),t(68),t(69),t(67),n.exports=t(6).Promise},function(n,o){n.exports=function(){}},function(n,o){n.exports=function(t,i,s,a){if(!(t instanceof i)||a!==void 0&&a in t)throw TypeError(s+": incorrect invocation!");return t}},function(n,o,t){var i=t(13),s=t(31),a=t(62);n.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(n,d,t){var i=t(7),s=t(44),a=t(43),c=t(3),l=t(31),u=t(64),f={},p={},d=n.exports=function(h,w,v,P,S){var x,R,M,g,T=S?function(){return h}:u(h),L=i(v,P,w?2:1),C=0;if(typeof T!="function")throw TypeError(h+" is not iterable!");if(a(T)){for(x=l(h.length);x>C;C++)if(g=w?L(c(R=h[C])[0],R[1]):L(h[C]),g===f||g===p)return g}else for(M=T.call(h);!(R=M.next()).done;)if(g=s(M,L,R.value,w),g===f||g===p)return g};d.BREAK=f,d.RETURN=p},function(n,o){n.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(n,o,t){var i=t(11);n.exports=Object("z").propertyIsEnumerable(0)?Object:function(s){return i(s)=="String"?s.split(""):Object(s)}},function(n,o,t){var i=t(10),s=t(1)("iterator"),a=Array.prototype;n.exports=function(c){return c!==void 0&&(i.Array===c||a[s]===c)}},function(n,o,t){var i=t(3);n.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(n,o,t){"use strict";var i=t(49),s=t(17),a=t(18),c={};t(5)(c,t(1)("iterator"),function(){return this}),n.exports=function(l,u,f){l.prototype=i(c,{next:s(1,f)}),a(l,u+" Iterator")}},function(n,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{}n.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(n,o){n.exports=function(t,i){return{value:i,done:!!t}}},function(n,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";n.exports=function(){var f,p,d,h=function(){var S,x;for(u&&(S=c.domain)&&S.exit();f;){x=f.fn,f=f.next;try{x()}catch(R){throw f?d():p=void 0,R}}p=void 0,S&&S.enter()};if(u)d=function(){c.nextTick(h)};else if(a){var w=!0,v=document.createTextNode("");new a(h).observe(v,{characterData:!0}),d=function(){v.data=w=!w}}else if(l&&l.resolve){var P=l.resolve();d=function(){P.then(h)}}else d=function(){s.call(i,h)};return function(S){var x={fn:S,next:void 0};p&&(p.next=x),f||(f=x,d()),p=x}}},function(n,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()};n.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(n,o,t){var i=t(12),s=t(3),a=t(54);n.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(n,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(n,o,t){var i=t(8),s=t(63),a=t(19)("IE_PROTO"),c=Object.prototype;n.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(n,o,t){var i=t(8),s=t(13),a=t(39)(!1),c=t(19)("IE_PROTO");n.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(n,o,t){var i=t(53),s=t(22);n.exports=Object.keys||function(a){return i(a,s)}},function(n,o){o.f={}.propertyIsEnumerable},function(n,o,t){var i=t(5);n.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(n,o,t){n.exports=t(5)},function(n,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!")};n.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(n,o,t){"use strict";var i=t(2),s=t(6),a=t(12),c=t(4),l=t(1)("species");n.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(n,o,t){var i=t(3),s=t(14),a=t(1)("species");n.exports=function(c,l){var u,f=i(c).constructor;return f===void 0||(u=i(f)[a])==null?l:s(u)}},function(n,o,t){var i=t(20),s=t(15);n.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(n,o,t){var i=t(20),s=Math.max,a=Math.min;n.exports=function(c,l){return c=i(c),c<0?s(c+l,0):a(c,l)}},function(n,o,t){var i=t(15);n.exports=function(s){return Object(i(s))}},function(n,o,t){var i=t(21),s=t(1)("iterator"),a=t(10);n.exports=t(6).getIteratorMethod=function(c){if(c!=null)return c[s]||c["@@iterator"]||a[i(c)]}},function(n,o,t){"use strict";var i=t(37),s=t(47),a=t(10),c=t(13);n.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(n,o){},function(n,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),v=t(40),P=(t(58).set,t(60)),S=t(30).set,x=t(48)(),R="Promise",M=l.TypeError,T=l.process,g=l[R],T=l.process,L=f(T)=="process",C=function(){},z=!!(function(){try{var y=g.resolve(1),b=(y.constructor={})[t(1)("species")]=function(k){k(C,C)};return(L||typeof PromiseRejectionEvent=="function")&&y.then(C)instanceof b}catch{}})(),ue=function(y,b){return y===b||y===g&&b===a},xe=function(y){var b;return!(!d(y)||typeof(b=y.then)!="function")&&b},fe=function(y){return ue(g,y)?new He(y):new s(y)},He=s=function(y){var b,k;this.promise=new y(function(U,oe){if(b!==void 0||k!==void 0)throw M("Bad Promise constructor");b=U,k=oe}),this.resolve=h(b),this.reject=h(k)},Vt=function(y){try{y()}catch(b){return{error:b}}},xt=function(y,b){if(!y._n){y._n=!0;var k=y._c;x(function(){for(var U=y._v,oe=y._s==1,At=0,Yt=function(at){var Le,mr,In=oe?at.ok:at.fail,Ln=at.resolve,Xt=at.reject,hr=at.domain;try{In?(oe||(y._h==2&&st(y),y._h=1),In===!0?Le=U:(hr&&hr.enter(),Le=In(U),hr&&hr.exit()),Le===at.promise?Xt(M("Promise-chain cycle")):(mr=xe(Le))?mr.call(Le,Ln,Xt):Ln(Le)):Xt(U)}catch(fc){Xt(fc)}};k.length>At;)Yt(k[At++]);y._c=[],y._n=!1,b&&!y._h&&$n(y)})}},$n=function(y){S.call(l,function(){var b,k,U,oe=y._v;if(pe(y)&&(b=Vt(function(){L?T.emit("unhandledRejection",oe,y):(k=l.onunhandledrejection)?k({promise:y,reason:oe}):(U=l.console)&&U.error&&U.error("Unhandled promise rejection",oe)}),y._h=L||pe(y)?2:1),y._a=void 0,b)throw b.error})},pe=function(y){if(y._h==1)return!1;for(var b,k=y._a||y._c,U=0;k.length>U;)if(b=k[U++],b.fail||!pe(b.promise))return!1;return!0},st=function(y){S.call(l,function(){var b;L?T.emit("rejectionHandled",y):(b=l.onrejectionhandled)&&b({promise:y,reason:y._v})})},he=function(y){var b=this;b._d||(b._d=!0,b=b._w||b,b._v=y,b._s=2,b._a||(b._a=b._c.slice()),xt(b,!0))},On=function(y){var b,k=this;if(!k._d){k._d=!0,k=k._w||k;try{if(k===y)throw M("Promise can't be resolved itself");(b=xe(y))?x(function(){var U={_w:k,_d:!1};try{b.call(y,u(On,U,1),u(he,U,1))}catch(oe){he.call(U,oe)}}):(k._v=y,k._s=1,xt(k,!1))}catch(U){he.call({_w:k,_d:!1},U)}}};z||(g=function(y){w(this,g,R,"_h"),h(y),i.call(this);try{y(u(On,this,1),u(he,this,1))}catch(b){he.call(this,b)}},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,b){var k=fe(P(this,g));return k.ok=typeof y!="function"||y,k.fail=typeof b=="function"&&b,k.domain=L?T.domain:void 0,this._c.push(k),this._a&&this._a.push(k),this._s&&xt(this,!1),k.promise},catch:function(y){return this.then(void 0,y)}}),He=function(){var y=new i;this.promise=y,this.resolve=u(On,y,1),this.reject=u(he,y,1)}),p(p.G+p.W+p.F*!z,{Promise:g}),t(18)(g,R),t(59)(R),a=t(6)[R],p(p.S+p.F*!z,R,{reject:function(y){var b=fe(this),k=b.reject;return k(y),b.promise}}),p(p.S+p.F*(c||!z),R,{resolve:function(y){if(y instanceof g&&ue(y.constructor,this))return y;var b=fe(this),k=b.resolve;return k(y),b.promise}}),p(p.S+p.F*!(z&&t(46)(function(y){g.all(y).catch(C)})),R,{all:function(y){var b=this,k=fe(b),U=k.resolve,oe=k.reject,At=Vt(function(){var Yt=[],at=0,Le=1;v(y,!1,function(mr){var In=at++,Ln=!1;Yt.push(void 0),Le++,b.resolve(mr).then(function(Xt){Ln||(Ln=!0,Yt[In]=Xt,--Le||U(Yt))},oe)}),--Le||U(Yt)});return At&&oe(At.error),k.promise},race:function(y){var b=this,k=fe(b),U=k.reject,oe=Vt(function(){v(y,!1,function(At){b.resolve(At).then(k.resolve,U)})});return oe&&U(oe.error),k.promise}})},function(n,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(n,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(n,o){n.exports=require("child_process")},function(n,o){n.exports=require("crypto")}])})});var ma={};wc(ma,{initTray:()=>cr,killTray:()=>Bt,openBrowser:()=>Ut,showTrayNotification:()=>Ho,updateTrayTooltip:()=>Tn});function sa(e){for(let r of e)try{if(En.default.existsSync(r))return r}catch{}return null}function ou(){if(process.platform==="win32"){for(let e of fa)try{if(En.default.existsSync(e))return En.default.readFileSync(e).toString("base64")}catch{}return ia}return ia}function iu(){if(process.env.NREMOTE_DESKTOP)return!1;let e=process.platform;return!(!["darwin","win32","linux"].includes(e)||e==="linux"&&!process.env.DISPLAY)}function pa(){let{port:e,tunnelUrl:r,running:n}=Sn,o=n?r?"Tunnel ON":"Local only":"Idle",t=`http://localhost:${e}`;return`9Remote \u2022 ${o}
5
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="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",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+`
6
+ Right-click to open / quit`}function da(){let{port:e,tunnelUrl:r}=Sn,n=process.platform==="win32",o=r?`9Remote (Port ${e}) \u2022 Tunnel ON`:`9Remote (Port ${e}) \u2022 Local only`;return{icon:ou(),title:n?`9Remote - Port ${e}`:"",tooltip:pa(),items:[{title:o,tooltip:r||`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 su(){try{let e=require(Ue.default.join(ua,"systray2"));return e.default?.default||e.default||e}catch{return null}}function au({port:e,onQuit:r,onOpenUI:n}){let o=sa(fa),t=sa(ru);if(!o||!t)return null;let i;try{i=(0,et.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 aa.default.createInterface({input:i.stdout}).on("line",c=>{try{let l=JSON.parse(c);if(l.type!=="click")return;l.index===0?n?.():l.index===1&&(r?.(),Bt(),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 cr({port:e,onQuit:r,onOpenUI:n}){if(!iu())return null;if(process.platform==="win32")return Sn={port:e,tunnelUrl:"",running:!0},ae=au({port:e,onQuit:r,onOpenUI:n}),ae;try{let o=su();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=Ue.default.join(ua,"systray2","traybin",i);if(!En.default.existsSync(s))return null;if(process.platform!=="win32")try{En.default.chmodSync(s,493)}catch{}if(Sn={port:e,tunnelUrl:"",running:!0},ae=new o({menu:da(),debug:!1,copyDir:!0}),ae.onClick(a=>{let c=a.item?.title||a.item;c==="Open Web UI"?n?.():c==="Shutdown"&&(r?.(),Bt(),setTimeout(()=>process.exit(0),500))}),typeof ae.ready=="function")try{await ae.ready()}catch{return ae=null,null}else ae.onReady(()=>{}),ae.onError(()=>{});return ae}catch{return null}}function Tn({tunnelUrl:e,running:r}={}){if(e!==void 0&&(Sn.tunnelUrl=e),r!==void 0&&(Sn.running=r),!!ae){if(ae._isWin){ae._setTooltip?.(pa());return}try{ae.sendAction({type:"update-menu",menu:da(),seq_id:-1})?.catch?.(()=>{})}catch{}}}function Bt(){let e=ae;if(ae=null,e)try{e.kill(!0)}catch{}}function Ho({title:e="9Remote",message:r}){let n=process.platform;if(r){if(n==="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(r)}</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(r)}';`,"$n.Visible = $true;","$n.ShowBalloonTip(5000);","Start-Sleep -Seconds 6;","$n.Dispose();","}"].join(" ");try{(0,et.spawn)("powershell.exe",["-NoProfile","-WindowStyle","Hidden","-Command",a],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(n==="darwin"){try{let o=s=>String(s).replace(/"/g,'\\"'),t=`display notification "${o(r)}" with title "${o(e)}"`;(0,et.spawn)("osascript",["-e",t],{detached:!0,stdio:"ignore"}).unref()}catch{}return}try{(0,et.spawn)("notify-send",[e,r],{detached:!0,stdio:"ignore"}).unref()}catch{}}}function Ut(e){let r=process.platform;if(r==="win32"){try{(0,et.spawn)("rundll32.exe",["url.dll,FileProtocolHandler",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref();return}catch{}try{(0,et.spawn)("cmd.exe",["/d","/s","/c","start","",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(r==="darwin"){try{(0,et.spawn)("open",[e],{detached:!0,stdio:"ignore"}).unref()}catch{}return}let n=[["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 n)try{(0,et.spawn)(o,t,{detached:!0,stdio:"ignore",env:{...process.env}}).unref();return}catch{}}var et,aa,En,Ue,ca,la,ua,ae,Sn,Hr,ia,fa,ru,Ft=yc(()=>{et=require("child_process"),aa=A(require("readline"),1),En=A(require("fs"),1),Ue=A(require("path"),1),ca=A(require("os"),1),la=require("url"),ua=(0,Ue.join)(ca.default.homedir(),".9remote","runtime","node_modules"),ae=null,Sn={port:0,tunnelUrl:"",running:!1},Hr=Ue.default.dirname((0,la.fileURLToPath)(__importMetaUrl)),ia="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",fa=[Ue.default.join(Hr,"assets","trayIcon.ico"),Ue.default.join(Hr,"..","assets","trayIcon.ico")],ru=[Ue.default.join(Hr,"assets","tray.ps1"),Ue.default.join(Hr,"..","assets","tray.ps1")]});var qo=ve((ad,Sa)=>{Sa.exports={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}});var Aa=ve((cd,xa)=>{var fu=qo();function Ta(e){this.mode=fu.MODE_8BIT_BYTE,this.data=e}Ta.prototype={getLength:function(){return this.data.length},write:function(e){for(var r=0;r<this.data.length;r++)e.put(this.data.charCodeAt(r),8)}};xa.exports=Ta});var Qo=ve((ld,ka)=>{var Ie={glog:function(e){if(e<1)throw new Error("glog("+e+")");return Ie.LOG_TABLE[e]},gexp:function(e){for(;e<0;)e+=255;for(;e>=256;)e-=255;return Ie.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(q=0;q<8;q++)Ie.EXP_TABLE[q]=1<<q;var q;for(q=8;q<256;q++)Ie.EXP_TABLE[q]=Ie.EXP_TABLE[q-4]^Ie.EXP_TABLE[q-5]^Ie.EXP_TABLE[q-6]^Ie.EXP_TABLE[q-8];var q;for(q=0;q<255;q++)Ie.LOG_TABLE[Ie.EXP_TABLE[q]]=q;var q;ka.exports=Ie});var Jo=ve((ud,Ra)=>{var Wt=Qo();function Vr(e,r){if(e.length===void 0)throw new Error(e.length+"/"+r);for(var n=0;n<e.length&&e[n]===0;)n++;this.num=new Array(e.length-n+r);for(var o=0;o<e.length-n;o++)this.num[o]=e[o+n]}Vr.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var r=new Array(this.getLength()+e.getLength()-1),n=0;n<this.getLength();n++)for(var o=0;o<e.getLength();o++)r[n+o]^=Wt.gexp(Wt.glog(this.get(n))+Wt.glog(e.get(o)));return new Vr(r,0)},mod:function(e){if(this.getLength()-e.getLength()<0)return this;for(var r=Wt.glog(this.get(0))-Wt.glog(e.get(0)),n=new Array(this.getLength()),o=0;o<this.getLength();o++)n[o]=this.get(o);for(var t=0;t<e.getLength();t++)n[t]^=Wt.gexp(Wt.glog(e.get(t))+r);return new Vr(n,0).mod(e)}};Ra.exports=Vr});var $a=ve((fd,Pa)=>{Pa.exports={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7}});var La=ve((pd,Ia)=>{var Te=qo(),Oa=Jo(),pu=Qo(),Et=$a(),re={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 r=e<<10;re.getBCHDigit(r)-re.getBCHDigit(re.G15)>=0;)r^=re.G15<<re.getBCHDigit(r)-re.getBCHDigit(re.G15);return(e<<10|r)^re.G15_MASK},getBCHTypeNumber:function(e){for(var r=e<<12;re.getBCHDigit(r)-re.getBCHDigit(re.G18)>=0;)r^=re.G18<<re.getBCHDigit(r)-re.getBCHDigit(re.G18);return e<<12|r},getBCHDigit:function(e){for(var r=0;e!==0;)r++,e>>>=1;return r},getPatternPosition:function(e){return re.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,r,n){switch(e){case Et.PATTERN000:return(r+n)%2===0;case Et.PATTERN001:return r%2===0;case Et.PATTERN010:return n%3===0;case Et.PATTERN011:return(r+n)%3===0;case Et.PATTERN100:return(Math.floor(r/2)+Math.floor(n/3))%2===0;case Et.PATTERN101:return r*n%2+r*n%3===0;case Et.PATTERN110:return(r*n%2+r*n%3)%2===0;case Et.PATTERN111:return(r*n%3+(r+n)%2)%2===0;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var r=new Oa([1],0),n=0;n<e;n++)r=r.multiply(new Oa([1,pu.gexp(n)],0));return r},getLengthInBits:function(e,r){if(1<=r&&r<10)switch(e){case Te.MODE_NUMBER:return 10;case Te.MODE_ALPHA_NUM:return 9;case Te.MODE_8BIT_BYTE:return 8;case Te.MODE_KANJI:return 8;default:throw new Error("mode:"+e)}else if(r<27)switch(e){case Te.MODE_NUMBER:return 12;case Te.MODE_ALPHA_NUM:return 11;case Te.MODE_8BIT_BYTE:return 16;case Te.MODE_KANJI:return 10;default:throw new Error("mode:"+e)}else if(r<41)switch(e){case Te.MODE_NUMBER:return 14;case Te.MODE_ALPHA_NUM:return 13;case Te.MODE_8BIT_BYTE:return 16;case Te.MODE_KANJI:return 12;default:throw new Error("mode:"+e)}else throw new Error("type:"+r)},getLostPoint:function(e){var r=e.getModuleCount(),n=0,o=0,t=0;for(o=0;o<r;o++)for(t=0;t<r;t++){for(var i=0,s=e.isDark(o,t),a=-1;a<=1;a++)if(!(o+a<0||r<=o+a))for(var c=-1;c<=1;c++)t+c<0||r<=t+c||a===0&&c===0||s===e.isDark(o+a,t+c)&&i++;i>5&&(n+=3+i-5)}for(o=0;o<r-1;o++)for(t=0;t<r-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)&&(n+=3)}for(o=0;o<r;o++)for(t=0;t<r-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)&&(n+=40);for(t=0;t<r;t++)for(o=0;o<r-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)&&(n+=40);var u=0;for(t=0;t<r;t++)for(o=0;o<r;o++)e.isDark(o,t)&&u++;var f=Math.abs(100*u/r/r-50)/5;return n+=f*10,n}};Ia.exports=re});var Zo=ve((dd,_a)=>{_a.exports={L:1,M:0,Q:3,H:2}});var Ca=ve((md,Ma)=>{var Yr=Zo();function Fe(e,r){this.totalCount=e,this.dataCount=r}Fe.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]];Fe.getRSBlocks=function(e,r){var n=Fe.getRsBlockTable(e,r);if(n===void 0)throw new Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+r);for(var o=n.length/3,t=[],i=0;i<o;i++)for(var s=n[i*3+0],a=n[i*3+1],c=n[i*3+2],l=0;l<s;l++)t.push(new Fe(a,c));return t};Fe.getRsBlockTable=function(e,r){switch(r){case Yr.L:return Fe.RS_BLOCK_TABLE[(e-1)*4+0];case Yr.M:return Fe.RS_BLOCK_TABLE[(e-1)*4+1];case Yr.Q:return Fe.RS_BLOCK_TABLE[(e-1)*4+2];case Yr.H:return Fe.RS_BLOCK_TABLE[(e-1)*4+3];default:return}};Ma.exports=Fe});var Ba=ve((hd,Da)=>{function Na(){this.buffer=[],this.length=0}Na.prototype={get:function(e){var r=Math.floor(e/8);return(this.buffer[r]>>>7-e%8&1)==1},put:function(e,r){for(var n=0;n<r;n++)this.putBit((e>>>r-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){var r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),e&&(this.buffer[r]|=128>>>this.length%8),this.length++}};Da.exports=Na});var Ha=ve((gd,Ka)=>{var du=Aa(),St=La(),mu=Jo(),Ua=Ca(),Fa=Ba();function Ke(e,r){this.typeNumber=e,this.errorCorrectLevel=r,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}Ke.prototype={addData:function(e){var r=new du(e);this.dataList.push(r),this.dataCache=null},isDark:function(e,r){if(e<0||this.moduleCount<=e||r<0||this.moduleCount<=r)throw new Error(e+","+r);return this.modules[e][r]},getModuleCount:function(){return this.moduleCount},make:function(){if(this.typeNumber<1){var e=1;for(e=1;e<40;e++){for(var r=Ua.getRSBlocks(e,this.errorCorrectLevel),n=new Fa,o=0,t=0;t<r.length;t++)o+=r[t].dataCount;for(var i=0;i<this.dataList.length;i++){var s=this.dataList[i];n.put(s.mode,4),n.put(s.getLength(),St.getLengthInBits(s.mode,e)),s.write(n)}if(n.getLengthInBits()<=o*8)break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,r){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var n=0;n<this.moduleCount;n++){this.modules[n]=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++)this.modules[n][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,r),this.typeNumber>=7&&this.setupTypeNumber(e),this.dataCache===null&&(this.dataCache=Ke.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,r)},setupPositionProbePattern:function(e,r){for(var n=-1;n<=7;n++)if(!(e+n<=-1||this.moduleCount<=e+n))for(var o=-1;o<=7;o++)r+o<=-1||this.moduleCount<=r+o||(0<=n&&n<=6&&(o===0||o===6)||0<=o&&o<=6&&(n===0||n===6)||2<=n&&n<=4&&2<=o&&o<=4?this.modules[e+n][r+o]=!0:this.modules[e+n][r+o]=!1)},getBestMaskPattern:function(){for(var e=0,r=0,n=0;n<8;n++){this.makeImpl(!0,n);var o=St.getLostPoint(this);(n===0||e>o)&&(e=o,r=n)}return r},createMovieClip:function(e,r,n){var o=e.createEmptyMovieClip(r,n),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 r=8;r<this.moduleCount-8;r++)this.modules[6][r]===null&&(this.modules[6][r]=r%2===0)},setupPositionAdjustPattern:function(){for(var e=St.getPatternPosition(this.typeNumber),r=0;r<e.length;r++)for(var n=0;n<e.length;n++){var o=e[r],t=e[n];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 r=St.getBCHTypeNumber(this.typeNumber),n,o=0;o<18;o++)n=!e&&(r>>o&1)===1,this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3]=n;for(var t=0;t<18;t++)n=!e&&(r>>t&1)===1,this.modules[t%3+this.moduleCount-8-3][Math.floor(t/3)]=n},setupTypeInfo:function(e,r){for(var n=this.errorCorrectLevel<<3|r,o=St.getBCHTypeInfo(n),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,r){for(var n=-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=St.getMask(r,o,s-a);l&&(c=!c),this.modules[o][s-a]=c,t--,t===-1&&(i++,t=7)}if(o+=n,o<0||this.moduleCount<=o){o-=n,n=-n;break}}}};Ke.PAD0=236;Ke.PAD1=17;Ke.createData=function(e,r,n){for(var o=Ua.getRSBlocks(e,r),t=new Fa,i=0;i<n.length;i++){var s=n[i];t.put(s.mode,4),t.put(s.getLength(),St.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(Ke.PAD0,8),t.getLengthInBits()>=a*8));)t.put(Ke.PAD1,8);return Ke.createBytes(t,o)};Ke.createBytes=function(e,r){for(var n=0,o=0,t=0,i=new Array(r.length),s=new Array(r.length),a=0;a<r.length;a++){var c=r[a].dataCount,l=r[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+n];n+=c;var f=St.getErrorCorrectPolynomial(l),p=new mu(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 v=0,P=0;P<r.length;P++)v+=r[P].totalCount;for(var S=new Array(v),x=0,R=0;R<o;R++)for(var M=0;M<r.length;M++)R<i[M].length&&(S[x++]=i[M][R]);for(var g=0;g<t;g++)for(var T=0;T<r.length;T++)g<s[T].length&&(S[x++]=s[T][g]);return S};Ka.exports=Ke});var Ga=ve((yd,Wa)=>{var hu=Ha(),ja=Zo(),gu="\x1B[40m \x1B[0m",Xr="\x1B[47m \x1B[0m",yu=function(e){return e?gu:Xr},zo=function(e){return{times:function(r){return new Array(r).join(e)}}},wu=function(e,r){for(var n=new Array(e),o=0;o<e;o++)n[o]=r;return n};Wa.exports={error:ja.L,generate:function(e,r,n){typeof r=="function"&&(n=r,r={});var o=new hu(-1,this.error);o.addData(e),o.make();var t="";if(r&&r.small){var i=!0,s=!1,a=o.getModuleCount(),c=o.modules.slice(),l=a%2===1;l&&c.push(wu(a,s));var u={WHITE_ALL:"\u2588",WHITE_BLACK:"\u2580",BLACK_WHITE:"\u2584",BLACK_ALL:" "},f=zo(u.BLACK_WHITE).times(a+3),p=zo(u.WHITE_BLACK).times(a+3);t+=f+`
8
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(`
9
+ `}l||(t+=p)}else{var w=zo(Xr).times(o.getModuleCount()+3);t+=w+`
10
+ `,o.modules.forEach(function(v){t+=Xr,t+=v.map(yu).join(""),t+=Xr+`
11
+ `}),t+=w}n?n(t):console.log(t)},setErrorLevel:function(e){this.error=ja[e]||this.error}}});var yr=require("fs"),Cn=require("path"),di=require("url"),mi=A(require("os"),1);var gr=A(require("dns"),1),Ae=A(require("path"),1),si=A(require("os"),1),ee="9remote",to=process.env.NREMOTE_REGISTRY||`https://registry.npmjs.org/${ee}/latest`,ke=`${ee}@latest`,_e=process.env.NREMOTE_HOME||Ae.default.join(si.default.homedir(),".9remote"),Q={ROOT:_e,LOGS:Ae.default.join(_e,"logs"),STATE:Ae.default.join(_e,"state"),CONFIG:Ae.default.join(_e,"config"),BIN:Ae.default.join(_e,"bin"),PIDS:Ae.default.join(_e,"pids"),BUFFERS:Ae.default.join(_e,"buffers"),DAEMON:Ae.default.join(_e,"daemon"),AI_SESSIONS:Ae.default.join(_e,"ai-sessions"),BACKGROUNDS:Ae.default.join(_e,"backgrounds")},_n=new gr.default.promises.Resolver;_n.setServers(["1.1.1.1","1.0.0.1","8.8.8.8"]);var eo=gr.default.lookup,bc=/^(\d{1,3}\.){3}\d{1,3}$|^::1$|^[0-9a-f:]+$/i;gr.default.lookup=(e,r,n)=>{if(typeof r=="function"&&(n=r,r={}),e==="localhost"||bc.test(e))return eo(e,r,n);(async()=>{if(r.family===6)return{addrs:await _n.resolve6(e),family:6};if(r.family===4)return{addrs:await _n.resolve4(e),family:4};let[t,i]=await Promise.allSettled([_n.resolve4(e),_n.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 eo(e,r,n);r.all?n(null,t.addrs.map(i=>({address:i,family:t.family}))):n(null,t.addrs[0],t.family)}).catch(()=>eo(e,r,n))};var $=2208,ai=process.execPath,ci=(e=process.env)=>process.versions.electron?{...e,ELECTRON_RUN_AS_NODE:"1"}:{...e};var oi=5173,ii=3e3;var Xu=[`http://localhost:${$}`,`http://127.0.0.1:${$}`,`http://localhost:${oi}`,`http://127.0.0.1:${oi}`,`http://localhost:${ii}`,`http://127.0.0.1:${ii}`],Mn={fileName:"agent.log",rotatedName:"agent.log.1",maxBytes:2*1024*1024,cleanupAfterDays:7},li=60,O={STOPPED:0,PREPARING:1,CONNECTING:2,TUNNELING:3,VERIFYING:4,READY:5},ui={showTunnelUrlInMenu:!1};var fi={CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN:"1"};var pi={checkIntervalMs:3e4,requestTimeoutMs:5e3},ge={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}},Ec={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 W(e,r={}){return fetch(e,{...r,headers:{...Ec,...r.headers}})}var Sc=(0,Cn.dirname)((0,di.fileURLToPath)(__importMetaUrl)),Tc=[(0,Cn.join)(mi.default.homedir(),".9remote",".env"),(0,Cn.join)(Sc,"..",".env")];function xc(e){for(let r of e.split(`
12
+ `)){let n=r.trim();if(!n||n.startsWith("#"))continue;let o=n.match(/^([A-Z_][A-Z0-9_]*)\s*=\s*"?(.*?)"?$/);o&&!process.env[o[1]]&&(process.env[o[1]]=o[2])}}for(let e of Tc)if((0,yr.existsSync)(e))try{xc((0,yr.readFileSync)(e,"utf8"))}catch{}for(let[e,r]of Object.entries(fi))process.env[e]||(process.env[e]=r);var To=A(require("path"),1),ws=A(require("fs"),1),vs=require("url");var gi=A(hi(),1),ro=A(require("crypto"),1),{machineIdSync:Ac}=gi.default;async function qt(e=null){let r=e||process.env.MACHINE_ID_SALT||"9remote-salt";try{let n=Ac();return ro.default.createHash("sha256").update(n+r).digest("hex").substring(0,16)}catch(n){return console.error("Error getting machine ID:",n),ro.default.randomUUID().replace(/-/g,"").substring(0,16)}}var vi=A(require("crypto"),1),yi="abcdefghijklmnpqrstuvwxyz123456789",kc=8;function wi(){let e="";for(let r=0;r<kc;r++)e+=yi[vi.default.randomInt(yi.length)];return e}function kt(e){return`sk-${(e||"").slice(0,8).toLowerCase()}-${wi()}-${wi()}`}function oo(e){return/^sk-[a-z0-9]{8}-[a-np-z1-9]{8}-[a-np-z1-9]{8}$/.test(e||"")}function J(e){if(!oo(e))return e||null;let r=e.split("-");return`${r[0]}-${r[1]}-${r[2]}`}function bi(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 wr(e){return!e||e.length<8?"sk-***":`${e.slice(0,3)}***${e.slice(-4)}`}var de=A(require("fs"),1),Bn=A(require("path"),1);var ye=require("fs"),Ei=require("path"),Rc=0;function je(e,r,n={}){let{mode:o=384,spaces:t=2}=n;(0,ye.mkdirSync)((0,Ei.dirname)(e),{recursive:!0});let i=`${e}.${process.pid}.${++Rc}.tmp`;try{(0,ye.writeFileSync)(i,JSON.stringify(r,null,t),{mode:o}),(0,ye.renameSync)(i,e)}catch(s){try{(0,ye.existsSync)(i)&&(0,ye.unlinkSync)(i)}catch{}throw s}}function Si(e,r=null){try{return(0,ye.existsSync)(e)?JSON.parse((0,ye.readFileSync)(e,"utf8")):r}catch{return r}}var nf=Q.STATE,Dn=Bn.default.join(Q.STATE,"state.json"),io=Bn.default.join(Q.ROOT,"keys.json"),vr=Bn.default.join(Q.STATE,"cmd.json"),Ti=Bn.default.join(Q.STATE,"settings.json");function Qt(){for(let e of[Q.ROOT,Q.STATE])de.default.existsSync(e)||de.default.mkdirSync(e,{recursive:!0})}function xi(){try{return Qt(),de.default.existsSync(Dn)?JSON.parse(de.default.readFileSync(Dn,"utf8")):null}catch{return null}}function Un(e){try{Qt(),je(Dn,e)}catch(r){console.error("Error saving state:",r)}}function Ai(){try{de.default.existsSync(Dn)&&de.default.unlinkSync(Dn)}catch{}}function V(){try{return Qt(),de.default.existsSync(Ti)?JSON.parse(de.default.readFileSync(Ti,"utf8"))||{}:{}}catch{return{}}}function Fn(){try{return Qt(),de.default.existsSync(io)?JSON.parse(de.default.readFileSync(io,"utf8")):{machineId:null,key:null,name:"Default",createdAt:null}}catch{return{machineId:null,key:null,name:"Default",createdAt:null}}}function Jt(e){try{Qt(),je(vr,{cmd:e,ts:Date.now()},{spaces:0})}catch{}}function ki(){try{if(!de.default.existsSync(vr))return null;let e=JSON.parse(de.default.readFileSync(vr,"utf8"));return de.default.unlinkSync(vr),e.cmd}catch{return null}}function We(e,r,n="Default"){try{Qt();let o={machineId:e,key:r,name:n,createdAt:new Date().toISOString()};return je(io,o),o}catch(o){return console.error("Error saving key:",o),null}}var Me=A(require("fs"),1),so=A(require("path"),1);var Er=Q.LOGS,Kn=so.default.join(Er,Mn.fileName),Sr=so.default.join(Er,Mn.rotatedName),Ri=!1,Pi=null;function Pc(){Me.default.existsSync(Er)||Me.default.mkdirSync(Er,{recursive:!0})}function $c(){try{if(Me.default.statSync(Kn).size<Mn.maxBytes)return;try{Me.default.rmSync(Sr,{force:!0})}catch{}Me.default.renameSync(Kn,Sr)}catch{}}function Oc(){try{let e=Me.default.statSync(Sr);Date.now()-e.mtimeMs>Mn.cleanupAfterDays*864e5&&Me.default.rmSync(Sr,{force:!0})}catch{}}function ao(e){try{$c(),Me.default.appendFileSync(Kn,e+`
13
+ `)}catch{}}function br(e){return e.map(r=>{if(r instanceof Error)return r.stack||r.message;if(typeof r=="object")try{return JSON.stringify(r)}catch{return String(r)}return String(r)}).join(" ")}var Ic=/\x1b\[[0-9;]*m/g,Lc=/https?:\/\/[^\s]+/g;function _c(e){return String(e).replace(Ic,"").replace(Lc,"").replace(/\s+$/g,"")}function Zt(e,r,n){let o=_c(n);if(!o)return;let t=`${new Date().toISOString()} ${r.toUpperCase()} [${e}] ${o}`;if(ao(t),Pi)try{Pi(t)}catch{}}function Mc(){process.on("uncaughtException",e=>Zt("crash","error",`uncaughtException: ${e?.stack||e?.message||e}`)),process.on("unhandledRejection",e=>{let r=e instanceof Error?e.stack||e.message:String(e);Zt("crash","error",`unhandledRejection: ${r}`)}),process.on("exit",e=>ao(`${new Date().toISOString()} INFO [exit] code=${e} pid=${process.pid}`))}function $i(){Ri||(Ri=!0,Pc(),Oc(),ao(`
14
+ === SESSION ${new Date().toISOString()} pid=${process.pid} argv=${process.argv.slice(2).join(" ")} ===`),Mc())}function Oi(e=60){try{return Me.default.readFileSync(Kn,"utf8").split(`
15
+ `).filter(Boolean).slice(-e)}catch{return[]}}var Cc=process.env.NODE_ENV==="development"||process.env.AGENT_DEBUG==="1";function F(e){return{debug:(...r)=>{Cc&&Zt(e,"debug",br(r))},info:(...r)=>Zt(e,"info",br(r)),warn:(...r)=>Zt(e,"warn",br(r)),error:(...r)=>Zt(e,"error",br(r))}}var Hn=Kn;var ct=A(require("crypto"),1),en=require("fs");var Ii=require("path");var af=Buffer.from("302a300506032b656e","hex");var Tr=(0,Ii.join)(Q.CONFIG,"hostKey.json"),df=Buffer.from("302a300506032b6570032100","hex"),zt=null;function co(){if(zt)return zt;try{if((0,en.existsSync)(Tr)){let s=JSON.parse((0,en.readFileSync)(Tr,"utf8")),a=Buffer.from(s.publicKey,"base64");if(!s.x25519PrivateKey){let l=ct.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"),je(Tr,s)}let c=Buffer.from(s.x25519PublicKey,"base64");return zt={privateKey:ct.default.createPrivateKey({key:Buffer.from(s.privateKey,"base64"),format:"der",type:"pkcs8"}),publicKey:ct.default.createPublicKey({key:a,format:"der",type:"spki"}),publicKeyB64:a.subarray(-32).toString("base64"),x25519PrivateKey:ct.default.createPrivateKey({key:Buffer.from(s.x25519PrivateKey,"base64"),format:"der",type:"pkcs8"}),x25519PublicKeyB64:c.subarray(-32).toString("base64")},zt}}catch{}(0,en.mkdirSync)(Q.CONFIG,{recursive:!0});let{privateKey:e,publicKey:r}=ct.default.generateKeyPairSync("ed25519"),n=r.export({type:"spki",format:"der"}).toString("base64"),o=e.export({type:"pkcs8",format:"der"}).toString("base64"),t=ct.default.generateKeyPairSync("x25519"),i=t.publicKey.export({type:"spki",format:"der"}).toString("base64");return je(Tr,{privateKey:o,publicKey:n,x25519PrivateKey:t.privateKey.export({type:"pkcs8",format:"der"}).toString("base64"),x25519PublicKey:i}),zt={privateKey:e,publicKey:r,publicKeyB64:Buffer.from(n,"base64").subarray(-32).toString("base64"),x25519PrivateKey:t.privateKey,x25519PublicKeyB64:Buffer.from(i,"base64").subarray(-32).toString("base64")},zt}function lt(){return co().publicKeyB64}function ut(){return co().x25519PublicKeyB64}var Nc="9remote-session-v1";function Dc({apiKey:e,tunnelUrl:r,localIp:n,expiryMinutes:o,ts:t}){let i=a=>{let c=a==null?"":String(a);return`${c.length}:${c}`},s=`${Nc}|${i(e)}${i(r)}${i(n)}${i(o)}${i(t)}`;return ct.default.sign(null,Buffer.from(s,"utf8"),co().privateKey).toString("base64")}function Rt(e){let r=Date.now();return{ts:r,sig:Dc({...e,ts:r})}}var _i=A(require("crypto"),1),Mi=require("path");var Bc=F("pairing"),Ci=(0,Mi.join)(Q.STATE,"pairing.json"),Li="ABCDEFGHIJKLMNPQRSTUVWXYZ123456789",Uc=2;function Ni(){let e="";for(let r=0;r<Uc;r++)e+=Li[_i.default.randomInt(Li.length)];return e}function Fc(){let e=Si(Ci,null);return!e||Date.now()>e.expiresAt?null:e}function Kc(e){try{je(Ci,e)}catch(r){Bc.error(`persist pairing state: ${r.message}`)}}function Di(e,r,n,o=null){Kc({tempKey:e,tail:r,expiresAt:n,workerUrl:o})}function Bi(){let e=Fc();return e?{tempKey:e.tempKey,tail:e.tail,expiresAt:e.expiresAt}:null}var lo=F("session"),Hc=10;async function jn(e,r){let n=async()=>{let o=await W(`${r}/api/temp-key/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((()=>{let t={apiKey:J(e),expiryMinutes:Hc};return{...t,...Rt(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 n()}catch(i){if(lo.warn(`Temp key creation failed (${i.message}) \u2014 re-registering session`),!await Pt(e,r))throw i;o=await n()}let t=Ni();return Di(o.tempKey,t,o.expiresAt,r),{...o,oneTimeKey:`${o.tempKey}${t}`}}catch(o){return lo.error(`Temp key creation failed: ${o?.message||o}`),null}}function Wn(e,r){return r?.tempKey?`${e}/login?k=${r.tempKey}#${r.oneTimeKey}`:`${e}/login`}async function Pt(e,r,n,o){try{let t=await W(`${r}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:J(e),hostPublicKey:lt(),hostX25519Key:ut(),tempKey:Bi()?.tempKey||void 0})});if(!t.ok)throw new Error(`HTTP ${t.status}`);return n&&await W(`${r}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:J(e),tunnelUrl:n,...Rt({apiKey:J(e),tunnelUrl:n})})}).catch(()=>{}),o&&J(o)!==J(e)&&await W(`${r}/api/session/delete`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:J(o),...Rt({apiKey:J(o)})})}).catch(()=>{}),!0}catch(t){return lo.error(`Session registration failed: ${t?.message||t}`),!1}}var Ji=A(require("os"),1);var Pr=A(require("readline"),1),Fi=A(require("http"),1);var uo=require("child_process"),jc={screenRecording:"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture",accessibility:"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"};function xr(e){let r=jc[e];r&&process.platform==="darwin"&&(0,uo.exec)(`open "${r}"`,()=>{})}function Re({strategy:e,baseMs:r,maxMs:n},o){let t=Math.max(1,o),i=e==="exp"?r*Math.pow(2,t-1):r*t;return Math.min(i,n)}async function Ar({config:e,task:r,label:n="task",log:o=()=>{},ctx:t={}}){let i=0;for(;!t.cancelled;){i++;try{if(await r(i))return!0}catch(a){o(`\u274C ${n} attempt ${i} error: ${a?.message||a}`)}if(t.cancelled)return!1;let s=Re(e,i);o(`\u{1F504} ${n} retry in ${s}ms (attempt ${i})`),await new Promise(a=>setTimeout(a,s))}return!1}var E={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"},Ki=()=>Math.min(44,process.stdout.columns||44);function po(e,r=null){let o=Ki()-2,t=(a="")=>{let c=a.replace(/\x1b\[[0-9;]*m/g,""),l=Math.max(0,o-c.length);return E.orange+"\u2551"+E.reset+a+" ".repeat(l)+E.orange+"\u2551"+E.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 E.orange+"\u2551"+E.reset+" ".repeat(u)+c(a)+" ".repeat(f)+E.orange+"\u2551"+E.reset},s=["",E.orange+"\u2554"+"\u2550".repeat(o)+"\u2557"+E.reset,t(),i(`\u{1F680} 9Remote v${e}`,a=>E.bold+E.orange+a+E.reset),i("Remote terminal access from anywhere",a=>E.dim+a+E.reset),t()];return r&&(s.push(i(`\u2B06 New version v${r} available!`,a=>E.yellow+E.bold+a+E.reset)),s.push(i(`Run: npm i -g ${ke}`,a=>E.dim+a+E.reset)),s.push(t())),s.push(E.orange+"\u255A"+"\u2550".repeat(o)+"\u255D"+E.reset),s.push(""),s.join(`
16
+ `)}function nn(e,r=null){console.log(po(e,r))}var Ui=["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"],fo=[{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"}],Wc=process.platform==="win32",Gc=Wc?120:80;process.on("exit",()=>process.stdout.write("\x1B[?25h"));var Hi=(e,r)=>{process.stdout.write("\x1B[?25h"),process.listenerCount(e)<=1&&process.exit(r)};process.on("SIGINT",()=>Hi("SIGINT",130));process.on("SIGTERM",()=>Hi("SIGTERM",143));var Ge=0,$t=null,kr=0,Ce=-1,Gn=null,tn=null,Rr=!1;function ji(){let e=[],r=Ce===fo.length-1;return fo.forEach((n,o)=>{let t=o===Ce&&Gn?Gn:n.desc;if(o<Ce||r&&o===Ce)e.push(` ${E.green}\u2713${E.reset} ${E.dim}${n.label}${E.reset}`),tn&&o===tn.afterIdx&&e.push(` ${E.green}\u2713${E.reset} ${E.cyan}${tn.text}${E.reset}`);else if(o===Ce){let i=Ui[kr%Ui.length];e.push(` ${E.orange}${i}${E.reset} ${E.bold}${n.label}${E.reset} ${E.dim}${t}${E.reset}`)}else e.push(` ${E.dim}\u25CB ${n.label}${E.reset}`)}),e}function Wi(){let e=ji();Ge>0&&process.stdout.write(`\x1B[${Ge}A\x1B[0J`),process.stdout.write(e.join(`
17
17
  `)+`
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
- `))process.stdout.write(E+`\x1B[K
20
- `);e&&process.stdout.write(`${S.dim}${e}${S.reset}\x1B[K
18
+ `),Ge=e.length}function Gi(){if(Ge===0||Ce<0)return;let e=ji();if(e.length!==Ge){Wi();return}let r=Ce+(tn&&tn.afterIdx<Ce?1:0),n=Ge-r;process.stdout.write(`\x1B[${n}A\r\x1B[2K${e[r]}\x1B[${n}B\r`)}function Vc(){Rr||(process.stdout.write("\x1B[?25l"),Rr=!0)}function Vi(){Rr&&(process.stdout.write("\x1B[?25h"),Rr=!1)}function Yi(e,r=!1,n=null){$t&&(clearInterval($t),$t=null),Ce=e,Gn=n,kr=0,r||(Ge=0),Wi(),e>=0&&e<fo.length-1?(Vc(),$t=setInterval(()=>{kr++,Gi()},Gc)):Vi()}function rn(e){Gn=e,Ge>0&&Gi()}function Xi(){$t&&(clearInterval($t),$t=null),Vi(),Ge=0,Ce=-1,Gn=null,tn=null,kr=0}function Ne(e,r,n=0,o="",t=null,i=null){return new Promise(s=>{let a=n,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 v of w.split(`
19
+ `))process.stdout.write(v+`\x1B[K
20
+ `);e&&process.stdout.write(`${E.dim}${e}${E.reset}\x1B[K
21
21
  \x1B[K
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(`
22
+ `),r.forEach((v,P)=>{let S=P===a?u?">":"\u2605":u?" ":"\u2606",x=P===a?` \x1B[7m${E.bold}${S} ${v.label}${E.reset}`:` ${S} ${v.label}`;process.stdout.write(x+`\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,v)=>{!c||!v||(v.name==="up"?(a=(a-1+r.length)%r.length,f()):v.name==="down"?(a=(a+1)%r.length,f()):v.name==="return"?(p(),s(a)):v.name==="escape"?(p(),s(-1)):v.ctrl&&v.name==="c"&&(p(),i&&i(),process.exit(0)))};if(process.stdin.removeAllListeners("keypress"),Pr.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 mo(e){return new Promise(r=>{if(process.stdin.removeAllListeners("keypress"),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}if(process.stdin.pause(),process.stdout.write(`${e} (y/N): `),Pr.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{}process.stdin.resume();let n=(o,t)=>{if(!t)return;if(process.stdin.removeListener("keypress",n),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),t.ctrl&&t.name==="c"&&(process.stdout.write(`
24
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
25
+ `),r(i)};process.stdin.on("keypress",n)})}function qi(e,r){return new Promise(n=>{let o=e?e.slice(0,8):"unknown",t=Ki(),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=`${E.orange}${"\u2550".repeat(t)}${E.reset}`;if(process.stdout.write(`\x1B[2J\x1B[H
26
26
  ${s}
27
- ${S.orange}${S.bold} \u{1F514} New Device Connection${S.reset}
27
+ ${E.orange}${E.bold} \u{1F514} New Device Connection${E.reset}
28
28
  ${s}
29
- Device: ${S.cyan}${o}...${S.reset}
30
- IP: ${S.cyan}${n}${S.reset}
29
+ Device: ${E.cyan}${o}...${E.reset}
30
+ IP: ${E.cyan}${r}${E.reset}
31
31
  ${s}
32
32
 
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}
33
+ Allow this device? ${E.dim}(y/n)${E.reset} `),Pr.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,v=w?`${E.green}y${E.reset}
34
34
 
35
- ${S.green}\u2713 Device approved${S.reset}
36
- `:`${S.red}n${S.reset}
35
+ ${E.green}\u2713 Device approved${E.reset}
36
+ `:`${E.red}n${E.reset}
37
37
 
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 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
38
+ ${E.red}\u2717 Device rejected${E.reset}
39
+ `;process.stdout.write(v),setTimeout(()=>{try{a()}catch{}n(w)},500)};process.stdin.on("keypress",c)})}function Qi(e,r){let n=null,o=!1,t=null,i=45e3,s=()=>{t&&clearTimeout(t),t=setTimeout(()=>{try{n?.destroy()}catch{}},i)},a=async()=>{if(o)return;let c=await on();n=Fi.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(r(w.type,w)).catch(()=>{})}catch{}d=""}}),l.on("end",()=>{t&&clearTimeout(t),o||setTimeout(a,Re(ge.sse,1))})}),n.on("error",()=>{t&&clearTimeout(t),o||setTimeout(a,Re(ge.sse,1))})};return a(),()=>{o=!0,t&&clearTimeout(t),n?.destroy()}}var ho=!1;function Zi(e){ho=e}var Vn=null;async function on(){if(Vn)return Vn;let e=o=>fetch(`http://${o}:${$}/api/health`,{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok?o:Promise.reject()),n=(await Promise.allSettled(["localhost","127.0.0.1"].map(e))).map((o,t)=>o.status==="fulfilled"?["localhost","127.0.0.1"][t]:null);return Vn=n.find(o=>o==="localhost")||n.find(Boolean)||null,Vn||"127.0.0.1"}function zi(){Vn=null}async function Y(e,r){let n=await on();try{return await fetch(`http://${n}:${$}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}catch{return zi(),null}}async function te(e){let r=await on();try{let n=await fetch(`http://${r}:${$}${e}`);return n.ok?await n.json():null}catch{return zi(),null}}async function j(e){await Y("/api/ui/state",e)}async function _(e,r={}){ho&&Yi(e-1,e>O.PREPARING),await j({step:e,stepDesc:"",...r})}function $r({phase:e,percent:r}){let n=e==="download"?`Downloading tunnel binary ${r??0}%`:"Extracting tunnel binary";ho&&rn(n),j({stepDesc:n})}async function X(){return!!await te("/api/health")}async function go(){let[e,r,n,o]=await Promise.all([te("/api/ui/state"),te("/api/device/auto-approve"),te("/api/autostart"),te("/api/sleep-inhibit")]);return{desktopEnabled:!!e?.desktopEnabled,remoteAvailable:!!e?.remoteAvailable,autoApprove:!!r?.enabled,autoStart:!!n?.enabled,sleepInhibitMode:o?.mode||"never",sleepInhibitActive:!!o?.active,sleepInhibitPresets:Array.isArray(o?.presets)?o.presets:[]}}function es(){let e=Ji.default.networkInterfaces();for(let r of Object.values(e))for(let n of r)if(n.family==="IPv4"&&!n.internal)return n.address;return null}var ts=(e=0)=>r=>`\x1B[${r+e}m`,ns=(e=0)=>r=>`\x1B[${38+e};5;${r}m`,rs=(e=0)=>(r,n,o)=>`\x1B[${38+e};2;${r};${n};${o}m`,K={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]}},Nf=Object.keys(K.modifier),Yc=Object.keys(K.color),Xc=Object.keys(K.bgColor),Df=[...Yc,...Xc];function qc(){let e=new Map;for(let[r,n]of Object.entries(K)){for(let[o,t]of Object.entries(n))K[o]={open:`\x1B[${t[0]}m`,close:`\x1B[${t[1]}m`},n[o]=K[o],e.set(t[0],t[1]);Object.defineProperty(K,r,{value:n,enumerable:!1})}return Object.defineProperty(K,"codes",{value:e,enumerable:!1}),K.color.close="\x1B[39m",K.bgColor.close="\x1B[49m",K.color.ansi=ts(),K.color.ansi256=ns(),K.color.ansi16m=rs(),K.bgColor.ansi=ts(10),K.bgColor.ansi256=ns(10),K.bgColor.ansi16m=rs(10),Object.defineProperties(K,{rgbToAnsi256:{value(r,n,o){return r===n&&n===o?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(r){let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(r.toString(16));if(!n)return[0,0,0];let[o]=n;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:r=>K.rgbToAnsi256(...K.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value(r){if(r<8)return 30+r;if(r<16)return 90+(r-8);let n,o,t;if(r>=232)n=((r-232)*10+8)/255,o=n,t=n;else{r-=16;let a=r%36;n=Math.floor(r/36)/5,o=Math.floor(a/6)/5,t=a%6/5}let i=Math.max(n,o,t)*2;if(i===0)return 30;let s=30+(Math.round(t)<<2|Math.round(o)<<1|Math.round(n));return i===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(r,n,o)=>K.ansi256ToAnsi(K.rgbToAnsi256(r,n,o)),enumerable:!1},hexToAnsi:{value:r=>K.ansi256ToAnsi(K.hexToAnsi256(r)),enumerable:!1}}),K}var Qc=qc(),Pe=Qc;var Ir=A(require("node:process"),1),is=A(require("node:os"),1),yo=A(require("node:tty"),1);function be(e,r=globalThis.Deno?globalThis.Deno.args:Ir.default.argv){let n=e.startsWith("-")?"":e.length===1?"-":"--",o=r.indexOf(n+e),t=r.indexOf("--");return o!==-1&&(t===-1||o<t)}var{env:H}=Ir.default,Or;be("no-color")||be("no-colors")||be("color=false")||be("color=never")?Or=0:(be("color")||be("colors")||be("color=true")||be("color=always"))&&(Or=1);function Jc(){if("FORCE_COLOR"in H)return H.FORCE_COLOR==="true"?1:H.FORCE_COLOR==="false"?0:H.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(H.FORCE_COLOR,10),3)}function Zc(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function zc(e,{streamIsTTY:r,sniffFlags:n=!0}={}){let o=Jc();o!==void 0&&(Or=o);let t=n?Or:o;if(t===0)return 0;if(n){if(be("color=16m")||be("color=full")||be("color=truecolor"))return 3;if(be("color=256"))return 2}if("TF_BUILD"in H&&"AGENT_NAME"in H)return 1;if(e&&!r&&t===void 0)return 0;let i=t||0;if(H.TERM==="dumb")return i;if(Ir.default.platform==="win32"){let s=is.default.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in H)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in H)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in H)||H.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in H)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(H.TEAMCITY_VERSION)?1:0;if(H.COLORTERM==="truecolor"||H.TERM==="xterm-kitty"||H.TERM==="xterm-ghostty"||H.TERM==="wezterm")return 3;if("TERM_PROGRAM"in H){let s=Number.parseInt((H.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(H.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(H.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(H.TERM)||"COLORTERM"in H?1:i}function os(e,r={}){let n=zc(e,{streamIsTTY:e&&e.isTTY,...r});return Zc(n)}var el={stdout:os({isTTY:yo.default.isatty(1)}),stderr:os({isTTY:yo.default.isatty(2)})},ss=el;function as(e,r,n){let o=e.indexOf(r);if(o===-1)return e;let t=r.length,i=0,s="";do s+=e.slice(i,o)+r+n,i=o+t,o=e.indexOf(r,i);while(o!==-1);return s+=e.slice(i),s}function cs(e,r,n,o){let t=0,i="";do{let s=e[o-1]==="\r";i+=e.slice(t,s?o-1:o)+r+(s?`\r
41
41
  `:`
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(`
42
+ `)+n,t=o+1,o=e.indexOf(`
43
+ `,t)}while(o!==-1);return i+=e.slice(t),i}var{stdout:ls,stderr:us}=ss,wo=Symbol("GENERATOR"),sn=Symbol("STYLER"),Yn=Symbol("IS_EMPTY"),fs=["ansi","ansi","ansi256","ansi16m"],an=Object.create(null),tl=(e,r={})=>{if(r.level&&!(Number.isInteger(r.level)&&r.level>=0&&r.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let n=ls?ls.level:0;e.level=r.level===void 0?n:r.level};var nl=e=>{let r=(...n)=>n.join(" ");return tl(r,e),Object.setPrototypeOf(r,Xn.prototype),r};function Xn(e){return nl(e)}Object.setPrototypeOf(Xn.prototype,Function.prototype);for(let[e,r]of Object.entries(Pe))an[e]={get(){let n=Lr(this,bo(r.open,r.close,this[sn]),this[Yn]);return Object.defineProperty(this,e,{value:n}),n}};an.visible={get(){let e=Lr(this,this[sn],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var vo=(e,r,n,...o)=>e==="rgb"?r==="ansi16m"?Pe[n].ansi16m(...o):r==="ansi256"?Pe[n].ansi256(Pe.rgbToAnsi256(...o)):Pe[n].ansi(Pe.rgbToAnsi(...o)):e==="hex"?vo("rgb",r,n,...Pe.hexToRgb(...o)):Pe[n][e](...o),rl=["rgb","hex","ansi256"];for(let e of rl){an[e]={get(){let{level:n}=this;return function(...o){let t=bo(vo(e,fs[n],"color",...o),Pe.color.close,this[sn]);return Lr(this,t,this[Yn])}}};let r="bg"+e[0].toUpperCase()+e.slice(1);an[r]={get(){let{level:n}=this;return function(...o){let t=bo(vo(e,fs[n],"bgColor",...o),Pe.bgColor.close,this[sn]);return Lr(this,t,this[Yn])}}}}var ol=Object.defineProperties(()=>{},{...an,level:{enumerable:!0,get(){return this[wo].level},set(e){this[wo].level=e}}}),bo=(e,r,n)=>{let o,t;return n===void 0?(o=e,t=r):(o=n.openAll+e,t=r+n.closeAll),{open:e,close:r,openAll:o,closeAll:t,parent:n}},Lr=(e,r,n)=>{let o=(...t)=>il(o,t.length===1?""+t[0]:t.join(" "));return Object.setPrototypeOf(o,ol),o[wo]=e,o[sn]=r,o[Yn]=n,o},il=(e,r)=>{if(e.level<=0||!r)return e[Yn]?"":r;let n=e[sn];if(n===void 0)return r;let{openAll:o,closeAll:t}=n;if(r.includes("\x1B"))for(;n!==void 0;)r=as(r,n.close,n.open),n=n.parent;let i=r.indexOf(`
44
+ `);return i!==-1&&(r=cs(r,t,o,i)),o+r+t};Object.defineProperties(Xn.prototype,an);var sl=Xn(),Wf=Xn({level:us?us.level:0});var m=sl;var Yf=process.env.NODE_ENV==="development";var I=process.env.NREMOTE_WORKER_URL||"https://9remote.cc",ps=3e4,ds=500,Eo=300,$e={cmdMs:1e3,pendingApprovalMs:3e3,statsMs:5e3,serverReadyIntervalMs:200,serverReadyTimeoutMs:5e3,bgServerReadyTimeoutMs:15e3,bgServerReadyIntervalMs:300},ft={intervalMs:2e3,timeoutMs:12e4,fetchTimeoutMs:5e3,dnsTimeoutMs:2e3,maxLogEntries:80,postReadyHoldMs:2e3},ie={killCloudflaredMs:500,killCloudflaredTuiMs:300,serverBootMs:2e3,guestRecheckMs:3e3,trayReadyMs:1e3,postReadyHoldMs:2e3,bgSpawnFlushMs:400};var Ve={maxLogLines:200,headerWidth:44},Ye={checkIntervalMs:36e5,connectCheckDebounceMs:9e5,maxRetry:3,retryDelayMs:3e3,verifyTimeoutMs:15e3,lockTtlMs:3e5,lockFile:"update.lock",gateTimeoutMs:6e4},ms=5e3,So=12e4;var _r=1500,hs=2,gs=3e4,me={orange:m.rgb(230,138,110),orangeDim:m.rgb(200,120,95)};function ys(){return process.env.CODESPACES==="true"}var al=To.default.dirname((0,vs.fileURLToPath)(__importMetaUrl));async function pt(){let e=await qt();if(ys()&&process.env.NREMOTE_API_KEY)return We(e,process.env.NREMOTE_API_KEY,"Codespace");let r=Fn();if(r.key)bi(r.key)&&(r=await cl(e,r));else{let n=kt(e);r=We(e,n,"Default")}return r}async function cl(e,r){if(await X())return r;let n=kt(e);if(V().remoteEnabled===!1)return We(e,n,r.name||"Default");await Pt(n,I,null,r.key);let o=Fn();return oo(o.key)?o:We(e,n,r.name||"Default")}function De(){return"3.0.34"}var Z=require("fs"),Os=require("url"),ln=require("child_process"),Ee=A(require("path"),1),dt=A(require("os"),1);var cn=A(require("fs"),1),xo=A(require("path"),1),bs=A(require("os"),1),Es=require("child_process"),Mr=xo.default.join(bs.default.homedir(),".9remote","pids");function ll(){try{cn.default.existsSync(Mr)||cn.default.mkdirSync(Mr,{recursive:!0})}catch{}}function Ao(e){return xo.default.join(Mr,`${e}.pid`)}function Be(e,r){if(r)try{ll(),cn.default.writeFileSync(Ao(e),String(r))}catch{}}function qn(e){try{let r=cn.default.readFileSync(Ao(e),"utf8").trim(),n=parseInt(r,10);return Number.isFinite(n)&&n>0?n:null}catch{return null}}function Xe(e){try{cn.default.unlinkSync(Ao(e))}catch{}}function ko(e){if(!e)return!1;try{return process.kill(e,0),!0}catch{return!1}}function ul(e){let r=qn(e);if(Xe(e),!r)return!1;try{process.platform==="win32"?(0,Es.execSync)(`taskkill /F /T /PID ${r}`,{stdio:"ignore",windowsHide:!0}):process.kill(r,"SIGKILL")}catch{}return!0}var fl=["cloudflared","agent"];function Ss(){for(let e of fl)ul(e)}function Ts(){return Mr}var Lt=require("child_process"),N=require("fs"),Ot=require("path"),Po=A(require("os"),1),It=A(require("path"),1),As=require("url");var Nr=(0,Ot.join)(Q.LOGS,"autostart.log"),Cr="cc.9remote.agent",Dr="9Remote",Br=["--tray","--skip-update","--start"],Qn=Po.default.homedir(),xs=It.default.dirname((0,As.fileURLToPath)(__importMetaUrl)),se={darwin:(0,Ot.join)(Qn,"Library","LaunchAgents",`${Cr}.plist`),linux:(0,Ot.join)(Qn,".config","autostart",`${Cr}.desktop`),linuxSystemd:(0,Ot.join)(Qn,".config","systemd","user",`${Cr}.service`),win:(0,Ot.join)(process.env.APPDATA||"","Microsoft","Windows","Start Menu","Programs","Startup",`${Dr}.vbs`)};function qe(){for(let e=xs,r=null;e!==r;r=e,e=It.default.dirname(e)){let n=It.default.join(e,"package.json");if((0,N.existsSync)(n)){try{let o=JSON.parse((0,N.readFileSync)(n,"utf8"));if(o.name!==ee)continue;let t=typeof o.bin=="string"?o.bin:o.bin?.[ee];if(t){let i=It.default.resolve(e,t);if((0,N.existsSync)(i))return i}}catch{}break}}return process.argv[1]||It.default.resolve(xs,"..","index.js")}function Oe(){return process.execPath}function $o(){return process.versions.electron?"env ELECTRON_RUN_AS_NODE=1 ":""}function ks(e){let r=Oe(),n=qe();if(process.platform==="win32"){let t=e.join(" "),i=(0,Ot.join)(Po.default.tmpdir(),`${ee}-launch.vbs`);return(0,N.writeFileSync)(i,`CreateObject("WScript.Shell").Run """${r}"" ""${n}"" ${t}", 0, False
45
+ `),(0,Lt.execFile)("wscript.exe",[i],{windowsHide:!0}).unref?.(),null}let o=(0,Lt.spawn)(r,[n,...e],{detached:!0,stdio:"ignore"});return o.unref(),o.pid||null}function Rs(){let e=It.default.dirname(Oe()),r=["/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin","/opt/homebrew/bin"];return r.includes(e)||r.unshift(e),r.join(":")}function Ro(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function pl(e,r){let n=[e,r,...Br].map(o=>` <string>${Ro(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>${$r}</string>
51
+ <string>${Cr}</string>
52
52
  <key>ProgramArguments</key>
53
53
  <array>
54
- ${r}
54
+ ${n}
55
55
  </array>
56
56
  <key>RunAtLoad</key>
57
57
  <true/>
@@ -60,45 +60,45 @@ ${r}
60
60
  <key>EnvironmentVariables</key>
61
61
  <dict>
62
62
  <key>PATH</key>
63
- <string>${xo(As())}</string>
63
+ <string>${Ro(Rs())}</string>
64
64
  <key>HOME</key>
65
- <string>${xo(Xn)}</string>
65
+ <string>${Ro(Qn)}</string>
66
66
  </dict>
67
67
  <key>StandardOutPath</key>
68
- <string>${Mr}</string>
68
+ <string>${Nr}</string>
69
69
  <key>StandardErrorPath</key>
70
- <string>${Mr}</string>
70
+ <string>${Nr}</string>
71
71
  </dict>
72
72
  </plist>
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]
73
+ `}function dl(){return(0,N.existsSync)(se.darwin)}function ml(){let e=Br.join(" ");return`Set WshShell = CreateObject("WScript.Shell")
74
+ WshShell.Run """${Oe()}"" ""${qe()}"" ${e}", 0, False
75
+ `}function hl(){try{(0,Lt.execFileSync)("reg",["DELETE","HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run","/V",Dr,"/F"],{windowsHide:!0,stdio:"ignore"})}catch{}}function gl(){return(0,N.existsSync)(se.win)}function yl(){let e=`${Oe()} ${qe()} ${Br.join(" ")}`;return`[Desktop Entry]
76
76
  Type=Application
77
- Name=${Cr}
77
+ Name=${Dr}
78
78
  Exec=${e}
79
79
  X-GNOME-Autostart-enabled=true
80
80
  NoDisplay=false
81
81
  Terminal=false
82
- `}function al(){let e=Nr.map(n=>`'${n}'`).join(" ");return`[Unit]
83
- Description=${Cr} Host
82
+ `}function wl(){let e=Br.map(r=>`'${r}'`).join(" ");return`[Unit]
83
+ Description=${Dr} Host
84
84
  After=network-online.target
85
85
  Wants=network-online.target
86
86
 
87
87
  [Service]
88
88
  Type=simple
89
- ExecStart=${Ne()} ${ut()} ${e}
89
+ ExecStart=${Oe()} ${qe()} ${e}
90
90
  Restart=always
91
91
  RestartSec=10
92
- Environment=PATH=${As()}
93
- Environment=HOME=${Xn}
94
- StandardOutput=append:${Mr}
95
- StandardError=append:${Mr}
92
+ Environment=PATH=${Rs()}
93
+ Environment=HOME=${Qn}
94
+ StandardOutput=append:${Nr}
95
+ StandardError=append:${Nr}
96
96
 
97
97
  [Install]
98
98
  WantedBy=default.target
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");
99
+ `}function vl(e){try{return(0,Lt.execFileSync)("systemctl",["--user",...e],{stdio:"ignore"}),!0}catch{return!1}}function bl(){return(0,N.existsSync)(se.linux)||(0,N.existsSync)(se.linuxSystemd)}async function El(){try{if(process.platform==="darwin")return dl();if(process.platform==="win32")return await gl();if(process.platform==="linux")return bl()}catch{}return!1}async function Ps(){try{if(process.platform==="win32"&&hl(),!await El())return!1;if(process.platform==="darwin"){let e=pl(Oe(),qe());return((0,N.existsSync)(se.darwin)?(0,N.readFileSync)(se.darwin,"utf8"):"")===e?!1:((0,N.writeFileSync)(se.darwin,e),!0)}if(process.platform==="win32"){let e=ml();return((0,N.existsSync)(se.win)?(0,N.readFileSync)(se.win,"utf8"):"")===e?!1:((0,N.writeFileSync)(se.win,e),!0)}if(process.platform==="linux"){if((0,N.existsSync)(se.linuxSystemd)){let e=wl();return(0,N.readFileSync)(se.linuxSystemd,"utf8")===e?!1:((0,N.writeFileSync)(se.linuxSystemd,e),vl(["daemon-reload"]),!0)}if((0,N.existsSync)(se.linux)){let e=yl();return(0,N.readFileSync)(se.linux,"utf8")===e?!1:((0,N.writeFileSync)(se.linux,e),!0)}}}catch{}return!1}var Mt=F("update"),Sl=Ee.default.dirname((0,Os.fileURLToPath)(__importMetaUrl)),Is=(0,Z.existsSync)("/.dockerenv"),Ls=8e3;var _t=2208,Oo=Ee.default.join(dt.default.homedir(),".9remote","cloudflared.pid");function Tl(){try{Ss()}catch{}try{if((0,Z.existsSync)(Oo)){let e=parseInt((0,Z.readFileSync)(Oo,"utf8"));if(Number.isFinite(e))try{process.kill(e)}catch{}try{(0,Z.unlinkSync)(Oo)}catch{}}}catch{}try{process.platform==="win32"?(0,ln.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${_t}') do taskkill /F /PID %a`,{stdio:"ignore",windowsHide:!0}):(0,ln.execSync)(`lsof -ti:${_t} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}if(process.platform==="win32"){let e=Date.now()+1500;for(;Date.now()<e;);}}function _s(){return"3.0.34"}function Ms(e,r){let n=e.split(".").map(Number),o=r.split(".").map(Number);for(let t=0;t<3;t++){if(o[t]>n[t])return!0;if(o[t]<n[t])return!1}return!1}function xl(){return process.env.CODESPACES==="true"||process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN?"GitHub Codespaces":Is?"Docker":null}function Ur(){Tl()}async function Cs(){try{let e=_s();if(!e)return null;let r=await W(to,{signal:AbortSignal.timeout(Ls)});if(!r.ok)return null;let{version:n}=await r.json();return n&&Ms(e,n)?{current:e,latest:n}:null}catch{return null}}var Ct=Ee.default.join(Q.STATE,Ye.lockFile);function Al(){try{if((0,Z.existsSync)(Ct)){let{pid:e,ts:r}=JSON.parse((0,Z.readFileSync)(Ct,"utf8")),n=Date.now()-r<Ye.lockTtlMs,o=!1;try{process.kill(e,0),o=!0}catch{}if(n&&o)return!1}}catch{}try{(0,Z.writeFileSync)(Ct,JSON.stringify({pid:process.pid,ts:Date.now()}))}catch{}return!0}async function kl(){try{let e=await W(to,{signal:AbortSignal.timeout(Ls)});if(!e.ok)return null;let{version:r}=await e.json();return r||null}catch{return null}}function Ns(){try{if(process.env.NREMOTE_REGISTRY)return`--registry ${new URL(process.env.NREMOTE_REGISTRY).origin}`}catch{}return""}function Ds(){let e=qe(),r=Ee.default.sep,n=`${r}lib${r}node_modules${r}`,o=e.indexOf(n);return o>0?{global:"-g",prefix:`--prefix "${e.slice(0,o)}"`}:(o=e.indexOf(`${r}node_modules${r}`),o>0?{global:"",prefix:`--prefix "${e.slice(0,o)}"`}:{global:"-g",prefix:""})}function $s(){let e=process.argv.slice(2).filter(t=>t!=="--skip-update"),n=e.includes("ui")||e.includes("start")||e.some(t=>["--tray","--auto","--start"].includes(t))?e.join(" "):"--tray";return`${n.includes("--start")||n.includes("start")?n:`${n} --start`} --skip-update`}function Bs(){let e=process.env.NREMOTE_NPM_CLI;return e&&(0,Z.existsSync)(e)?process.platform==="win32"?`"${Oe()}" "${e}"`:`env ELECTRON_RUN_AS_NODE=1 "${Oe()}" "${e}"`:"npm"}function Rl(e,r){let n=Ee.default.join(dt.default.tmpdir(),`${ee}-gate.cjs`),o=`const http = require("http");
100
100
  const PORT = ${e};
101
- const EXIT_MS = ${n};
101
+ const EXIT_MS = ${r};
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,14 +115,14 @@ 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 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
118
+ `;return(0,Z.writeFileSync)(n,o),n}function Pl({currentVersion:e,latest:r,agentPid:n}){let o=Ts(),t=Ns(),i=Oe(),s=Rl(_t,Ye.gateTimeoutMs),a=$o(),c=qe(),l=Ct,{global:u,prefix:f}=Ds(),p=`${u} --prefer-online --no-audit --no-fund ${t} ${f}`.trim(),d=Bs();if(process.platform==="win32"){let v=Ee.default.join(dt.default.tmpdir(),`${ee}-restart.vbs`),P=`@echo off
119
119
  setlocal EnableDelayedExpansion
120
120
  set "NODE=${i}"
121
121
  set "CLI=${c}"
122
122
  ${process.env.NREMOTE_NPM_CLI?'set "ELECTRON_RUN_AS_NODE=1"':""}
123
123
 
124
124
  :waitloop
125
- tasklist /FI "PID eq ${r}" 2>nul | find "${r}" >nul
125
+ tasklist /FI "PID eq ${n}" 2>nul | find "${n}" >nul
126
126
  if not errorlevel 1 (
127
127
  timeout /t 1 /nobreak >nul
128
128
  goto waitloop
@@ -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 :${Lt}') do taskkill /F /PID %%a >nul 2>&1
137
+ for /f "tokens=5" %%a in ('netstat -aon ^| findstr :${_t}') 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 ${Ke} ${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 ${kt.maxRetry} (
149
- call ${d} install ${Ke} ${p} --omit=optional >nul 2>&1
148
+ if !ATTEMPT! GEQ ${Ye.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%\\${ae}-ver.txt"
157
+ set "VERFILE=%TEMP%\\${ee}-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,22 +164,22 @@ 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!"=="${n}" (
168
- call ${d} install ${ae}@${e} ${p} >nul 2>&1
167
+ if not "!NEWVER!"=="${r}" (
168
+ call ${d} install ${ee}@${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 :${Lt}') do taskkill /F /PID %%a >nul 2>&1
173
+ for /f "tokens=5" %%a in ('netstat -aon ^| findstr :${_t}') do taskkill /F /PID %%a >nul 2>&1
174
174
  timeout /t 1 /nobreak >nul
175
175
 
176
- wscript "${E}"
176
+ wscript "${v}"
177
177
  exit /b 0
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
- `),{shellCmd:["wscript.exe",[A]],windowsVerbatim:!1}}let h=`#!/bin/bash
178
+ `,S=Ee.default.join(dt.default.tmpdir(),`${ee}-update.bat`);(0,Z.writeFileSync)(S,P),(0,Z.writeFileSync)(v,`CreateObject("WScript.Shell").Run """%NODE%"" ""%CLI%"" ${$s()}", 0, False`.replace("%NODE%",i).replace("%CLI%",c)+`
179
+ `);let x=Ee.default.join(dt.default.tmpdir(),`${ee}-update.vbs`);return(0,Z.writeFileSync)(x,`CreateObject("WScript.Shell").Run "cmd /c ""${S}""", 0, False
180
+ `),{shellCmd:["wscript.exe",[x]],windowsVerbatim:!1}}let h=`#!/bin/bash
181
181
  # Wait for agent to exit so it releases the cli.cjs file lock
182
- while kill -0 ${r} 2>/dev/null; do sleep 1; done
182
+ while kill -0 ${n} 2>/dev/null; do sleep 1; done
183
183
 
184
184
  # Kill tracked PIDs only (never ptyDaemon \u2192 sessions survive)
185
185
  for name in cloudflared agent; do
@@ -190,19 +190,19 @@ for name in cloudflared agent; do
190
190
  rm -f "$f"
191
191
  fi
192
192
  done
193
- lsof -ti:${Lt} | xargs kill -9 2>/dev/null || true
193
+ lsof -ti:${_t} | 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 ${kt.maxRetry} ]; do
200
+ while [ $attempt -lt ${Ye.maxRetry} ]; do
201
201
  attempt=$((attempt+1))
202
202
  echo "Installing (attempt $attempt)..."
203
- if ${d} install ${Ke} ${p}; then break; fi
204
- if [ $attempt -eq ${kt.maxRetry} ]; then
205
- ${d} install ${Ke} ${p} --omit=optional || true
203
+ if ${d} install ${ke} ${p}; then break; fi
204
+ if [ $attempt -eq ${Ye.maxRetry} ]; then
205
+ ${d} install ${ke} ${p} --omit=optional || true
206
206
  fi
207
207
  sleep 3
208
208
  done
@@ -210,105 +210,147 @@ 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" != "${n}" ]; then
214
- echo "Verify failed (got $NEWVER, want ${n}), rolling back to ${e}..."
215
- ${d} install ${ae}@${e} ${p} || true
213
+ if [ "$NEWVER" != "${r}" ]; then
214
+ echo "Verify failed (got $NEWVER, want ${r}), rolling back to ${e}..."
215
+ ${d} install ${ee}@${e} ${p} || true
216
216
  fi
217
217
 
218
218
  # Free the port for the new agent (kills the loading gate)
219
- lsof -ti:${Lt} | xargs kill -9 2>/dev/null || true
219
+ lsof -ti:${_t} | 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}" ${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(`
224
+ `:""}${a}"${i}" "${c}" ${$s()}
225
+ `,w=Ee.default.join(dt.default.tmpdir(),`${ee}-update.sh`);return(0,Z.writeFileSync)(w,h,{mode:493}),{shellCmd:["sh",[w]],windowsVerbatim:!1}}async function Us(e){let r=await kl();return r?Ms(e,r)?Al()?r:(Mt.warn("update skipped: lock held by another run"),null):(Mt.info(`update skipped: ${e} >= registry ${r}`),null):(Mt.warn("update skipped: registry unreachable"),null)}function $l({currentVersion:e,latest:r,agentPid:n}){let{global:o,prefix:t}=Ds(),i=`${o} --prefer-online --no-audit --no-fund ${Ns()} ${t}`.trim(),s=Bs(),a=Oe(),c=$o(),l=qe(),u=`#!/bin/bash
226
+ LOG_DIR="$(dirname "${Ct}")"; mkdir -p "$LOG_DIR"
227
+ exec >>"$LOG_DIR/update-script.log" 2>&1
228
+ echo "=== $(date -u +%FT%TZ) docker update ${e} -> ${r} ==="
229
+
230
+ attempt=0
231
+ while [ $attempt -lt ${Ye.maxRetry} ]; do
232
+ attempt=$((attempt+1))
233
+ if ${s} install ${ke} ${i}; then break; fi
234
+ if [ $attempt -eq ${Ye.maxRetry} ]; then
235
+ ${s} install ${ke} ${i} --omit=optional || true
236
+ fi
237
+ sleep 3
238
+ done
239
+
240
+ NEWVER=$(${c}"${a}" "${l}" --version 2>/dev/null | head -1 | sed 's/\x1B[[0-9;?]*[a-zA-Z]//g' | tr -d '[:space:]')
241
+ if [ "$NEWVER" != "${r}" ]; then
242
+ echo "Verify failed (got $NEWVER, want ${r}), rolling back to ${e}..."
243
+ ${s} install ${ee}@${e} ${i} || true
244
+ rm -f "${Ct}"
245
+ exit 0
246
+ fi
247
+
248
+ rm -f "${Ct}"
249
+ kill -9 ${n} 2>/dev/null
250
+ `,f=Ee.default.join(dt.default.tmpdir(),`${ee}-update-docker.sh`);return(0,Z.writeFileSync)(f,u,{mode:493}),f}async function Ol(e){let r=await Us(e);if(!r)return!1;Mt.info(`update go (docker): ${e} -> ${r}`);let n=$l({currentVersion:e,latest:r,agentPid:process.pid});return(0,ln.spawn)("sh",[n],{detached:!0,stdio:"ignore"}).unref(),!0}async function Fs(){let e=_s();if(!e)return Mt.warn("update skipped: no version (source run?)"),!1;if(Is)return Ol(e);let r=xl();if(r)return Mt.warn(`update skipped: restricted env (${r})`),!1;let n=await Us(e);if(!n)return!1;Mt.info(`update go: ${e} -> ${n}`);let{shellCmd:o,windowsVerbatim:t}=Pl({currentVersion:e,latest:n,agentPid:process.pid});return(0,ln.spawn)(o[0],o[1],{detached:!0,stdio:"ignore",windowsHide:!0,windowsVerbatimArguments:t}).unref(),setTimeout(()=>process.exit(0),500),!0}var ur=require("child_process"),fr=A(require("path"),1),Xo=A(require("fs"),1),va=require("url");var G=A(require("fs"),1),ht=A(require("path"),1),Ko=A(require("https"),1),gt=A(require("os"),1),Zs=A(require("net"),1),Ze=require("child_process");var Ks=A(require("dns"),1),Hs=require("child_process");var Il=2e3,Ll=5e3,Io=new Ks.default.promises.Resolver;Io.setServers(["1.1.1.1","1.0.0.1","8.8.8.8"]);function un(){process.platform==="win32"&&(0,Hs.execFile)("ipconfig",["/flushdns"],{windowsHide:!0},()=>{})}async function Lo(e,r=Il){let n=Date.now();try{let o=async()=>{let[i,s]=await Promise.allSettled([Io.resolve4(e),Io.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"})),r))]),elapsedMs:Date.now()-n}}catch(o){return{ok:!1,code:o.code||o.message,elapsedMs:Date.now()-n}}}async function fn(e,{flushDns:r=!1}={}){let n=Date.now(),o=null;try{o=new URL(e).hostname}catch{}if(r&&un(),o){let t=await Lo(o);if(!t.ok)return un(),{ok:!1,dnsCode:t.code,elapsedMs:Date.now()-n}}try{let t=await W(`${e}/api/health`,{signal:AbortSignal.timeout(Ll)});return{ok:t.ok,httpStatus:t.status,elapsedMs:Date.now()-n}}catch(t){return{ok:!1,dnsCode:t.cause?.code||t.code||t.message,elapsedMs:Date.now()-n}}}var _l=F("tunnel"),Jn=null,Zn=null,pn=null,Nt=null,mt=0,Mo=!1;async function Co(e){try{let r=await on();await fetch(`http://${r}:${$}/api/ui/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch{}}var _o=!1;async function js(){if(!(!Zn||Mo||_o)){_o=!0;try{await Ml()}finally{_o=!1}}}async function Ml(){let e=await fn(Zn),r=e.ok?"healthy":"unreachable";if(r===pn){Nt=null,mt=0;return}if(r!==Nt){Nt=r,mt=1;return}mt++,!(mt<hs)&&(_l.info(`${pn??"init"} \u2192 ${r}${e.ok?"":` (http=${e.httpStatus??"-"} dns=${e.dnsCode??"-"})`}`),pn=r,Nt=null,mt=0,await Co({tunnelHealth:{status:r,checkedAt:Date.now()}}))}function Ws(e){if(!e)return zn();e!==Zn&&(Zn=e,pn=null,Nt=null,mt=0,un(),Jn||(Jn=setInterval(js,pi.checkIntervalMs)),js())}var Gs=Ws,dn=Ws;function Vs(){Mo=!0}function Ys(){Mo=!1}function Dt(e){pn=e,Nt=null,mt=0,Co({tunnelHealth:{status:e,checkedAt:Date.now()}})}function zn(){Jn&&(clearInterval(Jn),Jn=null),Zn=null,pn=null,Nt=null,mt=0,Co({tunnelHealth:{status:"unknown",checkedAt:null}})}var ne=F("tunnel"),Qe={networkCheckIntervalMs:5e3,networkRestoreDelayMs:2500,internetCheckTimeoutMs:3e3,internetCheckHost:"1.1.1.1",internetCheckPort:443,edgeProbeIntervalMs:15e3,edgeProbeFailureThreshold:3,readyTimeoutMs:1500},Cl=[20241,20242,20243,20244,20245],gn=null;async function Nl(e,r){try{let o=await(await fetch(`http://localhost:${e}/ready`,{signal:AbortSignal.timeout(r)})).json();return typeof o?.readyConnections=="number"?o:null}catch{return null}}async function Xs(e,r){let n=await Nl(e,r);if(!n)return null;let o=await Bl(e,r);return o&&Se&&!Se.includes(o)?null:n.readyConnections}async function Dl(e){if(gn!==null){let o=await Xs(gn,e);if(o!==null)return o;gn=null}let n=(await Promise.all(Cl.map(async o=>({port:o,conns:await Xs(o,e)})))).find(o=>o.conns!==null);return n?(gn=n.port,n.conns):null}async function Bl(e,r){try{return(await(await fetch(`http://localhost:${e}/quicktunnel`,{signal:AbortSignal.timeout(r)})).json())?.hostname||null}catch{return null}}var Ul=3e4,No=0,nr=null,Fr=null,yn=null,ir=null,wn=!1,er=0,Fo=!1,Se=null,vn=0,Do=0,Bo=!1,sr=0,Je=0,qs=3e4,Fl=5e3,tr=ht.default.join(gt.default.homedir(),".9remote","bin"),Qs="cloudflared",bn=gt.default.platform()==="win32",Kl=bn?`${Qs}.exe`:Qs,mn=ht.default.join(tr,Kl),Uo=ht.default.join(gt.default.homedir(),".9remote","cloudflared.pid"),rr=!1,hn=null,Hl="2026.6.1",zs=`https://github.com/cloudflare/cloudflared/releases/download/${Hl}`;function ea(){return new Promise(e=>{let r=new Zs.default.Socket,n=!1,o=t=>{if(!n){n=!0;try{r.destroy()}catch{}e(t)}};r.setTimeout(Qe.internetCheckTimeoutMs),r.once("connect",()=>o(!0)),r.once("timeout",()=>o(!1)),r.once("error",()=>o(!1));try{r.connect(Qe.internetCheckPort,Qe.internetCheckHost)}catch{o(!1)}})}async function jl(){Fo=!0;try{let e=0;for(;;){if(e++,await ea())return;await new Promise(r=>setTimeout(r,Re(ge.internet,e)))}}finally{Fo=!1}}async function or(e,r){if(!ir){ne.warn("No restartCallback registered \u2014 skip");return}if(!wn&&!(Date.now()-Do<Fl)){Do=Date.now(),wn=!0;try{await jl();let n=Re(ge.tunnelRestart,er+1);await new Promise(o=>setTimeout(o,n)),await ir(e),er=0,Do=0}catch(n){er++,ne.error(`restart failed (#${er}): ${n?.message||n}`),setImmediate(()=>{wn=!1,or(e,"retry after fail")});return}finally{wn=!1}}}var Wl={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 Gl(){let e=gt.default.platform(),r=gt.default.arch(),n=Wl[e];if(!n)throw new Error(`Unsupported platform: ${e}`);let o=n[r];if(!o)throw new Error(`Unsupported architecture: ${r} for platform ${e}`);return`${zs}/${o}`}var Vl=150;async function ta(e,r,n){return new Promise((o,t)=>{let i=G.default.createWriteStream(r);Ko.default.get(e,s=>{if([301,302].includes(s.statusCode)){i.close(),G.default.unlinkSync(r),ta(s.headers.location,r,n).then(o).catch(t);return}if(s.statusCode!==200){i.close(),G.default.unlinkSync(r),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,!n||!a)return;let p=Date.now(),d=Math.min(100,Math.floor(c/a*100));d!==u&&p-l>=Vl&&(l=p,u=d,n(d))}),s.pipe(i),i.on("finish",()=>{n&&a&&n(100),i.close(()=>o(r))}),i.on("error",f=>{i.close(),G.default.unlinkSync(r),t(f)})}).on("error",s=>{i.close(),G.default.existsSync(r)&&G.default.unlinkSync(r),t(s)})})}async function ar(e){if(G.default.existsSync(tr)||G.default.mkdirSync(tr,{recursive:!0}),G.default.existsSync(mn))return bn||G.default.chmodSync(mn,"755"),mn;let r=Gl(),n=r.endsWith(".tgz"),o=n?ht.default.join(tr,"cloudflared.tgz"):mn;try{return e?.({phase:"download",percent:0}),await ta(r,o,t=>{e?.({phase:"download",percent:t})}),await Yl(r,o),n&&(e?.({phase:"extract"}),(0,Ze.execSync)(`tar -xzf "${o}" -C "${tr}"`,{stdio:"pipe",windowsHide:!0}),G.default.unlinkSync(o)),bn||G.default.chmodSync(mn,"755"),mn}catch(t){try{G.default.existsSync(o)&&G.default.unlinkSync(o)}catch{}throw console.error("Failed to download cloudflared:",t.message),t}}function na(e){return new Promise((r,n)=>{Ko.default.get(e,o=>{if([301,302].includes(o.statusCode))return na(o.headers.location).then(r).catch(n);if(o.statusCode!==200)return n(new Error(`HTTP ${o.statusCode}`));let t="";o.on("data",i=>t+=i),o.on("end",()=>r(t))}).on("error",n)})}async function Yl(e,r){let n=ht.default.basename(e),o;try{o=await na(`${zs}/sha256sum.txt`)}catch(c){ne.warn(`sha256 manifest unavailable (${c.message}), skipping verify`);return}let t=o.split(`
251
+ `).find(c=>c.includes(n));if(!t){ne.warn(`No sha256 entry for ${n}, skipping verify`);return}let i=t.trim().split(/\s+/)[0],{createHash:s}=await import("crypto"),a=s("sha256").update(G.default.readFileSync(r)).digest("hex");if(a!==i)throw new Error(`Integrity check failed: SHA256 mismatch (expected ${i}, got ${a})`)}function Xl(e){let r=/https:\/\/([a-z0-9-]+)\.trycloudflare\.com/gi,n=[];for(let o of e.matchAll(r))o[1]!=="api"&&n.push(`https://${o[1]}.trycloudflare.com`);return n.length?n[n.length-1]:null}async function ze(e,r=null,n=null){let o=await ar();Zl(o),n&&(ir=n),yn=e;let t=G.default.mkdtempSync(ht.default.join(gt.default.tmpdir(),"9remote-quick-")),i=ht.default.join(t,"config.yml");G.default.writeFileSync(i,`# quick-tunnel
252
+ `,"utf8");let s=!1,a=()=>{if(!s){s=!0;try{G.default.rmSync(t,{recursive:!0,force:!0})}catch{}}},c=(0,Ze.spawn)(o,["tunnel","--url",`http://localhost:${e}`,"--config",i,"--no-autoupdate","--protocol","http2"],{detached:!1,windowsHide:!0,stdio:["ignore","pipe","pipe"]});return Be("cloudflared",c.pid),hn=c.pid,rr=!1,new Promise((l,u)=>{let f=!1,p=null,d="",h=setTimeout(()=>{if(!f){f=!0,a(),hn===c.pid&&(hn=null);try{c.kill("SIGKILL")}catch{}Xe("cloudflared"),u(new Error("Quick tunnel timed out after 90s"))}},9e4),w=v=>{let P=v.toString();d+=P,d.length>4096&&(d=d.slice(-4096));let S=Xl(P);if(S){if(!f){f=!0,p=S,Se=S,vn=Date.now(),Je=0,sr=0,gn=null,clearTimeout(h),a(),tu(),ne.info(`tunnel ready: ${S}`),l({child:c,tunnelUrl:S});return}S!==p&&(ne.info(`URL rotated: ${S}`),p=S,Se=S,vn=Date.now(),Je=0,sr=0,r?.(S))}};c.stdout.on("data",w),c.stderr.on("data",w),c.on("error",v=>{f||(f=!0,clearTimeout(h),a(),u(v))}),c.on("exit",(v,P)=>{a();let S=hn!==c.pid,x=rr||S;if(ne.info(`cloudflared exited (intentional=${rr} superseded=${S})`),x||Dt("unreachable"),!f){f=!0,clearTimeout(h);let R=d.trim().split(`
253
+ `).slice(-5).join(" | ");hn=null,u(new Error(`cloudflared exited (code=${v}, signal=${P}) output: ${R||"(empty)"}`));return}x||or(e,`quick tunnel exit code ${v}`)})})}function Kr(e){if(bn)try{(0,Ze.execSync)(`taskkill /PID ${e} /T /F`,{windowsHide:!0,stdio:"ignore"})}catch{}else try{process.kill(e,"SIGKILL")}catch{}}function ql(e){return e?e.split(`
254
+ `).flatMap(r=>{let n=r.match(/^\s*(\d+)\s+(.+)$/);return n?[{pid:Number(n[1]),args:n[2].trim()}]:[]}):[]}function Ql(e,r){return Array.isArray(e)?e.filter(n=>{if(!n?.args||typeof n.pid!="number")return!1;let o=n.args.split(/\s+/);return o.includes(r)&&o.includes("tunnel")}).map(n=>n.pid):[]}function Jl(e){try{let r=bn?(0,Ze.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,Ze.execSync)("ps -eo pid=,args=",{encoding:"utf8",stdio:["ignore","pipe","ignore"]});return Ql(ql(r),e)}catch{return[]}}function Zl(e){let r=Jl(e);for(let n of r)n!==process.pid&&(ne.info(`killing leftover cloudflared pid=${n}`),Kr(n));return r}function zl(e){try{let r=[];if(bn){let n=`Get-NetTCPConnection -LocalPort ${e} -State Established -ErrorAction SilentlyContinue | Where-Object { (Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).Name -eq 'cloudflared' } | Select-Object -ExpandProperty OwningProcess -Unique`;r=(0,Ze.execSync)(`powershell -NoProfile -Command "${n}"`,{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}).split(/\r?\n/).map(t=>+t.trim()).filter(Boolean)}else r=(0,Ze.execSync)(`lsof -nP -iTCP:${e} -sTCP:ESTABLISHED 2>/dev/null | awk '/cloudflar/ {print $2}' | sort -u`,{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).split(`
255
+ `).map(o=>+o.trim()).filter(Boolean);for(let n of new Set(r))Kr(n)}catch{}}function le(){if(!Bo){Bo=!0;try{try{if(G.default.existsSync(Uo)){let r=parseInt(G.default.readFileSync(Uo,"utf8"));Number.isFinite(r)&&(rr=!0,Kr(r)),G.default.unlinkSync(Uo)}}catch{}let e=qn("cloudflared");rr=!0,hn=null,e&&(Kr(e),Xe("cloudflared")),zl($)}finally{setTimeout(()=>{Bo=!1},2e3)}}}function ra(){if(!Se)return!1;let e=qn("cloudflared");return!!e&&ko(e)}function oa(){er=0,wn=!1,ir=null,yn=null,Se=null,Je=0,sr=0,gn=null,nu()}var eu=/^(utun|awdl|llw|anpi|bridge|gif|stf|ipsec|ap|tun|tap|vmnet|veth|docker)/i;function Js(){let e=gt.default.networkInterfaces(),r=[];for(let[n,o]of Object.entries(e))if(o&&!eu.test(n))for(let t of o)!t.internal&&t.family==="IPv4"&&r.push(`${n}:${t.address}`);return r.sort().join("|")}function tu(){nr||(Fr=Js(),No=Date.now(),nr=setInterval(async()=>{try{let e=Date.now(),r=e-No;if(No=e,Fo||wn||!ir||yn==null)return;if(r>Ul){if(ne.info(`Sleep/wake detected (gap=${r}ms)`),Se){let s=!1;for(let a=0;a<3;a++){if((await fn(Se)).ok){s=!0;break}a<2&&await new Promise(l=>setTimeout(l,3e3))}if(s)return;ne.info("tunnel unresponsive after sleep \u2192 restarting")}Dt("unreachable"),le(),or(yn,"woke from sleep");return}let n=Js(),o=n!==Fr;Fr=n;let t=qn("cloudflared"),i=!t||!ko(t);if(!o&&!i){if(Se&&vn&&Date.now()-vn>qs&&e-sr>=Qe.edgeProbeIntervalMs){sr=e;let s=await fn(Se);if(s.ok)Je=0;else if(++Je>=Qe.edgeProbeFailureThreshold){let a=await Dl(Qe.readyTimeoutMs);if(a>0){ne.info(`edge probe failing but cloudflared holds ${a} connection(s) \u2014 not restarting`),Je=0;return}ne.warn(`tunnel unreachable but cloudflared alive \u2014 edge lost after ${Je} probes (ready=${a??"unknown"}), restarting`),Je=0,Dt("unreachable"),le(),or(yn,"tunnel unreachable (edge lost)")}else ne.debug(`edge probe failed (${Je}/${Qe.edgeProbeFailureThreshold}) \u2014 ${s.dnsCode??s.httpStatus??"no response"}`)}return}if(o&&!i&&vn&&Date.now()-vn<qs||(o&&ne.info("Network change detected"),i&&ne.warn("cloudflared not alive \u2014 watchdog"),Dt("unreachable"),await new Promise(s=>setTimeout(s,Qe.networkRestoreDelayMs)),!await ea()))return;if(o&&!i&&Se){let s=!1;for(let a=0;a<2;a++){if((await fn(Se)).ok){s=!0;break}a===0&&await new Promise(l=>setTimeout(l,2e3))}if(s){ne.info("Tunnel survived network change, skip restart");return}}o&&!i&&le(),or(yn,o?"network change":"liveness watchdog")}catch(e){ne.error(`network monitor tick failed: ${e?.message||e}`)}},Qe.networkCheckIntervalMs))}function nu(){nr&&(clearInterval(nr),nr=null),Fr=null}Ft();async function yt(e,r={}){let n=r.intervalMs??ft.intervalMs,o=r.timeoutMs??ft.timeoutMs,t=`${e}/api/health`,i=(()=>{try{return new URL(e).hostname}catch{return null}})(),s=Date.now(),a=0,c=[];await j({healthCheck:{running:!0,timeoutMs:o,startedAt:s,logs:[]}});let l=u=>{c.push(u);let f=c.length>ft.maxLogEntries?c.slice(-ft.maxLogEntries):c;j({healthCheck:{running:!0,timeoutMs:o,startedAt:s,logs:f}})};for(;Date.now()-s<o;){if(a++,un(),i){let f=await Lo(i,ft.dnsTimeoutMs);if(!f.ok){let p=f.code==="ENOTFOUND"||f.code==="ETIMEOUT"||f.code==="ESERVFAIL",d=p?"connecting...":f.code;rn(`#${a} \u2192 ${d}`),l({attempt:a,status:d,elapsedMs:f.elapsedMs,ok:!1,waiting:p,time:Date.now()}),await new Promise(h=>setTimeout(h,n));continue}}let u=Date.now();try{let f=await W(t,{signal:AbortSignal.timeout(ft.fetchTimeoutMs)}),p=Date.now()-u;if(rn(`#${a} \u2192 ${f.status}`),l({attempt:a,status:String(f.status),elapsedMs:p,ok:f.ok,time:Date.now()}),f.ok)return await j({healthCheck:{running:!1,timeoutMs:0,startedAt:null,logs:[]}}),await new Promise(d=>setTimeout(d,ft.postReadyHoldMs)),!0}catch(f){let p=Date.now()-u,d=f.cause?.code||f.code||f.message,h=d==="ENOTFOUND",w=h?"connecting...":d;rn(`#${a} \u2192 ${w}`),l({attempt:a,status:w,elapsedMs:p,ok:!1,waiting:h,time:Date.now()})}await new Promise(f=>setTimeout(f,n))}return await j({healthCheck:{running:!1,timeoutMs:o,startedAt:s,logs:c}}),!1}var tt=F("tunnel"),jo=null,ha=null,ga=0;async function Kt(e,r){if(tt.debug(`updateTunnelUrl: key=${e?.slice(0,8)} url=${r}`),V().remoteEnabled===!1)return;if(Ht(e),r&&r===ha&&Date.now()-ga<ms){tt.debug("updateTunnelUrl: skipped (debounce, same URL)");return}jo&&(jo.cancelled=!0);let n={cancelled:!1};jo=n;let o=es();Ar({config:ge.urlSync,label:`urlSync ${r}`,log:t=>tt.warn(t),ctx:n,task:async()=>{let t=await W(`${I}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((()=>{let s={apiKey:J(e),tunnelUrl:r,localIp:o?`${o}:${$}`:null};return{...s,...Rt(s)}})())});if(n.cancelled)return!0;if(t.ok)return ha=r,ga=Date.now(),tt.debug(`urlSync OK: pushed ${r} to server`),cu(r),!0;let i=await t.text().catch(()=>"");return tt.warn(`urlSync HTTP ${t.status}: ${i.slice(0,200)}`),!1}}),r&&Gs(r)}var xn=null,An=null,Wo=!1,Vo=0;async function Yo(e,r){let n={apiKey:e,online:r},o=await W(`${I}/api/session/heartbeat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,...Rt(n)})});return o.ok||tt.warn(`heartbeat online=${r} HTTP ${o.status}`),o.ok}async function Go(){if(!(Wo||!An)){Wo=!0;try{await Yo(An,!0),Vo=Date.now()}catch(e){tt.debug(`heartbeat failed: ${e?.message||e}`)}finally{Wo=!1}}}function Ht(e){let r=J(e);if(r&&V().remoteEnabled!==!1){if(xn&&An===r){Date.now()-Vo>=So&&Go();return}jr(),An=r,Go(),xn=setInterval(Go,So),xn.unref?.()}}function jr({offline:e=!1}={}){xn&&(clearInterval(xn),xn=null);let r=An;return An=null,Vo=0,!e||!r?null:Yo(r,!1).catch(n=>tt.debug(`goodbye failed: ${n?.message||n}`))}function wt(e){let r=J(e);if(!r)return Promise.resolve(!1);jr();let n=Yo(r,!1).catch(o=>(tt.debug(`offline mark failed: ${o?.message||o}`),!1));return Promise.race([n,new Promise(o=>setTimeout(()=>o(!1),_r))])}var lr=null;async function cu(e){if(lr?.url===e)return;let r={url:e};lr=r,Vs();try{let n=await yt(e,{timeoutMs:gs});if(lr!==r)return;n&&Dt("healthy")}catch{}finally{lr===r&&(lr=null),Ys()}}var nt=F("server"),ba=fr.default.dirname((0,va.fileURLToPath)(__importMetaUrl)),lu=fr.default.resolve(ba,"./server.cjs"),ya=fr.default.resolve(ba,"../../index.js");function Wr(e){try{process.platform==="win32"?(0,ur.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${e}') do taskkill /F /PID %a`,{stdio:"ignore",windowsHide:!0}):(0,ur.execSync)(`lsof -ti:${e} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}}function vt(e,r,n){let o=null,t=!1,i=!1,s=!0,a=0,c=null,l=()=>{s&&(Wr($),s=!1);let u=process.env.NODE_ENV==="development"&&Xo.default.existsSync(ya),f=u?ya:lu;Xo.default.existsSync(f)||(nt.error(`Server not found: ${f}`),process.exit(1));let p={...process.env,PORT:String($)};u||delete p.NODE_ENV,o=(0,ur.spawn)(ai,[f],{cwd:fr.default.dirname(f),stdio:["ignore","inherit","inherit"],detached:!1,windowsHide:!0,env:ci(p)}),c&&clearTimeout(c),c=setTimeout(()=>{a=0},ps),o.on("exit",(d,h)=>{if(c&&(clearTimeout(c),c=null),t)return;if(i){i=!1,nt.info("Restarting server (requested)..."),setTimeout(()=>{l(),n?.()},500);return}nt.error(`Server exited unexpectedly (code: ${d}, signal: ${h})`),a++;let w=Re(ge.server,a);nt.warn(`Restarting server in ${w}ms (fail#${a})`),r&&r(),setTimeout(()=>{l(),n?.()},w)}),o.on("error",d=>{nt.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 Ea(e){return e?.restart?e.restart():!1}function rt({serverManager:e,tunnelProcess:r,exit:n=!0,code:o=0}={}){try{zn()}catch{}try{e?.shutdown?.()}catch{}try{r?.kill?.()}catch{}try{le()}catch{}try{Bt()}catch{}try{Wr($)}catch{}try{oa()}catch{}try{Ai()}catch{}try{Xe("agent")}catch{}try{Xe("cloudflared")}catch{}let t=jr({offline:!0});if(n){let i=new Promise(a=>setTimeout(a,ds)),s=t?Promise.race([t,new Promise(a=>setTimeout(a,_r))]):null;Promise.all([i,s]).finally(()=>process.exit(o))}}var wa=!1;function bt(e,r){if(wa)return;wa=!0;let n=!1,o=t=>{n||(n=!0,nt.info(`Stopping 9Remote (${t})...`),rt({serverManager:e,tunnelProcess:r}),nt.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=>{nt.error(`Uncaught exception: ${t?.stack||t?.message||t}`),o("uncaughtException"),setTimeout(()=>process.exit(1),Eo)}),process.on("unhandledRejection",t=>{nt.error(`Unhandled rejection: ${t?.stack||t?.message||t}`),o("unhandledRejection"),setTimeout(()=>process.exit(1),Eo)})}Ft();var jt=F("tunnel");async function uu(e,r,n,o){let t=0;for(;;){t++;try{return await ze(e,r,n)}catch(i){let s=Re(ge.tunnelSpawn,t);jt.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 ot({onUrlUpdate:e,setTunnel:r,onRetry:n}){return async o=>{try{let t=await uu(o,e,null,n);it(),r(t.child),await e(t.tunnelUrl),jt.info(`Tunnel restarted: ${t.tunnelUrl}`)}catch(t){jt.error(`Tunnel restart failed: ${t?.message||t}`)}}}var Gr=null;function it(){Gr&&(Gr.cancelled=!0,Gr=null)}function kn(e,{onUrlUpdate:r,onRestart:n,setActiveTunnel:o,onReady:t}){it();let i={cancelled:!1};return Gr=i,Ar({config:ge.tunnelRateLimit,task:async()=>{if(i.cancelled)return!0;if(ra())return jt.info("bg-tunnel: a tunnel is already live \u2014 standing down"),!0;let s=await ze(e,r,n);if(i.cancelled){try{le()}catch{}return!0}try{o?.(s.child),await r?.(s.tunnelUrl),await t?.(s),jt.info(`bg tunnel up: ${s.tunnelUrl}`)}catch(a){jt.error(`bg tunnel post-spawn failed: ${a?.message||a}`)}return!0},label:"bg-tunnel",log:s=>jt.info(s),ctx:i}),i}var ei=A(Ga(),1);var vu=F("session");function bu(e,r="\u{1F4F1} Scan QR to connect:"){console.log(me.orange(`
256
+ ${r}`)),ei.default.generate(e,{small:!0,type:"terminal",margin:0},n=>{console.log(n.trim())})}function Eu(e){return new Promise(r=>{ei.default.generate(e,{small:!0,type:"terminal",margin:0},n=>{r(me.orangeDim("\u{1F4F1} Scan QR to connect:")+`
257
+ `+n.trim())})})}async function qr(e,r){let n=await jn(e,I),o=Math.min(Ve.headerWidth,process.stdout.columns||55);if(!n){vu.warn("Temp key creation failed \u2014 showing UI without a QR"),await _(O.READY,{tunnelUrl:r,permanentKey:e,workerUrl:I}),console.log(m.red(`
258
+ \u274C Failed to create one-time key \u2014 generate a new one from the menu`)),console.log(me.orange("\u2550".repeat(o))),console.log(m.white("App URL".padEnd(14))+m.gray(`${I}/login`)),console.log(m.white("Key".padEnd(14))+m.gray(e)),console.log(me.orange("\u2550".repeat(o)));return}let t=Wn(I,n);await _(O.READY,{tunnelUrl:r,oneTimeKey:n.oneTimeKey,oneTimeKeyExpiresAt:n.expiresAt,permanentKey:e,qrUrl:t,workerUrl:I}),bu(t),console.log(m.gray(`
234
259
  QR will expire in 10 minutes (one-time use)
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(`
260
+ `)),console.log(me.orange("\u2550".repeat(o))),console.log(m.white("App URL".padEnd(14))+m.gray(`${I}/login`)),console.log(m.white("One-Time Key".padEnd(14))+me.orange.bold(n.oneTimeKey)),console.log(m.white("Key".padEnd(14))+m.gray(e)),console.log(me.orange("\u2550".repeat(o)))}async function Rn(e,r,n,o=""){let t=Math.min(Ve.headerWidth,process.stdout.columns||Ve.headerWidth),i=[];return e&&n?(i.push(await Eu(n)),i.push(m.gray(`
236
261
  QR expires in 30 minutes (one-time use)
237
262
  `))):i.push(m.gray(`
238
263
  (One-time key used \u2014 generate a new one from menu)
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(`
264
+ `)),i.push(me.orange("\u2550".repeat(t)),m.white("App URL".padEnd(14))+m.gray(`${I}/login`)),ui.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?me.orange.bold(e)+m.dim(" (expires in 30m)"):m.gray("\u2014")),m.white("Key".padEnd(14))+m.dim(r),me.orange("\u2550".repeat(t))),i.join(`
265
+ `)}var we=F("cmd");function Tt(e,r,n,o){let t=!1;setInterval(async()=>{if(t)return;let i=ki();if(i){t=!0;try{if(i==="stop-tunnel")await Va(e,r,n);else if(i==="restart-tunnel")await Va(e,r,n),await Ya(e,r,n);else if(i==="start-tunnel"){if(await Ya(e,r,n)==="alreadyRunning"){t=!1;return}}else if(i==="regenerate-key")await Su();else if(i==="shutdown")Tu(e,r);else if(i==="update"){let s=await Fs();we.info(`cmd update -> ${s?"started":"SKIPPED (see reasons above)"}`)}else i==="restart"&&Ea(o?.())}catch(s){we.error(`cmd "${i}" failed: ${s?.message||s}`)}finally{t=!1}}},$e.cmdMs)}async function Va(e,r,n){it(),zn();let o=e();o&&(o.kill(),r(null),we.info("Tunnel stopped")),n&&await wt(n),await _(O.STOPPED,{tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null,qrUrl:""}),Tn({tunnelUrl:"",running:!0})}async function Ya(e,r,n){if(V().remoteEnabled===!1){we.info("Start skipped \u2014 remote is disabled");return}let o=e();if(o)if(o.killed||o.exitCode!=null)r(null);else{let t=await te("/api/ui/state");return await _(O.READY,{tunnelUrl:t?.tunnelUrl||""}),"alreadyRunning"}it(),we.info("Starting...");try{await _(O.PREPARING),await ar($r),await _(O.CONNECTING);let t=await W(`${I}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:J(n),hostPublicKey:lt(),hostX25519Key:ut()})});if(!t.ok)throw new Error(`Session create failed: ${t.status}`);await Y("/api/signaling/retry",{}),Ht(n),await _(O.TUNNELING);let i=async l=>{await Kt(n,l),await j({tunnelUrl:l}),dn(l),Tn({tunnelUrl:l,running:!0})},s=({attempt:l,delay:u})=>{j({tunnelRetry:{attempt:l,delay:u,at:Date.now()}})},a=null;try{a=await ze($,i,ot({onUrlUpdate:i,setTunnel:l=>r(l),onRetry:s}))}catch(l){we.error(`Tunnel spawn failed: ${l?.message||l} \u2014 QR RTC-only, bg retry`)}j({tunnelRetry:null});let c="";a&&(r(a.child),c=a.tunnelUrl,await _(O.VERIFYING),await yt(c)||(we.warn("Tunnel health check timed out \u2014 bg reconnect"),c="",r(null),a=null)),await qr(n,c),await _(O.READY,{tunnelUrl:c}),a||kn($,{onUrlUpdate:i,onRestart:ot({onUrlUpdate:i,setTunnel:l=>r(l),onRetry:s}),setActiveTunnel:r,onReady:async l=>{await _(O.READY,{tunnelUrl:l.tunnelUrl})}})}catch(t){we.error(`Failed to start: ${t.message}`),await _(O.STOPPED)}}async function Su(){if(V().remoteEnabled===!1){we.info("Key regeneration skipped \u2014 remote is disabled");return}let e=await qt(),r=kt(e),n=Fn();if(!await Pt(r,I,xi()?.tunnelUrl,n?.key)){we.error("Key regeneration aborted \u2014 could not register the new key");return}We(e,r,n?.name||"Default"),await j({permanentKey:r,oneTimeKey:"",oneTimeKeyExpiresAt:null,qrUrl:"",pairingUsed:!0}),we.info(`Key regenerated: ${wr(r)}`)}function Tu(e,r){it(),we.info("Shutting down 9Remote completely...");let n=e();r(null),rt({tunnelProcess:n}),we.info("9Remote stopped")}Ft();async function Xa(){if(await X()&&(await new Promise(a=>setTimeout(a,ie.guestRecheckMs)),await X())){console.log(m.green(`
266
+ \u{1F310} UI already served at http://localhost:${$}`));return}Be("agent",process.pid),nn(De());let e=await pt(),r=process.argv.find(a=>a.startsWith("--theme=")),n=r?r.split("=")[1]:null;try{le(),await new Promise(a=>setTimeout(a,ie.killCloudflaredMs))}catch{}let o=vt(null,null);await new Promise(a=>setTimeout(a,ie.serverBootMs));let t=`http://localhost:${$}`;console.log(m.green(`
267
+ \u{1F310} UI ready at ${t}`));let i=null;V().remoteEnabled===!1&&await wt(e.key),await j({permanentKey:e.key,step:O.STOPPED,theme:n}),bt(o,null),Tt(()=>i,a=>{i=a},e.key,()=>o),await cr({port:$,onQuit:()=>{let a=i;i=null,rt({serverManager:o,tunnelProcess:a,exit:!1}),Bt(),setTimeout(()=>process.exit(0),500)},onOpenUI:()=>Ut(t)}),Tn({tunnelUrl:"",running:!0}),(process.argv.includes("--start")||process.argv.includes("--skip-update"))&&V().remoteEnabled!==!1&&Jt("start-tunnel"),await new Promise(()=>{})}Ft();async function qa(){if(await X()&&(await new Promise(l=>setTimeout(l,ie.guestRecheckMs)),await X())){console.log(`
268
+ \u{1F310} 9Remote already running at http://localhost:${$}`);return}Be("agent",process.pid),Ps().catch(()=>{});let e=await pt(),r=process.argv.find(l=>l.startsWith("--theme=")),n=r?r.split("=")[1]:null;try{le(),await new Promise(l=>setTimeout(l,ie.killCloudflaredMs))}catch{}let o=vt(null,null);await new Promise(l=>setTimeout(l,ie.serverBootMs));let t=`http://localhost:${$}`,i=null;await j({permanentKey:e.key,step:O.STOPPED,theme:n});let s=()=>{let l=i;i=null,rt({serverManager:o,tunnelProcess:l,exit:!1})};bt(o,null),Tt(()=>i,l=>{i=l},e.key,()=>o);try{Xe("cloudflared")}catch{}(process.argv.includes("--start")||process.argv.includes("--skip-update"))&&V().remoteEnabled!==!1&&Jt("start-tunnel"),await cr({port:$,onQuit:s,onOpenUI:()=>Ut(t)})&&Ho({title:"9Remote is running",message:`Open ${t} or use the tray icon to manage.`}),await new Promise(()=>{})}var Gt=F("mode");async function xu(e){Gt.info("Starting server..."),await _(O.PREPARING);try{le(),await new Promise(l=>setTimeout(l,ie.killCloudflaredMs))}catch{}let r=V().remoteEnabled===!1,n=!r;if(r&&await wt(e),n)try{let l=await W(`${I}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:J(e),hostPublicKey:lt(),hostX25519Key:ut()})});if(!l.ok)throw new Error(`Session create failed: ${l.status}`);Ht(e)}catch(l){Gt.error(`Session create failed: ${l.message} \u2014 local-only, retry from Web UI`),n=!1}let o=await X(),t=o?{getProcess:()=>null,shutdown:()=>{}}:vt(null,null);o||await new Promise(l=>setTimeout(l,ie.serverBootMs)),Gt.info("Starting tunnel..."),await _(O.CONNECTING);let i={current:null},s="",a=async l=>{Gt.info(`Tunnel URL rotated: ${l}`),await Kt(e,l),j({tunnelUrl:l}),dn(l)},c=null;if(n)try{c=await ze($,a,ot({onUrlUpdate:a,setTunnel:l=>{i.current=l}}))}catch(l){Gt.error(`Tunnel spawn failed: ${l.message} \u2014 RTC-only, bg retry`)}return c&&(i.current=c.child,s=c.tunnelUrl,await yt(s)||(Gt.warn("Tunnel health check timed out \u2014 bg reconnect"),i.current=null,s="",c=null)),!c&&n&&kn($,{onUrlUpdate:a,onRestart:ot({onUrlUpdate:a,setTunnel:l=>{i.current=l}}),setActiveTunnel:l=>{i.current=l},onReady:async l=>{await _(O.READY,{tunnelUrl:l.tunnelUrl})}}),s&&await Kt(e,s),n?await _(O.READY,{tunnelUrl:s}):await _(O.STOPPED,{tunnelUrl:""}),Un({apiKey:e,tunnelUrl:s,serverPid:t.getProcess()?.pid,tunnelPid:i.current?.pid}),{serverManager:t,tunnelRef:i,tunnelUrl:s,remoteOnline:n}}async function Qa(){nn(De());let e=await pt();Gt.info(`Using key: ${wr(e.key)} (${e.name})`);let{serverManager:r,tunnelRef:n,tunnelUrl:o,remoteOnline:t}=await xu(e.key);t?await qr(e.key,o):console.log(`\u26A0 ${V().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.`),bt(r,n.current),Tt(()=>n.current,s=>{n.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;j({uptime:`${a}:${String(c).padStart(2,"0")}:${String(l).padStart(2,"0")}`})},$e.statsMs),await new Promise(()=>{})}var Ja=A(require("path"),1),Za=A(require("fs"),1);Ft();async function za(){let e=`http://localhost:${$}`;await X()&&(Wr($),await new Promise(c=>setTimeout(c,500)));let r=["--tray"],n=process.argv.find(c=>c.startsWith("--theme="));n&&r.push(n);let o=Hn;try{Za.default.mkdirSync(Ja.default.dirname(o),{recursive:!0})}catch{}let t=null;try{t=ks(r),t&&Be("agent",t)}catch(c){console.log(m.red(`
269
+ \u274C Failed to launch background: ${c.message}`)),process.exit(1)}let i=Date.now()+$e.bgServerReadyTimeoutMs,s=!1;for(;Date.now()<i;){if(await X()){s=!0;break}await new Promise(c=>setTimeout(c,$e.bgServerReadyIntervalMs))}s||(console.log(m.red(`
245
270
  \u274C Background server failed to start.`)),console.log(m.gray(` Check log: ${o}
246
- `)),process.exit(1)),qt("start-tunnel"),Nt(e);let a=t?` (PID: ${t})`:"";console.log(m.green(`
271
+ `)),process.exit(1)),Jt("start-tunnel"),Ut(e);let a=t?` (PID: ${t})`:"";console.log(m.green(`
247
272
  \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 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(`
273
+ `)),await new Promise(c=>setTimeout(c,ie.bgSpawnFlushMs)),process.exit(0)}var ec=A(require("readline"),1);var Qr=F("mode"),Pn=null;async function Jr(){Be("agent",process.pid),console.clear(),Xi(),Zi(!0),await _(O.PREPARING);let e=await pt(),r=null,n={getProcess:()=>null,shutdown:()=>{}};if(!await X()){n=vt(null,null,()=>{if(process.stdin.isTTY){try{process.stdin.setRawMode(!1)}catch{}try{process.stdin.setRawMode(!0),process.stdin.resume()}catch{}}try{ec.default.emitKeypressEvents(process.stdin)}catch{}r?.()});let g=Date.now()+$e.serverReadyTimeoutMs;for(;Date.now()<g&&!await X();)await new Promise(T=>setTimeout(T,$e.serverReadyIntervalMs))}try{le(),await new Promise(g=>setTimeout(g,ie.killCloudflaredTuiMs))}catch{}try{await ar($r)}catch(g){Qr.error(`cloudflared setup failed: ${g?.message||g} \u2014 retry from Web UI`)}await _(O.CONNECTING);let t=V().remoteEnabled===!1,i=!t;if(t&&await wt(e.key),i)try{let g=await W(`${I}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:J(e.key),hostPublicKey:lt(),hostX25519Key:ut()})});if(!g.ok)throw new Error(`Session create failed: ${g.status}`);await Y("/api/signaling/retry",{}),Ht(e.key)}catch(g){Qr.error(`Failed to connect: ${g.message}`),i=!1}await _(O.TUNNELING);let s=i?await jn(e.key,I):null,a=Wn(I,s),c=s?.oneTimeKey||"",l=a,u="",f=null,p={current:null},d=async g=>{u=g,await Kt(e.key,g),await j({tunnelUrl:g}),dn(g),f!==null&&(f=await Rn(c,e.key,l,u),r?.())},h=null;if(i)try{h=await ze($,d,ot({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,Un({apiKey:e.key,tunnelUrl:h.tunnelUrl,tunnelPid:h.child?.pid}),await _(O.VERIFYING),await yt(h.tunnelUrl)?await d(h.tunnelUrl):(Qr.warn("Tunnel health check timed out \u2014 bg reconnect"),p.current=null,u="",h=null)),!h&&i&&kn($,{onUrlUpdate:d,onRestart:ot({onUrlUpdate:d,setTunnel:g=>{p.current=g}}),setActiveTunnel:g=>{p.current=g},onReady:async g=>{Un({apiKey:e.key,tunnelUrl:g.tunnelUrl,tunnelPid:g.child?.pid}),await _(O.READY,{tunnelUrl:g.tunnelUrl})}}),i?await _(O.READY,{tunnelUrl:u,oneTimeKey:s?.oneTimeKey||"",oneTimeKeyExpiresAt:s?.expiresAt||null,permanentKey:e.key,qrUrl:a,workerUrl:I}):(await _(O.STOPPED,{tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null,permanentKey:e.key,qrUrl:"",workerUrl:I}),console.log(m.red(`
249
274
  \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(`
275
+ `))),await new Promise(g=>setTimeout(g,ie.trayReadyMs)),f=await Rn(c,e.key,l,u);let w=[],v=!1,P=()=>{v||r?.()},S=async(g,T,L)=>{if(!v){v=!0;try{let C=await qi(T,L);await Y(`/api/device/${C?"approve":"reject"}`,{socketId:g})}catch{}finally{v=!1,r?.()}}},x=Qi($,async(g,T)=>{if(g==="log"&&T.message)w.push(T.message),w.length>Ve.maxLogLines&&w.shift();else if(g==="state"){let L=T.permanentKey||e.key,C=T.oneTimeKey!==void 0?T.oneTimeKey:c,z=T.qrUrl!==void 0?T.qrUrl:l,ue=T.tunnelUrl!==void 0?T.tunnelUrl:u;(C!==c||L!==e.key||ue!==u)&&(c=C,l=z,u=ue,T.permanentKey&&(e={...e,key:T.permanentKey}),f=await Rn(c,e.key,l,u),P())}else g==="permissions"?(v||Promise.resolve(Pn?.()).catch(()=>{}),P()):g==="autostart"||g==="sleepInhibit"?(v||Promise.resolve(Pn?.()).catch(()=>{}),P()):g==="deviceApproval"&&T.action==="pending"&&await S(T.socketId,T.deviceId,T.ip)}),R=setInterval(async()=>{if(!v)try{let T=(await te("/api/device/pending"))?.pending?.[0];T&&await S(T.socketId,T.deviceId,T.ip)}catch{}},$e.pendingApprovalMs);bt({getProcess:n.getProcess,shutdown:()=>{it(),n.shutdown();try{p.current?.kill()}catch{}x(),clearInterval(R)}}),Tt(()=>p.current,g=>{p.current=g},e.key,()=>n),await Au(e,u,()=>f,g=>{f=g},g=>{r=g},()=>{it();try{x()}catch{}try{clearInterval(R)}catch{}rt({serverManager:n,tunnelProcess:p.current,exit:!1})},w)}async function Au(e,r,n,o,t,i,s){for(;;){let{desktopEnabled:a,remoteAvailable:c,autoApprove:l}=await go(),u=[{label:"Open Web UI",action:"webui"}];V().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 Ne("",u,0,n,h=>{f=h},i),d=p>=0?u[p].action:"exit";if(d==="webui"){let h=`http://localhost:${$}`,{openBrowser:w}=await Promise.resolve().then(()=>(Ft(),ma));w(h),console.log(m.green(`
251
276
  \u{1F310} Opening ${h}
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(`
277
+ `))}else if(d==="keys")await ku(e,r,o,n);else if(d==="desktop")await $u();else if(d==="devices")await Ou();else if(d==="settings")await Pu();else if(d==="logs")await Iu();else{try{i?.()}catch{}console.log(m.gray(`
253
278
  Goodbye!
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
- `):m.gray(" No logs yet"),r=`
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(`
279
+ `)),process.exit(0)}}}async function ku(e,r,n,o){let t=V().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 Ne("Keys",t,0,o),s=i>=0?t[i].action:"back";if(s==="otk"){let a=await jn(e.key,I);if(a){let c=Wn(I,a);n(await Rn(a.oneTimeKey,e.key,c,r)),await j({oneTimeKey:a.oneTimeKey,oneTimeKeyExpiresAt:a.expiresAt,qrUrl:c})}}else if(s==="regen"&&await mo(m.yellow("Replace current key and disconnect all sessions? Continue?"))){let c=await qt(),l=kt(c);if(!await Pt(l,I,r,e.key)){n(m.red("Key regeneration failed \u2014 could not reach the server"));return}let u=We(c,l,e.name||"Default");Object.assign(e,u),n(await Rn("",e.key,"",r)),await j({permanentKey:e.key,oneTimeKey:"",oneTimeKeyExpiresAt:null,qrUrl:"",pairingUsed:!0})}}var ti={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 Ru(e,r){let n=r.map(s=>({label:ti[s]||s,action:s}));n.push({label:m.gray("\u2190 Back"),action:"back"});let o=Math.max(0,r.indexOf(e)),t=await Ne("Prevent sleep",n,o),i=t>=0?n[t].action:"back";i!=="back"&&await Y("/api/sleep-inhibit",{mode:i})}async function Pu(){for(;;){let e=!1,r="never",n=[],o=()=>[{label:`Launch on system startup: ${e?m.green("ON"):m.gray("OFF")}`,action:"autostart"},{label:`Prevent sleep: ${r==="none"?m.gray(ti.none):m.green(ti[r]||r)} \u25B6`,action:"sleep"},{label:m.gray("\u2190 Back"),action:"back"}],t=o(),i=null,s=async()=>{let l=await go();e=!!l.autoStart,r=l.sleepInhibitMode||"never",n=l.sleepInhibitPresets||[],t=o(),i?.()};await s(),Pn=s;let a=await Ne("Settings",t,0,"",l=>{i=l});Pn=null;let c=a>=0?t[a].action:"back";if(c==="autostart")await Y("/api/autostart",{enabled:!e});else if(c==="sleep")await Ru(r,n);else return}}async function $u(){for(;;){let e=!1,r={screenRecording:!1,accessibility:!1},n=()=>({toggle:`Toggle: ${e?m.green("ON \u2192 turn OFF"):m.gray("OFF \u2192 turn ON")}`,sr:`Screen Recording ${r.screenRecording?m.green("\u2713"):m.red("\u2717 (click to grant)")}`,ax:`Mouse & Keyboard control ${r.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 te("/api/ui/state")||{};e=!!a.desktopEnabled,r={screenRecording:!!a.screenRecording,accessibility:!!a.accessibility};let c=n();o[0].label=c.toggle,o[1].label=c.sr,o[2].label=c.ax,t?.()};await i(),Pn=i;let s=await Ne("Remote Desktop",o,0,"",a=>{t=a});if(Pn=null,s===0)await Y("/api/desktop/toggle",{enabled:!e});else if(s===1&&!r.screenRecording)await Y("/api/permissions/request",{type:"screenRecording"})||xr("screenRecording");else if(s===2&&!r.accessibility)await Y("/api/permissions/request",{type:"accessibility"})||xr("accessibility");else if(s===3||s===-1)return}}async function Ou(){for(;;){let[e,r]=await Promise.all([te("/api/device/approved"),te("/api/device/auto-approve")]),n=e?.devices||[],o=!!r?.enabled,t=[{label:`Auto-approve new devices: ${o?m.green("ON"):m.gray("OFF")}`,action:"toggle"},...n.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 Ne(`Approved Devices (${n.length})`,t,0);if(i===-1)return;let s=t[i];if(s.action==="back")return;if(s.action==="toggle"){await Y("/api/device/auto-approve",{enabled:!o});continue}s.action==="remove"&&await mo(m.yellow(`Remove device ${s.deviceId.slice(0,8)}...?`))&&await Y("/api/device/remove",{deviceId:s.deviceId})}}async function Iu(){let e=Oi(li),r=e.length?e.join(`
280
+ `):m.gray(" No logs yet"),n=`
281
+ ${m.dim("Log file:")} ${m.cyan(Hn)}
282
+ ${m.dim(`Tail: tail -f ${Hn}`)}`;await Ne("Logs",[{label:m.gray("\u2190 Back")}],0,r+n)}async function tc(){let e=De(),r=await Cs(),n=po(e,r?.latest??null),o=[];r?.latest&&o.push({label:m.yellow(`Update to v${r.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 Ne("",o,0,n),i=t>=0?o[t].action:"exit";if(i==="update"){let s=Math.min(Ve.headerWidth,process.stdout.columns||Ve.headerWidth);Ur(),console.log(me.orange(`
258
283
  `+"\u2550".repeat(s))),console.log(m.gray(` \u2713 Stopped running instances
259
284
  `)),console.log(m.yellow(` \u2B06 Run this command to update:
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
285
+ `)),console.log(m.white.bold(` npm i -g ${ke}
286
+ `)),console.log(me.orange("\u2550".repeat(s))+`
287
+ `),process.exit(0)}else i==="ui"?await za():i==="tui"?await Jr():process.exit(0)}var ac=A(require("node:fs"),1);function Lu(e){let r=new Set;return e.map(n=>{if(!r.has(n))return r.add(n),n;let o=2;for(;r.has(`${n} (${o})`);)o++;let t=`${n} (${o})`;return r.add(t),t})}function _u(e,r){let n=new Map;for(let o of e){let t=r(o)||"Page";n.has(t)||n.set(t,[]),n.get(t).push(o)}return[...n].map(([o,t])=>({path:o,items:t}))}var ni=e=>`${e.role}|${e.kind}`;var pr=e=>String(e??"").replace(/\n/g," "),nc=(e,r)=>{let n=e.value?` =${pr(e.value).slice(0,30)}`:"",o=e.checked?` [${e.checked}]`:"";return`${e.id} ${e.role||e.kind} "${pr(r)}"${o}${n}`};function Mu(e,r,n){let{period:o,cycles:t,constant:i}=r;if(o===1&&i[0])return[`${e[0].role} "${pr(e[0].label)}" \xD7${t}: `+e.map(c=>c.id).join(" ")];let s=Array.from({length:o},(c,l)=>i[l]?`${e[l].role} "${pr(e[l].label)}"`:e[l].role),a=[];for(let c=0;c<t;c++)a.push(Array.from({length:o},(l,u)=>{let f=e[c*o+u];return i[u]?f.id:`${f.id} ${pr(n.get(f.id))}`}).join(" \xB7 "));return[`row \xD7${t} [${s.join(", ")}]`,...a]}function Cu(e,r,n){let o=0;for(;r+(o+1)*n<=e.length&&e.slice(r+o*n,r+(o+1)*n).every((t,i)=>ni(t)===ni(e[r+i]));)o++;return o}function oc(e,r){let n=null,o=(a,c,l)=>!n||a>n.density+1e-9||Math.abs(a-n.density)<1e-9&&(c>n.len||c===n.len&&l<n.cycle.period);for(let a=0;a+6<=e.length;a++){let c=Math.min(50,Math.floor((e.length-a)/3));for(let l=1;l<=c;l++){let u=Cu(e,a,l);if(u<3||l===1&&new Set(e.slice(a,a+u).map(h=>h.label)).size>1)continue;let f=Array.from({length:l},(h,w)=>{let v=e[a+w].label;for(let P=1;P<u;P++)if(e[a+P*l+w].label!==v)return!1;return!0}),p=f.filter(Boolean).length;if(p===0&&new Set(e.slice(a,a+l).map(ni)).size<2)continue;let d=u*l;o(p/l,d,l)&&(n={start:a,len:d,cycle:{period:l,cycles:u,constant:f},density:p/l})}}if(!n)return e.map(a=>nc(a,r.get(a.id)));let t=e.slice(0,n.start).map(a=>nc(a,r.get(a.id))),i=Mu(e.slice(n.start,n.start+n.len),n.cycle,r),s=oc(e.slice(n.start+n.len),r);return[...t,...i,...s]}var rc=e=>" ".repeat(e);function ic(e){let r=Lu(e.map(i=>i.label)),n=new Map(e.map((i,s)=>[i.id,r[s]])),o=[],t=(i,s)=>{for(let{path:a,items:c}of _u(i,l=>l.path?.[0])){o.push(`${rc(s)}${a}:`);let l=c.filter(f=>(f.path?.length??1)>1).map(f=>({...f,path:f.path.slice(1)})),u=c.filter(f=>(f.path?.length??1)<=1);for(let f of oc(u,n))o.push(`${rc(s+1)}${f}`);l.length&&t(l,s+1)}};return t(e,0),o.join(`
288
+ `)}function Nu(e){let r=[],n={};for(let o=0;o<e.length;o++){let t=e[o];if(t==="--url"){n.url=e[++o];continue}if(t==="--max-steps"){n.maxSteps=Number(e[++o]);continue}if(t==="--attach"){n.mode="attach";continue}if(t==="--extension"){n.mode="extension";continue}if(t==="--no-headless"){n.headless=!1;continue}if(t==="--enter"){n.enter=!0;continue}if(t==="--only"){n.only=e[++o];continue}if(t==="--fields"){n.fields=Du(e[++o]);continue}if(t==="--expect-text"){(n.expectText||=[]).push(e[++o]);continue}if(t==="--expect-url"){n.expectUrl=e[++o];continue}if(t==="--expect-title"){n.expectTitle=e[++o];continue}if(t==="--tail"){n.tail=!0;continue}if(t==="--prompt"){n.promptText=e[++o];continue}if(t==="--wait"){n.wait=e[++o];continue}if(t==="--timeout-ms"){n.timeoutMs=Number(e[++o]);continue}r.push(t)}return{positional:r,opts:n}}function Du(e){let r={};for(let n of String(e||"").split(";")){let o=n.indexOf("=");o>0&&(r[n.slice(0,o).trim()]=n.slice(o+1))}return Object.keys(r).length?r:void 0}async function D(e,r){await X()||(console.error("9remote server is not running \u2014 start it first (9remote ui / start)"),process.exit(1));let n=await Y("/api/browser-use",{action:e,payload:r});return n||(console.error("Local API unreachable"),process.exit(1)),n.json()}function B(e){return e?.ok||(console.error(e?.error||"Request failed"),process.exit(1)),e}function ce(e){console.log(`${e.url}`),console.log(`${e.title||""} \xB7 ${e.actions?.length??0} elements \xB7 ${e.w}x${e.h}`);let r=String(e.text||"").replace(/\s+/g," ").trim();r&&console.log(`text: ${r.slice(0,800)}${r.length>800?" \u2026":""}`),console.log(ic(e.actions||[])),e.omitted_actions&&console.log(`\u2026 ${e.omitted_actions} more elements cut by the cap`)}function Bu(e){let r=[],n="",o=null;for(let t of e){if(o){n+=t,t===o&&(o=null);continue}if(t==='"'||t==="'"){o=t,n+=t;continue}if(t===";"){r.push(n.trim()),n="";continue}n+=t}return n.trim()&&r.push(n.trim()),r.filter(Boolean)}function Uu(e){let r=e.match(/^(click|select|type|enter|scroll|wait|run)\b\s*(.*)$/);if(!r)throw new Error(`Cannot parse step: ${e}`);let[,n,o]=r,t=o.match(/"[^"]*"|'[^']*'|\S+/g)||[],i=s=>String(s).replace(/^["']|["']$/g,"");switch(n){case"click":case"select":return{op:n,id:i(t[0])};case"type":{let s=t.includes("--enter"),a=t.filter(c=>c!=="--enter");return{op:n,id:i(a[0]),text:i(a.slice(1).join(" ")),enter:s}}case"enter":return{op:n};case"scroll":return{op:n,direction:i(t[0])||"down"};case"wait":{let s=t[0];return s&&/^["']/.test(s)?{op:n,text:i(s)}:{op:n,ms:Number(s)||300}}default:{let s=t.indexOf("--only"),a=s>=0?new Set([s,s+1]):null;return{op:"run",goal:i(t.filter((l,u)=>!a?.has(u)).join(" ")),only:s>=0?i(t[s+1]):void 0}}}}function Fu(e){for(let r of e.steps||[]){let n=[`#${r.seq}`,r.operation,r.targetIndex?`[${r.targetIndex}]`:"",r.label||""].filter(Boolean).join(" ");console.log(` ${n} \xB7 ${r.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 sc=`9remote browser \u2014 agent-driven Chrome via the host engine
263
289
 
264
- 9remote browser open <url> [--profile N] [--attach] [--no-headless]
290
+ 9remote browser open <url> [--attach] [--no-headless] [--wait "text"]
265
291
  # 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]
292
+ # --wait: hold until the page shows the text (SPA-ready marker)
293
+ 9remote browser state numbered element table
294
+ 9remote browser read [--tail] filtered page TEXT (cheaper than shot)
295
+ 9remote browser run "<sub-goal>" [--url URL] [--max-steps N] [--only REGEX] [--fields "L=text;..."] [--prompt "text"]
269
296
  # --only: Jev sees only matching element labels
297
+ # --fields: Jev picks the fields, engine types YOUR text
298
+ # (password values are masked, never sent to the model)
270
299
  # --expect-text "..." (repeatable) / --expect-url / --expect-title:
271
300
  # engine verifies them on a fresh read \u2014 only PASSED is success
272
- 9remote browser click <id> [options] click table id (e3)
301
+ 9remote browser click <id> [options] click table id (e3) \u2014 --wait "text" gates completion in this call
302
+ # --prompt "text": answer a window.prompt() the click opens
303
+ # (native dialog, never appears in the element table)
304
+ 9remote browser clickxy <x> <y> click exact page coordinates (custom widgets)
305
+ 9remote browser hover <id> move the mouse onto an element (hover menus)
306
+ 9remote browser key <enter|escape|tab|arrow...> send a named key
307
+ 9remote browser scroll <top|bottom|px> jump to top/bottom or scroll by pixels (negative = up)
308
+ 9remote browser back | forward | reload browser history navigation
309
+ 9remote browser wait "<text>" bounded wait until text/element appears
310
+ 9remote browser tab <n> | tabclose [<n>] switch tab #n / close one (active by default)
273
311
  9remote browser type <id> "<text>" [--enter] type exact text (+ Enter) into field
312
+ 9remote browser upload <id> <file-path> set a file on an observed file input (CDP, no native picker)
313
+ 9remote browser download [--timeout MS] wait for the next completed download, print its path
314
+ 9remote browser drag <from> <to> HTML5 drag: press at <from>, release over <to>
274
315
  9remote browser chain "click e1; type e2 'hi' --enter; wait 'result'" # many steps, ONE call
316
+ 9remote browser chain "run 'open pricing'; type e5 'hi'; run 'pick team plan' --only 'Plan'"
317
+ # batch Jev sub-goals in one chain too
275
318
  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>
319
+ 9remote browser shot writes /tmp/9remote-shot-*.jpg, prints the path
320
+ 9remote browser tabs [--attach] # list open browser tabs
321
+ 9remote browser close
279
322
  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(`
323
+ 9remote browser status config + sessions`;async function cc(e){let{positional:r,opts:n}=Nu(e),[o,...t]=r,i=n.mode==="attach";n.mode==="extension"&&(n.profile="__extension__");let s=(a={})=>({profile:i?"__attach__":void 0,...n,...a});switch(o){case void 0:case"help":console.log(sc);return;case"tabs":{let a=B(await D("tabs",s()));for(let c of a.tabs||[]){let l=c.active?"* ":" ";console.log(`${l}[${c.id}] ${c.title||"(untitled)"} \u2014 ${c.url}`)}return}case"open":{let a=B(await D("open",s({url:t[0],wait:n.wait,timeoutMs:n.timeoutMs}))),c=i?"real browser (debug)":n.mode==="extension"?"real browser (extension)":"isolated Chrome";console.log(`opened ${t[0]} (${c})`),a.state&&ce(a.state);return}case"state":{let a=B(await D("state",s()));ce(a);return}case"read":{let a=B(await D("state",s())),c=(a.headings||[]).join(" \u203A ");c&&console.log(`## ${c}`);let l=a.text||"";console.log(n.tail?l.slice(Math.floor(l.length/2)):l),l.trim()||console.log("(no readable text in view \u2014 scroll or open an article first)");return}case"run":{let a=B(await D("run",s({goal:t.join(" ")})));if(Fu(a),a.verification){console.log(`verification: ${a.verification.passed?"PASSED \u2014 independently verified, safe to report success":"FAILED"}`);for(let[c,l]of Object.entries(a.verification.checks))l||console.log(` not met: ${c}`)}a.frame&&console.log(`frame: ${a.frame}`),a.state&&ce(a.state);return}case"click":{let a=B(await D("click",s({id:t[0],wait:n.wait,timeoutMs:n.timeoutMs})));console.log(`clicked ${t[0]}`),a.state&&ce(a.state);return}case"clickxy":{let a=B(await D("clickxy",s({x:Number(t[0]),y:Number(t[1])})));console.log(`clicked x=${t[0]} y=${t[1]}`),a.state&&ce(a.state);return}case"scroll":{let a=String(t[0]||""),c=["top","bottom"].includes(a)?{edge:a}:{px:Number(a)},l=B(await D("scroll",s(c)));l.state&&ce(l.state);return}case"back":case"forward":{let a=B(await D(o,s()));a.state&&ce(a.state);return}case"reload":{let a=B(await D("reload",s()));a.state&&ce(a.state);return}case"key":{let a=B(await D("key",s({name:t[0]})));a.state&&ce(a.state);return}case"hover":{let a=B(await D("hover",s({id:t[0]})));console.log(`hovered ${t[0]}`),a.state&&ce(a.state);return}case"wait":{let a=B(await D("wait",s({text:t.join(" ")})));console.log(`wait "${t.join(" ")}": ${a.found?"FOUND":"TIMEOUT"}`),a.state&&ce(a.state);return}case"tab":{let a=B(await D("tab",s({index:Number(t[0])})));console.log(`active: ${a.url}`),a.state&&ce(a.state);return}case"tabclose":{let a=B(await D("tabclose",s(t[0]?{index:Number(t[0])}:{})));console.log(`closed: ${a.closed}`);return}case"type":{let a=B(await D("type",s({id:t[0],text:t.slice(1).join(" "),enter:!!n.enter,wait:n.wait,timeoutMs:n.timeoutMs})));console.log(`typed into ${t[0]}${n.enter?" + enter":""}`),a.state&&ce(a.state);return}case"upload":{let a=B(await D("upload",s({id:t[0],file:t[1]})));console.log(`uploaded ${a.uploaded} into ${t[0]}`),a.state&&ce(a.state);return}case"download":{let a=B(await D("download",s({timeout:n.timeout})));console.log(`downloaded: ${a.download.path}`);return}case"drag":{let a=B(await D("drag",s({from:t[0],to:t[1]})));console.log(`dragged ${t[0]} onto ${t[1]}`);return}case"enter":{let a=B(await D("enter",s()));console.log("enter pressed"),a.state&&ce(a.state);return}case"shot":{let a=B(await D("shot",s())),c=`/tmp/9remote-shot-${Date.now()}.jpg`;ac.default.writeFileSync(c,Buffer.from(a.image,"base64")),console.log(c);return}case"chain":{let a=Bu(t.join(" ")).map(Uu),c=await D("chain",s({steps:a}));if(!c?.results){B(c);return}for(let l of c.results)console.log(` ${l.ok?"ok":"FAIL"} #${l.step} ${l.summary||l.op}${l.error?` \u2014 ${l.error}`:""}`);c.failedStep&&console.error(`chain stopped at step ${c.failedStep}`),c.state&&ce(c.state);return}case"close":B(await D("close",s())),console.log("closed");return;case"attach":{let a=B(await D("attach.status",{}));a.available?console.log(`attached (port ${a.port})`):(console.log("not attached:"),(a.guide||[]).forEach((c,l)=>console.log(` ${l+1}. ${c}`)));return}case"status":{let a=B(await D("status",{}));console.log(JSON.stringify(a,null,2));return}default:console.error(`Unknown browser subcommand: ${o}
324
+ `),console.log(sc),process.exit(1)}}var lc=[["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 Zr(){nn(De()),console.log(m.white.bold(`
283
325
  Usage:
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(`
326
+ `));let e=Math.max(...lc.map(([r])=>r.length))+2;for(let[r,n]of lc)console.log(" "+m.cyan(r.padEnd(e))+m.gray(n));console.log()}async function dr(){return await X()?!0:(console.log(m.red(`
285
327
  \u2717 Server not running. Start it first: `)+m.cyan("9remote start")+`
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(`
328
+ `),!1)}async function Ku(e){if(!await dr())return;if(e){let n=await Y("/api/key/regenerate"),o=n&&n.ok?await n.json():null;if(!o?.permanentKey){console.log(m.red(`
287
329
  \u2717 Regenerate failed
288
330
  `));return}console.log(m.green(`
289
331
  \u2713 New key: `)+m.white.bold(o.permanentKey)+`
290
- `);return}let n=await Z("/api/ui/state")||{};if(!n.permanentKey){console.log(m.red(`
332
+ `);return}let r=await te("/api/ui/state")||{};if(!r.permanentKey){console.log(m.red(`
291
333
  \u2717 No key yet. Run: `)+m.cyan("9remote start")+`
292
334
  `);return}console.log(m.white(`
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(`
335
+ Key`.padEnd(14))+m.white.bold(r.permanentKey)),r.qrUrl&&console.log(m.white("Connect URL".padEnd(14))+m.cyan(r.qrUrl)),console.log(m.white("App URL".padEnd(14))+m.gray(`${I}/login`)+`
336
+ `)}async function Hu(){if(!await dr())return;let e=await Y("/api/key/one-time"),r=e&&e.ok?await e.json():null;if(!r?.qrUrl){console.log(m.red(`
295
337
  \u2717 Failed to create one-time key
296
338
  `));return}console.log(m.green(`
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(`
339
+ \u2713 One-time key (30 min): `)+m.white.bold(r.oneTimeKey)),console.log(m.white("Connect URL ")+m.cyan(r.qrUrl)+`
340
+ `)}async function ju(){if(!await dr())return;let r=(await te("/api/device/approved")||{}).devices||[],n=await te("/api/device/auto-approve")||{};if(console.log(m.white(`
341
+ Auto-approve: `)+(n.enabled?m.green("ON"):m.gray("OFF"))),!r.length){console.log(m.gray(`No approved devices
342
+ `));return}console.log(m.white(`Approved devices (${r.length}):`));for(let o of r)console.log(" "+m.cyan(o.deviceId));console.log()}async function Wu(e){if(!await dr())return;let r=e==="on";if(e!=="on"&&e!=="off"){console.log(m.red(`
301
343
  \u2717 Usage: 9remote auto-approve <on|off>
302
- `));return}let r=await G("/api/device/auto-approve",{enabled:n}),o=r&&r.ok?await r.json():null;console.log(m.green(`
344
+ `));return}let n=await Y("/api/device/auto-approve",{enabled:r}),o=n&&n.ok?await n.json():null;console.log(m.green(`
303
345
  \u2713 Auto-approve: `)+(o?.enabled?m.green("ON"):m.gray("OFF"))+`
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(`
346
+ `)}async function Gu(e){if(!await dr())return;if(!e){let t=(await te("/api/device/pending")||{}).pending||[];if(!t.length){console.log(m.gray(`
305
347
  No pending devices
306
348
  `));return}console.log(m.white(`
307
349
  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(`
308
350
  Approve with: `)+m.cyan("9remote approve <socketId>")+`
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(`
351
+ `);return}let r=await Y("/api/device/approve",{socketId:e}),n=r&&r.ok?await r.json():null;console.log(n?.ok?m.green(`
310
352
  \u2713 Approved
311
353
  `):m.red(`
312
354
  \u2717 Approve failed (invalid socketId?)
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);
355
+ `))}async function uc(e){let r=e[2],n=e.slice(3);switch(r){case"help":case"-h":case"--help":return Zr(),!0;case"key":return await Ku(n.includes("--new")),!0;case"otk":return await Hu(),!0;case"devices":return await ju(),!0;case"browser":return await cc(n),!0;case"auto-approve":return await Wu(n[0]),!0;case"approve":return await Gu(n[0]),!0;default:return!1}}var ri=process.argv[2];(ri==="version"||ri==="--version"||ri==="-v")&&(process.stdout.write(De()+`
356
+ `),process.exit(0));$i();async function Vu(){let e=process.argv[2];if(await uc(process.argv))return;let r=process.argv.includes("--tray")||process.argv.includes("--auto")||process.argv.includes("--start"),n=["ui","tui","start","help","-h","--help"].includes(e);if(e&&!e.startsWith("--")&&!n&&!r){Zr();return}r||Ur(),e==="ui"?await Xa():e==="tui"?await Jr():e==="start"||process.argv.includes("--auto")?await Qa():process.argv.includes("--tray")||process.argv.includes("--start")?await qa():process.stdin.isTTY?await tc():Zr()}Vu().catch(console.error);