"use strict";(self.rspackChunk_jupyter_docprovider_extension=self.rspackChunk_jupyter_docprovider_extension||[]).push([[757],{6484(e,t,r){var o=r(6758),a=r.n(o),n=r(935),i=r.n(n)()(a());i.push([e.id,`/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|---------------------------------------------------------------------------- */

.jp-conflict-diff-header.nbdime-Diff {
  border-bottom: var(--jp-border-width) solid var(--jp-toolbar-border-color);
  box-shadow: var(--jp-toolbar-box-shadow);
  background: var(--jp-toolbar-background);
  flex: 0 0 auto;
}

.jp-conflict-diff-header .nbdime-header-banner {
  display: grid;
  grid-template-columns: 47% 6% 47%;
}

.jp-conflict-diff-header .nbdime-header-base {
  grid-column: 1;
  display: inline-block;
  background-color: var(--jp-diff-deleted-color0);
  padding: 0 4px;
}

.jp-conflict-diff-header .nbdime-header-remote {
  grid-column: 3;
  display: inline-block;
  background-color: var(--jp-diff-added-color0);
  padding: 0 4px;
}

/* diff.css hides .jp-Cellrow-metadata on added/deleted cells by default.
   Override that so metadata changes are always visible in the conflict diff. */
.nbdime-Widget .jp-Diff-added .jp-Cellrow-metadata,
.nbdime-Widget .jp-Diff-deleted .jp-Cellrow-metadata {
  display: block !important;
}
`,""]),r.d(t,{},{A:i})},1277(e,t,r){r.r(t),r.d(t,{default:()=>Z});var o=r(5748),a=r(1660),n=r(3956),i=r(312),s=r(2110),l=r(582),d=r(3352),c=r(7284),p=r(9180),u=r(7651),v=r(6697),h=r(2359),g=r(9687);let m="api/collaboration/timeline",f="The file %1 has been opened with two different views. This is not supported. Please close this view; otherwise, some of your edits may not be saved properly.",y={id:"@jupyter/docprovider-extension:content-provider",description:"The RTC content provider",provides:v.ICollaborativeContentProvider,requires:[p.ITranslator,h.IDocumentProviderFactory],optional:[v.IGlobalAwareness,i.IDocumentManager],activate:(e,t,r,o,a)=>{let n=t.load("jupyter_collaboration"),i=e.serviceManager.contents.defaultDrive;if(!i)throw Error("Cannot initialize content provider: default drive property not accessible on contents manager instance.");let s=i.contentProviderRegistry;if(!s)throw Error("Cannot initialize content provider: no content provider registry.");let l=new h.RtcContentProvider({currentDrive:i,serverSettings:i.serverSettings,user:e.serviceManager.user,trans:n,globalAwareness:o,documentManager:a,fileChanged:i.fileChanged,providerFactory:r});return s.register("rtc",l),l}},b={id:"@jupyter/docprovider-extension:yfile",description:"Plugin to register the shared model factory for the content type 'file'",autoStart:!0,requires:[v.ICollaborativeContentProvider,s.IEditorWidgetFactory],activate:(e,t,r)=>{t.sharedModelFactory.registerDocumentFactory("file",()=>new u.YFile),r.contentProviderId="rtc"}},_={id:"@jupyter/docprovider-extension:ynotebook",description:"Plugin to register the shared model factory for the content type 'notebook'",autoStart:!0,requires:[v.ICollaborativeContentProvider,d.INotebookWidgetFactory],optional:[c.ISettingRegistry],activate:(e,t,r,o)=>{let a=!0;o&&o.load("@jupyterlab/notebook-extension:tracker").then(e=>{let t=e=>{a=!(null==e?void 0:e.get("experimentalEnableDocumentWideUndoRedo").composite)};t(e),e.changed.connect(e=>t(e))}),t.sharedModelFactory.registerDocumentFactory("notebook",()=>new u.YNotebook({disableDocumentWideUndoRedo:a})),r.contentProviderId="rtc"}},w={id:"@jupyter/docprovider-extension:statusBarTimeline",description:"Plugin to add a timeline slider to the status bar",autoStart:!0,requires:[n.IStatusBar,v.ICollaborativeContentProvider],activate:async(e,t,r)=>{try{let o=null,n=null,i=async(t,o)=>{if(!o)return;n&&(n.dispose(),n=null);let[i,s]=o.split(":"),l=r.providers.get(`${i}:${s}:${t}`);if(!l)return;let d=g.URLExt.join(e.serviceManager.serverSettings.baseUrl,m,t);n=new h.TimelineWidget(d,l,l.contentType,l.format,m,e.serviceManager.serverSettings);let c=document.getElementById("jp-slider-status-bar");c&&!n.isAttached&&a.Widget.attach(n,c)};e.shell.currentChanged&&e.shell.currentChanged.connect(async(e,t)=>{let r=t.newValue;n&&(n.dispose(),n=null),r&&"context"in r&&(await r.context.ready,await i(r.context.path,r.context.model.sharedModel.getState("document_id")))}),t&&!o&&((o=new a.Widget).addClass("jp-StatusBar-GroupItem"),o.addClass("jp-mod-highlighted"),o.id="jp-slider-status-bar",t.registerStatusItem("jp-slider-status-bar",{item:o,align:"left",rank:4,isActive:()=>{var t,r;let o=e.shell.currentWidget;return(null==(r=null==(t=null==o?void 0:o.context)?void 0:t.model)?void 0:r.collaborative)||!1}}))}catch(e){console.error("Failed to activate statusBarTimeline plugin:",e)}}},k={id:"@jupyter/docprovider-extension:logger",description:"A logging plugin for debugging purposes.",autoStart:!0,optional:[l.ILoggerRegistry,s.IEditorTracker,d.INotebookTracker,p.ITranslator],activate:(e,t,r,a,n)=>{let i=(null!=n?n:p.nullTranslator).load("jupyter_collaboration"),s="https://schema.jupyter.org/jupyter_collaboration/session/v1";if(!t)return void e.serviceManager.events.stream.connect((e,t)=>{var r,a;t.schema_id===s&&(console.debug(`[${t.room}(${t.path})] ${null!=(r=t.action)?r:""}: ${null!=(a=t.msg)?a:""}`),"WARNING"===t.level&&(0,o.showDialog)({title:i.__("Warning"),body:i.__(f,t.path),buttons:[o.Dialog.okButton()]}))});let l=new Map,d=(e,r)=>{let o=t.getLogger(r.context.path);l.set(r.context.localPath,o),r.disposed.connect(e=>{l.delete(e.context.localPath)})};r&&r.widgetAdded.connect(d),a&&a.widgetAdded.connect(d),(async()=>{var t,r;let{events:a}=e.serviceManager;for await(let e of a.stream)if(e.schema_id===s){let a=l.get(e.path);null==a||a.log({type:"text",level:e.level.toLowerCase(),data:`[${e.room}] ${null!=(t=e.action)?t:""}: ${null!=(r=e.msg)?r:""}`}),"WARNING"===e.level&&(0,o.showDialog)({title:i.__("Warning"),body:i.__(f,e.path),buttons:[o.Dialog.warnButton({label:i.__("Ok")})]})}})()}},C={id:"@jupyter/docprovider-extension:notebook-cell-executor",description:"Add notebook cell executor that uses REST API instead of kernel protocol over WebSocket.",autoStart:!0,provides:d.INotebookCellExecutor,activate:e=>"true"===g.PageConfig.getOption("serverSideExecution")?new h.NotebookCellServerExecutor({serverSettings:e.serviceManager.serverSettings}):Object.freeze({runCell:d.runCell})},x={id:"@jupyter/docprovider-extension:forkManager",autoStart:!0,requires:[v.ICollaborativeContentProvider],provides:h.IForkManagerToken,activate:(e,t)=>{let r=e.serviceManager.events;return new h.ForkManager({contentProvider:t,eventManager:r,serverSettings:e.serviceManager.serverSettings})}};var j=r(5518),I=r(651),S=r(9303),A=r(7560),D=r(2969);r(5557),r(5227),r(3461),r(6116),r(2079);var M=r(2591),T=r.n(M),P=r(1740),W=r.n(P),F=r(8128),E=r.n(F),N=r(855),R=r.n(N),B=r(3051),$=r.n(B),L=r(3656),O=r.n(L),q=r(6484),U={};U.styleTagTransform=O(),U.setAttributes=R(),U.insert=E().bind(null,"head"),U.domAPI=W(),U.insertStyleElement=$(),T()(q.A,U),q.A&&q.A.locals&&q.A.locals;class J extends a.Widget{constructor(e){var t;super(),this._nbdiffWidget=null,this.addClass("nbdime-Widget"),this._editorFactory=e.editorFactory,this._rendermime=e.rendermime,this._trans=null!=(t=e.translator)?t:p.nullTranslator.load("jupyter_collaboration"),this.node.style.display="flex",this.node.style.flexDirection="column",this.node.style.height="100%",this.node.style.overflow="auto"}async create(e){var t,r;let o,a,n,i,s=function(e,t){let r=e.cells,o=t.cells,a=function(e,t){let r=e.length,o=t.length,a=Array.from({length:r+1},()=>Array(o+1).fill(0));for(let n=1;n<=r;n++)for(let r=1;r<=o;r++)a[n][r]=e[n-1]===t[r-1]?a[n-1][r-1]+1:Math.max(a[n-1][r],a[n][r-1]);let n=[],i=r,s=o;for(;i>0&&s>0;)e[i-1]===t[s-1]?(n.unshift([i-1,s-1]),i--,s--):a[i-1][s]>a[i][s-1]?i--:s--;return n}(r.map(e=>{var t;return null!=(t=e.id)?t:""}),o.map(e=>{var t;return null!=(t=e.id)?t:""})),n=[],i=0,s=0;for(let[e,t]of a){i<e&&n.push({op:"removerange",key:i,length:e-i}),s<t&&n.push({op:"addrange",key:i,valuelist:o.slice(s,t)});let a=G(r[e])!==G(o[t]),l=JSON.stringify(r[e].metadata)!==JSON.stringify(o[t].metadata);a?(n.push({op:"removerange",key:e,length:1}),n.push({op:"addrange",key:e,valuelist:[o[t]]})):l&&n.push({op:"patch",key:e,diff:[{op:"replace",key:"metadata",value:o[t].metadata}]}),i=e+1,s=t+1}i<r.length&&n.push({op:"removerange",key:i,length:r.length-i}),s<o.length&&n.push({op:"addrange",key:i,valuelist:o.slice(s)});let l=[];return n.length>0&&l.push({op:"patch",key:"cells",diff:n}),JSON.stringify(e.metadata)!==JSON.stringify(t.metadata)&&l.push({op:"replace",key:"metadata",value:t.metadata}),l}(e.base,e.remote),l=new A.Uv(e.base,s),d=new D.Zx({model:l,rendermime:this._rendermime,editorFactory:this._editorFactory});await d.init(),this._nbdiffWidget=d,this.node.appendChild((t=this._trans.__("Server version"),r=this._trans.__("Local version"),(o=document.createElement("div")).className="jp-conflict-diff-header nbdime-Diff",(a=document.createElement("div")).className="nbdime-header-banner",(n=document.createElement("span")).className="nbdime-header-base",n.textContent=t,(i=document.createElement("span")).className="nbdime-header-remote",i.textContent=r,a.appendChild(n),a.appendChild(i),o.appendChild(a),o)),this.node.appendChild(d.node)}dispose(){var e;this.isDisposed||(null==(e=this._nbdiffWidget)||e.dispose(),super.dispose())}}function G(e){let t=e.source;return Array.isArray(t)?t.join(""):t}let z="@jupyter/docprovider-extension:websocket-provider";class Y{constructor(e){this._trans=e.translator,this._commands=e.commands,this._docManager=e.docManager,this._shell=e.shell,this._contents=e.contents,this._editorFactory=e.editorFactory,this._rendermime=e.rendermime}create(e){let t=this._shell,r=this._contents,a=this._editorFactory,n=this._rendermime,i=e.path,s=async e=>{let s=await r.get(i,{content:!0}),l=new J({translator:this._trans,editorFactory:a,rendermime:n});await l.create({base:s.content,remote:e});let d=new o.MainAreaWidget({content:l});d.title.label=this._trans.__("Conflict diff: %1",i),d.title.closable=!0,d.toolbar.addItem("revertToRemote",new o.ToolbarButton({icon:j.undoIcon,label:this._trans.__("Revert to Remote"),tooltip:this._trans.__("Discard local changes and reload the server version"),onClick:()=>{var e;let t=null==(e=this._docManager.findWidget(i))?void 0:e.context;t&&!t.isDisposed&&t.revert()}})),d.toolbar.addItem("saveLocalAs",new o.ToolbarButton({icon:j.saveIcon,label:this._trans.__("Save Local As"),tooltip:this._trans.__("Save the local version with a new name"),onClick:()=>{var e;let t=null==(e=this._docManager.findWidget(i))?void 0:e.context;t&&!t.isDisposed&&t.saveAs()}})),t.add(d,"main"),t.activateById(d.id)};return new h.WebSocketProvider({path:i,contentType:e.contentType,format:e.format,model:e.model,user:e.user,translator:this._trans,serverSettings:e.serverSettings,onConflictSaveAs:()=>this._commands.execute("docmanager:save-as"),onConflictRevert:()=>this._commands.execute("docmanager:reload"),onConflictShowDiff:"notebook"===e.contentType?s:void 0})}}class V{create(e){let t=g.URLExt.join(e.serverSettings.wsUrl,"api/collaboration/room");return new h.WebSocketAwarenessProvider({url:t,roomID:e.roomID,awareness:e.awareness,user:e.user})}}let Z=[y,b,_,k,C,w,x,{id:z+"-document-factory",description:"Provides a WebSocket document provider factory.",requires:[p.ITranslator,I.IEditorServices,S.IRenderMimeRegistry,i.IDocumentManager],optional:[],provides:h.IDocumentProviderFactory,activate:async(e,t,r,o,a)=>new Y({translator:t.load("jupyter_collaboration"),commands:e.commands,docManager:a,shell:e.shell,contents:e.serviceManager.contents,editorFactory:r.factoryService.newInlineEditor,rendermime:o})},{id:z+"-awareness-factory",description:"Provides awareness provider factory.",requires:[],optional:[],provides:h.IAwarenessProviderFactory,activate:async e=>new V}]}}]);