"use strict";(self.rspackChunk_JUPYTERLAB_CORE_OUTPUT=self.rspackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[1774],{77965(e,t,o){o.r(t),o.d(t,{default:()=>k});var n=o(66811),r=o(28122),i=o(41301),a=o(17281),s=o(5313),l=o(99777),d=o(15701),c=o(43318),p=o(45136);let u={id:"@jupyter-notebook/console-extension:opener",requires:[n.IRouter],autoStart:!0,description:"A plugin to open consoles in a new tab",activate:(e,t)=>{let{commands:o}=e,n=RegExp("/consoles/(.*)"),r="router:console";o.addCommand(r,{execute:e=>{let t=e.path.match(n);if(!t)return;let[,r]=t;if(!r)return;let i=decodeURIComponent(r);o.execute("console:create",{path:i})},describedBy:{args:{type:"object",properties:{path:{type:"string",description:"The routed URL path to handle."}},required:["path"]}}}),t.register({command:r,pattern:n})}},h={id:"@jupyter-notebook/console-extension:redirect",requires:[i.IConsoleTracker],optional:[c.INotebookPathOpener,c.INotebookShell,s.INotebookTracker],autoStart:!0,description:"Open consoles in a new tab",activate:(e,t,o,n,r)=>{let i=a.PageConfig.getBaseUrl(),s=null!=o?o:c.defaultNotebookPathOpener;t.widgetAdded.connect(async(t,o)=>{var l,d,c,u;if(n&&r){let e=r.currentWidget;if(await Promise.all([null==e?void 0:e.sessionContext.ready,o.sessionContext.ready]),(null==(d=null==(l=null==e?void 0:e.sessionContext.session)?void 0:l.kernel)?void 0:d.id)===(null==(u=null==(c=o.sessionContext.session)?void 0:c.kernel)?void 0:u.id)){n.add(o,"right"),n.expandRight(o.id);return}}let{sessionContext:h}=o;await h.ready,(0,p.find)(e.shell.widgets("main"),e=>e.id===o.id)||(s.open({prefix:a.URLExt.join(i,"consoles"),path:h.path,target:"_blank"}),o.dispose())})}},g={id:"@jupyter-notebook/console-extension:scratchpad-console",requires:[s.INotebookTracker],optional:[c.INotebookShell,r.ICommandPalette,l.ITranslator],autoStart:!0,description:"Open scratchpad console in side panel",activate:(e,t,o,n,r)=>{let{commands:i}=e,a=e.serviceManager,s=(null!=r?r:l.nullTranslator).load("notebook"),c="scratchpad-console:open";i.addCommand(c,{label:e=>e.isPalette?s.__("Open a scratchpad console"):s.__("Scratchpad console"),isVisible:()=>!!t.currentWidget,icon:e=>e.isPalette?void 0:d.consoleIcon,execute:async e=>{var n,r,l,d;if(!o)return;let c=g.id,p=o.rightHandler;if(p.isVisible&&(null==(n=p.currentWidget)?void 0:n.id)===c){e.isPalette||e.isMenu||(o.collapseRight(),null==(r=o.currentWidget)||r.activate());return}let u=p.widgets.find(e=>e.id===c);if(u)o.expandRight(c);else{let e=t.currentWidget;if(!e)return;let o=e.sessionContext;await Promise.all([o.ready,a.ready]);let n=null==(d=null==(l=o.session)?void 0:l.kernel)?void 0:d.id,r=o.kernelPreference;if(!(u=await i.execute("console:create",{kernelPreference:{...r,id:n},preventTitleUpdate:!0})))return void console.error("An error occurred during scratchpad console creation");u.title.caption=s.__("Console"),u.id=c}},describedBy:{args:{type:"object",properties:{isPalette:{type:"boolean",description:s.__("Whether the command is executed from the palette")},isMenu:{type:"boolean",description:s.__("Whether the command is executed from the menu")}}}}}),n&&n.addItem({category:"Notebook Console",command:c,args:{isPalette:!0}})}},k=[u,h,g]}}]);