notebook 7.3.0a1__py3-none-any.whl → 7.3.0b0__py3-none-any.whl
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.
Potentially problematic release.
This version of notebook might be problematic. Click here for more details.
- notebook/_version.py +1 -1
- notebook/app.py +10 -2
- notebook/static/113.bundle.js +1 -1
- notebook/static/1198.bundle.js +1 -1
- notebook/static/134.bundle.js +1 -1
- notebook/static/1408.bundle.js +1 -1
- notebook/static/1496.bundle.js +1 -1
- notebook/static/1584.bundle.js +1 -1
- notebook/static/1647.bundle.js +1 -1
- notebook/static/1650.bundle.js +1 -1
- notebook/static/1684.bundle.js +1 -1
- notebook/static/170.bundle.js +1 -1
- notebook/static/1809.bundle.js +1 -1
- notebook/static/1827.bundle.js +1 -1
- notebook/static/1828.bundle.js +1 -1
- notebook/static/1833.bundle.js +1 -1
- notebook/static/1958.bundle.js +1 -1
- notebook/static/1962.bundle.js +1 -1
- notebook/static/2007.bundle.js +1 -1
- notebook/static/2065.bundle.js +1 -1
- notebook/static/2088.bundle.js +1 -1
- notebook/static/2089.bundle.js +1 -1
- notebook/static/2122.bundle.js +1 -1
- notebook/static/2167.bundle.js +1 -1
- notebook/static/2184.bundle.js +1 -1
- notebook/static/2311.bundle.js +1 -1
- notebook/static/{3030.bundle.js → 2323.bundle.js} +1 -1
- notebook/static/2401.bundle.js +1 -1
- notebook/static/2424.bundle.js +377 -0
- notebook/static/2479.bundle.js +1 -1
- notebook/static/2489.bundle.js +1 -1
- notebook/static/2607.bundle.js +1 -1
- notebook/static/2615.bundle.js +1 -1
- notebook/static/2636.bundle.js +1 -1
- notebook/static/2756.bundle.js +1 -1
- notebook/static/2813.bundle.js +1 -1
- notebook/static/2866.bundle.js +1 -1
- notebook/static/2924.bundle.js +1 -1
- notebook/static/2944.bundle.js +1 -1
- notebook/static/2955.bundle.js +1 -0
- notebook/static/3129.bundle.js +1 -1
- notebook/static/3146.bundle.js +1 -1
- notebook/static/3187.bundle.js +1 -1
- notebook/static/3213.bundle.js +1 -1
- notebook/static/3301.bundle.js +1 -1
- notebook/static/3325.bundle.js +1 -1
- notebook/static/3340.bundle.js +1 -1
- notebook/static/3360.bundle.js +1 -1
- notebook/static/{1261.bundle.js → 3463.bundle.js} +1 -1
- notebook/static/3466.bundle.js +1 -1
- notebook/static/35.bundle.js +1 -1
- notebook/static/3512.bundle.js +1 -1
- notebook/static/3676.bundle.js +1 -1
- notebook/static/3680.bundle.js +1 -1
- notebook/static/374.bundle.js +1 -1
- notebook/static/3768.bundle.js +1 -1
- notebook/static/377.bundle.js +1 -1
- notebook/static/3863.bundle.js +1 -1
- notebook/static/3881.bundle.js +1 -1
- notebook/static/4042.bundle.js +1 -1
- notebook/static/4058.bundle.js +1 -1
- notebook/static/409.bundle.js +1 -1
- notebook/static/4212.bundle.js +1 -1
- notebook/static/4242.bundle.js +79 -0
- notebook/static/4271.bundle.js +1 -1
- notebook/static/4291.bundle.js +1 -1
- notebook/static/4382.bundle.js +1 -1
- notebook/static/4526.bundle.js +1 -1
- notebook/static/4588.bundle.js +1 -1
- notebook/static/4630.bundle.js +1 -1
- notebook/static/4645.bundle.js +1 -1
- notebook/static/4811.bundle.js +1 -1
- notebook/static/4837.bundle.js +1 -1
- notebook/static/5099.bundle.js +1 -1
- notebook/static/5135.bundle.js +1 -1
- notebook/static/5166.bundle.js +1 -1
- notebook/static/5234.bundle.js +1 -1
- notebook/static/5254.bundle.js +1 -1
- notebook/static/5261.bundle.js +1 -1
- notebook/static/5263.bundle.js +1 -0
- notebook/static/5313.bundle.js +1 -1
- notebook/static/5325.bundle.js +1 -1
- notebook/static/5346.bundle.js +1 -1
- notebook/static/5426.bundle.js +1 -1
- notebook/static/5430.bundle.js +653 -0
- notebook/static/545.bundle.js +1 -1
- notebook/static/5451.bundle.js +1 -1
- notebook/static/5573.bundle.js +1 -1
- notebook/static/5601.bundle.js +1 -1
- notebook/static/5649.bundle.js +3 -3
- notebook/static/5733.bundle.js +1 -1
- notebook/static/5850.bundle.js +1 -1
- notebook/static/5912.bundle.js +1 -1
- notebook/static/5921.bundle.js +1 -1
- notebook/static/6017.bundle.js +1 -1
- notebook/static/6061.bundle.js +1 -1
- notebook/static/6139.bundle.js +1 -1
- notebook/static/62.bundle.js +1 -1
- notebook/static/6271.bundle.js +1 -1
- notebook/static/6345.bundle.js +1 -1
- notebook/static/6604.bundle.js +1 -1
- notebook/static/6621.bundle.js +1 -1
- notebook/static/6627.bundle.js +1 -1
- notebook/static/6648.bundle.js +1 -0
- notebook/static/6731.bundle.js +1 -1
- notebook/static/6748.bundle.js +1 -1
- notebook/static/677.bundle.js +1 -1
- notebook/static/6815.bundle.js +1 -1
- notebook/static/6853.bundle.js +1 -1
- notebook/static/6893.bundle.js +1 -1
- notebook/static/690.bundle.js +1 -1
- notebook/static/6962.bundle.js +1 -1
- notebook/static/6999.bundle.js +1 -1
- notebook/static/7226.bundle.js +1 -1
- notebook/static/7252.bundle.js +1 -1
- notebook/static/7302.bundle.js +1 -1
- notebook/static/7369.bundle.js +1 -1
- notebook/static/7386.bundle.js +1 -1
- notebook/static/7391.bundle.js +1 -1
- notebook/static/7543.bundle.js +1 -1
- notebook/static/7603.bundle.js +1 -1
- notebook/static/7639.bundle.js +1 -1
- notebook/static/7655.bundle.js +1 -1
- notebook/static/7684.bundle.js +1 -1
- notebook/static/7812.bundle.js +1 -1
- notebook/static/7819.bundle.js +1 -1
- notebook/static/7821.bundle.js +1 -1
- notebook/static/7854.bundle.js +1 -1
- notebook/static/7866.bundle.js +1 -0
- notebook/static/7900.bundle.js +1 -1
- notebook/static/7906.bundle.js +1 -1
- notebook/static/8010.bundle.js +1 -1
- notebook/static/8032.bundle.js +1 -1
- notebook/static/8285.bundle.js +1 -1
- notebook/static/8471.bundle.js +1 -1
- notebook/static/8579.bundle.js +1 -1
- notebook/static/8633.bundle.js +1 -1
- notebook/static/8635.bundle.js +41 -0
- notebook/static/8771.bundle.js +1 -1
- notebook/static/8781.bundle.js +1 -1
- notebook/static/8875.bundle.js +1 -1
- notebook/static/8907.bundle.js +1 -1
- notebook/static/8928.bundle.js +1 -1
- notebook/static/8929.bundle.js +1 -1
- notebook/static/893.bundle.js +1 -1
- notebook/static/901.bundle.js +1 -1
- notebook/static/9068.bundle.js +1 -1
- notebook/static/911.bundle.js +1 -1
- notebook/static/9136.bundle.js +1 -1
- notebook/static/9151.bundle.js +1 -1
- notebook/static/9161.bundle.js +1 -1
- notebook/static/9268.bundle.js +1 -1
- notebook/static/9335.bundle.js +1 -1
- notebook/static/9341.bundle.js +1 -1
- notebook/static/9380.bundle.js +1 -1
- notebook/static/9605.bundle.js +1 -1
- notebook/static/9638.bundle.js +1 -1
- notebook/static/9672.bundle.js +352 -0
- notebook/static/9680.bundle.js +1 -1
- notebook/static/9685.bundle.js +1 -1
- notebook/static/9752.bundle.js +1 -1
- notebook/static/9799.bundle.js +1 -0
- notebook/static/9821.bundle.js +1 -1
- notebook/static/9852.bundle.js +1 -1
- notebook/static/bundle.js +1 -1
- notebook/static/third-party-licenses.json +124 -130
- notebook/templates/consoles.html +1 -1
- notebook/templates/edit.html +1 -1
- notebook/templates/error.html +1 -1
- notebook/templates/notebooks.html +1 -1
- notebook/templates/terminals.html +1 -1
- notebook/templates/tree.html +1 -1
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/package.json.orig +17 -17
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/documentsearch-extension/package.json.orig +5 -5
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/help-extension/package.json.orig +6 -6
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/package.json.orig +11 -11
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/tree-extension/package.json.orig +18 -18
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/tree-extension/widget.json +0 -1
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/package.json +13 -13
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/schemas/@jupyter-notebook/lab-extension/package.json.orig +12 -12
- notebook-7.3.0b0.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/568.67f8b11d2af855286118.js +1 -0
- notebook-7.3.0a1.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/600.25341cef1598f2727482.js → notebook-7.3.0b0.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/907.767373e59d0c0e33ef12.js +1 -1
- notebook-7.3.0b0.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/928.50419fa0a72e54064396.js +1 -0
- notebook-7.3.0b0.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/remoteEntry.fd0956ebf15f666a19f8.js +1 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/third-party-licenses.json +2 -2
- {notebook-7.3.0a1.dist-info → notebook-7.3.0b0.dist-info}/METADATA +2 -2
- {notebook-7.3.0a1.dist-info → notebook-7.3.0b0.dist-info}/RECORD +210 -218
- notebook/static/1226.bundle.js +0 -1
- notebook/static/1750.bundle.js +0 -1
- notebook/static/1884.bundle.js +0 -386
- notebook/static/4045.bundle.js +0 -1
- notebook/static/4434.bundle.js +0 -1
- notebook/static/5018.bundle.js +0 -1
- notebook/static/5712.bundle.js +0 -1
- notebook/static/6164.bundle.js +0 -1
- notebook/static/6318.bundle.js +0 -1
- notebook/static/6619.bundle.js +0 -1
- notebook/static/6898.bundle.js +0 -1
- notebook/static/7506.bundle.js +0 -703
- notebook/static/7579.bundle.js +0 -1
- notebook/static/8054.bundle.js +0 -1
- notebook/static/8647.bundle.js +0 -1
- notebook/static/8723.bundle.js +0 -1
- notebook/static/9734.bundle.js +0 -1
- notebook/static/9906.bundle.js +0 -1
- notebook-7.3.0a1.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/568.45e1d3167710e94c3d26.js +0 -1
- notebook-7.3.0a1.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/928.b94c92715d631efb4a8f.js +0 -1
- notebook-7.3.0a1.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/remoteEntry.8ca922abea871b34db72.js +0 -1
- /notebook/static/{7506.bundle.js.LICENSE.txt → 4242.bundle.js.LICENSE.txt} +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/etc/jupyter/jupyter_server_config.d/notebook.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/applications/jupyter-notebook.desktop +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/icons/hicolor/scalable/apps/notebook.svg +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/menus.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/pages.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/shell.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/title.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/top.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/zen.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/help-extension/open.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/checkpoints.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/edit-notebook-metadata.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/kernel-logo.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/scroll-output.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/tree-extension/file-actions.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/schemas/@jupyter-notebook/lab-extension/interface-switcher.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/schemas/@jupyter-notebook/lab-extension/launch-tree.json +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/93.eae3497dd223d842d198.js +0 -0
- {notebook-7.3.0a1.data → notebook-7.3.0b0.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/style.js +0 -0
- {notebook-7.3.0a1.dist-info → notebook-7.3.0b0.dist-info}/WHEEL +0 -0
- {notebook-7.3.0a1.dist-info → notebook-7.3.0b0.dist-info}/entry_points.txt +0 -0
- {notebook-7.3.0a1.dist-info → notebook-7.3.0b0.dist-info}/licenses/LICENSE +0 -0
notebook/static/2479.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[2479],{72479:(e,t,s)=>{s.r(t),s.d(t,{AttachmentsCell:()=>ge,AttachmentsCellModel:()=>I,Cell:()=>ue,CellDragUtils:()=>l,CellFooter:()=>v,CellHeader:()=>_,CellModel:()=>A,CellSearchProvider:()=>B,CodeCell:()=>pe,CodeCellLayout:()=>ce,CodeCellModel:()=>j,Collapser:()=>p,InputArea:()=>w,InputCollapser:()=>g,InputPlaceholder:()=>W,InputPrompt:()=>x,MarkdownCell:()=>me,MarkdownCellModel:()=>k,OutputCollapser:()=>m,OutputPlaceholder:()=>L,Placeholder:()=>F,RawCell:()=>Ce,RawCellModel:()=>D,SELECTED_HIGHLIGHT_CLASS:()=>z,createCellSearchProvider:()=>J,isCodeCellModel:()=>E,isMarkdownCellModel:()=>H,isRawCellModel:()=>b});var i=s(24475);const n="jp-dragImage",o="jp-dragImage-singlePrompt",r="jp-dragImage-content",a="jp-dragImage-prompt",d="jp-dragImage-multipleBack";var l;!function(e){e.findCell=function(e,t,s){let i=-1;for(;e&&e.parentElement;){if(s(e)){let s=-1;for(const n of t)if(n.node===e){i=++s;break}break}e=e.parentElement}return i},e.detectTargetArea=function(e,t){var s,i;let n;return n=e?(null===(s=e.editorWidget)||void 0===s?void 0:s.node.contains(t))?"input":(null===(i=e.promptNode)||void 0===i?void 0:i.contains(t))?"prompt":"cell":"unknown",n},e.shouldStartDrag=function(e,t,s,i){const n=Math.abs(s-e),o=Math.abs(i-t);return n>=5||o>=5},e.createCellDragImage=function(e,t){const s=t.length;let l;if("code"===e.model.type){const t=e.model.executionCount;l=" ",t&&(l=t.toString())}else l="";const h=e.model.sharedModel.getSource().split("\n")[0].slice(0,26);return s>1?""!==l?i.VirtualDOM.realize(i.h.div(i.h.div({className:n},i.h.span({className:a},"["+l+"]:"),i.h.span({className:r},h)),i.h.div({className:d},""))):i.VirtualDOM.realize(i.h.div(i.h.div({className:n},i.h.span({className:a}),i.h.span({className:r},h)),i.h.div({className:d},""))):""!==l?i.VirtualDOM.realize(i.h.div(i.h.div({className:`${n} ${o}`},i.h.span({className:a},"["+l+"]:"),i.h.span({className:r},h)))):i.VirtualDOM.realize(i.h.div(i.h.div({className:`${n} ${o}`},i.h.span({className:a}),i.h.span({className:r},h))))}}(l||(l={}));var h=s(12668),u=s(18395),c=s(78156);class p extends h.ReactWidget{constructor(){super(),this.addClass("jp-Collapser")}get collapsed(){return!1}render(){return c.createElement("div",{className:"jp-Collapser-child",onClick:e=>this.handleClick(e)})}}class g extends p{constructor(){super(),this.addClass("jp-InputCollapser")}get collapsed(){var e;const t=null===(e=this.parent)||void 0===e?void 0:e.parent;return!!t&&t.inputHidden}handleClick(e){var t;const s=null===(t=this.parent)||void 0===t?void 0:t.parent;s&&(s.inputHidden=!s.inputHidden),this.update()}}class m extends p{constructor(){super(),this.addClass("jp-OutputCollapser")}get collapsed(){var e;const t=null===(e=this.parent)||void 0===e?void 0:e.parent;return!!t&&t.outputHidden}handleClick(e){var t,s;const i=null===(t=this.parent)||void 0===t?void 0:t.parent;if(i&&(i.outputHidden=!i.outputHidden,i.outputHidden)){let e=null===(s=i.parent)||void 0===s?void 0:s.node;e&&u.ElementExt.scrollIntoViewIfNeeded(e,i.node)}this.update()}}var C=s(63485);class _ extends C.Widget{constructor(){super(),this.addClass("jp-CellHeader")}}class v extends C.Widget{constructor(){super(),this.addClass("jp-CellFooter")}}var y=s(52712);class w extends C.Widget{constructor(e){super(),this.addClass("jp-InputArea");const{contentFactory:t,editorOptions:s,model:i}=e;this.model=i,this.contentFactory=t;const n=this._prompt=t.createInputPrompt();n.addClass("jp-InputArea-prompt");const o=this._editor=new y.CodeEditorWrapper({factory:t.editorFactory,model:i,editorOptions:s});o.addClass("jp-InputArea-editor");const r=this.layout=new C.PanelLayout;r.addWidget(n),r.addWidget(o)}get editorWidget(){return this._editor}get editor(){return this._editor.editor}get promptNode(){return this._prompt.node}get renderedInput(){return this._rendered}renderInput(e){const t=this.layout;this._rendered&&(this._rendered.parent=null),this._editor.hide(),this._rendered=e,t.addWidget(e)}showEditor(){this._rendered&&(this._rendered.parent=null),this._editor.show()}setPrompt(e){this._prompt.executionCount=e}dispose(){this.isDisposed||(this._prompt=null,this._editor=null,this._rendered=null,super.dispose())}}!function(e){e.ContentFactory=class{constructor(e){this._editor=e.editorFactory}get editorFactory(){return this._editor}createInputPrompt(){return new x}}}(w||(w={}));class x extends C.Widget{constructor(){super(),this._executionCount=null,this.addClass("jp-InputPrompt")}get executionCount(){return this._executionCount}set executionCount(e){this._executionCount=e,this.node.textContent=null===e?" ":`[${e||" "}]:`}}var f=s(81997),M=s(9981),O=s(43648),S=s(57508);const P=(0,S.createMutex)();function E(e){return"code"===e.type}function H(e){return"markdown"===e.type}function b(e){return"raw"===e.type}class A extends y.CodeEditor.Model{constructor(e={}){const{cell_type:t,sharedModel:s,...i}=e;super({sharedModel:null!=s?s:(0,S.createStandaloneCell)({cell_type:null!=t?t:"raw",id:e.id}),...i}),this.contentChanged=new f.Signal(this),this.stateChanged=new f.Signal(this),this._metadataChanged=new f.Signal(this),this._trusted=!1,this.standaloneModel=void 0===e.sharedModel,this.trusted=!!this.getMetadata("trusted")||!!e.trusted,this.sharedModel.changed.connect(this.onGenericChange,this),this.sharedModel.metadataChanged.connect(this._onMetadataChanged,this)}get metadataChanged(){return this._metadataChanged}get id(){return this.sharedModel.getId()}get metadata(){return this.sharedModel.metadata}get trusted(){return this._trusted}set trusted(e){const t=this.trusted;t!==e&&(this._trusted=e,this.onTrustedChanged(this,{newValue:e,oldValue:t}))}dispose(){this.isDisposed||(this.sharedModel.changed.disconnect(this.onGenericChange,this),this.sharedModel.metadataChanged.disconnect(this._onMetadataChanged,this),super.dispose())}onTrustedChanged(e,t){}deleteMetadata(e){return this.sharedModel.deleteMetadata(e)}getMetadata(e){return this.sharedModel.getMetadata(e)}setMetadata(e,t){void 0===t?this.sharedModel.deleteMetadata(e):this.sharedModel.setMetadata(e,t)}toJSON(){return this.sharedModel.toJSON()}onGenericChange(){this.contentChanged.emit(void 0)}_onMetadataChanged(e,t){this._metadataChanged.emit(t)}}class I extends A{constructor(e){var t;super(e);const s=null!==(t=e.contentFactory)&&void 0!==t?t:I.defaultContentFactory,i=this.sharedModel.getAttachments();this._attachments=s.createAttachmentsModel({values:i}),this._attachments.stateChanged.connect(this.onGenericChange,this),this._attachments.changed.connect(this._onAttachmentsChange,this),this.sharedModel.changed.connect(this._onSharedModelChanged,this)}get attachments(){return this._attachments}dispose(){this.isDisposed||(this._attachments.stateChanged.disconnect(this.onGenericChange,this),this._attachments.changed.disconnect(this._onAttachmentsChange,this),this._attachments.dispose(),this.sharedModel.changed.disconnect(this._onSharedModelChanged,this),super.dispose())}toJSON(){return super.toJSON()}_onAttachmentsChange(e,t){const s=this.sharedModel;P((()=>s.setAttachments(e.toJSON())))}_onSharedModelChanged(e,t){if(t.attachmentsChange){const e=this.sharedModel;P((()=>{var t;return this._attachments.fromJSON(null!==(t=e.getAttachments())&&void 0!==t?t:{})}))}}}!function(e){class t{createAttachmentsModel(e){return new M.AttachmentsModel(e)}}e.ContentFactory=t,e.defaultContentFactory=new t}(I||(I={}));class D extends I{constructor(e={}){super({cell_type:"raw",...e})}get type(){return"raw"}toJSON(){return super.toJSON()}}class k extends I{constructor(e={}){super({cell_type:"markdown",...e}),this.mimeType="text/x-ipythongfm"}get type(){return"markdown"}toJSON(){return super.toJSON()}}class j extends A{constructor(e={}){var t;super({cell_type:"code",...e}),this._executionState="idle",this._executedCode="",this._isDirty=!1;const s=null!==(t=null==e?void 0:e.contentFactory)&&void 0!==t?t:j.defaultContentFactory,i=this.trusted,n=this.sharedModel.getOutputs();this._outputs=s.createOutputArea({trusted:i,values:n}),this.sharedModel.changed.connect(this._onSharedModelChanged,this),this._outputs.changed.connect(this.onGenericChange,this),this._outputs.changed.connect(this.onOutputsChange,this)}get type(){return"code"}get executionCount(){return this.sharedModel.execution_count||null}set executionCount(e){this.sharedModel.execution_count=e||null}get executionState(){return this._executionState}set executionState(e){const t=this._executionState;t!=e&&(this._executionState=e,this.stateChanged.emit({name:"executionState",oldValue:t,newValue:e}))}get isDirty(){return this._isDirty}set isDirty(e){this._setDirty(e)}get outputs(){return this._outputs}clearExecution(){this.outputs.clear(),this.executionCount=null,this.executionState="idle",this._setDirty(!1),this.sharedModel.deleteMetadata("execution"),this.trusted=!0}dispose(){this.isDisposed||(this.sharedModel.changed.disconnect(this._onSharedModelChanged,this),this._outputs.changed.disconnect(this.onGenericChange,this),this._outputs.changed.disconnect(this.onOutputsChange,this),this._outputs.dispose(),this._outputs=null,super.dispose())}onTrustedChanged(e,t){const s=t.newValue;if(this._outputs&&(this._outputs.trusted=s),s){const e=this.sharedModel,t=e.getMetadata();t.trusted=!0,e.setMetadata(t)}this.stateChanged.emit({name:"trusted",oldValue:t.oldValue,newValue:s})}toJSON(){return super.toJSON()}onOutputsChange(e,t){const s=this.sharedModel;P((()=>{switch(t.type){case"add":{const e=t.newValues.map((e=>e.toJSON()));s.updateOutputs(t.newIndex,t.newIndex,e);break}case"set":{const e=t.newValues.map((e=>e.toJSON()));s.updateOutputs(t.oldIndex,t.oldIndex+e.length,e);break}case"remove":s.updateOutputs(t.oldIndex,t.oldValues.length);break;default:throw new Error(`Invalid event type: ${t.type}`)}}))}_onSharedModelChanged(e,t){t.outputsChange&&P((()=>{this.outputs.clear(),e.getOutputs().forEach((e=>this._outputs.add(e)))})),t.executionCountChange&&(!t.executionCountChange.newValue||!this.isDirty&&t.executionCountChange.oldValue||this._setDirty(!1),this.stateChanged.emit({name:"executionCount",oldValue:t.executionCountChange.oldValue,newValue:t.executionCountChange.newValue})),t.sourceChange&&null!==this.executionCount&&this._setDirty(this._executedCode!==this.sharedModel.getSource().trim())}_setDirty(e){e||(this._executedCode=this.sharedModel.getSource().trim()),e!==this._isDirty&&(this._isDirty=e,this.stateChanged.emit({name:"isDirty",oldValue:!e,newValue:e}))}}!function(e){class t{createOutputArea(e){return new O.OutputAreaModel(e)}}e.ContentFactory=t,e.defaultContentFactory=new t}(j||(j={}));var N=s(25291);class F extends C.Widget{constructor(e){var t,s,i;const n=document.createElement("div");super({node:n});const o=(null!==(t=e.translator)&&void 0!==t?t:N.nullTranslator).load("jupyterlab"),r=document.createElement("div");r.className=null!==(s=e.promptClass)&&void 0!==s?s:"",n.insertAdjacentHTML("afterbegin",r.outerHTML),this._cell=document.createElement("div"),this._cell.classList.add("jp-Placeholder-content"),this._cell.title=o.__("Click to expand");const a=this._cell.appendChild(document.createElement("div"));a.classList.add("jp-Placeholder-contentContainer"),this._textContent=a.appendChild(document.createElement("span")),this._textContent.className="jp-PlaceholderText",this._textContent.innerText=null!==(i=e.text)&&void 0!==i?i:"",n.appendChild(this._cell),h.ellipsesIcon.element({container:a.appendChild(document.createElement("span")),className:"jp-MoreHorizIcon",elementPosition:"center",height:"auto",width:"32px"}),this.addClass("jp-Placeholder"),this._callback=e.callback}set text(e){this._textContent.innerText=e}get text(){return this._textContent.innerText}onAfterAttach(e){super.onAfterAttach(e),this.node.addEventListener("click",this._callback)}onBeforeDetach(e){this.node.removeEventListener("click",this._callback),super.onBeforeDetach(e)}}class W extends F{constructor(e){super({...e,promptClass:"jp-Placeholder-prompt jp-InputPrompt"}),this.addClass("jp-InputPlaceholder")}}class L extends F{constructor(e){super({...e,promptClass:"jp-Placeholder-prompt jp-OutputPrompt"}),this.addClass("jp-OutputPlaceholder")}}var T=s(81059),R=s(44548),V=s(57342);const z="jp-mod-selected";class B extends T.EditorSearchProvider{constructor(e){super(),this.cell=e,this.cell.inViewport||this.cell.editor||(0,R.signalToPromise)(e.inViewportChanged).then((([,e])=>{e&&this.cmHandler.setEditor(this.editor)}))}get editor(){return this.cell.editor}get model(){return this.cell.model}}class U extends B{constructor(e){super(e),this.currentProviderIndex=-1,this.outputsProvider=[];const t=this.cell.outputArea;this._onOutputsChanged(t,t.widgets.length).catch((e=>{console.error("Failed to initialize search on cell outputs.",e)})),t.outputLengthChanged.connect(this._onOutputsChanged,this),t.disposed.connect((()=>{t.outputLengthChanged.disconnect(this._onOutputsChanged)}),this)}get matchesCount(){return this.isActive?super.matchesCount+this.outputsProvider.reduce(((e,t)=>{var s;return e+(null!==(s=t.matchesCount)&&void 0!==s?s:0)}),0):0}async clearHighlight(){await super.clearHighlight(),await Promise.all(this.outputsProvider.map((e=>e.clearHighlight())))}dispose(){this.isDisposed||(super.dispose(),this.outputsProvider.map((e=>{e.dispose()})),this.outputsProvider.length=0)}async highlightNext(e,t){var s;const i=null!==(s=null==t?void 0:t.from)&&void 0!==s?s:"";if(!(0===this.matchesCount||"previous-match"===i&&null!==this.currentIndex&&this.currentIndex+1>=this.cmHandler.matches.length)&&this.isActive){if(-1===this.currentProviderIndex){const s=await super.highlightNext(e,t);if(s)return this.currentIndex=this.cmHandler.currentIndex,s;this.currentProviderIndex=0}for(;this.currentProviderIndex<this.outputsProvider.length;){const e=this.outputsProvider[this.currentProviderIndex],t=await e.highlightNext(!1);if(t)return this.currentIndex=super.matchesCount+this.outputsProvider.slice(0,this.currentProviderIndex).reduce(((e,t)=>{var s;return e+(null!==(s=t.matchesCount)&&void 0!==s?s:0)}),0)+e.currentMatchIndex,t;this.currentProviderIndex+=1}return this.currentProviderIndex=-1,void(this.currentIndex=null)}this.currentIndex=null}async highlightPrevious(){if(0!==this.matchesCount&&this.isActive){for(null===this.currentIndex&&(this.currentProviderIndex=this.outputsProvider.length-1);this.currentProviderIndex>=0;){const e=this.outputsProvider[this.currentProviderIndex],t=await e.highlightPrevious(!1);if(t)return this.currentIndex=super.matchesCount+this.outputsProvider.slice(0,this.currentProviderIndex).reduce(((e,t)=>{var s;return e+(null!==(s=t.matchesCount)&&void 0!==s?s:0)}),0)+e.currentMatchIndex,t;this.currentProviderIndex-=1}const e=await super.highlightPrevious();return e?(this.currentIndex=this.cmHandler.currentIndex,e):void(this.currentIndex=null)}this.currentIndex=null}async startQuery(e,t){await super.startQuery(e,t),!1!==(null==t?void 0:t.output)&&this.isActive&&await Promise.all(this.outputsProvider.map((t=>t.startQuery(e))))}async endQuery(){var e;await super.endQuery(),!1!==(null===(e=this.filters)||void 0===e?void 0:e.output)&&this.isActive&&await Promise.all(this.outputsProvider.map((e=>e.endQuery())))}async _onOutputsChanged(e,t){var s;this.outputsProvider.forEach((e=>{e.dispose()})),this.outputsProvider.length=0,this.currentProviderIndex=-1,this.outputsProvider=this.cell.outputArea.widgets.map((e=>new V.GenericSearchProvider(e))),this.isActive&&this.query&&!1!==(null===(s=this.filters)||void 0===s?void 0:s.output)&&await Promise.all([this.outputsProvider.map((e=>{e.startQuery(this.query)}))]),this._stateChanged.emit()}}class $ extends B{constructor(e){super(e),this._unrenderedByHighlight=!1,this.renderedProvider=new V.GenericSearchProvider(e.renderer)}async clearHighlight(){await super.clearHighlight(),await this.renderedProvider.clearHighlight()}dispose(){this.isDisposed||(super.dispose(),this.renderedProvider.dispose())}async endQuery(){await super.endQuery(),await this.renderedProvider.endQuery()}async highlightNext(e=!0,t){let s;if(!this.isActive)return s;const i=this.cell;if(i.rendered&&this.matchesCount>0){this._unrenderedByHighlight=!0;const e=(0,R.signalToPromise)(i.renderedChanged);i.rendered=!1,await e}return s=await super.highlightNext(e,t),s}async highlightPrevious(){let e;const t=this.cell;if(t.rendered&&this.matchesCount>0){this._unrenderedByHighlight=!0;const e=(0,R.signalToPromise)(t.renderedChanged);t.rendered=!1,await e}return e=await super.highlightPrevious(),e}async startQuery(e,t){await super.startQuery(e,t);const s=this.cell;s.rendered&&this.onRenderedChanged(s,s.rendered),s.renderedChanged.connect(this.onRenderedChanged,this)}async replaceAllMatches(e){const t=await super.replaceAllMatches(e);return this.cell.rendered&&this.cell.update(),t}onRenderedChanged(e,t){var s;this._unrenderedByHighlight||(this.currentIndex=null),this._unrenderedByHighlight=!1,this.isActive&&(t?this.renderedProvider.startQuery(this.query):(null===(s=e.editor)||void 0===s||s.setCursorPosition({column:0,line:0}),this.renderedProvider.endQuery()))}}function J(e){if(e.isPlaceholder())return new B(e);switch(e.model.type){case"code":return new U(e);case"markdown":return new $(e);default:return new B(e)}}var Q=s(63720),q=s(15465),G=s(50102),X=s(45776),Y=s(20998),K=s(33625),Z=s(49503),ee=s(97934);const te="jp-mod-resizedCell";class se extends C.Widget{constructor(e){super(),this.targetNode=e,this._isActive=!1,this._isDragging=!1,this.sizeChanged=new f.Signal(this),this.addClass("jp-CellResizeHandle"),this._resizer=new ee.Throttler((e=>this._resize(e)),50)}dispose(){this._resizer.dispose(),super.dispose()}handleEvent(e){var t,s;switch(e.type){case"dblclick":null===(t=this.targetNode.parentNode)||void 0===t||t.childNodes.forEach((e=>{e.classList.remove(te)})),document.documentElement.style.setProperty("--jp-side-by-side-output-size","1fr"),this._isActive=!1;break;case"mousedown":this._isDragging=!0,this._isActive||(null===(s=this.targetNode.parentNode)||void 0===s||s.childNodes.forEach((e=>{e.classList.add(te)})),this._isActive=!0),window.addEventListener("mousemove",this),window.addEventListener("mouseup",this);break;case"mousemove":this._isActive&&this._isDragging&&this._resizer.invoke(e);break;case"mouseup":this._isDragging=!1,window.removeEventListener("mousemove",this),window.removeEventListener("mouseup",this)}}onAfterAttach(e){this.node.addEventListener("dblclick",this),this.node.addEventListener("mousedown",this),super.onAfterAttach(e)}onBeforeDetach(e){this.node.removeEventListener("dblclick",this),this.node.removeEventListener("mousedown",this),super.onBeforeDetach(e)}_resize(e){const{width:t,x:s}=this.targetNode.getBoundingClientRect(),i=t/(e.clientX-s)-1;if(0<i){const e=Math.max(Math.min(Math.abs(i),50),.05);document.documentElement.style.setProperty("--jp-side-by-side-output-size",`${e}fr`),this.sizeChanged.emit(e)}}}const ie="jp-Cell-outputWrapper",ne="jp-mod-dirty",oe="jp-MarkdownHeadingCollapsed",re="jp-collapseHeadingButton",ae="jp-showHiddenCellsButton",de="jp-mod-rendered",le="jp-mod-noOutputs",he="application/x-jupyter-icontentsrich";class ue extends C.Widget{constructor(e){var t,s,i,n;super(),this.prompt="",this._displayChanged=new f.Signal(this),this._scrollRequested=new f.Signal(this),this._scrollHandlerExtension=Q.EditorView.scrollHandler.of(((e,t,s)=>{const i=null!==this._inViewport&&!this._inViewport;return this._scrollRequested.emit({defaultPrevented:i,scrollWithinCell:()=>{e.dispatch({effects:Q.EditorView.scrollIntoView(t,s)})}}),i})),this._editorConfig={},this._editorExtensions=[],this._inputHidden=!1,this._inViewportChanged=new f.Signal(this),this._readOnly=!1,this._ready=new Y.PromiseDelegate,this._resizeDebouncer=new ee.Debouncer((()=>{this._displayChanged.emit()}),0),this._syncCollapse=!1,this._syncEditable=!1,this.addClass("jp-Cell");const o=this._model=e.model;this.contentFactory=e.contentFactory,this.layout=null!==(t=e.layout)&&void 0!==t?t:new C.PanelLayout,this.translator=null!==(s=e.translator)&&void 0!==s?s:N.nullTranslator,this._editorConfig={searchWithCM:!1,...e.editorConfig},this._editorExtensions=null!==(i=e.editorExtensions)&&void 0!==i?i:[],this._editorExtensions.push(this._scrollHandlerExtension),this._placeholder=!0,this._inViewport=null,this.placeholder=null===(n=e.placeholder)||void 0===n||n,o.metadataChanged.connect(this.onMetadataChanged,this)}initializeState(){return this.loadCollapseState(),this.loadEditableState(),this}get displayChanged(){return this._displayChanged}get inViewport(){var e;return null!==(e=this._inViewport)&&void 0!==e&&e}set inViewport(e){this._inViewport!==e&&(this._inViewport=e,this._inViewportChanged.emit(this._inViewport))}get inViewportChanged(){return this._inViewportChanged}get placeholder(){return this._placeholder}set placeholder(e){this._placeholder!==e&&!1===e&&(this.initializeDOM(),this._placeholder=e,this._ready.resolve())}get promptNode(){return this.placeholder?null:this._inputHidden?this._inputPlaceholder.node.firstElementChild:this._input.promptNode}get editorWidget(){var e,t;return null!==(t=null===(e=this._input)||void 0===e?void 0:e.editorWidget)&&void 0!==t?t:null}get editor(){var e,t;return null!==(t=null===(e=this._input)||void 0===e?void 0:e.editor)&&void 0!==t?t:null}get editorConfig(){return this._editorConfig}get headings(){return new Array}get model(){return this._model}get inputArea(){return this._input}get readOnly(){return this._readOnly}set readOnly(e){e!==this._readOnly&&(this._readOnly=e,this.syncEditable&&this.saveEditableState(),this.update())}isPlaceholder(){return this.placeholder}saveEditableState(){const{sharedModel:e}=this.model,t=e.getMetadata("editable");this.readOnly&&!1===t||!this.readOnly&&void 0===t||(this.readOnly?e.setMetadata("editable",!1):e.deleteMetadata("editable"))}loadEditableState(){this.readOnly=!1===this.model.sharedModel.getMetadata("editable")}get ready(){return this._ready.promise}setPrompt(e){return this._setPrompt(e)}_setPrompt(e){var t;this.prompt=e,null===(t=this._input)||void 0===t||t.setPrompt(e)}get inputHidden(){return this._inputHidden}set inputHidden(e){var t;if(this._inputHidden!==e){if(!this.placeholder){const s=this._inputWrapper.layout;e?(this._input.parent=null,this._inputPlaceholder&&(this._inputPlaceholder.text=null===(t=this.model.sharedModel.getSource().split("\n"))||void 0===t?void 0:t[0]),s.addWidget(this._inputPlaceholder)):(this._inputPlaceholder.parent=null,s.addWidget(this._input))}this._inputHidden=e,this.syncCollapse&&this.saveCollapseState(),this.handleInputHidden(e)}}saveCollapseState(){const e={...this.model.getMetadata("jupyter")};this.inputHidden&&!0===e.source_hidden||!this.inputHidden&&void 0===e.source_hidden||(this.inputHidden?e.source_hidden=!0:delete e.source_hidden,0===Object.keys(e).length?this.model.deleteMetadata("jupyter"):this.model.setMetadata("jupyter",e))}loadCollapseState(){var e;const t=null!==(e=this.model.getMetadata("jupyter"))&&void 0!==e?e:{};this.inputHidden=!!t.source_hidden}handleInputHidden(e){}get syncCollapse(){return this._syncCollapse}set syncCollapse(e){this._syncCollapse!==e&&(this._syncCollapse=e,e&&this.loadCollapseState())}get syncEditable(){return this._syncEditable}set syncEditable(e){this._syncEditable!==e&&(this._syncEditable=e,e&&this.loadEditableState())}clone(){return new(0,this.constructor)({model:this.model,contentFactory:this.contentFactory,placeholder:!1,translator:this.translator})}dispose(){this.isDisposed||(this._resizeDebouncer.dispose(),this._input=null,this._model=null,this._inputWrapper=null,this._inputPlaceholder=null,super.dispose())}updateEditorConfig(e){this._editorConfig={...this._editorConfig,...e},this.editor&&this.editor.setOptions(this._editorConfig)}get scrollRequested(){return this._scrollRequested}initializeDOM(){if(!this.placeholder)return;const e=this.contentFactory,t=this._model,s=e.createCellHeader();s.addClass("jp-Cell-header"),this.layout.addWidget(s);const i=this._inputWrapper=new C.Panel;i.addClass("jp-Cell-inputWrapper");const n=new g;n.addClass("jp-Cell-inputCollapser");const o=this._input=new w({model:t,contentFactory:e,editorOptions:this.getEditorOptions()});o.addClass("jp-Cell-inputArea"),i.addWidget(n),i.addWidget(o),this.layout.addWidget(i),this._inputPlaceholder=new W({callback:()=>{this.inputHidden=!this.inputHidden},text:o.model.sharedModel.getSource().split("\n")[0],translator:this.translator}),o.model.contentChanged.connect(((e,t)=>{var s;this._inputPlaceholder&&this.inputHidden&&(this._inputPlaceholder.text=null===(s=e.sharedModel.getSource().split("\n"))||void 0===s?void 0:s[0])})),this.inputHidden&&(o.parent=null,i.layout.addWidget(this._inputPlaceholder));const r=this.contentFactory.createCellFooter();r.addClass("jp-Cell-footer"),this.layout.addWidget(r)}getEditorOptions(){return{config:this.editorConfig,extensions:this._editorExtensions}}onBeforeAttach(e){this.placeholder&&(this.placeholder=!1)}onAfterAttach(e){this.update()}onActivateRequest(e){var t;null===(t=this.editor)||void 0===t||t.focus()}onResize(e){this._resizeDebouncer.invoke()}onUpdateRequest(e){var t,s;this._model&&(null===(t=this.editor)||void 0===t?void 0:t.getOption("readOnly"))!==this._readOnly&&(null===(s=this.editor)||void 0===s||s.setOption("readOnly",this._readOnly))}onContentChanged(){var e;this.inputHidden&&this._inputPlaceholder&&(this._inputPlaceholder.text=null===(e=this.model.sharedModel.getSource().split("\n"))||void 0===e?void 0:e[0])}onMetadataChanged(e,t){switch(t.key){case"jupyter":this.syncCollapse&&this.loadCollapseState();break;case"editable":this.syncEditable&&this.loadEditableState()}}}!function(e){let t;!function(e){e[e.HTML=0]="HTML",e[e.Markdown=1]="Markdown"}(t=e.HeadingType||(e.HeadingType={})),e.ContentFactory=class{constructor(e){this._editorFactory=e.editorFactory}get editorFactory(){return this._editorFactory}createCellHeader(){return new _}createCellFooter(){return new v}createInputPrompt(){return new x}createOutputPrompt(){return new O.OutputPrompt}createStdin(e){return new O.Stdin(e)}}}(ue||(ue={}));class ce extends C.PanelLayout{onBeforeAttach(e){let t=!0;const s=this.parent.node.firstElementChild;for(const i of this)s&&(i.node===s?t=!1:(Z.MessageLoop.sendMessage(i,e),t?this.parent.node.insertBefore(i.node,s):this.parent.node.appendChild(i.node),this.parent.isHidden||i.setFlag(C.Widget.Flag.IsVisible),Z.MessageLoop.sendMessage(i,C.Widget.Msg.AfterAttach)))}onAfterDetach(e){for(const t of this)!t.hasClass(ie)&&t.node.isConnected&&(Z.MessageLoop.sendMessage(t,C.Widget.Msg.BeforeDetach),this.parent.node.removeChild(t.node),Z.MessageLoop.sendMessage(t,e))}}class pe extends ue{constructor(e){var t;super({layout:new ce,...e,placeholder:!0}),this._detectCaretMovementInOuput=e=>{const t=null!==this._inViewport&&!this._inViewport,s=e.target;if(!(s&&s instanceof HTMLElement))return;this._lastTarget&&(this._lastTarget.removeEventListener("selectionchange",this._lastOnCaretMovedHandler),document.removeEventListener("selectionchange",this._lastOnCaretMovedHandler));const i=()=>{this._scrollRequested.emit({scrollWithinCell:({scroller:e})=>{u.ElementExt.scrollIntoViewIfNeeded(e,s)},defaultPrevented:t})};this._lastTarget=s,this._lastOnCaretMovedHandler=i,s.addEventListener("selectionchange",i,{once:!0}),document.addEventListener("selectionchange",i,{once:!0}),setTimeout((()=>{s.removeEventListener("selectionchange",i),document.removeEventListener("selectionchange",i)}),250)},this._headingsCache=null,this._outputHidden=!1,this._outputWrapper=null,this._outputPlaceholder=null,this._syncScrolled=!1,this._lastTarget=null,this._lastOutputHeight="",this.addClass("jp-CodeCell");const s=this.translator.load("jupyterlab"),i=this._rendermime=e.rendermime,n=this.contentFactory,o=this.model;this.maxNumberOutputs=e.maxNumberOutputs;const r=0===o.outputs.length?s.__("Code Cell Content"):s.__("Code Cell Content with Output");this.node.setAttribute("aria-label",r);const a=this._output=new O.OutputArea({model:this.model.outputs,rendermime:i,contentFactory:n,maxNumberOutputs:this.maxNumberOutputs,translator:this.translator,promptOverlay:!0,inputHistoryScope:e.inputHistoryScope});a.node.addEventListener("keydown",this._detectCaretMovementInOuput),a.addClass("jp-Cell-outputArea"),a.toggleScrolling.connect((()=>{this.outputsScrolled=!this.outputsScrolled})),a.initialize.connect((()=>{this.updatePromptOverlayIcon()})),this.placeholder=null===(t=e.placeholder)||void 0===t||t,o.outputs.changed.connect(this.onOutputChanged,this),o.outputs.stateChanged.connect(this.onOutputChanged,this),o.stateChanged.connect(this.onStateChanged,this)}initializeDOM(){if(!this.placeholder)return;super.initializeDOM(),this._updatePrompt();const e=this._outputWrapper=new C.Panel;e.addClass(ie);const t=new m;t.addClass("jp-Cell-outputCollapser"),e.addWidget(t),0===this.model.outputs.length&&this.addClass(le),this._output.outputLengthChanged.connect(this._outputLengthHandler,this),e.addWidget(this._output);const s=this.layout,i=new se(this.node);i.sizeChanged.connect(this._sizeChangedHandler,this),s.insertWidget(s.widgets.length-1,i),s.insertWidget(s.widgets.length-1,e),this.model.isDirty&&this.addClass(ne),this._outputPlaceholder=new L({callback:()=>{this.outputHidden=!this.outputHidden},text:this.getOutputPlaceholderText(),translator:this.translator});const n=e.layout;this.outputHidden&&(n.removeWidget(this._output),n.addWidget(this._outputPlaceholder),this.inputHidden&&!e.isHidden&&this._outputWrapper.hide());const o=this.translator.load("jupyterlab"),r=0===this.model.outputs.length?o.__("Code Cell Content"):o.__("Code Cell Content with Output");this.node.setAttribute("aria-label",r)}getOutputPlaceholderText(){var e;const t=this.model.outputs.get(0);if(!(null==t?void 0:t.data))return;const s=["text/html","image/svg+xml","application/pdf","text/markdown","text/plain","application/vnd.jupyter.stderr","application/vnd.jupyter.stdout","text"].find((e=>{const s=t.data[e];return"string"==(Array.isArray(s)?typeof s[0]:typeof s)})),i=t.data[null!=s?s:""];return void 0!==i?null===(e=Array.isArray(i)?i:null==i?void 0:i.split("\n"))||void 0===e?void 0:e.find((e=>""!==e)):void 0}initializeState(){return super.initializeState(),this.loadScrolledState(),this._updatePrompt(),this}get headings(){if(!this._headingsCache){const e=[],t=this.model.outputs;for(let s=0;s<t.length;s++){const i=t.get(s);let n=null,o=null;Object.keys(i.data).forEach((e=>{!o&&X.TableOfContentsUtils.Markdown.isMarkdown(e)?o=e:!n&&X.TableOfContentsUtils.isHTML(e)&&(n=e)})),n?e.push(...X.TableOfContentsUtils.getHTMLHeadings(this._rendermime.sanitizer.sanitize(i.data[n])).map((e=>({...e,outputIndex:s,type:ue.HeadingType.HTML})))):o&&e.push(...X.TableOfContentsUtils.Markdown.getHeadings(i.data[o]).map((e=>({...e,outputIndex:s,type:ue.HeadingType.Markdown}))))}this._headingsCache=e}return[...this._headingsCache]}get outputArea(){return this._output}get outputHidden(){return this._outputHidden}set outputHidden(e){var t;if(this._outputHidden!==e){if(!this.placeholder){const s=this._outputWrapper.layout;e?(s.removeWidget(this._output),s.addWidget(this._outputPlaceholder),this.inputHidden&&!this._outputWrapper.isHidden&&this._outputWrapper.hide(),this._outputPlaceholder&&(this._outputPlaceholder.text=null!==(t=this.getOutputPlaceholderText())&&void 0!==t?t:"")):(this._outputWrapper.isHidden&&this._outputWrapper.show(),s.removeWidget(this._outputPlaceholder),s.addWidget(this._output))}this._outputHidden=e,this.syncCollapse&&this.saveCollapseState()}}saveCollapseState(){this.model.sharedModel.transact((()=>{super.saveCollapseState();const e=this.model.getMetadata("collapsed");this.outputHidden&&!0===e||!this.outputHidden&&void 0===e||(this.outputHidden?this.model.setMetadata("collapsed",!0):this.model.deleteMetadata("collapsed"))}),!1)}loadCollapseState(){super.loadCollapseState(),this.outputHidden=!!this.model.getMetadata("collapsed")}get outputsScrolled(){return this._outputsScrolled}set outputsScrolled(e){this.toggleClass("jp-mod-outputsScrolled",e),this._outputsScrolled=e,this.syncScrolled&&this.saveScrolledState(),this.updatePromptOverlayIcon()}updatePromptOverlayIcon(){var e;const t=q.DOMUtils.findElement(this.node,"jp-OutputArea-promptOverlay");if(!t)return;if(t.clientHeight<=24)return void(null===(e=t.firstChild)||void 0===e||e.remove());let s;this._outputsScrolled?(h.expandIcon.element({container:t}),s="Expand Output"):(h.collapseIcon.element({container:t}),s="Collapse Output");const i=this.translator.load("jupyterlab");t.title=i.__(s)}saveScrolledState(){const e=this.model.getMetadata("scrolled");this.outputsScrolled&&!0===e||!this.outputsScrolled&&void 0===e||(this.outputsScrolled?this.model.setMetadata("scrolled",!0):(this.outputArea.node.style.height="",this.model.deleteMetadata("scrolled")))}loadScrolledState(){"auto"===this.model.getMetadata("scrolled")?this.outputsScrolled=!1:this.outputsScrolled=!!this.model.getMetadata("scrolled")}get syncScrolled(){return this._syncScrolled}set syncScrolled(e){this._syncScrolled!==e&&(this._syncScrolled=e,e&&this.loadScrolledState())}handleInputHidden(e){this.placeholder||(!e&&this._outputWrapper.isHidden?this._outputWrapper.show():e&&!this._outputWrapper.isHidden&&this._outputHidden&&this._outputWrapper.hide())}clone(){return new(0,this.constructor)({model:this.model,contentFactory:this.contentFactory,rendermime:this._rendermime,placeholder:!1,translator:this.translator})}cloneOutputArea(){return new O.SimplifiedOutputArea({model:this.model.outputs,contentFactory:this.contentFactory,rendermime:this._rendermime})}dispose(){this.isDisposed||(this._output.outputLengthChanged.disconnect(this._outputLengthHandler,this),this._output.node.removeEventListener("keydown",this._detectCaretMovementInOuput),this._rendermime=null,this._output=null,this._outputWrapper=null,this._outputPlaceholder=null,super.dispose())}onStateChanged(e,t){switch(t.name){case"executionCount":this.model.executionState="idle",this._updatePrompt();break;case"executionState":this._updatePrompt();break;case"isDirty":e.isDirty?this.addClass(ne):this.removeClass(ne)}}onOutputChanged(){var e;this._headingsCache=null,this._outputPlaceholder&&this.outputHidden&&(this._outputPlaceholder.text=null!==(e=this.getOutputPlaceholderText())&&void 0!==e?e:""),this.updatePromptOverlayIcon();const t=this.outputArea.node.style.height;0===this.model.outputs.length&&""!==t?(this._lastOutputHeight=t,this.outputArea.node.style.height=""):this.model.outputs.length>0&&""===t&&(this.outputArea.node.style.height=this._lastOutputHeight)}onMetadataChanged(e,t){switch(t.key){case"scrolled":this.syncScrolled&&this.loadScrolledState();break;case"collapsed":this.syncCollapse&&this.loadCollapseState()}super.onMetadataChanged(e,t)}_updatePrompt(){let e;e="running"==this.model.executionState?"*":`${this.model.executionCount||""}`,this._setPrompt(e)}_outputLengthHandler(e,t){const s=0===t;this.toggleClass(le,s);const i=this.translator.load("jupyterlab"),n=s?i.__("Code Cell Content"):i.__("Code Cell Content with Output");this.node.setAttribute("aria-label",n)}_sizeChangedHandler(e){this._displayChanged.emit()}}!function(e){e.execute=async function(e,t,s){var i;const n=e.model,o=n.sharedModel.getSource();if(!o.trim()||!(null===(i=t.session)||void 0===i?void 0:i.kernel))return void n.sharedModel.transact((()=>{n.clearExecution()}),!1);const r={cellId:n.sharedModel.getId()};s={...n.metadata,...s,...r};const{recordTiming:a}=s;let d;n.sharedModel.transact((()=>{n.clearExecution(),e.outputHidden=!1}),!1),n.executionState="running",n.trusted=!0;try{const i=O.OutputArea.execute(o,e.outputArea,t,s);if(a){const t=e=>{let t;switch(e.header.msg_type){case"status":t=`status.${e.content.execution_state}`;break;case"execute_input":t="execute_input";break;default:return!0}const s=e.header.date||(new Date).toISOString(),i=Object.assign({},n.getMetadata("execution"));return i[`iopub.${t}`]=s,n.setMetadata("execution",i),!0};e.outputArea.future.registerMessageHook(t)}else n.deleteMetadata("execution");d=e.outputArea.future;const r=await i;if(n.executionCount=r.content.execution_count,a){const e=Object.assign({},n.getMetadata("execution")),t=r.metadata.started;t&&(e["shell.execute_reply.started"]=t);const s=r.header.date;e["shell.execute_reply"]=s||(new Date).toISOString(),n.setMetadata("execution",e)}return r}catch(t){if(d&&!e.isDisposed&&e.outputArea.future===d&&(e.model.executionState="idle",a&&d.isDisposed)){const e=Object.assign({},n.getMetadata("execution"));e.execution_failed=(new Date).toISOString(),n.setMetadata("execution",e)}throw t}}}(pe||(pe={}));class ge extends ue{handleEvent(e){switch(e.type){case"lm-dragover":this._evtDragOver(e);break;case"lm-drop":this._evtDrop(e)}}getEditorOptions(){var e,t;const s=null!==(e=super.getEditorOptions())&&void 0!==e?e:{};return s.extensions=[...null!==(t=s.extensions)&&void 0!==t?t:[],Q.EditorView.domEventHandlers({dragenter:e=>{e.preventDefault()},dragover:e=>{e.preventDefault()},drop:e=>{this._evtNativeDrop(e)},paste:e=>{this._evtPaste(e)}})],s}onAfterAttach(e){super.onAfterAttach(e);const t=this.node;t.addEventListener("lm-dragover",this),t.addEventListener("lm-drop",this)}onBeforeDetach(e){const t=this.node;t.removeEventListener("lm-dragover",this),t.removeEventListener("lm-drop",this),super.onBeforeDetach(e)}_evtDragOver(e){(0,K.some)(G.imageRendererFactory.mimeTypes,(t=>!!e.mimeData.hasData(he)&&e.mimeData.getData(he).model.mimetype===t))&&(e.preventDefault(),e.stopPropagation(),e.dropAction=e.proposedAction)}_evtPaste(e){if(e.clipboardData){const t=e.clipboardData.items;for(let s=0;s<t.length;s++){if("text/plain"===t[s].type){if(s<t.length-1&&"file"===t[s+1].kind)continue;t[s].getAsString((e=>{var t,s;null===(s=(t=this.editor).replaceSelection)||void 0===s||s.call(t,e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}))}this._attachFiles(e.clipboardData.items)}}e.preventDefault()}_evtNativeDrop(e){e.dataTransfer&&this._attachFiles(e.dataTransfer.items),e.preventDefault()}_evtDrop(e){const t=e.mimeData.types().filter((t=>{if(t===he){const t=e.mimeData.getData(he);return-1!==G.imageRendererFactory.mimeTypes.indexOf(t.model.mimetype)}return-1!==G.imageRendererFactory.mimeTypes.indexOf(t)}));if(0!==t.length)if(e.preventDefault(),e.stopPropagation(),"none"!==e.proposedAction){e.dropAction="copy";for(const s of t)if(s===he){const{model:t,withContent:s}=e.mimeData.getData(he);if("file"===t.type){const e=this._generateURI(t.name);this.updateCellSourceWithAttachment(t.name,e),s().then((t=>{this.model.attachments.set(e,{[t.mimetype]:t.content})}))}}else{const t=this._generateURI();this.model.attachments.set(t,{[s]:e.mimeData.getData(s)}),this.updateCellSourceWithAttachment(t,t)}}else e.dropAction="none"}_attachFiles(e){for(let t=0;t<e.length;t++){const s=e[t];if("file"===s.kind){const e=s.getAsFile();e&&this._attachFile(e)}}}_attachFile(e){const t=new FileReader;t.onload=s=>{const{href:i,protocol:n}=R.URLExt.parse(t.result);if("data:"!==n)return;const o=/([\w+\/\+]+)?(?:;(charset=[\w\d-]*|base64))?,(.*)/.exec(i);if(!o||4!==o.length)return;const r=o[1],a={[r]:o[3]},d=this._generateURI(e.name);r.startsWith("image/")&&(this.model.attachments.set(d,a),this.updateCellSourceWithAttachment(e.name,d))},t.onerror=t=>{console.error(`Failed to attach ${e.name}`+t)},t.readAsDataURL(e)}_generateURI(e=""){const t=e.lastIndexOf(".");return-1!==t?Y.UUID.uuid4().concat(e.substring(t)):Y.UUID.uuid4()}}class me extends ge{constructor(e){var t,s,i,n;super({...e,placeholder:!0}),this._headingsCache=null,this._headingCollapsedChanged=new f.Signal(this),this._prevText="",this._rendered=!0,this._renderedChanged=new f.Signal(this),this._showEditorForReadOnlyMarkdown=!0,this.addClass("jp-MarkdownCell"),this.model.contentChanged.connect(this.onContentChanged,this);const o=this.translator.load("jupyterlab");this.node.setAttribute("aria-label",o.__("Markdown Cell Content")),this._rendermime=e.rendermime.clone({resolver:new M.AttachmentsResolver({parent:null!==(t=e.rendermime.resolver)&&void 0!==t?t:void 0,model:this.model.attachments})}),this._renderer=this._rendermime.createRenderer("text/markdown"),this._renderer.addClass("jp-MarkdownOutput"),this._headingCollapsed=null!==(s=this.model.getMetadata(oe))&&void 0!==s&&s,this._showEditorForReadOnlyMarkdown=null!==(i=e.showEditorForReadOnlyMarkdown)&&void 0!==i?i:me.defaultShowEditorForReadOnlyMarkdown,this.placeholder=null===(n=e.placeholder)||void 0===n||n,this._monitor=new R.ActivityMonitor({signal:this.model.contentChanged,timeout:1e3}),this.ready.then((()=>{this.isDisposed||this._monitor.activityStopped.connect((()=>{this._rendered&&this.update()}),this)})).catch((e=>{console.error("Failed to be ready",e)}))}get headingInfo(){const e=this.headings;if(e.length>0){const{text:t,level:s}=e.reduce(((e,t)=>e.level<=t.level?e:t),e[0]);return{text:t,level:s}}return{text:"",level:-1}}get headings(){if(!this._headingsCache){const e=X.TableOfContentsUtils.Markdown.getHeadings(this.model.sharedModel.getSource());this._headingsCache=e.map((e=>({...e,type:ue.HeadingType.Markdown})))}return[...this._headingsCache]}get headingCollapsed(){return this._headingCollapsed}set headingCollapsed(e){var t;if(this._headingCollapsed!==e){this._headingCollapsed=e,e?this.model.setMetadata(oe,e):"undefined"!==this.model.getMetadata(oe)&&this.model.deleteMetadata(oe);const s=null===(t=this.inputArea)||void 0===t?void 0:t.promptNode.getElementsByClassName(re)[0];s&&(e?s.classList.add("jp-mod-collapsed"):s.classList.remove("jp-mod-collapsed")),this.renderCollapseButtons(this._renderer),this._headingCollapsedChanged.emit(this._headingCollapsed)}}get numberChildNodes(){return this._numberChildNodes}set numberChildNodes(e){this._numberChildNodes=e,this.renderCollapseButtons(this._renderer)}get headingCollapsedChanged(){return this._headingCollapsedChanged}get rendered(){return this._rendered}set rendered(e){this.readOnly&&!1===this._showEditorForReadOnlyMarkdown&&(e=!0),e!==this._rendered&&(this._rendered=e,this._handleRendered().then((()=>{this._displayChanged.emit(),this._renderedChanged.emit(this._rendered)})).catch((e=>{console.error("Failed to render",e)})))}get renderedChanged(){return this._renderedChanged}get showEditorForReadOnly(){return this._showEditorForReadOnlyMarkdown}set showEditorForReadOnly(e){this._showEditorForReadOnlyMarkdown=e,!1===e&&(this.rendered=!0)}get renderer(){return this._renderer}dispose(){this.isDisposed||(this._monitor.dispose(),super.dispose())}initializeDOM(){this.placeholder&&(super.initializeDOM(),this.renderCollapseButtons(this._renderer),this._handleRendered().catch((e=>{console.error("Failed to render",e)})))}maybeCreateCollapseButton(){var e;const{level:t}=this.headingInfo;if(t>0&&0==(null===(e=this.inputArea)||void 0===e?void 0:e.promptNode.getElementsByClassName(re).length)){let e=this.inputArea.promptNode.appendChild(document.createElement("button"));e.className=`jp-Button ${re}`,e.setAttribute("data-heading-level",t.toString()),this._headingCollapsed?e.classList.add("jp-mod-collapsed"):e.classList.remove("jp-mod-collapsed"),e.onclick=e=>{this.headingCollapsed=!this.headingCollapsed}}}maybeCreateOrUpdateExpandButton(){const e=this.node.getElementsByClassName(ae);let t=this.translator.load("jupyterlab")._n("%1 cell hidden","%1 cells hidden",this._numberChildNodes);if(this.headingCollapsed&&this._numberChildNodes>0&&0==e.length){const e=document.createElement("button");e.className=`jp-mod-minimal jp-Button ${ae}`,h.addIcon.render(e);const s=document.createElement("div");s.textContent=t,e.appendChild(s),e.onclick=()=>{this.headingCollapsed=!1},this.node.appendChild(e)}if(this.headingCollapsed&&this._numberChildNodes>0&&1==e.length&&(e[0].childNodes[1].textContent=t),!(this.headingCollapsed&&this._numberChildNodes>0))for(const t of e)this.node.removeChild(t)}onContentChanged(){super.onContentChanged(),this._headingsCache=null}renderCollapseButtons(e){this.node.classList.toggle(oe,this._headingCollapsed),this.maybeCreateCollapseButton(),this.maybeCreateOrUpdateExpandButton()}renderInput(e){this.addClass(de),this.placeholder||this.isDisposed||(this.renderCollapseButtons(e),this.inputArea.renderInput(e))}showEditor(){if(this.removeClass(de),!this.placeholder&&!this.isDisposed){this.inputArea.showEditor();let e=(this.model.sharedModel.getSource().match(/^#+/g)||[""])[0].length;e>0&&this.inputArea.editor.setCursorPosition({column:e+1,line:0},{scroll:!1})}}onUpdateRequest(e){this._handleRendered().catch((e=>{console.error("Failed to render",e)})),super.onUpdateRequest(e)}updateCellSourceWithAttachment(e,t){var s,i;const n=``;null===(i=null===(s=this.editor)||void 0===s?void 0:s.replaceSelection)||void 0===i||i.call(s,n)}async _handleRendered(){this._rendered?(await this._updateRenderedInput(),this._rendered&&this.renderInput(this._renderer)):this.showEditor()}_updateRenderedInput(){if(this.placeholder)return Promise.resolve();const e=this.model,t=e&&e.sharedModel.getSource()||"Type Markdown and LaTeX: $ α^2 $";if(t!==this._prevText){const e=new G.MimeModel({data:{"text/markdown":t}});return this._prevText=t,this._renderer.renderModel(e)}return Promise.resolve()}clone(){return new(0,this.constructor)({model:this.model,contentFactory:this.contentFactory,rendermime:this._rendermime,placeholder:!1,translator:this.translator})}}!function(e){e.defaultShowEditorForReadOnlyMarkdown=!0}(me||(me={}));class Ce extends ue{constructor(e){super(e),this.addClass("jp-RawCell");const t=this.translator.load("jupyterlab");this.node.setAttribute("aria-label",t.__("Raw Cell Content"))}clone(){return new(0,this.constructor)({model:this.model,contentFactory:this.contentFactory,placeholder:!1,translator:this.translator})}}}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[2479],{72479:(e,t,s)=>{s.r(t),s.d(t,{AttachmentsCell:()=>ge,AttachmentsCellModel:()=>I,Cell:()=>ue,CellDragUtils:()=>l,CellFooter:()=>v,CellHeader:()=>_,CellModel:()=>A,CellSearchProvider:()=>B,CodeCell:()=>pe,CodeCellLayout:()=>ce,CodeCellModel:()=>j,Collapser:()=>p,InputArea:()=>w,InputCollapser:()=>g,InputPlaceholder:()=>W,InputPrompt:()=>x,MarkdownCell:()=>me,MarkdownCellModel:()=>k,OutputCollapser:()=>m,OutputPlaceholder:()=>L,Placeholder:()=>F,RawCell:()=>Ce,RawCellModel:()=>D,SELECTED_HIGHLIGHT_CLASS:()=>z,createCellSearchProvider:()=>$,isCodeCellModel:()=>E,isMarkdownCellModel:()=>b,isRawCellModel:()=>H});var i=s(47087);const n="jp-dragImage",r="jp-dragImage-singlePrompt",o="jp-dragImage-content",a="jp-dragImage-prompt",d="jp-dragImage-multipleBack";var l;!function(e){e.findCell=function(e,t,s){let i=-1;for(;e&&e.parentElement;){if(s(e)){let s=-1;for(const n of t)if(n.node===e){i=++s;break}break}e=e.parentElement}return i},e.detectTargetArea=function(e,t){var s,i;let n;return n=e?(null===(s=e.editorWidget)||void 0===s?void 0:s.node.contains(t))?"input":(null===(i=e.promptNode)||void 0===i?void 0:i.contains(t))?"prompt":"cell":"unknown",n},e.shouldStartDrag=function(e,t,s,i){const n=Math.abs(s-e),r=Math.abs(i-t);return n>=5||r>=5},e.createCellDragImage=function(e,t){const s=t.length;let l;if("code"===e.model.type){const t=e.model.executionCount;l=" ",t&&(l=t.toString())}else l="";const h=e.model.sharedModel.getSource().split("\n")[0].slice(0,26);return s>1?""!==l?i.VirtualDOM.realize(i.h.div(i.h.div({className:n},i.h.span({className:a},"["+l+"]:"),i.h.span({className:o},h)),i.h.div({className:d},""))):i.VirtualDOM.realize(i.h.div(i.h.div({className:n},i.h.span({className:a}),i.h.span({className:o},h)),i.h.div({className:d},""))):""!==l?i.VirtualDOM.realize(i.h.div(i.h.div({className:`${n} ${r}`},i.h.span({className:a},"["+l+"]:"),i.h.span({className:o},h)))):i.VirtualDOM.realize(i.h.div(i.h.div({className:`${n} ${r}`},i.h.span({className:a}),i.h.span({className:o},h))))}}(l||(l={}));var h=s(76878),u=s(47392),c=s(78156);class p extends h.ReactWidget{constructor(){super(),this.addClass("jp-Collapser")}get collapsed(){return!1}render(){return c.createElement("div",{className:"jp-Collapser-child",onClick:e=>this.handleClick(e)})}}class g extends p{constructor(){super(),this.addClass("jp-InputCollapser")}get collapsed(){var e;const t=null===(e=this.parent)||void 0===e?void 0:e.parent;return!!t&&t.inputHidden}handleClick(e){var t;const s=null===(t=this.parent)||void 0===t?void 0:t.parent;s&&(s.inputHidden=!s.inputHidden),this.update()}}class m extends p{constructor(){super(),this.addClass("jp-OutputCollapser")}get collapsed(){var e;const t=null===(e=this.parent)||void 0===e?void 0:e.parent;return!!t&&t.outputHidden}handleClick(e){var t,s;const i=null===(t=this.parent)||void 0===t?void 0:t.parent;if(i&&(i.outputHidden=!i.outputHidden,i.outputHidden)){let e=null===(s=i.parent)||void 0===s?void 0:s.node;e&&u.ElementExt.scrollIntoViewIfNeeded(e,i.node)}this.update()}}var C=s(2260);class _ extends C.Widget{constructor(){super(),this.addClass("jp-CellHeader")}}class v extends C.Widget{constructor(){super(),this.addClass("jp-CellFooter")}}var y=s(983);class w extends C.Widget{constructor(e){super(),this.addClass("jp-InputArea");const{contentFactory:t,editorOptions:s,model:i}=e;this.model=i,this.contentFactory=t;const n=this._prompt=t.createInputPrompt();n.addClass("jp-InputArea-prompt");const r=this._editor=new y.CodeEditorWrapper({factory:t.editorFactory,model:i,editorOptions:s});r.addClass("jp-InputArea-editor");const o=this.layout=new C.PanelLayout;o.addWidget(n),o.addWidget(r)}get editorWidget(){return this._editor}get editor(){return this._editor.editor}get promptNode(){return this._prompt.node}get renderedInput(){return this._rendered}renderInput(e){const t=this.layout;this._rendered&&(this._rendered.parent=null),this._editor.hide(),this._rendered=e,t.addWidget(e)}showEditor(){this._rendered&&(this._rendered.parent=null),this._editor.show()}setPrompt(e){this._prompt.executionCount=e}dispose(){this.isDisposed||(this._prompt=null,this._editor=null,this._rendered=null,super.dispose())}}!function(e){e.ContentFactory=class{constructor(e){this._editor=e.editorFactory}get editorFactory(){return this._editor}createInputPrompt(){return new x}}}(w||(w={}));class x extends C.Widget{constructor(){super(),this._executionCount=null,this.addClass("jp-InputPrompt")}get executionCount(){return this._executionCount}set executionCount(e){this._executionCount=e,this.node.textContent=null===e?" ":`[${e||" "}]:`}}var f=s(2159),M=s(17820),O=s(82416),S=s(42763);const P=(0,S.createMutex)();function E(e){return"code"===e.type}function b(e){return"markdown"===e.type}function H(e){return"raw"===e.type}class A extends y.CodeEditor.Model{constructor(e={}){const{cell_type:t,sharedModel:s,...i}=e;super({sharedModel:null!=s?s:(0,S.createStandaloneCell)({cell_type:null!=t?t:"raw",id:e.id}),...i}),this.contentChanged=new f.Signal(this),this.stateChanged=new f.Signal(this),this._metadataChanged=new f.Signal(this),this._trusted=!1,this.standaloneModel=void 0===e.sharedModel,this.trusted=!!this.getMetadata("trusted")||!!e.trusted,this.sharedModel.changed.connect(this.onGenericChange,this),this.sharedModel.metadataChanged.connect(this._onMetadataChanged,this)}get metadataChanged(){return this._metadataChanged}get id(){return this.sharedModel.getId()}get metadata(){return this.sharedModel.metadata}get trusted(){return this._trusted}set trusted(e){const t=this.trusted;t!==e&&(this._trusted=e,this.onTrustedChanged(this,{newValue:e,oldValue:t}))}dispose(){this.isDisposed||(this.sharedModel.changed.disconnect(this.onGenericChange,this),this.sharedModel.metadataChanged.disconnect(this._onMetadataChanged,this),super.dispose())}onTrustedChanged(e,t){}deleteMetadata(e){return this.sharedModel.deleteMetadata(e)}getMetadata(e){return this.sharedModel.getMetadata(e)}setMetadata(e,t){void 0===t?this.sharedModel.deleteMetadata(e):this.sharedModel.setMetadata(e,t)}toJSON(){return this.sharedModel.toJSON()}onGenericChange(){this.contentChanged.emit(void 0)}_onMetadataChanged(e,t){this._metadataChanged.emit(t)}}class I extends A{constructor(e){var t;super(e);const s=null!==(t=e.contentFactory)&&void 0!==t?t:I.defaultContentFactory,i=this.sharedModel.getAttachments();this._attachments=s.createAttachmentsModel({values:i}),this._attachments.stateChanged.connect(this.onGenericChange,this),this._attachments.changed.connect(this._onAttachmentsChange,this),this.sharedModel.changed.connect(this._onSharedModelChanged,this)}get attachments(){return this._attachments}dispose(){this.isDisposed||(this._attachments.stateChanged.disconnect(this.onGenericChange,this),this._attachments.changed.disconnect(this._onAttachmentsChange,this),this._attachments.dispose(),this.sharedModel.changed.disconnect(this._onSharedModelChanged,this),super.dispose())}toJSON(){return super.toJSON()}_onAttachmentsChange(e,t){const s=this.sharedModel;P((()=>s.setAttachments(e.toJSON())))}_onSharedModelChanged(e,t){if(t.attachmentsChange){const e=this.sharedModel;P((()=>{var t;return this._attachments.fromJSON(null!==(t=e.getAttachments())&&void 0!==t?t:{})}))}}}!function(e){class t{createAttachmentsModel(e){return new M.AttachmentsModel(e)}}e.ContentFactory=t,e.defaultContentFactory=new t}(I||(I={}));class D extends I{constructor(e={}){super({cell_type:"raw",...e})}get type(){return"raw"}toJSON(){return super.toJSON()}}class k extends I{constructor(e={}){super({cell_type:"markdown",...e}),this.mimeType="text/x-ipythongfm"}get type(){return"markdown"}toJSON(){return super.toJSON()}}class j extends A{constructor(e={}){var t;super({cell_type:"code",...e}),this._executedCode="",this._isDirty=!1;const s=null!==(t=null==e?void 0:e.contentFactory)&&void 0!==t?t:j.defaultContentFactory,i=this.trusted,n=this.sharedModel.getOutputs();this._outputs=s.createOutputArea({trusted:i,values:n}),this.sharedModel.changed.connect(this._onSharedModelChanged,this),this._outputs.changed.connect(this.onGenericChange,this),this._outputs.changed.connect(this.onOutputsChange,this)}get type(){return"code"}get executionCount(){return this.sharedModel.execution_count||null}set executionCount(e){this.sharedModel.execution_count=e||null}get executionState(){return this.sharedModel.executionState}set executionState(e){this.sharedModel.executionState=e}get isDirty(){return this._isDirty}set isDirty(e){this._setDirty(e)}get outputs(){return this._outputs}clearExecution(){this.outputs.clear(),this.executionCount=null,this.executionState="idle",this._setDirty(!1),this.sharedModel.deleteMetadata("execution"),this.trusted=!0}dispose(){this.isDisposed||(this.sharedModel.changed.disconnect(this._onSharedModelChanged,this),this._outputs.changed.disconnect(this.onGenericChange,this),this._outputs.changed.disconnect(this.onOutputsChange,this),this._outputs.dispose(),this._outputs=null,super.dispose())}onTrustedChanged(e,t){const s=t.newValue;if(this._outputs&&(this._outputs.trusted=s),s){const e=this.sharedModel,t=e.getMetadata();t.trusted=!0,e.setMetadata(t)}this.stateChanged.emit({name:"trusted",oldValue:t.oldValue,newValue:s})}toJSON(){return super.toJSON()}onOutputsChange(e,t){const s=this.sharedModel;P((()=>{switch(t.type){case"add":{for(const e of t.newValues)"stream"===e.type&&e.streamText.changed.connect(((e,s)=>{if(void 0!==s.options&&s.options.silent)return;const i=this.sharedModel;"remove"===s.type?i.removeStreamOutput(t.newIndex,s.start,"silent-change"):i.appendStreamOutput(t.newIndex,s.value,"silent-change")}),this);const e=t.newValues.map((e=>e.toJSON()));s.updateOutputs(t.newIndex,t.newIndex,e,"silent-change");break}case"set":{const e=t.newValues.map((e=>e.toJSON()));s.updateOutputs(t.oldIndex,t.oldIndex+e.length,e,"silent-change");break}case"remove":s.updateOutputs(t.oldIndex,t.oldValues.length,[],"silent-change");break;default:throw new Error(`Invalid event type: ${t.type}`)}}))}_onSharedModelChanged(e,t){t.streamOutputChange&&P((()=>{for(const e of t.streamOutputChange)"delete"in e&&this._outputs.removeStreamOutput(e.delete),"insert"in e&&this._outputs.appendStreamOutput(e.insert.toString())})),t.outputsChange&&P((()=>{let e=0;for(const s of t.outputsChange){if("retain"in s&&(e+=s.retain),"delete"in s)for(let t=0;t<s.delete;t++)this._outputs.remove(e);if("insert"in s)for(const e of s.insert)this._outputs.add("toJSON"in e?e.toJSON():e)}})),t.executionCountChange&&(!t.executionCountChange.newValue||!this.isDirty&&t.executionCountChange.oldValue||this._setDirty(!1),this.stateChanged.emit({name:"executionCount",oldValue:t.executionCountChange.oldValue,newValue:t.executionCountChange.newValue})),t.executionStateChange&&this.stateChanged.emit({name:"executionState",oldValue:t.executionStateChange.oldValue,newValue:t.executionStateChange.newValue}),t.sourceChange&&null!==this.executionCount&&this._setDirty(this._executedCode!==this.sharedModel.getSource().trim())}_setDirty(e){e||(this._executedCode=this.sharedModel.getSource().trim()),e!==this._isDirty&&(this._isDirty=e,this.stateChanged.emit({name:"isDirty",oldValue:!e,newValue:e}))}}!function(e){class t{createOutputArea(e){return new O.OutputAreaModel(e)}}e.ContentFactory=t,e.defaultContentFactory=new t}(j||(j={}));var N=s(93050);class F extends C.Widget{constructor(e){var t,s,i;const n=document.createElement("div");super({node:n});const r=(null!==(t=e.translator)&&void 0!==t?t:N.nullTranslator).load("jupyterlab"),o=document.createElement("div");o.className=null!==(s=e.promptClass)&&void 0!==s?s:"",n.insertAdjacentHTML("afterbegin",o.outerHTML),this._cell=document.createElement("div"),this._cell.classList.add("jp-Placeholder-content"),this._cell.title=r.__("Click to expand");const a=this._cell.appendChild(document.createElement("div"));a.classList.add("jp-Placeholder-contentContainer"),this._textContent=a.appendChild(document.createElement("span")),this._textContent.className="jp-PlaceholderText",this._textContent.innerText=null!==(i=e.text)&&void 0!==i?i:"",n.appendChild(this._cell),h.ellipsesIcon.element({container:a.appendChild(document.createElement("span")),className:"jp-MoreHorizIcon",elementPosition:"center",height:"auto",width:"32px"}),this.addClass("jp-Placeholder"),this._callback=e.callback}set text(e){this._textContent.innerText=e}get text(){return this._textContent.innerText}onAfterAttach(e){super.onAfterAttach(e),this.node.addEventListener("click",this._callback)}onBeforeDetach(e){this.node.removeEventListener("click",this._callback),super.onBeforeDetach(e)}}class W extends F{constructor(e){super({...e,promptClass:"jp-Placeholder-prompt jp-InputPrompt"}),this.addClass("jp-InputPlaceholder")}}class L extends F{constructor(e){super({...e,promptClass:"jp-Placeholder-prompt jp-OutputPrompt"}),this.addClass("jp-OutputPlaceholder")}}var T=s(3984),R=s(20754),V=s(95514);const z="jp-mod-selected";class B extends T.EditorSearchProvider{constructor(e){super(),this.cell=e,this.cell.inViewport||this.cell.editor||(0,R.signalToPromise)(e.inViewportChanged).then((([,e])=>{e&&this.cmHandler.setEditor(this.editor)}))}get editor(){return this.cell.editor}get model(){return this.cell.model}}class U extends B{constructor(e){super(e),this.currentProviderIndex=-1,this.outputsProvider=[];const t=this.cell.outputArea;this._onOutputsChanged(t,t.widgets.length).catch((e=>{console.error("Failed to initialize search on cell outputs.",e)})),t.outputLengthChanged.connect(this._onOutputsChanged,this),t.disposed.connect((()=>{t.outputLengthChanged.disconnect(this._onOutputsChanged)}),this)}get matchesCount(){return this.isActive?super.matchesCount+this.outputsProvider.reduce(((e,t)=>{var s;return e+(null!==(s=t.matchesCount)&&void 0!==s?s:0)}),0):0}async clearHighlight(){await super.clearHighlight(),await Promise.all(this.outputsProvider.map((e=>e.clearHighlight())))}dispose(){this.isDisposed||(super.dispose(),this.outputsProvider.map((e=>{e.dispose()})),this.outputsProvider.length=0)}async highlightNext(e,t){var s;const i=null!==(s=null==t?void 0:t.from)&&void 0!==s?s:"";if(!(0===this.matchesCount||"previous-match"===i&&null!==this.currentIndex&&this.currentIndex+1>=this.cmHandler.matches.length)&&this.isActive){if(-1===this.currentProviderIndex){const s=await super.highlightNext(e,t);if(s)return this.currentIndex=this.cmHandler.currentIndex,s;this.currentProviderIndex=0}for(;this.currentProviderIndex<this.outputsProvider.length;){const e=this.outputsProvider[this.currentProviderIndex],t=await e.highlightNext(!1);if(t)return this.currentIndex=super.matchesCount+this.outputsProvider.slice(0,this.currentProviderIndex).reduce(((e,t)=>{var s;return e+(null!==(s=t.matchesCount)&&void 0!==s?s:0)}),0)+e.currentMatchIndex,t;this.currentProviderIndex+=1}return this.currentProviderIndex=-1,void(this.currentIndex=null)}this.currentIndex=null}async highlightPrevious(){if(0!==this.matchesCount&&this.isActive){for(null===this.currentIndex&&(this.currentProviderIndex=this.outputsProvider.length-1);this.currentProviderIndex>=0;){const e=this.outputsProvider[this.currentProviderIndex],t=await e.highlightPrevious(!1);if(t)return this.currentIndex=super.matchesCount+this.outputsProvider.slice(0,this.currentProviderIndex).reduce(((e,t)=>{var s;return e+(null!==(s=t.matchesCount)&&void 0!==s?s:0)}),0)+e.currentMatchIndex,t;this.currentProviderIndex-=1}const e=await super.highlightPrevious();return e?(this.currentIndex=this.cmHandler.currentIndex,e):void(this.currentIndex=null)}this.currentIndex=null}async startQuery(e,t){await super.startQuery(e,t),!1!==(null==t?void 0:t.output)&&this.isActive&&await Promise.all(this.outputsProvider.map((t=>t.startQuery(e))))}async endQuery(){var e;await super.endQuery(),!1!==(null===(e=this.filters)||void 0===e?void 0:e.output)&&this.isActive&&await Promise.all(this.outputsProvider.map((e=>e.endQuery())))}async replaceAllMatches(e){return!1===this.model.getMetadata("editable")?Promise.resolve(!1):await super.replaceAllMatches(e)}async replaceCurrentMatch(e,t,s){return!1===this.model.getMetadata("editable")?Promise.resolve(!1):await super.replaceCurrentMatch(e,t,s)}async _onOutputsChanged(e,t){var s;this.outputsProvider.forEach((e=>{e.dispose()})),this.outputsProvider.length=0,this.currentProviderIndex=-1,this.outputsProvider=this.cell.outputArea.widgets.map((e=>new V.GenericSearchProvider(e))),this.isActive&&this.query&&!1!==(null===(s=this.filters)||void 0===s?void 0:s.output)&&await Promise.all([this.outputsProvider.map((e=>{e.startQuery(this.query)}))]),this._stateChanged.emit()}}class J extends B{constructor(e){super(e),this._unrenderedByHighlight=!1,this.renderedProvider=new V.GenericSearchProvider(e.renderer)}async clearHighlight(){await super.clearHighlight(),await this.renderedProvider.clearHighlight()}dispose(){this.isDisposed||(super.dispose(),this.renderedProvider.dispose())}async endQuery(){await super.endQuery(),await this.renderedProvider.endQuery()}async highlightNext(e=!0,t){let s;if(!this.isActive)return s;const i=this.cell;if(i.rendered&&this.matchesCount>0){this._unrenderedByHighlight=!0;const e=(0,R.signalToPromise)(i.renderedChanged);i.rendered=!1,await e}return s=await super.highlightNext(e,t),s}async highlightPrevious(){let e;const t=this.cell;if(t.rendered&&this.matchesCount>0){this._unrenderedByHighlight=!0;const e=(0,R.signalToPromise)(t.renderedChanged);t.rendered=!1,await e}return e=await super.highlightPrevious(),e}async startQuery(e,t){await super.startQuery(e,t);const s=this.cell;s.rendered&&this.onRenderedChanged(s,s.rendered),s.renderedChanged.connect(this.onRenderedChanged,this)}async replaceAllMatches(e){if(!1===this.model.getMetadata("editable"))return Promise.resolve(!1);const t=await super.replaceAllMatches(e);return this.cell.rendered&&this.cell.update(),t}async replaceCurrentMatch(e,t,s){return!1===this.model.getMetadata("editable")?Promise.resolve(!1):await super.replaceCurrentMatch(e,t,s)}onRenderedChanged(e,t){var s;this._unrenderedByHighlight||(this.currentIndex=null),this._unrenderedByHighlight=!1,this.isActive&&(t?this.renderedProvider.startQuery(this.query):(null===(s=e.editor)||void 0===s||s.setCursorPosition({column:0,line:0}),this.renderedProvider.endQuery()))}}function $(e){if(e.isPlaceholder())return new B(e);switch(e.model.type){case"code":return new U(e);case"markdown":return new J(e);default:return new B(e)}}var Q=s(63720),q=s(53876),G=s(58194),X=s(10035),Y=s(21961),K=s(14931),Z=s(62633),ee=s(32406);const te="jp-mod-resizedCell";class se extends C.Widget{constructor(e){super(),this.targetNode=e,this._isActive=!1,this._isDragging=!1,this.sizeChanged=new f.Signal(this),this.addClass("jp-CellResizeHandle"),this._resizer=new ee.Throttler((e=>this._resize(e)),50)}dispose(){this._resizer.dispose(),super.dispose()}handleEvent(e){var t,s;switch(e.type){case"dblclick":null===(t=this.targetNode.parentNode)||void 0===t||t.childNodes.forEach((e=>{e.classList.remove(te)})),document.documentElement.style.setProperty("--jp-side-by-side-output-size","1fr"),this._isActive=!1;break;case"mousedown":this._isDragging=!0,this._isActive||(null===(s=this.targetNode.parentNode)||void 0===s||s.childNodes.forEach((e=>{e.classList.add(te)})),this._isActive=!0),window.addEventListener("mousemove",this),window.addEventListener("mouseup",this);break;case"mousemove":this._isActive&&this._isDragging&&this._resizer.invoke(e);break;case"mouseup":this._isDragging=!1,window.removeEventListener("mousemove",this),window.removeEventListener("mouseup",this)}}onAfterAttach(e){this.node.addEventListener("dblclick",this),this.node.addEventListener("mousedown",this),super.onAfterAttach(e)}onBeforeDetach(e){this.node.removeEventListener("dblclick",this),this.node.removeEventListener("mousedown",this),super.onBeforeDetach(e)}_resize(e){const{width:t,x:s}=this.targetNode.getBoundingClientRect(),i=t/(e.clientX-s)-1;if(0<i){const e=Math.max(Math.min(Math.abs(i),50),.05);document.documentElement.style.setProperty("--jp-side-by-side-output-size",`${e}fr`),this.sizeChanged.emit(e)}}}const ie="jp-Cell-outputWrapper",ne="jp-mod-dirty",re="jp-MarkdownHeadingCollapsed",oe="jp-collapseHeadingButton",ae="jp-showHiddenCellsButton",de="jp-mod-rendered",le="jp-mod-noOutputs",he="application/x-jupyter-icontentsrich";class ue extends C.Widget{constructor(e){var t,s,i,n;super(),this.prompt="",this._displayChanged=new f.Signal(this),this._scrollRequested=new f.Signal(this),this._scrollHandlerExtension=Q.EditorView.scrollHandler.of(((e,t,s)=>{const i=null!==this._inViewport&&!this._inViewport;return this._scrollRequested.emit({defaultPrevented:i,scrollWithinCell:()=>{e.dispatch({effects:Q.EditorView.scrollIntoView(t,s)})}}),i})),this._editorConfig={},this._editorExtensions=[],this._inputHidden=!1,this._inViewportChanged=new f.Signal(this),this._readOnly=!1,this._ready=new Y.PromiseDelegate,this._resizeDebouncer=new ee.Debouncer((()=>{this._displayChanged.emit()}),0),this._syncCollapse=!1,this._syncEditable=!1,this.addClass("jp-Cell");const r=this._model=e.model;this.contentFactory=e.contentFactory,this.layout=null!==(t=e.layout)&&void 0!==t?t:new C.PanelLayout,this.translator=null!==(s=e.translator)&&void 0!==s?s:N.nullTranslator,this._editorConfig={searchWithCM:!1,...e.editorConfig},this._editorExtensions=null!==(i=e.editorExtensions)&&void 0!==i?i:[],this._editorExtensions.push(this._scrollHandlerExtension),this._placeholder=!0,this._inViewport=null,this.placeholder=null===(n=e.placeholder)||void 0===n||n,r.metadataChanged.connect(this.onMetadataChanged,this)}initializeState(){return this.loadCollapseState(),this.loadEditableState(),this}get displayChanged(){return this._displayChanged}get inViewport(){var e;return null!==(e=this._inViewport)&&void 0!==e&&e}set inViewport(e){this._inViewport!==e&&(this._inViewport=e,this._inViewportChanged.emit(this._inViewport))}get inViewportChanged(){return this._inViewportChanged}get placeholder(){return this._placeholder}set placeholder(e){this._placeholder!==e&&!1===e&&(this.initializeDOM(),this._placeholder=e,this._ready.resolve())}get promptNode(){return this.placeholder?null:this._inputHidden?this._inputPlaceholder.node.firstElementChild:this._input.promptNode}get editorWidget(){var e,t;return null!==(t=null===(e=this._input)||void 0===e?void 0:e.editorWidget)&&void 0!==t?t:null}get editor(){var e,t;return null!==(t=null===(e=this._input)||void 0===e?void 0:e.editor)&&void 0!==t?t:null}get editorConfig(){return this._editorConfig}get headings(){return new Array}get model(){return this._model}get inputArea(){return this._input}get readOnly(){return this._readOnly}set readOnly(e){e!==this._readOnly&&(this._readOnly=e,this.syncEditable&&this.saveEditableState(),this.update())}isPlaceholder(){return this.placeholder}saveEditableState(){const{sharedModel:e}=this.model,t=e.getMetadata("editable");this.readOnly&&!1===t||!this.readOnly&&void 0===t||(this.readOnly?e.setMetadata("editable",!1):e.deleteMetadata("editable"))}loadEditableState(){this.readOnly=!1===this.model.sharedModel.getMetadata("editable")}get ready(){return this._ready.promise}setPrompt(e){return this._setPrompt(e)}_setPrompt(e){var t;this.prompt=e,null===(t=this._input)||void 0===t||t.setPrompt(e)}get inputHidden(){return this._inputHidden}set inputHidden(e){var t;if(this._inputHidden!==e){if(!this.placeholder){const s=this._inputWrapper.layout;e?(this._input.parent=null,this._inputPlaceholder&&(this._inputPlaceholder.text=null===(t=this.model.sharedModel.getSource().split("\n"))||void 0===t?void 0:t[0]),s.addWidget(this._inputPlaceholder)):(this._inputPlaceholder.parent=null,s.addWidget(this._input))}this._inputHidden=e,this.syncCollapse&&this.saveCollapseState(),this.handleInputHidden(e)}}saveCollapseState(){const e={...this.model.getMetadata("jupyter")};this.inputHidden&&!0===e.source_hidden||!this.inputHidden&&void 0===e.source_hidden||(this.inputHidden?e.source_hidden=!0:delete e.source_hidden,0===Object.keys(e).length?this.model.deleteMetadata("jupyter"):this.model.setMetadata("jupyter",e))}loadCollapseState(){var e;const t=null!==(e=this.model.getMetadata("jupyter"))&&void 0!==e?e:{};this.inputHidden=!!t.source_hidden}handleInputHidden(e){}get syncCollapse(){return this._syncCollapse}set syncCollapse(e){this._syncCollapse!==e&&(this._syncCollapse=e,e&&this.loadCollapseState())}get syncEditable(){return this._syncEditable}set syncEditable(e){this._syncEditable!==e&&(this._syncEditable=e,e&&this.loadEditableState())}clone(){return new(0,this.constructor)({model:this.model,contentFactory:this.contentFactory,placeholder:!1,translator:this.translator})}dispose(){this.isDisposed||(this._resizeDebouncer.dispose(),this._input=null,this._model=null,this._inputWrapper=null,this._inputPlaceholder=null,super.dispose())}updateEditorConfig(e){this._editorConfig={...this._editorConfig,...e},this.editor&&this.editor.setOptions(this._editorConfig)}get scrollRequested(){return this._scrollRequested}initializeDOM(){if(!this.placeholder)return;const e=this.contentFactory,t=this._model,s=e.createCellHeader();s.addClass("jp-Cell-header"),this.layout.addWidget(s);const i=this._inputWrapper=new C.Panel;i.addClass("jp-Cell-inputWrapper");const n=new g;n.addClass("jp-Cell-inputCollapser");const r=this._input=new w({model:t,contentFactory:e,editorOptions:this.getEditorOptions()});r.addClass("jp-Cell-inputArea"),i.addWidget(n),i.addWidget(r),this.layout.addWidget(i),this._inputPlaceholder=new W({callback:()=>{this.inputHidden=!this.inputHidden},text:r.model.sharedModel.getSource().split("\n")[0],translator:this.translator}),r.model.contentChanged.connect(((e,t)=>{var s;this._inputPlaceholder&&this.inputHidden&&(this._inputPlaceholder.text=null===(s=e.sharedModel.getSource().split("\n"))||void 0===s?void 0:s[0])})),this.inputHidden&&(r.parent=null,i.layout.addWidget(this._inputPlaceholder));const o=this.contentFactory.createCellFooter();o.addClass("jp-Cell-footer"),this.layout.addWidget(o)}getEditorOptions(){return{config:this.editorConfig,extensions:this._editorExtensions}}onBeforeAttach(e){this.placeholder&&(this.placeholder=!1)}onAfterAttach(e){this.update()}onActivateRequest(e){var t;null===(t=this.editor)||void 0===t||t.focus()}onResize(e){this._resizeDebouncer.invoke()}onUpdateRequest(e){var t,s;this._model&&(null===(t=this.editor)||void 0===t?void 0:t.getOption("readOnly"))!==this._readOnly&&(null===(s=this.editor)||void 0===s||s.setOption("readOnly",this._readOnly))}onContentChanged(){var e;this.inputHidden&&this._inputPlaceholder&&(this._inputPlaceholder.text=null===(e=this.model.sharedModel.getSource().split("\n"))||void 0===e?void 0:e[0])}onMetadataChanged(e,t){switch(t.key){case"jupyter":this.syncCollapse&&this.loadCollapseState();break;case"editable":this.syncEditable&&this.loadEditableState()}}}!function(e){let t;!function(e){e[e.HTML=0]="HTML",e[e.Markdown=1]="Markdown"}(t=e.HeadingType||(e.HeadingType={})),e.ContentFactory=class{constructor(e){this._editorFactory=e.editorFactory}get editorFactory(){return this._editorFactory}createCellHeader(){return new _}createCellFooter(){return new v}createInputPrompt(){return new x}createOutputPrompt(){return new O.OutputPrompt}createStdin(e){return new O.Stdin(e)}}}(ue||(ue={}));class ce extends C.PanelLayout{onBeforeAttach(e){let t=!0;const s=this.parent.node.firstElementChild;for(const i of this)s&&(i.node===s?t=!1:(Z.MessageLoop.sendMessage(i,e),t?this.parent.node.insertBefore(i.node,s):this.parent.node.appendChild(i.node),this.parent.isHidden||i.setFlag(C.Widget.Flag.IsVisible),Z.MessageLoop.sendMessage(i,C.Widget.Msg.AfterAttach)))}onAfterDetach(e){for(const t of this)!t.hasClass(ie)&&t.node.isConnected&&(Z.MessageLoop.sendMessage(t,C.Widget.Msg.BeforeDetach),this.parent.node.removeChild(t.node),Z.MessageLoop.sendMessage(t,e))}}class pe extends ue{constructor(e){var t;super({layout:new ce,...e,placeholder:!0}),this._detectCaretMovementInOuput=e=>{const t=null!==this._inViewport&&!this._inViewport,s=e.target;if(!(s&&s instanceof HTMLElement))return;this._lastTarget&&(this._lastTarget.removeEventListener("selectionchange",this._lastOnCaretMovedHandler),document.removeEventListener("selectionchange",this._lastOnCaretMovedHandler));const i=()=>{this._scrollRequested.emit({scrollWithinCell:({scroller:e})=>{u.ElementExt.scrollIntoViewIfNeeded(e,s)},defaultPrevented:t})};this._lastTarget=s,this._lastOnCaretMovedHandler=i,s.addEventListener("selectionchange",i,{once:!0}),document.addEventListener("selectionchange",i,{once:!0}),setTimeout((()=>{s.removeEventListener("selectionchange",i),document.removeEventListener("selectionchange",i)}),250)},this._headingsCache=null,this._outputHidden=!1,this._outputWrapper=null,this._outputPlaceholder=null,this._syncScrolled=!1,this._lastTarget=null,this._lastOutputHeight="",this.addClass("jp-CodeCell");const s=this.translator.load("jupyterlab"),i=this._rendermime=e.rendermime,n=this.contentFactory,r=this.model;this.maxNumberOutputs=e.maxNumberOutputs;const o=0===r.outputs.length?s.__("Code Cell Content"):s.__("Code Cell Content with Output");this.node.setAttribute("aria-label",o);const a=this._output=new O.OutputArea({model:this.model.outputs,rendermime:i,contentFactory:n,maxNumberOutputs:this.maxNumberOutputs,translator:this.translator,promptOverlay:!0,inputHistoryScope:e.inputHistoryScope});a.node.addEventListener("keydown",this._detectCaretMovementInOuput),a.addClass("jp-Cell-outputArea"),a.toggleScrolling.connect((()=>{this.outputsScrolled=!this.outputsScrolled})),a.initialize.connect((()=>{this.updatePromptOverlayIcon()})),this.placeholder=null===(t=e.placeholder)||void 0===t||t,r.outputs.changed.connect(this.onOutputChanged,this),r.outputs.stateChanged.connect(this.onOutputChanged,this),r.stateChanged.connect(this.onStateChanged,this)}initializeDOM(){if(!this.placeholder)return;super.initializeDOM(),this._updatePrompt();const e=this._outputWrapper=new C.Panel;e.addClass(ie);const t=new m;t.addClass("jp-Cell-outputCollapser"),e.addWidget(t),0===this.model.outputs.length&&this.addClass(le),this._output.outputLengthChanged.connect(this._outputLengthHandler,this),e.addWidget(this._output);const s=this.layout,i=new se(this.node);i.sizeChanged.connect(this._sizeChangedHandler,this),s.insertWidget(s.widgets.length-1,i),s.insertWidget(s.widgets.length-1,e),this.model.isDirty&&this.addClass(ne),this._outputPlaceholder=new L({callback:()=>{this.outputHidden=!this.outputHidden},text:this.getOutputPlaceholderText(),translator:this.translator});const n=e.layout;this.outputHidden&&(n.removeWidget(this._output),n.addWidget(this._outputPlaceholder),this.inputHidden&&!e.isHidden&&this._outputWrapper.hide());const r=this.translator.load("jupyterlab"),o=0===this.model.outputs.length?r.__("Code Cell Content"):r.__("Code Cell Content with Output");this.node.setAttribute("aria-label",o)}getOutputPlaceholderText(){var e;const t=this.model.outputs.get(0);if(!(null==t?void 0:t.data))return;const s=["text/html","image/svg+xml","application/pdf","text/markdown","text/plain","application/vnd.jupyter.stderr","application/vnd.jupyter.stdout","text"].find((e=>{const s=t.data[e];return"string"==(Array.isArray(s)?typeof s[0]:typeof s)})),i=t.data[null!=s?s:""];return void 0!==i?null===(e=Array.isArray(i)?i:null==i?void 0:i.split("\n"))||void 0===e?void 0:e.find((e=>""!==e)):void 0}initializeState(){return super.initializeState(),this.loadScrolledState(),this._updatePrompt(),this}get headings(){if(!this._headingsCache){const e=[],t=this.model.outputs;for(let s=0;s<t.length;s++){const i=t.get(s);let n=null,r=null;Object.keys(i.data).forEach((e=>{!r&&X.TableOfContentsUtils.Markdown.isMarkdown(e)?r=e:!n&&X.TableOfContentsUtils.isHTML(e)&&(n=e)})),n?e.push(...X.TableOfContentsUtils.getHTMLHeadings(this._rendermime.sanitizer.sanitize(i.data[n])).map((e=>({...e,outputIndex:s,type:ue.HeadingType.HTML})))):r&&e.push(...X.TableOfContentsUtils.Markdown.getHeadings(i.data[r]).map((e=>({...e,outputIndex:s,type:ue.HeadingType.Markdown}))))}this._headingsCache=e}return[...this._headingsCache]}get outputArea(){return this._output}get outputHidden(){return this._outputHidden}set outputHidden(e){var t;if(this._outputHidden!==e){if(!this.placeholder){const s=this._outputWrapper.layout;e?(s.removeWidget(this._output),s.addWidget(this._outputPlaceholder),this.inputHidden&&!this._outputWrapper.isHidden&&this._outputWrapper.hide(),this._outputPlaceholder&&(this._outputPlaceholder.text=null!==(t=this.getOutputPlaceholderText())&&void 0!==t?t:"")):(this._outputWrapper.isHidden&&this._outputWrapper.show(),s.removeWidget(this._outputPlaceholder),s.addWidget(this._output))}this._outputHidden=e,this.syncCollapse&&this.saveCollapseState()}}saveCollapseState(){this.model.sharedModel.transact((()=>{super.saveCollapseState();const e=this.model.getMetadata("collapsed");this.outputHidden&&!0===e||!this.outputHidden&&void 0===e||(this.outputHidden?this.model.setMetadata("collapsed",!0):this.model.deleteMetadata("collapsed"))}),!1,"silent-change")}loadCollapseState(){super.loadCollapseState(),this.outputHidden=!!this.model.getMetadata("collapsed")}get outputsScrolled(){return this._outputsScrolled}set outputsScrolled(e){this.toggleClass("jp-mod-outputsScrolled",e),this._outputsScrolled=e,this.syncScrolled&&this.saveScrolledState(),this.updatePromptOverlayIcon()}updatePromptOverlayIcon(){var e;const t=q.DOMUtils.findElement(this.node,"jp-OutputArea-promptOverlay");if(!t)return;if(t.clientHeight<=24)return void(null===(e=t.firstChild)||void 0===e||e.remove());let s;this._outputsScrolled?(h.expandIcon.element({container:t}),s="Expand Output"):(h.collapseIcon.element({container:t}),s="Collapse Output");const i=this.translator.load("jupyterlab");t.title=i.__(s)}saveScrolledState(){const e=this.model.getMetadata("scrolled");this.outputsScrolled&&!0===e||!this.outputsScrolled&&void 0===e||(this.outputsScrolled?this.model.setMetadata("scrolled",!0):(this.outputArea.node.style.height="",this.model.deleteMetadata("scrolled")))}loadScrolledState(){"auto"===this.model.getMetadata("scrolled")?this.outputsScrolled=!1:this.outputsScrolled=!!this.model.getMetadata("scrolled")}get syncScrolled(){return this._syncScrolled}set syncScrolled(e){this._syncScrolled!==e&&(this._syncScrolled=e,e&&this.loadScrolledState())}handleInputHidden(e){this.placeholder||(!e&&this._outputWrapper.isHidden?this._outputWrapper.show():e&&!this._outputWrapper.isHidden&&this._outputHidden&&this._outputWrapper.hide())}clone(){return new(0,this.constructor)({model:this.model,contentFactory:this.contentFactory,rendermime:this._rendermime,placeholder:!1,translator:this.translator})}cloneOutputArea(){return new O.SimplifiedOutputArea({model:this.model.outputs,contentFactory:this.contentFactory,rendermime:this._rendermime})}dispose(){this.isDisposed||(this._output.outputLengthChanged.disconnect(this._outputLengthHandler,this),this._output.node.removeEventListener("keydown",this._detectCaretMovementInOuput),this._rendermime=null,this._output=null,this._outputWrapper=null,this._outputPlaceholder=null,super.dispose())}onStateChanged(e,t){switch(t.name){case"executionCount":this.model.executionState="idle",this._updatePrompt();break;case"executionState":this._updatePrompt();break;case"isDirty":e.isDirty?this.addClass(ne):this.removeClass(ne)}}onOutputChanged(){var e;this._headingsCache=null,this._outputPlaceholder&&this.outputHidden&&(this._outputPlaceholder.text=null!==(e=this.getOutputPlaceholderText())&&void 0!==e?e:""),this.updatePromptOverlayIcon();const t=this.outputArea.node.style.height;0===this.model.outputs.length&&""!==t?(this._lastOutputHeight=t,this.outputArea.node.style.height=""):this.model.outputs.length>0&&""===t&&(this.outputArea.node.style.height=this._lastOutputHeight)}onMetadataChanged(e,t){switch(t.key){case"scrolled":this.syncScrolled&&this.loadScrolledState();break;case"collapsed":this.syncCollapse&&this.loadCollapseState()}super.onMetadataChanged(e,t)}_updatePrompt(){let e;e="running"==this.model.executionState?"*":`${this.model.executionCount||""}`,this._setPrompt(e)}_outputLengthHandler(e,t){const s=0===t;this.toggleClass(le,s);const i=this.translator.load("jupyterlab"),n=s?i.__("Code Cell Content"):i.__("Code Cell Content with Output");this.node.setAttribute("aria-label",n)}_sizeChangedHandler(e){this._displayChanged.emit()}}!function(e){e.execute=async function(e,t,s){var i;const n=e.model,r=n.sharedModel.getSource();if(!r.trim()||!(null===(i=t.session)||void 0===i?void 0:i.kernel))return void n.sharedModel.transact((()=>{n.clearExecution()}),!1,"silent-change");const o={cellId:n.sharedModel.getId()};s={...n.metadata,...s,...o};const{recordTiming:a}=s;let d;n.sharedModel.transact((()=>{n.clearExecution(),e.outputHidden=!1}),!1,"silent-change"),n.executionState="running",n.trusted=!0;try{const i=O.OutputArea.execute(r,e.outputArea,t,s);if(a){const t=e=>{let t;switch(e.header.msg_type){case"status":t=`status.${e.content.execution_state}`;break;case"execute_input":t="execute_input";break;default:return!0}const s=e.header.date||(new Date).toISOString(),i=Object.assign({},n.getMetadata("execution"));return i[`iopub.${t}`]=s,n.setMetadata("execution",i),!0};e.outputArea.future.registerMessageHook(t)}else n.deleteMetadata("execution");d=e.outputArea.future;const o=await i;if(n.executionCount=o.content.execution_count,a){const e=Object.assign({},n.getMetadata("execution")),t=o.metadata.started;t&&(e["shell.execute_reply.started"]=t);const s=o.header.date;e["shell.execute_reply"]=s||(new Date).toISOString(),n.setMetadata("execution",e)}return o}catch(t){if(d&&!e.isDisposed&&e.outputArea.future===d&&(e.model.executionState="idle",a&&d.isDisposed)){const e=Object.assign({},n.getMetadata("execution"));e.execution_failed=(new Date).toISOString(),n.setMetadata("execution",e)}throw t}}}(pe||(pe={}));class ge extends ue{handleEvent(e){switch(e.type){case"lm-dragover":this._evtDragOver(e);break;case"lm-drop":this._evtDrop(e)}}getEditorOptions(){var e,t;const s=null!==(e=super.getEditorOptions())&&void 0!==e?e:{};return s.extensions=[...null!==(t=s.extensions)&&void 0!==t?t:[],Q.EditorView.domEventHandlers({dragenter:e=>{e.preventDefault()},dragover:e=>{e.preventDefault()},drop:e=>{this._evtNativeDrop(e)},paste:e=>{this._evtPaste(e)}})],s}onAfterAttach(e){super.onAfterAttach(e);const t=this.node;t.addEventListener("lm-dragover",this),t.addEventListener("lm-drop",this)}onBeforeDetach(e){const t=this.node;t.removeEventListener("lm-dragover",this),t.removeEventListener("lm-drop",this),super.onBeforeDetach(e)}_evtDragOver(e){(0,K.some)(G.imageRendererFactory.mimeTypes,(t=>!!e.mimeData.hasData(he)&&e.mimeData.getData(he).model.mimetype===t))&&(e.preventDefault(),e.stopPropagation(),e.dropAction=e.proposedAction)}_evtPaste(e){if(e.clipboardData){const t=e.clipboardData.items;for(let s=0;s<t.length;s++){if("text/plain"===t[s].type){if(s<t.length-1&&"file"===t[s+1].kind)continue;t[s].getAsString((e=>{var t,s;null===(s=(t=this.editor).replaceSelection)||void 0===s||s.call(t,e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}))}this._attachFiles(e.clipboardData.items)}}e.preventDefault()}_evtNativeDrop(e){e.dataTransfer&&this._attachFiles(e.dataTransfer.items),e.preventDefault()}_evtDrop(e){const t=e.mimeData.types().filter((t=>{if(t===he){const t=e.mimeData.getData(he);return-1!==G.imageRendererFactory.mimeTypes.indexOf(t.model.mimetype)}return-1!==G.imageRendererFactory.mimeTypes.indexOf(t)}));if(0!==t.length)if(e.preventDefault(),e.stopPropagation(),"none"!==e.proposedAction){e.dropAction="copy";for(const s of t)if(s===he){const{model:t,withContent:s}=e.mimeData.getData(he);if("file"===t.type){const e=this._generateURI(t.name);this.updateCellSourceWithAttachment(t.name,e),s().then((t=>{this.model.attachments.set(e,{[t.mimetype]:t.content})}))}}else{const t=this._generateURI();this.model.attachments.set(t,{[s]:e.mimeData.getData(s)}),this.updateCellSourceWithAttachment(t,t)}}else e.dropAction="none"}_attachFiles(e){for(let t=0;t<e.length;t++){const s=e[t];if("file"===s.kind){const e=s.getAsFile();e&&this._attachFile(e)}}}_attachFile(e){const t=new FileReader;t.onload=s=>{const{href:i,protocol:n}=R.URLExt.parse(t.result);if("data:"!==n)return;const r=/([\w+\/\+]+)?(?:;(charset=[\w\d-]*|base64))?,(.*)/.exec(i);if(!r||4!==r.length)return;const o=r[1],a={[o]:r[3]},d=this._generateURI(e.name);o.startsWith("image/")&&(this.model.attachments.set(d,a),this.updateCellSourceWithAttachment(e.name,d))},t.onerror=t=>{console.error(`Failed to attach ${e.name}`+t)},t.readAsDataURL(e)}_generateURI(e=""){const t=e.lastIndexOf(".");return-1!==t?Y.UUID.uuid4().concat(e.substring(t)):Y.UUID.uuid4()}}class me extends ge{constructor(e){var t,s,i,n;super({...e,placeholder:!0}),this._headingsCache=null,this._headingCollapsedChanged=new f.Signal(this),this._prevText="",this._rendered=!0,this._renderedChanged=new f.Signal(this),this._showEditorForReadOnlyMarkdown=!0,this.addClass("jp-MarkdownCell"),this.model.contentChanged.connect(this.onContentChanged,this);const r=this.translator.load("jupyterlab");this.node.setAttribute("aria-label",r.__("Markdown Cell Content")),this._rendermime=e.rendermime.clone({resolver:new M.AttachmentsResolver({parent:null!==(t=e.rendermime.resolver)&&void 0!==t?t:void 0,model:this.model.attachments})}),this._renderer=this._rendermime.createRenderer("text/markdown"),this._renderer.addClass("jp-MarkdownOutput"),this._headingCollapsed=null!==(s=this.model.getMetadata(re))&&void 0!==s&&s,this._showEditorForReadOnlyMarkdown=null!==(i=e.showEditorForReadOnlyMarkdown)&&void 0!==i?i:me.defaultShowEditorForReadOnlyMarkdown,this.placeholder=null===(n=e.placeholder)||void 0===n||n,this._monitor=new R.ActivityMonitor({signal:this.model.contentChanged,timeout:1e3}),this.ready.then((()=>{this.isDisposed||this._monitor.activityStopped.connect((()=>{this._rendered&&this.update()}),this)})).catch((e=>{console.error("Failed to be ready",e)}))}get headingInfo(){const e=this.headings;if(e.length>0){const{text:t,level:s}=e.reduce(((e,t)=>e.level<=t.level?e:t),e[0]);return{text:t,level:s}}return{text:"",level:-1}}get headings(){if(!this._headingsCache){const e=X.TableOfContentsUtils.Markdown.getHeadings(this.model.sharedModel.getSource());this._headingsCache=e.map((e=>({...e,type:ue.HeadingType.Markdown})))}return[...this._headingsCache]}get headingCollapsed(){return this._headingCollapsed}set headingCollapsed(e){var t;if(this._headingCollapsed!==e){this._headingCollapsed=e,e?this.model.setMetadata(re,e):"undefined"!==this.model.getMetadata(re)&&this.model.deleteMetadata(re);const s=null===(t=this.inputArea)||void 0===t?void 0:t.promptNode.getElementsByClassName(oe)[0];s&&(e?s.classList.add("jp-mod-collapsed"):s.classList.remove("jp-mod-collapsed")),this.renderCollapseButtons(this._renderer),this._headingCollapsedChanged.emit(this._headingCollapsed)}}get numberChildNodes(){return this._numberChildNodes}set numberChildNodes(e){this._numberChildNodes=e,this.renderCollapseButtons(this._renderer)}get headingCollapsedChanged(){return this._headingCollapsedChanged}get rendered(){return this._rendered}set rendered(e){this.readOnly&&!1===this._showEditorForReadOnlyMarkdown&&(e=!0),e!==this._rendered&&(this._rendered=e,this._handleRendered().then((()=>{this._displayChanged.emit(),this._renderedChanged.emit(this._rendered)})).catch((e=>{console.error("Failed to render",e)})))}get renderedChanged(){return this._renderedChanged}get showEditorForReadOnly(){return this._showEditorForReadOnlyMarkdown}set showEditorForReadOnly(e){this._showEditorForReadOnlyMarkdown=e,!1===e&&(this.rendered=!0)}get renderer(){return this._renderer}dispose(){this.isDisposed||(this._monitor.dispose(),super.dispose())}initializeDOM(){this.placeholder&&(super.initializeDOM(),this.renderCollapseButtons(this._renderer),this._handleRendered().catch((e=>{console.error("Failed to render",e)})))}maybeCreateCollapseButton(){var e;const{level:t}=this.headingInfo;if(t>0&&0==(null===(e=this.inputArea)||void 0===e?void 0:e.promptNode.getElementsByClassName(oe).length)){let e=this.inputArea.promptNode.appendChild(document.createElement("button"));e.className=`jp-Button ${oe}`,e.setAttribute("data-heading-level",t.toString()),this._headingCollapsed?e.classList.add("jp-mod-collapsed"):e.classList.remove("jp-mod-collapsed"),e.onclick=e=>{this.headingCollapsed=!this.headingCollapsed}}}maybeCreateOrUpdateExpandButton(){const e=this.node.getElementsByClassName(ae);let t=this.translator.load("jupyterlab")._n("%1 cell hidden","%1 cells hidden",this._numberChildNodes);if(this.headingCollapsed&&this._numberChildNodes>0&&0==e.length){const e=document.createElement("button");e.className=`jp-mod-minimal jp-Button ${ae}`,h.addIcon.render(e);const s=document.createElement("div");s.textContent=t,e.appendChild(s),e.onclick=()=>{this.headingCollapsed=!1},this.node.appendChild(e)}if(this.headingCollapsed&&this._numberChildNodes>0&&1==e.length&&(e[0].childNodes[1].textContent=t),!(this.headingCollapsed&&this._numberChildNodes>0))for(const t of e)this.node.removeChild(t)}onContentChanged(){super.onContentChanged(),this._headingsCache=null}renderCollapseButtons(e){this.node.classList.toggle(re,this._headingCollapsed),this.maybeCreateCollapseButton(),this.maybeCreateOrUpdateExpandButton()}renderInput(e){this.addClass(de),this.placeholder||this.isDisposed||(this.renderCollapseButtons(e),this.inputArea.renderInput(e))}showEditor(){if(this.removeClass(de),!this.placeholder&&!this.isDisposed){this.inputArea.showEditor();let e=(this.model.sharedModel.getSource().match(/^#+/g)||[""])[0].length;e>0&&this.inputArea.editor.setCursorPosition({column:e+1,line:0},{scroll:!1})}}onUpdateRequest(e){this._handleRendered().catch((e=>{console.error("Failed to render",e)})),super.onUpdateRequest(e)}updateCellSourceWithAttachment(e,t){var s,i;const n=``;null===(i=null===(s=this.editor)||void 0===s?void 0:s.replaceSelection)||void 0===i||i.call(s,n)}async _handleRendered(){this._rendered?(await this._updateRenderedInput(),this._rendered&&this.renderInput(this._renderer)):this.showEditor()}_updateRenderedInput(){if(this.placeholder)return Promise.resolve();const e=this.model,t=e&&e.sharedModel.getSource()||"Type Markdown and LaTeX: $ α^2 $";if(t!==this._prevText){const e=new G.MimeModel({data:{"text/markdown":t}});return this._prevText=t,this._renderer.renderModel(e)}return Promise.resolve()}clone(){return new(0,this.constructor)({model:this.model,contentFactory:this.contentFactory,rendermime:this._rendermime,placeholder:!1,translator:this.translator})}}!function(e){e.defaultShowEditorForReadOnlyMarkdown=!0}(me||(me={}));class Ce extends ue{constructor(e){super(e),this.addClass("jp-RawCell");const t=this.translator.load("jupyterlab");this.node.setAttribute("aria-label",t.__("Raw Cell Content"))}clone(){return new(0,this.constructor)({model:this.model,contentFactory:this.contentFactory,placeholder:!1,translator:this.translator})}}}}]);
|
notebook/static/2489.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[2489],{72489:(e,t,i)=>{i.r(t),i.d(t,{ABCWidgetFactory:()=>F,Base64ModelFactory:()=>f,Context:()=>_,DocumentModel:()=>p,DocumentRegistry:()=>E,DocumentWidget:()=>w,MimeContent:()=>b,MimeDocument:()=>C,MimeDocumentFactory:()=>D,TextModelFactory:()=>y,createReadonlyLabel:()=>g});var s,a=i(15465),n=i(44548),o=i(50102),r=i(25291),l=i(20998),h=i(2549),d=i(81997),c=i(63485);class _{constructor(e){var t,i;this._isReady=!1,this._isDisposed=!1,this._isPopulated=!1,this._path="",this._lineEnding=null,this._contentsModel=null,this._populatedPromise=new l.PromiseDelegate,this._pathChanged=new d.Signal(this),this._fileChanged=new d.Signal(this),this._saveState=new d.Signal(this),this._disposed=new d.Signal(this),this._lastModifiedCheckMargin=500,this._conflictModalIsOpen=!1;const h=this._manager=e.manager;this.translator=e.translator||r.nullTranslator,this._trans=this.translator.load("jupyterlab"),this._factory=e.factory,this._dialogs=null!==(t=e.sessionDialogs)&&void 0!==t?t:new a.SessionContextDialogs({translator:e.translator}),this._opener=e.opener||s.noOp,this._path=this._manager.contents.normalize(e.path),this._lastModifiedCheckMargin=e.lastModifiedCheckMargin||500;const c=this._manager.contents.localPath(this._path),_=this._factory.preferredLanguage(n.PathExt.basename(c)),m=this._manager.contents.getSharedModelFactory(this._path),u=null==m?void 0:m.createNew({path:c,format:this._factory.fileFormat,contentType:this._factory.contentType,collaborative:this._factory.collaborative});this._model=this._factory.createNew({languagePreference:_,sharedModel:u,collaborationEnabled:null!==(i=null==m?void 0:m.collaborative)&&void 0!==i&&i}),this._readyPromise=h.ready.then((()=>this._populatedPromise.promise));const g=n.PathExt.extname(this._path);this.sessionContext=new a.SessionContext({sessionManager:h.sessions,specsManager:h.kernelspecs,path:c,type:".ipynb"===g?"notebook":"file",name:n.PathExt.basename(c),kernelPreference:e.kernelPreference||{shouldStart:!1},setBusy:e.setBusy}),this.sessionContext.propertyChanged.connect(this._onSessionChanged,this),h.contents.fileChanged.connect(this._onFileChanged,this),this.urlResolver=new o.RenderMimeRegistry.UrlResolver({path:this._path,contents:h.contents})}get pathChanged(){return this._pathChanged}get fileChanged(){return this._fileChanged}get saveState(){return this._saveState}get disposed(){return this._disposed}get lastModifiedCheckMargin(){return this._lastModifiedCheckMargin}set lastModifiedCheckMargin(e){this._lastModifiedCheckMargin=e}get model(){return this._model}get path(){return this._path}get localPath(){return this._manager.contents.localPath(this._path)}get contentsModel(){return this._contentsModel?{...this._contentsModel}:null}get factoryName(){return this.isDisposed?"":this._factory.name}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,this.sessionContext.dispose(),this._model.dispose(),this._model.sharedModel.dispose(),this._disposed.emit(void 0),d.Signal.clearData(this))}get isReady(){return this._isReady}get ready(){return this._readyPromise}get canSave(){var e;return!(!(null===(e=this._contentsModel)||void 0===e?void 0:e.writable)||this._model.collaborative)}async initialize(e){e?await this._save():await this._revert(),this.model.sharedModel.clearUndoHistory()}rename(e){return this.ready.then((()=>this._manager.ready.then((()=>this._rename(e)))))}async save(){await this.ready,await this._save()}async saveAs(){await this.ready;const e=this._manager.contents.localPath(this.path),t=await s.getSavePath(e);if(this.isDisposed||!t)return;const i=this._manager.contents.driveName(this.path),a=""==i?t:`${i}:${t}`;if(a===this._path)return this.save();try{await this._manager.ready,await this._manager.contents.get(a),await this._maybeOverWrite(a)}catch(e){if(!e.response||404!==e.response.status)throw e;await this._finishSaveAs(a)}}async download(){const e=await this._manager.contents.getDownloadUrl(this._path),t=document.createElement("a");t.href=e,t.download="",document.body.appendChild(t),t.click(),document.body.removeChild(t)}async revert(){await this.ready,await this._revert()}createCheckpoint(){const e=this._manager.contents;return this._manager.ready.then((()=>e.createCheckpoint(this._path)))}deleteCheckpoint(e){const t=this._manager.contents;return this._manager.ready.then((()=>t.deleteCheckpoint(this._path,e)))}restoreCheckpoint(e){const t=this._manager.contents,i=this._path;return this._manager.ready.then((()=>e?t.restoreCheckpoint(i,e):this.listCheckpoints().then((s=>{if(!this.isDisposed&&s.length)return e=s[s.length-1].id,t.restoreCheckpoint(i,e)}))))}listCheckpoints(){const e=this._manager.contents;return this._manager.ready.then((()=>e.listCheckpoints(this._path)))}addSibling(e,t={}){const i=this._opener;return i&&i(e,t),new h.DisposableDelegate((()=>{e.close()}))}_onFileChanged(e,t){var i;if("rename"!==t.type)return;let s=t.oldValue&&t.oldValue.path,a=t.newValue&&t.newValue.path;if(a&&0===this._path.indexOf(s||"")){let e=t.newValue;s!==this._path&&(a=this._path.replace(new RegExp(`^${s}/`),`${a}/`),s=this._path,e={last_modified:null===(i=t.newValue)||void 0===i?void 0:i.created,path:a}),this._updateContentsModel({...this._contentsModel,...e}),this._updatePath(a)}}_onSessionChanged(e,t){if("path"!==t)return;const i=this._manager.contents.driveName(this.path);let s=this.sessionContext.session.path;i&&(s=`${i}:${s}`),this._updatePath(s)}_updateContentsModel(e){var t,i,s,a;const n=e.writable&&!this._model.collaborative,o={path:e.path,name:e.name,type:e.type,writable:n,created:e.created,last_modified:e.last_modified,mimetype:e.mimetype,format:e.format,hash:e.hash,hash_algorithm:e.hash_algorithm},r=null!==(i=null===(t=this._contentsModel)||void 0===t?void 0:t.last_modified)&&void 0!==i?i:null,l=null!==(a=null===(s=this._contentsModel)||void 0===s?void 0:s.hash)&&void 0!==a?a:null;this._contentsModel=o,(!r&&!l||!l&&o.last_modified!==r||l&&o.hash!==l)&&this._fileChanged.emit(o)}_updatePath(e){var t,i,s,a;if(this._path===e)return;this._path=e;const o=this._manager.contents.localPath(e),r=n.PathExt.basename(o);if((null===(t=this.sessionContext.session)||void 0===t?void 0:t.path)!==o&&(null===(i=this.sessionContext.session)||void 0===i||i.setPath(o)),(null===(s=this.sessionContext.session)||void 0===s?void 0:s.name)!==r&&(null===(a=this.sessionContext.session)||void 0===a||a.setName(r)),this.urlResolver.path!==e&&(this.urlResolver.path=e),this._contentsModel&&(this._contentsModel.path!==e||this._contentsModel.name!==r)){const t={...this._contentsModel,name:r,path:e};this._updateContentsModel(t)}this._pathChanged.emit(e)}async _populate(){if(this._isPopulated=!0,this._isReady=!0,this._populatedPromise.resolve(void 0),await this._maybeCheckpoint(!1),this.isDisposed)return;const e=this._model.defaultKernelName||this.sessionContext.kernelPreference.name;this.sessionContext.kernelPreference={...this.sessionContext.kernelPreference,name:e,language:this._model.defaultKernelLanguage},this.sessionContext.initialize().then((e=>{e&&this._dialogs.selectKernel(this.sessionContext)}))}async _rename(e){const t=this.localPath.split("/");t[t.length-1]=e;let i=n.PathExt.join(...t);const s=this._manager.contents.driveName(this.path);s&&(i=`${s}:${i}`),await this._manager.contents.rename(this.path,i)}async _save(){this._saveState.emit("started");const e=this._createSaveOptions();try{await this._manager.ready;const t=await this._maybeSave(e);if(this.isDisposed)return;this._model.dirty=!1,this._updateContentsModel(t),this._isPopulated||await this._populate(),this._saveState.emit("completed")}catch(e){const{name:t}=e;if("ModalCancelError"===t||"ModalDuplicateError"===t)throw e;const i=this._manager.contents.localPath(this._path),s=n.PathExt.basename(i);throw this._handleError(e,this._trans.__("File Save Error for %1",s)),this._saveState.emit("failed"),e}}_revert(e=!1){const t={type:this._factory.contentType,content:null!==this._factory.fileFormat,hash:null!==this._factory.fileFormat,...null!==this._factory.fileFormat?{format:this._factory.fileFormat}:{}},i=this._path,s=this._model;return this._manager.ready.then((()=>this._manager.contents.get(i,t))).then((e=>{if(!this.isDisposed){if(e.content)if("json"===e.format)s.fromJSON(e.content);else{let t=e.content;-1!==t.indexOf("\r\n")?(this._lineEnding="\r\n",t=t.replace(/\r\n/g,"\n")):-1!==t.indexOf("\r")?(this._lineEnding="\r",t=t.replace(/\r/g,"\n")):this._lineEnding=null,s.fromString(t)}return this._updateContentsModel(e),s.dirty=!1,this._isPopulated?void 0:this._populate()}})).catch((async e=>{const t=this._manager.contents.localPath(this._path),i=n.PathExt.basename(t);throw this._handleError(e,this._trans.__("File Load Error for %1",i)),e}))}_maybeSave(e){const t=this._path;return this._manager.contents.get(t,{content:!1,hash:!0}).then((i=>{var s,a,n,o;if(this.isDisposed)return Promise.reject(new Error("Disposed"));const r=void 0!==(null===(s=this.contentsModel)||void 0===s?void 0:s.hash)&&null!==(null===(a=this.contentsModel)||void 0===a?void 0:a.hash)&&void 0!==i.hash&&null!==i.hash,l=null===(n=this.contentsModel)||void 0===n?void 0:n.hash,h=i.hash;if(r&&l!==h)return console.warn(`Different hash found for ${this.path}`),this._raiseConflict(i,e);const d=this._lastModifiedCheckMargin,c=null===(o=this.contentsModel)||void 0===o?void 0:o.last_modified,_=c?new Date(c):new Date,m=new Date(i.last_modified);return!r&&c&&m.getTime()-_.getTime()>d?(console.warn(`Last saving performed ${_} while the current file seems to have been saved ${m}`),this._raiseConflict(i,e)):this._manager.contents.save(t,e).then((async e=>{const i=await this._manager.contents.get(t,{content:!1,hash:!0});return{...e,hash:i.hash,hash_algorithm:i.hash_algorithm}}))}),(i=>{if(i.response&&404===i.response.status)return this._manager.contents.save(t,e).then((async e=>{const i=await this._manager.contents.get(t,{content:!1,hash:!0});return{...e,hash:i.hash,hash_algorithm:i.hash_algorithm}}));throw i}))}async _handleError(e,t){await(0,a.showErrorMessage)(t,e)}_maybeCheckpoint(e){let t=Promise.resolve(void 0);return this.canSave?(t=e?this.createCheckpoint().then():this.listCheckpoints().then((e=>{if(!this.isDisposed&&!e.length&&this.canSave)return this.createCheckpoint().then()})),t.catch((e=>{if(!e.response||403!==e.response.status)throw e}))):t}_raiseConflict(e,t){if(this._conflictModalIsOpen){const e=new Error("Modal is already displayed");return e.name="ModalDuplicateError",Promise.reject(e)}const i=this._trans.__('"%1" has changed on disk since the last time it was opened or saved.\nDo you want to overwrite the file on disk with the version open here,\nor load the version on disk (revert)?',this.path),s=a.Dialog.okButton({label:this._trans.__("Revert"),actions:["revert"]}),n=a.Dialog.warnButton({label:this._trans.__("Overwrite"),actions:["overwrite"]});return this._conflictModalIsOpen=!0,(0,a.showDialog)({title:this._trans.__("File Changed"),body:i,buttons:[a.Dialog.cancelButton(),s,n]}).then((i=>{if(this._conflictModalIsOpen=!1,this.isDisposed)return Promise.reject(new Error("Disposed"));if(i.button.actions.includes("overwrite"))return this._manager.contents.save(this._path,t);if(i.button.actions.includes("revert"))return this.revert().then((()=>e));const s=new Error("Cancel");return s.name="ModalCancelError",Promise.reject(s)}))}_maybeOverWrite(e){const t=this._trans.__('"%1" already exists. Do you want to replace it?',e),i=a.Dialog.warnButton({label:this._trans.__("Overwrite"),accept:!0});return(0,a.showDialog)({title:this._trans.__("File Overwrite?"),body:t,buttons:[a.Dialog.cancelButton(),i]}).then((t=>this.isDisposed?Promise.reject(new Error("Disposed")):t.button.accept?this._manager.contents.delete(e).then((()=>this._finishSaveAs(e))):void 0))}async _finishSaveAs(e){this._saveState.emit("started");try{await this._manager.ready;const t=this._createSaveOptions();await this._manager.contents.save(e,t),await this._maybeCheckpoint(!0),this._saveState.emit("completed")}catch(e){if("Cancel"===e.message||"Modal is already displayed"===e.message)throw e;const t=this._manager.contents.localPath(this._path),i=n.PathExt.basename(t);return this._handleError(e,this._trans.__("File Save Error for %1",i)),void this._saveState.emit("failed")}}_createSaveOptions(){let e=null;return"json"===this._factory.fileFormat?e=this._model.toJSON():(e=this._model.toString(),this._lineEnding&&(e=e.replace(/\n/g,this._lineEnding))),{type:this._factory.contentType,format:this._factory.fileFormat,content:e}}}!function(e){e.getSavePath=function(e,i){const s=(i=i||r.nullTranslator).load("jupyterlab"),n=a.Dialog.okButton({label:s.__("Save"),accept:!0});return(0,a.showDialog)({title:s.__("Save File As…"),body:new t(e),buttons:[a.Dialog.cancelButton(),n]}).then((e=>{var t;if(e.button.accept)return null!==(t=e.value)&&void 0!==t?t:void 0}))},e.noOp=function(){};class t extends c.Widget{constructor(e){super({node:i(e)})}getValue(){return this.node.value}}function i(e){const t=document.createElement("input");return t.value=e,t}}(s||(s={}));var m=i(52712),u=i(78156);function g(e,t){var i;let s=(null!=t?t:r.nullTranslator).load("jupyterlab");return a.ReactWidget.create(u.createElement("div",null,u.createElement("span",{className:"jp-ToolbarLabelComponent",title:s.__('Document is read-only. "Save" is disabled; use "Save as…" instead')},s.__("%1 is read-only",null===(i=e.context.contentsModel)||void 0===i?void 0:i.type))))}class p extends m.CodeEditor.Model{constructor(e={}){var t;super({sharedModel:e.sharedModel}),this._defaultLang="",this._dirty=!1,this._readOnly=!1,this._contentChanged=new d.Signal(this),this._stateChanged=new d.Signal(this),this._defaultLang=null!==(t=e.languagePreference)&&void 0!==t?t:"",this._collaborationEnabled=!!e.collaborationEnabled,this.sharedModel.changed.connect(this._onStateChanged,this)}get contentChanged(){return this._contentChanged}get stateChanged(){return this._stateChanged}get dirty(){return this._dirty}set dirty(e){const t=this._dirty;e!==t&&(this._dirty=e,this.triggerStateChange({name:"dirty",oldValue:t,newValue:e}))}get readOnly(){return this._readOnly}set readOnly(e){if(e===this._readOnly)return;const t=this._readOnly;this._readOnly=e,this.triggerStateChange({name:"readOnly",oldValue:t,newValue:e})}get defaultKernelName(){return""}get defaultKernelLanguage(){return this._defaultLang}get collaborative(){return this._collaborationEnabled}toString(){return this.sharedModel.getSource()}fromString(e){this.sharedModel.setSource(e)}toJSON(){return JSON.parse(this.sharedModel.getSource()||"null")}fromJSON(e){this.fromString(JSON.stringify(e))}initialize(){}triggerStateChange(e){this._stateChanged.emit(e)}triggerContentChange(){this._contentChanged.emit(void 0),this.dirty=!0}_onStateChanged(e,t){t.sourceChange&&this.triggerContentChange(),t.stateChange&&t.stateChange.forEach((e=>{"dirty"===e.name?this.dirty=e.newValue:e.oldValue!==e.newValue&&this.triggerStateChange({newValue:void 0,oldValue:void 0,...e})}))}}class y{constructor(e){this._isDisposed=!1,this._collaborative=null==e||e}get name(){return"text"}get contentType(){return"file"}get fileFormat(){return"text"}get collaborative(){return this._collaborative}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed=!0}createNew(e={}){const t=e.collaborationEnabled&&this.collaborative;return new p({...e,collaborationEnabled:t})}preferredLanguage(e){return""}}class f extends y{get name(){return"base64"}get contentType(){return"file"}get fileFormat(){return"base64"}}class F{constructor(e){this._isDisposed=!1,this._widgetCreated=new d.Signal(this),this._translator=e.translator||r.nullTranslator,this._name=e.name,this._label=e.label||e.name,this._readOnly=void 0!==e.readOnly&&e.readOnly,this._defaultFor=e.defaultFor?e.defaultFor.slice():[],this._defaultRendered=(e.defaultRendered||[]).slice(),this._fileTypes=e.fileTypes.slice(),this._modelName=e.modelName||"text",this._preferKernel=!!e.preferKernel,this._canStartKernel=!!e.canStartKernel,this._shutdownOnClose=!!e.shutdownOnClose,this._autoStartDefault=!!e.autoStartDefault,this._toolbarFactory=e.toolbarFactory}get widgetCreated(){return this._widgetCreated}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,d.Signal.clearData(this))}get readOnly(){return this._readOnly}get name(){return this._name}get label(){return this._label}get fileTypes(){return this._fileTypes.slice()}get modelName(){return this._modelName}get defaultFor(){return this._defaultFor.slice()}get defaultRendered(){return this._defaultRendered.slice()}get preferKernel(){return this._preferKernel}get canStartKernel(){return this._canStartKernel}get translator(){return this._translator}get shutdownOnClose(){return this._shutdownOnClose}set shutdownOnClose(e){this._shutdownOnClose=e}get autoStartDefault(){return this._autoStartDefault}set autoStartDefault(e){this._autoStartDefault=e}createNew(e,t){var i;const s=this.createNewWidget(e,t);return(0,a.setToolbar)(s,null!==(i=this._toolbarFactory)&&void 0!==i?i:this.defaultToolbarFactory.bind(this)),this._widgetCreated.emit(s),s}defaultToolbarFactory(e){return[]}}const v="jp-mod-dirty";class w extends a.MainAreaWidget{constructor(e){var t;e.reveal=Promise.all([e.reveal,e.context.ready]),super(e),this._trans=(null!==(t=e.translator)&&void 0!==t?t:r.nullTranslator).load("jupyterlab"),this.context=e.context,this.context.pathChanged.connect(this._onPathChanged,this),this._onPathChanged(this.context,this.context.path),this.context.model.stateChanged.connect(this._onModelStateChanged,this),this.context.ready.then((()=>{this._handleDirtyState()})),this.title.changed.connect(this._onTitleChanged,this)}setFragment(e){}async _onTitleChanged(e){const t=this.title.label,i=this.context.localPath.split("/").pop()||this.context.localPath;if(t!==i){if(t.length>0&&!/[\/\\:]/.test(t)){const e=this.context.path;if(await this.context.rename(t),this.context.path!==e)return}this.title.label=i}}_onPathChanged(e,t){this.title.label=n.PathExt.basename(e.localPath),this.isUntitled=!1}_onModelStateChanged(e,t){var i;if("dirty"===t.name&&this._handleDirtyState(),!this.context.model.dirty&&!this.context.model.collaborative&&!(null===(i=this.context.contentsModel)||void 0===i?void 0:i.writable)){const e=g(this);this.toolbar.insertBefore("kernelName","read-only-indicator",e)||this.toolbar.addItem("read-only-indicator",e)}}_handleDirtyState(){this.context.model.dirty&&!this.title.className.includes(v)?this.title.className+=` ${v}`:this.title.className=this.title.className.replace(v,"")}}var x,T=i(49503);class b extends c.Widget{constructor(e){super(),this._changeCallback=e=>{if(!e.data||!e.data[this.mimeType])return;const t=e.data[this.mimeType];"string"==typeof t?t!==this._context.model.toString()&&this._context.model.fromString(t):null==t||l.JSONExt.deepEqual(t,this._context.model.toJSON())||this._context.model.fromJSON(t)},this._fragment="",this._ready=new l.PromiseDelegate,this._isRendering=!1,this._renderRequested=!1,this.addClass("jp-MimeDocument"),this.translator=e.translator||r.nullTranslator,this._trans=this.translator.load("jupyterlab"),this.mimeType=e.mimeType,this._dataType=e.dataType||"string",this._context=e.context,this.renderer=e.renderer,(this.layout=new c.StackedLayout).addWidget(this.renderer),this._context.ready.then((()=>this._render())).then((()=>{this.node===document.activeElement&&T.MessageLoop.sendMessage(this.renderer,c.Widget.Msg.ActivateRequest),this._monitor=new n.ActivityMonitor({signal:this._context.model.contentChanged,timeout:e.renderTimeout}),this._monitor.activityStopped.connect(this.update,this),this._ready.resolve(void 0)})).catch((e=>{requestAnimationFrame((()=>{this.dispose()})),(0,a.showErrorMessage)(this._trans.__("Renderer Failure: %1",this._context.path),e)}))}[a.Printing.symbol](){return a.Printing.getPrintFunction(this.renderer)}get ready(){return this._ready.promise}setFragment(e){this._fragment=e,this.update()}dispose(){this.isDisposed||(this._monitor&&this._monitor.dispose(),this._monitor=null,super.dispose())}onUpdateRequest(e){this._context.isReady&&(this._render(),this._fragment="")}async _render(){if(this.isDisposed)return;if(this._isRendering)return void(this._renderRequested=!0);this._renderRequested=!1;const e=this._context,t=e.model,i={};"string"===this._dataType?i[this.mimeType]=t.toString():i[this.mimeType]=t.toJSON();const s=new o.MimeModel({data:i,callback:this._changeCallback,metadata:{fragment:this._fragment}});try{if(this._isRendering=!0,await this.renderer.renderModel(s),this._isRendering=!1,this._renderRequested)return this._render()}catch(t){requestAnimationFrame((()=>{this.dispose()})),(0,a.showErrorMessage)(this._trans.__("Renderer Failure: %1",e.path),t)}}}class C extends w{setFragment(e){this.content.setFragment(e)}}class D extends F{constructor(e){super(x.createRegistryOptions(e)),this._rendermime=e.rendermime,this._renderTimeout=e.renderTimeout||1e3,this._dataType=e.dataType||"string",this._fileType=e.primaryFileType,this._factory=e.factory}createNewWidget(e){var t,i;const s=this._fileType,a=(null==s?void 0:s.mimeTypes.length)?s.mimeTypes[0]:m.IEditorMimeTypeService.defaultMimeType,n=this._rendermime.clone({resolver:e.urlResolver});let o;o=this._factory&&this._factory.mimeTypes.includes(a)?this._factory.createRenderer({mimeType:a,resolver:n.resolver,sanitizer:n.sanitizer,linkHandler:n.linkHandler,latexTypesetter:n.latexTypesetter,markdownParser:n.markdownParser}):n.createRenderer(a);const r=new b({context:e,renderer:o,mimeType:a,renderTimeout:this._renderTimeout,dataType:this._dataType});return r.title.icon=null==s?void 0:s.icon,r.title.iconClass=null!==(t=null==s?void 0:s.iconClass)&&void 0!==t?t:"",r.title.iconLabel=null!==(i=null==s?void 0:s.iconLabel)&&void 0!==i?i:"",new C({content:r,context:e})}}!function(e){e.createRegistryOptions=function(e){return{...e,readOnly:!0}}}(x||(x={}));var S,M=i(12668),O=i(33625);class E{constructor(e={}){this._modelFactories=Object.create(null),this._widgetFactories=Object.create(null),this._defaultWidgetFactory="",this._defaultWidgetFactoryOverrides=Object.create(null),this._defaultWidgetFactories=Object.create(null),this._defaultRenderedWidgetFactories=Object.create(null),this._widgetFactoriesForFileType=Object.create(null),this._fileTypes=[],this._extenders=Object.create(null),this._changed=new d.Signal(this),this._isDisposed=!1;const t=e.textModelFactory;if(this.translator=e.translator||r.nullTranslator,t&&"text"!==t.name)throw new Error("Text model factory must have the name `text`");this._modelFactories.text=t||new y(!0),(e.initialFileTypes||E.getDefaultFileTypes(this.translator)).forEach((e=>{const t={...E.getFileTypeDefaults(this.translator),...e};this._fileTypes.push(t)}))}get changed(){return this._changed}get isDisposed(){return this._isDisposed}dispose(){if(!this.isDisposed){this._isDisposed=!0;for(const e in this._modelFactories)this._modelFactories[e].dispose();for(const e in this._widgetFactories)this._widgetFactories[e].dispose();for(const e in this._extenders)this._extenders[e].length=0;this._fileTypes.length=0,d.Signal.clearData(this)}}addWidgetFactory(e){const t=e.name.toLowerCase();if(!t||"default"===t)throw Error("Invalid factory name");if(this._widgetFactories[t])return console.warn(`Duplicate registered factory ${t}`),new h.DisposableDelegate(S.noOp);this._widgetFactories[t]=e;for(const i of e.defaultFor||[])-1!==e.fileTypes.indexOf(i)&&("*"===i?this._defaultWidgetFactory=t:this._defaultWidgetFactories[i]=t);for(const i of e.defaultRendered||[])-1!==e.fileTypes.indexOf(i)&&(this._defaultRenderedWidgetFactories[i]=t);for(const i of e.fileTypes)this._widgetFactoriesForFileType[i]||(this._widgetFactoriesForFileType[i]=[]),this._widgetFactoriesForFileType[i].push(t);return this._changed.emit({type:"widgetFactory",name:t,change:"added"}),new h.DisposableDelegate((()=>{delete this._widgetFactories[t],this._defaultWidgetFactory===t&&(this._defaultWidgetFactory="");for(const e of Object.keys(this._defaultWidgetFactories))this._defaultWidgetFactories[e]===t&&delete this._defaultWidgetFactories[e];for(const e of Object.keys(this._defaultRenderedWidgetFactories))this._defaultRenderedWidgetFactories[e]===t&&delete this._defaultRenderedWidgetFactories[e];for(const e of Object.keys(this._widgetFactoriesForFileType))O.ArrayExt.removeFirstOf(this._widgetFactoriesForFileType[e],t),0===this._widgetFactoriesForFileType[e].length&&delete this._widgetFactoriesForFileType[e];for(const e of Object.keys(this._defaultWidgetFactoryOverrides))this._defaultWidgetFactoryOverrides[e]===t&&delete this._defaultWidgetFactoryOverrides[e];this._changed.emit({type:"widgetFactory",name:t,change:"removed"})}))}addModelFactory(e){const t=e.name.toLowerCase();return this._modelFactories[t]?(console.warn(`Duplicate registered factory ${t}`),new h.DisposableDelegate(S.noOp)):(this._modelFactories[t]=e,this._changed.emit({type:"modelFactory",name:t,change:"added"}),new h.DisposableDelegate((()=>{delete this._modelFactories[t],this._changed.emit({type:"modelFactory",name:t,change:"removed"})})))}addWidgetExtension(e,t){(e=e.toLowerCase())in this._extenders||(this._extenders[e]=[]);const i=this._extenders[e];return-1!==O.ArrayExt.firstIndexOf(i,t)?(console.warn(`Duplicate registered extension for ${e}`),new h.DisposableDelegate(S.noOp)):(this._extenders[e].push(t),this._changed.emit({type:"widgetExtension",name:e,change:"added"}),new h.DisposableDelegate((()=>{O.ArrayExt.removeFirstOf(this._extenders[e],t),this._changed.emit({type:"widgetExtension",name:e,change:"removed"})})))}addFileType(e,t){const i={...E.getFileTypeDefaults(this.translator),...e,...!(e.icon||e.iconClass)&&{icon:M.fileIcon}};if(this._fileTypes.push(i),t){const e=i.name.toLowerCase();t.map((e=>e.toLowerCase())).forEach((t=>{this._widgetFactoriesForFileType[e]||(this._widgetFactoriesForFileType[e]=[]),this._widgetFactoriesForFileType[e].includes(t)||this._widgetFactoriesForFileType[e].push(t)})),this._defaultWidgetFactories[e]||(this._defaultWidgetFactories[e]=this._widgetFactoriesForFileType[e][0])}return this._changed.emit({type:"fileType",name:i.name,change:"added"}),new h.DisposableDelegate((()=>{if(O.ArrayExt.removeFirstOf(this._fileTypes,i),t){const e=i.name.toLowerCase();for(const i of t.map((e=>e.toLowerCase())))O.ArrayExt.removeFirstOf(this._widgetFactoriesForFileType[e],i);this._defaultWidgetFactories[e]===t[0].toLowerCase()&&delete this._defaultWidgetFactories[e]}this._changed.emit({type:"fileType",name:e.name,change:"removed"})}))}preferredWidgetFactories(e){const t=new Set,i=this.getFileTypesForPath(n.PathExt.basename(e));i.forEach((e=>{e.name in this._defaultWidgetFactoryOverrides&&t.add(this._defaultWidgetFactoryOverrides[e.name])})),i.forEach((e=>{e.name in this._defaultWidgetFactories&&t.add(this._defaultWidgetFactories[e.name])})),i.forEach((e=>{e.name in this._defaultRenderedWidgetFactories&&t.add(this._defaultRenderedWidgetFactories[e.name])})),this._defaultWidgetFactory&&t.add(this._defaultWidgetFactory);for(const e of i)if(e.name in this._widgetFactoriesForFileType)for(const i of this._widgetFactoriesForFileType[e.name])t.add(i);if("*"in this._widgetFactoriesForFileType)for(const e of this._widgetFactoriesForFileType["*"])t.add(e);const s=[];for(const e of t){const t=this._widgetFactories[e];t&&((t.modelName||"text")in this._modelFactories&&s.push(t))}return s}defaultRenderedWidgetFactory(e){const t=this.getFileTypesForPath(n.PathExt.basename(e)).map((e=>e.name));for(const e in t)if(e in this._defaultWidgetFactoryOverrides)return this._widgetFactories[this._defaultWidgetFactoryOverrides[e]];for(const e in t)if(e in this._defaultRenderedWidgetFactories)return this._widgetFactories[this._defaultRenderedWidgetFactories[e]];return this.defaultWidgetFactory(e)}defaultWidgetFactory(e){return e?this.preferredWidgetFactories(e)[0]:this._widgetFactories[this._defaultWidgetFactory]}setDefaultWidgetFactory(e,t){if(e=e.toLowerCase(),!this.getFileType(e))throw Error(`Cannot find file type ${e}`);if(!t)return void(this._defaultWidgetFactoryOverrides[e]&&delete this._defaultWidgetFactoryOverrides[e]);if(!this.getWidgetFactory(t))throw Error(`Cannot find widget factory ${t}`);t=t.toLowerCase();const i=this._widgetFactoriesForFileType[e];if(!(t===this._defaultWidgetFactory||i&&i.includes(t)))throw Error(`Factory ${t} cannot view file type ${e}`);this._defaultWidgetFactoryOverrides[e]=t}*widgetFactories(){for(const e in this._widgetFactories)yield this._widgetFactories[e]}*modelFactories(){for(const e in this._modelFactories)yield this._modelFactories[e]}*widgetExtensions(e){if((e=e.toLowerCase())in this._extenders)for(const t of this._extenders[e])yield t}*fileTypes(){for(const e of this._fileTypes)yield e}getWidgetFactory(e){return this._widgetFactories[e.toLowerCase()]}getModelFactory(e){return this._modelFactories[e.toLowerCase()]}getFileType(e){return e=e.toLowerCase(),(0,O.find)(this._fileTypes,(t=>t.name.toLowerCase()===e))}getKernelPreference(e,t,i){t=t.toLowerCase();const s=this._widgetFactories[t];if(!s)return;const a=this.getModelFactory(s.modelName||"text");if(!a)return;const o=a.preferredLanguage(n.PathExt.basename(e)),r=i&&i.name;return{id:i&&i.id,name:r,language:o,shouldStart:s.preferKernel,canStart:s.canStartKernel,shutdownOnDispose:s.shutdownOnClose,autoStartDefault:s.autoStartDefault}}getFileTypeForModel(e){let t=null;if(e.name||e.path){const i=e.name||n.PathExt.basename(e.path),s=this.getFileTypesForPath(i);s.length>0&&(t=s[0])}switch(e.type){case"directory":return null!==t&&"directory"===t.contentType?t:(0,O.find)(this._fileTypes,(e=>"directory"===e.contentType))||E.getDefaultDirectoryFileType(this.translator);case"notebook":return null!==t&&"notebook"===t.contentType?t:(0,O.find)(this._fileTypes,(e=>"notebook"===e.contentType))||E.getDefaultNotebookFileType(this.translator);default:return null!==t?t:this.getFileType("text")||E.getDefaultTextFileType(this.translator)}}getFileTypesForPath(e){const t=[],i=n.PathExt.basename(e);let s=(0,O.find)(this._fileTypes,(e=>!(!e.pattern||null===i.match(e.pattern))));s&&t.push(s);let a=S.extname(i);for(;a.length>1;){const e=this._fileTypes.filter((e=>e.extensions.map((e=>e.toLowerCase())).includes(a)));t.push(...e),a="."+a.split(".").slice(2).join(".")}return t}}!function(e){function t(e){return{name:"default",displayName:(null==(e=e||r.nullTranslator)?void 0:e.load("jupyterlab")).__("default"),extensions:[],mimeTypes:[],contentType:"file",fileFormat:"text"}}function i(e){const i=null==(e=e||r.nullTranslator)?void 0:e.load("jupyterlab");return{...t(e),name:"text",displayName:i.__("Text"),mimeTypes:["text/plain"],extensions:[".txt"],icon:M.fileIcon}}function s(e){const i=null==(e=e||r.nullTranslator)?void 0:e.load("jupyterlab");return{...t(e),name:"notebook",displayName:i.__("Notebook"),mimeTypes:["application/x-ipynb+json"],extensions:[".ipynb"],contentType:"notebook",fileFormat:"json",icon:M.notebookIcon}}function a(e){const i=null==(e=e||r.nullTranslator)?void 0:e.load("jupyterlab");return{...t(e),name:"directory",displayName:i.__("Directory"),extensions:[],mimeTypes:["text/directory"],contentType:"directory",icon:M.folderIcon}}e.getFileTypeDefaults=t,e.getDefaultTextFileType=i,e.getDefaultNotebookFileType=s,e.getDefaultDirectoryFileType=a,e.getDefaultFileTypes=function(e){const t=null==(e=e||r.nullTranslator)?void 0:e.load("jupyterlab");return[i(e),s(e),a(e),{name:"markdown",displayName:t.__("Markdown File"),extensions:[".md"],mimeTypes:["text/markdown"],icon:M.markdownIcon},{name:"PDF",displayName:t.__("PDF File"),extensions:[".pdf"],mimeTypes:["application/pdf"],icon:M.pdfIcon},{name:"python",displayName:t.__("Python File"),extensions:[".py"],mimeTypes:["text/x-python"],icon:M.pythonIcon},{name:"json",displayName:t.__("JSON File"),extensions:[".json"],mimeTypes:["application/json"],icon:M.jsonIcon},{name:"jsonl",displayName:t.__("JSONLines File"),extensions:[".jsonl",".ndjson"],mimeTypes:["text/jsonl","application/jsonl","application/json-lines"],icon:M.jsonIcon},{name:"julia",displayName:t.__("Julia File"),extensions:[".jl"],mimeTypes:["text/x-julia"],icon:M.juliaIcon},{name:"csv",displayName:t.__("CSV File"),extensions:[".csv"],mimeTypes:["text/csv"],icon:M.spreadsheetIcon},{name:"tsv",displayName:t.__("TSV File"),extensions:[".tsv"],mimeTypes:["text/csv"],icon:M.spreadsheetIcon},{name:"r",displayName:t.__("R File"),mimeTypes:["text/x-rsrc"],extensions:[".R"],icon:M.rKernelIcon},{name:"yaml",displayName:t.__("YAML File"),mimeTypes:["text/x-yaml","text/yaml"],extensions:[".yaml",".yml"],icon:M.yamlIcon},{name:"svg",displayName:t.__("Image"),mimeTypes:["image/svg+xml"],extensions:[".svg"],icon:M.imageIcon,fileFormat:"base64"},{name:"tiff",displayName:t.__("Image"),mimeTypes:["image/tiff"],extensions:[".tif",".tiff"],icon:M.imageIcon,fileFormat:"base64"},{name:"jpeg",displayName:t.__("Image"),mimeTypes:["image/jpeg"],extensions:[".jpg",".jpeg"],icon:M.imageIcon,fileFormat:"base64"},{name:"gif",displayName:t.__("Image"),mimeTypes:["image/gif"],extensions:[".gif"],icon:M.imageIcon,fileFormat:"base64"},{name:"png",displayName:t.__("Image"),mimeTypes:["image/png"],extensions:[".png"],icon:M.imageIcon,fileFormat:"base64"},{name:"bmp",displayName:t.__("Image"),mimeTypes:["image/bmp"],extensions:[".bmp"],icon:M.imageIcon,fileFormat:"base64"},{name:"webp",displayName:t.__("Image"),mimeTypes:["image/webp"],extensions:[".webp"],icon:M.imageIcon,fileFormat:"base64"}]}}(E||(E={})),function(e){e.extname=function(e){const t=n.PathExt.basename(e).split(".");return t.shift(),("."+t.join(".")).toLowerCase()},e.noOp=function(){}}(S||(S={}))}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[2489],{72489:(e,t,i)=>{i.r(t),i.d(t,{ABCWidgetFactory:()=>F,Base64ModelFactory:()=>f,Context:()=>_,DocumentModel:()=>g,DocumentRegistry:()=>E,DocumentWidget:()=>w,MimeContent:()=>b,MimeDocument:()=>C,MimeDocumentFactory:()=>D,TextModelFactory:()=>y,createReadonlyLabel:()=>p});var s,a=i(53876),n=i(20754),o=i(58194),r=i(93050),l=i(21961),h=i(49901),d=i(2159),c=i(2260);class _{constructor(e){var t,i;this._isReady=!1,this._isDisposed=!1,this._isPopulated=!1,this._path="",this._lineEnding=null,this._contentsModel=null,this._populatedPromise=new l.PromiseDelegate,this._pathChanged=new d.Signal(this),this._fileChanged=new d.Signal(this),this._saveState=new d.Signal(this),this._disposed=new d.Signal(this),this._lastModifiedCheckMargin=500,this._conflictModalIsOpen=!1;const h=this._manager=e.manager;this.translator=e.translator||r.nullTranslator,this._trans=this.translator.load("jupyterlab"),this._factory=e.factory,this._dialogs=null!==(t=e.sessionDialogs)&&void 0!==t?t:new a.SessionContextDialogs({translator:e.translator}),this._opener=e.opener||s.noOp,this._path=this._manager.contents.normalize(e.path),this._lastModifiedCheckMargin=e.lastModifiedCheckMargin||500;const c=this._manager.contents.localPath(this._path),_=this._factory.preferredLanguage(n.PathExt.basename(c)),m=this._manager.contents.getSharedModelFactory(this._path),u=null==m?void 0:m.createNew({path:c,format:this._factory.fileFormat,contentType:this._factory.contentType,collaborative:this._factory.collaborative});this._model=this._factory.createNew({languagePreference:_,sharedModel:u,collaborationEnabled:null!==(i=null==m?void 0:m.collaborative)&&void 0!==i&&i}),this._readyPromise=h.ready.then((()=>this._populatedPromise.promise));const p=n.PathExt.extname(this._path);this.sessionContext=new a.SessionContext({kernelManager:h.kernels,sessionManager:h.sessions,specsManager:h.kernelspecs,path:c,type:".ipynb"===p?"notebook":"file",name:n.PathExt.basename(c),kernelPreference:e.kernelPreference||{shouldStart:!1},setBusy:e.setBusy}),this.sessionContext.propertyChanged.connect(this._onSessionChanged,this),h.contents.fileChanged.connect(this._onFileChanged,this),this.urlResolver=new o.RenderMimeRegistry.UrlResolver({path:this._path,contents:h.contents})}get pathChanged(){return this._pathChanged}get fileChanged(){return this._fileChanged}get saveState(){return this._saveState}get disposed(){return this._disposed}get lastModifiedCheckMargin(){return this._lastModifiedCheckMargin}set lastModifiedCheckMargin(e){this._lastModifiedCheckMargin=e}get model(){return this._model}get path(){return this._path}get localPath(){return this._manager.contents.localPath(this._path)}get contentsModel(){return this._contentsModel?{...this._contentsModel}:null}get factoryName(){return this.isDisposed?"":this._factory.name}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,this.sessionContext.dispose(),this._model.dispose(),this._model.sharedModel.dispose(),this._disposed.emit(void 0),d.Signal.clearData(this))}get isReady(){return this._isReady}get ready(){return this._readyPromise}get canSave(){var e;return!(!(null===(e=this._contentsModel)||void 0===e?void 0:e.writable)||this._model.collaborative)}async initialize(e){e?await this._save():await this._revert(),this.model.sharedModel.clearUndoHistory()}rename(e){return this.ready.then((()=>this._manager.ready.then((()=>this._rename(e)))))}async save(){await this.ready,await this._save()}async saveAs(){await this.ready;const e=this._manager.contents.localPath(this.path),t=await s.getSavePath(e);if(this.isDisposed||!t)return;const i=this._manager.contents.driveName(this.path),a=""==i?t:`${i}:${t}`;if(a===this._path)return this.save();try{await this._manager.ready,await this._manager.contents.get(a),await this._maybeOverWrite(a)}catch(e){if(!e.response||404!==e.response.status)throw e;await this._finishSaveAs(a)}}async download(){const e=await this._manager.contents.getDownloadUrl(this._path),t=document.createElement("a");t.href=e,t.download="",document.body.appendChild(t),t.click(),document.body.removeChild(t)}async revert(){await this.ready,await this._revert()}createCheckpoint(){const e=this._manager.contents;return this._manager.ready.then((()=>e.createCheckpoint(this._path)))}deleteCheckpoint(e){const t=this._manager.contents;return this._manager.ready.then((()=>t.deleteCheckpoint(this._path,e)))}restoreCheckpoint(e){const t=this._manager.contents,i=this._path;return this._manager.ready.then((()=>e?t.restoreCheckpoint(i,e):this.listCheckpoints().then((s=>{if(!this.isDisposed&&s.length)return e=s[s.length-1].id,t.restoreCheckpoint(i,e)}))))}listCheckpoints(){const e=this._manager.contents;return this._manager.ready.then((()=>e.listCheckpoints(this._path)))}addSibling(e,t={}){const i=this._opener;return i&&i(e,t),new h.DisposableDelegate((()=>{e.close()}))}_onFileChanged(e,t){var i;if("save"===t.type&&this._model.collaborative)return void this._updateContentsModel({...this._contentsModel,...t.newValue});if("rename"!==t.type)return;let s=t.oldValue&&t.oldValue.path,a=t.newValue&&t.newValue.path;if(a&&0===this._path.indexOf(s||"")){let e=t.newValue;s!==this._path&&(a=this._path.replace(new RegExp(`^${s}/`),`${a}/`),s=this._path,e={last_modified:null===(i=t.newValue)||void 0===i?void 0:i.created,path:a}),this._updateContentsModel({...this._contentsModel,...e}),this._updatePath(a)}}_onSessionChanged(e,t){if("path"!==t)return;const i=this._manager.contents.driveName(this.path);let s=this.sessionContext.session.path;i&&(s=`${i}:${s}`),this._updatePath(s)}_updateContentsModel(e){var t,i,s,a;const n=e.writable&&!this._model.collaborative,o={path:e.path,name:e.name,type:e.type,writable:n,created:e.created,last_modified:e.last_modified,mimetype:e.mimetype,format:e.format,hash:e.hash,hash_algorithm:e.hash_algorithm},r=null!==(i=null===(t=this._contentsModel)||void 0===t?void 0:t.last_modified)&&void 0!==i?i:null,l=null!==(a=null===(s=this._contentsModel)||void 0===s?void 0:s.hash)&&void 0!==a?a:null;this._contentsModel=o,(!r&&!l||!l&&o.last_modified!==r||l&&o.hash!==l)&&this._fileChanged.emit(o)}_updatePath(e){var t,i,s,a;if(this._path===e)return;this._path=e;const o=this._manager.contents.localPath(e),r=n.PathExt.basename(o);if((null===(t=this.sessionContext.session)||void 0===t?void 0:t.path)!==o&&(null===(i=this.sessionContext.session)||void 0===i||i.setPath(o)),(null===(s=this.sessionContext.session)||void 0===s?void 0:s.name)!==r&&(null===(a=this.sessionContext.session)||void 0===a||a.setName(r)),this.urlResolver.path!==e&&(this.urlResolver.path=e),this._contentsModel&&(this._contentsModel.path!==e||this._contentsModel.name!==r)){const t={...this._contentsModel,name:r,path:e};this._updateContentsModel(t)}this._pathChanged.emit(e)}async _populate(){if(this._isPopulated=!0,this._isReady=!0,this._populatedPromise.resolve(void 0),await this._maybeCheckpoint(!1),this.isDisposed)return;const e=this._model.defaultKernelName||this.sessionContext.kernelPreference.name;this.sessionContext.kernelPreference={...this.sessionContext.kernelPreference,name:e,language:this._model.defaultKernelLanguage},this.sessionContext.initialize().then((e=>{e&&this._dialogs.selectKernel(this.sessionContext)}))}async _rename(e){const t=this.localPath.split("/");t[t.length-1]=e;let i=n.PathExt.join(...t);const s=this._manager.contents.driveName(this.path);s&&(i=`${s}:${i}`),await this._manager.contents.rename(this.path,i)}async _save(){this._saveState.emit("started");const e=this._createSaveOptions();try{await this._manager.ready;const t=await this._maybeSave(e);if(this.isDisposed)return;this._model.dirty=!1,this._updateContentsModel(t),this._isPopulated||await this._populate(),this._saveState.emit("completed")}catch(e){const{name:t}=e;if("ModalCancelError"===t||"ModalDuplicateError"===t)throw e;const i=this._manager.contents.localPath(this._path),s=n.PathExt.basename(i);throw this._handleError(e,this._trans.__("File Save Error for %1",s)),this._saveState.emit("failed"),e}}_revert(e=!1){const t={type:this._factory.contentType,content:null!==this._factory.fileFormat,hash:null!==this._factory.fileFormat,...null!==this._factory.fileFormat?{format:this._factory.fileFormat}:{}},i=this._path,s=this._model;return this._manager.ready.then((()=>this._manager.contents.get(i,t))).then((e=>{if(!this.isDisposed){if(e.content)if("json"===e.format)s.fromJSON(e.content);else{let t=e.content;-1!==t.indexOf("\r\n")?(this._lineEnding="\r\n",t=t.replace(/\r\n/g,"\n")):-1!==t.indexOf("\r")?(this._lineEnding="\r",t=t.replace(/\r/g,"\n")):this._lineEnding=null,s.fromString(t)}return this._updateContentsModel(e),s.dirty=!1,this._isPopulated?void 0:this._populate()}})).catch((async e=>{const t=this._manager.contents.localPath(this._path),i=n.PathExt.basename(t);throw this._handleError(e,this._trans.__("File Load Error for %1",i)),e}))}_maybeSave(e){const t=this._path;return this._manager.contents.get(t,{content:!1,hash:!0}).then((i=>{var s,a,n,o;if(this.isDisposed)return Promise.reject(new Error("Disposed"));const r=void 0!==(null===(s=this.contentsModel)||void 0===s?void 0:s.hash)&&null!==(null===(a=this.contentsModel)||void 0===a?void 0:a.hash)&&void 0!==i.hash&&null!==i.hash,l=null===(n=this.contentsModel)||void 0===n?void 0:n.hash,h=i.hash;if(r&&l!==h)return console.warn(`Different hash found for ${this.path}`),this._raiseConflict(i,e);const d=this._lastModifiedCheckMargin,c=null===(o=this.contentsModel)||void 0===o?void 0:o.last_modified,_=c?new Date(c):new Date,m=new Date(i.last_modified);return!r&&c&&m.getTime()-_.getTime()>d?(console.warn(`Last saving performed ${_} while the current file seems to have been saved ${m}`),this._raiseConflict(i,e)):this._manager.contents.save(t,e).then((async e=>{const i=await this._manager.contents.get(t,{content:!1,hash:!0});return{...e,hash:i.hash,hash_algorithm:i.hash_algorithm}}))}),(i=>{if(i.response&&404===i.response.status)return this._manager.contents.save(t,e).then((async e=>{const i=await this._manager.contents.get(t,{content:!1,hash:!0});return{...e,hash:i.hash,hash_algorithm:i.hash_algorithm}}));throw i}))}async _handleError(e,t){await(0,a.showErrorMessage)(t,e)}_maybeCheckpoint(e){let t=Promise.resolve(void 0);return this.canSave?(t=e?this.createCheckpoint().then():this.listCheckpoints().then((e=>{if(!this.isDisposed&&!e.length&&this.canSave)return this.createCheckpoint().then()})),t.catch((e=>{if(!e.response||403!==e.response.status)throw e}))):t}_raiseConflict(e,t){if(this._conflictModalIsOpen){const e=new Error("Modal is already displayed");return e.name="ModalDuplicateError",Promise.reject(e)}const i=this._trans.__('"%1" has changed on disk since the last time it was opened or saved.\nDo you want to overwrite the file on disk with the version open here,\nor load the version on disk (revert)?',this.path),s=a.Dialog.okButton({label:this._trans.__("Revert"),actions:["revert"]}),n=a.Dialog.warnButton({label:this._trans.__("Overwrite"),actions:["overwrite"]});return this._conflictModalIsOpen=!0,(0,a.showDialog)({title:this._trans.__("File Changed"),body:i,buttons:[a.Dialog.cancelButton(),s,n]}).then((i=>{if(this._conflictModalIsOpen=!1,this.isDisposed)return Promise.reject(new Error("Disposed"));if(i.button.actions.includes("overwrite"))return this._manager.contents.save(this._path,t);if(i.button.actions.includes("revert"))return this.revert().then((()=>e));const s=new Error("Cancel");return s.name="ModalCancelError",Promise.reject(s)}))}_maybeOverWrite(e){const t=this._trans.__('"%1" already exists. Do you want to replace it?',e),i=a.Dialog.warnButton({label:this._trans.__("Overwrite"),accept:!0});return(0,a.showDialog)({title:this._trans.__("File Overwrite?"),body:t,buttons:[a.Dialog.cancelButton(),i]}).then((t=>this.isDisposed?Promise.reject(new Error("Disposed")):t.button.accept?this._manager.contents.delete(e).then((()=>this._finishSaveAs(e))):void 0))}async _finishSaveAs(e){this._saveState.emit("started");try{await this._manager.ready;const t=this._createSaveOptions();await this._manager.contents.save(e,t),await this._maybeCheckpoint(!0),this._saveState.emit("completed")}catch(e){if("Cancel"===e.message||"Modal is already displayed"===e.message)throw e;const t=this._manager.contents.localPath(this._path),i=n.PathExt.basename(t);return this._handleError(e,this._trans.__("File Save Error for %1",i)),void this._saveState.emit("failed")}}_createSaveOptions(){let e=null;return"json"===this._factory.fileFormat?e=this._model.toJSON():(e=this._model.toString(),this._lineEnding&&(e=e.replace(/\n/g,this._lineEnding))),{type:this._factory.contentType,format:this._factory.fileFormat,content:e}}}!function(e){e.getSavePath=function(e,i){const s=(i=i||r.nullTranslator).load("jupyterlab"),n=a.Dialog.okButton({label:s.__("Save"),accept:!0});return(0,a.showDialog)({title:s.__("Save File As…"),body:new t(e),buttons:[a.Dialog.cancelButton(),n]}).then((e=>{var t;if(e.button.accept)return null!==(t=e.value)&&void 0!==t?t:void 0}))},e.noOp=function(){};class t extends c.Widget{constructor(e){super({node:i(e)})}getValue(){return this.node.value}}function i(e){const t=document.createElement("input");return t.value=e,t}}(s||(s={}));var m=i(983),u=i(78156);function p(e,t){var i;let s=(null!=t?t:r.nullTranslator).load("jupyterlab");return a.ReactWidget.create(u.createElement("div",null,u.createElement("span",{className:"jp-ToolbarLabelComponent",title:s.__('Document is read-only. "Save" is disabled; use "Save as…" instead')},s.__("%1 is read-only",null===(i=e.context.contentsModel)||void 0===i?void 0:i.type))))}class g extends m.CodeEditor.Model{constructor(e={}){var t;super({sharedModel:e.sharedModel}),this._defaultLang="",this._dirty=!1,this._readOnly=!1,this._contentChanged=new d.Signal(this),this._stateChanged=new d.Signal(this),this._defaultLang=null!==(t=e.languagePreference)&&void 0!==t?t:"",this._collaborationEnabled=!!e.collaborationEnabled,this.sharedModel.changed.connect(this._onStateChanged,this)}get contentChanged(){return this._contentChanged}get stateChanged(){return this._stateChanged}get dirty(){return this._dirty}set dirty(e){const t=this._dirty;e!==t&&(this._dirty=e,this.triggerStateChange({name:"dirty",oldValue:t,newValue:e}))}get readOnly(){return this._readOnly}set readOnly(e){if(e===this._readOnly)return;const t=this._readOnly;this._readOnly=e,this.triggerStateChange({name:"readOnly",oldValue:t,newValue:e})}get defaultKernelName(){return""}get defaultKernelLanguage(){return this._defaultLang}get collaborative(){return this._collaborationEnabled}toString(){return this.sharedModel.getSource()}fromString(e){this.sharedModel.setSource(e)}toJSON(){return JSON.parse(this.sharedModel.getSource()||"null")}fromJSON(e){this.fromString(JSON.stringify(e))}initialize(){}triggerStateChange(e){this._stateChanged.emit(e)}triggerContentChange(){this._contentChanged.emit(void 0),this.dirty=!0}_onStateChanged(e,t){t.sourceChange&&this.triggerContentChange(),t.stateChange&&t.stateChange.forEach((e=>{"dirty"===e.name?this.dirty=e.newValue:e.oldValue!==e.newValue&&this.triggerStateChange({newValue:void 0,oldValue:void 0,...e})}))}}class y{constructor(e){this._isDisposed=!1,this._collaborative=null==e||e}get name(){return"text"}get contentType(){return"file"}get fileFormat(){return"text"}get collaborative(){return this._collaborative}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed=!0}createNew(e={}){const t=e.collaborationEnabled&&this.collaborative;return new g({...e,collaborationEnabled:t})}preferredLanguage(e){return""}}class f extends y{get name(){return"base64"}get contentType(){return"file"}get fileFormat(){return"base64"}}class F{constructor(e){this._isDisposed=!1,this._widgetCreated=new d.Signal(this),this._translator=e.translator||r.nullTranslator,this._name=e.name,this._label=e.label||e.name,this._readOnly=void 0!==e.readOnly&&e.readOnly,this._defaultFor=e.defaultFor?e.defaultFor.slice():[],this._defaultRendered=(e.defaultRendered||[]).slice(),this._fileTypes=e.fileTypes.slice(),this._modelName=e.modelName||"text",this._preferKernel=!!e.preferKernel,this._canStartKernel=!!e.canStartKernel,this._shutdownOnClose=!!e.shutdownOnClose,this._autoStartDefault=!!e.autoStartDefault,this._toolbarFactory=e.toolbarFactory}get widgetCreated(){return this._widgetCreated}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,d.Signal.clearData(this))}get readOnly(){return this._readOnly}get name(){return this._name}get label(){return this._label}get fileTypes(){return this._fileTypes.slice()}get modelName(){return this._modelName}get defaultFor(){return this._defaultFor.slice()}get defaultRendered(){return this._defaultRendered.slice()}get preferKernel(){return this._preferKernel}get canStartKernel(){return this._canStartKernel}get translator(){return this._translator}get shutdownOnClose(){return this._shutdownOnClose}set shutdownOnClose(e){this._shutdownOnClose=e}get autoStartDefault(){return this._autoStartDefault}set autoStartDefault(e){this._autoStartDefault=e}createNew(e,t){var i;const s=this.createNewWidget(e,t);return(0,a.setToolbar)(s,null!==(i=this._toolbarFactory)&&void 0!==i?i:this.defaultToolbarFactory.bind(this)),this._widgetCreated.emit(s),s}defaultToolbarFactory(e){return[]}}const v="jp-mod-dirty";class w extends a.MainAreaWidget{constructor(e){var t;e.reveal=Promise.all([e.reveal,e.context.ready]),super(e),this._trans=(null!==(t=e.translator)&&void 0!==t?t:r.nullTranslator).load("jupyterlab"),this.context=e.context,this.context.pathChanged.connect(this._onPathChanged,this),this._onPathChanged(this.context,this.context.path),this.context.model.stateChanged.connect(this._onModelStateChanged,this),this.context.ready.then((()=>{this._handleDirtyState()})),this.title.changed.connect(this._onTitleChanged,this)}setFragment(e){}async _onTitleChanged(e){const t=this.title.label,i=this.context.localPath.split("/").pop()||this.context.localPath;if(t!==i){if(t.length>0&&!/[\/\\:]/.test(t)){const e=this.context.path;if(await this.context.rename(t),this.context.path!==e)return}this.title.label=i}}_onPathChanged(e,t){this.title.label=n.PathExt.basename(e.localPath),this.isUntitled=!1}_onModelStateChanged(e,t){var i;if("dirty"===t.name&&this._handleDirtyState(),!this.context.model.dirty&&!this.context.model.collaborative&&!(null===(i=this.context.contentsModel)||void 0===i?void 0:i.writable)){const e=p(this);this.toolbar.insertBefore("kernelName","read-only-indicator",e)||this.toolbar.addItem("read-only-indicator",e)}}_handleDirtyState(){this.context.model.dirty&&!this.title.className.includes(v)?this.title.className+=` ${v}`:this.title.className=this.title.className.replace(v,"")}}var x,T=i(62633);class b extends c.Widget{constructor(e){super(),this._changeCallback=e=>{if(!e.data||!e.data[this.mimeType])return;const t=e.data[this.mimeType];"string"==typeof t?t!==this._context.model.toString()&&this._context.model.fromString(t):null==t||l.JSONExt.deepEqual(t,this._context.model.toJSON())||this._context.model.fromJSON(t)},this._fragment="",this._ready=new l.PromiseDelegate,this._isRendering=!1,this._renderRequested=!1,this.addClass("jp-MimeDocument"),this.translator=e.translator||r.nullTranslator,this._trans=this.translator.load("jupyterlab"),this.mimeType=e.mimeType,this._dataType=e.dataType||"string",this._context=e.context,this.renderer=e.renderer,(this.layout=new c.StackedLayout).addWidget(this.renderer),this._context.ready.then((()=>this._render())).then((()=>{this.node===document.activeElement&&T.MessageLoop.sendMessage(this.renderer,c.Widget.Msg.ActivateRequest),this._monitor=new n.ActivityMonitor({signal:this._context.model.contentChanged,timeout:e.renderTimeout}),this._monitor.activityStopped.connect(this.update,this),this._ready.resolve(void 0)})).catch((e=>{requestAnimationFrame((()=>{this.dispose()})),(0,a.showErrorMessage)(this._trans.__("Renderer Failure: %1",this._context.path),e)}))}[a.Printing.symbol](){return a.Printing.getPrintFunction(this.renderer)}get ready(){return this._ready.promise}setFragment(e){this._fragment=e,this.update()}dispose(){this.isDisposed||(this._monitor&&this._monitor.dispose(),this._monitor=null,super.dispose())}onUpdateRequest(e){this._context.isReady&&(this._render(),this._fragment="")}async _render(){if(this.isDisposed)return;if(this._isRendering)return void(this._renderRequested=!0);this._renderRequested=!1;const e=this._context,t=e.model,i={};"string"===this._dataType?i[this.mimeType]=t.toString():i[this.mimeType]=t.toJSON();const s=new o.MimeModel({data:i,callback:this._changeCallback,metadata:{fragment:this._fragment}});try{if(this._isRendering=!0,await this.renderer.renderModel(s),this._isRendering=!1,this._renderRequested)return this._render()}catch(t){requestAnimationFrame((()=>{this.dispose()})),(0,a.showErrorMessage)(this._trans.__("Renderer Failure: %1",e.path),t)}}}class C extends w{setFragment(e){this.content.setFragment(e)}}class D extends F{constructor(e){super(x.createRegistryOptions(e)),this._rendermime=e.rendermime,this._renderTimeout=e.renderTimeout||1e3,this._dataType=e.dataType||"string",this._fileType=e.primaryFileType,this._factory=e.factory}createNewWidget(e){var t,i;const s=this._fileType,a=(null==s?void 0:s.mimeTypes.length)?s.mimeTypes[0]:m.IEditorMimeTypeService.defaultMimeType,n=this._rendermime.clone({resolver:e.urlResolver});let o;o=this._factory&&this._factory.mimeTypes.includes(a)?this._factory.createRenderer({mimeType:a,resolver:n.resolver,sanitizer:n.sanitizer,linkHandler:n.linkHandler,latexTypesetter:n.latexTypesetter,markdownParser:n.markdownParser}):n.createRenderer(a);const r=new b({context:e,renderer:o,mimeType:a,renderTimeout:this._renderTimeout,dataType:this._dataType});return r.title.icon=null==s?void 0:s.icon,r.title.iconClass=null!==(t=null==s?void 0:s.iconClass)&&void 0!==t?t:"",r.title.iconLabel=null!==(i=null==s?void 0:s.iconLabel)&&void 0!==i?i:"",new C({content:r,context:e})}}!function(e){e.createRegistryOptions=function(e){return{...e,readOnly:!0}}}(x||(x={}));var S,M=i(76878),O=i(14931);class E{constructor(e={}){this._modelFactories=Object.create(null),this._widgetFactories=Object.create(null),this._defaultWidgetFactory="",this._defaultWidgetFactoryOverrides=Object.create(null),this._defaultWidgetFactories=Object.create(null),this._defaultRenderedWidgetFactories=Object.create(null),this._widgetFactoriesForFileType=Object.create(null),this._fileTypes=[],this._extenders=Object.create(null),this._changed=new d.Signal(this),this._isDisposed=!1;const t=e.textModelFactory;if(this.translator=e.translator||r.nullTranslator,t&&"text"!==t.name)throw new Error("Text model factory must have the name `text`");this._modelFactories.text=t||new y(!0),(e.initialFileTypes||E.getDefaultFileTypes(this.translator)).forEach((e=>{const t={...E.getFileTypeDefaults(this.translator),...e};this._fileTypes.push(t)}))}get changed(){return this._changed}get isDisposed(){return this._isDisposed}dispose(){if(!this.isDisposed){this._isDisposed=!0;for(const e in this._modelFactories)this._modelFactories[e].dispose();for(const e in this._widgetFactories)this._widgetFactories[e].dispose();for(const e in this._extenders)this._extenders[e].length=0;this._fileTypes.length=0,d.Signal.clearData(this)}}addWidgetFactory(e){const t=e.name.toLowerCase();if(!t||"default"===t)throw Error("Invalid factory name");if(this._widgetFactories[t])return console.warn(`Duplicate registered factory ${t}`),new h.DisposableDelegate(S.noOp);this._widgetFactories[t]=e;for(const i of e.defaultFor||[])-1!==e.fileTypes.indexOf(i)&&("*"===i?this._defaultWidgetFactory=t:this._defaultWidgetFactories[i]=t);for(const i of e.defaultRendered||[])-1!==e.fileTypes.indexOf(i)&&(this._defaultRenderedWidgetFactories[i]=t);for(const i of e.fileTypes)this._widgetFactoriesForFileType[i]||(this._widgetFactoriesForFileType[i]=[]),this._widgetFactoriesForFileType[i].push(t);return this._changed.emit({type:"widgetFactory",name:t,change:"added"}),new h.DisposableDelegate((()=>{delete this._widgetFactories[t],this._defaultWidgetFactory===t&&(this._defaultWidgetFactory="");for(const e of Object.keys(this._defaultWidgetFactories))this._defaultWidgetFactories[e]===t&&delete this._defaultWidgetFactories[e];for(const e of Object.keys(this._defaultRenderedWidgetFactories))this._defaultRenderedWidgetFactories[e]===t&&delete this._defaultRenderedWidgetFactories[e];for(const e of Object.keys(this._widgetFactoriesForFileType))O.ArrayExt.removeFirstOf(this._widgetFactoriesForFileType[e],t),0===this._widgetFactoriesForFileType[e].length&&delete this._widgetFactoriesForFileType[e];for(const e of Object.keys(this._defaultWidgetFactoryOverrides))this._defaultWidgetFactoryOverrides[e]===t&&delete this._defaultWidgetFactoryOverrides[e];this._changed.emit({type:"widgetFactory",name:t,change:"removed"})}))}addModelFactory(e){const t=e.name.toLowerCase();return this._modelFactories[t]?(console.warn(`Duplicate registered factory ${t}`),new h.DisposableDelegate(S.noOp)):(this._modelFactories[t]=e,this._changed.emit({type:"modelFactory",name:t,change:"added"}),new h.DisposableDelegate((()=>{delete this._modelFactories[t],this._changed.emit({type:"modelFactory",name:t,change:"removed"})})))}addWidgetExtension(e,t){(e=e.toLowerCase())in this._extenders||(this._extenders[e]=[]);const i=this._extenders[e];return-1!==O.ArrayExt.firstIndexOf(i,t)?(console.warn(`Duplicate registered extension for ${e}`),new h.DisposableDelegate(S.noOp)):(this._extenders[e].push(t),this._changed.emit({type:"widgetExtension",name:e,change:"added"}),new h.DisposableDelegate((()=>{O.ArrayExt.removeFirstOf(this._extenders[e],t),this._changed.emit({type:"widgetExtension",name:e,change:"removed"})})))}addFileType(e,t){const i={...E.getFileTypeDefaults(this.translator),...e,...!(e.icon||e.iconClass)&&{icon:M.fileIcon}};if(this._fileTypes.push(i),t){const e=i.name.toLowerCase();t.map((e=>e.toLowerCase())).forEach((t=>{this._widgetFactoriesForFileType[e]||(this._widgetFactoriesForFileType[e]=[]),this._widgetFactoriesForFileType[e].includes(t)||this._widgetFactoriesForFileType[e].push(t)})),this._defaultWidgetFactories[e]||(this._defaultWidgetFactories[e]=this._widgetFactoriesForFileType[e][0])}return this._changed.emit({type:"fileType",name:i.name,change:"added"}),new h.DisposableDelegate((()=>{if(O.ArrayExt.removeFirstOf(this._fileTypes,i),t){const e=i.name.toLowerCase();for(const i of t.map((e=>e.toLowerCase())))O.ArrayExt.removeFirstOf(this._widgetFactoriesForFileType[e],i);this._defaultWidgetFactories[e]===t[0].toLowerCase()&&delete this._defaultWidgetFactories[e]}this._changed.emit({type:"fileType",name:e.name,change:"removed"})}))}preferredWidgetFactories(e){const t=new Set,i=this.getFileTypesForPath(n.PathExt.basename(e));i.forEach((e=>{e.name in this._defaultWidgetFactoryOverrides&&t.add(this._defaultWidgetFactoryOverrides[e.name])})),i.forEach((e=>{e.name in this._defaultWidgetFactories&&t.add(this._defaultWidgetFactories[e.name])})),i.forEach((e=>{e.name in this._defaultRenderedWidgetFactories&&t.add(this._defaultRenderedWidgetFactories[e.name])})),this._defaultWidgetFactory&&t.add(this._defaultWidgetFactory);for(const e of i)if(e.name in this._widgetFactoriesForFileType)for(const i of this._widgetFactoriesForFileType[e.name])t.add(i);if("*"in this._widgetFactoriesForFileType)for(const e of this._widgetFactoriesForFileType["*"])t.add(e);const s=[];for(const e of t){const t=this._widgetFactories[e];t&&((t.modelName||"text")in this._modelFactories&&s.push(t))}return s}defaultRenderedWidgetFactory(e){const t=this.getFileTypesForPath(n.PathExt.basename(e)).map((e=>e.name));for(const e in t)if(e in this._defaultWidgetFactoryOverrides)return this._widgetFactories[this._defaultWidgetFactoryOverrides[e]];for(const e in t)if(e in this._defaultRenderedWidgetFactories)return this._widgetFactories[this._defaultRenderedWidgetFactories[e]];return this.defaultWidgetFactory(e)}defaultWidgetFactory(e){return e?this.preferredWidgetFactories(e)[0]:this._widgetFactories[this._defaultWidgetFactory]}setDefaultWidgetFactory(e,t){if(e=e.toLowerCase(),!this.getFileType(e))throw Error(`Cannot find file type ${e}`);if(!t)return void(this._defaultWidgetFactoryOverrides[e]&&delete this._defaultWidgetFactoryOverrides[e]);if(!this.getWidgetFactory(t))throw Error(`Cannot find widget factory ${t}`);t=t.toLowerCase();const i=this._widgetFactoriesForFileType[e];if(!(t===this._defaultWidgetFactory||i&&i.includes(t)))throw Error(`Factory ${t} cannot view file type ${e}`);this._defaultWidgetFactoryOverrides[e]=t}*widgetFactories(){for(const e in this._widgetFactories)yield this._widgetFactories[e]}*modelFactories(){for(const e in this._modelFactories)yield this._modelFactories[e]}*widgetExtensions(e){if((e=e.toLowerCase())in this._extenders)for(const t of this._extenders[e])yield t}*fileTypes(){for(const e of this._fileTypes)yield e}getWidgetFactory(e){return this._widgetFactories[e.toLowerCase()]}getModelFactory(e){return this._modelFactories[e.toLowerCase()]}getFileType(e){return e=e.toLowerCase(),(0,O.find)(this._fileTypes,(t=>t.name.toLowerCase()===e))}getKernelPreference(e,t,i){t=t.toLowerCase();const s=this._widgetFactories[t];if(!s)return;const a=this.getModelFactory(s.modelName||"text");if(!a)return;const o=a.preferredLanguage(n.PathExt.basename(e)),r=i&&i.name;return{id:i&&i.id,name:r,language:o,shouldStart:s.preferKernel,canStart:s.canStartKernel,shutdownOnDispose:s.shutdownOnClose,autoStartDefault:s.autoStartDefault}}getFileTypeForModel(e){let t=null;if(e.name||e.path){const i=e.name||n.PathExt.basename(e.path),s=this.getFileTypesForPath(i);s.length>0&&(t=s[0])}switch(e.type){case"directory":return null!==t&&"directory"===t.contentType?t:(0,O.find)(this._fileTypes,(e=>"directory"===e.contentType))||E.getDefaultDirectoryFileType(this.translator);case"notebook":return null!==t&&"notebook"===t.contentType?t:(0,O.find)(this._fileTypes,(e=>"notebook"===e.contentType))||E.getDefaultNotebookFileType(this.translator);default:return null!==t?t:this.getFileType("text")||E.getDefaultTextFileType(this.translator)}}getFileTypesForPath(e){const t=[],i=n.PathExt.basename(e);let s=(0,O.find)(this._fileTypes,(e=>!(!e.pattern||null===i.match(e.pattern))));s&&t.push(s);let a=S.extname(i);for(;a.length>1;){const e=this._fileTypes.filter((e=>e.extensions.map((e=>e.toLowerCase())).includes(a)));t.push(...e),a="."+a.split(".").slice(2).join(".")}return t}}!function(e){function t(e){return{name:"default",displayName:(null==(e=e||r.nullTranslator)?void 0:e.load("jupyterlab")).__("default"),extensions:[],mimeTypes:[],contentType:"file",fileFormat:"text"}}function i(e){const i=null==(e=e||r.nullTranslator)?void 0:e.load("jupyterlab");return{...t(e),name:"text",displayName:i.__("Text"),mimeTypes:["text/plain"],extensions:[".txt"],icon:M.fileIcon}}function s(e){const i=null==(e=e||r.nullTranslator)?void 0:e.load("jupyterlab");return{...t(e),name:"notebook",displayName:i.__("Notebook"),mimeTypes:["application/x-ipynb+json"],extensions:[".ipynb"],contentType:"notebook",fileFormat:"json",icon:M.notebookIcon}}function a(e){const i=null==(e=e||r.nullTranslator)?void 0:e.load("jupyterlab");return{...t(e),name:"directory",displayName:i.__("Directory"),extensions:[],mimeTypes:["text/directory"],contentType:"directory",icon:M.folderIcon}}e.getFileTypeDefaults=t,e.getDefaultTextFileType=i,e.getDefaultNotebookFileType=s,e.getDefaultDirectoryFileType=a,e.getDefaultFileTypes=function(e){const t=null==(e=e||r.nullTranslator)?void 0:e.load("jupyterlab");return[i(e),s(e),a(e),{name:"markdown",displayName:t.__("Markdown File"),extensions:[".md"],mimeTypes:["text/markdown"],icon:M.markdownIcon},{name:"PDF",displayName:t.__("PDF File"),extensions:[".pdf"],mimeTypes:["application/pdf"],icon:M.pdfIcon},{name:"python",displayName:t.__("Python File"),extensions:[".py"],mimeTypes:["text/x-python"],icon:M.pythonIcon},{name:"json",displayName:t.__("JSON File"),extensions:[".json"],mimeTypes:["application/json"],icon:M.jsonIcon},{name:"jsonl",displayName:t.__("JSONLines File"),extensions:[".jsonl",".ndjson"],mimeTypes:["text/jsonl","application/jsonl","application/json-lines"],icon:M.jsonIcon},{name:"julia",displayName:t.__("Julia File"),extensions:[".jl"],mimeTypes:["text/x-julia"],icon:M.juliaIcon},{name:"csv",displayName:t.__("CSV File"),extensions:[".csv"],mimeTypes:["text/csv"],icon:M.spreadsheetIcon},{name:"tsv",displayName:t.__("TSV File"),extensions:[".tsv"],mimeTypes:["text/csv"],icon:M.spreadsheetIcon},{name:"r",displayName:t.__("R File"),mimeTypes:["text/x-rsrc"],extensions:[".R"],icon:M.rKernelIcon},{name:"yaml",displayName:t.__("YAML File"),mimeTypes:["text/x-yaml","text/yaml"],extensions:[".yaml",".yml"],icon:M.yamlIcon},{name:"svg",displayName:t.__("Image"),mimeTypes:["image/svg+xml"],extensions:[".svg"],icon:M.imageIcon,fileFormat:"base64"},{name:"tiff",displayName:t.__("Image"),mimeTypes:["image/tiff"],extensions:[".tif",".tiff"],icon:M.imageIcon,fileFormat:"base64"},{name:"jpeg",displayName:t.__("Image"),mimeTypes:["image/jpeg"],extensions:[".jpg",".jpeg"],icon:M.imageIcon,fileFormat:"base64"},{name:"gif",displayName:t.__("Image"),mimeTypes:["image/gif"],extensions:[".gif"],icon:M.imageIcon,fileFormat:"base64"},{name:"png",displayName:t.__("Image"),mimeTypes:["image/png"],extensions:[".png"],icon:M.imageIcon,fileFormat:"base64"},{name:"bmp",displayName:t.__("Image"),mimeTypes:["image/bmp"],extensions:[".bmp"],icon:M.imageIcon,fileFormat:"base64"},{name:"webp",displayName:t.__("Image"),mimeTypes:["image/webp"],extensions:[".webp"],icon:M.imageIcon,fileFormat:"base64"}]}}(E||(E={})),function(e){e.extname=function(e){const t=n.PathExt.basename(e).split(".");return t.shift(),("."+t.join(".")).toLowerCase()},e.noOp=function(){}}(S||(S={}))}}]);
|
notebook/static/2607.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[2607,2007],{12007:(e,n,s)=>{s.r(n),s.d(n,{EditMenu:()=>d,FileMenu:()=>m,HelpMenu:()=>o,IMainMenu:()=>k,KernelMenu:()=>c,MainMenu:()=>p,RunMenu:()=>l,SettingsMenu:()=>M,TabsMenu:()=>h,ViewMenu:()=>_});var t,r=s(
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[2607,2007],{12007:(e,n,s)=>{s.r(n),s.d(n,{EditMenu:()=>d,FileMenu:()=>m,HelpMenu:()=>o,IMainMenu:()=>k,KernelMenu:()=>c,MainMenu:()=>p,RunMenu:()=>l,SettingsMenu:()=>M,TabsMenu:()=>h,ViewMenu:()=>_});var t,r=s(76878),i=s(14931),a=s(2260),u=s(53876);class d extends r.RankedMenu{constructor(e){super(e),this.undoers={redo:new u.SemanticCommand,undo:new u.SemanticCommand},this.clearers={clearAll:new u.SemanticCommand,clearCurrent:new u.SemanticCommand},this.goToLiners=new u.SemanticCommand}}class m extends r.RankedMenu{constructor(e){super(e),this.quitEntry=!1,this.closeAndCleaners=new u.SemanticCommand,this.consoleCreators=new u.SemanticCommand}get newMenu(){var e,n;return this._newMenu||(this._newMenu=null!==(n=null===(e=(0,i.find)(this.items,(e=>{var n;return"jp-mainmenu-file-new"===(null===(n=e.submenu)||void 0===n?void 0:n.id)})))||void 0===e?void 0:e.submenu)&&void 0!==n?n:new r.RankedMenu({commands:this.commands})),this._newMenu}dispose(){var e;null===(e=this._newMenu)||void 0===e||e.dispose(),super.dispose()}}class o extends r.RankedMenu{constructor(e){super(e),this.getKernel=new u.SemanticCommand}}class c extends r.RankedMenu{constructor(e){super(e),this.kernelUsers={changeKernel:new u.SemanticCommand,clearWidget:new u.SemanticCommand,interruptKernel:new u.SemanticCommand,reconnectToKernel:new u.SemanticCommand,restartKernel:new u.SemanticCommand,shutdownKernel:new u.SemanticCommand}}}class l extends r.RankedMenu{constructor(e){super(e),this.codeRunners={restart:new u.SemanticCommand,run:new u.SemanticCommand,runAll:new u.SemanticCommand}}}class M extends r.RankedMenu{constructor(e){super(e)}}class h extends r.RankedMenu{constructor(e){super(e)}}class _ extends r.RankedMenu{constructor(e){super(e),this.editorViewers={toggleLineNumbers:new u.SemanticCommand,toggleMatchBrackets:new u.SemanticCommand,toggleWordWrap:new u.SemanticCommand}}}class p extends a.MenuBar{constructor(e){super({forceItemsPosition:{forceX:!1,forceY:!0}}),this._items=[],this._commands=e}get editMenu(){return this._editMenu||(this._editMenu=new d({commands:this._commands,rank:2,renderer:r.MenuSvg.defaultRenderer})),this._editMenu}get fileMenu(){return this._fileMenu||(this._fileMenu=new m({commands:this._commands,rank:1,renderer:r.MenuSvg.defaultRenderer})),this._fileMenu}get helpMenu(){return this._helpMenu||(this._helpMenu=new o({commands:this._commands,rank:1e3,renderer:r.MenuSvg.defaultRenderer})),this._helpMenu}get kernelMenu(){return this._kernelMenu||(this._kernelMenu=new c({commands:this._commands,rank:5,renderer:r.MenuSvg.defaultRenderer})),this._kernelMenu}get runMenu(){return this._runMenu||(this._runMenu=new l({commands:this._commands,rank:4,renderer:r.MenuSvg.defaultRenderer})),this._runMenu}get settingsMenu(){return this._settingsMenu||(this._settingsMenu=new M({commands:this._commands,rank:999,renderer:r.MenuSvg.defaultRenderer})),this._settingsMenu}get viewMenu(){return this._viewMenu||(this._viewMenu=new _({commands:this._commands,rank:3,renderer:r.MenuSvg.defaultRenderer})),this._viewMenu}get tabsMenu(){return this._tabsMenu||(this._tabsMenu=new h({commands:this._commands,rank:500,renderer:r.MenuSvg.defaultRenderer})),this._tabsMenu}addMenu(e,n=!0,s={}){if(i.ArrayExt.firstIndexOf(this.menus,e)>-1)return;r.MenuSvg.overrideDefaultRenderer(e);const a={menu:e,rank:"rank"in s?s.rank:"rank"in e?e.rank:r.IRankedMenu.DEFAULT_RANK},u=i.ArrayExt.upperBound(this._items,a,t.itemCmp);switch(e.disposed.connect(this._onMenuDisposed,this),i.ArrayExt.insert(this._items,u,a),this.insertMenu(u,e),e.id){case"jp-mainmenu-file":!this._fileMenu&&e instanceof m&&(this._fileMenu=e);break;case"jp-mainmenu-edit":!this._editMenu&&e instanceof d&&(this._editMenu=e);break;case"jp-mainmenu-view":!this._viewMenu&&e instanceof _&&(this._viewMenu=e);break;case"jp-mainmenu-run":!this._runMenu&&e instanceof l&&(this._runMenu=e);break;case"jp-mainmenu-kernel":!this._kernelMenu&&e instanceof c&&(this._kernelMenu=e);break;case"jp-mainmenu-tabs":!this._tabsMenu&&e instanceof h&&(this._tabsMenu=e);break;case"jp-mainmenu-settings":!this._settingsMenu&&e instanceof M&&(this._settingsMenu=e);break;case"jp-mainmenu-help":!this._helpMenu&&e instanceof o&&(this._helpMenu=e)}}dispose(){var e,n,s,t,r,i,a,u;null===(e=this._editMenu)||void 0===e||e.dispose(),null===(n=this._fileMenu)||void 0===n||n.dispose(),null===(s=this._helpMenu)||void 0===s||s.dispose(),null===(t=this._kernelMenu)||void 0===t||t.dispose(),null===(r=this._runMenu)||void 0===r||r.dispose(),null===(i=this._settingsMenu)||void 0===i||i.dispose(),null===(a=this._viewMenu)||void 0===a||a.dispose(),null===(u=this._tabsMenu)||void 0===u||u.dispose(),super.dispose()}static generateMenu(e,n,s){let t;const{id:i,label:a,rank:u}=n;switch(i){case"jp-mainmenu-file":t=new m({commands:e,rank:u,renderer:r.MenuSvg.defaultRenderer});break;case"jp-mainmenu-edit":t=new d({commands:e,rank:u,renderer:r.MenuSvg.defaultRenderer});break;case"jp-mainmenu-view":t=new _({commands:e,rank:u,renderer:r.MenuSvg.defaultRenderer});break;case"jp-mainmenu-run":t=new l({commands:e,rank:u,renderer:r.MenuSvg.defaultRenderer});break;case"jp-mainmenu-kernel":t=new c({commands:e,rank:u,renderer:r.MenuSvg.defaultRenderer});break;case"jp-mainmenu-tabs":t=new h({commands:e,rank:u,renderer:r.MenuSvg.defaultRenderer});break;case"jp-mainmenu-settings":t=new M({commands:e,rank:u,renderer:r.MenuSvg.defaultRenderer});break;case"jp-mainmenu-help":t=new o({commands:e,rank:u,renderer:r.MenuSvg.defaultRenderer});break;default:t=new r.RankedMenu({commands:e,rank:u,renderer:r.MenuSvg.defaultRenderer})}return a&&(t.title.label=s._p("menu",a)),t}_onMenuDisposed(e){this.removeMenu(e);const n=i.ArrayExt.findFirstIndex(this._items,(n=>n.menu===e));-1!==n&&i.ArrayExt.removeAt(this._items,n)}}!function(e){e.itemCmp=function(e,n){return e.rank-n.rank}}(t||(t={}));const k=new(s(21961).Token)("@jupyterlab/mainmenu:IMainMenu","A service for the main menu bar for the application.\n Use this if you want to add your own menu items or provide implementations for standardized menu items for specific activities.")}}]);
|
notebook/static/2615.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[2615],{92615:(e,t,a)=>{a.r(t),a.d(t,{DETAILS_CLASS:()=>u,IMermaidManager:()=>h,IMermaidMarkdown:()=>M,MERMAID_CLASS:()=>l,MERMAID_CODE_CLASS:()=>c,MERMAID_DARK_THEME:()=>m,MERMAID_DEFAULT_THEME:()=>d,MERMAID_FILE_EXTENSIONS:()=>s,MERMAID_MIME_TYPE:()=>i,MermaidManager:()=>p,MermaidMarkdown:()=>_,RenderedMermaid:()=>w,SUMMARY_CLASS:()=>g,WARNING_CLASS:()=>o,rendererFactory:()=>T});var r=a(
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[2615],{92615:(e,t,a)=>{a.r(t),a.d(t,{DETAILS_CLASS:()=>u,IMermaidManager:()=>h,IMermaidMarkdown:()=>M,MERMAID_CLASS:()=>l,MERMAID_CODE_CLASS:()=>c,MERMAID_DARK_THEME:()=>m,MERMAID_DEFAULT_THEME:()=>d,MERMAID_FILE_EXTENSIONS:()=>s,MERMAID_MIME_TYPE:()=>i,MermaidManager:()=>p,MermaidMarkdown:()=>_,RenderedMermaid:()=>w,SUMMARY_CLASS:()=>g,WARNING_CLASS:()=>o,rendererFactory:()=>T});var r=a(21961),n=a(20754);const i="text/vnd.mermaid",s=[".mmd",".mermaid"],d="default",m="dark",l="jp-RenderedMermaid",c="mermaid",o="jp-mod-warning",u="jp-RenderedMermaid-Details",g="jp-RenderedMermaid-Summary",h=new r.Token("@jupyterlab/mermaid:IMermaidManager","a manager for rendering mermaid text-based diagrams"),M=new r.Token("@jupyterlab/mermaid:IMermaidMarkdown","a manager for rendering mermaid text-based diagrams in markdown fenced code blocks");class p{constructor(e={}){this._diagrams=new n.LruCache({maxSize:e.maxCacheSize||null}),e.themes&&(E.initThemes(e.themes||null),e.themes.themeChanged.connect(this.initialize,this))}static cleanMermaidSvg(e){return e.replace(E.RE_VOID_ELEMENT,E.replaceVoidElement)}initialize(){this._diagrams.clear(),E.initMermaid()}async getMermaid(){return await E.ensureMermaid()}getMermaidVersion(){return E.version()}getCachedFigure(e){return this._diagrams.get(e)}async renderSvg(e){const t=await this.getMermaid(),a=`jp-mermaid-${E.nextMermaidId()}`,r=document.createElement("div");document.body.appendChild(r);try{let{svg:n}=await t.render(a,e,r);n=p.cleanMermaidSvg(n);const i=(new DOMParser).parseFromString(n,"image/svg+xml"),s={text:e,svg:n},d=i.querySelector("svg"),{maxWidth:m}=(null==d?void 0:d.style)||{};s.width=m?parseFloat(m):null;const l=i.querySelector("title"),c=i.querySelector("desc");return l&&(s.accessibleTitle=l.textContent),c&&(s.accessibleDescription=c.textContent),s}finally{r.remove()}}async renderFigure(e){let t=this._diagrams.get(e);if(null!=t)return t;let a=l,r=null;t=document.createElement("div"),t.className=a;try{const t=await this.renderSvg(e);r=this.makeMermaidFigure(t)}catch(a){t.classList.add(o),r=await this.makeMermaidError(e)}let n=this.getMermaidVersion();return n&&(r.dataset.jpMermaidVersion=n),t.appendChild(r),this._diagrams.set(e,t),t}makeMermaidCode(e){const t=document.createElement("pre"),a=document.createElement("code");return a.innerText=e,t.appendChild(a),a.className=c,a.textContent=e,t}async makeMermaidError(e){const t=await this.getMermaid();let a="";try{await t.parse(e)}catch(e){a=`${e}`}const r=document.createElement("details");r.className=u;const n=document.createElement("summary");n.className=g,n.appendChild(this.makeMermaidCode(e)),r.appendChild(n);const i=document.createElement("pre");return i.innerText=a,r.appendChild(i),r}makeMermaidFigure(e){const t=document.createElement("figure"),a=document.createElement("img");if(t.appendChild(a),a.setAttribute("src",`data:image/svg+xml,${encodeURIComponent(e.svg)}`),e.width&&(a.width=e.width),e.accessibleTitle&&a.setAttribute("alt",e.accessibleTitle),t.appendChild(this.makeMermaidCode(e.text)),e.accessibleDescription){const a=document.createElement("figcaption");a.className="sr-only",a.textContent=e.accessibleDescription,t.appendChild(a)}return t}}var E;!function(e){let t=null,n=null,i=null,s=0,l=null;function c(){if(!n)return!1;let e=d;if(t){const a=t.theme;e=a&&t.isLight(a)?d:m}const a=window.getComputedStyle(document.body).getPropertyValue("--jp-ui-font-family");return n.mermaidAPI.globalReset(),n.mermaidAPI.initialize({theme:e,fontFamily:a,securityLevel:"strict",maxTextSize:1e5,maxEdges:1e5,startOnLoad:!1}),!0}e.initThemes=function(e){t=e},e.version=function(){return l},e.initMermaid=c,e.getMermaid=function(){return n},e.nextMermaidId=function(){return s++},e.ensureMermaid=async function(){return null!=n?n:i?i.promise:(i=new r.PromiseDelegate,l=(await a.e(1169).then(a.t.bind(a,21169,19))).version,n=(await Promise.all([a.e(4499),a.e(4630)]).then(a.bind(a,84630))).default,c(),i.resolve(n),n)},e.RE_VOID_ELEMENT=/<\s*(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)\s*([^>]*?)\s*>/gi,e.replaceVoidElement=function(e,t,a){return(a=a.trim()).endsWith("/")||(a=`${a} /`),`<${t} ${a}>`}}(E||(E={}));class _{constructor(e){this.languages=["mermaid"],this.rank=100,this._mermaid=e.mermaid}async walk(e){await this._mermaid.renderFigure(e)}render(e){let t=this._mermaid.getCachedFigure(e);return t?t.outerHTML:null}}var y=a(2260);const C="image/svg+xml";class w extends y.Widget{constructor(e){super(),this._lastRendered=null,this._mimeType=e.mimeType,this.addClass(l)}static set manager(e){w._manager?console.warn("Mermaid manager may only be set once, and is already set."):(w._manager=e,w._managerReady.resolve(e))}async renderModel(e){const t=await w._managerReady.promise,a=e.data[this._mimeType];if(null==a||a===this._lastRendered)return;this._lastRendered=a;const r=await t.renderFigure(a);if(r.classList.contains(o)?this.node.classList.add(o):this.node.classList.remove(o),!r.firstChild)return;this.node.innerHTML!==r.innerHTML&&(this.node.innerHTML=r.innerHTML);const n=t.getMermaidVersion(),s={...e.metadata[i]||{},version:n},d={...e.metadata,[i]:s},m=r.querySelector("img");if(m){const t=decodeURIComponent(m.src.split(",")[1]);t!==e.data[C]&&e.setData({data:{...e.data,[C]:t},metadata:d})}else{const t={...e.data};delete t[C],e.setData({data:t,metadata:d})}}}w._manager=null,w._managerReady=new r.PromiseDelegate;const T={safe:!0,mimeTypes:[i],createRenderer:e=>new w(e)}}}]);
|
notebook/static/2636.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[2636],{72636:(e,t,s)=>{s.r(t),s.d(t,{CodeConsole:()=>x,ConsoleHistory:()=>a,ConsolePanel:()=>b,ForeignHandler:()=>r,IConsoleCellExecutor:()=>S,IConsoleTracker:()=>k,runCell:()=>n});var o=s(688);async function n({cell:e,onCellExecuted:t,sessionContext:s}){return o.CodeCell.execute(e,s).then((s=>{if(s&&"ok"===s.content.status){const o=s.content;if(o.payload&&o.payload.length){const t=o.payload.filter((e=>"set_next_input"===e.source))[0];if(t){const s=t.text;e.model.sharedModel.setSource(s)}}return t({cell:e,executionDate:new Date,success:!0}),!0}if(s&&"error"===s.content.status){const o=s.content.ename,n=s.content.evalue;return t({cell:e,executionDate:new Date,success:!1,error:new Error(`KernelReplyNotOK: ${o} ${n}`)}),!1}return t({cell:e,executionDate:new Date,success:!1}),!1}),(s=>(t({cell:e,executionDate:new Date,success:!1,error:new Error(s)}),!1)))}var i,l=s(81997);class r{constructor(e){this._enabled=!1,this._isDisposed=!1,this.sessionContext=e.sessionContext,this.sessionContext.iopubMessage.connect(this.onIOPubMessage,this),this._parent=e.parent}get enabled(){return this._enabled}set enabled(e){this._enabled=e}get parent(){return this._parent}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,l.Signal.clearData(this))}onIOPubMessage(e,t){var s;if(!this._enabled)return!1;const o=null===(s=this.sessionContext.session)||void 0===s?void 0:s.kernel;if(!o)return!1;const n=this._parent;if(t.parent_header.session===o.clientId)return!1;const i=t.header.msg_type,l=t.parent_header.msg_id;let r;switch(i){case"execute_input":{const e=t;r=this._newCell(l);const s=r.model;return s.executionCount=e.content.execution_count,s.sharedModel.setSource(e.content.code),s.trusted=!0,n.update(),!0}case"execute_result":case"display_data":case"stream":case"error":{if(r=this._parent.getCell(l),!r)return!1;const e={...t.content,output_type:i};return r.model.outputs.add(e),n.update(),!0}case"clear_output":{const e=t.content.wait;return r=this._parent.getCell(l),r&&r.model.outputs.clear(e),!0}default:return!1}}_newCell(e){const t=this.parent.createCodeCell();return t.addClass("jp-CodeConsole-foreignCell"),this._parent.addCell(t,e),t}}class a{constructor(e){this._cursor=0,this._hasSession=!1,this._history=[],this._placeholder="",this._setByHistory=!1,this._isDisposed=!1,this._editor=null,this._filtered=[];const{sessionContext:t}=e;t&&(this.sessionContext=t,this._handleKernel(),this.sessionContext.kernelChanged.connect(this._handleKernel,this))}get editor(){return this._editor}set editor(e){if(this._editor===e)return;const t=this._editor;t&&(t.edgeRequested.disconnect(this.onEdgeRequest,this),t.model.sharedModel.changed.disconnect(this.onTextChange,this)),this._editor=e,e&&(e.edgeRequested.connect(this.onEdgeRequest,this),e.model.sharedModel.changed.connect(this.onTextChange,this))}get placeholder(){return this._placeholder}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed=!0,this._history.length=0,l.Signal.clearData(this)}back(e){this._hasSession||(this._hasSession=!0,this._placeholder=e,this.setFilter(e),this._cursor=this._filtered.length-1),--this._cursor,this._cursor=Math.max(0,this._cursor);const t=this._filtered[this._cursor];return Promise.resolve(t)}forward(e){this._hasSession||(this._hasSession=!0,this._placeholder=e,this.setFilter(e),this._cursor=this._filtered.length),++this._cursor,this._cursor=Math.min(this._filtered.length-1,this._cursor);const t=this._filtered[this._cursor];return Promise.resolve(t)}push(e){e&&e!==this._history[this._history.length-1]&&this._history.push(e),this.reset()}reset(){this._cursor=this._history.length,this._hasSession=!1,this._placeholder=""}onHistory(e){this._history.length=0;let t="",s="";if("ok"===e.content.status)for(let o=0;o<e.content.history.length;o++)s=e.content.history[o][2],s!==t&&this._history.push(t=s);this._cursor=this._history.length}onTextChange(){this._setByHistory?this._setByHistory=!1:this.reset()}onEdgeRequest(e,t){const s=e.model.sharedModel,o=s.getSource();"top"===t||"topLine"===t?this.back(o).then((t=>{if(this.isDisposed||!t)return;if(s.getSource()===t)return;this._setByHistory=!0,s.setSource(t);let o=0;o=t.indexOf("\n"),o<0&&(o=t.length),e.setCursorPosition({line:0,column:o})})):this.forward(o).then((t=>{if(this.isDisposed)return;const o=t||this.placeholder;if(s.getSource()===o)return;this._setByHistory=!0,s.setSource(o);const n=e.getPositionAt(o.length);n&&e.setCursorPosition(n)}))}async _handleKernel(){var e,t;const s=null===(t=null===(e=this.sessionContext)||void 0===e?void 0:e.session)||void 0===t?void 0:t.kernel;if(s)return s.requestHistory(i.initialRequest).then((e=>{this.onHistory(e)}));this._history.length=0}setFilter(e=""){this._filtered.length=0;let t="",s="";for(let o=0;o<this._history.length;o++)s=this._history[o],s!==t&&e===s.slice(0,e.length)&&this._filtered.push(t=s);this._filtered.push(e)}}!function(e){e.initialRequest={output:!1,raw:!0,hist_access_type:"tail",n:500}}(i||(i={}));var c=s(15465),h=s(44548),d=s(50102),u=s(25291),p=s(12668),_=s(20998),C=s(63485),m=s(57508),g=s(81417),y=s(99615);const f="jp-Console-cell",v="jp-CodeConsole-promptCell";class x extends C.Widget{constructor(e){var t,s,o;super(),this.editorConfig=x.defaultEditorConfig,this._banner=null,this._executed=new l.Signal(this),this._mimetype="text/x-ipython",this._msgIds=new Map,this._msgIdCells=new Map,this._promptCellCreated=new l.Signal(this),this._dragData=null,this._drag=null,this._focusedCell=null,this._translator=null!==(t=e.translator)&&void 0!==t?t:u.nullTranslator,this._executor=null!==(s=e.executor)&&void 0!==s?s:Object.freeze({runCell:n}),this.addClass("jp-CodeConsole"),this.node.dataset.jpKernelUser="true",this.node.dataset.jpCodeRunner="true",this.node.dataset.jpUndoer="true",this.node.tabIndex=-1;const i=this.layout=new C.PanelLayout;this._cells=new g.ObservableList,this._content=new C.Panel,this._input=new C.Panel,this.contentFactory=e.contentFactory,this.modelFactory=null!==(o=e.modelFactory)&&void 0!==o?o:x.defaultModelFactory,this.rendermime=e.rendermime,this.sessionContext=e.sessionContext,this._mimeTypeService=e.mimeTypeService,this._content.addClass("jp-CodeConsole-content"),this._input.addClass("jp-CodeConsole-input"),i.addWidget(this._content),i.addWidget(this._input),this._history=new a({sessionContext:this.sessionContext}),this._onKernelChanged(),this.sessionContext.kernelChanged.connect(this._onKernelChanged,this),this.sessionContext.statusChanged.connect(this._onKernelStatusChanged,this)}get executed(){return this._executed}get promptCellCreated(){return this._promptCellCreated}get cells(){return this._cells}get promptCell(){return this._input.layout.widgets[0]||null}addCell(e,t){e.addClass(f),this._content.addWidget(e),this._cells.push(e),t&&(this._msgIds.set(t,e),this._msgIdCells.set(e,t)),e.disposed.connect(this._onCellDisposed,this),this.update()}addBanner(){if(this._banner){const e=this._banner;this._cells.push(this._banner),e.disposed.connect(this._onCellDisposed,this)}const e=this.modelFactory.createRawCell({sharedModel:(0,m.createStandaloneCell)({cell_type:"raw",source:"..."})}),t=(this._banner=new o.RawCell({model:e,contentFactory:this.contentFactory,placeholder:!1,editorConfig:{autoClosingBrackets:!1,codeFolding:!1,highlightActiveLine:!1,highlightTrailingWhitespace:!1,highlightWhitespace:!1,indentUnit:"4",lineNumbers:!1,lineWrap:!0,matchBrackets:!1,readOnly:!0,rulers:[],scrollPastEnd:!1,smartIndent:!1,tabSize:4,theme:"jupyter"}})).initializeState();t.addClass("jp-CodeConsole-banner"),t.readOnly=!0,this._content.addWidget(t)}clear(){const e=this._cells;for(;e.length>0;)e.get(0).dispose()}createCodeCell(){const e=this.contentFactory,t=this._createCodeCellOptions(),s=e.createCodeCell(t);return s.readOnly=!0,s.model.mimeType=this._mimetype,s}dispose(){this.isDisposed||(this._msgIdCells=null,this._msgIds=null,this._history.dispose(),super.dispose())}async execute(e=!1,t=250){var s,o;if("dead"===(null===(o=null===(s=this.sessionContext.session)||void 0===s?void 0:s.kernel)||void 0===o?void 0:o.status))return;const n=this.promptCell;if(!n)throw new Error("Cannot execute without a prompt cell");if(n.model.trusted=!0,e)return this.newPromptCell(),void await this._execute(n);const i=await this._shouldExecute(t);this.isDisposed||(i?(this.newPromptCell(),this.promptCell.editor.focus(),await this._execute(n)):n.editor.newIndentedLine())}getCell(e){return this._msgIds.get(e)}inject(e,t={}){const s=this.createCodeCell();s.model.sharedModel.setSource(e);for(const e of Object.keys(t))s.model.setMetadata(e,t[e]);return this.addCell(s),this._execute(s)}insertLinebreak(){const e=this.promptCell;e&&e.editor.newIndentedLine()}replaceSelection(e){var t,s;const o=this.promptCell;o&&(null===(s=(t=o.editor).replaceSelection)||void 0===s||s.call(t,e))}serialize(){const e=[];for(const t of this._cells){const s=t.model;(0,o.isCodeCellModel)(s)&&e.push(s.toJSON())}return this.promptCell&&e.push(this.promptCell.model.toJSON()),e}_evtMouseDown(e){const{button:t,shiftKey:s}=e;if(0!==t&&2!==t||s&&2===t)return;let n=e.target;const i=e=>e.classList.contains(f);let l=o.CellDragUtils.findCell(n,this._cells,i);if(-1===l&&(n=document.elementFromPoint(e.clientX,e.clientY),l=o.CellDragUtils.findCell(n,this._cells,i)),-1===l)return;const r=this._cells.get(l);"prompt"===o.CellDragUtils.detectTargetArea(r,e.target)&&(this._dragData={pressX:e.clientX,pressY:e.clientY,index:l},this._focusedCell=r,document.addEventListener("mouseup",this,!0),document.addEventListener("mousemove",this,!0),e.preventDefault())}_evtMouseMove(e){const t=this._dragData;t&&o.CellDragUtils.shouldStartDrag(t.pressX,t.pressY,e.clientX,e.clientY)&&this._startDrag(t.index,e.clientX,e.clientY)}_startDrag(e,t,s){const n=this._focusedCell.model,i=[n.toJSON()],l=o.CellDragUtils.createCellDragImage(this._focusedCell,i);this._drag=new y.Drag({mimeData:new _.MimeData,dragImage:l,proposedAction:"copy",supportedActions:"copy",source:this}),this._drag.mimeData.setData("application/vnd.jupyter.cells",i);const r=n.sharedModel.getSource();return this._drag.mimeData.setData("text/plain",r),this._focusedCell=null,document.removeEventListener("mousemove",this,!0),document.removeEventListener("mouseup",this,!0),this._drag.start(t,s).then((()=>{this.isDisposed||(this._drag=null,this._dragData=null)}))}handleEvent(e){switch(e.type){case"keydown":this._evtKeyDown(e);break;case"mousedown":this._evtMouseDown(e);break;case"mousemove":this._evtMouseMove(e);break;case"mouseup":this._evtMouseUp(e);break;case"focusin":this._evtFocusIn(e);break;case"focusout":this._evtFocusOut(e)}}onAfterAttach(e){const t=this.node;t.addEventListener("keydown",this,!0),t.addEventListener("click",this),t.addEventListener("mousedown",this),t.addEventListener("focusin",this),t.addEventListener("focusout",this),this.promptCell?(this.promptCell.editor.focus(),this.update()):this.newPromptCell()}onBeforeDetach(e){const t=this.node;t.removeEventListener("keydown",this,!0),t.removeEventListener("click",this),t.removeEventListener("focusin",this),t.removeEventListener("focusout",this)}onActivateRequest(e){const t=this.promptCell&&this.promptCell.editor;t&&t.focus(),this.update()}newPromptCell(){var e;let t=this.promptCell;const s=this._input;if(t){t.readOnly=!0,t.removeClass(v);const o=t;requestIdleCallback((()=>{l.Signal.clearData(o.editor)})),null===(e=t.editor)||void 0===e||e.blur(),s.widgets[0].parent=null,this.addCell(t)}const o=this.contentFactory,n=this._createCodeCellOptions();t=o.createCodeCell(n),t.model.mimeType=this._mimetype,t.addClass(v),this._input.addWidget(t),this._history.editor=t.editor,this._promptCellCreated.emit(t)}onUpdateRequest(e){w.scrollToBottom(this._content.node)}_evtKeyDown(e){const t=this.promptCell&&this.promptCell.editor;t&&(13!==e.keyCode||t.hasFocus()?27===e.keyCode&&t.hasFocus()&&(e.preventDefault(),e.stopPropagation(),this.node.focus()):(e.preventDefault(),t.focus()))}_evtMouseUp(e){this.promptCell&&this.promptCell.node.contains(e.target)&&this.promptCell.editor.focus()}_evtFocusIn(e){this._updateReadWrite()}_evtFocusOut(e){this._updateReadWrite()}async _execute(e){const t=e.model.sharedModel.getSource();if(this._history.push(t),"clear"===t||"%clear"===t)return this.clear(),Promise.resolve(void 0);e.model.contentChanged.connect(this.update,this);const s={cell:e,sessionContext:this.sessionContext,onCellExecuted:e=>{if(this._executed.emit(e.executionDate),e.error)for(const e of this._cells)null===e.model.executionCount&&(e.model.executionState="idle")}};try{await this._executor.runCell(s)}finally{this.isDisposed||(e.model.contentChanged.disconnect(this.update,this),this.update())}}_handleInfo(e){if("ok"!==e.status)return void this._banner.model.sharedModel.setSource("Error in getting kernel banner");this._banner.model.sharedModel.setSource(e.banner);const t=e.language_info;this._mimetype=this._mimeTypeService.getMimeTypeByLanguage(t),this.promptCell&&(this.promptCell.model.mimeType=this._mimetype)}_createCodeCellOptions(){const e=this.contentFactory;return{model:this.modelFactory.createCodeCell({}),rendermime:this.rendermime,contentFactory:e,editorConfig:this.editorConfig,placeholder:!1,translator:this._translator}}_onCellDisposed(e,t){if(!this.isDisposed){this._cells.removeValue(e);const t=this._msgIdCells.get(e);t&&(this._msgIdCells.delete(e),this._msgIds.delete(t))}}_shouldExecute(e){const t=this.promptCell;if(!t)return Promise.resolve(!1);const s=t.model.sharedModel.getSource();return new Promise(((t,o)=>{var n;const i=setTimeout((()=>{t(!0)}),e),l=null===(n=this.sessionContext.session)||void 0===n?void 0:n.kernel;l?l.requestIsComplete({code:s}).then((e=>{clearTimeout(i),this.isDisposed&&t(!1),"incomplete"===e.content.status?t(!1):t(!0)})).catch((()=>{t(!0)})):t(!1)}))}async _onKernelChanged(){var e;this.clear(),this._banner&&(this._banner.dispose(),this._banner=null),this.addBanner(),(null===(e=this.sessionContext.session)||void 0===e?void 0:e.kernel)&&this._handleInfo(await this.sessionContext.session.kernel.info)}async _onKernelStatusChanged(){var e;const t=null===(e=this.sessionContext.session)||void 0===e?void 0:e.kernel;"restarting"===(null==t?void 0:t.status)&&(this.addBanner(),this._handleInfo(await(null==t?void 0:t.info)))}_updateReadWrite(){const e=c.DOMUtils.hasActiveEditableElement(this.node);this.node.classList.toggle("jp-mod-readWrite",e)}}var w,D;!function(e){e.defaultEditorConfig={codeFolding:!1,lineNumbers:!1};class t extends o.Cell.ContentFactory{createCodeCell(e){return new o.CodeCell(e).initializeState()}createRawCell(e){return new o.RawCell(e).initializeState()}}e.ContentFactory=t;class s{constructor(e={}){this.codeCellContentFactory=e.codeCellContentFactory||o.CodeCellModel.defaultContentFactory}createCodeCell(e={}){return e.contentFactory||(e.contentFactory=this.codeCellContentFactory),new o.CodeCellModel(e)}createRawCell(e){return new o.RawCellModel(e)}}e.ModelFactory=s,e.defaultModelFactory=new s({})}(x||(x={})),function(e){e.scrollToBottom=function(e){e.scrollTop=e.scrollHeight-e.clientHeight}}(w||(w={}));class b extends c.MainAreaWidget{constructor(e){super({content:new C.Panel}),this._executed=null,this._connected=null,this.addClass("jp-ConsolePanel");let{executor:t,rendermime:s,mimeTypeService:o,path:n,basePath:i,name:l,manager:r,modelFactory:a,sessionContext:m,translator:g}=e;this.translator=null!=g?g:u.nullTranslator;const y=this.translator.load("jupyterlab"),f=this.contentFactory=e.contentFactory,v=D.count++;n||(n=h.PathExt.join(i||"",`console-${v}-${_.UUID.uuid4()}`)),m=this._sessionContext=null!=m?m:new c.SessionContext({sessionManager:r.sessions,specsManager:r.kernelspecs,path:r.contents.localPath(n),name:l||y.__("Console %1",v),type:"console",kernelPreference:e.kernelPreference,setBusy:e.setBusy});const x=new d.RenderMimeRegistry.UrlResolver({path:n,contents:r.contents});s=s.clone({resolver:x}),this.console=f.createConsole({executor:t,rendermime:s,sessionContext:m,mimeTypeService:o,contentFactory:f,modelFactory:a,translator:g}),this.content.addWidget(this.console),m.initialize().then((async t=>{var s;t&&await(null!==(s=e.sessionDialogs)&&void 0!==s?s:new c.SessionContextDialogs({translator:g})).selectKernel(m),this._connected=new Date,this._updateTitlePanel()})),this.console.executed.connect(this._onExecuted,this),this._updateTitlePanel(),m.kernelChanged.connect(this._updateTitlePanel,this),m.propertyChanged.connect(this._updateTitlePanel,this),this.title.icon=p.consoleIcon,this.title.closable=!0,this.id=`console-${v}`}get sessionContext(){return this._sessionContext}dispose(){this.sessionContext.dispose(),this.console.dispose(),super.dispose()}onActivateRequest(e){const t=this.console.promptCell;t&&t.editor.focus()}onCloseRequest(e){super.onCloseRequest(e),this.dispose()}_onExecuted(e,t){this._executed=t,this._updateTitlePanel()}_updateTitlePanel(){D.updateTitle(this,this._connected,this._executed,this.translator)}}!function(e){class t extends x.ContentFactory{createConsole(e){return new x(e)}}e.ContentFactory=t,e.IContentFactory=new _.Token("@jupyterlab/console:IContentFactory","A factory object that creates new code consoles. Use this if you want to create and host code consoles in your own UI elements.")}(b||(b={})),function(e){e.count=1,e.updateTitle=function(e,t,s,o){const n=(o=o||u.nullTranslator).load("jupyterlab"),i=e.console.sessionContext.session;if(i){let o=n.__("Name: %1\n",i.name)+n.__("Directory: %1\n",h.PathExt.dirname(i.path))+n.__("Kernel: %1",e.console.sessionContext.kernelDisplayName);t&&(o+=n.__("\nConnected: %1",h.Time.format(t.toISOString()))),s&&(o+=n.__("\nLast Execution: %1")),e.title.label=i.name,e.title.caption=o}else e.title.label=n.__("Console"),e.title.caption=""}}(D||(D={}));const k=new _.Token("@jupyterlab/console:IConsoleTracker","A widget tracker for code consoles.\n Use this if you want to be able to iterate over and interact with code consoles\n created by the application."),S=new _.Token("@jupyterlab/console:IConsoleCellExecutor","The console cell executor")}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[2636],{72636:(e,t,s)=>{s.r(t),s.d(t,{CodeConsole:()=>x,ConsoleHistory:()=>a,ConsolePanel:()=>b,ForeignHandler:()=>r,IConsoleCellExecutor:()=>S,IConsoleTracker:()=>k,runCell:()=>n});var o=s(6532);async function n({cell:e,onCellExecuted:t,sessionContext:s}){return o.CodeCell.execute(e,s).then((s=>{if(s&&"ok"===s.content.status){const o=s.content;if(o.payload&&o.payload.length){const t=o.payload.filter((e=>"set_next_input"===e.source))[0];if(t){const s=t.text;e.model.sharedModel.setSource(s)}}return t({cell:e,executionDate:new Date,success:!0}),!0}if(s&&"error"===s.content.status){const o=s.content.ename,n=s.content.evalue;return t({cell:e,executionDate:new Date,success:!1,error:new Error(`KernelReplyNotOK: ${o} ${n}`)}),!1}return t({cell:e,executionDate:new Date,success:!1}),!1}),(s=>(t({cell:e,executionDate:new Date,success:!1,error:new Error(s)}),!1)))}var i,l=s(2159);class r{constructor(e){this._enabled=!1,this._isDisposed=!1,this.sessionContext=e.sessionContext,this.sessionContext.iopubMessage.connect(this.onIOPubMessage,this),this._parent=e.parent}get enabled(){return this._enabled}set enabled(e){this._enabled=e}get parent(){return this._parent}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,l.Signal.clearData(this))}onIOPubMessage(e,t){var s;if(!this._enabled)return!1;const o=null===(s=this.sessionContext.session)||void 0===s?void 0:s.kernel;if(!o)return!1;const n=this._parent;if(t.parent_header.session===o.clientId)return!1;const i=t.header.msg_type,l=t.parent_header.msg_id;let r;switch(i){case"execute_input":{const e=t;r=this._newCell(l);const s=r.model;return s.executionCount=e.content.execution_count,s.sharedModel.setSource(e.content.code),s.trusted=!0,n.update(),!0}case"execute_result":case"display_data":case"stream":case"error":{if(r=this._parent.getCell(l),!r)return!1;const e={...t.content,output_type:i};return r.model.outputs.add(e),n.update(),!0}case"clear_output":{const e=t.content.wait;return r=this._parent.getCell(l),r&&r.model.outputs.clear(e),!0}default:return!1}}_newCell(e){const t=this.parent.createCodeCell();return t.addClass("jp-CodeConsole-foreignCell"),this._parent.addCell(t,e),t}}class a{constructor(e){this._cursor=0,this._hasSession=!1,this._history=[],this._placeholder="",this._setByHistory=!1,this._isDisposed=!1,this._editor=null,this._filtered=[];const{sessionContext:t}=e;t&&(this.sessionContext=t,this._handleKernel(),this.sessionContext.kernelChanged.connect(this._handleKernel,this))}get editor(){return this._editor}set editor(e){if(this._editor===e)return;const t=this._editor;t&&(t.edgeRequested.disconnect(this.onEdgeRequest,this),t.model.sharedModel.changed.disconnect(this.onTextChange,this)),this._editor=e,e&&(e.edgeRequested.connect(this.onEdgeRequest,this),e.model.sharedModel.changed.connect(this.onTextChange,this))}get placeholder(){return this._placeholder}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed=!0,this._history.length=0,l.Signal.clearData(this)}back(e){this._hasSession||(this._hasSession=!0,this._placeholder=e,this.setFilter(e),this._cursor=this._filtered.length-1),--this._cursor,this._cursor=Math.max(0,this._cursor);const t=this._filtered[this._cursor];return Promise.resolve(t)}forward(e){this._hasSession||(this._hasSession=!0,this._placeholder=e,this.setFilter(e),this._cursor=this._filtered.length),++this._cursor,this._cursor=Math.min(this._filtered.length-1,this._cursor);const t=this._filtered[this._cursor];return Promise.resolve(t)}push(e){e&&e!==this._history[this._history.length-1]&&this._history.push(e),this.reset()}reset(){this._cursor=this._history.length,this._hasSession=!1,this._placeholder=""}onHistory(e){this._history.length=0;let t="",s="";if("ok"===e.content.status)for(let o=0;o<e.content.history.length;o++)s=e.content.history[o][2],s!==t&&this._history.push(t=s);this._cursor=this._history.length}onTextChange(){this._setByHistory?this._setByHistory=!1:this.reset()}onEdgeRequest(e,t){const s=e.model.sharedModel,o=s.getSource();"top"===t||"topLine"===t?this.back(o).then((t=>{if(this.isDisposed||!t)return;if(s.getSource()===t)return;this._setByHistory=!0,s.setSource(t);let o=0;o=t.indexOf("\n"),o<0&&(o=t.length),e.setCursorPosition({line:0,column:o})})):this.forward(o).then((t=>{if(this.isDisposed)return;const o=t||this.placeholder;if(s.getSource()===o)return;this._setByHistory=!0,s.setSource(o);const n=e.getPositionAt(o.length);n&&e.setCursorPosition(n)}))}async _handleKernel(){var e,t;const s=null===(t=null===(e=this.sessionContext)||void 0===e?void 0:e.session)||void 0===t?void 0:t.kernel;if(s)return s.requestHistory(i.initialRequest).then((e=>{this.onHistory(e)}));this._history.length=0}setFilter(e=""){this._filtered.length=0;let t="",s="";for(let o=0;o<this._history.length;o++)s=this._history[o],s!==t&&e===s.slice(0,e.length)&&this._filtered.push(t=s);this._filtered.push(e)}}!function(e){e.initialRequest={output:!1,raw:!0,hist_access_type:"tail",n:500}}(i||(i={}));var c=s(53876),h=s(20754),d=s(58194),u=s(93050),p=s(76878),_=s(21961),C=s(2260),m=s(42763),g=s(71370),y=s(23246);const f="jp-Console-cell",v="jp-CodeConsole-promptCell";class x extends C.Widget{constructor(e){var t,s,o;super(),this.editorConfig=x.defaultEditorConfig,this._banner=null,this._executed=new l.Signal(this),this._mimetype="text/x-ipython",this._msgIds=new Map,this._msgIdCells=new Map,this._promptCellCreated=new l.Signal(this),this._dragData=null,this._drag=null,this._focusedCell=null,this._translator=null!==(t=e.translator)&&void 0!==t?t:u.nullTranslator,this._executor=null!==(s=e.executor)&&void 0!==s?s:Object.freeze({runCell:n}),this.addClass("jp-CodeConsole"),this.node.dataset.jpKernelUser="true",this.node.dataset.jpCodeRunner="true",this.node.dataset.jpUndoer="true",this.node.tabIndex=-1;const i=this.layout=new C.PanelLayout;this._cells=new g.ObservableList,this._content=new C.Panel,this._input=new C.Panel,this.contentFactory=e.contentFactory,this.modelFactory=null!==(o=e.modelFactory)&&void 0!==o?o:x.defaultModelFactory,this.rendermime=e.rendermime,this.sessionContext=e.sessionContext,this._mimeTypeService=e.mimeTypeService,this._content.addClass("jp-CodeConsole-content"),this._input.addClass("jp-CodeConsole-input"),i.addWidget(this._content),i.addWidget(this._input),this._history=new a({sessionContext:this.sessionContext}),this._onKernelChanged(),this.sessionContext.kernelChanged.connect(this._onKernelChanged,this),this.sessionContext.statusChanged.connect(this._onKernelStatusChanged,this)}get executed(){return this._executed}get promptCellCreated(){return this._promptCellCreated}get cells(){return this._cells}get promptCell(){return this._input.layout.widgets[0]||null}addCell(e,t){e.addClass(f),this._content.addWidget(e),this._cells.push(e),t&&(this._msgIds.set(t,e),this._msgIdCells.set(e,t)),e.disposed.connect(this._onCellDisposed,this),this.update()}addBanner(){if(this._banner){const e=this._banner;this._cells.push(this._banner),e.disposed.connect(this._onCellDisposed,this)}const e=this.modelFactory.createRawCell({sharedModel:(0,m.createStandaloneCell)({cell_type:"raw",source:"..."})}),t=(this._banner=new o.RawCell({model:e,contentFactory:this.contentFactory,placeholder:!1,editorConfig:{autoClosingBrackets:!1,codeFolding:!1,highlightActiveLine:!1,highlightTrailingWhitespace:!1,highlightWhitespace:!1,indentUnit:"4",lineNumbers:!1,lineWrap:!0,matchBrackets:!1,readOnly:!0,rulers:[],scrollPastEnd:!1,smartIndent:!1,tabSize:4,theme:"jupyter"}})).initializeState();t.addClass("jp-CodeConsole-banner"),t.readOnly=!0,this._content.addWidget(t)}clear(){const e=this._cells;for(;e.length>0;)e.get(0).dispose()}createCodeCell(){const e=this.contentFactory,t=this._createCodeCellOptions(),s=e.createCodeCell(t);return s.readOnly=!0,s.model.mimeType=this._mimetype,s}dispose(){this.isDisposed||(this._msgIdCells=null,this._msgIds=null,this._history.dispose(),super.dispose())}async execute(e=!1,t=250){var s,o;if("dead"===(null===(o=null===(s=this.sessionContext.session)||void 0===s?void 0:s.kernel)||void 0===o?void 0:o.status))return;const n=this.promptCell;if(!n)throw new Error("Cannot execute without a prompt cell");if(n.model.trusted=!0,e)return this.newPromptCell(),void await this._execute(n);const i=await this._shouldExecute(t);this.isDisposed||(i?(this.newPromptCell(),this.promptCell.editor.focus(),await this._execute(n)):n.editor.newIndentedLine())}getCell(e){return this._msgIds.get(e)}inject(e,t={}){const s=this.createCodeCell();s.model.sharedModel.setSource(e);for(const e of Object.keys(t))s.model.setMetadata(e,t[e]);return this.addCell(s),this._execute(s)}insertLinebreak(){const e=this.promptCell;e&&e.editor.newIndentedLine()}replaceSelection(e){var t,s;const o=this.promptCell;o&&(null===(s=(t=o.editor).replaceSelection)||void 0===s||s.call(t,e))}serialize(){const e=[];for(const t of this._cells){const s=t.model;(0,o.isCodeCellModel)(s)&&e.push(s.toJSON())}return this.promptCell&&e.push(this.promptCell.model.toJSON()),e}_evtMouseDown(e){const{button:t,shiftKey:s}=e;if(0!==t&&2!==t||s&&2===t)return;let n=e.target;const i=e=>e.classList.contains(f);let l=o.CellDragUtils.findCell(n,this._cells,i);if(-1===l&&(n=document.elementFromPoint(e.clientX,e.clientY),l=o.CellDragUtils.findCell(n,this._cells,i)),-1===l)return;const r=this._cells.get(l);"prompt"===o.CellDragUtils.detectTargetArea(r,e.target)&&(this._dragData={pressX:e.clientX,pressY:e.clientY,index:l},this._focusedCell=r,document.addEventListener("mouseup",this,!0),document.addEventListener("mousemove",this,!0),e.preventDefault())}_evtMouseMove(e){const t=this._dragData;t&&o.CellDragUtils.shouldStartDrag(t.pressX,t.pressY,e.clientX,e.clientY)&&this._startDrag(t.index,e.clientX,e.clientY)}_startDrag(e,t,s){const n=this._focusedCell.model,i=[n.toJSON()],l=o.CellDragUtils.createCellDragImage(this._focusedCell,i);this._drag=new y.Drag({mimeData:new _.MimeData,dragImage:l,proposedAction:"copy",supportedActions:"copy",source:this}),this._drag.mimeData.setData("application/vnd.jupyter.cells",i);const r=n.sharedModel.getSource();return this._drag.mimeData.setData("text/plain",r),this._focusedCell=null,document.removeEventListener("mousemove",this,!0),document.removeEventListener("mouseup",this,!0),this._drag.start(t,s).then((()=>{this.isDisposed||(this._drag=null,this._dragData=null)}))}handleEvent(e){switch(e.type){case"keydown":this._evtKeyDown(e);break;case"mousedown":this._evtMouseDown(e);break;case"mousemove":this._evtMouseMove(e);break;case"mouseup":this._evtMouseUp(e);break;case"focusin":this._evtFocusIn(e);break;case"focusout":this._evtFocusOut(e)}}onAfterAttach(e){const t=this.node;t.addEventListener("keydown",this,!0),t.addEventListener("click",this),t.addEventListener("mousedown",this),t.addEventListener("focusin",this),t.addEventListener("focusout",this),this.promptCell?(this.promptCell.editor.focus(),this.update()):this.newPromptCell()}onBeforeDetach(e){const t=this.node;t.removeEventListener("keydown",this,!0),t.removeEventListener("click",this),t.removeEventListener("focusin",this),t.removeEventListener("focusout",this)}onActivateRequest(e){const t=this.promptCell&&this.promptCell.editor;t&&t.focus(),this.update()}newPromptCell(){var e;let t=this.promptCell;const s=this._input;if(t){t.readOnly=!0,t.removeClass(v);const o=t;requestIdleCallback((()=>{l.Signal.clearData(o.editor)})),null===(e=t.editor)||void 0===e||e.blur(),s.widgets[0].parent=null,this.addCell(t)}const o=this.contentFactory,n=this._createCodeCellOptions();t=o.createCodeCell(n),t.model.mimeType=this._mimetype,t.addClass(v),this._input.addWidget(t),this._history.editor=t.editor,this._promptCellCreated.emit(t)}onUpdateRequest(e){w.scrollToBottom(this._content.node)}_evtKeyDown(e){const t=this.promptCell&&this.promptCell.editor;t&&(13!==e.keyCode||t.hasFocus()?27===e.keyCode&&t.hasFocus()&&(e.preventDefault(),e.stopPropagation(),this.node.focus()):(e.preventDefault(),t.focus()))}_evtMouseUp(e){this.promptCell&&this.promptCell.node.contains(e.target)&&this.promptCell.editor.focus()}_evtFocusIn(e){this._updateReadWrite()}_evtFocusOut(e){this._updateReadWrite()}async _execute(e){const t=e.model.sharedModel.getSource();if(this._history.push(t),"clear"===t||"%clear"===t)return this.clear(),Promise.resolve(void 0);e.model.contentChanged.connect(this.update,this);const s={cell:e,sessionContext:this.sessionContext,onCellExecuted:e=>{if(this._executed.emit(e.executionDate),e.error)for(const e of this._cells)null===e.model.executionCount&&(e.model.executionState="idle")}};try{await this._executor.runCell(s)}finally{this.isDisposed||(e.model.contentChanged.disconnect(this.update,this),this.update())}}_handleInfo(e){if("ok"!==e.status)return void this._banner.model.sharedModel.setSource("Error in getting kernel banner");this._banner.model.sharedModel.setSource(e.banner);const t=e.language_info;this._mimetype=this._mimeTypeService.getMimeTypeByLanguage(t),this.promptCell&&(this.promptCell.model.mimeType=this._mimetype)}_createCodeCellOptions(){const e=this.contentFactory;return{model:this.modelFactory.createCodeCell({}),rendermime:this.rendermime,contentFactory:e,editorConfig:this.editorConfig,placeholder:!1,translator:this._translator}}_onCellDisposed(e,t){if(!this.isDisposed){this._cells.removeValue(e);const t=this._msgIdCells.get(e);t&&(this._msgIdCells.delete(e),this._msgIds.delete(t))}}_shouldExecute(e){const t=this.promptCell;if(!t)return Promise.resolve(!1);const s=t.model.sharedModel.getSource();return new Promise(((t,o)=>{var n;const i=setTimeout((()=>{t(!0)}),e),l=null===(n=this.sessionContext.session)||void 0===n?void 0:n.kernel;l?l.requestIsComplete({code:s}).then((e=>{clearTimeout(i),this.isDisposed&&t(!1),"incomplete"===e.content.status?t(!1):t(!0)})).catch((()=>{t(!0)})):t(!1)}))}async _onKernelChanged(){var e;this.clear(),this._banner&&(this._banner.dispose(),this._banner=null),this.addBanner(),(null===(e=this.sessionContext.session)||void 0===e?void 0:e.kernel)&&this._handleInfo(await this.sessionContext.session.kernel.info)}async _onKernelStatusChanged(){var e;const t=null===(e=this.sessionContext.session)||void 0===e?void 0:e.kernel;"restarting"===(null==t?void 0:t.status)&&(this.addBanner(),this._handleInfo(await(null==t?void 0:t.info)))}_updateReadWrite(){const e=c.DOMUtils.hasActiveEditableElement(this.node);this.node.classList.toggle("jp-mod-readWrite",e)}}var w,D;!function(e){e.defaultEditorConfig={codeFolding:!1,lineNumbers:!1};class t extends o.Cell.ContentFactory{createCodeCell(e){return new o.CodeCell(e).initializeState()}createRawCell(e){return new o.RawCell(e).initializeState()}}e.ContentFactory=t;class s{constructor(e={}){this.codeCellContentFactory=e.codeCellContentFactory||o.CodeCellModel.defaultContentFactory}createCodeCell(e={}){return e.contentFactory||(e.contentFactory=this.codeCellContentFactory),new o.CodeCellModel(e)}createRawCell(e){return new o.RawCellModel(e)}}e.ModelFactory=s,e.defaultModelFactory=new s({})}(x||(x={})),function(e){e.scrollToBottom=function(e){e.scrollTop=e.scrollHeight-e.clientHeight}}(w||(w={}));class b extends c.MainAreaWidget{constructor(e){super({content:new C.Panel}),this._executed=null,this._connected=null,this.addClass("jp-ConsolePanel");let{executor:t,rendermime:s,mimeTypeService:o,path:n,basePath:i,name:l,manager:r,modelFactory:a,sessionContext:m,translator:g}=e;this.translator=null!=g?g:u.nullTranslator;const y=this.translator.load("jupyterlab"),f=this.contentFactory=e.contentFactory,v=D.count++;n||(n=h.PathExt.join(i||"",`console-${v}-${_.UUID.uuid4()}`)),m=this._sessionContext=null!=m?m:new c.SessionContext({kernelManager:r.kernels,sessionManager:r.sessions,specsManager:r.kernelspecs,path:r.contents.localPath(n),name:l||y.__("Console %1",v),type:"console",kernelPreference:e.kernelPreference,setBusy:e.setBusy});const x=new d.RenderMimeRegistry.UrlResolver({path:n,contents:r.contents});s=s.clone({resolver:x}),this.console=f.createConsole({executor:t,rendermime:s,sessionContext:m,mimeTypeService:o,contentFactory:f,modelFactory:a,translator:g}),this.content.addWidget(this.console),m.initialize().then((async t=>{var s;t&&await(null!==(s=e.sessionDialogs)&&void 0!==s?s:new c.SessionContextDialogs({translator:g})).selectKernel(m),this._connected=new Date,this._updateTitlePanel()})),this.console.executed.connect(this._onExecuted,this),this._updateTitlePanel(),m.kernelChanged.connect(this._updateTitlePanel,this),m.propertyChanged.connect(this._updateTitlePanel,this),this.title.icon=p.consoleIcon,this.title.closable=!0,this.id=`console-${v}`}get sessionContext(){return this._sessionContext}dispose(){this.sessionContext.dispose(),this.console.dispose(),super.dispose()}onActivateRequest(e){const t=this.console.promptCell;t&&t.editor.focus()}onCloseRequest(e){super.onCloseRequest(e),this.dispose()}_onExecuted(e,t){this._executed=t,this._updateTitlePanel()}_updateTitlePanel(){D.updateTitle(this,this._connected,this._executed,this.translator)}}!function(e){class t extends x.ContentFactory{createConsole(e){return new x(e)}}e.ContentFactory=t,e.IContentFactory=new _.Token("@jupyterlab/console:IContentFactory","A factory object that creates new code consoles. Use this if you want to create and host code consoles in your own UI elements.")}(b||(b={})),function(e){e.count=1,e.updateTitle=function(e,t,s,o){const n=(o=o||u.nullTranslator).load("jupyterlab"),i=e.console.sessionContext.session;if(i){let o=n.__("Name: %1\n",i.name)+n.__("Directory: %1\n",h.PathExt.dirname(i.path))+n.__("Kernel: %1",e.console.sessionContext.kernelDisplayName);t&&(o+=n.__("\nConnected: %1",h.Time.format(t.toISOString()))),s&&(o+=n.__("\nLast Execution: %1")),e.title.label=i.name,e.title.caption=o}else e.title.label=n.__("Console"),e.title.caption=""}}(D||(D={}));const k=new _.Token("@jupyterlab/console:IConsoleTracker","A widget tracker for code consoles.\n Use this if you want to be able to iterate over and interact with code consoles\n created by the application."),S=new _.Token("@jupyterlab/console:IConsoleCellExecutor","The console cell executor")}}]);
|