@datalayer/agent-runtimes 1.5.53 → 1.5.55
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.
- package/dist-embed/chunks/ChatView-D4hFmYbm.js +32 -0
- package/dist-embed/chunks/{DeckComponent-C7AztSPA.js → DeckComponent-y0KZOMsH.js} +1 -1
- package/dist-embed/chunks/{DocumentView-DwpK2feQ.js → DocumentView-BKeO-v4k.js} +1 -1
- package/dist-embed/chunks/{EphemeralDocument-rusBlgBp.js → EphemeralDocument-BvbG68Jm.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawComponent-Qv9LHutW.js → ExcalidrawComponent-DeNgg0ms.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawModal-D6Mb9nmf.js → ExcalidrawModal-X6Yh6FKI.js} +1 -1
- package/dist-embed/chunks/{JupyterLexicalExtension-r47Jyrrd.js → JupyterLexicalExtension-Ght2bbbp.js} +5 -5
- package/dist-embed/chunks/{YouTubePlugin-4pUBJORX.js → YouTubePlugin-BnaV5Sxl.js} +1 -1
- package/dist-embed/chunks/{ar-SA-G6X2FPQ2-CD4X_3wm.js → ar-SA-G6X2FPQ2-DFML-KO4.js} +1 -1
- package/dist-embed/chunks/{az-AZ-76LH7QW2-oMbKQcB-.js → az-AZ-76LH7QW2-DTzTpRpk.js} +1 -1
- package/dist-embed/chunks/{bg-BG-XCXSNQG7-lSIB5dDU.js → bg-BG-XCXSNQG7-DMTmzgtc.js} +1 -1
- package/dist-embed/chunks/{bn-BD-2XOGV67Q-B5PkHAFO.js → bn-BD-2XOGV67Q-D1xy-Djm.js} +1 -1
- package/dist-embed/chunks/{ca-ES-6MX7JW3Y-BPeavtUl.js → ca-ES-6MX7JW3Y-hTO_csy7.js} +1 -1
- package/dist-embed/chunks/{cs-CZ-2BRQDIVT-DrBOFpi4.js → cs-CZ-2BRQDIVT-DBcXv81g.js} +1 -1
- package/dist-embed/chunks/{da-DK-5WZEPLOC-G5bUTE3Z.js → da-DK-5WZEPLOC-Rp51nhJX.js} +1 -1
- package/dist-embed/chunks/{de-DE-XR44H4JA-Drpt3qDZ.js → de-DE-XR44H4JA-DIgLamrP.js} +1 -1
- package/dist-embed/chunks/{el-GR-BZB4AONW-D4taPxaF.js → el-GR-BZB4AONW-XWt7TL7f.js} +1 -1
- package/dist-embed/chunks/{es-ES-U4NZUMDT-BvIGVphk.js → es-ES-U4NZUMDT-Bh1eks-u.js} +1 -1
- package/dist-embed/chunks/{eu-ES-A7QVB2H4-B8nvrNDk.js → eu-ES-A7QVB2H4-Bslg2HDc.js} +1 -1
- package/dist-embed/chunks/{fa-IR-HGAKTJCU-hwisHoU4.js → fa-IR-HGAKTJCU-9fGOejth.js} +1 -1
- package/dist-embed/chunks/{fi-FI-Z5N7JZ37-DKrDvTXs.js → fi-FI-Z5N7JZ37-DctXrD-R.js} +1 -1
- package/dist-embed/chunks/{fr-FR-RHASNOE6-DPtlBK_j.js → fr-FR-RHASNOE6-PUSl_g5c.js} +1 -1
- package/dist-embed/chunks/{gl-ES-HMX3MZ6V-B1ngwQkd.js → gl-ES-HMX3MZ6V-C5hGec18.js} +1 -1
- package/dist-embed/chunks/{he-IL-6SHJWFNN-BaoAQZ3f.js → he-IL-6SHJWFNN-rdU3Uatf.js} +1 -1
- package/dist-embed/chunks/{hi-IN-IWLTKZ5I-DzPeRmLM.js → hi-IN-IWLTKZ5I-CbVBP2OS.js} +1 -1
- package/dist-embed/chunks/{hu-HU-A5ZG7DT2-BgLcm8oA.js → hu-HU-A5ZG7DT2-BqNM3HXj.js} +1 -1
- package/dist-embed/chunks/{id-ID-SAP4L64H-egIA8l8_.js → id-ID-SAP4L64H-Z7074d-A.js} +1 -1
- package/dist-embed/chunks/{index-cYM4KfdD.js → index-2ciQBsIP.js} +1 -1
- package/dist-embed/chunks/{index-CkQ6IAoY.js → index-BIbnsdGY.js} +1 -1
- package/dist-embed/chunks/{index-Z2pxzg3H.js → index-BP84Dsqq.js} +1 -1
- package/dist-embed/chunks/{index-BzMt3uYX.js → index-BdQdhGo5.js} +1 -1
- package/dist-embed/chunks/{index-BKB97UwL.js → index-BpX_2Evh.js} +1 -1
- package/dist-embed/chunks/{index-CEbnhuIo.js → index-BrPjTG8-.js} +1 -1
- package/dist-embed/chunks/{index-Di3aBGLV.js → index-CAPuT1O_.js} +1 -1
- package/dist-embed/chunks/{index-5N0EOEHV.js → index-CC3OzP1C.js} +1 -1
- package/dist-embed/chunks/{index-D9_026K2.js → index-COWwWw7v.js} +1 -1
- package/dist-embed/chunks/{index-BTdq_niO.js → index-C_IEokTU.js} +1 -1
- package/dist-embed/chunks/{index-_H5U6gal.js → index-CalzGdbU.js} +1 -1
- package/dist-embed/chunks/{index-DVaPKQyL.js → index-CynaHotU.js} +1 -1
- package/dist-embed/chunks/{index-Cd5CgKFr.js → index-D4zET-qQ.js} +1 -1
- package/dist-embed/chunks/{index-BKOQQ5Ku.js → index-DJq5Nwi9.js} +1 -1
- package/dist-embed/chunks/{index-CZB8DyUw.js → index-Dx_VgK3b.js} +1 -1
- package/dist-embed/chunks/{index-BN8Bbau-.js → index-Dzf9vro3.js} +2 -2
- package/dist-embed/chunks/{index-DWfzdTZo.js → index-IGJ-OsCO.js} +1 -1
- package/dist-embed/chunks/{index-b6e3y1R-.js → index-mjwdOWLk.js} +1 -1
- package/dist-embed/chunks/{index-Gngo0bXi.js → index-wuTQQ7uK.js} +1 -1
- package/dist-embed/chunks/{index-CCRwowMu.js → index-zOsAyJ2Z.js} +1 -1
- package/dist-embed/chunks/{it-IT-JPQ66NNP-DDwc6pzw.js → it-IT-JPQ66NNP-CMr44eTw.js} +1 -1
- package/dist-embed/chunks/{ja-JP-DBVTYXUO-TrA2khDT.js → ja-JP-DBVTYXUO-DT0NU6hE.js} +1 -1
- package/dist-embed/chunks/{kaa-6HZHGXH3-GwFnOAIz.js → kaa-6HZHGXH3-C7H2NR4A.js} +1 -1
- package/dist-embed/chunks/{kab-KAB-ZGHBKWFO-xYS1Kjfb.js → kab-KAB-ZGHBKWFO-CNMStwQY.js} +1 -1
- package/dist-embed/chunks/{kk-KZ-P5N5QNE5-BwDJRk5I.js → kk-KZ-P5N5QNE5-D6IFMubV.js} +1 -1
- package/dist-embed/chunks/{km-KH-HSX4SM5Z-Di9J-9zc.js → km-KH-HSX4SM5Z-sh4HcGEj.js} +1 -1
- package/dist-embed/chunks/{ko-KR-MTYHY66A-BxF1Locw.js → ko-KR-MTYHY66A-Bgk5LE7Q.js} +1 -1
- package/dist-embed/chunks/{ku-TR-6OUDTVRD-mGflwIcv.js → ku-TR-6OUDTVRD-CoM0o1jW.js} +1 -1
- package/dist-embed/chunks/{lt-LT-XHIRWOB4-DWluphZ2.js → lt-LT-XHIRWOB4-1uHPL6b-.js} +1 -1
- package/dist-embed/chunks/{lv-LV-5QDEKY6T-D9EEzVQ9.js → lv-LV-5QDEKY6T-DYKbCrq6.js} +1 -1
- package/dist-embed/chunks/{mr-IN-CRQNXWMA-DoMvP_Jp.js → mr-IN-CRQNXWMA-C7qlI0yH.js} +1 -1
- package/dist-embed/chunks/{my-MM-5M5IBNSE-CPPbx93K.js → my-MM-5M5IBNSE-BWSQ_5V3.js} +1 -1
- package/dist-embed/chunks/{nb-NO-T6EIAALU-m2hgNNww.js → nb-NO-T6EIAALU-BVQfX-Pe.js} +1 -1
- package/dist-embed/chunks/{nl-NL-IS3SIHDZ-B809T0Iy.js → nl-NL-IS3SIHDZ-BXjyEe9g.js} +1 -1
- package/dist-embed/chunks/{nn-NO-6E72VCQL-DcMxKEVg.js → nn-NO-6E72VCQL-3eaL8woM.js} +1 -1
- package/dist-embed/chunks/{oc-FR-POXYY2M6-BZTBaY64.js → oc-FR-POXYY2M6-CDqoITm8.js} +1 -1
- package/dist-embed/chunks/{pa-IN-N4M65BXN-Cs4i3fnS.js → pa-IN-N4M65BXN-CoKaIMNa.js} +1 -1
- package/dist-embed/chunks/{percentages-BXMCSKIN-D82iCuEy.js → percentages-BXMCSKIN-X4aF_7zv.js} +3 -3
- package/dist-embed/chunks/{pl-PL-T2D74RX3-B3jg7qOY.js → pl-PL-T2D74RX3-DDD5SgtT.js} +1 -1
- package/dist-embed/chunks/{pt-BR-5N22H2LF-aCJuloaY.js → pt-BR-5N22H2LF-BIIRVQqv.js} +1 -1
- package/dist-embed/chunks/{pt-PT-UZXXM6DQ-8ZZdQp1P.js → pt-PT-UZXXM6DQ-HB1n3nNc.js} +1 -1
- package/dist-embed/chunks/{ro-RO-JPDTUUEW-BmyO5zyl.js → ro-RO-JPDTUUEW-CDxFIF2P.js} +1 -1
- package/dist-embed/chunks/{ru-RU-B4JR7IUQ-BneR_2Bm.js → ru-RU-B4JR7IUQ-CM2wpzEh.js} +1 -1
- package/dist-embed/chunks/{si-LK-N5RQ5JYF-CDB0IyVm.js → si-LK-N5RQ5JYF-u_f-pZ4T.js} +1 -1
- package/dist-embed/chunks/{sk-SK-C5VTKIMK-ypZmPMe_.js → sk-SK-C5VTKIMK-1MdhriDY.js} +1 -1
- package/dist-embed/chunks/{sl-SI-NN7IZMDC-D9OrZXr7.js → sl-SI-NN7IZMDC-BtkaEwYy.js} +1 -1
- package/dist-embed/chunks/{subset-shared.chunk-cQajIUFT.js → subset-shared.chunk-Ca3xPoZL.js} +1 -1
- package/dist-embed/chunks/{subset-worker.chunk-DEC9qaDu.js → subset-worker.chunk-CEgJtfh9.js} +1 -1
- package/dist-embed/chunks/{sv-SE-XGPEYMSR-CXBRqMMZ.js → sv-SE-XGPEYMSR-CX9l-s8b.js} +1 -1
- package/dist-embed/chunks/{ta-IN-2NMHFXQM-BuB9HEjH.js → ta-IN-2NMHFXQM-Bs3QMZdy.js} +1 -1
- package/dist-embed/chunks/{th-TH-HPSO5L25-Ci7wR5dZ.js → th-TH-HPSO5L25-yCfu_zLh.js} +1 -1
- package/dist-embed/chunks/{tr-TR-DEFEU3FU-CEJUT8zN.js → tr-TR-DEFEU3FU-PnpIJqSm.js} +1 -1
- package/dist-embed/chunks/{uk-UA-QMV73CPH-Ceh5JIiD.js → uk-UA-QMV73CPH--aODafpt.js} +1 -1
- package/dist-embed/chunks/{url-DuKx0yk0.js → url-CzjbCo42.js} +1 -1
- package/dist-embed/chunks/{vi-VN-M7AON7JQ-8-R9Ohxp.js → vi-VN-M7AON7JQ-BruA8Fg-.js} +1 -1
- package/dist-embed/chunks/{zh-CN-LNUGB5OW-D4q5wqKm.js → zh-CN-LNUGB5OW-DtbH5pJi.js} +1 -1
- package/dist-embed/chunks/{zh-HK-E62DVLB3-_UiIVKpk.js → zh-HK-E62DVLB3-CPacR6Re.js} +1 -1
- package/dist-embed/chunks/{zh-TW-RAJ6MFWO-DyXZ-PXI.js → zh-TW-RAJ6MFWO-CImbtPSf.js} +1 -1
- package/dist-embed/datalayer-app-main.js +86 -86
- package/lib/apps/core/index.d.ts +11 -0
- package/lib/apps/plugins/app-rules/AppRulesCard.d.ts +6 -0
- package/lib/apps/plugins/app-rules/AppRulesCard.js +9 -1
- package/lib/apps/plugins/chat/ChatView.js +18 -3
- package/lib/apps/shell/LoopWorkspace.js +8 -0
- package/lib/portable/hosts/contracts.json +30 -0
- package/lib/specs/agents/agents.d.ts +6 -0
- package/lib/specs/agents/agents.js +294 -0
- package/lib/voice/HandsFree.js +11 -1
- package/lib/voice/VoiceInput.js +10 -2
- package/lib/voice/handsFree.d.ts +4 -2
- package/lib/voice/handsFree.js +4 -2
- package/package.json +1 -1
- package/dist-embed/chunks/ChatView-CRp8Mt57.js +0 -32
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as ue,t as rt,T as at,p as de,b as Ve,f as Ue,I as dt,j as ct,a as qe,d as ut,C as Ee,g as Ne}from"./index-CFP9psRB.js";import{r as H,ha as ht,c4 as pt,v as A,ag as Z,c1 as ne,ak as O,gN as gt,dH as bt,gE as mt,hb as Ct,an as $e,dN as vt,h3 as ft,dL as _t,cv as Q,c8 as yt,hc as _,cI as Je,cD as De,cJ as ze,eO as Ge,eP as Ye,dK as xe,am as xt,ci as Xe,ch as ve,c2 as we,hd as wt,he as kt,h5 as St,b$ as ke,l as Y,aW as At,gF as Mt,J as Tt,ah as pe,gS as G,hf as he,af as ie,hg as Ce,dE as Oe,hh as Bt,hi as Et,cV as je,cT as Re,hj as le,cX as Ie,hk as Pe,cU as Nt,hl as Ot,hm as jt,ac as Qe,hn as Rt,ho as It,dJ as Pt,ai as F,du as ge,hp as fe,cx as Lt,dC as Wt,c$ as Ht,hq as Ft,hr as se,hs as Ze,d7 as Kt,b_ as Vt,aj as Ut,cy as qt,ca as $t,gQ as Jt,ht as Dt,cN as zt,cQ as Gt,hu as Yt,hv as Xt,hw as Qt,da as Zt,db as eo,cS as to,aV as oo,ee as no}from"../datalayer-app-main.js";import{b as io,I as et}from"./token-BRjncM66.js";import{ToolbarItems as lo}from"./index-CCRwowMu.js";import{I as so}from"./index-Dv_XGY6Q.js";import{I as Se}from"./tokens-BHMD_ju9.js";import{a as tt,I,b as ot,c as ro}from"./tokens-CydTkiyv.js";import{I as ao,a as nt}from"./tokens-BvmYCqiu.js";import{I as co}from"./tokens-CBD7cd6p.js";import{f as it,e as uo,c as ho,I as po,b as go}from"./index-BN8Bbau-.js";import{I as lt}from"./tokens-D1_9ZFxB.js";import{I as be}from"./tokens-BHLmeqjP.js";import{a as Ae}from"./tokens-_fLcuFXz.js";import{I as bo}from"./tokens-CENaHAHm.js";import{I as mo}from"./index-DSN70XMH.js";import{I as Co}from"./tokens-DXLxGbDM.js";import{W as vo,u as Le,V as fo,I as _o,a as yo,b as xo,c as wo}from"./document-Dluvp7zl.js";import{b as ko,c as So,d as Ao}from"./CellSidebarExtension-B-73cmcQ.js";import{T as Mo,a as To}from"./model-BziAhKNp.js";import{C as We}from"./celltoolbartracker-DcYHi8Du.js";import"./hoverbox-CStlKQWE.js";import"./Output-no9rnFJ7.js";import"./index-S4sn4R3i.js";import"./color-CG7_7V2-.js";import"./isEqual-g-jK7vY0.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./PaintbrushIcon-CLU8RilX.js";import"./index-BJhxZF_K.js";import"./RestartIcon-Ca6_HoK0.js";import"./NotebookSkeleton-CI7ovjNW.js";import"./Avatar-9MpXENSs.js";import"./renderer-DKKfWkWv.js";import"./SquareIcon-e3ygcjpv.js";import"./SortAscIcon-CVKVWIWQ.js";import"./url-DuKx0yk0.js";/* empty css */import"./index-Dro44tIm.js";/* empty css *//* empty css */import"./index-DsG9xhMj.js";/* empty css */import"./index-CNU-WVhQ.js";import"./index--OLIX362.js";import"./index-DYGslHkf.js";import"./index-BSRVX3UN.js";import"./index-BH2OX5l8.js";import"./index-C3vDfO5_.js";import"./index-Ko8lxXFd.js";import"./index-CB9u17_J.js";import"./index-BUVtc_FV.js";import"./ArrowLeftIcon-Y3PTljcl.js";import"./SkubbleIcon-tlg17jBG.js";import"./usePrimerThemeBridge-CoHussa9.js";import"./index-Dobs-OKl.js";import"./KernelVariables-CS6h5HyK.js";import"./index-BvgsWH_d.js";import"./SortDescIcon-CS4EzHeS.js";import"./NotebookToolbar-rtMQZWHQ.js";import"./RepoPushIcon-Cm8g9NuL.js";import"./Toolbar-CGQDY041.js";import"./sessions-BRALW9Yv.js";import"./tokens-DTIgYcNS.js";import"./drivecontents-CxwZz_5W.js";import"./kernel-BI-BLP-K.js";const Bo="jp-DefaultStyle",Eo="jp-HTMLSelect";class No extends H.Component{render(){const{className:e,defaultStyle:i=!0,disabled:a,elementRef:s,iconProps:l,icon:p=ht,options:n=[],...c}=this.props,d=pt(Eo,{[Bo]:i},e),g=b=>{b.stopPropagation()},m=n.map(b=>{const f=typeof b=="object"?b:{value:b};return H.createElement("option",{...f,key:f.value},f.label||f.value)});return H.createElement("div",{className:d},H.createElement("select",{onFocus:g,disabled:a,ref:s,...c,multiple:!1},m,c.children),H.createElement(p.react,{tag:"span",stylesheet:"select",right:"4px",top:"4px",...l}))}}function Oo(r){const i=a=>{const s=Math.max(a*3.6,.1),l=s*Math.PI/180,p=Math.sin(l)*104,n=Math.cos(l)*-104;return"M 0 0 v -104 A 104 104 1 "+(s<180?1:0)+" 0 "+p.toFixed(4)+" "+n.toFixed(4)+" z"};return A.createElement("div",{className:"jp-Statusbar-ProgressCircle",role:"progressbar","aria-label":r.label||"Unlabelled progress circle","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r.progress,onClick:r.onClick},A.createElement("svg",{viewBox:"0 0 250 250"},A.createElement("circle",{cx:"125",cy:"125",r:"104",stroke:"var(--jp-inverse-layout-color3)",strokeWidth:"20",fill:"none"}),A.createElement("path",{className:"jp-Statusbar-ProgressCirclePath",transform:"translate(125,125) scale(.9)",d:i(r.progress),fill:"var(--jp-inverse-layout-color3)"})))}const jo="jp-JSONEditor",ce="jp-mod-error",Ro="jp-JSONEditor-host",Io="jp-JSONEditor-header";class Po extends Z{constructor(e){super(),this._dataDirty=!1,this._inputDirty=!1,this._source=null,this._originalValue=ne.emptyObject,this._changeGuard=!1,this.translator=e.translator||O,this._trans=this.translator.load("jupyterlab"),this.addClass(jo),this.headerNode=document.createElement("div"),this.headerNode.className=Io,this.revertButtonNode=gt.element({tag:"span",title:this._trans.__("Revert changes to data")}),this.commitButtonNode=bt.element({tag:"span",title:this._trans.__("Commit changes to data"),marginLeft:"8px"}),this.editorHostNode=document.createElement("div"),this.editorHostNode.className=Ro,this.headerNode.appendChild(this.revertButtonNode),this.headerNode.appendChild(this.commitButtonNode),this.node.appendChild(this.headerNode),this.node.appendChild(this.editorHostNode);const i=new mt.Model({mimeType:"application/json"});i.sharedModel.changed.connect(this._onModelChanged,this),this.model=i,this.editor=e.editorFactory({host:this.editorHostNode,model:i,config:{readOnly:!0}})}get source(){return this._source}set source(e){this._source!==e&&(this._source&&this._source.changed.disconnect(this._onSourceChanged,this),this._source=e,this.editor.setOption("readOnly",e===null),e&&e.changed.connect(this._onSourceChanged,this),this._setValue())}get isDirty(){return this._dataDirty||this._inputDirty}dispose(){var e;this.isDisposed||((e=this.source)===null||e===void 0||e.dispose(),this.model.dispose(),this.editor.dispose(),super.dispose())}handleEvent(e){switch(e.type){case"blur":this._evtBlur(e);break;case"click":this._evtClick(e);break}}onAfterAttach(e){const i=this.editorHostNode;i.addEventListener("blur",this,!0),i.addEventListener("click",this,!0),this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.headerNode.addEventListener("click",this)}onBeforeDetach(e){const i=this.editorHostNode;i.removeEventListener("blur",this,!0),i.removeEventListener("click",this,!0),this.headerNode.removeEventListener("click",this)}_onSourceChanged(e,i){if(!this._changeGuard){if(this._inputDirty||this.editor.hasFocus()){this._dataDirty=!0;return}this._setValue()}}_onModelChanged(e,i){if(i.sourceChange){let a=!0;try{const s=JSON.parse(this.editor.model.sharedModel.getSource());this.removeClass(ce),this._inputDirty=!this._changeGuard&&!ne.deepEqual(s,this._originalValue)}catch{this.addClass(ce),this._inputDirty=!0,a=!1}this.revertButtonNode.hidden=!this._inputDirty,this.commitButtonNode.hidden=!a||!this._inputDirty}}_evtBlur(e){!this._inputDirty&&this._dataDirty&&this._setValue()}_evtClick(e){const i=e.target;this.revertButtonNode.contains(i)?this._setValue():this.commitButtonNode.contains(i)?!this.commitButtonNode.hidden&&!this.hasClass(ce)&&(this._changeGuard=!0,this._mergeContent(),this._changeGuard=!1,this._setValue()):this.editorHostNode.contains(i)&&this.editor.focus()}_mergeContent(){const e=this.editor.model,i=this._originalValue,a=JSON.parse(e.sharedModel.getSource()),s=this.source;if(s){for(const l in a)ne.deepEqual(a[l],i[l]||null)||s.set(l,a[l]);for(const l in i)l in a||s.delete(l)}}_setValue(){this._dataDirty=!1,this._inputDirty=!1,this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.removeClass(ce);const e=this.editor.model,i=this._source?this._source.toJSON():{};if(this._changeGuard=!0,i===void 0)e.sharedModel.setSource(this._trans.__("No data!")),this._originalValue=ne.emptyObject;else{const a=JSON.stringify(i,null,4);e.sharedModel.setSource(a),this._originalValue=i,a.length>1&&a[0]==="{"&&this.editor.setCursorPosition({line:0,column:1})}this._changeGuard=!1,this.commitButtonNode.hidden=!0,this.revertButtonNode.hidden=!0}}const Lo="jp-Notebook-toolbarCellType",Wo="jp-Notebook-toolbarCellTypeDropdown";var _e;(function(r){function e(g,m){const b=(m||O).load("jupyterlab");function f(){if(g.context.model.readOnly)return Xe({title:b.__("Cannot Save"),body:b.__("Document is read-only"),buttons:[ve.okButton()]});g.context.save().then(()=>{if(!g.isDisposed)return g.context.createCheckpoint()})}return Ct($e.create(H.createElement(vt,{signal:g.context.fileChanged},()=>H.createElement(ft,{icon:_t,onClick:f,tooltip:b.__("Save the notebook contents and create checkpoint"),enabled:!!(g&&g.context&&g.context.contentsModel&&g.context.contentsModel.writable)}))))}r.createSaveButton=e;function i(g,m){const b=(m||O).load("jupyterlab");return new Q({icon:yt,onClick:()=>{_.insertBelow(g.content)},tooltip:b.__("Insert a cell below")})}r.createInsertButton=i;function a(g,m,b){const f=(m||O).load("jupyterlab");return new Q({icon:Je,onClick:async()=>{b?.get("useSystemClipboardForCells").composite?await _.cutToSystemClipboard(g.content):_.cut(g.content)},tooltip:f.__("Cut the selected cells")})}r.createCutButton=a;function s(g,m,b){const f=(m||O).load("jupyterlab");return new Q({icon:De,onClick:async()=>{b?.get("useSystemClipboardForCells").composite?await _.copyToSystemClipboard(g.content):_.copy(g.content)},tooltip:f.__("Copy the selected cells")})}r.createCopyButton=s;function l(g,m,b){const f=(m||O).load("jupyterlab");return new Q({icon:ze,onClick:async()=>{b?.get("useSystemClipboardForCells").composite?await _.pasteFromSystemClipboard(g.content):_.paste(g.content)},tooltip:f.__("Paste cells from the clipboard")})}r.createPasteButton=l;function p(g,m,b){const f=(b??O).load("jupyterlab");return new Q({icon:Ge,onClick:()=>{_.runAndAdvance(g.content,g.sessionContext,m,b)},tooltip:f.__("Run the selected cells and advance")})}r.createRunButton=p;function n(g,m,b){const f=(b??O).load("jupyterlab");return new Q({icon:Ye,onClick:()=>{const x=m??new xe({translator:b});x.restart(g.sessionContext).then(o=>(o&&_.runAll(g.content,g.sessionContext,x,b),o))},tooltip:f.__("Restart the kernel, then re-run the whole notebook")})}r.createRestartRunAllButton=n;function c(g,m){return new Ho(g.content,m)}r.createCellTypeItem=c;function d(g,m,b,f){return[{name:"save",widget:e(g,b)},{name:"insert",widget:i(g,b)},{name:"cut",widget:a(g,b,f)},{name:"copy",widget:s(g,b,f)},{name:"paste",widget:l(g,b,f)},{name:"run",widget:p(g,m,b)},{name:"interrupt",widget:ue.createInterruptButton(g.sessionContext,b)},{name:"restart",widget:ue.createRestartButton(g.sessionContext,m,b)},{name:"restart-and-run",widget:n(g,m,b)},{name:"cellType",widget:c(g,b)},{name:"spacer",widget:xt.createSpacerItem()},{name:"kernelName",widget:ue.createKernelNameItem(g.sessionContext,m,b)}]}r.getDefaultItems=d})(_e||(_e={}));class Ho extends $e{constructor(e,i){super(),this.handleChange=a=>{a.target.value!=="-"&&(_.changeCellType(this._notebook,a.target.value),this._notebook.activate())},this.handleKeyDown=a=>{a.key==="Enter"&&this._notebook.activate()},this._trans=(i||O).load("jupyterlab"),this.addClass(Lo),this._notebook=e,e.model&&this.update(),e.activeCellChanged.connect(this.update,this),e.selectionChanged.connect(this.update,this)}render(){let e="-";this._notebook.activeCell&&(e=this._notebook.activeCell.model.type);for(const i of this._notebook.widgets)if(this._notebook.isSelectedOrActive(i)&&i.model.type!==e){e="-";break}return H.createElement(No,{className:Wo,onChange:this.handleChange,onKeyDown:this.handleKeyDown,value:e,"aria-label":this._trans.__("Cell type"),title:this._trans.__("Select the cell type")},H.createElement("option",{value:"-"},"-"),H.createElement("option",{value:"code"},this._trans.__("Code")),H.createElement("option",{value:"markdown"},this._trans.__("Markdown")),H.createElement("option",{value:"raw"},this._trans.__("Raw")))}}function He(r){var e;const i=r.translator||O,a=rt(i),s=i.load("jupyterlab"),l=(e=r.displayOption.showJumpToCell)!==null&&e!==void 0?e:!1,p=r.state,n=r.displayOption.showOnToolBar,c=r.displayOption.showProgress,d=n?"down":"up",g=A.createElement("div",null),[m,b]=A.useState(!1);if(A.useEffect(()=>{if(m)return;const j=()=>{b(!0)};return _.executionScheduled.connect(j),()=>{_.executionScheduled.disconnect(j)}},[l,m]),!p)return g;const f=p.kernelStatus,x={alignSelf:"normal",height:"24px"},o=p.totalTime,t=p.scheduledCellNumber||0,u=p.scheduledCell.size||0,C=t-u;let w=100*C/t,B=c?"":"hidden";!c&&w<100&&(w=0);const M=j=>A.createElement(Oo,{progress:j,width:16,height:24,label:s.__("Kernel status")}),K=j=>s.__("Kernel status: %1",j),V=()=>{const j=r.notebook;_.selectLastRunCell(j),j.activeCell&&j.scrollToCell(j.activeCell)},R=(j,$,P)=>A.createElement("div",{className:"jp-Notebook-ExecutionIndicator",title:c?"":K(a[j]),"data-status":j},$,A.createElement("div",{className:`jp-Notebook-ExecutionIndicator-tooltip ${d} ${B}`},A.createElement("span",null," ",K(a[j])," "),P,l&&m&&A.createElement(St,{className:"jp-Notebook-ExecutionIndicator-jumpButton",onClick:V,title:s.__("Jump to current or last executed cell")},s.__("Jump to cell"))));if(p.kernelStatus==="connecting"||p.kernelStatus==="disconnected"||p.kernelStatus==="unknown")return R(f,A.createElement(wt.react,{...x}),[]);if(p.kernelStatus==="starting"||p.kernelStatus==="terminating"||p.kernelStatus==="restarting"||p.kernelStatus==="initializing")return R(f,A.createElement(kt.react,{...x}),[]);if(p.executionStatus==="busy")return R("busy",M(w),[A.createElement("span",{key:0},s.__("Executed %1/%2 cells",C,t)),A.createElement("span",{key:1},s._n("Elapsed time: %1 second","Elapsed time: %1 seconds",o))]);{const j=p.kernelStatus==="busy"?0:100,$=p.kernelStatus==="busy"||o===0?[]:[A.createElement("span",{key:0},s._n("Executed %1 cell","Executed %1 cells",t)),A.createElement("span",{key:1},s._n("Elapsed time: %1 second","Elapsed time: %1 seconds",o))];return R(p.kernelStatus,M(j),$)}}class X extends we{constructor(e,i=!0){super(new X.Model),this.translator=e||O,this.addClass("jp-mod-highlighted")}render(){if(this.model===null||!this.model.renderFlag)return A.createElement("div",null);{const e=this.model.currentNotebook;return e?A.createElement(He,{displayOption:this.model.displayOption,state:this.model.executionState(e),translator:this.translator,notebook:e}):A.createElement(He,{displayOption:this.model.displayOption,state:void 0,translator:this.translator,notebook:void 0})}}}(function(r){class e extends ke{constructor(){super(),this._notebookExecutionProgress=new WeakMap,this._displayOption={showOnToolBar:!0,showProgress:!0,showJumpToCell:!1},this._renderFlag=!0}attachNotebook(l){var p,n,c,d;if(l&&l.content&&l.context){const g=l.content,m=l.context;if(this._currentNotebook=g,!this._notebookExecutionProgress.has(g)){this._notebookExecutionProgress.set(g,{executionStatus:"idle",kernelStatus:"idle",totalTime:0,interval:0,timeout:0,scheduledCell:new Set,scheduledCellNumber:0,needReset:!0});const b=this._notebookExecutionProgress.get(g),f=u=>{b&&(b.kernelStatus=u.kernelDisplayStatus),this.stateChanged.emit(void 0)};m.statusChanged.connect(f,this);const x=u=>{b&&(b.kernelStatus=u.kernelDisplayStatus),this.stateChanged.emit(void 0)};m.connectionStatusChanged.connect(x,this),m.disposed.connect(u=>{u.connectionStatusChanged.disconnect(x,this),u.statusChanged.disconnect(f,this)});const o=(u,C)=>{const w=C.msg,B=w.header.msg_id;if(w.header.msg_type==="execute_request")this._cellScheduledCallback(g,B);else if(Y.KernelMessage.isStatusMsg(w)&&w.content.execution_state==="idle"){const M=w.parent_header.msg_id;this._cellExecutedCallback(g,M)}else Y.KernelMessage.isStatusMsg(w)&&w.content.execution_state==="restarting"?this._restartHandler(g):w.header.msg_type==="execute_input"&&this._startTimer(g)};(n=(p=m.session)===null||p===void 0?void 0:p.kernel)===null||n===void 0||n.anyMessage.connect(o),(d=(c=m.session)===null||c===void 0?void 0:c.kernel)===null||d===void 0||d.disposed.connect(u=>u.anyMessage.disconnect(o));const t=(u,C)=>{b&&(this._resetTime(b),this.stateChanged.emit(void 0),C.newValue&&C.newValue.anyMessage.connect(o))};m.kernelChanged.connect(t),m.disposed.connect(u=>u.kernelChanged.disconnect(t))}}}get currentNotebook(){return this._currentNotebook}get displayOption(){return this._displayOption}set displayOption(l){this._displayOption=l}executionState(l){return this._notebookExecutionProgress.get(l)}_scheduleSwitchToIdle(l){window.setTimeout(()=>{l.executionStatus="idle",clearInterval(l.interval),this.stateChanged.emit(void 0)},150),l.timeout=window.setTimeout(()=>{l.needReset=!0},1e3)}_cellExecutedCallback(l,p){const n=this._notebookExecutionProgress.get(l);n&&n.scheduledCell.has(p)&&(n.scheduledCell.delete(p),n.scheduledCell.size===0&&this._scheduleSwitchToIdle(n))}_restartHandler(l){const p=this._notebookExecutionProgress.get(l);p&&(p.scheduledCell.clear(),this._scheduleSwitchToIdle(p))}_startTimer(l){const p=this._notebookExecutionProgress.get(l);p&&(p.scheduledCell.size>0?p.executionStatus!=="busy"&&(p.executionStatus="busy",clearTimeout(p.timeout),this.stateChanged.emit(void 0),p.interval=window.setInterval(()=>{this._tick(p)},1e3)):this._resetTime(p))}_cellScheduledCallback(l,p){const n=this._notebookExecutionProgress.get(l);n&&!n.scheduledCell.has(p)&&(n.needReset&&this._resetTime(n),n.scheduledCell.add(p),n.scheduledCellNumber+=1)}_tick(l){l.totalTime+=1,this.stateChanged.emit(void 0)}_resetTime(l){l.totalTime=0,l.scheduledCellNumber=0,l.executionStatus="idle",l.scheduledCell=new Set,clearTimeout(l.timeout),clearInterval(l.interval),l.needReset=!1}get renderFlag(){return this._renderFlag}updateRenderOption(l){this.displayOption.showOnToolBar&&(l.showOnToolBar?this._renderFlag=!0:this._renderFlag=!1),this.displayOption.showProgress=l.showProgress,this.displayOption.showJumpToCell=l.showJumpToCell,this.stateChanged.emit(void 0)}}r.Model=e;function i(s,l,p){const n=new r(l);return n.model.displayOption={showOnToolBar:!0,showProgress:!0,showJumpToCell:!1},n.model.attachNotebook({content:s.content,context:s.sessionContext}),p&&p.then(c=>{const d=g=>{const m=a(g);m.showJumpToCell&&(g.get("recordTiming").composite||g.set("recordTiming",!0).catch(f=>{console.error("Failed to auto-enable recordTiming:",f.message)})),n.model.updateRenderOption(m)};c.changed.connect(d),d(c),n.disposed.connect(()=>{c.changed.disconnect(d)})}).catch(c=>{console.error(c.message)}),n}r.createExecutionIndicatorItem=i;function a(s){let l=!0,p=!0,n=!1;const c=s.get("kernelStatus").composite;return c&&(l=!c.showOnStatusBar,p=c.showProgress,n=c.showJumpToRecentExecutionButton),{showOnToolBar:l,showProgress:p,showJumpToCell:n}}r.getSettingValue=a})(X||(X={}));function Fo(r){const e=(r.translator||O).load("jupyterlab");return H.createElement(at,{source:e.__("Mode: %1",r.modeNames[r.notebookMode])})}class re extends we{constructor(e){super(new re.Model),this.translator=e||O,this._trans=this.translator.load("jupyterlab"),this._modeNames={command:this._trans.__("Command"),edit:this._trans.__("Edit")}}render(){return this.model?(this.node.title=this._trans.__("Notebook is in %1 mode",this._modeNames[this.model.notebookMode]),H.createElement(Fo,{notebookMode:this.model.notebookMode,translator:this.translator,modeNames:this._modeNames})):null}}(function(r){class e extends ke{constructor(){super(...arguments),this._onChanged=a=>{const s=this._notebookMode;this._notebook?this._notebookMode=a.mode:this._notebookMode="command",this._triggerChange(s,this._notebookMode)},this._notebookMode="command",this._notebook=null}get notebookMode(){return this._notebookMode}set notebook(a){const s=this._notebook;s!==null&&(s.stateChanged.disconnect(this._onChanged,this),s.activeCellChanged.disconnect(this._onChanged,this),s.modelContentChanged.disconnect(this._onChanged,this));const l=this._notebookMode;this._notebook=a,this._notebook===null?this._notebookMode="command":(this._notebookMode=this._notebook.mode,this._notebook.stateChanged.connect(this._onChanged,this),this._notebook.activeCellChanged.connect(this._onChanged,this),this._notebook.modelContentChanged.connect(this._onChanged,this)),this._triggerChange(l,this._notebookMode)}_triggerChange(a,s){a!==s&&this.stateChanged.emit(void 0)}}r.Model=e})(re||(re={}));class Ko extends vo{constructor(e,i){super(e,i),this.editorWidget=e,this.options=i,this._type="code",this._readyDelegate=new At,this._editorToCell=new Map,this.editor=e.content,this._cellToEditor=new WeakMap,this.isReady=this.isReady.bind(this),Promise.all([this.widget.context.sessionContext.ready,this.connectionManager.ready]).then(async()=>{await this.initOnceReady(),this._readyDelegate.resolve()}).catch(console.error)}get documentPath(){return this.widget.context.path}get mimeType(){var e;let i,a=this.language_info();return!a||!a.mimetype?i=this.widget.content.codeMimetype:i=a.mimetype,Array.isArray(i)?(e=i[0])!==null&&e!==void 0?e:Mt.defaultMimeType:i}get languageFileExtension(){let e=this.language_info();if(!(!e||!e.file_extension))return e.file_extension.replace(".","")}get wrapperElement(){return this.widget.node}get editors(){if(this.isDisposed)return[];let e=this.widget.content;return this._editorToCell.clear(),e.isDisposed?[]:e.widgets.map(i=>({ceEditor:this._getCellEditor(i),type:i.model.type,value:i.model.sharedModel.getSource()}))}get activeEditor(){return this.editor.activeCell?this._getCellEditor(this.editor.activeCell):void 0}get ready(){return this._readyDelegate.promise}getEditorIndexAt(e){let i=this._getCellAt(e);return this.widget.content.widgets.findIndex(s=>i===s)}getEditorIndex(e){let i=this._editorToCell.get(e);return this.editor.widgets.findIndex(a=>i===a)}getEditorWrapper(e){return this._editorToCell.get(e).node}async onKernelChanged(e,i){if(i.newValue)try{const a=this._languageInfo;await Le(this.isReady,-1),await this._updateLanguageInfo();const s=this._languageInfo;a?.name!=s.name||a?.mimetype!=s?.mimetype||a?.file_extension!=s?.file_extension?(console.log(`Changed to ${this._languageInfo.name} kernel, reconnecting`),this.reloadConnection()):console.log("Keeping old LSP connection as the new kernel uses the same language")}catch(a){console.warn(a),this.reloadConnection()}}dispose(){this.isDisposed||(this.widget.context.sessionContext.kernelChanged.disconnect(this.onKernelChanged,this),this.widget.content.activeCellChanged.disconnect(this._activeCellChanged,this),super.dispose(),this._editorToCell.clear(),Tt.clearData(this))}isReady(){var e;return!this.widget.isDisposed&&this.widget.context.isReady&&this.widget.content.isVisible&&this.widget.content.widgets.length>0&&((e=this.widget.context.sessionContext.session)===null||e===void 0?void 0:e.kernel)!=null}async handleCellChange(e,i){let a=[],s=[];const l=this._type;if(i.type==="set"){let p=[],n=[];if(i.newValues.length===i.oldValues.length){for(let c=0;c<i.newValues.length;c++)i.oldValues[c].type===l&&i.newValues[c].type!==l?p.push(i.newValues[c]):i.oldValues[c].type!==l&&i.newValues[c].type===l&&n.push(i.newValues[c]);a=n,s=p}}else i.type=="add"&&(a=i.newValues.filter(p=>p.type===l));(s.length||a.length||i.type==="set"||i.type==="move"||i.type==="remove"||i.type==="clear")&&await this.updateDocuments();for(let p of a){let n=this.widget.content.widgets.find(c=>c.model.id===p.id);if(!n){console.warn(`Widget for added cell with ID: ${p.id} not found!`);continue}this._getCellEditor(n)}}createVirtualDocument(){return new fo({language:this.language,foreignCodeExtractors:this.options.foreignCodeExtractorsManager,path:this.documentPath,fileExtension:this.languageFileExtension,standalone:!1,hasLspSupportedFile:!1})}language_info(){return this._languageInfo}async initOnceReady(){await Le(this.isReady.bind(this),-1),await this._updateLanguageInfo(),this.initVirtual(),this.connectDocument(this.virtualDocument,!1).catch(console.warn),this.widget.context.sessionContext.kernelChanged.connect(this.onKernelChanged,this),this.widget.content.activeCellChanged.connect(this._activeCellChanged,this),this._connectModelSignals(this.widget),this.editor.modelChanged.connect(e=>{console.warn("Model changed, connecting cell change handler; this is not something we were expecting"),this._connectModelSignals(e)})}_connectModelSignals(e){e.model===null?console.warn(`Model is missing for notebook ${e}, cannot connect cell changed signal!`):e.model.cells.changed.connect(this.handleCellChange,this)}async _updateLanguageInfo(){var e,i,a,s;const l=(s=await((a=(i=(e=this.widget.context.sessionContext)===null||e===void 0?void 0:e.session)===null||i===void 0?void 0:i.kernel)===null||a===void 0?void 0:a.info))===null||s===void 0?void 0:s.language_info;if(l)this._languageInfo=l;else throw new Error("Language info update failed (no session, kernel, or info available)")}_activeCellChanged(e,i){!i||i.model.type!==this._type||this._activeEditorChanged.emit({editor:this._getCellEditor(i)})}_getCellAt(e){let i=this.virtualDocument.getEditorAtVirtualLine(e);return this._editorToCell.get(i)}_getCellEditor(e){if(!this._cellToEditor.has(e)){const i=Object.freeze({getEditor:()=>e.editor,ready:async()=>(await e.ready,e.editor),reveal:async()=>(await this.editor.scrollToCell(e),e.editor)});this._cellToEditor.set(e,i),this._editorToCell.set(i,e),e.disposed.connect(()=>{this._cellToEditor.delete(e),this._editorToCell.delete(i),this._editorRemoved.emit({editor:i})}),this._editorAdded.emit({editor:i})}return this._cellToEditor.get(e)}}class Vo extends Z{constructor(){super(),this._items=[],this.layout=new pe,this.addClass("jp-RankedPanel")}addWidget(e,i){const a={widget:e,rank:i},s=ie.upperBound(this._items,a,ye.itemCmp);ie.insert(this._items,s,a),this.layout.insertWidget(s,e)}onChildRemoved(e){const i=ie.findFirstIndex(this._items,a=>a.widget===e.child);i!==-1&&ie.removeAt(this._items,i)}}class q extends Z{constructor(e){super(),this.addClass("jp-NotebookTools"),this.translator=e.translator||O,this._tools=[],this.layout=new pe,this._tracker=e.tracker,this._tracker.currentChanged.connect(this._onActiveNotebookPanelChanged,this),this._tracker.activeCellChanged.connect(this._onActiveCellChanged,this),this._tracker.selectionChanged.connect(this._onSelectionChanged,this),this._onActiveNotebookPanelChanged(),this._onActiveCellChanged(),this._onSelectionChanged()}get activeCell(){return this._tracker.activeCell}get selectedCells(){const e=this._tracker.currentWidget;if(!e)return[];const i=e.content;return i.widgets.filter(a=>i.isSelectedOrActive(a))}get activeNotebookPanel(){return this._tracker.currentWidget}addItem(e){var i;const a=e.tool,s=(i=e.rank)!==null&&i!==void 0?i:100;let l;const p=this._tools.find(n=>n.section===e.section);if(p)l=p.panel;else throw new Error(`The section ${e.section} does not exist`);a.addClass("jp-NotebookTools-tool"),l.addWidget(a,s),a.notebookTools=this,G.sendMessage(a,q.ActiveNotebookPanelMessage),G.sendMessage(a,q.ActiveCellMessage)}addSection(e){var i;const a=e.sectionName,s=e.label||e.sectionName,l=e.tool;let p=(i=e.rank)!==null&&i!==void 0?i:null;const n=new Vo;if(n.title.label=s,l&&n.addWidget(l,0),this._tools.push({section:a,panel:n,rank:p}),p!=null)this.layout.insertWidget(p,new de({widget:n}));else{let c=null;const d=this.layout;for(let g=0;g<d.widgets.length;g++){let m=d.widgets[g];if(m instanceof de&&m.widget.id==="advancedToolsSection"){c=g;break}}c!==null?this.layout.insertWidget(c,new de({widget:n})):this.layout.addWidget(new de({widget:n}))}}_onActiveNotebookPanelChanged(){this._prevActiveNotebookModel&&!this._prevActiveNotebookModel.isDisposed&&this._prevActiveNotebookModel.metadataChanged.disconnect(this._onActiveNotebookPanelMetadataChanged,this);const e=this.activeNotebookPanel&&this.activeNotebookPanel.content?this.activeNotebookPanel.content.model:null;this._prevActiveNotebookModel=e,e&&e.metadataChanged.connect(this._onActiveNotebookPanelMetadataChanged,this);for(const i of this._toolChildren())G.sendMessage(i,q.ActiveNotebookPanelMessage)}_onActiveCellChanged(){this._prevActiveCell&&!this._prevActiveCell.isDisposed&&this._prevActiveCell.metadataChanged.disconnect(this._onActiveCellMetadataChanged,this);const e=this.activeCell?this.activeCell.model:null;this._prevActiveCell=e,e&&e.metadataChanged.connect(this._onActiveCellMetadataChanged,this);for(const i of this._toolChildren())G.sendMessage(i,q.ActiveCellMessage)}_onSelectionChanged(){for(const e of this._toolChildren())G.sendMessage(e,q.SelectionMessage)}_onActiveNotebookPanelMetadataChanged(e,i){const a=new he.ChangeMessage("activenotebookpanel-metadata-changed",{oldValue:void 0,newValue:void 0,...i});for(const s of this._toolChildren())G.sendMessage(s,a)}_onActiveCellMetadataChanged(e,i){const a=new he.ChangeMessage("activecell-metadata-changed",{newValue:void 0,oldValue:void 0,...i});for(const s of this._toolChildren())G.sendMessage(s,a)}*_toolChildren(){for(let e of this._tools)yield*e.panel.children()}}(function(r){r.ActiveNotebookPanelMessage=new Ce("activenotebookpanel-changed"),r.ActiveCellMessage=new Ce("activecell-changed"),r.SelectionMessage=new Ce("selection-changed");class e extends Z{dispose(){super.dispose(),this.notebookTools&&(this.notebookTools=null)}processMessage(s){switch(super.processMessage(s),s.type){case"activenotebookpanel-changed":this.onActiveNotebookPanelChanged(s);break;case"activecell-changed":this.onActiveCellChanged(s);break;case"selection-changed":this.onSelectionChanged(s);break;case"activecell-metadata-changed":this.onActiveCellMetadataChanged(s);break;case"activenotebookpanel-metadata-changed":this.onActiveNotebookPanelMetadataChanged(s);break}}onActiveNotebookPanelChanged(s){}onActiveCellChanged(s){}onSelectionChanged(s){}onActiveCellMetadataChanged(s){}onActiveNotebookPanelMetadataChanged(s){}}r.Tool=e;class i extends e{constructor(s){super();const{editorFactory:l}=s;this.addClass("jp-MetadataEditorTool");const p=this.layout=new pe;this._editorFactory=l,this._editorLabel=s.label||"Edit Metadata",this.createEditor();const n=new Z({node:document.createElement("label")});n.node.textContent=s.label||"Edit Metadata",p.addWidget(n),p.addWidget(this.editor)}get editor(){return this._editor}onActiveNotebookPanelChanged(s){this.editor.dispose(),this.notebookTools.activeNotebookPanel&&this.createEditor()}createEditor(){this._editor=new Po({editorFactory:this._editorFactory}),this.editor.title.label=this._editorLabel,this.layout.addWidget(this.editor)}}r.MetadataEditorTool=i})(q||(q={}));var ye;(function(r){function e(i,a){return i.rank-a.rank}r.itemCmp=e})(ye||(ye={}));const Uo=6;var W;(function(r){r[r.Idle=-1]="Idle",r[r.Error=-.5]="Error",r[r.Scheduled=0]="Scheduled",r[r.Running=1]="Running"})(W||(W={}));class qo extends To{constructor(e,i,a,s){super(e,s),this.parser=i,this.sanitizer=a,this.configMetadataMap={numberHeaders:["toc-autonumbering","toc/number_sections"],numberingH1:["!toc/skip_h1_title"],baseNumbering:["toc/base_numbering"]},this._runningCells=new Array,this._errorCells=new Array,this._cellToHeadingIndex=new WeakMap,e.context.ready.then(()=>{this.setConfiguration({})}),this.widget.context.model.metadataChanged.connect(this.onMetadataChanged,this),this.widget.content.activeCellChanged.connect(this.onActiveCellChanged,this),_.executionScheduled.connect(this.onExecutionScheduled,this),_.executed.connect(this.onExecuted,this),_.outputCleared.connect(this.onOutputCleared,this),this.headingsChanged.connect(this.onHeadingsChanged,this)}get documentType(){return"notebook"}get isAlwaysActive(){return!0}get supportedOptions(){return["baseNumbering","maximalDepth","numberingH1","numberHeaders","includeOutput","syncCollapseState"]}getCellHeadings(e){const i=new Array;let a=this._cellToHeadingIndex.get(e);if(a!==void 0){const s=this.headings[a];for(i.push(s);this.headings[a-1]&&this.headings[a-1].cellRef===s.cellRef;)a--,i.unshift(this.headings[a])}return i}dispose(){var e,i,a;this.isDisposed||(this.headingsChanged.disconnect(this.onHeadingsChanged,this),(i=(e=this.widget.context)===null||e===void 0?void 0:e.model)===null||i===void 0||i.metadataChanged.disconnect(this.onMetadataChanged,this),(a=this.widget.content)===null||a===void 0||a.activeCellChanged.disconnect(this.onActiveCellChanged,this),_.executionScheduled.disconnect(this.onExecutionScheduled,this),_.executed.disconnect(this.onExecuted,this),_.outputCleared.disconnect(this.onOutputCleared,this),this._runningCells.length=0,this._errorCells.length=0,super.dispose())}setConfiguration(e){const i=this.loadConfigurationFromMetadata();super.setConfiguration({...this.configuration,...i,...e})}toggleCollapse(e){super.toggleCollapse(e),this.updateRunningStatus(this.headings)}async getHeadings(){const e=this.widget.content.widgets,i=new Set(e),a=[],s=new Array,l=new WeakMap;for(let p=0;p<e.length;p++){const n=e[p];switch(n.model.type){case"code":{!this.configuration.syncCollapseState&&this.configuration.includeOutput&&a.push(...Ie(await n.getHeadings(),this.configuration,s).map(d=>({...d,cellRef:n,collapsed:!1,isRunning:W.Idle})));break}case"markdown":{const d=Ie(await n.getHeadings(),this.configuration,s).map((g,m)=>({...g,cellRef:n,collapsed:!1,isRunning:W.Idle}));if(this.configuration.syncCollapseState&&n.headingCollapsed){const g=Math.min(...d.map(b=>b.level)),m=d.find(b=>b.level===g);m.collapsed=n.headingCollapsed}a.push(...d);break}}a.length>0&&l.set(n,a.length-1)}return this._cellToHeadingIndex=l,this._runningCells=this._runningCells.filter(p=>i.has(p)),this._errorCells=this._errorCells.filter(p=>i.has(p)),this.updateRunningStatus(a),Promise.resolve(a)}isHeadingEqual(e,i){return super.isHeadingEqual(e,i)&&e.cellRef===i.cellRef&&e.isRunning===i.isRunning}loadConfigurationFromMetadata(){const e=this.widget.content.model,i={};if(e)for(const a in this.configMetadataMap){const s=this.configMetadataMap[a];for(const l of s){let p=l;const n=p[0]==="!";n&&(p=p.slice(1));const c=p.split("/");let d=e.getMetadata(c[0]);for(let g=1;g<c.length;g++)d=(d??{})[c[g]];d!==void 0&&(typeof d=="boolean"&&n&&(d=!d),i[a]=d)}}return i}onActiveCellChanged(e,i){const a=this.getCellHeadings(i)[0];this.setActiveHeading(a??null,!1)}onHeadingsChanged(){this.widget.content.activeCell&&this.onActiveCellChanged(this.widget.content,this.widget.content.activeCell)}onExecuted(e,i){this._runningCells.forEach((a,s)=>{var l;if(a===i.cell){this._runningCells.splice(s,1);const p=this._cellToHeadingIndex.get(a);if(p!==void 0){const n=this.headings[p];if(i.success||((l=i.error)===null||l===void 0?void 0:l.errorName)===void 0){n.isRunning=W.Idle;return}n.isRunning=W.Error,this._errorCells.includes(a)||this._errorCells.push(a)}}}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onExecutionScheduled(e,i){this._runningCells.includes(i.cell)||this._runningCells.push(i.cell),this._errorCells.forEach((a,s)=>{a===i.cell&&this._errorCells.splice(s,1)}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onOutputCleared(e,i){this._errorCells.forEach((a,s)=>{if(a===i.cell){this._errorCells.splice(s,1);const l=this._cellToHeadingIndex.get(a);if(l!==void 0){const p=this.headings[l];p.isRunning=W.Idle}}}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onMetadataChanged(){this.setConfiguration({})}updateRunningStatus(e){e.forEach(s=>{s.isRunning=W.Idle}),this._runningCells.forEach((s,l)=>{const p=this._cellToHeadingIndex.get(s);if(p!==void 0){const n=e[p];n.isRunning!==W.Running&&(n.isRunning=l>0?W.Scheduled:W.Running)}}),this._errorCells.forEach((s,l)=>{const p=this._cellToHeadingIndex.get(s);if(p!==void 0){const n=e[p];n.isRunning===W.Idle&&(n.isRunning=W.Error)}});let i=0;for(;i<e.length;){const s=e[i];if(i++,s.collapsed){const l=Math.max(s.isRunning,a(e,s.level));s.dataset={...s.dataset,"data-running":l.toString()}}else s.dataset={...s.dataset,"data-running":s.isRunning.toString()}}function a(s,l){let p=W.Idle;for(;i<s.length;){const n=s[i];if(n.dataset={...n.dataset,"data-running":n.isRunning.toString()},n.level>l)i++,p=Math.max(n.isRunning,p),n.collapsed&&(p=Math.max(p,a(s,n.level)),n.dataset={...n.dataset,"data-running":p.toString()});else break}return p}}}class $o extends Mo{constructor(e,i,a,s){super(e),this.parser=i,this.sanitizer=a,this.commands=s,this._scrollToTop=!0}get scrollToTop(){return this._scrollToTop}set scrollToTop(e){this._scrollToTop=e}_createNew(e,i){const a=new qo(e,this.parser,this.sanitizer,i);let s=new WeakMap;const l=(m,b)=>{if(b){const f=async u=>{if(!u.inViewport)return;const C=s.get(b);if(C)if(this.scrollToTop)C.scrollIntoView({block:"start"}),e.content.outerNode.scrollTop-=Uo;else{const w=e.content.node.getBoundingClientRect(),B=C.getBoundingClientRect();(B.top>w.bottom||B.bottom<w.top)&&C.scrollIntoView({block:"center"})}else console.debug("scrolling to heading: using fallback strategy"),await e.content.scrollToItem(e.content.activeCellIndex,this.scrollToTop?"start":void 0,0)},x=b.cellRef,t=e.content.widgets.indexOf(x);x.model.type=="markdown"&&e.content.mode!="command"&&(e.content.mode="command"),e.content.activeCellIndex=t,x.inViewport?f(x).catch(u=>{console.error(`Fail to scroll to cell to display the required heading (${u}).`)}):e.content.scrollToItem(t,this.scrollToTop?"start":void 0).then(()=>p(x)).then(()=>f(x)).catch(u=>{console.error(`Fail to scroll to cell to display the required heading (${u}).`)})}},p=m=>Promise.all(a.getCellHeadings(m).map(async b=>{var f,x,o;const t=await Jo(b,this.parser,this.sanitizer),u=(f=this.sanitizer.allowNamedProperties)!==null&&f!==void 0&&f?"id":"data-jupyter-id",C=t?`h${b.level}[${u}="${CSS.escape(t)}"]`:`h${b.level}`;b.outputIndex!==void 0?s.set(b,je(b.cellRef.outputArea.widgets[b.outputIndex].node,C,(x=b.prefix)!==null&&x!==void 0?x:"")):s.set(b,je(b.cellRef.node,C,(o=b.prefix)!==null&&o!==void 0?o:""))})).then(()=>{}),n=m=>{if(this.parser)return Re(e.content.node),s=new WeakMap,Promise.all(e.content.widgets.map(b=>p(b)))},c=(m,b)=>{var f,x,o,t;if(a.configuration.syncCollapseState)if(b!==null){const u=b.cellRef;u.headingCollapsed!==((f=b.collapsed)!==null&&f!==void 0?f:!1)&&(u.headingCollapsed=(x=b.collapsed)!==null&&x!==void 0?x:!1)}else{const u=(t=(o=a.headings[0])===null||o===void 0?void 0:o.collapsed)!==null&&t!==void 0?t:!1;e.content.widgets.forEach(C=>{C instanceof le&&C.headingInfo.level>=0&&(C.headingCollapsed=u)})}},d=(m,b)=>{if(a.configuration.syncCollapseState){const f=a.getCellHeadings(b)[0];f&&a.toggleCollapse({heading:f,collapsed:b.headingCollapsed})}},g=(m,b)=>{var f;b.inViewport?(f=p(b))===null||f===void 0||f.catch(console.warn):Re(b.node)};return e.context.ready.then(()=>{var m;(m=n())===null||m===void 0||m.catch(console.warn),a.activeHeadingChanged.connect(l),a.headingsChanged.connect(n),a.collapseChanged.connect(c),e.content.cellCollapsed.connect(d),e.content.cellInViewportChanged.connect(g),e.disposed.connect(()=>{a.activeHeadingChanged.disconnect(l),a.headingsChanged.disconnect(n),a.collapseChanged.disconnect(c),e.content.cellCollapsed.disconnect(d),e.content.cellInViewportChanged.disconnect(g)})}),a}getToolbarItems(e){return this.commands?[{name:"select-last-modified-back",widget:new Oe({commands:this.commands,id:"notebook:select-last-modified-cell",args:{toolbar:!0},icon:Bt,label:""})},{name:"select-last-modified-forward",widget:new Oe({commands:this.commands,id:"notebook:select-next-modified-cell",args:{toolbar:!0},icon:Et,label:""})}]:[]}}async function Jo(r,e,i){let a=null;return r.type===Pe.HeadingType.Markdown?a=await Nt(e,r.raw,r.level,i):r.type===Pe.HeadingType.HTML&&(a=r.id),a}const Do="jp-StatusItem-trust";function zo(r,e){e=e||O;const i=e.load("jupyterlab");return r.trustedCells===r.totalCells?i.__("Notebook trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells):r.activeCellTrusted?i.__("Active cell trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells):i.__("Notebook not trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells)}function Go(r){return r.allCellsTrusted?A.createElement(Ot.react,{top:"2px",stylesheet:"statusBar"}):A.createElement(jt.react,{top:"2px",stylesheet:"statusBar"})}class ae extends we{constructor(e){super(new ae.Model),this.translator=e||O,this.node.classList.add(Do)}render(){if(!this.model)return null;const e=zo(this.model,this.translator);return e!==this.node.title&&(this.node.title=e),A.createElement(Go,{allCellsTrusted:this.model.trustedCells===this.model.totalCells,activeCellTrusted:this.model.activeCellTrusted,totalCells:this.model.totalCells,trustedCells:this.model.trustedCells})}}(function(r){class e extends ke{constructor(){super(...arguments),this._trustedCells=0,this._totalCells=0,this._activeCellTrusted=!1,this._notebook=null}get trustedCells(){return this._trustedCells}get totalCells(){return this._totalCells}get activeCellTrusted(){return this._activeCellTrusted}get notebook(){return this._notebook}set notebook(a){const s=this._notebook;s!==null&&(s.activeCellChanged.disconnect(this._onActiveCellChanged,this),s.modelContentChanged.disconnect(this._onModelChanged,this));const l=this._getAllState();if(this._notebook=a,this._notebook===null)this._trustedCells=0,this._totalCells=0,this._activeCellTrusted=!1;else{this._notebook.activeCellChanged.connect(this._onActiveCellChanged,this),this._notebook.modelContentChanged.connect(this._onModelChanged,this),this._notebook.activeCell?this._activeCellTrusted=this._notebook.activeCell.model.trusted:this._activeCellTrusted=!1;const{total:p,trusted:n}=this._deriveCellTrustState(this._notebook.model);this._totalCells=p,this._trustedCells=n}this._triggerChange(l,this._getAllState())}_onModelChanged(a){const s=this._getAllState(),{total:l,trusted:p}=this._deriveCellTrustState(a.model);this._totalCells=l,this._trustedCells=p,this._triggerChange(s,this._getAllState())}_onActiveCellChanged(a,s){const l=this._getAllState();s?this._activeCellTrusted=s.model.trusted:this._activeCellTrusted=!1,this._triggerChange(l,this._getAllState())}_deriveCellTrustState(a){if(a===null)return{total:0,trusted:0};let s=0,l=0;for(const p of a.cells)p.type==="code"&&(s++,p.trusted&&l++);return{total:s,trusted:l}}_getAllState(){return[this._trustedCells,this._totalCells,this.activeCellTrusted]}_triggerChange(a,s){(a[0]!==s[0]||a[1]!==s[1]||a[2]!==s[2])&&this.stateChanged.emit(void 0)}}r.Model=e})(ae||(ae={}));const Yo=new Qe("@jupyterlab/metadataform:IMetadataFormProvider","A service to register new metadata editor widgets."),Xo={id:"@jupyterlab/notebook-extension:cell-executor",description:"Provides the notebook cell executor.",autoStart:!0,provides:tt,activate:()=>Object.freeze({runCell:Rt})},Qo=new Qe("@jupyterlab/logconsole:ILoggerRegistry","A service providing a logger infrastructure."),Zo={activate:en,id:"@jupyterlab/notebook-extension:log-output",description:"Adds cell outputs log to the application logger.",requires:[I],optional:[Qo],autoStart:!0};function en(r,e,i){if(!i)return;function a(s){function l(p,n,c){if(Y.KernelMessage.isDisplayDataMsg(p)||Y.KernelMessage.isStreamMsg(p)||Y.KernelMessage.isErrorMsg(p)||Y.KernelMessage.isExecuteResultMsg(p)){const d=i.getLogger(s.context.path);d.rendermime=s.content.rendermime;const g={...p.content,output_type:p.header.msg_type};let m=n;(Y.KernelMessage.isErrorMsg(p)||Y.KernelMessage.isStreamMsg(p)&&p.content.name==="stderr")&&(m=c),d.log({type:"output",data:g,level:m})}}s.context.sessionContext.iopubMessage.connect((p,n)=>l(n,"info","info")),s.context.sessionContext.unhandledMessage.connect((p,n)=>l(n,"warning","error"))}e.forEach(s=>a(s)),e.widgetAdded.connect((s,l)=>a(l))}const tn="jp-ActiveCellTool",on="jp-ActiveCellTool-Content",nn="jp-ActiveCellTool-CellContent";class ln extends q.Tool{constructor(e){super();const{languages:i}=e;this._tracker=e.tracker,this.addClass(tn),this.layout=new pe,this._inputPrompt=new It,this.layout.addWidget(this._inputPrompt);const a=document.createElement("div");a.classList.add(on);const s=a.appendChild(document.createElement("div")),l=s.appendChild(document.createElement("pre"));s.className=nn,this._editorEl=l,this.layout.addWidget(new Z({node:a}));const p=async()=>{var n,c;this._editorEl.innerHTML="",((n=this._cellModel)===null||n===void 0?void 0:n.type)==="code"?(this._inputPrompt.executionCount=`${(c=this._cellModel.executionCount)!==null&&c!==void 0?c:""}`,this._inputPrompt.show()):(this._inputPrompt.executionCount=null,this._inputPrompt.hide()),this._cellModel&&await i.highlight(this._cellModel.sharedModel.getSource().split(`
|
|
1
|
+
import{o as ue,t as rt,T as at,p as de,b as Ve,f as Ue,I as dt,j as ct,a as qe,d as ut,C as Ee,g as Ne}from"./index-CFP9psRB.js";import{r as H,ha as ht,c4 as pt,v as A,ag as Z,c1 as ne,ak as O,gN as gt,dH as bt,gE as mt,hb as Ct,an as $e,dN as vt,h3 as ft,dL as _t,cv as Q,c8 as yt,hc as _,cI as Je,cD as De,cJ as ze,eO as Ge,eP as Ye,dK as xe,am as xt,ci as Xe,ch as ve,c2 as we,hd as wt,he as kt,h5 as St,b$ as ke,l as Y,aW as At,gF as Mt,J as Tt,ah as pe,gS as G,hf as he,af as ie,hg as Ce,dE as Oe,hh as Bt,hi as Et,cV as je,cT as Re,hj as le,cX as Ie,hk as Pe,cU as Nt,hl as Ot,hm as jt,ac as Qe,hn as Rt,ho as It,dJ as Pt,ai as F,du as ge,hp as fe,cx as Lt,dC as Wt,c$ as Ht,hq as Ft,hr as se,hs as Ze,d7 as Kt,b_ as Vt,aj as Ut,cy as qt,ca as $t,gQ as Jt,ht as Dt,cN as zt,cQ as Gt,hu as Yt,hv as Xt,hw as Qt,da as Zt,db as eo,cS as to,aV as oo,ee as no}from"../datalayer-app-main.js";import{b as io,I as et}from"./token-BRjncM66.js";import{ToolbarItems as lo}from"./index-zOsAyJ2Z.js";import{I as so}from"./index-Dv_XGY6Q.js";import{I as Se}from"./tokens-BHMD_ju9.js";import{a as tt,I,b as ot,c as ro}from"./tokens-CydTkiyv.js";import{I as ao,a as nt}from"./tokens-BvmYCqiu.js";import{I as co}from"./tokens-CBD7cd6p.js";import{f as it,e as uo,c as ho,I as po,b as go}from"./index-Dzf9vro3.js";import{I as lt}from"./tokens-D1_9ZFxB.js";import{I as be}from"./tokens-BHLmeqjP.js";import{a as Ae}from"./tokens-_fLcuFXz.js";import{I as bo}from"./tokens-CENaHAHm.js";import{I as mo}from"./index-DSN70XMH.js";import{I as Co}from"./tokens-DXLxGbDM.js";import{W as vo,u as Le,V as fo,I as _o,a as yo,b as xo,c as wo}from"./document-Dluvp7zl.js";import{b as ko,c as So,d as Ao}from"./CellSidebarExtension-B-73cmcQ.js";import{T as Mo,a as To}from"./model-BziAhKNp.js";import{C as We}from"./celltoolbartracker-DcYHi8Du.js";import"./hoverbox-CStlKQWE.js";import"./Output-no9rnFJ7.js";import"./index-S4sn4R3i.js";import"./color-CG7_7V2-.js";import"./isEqual-g-jK7vY0.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./PaintbrushIcon-CLU8RilX.js";import"./index-BJhxZF_K.js";import"./RestartIcon-Ca6_HoK0.js";import"./NotebookSkeleton-CI7ovjNW.js";import"./Avatar-9MpXENSs.js";import"./renderer-DKKfWkWv.js";import"./SquareIcon-e3ygcjpv.js";import"./SortAscIcon-CVKVWIWQ.js";import"./url-CzjbCo42.js";/* empty css */import"./index-Dro44tIm.js";/* empty css *//* empty css */import"./index-DsG9xhMj.js";/* empty css */import"./index-CNU-WVhQ.js";import"./index--OLIX362.js";import"./index-DYGslHkf.js";import"./index-BSRVX3UN.js";import"./index-BH2OX5l8.js";import"./index-C3vDfO5_.js";import"./index-Ko8lxXFd.js";import"./index-CB9u17_J.js";import"./index-BUVtc_FV.js";import"./ArrowLeftIcon-Y3PTljcl.js";import"./SkubbleIcon-tlg17jBG.js";import"./usePrimerThemeBridge-CoHussa9.js";import"./index-Dobs-OKl.js";import"./KernelVariables-CS6h5HyK.js";import"./index-BvgsWH_d.js";import"./SortDescIcon-CS4EzHeS.js";import"./NotebookToolbar-rtMQZWHQ.js";import"./RepoPushIcon-Cm8g9NuL.js";import"./Toolbar-CGQDY041.js";import"./sessions-BRALW9Yv.js";import"./tokens-DTIgYcNS.js";import"./drivecontents-CxwZz_5W.js";import"./kernel-BI-BLP-K.js";const Bo="jp-DefaultStyle",Eo="jp-HTMLSelect";class No extends H.Component{render(){const{className:e,defaultStyle:i=!0,disabled:a,elementRef:s,iconProps:l,icon:p=ht,options:n=[],...c}=this.props,d=pt(Eo,{[Bo]:i},e),g=b=>{b.stopPropagation()},m=n.map(b=>{const f=typeof b=="object"?b:{value:b};return H.createElement("option",{...f,key:f.value},f.label||f.value)});return H.createElement("div",{className:d},H.createElement("select",{onFocus:g,disabled:a,ref:s,...c,multiple:!1},m,c.children),H.createElement(p.react,{tag:"span",stylesheet:"select",right:"4px",top:"4px",...l}))}}function Oo(r){const i=a=>{const s=Math.max(a*3.6,.1),l=s*Math.PI/180,p=Math.sin(l)*104,n=Math.cos(l)*-104;return"M 0 0 v -104 A 104 104 1 "+(s<180?1:0)+" 0 "+p.toFixed(4)+" "+n.toFixed(4)+" z"};return A.createElement("div",{className:"jp-Statusbar-ProgressCircle",role:"progressbar","aria-label":r.label||"Unlabelled progress circle","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r.progress,onClick:r.onClick},A.createElement("svg",{viewBox:"0 0 250 250"},A.createElement("circle",{cx:"125",cy:"125",r:"104",stroke:"var(--jp-inverse-layout-color3)",strokeWidth:"20",fill:"none"}),A.createElement("path",{className:"jp-Statusbar-ProgressCirclePath",transform:"translate(125,125) scale(.9)",d:i(r.progress),fill:"var(--jp-inverse-layout-color3)"})))}const jo="jp-JSONEditor",ce="jp-mod-error",Ro="jp-JSONEditor-host",Io="jp-JSONEditor-header";class Po extends Z{constructor(e){super(),this._dataDirty=!1,this._inputDirty=!1,this._source=null,this._originalValue=ne.emptyObject,this._changeGuard=!1,this.translator=e.translator||O,this._trans=this.translator.load("jupyterlab"),this.addClass(jo),this.headerNode=document.createElement("div"),this.headerNode.className=Io,this.revertButtonNode=gt.element({tag:"span",title:this._trans.__("Revert changes to data")}),this.commitButtonNode=bt.element({tag:"span",title:this._trans.__("Commit changes to data"),marginLeft:"8px"}),this.editorHostNode=document.createElement("div"),this.editorHostNode.className=Ro,this.headerNode.appendChild(this.revertButtonNode),this.headerNode.appendChild(this.commitButtonNode),this.node.appendChild(this.headerNode),this.node.appendChild(this.editorHostNode);const i=new mt.Model({mimeType:"application/json"});i.sharedModel.changed.connect(this._onModelChanged,this),this.model=i,this.editor=e.editorFactory({host:this.editorHostNode,model:i,config:{readOnly:!0}})}get source(){return this._source}set source(e){this._source!==e&&(this._source&&this._source.changed.disconnect(this._onSourceChanged,this),this._source=e,this.editor.setOption("readOnly",e===null),e&&e.changed.connect(this._onSourceChanged,this),this._setValue())}get isDirty(){return this._dataDirty||this._inputDirty}dispose(){var e;this.isDisposed||((e=this.source)===null||e===void 0||e.dispose(),this.model.dispose(),this.editor.dispose(),super.dispose())}handleEvent(e){switch(e.type){case"blur":this._evtBlur(e);break;case"click":this._evtClick(e);break}}onAfterAttach(e){const i=this.editorHostNode;i.addEventListener("blur",this,!0),i.addEventListener("click",this,!0),this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.headerNode.addEventListener("click",this)}onBeforeDetach(e){const i=this.editorHostNode;i.removeEventListener("blur",this,!0),i.removeEventListener("click",this,!0),this.headerNode.removeEventListener("click",this)}_onSourceChanged(e,i){if(!this._changeGuard){if(this._inputDirty||this.editor.hasFocus()){this._dataDirty=!0;return}this._setValue()}}_onModelChanged(e,i){if(i.sourceChange){let a=!0;try{const s=JSON.parse(this.editor.model.sharedModel.getSource());this.removeClass(ce),this._inputDirty=!this._changeGuard&&!ne.deepEqual(s,this._originalValue)}catch{this.addClass(ce),this._inputDirty=!0,a=!1}this.revertButtonNode.hidden=!this._inputDirty,this.commitButtonNode.hidden=!a||!this._inputDirty}}_evtBlur(e){!this._inputDirty&&this._dataDirty&&this._setValue()}_evtClick(e){const i=e.target;this.revertButtonNode.contains(i)?this._setValue():this.commitButtonNode.contains(i)?!this.commitButtonNode.hidden&&!this.hasClass(ce)&&(this._changeGuard=!0,this._mergeContent(),this._changeGuard=!1,this._setValue()):this.editorHostNode.contains(i)&&this.editor.focus()}_mergeContent(){const e=this.editor.model,i=this._originalValue,a=JSON.parse(e.sharedModel.getSource()),s=this.source;if(s){for(const l in a)ne.deepEqual(a[l],i[l]||null)||s.set(l,a[l]);for(const l in i)l in a||s.delete(l)}}_setValue(){this._dataDirty=!1,this._inputDirty=!1,this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.removeClass(ce);const e=this.editor.model,i=this._source?this._source.toJSON():{};if(this._changeGuard=!0,i===void 0)e.sharedModel.setSource(this._trans.__("No data!")),this._originalValue=ne.emptyObject;else{const a=JSON.stringify(i,null,4);e.sharedModel.setSource(a),this._originalValue=i,a.length>1&&a[0]==="{"&&this.editor.setCursorPosition({line:0,column:1})}this._changeGuard=!1,this.commitButtonNode.hidden=!0,this.revertButtonNode.hidden=!0}}const Lo="jp-Notebook-toolbarCellType",Wo="jp-Notebook-toolbarCellTypeDropdown";var _e;(function(r){function e(g,m){const b=(m||O).load("jupyterlab");function f(){if(g.context.model.readOnly)return Xe({title:b.__("Cannot Save"),body:b.__("Document is read-only"),buttons:[ve.okButton()]});g.context.save().then(()=>{if(!g.isDisposed)return g.context.createCheckpoint()})}return Ct($e.create(H.createElement(vt,{signal:g.context.fileChanged},()=>H.createElement(ft,{icon:_t,onClick:f,tooltip:b.__("Save the notebook contents and create checkpoint"),enabled:!!(g&&g.context&&g.context.contentsModel&&g.context.contentsModel.writable)}))))}r.createSaveButton=e;function i(g,m){const b=(m||O).load("jupyterlab");return new Q({icon:yt,onClick:()=>{_.insertBelow(g.content)},tooltip:b.__("Insert a cell below")})}r.createInsertButton=i;function a(g,m,b){const f=(m||O).load("jupyterlab");return new Q({icon:Je,onClick:async()=>{b?.get("useSystemClipboardForCells").composite?await _.cutToSystemClipboard(g.content):_.cut(g.content)},tooltip:f.__("Cut the selected cells")})}r.createCutButton=a;function s(g,m,b){const f=(m||O).load("jupyterlab");return new Q({icon:De,onClick:async()=>{b?.get("useSystemClipboardForCells").composite?await _.copyToSystemClipboard(g.content):_.copy(g.content)},tooltip:f.__("Copy the selected cells")})}r.createCopyButton=s;function l(g,m,b){const f=(m||O).load("jupyterlab");return new Q({icon:ze,onClick:async()=>{b?.get("useSystemClipboardForCells").composite?await _.pasteFromSystemClipboard(g.content):_.paste(g.content)},tooltip:f.__("Paste cells from the clipboard")})}r.createPasteButton=l;function p(g,m,b){const f=(b??O).load("jupyterlab");return new Q({icon:Ge,onClick:()=>{_.runAndAdvance(g.content,g.sessionContext,m,b)},tooltip:f.__("Run the selected cells and advance")})}r.createRunButton=p;function n(g,m,b){const f=(b??O).load("jupyterlab");return new Q({icon:Ye,onClick:()=>{const x=m??new xe({translator:b});x.restart(g.sessionContext).then(o=>(o&&_.runAll(g.content,g.sessionContext,x,b),o))},tooltip:f.__("Restart the kernel, then re-run the whole notebook")})}r.createRestartRunAllButton=n;function c(g,m){return new Ho(g.content,m)}r.createCellTypeItem=c;function d(g,m,b,f){return[{name:"save",widget:e(g,b)},{name:"insert",widget:i(g,b)},{name:"cut",widget:a(g,b,f)},{name:"copy",widget:s(g,b,f)},{name:"paste",widget:l(g,b,f)},{name:"run",widget:p(g,m,b)},{name:"interrupt",widget:ue.createInterruptButton(g.sessionContext,b)},{name:"restart",widget:ue.createRestartButton(g.sessionContext,m,b)},{name:"restart-and-run",widget:n(g,m,b)},{name:"cellType",widget:c(g,b)},{name:"spacer",widget:xt.createSpacerItem()},{name:"kernelName",widget:ue.createKernelNameItem(g.sessionContext,m,b)}]}r.getDefaultItems=d})(_e||(_e={}));class Ho extends $e{constructor(e,i){super(),this.handleChange=a=>{a.target.value!=="-"&&(_.changeCellType(this._notebook,a.target.value),this._notebook.activate())},this.handleKeyDown=a=>{a.key==="Enter"&&this._notebook.activate()},this._trans=(i||O).load("jupyterlab"),this.addClass(Lo),this._notebook=e,e.model&&this.update(),e.activeCellChanged.connect(this.update,this),e.selectionChanged.connect(this.update,this)}render(){let e="-";this._notebook.activeCell&&(e=this._notebook.activeCell.model.type);for(const i of this._notebook.widgets)if(this._notebook.isSelectedOrActive(i)&&i.model.type!==e){e="-";break}return H.createElement(No,{className:Wo,onChange:this.handleChange,onKeyDown:this.handleKeyDown,value:e,"aria-label":this._trans.__("Cell type"),title:this._trans.__("Select the cell type")},H.createElement("option",{value:"-"},"-"),H.createElement("option",{value:"code"},this._trans.__("Code")),H.createElement("option",{value:"markdown"},this._trans.__("Markdown")),H.createElement("option",{value:"raw"},this._trans.__("Raw")))}}function He(r){var e;const i=r.translator||O,a=rt(i),s=i.load("jupyterlab"),l=(e=r.displayOption.showJumpToCell)!==null&&e!==void 0?e:!1,p=r.state,n=r.displayOption.showOnToolBar,c=r.displayOption.showProgress,d=n?"down":"up",g=A.createElement("div",null),[m,b]=A.useState(!1);if(A.useEffect(()=>{if(m)return;const j=()=>{b(!0)};return _.executionScheduled.connect(j),()=>{_.executionScheduled.disconnect(j)}},[l,m]),!p)return g;const f=p.kernelStatus,x={alignSelf:"normal",height:"24px"},o=p.totalTime,t=p.scheduledCellNumber||0,u=p.scheduledCell.size||0,C=t-u;let w=100*C/t,B=c?"":"hidden";!c&&w<100&&(w=0);const M=j=>A.createElement(Oo,{progress:j,width:16,height:24,label:s.__("Kernel status")}),K=j=>s.__("Kernel status: %1",j),V=()=>{const j=r.notebook;_.selectLastRunCell(j),j.activeCell&&j.scrollToCell(j.activeCell)},R=(j,$,P)=>A.createElement("div",{className:"jp-Notebook-ExecutionIndicator",title:c?"":K(a[j]),"data-status":j},$,A.createElement("div",{className:`jp-Notebook-ExecutionIndicator-tooltip ${d} ${B}`},A.createElement("span",null," ",K(a[j])," "),P,l&&m&&A.createElement(St,{className:"jp-Notebook-ExecutionIndicator-jumpButton",onClick:V,title:s.__("Jump to current or last executed cell")},s.__("Jump to cell"))));if(p.kernelStatus==="connecting"||p.kernelStatus==="disconnected"||p.kernelStatus==="unknown")return R(f,A.createElement(wt.react,{...x}),[]);if(p.kernelStatus==="starting"||p.kernelStatus==="terminating"||p.kernelStatus==="restarting"||p.kernelStatus==="initializing")return R(f,A.createElement(kt.react,{...x}),[]);if(p.executionStatus==="busy")return R("busy",M(w),[A.createElement("span",{key:0},s.__("Executed %1/%2 cells",C,t)),A.createElement("span",{key:1},s._n("Elapsed time: %1 second","Elapsed time: %1 seconds",o))]);{const j=p.kernelStatus==="busy"?0:100,$=p.kernelStatus==="busy"||o===0?[]:[A.createElement("span",{key:0},s._n("Executed %1 cell","Executed %1 cells",t)),A.createElement("span",{key:1},s._n("Elapsed time: %1 second","Elapsed time: %1 seconds",o))];return R(p.kernelStatus,M(j),$)}}class X extends we{constructor(e,i=!0){super(new X.Model),this.translator=e||O,this.addClass("jp-mod-highlighted")}render(){if(this.model===null||!this.model.renderFlag)return A.createElement("div",null);{const e=this.model.currentNotebook;return e?A.createElement(He,{displayOption:this.model.displayOption,state:this.model.executionState(e),translator:this.translator,notebook:e}):A.createElement(He,{displayOption:this.model.displayOption,state:void 0,translator:this.translator,notebook:void 0})}}}(function(r){class e extends ke{constructor(){super(),this._notebookExecutionProgress=new WeakMap,this._displayOption={showOnToolBar:!0,showProgress:!0,showJumpToCell:!1},this._renderFlag=!0}attachNotebook(l){var p,n,c,d;if(l&&l.content&&l.context){const g=l.content,m=l.context;if(this._currentNotebook=g,!this._notebookExecutionProgress.has(g)){this._notebookExecutionProgress.set(g,{executionStatus:"idle",kernelStatus:"idle",totalTime:0,interval:0,timeout:0,scheduledCell:new Set,scheduledCellNumber:0,needReset:!0});const b=this._notebookExecutionProgress.get(g),f=u=>{b&&(b.kernelStatus=u.kernelDisplayStatus),this.stateChanged.emit(void 0)};m.statusChanged.connect(f,this);const x=u=>{b&&(b.kernelStatus=u.kernelDisplayStatus),this.stateChanged.emit(void 0)};m.connectionStatusChanged.connect(x,this),m.disposed.connect(u=>{u.connectionStatusChanged.disconnect(x,this),u.statusChanged.disconnect(f,this)});const o=(u,C)=>{const w=C.msg,B=w.header.msg_id;if(w.header.msg_type==="execute_request")this._cellScheduledCallback(g,B);else if(Y.KernelMessage.isStatusMsg(w)&&w.content.execution_state==="idle"){const M=w.parent_header.msg_id;this._cellExecutedCallback(g,M)}else Y.KernelMessage.isStatusMsg(w)&&w.content.execution_state==="restarting"?this._restartHandler(g):w.header.msg_type==="execute_input"&&this._startTimer(g)};(n=(p=m.session)===null||p===void 0?void 0:p.kernel)===null||n===void 0||n.anyMessage.connect(o),(d=(c=m.session)===null||c===void 0?void 0:c.kernel)===null||d===void 0||d.disposed.connect(u=>u.anyMessage.disconnect(o));const t=(u,C)=>{b&&(this._resetTime(b),this.stateChanged.emit(void 0),C.newValue&&C.newValue.anyMessage.connect(o))};m.kernelChanged.connect(t),m.disposed.connect(u=>u.kernelChanged.disconnect(t))}}}get currentNotebook(){return this._currentNotebook}get displayOption(){return this._displayOption}set displayOption(l){this._displayOption=l}executionState(l){return this._notebookExecutionProgress.get(l)}_scheduleSwitchToIdle(l){window.setTimeout(()=>{l.executionStatus="idle",clearInterval(l.interval),this.stateChanged.emit(void 0)},150),l.timeout=window.setTimeout(()=>{l.needReset=!0},1e3)}_cellExecutedCallback(l,p){const n=this._notebookExecutionProgress.get(l);n&&n.scheduledCell.has(p)&&(n.scheduledCell.delete(p),n.scheduledCell.size===0&&this._scheduleSwitchToIdle(n))}_restartHandler(l){const p=this._notebookExecutionProgress.get(l);p&&(p.scheduledCell.clear(),this._scheduleSwitchToIdle(p))}_startTimer(l){const p=this._notebookExecutionProgress.get(l);p&&(p.scheduledCell.size>0?p.executionStatus!=="busy"&&(p.executionStatus="busy",clearTimeout(p.timeout),this.stateChanged.emit(void 0),p.interval=window.setInterval(()=>{this._tick(p)},1e3)):this._resetTime(p))}_cellScheduledCallback(l,p){const n=this._notebookExecutionProgress.get(l);n&&!n.scheduledCell.has(p)&&(n.needReset&&this._resetTime(n),n.scheduledCell.add(p),n.scheduledCellNumber+=1)}_tick(l){l.totalTime+=1,this.stateChanged.emit(void 0)}_resetTime(l){l.totalTime=0,l.scheduledCellNumber=0,l.executionStatus="idle",l.scheduledCell=new Set,clearTimeout(l.timeout),clearInterval(l.interval),l.needReset=!1}get renderFlag(){return this._renderFlag}updateRenderOption(l){this.displayOption.showOnToolBar&&(l.showOnToolBar?this._renderFlag=!0:this._renderFlag=!1),this.displayOption.showProgress=l.showProgress,this.displayOption.showJumpToCell=l.showJumpToCell,this.stateChanged.emit(void 0)}}r.Model=e;function i(s,l,p){const n=new r(l);return n.model.displayOption={showOnToolBar:!0,showProgress:!0,showJumpToCell:!1},n.model.attachNotebook({content:s.content,context:s.sessionContext}),p&&p.then(c=>{const d=g=>{const m=a(g);m.showJumpToCell&&(g.get("recordTiming").composite||g.set("recordTiming",!0).catch(f=>{console.error("Failed to auto-enable recordTiming:",f.message)})),n.model.updateRenderOption(m)};c.changed.connect(d),d(c),n.disposed.connect(()=>{c.changed.disconnect(d)})}).catch(c=>{console.error(c.message)}),n}r.createExecutionIndicatorItem=i;function a(s){let l=!0,p=!0,n=!1;const c=s.get("kernelStatus").composite;return c&&(l=!c.showOnStatusBar,p=c.showProgress,n=c.showJumpToRecentExecutionButton),{showOnToolBar:l,showProgress:p,showJumpToCell:n}}r.getSettingValue=a})(X||(X={}));function Fo(r){const e=(r.translator||O).load("jupyterlab");return H.createElement(at,{source:e.__("Mode: %1",r.modeNames[r.notebookMode])})}class re extends we{constructor(e){super(new re.Model),this.translator=e||O,this._trans=this.translator.load("jupyterlab"),this._modeNames={command:this._trans.__("Command"),edit:this._trans.__("Edit")}}render(){return this.model?(this.node.title=this._trans.__("Notebook is in %1 mode",this._modeNames[this.model.notebookMode]),H.createElement(Fo,{notebookMode:this.model.notebookMode,translator:this.translator,modeNames:this._modeNames})):null}}(function(r){class e extends ke{constructor(){super(...arguments),this._onChanged=a=>{const s=this._notebookMode;this._notebook?this._notebookMode=a.mode:this._notebookMode="command",this._triggerChange(s,this._notebookMode)},this._notebookMode="command",this._notebook=null}get notebookMode(){return this._notebookMode}set notebook(a){const s=this._notebook;s!==null&&(s.stateChanged.disconnect(this._onChanged,this),s.activeCellChanged.disconnect(this._onChanged,this),s.modelContentChanged.disconnect(this._onChanged,this));const l=this._notebookMode;this._notebook=a,this._notebook===null?this._notebookMode="command":(this._notebookMode=this._notebook.mode,this._notebook.stateChanged.connect(this._onChanged,this),this._notebook.activeCellChanged.connect(this._onChanged,this),this._notebook.modelContentChanged.connect(this._onChanged,this)),this._triggerChange(l,this._notebookMode)}_triggerChange(a,s){a!==s&&this.stateChanged.emit(void 0)}}r.Model=e})(re||(re={}));class Ko extends vo{constructor(e,i){super(e,i),this.editorWidget=e,this.options=i,this._type="code",this._readyDelegate=new At,this._editorToCell=new Map,this.editor=e.content,this._cellToEditor=new WeakMap,this.isReady=this.isReady.bind(this),Promise.all([this.widget.context.sessionContext.ready,this.connectionManager.ready]).then(async()=>{await this.initOnceReady(),this._readyDelegate.resolve()}).catch(console.error)}get documentPath(){return this.widget.context.path}get mimeType(){var e;let i,a=this.language_info();return!a||!a.mimetype?i=this.widget.content.codeMimetype:i=a.mimetype,Array.isArray(i)?(e=i[0])!==null&&e!==void 0?e:Mt.defaultMimeType:i}get languageFileExtension(){let e=this.language_info();if(!(!e||!e.file_extension))return e.file_extension.replace(".","")}get wrapperElement(){return this.widget.node}get editors(){if(this.isDisposed)return[];let e=this.widget.content;return this._editorToCell.clear(),e.isDisposed?[]:e.widgets.map(i=>({ceEditor:this._getCellEditor(i),type:i.model.type,value:i.model.sharedModel.getSource()}))}get activeEditor(){return this.editor.activeCell?this._getCellEditor(this.editor.activeCell):void 0}get ready(){return this._readyDelegate.promise}getEditorIndexAt(e){let i=this._getCellAt(e);return this.widget.content.widgets.findIndex(s=>i===s)}getEditorIndex(e){let i=this._editorToCell.get(e);return this.editor.widgets.findIndex(a=>i===a)}getEditorWrapper(e){return this._editorToCell.get(e).node}async onKernelChanged(e,i){if(i.newValue)try{const a=this._languageInfo;await Le(this.isReady,-1),await this._updateLanguageInfo();const s=this._languageInfo;a?.name!=s.name||a?.mimetype!=s?.mimetype||a?.file_extension!=s?.file_extension?(console.log(`Changed to ${this._languageInfo.name} kernel, reconnecting`),this.reloadConnection()):console.log("Keeping old LSP connection as the new kernel uses the same language")}catch(a){console.warn(a),this.reloadConnection()}}dispose(){this.isDisposed||(this.widget.context.sessionContext.kernelChanged.disconnect(this.onKernelChanged,this),this.widget.content.activeCellChanged.disconnect(this._activeCellChanged,this),super.dispose(),this._editorToCell.clear(),Tt.clearData(this))}isReady(){var e;return!this.widget.isDisposed&&this.widget.context.isReady&&this.widget.content.isVisible&&this.widget.content.widgets.length>0&&((e=this.widget.context.sessionContext.session)===null||e===void 0?void 0:e.kernel)!=null}async handleCellChange(e,i){let a=[],s=[];const l=this._type;if(i.type==="set"){let p=[],n=[];if(i.newValues.length===i.oldValues.length){for(let c=0;c<i.newValues.length;c++)i.oldValues[c].type===l&&i.newValues[c].type!==l?p.push(i.newValues[c]):i.oldValues[c].type!==l&&i.newValues[c].type===l&&n.push(i.newValues[c]);a=n,s=p}}else i.type=="add"&&(a=i.newValues.filter(p=>p.type===l));(s.length||a.length||i.type==="set"||i.type==="move"||i.type==="remove"||i.type==="clear")&&await this.updateDocuments();for(let p of a){let n=this.widget.content.widgets.find(c=>c.model.id===p.id);if(!n){console.warn(`Widget for added cell with ID: ${p.id} not found!`);continue}this._getCellEditor(n)}}createVirtualDocument(){return new fo({language:this.language,foreignCodeExtractors:this.options.foreignCodeExtractorsManager,path:this.documentPath,fileExtension:this.languageFileExtension,standalone:!1,hasLspSupportedFile:!1})}language_info(){return this._languageInfo}async initOnceReady(){await Le(this.isReady.bind(this),-1),await this._updateLanguageInfo(),this.initVirtual(),this.connectDocument(this.virtualDocument,!1).catch(console.warn),this.widget.context.sessionContext.kernelChanged.connect(this.onKernelChanged,this),this.widget.content.activeCellChanged.connect(this._activeCellChanged,this),this._connectModelSignals(this.widget),this.editor.modelChanged.connect(e=>{console.warn("Model changed, connecting cell change handler; this is not something we were expecting"),this._connectModelSignals(e)})}_connectModelSignals(e){e.model===null?console.warn(`Model is missing for notebook ${e}, cannot connect cell changed signal!`):e.model.cells.changed.connect(this.handleCellChange,this)}async _updateLanguageInfo(){var e,i,a,s;const l=(s=await((a=(i=(e=this.widget.context.sessionContext)===null||e===void 0?void 0:e.session)===null||i===void 0?void 0:i.kernel)===null||a===void 0?void 0:a.info))===null||s===void 0?void 0:s.language_info;if(l)this._languageInfo=l;else throw new Error("Language info update failed (no session, kernel, or info available)")}_activeCellChanged(e,i){!i||i.model.type!==this._type||this._activeEditorChanged.emit({editor:this._getCellEditor(i)})}_getCellAt(e){let i=this.virtualDocument.getEditorAtVirtualLine(e);return this._editorToCell.get(i)}_getCellEditor(e){if(!this._cellToEditor.has(e)){const i=Object.freeze({getEditor:()=>e.editor,ready:async()=>(await e.ready,e.editor),reveal:async()=>(await this.editor.scrollToCell(e),e.editor)});this._cellToEditor.set(e,i),this._editorToCell.set(i,e),e.disposed.connect(()=>{this._cellToEditor.delete(e),this._editorToCell.delete(i),this._editorRemoved.emit({editor:i})}),this._editorAdded.emit({editor:i})}return this._cellToEditor.get(e)}}class Vo extends Z{constructor(){super(),this._items=[],this.layout=new pe,this.addClass("jp-RankedPanel")}addWidget(e,i){const a={widget:e,rank:i},s=ie.upperBound(this._items,a,ye.itemCmp);ie.insert(this._items,s,a),this.layout.insertWidget(s,e)}onChildRemoved(e){const i=ie.findFirstIndex(this._items,a=>a.widget===e.child);i!==-1&&ie.removeAt(this._items,i)}}class q extends Z{constructor(e){super(),this.addClass("jp-NotebookTools"),this.translator=e.translator||O,this._tools=[],this.layout=new pe,this._tracker=e.tracker,this._tracker.currentChanged.connect(this._onActiveNotebookPanelChanged,this),this._tracker.activeCellChanged.connect(this._onActiveCellChanged,this),this._tracker.selectionChanged.connect(this._onSelectionChanged,this),this._onActiveNotebookPanelChanged(),this._onActiveCellChanged(),this._onSelectionChanged()}get activeCell(){return this._tracker.activeCell}get selectedCells(){const e=this._tracker.currentWidget;if(!e)return[];const i=e.content;return i.widgets.filter(a=>i.isSelectedOrActive(a))}get activeNotebookPanel(){return this._tracker.currentWidget}addItem(e){var i;const a=e.tool,s=(i=e.rank)!==null&&i!==void 0?i:100;let l;const p=this._tools.find(n=>n.section===e.section);if(p)l=p.panel;else throw new Error(`The section ${e.section} does not exist`);a.addClass("jp-NotebookTools-tool"),l.addWidget(a,s),a.notebookTools=this,G.sendMessage(a,q.ActiveNotebookPanelMessage),G.sendMessage(a,q.ActiveCellMessage)}addSection(e){var i;const a=e.sectionName,s=e.label||e.sectionName,l=e.tool;let p=(i=e.rank)!==null&&i!==void 0?i:null;const n=new Vo;if(n.title.label=s,l&&n.addWidget(l,0),this._tools.push({section:a,panel:n,rank:p}),p!=null)this.layout.insertWidget(p,new de({widget:n}));else{let c=null;const d=this.layout;for(let g=0;g<d.widgets.length;g++){let m=d.widgets[g];if(m instanceof de&&m.widget.id==="advancedToolsSection"){c=g;break}}c!==null?this.layout.insertWidget(c,new de({widget:n})):this.layout.addWidget(new de({widget:n}))}}_onActiveNotebookPanelChanged(){this._prevActiveNotebookModel&&!this._prevActiveNotebookModel.isDisposed&&this._prevActiveNotebookModel.metadataChanged.disconnect(this._onActiveNotebookPanelMetadataChanged,this);const e=this.activeNotebookPanel&&this.activeNotebookPanel.content?this.activeNotebookPanel.content.model:null;this._prevActiveNotebookModel=e,e&&e.metadataChanged.connect(this._onActiveNotebookPanelMetadataChanged,this);for(const i of this._toolChildren())G.sendMessage(i,q.ActiveNotebookPanelMessage)}_onActiveCellChanged(){this._prevActiveCell&&!this._prevActiveCell.isDisposed&&this._prevActiveCell.metadataChanged.disconnect(this._onActiveCellMetadataChanged,this);const e=this.activeCell?this.activeCell.model:null;this._prevActiveCell=e,e&&e.metadataChanged.connect(this._onActiveCellMetadataChanged,this);for(const i of this._toolChildren())G.sendMessage(i,q.ActiveCellMessage)}_onSelectionChanged(){for(const e of this._toolChildren())G.sendMessage(e,q.SelectionMessage)}_onActiveNotebookPanelMetadataChanged(e,i){const a=new he.ChangeMessage("activenotebookpanel-metadata-changed",{oldValue:void 0,newValue:void 0,...i});for(const s of this._toolChildren())G.sendMessage(s,a)}_onActiveCellMetadataChanged(e,i){const a=new he.ChangeMessage("activecell-metadata-changed",{newValue:void 0,oldValue:void 0,...i});for(const s of this._toolChildren())G.sendMessage(s,a)}*_toolChildren(){for(let e of this._tools)yield*e.panel.children()}}(function(r){r.ActiveNotebookPanelMessage=new Ce("activenotebookpanel-changed"),r.ActiveCellMessage=new Ce("activecell-changed"),r.SelectionMessage=new Ce("selection-changed");class e extends Z{dispose(){super.dispose(),this.notebookTools&&(this.notebookTools=null)}processMessage(s){switch(super.processMessage(s),s.type){case"activenotebookpanel-changed":this.onActiveNotebookPanelChanged(s);break;case"activecell-changed":this.onActiveCellChanged(s);break;case"selection-changed":this.onSelectionChanged(s);break;case"activecell-metadata-changed":this.onActiveCellMetadataChanged(s);break;case"activenotebookpanel-metadata-changed":this.onActiveNotebookPanelMetadataChanged(s);break}}onActiveNotebookPanelChanged(s){}onActiveCellChanged(s){}onSelectionChanged(s){}onActiveCellMetadataChanged(s){}onActiveNotebookPanelMetadataChanged(s){}}r.Tool=e;class i extends e{constructor(s){super();const{editorFactory:l}=s;this.addClass("jp-MetadataEditorTool");const p=this.layout=new pe;this._editorFactory=l,this._editorLabel=s.label||"Edit Metadata",this.createEditor();const n=new Z({node:document.createElement("label")});n.node.textContent=s.label||"Edit Metadata",p.addWidget(n),p.addWidget(this.editor)}get editor(){return this._editor}onActiveNotebookPanelChanged(s){this.editor.dispose(),this.notebookTools.activeNotebookPanel&&this.createEditor()}createEditor(){this._editor=new Po({editorFactory:this._editorFactory}),this.editor.title.label=this._editorLabel,this.layout.addWidget(this.editor)}}r.MetadataEditorTool=i})(q||(q={}));var ye;(function(r){function e(i,a){return i.rank-a.rank}r.itemCmp=e})(ye||(ye={}));const Uo=6;var W;(function(r){r[r.Idle=-1]="Idle",r[r.Error=-.5]="Error",r[r.Scheduled=0]="Scheduled",r[r.Running=1]="Running"})(W||(W={}));class qo extends To{constructor(e,i,a,s){super(e,s),this.parser=i,this.sanitizer=a,this.configMetadataMap={numberHeaders:["toc-autonumbering","toc/number_sections"],numberingH1:["!toc/skip_h1_title"],baseNumbering:["toc/base_numbering"]},this._runningCells=new Array,this._errorCells=new Array,this._cellToHeadingIndex=new WeakMap,e.context.ready.then(()=>{this.setConfiguration({})}),this.widget.context.model.metadataChanged.connect(this.onMetadataChanged,this),this.widget.content.activeCellChanged.connect(this.onActiveCellChanged,this),_.executionScheduled.connect(this.onExecutionScheduled,this),_.executed.connect(this.onExecuted,this),_.outputCleared.connect(this.onOutputCleared,this),this.headingsChanged.connect(this.onHeadingsChanged,this)}get documentType(){return"notebook"}get isAlwaysActive(){return!0}get supportedOptions(){return["baseNumbering","maximalDepth","numberingH1","numberHeaders","includeOutput","syncCollapseState"]}getCellHeadings(e){const i=new Array;let a=this._cellToHeadingIndex.get(e);if(a!==void 0){const s=this.headings[a];for(i.push(s);this.headings[a-1]&&this.headings[a-1].cellRef===s.cellRef;)a--,i.unshift(this.headings[a])}return i}dispose(){var e,i,a;this.isDisposed||(this.headingsChanged.disconnect(this.onHeadingsChanged,this),(i=(e=this.widget.context)===null||e===void 0?void 0:e.model)===null||i===void 0||i.metadataChanged.disconnect(this.onMetadataChanged,this),(a=this.widget.content)===null||a===void 0||a.activeCellChanged.disconnect(this.onActiveCellChanged,this),_.executionScheduled.disconnect(this.onExecutionScheduled,this),_.executed.disconnect(this.onExecuted,this),_.outputCleared.disconnect(this.onOutputCleared,this),this._runningCells.length=0,this._errorCells.length=0,super.dispose())}setConfiguration(e){const i=this.loadConfigurationFromMetadata();super.setConfiguration({...this.configuration,...i,...e})}toggleCollapse(e){super.toggleCollapse(e),this.updateRunningStatus(this.headings)}async getHeadings(){const e=this.widget.content.widgets,i=new Set(e),a=[],s=new Array,l=new WeakMap;for(let p=0;p<e.length;p++){const n=e[p];switch(n.model.type){case"code":{!this.configuration.syncCollapseState&&this.configuration.includeOutput&&a.push(...Ie(await n.getHeadings(),this.configuration,s).map(d=>({...d,cellRef:n,collapsed:!1,isRunning:W.Idle})));break}case"markdown":{const d=Ie(await n.getHeadings(),this.configuration,s).map((g,m)=>({...g,cellRef:n,collapsed:!1,isRunning:W.Idle}));if(this.configuration.syncCollapseState&&n.headingCollapsed){const g=Math.min(...d.map(b=>b.level)),m=d.find(b=>b.level===g);m.collapsed=n.headingCollapsed}a.push(...d);break}}a.length>0&&l.set(n,a.length-1)}return this._cellToHeadingIndex=l,this._runningCells=this._runningCells.filter(p=>i.has(p)),this._errorCells=this._errorCells.filter(p=>i.has(p)),this.updateRunningStatus(a),Promise.resolve(a)}isHeadingEqual(e,i){return super.isHeadingEqual(e,i)&&e.cellRef===i.cellRef&&e.isRunning===i.isRunning}loadConfigurationFromMetadata(){const e=this.widget.content.model,i={};if(e)for(const a in this.configMetadataMap){const s=this.configMetadataMap[a];for(const l of s){let p=l;const n=p[0]==="!";n&&(p=p.slice(1));const c=p.split("/");let d=e.getMetadata(c[0]);for(let g=1;g<c.length;g++)d=(d??{})[c[g]];d!==void 0&&(typeof d=="boolean"&&n&&(d=!d),i[a]=d)}}return i}onActiveCellChanged(e,i){const a=this.getCellHeadings(i)[0];this.setActiveHeading(a??null,!1)}onHeadingsChanged(){this.widget.content.activeCell&&this.onActiveCellChanged(this.widget.content,this.widget.content.activeCell)}onExecuted(e,i){this._runningCells.forEach((a,s)=>{var l;if(a===i.cell){this._runningCells.splice(s,1);const p=this._cellToHeadingIndex.get(a);if(p!==void 0){const n=this.headings[p];if(i.success||((l=i.error)===null||l===void 0?void 0:l.errorName)===void 0){n.isRunning=W.Idle;return}n.isRunning=W.Error,this._errorCells.includes(a)||this._errorCells.push(a)}}}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onExecutionScheduled(e,i){this._runningCells.includes(i.cell)||this._runningCells.push(i.cell),this._errorCells.forEach((a,s)=>{a===i.cell&&this._errorCells.splice(s,1)}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onOutputCleared(e,i){this._errorCells.forEach((a,s)=>{if(a===i.cell){this._errorCells.splice(s,1);const l=this._cellToHeadingIndex.get(a);if(l!==void 0){const p=this.headings[l];p.isRunning=W.Idle}}}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onMetadataChanged(){this.setConfiguration({})}updateRunningStatus(e){e.forEach(s=>{s.isRunning=W.Idle}),this._runningCells.forEach((s,l)=>{const p=this._cellToHeadingIndex.get(s);if(p!==void 0){const n=e[p];n.isRunning!==W.Running&&(n.isRunning=l>0?W.Scheduled:W.Running)}}),this._errorCells.forEach((s,l)=>{const p=this._cellToHeadingIndex.get(s);if(p!==void 0){const n=e[p];n.isRunning===W.Idle&&(n.isRunning=W.Error)}});let i=0;for(;i<e.length;){const s=e[i];if(i++,s.collapsed){const l=Math.max(s.isRunning,a(e,s.level));s.dataset={...s.dataset,"data-running":l.toString()}}else s.dataset={...s.dataset,"data-running":s.isRunning.toString()}}function a(s,l){let p=W.Idle;for(;i<s.length;){const n=s[i];if(n.dataset={...n.dataset,"data-running":n.isRunning.toString()},n.level>l)i++,p=Math.max(n.isRunning,p),n.collapsed&&(p=Math.max(p,a(s,n.level)),n.dataset={...n.dataset,"data-running":p.toString()});else break}return p}}}class $o extends Mo{constructor(e,i,a,s){super(e),this.parser=i,this.sanitizer=a,this.commands=s,this._scrollToTop=!0}get scrollToTop(){return this._scrollToTop}set scrollToTop(e){this._scrollToTop=e}_createNew(e,i){const a=new qo(e,this.parser,this.sanitizer,i);let s=new WeakMap;const l=(m,b)=>{if(b){const f=async u=>{if(!u.inViewport)return;const C=s.get(b);if(C)if(this.scrollToTop)C.scrollIntoView({block:"start"}),e.content.outerNode.scrollTop-=Uo;else{const w=e.content.node.getBoundingClientRect(),B=C.getBoundingClientRect();(B.top>w.bottom||B.bottom<w.top)&&C.scrollIntoView({block:"center"})}else console.debug("scrolling to heading: using fallback strategy"),await e.content.scrollToItem(e.content.activeCellIndex,this.scrollToTop?"start":void 0,0)},x=b.cellRef,t=e.content.widgets.indexOf(x);x.model.type=="markdown"&&e.content.mode!="command"&&(e.content.mode="command"),e.content.activeCellIndex=t,x.inViewport?f(x).catch(u=>{console.error(`Fail to scroll to cell to display the required heading (${u}).`)}):e.content.scrollToItem(t,this.scrollToTop?"start":void 0).then(()=>p(x)).then(()=>f(x)).catch(u=>{console.error(`Fail to scroll to cell to display the required heading (${u}).`)})}},p=m=>Promise.all(a.getCellHeadings(m).map(async b=>{var f,x,o;const t=await Jo(b,this.parser,this.sanitizer),u=(f=this.sanitizer.allowNamedProperties)!==null&&f!==void 0&&f?"id":"data-jupyter-id",C=t?`h${b.level}[${u}="${CSS.escape(t)}"]`:`h${b.level}`;b.outputIndex!==void 0?s.set(b,je(b.cellRef.outputArea.widgets[b.outputIndex].node,C,(x=b.prefix)!==null&&x!==void 0?x:"")):s.set(b,je(b.cellRef.node,C,(o=b.prefix)!==null&&o!==void 0?o:""))})).then(()=>{}),n=m=>{if(this.parser)return Re(e.content.node),s=new WeakMap,Promise.all(e.content.widgets.map(b=>p(b)))},c=(m,b)=>{var f,x,o,t;if(a.configuration.syncCollapseState)if(b!==null){const u=b.cellRef;u.headingCollapsed!==((f=b.collapsed)!==null&&f!==void 0?f:!1)&&(u.headingCollapsed=(x=b.collapsed)!==null&&x!==void 0?x:!1)}else{const u=(t=(o=a.headings[0])===null||o===void 0?void 0:o.collapsed)!==null&&t!==void 0?t:!1;e.content.widgets.forEach(C=>{C instanceof le&&C.headingInfo.level>=0&&(C.headingCollapsed=u)})}},d=(m,b)=>{if(a.configuration.syncCollapseState){const f=a.getCellHeadings(b)[0];f&&a.toggleCollapse({heading:f,collapsed:b.headingCollapsed})}},g=(m,b)=>{var f;b.inViewport?(f=p(b))===null||f===void 0||f.catch(console.warn):Re(b.node)};return e.context.ready.then(()=>{var m;(m=n())===null||m===void 0||m.catch(console.warn),a.activeHeadingChanged.connect(l),a.headingsChanged.connect(n),a.collapseChanged.connect(c),e.content.cellCollapsed.connect(d),e.content.cellInViewportChanged.connect(g),e.disposed.connect(()=>{a.activeHeadingChanged.disconnect(l),a.headingsChanged.disconnect(n),a.collapseChanged.disconnect(c),e.content.cellCollapsed.disconnect(d),e.content.cellInViewportChanged.disconnect(g)})}),a}getToolbarItems(e){return this.commands?[{name:"select-last-modified-back",widget:new Oe({commands:this.commands,id:"notebook:select-last-modified-cell",args:{toolbar:!0},icon:Bt,label:""})},{name:"select-last-modified-forward",widget:new Oe({commands:this.commands,id:"notebook:select-next-modified-cell",args:{toolbar:!0},icon:Et,label:""})}]:[]}}async function Jo(r,e,i){let a=null;return r.type===Pe.HeadingType.Markdown?a=await Nt(e,r.raw,r.level,i):r.type===Pe.HeadingType.HTML&&(a=r.id),a}const Do="jp-StatusItem-trust";function zo(r,e){e=e||O;const i=e.load("jupyterlab");return r.trustedCells===r.totalCells?i.__("Notebook trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells):r.activeCellTrusted?i.__("Active cell trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells):i.__("Notebook not trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells)}function Go(r){return r.allCellsTrusted?A.createElement(Ot.react,{top:"2px",stylesheet:"statusBar"}):A.createElement(jt.react,{top:"2px",stylesheet:"statusBar"})}class ae extends we{constructor(e){super(new ae.Model),this.translator=e||O,this.node.classList.add(Do)}render(){if(!this.model)return null;const e=zo(this.model,this.translator);return e!==this.node.title&&(this.node.title=e),A.createElement(Go,{allCellsTrusted:this.model.trustedCells===this.model.totalCells,activeCellTrusted:this.model.activeCellTrusted,totalCells:this.model.totalCells,trustedCells:this.model.trustedCells})}}(function(r){class e extends ke{constructor(){super(...arguments),this._trustedCells=0,this._totalCells=0,this._activeCellTrusted=!1,this._notebook=null}get trustedCells(){return this._trustedCells}get totalCells(){return this._totalCells}get activeCellTrusted(){return this._activeCellTrusted}get notebook(){return this._notebook}set notebook(a){const s=this._notebook;s!==null&&(s.activeCellChanged.disconnect(this._onActiveCellChanged,this),s.modelContentChanged.disconnect(this._onModelChanged,this));const l=this._getAllState();if(this._notebook=a,this._notebook===null)this._trustedCells=0,this._totalCells=0,this._activeCellTrusted=!1;else{this._notebook.activeCellChanged.connect(this._onActiveCellChanged,this),this._notebook.modelContentChanged.connect(this._onModelChanged,this),this._notebook.activeCell?this._activeCellTrusted=this._notebook.activeCell.model.trusted:this._activeCellTrusted=!1;const{total:p,trusted:n}=this._deriveCellTrustState(this._notebook.model);this._totalCells=p,this._trustedCells=n}this._triggerChange(l,this._getAllState())}_onModelChanged(a){const s=this._getAllState(),{total:l,trusted:p}=this._deriveCellTrustState(a.model);this._totalCells=l,this._trustedCells=p,this._triggerChange(s,this._getAllState())}_onActiveCellChanged(a,s){const l=this._getAllState();s?this._activeCellTrusted=s.model.trusted:this._activeCellTrusted=!1,this._triggerChange(l,this._getAllState())}_deriveCellTrustState(a){if(a===null)return{total:0,trusted:0};let s=0,l=0;for(const p of a.cells)p.type==="code"&&(s++,p.trusted&&l++);return{total:s,trusted:l}}_getAllState(){return[this._trustedCells,this._totalCells,this.activeCellTrusted]}_triggerChange(a,s){(a[0]!==s[0]||a[1]!==s[1]||a[2]!==s[2])&&this.stateChanged.emit(void 0)}}r.Model=e})(ae||(ae={}));const Yo=new Qe("@jupyterlab/metadataform:IMetadataFormProvider","A service to register new metadata editor widgets."),Xo={id:"@jupyterlab/notebook-extension:cell-executor",description:"Provides the notebook cell executor.",autoStart:!0,provides:tt,activate:()=>Object.freeze({runCell:Rt})},Qo=new Qe("@jupyterlab/logconsole:ILoggerRegistry","A service providing a logger infrastructure."),Zo={activate:en,id:"@jupyterlab/notebook-extension:log-output",description:"Adds cell outputs log to the application logger.",requires:[I],optional:[Qo],autoStart:!0};function en(r,e,i){if(!i)return;function a(s){function l(p,n,c){if(Y.KernelMessage.isDisplayDataMsg(p)||Y.KernelMessage.isStreamMsg(p)||Y.KernelMessage.isErrorMsg(p)||Y.KernelMessage.isExecuteResultMsg(p)){const d=i.getLogger(s.context.path);d.rendermime=s.content.rendermime;const g={...p.content,output_type:p.header.msg_type};let m=n;(Y.KernelMessage.isErrorMsg(p)||Y.KernelMessage.isStreamMsg(p)&&p.content.name==="stderr")&&(m=c),d.log({type:"output",data:g,level:m})}}s.context.sessionContext.iopubMessage.connect((p,n)=>l(n,"info","info")),s.context.sessionContext.unhandledMessage.connect((p,n)=>l(n,"warning","error"))}e.forEach(s=>a(s)),e.widgetAdded.connect((s,l)=>a(l))}const tn="jp-ActiveCellTool",on="jp-ActiveCellTool-Content",nn="jp-ActiveCellTool-CellContent";class ln extends q.Tool{constructor(e){super();const{languages:i}=e;this._tracker=e.tracker,this.addClass(tn),this.layout=new pe,this._inputPrompt=new It,this.layout.addWidget(this._inputPrompt);const a=document.createElement("div");a.classList.add(on);const s=a.appendChild(document.createElement("div")),l=s.appendChild(document.createElement("pre"));s.className=nn,this._editorEl=l,this.layout.addWidget(new Z({node:a}));const p=async()=>{var n,c;this._editorEl.innerHTML="",((n=this._cellModel)===null||n===void 0?void 0:n.type)==="code"?(this._inputPrompt.executionCount=`${(c=this._cellModel.executionCount)!==null&&c!==void 0?c:""}`,this._inputPrompt.show()):(this._inputPrompt.executionCount=null,this._inputPrompt.hide()),this._cellModel&&await i.highlight(this._cellModel.sharedModel.getSource().split(`
|
|
2
2
|
`)[0],i.findByMIME(this._cellModel.mimeType),this._editorEl)};this._refreshDebouncer=new Pt(p,150)}render(e){var i,a;const s=this._tracker.activeCell;return s&&(this._cellModel=s?.model||null),((i=this._cellModel)===null||i===void 0?void 0:i.sharedModel).changed.connect(this.refresh,this),(a=this._cellModel)===null||a===void 0||a.mimeTypeChanged.connect(this.refresh,this),this.refresh().then(()=>{}).catch(()=>{}),A.createElement("div",{ref:l=>l?.appendChild(this.node)})}async refresh(){await this._refreshDebouncer.invoke()}}const sn="jp-CellMetadataEditor",rn="jp-NotebookMetadataEditor";class an extends q.MetadataEditorTool{constructor(e){super(e),this._tracker=e.tracker,this.editor.editorHostNode.addEventListener("blur",this.editor,!0),this.editor.editorHostNode.addEventListener("click",this.editor,!0),this.editor.headerNode.addEventListener("click",this.editor)}_onSourceChanged(){var e,i,a;const s=(e=this._tracker.activeCell)===null||e===void 0?void 0:e.model.sharedModel;if(s&&this.editor.source){const l=Object.keys((i=s.metadata)!==null&&i!==void 0?i:{}),p=(a=this.editor.source.toJSON())!==null&&a!==void 0?a:{};s.transact(()=>{l.forEach(n=>s.deleteMetadata(n)),s.setMetadata(p)})}}render(e){var i;const a=this._tracker.activeCell;return this.editor.source=a?new he({values:a.model.metadata}):null,(i=this.editor.source)===null||i===void 0||i.changed.connect(this._onSourceChanged,this),A.createElement("div",{className:sn},A.createElement("div",{ref:s=>s?.appendChild(this.node)}))}}class dn extends q.MetadataEditorTool{constructor(e){super(e),this._tracker=e.tracker,this.editor.editorHostNode.addEventListener("blur",this.editor,!0),this.editor.editorHostNode.addEventListener("click",this.editor,!0),this.editor.headerNode.addEventListener("click",this.editor)}_onSourceChanged(){var e,i;this.editor.source&&((i=(e=this._tracker.currentWidget)===null||e===void 0?void 0:e.model)===null||i===void 0||i.sharedModel.setMetadata(this.editor.source.toJSON()))}render(e){var i,a;const s=this._tracker.currentWidget;return this.editor.source=s?new he({values:(i=s.model)===null||i===void 0?void 0:i.metadata}):null,(a=this.editor.source)===null||a===void 0||a.changed.connect(this._onSourceChanged,this),A.createElement("div",{className:rn},A.createElement("div",{ref:l=>l?.appendChild(this.node)}))}}var h;(function(r){r.createNew="notebook:create-new",r.interrupt="notebook:interrupt-kernel",r.restart="notebook:restart-kernel",r.restartClear="notebook:restart-clear-output",r.restartAndRunToSelected="notebook:restart-and-run-to-selected",r.restartRunAll="notebook:restart-run-all",r.reconnectToKernel="notebook:reconnect-to-kernel",r.changeKernel="notebook:change-kernel",r.getKernel="notebook:get-kernel",r.createConsole="notebook:create-console",r.createSubshellConsole="notebook:create-subshell-console",r.createOutputView="notebook:create-output-view",r.clearAllOutputs="notebook:clear-all-cell-outputs",r.shutdown="notebook:shutdown-kernel",r.closeAndShutdown="notebook:close-and-shutdown",r.trust="notebook:trust",r.exportToFormat="notebook:export-to-format",r.run="notebook:run-cell",r.runAndAdvance="notebook:run-cell-and-select-next",r.runAndInsert="notebook:run-cell-and-insert-below",r.runInConsole="notebook:run-in-console",r.runAll="notebook:run-all-cells",r.runAllAbove="notebook:run-all-above",r.runAllBelow="notebook:run-all-below",r.renderAllMarkdown="notebook:render-all-markdown",r.toCode="notebook:change-cell-to-code",r.toMarkdown="notebook:change-cell-to-markdown",r.toRaw="notebook:change-cell-to-raw",r.cut="notebook:cut-cell",r.copy="notebook:copy-cell",r.pasteAbove="notebook:paste-cell-above",r.pasteBelow="notebook:paste-cell-below",r.duplicateBelow="notebook:duplicate-below",r.pasteAndReplace="notebook:paste-and-replace-cell",r.moveUp="notebook:move-cell-up",r.moveDown="notebook:move-cell-down",r.clearOutputs="notebook:clear-cell-output",r.deleteCell="notebook:delete-cell",r.insertAbove="notebook:insert-cell-above",r.insertBelow="notebook:insert-cell-below",r.selectAbove="notebook:move-cursor-up",r.selectBelow="notebook:move-cursor-down",r.selectHeadingAboveOrCollapse="notebook:move-cursor-heading-above-or-collapse",r.selectHeadingBelowOrExpand="notebook:move-cursor-heading-below-or-expand",r.insertHeadingAbove="notebook:insert-heading-above",r.insertHeadingBelow="notebook:insert-heading-below",r.extendAbove="notebook:extend-marked-cells-above",r.extendTop="notebook:extend-marked-cells-top",r.extendBelow="notebook:extend-marked-cells-below",r.extendBottom="notebook:extend-marked-cells-bottom",r.selectAll="notebook:select-all",r.deselectAll="notebook:deselect-all",r.editMode="notebook:enter-edit-mode",r.merge="notebook:merge-cells",r.mergeAbove="notebook:merge-cell-above",r.mergeBelow="notebook:merge-cell-below",r.split="notebook:split-cell-at-cursor",r.commandMode="notebook:enter-command-mode",r.toggleAllLines="notebook:toggle-all-cell-line-numbers",r.undoCellAction="notebook:undo-cell-action",r.redoCellAction="notebook:redo-cell-action",r.redo="notebook:redo",r.undo="notebook:undo",r.markdown1="notebook:change-cell-to-heading-1",r.markdown2="notebook:change-cell-to-heading-2",r.markdown3="notebook:change-cell-to-heading-3",r.markdown4="notebook:change-cell-to-heading-4",r.markdown5="notebook:change-cell-to-heading-5",r.markdown6="notebook:change-cell-to-heading-6",r.hideCode="notebook:hide-cell-code",r.showCode="notebook:show-cell-code",r.hideAllCode="notebook:hide-all-cell-code",r.showAllCode="notebook:show-all-cell-code",r.hideOutput="notebook:hide-cell-outputs",r.showOutput="notebook:show-cell-outputs",r.toggleOutput="notebook:toggle-cell-outputs",r.hideAllOutputs="notebook:hide-all-cell-outputs",r.showAllOutputs="notebook:show-all-cell-outputs",r.toggleRenderSideBySideCurrentNotebook="notebook:toggle-render-side-by-side-current",r.setSideBySideRatio="notebook:set-side-by-side-ratio",r.enableOutputScrolling="notebook:enable-output-scrolling",r.disableOutputScrolling="notebook:disable-output-scrolling",r.selectLastRunCell="notebook:select-last-run-cell",r.replaceSelection="notebook:replace-selection",r.autoClosingBrackets="notebook:toggle-autoclosing-brackets",r.toggleCollapseCmd="notebook:toggle-heading-collapse",r.collapseAllCmd="notebook:collapse-all-headings",r.expandAllCmd="notebook:expand-all-headings",r.copyToClipboard="notebook:copy-to-clipboard",r.invokeCompleter="completer:invoke-notebook",r.selectCompleter="completer:select-notebook",r.tocRunCells="toc:run-cells",r.accessPreviousHistory="notebook:access-previous-history-entry",r.accessNextHistory="notebook:access-next-history-entry",r.virtualScrollbar="notebook:toggle-virtual-scrollbar"})(h||(h={}));const J="Notebook",cn=["notebook","python","custom"],un="@jupyterlab/notebook-extension:panel",Fe="jp-NotebookExtension-sideBySideMargins",ee={id:"@jupyterlab/notebook-extension:tracker",description:"Provides the notebook widget tracker.",provides:I,requires:[ot,io,tt],optional:[Ve,ao,co,it,lt,uo,be,Ue,F,Ae,nt],activate:Ln,autoStart:!0},hn={id:"@jupyterlab/notebook-extension:factory",description:"Provides the notebook cell factory.",provides:fe.IContentFactory,requires:[ge],autoStart:!0,activate:(r,e)=>{const i=e.factoryService.newInlineEditor;return new fe.ContentFactory({editorFactory:i})}},pn={activate:On,provides:ro,id:"@jupyterlab/notebook-extension:tools",description:"Provides the notebook tools.",autoStart:!0,requires:[I,ge,et,Lt.IStateDB,F],optional:[so]},gn={id:"@jupyterlab/notebook-extension:mode-status",description:"Adds a notebook mode status widget.",autoStart:!0,requires:[I,F],optional:[Se],activate:(r,e,i,a)=>{if(!a)return;const{shell:s}=r,l=new re(i);e.currentChanged.connect(()=>{const p=e.currentWidget;l.model.notebook=p&&p.content}),a.registerStatusItem("@jupyterlab/notebook-extension:mode-status",{priority:1,item:l,align:"right",rank:4,isActive:()=>!!s.currentWidget&&!!e.currentWidget&&s.currentWidget===e.currentWidget})}},bn={id:"@jupyterlab/notebook-extension:execution-indicator",description:"Adds a notebook execution status widget.",autoStart:!0,requires:[I,ho,F],optional:[Se,be],activate:(r,e,i,a,s,l)=>{let p,n,c;const d=g=>{var m,b;let{showOnToolBar:f,showProgress:x,showJumpToCell:o}=g;if(f)c&&(i.currentChanged.disconnect(n),c.dispose());else{if(!s)return;p?.model||(p=new X(a),n=(t,u)=>{const{newValue:C}=u;if(C&&e.has(C)){const w=C;p.model.attachNotebook({content:w.content,context:w.sessionContext})}},c=s.registerStatusItem("@jupyterlab/notebook-extension:execution-indicator",{item:p,align:"left",rank:3,isActive:()=>{const t=i.currentWidget;return!!t&&e.has(t)}}),p.model.attachNotebook({content:(m=e.currentWidget)===null||m===void 0?void 0:m.content,context:(b=e.currentWidget)===null||b===void 0?void 0:b.sessionContext}),i.currentChanged.connect(n),p.disposed.connect(()=>{i.currentChanged.disconnect(n)})),p.model.displayOption={showOnToolBar:f,showProgress:x,showJumpToCell:o}}};if(l){const g=l.load(ee.id);Promise.all([g,r.restored]).then(([m])=>{d(X.getSettingValue(m)),m.changed.connect(b=>d(X.getSettingValue(b)))}).catch(m=>{console.error(m.message)})}}},mn={id:"@jupyterlab/notebook-extension:export",description:"Adds the export notebook commands.",autoStart:!0,requires:[F,I],optional:[lt,Ve],activate:(r,e,i,a,s)=>{var l;const p=e.load("jupyterlab"),{commands:n,shell:c}=r,d=r.serviceManager,g=()=>L.isEnabled(c,i);n.addCommand(h.exportToFormat,{label:x=>{if(x.label===void 0)return p.__("Save and Export Notebook to the given `format`.");const o=x.label;return x.isPalette?p.__("Save and Export Notebook: %1",o):o},execute:async x=>{var o,t;const u=v(i,c,x);if(!u)return;const{context:C}=u,w={format:x.format,path:u.context.path,exporterOptions:{download:!0}};return C.model.dirty&&!C.model.readOnly&&await C.save(),(t=(o=d.nbconvert).exportAs)===null||t===void 0?void 0:t.call(o,w)},isEnabled:g,describedBy:{args:{type:"object",properties:{format:{type:"string",description:p.__("The export format (e.g., pdf, html, latex)")},label:{type:"string",description:p.__("The label to display for this format")},isPalette:{type:"boolean",description:p.__("Whether the command is called from the command palette")}},required:["format"]}}});let m;a&&(m=(l=a.fileMenu.items.find(x=>{var o;return x.type==="submenu"&&((o=x.submenu)===null||o===void 0?void 0:o.id)==="jp-mainmenu-file-notebookexport"}))===null||l===void 0?void 0:l.submenu);let b=!1;const f=async()=>{if(b)return;i.widgetAdded.disconnect(f),b=!0;const x=await d.nbconvert.getExportFormats(!1);if(!x)return;const o=L.getFormatLabels(e);Object.keys(x).forEach(function(u){const C=p.__(u[0].toUpperCase()+u.substr(1)),w=o[u]?o[u]:C;let B={format:u,label:w,isPalette:!1};if(cn.indexOf(u)===-1&&(m&&m.addItem({command:h.exportToFormat,args:B}),s)){B={format:u,label:w,isPalette:!0};const M=p.__("Notebook Operations");s.addItem({command:h.exportToFormat,category:M,args:B})}})};i.widgetAdded.connect(f)}},Cn={id:"@jupyterlab/notebook-extension:trust-status",description:"Adds the notebook trusted status widget.",autoStart:!0,requires:[I,F],optional:[Se],activate:(r,e,i,a)=>{if(!a)return;const{shell:s}=r,l=new ae(i);e.currentChanged.connect(()=>{const p=e.currentWidget;l.model.notebook=p&&p.content}),a.registerStatusItem("@jupyterlab/notebook-extension:trust-status",{item:l,align:"right",rank:3,isActive:()=>!!s.currentWidget&&!!e.currentWidget&&s.currentWidget===e.currentWidget})}},vn={id:"@jupyterlab/notebook-extension:widget-factory",description:"Provides the notebook widget factory.",provides:ot,requires:[fe.IContentFactory,ge,po,dt],optional:[be,Ue,F],activate:jn,autoStart:!0},fn={id:"@jupyterlab/notebook-extension:cloned-outputs",description:"Adds the clone output feature.",requires:[bo,I,F],optional:[it],activate:Rn,autoStart:!0},_n={id:"@jupyterlab/notebook-extension:code-console",description:"Adds the notebook code consoles features.",requires:[I,F],activate:In,autoStart:!0},yn={id:"@jupyterlab/notebook-extension:copy-output",description:"Adds the copy cell outputs feature.",activate:Pn,requires:[F,I],autoStart:!0},xn={id:"@jupyterlab/notebook-extension:kernel-status",description:"Adds the notebook kernel status.",activate:(r,e,i)=>{const a=s=>{let l=null;return s&&e.has(s)?s.sessionContext:l};i.addSessionProvider(a)},requires:[I,ct],autoStart:!0},wn={id:"@jupyterlab/notebook-extension:cursor-position",description:"Adds the notebook cursor position status.",activate:(r,e,i)=>{let a=null;const s=async l=>{let p=null;if(l!==a){if(a?.content.activeCellChanged.disconnect(i.update),a=null,l&&e.has(l)){l.content.activeCellChanged.connect(i.update);const n=l.content.activeCell;p=null,n&&(await n.ready,p=n.editor),a=l}}else if(l){const n=l.content.activeCell;p=null,n&&(await n.ready,p=n.editor)}return p};i.addEditorProvider(s)},requires:[I,Wt],autoStart:!0},kn={id:"@jupyterlab/notebook-extension:completer",description:"Adds the code completion capability to notebooks.",requires:[I],optional:[mo,F,qe],activate:Wn,autoStart:!0},Sn={id:"@jupyterlab/notebook-extension:search",description:"Adds search capability to notebooks.",requires:[Co],autoStart:!0,activate:(r,e)=>{e.add("jp-notebookSearchProvider",Dt)}},An={id:"@jupyterlab/notebook-extension:toc",description:"Adds table of content capability to the notebooks",requires:[I,Ht,qe],optional:[go,be],autoStart:!0,activate:(r,e,i,a,s,l)=>{const p=new $o(e,s,a);i.add(p),l&&Promise.all([r.restored,l.load(ee.id)]).then(([n,c])=>{const d=()=>{var g;p.scrollToTop=(g=c.composite.scrollHeadingToTop)!==null&&g!==void 0?g:!0};d(),c.changed.connect(d)}).catch(n=>{console.error("Failed to load notebook table of content settings.",n)})}},Mn={id:"@jupyterlab/notebook-extension:language-server",description:"Adds language server capability to the notebooks.",requires:[I,_o,yo,xo,wo],activate:Hn,autoStart:!0},Tn={id:"@jupyterlab/notebook-extension:update-raw-mimetype",description:"Adds metadata form editor for raw cell mimetype.",autoStart:!0,requires:[I,Yo,F],activate:(r,e,i,a)=>{const s=a.load("jupyterlab");let l=!1;async function p(){if(l||!i.get("commonToolsSection"))return;const n=i.get("commonToolsSection").getProperties("/raw_mimetype");if(!n)return;e.widgetAdded.disconnect(p),l=!0;const d=await r.serviceManager.nbconvert.getExportFormats(!1);if(!d)return;const g=Object.keys(d),m=L.getFormatLabels(a);g.forEach(function(b){var f;if(!(((f=n.oneOf)===null||f===void 0?void 0:f.filter(o=>o.const===b).length)>0)){const o=s.__(b[0].toUpperCase()+b.substr(1)),t=m[b]?m[b]:o,u=d[b].output_mimetype;n.oneOf.push({const:u,title:t})}}),i.get("commonToolsSection").setProperties("/raw_mimetype",n)}e.widgetAdded.connect(p)}},Bn={id:"@jupyterlab/notebook-extension:metadata-editor",description:"Adds metadata form for full metadata editor.",autoStart:!0,requires:[I,ge,Ae],optional:[F],activate:(r,e,i,a,s)=>{const l=c=>i.factoryService.newInlineEditor(c),p={fieldRenderer:c=>new an({editorFactory:l,tracker:e,label:"Cell metadata",translator:s}).render(c)};a.addRenderer("@jupyterlab/notebook-extension:metadata-editor.cell-metadata",p);const n={fieldRenderer:c=>new dn({editorFactory:l,tracker:e,label:"Notebook metadata",translator:s}).render(c)};a.addRenderer("@jupyterlab/notebook-extension:metadata-editor.notebook-metadata",n)}},En={id:"@jupyterlab/notebook-extension:active-cell-tool",description:"Adds active cell field in the metadata editor tab.",autoStart:!0,requires:[I,Ae,et],activate:(r,e,i,a)=>{const s={fieldRenderer:l=>new ln({tracker:e,languages:a}).render(l)};i.addRenderer("@jupyterlab/notebook-extension:active-cell-tool.renderer",s)}},Nn={id:"@jupyterlab/notebook-extension:open-with-no-kernel",description:'Adds the "Notebook (no kernel)" option to the Open With menu.',requires:[nt],optional:[F],autoStart:!0,activate:(r,e,i)=>{const{tracker:a}=e,s=(i??O).load("jupyterlab"),l=[];function p(n){var c,d;l.forEach(f=>f.dispose()),l.length=0;const g=(d=(c=n.menu.items.find(f=>{var x;return f.type==="submenu"&&((x=f.submenu)===null||x===void 0?void 0:x.id)==="jp-contextmenu-open-with"}))===null||c===void 0?void 0:c.submenu)!==null&&d!==void 0?d:null;if(!g)return;(a.currentWidget?Array.from(a.currentWidget.selectedItems()):[]).some(f=>f.type==="notebook")&&l.push(g.addItem({command:"filebrowser:open",args:{label:s.__("Notebook (no kernel)"),factory:J,kernelPreference:{shouldStart:!1}}}))}r.contextMenu.opened.connect(p)}},el=[Xo,hn,ee,bn,mn,pn,gn,Cn,vn,Zo,fn,_n,yn,xn,wn,kn,Sn,An,Mn,Tn,Bn,En,Nn];function On(r,e,i,a,s,l,p){const n=l.load("jupyterlab"),c="notebook-tools",d=new q({tracker:e,translator:l}),g=(m,b)=>{switch(b.type){case"activate-request":s.save(c,{open:!0});break;case"after-hide":case"close-request":s.remove(c);break}return!0};return d.title.icon=Kt,d.title.caption=n.__("Notebook Tools"),d.id=c,G.installMessageHook(d,g),p&&e.widgetAdded.connect((m,b)=>{p.register(b).render(d)}),d}function jn(r,e,i,a,s,l,p,n){const c=n??O,d=p??new xe({translator:c}),g=Vt.PageConfig.getOption("notebookStartsKernel"),m=g===""||g.toLowerCase()==="true",{commands:b}=r;let f;s.addFactory(J,"save",t=>lo.createSaveButton(b,t.context.fileChanged)),s.addFactory(J,"cellType",t=>_e.createCellTypeItem(t,c)),s.addFactory(J,"kernelName",t=>ue.createKernelNameItem(t.sessionContext,d,c)),s.addFactory(J,"executionProgress",t=>{const u=l?.load(ee.id),C=X.createExecutionIndicatorItem(t,c,u);return u?.then(w=>{t.disposed.connect(()=>{w.dispose()})}),C}),l&&(f=Ut(s,l,J,un,c));const x=c.load("jupyterlab"),o=new Ao({name:J,label:x.__("Notebook"),fileTypes:["notebook"],modelName:"notebook",defaultFor:["notebook"],preferKernel:m,canStartKernel:!0,rendermime:a,contentFactory:e,editorConfig:se.defaultEditorConfig,notebookConfig:se.defaultNotebookConfig,mimeTypeService:i.mimeTypeService,toolbarFactory:f,translator:c});return r.docRegistry.addWidgetFactory(o),o}function Rn(r,e,i,a,s){const l=a.load("jupyterlab"),p=new qt({namespace:"cloned-outputs"});s&&s.restore(p,{command:h.createOutputView,args:g=>({path:g.content.path,index:g.content.index}),name:g=>`${g.content.path}:${g.content.index}`,when:i.restored});const{commands:n,shell:c}=r,d=()=>L.isEnabledAndSingleSelected(c,i);n.addCommand(h.createOutputView,{label:l.__("Create New View for Cell Output"),execute:async g=>{var m;let b,f;const x=g.path;let o=g.index;if(x&&o!==void 0&&o!==null){if(f=e.findWidget(x,J),!f)return}else{if(f=i.currentWidget,!f)return;b=f.content.activeCell,o=f.content.activeCellIndex}const t=new L.ClonedOutputArea({notebook:f,cell:b,index:o,translator:a}),u=new $t({content:t});f.context.addSibling(u,{ref:f.id,mode:"split-bottom",type:"Cloned Output"});const C=()=>{p.save(u)};f.context.pathChanged.connect(C),(m=f.context.model)===null||m===void 0||m.cells.changed.connect(C),p.add(u),f.content.disposed.connect(()=>{var w;f.context.pathChanged.disconnect(C),(w=f.context.model)===null||w===void 0||w.cells.changed.disconnect(C),u.dispose()})},isEnabled:d,describedBy:{args:{type:"object",properties:{path:{type:"string",description:l.__("The path to the notebook containing the cell")},index:{type:"number",description:l.__("The index of the cell to create an output view for")}}}}})}function In(r,e,i){const a=i.load("jupyterlab"),{commands:s,shell:l}=r,p=()=>L.isEnabled(l,e);s.addCommand(h.createConsole,{label:a.__("New Console for Notebook"),execute:n=>{const c=e.currentWidget;if(c)return L.createConsole(s,c,n.activate)},isEnabled:p,describedBy:{args:{type:"object",properties:{activate:{type:"boolean",description:a.__("Whether to activate the console after creation")}}}}}),s.addCommand(h.createSubshellConsole,{label:a.__("New Subshell Console for Notebook"),execute:n=>{const c=e.currentWidget;if(c)return L.createConsole(s,c,n.activate,!0)},isEnabled:p,isVisible:()=>{var n,c,d;const g=(c=(n=e.currentWidget)===null||n===void 0?void 0:n.context.sessionContext.session)===null||c===void 0?void 0:c.kernel;return(d=g?.supportsSubshells)!==null&&d!==void 0?d:!1},describedBy:{args:{type:"object",properties:{activate:{type:"boolean",description:a.__("Whether to activate the console after creation")}}}}}),s.addCommand(h.runInConsole,{label:a.__("Run Selected Text or Current Line in Console"),execute:async n=>{var c,d;const g=e.currentWidget;if(!g)return;const{context:m,content:b}=g,f=b.activeCell,x=f?.model.metadata,o=m.path;if(!f||f.model.type!=="code")return;let t;const u=f.editor;if(!u)return;const C=u.getSelection(),{start:w,end:B}=C;if(w.column!==B.column||w.line!==B.line){const K=u.getOffsetAt(C.start),V=u.getOffsetAt(C.end);t=u.model.sharedModel.getSource().substring(K,V)}else{const K=u.getCursorPosition(),V=u.model.sharedModel.getSource().split(`
|
|
3
3
|
`);let R=C.start.line;for(;R<u.lineCount&&!V[R].replace(/\s/g,"").length;)R+=1;let j=R>0,$=0,P=$+1;for(;;){t=V.slice($,P).join(`
|
|
4
4
|
`);const te=await((d=(c=g.context.sessionContext.session)===null||c===void 0?void 0:c.kernel)===null||d===void 0?void 0:d.requestIsComplete({code:t+`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as t,r as i}from"../datalayer-app-main.js";import{I as l,r}from"./JupyterLexicalExtension-
|
|
1
|
+
import{K as t,r as i}from"../datalayer-app-main.js";import{I as l,r}from"./JupyterLexicalExtension-Ght2bbbp.js";import{$ as h,a as j,b as k,c as q,d as v,e as w,C as y,f as z,g as F}from"./JupyterLexicalExtension-Ght2bbbp.js";import"./NotebookSkeleton-CI7ovjNW.js";import"./Avatar-9MpXENSs.js";import"./url-CzjbCo42.js";import"./isSymbol-BLtK9CV6.js";import"./toNumber-B1wj8-wx.js";import"./VideoIcon-BjP_LDa4.js";import"./LinkIcon-DUI0jw25.js";import"./Toolbar-CGQDY041.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./ArrowUpIcon-BUCpIXDR.js";import"./SortDescIcon-CS4EzHeS.js";import"./PaintbrushIcon-CLU8RilX.js";import"./PrismCss-CcU1ChRk.js";import"./Output-no9rnFJ7.js";import"./index-CFP9psRB.js";import"./hoverbox-CStlKQWE.js";import"./index-DSN70XMH.js";import"./index-S4sn4R3i.js";import"./color-CG7_7V2-.js";import"./isEqual-g-jK7vY0.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./index-BJhxZF_K.js";import"./RestartIcon-Ca6_HoK0.js";import"./LexicalToolRegistry-8wJyLumb.js";function D(){const[o]=t();return i.useEffect(()=>r(o),[o]),null}export{h as $createCollapsibleContainerNode,j as $createCollapsibleContentNode,k as $createCollapsibleTitleNode,q as $isCollapsibleContainerNode,v as $isCollapsibleContentNode,w as $isCollapsibleTitleNode,y as CollapsibleContainerNode,z as CollapsibleContentNode,D as CollapsiblePlugin,F as CollapsibleTitleNode,l as INSERT_COLLAPSIBLE_COMMAND,D as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{cT as C,cU as F,cV as I,cW as S,cX as W,ac as O,ag as P,aW as A,J as E,ak as H,cY as D,b_ as R,a9 as j,c6 as B,cZ as V,c_ as q,c$ as L,ai as N,d0 as U,cy as z}from"../datalayer-app-main.js";import{f as Y,I as $}from"./index-
|
|
1
|
+
import{cT as C,cU as F,cV as I,cW as S,cX as W,ac as O,ag as P,aW as A,J as E,ak as H,cY as D,b_ as R,a9 as j,c6 as B,cZ as V,c_ as q,c$ as L,ai as N,d0 as U,cy as z}from"../datalayer-app-main.js";import{f as Y,I as $}from"./index-Dzf9vro3.js";import{I as G}from"./tokens-BHLmeqjP.js";import{a as J,C as T}from"./index-CFP9psRB.js";import{T as K,a as X}from"./model-BziAhKNp.js";import"./Output-no9rnFJ7.js";import"./index-DSN70XMH.js";import"./hoverbox-CStlKQWE.js";import"./index-S4sn4R3i.js";import"./color-CG7_7V2-.js";import"./isEqual-g-jK7vY0.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./PaintbrushIcon-CLU8RilX.js";import"./index-BJhxZF_K.js";import"./RestartIcon-Ca6_HoK0.js";import"./CellSidebarExtension-B-73cmcQ.js";import"./NotebookSkeleton-CI7ovjNW.js";import"./Avatar-9MpXENSs.js";import"./renderer-DKKfWkWv.js";import"./SquareIcon-e3ygcjpv.js";import"./SortAscIcon-CVKVWIWQ.js";import"./url-CzjbCo42.js";/* empty css */import"./index-Dro44tIm.js";/* empty css *//* empty css */import"./index-DsG9xhMj.js";/* empty css */import"./index-CNU-WVhQ.js";import"./index--OLIX362.js";import"./index-DYGslHkf.js";import"./index-BSRVX3UN.js";import"./index-BH2OX5l8.js";import"./index-C3vDfO5_.js";import"./index-Ko8lxXFd.js";import"./index-CB9u17_J.js";import"./index-BUVtc_FV.js";import"./ArrowLeftIcon-Y3PTljcl.js";import"./SkubbleIcon-tlg17jBG.js";import"./usePrimerThemeBridge-CoHussa9.js";import"./index-Dobs-OKl.js";import"./KernelVariables-CS6h5HyK.js";import"./index-BvgsWH_d.js";import"./SortDescIcon-CS4EzHeS.js";import"./NotebookToolbar-rtMQZWHQ.js";import"./RepoPushIcon-Cm8g9NuL.js";import"./Toolbar-CGQDY041.js";import"./sessions-BRALW9Yv.js";import"./tokens-DTIgYcNS.js";import"./drivecontents-CxwZz_5W.js";import"./kernel-BI-BLP-K.js";class Z extends X{constructor(e,r,t){super(e,t),this.parser=r}get documentType(){return"markdown-viewer"}get isAlwaysActive(){return!0}get supportedOptions(){return["maximalDepth","numberingH1","numberHeaders"]}async getHeadings(){const e=this.widget.context.model.toString(),r=await S(e,this.parser),t=W(r,{...this.configuration,baseNumbering:1});return Promise.resolve(t)}}class Q extends K{constructor(e,r,t){super(e),this.parser=r,this.sanitizer=t}_createNew(e,r){const t=new Z(e,this.parser,r);let o=new WeakMap;const l=(c,m)=>{if(m){const a=o.get(m);if(a){const u=e.content.node.getBoundingClientRect(),p=a.getBoundingClientRect();(p.top>u.bottom||p.bottom<u.top)&&a.scrollIntoView({block:"center"})}else console.warn("Heading element not found for heading",m,"in widget",e)}},s=()=>{this.parser&&(C(e.content.node),o=new WeakMap,t.headings.forEach(async c=>{var m,a;const u=await F(this.parser,c.raw,c.level,this.sanitizer);if(!u)return;const p=(m=this.sanitizer.allowNamedProperties)!==null&&m!==void 0&&m?"id":"data-jupyter-id",w=`h${c.level}[${p}="${CSS.escape(u)}"]`;o.set(c,I(e.content.node,w,(a=c.prefix)!==null&&a!==void 0?a:""))}))};return e.content.ready.then(()=>{s(),e.content.rendered.connect(s),t.activeHeadingChanged.connect(l),t.headingsChanged.connect(s),e.disposed.connect(()=>{e.content.rendered.disconnect(s),t.activeHeadingChanged.disconnect(l),t.headingsChanged.disconnect(s)})}),t}}const ee=new O("@jupyterlab/markdownviewer:IMarkdownViewerTracker",`A widget tracker for markdown
|
|
2
2
|
document viewers. Use this if you want to iterate over and interact with rendered markdown documents.`),te="jp-MarkdownViewer",x="text/markdown";class f extends P{constructor(e){super(),this._config={...f.defaultConfig},this._fragment="",this._ready=new A,this._isRendering=!1,this._renderRequested=!1,this._rendered=new E(this),this.context=e.context,this.translator=e.translator||H,this._trans=this.translator.load("jupyterlab"),this.renderer=e.renderer,this.node.tabIndex=0,this.addClass(te),(this.layout=new D).addWidget(this.renderer),this.context.ready.then(async()=>{await this._render(),this._monitor=new R.ActivityMonitor({signal:this.context.model.contentChanged,timeout:this._config.renderTimeout}),this._monitor.activityStopped.connect(this.update,this),this._ready.resolve(void 0)})}get ready(){return this._ready.promise}get rendered(){return this._rendered}setFragment(e){this._fragment=e,this.update()}setOption(e,r){if(this._config[e]===r)return;this._config[e]=r;const{style:t}=this.renderer.node;switch(e){case"fontFamily":t.setProperty("font-family",r);break;case"fontSize":t.setProperty("font-size",r?r+"px":null);break;case"hideFrontMatter":this.update();break;case"lineHeight":t.setProperty("line-height",r?r.toString():null);break;case"lineWidth":{const o=r?`calc(50% - ${r/2}ch)`:null;t.setProperty("padding-left",o),t.setProperty("padding-right",o);break}case"renderTimeout":this._monitor&&(this._monitor.timeout=r);break}}dispose(){this.isDisposed||(this._monitor&&this._monitor.dispose(),this._monitor=null,super.dispose())}onUpdateRequest(e){this.context.isReady&&!this.isDisposed&&(this._render(),this._fragment="")}onActivateRequest(e){this.node.focus()}async _render(){if(this.isDisposed)return;if(this._isRendering){this._renderRequested=!0;return}this._renderRequested=!1;const{context:e}=this,{model:r}=e,t=r.toString(),o={};o[x]=this._config.hideFrontMatter?_.removeFrontMatter(t):t;const l=new j({data:o,metadata:{fragment:this._fragment}});try{if(this._isRendering=!0,await this.renderer.renderModel(l),this._isRendering=!1,this._renderRequested)return this._render();this._rendered.emit()}catch(s){requestAnimationFrame(()=>{this.dispose()}),B(this._trans.__("Renderer Failure: %1",e.path),s)}}}(function(d){d.defaultConfig={fontFamily:null,fontSize:null,lineHeight:null,lineWidth:null,hideFrontMatter:!0,renderTimeout:1e3}})(f||(f={}));class re extends q{setFragment(e){this.content.setFragment(e)}}class ne extends V{constructor(e){super(_.createRegistryOptions(e)),this._fileType=e.primaryFileType,this._rendermime=e.rendermime}createNewWidget(e){var r,t,o,l,s;const m=this._rendermime.clone({resolver:e.urlResolver}).createRenderer(x),a=new f({context:e,renderer:m});return a.title.icon=(r=this._fileType)===null||r===void 0?void 0:r.icon,a.title.iconClass=(o=(t=this._fileType)===null||t===void 0?void 0:t.iconClass)!==null&&o!==void 0?o:"",a.title.iconLabel=(s=(l=this._fileType)===null||l===void 0?void 0:l.iconLabel)!==null&&s!==void 0?s:"",a.title.caption=this.label,new re({content:a,context:e})}}var _;(function(d){function e(t){return{...t,readOnly:!0}}d.createRegistryOptions=e;function r(t){const o=/^---\n[^]*?\n(---|...)\n/,l=t.match(o);if(!l)return t;const{length:s}=l[0];return t.slice(s)}d.removeFrontMatter=r})(_||(_={}));var g;(function(d){d.markdownPreview="markdownviewer:open",d.markdownEditor="markdownviewer:edit",d.trust="markdownviewer:trust"})(g||(g={}));const v="Markdown Preview",ie={activate:oe,id:"@jupyterlab/markdownviewer-extension:plugin",description:"Adds markdown file viewer and provides its tracker.",provides:ee,requires:[$,N],optional:[Y,G,L,J],autoStart:!0};function oe(d,e,r,t,o,l,s){const c=r.load("jupyterlab"),{commands:m,docRegistry:a}=d;e.addFactory(U);const u="markdownviewer-widget",p=new z({namespace:u});let w={...f.defaultConfig};function k(i){Object.keys(w).forEach(n=>{var h;i.setOption(n,(h=w[n])!==null&&h!==void 0?h:null)})}if(o){const i=n=>{w=n.composite,p.forEach(h=>{k(h.content)})};o.load(ie.id).then(n=>{n.changed.connect(()=>{i(n)}),i(n)}).catch(n=>{console.error(n.message)})}const b=new ne({rendermime:e,name:v,label:c.__("Markdown Preview"),primaryFileType:a.getFileType("markdown"),fileTypes:["markdown"],defaultRendered:["markdown"]});return b.widgetCreated.connect((i,n)=>{n.context.pathChanged.connect(()=>{p.save(n)}),k(n.content),n.content.node.setAttribute("data-trust-command",g.trust),p.add(n)}),a.addWidgetFactory(b),t&&t.restore(p,{command:"docmanager:open",args:i=>({path:i.context.path,factory:v}),name:i=>i.context.path}),m.addCommand(g.markdownPreview,{label:c.__("Markdown Preview"),execute:i=>{const n=i.path;if(typeof n=="string")return m.execute("docmanager:open",{path:n,factory:v,options:i.options})},describedBy:{args:{type:"object",properties:{path:{type:"string",description:c.__("The path to the markdown file to preview")},options:{type:"object",description:c.__("Options for opening the preview")}},required:["path"]}}}),m.addCommand(g.markdownEditor,{execute:()=>{const i=p.currentWidget;if(!i)return;const n=i.context.path;return m.execute("docmanager:open",{path:n,factory:"Editor",options:{mode:"split-right"}})},isVisible:()=>{const i=p.currentWidget;return i&&R.PathExt.extname(i.context.path)===".md"||!1},label:c.__("Show Markdown Editor"),describedBy:{args:{type:"object",properties:{}}}}),m.addCommand(g.trust,{label:c.__("Trust Markdown Preview"),execute:i=>{var n;const h=i[T.TRUST_BOUNDARY_ID_ARG],y=typeof h=="string"?(n=p.find(M=>M.content.node.id===h))!==null&&n!==void 0?n:null:p.currentWidget;return y&&!y.isDisposed?(y.content.node.classList.add("jp-mod-trusted"),d.commandLinker.markTrusted(y.content.node),{trusted:!0}):{trusted:!1}},describedBy:{args:{type:"object",properties:{[T.TRUST_BOUNDARY_ID_ARG]:{type:"string",description:c.__("The Markdown preview trust boundary ID")}}}}}),l&&l.add(new Q(p,e.markdownParser,s??e.sanitizer)),p}export{ie as default};
|