| 1 | /* Generated by tools/gen_ui.py from src/ui.html. Do not edit by hand. */ |
| 2 | #ifndef SX_AGYLOGIN_UI_HTML_H |
| 3 | #define SX_AGYLOGIN_UI_HTML_H |
| 4 | |
| 5 | static const char *UI_HTML = |
| 6 | "<!DOCTYPE html>\n" |
| 7 | "<html lang=\"en\"><head><meta charset=\"utf-8\">\n" |
| 8 | "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n" |
| 9 | "<title>google</title>\n" |
| 10 | "\001\n" |
| 11 | "<style>\n" |
| 12 | "*{box-sizing:border-box}\n" |
| 13 | "html,body{margin:0;min-height:100%}\n" |
| 14 | "body{background:var(--bg);color:var(--text);font-family:var(--font);font-size:14px;\n" |
| 15 | " line-height:1.5;-webkit-font-smoothing:antialiased}\n" |
| 16 | "#app{max-width:840px;margin:0 auto;padding:16px 16px 40px}\n" |
| 17 | ".hd{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:14px}\n" |
| 18 | ".hd .grow{flex:1 1 auto;min-width:0}\n" |
| 19 | ".hd h1{margin:0;font-size:18px;font-weight:650;letter-spacing:-.01em}\n" |
| 20 | ".hd .sub{font-size:11.5px;color:var(--text-2);margin-top:2px;white-space:nowrap;\n" |
| 21 | " overflow:hidden;text-overflow:ellipsis}\n" |
| 22 | ".pill{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;font-weight:650;\n" |
| 23 | " padding:4px 10px;border-radius:999px;background:var(--surface-2);color:var(--text-2);\n" |
| 24 | " border:1px solid var(--line);white-space:nowrap}\n" |
| 25 | ".pill .dot{width:7px;height:7px;border-radius:50%;background:var(--gray);flex:0 0 auto}\n" |
| 26 | ".pill.ok{color:var(--green);border-color:rgba(48,209,88,.35)}\n" |
| 27 | ".pill.ok .dot{background:var(--green);box-shadow:0 0 0 3px rgba(48,209,88,.15)}\n" |
| 28 | ".pill.warn{color:var(--orange);border-color:rgba(255,159,10,.35)}\n" |
| 29 | ".pill.warn .dot{background:var(--orange)}\n" |
| 30 | ".pill.off .dot{background:var(--gray)}\n" |
| 31 | ".card{background:var(--bg-card);border:1px solid var(--line);border-radius:14px;\n" |
| 32 | " padding:16px;margin-bottom:12px}\n" |
| 33 | ".card h2{margin:0 0 4px;font-size:13px;font-weight:700;letter-spacing:.08em;\n" |
| 34 | " text-transform:uppercase;color:var(--text-2)}\n" |
| 35 | ".card .lead{margin:0 0 12px;font-size:12.5px;color:var(--text-2)}\n" |
| 36 | ".row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}\n" |
| 37 | ".btn{background:var(--blue);color:#fff;border:0;border-radius:980px;padding:7px 16px;\n" |
| 38 | " font-weight:600;font-size:13px;cursor:pointer;font-family:inherit;\n" |
| 39 | " transition:transform .12s var(--ease),opacity .12s}\n" |
| 40 | ".btn:active{transform:scale(.98)}\n" |
| 41 | ".btn:disabled{opacity:.5;cursor:default}\n" |
| 42 | ".btn.ghost{background:var(--surface-2);color:var(--text);border:1px solid var(--line)}\n" |
| 43 | ".btn.ghost:hover{background:var(--surface-hover);border-color:var(--line-2)}\n" |
| 44 | ".btn.danger{background:transparent;color:var(--red);border:1px solid rgba(255,69,58,.35)}\n" |
| 45 | "a.btn{display:inline-flex;align-items:center;gap:6px;text-decoration:none}\n" |
| 46 | ".kv{display:grid;grid-template-columns:132px minmax(0,1fr);gap:6px 12px;font-size:13px}\n" |
| 47 | ".kv .k{color:var(--text-2);font-size:12px}\n" |
| 48 | ".kv .v{font-family:var(--mono);font-size:12px;word-break:break-all}\n" |
| 49 | ".kv .v.plain{font-family:var(--font);font-size:13px}\n" |
| 50 | ".hint{font-size:12px;color:var(--text-2);margin:10px 0 0}\n" |
| 51 | ".step{display:none}\n" |
| 52 | ".step.on{display:block}\n" |
| 53 | ".authurl{margin:10px 0;padding:10px 11px;border-radius:10px;background:var(--code-bg);\n" |
| 54 | " border:1px solid var(--line);font-family:var(--mono);font-size:11.5px;\n" |
| 55 | " word-break:break-all;max-height:120px;overflow:auto;color:var(--text)}\n" |
| 56 | "textarea{width:100%;min-height:82px;resize:vertical;border-radius:10px;padding:10px 11px;\n" |
| 57 | " border:1px solid var(--line);background:var(--input-bg);color:var(--text);\n" |
| 58 | " font-family:var(--mono);font-size:12px;line-height:1.45}\n" |
| 59 | "textarea:focus{outline:2px solid var(--blue);outline-offset:-1px}\n" |
| 60 | ".note{display:none;margin-top:10px;padding:9px 11px;border-radius:10px;font-size:12.5px;\n" |
| 61 | " border:1px solid var(--line);background:var(--surface-2)}\n" |
| 62 | ".note.show{display:block}\n" |
| 63 | ".note.err{color:var(--red);border-color:rgba(255,69,58,.35)}\n" |
| 64 | ".note.ok{color:var(--green);border-color:rgba(48,209,88,.35)}\n" |
| 65 | ".empty{padding:10px 0;color:var(--text-2);font-size:12.5px}\n" |
| 66 | ".toast{position:fixed;left:50%;bottom:18px;transform:translate(-50%,14px);opacity:0;\n" |
| 67 | " pointer-events:none;background:var(--modal-bg);border:1px solid var(--line-2);\n" |
| 68 | " color:var(--text);border-radius:999px;padding:8px 16px;font-size:12.5px;\n" |
| 69 | " box-shadow:var(--shadow-lg);transition:opacity .18s var(--ease),transform .18s var(--ease);\n" |
| 70 | " z-index:9;max-width:calc(100vw - 32px)}\n" |
| 71 | ".toast.show{opacity:1;transform:translate(-50%,0)}\n" |
| 72 | "#themeToggle{background:var(--surface-2);border:1px solid var(--line);color:var(--text);\n" |
| 73 | " border-radius:980px;padding:5px 12px;font-size:12px;font-weight:600;cursor:pointer;\n" |
| 74 | " font-family:inherit}\n" |
| 75 | "@media (max-width:520px){\n" |
| 76 | " #app{padding:12px 12px 32px}\n" |
| 77 | " .kv{grid-template-columns:1fr;gap:2px 0}\n" |
| 78 | " .kv .k{margin-top:8px}\n" |
| 79 | " .card{padding:13px;border-radius:12px}\n" |
| 80 | "}\n" |
| 81 | "</style>\n" |
| 82 | "</head>\n" |
| 83 | "<body>\n" |
| 84 | "<div id=\"app\">\n" |
| 85 | " <div class=\"hd\">\n" |
| 86 | " <div class=\"grow\">\n" |
| 87 | " <h1>Google Antigravity</h1>\n" |
| 88 | " <div class=\"sub\" id=\"sub\">OAuth 2.0 PKCE login on this node</div>\n" |
| 89 | " </div>\n" |
| 90 | " <span class=\"pill off\" id=\"pill\"><span class=\"dot\"></span><span id=\"pillText\">Checking</span></span>\n" |
| 91 | " <button id=\"themeToggle\" class=\"embed-hide\" type=\"button\">Theme</button>\n" |
| 92 | " </div>\n" |
| 93 | "\n" |
| 94 | " <div class=\"card\">\n" |
| 95 | " <h2>Session</h2>\n" |
| 96 | " <p class=\"lead\" id=\"sessionLead\">Reading the local Antigravity credentials.</p>\n" |
| 97 | " <div class=\"kv\" id=\"session\"></div>\n" |
| 98 | " <div class=\"row\" style=\"margin-top:14px\">\n" |
| 99 | " <button class=\"btn ghost\" id=\"btnRefresh\" type=\"button\">Refresh Token Now</button>\n" |
| 100 | " <button class=\"btn ghost\" id=\"btnReload\" type=\"button\">Reload</button>\n" |
| 101 | " </div>\n" |
| 102 | " <div class=\"note\" id=\"refreshNote\"></div>\n" |
| 103 | " </div>\n" |
| 104 | "\n" |
| 105 | " <div class=\"card\">\n" |
| 106 | " <h2>OAuth login</h2>\n" |
| 107 | " <p class=\"lead\">Sign in with Google. Nothing leaves this node: the login CLI performs the\n" |
| 108 | " exchange and writes the credential file here.</p>\n" |
| 109 | "\n" |
| 110 | " <div class=\"step on\" id=\"step1\">\n" |
| 111 | " <button class=\"btn\" id=\"btnStart\" type=\"button\">Start Google Login</button>\n" |
| 112 | " <p class=\"hint\">This generates a PKCE challenge and an authorization link. No token is\n" |
| 113 | " created until you paste the code back.</p>\n" |
| 114 | " </div>\n" |
| 115 | "\n" |
| 116 | " <div class=\"step\" id=\"step2\">\n" |
| 117 | " <div class=\"row\">\n" |
| 118 | " <a class=\"btn\" id=\"linkOpen\" href=\"#\" target=\"_blank\" rel=\"noopener noreferrer\">Open Google Sign-in</a>\n" |
| 119 | " <button class=\"btn ghost\" id=\"btnCopy\" type=\"button\">Copy link</button>\n" |
| 120 | " <button class=\"btn ghost\" id=\"btnCancel\" type=\"button\">Cancel</button>\n" |
| 121 | " </div>\n" |
| 122 | " <div class=\"authurl\" id=\"authUrl\"></div>\n" |
| 123 | " <p class=\"hint\" id=\"flowHint\">After approving, the browser lands on antigravity.google. Copy the\n" |
| 124 | " whole address (or just the <span style=\"font-family:var(--mono)\">code=</span> value) and paste it below.</p>\n" |
| 125 | " <textarea id=\"codeInput\" spellcheck=\"false\" autocomplete=\"off\"\n" |
| 126 | " placeholder=\"Paste the authorization code or the full redirect URL\"></textarea>\n" |
| 127 | " <div class=\"row\" style=\"margin-top:10px\">\n" |
| 128 | " <button class=\"btn\" id=\"btnFinish\" type=\"button\">Authorize & Discover Project</button>\n" |
| 129 | " </div>\n" |
| 130 | " <div class=\"note\" id=\"loginNote\"></div>\n" |
| 131 | " </div>\n" |
| 132 | " </div>\n" |
| 133 | "\n" |
| 134 | " <div class=\"card\">\n" |
| 135 | " <h2>Companion project</h2>\n" |
| 136 | " <p class=\"lead\">The Google Cloud project the Antigravity session bills against.</p>\n" |
| 137 | " <div class=\"kv\" id=\"project\"></div>\n" |
| 138 | " </div>\n" |
| 139 | "</div>\n" |
| 140 | "\n" |
| 141 | "<div class=\"toast\" id=\"toast\"></div>\n" |
| 142 | "\n" |
| 143 | "<script>\n" |
| 144 | "var q=new URLSearchParams(location.search);\n" |
| 145 | "var node=q.get('node')||'';\n" |
| 146 | "var sid=q.get('id')||'';\n" |
| 147 | "var pwd=q.get('pwd')||(node&&localStorage.getItem('bot_pwd_'+node))||\n" |
| 148 | " localStorage.getItem('bot_active_pwd')||'';\n" |
| 149 | "\n" |
| 150 | "/* Two call routes. Getting this wrong is the most common plugin bug:\n" |
| 151 | " * page served through the hub (bot.scorpiox.net/plugins?plugin=...&node=..)\n" |
| 152 | " * -> call the hub proxy back: /plugins?plugin=plugin_antigravity_login&action=..\n" |
| 153 | " * opened directly on the node\n" |
| 154 | " * -> the plugin itself is the route: /plugin_antigravity_login?action=..\n" |
| 155 | " * Calling /plugins?plugin= on the node returns the discovery list, not us. */\n" |
| 156 | "var HUB=q.get('plugin')||'';\n" |
| 157 | "function url(action,extra){\n" |
| 158 | " return (HUB?'/plugins?plugin='+encodeURIComponent(HUB):'/plugin_antigravity_login')+\n" |
| 159 | " '?action='+encodeURIComponent(action)+\n" |
| 160 | " (extra?('&'+extra):'')+\n" |
| 161 | " (node?'&node='+encodeURIComponent(node):'')+\n" |
| 162 | " (sid?'&id='+encodeURIComponent(sid):'')+\n" |
| 163 | " (pwd?'&pwd='+encodeURIComponent(pwd):'');\n" |
| 164 | "}\n" |
| 165 | "function hdr(){\n" |
| 166 | " var h={};\n" |
| 167 | " if(pwd)h['X-Bot-Password']=pwd;\n" |
| 168 | " return h;\n" |
| 169 | "}\n" |
| 170 | "function api(action,extra){\n" |
| 171 | " return fetch(url(action,extra),{headers:hdr()}).then(function(r){\n" |
| 172 | " return r.json().catch(function(){return {ok:false,error:'bad response'};});\n" |
| 173 | " });\n" |
| 174 | "}\n" |
| 175 | "\n" |
| 176 | "var $=function(id){return document.getElementById(id);};\n" |
| 177 | "function toast(msg){\n" |
| 178 | " var t=$('toast');t.textContent=msg;t.classList.add('show');\n" |
| 179 | " clearTimeout(t._t);t._t=setTimeout(function(){t.classList.remove('show');},2200);\n" |
| 180 | "}\n" |
| 181 | "function note(el,msg,kind){\n" |
| 182 | " el.textContent=msg||'';\n" |
| 183 | " el.className='note'+(msg?' show '+(kind||''):'');\n" |
| 184 | "}\n" |
| 185 | "function kv(el,rows){\n" |
| 186 | " el.innerHTML='';\n" |
| 187 | " rows.forEach(function(r){\n" |
| 188 | " var a=document.createElement('div');a.className='k';a.textContent=r[0];\n" |
| 189 | " var b=document.createElement('div');b.className='v'+(r[2]?' plain':'');\n" |
| 190 | " b.textContent=r[1];el.appendChild(a);el.appendChild(b);\n" |
| 191 | " });\n" |
| 192 | "}\n" |
| 193 | "function fmtExpiry(sec){\n" |
| 194 | " if(typeof sec!=='number')return '-';\n" |
| 195 | " if(sec<=0)return 'expired';\n" |
| 196 | " if(sec<90)return sec+'s';\n" |
| 197 | " if(sec<5400)return Math.round(sec/60)+' min';\n" |
| 198 | " if(sec<172800)return Math.round(sec/3600)+' h';\n" |
| 199 | " if(sec<63072000)return Math.round(sec/86400)+' d';\n" |
| 200 | " return Math.round(sec/31536000)+' yr';\n" |
| 201 | "}\n" |
| 202 | "function setPill(st){\n" |
| 203 | " var p=$('pill'),t=$('pillText');\n" |
| 204 | " if(st.logged_in&&st.expired){p.className='pill warn';t.textContent='Expired';}\n" |
| 205 | " else if(st.logged_in){p.className='pill ok';t.textContent='Connected';}\n" |
| 206 | " else if(st.pending){p.className='pill warn';t.textContent='Signing in';}\n" |
| 207 | " else {p.className='pill off';t.textContent='Not Connected';}\n" |
| 208 | "}\n" |
| 209 | "function render(st){\n" |
| 210 | " setPill(st);\n" |
| 211 | " $('sub').textContent=st.email?st.email:'OAuth 2.0 PKCE login on this node';\n" |
| 212 | "\n" |
| 213 | " if(st.logged_in){\n" |
| 214 | " $('sessionLead').textContent=st.expired\n" |
| 215 | " ? 'The session is present but its access token has expired. Use Refresh Token Now.'\n" |
| 216 | " : 'This node holds a Google Antigravity session.';\n" |
| 217 | " }else{\n" |
| 218 | " $('sessionLead').textContent='No Google session on this node yet. Start a login below.';\n" |
| 219 | " }\n" |
| 220 | " kv($('session'),[\n" |
| 221 | " ['Account', st.email||'-', true],\n" |
| 222 | " ['Logged in', st.logged_in?'yes':'no', true],\n" |
| 223 | " ['Refresh token', st.has_refresh?'stored':'none', true],\n" |
| 224 | " ['Token expires', st.logged_in?fmtExpiry(st.expires_in_sec):'-', true],\n" |
| 225 | " ['Login pending', st.pending?'yes':'no', true],\n" |
| 226 | " ['Login CLI', st.cli_present?'found':'not found', true],\n" |
| 227 | " ['Credentials', st.credentials_path||'-']\n" |
| 228 | " ]);\n" |
| 229 | " kv($('project'),[\n" |
| 230 | " ['Project ID', st.project_id||'(consumer shared project)', !st.project_id],\n" |
| 231 | " ['Profile', st.profile||'-', true],\n" |
| 232 | " ['Provider', 'google (Antigravity)', true]\n" |
| 233 | " ]);\n" |
| 234 | "\n" |
| 235 | " if(st.pending){$('step1').classList.remove('on');$('step2').classList.add('on');}\n" |
| 236 | "}\n" |
| 237 | "function load(){\n" |
| 238 | " return api('status').then(function(d){\n" |
| 239 | " if(d&&d.ok)render(d);\n" |
| 240 | " else toast((d&&d.error)||'status failed');\n" |
| 241 | " }).catch(function(e){toast('Status failed: '+e.message);});\n" |
| 242 | "}\n" |
| 243 | "\n" |
| 244 | "var authUrl='';\n" |
| 245 | "function start(){\n" |
| 246 | " var b=$('btnStart');\n" |
| 247 | " b.disabled=true;b.textContent='Starting...';\n" |
| 248 | " api('start').then(function(d){\n" |
| 249 | " b.disabled=false;b.textContent='Start Google Login';\n" |
| 250 | " if(!d||!d.ok){toast((d&&(d.detail||d.error))||'start failed');return;}\n" |
| 251 | " authUrl=d.auth_url||'';\n" |
| 252 | " $('authUrl').textContent=authUrl;\n" |
| 253 | " $('linkOpen').setAttribute('href',authUrl);\n" |
| 254 | " if(d.hint)$('flowHint').textContent=d.hint;\n" |
| 255 | " $('step1').classList.remove('on');\n" |
| 256 | " $('step2').classList.add('on');\n" |
| 257 | " $('codeInput').focus();\n" |
| 258 | " }).catch(function(e){\n" |
| 259 | " b.disabled=false;b.textContent='Start Google Login';\n" |
| 260 | " toast('Start failed: '+e.message);\n" |
| 261 | " });\n" |
| 262 | "}\n" |
| 263 | "\n" |
| 264 | "function finish(){\n" |
| 265 | " var raw=$('codeInput').value.trim();\n" |
| 266 | " if(!raw){note($('loginNote'),'Paste the code or the redirect address first.','err');return;}\n" |
| 267 | " var b=$('btnFinish');\n" |
| 268 | " b.disabled=true;b.textContent='Authorizing...';\n" |
| 269 | " note($('loginNote'),'Exchange in progress. The Google project discovery can take a few seconds.');\n" |
| 270 | " api('finish','code='+encodeURIComponent(raw)).then(function(d){\n" |
| 271 | " b.disabled=false;b.textContent='Authorize & Discover Project';\n" |
| 272 | " if(!d||!d.ok){\n" |
| 273 | " note($('loginNote'),(d&&(d.detail||d.error))||'exchange failed','err');\n" |
| 274 | " return;\n" |
| 275 | " }\n" |
| 276 | " note($('loginNote'),'');\n" |
| 277 | " $('step2').classList.remove('on');\n" |
| 278 | " $('step1').classList.add('on');\n" |
| 279 | " $('codeInput').value='';\n" |
| 280 | " render(d);\n" |
| 281 | " toast('Signed in as '+(d.email||'Google account'));\n" |
| 282 | " }).catch(function(e){\n" |
| 283 | " b.disabled=false;b.textContent='Authorize & Discover Project';\n" |
| 284 | " note($('loginNote'),'Exchange failed: '+e.message,'err');\n" |
| 285 | " });\n" |
| 286 | "}\n" |
| 287 | "\n" |
| 288 | "function cancel(){\n" |
| 289 | " api('cancel').then(function(){\n" |
| 290 | " $('step2').classList.remove('on');\n" |
| 291 | " $('step1').classList.add('on');\n" |
| 292 | " $('codeInput').value='';\n" |
| 293 | " note($('loginNote'),'');\n" |
| 294 | " toast('Pending login cancelled');\n" |
| 295 | " load();\n" |
| 296 | " }).catch(function(e){toast('Cancel failed: '+e.message);});\n" |
| 297 | "}\n" |
| 298 | "\n" |
| 299 | "function refreshToken(){\n" |
| 300 | " var b=$('btnRefresh');\n" |
| 301 | " b.disabled=true;b.textContent='Refreshing...';\n" |
| 302 | " note($('refreshNote'),'Asking Google for a new access token...');\n" |
| 303 | " api('refresh').then(function(d){\n" |
| 304 | " b.disabled=false;b.textContent='Refresh Token Now';\n" |
| 305 | " if(!d||!d.ok){\n" |
| 306 | " note($('refreshNote'),(d&&(d.detail||d.error))||'refresh failed','err');\n" |
| 307 | " return;\n" |
| 308 | " }\n" |
| 309 | " note($('refreshNote'),'Token refreshed. Expires in '+fmtExpiry(d.expires_in_sec)+'.','ok');\n" |
| 310 | " render(d);\n" |
| 311 | " }).catch(function(e){\n" |
| 312 | " b.disabled=false;b.textContent='Refresh Token Now';\n" |
| 313 | " note($('refreshNote'),'Refresh failed: '+e.message,'err');\n" |
| 314 | " });\n" |
| 315 | "}\n" |
| 316 | "\n" |
| 317 | "function copyLink(){\n" |
| 318 | " if(!authUrl)return;\n" |
| 319 | " var done=function(){toast('Link copied');};\n" |
| 320 | " if(navigator.clipboard&&navigator.clipboard.writeText){\n" |
| 321 | " navigator.clipboard.writeText(authUrl).then(done).catch(function(){toast('Copy failed');});\n" |
| 322 | " }else{toast('Copy not available');}\n" |
| 323 | "}\n" |
| 324 | "\n" |
| 325 | "$('btnStart').onclick=start;\n" |
| 326 | "$('btnFinish').onclick=finish;\n" |
| 327 | "$('btnCancel').onclick=cancel;\n" |
| 328 | "$('btnRefresh').onclick=refreshToken;\n" |
| 329 | "$('btnReload').onclick=load;\n" |
| 330 | "$('btnCopy').onclick=copyLink;\n" |
| 331 | "$('codeInput').addEventListener('keydown',function(e){\n" |
| 332 | " if(e.key==='Enter'&&(e.metaKey||e.ctrlKey)){e.preventDefault();finish();}\n" |
| 333 | "});\n" |
| 334 | "load();\n" |
| 335 | "</script>\n" |
| 336 | "\002</body></html>\n" |
| 337 | ; |
| 338 | |
| 339 | #endif /* SX_AGYLOGIN_UI_HTML_H */ |