"use strict";(self.webpackChunk_groundsada_jupyterhub_vscode=self.webpackChunk_groundsada_jupyterhub_vscode||[]).push([[509],{509(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});const o=n(41),r=n(498),i=n(247);class s extends i.Widget{constructor(e){super(),this._username=e,this.addClass("jp-VSCodeButton");const t=document.createElement("button");t.title="Open in VS Code",t.style.cssText="\n      display: flex; align-items: center; gap: 6px;\n      padding: 4px 10px; cursor: pointer; border-radius: 4px;\n      background: transparent; border: 1px solid var(--jp-border-color1);\n      color: var(--jp-ui-font-color1); font-size: 13px;\n      font-family: var(--jp-ui-font-family);\n    ",t.innerHTML='\n      <svg width="16" height="16" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" fill="currentColor">\n        <path d="M74.8 4.9L40.6 34.7 17.3 18.5 5 25.3v49.4l12.3 6.8 23.3-16.2 34.2 29.8 18.2-8.7V13.6L74.8 4.9zM17.3 62.6V37.4l16.4 12.6-16.4 12.6zm39.4-.5L38.2 50l18.5-12.1V62.1z"/>\n      </svg>\n      Open in VS Code\n    ',t.addEventListener("click",()=>{this._onClick()}),this.node.appendChild(t)}async _onClick(){const e=this.node.querySelector("button");e.textContent="Connecting…",e.setAttribute("disabled","true");try{const e=await async function(e){const t=r.ServerConnection.makeSettings(),n=`${o.PageConfig.getOption("hubPrefix")||"/hub"}/api/users/${encodeURIComponent(e)}/vscode-connect`,i=await r.ServerConnection.makeRequest(n,{method:"GET"},t);if(!i.ok){const e=await i.text();throw new Error(`Hub API ${i.status}: ${e}`)}return i.json()}(this._username);window.location.href=e.vscode_uri}catch(t){const n=t instanceof Error?t.message:String(t);console.error("[jhub-vscode]",n),e.textContent="⚠ Failed",e.title=n,setTimeout(()=>{e.innerHTML='\n          <svg width="16" height="16" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" fill="currentColor">\n            <path d="M74.8 4.9L40.6 34.7 17.3 18.5 5 25.3v49.4l12.3 6.8 23.3-16.2 34.2 29.8 18.2-8.7V13.6L74.8 4.9zM17.3 62.6V37.4l16.4 12.6-16.4 12.6zm39.4-.5L38.2 50l18.5-12.1V62.1z"/>\n          </svg>\n          Open in VS Code\n        ',e.removeAttribute("disabled"),e.title="Open in VS Code"},3e3)}finally{e.removeAttribute("disabled")}}}const a={id:"@groundsada/jupyterhub-vscode:plugin",description:'One-click "Open in VS Code" button for JupyterHub',autoStart:!0,activate:e=>{const t=o.PageConfig.getOption("hubUser");if(!t)return void console.log("[jhub-vscode] Not running under JupyterHub — skipping");const n=new s(t);e.shell.add(n,"top",{rank:1e3})}};t.default=a}}]);