@jupyterlite/pyodide-kernel 0.8.0-alpha.2 → 0.8.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_pypi.d.ts +2 -2
- package/lib/_pypi.js +2 -2
- package/lib/coincident.worker.js +5 -5
- package/lib/coincident.worker.js.map +3 -3
- package/lib/comlink.worker.js +12 -12
- package/lib/comlink.worker.js.map +3 -3
- package/package.json +7 -7
- package/pypi/all.json +33 -33
- package/pypi/ipykernel-6.9.2-py3-none-any.whl +0 -0
- package/pypi/{piplite-0.8.0a2-py3-none-any.whl → piplite-0.8.0b0-py3-none-any.whl} +0 -0
- package/pypi/{pyodide_kernel-0.8.0a2-py3-none-any.whl → pyodide_kernel-0.8.0b0-py3-none-any.whl} +0 -0
- package/pypi/widgetsnbextension-3.6.999-py3-none-any.whl +0 -0
- package/pypi/widgetsnbextension-4.0.999-py3-none-any.whl +0 -0
package/lib/comlink.worker.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
var Xo=Object.create;var Wn=Object.defineProperty;var Yo=Object.getOwnPropertyDescriptor;var Qo=Object.getOwnPropertyNames;var Zo=Object.getPrototypeOf,ea=Object.prototype.hasOwnProperty;var ri=(n,e)=>()=>(n&&(e=n(n=0)),e);var R=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),ta=(n,e)=>{for(var t in e)Wn(n,t,{get:e[t],enumerable:!0})},na=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Qo(e))!ea.call(n,i)&&i!==t&&Wn(n,i,{get:()=>e[i],enumerable:!(s=Yo(e,i))||s.enumerable});return n};var $n=(n,e,t)=>(t=n!=null?Xo(Zo(n)):{},na(e||!n||!n.__esModule?Wn(t,"default",{value:n,enumerable:!0}):t,n));var Gn=R((xt,fi)=>{(function(n,e){typeof xt=="object"&&typeof fi!="undefined"?e(xt):typeof define=="function"&&define.amd?define(["exports"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_algorithm={}))})(xt,function(n){"use strict";n.ArrayExt=void 0,function(f){function y(S,M,p=0,_=-1){let g=S.length;if(g===0)return-1;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E;_<p?E=_+1+(g-p):E=_-p+1;for(let O=0;O<E;++O){let z=(p+O)%g;if(S[z]===M)return z}return-1}f.firstIndexOf=y;function b(S,M,p=-1,_=0){let g=S.length;if(g===0)return-1;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E;p<_?E=p+1+(g-_):E=p-_+1;for(let O=0;O<E;++O){let z=(p-O+g)%g;if(S[z]===M)return z}return-1}f.lastIndexOf=b;function P(S,M,p=0,_=-1){let g=S.length;if(g===0)return-1;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E;_<p?E=_+1+(g-p):E=_-p+1;for(let O=0;O<E;++O){let z=(p+O)%g;if(M(S[z],z))return z}return-1}f.findFirstIndex=P;function x(S,M,p=-1,_=0){let g=S.length;if(g===0)return-1;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E;p<_?E=p+1+(g-_):E=p-_+1;for(let O=0;O<E;++O){let z=(p-O+g)%g;if(M(S[z],z))return z}return-1}f.findLastIndex=x;function J(S,M,p=0,_=-1){let g=P(S,M,p,_);return g!==-1?S[g]:void 0}f.findFirstValue=J;function F(S,M,p=-1,_=0){let g=x(S,M,p,_);return g!==-1?S[g]:void 0}f.findLastValue=F;function K(S,M,p,_=0,g=-1){let E=S.length;if(E===0)return 0;_<0?_=Math.max(0,_+E):_=Math.min(_,E-1),g<0?g=Math.max(0,g+E):g=Math.min(g,E-1);let O=_,z=g-_+1;for(;z>0;){let we=z>>1,at=O+we;p(S[at],M)<0?(O=at+1,z-=we+1):z=we}return O}f.lowerBound=K;function X(S,M,p,_=0,g=-1){let E=S.length;if(E===0)return 0;_<0?_=Math.max(0,_+E):_=Math.min(_,E-1),g<0?g=Math.max(0,g+E):g=Math.min(g,E-1);let O=_,z=g-_+1;for(;z>0;){let we=z>>1,at=O+we;p(S[at],M)>0?z=we:(O=at+1,z-=we+1)}return O}f.upperBound=X;function B(S,M,p){if(S===M)return!0;if(S.length!==M.length)return!1;for(let _=0,g=S.length;_<g;++_)if(p?!p(S[_],M[_]):S[_]!==M[_])return!1;return!0}f.shallowEqual=B;function Z(S,M={}){let{start:p,stop:_,step:g}=M;if(g===void 0&&(g=1),g===0)throw new Error("Slice `step` cannot be zero.");let E=S.length;p===void 0?p=g<0?E-1:0:p<0?p=Math.max(p+E,g<0?-1:0):p>=E&&(p=g<0?E-1:E),_===void 0?_=g<0?-1:E:_<0?_=Math.max(_+E,g<0?-1:0):_>=E&&(_=g<0?E-1:E);let O;g<0&&_>=p||g>0&&p>=_?O=0:g<0?O=Math.floor((_-p+1)/g+1):O=Math.floor((_-p-1)/g+1);let z=[];for(let we=0;we<O;++we)z[we]=S[p+we*g];return z}f.slice=Z;function G(S,M,p){let _=S.length;if(_<=1||(M<0?M=Math.max(0,M+_):M=Math.min(M,_-1),p<0?p=Math.max(0,p+_):p=Math.min(p,_-1),M===p))return;let g=S[M],E=M<p?1:-1;for(let O=M;O!==p;O+=E)S[O]=S[O+E];S[p]=g}f.move=G;function ue(S,M=0,p=-1){let _=S.length;if(!(_<=1))for(M<0?M=Math.max(0,M+_):M=Math.min(M,_-1),p<0?p=Math.max(0,p+_):p=Math.min(p,_-1);M<p;){let g=S[M],E=S[p];S[M++]=E,S[p--]=g}}f.reverse=ue;function Ce(S,M,p=0,_=-1){let g=S.length;if(g<=1||(p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1),p>=_))return;let E=_-p+1;if(M>0?M=M%E:M<0&&(M=(M%E+E)%E),M===0)return;let O=p+M;ue(S,p,O-1),ue(S,O,_),ue(S,p,_)}f.rotate=Ce;function Ee(S,M,p=0,_=-1){let g=S.length;if(g===0)return;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E;_<p?E=_+1+(g-p):E=_-p+1;for(let O=0;O<E;++O)S[(p+O)%g]=M}f.fill=Ee;function Vo(S,M,p){let _=S.length;M<0?M=Math.max(0,M+_):M=Math.min(M,_);for(let g=_;g>M;--g)S[g]=S[g-1];S[M]=p}f.insert=Vo;function ot(S,M){let p=S.length;if(M<0&&(M+=p),M<0||M>=p)return;let _=S[M];for(let g=M+1;g<p;++g)S[g-1]=S[g];return S.length=p-1,_}f.removeAt=ot;function Bo(S,M,p=0,_=-1){let g=y(S,M,p,_);return g!==-1&&ot(S,g),g}f.removeFirstOf=Bo;function Wo(S,M,p=-1,_=0){let g=b(S,M,p,_);return g!==-1&&ot(S,g),g}f.removeLastOf=Wo;function $o(S,M,p=0,_=-1){let g=S.length;if(g===0)return 0;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E=0;for(let O=0;O<g;++O)p<=_&&O>=p&&O<=_&&S[O]===M||_<p&&(O<=_||O>=p)&&S[O]===M?E++:E>0&&(S[O-E]=S[O]);return E>0&&(S.length=g-E),E}f.removeAllOf=$o;function Ho(S,M,p=0,_=-1){let g,E=P(S,M,p,_);return E!==-1&&(g=ot(S,E)),{index:E,value:g}}f.removeFirstWhere=Ho;function Jo(S,M,p=-1,_=0){let g,E=x(S,M,p,_);return E!==-1&&(g=ot(S,E)),{index:E,value:g}}f.removeLastWhere=Jo;function Go(S,M,p=0,_=-1){let g=S.length;if(g===0)return 0;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E=0;for(let O=0;O<g;++O)p<=_&&O>=p&&O<=_&&M(S[O],O)||_<p&&(O<=_||O>=p)&&M(S[O],O)?E++:E>0&&(S[O-E]=S[O]);return E>0&&(S.length=g-E),E}f.removeAllWhere=Go}(n.ArrayExt||(n.ArrayExt={}));function*e(...f){for(let y of f)yield*y}function*t(){}function*s(f,y=0){for(let b of f)yield[y++,b]}function*i(f,y){let b=0;for(let P of f)y(P,b++)&&(yield P)}function r(f,y){let b=0;for(let P of f)if(y(P,b++))return P}function o(f,y){let b=0;for(let P of f)if(y(P,b++))return b-1;return-1}function a(f,y){let b;for(let P of f){if(b===void 0){b=P;continue}y(P,b)<0&&(b=P)}return b}function d(f,y){let b;for(let P of f){if(b===void 0){b=P;continue}y(P,b)>0&&(b=P)}return b}function c(f,y){let b=!0,P,x;for(let J of f)b?(P=J,x=J,b=!1):y(J,P)<0?P=J:y(J,x)>0&&(x=J);return b?void 0:[P,x]}function u(f){return Array.from(f)}function l(f){let y={};for(let[b,P]of f)y[b]=P;return y}function h(f,y){let b=0;for(let P of f)if(y(P,b++)===!1)return}function v(f,y){let b=0;for(let P of f)if(y(P,b++)===!1)return!1;return!0}function m(f,y){let b=0;for(let P of f)if(y(P,b++))return!0;return!1}function*q(f,y){let b=0;for(let P of f)yield y(P,b++)}function*I(f,y,b){y===void 0?(y=f,f=0,b=1):b===void 0&&(b=1);let P=T.rangeLength(f,y,b);for(let x=0;x<P;x++)yield f+b*x}var T;(function(f){function y(b,P,x){return x===0?1/0:b>P&&x>0||b<P&&x<0?0:Math.ceil((P-b)/x)}f.rangeLength=y})(T||(T={}));function A(f,y,b){let P=f[Symbol.iterator](),x=0,J=P.next();if(J.done&&b===void 0)throw new TypeError("Reduce of empty iterable with no initial value.");if(J.done)return b;let F=P.next();if(F.done&&b===void 0)return J.value;if(F.done)return y(b,J.value,x++);let K;b===void 0?K=y(J.value,F.value,x++):K=y(y(b,J.value,x++),F.value,x++);let X;for(;!(X=P.next()).done;)K=y(K,X.value,x++);return K}function*C(f,y){for(;0<y--;)yield f}function*w(f){yield f}function*k(f){if(typeof f.retro=="function")yield*f.retro();else for(let y=f.length-1;y>-1;y--)yield f[y]}function N(f){let y=[],b=new Set,P=new Map;for(let F of f)x(F);for(let[F]of P)J(F);return y;function x(F){let[K,X]=F,B=P.get(X);B?B.push(K):P.set(X,[K])}function J(F){if(b.has(F))return;b.add(F);let K=P.get(F);if(K)for(let X of K)J(X);y.push(F)}}function*j(f,y){let b=0;for(let P of f)b++%y===0&&(yield P)}n.StringExt=void 0,function(f){function y(F,K,X=0){let B=new Array(K.length);for(let Z=0,G=X,ue=K.length;Z<ue;++Z,++G){if(G=F.indexOf(K[Z],G),G===-1)return null;B[Z]=G}return B}f.findIndices=y;function b(F,K,X=0){let B=y(F,K,X);if(!B)return null;let Z=0;for(let G=0,ue=B.length;G<ue;++G){let Ce=B[G]-X;Z+=Ce*Ce}return{score:Z,indices:B}}f.matchSumOfSquares=b;function P(F,K,X=0){let B=y(F,K,X);if(!B)return null;let Z=0,G=X-1;for(let ue=0,Ce=B.length;ue<Ce;++ue){let Ee=B[ue];Z+=Ee-G-1,G=Ee}return{score:Z,indices:B}}f.matchSumOfDeltas=P;function x(F,K,X){let B=[],Z=0,G=0,ue=K.length;for(;Z<ue;){let Ce=K[Z],Ee=K[Z];for(;++Z<ue&&K[Z]===Ee+1;)Ee++;G<Ce&&B.push(F.slice(G,Ce)),Ce<Ee+1&&B.push(X(F.slice(Ce,Ee+1))),G=Ee+1}return G<F.length&&B.push(F.slice(G)),B}f.highlight=x;function J(F,K){return F<K?-1:F>K?1:0}f.cmp=J}(n.StringExt||(n.StringExt={}));function*D(f,y){if(y<1)return;let b=f[Symbol.iterator](),P;for(;0<y--&&!(P=b.next()).done;)yield P.value}function*U(...f){let y=f.map(P=>P[Symbol.iterator]()),b=y.map(P=>P.next());for(;v(b,P=>!P.done);b=y.map(P=>P.next()))yield b.map(P=>P.value)}n.chain=e,n.each=h,n.empty=t,n.enumerate=s,n.every=v,n.filter=i,n.find=r,n.findIndex=o,n.map=q,n.max=d,n.min=a,n.minmax=c,n.once=w,n.range=I,n.reduce=A,n.repeat=C,n.retro=k,n.some=m,n.stride=j,n.take=D,n.toArray=u,n.toObject=l,n.topologicSort=N,n.zip=U})});var Y=R((Ft,_i)=>{(function(n,e){typeof Ft=="object"&&typeof _i!="undefined"?e(Ft,Gn()):typeof define=="function"&&define.amd?define(["exports","@lumino/algorithm"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_coreutils={},n.lumino_algorithm))})(Ft,function(n,e){"use strict";n.JSONExt=void 0,function(c){c.emptyObject=Object.freeze({}),c.emptyArray=Object.freeze([]);function u(C){return C===null||typeof C=="boolean"||typeof C=="number"||typeof C=="string"}c.isPrimitive=u;function l(C){return Array.isArray(C)}c.isArray=l;function h(C){return!u(C)&&!l(C)}c.isObject=h;function v(C,w){if(C===w)return!0;if(u(C)||u(w))return!1;let k=l(C),N=l(w);return k!==N?!1:k&&N?q(C,w):I(C,w)}c.deepEqual=v;function m(C){return u(C)?C:l(C)?T(C):A(C)}c.deepCopy=m;function q(C,w){if(C===w)return!0;if(C.length!==w.length)return!1;for(let k=0,N=C.length;k<N;++k)if(!v(C[k],w[k]))return!1;return!0}function I(C,w){if(C===w)return!0;for(let k in C)if(C[k]!==void 0&&!(k in w))return!1;for(let k in w)if(w[k]!==void 0&&!(k in C))return!1;for(let k in C){let N=C[k],j=w[k];if(!(N===void 0&&j===void 0)&&(N===void 0||j===void 0||!v(N,j)))return!1}return!0}function T(C){let w=new Array(C.length);for(let k=0,N=C.length;k<N;++k)w[k]=m(C[k]);return w}function A(C){let w={};for(let k in C){let N=C[k];N!==void 0&&(w[k]=m(N))}return w}}(n.JSONExt||(n.JSONExt={}));class t{constructor(){this._types=[],this._values=[]}types(){return this._types.slice()}hasData(u){return this._types.indexOf(u)!==-1}getData(u){let l=this._types.indexOf(u);return l!==-1?this._values[l]:void 0}setData(u,l){this.clearData(u),this._types.push(u),this._values.push(l)}clearData(u){let l=this._types.indexOf(u);l!==-1&&(this._types.splice(l,1),this._values.splice(l,1))}clear(){this._types.length=0,this._values.length=0}}class s{constructor(u={}){this._application=null,this._validatePlugin=()=>!0,this._plugins=new Map,this._services=new Map,u.validatePlugin&&(console.info("Plugins may be rejected by the custom validation plugin method."),this._validatePlugin=u.validatePlugin)}get application(){return this._application}set application(u){if(this._application!==null)throw Error("PluginRegistry.application is already set. It cannot be overridden.");this._application=u}get deferredPlugins(){return Array.from(this._plugins).filter(([u,l])=>l.autoStart==="defer").map(([u,l])=>u)}getPluginDescription(u){var l,h;return(h=(l=this._plugins.get(u))===null||l===void 0?void 0:l.description)!==null&&h!==void 0?h:""}hasPlugin(u){return this._plugins.has(u)}isPluginActivated(u){var l,h;return(h=(l=this._plugins.get(u))===null||l===void 0?void 0:l.activated)!==null&&h!==void 0?h:!1}listPlugins(){return Array.from(this._plugins.keys())}registerPlugin(u){if(this._plugins.has(u.id))throw new TypeError(`Plugin '${u.id}' is already registered.`);if(!this._validatePlugin(u))throw new Error(`Plugin '${u.id}' is not valid.`);let l=i.createPluginData(u);i.ensureNoCycle(l,this._plugins,this._services),l.provides&&this._services.set(l.provides,l.id),this._plugins.set(l.id,l)}registerPlugins(u){for(let l of u)this.registerPlugin(l)}deregisterPlugin(u,l){let h=this._plugins.get(u);if(h){if(h.activated&&!l)throw new Error(`Plugin '${u}' is still active.`);this._plugins.delete(u)}}async activatePlugin(u){let l=this._plugins.get(u);if(!l)throw new ReferenceError(`Plugin '${u}' is not registered.`);if(l.activated)return;if(l.promise)return l.promise;let h=l.requires.map(m=>this.resolveRequiredService(m)),v=l.optional.map(m=>this.resolveOptionalService(m));return l.promise=Promise.all([...h,...v]).then(m=>l.activate.apply(void 0,[this.application,...m])).then(m=>{l.service=m,l.activated=!0,l.promise=null}).catch(m=>{throw l.promise=null,m}),l.promise}async activatePlugins(u,l={}){switch(u){case"defer":{let h=this.deferredPlugins.filter(v=>this._plugins.get(v).autoStart).map(v=>this.activatePlugin(v));await Promise.all(h);break}case"startUp":{let v=i.collectStartupPlugins(this._plugins,l).map(async m=>{try{return await this.activatePlugin(m)}catch(q){console.error(`Plugin '${m}' failed to activate.`,q)}});await Promise.all(v);break}}}async deactivatePlugin(u){let l=this._plugins.get(u);if(!l)throw new ReferenceError(`Plugin '${u}' is not registered.`);if(!l.activated)return[];if(!l.deactivate)throw new TypeError(`Plugin '${u}'#deactivate() method missing`);let h=i.findDependents(u,this._plugins,this._services),v=h.map(m=>this._plugins.get(m));for(let m of v)if(!m.deactivate)throw new TypeError(`Plugin ${m.id}#deactivate() method missing (depends on ${u})`);for(let m of v){let q=[...m.requires,...m.optional].map(I=>{let T=this._services.get(I);return T?this._plugins.get(T).service:null});await m.deactivate(this.application,...q),m.service=null,m.activated=!1}return h.pop(),h}async resolveRequiredService(u){let l=this._services.get(u);if(!l)throw new TypeError(`No provider for: ${u.name}.`);let h=this._plugins.get(l);return h.activated||await this.activatePlugin(l),h.service}async resolveOptionalService(u){let l=this._services.get(u);if(!l)return null;let h=this._plugins.get(l);if(!h.activated)try{await this.activatePlugin(l)}catch(v){return console.error(v),null}return h.service}}var i;(function(c){class u{constructor(I){var T,A,C,w;this._activated=!1,this._promise=null,this._service=null,this.id=I.id,this.description=(T=I.description)!==null&&T!==void 0?T:"",this.activate=I.activate,this.deactivate=(A=I.deactivate)!==null&&A!==void 0?A:null,this.provides=(C=I.provides)!==null&&C!==void 0?C:null,this.autoStart=(w=I.autoStart)!==null&&w!==void 0?w:!1,this.requires=I.requires?I.requires.slice():[],this.optional=I.optional?I.optional.slice():[]}get activated(){return this._activated}set activated(I){this._activated=I}get service(){return this._service}set service(I){this._service=I}get promise(){return this._promise}set promise(I){this._promise=I}}function l(q){return new u(q)}c.createPluginData=l;function h(q,I,T){let A=[...q.requires,...q.optional],C=k=>{if(k===q.provides)return!0;let N=T.get(k);if(!N)return!1;let j=I.get(N),D=[...j.requires,...j.optional];return D.length===0?!1:(w.push(N),D.some(C)?!0:(w.pop(),!1))};if(!q.provides||A.length===0)return;let w=[q.id];if(A.some(C))throw new ReferenceError(`Cycle detected: ${w.join(" -> ")}.`)}c.ensureNoCycle=h;function v(q,I,T){let A=new Array,C=D=>{let U=I.get(D),f=[...U.requires,...U.optional];A.push(...f.reduce((y,b)=>{let P=T.get(b);return P&&y.push([D,P]),y},[]))};for(let D of I.keys())C(D);let w=A.filter(D=>D[1]===q),k=0;for(;w.length>k;){let D=w.length,U=new Set(w.map(f=>f[0]));for(let f of U)A.filter(y=>y[1]===f).forEach(y=>{w.includes(y)||w.push(y)});k=D}let N=e.topologicSort(w),j=N.findIndex(D=>D===q);return j===-1?[q]:N.slice(0,j+1)}c.findDependents=v;function m(q,I){let T=new Set;for(let A of q.keys())q.get(A).autoStart===!0&&T.add(A);if(I.startPlugins)for(let A of I.startPlugins)T.add(A);if(I.ignorePlugins)for(let A of I.ignorePlugins)T.delete(A);return Array.from(T)}c.collectStartupPlugins=m})(i||(i={}));class r{constructor(){this.promise=new Promise((u,l)=>{this._resolve=u,this._reject=l})}resolve(u){let l=this._resolve;l(u)}reject(u){let l=this._reject;l(u)}}class o{constructor(u,l){this.name=u,this.description=l!=null?l:"",this._tokenStructuralPropertyT=null}}function a(c){let u=0;for(let l=0,h=c.length;l<h;++l)l%4===0&&(u=Math.random()*4294967295>>>0),c[l]=u&255,u>>>=8}n.Random=void 0,function(c){c.getRandomValues=(()=>{let u=typeof window!="undefined"&&(window.crypto||window.msCrypto)||null;return u&&typeof u.getRandomValues=="function"?function(h){return u.getRandomValues(h)}:a})()}(n.Random||(n.Random={}));function d(c){let u=new Uint8Array(16),l=new Array(256);for(let h=0;h<16;++h)l[h]="0"+h.toString(16);for(let h=16;h<256;++h)l[h]=h.toString(16);return function(){return c(u),u[6]=64|u[6]&15,u[8]=128|u[8]&63,l[u[0]]+l[u[1]]+l[u[2]]+l[u[3]]+"-"+l[u[4]]+l[u[5]]+"-"+l[u[6]]+l[u[7]]+"-"+l[u[8]]+l[u[9]]+"-"+l[u[10]]+l[u[11]]+l[u[12]]+l[u[13]]+l[u[14]]+l[u[15]]}}n.UUID=void 0,function(c){c.uuid4=d(n.Random.getRandomValues)}(n.UUID||(n.UUID={})),n.MimeData=t,n.PluginRegistry=s,n.PromiseDelegate=r,n.Token=o})});var ee=R((Kt,pi)=>{(function(n,e){typeof Kt=="object"&&typeof pi!="undefined"?e(Kt,Gn(),Y()):typeof define=="function"&&define.amd?define(["exports","@lumino/algorithm","@lumino/coreutils"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_signaling={},n.lumino_algorithm,n.lumino_coreutils))})(Kt,function(n,e,t){"use strict";class s{constructor(a){this.sender=a}connect(a,d){return r.connect(this,a,d)}disconnect(a,d){return r.disconnect(this,a,d)}emit(a){r.emit(this,a)}}(function(o){function a(m,q){r.disconnectBetween(m,q)}o.disconnectBetween=a;function d(m){r.disconnectSender(m)}o.disconnectSender=d;function c(m){r.disconnectReceiver(m)}o.disconnectReceiver=c;function u(m){r.disconnectAll(m)}o.disconnectAll=u;function l(m){r.disconnectAll(m)}o.clearData=l;function h(){return r.exceptionHandler}o.getExceptionHandler=h;function v(m){let q=r.exceptionHandler;return r.exceptionHandler=m,q}o.setExceptionHandler=v})(s||(s={}));class i extends s{constructor(){super(...arguments),this._pending=new t.PromiseDelegate}async*[Symbol.asyncIterator](){let a=this._pending;for(;;)try{let{args:d,next:c}=await a.promise;a=c,yield d}catch{return}}emit(a){let d=this._pending,c=this._pending=new t.PromiseDelegate;d.resolve({args:a,next:c}),super.emit(a)}stop(){this._pending.promise.catch(()=>{}),this._pending.reject("stop"),this._pending=new t.PromiseDelegate}}var r;(function(o){o.exceptionHandler=D=>{console.error(D)};function a(D,U,f){f=f||void 0;let y=m.get(D.sender);if(y||(y=[],m.set(D.sender,y)),A(y,D,U,f))return!1;let b=f||U,P=q.get(b);P||(P=[],q.set(b,P));let x={signal:D,slot:U,thisArg:f};return y.push(x),P.push(x),!0}o.connect=a;function d(D,U,f){f=f||void 0;let y=m.get(D.sender);if(!y||y.length===0)return!1;let b=A(y,D,U,f);if(!b)return!1;let P=f||U,x=q.get(P);return b.signal=null,w(y),w(x),!0}o.disconnect=d;function c(D,U){let f=m.get(D);if(!f||f.length===0)return;let y=q.get(U);if(!(!y||y.length===0)){for(let b of y)b.signal&&b.signal.sender===D&&(b.signal=null);w(f),w(y)}}o.disconnectBetween=c;function u(D){let U=m.get(D);if(!(!U||U.length===0)){for(let f of U){if(!f.signal)continue;let y=f.thisArg||f.slot;f.signal=null,w(q.get(y))}w(U)}}o.disconnectSender=u;function l(D){let U=q.get(D);if(!(!U||U.length===0)){for(let f of U){if(!f.signal)continue;let y=f.signal.sender;f.signal=null,w(m.get(y))}w(U)}}o.disconnectReceiver=l;function h(D){u(D),l(D)}o.disconnectAll=h;function v(D,U){let f=m.get(D.sender);if(!(!f||f.length===0))for(let y=0,b=f.length;y<b;++y){let P=f[y];P.signal===D&&C(P,U)}}o.emit=v;let m=new WeakMap,q=new WeakMap,I=new Set,T=typeof requestAnimationFrame=="function"?requestAnimationFrame:setImmediate;function A(D,U,f,y){return e.find(D,b=>b.signal===U&&b.slot===f&&b.thisArg===y)}function C(D,U){let{signal:f,slot:y,thisArg:b}=D;try{y.call(b,f.sender,U)}catch(P){o.exceptionHandler(P)}}function w(D){I.size===0&&T(k),I.add(D)}function k(){I.forEach(N),I.clear()}function N(D){e.ArrayExt.removeAllWhere(D,j)}function j(D){return D.signal===null}})(r||(r={})),n.Signal=s,n.Stream=i})});var mi=R(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.ActivityMonitor=void 0;var gi=ee(),Xn=class{constructor(e){this._timer=-1,this._timeout=-1,this._isDisposed=!1,this._activityStopped=new gi.Signal(this),e.signal.connect(this._onSignalFired,this),this._timeout=e.timeout||1e3}get activityStopped(){return this._activityStopped}get timeout(){return this._timeout}set timeout(e){this._timeout=e}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,gi.Signal.clearData(this))}_onSignalFired(e,t){clearTimeout(this._timer),this._sender=e,this._args=t,this._timer=setTimeout(()=>{this._activityStopped.emit({sender:this._sender,args:this._args})},this._timeout)}};zt.ActivityMonitor=Xn});var yi=R(vi=>{"use strict";Object.defineProperty(vi,"__esModule",{value:!0})});var wi=R(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.LruCache=void 0;var ga=128,Yn=class{constructor(e={}){this._map=new Map,this._maxSize=(e==null?void 0:e.maxSize)||ga}get size(){return this._map.size}clear(){this._map.clear()}get(e){let t=this._map.get(e)||null;return t!=null&&(this._map.delete(e),this._map.set(e,t)),t}set(e,t){this._map.size>=this._maxSize&&this._map.delete(this._map.keys().next().value),this._map.set(e,t)}};Vt.LruCache=Yn});var bi=R(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.MarkdownCodeBlocks=void 0;var Si;(function(n){n.CODE_BLOCK_MARKER="```";let e=[".markdown",".mdown",".mkdn",".md",".mkd",".mdwn",".mdtxt",".mdtext",".text",".txt",".Rmd"];class t{constructor(o){this.startLine=o,this.code="",this.endLine=-1}}n.MarkdownCodeBlock=t;function s(r){return e.indexOf(r)>-1}n.isMarkdown=s;function i(r){if(!r||r==="")return[];let o=r.split(`
|
|
2
|
-
`),a=[],
|
|
3
|
-
`);else{d=new t(c);let v=u.indexOf(n.CODE_BLOCK_MARKER),m=u.lastIndexOf(n.CODE_BLOCK_MARKER);v!==m&&(d.code=u.substring(v+n.CODE_BLOCK_MARKER.length,m),d.endLine=c,a.push(d),d=null)}}return a}n.findMarkdownCodeBlocks=i})(Si||(Bt.MarkdownCodeBlocks=Si={}))});var Ei=R((Nu,Mi)=>{"use strict";function ma(n,e){var t=n;e.slice(0,-1).forEach(function(i){t=t[i]||{}});var s=e[e.length-1];return s in t}function Ci(n){return typeof n=="number"||/^0x[0-9a-f]+$/i.test(n)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(n)}function Pi(n,e){return e==="constructor"&&typeof n[e]=="function"||e==="__proto__"}Mi.exports=function(n,e){e||(e={});var t={bools:{},strings:{},unknownFn:null};typeof e.unknown=="function"&&(t.unknownFn=e.unknown),typeof e.boolean=="boolean"&&e.boolean?t.allBools=!0:[].concat(e.boolean).filter(Boolean).forEach(function(w){t.bools[w]=!0});var s={};function i(w){return s[w].some(function(k){return t.bools[k]})}Object.keys(e.alias||{}).forEach(function(w){s[w]=[].concat(e.alias[w]),s[w].forEach(function(k){s[k]=[w].concat(s[w].filter(function(N){return k!==N}))})}),[].concat(e.string).filter(Boolean).forEach(function(w){t.strings[w]=!0,s[w]&&[].concat(s[w]).forEach(function(k){t.strings[k]=!0})});var r=e.default||{},o={_:[]};function a(w,k){return t.allBools&&/^--[^=]+$/.test(k)||t.strings[w]||t.bools[w]||s[w]}function d(w,k,N){for(var j=w,D=0;D<k.length-1;D++){var U=k[D];if(Pi(j,U))return;j[U]===void 0&&(j[U]={}),(j[U]===Object.prototype||j[U]===Number.prototype||j[U]===String.prototype)&&(j[U]={}),j[U]===Array.prototype&&(j[U]=[]),j=j[U]}var f=k[k.length-1];Pi(j,f)||((j===Object.prototype||j===Number.prototype||j===String.prototype)&&(j={}),j===Array.prototype&&(j=[]),j[f]===void 0||t.bools[f]||typeof j[f]=="boolean"?j[f]=N:Array.isArray(j[f])?j[f].push(N):j[f]=[j[f],N])}function c(w,k,N){if(!(N&&t.unknownFn&&!a(w,N)&&t.unknownFn(N)===!1)){var j=!t.strings[w]&&Ci(k)?Number(k):k;d(o,w.split("."),j),(s[w]||[]).forEach(function(D){d(o,D.split("."),j)})}}Object.keys(t.bools).forEach(function(w){c(w,r[w]===void 0?!1:r[w])});var u=[];n.indexOf("--")!==-1&&(u=n.slice(n.indexOf("--")+1),n=n.slice(0,n.indexOf("--")));for(var l=0;l<n.length;l++){var h=n[l],v,m;if(/^--.+=/.test(h)){var q=h.match(/^--([^=]+)=([\s\S]*)$/);v=q[1];var I=q[2];t.bools[v]&&(I=I!=="false"),c(v,I,h)}else if(/^--no-.+/.test(h))v=h.match(/^--no-(.+)/)[1],c(v,!1,h);else if(/^--.+/.test(h))v=h.match(/^--(.+)/)[1],m=n[l+1],m!==void 0&&!/^(-|--)[^-]/.test(m)&&!t.bools[v]&&!t.allBools&&(!s[v]||!i(v))?(c(v,m,h),l+=1):/^(true|false)$/.test(m)?(c(v,m==="true",h),l+=1):c(v,t.strings[v]?"":!0,h);else if(/^-[^-]+/.test(h)){for(var T=h.slice(1,-1).split(""),A=!1,C=0;C<T.length;C++){if(m=h.slice(C+2),m==="-"){c(T[C],m,h);continue}if(/[A-Za-z]/.test(T[C])&&m[0]==="="){c(T[C],m.slice(1),h),A=!0;break}if(/[A-Za-z]/.test(T[C])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(m)){c(T[C],m,h),A=!0;break}if(T[C+1]&&T[C+1].match(/\W/)){c(T[C],h.slice(C+2),h),A=!0;break}else c(T[C],t.strings[T[C]]?"":!0,h)}v=h.slice(-1)[0],!A&&v!=="-"&&(n[l+1]&&!/^(-|--)[^-]/.test(n[l+1])&&!t.bools[v]&&(!s[v]||!i(v))?(c(v,n[l+1],h),l+=1):n[l+1]&&/^(true|false)$/.test(n[l+1])?(c(v,n[l+1]==="true",h),l+=1):c(v,t.strings[v]?"":!0,h))}else if((!t.unknownFn||t.unknownFn(h)!==!1)&&o._.push(t.strings._||!Ci(h)?h:Number(h)),e.stopEarly){o._.push.apply(o._,n.slice(l+1));break}}return Object.keys(r).forEach(function(w){ma(o,w.split("."))||(d(o,w.split("."),r[w]),(s[w]||[]).forEach(function(k){d(o,k.split("."),r[w])}))}),e["--"]?o["--"]=u.slice():u.forEach(function(w){o._.push(w)}),o}});var Wt=R((Lu,Ri)=>{"use strict";function Ie(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}function Ii(n,e){for(var t="",s=0,i=-1,r=0,o,a=0;a<=n.length;++a){if(a<n.length)o=n.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(i===a-1||r===1))if(i!==a-1&&r===2){if(t.length<2||s!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var d=t.lastIndexOf("/");if(d!==t.length-1){d===-1?(t="",s=0):(t=t.slice(0,d),s=t.length-1-t.lastIndexOf("/")),i=a,r=0;continue}}else if(t.length===2||t.length===1){t="",s=0,i=a,r=0;continue}}e&&(t.length>0?t+="/..":t="..",s=2)}else t.length>0?t+="/"+n.slice(i+1,a):t=n.slice(i+1,a),s=a-i-1;i=a,r=0}else o===46&&r!==-1?++r:r=-1}return t}function va(n,e){var t=e.dir||e.root,s=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+s:t+n+s:s}var Ye={resolve:function(){for(var e="",t=!1,s,i=arguments.length-1;i>=-1&&!t;i--){var r;i>=0?r=arguments[i]:(s===void 0&&(s=process.cwd()),r=s),Ie(r),r.length!==0&&(e=r+"/"+e,t=r.charCodeAt(0)===47)}return e=Ii(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(Ie(e),e.length===0)return".";var t=e.charCodeAt(0)===47,s=e.charCodeAt(e.length-1)===47;return e=Ii(e,!t),e.length===0&&!t&&(e="."),e.length>0&&s&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return Ie(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var s=arguments[t];Ie(s),s.length>0&&(e===void 0?e=s:e+="/"+s)}return e===void 0?".":Ye.normalize(e)},relative:function(e,t){if(Ie(e),Ie(t),e===t||(e=Ye.resolve(e),t=Ye.resolve(t),e===t))return"";for(var s=1;s<e.length&&e.charCodeAt(s)===47;++s);for(var i=e.length,r=i-s,o=1;o<t.length&&t.charCodeAt(o)===47;++o);for(var a=t.length,d=a-o,c=r<d?r:d,u=-1,l=0;l<=c;++l){if(l===c){if(d>c){if(t.charCodeAt(o+l)===47)return t.slice(o+l+1);if(l===0)return t.slice(o+l)}else r>c&&(e.charCodeAt(s+l)===47?u=l:l===0&&(u=0));break}var h=e.charCodeAt(s+l),v=t.charCodeAt(o+l);if(h!==v)break;h===47&&(u=l)}var m="";for(l=s+u+1;l<=i;++l)(l===i||e.charCodeAt(l)===47)&&(m.length===0?m+="..":m+="/..");return m.length>0?m+t.slice(o+u):(o+=u,t.charCodeAt(o)===47&&++o,t.slice(o))},_makeLong:function(e){return e},dirname:function(e){if(Ie(e),e.length===0)return".";for(var t=e.charCodeAt(0),s=t===47,i=-1,r=!0,o=e.length-1;o>=1;--o)if(t=e.charCodeAt(o),t===47){if(!r){i=o;break}}else r=!1;return i===-1?s?"/":".":s&&i===1?"//":e.slice(0,i)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ie(e);var s=0,i=-1,r=!0,o;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,d=-1;for(o=e.length-1;o>=0;--o){var c=e.charCodeAt(o);if(c===47){if(!r){s=o+1;break}}else d===-1&&(r=!1,d=o+1),a>=0&&(c===t.charCodeAt(a)?--a===-1&&(i=o):(a=-1,i=d))}return s===i?i=d:i===-1&&(i=e.length),e.slice(s,i)}else{for(o=e.length-1;o>=0;--o)if(e.charCodeAt(o)===47){if(!r){s=o+1;break}}else i===-1&&(r=!1,i=o+1);return i===-1?"":e.slice(s,i)}},extname:function(e){Ie(e);for(var t=-1,s=0,i=-1,r=!0,o=0,a=e.length-1;a>=0;--a){var d=e.charCodeAt(a);if(d===47){if(!r){s=a+1;break}continue}i===-1&&(r=!1,i=a+1),d===46?t===-1?t=a:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||i===-1||o===0||o===1&&t===i-1&&t===s+1?"":e.slice(t,i)},format:function(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return va("/",e)},parse:function(e){Ie(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var s=e.charCodeAt(0),i=s===47,r;i?(t.root="/",r=1):r=0;for(var o=-1,a=0,d=-1,c=!0,u=e.length-1,l=0;u>=r;--u){if(s=e.charCodeAt(u),s===47){if(!c){a=u+1;break}continue}d===-1&&(c=!1,d=u+1),s===46?o===-1?o=u:l!==1&&(l=1):o!==-1&&(l=-1)}return o===-1||d===-1||l===0||l===1&&o===d-1&&o===a+1?d!==-1&&(a===0&&i?t.base=t.name=e.slice(1,d):t.base=t.name=e.slice(a,d)):(a===0&&i?(t.name=e.slice(1,o),t.base=e.slice(1,d)):(t.name=e.slice(a,o),t.base=e.slice(a,d)),t.ext=e.slice(o,d)),a>0?t.dir=e.slice(0,a-1):i&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};Ye.posix=Ye;Ri.exports=Ye});var Oi=R((xu,ki)=>{"use strict";ki.exports=function(e,t){if(t=t.split(":")[0],e=+e,!e)return!1;switch(t){case"http":case"ws":return e!==80;case"https":case"wss":return e!==443;case"ftp":return e!==21;case"gopher":return e!==70;case"file":return!1}return e!==0}});var Ti=R(Qn=>{"use strict";var ya=Object.prototype.hasOwnProperty,wa;function Di(n){try{return decodeURIComponent(n.replace(/\+/g," "))}catch{return null}}function qi(n){try{return encodeURIComponent(n)}catch{return null}}function Sa(n){for(var e=/([^=?#&]+)=?([^&]*)/g,t={},s;s=e.exec(n);){var i=Di(s[1]),r=Di(s[2]);i===null||r===null||i in t||(t[i]=r)}return t}function ba(n,e){e=e||"";var t=[],s,i;typeof e!="string"&&(e="?");for(i in n)if(ya.call(n,i)){if(s=n[i],!s&&(s===null||s===wa||isNaN(s))&&(s=""),i=qi(i),s=qi(s),i===null||s===null)continue;t.push(i+"="+s)}return t.length?e+t.join("&"):""}Qn.stringify=ba;Qn.parse=Sa});var Ki=R((Ku,Fi)=>{"use strict";var Ui=Oi(),$t=Ti(),Ca=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,Ai=/[\n\r\t]/g,Pa=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,Ni=/:\d+$/,Ma=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,Ea=/^[a-zA-Z]:/;function es(n){return(n||"").toString().replace(Ca,"")}var Zn=[["#","hash"],["?","query"],function(e,t){return Re(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],ji={hash:1,query:1};function Li(n){var e;typeof window!="undefined"?e=window:typeof global!="undefined"?e=global:typeof self!="undefined"?e=self:e={};var t=e.location||{};n=n||t;var s={},i=typeof n,r;if(n.protocol==="blob:")s=new ke(unescape(n.pathname),{});else if(i==="string"){s=new ke(n,{});for(r in ji)delete s[r]}else if(i==="object"){for(r in n)r in ji||(s[r]=n[r]);s.slashes===void 0&&(s.slashes=Pa.test(n.href))}return s}function Re(n){return n==="file:"||n==="ftp:"||n==="http:"||n==="https:"||n==="ws:"||n==="wss:"}function xi(n,e){n=es(n),n=n.replace(Ai,""),e=e||{};var t=Ma.exec(n),s=t[1]?t[1].toLowerCase():"",i=!!t[2],r=!!t[3],o=0,a;return i?r?(a=t[2]+t[3]+t[4],o=t[2].length+t[3].length):(a=t[2]+t[4],o=t[2].length):r?(a=t[3]+t[4],o=t[3].length):a=t[4],s==="file:"?o>=2&&(a=a.slice(2)):Re(s)?a=t[4]:s?i&&(a=a.slice(2)):o>=2&&Re(e.protocol)&&(a=t[4]),{protocol:s,slashes:i||Re(s),slashesCount:o,rest:a}}function Ia(n,e){if(n==="")return e;for(var t=(e||"/").split("/").slice(0,-1).concat(n.split("/")),s=t.length,i=t[s-1],r=!1,o=0;s--;)t[s]==="."?t.splice(s,1):t[s]===".."?(t.splice(s,1),o++):o&&(s===0&&(r=!0),t.splice(s,1),o--);return r&&t.unshift(""),(i==="."||i==="..")&&t.push(""),t.join("/")}function ke(n,e,t){if(n=es(n),n=n.replace(Ai,""),!(this instanceof ke))return new ke(n,e,t);var s,i,r,o,a,d,c=Zn.slice(),u=typeof e,l=this,h=0;for(u!=="object"&&u!=="string"&&(t=e,e=null),t&&typeof t!="function"&&(t=$t.parse),e=Li(e),i=xi(n||"",e),s=!i.protocol&&!i.slashes,l.slashes=i.slashes||s&&e.slashes,l.protocol=i.protocol||e.protocol||"",n=i.rest,(i.protocol==="file:"&&(i.slashesCount!==2||Ea.test(n))||!i.slashes&&(i.protocol||i.slashesCount<2||!Re(l.protocol)))&&(c[3]=[/(.*)/,"pathname"]);h<c.length;h++){if(o=c[h],typeof o=="function"){n=o(n,l);continue}r=o[0],d=o[1],r!==r?l[d]=n:typeof r=="string"?(a=r==="@"?n.lastIndexOf(r):n.indexOf(r),~a&&(typeof o[2]=="number"?(l[d]=n.slice(0,a),n=n.slice(a+o[2])):(l[d]=n.slice(a),n=n.slice(0,a)))):(a=r.exec(n))&&(l[d]=a[1],n=n.slice(0,a.index)),l[d]=l[d]||s&&o[3]&&e[d]||"",o[4]&&(l[d]=l[d].toLowerCase())}t&&(l.query=t(l.query)),s&&e.slashes&&l.pathname.charAt(0)!=="/"&&(l.pathname!==""||e.pathname!=="")&&(l.pathname=Ia(l.pathname,e.pathname)),l.pathname.charAt(0)!=="/"&&Re(l.protocol)&&(l.pathname="/"+l.pathname),Ui(l.port,l.protocol)||(l.host=l.hostname,l.port=""),l.username=l.password="",l.auth&&(a=l.auth.indexOf(":"),~a?(l.username=l.auth.slice(0,a),l.username=encodeURIComponent(decodeURIComponent(l.username)),l.password=l.auth.slice(a+1),l.password=encodeURIComponent(decodeURIComponent(l.password))):l.username=encodeURIComponent(decodeURIComponent(l.auth)),l.auth=l.password?l.username+":"+l.password:l.username),l.origin=l.protocol!=="file:"&&Re(l.protocol)&&l.host?l.protocol+"//"+l.host:"null",l.href=l.toString()}function Ra(n,e,t){var s=this;switch(n){case"query":typeof e=="string"&&e.length&&(e=(t||$t.parse)(e)),s[n]=e;break;case"port":s[n]=e,Ui(e,s.protocol)?e&&(s.host=s.hostname+":"+e):(s.host=s.hostname,s[n]="");break;case"hostname":s[n]=e,s.port&&(e+=":"+s.port),s.host=e;break;case"host":s[n]=e,Ni.test(e)?(e=e.split(":"),s.port=e.pop(),s.hostname=e.join(":")):(s.hostname=e,s.port="");break;case"protocol":s.protocol=e.toLowerCase(),s.slashes=!t;break;case"pathname":case"hash":if(e){var i=n==="pathname"?"/":"#";s[n]=e.charAt(0)!==i?i+e:e}else s[n]=e;break;case"username":case"password":s[n]=encodeURIComponent(e);break;case"auth":var r=e.indexOf(":");~r?(s.username=e.slice(0,r),s.username=encodeURIComponent(decodeURIComponent(s.username)),s.password=e.slice(r+1),s.password=encodeURIComponent(decodeURIComponent(s.password))):s.username=encodeURIComponent(decodeURIComponent(e))}for(var o=0;o<Zn.length;o++){var a=Zn[o];a[4]&&(s[a[1]]=s[a[1]].toLowerCase())}return s.auth=s.password?s.username+":"+s.password:s.username,s.origin=s.protocol!=="file:"&&Re(s.protocol)&&s.host?s.protocol+"//"+s.host:"null",s.href=s.toString(),s}function ka(n){(!n||typeof n!="function")&&(n=$t.stringify);var e,t=this,s=t.host,i=t.protocol;i&&i.charAt(i.length-1)!==":"&&(i+=":");var r=i+(t.protocol&&t.slashes||Re(t.protocol)?"//":"");return t.username?(r+=t.username,t.password&&(r+=":"+t.password),r+="@"):t.password?(r+=":"+t.password,r+="@"):t.protocol!=="file:"&&Re(t.protocol)&&!s&&t.pathname!=="/"&&(r+="@"),(s[s.length-1]===":"||Ni.test(t.hostname)&&!t.port)&&(s+=":"),r+=s+t.pathname,e=typeof t.query=="object"?n(t.query):t.query,e&&(r+=e.charAt(0)!=="?"?"?"+e:e),t.hash&&(r+=t.hash),r}ke.prototype={set:Ra,toString:ka};ke.extractProtocol=xi;ke.location=Li;ke.trimLeft=es;ke.qs=$t;Fi.exports=ke});var ts=R(Qe=>{"use strict";var Oa=Qe&&Qe.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Qe,"__esModule",{value:!0});Qe.URLExt=void 0;var Da=Wt(),Ht=Oa(Ki()),zi;(function(n){function e(c){if(typeof document!="undefined"&&document){let u=document.createElement("a");return u.href=c,u}return(0,Ht.default)(c)}n.parse=e;function t(c){return(0,Ht.default)(c).hostname}n.getHostName=t;function s(c){return c&&e(c).toString()}n.normalize=s;function i(...c){let u=(0,Ht.default)(c[0],{}),l=u.protocol===""&&u.slashes;l&&(u=(0,Ht.default)(c[0],"https:"+c[0]));let h=`${l?"":u.protocol}${u.slashes?"//":""}${u.auth}${u.auth?"@":""}${u.host}`,v=Da.posix.join(`${h&&u.pathname[0]!=="/"?"/":""}${u.pathname}`,...c.slice(1));return`${h}${v==="."?"":v}`}n.join=i;function r(c){return i(...c.split("/").map(encodeURIComponent))}n.encodeParts=r;function o(c){let u=Object.keys(c).filter(l=>l.length>0);return u.length?"?"+u.map(l=>{let h=encodeURIComponent(String(c[l]));return l+(h?"="+h:"")}).join("&"):""}n.objectToQueryString=o;function a(c){return c.replace(/^\?/,"").split("&").reduce((u,l)=>{let[h,v]=l.split("=");return h.length>0&&(u[h]=decodeURIComponent(v||"")),u},{})}n.queryStringToObject=a;function d(c,u=!1){let{protocol:l}=e(c);return(!l||c.toLowerCase().indexOf(l)!==0)&&(u?c.indexOf("//")!==0:c.indexOf("/")!==0)}n.isLocal=d})(zi||(Qe.URLExt=zi={}))});var Vi=R((exports,module)=>{"use strict";var __importDefault=exports&&exports.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(exports,"__esModule",{value:!0});exports.PageConfig=void 0;var coreutils_1=Y(),minimist_1=__importDefault(Ei()),url_1=ts(),PageConfig;(function(PageConfig){function getOption(name){if(configData)return configData[name]||getBodyData(name);configData=Object.create(null);let found=!1;if(typeof document!="undefined"&&document){let n=document.getElementById("jupyter-config-data");n&&(configData=JSON.parse(n.textContent||""),found=!0)}if(!found&&typeof process!="undefined"&&process.argv)try{let cli=(0,minimist_1.default)(process.argv.slice(2)),path=Wt(),fullPath="";"jupyter-config-data"in cli?fullPath=path.resolve(cli["jupyter-config-data"]):"JUPYTER_CONFIG_DATA"in process.env&&(fullPath=path.resolve(process.env.JUPYTER_CONFIG_DATA)),fullPath&&(configData=eval("require")(fullPath))}catch(n){console.error(n)}if(!coreutils_1.JSONExt.isObject(configData))configData=Object.create(null);else for(let n in configData)typeof configData[n]!="string"&&(configData[n]=JSON.stringify(configData[n]));return configData[name]||getBodyData(name)}PageConfig.getOption=getOption;function setOption(n,e){let t=getOption(n);return configData[n]=e,t}PageConfig.setOption=setOption;function getBaseUrl(){return url_1.URLExt.normalize(getOption("baseUrl")||"/")}PageConfig.getBaseUrl=getBaseUrl;function getTreeUrl(){return url_1.URLExt.join(getBaseUrl(),getOption("treeUrl"))}PageConfig.getTreeUrl=getTreeUrl;function getShareUrl(){return url_1.URLExt.normalize(getOption("shareUrl")||getBaseUrl())}PageConfig.getShareUrl=getShareUrl;function getTreeShareUrl(){return url_1.URLExt.normalize(url_1.URLExt.join(getShareUrl(),getOption("treeUrl")))}PageConfig.getTreeShareUrl=getTreeShareUrl;function getUrl(n){var e,t,s,i;let r=n.toShare?getShareUrl():getBaseUrl(),o=(e=n.mode)!==null&&e!==void 0?e:getOption("mode"),a=(t=n.workspace)!==null&&t!==void 0?t:getOption("workspace"),d=o==="single-document"?"doc":"lab";r=url_1.URLExt.join(r,d),a!==PageConfig.defaultWorkspace&&(r=url_1.URLExt.join(r,"workspaces",encodeURIComponent((s=getOption("workspace"))!==null&&s!==void 0?s:PageConfig.defaultWorkspace)));let c=(i=n.treePath)!==null&&i!==void 0?i:getOption("treePath");return c&&(r=url_1.URLExt.join(r,"tree",url_1.URLExt.encodeParts(c))),r}PageConfig.getUrl=getUrl,PageConfig.defaultWorkspace="default";function getWsUrl(n){let e=getOption("wsUrl");if(!e){if(n=n?url_1.URLExt.normalize(n):getBaseUrl(),n.indexOf("http")!==0)return"";e="ws"+n.slice(4)}return url_1.URLExt.normalize(e)}PageConfig.getWsUrl=getWsUrl;function getNBConvertURL({path:n,format:e,download:t}){let s=url_1.URLExt.encodeParts(n),i=url_1.URLExt.join(getBaseUrl(),"nbconvert",e,s);return t?i+"?download=true":i}PageConfig.getNBConvertURL=getNBConvertURL;function getToken(){return getOption("token")||getBodyData("jupyterApiToken")}PageConfig.getToken=getToken;function getNotebookVersion(){let n=getOption("notebookVersion");return n===""?[0,0,0]:JSON.parse(n)}PageConfig.getNotebookVersion=getNotebookVersion;let configData=null;function getBodyData(n){if(typeof document=="undefined"||!document.body)return"";let e=document.body.dataset[n];return typeof e=="undefined"?"":decodeURIComponent(e)}let Extension;(function(n){function e(i){try{let r=getOption(i);if(r)return JSON.parse(r)}catch(r){console.warn(`Unable to parse ${i}.`,r)}return[]}n.deferred=e("deferredExtensions"),n.disabled=e("disabledExtensions");function t(i){let r=i.indexOf(":"),o="";return r!==-1&&(o=i.slice(0,r)),n.deferred.some(a=>a===i||o&&a===o)}n.isDeferred=t;function s(i){let r=i.indexOf(":"),o="";return r!==-1&&(o=i.slice(0,r)),n.disabled.some(a=>a===i||o&&a===o)}n.isDisabled=s})(Extension=PageConfig.Extension||(PageConfig.Extension={}))})(PageConfig||(exports.PageConfig=PageConfig={}))});var Wi=R(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.PathExt=void 0;var Le=Wt(),Bi;(function(n){function e(...l){let h=Le.posix.join(...l);return h==="."?"":u(h)}n.join=e;function t(...l){let h=Le.posix.join(...l);return h==="."?"":h}n.joinWithLeadingSlash=t;function s(l,h){return Le.posix.basename(l,h)}n.basename=s;function i(l){let h=u(Le.posix.dirname(l));return h==="."?"":h}n.dirname=i;function r(l){return Le.posix.extname(l)}n.extname=r;function o(l){return l===""?"":u(Le.posix.normalize(l))}n.normalize=o;function a(...l){return u(Le.posix.resolve(...l))}n.resolve=a;function d(l,h){return u(Le.posix.relative(l,h))}n.relative=d;function c(l){return l.length>0&&l.indexOf(".")!==0&&(l=`.${l}`),l}n.normalizeExtension=c;function u(l){return l.indexOf("/")===0&&(l=l.slice(1)),l}n.removeSlash=u})(Bi||(Jt.PathExt=Bi={}))});var $i=R(ns=>{"use strict";Object.defineProperty(ns,"__esModule",{value:!0});ns.signalToPromise=Ta;var qa=Y();function Ta(n,e){let t=new qa.PromiseDelegate;function s(){n.disconnect(i)}function i(r,o){s(),t.resolve([r,o])}return n.connect(i),(e!=null?e:0)>0&&setTimeout(()=>{s(),t.reject(`Signal not emitted within ${e} ms.`)},e),t.promise}});var Ji=R(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.Text=void 0;var Hi;(function(n){let e=2>1;function t(o,a){if(!e)return o;let d=o;for(let c=0;c+1<a.length&&c<o;c++){let u=a.charCodeAt(c);if(u>=55296&&u<=56319){let l=a.charCodeAt(c+1);l>=56320&&l<=57343&&(d--,c++)}}return d}n.jsIndexToCharIndex=t;function s(o,a){if(!e)return o;let d=o;for(let c=0;c+1<a.length&&c<d;c++){let u=a.charCodeAt(c);if(u>=55296&&u<=56319){let l=a.charCodeAt(c+1);l>=56320&&l<=57343&&(d++,c++)}}return d}n.charIndexToJsIndex=s;function i(o,a=!1){return o.replace(/^(\w)|[\s-_:]+(\w)/g,function(d,c,u){return u?u.toUpperCase():a?c.toUpperCase():c.toLowerCase()})}n.camelCase=i;function r(o){return(o||"").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}n.titleCase=r})(Hi||(Gt.Text=Hi={}))});var Xi=R(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.Time=void 0;var ja=[{name:"years",milliseconds:365*24*60*60*1e3},{name:"months",milliseconds:30*24*60*60*1e3},{name:"days",milliseconds:24*60*60*1e3},{name:"hours",milliseconds:60*60*1e3},{name:"minutes",milliseconds:60*1e3},{name:"seconds",milliseconds:1e3}],Gi;(function(n){function e(s,i="long"){let r=document.documentElement.lang||"en",o=new Intl.RelativeTimeFormat(r,{numeric:"auto",style:i}),a=new Date(s).getTime()-Date.now();for(let d of ja){let c=Math.ceil(a/d.milliseconds);if(c!==0)return o.format(c,d.name)}return o.format(0,"seconds")}n.formatHuman=e;function t(s){let i=document.documentElement.lang||"en";return new Intl.DateTimeFormat(i,{dateStyle:"short",timeStyle:"short"}).format(new Date(s))}n.format=t})(Gi||(Xt.Time=Gi={}))});var Yi=R(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.JupyterPluginRegistry=void 0;var Ua=Y(),Aa=5e3,ss=class extends Ua.PluginRegistry{constructor(e){var t;super(e),this._pluginData=new Map,this._expectedActivationTime=(t=e==null?void 0:e.expectedActivationTime)!==null&&t!==void 0?t:Aa}registerPlugin(e){return this._pluginData.set(e.id,e),super.registerPlugin(e)}async activatePlugin(e){let t=performance.now(),s=setTimeout(()=>{console.warn(`Plugin ${e} is taking too long to activate.`)},this._expectedActivationTime);try{let i=await super.activatePlugin(e);clearTimeout(s);let o=performance.now()-t;if(o>=this._expectedActivationTime){let a=this._getDependentCount(e);console.warn(`Plugin ${e} (with ${a} dependants) took ${o.toFixed(2)}ms to activate.`)}return i}catch(i){throw clearTimeout(s),console.error(`Error activating plugin: ${e}`,i),i}}_getDependentCount(e){var t;let s=this._pluginData.get(e);if(!(s!=null&&s.provides))return 0;let i=s.provides.name,r=0;for(let[o,a]of this._pluginData.entries()){if(o===e)continue;((t=a.requires)===null||t===void 0?void 0:t.filter(c=>!!c).some(c=>c.name===i))&&r++}return r}};Yt.JupyterPluginRegistry=ss});var te=R(ie=>{"use strict";var Na=ie&&ie.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Pe=ie&&ie.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Na(e,n,t)};Object.defineProperty(ie,"__esModule",{value:!0});Pe(mi(),ie);Pe(yi(),ie);Pe(wi(),ie);Pe(bi(),ie);Pe(Vi(),ie);Pe(Wi(),ie);Pe($i(),ie);Pe(Ji(),ie);Pe(Xi(),ie);Pe(ts(),ie);Pe(Yi(),ie)});var Ze=R(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.supportedKernelWebSocketProtocols=void 0;V.createMessage=xa;V.isStreamMsg=Fa;V.isDisplayDataMsg=Ka;V.isUpdateDisplayDataMsg=za;V.isExecuteInputMsg=Va;V.isExecuteResultMsg=Ba;V.isErrorMsg=Wa;V.isStatusMsg=$a;V.isClearOutputMsg=Ha;V.isDebugEventMsg=Ja;V.isCommOpenMsg=Ga;V.isCommCloseMsg=Xa;V.isCommMsgMsg=Ya;V.isInfoRequestMsg=Qa;V.isExecuteReplyMsg=Za;V.isDebugRequestMsg=el;V.isDebugReplyMsg=tl;V.isInputRequestMsg=nl;V.isInputReplyMsg=sl;var La=Y();function xa(n){var e,t,s,i,r,o;return{buffers:(e=n.buffers)!==null&&e!==void 0?e:[],channel:n.channel,content:n.content,header:{date:new Date().toISOString(),msg_id:(t=n.msgId)!==null&&t!==void 0?t:La.UUID.uuid4(),msg_type:n.msgType,session:n.session,username:(s=n.username)!==null&&s!==void 0?s:"",subshell_id:(i=n.subshellId)!==null&&i!==void 0?i:null,version:"5.2"},metadata:(r=n.metadata)!==null&&r!==void 0?r:{},parent_header:(o=n.parentHeader)!==null&&o!==void 0?o:{}}}function Fa(n){return n.header.msg_type==="stream"}function Ka(n){return n.header.msg_type==="display_data"}function za(n){return n.header.msg_type==="update_display_data"}function Va(n){return n.header.msg_type==="execute_input"}function Ba(n){return n.header.msg_type==="execute_result"}function Wa(n){return n.header.msg_type==="error"}function $a(n){return n.header.msg_type==="status"}function Ha(n){return n.header.msg_type==="clear_output"}function Ja(n){return n.header.msg_type==="debug_event"}function Ga(n){return n.header.msg_type==="comm_open"}function Xa(n){return n.header.msg_type==="comm_close"}function Ya(n){return n.header.msg_type==="comm_msg"}function Qa(n){return n.header.msg_type==="kernel_info_request"}function Za(n){return n.header.msg_type==="execute_reply"}function el(n){return n.header.msg_type==="debug_request"}function tl(n){return n.header.msg_type==="debug_reply"}function nl(n){return n.header.msg_type==="input_request"}function sl(n){return n.header.msg_type==="input_reply"}var Qi;(function(n){n.v1KernelWebsocketJupyterOrg="v1.kernel.websocket.jupyter.org"})(Qi||(V.supportedKernelWebSocketProtocols=Qi={}))});var er=R(Oe=>{"use strict";var il=Oe&&Oe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),rl=Oe&&Oe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),ol=Oe&&Oe.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&il(e,n,t);return rl(e,n),e};Object.defineProperty(Oe,"__esModule",{value:!0});Oe.serialize=al;Oe.deserialize=ll;var Zi=ol(Ze());function al(n,e=""){switch(e){case Zi.supportedKernelWebSocketProtocols.v1KernelWebsocketJupyterOrg:return et.serializeV1KernelWebsocketJupyterOrg(n);default:return et.serializeDefault(n)}}function ll(n,e=""){switch(e){case Zi.supportedKernelWebSocketProtocols.v1KernelWebsocketJupyterOrg:return et.deserializeV1KernelWebsocketJupyterOrg(n);default:return et.deserializeDefault(n)}}var et;(function(n){function e(a){let d,c=new DataView(a),u=Number(c.getBigUint64(0,!0)),l=[];for(let C=0;C<u;C++)l.push(Number(c.getBigUint64(8*(C+1),!0)));let h=new TextDecoder("utf8"),v=h.decode(a.slice(l[0],l[1])),m=JSON.parse(h.decode(a.slice(l[1],l[2]))),q=JSON.parse(h.decode(a.slice(l[2],l[3]))),I=JSON.parse(h.decode(a.slice(l[3],l[4]))),T=JSON.parse(h.decode(a.slice(l[4],l[5]))),A=[];for(let C=5;C<l.length-1;C++)A.push(new DataView(a.slice(l[C],l[C+1])));return d={channel:v,header:m,parent_header:q,metadata:I,content:T,buffers:A},d}n.deserializeV1KernelWebsocketJupyterOrg=e;function t(a){let d=JSON.stringify(a.header),c=a.parent_header==null?"{}":JSON.stringify(a.parent_header),u=JSON.stringify(a.metadata),l=JSON.stringify(a.content),h=a.buffers!==void 0?a.buffers:[],v=5+h.length+1,m=[];m.push(8*(1+v)),m.push(a.channel.length+m[m.length-1]);let q=new TextEncoder,I=q.encode(a.channel),T=q.encode(d),A=q.encode(c),C=q.encode(u),w=q.encode(l),k=new Uint8Array(I.length+T.length+A.length+C.length+w.length);k.set(I),k.set(T,I.length),k.set(A,I.length+T.length),k.set(C,I.length+T.length+A.length),k.set(w,I.length+T.length+A.length+C.length);for(let f of[T.length,A.length,C.length,w.length])m.push(f+m[m.length-1]);let N=0;for(let f of h){let y=f.byteLength;m.push(y+m[m.length-1]),N+=y}let j=new Uint8Array(8*(1+v)+k.byteLength+N),D=new ArrayBuffer(8),U=new DataView(D);U.setBigUint64(0,BigInt(v),!0),j.set(new Uint8Array(D),0);for(let f=0;f<m.length;f++)U.setBigUint64(0,BigInt(m[f]),!0),j.set(new Uint8Array(D),8*(f+1));j.set(k,m[0]);for(let f=0;f<h.length;f++){let y=h[f];j.set(new Uint8Array(ArrayBuffer.isView(y)?y.buffer:y),m[5+f])}return j.buffer}n.serializeV1KernelWebsocketJupyterOrg=t;function s(a){let d;return typeof a=="string"?d=JSON.parse(a):d=r(a),d}n.deserializeDefault=s;function i(a){var d;let c;return!((d=a.buffers)===null||d===void 0)&&d.length?c=o(a):c=JSON.stringify(a),c}n.serializeDefault=i;function r(a){let d=new DataView(a),c=d.getUint32(0),u=[];if(c<2)throw new Error("Invalid incoming Kernel Message");for(let v=1;v<=c;v++)u.push(d.getUint32(v*4));let l=new Uint8Array(a.slice(u[0],u[1])),h=JSON.parse(new TextDecoder("utf8").decode(l));h.buffers=[];for(let v=1;v<c;v++){let m=u[v],q=u[v+1]||a.byteLength;h.buffers.push(new DataView(a.slice(m,q)))}return h}function o(a){let d=[],c=[],u=new TextEncoder,l=[];a.buffers!==void 0&&(l=a.buffers,delete a.buffers);let h=u.encode(JSON.stringify(a));c.push(h.buffer);for(let I=0;I<l.length;I++){let T=l[I];c.push(ArrayBuffer.isView(T)?T.buffer:T)}let v=c.length;d.push(4*(v+1));for(let I=0;I+1<c.length;I++)d.push(d[d.length-1]+c[I].byteLength);let m=new Uint8Array(d[d.length-1]+c[c.length-1].byteLength),q=new DataView(m.buffer);q.setUint32(0,v);for(let I=0;I<d.length;I++)q.setUint32(4*(I+1),d[I]);for(let I=0;I<c.length;I++)m.set(new Uint8Array(c[I]),d[I]);return m.buffer}})(et||(et={}))});var tr=R(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.default=WebSocket});var de=R(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});Zt.ServerConnection=void 0;var xe=te(),nr=er(),rs;typeof window=="undefined"?rs=tr():rs=WebSocket;var os;(function(n){function e(r){return Qt.makeSettings(r)}n.makeSettings=e;function t(r,o,a){return Qt.handleRequest(r,o,a)}n.makeRequest=t;class s extends Error{static async create(o){try{let a=await o.json(),{message:d,traceback:c}=a;return c&&console.error(c),new s(o,d!=null?d:s._defaultMessage(o),c!=null?c:"")}catch(a){return console.debug(a),new s(o)}}constructor(o,a=s._defaultMessage(o),d=""){super(a),this.response=o,this.traceback=d}static _defaultMessage(o){return`Invalid response: ${o.status} ${o.statusText}`}}n.ResponseError=s;class i extends TypeError{constructor(o){super(o.message),this.stack=o.stack}}n.NetworkError=i})(os||(Zt.ServerConnection=os={}));var Qt;(function(n){function e(i={}){var r;let o=xe.PageConfig.getBaseUrl(),a=xe.PageConfig.getWsUrl(),d=xe.URLExt.normalize(i.baseUrl)||o,c=i.wsUrl;!c&&d===o&&(c=a),!c&&d.indexOf("http")===0&&(c="ws"+d.slice(4)),c=c!=null?c:a;let u=xe.PageConfig.getOption("appendToken").toLowerCase(),l;return u===""?l=typeof window=="undefined"||typeof process!="undefined"&&((r=process==null?void 0:process.env)===null||r===void 0?void 0:r.JEST_WORKER_ID)!==void 0||xe.URLExt.getHostName(o)!==xe.URLExt.getHostName(c):l=u==="true",{init:{cache:"no-store",credentials:"same-origin"},fetch,Headers,Request,WebSocket:rs,token:xe.PageConfig.getToken(),appUrl:xe.PageConfig.getOption("appUrl"),appendToken:l,serializer:{serialize:nr.serialize,deserialize:nr.deserialize},...i,baseUrl:d,wsUrl:c}}n.makeSettings=e;function t(i,r,o){var a;if(i.indexOf(o.baseUrl)!==0)throw new Error("Can only be used for notebook server requests");((a=r.cache)!==null&&a!==void 0?a:o.init.cache)==="no-store"&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());let c=new o.Request(i,{...o.init,...r}),u=!1;if(o.token&&(u=!0,c.headers.append("Authorization",`token ${o.token}`)),typeof document!="undefined"){let l=s("_xsrf");l!==void 0&&(u=!0,c.headers.append("X-XSRFToken",l))}return!c.headers.has("Content-Type")&&u&&c.headers.set("Content-Type","application/json"),o.fetch.call(null,c).catch(l=>{throw new os.NetworkError(l)})}n.handleRequest=t;function s(i){let r="";try{r=document.cookie}catch{return}let o=r.match("\\b"+i+"=([^;]*)\\b");return o==null?void 0:o[1]}})(Qt||(Qt={}))});var He=R(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});en.BaseManager=void 0;var sr=ee(),cl=de(),as=class{constructor(e){var t;this._isDisposed=!1,this._disposed=new sr.Signal(this),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:cl.ServerConnection.makeSettings()}get disposed(){return this._disposed}get isDisposed(){return this._isDisposed}get isActive(){return!0}dispose(){this.isDisposed||(this._isDisposed=!0,this._disposed.emit(void 0),sr.Signal.clearData(this))}};en.BaseManager=as});var rr=R(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.ConfigWithDefaults=Fe.ConfigSection=Fe.ConfigSectionManager=void 0;var ul=te(),tt=Ae(),dl="api/config",ls=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:tt.ServerConnection.makeSettings()}async create(e){let t=new tn({...e,serverSettings:this.serverSettings});return await t.load(),t}};Fe.ConfigSectionManager=ls;var ir;(function(n){async function e(i){if(!t){let o=new tn(i);return await o.load(),o}return await t.create(i)}n.create=e;let t;function s(i){if(t)throw new Error("ConfigSectionManager already set. If you would like to create a config section, use the `IConfigSectionManager` token in a plugin.");t=i}n._setConfigSectionManager=s})(ir||(Fe.ConfigSection=ir={}));var tn=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:tt.ServerConnection.makeSettings(),this._name=e.name}get data(){return this._data}async load(){let e=await tt.ServerConnection.makeRequest(this._url,{},this.serverSettings);if(e.status!==200)throw await tt.ServerConnection.ResponseError.create(e);this._data=await e.json()}async update(e){this._data={...this._data,...e};let t={method:"PATCH",body:JSON.stringify(e)},s=await tt.ServerConnection.makeRequest(this._url,t,this.serverSettings);if(s.status!==200)throw await tt.ServerConnection.ResponseError.create(s);return this._data=await s.json(),this._data}get _url(){return ul.URLExt.join(this.serverSettings.baseUrl,dl,encodeURIComponent(this._name))}},cs=class{constructor(e){var t,s;this._className="",this._section=e.section,this._defaults=(t=e.defaults)!==null&&t!==void 0?t:{},this._className=(s=e.className)!==null&&s!==void 0?s:""}get(e){let t=this._classData();return e in t?t[e]:this._defaults[e]}set(e,t){let s={};if(s[e]=t,this._className){let i={};return i[this._className]=s,this._section.update(i)}else return this._section.update(s)}_classData(){let e=this._section.data;return this._className&&this._className in e?e[this._className]:e}};Fe.ConfigWithDefaults=cs});var or=R(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});nn.ConnectionStatus=void 0;var us=class{constructor(){this.isConnected=!0}};nn.ConnectionStatus=us});var rn=R((sn,ar)=>{(function(n,e){typeof sn=="object"&&typeof ar!="undefined"?e(sn,ee()):typeof define=="function"&&define.amd?define(["exports","@lumino/signaling"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_disposable={},n.lumino_signaling))})(sn,function(n,e){"use strict";class t{constructor(a){this._fn=a}get isDisposed(){return!this._fn}dispose(){if(!this._fn)return;let a=this._fn;this._fn=null,a()}}class s extends t{constructor(){super(...arguments),this._disposed=new e.Signal(this)}get disposed(){return this._disposed}dispose(){this.isDisposed||(super.dispose(),this._disposed.emit(void 0),e.Signal.clearData(this))}}class i{constructor(){this._isDisposed=!1,this._items=new Set}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,this._items.forEach(a=>{a.dispose()}),this._items.clear())}contains(a){return this._items.has(a)}add(a){this._items.add(a)}remove(a){this._items.delete(a)}clear(){this._items.clear()}}(function(o){function a(d){let c=new o;for(let u of d)c.add(u);return c}o.from=a})(i||(i={}));class r extends i{constructor(){super(...arguments),this._disposed=new e.Signal(this)}get disposed(){return this._disposed}dispose(){this.isDisposed||(super.dispose(),this._disposed.emit(void 0),e.Signal.clearData(this))}}(function(o){function a(d){let c=new o;for(let u of d)c.add(u);return c}o.from=a})(r||(r={})),n.DisposableDelegate=t,n.DisposableSet=i,n.ObservableDisposableDelegate=s,n.ObservableDisposableSet=r})});var lt=R(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});ds.validateProperty=hl;function hl(n,e,t,s=[]){if(!n.hasOwnProperty(e))throw Error(`Missing property '${e}'`);let i=n[e];if(t!==void 0){let r=!0;switch(t){case"array":r=Array.isArray(i);break;case"object":r=typeof i!="undefined";break;default:r=typeof i===t}if(!r)throw new Error(`Property '${e}' is not of type '${t}'`);if(s.length>0){let o=!0;switch(t){case"string":case"number":case"boolean":o=s.includes(i);break;default:o=s.findIndex(a=>a===i)>=0;break}if(!o)throw new Error(`Property '${e}' is not one of the valid values ${JSON.stringify(s)}`)}}}});var lr=R(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.validateContentsModel=fl;on.validateCheckpointModel=_l;var De=lt();function fl(n){(0,De.validateProperty)(n,"name","string"),(0,De.validateProperty)(n,"path","string"),(0,De.validateProperty)(n,"type","string"),(0,De.validateProperty)(n,"created","string"),(0,De.validateProperty)(n,"last_modified","string"),(0,De.validateProperty)(n,"mimetype","object"),(0,De.validateProperty)(n,"content","object"),(0,De.validateProperty)(n,"format","object")}function _l(n){(0,De.validateProperty)(n,"id","string"),(0,De.validateProperty)(n,"last_modified","string")}});var _s=R(ne=>{"use strict";var pl=ne&&ne.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),gl=ne&&ne.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),ml=ne&&ne.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&pl(e,n,t);return gl(e,n),e};Object.defineProperty(ne,"__esModule",{value:!0});ne.RestContentProvider=ne.ContentProviderRegistry=ne.Drive=ne.ContentsManager=ne.Contents=void 0;var he=te(),vl=rn(),ct=ee(),W=Ae(),Ne=ml(lr()),yl="api/contents",wl="files",cr;(function(n){function e(s){Ne.validateContentsModel(s)}n.validateContentsModel=e;function t(s){Ne.validateCheckpointModel(s)}n.validateCheckpointModel=t})(cr||(ne.Contents=cr={}));var hs=class{constructor(e={}){var t,s;this._isDisposed=!1,this._additionalDrives=new Map,this._fileChanged=new ct.Signal(this);let i=this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:W.ServerConnection.makeSettings();this._defaultDrive=(s=e.defaultDrive)!==null&&s!==void 0?s:new an({serverSettings:i}),this._defaultDrive.fileChanged.connect(this._onFileChanged,this)}get defaultDrive(){return this._defaultDrive}get fileChanged(){return this._fileChanged}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,ct.Signal.clearData(this))}addDrive(e){this._additionalDrives.set(e.name,e),e.fileChanged.connect(this._onFileChanged,this)}getSharedModelFactory(e,t){var s,i;let[r]=this._driveForPath(e),o=(s=r.contentProviderRegistry)===null||s===void 0?void 0:s.getProvider(t==null?void 0:t.contentProviderId);return o!=null&&o.sharedModelFactory?o.sharedModelFactory:(i=r.sharedModelFactory)!==null&&i!==void 0?i:null}localPath(e){let t=e.split("/"),s=t[0].split(":");return s.length===1||!this._additionalDrives.has(s[0])?he.PathExt.removeSlash(e):he.PathExt.join(s.slice(1).join(":"),...t.slice(1))}normalize(e){let t=e.split(":");return t.length===1?he.PathExt.normalize(e):`${t[0]}:${he.PathExt.normalize(t.slice(1).join(":"))}`}resolvePath(e,t){let s=this.driveName(e),i=this.localPath(e),r=he.PathExt.resolve("/",i,t);return s?`${s}:${r}`:r}driveName(e){let s=e.split("/")[0].split(":");return s.length===1?"":this._additionalDrives.has(s[0])?s[0]:""}get(e,t){let[s,i]=this._driveForPath(e);return s.get(i,t).then(r=>{let o=[];if(r.type==="directory"&&r.content){for(let a of r.content)o.push({...a,path:this._toGlobalPath(s,a.path)});return{...r,path:this._toGlobalPath(s,i),content:o,serverPath:r.path}}else return{...r,path:this._toGlobalPath(s,i),serverPath:r.path}})}getDownloadUrl(e){let[t,s]=this._driveForPath(e);return t.getDownloadUrl(s)}newUntitled(e={}){if(e.path){let t=this.normalize(e.path),[s,i]=this._driveForPath(t);return s.newUntitled({...e,path:i}).then(r=>({...r,path:he.PathExt.join(t,r.name),serverPath:r.path}))}else return this._defaultDrive.newUntitled(e)}delete(e){let[t,s]=this._driveForPath(e);return t.delete(s)}rename(e,t){let[s,i]=this._driveForPath(e),[r,o]=this._driveForPath(t);if(s!==r)throw Error("ContentsManager: renaming files must occur within a Drive");return s.rename(i,o).then(a=>({...a,path:this._toGlobalPath(s,o),serverPath:a.path}))}save(e,t={}){let s=this.normalize(e),[i,r]=this._driveForPath(e);return i.save(r,{...t,path:r}).then(o=>({...o,path:s,serverPath:o.path}))}copy(e,t){let[s,i]=this._driveForPath(e),[r,o]=this._driveForPath(t);if(s===r)return s.copy(i,o).then(a=>({...a,path:this._toGlobalPath(s,a.path),serverPath:a.path}));throw Error("Copying files between drives is not currently implemented")}createCheckpoint(e){let[t,s]=this._driveForPath(e);return t.createCheckpoint(s)}listCheckpoints(e){let[t,s]=this._driveForPath(e);return t.listCheckpoints(s)}restoreCheckpoint(e,t){let[s,i]=this._driveForPath(e);return s.restoreCheckpoint(i,t)}deleteCheckpoint(e,t){let[s,i]=this._driveForPath(e);return s.deleteCheckpoint(i,t)}_toGlobalPath(e,t){return e===this._defaultDrive?he.PathExt.removeSlash(t):`${e.name}:${he.PathExt.removeSlash(t)}`}_driveForPath(e){let t=this.driveName(e),s=this.localPath(e);return t?[this._additionalDrives.get(t),s]:[this._defaultDrive,s]}_onFileChanged(e,t){var s,i;if(e===this._defaultDrive)this._fileChanged.emit(t);else{let r=null,o=null;!((s=t.newValue)===null||s===void 0)&&s.path&&(r={...t.newValue,path:this._toGlobalPath(e,t.newValue.path)}),!((i=t.oldValue)===null||i===void 0)&&i.path&&(o={...t.oldValue,path:this._toGlobalPath(e,t.oldValue.path)}),this._fileChanged.emit({type:t.type,newValue:r,oldValue:o})}}};ne.ContentsManager=hs;var an=class{constructor(e={}){var t,s,i;this._isDisposed=!1,this._fileChanged=new ct.Signal(this),this.name=(t=e.name)!==null&&t!==void 0?t:"Default",this._apiEndpoint=(s=e.apiEndpoint)!==null&&s!==void 0?s:yl,this.serverSettings=(i=e.serverSettings)!==null&&i!==void 0?i:W.ServerConnection.makeSettings(),this._restContentProvider=new ln({...e,apiEndpoint:this._apiEndpoint,serverSettings:this.serverSettings}),e.defaultContentProvider?this.contentProviderRegistry=new ut({defaultProvider:e.defaultContentProvider}):this.contentProviderRegistry=new ut,this.contentProviderRegistry.fileChanged.connect((r,o)=>{this._fileChanged.emit(o)})}get fileChanged(){return this._fileChanged}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,ct.Signal.clearData(this))}async get(e,t){let s=this.contentProviderRegistry.getProvider(t==null?void 0:t.contentProviderId);return s?s.get(e,t):await this._restContentProvider.get(e,t)}getDownloadUrl(e){let t=this.serverSettings.baseUrl,s=he.URLExt.join(t,wl,he.URLExt.encodeParts(e)),i="";try{i=document.cookie}catch{}let r=i.match("\\b_xsrf=([^;]*)\\b");if(r){let o=new URL(s);o.searchParams.append("_xsrf",r[1]),s=o.toString()}return Promise.resolve(s)}async newUntitled(e={}){var t;let s="{}";e&&(e.ext&&(e.ext=fs.normalizeExtension(e.ext)),s=JSON.stringify(e));let i=this.serverSettings,r=this._getUrl((t=e.path)!==null&&t!==void 0?t:""),o={method:"POST",body:s},a=await W.ServerConnection.makeRequest(r,o,i);if(a.status!==201)throw await W.ServerConnection.ResponseError.create(a);let d=await a.json();return Ne.validateContentsModel(d),this._fileChanged.emit({type:"new",oldValue:null,newValue:d}),d}async delete(e){let t=this._getUrl(e),s=this.serverSettings,i={method:"DELETE"},r=await W.ServerConnection.makeRequest(t,i,s);if(r.status!==204)throw await W.ServerConnection.ResponseError.create(r);this._fileChanged.emit({type:"delete",oldValue:{path:e},newValue:null})}async rename(e,t){let s=this.serverSettings,i=this._getUrl(e),r={method:"PATCH",body:JSON.stringify({path:t})},o=await W.ServerConnection.makeRequest(i,r,s);if(o.status!==200)throw await W.ServerConnection.ResponseError.create(o);let a=await o.json();return Ne.validateContentsModel(a),this._fileChanged.emit({type:"rename",oldValue:{path:e},newValue:a}),a}async save(e,t={}){let s=this.contentProviderRegistry.getProvider(t==null?void 0:t.contentProviderId),i;return s?i=await s.save(e,t):i=await this._restContentProvider.save(e,t),this._fileChanged.emit({type:"save",oldValue:null,newValue:i}),i}async copy(e,t){let s=this.serverSettings,i=this._getUrl(t),r={method:"POST",body:JSON.stringify({copy_from:e})},o=await W.ServerConnection.makeRequest(i,r,s);if(o.status!==201)throw await W.ServerConnection.ResponseError.create(o);let a=await o.json();return Ne.validateContentsModel(a),this._fileChanged.emit({type:"new",oldValue:null,newValue:a}),a}async createCheckpoint(e){let t=this._getUrl(e,"checkpoints"),s={method:"POST"},i=await W.ServerConnection.makeRequest(t,s,this.serverSettings);if(i.status!==201)throw await W.ServerConnection.ResponseError.create(i);let r=await i.json();return Ne.validateCheckpointModel(r),r}async listCheckpoints(e){let t=this._getUrl(e,"checkpoints"),s=await W.ServerConnection.makeRequest(t,{},this.serverSettings);if(s.status!==200)throw await W.ServerConnection.ResponseError.create(s);let i=await s.json();if(!Array.isArray(i))throw new Error("Invalid Checkpoint list");for(let r=0;r<i.length;r++)Ne.validateCheckpointModel(i[r]);return i}async restoreCheckpoint(e,t){let s=this._getUrl(e,"checkpoints",t),i={method:"POST"},r=await W.ServerConnection.makeRequest(s,i,this.serverSettings);if(r.status!==204)throw await W.ServerConnection.ResponseError.create(r)}async deleteCheckpoint(e,t){let s=this._getUrl(e,"checkpoints",t),i={method:"DELETE"},r=await W.ServerConnection.makeRequest(s,i,this.serverSettings);if(r.status!==204)throw await W.ServerConnection.ResponseError.create(r)}_getUrl(...e){let t=e.map(i=>he.URLExt.encodeParts(i)),s=this.serverSettings.baseUrl;return he.URLExt.join(s,this._apiEndpoint,...t)}};ne.Drive=an;var fs;(function(n){function e(t){return t.length>0&&t.indexOf(".")!==0&&(t=`.${t}`),t}n.normalizeExtension=e})(fs||(fs={}));var ut=class{constructor(e){this._providers=new Map,this._fileChanged=new ct.Signal(this),e!=null&&e.defaultProvider&&this.register("default",e.defaultProvider)}register(e,t){if(this._providers.has(e))throw Error(`Provider with ${e} identifier was already registered on this drive`);this._providers.set(e,t);let s=(i,r)=>{this._fileChanged.emit(r)};return t.fileChanged&&t.fileChanged.connect(s),new vl.DisposableDelegate(()=>{t.fileChanged&&t.fileChanged.disconnect(s),this._providers.has(e)&&this._providers.delete(e)})}getProvider(e){if(!e)return null;let t=this._providers.get(e);if(!t)throw Error(`Provider ${e} is not registered`);return t}get fileChanged(){return this._fileChanged}};ne.ContentProviderRegistry=ut;var ln=class{constructor(e){this._options=e}async get(e,t){let s=this._getUrl(e);if(t){t.type==="notebook"&&delete t.format;let a=t.content?"1":"0",d=t.hash?"1":"0",c={...t,content:a,hash:d};s+=he.URLExt.objectToQueryString(c)}let i=this._options.serverSettings,r=await W.ServerConnection.makeRequest(s,{},i);if(r.status!==200)throw await W.ServerConnection.ResponseError.create(r);let o=await r.json();return Ne.validateContentsModel(o),o}async save(e,t={}){let s=this._options.serverSettings,i=this._getUrl(e),o={method:"PUT",body:new File([JSON.stringify(t)],"data.json",{type:"application/json"})},a=await W.ServerConnection.makeRequest(i,o,s);if(a.status!==200&&a.status!==201)throw await W.ServerConnection.ResponseError.create(a);let d=await a.json();return Ne.validateContentsModel(d),d}_getUrl(...e){let t=e.map(i=>he.URLExt.encodeParts(i)),s=this._options.serverSettings.baseUrl;return he.URLExt.join(s,this._options.apiEndpoint,...t)}};ne.RestContentProvider=ln});var Je=R((cn,ur)=>{(function(n,e){typeof cn=="object"&&typeof ur!="undefined"?e(cn,Y(),ee()):typeof define=="function"&&define.amd?define(["exports","@lumino/coreutils","@lumino/signaling"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_polling={},n.lumino_coreutils,n.lumino_signaling))})(cn,function(n,e,t){"use strict";class s{constructor(c){var u;this._disposed=new t.Signal(this),this._lingered=0,this._tick=new e.PromiseDelegate,this._ticked=new t.Signal(this),this._factory=c.factory,this._linger=(u=c.linger)!==null&&u!==void 0?u:i.DEFAULT_LINGER,this._standby=c.standby||i.DEFAULT_STANDBY,this._state={...i.DEFAULT_STATE,timestamp:new Date().getTime()};let l=c.frequency||{},h=Math.max(l.interval||0,l.max||0,i.DEFAULT_FREQUENCY.max);this.frequency={...i.DEFAULT_FREQUENCY,...l,max:h},this.name=c.name||i.DEFAULT_NAME,(!("auto"in c)||c.auto)&&setTimeout(()=>this.start())}get disposed(){return this._disposed}get frequency(){return this._frequency}set frequency(c){if(this.isDisposed||e.JSONExt.deepEqual(c,this.frequency||{}))return;let{backoff:u,interval:l,max:h}=c;if(l=Math.round(l),h=Math.round(h),typeof u=="number"&&u<1)throw new Error("Poll backoff growth factor must be at least 1");if((l<0||l>h)&&l!==s.NEVER)throw new Error("Poll interval must be between 0 and max");if(h>s.MAX_INTERVAL&&h!==s.NEVER)throw new Error(`Max interval must be less than ${s.MAX_INTERVAL}`);this._frequency={backoff:u,interval:l,max:h}}get isDisposed(){return this.state.phase==="disposed"}get standby(){return this._standby}set standby(c){this.isDisposed||this.standby===c||(this._standby=c)}get state(){return this._state}get tick(){return this._tick.promise}get ticked(){return this._ticked}async*[Symbol.asyncIterator](){for(;!this.isDisposed;)yield this.state,await this.tick.catch(()=>{})}dispose(){this.isDisposed||(this._state={...i.DISPOSED_STATE,timestamp:new Date().getTime()},this._tick.promise.catch(c=>{}),this._tick.reject(new Error(`Poll (${this.name}) is disposed.`)),this._disposed.emit(void 0),t.Signal.clearData(this))}refresh(){return this.schedule({cancel:({phase:c})=>c==="refreshed",interval:s.IMMEDIATE,phase:"refreshed"})}async schedule(c={}){if(this.isDisposed||c.cancel&&c.cancel(this.state))return;let u=this._tick,l=new e.PromiseDelegate,h={interval:this.frequency.interval,payload:null,phase:"standby",timestamp:new Date().getTime(),...c};if(this._state=h,this._tick=l,clearTimeout(this._timeout),this._ticked.emit(this.state),u.resolve(this),await u.promise,h.interval===s.NEVER){this._timeout=void 0;return}let v=()=>{this.isDisposed||this.tick!==l.promise||this._execute()};this._timeout=setTimeout(v,h.interval)}start(){return this.schedule({cancel:({phase:c})=>c!=="constructed"&&c!=="standby"&&c!=="stopped",interval:s.IMMEDIATE,phase:"started"})}stop(){return this.schedule({cancel:({phase:c})=>c==="stopped",interval:s.NEVER,phase:"stopped"})}get hidden(){return i.hidden}_execute(){let c=typeof this.standby=="function"?this.standby():this.standby;if(c==="never"?c=!1:c==="when-hidden"&&(this.hidden?c=++this._lingered>this._linger:(this._lingered=0,c=!1)),c){this.schedule();return}let u=this.tick;this._factory(this.state).then(l=>{this.isDisposed||this.tick!==u||this.schedule({payload:l,phase:this.state.phase==="rejected"?"reconnected":"resolved"})}).catch(l=>{this.isDisposed||this.tick!==u||this.schedule({interval:i.sleep(this.frequency,this.state),payload:l,phase:"rejected"})})}}(function(d){d.IMMEDIATE=0,d.MAX_INTERVAL=2147483647,d.NEVER=1/0})(s||(s={}));var i;(function(d){d.DEFAULT_BACKOFF=3,d.DEFAULT_FREQUENCY={backoff:!0,interval:1e3,max:30*1e3},d.DEFAULT_LINGER=1,d.DEFAULT_NAME="unknown",d.DEFAULT_STANDBY="when-hidden",d.DEFAULT_STATE={interval:s.NEVER,payload:null,phase:"constructed",timestamp:new Date(0).getTime()},d.DISPOSED_STATE={interval:s.NEVER,payload:null,phase:"disposed",timestamp:new Date(0).getTime()};function c(l,h){let{backoff:v,interval:m,max:q}=l;if(m===s.NEVER)return m;let I=v===!0?d.DEFAULT_BACKOFF:v===!1?1:v,T=u(m,h.interval*I);return Math.min(q,T)}d.sleep=c,d.hidden=typeof document=="undefined"?!1:(document.addEventListener("visibilitychange",()=>{d.hidden=document.visibilityState==="hidden"}),document.addEventListener("pagehide",()=>{d.hidden=document.visibilityState==="hidden"}),document.visibilityState==="hidden");function u(l,h){return l=Math.ceil(l),h=Math.floor(h),Math.floor(Math.random()*(h-l+1))+l}})(i||(i={}));class r{constructor(c,u=500){this.args=void 0,this.payload=null,this.limit=u,this.poll=new s({auto:!1,factory:async()=>{let{args:l}=this;return this.args=void 0,c(...l)},frequency:{backoff:!1,interval:s.NEVER,max:s.NEVER},standby:"never"}),this.payload=new e.PromiseDelegate,this.poll.ticked.connect((l,h)=>{let{payload:v}=this;if(h.phase==="resolved"){this.payload=new e.PromiseDelegate,v.resolve(h.payload);return}if(h.phase==="rejected"||h.phase==="stopped"){this.payload=new e.PromiseDelegate,v.promise.catch(m=>{}),v.reject(h.payload);return}},this)}get isDisposed(){return this.payload===null}dispose(){this.isDisposed||(this.args=void 0,this.payload=null,this.poll.dispose())}async stop(){return this.poll.stop()}}class o extends r{invoke(...c){return this.args=c,this.poll.schedule({interval:this.limit,phase:"invoked"}),this.payload.promise}}class a extends r{constructor(c,u){super(c,typeof u=="number"?u:u&&u.limit),this._trailing=!1,typeof u!="number"&&u&&u.edge==="trailing"&&(this._trailing=!0),this._interval=this._trailing?this.limit:s.IMMEDIATE}invoke(...c){let u=this.poll.state.phase!=="invoked";return(u||this._trailing)&&(this.args=c),u&&this.poll.schedule({interval:this._interval,phase:"invoked"}),this.payload.promise}}n.Debouncer=o,n.Poll=s,n.RateLimiter=r,n.Throttler=a})});var gs=R(un=>{"use strict";Object.defineProperty(un,"__esModule",{value:!0});un.EventManager=void 0;var dr=te(),Sl=Je(),hr=ee(),fr=de(),_r="api/events",ps=class{constructor(e={}){var t,s;this._socket=null,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:fr.ServerConnection.makeSettings(),this._poll=new Sl.Poll({factory:()=>this._subscribe(),standby:(s=e.standby)!==null&&s!==void 0?s:"when-hidden"}),this._stream=new hr.Stream(this),this._poll.start()}get isDisposed(){return this._poll.isDisposed}get stream(){return this._stream}dispose(){if(this.isDisposed)return;this._poll.dispose();let e=this._socket;e&&(this._socket=null,e.onopen=()=>{},e.onerror=()=>{},e.onmessage=()=>{},e.onclose=()=>{},e.close()),hr.Signal.clearData(this),this._stream.stop()}async emit(e){let{serverSettings:t}=this,{baseUrl:s}=t,{makeRequest:i,ResponseError:r}=fr.ServerConnection,o=dr.URLExt.join(s,_r),a={body:JSON.stringify(e),method:"POST"},d=await i(o,a,t);if(d.status!==204)throw new r(d)}_subscribe(){return new Promise((e,t)=>{if(this.isDisposed)return;let{appendToken:s,token:i,WebSocket:r,wsUrl:o}=this.serverSettings,a=dr.URLExt.join(o,_r,"subscribe");s&&i!==""&&(a+=`?token=${encodeURIComponent(i)}`);let d=this._socket=new r(a),c=this._stream;d.onclose=()=>t(new Error("EventManager socket closed")),d.onmessage=u=>u.data&&c.emit(JSON.parse(u.data))})}};un.EventManager=ps});var ms=R(Se=>{"use strict";var bl=Se&&Se.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Cl=Se&&Se.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Pl=Se&&Se.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&bl(e,n,t);return Cl(e,n),e};Object.defineProperty(Se,"__esModule",{value:!0});Se.CommHandler=Se.CommsOverSubshells=void 0;var Ml=Y(),El=rn(),dn=Pl(Ze()),nt;(function(n){n.Disabled="disabled",n.PerComm="perComm",n.PerCommTarget="perCommTarget"})(nt||(Se.CommsOverSubshells=nt={}));var hn=class n extends El.DisposableDelegate{constructor(e,t,s,i,r){super(i),this._subshellStarted=new Ml.PromiseDelegate,this._subshellId=null,this._target="",this._id="",this._id=t,this._target=e,this._kernel=s,this._kernel.statusChanged.connect(()=>{this._kernel.status==="restarting"&&this._cleanSubshells()}),this.commsOverSubshells=r!=null?r:nt.PerCommTarget}get commId(){return this._id}get targetName(){return this._target}get subshellId(){return this._subshellId}get subshellStarted(){return this._subshellStarted.promise}get commsOverSubshells(){return this._commsOverSubshells}set commsOverSubshells(e){this._commsOverSubshells=e,this._commsOverSubshells===nt.Disabled?this._maybeCloseSubshell():this._maybeStartSubshell()}get onClose(){return this._onClose}set onClose(e){this._onClose=e}get onMsg(){return this._onMsg}set onMsg(e){this._onMsg=e}open(e,t,s=[]){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot open");let i=dn.createMessage({msgType:"comm_open",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,target_name:this._target,data:e!=null?e:{}},metadata:t,buffers:s});return this._kernel.sendShellMessage(i,!1,!0)}send(e,t,s=[],i=!0){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot send");let r=dn.createMessage({msgType:"comm_msg",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,data:e},metadata:t,buffers:s});return this._kernel.sendShellMessage(r,!1,i)}close(e,t,s=[]){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot close");let i=dn.createMessage({msgType:"comm_close",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,data:e!=null?e:{}},metadata:t,buffers:s}),r=this._kernel.sendShellMessage(i,!1,!0),o=this._onClose;if(o){let a=dn.createMessage({msgType:"comm_close",channel:"iopub",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,data:e!=null?e:{}},metadata:t,buffers:s});o(a)}return this.dispose(),r}dispose(){this._maybeCloseSubshell(),super.dispose()}_cleanSubshells(){let e=this._kernel.id;n._commTargetSubShellsId.hasOwnProperty(e)&&delete n._commTargetSubShellsId[e]}async _maybeStartSubshell(){if(await this._kernel.info,!this._kernel.supportsSubshells)return;if(this._commsOverSubshells===nt.PerComm){let s=await this._kernel.requestCreateSubshell({}).done;this._subshellId=s.content.subshell_id,this._subshellStarted.resolve();return}let e=this._kernel.id;n._commTargetSubShellsId.hasOwnProperty(e)||(n._commTargetSubShellsId[e]={});let t=n._commTargetSubShellsId[e];t[this._target]?(this._subshellId=await t[this._target],this._subshellStarted.resolve()):(t[this._target]=this._kernel.requestCreateSubshell({}).done.then(s=>(this._subshellId=s.content.subshell_id,this._subshellId)),await t[this._target],this._subshellStarted.resolve())}_maybeCloseSubshell(){if(this._commsOverSubshells!==nt.PerComm){this._subshellId=null;return}this._subshellId&&this._kernel.status!=="dead"&&this._kernel.requestDeleteSubshell({subshell_id:this._subshellId},!0),this._subshellId=null}};Se.CommHandler=hn;hn._commTargetSubShellsId={}});var gr=R(pr=>{"use strict";Object.defineProperty(pr,"__esModule",{value:!0})});var fn=R(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.validateMessage=kl;dt.validateModel=vr;dt.validateModels=Dl;var Ge=lt(),mr=["username","version","session","msg_id","msg_type"],Il={stream:{name:"string",text:"string"},display_data:{data:"object",metadata:"object"},execute_input:{code:"string",execution_count:"number"},execute_result:{execution_count:"number",data:"object",metadata:"object"},error:{ename:"string",evalue:"string",traceback:"object"},status:{execution_state:["string",["starting","idle","busy","restarting","dead"]]},clear_output:{wait:"boolean"},comm_open:{comm_id:"string",target_name:"string",data:"object"},comm_msg:{comm_id:"string",data:"object"},comm_close:{comm_id:"string"},shutdown_reply:{restart:"boolean"}};function Rl(n){for(let e=0;e<mr.length;e++)(0,Ge.validateProperty)(n,mr[e],"string")}function kl(n){(0,Ge.validateProperty)(n,"metadata","object"),(0,Ge.validateProperty)(n,"content","object"),(0,Ge.validateProperty)(n,"channel","string"),Rl(n.header),n.channel==="iopub"&&Ol(n)}function Ol(n){if(n.channel==="iopub"){let e=Il[n.header.msg_type];if(e===void 0)return;let t=Object.keys(e),s=n.content;for(let i=0;i<t.length;i++){let r=e[t[i]];Array.isArray(r)||(r=[r]),(0,Ge.validateProperty)(s,t[i],...r)}}}function vr(n){(0,Ge.validateProperty)(n,"name","string"),(0,Ge.validateProperty)(n,"id","string")}function Dl(n){if(!Array.isArray(n))throw new Error("Invalid kernel list");n.forEach(e=>vr(e))}});var pn=R(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});se.KernelAPIClient=se.KERNEL_SERVICE_URL=void 0;se.listRunning=yr;se.startNew=wr;se.restartKernel=Sr;se.interruptKernel=br;se.shutdownKernel=Cr;se.getKernelModel=Pr;var Q=de(),st=te(),_n=fn();se.KERNEL_SERVICE_URL="api/kernels";async function yr(n=Q.ServerConnection.makeSettings()){let e=st.URLExt.join(n.baseUrl,se.KERNEL_SERVICE_URL),t=await Q.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await Q.ServerConnection.ResponseError.create(t);let s=await t.json();return(0,_n.validateModels)(s),s}async function wr(n={},e=Q.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL),s={method:"POST",body:JSON.stringify(n)},i=await Q.ServerConnection.makeRequest(t,s,e);if(i.status!==201)throw await Q.ServerConnection.ResponseError.create(i);let r=await i.json();return(0,_n.validateModel)(r),r}async function Sr(n,e=Q.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(n),"restart"),s={method:"POST"},i=await Q.ServerConnection.makeRequest(t,s,e);if(i.status!==200)throw await Q.ServerConnection.ResponseError.create(i);let r=await i.json();(0,_n.validateModel)(r)}async function br(n,e=Q.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(n),"interrupt"),s={method:"POST"},i=await Q.ServerConnection.makeRequest(t,s,e);if(i.status!==204)throw await Q.ServerConnection.ResponseError.create(i)}async function Cr(n,e=Q.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(n)),s={method:"DELETE"},i=await Q.ServerConnection.makeRequest(t,s,e);if(i.status===404){let r=`The kernel "${n}" does not exist on the server`;console.warn(r)}else if(i.status!==204)throw await Q.ServerConnection.ResponseError.create(i)}async function Pr(n,e=Q.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(n)),s=await Q.ServerConnection.makeRequest(t,{},e);if(s.status===404)return;if(s.status!==200)throw await Q.ServerConnection.ResponseError.create(s);let i=await s.json();return(0,_n.validateModel)(i),i}var vs=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Q.ServerConnection.makeSettings()}async listRunning(){return yr(this.serverSettings)}async getModel(e){return Pr(e,this.serverSettings)}async startNew(e={}){return wr(e,this.serverSettings)}async restart(e){return Sr(e,this.serverSettings)}async interrupt(e){return br(e,this.serverSettings)}async shutdown(e){return Cr(e,this.serverSettings)}};se.KernelAPIClient=vs});var Er=R(ve=>{"use strict";var ql=ve&&ve.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Tl=ve&&ve.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),jl=ve&&ve.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&ql(e,n,t);return Tl(e,n),e};Object.defineProperty(ve,"__esModule",{value:!0});ve.KernelShellFutureHandler=ve.KernelControlFutureHandler=ve.KernelFutureHandler=void 0;var Mr=Y(),Ul=rn(),Al=jl(Ze()),ht=class extends Ul.DisposableDelegate{constructor(e,t,s,i,r){super(e),this._status=0,this._stdin=re.noOp,this._iopub=re.noOp,this._reply=re.noOp,this._done=new Mr.PromiseDelegate,this._hooks=new re.HookList,this._disposeOnDone=!0,this._msg=t,s||this._setFlag(re.KernelFutureFlag.GotReply),this._disposeOnDone=i,this._kernel=r}get msg(){return this._msg}get done(){return this._done.promise}get onReply(){return this._reply}set onReply(e){this._reply=e}get onIOPub(){return this._iopub}set onIOPub(e){this._iopub=e}get onStdin(){return this._stdin}set onStdin(e){this._stdin=e}registerMessageHook(e){if(this.isDisposed)throw new Error("Kernel future is disposed");this._hooks.add(e)}removeMessageHook(e){this.isDisposed||this._hooks.remove(e)}sendInputReply(e,t){this._kernel.sendInputReply(e,t)}dispose(){this._stdin=re.noOp,this._iopub=re.noOp,this._reply=re.noOp,this._hooks=null,this._testFlag(re.KernelFutureFlag.IsDone)||(this._done.promise.catch(()=>{}),this._done.reject(new Error(`Canceled future for ${this.msg.header.msg_type} message before replies were done`))),super.dispose()}async handleMsg(e){switch(e.channel){case"control":case"shell":e.channel===this.msg.channel&&e.parent_header.msg_id===this.msg.header.msg_id&&await this._handleReply(e);break;case"stdin":await this._handleStdin(e);break;case"iopub":await this._handleIOPub(e);break;default:break}}async _handleReply(e){let t=this._reply;t&&await t(e),this._replyMsg=e,this._setFlag(re.KernelFutureFlag.GotReply),this._testFlag(re.KernelFutureFlag.GotIdle)&&this._handleDone()}async _handleStdin(e){this._kernel.hasPendingInput=!0;let t=this._stdin;t&&await t(e)}async _handleIOPub(e){let t=await this._hooks.process(e),s=this._iopub;t&&s&&await s(e),Al.isStatusMsg(e)&&e.content.execution_state==="idle"&&(this._setFlag(re.KernelFutureFlag.GotIdle),this._testFlag(re.KernelFutureFlag.GotReply)&&this._handleDone())}_handleDone(){this._testFlag(re.KernelFutureFlag.IsDone)||(this._setFlag(re.KernelFutureFlag.IsDone),this._done.resolve(this._replyMsg),this._disposeOnDone&&this.dispose())}_testFlag(e){return(this._status&e)!==0}_setFlag(e){this._status|=e}};ve.KernelFutureHandler=ht;var ys=class extends ht{};ve.KernelControlFutureHandler=ys;var ws=class extends ht{};ve.KernelShellFutureHandler=ws;var re;(function(n){n.noOp=()=>{};let e=typeof requestAnimationFrame=="function"?requestAnimationFrame:setImmediate;class t{constructor(){this._hooks=[]}add(r){this.remove(r),this._hooks.push(r)}remove(r){let o=this._hooks.indexOf(r);o>=0&&(this._hooks[o]=null,this._scheduleCompact())}async process(r){await this._processing;let o=new Mr.PromiseDelegate;this._processing=o.promise;let a;for(let d=this._hooks.length-1;d>=0;d--){let c=this._hooks[d];if(c!==null){try{a=await c(r)}catch(u){a=!0,console.error(u)}if(a===!1)return o.resolve(void 0),!1}}return o.resolve(void 0),!0}_scheduleCompact(){this._compactScheduled||(this._compactScheduled=!0,e(()=>{this._processing=this._processing.then(()=>{this._compactScheduled=!1,this._compact()})}))}_compact(){let r=0;for(let o=0,a=this._hooks.length;o<a;o++){let d=this._hooks[o];this._hooks[o]===null?r++:this._hooks[o-r]=d}this._hooks.length-=r}}n.HookList=t;let s;(function(i){i[i.GotReply=1]="GotReply",i[i.GotIdle=2]="GotIdle",i[i.IsDone=4]="IsDone",i[i.DisposeOnDone=8]="DisposeOnDone"})(s=n.KernelFutureFlag||(n.KernelFutureFlag={}))})(re||(re={}))});var Rr=R(gn=>{"use strict";Object.defineProperty(gn,"__esModule",{value:!0});gn.validateSpecModel=Ir;gn.validateSpecModels=Nl;var Ke=lt();function Ir(n){let e=n.spec;if(!e)throw new Error("Invalid kernel spec");(0,Ke.validateProperty)(n,"name","string"),(0,Ke.validateProperty)(n,"resources","object"),(0,Ke.validateProperty)(e,"language","string"),(0,Ke.validateProperty)(e,"display_name","string"),(0,Ke.validateProperty)(e,"argv","array");let t=null;e.hasOwnProperty("metadata")&&((0,Ke.validateProperty)(e,"metadata","object"),t=e.metadata);let s=null;return e.hasOwnProperty("env")&&((0,Ke.validateProperty)(e,"env","object"),s=e.env),e.hasOwnProperty("interrupt_mode")&&((0,Ke.validateProperty)(e,"interrupt_mode","string"),s=e.env),{name:n.name,resources:n.resources,language:e.language,display_name:e.display_name,argv:e.argv,metadata:t,env:s}}function Nl(n){if(!n.hasOwnProperty("kernelspecs"))throw new Error("No kernelspecs found");let e=Object.keys(n.kernelspecs),t=Object.create(null),s=n.default;for(let i=0;i<e.length;i++){let r=n.kernelspecs[e[i]];try{t[e[i]]=Ir(r)}catch{console.warn(`Removing errant kernel spec: ${e[i]}`)}}if(e=Object.keys(t),!e.length)throw new Error("No valid kernelspecs found");return(!s||typeof s!="string"||!(s in t))&&(s=e[0],console.warn(`Default kernel not found, using '${e[0]}'`)),{default:s,kernelspecs:t}}});var _t=R(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.KernelSpecAPIClient=void 0;ft.getSpecs=kr;var mn=de(),Ll=Rr(),xl=te(),Fl="api/kernelspecs";async function kr(n=mn.ServerConnection.makeSettings()){let e=xl.URLExt.join(n.baseUrl,Fl),t=await mn.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await mn.ServerConnection.ResponseError.create(t);let s=await t.json();return(0,Ll.validateSpecModels)(s)}var Ss=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:mn.ServerConnection.makeSettings()}async get(){return kr(this.serverSettings)}};ft.KernelSpecAPIClient=Ss});var Cs=R(qe=>{"use strict";var Kl=qe&&qe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),zl=qe&&qe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),jr=qe&&qe.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&Kl(e,n,t);return zl(e,n),e};Object.defineProperty(qe,"__esModule",{value:!0});qe.KernelConnection=void 0;var Or=te(),ze=Y(),Ve=ee(),pt=Ae(),Dr=ms(),oe=jr(Ze()),qr=Er(),Vl=jr(fn()),Tr=pn(),Bl=_t(),Wl=te(),$l=3e3,it="_RESTARTING_",Hl="",bs=class n{constructor(e){var t,s,i,r,o,a,d,c;this._createSocket=(u=!0)=>{this._errorIfDisposed(),this._clearSocket(),this._updateConnectionStatus("connecting");let l=this.serverSettings,h=Or.URLExt.join(l.wsUrl,Tr.KERNEL_SERVICE_URL,encodeURIComponent(this._id)),v=h.replace(/^((?:\w+:)?\/\/)(?:[^@\/]+@)/,"$1");console.debug(`Starting WebSocket: ${v}`);let m=Or.URLExt.join(h,"channels?session_id="+encodeURIComponent(this._clientId)),q=l.token;l.appendToken&&q!==""&&(m=m+`&token=${encodeURIComponent(q)}`);let I=u?this._supportedProtocols:[];this._ws=new l.WebSocket(m,I),this._ws.binaryType="arraybuffer";let T=!1,A=async w=>{var k,N;if(!this._isDisposed){this._reason="",this._model=void 0;try{let j=await this._kernelAPIClient.getModel(this._id);this._model=j,(j==null?void 0:j.execution_state)==="dead"?this._updateStatus("dead"):this._onWSClose(w)}catch(j){if(j instanceof pt.ServerConnection.NetworkError||((k=j.response)===null||k===void 0?void 0:k.status)===503||((N=j.response)===null||N===void 0?void 0:N.status)===424){let D=be.getRandomIntInclusive(10,30)*1e3;setTimeout(A,D,w)}else this._reason="Kernel died unexpectedly",this._updateStatus("dead")}}},C=async w=>{T||(T=!0,await A(w))};this._ws.onmessage=this._onWSMessage,this._ws.onopen=this._onWSOpen,this._ws.onclose=C,this._ws.onerror=C},this._onWSOpen=u=>{if(this._ws.protocol!==""&&!this._supportedProtocols.includes(this._ws.protocol))throw console.log("Server selected unknown kernel wire protocol:",this._ws.protocol),this._updateStatus("dead"),new Error(`Unknown kernel wire protocol: ${this._ws.protocol}`);this._selectedProtocol=this._ws.protocol,this._ws.onclose=this._onWSClose,this._ws.onerror=this._onWSClose,this._updateConnectionStatus("connected")},this._onWSMessage=u=>{let l;try{l=this.serverSettings.serializer.deserialize(u.data,this._ws.protocol),Vl.validateMessage(l)}catch(h){throw h.message=`Kernel message validation error: ${h.message}`,h}this._kernelSession=l.header.session,this._msgChain=this._msgChain.then(()=>this._handleMessage(l)).catch(h=>{h.message.startsWith("Canceled future for ")&&console.error(h)}),this._anyMessage.emit({msg:l,direction:"recv"})},this._onWSClose=u=>{this.isDisposed||this._reconnect()},this._id="",this._name="",this._status="unknown",this._connectionStatus="connecting",this._kernelSession="",this._isDisposed=!1,this._ws=null,this._username="",this._reconnectLimit=7,this._reconnectAttempt=0,this._reconnectTimeout=null,this._supportedProtocols=Object.values(oe.supportedKernelWebSocketProtocols),this._selectedProtocol="",this._commsOverSubshells=pt.CommsOverSubshells.PerCommTarget,this._futures=new Map,this._comms=new Map,this._targetRegistry=Object.create(null),this._info=new ze.PromiseDelegate,this._pendingMessages=[],this._statusChanged=new Ve.Signal(this),this._connectionStatusChanged=new Ve.Signal(this),this._disposed=new Ve.Signal(this),this._iopubMessage=new Ve.Signal(this),this._anyMessage=new Ve.Signal(this),this._pendingInput=new Ve.Signal(this),this._unhandledMessage=new Ve.Signal(this),this._displayIdToParentIds=new Map,this._msgIdToDisplayIds=new Map,this._msgChain=Promise.resolve(),this._hasPendingInput=!1,this._reason="",this._noOp=()=>{},this._supportsSubshells=!1,this._name=e.model.name,this._id=e.model.id,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:pt.ServerConnection.makeSettings(),this._kernelAPIClient=(s=e.kernelAPIClient)!==null&&s!==void 0?s:new Tr.KernelAPIClient({serverSettings:this.serverSettings}),this._kernelSpecAPIClient=(i=e.kernelSpecAPIClient)!==null&&i!==void 0?i:new Bl.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._clientId=(r=e.clientId)!==null&&r!==void 0?r:ze.UUID.uuid4(),this._username=(o=e.username)!==null&&o!==void 0?o:"",this.handleComms=(a=e.handleComms)!==null&&a!==void 0?a:!0,this._commsOverSubshells=(d=e.commsOverSubshells)!==null&&d!==void 0?d:pt.CommsOverSubshells.PerCommTarget,this._subshellId=(c=e.subshellId)!==null&&c!==void 0?c:null,this._createSocket()}get disposed(){return this._disposed}get commsOverSubshells(){return this._commsOverSubshells}set commsOverSubshells(e){this._commsOverSubshells=e;for(let[t,s]of this._comms)s.commsOverSubshells=e}get statusChanged(){return this._statusChanged}get connectionStatusChanged(){return this._connectionStatusChanged}get iopubMessage(){return this._iopubMessage}get unhandledMessage(){return this._unhandledMessage}get model(){return this._model||{id:this.id,name:this.name,reason:this._reason}}get anyMessage(){return this._anyMessage}get pendingInput(){return this._pendingInput}get id(){return this._id}get name(){return this._name}get username(){return this._username}get clientId(){return this._clientId}get subshellId(){return this._subshellId}set subshellId(e){this._subshellId=e}get status(){return this._status}get connectionStatus(){return this._connectionStatus}get isDisposed(){return this._isDisposed}get info(){return this._info.promise}get spec(){return this._specPromise?this._specPromise:(this._specPromise=this._kernelSpecAPIClient.get().then(e=>e.kernelspecs[this._name]),this._specPromise)}get supportsSubshells(){return this._supportsSubshells}clone(e={}){return new n({model:this.model,username:this.username,serverSettings:this.serverSettings,handleComms:!1,kernelAPIClient:this._kernelAPIClient,commsOverSubshells:pt.CommsOverSubshells.Disabled,...e})}dispose(){if(this.isDisposed)return;let e=()=>{this._isDisposed=!0,this._disposed.emit(),this._updateConnectionStatus("disconnected"),this._clearKernelState(),this._pendingMessages=[],this._clearSocket(),Ve.Signal.clearData(this)};if(this._subshellId!==null){let t=this.requestDeleteSubshell({subshell_id:this._subshellId},!0);t.onReply=s=>{e()}}else e()}sendShellMessage(e,t=!1,s=!0){return this._sendKernelShellControl(qr.KernelShellFutureHandler,e,t,s)}sendControlMessage(e,t=!1,s=!0){return this._sendKernelShellControl(qr.KernelControlFutureHandler,e,t,s)}_sendKernelShellControl(e,t,s=!1,i=!0){this._sendMessage(t),this._anyMessage.emit({msg:t,direction:"send"});let r=new e(()=>{let o=t.header.msg_id;this._futures.delete(o);let a=this._msgIdToDisplayIds.get(o);a&&(a.forEach(d=>{let c=this._displayIdToParentIds.get(d);if(c){let u=c.indexOf(o);if(u===-1)return;c.length===1?this._displayIdToParentIds.delete(d):(c.splice(u,1),this._displayIdToParentIds.set(d,c))}}),this._msgIdToDisplayIds.delete(o))},t,s,i,this);return this._futures.set(t.header.msg_id,r),r}_sendMessage(e,t=!0){if(this.status==="dead")throw new Error("Kernel is dead");if((this._kernelSession===Hl||this._kernelSession===it)&&oe.isInfoRequestMsg(e))if(this.connectionStatus==="connected"){this._ws.send(this.serverSettings.serializer.serialize(e,this._ws.protocol));return}else throw new Error("Could not send message: status is not connected");if(t&&this._pendingMessages.length>0){this._pendingMessages.push(e);return}if(this.connectionStatus==="connected"&&this._kernelSession!==it)this._ws.send(this.serverSettings.serializer.serialize(e,this._ws.protocol));else if(t)this._pendingMessages.push(e);else throw new Error("Could not send message")}async interrupt(){if(this.hasPendingInput=!1,this.status==="dead")throw new Error("Kernel is dead");return this._kernelAPIClient.interrupt(this.id)}async restart(){if(this.status==="dead")throw new Error("Kernel is dead");this._updateStatus("restarting"),this._clearKernelState(),this._kernelSession=it,await this._kernelAPIClient.restart(this.id),await this.reconnect(),this.hasPendingInput=!1}reconnect(){this._errorIfDisposed();let e=new ze.PromiseDelegate,t=(s,i)=>{i==="connected"?(e.resolve(),this.connectionStatusChanged.disconnect(t,this)):i==="disconnected"&&(e.reject(new Error("Kernel connection disconnected")),this.connectionStatusChanged.disconnect(t,this))};return this.connectionStatusChanged.connect(t,this),this._reconnectAttempt=0,this._reconnect(),e.promise}async shutdown(){this.status!=="dead"&&await this._kernelAPIClient.shutdown(this.id),this.handleShutdown()}handleShutdown(){this._updateStatus("dead"),this.dispose()}async requestKernelInfo(){let e=oe.createMessage({msgType:"kernel_info_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:{}}),t;try{t=await be.handleShellMessage(this,e)}catch(i){if(this.isDisposed)return;throw i}if(this._errorIfDisposed(),!t)return;if(t.content.status===void 0&&(t.content.status="ok"),t.content.status!=="ok")return this._info.reject("Kernel info reply errored"),t;this._info.resolve(t.content),this._kernelSession=t.header.session;let s=t.content.supported_features;return this._supportsSubshells=s!==void 0&&s.includes("kernel subshells"),t}requestComplete(e){let t=oe.createMessage({msgType:"complete_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return be.handleShellMessage(this,t)}requestInspect(e){let t=oe.createMessage({msgType:"inspect_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return be.handleShellMessage(this,t)}requestHistory(e){let t=oe.createMessage({msgType:"history_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return be.handleShellMessage(this,t)}requestExecute(e,t=!0,s){let i={silent:!1,store_history:!0,user_expressions:{},allow_stdin:!0,stop_on_error:!1},r=oe.createMessage({msgType:"execute_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:{...i,...e},metadata:s});return this.sendShellMessage(r,!0,t)}requestDebug(e,t=!0){let s=oe.createMessage({msgType:"debug_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(s,!0,t)}requestCreateSubshell(e,t=!0){if(!this.supportsSubshells)throw new Error("Kernel subshells are not supported");let s=oe.createMessage({msgType:"create_subshell_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(s,!0,t)}requestDeleteSubshell(e,t=!0){if(!this.supportsSubshells)throw new Error("Kernel subshells are not supported");let s=oe.createMessage({msgType:"delete_subshell_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(s,!0,t)}requestListSubshell(e,t=!0){if(!this.supportsSubshells)throw new Error("Kernel subshells are not supported");let s=oe.createMessage({msgType:"list_subshell_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(s,!0,t)}requestIsComplete(e){let t=oe.createMessage({msgType:"is_complete_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return be.handleShellMessage(this,t)}requestCommInfo(e){let t=oe.createMessage({msgType:"comm_info_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return be.handleShellMessage(this,t)}sendInputReply(e,t){let s=oe.createMessage({msgType:"input_reply",channel:"stdin",username:this._username,session:this._clientId,content:e});s.parent_header=t,this._sendMessage(s),this._anyMessage.emit({msg:s,direction:"send"}),this.hasPendingInput=!1}createComm(e,t=ze.UUID.uuid4()){if(!this.handleComms)throw new Error("Comms are disabled on this kernel connection");if(this._comms.has(t))throw new Error("Comm is already created");let s=new Dr.CommHandler(e,t,this,()=>{this._unregisterComm(t)},this._commsOverSubshells);return this._comms.set(t,s),s}hasComm(e){return this._comms.has(e)}registerCommTarget(e,t){this.handleComms&&(this._targetRegistry[e]=t)}removeCommTarget(e,t){this.handleComms&&!this.isDisposed&&this._targetRegistry[e]===t&&delete this._targetRegistry[e]}registerMessageHook(e,t){var s;let i=(s=this._futures)===null||s===void 0?void 0:s.get(e);i&&i.registerMessageHook(t)}removeMessageHook(e,t){var s;let i=(s=this._futures)===null||s===void 0?void 0:s.get(e);i&&i.removeMessageHook(t)}removeInputGuard(){this.hasPendingInput=!1}async _handleDisplayId(e,t){var s,i;let r=t.parent_header.msg_id,o=this._displayIdToParentIds.get(e);if(o){let d={header:ze.JSONExt.deepCopy(t.header),parent_header:ze.JSONExt.deepCopy(t.parent_header),metadata:ze.JSONExt.deepCopy(t.metadata),content:ze.JSONExt.deepCopy(t.content),channel:t.channel,buffers:t.buffers?t.buffers.slice():[]};d.header.msg_type="update_display_data",await Promise.all(o.map(async c=>{let u=this._futures&&this._futures.get(c);u&&await u.handleMsg(d)}))}if(t.header.msg_type==="update_display_data")return!0;o=(s=this._displayIdToParentIds.get(e))!==null&&s!==void 0?s:[],o.indexOf(r)===-1&&o.push(r),this._displayIdToParentIds.set(e,o);let a=(i=this._msgIdToDisplayIds.get(r))!==null&&i!==void 0?i:[];return a.indexOf(r)===-1&&a.push(r),this._msgIdToDisplayIds.set(r,a),!1}_clearSocket(){this._ws!==null&&(this._ws.onopen=this._noOp,this._ws.onclose=this._noOp,this._ws.onerror=this._noOp,this._ws.onmessage=this._noOp,this._ws.close(),this._ws=null)}_updateStatus(e){this._status===e||this._status==="dead"||(this._status=e,be.logKernelStatus(this),this._statusChanged.emit(e),e==="dead"&&this.dispose())}_sendPending(){for(;this.connectionStatus==="connected"&&this._kernelSession!==it&&this._pendingMessages.length>0;)this._sendMessage(this._pendingMessages[0],!1),this._pendingMessages.shift()}_clearKernelState(){this._kernelSession="",this._pendingMessages=[],this._futures.forEach(e=>{e.dispose()}),this._comms.forEach(e=>{e.dispose()}),this._msgChain=Promise.resolve(),this._futures=new Map,this._comms=new Map,this._displayIdToParentIds.clear(),this._msgIdToDisplayIds.clear()}_assertCurrentMessage(e){if(this._errorIfDisposed(),e.header.session!==this._kernelSession)throw new Error(`Canceling handling of old message: ${e.header.msg_type}`)}async _handleCommOpen(e){this._assertCurrentMessage(e);let t=e.content,s=new Dr.CommHandler(t.target_name,t.comm_id,this,()=>{this._unregisterComm(t.comm_id)},this.commsOverSubshells);this._comms.set(t.comm_id,s);try{await(await be.loadObject(t.target_name,t.target_module,this._targetRegistry))(s,e)}catch(i){throw s.close(),console.error("Exception opening new comm"),i}}async _handleCommClose(e){this._assertCurrentMessage(e);let t=e.content,s=this._comms.get(t.comm_id);if(!s){console.error("Comm not found for comm id "+t.comm_id);return}this._unregisterComm(s.commId);let i=s.onClose;i&&await i(e),s.dispose()}async _handleCommMsg(e){this._assertCurrentMessage(e);let t=e.content,s=this._comms.get(t.comm_id);if(!s)return;let i=s.onMsg;i&&await i(e)}_unregisterComm(e){this._comms.delete(e)}_updateConnectionStatus(e){if(this._connectionStatus!==e){if(this._connectionStatus=e,e!=="connecting"&&(this._reconnectAttempt=0,clearTimeout(this._reconnectTimeout)),this.status!=="dead")if(e==="connected"){let t=this._kernelSession===it,s=this.requestKernelInfo(),i=!1,r=()=>{i||(i=!0,t&&this._kernelSession===it&&(this._kernelSession=""),clearTimeout(o),this._pendingMessages.length>0&&this._sendPending())};s.then(r);let o=setTimeout(r,$l)}else this._updateStatus("unknown");this._connectionStatusChanged.emit(e)}}async _handleMessage(e){var t,s;let i=!1;if(e.parent_header&&e.channel==="iopub"&&(oe.isDisplayDataMsg(e)||oe.isUpdateDisplayDataMsg(e)||oe.isExecuteResultMsg(e))){let o=((t=e.content.transient)!==null&&t!==void 0?t:{}).display_id;o&&(i=await this._handleDisplayId(o,e),this._assertCurrentMessage(e))}if(!i&&e.parent_header){let r=e.parent_header,o=(s=this._futures)===null||s===void 0?void 0:s.get(r.msg_id);if(o)await o.handleMsg(e),this._assertCurrentMessage(e);else{let a=r.session===this.clientId;e.channel!=="iopub"&&a&&this._unhandledMessage.emit(e)}}if(e.channel==="iopub"){switch(e.header.msg_type){case"status":{let r=Wl.PageConfig.getOption("untracked_message_types");if(JSON.parse(r||"[]").includes(e.parent_header.msg_type))break;let a=e.content.execution_state;a==="restarting"&&Promise.resolve().then(async()=>{this._updateStatus("autorestarting"),this._clearKernelState(),await this.reconnect()}),this._updateStatus(a);break}case"comm_open":this.handleComms&&await this._handleCommOpen(e);break;case"comm_msg":this.handleComms&&await this._handleCommMsg(e);break;case"comm_close":this.handleComms&&await this._handleCommClose(e);break;default:break}this.isDisposed||(this._assertCurrentMessage(e),this._iopubMessage.emit(e))}}_reconnect(){if(this._errorIfDisposed(),clearTimeout(this._reconnectTimeout),this._reconnectAttempt<this._reconnectLimit){this._updateConnectionStatus("connecting");let e=be.getRandomIntInclusive(0,1e3*(Math.pow(2,this._reconnectAttempt)-1));console.warn(`Connection lost, reconnecting in ${Math.floor(e/1e3)} seconds.`);let t=this._selectedProtocol!=="";this._reconnectTimeout=setTimeout(this._createSocket,e,t),this._reconnectAttempt+=1}else this._updateConnectionStatus("disconnected");this._clearSocket()}_errorIfDisposed(){if(this.isDisposed)throw new Error("Kernel connection is disposed")}get hasPendingInput(){return this._hasPendingInput}set hasPendingInput(e){this._hasPendingInput=e,this._pendingInput.emit(e)}};qe.KernelConnection=bs;var be;(function(n){function e(r){switch(r.status){case"idle":case"busy":case"unknown":return;default:console.debug(`Kernel: ${r.status} (${r.id})`);break}}n.logKernelStatus=e;async function t(r,o){return r.sendShellMessage(o,!0).done}n.handleShellMessage=t;function s(r,o,a){return new Promise((d,c)=>{if(o){if(typeof requirejs=="undefined")throw new Error("requirejs not found");requirejs([o],u=>{if(u[r]===void 0){let l=`Object '${r}' not found in module '${o}'`;c(new Error(l))}else d(u[r])},c)}else a!=null&&a[r]?d(a[r]):c(new Error(`Object '${r}' not found in registry`))})}n.loadObject=s;function i(r,o){return r=Math.ceil(r),o=Math.floor(o),Math.floor(Math.random()*(o-r+1))+r}n.getRandomIntInclusive=i})(be||(be={}))});var Nr=R(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.KernelManager=void 0;var Jl=Je(),Ur=ee(),Ar=Ae(),Gl=He(),Xl=pn(),Yl=Cs(),Ql=_t(),gt=class extends Gl.BaseManager{constructor(e={}){var t,s,i;super(e),this._commsOverSubshells=Ar.CommsOverSubshells.PerCommTarget,this._isReady=!1,this._kernelConnections=new Set,this._models=new Map,this._runningChanged=new Ur.Signal(this),this._connectionFailure=new Ur.Signal(this),this._kernelAPIClient=(t=e.kernelAPIClient)!==null&&t!==void 0?t:new Xl.KernelAPIClient({serverSettings:this.serverSettings}),this._kernelSpecAPIClient=(s=e.kernelSpecAPIClient)!==null&&s!==void 0?s:new Ql.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._pollModels=new Jl.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:KernelManager#models",standby:(i=e.standby)!==null&&i!==void 0?i:"when-hidden"}),this._ready=(async()=>{await this._pollModels.start(),await this._pollModels.tick,this._isReady=!0})()}get isReady(){return this._isReady}get ready(){return this._ready}get runningChanged(){return this._runningChanged}get connectionFailure(){return this._connectionFailure}dispose(){this.isDisposed||(this._models.clear(),this._kernelConnections.forEach(e=>e.dispose()),this._pollModels.dispose(),super.dispose())}connectTo(e){var t;let{id:s}=e.model,i=(t=e.handleComms)!==null&&t!==void 0?t:!0;if(e.handleComms===void 0){for(let o of this._kernelConnections)if(o.id===s&&o.handleComms){i=!1;break}}e.commsOverSubshells=this._commsOverSubshells;let r=new Yl.KernelConnection({handleComms:i,...e,serverSettings:this.serverSettings,kernelAPIClient:this._kernelAPIClient,kernelSpecAPIClient:this._kernelSpecAPIClient});return this._onStarted(r),this._models.has(s)||this.refreshRunning().catch(()=>{}),r}running(){return this._models.values()}get runningCount(){return this._models.size}get commsOverSubshells(){return this._commsOverSubshells}set commsOverSubshells(e){this._commsOverSubshells=e;for(let t of this._kernelConnections)t.commsOverSubshells=e}async refreshRunning(){await this._pollModels.refresh(),await this._pollModels.tick}async startNew(e={},t={}){let s=await this._kernelAPIClient.startNew(e);return this.connectTo({...t,model:s})}async shutdown(e){await this._kernelAPIClient.shutdown(e),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all([...this._models.keys()].map(e=>this._kernelAPIClient.shutdown(e))),await this.refreshRunning()}async findById(e){return this._models.has(e)?this._models.get(e):(await this.refreshRunning(),this._models.get(e))}async requestRunning(){var e,t;let s;try{s=await this._kernelAPIClient.listRunning()}catch(i){throw(i instanceof Ar.ServerConnection.NetworkError||((e=i.response)===null||e===void 0?void 0:e.status)===503||((t=i.response)===null||t===void 0?void 0:t.status)===424)&&this._connectionFailure.emit(i),i}this.isDisposed||this._models.size===s.length&&s.every(i=>{let r=this._models.get(i.id);return r?r.connections===i.connections&&r.execution_state===i.execution_state&&r.last_activity===i.last_activity&&r.name===i.name&&r.reason===i.reason&&r.traceback===i.traceback:!1})||(this._models=new Map(s.map(i=>[i.id,i])),this._kernelConnections.forEach(i=>{this._models.has(i.id)||i.handleShutdown()}),this._runningChanged.emit(s))}_onStarted(e){this._kernelConnections.add(e),e.statusChanged.connect(this._onStatusChanged,this),e.disposed.connect(this._onDisposed,this)}_onDisposed(e){this._kernelConnections.delete(e),this.refreshRunning().catch(()=>{})}_onStatusChanged(e,t){t==="dead"&&this.refreshRunning().catch(()=>{})}};mt.KernelManager=gt;(function(n){class e extends n{constructor(){super(...arguments),this._readyPromise=new Promise(()=>{})}get isActive(){return!1}get parentReady(){return super.ready}async startNew(s={},i={}){return Promise.reject(new Error("Not implemented in no-op Kernel Manager"))}connectTo(s){throw new Error("Not implemented in no-op Kernel Manager")}async shutdown(s){return Promise.reject(new Error("Not implemented in no-op Kernel Manager"))}get ready(){return this.parentReady.then(()=>this._readyPromise)}async requestRunning(){return Promise.resolve()}}n.NoopManager=e})(gt||(mt.KernelManager=gt={}))});var Ms=R(H=>{"use strict";var Lr=H&&H.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Zl=H&&H.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Ps=H&&H.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&Lr(e,n,t);return Zl(e,n),e},ec=H&&H.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Lr(e,n,t)};Object.defineProperty(H,"__esModule",{value:!0});H.CommsOverSubshells=H.KernelConnection=H.KernelAPI=H.KernelMessage=H.Kernel=void 0;var tc=ms();Object.defineProperty(H,"CommsOverSubshells",{enumerable:!0,get:function(){return tc.CommsOverSubshells}});var nc=Ps(gr());H.Kernel=nc;var sc=Ps(Ze());H.KernelMessage=sc;var ic=Ps(pn());H.KernelAPI=ic;var rc=Cs();Object.defineProperty(H,"KernelConnection",{enumerable:!0,get:function(){return rc.KernelConnection}});ec(Nr(),H)});var Fr=R(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0})});var zr=R(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.KernelSpecManager=void 0;var oc=Y(),ac=Je(),Kr=ee(),lc=He(),cc=_t(),Es=class extends lc.BaseManager{constructor(e={}){var t,s;super(e),this._isReady=!1,this._connectionFailure=new Kr.Signal(this),this._specs=null,this._specsChanged=new Kr.Signal(this),this._kernelSpecAPIClient=(t=e.kernelSpecAPIClient)!==null&&t!==void 0?t:new cc.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._ready=Promise.all([this.requestSpecs()]).then(i=>{}).catch(i=>{}).then(()=>{this.isDisposed||(this._isReady=!0)}),this._pollSpecs=new ac.Poll({auto:!1,factory:()=>this.requestSpecs(),frequency:{interval:61*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:KernelSpecManager#specs",standby:(s=e.standby)!==null&&s!==void 0?s:"when-hidden"}),this.ready.then(()=>{this._pollSpecs.start()})}get isReady(){return this._isReady}get ready(){return this._ready}get specs(){return this._specs}get specsChanged(){return this._specsChanged}get connectionFailure(){return this._connectionFailure}dispose(){this._pollSpecs.dispose(),super.dispose()}async refreshSpecs(){await this._pollSpecs.refresh(),await this._pollSpecs.tick}async requestSpecs(){let e=await this._kernelSpecAPIClient.get();this.isDisposed||oc.JSONExt.deepEqual(e,this._specs)||(this._specs=e,this._specsChanged.emit(e))}};vn.KernelSpecManager=Es});var Is=R(fe=>{"use strict";var Vr=fe&&fe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),uc=fe&&fe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Br=fe&&fe.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&Vr(e,n,t);return uc(e,n),e},dc=fe&&fe.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Vr(e,n,t)};Object.defineProperty(fe,"__esModule",{value:!0});fe.KernelSpecAPI=fe.KernelSpec=void 0;var hc=Br(Fr());fe.KernelSpec=hc;var fc=Br(_t());fe.KernelSpecAPI=fc;dc(zr(),fe)});var Wr=R(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.BuildManager=void 0;var Rs=te(),Be=de(),_c="api/build",ks=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Be.ServerConnection.makeSettings()}get isAvailable(){return Rs.PageConfig.getOption("buildAvailable").toLowerCase()==="true"}get shouldCheck(){return Rs.PageConfig.getOption("buildCheck").toLowerCase()==="true"}getStatus(){let{_url:e,serverSettings:t}=this;return Be.ServerConnection.makeRequest(e,{},t).then(i=>{if(i.status!==200)throw new Be.ServerConnection.ResponseError(i);return i.json()}).then(i=>{if(typeof i.status!="string")throw new Error("Invalid data");if(typeof i.message!="string")throw new Error("Invalid data");return i})}build(){let{_url:e,serverSettings:t}=this,s={method:"POST"};return Be.ServerConnection.makeRequest(e,s,t).then(r=>{if(r.status===400)throw new Be.ServerConnection.ResponseError(r,"Build aborted");if(r.status!==200){let o=`Build failed with ${r.status}.
|
|
1
|
+
var Qo=Object.create;var $n=Object.defineProperty;var Zo=Object.getOwnPropertyDescriptor;var ea=Object.getOwnPropertyNames;var ta=Object.getPrototypeOf,na=Object.prototype.hasOwnProperty;var or=(r,e)=>()=>(r&&(e=r(r=0)),e);var O=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),sa=(r,e)=>{for(var t in e)$n(r,t,{get:e[t],enumerable:!0})},ra=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ea(e))!na.call(r,s)&&s!==t&&$n(r,s,{get:()=>e[s],enumerable:!(n=Zo(e,s))||n.enumerable});return r};var Wn=(r,e,t)=>(t=r!=null?Qo(ta(r)):{},ra(e||!r||!r.__esModule?$n(t,"default",{value:r,enumerable:!0}):t,r));var Gn=O((xt,_r)=>{(function(r,e){typeof xt=="object"&&typeof _r!="undefined"?e(xt):typeof define=="function"&&define.amd?define(["exports"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r.lumino_algorithm={}))})(xt,function(r){"use strict";r.ArrayExt=void 0,function(f){function y(S,M,g=0,_=-1){let p=S.length;if(p===0)return-1;g<0?g=Math.max(0,g+p):g=Math.min(g,p-1),_<0?_=Math.max(0,_+p):_=Math.min(_,p-1);let I;_<g?I=_+1+(p-g):I=_-g+1;for(let D=0;D<I;++D){let z=(g+D)%p;if(S[z]===M)return z}return-1}f.firstIndexOf=y;function b(S,M,g=-1,_=0){let p=S.length;if(p===0)return-1;g<0?g=Math.max(0,g+p):g=Math.min(g,p-1),_<0?_=Math.max(0,_+p):_=Math.min(_,p-1);let I;g<_?I=g+1+(p-_):I=g-_+1;for(let D=0;D<I;++D){let z=(g-D+p)%p;if(S[z]===M)return z}return-1}f.lastIndexOf=b;function P(S,M,g=0,_=-1){let p=S.length;if(p===0)return-1;g<0?g=Math.max(0,g+p):g=Math.min(g,p-1),_<0?_=Math.max(0,_+p):_=Math.min(_,p-1);let I;_<g?I=_+1+(p-g):I=_-g+1;for(let D=0;D<I;++D){let z=(g+D)%p;if(M(S[z],z))return z}return-1}f.findFirstIndex=P;function x(S,M,g=-1,_=0){let p=S.length;if(p===0)return-1;g<0?g=Math.max(0,g+p):g=Math.min(g,p-1),_<0?_=Math.max(0,_+p):_=Math.min(_,p-1);let I;g<_?I=g+1+(p-_):I=g-_+1;for(let D=0;D<I;++D){let z=(g-D+p)%p;if(M(S[z],z))return z}return-1}f.findLastIndex=x;function J(S,M,g=0,_=-1){let p=P(S,M,g,_);return p!==-1?S[p]:void 0}f.findFirstValue=J;function F(S,M,g=-1,_=0){let p=x(S,M,g,_);return p!==-1?S[p]:void 0}f.findLastValue=F;function K(S,M,g,_=0,p=-1){let I=S.length;if(I===0)return 0;_<0?_=Math.max(0,_+I):_=Math.min(_,I-1),p<0?p=Math.max(0,p+I):p=Math.min(p,I-1);let D=_,z=p-_+1;for(;z>0;){let Se=z>>1,at=D+Se;g(S[at],M)<0?(D=at+1,z-=Se+1):z=Se}return D}f.lowerBound=K;function Y(S,M,g,_=0,p=-1){let I=S.length;if(I===0)return 0;_<0?_=Math.max(0,_+I):_=Math.min(_,I-1),p<0?p=Math.max(0,p+I):p=Math.min(p,I-1);let D=_,z=p-_+1;for(;z>0;){let Se=z>>1,at=D+Se;g(S[at],M)>0?z=Se:(D=at+1,z-=Se+1)}return D}f.upperBound=Y;function B(S,M,g){if(S===M)return!0;if(S.length!==M.length)return!1;for(let _=0,p=S.length;_<p;++_)if(g?!g(S[_],M[_]):S[_]!==M[_])return!1;return!0}f.shallowEqual=B;function Z(S,M={}){let{start:g,stop:_,step:p}=M;if(p===void 0&&(p=1),p===0)throw new Error("Slice `step` cannot be zero.");let I=S.length;g===void 0?g=p<0?I-1:0:g<0?g=Math.max(g+I,p<0?-1:0):g>=I&&(g=p<0?I-1:I),_===void 0?_=p<0?-1:I:_<0?_=Math.max(_+I,p<0?-1:0):_>=I&&(_=p<0?I-1:I);let D;p<0&&_>=g||p>0&&g>=_?D=0:p<0?D=Math.floor((_-g+1)/p+1):D=Math.floor((_-g-1)/p+1);let z=[];for(let Se=0;Se<D;++Se)z[Se]=S[g+Se*p];return z}f.slice=Z;function G(S,M,g){let _=S.length;if(_<=1||(M<0?M=Math.max(0,M+_):M=Math.min(M,_-1),g<0?g=Math.max(0,g+_):g=Math.min(g,_-1),M===g))return;let p=S[M],I=M<g?1:-1;for(let D=M;D!==g;D+=I)S[D]=S[D+I];S[g]=p}f.move=G;function ue(S,M=0,g=-1){let _=S.length;if(!(_<=1))for(M<0?M=Math.max(0,M+_):M=Math.min(M,_-1),g<0?g=Math.max(0,g+_):g=Math.min(g,_-1);M<g;){let p=S[M],I=S[g];S[M++]=I,S[g--]=p}}f.reverse=ue;function Pe(S,M,g=0,_=-1){let p=S.length;if(p<=1||(g<0?g=Math.max(0,g+p):g=Math.min(g,p-1),_<0?_=Math.max(0,_+p):_=Math.min(_,p-1),g>=_))return;let I=_-g+1;if(M>0?M=M%I:M<0&&(M=(M%I+I)%I),M===0)return;let D=g+M;ue(S,g,D-1),ue(S,D,_),ue(S,g,_)}f.rotate=Pe;function Ie(S,M,g=0,_=-1){let p=S.length;if(p===0)return;g<0?g=Math.max(0,g+p):g=Math.min(g,p-1),_<0?_=Math.max(0,_+p):_=Math.min(_,p-1);let I;_<g?I=_+1+(p-g):I=_-g+1;for(let D=0;D<I;++D)S[(g+D)%p]=M}f.fill=Ie;function $o(S,M,g){let _=S.length;M<0?M=Math.max(0,M+_):M=Math.min(M,_);for(let p=_;p>M;--p)S[p]=S[p-1];S[M]=g}f.insert=$o;function ot(S,M){let g=S.length;if(M<0&&(M+=g),M<0||M>=g)return;let _=S[M];for(let p=M+1;p<g;++p)S[p-1]=S[p];return S.length=g-1,_}f.removeAt=ot;function Wo(S,M,g=0,_=-1){let p=y(S,M,g,_);return p!==-1&&ot(S,p),p}f.removeFirstOf=Wo;function Ho(S,M,g=-1,_=0){let p=b(S,M,g,_);return p!==-1&&ot(S,p),p}f.removeLastOf=Ho;function Jo(S,M,g=0,_=-1){let p=S.length;if(p===0)return 0;g<0?g=Math.max(0,g+p):g=Math.min(g,p-1),_<0?_=Math.max(0,_+p):_=Math.min(_,p-1);let I=0;for(let D=0;D<p;++D)g<=_&&D>=g&&D<=_&&S[D]===M||_<g&&(D<=_||D>=g)&&S[D]===M?I++:I>0&&(S[D-I]=S[D]);return I>0&&(S.length=p-I),I}f.removeAllOf=Jo;function Go(S,M,g=0,_=-1){let p,I=P(S,M,g,_);return I!==-1&&(p=ot(S,I)),{index:I,value:p}}f.removeFirstWhere=Go;function Xo(S,M,g=-1,_=0){let p,I=x(S,M,g,_);return I!==-1&&(p=ot(S,I)),{index:I,value:p}}f.removeLastWhere=Xo;function Yo(S,M,g=0,_=-1){let p=S.length;if(p===0)return 0;g<0?g=Math.max(0,g+p):g=Math.min(g,p-1),_<0?_=Math.max(0,_+p):_=Math.min(_,p-1);let I=0;for(let D=0;D<p;++D)g<=_&&D>=g&&D<=_&&M(S[D],D)||_<g&&(D<=_||D>=g)&&M(S[D],D)?I++:I>0&&(S[D-I]=S[D]);return I>0&&(S.length=p-I),I}f.removeAllWhere=Yo}(r.ArrayExt||(r.ArrayExt={}));function*e(...f){for(let y of f)yield*y}function*t(){}function*n(f,y=0){for(let b of f)yield[y++,b]}function*s(f,y){let b=0;for(let P of f)y(P,b++)&&(yield P)}function i(f,y){let b=0;for(let P of f)if(y(P,b++))return P}function o(f,y){let b=0;for(let P of f)if(y(P,b++))return b-1;return-1}function a(f,y){let b;for(let P of f){if(b===void 0){b=P;continue}y(P,b)<0&&(b=P)}return b}function h(f,y){let b;for(let P of f){if(b===void 0){b=P;continue}y(P,b)>0&&(b=P)}return b}function c(f,y){let b=!0,P,x;for(let J of f)b?(P=J,x=J,b=!1):y(J,P)<0?P=J:y(J,x)>0&&(x=J);return b?void 0:[P,x]}function u(f){return Array.from(f)}function l(f){let y={};for(let[b,P]of f)y[b]=P;return y}function d(f,y){let b=0;for(let P of f)if(y(P,b++)===!1)return}function m(f,y){let b=0;for(let P of f)if(y(P,b++)===!1)return!1;return!0}function v(f,y){let b=0;for(let P of f)if(y(P,b++))return!0;return!1}function*T(f,y){let b=0;for(let P of f)yield y(P,b++)}function*E(f,y,b){y===void 0?(y=f,f=0,b=1):b===void 0&&(b=1);let P=q.rangeLength(f,y,b);for(let x=0;x<P;x++)yield f+b*x}var q;(function(f){function y(b,P,x){return x===0?1/0:b>P&&x>0||b<P&&x<0?0:Math.ceil((P-b)/x)}f.rangeLength=y})(q||(q={}));function A(f,y,b){let P=f[Symbol.iterator](),x=0,J=P.next();if(J.done&&b===void 0)throw new TypeError("Reduce of empty iterable with no initial value.");if(J.done)return b;let F=P.next();if(F.done&&b===void 0)return J.value;if(F.done)return y(b,J.value,x++);let K;b===void 0?K=y(J.value,F.value,x++):K=y(y(b,J.value,x++),F.value,x++);let Y;for(;!(Y=P.next()).done;)K=y(K,Y.value,x++);return K}function*C(f,y){for(;0<y--;)yield f}function*w(f){yield f}function*k(f){if(typeof f.retro=="function")yield*f.retro();else for(let y=f.length-1;y>-1;y--)yield f[y]}function N(f){let y=[],b=new Set,P=new Map;for(let F of f)x(F);for(let[F]of P)J(F);return y;function x(F){let[K,Y]=F,B=P.get(Y);B?B.push(K):P.set(Y,[K])}function J(F){if(b.has(F))return;b.add(F);let K=P.get(F);if(K)for(let Y of K)J(Y);y.push(F)}}function*j(f,y){let b=0;for(let P of f)b++%y===0&&(yield P)}r.StringExt=void 0,function(f){function y(F,K,Y=0){let B=new Array(K.length);for(let Z=0,G=Y,ue=K.length;Z<ue;++Z,++G){if(G=F.indexOf(K[Z],G),G===-1)return null;B[Z]=G}return B}f.findIndices=y;function b(F,K,Y=0){let B=y(F,K,Y);if(!B)return null;let Z=0;for(let G=0,ue=B.length;G<ue;++G){let Pe=B[G]-Y;Z+=Pe*Pe}return{score:Z,indices:B}}f.matchSumOfSquares=b;function P(F,K,Y=0){let B=y(F,K,Y);if(!B)return null;let Z=0,G=Y-1;for(let ue=0,Pe=B.length;ue<Pe;++ue){let Ie=B[ue];Z+=Ie-G-1,G=Ie}return{score:Z,indices:B}}f.matchSumOfDeltas=P;function x(F,K,Y){let B=[],Z=0,G=0,ue=K.length;for(;Z<ue;){let Pe=K[Z],Ie=K[Z];for(;++Z<ue&&K[Z]===Ie+1;)Ie++;G<Pe&&B.push(F.slice(G,Pe)),Pe<Ie+1&&B.push(Y(F.slice(Pe,Ie+1))),G=Ie+1}return G<F.length&&B.push(F.slice(G)),B}f.highlight=x;function J(F,K){return F<K?-1:F>K?1:0}f.cmp=J}(r.StringExt||(r.StringExt={}));function*R(f,y){if(y<1)return;let b=f[Symbol.iterator](),P;for(;0<y--&&!(P=b.next()).done;)yield P.value}function*U(...f){let y=f.map(P=>P[Symbol.iterator]()),b=y.map(P=>P.next());for(;m(b,P=>!P.done);b=y.map(P=>P.next()))yield b.map(P=>P.value)}r.chain=e,r.each=d,r.empty=t,r.enumerate=n,r.every=m,r.filter=s,r.find=i,r.findIndex=o,r.map=T,r.max=h,r.min=a,r.minmax=c,r.once=w,r.range=E,r.reduce=A,r.repeat=C,r.retro=k,r.some=v,r.stride=j,r.take=R,r.toArray=u,r.toObject=l,r.topologicSort=N,r.zip=U})});var X=O((Ft,gr)=>{(function(r,e){typeof Ft=="object"&&typeof gr!="undefined"?e(Ft,Gn()):typeof define=="function"&&define.amd?define(["exports","@lumino/algorithm"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r.lumino_coreutils={},r.lumino_algorithm))})(Ft,function(r,e){"use strict";r.JSONExt=void 0,function(c){c.emptyObject=Object.freeze({}),c.emptyArray=Object.freeze([]);function u(C){return C===null||typeof C=="boolean"||typeof C=="number"||typeof C=="string"}c.isPrimitive=u;function l(C){return Array.isArray(C)}c.isArray=l;function d(C){return!u(C)&&!l(C)}c.isObject=d;function m(C,w){if(C===w)return!0;if(u(C)||u(w))return!1;let k=l(C),N=l(w);return k!==N?!1:k&&N?T(C,w):E(C,w)}c.deepEqual=m;function v(C){return u(C)?C:l(C)?q(C):A(C)}c.deepCopy=v;function T(C,w){if(C===w)return!0;if(C.length!==w.length)return!1;for(let k=0,N=C.length;k<N;++k)if(!m(C[k],w[k]))return!1;return!0}function E(C,w){if(C===w)return!0;for(let k in C)if(C[k]!==void 0&&!(k in w))return!1;for(let k in w)if(w[k]!==void 0&&!(k in C))return!1;for(let k in C){let N=C[k],j=w[k];if(!(N===void 0&&j===void 0)&&(N===void 0||j===void 0||!m(N,j)))return!1}return!0}function q(C){let w=new Array(C.length);for(let k=0,N=C.length;k<N;++k)w[k]=v(C[k]);return w}function A(C){let w={};for(let k in C){let N=C[k];N!==void 0&&(w[k]=v(N))}return w}}(r.JSONExt||(r.JSONExt={}));class t{constructor(){this._types=[],this._values=[]}types(){return this._types.slice()}hasData(u){return this._types.indexOf(u)!==-1}getData(u){let l=this._types.indexOf(u);return l!==-1?this._values[l]:void 0}setData(u,l){this.clearData(u),this._types.push(u),this._values.push(l)}clearData(u){let l=this._types.indexOf(u);l!==-1&&(this._types.splice(l,1),this._values.splice(l,1))}clear(){this._types.length=0,this._values.length=0}}class n{constructor(u={}){this._application=null,this._validatePlugin=()=>!0,this._plugins=new Map,this._services=new Map,u.validatePlugin&&(console.info("Plugins may be rejected by the custom validation plugin method."),this._validatePlugin=u.validatePlugin)}get application(){return this._application}set application(u){if(this._application!==null)throw Error("PluginRegistry.application is already set. It cannot be overridden.");this._application=u}get deferredPlugins(){return Array.from(this._plugins).filter(([u,l])=>l.autoStart==="defer").map(([u,l])=>u)}getPluginDescription(u){var l,d;return(d=(l=this._plugins.get(u))===null||l===void 0?void 0:l.description)!==null&&d!==void 0?d:""}hasPlugin(u){return this._plugins.has(u)}isPluginActivated(u){var l,d;return(d=(l=this._plugins.get(u))===null||l===void 0?void 0:l.activated)!==null&&d!==void 0?d:!1}listPlugins(){return Array.from(this._plugins.keys())}registerPlugin(u){if(this._plugins.has(u.id))throw new TypeError(`Plugin '${u.id}' is already registered.`);if(!this._validatePlugin(u))throw new Error(`Plugin '${u.id}' is not valid.`);let l=s.createPluginData(u);s.ensureNoCycle(l,this._plugins,this._services),l.provides&&this._services.set(l.provides,l.id),this._plugins.set(l.id,l)}registerPlugins(u){for(let l of u)this.registerPlugin(l)}deregisterPlugin(u,l){let d=this._plugins.get(u);if(d){if(d.activated&&!l)throw new Error(`Plugin '${u}' is still active.`);this._plugins.delete(u)}}async activatePlugin(u){let l=this._plugins.get(u);if(!l)throw new ReferenceError(`Plugin '${u}' is not registered.`);if(l.activated)return;if(l.promise)return l.promise;let d=l.requires.map(v=>this.resolveRequiredService(v)),m=l.optional.map(v=>this.resolveOptionalService(v));return l.promise=Promise.all([...d,...m]).then(v=>l.activate.apply(void 0,[this.application,...v])).then(v=>{l.service=v,l.activated=!0,l.promise=null}).catch(v=>{throw l.promise=null,v}),l.promise}async activatePlugins(u,l={}){switch(u){case"defer":{let d=this.deferredPlugins.filter(m=>this._plugins.get(m).autoStart).map(m=>this.activatePlugin(m));await Promise.all(d);break}case"startUp":{let m=s.collectStartupPlugins(this._plugins,l).map(async v=>{try{return await this.activatePlugin(v)}catch(T){console.error(`Plugin '${v}' failed to activate.`,T)}});await Promise.all(m);break}}}async deactivatePlugin(u){let l=this._plugins.get(u);if(!l)throw new ReferenceError(`Plugin '${u}' is not registered.`);if(!l.activated)return[];if(!l.deactivate)throw new TypeError(`Plugin '${u}'#deactivate() method missing`);let d=s.findDependents(u,this._plugins,this._services),m=d.map(v=>this._plugins.get(v));for(let v of m)if(!v.deactivate)throw new TypeError(`Plugin ${v.id}#deactivate() method missing (depends on ${u})`);for(let v of m){let T=[...v.requires,...v.optional].map(E=>{let q=this._services.get(E);return q?this._plugins.get(q).service:null});await v.deactivate(this.application,...T),v.service=null,v.activated=!1}return d.pop(),d}async resolveRequiredService(u){let l=this._services.get(u);if(!l)throw new TypeError(`No provider for: ${u.name}.`);let d=this._plugins.get(l);return d.activated||await this.activatePlugin(l),d.service}async resolveOptionalService(u){let l=this._services.get(u);if(!l)return null;let d=this._plugins.get(l);if(!d.activated)try{await this.activatePlugin(l)}catch(m){return console.error(m),null}return d.service}}var s;(function(c){class u{constructor(E){var q,A,C,w;this._activated=!1,this._promise=null,this._service=null,this.id=E.id,this.description=(q=E.description)!==null&&q!==void 0?q:"",this.activate=E.activate,this.deactivate=(A=E.deactivate)!==null&&A!==void 0?A:null,this.provides=(C=E.provides)!==null&&C!==void 0?C:null,this.autoStart=(w=E.autoStart)!==null&&w!==void 0?w:!1,this.requires=E.requires?E.requires.slice():[],this.optional=E.optional?E.optional.slice():[]}get activated(){return this._activated}set activated(E){this._activated=E}get service(){return this._service}set service(E){this._service=E}get promise(){return this._promise}set promise(E){this._promise=E}}function l(T){return new u(T)}c.createPluginData=l;function d(T,E,q){let A=[...T.requires,...T.optional],C=k=>{if(k===T.provides)return!0;let N=q.get(k);if(!N)return!1;let j=E.get(N),R=[...j.requires,...j.optional];return R.length===0?!1:(w.push(N),R.some(C)?!0:(w.pop(),!1))};if(!T.provides||A.length===0)return;let w=[T.id];if(A.some(C))throw new ReferenceError(`Cycle detected: ${w.join(" -> ")}.`)}c.ensureNoCycle=d;function m(T,E,q){let A=new Array,C=R=>{let U=E.get(R),f=[...U.requires,...U.optional];A.push(...f.reduce((y,b)=>{let P=q.get(b);return P&&y.push([R,P]),y},[]))};for(let R of E.keys())C(R);let w=A.filter(R=>R[1]===T),k=0;for(;w.length>k;){let R=w.length,U=new Set(w.map(f=>f[0]));for(let f of U)A.filter(y=>y[1]===f).forEach(y=>{w.includes(y)||w.push(y)});k=R}let N=e.topologicSort(w),j=N.findIndex(R=>R===T);return j===-1?[T]:N.slice(0,j+1)}c.findDependents=m;function v(T,E){let q=new Set;for(let A of T.keys())T.get(A).autoStart===!0&&q.add(A);if(E.startPlugins)for(let A of E.startPlugins)q.add(A);if(E.ignorePlugins)for(let A of E.ignorePlugins)q.delete(A);return Array.from(q)}c.collectStartupPlugins=v})(s||(s={}));class i{constructor(){this.promise=new Promise((u,l)=>{this._resolve=u,this._reject=l})}resolve(u){let l=this._resolve;l(u)}reject(u){let l=this._reject;l(u)}}class o{constructor(u,l){this.name=u,this.description=l!=null?l:"",this._tokenStructuralPropertyT=null}}function a(c){let u=0;for(let l=0,d=c.length;l<d;++l)l%4===0&&(u=Math.random()*4294967295>>>0),c[l]=u&255,u>>>=8}r.Random=void 0,function(c){c.getRandomValues=(()=>{let u=typeof window!="undefined"&&(window.crypto||window.msCrypto)||null;return u&&typeof u.getRandomValues=="function"?function(d){return u.getRandomValues(d)}:a})()}(r.Random||(r.Random={}));function h(c){let u=new Uint8Array(16),l=new Array(256);for(let d=0;d<16;++d)l[d]="0"+d.toString(16);for(let d=16;d<256;++d)l[d]=d.toString(16);return function(){return c(u),u[6]=64|u[6]&15,u[8]=128|u[8]&63,l[u[0]]+l[u[1]]+l[u[2]]+l[u[3]]+"-"+l[u[4]]+l[u[5]]+"-"+l[u[6]]+l[u[7]]+"-"+l[u[8]]+l[u[9]]+"-"+l[u[10]]+l[u[11]]+l[u[12]]+l[u[13]]+l[u[14]]+l[u[15]]}}r.UUID=void 0,function(c){c.uuid4=h(r.Random.getRandomValues)}(r.UUID||(r.UUID={})),r.MimeData=t,r.PluginRegistry=n,r.PromiseDelegate=i,r.Token=o})});var ee=O((Kt,pr)=>{(function(r,e){typeof Kt=="object"&&typeof pr!="undefined"?e(Kt,Gn(),X()):typeof define=="function"&&define.amd?define(["exports","@lumino/algorithm","@lumino/coreutils"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r.lumino_signaling={},r.lumino_algorithm,r.lumino_coreutils))})(Kt,function(r,e,t){"use strict";class n{constructor(a){this.sender=a}connect(a,h){return i.connect(this,a,h)}disconnect(a,h){return i.disconnect(this,a,h)}emit(a){i.emit(this,a)}}(function(o){function a(v,T){i.disconnectBetween(v,T)}o.disconnectBetween=a;function h(v){i.disconnectSender(v)}o.disconnectSender=h;function c(v){i.disconnectReceiver(v)}o.disconnectReceiver=c;function u(v){i.disconnectAll(v)}o.disconnectAll=u;function l(v){i.disconnectAll(v)}o.clearData=l;function d(){return i.exceptionHandler}o.getExceptionHandler=d;function m(v){let T=i.exceptionHandler;return i.exceptionHandler=v,T}o.setExceptionHandler=m})(n||(n={}));class s extends n{constructor(){super(...arguments),this._pending=new t.PromiseDelegate}async*[Symbol.asyncIterator](){let a=this._pending;for(;;)try{let{args:h,next:c}=await a.promise;a=c,yield h}catch{return}}emit(a){let h=this._pending,c=this._pending=new t.PromiseDelegate;h.resolve({args:a,next:c}),super.emit(a)}stop(){this._pending.promise.catch(()=>{}),this._pending.reject("stop"),this._pending=new t.PromiseDelegate}}var i;(function(o){o.exceptionHandler=R=>{console.error(R)};function a(R,U,f){f=f||void 0;let y=v.get(R.sender);if(y||(y=[],v.set(R.sender,y)),A(y,R,U,f))return!1;let b=f||U,P=T.get(b);P||(P=[],T.set(b,P));let x={signal:R,slot:U,thisArg:f};return y.push(x),P.push(x),!0}o.connect=a;function h(R,U,f){f=f||void 0;let y=v.get(R.sender);if(!y||y.length===0)return!1;let b=A(y,R,U,f);if(!b)return!1;let P=f||U,x=T.get(P);return b.signal=null,w(y),w(x),!0}o.disconnect=h;function c(R,U){let f=v.get(R);if(!f||f.length===0)return;let y=T.get(U);if(!(!y||y.length===0)){for(let b of y)b.signal&&b.signal.sender===R&&(b.signal=null);w(f),w(y)}}o.disconnectBetween=c;function u(R){let U=v.get(R);if(!(!U||U.length===0)){for(let f of U){if(!f.signal)continue;let y=f.thisArg||f.slot;f.signal=null,w(T.get(y))}w(U)}}o.disconnectSender=u;function l(R){let U=T.get(R);if(!(!U||U.length===0)){for(let f of U){if(!f.signal)continue;let y=f.signal.sender;f.signal=null,w(v.get(y))}w(U)}}o.disconnectReceiver=l;function d(R){u(R),l(R)}o.disconnectAll=d;function m(R,U){let f=v.get(R.sender);if(!(!f||f.length===0))for(let y=0,b=f.length;y<b;++y){let P=f[y];P.signal===R&&C(P,U)}}o.emit=m;let v=new WeakMap,T=new WeakMap,E=new Set,q=typeof requestAnimationFrame=="function"?requestAnimationFrame:setImmediate;function A(R,U,f,y){return e.find(R,b=>b.signal===U&&b.slot===f&&b.thisArg===y)}function C(R,U){let{signal:f,slot:y,thisArg:b}=R;try{y.call(b,f.sender,U)}catch(P){o.exceptionHandler(P)}}function w(R){E.size===0&&q(k),E.add(R)}function k(){E.forEach(N),E.clear()}function N(R){e.ArrayExt.removeAllWhere(R,j)}function j(R){return R.signal===null}})(i||(i={})),r.Signal=n,r.Stream=s})});var vr=O(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.ActivityMonitor=void 0;var mr=ee(),Xn=class{constructor(e){this._timer=-1,this._timeout=-1,this._isDisposed=!1,this._activityStopped=new mr.Signal(this),e.signal.connect(this._onSignalFired,this),this._timeout=e.timeout||1e3}get activityStopped(){return this._activityStopped}get timeout(){return this._timeout}set timeout(e){this._timeout=e}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,mr.Signal.clearData(this))}_onSignalFired(e,t){clearTimeout(this._timer),this._sender=e,this._args=t,this._timer=setTimeout(()=>{this._activityStopped.emit({sender:this._sender,args:this._args})},this._timeout)}};zt.ActivityMonitor=Xn});var wr=O(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0})});var Sr=O(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.LruCache=void 0;var va=128,Yn=class{constructor(e={}){if(this._map=new Map,this._maxSize=(e==null?void 0:e.maxSize)||va,this._maxSize<1)throw new Error("maxSize must be at least 1")}get size(){return this._map.size}clear(){this._map.clear()}get(e){let t=this._map.get(e)||null;return t!=null&&(this._map.delete(e),this._map.set(e,t)),t}set(e,t){this._map.size>=this._maxSize&&this._map.delete(this._map.keys().next().value),this._map.set(e,t)}};Vt.LruCache=Yn});var Cr=O(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.MarkdownCodeBlocks=void 0;var br;(function(r){r.CODE_BLOCK_MARKER="```";let e=[".markdown",".mdown",".mkdn",".md",".mkd",".mdwn",".mdtxt",".mdtext",".text",".txt",".Rmd"];class t{constructor(o){this.startLine=o,this.code="",this.endLine=-1}}r.MarkdownCodeBlock=t;function n(i){return e.indexOf(i)>-1}r.isMarkdown=n;function s(i){if(!i||i==="")return[];let o=i.split(`
|
|
2
|
+
`),a=[],h=null;for(let c=0;c<o.length;c++){let u=o[c],l=u.indexOf(r.CODE_BLOCK_MARKER)===0,d=h!=null;if(!(!l&&!d))if(d)h&&(l?(h.endLine=c-1,a.push(h),h=null):h.code+=u+`
|
|
3
|
+
`);else{h=new t(c);let m=u.indexOf(r.CODE_BLOCK_MARKER),v=u.lastIndexOf(r.CODE_BLOCK_MARKER);m!==v&&(h.code=u.substring(m+r.CODE_BLOCK_MARKER.length,v),h.endLine=c,a.push(h),h=null)}}return a}r.findMarkdownCodeBlocks=s})(br||(Bt.MarkdownCodeBlocks=br={}))});var Ir=O((Nu,Er)=>{"use strict";function ya(r,e){var t=r;e.slice(0,-1).forEach(function(s){t=t[s]||{}});var n=e[e.length-1];return n in t}function Pr(r){return typeof r=="number"||/^0x[0-9a-f]+$/i.test(r)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(r)}function Mr(r,e){return e==="constructor"&&typeof r[e]=="function"||e==="__proto__"}Er.exports=function(r,e){e||(e={});var t={bools:{},strings:{},unknownFn:null};typeof e.unknown=="function"&&(t.unknownFn=e.unknown),typeof e.boolean=="boolean"&&e.boolean?t.allBools=!0:[].concat(e.boolean).filter(Boolean).forEach(function(w){t.bools[w]=!0});var n={};function s(w){return n[w].some(function(k){return t.bools[k]})}Object.keys(e.alias||{}).forEach(function(w){n[w]=[].concat(e.alias[w]),n[w].forEach(function(k){n[k]=[w].concat(n[w].filter(function(N){return k!==N}))})}),[].concat(e.string).filter(Boolean).forEach(function(w){t.strings[w]=!0,n[w]&&[].concat(n[w]).forEach(function(k){t.strings[k]=!0})});var i=e.default||{},o={_:[]};function a(w,k){return t.allBools&&/^--[^=]+$/.test(k)||t.strings[w]||t.bools[w]||n[w]}function h(w,k,N){for(var j=w,R=0;R<k.length-1;R++){var U=k[R];if(Mr(j,U))return;j[U]===void 0&&(j[U]={}),(j[U]===Object.prototype||j[U]===Number.prototype||j[U]===String.prototype)&&(j[U]={}),j[U]===Array.prototype&&(j[U]=[]),j=j[U]}var f=k[k.length-1];Mr(j,f)||((j===Object.prototype||j===Number.prototype||j===String.prototype)&&(j={}),j===Array.prototype&&(j=[]),j[f]===void 0||t.bools[f]||typeof j[f]=="boolean"?j[f]=N:Array.isArray(j[f])?j[f].push(N):j[f]=[j[f],N])}function c(w,k,N){if(!(N&&t.unknownFn&&!a(w,N)&&t.unknownFn(N)===!1)){var j=!t.strings[w]&&Pr(k)?Number(k):k;h(o,w.split("."),j),(n[w]||[]).forEach(function(R){h(o,R.split("."),j)})}}Object.keys(t.bools).forEach(function(w){c(w,i[w]===void 0?!1:i[w])});var u=[];r.indexOf("--")!==-1&&(u=r.slice(r.indexOf("--")+1),r=r.slice(0,r.indexOf("--")));for(var l=0;l<r.length;l++){var d=r[l],m,v;if(/^--.+=/.test(d)){var T=d.match(/^--([^=]+)=([\s\S]*)$/);m=T[1];var E=T[2];t.bools[m]&&(E=E!=="false"),c(m,E,d)}else if(/^--no-.+/.test(d))m=d.match(/^--no-(.+)/)[1],c(m,!1,d);else if(/^--.+/.test(d))m=d.match(/^--(.+)/)[1],v=r[l+1],v!==void 0&&!/^(-|--)[^-]/.test(v)&&!t.bools[m]&&!t.allBools&&(!n[m]||!s(m))?(c(m,v,d),l+=1):/^(true|false)$/.test(v)?(c(m,v==="true",d),l+=1):c(m,t.strings[m]?"":!0,d);else if(/^-[^-]+/.test(d)){for(var q=d.slice(1,-1).split(""),A=!1,C=0;C<q.length;C++){if(v=d.slice(C+2),v==="-"){c(q[C],v,d);continue}if(/[A-Za-z]/.test(q[C])&&v[0]==="="){c(q[C],v.slice(1),d),A=!0;break}if(/[A-Za-z]/.test(q[C])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(v)){c(q[C],v,d),A=!0;break}if(q[C+1]&&q[C+1].match(/\W/)){c(q[C],d.slice(C+2),d),A=!0;break}else c(q[C],t.strings[q[C]]?"":!0,d)}m=d.slice(-1)[0],!A&&m!=="-"&&(r[l+1]&&!/^(-|--)[^-]/.test(r[l+1])&&!t.bools[m]&&(!n[m]||!s(m))?(c(m,r[l+1],d),l+=1):r[l+1]&&/^(true|false)$/.test(r[l+1])?(c(m,r[l+1]==="true",d),l+=1):c(m,t.strings[m]?"":!0,d))}else if((!t.unknownFn||t.unknownFn(d)!==!1)&&o._.push(t.strings._||!Pr(d)?d:Number(d)),e.stopEarly){o._.push.apply(o._,r.slice(l+1));break}}return Object.keys(i).forEach(function(w){ya(o,w.split("."))||(h(o,w.split("."),i[w]),(n[w]||[]).forEach(function(k){h(o,k.split("."),i[w])}))}),e["--"]?o["--"]=u.slice():u.forEach(function(w){o._.push(w)}),o}});var $t=O((Lu,Rr)=>{"use strict";function Oe(r){if(typeof r!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function Or(r,e){for(var t="",n=0,s=-1,i=0,o,a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||i===1))if(s!==a-1&&i===2){if(t.length<2||n!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var h=t.lastIndexOf("/");if(h!==t.length-1){h===-1?(t="",n=0):(t=t.slice(0,h),n=t.length-1-t.lastIndexOf("/")),s=a,i=0;continue}}else if(t.length===2||t.length===1){t="",n=0,s=a,i=0;continue}}e&&(t.length>0?t+="/..":t="..",n=2)}else t.length>0?t+="/"+r.slice(s+1,a):t=r.slice(s+1,a),n=a-s-1;s=a,i=0}else o===46&&i!==-1?++i:i=-1}return t}function wa(r,e){var t=e.dir||e.root,n=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+n:t+r+n:n}var Qe={resolve:function(){for(var e="",t=!1,n,s=arguments.length-1;s>=-1&&!t;s--){var i;s>=0?i=arguments[s]:(n===void 0&&(n=process.cwd()),i=n),Oe(i),i.length!==0&&(e=i+"/"+e,t=i.charCodeAt(0)===47)}return e=Or(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(Oe(e),e.length===0)return".";var t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=Or(e,!t),e.length===0&&!t&&(e="."),e.length>0&&n&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return Oe(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];Oe(n),n.length>0&&(e===void 0?e=n:e+="/"+n)}return e===void 0?".":Qe.normalize(e)},relative:function(e,t){if(Oe(e),Oe(t),e===t||(e=Qe.resolve(e),t=Qe.resolve(t),e===t))return"";for(var n=1;n<e.length&&e.charCodeAt(n)===47;++n);for(var s=e.length,i=s-n,o=1;o<t.length&&t.charCodeAt(o)===47;++o);for(var a=t.length,h=a-o,c=i<h?i:h,u=-1,l=0;l<=c;++l){if(l===c){if(h>c){if(t.charCodeAt(o+l)===47)return t.slice(o+l+1);if(l===0)return t.slice(o+l)}else i>c&&(e.charCodeAt(n+l)===47?u=l:l===0&&(u=0));break}var d=e.charCodeAt(n+l),m=t.charCodeAt(o+l);if(d!==m)break;d===47&&(u=l)}var v="";for(l=n+u+1;l<=s;++l)(l===s||e.charCodeAt(l)===47)&&(v.length===0?v+="..":v+="/..");return v.length>0?v+t.slice(o+u):(o+=u,t.charCodeAt(o)===47&&++o,t.slice(o))},_makeLong:function(e){return e},dirname:function(e){if(Oe(e),e.length===0)return".";for(var t=e.charCodeAt(0),n=t===47,s=-1,i=!0,o=e.length-1;o>=1;--o)if(t=e.charCodeAt(o),t===47){if(!i){s=o;break}}else i=!1;return s===-1?n?"/":".":n&&s===1?"//":e.slice(0,s)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Oe(e);var n=0,s=-1,i=!0,o;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,h=-1;for(o=e.length-1;o>=0;--o){var c=e.charCodeAt(o);if(c===47){if(!i){n=o+1;break}}else h===-1&&(i=!1,h=o+1),a>=0&&(c===t.charCodeAt(a)?--a===-1&&(s=o):(a=-1,s=h))}return n===s?s=h:s===-1&&(s=e.length),e.slice(n,s)}else{for(o=e.length-1;o>=0;--o)if(e.charCodeAt(o)===47){if(!i){n=o+1;break}}else s===-1&&(i=!1,s=o+1);return s===-1?"":e.slice(n,s)}},extname:function(e){Oe(e);for(var t=-1,n=0,s=-1,i=!0,o=0,a=e.length-1;a>=0;--a){var h=e.charCodeAt(a);if(h===47){if(!i){n=a+1;break}continue}s===-1&&(i=!1,s=a+1),h===46?t===-1?t=a:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||s===-1||o===0||o===1&&t===s-1&&t===n+1?"":e.slice(t,s)},format:function(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return wa("/",e)},parse:function(e){Oe(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var n=e.charCodeAt(0),s=n===47,i;s?(t.root="/",i=1):i=0;for(var o=-1,a=0,h=-1,c=!0,u=e.length-1,l=0;u>=i;--u){if(n=e.charCodeAt(u),n===47){if(!c){a=u+1;break}continue}h===-1&&(c=!1,h=u+1),n===46?o===-1?o=u:l!==1&&(l=1):o!==-1&&(l=-1)}return o===-1||h===-1||l===0||l===1&&o===h-1&&o===a+1?h!==-1&&(a===0&&s?t.base=t.name=e.slice(1,h):t.base=t.name=e.slice(a,h)):(a===0&&s?(t.name=e.slice(1,o),t.base=e.slice(1,h)):(t.name=e.slice(a,o),t.base=e.slice(a,h)),t.ext=e.slice(o,h)),a>0?t.dir=e.slice(0,a-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};Qe.posix=Qe;Rr.exports=Qe});var Dr=O((xu,kr)=>{"use strict";kr.exports=function(e,t){if(t=t.split(":")[0],e=+e,!e)return!1;switch(t){case"http":case"ws":return e!==80;case"https":case"wss":return e!==443;case"ftp":return e!==21;case"gopher":return e!==70;case"file":return!1}return e!==0}});var jr=O(Qn=>{"use strict";var Sa=Object.prototype.hasOwnProperty,ba;function Tr(r){try{return decodeURIComponent(r.replace(/\+/g," "))}catch{return null}}function qr(r){try{return encodeURIComponent(r)}catch{return null}}function Ca(r){for(var e=/([^=?#&]+)=?([^&]*)/g,t={},n;n=e.exec(r);){var s=Tr(n[1]),i=Tr(n[2]);s===null||i===null||s in t||(t[s]=i)}return t}function Pa(r,e){e=e||"";var t=[],n,s;typeof e!="string"&&(e="?");for(s in r)if(Sa.call(r,s)){if(n=r[s],!n&&(n===null||n===ba||isNaN(n))&&(n=""),s=qr(s),n=qr(n),s===null||n===null)continue;t.push(s+"="+n)}return t.length?e+t.join("&"):""}Qn.stringify=Pa;Qn.parse=Ca});var zr=O((Ku,Kr)=>{"use strict";var Ar=Dr(),Wt=jr(),Ma=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,Nr=/[\n\r\t]/g,Ea=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,Lr=/:\d+$/,Ia=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,Oa=/^[a-zA-Z]:/;function es(r){return(r||"").toString().replace(Ma,"")}var Zn=[["#","hash"],["?","query"],function(e,t){return Re(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],Ur={hash:1,query:1};function xr(r){var e;typeof window!="undefined"?e=window:typeof global!="undefined"?e=global:typeof self!="undefined"?e=self:e={};var t=e.location||{};r=r||t;var n={},s=typeof r,i;if(r.protocol==="blob:")n=new ke(unescape(r.pathname),{});else if(s==="string"){n=new ke(r,{});for(i in Ur)delete n[i]}else if(s==="object"){for(i in r)i in Ur||(n[i]=r[i]);n.slashes===void 0&&(n.slashes=Ea.test(r.href))}return n}function Re(r){return r==="file:"||r==="ftp:"||r==="http:"||r==="https:"||r==="ws:"||r==="wss:"}function Fr(r,e){r=es(r),r=r.replace(Nr,""),e=e||{};var t=Ia.exec(r),n=t[1]?t[1].toLowerCase():"",s=!!t[2],i=!!t[3],o=0,a;return s?i?(a=t[2]+t[3]+t[4],o=t[2].length+t[3].length):(a=t[2]+t[4],o=t[2].length):i?(a=t[3]+t[4],o=t[3].length):a=t[4],n==="file:"?o>=2&&(a=a.slice(2)):Re(n)?a=t[4]:n?s&&(a=a.slice(2)):o>=2&&Re(e.protocol)&&(a=t[4]),{protocol:n,slashes:s||Re(n),slashesCount:o,rest:a}}function Ra(r,e){if(r==="")return e;for(var t=(e||"/").split("/").slice(0,-1).concat(r.split("/")),n=t.length,s=t[n-1],i=!1,o=0;n--;)t[n]==="."?t.splice(n,1):t[n]===".."?(t.splice(n,1),o++):o&&(n===0&&(i=!0),t.splice(n,1),o--);return i&&t.unshift(""),(s==="."||s==="..")&&t.push(""),t.join("/")}function ke(r,e,t){if(r=es(r),r=r.replace(Nr,""),!(this instanceof ke))return new ke(r,e,t);var n,s,i,o,a,h,c=Zn.slice(),u=typeof e,l=this,d=0;for(u!=="object"&&u!=="string"&&(t=e,e=null),t&&typeof t!="function"&&(t=Wt.parse),e=xr(e),s=Fr(r||"",e),n=!s.protocol&&!s.slashes,l.slashes=s.slashes||n&&e.slashes,l.protocol=s.protocol||e.protocol||"",r=s.rest,(s.protocol==="file:"&&(s.slashesCount!==2||Oa.test(r))||!s.slashes&&(s.protocol||s.slashesCount<2||!Re(l.protocol)))&&(c[3]=[/(.*)/,"pathname"]);d<c.length;d++){if(o=c[d],typeof o=="function"){r=o(r,l);continue}i=o[0],h=o[1],i!==i?l[h]=r:typeof i=="string"?(a=i==="@"?r.lastIndexOf(i):r.indexOf(i),~a&&(typeof o[2]=="number"?(l[h]=r.slice(0,a),r=r.slice(a+o[2])):(l[h]=r.slice(a),r=r.slice(0,a)))):(a=i.exec(r))&&(l[h]=a[1],r=r.slice(0,a.index)),l[h]=l[h]||n&&o[3]&&e[h]||"",o[4]&&(l[h]=l[h].toLowerCase())}t&&(l.query=t(l.query)),n&&e.slashes&&l.pathname.charAt(0)!=="/"&&(l.pathname!==""||e.pathname!=="")&&(l.pathname=Ra(l.pathname,e.pathname)),l.pathname.charAt(0)!=="/"&&Re(l.protocol)&&(l.pathname="/"+l.pathname),Ar(l.port,l.protocol)||(l.host=l.hostname,l.port=""),l.username=l.password="",l.auth&&(a=l.auth.indexOf(":"),~a?(l.username=l.auth.slice(0,a),l.username=encodeURIComponent(decodeURIComponent(l.username)),l.password=l.auth.slice(a+1),l.password=encodeURIComponent(decodeURIComponent(l.password))):l.username=encodeURIComponent(decodeURIComponent(l.auth)),l.auth=l.password?l.username+":"+l.password:l.username),l.origin=l.protocol!=="file:"&&Re(l.protocol)&&l.host?l.protocol+"//"+l.host:"null",l.href=l.toString()}function ka(r,e,t){var n=this;switch(r){case"query":typeof e=="string"&&e.length&&(e=(t||Wt.parse)(e)),n[r]=e;break;case"port":n[r]=e,Ar(e,n.protocol)?e&&(n.host=n.hostname+":"+e):(n.host=n.hostname,n[r]="");break;case"hostname":n[r]=e,n.port&&(e+=":"+n.port),n.host=e;break;case"host":n[r]=e,Lr.test(e)?(e=e.split(":"),n.port=e.pop(),n.hostname=e.join(":")):(n.hostname=e,n.port="");break;case"protocol":n.protocol=e.toLowerCase(),n.slashes=!t;break;case"pathname":case"hash":if(e){var s=r==="pathname"?"/":"#";n[r]=e.charAt(0)!==s?s+e:e}else n[r]=e;break;case"username":case"password":n[r]=encodeURIComponent(e);break;case"auth":var i=e.indexOf(":");~i?(n.username=e.slice(0,i),n.username=encodeURIComponent(decodeURIComponent(n.username)),n.password=e.slice(i+1),n.password=encodeURIComponent(decodeURIComponent(n.password))):n.username=encodeURIComponent(decodeURIComponent(e))}for(var o=0;o<Zn.length;o++){var a=Zn[o];a[4]&&(n[a[1]]=n[a[1]].toLowerCase())}return n.auth=n.password?n.username+":"+n.password:n.username,n.origin=n.protocol!=="file:"&&Re(n.protocol)&&n.host?n.protocol+"//"+n.host:"null",n.href=n.toString(),n}function Da(r){(!r||typeof r!="function")&&(r=Wt.stringify);var e,t=this,n=t.host,s=t.protocol;s&&s.charAt(s.length-1)!==":"&&(s+=":");var i=s+(t.protocol&&t.slashes||Re(t.protocol)?"//":"");return t.username?(i+=t.username,t.password&&(i+=":"+t.password),i+="@"):t.password?(i+=":"+t.password,i+="@"):t.protocol!=="file:"&&Re(t.protocol)&&!n&&t.pathname!=="/"&&(i+="@"),(n[n.length-1]===":"||Lr.test(t.hostname)&&!t.port)&&(n+=":"),i+=n+t.pathname,e=typeof t.query=="object"?r(t.query):t.query,e&&(i+=e.charAt(0)!=="?"?"?"+e:e),t.hash&&(i+=t.hash),i}ke.prototype={set:ka,toString:Da};ke.extractProtocol=Fr;ke.location=xr;ke.trimLeft=es;ke.qs=Wt;Kr.exports=ke});var ts=O(Ze=>{"use strict";var Ta=Ze&&Ze.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ze,"__esModule",{value:!0});Ze.URLExt=void 0;var qa=$t(),Ht=Ta(zr()),Vr;(function(r){function e(c){if(typeof document!="undefined"&&document){let u=document.createElement("a");return u.href=c,u}return(0,Ht.default)(c)}r.parse=e;function t(c){return(0,Ht.default)(c).hostname}r.getHostName=t;function n(c){return c&&e(c).toString()}r.normalize=n;function s(...c){let u=(0,Ht.default)(c[0],{}),l=u.protocol===""&&u.slashes;l&&(u=(0,Ht.default)(c[0],"https:"+c[0]));let d=`${l?"":u.protocol}${u.slashes?"//":""}${u.auth}${u.auth?"@":""}${u.host}`,m=qa.posix.join(`${d&&u.pathname[0]!=="/"?"/":""}${u.pathname}`,...c.slice(1));return`${d}${m==="."?"":m}`}r.join=s;function i(c){return s(...c.split("/").map(encodeURIComponent))}r.encodeParts=i;function o(c){let u=Object.keys(c).filter(l=>l.length>0);return u.length?"?"+u.map(l=>{let d=encodeURIComponent(String(c[l]));return l+(d?"="+d:"")}).join("&"):""}r.objectToQueryString=o;function a(c){return c.replace(/^\?/,"").split("&").reduce((u,l)=>{let[d,m]=l.split("=");return d.length>0&&(u[d]=decodeURIComponent(m||"")),u},{})}r.queryStringToObject=a;function h(c,u=!1){let{protocol:l}=e(c);return(!l||c.toLowerCase().indexOf(l)!==0)&&(u?c.indexOf("//")!==0:c.indexOf("/")!==0)}r.isLocal=h})(Vr||(Ze.URLExt=Vr={}))});var Br=O((exports,module)=>{"use strict";var __importDefault=exports&&exports.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(exports,"__esModule",{value:!0});exports.PageConfig=void 0;exports.compareVersions=compareVersions;var coreutils_1=X(),minimist_1=__importDefault(Ir()),url_1=ts(),PageConfig;(function(PageConfig){function getOption(name){if(configData)return configData[name]||getBodyData(name);configData=Object.create(null);let found=!1;if(typeof document!="undefined"&&document){let r=document.getElementById("jupyter-config-data");r&&(configData=JSON.parse(r.textContent||""),found=!0)}if(!found&&typeof process!="undefined"&&process.argv)try{let cli=(0,minimist_1.default)(process.argv.slice(2)),path=$t(),fullPath="";"jupyter-config-data"in cli?fullPath=path.resolve(cli["jupyter-config-data"]):"JUPYTER_CONFIG_DATA"in process.env&&(fullPath=path.resolve(process.env.JUPYTER_CONFIG_DATA)),fullPath&&(configData=eval("require")(fullPath))}catch(r){console.error(r)}if(!coreutils_1.JSONExt.isObject(configData))configData=Object.create(null);else for(let r in configData)typeof configData[r]!="string"&&(configData[r]=JSON.stringify(configData[r]));return configData[name]||getBodyData(name)}PageConfig.getOption=getOption;function setOption(r,e){let t=getOption(r);return configData[r]=e,t}PageConfig.setOption=setOption;function getBaseUrl(){return url_1.URLExt.normalize(getOption("baseUrl")||"/")}PageConfig.getBaseUrl=getBaseUrl;function getTreeUrl(){return url_1.URLExt.join(getBaseUrl(),getOption("treeUrl"))}PageConfig.getTreeUrl=getTreeUrl;function getShareUrl(){return url_1.URLExt.normalize(getOption("shareUrl")||getBaseUrl())}PageConfig.getShareUrl=getShareUrl;function getTreeShareUrl(){return url_1.URLExt.normalize(url_1.URLExt.join(getShareUrl(),getOption("treeUrl")))}PageConfig.getTreeShareUrl=getTreeShareUrl;function getUrl(r){var e,t,n;let s=r.toShare?getShareUrl():getBaseUrl(),i=(e=r.mode)!==null&&e!==void 0?e:getOption("mode"),o=(t=r.workspace)!==null&&t!==void 0?t:getOption("workspace"),a=i==="single-document"?"doc":"lab";s=url_1.URLExt.join(s,a),o!==PageConfig.defaultWorkspace&&(s=url_1.URLExt.join(s,"workspaces",encodeURIComponent(o)));let h=(n=r.treePath)!==null&&n!==void 0?n:getOption("treePath");return h&&(s=url_1.URLExt.join(s,"tree",url_1.URLExt.encodeParts(h))),s}PageConfig.getUrl=getUrl,PageConfig.defaultWorkspace="default";function getWsUrl(r){let e=getOption("wsUrl");if(!e){if(r=r?url_1.URLExt.normalize(r):getBaseUrl(),r.indexOf("http")!==0)return"";e="ws"+r.slice(4)}return url_1.URLExt.normalize(e)}PageConfig.getWsUrl=getWsUrl;function getNBConvertURL({path:r,format:e,download:t}){let n=url_1.URLExt.encodeParts(r),s=url_1.URLExt.join(getBaseUrl(),"nbconvert",e,n);return t?s+"?download=true":s}PageConfig.getNBConvertURL=getNBConvertURL;function getToken(){return getOption("token")||getBodyData("jupyterApiToken")}PageConfig.getToken=getToken;function getNotebookVersion(){let r=getOption("notebookVersion");return r===""?[0,0,0]:JSON.parse(r)}PageConfig.getNotebookVersion=getNotebookVersion;let configData=null;function getBodyData(r){if(typeof document=="undefined"||!document.body)return"";let e=document.body.dataset[r];return typeof e=="undefined"?"":decodeURIComponent(e)}let Extension;(function(r){function e(s){try{let i=getOption(s);if(i)return JSON.parse(i)}catch(i){console.warn(`Unable to parse ${s}.`,i)}return[]}r.deferred=e("deferredExtensions"),r.disabled=e("disabledExtensions");function t(s){let i=s.indexOf(":"),o="";return i!==-1&&(o=s.slice(0,i)),r.deferred.some(a=>a===s||o&&a===o)}r.isDeferred=t;function n(s){let i=s.indexOf(":"),o="";return i!==-1&&(o=s.slice(0,i)),r.disabled.some(a=>a===s||o&&a===o)}r.isDisabled=n})(Extension=PageConfig.Extension||(PageConfig.Extension={}))})(PageConfig||(exports.PageConfig=PageConfig={}));function compareVersions(r,e){for(let t=0;t<3;t++)if(r[t]!==e[t])return r[t]-e[t];return 0}});var Wr=O(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.PathExt=void 0;var Le=$t(),$r;(function(r){function e(...l){let d=Le.posix.join(...l);return d==="."?"":u(d)}r.join=e;function t(...l){let d=Le.posix.join(...l);return d==="."?"":d}r.joinWithLeadingSlash=t;function n(l,d){return Le.posix.basename(l,d)}r.basename=n;function s(l){let d=u(Le.posix.dirname(l));return d==="."?"":d}r.dirname=s;function i(l){return Le.posix.extname(l)}r.extname=i;function o(l){return l===""?"":u(Le.posix.normalize(l))}r.normalize=o;function a(...l){return u(Le.posix.resolve(...l))}r.resolve=a;function h(l,d){return u(Le.posix.relative(l,d))}r.relative=h;function c(l){return l.length>0&&l.indexOf(".")!==0&&(l=`.${l}`),l}r.normalizeExtension=c;function u(l){return l.indexOf("/")===0&&(l=l.slice(1)),l}r.removeSlash=u})($r||(Jt.PathExt=$r={}))});var Hr=O(ns=>{"use strict";Object.defineProperty(ns,"__esModule",{value:!0});ns.signalToPromise=Ua;var ja=X();function Ua(r,e){let t=new ja.PromiseDelegate;function n(){r.disconnect(s)}function s(i,o){n(),t.resolve([i,o])}return r.connect(s),(e!=null?e:0)>0&&setTimeout(()=>{n(),t.reject(`Signal not emitted within ${e} ms.`)},e),t.promise}});var Gr=O(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.Text=void 0;var Jr;(function(r){let e=2>1;function t(o,a){if(!e)return o;let h=o;for(let c=0;c+1<a.length&&c<o;c++){let u=a.charCodeAt(c);if(u>=55296&&u<=56319){let l=a.charCodeAt(c+1);l>=56320&&l<=57343&&(h--,c++)}}return h}r.jsIndexToCharIndex=t;function n(o,a){if(!e)return o;let h=o;for(let c=0;c+1<a.length&&c<h;c++){let u=a.charCodeAt(c);if(u>=55296&&u<=56319){let l=a.charCodeAt(c+1);l>=56320&&l<=57343&&(h++,c++)}}return h}r.charIndexToJsIndex=n;function s(o,a=!1){return o.replace(/^(\w)|[\s-_:]+(\w)/g,function(h,c,u){return u?u.toUpperCase():a?c.toUpperCase():c.toLowerCase()})}r.camelCase=s;function i(o){return(o||"").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}r.titleCase=i})(Jr||(Gt.Text=Jr={}))});var Yr=O(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.Time=void 0;var Aa=[{name:"years",milliseconds:365*24*60*60*1e3},{name:"months",milliseconds:30*24*60*60*1e3},{name:"days",milliseconds:24*60*60*1e3},{name:"hours",milliseconds:60*60*1e3},{name:"minutes",milliseconds:60*1e3},{name:"seconds",milliseconds:1e3}],Xr;(function(r){function e(n,s="long"){let i=document.documentElement.lang||"en",o=new Intl.RelativeTimeFormat(i,{numeric:"auto",style:s}),a=new Date(n).getTime()-Date.now();for(let h of Aa){let c=Math.ceil(a/h.milliseconds);if(c!==0)return o.format(c,h.name)}return o.format(0,"seconds")}r.formatHuman=e;function t(n){let s=document.documentElement.lang||"en";return new Intl.DateTimeFormat(s,{dateStyle:"short",timeStyle:"short"}).format(new Date(n))}r.format=t})(Xr||(Xt.Time=Xr={}))});var Qr=O(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.JupyterPluginRegistry=void 0;var Na=X(),La=5e3,ss=class extends Na.PluginRegistry{constructor(e){var t;super(e),this._pluginData=new Map,this._expectedActivationTime=(t=e==null?void 0:e.expectedActivationTime)!==null&&t!==void 0?t:La}registerPlugin(e){return this._pluginData.set(e.id,e),super.registerPlugin(e)}async activatePlugin(e){let t=performance.now(),n=setTimeout(()=>{console.warn(`Plugin ${e} is taking too long to activate.`)},this._expectedActivationTime);try{let s=await super.activatePlugin(e);clearTimeout(n);let o=performance.now()-t;if(o>=this._expectedActivationTime){let a=this._getDependentCount(e);console.warn(`Plugin ${e} (with ${a} dependants) took ${o.toFixed(2)}ms to activate.`)}return s}catch(s){throw clearTimeout(n),console.error(`Error activating plugin: ${e}`,s),s}}_getDependentCount(e){var t;let n=this._pluginData.get(e);if(!(n!=null&&n.provides))return 0;let s=n.provides.name,i=0;for(let[o,a]of this._pluginData.entries()){if(o===e)continue;((t=a.requires)===null||t===void 0?void 0:t.filter(c=>!!c).some(c=>c.name===s))&&i++}return i}};Yt.JupyterPluginRegistry=ss});var te=O(re=>{"use strict";var xa=re&&re.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),Me=re&&re.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&xa(e,r,t)};Object.defineProperty(re,"__esModule",{value:!0});Me(vr(),re);Me(wr(),re);Me(Sr(),re);Me(Cr(),re);Me(Br(),re);Me(Wr(),re);Me(Hr(),re);Me(Gr(),re);Me(Yr(),re);Me(ts(),re);Me(Qr(),re)});var et=O(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.supportedKernelWebSocketProtocols=void 0;V.createMessage=Ka;V.isStreamMsg=za;V.isDisplayDataMsg=Va;V.isUpdateDisplayDataMsg=Ba;V.isExecuteInputMsg=$a;V.isExecuteResultMsg=Wa;V.isErrorMsg=Ha;V.isStatusMsg=Ja;V.isClearOutputMsg=Ga;V.isDebugEventMsg=Xa;V.isCommOpenMsg=Ya;V.isCommCloseMsg=Qa;V.isCommMsgMsg=Za;V.isInfoRequestMsg=el;V.isExecuteReplyMsg=tl;V.isDebugRequestMsg=nl;V.isDebugReplyMsg=sl;V.isInputRequestMsg=rl;V.isInputReplyMsg=il;var Fa=X();function Ka(r){var e,t,n,s,i,o;return{buffers:(e=r.buffers)!==null&&e!==void 0?e:[],channel:r.channel,content:r.content,header:{date:new Date().toISOString(),msg_id:(t=r.msgId)!==null&&t!==void 0?t:Fa.UUID.uuid4(),msg_type:r.msgType,session:r.session,username:(n=r.username)!==null&&n!==void 0?n:"",subshell_id:(s=r.subshellId)!==null&&s!==void 0?s:null,version:"5.2"},metadata:(i=r.metadata)!==null&&i!==void 0?i:{},parent_header:(o=r.parentHeader)!==null&&o!==void 0?o:{}}}function za(r){return r.header.msg_type==="stream"}function Va(r){return r.header.msg_type==="display_data"}function Ba(r){return r.header.msg_type==="update_display_data"}function $a(r){return r.header.msg_type==="execute_input"}function Wa(r){return r.header.msg_type==="execute_result"}function Ha(r){return r.header.msg_type==="error"}function Ja(r){return r.header.msg_type==="status"}function Ga(r){return r.header.msg_type==="clear_output"}function Xa(r){return r.header.msg_type==="debug_event"}function Ya(r){return r.header.msg_type==="comm_open"}function Qa(r){return r.header.msg_type==="comm_close"}function Za(r){return r.header.msg_type==="comm_msg"}function el(r){return r.header.msg_type==="kernel_info_request"}function tl(r){return r.header.msg_type==="execute_reply"}function nl(r){return r.header.msg_type==="debug_request"}function sl(r){return r.header.msg_type==="debug_reply"}function rl(r){return r.header.msg_type==="input_request"}function il(r){return r.header.msg_type==="input_reply"}var Zr;(function(r){r.v1KernelWebsocketJupyterOrg="v1.kernel.websocket.jupyter.org"})(Zr||(V.supportedKernelWebSocketProtocols=Zr={}))});var ti=O(De=>{"use strict";var ol=De&&De.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),al=De&&De.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),ll=De&&De.__importStar||function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&ol(t,e,n[s]);return al(t,e),t}}();Object.defineProperty(De,"__esModule",{value:!0});De.serialize=cl;De.deserialize=ul;var ei=ll(et());function cl(r,e=""){switch(e){case ei.supportedKernelWebSocketProtocols.v1KernelWebsocketJupyterOrg:return tt.serializeV1KernelWebsocketJupyterOrg(r);default:return tt.serializeDefault(r)}}function ul(r,e=""){switch(e){case ei.supportedKernelWebSocketProtocols.v1KernelWebsocketJupyterOrg:return tt.deserializeV1KernelWebsocketJupyterOrg(r);default:return tt.deserializeDefault(r)}}var tt;(function(r){function e(a){let h,c=new DataView(a),u=Number(c.getBigUint64(0,!0)),l=[];for(let C=0;C<u;C++)l.push(Number(c.getBigUint64(8*(C+1),!0)));let d=new TextDecoder("utf8"),m=d.decode(a.slice(l[0],l[1])),v=JSON.parse(d.decode(a.slice(l[1],l[2]))),T=JSON.parse(d.decode(a.slice(l[2],l[3]))),E=JSON.parse(d.decode(a.slice(l[3],l[4]))),q=JSON.parse(d.decode(a.slice(l[4],l[5]))),A=[];for(let C=5;C<l.length-1;C++)A.push(new DataView(a.slice(l[C],l[C+1])));return h={channel:m,header:v,parent_header:T,metadata:E,content:q,buffers:A},h}r.deserializeV1KernelWebsocketJupyterOrg=e;function t(a){let h=JSON.stringify(a.header),c=a.parent_header==null?"{}":JSON.stringify(a.parent_header),u=JSON.stringify(a.metadata),l=JSON.stringify(a.content),d=a.buffers!==void 0?a.buffers:[],m=5+d.length+1,v=[];v.push(8*(1+m)),v.push(a.channel.length+v[v.length-1]);let T=new TextEncoder,E=T.encode(a.channel),q=T.encode(h),A=T.encode(c),C=T.encode(u),w=T.encode(l),k=new Uint8Array(E.length+q.length+A.length+C.length+w.length);k.set(E),k.set(q,E.length),k.set(A,E.length+q.length),k.set(C,E.length+q.length+A.length),k.set(w,E.length+q.length+A.length+C.length);for(let f of[q.length,A.length,C.length,w.length])v.push(f+v[v.length-1]);let N=0;for(let f of d){let y=f.byteLength;v.push(y+v[v.length-1]),N+=y}let j=new Uint8Array(8*(1+m)+k.byteLength+N),R=new ArrayBuffer(8),U=new DataView(R);U.setBigUint64(0,BigInt(m),!0),j.set(new Uint8Array(R),0);for(let f=0;f<v.length;f++)U.setBigUint64(0,BigInt(v[f]),!0),j.set(new Uint8Array(R),8*(f+1));j.set(k,v[0]);for(let f=0;f<d.length;f++){let y=d[f];j.set(new Uint8Array(ArrayBuffer.isView(y)?y.buffer:y),v[5+f])}return j.buffer}r.serializeV1KernelWebsocketJupyterOrg=t;function n(a){let h;return typeof a=="string"?h=JSON.parse(a):h=i(a),h}r.deserializeDefault=n;function s(a){var h;let c;return!((h=a.buffers)===null||h===void 0)&&h.length?c=o(a):c=JSON.stringify(a),c}r.serializeDefault=s;function i(a){let h=new DataView(a),c=h.getUint32(0),u=[];if(c<2)throw new Error("Invalid incoming Kernel Message");for(let m=1;m<=c;m++)u.push(h.getUint32(m*4));let l=new Uint8Array(a.slice(u[0],u[1])),d=JSON.parse(new TextDecoder("utf8").decode(l));d.buffers=[];for(let m=1;m<c;m++){let v=u[m],T=u[m+1]||a.byteLength;d.buffers.push(new DataView(a.slice(v,T)))}return d}function o(a){let h=[],c=[],u=new TextEncoder,l=[];a.buffers!==void 0&&(l=a.buffers,delete a.buffers);let d=u.encode(JSON.stringify(a));c.push(d.buffer);for(let E=0;E<l.length;E++){let q=l[E];c.push(ArrayBuffer.isView(q)?q.buffer:q)}let m=c.length;h.push(4*(m+1));for(let E=0;E+1<c.length;E++)h.push(h[h.length-1]+c[E].byteLength);let v=new Uint8Array(h[h.length-1]+c[c.length-1].byteLength),T=new DataView(v.buffer);T.setUint32(0,m);for(let E=0;E<h.length;E++)T.setUint32(4*(E+1),h[E]);for(let E=0;E<c.length;E++)v.set(new Uint8Array(c[E]),h[E]);return v.buffer}})(tt||(tt={}))});var ni=O(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.default=WebSocket});var he=O(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});Zt.ServerConnection=void 0;var xe=te(),si=ti(),is;typeof window=="undefined"?is=ni():is=WebSocket;var os;(function(r){function e(i){return Qt.makeSettings(i)}r.makeSettings=e;function t(i,o,a){return Qt.handleRequest(i,o,a)}r.makeRequest=t;class n extends Error{static async create(o){try{let a=await o.json(),{message:h,traceback:c}=a;return c&&console.error(c),new n(o,h!=null?h:n._defaultMessage(o),c!=null?c:"")}catch(a){return console.debug(a),new n(o)}}constructor(o,a=n._defaultMessage(o),h=""){super(a),this.response=o,this.traceback=h}static _defaultMessage(o){return`Invalid response: ${o.status} ${o.statusText}`}}r.ResponseError=n;class s extends TypeError{constructor(o){super(o.message),this.stack=o.stack}}r.NetworkError=s})(os||(Zt.ServerConnection=os={}));var Qt;(function(r){function e(s={}){var i;let o=xe.PageConfig.getBaseUrl(),a=xe.PageConfig.getWsUrl(),h=xe.URLExt.normalize(s.baseUrl)||o,c=s.wsUrl;!c&&h===o&&(c=a),!c&&h.indexOf("http")===0&&(c="ws"+h.slice(4)),c=c!=null?c:a;let u=xe.PageConfig.getOption("appendToken").toLowerCase(),l;return u===""?l=typeof window=="undefined"||typeof process!="undefined"&&((i=process==null?void 0:process.env)===null||i===void 0?void 0:i.JEST_WORKER_ID)!==void 0||xe.URLExt.getHostName(o)!==xe.URLExt.getHostName(c):l=u==="true",{init:{cache:"no-store",credentials:"same-origin"},fetch,Headers,Request,WebSocket:is,token:xe.PageConfig.getToken(),appUrl:xe.PageConfig.getOption("appUrl"),appendToken:l,serializer:{serialize:si.serialize,deserialize:si.deserialize},...s,baseUrl:h,wsUrl:c}}r.makeSettings=e;function t(s,i,o){var a;if(s.indexOf(o.baseUrl)!==0)throw new Error("Can only be used for notebook server requests");((a=i.cache)!==null&&a!==void 0?a:o.init.cache)==="no-store"&&(s+=(/\?/.test(s)?"&":"?")+new Date().getTime());let c=new o.Request(s,{...o.init,...i}),u=!1;if(o.token&&(u=!0,c.headers.append("Authorization",`token ${o.token}`)),typeof document!="undefined"){let l=n("_xsrf");l!==void 0&&(u=!0,c.headers.append("X-XSRFToken",l))}return!c.headers.has("Content-Type")&&u&&c.headers.set("Content-Type","application/json"),o.fetch.call(null,c).catch(l=>{throw new os.NetworkError(l)})}r.handleRequest=t;function n(s){let i="";try{i=document.cookie}catch{return}let o=s+"=",a;for(let h of i.split(";")){let c=h.trim();c.startsWith(o)&&(a=c.substring(o.length))}return a}})(Qt||(Qt={}))});var Je=O(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});en.BaseManager=void 0;var ri=ee(),hl=he(),as=class{constructor(e){var t;this._isDisposed=!1,this._disposed=new ri.Signal(this),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:hl.ServerConnection.makeSettings()}get disposed(){return this._disposed}get isDisposed(){return this._isDisposed}get isActive(){return!0}dispose(){this.isDisposed||(this._isDisposed=!0,this._disposed.emit(void 0),ri.Signal.clearData(this))}};en.BaseManager=as});var oi=O(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.ConfigWithDefaults=Fe.ConfigSection=Fe.ConfigSectionManager=void 0;var dl=te(),nt=Ae(),fl="api/config",ls=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:nt.ServerConnection.makeSettings()}async create(e){let t=new tn({...e,serverSettings:this.serverSettings});return await t.load(),t}};Fe.ConfigSectionManager=ls;var ii;(function(r){async function e(s){if(!t){let o=new tn(s);return await o.load(),o}return await t.create(s)}r.create=e;let t;function n(s){if(t)throw new Error("ConfigSectionManager already set. If you would like to create a config section, use the `IConfigSectionManager` token in a plugin.");t=s}r._setConfigSectionManager=n})(ii||(Fe.ConfigSection=ii={}));var tn=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:nt.ServerConnection.makeSettings(),this._name=e.name}get data(){return this._data}async load(){let e=await nt.ServerConnection.makeRequest(this._url,{},this.serverSettings);if(e.status!==200)throw await nt.ServerConnection.ResponseError.create(e);this._data=await e.json()}async update(e){this._data={...this._data,...e};let t={method:"PATCH",body:JSON.stringify(e)},n=await nt.ServerConnection.makeRequest(this._url,t,this.serverSettings);if(n.status!==200)throw await nt.ServerConnection.ResponseError.create(n);return this._data=await n.json(),this._data}get _url(){return dl.URLExt.join(this.serverSettings.baseUrl,fl,encodeURIComponent(this._name))}},cs=class{constructor(e){var t,n;this._className="",this._section=e.section,this._defaults=(t=e.defaults)!==null&&t!==void 0?t:{},this._className=(n=e.className)!==null&&n!==void 0?n:""}get(e){let t=this._classData();return e in t?t[e]:this._defaults[e]}set(e,t){let n={};if(n[e]=t,this._className){let s={};return s[this._className]=n,this._section.update(s)}else return this._section.update(n)}_classData(){let e=this._section.data;return this._className&&this._className in e?e[this._className]:e}};Fe.ConfigWithDefaults=cs});var ai=O(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});nn.ConnectionStatus=void 0;var us=class{constructor(){this.isConnected=!0}};nn.ConnectionStatus=us});var rn=O((sn,li)=>{(function(r,e){typeof sn=="object"&&typeof li!="undefined"?e(sn,ee()):typeof define=="function"&&define.amd?define(["exports","@lumino/signaling"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r.lumino_disposable={},r.lumino_signaling))})(sn,function(r,e){"use strict";class t{constructor(a){this._fn=a}get isDisposed(){return!this._fn}dispose(){if(!this._fn)return;let a=this._fn;this._fn=null,a()}}class n extends t{constructor(){super(...arguments),this._disposed=new e.Signal(this)}get disposed(){return this._disposed}dispose(){this.isDisposed||(super.dispose(),this._disposed.emit(void 0),e.Signal.clearData(this))}}class s{constructor(){this._isDisposed=!1,this._items=new Set}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,this._items.forEach(a=>{a.dispose()}),this._items.clear())}contains(a){return this._items.has(a)}add(a){this._items.add(a)}remove(a){this._items.delete(a)}clear(){this._items.clear()}}(function(o){function a(h){let c=new o;for(let u of h)c.add(u);return c}o.from=a})(s||(s={}));class i extends s{constructor(){super(...arguments),this._disposed=new e.Signal(this)}get disposed(){return this._disposed}dispose(){this.isDisposed||(super.dispose(),this._disposed.emit(void 0),e.Signal.clearData(this))}}(function(o){function a(h){let c=new o;for(let u of h)c.add(u);return c}o.from=a})(i||(i={})),r.DisposableDelegate=t,r.DisposableSet=s,r.ObservableDisposableDelegate=n,r.ObservableDisposableSet=i})});var lt=O(hs=>{"use strict";Object.defineProperty(hs,"__esModule",{value:!0});hs.validateProperty=_l;function _l(r,e,t,n=[]){if(!r.hasOwnProperty(e))throw Error(`Missing property '${e}'`);let s=r[e];if(t!==void 0){let i;switch(t){case"array":i=Array.isArray(s);break;case"object":i=typeof s!="undefined";break;default:i=typeof s===t}if(!i)throw new Error(`Property '${e}' is not of type '${t}'`);if(n.length>0){let o;switch(t){case"string":case"number":case"boolean":o=n.includes(s);break;default:o=n.findIndex(a=>a===s)>=0;break}if(!o)throw new Error(`Property '${e}' is not one of the valid values ${JSON.stringify(n)}`)}}}});var ci=O(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.validateContentsModel=gl;on.validateCheckpointModel=pl;var Te=lt();function gl(r){(0,Te.validateProperty)(r,"name","string"),(0,Te.validateProperty)(r,"path","string"),(0,Te.validateProperty)(r,"type","string"),(0,Te.validateProperty)(r,"created","string"),(0,Te.validateProperty)(r,"last_modified","string"),(0,Te.validateProperty)(r,"mimetype","object"),(0,Te.validateProperty)(r,"content","object"),(0,Te.validateProperty)(r,"format","object")}function pl(r){(0,Te.validateProperty)(r,"id","string"),(0,Te.validateProperty)(r,"last_modified","string")}});var _s=O(ne=>{"use strict";var ml=ne&&ne.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),vl=ne&&ne.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),yl=ne&&ne.__importStar||function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&ml(t,e,n[s]);return vl(t,e),t}}();Object.defineProperty(ne,"__esModule",{value:!0});ne.RestContentProvider=ne.ContentProviderRegistry=ne.Drive=ne.ContentsManager=ne.Contents=void 0;var de=te(),wl=X(),Sl=rn(),ct=ee(),$=Ae(),Ne=yl(ci()),bl="api/contents",Cl="files",ui;(function(r){function e(n){Ne.validateContentsModel(n)}r.validateContentsModel=e;function t(n){Ne.validateCheckpointModel(n)}r.validateCheckpointModel=t})(ui||(ne.Contents=ui={}));var ds=class{constructor(e={}){var t,n;this._isDisposed=!1,this._additionalDrives=new Map,this._fileChanged=new ct.Signal(this);let s=this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:$.ServerConnection.makeSettings();this._defaultDrive=(n=e.defaultDrive)!==null&&n!==void 0?n:new an({serverSettings:s}),this._defaultDrive.fileChanged.connect(this._onFileChanged,this)}get defaultDrive(){return this._defaultDrive}get fileChanged(){return this._fileChanged}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,ct.Signal.clearData(this))}addDrive(e){this._additionalDrives.set(e.name,e),e.fileChanged.connect(this._onFileChanged,this)}getSharedModelFactory(e,t){var n,s;let[i]=this._driveForPath(e),o=(n=i.contentProviderRegistry)===null||n===void 0?void 0:n.getProvider(t==null?void 0:t.contentProviderId);return o!=null&&o.sharedModelFactory?o.sharedModelFactory:(s=i.sharedModelFactory)!==null&&s!==void 0?s:null}localPath(e){let t=e.split("/"),n=t[0].split(":");return n.length===1||!this._additionalDrives.has(n[0])?de.PathExt.removeSlash(e):de.PathExt.join(n.slice(1).join(":"),...t.slice(1))}normalize(e){let t=e.split(":");return t.length===1?de.PathExt.normalize(e):`${t[0]}:${de.PathExt.normalize(t.slice(1).join(":"))}`}resolvePath(e,t){let n=this.driveName(e),s=this.localPath(e),i=de.PathExt.resolve("/",s,t);return n?`${n}:${i}`:i}driveName(e){let n=e.split("/")[0].split(":");return n.length===1?"":this._additionalDrives.has(n[0])?n[0]:""}get(e,t){let[n,s]=this._driveForPath(e);return n.get(s,t).then(i=>{let o=[];if(i.type==="directory"&&i.content){for(let a of i.content)o.push({...a,path:this._toGlobalPath(n,a.path)});return{...i,path:this._toGlobalPath(n,s),content:o,serverPath:i.path}}else return{...i,path:this._toGlobalPath(n,s),serverPath:i.path}})}getDownloadUrl(e){let[t,n]=this._driveForPath(e);return t.getDownloadUrl(n)}newUntitled(e={}){if(e.path){let t=this.normalize(e.path),[n,s]=this._driveForPath(t);return n.newUntitled({...e,path:s}).then(i=>({...i,path:de.PathExt.join(t,i.name),serverPath:i.path}))}else return this._defaultDrive.newUntitled(e)}delete(e){let[t,n]=this._driveForPath(e);return t.delete(n)}rename(e,t){let[n,s]=this._driveForPath(e),[i,o]=this._driveForPath(t);if(n!==i)throw Error("ContentsManager: renaming files must occur within a Drive");return n.rename(s,o).then(a=>({...a,path:this._toGlobalPath(n,o),serverPath:a.path}))}async overwrite(e,t){let n=`${t}.${wl.UUID.uuid4()}`;await this.rename(e,n);try{await this.delete(t)}finally{}return await this.rename(n,t)}save(e,t={}){let n=this.normalize(e),[s,i]=this._driveForPath(e);return s.save(i,{...t,path:i}).then(o=>({...o,path:n,serverPath:o.path}))}copy(e,t){let[n,s]=this._driveForPath(e),[i,o]=this._driveForPath(t);if(n===i)return n.copy(s,o).then(a=>({...a,path:this._toGlobalPath(n,a.path),serverPath:a.path}));throw Error("Copying files between drives is not currently implemented")}createCheckpoint(e){let[t,n]=this._driveForPath(e);return t.createCheckpoint(n)}listCheckpoints(e){let[t,n]=this._driveForPath(e);return t.listCheckpoints(n)}restoreCheckpoint(e,t){let[n,s]=this._driveForPath(e);return n.restoreCheckpoint(s,t)}deleteCheckpoint(e,t){let[n,s]=this._driveForPath(e);return n.deleteCheckpoint(s,t)}_toGlobalPath(e,t){return e===this._defaultDrive?de.PathExt.removeSlash(t):`${e.name}:${de.PathExt.removeSlash(t)}`}_driveForPath(e){let t=this.driveName(e),n=this.localPath(e);return t?[this._additionalDrives.get(t),n]:[this._defaultDrive,n]}_onFileChanged(e,t){var n,s;if(e===this._defaultDrive)this._fileChanged.emit(t);else{let i=null,o=null;!((n=t.newValue)===null||n===void 0)&&n.path&&(i={...t.newValue,path:this._toGlobalPath(e,t.newValue.path)}),!((s=t.oldValue)===null||s===void 0)&&s.path&&(o={...t.oldValue,path:this._toGlobalPath(e,t.oldValue.path)}),this._fileChanged.emit({type:t.type,newValue:i,oldValue:o})}}};ne.ContentsManager=ds;var an=class{constructor(e={}){var t,n,s;this._isDisposed=!1,this._fileChanged=new ct.Signal(this),this.name=(t=e.name)!==null&&t!==void 0?t:"Default",this._apiEndpoint=(n=e.apiEndpoint)!==null&&n!==void 0?n:bl,this.serverSettings=(s=e.serverSettings)!==null&&s!==void 0?s:$.ServerConnection.makeSettings(),this._restContentProvider=new ln({...e,apiEndpoint:this._apiEndpoint,serverSettings:this.serverSettings}),e.defaultContentProvider?this.contentProviderRegistry=new ut({defaultProvider:e.defaultContentProvider}):this.contentProviderRegistry=new ut,this.contentProviderRegistry.fileChanged.connect((i,o)=>{this._fileChanged.emit(o)})}get fileChanged(){return this._fileChanged}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,ct.Signal.clearData(this))}async get(e,t){let n=this.contentProviderRegistry.getProvider(t==null?void 0:t.contentProviderId);return n?n.get(e,t):await this._restContentProvider.get(e,t)}getDownloadUrl(e){let t=this.serverSettings.baseUrl,n=de.URLExt.join(t,Cl,de.URLExt.encodeParts(e)),s="";try{s=document.cookie}catch{}let i=s.match("\\b_xsrf=([^;]*)\\b");if(i){let o=new URL(n);o.searchParams.append("_xsrf",i[1]),n=o.toString()}return Promise.resolve(n)}async newUntitled(e={}){var t;let n="{}";e&&(e.ext&&(e.ext=fs.normalizeExtension(e.ext)),n=JSON.stringify(e));let s=this.serverSettings,i=this._getUrl((t=e.path)!==null&&t!==void 0?t:""),o={method:"POST",body:n},a=await $.ServerConnection.makeRequest(i,o,s);if(a.status!==201)throw await $.ServerConnection.ResponseError.create(a);let h=await a.json();return Ne.validateContentsModel(h),this._fileChanged.emit({type:"new",oldValue:null,newValue:h}),h}async delete(e){let t=this._getUrl(e),n=this.serverSettings,s={method:"DELETE"},i=await $.ServerConnection.makeRequest(t,s,n);if(i.status!==204)throw await $.ServerConnection.ResponseError.create(i);this._fileChanged.emit({type:"delete",oldValue:{path:e},newValue:null})}async rename(e,t){let n=this.serverSettings,s=this._getUrl(e),i={method:"PATCH",body:JSON.stringify({path:t})},o=await $.ServerConnection.makeRequest(s,i,n);if(o.status!==200)throw await $.ServerConnection.ResponseError.create(o);let a=await o.json();return Ne.validateContentsModel(a),this._fileChanged.emit({type:"rename",oldValue:{path:e},newValue:a}),a}async save(e,t={}){let n=this.contentProviderRegistry.getProvider(t==null?void 0:t.contentProviderId),s;return n?s=await n.save(e,t):s=await this._restContentProvider.save(e,t),this._fileChanged.emit({type:"save",oldValue:null,newValue:s}),s}async copy(e,t){let n=this.serverSettings,s=this._getUrl(t),i={method:"POST",body:JSON.stringify({copy_from:e})},o=await $.ServerConnection.makeRequest(s,i,n);if(o.status!==201)throw await $.ServerConnection.ResponseError.create(o);let a=await o.json();return Ne.validateContentsModel(a),this._fileChanged.emit({type:"new",oldValue:null,newValue:a}),a}async createCheckpoint(e){let t=this._getUrl(e,"checkpoints"),n={method:"POST"},s=await $.ServerConnection.makeRequest(t,n,this.serverSettings);if(s.status!==201)throw await $.ServerConnection.ResponseError.create(s);let i=await s.json();return Ne.validateCheckpointModel(i),i}async listCheckpoints(e){let t=this._getUrl(e,"checkpoints"),n=await $.ServerConnection.makeRequest(t,{},this.serverSettings);if(n.status!==200)throw await $.ServerConnection.ResponseError.create(n);let s=await n.json();if(!Array.isArray(s))throw new Error("Invalid Checkpoint list");for(let i=0;i<s.length;i++)Ne.validateCheckpointModel(s[i]);return s}async restoreCheckpoint(e,t){let n=this._getUrl(e,"checkpoints",t),s={method:"POST"},i=await $.ServerConnection.makeRequest(n,s,this.serverSettings);if(i.status!==204)throw await $.ServerConnection.ResponseError.create(i)}async deleteCheckpoint(e,t){let n=this._getUrl(e,"checkpoints",t),s={method:"DELETE"},i=await $.ServerConnection.makeRequest(n,s,this.serverSettings);if(i.status!==204)throw await $.ServerConnection.ResponseError.create(i)}_getUrl(...e){let t=e.map(s=>de.URLExt.encodeParts(s)),n=this.serverSettings.baseUrl;return de.URLExt.join(n,this._apiEndpoint,...t)}};ne.Drive=an;var fs;(function(r){function e(t){return t.length>0&&t.indexOf(".")!==0&&(t=`.${t}`),t}r.normalizeExtension=e})(fs||(fs={}));var ut=class{constructor(e){this._providers=new Map,this._fileChanged=new ct.Signal(this),e!=null&&e.defaultProvider&&this.register("default",e.defaultProvider)}register(e,t){if(this._providers.has(e))throw Error(`Provider with ${e} identifier was already registered on this drive`);this._providers.set(e,t);let n=(s,i)=>{this._fileChanged.emit(i)};return t.fileChanged&&t.fileChanged.connect(n),new Sl.DisposableDelegate(()=>{t.fileChanged&&t.fileChanged.disconnect(n),this._providers.has(e)&&this._providers.delete(e)})}getProvider(e){if(!e)return null;let t=this._providers.get(e);if(!t)throw Error(`Provider ${e} is not registered`);return t}get fileChanged(){return this._fileChanged}};ne.ContentProviderRegistry=ut;var ln=class{constructor(e){this._options=e}async get(e,t){let n=this._getUrl(e);if(t){t.type==="notebook"&&delete t.format;let a=t.content?"1":"0",h=t.hash?"1":"0",c={...t,content:a,hash:h};n+=de.URLExt.objectToQueryString(c)}let s=this._options.serverSettings,i=await $.ServerConnection.makeRequest(n,{},s);if(i.status!==200)throw await $.ServerConnection.ResponseError.create(i);let o=await i.json();return Ne.validateContentsModel(o),o}async save(e,t={}){let n=this._options.serverSettings,s=this._getUrl(e),o={method:"PUT",body:new File([JSON.stringify(t)],"data.json",{type:"application/json"})},a=await $.ServerConnection.makeRequest(s,o,n);if(a.status!==200&&a.status!==201)throw await $.ServerConnection.ResponseError.create(a);let h=await a.json();return Ne.validateContentsModel(h),h}_getUrl(...e){let t=e.map(s=>de.URLExt.encodeParts(s)),n=this._options.serverSettings.baseUrl;return de.URLExt.join(n,this._options.apiEndpoint,...t)}};ne.RestContentProvider=ln});var Ge=O((cn,hi)=>{(function(r,e){typeof cn=="object"&&typeof hi!="undefined"?e(cn,X(),ee()):typeof define=="function"&&define.amd?define(["exports","@lumino/coreutils","@lumino/signaling"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r.lumino_polling={},r.lumino_coreutils,r.lumino_signaling))})(cn,function(r,e,t){"use strict";class n{constructor(c){var u;this._disposed=new t.Signal(this),this._lingered=0,this._tick=new e.PromiseDelegate,this._ticked=new t.Signal(this),this._factory=c.factory,this._linger=(u=c.linger)!==null&&u!==void 0?u:s.DEFAULT_LINGER,this._standby=c.standby||s.DEFAULT_STANDBY,this._state={...s.DEFAULT_STATE,timestamp:new Date().getTime()};let l=c.frequency||{},d=Math.max(l.interval||0,l.max||0,s.DEFAULT_FREQUENCY.max);this.frequency={...s.DEFAULT_FREQUENCY,...l,max:d},this.name=c.name||s.DEFAULT_NAME,(!("auto"in c)||c.auto)&&setTimeout(()=>this.start())}get disposed(){return this._disposed}get frequency(){return this._frequency}set frequency(c){if(this.isDisposed||e.JSONExt.deepEqual(c,this.frequency||{}))return;let{backoff:u,interval:l,max:d}=c;if(l=Math.round(l),d=Math.round(d),typeof u=="number"&&u<1)throw new Error("Poll backoff growth factor must be at least 1");if((l<0||l>d)&&l!==n.NEVER)throw new Error("Poll interval must be between 0 and max");if(d>n.MAX_INTERVAL&&d!==n.NEVER)throw new Error(`Max interval must be less than ${n.MAX_INTERVAL}`);this._frequency={backoff:u,interval:l,max:d}}get isDisposed(){return this.state.phase==="disposed"}get standby(){return this._standby}set standby(c){this.isDisposed||this.standby===c||(this._standby=c)}get state(){return this._state}get tick(){return this._tick.promise}get ticked(){return this._ticked}async*[Symbol.asyncIterator](){for(;!this.isDisposed;)yield this.state,await this.tick.catch(()=>{})}dispose(){this.isDisposed||(this._state={...s.DISPOSED_STATE,timestamp:new Date().getTime()},this._tick.promise.catch(c=>{}),this._tick.reject(new Error(`Poll (${this.name}) is disposed.`)),this._disposed.emit(void 0),t.Signal.clearData(this))}refresh(){return this.schedule({cancel:({phase:c})=>c==="refreshed",interval:n.IMMEDIATE,phase:"refreshed"})}async schedule(c={}){if(this.isDisposed||c.cancel&&c.cancel(this.state))return;let u=this._tick,l=new e.PromiseDelegate,d={interval:this.frequency.interval,payload:null,phase:"standby",timestamp:new Date().getTime(),...c};if(this._state=d,this._tick=l,clearTimeout(this._timeout),this._ticked.emit(this.state),u.resolve(this),await u.promise,d.interval===n.NEVER){this._timeout=void 0;return}let m=()=>{this.isDisposed||this.tick!==l.promise||this._execute()};this._timeout=setTimeout(m,d.interval)}start(){return this.schedule({cancel:({phase:c})=>c!=="constructed"&&c!=="standby"&&c!=="stopped",interval:n.IMMEDIATE,phase:"started"})}stop(){return this.schedule({cancel:({phase:c})=>c==="stopped",interval:n.NEVER,phase:"stopped"})}get hidden(){return s.hidden}_execute(){let c=typeof this.standby=="function"?this.standby():this.standby;if(c==="never"?c=!1:c==="when-hidden"&&(this.hidden?c=++this._lingered>this._linger:(this._lingered=0,c=!1)),c){this.schedule();return}let u=this.tick;this._factory(this.state).then(l=>{this.isDisposed||this.tick!==u||this.schedule({payload:l,phase:this.state.phase==="rejected"?"reconnected":"resolved"})}).catch(l=>{this.isDisposed||this.tick!==u||this.schedule({interval:s.sleep(this.frequency,this.state),payload:l,phase:"rejected"})})}}(function(h){h.IMMEDIATE=0,h.MAX_INTERVAL=2147483647,h.NEVER=1/0})(n||(n={}));var s;(function(h){h.DEFAULT_BACKOFF=3,h.DEFAULT_FREQUENCY={backoff:!0,interval:1e3,max:30*1e3},h.DEFAULT_LINGER=1,h.DEFAULT_NAME="unknown",h.DEFAULT_STANDBY="when-hidden",h.DEFAULT_STATE={interval:n.NEVER,payload:null,phase:"constructed",timestamp:new Date(0).getTime()},h.DISPOSED_STATE={interval:n.NEVER,payload:null,phase:"disposed",timestamp:new Date(0).getTime()};function c(l,d){let{backoff:m,interval:v,max:T}=l;if(v===n.NEVER)return v;let E=m===!0?h.DEFAULT_BACKOFF:m===!1?1:m,q=u(v,d.interval*E);return Math.min(T,q)}h.sleep=c,h.hidden=typeof document=="undefined"?!1:(document.addEventListener("visibilitychange",()=>{h.hidden=document.visibilityState==="hidden"}),document.addEventListener("pagehide",()=>{h.hidden=document.visibilityState==="hidden"}),document.visibilityState==="hidden");function u(l,d){return l=Math.ceil(l),d=Math.floor(d),Math.floor(Math.random()*(d-l+1))+l}})(s||(s={}));class i{constructor(c,u=500){this.args=void 0,this.payload=null,this.limit=u,this.poll=new n({auto:!1,factory:async()=>{let{args:l}=this;return this.args=void 0,c(...l)},frequency:{backoff:!1,interval:n.NEVER,max:n.NEVER},standby:"never"}),this.payload=new e.PromiseDelegate,this.poll.ticked.connect((l,d)=>{let{payload:m}=this;if(d.phase==="resolved"){this.payload=new e.PromiseDelegate,m.resolve(d.payload);return}if(d.phase==="rejected"||d.phase==="stopped"){this.payload=new e.PromiseDelegate,m.promise.catch(v=>{}),m.reject(d.payload);return}},this)}get isDisposed(){return this.payload===null}dispose(){this.isDisposed||(this.args=void 0,this.payload=null,this.poll.dispose())}async stop(){return this.poll.stop()}}class o extends i{invoke(...c){return this.args=c,this.poll.schedule({interval:this.limit,phase:"invoked"}),this.payload.promise}}class a extends i{constructor(c,u){super(c,typeof u=="number"?u:u&&u.limit),this._trailing=!1,typeof u!="number"&&u&&u.edge==="trailing"&&(this._trailing=!0),this._interval=this._trailing?this.limit:n.IMMEDIATE}invoke(...c){let u=this.poll.state.phase!=="invoked";return(u||this._trailing)&&(this.args=c),u&&this.poll.schedule({interval:this._interval,phase:"invoked"}),this.payload.promise}}r.Debouncer=o,r.Poll=n,r.RateLimiter=i,r.Throttler=a})});var ps=O(un=>{"use strict";Object.defineProperty(un,"__esModule",{value:!0});un.EventManager=void 0;var di=te(),Pl=Ge(),fi=ee(),_i=he(),gi="api/events",gs=class{constructor(e={}){var t,n;this._socket=null,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:_i.ServerConnection.makeSettings(),this._poll=new Pl.Poll({factory:()=>this._subscribe(),standby:(n=e.standby)!==null&&n!==void 0?n:"when-hidden"}),this._stream=new fi.Stream(this),this._poll.start()}get isDisposed(){return this._poll.isDisposed}get stream(){return this._stream}dispose(){if(this.isDisposed)return;this._poll.dispose();let e=this._socket;e&&(this._socket=null,e.onopen=()=>{},e.onerror=()=>{},e.onmessage=()=>{},e.onclose=()=>{},e.close()),fi.Signal.clearData(this),this._stream.stop()}async emit(e){let{serverSettings:t}=this,{baseUrl:n}=t,{makeRequest:s,ResponseError:i}=_i.ServerConnection,o=di.URLExt.join(n,gi),a={body:JSON.stringify(e),method:"POST"},h=await s(o,a,t);if(h.status!==204)throw new i(h)}_subscribe(){return new Promise((e,t)=>{if(this.isDisposed)return;let{appendToken:n,token:s,WebSocket:i,wsUrl:o}=this.serverSettings,a=di.URLExt.join(o,gi,"subscribe");n&&s!==""&&(a+=`?token=${encodeURIComponent(s)}`);let h=this._socket=new i(a),c=this._stream;h.onclose=()=>t(new Error("EventManager socket closed")),h.onmessage=u=>u.data&&c.emit(JSON.parse(u.data))})}};un.EventManager=gs});var vs=O(be=>{"use strict";var Ml=be&&be.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),El=be&&be.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),Il=be&&be.__importStar||function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&Ml(t,e,n[s]);return El(t,e),t}}();Object.defineProperty(be,"__esModule",{value:!0});be.CommHandler=be.CommsOverSubshells=void 0;var ms=X(),Ol=rn(),hn=Il(et()),Ke;(function(r){r.Disabled="disabled",r.PerComm="perComm",r.PerCommTarget="perCommTarget"})(Ke||(be.CommsOverSubshells=Ke={}));var dn=class r extends Ol.DisposableDelegate{constructor(e,t,n,s,i){super(s),this._subshellStarted=new ms.PromiseDelegate,this._subshellId=null,this._target="",this._id="",this._id=t,this._target=e,this._kernel=n,this._kernel.statusChanged.connect(()=>{this._kernel.status==="restarting"&&this._cleanSubshells()}),this.commsOverSubshells=i!=null?i:Ke.PerCommTarget}get commId(){return this._id}get targetName(){return this._target}get subshellId(){return this._subshellId}get subshellStarted(){return this._subshellStarted.promise}get commsOverSubshells(){return this._commsOverSubshells}set commsOverSubshells(e){if(e===this._commsOverSubshells)return;let t=this._maybeCloseSubshell(this._commsOverSubshells);this._commsOverSubshells=e,t.then(()=>{this._commsOverSubshells!==Ke.Disabled&&this._maybeStartSubshell()}).catch(console.warn)}get onClose(){return this._onClose}set onClose(e){this._onClose=e}get onMsg(){return this._onMsg}set onMsg(e){this._onMsg=e}open(e,t,n=[]){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot open");let s=hn.createMessage({msgType:"comm_open",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,target_name:this._target,data:e!=null?e:{}},metadata:t,buffers:n});return this._kernel.sendShellMessage(s,!1,!0)}send(e,t,n=[],s=!0){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot send");let i=hn.createMessage({msgType:"comm_msg",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,data:e},metadata:t,buffers:n});return this._kernel.sendShellMessage(i,!1,s)}close(e,t,n=[]){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot close");let s=hn.createMessage({msgType:"comm_close",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,data:e!=null?e:{}},metadata:t,buffers:n}),i=this._kernel.sendShellMessage(s,!1,!0),o=this._onClose;if(o){let a=hn.createMessage({msgType:"comm_close",channel:"iopub",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,data:e!=null?e:{}},metadata:t,buffers:n});o(a)}return this.dispose(),i}dispose(){this._maybeCloseSubshell(this._commsOverSubshells),super.dispose()}_cleanSubshells(){let e=this._kernel.id;r._commTargetSubShellsId.hasOwnProperty(e)&&delete r._commTargetSubShellsId[e]}async _maybeStartSubshell(){if(await this._kernel.info,!this._kernel.supportsSubshells)return;if(this._commsOverSubshells===Ke.PerComm){let o=await this._kernel.requestCreateSubshell({}).done;this._subshellId=o.content.subshell_id,this._subshellStarted.resolve();return}let e=this._subshellStarted,t=this._kernel.id;r._commTargetSubShellsId.hasOwnProperty(t)||(r._commTargetSubShellsId[t]={});let n=r._commTargetSubShellsId[t],s=n[this._target];if(s){s.referenceCount+=1;try{this._subshellId=await s.subshellId,e.resolve()}catch(o){await this._closePerCommTargetSubshell(!1),e.reject(`Per comm-target subshell creation failed: ${o}`)}return}let i={subshellId:this._kernel.requestCreateSubshell({}).done.then(o=>o.content.subshell_id),referenceCount:1};n[this._target]=i;try{this._subshellId=await i.subshellId,e.resolve()}catch(o){await this._closePerCommTargetSubshell(!1),e.reject(`Per comm-target subshell creation failed: ${o}`)}}async _closePerCommTargetSubshell(e=!0){let t=this._kernel.id,n=this._target;if(r._commTargetSubShellsId.hasOwnProperty(t)){let s=r._commTargetSubShellsId[t],i=s[n];if(i&&(i.referenceCount-=1,i.referenceCount<=0)){if(e){let o=null;try{o=await i.subshellId}catch(a){console.warn(`Subshell identifier not available in the closeout sequence, will not request deletion: ${a}`)}o!==null&&this._kernel.requestDeleteSubshell({subshell_id:o},!0)}delete s[n]}Object.keys(s).length===0&&delete r._commTargetSubShellsId[t],this._subshellId=null}this._subshellStarted=new ms.PromiseDelegate}async _maybeCloseSubshell(e){if(this._kernel.status!=="dead")switch(e){case Ke.PerComm:{this._subshellId&&(this._kernel.requestDeleteSubshell({subshell_id:this._subshellId},!0),this._subshellId=null),this._subshellStarted=new ms.PromiseDelegate;break}case Ke.PerCommTarget:{await this._closePerCommTargetSubshell();break}case Ke.Disabled:break}}};be.CommHandler=dn;dn._commTargetSubShellsId={}});var mi=O(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0})});var fn=O(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.validateMessage=Dl;ht.validateModel=yi;ht.validateModels=ql;var Xe=lt(),vi=["username","version","session","msg_id","msg_type"],Rl={stream:{name:"string",text:"string"},display_data:{data:"object",metadata:"object"},execute_input:{code:"string",execution_count:"number"},execute_result:{execution_count:"number",data:"object",metadata:"object"},error:{ename:"string",evalue:"string",traceback:"object"},status:{execution_state:["string",["starting","idle","busy","restarting","dead"]]},clear_output:{wait:"boolean"},comm_open:{comm_id:"string",target_name:"string",data:"object"},comm_msg:{comm_id:"string",data:"object"},comm_close:{comm_id:"string"},shutdown_reply:{restart:"boolean"}};function kl(r){for(let e=0;e<vi.length;e++)(0,Xe.validateProperty)(r,vi[e],"string")}function Dl(r){(0,Xe.validateProperty)(r,"metadata","object"),(0,Xe.validateProperty)(r,"content","object"),(0,Xe.validateProperty)(r,"channel","string"),kl(r.header),r.channel==="iopub"&&Tl(r)}function Tl(r){if(r.channel==="iopub"){let e=Rl[r.header.msg_type];if(e===void 0)return;let t=Object.keys(e),n=r.content;for(let s=0;s<t.length;s++){let i=e[t[s]];Array.isArray(i)||(i=[i]),(0,Xe.validateProperty)(n,t[s],...i)}}}function yi(r){(0,Xe.validateProperty)(r,"name","string"),(0,Xe.validateProperty)(r,"id","string")}function ql(r){if(!Array.isArray(r))throw new Error("Invalid kernel list");r.forEach(e=>yi(e))}});var gn=O(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});se.KernelAPIClient=se.KERNEL_SERVICE_URL=void 0;se.listRunning=wi;se.startNew=Si;se.restartKernel=bi;se.interruptKernel=Ci;se.shutdownKernel=Pi;se.getKernelModel=Mi;var Q=he(),st=te(),_n=fn();se.KERNEL_SERVICE_URL="api/kernels";async function wi(r=Q.ServerConnection.makeSettings()){let e=st.URLExt.join(r.baseUrl,se.KERNEL_SERVICE_URL),t=await Q.ServerConnection.makeRequest(e,{},r);if(t.status!==200)throw await Q.ServerConnection.ResponseError.create(t);let n=await t.json();return(0,_n.validateModels)(n),n}async function Si(r={},e=Q.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL),n={method:"POST",body:JSON.stringify(r)},s=await Q.ServerConnection.makeRequest(t,n,e);if(s.status!==201)throw await Q.ServerConnection.ResponseError.create(s);let i=await s.json();return(0,_n.validateModel)(i),i}async function bi(r,e=Q.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(r),"restart"),n={method:"POST"},s=await Q.ServerConnection.makeRequest(t,n,e);if(s.status!==200)throw await Q.ServerConnection.ResponseError.create(s);let i=await s.json();(0,_n.validateModel)(i)}async function Ci(r,e=Q.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(r),"interrupt"),n={method:"POST"},s=await Q.ServerConnection.makeRequest(t,n,e);if(s.status!==204)throw await Q.ServerConnection.ResponseError.create(s)}async function Pi(r,e=Q.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(r)),n={method:"DELETE"},s=await Q.ServerConnection.makeRequest(t,n,e);if(s.status===404){let i=`The kernel "${r}" does not exist on the server`;console.warn(i)}else if(s.status!==204)throw await Q.ServerConnection.ResponseError.create(s)}async function Mi(r,e=Q.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(r)),n=await Q.ServerConnection.makeRequest(t,{},e);if(n.status===404)return;if(n.status!==200)throw await Q.ServerConnection.ResponseError.create(n);let s=await n.json();return(0,_n.validateModel)(s),s}var ys=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Q.ServerConnection.makeSettings()}async listRunning(){return wi(this.serverSettings)}async getModel(e){return Mi(e,this.serverSettings)}async startNew(e={}){return Si(e,this.serverSettings)}async restart(e){return bi(e,this.serverSettings)}async interrupt(e){return Ci(e,this.serverSettings)}async shutdown(e){return Pi(e,this.serverSettings)}};se.KernelAPIClient=ys});var Ii=O(ve=>{"use strict";var jl=ve&&ve.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),Ul=ve&&ve.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),Al=ve&&ve.__importStar||function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&jl(t,e,n[s]);return Ul(t,e),t}}();Object.defineProperty(ve,"__esModule",{value:!0});ve.KernelShellFutureHandler=ve.KernelControlFutureHandler=ve.KernelFutureHandler=void 0;var Ei=X(),Nl=rn(),Ll=Al(et()),dt=class extends Nl.DisposableDelegate{constructor(e,t,n,s,i){super(e),this._status=0,this._stdin=ie.noOp,this._iopub=ie.noOp,this._reply=ie.noOp,this._done=new Ei.PromiseDelegate,this._hooks=new ie.HookList,this._disposeOnDone=!0,this._msg=t,n||this._setFlag(ie.KernelFutureFlag.GotReply),this._disposeOnDone=s,this._kernel=i}get msg(){return this._msg}get done(){return this._done.promise}get onReply(){return this._reply}set onReply(e){this._reply=e}get onIOPub(){return this._iopub}set onIOPub(e){this._iopub=e}get onStdin(){return this._stdin}set onStdin(e){this._stdin=e}registerMessageHook(e){if(this.isDisposed)throw new Error("Kernel future is disposed");this._hooks.add(e)}removeMessageHook(e){this.isDisposed||this._hooks.remove(e)}sendInputReply(e,t){this._kernel.sendInputReply(e,t)}dispose(){this._stdin=ie.noOp,this._iopub=ie.noOp,this._reply=ie.noOp,this._hooks=null,this._testFlag(ie.KernelFutureFlag.IsDone)||(this._done.promise.catch(()=>{}),this._done.reject(new Error(`Canceled future for ${this.msg.header.msg_type} message before replies were done`))),super.dispose()}async handleMsg(e){switch(e.channel){case"control":case"shell":e.channel===this.msg.channel&&e.parent_header.msg_id===this.msg.header.msg_id&&await this._handleReply(e);break;case"stdin":await this._handleStdin(e);break;case"iopub":await this._handleIOPub(e);break;default:break}}async _handleReply(e){let t=this._reply;t&&await t(e),this._replyMsg=e,this._setFlag(ie.KernelFutureFlag.GotReply),this._testFlag(ie.KernelFutureFlag.GotIdle)&&this._handleDone()}async _handleStdin(e){this._kernel.hasPendingInput=!0;let t=this._stdin;t&&await t(e)}async _handleIOPub(e){let t=await this._hooks.process(e),n=this._iopub;t&&n&&await n(e),Ll.isStatusMsg(e)&&e.content.execution_state==="idle"&&(this._setFlag(ie.KernelFutureFlag.GotIdle),this._testFlag(ie.KernelFutureFlag.GotReply)&&this._handleDone())}_handleDone(){this._testFlag(ie.KernelFutureFlag.IsDone)||(this._setFlag(ie.KernelFutureFlag.IsDone),this._done.resolve(this._replyMsg),this._disposeOnDone&&this.dispose())}_testFlag(e){return(this._status&e)!==0}_setFlag(e){this._status|=e}};ve.KernelFutureHandler=dt;var ws=class extends dt{};ve.KernelControlFutureHandler=ws;var Ss=class extends dt{};ve.KernelShellFutureHandler=Ss;var ie;(function(r){r.noOp=()=>{};let e=typeof requestAnimationFrame=="function"?requestAnimationFrame:setImmediate;class t{constructor(){this._hooks=[]}add(i){this.remove(i),this._hooks.push(i)}remove(i){let o=this._hooks.indexOf(i);o>=0&&(this._hooks[o]=null,this._scheduleCompact())}async process(i){await this._processing;let o=new Ei.PromiseDelegate;this._processing=o.promise;let a;for(let h=this._hooks.length-1;h>=0;h--){let c=this._hooks[h];if(c!==null){try{a=await c(i)}catch(u){a=!0,console.error(u)}if(a===!1)return o.resolve(void 0),!1}}return o.resolve(void 0),!0}_scheduleCompact(){this._compactScheduled||(this._compactScheduled=!0,e(()=>{this._processing=this._processing.then(()=>{this._compactScheduled=!1,this._compact()})}))}_compact(){let i=0;for(let o=0,a=this._hooks.length;o<a;o++){let h=this._hooks[o];this._hooks[o]===null?i++:this._hooks[o-i]=h}this._hooks.length-=i}}r.HookList=t;let n;(function(s){s[s.GotReply=1]="GotReply",s[s.GotIdle=2]="GotIdle",s[s.IsDone=4]="IsDone",s[s.DisposeOnDone=8]="DisposeOnDone"})(n=r.KernelFutureFlag||(r.KernelFutureFlag={}))})(ie||(ie={}))});var Ri=O(pn=>{"use strict";Object.defineProperty(pn,"__esModule",{value:!0});pn.validateSpecModel=Oi;pn.validateSpecModels=xl;var ze=lt();function Oi(r){let e=r.spec;if(!e)throw new Error("Invalid kernel spec");(0,ze.validateProperty)(r,"name","string"),(0,ze.validateProperty)(r,"resources","object"),(0,ze.validateProperty)(e,"language","string"),(0,ze.validateProperty)(e,"display_name","string"),(0,ze.validateProperty)(e,"argv","array");let t=null;e.hasOwnProperty("metadata")&&((0,ze.validateProperty)(e,"metadata","object"),t=e.metadata);let n=null;return e.hasOwnProperty("env")&&((0,ze.validateProperty)(e,"env","object"),n=e.env),e.hasOwnProperty("interrupt_mode")&&((0,ze.validateProperty)(e,"interrupt_mode","string"),n=e.env),{name:r.name,resources:r.resources,language:e.language,display_name:e.display_name,argv:e.argv,metadata:t,env:n}}function xl(r){if(!r.hasOwnProperty("kernelspecs"))throw new Error("No kernelspecs found");let e=Object.keys(r.kernelspecs),t=Object.create(null),n=r.default;for(let s=0;s<e.length;s++){let i=r.kernelspecs[e[s]];try{t[e[s]]=Oi(i)}catch{console.warn(`Removing errant kernel spec: ${e[s]}`)}}if(e=Object.keys(t),!e.length)throw new Error("No valid kernelspecs found");return(!n||typeof n!="string"||!(n in t))&&(n=e[0],console.warn(`Default kernel not found, using '${e[0]}'`)),{default:n,kernelspecs:t}}});var _t=O(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.KernelSpecAPIClient=void 0;ft.getSpecs=ki;var mn=he(),Fl=Ri(),Kl=te(),zl="api/kernelspecs";async function ki(r=mn.ServerConnection.makeSettings()){let e=Kl.URLExt.join(r.baseUrl,zl),t=await mn.ServerConnection.makeRequest(e,{},r);if(t.status!==200)throw await mn.ServerConnection.ResponseError.create(t);let n=await t.json();return(0,Fl.validateSpecModels)(n)}var bs=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:mn.ServerConnection.makeSettings()}async get(){return ki(this.serverSettings)}};ft.KernelSpecAPIClient=bs});var Ps=O(ye=>{"use strict";var Vl=ye&&ye.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),Bl=ye&&ye.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),Ui=ye&&ye.__importStar||function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&Vl(t,e,n[s]);return Bl(t,e),t}}();Object.defineProperty(ye,"__esModule",{value:!0});ye.KernelConnection=ye.DEFAULT_KERNEL_INFO_TIMEOUT=void 0;var Di=te(),Ve=X(),Be=ee(),gt=Ae(),Ti=vs(),oe=Ui(et()),qi=Ii(),$l=Ui(fn()),ji=gn(),Wl=_t(),Hl=te();ye.DEFAULT_KERNEL_INFO_TIMEOUT=3e3;var rt="_RESTARTING_",Jl="",Cs=class r{constructor(e){var t,n,s,i,o,a,h,c,u;this._createSocket=(l=!0)=>{this._errorIfDisposed(),this._clearSocket(),this._updateConnectionStatus("connecting");let d=this.serverSettings,m=Di.URLExt.join(d.wsUrl,ji.KERNEL_SERVICE_URL,encodeURIComponent(this._id)),v=m.replace(/^((?:\w+:)?\/\/)[^@/]+@/,"$1");console.debug(`Starting WebSocket: ${v}`);let T=Di.URLExt.join(m,"channels?session_id="+encodeURIComponent(this._clientId)),E=d.token;d.appendToken&&E!==""&&(T=T+`&token=${encodeURIComponent(E)}`);let q=l?this._supportedProtocols:[];this._ws=new d.WebSocket(T,q),this._ws.binaryType="arraybuffer";let A=!1,C=async k=>{var N,j;if(!this._isDisposed){this._reason="",this._model=void 0;try{let R=await this._kernelAPIClient.getModel(this._id);this._model=R,(R==null?void 0:R.execution_state)==="dead"?this._updateStatus("dead"):this._onWSClose(k)}catch(R){if(R instanceof gt.ServerConnection.NetworkError||((N=R.response)===null||N===void 0?void 0:N.status)===503||((j=R.response)===null||j===void 0?void 0:j.status)===424){let U=Ce.getRandomIntInclusive(10,30)*1e3;setTimeout(C,U,k)}else this._reason="Kernel died unexpectedly",this._updateStatus("dead")}}},w=async k=>{A||(A=!0,await C(k))};this._ws.onmessage=this._onWSMessage,this._ws.onopen=this._onWSOpen,this._ws.onclose=w,this._ws.onerror=w},this._onWSOpen=l=>{if(this._ws.protocol!==""&&!this._supportedProtocols.includes(this._ws.protocol))throw console.log("Server selected unknown kernel wire protocol:",this._ws.protocol),this._updateStatus("dead"),new Error(`Unknown kernel wire protocol: ${this._ws.protocol}`);this._selectedProtocol=this._ws.protocol,this._ws.onclose=this._onWSClose,this._ws.onerror=this._onWSClose,this._updateConnectionStatus("connected")},this._onWSMessage=l=>{let d;try{d=this.serverSettings.serializer.deserialize(l.data,this._ws.protocol),$l.validateMessage(d)}catch(m){throw m.message=`Kernel message validation error: ${m.message}`,m}this._kernelSession=d.header.session,this._msgChain=this._msgChain.then(()=>this._handleMessage(d)).catch(m=>{m.message.startsWith("Canceled future for ")&&console.error(m)}),this._anyMessage.emit({msg:d,direction:"recv"})},this._onWSClose=l=>{if(!this.isDisposed){if("code"in l&&(l.code===1e3||l.code===1001)){this._updateConnectionStatus("disconnected");return}this._reconnect()}},this._id="",this._name="",this._status="unknown",this._connectionStatus="connecting",this._kernelSession="",this._isDisposed=!1,this._ws=null,this._username="",this._reconnectLimit=7,this._reconnectAttempt=0,this._reconnectTimeout=null,this._supportedProtocols=Object.values(oe.supportedKernelWebSocketProtocols),this._selectedProtocol="",this._commsOverSubshells=gt.CommsOverSubshells.PerCommTarget,this._futures=new Map,this._comms=new Map,this._targetRegistry=Object.create(null),this._info=new Ve.PromiseDelegate,this._pendingMessages=[],this._statusChanged=new Be.Signal(this),this._connectionStatusChanged=new Be.Signal(this),this._disposed=new Be.Signal(this),this._iopubMessage=new Be.Signal(this),this._anyMessage=new Be.Signal(this),this._pendingInput=new Be.Signal(this),this._unhandledMessage=new Be.Signal(this),this._displayIdToParentIds=new Map,this._msgIdToDisplayIds=new Map,this._msgChain=Promise.resolve(),this._hasPendingInput=!1,this._reason="",this._noOp=()=>{},this._supportsSubshells=!1,this._kernelInfoTimeout=ye.DEFAULT_KERNEL_INFO_TIMEOUT,this._name=e.model.name,this._id=e.model.id,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:gt.ServerConnection.makeSettings(),this._kernelAPIClient=(n=e.kernelAPIClient)!==null&&n!==void 0?n:new ji.KernelAPIClient({serverSettings:this.serverSettings}),this._kernelSpecAPIClient=(s=e.kernelSpecAPIClient)!==null&&s!==void 0?s:new Wl.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._clientId=(i=e.clientId)!==null&&i!==void 0?i:Ve.UUID.uuid4(),this._username=(o=e.username)!==null&&o!==void 0?o:"",this.handleComms=(a=e.handleComms)!==null&&a!==void 0?a:!0,this._commsOverSubshells=(h=e.commsOverSubshells)!==null&&h!==void 0?h:gt.CommsOverSubshells.PerCommTarget,this._subshellId=(c=e.subshellId)!==null&&c!==void 0?c:null,this._createSocket(),this._kernelInfoTimeout=(u=e==null?void 0:e.kernelInfoTimeout)!==null&&u!==void 0?u:ye.DEFAULT_KERNEL_INFO_TIMEOUT}get disposed(){return this._disposed}get commsOverSubshells(){return this._commsOverSubshells}set commsOverSubshells(e){this._commsOverSubshells=e;for(let[t,n]of this._comms)n.commsOverSubshells=e}get statusChanged(){return this._statusChanged}get connectionStatusChanged(){return this._connectionStatusChanged}get iopubMessage(){return this._iopubMessage}get unhandledMessage(){return this._unhandledMessage}get model(){return this._model||{id:this.id,name:this.name,reason:this._reason}}get anyMessage(){return this._anyMessage}get pendingInput(){return this._pendingInput}get id(){return this._id}get name(){return this._name}get username(){return this._username}get clientId(){return this._clientId}get subshellId(){return this._subshellId}set subshellId(e){this._subshellId=e}get status(){return this._status}get connectionStatus(){return this._connectionStatus}get isDisposed(){return this._isDisposed}get info(){return this._info.promise}get spec(){return this._specPromise?this._specPromise:(this._specPromise=this._kernelSpecAPIClient.get().then(e=>e.kernelspecs[this._name]),this._specPromise)}get supportsSubshells(){return this._supportsSubshells}clone(e={}){return new r({model:this.model,username:this.username,serverSettings:this.serverSettings,handleComms:!1,kernelAPIClient:this._kernelAPIClient,commsOverSubshells:gt.CommsOverSubshells.Disabled,kernelInfoTimeout:this._kernelInfoTimeout,...e})}dispose(){if(this.isDisposed)return;let e=()=>{this._isDisposed=!0,this._disposed.emit(),this._updateConnectionStatus("disconnected"),this._clearKernelState(),this._pendingMessages=[],this._clearSocket(),Be.Signal.clearData(this)};if(this._subshellId!==null){let t=this.requestDeleteSubshell({subshell_id:this._subshellId},!0);t.onReply=n=>{e()}}else e()}sendShellMessage(e,t=!1,n=!0){return this._sendKernelShellControl(qi.KernelShellFutureHandler,e,t,n)}sendControlMessage(e,t=!1,n=!0){return this._sendKernelShellControl(qi.KernelControlFutureHandler,e,t,n)}_sendKernelShellControl(e,t,n=!1,s=!0){this._sendMessage(t),this._anyMessage.emit({msg:t,direction:"send"});let i=new e(()=>{let o=t.header.msg_id;this._futures.delete(o);let a=this._msgIdToDisplayIds.get(o);a&&(a.forEach(h=>{let c=this._displayIdToParentIds.get(h);if(c){let u=c.indexOf(o);if(u===-1)return;c.length===1?this._displayIdToParentIds.delete(h):(c.splice(u,1),this._displayIdToParentIds.set(h,c))}}),this._msgIdToDisplayIds.delete(o))},t,n,s,this);return this._futures.set(t.header.msg_id,i),i}_sendMessage(e,t=!0){if(this.status==="dead")throw new Error("Kernel is dead");if((this._kernelSession===Jl||this._kernelSession===rt)&&oe.isInfoRequestMsg(e))if(this.connectionStatus==="connected"){this._ws.send(this.serverSettings.serializer.serialize(e,this._ws.protocol));return}else throw new Error("Could not send message: status is not connected");if(t&&this._pendingMessages.length>0){this._pendingMessages.push(e);return}if(this.connectionStatus==="connected"&&this._kernelSession!==rt)this._ws.send(this.serverSettings.serializer.serialize(e,this._ws.protocol));else if(t)this._pendingMessages.push(e);else throw new Error("Could not send message")}async interrupt(){if(this.hasPendingInput=!1,this.status==="dead")throw new Error("Kernel is dead");return this._kernelAPIClient.interrupt(this.id)}async restart(){if(this.status==="dead")throw new Error("Kernel is dead");this._updateStatus("restarting"),this._clearKernelState(),this._kernelSession=rt,await this._kernelAPIClient.restart(this.id),await this.reconnect(),this.hasPendingInput=!1}reconnect(){this._errorIfDisposed();let e=new Ve.PromiseDelegate,t=(n,s)=>{s==="connected"?(e.resolve(),this.connectionStatusChanged.disconnect(t,this)):s==="disconnected"&&(e.reject(new Error("Kernel connection disconnected")),this.connectionStatusChanged.disconnect(t,this))};return this.connectionStatusChanged.connect(t,this),this._reconnectAttempt=0,this._reconnect(),e.promise}async shutdown(){this.status!=="dead"&&await this._kernelAPIClient.shutdown(this.id),this.handleShutdown()}handleShutdown(){this._updateStatus("dead"),this.dispose()}async requestKernelInfo(){let e=oe.createMessage({msgType:"kernel_info_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:{}}),t;try{t=await Ce.handleShellMessage(this,e)}catch(s){if(this.isDisposed)return;throw s}if(this._errorIfDisposed(),!t)return;if(t.content.status===void 0&&(t.content.status="ok"),t.content.status!=="ok")return this._info.reject("Kernel info reply errored"),t;this._info.resolve(t.content),this._kernelSession=t.header.session;let n=t.content.supported_features;return this._supportsSubshells=n!==void 0&&n.includes("kernel subshells"),t}requestComplete(e){let t=oe.createMessage({msgType:"complete_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return Ce.handleShellMessage(this,t)}requestInspect(e){let t=oe.createMessage({msgType:"inspect_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return Ce.handleShellMessage(this,t)}requestHistory(e){let t=oe.createMessage({msgType:"history_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return Ce.handleShellMessage(this,t)}requestExecute(e,t=!0,n){let s={silent:!1,store_history:!0,user_expressions:{},allow_stdin:!0,stop_on_error:!1},i=oe.createMessage({msgType:"execute_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:{...s,...e},metadata:n});return this.sendShellMessage(i,!0,t)}requestDebug(e,t=!0){let n=oe.createMessage({msgType:"debug_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(n,!0,t)}requestCreateSubshell(e,t=!0){if(!this.supportsSubshells)throw new Error("Kernel subshells are not supported");let n=oe.createMessage({msgType:"create_subshell_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(n,!0,t)}requestDeleteSubshell(e,t=!0){if(!this.supportsSubshells)throw new Error("Kernel subshells are not supported");let n=oe.createMessage({msgType:"delete_subshell_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(n,!0,t)}requestListSubshell(e,t=!0){if(!this.supportsSubshells)throw new Error("Kernel subshells are not supported");let n=oe.createMessage({msgType:"list_subshell_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(n,!0,t)}requestIsComplete(e){let t=oe.createMessage({msgType:"is_complete_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return Ce.handleShellMessage(this,t)}requestCommInfo(e){let t=oe.createMessage({msgType:"comm_info_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return Ce.handleShellMessage(this,t)}sendInputReply(e,t){let n=oe.createMessage({msgType:"input_reply",channel:"stdin",username:this._username,session:this._clientId,content:e});n.parent_header=t,this._sendMessage(n),this._anyMessage.emit({msg:n,direction:"send"}),this.hasPendingInput=!1}createComm(e,t=Ve.UUID.uuid4()){if(!this.handleComms)throw new Error("Comms are disabled on this kernel connection");if(this._comms.has(t))throw new Error("Comm is already created");let n=new Ti.CommHandler(e,t,this,()=>{this._unregisterComm(t)},this._commsOverSubshells);return this._comms.set(t,n),n}hasComm(e){return this._comms.has(e)}registerCommTarget(e,t){this.handleComms&&(this._targetRegistry[e]=t)}removeCommTarget(e,t){this.handleComms&&!this.isDisposed&&this._targetRegistry[e]===t&&delete this._targetRegistry[e]}registerMessageHook(e,t){var n;let s=(n=this._futures)===null||n===void 0?void 0:n.get(e);s&&s.registerMessageHook(t)}removeMessageHook(e,t){var n;let s=(n=this._futures)===null||n===void 0?void 0:n.get(e);s&&s.removeMessageHook(t)}removeInputGuard(){this.hasPendingInput=!1}async _handleDisplayId(e,t){var n,s;let i=t.parent_header.msg_id,o=this._displayIdToParentIds.get(e);if(o){let h={header:Ve.JSONExt.deepCopy(t.header),parent_header:Ve.JSONExt.deepCopy(t.parent_header),metadata:Ve.JSONExt.deepCopy(t.metadata),content:Ve.JSONExt.deepCopy(t.content),channel:t.channel,buffers:t.buffers?t.buffers.slice():[]};h.header.msg_type="update_display_data",await Promise.all(o.map(async c=>{let u=this._futures&&this._futures.get(c);u&&await u.handleMsg(h)}))}if(t.header.msg_type==="update_display_data")return!0;o=(n=this._displayIdToParentIds.get(e))!==null&&n!==void 0?n:[],o.indexOf(i)===-1&&o.push(i),this._displayIdToParentIds.set(e,o);let a=(s=this._msgIdToDisplayIds.get(i))!==null&&s!==void 0?s:[];return a.indexOf(i)===-1&&a.push(i),this._msgIdToDisplayIds.set(i,a),!1}_clearSocket(){this._ws!==null&&(this._ws.onopen=this._noOp,this._ws.onclose=this._noOp,this._ws.onerror=this._noOp,this._ws.onmessage=this._noOp,this._ws.close(),this._ws=null)}_updateStatus(e){this._status===e||this._status==="dead"||(this._status=e,Ce.logKernelStatus(this),this._statusChanged.emit(e),e==="dead"&&this.dispose())}_sendPending(){for(;this.connectionStatus==="connected"&&this._kernelSession!==rt&&this._pendingMessages.length>0;)this._sendMessage(this._pendingMessages[0],!1),this._pendingMessages.shift()}_clearKernelState(){this._kernelSession="",this._pendingMessages=[],this._futures.forEach(e=>{e.dispose()}),this._comms.forEach(e=>{e.dispose()}),this._msgChain=Promise.resolve(),this._futures=new Map,this._comms=new Map,this._displayIdToParentIds.clear(),this._msgIdToDisplayIds.clear()}_assertCurrentMessage(e){if(this._errorIfDisposed(),e.header.session!==this._kernelSession)throw new Error(`Canceling handling of old message: ${e.header.msg_type}`)}async _handleCommOpen(e){this._assertCurrentMessage(e);let t=e.content,n=new Ti.CommHandler(t.target_name,t.comm_id,this,()=>{this._unregisterComm(t.comm_id)},this.commsOverSubshells);this._comms.set(t.comm_id,n);try{await(await Ce.loadObject(t.target_name,t.target_module,this._targetRegistry))(n,e)}catch(s){throw n.close(),console.error("Exception opening new comm"),s}}async _handleCommClose(e){this._assertCurrentMessage(e);let t=e.content,n=this._comms.get(t.comm_id);if(!n){console.error("Comm not found for comm id "+t.comm_id);return}this._unregisterComm(n.commId);let s=n.onClose;s&&await s(e),n.dispose()}async _handleCommMsg(e){this._assertCurrentMessage(e);let t=e.content,n=this._comms.get(t.comm_id);if(!n)return;let s=n.onMsg;s&&await s(e)}_unregisterComm(e){this._comms.delete(e)}_updateConnectionStatus(e){if(this._connectionStatus!==e){if(this._connectionStatus=e,e!=="connecting"&&(this._reconnectAttempt=0,clearTimeout(this._reconnectTimeout)),this.status!=="dead")if(e==="connected"){let t=this._kernelSession===rt,n=this.requestKernelInfo(),s=!1,i=()=>{s||(s=!0,t&&this._kernelSession===rt&&(this._kernelSession=""),clearTimeout(o),this._pendingMessages.length>0&&this._sendPending())};n.then(i);let o=setTimeout(i,this._kernelInfoTimeout)}else this._updateStatus("unknown");this._connectionStatusChanged.emit(e)}}async _handleMessage(e){var t,n;let s=!1;if(e.parent_header&&e.channel==="iopub"&&(oe.isDisplayDataMsg(e)||oe.isUpdateDisplayDataMsg(e)||oe.isExecuteResultMsg(e))){let o=((t=e.content.transient)!==null&&t!==void 0?t:{}).display_id;o&&(s=await this._handleDisplayId(o,e),this._assertCurrentMessage(e))}if(!s&&e.parent_header){let i=e.parent_header,o=(n=this._futures)===null||n===void 0?void 0:n.get(i.msg_id);if(o)await o.handleMsg(e),this._assertCurrentMessage(e);else{let a=i.session===this.clientId;e.channel!=="iopub"&&a&&this._unhandledMessage.emit(e)}}if(e.channel==="iopub"){switch(e.header.msg_type){case"status":{let i=Hl.PageConfig.getOption("untracked_message_types");if(JSON.parse(i||"[]").includes(e.parent_header.msg_type))break;let a=e.content.execution_state;a==="restarting"&&Promise.resolve().then(async()=>{this._updateStatus("autorestarting"),this._clearKernelState(),await this.reconnect()}),this._updateStatus(a);break}case"comm_open":this.handleComms&&await this._handleCommOpen(e);break;case"comm_msg":this.handleComms&&await this._handleCommMsg(e);break;case"comm_close":this.handleComms&&await this._handleCommClose(e);break;default:break}this.isDisposed||(this._assertCurrentMessage(e),this._iopubMessage.emit(e))}}_reconnect(){if(this._errorIfDisposed(),clearTimeout(this._reconnectTimeout),this._reconnectAttempt<this._reconnectLimit){this._updateConnectionStatus("connecting");let e=Ce.getRandomIntInclusive(0,1e3*(Math.pow(2,this._reconnectAttempt)-1));console.warn(`Connection lost, reconnecting in ${Math.floor(e/1e3)} seconds.`);let t=this._selectedProtocol!=="";this._reconnectTimeout=setTimeout(this._createSocket,e,t),this._reconnectAttempt+=1}else this._updateConnectionStatus("disconnected");this._clearSocket()}_errorIfDisposed(){if(this.isDisposed)throw new Error("Kernel connection is disposed")}get hasPendingInput(){return this._hasPendingInput}set hasPendingInput(e){this._hasPendingInput=e,this._pendingInput.emit(e)}};ye.KernelConnection=Cs;var Ce;(function(r){function e(i){switch(i.status){case"idle":case"busy":case"unknown":return;default:console.debug(`Kernel: ${i.status} (${i.id})`);break}}r.logKernelStatus=e;async function t(i,o){return i.sendShellMessage(o,!0).done}r.handleShellMessage=t;function n(i,o,a){return new Promise((h,c)=>{if(o){if(typeof requirejs=="undefined")throw new Error("requirejs not found");requirejs([o],u=>{if(u[i]===void 0){let l=`Object '${i}' not found in module '${o}'`;c(new Error(l))}else h(u[i])},c)}else a!=null&&a[i]?h(a[i]):c(new Error(`Object '${i}' not found in registry`))})}r.loadObject=n;function s(i,o){return i=Math.ceil(i),o=Math.floor(o),Math.floor(Math.random()*(o-i+1))+i}r.getRandomIntInclusive=s})(Ce||(Ce={}))});var xi=O(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.KernelManager=void 0;var Gl=Ge(),Ai=ee(),Ni=Ae(),Xl=Je(),Yl=gn(),Li=Ps(),Ql=_t(),pt=class extends Xl.BaseManager{constructor(e={}){var t,n,s;super(e),this._commsOverSubshells=Ni.CommsOverSubshells.PerCommTarget,this._isReady=!1,this._kernelConnections=new Set,this._models=new Map,this._runningChanged=new Ai.Signal(this),this._connectionFailure=new Ai.Signal(this),this._kernelInfoTimeout=Li.DEFAULT_KERNEL_INFO_TIMEOUT,this._kernelAPIClient=(t=e.kernelAPIClient)!==null&&t!==void 0?t:new Yl.KernelAPIClient({serverSettings:this.serverSettings}),this._kernelSpecAPIClient=(n=e.kernelSpecAPIClient)!==null&&n!==void 0?n:new Ql.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._pollModels=new Gl.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:KernelManager#models",standby:(s=e.standby)!==null&&s!==void 0?s:"when-hidden"}),this._ready=(async()=>{await this._pollModels.start(),await this._pollModels.tick,this._isReady=!0})()}get isReady(){return this._isReady}get ready(){return this._ready}get runningChanged(){return this._runningChanged}get connectionFailure(){return this._connectionFailure}get kernelInfoTimeout(){return this._kernelInfoTimeout}set kernelInfoTimeout(e){this._kernelInfoTimeout=e}dispose(){this.isDisposed||(this._models.clear(),this._kernelConnections.forEach(e=>e.dispose()),this._pollModels.dispose(),super.dispose())}connectTo(e){var t;let{id:n}=e.model,s=(t=e.handleComms)!==null&&t!==void 0?t:!0;if(e.handleComms===void 0){for(let o of this._kernelConnections)if(o.id===n&&o.handleComms){s=!1;break}}e.commsOverSubshells=this._commsOverSubshells;let i=new Li.KernelConnection({handleComms:s,...e,serverSettings:this.serverSettings,kernelAPIClient:this._kernelAPIClient,kernelSpecAPIClient:this._kernelSpecAPIClient,kernelInfoTimeout:this._kernelInfoTimeout});return this._onStarted(i),this._models.has(n)||this.refreshRunning().catch(()=>{}),i}running(){return this._models.values()}get runningCount(){return this._models.size}get commsOverSubshells(){return this._commsOverSubshells}set commsOverSubshells(e){this._commsOverSubshells=e;for(let t of this._kernelConnections)t.commsOverSubshells=e}async refreshRunning(){await this._pollModels.refresh(),await this._pollModels.tick}async startNew(e={},t={}){let n=await this._kernelAPIClient.startNew(e);return this.connectTo({...t,model:n})}async shutdown(e){await this._kernelAPIClient.shutdown(e),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all([...this._models.keys()].map(e=>this._kernelAPIClient.shutdown(e))),await this.refreshRunning()}async findById(e){return this._models.has(e)?this._models.get(e):(await this.refreshRunning(),this._models.get(e))}async requestRunning(){var e,t;let n;try{n=await this._kernelAPIClient.listRunning()}catch(s){throw(s instanceof Ni.ServerConnection.NetworkError||((e=s.response)===null||e===void 0?void 0:e.status)===503||((t=s.response)===null||t===void 0?void 0:t.status)===424)&&this._connectionFailure.emit(s),s}this.isDisposed||this._models.size===n.length&&n.every(s=>{let i=this._models.get(s.id);return i?i.connections===s.connections&&i.execution_state===s.execution_state&&i.last_activity===s.last_activity&&i.name===s.name&&i.reason===s.reason&&i.traceback===s.traceback:!1})||(this._models=new Map(n.map(s=>[s.id,s])),this._kernelConnections.forEach(s=>{this._models.has(s.id)||s.handleShutdown()}),this._runningChanged.emit(n))}_onStarted(e){this._kernelConnections.add(e),e.statusChanged.connect(this._onStatusChanged,this),e.disposed.connect(this._onDisposed,this)}_onDisposed(e){this._kernelConnections.delete(e),this.refreshRunning().catch(()=>{})}_onStatusChanged(e,t){t==="dead"&&this.refreshRunning().catch(()=>{})}};mt.KernelManager=pt;(function(r){class e extends r{constructor(){super(...arguments),this._readyPromise=new Promise(()=>{})}get isActive(){return!1}get parentReady(){return super.ready}async startNew(n={},s={}){return Promise.reject(new Error("Not implemented in no-op Kernel Manager"))}connectTo(n){throw new Error("Not implemented in no-op Kernel Manager")}async shutdown(n){return Promise.reject(new Error("Not implemented in no-op Kernel Manager"))}get ready(){return this.parentReady.then(()=>this._readyPromise)}async requestRunning(){return Promise.resolve()}}r.NoopManager=e})(pt||(mt.KernelManager=pt={}))});var Es=O(H=>{"use strict";var Fi=H&&H.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),Zl=H&&H.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),Ms=H&&H.__importStar||function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&Fi(t,e,n[s]);return Zl(t,e),t}}(),ec=H&&H.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Fi(e,r,t)};Object.defineProperty(H,"__esModule",{value:!0});H.CommsOverSubshells=H.KernelConnection=H.KernelAPI=H.KernelMessage=H.Kernel=void 0;var tc=vs();Object.defineProperty(H,"CommsOverSubshells",{enumerable:!0,get:function(){return tc.CommsOverSubshells}});var nc=Ms(mi());H.Kernel=nc;var sc=Ms(et());H.KernelMessage=sc;var rc=Ms(gn());H.KernelAPI=rc;var ic=Ps();Object.defineProperty(H,"KernelConnection",{enumerable:!0,get:function(){return ic.KernelConnection}});ec(xi(),H)});var zi=O(Ki=>{"use strict";Object.defineProperty(Ki,"__esModule",{value:!0})});var Bi=O(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.KernelSpecManager=void 0;var oc=X(),ac=Ge(),Vi=ee(),lc=Je(),cc=_t(),Is=class extends lc.BaseManager{constructor(e={}){var t,n;super(e),this._isReady=!1,this._connectionFailure=new Vi.Signal(this),this._specs=null,this._specsChanged=new Vi.Signal(this),this._kernelSpecAPIClient=(t=e.kernelSpecAPIClient)!==null&&t!==void 0?t:new cc.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._ready=Promise.all([this.requestSpecs()]).then(s=>{}).catch(s=>{}).then(()=>{this.isDisposed||(this._isReady=!0)}),this._pollSpecs=new ac.Poll({auto:!1,factory:()=>this.requestSpecs(),frequency:{interval:61*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:KernelSpecManager#specs",standby:(n=e.standby)!==null&&n!==void 0?n:"when-hidden"}),this.ready.then(()=>{this._pollSpecs.start()})}get isReady(){return this._isReady}get ready(){return this._ready}get specs(){return this._specs}get specsChanged(){return this._specsChanged}get connectionFailure(){return this._connectionFailure}dispose(){this._pollSpecs.dispose(),super.dispose()}async refreshSpecs(){await this._pollSpecs.refresh(),await this._pollSpecs.tick}async requestSpecs(){let e=await this._kernelSpecAPIClient.get();this.isDisposed||oc.JSONExt.deepEqual(e,this._specs)||(this._specs=e,this._specsChanged.emit(e))}};vn.KernelSpecManager=Is});var Os=O(fe=>{"use strict";var $i=fe&&fe.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),uc=fe&&fe.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),Wi=fe&&fe.__importStar||function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&$i(t,e,n[s]);return uc(t,e),t}}(),hc=fe&&fe.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&$i(e,r,t)};Object.defineProperty(fe,"__esModule",{value:!0});fe.KernelSpecAPI=fe.KernelSpec=void 0;var dc=Wi(zi());fe.KernelSpec=dc;var fc=Wi(_t());fe.KernelSpecAPI=fc;hc(Bi(),fe)});var Hi=O(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.BuildManager=void 0;var Rs=te(),$e=he(),_c="api/build",ks=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:$e.ServerConnection.makeSettings()}get isAvailable(){return Rs.PageConfig.getOption("buildAvailable").toLowerCase()==="true"}get shouldCheck(){return Rs.PageConfig.getOption("buildCheck").toLowerCase()==="true"}getStatus(){let{_url:e,serverSettings:t}=this;return $e.ServerConnection.makeRequest(e,{},t).then(s=>{if(s.status!==200)throw new $e.ServerConnection.ResponseError(s);return s.json()}).then(s=>{if(typeof s.status!="string")throw new Error("Invalid data");if(typeof s.message!="string")throw new Error("Invalid data");return s})}build(){let{_url:e,serverSettings:t}=this,n={method:"POST"};return $e.ServerConnection.makeRequest(e,n,t).then(i=>{if(i.status===400)throw new $e.ServerConnection.ResponseError(i,"Build aborted");if(i.status!==200){let o=`Build failed with ${i.status}.
|
|
4
4
|
|
|
5
5
|
If you are experiencing the build failure after installing an extension (or trying to include previously installed extension after updating JupyterLab) please check the extension repository for new installation instructions as many extensions migrated to the prebuilt extensions system which no longer requires rebuilding JupyterLab (but uses a different installation procedure, typically involving a package manager such as 'pip' or 'conda').
|
|
6
6
|
|
|
7
|
-
If you specifically intended to install a source extension, please run 'jupyter lab build' on the server for full output.`;throw new Be.ServerConnection.ResponseError(r,o)}})}cancel(){let{_url:e,serverSettings:t}=this,s={method:"DELETE"};return Be.ServerConnection.makeRequest(e,s,t).then(r=>{if(r.status!==204)throw new Be.ServerConnection.ResponseError(r)})}get _url(){let{baseUrl:e,appUrl:t}=this.serverSettings;return Rs.URLExt.join(e,t,_c)}};yn.BuildManager=ks});var Ts=R(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.NbConvertManager=void 0;var Os=te(),Ds=de(),pc=Y(),gc="api/nbconvert",mc="nbconvert",qs=class{constructor(e={}){var t;this._exportFormats=null,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ds.ServerConnection.makeSettings()}async fetchExportFormats(){this._requestingFormats=new pc.PromiseDelegate,this._exportFormats=null;let e=this.serverSettings.baseUrl,t=Os.URLExt.join(e,gc),{serverSettings:s}=this,i=await Ds.ServerConnection.makeRequest(t,{},s);if(i.status!==200)throw await Ds.ServerConnection.ResponseError.create(i);let r=await i.json(),o={};return Object.keys(r).forEach(function(d){let c=r[d].output_mimetype;o[d]={output_mimetype:c}}),this._exportFormats=o,this._requestingFormats.resolve(o),o}async getExportFormats(e=!0){return this._requestingFormats?this._requestingFormats.promise:e||!this._exportFormats?await this.fetchExportFormats():this._exportFormats}async exportAs(e){let{format:t,path:s}=e,{download:i=!1}=e.exporterOptions||{},r=this.serverSettings.baseUrl,o=Os.URLExt.encodeParts(s),a=Os.URLExt.join(r,mc,t,o);i&&(a+="?download=true"),window==null||window.open(a,"_blank","noopener")}};wn.NbConvertManager=qs});var Hr=R($r=>{"use strict";Object.defineProperty($r,"__esModule",{value:!0})});var Gr=R(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.validateModel=Jr;yt.updateLegacySessionModel=yc;yt.validateModels=wc;var vc=fn(),vt=lt();function Jr(n){(0,vt.validateProperty)(n,"id","string"),(0,vt.validateProperty)(n,"type","string"),(0,vt.validateProperty)(n,"name","string"),(0,vt.validateProperty)(n,"path","string"),(0,vt.validateProperty)(n,"kernel","object"),(0,vc.validateModel)(n.kernel)}function yc(n){n.path===void 0&&n.notebook!==void 0&&(n.path=n.notebook.path,n.type="notebook",n.name="")}function wc(n){if(!Array.isArray(n))throw new Error("Invalid session list");n.forEach(e=>Jr(e))}});var Cn=R(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.SessionAPIClient=_e.SESSION_SERVICE_URL=void 0;_e.listRunning=Xr;_e.getSessionUrl=bn;_e.shutdownSession=Yr;_e.getSessionModel=Qr;_e.startSession=Zr;_e.updateSession=eo;var ae=de(),Sn=te(),We=Gr();_e.SESSION_SERVICE_URL="api/sessions";async function Xr(n=ae.ServerConnection.makeSettings()){let e=Sn.URLExt.join(n.baseUrl,_e.SESSION_SERVICE_URL),t=await ae.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await ae.ServerConnection.ResponseError.create(t);let s=await t.json();if(!Array.isArray(s))throw new Error("Invalid Session list");return s.forEach(i=>{(0,We.updateLegacySessionModel)(i),(0,We.validateModel)(i)}),s}function bn(n,e){let t=Sn.URLExt.join(n,_e.SESSION_SERVICE_URL),s=Sn.URLExt.join(t,e);if(!s.startsWith(t))throw new Error("Can only be used for services requests");return s}async function Yr(n,e=ae.ServerConnection.makeSettings()){var t;let s=bn(e.baseUrl,n),i={method:"DELETE"},r=await ae.ServerConnection.makeRequest(s,i,e);if(r.status===404){let a=(t=(await r.json()).message)!==null&&t!==void 0?t:`The session "${n}"" does not exist on the server`;console.warn(a)}else{if(r.status===410)throw new ae.ServerConnection.ResponseError(r,"The kernel was deleted but the session was not");if(r.status!==204)throw await ae.ServerConnection.ResponseError.create(r)}}async function Qr(n,e=ae.ServerConnection.makeSettings()){let t=bn(e.baseUrl,n),s=await ae.ServerConnection.makeRequest(t,{},e);if(s.status!==200)throw await ae.ServerConnection.ResponseError.create(s);let i=await s.json();return(0,We.updateLegacySessionModel)(i),(0,We.validateModel)(i),i}async function Zr(n,e=ae.ServerConnection.makeSettings()){let t=Sn.URLExt.join(e.baseUrl,_e.SESSION_SERVICE_URL),s={method:"POST",body:JSON.stringify(n)},i=await ae.ServerConnection.makeRequest(t,s,e);if(i.status!==201)throw await ae.ServerConnection.ResponseError.create(i);let r=await i.json();return(0,We.updateLegacySessionModel)(r),(0,We.validateModel)(r),r}async function eo(n,e=ae.ServerConnection.makeSettings()){let t=bn(e.baseUrl,n.id),s={method:"PATCH",body:JSON.stringify(n)},i=await ae.ServerConnection.makeRequest(t,s,e);if(i.status!==200)throw await ae.ServerConnection.ResponseError.create(i);let r=await i.json();return(0,We.updateLegacySessionModel)(r),(0,We.validateModel)(r),r}var js=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:ae.ServerConnection.makeSettings()}async listRunning(){return Xr(this.serverSettings)}async getModel(e){return Qr(e,this.serverSettings)}async startNew(e){return Zr(e,this.serverSettings)}async shutdown(e){return Yr(e,this.serverSettings)}async update(e){return eo(e,this.serverSettings)}};_e.SessionAPIClient=js});var to=R(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.SessionConnection=void 0;var Te=ee(),Sc=Ae(),bc=Y(),Cc=Cn(),Us=class{constructor(e){var t,s,i,r,o;this._id="",this._path="",this._name="",this._type="",this._kernel=null,this._isDisposed=!1,this._disposed=new Te.Signal(this),this._kernelChanged=new Te.Signal(this),this._statusChanged=new Te.Signal(this),this._connectionStatusChanged=new Te.Signal(this),this._pendingInput=new Te.Signal(this),this._iopubMessage=new Te.Signal(this),this._unhandledMessage=new Te.Signal(this),this._anyMessage=new Te.Signal(this),this._propertyChanged=new Te.Signal(this),this._id=e.model.id,this._name=e.model.name,this._path=e.model.path,this._type=e.model.type,this._username=(t=e.username)!==null&&t!==void 0?t:"",this._clientId=(s=e.clientId)!==null&&s!==void 0?s:bc.UUID.uuid4(),this._connectToKernel=e.connectToKernel,this._kernelConnectionOptions=(i=e.kernelConnectionOptions)!==null&&i!==void 0?i:{},this.serverSettings=(r=e.serverSettings)!==null&&r!==void 0?r:Sc.ServerConnection.makeSettings(),this._sessionAPIClient=(o=e.sessionAPIClient)!==null&&o!==void 0?o:new Cc.SessionAPIClient({serverSettings:this.serverSettings}),this.setupKernel(e.model.kernel)}get disposed(){return this._disposed}get kernelChanged(){return this._kernelChanged}get statusChanged(){return this._statusChanged}get connectionStatusChanged(){return this._connectionStatusChanged}get pendingInput(){return this._pendingInput}get iopubMessage(){return this._iopubMessage}get unhandledMessage(){return this._unhandledMessage}get anyMessage(){return this._anyMessage}get propertyChanged(){return this._propertyChanged}get id(){return this._id}get kernel(){return this._kernel}get path(){return this._path}get type(){return this._type}get name(){return this._name}get model(){return{id:this.id,kernel:this.kernel&&{id:this.kernel.id,name:this.kernel.name},path:this._path,type:this._type,name:this._name}}get isDisposed(){return this._isDisposed}update(e){let t=this.model;if(this._path=e.path,this._name=e.name,this._type=e.type,this._kernel===null&&e.kernel!==null||this._kernel!==null&&e.kernel===null||this._kernel!==null&&e.kernel!==null&&this._kernel.id!==e.kernel.id){this._kernel!==null&&this._kernel.dispose();let s=this._kernel||null;this.setupKernel(e.kernel);let i=this._kernel||null;this._kernelChanged.emit({name:"kernel",oldValue:s,newValue:i})}this._handleModelChange(t)}dispose(){if(!this.isDisposed){if(this._isDisposed=!0,this._disposed.emit(),this._kernel){this._kernel.dispose();let e=this._kernel;this._kernel=null;let t=this._kernel;this._kernelChanged.emit({name:"kernel",oldValue:e,newValue:t})}Te.Signal.clearData(this)}}async setPath(e){if(this.isDisposed)throw new Error("Session is disposed");await this._patch({path:e})}async setName(e){if(this.isDisposed)throw new Error("Session is disposed");await this._patch({name:e})}async setType(e){if(this.isDisposed)throw new Error("Session is disposed");await this._patch({type:e})}async changeKernel(e){if(this.isDisposed)throw new Error("Session is disposed");return await this._patch({kernel:e}),this.kernel}async shutdown(){if(this.isDisposed)throw new Error("Session is disposed");await this._sessionAPIClient.shutdown(this.id),this.dispose()}setupKernel(e){if(e===null){this._kernel=null;return}let t=this._connectToKernel({...this._kernelConnectionOptions,model:e,username:this._username,clientId:this._clientId,serverSettings:this.serverSettings});this._kernel=t,t.statusChanged.connect(this.onKernelStatus,this),t.connectionStatusChanged.connect(this.onKernelConnectionStatus,this),t.pendingInput.connect(this.onPendingInput,this),t.unhandledMessage.connect(this.onUnhandledMessage,this),t.iopubMessage.connect(this.onIOPubMessage,this),t.anyMessage.connect(this.onAnyMessage,this)}onKernelStatus(e,t){this._statusChanged.emit(t)}onKernelConnectionStatus(e,t){this._connectionStatusChanged.emit(t)}onPendingInput(e,t){this._pendingInput.emit(t)}onIOPubMessage(e,t){this._iopubMessage.emit(t)}onUnhandledMessage(e,t){this._unhandledMessage.emit(t)}onAnyMessage(e,t){this._anyMessage.emit(t)}async _patch(e){let t=await this._sessionAPIClient.update({...e,id:this._id});return this.update(t),t}_handleModelChange(e){e.name!==this._name&&this._propertyChanged.emit("name"),e.type!==this._type&&this._propertyChanged.emit("type"),e.path!==this._path&&this._propertyChanged.emit("path")}};Pn.SessionConnection=Us});var so=R(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.SessionManager=void 0;var Pc=Je(),no=ee(),Mc=de(),Ec=He(),Ic=to(),Rc=Cn(),wt=class extends Ec.BaseManager{constructor(e){var t,s;super(e),this._isReady=!1,this._sessionConnections=new Set,this._models=new Map,this._runningChanged=new no.Signal(this),this._connectionFailure=new no.Signal(this),this._connectToKernel=i=>this._kernelManager.connectTo(i),this._kernelManager=e.kernelManager,this._sessionAPIClient=(t=e.sessionAPIClient)!==null&&t!==void 0?t:new Rc.SessionAPIClient({serverSettings:e.serverSettings}),this._pollModels=new Pc.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:SessionManager#models",standby:(s=e.standby)!==null&&s!==void 0?s:"when-hidden"}),this._ready=(async()=>{await this._pollModels.start(),await this._pollModels.tick,this._kernelManager.isActive&&await this._kernelManager.ready,this._isReady=!0})()}get isReady(){return this._isReady}get ready(){return this._ready}get runningChanged(){return this._runningChanged}get connectionFailure(){return this._connectionFailure}dispose(){this.isDisposed||(this._models.clear(),this._sessionConnections.forEach(e=>e.dispose()),this._pollModels.dispose(),super.dispose())}connectTo(e){let t=new Ic.SessionConnection({...e,connectToKernel:this._connectToKernel,serverSettings:this.serverSettings,sessionAPIClient:this._sessionAPIClient});return this._onStarted(t),this._models.has(e.model.id)||this.refreshRunning().catch(()=>{}),t}running(){return this._models.values()}async refreshRunning(){await this._pollModels.refresh(),await this._pollModels.tick}async startNew(e,t={}){let s=await this._sessionAPIClient.startNew(e);return await this.refreshRunning(),this.connectTo({...t,model:s})}async shutdown(e){await this._sessionAPIClient.shutdown(e),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all([...this._models.keys()].map(e=>this._sessionAPIClient.shutdown(e))),await this.refreshRunning()}async stopIfNeeded(e){try{let s=(await this._sessionAPIClient.listRunning()).filter(i=>i.path===e);if(s.length===1){let i=s[0].id;await this.shutdown(i)}}catch{}}async findById(e){return this._models.has(e)?this._models.get(e):(await this.refreshRunning(),this._models.get(e))}async findByPath(e){for(let t of this._models.values())if(t.path===e)return t;await this.refreshRunning();for(let t of this._models.values())if(t.path===e)return t}async requestRunning(){var e,t;let s;try{s=await this._sessionAPIClient.listRunning()}catch(i){throw(i instanceof Mc.ServerConnection.NetworkError||((e=i.response)===null||e===void 0?void 0:e.status)===503||((t=i.response)===null||t===void 0?void 0:t.status)===424)&&this._connectionFailure.emit(i),i}this.isDisposed||this._models.size===s.length&&s.every(i=>{var r,o,a,d;let c=this._models.get(i.id);return c?((r=c.kernel)===null||r===void 0?void 0:r.id)===((o=i.kernel)===null||o===void 0?void 0:o.id)&&((a=c.kernel)===null||a===void 0?void 0:a.name)===((d=i.kernel)===null||d===void 0?void 0:d.name)&&c.name===i.name&&c.path===i.path&&c.type===i.type:!1})||(this._models=new Map(s.map(i=>[i.id,i])),this._sessionConnections.forEach(i=>{this._models.has(i.id)?i.update(this._models.get(i.id)):i.dispose()}),this._runningChanged.emit(s))}_onStarted(e){this._sessionConnections.add(e),e.disposed.connect(this._onDisposed,this),e.propertyChanged.connect(this._onChanged,this),e.kernelChanged.connect(this._onChanged,this)}_onDisposed(e){this._sessionConnections.delete(e),this.refreshRunning().catch(()=>{})}_onChanged(){this.refreshRunning().catch(()=>{})}};St.SessionManager=wt;(function(n){class e extends n{constructor(){super(...arguments),this._readyPromise=new Promise(()=>{})}get isActive(){return!1}get parentReady(){return super.ready}async startNew(s,i={}){return Promise.reject(new Error("Not implemented in no-op Session Manager"))}connectTo(s){throw Error("Not implemented in no-op Session Manager")}get ready(){return this.parentReady.then(()=>this._readyPromise)}async shutdown(s){return Promise.reject(new Error("Not implemented in no-op Session Manager"))}async requestRunning(){return Promise.resolve()}}n.NoopManager=e})(wt||(St.SessionManager=wt={}))});var As=R(pe=>{"use strict";var io=pe&&pe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),kc=pe&&pe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),ro=pe&&pe.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&io(e,n,t);return kc(e,n),e},Oc=pe&&pe.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&io(e,n,t)};Object.defineProperty(pe,"__esModule",{value:!0});pe.SessionAPI=pe.Session=void 0;var Dc=ro(Hr());pe.Session=Dc;var qc=ro(Cn());pe.SessionAPI=qc;Oc(so(),pe)});var oo=R(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});Mn.DataConnector=void 0;var Ns=class{async list(e){throw new Error("DataConnector#list method has not been implemented.")}async remove(e){throw new Error("DataConnector#remove method has not been implemented.")}async save(e,t){throw new Error("DataConnector#save method has not been implemented.")}};Mn.DataConnector=Ns});var lo=R(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0})});var uo=R((En,co)=>{(function(n,e){typeof En=="object"&&typeof co!="undefined"?e(En):typeof define=="function"&&define.amd?define(["exports"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_properties={}))})(En,function(n){"use strict";class e{constructor(i){this._pid=t.nextPID(),this.name=i.name,this._create=i.create,this._coerce=i.coerce||null,this._compare=i.compare||null,this._changed=i.changed||null}get(i){let r,o=t.ensureMap(i);return this._pid in o?r=o[this._pid]:r=o[this._pid]=this._createValue(i),r}set(i,r){let o,a=t.ensureMap(i);this._pid in a?o=a[this._pid]:o=a[this._pid]=this._createValue(i);let d=this._coerceValue(i,r);this._maybeNotify(i,o,a[this._pid]=d)}coerce(i){let r,o=t.ensureMap(i);this._pid in o?r=o[this._pid]:r=o[this._pid]=this._createValue(i);let a=this._coerceValue(i,r);this._maybeNotify(i,r,o[this._pid]=a)}_createValue(i){let r=this._create;return r(i)}_coerceValue(i,r){let o=this._coerce;return o?o(i,r):r}_compareValue(i,r){let o=this._compare;return o?o(i,r):i===r}_maybeNotify(i,r,o){let a=this._changed;a&&!this._compareValue(r,o)&&a(i,r,o)}}(function(s){function i(r){t.ownerData.delete(r)}s.clearData=i})(e||(e={}));var t;(function(s){s.ownerData=new WeakMap,s.nextPID=(()=>{let r=0;return()=>`pid-${`${Math.random()}`.slice(2)}-${r++}`})();function i(r){let o=s.ownerData.get(r);return o||(o=Object.create(null),s.ownerData.set(r,o),o)}s.ensureMap=i})(t||(t={})),n.AttachedProperty=e})});var fo=R(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.RestorablePool=void 0;var Tc=Y(),ho=uo(),In=ee(),Ls=class{constructor(e){this._added=new In.Signal(this),this._current=null,this._currentChanged=new In.Signal(this),this._hasRestored=!1,this._isDisposed=!1,this._objects=new Set,this._restore=null,this._restored=new Tc.PromiseDelegate,this._updated=new In.Signal(this),this.namespace=e.namespace}get added(){return this._added}get current(){return this._current}set current(e){this._current!==e&&e!==null&&this._objects.has(e)&&(this._current=e,this._currentChanged.emit(this._current))}get currentChanged(){return this._currentChanged}get isDisposed(){return this._isDisposed}get restored(){return this._restored.promise}get size(){return this._objects.size}get updated(){return this._updated}async add(e){var t,s;if(e.isDisposed){let i="A disposed object cannot be added.";throw console.warn(i,e),new Error(i)}if(this._objects.has(e)){let i="This object already exists in the pool.";throw console.warn(i,e),new Error(i)}if(this._objects.add(e),e.disposed.connect(this._onInstanceDisposed,this),!je.injectedProperty.get(e)){if(this._restore){let{connector:i}=this._restore,r=this._restore.name(e);if(r){let o=`${this.namespace}:${r}`,a=(s=(t=this._restore).args)===null||s===void 0?void 0:s.call(t,e);je.nameProperty.set(e,o),await i.save(o,{data:a})}}this._added.emit(e)}}dispose(){this.isDisposed||(this._current=null,this._isDisposed=!0,this._objects.clear(),In.Signal.clearData(this))}find(e){let t=this._objects.values();for(let s of t)if(e(s))return s}forEach(e){this._objects.forEach(e)}filter(e){let t=[];return this.forEach(s=>{e(s)&&t.push(s)}),t}inject(e){return je.injectedProperty.set(e,!0),this.add(e)}has(e){return this._objects.has(e)}async restore(e){if(this._hasRestored)throw new Error("This pool has already been restored.");this._hasRestored=!0;let{command:t,connector:s,registry:i,when:r}=e,o=this.namespace,a=r?[s.list(o)].concat(r):[s.list(o)];this._restore=e;let[d]=await Promise.all(a),c=await Promise.all(d.ids.map(async(u,l)=>{let h=d.values[l],v=h&&h.data;return v===void 0?s.remove(u):i.execute(t,v).catch(()=>s.remove(u))}));return this._restored.resolve(),c}async save(e){var t,s;let i=je.injectedProperty.get(e);if(!this._restore||!this.has(e)||i)return;let{connector:r}=this._restore,o=this._restore.name(e),a=je.nameProperty.get(e),d=o?`${this.namespace}:${o}`:"";if(a&&a!==d&&await r.remove(a),je.nameProperty.set(e,d),d){let c=(s=(t=this._restore).args)===null||s===void 0?void 0:s.call(t,e);await r.save(d,{data:c})}a!==d&&this._updated.emit(e)}_onInstanceDisposed(e){if(this._objects.delete(e),e===this._current&&(this._current=null,this._currentChanged.emit(this._current)),je.injectedProperty.get(e)||!this._restore)return;let{connector:t}=this._restore,s=je.nameProperty.get(e);s&&t.remove(s)}};Rn.RestorablePool=Ls;var je;(function(n){n.injectedProperty=new ho.AttachedProperty({name:"injected",create:()=>!1}),n.nameProperty=new ho.AttachedProperty({name:"name",create:()=>""})})(je||(je={}))});var _o=R(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.StateDB=void 0;var jc=ee(),bt=class n{constructor(e={}){this._changed=new jc.Signal(this);let{connector:t,transform:s}=e;this._connector=t||new n.Connector,s?this._ready=s.then(i=>{let{contents:r,type:o}=i;switch(o){case"cancel":return;case"clear":return this._clear();case"merge":return this._merge(r||{});case"overwrite":return this._overwrite(r||{});default:return}}):this._ready=Promise.resolve(void 0)}get changed(){return this._changed}async clear(){await this._ready,await this._clear()}async fetch(e){return await this._ready,this._fetch(e)}async list(e){return await this._ready,this._list(e)}async remove(e){await this._ready,await this._remove(e),this._changed.emit({id:e,type:"remove"})}async save(e,t){await this._ready,await this._save(e,t),this._changed.emit({id:e,type:"save"})}async toJSON(){await this._ready;let{ids:e,values:t}=await this._list();return t.reduce((s,i,r)=>(s[e[r]]=i,s),{})}async _clear(){await Promise.all((await this._list()).ids.map(e=>this._remove(e)))}async _fetch(e){let t=await this._connector.fetch(e);if(t)return JSON.parse(t).v}async _list(e=""){let{ids:t,values:s}=await this._connector.list(e);return{ids:t,values:s.map(i=>JSON.parse(i).v)}}async _merge(e){await Promise.all(Object.keys(e).map(t=>e[t]&&this._save(t,e[t])))}async _overwrite(e){await this._clear(),await this._merge(e)}async _remove(e){return this._connector.remove(e)}async _save(e,t){return this._connector.save(e,JSON.stringify({v:t}))}};Ct.StateDB=bt;(function(n){class e{constructor(){this._storage={}}async fetch(s){return this._storage[s]}async list(s=""){return Object.keys(this._storage).reduce((i,r)=>((s===""||s===r.split(":")[0])&&(i.ids.push(r),i.values.push(this._storage[r])),i),{ids:[],values:[]})}async remove(s){delete this._storage[s]}async save(s,i){this._storage[s]=i}}n.Connector=e})(bt||(Ct.StateDB=bt={}))});var po=R(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.IStateDB=void 0;var Uc=Y();kn.IStateDB=new Uc.Token("@jupyterlab/coreutils:IStateDB",`A service for the JupyterLab state database.
|
|
7
|
+
If you specifically intended to install a source extension, please run 'jupyter lab build' on the server for full output.`;throw new $e.ServerConnection.ResponseError(i,o)}})}cancel(){let{_url:e,serverSettings:t}=this,n={method:"DELETE"};return $e.ServerConnection.makeRequest(e,n,t).then(i=>{if(i.status!==204)throw new $e.ServerConnection.ResponseError(i)})}get _url(){let{baseUrl:e,appUrl:t}=this.serverSettings;return Rs.URLExt.join(e,t,_c)}};yn.BuildManager=ks});var js=O(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.NbConvertManager=void 0;var Ds=te(),Ts=he(),gc=X(),pc="api/nbconvert",mc="nbconvert",qs=class{constructor(e={}){var t;this._exportFormats=null,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ts.ServerConnection.makeSettings()}async fetchExportFormats(){this._requestingFormats=new gc.PromiseDelegate,this._exportFormats=null;let e=this.serverSettings.baseUrl,t=Ds.URLExt.join(e,pc),{serverSettings:n}=this,s=await Ts.ServerConnection.makeRequest(t,{},n);if(s.status!==200)throw await Ts.ServerConnection.ResponseError.create(s);let i=await s.json(),o={};return Object.keys(i).forEach(function(h){let c=i[h].output_mimetype;o[h]={output_mimetype:c}}),this._exportFormats=o,this._requestingFormats.resolve(o),o}async getExportFormats(e=!0){return this._requestingFormats?this._requestingFormats.promise:e||!this._exportFormats?await this.fetchExportFormats():this._exportFormats}async exportAs(e){let{format:t,path:n}=e,{download:s=!1,sanitizeHtml:i=!1}=e.exporterOptions||{},o=this.serverSettings.baseUrl,a=Ds.URLExt.encodeParts(n),h=Ds.URLExt.join(o,mc,t,a),c=new URLSearchParams;s&&c.set("download","true"),i&&c.set("sanitize_html","true");let u=c.toString();u&&(h+=`?${u}`),window==null||window.open(h,"_blank","noopener")}};wn.NbConvertManager=qs});var Gi=O(Ji=>{"use strict";Object.defineProperty(Ji,"__esModule",{value:!0})});var Yi=O(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.validateModel=Xi;yt.updateLegacySessionModel=yc;yt.validateModels=wc;var vc=fn(),vt=lt();function Xi(r){(0,vt.validateProperty)(r,"id","string"),(0,vt.validateProperty)(r,"type","string"),(0,vt.validateProperty)(r,"name","string"),(0,vt.validateProperty)(r,"path","string"),(0,vt.validateProperty)(r,"kernel","object"),(0,vc.validateModel)(r.kernel)}function yc(r){r.path===void 0&&r.notebook!==void 0&&(r.path=r.notebook.path,r.type="notebook",r.name="")}function wc(r){if(!Array.isArray(r))throw new Error("Invalid session list");r.forEach(e=>Xi(e))}});var Cn=O(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.SessionAPIClient=_e.SESSION_SERVICE_URL=void 0;_e.listRunning=Qi;_e.getSessionUrl=bn;_e.shutdownSession=Zi;_e.getSessionModel=eo;_e.startSession=to;_e.updateSession=no;var ae=he(),Sn=te(),We=Yi();_e.SESSION_SERVICE_URL="api/sessions";async function Qi(r=ae.ServerConnection.makeSettings()){let e=Sn.URLExt.join(r.baseUrl,_e.SESSION_SERVICE_URL),t=await ae.ServerConnection.makeRequest(e,{},r);if(t.status!==200)throw await ae.ServerConnection.ResponseError.create(t);let n=await t.json();if(!Array.isArray(n))throw new Error("Invalid Session list");return n.forEach(s=>{(0,We.updateLegacySessionModel)(s),(0,We.validateModel)(s)}),n}function bn(r,e){let t=Sn.URLExt.join(r,_e.SESSION_SERVICE_URL),n=Sn.URLExt.join(t,e);if(!n.startsWith(t))throw new Error("Can only be used for services requests");return n}async function Zi(r,e=ae.ServerConnection.makeSettings()){var t;let n=bn(e.baseUrl,r),s={method:"DELETE"},i=await ae.ServerConnection.makeRequest(n,s,e);if(i.status===404){let a=(t=(await i.json()).message)!==null&&t!==void 0?t:`The session "${r}"" does not exist on the server`;console.warn(a)}else{if(i.status===410)throw new ae.ServerConnection.ResponseError(i,"The kernel was deleted but the session was not");if(i.status!==204)throw await ae.ServerConnection.ResponseError.create(i)}}async function eo(r,e=ae.ServerConnection.makeSettings()){let t=bn(e.baseUrl,r),n=await ae.ServerConnection.makeRequest(t,{},e);if(n.status!==200)throw await ae.ServerConnection.ResponseError.create(n);let s=await n.json();return(0,We.updateLegacySessionModel)(s),(0,We.validateModel)(s),s}async function to(r,e=ae.ServerConnection.makeSettings()){let t=Sn.URLExt.join(e.baseUrl,_e.SESSION_SERVICE_URL),n={method:"POST",body:JSON.stringify(r)},s=await ae.ServerConnection.makeRequest(t,n,e);if(s.status!==201)throw await ae.ServerConnection.ResponseError.create(s);let i=await s.json();return(0,We.updateLegacySessionModel)(i),(0,We.validateModel)(i),i}async function no(r,e=ae.ServerConnection.makeSettings()){let t=bn(e.baseUrl,r.id),n={method:"PATCH",body:JSON.stringify(r)},s=await ae.ServerConnection.makeRequest(t,n,e);if(s.status!==200)throw await ae.ServerConnection.ResponseError.create(s);let i=await s.json();return(0,We.updateLegacySessionModel)(i),(0,We.validateModel)(i),i}var Us=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:ae.ServerConnection.makeSettings()}async listRunning(){return Qi(this.serverSettings)}async getModel(e){return eo(e,this.serverSettings)}async startNew(e){return to(e,this.serverSettings)}async shutdown(e){return Zi(e,this.serverSettings)}async update(e){return no(e,this.serverSettings)}};_e.SessionAPIClient=Us});var so=O(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.SessionConnection=void 0;var qe=ee(),Sc=Ae(),bc=X(),Cc=Cn(),As=class{constructor(e){var t,n,s,i,o;this._id="",this._path="",this._name="",this._type="",this._kernel=null,this._isDisposed=!1,this._disposed=new qe.Signal(this),this._kernelChanged=new qe.Signal(this),this._statusChanged=new qe.Signal(this),this._connectionStatusChanged=new qe.Signal(this),this._pendingInput=new qe.Signal(this),this._iopubMessage=new qe.Signal(this),this._unhandledMessage=new qe.Signal(this),this._anyMessage=new qe.Signal(this),this._propertyChanged=new qe.Signal(this),this._id=e.model.id,this._name=e.model.name,this._path=e.model.path,this._type=e.model.type,this._username=(t=e.username)!==null&&t!==void 0?t:"",this._clientId=(n=e.clientId)!==null&&n!==void 0?n:bc.UUID.uuid4(),this._connectToKernel=e.connectToKernel,this._kernelConnectionOptions=(s=e.kernelConnectionOptions)!==null&&s!==void 0?s:{},this.serverSettings=(i=e.serverSettings)!==null&&i!==void 0?i:Sc.ServerConnection.makeSettings(),this._sessionAPIClient=(o=e.sessionAPIClient)!==null&&o!==void 0?o:new Cc.SessionAPIClient({serverSettings:this.serverSettings}),this.setupKernel(e.model.kernel)}get disposed(){return this._disposed}get kernelChanged(){return this._kernelChanged}get statusChanged(){return this._statusChanged}get connectionStatusChanged(){return this._connectionStatusChanged}get pendingInput(){return this._pendingInput}get iopubMessage(){return this._iopubMessage}get unhandledMessage(){return this._unhandledMessage}get anyMessage(){return this._anyMessage}get propertyChanged(){return this._propertyChanged}get id(){return this._id}get kernel(){return this._kernel}get path(){return this._path}get type(){return this._type}get name(){return this._name}get model(){return{id:this.id,kernel:this.kernel&&{id:this.kernel.id,name:this.kernel.name},path:this._path,type:this._type,name:this._name}}get isDisposed(){return this._isDisposed}update(e){let t=this.model;if(this._path=e.path,this._name=e.name,this._type=e.type,this._kernel===null&&e.kernel!==null||this._kernel!==null&&e.kernel===null||this._kernel!==null&&e.kernel!==null&&this._kernel.id!==e.kernel.id){this._kernel!==null&&this._kernel.dispose();let n=this._kernel||null;this.setupKernel(e.kernel);let s=this._kernel||null;this._kernelChanged.emit({name:"kernel",oldValue:n,newValue:s})}this._handleModelChange(t)}dispose(){if(!this.isDisposed){if(this._isDisposed=!0,this._disposed.emit(),this._kernel){this._kernel.dispose();let e=this._kernel;this._kernel=null;let t=this._kernel;this._kernelChanged.emit({name:"kernel",oldValue:e,newValue:t})}qe.Signal.clearData(this)}}async setPath(e){if(this.isDisposed)throw new Error("Session is disposed");await this._patch({path:e})}async setName(e){if(this.isDisposed)throw new Error("Session is disposed");await this._patch({name:e})}async setType(e){if(this.isDisposed)throw new Error("Session is disposed");await this._patch({type:e})}async changeKernel(e){if(this.isDisposed)throw new Error("Session is disposed");return await this._patch({kernel:e}),this.kernel}async shutdown(){if(this.isDisposed)throw new Error("Session is disposed");await this._sessionAPIClient.shutdown(this.id),this.dispose()}setupKernel(e){if(e===null){this._kernel=null;return}let t=this._connectToKernel({...this._kernelConnectionOptions,model:e,username:this._username,clientId:this._clientId,serverSettings:this.serverSettings});this._kernel=t,t.statusChanged.connect(this.onKernelStatus,this),t.connectionStatusChanged.connect(this.onKernelConnectionStatus,this),t.pendingInput.connect(this.onPendingInput,this),t.unhandledMessage.connect(this.onUnhandledMessage,this),t.iopubMessage.connect(this.onIOPubMessage,this),t.anyMessage.connect(this.onAnyMessage,this)}onKernelStatus(e,t){this._statusChanged.emit(t)}onKernelConnectionStatus(e,t){this._connectionStatusChanged.emit(t)}onPendingInput(e,t){this._pendingInput.emit(t)}onIOPubMessage(e,t){this._iopubMessage.emit(t)}onUnhandledMessage(e,t){this._unhandledMessage.emit(t)}onAnyMessage(e,t){this._anyMessage.emit(t)}async _patch(e){let t=await this._sessionAPIClient.update({...e,id:this._id});return this.update(t),t}_handleModelChange(e){e.name!==this._name&&this._propertyChanged.emit("name"),e.type!==this._type&&this._propertyChanged.emit("type"),e.path!==this._path&&this._propertyChanged.emit("path")}};Pn.SessionConnection=As});var io=O(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.SessionManager=void 0;var Pc=Ge(),ro=ee(),Mc=he(),Ec=Je(),Ic=so(),Oc=Cn(),wt=class extends Ec.BaseManager{constructor(e){var t,n;super(e),this._isReady=!1,this._sessionConnections=new Set,this._models=new Map,this._runningChanged=new ro.Signal(this),this._connectionFailure=new ro.Signal(this),this._connectToKernel=s=>this._kernelManager.connectTo(s),this._kernelManager=e.kernelManager,this._sessionAPIClient=(t=e.sessionAPIClient)!==null&&t!==void 0?t:new Oc.SessionAPIClient({serverSettings:e.serverSettings}),this._pollModels=new Pc.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:SessionManager#models",standby:(n=e.standby)!==null&&n!==void 0?n:"when-hidden"}),this._ready=(async()=>{await this._pollModels.start(),await this._pollModels.tick,this._kernelManager.isActive&&await this._kernelManager.ready,this._isReady=!0})()}get isReady(){return this._isReady}get ready(){return this._ready}get runningChanged(){return this._runningChanged}get connectionFailure(){return this._connectionFailure}dispose(){this.isDisposed||(this._models.clear(),this._sessionConnections.forEach(e=>e.dispose()),this._pollModels.dispose(),super.dispose())}connectTo(e){let t=new Ic.SessionConnection({...e,connectToKernel:this._connectToKernel,serverSettings:this.serverSettings,sessionAPIClient:this._sessionAPIClient});return this._onStarted(t),this._models.has(e.model.id)||this.refreshRunning().catch(()=>{}),t}running(){return this._models.values()}async refreshRunning(){await this._pollModels.refresh(),await this._pollModels.tick}async startNew(e,t={}){let n=await this._sessionAPIClient.startNew(e);return await this.refreshRunning(),this.connectTo({...t,model:n})}async shutdown(e){await this._sessionAPIClient.shutdown(e),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all([...this._models.keys()].map(e=>this._sessionAPIClient.shutdown(e))),await this.refreshRunning()}async stopIfNeeded(e){try{let n=(await this._sessionAPIClient.listRunning()).filter(s=>s.path===e);if(n.length===1){let s=n[0].id;await this.shutdown(s)}}catch{}}async findById(e){return this._models.has(e)?this._models.get(e):(await this.refreshRunning(),this._models.get(e))}async findByPath(e){for(let t of this._models.values())if(t.path===e)return t;await this.refreshRunning();for(let t of this._models.values())if(t.path===e)return t}async requestRunning(){var e,t;let n;try{n=await this._sessionAPIClient.listRunning()}catch(s){throw(s instanceof Mc.ServerConnection.NetworkError||((e=s.response)===null||e===void 0?void 0:e.status)===503||((t=s.response)===null||t===void 0?void 0:t.status)===424)&&this._connectionFailure.emit(s),s}this.isDisposed||this._models.size===n.length&&n.every(s=>{var i,o,a,h;let c=this._models.get(s.id);return c?((i=c.kernel)===null||i===void 0?void 0:i.id)===((o=s.kernel)===null||o===void 0?void 0:o.id)&&((a=c.kernel)===null||a===void 0?void 0:a.name)===((h=s.kernel)===null||h===void 0?void 0:h.name)&&c.name===s.name&&c.path===s.path&&c.type===s.type:!1})||(this._models=new Map(n.map(s=>[s.id,s])),this._sessionConnections.forEach(s=>{this._models.has(s.id)?s.update(this._models.get(s.id)):s.dispose()}),this._runningChanged.emit(n))}_onStarted(e){this._sessionConnections.add(e),e.disposed.connect(this._onDisposed,this),e.propertyChanged.connect(this._onChanged,this),e.kernelChanged.connect(this._onChanged,this)}_onDisposed(e){this._sessionConnections.delete(e),this.refreshRunning().catch(()=>{})}_onChanged(){this.refreshRunning().catch(()=>{})}};St.SessionManager=wt;(function(r){class e extends r{constructor(){super(...arguments),this._readyPromise=new Promise(()=>{})}get isActive(){return!1}get parentReady(){return super.ready}async startNew(n,s={}){return Promise.reject(new Error("Not implemented in no-op Session Manager"))}connectTo(n){throw Error("Not implemented in no-op Session Manager")}get ready(){return this.parentReady.then(()=>this._readyPromise)}async shutdown(n){return Promise.reject(new Error("Not implemented in no-op Session Manager"))}async requestRunning(){return Promise.resolve()}}r.NoopManager=e})(wt||(St.SessionManager=wt={}))});var Ns=O(ge=>{"use strict";var oo=ge&&ge.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),Rc=ge&&ge.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),ao=ge&&ge.__importStar||function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&oo(t,e,n[s]);return Rc(t,e),t}}(),kc=ge&&ge.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&oo(e,r,t)};Object.defineProperty(ge,"__esModule",{value:!0});ge.SessionAPI=ge.Session=void 0;var Dc=ao(Gi());ge.Session=Dc;var Tc=ao(Cn());ge.SessionAPI=Tc;kc(io(),ge)});var lo=O(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});Mn.DataConnector=void 0;var Ls=class{async list(e){throw new Error("DataConnector#list method has not been implemented.")}async remove(e){throw new Error("DataConnector#remove method has not been implemented.")}async save(e,t){throw new Error("DataConnector#save method has not been implemented.")}};Mn.DataConnector=Ls});var uo=O(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0})});var fo=O((En,ho)=>{(function(r,e){typeof En=="object"&&typeof ho!="undefined"?e(En):typeof define=="function"&&define.amd?define(["exports"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r.lumino_properties={}))})(En,function(r){"use strict";class e{constructor(s){this._pid=t.nextPID(),this.name=s.name,this._create=s.create,this._coerce=s.coerce||null,this._compare=s.compare||null,this._changed=s.changed||null}get(s){let i,o=t.ensureMap(s);return this._pid in o?i=o[this._pid]:i=o[this._pid]=this._createValue(s),i}set(s,i){let o,a=t.ensureMap(s);this._pid in a?o=a[this._pid]:o=a[this._pid]=this._createValue(s);let h=this._coerceValue(s,i);this._maybeNotify(s,o,a[this._pid]=h)}coerce(s){let i,o=t.ensureMap(s);this._pid in o?i=o[this._pid]:i=o[this._pid]=this._createValue(s);let a=this._coerceValue(s,i);this._maybeNotify(s,i,o[this._pid]=a)}_createValue(s){let i=this._create;return i(s)}_coerceValue(s,i){let o=this._coerce;return o?o(s,i):i}_compareValue(s,i){let o=this._compare;return o?o(s,i):s===i}_maybeNotify(s,i,o){let a=this._changed;a&&!this._compareValue(i,o)&&a(s,i,o)}}(function(n){function s(i){t.ownerData.delete(i)}n.clearData=s})(e||(e={}));var t;(function(n){n.ownerData=new WeakMap,n.nextPID=(()=>{let i=0;return()=>`pid-${`${Math.random()}`.slice(2)}-${i++}`})();function s(i){let o=n.ownerData.get(i);return o||(o=Object.create(null),n.ownerData.set(i,o),o)}n.ensureMap=s})(t||(t={})),r.AttachedProperty=e})});var go=O(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});On.RestorablePool=void 0;var qc=X(),_o=fo(),In=ee(),xs=class{constructor(e){this._added=new In.Signal(this),this._current=null,this._currentChanged=new In.Signal(this),this._hasRestored=!1,this._isDisposed=!1,this._objects=new Set,this._restore=null,this._restored=new qc.PromiseDelegate,this._updated=new In.Signal(this),this.namespace=e.namespace}get added(){return this._added}get current(){return this._current}set current(e){this._current!==e&&e!==null&&this._objects.has(e)&&(this._current=e,this._currentChanged.emit(this._current))}get currentChanged(){return this._currentChanged}get isDisposed(){return this._isDisposed}get restored(){return this._restored.promise}get size(){return this._objects.size}get updated(){return this._updated}async add(e){var t,n;if(e.isDisposed){let s="A disposed object cannot be added.";throw console.warn(s,e),new Error(s)}if(this._objects.has(e)){let s="This object already exists in the pool.";throw console.warn(s,e),new Error(s)}if(this._objects.add(e),e.disposed.connect(this._onInstanceDisposed,this),!je.injectedProperty.get(e)){if(this._restore){let{connector:s}=this._restore,i=this._restore.name(e);if(i){let o=`${this.namespace}:${i}`,a=(n=(t=this._restore).args)===null||n===void 0?void 0:n.call(t,e);je.nameProperty.set(e,o),await s.save(o,{data:a})}}this._added.emit(e)}}dispose(){this.isDisposed||(this._current=null,this._isDisposed=!0,this._objects.clear(),In.Signal.clearData(this))}find(e){let t=this._objects.values();for(let n of t)if(e(n))return n}forEach(e){this._objects.forEach(e)}filter(e){let t=[];return this.forEach(n=>{e(n)&&t.push(n)}),t}inject(e){return je.injectedProperty.set(e,!0),this.add(e)}has(e){return this._objects.has(e)}async restore(e){if(this._hasRestored)throw new Error("This pool has already been restored.");this._hasRestored=!0;let{command:t,connector:n,registry:s,when:i}=e,o=this.namespace,a=i?[n.list(o)].concat(i):[n.list(o)];this._restore=e;let[h]=await Promise.all(a),c=await Promise.all(h.ids.map(async(u,l)=>{let d=h.values[l],m=d&&d.data;return m===void 0?n.remove(u):s.execute(t,m).catch(()=>n.remove(u))}));return this._restored.resolve(),c}async save(e){var t,n;let s=je.injectedProperty.get(e);if(!this._restore||!this.has(e)||s)return;let{connector:i}=this._restore,o=this._restore.name(e),a=je.nameProperty.get(e),h=o?`${this.namespace}:${o}`:"";if(a&&a!==h&&await i.remove(a),je.nameProperty.set(e,h),h){let c=(n=(t=this._restore).args)===null||n===void 0?void 0:n.call(t,e);await i.save(h,{data:c})}a!==h&&this._updated.emit(e)}_onInstanceDisposed(e){if(this._objects.delete(e),e===this._current&&(this._current=null,this._currentChanged.emit(this._current)),je.injectedProperty.get(e)||!this._restore)return;let{connector:t}=this._restore,n=je.nameProperty.get(e);n&&t.remove(n)}};On.RestorablePool=xs;var je;(function(r){r.injectedProperty=new _o.AttachedProperty({name:"injected",create:()=>!1}),r.nameProperty=new _o.AttachedProperty({name:"name",create:()=>""})})(je||(je={}))});var po=O(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.StateDB=void 0;var jc=ee(),bt=class r{constructor(e={}){this._changed=new jc.Signal(this);let{connector:t,transform:n}=e;this._connector=t||new r.Connector,n?this._ready=n.then(s=>{let{contents:i,type:o}=s;switch(o){case"cancel":return;case"clear":return this._clear();case"merge":return this._merge(i||{});case"overwrite":return this._overwrite(i||{});default:return}}):this._ready=Promise.resolve(void 0)}get changed(){return this._changed}async clear(){await this._ready,await this._clear()}async fetch(e){return await this._ready,this._fetch(e)}async list(e){return await this._ready,this._list(e)}async remove(e){await this._ready,await this._remove(e),this._changed.emit({id:e,type:"remove"})}async save(e,t){await this._ready,await this._save(e,t),this._changed.emit({id:e,type:"save"})}async toJSON(){await this._ready;let{ids:e,values:t}=await this._list();return t.reduce((n,s,i)=>(n[e[i]]=s,n),{})}async _clear(){await Promise.all((await this._list()).ids.map(e=>this._remove(e)))}async _fetch(e){let t=await this._connector.fetch(e);if(t)return JSON.parse(t).v}async _list(e=""){let{ids:t,values:n}=await this._connector.list(e);return{ids:t,values:n.map(s=>JSON.parse(s).v)}}async _merge(e){await Promise.all(Object.keys(e).map(t=>e[t]&&this._save(t,e[t])))}async _overwrite(e){await this._clear(),await this._merge(e)}async _remove(e){return this._connector.remove(e)}async _save(e,t){return this._connector.save(e,JSON.stringify({v:t}))}};Ct.StateDB=bt;(function(r){class e{constructor(){this._storage={}}async fetch(n){return this._storage[n]}async list(n=""){return Object.keys(this._storage).reduce((s,i)=>((n===""||n===i.split(":")[0])&&(s.ids.push(i),s.values.push(this._storage[i])),s),{ids:[],values:[]})}async remove(n){delete this._storage[n]}async save(n,s){this._storage[n]=s}}r.Connector=e})(bt||(Ct.StateDB=bt={}))});var mo=O(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.IStateDB=void 0;var Uc=X();Rn.IStateDB=new Uc.Token("@jupyterlab/coreutils:IStateDB",`A service for the JupyterLab state database.
|
|
8
8
|
Use this if you want to store data that will persist across page loads.
|
|
9
|
-
See "state database" for more information.`)});var xs=R(Me=>{"use strict";var Ac=Me&&Me.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Pt=Me&&Me.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Ac(e,n,t)};Object.defineProperty(Me,"__esModule",{value:!0});Pt(oo(),Me);Pt(lo(),Me);Pt(fo(),Me);Pt(_o(),Me);Pt(po(),Me)});var zs=R(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.SettingManager=void 0;var Fs=te(),Nc=xs(),On=de(),Lc="api/settings",Ks=class extends Nc.DataConnector{constructor(e={}){var t;super(),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:On.ServerConnection.makeSettings()}async fetch(e){if(!e)throw new Error("Plugin `id` parameter is required for settings fetch.");let{serverSettings:t}=this,{baseUrl:s,appUrl:i}=t,{makeRequest:r,ResponseError:o}=On.ServerConnection,a=s+i,d=Mt.url(a,e),c=await r(d,{},t);if(c.status!==200)throw await o.create(c);return c.json()}async list(e){var t,s,i,r;let{serverSettings:o}=this,{baseUrl:a,appUrl:d}=o,{makeRequest:c,ResponseError:u}=On.ServerConnection,l=a+d,h=Mt.url(l,"",e==="ids"),v=await c(h,{},o);if(v.status!==200)throw new u(v);let m=await v.json(),q=(s=(t=m==null?void 0:m.settings)===null||t===void 0?void 0:t.map(T=>T.id))!==null&&s!==void 0?s:[],I=[];return e||(I=(r=(i=m==null?void 0:m.settings)===null||i===void 0?void 0:i.map(T=>(T.data={composite:{},user:{}},T)))!==null&&r!==void 0?r:[]),{ids:q,values:I}}async save(e,t){let{serverSettings:s}=this,{baseUrl:i,appUrl:r}=s,{makeRequest:o,ResponseError:a}=On.ServerConnection,d=i+r,c=Mt.url(d,e),u={body:JSON.stringify({raw:t}),method:"PUT"},l=await o(c,u,s);if(l.status!==204)throw new a(l)}};Dn.SettingManager=Ks;var Mt;(function(n){function e(t,s,i){let r=i?Fs.URLExt.objectToQueryString({ids_only:!0}):"",o=Fs.URLExt.join(t,Lc),a=Fs.URLExt.join(o,s);if(!a.startsWith(o))throw new Error("Can only be used for workspaces requests");return`${a}${r}`}n.url=e})(Mt||(Mt={}))});var Rt=R(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.TerminalAPIClient=ye.TERMINAL_SERVICE_URL=void 0;ye.isAvailable=Bs;ye.startNew=go;ye.listRunning=mo;ye.shutdownTerminal=vo;var Et=te(),Ue=de();ye.TERMINAL_SERVICE_URL="api/terminals";function Bs(){return String(Et.PageConfig.getOption("terminalsAvailable")).toLowerCase()==="true"}async function go(n=Ue.ServerConnection.makeSettings(),e,t){It.errorIfNotAvailable();let s=Et.URLExt.join(n.baseUrl,ye.TERMINAL_SERVICE_URL),i={method:"POST",body:JSON.stringify({name:e,cwd:t})},r=await Ue.ServerConnection.makeRequest(s,i,n);if(r.status!==200)throw await Ue.ServerConnection.ResponseError.create(r);return await r.json()}async function mo(n=Ue.ServerConnection.makeSettings()){It.errorIfNotAvailable();let e=Et.URLExt.join(n.baseUrl,ye.TERMINAL_SERVICE_URL),t=await Ue.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await Ue.ServerConnection.ResponseError.create(t);let s=await t.json();if(!Array.isArray(s))throw new Error("Invalid terminal list");return s}async function vo(n,e=Ue.ServerConnection.makeSettings()){var t;It.errorIfNotAvailable();let s=Et.URLExt.join(e.baseUrl,ye.TERMINAL_SERVICE_URL),i=Et.URLExt.join(s,n);if(!i.startsWith(s))throw new Error("Can only be used for terminal requests");let r={method:"DELETE"},o=await Ue.ServerConnection.makeRequest(i,r,e);if(o.status===404){let d=(t=(await o.json()).message)!==null&&t!==void 0?t:`The terminal session "${n}"" does not exist on the server`;console.warn(d)}else if(o.status!==204)throw await Ue.ServerConnection.ResponseError.create(o)}var Vs=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ue.ServerConnection.makeSettings()}get isAvailable(){return Bs()}async startNew(e={}){let{name:t,cwd:s}=e;return go(this.serverSettings,t,s)}async listRunning(){return mo(this.serverSettings)}async shutdown(e){return vo(e,this.serverSettings)}};ye.TerminalAPIClient=Vs;var It;(function(n){function e(){if(!Bs())throw new Error("Terminals Unavailable")}n.errorIfNotAvailable=e})(It||(It={}))});var yo=R(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.isAvailable=void 0;var xc=Rt();Object.defineProperty(qn,"isAvailable",{enumerable:!0,get:function(){return xc.isAvailable}})});var wo=R(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.TerminalConnection=void 0;var Fc=te(),Kc=Y(),Tn=ee(),zc=Ae(),Vc=Rt(),Ws=class n{constructor(e){var t,s;this._createSocket=()=>{this._errorIfDisposed(),this._clearSocket(),this._updateConnectionStatus("connecting");let i=this._name,r=this.serverSettings,o=Fc.URLExt.join(r.wsUrl,"terminals","websocket",encodeURIComponent(i)),a=r.token;r.appendToken&&a!==""&&(o=o+`?token=${encodeURIComponent(a)}`),this._ws=new r.WebSocket(o),this._ws.onmessage=this._onWSMessage,this._ws.onclose=this._onWSClose,this._ws.onerror=this._onWSClose},this._onWSMessage=i=>{if(this._isDisposed)return;let r=JSON.parse(i.data);if(r[0]==="disconnect"&&this.dispose(),this._connectionStatus==="connecting"){r[0]==="setup"&&this._updateConnectionStatus("connected");return}this._messageReceived.emit({type:r[0],content:r.slice(1)})},this._onWSClose=i=>{console.warn(`Terminal websocket closed: ${i.code}`),this.isDisposed||this._reconnect()},this._connectionStatus="connecting",this._connectionStatusChanged=new Tn.Signal(this),this._isDisposed=!1,this._disposed=new Tn.Signal(this),this._messageReceived=new Tn.Signal(this),this._reconnectTimeout=null,this._ws=null,this._noOp=()=>{},this._reconnectLimit=7,this._reconnectAttempt=0,this._pendingMessages=[],this._name=e.model.name,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:zc.ServerConnection.makeSettings(),this._terminalAPIClient=(s=e.terminalAPIClient)!==null&&s!==void 0?s:new Vc.TerminalAPIClient({serverSettings:this.serverSettings}),this._createSocket()}get disposed(){return this._disposed}get messageReceived(){return this._messageReceived}get name(){return this._name}get model(){return{name:this._name}}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposed.emit(),this._updateConnectionStatus("disconnected"),this._clearSocket(),Tn.Signal.clearData(this))}send(e){this._sendMessage(e)}_sendMessage(e,t=!0){if(!(this._isDisposed||!e.content))if(this.connectionStatus==="connected"&&this._ws){let s=[e.type,...e.content];this._ws.send(JSON.stringify(s))}else if(t)this._pendingMessages.push(e);else throw new Error(`Could not send message: ${JSON.stringify(e)}`)}_sendPending(){for(;this.connectionStatus==="connected"&&this._pendingMessages.length>0;)this._sendMessage(this._pendingMessages[0],!1),this._pendingMessages.shift()}reconnect(){this._errorIfDisposed();let e=new Kc.PromiseDelegate,t=(s,i)=>{i==="connected"?(e.resolve(),this.connectionStatusChanged.disconnect(t,this)):i==="disconnected"&&(e.reject(new Error("Terminal connection disconnected")),this.connectionStatusChanged.disconnect(t,this))};return this.connectionStatusChanged.connect(t,this),this._reconnectAttempt=0,this._reconnect(),e.promise}_reconnect(){if(this._errorIfDisposed(),clearTimeout(this._reconnectTimeout),this._reconnectAttempt<this._reconnectLimit){this._updateConnectionStatus("connecting");let e=$s.getRandomIntInclusive(0,1e3*(Math.pow(2,this._reconnectAttempt)-1));console.error(`Connection lost, reconnecting in ${Math.floor(e/1e3)} seconds.`),this._reconnectTimeout=setTimeout(this._createSocket,e),this._reconnectAttempt+=1}else this._updateConnectionStatus("disconnected");this._clearSocket()}_clearSocket(){this._ws!==null&&(this._ws.onopen=this._noOp,this._ws.onclose=this._noOp,this._ws.onerror=this._noOp,this._ws.onmessage=this._noOp,this._ws.close(),this._ws=null)}async shutdown(){await this._terminalAPIClient.shutdown(this.name),this.dispose()}clone(){return new n({model:this.model,serverSettings:this.serverSettings,terminalAPIClient:this._terminalAPIClient})}_updateConnectionStatus(e){this._connectionStatus!==e&&(this._connectionStatus=e,e!=="connecting"&&(this._reconnectAttempt=0,clearTimeout(this._reconnectTimeout)),e==="connected"&&this._sendPending(),this._connectionStatusChanged.emit(e))}_errorIfDisposed(){if(this.isDisposed)throw new Error("Terminal connection is disposed")}get connectionStatusChanged(){return this._connectionStatusChanged}get connectionStatus(){return this._connectionStatus}};jn.TerminalConnection=Ws;var $s;(function(n){function e(t,s){return t=Math.ceil(t),s=Math.floor(s),Math.floor(Math.random()*(s-t+1))+t}n.getRandomIntInclusive=e})($s||($s={}))});var bo=R(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.TerminalManager=void 0;var Bc=Je(),So=ee(),Wc=Ae(),$c=He(),Hc=Rt(),Jc=wo(),kt=class extends $c.BaseManager{constructor(e={}){var t,s;if(super(e),this._isReady=!1,this._names=[],this._terminalConnections=new Set,this._runningChanged=new So.Signal(this),this._connectionFailure=new So.Signal(this),this._terminalAPIClient=(t=e.terminalAPIClient)!==null&&t!==void 0?t:new Hc.TerminalAPIClient({serverSettings:this.serverSettings}),!this.isAvailable()){this._ready=Promise.reject("Terminals unavailable"),this._ready.catch(r=>{});return}let i=this._pollModels=new Bc.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:TerminalManager#models",standby:(s=e.standby)!==null&&s!==void 0?s:"when-hidden"});this._ready=(async()=>{await i.start(),await i.tick,this._isReady=!0})()}get isReady(){return this._isReady}get ready(){return this._ready}get runningChanged(){return this._runningChanged}get connectionFailure(){return this._connectionFailure}dispose(){var e;this.isDisposed||(this._names.length=0,this._terminalConnections.forEach(t=>t.dispose()),(e=this._pollModels)===null||e===void 0||e.dispose(),super.dispose())}isAvailable(){return this._terminalAPIClient.isAvailable}connectTo(e){let t=new Jc.TerminalConnection({...e,serverSettings:this.serverSettings,terminalAPIClient:this._terminalAPIClient});return this._onStarted(t),this._names.includes(e.model.name)||this.refreshRunning().catch(()=>{}),t}running(){return this._models[Symbol.iterator]()}async refreshRunning(){this._pollModels&&(await this._pollModels.refresh(),await this._pollModels.tick)}async startNew(e={}){let{name:t,cwd:s}=e,i=await this._terminalAPIClient.startNew({name:t,cwd:s});return await this.refreshRunning(),this.connectTo({model:i})}async shutdown(e){await this._terminalAPIClient.shutdown(e),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all(this._names.map(e=>this._terminalAPIClient.shutdown(e))),await this.refreshRunning()}async requestRunning(){var e,t;let s;try{s=await this._terminalAPIClient.listRunning()}catch(r){throw(r instanceof Wc.ServerConnection.NetworkError||((e=r.response)===null||e===void 0?void 0:e.status)===503||((t=r.response)===null||t===void 0?void 0:t.status)===424)&&this._connectionFailure.emit(r),r}if(this.isDisposed)return;let i=s.map(({name:r})=>r).sort();i!==this._names&&(this._names=i,this._terminalConnections.forEach(r=>{i.includes(r.name)||r.dispose()}),this._runningChanged.emit(this._models))}_onStarted(e){this._terminalConnections.add(e),e.disposed.connect(this._onDisposed,this)}_onDisposed(e){this._terminalConnections.delete(e),this.refreshRunning().catch(()=>{})}get _models(){return this._names.map(e=>({name:e}))}};Ot.TerminalManager=kt;(function(n){class e extends n{constructor(){super(...arguments),this._readyPromise=new Promise(()=>{})}get isActive(){return!1}get parentReady(){return super.ready}get ready(){return this.parentReady.then(()=>this._readyPromise)}async startNew(s){return Promise.reject(new Error("Not implemented in no-op Terminal Manager"))}connectTo(s){throw Error("Not implemented in no-op Terminal Manager")}async shutdown(s){return Promise.reject(new Error("Not implemented in no-op Terminal Manager"))}async requestRunning(){return Promise.resolve()}}n.NoopManager=e})(kt||(Ot.TerminalManager=kt={}))});var Hs=R(ge=>{"use strict";var Co=ge&&ge.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Gc=ge&&ge.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Po=ge&&ge.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&Co(e,n,t);return Gc(e,n),e},Xc=ge&&ge.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Co(e,n,t)};Object.defineProperty(ge,"__esModule",{value:!0});ge.TerminalAPI=ge.Terminal=void 0;var Yc=Po(yo());ge.Terminal=Yc;var Qc=Po(Rt());ge.TerminalAPI=Qc;Xc(bo(),ge)});var Eo=R(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0})});var Gs=R(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.UserAPIClient=void 0;var Io=de(),Zc=te(),eu="api/me",Js=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Io.ServerConnection.makeSettings()}async get(){let{baseUrl:e}=this.serverSettings,{makeRequest:t,ResponseError:s}=Io.ServerConnection,i=Zc.URLExt.join(e,eu),r=await t(i,{},this.serverSettings);if(r.status!==200)throw await s.create(r);return await r.json()}};Un.UserAPIClient=Js});var ko=R(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.UserManager=void 0;var tu=Y(),nu=Je(),Ro=ee(),su=He(),iu=Gs(),Xs="@jupyterlab/services:UserManager#user",Ys=class extends su.BaseManager{constructor(e={}){var t,s;super(e),this._isReady=!1,this._userChanged=new Ro.Signal(this),this._connectionFailure=new Ro.Signal(this),this._userApiClient=(t=e.userApiClient)!==null&&t!==void 0?t:new iu.UserAPIClient({serverSettings:this.serverSettings}),this._ready=this.requestUser().then(()=>{this.isDisposed||(this._isReady=!0)}).catch(i=>new Promise(()=>{})),this._pollUser=new nu.Poll({auto:!1,factory:()=>this.requestUser(),frequency:{interval:61*1e3,backoff:!0,max:300*1e3},name:Xs,standby:(s=e.standby)!==null&&s!==void 0?s:"when-hidden"}),this.ready.then(()=>{this._pollUser.start()})}get isReady(){return this._isReady}get ready(){return this._ready}get identity(){return this._identity}get permissions(){return this._permissions}get userChanged(){return this._userChanged}get connectionFailure(){return this._connectionFailure}dispose(){this._pollUser.dispose(),super.dispose()}async refreshUser(){await this._pollUser.refresh(),await this._pollUser.tick}async requestUser(){if(this.isDisposed)return;let e={identity:this._identity,permissions:this._permissions},t=await this._userApiClient.get(),s=t.identity,{localStorage:i}=window,r=i.getItem(Xs);if(r&&(!s.initials||!s.color)){let o=JSON.parse(r);s.initials=s.initials||o.initials||s.name.substring(0,1),s.color=s.color||o.color||Qs.getRandomColor()}tu.JSONExt.deepEqual(t,e)||(this._identity=s,this._permissions=t.permissions,i.setItem(Xs,JSON.stringify(s)),this._userChanged.emit(t))}};An.UserManager=Ys;var Qs;(function(n){let e=["var(--jp-collaborator-color1)","var(--jp-collaborator-color2)","var(--jp-collaborator-color3)","var(--jp-collaborator-color4)","var(--jp-collaborator-color5)","var(--jp-collaborator-color6)","var(--jp-collaborator-color7)"];n.getRandomColor=()=>e[Math.floor(Math.random()*e.length)]})(Qs||(Qs={}))});var Zs=R(me=>{"use strict";var Oo=me&&me.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),ru=me&&me.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Do=me&&me.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&Oo(e,n,t);return ru(e,n),e},ou=me&&me.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Oo(e,n,t)};Object.defineProperty(me,"__esModule",{value:!0});me.UserAPI=me.User=void 0;var au=Do(Eo());me.User=au;var lu=Do(Gs());me.UserAPI=lu;ou(ko(),me)});var ti=R(Nn=>{"use strict";Object.defineProperty(Nn,"__esModule",{value:!0});Nn.WorkspaceManager=void 0;var qo=te(),cu=xs(),Dt=de(),uu="api/workspaces",ei=class extends cu.DataConnector{constructor(e={}){var t;super(),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Dt.ServerConnection.makeSettings()}async fetch(e){let{serverSettings:t}=this,{baseUrl:s,appUrl:i}=t,{makeRequest:r,ResponseError:o}=Dt.ServerConnection,a=s+i,d=rt.url(a,e),c=await r(d,{},t);if(c.status!==200)throw await o.create(c);return c.json()}async list(){let{serverSettings:e}=this,{baseUrl:t,appUrl:s}=e,{makeRequest:i,ResponseError:r}=Dt.ServerConnection,o=t+s,a=rt.url(o,""),d=await i(a,{},e);if(d.status!==200)throw await r.create(d);return(await d.json()).workspaces}async remove(e){let{serverSettings:t}=this,{baseUrl:s,appUrl:i}=t,{makeRequest:r,ResponseError:o}=Dt.ServerConnection,a=s+i,d=rt.url(a,e),u=await r(d,{method:"DELETE"},t);if(u.status!==204)throw await o.create(u)}async save(e,t){let{serverSettings:s}=this,{baseUrl:i,appUrl:r}=s,{makeRequest:o,ResponseError:a}=Dt.ServerConnection,d=i+r,c=rt.url(d,e),u={body:JSON.stringify(t),method:"PUT"},l=await o(c,u,s);if(l.status!==204)throw await a.create(l)}};Nn.WorkspaceManager=ei;var rt;(function(n){function e(t,s){let i=qo.URLExt.join(t,uu),r=qo.URLExt.join(i,s);if(!r.startsWith(i))throw new Error("Can only be used for workspaces requests");return r}n.url=e})(rt||(rt={}))});var jo=R(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.ServiceManager=void 0;var To=ee(),du=Wr(),hu=_s(),fu=gs(),_u=Ms(),pu=Is(),gu=Ts(),mu=de(),vu=As(),yu=zs(),wu=Hs(),Su=Zs(),bu=ti(),ni=class{constructor(e={}){var t,s;this._isDisposed=!1,this._connectionFailure=new To.Signal(this),this._isReady=!1;let i=e.defaultDrive,r=(t=e.serverSettings)!==null&&t!==void 0?t:mu.ServerConnection.makeSettings(),o=(s=e.standby)!==null&&s!==void 0?s:"when-hidden",a={defaultDrive:i,serverSettings:r,standby:o};this.serverSettings=r,this.contents=e.contents||new hu.ContentsManager(a),this.events=e.events||new fu.EventManager(a),this.kernels=e.kernels||new _u.KernelManager(a),this.sessions=e.sessions||new vu.SessionManager({...a,kernelManager:this.kernels}),this.settings=e.settings||new yu.SettingManager(a),this.terminals=e.terminals||new wu.TerminalManager(a),this.builder=e.builder||new du.BuildManager(a),this.workspaces=e.workspaces||new bu.WorkspaceManager(a),this.nbconvert=e.nbconvert||new gu.NbConvertManager(a),this.kernelspecs=e.kernelspecs||new pu.KernelSpecManager(a),this.user=e.user||new Su.UserManager(a),this.kernelspecs.connectionFailure.connect(this._onConnectionFailure,this),this.sessions.connectionFailure.connect(this._onConnectionFailure,this),this.terminals.connectionFailure.connect(this._onConnectionFailure,this);let d=[this.sessions.ready,this.kernelspecs.ready];this.terminals.isAvailable()&&d.push(this.terminals.ready),this._readyPromise=Promise.all(d).then(()=>{this._isReady=!0})}get connectionFailure(){return this._connectionFailure}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,To.Signal.clearData(this),this.contents.dispose(),this.events.dispose(),this.sessions.dispose(),this.terminals.dispose())}get isReady(){return this._isReady}get ready(){return this._readyPromise}_onConnectionFailure(e,t){this._connectionFailure.emit(t)}};Ln.ServiceManager=ni});var Uo=R(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.IWorkspaceManager=L.IUserManager=L.ITerminalManager=L.IServiceManager=L.ISettingManager=L.ISessionManager=L.IServerSettings=L.INbConvertManager=L.IKernelSpecManager=L.IKernelManager=L.IEventManager=L.IDefaultDrive=L.IDefaultContentProvider=L.IContentsManager=L.IConfigSectionManager=L.IConnectionStatus=void 0;var le=Y();L.IConnectionStatus=new le.Token("@jupyterlab/application:IConnectionStatus","A service providing the application connection status.");L.IConfigSectionManager=new le.Token("@jupyterlab/services:IConfigSectionManager","A service providing the config section manager.");L.IContentsManager=new le.Token("@jupyterlab/services:IContentsManager","The contents manager token.");L.IDefaultContentProvider=new le.Token("@jupyterlab/services:IDefaultContentProvider","The default content provider for the contents manager.");L.IDefaultDrive=new le.Token("@jupyterlab/services:IDefaultDrive","The default drive for the contents manager.");L.IEventManager=new le.Token("@jupyterlab/services:IEventManager","The event manager token.");L.IKernelManager=new le.Token("@jupyterlab/services:IKernelManager","The kernel manager token.");L.IKernelSpecManager=new le.Token("@jupyterlab/services:IKernelSpecManager","The kernel spec manager token.");L.INbConvertManager=new le.Token("@jupyterlab/services:INbConvertManager","The nbconvert manager token.");L.IServerSettings=new le.Token("@jupyterlab/services:IServerSettings","The server settings for the application.");L.ISessionManager=new le.Token("@jupyterlab/services:ISessionManager","The session manager token.");L.ISettingManager=new le.Token("@jupyterlab/services:ISettingManager","The setting manager token.");L.IServiceManager=new le.Token("@jupyterlab/services:IServiceManager","The service manager for the application.");L.ITerminalManager=new le.Token("@jupyterlab/services:ITerminalManager","The terminal manager token.");L.IUserManager=new le.Token("@jupyterlab/services:IUserManager","The user manager token.");L.IWorkspaceManager=new le.Token("@jupyterlab/services:IWorkspaceManager","The workspace manager token.")});var Ae=R($=>{"use strict";var Cu=$&&$.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),ce=$&&$.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Cu(e,n,t)};Object.defineProperty($,"__esModule",{value:!0});ce(He(),$);ce(rr(),$);ce(or(),$);ce(_s(),$);ce(gs(),$);ce(Ms(),$);ce(Is(),$);ce(jo(),$);ce(de(),$);ce(As(),$);ce(zs(),$);ce(Hs(),$);ce(Uo(),$);ce(Zs(),$);ce(ti(),$);ce(Ts(),$)});function Ao(n){return"node"in n}var No=ri(()=>{});var Fo={};ta(Fo,{BLOCK_SIZE:()=>Iu,ContentsAPI:()=>zn,DRIVE_SEPARATOR:()=>xo,DriveFS:()=>qt,DriveFSEmscriptenNodeOps:()=>Kn,DriveFSEmscriptenStreamOps:()=>Fn,ServiceWorkerContentsAPI:()=>Vn});var Lo,xo,Iu,Ru,ku,xn,Fn,Kn,zn,Vn,qt,si=ri(()=>{Lo=$n(Y());No();xo=":",Iu=4096,Ru=new TextEncoder,ku=new TextDecoder("utf-8"),xn={0:!1,1:!0,2:!0,64:!0,65:!0,66:!0,129:!0,193:!0,514:!0,577:!0,578:!0,705:!0,706:!0,1024:!0,1025:!0,1026:!0,1089:!0,1090:!0,1153:!0,1154:!0,1217:!0,1218:!0,4096:!0,4098:!0},Fn=class{constructor(e){this.fs=e}open(e){var t;let s=this.fs.realPath(e.node);if(this.fs.FS.isFile(e.node.mode))try{let i=this.fs.API.get(s);e.file=i}catch{let r=(t=e.flags)!==null&&t!==void 0?t:e.shared.flags,o=typeof r=="string"?parseInt(r,10):r;o&=8191;let a=!0;if(o in xn&&(a=xn[o]),a){e.node=this.fs.node_ops.mknod(e.node.parent,e.node.name,e.node.mode,0);let d=this.fs.API.get(s);e.file=d}else throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.ENOENT)}}close(e){var t;if(!this.fs.FS.isFile(e.node.mode)||!e.file)return;let s=this.fs.realPath(e.node),i=(t=e.flags)!==null&&t!==void 0?t:e.shared.flags,r=typeof i=="string"?parseInt(i,10):i;r&=8191;let o=!0;r in xn&&(o=xn[r]),o&&this.fs.API.put(s,e.file),e.file=void 0}read(e,t,s,i,r){if(i<=0||e.file===void 0||r>=(e.file.data.length||0))return 0;let o=Math.min(e.file.data.length-r,i);return t.set(e.file.data.subarray(r,r+o),s),o}write(e,t,s,i,r){var o;if(i<=0||e.file===void 0)return 0;let a=Date.now();if(e.node.timestamp=a,e.node.atime=a,e.node.mtime=a,e.node.ctime=a,r+i>(((o=e.file)===null||o===void 0?void 0:o.data.length)||0)){let d=e.file.data?e.file.data:new Uint8Array;e.file.data=new Uint8Array(r+i),e.file.data.set(d)}return e.file.data.set(t.subarray(s,s+i),r),i}llseek(e,t,s){var i;let r=t;if(s===1)r+=(i=e.position)!==null&&i!==void 0?i:e.shared.position;else if(s===2&&this.fs.FS.isFile(e.node.mode))if(e.file!==void 0)r+=e.file.data.length;else throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM);if(r<0)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EINVAL);return r}},Kn=class{constructor(e){this.node=t=>Ao(t)?t.node:t,this.getattr=t=>{let s=this.node(t);return{...this.fs.API.getattr(this.fs.realPath(s)),mode:s.mode,ino:s.id}},this.setattr=(t,s)=>{let i=this.node(t);for(let[r,o]of Object.entries(s))switch(r){case"mode":i.mode=o;break;case"timestamp":i.timestamp=o;break;case"atime":i.atime=o;break;case"mtime":i.mtime=o;break;case"ctime":i.ctime=o;break;case"size":{let a=o,d=this.fs.realPath(i);if(this.fs.FS.isFile(i.mode)&&a>=0){let c;try{c=this.fs.API.get(d)}catch{break}let u=c.data?c.data:new Uint8Array;a!==u.length&&(a<u.length?c.data=c.data.slice(0,a):(c.data=new Uint8Array(a),c.data.set(u)),this.fs.API.put(d,c))}else console.warn("setattr size of",a,"on",i,"not yet implemented");break}case"dontFollow":break;default:console.warn("setattr",r,"of",o,"on",i,"not yet implemented");break}},this.lookup=(t,s)=>{let i=this.node(t),r=this.fs.PATH.join2(this.fs.realPath(i),s),o=this.fs.API.lookup(r);if(!o.ok)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.ENOENT);return this.fs.createNode(i,s,o.mode,0)},this.mknod=(t,s,i,r)=>{let o=this.node(t),a=this.fs.PATH.join2(this.fs.realPath(o),s);return this.fs.API.mknod(a,i),this.fs.createNode(o,s,i,r)},this.rename=(t,s,i)=>{let r=this.node(t),o=this.node(s);this.fs.API.rename(r.parent?this.fs.PATH.join2(this.fs.realPath(r.parent),r.name):r.name,this.fs.PATH.join2(this.fs.realPath(o),i)),r.name=i,r.parent=o},this.unlink=(t,s)=>this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(this.node(t)),s)),this.rmdir=(t,s)=>this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(this.node(t)),s)),this.readdir=t=>this.fs.API.readdir(this.fs.realPath(this.node(t))),this.symlink=(t,s,i)=>{throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM)},this.readlink=t=>{throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EINVAL)},this.fs=e}},zn=class{constructor(e){this._driveName=e.driveName,this._mountpoint=e.mountpoint,this.FS=e.FS,this.ERRNO_CODES=e.ERRNO_CODES}lookup(e){return this.request({method:"lookup",path:this.normalizePath(e)})}getmode(e){return this.request({method:"getmode",path:this.normalizePath(e)})}mknod(e,t){return this.request({method:"mknod",path:this.normalizePath(e),data:{mode:t}})}rename(e,t){return this.request({method:"rename",path:this.normalizePath(e),data:{newPath:this.normalizePath(t)}})}readdir(e){let t=this.request({method:"readdir",path:this.normalizePath(e)});return t.push("."),t.push(".."),t}rmdir(e){return this.request({method:"rmdir",path:this.normalizePath(e)})}get(e){let t=this.request({method:"get",path:this.normalizePath(e)});if(!t)throw new this.FS.ErrnoError(this.ERRNO_CODES.ENOENT);let s=t.content,i=t.format;switch(i){case"json":case"text":return{data:Ru.encode(s),format:i};case"base64":{let r=atob(s),o=r.length,a=new Uint8Array(o);for(let d=0;d<o;d++)a[d]=r.charCodeAt(d);return{data:a,format:i}}default:throw new this.FS.ErrnoError(this.ERRNO_CODES.ENOENT)}}put(e,t){switch(t.format){case"json":case"text":return this.request({method:"put",path:this.normalizePath(e),data:{format:t.format,data:ku.decode(t.data)}});case"base64":{let s="";for(let i=0;i<t.data.byteLength;i++)s+=String.fromCharCode(t.data[i]);return this.request({method:"put",path:this.normalizePath(e),data:{format:t.format,data:btoa(s)}})}}}getattr(e){let t=this.request({method:"getattr",path:this.normalizePath(e)}),s=new Date(0);return t.atime=t.atime?new Date(t.atime):s,t.mtime=t.mtime?new Date(t.mtime):s,t.ctime=t.ctime?new Date(t.ctime):s,t.size=t.size||0,t}normalizePath(e){return e.startsWith(this._mountpoint)&&(e=e.slice(this._mountpoint.length)),this._driveName&&(e=`${this._driveName}${xo}${e}`),e}},Vn=class extends zn{constructor(e){super(e),this._baseUrl=e.baseUrl,this._browsingContextId=e.browsingContextId||""}request(e){let t=new XMLHttpRequest;t.open("POST",encodeURI(this.endpoint),!1);let s=Lo.UUID.uuid4(),i={data:{...e,requestId:s},browsingContextId:this._browsingContextId,requestId:s};try{t.send(JSON.stringify(i))}catch(r){console.error(r)}if(t.status>=400)throw new this.FS.ErrnoError(this.ERRNO_CODES.EINVAL);return JSON.parse(t.responseText)}get endpoint(){return`${this._baseUrl}api/drive`}},qt=class{constructor(e){this.FS=e.FS,this.PATH=e.PATH,this.ERRNO_CODES=e.ERRNO_CODES,this.API=this.createAPI(e),this.driveName=e.driveName,this.node_ops=new Kn(this),this.stream_ops=new Fn(this)}createAPI(e){if(!e.browsingContextId||!e.baseUrl)throw new Error("Cannot create service-worker API without current browsingContextId");return new Vn(e)}mount(e){return this.createNode(null,e.mountpoint,16895,0)}createNode(e,t,s,i){let r=this.FS;if(!r.isDir(s)&&!r.isFile(s))throw new r.ErrnoError(this.ERRNO_CODES.EINVAL);let o=r.createNode(e,t,s,i);return o.node_ops=this.node_ops,o.stream_ops=this.stream_ops,o}getMode(e){return this.API.getmode(e)}realPath(e){let t=[],s=e;for(t.push(s.name);s.parent!==s;)s=s.parent,t.push(s.name);return t.reverse(),this.PATH.join.apply(null,t)}}});var ai=Symbol("Comlink.proxy"),sa=Symbol("Comlink.endpoint"),ia=Symbol("Comlink.releaseProxy"),Hn=Symbol("Comlink.finalizer"),jt=Symbol("Comlink.thrown"),li=n=>typeof n=="object"&&n!==null||typeof n=="function",ra={canHandle:n=>li(n)&&n[ai],serialize(n){let{port1:e,port2:t}=new MessageChannel;return Lt(n,e),[t,[t]]},deserialize(n){return n.start(),ca(n)}},oa={canHandle:n=>li(n)&&jt in n,serialize({value:n}){let e;return n instanceof Error?e={isError:!0,value:{message:n.message,name:n.name,stack:n.stack}}:e={isError:!1,value:n},[e,[]]},deserialize(n){throw n.isError?Object.assign(new Error(n.value.message),n.value):n.value}},ci=new Map([["proxy",ra],["throw",oa]]);function aa(n,e){for(let t of n)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function Lt(n,e=globalThis,t=["*"]){e.addEventListener("message",function s(i){if(!i||!i.data)return;if(!aa(t,i.origin)){console.warn(`Invalid origin '${i.origin}' for comlink proxy`);return}let{id:r,type:o,path:a}=Object.assign({path:[]},i.data),d=(i.data.argumentList||[]).map($e),c;try{let u=a.slice(0,-1).reduce((h,v)=>h[v],n),l=a.reduce((h,v)=>h[v],n);switch(o){case"GET":c=l;break;case"SET":u[a.slice(-1)[0]]=$e(i.data.value),c=!0;break;case"APPLY":c=l.apply(u,d);break;case"CONSTRUCT":{let h=new l(...d);c=_a(h)}break;case"ENDPOINT":{let{port1:h,port2:v}=new MessageChannel;Lt(n,v),c=fa(h,[h])}break;case"RELEASE":c=void 0;break;default:return}}catch(u){c={value:u,[jt]:0}}Promise.resolve(c).catch(u=>({value:u,[jt]:0})).then(u=>{let[l,h]=Nt(u);e.postMessage(Object.assign(Object.assign({},l),{id:r}),h),o==="RELEASE"&&(e.removeEventListener("message",s),ui(e),Hn in n&&typeof n[Hn]=="function"&&n[Hn]())}).catch(u=>{let[l,h]=Nt({value:new TypeError("Unserializable return value"),[jt]:0});e.postMessage(Object.assign(Object.assign({},l),{id:r}),h)})}),e.start&&e.start()}function la(n){return n.constructor.name==="MessagePort"}function ui(n){la(n)&&n.close()}function ca(n,e){let t=new Map;return n.addEventListener("message",function(i){let{data:r}=i;if(!r||!r.id)return;let o=t.get(r.id);if(o)try{o(r)}finally{t.delete(r.id)}}),Jn(n,t,[],e)}function Tt(n){if(n)throw new Error("Proxy has been released and is not useable")}function di(n){return Xe(n,new Map,{type:"RELEASE"}).then(()=>{ui(n)})}var Ut=new WeakMap,At="FinalizationRegistry"in globalThis&&new FinalizationRegistry(n=>{let e=(Ut.get(n)||0)-1;Ut.set(n,e),e===0&&di(n)});function ua(n,e){let t=(Ut.get(e)||0)+1;Ut.set(e,t),At&&At.register(n,e,n)}function da(n){At&&At.unregister(n)}function Jn(n,e,t=[],s=function(){}){let i=!1,r=new Proxy(s,{get(o,a){if(Tt(i),a===ia)return()=>{da(r),di(n),e.clear(),i=!0};if(a==="then"){if(t.length===0)return{then:()=>r};let d=Xe(n,e,{type:"GET",path:t.map(c=>c.toString())}).then($e);return d.then.bind(d)}return Jn(n,e,[...t,a])},set(o,a,d){Tt(i);let[c,u]=Nt(d);return Xe(n,e,{type:"SET",path:[...t,a].map(l=>l.toString()),value:c},u).then($e)},apply(o,a,d){Tt(i);let c=t[t.length-1];if(c===sa)return Xe(n,e,{type:"ENDPOINT"}).then($e);if(c==="bind")return Jn(n,e,t.slice(0,-1));let[u,l]=oi(d);return Xe(n,e,{type:"APPLY",path:t.map(h=>h.toString()),argumentList:u},l).then($e)},construct(o,a){Tt(i);let[d,c]=oi(a);return Xe(n,e,{type:"CONSTRUCT",path:t.map(u=>u.toString()),argumentList:d},c).then($e)}});return ua(r,n),r}function ha(n){return Array.prototype.concat.apply([],n)}function oi(n){let e=n.map(Nt);return[e.map(t=>t[0]),ha(e.map(t=>t[1]))]}var hi=new WeakMap;function fa(n,e){return hi.set(n,e),n}function _a(n){return Object.assign(n,{[ai]:!0})}function Nt(n){for(let[e,t]of ci)if(t.canHandle(n)){let[s,i]=t.serialize(n);return[{type:"HANDLER",name:e,value:s},i]}return[{type:"RAW",value:n},hi.get(n)||[]]}function $e(n){switch(n.type){case"HANDLER":return ci.get(n.name).deserialize(n.value);case"RAW":return n.value}}function Xe(n,e,t,s){return new Promise(i=>{let r=pa();e.set(r,i),n.start&&n.start(),n.postMessage(Object.assign({id:r},t),s)})}function pa(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var Ko=$n(te()),zo=$n(Ae());si();var Bn=class{constructor(){this._options=null;this._initializer=null;this._pyodide=null;this._localPath="";this._driveName="";this._driveFS=null;this._sendWorkerMessage=()=>{};this._logMessage=()=>{};this._initialized=new Promise((e,t)=>{this._initializer={resolve:e,reject:t}})}async initialize(e){var t;if(this._options=e,e.location.includes(":")){let s=e.location.split(":");this._driveName=s[0],this._localPath=s[1]}else this._driveName="",this._localPath=e.location;await this.initRuntime(e),await this.initFilesystem(e),await this.initPackageManager(e),await this.initKernel(e),await this.initGlobals(e),(t=this._initializer)==null||t.resolve()}async initRuntime(e){let{pyodideUrl:t,indexUrl:s}=e,i;t.endsWith(".mjs")?i=(await import(t)).loadPyodide:(importScripts(t),i=self.loadPyodide),this._pyodide=await i({indexURL:s,stdout:r=>{console.log(r),this._logMessage({type:"text",level:"info",data:r})},stderr:r=>{console.error(r),this._logMessage({type:"text",level:"critical",data:r})},...e.loadPyodideOptions}),this._pyodide._api.on_fatal=async r=>{let o="";r.name==="Exit"?o="Pyodide has exited and can no longer be used.":o=`Pyodide has suffered a fatal error. Please report this to the Pyodide maintainers.
|
|
10
|
-
The cause of the error was: ${
|
|
11
|
-
${
|
|
9
|
+
See "state database" for more information.`)});var Fs=O(Ee=>{"use strict";var Ac=Ee&&Ee.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),Pt=Ee&&Ee.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Ac(e,r,t)};Object.defineProperty(Ee,"__esModule",{value:!0});Pt(lo(),Ee);Pt(uo(),Ee);Pt(go(),Ee);Pt(po(),Ee);Pt(mo(),Ee)});var Vs=O(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.SettingManager=void 0;var Ks=te(),Nc=Fs(),kn=he(),Lc="api/settings",zs=class extends Nc.DataConnector{constructor(e={}){var t;super(),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:kn.ServerConnection.makeSettings()}async fetch(e){if(!e)throw new Error("Plugin `id` parameter is required for settings fetch.");let{serverSettings:t}=this,{baseUrl:n,appUrl:s}=t,{makeRequest:i,ResponseError:o}=kn.ServerConnection,a=n+s,h=Mt.url(a,e),c=await i(h,{},t);if(c.status!==200)throw await o.create(c);return c.json()}async list(e){var t,n,s,i;let{serverSettings:o}=this,{baseUrl:a,appUrl:h}=o,{makeRequest:c,ResponseError:u}=kn.ServerConnection,l=a+h,d=Mt.url(l,"",e==="ids"),m=await c(d,{},o);if(m.status!==200)throw new u(m);let v=await m.json(),T=(n=(t=v==null?void 0:v.settings)===null||t===void 0?void 0:t.map(q=>q.id))!==null&&n!==void 0?n:[],E=[];return e||(E=(i=(s=v==null?void 0:v.settings)===null||s===void 0?void 0:s.map(q=>(q.data={composite:{},user:{}},q)))!==null&&i!==void 0?i:[]),{ids:T,values:E}}async save(e,t){let{serverSettings:n}=this,{baseUrl:s,appUrl:i}=n,{makeRequest:o,ResponseError:a}=kn.ServerConnection,h=s+i,c=Mt.url(h,e),u={body:JSON.stringify({raw:t}),method:"PUT"},l=await o(c,u,n);if(l.status!==204)throw new a(l)}};Dn.SettingManager=zs;var Mt;(function(r){function e(t,n,s){let i=s?Ks.URLExt.objectToQueryString({ids_only:!0}):"",o=Ks.URLExt.join(t,Lc),a=Ks.URLExt.join(o,n);if(!a.startsWith(o))throw new Error("Can only be used for workspaces requests");return`${a}${i}`}r.url=e})(Mt||(Mt={}))});var Ot=O(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.TerminalAPIClient=we.TERMINAL_SERVICE_URL=void 0;we.isAvailable=$s;we.startNew=vo;we.listRunning=yo;we.shutdownTerminal=wo;var Et=te(),Ue=he();we.TERMINAL_SERVICE_URL="api/terminals";function $s(){return String(Et.PageConfig.getOption("terminalsAvailable")).toLowerCase()==="true"}async function vo(r=Ue.ServerConnection.makeSettings(),e,t){It.errorIfNotAvailable();let n=Et.URLExt.join(r.baseUrl,we.TERMINAL_SERVICE_URL),s={method:"POST",body:JSON.stringify({name:e,cwd:t})},i=await Ue.ServerConnection.makeRequest(n,s,r);if(i.status!==200)throw await Ue.ServerConnection.ResponseError.create(i);return await i.json()}async function yo(r=Ue.ServerConnection.makeSettings()){It.errorIfNotAvailable();let e=Et.URLExt.join(r.baseUrl,we.TERMINAL_SERVICE_URL),t=await Ue.ServerConnection.makeRequest(e,{},r);if(t.status!==200)throw await Ue.ServerConnection.ResponseError.create(t);let n=await t.json();if(!Array.isArray(n))throw new Error("Invalid terminal list");return n}async function wo(r,e=Ue.ServerConnection.makeSettings()){var t;It.errorIfNotAvailable();let n=Et.URLExt.join(e.baseUrl,we.TERMINAL_SERVICE_URL),s=Et.URLExt.join(n,r);if(!s.startsWith(n))throw new Error("Can only be used for terminal requests");let i={method:"DELETE"},o=await Ue.ServerConnection.makeRequest(s,i,e);if(o.status===404){let h=(t=(await o.json()).message)!==null&&t!==void 0?t:`The terminal session "${r}"" does not exist on the server`;console.warn(h)}else if(o.status!==204)throw await Ue.ServerConnection.ResponseError.create(o)}var Bs=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ue.ServerConnection.makeSettings()}get isAvailable(){return $s()}async startNew(e={}){let{name:t,cwd:n}=e;return vo(this.serverSettings,t,n)}async listRunning(){return yo(this.serverSettings)}async shutdown(e){return wo(e,this.serverSettings)}};we.TerminalAPIClient=Bs;var It;(function(r){function e(){if(!$s())throw new Error("Terminals Unavailable")}r.errorIfNotAvailable=e})(It||(It={}))});var So=O(Tn=>{"use strict";Object.defineProperty(Tn,"__esModule",{value:!0});Tn.isAvailable=void 0;var xc=Ot();Object.defineProperty(Tn,"isAvailable",{enumerable:!0,get:function(){return xc.isAvailable}})});var bo=O(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.TerminalConnection=void 0;var Fc=te(),Kc=X(),qn=ee(),zc=Ae(),Vc=Ot(),Ws=class r{constructor(e){var t,n;this._createSocket=()=>{this._errorIfDisposed(),this._clearSocket(),this._updateConnectionStatus("connecting");let s=this._name,i=this.serverSettings,o=Fc.URLExt.join(i.wsUrl,"terminals","websocket",encodeURIComponent(s)),a=i.token;i.appendToken&&a!==""&&(o=o+`?token=${encodeURIComponent(a)}`),this._ws=new i.WebSocket(o),this._ws.onmessage=this._onWSMessage,this._ws.onclose=this._onWSClose,this._ws.onerror=this._onWSClose},this._onWSMessage=s=>{if(this._isDisposed)return;let i=JSON.parse(s.data);if(i[0]==="disconnect"&&this.dispose(),this._connectionStatus==="connecting"){i[0]==="setup"&&this._updateConnectionStatus("connected");return}this._messageReceived.emit({type:i[0],content:i.slice(1)})},this._onWSClose=s=>{console.warn(`Terminal websocket closed: ${s.code}`),!this.isDisposed&&(s.code===1e3||s.code===1001||this._reconnect())},this._connectionStatus="connecting",this._connectionStatusChanged=new qn.Signal(this),this._isDisposed=!1,this._disposed=new qn.Signal(this),this._messageReceived=new qn.Signal(this),this._reconnectTimeout=null,this._ws=null,this._noOp=()=>{},this._reconnectLimit=7,this._reconnectAttempt=0,this._pendingMessages=[],this._name=e.model.name,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:zc.ServerConnection.makeSettings(),this._terminalAPIClient=(n=e.terminalAPIClient)!==null&&n!==void 0?n:new Vc.TerminalAPIClient({serverSettings:this.serverSettings}),this._createSocket()}get disposed(){return this._disposed}get messageReceived(){return this._messageReceived}get name(){return this._name}get model(){return{name:this._name}}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposed.emit(),this._updateConnectionStatus("disconnected"),this._clearSocket(),qn.Signal.clearData(this))}send(e){this._sendMessage(e)}_sendMessage(e,t=!0){if(!(this._isDisposed||!e.content))if(this.connectionStatus==="connected"&&this._ws){let n=[e.type,...e.content];this._ws.send(JSON.stringify(n))}else if(t)this._pendingMessages.push(e);else throw new Error(`Could not send message: ${JSON.stringify(e)}`)}_sendPending(){for(;this.connectionStatus==="connected"&&this._pendingMessages.length>0;)this._sendMessage(this._pendingMessages[0],!1),this._pendingMessages.shift()}reconnect(){this._errorIfDisposed();let e=new Kc.PromiseDelegate,t=(n,s)=>{s==="connected"?(e.resolve(),this.connectionStatusChanged.disconnect(t,this)):s==="disconnected"&&(e.reject(new Error("Terminal connection disconnected")),this.connectionStatusChanged.disconnect(t,this))};return this.connectionStatusChanged.connect(t,this),this._reconnectAttempt=0,this._reconnect(),e.promise}_reconnect(){if(this._errorIfDisposed(),clearTimeout(this._reconnectTimeout),this._reconnectAttempt<this._reconnectLimit){this._updateConnectionStatus("connecting");let e=Hs.getRandomIntInclusive(0,1e3*(Math.pow(2,this._reconnectAttempt)-1));console.error(`Connection lost, reconnecting in ${Math.floor(e/1e3)} seconds.`),this._reconnectTimeout=setTimeout(this._createSocket,e),this._reconnectAttempt+=1}else this._updateConnectionStatus("disconnected");this._clearSocket()}_clearSocket(){this._ws!==null&&(this._ws.onopen=this._noOp,this._ws.onclose=this._noOp,this._ws.onerror=this._noOp,this._ws.onmessage=this._noOp,this._ws.close(),this._ws=null)}async shutdown(){await this._terminalAPIClient.shutdown(this.name),this.dispose()}clone(){return new r({model:this.model,serverSettings:this.serverSettings,terminalAPIClient:this._terminalAPIClient})}_updateConnectionStatus(e){this._connectionStatus!==e&&(this._connectionStatus=e,e!=="connecting"&&(this._reconnectAttempt=0,clearTimeout(this._reconnectTimeout)),e==="connected"&&this._sendPending(),this._connectionStatusChanged.emit(e))}_errorIfDisposed(){if(this.isDisposed)throw new Error("Terminal connection is disposed")}get connectionStatusChanged(){return this._connectionStatusChanged}get connectionStatus(){return this._connectionStatus}};jn.TerminalConnection=Ws;var Hs;(function(r){function e(t,n){return t=Math.ceil(t),n=Math.floor(n),Math.floor(Math.random()*(n-t+1))+t}r.getRandomIntInclusive=e})(Hs||(Hs={}))});var Po=O(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.TerminalManager=void 0;var Bc=Ge(),Co=ee(),$c=Ae(),Wc=Je(),Hc=Ot(),Jc=bo(),Rt=class extends Wc.BaseManager{constructor(e={}){var t,n;if(super(e),this._isReady=!1,this._names=[],this._terminalConnections=new Set,this._runningChanged=new Co.Signal(this),this._connectionFailure=new Co.Signal(this),this._terminalAPIClient=(t=e.terminalAPIClient)!==null&&t!==void 0?t:new Hc.TerminalAPIClient({serverSettings:this.serverSettings}),!this.isAvailable()){this._ready=Promise.reject("Terminals unavailable"),this._ready.catch(i=>{});return}let s=this._pollModels=new Bc.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:TerminalManager#models",standby:(n=e.standby)!==null&&n!==void 0?n:"when-hidden"});this._ready=(async()=>{await s.start(),await s.tick,this._isReady=!0})()}get isReady(){return this._isReady}get ready(){return this._ready}get runningChanged(){return this._runningChanged}get connectionFailure(){return this._connectionFailure}dispose(){var e;this.isDisposed||(this._names.length=0,this._terminalConnections.forEach(t=>t.dispose()),(e=this._pollModels)===null||e===void 0||e.dispose(),super.dispose())}isAvailable(){return this._terminalAPIClient.isAvailable}connectTo(e){let t=new Jc.TerminalConnection({...e,serverSettings:this.serverSettings,terminalAPIClient:this._terminalAPIClient});return this._onStarted(t),this._names.includes(e.model.name)||this.refreshRunning().catch(()=>{}),t}running(){return this._models[Symbol.iterator]()}async refreshRunning(){this._pollModels&&(await this._pollModels.refresh(),await this._pollModels.tick)}async startNew(e={}){let{name:t,cwd:n}=e,s=await this._terminalAPIClient.startNew({name:t,cwd:n});return await this.refreshRunning(),this.connectTo({model:s})}async shutdown(e){await this._terminalAPIClient.shutdown(e),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all(this._names.map(e=>this._terminalAPIClient.shutdown(e))),await this.refreshRunning()}async requestRunning(){var e,t;let n;try{n=await this._terminalAPIClient.listRunning()}catch(i){throw(i instanceof $c.ServerConnection.NetworkError||((e=i.response)===null||e===void 0?void 0:e.status)===503||((t=i.response)===null||t===void 0?void 0:t.status)===424)&&this._connectionFailure.emit(i),i}if(this.isDisposed)return;let s=n.map(({name:i})=>i).sort();s!==this._names&&(this._names=s,this._terminalConnections.forEach(i=>{s.includes(i.name)||i.dispose()}),this._runningChanged.emit(this._models))}_onStarted(e){this._terminalConnections.add(e),e.disposed.connect(this._onDisposed,this)}_onDisposed(e){this._terminalConnections.delete(e),this.refreshRunning().catch(()=>{})}get _models(){return this._names.map(e=>({name:e}))}};kt.TerminalManager=Rt;(function(r){class e extends r{constructor(){super(...arguments),this._readyPromise=new Promise(()=>{})}get isActive(){return!1}get parentReady(){return super.ready}get ready(){return this.parentReady.then(()=>this._readyPromise)}async startNew(n){return Promise.reject(new Error("Not implemented in no-op Terminal Manager"))}connectTo(n){throw Error("Not implemented in no-op Terminal Manager")}async shutdown(n){return Promise.reject(new Error("Not implemented in no-op Terminal Manager"))}async requestRunning(){return Promise.resolve()}}r.NoopManager=e})(Rt||(kt.TerminalManager=Rt={}))});var Js=O(pe=>{"use strict";var Mo=pe&&pe.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),Gc=pe&&pe.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),Eo=pe&&pe.__importStar||function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&Mo(t,e,n[s]);return Gc(t,e),t}}(),Xc=pe&&pe.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Mo(e,r,t)};Object.defineProperty(pe,"__esModule",{value:!0});pe.TerminalAPI=pe.Terminal=void 0;var Yc=Eo(So());pe.Terminal=Yc;var Qc=Eo(Ot());pe.TerminalAPI=Qc;Xc(Po(),pe)});var Oo=O(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0})});var Xs=O(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.UserAPIClient=void 0;var Ro=he(),Zc=te(),eu="api/me",Gs=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ro.ServerConnection.makeSettings()}async get(){let{baseUrl:e}=this.serverSettings,{makeRequest:t,ResponseError:n}=Ro.ServerConnection,s=Zc.URLExt.join(e,eu),i=await t(s,{},this.serverSettings);if(i.status!==200)throw await n.create(i);return await i.json()}};Un.UserAPIClient=Gs});var Do=O(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.UserManager=void 0;var tu=X(),nu=Ge(),ko=ee(),su=Je(),ru=Xs(),Ys="@jupyterlab/services:UserManager#user",Qs=class extends su.BaseManager{constructor(e={}){var t,n;super(e),this._isReady=!1,this._userChanged=new ko.Signal(this),this._connectionFailure=new ko.Signal(this),this._userApiClient=(t=e.userApiClient)!==null&&t!==void 0?t:new ru.UserAPIClient({serverSettings:this.serverSettings}),this._ready=this.requestUser().then(()=>{this.isDisposed||(this._isReady=!0)}).catch(s=>new Promise(()=>{})),this._pollUser=new nu.Poll({auto:!1,factory:()=>this.requestUser(),frequency:{interval:61*1e3,backoff:!0,max:300*1e3},name:Ys,standby:(n=e.standby)!==null&&n!==void 0?n:"when-hidden"}),this.ready.then(()=>{this._pollUser.start()})}get isReady(){return this._isReady}get ready(){return this._ready}get identity(){return this._identity}get permissions(){return this._permissions}get userChanged(){return this._userChanged}get connectionFailure(){return this._connectionFailure}dispose(){this._pollUser.dispose(),super.dispose()}async refreshUser(){await this._pollUser.refresh(),await this._pollUser.tick}async requestUser(){if(this.isDisposed)return;let e={identity:this._identity,permissions:this._permissions},t=await this._userApiClient.get(),n=t.identity,{localStorage:s}=window,i=s.getItem(Ys);if(i&&(!n.initials||!n.color)){let o=JSON.parse(i);n.initials=n.initials||o.initials||n.name.substring(0,1),n.color=n.color||o.color||Zs.getRandomColor()}tu.JSONExt.deepEqual(t,e)||(this._identity=n,this._permissions=t.permissions,s.setItem(Ys,JSON.stringify(n)),this._userChanged.emit(t))}};An.UserManager=Qs;var Zs;(function(r){let e=["var(--jp-collaborator-color1)","var(--jp-collaborator-color2)","var(--jp-collaborator-color3)","var(--jp-collaborator-color4)","var(--jp-collaborator-color5)","var(--jp-collaborator-color6)","var(--jp-collaborator-color7)"];r.getRandomColor=()=>e[Math.floor(Math.random()*e.length)]})(Zs||(Zs={}))});var er=O(me=>{"use strict";var To=me&&me.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),iu=me&&me.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),qo=me&&me.__importStar||function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&To(t,e,n[s]);return iu(t,e),t}}(),ou=me&&me.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&To(e,r,t)};Object.defineProperty(me,"__esModule",{value:!0});me.UserAPI=me.User=void 0;var au=qo(Oo());me.User=au;var lu=qo(Xs());me.UserAPI=lu;ou(Do(),me)});var nr=O(Nn=>{"use strict";Object.defineProperty(Nn,"__esModule",{value:!0});Nn.WorkspaceManager=void 0;var jo=te(),cu=Fs(),Dt=he(),uu="api/workspaces",tr=class extends cu.DataConnector{constructor(e={}){var t;super(),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Dt.ServerConnection.makeSettings()}async fetch(e){let{serverSettings:t}=this,{baseUrl:n,appUrl:s}=t,{makeRequest:i,ResponseError:o}=Dt.ServerConnection,a=n+s,h=it.url(a,e),c=await i(h,{},t);if(c.status!==200)throw await o.create(c);return c.json()}async list(){let{serverSettings:e}=this,{baseUrl:t,appUrl:n}=e,{makeRequest:s,ResponseError:i}=Dt.ServerConnection,o=t+n,a=it.url(o,""),h=await s(a,{},e);if(h.status!==200)throw await i.create(h);return(await h.json()).workspaces}async remove(e){let{serverSettings:t}=this,{baseUrl:n,appUrl:s}=t,{makeRequest:i,ResponseError:o}=Dt.ServerConnection,a=n+s,h=it.url(a,e),u=await i(h,{method:"DELETE"},t);if(u.status!==204)throw await o.create(u)}async save(e,t){let{serverSettings:n}=this,{baseUrl:s,appUrl:i}=n,{makeRequest:o,ResponseError:a}=Dt.ServerConnection,h=s+i,c=it.url(h,e),u={body:JSON.stringify(t),method:"PUT"},l=await o(c,u,n);if(l.status!==204)throw await a.create(l)}};Nn.WorkspaceManager=tr;var it;(function(r){function e(t,n){let s=jo.URLExt.join(t,uu),i=jo.URLExt.join(s,n);if(!i.startsWith(s))throw new Error("Can only be used for workspaces requests");return i}r.url=e})(it||(it={}))});var Ao=O(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.ServiceManager=void 0;var Uo=ee(),hu=Hi(),du=_s(),fu=ps(),_u=Es(),gu=Os(),pu=js(),mu=he(),vu=Ns(),yu=Vs(),wu=Js(),Su=er(),bu=nr(),sr=class{constructor(e={}){var t,n;this._isDisposed=!1,this._connectionFailure=new Uo.Signal(this),this._isReady=!1;let s=e.defaultDrive,i=(t=e.serverSettings)!==null&&t!==void 0?t:mu.ServerConnection.makeSettings(),o=(n=e.standby)!==null&&n!==void 0?n:"when-hidden",a={defaultDrive:s,serverSettings:i,standby:o};this.serverSettings=i,this.contents=e.contents||new du.ContentsManager(a),this.events=e.events||new fu.EventManager(a),this.kernels=e.kernels||new _u.KernelManager(a),this.sessions=e.sessions||new vu.SessionManager({...a,kernelManager:this.kernels}),this.settings=e.settings||new yu.SettingManager(a),this.terminals=e.terminals||new wu.TerminalManager(a),this.builder=e.builder||new hu.BuildManager(a),this.workspaces=e.workspaces||new bu.WorkspaceManager(a),this.nbconvert=e.nbconvert||new pu.NbConvertManager(a),this.kernelspecs=e.kernelspecs||new gu.KernelSpecManager(a),this.user=e.user||new Su.UserManager(a),this.kernelspecs.connectionFailure.connect(this._onConnectionFailure,this),this.sessions.connectionFailure.connect(this._onConnectionFailure,this),this.terminals.connectionFailure.connect(this._onConnectionFailure,this);let h=[this.sessions.ready,this.kernelspecs.ready];this.terminals.isAvailable()&&h.push(this.terminals.ready),this._readyPromise=Promise.all(h).then(()=>{this._isReady=!0})}get connectionFailure(){return this._connectionFailure}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,Uo.Signal.clearData(this),this.contents.dispose(),this.events.dispose(),this.sessions.dispose(),this.terminals.dispose())}get isReady(){return this._isReady}get ready(){return this._readyPromise}_onConnectionFailure(e,t){this._connectionFailure.emit(t)}};Ln.ServiceManager=sr});var No=O(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.IWorkspaceManager=L.IUserManager=L.ITerminalManager=L.IServiceManager=L.ISettingManager=L.ISessionManager=L.IServerSettings=L.INbConvertManager=L.IKernelSpecManager=L.IKernelManager=L.IEventManager=L.IDefaultDrive=L.IDefaultContentProvider=L.IContentsManager=L.IConfigSectionManager=L.IConnectionStatus=void 0;var le=X();L.IConnectionStatus=new le.Token("@jupyterlab/application:IConnectionStatus","A service providing the application connection status.");L.IConfigSectionManager=new le.Token("@jupyterlab/services:IConfigSectionManager","A service providing the config section manager.");L.IContentsManager=new le.Token("@jupyterlab/services:IContentsManager","The contents manager token.");L.IDefaultContentProvider=new le.Token("@jupyterlab/services:IDefaultContentProvider","The default content provider for the contents manager.");L.IDefaultDrive=new le.Token("@jupyterlab/services:IDefaultDrive","The default drive for the contents manager.");L.IEventManager=new le.Token("@jupyterlab/services:IEventManager","The event manager token.");L.IKernelManager=new le.Token("@jupyterlab/services:IKernelManager","The kernel manager token.");L.IKernelSpecManager=new le.Token("@jupyterlab/services:IKernelSpecManager","The kernel spec manager token.");L.INbConvertManager=new le.Token("@jupyterlab/services:INbConvertManager","The nbconvert manager token.");L.IServerSettings=new le.Token("@jupyterlab/services:IServerSettings","The server settings for the application.");L.ISessionManager=new le.Token("@jupyterlab/services:ISessionManager","The session manager token.");L.ISettingManager=new le.Token("@jupyterlab/services:ISettingManager","The setting manager token.");L.IServiceManager=new le.Token("@jupyterlab/services:IServiceManager","The service manager for the application.");L.ITerminalManager=new le.Token("@jupyterlab/services:ITerminalManager","The terminal manager token.");L.IUserManager=new le.Token("@jupyterlab/services:IUserManager","The user manager token.");L.IWorkspaceManager=new le.Token("@jupyterlab/services:IWorkspaceManager","The workspace manager token.")});var Ae=O(W=>{"use strict";var Cu=W&&W.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),ce=W&&W.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Cu(e,r,t)};Object.defineProperty(W,"__esModule",{value:!0});ce(Je(),W);ce(oi(),W);ce(ai(),W);ce(_s(),W);ce(ps(),W);ce(Es(),W);ce(Os(),W);ce(Ao(),W);ce(he(),W);ce(Ns(),W);ce(Vs(),W);ce(Js(),W);ce(No(),W);ce(er(),W);ce(nr(),W);ce(js(),W)});function Lo(r){return"node"in r}var xo=or(()=>{});var zo={};sa(zo,{BLOCK_SIZE:()=>Iu,ContentsAPI:()=>zn,DRIVE_SEPARATOR:()=>Ko,DriveFS:()=>Tt,DriveFSEmscriptenNodeOps:()=>Kn,DriveFSEmscriptenStreamOps:()=>Fn,ServiceWorkerContentsAPI:()=>Vn});var Fo,Ko,Iu,Ou,Ru,xn,Fn,Kn,zn,Vn,Tt,rr=or(()=>{Fo=Wn(X());xo();Ko=":",Iu=4096,Ou=new TextEncoder,Ru=new TextDecoder("utf-8"),xn={0:!1,1:!0,2:!0,64:!0,65:!0,66:!0,129:!0,193:!0,514:!0,577:!0,578:!0,705:!0,706:!0,1024:!0,1025:!0,1026:!0,1089:!0,1090:!0,1153:!0,1154:!0,1217:!0,1218:!0,4096:!0,4098:!0},Fn=class{constructor(e){this.fs=e}open(e){var t;let n=this.fs.realPath(e.node);if(this.fs.FS.isFile(e.node.mode))try{let s=this.fs.API.get(n);e.file=s}catch{let s=(t=e.flags)!==null&&t!==void 0?t:e.shared.flags,i=typeof s=="string"?parseInt(s,10):s;i&=8191;let o=!0;if(i in xn&&(o=xn[i]),o){e.node=this.fs.node_ops.mknod(e.node.parent,e.node.name,e.node.mode,0);let a=this.fs.API.get(n);e.file=a}else throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.ENOENT)}}close(e){var t;if(!this.fs.FS.isFile(e.node.mode)||!e.file)return;let n=this.fs.realPath(e.node),s=(t=e.flags)!==null&&t!==void 0?t:e.shared.flags,i=typeof s=="string"?parseInt(s,10):s;i&=8191;let o=!0;i in xn&&(o=xn[i]),o&&this.fs.API.put(n,e.file),e.file=void 0}read(e,t,n,s,i){if(s<=0||e.file===void 0||i>=(e.file.data.length||0))return 0;let o=Math.min(e.file.data.length-i,s);return t.set(e.file.data.subarray(i,i+o),n),o}write(e,t,n,s,i){var o;if(s<=0||e.file===void 0)return 0;let a=Date.now();if(e.node.timestamp=a,e.node.atime=a,e.node.mtime=a,e.node.ctime=a,i+s>(((o=e.file)===null||o===void 0?void 0:o.data.length)||0)){let h=e.file.data?e.file.data:new Uint8Array;e.file.data=new Uint8Array(i+s),e.file.data.set(h)}return e.file.data.set(t.subarray(n,n+s),i),s}llseek(e,t,n){var s;let i=t;if(n===1)i+=(s=e.position)!==null&&s!==void 0?s:e.shared.position;else if(n===2&&this.fs.FS.isFile(e.node.mode))if(e.file!==void 0)i+=e.file.data.length;else throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM);if(i<0)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EINVAL);return i}},Kn=class{constructor(e){this.node=t=>Lo(t)?t.node:t,this.getattr=t=>{let n=this.node(t);return{...this.fs.API.getattr(this.fs.realPath(n)),mode:n.mode,ino:n.id}},this.setattr=(t,n)=>{let s=this.node(t);for(let[i,o]of Object.entries(n))switch(i){case"mode":s.mode=o;break;case"timestamp":s.timestamp=o;break;case"atime":s.atime=o;break;case"mtime":s.mtime=o;break;case"ctime":s.ctime=o;break;case"size":{let a=o,h=this.fs.realPath(s);if(this.fs.FS.isFile(s.mode)&&a>=0){let c;try{c=this.fs.API.get(h)}catch{break}let u=c.data?c.data:new Uint8Array;a!==u.length&&(a<u.length?c.data=c.data.slice(0,a):(c.data=new Uint8Array(a),c.data.set(u)),this.fs.API.put(h,c))}else console.warn("setattr size of",a,"on",s,"not yet implemented");break}case"dontFollow":break;default:console.warn("setattr",i,"of",o,"on",s,"not yet implemented");break}},this.lookup=(t,n)=>{let s=this.node(t),i=this.fs.PATH.join2(this.fs.realPath(s),n),o=this.fs.API.lookup(i);if(!o.ok)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.ENOENT);return this.fs.createNode(s,n,o.mode,0)},this.mknod=(t,n,s,i)=>{let o=this.node(t),a=this.fs.PATH.join2(this.fs.realPath(o),n);return this.fs.API.mknod(a,s),this.fs.createNode(o,n,s,i)},this.rename=(t,n,s)=>{let i=this.node(t),o=this.node(n);this.fs.API.rename(i.parent?this.fs.PATH.join2(this.fs.realPath(i.parent),i.name):i.name,this.fs.PATH.join2(this.fs.realPath(o),s)),i.name=s,i.parent=o},this.unlink=(t,n)=>this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(this.node(t)),n)),this.rmdir=(t,n)=>this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(this.node(t)),n)),this.readdir=t=>this.fs.API.readdir(this.fs.realPath(this.node(t))),this.symlink=(t,n,s)=>{throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM)},this.readlink=t=>{throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EINVAL)},this.fs=e}},zn=class{constructor(e){this._driveName=e.driveName,this._mountpoint=e.mountpoint,this.FS=e.FS,this.ERRNO_CODES=e.ERRNO_CODES}lookup(e){return this.request({method:"lookup",path:this.normalizePath(e)})}getmode(e){return this.request({method:"getmode",path:this.normalizePath(e)})}mknod(e,t){return this.request({method:"mknod",path:this.normalizePath(e),data:{mode:t}})}rename(e,t){return this.request({method:"rename",path:this.normalizePath(e),data:{newPath:this.normalizePath(t)}})}readdir(e){let t=this.request({method:"readdir",path:this.normalizePath(e)});return t.push("."),t.push(".."),t}rmdir(e){return this.request({method:"rmdir",path:this.normalizePath(e)})}get(e){let t=this.request({method:"get",path:this.normalizePath(e)});if(!t)throw new this.FS.ErrnoError(this.ERRNO_CODES.ENOENT);let n=t.content,s=t.format;switch(s){case"json":case"text":return{data:Ou.encode(n),format:s};case"base64":{let i=atob(n),o=i.length,a=new Uint8Array(o);for(let h=0;h<o;h++)a[h]=i.charCodeAt(h);return{data:a,format:s}}default:throw new this.FS.ErrnoError(this.ERRNO_CODES.ENOENT)}}put(e,t){switch(t.format){case"json":case"text":return this.request({method:"put",path:this.normalizePath(e),data:{format:t.format,data:Ru.decode(t.data)}});case"base64":{let n="";for(let s=0;s<t.data.byteLength;s++)n+=String.fromCharCode(t.data[s]);return this.request({method:"put",path:this.normalizePath(e),data:{format:t.format,data:btoa(n)}})}}}getattr(e){let t=this.request({method:"getattr",path:this.normalizePath(e)}),n=new Date(0);return t.atime=t.atime?new Date(t.atime):n,t.mtime=t.mtime?new Date(t.mtime):n,t.ctime=t.ctime?new Date(t.ctime):n,t.size=t.size||0,t}normalizePath(e){return e.startsWith(this._mountpoint)&&(e=e.slice(this._mountpoint.length)),this._driveName&&(e=`${this._driveName}${Ko}${e}`),e}},Vn=class extends zn{constructor(e){super(e),this._baseUrl=e.baseUrl,this._browsingContextId=e.browsingContextId||""}request(e){let t=new XMLHttpRequest;t.open("POST",encodeURI(this.endpoint),!1);let n=Fo.UUID.uuid4(),s={data:{...e,requestId:n},browsingContextId:this._browsingContextId,requestId:n};try{t.send(JSON.stringify(s))}catch(i){console.error(i)}if(t.status>=400)throw new this.FS.ErrnoError(this.ERRNO_CODES.EINVAL);return JSON.parse(t.responseText)}get endpoint(){return`${this._baseUrl}api/drive`}},Tt=class{constructor(e){this.FS=e.FS,this.PATH=e.PATH,this.ERRNO_CODES=e.ERRNO_CODES,this.API=this.createAPI(e),this.driveName=e.driveName,this.node_ops=new Kn(this),this.stream_ops=new Fn(this)}createAPI(e){if(!e.browsingContextId||!e.baseUrl)throw new Error("Cannot create service-worker API without current browsingContextId");return new Vn(e)}mount(e){return this.createNode(null,e.mountpoint,16895,0)}createNode(e,t,n,s){let i=this.FS;if(!i.isDir(n)&&!i.isFile(n))throw new i.ErrnoError(this.ERRNO_CODES.EINVAL);let o=i.createNode(e,t,n,s);return o.node_ops=this.node_ops,o.stream_ops=this.stream_ops,o}getMode(e){return this.API.getmode(e)}realPath(e){let t=[],n=e;for(t.push(n.name);n.parent!==n;)n=n.parent,t.push(n.name);return t.reverse(),this.PATH.join.apply(null,t)}}});var lr=Symbol("Comlink.proxy"),ia=Symbol("Comlink.endpoint"),oa=Symbol("Comlink.releaseProxy"),Hn=Symbol("Comlink.finalizer"),jt=Symbol("Comlink.thrown"),cr=r=>typeof r=="object"&&r!==null||typeof r=="function",aa={canHandle:r=>cr(r)&&r[lr],serialize(r){let{port1:e,port2:t}=new MessageChannel;return Lt(r,e),[t,[t]]},deserialize(r){return r.start(),ha(r)}},la={canHandle:r=>cr(r)&&jt in r,serialize({value:r}){let e;return r instanceof Error?e={isError:!0,value:{message:r.message,name:r.name,stack:r.stack}}:e={isError:!1,value:r},[e,[]]},deserialize(r){throw r.isError?Object.assign(new Error(r.value.message),r.value):r.value}},ur=new Map([["proxy",aa],["throw",la]]);function ca(r,e){for(let t of r)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function Lt(r,e=globalThis,t=["*"]){e.addEventListener("message",function n(s){if(!s||!s.data)return;if(!ca(t,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}let{id:i,type:o,path:a}=Object.assign({path:[]},s.data),h=(s.data.argumentList||[]).map(He),c;try{let u=a.slice(0,-1).reduce((d,m)=>d[m],r),l=a.reduce((d,m)=>d[m],r);switch(o){case"GET":c=l;break;case"SET":u[a.slice(-1)[0]]=He(s.data.value),c=!0;break;case"APPLY":c=l.apply(u,h);break;case"CONSTRUCT":{let d=new l(...h);c=pa(d)}break;case"ENDPOINT":{let{port1:d,port2:m}=new MessageChannel;Lt(r,m),c=ga(d,[d])}break;case"RELEASE":c=void 0;break;default:return}}catch(u){c={value:u,[jt]:0}}Promise.resolve(c).catch(u=>({value:u,[jt]:0})).then(u=>{let[l,d]=Nt(u);e.postMessage(Object.assign(Object.assign({},l),{id:i}),d),o==="RELEASE"&&(e.removeEventListener("message",n),hr(e),Hn in r&&typeof r[Hn]=="function"&&r[Hn]())}).catch(u=>{let[l,d]=Nt({value:new TypeError("Unserializable return value"),[jt]:0});e.postMessage(Object.assign(Object.assign({},l),{id:i}),d)})}),e.start&&e.start()}function ua(r){return r.constructor.name==="MessagePort"}function hr(r){ua(r)&&r.close()}function ha(r,e){let t=new Map;return r.addEventListener("message",function(s){let{data:i}=s;if(!i||!i.id)return;let o=t.get(i.id);if(o)try{o(i)}finally{t.delete(i.id)}}),Jn(r,t,[],e)}function qt(r){if(r)throw new Error("Proxy has been released and is not useable")}function dr(r){return Ye(r,new Map,{type:"RELEASE"}).then(()=>{hr(r)})}var Ut=new WeakMap,At="FinalizationRegistry"in globalThis&&new FinalizationRegistry(r=>{let e=(Ut.get(r)||0)-1;Ut.set(r,e),e===0&&dr(r)});function da(r,e){let t=(Ut.get(e)||0)+1;Ut.set(e,t),At&&At.register(r,e,r)}function fa(r){At&&At.unregister(r)}function Jn(r,e,t=[],n=function(){}){let s=!1,i=new Proxy(n,{get(o,a){if(qt(s),a===oa)return()=>{fa(i),dr(r),e.clear(),s=!0};if(a==="then"){if(t.length===0)return{then:()=>i};let h=Ye(r,e,{type:"GET",path:t.map(c=>c.toString())}).then(He);return h.then.bind(h)}return Jn(r,e,[...t,a])},set(o,a,h){qt(s);let[c,u]=Nt(h);return Ye(r,e,{type:"SET",path:[...t,a].map(l=>l.toString()),value:c},u).then(He)},apply(o,a,h){qt(s);let c=t[t.length-1];if(c===ia)return Ye(r,e,{type:"ENDPOINT"}).then(He);if(c==="bind")return Jn(r,e,t.slice(0,-1));let[u,l]=ar(h);return Ye(r,e,{type:"APPLY",path:t.map(d=>d.toString()),argumentList:u},l).then(He)},construct(o,a){qt(s);let[h,c]=ar(a);return Ye(r,e,{type:"CONSTRUCT",path:t.map(u=>u.toString()),argumentList:h},c).then(He)}});return da(i,r),i}function _a(r){return Array.prototype.concat.apply([],r)}function ar(r){let e=r.map(Nt);return[e.map(t=>t[0]),_a(e.map(t=>t[1]))]}var fr=new WeakMap;function ga(r,e){return fr.set(r,e),r}function pa(r){return Object.assign(r,{[lr]:!0})}function Nt(r){for(let[e,t]of ur)if(t.canHandle(r)){let[n,s]=t.serialize(r);return[{type:"HANDLER",name:e,value:n},s]}return[{type:"RAW",value:r},fr.get(r)||[]]}function He(r){switch(r.type){case"HANDLER":return ur.get(r.name).deserialize(r.value);case"RAW":return r.value}}function Ye(r,e,t,n){return new Promise(s=>{let i=ma();e.set(i,s),r.start&&r.start(),r.postMessage(Object.assign({id:i},t),n)})}function ma(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var Vo=Wn(te()),Bo=Wn(Ae());rr();var Bn=class{constructor(){this._options=null;this._initializer=null;this._pyodide=null;this._localPath="";this._driveName="";this._driveFS=null;this._sendWorkerMessage=()=>{};this._logMessage=()=>{};this._initialized=new Promise((e,t)=>{this._initializer={resolve:e,reject:t}})}async initialize(e){var t;if(this._options=e,e.location.includes(":")){let n=e.location.split(":");this._driveName=n[0],this._localPath=n[1]}else this._driveName="",this._localPath=e.location;await this.initRuntime(e),await this.initFilesystem(e),await this.initPackageManager(e),await this.initKernel(e),await this.initGlobals(e),(t=this._initializer)==null||t.resolve()}async initRuntime(e){let{pyodideUrl:t,indexUrl:n}=e,s;t.endsWith(".mjs")?s=(await import(t)).loadPyodide:(importScripts(t),s=self.loadPyodide),this._pyodide=await s({indexURL:n,stdout:i=>{console.log(i),this._logMessage({type:"text",level:"info",data:i})},stderr:i=>{console.error(i),this._logMessage({type:"text",level:"critical",data:i})},...e.loadPyodideOptions}),this._pyodide._api.on_fatal=async i=>{let o="";i.name==="Exit"?o="Pyodide has exited and can no longer be used.":o=`Pyodide has suffered a fatal error. Please report this to the Pyodide maintainers.
|
|
10
|
+
The cause of the error was: ${i.name}
|
|
11
|
+
${i.message}
|
|
12
12
|
Stack trace:
|
|
13
|
-
${
|
|
13
|
+
${i.stack}`,this._logMessage({type:"text",level:"critical",data:o})}}async initPackageManager(e){if(!this._options)throw new Error("Uninitialized");let{pipliteWheelUrl:t,disablePyPIFallback:n,pipliteUrls:s,loadPyodideOptions:i}=this._options,o=(i||{}).packages||[];o.includes("micropip")||await this._pyodide.loadPackage(["micropip"]),o.includes("piplite")||await this._pyodide.runPythonAsync(`
|
|
14
14
|
import micropip
|
|
15
15
|
await micropip.install('${t}', keep_going=True)
|
|
16
16
|
`),await this._pyodide.runPythonAsync(`
|
|
17
17
|
import piplite.piplite
|
|
18
|
-
piplite.piplite._PIPLITE_DISABLE_PYPI = ${
|
|
19
|
-
piplite.piplite._PIPLITE_URLS = ${JSON.stringify(
|
|
20
|
-
`)}async initKernel(e){let t=(e.loadPyodideOptions||{}).packages||[],
|
|
21
|
-
`))}async initGlobals(e){let{globals:t}=this._pyodide;this._kernel=t.get("pyodide_kernel").kernel_instance.copy(),this._stdout_stream=t.get("pyodide_kernel").stdout_stream.copy(),this._stderr_stream=t.get("pyodide_kernel").stderr_stream.copy(),this._interpreter=this._kernel.interpreter.copy(),this._interpreter.send_comm=this.sendComm.bind(this)}async initFilesystem(e){if(e.mountDrive){let t="/drive",{FS:
|
|
18
|
+
piplite.piplite._PIPLITE_DISABLE_PYPI = ${n?"True":"False"}
|
|
19
|
+
piplite.piplite._PIPLITE_URLS = ${JSON.stringify(s)}
|
|
20
|
+
`)}async initKernel(e){let t=(e.loadPyodideOptions||{}).packages||[],n=["sqlite3","ipykernel","comm","pyodide_kernel","jedi","ipython"],s=[];for(let i of n)t.includes(i)||s.push(`await piplite.install('${i}', keep_going=True)`);s.push("import pyodide_kernel"),e.mountDrive&&this._localPath&&s.push("import os",`os.chdir("${this._localPath}")`),await this._pyodide.runPythonAsync(s.join(`
|
|
21
|
+
`))}async initGlobals(e){let{globals:t}=this._pyodide;this._kernel=t.get("pyodide_kernel").kernel_instance.copy(),this._stdout_stream=t.get("pyodide_kernel").stdout_stream.copy(),this._stderr_stream=t.get("pyodide_kernel").stderr_stream.copy(),this._interpreter=this._kernel.interpreter.copy(),this._interpreter.send_comm=this.sendComm.bind(this)}async initFilesystem(e){if(e.mountDrive){let t="/drive",{FS:n,PATH:s,ERRNO_CODES:i}=this._pyodide,{baseUrl:o}=e,{DriveFS:a}=await Promise.resolve().then(()=>(rr(),zo)),h=new a({FS:n,PATH:s,ERRNO_CODES:i,baseUrl:o,driveName:this._driveName,mountpoint:t,browsingContextId:this._browsingContextId});n.mkdirTree(t),n.mount(h,{},t),n.chdir(t),this._driveFS=h}}mapToObject(e){let t=e instanceof Array?[]:{},n=e instanceof Map?e.entries():Object.entries(e);for(let[s,i]of n)t[s]=i instanceof Map||i instanceof Array?this.mapToObject(i):i;return t}formatResult(e){if(!(e instanceof this._pyodide.ffi.PyProxy))return e;let t=e.toJs();return this.mapToObject(t)}registerWorkerMessageCallback(e){this._sendWorkerMessage=e}registerLogMessageCallback(e){this._logMessage=e}async setup(e){await this._initialized,this._kernel._parent_header=this._pyodide.toPy(e)}async execute(e,t){await this.setup(t);let n=(l,d,m)=>{let v={execution_count:l,data:this.formatResult(d),metadata:this.formatResult(m)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:v,type:"execute_result"})},s=(l,d,m)=>{let v={ename:l,evalue:d,traceback:m};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:v,type:"execute_error"})},i=l=>{let d={wait:this.formatResult(l)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:d,type:"clear_output"})},o=(l,d,m)=>{let v={data:this.formatResult(l),metadata:this.formatResult(d),transient:this.formatResult(m)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:v,type:"display_data"})},a=(l,d,m)=>{let v={data:this.formatResult(l),metadata:this.formatResult(d),transient:this.formatResult(m)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:v,type:"update_display_data"})},h=(l,d)=>{let m={name:this.formatResult(l),text:this.formatResult(d)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:m,type:"stream"})};this._stdout_stream.publish_stream_callback=h,this._stderr_stream.publish_stream_callback=h,this._interpreter.display_pub.clear_output_callback=i,this._interpreter.display_pub.display_data_callback=o,this._interpreter.display_pub.update_display_data_callback=a,this._interpreter.displayhook.publish_execution_result=n,this._interpreter.input=this.input.bind(this),this._interpreter.getpass=this.getpass.bind(this);let c=await this._kernel.run(e.code),u=this.formatResult(c);return u.status==="error"&&s(u.ename,u.evalue,u.traceback),u}async complete(e,t){await this.setup(t);let n=this._kernel.complete(e.code,e.cursor_pos);return this.formatResult(n)}async inspect(e,t){await this.setup(t);let n=this._kernel.inspect(e.code,e.cursor_pos,e.detail_level);return this.formatResult(n)}async isComplete(e,t){await this.setup(t);let n=this._kernel.is_complete(e.code);return this.formatResult(n)}async commInfo(e,t){await this.setup(t);let n=this._kernel.comm_info(e.target_name);return{comms:this.formatResult(n),status:"ok"}}async commOpen(e,t){await this.setup(t);let n=this._kernel.comm_manager.comm_open(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(e));return this.formatResult(n)}async commMsg(e,t){await this.setup(t);let n=this._kernel.comm_manager.comm_msg(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(e));return this.formatResult(n)}async commClose(e,t){await this.setup(t);let n=this._kernel.comm_manager.comm_close(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(e));return this.formatResult(n)}async inputReply(e,t){}getpass(e){return e=typeof e=="undefined"?"":e,this.sendInputRequest(e,!0)}input(e){return e=typeof e=="undefined"?"":e,this.sendInputRequest(e,!1)}async sendComm(e,t,n,s,i){this._sendWorkerMessage({type:e,content:this.formatResult(t),metadata:this.formatResult(n),ident:this.formatResult(s),buffers:this.formatResult(i),parentHeader:this.formatResult(this._kernel._parent_header).header})}};var ir=class extends Bn{constructor(){super(),this._sendWorkerMessage=e=>{postMessage({_kernelMessage:e})},this._logMessage=e=>{postMessage({_logMessage:e})}}async initFilesystem(e){if(e.mountDrive){let t="/drive",{FS:n,PATH:s,ERRNO_CODES:i}=this._pyodide,{baseUrl:o,browsingContextId:a}=e,h=new Tt({FS:n,PATH:s,ERRNO_CODES:i,baseUrl:o,driveName:this._driveName,mountpoint:t,browsingContextId:a});n.mkdirTree(t),n.mount(h,{},t),n.chdir(t),this._driveFS=h}}sendInputRequest(e,t){var i,o;let n=this.formatResult(this._kernel._parent_header).header,s=Bo.KernelMessage.createMessage({channel:"stdin",msgType:"input_request",session:(i=n==null?void 0:n.session)!=null?i:"",parentHeader:n,content:{prompt:e,password:t}});try{if(!this._options)throw new Error("Kernel options not set");let{baseUrl:a,browsingContextId:h}=this._options;if(!h)throw new Error("Kernel browsingContextId not set");let c=new XMLHttpRequest,u=Vo.URLExt.join(a,"/api/stdin/kernel");c.open("POST",u,!1);let l=JSON.stringify({browsingContextId:h,data:s});c.send(l);let d=JSON.parse(c.response);if("error"in d)throw new Error(d.error);return(o=d.content)==null?void 0:o.value}catch(a){console.warn(`Failed to request stdin via service worker: ${a}`);return}}},ku=new ir;Lt(ku);export{ir as PyodideComlinkKernel};
|
|
22
22
|
/*! Bundled license information:
|
|
23
23
|
|
|
24
24
|
comlink/dist/esm/comlink.mjs:
|