9remote 2.1.21 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/tray.ps1 +8 -0
- package/dist/bin/desktop-bridge.cs +212 -0
- package/dist/bin/desktop-elevate.cs +166 -0
- package/dist/cli.cjs +91 -90
- package/dist/ptyDaemon.cjs +6 -7
- package/dist/server.cjs +168 -97
- package/dist/ui/assets/{index-BRA8JHNZ.js → index-DviNN66Q.js} +2958 -3882
- package/dist/ui/assets/{index-Cq9ojg5L.css → index-ulRsGAYR.css} +8 -5
- package/dist/ui/index.html +2 -2
- package/package.json +5 -3
package/dist/cli.cjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const __importMetaUrl = require('url').pathToFileURL(__filename).href;
|
|
3
|
-
var
|
|
4
|
-
`)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return b.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return b.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return b.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function l(b){var k=c((0,d.execSync)(x[T]).toString());return b?k:a(k)}function u(b){return new p.default(function(k,S){return(0,d.exec)(x[T],{},function(g,_,O){if(g)return S(new Error("Error while obtaining machine id: "+g.stack));var F=c(_.toString());return k(b?F:a(F))})})}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,T=w.platform,P={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},x={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(r,o,t){r.exports={default:t(36),__esModule:!0}},function(r,o,t){t(66),t(68),t(69),t(67),r.exports=t(6).Promise},function(r,o){r.exports=function(){}},function(r,o){r.exports=function(t,i,s,a){if(!(t instanceof i)||a!==void 0&&a in t)throw TypeError(s+": incorrect invocation!");return t}},function(r,o,t){var i=t(13),s=t(31),a=t(62);r.exports=function(c){return function(l,u,f){var p,d=i(l),h=s(d.length),w=a(f,h);if(c&&u!=u){for(;h>w;)if(p=d[w++],p!=p)return!0}else for(;h>w;w++)if((c||w in d)&&d[w]===u)return c||w||0;return!c&&-1}}},function(r,d,t){var i=t(7),s=t(44),a=t(43),c=t(3),l=t(31),u=t(64),f={},p={},d=r.exports=function(h,w,T,P,x){var b,k,S,g,_=x?function(){return h}:u(h),O=i(T,P,w?2:1),F=0;if(typeof _!="function")throw TypeError(h+" is not iterable!");if(a(_)){for(b=l(h.length);b>F;F++)if(g=w?O(c(k=h[F])[0],k[1]):O(h[F]),g===f||g===p)return g}else for(S=_.call(h);!(k=S.next()).done;)if(g=s(S,O,k.value,w),g===f||g===p)return g};d.BREAK=f,d.RETURN=p},function(r,o){r.exports=function(t,i,s){var a=s===void 0;switch(i.length){case 0:return a?t():t.call(s);case 1:return a?t(i[0]):t.call(s,i[0]);case 2:return a?t(i[0],i[1]):t.call(s,i[0],i[1]);case 3:return a?t(i[0],i[1],i[2]):t.call(s,i[0],i[1],i[2]);case 4:return a?t(i[0],i[1],i[2],i[3]):t.call(s,i[0],i[1],i[2],i[3])}return t.apply(s,i)}},function(r,o,t){var i=t(11);r.exports=Object("z").propertyIsEnumerable(0)?Object:function(s){return i(s)=="String"?s.split(""):Object(s)}},function(r,o,t){var i=t(10),s=t(1)("iterator"),a=Array.prototype;r.exports=function(c){return c!==void 0&&(i.Array===c||a[s]===c)}},function(r,o,t){var i=t(3);r.exports=function(s,a,c,l){try{return l?a(i(c)[0],c[1]):a(c)}catch(f){var u=s.return;throw u!==void 0&&i(u.call(s)),f}}},function(r,o,t){"use strict";var i=t(49),s=t(17),a=t(18),c={};t(5)(c,t(1)("iterator"),function(){return this}),r.exports=function(l,u,f){l.prototype=i(c,{next:s(1,f)}),a(l,u+" Iterator")}},function(r,o,t){var i=t(1)("iterator"),s=!1;try{var a=[7][i]();a.return=function(){s=!0},Array.from(a,function(){throw 2})}catch{}r.exports=function(c,l){if(!l&&!s)return!1;var u=!1;try{var f=[7],p=f[i]();p.next=function(){return{done:u=!0}},f[i]=function(){return p},c(f)}catch{}return u}},function(r,o){r.exports=function(t,i){return{value:i,done:!!t}}},function(r,o,t){var i=t(2),s=t(30).set,a=i.MutationObserver||i.WebKitMutationObserver,c=i.process,l=i.Promise,u=t(11)(c)=="process";r.exports=function(){var f,p,d,h=function(){var x,b;for(u&&(x=c.domain)&&x.exit();f;){b=f.fn,f=f.next;try{b()}catch(k){throw f?d():p=void 0,k}}p=void 0,x&&x.enter()};if(u)d=function(){c.nextTick(h)};else if(a){var w=!0,T=document.createTextNode("");new a(h).observe(T,{characterData:!0}),d=function(){T.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(x){var b={fn:x,next:void 0};p&&(p.next=b),f||(f=b,d()),p=b}}},function(r,o,t){var i=t(3),s=t(50),a=t(22),c=t(19)("IE_PROTO"),l=function(){},u="prototype",f=function(){var p,d=t(16)("iframe"),h=a.length,w=">";for(d.style.display="none",t(25).appendChild(d),d.src="javascript:",p=d.contentWindow.document,p.open(),p.write("<script>document.F=Object</script"+w),p.close(),f=p.F;h--;)delete f[u][a[h]];return f()};r.exports=Object.create||function(p,d){var h;return p!==null?(l[u]=i(p),h=new l,l[u]=null,h[c]=p):h=f(),d===void 0?h:s(h,d)}},function(r,o,t){var i=t(12),s=t(3),a=t(54);r.exports=t(4)?Object.defineProperties:function(c,l){s(c);for(var u,f=a(l),p=f.length,d=0;p>d;)i.f(c,u=f[d++],l[u]);return c}},function(r,o,t){var i=t(55),s=t(17),a=t(13),c=t(32),l=t(8),u=t(26),f=Object.getOwnPropertyDescriptor;o.f=t(4)?f:function(p,d){if(p=a(p),d=c(d,!0),u)try{return f(p,d)}catch{}if(l(p,d))return s(!i.f.call(p,d),p[d])}},function(r,o,t){var i=t(8),s=t(63),a=t(19)("IE_PROTO"),c=Object.prototype;r.exports=Object.getPrototypeOf||function(l){return l=s(l),i(l,a)?l[a]:typeof l.constructor=="function"&&l instanceof l.constructor?l.constructor.prototype:l instanceof Object?c:null}},function(r,o,t){var i=t(8),s=t(13),a=t(39)(!1),c=t(19)("IE_PROTO");r.exports=function(l,u){var f,p=s(l),d=0,h=[];for(f in p)f!=c&&i(p,f)&&h.push(f);for(;u.length>d;)i(p,f=u[d++])&&(~a(h,f)||h.push(f));return h}},function(r,o,t){var i=t(53),s=t(22);r.exports=Object.keys||function(a){return i(a,s)}},function(r,o){o.f={}.propertyIsEnumerable},function(r,o,t){var i=t(5);r.exports=function(s,a,c){for(var l in a)c&&s[l]?s[l]=a[l]:i(s,l,a[l]);return s}},function(r,o,t){r.exports=t(5)},function(r,o,t){var i=t(9),s=t(3),a=function(c,l){if(s(c),!i(l)&&l!==null)throw TypeError(l+": can't set as prototype!")};r.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(c,l,u){try{u=t(7)(Function.call,t(51).f(Object.prototype,"__proto__").set,2),u(c,[]),l=!(c instanceof Array)}catch{l=!0}return function(f,p){return a(f,p),l?f.__proto__=p:u(f,p),f}})({},!1):void 0),check:a}},function(r,o,t){"use strict";var i=t(2),s=t(6),a=t(12),c=t(4),l=t(1)("species");r.exports=function(u){var f=typeof s[u]=="function"?s[u]:i[u];c&&f&&!f[l]&&a.f(f,l,{configurable:!0,get:function(){return this}})}},function(r,o,t){var i=t(3),s=t(14),a=t(1)("species");r.exports=function(c,l){var u,f=i(c).constructor;return f===void 0||(u=i(f)[a])==null?l:s(u)}},function(r,o,t){var i=t(20),s=t(15);r.exports=function(a){return function(c,l){var u,f,p=String(s(c)),d=i(l),h=p.length;return d<0||d>=h?a?"":void 0:(u=p.charCodeAt(d),u<55296||u>56319||d+1===h||(f=p.charCodeAt(d+1))<56320||f>57343?a?p.charAt(d):u:a?p.slice(d,d+2):(u-55296<<10)+(f-56320)+65536)}}},function(r,o,t){var i=t(20),s=Math.max,a=Math.min;r.exports=function(c,l){return c=i(c),c<0?s(c+l,0):a(c,l)}},function(r,o,t){var i=t(15);r.exports=function(s){return Object(i(s))}},function(r,o,t){var i=t(21),s=t(1)("iterator"),a=t(10);r.exports=t(6).getIteratorMethod=function(c){if(c!=null)return c[s]||c["@@iterator"]||a[i(c)]}},function(r,o,t){"use strict";var i=t(37),s=t(47),a=t(10),c=t(13);r.exports=t(27)(Array,"Array",function(l,u){this._t=c(l),this._i=0,this._k=u},function(){var l=this._t,u=this._k,f=this._i++;return!l||f>=l.length?(this._t=void 0,s(1)):u=="keys"?s(0,f):u=="values"?s(0,l[f]):s(0,[f,l[f]])},"values"),a.Arguments=a.Array,i("keys"),i("values"),i("entries")},function(r,o){},function(r,o,t){"use strict";var i,s,a,c=t(28),l=t(2),u=t(7),f=t(21),p=t(23),d=t(9),h=(t(3),t(14)),w=t(38),T=t(40),P=(t(58).set,t(60)),x=t(30).set,b=t(48)(),k="Promise",S=l.TypeError,_=l.process,g=l[k],_=l.process,O=f(_)=="process",F=function(){},j=!!(function(){try{var y=g.resolve(1),v=(y.constructor={})[t(1)("species")]=function(R){R(F,F)};return(O||typeof PromiseRejectionEvent=="function")&&y.then(F)instanceof v}catch{}})(),de=function(y,v){return y===v||y===g&&v===a},me=function(y){var v;return!(!d(y)||typeof(v=y.then)!="function")&&v},ee=function(y){return de(g,y)?new _e(y):new s(y)},_e=s=function(y){var v,R;this.promise=new y(function(L,q){if(v!==void 0||R!==void 0)throw S("Bad Promise constructor");v=L,R=q}),this.resolve=h(v),this.reject=h(R)},gt=function(y){try{y()}catch(v){return{error:v}}},tt=function(y,v){if(!y._n){y._n=!0;var R=y._c;b(function(){for(var L=y._v,q=y._s==1,nt=0,yt=function(De){var ve,_n,Wt=q?De.ok:De.fail,Vt=De.resolve,wt=De.reject,Pn=De.domain;try{Wt?(q||(y._h==2&&Ne(y),y._h=1),Wt===!0?ve=L:(Pn&&Pn.enter(),ve=Wt(L),Pn&&Pn.exit()),ve===De.promise?wt(S("Promise-chain cycle")):(_n=me(ve))?_n.call(ve,Vt,wt):Vt(ve)):wt(L)}catch(Ws){wt(Ws)}};R.length>nt;)yt(R[nt++]);y._c=[],y._n=!1,v&&!y._h&&Kt(y)})}},Kt=function(y){x.call(l,function(){var v,R,L,q=y._v;if(te(y)&&(v=gt(function(){O?_.emit("unhandledRejection",q,y):(R=l.onunhandledrejection)?R({promise:y,reason:q}):(L=l.console)&&L.error&&L.error("Unhandled promise rejection",q)}),y._h=O||te(y)?2:1),y._a=void 0,v)throw v.error})},te=function(y){if(y._h==1)return!1;for(var v,R=y._a||y._c,L=0;R.length>L;)if(v=R[L++],v.fail||!te(v.promise))return!1;return!0},Ne=function(y){x.call(l,function(){var v;O?_.emit("rejectionHandled",y):(v=l.onrejectionhandled)&&v({promise:y,reason:y._v})})},se=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))},Gt=function(y){var v,R=this;if(!R._d){R._d=!0,R=R._w||R;try{if(R===y)throw S("Promise can't be resolved itself");(v=me(y))?b(function(){var L={_w:R,_d:!1};try{v.call(y,u(Gt,L,1),u(se,L,1))}catch(q){se.call(L,q)}}):(R._v=y,R._s=1,tt(R,!1))}catch(L){se.call({_w:R,_d:!1},L)}}};j||(g=function(y){w(this,g,k,"_h"),h(y),i.call(this);try{y(u(Gt,this,1),u(se,this,1))}catch(v){se.call(this,v)}},i=function(y){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},i.prototype=t(56)(g.prototype,{then:function(y,v){var R=ee(P(this,g));return R.ok=typeof y!="function"||y,R.fail=typeof v=="function"&&v,R.domain=O?_.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)}}),_e=function(){var y=new i;this.promise=y,this.resolve=u(Gt,y,1),this.reject=u(se,y,1)}),p(p.G+p.W+p.F*!j,{Promise:g}),t(18)(g,k),t(59)(k),a=t(6)[k],p(p.S+p.F*!j,k,{reject:function(y){var v=ee(this),R=v.reject;return R(y),v.promise}}),p(p.S+p.F*(c||!j),k,{resolve:function(y){if(y instanceof g&&de(y.constructor,this))return y;var v=ee(this),R=v.resolve;return R(y),v.promise}}),p(p.S+p.F*!(j&&t(46)(function(y){g.all(y).catch(F)})),k,{all:function(y){var v=this,R=ee(v),L=R.resolve,q=R.reject,nt=gt(function(){var yt=[],De=0,ve=1;T(y,!1,function(_n){var Wt=De++,Vt=!1;yt.push(void 0),ve++,v.resolve(_n).then(function(wt){Vt||(Vt=!0,yt[Wt]=wt,--ve||L(yt))},q)}),--ve||L(yt)});return nt&&q(nt.error),R.promise},race:function(y){var v=this,R=ee(v),L=R.reject,q=gt(function(){T(y,!1,function(nt){v.resolve(nt).then(R.resolve,L)})});return q&&L(q.error),R.promise}})},function(r,o,t){"use strict";var i=t(61)(!0);t(27)(String,"String",function(s){this._t=String(s),this._i=0},function(){var s,a=this._t,c=this._i;return c>=a.length?{value:void 0,done:!0}:(s=i(a,c),this._i+=s.length,{value:s,done:!1})})},function(r,o,t){t(65);for(var i=t(2),s=t(5),a=t(10),c=t(1)("toStringTag"),l=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var f=l[u],p=i[f],d=p&&p.prototype;d&&!d[c]&&s(d,c,f),a[f]=a.Array}},function(r,o){r.exports=require("child_process")},function(r,o){r.exports=require("crypto")}])})});var zi={};Zs(zi,{initTray:()=>Jr,killTray:()=>Sn,openBrowser:()=>En,showTrayNotification:()=>Qr,updateTrayTooltip:()=>sr});function Wi(e){for(let n of e)try{if(Dt.default.existsSync(n))return n}catch{}return null}function Sc(){if(process.platform==="win32"){for(let e of Qi)try{if(Dt.default.existsSync(e))return Dt.default.readFileSync(e).toString("base64")}catch{}return Gi}return Gi}function Ec(){let e=process.platform;return!(!["darwin","win32","linux"].includes(e)||e==="linux"&&!process.env.DISPLAY)}function Xi(){let{port:e,tunnelUrl:n,running:r}=Ft,o=r?n?"Tunnel ON":"Local only":"Idle",t=`http://localhost:${e}`;return`9Remote \u2022 ${o}
|
|
3
|
+
var Js=Object.create;var fr=Object.defineProperty;var Qs=Object.getOwnPropertyDescriptor;var Xs=Object.getOwnPropertyNames;var Zs=Object.getPrototypeOf,zs=Object.prototype.hasOwnProperty;var ea=(e,n)=>()=>(e&&(n=e(e=0)),n);var ae=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),ta=(e,n)=>{for(var r in n)fr(e,r,{get:n[r],enumerable:!0})},na=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of Xs(n))!zs.call(e,t)&&t!==r&&fr(e,t,{get:()=>n[t],enumerable:!(o=Qs(n,t))||o.enumerable});return e};var A=(e,n,r)=>(r=e!=null?Js(Zs(e)):{},na(n||!e||!e.__esModule?fr(r,"default",{value:e,enumerable:!0}):r,e));var So=ae((Qt,mr)=>{(function(e,n){typeof Qt=="object"&&typeof mr=="object"?mr.exports=n(require("child_process"),require("crypto")):typeof define=="function"&&define.amd?define(["child_process","crypto"],n):typeof Qt=="object"?Qt["electron-machine-id"]=n(require("child_process"),require("crypto")):e["electron-machine-id"]=n(e.child_process,e.crypto)})(Qt,function(e,n){return(function(r){function o(i){if(t[i])return t[i].exports;var s=t[i]={exports:{},id:i,loaded:!1};return r[i].call(s.exports,s,s.exports,o),s.loaded=!0,s.exports}var t={};return o.m=r,o.c=t,o.p="",o(0)})([function(r,o,t){r.exports=t(34)},function(r,o,t){var i=t(29)("wks"),s=t(33),a=t(2).Symbol,c=typeof a=="function",l=r.exports=function(u){return i[u]||(i[u]=c&&a[u]||(c?a:s)("Symbol."+u))};l.store=i},function(r,o){var t=r.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=t)},function(r,o,t){var i=t(9);r.exports=function(s){if(!i(s))throw TypeError(s+" is not an object!");return s}},function(r,o,t){r.exports=!t(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(r,o,t){var i=t(12),s=t(17);r.exports=t(4)?function(a,c,l){return i.f(a,c,s(1,l))}:function(a,c,l){return a[c]=l,a}},function(r,o){var t=r.exports={version:"2.4.0"};typeof __e=="number"&&(__e=t)},function(r,o,t){var i=t(14);r.exports=function(s,a,c){if(i(s),a===void 0)return s;switch(c){case 1:return function(l){return s.call(a,l)};case 2:return function(l,u){return s.call(a,l,u)};case 3:return function(l,u,f){return s.call(a,l,u,f)}}return function(){return s.apply(a,arguments)}}},function(r,o){var t={}.hasOwnProperty;r.exports=function(i,s){return t.call(i,s)}},function(r,o){r.exports=function(t){return typeof t=="object"?t!==null:typeof t=="function"}},function(r,o){r.exports={}},function(r,o){var t={}.toString;r.exports=function(i){return t.call(i).slice(8,-1)}},function(r,o,t){var i=t(3),s=t(26),a=t(32),c=Object.defineProperty;o.f=t(4)?Object.defineProperty:function(l,u,f){if(i(l),u=a(u,!0),i(f),s)try{return c(l,u,f)}catch{}if("get"in f||"set"in f)throw TypeError("Accessors not supported!");return"value"in f&&(l[u]=f.value),l}},function(r,o,t){var i=t(42),s=t(15);r.exports=function(a){return i(s(a))}},function(r,o){r.exports=function(t){if(typeof t!="function")throw TypeError(t+" is not a function!");return t}},function(r,o){r.exports=function(t){if(t==null)throw TypeError("Can't call method on "+t);return t}},function(r,o,t){var i=t(9),s=t(2).document,a=i(s)&&i(s.createElement);r.exports=function(c){return a?s.createElement(c):{}}},function(r,o){r.exports=function(t,i){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:i}}},function(r,o,t){var i=t(12).f,s=t(8),a=t(1)("toStringTag");r.exports=function(c,l,u){c&&!s(c=u?c:c.prototype,a)&&i(c,a,{configurable:!0,value:l})}},function(r,o,t){var i=t(29)("keys"),s=t(33);r.exports=function(a){return i[a]||(i[a]=s(a))}},function(r,o){var t=Math.ceil,i=Math.floor;r.exports=function(s){return isNaN(s=+s)?0:(s>0?i:t)(s)}},function(r,o,t){var i=t(11),s=t(1)("toStringTag"),a=i((function(){return arguments})())=="Arguments",c=function(l,u){try{return l[u]}catch{}};r.exports=function(l){var u,f,p;return l===void 0?"Undefined":l===null?"Null":typeof(f=c(u=Object(l),s))=="string"?f:a?i(u):(p=i(u))=="Object"&&typeof u.callee=="function"?"Arguments":p}},function(r,o){r.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(r,o,t){var i=t(2),s=t(6),a=t(7),c=t(5),l="prototype",u=function(f,p,d){var h,w,S,O=f&u.F,x=f&u.G,b=f&u.S,k=f&u.P,E=f&u.B,g=f&u.W,_=x?s:s[p]||(s[p]={}),I=_[l],F=x?i:b?i[p]:(i[p]||{})[l];x&&(d=p);for(h in d)w=!O&&F&&F[h]!==void 0,w&&h in _||(S=w?F[h]:d[h],_[h]=x&&typeof F[h]!="function"?d[h]:E&&w?a(S,i):g&&F[h]==S?(function(j){var de=function(me,z,Pe){if(this instanceof j){switch(arguments.length){case 0:return new j;case 1:return new j(me);case 2:return new j(me,z)}return new j(me,z,Pe)}return j.apply(this,arguments)};return de[l]=j[l],de})(S):k&&typeof S=="function"?a(Function.call,S):S,k&&((_.virtual||(_.virtual={}))[h]=S,f&u.R&&I&&!I[h]&&c(I,h,S)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,r.exports=u},function(r,o){r.exports=function(t){try{return!!t()}catch{return!0}}},function(r,o,t){r.exports=t(2).document&&document.documentElement},function(r,o,t){r.exports=!t(4)&&!t(24)(function(){return Object.defineProperty(t(16)("div"),"a",{get:function(){return 7}}).a!=7})},function(r,o,t){"use strict";var i=t(28),s=t(23),a=t(57),c=t(5),l=t(8),u=t(10),f=t(45),p=t(18),d=t(52),h=t(1)("iterator"),w=!([].keys&&"next"in[].keys()),S="@@iterator",O="keys",x="values",b=function(){return this};r.exports=function(k,E,g,_,I,F,j){f(g,E,_);var de,me,z,Pe=function(v){if(!w&&v in ee)return ee[v];switch(v){case O:return function(){return new g(this,v)};case x:return function(){return new g(this,v)}}return function(){return new g(this,v)}},yt=E+" Iterator",nt=I==x,Gt=!1,ee=k.prototype,De=ee[h]||ee[S]||I&&ee[I],ie=De||Pe(I),Wt=I?nt?Pe("entries"):ie:void 0,y=E=="Array"&&ee.entries||De;if(y&&(z=d(y.call(new k)),z!==Object.prototype&&(p(z,yt,!0),i||l(z,h)||c(z,h,b))),nt&&De&&De.name!==x&&(Gt=!0,ie=function(){return De.call(this)}),i&&!j||!w&&!Gt&&ee[h]||c(ee,h,ie),u[E]=ie,u[yt]=b,I)if(de={values:nt?ie:Pe(x),keys:F?ie:Pe(O),entries:Wt},j)for(me in de)me in ee||a(ee,me,de[me]);else s(s.P+s.F*(w||Gt),E,de);return de}},function(r,o){r.exports=!0},function(r,o,t){var i=t(2),s="__core-js_shared__",a=i[s]||(i[s]={});r.exports=function(c){return a[c]||(a[c]={})}},function(r,o,t){var i,s,a,c=t(7),l=t(41),u=t(25),f=t(16),p=t(2),d=p.process,h=p.setImmediate,w=p.clearImmediate,S=p.MessageChannel,O=0,x={},b="onreadystatechange",k=function(){var g=+this;if(x.hasOwnProperty(g)){var _=x[g];delete x[g],_()}},E=function(g){k.call(g.data)};h&&w||(h=function(g){for(var _=[],I=1;arguments.length>I;)_.push(arguments[I++]);return x[++O]=function(){l(typeof g=="function"?g:Function(g),_)},i(O),O},w=function(g){delete x[g]},t(11)(d)=="process"?i=function(g){d.nextTick(c(k,g,1))}:S?(s=new S,a=s.port2,s.port1.onmessage=E,i=c(a.postMessage,a,1)):p.addEventListener&&typeof postMessage=="function"&&!p.importScripts?(i=function(g){p.postMessage(g+"","*")},p.addEventListener("message",E,!1)):i=b in f("script")?function(g){u.appendChild(f("script"))[b]=function(){u.removeChild(this),k.call(g)}}:function(g){setTimeout(c(k,g,1),0)}),r.exports={set:h,clear:w}},function(r,o,t){var i=t(20),s=Math.min;r.exports=function(a){return a>0?s(i(a),9007199254740991):0}},function(r,o,t){var i=t(9);r.exports=function(s,a){if(!i(s))return s;var c,l;if(a&&typeof(c=s.toString)=="function"&&!i(l=c.call(s))||typeof(c=s.valueOf)=="function"&&!i(l=c.call(s))||!a&&typeof(c=s.toString)=="function"&&!i(l=c.call(s)))return l;throw TypeError("Can't convert object to primitive value")}},function(r,o){var t=0,i=Math.random();r.exports=function(s){return"Symbol(".concat(s===void 0?"":s,")_",(++t+i).toString(36))}},function(r,o,t){"use strict";function i(b){return b&&b.__esModule?b:{default:b}}function s(){return process.platform!=="win32"?"":process.arch==="ia32"&&process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")?"mixed":"native"}function a(b){return(0,h.createHash)("sha256").update(b).digest("hex")}function c(b){switch(S){case"darwin":return b.split("IOPlatformUUID")[1].split(`
|
|
4
|
+
`)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return b.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return b.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return b.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function l(b){var k=c((0,d.execSync)(x[S]).toString());return b?k:a(k)}function u(b){return new p.default(function(k,E){return(0,d.exec)(x[S],{},function(g,_,I){if(g)return E(new Error("Error while obtaining machine id: "+g.stack));var F=c(_.toString());return k(b?F:a(F))})})}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,S=w.platform,O={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},x={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:O[s()]+"\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid",linux:"( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :",freebsd:"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid"}},function(r,o,t){r.exports={default:t(36),__esModule:!0}},function(r,o,t){t(66),t(68),t(69),t(67),r.exports=t(6).Promise},function(r,o){r.exports=function(){}},function(r,o){r.exports=function(t,i,s,a){if(!(t instanceof i)||a!==void 0&&a in t)throw TypeError(s+": incorrect invocation!");return t}},function(r,o,t){var i=t(13),s=t(31),a=t(62);r.exports=function(c){return function(l,u,f){var p,d=i(l),h=s(d.length),w=a(f,h);if(c&&u!=u){for(;h>w;)if(p=d[w++],p!=p)return!0}else for(;h>w;w++)if((c||w in d)&&d[w]===u)return c||w||0;return!c&&-1}}},function(r,d,t){var i=t(7),s=t(44),a=t(43),c=t(3),l=t(31),u=t(64),f={},p={},d=r.exports=function(h,w,S,O,x){var b,k,E,g,_=x?function(){return h}:u(h),I=i(S,O,w?2:1),F=0;if(typeof _!="function")throw TypeError(h+" is not iterable!");if(a(_)){for(b=l(h.length);b>F;F++)if(g=w?I(c(k=h[F])[0],k[1]):I(h[F]),g===f||g===p)return g}else for(E=_.call(h);!(k=E.next()).done;)if(g=s(E,I,k.value,w),g===f||g===p)return g};d.BREAK=f,d.RETURN=p},function(r,o){r.exports=function(t,i,s){var a=s===void 0;switch(i.length){case 0:return a?t():t.call(s);case 1:return a?t(i[0]):t.call(s,i[0]);case 2:return a?t(i[0],i[1]):t.call(s,i[0],i[1]);case 3:return a?t(i[0],i[1],i[2]):t.call(s,i[0],i[1],i[2]);case 4:return a?t(i[0],i[1],i[2],i[3]):t.call(s,i[0],i[1],i[2],i[3])}return t.apply(s,i)}},function(r,o,t){var i=t(11);r.exports=Object("z").propertyIsEnumerable(0)?Object:function(s){return i(s)=="String"?s.split(""):Object(s)}},function(r,o,t){var i=t(10),s=t(1)("iterator"),a=Array.prototype;r.exports=function(c){return c!==void 0&&(i.Array===c||a[s]===c)}},function(r,o,t){var i=t(3);r.exports=function(s,a,c,l){try{return l?a(i(c)[0],c[1]):a(c)}catch(f){var u=s.return;throw u!==void 0&&i(u.call(s)),f}}},function(r,o,t){"use strict";var i=t(49),s=t(17),a=t(18),c={};t(5)(c,t(1)("iterator"),function(){return this}),r.exports=function(l,u,f){l.prototype=i(c,{next:s(1,f)}),a(l,u+" Iterator")}},function(r,o,t){var i=t(1)("iterator"),s=!1;try{var a=[7][i]();a.return=function(){s=!0},Array.from(a,function(){throw 2})}catch{}r.exports=function(c,l){if(!l&&!s)return!1;var u=!1;try{var f=[7],p=f[i]();p.next=function(){return{done:u=!0}},f[i]=function(){return p},c(f)}catch{}return u}},function(r,o){r.exports=function(t,i){return{value:i,done:!!t}}},function(r,o,t){var i=t(2),s=t(30).set,a=i.MutationObserver||i.WebKitMutationObserver,c=i.process,l=i.Promise,u=t(11)(c)=="process";r.exports=function(){var f,p,d,h=function(){var x,b;for(u&&(x=c.domain)&&x.exit();f;){b=f.fn,f=f.next;try{b()}catch(k){throw f?d():p=void 0,k}}p=void 0,x&&x.enter()};if(u)d=function(){c.nextTick(h)};else if(a){var w=!0,S=document.createTextNode("");new a(h).observe(S,{characterData:!0}),d=function(){S.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(x){var b={fn:x,next:void 0};p&&(p.next=b),f||(f=b,d()),p=b}}},function(r,o,t){var i=t(3),s=t(50),a=t(22),c=t(19)("IE_PROTO"),l=function(){},u="prototype",f=function(){var p,d=t(16)("iframe"),h=a.length,w=">";for(d.style.display="none",t(25).appendChild(d),d.src="javascript:",p=d.contentWindow.document,p.open(),p.write("<script>document.F=Object</script"+w),p.close(),f=p.F;h--;)delete f[u][a[h]];return f()};r.exports=Object.create||function(p,d){var h;return p!==null?(l[u]=i(p),h=new l,l[u]=null,h[c]=p):h=f(),d===void 0?h:s(h,d)}},function(r,o,t){var i=t(12),s=t(3),a=t(54);r.exports=t(4)?Object.defineProperties:function(c,l){s(c);for(var u,f=a(l),p=f.length,d=0;p>d;)i.f(c,u=f[d++],l[u]);return c}},function(r,o,t){var i=t(55),s=t(17),a=t(13),c=t(32),l=t(8),u=t(26),f=Object.getOwnPropertyDescriptor;o.f=t(4)?f:function(p,d){if(p=a(p),d=c(d,!0),u)try{return f(p,d)}catch{}if(l(p,d))return s(!i.f.call(p,d),p[d])}},function(r,o,t){var i=t(8),s=t(63),a=t(19)("IE_PROTO"),c=Object.prototype;r.exports=Object.getPrototypeOf||function(l){return l=s(l),i(l,a)?l[a]:typeof l.constructor=="function"&&l instanceof l.constructor?l.constructor.prototype:l instanceof Object?c:null}},function(r,o,t){var i=t(8),s=t(13),a=t(39)(!1),c=t(19)("IE_PROTO");r.exports=function(l,u){var f,p=s(l),d=0,h=[];for(f in p)f!=c&&i(p,f)&&h.push(f);for(;u.length>d;)i(p,f=u[d++])&&(~a(h,f)||h.push(f));return h}},function(r,o,t){var i=t(53),s=t(22);r.exports=Object.keys||function(a){return i(a,s)}},function(r,o){o.f={}.propertyIsEnumerable},function(r,o,t){var i=t(5);r.exports=function(s,a,c){for(var l in a)c&&s[l]?s[l]=a[l]:i(s,l,a[l]);return s}},function(r,o,t){r.exports=t(5)},function(r,o,t){var i=t(9),s=t(3),a=function(c,l){if(s(c),!i(l)&&l!==null)throw TypeError(l+": can't set as prototype!")};r.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(c,l,u){try{u=t(7)(Function.call,t(51).f(Object.prototype,"__proto__").set,2),u(c,[]),l=!(c instanceof Array)}catch{l=!0}return function(f,p){return a(f,p),l?f.__proto__=p:u(f,p),f}})({},!1):void 0),check:a}},function(r,o,t){"use strict";var i=t(2),s=t(6),a=t(12),c=t(4),l=t(1)("species");r.exports=function(u){var f=typeof s[u]=="function"?s[u]:i[u];c&&f&&!f[l]&&a.f(f,l,{configurable:!0,get:function(){return this}})}},function(r,o,t){var i=t(3),s=t(14),a=t(1)("species");r.exports=function(c,l){var u,f=i(c).constructor;return f===void 0||(u=i(f)[a])==null?l:s(u)}},function(r,o,t){var i=t(20),s=t(15);r.exports=function(a){return function(c,l){var u,f,p=String(s(c)),d=i(l),h=p.length;return d<0||d>=h?a?"":void 0:(u=p.charCodeAt(d),u<55296||u>56319||d+1===h||(f=p.charCodeAt(d+1))<56320||f>57343?a?p.charAt(d):u:a?p.slice(d,d+2):(u-55296<<10)+(f-56320)+65536)}}},function(r,o,t){var i=t(20),s=Math.max,a=Math.min;r.exports=function(c,l){return c=i(c),c<0?s(c+l,0):a(c,l)}},function(r,o,t){var i=t(15);r.exports=function(s){return Object(i(s))}},function(r,o,t){var i=t(21),s=t(1)("iterator"),a=t(10);r.exports=t(6).getIteratorMethod=function(c){if(c!=null)return c[s]||c["@@iterator"]||a[i(c)]}},function(r,o,t){"use strict";var i=t(37),s=t(47),a=t(10),c=t(13);r.exports=t(27)(Array,"Array",function(l,u){this._t=c(l),this._i=0,this._k=u},function(){var l=this._t,u=this._k,f=this._i++;return!l||f>=l.length?(this._t=void 0,s(1)):u=="keys"?s(0,f):u=="values"?s(0,l[f]):s(0,[f,l[f]])},"values"),a.Arguments=a.Array,i("keys"),i("values"),i("entries")},function(r,o){},function(r,o,t){"use strict";var i,s,a,c=t(28),l=t(2),u=t(7),f=t(21),p=t(23),d=t(9),h=(t(3),t(14)),w=t(38),S=t(40),O=(t(58).set,t(60)),x=t(30).set,b=t(48)(),k="Promise",E=l.TypeError,_=l.process,g=l[k],_=l.process,I=f(_)=="process",F=function(){},j=!!(function(){try{var y=g.resolve(1),v=(y.constructor={})[t(1)("species")]=function(R){R(F,F)};return(I||typeof PromiseRejectionEvent=="function")&&y.then(F)instanceof v}catch{}})(),de=function(y,v){return y===v||y===g&&v===a},me=function(y){var v;return!(!d(y)||typeof(v=y.then)!="function")&&v},z=function(y){return de(g,y)?new Pe(y):new s(y)},Pe=s=function(y){var v,R;this.promise=new y(function(L,q){if(v!==void 0||R!==void 0)throw E("Bad Promise constructor");v=L,R=q}),this.resolve=h(v),this.reject=h(R)},yt=function(y){try{y()}catch(v){return{error:v}}},nt=function(y,v){if(!y._n){y._n=!0;var R=y._c;b(function(){for(var L=y._v,q=y._s==1,rt=0,wt=function(Fe){var ve,_n,Vt=q?Fe.ok:Fe.fail,Yt=Fe.resolve,vt=Fe.reject,Pn=Fe.domain;try{Vt?(q||(y._h==2&&De(y),y._h=1),Vt===!0?ve=L:(Pn&&Pn.enter(),ve=Vt(L),Pn&&Pn.exit()),ve===Fe.promise?vt(E("Promise-chain cycle")):(_n=me(ve))?_n.call(ve,Yt,vt):Yt(ve)):vt(L)}catch(qs){vt(qs)}};R.length>rt;)wt(R[rt++]);y._c=[],y._n=!1,v&&!y._h&&Gt(y)})}},Gt=function(y){x.call(l,function(){var v,R,L,q=y._v;if(ee(y)&&(v=yt(function(){I?_.emit("unhandledRejection",q,y):(R=l.onunhandledrejection)?R({promise:y,reason:q}):(L=l.console)&&L.error&&L.error("Unhandled promise rejection",q)}),y._h=I||ee(y)?2:1),y._a=void 0,v)throw v.error})},ee=function(y){if(y._h==1)return!1;for(var v,R=y._a||y._c,L=0;R.length>L;)if(v=R[L++],v.fail||!ee(v.promise))return!1;return!0},De=function(y){x.call(l,function(){var v;I?_.emit("rejectionHandled",y):(v=l.onrejectionhandled)&&v({promise:y,reason:y._v})})},ie=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()),nt(v,!0))},Wt=function(y){var v,R=this;if(!R._d){R._d=!0,R=R._w||R;try{if(R===y)throw E("Promise can't be resolved itself");(v=me(y))?b(function(){var L={_w:R,_d:!1};try{v.call(y,u(Wt,L,1),u(ie,L,1))}catch(q){ie.call(L,q)}}):(R._v=y,R._s=1,nt(R,!1))}catch(L){ie.call({_w:R,_d:!1},L)}}};j||(g=function(y){w(this,g,k,"_h"),h(y),i.call(this);try{y(u(Wt,this,1),u(ie,this,1))}catch(v){ie.call(this,v)}},i=function(y){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},i.prototype=t(56)(g.prototype,{then:function(y,v){var R=z(O(this,g));return R.ok=typeof y!="function"||y,R.fail=typeof v=="function"&&v,R.domain=I?_.domain:void 0,this._c.push(R),this._a&&this._a.push(R),this._s&&nt(this,!1),R.promise},catch:function(y){return this.then(void 0,y)}}),Pe=function(){var y=new i;this.promise=y,this.resolve=u(Wt,y,1),this.reject=u(ie,y,1)}),p(p.G+p.W+p.F*!j,{Promise:g}),t(18)(g,k),t(59)(k),a=t(6)[k],p(p.S+p.F*!j,k,{reject:function(y){var v=z(this),R=v.reject;return R(y),v.promise}}),p(p.S+p.F*(c||!j),k,{resolve:function(y){if(y instanceof g&&de(y.constructor,this))return y;var v=z(this),R=v.resolve;return R(y),v.promise}}),p(p.S+p.F*!(j&&t(46)(function(y){g.all(y).catch(F)})),k,{all:function(y){var v=this,R=z(v),L=R.resolve,q=R.reject,rt=yt(function(){var wt=[],Fe=0,ve=1;S(y,!1,function(_n){var Vt=Fe++,Yt=!1;wt.push(void 0),ve++,v.resolve(_n).then(function(vt){Yt||(Yt=!0,wt[Vt]=vt,--ve||L(wt))},q)}),--ve||L(wt)});return rt&&q(rt.error),R.promise},race:function(y){var v=this,R=z(v),L=R.reject,q=yt(function(){S(y,!1,function(rt){v.resolve(rt).then(R.resolve,L)})});return q&&L(q.error),R.promise}})},function(r,o,t){"use strict";var i=t(61)(!0);t(27)(String,"String",function(s){this._t=String(s),this._i=0},function(){var s,a=this._t,c=this._i;return c>=a.length?{value:void 0,done:!0}:(s=i(a,c),this._i+=s.length,{value:s,done:!1})})},function(r,o,t){t(65);for(var i=t(2),s=t(5),a=t(10),c=t(1)("toStringTag"),l=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var f=l[u],p=i[f],d=p&&p.prototype;d&&!d[c]&&s(d,c,f),a[f]=a.Array}},function(r,o){r.exports=require("child_process")},function(r,o){r.exports=require("crypto")}])})});var ts={};ta(ts,{initTray:()=>qr,killTray:()=>En,openBrowser:()=>Tn,showTrayNotification:()=>Jr,updateTrayTooltip:()=>ir});function Yi(e){for(let n of e)try{if(Ft.default.existsSync(n))return n}catch{}return null}function bc(){if(process.platform==="win32"){for(let e of Zi)try{if(Ft.default.existsSync(e))return Ft.default.readFileSync(e).toString("base64")}catch{}return Vi}return Vi}function Ac(){let e=process.platform;return!(!["darwin","win32","linux"].includes(e)||e==="linux"&&!process.env.DISPLAY)}function zi(){let{port:e,tunnelUrl:n,running:r}=Ut,o=r?n?"Tunnel ON":"Local only":"Idle",t=`http://localhost:${e}`;return`9Remote \u2022 ${o}
|
|
5
5
|
Local: ${t}
|
|
6
|
-
Right-click to open / quit`}function
|
|
7
|
-
`,"utf8")}catch{}};return Vi.default.createInterface({input:i.stdout}).on("line",c=>{try{let l=JSON.parse(c);if(l.type!=="click")return;l.index===0?r?.():l.index===1&&(n?.(),Sn(),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 Jr({port:e,onQuit:n,onOpenUI:r}){if(!Ec())return null;if(process.platform==="win32")return Ft={port:e,tunnelUrl:"",running:!0},z=xc({port:e,onQuit:n,onOpenUI:r}),z;try{let o=Tc();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=Re.default.join(Ji,"systray2","traybin",i);if(!Dt.default.existsSync(s))return null;if(process.platform!=="win32")try{Dt.default.chmodSync(s,493)}catch{}return Ft={port:e,tunnelUrl:"",running:!0},z=new o({menu:Zi(),debug:!1,copyDir:!0}),z.onClick(a=>{let c=a.item?.title||a.item;c==="Open Web UI"?r?.():c==="Shutdown"&&(n?.(),Sn(),setTimeout(()=>process.exit(0),500))}),typeof z.ready=="function"?z.ready().catch(()=>{}):(z.onReady(()=>{}),z.onError(()=>{})),z}catch{return null}}function sr({tunnelUrl:e,running:n}={}){if(e!==void 0&&(Ft.tunnelUrl=e),n!==void 0&&(Ft.running=n),!!z){if(z._isWin){z._setTooltip?.(Xi());return}try{z.sendAction({type:"update-menu",menu:Zi(),seq_id:-1})}catch{}}}function Sn(){let e=z;if(z=null,e)try{e.kill(!0)}catch{}}function Qr({title:e="9Remote",message:n}){let r=process.platform;if(n){if(r==="win32"){let o=c=>String(c).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,"""),t=c=>String(c).replace(/'/g,"''"),i="9Remote",s=`<toast><visual><binding template="ToastText02"><text id="1">${o(e)}</text><text id="2">${o(n)}</text></binding></visual></toast>`,a=["try {","[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType=WindowsRuntime] > $null;","[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType=WindowsRuntime] > $null;","$xml = New-Object Windows.Data.Xml.Dom.XmlDocument;",`$xml.LoadXml('${t(s)}');`,"$toast = [Windows.UI.Notifications.ToastNotification]::new($xml);",`[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('${t(i)}').Show($toast);`,"} catch {","Add-Type -AssemblyName System.Windows.Forms;","$n = New-Object System.Windows.Forms.NotifyIcon;","$n.Icon = [System.Drawing.SystemIcons]::Information;",`$n.BalloonTipTitle = '${t(e)}';`,`$n.BalloonTipText = '${t(n)}';`,"$n.Visible = $true;","$n.ShowBalloonTip(5000);","Start-Sleep -Seconds 6;","$n.Dispose();","}"].join(" ");try{(0,Le.spawn)("powershell.exe",["-NoProfile","-WindowStyle","Hidden","-Command",a],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(r==="darwin"){try{let o=s=>String(s).replace(/"/g,'\\"'),t=`display notification "${o(n)}" with title "${o(e)}"`;(0,Le.spawn)("osascript",["-e",t],{detached:!0,stdio:"ignore"}).unref()}catch{}return}try{(0,Le.spawn)("notify-send",[e,n],{detached:!0,stdio:"ignore"}).unref()}catch{}}}function En(e){let n=process.platform;if(n==="win32"){try{(0,Le.spawn)("rundll32.exe",["url.dll,FileProtocolHandler",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref();return}catch{}try{(0,Le.spawn)("cmd.exe",["/d","/s","/c","start","",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(n==="darwin"){try{(0,Le.spawn)("open",[e],{detached:!0,stdio:"ignore"}).unref()}catch{}return}let r=[["setsid",["--fork","xdg-open",e]],["setsid",["xdg-open",e]],["xdg-open",[e]],["gio",["open",e]],["sensible-browser",[e]],["x-www-browser",[e]]];for(let[o,t]of r)try{(0,Le.spawn)(o,t,{detached:!0,stdio:"ignore",env:{...process.env}}).unref();return}catch{}}var Le,Vi,Dt,Re,Yi,qi,Ji,z,Ft,ir,Gi,Qi,vc,Ut=Xs(()=>{Le=require("child_process"),Vi=A(require("readline"),1),Dt=A(require("fs"),1),Re=A(require("path"),1),Yi=A(require("os"),1),qi=require("url"),Ji=(0,Re.join)(Yi.default.homedir(),".9remote","runtime","node_modules"),z=null,Ft={port:0,tunnelUrl:"",running:!1},ir=Re.default.dirname((0,qi.fileURLToPath)(__importMetaUrl)),Gi="iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAFw0lEQVR4nOWbaWwUVQDHf2+2tXRbCqmoKGgAuRIJoBwKkSAoDVKamDYLxUYUBSJHNCD30RhAbVWQqKCgXFGodKUfqGLljERsRaNQQoKoCKGFRhBp6XZ7sPv8MF0o7NTO7hzb4/dt5/9m3v/9d/fNO2YEOpEZiQnUeZMRYjQwAOgGdASi9V7DIuqAq8BZBMeQ8iDeuK/F7svX9JwsmiogJ8b0RjgWIkkHnAbN2kUVkIPDly121Pz+fwUbDUC6iEWJXQniVSDKbIc2UQdyLbHeTLGVaq0CmgHIZ2N64XPkAf0stWcfRUSTKj6vuni7EBSATHc+jORb4C5brNmFpASHSBY5nuKGh28JoP6bP0Jra3wASQlSDBFuT1ngkHJDe4F2+BxuWmvjAQRdccivpIvYwKEbAeCNXYV6e2vdSAahOBcFPgqov9XhOEnL7e1DpRK/6CXcnjL1FyAcC2k7jQeIR5GZAEJmJCZwvfoiLWeQYxYevM57Feq8ybS9xgPE4fSMU+rH9m0TKUZHEUrPH9cBnp4F9/SA4/vg+53WmbOH/lFAd11FHVGwvAC69Vc/j5gEPQfD1vnW2bMaSQ8FSNBVuO/wm40PMHYmpC7SLt8SEHRQgDsMXWTCchgz1RxD9hOjNF2mnlM/wNlibW3KGngs1SRP9qI/AN91eDsNLp3TuIoDZm+CAU+ZaM0e9AcAcOUCvJEC5X8Ha1F3wNwc6P2oSdbsIbQAAMr+hOw08FYGazFOmO+GLn1MsGYPoQcAcOYXeNcFdTXBWvs7YWk+dHrAoDV7CC8AgJOH4f3nwe8L1hK7wLJ8SGj+SwvhBwDwUz5snqOtde4JC76EdvGGqrAaYwEA7N8EuSu1tZ6DYd5OiI4xXI1VGA8AIC8L9nygrfV7AmZsAGFOVWZjnqvPFsN327W14S6Ystq0qszEvACkhI2z4NhebT1perOcN5j7u/TVwXsZ8Fuhtj5huTqdbkaY/8esqVKHzOdOaOuTs2BYmunVhos1PZOnXB0tXj4frAkFZn4SPLWOENZ1zVdK4c0UqLgcrEXHwJMvWlZ1KDTPe5ONWBdAYhdYkg8JnYK1uho4sNmyqkPBmgDaJ8KS3dDp/mBN+mH9tMYXV2zG/ABinDAvF7r21da3LYTCXaZXGy7mBuCIhjnboc8wbT13BRSsN7VKo5gXgBAwfR0MTNLW926EvGzTqjML8wJ4LgtGZmhrR3Jhy2umVWUm5gSQthjGzdbWThyCj19WO79miPEAxkwF1zJt7Y+fYXW69tJZM8FYAENS1D0BLUpOQdYzUK2xeNqMCD+Ah0bCK9vUPYHbuVKqNr7yXwPW7CG8AB4cpN7rtZa6rv0Dq8ZrT4SaIaEHEFjsjNVY7KypgndccOG0CdbsIbTnghLvU5e7O9wdrF2vhTWT4PSPobt4fCIMSIJoA/u0UkLpKfhmnTod14n+ABxRsGCX9oaH3wcfvgTH9+u+3A1SF6krRWYxOAWWjlD3MnWg/y+g9XxAgC1zoShP96VuYeyM8M5rjG79Va86UYBaQxXmroR9nxq6RASpUYAKXUW1ng8oWK/uCRih4CNj59/O2WLVqx4k5UJOdB4Fhug6waqHpCLXCRYJme7ciGRa+DW3aDYoSHkw0i4ihzwgpIt4FGcZEBdpOzbjwV/VWRFuKoEvIu3GdgQ7hJtKdRzg8GWjvn7WVqhF8WdB/UBIfbVMro2sJzuRa8SO6jPQcCQY680EiiJlyTYEhVR4X7/5sQHSFdcZRR4FNBb0WwUX8Muhwu0tDRy4ZS4g3J4yFDEeSYn93iznPH4xtmHjQWMyJHI8xUjlERCH7fNmMYJC/GKocHuC9uw1Z4PCXXmJCk8SsALwWO3PQmoRvEV51aiG7wo2pOmXp9V+IROYTMsZLHmA7Tj82YHevjGaDCCAdBGPIzYZKUYBA5F0R9ARo4/bG6cWyVUEfyH4Fb88hPTuqR/gNcl/yU6WmseVCn8AAAAASUVORK5CYII=",Qi=[Re.default.join(ir,"assets","trayIcon.ico"),Re.default.join(ir,"..","assets","trayIcon.ico")],vc=[Re.default.join(ir,"assets","tray.ps1"),Re.default.join(ir,"..","assets","tray.ps1")]});var eo=ce((Du,as)=>{as.exports={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}});var us=ce((Fu,ls)=>{var Ac=eo();function cs(e){this.mode=Ac.MODE_8BIT_BYTE,this.data=e}cs.prototype={getLength:function(){return this.data.length},write:function(e){for(var n=0;n<this.data.length;n++)e.put(this.data.charCodeAt(n),8)}};ls.exports=cs});var to=ce((Uu,fs)=>{var we={glog:function(e){if(e<1)throw new Error("glog("+e+")");return we.LOG_TABLE[e]},gexp:function(e){for(;e<0;)e+=255;for(;e>=256;)e-=255;return we.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(H=0;H<8;H++)we.EXP_TABLE[H]=1<<H;var H;for(H=8;H<256;H++)we.EXP_TABLE[H]=we.EXP_TABLE[H-4]^we.EXP_TABLE[H-5]^we.EXP_TABLE[H-6]^we.EXP_TABLE[H-8];var H;for(H=0;H<255;H++)we.LOG_TABLE[we.EXP_TABLE[H]]=H;var H;fs.exports=we});var no=ce((Bu,ps)=>{var mt=to();function cr(e,n){if(e.length===void 0)throw new Error(e.length+"/"+n);for(var r=0;r<e.length&&e[r]===0;)r++;this.num=new Array(e.length-r+n);for(var o=0;o<e.length-r;o++)this.num[o]=e[o+r]}cr.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var n=new Array(this.getLength()+e.getLength()-1),r=0;r<this.getLength();r++)for(var o=0;o<e.getLength();o++)n[r+o]^=mt.gexp(mt.glog(this.get(r))+mt.glog(e.get(o)));return new cr(n,0)},mod:function(e){if(this.getLength()-e.getLength()<0)return this;for(var n=mt.glog(this.get(0))-mt.glog(e.get(0)),r=new Array(this.getLength()),o=0;o<this.getLength();o++)r[o]=this.get(o);for(var t=0;t<e.getLength();t++)r[t]^=mt.gexp(mt.glog(e.get(t))+n);return new cr(r,0).mod(e)}};ps.exports=cr});var ms=ce((Hu,ds)=>{ds.exports={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7}});var ys=ce((ju,gs)=>{var pe=eo(),hs=no(),kc=to(),Xe=ms(),Y={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(e){for(var n=e<<10;Y.getBCHDigit(n)-Y.getBCHDigit(Y.G15)>=0;)n^=Y.G15<<Y.getBCHDigit(n)-Y.getBCHDigit(Y.G15);return(e<<10|n)^Y.G15_MASK},getBCHTypeNumber:function(e){for(var n=e<<12;Y.getBCHDigit(n)-Y.getBCHDigit(Y.G18)>=0;)n^=Y.G18<<Y.getBCHDigit(n)-Y.getBCHDigit(Y.G18);return e<<12|n},getBCHDigit:function(e){for(var n=0;e!==0;)n++,e>>>=1;return n},getPatternPosition:function(e){return Y.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,n,r){switch(e){case Xe.PATTERN000:return(n+r)%2===0;case Xe.PATTERN001:return n%2===0;case Xe.PATTERN010:return r%3===0;case Xe.PATTERN011:return(n+r)%3===0;case Xe.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2===0;case Xe.PATTERN101:return n*r%2+n*r%3===0;case Xe.PATTERN110:return(n*r%2+n*r%3)%2===0;case Xe.PATTERN111:return(n*r%3+(n+r)%2)%2===0;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var n=new hs([1],0),r=0;r<e;r++)n=n.multiply(new hs([1,kc.gexp(r)],0));return n},getLengthInBits:function(e,n){if(1<=n&&n<10)switch(e){case pe.MODE_NUMBER:return 10;case pe.MODE_ALPHA_NUM:return 9;case pe.MODE_8BIT_BYTE:return 8;case pe.MODE_KANJI:return 8;default:throw new Error("mode:"+e)}else if(n<27)switch(e){case pe.MODE_NUMBER:return 12;case pe.MODE_ALPHA_NUM:return 11;case pe.MODE_8BIT_BYTE:return 16;case pe.MODE_KANJI:return 10;default:throw new Error("mode:"+e)}else if(n<41)switch(e){case pe.MODE_NUMBER:return 14;case pe.MODE_ALPHA_NUM:return 13;case pe.MODE_8BIT_BYTE:return 16;case pe.MODE_KANJI:return 12;default:throw new Error("mode:"+e)}else throw new Error("type:"+n)},getLostPoint:function(e){var n=e.getModuleCount(),r=0,o=0,t=0;for(o=0;o<n;o++)for(t=0;t<n;t++){for(var i=0,s=e.isDark(o,t),a=-1;a<=1;a++)if(!(o+a<0||n<=o+a))for(var c=-1;c<=1;c++)t+c<0||n<=t+c||a===0&&c===0||s===e.isDark(o+a,t+c)&&i++;i>5&&(r+=3+i-5)}for(o=0;o<n-1;o++)for(t=0;t<n-1;t++){var l=0;e.isDark(o,t)&&l++,e.isDark(o+1,t)&&l++,e.isDark(o,t+1)&&l++,e.isDark(o+1,t+1)&&l++,(l===0||l===4)&&(r+=3)}for(o=0;o<n;o++)for(t=0;t<n-6;t++)e.isDark(o,t)&&!e.isDark(o,t+1)&&e.isDark(o,t+2)&&e.isDark(o,t+3)&&e.isDark(o,t+4)&&!e.isDark(o,t+5)&&e.isDark(o,t+6)&&(r+=40);for(t=0;t<n;t++)for(o=0;o<n-6;o++)e.isDark(o,t)&&!e.isDark(o+1,t)&&e.isDark(o+2,t)&&e.isDark(o+3,t)&&e.isDark(o+4,t)&&!e.isDark(o+5,t)&&e.isDark(o+6,t)&&(r+=40);var u=0;for(t=0;t<n;t++)for(o=0;o<n;o++)e.isDark(o,t)&&u++;var f=Math.abs(100*u/n/n-50)/5;return r+=f*10,r}};gs.exports=Y});var ro=ce((Ku,ws)=>{ws.exports={L:1,M:0,Q:3,H:2}});var Ss=ce((Gu,vs)=>{var lr=ro();function Ae(e,n){this.totalCount=e,this.dataCount=n}Ae.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]];Ae.getRSBlocks=function(e,n){var r=Ae.getRsBlockTable(e,n);if(r===void 0)throw new Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+n);for(var o=r.length/3,t=[],i=0;i<o;i++)for(var s=r[i*3+0],a=r[i*3+1],c=r[i*3+2],l=0;l<s;l++)t.push(new Ae(a,c));return t};Ae.getRsBlockTable=function(e,n){switch(n){case lr.L:return Ae.RS_BLOCK_TABLE[(e-1)*4+0];case lr.M:return Ae.RS_BLOCK_TABLE[(e-1)*4+1];case lr.Q:return Ae.RS_BLOCK_TABLE[(e-1)*4+2];case lr.H:return Ae.RS_BLOCK_TABLE[(e-1)*4+3];default:return}};vs.exports=Ae});var xs=ce((Wu,Ts)=>{function Es(){this.buffer=[],this.length=0}Es.prototype={get:function(e){var n=Math.floor(e/8);return(this.buffer[n]>>>7-e%8&1)==1},put:function(e,n){for(var r=0;r<n;r++)this.putBit((e>>>n-r-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){var n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),e&&(this.buffer[n]|=128>>>this.length%8),this.length++}};Ts.exports=Es});var ks=ce((Vu,As)=>{var _c=us(),Ze=ys(),Pc=no(),Rs=Ss(),bs=xs();function ke(e,n){this.typeNumber=e,this.errorCorrectLevel=n,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}ke.prototype={addData:function(e){var n=new _c(e);this.dataList.push(n),this.dataCache=null},isDark:function(e,n){if(e<0||this.moduleCount<=e||n<0||this.moduleCount<=n)throw new Error(e+","+n);return this.modules[e][n]},getModuleCount:function(){return this.moduleCount},make:function(){if(this.typeNumber<1){var e=1;for(e=1;e<40;e++){for(var n=Rs.getRSBlocks(e,this.errorCorrectLevel),r=new bs,o=0,t=0;t<n.length;t++)o+=n[t].dataCount;for(var i=0;i<this.dataList.length;i++){var s=this.dataList[i];r.put(s.mode,4),r.put(s.getLength(),Ze.getLengthInBits(s.mode,e)),s.write(r)}if(r.getLengthInBits()<=o*8)break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,n){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var r=0;r<this.moduleCount;r++){this.modules[r]=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++)this.modules[r][o]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(e,n),this.typeNumber>=7&&this.setupTypeNumber(e),this.dataCache===null&&(this.dataCache=ke.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,n)},setupPositionProbePattern:function(e,n){for(var r=-1;r<=7;r++)if(!(e+r<=-1||this.moduleCount<=e+r))for(var o=-1;o<=7;o++)n+o<=-1||this.moduleCount<=n+o||(0<=r&&r<=6&&(o===0||o===6)||0<=o&&o<=6&&(r===0||r===6)||2<=r&&r<=4&&2<=o&&o<=4?this.modules[e+r][n+o]=!0:this.modules[e+r][n+o]=!1)},getBestMaskPattern:function(){for(var e=0,n=0,r=0;r<8;r++){this.makeImpl(!0,r);var o=Ze.getLostPoint(this);(r===0||e>o)&&(e=o,n=r)}return n},createMovieClip:function(e,n,r){var o=e.createEmptyMovieClip(n,r),t=1;this.make();for(var i=0;i<this.modules.length;i++)for(var s=i*t,a=0;a<this.modules[i].length;a++){var c=a*t,l=this.modules[i][a];l&&(o.beginFill(0,100),o.moveTo(c,s),o.lineTo(c+t,s),o.lineTo(c+t,s+t),o.lineTo(c,s+t),o.endFill())}return o},setupTimingPattern:function(){for(var e=8;e<this.moduleCount-8;e++)this.modules[e][6]===null&&(this.modules[e][6]=e%2===0);for(var n=8;n<this.moduleCount-8;n++)this.modules[6][n]===null&&(this.modules[6][n]=n%2===0)},setupPositionAdjustPattern:function(){for(var e=Ze.getPatternPosition(this.typeNumber),n=0;n<e.length;n++)for(var r=0;r<e.length;r++){var o=e[n],t=e[r];if(this.modules[o][t]===null)for(var i=-2;i<=2;i++)for(var s=-2;s<=2;s++)Math.abs(i)===2||Math.abs(s)===2||i===0&&s===0?this.modules[o+i][t+s]=!0:this.modules[o+i][t+s]=!1}},setupTypeNumber:function(e){for(var n=Ze.getBCHTypeNumber(this.typeNumber),r,o=0;o<18;o++)r=!e&&(n>>o&1)===1,this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3]=r;for(var t=0;t<18;t++)r=!e&&(n>>t&1)===1,this.modules[t%3+this.moduleCount-8-3][Math.floor(t/3)]=r},setupTypeInfo:function(e,n){for(var r=this.errorCorrectLevel<<3|n,o=Ze.getBCHTypeInfo(r),t,i=0;i<15;i++)t=!e&&(o>>i&1)===1,i<6?this.modules[i][8]=t:i<8?this.modules[i+1][8]=t:this.modules[this.moduleCount-15+i][8]=t;for(var s=0;s<15;s++)t=!e&&(o>>s&1)===1,s<8?this.modules[8][this.moduleCount-s-1]=t:s<9?this.modules[8][15-s-1+1]=t:this.modules[8][15-s-1]=t;this.modules[this.moduleCount-8][8]=!e},mapData:function(e,n){for(var r=-1,o=this.moduleCount-1,t=7,i=0,s=this.moduleCount-1;s>0;s-=2)for(s===6&&s--;;){for(var a=0;a<2;a++)if(this.modules[o][s-a]===null){var c=!1;i<e.length&&(c=(e[i]>>>t&1)===1);var l=Ze.getMask(n,o,s-a);l&&(c=!c),this.modules[o][s-a]=c,t--,t===-1&&(i++,t=7)}if(o+=r,o<0||this.moduleCount<=o){o-=r,r=-r;break}}}};ke.PAD0=236;ke.PAD1=17;ke.createData=function(e,n,r){for(var o=Rs.getRSBlocks(e,n),t=new bs,i=0;i<r.length;i++){var s=r[i];t.put(s.mode,4),t.put(s.getLength(),Ze.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,n){for(var r=0,o=0,t=0,i=new Array(n.length),s=new Array(n.length),a=0;a<n.length;a++){var c=n[a].dataCount,l=n[a].totalCount-c;o=Math.max(o,c),t=Math.max(t,l),i[a]=new Array(c);for(var u=0;u<i[a].length;u++)i[a][u]=255&e.buffer[u+r];r+=c;var f=Ze.getErrorCorrectPolynomial(l),p=new Pc(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 T=0,P=0;P<n.length;P++)T+=n[P].totalCount;for(var x=new Array(T),b=0,k=0;k<o;k++)for(var S=0;S<n.length;S++)k<i[S].length&&(x[b++]=i[S][k]);for(var g=0;g<t;g++)for(var _=0;_<n.length;_++)g<s[_].length&&(x[b++]=s[_][g]);return x};As.exports=ke});var Is=ce((Yu,Ps)=>{var Ic=ks(),_s=ro(),Oc="\x1B[40m \x1B[0m",ur="\x1B[47m \x1B[0m",$c=function(e){return e?Oc:ur},oo=function(e){return{times:function(n){return new Array(n).join(e)}}},Cc=function(e,n){for(var r=new Array(e),o=0;o<e;o++)r[o]=n;return r};Ps.exports={error:_s.L,generate:function(e,n,r){typeof n=="function"&&(r=n,n={});var o=new Ic(-1,this.error);o.addData(e),o.make();var t="";if(n&&n.small){var i=!0,s=!1,a=o.getModuleCount(),c=o.modules.slice(),l=a%2===1;l&&c.push(Cc(a,s));var u={WHITE_ALL:"\u2588",WHITE_BLACK:"\u2580",BLACK_WHITE:"\u2584",BLACK_ALL:" "},f=oo(u.BLACK_WHITE).times(a+3),p=oo(u.WHITE_BLACK).times(a+3);t+=f+`
|
|
6
|
+
Right-click to open / quit`}function es(){let{port:e,tunnelUrl:n}=Ut,r=process.platform==="win32",o=n?`9Remote (Port ${e}) \u2022 Tunnel ON`:`9Remote (Port ${e}) \u2022 Local only`;return{icon:bc(),title:r?`9Remote - Port ${e}`:"",tooltip:zi(),items:[{title:o,tooltip:n||`http://localhost:${e}`,checked:!1,enabled:!1},{title:"Open Web UI",tooltip:`Open http://localhost:${e} in your browser`,checked:!1,enabled:!0},{title:"Shutdown",tooltip:"Stop 9Remote server, tunnel and quit",checked:!1,enabled:!0}]}}function kc(){try{let e=require(Ae.default.join(Xi,"systray2"));return e.default?.default||e.default||e}catch{return null}}function _c({port:e,onQuit:n,onOpenUI:r}){let o=Yi(Zi),t=Yi(Rc);if(!o||!t)return null;let i;try{i=(0,Le.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 qi.default.createInterface({input:i.stdout}).on("line",c=>{try{let l=JSON.parse(c);if(l.type!=="click")return;l.index===0?r?.():l.index===1&&(n?.(),En(),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 qr({port:e,onQuit:n,onOpenUI:r}){if(!Ac())return null;if(process.platform==="win32")return Ut={port:e,tunnelUrl:"",running:!0},Z=_c({port:e,onQuit:n,onOpenUI:r}),Z;try{let o=kc();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=Ae.default.join(Xi,"systray2","traybin",i);if(!Ft.default.existsSync(s))return null;if(process.platform!=="win32")try{Ft.default.chmodSync(s,493)}catch{}return Ut={port:e,tunnelUrl:"",running:!0},Z=new o({menu:es(),debug:!1,copyDir:!0}),Z.onClick(a=>{let c=a.item?.title||a.item;c==="Open Web UI"?r?.():c==="Shutdown"&&(n?.(),En(),setTimeout(()=>process.exit(0),500))}),typeof Z.ready=="function"?Z.ready().catch(()=>{}):(Z.onReady(()=>{}),Z.onError(()=>{})),Z}catch{return null}}function ir({tunnelUrl:e,running:n}={}){if(e!==void 0&&(Ut.tunnelUrl=e),n!==void 0&&(Ut.running=n),!!Z){if(Z._isWin){Z._setTooltip?.(zi());return}try{Z.sendAction({type:"update-menu",menu:es(),seq_id:-1})}catch{}}}function En(){let e=Z;if(Z=null,e)try{e.kill(!0)}catch{}}function Jr({title:e="9Remote",message:n}){let r=process.platform;if(n){if(r==="win32"){let o=c=>String(c).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,"""),t=c=>String(c).replace(/'/g,"''"),i="9Remote",s=`<toast><visual><binding template="ToastText02"><text id="1">${o(e)}</text><text id="2">${o(n)}</text></binding></visual></toast>`,a=["try {","[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType=WindowsRuntime] > $null;","[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType=WindowsRuntime] > $null;","$xml = New-Object Windows.Data.Xml.Dom.XmlDocument;",`$xml.LoadXml('${t(s)}');`,"$toast = [Windows.UI.Notifications.ToastNotification]::new($xml);",`[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('${t(i)}').Show($toast);`,"} catch {","Add-Type -AssemblyName System.Windows.Forms;","$n = New-Object System.Windows.Forms.NotifyIcon;","$n.Icon = [System.Drawing.SystemIcons]::Information;",`$n.BalloonTipTitle = '${t(e)}';`,`$n.BalloonTipText = '${t(n)}';`,"$n.Visible = $true;","$n.ShowBalloonTip(5000);","Start-Sleep -Seconds 6;","$n.Dispose();","}"].join(" ");try{(0,Le.spawn)("powershell.exe",["-NoProfile","-WindowStyle","Hidden","-Command",a],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(r==="darwin"){try{let o=s=>String(s).replace(/"/g,'\\"'),t=`display notification "${o(n)}" with title "${o(e)}"`;(0,Le.spawn)("osascript",["-e",t],{detached:!0,stdio:"ignore"}).unref()}catch{}return}try{(0,Le.spawn)("notify-send",[e,n],{detached:!0,stdio:"ignore"}).unref()}catch{}}}function Tn(e){let n=process.platform;if(n==="win32"){try{(0,Le.spawn)("rundll32.exe",["url.dll,FileProtocolHandler",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref();return}catch{}try{(0,Le.spawn)("cmd.exe",["/d","/s","/c","start","",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(n==="darwin"){try{(0,Le.spawn)("open",[e],{detached:!0,stdio:"ignore"}).unref()}catch{}return}let r=[["setsid",["--fork","xdg-open",e]],["setsid",["xdg-open",e]],["xdg-open",[e]],["gio",["open",e]],["sensible-browser",[e]],["x-www-browser",[e]]];for(let[o,t]of r)try{(0,Le.spawn)(o,t,{detached:!0,stdio:"ignore",env:{...process.env}}).unref();return}catch{}}var Le,qi,Ft,Ae,Ji,Qi,Xi,Z,Ut,or,Vi,Zi,Rc,Bt=ea(()=>{Le=require("child_process"),qi=A(require("readline"),1),Ft=A(require("fs"),1),Ae=A(require("path"),1),Ji=A(require("os"),1),Qi=require("url"),Xi=(0,Ae.join)(Ji.default.homedir(),".9remote","runtime","node_modules"),Z=null,Ut={port:0,tunnelUrl:"",running:!1},or=Ae.default.dirname((0,Qi.fileURLToPath)(__importMetaUrl)),Vi="iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAFw0lEQVR4nOWbaWwUVQDHf2+2tXRbCqmoKGgAuRIJoBwKkSAoDVKamDYLxUYUBSJHNCD30RhAbVWQqKCgXFGodKUfqGLljERsRaNQQoKoCKGFRhBp6XZ7sPv8MF0o7NTO7hzb4/dt5/9m3v/9d/fNO2YEOpEZiQnUeZMRYjQwAOgGdASi9V7DIuqAq8BZBMeQ8iDeuK/F7svX9JwsmiogJ8b0RjgWIkkHnAbN2kUVkIPDly121Pz+fwUbDUC6iEWJXQniVSDKbIc2UQdyLbHeTLGVaq0CmgHIZ2N64XPkAf0stWcfRUSTKj6vuni7EBSATHc+jORb4C5brNmFpASHSBY5nuKGh28JoP6bP0Jra3wASQlSDBFuT1ngkHJDe4F2+BxuWmvjAQRdccivpIvYwKEbAeCNXYV6e2vdSAahOBcFPgqov9XhOEnL7e1DpRK/6CXcnjL1FyAcC2k7jQeIR5GZAEJmJCZwvfoiLWeQYxYevM57Feq8ybS9xgPE4fSMU+rH9m0TKUZHEUrPH9cBnp4F9/SA4/vg+53WmbOH/lFAd11FHVGwvAC69Vc/j5gEPQfD1vnW2bMaSQ8FSNBVuO/wm40PMHYmpC7SLt8SEHRQgDsMXWTCchgz1RxD9hOjNF2mnlM/wNlibW3KGngs1SRP9qI/AN91eDsNLp3TuIoDZm+CAU+ZaM0e9AcAcOUCvJEC5X8Ha1F3wNwc6P2oSdbsIbQAAMr+hOw08FYGazFOmO+GLn1MsGYPoQcAcOYXeNcFdTXBWvs7YWk+dHrAoDV7CC8AgJOH4f3nwe8L1hK7wLJ8SGj+SwvhBwDwUz5snqOtde4JC76EdvGGqrAaYwEA7N8EuSu1tZ6DYd5OiI4xXI1VGA8AIC8L9nygrfV7AmZsAGFOVWZjnqvPFsN327W14S6Ystq0qszEvACkhI2z4NhebT1perOcN5j7u/TVwXsZ8Fuhtj5huTqdbkaY/8esqVKHzOdOaOuTs2BYmunVhos1PZOnXB0tXj4frAkFZn4SPLWOENZ1zVdK4c0UqLgcrEXHwJMvWlZ1KDTPe5ONWBdAYhdYkg8JnYK1uho4sNmyqkPBmgDaJ8KS3dDp/mBN+mH9tMYXV2zG/ABinDAvF7r21da3LYTCXaZXGy7mBuCIhjnboc8wbT13BRSsN7VKo5gXgBAwfR0MTNLW926EvGzTqjML8wJ4LgtGZmhrR3Jhy2umVWUm5gSQthjGzdbWThyCj19WO79miPEAxkwF1zJt7Y+fYXW69tJZM8FYAENS1D0BLUpOQdYzUK2xeNqMCD+Ah0bCK9vUPYHbuVKqNr7yXwPW7CG8AB4cpN7rtZa6rv0Dq8ZrT4SaIaEHEFjsjNVY7KypgndccOG0CdbsIbTnghLvU5e7O9wdrF2vhTWT4PSPobt4fCIMSIJoA/u0UkLpKfhmnTod14n+ABxRsGCX9oaH3wcfvgTH9+u+3A1SF6krRWYxOAWWjlD3MnWg/y+g9XxAgC1zoShP96VuYeyM8M5rjG79Va86UYBaQxXmroR9nxq6RASpUYAKXUW1ng8oWK/uCRih4CNj59/O2WLVqx4k5UJOdB4Fhug6waqHpCLXCRYJme7ciGRa+DW3aDYoSHkw0i4ihzwgpIt4FGcZEBdpOzbjwV/VWRFuKoEvIu3GdgQ7hJtKdRzg8GWjvn7WVqhF8WdB/UBIfbVMro2sJzuRa8SO6jPQcCQY680EiiJlyTYEhVR4X7/5sQHSFdcZRR4FNBb0WwUX8Muhwu0tDRy4ZS4g3J4yFDEeSYn93iznPH4xtmHjQWMyJHI8xUjlERCH7fNmMYJC/GKocHuC9uw1Z4PCXXmJCk8SsALwWO3PQmoRvEV51aiG7wo2pOmXp9V+IROYTMsZLHmA7Tj82YHevjGaDCCAdBGPIzYZKUYBA5F0R9ARo4/bG6cWyVUEfyH4Fb88hPTuqR/gNcl/yU6WmseVCn8AAAAASUVORK5CYII=",Zi=[Ae.default.join(or,"assets","trayIcon.ico"),Ae.default.join(or,"..","assets","trayIcon.ico")],Rc=[Ae.default.join(or,"assets","tray.ps1"),Ae.default.join(or,"..","assets","tray.ps1")]});var zr=ae((ju,us)=>{us.exports={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}});var ds=ae((Ku,ps)=>{var Ic=zr();function fs(e){this.mode=Ic.MODE_8BIT_BYTE,this.data=e}fs.prototype={getLength:function(){return this.data.length},write:function(e){for(var n=0;n<this.data.length;n++)e.put(this.data.charCodeAt(n),8)}};ps.exports=fs});var eo=ae((Gu,ms)=>{var we={glog:function(e){if(e<1)throw new Error("glog("+e+")");return we.LOG_TABLE[e]},gexp:function(e){for(;e<0;)e+=255;for(;e>=256;)e-=255;return we.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(H=0;H<8;H++)we.EXP_TABLE[H]=1<<H;var H;for(H=8;H<256;H++)we.EXP_TABLE[H]=we.EXP_TABLE[H-4]^we.EXP_TABLE[H-5]^we.EXP_TABLE[H-6]^we.EXP_TABLE[H-8];var H;for(H=0;H<255;H++)we.LOG_TABLE[we.EXP_TABLE[H]]=H;var H;ms.exports=we});var to=ae((Wu,hs)=>{var ht=eo();function ar(e,n){if(e.length===void 0)throw new Error(e.length+"/"+n);for(var r=0;r<e.length&&e[r]===0;)r++;this.num=new Array(e.length-r+n);for(var o=0;o<e.length-r;o++)this.num[o]=e[o+r]}ar.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var n=new Array(this.getLength()+e.getLength()-1),r=0;r<this.getLength();r++)for(var o=0;o<e.getLength();o++)n[r+o]^=ht.gexp(ht.glog(this.get(r))+ht.glog(e.get(o)));return new ar(n,0)},mod:function(e){if(this.getLength()-e.getLength()<0)return this;for(var n=ht.glog(this.get(0))-ht.glog(e.get(0)),r=new Array(this.getLength()),o=0;o<this.getLength();o++)r[o]=this.get(o);for(var t=0;t<e.getLength();t++)r[t]^=ht.gexp(ht.glog(e.get(t))+n);return new ar(r,0).mod(e)}};hs.exports=ar});var ys=ae((Vu,gs)=>{gs.exports={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7}});var Ss=ae((Yu,vs)=>{var pe=zr(),ws=to(),$c=eo(),Ze=ys(),Y={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(e){for(var n=e<<10;Y.getBCHDigit(n)-Y.getBCHDigit(Y.G15)>=0;)n^=Y.G15<<Y.getBCHDigit(n)-Y.getBCHDigit(Y.G15);return(e<<10|n)^Y.G15_MASK},getBCHTypeNumber:function(e){for(var n=e<<12;Y.getBCHDigit(n)-Y.getBCHDigit(Y.G18)>=0;)n^=Y.G18<<Y.getBCHDigit(n)-Y.getBCHDigit(Y.G18);return e<<12|n},getBCHDigit:function(e){for(var n=0;e!==0;)n++,e>>>=1;return n},getPatternPosition:function(e){return Y.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,n,r){switch(e){case Ze.PATTERN000:return(n+r)%2===0;case Ze.PATTERN001:return n%2===0;case Ze.PATTERN010:return r%3===0;case Ze.PATTERN011:return(n+r)%3===0;case Ze.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2===0;case Ze.PATTERN101:return n*r%2+n*r%3===0;case Ze.PATTERN110:return(n*r%2+n*r%3)%2===0;case Ze.PATTERN111:return(n*r%3+(n+r)%2)%2===0;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var n=new ws([1],0),r=0;r<e;r++)n=n.multiply(new ws([1,$c.gexp(r)],0));return n},getLengthInBits:function(e,n){if(1<=n&&n<10)switch(e){case pe.MODE_NUMBER:return 10;case pe.MODE_ALPHA_NUM:return 9;case pe.MODE_8BIT_BYTE:return 8;case pe.MODE_KANJI:return 8;default:throw new Error("mode:"+e)}else if(n<27)switch(e){case pe.MODE_NUMBER:return 12;case pe.MODE_ALPHA_NUM:return 11;case pe.MODE_8BIT_BYTE:return 16;case pe.MODE_KANJI:return 10;default:throw new Error("mode:"+e)}else if(n<41)switch(e){case pe.MODE_NUMBER:return 14;case pe.MODE_ALPHA_NUM:return 13;case pe.MODE_8BIT_BYTE:return 16;case pe.MODE_KANJI:return 12;default:throw new Error("mode:"+e)}else throw new Error("type:"+n)},getLostPoint:function(e){var n=e.getModuleCount(),r=0,o=0,t=0;for(o=0;o<n;o++)for(t=0;t<n;t++){for(var i=0,s=e.isDark(o,t),a=-1;a<=1;a++)if(!(o+a<0||n<=o+a))for(var c=-1;c<=1;c++)t+c<0||n<=t+c||a===0&&c===0||s===e.isDark(o+a,t+c)&&i++;i>5&&(r+=3+i-5)}for(o=0;o<n-1;o++)for(t=0;t<n-1;t++){var l=0;e.isDark(o,t)&&l++,e.isDark(o+1,t)&&l++,e.isDark(o,t+1)&&l++,e.isDark(o+1,t+1)&&l++,(l===0||l===4)&&(r+=3)}for(o=0;o<n;o++)for(t=0;t<n-6;t++)e.isDark(o,t)&&!e.isDark(o,t+1)&&e.isDark(o,t+2)&&e.isDark(o,t+3)&&e.isDark(o,t+4)&&!e.isDark(o,t+5)&&e.isDark(o,t+6)&&(r+=40);for(t=0;t<n;t++)for(o=0;o<n-6;o++)e.isDark(o,t)&&!e.isDark(o+1,t)&&e.isDark(o+2,t)&&e.isDark(o+3,t)&&e.isDark(o+4,t)&&!e.isDark(o+5,t)&&e.isDark(o+6,t)&&(r+=40);var u=0;for(t=0;t<n;t++)for(o=0;o<n;o++)e.isDark(o,t)&&u++;var f=Math.abs(100*u/n/n-50)/5;return r+=f*10,r}};vs.exports=Y});var no=ae((qu,Es)=>{Es.exports={L:1,M:0,Q:3,H:2}});var xs=ae((Ju,Ts)=>{var cr=no();function ke(e,n){this.totalCount=e,this.dataCount=n}ke.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]];ke.getRSBlocks=function(e,n){var r=ke.getRsBlockTable(e,n);if(r===void 0)throw new Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+n);for(var o=r.length/3,t=[],i=0;i<o;i++)for(var s=r[i*3+0],a=r[i*3+1],c=r[i*3+2],l=0;l<s;l++)t.push(new ke(a,c));return t};ke.getRsBlockTable=function(e,n){switch(n){case cr.L:return ke.RS_BLOCK_TABLE[(e-1)*4+0];case cr.M:return ke.RS_BLOCK_TABLE[(e-1)*4+1];case cr.Q:return ke.RS_BLOCK_TABLE[(e-1)*4+2];case cr.H:return ke.RS_BLOCK_TABLE[(e-1)*4+3];default:return}};Ts.exports=ke});var As=ae((Qu,bs)=>{function Rs(){this.buffer=[],this.length=0}Rs.prototype={get:function(e){var n=Math.floor(e/8);return(this.buffer[n]>>>7-e%8&1)==1},put:function(e,n){for(var r=0;r<n;r++)this.putBit((e>>>n-r-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){var n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),e&&(this.buffer[n]|=128>>>this.length%8),this.length++}};bs.exports=Rs});var Os=ae((Xu,Ps)=>{var Cc=ds(),ze=Ss(),Lc=to(),ks=xs(),_s=As();function _e(e,n){this.typeNumber=e,this.errorCorrectLevel=n,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}_e.prototype={addData:function(e){var n=new Cc(e);this.dataList.push(n),this.dataCache=null},isDark:function(e,n){if(e<0||this.moduleCount<=e||n<0||this.moduleCount<=n)throw new Error(e+","+n);return this.modules[e][n]},getModuleCount:function(){return this.moduleCount},make:function(){if(this.typeNumber<1){var e=1;for(e=1;e<40;e++){for(var n=ks.getRSBlocks(e,this.errorCorrectLevel),r=new _s,o=0,t=0;t<n.length;t++)o+=n[t].dataCount;for(var i=0;i<this.dataList.length;i++){var s=this.dataList[i];r.put(s.mode,4),r.put(s.getLength(),ze.getLengthInBits(s.mode,e)),s.write(r)}if(r.getLengthInBits()<=o*8)break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,n){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var r=0;r<this.moduleCount;r++){this.modules[r]=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++)this.modules[r][o]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(e,n),this.typeNumber>=7&&this.setupTypeNumber(e),this.dataCache===null&&(this.dataCache=_e.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,n)},setupPositionProbePattern:function(e,n){for(var r=-1;r<=7;r++)if(!(e+r<=-1||this.moduleCount<=e+r))for(var o=-1;o<=7;o++)n+o<=-1||this.moduleCount<=n+o||(0<=r&&r<=6&&(o===0||o===6)||0<=o&&o<=6&&(r===0||r===6)||2<=r&&r<=4&&2<=o&&o<=4?this.modules[e+r][n+o]=!0:this.modules[e+r][n+o]=!1)},getBestMaskPattern:function(){for(var e=0,n=0,r=0;r<8;r++){this.makeImpl(!0,r);var o=ze.getLostPoint(this);(r===0||e>o)&&(e=o,n=r)}return n},createMovieClip:function(e,n,r){var o=e.createEmptyMovieClip(n,r),t=1;this.make();for(var i=0;i<this.modules.length;i++)for(var s=i*t,a=0;a<this.modules[i].length;a++){var c=a*t,l=this.modules[i][a];l&&(o.beginFill(0,100),o.moveTo(c,s),o.lineTo(c+t,s),o.lineTo(c+t,s+t),o.lineTo(c,s+t),o.endFill())}return o},setupTimingPattern:function(){for(var e=8;e<this.moduleCount-8;e++)this.modules[e][6]===null&&(this.modules[e][6]=e%2===0);for(var n=8;n<this.moduleCount-8;n++)this.modules[6][n]===null&&(this.modules[6][n]=n%2===0)},setupPositionAdjustPattern:function(){for(var e=ze.getPatternPosition(this.typeNumber),n=0;n<e.length;n++)for(var r=0;r<e.length;r++){var o=e[n],t=e[r];if(this.modules[o][t]===null)for(var i=-2;i<=2;i++)for(var s=-2;s<=2;s++)Math.abs(i)===2||Math.abs(s)===2||i===0&&s===0?this.modules[o+i][t+s]=!0:this.modules[o+i][t+s]=!1}},setupTypeNumber:function(e){for(var n=ze.getBCHTypeNumber(this.typeNumber),r,o=0;o<18;o++)r=!e&&(n>>o&1)===1,this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3]=r;for(var t=0;t<18;t++)r=!e&&(n>>t&1)===1,this.modules[t%3+this.moduleCount-8-3][Math.floor(t/3)]=r},setupTypeInfo:function(e,n){for(var r=this.errorCorrectLevel<<3|n,o=ze.getBCHTypeInfo(r),t,i=0;i<15;i++)t=!e&&(o>>i&1)===1,i<6?this.modules[i][8]=t:i<8?this.modules[i+1][8]=t:this.modules[this.moduleCount-15+i][8]=t;for(var s=0;s<15;s++)t=!e&&(o>>s&1)===1,s<8?this.modules[8][this.moduleCount-s-1]=t:s<9?this.modules[8][15-s-1+1]=t:this.modules[8][15-s-1]=t;this.modules[this.moduleCount-8][8]=!e},mapData:function(e,n){for(var r=-1,o=this.moduleCount-1,t=7,i=0,s=this.moduleCount-1;s>0;s-=2)for(s===6&&s--;;){for(var a=0;a<2;a++)if(this.modules[o][s-a]===null){var c=!1;i<e.length&&(c=(e[i]>>>t&1)===1);var l=ze.getMask(n,o,s-a);l&&(c=!c),this.modules[o][s-a]=c,t--,t===-1&&(i++,t=7)}if(o+=r,o<0||this.moduleCount<=o){o-=r,r=-r;break}}}};_e.PAD0=236;_e.PAD1=17;_e.createData=function(e,n,r){for(var o=ks.getRSBlocks(e,n),t=new _s,i=0;i<r.length;i++){var s=r[i];t.put(s.mode,4),t.put(s.getLength(),ze.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(_e.PAD0,8),t.getLengthInBits()>=a*8));)t.put(_e.PAD1,8);return _e.createBytes(t,o)};_e.createBytes=function(e,n){for(var r=0,o=0,t=0,i=new Array(n.length),s=new Array(n.length),a=0;a<n.length;a++){var c=n[a].dataCount,l=n[a].totalCount-c;o=Math.max(o,c),t=Math.max(t,l),i[a]=new Array(c);for(var u=0;u<i[a].length;u++)i[a][u]=255&e.buffer[u+r];r+=c;var f=ze.getErrorCorrectPolynomial(l),p=new Lc(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 S=0,O=0;O<n.length;O++)S+=n[O].totalCount;for(var x=new Array(S),b=0,k=0;k<o;k++)for(var E=0;E<n.length;E++)k<i[E].length&&(x[b++]=i[E][k]);for(var g=0;g<t;g++)for(var _=0;_<n.length;_++)g<s[_].length&&(x[b++]=s[_][g]);return x};Ps.exports=_e});var Cs=ae((Zu,$s)=>{var Mc=Os(),Is=no(),Nc="\x1B[40m \x1B[0m",lr="\x1B[47m \x1B[0m",Dc=function(e){return e?Nc:lr},ro=function(e){return{times:function(n){return new Array(n).join(e)}}},Fc=function(e,n){for(var r=new Array(e),o=0;o<e;o++)r[o]=n;return r};$s.exports={error:Is.L,generate:function(e,n,r){typeof n=="function"&&(r=n,n={});var o=new Mc(-1,this.error);o.addData(e),o.make();var t="";if(n&&n.small){var i=!0,s=!1,a=o.getModuleCount(),c=o.modules.slice(),l=a%2===1;l&&c.push(Fc(a,s));var u={WHITE_ALL:"\u2588",WHITE_BLACK:"\u2580",BLACK_WHITE:"\u2584",BLACK_ALL:" "},f=ro(u.BLACK_WHITE).times(a+3),p=ro(u.WHITE_BLACK).times(a+3);t+=f+`
|
|
8
8
|
`;for(var d=0;d<a;d+=2){t+=u.WHITE_ALL;for(var h=0;h<a;h++)c[d][h]===s&&c[d+1][h]===s?t+=u.WHITE_ALL:c[d][h]===s&&c[d+1][h]===i?t+=u.WHITE_BLACK:c[d][h]===i&&c[d+1][h]===s?t+=u.BLACK_WHITE:t+=u.BLACK_ALL;t+=u.WHITE_ALL+`
|
|
9
|
-
`}l||(t+=p)}else{var w=
|
|
10
|
-
`,o.modules.forEach(function(
|
|
11
|
-
`}),t+=w}r?r(t):console.log(t)},setErrorLevel:function(e){this.error=
|
|
12
|
-
`)){let r=n.trim();if(!r||r.startsWith("#"))continue;let o=r.match(/^([A-Z_][A-Z0-9_]*)\s*=\s*"?(.*?)"?$/);o&&!process.env[o[1]]&&(process.env[o[1]]=o[2])}}for(let e of
|
|
13
|
-
`)}catch{}}function
|
|
14
|
-
=== SESSION ${new Date().toISOString()} pid=${process.pid} argv=${process.argv.slice(2).join(" ")} ===`),
|
|
15
|
-
`).filter(Boolean).slice(-e)}catch{return[]}}function J(e){return{info:(...n)=>
|
|
9
|
+
`}l||(t+=p)}else{var w=ro(lr).times(o.getModuleCount()+3);t+=w+`
|
|
10
|
+
`,o.modules.forEach(function(S){t+=lr,t+=S.map(Dc).join(""),t+=lr+`
|
|
11
|
+
`}),t+=w}r?r(t):console.log(t)},setErrorLevel:function(e){this.error=Is[e]||this.error}}});var In=require("fs"),Jt=require("path"),wo=require("url"),vo=A(require("os"),1);var On=A(require("dns"),1),Oe=A(require("path"),1),lo=A(require("os"),1),te="9remote",dr=process.env.NREMOTE_REGISTRY||`https://registry.npmjs.org/${te}/latest`,Ie=`${te}@latest`,Ue=Oe.default.join(lo.default.homedir(),".9remote"),ne={ROOT:Ue,LOGS:Oe.default.join(Ue,"logs"),STATE:Oe.default.join(Ue,"state"),CONFIG:Oe.default.join(Ue,"config"),BIN:Oe.default.join(Ue,"bin"),PIDS:Oe.default.join(Ue,"pids"),BUFFERS:Oe.default.join(Ue,"buffers"),DAEMON:Oe.default.join(Ue,"daemon")},uo=new On.default.promises.Resolver;uo.setServers(["1.1.1.1","1.0.0.1","8.8.8.8"]);var pr=On.default.lookup,ra=/^(\d{1,3}\.){3}\d{1,3}$|^::1$|^[0-9a-f:]+$/i;On.default.lookup=(e,n,r)=>{if(typeof n=="function"&&(r=n,n={}),e==="localhost"||ra.test(e))return pr(e,n,r);uo.resolve4(e).then(o=>{if(!o?.length)return pr(e,n,r);n.all?r(null,o.map(t=>({address:t,family:4}))):r(null,o[0],4)}).catch(()=>pr(e,n,r))};var P=2208,fo=process.execPath,po=(e=process.env)=>process.versions.electron?{...e,ELECTRON_RUN_AS_NODE:"1"}:{...e};var co=5173;var il=[`http://localhost:${P}`,`http://127.0.0.1:${P}`,`http://localhost:${co}`,`http://127.0.0.1:${co}`],qt={fileName:"agent.log",rotatedName:"agent.log.1",maxBytes:2*1024*1024,cleanupAfterDays:7},mo=60,$={STOPPED:0,PREPARING:1,CONNECTING:2,TUNNELING:3,VERIFYING:4,READY:5},ho={showTunnelUrlInMenu:!1};var go={CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN:"1"};var yo={checkIntervalMs:3e4,requestTimeoutMs:5e3},ce={server:{strategy:"exp",baseMs:1e3,maxMs:6e4},tunnelRestart:{strategy:"exp",baseMs:2e3,maxMs:3e5},tunnelSpawn:{strategy:"linear",baseMs:5e3,maxMs:6e4},internet:{strategy:"linear",baseMs:3e3,maxMs:6e4},sse:{strategy:"linear",baseMs:2e3,maxMs:2e3},urlSync:{strategy:"linear",baseMs:5e3,maxMs:6e4}},oa={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 G(e,n={}){return fetch(e,{...n,headers:{...oa,...n.headers}})}var ia=(0,Jt.dirname)((0,wo.fileURLToPath)(__importMetaUrl)),sa=[(0,Jt.join)(vo.default.homedir(),".9remote",".env"),(0,Jt.join)(ia,"..",".env")];function aa(e){for(let n of e.split(`
|
|
12
|
+
`)){let r=n.trim();if(!r||r.startsWith("#"))continue;let o=r.match(/^([A-Z_][A-Z0-9_]*)\s*=\s*"?(.*?)"?$/);o&&!process.env[o[1]]&&(process.env[o[1]]=o[2])}}for(let e of sa)if((0,In.existsSync)(e))try{aa((0,In.readFileSync)(e,"utf8"))}catch{}for(let[e,n]of Object.entries(go))process.env[e]||(process.env[e]=n);var wr=A(require("path"),1),Ao=A(require("fs"),1),ko=require("url");var Eo=A(So(),1),hr=A(require("crypto"),1),{machineIdSync:ca}=Eo.default;async function St(e=null){let n=e||process.env.MACHINE_ID_SALT||"9remote-salt";try{let r=ca();return hr.default.createHash("sha256").update(r+n).digest("hex").substring(0,16)}catch(r){return console.error("Error getting machine ID:",r),hr.default.randomUUID().replace(/-/g,"").substring(0,16)}}var To=A(require("crypto"),1),la=process.env.API_KEY_SECRET||"9remote-api-key-secret";function ua(){let e="abcdefghijklmnopqrstuvwxyz0123456789",n="";for(let r=0;r<4;r++)n+=e.charAt(Math.floor(Math.random()*e.length));return n}function fa(e,n){return To.default.createHmac("sha256",la).update(e+n).digest("hex").slice(0,6)}function Et(e){let n=e.slice(0,8),r=ua(),o=fa(n,r);return{key:`sk-${n}-${r}-${o}`,keyId:r}}function $n(e){return!e||e.length<8?"sk-***":`${e.slice(0,3)}***${e.slice(-4)}`}var se=A(require("fs"),1),Xt=A(require("path"),1);var fl=ne.STATE,gr=Xt.default.join(ne.STATE,"state.json"),yr=Xt.default.join(ne.ROOT,"keys.json"),Cn=Xt.default.join(ne.STATE,"cmd.json"),pl=Xt.default.join(ne.STATE,"settings.json");function Ln(){for(let e of[ne.ROOT,ne.STATE])se.default.existsSync(e)||se.default.mkdirSync(e,{recursive:!0})}function Mn(e){try{Ln(),se.default.writeFileSync(gr,JSON.stringify(e,null,2),{mode:384})}catch(n){console.error("Error saving state:",n)}}function xo(){try{se.default.existsSync(gr)&&se.default.unlinkSync(gr)}catch{}}function Nn(){try{return Ln(),se.default.existsSync(yr)?JSON.parse(se.default.readFileSync(yr,"utf8")):{machineId:null,key:null,name:"Default",createdAt:null}}catch{return{machineId:null,key:null,name:"Default",createdAt:null}}}function Tt(e){try{Ln(),se.default.writeFileSync(Cn,JSON.stringify({cmd:e,ts:Date.now()}))}catch{}}function Ro(){try{if(!se.default.existsSync(Cn))return null;let e=JSON.parse(se.default.readFileSync(Cn,"utf8"));return se.default.unlinkSync(Cn),e.cmd}catch{return null}}function ot(e,n,r="Default"){try{Ln();let o={machineId:e,key:n,name:r,createdAt:new Date().toISOString()};return se.default.writeFileSync(yr,JSON.stringify(o,null,2),{mode:384}),o}catch(o){return console.error("Error saving key:",o),null}}function bo(){return process.env.CODESPACES==="true"}var pa=wr.default.dirname((0,ko.fileURLToPath)(__importMetaUrl));async function Be(){let e=await St();if(bo()&&process.env.NREMOTE_API_KEY)return ot(e,process.env.NREMOTE_API_KEY,"Codespace");let n=Nn();if(!n.key){let{key:r}=Et(e);n=ot(e,r,"Default")}return n}function Se(){return"2.2.4"}var Ee=A(require("fs"),1),Sr=A(require("path"),1);var Dn=ne.LOGS,zt=Sr.default.join(Dn,qt.fileName),Fn=Sr.default.join(Dn,qt.rotatedName),_o=!1,Po=null;function da(){Ee.default.existsSync(Dn)||Ee.default.mkdirSync(Dn,{recursive:!0})}function ma(){try{if(Ee.default.statSync(zt).size<qt.maxBytes)return;try{Ee.default.rmSync(Fn,{force:!0})}catch{}Ee.default.renameSync(zt,Fn)}catch{}}function ha(){try{let e=Ee.default.statSync(Fn);Date.now()-e.mtimeMs>qt.cleanupAfterDays*864e5&&Ee.default.rmSync(Fn,{force:!0})}catch{}}function Er(e){try{ma(),Ee.default.appendFileSync(zt,e+`
|
|
13
|
+
`)}catch{}}function vr(e){return e.map(n=>{if(n instanceof Error)return n.stack||n.message;if(typeof n=="object")try{return JSON.stringify(n)}catch{return String(n)}return String(n)}).join(" ")}function Oo(){let e=new Date,n=(r,o=2)=>String(r).padStart(o,"0");return`${n(e.getHours())}:${n(e.getMinutes())}:${n(e.getSeconds())}.${n(e.getMilliseconds(),3)}`}var ga=/\x1b\[[0-9;]*m/g,ya=/https?:\/\/[^\s]+/g;function wa(e){return String(e).replace(ga,"").replace(ya,"").replace(/\s+$/g,"")}function Zt(e,n,r){let o=wa(r);if(!o)return;let t=n==="info"?e:`${e}:${n}`,i=`${Oo()} [${t}] ${o}`;if(Er(i),Po)try{Po(i)}catch{}}function va(){process.on("uncaughtException",e=>Zt("crash","error",`uncaughtException: ${e?.stack||e?.message||e}`)),process.on("unhandledRejection",e=>{let n=e instanceof Error?e.stack||e.message:String(e);Zt("crash","error",`unhandledRejection: ${n}`)}),process.on("exit",e=>Er(`${Oo()} [exit] code=${e} pid=${process.pid}`))}function Io(){_o||(_o=!0,da(),ha(),Er(`
|
|
14
|
+
=== SESSION ${new Date().toISOString()} pid=${process.pid} argv=${process.argv.slice(2).join(" ")} ===`),va())}function $o(e=60){try{return Ee.default.readFileSync(zt,"utf8").split(`
|
|
15
|
+
`).filter(Boolean).slice(-e)}catch{return[]}}function J(e){return{info:(...n)=>Zt(e,"info",vr(n)),warn:(...n)=>Zt(e,"warn",vr(n)),error:(...n)=>Zt(e,"error",vr(n))}}var en=zt;var Co=(e=0)=>n=>`\x1B[${n+e}m`,Lo=(e=0)=>n=>`\x1B[${38+e};5;${n}m`,Mo=(e=0)=>(n,r,o)=>`\x1B[${38+e};2;${n};${r};${o}m`,M={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]}},Tl=Object.keys(M.modifier),Sa=Object.keys(M.color),Ea=Object.keys(M.bgColor),xl=[...Sa,...Ea];function Ta(){let e=new Map;for(let[n,r]of Object.entries(M)){for(let[o,t]of Object.entries(r))M[o]={open:`\x1B[${t[0]}m`,close:`\x1B[${t[1]}m`},r[o]=M[o],e.set(t[0],t[1]);Object.defineProperty(M,n,{value:r,enumerable:!1})}return Object.defineProperty(M,"codes",{value:e,enumerable:!1}),M.color.close="\x1B[39m",M.bgColor.close="\x1B[49m",M.color.ansi=Co(),M.color.ansi256=Lo(),M.color.ansi16m=Mo(),M.bgColor.ansi=Co(10),M.bgColor.ansi256=Lo(10),M.bgColor.ansi16m=Mo(10),Object.defineProperties(M,{rgbToAnsi256:{value(n,r,o){return n===r&&r===o?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(n){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!r)return[0,0,0];let[o]=r;o.length===3&&(o=[...o].map(i=>i+i).join(""));let t=Number.parseInt(o,16);return[t>>16&255,t>>8&255,t&255]},enumerable:!1},hexToAnsi256:{value:n=>M.rgbToAnsi256(...M.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value(n){if(n<8)return 30+n;if(n<16)return 90+(n-8);let r,o,t;if(n>=232)r=((n-232)*10+8)/255,o=r,t=r;else{n-=16;let a=n%36;r=Math.floor(n/36)/5,o=Math.floor(a/6)/5,t=a%6/5}let i=Math.max(r,o,t)*2;if(i===0)return 30;let s=30+(Math.round(t)<<2|Math.round(o)<<1|Math.round(r));return i===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(n,r,o)=>M.ansi256ToAnsi(M.rgbToAnsi256(n,r,o)),enumerable:!1},hexToAnsi:{value:n=>M.ansi256ToAnsi(M.hexToAnsi256(n)),enumerable:!1}}),M}var xa=Ta(),he=xa;var Bn=A(require("node:process"),1),Do=A(require("node:os"),1),Tr=A(require("node:tty"),1);function le(e,n=globalThis.Deno?globalThis.Deno.args:Bn.default.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",o=n.indexOf(r+e),t=n.indexOf("--");return o!==-1&&(t===-1||o<t)}var{env:N}=Bn.default,Un;le("no-color")||le("no-colors")||le("color=false")||le("color=never")?Un=0:(le("color")||le("colors")||le("color=true")||le("color=always"))&&(Un=1);function Ra(){if("FORCE_COLOR"in N)return N.FORCE_COLOR==="true"?1:N.FORCE_COLOR==="false"?0:N.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(N.FORCE_COLOR,10),3)}function ba(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Aa(e,{streamIsTTY:n,sniffFlags:r=!0}={}){let o=Ra();o!==void 0&&(Un=o);let t=r?Un:o;if(t===0)return 0;if(r){if(le("color=16m")||le("color=full")||le("color=truecolor"))return 3;if(le("color=256"))return 2}if("TF_BUILD"in N&&"AGENT_NAME"in N)return 1;if(e&&!n&&t===void 0)return 0;let i=t||0;if(N.TERM==="dumb")return i;if(Bn.default.platform==="win32"){let s=Do.default.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in N)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in N)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in N)||N.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in N)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(N.TEAMCITY_VERSION)?1:0;if(N.COLORTERM==="truecolor"||N.TERM==="xterm-kitty"||N.TERM==="xterm-ghostty"||N.TERM==="wezterm")return 3;if("TERM_PROGRAM"in N){let s=Number.parseInt((N.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(N.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(N.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(N.TERM)||"COLORTERM"in N?1:i}function No(e,n={}){let r=Aa(e,{streamIsTTY:e&&e.isTTY,...n});return ba(r)}var ka={stdout:No({isTTY:Tr.default.isatty(1)}),stderr:No({isTTY:Tr.default.isatty(2)})},Fo=ka;function Uo(e,n,r){let o=e.indexOf(n);if(o===-1)return e;let t=n.length,i=0,s="";do s+=e.slice(i,o)+n+r,i=o+t,o=e.indexOf(n,i);while(o!==-1);return s+=e.slice(i),s}function Bo(e,n,r,o){let t=0,i="";do{let s=e[o-1]==="\r";i+=e.slice(t,s?o-1:o)+n+(s?`\r
|
|
16
16
|
`:`
|
|
17
17
|
`)+r,t=o+1,o=e.indexOf(`
|
|
18
|
-
`,t)}while(o!==-1);return i+=e.slice(t),i}var{stdout:
|
|
19
|
-
`);return i!==-1&&(n=
|
|
20
|
-
`),(0,
|
|
18
|
+
`,t)}while(o!==-1);return i+=e.slice(t),i}var{stdout:Ho,stderr:jo}=Fo,xr=Symbol("GENERATOR"),xt=Symbol("STYLER"),tn=Symbol("IS_EMPTY"),Ko=["ansi","ansi","ansi256","ansi16m"],Rt=Object.create(null),_a=(e,n={})=>{if(n.level&&!(Number.isInteger(n.level)&&n.level>=0&&n.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=Ho?Ho.level:0;e.level=n.level===void 0?r:n.level};var Pa=e=>{let n=(...r)=>r.join(" ");return _a(n,e),Object.setPrototypeOf(n,nn.prototype),n};function nn(e){return Pa(e)}Object.setPrototypeOf(nn.prototype,Function.prototype);for(let[e,n]of Object.entries(he))Rt[e]={get(){let r=Hn(this,br(n.open,n.close,this[xt]),this[tn]);return Object.defineProperty(this,e,{value:r}),r}};Rt.visible={get(){let e=Hn(this,this[xt],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var Rr=(e,n,r,...o)=>e==="rgb"?n==="ansi16m"?he[r].ansi16m(...o):n==="ansi256"?he[r].ansi256(he.rgbToAnsi256(...o)):he[r].ansi(he.rgbToAnsi(...o)):e==="hex"?Rr("rgb",n,r,...he.hexToRgb(...o)):he[r][e](...o),Oa=["rgb","hex","ansi256"];for(let e of Oa){Rt[e]={get(){let{level:r}=this;return function(...o){let t=br(Rr(e,Ko[r],"color",...o),he.color.close,this[xt]);return Hn(this,t,this[tn])}}};let n="bg"+e[0].toUpperCase()+e.slice(1);Rt[n]={get(){let{level:r}=this;return function(...o){let t=br(Rr(e,Ko[r],"bgColor",...o),he.bgColor.close,this[xt]);return Hn(this,t,this[tn])}}}}var Ia=Object.defineProperties(()=>{},{...Rt,level:{enumerable:!0,get(){return this[xr].level},set(e){this[xr].level=e}}}),br=(e,n,r)=>{let o,t;return r===void 0?(o=e,t=n):(o=r.openAll+e,t=n+r.closeAll),{open:e,close:n,openAll:o,closeAll:t,parent:r}},Hn=(e,n,r)=>{let o=(...t)=>$a(o,t.length===1?""+t[0]:t.join(" "));return Object.setPrototypeOf(o,Ia),o[xr]=e,o[xt]=n,o[tn]=r,o},$a=(e,n)=>{if(e.level<=0||!n)return e[tn]?"":n;let r=e[xt];if(r===void 0)return n;let{openAll:o,closeAll:t}=r;if(n.includes("\x1B"))for(;r!==void 0;)n=Uo(n,r.close,r.open),r=r.parent;let i=n.indexOf(`
|
|
19
|
+
`);return i!==-1&&(n=Bo(n,t,o,i)),o+n+t};Object.defineProperties(nn.prototype,Rt);var Ca=nn(),Ol=nn({level:jo?jo.level:0});var m=Ca;var W=require("fs"),si=require("url"),on=require("child_process"),xe=A(require("path"),1),kt=A(require("os"),1);var bt=A(require("fs"),1),Ar=A(require("path"),1),Go=A(require("os"),1),Wo=require("child_process"),jn=Ar.default.join(Go.default.homedir(),".9remote","pids");function La(){try{bt.default.existsSync(jn)||bt.default.mkdirSync(jn,{recursive:!0})}catch{}}function kr(e){return Ar.default.join(jn,`${e}.pid`)}function He(e,n){if(n)try{La(),bt.default.writeFileSync(kr(e),String(n))}catch{}}function Kn(e){try{let n=bt.default.readFileSync(kr(e),"utf8").trim(),r=parseInt(n,10);return Number.isFinite(r)&&r>0?r:null}catch{return null}}function je(e){try{bt.default.unlinkSync(kr(e))}catch{}}function Vo(e){if(!e)return!1;try{return process.kill(e,0),!0}catch{return!1}}function Ma(e){let n=Kn(e);if(je(e),!n)return!1;try{process.platform==="win32"?(0,Wo.execSync)(`taskkill /F /T /PID ${n}`,{stdio:"ignore",windowsHide:!0}):process.kill(n,"SIGKILL")}catch{}return!0}var Na=["cloudflared","agent"];function Yo(){for(let e of Na)Ma(e)}function qo(){return jn}var at=require("child_process"),C=require("fs"),it=require("path"),Pr=A(require("os"),1),st=A(require("path"),1),Qo=require("url");var Wn=(0,it.join)(ne.LOGS,"autostart.log"),Gn="cc.9remote.agent",Vn="9Remote",Yn=["--tray","--skip-update","--start"],rn=Pr.default.homedir(),Jo=st.default.dirname((0,Qo.fileURLToPath)(__importMetaUrl)),Q={darwin:(0,it.join)(rn,"Library","LaunchAgents",`${Gn}.plist`),linux:(0,it.join)(rn,".config","autostart",`${Gn}.desktop`),linuxSystemd:(0,it.join)(rn,".config","systemd","user",`${Gn}.service`),win:(0,it.join)(process.env.APPDATA||"","Microsoft","Windows","Start Menu","Programs","Startup",`${Vn}.vbs`)};function Ke(){for(let e=Jo,n=null;e!==n;n=e,e=st.default.dirname(e)){let r=st.default.join(e,"package.json");if((0,C.existsSync)(r)){try{let o=JSON.parse((0,C.readFileSync)(r,"utf8"));if(o.name!==te)continue;let t=typeof o.bin=="string"?o.bin:o.bin?.[te];if(t){let i=st.default.resolve(e,t);if((0,C.existsSync)(i))return i}}catch{}break}}return process.argv[1]||st.default.resolve(Jo,"..","index.js")}function Te(){return process.execPath}function Xo(){return process.versions.electron?"env ELECTRON_RUN_AS_NODE=1 ":""}function Zo(e){let n=Te(),r=Ke();if(process.platform==="win32"){let t=e.join(" "),i=(0,it.join)(Pr.default.tmpdir(),`${te}-launch.vbs`);return(0,C.writeFileSync)(i,`CreateObject("WScript.Shell").Run """${n}"" ""${r}"" ${t}", 0, False
|
|
20
|
+
`),(0,at.execFile)("wscript.exe",[i],{windowsHide:!0}).unref?.(),null}let o=(0,at.spawn)(n,[r,...e],{detached:!0,stdio:"ignore"});return o.unref(),o.pid||null}function zo(){let e=st.default.dirname(Te()),n=["/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin","/opt/homebrew/bin"];return n.includes(e)||n.unshift(e),n.join(":")}function _r(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Da(e,n){let r=[e,n,...Yn].map(o=>` <string>${_r(o)}</string>`).join(`
|
|
21
21
|
`);return`<?xml version="1.0" encoding="UTF-8"?>
|
|
22
22
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
23
23
|
<plist version="1.0">
|
|
@@ -35,9 +35,9 @@ ${r}
|
|
|
35
35
|
<key>EnvironmentVariables</key>
|
|
36
36
|
<dict>
|
|
37
37
|
<key>PATH</key>
|
|
38
|
-
<string>${
|
|
38
|
+
<string>${_r(zo())}</string>
|
|
39
39
|
<key>HOME</key>
|
|
40
|
-
<string>${
|
|
40
|
+
<string>${_r(rn)}</string>
|
|
41
41
|
</dict>
|
|
42
42
|
<key>StandardOutPath</key>
|
|
43
43
|
<string>${Wn}</string>
|
|
@@ -45,36 +45,37 @@ ${r}
|
|
|
45
45
|
<string>${Wn}</string>
|
|
46
46
|
</dict>
|
|
47
47
|
</plist>
|
|
48
|
-
`}function
|
|
49
|
-
WshShell.Run """${
|
|
50
|
-
`}function
|
|
48
|
+
`}function Fa(){return(0,C.existsSync)(Q.darwin)}function Ua(){let e=Yn.join(" ");return`Set WshShell = CreateObject("WScript.Shell")
|
|
49
|
+
WshShell.Run """${Te()}"" ""${Ke()}"" ${e}", 0, False
|
|
50
|
+
`}function Ba(){try{(0,at.execFileSync)("reg",["DELETE","HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run","/V",Vn,"/F"],{windowsHide:!0,stdio:"ignore"})}catch{}}function Ha(){return(0,C.existsSync)(Q.win)}function ja(){let e=`${Te()} ${Ke()} ${Yn.join(" ")}`;return`[Desktop Entry]
|
|
51
51
|
Type=Application
|
|
52
52
|
Name=${Vn}
|
|
53
53
|
Exec=${e}
|
|
54
54
|
X-GNOME-Autostart-enabled=true
|
|
55
55
|
NoDisplay=false
|
|
56
56
|
Terminal=false
|
|
57
|
-
`}function
|
|
57
|
+
`}function Ka(){let e=Yn.map(n=>`'${n}'`).join(" ");return`[Unit]
|
|
58
58
|
Description=${Vn} Agent
|
|
59
59
|
After=network-online.target
|
|
60
60
|
Wants=network-online.target
|
|
61
61
|
|
|
62
62
|
[Service]
|
|
63
63
|
Type=simple
|
|
64
|
-
ExecStart=${
|
|
64
|
+
ExecStart=${Te()} ${Ke()} ${e}
|
|
65
65
|
Restart=always
|
|
66
66
|
RestartSec=10
|
|
67
|
-
Environment=PATH=${
|
|
68
|
-
Environment=HOME=${
|
|
67
|
+
Environment=PATH=${zo()}
|
|
68
|
+
Environment=HOME=${rn}
|
|
69
69
|
StandardOutput=append:${Wn}
|
|
70
70
|
StandardError=append:${Wn}
|
|
71
71
|
|
|
72
72
|
[Install]
|
|
73
73
|
WantedBy=default.target
|
|
74
|
-
`}function
|
|
74
|
+
`}function Ga(e){try{return(0,at.execFileSync)("systemctl",["--user",...e],{stdio:"ignore"}),!0}catch{return!1}}function Wa(){return(0,C.existsSync)(Q.linux)||(0,C.existsSync)(Q.linuxSystemd)}async function Va(){try{if(process.platform==="darwin")return Fa();if(process.platform==="win32")return await Ha();if(process.platform==="linux")return Wa()}catch{}return!1}async function ei(){try{if(process.platform==="win32"&&Ba(),!await Va())return!1;if(process.platform==="darwin"){let e=Da(Te(),Ke());return((0,C.existsSync)(Q.darwin)?(0,C.readFileSync)(Q.darwin,"utf8"):"")===e?!1:((0,C.writeFileSync)(Q.darwin,e),!0)}if(process.platform==="win32"){let e=Ua();return((0,C.existsSync)(Q.win)?(0,C.readFileSync)(Q.win,"utf8"):"")===e?!1:((0,C.writeFileSync)(Q.win,e),!0)}if(process.platform==="linux"){if((0,C.existsSync)(Q.linuxSystemd)){let e=Ka();return(0,C.readFileSync)(Q.linuxSystemd,"utf8")===e?!1:((0,C.writeFileSync)(Q.linuxSystemd,e),Ga(["daemon-reload"]),!0)}if((0,C.existsSync)(Q.linux)){let e=ja();return(0,C.readFileSync)(Q.linux,"utf8")===e?!1:((0,C.writeFileSync)(Q.linux,e),!0)}}}catch{}return!1}var D="https://9remote.cc",ti=3e4,ni=500,Or=300,ge={cmdMs:1e3,pendingApprovalMs:3e3,statsMs:5e3,serverReadyIntervalMs:200,serverReadyTimeoutMs:5e3,bgServerReadyTimeoutMs:15e3,bgServerReadyIntervalMs:300},Ge={intervalMs:2e3,timeoutMs:18e4,fetchTimeoutMs:5e3,dnsTimeoutMs:2e3,maxLogEntries:80,postReadyHoldMs:2e3},re={killCloudflaredMs:500,killCloudflaredTuiMs:300,serverBootMs:2e3,trayReadyMs:1e3,postReadyHoldMs:2e3,bgSpawnFlushMs:400},$e={maxLogLines:200,headerWidth:44},At={checkIntervalMs:36e5,connectCheckDebounceMs:9e5,maxRetry:3,retryDelayMs:3e3,verifyTimeoutMs:15e3,lockTtlMs:3e5,lockFile:"update.lock"},ri=5e3,oi=2,ii=3e4,ue={orange:m.rgb(230,138,110),orangeDim:m.rgb(200,120,95)};var Ya=xe.default.dirname((0,si.fileURLToPath)(__importMetaUrl)),ai=3e3;var Jn=2208,Ir=xe.default.join(kt.default.homedir(),".9remote","cloudflared.pid");function qa(){try{Yo()}catch{}try{if((0,W.existsSync)(Ir)){let e=parseInt((0,W.readFileSync)(Ir,"utf8"));if(Number.isFinite(e))try{process.kill(e)}catch{}try{(0,W.unlinkSync)(Ir)}catch{}}}catch{}try{process.platform==="win32"?(0,on.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${Jn}') do taskkill /F /PID %a`,{stdio:"ignore",windowsHide:!0}):(0,on.execSync)(`lsof -ti:${Jn} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}if(process.platform==="win32"){let e=Date.now()+1500;for(;Date.now()<e;);}}function ci(){return"2.2.4"}function li(e,n){let r=e.split(".").map(Number),o=n.split(".").map(Number);for(let t=0;t<3;t++){if(o[t]>r[t])return!0;if(o[t]<r[t])return!1}return!1}function Ja(){return process.env.CODESPACES==="true"||process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN?"GitHub Codespaces":(0,W.existsSync)("/.dockerenv")?"Docker":null}function Qn(){qa()}async function ui(){try{let e=ci();if(!e)return null;let n=await G(dr,{signal:AbortSignal.timeout(ai)});if(!n.ok)return null;let{version:r}=await n.json();return r&&li(e,r)?{current:e,latest:r}:null}catch{return null}}var qn=xe.default.join(ne.STATE,At.lockFile);function Qa(){try{if((0,W.existsSync)(qn)){let{pid:e,ts:n}=JSON.parse((0,W.readFileSync)(qn,"utf8")),r=Date.now()-n<At.lockTtlMs,o=!1;try{process.kill(e,0),o=!0}catch{}if(r&&o)return!1}}catch{}try{(0,W.writeFileSync)(qn,JSON.stringify({pid:process.pid,ts:Date.now()}))}catch{}return!0}async function Xa(){try{let e=await G(dr,{signal:AbortSignal.timeout(ai)});if(!e.ok)return null;let{version:n}=await e.json();return n||null}catch{return null}}function Za(){try{if(process.env.NREMOTE_REGISTRY)return`--registry ${new URL(process.env.NREMOTE_REGISTRY).origin}`}catch{}return""}function za(){let e=Ke(),n=xe.default.sep;for(let r of[`${n}lib${n}node_modules${n}`,`${n}node_modules${n}`]){let o=e.indexOf(r);if(o>0)return`--prefix "${e.slice(0,o)}"`}return""}function ec(){let e=process.env.NREMOTE_NPM_CLI;return e&&(0,W.existsSync)(e)?process.platform==="win32"?`"${Te()}" "${e}"`:`env ELECTRON_RUN_AS_NODE=1 "${Te()}" "${e}"`:"npm"}function tc({currentVersion:e,latest:n,agentPid:r}){let o=qo(),t=Za(),i=Te(),s=Xo(),a=Ke(),c=qn,l=`--prefer-online --no-audit --no-fund ${t} ${za()}`.trim(),u=ec();if(process.platform==="win32"){let d=xe.default.join(kt.default.tmpdir(),`${te}-restart.vbs`),h=`@echo off
|
|
75
75
|
setlocal EnableDelayedExpansion
|
|
76
76
|
set "NODE=${i}"
|
|
77
|
-
set "CLI=${
|
|
77
|
+
set "CLI=${a}"
|
|
78
|
+
${process.env.NREMOTE_NPM_CLI?'set "ELECTRON_RUN_AS_NODE=1"':""}
|
|
78
79
|
|
|
79
80
|
:waitloop
|
|
80
81
|
tasklist /FI "PID eq ${r}" 2>nul | find "${r}" >nul
|
|
@@ -95,10 +96,10 @@ timeout /t 3 /nobreak >nul
|
|
|
95
96
|
set ATTEMPT=0
|
|
96
97
|
:installloop
|
|
97
98
|
set /a ATTEMPT+=1
|
|
98
|
-
call
|
|
99
|
+
call ${u} install -g ${Ie} ${l} >nul 2>&1
|
|
99
100
|
if !ERRORLEVEL! EQU 0 goto verify
|
|
100
|
-
if !ATTEMPT! GEQ ${
|
|
101
|
-
call
|
|
101
|
+
if !ATTEMPT! GEQ ${At.maxRetry} (
|
|
102
|
+
call ${u} install -g ${Ie} ${l} --omit=optional >nul 2>&1
|
|
102
103
|
goto verify
|
|
103
104
|
)
|
|
104
105
|
timeout /t 3 /nobreak >nul
|
|
@@ -106,7 +107,7 @@ goto installloop
|
|
|
106
107
|
|
|
107
108
|
:verify
|
|
108
109
|
set "NEWVER="
|
|
109
|
-
set "VERFILE=%TEMP%\\${
|
|
110
|
+
set "VERFILE=%TEMP%\\${te}-ver.txt"
|
|
110
111
|
"%NODE%" "%CLI%" --version > "%VERFILE%" 2>nul
|
|
111
112
|
REM Read first line + strip surrounding whitespace/CR via for/f tokens
|
|
112
113
|
for /f "usebackq tokens=* delims= " %%V in ("%VERFILE%") do (
|
|
@@ -117,15 +118,15 @@ for /f "usebackq tokens=* delims= " %%V in ("%VERFILE%") do (
|
|
|
117
118
|
del /f /q "%VERFILE%" >nul 2>&1
|
|
118
119
|
if defined NEWVER set "NEWVER=!NEWVER: =!"
|
|
119
120
|
if not "!NEWVER!"=="${n}" (
|
|
120
|
-
call
|
|
121
|
+
call ${u} install -g ${te}@${e} ${l} >nul 2>&1
|
|
121
122
|
)
|
|
122
|
-
del /f /q "${
|
|
123
|
+
del /f /q "${c}" >nul 2>&1
|
|
123
124
|
|
|
124
|
-
wscript "${
|
|
125
|
+
wscript "${d}"
|
|
125
126
|
exit /b 0
|
|
126
|
-
`,
|
|
127
|
-
`);let
|
|
128
|
-
`),{shellCmd:["wscript.exe",[
|
|
127
|
+
`,w=xe.default.join(kt.default.tmpdir(),`${te}-update.bat`);(0,W.writeFileSync)(w,h),(0,W.writeFileSync)(d,'CreateObject("WScript.Shell").Run """%NODE%"" ""%CLI%"" --tray --skip-update --start", 0, False'.replace("%NODE%",i).replace("%CLI%",a)+`
|
|
128
|
+
`);let S=xe.default.join(kt.default.tmpdir(),`${te}-update.vbs`);return(0,W.writeFileSync)(S,`CreateObject("WScript.Shell").Run "cmd /c ""${w}""", 0, False
|
|
129
|
+
`),{shellCmd:["wscript.exe",[S]],windowsVerbatim:!1}}let f=`#!/bin/bash
|
|
129
130
|
# Wait for agent to exit so it releases the cli.cjs file lock
|
|
130
131
|
while kill -0 ${r} 2>/dev/null; do sleep 1; done
|
|
131
132
|
|
|
@@ -142,112 +143,112 @@ lsof -ti:${Jn} | xargs kill -9 2>/dev/null || true
|
|
|
142
143
|
sleep 2
|
|
143
144
|
|
|
144
145
|
attempt=0
|
|
145
|
-
while [ $attempt -lt ${
|
|
146
|
+
while [ $attempt -lt ${At.maxRetry} ]; do
|
|
146
147
|
attempt=$((attempt+1))
|
|
147
148
|
echo "Installing (attempt $attempt)..."
|
|
148
|
-
if
|
|
149
|
-
if [ $attempt -eq ${
|
|
150
|
-
|
|
149
|
+
if ${u} install -g ${Ie} ${l}; then break; fi
|
|
150
|
+
if [ $attempt -eq ${At.maxRetry} ]; then
|
|
151
|
+
${u} install -g ${Ie} ${l} --omit=optional || true
|
|
151
152
|
fi
|
|
152
153
|
sleep 3
|
|
153
154
|
done
|
|
154
155
|
|
|
155
156
|
# Verify version == latest; roll back if the new binary is broken/wrong (R2)
|
|
156
157
|
# Take first line + strip ANSI escapes so trailing cursor codes don't corrupt compare
|
|
157
|
-
NEWVER=$("${i}" "${
|
|
158
|
+
NEWVER=$(${s}"${i}" "${a}" --version 2>/dev/null | head -1 | sed 's/\x1B[[0-9;?]*[a-zA-Z]//g' | tr -d '[:space:]')
|
|
158
159
|
if [ "$NEWVER" != "${n}" ]; then
|
|
159
160
|
echo "Verify failed (got $NEWVER, want ${n}), rolling back to ${e}..."
|
|
160
|
-
|
|
161
|
+
${u} install -g ${te}@${e} ${l} || true
|
|
161
162
|
fi
|
|
162
163
|
|
|
163
|
-
rm -f "${
|
|
164
|
-
"${i}" "${
|
|
165
|
-
`,
|
|
166
|
-
`)}function
|
|
164
|
+
rm -f "${c}"
|
|
165
|
+
${s}"${i}" "${a}" --tray --skip-update --start
|
|
166
|
+
`,p=xe.default.join(kt.default.tmpdir(),`${te}-update.sh`);return(0,W.writeFileSync)(p,f,{mode:493}),{shellCmd:["sh",[p]],windowsVerbatim:!1}}async function fi(){let e=ci();if(!e||Ja())return!1;let n=await Xa();if(!n||!li(e,n)||!Qa())return!1;let{shellCmd:r,windowsVerbatim:o}=tc({currentVersion:e,latest:n,agentPid:process.pid});return(0,on.spawn)(r[0],r[1],{detached:!0,stdio:"ignore",windowsHide:!0,windowsVerbatimArguments:o}).unref(),setTimeout(()=>process.exit(0),500),!0}var bi=A(require("os"),1);var er=A(require("readline"),1),mi=A(require("http"),1);var $r=require("child_process"),nc={screenRecording:"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture",accessibility:"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"};function Xn(e){let n=nc[e];n&&process.platform==="darwin"&&(0,$r.exec)(`open "${n}"`,()=>{})}function ye({strategy:e,baseMs:n,maxMs:r},o){let t=Math.max(1,o),i=e==="exp"?n*Math.pow(2,t-1):n*t;return Math.min(i,r)}async function pi({config:e,task:n,label:r="task",log:o=()=>{},ctx:t={}}){let i=0;for(;!t.cancelled;){i++;try{if(await n(i))return!0}catch(a){o(`\u274C ${r} attempt ${i} error: ${a?.message||a}`)}if(t.cancelled)return!1;let s=ye(e,i);o(`\u{1F504} ${r} retry in ${s}ms (attempt ${i})`),await new Promise(a=>setTimeout(a,s))}return!1}var T={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"},hi=()=>Math.min(44,process.stdout.columns||44);function Lr(e,n=null){let o=hi()-2,t=(a="")=>{let c=a.replace(/\x1b\[[0-9;]*m/g,""),l=Math.max(0,o-c.length);return T.orange+"\u2551"+T.reset+a+" ".repeat(l)+T.orange+"\u2551"+T.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 T.orange+"\u2551"+T.reset+" ".repeat(u)+c(a)+" ".repeat(f)+T.orange+"\u2551"+T.reset},s=["",T.orange+"\u2554"+"\u2550".repeat(o)+"\u2557"+T.reset,t(),i(`\u{1F680} 9Remote v${e}`,a=>T.bold+T.orange+a+T.reset),i("Remote terminal access from anywhere",a=>T.dim+a+T.reset),t()];return n&&(s.push(i(`\u2B06 New version v${n} available!`,a=>T.yellow+T.bold+a+T.reset)),s.push(i(`Run: npm i -g ${Ie}`,a=>T.dim+a+T.reset)),s.push(t())),s.push(T.orange+"\u255A"+"\u2550".repeat(o)+"\u255D"+T.reset),s.push(""),s.join(`
|
|
167
|
+
`)}function Pt(e,n=null){console.log(Lr(e,n))}var di=["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"],Cr=[{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"}],rc=process.platform==="win32",oc=rc?120:80;process.on("exit",()=>process.stdout.write("\x1B[?25h"));var gi=(e,n)=>{process.stdout.write("\x1B[?25h"),process.listenerCount(e)<=1&&process.exit(n)};process.on("SIGINT",()=>gi("SIGINT",130));process.on("SIGTERM",()=>gi("SIGTERM",143));var Ce=0,ct=null,Zn=0,Re=-1,sn=null,_t=null,zn=!1;function yi(){let e=[],n=Re===Cr.length-1;return Cr.forEach((r,o)=>{let t=o===Re&&sn?sn:r.desc;if(o<Re||n&&o===Re)e.push(` ${T.green}\u2713${T.reset} ${T.dim}${r.label}${T.reset}`),_t&&o===_t.afterIdx&&e.push(` ${T.green}\u2713${T.reset} ${T.cyan}${_t.text}${T.reset}`);else if(o===Re){let i=di[Zn%di.length];e.push(` ${T.orange}${i}${T.reset} ${T.bold}${r.label}${T.reset} ${T.dim}${t}${T.reset}`)}else e.push(` ${T.dim}\u25CB ${r.label}${T.reset}`)}),e}function wi(){let e=yi();Ce>0&&process.stdout.write(`\x1B[${Ce}A\x1B[0J`),process.stdout.write(e.join(`
|
|
167
168
|
`)+`
|
|
168
|
-
`),Ce=e.length}function
|
|
169
|
-
`))process.stdout.write(
|
|
170
|
-
`);e&&process.stdout.write(`${
|
|
169
|
+
`),Ce=e.length}function vi(){if(Ce===0||Re<0)return;let e=yi();if(e.length!==Ce){wi();return}let n=Re+(_t&&_t.afterIdx<Re?1:0),r=Ce-n;process.stdout.write(`\x1B[${r}A\r\x1B[2K${e[n]}\x1B[${r}B\r`)}function ic(){zn||(process.stdout.write("\x1B[?25l"),zn=!0)}function Si(){zn&&(process.stdout.write("\x1B[?25h"),zn=!1)}function Ei(e,n=!1,r=null){ct&&(clearInterval(ct),ct=null),Re=e,sn=r,Zn=0,n||(Ce=0),wi(),e<Cr.length-1?(ic(),ct=setInterval(()=>{Zn++,vi()},oc)):Si()}function Ot(e){sn=e,Ce>0&&vi()}function Ti(){ct&&(clearInterval(ct),ct=null),Si(),Ce=0,Re=-1,sn=null,_t=null,Zn=0}function be(e,n,r=0,o="",t=null,i=null){return new Promise(s=>{let a=r,c=!0,l=!0,u=process.platform==="win32",f=()=>{if(!c)return;process.stdout.write(l?"\x1B[2J\x1B[H":"\x1B[H"),l=!1;let w=typeof o=="function"?o():o;if(w)for(let S of w.split(`
|
|
170
|
+
`))process.stdout.write(S+`\x1B[K
|
|
171
|
+
`);e&&process.stdout.write(`${T.dim}${e}${T.reset}\x1B[K
|
|
171
172
|
\x1B[K
|
|
172
|
-
`),n.forEach((
|
|
173
|
-
`)}),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,
|
|
173
|
+
`),n.forEach((S,O)=>{let x=O===a?u?">":"\u2605":u?" ":"\u2606",b=O===a?` \x1B[7m${T.bold}${x} ${S.label}${T.reset}`:` ${x} ${S.label}`;process.stdout.write(b+`\x1B[K
|
|
174
|
+
`)}),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,S)=>{!c||!S||(S.name==="up"?(a=(a-1+n.length)%n.length,f()):S.name==="down"?(a=(a+1)%n.length,f()):S.name==="return"?(p(),s(a)):S.name==="escape"?(p(),s(-1)):S.ctrl&&S.name==="c"&&(p(),i&&i(),process.exit(0)))};if(process.stdin.removeAllListeners("keypress"),er.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 Mr(e){return new Promise(n=>{if(process.stdin.removeAllListeners("keypress"),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}if(process.stdin.pause(),process.stdout.write(`${e} (y/N): `),er.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{}process.stdin.resume();let r=(o,t)=>{if(!t)return;if(process.stdin.removeListener("keypress",r),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),t.ctrl&&t.name==="c"&&(process.stdout.write(`
|
|
174
175
|
`),process.exit(0));let i=(t.name||"").toLowerCase()==="y";process.stdout.write((i?"y":"n")+`
|
|
175
|
-
`),n(i)};process.stdin.on("keypress",r)})}function
|
|
176
|
+
`),n(i)};process.stdin.on("keypress",r)})}function xi(e,n){return new Promise(r=>{let o=e?e.slice(0,8):"unknown",t=hi(),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=`${T.orange}${"\u2550".repeat(t)}${T.reset}`;if(process.stdout.write(`\x1B[2J\x1B[H
|
|
176
177
|
${s}
|
|
177
|
-
${
|
|
178
|
+
${T.orange}${T.bold} \u{1F514} New Device Connection${T.reset}
|
|
178
179
|
${s}
|
|
179
|
-
Device: ${
|
|
180
|
-
IP: ${
|
|
180
|
+
Device: ${T.cyan}${o}...${T.reset}
|
|
181
|
+
IP: ${T.cyan}${n}${T.reset}
|
|
181
182
|
${s}
|
|
182
183
|
|
|
183
|
-
Allow this device? ${
|
|
184
|
+
Allow this device? ${T.dim}(y/n)${T.reset} `),er.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,S=w?`${T.green}y${T.reset}
|
|
184
185
|
|
|
185
|
-
${
|
|
186
|
-
`:`${
|
|
186
|
+
${T.green}\u2713 Device approved${T.reset}
|
|
187
|
+
`:`${T.red}n${T.reset}
|
|
187
188
|
|
|
188
|
-
${
|
|
189
|
-
`;process.stdout.write(
|
|
190
|
-
`);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);n(w.type,w)}catch{}d=""}}),l.on("end",()=>{t&&clearTimeout(t),o||setTimeout(a,ye(
|
|
191
|
-
`).find(c=>c.includes(r));if(!t){
|
|
192
|
-
`,"utf8");let s=!1,a=()=>{if(!s){s=!0;try{B.default.rmSync(t,{recursive:!0,force:!0})}catch{}}},c=(0,
|
|
193
|
-
`).slice(-5).join(" | ");u(new Error(`cloudflared exited (code=${
|
|
194
|
-
`).map(o=>+o.trim()).filter(Boolean);for(let r of new Set(n))
|
|
195
|
-
${n}`)),
|
|
196
|
-
`+r.trim())})})}async function
|
|
189
|
+
${T.red}\u2717 Device rejected${T.reset}
|
|
190
|
+
`;process.stdout.write(S),setTimeout(()=>{try{a()}catch{}r(w)},500)};process.stdin.on("keypress",c)})}function Ri(e,n){let r=null,o=!1,t=null,i=45e3,s=()=>{t&&clearTimeout(t),t=setTimeout(()=>{try{r?.destroy()}catch{}},i)},a=async()=>{if(o)return;let c=await It();r=mi.default.get(`http://${c}:${e}/api/ui/events`,l=>{let u="";s(),l.on("data",f=>{s(),u+=f.toString();let p=u.split(`
|
|
191
|
+
`);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);n(w.type,w)}catch{}d=""}}),l.on("end",()=>{t&&clearTimeout(t),o||setTimeout(a,ye(ce.sse,1))})}),r.on("error",()=>{t&&clearTimeout(t),o||setTimeout(a,ye(ce.sse,1))})};return a(),()=>{o=!0,t&&clearTimeout(t),r?.destroy()}}var Nr=!1;function Ai(e){Nr=e}var an=null;async function It(){if(an)return an;let e=o=>fetch(`http://${o}:${P}/api/health`,{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok?o:Promise.reject()),r=(await Promise.allSettled(["localhost","127.0.0.1"].map(e))).map((o,t)=>o.status==="fulfilled"?["localhost","127.0.0.1"][t]:null);return an=r.find(o=>o==="localhost")||r.find(Boolean)||null,an||"127.0.0.1"}function ki(){an=null}async function X(e,n){let r=await It();try{return await fetch(`http://${r}:${P}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch{return ki(),null}}async function V(e){let n=await It();try{let r=await fetch(`http://${n}:${P}${e}`);return r.ok?await r.json():null}catch{return ki(),null}}async function U(e){await X("/api/ui/state",e)}async function K(e,n={}){Nr&&Ei(e-1,e>$.PREPARING),await U({step:e,stepDesc:"",...n})}function tr({phase:e,percent:n}){let r=e==="download"?`Downloading tunnel binary ${n??0}%`:"Extracting tunnel binary";Nr&&Ot(r),U({stepDesc:r})}async function oe(){return!!await V("/api/health")}async function Dr(){let[e,n,r,o]=await Promise.all([V("/api/ui/state"),V("/api/device/auto-approve"),V("/api/autostart"),V("/api/sleep-inhibit")]);return{desktopEnabled:!!e?.desktopEnabled,remoteAvailable:!!e?.remoteAvailable,autoApprove:!!n?.enabled,autoStart:!!r?.enabled,sleepInhibitMode:o?.mode||"never",sleepInhibitActive:!!o?.active,sleepInhibitPresets:Array.isArray(o?.presets)?o.presets:[]}}function _i(){let e=bi.default.networkInterfaces();for(let n of Object.values(e))for(let r of n)if(r.family==="IPv4"&&!r.internal)return r.address;return null}var xn=require("child_process"),Rn=A(require("path"),1),Qr=A(require("fs"),1),os=require("url");var B=A(require("fs"),1),Ve=A(require("path"),1),Yr=A(require("https"),1),Ye=A(require("os"),1),Ui=A(require("net"),1),pt=require("child_process");var Pi=A(require("dns"),1),Oi=require("child_process");var sc=2e3,ac=5e3,Ii=new Pi.default.promises.Resolver;Ii.setServers(["1.1.1.1","1.0.0.1","8.8.8.8"]);function $t(){process.platform==="win32"&&(0,Oi.execFile)("ipconfig",["/flushdns"],{windowsHide:!0},()=>{})}async function Fr(e,n=sc){let r=Date.now();try{return{ok:!0,addrs:await Promise.race([Ii.resolve4(e),new Promise((t,i)=>setTimeout(()=>i(Object.assign(new Error("DNS timeout"),{code:"ETIMEOUT"})),n))]),elapsedMs:Date.now()-r}}catch(o){return{ok:!1,code:o.code||o.message,elapsedMs:Date.now()-r}}}async function cn(e,{flushDns:n=!1}={}){let r=Date.now(),o=null;try{o=new URL(e).hostname}catch{}if(n&&$t(),o){let t=await Fr(o);if(!t.ok)return $t(),{ok:!1,dnsCode:t.code,elapsedMs:Date.now()-r}}try{let t=await G(`${e}/api/health`,{signal:AbortSignal.timeout(ac)});return{ok:t.ok,httpStatus:t.status,elapsedMs:Date.now()-r}}catch(t){return{ok:!1,dnsCode:t.cause?.code||t.code||t.message,elapsedMs:Date.now()-r}}}var cc=J("tunnel"),ln=null,un=null,Ct=null,lt=null,We=0,Ur=!1;async function Br(e){try{let n=await It();await fetch(`http://${n}:${P}/api/ui/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch{}}async function $i(){if(!un||Ur)return;let e=await cn(un),n=e.ok?"healthy":"unreachable";if(n===Ct){lt=null,We=0;return}if(n!==lt){lt=n,We=1;return}We++,!(We<oi)&&(cc.info(`${Ct??"init"} \u2192 ${n}${e.ok?"":` (http=${e.httpStatus??"-"} dns=${e.dnsCode??"-"})`}`),Ct=n,lt=null,We=0,await Br({tunnelHealth:{status:n,checkedAt:Date.now()}}))}function Ci(e){if(!e)return fn();e!==un&&(un=e,Ct=null,lt=null,We=0,$t(),ln||(ln=setInterval($i,yo.checkIntervalMs)),$i())}var Li=Ci,Lt=Ci;function Mi(){Ur=!0}function Ni(){Ur=!1}function Mt(e){Ct=e,lt=null,We=0,Br({tunnelHealth:{status:e,checkedAt:Date.now()}})}function fn(){ln&&(clearInterval(ln),ln=null),un=null,Ct=null,lt=null,We=0,Br({tunnelHealth:{status:"unknown",checkedAt:null}})}var fe=J("tunnel"),mn={networkCheckIntervalMs:5e3,networkRestoreDelayMs:2500,internetCheckTimeoutMs:3e3,internetCheckHost:"1.1.1.1",internetCheckPort:443},lc=3e4,Hr=0,hn=null,nr=null,gn=null,yn=null,Dt=!1,pn=0,Wr=!1,ft=null,rr=0,jr=0,Kr=!1,uc=3e4,fc=5e3,dn=Ve.default.join(Ye.default.homedir(),".9remote","bin"),Di="cloudflared",wn=Ye.default.platform()==="win32",pc=wn?`${Di}.exe`:Di,Nt=Ve.default.join(dn,pc),Gr=Ve.default.join(Ye.default.homedir(),".9remote","cloudflared.pid"),ut=!1,dc="2026.6.1",Bi=`https://github.com/cloudflare/cloudflared/releases/download/${dc}`;function Hi(){return new Promise(e=>{let n=new Ui.default.Socket,r=!1,o=t=>{if(!r){r=!0;try{n.destroy()}catch{}e(t)}};n.setTimeout(mn.internetCheckTimeoutMs),n.once("connect",()=>o(!0)),n.once("timeout",()=>o(!1)),n.once("error",()=>o(!1));try{n.connect(mn.internetCheckPort,mn.internetCheckHost)}catch{o(!1)}})}async function mc(){Wr=!0;try{let e=0;for(;;){if(e++,await Hi())return;await new Promise(n=>setTimeout(n,ye(ce.internet,e)))}}finally{Wr=!1}}async function vn(e,n){if(!yn){fe.warn("No restartCallback registered \u2014 skip");return}if(!Dt&&!(Date.now()-jr<fc)){jr=Date.now(),Dt=!0;try{await mc();let r=ye(ce.tunnelRestart,pn+1);await new Promise(o=>setTimeout(o,r)),await yn(e),pn=0,jr=0}catch(r){pn++,fe.error(`restart failed (#${pn}): ${r?.message||r}`),setImmediate(()=>{Dt=!1,vn(e,"retry after fail")});return}finally{Dt=!1}}}var hc={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 gc(){let e=Ye.default.platform(),n=Ye.default.arch(),r=hc[e];if(!r)throw new Error(`Unsupported platform: ${e}`);let o=r[n];if(!o)throw new Error(`Unsupported architecture: ${n} for platform ${e}`);return`${Bi}/${o}`}var yc=150;async function ji(e,n,r){return new Promise((o,t)=>{let i=B.default.createWriteStream(n);Yr.default.get(e,s=>{if([301,302].includes(s.statusCode)){i.close(),B.default.unlinkSync(n),ji(s.headers.location,n,r).then(o).catch(t);return}if(s.statusCode!==200){i.close(),B.default.unlinkSync(n),t(new Error(`Download failed with status ${s.statusCode}`));return}let a=parseInt(s.headers["content-length"]||"0",10),c=0,l=0,u=-1;s.on("data",f=>{if(c+=f.length,!r||!a)return;let p=Date.now(),d=Math.min(100,Math.floor(c/a*100));d!==u&&p-l>=yc&&(l=p,u=d,r(d))}),s.pipe(i),i.on("finish",()=>{r&&a&&r(100),i.close(()=>o(n))}),i.on("error",f=>{i.close(),B.default.unlinkSync(n),t(f)})}).on("error",s=>{i.close(),B.default.existsSync(n)&&B.default.unlinkSync(n),t(s)})})}async function Sn(e){if(B.default.existsSync(dn)||B.default.mkdirSync(dn,{recursive:!0}),B.default.existsSync(Nt))return wn||B.default.chmodSync(Nt,"755"),Nt;let n=gc(),r=n.endsWith(".tgz"),o=r?Ve.default.join(dn,"cloudflared.tgz"):Nt;try{return e?.({phase:"download",percent:0}),await ji(n,o,t=>{e?.({phase:"download",percent:t})}),await wc(n,o),r&&(e?.({phase:"extract"}),(0,pt.execSync)(`tar -xzf "${o}" -C "${dn}"`,{stdio:"pipe",windowsHide:!0}),B.default.unlinkSync(o)),wn||B.default.chmodSync(Nt,"755"),Nt}catch(t){try{B.default.existsSync(o)&&B.default.unlinkSync(o)}catch{}throw console.error("Failed to download cloudflared:",t.message),t}}function Ki(e){return new Promise((n,r)=>{Yr.default.get(e,o=>{if([301,302].includes(o.statusCode))return Ki(o.headers.location).then(n).catch(r);if(o.statusCode!==200)return r(new Error(`HTTP ${o.statusCode}`));let t="";o.on("data",i=>t+=i),o.on("end",()=>n(t))}).on("error",r)})}async function wc(e,n){let r=Ve.default.basename(e),o;try{o=await Ki(`${Bi}/sha256sum.txt`)}catch(c){fe.warn(`sha256 manifest unavailable (${c.message}), skipping verify`);return}let t=o.split(`
|
|
192
|
+
`).find(c=>c.includes(r));if(!t){fe.warn(`No sha256 entry for ${r}, skipping verify`);return}let i=t.trim().split(/\s+/)[0],{createHash:s}=await import("crypto"),a=s("sha256").update(B.default.readFileSync(n)).digest("hex");if(a!==i)throw new Error(`Integrity check failed: SHA256 mismatch (expected ${i}, got ${a})`)}function vc(e){let n=/https:\/\/([a-z0-9-]+)\.trycloudflare\.com/gi,r=[];for(let o of e.matchAll(n))o[1]!=="api"&&r.push(`https://${o[1]}.trycloudflare.com`);return r.length?r[r.length-1]:null}async function Gi(e,n=null,r=null){let o=await Sn();r&&(yn=r),gn=e;let t=B.default.mkdtempSync(Ve.default.join(Ye.default.tmpdir(),"9remote-quick-")),i=Ve.default.join(t,"config.yml");B.default.writeFileSync(i,`# quick-tunnel
|
|
193
|
+
`,"utf8");let s=!1,a=()=>{if(!s){s=!0;try{B.default.rmSync(t,{recursive:!0,force:!0})}catch{}}},c=(0,pt.spawn)(o,["tunnel","--url",`http://localhost:${e}`,"--config",i,"--no-autoupdate","--protocol","http2"],{detached:!1,windowsHide:!0,stdio:["ignore","pipe","pipe"]});return He("cloudflared",c.pid),ut=!1,new Promise((l,u)=>{let f=!1,p=null,d="",h=setTimeout(()=>{f||(f=!0,a(),u(new Error("Quick tunnel timed out after 90s")))},9e4),w=S=>{let O=S.toString();d+=O,d.length>4096&&(d=d.slice(-4096));let x=vc(O);if(x){if(!f){f=!0,p=x,ft=x,rr=Date.now(),clearTimeout(h),a(),Tc(),fe.info(`tunnel ready: ${x}`),l({child:c,tunnelUrl:x});return}x!==p&&(fe.info(`URL rotated: ${x}`),p=x,ft=x,rr=Date.now(),n?.(x))}};c.stdout.on("data",w),c.stderr.on("data",w),c.on("error",S=>{f||(f=!0,clearTimeout(h),a(),u(S))}),c.on("exit",(S,O)=>{if(a(),fe.info(`cloudflared exited (intentional=${ut})`),ut||Mt("unreachable"),!f){f=!0,clearTimeout(h);let x=d.trim().split(`
|
|
194
|
+
`).slice(-5).join(" | ");u(new Error(`cloudflared exited (code=${S}, signal=${O}) output: ${x||"(empty)"}`)),ut||vn(e,`initial spawn failed (code ${S})`);return}ut||vn(e,`quick tunnel exit code ${S}`)})})}function Vr(e){if(wn)try{(0,pt.execSync)(`taskkill /PID ${e} /T /F`,{windowsHide:!0,stdio:"ignore"})}catch{}else try{process.kill(e,"SIGKILL")}catch{}}function Sc(e){try{let n=[];if(wn){let r=`Get-NetTCPConnection -LocalPort ${e} -State Established -ErrorAction SilentlyContinue | Where-Object { (Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).Name -eq 'cloudflared' } | Select-Object -ExpandProperty OwningProcess -Unique`;n=(0,pt.execSync)(`powershell -NoProfile -Command "${r}"`,{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}).split(/\r?\n/).map(t=>+t.trim()).filter(Boolean)}else n=(0,pt.execSync)(`lsof -nP -iTCP:${e} -sTCP:ESTABLISHED 2>/dev/null | awk '/cloudflar/ {print $2}' | sort -u`,{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).split(`
|
|
195
|
+
`).map(o=>+o.trim()).filter(Boolean);for(let r of new Set(n))Vr(r)}catch{}}function qe(){if(!Kr){Kr=!0;try{try{if(B.default.existsSync(Gr)){let n=parseInt(B.default.readFileSync(Gr,"utf8"));Number.isFinite(n)&&(ut=!0,Vr(n)),B.default.unlinkSync(Gr)}}catch{}let e=Kn("cloudflared");ut=!0,e&&(Vr(e),je("cloudflared")),Sc(P)}finally{setTimeout(()=>{Kr=!1},2e3)}}}function Wi(){pn=0,Dt=!1,yn=null,gn=null,ft=null,xc()}var Ec=/^(utun|awdl|llw|anpi|bridge|gif|stf|ipsec|ap|tun|tap|vmnet|veth|docker)/i;function Fi(){let e=Ye.default.networkInterfaces(),n=[];for(let[r,o]of Object.entries(e))if(o&&!Ec.test(r))for(let t of o)!t.internal&&t.family==="IPv4"&&n.push(`${r}:${t.address}`);return n.sort().join("|")}function Tc(){hn||(nr=Fi(),Hr=Date.now(),hn=setInterval(async()=>{let e=Date.now(),n=e-Hr;if(Hr=e,Wr||Dt||!yn||gn==null)return;if(n>lc){if(fe.info(`Sleep/wake detected (gap=${n}ms)`),ft){let s=!1;for(let a=0;a<3;a++){if((await cn(ft)).ok){s=!0;break}a<2&&await new Promise(l=>setTimeout(l,3e3))}if(s)return;fe.info("tunnel unresponsive after sleep \u2192 restarting")}Mt("unreachable"),qe(),vn(gn,"woke from sleep");return}let r=Fi(),o=r!==nr;nr=r;let t=Kn("cloudflared"),i=!t||!Vo(t);if(!(!o&&!i)&&!(o&&!i&&rr&&Date.now()-rr<uc)&&(o&&fe.info("Network change detected"),i&&fe.warn("cloudflared not alive \u2014 watchdog"),Mt("unreachable"),await new Promise(s=>setTimeout(s,mn.networkRestoreDelayMs)),!!await Hi())){if(o&&!i&&ft){let s=!1;for(let a=0;a<2;a++){if((await cn(ft)).ok){s=!0;break}a===0&&await new Promise(l=>setTimeout(l,2e3))}if(s){fe.info("Tunnel survived network change, skip restart");return}}o&&!i&&qe(),vn(gn,o?"network change":"liveness watchdog")}},mn.networkCheckIntervalMs))}function xc(){hn&&(clearInterval(hn),hn=null),nr=null}Bt();var Me=J("server"),is=Rn.default.dirname((0,os.fileURLToPath)(__importMetaUrl)),Pc=Rn.default.resolve(is,"./server.cjs"),ns=Rn.default.resolve(is,"../../index.js");function sr(e){try{process.platform==="win32"?(0,xn.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${e}') do taskkill /F /PID %a`,{stdio:"ignore",windowsHide:!0}):(0,xn.execSync)(`lsof -ti:${e} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}}function Je(e,n,r){let o=null,t=!1,i=!1,s=!0,a=0,c=null,l=()=>{s&&(sr(P),s=!1);let u=process.env.NODE_ENV==="development"&&Qr.default.existsSync(ns),f=u?ns:Pc;Qr.default.existsSync(f)||(Me.error(`Server not found: ${f}`),process.exit(1));let p={...process.env,PORT:String(P)};u||delete p.NODE_ENV,o=(0,xn.spawn)(fo,[f],{cwd:Rn.default.dirname(f),stdio:["ignore","inherit","inherit"],detached:!1,windowsHide:!0,env:po(p)}),c&&clearTimeout(c),c=setTimeout(()=>{a=0},ti),o.on("exit",(d,h)=>{if(c&&(clearTimeout(c),c=null),t)return;if(i){i=!1,Me.info("Restarting server (requested)..."),setTimeout(()=>{l(),r?.()},500);return}Me.error(`Server exited unexpectedly (code: ${d}, signal: ${h})`),a++;let w=ye(ce.server,a);Me.warn(`Restarting server in ${w}ms (fail#${a})`),n&&n(),setTimeout(()=>{l(),r?.()},w)}),o.on("error",d=>{Me.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 ss(e){return e?.restart?e.restart():!1}function dt({serverManager:e,tunnelProcess:n,exit:r=!0,code:o=0}={}){try{fn()}catch{}try{e?.shutdown?.()}catch{}try{n?.kill?.()}catch{}try{qe()}catch{}try{En()}catch{}try{sr(P)}catch{}try{Wi()}catch{}try{xo()}catch{}try{je("agent")}catch{}try{je("cloudflared")}catch{}r&&setTimeout(()=>process.exit(o),ni)}var rs=!1;function Qe(e,n){if(rs)return;rs=!0;let r=!1,o=t=>{r||(r=!0,Me.info(`Stopping 9Remote (${t})...`),dt({serverManager:e,tunnelProcess:n}),Me.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=>{Me.error(`Uncaught exception: ${t?.stack||t?.message||t}`),o("uncaughtException"),setTimeout(()=>process.exit(1),Or)}),process.on("unhandledRejection",t=>{Me.error(`Unhandled rejection: ${t?.stack||t?.message||t}`),o("unhandledRejection"),setTimeout(()=>process.exit(1),Or)})}Bt();var Xr=J("tunnel");async function mt(e,n,r){let o=0;for(;;){o++;try{return await Gi(e,n,r)}catch(t){let i=ye(ce.tunnelSpawn,o);Xr.warn(`spawn attempt ${o} failed: ${t?.message||t} \u2014 retry in ${i}ms`),await new Promise(s=>setTimeout(s,i))}}}function Ht({onUrlUpdate:e,setTunnel:n}){return async r=>{try{let o=await mt(r,e);n(o.child),await e(o.tunnelUrl),Xr.info(`Tunnel restarted: ${o.tunnelUrl}`)}catch(o){Xr.error(`Tunnel restart failed: ${o?.message||o}`)}}}async function Xe(e,n={}){let r=n.intervalMs??Ge.intervalMs,o=n.timeoutMs??Ge.timeoutMs,t=`${e}/api/health`,i=(()=>{try{return new URL(e).hostname}catch{return null}})(),s=Date.now(),a=0,c=[];await U({healthCheck:{running:!0,timeoutMs:o,startedAt:s,logs:[]}});let l=u=>{c.push(u);let f=c.length>Ge.maxLogEntries?c.slice(-Ge.maxLogEntries):c;U({healthCheck:{running:!0,timeoutMs:o,startedAt:s,logs:f}})};for(;Date.now()-s<o;){if(a++,$t(),i){let f=await Fr(i,Ge.dnsTimeoutMs);if(!f.ok){let p=f.code==="ENOTFOUND"||f.code==="ETIMEOUT"||f.code==="ESERVFAIL",d=p?"connecting...":f.code;Ot(`#${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 G(t,{signal:AbortSignal.timeout(Ge.fetchTimeoutMs)}),p=Date.now()-u;if(Ot(`#${a} \u2192 ${f.status}`),l({attempt:a,status:String(f.status),elapsedMs:p,ok:f.ok,time:Date.now()}),f.ok)return await U({healthCheck:{running:!1,timeoutMs:0,startedAt:null,logs:[]}}),await new Promise(d=>setTimeout(d,Ge.postReadyHoldMs)),!0}catch(f){let p=Date.now()-u,d=f.cause?.code||f.code||f.message,h=d==="ENOTFOUND",w=h?"connecting...":d;Ot(`#${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 U({healthCheck:{running:!1,timeoutMs:o,startedAt:s,logs:c}}),!1}var as=J("tunnel"),Zr=null,cs=null,ls=0;async function Ne(e,n){if(n&&n===cs&&Date.now()-ls<ri)return;Zr&&(Zr.cancelled=!0);let r={cancelled:!1};Zr=r;let o=_i();pi({config:ce.urlSync,label:`urlSync ${n}`,log:t=>as.warn(t),ctx:r,task:async()=>{let t=await G(`${D}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:e,tunnelUrl:n,localIp:o?`${o}:${P}`:null})});if(r.cancelled)return!0;if(t.ok)return cs=n,ls=Date.now(),Oc(n),!0;let i=await t.text().catch(()=>"");return as.warn(`urlSync HTTP ${t.status}: ${i.slice(0,200)}`),!1}}),n&&Li(n)}var bn=null;async function Oc(e){if(bn?.url===e)return;let n={url:e};bn=n,Mi();try{let r=await Xe(e,{timeoutMs:ii});if(bn!==n)return;r&&Mt("healthy")}catch{}finally{bn===n&&(bn=null),Ni()}}var oo=A(Cs(),1);var Uc=30;async function jt(e,n){try{let r=await G(`${n}/api/temp-key/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:e,expiryMinutes:Uc})});if(!r.ok){let o=await r.json();throw new Error(o.error||"Failed to create temp key")}return await r.json()}catch(r){return console.error("Error creating temp key:",r),null}}function Bc(e,n="\u{1F4F1} Scan QR to connect:"){console.log(ue.orange(`
|
|
196
|
+
${n}`)),oo.default.generate(e,{small:!0,type:"terminal",margin:0},r=>{console.log(r.trim())})}function Hc(e){return new Promise(n=>{oo.default.generate(e,{small:!0,type:"terminal",margin:0},r=>{n(ue.orangeDim("\u{1F4F1} Scan QR to connect:")+`
|
|
197
|
+
`+r.trim())})})}async function ur(e,n){let r=await jt(e,D);if(!r){console.log(m.red("\u274C Failed to create temp key"));return}let o=`${D}/login?k=${r.tempKey}`,t=Math.min($e.headerWidth,process.stdout.columns||55);await K($.READY,{tunnelUrl:n,oneTimeKey:r.tempKey,oneTimeKeyExpiresAt:r.expiresAt,permanentKey:e,qrUrl:o,workerUrl:D}),Bc(o),console.log(m.gray(`
|
|
197
198
|
QR will expire in 30 minutes (one-time use)
|
|
198
|
-
`)),console.log(
|
|
199
|
+
`)),console.log(ue.orange("\u2550".repeat(t))),console.log(m.white("App URL".padEnd(14))+m.gray(`${D}/login`)),console.log(m.white("One-Time Key".padEnd(14))+ue.orange.bold(r.tempKey)),console.log(m.white("Key".padEnd(14))+m.gray(e)),console.log(ue.orange("\u2550".repeat(t)))}async function An(e,n,r,o=""){let t=Math.min($e.headerWidth,process.stdout.columns||$e.headerWidth),i=[];return e&&r?(i.push(await Hc(r)),i.push(m.gray(`
|
|
199
200
|
QR expires in 30 minutes (one-time use)
|
|
200
201
|
`))):i.push(m.gray(`
|
|
201
202
|
(One-time key used \u2014 generate a new one from menu)
|
|
202
|
-
`)),i.push(
|
|
203
|
-
`)}var
|
|
204
|
-
\u{1F310} UI ready at ${i}`));let s=null;await U({permanentKey:e.key,step:$.STOPPED,theme:r}),
|
|
205
|
-
\u274C Failed to launch background: ${c.message}`)),process.exit(1)}let i=Date.now()+ge.bgServerReadyTimeoutMs,s=!1;for(;Date.now()<i;){if(await
|
|
203
|
+
`)),i.push(ue.orange("\u2550".repeat(t)),m.white("App URL".padEnd(14))+m.gray(`${D}/login`)),ho.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?ue.orange.bold(e)+m.dim(" (expires in 30m)"):m.gray("\u2014")),m.white("Key".padEnd(14))+m.dim(n),ue.orange("\u2550".repeat(t))),i.join(`
|
|
204
|
+
`)}var gt=J("cmd");function et(e,n,r,o){let t=!1;setInterval(async()=>{if(t)return;let i=Ro();if(i){t=!0;try{if(i==="stop-tunnel")await Ls(e,n);else if(i==="restart-tunnel")await Ls(e,n),await Ms(e,n,r);else if(i==="start-tunnel"){if(await Ms(e,n,r)==="alreadyRunning"){t=!1;return}}else i==="regenerate-key"?await jc():i==="shutdown"?Kc(e,n):i==="update"?await fi():i==="restart"&&ss(o?.())}finally{t=!1}}},ge.cmdMs)}async function Ls(e,n){fn();let r=e();r&&(r.kill(),n(null),gt.info("Tunnel stopped")),await K($.STOPPED,{tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null}),ir({tunnelUrl:"",running:!0})}async function Ms(e,n,r){let o=e();if(o)if(o.killed||o.exitCode!=null)n(null);else{let t=await V("/api/ui/state");return await K($.READY,{tunnelUrl:t?.tunnelUrl||""}),"alreadyRunning"}gt.info("Starting tunnel...");try{await K($.PREPARING),await Sn(tr),await K($.CONNECTING);let t=await G(`${D}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:r})});if(!t.ok)throw new Error(`Session create failed: ${t.status}`);await K($.TUNNELING);let i=async c=>{await Ne(r,c),await U({tunnelUrl:c}),Lt(c)},s=await mt(P,i,Ht({onUrlUpdate:i,setTunnel:c=>n(c)}));n(s.child),await K($.VERIFYING),await Xe(s.tunnelUrl)||gt.warn("Tunnel health check timed out, proceeding anyway..."),await Ne(r,s.tunnelUrl),ir({tunnelUrl:s.tunnelUrl,running:!0}),await new Promise(c=>setTimeout(c,re.postReadyHoldMs)),await ur(r,s.tunnelUrl)}catch(t){gt.error(`Failed to start tunnel: ${t.message}`),await K($.STOPPED)}}async function jc(){let e=await St(),{key:n}=Et(e),r=Nn();ot(e,n,r?.name||"Default"),await U({permanentKey:n}),gt.info(`Key regenerated: ${$n(n)}`)}function Kc(e,n){gt.info("Shutting down 9Remote completely...");let r=e();n(null),dt({tunnelProcess:r}),gt.info("9Remote stopped")}async function Ns(){He("agent",process.pid),Pt(Se());let e=await Be(),n=process.argv.find(a=>a.startsWith("--theme=")),r=n?n.split("=")[1]:null,o=await oe(),t=o?{getProcess:()=>null,shutdown:()=>{}}:Je(null,null);o||await new Promise(a=>setTimeout(a,re.serverBootMs));let i=`http://localhost:${P}`;console.log(m.green(`
|
|
205
|
+
\u{1F310} UI ready at ${i}`));let s=null;await U({permanentKey:e.key,step:$.STOPPED,theme:r}),Qe(t,null),et(()=>s,a=>{s=a},e.key,()=>t),process.argv.includes("--start")&&Tt("start-tunnel"),await new Promise(()=>{})}Bt();async function Ds(){He("agent",process.pid),ei().catch(()=>{});let e=await Be(),n=process.argv.find(l=>l.startsWith("--theme=")),r=n?n.split("=")[1]:null,o=await oe(),t=o?{getProcess:()=>null,shutdown:()=>{}}:Je(null,null);o||await new Promise(l=>setTimeout(l,re.serverBootMs));let i=`http://localhost:${P}`,s=null;await U({permanentKey:e.key,step:$.STOPPED,theme:r});let a=()=>{let l=s;s=null,dt({serverManager:t,tunnelProcess:l,exit:!1})};Qe(t,null),et(()=>s,l=>{s=l},e.key,()=>t);try{je("cloudflared")}catch{}process.argv.includes("--start")&&Tt("start-tunnel"),await qr({port:P,onQuit:a,onOpenUI:()=>Tn(i)})&&Jr({title:"9Remote is running",message:`Open ${i} or use the tray icon to manage.`}),await new Promise(()=>{})}var tt=J("mode");async function Gc(e){tt.info("Starting server..."),await K($.PREPARING);try{qe(),await new Promise(s=>setTimeout(s,re.killCloudflaredMs))}catch{}try{let s=await G(`${D}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:e})});if(!s.ok)return tt.error(`Session create failed: ${s.status}`),null}catch(s){return tt.error(`Session create failed: ${s.message}`),null}let n=await oe(),r=n?{getProcess:()=>null,shutdown:()=>{}}:Je(null,null);n||await new Promise(s=>setTimeout(s,re.serverBootMs)),tt.info("Starting tunnel..."),await K($.CONNECTING);let o={current:null},t,i=async s=>{tt.info(`Tunnel URL rotated: ${s}`),await Ne(e,s),U({tunnelUrl:s}),Lt(s)};try{let s=await mt(P,i,Ht({onUrlUpdate:i,setTunnel:a=>{o.current=a}}));o.current=s.child,t=s.tunnelUrl}catch(s){return tt.error(`Failed to start tunnel: ${s.message}`),r.shutdown(),null}return await Xe(t)||tt.warn("Tunnel health check timed out, proceeding anyway..."),await Ne(e,t),Mn({apiKey:e,tunnelUrl:t,serverPid:r.getProcess()?.pid,tunnelPid:o.current?.pid}),{serverManager:r,tunnelRef:o,tunnelUrl:t}}async function Fs(){Pt(Se());let e=await Be();tt.info(`Using key: ${$n(e.key)} (${e.name})`);let n=await Gc(e.key);n||process.exit(1);let{serverManager:r,tunnelRef:o,tunnelUrl:t}=n;await ur(e.key,t),Qe(r,o.current),et(()=>o.current,s=>{o.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;U({uptime:`${a}:${String(c).padStart(2,"0")}:${String(l).padStart(2,"0")}`})},ge.statsMs),await new Promise(()=>{})}var Us=A(require("path"),1),Bs=A(require("fs"),1);Bt();async function Hs(){let e=`http://localhost:${P}`;await oe()&&(sr(P),await new Promise(c=>setTimeout(c,500)));let n=["--tray"],r=process.argv.find(c=>c.startsWith("--theme="));r&&n.push(r);let o=en;try{Bs.default.mkdirSync(Us.default.dirname(o),{recursive:!0})}catch{}let t=null;try{t=Zo(n),t&&He("agent",t)}catch(c){console.log(m.red(`
|
|
206
|
+
\u274C Failed to launch background: ${c.message}`)),process.exit(1)}let i=Date.now()+ge.bgServerReadyTimeoutMs,s=!1;for(;Date.now()<i;){if(await oe()){s=!0;break}await new Promise(c=>setTimeout(c,ge.bgServerReadyIntervalMs))}s||(console.log(m.red(`
|
|
206
207
|
\u274C Background server failed to start.`)),console.log(m.gray(` Check log: ${o}
|
|
207
|
-
`)),process.exit(1)),
|
|
208
|
+
`)),process.exit(1)),Tt("start-tunnel"),Tn(e);let a=t?` (PID: ${t})`:"";console.log(m.green(`
|
|
208
209
|
\u{1F310} 9Remote running at ${e}${a}`)),console.log(m.gray(`\u{1F4A1} Log: ${o}
|
|
209
|
-
`)),await new Promise(c=>setTimeout(c,
|
|
210
|
+
`)),await new Promise(c=>setTimeout(c,re.bgSpawnFlushMs)),process.exit(0)}var js=A(require("readline"),1);var io=J("mode"),Kt=null;async function Ks(){console.clear(),Ti(),Ai(!0),await K($.PREPARING);let e=await Be(),n=null,r={getProcess:()=>null,shutdown:()=>{}};if(!await oe()){r=Je(null,null,()=>{if(process.stdin.isTTY){try{process.stdin.setRawMode(!1)}catch{}try{process.stdin.setRawMode(!0),process.stdin.resume()}catch{}}try{js.default.emitKeypressEvents(process.stdin)}catch{}n?.()});let E=Date.now()+ge.serverReadyTimeoutMs;for(;Date.now()<E&&!await oe();)await new Promise(g=>setTimeout(g,ge.serverReadyIntervalMs))}try{qe(),await new Promise(E=>setTimeout(E,re.killCloudflaredTuiMs))}catch{}await Sn(tr),await K($.CONNECTING);try{let E=await G(`${D}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:e.key})});if(!E.ok)throw new Error(`Session create failed: ${E.status}`)}catch(E){io.error(`Failed to connect: ${E.message}`),process.exit(1)}await K($.TUNNELING);let t,i,s={current:null},a=async E=>{await Ne(e.key,E),await U({tunnelUrl:E}),Lt(E)};try{let E=await mt(P,a,Ht({onUrlUpdate:a,setTunnel:g=>{s.current=g}}));t=E.child,i=E.tunnelUrl,s.current=t}catch(E){io.error(`Tunnel failed: ${E.message}`),process.exit(1)}await K($.VERIFYING),await Xe(i)||io.warn("Tunnel health check timed out, proceeding anyway..."),await Ne(e.key,i),Mn({apiKey:e.key,tunnelUrl:i,tunnelPid:t.pid});let c=await jt(e.key,D),l=c?`${D}/login?k=${c.tempKey}`:`${D}/login`;await K($.READY,{tunnelUrl:i,oneTimeKey:c?.tempKey||"",oneTimeKeyExpiresAt:c?.expiresAt||null,permanentKey:e.key,qrUrl:l,workerUrl:D}),await new Promise(E=>setTimeout(E,re.trayReadyMs));let u=c?.tempKey||"",f=l,p=i,d=await An(u,e.key,f,p),h=[],w=!1,S=()=>{w||n?.()},O=async(E,g,_)=>{if(!w){w=!0;try{let I=await xi(g,_);await X(`/api/device/${I?"approve":"reject"}`,{socketId:E})}catch{}finally{w=!1,n?.()}}},x=Ri(P,async(E,g)=>{if(E==="log"&&g.message)h.push(g.message),h.length>$e.maxLogLines&&h.shift();else if(E==="state"){let _=g.permanentKey||e.key,I=g.oneTimeKey!==void 0?g.oneTimeKey:u,F=g.qrUrl!==void 0?g.qrUrl:f,j=g.tunnelUrl!==void 0?g.tunnelUrl:p;(I!==u||_!==e.key||j!==p)&&(u=I,f=F,p=j,g.permanentKey&&(e={...e,key:g.permanentKey}),d=await An(u,e.key,f,p),S())}else E==="permissions"||E==="autostart"||E==="sleepInhibit"?(w||Kt?.(),S()):E==="deviceApproval"&&g.action==="pending"&&await O(g.socketId,g.deviceId,g.ip)}),b=setInterval(async()=>{if(w)return;let g=(await V("/api/device/pending"))?.pending?.[0];g&&await O(g.socketId,g.deviceId,g.ip)},ge.pendingApprovalMs);Qe({getProcess:r.getProcess,shutdown:()=>{r.shutdown(),x(),clearInterval(b)}},t),et(()=>s.current,E=>{s.current=E},e.key,()=>r),await Wc(e,i,()=>d,E=>{d=E},E=>{n=E},()=>{try{x()}catch{}try{clearInterval(b)}catch{}dt({serverManager:r,tunnelProcess:t,exit:!1})},h)}async function Wc(e,n,r,o,t,i,s){for(;;){let{desktopEnabled:a,remoteAvailable:c,autoApprove:l}=await Dr(),u=[{label:"Open Web UI",action:"webui"},{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 be("",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(()=>(Bt(),ts));w(h),console.log(m.green(`
|
|
210
211
|
\u{1F310} Opening ${h}
|
|
211
|
-
`))}else if(d==="keys")await
|
|
212
|
+
`))}else if(d==="keys")await Vc(e,n,o,r);else if(d==="desktop")await Jc();else if(d==="devices")await Qc();else if(d==="settings")await qc();else if(d==="logs")await Xc();else{try{i?.()}catch{}console.log(m.gray(`
|
|
212
213
|
Goodbye!
|
|
213
|
-
`)),process.exit(0)}}}async function
|
|
214
|
+
`)),process.exit(0)}}}async function Vc(e,n,r,o){let t=[{label:"New One-Time Key",action:"otk"},{label:"Regenerate Permanent Key",action:"regen"},{label:m.gray("\u2190 Back"),action:"back"}],i=await be("Keys",t,0,o),s=i>=0?t[i].action:"back";if(s==="otk"){let a=await jt(e.key,D);if(a){let c=`${D}/login?k=${a.tempKey}`;r(await An(a.tempKey,e.key,c,n)),await U({oneTimeKey:a.tempKey,oneTimeKeyExpiresAt:a.expiresAt,qrUrl:c})}}else if(s==="regen"&&await Mr(m.yellow("Replace current key and disconnect all sessions? Continue?"))){let c=await St(),{key:l}=Et(c),u=ot(c,l,e.name||"Default");Object.assign(e,u),await U({permanentKey:e.key});let f=await jt(e.key,D);if(f){let p=`${D}/login?k=${f.tempKey}`;r(await An(f.tempKey,e.key,p,n)),await U({oneTimeKey:f.tempKey,oneTimeKeyExpiresAt:f.expiresAt,qrUrl:p})}}}var Gs={"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 Yc(e,n){let r=n.map(s=>({label:Gs[s]||s,action:s}));r.push({label:m.gray("\u2190 Back"),action:"back"});let o=Math.max(0,n.indexOf(e)),t=await be("Prevent sleep",r,o),i=t>=0?r[t].action:"back";i!=="back"&&await X("/api/sleep-inhibit",{mode:i})}async function qc(){for(;;){let e=!1,n="never",r=[],o=()=>[{label:`Launch on system startup: ${e?m.green("ON"):m.gray("OFF")}`,action:"autostart"},{label:`Prevent sleep: ${m.green(Gs[n]||n)} \u25B6`,action:"sleep"},{label:m.gray("\u2190 Back"),action:"back"}],t=o(),i=null,s=async()=>{let l=await Dr();e=!!l.autoStart,n=l.sleepInhibitMode||"never",r=l.sleepInhibitPresets||[],t=o(),i?.()};await s(),Kt=s;let a=await be("Settings",t,0,"",l=>{i=l});Kt=null;let c=a>=0?t[a].action:"back";if(c==="autostart")await X("/api/autostart",{enabled:!e});else if(c==="sleep")await Yc(n,r);else return}}async function Jc(){for(;;){let e=!1,n={screenRecording:!1,accessibility:!1},r=()=>({toggle:`Toggle: ${e?m.green("ON \u2192 turn OFF"):m.gray("OFF \u2192 turn ON")}`,sr:`Screen Recording ${n.screenRecording?m.green("\u2713"):m.red("\u2717 (click to grant)")}`,ax:`Mouse & Keyboard control ${n.accessibility?m.green("\u2713"):m.red("\u2717 (click to grant)")}`}),o=[{label:""},{label:""},{label:""},{label:m.gray("\u2190 Back")}],t=null,i=async()=>{let a=await V("/api/ui/state")||{};e=!!a.desktopEnabled,n={screenRecording:!!a.screenRecording,accessibility:!!a.accessibility};let c=r();o[0].label=c.toggle,o[1].label=c.sr,o[2].label=c.ax,t?.()};await i(),Kt=i;let s=await be("Remote Desktop",o,0,"",a=>{t=a});if(Kt=null,s===0)await X("/api/desktop/toggle",{enabled:!e});else if(s===1&&!n.screenRecording)await X("/api/permissions/request",{type:"screenRecording"})||Xn("screenRecording");else if(s===2&&!n.accessibility)await X("/api/permissions/request",{type:"accessibility"})||Xn("accessibility");else if(s===3||s===-1)return}}async function Qc(){for(;;){let[e,n]=await Promise.all([V("/api/device/approved"),V("/api/device/auto-approve")]),r=e?.devices||[],o=!!n?.enabled,t=[{label:`Auto-approve new devices: ${o?m.green("ON"):m.gray("OFF")}`,action:"toggle"},...r.map(a=>{let c=a.deviceId.slice(0,8),l=a.approvedAt?new Date(a.approvedAt).toLocaleString():"unknown";return{label:`${c}... ${m.dim(l)}`,action:"remove",deviceId:a.deviceId}}),{label:m.gray("\u2190 Back"),action:"back"}],i=await be(`Approved Devices (${r.length})`,t,0);if(i===-1)return;let s=t[i];if(s.action==="back")return;if(s.action==="toggle"){await X("/api/device/auto-approve",{enabled:!o});continue}s.action==="remove"&&await Mr(m.yellow(`Remove device ${s.deviceId.slice(0,8)}...?`))&&await X("/api/device/remove",{deviceId:s.deviceId})}}async function Xc(){let e=$o(mo),n=e.length?e.join(`
|
|
214
215
|
`):m.gray(" No logs yet"),r=`
|
|
215
|
-
${m.dim("Log file:")} ${m.cyan(
|
|
216
|
-
${m.dim(`Tail: tail -f ${
|
|
216
|
+
${m.dim("Log file:")} ${m.cyan(en)}
|
|
217
|
+
${m.dim(`Tail: tail -f ${en}`)}`;await be("Logs",[{label:m.gray("\u2190 Back")}],0,n+r)}async function Ws(){let e=Se(),n=await ui(),r=Lr(e,n?.latest??null),o=[];n?.latest&&o.push({label:m.yellow(`Update to v${n.latest}`),action:"update"}),o.push({label:"Open Web UI (background)",action:"ui"},{label:"Terminal UI",action:"tui"},{label:m.gray("Exit"),action:"exit"});let t=await be("",o,0,r),i=t>=0?o[t].action:"exit";if(i==="update"){let s=Math.min($e.headerWidth,process.stdout.columns||$e.headerWidth);Qn(),console.log(ue.orange(`
|
|
217
218
|
`+"\u2550".repeat(s))),console.log(m.gray(` \u2713 Stopped running instances
|
|
218
219
|
`)),console.log(m.yellow(` \u2B06 Run this command to update:
|
|
219
220
|
`)),console.log(m.white.bold(` npm i -g ${Ie}
|
|
220
|
-
`)),console.log(
|
|
221
|
-
`),process.exit(0)}else i==="ui"?await
|
|
221
|
+
`)),console.log(ue.orange("\u2550".repeat(s))+`
|
|
222
|
+
`),process.exit(0)}else i==="ui"?await Hs():i==="tui"?await Ks():process.exit(0)}var Vs=[["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 so(){Pt(Se()),console.log(m.white.bold(`
|
|
222
223
|
Usage:
|
|
223
|
-
`));let e=Math.max(...
|
|
224
|
+
`));let e=Math.max(...Vs.map(([n])=>n.length))+2;for(let[n,r]of Vs)console.log(" "+m.cyan(n.padEnd(e))+m.gray(r));console.log()}async function kn(){return await oe()?!0:(console.log(m.red(`
|
|
224
225
|
\u2717 Server not running. Start it first: `)+m.cyan("9remote start")+`
|
|
225
|
-
`),!1)}async function
|
|
226
|
+
`),!1)}async function Zc(e){if(!await kn())return;if(e){let r=await X("/api/key/regenerate"),o=r&&r.ok?await r.json():null;if(!o?.permanentKey){console.log(m.red(`
|
|
226
227
|
\u2717 Regenerate failed
|
|
227
228
|
`));return}console.log(m.green(`
|
|
228
229
|
\u2713 New key: `)+m.white.bold(o.permanentKey)+`
|
|
229
|
-
`);return}let n=await
|
|
230
|
+
`);return}let n=await V("/api/ui/state")||{};if(!n.permanentKey){console.log(m.red(`
|
|
230
231
|
\u2717 No key yet. Run: `)+m.cyan("9remote start")+`
|
|
231
232
|
`);return}console.log(m.white(`
|
|
232
233
|
Key`.padEnd(14))+m.white.bold(n.permanentKey)),n.qrUrl&&console.log(m.white("Connect URL".padEnd(14))+m.cyan(n.qrUrl)),console.log(m.white("App URL".padEnd(14))+m.gray(`${D}/login`)+`
|
|
233
|
-
`)}async function
|
|
234
|
+
`)}async function zc(){if(!await kn())return;let e=await X("/api/key/one-time"),n=e&&e.ok?await e.json():null;if(!n?.qrUrl){console.log(m.red(`
|
|
234
235
|
\u2717 Failed to create one-time key
|
|
235
236
|
`));return}console.log(m.green(`
|
|
236
237
|
\u2713 One-time key (30 min): `)+m.white.bold(n.oneTimeKey)),console.log(m.white("Connect URL ")+m.cyan(n.qrUrl)+`
|
|
237
|
-
`)}async function
|
|
238
|
+
`)}async function el(){if(!await kn())return;let n=(await V("/api/device/approved")||{}).devices||[],r=await V("/api/device/auto-approve")||{};if(console.log(m.white(`
|
|
238
239
|
Auto-approve: `)+(r.enabled?m.green("ON"):m.gray("OFF"))),!n.length){console.log(m.gray(`No approved devices
|
|
239
|
-
`));return}console.log(m.white(`Approved devices (${n.length}):`));for(let o of n)console.log(" "+m.cyan(o.deviceId));console.log()}async function
|
|
240
|
+
`));return}console.log(m.white(`Approved devices (${n.length}):`));for(let o of n)console.log(" "+m.cyan(o.deviceId));console.log()}async function tl(e){if(!await kn())return;let n=e==="on";if(e!=="on"&&e!=="off"){console.log(m.red(`
|
|
240
241
|
\u2717 Usage: 9remote auto-approve <on|off>
|
|
241
|
-
`));return}let r=await
|
|
242
|
+
`));return}let r=await X("/api/device/auto-approve",{enabled:n}),o=r&&r.ok?await r.json():null;console.log(m.green(`
|
|
242
243
|
\u2713 Auto-approve: `)+(o?.enabled?m.green("ON"):m.gray("OFF"))+`
|
|
243
|
-
`)}async function
|
|
244
|
+
`)}async function nl(e){if(!await kn())return;if(!e){let t=(await V("/api/device/pending")||{}).pending||[];if(!t.length){console.log(m.gray(`
|
|
244
245
|
No pending devices
|
|
245
246
|
`));return}console.log(m.white(`
|
|
246
247
|
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(`
|
|
247
248
|
Approve with: `)+m.cyan("9remote approve <socketId>")+`
|
|
248
|
-
`);return}let n=await
|
|
249
|
+
`);return}let n=await X("/api/device/approve",{socketId:e}),r=n&&n.ok?await n.json():null;console.log(r?.ok?m.green(`
|
|
249
250
|
\u2713 Approved
|
|
250
251
|
`):m.red(`
|
|
251
252
|
\u2717 Approve failed (invalid socketId?)
|
|
252
|
-
`))}async function
|
|
253
|
-
`),process.exit(0));Io();async function
|
|
253
|
+
`))}async function Ys(e){let n=e[2],r=e.slice(3);switch(n){case"help":case"-h":case"--help":return so(),!0;case"key":return await Zc(r.includes("--new")),!0;case"otk":return await zc(),!0;case"devices":return await el(),!0;case"auto-approve":return await tl(r[0]),!0;case"approve":return await nl(r[0]),!0;default:return!1}}var ao=process.argv[2];(ao==="version"||ao==="--version"||ao==="-v")&&(process.stdout.write(Se()+`
|
|
254
|
+
`),process.exit(0));Io();async function rl(){let e=process.argv[2];if(await Ys(process.argv))return;process.argv.includes("--tray")||process.argv.includes("--auto")||process.argv.includes("--start")||Qn(),e==="ui"?await Ns():e==="start"||process.argv.includes("--auto")?await Fs():process.argv.includes("--tray")||process.argv.includes("--start")?await Ds():process.stdin.isTTY?await Ws():so()}rl().catch(console.error);
|