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