9remote 0.1.53 → 0.1.55
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/cli/index.js +379 -198
- package/cli/utils/apiKey.js +13 -8
- package/cli/utils/permissions.js +45 -0
- package/cli/utils/state.js +23 -0
- package/cli/utils/tui.js +251 -0
- package/cli/utils/updateChecker.js +22 -0
- package/dist/cli.cjs +44 -95
- package/dist/server.cjs +48 -45
- package/dist/ui/assets/index-CMD-4YxV.js +8 -0
- package/dist/ui/assets/index-D4GJ1wNn.css +1 -0
- package/dist/ui/index.html +2 -2
- package/index.js +200 -8
- package/package.json +1 -1
- package/dist/ui/assets/index-BIuRs677.js +0 -8
- package/dist/ui/assets/index-DhKgENYK.css +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const s of r.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&i(s)}).observe(document,{childList:!0,subtree:!0});function o(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(n){if(n.ep)return;n.ep=!0;const r=o(n);fetch(n.href,r)}})();var ue,B,Ot,O,et,jt,Vt,Jt,Ve,He,Ke,ie={},se=[],dn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,fe=Array.isArray;function F(e,t){for(var o in t)e[o]=t[o];return e}function Je(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function hn(e,t,o){var i,n,r,s={};for(r in t)r=="key"?i=t[r]:r=="ref"?n=t[r]:s[r]=t[r];if(arguments.length>2&&(s.children=arguments.length>3?ue.call(arguments,2):o),typeof e=="function"&&e.defaultProps!=null)for(r in e.defaultProps)s[r]===void 0&&(s[r]=e.defaultProps[r]);return ne(e,s,i,n,null)}function ne(e,t,o,i,n){var r={type:e,props:t,key:o,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:n??++Ot,__i:-1,__u:0};return n==null&&B.vnode!=null&&B.vnode(r),r}function H(e){return e.children}function re(e,t){this.props=e,this.context=t}function G(e,t){if(t==null)return e.__?G(e.__,e.__i+1):null;for(var o;t<e.__k.length;t++)if((o=e.__k[t])!=null&&o.__e!=null)return o.__e;return typeof e.type=="function"?G(e):null}function _n(e){if(e.__P&&e.__d){var t=e.__v,o=t.__e,i=[],n=[],r=F({},t);r.__v=t.__v+1,B.vnode&&B.vnode(r),Ye(e.__P,r,t,e.__n,e.__P.namespaceURI,32&t.__u?[o]:null,i,o??G(t),!!(32&t.__u),n),r.__v=t.__v,r.__.__k[r.__i]=r,Wt(i,r,n),t.__e=t.__=null,r.__e!=o&&Yt(r)}}function Yt(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Yt(e)}function tt(e){(!e.__d&&(e.__d=!0)&&O.push(e)&&!le.__r++||et!=B.debounceRendering)&&((et=B.debounceRendering)||jt)(le)}function le(){try{for(var e,t=1;O.length;)O.length>t&&O.sort(Vt),e=O.shift(),t=O.length,_n(e)}finally{O.length=le.__r=0}}function Gt(e,t,o,i,n,r,s,l,a,f,h){var c,_,d,b,N,P,y,m=i&&i.__k||se,g=t.length;for(a=mn(o,t,m,a,g),c=0;c<g;c++)(d=o.__k[c])!=null&&(_=d.__i!=-1&&m[d.__i]||ie,d.__i=c,P=Ye(e,d,_,n,r,s,l,a,f,h),b=d.__e,d.ref&&_.ref!=d.ref&&(_.ref&&Ge(_.ref,null,d),h.push(d.ref,d.__c||b,d)),N==null&&b!=null&&(N=b),(y=!!(4&d.__u))||_.__k===d.__k?a=Qt(d,a,e,y):typeof d.type=="function"&&P!==void 0?a=P:b&&(a=b.nextSibling),d.__u&=-7);return o.__e=N,a}function mn(e,t,o,i,n){var r,s,l,a,f,h=o.length,c=h,_=0;for(e.__k=new Array(n),r=0;r<n;r++)(s=t[r])!=null&&typeof s!="boolean"&&typeof s!="function"?(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?s=e.__k[r]=ne(null,s,null,null,null):fe(s)?s=e.__k[r]=ne(H,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=e.__k[r]=ne(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[r]=s,a=r+_,s.__=e,s.__b=e.__b+1,l=null,(f=s.__i=gn(s,o,a,c))!=-1&&(c--,(l=o[f])&&(l.__u|=2)),l==null||l.__v==null?(f==-1&&(n>h?_--:n<h&&_++),typeof s.type!="function"&&(s.__u|=4)):f!=a&&(f==a-1?_--:f==a+1?_++:(f>a?_--:_++,s.__u|=4))):e.__k[r]=null;if(c)for(r=0;r<h;r++)(l=o[r])!=null&&(2&l.__u)==0&&(l.__e==i&&(i=G(l)),Zt(l,l));return i}function Qt(e,t,o,i){var n,r;if(typeof e.type=="function"){for(n=e.__k,r=0;n&&r<n.length;r++)n[r]&&(n[r].__=e,t=Qt(n[r],t,o,i));return t}e.__e!=t&&(i&&(t&&e.type&&!t.parentNode&&(t=G(e)),o.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function gn(e,t,o,i){var n,r,s,l=e.key,a=e.type,f=t[o],h=f!=null&&(2&f.__u)==0;if(f===null&&l==null||h&&l==f.key&&a==f.type)return o;if(i>(h?1:0)){for(n=o-1,r=o+1;n>=0||r<t.length;)if((f=t[s=n>=0?n--:r++])!=null&&(2&f.__u)==0&&l==f.key&&a==f.type)return s}return-1}function nt(e,t,o){t[0]=="-"?e.setProperty(t,o??""):e[t]=o==null?"":typeof o!="number"||dn.test(t)?o:o+"px"}function $(e,t,o,i,n){var r,s;e:if(t=="style")if(typeof o=="string")e.style.cssText=o;else{if(typeof i=="string"&&(e.style.cssText=i=""),i)for(t in i)o&&t in o||nt(e.style,t,"");if(o)for(t in o)i&&o[t]==i[t]||nt(e.style,t,o[t])}else if(t[0]=="o"&&t[1]=="n")r=t!=(t=t.replace(Jt,"$1")),s=t.toLowerCase(),t=s in e||t=="onFocusOut"||t=="onFocusIn"?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=o,o?i?o.u=i.u:(o.u=Ve,e.addEventListener(t,r?Ke:He,r)):e.removeEventListener(t,r?Ke:He,r);else{if(n=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=o??"";break e}catch{}typeof o=="function"||(o==null||o===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&o==1?"":o))}}function rt(e){return function(t){if(this.l){var o=this.l[t.type+e];if(t.t==null)t.t=Ve++;else if(t.t<o.u)return;return o(B.event?B.event(t):t)}}}function Ye(e,t,o,i,n,r,s,l,a,f){var h,c,_,d,b,N,P,y,m,g,p,A,x,C,v,w=t.type;if(t.constructor!==void 0)return null;128&o.__u&&(a=!!(32&o.__u),r=[l=t.__e=o.__e]),(h=B.__b)&&h(t);e:if(typeof w=="function")try{if(y=t.props,m=w.prototype&&w.prototype.render,g=(h=w.contextType)&&i[h.__c],p=h?g?g.props.value:h.__:i,o.__c?P=(c=t.__c=o.__c).__=c.__E:(m?t.__c=c=new w(y,p):(t.__c=c=new re(y,p),c.constructor=w,c.render=yn),g&&g.sub(c),c.state||(c.state={}),c.__n=i,_=c.__d=!0,c.__h=[],c._sb=[]),m&&c.__s==null&&(c.__s=c.state),m&&w.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=F({},c.__s)),F(c.__s,w.getDerivedStateFromProps(y,c.__s))),d=c.props,b=c.state,c.__v=t,_)m&&w.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),m&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(m&&w.getDerivedStateFromProps==null&&y!==d&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(y,p),t.__v==o.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(y,c.__s,p)===!1){t.__v!=o.__v&&(c.props=y,c.state=c.__s,c.__d=!1),t.__e=o.__e,t.__k=o.__k,t.__k.some(function(E){E&&(E.__=t)}),se.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&s.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(y,c.__s,p),m&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(d,b,N)})}if(c.context=p,c.props=y,c.__P=e,c.__e=!1,A=B.__r,x=0,m)c.state=c.__s,c.__d=!1,A&&A(t),h=c.render(c.props,c.state,c.context),se.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,A&&A(t),h=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++x<25);c.state=c.__s,c.getChildContext!=null&&(i=F(F({},i),c.getChildContext())),m&&!_&&c.getSnapshotBeforeUpdate!=null&&(N=c.getSnapshotBeforeUpdate(d,b)),C=h!=null&&h.type===H&&h.key==null?Xt(h.props.children):h,l=Gt(e,fe(C)?C:[C],t,o,i,n,r,s,l,a,f),c.base=t.__e,t.__u&=-161,c.__h.length&&s.push(c),P&&(c.__E=c.__=null)}catch(E){if(t.__v=null,a||r!=null)if(E.then){for(t.__u|=a?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;r[r.indexOf(l)]=null,t.__e=l}else{for(v=r.length;v--;)Je(r[v]);ze(t)}else t.__e=o.__e,t.__k=o.__k,E.then||ze(t);B.__e(E,t,o)}else r==null&&t.__v==o.__v?(t.__k=o.__k,t.__e=o.__e):l=t.__e=pn(o.__e,t,o,i,n,r,s,a,f);return(h=B.diffed)&&h(t),128&t.__u?void 0:l}function ze(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ze))}function Wt(e,t,o){for(var i=0;i<o.length;i++)Ge(o[i],o[++i],o[++i]);B.__c&&B.__c(t,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(r){r.call(n)})}catch(r){B.__e(r,n.__v)}})}function Xt(e){return typeof e!="object"||e==null||e.__b>0?e:fe(e)?e.map(Xt):F({},e)}function pn(e,t,o,i,n,r,s,l,a){var f,h,c,_,d,b,N,P=o.props||ie,y=t.props,m=t.type;if(m=="svg"?n="http://www.w3.org/2000/svg":m=="math"?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),r!=null){for(f=0;f<r.length;f++)if((d=r[f])&&"setAttribute"in d==!!m&&(m?d.localName==m:d.nodeType==3)){e=d,r[f]=null;break}}if(e==null){if(m==null)return document.createTextNode(y);e=document.createElementNS(n,m,y.is&&y),l&&(B.__m&&B.__m(t,r),l=!1),r=null}if(m==null)P===y||l&&e.data==y||(e.data=y);else{if(r=r&&ue.call(e.childNodes),!l&&r!=null)for(P={},f=0;f<e.attributes.length;f++)P[(d=e.attributes[f]).name]=d.value;for(f in P)d=P[f],f=="dangerouslySetInnerHTML"?c=d:f=="children"||f in y||f=="value"&&"defaultValue"in y||f=="checked"&&"defaultChecked"in y||$(e,f,null,d,n);for(f in y)d=y[f],f=="children"?_=d:f=="dangerouslySetInnerHTML"?h=d:f=="value"?b=d:f=="checked"?N=d:l&&typeof d!="function"||P[f]===d||$(e,f,d,P[f],n);if(h)l||c&&(h.__html==c.__html||h.__html==e.innerHTML)||(e.innerHTML=h.__html),t.__k=[];else if(c&&(e.innerHTML=""),Gt(t.type=="template"?e.content:e,fe(_)?_:[_],t,o,i,m=="foreignObject"?"http://www.w3.org/1999/xhtml":n,r,s,r?r[0]:o.__k&&G(o,0),l,a),r!=null)for(f=r.length;f--;)Je(r[f]);l||(f="value",m=="progress"&&b==null?e.removeAttribute("value"):b!=null&&(b!==e[f]||m=="progress"&&!b||m=="option"&&b!=P[f])&&$(e,f,b,P[f],n),f="checked",N!=null&&N!=e[f]&&$(e,f,N,P[f],n))}return e}function Ge(e,t,o){try{if(typeof e=="function"){var i=typeof e.__u=="function";i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(n){B.__e(n,o)}}function Zt(e,t,o){var i,n;if(B.unmount&&B.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||Ge(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(r){B.__e(r,t)}i.base=i.__P=null}if(i=e.__k)for(n=0;n<i.length;n++)i[n]&&Zt(i[n],t,o||typeof e.type!="function");o||Je(e.__e),e.__c=e.__=e.__e=void 0}function yn(e,t,o){return this.constructor(e,o)}function wn(e,t,o){var i,n,r,s;t==document&&(t=document.documentElement),B.__&&B.__(e,t),n=(i=!1)?null:t.__k,r=[],s=[],Ye(t,e=t.__k=hn(H,null,[e]),n||ie,ie,t.namespaceURI,n?null:t.firstChild?ue.call(t.childNodes):null,r,n?n.__e:t.firstChild,i,s),Wt(r,e,s)}ue=se.slice,B={__e:function(e,t,o,i){for(var n,r,s;t=t.__;)if((n=t.__c)&&!n.__)try{if((r=n.constructor)&&r.getDerivedStateFromError!=null&&(n.setState(r.getDerivedStateFromError(e)),s=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(e,i||{}),s=n.__d),s)return n.__E=n}catch(l){e=l}throw e}},Ot=0,re.prototype.setState=function(e,t){var o;o=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=F({},this.state),typeof e=="function"&&(e=e(F({},o),this.props)),e&&F(o,e),e!=null&&this.__v&&(t&&this._sb.push(t),tt(this))},re.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),tt(this))},re.prototype.render=H,O=[],jt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Vt=function(e,t){return e.__v.__b-t.__v.__b},le.__r=0,Jt=/(PointerCapture)$|Capture$/i,Ve=0,He=rt(!1),Ke=rt(!0);var bn=0;function u(e,t,o,i,n,r){t||(t={});var s,l,a=t;if("ref"in a)for(l in a={},t)l=="ref"?s=t[l]:a[l]=t[l];var f={type:e,props:a,key:o,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--bn,__i:-1,__u:0,__source:n,__self:r};if(typeof e=="function"&&(s=e.defaultProps))for(l in s)a[l]===void 0&&(a[l]=s[l]);return B.vnode&&B.vnode(f),f}var X,M,ge,ot,ae=0,$t=[],I=B,it=I.__b,st=I.__r,lt=I.diffed,at=I.__c,ct=I.unmount,ut=I.__;function Qe(e,t){I.__h&&I.__h(M,e,ae||t),ae=0;var o=M.__H||(M.__H={__:[],__h:[]});return e>=o.__.length&&o.__.push({}),o.__[e]}function L(e){return ae=1,xn(nn,e)}function xn(e,t,o){var i=Qe(X++,2);if(i.t=e,!i.__c&&(i.__=[nn(void 0,t),function(l){var a=i.__N?i.__N[0]:i.__[0],f=i.t(a,l);a!==f&&(i.__N=[f,i.__[1]],i.__c.setState({}))}],i.__c=M,!M.__f)){var n=function(l,a,f){if(!i.__c.__H)return!0;var h=i.__c.__H.__.filter(function(_){return _.__c});if(h.every(function(_){return!_.__N}))return!r||r.call(this,l,a,f);var c=i.__c.props!==l;return h.some(function(_){if(_.__N){var d=_.__[0];_.__=_.__N,_.__N=void 0,d!==_.__[0]&&(c=!0)}}),r&&r.call(this,l,a,f)||c};M.__f=!0;var r=M.shouldComponentUpdate,s=M.componentWillUpdate;M.componentWillUpdate=function(l,a,f){if(this.__e){var h=r;r=void 0,n(l,a,f),r=h}s&&s.call(this,l,a,f)},M.shouldComponentUpdate=n}return i.__N||i.__}function ce(e,t){var o=Qe(X++,3);!I.__s&&tn(o.__H,t)&&(o.__=e,o.u=t,M.__H.__h.push(o))}function en(e){return ae=5,vn(function(){return{current:e}},[])}function vn(e,t){var o=Qe(X++,7);return tn(o.__H,t)&&(o.__=e(),o.__H=t,o.__h=e),o.__}function Nn(){for(var e;e=$t.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(oe),t.__h.some(Oe),t.__h=[]}catch(o){t.__h=[],I.__e(o,e.__v)}}}I.__b=function(e){M=null,it&&it(e)},I.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ut&&ut(e,t)},I.__r=function(e){st&&st(e),X=0;var t=(M=e.__c).__H;t&&(ge===M?(t.__h=[],M.__h=[],t.__.some(function(o){o.__N&&(o.__=o.__N),o.u=o.__N=void 0})):(t.__h.some(oe),t.__h.some(Oe),t.__h=[],X=0)),ge=M},I.diffed=function(e){lt&<(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&($t.push(t)!==1&&ot===I.requestAnimationFrame||((ot=I.requestAnimationFrame)||Cn)(Nn)),t.__H.__.some(function(o){o.u&&(o.__H=o.u),o.u=void 0})),ge=M=null},I.__c=function(e,t){t.some(function(o){try{o.__h.some(oe),o.__h=o.__h.filter(function(i){return!i.__||Oe(i)})}catch(i){t.some(function(n){n.__h&&(n.__h=[])}),t=[],I.__e(i,o.__v)}}),at&&at(e,t)},I.unmount=function(e){ct&&ct(e);var t,o=e.__c;o&&o.__H&&(o.__H.__.some(function(i){try{oe(i)}catch(n){t=n}}),o.__H=void 0,t&&I.__e(t,o.__v))};var ft=typeof requestAnimationFrame=="function";function Cn(e){var t,o=function(){clearTimeout(i),ft&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(o,35);ft&&(t=requestAnimationFrame(o))}function oe(e){var t=M,o=e.__c;typeof o=="function"&&(e.__c=void 0,o()),M=t}function Oe(e){var t=M;e.__c=e.__(),M=t}function tn(e,t){return!e||e.length!==t.length||t.some(function(o,i){return o!==e[i]})}function nn(e,t){return typeof t=="function"?t(e):t}const En=[{icon:"download",label:"Preparing",desc:"Checking tunnel binary"},{icon:"cloud_sync",label:"Connecting",desc:"Creating session"},{icon:"lan",label:"Tunneling",desc:"Starting secure tunnel"},{icon:"check_circle",label:"Ready",desc:"Connected"}];function kn({currentStep:e}){const t=e-1;return u("div",{className:"glass-card p-5 flex flex-col gap-4",children:[u("span",{className:"text-xs text-white/50 font-medium uppercase tracking-wider",children:"Setting up connection"}),u("div",{className:"flex flex-col gap-3",children:En.map((o,i)=>{const n=i<t,r=i===t;return u("div",{className:"flex items-center gap-3",children:[u("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",style:{background:n?"var(--brand-500)":r?"rgba(255,87,10,0.15)":"rgba(255,255,255,0.06)",border:r?"1.5px solid var(--brand-500)":"1.5px solid transparent"},children:n?u("span",{className:"material-symbols-outlined text-white",style:{fontSize:16},children:"check"}):r?u("span",{className:"flex gap-0.5 items-center",children:[0,1,2].map(s=>u("span",{className:"w-1 h-1 rounded-full bg-orange-400 dot-bounce",style:{animationDelay:`${s*.18}s`}},s))}):u("span",{className:"material-symbols-outlined text-white/20",style:{fontSize:16},children:o.icon})}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:`text-sm font-medium ${n?"text-white/60":r?"text-white":"text-white/25"}`,children:o.label}),u("p",{className:`text-xs mt-0.5 ${r?"text-white/40":"text-white/20"}`,children:o.desc})]}),n&&u("span",{className:"text-xs text-white/30 flex-shrink-0",children:"Done"}),r&&u("span",{className:"text-xs flex-shrink-0 px-2 py-0.5 rounded-full",style:{background:"rgba(255,87,10,0.15)",color:"var(--brand-400)"},children:"Running"})]},i)})})]})}function Sn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Y={},pe,dt;function Tn(){return dt||(dt=1,pe=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),pe}var ye={},z={},ht;function j(){if(ht)return z;ht=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return z.getSymbolSize=function(i){if(!i)throw new Error('"version" cannot be null or undefined');if(i<1||i>40)throw new Error('"version" should be in range from 1 to 40');return i*4+17},z.getSymbolTotalCodewords=function(i){return t[i]},z.getBCHDigit=function(o){let i=0;for(;o!==0;)i++,o>>>=1;return i},z.setToSJISFunction=function(i){if(typeof i!="function")throw new Error('"toSJISFunc" is not a valid function.');e=i},z.isKanjiModeEnabled=function(){return typeof e<"u"},z.toSJIS=function(i){return e(i)},z}var we={},_t;function We(){return _t||(_t=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+o)}}e.isValid=function(i){return i&&typeof i.bit<"u"&&i.bit>=0&&i.bit<4},e.from=function(i,n){if(e.isValid(i))return i;try{return t(i)}catch{return n}}})(we)),we}var be,mt;function Pn(){if(mt)return be;mt=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const o=Math.floor(t/8);return(this.buffer[o]>>>7-t%8&1)===1},put:function(t,o){for(let i=0;i<o;i++)this.putBit((t>>>o-i-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),t&&(this.buffer[o]|=128>>>this.length%8),this.length++}},be=e,be}var xe,gt;function Rn(){if(gt)return xe;gt=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,o,i,n){const r=t*this.size+o;this.data[r]=i,n&&(this.reservedBit[r]=!0)},e.prototype.get=function(t,o){return this.data[t*this.size+o]},e.prototype.xor=function(t,o,i){this.data[t*this.size+o]^=i},e.prototype.isReserved=function(t,o){return this.reservedBit[t*this.size+o]},xe=e,xe}var ve={},pt;function An(){return pt||(pt=1,(function(e){const t=j().getSymbolSize;e.getRowColCoords=function(i){if(i===1)return[];const n=Math.floor(i/7)+2,r=t(i),s=r===145?26:Math.ceil((r-13)/(2*n-2))*2,l=[r-7];for(let a=1;a<n-1;a++)l[a]=l[a-1]-s;return l.push(6),l.reverse()},e.getPositions=function(i){const n=[],r=e.getRowColCoords(i),s=r.length;for(let l=0;l<s;l++)for(let a=0;a<s;a++)l===0&&a===0||l===0&&a===s-1||l===s-1&&a===0||n.push([r[l],r[a]]);return n}})(ve)),ve}var Ne={},yt;function Bn(){if(yt)return Ne;yt=1;const e=j().getSymbolSize,t=7;return Ne.getPositions=function(i){const n=e(i);return[[0,0],[n-t,0],[0,n-t]]},Ne}var Ce={},wt;function Mn(){return wt||(wt=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},e.from=function(n){return e.isValid(n)?parseInt(n,10):void 0},e.getPenaltyN1=function(n){const r=n.size;let s=0,l=0,a=0,f=null,h=null;for(let c=0;c<r;c++){l=a=0,f=h=null;for(let _=0;_<r;_++){let d=n.get(c,_);d===f?l++:(l>=5&&(s+=t.N1+(l-5)),f=d,l=1),d=n.get(_,c),d===h?a++:(a>=5&&(s+=t.N1+(a-5)),h=d,a=1)}l>=5&&(s+=t.N1+(l-5)),a>=5&&(s+=t.N1+(a-5))}return s},e.getPenaltyN2=function(n){const r=n.size;let s=0;for(let l=0;l<r-1;l++)for(let a=0;a<r-1;a++){const f=n.get(l,a)+n.get(l,a+1)+n.get(l+1,a)+n.get(l+1,a+1);(f===4||f===0)&&s++}return s*t.N2},e.getPenaltyN3=function(n){const r=n.size;let s=0,l=0,a=0;for(let f=0;f<r;f++){l=a=0;for(let h=0;h<r;h++)l=l<<1&2047|n.get(f,h),h>=10&&(l===1488||l===93)&&s++,a=a<<1&2047|n.get(h,f),h>=10&&(a===1488||a===93)&&s++}return s*t.N3},e.getPenaltyN4=function(n){let r=0;const s=n.data.length;for(let a=0;a<s;a++)r+=n.data[a];return Math.abs(Math.ceil(r*100/s/5)-10)*t.N4};function o(i,n,r){switch(i){case e.Patterns.PATTERN000:return(n+r)%2===0;case e.Patterns.PATTERN001:return n%2===0;case e.Patterns.PATTERN010:return r%3===0;case e.Patterns.PATTERN011:return(n+r)%3===0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2===0;case e.Patterns.PATTERN101:return n*r%2+n*r%3===0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2===0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2===0;default:throw new Error("bad maskPattern:"+i)}}e.applyMask=function(n,r){const s=r.size;for(let l=0;l<s;l++)for(let a=0;a<s;a++)r.isReserved(a,l)||r.xor(a,l,o(n,a,l))},e.getBestMask=function(n,r){const s=Object.keys(e.Patterns).length;let l=0,a=1/0;for(let f=0;f<s;f++){r(f),e.applyMask(f,n);const h=e.getPenaltyN1(n)+e.getPenaltyN2(n)+e.getPenaltyN3(n)+e.getPenaltyN4(n);e.applyMask(f,n),h<a&&(a=h,l=f)}return l}})(Ce)),Ce}var ee={},bt;function rn(){if(bt)return ee;bt=1;const e=We(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],o=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return ee.getBlocksCount=function(n,r){switch(r){case e.L:return t[(n-1)*4+0];case e.M:return t[(n-1)*4+1];case e.Q:return t[(n-1)*4+2];case e.H:return t[(n-1)*4+3];default:return}},ee.getTotalCodewordsCount=function(n,r){switch(r){case e.L:return o[(n-1)*4+0];case e.M:return o[(n-1)*4+1];case e.Q:return o[(n-1)*4+2];case e.H:return o[(n-1)*4+3];default:return}},ee}var Ee={},W={},xt;function In(){if(xt)return W;xt=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let i=1;for(let n=0;n<255;n++)e[n]=i,t[i]=n,i<<=1,i&256&&(i^=285);for(let n=255;n<512;n++)e[n]=e[n-255]})(),W.log=function(i){if(i<1)throw new Error("log("+i+")");return t[i]},W.exp=function(i){return e[i]},W.mul=function(i,n){return i===0||n===0?0:e[t[i]+t[n]]},W}var vt;function Ln(){return vt||(vt=1,(function(e){const t=In();e.mul=function(i,n){const r=new Uint8Array(i.length+n.length-1);for(let s=0;s<i.length;s++)for(let l=0;l<n.length;l++)r[s+l]^=t.mul(i[s],n[l]);return r},e.mod=function(i,n){let r=new Uint8Array(i);for(;r.length-n.length>=0;){const s=r[0];for(let a=0;a<n.length;a++)r[a]^=t.mul(n[a],s);let l=0;for(;l<r.length&&r[l]===0;)l++;r=r.slice(l)}return r},e.generateECPolynomial=function(i){let n=new Uint8Array([1]);for(let r=0;r<i;r++)n=e.mul(n,new Uint8Array([1,t.exp(r)]));return n}})(Ee)),Ee}var ke,Nt;function Dn(){if(Nt)return ke;Nt=1;const e=Ln();function t(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(i){this.degree=i,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(i){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(i.length+this.degree);n.set(i);const r=e.mod(n,this.genPoly),s=this.degree-r.length;if(s>0){const l=new Uint8Array(this.degree);return l.set(r,s),l}return r},ke=t,ke}var Se={},Te={},Pe={},Ct;function on(){return Ct||(Ct=1,Pe.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Pe}var D={},Et;function sn(){if(Et)return D;Et=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\u");const i="(?:(?![A-Z0-9 $%*+\\-./:]|"+o+`)(?:.|[\r
|
|
2
|
+
]))+`;D.KANJI=new RegExp(o,"g"),D.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),D.BYTE=new RegExp(i,"g"),D.NUMERIC=new RegExp(e,"g"),D.ALPHANUMERIC=new RegExp(t,"g");const n=new RegExp("^"+o+"$"),r=new RegExp("^"+e+"$"),s=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return D.testKanji=function(a){return n.test(a)},D.testNumeric=function(a){return r.test(a)},D.testAlphanumeric=function(a){return s.test(a)},D}var kt;function V(){return kt||(kt=1,(function(e){const t=on(),o=sn();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(r,s){if(!r.ccBits)throw new Error("Invalid mode: "+r);if(!t.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?r.ccBits[0]:s<27?r.ccBits[1]:r.ccBits[2]},e.getBestModeForData=function(r){return o.testNumeric(r)?e.NUMERIC:o.testAlphanumeric(r)?e.ALPHANUMERIC:o.testKanji(r)?e.KANJI:e.BYTE},e.toString=function(r){if(r&&r.id)return r.id;throw new Error("Invalid mode")},e.isValid=function(r){return r&&r.bit&&r.ccBits};function i(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+n)}}e.from=function(r,s){if(e.isValid(r))return r;try{return i(r)}catch{return s}}})(Te)),Te}var St;function Un(){return St||(St=1,(function(e){const t=j(),o=rn(),i=We(),n=V(),r=on(),s=7973,l=t.getBCHDigit(s);function a(_,d,b){for(let N=1;N<=40;N++)if(d<=e.getCapacity(N,b,_))return N}function f(_,d){return n.getCharCountIndicator(_,d)+4}function h(_,d){let b=0;return _.forEach(function(N){const P=f(N.mode,d);b+=P+N.getBitsLength()}),b}function c(_,d){for(let b=1;b<=40;b++)if(h(_,b)<=e.getCapacity(b,d,n.MIXED))return b}e.from=function(d,b){return r.isValid(d)?parseInt(d,10):b},e.getCapacity=function(d,b,N){if(!r.isValid(d))throw new Error("Invalid QR Code version");typeof N>"u"&&(N=n.BYTE);const P=t.getSymbolTotalCodewords(d),y=o.getTotalCodewordsCount(d,b),m=(P-y)*8;if(N===n.MIXED)return m;const g=m-f(N,d);switch(N){case n.NUMERIC:return Math.floor(g/10*3);case n.ALPHANUMERIC:return Math.floor(g/11*2);case n.KANJI:return Math.floor(g/13);case n.BYTE:default:return Math.floor(g/8)}},e.getBestVersionForData=function(d,b){let N;const P=i.from(b,i.M);if(Array.isArray(d)){if(d.length>1)return c(d,P);if(d.length===0)return 1;N=d[0]}else N=d;return a(N.mode,N.getLength(),P)},e.getEncodedBits=function(d){if(!r.isValid(d)||d<7)throw new Error("Invalid QR Code version");let b=d<<12;for(;t.getBCHDigit(b)-l>=0;)b^=s<<t.getBCHDigit(b)-l;return d<<12|b}})(Se)),Se}var Re={},Tt;function qn(){if(Tt)return Re;Tt=1;const e=j(),t=1335,o=21522,i=e.getBCHDigit(t);return Re.getEncodedBits=function(r,s){const l=r.bit<<3|s;let a=l<<10;for(;e.getBCHDigit(a)-i>=0;)a^=t<<e.getBCHDigit(a)-i;return(l<<10|a)^o},Re}var Ae={},Be,Pt;function Fn(){if(Pt)return Be;Pt=1;const e=V();function t(o){this.mode=e.NUMERIC,this.data=o.toString()}return t.getBitsLength=function(i){return 10*Math.floor(i/3)+(i%3?i%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(i){let n,r,s;for(n=0;n+3<=this.data.length;n+=3)r=this.data.substr(n,3),s=parseInt(r,10),i.put(s,10);const l=this.data.length-n;l>0&&(r=this.data.substr(n),s=parseInt(r,10),i.put(s,l*3+1))},Be=t,Be}var Me,Rt;function Hn(){if(Rt)return Me;Rt=1;const e=V(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function o(i){this.mode=e.ALPHANUMERIC,this.data=i}return o.getBitsLength=function(n){return 11*Math.floor(n/2)+6*(n%2)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(n){let r;for(r=0;r+2<=this.data.length;r+=2){let s=t.indexOf(this.data[r])*45;s+=t.indexOf(this.data[r+1]),n.put(s,11)}this.data.length%2&&n.put(t.indexOf(this.data[r]),6)},Me=o,Me}var Ie,At;function Kn(){if(At)return Ie;At=1;const e=V();function t(o){this.mode=e.BYTE,typeof o=="string"?this.data=new TextEncoder().encode(o):this.data=new Uint8Array(o)}return t.getBitsLength=function(i){return i*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(o){for(let i=0,n=this.data.length;i<n;i++)o.put(this.data[i],8)},Ie=t,Ie}var Le,Bt;function zn(){if(Bt)return Le;Bt=1;const e=V(),t=j();function o(i){this.mode=e.KANJI,this.data=i}return o.getBitsLength=function(n){return n*13},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(i){let n;for(n=0;n<this.data.length;n++){let r=t.toSJIS(this.data[n]);if(r>=33088&&r<=40956)r-=33088;else if(r>=57408&&r<=60351)r-=49472;else throw new Error("Invalid SJIS character: "+this.data[n]+`
|
|
3
|
+
Make sure your charset is UTF-8`);r=(r>>>8&255)*192+(r&255),i.put(r,13)}},Le=o,Le}var De={exports:{}},Mt;function On(){return Mt||(Mt=1,(function(e){var t={single_source_shortest_paths:function(o,i,n){var r={},s={};s[i]=0;var l=t.PriorityQueue.make();l.push(i,0);for(var a,f,h,c,_,d,b,N,P;!l.empty();){a=l.pop(),f=a.value,c=a.cost,_=o[f]||{};for(h in _)_.hasOwnProperty(h)&&(d=_[h],b=c+d,N=s[h],P=typeof s[h]>"u",(P||N>b)&&(s[h]=b,l.push(h,b),r[h]=f))}if(typeof n<"u"&&typeof s[n]>"u"){var y=["Could not find a path from ",i," to ",n,"."].join("");throw new Error(y)}return r},extract_shortest_path_from_predecessor_list:function(o,i){for(var n=[],r=i;r;)n.push(r),o[r],r=o[r];return n.reverse(),n},find_path:function(o,i,n){var r=t.single_source_shortest_paths(o,i,n);return t.extract_shortest_path_from_predecessor_list(r,n)},PriorityQueue:{make:function(o){var i=t.PriorityQueue,n={},r;o=o||{};for(r in i)i.hasOwnProperty(r)&&(n[r]=i[r]);return n.queue=[],n.sorter=o.sorter||i.default_sorter,n},default_sorter:function(o,i){return o.cost-i.cost},push:function(o,i){var n={value:o,cost:i};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(De)),De.exports}var It;function jn(){return It||(It=1,(function(e){const t=V(),o=Fn(),i=Hn(),n=Kn(),r=zn(),s=sn(),l=j(),a=On();function f(y){return unescape(encodeURIComponent(y)).length}function h(y,m,g){const p=[];let A;for(;(A=y.exec(g))!==null;)p.push({data:A[0],index:A.index,mode:m,length:A[0].length});return p}function c(y){const m=h(s.NUMERIC,t.NUMERIC,y),g=h(s.ALPHANUMERIC,t.ALPHANUMERIC,y);let p,A;return l.isKanjiModeEnabled()?(p=h(s.BYTE,t.BYTE,y),A=h(s.KANJI,t.KANJI,y)):(p=h(s.BYTE_KANJI,t.BYTE,y),A=[]),m.concat(g,p,A).sort(function(C,v){return C.index-v.index}).map(function(C){return{data:C.data,mode:C.mode,length:C.length}})}function _(y,m){switch(m){case t.NUMERIC:return o.getBitsLength(y);case t.ALPHANUMERIC:return i.getBitsLength(y);case t.KANJI:return r.getBitsLength(y);case t.BYTE:return n.getBitsLength(y)}}function d(y){return y.reduce(function(m,g){const p=m.length-1>=0?m[m.length-1]:null;return p&&p.mode===g.mode?(m[m.length-1].data+=g.data,m):(m.push(g),m)},[])}function b(y){const m=[];for(let g=0;g<y.length;g++){const p=y[g];switch(p.mode){case t.NUMERIC:m.push([p,{data:p.data,mode:t.ALPHANUMERIC,length:p.length},{data:p.data,mode:t.BYTE,length:p.length}]);break;case t.ALPHANUMERIC:m.push([p,{data:p.data,mode:t.BYTE,length:p.length}]);break;case t.KANJI:m.push([p,{data:p.data,mode:t.BYTE,length:f(p.data)}]);break;case t.BYTE:m.push([{data:p.data,mode:t.BYTE,length:f(p.data)}])}}return m}function N(y,m){const g={},p={start:{}};let A=["start"];for(let x=0;x<y.length;x++){const C=y[x],v=[];for(let w=0;w<C.length;w++){const E=C[w],k=""+x+w;v.push(k),g[k]={node:E,lastCount:0},p[k]={};for(let T=0;T<A.length;T++){const S=A[T];g[S]&&g[S].node.mode===E.mode?(p[S][k]=_(g[S].lastCount+E.length,E.mode)-_(g[S].lastCount,E.mode),g[S].lastCount+=E.length):(g[S]&&(g[S].lastCount=E.length),p[S][k]=_(E.length,E.mode)+4+t.getCharCountIndicator(E.mode,m))}}A=v}for(let x=0;x<A.length;x++)p[A[x]].end=0;return{map:p,table:g}}function P(y,m){let g;const p=t.getBestModeForData(y);if(g=t.from(m,p),g!==t.BYTE&&g.bit<p.bit)throw new Error('"'+y+'" cannot be encoded with mode '+t.toString(g)+`.
|
|
4
|
+
Suggested mode is: `+t.toString(p));switch(g===t.KANJI&&!l.isKanjiModeEnabled()&&(g=t.BYTE),g){case t.NUMERIC:return new o(y);case t.ALPHANUMERIC:return new i(y);case t.KANJI:return new r(y);case t.BYTE:return new n(y)}}e.fromArray=function(m){return m.reduce(function(g,p){return typeof p=="string"?g.push(P(p,null)):p.data&&g.push(P(p.data,p.mode)),g},[])},e.fromString=function(m,g){const p=c(m,l.isKanjiModeEnabled()),A=b(p),x=N(A,g),C=a.find_path(x.map,"start","end"),v=[];for(let w=1;w<C.length-1;w++)v.push(x.table[C[w]].node);return e.fromArray(d(v))},e.rawSplit=function(m){return e.fromArray(c(m,l.isKanjiModeEnabled()))}})(Ae)),Ae}var Lt;function Vn(){if(Lt)return ye;Lt=1;const e=j(),t=We(),o=Pn(),i=Rn(),n=An(),r=Bn(),s=Mn(),l=rn(),a=Dn(),f=Un(),h=qn(),c=V(),_=jn();function d(x,C){const v=x.size,w=r.getPositions(C);for(let E=0;E<w.length;E++){const k=w[E][0],T=w[E][1];for(let S=-1;S<=7;S++)if(!(k+S<=-1||v<=k+S))for(let R=-1;R<=7;R++)T+R<=-1||v<=T+R||(S>=0&&S<=6&&(R===0||R===6)||R>=0&&R<=6&&(S===0||S===6)||S>=2&&S<=4&&R>=2&&R<=4?x.set(k+S,T+R,!0,!0):x.set(k+S,T+R,!1,!0))}}function b(x){const C=x.size;for(let v=8;v<C-8;v++){const w=v%2===0;x.set(v,6,w,!0),x.set(6,v,w,!0)}}function N(x,C){const v=n.getPositions(C);for(let w=0;w<v.length;w++){const E=v[w][0],k=v[w][1];for(let T=-2;T<=2;T++)for(let S=-2;S<=2;S++)T===-2||T===2||S===-2||S===2||T===0&&S===0?x.set(E+T,k+S,!0,!0):x.set(E+T,k+S,!1,!0)}}function P(x,C){const v=x.size,w=f.getEncodedBits(C);let E,k,T;for(let S=0;S<18;S++)E=Math.floor(S/3),k=S%3+v-8-3,T=(w>>S&1)===1,x.set(E,k,T,!0),x.set(k,E,T,!0)}function y(x,C,v){const w=x.size,E=h.getEncodedBits(C,v);let k,T;for(k=0;k<15;k++)T=(E>>k&1)===1,k<6?x.set(k,8,T,!0):k<8?x.set(k+1,8,T,!0):x.set(w-15+k,8,T,!0),k<8?x.set(8,w-k-1,T,!0):k<9?x.set(8,15-k-1+1,T,!0):x.set(8,15-k-1,T,!0);x.set(w-8,8,1,!0)}function m(x,C){const v=x.size;let w=-1,E=v-1,k=7,T=0;for(let S=v-1;S>0;S-=2)for(S===6&&S--;;){for(let R=0;R<2;R++)if(!x.isReserved(E,S-R)){let K=!1;T<C.length&&(K=(C[T]>>>k&1)===1),x.set(E,S-R,K),k--,k===-1&&(T++,k=7)}if(E+=w,E<0||v<=E){E-=w,w=-w;break}}}function g(x,C,v){const w=new o;v.forEach(function(R){w.put(R.mode.bit,4),w.put(R.getLength(),c.getCharCountIndicator(R.mode,x)),R.write(w)});const E=e.getSymbolTotalCodewords(x),k=l.getTotalCodewordsCount(x,C),T=(E-k)*8;for(w.getLengthInBits()+4<=T&&w.put(0,4);w.getLengthInBits()%8!==0;)w.putBit(0);const S=(T-w.getLengthInBits())/8;for(let R=0;R<S;R++)w.put(R%2?17:236,8);return p(w,x,C)}function p(x,C,v){const w=e.getSymbolTotalCodewords(C),E=l.getTotalCodewordsCount(C,v),k=w-E,T=l.getBlocksCount(C,v),S=w%T,R=T-S,K=Math.floor(w/T),Q=Math.floor(k/T),cn=Q+1,Xe=K-Q,un=new a(Xe);let de=0;const Z=new Array(T),Ze=new Array(T);let he=0;const fn=new Uint8Array(x.buffer);for(let J=0;J<T;J++){const me=J<R?Q:cn;Z[J]=fn.slice(de,de+me),Ze[J]=un.encode(Z[J]),de+=me,he=Math.max(he,me)}const _e=new Uint8Array(w);let $e=0,U,q;for(U=0;U<he;U++)for(q=0;q<T;q++)U<Z[q].length&&(_e[$e++]=Z[q][U]);for(U=0;U<Xe;U++)for(q=0;q<T;q++)_e[$e++]=Ze[q][U];return _e}function A(x,C,v,w){let E;if(Array.isArray(x))E=_.fromArray(x);else if(typeof x=="string"){let K=C;if(!K){const Q=_.rawSplit(x);K=f.getBestVersionForData(Q,v)}E=_.fromString(x,K||40)}else throw new Error("Invalid data");const k=f.getBestVersionForData(E,v);if(!k)throw new Error("The amount of data is too big to be stored in a QR Code");if(!C)C=k;else if(C<k)throw new Error(`
|
|
5
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
6
|
+
Minimum version required to store current data is: `+k+`.
|
|
7
|
+
`);const T=g(C,v,E),S=e.getSymbolSize(C),R=new i(S);return d(R,C),b(R),N(R,C),y(R,v,0),C>=7&&P(R,C),m(R,T),isNaN(w)&&(w=s.getBestMask(R,y.bind(null,R,v))),s.applyMask(w,R),y(R,v,w),{modules:R,version:C,errorCorrectionLevel:v,maskPattern:w,segments:E}}return ye.create=function(C,v){if(typeof C>"u"||C==="")throw new Error("No input text");let w=t.M,E,k;return typeof v<"u"&&(w=t.from(v.errorCorrectionLevel,t.M),E=f.from(v.version),k=s.from(v.maskPattern),v.toSJISFunc&&e.setToSJISFunction(v.toSJISFunc)),A(C,E,w,k)},ye}var Ue={},qe={},Dt;function ln(){return Dt||(Dt=1,(function(e){function t(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let i=o.slice().replace("#","").split("");if(i.length<3||i.length===5||i.length>8)throw new Error("Invalid hex color: "+o);(i.length===3||i.length===4)&&(i=Array.prototype.concat.apply([],i.map(function(r){return[r,r]}))),i.length===6&&i.push("F","F");const n=parseInt(i.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+i.slice(0,6).join("")}}e.getOptions=function(i){i||(i={}),i.color||(i.color={});const n=typeof i.margin>"u"||i.margin===null||i.margin<0?4:i.margin,r=i.width&&i.width>=21?i.width:void 0,s=i.scale||4;return{width:r,scale:r?4:s,margin:n,color:{dark:t(i.color.dark||"#000000ff"),light:t(i.color.light||"#ffffffff")},type:i.type,rendererOpts:i.rendererOpts||{}}},e.getScale=function(i,n){return n.width&&n.width>=i+n.margin*2?n.width/(i+n.margin*2):n.scale},e.getImageWidth=function(i,n){const r=e.getScale(i,n);return Math.floor((i+n.margin*2)*r)},e.qrToImageData=function(i,n,r){const s=n.modules.size,l=n.modules.data,a=e.getScale(s,r),f=Math.floor((s+r.margin*2)*a),h=r.margin*a,c=[r.color.light,r.color.dark];for(let _=0;_<f;_++)for(let d=0;d<f;d++){let b=(_*f+d)*4,N=r.color.light;if(_>=h&&d>=h&&_<f-h&&d<f-h){const P=Math.floor((_-h)/a),y=Math.floor((d-h)/a);N=c[l[P*s+y]?1:0]}i[b++]=N.r,i[b++]=N.g,i[b++]=N.b,i[b]=N.a}}})(qe)),qe}var Ut;function Jn(){return Ut||(Ut=1,(function(e){const t=ln();function o(n,r,s){n.clearRect(0,0,r.width,r.height),r.style||(r.style={}),r.height=s,r.width=s,r.style.height=s+"px",r.style.width=s+"px"}function i(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(r,s,l){let a=l,f=s;typeof a>"u"&&(!s||!s.getContext)&&(a=s,s=void 0),s||(f=i()),a=t.getOptions(a);const h=t.getImageWidth(r.modules.size,a),c=f.getContext("2d"),_=c.createImageData(h,h);return t.qrToImageData(_.data,r,a),o(c,f,h),c.putImageData(_,0,0),f},e.renderToDataURL=function(r,s,l){let a=l;typeof a>"u"&&(!s||!s.getContext)&&(a=s,s=void 0),a||(a={});const f=e.render(r,s,a),h=a.type||"image/png",c=a.rendererOpts||{};return f.toDataURL(h,c.quality)}})(Ue)),Ue}var Fe={},qt;function Yn(){if(qt)return Fe;qt=1;const e=ln();function t(n,r){const s=n.a/255,l=r+'="'+n.hex+'"';return s<1?l+" "+r+'-opacity="'+s.toFixed(2).slice(1)+'"':l}function o(n,r,s){let l=n+r;return typeof s<"u"&&(l+=" "+s),l}function i(n,r,s){let l="",a=0,f=!1,h=0;for(let c=0;c<n.length;c++){const _=Math.floor(c%r),d=Math.floor(c/r);!_&&!f&&(f=!0),n[c]?(h++,c>0&&_>0&&n[c-1]||(l+=f?o("M",_+s,.5+d+s):o("m",a,0),a=0,f=!1),_+1<r&&n[c+1]||(l+=o("h",h),h=0)):a++}return l}return Fe.render=function(r,s,l){const a=e.getOptions(s),f=r.modules.size,h=r.modules.data,c=f+a.margin*2,_=a.color.light.a?"<path "+t(a.color.light,"fill")+' d="M0 0h'+c+"v"+c+'H0z"/>':"",d="<path "+t(a.color.dark,"stroke")+' d="'+i(h,f,a.margin)+'"/>',b='viewBox="0 0 '+c+" "+c+'"',P='<svg xmlns="http://www.w3.org/2000/svg" '+(a.width?'width="'+a.width+'" height="'+a.width+'" ':"")+b+' shape-rendering="crispEdges">'+_+d+`</svg>
|
|
8
|
+
`;return typeof l=="function"&&l(null,P),P},Fe}var Ft;function Gn(){if(Ft)return Y;Ft=1;const e=Tn(),t=Vn(),o=Jn(),i=Yn();function n(r,s,l,a,f){const h=[].slice.call(arguments,1),c=h.length,_=typeof h[c-1]=="function";if(!_&&!e())throw new Error("Callback required as last argument");if(_){if(c<2)throw new Error("Too few arguments provided");c===2?(f=l,l=s,s=a=void 0):c===3&&(s.getContext&&typeof f>"u"?(f=a,a=void 0):(f=a,a=l,l=s,s=void 0))}else{if(c<1)throw new Error("Too few arguments provided");return c===1?(l=s,s=a=void 0):c===2&&!s.getContext&&(a=l,l=s,s=void 0),new Promise(function(d,b){try{const N=t.create(l,a);d(r(N,s,a))}catch(N){b(N)}})}try{const d=t.create(l,a);f(null,r(d,s,a))}catch(d){f(d)}}return Y.create=t.create,Y.toCanvas=n.bind(null,o.render),Y.toDataURL=n.bind(null,o.renderToDataURL),Y.toString=n.bind(null,function(r,s,l){return i.render(r,l)}),Y}var Qn=Gn();const Wn=Sn(Qn);function je({message:e,confirmLabel:t="Confirm",confirmDanger:o=!1,onConfirm:i,onCancel:n}){return u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.6)"},children:u("div",{className:"glass-card p-5 flex flex-col gap-4 w-72",children:[u("p",{className:"text-sm text-white text-center",children:e}),u("div",{className:"flex gap-2",children:[u("button",{onClick:n,className:"glass-btn flex-1 py-2 text-sm text-white/60 hover:text-white",children:"Cancel"}),u("button",{onClick:i,className:"flex-1 py-2 text-sm font-semibold rounded-xl",style:{background:o?"rgba(220,53,69,0.8)":"var(--brand-500)",color:"#fff"},children:t})]})]})})}const Ht="9remote.cc";function Xn(e){if(e<=0)return"Expired";const t=Math.floor(e/1e3),o=Math.floor(t/60),i=t%60;return`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function te({icon:e,onClick:t,title:o,danger:i}){return u("button",{onClick:t,title:o,className:"glass-btn w-7 h-7 flex items-center justify-center flex-shrink-0 text-white/50 hover:text-white",style:i?{color:"rgba(255,100,100,0.7)"}:{},children:u("span",{className:"material-symbols-outlined",style:{fontSize:15},children:e})})}function Zn({qrUrl:e,oneTimeKey:t,oneTimeKeyExpiresAt:o,permanentKey:i,onGenerateOneTimeKey:n,onRegenerateKey:r}){const s=en(null),[l,a]=L(null),[f,h]=L(null),[c,_]=L(null);ce(()=>{!e||!s.current||Wn.toCanvas(s.current,e,{width:160,margin:1,color:{dark:"#0f1923",light:"#ffffff"}}).catch(()=>{})},[e]),ce(()=>{if(!o){a(null);return}const b=()=>a(o-Date.now());b();const N=setInterval(b,1e3);return()=>clearInterval(N)},[o]);const d=(b,N)=>{navigator.clipboard.writeText(b).catch(()=>{}),h(N),setTimeout(()=>h(null),2e3)};return u(H,{children:[c==="oneTime"&&u(je,{message:"Generate a new one-time key? The current one will expire immediately.",confirmLabel:"Generate",onConfirm:()=>{_(null),n==null||n()},onCancel:()=>_(null)}),c==="regen"&&u(je,{message:"Regenerate permanent key? All existing sessions will be disconnected.",confirmLabel:"Regenerate",confirmDanger:!0,onConfirm:()=>{_(null),r==null||r()},onCancel:()=>_(null)}),u("div",{className:"glass-card p-5 flex flex-col items-center gap-4",children:[u("div",{className:"w-44 h-44 rounded-xl overflow-hidden bg-white p-2 flex items-center justify-center flex-shrink-0",children:e?u("canvas",{ref:s}):u("span",{className:"material-symbols-outlined text-gray-300 text-6xl",children:"qr_code_2"})}),u("a",{href:`https://${Ht}/login`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 hover:opacity-80 transition-opacity",children:[u("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 flex-shrink-0"}),u("span",{className:"text-xs text-white/60 font-medium",children:[Ht,"/login"]})]}),u("div",{className:"w-full h-px bg-white/5"}),u("div",{className:"w-full flex flex-col gap-1.5",children:[u("div",{className:"flex items-center justify-between px-0.5",children:[u("span",{className:"text-xs font-medium text-white/50",children:"One-Time Key"}),u("span",{className:"text-xs text-white/30",children:"Single use · expires"})]}),u("div",{className:"w-full flex items-center gap-2 dark-card px-3 py-2.5",children:[u("span",{className:"material-symbols-outlined text-white/30 flex-shrink-0",style:{fontSize:16},children:"timer"}),u("span",{className:"flex-1 font-mono font-bold tracking-[0.18em] text-base truncate",style:{color:t?"var(--brand-500)":"rgba(255,255,255,0.15)"},children:t||"• • • • • •"}),l!==null&&u("span",{className:`text-xs font-mono flex-shrink-0 ${l<=0?"text-red-400":"text-white/40"}`,children:Xn(l)}),t&&u(te,{icon:f==="oneTime"?"check":"content_copy",onClick:()=>d(t,"oneTime"),title:"Copy one-time key"}),u(te,{icon:"refresh",onClick:()=>_("oneTime"),title:"New one-time key"})]})]}),u("div",{className:"w-full flex flex-col gap-1.5",children:[u("div",{className:"flex items-center justify-between px-0.5",children:[u("span",{className:"text-xs font-medium text-white/50",children:"Permanent Key"}),u("span",{className:"text-xs text-white/30",children:"Reusable · no expiry"})]}),u("div",{className:"w-full flex items-center gap-2 dark-card px-3 py-2.5",children:[u("span",{className:"material-symbols-outlined text-white/30 flex-shrink-0",style:{fontSize:16},children:"key"}),u("span",{className:"flex-1 font-mono text-xs text-white/50 truncate",children:i||"— not set —"}),i&&u(te,{icon:f==="permanent"?"check":"content_copy",onClick:()=>d(i,"permanent"),title:"Copy permanent key"}),u(te,{icon:"autorenew",onClick:()=>_("regen"),title:"Regenerate permanent key",danger:!0})]})]})]})]})}const $n="https://docs.9remote.cc/",an={screenRecording:{label:"Screen Recording",icon:"screenshot_monitor",desc:"Capture screen content"},accessibility:{label:"Accessibility",icon:"accessibility_new",desc:"Control mouse & keyboard"}};function er({type:e,granted:t,onRequest:o}){const i=an[e]||{label:e,desc:""};return u("div",{className:"flex items-center gap-3 py-2 border-b border-white/5 last:border-0",children:[u("span",{className:`material-symbols-outlined flex-shrink-0 ${t?"text-green-400":"text-white/30"}`,style:{fontSize:18},children:t?"check_circle":"cancel"}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:`text-xs font-medium ${t?"text-white/80":"text-white/50"}`,children:i.label}),u("p",{className:"text-[10px] text-white/30 leading-4",children:i.desc})]}),!t&&u("button",{onClick:()=>o(e),className:"flex-shrink-0 text-xs px-2.5 py-1 rounded-lg font-medium",style:{background:"rgba(255,87,10,0.15)",color:"var(--brand-400)"},children:"Grant"})]})}function tr(){return u("div",{className:"glass-card p-4 flex items-center gap-3",children:[u("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"rgba(255,87,10,0.15)"},children:u("span",{className:"material-symbols-outlined",style:{fontSize:20,color:"var(--brand-400)"},children:"terminal"})}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-sm font-semibold text-white",children:"Remote Terminal"}),u("p",{className:"text-xs text-white/40",children:"Full shell access · always on"})]}),u("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-full",style:{background:"rgba(74,222,128,0.1)"},children:[u("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400"}),u("span",{className:"text-xs text-green-400 font-medium",children:"On"})]})]})}function nr({enabled:e,onToggle:t,permissions:o,onRequestPermission:i}){const n=Object.entries(an);return u("div",{className:"glass-card p-4 flex flex-col gap-3",children:[u("div",{className:"flex items-center gap-3",children:[u("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:e?"rgba(255,87,10,0.15)":"rgba(255,255,255,0.05)"},children:u("span",{className:"material-symbols-outlined",style:{fontSize:20,color:e?"var(--brand-400)":"rgba(255,255,255,0.25)"},children:"desktop_windows"})}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-sm font-semibold text-white",children:"Remote Desktop"}),u("p",{className:"text-xs text-white/40",children:"Control screen, mouse & keyboard"})]}),u("button",{onClick:t,className:"flex-shrink-0 w-11 h-6 rounded-full transition-all relative",style:{background:e?"var(--brand-500)":"rgba(255,255,255,0.1)"},children:u("span",{className:"absolute top-0.5 w-5 h-5 rounded-full bg-white transition-all",style:{left:e?"calc(100% - 22px)":"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]}),e&&u("div",{className:"flex flex-col border-t border-white/5 pt-2",children:[u("p",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"System Permissions"}),n.map(([r])=>u(er,{type:r,granted:(o==null?void 0:o[r])??!1,onRequest:i},r))]})]})}function rr({version:e}){return e?u("div",{className:"px-5 py-2 flex items-center gap-2 border-b",style:{background:"rgba(255,87,10,0.08)",borderColor:"rgba(255,87,10,0.2)"},children:[u("span",{className:"material-symbols-outlined text-sm flex-shrink-0",style:{color:"var(--brand-400)"},children:"system_update"}),u("span",{className:"text-xs flex-1",style:{color:"var(--brand-400)"},children:["Version ",e," available"]}),u("button",{onClick:()=>fetch("/api/update",{method:"POST"}).catch(()=>{}),className:"flex-shrink-0 text-xs px-2 py-0.5 rounded font-medium",style:{background:"rgba(255,87,10,0.15)",color:"var(--brand-400)"},children:"Update"})]}):null}const or=[{icon:"terminal",label:"Terminal",desc:"Full shell access"},{icon:"desktop_windows",label:"Desktop",desc:"Remote screen control"},{icon:"folder_open",label:"Files",desc:"Browse & edit files"}],ir=[{icon:"qr_code_scanner",text:"Scan QR to connect instantly"},{icon:"wifi_off",text:"No port forwarding needed"},{icon:"devices",text:"Works on any device"}];function sr({onStart:e}){const[t,o]=L(!1),i=()=>{o(!0),e()};return u("div",{className:"flex-1 flex flex-col items-center justify-between px-6 py-6 overflow-y-auto",children:[u("div",{className:"flex flex-col items-center gap-2 text-center mt-2",children:[u("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mb-1",style:{background:"var(--brand-500)",boxShadow:"0 8px 32px rgba(255,87,10,0.35)"},children:u("span",{className:"material-symbols-outlined text-white",style:{fontSize:30},children:"terminal"})}),u("h1",{className:"text-lg font-bold text-white tracking-tight",children:"9Remote"}),u("p",{className:"text-xs text-white/50 leading-5 max-w-[220px]",children:"Access your terminal, desktop & files from anywhere"})]}),u("div",{className:"flex gap-2 w-full mt-5",children:or.map(n=>u("div",{className:"flex-1 dark-card flex flex-col items-center gap-1.5 py-3 px-1",children:[u("span",{className:"material-symbols-outlined text-white/70",style:{fontSize:22,color:"var(--brand-400)"},children:n.icon}),u("p",{className:"text-xs font-semibold text-white",children:n.label}),u("p",{className:"text-[10px] text-white/40 text-center leading-4",children:n.desc})]},n.label))}),u("div",{className:"flex flex-col gap-2 w-full mt-4",children:ir.map(n=>u("div",{className:"flex items-center gap-2.5",children:[u("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:16,color:"var(--brand-400)"},children:n.icon}),u("span",{className:"text-xs text-white/60",children:n.text})]},n.text))}),u("button",{onClick:t?void 0:i,disabled:t,className:"btn-primary w-full py-3.5 flex items-center justify-center gap-2 text-sm font-semibold mt-6",style:{borderRadius:"var(--radius-brand)",opacity:t?.7:1},children:t?u(H,{children:[u("span",{className:"flex gap-0.5 items-center",children:[0,1,2].map(n=>u("span",{className:"w-1.5 h-1.5 rounded-full bg-white dot-bounce",style:{animationDelay:`${n*.18}s`}},n))}),"Connecting..."]}):u(H,{children:[u("span",{className:"material-symbols-outlined text-base",children:"play_arrow"}),"Connect"]})})]})}function lr({conn:e}){return u("div",{className:"flex items-center gap-3 py-2 border-b border-white/5 last:border-0",children:[u("div",{className:"w-2 h-2 rounded-full bg-green-400 flex-shrink-0"}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-xs text-white font-medium truncate",children:e.ip||"Unknown"}),u("p",{className:"text-xs text-white/30",children:e.connectedAt?new Date(e.connectedAt).toLocaleTimeString():""})]}),u("span",{className:"text-xs text-white/30",children:e.type||"ws"})]})}function ar({step:e,tunnelUrl:t,oneTimeKey:o,oneTimeKeyExpiresAt:i,permanentKey:n,qrUrl:r,permissions:s,desktopEnabled:l,updateVersion:a,connections:f=[],onRequestPermission:h,onDesktopToggle:c,onStop:_,onStart:d,onGenerateOneTimeKey:b,onRegenerateKey:N,logs:P=[]}){const[y,m]=L("connect"),[g,p]=L(!1),A=en(null),x=e===0,C=e>0&&e<4;return ce(()=>{var v;y==="log"&&((v=A.current)==null||v.scrollIntoView({behavior:"smooth"}))},[P,y]),u("div",{className:"h-full flex flex-col relative overflow-hidden",style:{background:"#333"},children:[u("div",{className:"flex-1 flex flex-col w-full max-w-sm mx-auto min-h-0 dot-grid-bg overflow-hidden",children:[u("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/5",children:[u("div",{className:"flex items-center gap-3",children:[u("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--brand-500)"},children:u("span",{className:"material-symbols-outlined text-white text-base",children:"terminal"})}),u("span",{className:"brand-text text-xs",children:"9Remote"})]}),u("div",{className:"flex items-center gap-2",children:[u("button",{onClick:()=>window.open($n,"_blank"),className:"glass-btn w-7 h-7 flex items-center justify-center text-white/40 hover:text-white",children:u("span",{className:"material-symbols-outlined text-sm",children:"help_outline"})}),!x&&u("button",{onClick:()=>p(!0),className:"btn-danger px-3 h-7 flex items-center gap-1.5 text-xs font-medium",children:[u("span",{className:"material-symbols-outlined text-sm",children:"stop_circle"}),"Disconnect"]})]})]}),u(rr,{version:a}),x?u(sr,{onStart:d,connecting:!1}):C?u("div",{className:"flex-1 overflow-y-auto px-5 py-4 flex flex-col gap-4",children:u(kn,{currentStep:e})}):u(H,{children:[u("div",{className:"flex px-5 gap-3 border-b border-white/5",children:[{id:"connect",label:"Connection"},{id:"log",label:"Logs"}].map(v=>u("button",{onClick:()=>m(v.id),className:"pb-2 text-xs font-medium border-b-2 transition-colors",style:y===v.id?{borderColor:"var(--brand-500)",color:"var(--brand-500)"}:{borderColor:"transparent",color:"rgba(255,255,255,0.4)"},children:v.label},v.id))}),u("div",{className:"flex-1 overflow-y-auto px-5 py-4 flex flex-col gap-4",children:[y==="connect"&&u(H,{children:[u(Zn,{qrUrl:r,oneTimeKey:o,oneTimeKeyExpiresAt:i,permanentKey:n,tunnelUrl:t,onGenerateOneTimeKey:b,onRegenerateKey:N}),u(tr,{}),u(nr,{enabled:l,onToggle:c,permissions:s,onRequestPermission:h}),u("div",{className:"glass-card p-4 flex flex-col gap-1",children:[u("p",{className:"text-xs text-white/60 font-medium uppercase tracking-wider mb-2",children:["Clients",f.length>0?` (${f.length})`:""]}),f.length===0?u("p",{className:"text-xs text-white/30 text-center py-3",children:"No active connections"}):f.map((v,w)=>u(lr,{conn:v},w))]})]}),y==="log"&&u("div",{className:"flex-1 flex flex-col",children:P.length===0?u("p",{className:"text-xs text-white/30 text-center mt-8",children:"No logs yet"}):u("div",{className:"flex flex-col gap-0.5",children:[P.map((v,w)=>u("p",{className:"text-xs font-mono text-white/60 leading-5 break-all",children:v},w)),u("div",{ref:A})]})})]})]})]}),g&&u(je,{message:"Disconnect and stop the tunnel? Remote clients will be disconnected.",confirmLabel:"Disconnect",confirmDanger:!0,onConfirm:()=>{p(!1),_==null||_()},onCancel:()=>p(!1)})]})}const Kt={step:0,tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null,permanentKey:"",qrUrl:"",latency:null,uptime:null},cr={screenRecording:!1,accessibility:!1},zt=200;function ur(){const[e,t]=L(Kt),[o,i]=L(cr),[n,r]=L(!1),[s,l]=L([]),[a,f]=L(null),[h,c]=L([]);ce(()=>{fetch("/api/ui/state").then(g=>g.json()).then(g=>{t({step:g.step??0,tunnelUrl:g.tunnelUrl??"",oneTimeKey:g.oneTimeKey??"",oneTimeKeyExpiresAt:g.oneTimeKeyExpiresAt??null,permanentKey:g.permanentKey??"",qrUrl:g.qrUrl??"",latency:g.latency??null,uptime:g.uptime??null}),i({screenRecording:g.screenRecording??!1,accessibility:g.accessibility??!1}),g.desktopEnabled!==void 0&&r(g.desktopEnabled)}).catch(()=>{});const m=new EventSource("/api/ui/events");return m.onmessage=g=>{try{const p=JSON.parse(g.data);p.type==="state"?t({step:p.step??0,tunnelUrl:p.tunnelUrl??"",oneTimeKey:p.oneTimeKey??"",oneTimeKeyExpiresAt:p.oneTimeKeyExpiresAt??null,permanentKey:p.permanentKey??"",qrUrl:p.qrUrl??"",latency:p.latency??null,uptime:p.uptime??null}):p.type==="log"?l(A=>{const x=[...A,p.message];return x.length>zt?x.slice(-zt):x}):p.type==="updateAvailable"?f(p.version):p.type==="permissions"?(i({screenRecording:p.screenRecording,accessibility:p.accessibility}),p.desktopEnabled!==void 0&&r(p.desktopEnabled)):p.type==="connections"&&c(p.connections??[])}catch{}},m.onerror=()=>{},()=>m.close()},[]);const _=async m=>{await fetch("/api/permissions/request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:m})}).catch(()=>{})},d=()=>{fetch("/api/ui/stop",{method:"POST"}).catch(()=>{}),t(Kt)},b=()=>{fetch("/api/ui/start",{method:"POST"}).catch(()=>{})},N=async()=>{const m=await fetch("/api/key/one-time",{method:"POST"}).catch(()=>null);if(!(m!=null&&m.ok))return;const g=await m.json().catch(()=>null);g!=null&&g.oneTimeKey&&t(p=>({...p,oneTimeKey:g.oneTimeKey,oneTimeKeyExpiresAt:g.expiresAt,qrUrl:g.qrUrl??p.qrUrl}))},P=async()=>{const m=!n;r(m),await fetch("/api/desktop/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:m})}).catch(()=>{})},y=async()=>{const m=await fetch("/api/key/regenerate",{method:"POST"}).catch(()=>null);if(!(m!=null&&m.ok))return;const g=await m.json().catch(()=>null);g!=null&&g.permanentKey&&t(p=>({...p,permanentKey:g.permanentKey}))};return u(ar,{step:e.step,tunnelUrl:e.tunnelUrl,oneTimeKey:e.oneTimeKey,oneTimeKeyExpiresAt:e.oneTimeKeyExpiresAt,permanentKey:e.permanentKey,qrUrl:e.qrUrl,permissions:o,desktopEnabled:n,updateVersion:a,connections:h,onRequestPermission:_,onDesktopToggle:P,onStop:d,onStart:b,onGenerateOneTimeKey:N,onRegenerateKey:y,logs:s})}wn(u(ur,{}),document.getElementById("root"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap";@import"https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap";@import"https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200";*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}*{box-sizing:border-box;margin:0;padding:0}html,body,#root{height:100%;width:100%;overflow:hidden}body{font-family:Inter,sans-serif;background-color:#333;color:#fff;-webkit-font-smoothing:antialiased;-webkit-user-select:none;-moz-user-select:none;user-select:none}input,textarea{accent-color:var(--brand-500)}button{-webkit-user-select:none;-moz-user-select:none;user-select:none}.dot-grid-bg{background-color:var(--dark-800);background-image:radial-gradient(circle at 15% 20%,rgba(255,87,10,.2) 0%,transparent 45%),radial-gradient(circle at 85% 80%,rgba(255,87,10,.12) 0%,transparent 45%),linear-gradient(rgba(255,255,255,.04) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.04) 1px,transparent 1px);background-size:100% 100%,100% 100%,40px 40px,40px 40px}.dark-card,.glass-card{background:var(--dark-600);border:1px solid var(--dark-400);border-radius:var(--radius-brand)}.glass-btn{background:#ffffff0f;border:1px solid rgba(255,255,255,.1);border-radius:8px;transition:all .2s ease}.glass-btn:hover{background:#ffffff1a;border-color:#ffffff2e}.btn-primary{background:var(--brand-500);border-radius:var(--radius-brand);color:#fff;font-weight:600;transition:all .2s ease;box-shadow:0 4px 16px #ff570a33}.btn-primary:hover{background:var(--brand-600);transform:scale(1.02)}.btn-primary:disabled{background:#ff570a4d;cursor:not-allowed;transform:none;box-shadow:none}.btn-danger{background:#dc35451f;border:1px solid rgba(220,53,69,.25);border-radius:var(--radius-brand);color:#ff6b7a;font-weight:600;transition:all .2s ease}.btn-danger:hover{background:#dc354538;border-color:#dc354566}.brand-text{font-family:"Press Start 2P",monospace;color:var(--brand-500);letter-spacing:.05em}.material-symbols-outlined{font-variation-settings:"FILL" 0,"wght" 400,"GRAD" 0,"opsz" 24}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.top-0\.5{top:.125rem}.z-50{z-index:50}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mt-0\.5{margin-top:.125rem}.mt-2{margin-top:.5rem}.mt-4{margin-top:1rem}.mt-5{margin-top:1.25rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.inline{display:inline}.flex{display:flex}.h-1{height:.25rem}.h-1\.5{height:.375rem}.h-14{height:3.5rem}.h-2{height:.5rem}.h-44{height:11rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-full{height:100%}.h-px{height:1px}.min-h-0{min-height:0px}.w-1{width:.25rem}.w-1\.5{width:.375rem}.w-11{width:2.75rem}.w-14{width:3.5rem}.w-2{width:.5rem}.w-44{width:11rem}.w-5{width:1.25rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-8{width:2rem}.w-9{width:2.25rem}.w-full{width:100%}.min-w-0{min-width:0px}.max-w-\[220px\]{max-width:220px}.max-w-sm{max-width:24rem}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:1rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-t{border-top-width:1px}.border-white\/5{border-color:#ffffff0d}.bg-green-400{--tw-bg-opacity: 1;background-color:rgb(74 222 128 / var(--tw-bg-opacity, 1))}.bg-orange-400{--tw-bg-opacity: 1;background-color:rgb(251 146 60 / var(--tw-bg-opacity, 1))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-white\/5{background-color:#ffffff0d}.p-2{padding:.5rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-3\.5{padding-top:.875rem;padding-bottom:.875rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-2{padding-bottom:.5rem}.pt-2{padding-top:.5rem}.text-center{text-align:center}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-6xl{font-size:3.75rem;line-height:1}.text-\[10px\]{font-size:10px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.tracking-\[0\.18em\]{letter-spacing:.18em}.tracking-tight{letter-spacing:-.025em}.tracking-wider{letter-spacing:.05em}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-white\/20{color:#fff3}.text-white\/25{color:#ffffff40}.text-white\/30{color:#ffffff4d}.text-white\/40{color:#fff6}.text-white\/50{color:#ffffff80}.text-white\/60{color:#fff9}.text-white\/70{color:#ffffffb3}.text-white\/80{color:#fffc}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--brand-500: #FF570A;--brand-600: #e04400;--brand-400: #ff6e33;--dark-400: #404040;--dark-500: #252525;--dark-600: #1a1a1a;--dark-700: #121212;--dark-800: #0d0d0d;--dark-100: #a0a0a0;--radius-brand: 12px;--radius-brand-lg: 16px}@keyframes pulse-ring{0%{transform:scale(.8);opacity:1}to{transform:scale(1.6);opacity:0}}.pulse-ring{animation:pulse-ring 1.4s ease-out infinite}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.spin{animation:spin 1s linear infinite}@keyframes dot-bounce{0%,80%,to{transform:scale(.6);opacity:.4}40%{transform:scale(1);opacity:1}}.dot-bounce{animation:dot-bounce 1s ease-in-out infinite}.last\:border-0:last-child{border-width:0px}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\:opacity-80:hover{opacity:.8}
|
package/dist/ui/index.html
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
9
9
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
|
|
10
10
|
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" rel="stylesheet" />
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
12
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-CMD-4YxV.js"></script>
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/index-D4GJ1wNn.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<div id="root"></div>
|
package/index.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { createServer, request as httpRequest } from "http";
|
|
6
6
|
import { parse } from "url";
|
|
7
|
-
import { exec } from "child_process";
|
|
8
|
-
import { readFileSync, existsSync } from "fs";
|
|
7
|
+
import { exec, execSync } from "child_process";
|
|
8
|
+
import { readFileSync, existsSync, writeFileSync, mkdirSync } from "fs";
|
|
9
9
|
import { join, extname } from "path";
|
|
10
10
|
import { fileURLToPath } from "url";
|
|
11
11
|
import { setupSocketIO, getIO } from "./lib/socketio.js";
|
|
@@ -16,6 +16,10 @@ import { initializeTerminal } from "./features/terminal/terminalSocket.js";
|
|
|
16
16
|
import { sendPushNotification } from "./features/terminal/pushManager.js";
|
|
17
17
|
import { addNotification } from "./features/terminal/notificationManager.js";
|
|
18
18
|
import chalk from "chalk";
|
|
19
|
+
import { loadKey, saveKey, writeCmd } from "./cli/utils/state.js";
|
|
20
|
+
import { checkPermissions, openPermissionPane } from "./cli/utils/permissions.js";
|
|
21
|
+
import { generateApiKeyWithMachine } from "./cli/utils/apiKey.js";
|
|
22
|
+
import { getConsistentMachineId } from "./cli/utils/machineId.js";
|
|
19
23
|
|
|
20
24
|
const __dirname = fileURLToPath(new URL(".", import.meta.url));
|
|
21
25
|
const IS_DEV = process.env.NODE_ENV === "development";
|
|
@@ -81,6 +85,32 @@ async function checkForUpdate(currentVersion) {
|
|
|
81
85
|
|
|
82
86
|
// ── UI State (SSE) ──────────────────────────────────────────────────────────
|
|
83
87
|
|
|
88
|
+
const UI_STATE_FILE = join(
|
|
89
|
+
process.env.HOME || process.env.USERPROFILE || ".",
|
|
90
|
+
".9remote", "ui-state.json"
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
/** Persist uiState to disk */
|
|
94
|
+
function saveUiState() {
|
|
95
|
+
try {
|
|
96
|
+
mkdirSync(join(process.env.HOME || process.env.USERPROFILE || ".", ".9remote"), { recursive: true });
|
|
97
|
+
writeFileSync(UI_STATE_FILE, JSON.stringify(uiState));
|
|
98
|
+
} catch {}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Load uiState from disk */
|
|
102
|
+
function loadUiState() {
|
|
103
|
+
try {
|
|
104
|
+
if (existsSync(UI_STATE_FILE)) {
|
|
105
|
+
const saved = JSON.parse(readFileSync(UI_STATE_FILE, "utf8"));
|
|
106
|
+
// Only restore if tunnel was ready — otherwise start fresh
|
|
107
|
+
if (saved.step === 4 && saved.permanentKey) {
|
|
108
|
+
uiState = { ...uiState, ...saved };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
} catch {}
|
|
112
|
+
}
|
|
113
|
+
|
|
84
114
|
// In-memory UI state + SSE clients
|
|
85
115
|
let uiState = { step: 0, tunnelUrl: "", oneTimeKey: "", oneTimeKeyExpiresAt: null, permanentKey: "", qrUrl: "", latency: null, uptime: null };
|
|
86
116
|
const sseClients = new Set();
|
|
@@ -88,6 +118,72 @@ const sseClients = new Set();
|
|
|
88
118
|
// Active socket connections for UI display
|
|
89
119
|
const activeConnections = new Map();
|
|
90
120
|
|
|
121
|
+
// Remote desktop toggle state — loaded from state file on start
|
|
122
|
+
let desktopEnabled = false;
|
|
123
|
+
|
|
124
|
+
const DESKTOP_STATE_FILE = join(
|
|
125
|
+
process.env.HOME || process.env.USERPROFILE || ".",
|
|
126
|
+
".9remote", "desktop.json"
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
/** Load desktopEnabled from state file */
|
|
130
|
+
function loadDesktopState() {
|
|
131
|
+
try {
|
|
132
|
+
if (existsSync(DESKTOP_STATE_FILE)) {
|
|
133
|
+
const data = JSON.parse(readFileSync(DESKTOP_STATE_FILE, "utf8"));
|
|
134
|
+
desktopEnabled = !!data.enabled;
|
|
135
|
+
}
|
|
136
|
+
} catch {}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Save desktopEnabled to state file */
|
|
140
|
+
function saveDesktopState() {
|
|
141
|
+
try {
|
|
142
|
+
mkdirSync(join(process.env.HOME || process.env.USERPROFILE || ".", ".9remote"), { recursive: true });
|
|
143
|
+
writeFileSync(DESKTOP_STATE_FILE, JSON.stringify({ enabled: desktopEnabled }));
|
|
144
|
+
} catch {}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Cached permissions — refreshed async, never blocks request
|
|
148
|
+
let cachedPermissions = { screenRecording: false, accessibility: false };
|
|
149
|
+
|
|
150
|
+
function refreshPermissionsAsync() {
|
|
151
|
+
checkPermissions().then((p) => { cachedPermissions = p; });
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function getSystemPermissions() {
|
|
155
|
+
return cachedPermissions;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Open System Preferences pane for a permission, then poll until granted */
|
|
159
|
+
function requestSystemPermission(type) {
|
|
160
|
+
return new Promise((resolve) => {
|
|
161
|
+
if (process.platform !== "darwin") { resolve(); return; }
|
|
162
|
+
openPermissionPane(type);
|
|
163
|
+
resolve(); // resolve immediately — UI stays open
|
|
164
|
+
|
|
165
|
+
// Poll every 2s for up to 60s to detect when user grants permission
|
|
166
|
+
let attempts = 0;
|
|
167
|
+
const poll = setInterval(() => {
|
|
168
|
+
attempts++;
|
|
169
|
+
checkPermissions().then((p) => {
|
|
170
|
+
cachedPermissions = p;
|
|
171
|
+
if (p[type] || attempts >= 30) {
|
|
172
|
+
clearInterval(poll);
|
|
173
|
+
pushUiEvent("permissions", { ...cachedPermissions, desktopEnabled });
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}, 2000);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Clear one-time key from UI state after client uses it */
|
|
181
|
+
export function clearOneTimeKey() {
|
|
182
|
+
uiState = { ...uiState, oneTimeKey: "", oneTimeKeyExpiresAt: null, qrUrl: "" };
|
|
183
|
+
pushUiEvent("state", uiState);
|
|
184
|
+
saveUiState();
|
|
185
|
+
}
|
|
186
|
+
|
|
91
187
|
/** Track a new socket connection */
|
|
92
188
|
export function trackConnection(socketId, ip, type = "ws") {
|
|
93
189
|
activeConnections.set(socketId, { ip, type, connectedAt: Date.now() });
|
|
@@ -120,9 +216,10 @@ function handleUiEvents(req, res) {
|
|
|
120
216
|
res.setHeader("Connection", "keep-alive");
|
|
121
217
|
res.writeHead(200);
|
|
122
218
|
|
|
123
|
-
// Send current state + connections immediately on connect
|
|
219
|
+
// Send current state + connections + permissions immediately on connect
|
|
124
220
|
res.write(`data: ${JSON.stringify({ type: "state", ...uiState })}\n\n`);
|
|
125
221
|
res.write(`data: ${JSON.stringify({ type: "connections", connections: [...activeConnections.values()] })}\n\n`);
|
|
222
|
+
res.write(`data: ${JSON.stringify({ type: "permissions", ...getSystemPermissions(), desktopEnabled })}\n\n`);
|
|
126
223
|
sseClients.add(res);
|
|
127
224
|
|
|
128
225
|
req.on("close", () => sseClients.delete(res));
|
|
@@ -134,6 +231,7 @@ function handleUiState(body) {
|
|
|
134
231
|
const data = JSON.parse(body || "{}");
|
|
135
232
|
uiState = { ...uiState, ...data };
|
|
136
233
|
pushUiEvent("state", uiState);
|
|
234
|
+
saveUiState();
|
|
137
235
|
} catch { /* ignore malformed */ }
|
|
138
236
|
}
|
|
139
237
|
|
|
@@ -290,7 +388,38 @@ export async function startServer() {
|
|
|
290
388
|
if (pathname === "/api/ui/state" && req.method === "GET") {
|
|
291
389
|
res.setHeader("Content-Type", "application/json");
|
|
292
390
|
res.writeHead(200);
|
|
293
|
-
|
|
391
|
+
// Include permissions + desktopEnabled so UI only needs 1 fetch
|
|
392
|
+
res.end(JSON.stringify({
|
|
393
|
+
...uiState,
|
|
394
|
+
...getSystemPermissions(),
|
|
395
|
+
desktopEnabled,
|
|
396
|
+
}));
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Stop tunnel (disconnect), keep server alive
|
|
401
|
+
if (pathname === "/api/ui/stop" && req.method === "POST") {
|
|
402
|
+
res.setHeader("Content-Type", "application/json");
|
|
403
|
+
res.writeHead(200);
|
|
404
|
+
res.end(JSON.stringify({ ok: true }));
|
|
405
|
+
// Immediately reset state so UI transitions to welcome screen
|
|
406
|
+
uiState = { ...uiState, step: 0, tunnelUrl: "", oneTimeKey: "", oneTimeKeyExpiresAt: null };
|
|
407
|
+
pushUiEvent("state", uiState);
|
|
408
|
+
saveUiState();
|
|
409
|
+
writeCmd("stop-tunnel");
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// Start tunnel (reconnect)
|
|
414
|
+
if (pathname === "/api/ui/start" && req.method === "POST") {
|
|
415
|
+
res.setHeader("Content-Type", "application/json");
|
|
416
|
+
res.writeHead(200);
|
|
417
|
+
res.end(JSON.stringify({ ok: true }));
|
|
418
|
+
// Immediately push step:1 so UI transitions to progress screen
|
|
419
|
+
uiState = { ...uiState, step: 1 };
|
|
420
|
+
pushUiEvent("state", uiState);
|
|
421
|
+
saveUiState();
|
|
422
|
+
writeCmd("start-tunnel");
|
|
294
423
|
return;
|
|
295
424
|
}
|
|
296
425
|
|
|
@@ -323,13 +452,71 @@ export async function startServer() {
|
|
|
323
452
|
return;
|
|
324
453
|
}
|
|
325
454
|
|
|
326
|
-
// Regenerate permanent key
|
|
455
|
+
// Regenerate permanent key
|
|
327
456
|
if (pathname === "/api/key/regenerate" && req.method === "POST") {
|
|
328
457
|
res.setHeader("Content-Type", "application/json");
|
|
329
|
-
|
|
330
|
-
|
|
458
|
+
try {
|
|
459
|
+
const machineId = await getConsistentMachineId();
|
|
460
|
+
const { key } = generateApiKeyWithMachine(machineId);
|
|
461
|
+
const existing = loadKey();
|
|
462
|
+
saveKey(machineId, key, existing?.name || "Default");
|
|
463
|
+
pushUiEvent("state", { ...uiState, permanentKey: key });
|
|
464
|
+
uiState = { ...uiState, permanentKey: key };
|
|
465
|
+
res.writeHead(200);
|
|
466
|
+
res.end(JSON.stringify({ ok: true, permanentKey: key }));
|
|
467
|
+
} catch (err) {
|
|
468
|
+
res.writeHead(500);
|
|
469
|
+
res.end(JSON.stringify({ error: err.message }));
|
|
470
|
+
}
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// Get system permissions status
|
|
475
|
+
if (pathname === "/api/permissions" && req.method === "GET") {
|
|
476
|
+
res.setHeader("Content-Type", "application/json");
|
|
331
477
|
res.writeHead(200);
|
|
332
|
-
res.end(JSON.stringify(
|
|
478
|
+
res.end(JSON.stringify(getSystemPermissions()));
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// Request a system permission
|
|
483
|
+
if (pathname === "/api/permissions/request" && req.method === "POST") {
|
|
484
|
+
let body = "";
|
|
485
|
+
req.on("data", (chunk) => body += chunk);
|
|
486
|
+
req.on("end", async () => {
|
|
487
|
+
try {
|
|
488
|
+
const { type } = JSON.parse(body || "{}");
|
|
489
|
+
await requestSystemPermission(type);
|
|
490
|
+
res.setHeader("Content-Type", "application/json");
|
|
491
|
+
res.writeHead(200);
|
|
492
|
+
res.end(JSON.stringify({ ok: true }));
|
|
493
|
+
} catch (err) {
|
|
494
|
+
res.writeHead(500);
|
|
495
|
+
res.end(JSON.stringify({ error: err.message }));
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// Toggle remote desktop
|
|
502
|
+
if (pathname === "/api/desktop/toggle" && req.method === "POST") {
|
|
503
|
+
let body = "";
|
|
504
|
+
req.on("data", (chunk) => body += chunk);
|
|
505
|
+
req.on("end", () => {
|
|
506
|
+
try {
|
|
507
|
+
const { enabled } = JSON.parse(body || "{}");
|
|
508
|
+
desktopEnabled = !!enabled;
|
|
509
|
+
saveDesktopState();
|
|
510
|
+
// Push updated state including desktopEnabled + fresh permissions
|
|
511
|
+
pushUiEvent("permissions", { ...getSystemPermissions(), desktopEnabled });
|
|
512
|
+
res.setHeader("Content-Type", "application/json");
|
|
513
|
+
res.writeHead(200);
|
|
514
|
+
res.end(JSON.stringify({ ok: true, enabled: desktopEnabled }));
|
|
515
|
+
} catch (err) {
|
|
516
|
+
res.writeHead(500);
|
|
517
|
+
res.end(JSON.stringify({ error: err.message }));
|
|
518
|
+
}
|
|
519
|
+
});
|
|
333
520
|
return;
|
|
334
521
|
}
|
|
335
522
|
|
|
@@ -455,6 +642,11 @@ export async function startServer() {
|
|
|
455
642
|
}
|
|
456
643
|
});
|
|
457
644
|
|
|
645
|
+
// Load persisted states + warm up permission cache
|
|
646
|
+
loadUiState();
|
|
647
|
+
loadDesktopState();
|
|
648
|
+
refreshPermissionsAsync();
|
|
649
|
+
|
|
458
650
|
await setupSocketIO(server);
|
|
459
651
|
|
|
460
652
|
server.listen(port, (err) => {
|