notebook-intelligence 2.2.8__tar.gz → 2.3.1__tar.gz
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.
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/PKG-INFO +3 -3
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/_version.py +1 -1
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/ai_service_manager.py +2 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/api.py +6 -1
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/base_chat_participant.py +0 -6
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/extension.py +15 -1
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/github_copilot.py +8 -4
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/package.json +2 -2
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/schemas/@notebook-intelligence/notebook-intelligence/package.json.orig +1 -1
- notebook_intelligence-2.3.1/notebook_intelligence/labextension/static/144.32670846ec78677e2b97.js +1 -0
- notebook_intelligence-2.2.8/notebook_intelligence/labextension/static/172.5e09e00fc564d61e8782.js → notebook_intelligence-2.3.1/notebook_intelligence/labextension/static/172.f84dcbf94ffcedfac5aa.js +1 -1
- notebook_intelligence-2.2.8/notebook_intelligence/labextension/static/728.2f7d112a9c63a34d9d0f.js → notebook_intelligence-2.3.1/notebook_intelligence/labextension/static/728.8613949c97cd3a351215.js +1 -1
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/editor.worker.js +2 -2
- notebook_intelligence-2.2.8/notebook_intelligence/labextension/static/remoteEntry.b0c8707eb3ddbf54633b.js → notebook_intelligence-2.3.1/notebook_intelligence/labextension/static/remoteEntry.8be96dca5aaf11bd8c0a.js +1 -1
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/llm_providers/github_copilot_llm_provider.py +2 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/mcp_manager.py +32 -57
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/package.json +1 -1
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/pyproject.toml +2 -2
- notebook_intelligence-2.2.8/notebook_intelligence/labextension/static/144.2285a11b0b91abe27c08.js +0 -1
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/.copier-answers.yml +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/.gitignore +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/.prettierignore +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/.yarnrc.yml +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/CHANGELOG.md +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/CONTRIBUTING.md +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/LICENSE +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/README.md +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/RELEASE.md +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/install.json +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/jupyter-config/server-config/notebook_intelligence.json +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/__init__.py +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/built_in_toolsets.py +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/config.py +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/github_copilot_chat_participant.py +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/schemas/@notebook-intelligence/notebook-intelligence/plugin.json +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/196.db3f5562c0372c6e07f6.js +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/1b55f12eca93ba6743e7.ttf +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/326.4de77f44c9c6c2bbad47.js +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/326.4de77f44c9c6c2bbad47.js.LICENSE.txt +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/327.fe6b84491254fcaf64bf.js +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/327.fe6b84491254fcaf64bf.js.LICENSE.txt +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/671.1797d409270b24758991.js +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/694.d0b052d80c0397c7f1ea.js +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/977.7e3d66ffc344a0af7a4e.js +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/be02dcbf2787b0b29ec8.module.wasm +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/e589c9ba04e3e5a90081.module.wasm +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/editor.worker.js.LICENSE.txt +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/style.js +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/labextension/static/third-party-licenses.json +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/llm_providers/litellm_compatible_llm_provider.py +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/llm_providers/ollama_llm_provider.py +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/llm_providers/openai_compatible_llm_provider.py +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/prompts.py +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/util.py +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/schema/plugin.json +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/setup.py +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/tsconfig.json +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/webpack.config.js +0 -0
- {notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/yarn.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: notebook_intelligence
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.1
|
|
4
4
|
Summary: AI coding assistant for JupyterLab
|
|
5
5
|
Project-URL: Homepage, https://github.com/notebook-intelligence/notebook-intelligence
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/notebook-intelligence/notebook-intelligence/issues
|
|
@@ -695,12 +695,12 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
695
695
|
Classifier: Programming Language :: Python :: 3.12
|
|
696
696
|
Requires-Python: >=3.10
|
|
697
697
|
Requires-Dist: cryptography
|
|
698
|
+
Requires-Dist: fastmcp
|
|
698
699
|
Requires-Dist: fuzy-jon==0.1.0
|
|
699
700
|
Requires-Dist: jupyter-server<3,>=2.0.1
|
|
700
701
|
Requires-Dist: litellm>=1.62.1
|
|
701
|
-
Requires-Dist: mcp
|
|
702
702
|
Requires-Dist: ollama
|
|
703
|
-
Requires-Dist: openai
|
|
703
|
+
Requires-Dist: openai<1.100.0
|
|
704
704
|
Requires-Dist: sseclient-py
|
|
705
705
|
Requires-Dist: tiktoken
|
|
706
706
|
Description-Content-Type: text/markdown
|
|
@@ -96,6 +96,8 @@ class AIServiceManager(Host):
|
|
|
96
96
|
|
|
97
97
|
self.chat_participants[DEFAULT_CHAT_PARTICIPANT_ID] = self._default_chat_participant
|
|
98
98
|
|
|
99
|
+
def update_mcp_servers(self):
|
|
100
|
+
self._mcp_manager.update_mcp_servers(self.nbi_config.mcp)
|
|
99
101
|
|
|
100
102
|
def initialize_extensions(self):
|
|
101
103
|
extensions_dir = path.join(sys.prefix, "share", "jupyter", "nbi_extensions")
|
|
@@ -104,6 +104,7 @@ class ResponseStreamData:
|
|
|
104
104
|
@dataclass
|
|
105
105
|
class MarkdownData(ResponseStreamData):
|
|
106
106
|
content: str = ''
|
|
107
|
+
detail: dict = None
|
|
107
108
|
|
|
108
109
|
@property
|
|
109
110
|
def data_type(self) -> ResponseStreamDataType:
|
|
@@ -274,6 +275,7 @@ class ChatResponse:
|
|
|
274
275
|
@dataclass
|
|
275
276
|
class ToolPreInvokeResponse:
|
|
276
277
|
message: str = None
|
|
278
|
+
detail: dict = None
|
|
277
279
|
confirmationTitle: str = None
|
|
278
280
|
confirmationMessage: str = None
|
|
279
281
|
|
|
@@ -379,6 +381,9 @@ class MCPServer:
|
|
|
379
381
|
|
|
380
382
|
async def disconnect(self):
|
|
381
383
|
return NotImplemented
|
|
384
|
+
|
|
385
|
+
async def update_tool_list(self):
|
|
386
|
+
return NotImplemented
|
|
382
387
|
|
|
383
388
|
def get_tools(self) -> list[Tool]:
|
|
384
389
|
return NotImplemented
|
|
@@ -534,7 +539,7 @@ class ChatParticipant:
|
|
|
534
539
|
tool_pre_invoke_response = tool_to_call.pre_invoke(request, args)
|
|
535
540
|
if tool_pre_invoke_response is not None:
|
|
536
541
|
if tool_pre_invoke_response.message is not None:
|
|
537
|
-
response.stream(MarkdownData(f"✓ {tool_pre_invoke_response.message}..."))
|
|
542
|
+
response.stream(MarkdownData(f"✓ {tool_pre_invoke_response.message}...", tool_pre_invoke_response.detail))
|
|
538
543
|
if tool_pre_invoke_response.confirmationMessage is not None:
|
|
539
544
|
response.stream(ConfirmationData(
|
|
540
545
|
title=tool_pre_invoke_response.confirmationTitle,
|
|
@@ -414,14 +414,8 @@ class BaseChatParticipant(ChatParticipant):
|
|
|
414
414
|
if mcp_server not in mcp_servers_used:
|
|
415
415
|
mcp_servers_used.append(mcp_server)
|
|
416
416
|
|
|
417
|
-
for mcp_server in mcp_servers_used:
|
|
418
|
-
await mcp_server.connect()
|
|
419
|
-
|
|
420
417
|
await self.handle_chat_request_with_tools(request, response, options)
|
|
421
418
|
|
|
422
|
-
for mcp_server in mcp_servers_used:
|
|
423
|
-
await mcp_server.disconnect()
|
|
424
|
-
|
|
425
419
|
async def handle_ask_mode_chat_request(self, request: ChatRequest, response: ChatResponse, options: dict = {}) -> None:
|
|
426
420
|
chat_model = request.host.chat_model
|
|
427
421
|
if request.command == 'newNotebook':
|
{notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/extension.py
RENAMED
|
@@ -71,6 +71,8 @@ class GetCapabilitiesHandler(APIHandler):
|
|
|
71
71
|
extensions.sort(key=lambda extension: extension["id"])
|
|
72
72
|
|
|
73
73
|
response = {
|
|
74
|
+
"user_home_dir": os.path.expanduser('~'),
|
|
75
|
+
"config_file_path": nbi_config.user_config_file,
|
|
74
76
|
"using_github_copilot_service": nbi_config.using_github_copilot_service,
|
|
75
77
|
"llm_providers": [{"id": provider.id, "name": provider.name} for provider in llm_providers],
|
|
76
78
|
"chat_models": ai_service_manager.chat_model_ids,
|
|
@@ -123,6 +125,15 @@ class UpdateProviderModelsHandler(APIHandler):
|
|
|
123
125
|
ai_service_manager.ollama_llm_provider.update_chat_model_list()
|
|
124
126
|
self.finish(json.dumps({}))
|
|
125
127
|
|
|
128
|
+
class ReloadMCPServersHandler(APIHandler):
|
|
129
|
+
@tornado.web.authenticated
|
|
130
|
+
def post(self):
|
|
131
|
+
ai_service_manager.nbi_config.load()
|
|
132
|
+
ai_service_manager.update_mcp_servers()
|
|
133
|
+
self.finish(json.dumps({
|
|
134
|
+
"mcpServers": [{"id": server.name} for server in ai_service_manager.get_mcp_servers()]
|
|
135
|
+
}))
|
|
136
|
+
|
|
126
137
|
class EmitTelemetryEventHandler(APIHandler):
|
|
127
138
|
@tornado.web.authenticated
|
|
128
139
|
def post(self):
|
|
@@ -226,7 +237,8 @@ class WebsocketCopilotResponseEmitter(ChatResponse):
|
|
|
226
237
|
"delta": {
|
|
227
238
|
"nbiContent": {
|
|
228
239
|
"type": data_type,
|
|
229
|
-
"content": data.content
|
|
240
|
+
"content": data.content,
|
|
241
|
+
"detail": data.detail
|
|
230
242
|
},
|
|
231
243
|
"content": "",
|
|
232
244
|
"role": "assistant"
|
|
@@ -604,6 +616,7 @@ class NotebookIntelligence(ExtensionApp):
|
|
|
604
616
|
route_pattern_capabilities = url_path_join(base_url, "notebook-intelligence", "capabilities")
|
|
605
617
|
route_pattern_config = url_path_join(base_url, "notebook-intelligence", "config")
|
|
606
618
|
route_pattern_update_provider_models = url_path_join(base_url, "notebook-intelligence", "update-provider-models")
|
|
619
|
+
route_pattern_reload_mcp_servers = url_path_join(base_url, "notebook-intelligence", "reload-mcp-servers")
|
|
607
620
|
route_pattern_emit_telemetry_event = url_path_join(base_url, "notebook-intelligence", "emit-telemetry-event")
|
|
608
621
|
route_pattern_github_login_status = url_path_join(base_url, "notebook-intelligence", "gh-login-status")
|
|
609
622
|
route_pattern_github_login = url_path_join(base_url, "notebook-intelligence", "gh-login")
|
|
@@ -614,6 +627,7 @@ class NotebookIntelligence(ExtensionApp):
|
|
|
614
627
|
(route_pattern_capabilities, GetCapabilitiesHandler),
|
|
615
628
|
(route_pattern_config, ConfigHandler),
|
|
616
629
|
(route_pattern_update_provider_models, UpdateProviderModelsHandler),
|
|
630
|
+
(route_pattern_reload_mcp_servers, ReloadMCPServersHandler),
|
|
617
631
|
(route_pattern_emit_telemetry_event, EmitTelemetryEventHandler),
|
|
618
632
|
(route_pattern_github_login_status, GetGitHubLoginStatusHandler),
|
|
619
633
|
(route_pattern_github_login, PostGitHubLoginHandler),
|
{notebook_intelligence-2.2.8 → notebook_intelligence-2.3.1}/notebook_intelligence/github_copilot.py
RENAMED
|
@@ -473,16 +473,19 @@ def completions(model_id, messages, tools = None, response: ChatResponse = None,
|
|
|
473
473
|
'temperature': 0,
|
|
474
474
|
'top_p': 1,
|
|
475
475
|
'n': 1,
|
|
476
|
-
'stop': ['<END>'],
|
|
477
476
|
'nwo': 'NotebookIntelligence',
|
|
478
477
|
'stream': True
|
|
479
478
|
}
|
|
480
479
|
|
|
480
|
+
if not (model_id == 'gpt-5' or model_id == 'gpt-5-mini'):
|
|
481
|
+
data['stop'] = ['<END>']
|
|
482
|
+
|
|
481
483
|
if 'tool_choice' in options:
|
|
482
484
|
data['tool_choice'] = options['tool_choice']
|
|
483
485
|
|
|
484
486
|
if cancel_token is not None and cancel_token.is_cancel_requested:
|
|
485
|
-
response
|
|
487
|
+
if response is not None:
|
|
488
|
+
response.finish()
|
|
486
489
|
return
|
|
487
490
|
|
|
488
491
|
request = requests.post(
|
|
@@ -495,8 +498,9 @@ def completions(model_id, messages, tools = None, response: ChatResponse = None,
|
|
|
495
498
|
if request.status_code != 200:
|
|
496
499
|
msg = f"Failed to get completions from GitHub Copilot: [{request.status_code}]: {request.text}"
|
|
497
500
|
log.error(msg)
|
|
498
|
-
response
|
|
499
|
-
|
|
501
|
+
if response is not None:
|
|
502
|
+
response.stream(MarkdownData(msg))
|
|
503
|
+
response.finish()
|
|
500
504
|
raise Exception(msg)
|
|
501
505
|
|
|
502
506
|
client = sseclient.SSEClient(request)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notebook-intelligence/notebook-intelligence",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "AI coding assistant for JupyterLab",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"AI",
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
}
|
|
131
131
|
},
|
|
132
132
|
"_build": {
|
|
133
|
-
"load": "static/remoteEntry.
|
|
133
|
+
"load": "static/remoteEntry.8be96dca5aaf11bd8c0a.js",
|
|
134
134
|
"extension": "./extension",
|
|
135
135
|
"style": "./style"
|
|
136
136
|
}
|
notebook_intelligence-2.3.1/notebook_intelligence/labextension/static/144.32670846ec78677e2b97.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_notebook_intelligence_notebook_intelligence=self.webpackChunk_notebook_intelligence_notebook_intelligence||[]).push([[144],{85947:(e,t,n)=>{n.r(t),n.d(t,{BackendMessageType:()=>x,BuiltinToolsetType:()=>w,ContextType:()=>A,GITHUB_COPILOT_PROVIDER_ID:()=>S,INotebookIntelligence:()=>T,RequestDataType:()=>N,ResponseStreamDataType:()=>I,TelemetryEventType:()=>j,default:()=>_e});var o=n(3427),i=n(59715),l=n(72406),a=n(48118),c=n(30494),s=n(78361),r=n(42597),d=n(28531),u=n(48121),m=n(80438),g=n(81269),p=n(89159),h=n(35256),C=n(46167),f=n(74797),v=n(93345),b=n.n(v),M=n(67262),E=n(37227),y=n(52310);async function k(e="",t={}){const n=g.ServerConnection.makeSettings(),o=y.URLExt.join(n.baseUrl,"notebook-intelligence",e);let i;try{i=await g.ServerConnection.makeRequest(o,t,n)}catch(e){throw new g.ServerConnection.NetworkError(e)}let l=await i.text();if(l.length>0)try{l=JSON.parse(l)}catch(e){console.log("Not a JSON response body.",i)}if(!i.ok)throw new g.ServerConnection.ResponseError(i,l.message||l.error||l);return l}var N,x,I,A,w,D=n(74602);!function(e){e.ChatRequest="chat-request",e.ChatUserInput="chat-user-input",e.ClearChatHistory="clear-chat-history",e.RunUICommandResponse="run-ui-command-response",e.GenerateCode="generate-code",e.CancelChatRequest="cancel-chat-request",e.InlineCompletionRequest="inline-completion-request",e.CancelInlineCompletionRequest="cancel-inline-completion-request"}(N||(N={})),function(e){e.StreamMessage="stream-message",e.StreamEnd="stream-end",e.RunUICommand="run-ui-command"}(x||(x={})),function(e){e.LLMRaw="llm-raw",e.Markdown="markdown",e.MarkdownPart="markdown-part",e.Image="image",e.HTMLFrame="html-frame",e.Button="button",e.Anchor="anchor",e.Progress="progress",e.Confirmation="confirmation"}(I||(I={})),function(e){e.Custom="custom",e.CurrentFile="current-file"}(A||(A={})),function(e){e.NotebookEdit="nbi-notebook-edit",e.NotebookExecute="nbi-notebook-execute"}(w||(w={}));const S="github-copilot";var j;!function(e){e.InlineCompletionRequest="inline-completion-request",e.ExplainThisRequest="explain-this-request",e.FixThisCodeRequest="fix-this-code-request",e.ExplainThisOutputRequest="explain-this-output-request",e.TroubleshootThisOutputRequest="troubleshoot-this-output-request",e.GenerateCodeRequest="generate-code-request",e.ChatRequest="chat-request",e.InlineChatRequest="inline-chat-request",e.ChatResponse="chat-response",e.InlineChatResponse="inline-chat-response",e.InlineCompletionResponse="inline-completion-response"}(j||(j={}));const T=new M.Token("@notebook-intelligence/notebook-intelligence:INotebookIntelligence","AI coding assistant for JupyterLab.");var L,_;!function(e){e.NotLoggedIn="NOT_LOGGED_IN",e.ActivatingDevice="ACTIVATING_DEVICE",e.LoggingIn="LOGGING_IN",e.LoggedIn="LOGGED_IN"}(_||(_={}));class O{static async initialize(){await this.fetchCapabilities(),this.updateGitHubLoginStatus(),setInterval((()=>{this.updateGitHubLoginStatus()}),2e3),O.initializeWebsocket()}static async initializeWebsocket(){const e=g.ServerConnection.makeSettings(),t=y.URLExt.join(e.wsUrl,"notebook-intelligence","copilot");this._webSocket=new e.WebSocket(t),this._webSocket.onmessage=e=>{this._messageReceived.emit(e.data)},this._webSocket.onerror=e=>{console.error(`Websocket error: ${e}. Closing...`),this._webSocket.close()},this._webSocket.onclose=e=>{console.log(`Websocket is closed: ${e.reason}. Reconnecting...`),setTimeout((()=>{O.initializeWebsocket()}),1e3)}}static getLoginStatus(){return this._loginStatus}static getDeviceVerificationInfo(){return this._deviceVerificationInfo}static async loginToGitHub(){return this._loginStatus=_.ActivatingDevice,new Promise(((e,t)=>{k("gh-login",{method:"POST"}).then((t=>{e({verificationURI:t.verification_uri,userCode:t.user_code}),this.updateGitHubLoginStatus()})).catch((e=>{console.error(`Failed to login to GitHub Copilot.\n${e}`),t(e)}))}))}static async logoutFromGitHub(){return this._loginStatus=_.ActivatingDevice,new Promise(((e,t)=>{k("gh-logout",{method:"GET"}).then((t=>{this.updateGitHubLoginStatus().then((()=>{e(t)}))})).catch((e=>{console.error(`Failed to logout from GitHub Copilot.\n${e}`),t(e)}))}))}static async updateGitHubLoginStatus(){return new Promise(((e,t)=>{k("gh-login-status").then((t=>{this._loginStatus=t.status,this._deviceVerificationInfo.verificationURI=t.verification_uri||"",this._deviceVerificationInfo.userCode=t.user_code||"",e()})).catch((e=>{console.error(`Failed to fetch GitHub Copilot login status.\n${e}`),t(e)}))}))}static async fetchCapabilities(){return new Promise(((e,t)=>{k("capabilities",{method:"GET"}).then((t=>{this.config.capabilities=structuredClone(t),this.config.chatParticipants=structuredClone(t.chat_participants),this.configChanged.emit(),e()})).catch((e=>{console.error(`Failed to get extension capabilities.\n${e}`),t(e)}))}))}static async setConfig(e){k("config",{method:"POST",body:JSON.stringify(e)}).then((e=>{O.fetchCapabilities()})).catch((e=>{console.error(`Failed to set NBI config.\n${e}`)}))}static async updateOllamaModelList(){return new Promise(((e,t)=>{k("update-provider-models",{method:"POST",body:JSON.stringify({provider:"ollama"})}).then((async t=>{await O.fetchCapabilities(),e()})).catch((e=>{console.error(`Failed to update ollama model list.\n${e}`),t(e)}))}))}static async reloadMCPServerList(){return new Promise(((e,t)=>{k("reload-mcp-servers",{method:"POST"}).then((async t=>{await O.fetchCapabilities(),e(t)})).catch((e=>{console.error(`Failed to reload MCP server list.\n${e}`),t(e)}))}))}static async chatRequest(e,t,n,o,i,l,a,c,s){this._messageReceived.connect(((t,n)=>{(n=JSON.parse(n)).id===e&&s.emit(n)})),this._webSocket.send(JSON.stringify({id:e,type:N.ChatRequest,data:{chatId:t,prompt:n,language:o,filename:i,additionalContext:l,chatMode:a,toolSelections:c}}))}static async generateCode(e,t,n,o,i,l,a,c){const s=M.UUID.uuid4();this._messageReceived.connect(((e,t)=>{(t=JSON.parse(t)).id===s&&c.emit(t)})),this._webSocket.send(JSON.stringify({id:s,type:N.GenerateCode,data:{chatId:e,prompt:t,prefix:n,suffix:o,existingCode:i,language:l,filename:a}}))}static async sendChatUserInput(e,t){this._webSocket.send(JSON.stringify({id:e,type:N.ChatUserInput,data:t}))}static async sendWebSocketMessage(e,t,n){this._webSocket.send(JSON.stringify({id:e,type:t,data:n}))}static async inlineCompletionsRequest(e,t,n,o,i,l,a){this._messageReceived.connect(((e,n)=>{(n=JSON.parse(n)).id===t&&a.emit(n)})),this._webSocket.send(JSON.stringify({id:t,type:N.InlineCompletionRequest,data:{chatId:e,prefix:n,suffix:o,language:i,filename:l}}))}static async emitTelemetryEvent(e){return new Promise(((t,n)=>{k("emit-telemetry-event",{method:"POST",body:JSON.stringify(e)}).then((async e=>{t()})).catch((e=>{console.error(`Failed to emit telemetry event.\n${e}`),n(e)}))}))}}L=O,O._loginStatus=_.NotLoggedIn,O._deviceVerificationInfo={verificationURI:"",userCode:""},O._messageReceived=new D.Signal(L),O.config=new class{constructor(){this.capabilities={},this.chatParticipants=[],this.changed=new D.Signal(this)}get userHomeDir(){return this.capabilities.user_home_dir}get configFilePath(){return this.capabilities.config_file_path}get llmProviders(){return this.capabilities.llm_providers}get chatModels(){return this.capabilities.chat_models}get inlineCompletionModels(){return this.capabilities.inline_completion_models}get chatModel(){return this.capabilities.chat_model}get inlineCompletionModel(){return this.capabilities.inline_completion_model}get usingGitHubCopilotModel(){return this.chatModel.provider===S||this.inlineCompletionModel.provider===S}get storeGitHubAccessToken(){return!0===this.capabilities.store_github_access_token}get toolConfig(){return this.capabilities.tool_config}},O.configChanged=L.config.changed;var R=n(14067),W=n.n(R),z=n(93798),P=n.n(z),G=n(50238),U=n(50695),F=n(13151);const q=(0,n(96559).encoding_for_model)("gpt-4o");function Q(e){e.endsWith("```")&&(e=e.slice(0,-3));const t=e.split("\n");if(t.length<2)return e;const n=t.length;let o=-1,i=n;for(let e=0;e<n;e++)if(-1===o){if(t[e].trimStart().startsWith("```")){o=e;continue}}else if(t[e].trimStart().startsWith("```")){i=e;break}return-1!==o?t.slice(o+1,i).join("\n"):e}function Z(){return"false"===document.body.getAttribute("data-jp-theme-light")}function V(e){return e.split("\n").map((e=>`# ${e}`)).join("\n")}function Y(e){let t="";const n=e.outputArea.model.toJSON();for(const e of n)"execute_result"===e.output_type?t+="object"==typeof e.data&&null!==e.data?e.data["text/plain"]:"\n":"stream"===e.output_type?t+=e.text+"\n":"error"===e.output_type&&Array.isArray(e.traceback)&&(t+=e.ename+": "+e.evalue+"\n",t+=e.traceback.map((e=>e.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""))).join("\n")+"\n");return t}function $(e,t){return e.line===t.line&&e.column===t.column}function H(e){return e.start.line===e.end.line&&e.start.column===e.end.column}function J(e){const t=e.getSelection(),n=e.getOffsetAt(t.start),o=e.getOffsetAt(t.end);return e.model.sharedModel.getSource().substring(n,o)}function B(e,t){var n;const o=e.getSelection(),i=e.getOffsetAt(o.start),l=e.getOffsetAt(o.end);e.model.sharedModel.updateSource(i,l,t);const a=t.split("\n").length,c=Math.min(o.start.line+a-1,e.lineCount-1),s=(null===(n=e.getLine(c))||void 0===n?void 0:n.length)||0;e.setCursorPosition({line:c,column:s})}const K='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--\x3e<path fill="currentColor" d="M384 336l-192 0c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l140.1 0L400 115.9 400 320c0 8.8-7.2 16-16 16zM192 384l192 0c35.3 0 64-28.7 64-64l0-204.1c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1L192 0c-35.3 0-64 28.7-64 64l0 256c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64L0 448c0 35.3 28.7 64 64 64l192 0c35.3 0 64-28.7 64-64l0-32-48 0 0 32c0 8.8-7.2 16-16 16L64 464c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l32 0 0-48-32 0z"/></svg>\n',X='<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M6.25 9.016C6.66421 9.016 7 9.35089 7 9.76399V11.26C7 11.6731 6.66421 12.008 6.25 12.008C5.83579 12.008 5.5 11.6731 5.5 11.26V9.76399C5.5 9.35089 5.83579 9.016 6.25 9.016Z"/><path d="M10.5 9.76399C10.5 9.35089 10.1642 9.016 9.75 9.016C9.33579 9.016 9 9.35089 9 9.76399V11.26C9 11.6731 9.33579 12.008 9.75 12.008C10.1642 12.008 10.5 11.6731 10.5 11.26V9.76399Z"/><path d="M7.86079 1.80482C7.91028 1.8577 7.95663 1.91232 8 1.96856C8.04337 1.91232 8.08972 1.8577 8.13921 1.80482C8.82116 1.07611 9.87702 0.90832 11.0828 1.04194C12.3131 1.17827 13.2283 1.56829 13.8072 2.29916C14.3725 3.01276 14.5 3.90895 14.5 4.77735C14.5 5.34785 14.447 5.92141 14.2459 6.428L14.4135 7.26391L14.4798 7.29699C15.4115 7.76158 16 8.71126 16 9.7501V11.0107C16 11.2495 15.9143 11.4478 15.844 11.5763C15.7691 11.7131 15.6751 11.8368 15.5851 11.9416C15.4049 12.1512 15.181 12.3534 14.9801 12.5202C14.7751 12.6907 14.5728 12.8419 14.4235 12.9494C14.1842 13.1217 13.9389 13.2807 13.6826 13.4277C13.3756 13.6038 12.9344 13.8361 12.3867 14.0679C11.2956 14.5296 9.75604 15 8 15C6.24396 15 4.70442 14.5296 3.61334 14.0679C3.06559 13.8361 2.62435 13.6038 2.31739 13.4277C2.0611 13.2807 1.81581 13.1217 1.57651 12.9494C1.42716 12.8419 1.2249 12.6907 1.01986 12.5202C0.819 12.3534 0.595113 12.1512 0.414932 11.9416C0.3249 11.8368 0.230849 11.7131 0.156031 11.5763C0.0857453 11.4478 0 11.2495 1.90735e-06 11.0107L0 9.7501C0 8.71126 0.588507 7.76158 1.52017 7.29699L1.5865 7.26391L1.75413 6.42799C1.55295 5.9214 1.5 5.34785 1.5 4.77735C1.5 3.90895 1.62745 3.01276 2.19275 2.29916C2.77172 1.56829 3.68694 1.17827 4.91718 1.04194C6.12298 0.90832 7.17884 1.07611 7.86079 1.80482ZM3.0231 7.7282L3 7.8434V12.0931C3.02086 12.1053 3.04268 12.1179 3.06543 12.131C3.32878 12.2821 3.71567 12.4861 4.19916 12.6907C5.17058 13.1017 6.50604 13.504 8 13.504C9.49396 13.504 10.8294 13.1017 11.8008 12.6907C12.2843 12.4861 12.6712 12.2821 12.9346 12.131C12.9573 12.1179 12.9791 12.1053 13 12.0931V7.8434L12.9769 7.7282C12.4867 7.93728 11.9022 8.01867 11.25 8.01867C10.1037 8.01867 9.19051 7.69201 8.54033 7.03004C8.3213 6.80703 8.14352 6.55741 8 6.28924C7.85648 6.55741 7.6787 6.80703 7.45967 7.03004C6.80949 7.69201 5.89633 8.01867 4.75 8.01867C4.09776 8.01867 3.51325 7.93728 3.0231 7.7282ZM6.76421 2.82557C6.57116 2.61928 6.12702 2.41307 5.08282 2.52878C4.06306 2.64179 3.60328 2.93176 3.36975 3.22656C3.12255 3.53861 3 4.01374 3 4.77735C3 5.56754 3.12905 5.94499 3.3082 6.1441C3.47045 6.32443 3.82768 6.52267 4.75 6.52267C5.60367 6.52267 6.08903 6.28769 6.38811 5.98319C6.70349 5.66209 6.91507 5.1591 7.00579 4.43524C7.12274 3.50212 6.96805 3.04338 6.76421 2.82557ZM9.23579 2.82557C9.03195 3.04338 8.87726 3.50212 8.99421 4.43524C9.08493 5.1591 9.29651 5.66209 9.61189 5.98319C9.91097 6.28769 10.3963 6.52267 11.25 6.52267C12.1723 6.52267 12.5295 6.32443 12.6918 6.1441C12.871 5.94499 13 5.56754 13 4.77735C13 4.01374 12.8775 3.53861 12.6303 3.22656C12.3967 2.93176 11.9369 2.64179 10.9172 2.52878C9.87298 2.41307 9.42884 2.61928 9.23579 2.82557Z"/></svg>\n';var ee=n(87284);const te=(0,v.memo)((function({children:e,getApp:t,getActiveDocumentInfo:n}){const o=t(),i=n().filename.endsWith(".ipynb");return b().createElement(W(),{remarkPlugins:[P()],components:{code({node:e,inline:t,className:n,children:l,getApp:a,...c}){const s=/language-(\w+)/.exec(n||""),r=String(l).replace(/\n$/,""),d=s?s[1]:"text";return!t&&s?b().createElement("div",null,b().createElement("div",{className:"code-block-header"},b().createElement("div",{className:"code-block-header-language"},b().createElement("span",null,d)),b().createElement("div",{className:"code-block-header-button",onClick:()=>{navigator.clipboard.writeText(r)}},b().createElement(F.ASe,{size:16,title:"Copy to clipboard"}),b().createElement("span",null,"Copy")),b().createElement("div",{className:"code-block-header-button",onClick:()=>{o.commands.execute("notebook-intelligence:insert-at-cursor",{language:d,code:r})}},b().createElement(F.Mo,{size:16,title:"Insert at cursor"})),i&&b().createElement("div",{className:"code-block-header-button",onClick:()=>{o.commands.execute("notebook-intelligence:add-code-as-new-cell",{language:d,code:r})}},b().createElement(F.ivV,{size:16,title:"Add as new cell"})),b().createElement("div",{className:"code-block-header-button",onClick:()=>{o.commands.execute("notebook-intelligence:create-new-file",{language:d,code:r})}},b().createElement(F.NEl,{size:16,title:"New file"})),"python"===d&&b().createElement("div",{className:"code-block-header-button",onClick:()=>{o.commands.execute("notebook-intelligence:create-new-notebook-from-py",{language:d,code:r})}},b().createElement(F.YER,{size:16,title:"New notebook"}))),b().createElement(G.Prism,{style:Z()?U.bM:U.Je,PreTag:"div",language:d,...c},r)):b().createElement("code",{className:n,...c},l)}}},e)})),ne="openai-compatible-chat-model",oe="litellm-compatible-chat-model",ie="openai-compatible-inline-completion-model",le="litellm-compatible-inline-completion-model";var ae;!function(e){e[e.Chat=0]="Chat",e[e.ExplainThis=1]="ExplainThis",e[e.FixThis=2]="FixThis",e[e.GenerateCode=3]="GenerateCode",e[e.ExplainThisOutput=4]="ExplainThisOutput",e[e.TroubleshootThisOutput=5]="TroubleshootThisOutput"}(ae||(ae={}));class ce extends i.ReactWidget{constructor(e){super(),this._options=e,this.node.style.height="100%"}render(){return b().createElement(fe,{getActiveDocumentInfo:this._options.getActiveDocumentInfo,getActiveSelectionContent:this._options.getActiveSelectionContent,getCurrentCellContents:this._options.getCurrentCellContents,openFile:this._options.openFile,getApp:this._options.getApp,getTelemetryEmitter:this._options.getTelemetryEmitter})}}class se extends i.ReactWidget{constructor(e,t){super(),this.node.classList.add("inline-prompt-widget"),this.node.style.top=`${e.top+32}px`,this.node.style.left=`${e.left}px`,this.node.style.width=e.width+"px",this.node.style.height="48px",this._options=t,this.node.addEventListener("focusout",(e=>{this.node.contains(e.relatedTarget)||this._options.onRequestCancelled()}))}updatePosition(e){this.node.style.top=`${e.top+32}px`,this.node.style.left=`${e.left}px`,this.node.style.width=e.width+"px"}_onResponse(e){var t,n,o,i,l;if(e.type===x.StreamMessage){if(!(null===(n=null===(t=e.data.choices)||void 0===t?void 0:t[0])||void 0===n?void 0:n.delta))return;const a=null===(l=null===(i=null===(o=e.data.choices)||void 0===o?void 0:o[0])||void 0===i?void 0:i.delta)||void 0===l?void 0:l.content;if(!a)return;this._options.onContentStream(a)}else if(e.type===x.StreamEnd){this._options.onContentStreamEnd();const e=((new Date).getTime()-this._requestTime.getTime())/1e3;this._options.telemetryEmitter.emitTelemetryEvent({type:j.InlineChatResponse,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model},timeElapsed:e}})}}_onRequestSubmitted(e){""!==this._options.existingCode&&(this.node.style.height="300px"),this._options.prompt=e,this._options.onRequestSubmitted(e),this._requestTime=new Date,this._options.telemetryEmitter.emitTelemetryEvent({type:j.InlineChatRequest,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model},prompt:e}})}render(){return b().createElement(ve,{prompt:this._options.prompt,existingCode:this._options.existingCode,onRequestSubmitted:this._onRequestSubmitted.bind(this),onRequestCancelled:this._options.onRequestCancelled,onResponseEmit:this._onResponse.bind(this),prefix:this._options.prefix,suffix:this._options.suffix,onUpdatedCodeChange:this._options.onUpdatedCodeChange,onUpdatedCodeAccepted:this._options.onUpdatedCodeAccepted})}}class re extends i.ReactWidget{constructor(e){super(),this._getApp=e.getApp}render(){return b().createElement(Ee,{getApp:this._getApp})}}class de extends i.ReactWidget{constructor(e){super(),this._onLoggedIn=e.onLoggedIn}render(){return b().createElement(ye,{onLoggedIn:()=>this._onLoggedIn()})}}class ue extends i.ReactWidget{constructor(e){super(),this._onSave=e.onSave}render(){return b().createElement(ke,{onSave:this._onSave})}}const me=new Map;function ge(e){const t=(0,v.useMemo)((()=>URL.createObjectURL(new Blob([e.source],{type:"text/html"}))),[]);return b().createElement("div",{className:"chat-response-html-frame",key:`key-${e.index}`},b().createElement("iframe",{className:"chat-response-html-frame-iframe",height:e.height,sandbox:"allow-scripts",src:t}))}const pe=(0,v.memo)((function(e){var t,n,o;const[i,l]=(0,v.useState)(0),a=e.message,c=a.date.toLocaleTimeString("en-US",{hour12:!1}),s=(t,n)=>{e.getApp().commands.execute(t,n)},r=[];let d;const u=e=>{let t=e.content;if("string"!=typeof t)return!1;let n="",o=new Date;const i=new Date,l=t.indexOf("<think>"),a=l>=0;o=new Date(e.created),a&&(t=t.substring(l+7));const c=t.indexOf("</think>"),s=c>=0;return s?(n+=t.substring(0,c),t=t.substring(c+8)):a&&(n+=t,t=""),e.content=t,e.reasoningContent=n,e.reasoningFinished=s,e.reasoningTime=(i.getTime()-o.getTime())/1e3,a&&!s};for(let e=0;e<a.contents.length;e++){const t=a.contents[e];t.type===d&&d===I.MarkdownPart?r[r.length-1].content+=t.content:(r.push(structuredClone(t)),d=t.type)}const[m,g]=(0,v.useState)(!1);for(const e of r)u(e)&&!m&&g(!0);(0,v.useEffect)((()=>{let e;return m&&(e=setInterval((()=>{l((e=>e+1)),g(!1)}),1e3)),()=>clearInterval(e)}),[m]);const p=e=>{const t=e.currentTarget.parentElement;t.classList.contains("expanded")?t.classList.remove("expanded"):t.classList.add("expanded")};return b().createElement("div",{className:`chat-message chat-message-${a.from}`,"data-render-count":i},b().createElement("div",{className:"chat-message-header"},b().createElement("div",{className:"chat-message-from"},(null===(t=a.participant)||void 0===t?void 0:t.iconPath)&&b().createElement("div",{className:`chat-message-from-icon ${"default"===(null===(n=a.participant)||void 0===n?void 0:n.id)?"chat-message-from-icon-default":""} ${Z()?"dark":""}`},b().createElement("img",{src:a.participant.iconPath})),b().createElement("div",{className:"chat-message-from-title"},"user"===a.from?"User":(null===(o=a.participant)||void 0===o?void 0:o.name)||"AI Assistant"),b().createElement("div",{className:"chat-message-from-progress",style:{display:e.showGenerating?"visible":"none"}},b().createElement("div",{className:"loading-ellipsis"},"Generating"))),b().createElement("div",{className:"chat-message-timestamp"},c)),b().createElement("div",{className:"chat-message-content"},r.map(((t,n)=>{switch(t.type){case I.Markdown:case I.MarkdownPart:return b().createElement(b().Fragment,null,t.reasoningContent&&b().createElement("div",{className:"expandable-content"},b().createElement("div",{className:"expandable-content-title",onClick:e=>p(e)},b().createElement(F.ny8,{className:"collapsed-icon"}),b().createElement(F.xDk,{className:"expanded-icon"})," ",t.reasoningFinished?"Thought":`Thinking (${Math.floor(t.reasoningTime)} s)`),b().createElement("div",{className:"expandable-content-text"},b().createElement(te,{key:`key-${n}`,getApp:e.getApp,getActiveDocumentInfo:e.getActiveDocumentInfo},t.reasoningContent))),b().createElement(te,{key:`key-${n}`,getApp:e.getApp,getActiveDocumentInfo:e.getActiveDocumentInfo},t.content),t.contentDetail?b().createElement("div",{className:"expandable-content"},b().createElement("div",{className:"expandable-content-title",onClick:e=>p(e)},b().createElement(F.ny8,{className:"collapsed-icon"}),b().createElement(F.xDk,{className:"expanded-icon"})," ",t.contentDetail.title),b().createElement("div",{className:"expandable-content-text"},b().createElement(te,{key:`key-${n}`,getApp:e.getApp,getActiveDocumentInfo:e.getActiveDocumentInfo},t.contentDetail.content))):null);case I.Image:return b().createElement("div",{className:"chat-response-img",key:`key-${n}`},b().createElement("img",{src:t.content}));case I.HTMLFrame:return b().createElement(ge,{index:n,source:t.content.source,height:t.content.height});case I.Button:return b().createElement("div",{className:"chat-response-button",key:`key-${n}`},b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-styled",onClick:()=>s(t.content.commandId,t.content.args)},b().createElement("div",{className:"jp-Dialog-buttonLabel"},t.content.title)));case I.Anchor:return b().createElement("div",{className:"chat-response-anchor",key:`key-${n}`},b().createElement("a",{href:t.content.uri,target:"_blank"},t.content.title));case I.Progress:return n===r.length-1?b().createElement("div",{className:"chat-response-progress",key:`key-${n}`},"✓ ",t.content):null;case I.Confirmation:return"confirmed"===me.get(t.id)?null:"canceled"===me.get(t.id)?b().createElement("div",null,"✖ Canceled"):b().createElement("div",{className:"chat-confirmation-form",key:`key-${n}`},t.content.title?b().createElement("div",null,b().createElement("b",null,t.content.title)):null,t.content.message?b().createElement("div",null,t.content.message):null,b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-styled",onClick:()=>{var e;e=t.id,me.set(e,"confirmed"),l((e=>e+1)),s("notebook-intelligence:chat-user-input",t.content.confirmArgs)}},b().createElement("div",{className:"jp-Dialog-buttonLabel"},t.content.confirmLabel)),b().createElement("button",{className:"jp-Dialog-button jp-mod-reject jp-mod-styled",onClick:()=>{var e;e=t.id,me.set(e,"canceled"),l((e=>e+1)),s("notebook-intelligence:chat-user-input",t.content.cancelArgs)}},b().createElement("div",{className:"jp-Dialog-buttonLabel"},t.content.cancelLabel)))}return null})),a.notebookLink&&b().createElement("a",{className:"copilot-generated-notebook-link","data-ref":a.notebookLink,onClick:t=>{const n=t.target.dataset.ref;e.openFile(n)}},"open notebook")))}));async function he(e,t){switch(e.type){case ae.Chat:return O.chatRequest(e.messageId,e.chatId,e.content,e.language||"python",e.filename||"Untitled.ipynb",e.additionalContext||[],e.chatMode,e.toolSelections||{},t);case ae.ExplainThis:case ae.FixThis:case ae.ExplainThisOutput:case ae.TroubleshootThisOutput:return O.chatRequest(e.messageId,e.chatId,e.content,e.language||"python",e.filename||"Untitled.ipynb",[],"ask",{},t);case ae.GenerateCode:return O.generateCode(e.chatId,e.content,e.prefix||"",e.suffix||"",e.existingCode||"",e.language||"python",e.filename||"Untitled.ipynb",t)}}function Ce(e){const t=e.indent||0;return b().createElement("div",{className:`checkbox-item checkbox-item-indent-${t} ${e.header?"checkbox-item-header":""}`,title:e.title,onClick:t=>e.onClick(t)},b().createElement("div",{className:"checkbox-item-toggle"},e.checked?b().createElement(ee.lEn,{className:"checkbox-icon"}):b().createElement(ee.ZRN,{className:"checkbox-icon"}),e.label),e.title&&b().createElement("div",{className:"checkbox-item-description"},e.title))}function fe(e){const[t,n]=(0,v.useState)([]),[o,i]=(0,v.useState)(""),[l,a]=(0,v.useState)(""),c=(0,v.useRef)(null),[s,r]=(0,v.useState)(_.NotLoggedIn),[d,u]=(0,v.useState)(0),[m,g]=(0,v.useState)(!1),[p,h]=(0,v.useState)(!1),[C,f]=(0,v.useState)([]),[E,y]=(0,v.useState)([]),[k,D]=(0,v.useState)(0),T=(0,v.useRef)(null),[L,R]=(0,v.useState)([]),[W,z]=(0,v.useState)(0),[P,G]=(0,v.useState)(M.UUID.uuid4()),U=(0,v.useRef)(""),q=(0,v.useRef)(new Date),[Q,Z]=(0,v.useState)(!1),[V,Y]=(0,v.useState)(null),[$,H]=(0,v.useState)(""),J=e.getTelemetryEmitter(),[B,K]=(0,v.useState)("ask"),[X,ee]=(0,v.useState)("Tool selection"),[te,ne]=(0,v.useState)(0),[oe,ie]=(0,v.useState)(!1),[le,ce]=(0,v.useState)({builtinToolsets:[{id:w.NotebookEdit,name:"Notebook edit"},{id:w.NotebookExecute,name:"Notebook execute"}],mcpServers:[],extensions:[]}),[se,re]=(0,v.useState)(!1),de={builtinToolsets:[w.NotebookEdit],mcpServers:{},extensions:{}},ue={builtinToolsets:[],mcpServers:{},extensions:{}},[me,ge]=(0,v.useState)(de),[fe,ve]=(0,v.useState)(!1),[be,Me]=(0,v.useState)(0),[Ee,ye]=(0,v.useState)(!1);O.configChanged.connect((()=>{ce(O.config.toolConfig)})),(0,v.useEffect)((()=>{let e=!1;for(const t of le.extensions)if(t.toolsets.length>0){e=!0;break}ve(e)}),[le]),(0,v.useEffect)((()=>{const e=me.builtinToolsets.length;let t=0,n=0;for(const e in me.mcpServers)t+=me.mcpServers[e].length;for(const e in me.extensions){const t=me.extensions[e];for(const e in t)n+=t[e].length}const o=[];e>0&&o.push(`${e} built-in`),t>0&&o.push(`${t} mcp`),n>0&&o.push(`${n} ext`),ne(e+t+n),ie(me.builtinToolsets.includes(w.NotebookExecute)),ee(0===o.length?"Tool selection":`Tool selection (${o.join(", ")})`)}),[me]);const ke=e=>me.builtinToolsets.includes(e),Ne=e=>{if(!(e in me.mcpServers))return!1;const t=le.mcpServers.find((t=>t.id===e)),n=me.mcpServers[e];for(const e of t.tools)if(!n.includes(e.name))return!1;return!0},xe=(e,t)=>e in me.mcpServers&&me.mcpServers[e].includes(t),Ie=e=>{if(!(e in me.extensions))return!1;const t=le.extensions.find((t=>t.id===e));for(const n of t.toolsets)if(!Ae(e,n.id))return!1;return!0},Ae=(e,t)=>{if(!(e in me.extensions))return!1;if(!(t in me.extensions[e]))return!1;const n=le.extensions.find((t=>t.id===e)).toolsets.find((e=>e.id===t)),o=me.extensions[e][t];for(const e of n.tools)if(!o.includes(e.name))return!1;return!0},we=(e,t,n)=>{if(!(e in me.extensions))return!1;const o=me.extensions[e];return t in o&&o[t].includes(n)};(0,v.useEffect)((()=>{const e=[];if("ask"!==B)return e.push("/clear"),f(e),void y(e);const t=O.config.chatParticipants;for(const n of t){const t=n.id,o=n.commands,i="default"===t?"":`@${t}`;""!==i&&e.push(i);const l=""===i?"":`${i} `;for(const t of o)e.push(`${l}/${t}`)}f(e),y(e)}),[B]),(0,v.useEffect)((()=>{const e=()=>{r(O.getLoginStatus())};e();const t=setInterval(e,1e3);return()=>clearInterval(t)}),[d]),(0,v.useEffect)((()=>{D(0)}),[E]);const De=e=>{var t;e.includes(o)?i(`${e} `):i(`${e} ${o} `),h(!1),null===(t=T.current)||void 0===t||t.focus(),D(0)},Se=async()=>{re(!1),m?Te():je()},je=async()=>{z(L.length+1),R([...L,o]),h(!1);const l=[],a=o.split(" ");if(a.length>1)for(let e=0;e<Math.min(a.length,2);e++){const t=a[e];(t.startsWith("@")||t.startsWith("/"))&&l.push(t)}const c=l.length>0?l.join(" ")+" ":"";U.current=M.UUID.uuid4(),q.current=new Date;const s=[...t,{id:U.current,date:new Date,from:"user",contents:[{id:M.UUID.uuid4(),type:I.Markdown,content:o,created:new Date}]}];if(n(s),o.startsWith("/clear"))return n([]),i(""),Oe(),_e(),R([]),z(0),void O.sendWebSocketMessage(M.UUID.uuid4(),N.ClearChatHistory,{chatId:P});g(!0);const r=e.getActiveDocumentInfo(),d=o,u=[],m=e.getApp(),p=[];if(Q&&(null==V?void 0:V.filename)){const t=V.selection,n=t&&!(t.start.line===t.end.line&&t.start.column===t.end.column);p.push({type:A.CurrentFile,content:e.getActiveSelectionContent(),currentCellContents:n?null:e.getCurrentCellContents(),filePath:V.filePath,cellIndex:V.activeCellIndex,startLine:t?t.start.line+1:1,endLine:t?t.end.line+1:1})}he({messageId:U.current,chatId:P,type:ae.Chat,content:d,language:r.language,filename:r.filename,additionalContext:p,chatMode:B,toolSelections:me},{emit:async e=>{var t,o,i,l,a;if(e.id!==U.current)return;let c="";if(e.type===x.StreamMessage){const n=null===(o=null===(t=e.data.choices)||void 0===t?void 0:t[0])||void 0===o?void 0:o.delta;if(!n)return;if(n.nbiContent){const t=n.nbiContent;u.push({id:M.UUID.uuid4(),type:t.type,content:t.content,contentDetail:t.detail,created:new Date(e.created)})}else{if(c=null===(a=null===(l=null===(i=e.data.choices)||void 0===i?void 0:i[0])||void 0===l?void 0:l.delta)||void 0===a?void 0:a.content,!c)return;u.push({id:M.UUID.uuid4(),type:I.MarkdownPart,content:c,created:new Date(e.created)})}}else if(e.type===x.StreamEnd){g(!1);const e=((new Date).getTime()-q.current.getTime())/1e3;J.emitTelemetryEvent({type:j.ChatResponse,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model},timeElapsed:e}})}else if(e.type===x.RunUICommand){const t=e.id,n=await m.commands.execute(e.data.commandId,e.data.args),o={callback_id:e.data.callback_id,result:n||"void"};try{JSON.stringify(o)}catch(e){o.result="Could not serialize the result"}O.sendWebSocketMessage(t,N.RunUICommandResponse,o)}n([...s,{id:M.UUID.uuid4(),date:new Date,from:"copilot",contents:u,participant:O.config.chatParticipants.find((t=>t.id===e.participant))}])}});const C=o.startsWith("/settings")?"":c;i(C),Le(C),J.emitTelemetryEvent({type:j.ChatRequest,data:{chatMode:B,chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model},prompt:d}})},Te=async()=>{O.sendWebSocketMessage(U.current,N.CancelChatRequest,{chatId:P}),U.current="",g(!1)},Le=e=>{const t=e.trimStart();y(""===t?C:C.filter((e=>e.includes(t))))},_e=()=>{y(C),D(0)},Oe=()=>{G(M.UUID.uuid4())},Re=async()=>{e.getApp().commands.execute("notebook-intelligence:open-configuration-dialog")};(0,v.useEffect)((()=>{(()=>{var e;const t=Date.now();t-be>=1e3?(null===(e=c.current)||void 0===e||e.scrollIntoView({behavior:"smooth"}),Me(t)):Ee||(ye(!0),setTimeout((()=>{var e;null===(e=c.current)||void 0===e||e.scrollIntoView({behavior:"smooth"}),Me(Date.now()),ye(!1)}),1e3-(t-be)))})()}),[t]);const We=(0,v.useCallback)((e=>{const o=e.detail;o.chatId=P;let i="";switch(o.type){case ae.ExplainThis:i=`Explain this code:\n\`\`\`\n${o.content}\n\`\`\`\n`;break;case ae.FixThis:i=`Fix this code:\n\`\`\`\n${o.content}\n\`\`\`\n`;break;case ae.ExplainThisOutput:i=`Explain this notebook cell output: \n\`\`\`\n${o.content}\n\`\`\`\n`;break;case ae.TroubleshootThisOutput:i=`Troubleshoot errors reported in the notebook cell output: \n\`\`\`\n${o.content}\n\`\`\`\n`}const l=M.UUID.uuid4();o.messageId=l;const a=[...t,{id:l,date:new Date,from:"user",contents:[{id:l,type:I.Markdown,content:i,created:new Date}]}];n(a),g(!0);const c=[];he(o,{emit:e=>{var t,o,i,l,s;if(e.type===x.StreamMessage){if(!(null===(o=null===(t=e.data.choices)||void 0===t?void 0:t[0])||void 0===o?void 0:o.delta))return;const n=null===(s=null===(l=null===(i=e.data.choices)||void 0===i?void 0:i[0])||void 0===l?void 0:l.delta)||void 0===s?void 0:s.content;if(!n)return;c.push({id:e.id,type:I.MarkdownPart,content:n,created:new Date(e.created)})}else e.type===x.StreamEnd&&g(!1);const r=M.UUID.uuid4();n([...a,{id:r,date:new Date,from:"copilot",contents:c,participant:O.config.chatParticipants.find((t=>t.id===e.participant))}])}})}),[t]);(0,v.useEffect)((()=>(document.addEventListener("copilotSidebar:runPrompt",We),()=>{document.removeEventListener("copilotSidebar:runPrompt",We)})),[t]);const ze=e=>{var t;(null===(t=e.detail.activeDocumentInfo)||void 0===t?void 0:t.filePath)!==(null==V?void 0:V.filePath)&&Z(!1),Y({...e.detail.activeDocumentInfo,activeWidget:null}),H(Pe(e.detail.activeDocumentInfo))};(0,v.useEffect)((()=>(document.addEventListener("copilotSidebar:activeDocumentChanged",ze),()=>{document.removeEventListener("copilotSidebar:activeDocumentChanged",ze)})),[V]);const Pe=e=>{if(!(null==e?void 0:e.filename))return"";let t="";return!e.selection||e.selection.start.line===e.selection.end.line&&e.selection.start.column===e.selection.end.column||(e.filename.endsWith(".ipynb")&&(t=` · Cell ${e.activeCellIndex+1}`),e.selection.start.line===e.selection.end.line?t+=`:${e.selection.start.line+1}`:t+=`:${e.selection.start.line+1}-${e.selection.end.line+1}`),`${e.filename}${t}`},Ge=O.config,Ue=()=>Ge.usingGitHubCopilotModel&&O.getLoginStatus()===_.NotLoggedIn,Fe=()=>Ge.chatModel.provider===S?!Ue():Ge.llmProviders.find((e=>e.id===Ge.chatModel.provider)),[qe,Qe]=(0,v.useState)(Ue()),[Ze,Ve]=(0,v.useState)(Fe());return O.configChanged.connect((()=>{Qe(Ue()),Ve(Fe())})),(0,v.useEffect)((()=>{Qe(Ue()),Ve(Fe())}),[s]),b().createElement("div",{className:"sidebar"},b().createElement("div",{className:"sidebar-header"},b().createElement("div",{className:"sidebar-title"},"Notebook Intelligence"),b().createElement("div",{className:"user-input-footer-button",onClick:()=>(async()=>{re(!1),e.getApp().commands.execute("notebook-intelligence:open-configuration-dialog")})()},b().createElement(F.Fy3,null))),!Ze&&!qe&&b().createElement("div",{className:"sidebar-login-info"},"Chat is disabled as you don't have a model configured.",b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-styled",onClick:Re},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Configure models"))),qe&&b().createElement("div",{className:"sidebar-login-info"},b().createElement("div",null,"You are not logged in to GitHub Copilot. Please login now to activate chat."),b().createElement("div",{className:"sidebar-login-buttons"},b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-styled",onClick:async()=>{e.getApp().commands.execute("notebook-intelligence:open-github-copilot-login-dialog")}},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Login to GitHub Copilot")),b().createElement("button",{className:"jp-Dialog-button jp-mod-reject jp-mod-styled",onClick:Re},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Change provider")))),Ze&&(0===t.length?b().createElement("div",{className:"sidebar-messages"},b().createElement("div",{className:"sidebar-greeting"},"Welcome! How can I assist you today?")):b().createElement("div",{className:"sidebar-messages"},t.map(((n,o)=>b().createElement(pe,{key:n.id,message:n,openFile:e.openFile,getApp:e.getApp,getActiveDocumentInfo:e.getActiveDocumentInfo,showGenerating:o===t.length-1&&"copilot"===n.from&&m}))),b().createElement("div",{ref:c}))),Ze&&b().createElement("div",{className:"sidebar-user-input "+(m?"generating":"")},b().createElement("textarea",{ref:T,rows:3,onChange:e=>{const t=e.target.value;i(t);const n=t.trimStart();"@"===n||"/"===n?(h(!0),Le(n)):n.startsWith("@")||n.startsWith("/")||""===n?Le(n):h(!1)},onKeyDown:async e=>{if("Enter"===e.key){if(e.stopPropagation(),e.preventDefault(),p)return void De(E[k]);D(0),Se()}else if("Tab"===e.key){if(p)return e.stopPropagation(),e.preventDefault(),void De(E[k])}else if("Escape"===e.key)e.stopPropagation(),e.preventDefault(),h(!1),re(!1),D(0);else if("ArrowUp"===e.key){if(e.stopPropagation(),e.preventDefault(),p)return void D((k-1+E.length)%E.length);if(h(!1),L.length>0&&W===L.length&&a(o),L.length>0&&W>0&&W<=L.length){const e=L[W-1],t=W-1;i(e),z(t)}}else if("ArrowDown"===e.key){if(e.stopPropagation(),e.preventDefault(),p)return void D((k+1+E.length)%E.length);if(h(!1),L.length>0&&W>=0&&W<L.length){if(W===L.length-1)return i(l),void z(L.length);const e=L[W+1],t=W+1;i(e),z(t)}}},placeholder:"Ask Notebook Intelligence...",spellCheck:!1,value:o}),(null==V?void 0:V.filename)&&b().createElement("div",{className:"user-input-context-row"},b().createElement("div",{className:"user-input-context user-input-context-active-file "+(Q?"on":"off")},b().createElement("div",null,$),Q?b().createElement("div",{className:"user-input-context-toggle",onClick:()=>Z(!Q)},b().createElement(F.gZ8,{title:"Use as context"})):b().createElement("div",{className:"user-input-context-toggle",onClick:()=>Z(!Q)},b().createElement(F.iWd,{title:"Don't use as context"})))),b().createElement("div",{className:"user-input-footer"},"ask"===B&&b().createElement("div",null,b().createElement("a",{href:"javascript:void(0)",onClick:()=>{var e;h(!0),null===(e=T.current)||void 0===e||e.focus()},title:"Select chat participant"},"@")),b().createElement("div",{style:{flexGrow:1}}),b().createElement("div",{className:"chat-mode-widgets-container"},b().createElement("div",null,b().createElement("select",{className:"chat-mode-select",title:"Chat mode",value:B,onChange:e=>{"ask"===e.target.value?ge(ue):"agent"===e.target.value&&ge(de),re(!1),K(e.target.value)}},b().createElement("option",{value:"ask"},"Ask"),b().createElement("option",{value:"agent"},"Agent"))),"ask"!==B&&b().createElement("div",{className:"user-input-footer-button tools-button "+(oe?"tools-button-warning":te>0?"tools-button-active":""),onClick:()=>(async()=>{se||O.fetchCapabilities(),re(!se)})(),title:oe?`Notebook execute tool selected!\n${X}`:X},b().createElement(F.OVZ,null),te>0&&b().createElement(b().Fragment,null,te))),b().createElement("div",null,b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-styled send-button",onClick:()=>Se(),disabled:0===o.length&&!m},m?b().createElement(F.nK7,null):b().createElement(F.tON,null)))),p&&E.length>0&&b().createElement("div",{className:"user-input-autocomplete"},E.map(((e,t)=>b().createElement("div",{key:`key-${t}`,className:"user-input-autocomplete-item "+(t===k?"selected":""),"data-value":e,onClick:e=>(e=>{const t=e.target.dataset.value;De(t)})(e)},e)))),se&&b().createElement("div",{className:"mode-tools-popover",tabIndex:1,autoFocus:!0,onKeyDown:e=>{"Escape"!==e.key&&"Enter"!==e.key||(e.stopPropagation(),e.preventDefault(),re(!1))}},b().createElement("div",{className:"mode-tools-popover-header"},b().createElement("div",{className:"mode-tools-popover-header-icon"},b().createElement(F.OVZ,null)),b().createElement("div",{className:"mode-tools-popover-title"},X),b().createElement("div",{className:"mode-tools-popover-clear-tools-button",style:{visibility:te>0?"visible":"hidden"}},b().createElement("div",null,b().createElement(F.TQi,null)),b().createElement("div",null,b().createElement("a",{href:"javascript:void(0);",onClick:()=>{ge(ue)}},"clear"))),b().createElement("div",{className:"mode-tools-popover-close-button",onClick:()=>re(!1)},b().createElement("div",null,b().createElement(F.Mk4,null)),b().createElement("div",null,"Done"))),b().createElement("div",{className:"mode-tools-popover-tool-list"},b().createElement("div",{className:"mode-tools-group-header"},"Built-in"),b().createElement("div",{className:"mode-tools-group mode-tools-group-built-in"},le.builtinToolsets.map((e=>b().createElement(Ce,{key:e.id,label:e.name,checked:ke(e.id),header:!0,onClick:()=>{((e,t)=>{const n={...me};if(t)me.builtinToolsets.includes(e)||n.builtinToolsets.push(e);else{const t=n.builtinToolsets.indexOf(e);-1!==t&&n.builtinToolsets.splice(t,1)}ge(n)})(e.id,!ke(e.id))}})))),le.mcpServers.length>0&&b().createElement("div",{className:"mode-tools-group-header"},"MCP Servers"),le.mcpServers.map(((e,t)=>b().createElement("div",{className:"mode-tools-group"},b().createElement(Ce,{label:e.id,header:!0,checked:Ne(e.id),onClick:()=>(e=>{if((e=>e in me.mcpServers&&me.mcpServers[e].length>0)(e)){const t={...me};delete t.mcpServers[e],ge(t)}else{const t=le.mcpServers.find((t=>t.id===e)),n={...me};n.mcpServers[e]=structuredClone(t.tools.map((e=>e.name))),ge(n)}})(e.id)}),e.tools.map(((t,n)=>b().createElement(Ce,{label:t.name,title:t.description,indent:1,checked:xe(e.id,t.name),onClick:()=>((e,t,n)=>{const o={...me};n&&!(e in o.mcpServers)&&(o.mcpServers[e]=[]);const i=o.mcpServers[e];if(n)i.push(t);else{const e=i.indexOf(t);-1!==e&&i.splice(e,1)}ge(o)})(e.id,t.name,!xe(e.id,t.name))})))))),fe&&b().createElement("div",{className:"mode-tools-group-header"},"Extension tools"),le.extensions.map(((e,t)=>b().createElement("div",{className:"mode-tools-group"},b().createElement(Ce,{label:`${e.name} (${e.id})`,header:!0,checked:Ie(e.id),onClick:()=>(e=>{if((e=>e in me.extensions&&Object.keys(me.extensions[e]).length>0)(e)){const t={...me};delete t.extensions[e],ge(t)}else{const t={...me},n=le.extensions.find((t=>t.id===e));e in t.extensions&&delete t.extensions[e],t.extensions[e]={};for(const o of n.toolsets)t.extensions[e][o.id]=structuredClone(o.tools.map((e=>e.name)));ge(t)}})(e.id)}),e.toolsets.map(((t,n)=>b().createElement(b().Fragment,null,b().createElement(Ce,{label:`${t.name} (${t.id})`,title:t.description,indent:1,checked:Ae(e.id,t.id),onClick:()=>((e,t)=>{if(((e,t)=>e in me.extensions&&t in me.extensions[e]&&me.extensions[e][t].length>0)(e,t)){const n={...me};t in n.extensions[e]&&delete n.extensions[e][t],ge(n)}else{const n=le.extensions.find((t=>t.id===e)).toolsets.find((e=>e.id===t)),o={...me};e in o.extensions||(o.extensions[e]={}),o.extensions[e][t]=structuredClone(n.tools.map((e=>e.name))),ge(o)}})(e.id,t.id)}),t.tools.map(((n,o)=>b().createElement(Ce,{label:n.name,title:n.description,indent:2,checked:we(e.id,t.id,n.name),onClick:()=>((e,t,n,o)=>{const i={...me};o&&!(e in i.extensions)&&(i.extensions[e]={}),o&&!(t in i.extensions[e])&&(i.extensions[e][t]=[]);const l=i.extensions[e][t];if(o)l.push(n);else{const e=l.indexOf(n);-1!==e&&l.splice(e,1)}ge(i)})(e.id,t.id,n.name,!we(e.id,t.id,n.name))})))))))))))))}function ve(e){const[t,n]=(0,v.useState)(""),[o,i]=(0,v.useState)(!1),l=e.onRequestSubmitted,a=e.onResponseEmit;return b().createElement("div",{className:"inline-popover"},b().createElement(Me,{...e,onRequestSubmitted:e=>{n(""),i(!0),l(e)},onResponseEmit:e=>{var t,o,i,l,c;if(e.type===x.StreamMessage){if(!(null===(o=null===(t=e.data.choices)||void 0===t?void 0:t[0])||void 0===o?void 0:o.delta))return;const a=null===(c=null===(l=null===(i=e.data.choices)||void 0===i?void 0:i[0])||void 0===l?void 0:l.delta)||void 0===c?void 0:c.content;if(!a)return;n((e=>e+a))}else e.type===x.StreamEnd&&n((e=>Q(e)));a(e)},onUpdatedCodeAccepted:e.onUpdatedCodeAccepted,limitHeight:""!==e.existingCode&&o}),""!==e.existingCode&&o&&b().createElement(b().Fragment,null,b().createElement(be,{...e,modifiedCode:t}),b().createElement("div",{className:"inline-popover-footer"},b().createElement("div",null,b().createElement("button",{className:"jp-Button jp-mod-accept jp-mod-styled jp-mod-small",onClick:()=>e.onUpdatedCodeAccepted()},"Accept")),b().createElement("div",null,b().createElement("button",{className:"jp-Button jp-mod-reject jp-mod-styled jp-mod-small",onClick:()=>e.onRequestCancelled()},"Cancel")))))}function be(e){const t=(0,v.useRef)(null),[n,o]=(0,v.useState)(null);return(0,v.useEffect)((()=>{const n=t.current;n.className="monaco-editor-container";const i=E.editor.createModel(e.existingCode,"text/plain"),l=E.editor.createModel(e.modifiedCode,"text/plain"),a=E.editor.createDiffEditor(n,{originalEditable:!1,automaticLayout:!0,theme:Z()?"vs-dark":"vs"});a.setModel({original:i,modified:l}),l.onDidChangeContent((()=>{e.onUpdatedCodeChange(l.getValue())})),o(a)}),[]),(0,v.useEffect)((()=>{var t;null===(t=null==n?void 0:n.getModifiedEditor().getModel())||void 0===t||t.setValue(e.modifiedCode)}),[e.modifiedCode]),b().createElement("div",{ref:t,className:"monaco-editor-container"})}function Me(e){const[t,n]=(0,v.useState)(e.prompt),o=(0,v.useRef)(null),[i,l]=(0,v.useState)(!1);return(0,v.useEffect)((()=>{var e;const t=o.current;t&&(t.select(),null===(e=o.current)||void 0===e||e.focus())}),[]),b().createElement("div",{className:"inline-prompt-container",style:{height:e.limitHeight?"40px":"100%"}},b().createElement("textarea",{ref:o,rows:3,onChange:e=>{const t=e.target.value;n(t)},onKeyDown:async n=>{"Enter"===n.key?(n.stopPropagation(),n.preventDefault(),i&&(n.metaKey||n.ctrlKey)?e.onUpdatedCodeAccepted():(e.onRequestSubmitted(t),(async()=>{const n=[],o=t.split(" ");if(o.length>1)for(let e=0;e<Math.min(o.length,2);e++){const t=o[e];(t.startsWith("@")||t.startsWith("/"))&&n.push(t)}he({messageId:M.UUID.uuid4(),chatId:M.UUID.uuid4(),type:ae.GenerateCode,content:t,language:void 0,filename:void 0,prefix:e.prefix,suffix:e.suffix,existingCode:e.existingCode,chatMode:"ask"},{emit:async t=>{e.onResponseEmit(t)}}),l(!0)})())):"Escape"===n.key&&(n.stopPropagation(),n.preventDefault(),e.onRequestCancelled())},placeholder:"Ask Notebook Intelligence to generate Python code...",spellCheck:!1,value:t}))}function Ee(e){const[t,n]=(0,v.useState)(_.NotLoggedIn),[o,i]=(0,v.useState)(0);return(0,v.useEffect)((()=>{const e=()=>{n(O.getLoginStatus())};e();const t=setInterval(e,1e3);return()=>clearInterval(t)}),[o]),b().createElement("div",{title:"GitHub Copilot: "+(t===_.LoggedIn?"Logged in":"Not logged in"),className:"github-copilot-status-bar",onClick:()=>{e.getApp().commands.execute("notebook-intelligence:open-github-copilot-login-dialog")},dangerouslySetInnerHTML:{__html:t===_.LoggedIn?X:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M7.86079 1.76938C7.91028 1.8224 7.95663 1.87717 8 1.93356C8.04336 1.87717 8.08972 1.8224 8.13921 1.76938C8.82116 1.03872 9.87702 0.870477 11.0828 1.00446C12.3131 1.14115 13.2283 1.53222 13.8072 2.26504C14.3725 2.98056 14.5 3.87915 14.5 4.74987C14.5 5.21326 14.4653 5.67866 14.3451 6.10875C13.9119 5.84737 13.4429 5.63921 12.9473 5.49331C12.9809 5.29773 13 5.05436 13 4.74987C13 3.98422 12.8774 3.50781 12.6303 3.19493C12.3967 2.89934 11.9369 2.60859 10.9172 2.49528C9.87298 2.37926 9.42884 2.58602 9.23579 2.79286C9.03195 3.01126 8.87725 3.47123 8.99421 4.40684C9.05402 4.88539 9.16638 5.26766 9.32639 5.56486C8.14474 5.96456 7.12813 6.72232 6.40569 7.70903C5.92566 7.90339 5.37217 7.99987 4.75 7.99987C4.09776 7.99987 3.51325 7.91826 3.0231 7.70862L3 7.82413V12.0852C3.02086 12.0974 3.04268 12.1101 3.06543 12.1232C3.32878 12.2747 3.71567 12.4793 4.19916 12.6844C4.59656 12.853 5.05487 13.0201 5.56004 13.1588C5.77061 13.7867 6.08221 14.3683 6.47552 14.8842C5.35549 14.7159 4.37511 14.3885 3.61334 14.0653C3.06559 13.8329 2.62435 13.6 2.31739 13.4234C2.16373 13.335 2.0432 13.2604 1.95925 13.2066C1.91725 13.1797 1.88437 13.158 1.86101 13.1423L1.83316 13.1235L1.82736 13.1195L1.81237 13.1094C1.79971 13.1008 1.7818 13.0886 1.75941 13.0731C1.71466 13.0422 1.65169 12.9981 1.57651 12.9438C1.42716 12.836 1.2249 12.6844 1.01986 12.5135C0.819 12.3461 0.595113 12.1435 0.414932 11.9333C0.3249 11.8282 0.230849 11.7042 0.156031 11.567C0.0857453 11.4382 0 11.2394 1.90735e-06 10.9999L0 9.73594C0 8.69432 0.588507 7.74209 1.52017 7.27626L1.5865 7.24309L1.75413 6.40494C1.55295 5.89699 1.5 5.3219 1.5 4.74987C1.5 3.87915 1.62745 2.98056 2.19275 2.26504C2.77172 1.53222 3.68694 1.14115 4.91717 1.00446C6.12298 0.870477 7.17884 1.03872 7.86079 1.76938ZM6.76421 2.79286C6.57116 2.58602 6.12702 2.37926 5.08282 2.49528C4.06305 2.60859 3.60327 2.89934 3.36974 3.19493C3.12255 3.50781 3 3.98422 3 4.74987C3 5.54218 3.12905 5.92064 3.3082 6.12028C3.47045 6.30109 3.82768 6.49987 4.75 6.49987C5.60367 6.49987 6.08903 6.26426 6.38811 5.95894C6.70349 5.63698 6.91507 5.13264 7.00579 4.40684C7.12274 3.47123 6.96805 3.01126 6.76421 2.79286Z"/><path d="M8.49808 14.8106C9.25887 15.3994 10.2135 15.7499 11.25 15.7499C13.7353 15.7499 15.75 13.7352 15.75 11.2499C15.75 9.60081 14.863 8.15893 13.54 7.37532C12.8692 6.97796 12.0862 6.74987 11.25 6.74987C10.417 6.74987 9.63686 6.97621 8.96772 7.37074C7.64049 8.1533 6.75 9.59759 6.75 11.2499C6.75 12.0588 6.96343 12.8178 7.33706 13.4738C7.63262 13.9927 8.02841 14.4471 8.49808 14.8106ZM10.5 8.74987C10.5 8.33566 10.8366 7.99987 11.2508 7.99987C11.6647 8.00031 12 8.33593 12 8.74987V10.9999C12 11.4141 11.6642 11.7499 11.25 11.7499C10.8358 11.7499 10.5 11.4141 10.5 10.9999V8.74987ZM11.25 14.4999C10.6977 14.4999 10.25 14.0522 10.25 13.4999C10.25 12.9476 10.6977 12.4999 11.25 12.4999C11.8023 12.4999 12.25 12.9476 12.25 13.4999C12.25 14.0522 11.8023 14.4999 11.25 14.4999Z"/></svg>\n'}})}function ye(e){const[t,n]=(0,v.useState)(_.NotLoggedIn),[o,i]=(0,v.useState)(0),[l,a]=(0,v.useState)(!1),[c,s]=(0,v.useState)(""),[r,d]=(0,v.useState)("");(0,v.useEffect)((()=>{const t=()=>{const t=O.getLoginStatus();n(t),t===_.LoggedIn&&l&&setTimeout((()=>{e.onLoggedIn()}),1e3)};t();const o=setInterval(t,1e3);return()=>clearInterval(o)}),[o]);const u=async()=>{await O.logoutFromGitHub(),i(o+1)},m=t===_.LoggedIn;return b().createElement("div",{className:"github-copilot-login-dialog"},b().createElement("div",{className:"github-copilot-login-status"},b().createElement("h4",null,"Login status:"," ",b().createElement("span",{className:"github-copilot-login-status-text "+(m?"logged-in":"")},m?"Logged in":t===_.LoggingIn?"Logging in...":t===_.ActivatingDevice?"Activating device...":t===_.NotLoggedIn?"Not logged in":"Unknown"))),t===_.NotLoggedIn&&b().createElement(b().Fragment,null,b().createElement("div",null,"Your code and data are directly transferred to GitHub Copilot as needed without storing any copies other than keeping in the process memory."),b().createElement("div",null,b().createElement("a",{href:"https://github.com/features/copilot",target:"_blank"},"GitHub Copilot")," ","requires a subscription and it has a free tier. GitHub Copilot is subject to the"," ",b().createElement("a",{href:"https://docs.github.com/en/site-policy/github-terms/github-terms-for-additional-products-and-features",target:"_blank"},"GitHub Terms for Additional Products and Features"),"."),b().createElement("div",null,b().createElement("h4",null,"Privacy and terms"),"By using Notebook Intelligence with GitHub Copilot subscription you agree to"," ",b().createElement("a",{href:"https://docs.github.com/en/copilot/responsible-use-of-github-copilot-features/responsible-use-of-github-copilot-chat-in-your-ide",target:"_blank"},"GitHub Copilot chat terms"),". Review the terms to understand about usage, limitations and ways to improve GitHub Copilot. Please review"," ",b().createElement("a",{href:"https://docs.github.com/en/site-policy/privacy-policies/github-general-privacy-statement",target:"_blank"},"Privacy Statement"),"."),b().createElement("div",null,b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-reject jp-mod-styled",onClick:async()=>{const e=await O.loginToGitHub();s(e.verificationURI),d(e.userCode),i(o+1),a(!0)}},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Login using your GitHub account")))),m&&b().createElement("div",null,b().createElement("button",{className:"jp-Dialog-button jp-mod-reject jp-mod-styled",onClick:u},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Logout"))),t===_.ActivatingDevice&&c&&r&&b().createElement("div",null,b().createElement("div",{className:"copilot-activation-message"},"Copy code"," ",b().createElement("span",{className:"user-code-span",onClick:()=>(navigator.clipboard.writeText(r),!0)},b().createElement("b",null,r," ",b().createElement("span",{className:"copy-icon",dangerouslySetInnerHTML:{__html:K}})))," ","and enter at"," ",b().createElement("a",{href:c,target:"_blank"},c)," ","to allow access to GitHub Copilot from this app. Activation could take up to a minute after you enter the code.")),t===_.ActivatingDevice&&b().createElement("div",{style:{marginTop:"10px"}},b().createElement("button",{className:"jp-Dialog-button jp-mod-reject jp-mod-styled",onClick:u},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Cancel activation"))))}function ke(e){var t;const n=O.config,o=n.llmProviders,[i,l]=(0,v.useState)([]),[a,c]=(0,v.useState)([]),[s,r]=(0,v.useState)((null===(t=n.toolConfig.mcpServers)||void 0===t?void 0:t.map((e=>e.id)))||[]),[d,u]=(0,v.useState)(n.chatModel.provider||"none"),[m,g]=(0,v.useState)(n.inlineCompletionModel.provider||"none"),[p,h]=(0,v.useState)(n.chatModel.model),[C,f]=(0,v.useState)([]),[M,E]=(0,v.useState)([]),[y,k]=(0,v.useState)(n.inlineCompletionModel.model),[N,x]=(0,v.useState)(n.storeGitHubAccessToken),I=(e,t)=>{"chat"===t?u(e):g(e);const o="chat"===t?n.chatModels:n.inlineCompletionModels,i="chat"===t?n.chatModel.model:n.inlineCompletionModel.model,a=o.filter((t=>t.provider===e));"chat"===t?l(a):c(a);let s=a.find((e=>e.id===i));s||(s=null==a?void 0:a[0]),s?"chat"===t?(h(s.id),f(s.properties)):(k(s.id),E(s.properties)):"chat"===t?f([]):E([])},A=(e,t,n)=>{const o=("chat"===e?C:M).map((e=>e.id===t?{...e,value:n}:e));"chat"===e?f(o):E(o)};return(0,v.useEffect)((()=>{I(d,"chat"),I(m,"inline-completion")}),[]),b().createElement("div",{className:"config-dialog"},b().createElement("div",{className:"config-dialog-body"},b().createElement("div",{className:"model-config-section"},b().createElement("div",{className:"model-config-section-header"},"Chat model"),b().createElement("div",{className:"model-config-section-body"},b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},b().createElement("div",null,"Provider"),b().createElement("div",null,b().createElement("select",{className:"jp-mod-styled",onChange:e=>I(e.target.value,"chat")},o.map(((e,t)=>b().createElement("option",{key:t,value:e.id,selected:e.id===d},e.name))),b().createElement("option",{key:-1,value:"none",selected:"none"===d||!o.find((e=>e.id===d))},"None")))),!["openai-compatible","litellm-compatible","none"].includes(d)&&i.length>0&&b().createElement("div",{className:"model-config-section-column"},b().createElement("div",null,"Model"),![ne,oe].includes(p)&&i.length>0&&b().createElement("div",null,b().createElement("select",{className:"jp-mod-styled",onChange:e=>h(e.target.value)},i.map(((e,t)=>b().createElement("option",{key:t,value:e.id,selected:e.id===p},e.name))))))),b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},"ollama"===d&&0===i.length&&b().createElement("div",{className:"ollama-warning-message"},"No Ollama models found! Make sure"," ",b().createElement("a",{href:"https://ollama.com/",target:"_blank"},"Ollama")," ","is running and models are downloaded to your computer."," ",b().createElement("a",{href:"javascript:void(0)",onClick:async()=>{await O.updateOllamaModelList(),I(d,"chat")}},"Try again")," ","once ready."))),b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},C.map(((e,t)=>b().createElement("div",{className:"form-field-row",key:t},b().createElement("div",{className:"form-field-description"},e.name," ",e.optional?"(optional)":""),b().createElement("input",{name:"chat-model-id-input",placeholder:e.description,className:"jp-mod-styled",spellCheck:!1,value:e.value,onChange:t=>A("chat",e.id,t.target.value)})))))))),b().createElement("div",{className:"model-config-section"},b().createElement("div",{className:"model-config-section-header"},"Auto-complete model"),b().createElement("div",{className:"model-config-section-body"},b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},b().createElement("div",null,"Provider"),b().createElement("div",null,b().createElement("select",{className:"jp-mod-styled",onChange:e=>I(e.target.value,"inline-completion")},o.map(((e,t)=>b().createElement("option",{key:t,value:e.id,selected:e.id===m},e.name))),b().createElement("option",{key:-1,value:"none",selected:"none"===m||!o.find((e=>e.id===m))},"None")))),!["openai-compatible","litellm-compatible","none"].includes(m)&&b().createElement("div",{className:"model-config-section-column"},b().createElement("div",null,"Model"),![ie,le].includes(y)&&b().createElement("div",null,b().createElement("select",{className:"jp-mod-styled",onChange:e=>k(e.target.value)},a.map(((e,t)=>b().createElement("option",{key:t,value:e.id,selected:e.id===y},e.name))))))),b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},M.map(((e,t)=>b().createElement("div",{className:"form-field-row",key:t},b().createElement("div",{className:"form-field-description"},e.name," ",e.optional?"(optional)":""),b().createElement("input",{name:"inline-completion-model-id-input",placeholder:e.description,className:"jp-mod-styled",spellCheck:!1,value:e.value,onChange:t=>A("inline-completion",e.id,t.target.value)})))))))),("github-copilot"===d||"github-copilot"===m)&&b().createElement("div",{className:"model-config-section"},b().createElement("div",{className:"model-config-section-header access-token-config-header"},"GitHub Copilot login"," ",b().createElement("a",{href:"https://github.com/notebook-intelligence/notebook-intelligence/blob/main/README.md#remembering-github-copilot-login",target:"_blank"}," ",b().createElement(F.vDk,{className:"access-token-warning",title:"Click to learn more about security implications"}))),b().createElement("div",{className:"model-config-section-body"},b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},b().createElement("label",null,b().createElement("input",{type:"checkbox",checked:N,onChange:e=>{x(e.target.checked)}}),"Remember my GitHub Copilot access token"))))),b().createElement("div",{className:"model-config-section"},b().createElement("div",{className:"model-config-section-header"},"MCP Servers [",s.length,"]"),b().createElement("div",{className:"model-config-section-body"},b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},0===s.length&&b().createElement("div",null,"No MCP servers found. Add MCP servers in the configuration file."),s.length>0&&b().createElement("div",null,s.sort().join(", "))),b().createElement("div",{className:"model-config-section-column",style:{flexGrow:"initial"}},b().createElement("button",{className:"jp-Dialog-button jp-mod-reject jp-mod-styled",onClick:async()=>{var e;const t=await O.reloadMCPServerList();r((null===(e=t.mcpServers)||void 0===e?void 0:e.map((e=>e.id)))||[])}},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Reload")))))),b().createElement("div",{className:"model-config-section"},b().createElement("div",{className:"model-config-section-header"},"Config file path"),b().createElement("div",{className:"model-config-section-body"},b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},b().createElement("span",{className:"user-code-span",onClick:()=>(navigator.clipboard.writeText(O.config.configFilePath),!0)},O.config.configFilePath," ",b().createElement("span",{className:"copy-icon",dangerouslySetInnerHTML:{__html:K}}))))))),b().createElement("div",{className:"config-dialog-footer"},b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-styled",onClick:async()=>{const t={chat_model:{provider:d,model:p,properties:C},inline_completion_model:{provider:m,model:y,properties:M}};"github-copilot"!==d&&"github-copilot"!==m||(t.store_github_access_token=N),await O.setConfig(t),e.onSave()}},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Save"))))}const Ne='<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="var(--jp-inverse-layout-color3)"><path d="M 5.398 10.807 C 5.574 10.931 5.785 10.998 6 10.997 C 6.216 10.998 6.427 10.93 6.602 10.804 C 6.78 10.674 6.915 10.494 6.989 10.286 L 7.436 8.913 C 7.551 8.569 7.744 8.256 8 7.999 C 8.257 7.743 8.569 7.549 8.913 7.434 L 10.304 6.983 C 10.456 6.929 10.594 6.84 10.706 6.724 C 10.817 6.608 10.901 6.467 10.949 6.313 C 10.998 6.159 11.01 5.996 10.985 5.837 C 10.96 5.677 10.898 5.526 10.804 5.394 C 10.67 5.208 10.479 5.071 10.26 5.003 L 8.885 4.556 C 8.541 4.442 8.228 4.249 7.971 3.993 C 7.714 3.736 7.52 3.424 7.405 3.079 L 6.953 1.691 C 6.881 1.489 6.748 1.314 6.571 1.191 C 6.439 1.098 6.286 1.036 6.125 1.012 C 5.965 0.987 5.801 1.001 5.646 1.051 C 5.492 1.101 5.351 1.187 5.236 1.301 C 5.12 1.415 5.033 1.555 4.98 1.708 L 4.523 3.108 C 4.409 3.443 4.22 3.748 3.97 3.999 C 3.721 4.25 3.418 4.441 3.083 4.557 L 1.692 5.005 C 1.541 5.06 1.404 5.149 1.292 5.265 C 1.18 5.381 1.097 5.521 1.048 5.675 C 1 5.829 0.988 5.992 1.013 6.151 C 1.038 6.31 1.099 6.462 1.192 6.593 C 1.32 6.773 1.501 6.908 1.709 6.979 L 3.083 7.424 C 3.524 7.571 3.91 7.845 4.193 8.212 C 4.356 8.423 4.481 8.66 4.564 8.912 L 5.016 10.303 C 5.088 10.507 5.222 10.683 5.398 10.807 Z M 11.535 14.849 C 11.671 14.946 11.834 14.997 12 14.997 C 12.165 14.997 12.326 14.946 12.461 14.851 C 12.601 14.753 12.706 14.613 12.761 14.451 L 13.009 13.689 C 13.063 13.531 13.152 13.387 13.269 13.268 C 13.387 13.15 13.531 13.061 13.689 13.009 L 14.461 12.757 C 14.619 12.703 14.756 12.6 14.852 12.464 C 14.926 12.361 14.974 12.242 14.992 12.117 C 15.011 11.992 14.999 11.865 14.959 11.745 C 14.918 11.625 14.85 11.516 14.76 11.428 C 14.669 11.34 14.559 11.274 14.438 11.236 L 13.674 10.987 C 13.516 10.935 13.372 10.846 13.254 10.729 C 13.136 10.611 13.047 10.467 12.994 10.309 L 12.742 9.536 C 12.689 9.379 12.586 9.242 12.449 9.146 C 12.347 9.073 12.23 9.025 12.106 9.006 C 11.982 8.987 11.855 8.998 11.736 9.037 C 11.616 9.076 11.508 9.142 11.419 9.231 C 11.33 9.319 11.264 9.427 11.224 9.546 L 10.977 10.308 C 10.925 10.466 10.838 10.61 10.721 10.728 C 10.607 10.845 10.467 10.934 10.312 10.987 L 9.539 11.239 C 9.38 11.293 9.242 11.396 9.145 11.533 C 9.047 11.669 8.995 11.833 8.996 12.001 C 8.997 12.169 9.051 12.333 9.15 12.468 C 9.249 12.604 9.388 12.705 9.547 12.757 L 10.31 13.004 C 10.469 13.058 10.614 13.147 10.732 13.265 C 10.851 13.384 10.939 13.528 10.99 13.687 L 11.243 14.461 C 11.298 14.618 11.4 14.753 11.535 14.849 Z"/></svg>\n';var xe;!function(e){e.chatuserInput="notebook-intelligence:chat-user-input",e.insertAtCursor="notebook-intelligence:insert-at-cursor",e.addCodeAsNewCell="notebook-intelligence:add-code-as-new-cell",e.createNewFile="notebook-intelligence:create-new-file",e.createNewNotebookFromPython="notebook-intelligence:create-new-notebook-from-py",e.addCodeCellToNotebook="notebook-intelligence:add-code-cell-to-notebook",e.addMarkdownCellToNotebook="notebook-intelligence:add-markdown-cell-to-notebook",e.editorGenerateCode="notebook-intelligence:editor-generate-code",e.editorExplainThisCode="notebook-intelligence:editor-explain-this-code",e.editorFixThisCode="notebook-intelligence:editor-fix-this-code",e.editorExplainThisOutput="notebook-intelligence:editor-explain-this-output",e.editorTroubleshootThisOutput="notebook-intelligence:editor-troubleshoot-this-output",e.openGitHubCopilotLoginDialog="notebook-intelligence:open-github-copilot-login-dialog",e.openConfigurationDialog="notebook-intelligence:open-configuration-dialog",e.addMarkdownCellToActiveNotebook="notebook-intelligence:add-markdown-cell-to-active-notebook",e.addCodeCellToActiveNotebook="notebook-intelligence:add-code-cell-to-active-notebook",e.deleteCellAtIndex="notebook-intelligence:delete-cell-at-index",e.insertCellAtIndex="notebook-intelligence:insert-cell-at-index",e.getCellTypeAndSource="notebook-intelligence:get-cell-type-and-source",e.setCellTypeAndSource="notebook-intelligence:set-cell-type-and-source",e.getNumberOfCells="notebook-intelligence:get-number-of-cells",e.getCellOutput="notebook-intelligence:get-cell-output",e.runCellAtIndex="notebook-intelligence:run-cell-at-index",e.getCurrentFileContent="notebook-intelligence:get-current-file-content",e.setCurrentFileContent="notebook-intelligence:set-current-file-content"}(xe||(xe={}));const Ie=new p.LabIcon({name:"notebook-intelligence:github-copilot-icon",svgstr:X}),Ae=new p.LabIcon({name:"notebook-intelligence:sparkles-icon",svgstr:Ne}),we={cells:[],metadata:{},nbformat:4,nbformat_minor:5},De="backend-telemetry-listener";class Se{static initialize(e,t){var n;Se._languageRegistry=t,null===(n=e.shell.currentChanged)||void 0===n||n.connect(((e,t)=>{Se.watchDocument(t.newValue)})),Se.activeDocumentInfo.activeWidget=e.shell.currentWidget,Se.handleWatchDocument()}static watchDocument(e){Se.activeDocumentInfo.activeWidget!==e&&(clearInterval(Se._watchTimer),Se.activeDocumentInfo.activeWidget=e,Se._watchTimer=setInterval((()=>{Se.handleWatchDocument()}),1e3),Se.handleWatchDocument())}static handleWatchDocument(){var e,t,n,o,i,l,a;const c=Se.activeDocumentInfo,s={...c,activeWidget:null},r=c.activeWidget;if(r instanceof d.NotebookPanel){const l=r;c.filename=l.sessionContext.name,c.filePath=l.sessionContext.path,c.language=(null===(o=null===(n=null===(t=null===(e=l.model)||void 0===e?void 0:e.sharedModel)||void 0===t?void 0:t.metadata)||void 0===n?void 0:n.kernelspec)||void 0===o?void 0:o.language)||"python";const{activeCellIndex:a,activeCell:s}=l.content;c.activeCellIndex=a,c.selection=null===(i=null==s?void 0:s.editor)||void 0===i?void 0:i.getSelection()}else if(r){const e=null===(l=r.context)||void 0===l?void 0:l.contentsModel;if("text"===(null==e?void 0:e.format)){const t=e.name,n=e.path,o=Se._languageRegistry.findByMIME(e.mimetype)||Se._languageRegistry.findByFileName(t);if(c.language=(null==o?void 0:o.name)||"unknown",c.filename=t,c.filePath=n,r instanceof u.FileEditorWidget){const e=r;c.selection=null===(a=e.content.editor)||void 0===a?void 0:a.getSelection()}else c.selection=void 0}else c.filename="",c.filePath="",c.language=""}Se.documentInfoChanged(s,c)&&Se.fireActiveDocumentChangedEvent()}static documentInfoChanged(e,t){return!e||!t||e.filename!==t.filename||e.filePath!==t.filePath||e.language!==t.language||e.activeCellIndex!==t.activeCellIndex||!function(e,t){return!(e&&t||!e&&!t)||e===t||$(e.start,t.start)&&$(e.end,t.end)}(e.selection,t.selection)}static getActiveSelectionContent(){var e,t;const n=Se.activeDocumentInfo.activeWidget;if(n instanceof d.NotebookPanel){const e=n,t=e.content.activeCell.editor;return H(t.getSelection())?function(e){let t="";for(const n of e.content.widgets){const e=n.model.sharedModel;"code"===e.cell_type?t+=e.source+"\n":"markdown"===e.cell_type&&(t+=V(e.source)+"\n")}return t}(e):J(t)}if(n instanceof u.FileEditorWidget){const e=n.content.editor;return H(e.getSelection())?e.model.sharedModel.getSource():J(e)}{const o=2048;return(null===(t=null===(e=null==n?void 0:n.context)||void 0===e?void 0:e.model)||void 0===t?void 0:t.toString()).substring(0,o)}}static getCurrentCellContents(){const e=Se.activeDocumentInfo.activeWidget;if(e instanceof d.NotebookPanel){const t=e,n=t.content.activeCell,o=n.model.sharedModel.source.trim();let i="";return n instanceof c.CodeCell&&(i=Y(t.content.activeCell)),{input:o,output:i}}return null}static fireActiveDocumentChangedEvent(){document.dispatchEvent(new CustomEvent("copilotSidebar:activeDocumentChanged",{detail:{activeDocumentInfo:Se.activeDocumentInfo}}))}}Se.activeDocumentInfo={language:"python",filename:"nb-doesnt-exist.ipynb",filePath:"nb-doesnt-exist.ipynb",activeWidget:null,activeCellIndex:-1,selection:null};class je{constructor(e){this._lastRequestInfo=null,this._telemetryEmitter=e}get schema(){return{default:{debouncerDelay:200,timeout:15e3}}}fetch(e,t){let n="",o="";const i=e.text.substring(0,e.offset),l=e.text.substring(e.offset);let a=Se.activeDocumentInfo.language,c="file-editor";if(t.widget instanceof d.NotebookPanel){c="notebook";const e=t.widget.content.activeCell;"markdown"===e.model.sharedModel.cell_type&&(a="markdown");let i=!1;for(const l of t.widget.content.widgets){const t=l.model.sharedModel;l===e?i=!0:i?"code"===t.cell_type?o+=t.source+"\n":"markdown"===t.cell_type&&(o+=V(t.source)+"\n"):"code"===t.cell_type?n+=t.source+"\n":"markdown"===t.cell_type&&(n+=V(t.source)+"\n")}}const s=O.config,r=s.inlineCompletionModel.provider===S?O.getLoginStatus()===_.LoggedIn:"none"!==s.inlineCompletionModel.provider;return this._telemetryEmitter.emitTelemetryEvent({type:j.InlineCompletionRequest,data:{inlineCompletionModel:{provider:O.config.inlineCompletionModel.provider,model:O.config.inlineCompletionModel.model},editorType:c}}),new Promise(((e,t)=>{const c=[];if(!r)return void e({items:c});this._lastRequestInfo&&O.sendWebSocketMessage(this._lastRequestInfo.messageId,N.CancelInlineCompletionRequest,{chatId:this._lastRequestInfo.chatId});const s=M.UUID.uuid4(),d=M.UUID.uuid4();this._lastRequestInfo={chatId:d,messageId:s,requestTime:new Date},O.inlineCompletionsRequest(d,s,n+i,l+o,a,Se.activeDocumentInfo.filename,{emit:n=>{if(n.type===x.StreamMessage&&n.id===this._lastRequestInfo.messageId){c.push({insertText:n.data.completions});const t=((new Date).getTime()-this._lastRequestInfo.requestTime.getTime())/1e3;this._telemetryEmitter.emitTelemetryEvent({type:j.InlineCompletionResponse,data:{inlineCompletionModel:{provider:O.config.inlineCompletionModel.provider,model:O.config.inlineCompletionModel.model},timeElapsed:t}}),e({items:c})}else t()}})}))}get name(){return"Notebook Intelligence"}get identifier(){return"@notebook-intelligence/notebook-intelligence"}get icon(){return O.config.usingGitHubCopilotModel?Ie:Ae}}class Te{constructor(){this._listeners=new Set}registerTelemetryListener(e){const t=e.name;t!==De&&console.warn(`Notebook Intelligence telemetry listener '${t}' registered. Make sure it is from a trusted source.`);let n=!1;this._listeners.forEach((e=>{e.name===t&&(n=!0)})),n?console.error(`Notebook Intelligence telemetry listener '${t}' already exists!`):this._listeners.add(e)}unregisterTelemetryListener(e){this._listeners.delete(e)}emitTelemetryEvent(e){this._listeners.forEach((t=>{t.onTelemetryEvent(e)}))}}const Le={id:"@notebook-intelligence/notebook-intelligence:plugin",description:"Notebook Intelligence",autoStart:!0,requires:[r.ICompletionProviderManager,o.IDocumentManager,m.IDefaultFileBrowser,a.IEditorLanguageRegistry,i.ICommandPalette,l.IMainMenu],optional:[s.ISettingRegistry,f.IStatusBar],provides:T,activate:async(e,t,n,o,l,a,s,r,m)=>{console.log("JupyterLab extension @notebook-intelligence/notebook-intelligence is activated!");const f=new Te;f.registerTelemetryListener({name:De,onTelemetryEvent:e=>{O.emitTelemetryEvent(e)}});const v={registerTelemetryListener:e=>{f.registerTelemetryListener(e)},unregisterTelemetryListener:e=>{f.unregisterTelemetryListener(e)}};await O.initialize();let b=null;t.registerInlineProvider(new je(f)),r&&r.load(Le.id).then((e=>{})).catch((e=>{console.error("Failed to load settings for @notebook-intelligence/notebook-intelligence.",e)}));const M=async t=>{const n=t.endsWith(".ipynb");return new Promise(((o,i)=>{const l=()=>{const i=Se.activeDocumentInfo.filePath,a=t,c=e.shell.currentWidget;i===a&&(n&&c instanceof d.NotebookPanel&&c.content.activeCell&&c.content.activeCell.node.contains(document.activeElement)||!n&&c instanceof u.FileEditorWidget&&c.content.editor.hasFocus())?o(!0):setTimeout(l,200)};l(),async function(){return new Promise((e=>{setTimeout((()=>{e()}),1e4)}))}().then((()=>{o(!1)}))}))},E=new h.Panel;E.id="notebook-intelligence-tab",E.title.caption="Notebook Intelligence";const y=new p.LabIcon({name:"ui-components:palette",svgstr:Ne});E.title.icon=y;const k=new ce({getActiveDocumentInfo:()=>Se.activeDocumentInfo,getActiveSelectionContent:()=>Se.getActiveSelectionContent(),getCurrentCellContents:()=>Se.getCurrentCellContents(),openFile:e=>{n.openOrReveal(e)},getApp:()=>e,getTelemetryEmitter:()=>f});E.addWidget(k),e.shell.add(E,"left",{rank:1e3}),e.shell.activateById(E.id),e.commands.addCommand(xe.chatuserInput,{execute:e=>{O.sendChatUserInput(e.id,e.data)}}),e.commands.addCommand(xe.insertAtCursor,{execute:t=>{const n=e.shell.currentWidget;if(n instanceof d.NotebookPanel){const e=n.content.activeCell;if(e)return void B(e.editor,t.code)}else if(n instanceof u.FileEditorWidget)return void B(n.content.editor,t.code);e.commands.execute("apputils:notify",{message:"Failed to insert at cursor. Open a notebook or file to insert the code.",type:"error",options:{autoClose:!0}})}}),e.commands.addCommand(xe.addCodeAsNewCell,{execute:t=>{var n;const o=e.shell.currentWidget;if(o instanceof d.NotebookPanel){let e=o.content.activeCellIndex;e=-1===e?o.content.widgets.length:e+1,null===(n=o.model)||void 0===n||n.sharedModel.insertCell(e,{cell_type:"code",metadata:{trusted:!0},source:t.code}),o.content.activeCellIndex=e}else e.commands.execute("apputils:notify",{message:"Open a notebook to insert the code as new cell",type:"error",options:{autoClose:!0}})}}),e.commands.addCommand(xe.createNewFile,{execute:async e=>{const t=new g.ContentsManager,i=await t.newUntitled({ext:".py",path:null==o?void 0:o.model.path});return t.save(i.path,{content:Q(e.code),format:"text",type:"file"}),n.openOrReveal(i.path),await M(i.path),i}}),e.commands.addCommand(xe.createNewNotebookFromPython,{execute:async e=>{var t;let i=null;const l=new g.ContentsManager,a=new g.KernelSpecManager;await a.ready;const c=null===(t=a.specs)||void 0===t?void 0:t.kernelspecs;if(c)for(const e in c){const t=c[e];if("python"===(null==t?void 0:t.language)){i=t;break}}const s=await l.newUntitled({ext:".ipynb",path:null==o?void 0:o.model.path}),r=structuredClone(we);return i&&(r.metadata={kernelspec:{language:"python",name:i.name,display_name:i.display_name}}),e.code&&r.cells.push({cell_type:"code",metadata:{trusted:!0},source:[e.code],outputs:[]}),l.save(s.path,{content:r,format:"json",type:"notebook"}),n.openOrReveal(s.path),await M(s.path),s}});const N=e=>1===e.cells.length&&"code"===e.cells[0].cell_type&&""===e.cells[0].source,x=()=>O.config.chatModel.provider===S?!(O.config.usingGitHubCopilotModel&&O.getLoginStatus()===_.NotLoggedIn):"none"!==O.config.chatModel.provider,I=()=>e.shell.currentWidget instanceof d.NotebookPanel&&e.shell.currentWidget.content.activeCell instanceof c.CodeCell,A=(t,n,o)=>{const i=e.shell.currentWidget;if(!(i instanceof d.NotebookPanel&&i.sessionContext.path===t&&i.model))return e.commands.execute("apputils:notify",{message:`Failed to access the notebook: ${t}`,type:"error",options:{autoClose:!0}}),!1;const l=i.model.sharedModel,a=N(l)?0:l.cells.length-1;return l.insertCell(a,{cell_type:n,metadata:{trusted:!0},source:o}),!0};e.commands.addCommand(xe.addCodeCellToNotebook,{execute:e=>A(e.path,"code",e.code)}),e.commands.addCommand(xe.addMarkdownCellToNotebook,{execute:e=>A(e.path,"markdown",e.markdown)});const w=()=>{const t=e.shell.currentWidget;return!!(t instanceof d.NotebookPanel&&t.model)||(e.commands.execute("apputils:notify",{message:"Failed to find active notebook",type:"error",options:{autoClose:!0}}),!1)},D=()=>!!(e.shell.currentWidget instanceof u.FileEditorWidget)||(e.commands.execute("apputils:notify",{message:"Failed to find active file",type:"error",options:{autoClose:!0}}),!1);e.commands.addCommand(xe.addMarkdownCellToActiveNotebook,{execute:t=>{if(!w())return!1;const n=e.shell.currentWidget.model.sharedModel,o=N(n)?0:n.cells.length-1;return n.insertCell(o,{cell_type:"markdown",metadata:{trusted:!0},source:t.source}),!0}}),e.commands.addCommand(xe.addCodeCellToActiveNotebook,{execute:t=>{if(!w())return!1;const n=e.shell.currentWidget.model.sharedModel,o=N(n)?0:n.cells.length-1;return n.insertCell(o,{cell_type:"code",metadata:{trusted:!0},source:t.source}),!0}}),e.commands.addCommand(xe.getCellTypeAndSource,{execute:t=>{if(!w())return!1;const n=e.shell.currentWidget.model.sharedModel;return{type:n.cells[t.cellIndex].cell_type,source:n.cells[t.cellIndex].source}}}),e.commands.addCommand(xe.setCellTypeAndSource,{execute:t=>{if(!w())return!1;const n=e.shell.currentWidget.model.sharedModel,o=t.cellIndex,i=t.cellType,l=n.getCell(o);return n.deleteCell(o),n.insertCell(o,{cell_type:i,metadata:l.metadata,source:t.source}),!0}}),e.commands.addCommand(xe.getNumberOfCells,{execute:t=>!!w()&&e.shell.currentWidget.model.sharedModel.cells.length}),e.commands.addCommand(xe.getCellOutput,{execute:t=>{if(!w())return!1;const n=e.shell.currentWidget,o=t.cellIndex,i=n.content.widgets[o];return i instanceof c.CodeCell?Y(i):""}}),e.commands.addCommand(xe.insertCellAtIndex,{execute:t=>{if(!w())return!1;const n=e.shell.currentWidget.model.sharedModel,o=t.cellIndex,i=t.cellType;return n.insertCell(o,{cell_type:i,metadata:{trusted:!0},source:t.source}),!0}}),e.commands.addCommand(xe.deleteCellAtIndex,{execute:t=>{if(!w())return!1;const n=e.shell.currentWidget.model.sharedModel,o=t.cellIndex;return n.deleteCell(o),!0}}),e.commands.addCommand(xe.runCellAtIndex,{execute:async t=>{if(!w())return!1;e.shell.currentWidget.content.activeCellIndex=t.cellIndex,await e.commands.execute("notebook:run-cell")}}),e.commands.addCommand(xe.getCurrentFileContent,{execute:async t=>!!D()&&e.shell.currentWidget.content.editor.model.sharedModel.getSource()}),e.commands.addCommand(xe.setCurrentFileContent,{execute:async t=>{if(!D())return!1;const n=e.shell.currentWidget.content.editor;return n.model.sharedModel.setSource(t.content),n.model.sharedModel.getSource()}}),e.commands.addCommand(xe.openGitHubCopilotLoginDialog,{execute:e=>{let t=null;const n=new de({onLoggedIn:()=>null==t?void 0:t.dispose()});t=new i.Dialog({title:"GitHub Copilot Status",hasClose:!0,body:n,buttons:[]}),t.launch()}}),e.commands.addCommand(xe.openConfigurationDialog,{label:"Notebook Intelligence Settings",execute:e=>{let t=null;const n=new ue({onSave:()=>{null==t||t.dispose(),O.fetchCapabilities()}});t=new i.Dialog({title:"Notebook Intelligence Settings",hasClose:!0,body:n,buttons:[]}),t.node.classList.add("config-dialog-container"),t.launch()}}),a.addItem({command:xe.openConfigurationDialog,category:"Notebook Intelligence"}),s.settingsMenu.addGroup([{command:xe.openConfigurationDialog}]);const T={execute:t=>{(()=>{const t=I(),n=e.shell.currentWidget;let o,i=null,l=null;if(t){const e=n,t=e.content.activeCell;if(i=t.node.querySelector(".jp-InputArea-editor"),!i)return;l=e.node.querySelector(".jp-WindowedPanel-outer"),o=t.editor}else{const e=n;i=e.node,l=e.node.querySelector(".cm-scroller"),o=e.content.editor}const a=()=>{const e=o.getSelection(),n=Math.min(e.end.line+1,o.lineCount-1),l=o.getCoordinateForPosition({line:n,column:e.end.column}),a=i.getBoundingClientRect();if(!l)return a;let c=l.top-30;const s=l.bottom-l.top;return t||c+s+300>a.bottom&&(c=a.bottom-s-300,c<a.top&&(c=a.top)),new DOMRect(a.left,c,a.right-a.left,s)},c=a(),s=()=>{if(null!==b){const e=a();b.updatePosition(e)}},r=new ResizeObserver(s),m=()=>{null!==b&&(r.unobserve(i),l&&l.removeEventListener("scroll",s),b=null,h.Widget.detach(A)),t&&(null==i||i.classList.remove("generating"))};let g="",p="",C="",v="",M="";if(t){const t=(()=>{let t="",n="";const o=e.shell.currentWidget;if(!(o instanceof d.NotebookPanel&&o.content.activeCell))return{prefix:t,suffix:n};const i=o.content.activeCellIndex,l=o.content.widgets.length;for(let e=1;e<l;++e){const c=i-e,s=i+e;if(c<0&&s>=l||(a=`${t} ${n}`,q.encode(a).length>=2867.2))break;if(c>=0){const e=o.content.widgets[c].model.sharedModel;"code"===e.cell_type?t=e.source+"\n"+t:"markdown"===e.cell_type&&(t=V(e.source)+"\n"+t)}if(s<l){const e=o.content.widgets[s].model.sharedModel;"code"===e.cell_type?n+=e.source+"\n":"markdown"===e.cell_type&&(n+=V(e.source)+"\n")}}var a;return{prefix:t,suffix:n}})();v=t.prefix,M=t.suffix}else{const t=(()=>{let t="",n="";const o=e.shell.currentWidget;if(!(o instanceof u.FileEditorWidget))return{prefix:t,suffix:n};const i=o,l=i.content.editor.getCursorPosition(),a=i.content.editor.getOffsetAt(l),c=i.content.editor.model.sharedModel.getSource();return t=c.substring(0,a),n=c.substring(a),{prefix:t,suffix:n}})();v=t.prefix,M=t.suffix}const E=o.getSelection(),y=o.getOffsetAt(E.start),k=o.getOffsetAt(E.end),N=o.model.sharedModel.getSource();t?(v+="\n"+N.substring(0,y),p=N.substring(y,k),M=N.substring(k)+"\n"+M):p=N.substring(y,k);const x=()=>{C=Q(C),B(o,C),C="",m()};m();const A=new se(c,{prompt:g,existingCode:p,prefix:v,suffix:M,onRequestSubmitted:e=>{g=e,C="",""===p&&(m(),t&&(null==i||i.classList.add("generating")))},onRequestCancelled:()=>{m(),o.focus()},onContentStream:e=>{""===p&&(C+=e)},onContentStreamEnd:()=>{""===p&&(x(),o.focus())},onUpdatedCodeChange:e=>{C=e},onUpdatedCodeAccepted:()=>{x(),o.focus()},telemetryEmitter:f});b=A,r.observe(i),l&&l.addEventListener("scroll",s),h.Widget.attach(A,document.body),f.emitTelemetryEvent({type:j.GenerateCodeRequest,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model},editorType:t?"notebook":"file-editor"}})})()},label:"Generate code",isEnabled:()=>x()&&(I()||e.shell.currentWidget instanceof u.FileEditorWidget)};e.commands.addCommand(xe.editorGenerateCode,T);const L=new C.CommandRegistry;L.addCommand(xe.editorGenerateCode,T),L.addCommand(xe.editorExplainThisCode,{execute:()=>{const t=e.shell.currentWidget.content.activeCell,n=(null==t?void 0:t.model.sharedModel.source)||"";document.dispatchEvent(new CustomEvent("copilotSidebar:runPrompt",{detail:{type:ae.ExplainThis,content:n,language:Se.activeDocumentInfo.language,filename:Se.activeDocumentInfo.filename}})),e.commands.execute("tabsmenu:activate-by-id",{id:E.id}),f.emitTelemetryEvent({type:j.ExplainThisRequest,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model}}})},label:"Explain code",isEnabled:()=>x()&&I()}),L.addCommand(xe.editorFixThisCode,{execute:()=>{const t=e.shell.currentWidget.content.activeCell,n=(null==t?void 0:t.model.sharedModel.source)||"";document.dispatchEvent(new CustomEvent("copilotSidebar:runPrompt",{detail:{type:ae.FixThis,content:n,language:Se.activeDocumentInfo.language,filename:Se.activeDocumentInfo.filename}})),e.commands.execute("tabsmenu:activate-by-id",{id:E.id}),f.emitTelemetryEvent({type:j.FixThisCodeRequest,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model}}})},label:"Fix code",isEnabled:()=>x()&&I()}),L.addCommand(xe.editorExplainThisOutput,{execute:()=>{const t=e.shell.currentWidget.content.activeCell;if(!(t instanceof c.CodeCell))return;const n=Y(t);document.dispatchEvent(new CustomEvent("copilotSidebar:runPrompt",{detail:{type:ae.ExplainThisOutput,content:n,language:Se.activeDocumentInfo.language,filename:Se.activeDocumentInfo.filename}})),e.commands.execute("tabsmenu:activate-by-id",{id:E.id}),f.emitTelemetryEvent({type:j.ExplainThisOutputRequest,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model}}})},label:"Explain output",isEnabled:()=>{if(!(x()&&e.shell.currentWidget instanceof d.NotebookPanel))return!1;const t=e.shell.currentWidget.content.activeCell;if(!(t instanceof c.CodeCell))return!1;const n=t.outputArea.model.toJSON();return Array.isArray(n)&&n.length>0}}),L.addCommand(xe.editorTroubleshootThisOutput,{execute:()=>{const t=e.shell.currentWidget.content.activeCell;if(!(t instanceof c.CodeCell))return;const n=Y(t);document.dispatchEvent(new CustomEvent("copilotSidebar:runPrompt",{detail:{type:ae.TroubleshootThisOutput,content:n,language:Se.activeDocumentInfo.language,filename:Se.activeDocumentInfo.filename}})),e.commands.execute("tabsmenu:activate-by-id",{id:E.id}),f.emitTelemetryEvent({type:j.TroubleshootThisOutputRequest,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model}}})},label:"Troubleshoot errors in output",isEnabled:()=>{if(!(x()&&e.shell.currentWidget instanceof d.NotebookPanel))return!1;const t=e.shell.currentWidget.content.activeCell;if(!(t instanceof c.CodeCell))return!1;const n=t.outputArea.model.toJSON();return Array.isArray(n)&&n.length>0&&n.some((e=>"error"===e.output_type))}});const R=new h.Menu({commands:L});if(R.id="notebook-intelligence:editor-context-menu",R.title.label="Notebook Intelligence",R.title.icon=y,R.addItem({command:xe.editorGenerateCode}),R.addItem({command:xe.editorExplainThisCode}),R.addItem({command:xe.editorFixThisCode}),R.addItem({command:xe.editorExplainThisOutput}),R.addItem({command:xe.editorTroubleshootThisOutput}),e.contextMenu.addItem({type:"submenu",submenu:R,selector:".jp-Editor",rank:1}),e.contextMenu.addItem({type:"submenu",submenu:R,selector:".jp-OutputArea-child",rank:1}),m){const t=new re({getApp:()=>e});m.registerStatusItem("notebook-intelligence:github-copilot-status",{item:t,align:"right",rank:100,isActive:()=>O.config.usingGitHubCopilotModel}),O.configChanged.connect((()=>{O.config.usingGitHubCopilotModel?t.show():t.hide()}))}const W=e;return Se.initialize(W,l),v}},_e=Le},68968:e=>{e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa/1AAAAHUlEQVQYV2PYvXu3JAi7uLiAMaYAjAGTQBPYLQkAa/0Zef3qRswAAAAASUVORK5CYII="},3552:e=>{e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAAL0lEQVQoz2NgCD3x//9/BhBYBWdhgFVAiVW4JBFKGIa4AqD0//9D3pt4I4tAdAMAHTQ/j5Zom30AAAAASUVORK5CYII="},62974:e=>{e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAAz0lEQVRIx2NgYGBY/R8I/vx5eelX3n82IJ9FxGf6tksvf/8FiTMQAcAGQMDvSwu09abffY8QYSAScNk45G198eX//yev73/4///701eh//kZSARckrNBRvz//+8+6ZohwCzjGNjdgQxkAg7B9WADeBjIBqtJCbhRA0YNoIkBSNmaPEMoNmA0FkYNoFKhapJ6FGyAH3nauaSmPfwI0v/3OukVi0CIZ+F25KrtYcx/CTIy0e+rC7R1Z4KMICVTQQ14feVXIbR695u14+Ir4gwAAD49E54wc1kWAAAAAElFTkSuQmCC"},54676:e=>{e.exports="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTMiIGhlaWdodD0iMzYiIHZpZXdCb3g9IjAgMCA1MyAzNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiPg0KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00OC4wMzY0IDQuMDEwNDJINC4wMDc3OUw0LjAwNzc5IDMyLjAyODZINDguMDM2NFY0LjAxMDQyWk00LjAwNzc5IDAuMDA3ODEyNUMxLjc5NzIxIDAuMDA3ODEyNSAwLjAwNTE4Nzk5IDEuNzk5ODQgMC4wMDUxODc5OSA0LjAxMDQyVjMyLjAyODZDMC4wMDUxODc5OSAzNC4yMzkyIDEuNzk3MjEgMzYuMDMxMiA0LjAwNzc5IDM2LjAzMTJINDguMDM2NEM1MC4yNDcgMzYuMDMxMiA1Mi4wMzkgMzQuMjM5MiA1Mi4wMzkgMzIuMDI4NlY0LjAxMDQyQzUyLjAzOSAxLjc5OTg0IDUwLjI0NyAwLjAwNzgxMjUgNDguMDM2NCAwLjAwNzgxMjVINC4wMDc3OVpNOC4wMTA0MiA4LjAxMzAySDEyLjAxM1YxMi4wMTU2SDguMDEwNDJWOC4wMTMwMlpNMjAuMDE4MiA4LjAxMzAySDE2LjAxNTZWMTIuMDE1NkgyMC4wMTgyVjguMDEzMDJaTTI0LjAyMDggOC4wMTMwMkgyOC4wMjM0VjEyLjAxNTZIMjQuMDIwOFY4LjAxMzAyWk0zNi4wMjg2IDguMDEzMDJIMzIuMDI2VjEyLjAxNTZIMzYuMDI4NlY4LjAxMzAyWk00MC4wMzEyIDguMDEzMDJINDQuMDMzOVYxMi4wMTU2SDQwLjAzMTJWOC4wMTMwMlpNMTYuMDE1NiAxNi4wMTgySDguMDEwNDJWMjAuMDIwOEgxNi4wMTU2VjE2LjAxODJaTTIwLjAxODIgMTYuMDE4MkgyNC4wMjA4VjIwLjAyMDhIMjAuMDE4MlYxNi4wMTgyWk0zMi4wMjYgMTYuMDE4MkgyOC4wMjM0VjIwLjAyMDhIMzIuMDI2VjE2LjAxODJaTTQ0LjAzMzkgMTYuMDE4MlYyMC4wMjA4SDM2LjAyODZWMTYuMDE4Mkg0NC4wMzM5Wk0xMi4wMTMgMjQuMDIzNEg4LjAxMDQyVjI4LjAyNkgxMi4wMTNWMjQuMDIzNFpNMTYuMDE1NiAyNC4wMjM0SDM2LjAyODZWMjguMDI2SDE2LjAxNTZWMjQuMDIzNFpNNDQuMDMzOSAyNC4wMjM0SDQwLjAzMTJWMjguMDI2SDQ0LjAzMzlWMjQuMDIzNFoiIGZpbGw9IiM0MjQyNDIiLz4NCjwvZz4NCjxkZWZzPg0KPGNsaXBQYXRoIGlkPSJjbGlwMCI+DQo8cmVjdCB3aWR0aD0iNTMiIGhlaWdodD0iMzYiIGZpbGw9IndoaXRlIi8+DQo8L2NsaXBQYXRoPg0KPC9kZWZzPg0KPC9zdmc+DQo="},51240:e=>{e.exports="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTMiIGhlaWdodD0iMzYiIHZpZXdCb3g9IjAgMCA1MyAzNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiPg0KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00OC4wMzY0IDQuMDEwNDJINC4wMDc3OUw0LjAwNzc5IDMyLjAyODZINDguMDM2NFY0LjAxMDQyWk00LjAwNzc5IDAuMDA3ODEyNUMxLjc5NzIxIDAuMDA3ODEyNSAwLjAwNTE4Nzk5IDEuNzk5ODQgMC4wMDUxODc5OSA0LjAxMDQyVjMyLjAyODZDMC4wMDUxODc5OSAzNC4yMzkyIDEuNzk3MjEgMzYuMDMxMiA0LjAwNzc5IDM2LjAzMTJINDguMDM2NEM1MC4yNDcgMzYuMDMxMiA1Mi4wMzkgMzQuMjM5MiA1Mi4wMzkgMzIuMDI4NlY0LjAxMDQyQzUyLjAzOSAxLjc5OTg0IDUwLjI0NyAwLjAwNzgxMjUgNDguMDM2NCAwLjAwNzgxMjVINC4wMDc3OVpNOC4wMTA0MiA4LjAxMzAySDEyLjAxM1YxMi4wMTU2SDguMDEwNDJWOC4wMTMwMlpNMjAuMDE4MiA4LjAxMzAySDE2LjAxNTZWMTIuMDE1NkgyMC4wMTgyVjguMDEzMDJaTTI0LjAyMDggOC4wMTMwMkgyOC4wMjM0VjEyLjAxNTZIMjQuMDIwOFY4LjAxMzAyWk0zNi4wMjg2IDguMDEzMDJIMzIuMDI2VjEyLjAxNTZIMzYuMDI4NlY4LjAxMzAyWk00MC4wMzEyIDguMDEzMDJINDQuMDMzOVYxMi4wMTU2SDQwLjAzMTJWOC4wMTMwMlpNMTYuMDE1NiAxNi4wMTgySDguMDEwNDJWMjAuMDIwOEgxNi4wMTU2VjE2LjAxODJaTTIwLjAxODIgMTYuMDE4MkgyNC4wMjA4VjIwLjAyMDhIMjAuMDE4MlYxNi4wMTgyWk0zMi4wMjYgMTYuMDE4MkgyOC4wMjM0VjIwLjAyMDhIMzIuMDI2VjE2LjAxODJaTTQ0LjAzMzkgMTYuMDE4MlYyMC4wMjA4SDM2LjAyODZWMTYuMDE4Mkg0NC4wMzM5Wk0xMi4wMTMgMjQuMDIzNEg4LjAxMDQyVjI4LjAyNkgxMi4wMTNWMjQuMDIzNFpNMTYuMDE1NiAyNC4wMjM0SDM2LjAyODZWMjguMDI2SDE2LjAxNTZWMjQuMDIzNFpNNDQuMDMzOSAyNC4wMjM0SDQwLjAzMTJWMjguMDI2SDQ0LjAzMzlWMjQuMDIzNFoiIGZpbGw9IiNDNUM1QzUiLz4NCjwvZz4NCjxkZWZzPg0KPGNsaXBQYXRoIGlkPSJjbGlwMCI+DQo8cmVjdCB3aWR0aD0iNTMiIGhlaWdodD0iMzYiIGZpbGw9IndoaXRlIi8+DQo8L2NsaXBQYXRoPg0KPC9kZWZzPg0KPC9zdmc+DQo="}}]);
|