"use strict";(self.webpackChunknb_venv_kernels=self.webpackChunknb_venv_kernels||[]).push([[509],{509:(n,e,t)=>{t.r(e),t.d(e,{default:()=>d});var o=t(891),a=t(324),s=t(603),r=t(596),i=t(247);const l="nb_venv_kernels:scan";async function c(){const n=function(){const n=document.createElement("div");n.style.display="flex",n.style.alignItems="center",n.style.gap="12px",n.style.padding="8px 0",n.innerHTML='\n    <div style="\n      width: 24px;\n      height: 24px;\n      border: 3px solid var(--jp-border-color2);\n      border-top-color: var(--jp-brand-color1);\n      border-radius: 50%;\n      animation: nb-venv-spin 1s linear infinite;\n    "></div>\n    <span>Scanning for Python environments...</span>\n    <style>\n      @keyframes nb-venv-spin {\n        to { transform: rotate(360deg); }\n      }\n    </style>\n  ';const e=new i.Widget({node:n}),t=new a.Dialog({title:"Scanning",body:e,buttons:[]});return t.launch(),t}();try{const e=await async function(){const n=r.ServerConnection.makeSettings(),e=s.URLExt.join(n.baseUrl,"nb-venv-kernels","scan"),t=await r.ServerConnection.makeRequest(e,{method:"POST",body:JSON.stringify({})},n);if(!t.ok)throw new Error(`Scan failed: ${t.status}`);return t.json()}();n.dispose(),await async function(n){const e=document.createElement("div");e.style.minWidth="500px",e.style.maxHeight="400px",e.style.overflow="auto",e.innerHTML=function(n){const e=n.environments.length,t=n.summary.add,o=n.summary.keep,a=n.summary.remove;let s;if(0===e)s="<p>No environments found.</p>";else{const n=[];t>0&&n.push(`${t} new`),o>0&&n.push(`${o} kept`),a>0&&n.push(`${a} missing`),s=`<p>Found ${e} environment${1!==e?"s":""}: ${n.join(", ")}.</p>`}if(0===n.environments.length)return s;const r=function(n){const e={add:0,keep:1,remove:2},t={conda:0,uv:1,venv:2};return[...n].sort((n,o)=>{var a,s,r,i;const l=(null!==(a=e[n.action])&&void 0!==a?a:3)-(null!==(s=e[o.action])&&void 0!==s?s:3);if(0!==l)return l;const c=(null!==(r=t[n.type])&&void 0!==r?r:3)-(null!==(i=t[o.type])&&void 0!==i?i:3);return 0!==c?c:n.name.toLowerCase().localeCompare(o.name.toLowerCase())})}(n.environments).map(n=>{const e=n.exists?"yes":'<span class="nb-venv-no">no</span>',t=n.has_kernel?"yes":'<span class="nb-venv-no">no</span>';return`<tr>\n      <td class="nb-venv-action-${n.action}">${n.action}</td>\n      <td>${n.name}</td>\n      <td>${n.type}</td>\n      <td>${e}</td>\n      <td>${t}</td>\n      <td class="path-col">${n.path}</td>\n    </tr>`}).join(""),i=[];n.summary.add>0&&i.push(`${n.summary.add} added`),n.summary.keep>0&&i.push(`${n.summary.keep} kept`),n.summary.remove>0&&i.push(`${n.summary.remove} removed`);const l=n.environments.some(n=>n.exists&&!n.has_kernel)?'<p style="margin-top: 8px; font-size: 0.9em; color: var(--jp-ui-font-color2);"><em>Install ipykernel in environments without kernel to use them in JupyterLab.</em></p>':"";return`\n    <style>\n      .nb-venv-table { border-collapse: collapse; width: 100%; margin-top: 8px; font-size: var(--jp-ui-font-size1); }\n      .nb-venv-table th, .nb-venv-table td { text-align: left; padding: 1px 6px; white-space: nowrap; vertical-align: baseline; }\n      .nb-venv-table thead tr { border-bottom: 1px solid var(--jp-border-color1); }\n      .nb-venv-table tbody tr { line-height: 1.2; }\n      .nb-venv-table .path-col { font-family: var(--jp-code-font-family); font-size: var(--jp-code-font-size); white-space: normal; }\n      .nb-venv-action-add { color: #22c55e; font-weight: 500; }\n      .nb-venv-action-keep { color: #3b82f6; }\n      .nb-venv-action-remove { color: #f97316; }\n      .nb-venv-no { color: #ef4444; }\n    </style>\n    ${s}\n    <table class="nb-venv-table">\n      <thead>\n        <tr>\n          <th>action</th>\n          <th>name</th>\n          <th>type</th>\n          <th>exists</th>\n          <th>kernel</th>\n          <th>path (relative to workspace)</th>\n        </tr>\n      </thead>\n      <tbody>\n        ${r}\n      </tbody>\n    </table>\n    <p style="margin-top: 8px; color: var(--jp-ui-font-color2);"><strong>Summary:</strong> ${i.join(", ")}</p>\n    ${l}\n  `}(n);const t=new i.Widget({node:e});await(0,a.showDialog)({title:"Environment Scan Results",body:t,buttons:[a.Dialog.okButton()]})}(e)}catch(e){n.dispose(),console.error("Scan failed:",e),await(0,a.showDialog)({title:"Scan Failed",body:`Failed to scan environments: ${e}`,buttons:[a.Dialog.okButton()]})}}const d={id:"nb_venv_kernels:plugin",description:"Discovers Jupyter kernels from conda, venv, and uv environments",autoStart:!0,optional:[o.IMainMenu,a.ICommandPalette],activate:(n,e,t)=>{console.log("JupyterLab extension nb_venv_kernels is activated!"),n.commands.addCommand(l,{label:"Scan for Python Environments",caption:"Scan workspace for venv/uv/conda environments",execute:c}),e&&e.kernelMenu.addGroup([{command:l}],100),t&&t.addItem({command:l,category:"Kernel"})}}}}]);