@jupyterlite/pyodide-kernel 0.7.0-rc.1 → 0.8.0-alpha.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/comlink.worker.js +11 -11
- package/lib/comlink.worker.js.map +4 -4
- package/package.json +6 -6
- package/pypi/all.json +35 -35
- package/pypi/ipykernel-6.9.2-py3-none-any.whl +0 -0
- package/pypi/{piplite-0.7.0rc1-py3-none-any.whl → piplite-0.8.0a0-py3-none-any.whl} +0 -0
- package/pypi/{pyodide_kernel-0.7.0rc1-py3-none-any.whl → pyodide_kernel-0.8.0a0-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/schema/piplite.v0.schema.json +1 -1
package/lib/comlink.worker.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
var Ho=Object.create;var Bn=Object.defineProperty;var Jo=Object.getOwnPropertyDescriptor;var Go=Object.getOwnPropertyNames;var Xo=Object.getPrototypeOf,Yo=Object.prototype.hasOwnProperty;var sr=(n,e)=>()=>(n&&(e=n(n=0)),e);var R=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Qo=(n,e)=>{for(var t in e)Bn(n,t,{get:e[t],enumerable:!0})},Zo=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Go(e))!Yo.call(n,r)&&r!==t&&Bn(n,r,{get:()=>e[r],enumerable:!(s=Jo(e,r))||s.enumerable});return n};var Wn=(n,e,t)=>(t=n!=null?Ho(Xo(n)):{},Zo(e||!n||!n.__esModule?Bn(t,"default",{value:n,enumerable:!0}):t,n));var Jn=R((Lt,hr)=>{(function(n,e){typeof Lt=="object"&&typeof hr!="undefined"?e(Lt):typeof define=="function"&&define.amd?define(["exports"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_algorithm={}))})(Lt,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 Q(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=Q;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 Me(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=Me;function Fo(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=Fo;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 Ko(S,M,p=0,_=-1){let g=y(S,M,p,_);return g!==-1&&ot(S,g),g}f.removeFirstOf=Ko;function zo(S,M,p=-1,_=0){let g=b(S,M,p,_);return g!==-1&&ot(S,g),g}f.removeLastOf=zo;function Vo(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=Vo;function Bo(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=Bo;function Wo(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=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<=_&&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=$o}(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*r(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 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=j.rangeLength(f,y,b);for(let x=0;x<P;x++)yield f+b*x}var j;(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})(j||(j={}));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*T(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 Q=0,G=X,ue=K.length;Q<ue;++Q,++G){if(G=F.indexOf(K[Q],G),G===-1)return null;B[Q]=G}return B}f.findIndices=y;function b(F,K,X=0){let B=y(F,K,X);if(!B)return null;let Q=0;for(let G=0,ue=B.length;G<ue;++G){let Ce=B[G]-X;Q+=Ce*Ce}return{score:Q,indices:B}}f.matchSumOfSquares=b;function P(F,K,X=0){let B=y(F,K,X);if(!B)return null;let Q=0,G=X-1;for(let ue=0,Ce=B.length;ue<Ce;++ue){let Me=B[ue];Q+=Me-G-1,G=Me}return{score:Q,indices:B}}f.matchSumOfDeltas=P;function x(F,K,X){let B=[],Q=0,G=0,ue=K.length;for(;Q<ue;){let Ce=K[Q],Me=K[Q];for(;++Q<ue&&K[Q]===Me+1;)Me++;G<Ce&&B.push(F.slice(G,Ce)),Ce<Me+1&&B.push(X(F.slice(Ce,Me+1))),G=Me+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=d,n.empty=t,n.enumerate=s,n.every=v,n.filter=r,n.find=i,n.findIndex=o,n.map=q,n.max=h,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=T,n.take=D,n.toArray=u,n.toObject=l,n.topologicSort=N,n.zip=U})});var Z=R((xt,dr)=>{(function(n,e){typeof xt=="object"&&typeof dr!="undefined"?e(xt,Jn()):typeof define=="function"&&define.amd?define(["exports","@lumino/algorithm"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_coreutils={},n.lumino_algorithm))})(xt,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 d(C){return!u(C)&&!l(C)}c.isObject=d;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)?j(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],T=w[k];if(!(N===void 0&&T===void 0)&&(N===void 0||T===void 0||!v(N,T)))return!1}return!0}function j(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,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=r.createPluginData(u);r.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(m=>this.resolveRequiredService(m)),v=l.optional.map(m=>this.resolveOptionalService(m));return l.promise=Promise.all([...d,...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 d=this.deferredPlugins.filter(v=>this._plugins.get(v).autoStart).map(v=>this.activatePlugin(v));await Promise.all(d);break}case"startUp":{let v=r.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 d=r.findDependents(u,this._plugins,this._services),v=d.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 j=this._services.get(I);return j?this._plugins.get(j).service:null});await m.deactivate(this.application,...q),m.service=null,m.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(v){return console.error(v),null}return d.service}}var r;(function(c){class u{constructor(I){var j,A,C,w;this._activated=!1,this._promise=null,this._service=null,this.id=I.id,this.description=(j=I.description)!==null&&j!==void 0?j:"",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 d(q,I,j){let A=[...q.requires,...q.optional],C=k=>{if(k===q.provides)return!0;let N=j.get(k);if(!N)return!1;let T=I.get(N),D=[...T.requires,...T.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=d;function v(q,I,j){let A=new Array,C=D=>{let U=I.get(D),f=[...U.requires,...U.optional];A.push(...f.reduce((y,b)=>{let P=j.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),T=N.findIndex(D=>D===q);return T===-1?[q]:N.slice(0,T+1)}c.findDependents=v;function m(q,I){let j=new Set;for(let A of q.keys())q.get(A).autoStart===!0&&j.add(A);if(I.startPlugins)for(let A of I.startPlugins)j.add(A);if(I.ignorePlugins)for(let A of I.ignorePlugins)j.delete(A);return Array.from(j)}c.collectStartupPlugins=m})(r||(r={}));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}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(d){return u.getRandomValues(d)}:a})()}(n.Random||(n.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]]}}n.UUID=void 0,function(c){c.uuid4=h(n.Random.getRandomValues)}(n.UUID||(n.UUID={})),n.MimeData=t,n.PluginRegistry=s,n.PromiseDelegate=i,n.Token=o})});var ee=R((Ft,fr)=>{(function(n,e){typeof Ft=="object"&&typeof fr!="undefined"?e(Ft,Jn(),Z()):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))})(Ft,function(n,e,t){"use strict";class s{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(m,q){i.disconnectBetween(m,q)}o.disconnectBetween=a;function h(m){i.disconnectSender(m)}o.disconnectSender=h;function c(m){i.disconnectReceiver(m)}o.disconnectReceiver=c;function u(m){i.disconnectAll(m)}o.disconnectAll=u;function l(m){i.disconnectAll(m)}o.clearData=l;function d(){return i.exceptionHandler}o.getExceptionHandler=d;function v(m){let q=i.exceptionHandler;return i.exceptionHandler=m,q}o.setExceptionHandler=v})(s||(s={}));class r extends s{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=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 h(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=h;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 d(D){u(D),l(D)}o.disconnectAll=d;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,j=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&&j(k),I.add(D)}function k(){I.forEach(N),I.clear()}function N(D){e.ArrayExt.removeAllWhere(D,T)}function T(D){return D.signal===null}})(i||(i={})),n.Signal=s,n.Stream=r})});var pr=R(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.ActivityMonitor=void 0;var _r=ee(),Gn=class{constructor(e){this._timer=-1,this._timeout=-1,this._isDisposed=!1,this._activityStopped=new _r.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,_r.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)}};Kt.ActivityMonitor=Gn});var mr=R(gr=>{"use strict";Object.defineProperty(gr,"__esModule",{value:!0})});var vr=R(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.LruCache=void 0;var fa=128,Xn=class{constructor(e={}){this._map=new Map,this._maxSize=(e==null?void 0:e.maxSize)||fa}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)}};zt.LruCache=Xn});var wr=R(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.MarkdownCodeBlocks=void 0;var yr;(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(i){return e.indexOf(i)>-1}n.isMarkdown=s;function r(i){if(!i||i==="")return[];let o=i.split(`
|
|
2
|
-
`),a=[],
|
|
3
|
-
`);else{h=new t(c);let v=u.indexOf(n.CODE_BLOCK_MARKER),m=u.lastIndexOf(n.CODE_BLOCK_MARKER);v!==m&&(h.code=u.substring(v+n.CODE_BLOCK_MARKER.length,m),h.endLine=c,a.push(h),h=null)}}return a}n.findMarkdownCodeBlocks=r})(yr||(Vt.MarkdownCodeBlocks=yr={}))});var Pr=R((qu,Cr)=>{"use strict";function _a(n,e){var t=n;e.slice(0,-1).forEach(function(r){t=t[r]||{}});var s=e[e.length-1];return s in t}function Sr(n){return typeof n=="number"||/^0x[0-9a-f]+$/i.test(n)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(n)}function br(n,e){return e==="constructor"&&typeof n[e]=="function"||e==="__proto__"}Cr.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 r(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 i=e.default||{},o={_:[]};function a(w,k){return t.allBools&&/^--[^=]+$/.test(k)||t.strings[w]||t.bools[w]||s[w]}function h(w,k,N){for(var T=w,D=0;D<k.length-1;D++){var U=k[D];if(br(T,U))return;T[U]===void 0&&(T[U]={}),(T[U]===Object.prototype||T[U]===Number.prototype||T[U]===String.prototype)&&(T[U]={}),T[U]===Array.prototype&&(T[U]=[]),T=T[U]}var f=k[k.length-1];br(T,f)||((T===Object.prototype||T===Number.prototype||T===String.prototype)&&(T={}),T===Array.prototype&&(T=[]),T[f]===void 0||t.bools[f]||typeof T[f]=="boolean"?T[f]=N:Array.isArray(T[f])?T[f].push(N):T[f]=[T[f],N])}function c(w,k,N){if(!(N&&t.unknownFn&&!a(w,N)&&t.unknownFn(N)===!1)){var T=!t.strings[w]&&Sr(k)?Number(k):k;h(o,w.split("."),T),(s[w]||[]).forEach(function(D){h(o,D.split("."),T)})}}Object.keys(t.bools).forEach(function(w){c(w,i[w]===void 0?!1:i[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 d=n[l],v,m;if(/^--.+=/.test(d)){var q=d.match(/^--([^=]+)=([\s\S]*)$/);v=q[1];var I=q[2];t.bools[v]&&(I=I!=="false"),c(v,I,d)}else if(/^--no-.+/.test(d))v=d.match(/^--no-(.+)/)[1],c(v,!1,d);else if(/^--.+/.test(d))v=d.match(/^--(.+)/)[1],m=n[l+1],m!==void 0&&!/^(-|--)[^-]/.test(m)&&!t.bools[v]&&!t.allBools&&(!s[v]||!r(v))?(c(v,m,d),l+=1):/^(true|false)$/.test(m)?(c(v,m==="true",d),l+=1):c(v,t.strings[v]?"":!0,d);else if(/^-[^-]+/.test(d)){for(var j=d.slice(1,-1).split(""),A=!1,C=0;C<j.length;C++){if(m=d.slice(C+2),m==="-"){c(j[C],m,d);continue}if(/[A-Za-z]/.test(j[C])&&m[0]==="="){c(j[C],m.slice(1),d),A=!0;break}if(/[A-Za-z]/.test(j[C])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(m)){c(j[C],m,d),A=!0;break}if(j[C+1]&&j[C+1].match(/\W/)){c(j[C],d.slice(C+2),d),A=!0;break}else c(j[C],t.strings[j[C]]?"":!0,d)}v=d.slice(-1)[0],!A&&v!=="-"&&(n[l+1]&&!/^(-|--)[^-]/.test(n[l+1])&&!t.bools[v]&&(!s[v]||!r(v))?(c(v,n[l+1],d),l+=1):n[l+1]&&/^(true|false)$/.test(n[l+1])?(c(v,n[l+1]==="true",d),l+=1):c(v,t.strings[v]?"":!0,d))}else if((!t.unknownFn||t.unknownFn(d)!==!1)&&o._.push(t.strings._||!Sr(d)?d:Number(d)),e.stopEarly){o._.push.apply(o._,n.slice(l+1));break}}return Object.keys(i).forEach(function(w){_a(o,w.split("."))||(h(o,w.split("."),i[w]),(s[w]||[]).forEach(function(k){h(o,k.split("."),i[w])}))}),e["--"]?o["--"]=u.slice():u.forEach(function(w){o._.push(w)}),o}});var Bt=R((ju,Er)=>{"use strict";function Ee(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}function Mr(n,e){for(var t="",s=0,r=-1,i=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(!(r===a-1||i===1))if(r!==a-1&&i===2){if(t.length<2||s!==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="",s=0):(t=t.slice(0,h),s=t.length-1-t.lastIndexOf("/")),r=a,i=0;continue}}else if(t.length===2||t.length===1){t="",s=0,r=a,i=0;continue}}e&&(t.length>0?t+="/..":t="..",s=2)}else t.length>0?t+="/"+n.slice(r+1,a):t=n.slice(r+1,a),s=a-r-1;r=a,i=0}else o===46&&i!==-1?++i:i=-1}return t}function pa(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,r=arguments.length-1;r>=-1&&!t;r--){var i;r>=0?i=arguments[r]:(s===void 0&&(s=process.cwd()),i=s),Ee(i),i.length!==0&&(e=i+"/"+e,t=i.charCodeAt(0)===47)}return e=Mr(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(Ee(e),e.length===0)return".";var t=e.charCodeAt(0)===47,s=e.charCodeAt(e.length-1)===47;return e=Mr(e,!t),e.length===0&&!t&&(e="."),e.length>0&&s&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return Ee(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];Ee(s),s.length>0&&(e===void 0?e=s:e+="/"+s)}return e===void 0?".":Ye.normalize(e)},relative:function(e,t){if(Ee(e),Ee(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 r=e.length,i=r-s,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(s+l)===47?u=l:l===0&&(u=0));break}var d=e.charCodeAt(s+l),v=t.charCodeAt(o+l);if(d!==v)break;d===47&&(u=l)}var m="";for(l=s+u+1;l<=r;++l)(l===r||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(Ee(e),e.length===0)return".";for(var t=e.charCodeAt(0),s=t===47,r=-1,i=!0,o=e.length-1;o>=1;--o)if(t=e.charCodeAt(o),t===47){if(!i){r=o;break}}else i=!1;return r===-1?s?"/":".":s&&r===1?"//":e.slice(0,r)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ee(e);var s=0,r=-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){s=o+1;break}}else h===-1&&(i=!1,h=o+1),a>=0&&(c===t.charCodeAt(a)?--a===-1&&(r=o):(a=-1,r=h))}return s===r?r=h:r===-1&&(r=e.length),e.slice(s,r)}else{for(o=e.length-1;o>=0;--o)if(e.charCodeAt(o)===47){if(!i){s=o+1;break}}else r===-1&&(i=!1,r=o+1);return r===-1?"":e.slice(s,r)}},extname:function(e){Ee(e);for(var t=-1,s=0,r=-1,i=!0,o=0,a=e.length-1;a>=0;--a){var h=e.charCodeAt(a);if(h===47){if(!i){s=a+1;break}continue}r===-1&&(i=!1,r=a+1),h===46?t===-1?t=a:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||r===-1||o===0||o===1&&t===r-1&&t===s+1?"":e.slice(t,r)},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 pa("/",e)},parse:function(e){Ee(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var s=e.charCodeAt(0),r=s===47,i;r?(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(s=e.charCodeAt(u),s===47){if(!c){a=u+1;break}continue}h===-1&&(c=!1,h=u+1),s===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&&r?t.base=t.name=e.slice(1,h):t.base=t.name=e.slice(a,h)):(a===0&&r?(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):r&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};Ye.posix=Ye;Er.exports=Ye});var Rr=R((Tu,Ir)=>{"use strict";Ir.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 Dr=R(Yn=>{"use strict";var ga=Object.prototype.hasOwnProperty,ma;function kr(n){try{return decodeURIComponent(n.replace(/\+/g," "))}catch{return null}}function Or(n){try{return encodeURIComponent(n)}catch{return null}}function va(n){for(var e=/([^=?#&]+)=?([^&]*)/g,t={},s;s=e.exec(n);){var r=kr(s[1]),i=kr(s[2]);r===null||i===null||r in t||(t[r]=i)}return t}function ya(n,e){e=e||"";var t=[],s,r;typeof e!="string"&&(e="?");for(r in n)if(ga.call(n,r)){if(s=n[r],!s&&(s===null||s===ma||isNaN(s))&&(s=""),r=Or(r),s=Or(s),r===null||s===null)continue;t.push(r+"="+s)}return t.length?e+t.join("&"):""}Yn.stringify=ya;Yn.parse=va});var xr=R((Au,Lr)=>{"use strict";var jr=Rr(),Wt=Dr(),wa=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,Tr=/[\n\r\t]/g,Sa=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,Ur=/:\d+$/,ba=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,Ca=/^[a-zA-Z]:/;function Zn(n){return(n||"").toString().replace(wa,"")}var Qn=[["#","hash"],["?","query"],function(e,t){return Ie(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]],qr={hash:1,query:1};function Ar(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={},r=typeof n,i;if(n.protocol==="blob:")s=new Re(unescape(n.pathname),{});else if(r==="string"){s=new Re(n,{});for(i in qr)delete s[i]}else if(r==="object"){for(i in n)i in qr||(s[i]=n[i]);s.slashes===void 0&&(s.slashes=Sa.test(n.href))}return s}function Ie(n){return n==="file:"||n==="ftp:"||n==="http:"||n==="https:"||n==="ws:"||n==="wss:"}function Nr(n,e){n=Zn(n),n=n.replace(Tr,""),e=e||{};var t=ba.exec(n),s=t[1]?t[1].toLowerCase():"",r=!!t[2],i=!!t[3],o=0,a;return r?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],s==="file:"?o>=2&&(a=a.slice(2)):Ie(s)?a=t[4]:s?r&&(a=a.slice(2)):o>=2&&Ie(e.protocol)&&(a=t[4]),{protocol:s,slashes:r||Ie(s),slashesCount:o,rest:a}}function Pa(n,e){if(n==="")return e;for(var t=(e||"/").split("/").slice(0,-1).concat(n.split("/")),s=t.length,r=t[s-1],i=!1,o=0;s--;)t[s]==="."?t.splice(s,1):t[s]===".."?(t.splice(s,1),o++):o&&(s===0&&(i=!0),t.splice(s,1),o--);return i&&t.unshift(""),(r==="."||r==="..")&&t.push(""),t.join("/")}function Re(n,e,t){if(n=Zn(n),n=n.replace(Tr,""),!(this instanceof Re))return new Re(n,e,t);var s,r,i,o,a,h,c=Qn.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=Ar(e),r=Nr(n||"",e),s=!r.protocol&&!r.slashes,l.slashes=r.slashes||s&&e.slashes,l.protocol=r.protocol||e.protocol||"",n=r.rest,(r.protocol==="file:"&&(r.slashesCount!==2||Ca.test(n))||!r.slashes&&(r.protocol||r.slashesCount<2||!Ie(l.protocol)))&&(c[3]=[/(.*)/,"pathname"]);d<c.length;d++){if(o=c[d],typeof o=="function"){n=o(n,l);continue}i=o[0],h=o[1],i!==i?l[h]=n:typeof i=="string"?(a=i==="@"?n.lastIndexOf(i):n.indexOf(i),~a&&(typeof o[2]=="number"?(l[h]=n.slice(0,a),n=n.slice(a+o[2])):(l[h]=n.slice(a),n=n.slice(0,a)))):(a=i.exec(n))&&(l[h]=a[1],n=n.slice(0,a.index)),l[h]=l[h]||s&&o[3]&&e[h]||"",o[4]&&(l[h]=l[h].toLowerCase())}t&&(l.query=t(l.query)),s&&e.slashes&&l.pathname.charAt(0)!=="/"&&(l.pathname!==""||e.pathname!=="")&&(l.pathname=Pa(l.pathname,e.pathname)),l.pathname.charAt(0)!=="/"&&Ie(l.protocol)&&(l.pathname="/"+l.pathname),jr(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:"&&Ie(l.protocol)&&l.host?l.protocol+"//"+l.host:"null",l.href=l.toString()}function Ma(n,e,t){var s=this;switch(n){case"query":typeof e=="string"&&e.length&&(e=(t||Wt.parse)(e)),s[n]=e;break;case"port":s[n]=e,jr(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,Ur.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 r=n==="pathname"?"/":"#";s[n]=e.charAt(0)!==r?r+e:e}else s[n]=e;break;case"username":case"password":s[n]=encodeURIComponent(e);break;case"auth":var i=e.indexOf(":");~i?(s.username=e.slice(0,i),s.username=encodeURIComponent(decodeURIComponent(s.username)),s.password=e.slice(i+1),s.password=encodeURIComponent(decodeURIComponent(s.password))):s.username=encodeURIComponent(decodeURIComponent(e))}for(var o=0;o<Qn.length;o++){var a=Qn[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:"&&Ie(s.protocol)&&s.host?s.protocol+"//"+s.host:"null",s.href=s.toString(),s}function Ea(n){(!n||typeof n!="function")&&(n=Wt.stringify);var e,t=this,s=t.host,r=t.protocol;r&&r.charAt(r.length-1)!==":"&&(r+=":");var i=r+(t.protocol&&t.slashes||Ie(t.protocol)?"//":"");return t.username?(i+=t.username,t.password&&(i+=":"+t.password),i+="@"):t.password?(i+=":"+t.password,i+="@"):t.protocol!=="file:"&&Ie(t.protocol)&&!s&&t.pathname!=="/"&&(i+="@"),(s[s.length-1]===":"||Ur.test(t.hostname)&&!t.port)&&(s+=":"),i+=s+t.pathname,e=typeof t.query=="object"?n(t.query):t.query,e&&(i+=e.charAt(0)!=="?"?"?"+e:e),t.hash&&(i+=t.hash),i}Re.prototype={set:Ma,toString:Ea};Re.extractProtocol=Nr;Re.location=Ar;Re.trimLeft=Zn;Re.qs=Wt;Lr.exports=Re});var es=R(Qe=>{"use strict";var Ia=Qe&&Qe.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Qe,"__esModule",{value:!0});Qe.URLExt=void 0;var Ra=Bt(),$t=Ia(xr()),Fr;(function(n){function e(c){if(typeof document!="undefined"&&document){let u=document.createElement("a");return u.href=c,u}return(0,$t.default)(c)}n.parse=e;function t(c){return(0,$t.default)(c).hostname}n.getHostName=t;function s(c){return c&&e(c).toString()}n.normalize=s;function r(...c){let u=(0,$t.default)(c[0],{}),l=u.protocol===""&&u.slashes;l&&(u=(0,$t.default)(c[0],"https:"+c[0]));let d=`${l?"":u.protocol}${u.slashes?"//":""}${u.auth}${u.auth?"@":""}${u.host}`,v=Ra.posix.join(`${d&&u.pathname[0]!=="/"?"/":""}${u.pathname}`,...c.slice(1));return`${d}${v==="."?"":v}`}n.join=r;function i(c){return r(...c.split("/").map(encodeURIComponent))}n.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("&"):""}n.objectToQueryString=o;function a(c){return c.replace(/^\?/,"").split("&").reduce((u,l)=>{let[d,v]=l.split("=");return d.length>0&&(u[d]=decodeURIComponent(v||"")),u},{})}n.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)}n.isLocal=h})(Fr||(Qe.URLExt=Fr={}))});var Kr=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=Z(),minimist_1=__importDefault(Pr()),url_1=es(),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=Bt(),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,r;let i=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"),h=o==="single-document"?"doc":"lab";i=url_1.URLExt.join(i,h),a!==PageConfig.defaultWorkspace&&(i=url_1.URLExt.join(i,"workspaces",encodeURIComponent((s=getOption("workspace"))!==null&&s!==void 0?s:PageConfig.defaultWorkspace)));let c=(r=n.treePath)!==null&&r!==void 0?r:getOption("treePath");return c&&(i=url_1.URLExt.join(i,"tree",url_1.URLExt.encodeParts(c))),i}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),r=url_1.URLExt.join(getBaseUrl(),"nbconvert",e,s);return t?r+"?download=true":r}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(r){try{let i=getOption(r);if(i)return JSON.parse(i)}catch(i){console.warn(`Unable to parse ${r}.`,i)}return[]}n.deferred=e("deferredExtensions"),n.disabled=e("disabledExtensions");function t(r){let i=r.indexOf(":"),o="";return i!==-1&&(o=r.slice(0,i)),n.deferred.some(a=>a===r||o&&a===o)}n.isDeferred=t;function s(r){let i=r.indexOf(":"),o="";return i!==-1&&(o=r.slice(0,i)),n.disabled.some(a=>a===r||o&&a===o)}n.isDisabled=s})(Extension=PageConfig.Extension||(PageConfig.Extension={}))})(PageConfig||(exports.PageConfig=PageConfig={}))});var Vr=R(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.PathExt=void 0;var Le=Bt(),zr;(function(n){function e(...l){let d=Le.posix.join(...l);return d==="."?"":u(d)}n.join=e;function t(...l){let d=Le.posix.join(...l);return d==="."?"":d}n.joinWithLeadingSlash=t;function s(l,d){return Le.posix.basename(l,d)}n.basename=s;function r(l){let d=u(Le.posix.dirname(l));return d==="."?"":d}n.dirname=r;function i(l){return Le.posix.extname(l)}n.extname=i;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 h(l,d){return u(Le.posix.relative(l,d))}n.relative=h;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})(zr||(Ht.PathExt=zr={}))});var Br=R(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.signalToPromise=Oa;var ka=Z();function Oa(n,e){let t=new ka.PromiseDelegate;function s(){n.disconnect(r)}function r(i,o){s(),t.resolve([i,o])}return n.connect(r),(e!=null?e:0)>0&&setTimeout(()=>{s(),t.reject(`Signal not emitted within ${e} ms.`)},e),t.promise}});var $r=R(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.Text=void 0;var Wr;(function(n){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}n.jsIndexToCharIndex=t;function s(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}n.charIndexToJsIndex=s;function r(o,a=!1){return o.replace(/^(\w)|[\s-_:]+(\w)/g,function(h,c,u){return u?u.toUpperCase():a?c.toUpperCase():c.toLowerCase()})}n.camelCase=r;function i(o){return(o||"").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}n.titleCase=i})(Wr||(Jt.Text=Wr={}))});var Jr=R(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.Time=void 0;var Da=[{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}],Hr;(function(n){function e(s,r="long"){let i=document.documentElement.lang||"en",o=new Intl.RelativeTimeFormat(i,{numeric:"auto",style:r}),a=new Date(s).getTime()-Date.now();for(let h of Da){let c=Math.ceil(a/h.milliseconds);if(c!==0)return o.format(c,h.name)}return o.format(0,"seconds")}n.formatHuman=e;function t(s){let r=document.documentElement.lang||"en";return new Intl.DateTimeFormat(r,{dateStyle:"short",timeStyle:"short"}).format(new Date(s))}n.format=t})(Hr||(Gt.Time=Hr={}))});var te=R(ae=>{"use strict";var qa=ae&&ae.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),ke=ae&&ae.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&qa(e,n,t)};Object.defineProperty(ae,"__esModule",{value:!0});ke(pr(),ae);ke(mr(),ae);ke(vr(),ae);ke(wr(),ae);ke(Kr(),ae);ke(Vr(),ae);ke(Br(),ae);ke($r(),ae);ke(Jr(),ae);ke(es(),ae)});var Ze=R(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.supportedKernelWebSocketProtocols=void 0;V.createMessage=Ta;V.isStreamMsg=Ua;V.isDisplayDataMsg=Aa;V.isUpdateDisplayDataMsg=Na;V.isExecuteInputMsg=La;V.isExecuteResultMsg=xa;V.isErrorMsg=Fa;V.isStatusMsg=Ka;V.isClearOutputMsg=za;V.isDebugEventMsg=Va;V.isCommOpenMsg=Ba;V.isCommCloseMsg=Wa;V.isCommMsgMsg=$a;V.isInfoRequestMsg=Ha;V.isExecuteReplyMsg=Ja;V.isDebugRequestMsg=Ga;V.isDebugReplyMsg=Xa;V.isInputRequestMsg=Ya;V.isInputReplyMsg=Qa;var ja=Z();function Ta(n){var e,t,s,r,i,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:ja.UUID.uuid4(),msg_type:n.msgType,session:n.session,username:(s=n.username)!==null&&s!==void 0?s:"",subshell_id:(r=n.subshellId)!==null&&r!==void 0?r:null,version:"5.2"},metadata:(i=n.metadata)!==null&&i!==void 0?i:{},parent_header:(o=n.parentHeader)!==null&&o!==void 0?o:{}}}function Ua(n){return n.header.msg_type==="stream"}function Aa(n){return n.header.msg_type==="display_data"}function Na(n){return n.header.msg_type==="update_display_data"}function La(n){return n.header.msg_type==="execute_input"}function xa(n){return n.header.msg_type==="execute_result"}function Fa(n){return n.header.msg_type==="error"}function Ka(n){return n.header.msg_type==="status"}function za(n){return n.header.msg_type==="clear_output"}function Va(n){return n.header.msg_type==="debug_event"}function Ba(n){return n.header.msg_type==="comm_open"}function Wa(n){return n.header.msg_type==="comm_close"}function $a(n){return n.header.msg_type==="comm_msg"}function Ha(n){return n.header.msg_type==="kernel_info_request"}function Ja(n){return n.header.msg_type==="execute_reply"}function Ga(n){return n.header.msg_type==="debug_request"}function Xa(n){return n.header.msg_type==="debug_reply"}function Ya(n){return n.header.msg_type==="input_request"}function Qa(n){return n.header.msg_type==="input_reply"}var Gr;(function(n){n.v1KernelWebsocketJupyterOrg="v1.kernel.websocket.jupyter.org"})(Gr||(V.supportedKernelWebSocketProtocols=Gr={}))});var Yr=R(Oe=>{"use strict";var Za=Oe&&Oe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),el=Oe&&Oe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),tl=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)&&Za(e,n,t);return el(e,n),e};Object.defineProperty(Oe,"__esModule",{value:!0});Oe.serialize=nl;Oe.deserialize=sl;var Xr=tl(Ze());function nl(n,e=""){switch(e){case Xr.supportedKernelWebSocketProtocols.v1KernelWebsocketJupyterOrg:return et.serializeV1KernelWebsocketJupyterOrg(n);default:return et.serializeDefault(n)}}function sl(n,e=""){switch(e){case Xr.supportedKernelWebSocketProtocols.v1KernelWebsocketJupyterOrg:return et.deserializeV1KernelWebsocketJupyterOrg(n);default:return et.deserializeDefault(n)}}var et;(function(n){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"),v=d.decode(a.slice(l[0],l[1])),m=JSON.parse(d.decode(a.slice(l[1],l[2]))),q=JSON.parse(d.decode(a.slice(l[2],l[3]))),I=JSON.parse(d.decode(a.slice(l[3],l[4]))),j=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:v,header:m,parent_header:q,metadata:I,content:j,buffers:A},h}n.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:[],v=5+d.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),j=q.encode(h),A=q.encode(c),C=q.encode(u),w=q.encode(l),k=new Uint8Array(I.length+j.length+A.length+C.length+w.length);k.set(I),k.set(j,I.length),k.set(A,I.length+j.length),k.set(C,I.length+j.length+A.length),k.set(w,I.length+j.length+A.length+C.length);for(let f of[j.length,A.length,C.length,w.length])m.push(f+m[m.length-1]);let N=0;for(let f of d){let y=f.byteLength;m.push(y+m[m.length-1]),N+=y}let T=new Uint8Array(8*(1+v)+k.byteLength+N),D=new ArrayBuffer(8),U=new DataView(D);U.setBigUint64(0,BigInt(v),!0),T.set(new Uint8Array(D),0);for(let f=0;f<m.length;f++)U.setBigUint64(0,BigInt(m[f]),!0),T.set(new Uint8Array(D),8*(f+1));T.set(k,m[0]);for(let f=0;f<d.length;f++){let y=d[f];T.set(new Uint8Array(ArrayBuffer.isView(y)?y.buffer:y),m[5+f])}return T.buffer}n.serializeV1KernelWebsocketJupyterOrg=t;function s(a){let h;return typeof a=="string"?h=JSON.parse(a):h=i(a),h}n.deserializeDefault=s;function r(a){var h;let c;return!((h=a.buffers)===null||h===void 0)&&h.length?c=o(a):c=JSON.stringify(a),c}n.serializeDefault=r;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 v=1;v<=c;v++)u.push(h.getUint32(v*4));let l=new Uint8Array(a.slice(u[0],u[1])),d=JSON.parse(new TextDecoder("utf8").decode(l));d.buffers=[];for(let v=1;v<c;v++){let m=u[v],q=u[v+1]||a.byteLength;d.buffers.push(new DataView(a.slice(m,q)))}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 I=0;I<l.length;I++){let j=l[I];c.push(ArrayBuffer.isView(j)?j.buffer:j)}let v=c.length;h.push(4*(v+1));for(let I=0;I+1<c.length;I++)h.push(h[h.length-1]+c[I].byteLength);let m=new Uint8Array(h[h.length-1]+c[c.length-1].byteLength),q=new DataView(m.buffer);q.setUint32(0,v);for(let I=0;I<h.length;I++)q.setUint32(4*(I+1),h[I]);for(let I=0;I<c.length;I++)m.set(new Uint8Array(c[I]),h[I]);return m.buffer}})(et||(et={}))});var Qr=R(ns=>{"use strict";Object.defineProperty(ns,"__esModule",{value:!0});ns.default=WebSocket});var he=R(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.ServerConnection=void 0;var xe=te(),Zr=Yr(),ss;typeof window=="undefined"?ss=Qr():ss=WebSocket;var rs;(function(n){function e(i){return Xt.makeSettings(i)}n.makeSettings=e;function t(i,o,a){return Xt.handleRequest(i,o,a)}n.makeRequest=t;class s extends Error{static async create(o){try{let a=await o.json(),{message:h,traceback:c}=a;return c&&console.error(c),new s(o,h!=null?h:s._defaultMessage(o),c!=null?c:"")}catch(a){return console.debug(a),new s(o)}}constructor(o,a=s._defaultMessage(o),h=""){super(a),this.response=o,this.traceback=h}static _defaultMessage(o){return`Invalid response: ${o.status} ${o.statusText}`}}n.ResponseError=s;class r extends TypeError{constructor(o){super(o.message),this.stack=o.stack}}n.NetworkError=r})(rs||(Yt.ServerConnection=rs={}));var Xt;(function(n){function e(r={}){var i;let o=xe.PageConfig.getBaseUrl(),a=xe.PageConfig.getWsUrl(),h=xe.URLExt.normalize(r.baseUrl)||o,c=r.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:ss,token:xe.PageConfig.getToken(),appUrl:xe.PageConfig.getOption("appUrl"),appendToken:l,serializer:{serialize:Zr.serialize,deserialize:Zr.deserialize},...r,baseUrl:h,wsUrl:c}}n.makeSettings=e;function t(r,i,o){var a;if(r.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"&&(r+=(/\?/.test(r)?"&":"?")+new Date().getTime());let c=new o.Request(r,{...o.init,...i}),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 rs.NetworkError(l)})}n.handleRequest=t;function s(r){let i="";try{i=document.cookie}catch{return}let o=i.match("\\b"+r+"=([^;]*)\\b");return o==null?void 0:o[1]}})(Xt||(Xt={}))});var $e=R(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.BaseManager=void 0;var ei=ee(),rl=he(),is=class{constructor(e){var t;this._isDisposed=!1,this._disposed=new ei.Signal(this),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:rl.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),ei.Signal.clearData(this))}};Qt.BaseManager=is});var ni=R(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.ConfigWithDefaults=Fe.ConfigSection=Fe.ConfigSectionManager=void 0;var il=te(),tt=Ae(),ol="api/config",os=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:tt.ServerConnection.makeSettings()}async create(e){let t=new Zt({...e,serverSettings:this.serverSettings});return await t.load(),t}};Fe.ConfigSectionManager=os;var ti;(function(n){async function e(r){if(!t){let o=new Zt(r);return await o.load(),o}return await t.create(r)}n.create=e;let t;function s(r){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=r}n._setConfigSectionManager=s})(ti||(Fe.ConfigSection=ti={}));var Zt=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 il.URLExt.join(this.serverSettings.baseUrl,ol,encodeURIComponent(this._name))}},as=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 r={};return r[this._className]=s,this._section.update(r)}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=as});var si=R(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});en.ConnectionStatus=void 0;var ls=class{constructor(){this.isConnected=!0}};en.ConnectionStatus=ls});var nn=R((tn,ri)=>{(function(n,e){typeof tn=="object"&&typeof ri!="undefined"?e(tn,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))})(tn,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 r{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})(r||(r={}));class i extends r{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={})),n.DisposableDelegate=t,n.DisposableSet=r,n.ObservableDisposableDelegate=s,n.ObservableDisposableSet=i})});var lt=R(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});cs.validateProperty=al;function al(n,e,t,s=[]){if(!n.hasOwnProperty(e))throw Error(`Missing property '${e}'`);let r=n[e];if(t!==void 0){let i=!0;switch(t){case"array":i=Array.isArray(r);break;case"object":i=typeof r!="undefined";break;default:i=typeof r===t}if(!i)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(r);break;default:o=s.findIndex(a=>a===r)>=0;break}if(!o)throw new Error(`Property '${e}' is not one of the valid values ${JSON.stringify(s)}`)}}}});var ii=R(sn=>{"use strict";Object.defineProperty(sn,"__esModule",{value:!0});sn.validateContentsModel=ll;sn.validateCheckpointModel=cl;var De=lt();function ll(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 cl(n){(0,De.validateProperty)(n,"id","string"),(0,De.validateProperty)(n,"last_modified","string")}});var ds=R(ne=>{"use strict";var ul=ne&&ne.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),hl=ne&&ne.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),dl=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)&&ul(e,n,t);return hl(e,n),e};Object.defineProperty(ne,"__esModule",{value:!0});ne.RestContentProvider=ne.ContentProviderRegistry=ne.Drive=ne.ContentsManager=ne.Contents=void 0;var de=te(),fl=nn(),ct=ee(),W=Ae(),Ne=dl(ii()),_l="api/contents",pl="files",oi;(function(n){function e(s){Ne.validateContentsModel(s)}n.validateContentsModel=e;function t(s){Ne.validateCheckpointModel(s)}n.validateCheckpointModel=t})(oi||(ne.Contents=oi={}));var us=class{constructor(e={}){var t,s;this._isDisposed=!1,this._additionalDrives=new Map,this._fileChanged=new ct.Signal(this);let r=this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:W.ServerConnection.makeSettings();this._defaultDrive=(s=e.defaultDrive)!==null&&s!==void 0?s:new rn({serverSettings:r}),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,r;let[i]=this._driveForPath(e),o=(s=i.contentProviderRegistry)===null||s===void 0?void 0:s.getProvider(t==null?void 0:t.contentProviderId);return o!=null&&o.sharedModelFactory?o.sharedModelFactory:(r=i.sharedModelFactory)!==null&&r!==void 0?r:null}localPath(e){let t=e.split("/"),s=t[0].split(":");return s.length===1||!this._additionalDrives.has(s[0])?de.PathExt.removeSlash(e):de.PathExt.join(s.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 s=this.driveName(e),r=this.localPath(e),i=de.PathExt.resolve("/",r,t);return s?`${s}:${i}`:i}driveName(e){let s=e.split("/")[0].split(":");return s.length===1?"":this._additionalDrives.has(s[0])?s[0]:""}get(e,t){let[s,r]=this._driveForPath(e);return s.get(r,t).then(i=>{let o=[];if(i.type==="directory"&&i.content){for(let a of i.content)o.push({...a,path:this._toGlobalPath(s,a.path)});return{...i,path:this._toGlobalPath(s,r),content:o,serverPath:i.path}}else return{...i,path:this._toGlobalPath(s,r),serverPath:i.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,r]=this._driveForPath(t);return s.newUntitled({...e,path:r}).then(i=>({...i,path:de.PathExt.join(t,i.name),serverPath:i.path}))}else return this._defaultDrive.newUntitled(e)}delete(e){let[t,s]=this._driveForPath(e);return t.delete(s)}rename(e,t){let[s,r]=this._driveForPath(e),[i,o]=this._driveForPath(t);if(s!==i)throw Error("ContentsManager: renaming files must occur within a Drive");return s.rename(r,o).then(a=>({...a,path:this._toGlobalPath(s,o),serverPath:a.path}))}save(e,t={}){let s=this.normalize(e),[r,i]=this._driveForPath(e);return r.save(i,{...t,path:i}).then(o=>({...o,path:s,serverPath:o.path}))}copy(e,t){let[s,r]=this._driveForPath(e),[i,o]=this._driveForPath(t);if(s===i)return s.copy(r,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,r]=this._driveForPath(e);return s.restoreCheckpoint(r,t)}deleteCheckpoint(e,t){let[s,r]=this._driveForPath(e);return s.deleteCheckpoint(r,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),s=this.localPath(e);return t?[this._additionalDrives.get(t),s]:[this._defaultDrive,s]}_onFileChanged(e,t){var s,r;if(e===this._defaultDrive)this._fileChanged.emit(t);else{let i=null,o=null;!((s=t.newValue)===null||s===void 0)&&s.path&&(i={...t.newValue,path:this._toGlobalPath(e,t.newValue.path)}),!((r=t.oldValue)===null||r===void 0)&&r.path&&(o={...t.oldValue,path:this._toGlobalPath(e,t.oldValue.path)}),this._fileChanged.emit({type:t.type,newValue:i,oldValue:o})}}};ne.ContentsManager=us;var rn=class{constructor(e={}){var t,s,r,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:_l,this.serverSettings=(r=e.serverSettings)!==null&&r!==void 0?r:W.ServerConnection.makeSettings();let o=(i=e.defaultContentProvider)!==null&&i!==void 0?i:new an({apiEndpoint:this._apiEndpoint,serverSettings:this.serverSettings});this.contentProviderRegistry=new on({defaultProvider:o}),this.contentProviderRegistry.fileChanged.connect((a,h)=>{this._fileChanged.emit(h)})}get fileChanged(){return this._fileChanged}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,ct.Signal.clearData(this))}async get(e,t){return this.contentProviderRegistry.getProvider(t==null?void 0:t.contentProviderId).get(e,t)}getDownloadUrl(e){let t=this.serverSettings.baseUrl,s=de.URLExt.join(t,pl,de.URLExt.encodeParts(e)),r="";try{r=document.cookie}catch{}let i=r.match("\\b_xsrf=([^;]*)\\b");if(i){let o=new URL(s);o.searchParams.append("_xsrf",i[1]),s=o.toString()}return Promise.resolve(s)}async newUntitled(e={}){var t;let s="{}";e&&(e.ext&&(e.ext=hs.normalizeExtension(e.ext)),s=JSON.stringify(e));let r=this.serverSettings,i=this._getUrl((t=e.path)!==null&&t!==void 0?t:""),o={method:"POST",body:s},a=await W.ServerConnection.makeRequest(i,o,r);if(a.status!==201)throw await W.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),s=this.serverSettings,r={method:"DELETE"},i=await W.ServerConnection.makeRequest(t,r,s);if(i.status!==204)throw await W.ServerConnection.ResponseError.create(i);this._fileChanged.emit({type:"delete",oldValue:{path:e},newValue:null})}async rename(e,t){let s=this.serverSettings,r=this._getUrl(e),i={method:"PATCH",body:JSON.stringify({path:t})},o=await W.ServerConnection.makeRequest(r,i,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 r=await this.contentProviderRegistry.getProvider(t==null?void 0:t.contentProviderId).save(e,t);return this._fileChanged.emit({type:"save",oldValue:null,newValue:r}),r}async copy(e,t){let s=this.serverSettings,r=this._getUrl(t),i={method:"POST",body:JSON.stringify({copy_from:e})},o=await W.ServerConnection.makeRequest(r,i,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"},r=await W.ServerConnection.makeRequest(t,s,this.serverSettings);if(r.status!==201)throw await W.ServerConnection.ResponseError.create(r);let i=await r.json();return Ne.validateCheckpointModel(i),i}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 r=await s.json();if(!Array.isArray(r))throw new Error("Invalid Checkpoint list");for(let i=0;i<r.length;i++)Ne.validateCheckpointModel(r[i]);return r}async restoreCheckpoint(e,t){let s=this._getUrl(e,"checkpoints",t),r={method:"POST"},i=await W.ServerConnection.makeRequest(s,r,this.serverSettings);if(i.status!==204)throw await W.ServerConnection.ResponseError.create(i)}async deleteCheckpoint(e,t){let s=this._getUrl(e,"checkpoints",t),r={method:"DELETE"},i=await W.ServerConnection.makeRequest(s,r,this.serverSettings);if(i.status!==204)throw await W.ServerConnection.ResponseError.create(i)}_getUrl(...e){let t=e.map(r=>de.URLExt.encodeParts(r)),s=this.serverSettings.baseUrl;return de.URLExt.join(s,this._apiEndpoint,...t)}};ne.Drive=rn;var hs;(function(n){function e(t){return t.length>0&&t.indexOf(".")!==0&&(t=`.${t}`),t}n.normalizeExtension=e})(hs||(hs={}));var on=class{constructor(e){this._providers=new Map,this._fileChanged=new ct.Signal(this),this.register("default",e.defaultProvider),this._defaultProvider=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=(r,i)=>{this._fileChanged.emit(i)};return t.fileChanged&&t.fileChanged.connect(s),new fl.DisposableDelegate(()=>{t.fileChanged&&t.fileChanged.disconnect(s),this._providers.has(e)&&this._providers.delete(e)})}getProvider(e){if(!e)return this._defaultProvider;let t=this._providers.get(e);if(!t)throw Error(`Provider ${e} is not registered`);return t}get fileChanged(){return this._fileChanged}};ne.ContentProviderRegistry=on;var an=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",h=t.hash?"1":"0",c={...t,content:a,hash:h};s+=de.URLExt.objectToQueryString(c)}let r=this._options.serverSettings,i=await W.ServerConnection.makeRequest(s,{},r);if(i.status!==200)throw await W.ServerConnection.ResponseError.create(i);let o=await i.json();return Ne.validateContentsModel(o),o}async save(e,t={}){let s=this._options.serverSettings,r=this._getUrl(e),o={method:"PUT",body:new File([JSON.stringify(t)],"data.json",{type:"application/json"})},a=await W.ServerConnection.makeRequest(r,o,s);if(a.status!==200&&a.status!==201)throw await W.ServerConnection.ResponseError.create(a);let h=await a.json();return Ne.validateContentsModel(h),h}_getUrl(...e){let t=e.map(r=>de.URLExt.encodeParts(r)),s=this._options.serverSettings.baseUrl;return de.URLExt.join(s,this._options.apiEndpoint,...t)}};ne.RestContentProvider=an});var He=R((ln,ai)=>{(function(n,e){typeof ln=="object"&&typeof ai!="undefined"?e(ln,Z(),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))})(ln,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:r.DEFAULT_LINGER,this._standby=c.standby||r.DEFAULT_STANDBY,this._state={...r.DEFAULT_STATE,timestamp:new Date().getTime()};let l=c.frequency||{},d=Math.max(l.interval||0,l.max||0,r.DEFAULT_FREQUENCY.max);this.frequency={...r.DEFAULT_FREQUENCY,...l,max:d},this.name=c.name||r.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!==s.NEVER)throw new Error("Poll interval must be between 0 and max");if(d>s.MAX_INTERVAL&&d!==s.NEVER)throw new Error(`Max interval must be less than ${s.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={...r.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,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===s.NEVER){this._timeout=void 0;return}let v=()=>{this.isDisposed||this.tick!==l.promise||this._execute()};this._timeout=setTimeout(v,d.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 r.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:r.sleep(this.frequency,this.state),payload:l,phase:"rejected"})})}}(function(h){h.IMMEDIATE=0,h.MAX_INTERVAL=2147483647,h.NEVER=1/0})(s||(s={}));var r;(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:s.NEVER,payload:null,phase:"constructed",timestamp:new Date(0).getTime()},h.DISPOSED_STATE={interval:s.NEVER,payload:null,phase:"disposed",timestamp:new Date(0).getTime()};function c(l,d){let{backoff:v,interval:m,max:q}=l;if(m===s.NEVER)return m;let I=v===!0?h.DEFAULT_BACKOFF:v===!1?1:v,j=u(m,d.interval*I);return Math.min(q,j)}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}})(r||(r={}));class i{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,d)=>{let{payload:v}=this;if(d.phase==="resolved"){this.payload=new e.PromiseDelegate,v.resolve(d.payload);return}if(d.phase==="rejected"||d.phase==="stopped"){this.payload=new e.PromiseDelegate,v.promise.catch(m=>{}),v.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: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=i,n.Throttler=a})});var _s=R(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});cn.EventManager=void 0;var li=te(),gl=He(),ci=ee(),ui=he(),hi="api/events",fs=class{constructor(e={}){var t,s;this._socket=null,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:ui.ServerConnection.makeSettings(),this._poll=new gl.Poll({factory:()=>this._subscribe(),standby:(s=e.standby)!==null&&s!==void 0?s:"when-hidden"}),this._stream=new ci.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()),ci.Signal.clearData(this),this._stream.stop()}async emit(e){let{serverSettings:t}=this,{baseUrl:s}=t,{makeRequest:r,ResponseError:i}=ui.ServerConnection,o=li.URLExt.join(s,hi),a={body:JSON.stringify(e),method:"POST"},h=await r(o,a,t);if(h.status!==204)throw new i(h)}_subscribe(){return new Promise((e,t)=>{if(this.isDisposed)return;let{appendToken:s,token:r,WebSocket:i,wsUrl:o}=this.serverSettings,a=li.URLExt.join(o,hi,"subscribe");s&&r!==""&&(a+=`?token=${encodeURIComponent(r)}`);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))})}};cn.EventManager=fs});var ps=R(Se=>{"use strict";var ml=Se&&Se.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),vl=Se&&Se.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),yl=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)&&ml(e,n,t);return vl(e,n),e};Object.defineProperty(Se,"__esModule",{value:!0});Se.CommHandler=Se.CommsOverSubshells=void 0;var wl=Z(),Sl=nn(),un=yl(Ze()),nt;(function(n){n.Disabled="disabled",n.PerComm="perComm",n.PerCommTarget="perCommTarget"})(nt||(Se.CommsOverSubshells=nt={}));var hn=class n extends Sl.DisposableDelegate{constructor(e,t,s,r,i){super(r),this._subshellStarted=new wl.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=i!=null?i: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 r=un.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(r,!1,!0)}send(e,t,s=[],r=!0){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot send");let i=un.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(i,!1,r)}close(e,t,s=[]){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot close");let r=un.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}),i=this._kernel.sendShellMessage(r,!1,!0),o=this._onClose;if(o){let a=un.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(),i}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 fi=R(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0})});var dn=R(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.validateMessage=Pl;ut.validateModel=pi;ut.validateModels=El;var Je=lt(),_i=["username","version","session","msg_id","msg_type"],bl={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 Cl(n){for(let e=0;e<_i.length;e++)(0,Je.validateProperty)(n,_i[e],"string")}function Pl(n){(0,Je.validateProperty)(n,"metadata","object"),(0,Je.validateProperty)(n,"content","object"),(0,Je.validateProperty)(n,"channel","string"),Cl(n.header),n.channel==="iopub"&&Ml(n)}function Ml(n){if(n.channel==="iopub"){let e=bl[n.header.msg_type];if(e===void 0)return;let t=Object.keys(e),s=n.content;for(let r=0;r<t.length;r++){let i=e[t[r]];Array.isArray(i)||(i=[i]),(0,Je.validateProperty)(s,t[r],...i)}}}function pi(n){(0,Je.validateProperty)(n,"name","string"),(0,Je.validateProperty)(n,"id","string")}function El(n){if(!Array.isArray(n))throw new Error("Invalid kernel list");n.forEach(e=>pi(e))}});var _n=R(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});se.KernelAPIClient=se.KERNEL_SERVICE_URL=void 0;se.listRunning=gi;se.startNew=mi;se.restartKernel=vi;se.interruptKernel=yi;se.shutdownKernel=wi;se.getKernelModel=Si;var Y=he(),st=te(),fn=dn();se.KERNEL_SERVICE_URL="api/kernels";async function gi(n=Y.ServerConnection.makeSettings()){let e=st.URLExt.join(n.baseUrl,se.KERNEL_SERVICE_URL),t=await Y.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await Y.ServerConnection.ResponseError.create(t);let s=await t.json();return(0,fn.validateModels)(s),s}async function mi(n={},e=Y.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL),s={method:"POST",body:JSON.stringify(n)},r=await Y.ServerConnection.makeRequest(t,s,e);if(r.status!==201)throw await Y.ServerConnection.ResponseError.create(r);let i=await r.json();return(0,fn.validateModel)(i),i}async function vi(n,e=Y.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(n),"restart"),s={method:"POST"},r=await Y.ServerConnection.makeRequest(t,s,e);if(r.status!==200)throw await Y.ServerConnection.ResponseError.create(r);let i=await r.json();(0,fn.validateModel)(i)}async function yi(n,e=Y.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(n),"interrupt"),s={method:"POST"},r=await Y.ServerConnection.makeRequest(t,s,e);if(r.status!==204)throw await Y.ServerConnection.ResponseError.create(r)}async function wi(n,e=Y.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(n)),s={method:"DELETE"},r=await Y.ServerConnection.makeRequest(t,s,e);if(r.status===404){let i=`The kernel "${n}" does not exist on the server`;console.warn(i)}else if(r.status!==204)throw await Y.ServerConnection.ResponseError.create(r)}async function Si(n,e=Y.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(n)),s=await Y.ServerConnection.makeRequest(t,{},e);if(s.status===404)return;if(s.status!==200)throw await Y.ServerConnection.ResponseError.create(s);let r=await s.json();return(0,fn.validateModel)(r),r}var gs=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Y.ServerConnection.makeSettings()}async listRunning(){return gi(this.serverSettings)}async getModel(e){return Si(e,this.serverSettings)}async startNew(e={}){return mi(e,this.serverSettings)}async restart(e){return vi(e,this.serverSettings)}async interrupt(e){return yi(e,this.serverSettings)}async shutdown(e){return wi(e,this.serverSettings)}};se.KernelAPIClient=gs});var Ci=R(ve=>{"use strict";var Il=ve&&ve.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Rl=ve&&ve.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),kl=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)&&Il(e,n,t);return Rl(e,n),e};Object.defineProperty(ve,"__esModule",{value:!0});ve.KernelShellFutureHandler=ve.KernelControlFutureHandler=ve.KernelFutureHandler=void 0;var bi=Z(),Ol=nn(),Dl=kl(Ze()),ht=class extends Ol.DisposableDelegate{constructor(e,t,s,r,i){super(e),this._status=0,this._stdin=re.noOp,this._iopub=re.noOp,this._reply=re.noOp,this._done=new bi.PromiseDelegate,this._hooks=new re.HookList,this._disposeOnDone=!0,this._msg=t,s||this._setFlag(re.KernelFutureFlag.GotReply),this._disposeOnDone=r,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=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),Dl.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 ms=class extends ht{};ve.KernelControlFutureHandler=ms;var vs=class extends ht{};ve.KernelShellFutureHandler=vs;var re;(function(n){n.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 bi.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}}n.HookList=t;let s;(function(r){r[r.GotReply=1]="GotReply",r[r.GotIdle=2]="GotIdle",r[r.IsDone=4]="IsDone",r[r.DisposeOnDone=8]="DisposeOnDone"})(s=n.KernelFutureFlag||(n.KernelFutureFlag={}))})(re||(re={}))});var Mi=R(pn=>{"use strict";Object.defineProperty(pn,"__esModule",{value:!0});pn.validateSpecModel=Pi;pn.validateSpecModels=ql;var Ge=lt();function Pi(n){let e=n.spec;if(!e)throw new Error("Invalid kernel spec");(0,Ge.validateProperty)(n,"name","string"),(0,Ge.validateProperty)(n,"resources","object"),(0,Ge.validateProperty)(e,"language","string"),(0,Ge.validateProperty)(e,"display_name","string"),(0,Ge.validateProperty)(e,"argv","array");let t=null;e.hasOwnProperty("metadata")&&((0,Ge.validateProperty)(e,"metadata","object"),t=e.metadata);let s=null;return e.hasOwnProperty("env")&&((0,Ge.validateProperty)(e,"env","object"),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 ql(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 r=0;r<e.length;r++){let i=n.kernelspecs[e[r]];try{t[e[r]]=Pi(i)}catch{console.warn(`Removing errant kernel spec: ${e[r]}`)}}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 ft=R(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.KernelSpecAPIClient=void 0;dt.getSpecs=Ei;var gn=he(),jl=Mi(),Tl=te(),Ul="api/kernelspecs";async function Ei(n=gn.ServerConnection.makeSettings()){let e=Tl.URLExt.join(n.baseUrl,Ul),t=await gn.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await gn.ServerConnection.ResponseError.create(t);let s=await t.json();return(0,jl.validateSpecModels)(s)}var ys=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:gn.ServerConnection.makeSettings()}async get(){return Ei(this.serverSettings)}};dt.KernelSpecAPIClient=ys});var Ss=R(qe=>{"use strict";var Al=qe&&qe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Nl=qe&&qe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Di=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)&&Al(e,n,t);return Nl(e,n),e};Object.defineProperty(qe,"__esModule",{value:!0});qe.KernelConnection=void 0;var Ii=te(),Ke=Z(),ze=ee(),_t=Ae(),Ri=ps(),ie=Di(Ze()),ki=Ci(),Ll=Di(dn()),Oi=_n(),xl=ft(),Fl=te(),Kl=3e3,rt="_RESTARTING_",zl="",ws=class n{constructor(e){var t,s,r,i,o,a,h,c;this._createSocket=(u=!0)=>{this._errorIfDisposed(),this._clearSocket(),this._updateConnectionStatus("connecting");let l=this.serverSettings,d=Ii.URLExt.join(l.wsUrl,Oi.KERNEL_SERVICE_URL,encodeURIComponent(this._id)),v=d.replace(/^((?:\w+:)?\/\/)(?:[^@\/]+@)/,"$1");console.debug(`Starting WebSocket: ${v}`);let m=Ii.URLExt.join(d,"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 j=!1,A=async w=>{var k,N;if(!this._isDisposed){this._reason="",this._model=void 0;try{let T=await this._kernelAPIClient.getModel(this._id);this._model=T,(T==null?void 0:T.execution_state)==="dead"?this._updateStatus("dead"):this._onWSClose(w)}catch(T){if(T instanceof _t.ServerConnection.NetworkError||((k=T.response)===null||k===void 0?void 0:k.status)===503||((N=T.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=>{j||(j=!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),Ll.validateMessage(l)}catch(d){throw d.message=`Kernel message validation error: ${d.message}`,d}this._kernelSession=l.header.session,this._msgChain=this._msgChain.then(()=>this._handleMessage(l)).catch(d=>{d.message.startsWith("Canceled future for ")&&console.error(d)}),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(ie.supportedKernelWebSocketProtocols),this._selectedProtocol="",this._commsOverSubshells=_t.CommsOverSubshells.PerCommTarget,this._futures=new Map,this._comms=new Map,this._targetRegistry=Object.create(null),this._info=new Ke.PromiseDelegate,this._pendingMessages=[],this._statusChanged=new ze.Signal(this),this._connectionStatusChanged=new ze.Signal(this),this._disposed=new ze.Signal(this),this._iopubMessage=new ze.Signal(this),this._anyMessage=new ze.Signal(this),this._pendingInput=new ze.Signal(this),this._unhandledMessage=new ze.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:_t.ServerConnection.makeSettings(),this._kernelAPIClient=(s=e.kernelAPIClient)!==null&&s!==void 0?s:new Oi.KernelAPIClient({serverSettings:this.serverSettings}),this._kernelSpecAPIClient=(r=e.kernelSpecAPIClient)!==null&&r!==void 0?r:new xl.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._clientId=(i=e.clientId)!==null&&i!==void 0?i:Ke.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:_t.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:_t.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(),ze.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(ki.KernelShellFutureHandler,e,t,s)}sendControlMessage(e,t=!1,s=!0){return this._sendKernelShellControl(ki.KernelControlFutureHandler,e,t,s)}_sendKernelShellControl(e,t,s=!1,r=!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,s,r,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===zl||this._kernelSession===rt)&&ie.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 Ke.PromiseDelegate,t=(s,r)=>{r==="connected"?(e.resolve(),this.connectionStatusChanged.disconnect(t,this)):r==="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=ie.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(r){if(this.isDisposed)return;throw r}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=ie.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=ie.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=ie.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 r={silent:!1,store_history:!0,user_expressions:{},allow_stdin:!0,stop_on_error:!1},i=ie.createMessage({msgType:"execute_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:{...r,...e},metadata:s});return this.sendShellMessage(i,!0,t)}requestDebug(e,t=!0){let s=ie.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=ie.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=ie.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=ie.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=ie.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=ie.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=ie.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=Ke.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 Ri.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 r=(s=this._futures)===null||s===void 0?void 0:s.get(e);r&&r.registerMessageHook(t)}removeMessageHook(e,t){var s;let r=(s=this._futures)===null||s===void 0?void 0:s.get(e);r&&r.removeMessageHook(t)}removeInputGuard(){this.hasPendingInput=!1}async _handleDisplayId(e,t){var s,r;let i=t.parent_header.msg_id,o=this._displayIdToParentIds.get(e);if(o){let h={header:Ke.JSONExt.deepCopy(t.header),parent_header:Ke.JSONExt.deepCopy(t.parent_header),metadata:Ke.JSONExt.deepCopy(t.metadata),content:Ke.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=(s=this._displayIdToParentIds.get(e))!==null&&s!==void 0?s:[],o.indexOf(i)===-1&&o.push(i),this._displayIdToParentIds.set(e,o);let a=(r=this._msgIdToDisplayIds.get(i))!==null&&r!==void 0?r:[];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,be.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,s=new Ri.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(r){throw s.close(),console.error("Exception opening new comm"),r}}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 r=s.onClose;r&&await r(e),s.dispose()}async _handleCommMsg(e){this._assertCurrentMessage(e);let t=e.content,s=this._comms.get(t.comm_id);if(!s)return;let r=s.onMsg;r&&await r(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,s=this.requestKernelInfo(),r=!1,i=()=>{r||(r=!0,t&&this._kernelSession===rt&&(this._kernelSession=""),clearTimeout(o),this._pendingMessages.length>0&&this._sendPending())};s.then(i);let o=setTimeout(i,Kl)}else this._updateStatus("unknown");this._connectionStatusChanged.emit(e)}}async _handleMessage(e){var t,s;let r=!1;if(e.parent_header&&e.channel==="iopub"&&(ie.isDisplayDataMsg(e)||ie.isUpdateDisplayDataMsg(e)||ie.isExecuteResultMsg(e))){let o=((t=e.content.transient)!==null&&t!==void 0?t:{}).display_id;o&&(r=await this._handleDisplayId(o,e),this._assertCurrentMessage(e))}if(!r&&e.parent_header){let i=e.parent_header,o=(s=this._futures)===null||s===void 0?void 0:s.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=Fl.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=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=ws;var be;(function(n){function e(i){switch(i.status){case"idle":case"busy":case"unknown":return;default:console.debug(`Kernel: ${i.status} (${i.id})`);break}}n.logKernelStatus=e;async function t(i,o){return i.sendShellMessage(o,!0).done}n.handleShellMessage=t;function s(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`))})}n.loadObject=s;function r(i,o){return i=Math.ceil(i),o=Math.floor(o),Math.floor(Math.random()*(o-i+1))+i}n.getRandomIntInclusive=r})(be||(be={}))});var Ti=R(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.KernelManager=void 0;var Vl=He(),qi=ee(),ji=Ae(),Bl=$e(),Wl=_n(),$l=Ss(),Hl=ft(),pt=class extends Bl.BaseManager{constructor(e={}){var t,s,r;super(e),this._commsOverSubshells=ji.CommsOverSubshells.PerCommTarget,this._isReady=!1,this._kernelConnections=new Set,this._models=new Map,this._runningChanged=new qi.Signal(this),this._connectionFailure=new qi.Signal(this),this._kernelAPIClient=(t=e.kernelAPIClient)!==null&&t!==void 0?t:new Wl.KernelAPIClient({serverSettings:this.serverSettings}),this._kernelSpecAPIClient=(s=e.kernelSpecAPIClient)!==null&&s!==void 0?s:new Hl.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._pollModels=new Vl.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:KernelManager#models",standby:(r=e.standby)!==null&&r!==void 0?r:"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,r=(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){r=!1;break}}e.commsOverSubshells=this._commsOverSubshells;let i=new $l.KernelConnection({handleComms:r,...e,serverSettings:this.serverSettings,kernelAPIClient:this._kernelAPIClient,kernelSpecAPIClient:this._kernelSpecAPIClient});return this._onStarted(i),this._models.has(s)||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 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(r){throw(r instanceof ji.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}this.isDisposed||this._models.size===s.length&&s.every(r=>{let i=this._models.get(r.id);return i?i.connections===r.connections&&i.execution_state===r.execution_state&&i.last_activity===r.last_activity&&i.name===r.name&&i.reason===r.reason&&i.traceback===r.traceback:!1})||(this._models=new Map(s.map(r=>[r.id,r])),this._kernelConnections.forEach(r=>{this._models.has(r.id)||r.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(()=>{})}};gt.KernelManager=pt;(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={},r={}){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})(pt||(gt.KernelManager=pt={}))});var Cs=R(H=>{"use strict";var Ui=H&&H.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Jl=H&&H.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),bs=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)&&Ui(e,n,t);return Jl(e,n),e},Gl=H&&H.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Ui(e,n,t)};Object.defineProperty(H,"__esModule",{value:!0});H.CommsOverSubshells=H.KernelConnection=H.KernelAPI=H.KernelMessage=H.Kernel=void 0;var Xl=ps();Object.defineProperty(H,"CommsOverSubshells",{enumerable:!0,get:function(){return Xl.CommsOverSubshells}});var Yl=bs(fi());H.Kernel=Yl;var Ql=bs(Ze());H.KernelMessage=Ql;var Zl=bs(_n());H.KernelAPI=Zl;var ec=Ss();Object.defineProperty(H,"KernelConnection",{enumerable:!0,get:function(){return ec.KernelConnection}});Gl(Ti(),H)});var Ni=R(Ai=>{"use strict";Object.defineProperty(Ai,"__esModule",{value:!0})});var xi=R(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});mn.KernelSpecManager=void 0;var tc=Z(),nc=He(),Li=ee(),sc=$e(),rc=ft(),Ps=class extends sc.BaseManager{constructor(e={}){var t,s;super(e),this._isReady=!1,this._connectionFailure=new Li.Signal(this),this._specs=null,this._specsChanged=new Li.Signal(this),this._kernelSpecAPIClient=(t=e.kernelSpecAPIClient)!==null&&t!==void 0?t:new rc.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._ready=Promise.all([this.requestSpecs()]).then(r=>{}).catch(r=>{}).then(()=>{this.isDisposed||(this._isReady=!0)}),this._pollSpecs=new nc.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||tc.JSONExt.deepEqual(e,this._specs)||(this._specs=e,this._specsChanged.emit(e))}};mn.KernelSpecManager=Ps});var Ms=R(fe=>{"use strict";var Fi=fe&&fe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),ic=fe&&fe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Ki=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)&&Fi(e,n,t);return ic(e,n),e},oc=fe&&fe.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Fi(e,n,t)};Object.defineProperty(fe,"__esModule",{value:!0});fe.KernelSpecAPI=fe.KernelSpec=void 0;var ac=Ki(Ni());fe.KernelSpec=ac;var lc=Ki(ft());fe.KernelSpecAPI=lc;oc(xi(),fe)});var zi=R(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.BuildManager=void 0;var Es=te(),Ve=he(),cc="api/build",Is=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ve.ServerConnection.makeSettings()}get isAvailable(){return Es.PageConfig.getOption("buildAvailable").toLowerCase()==="true"}get shouldCheck(){return Es.PageConfig.getOption("buildCheck").toLowerCase()==="true"}getStatus(){let{_url:e,serverSettings:t}=this;return Ve.ServerConnection.makeRequest(e,{},t).then(r=>{if(r.status!==200)throw new Ve.ServerConnection.ResponseError(r);return r.json()}).then(r=>{if(typeof r.status!="string")throw new Error("Invalid data");if(typeof r.message!="string")throw new Error("Invalid data");return r})}build(){let{_url:e,serverSettings:t}=this,s={method:"POST"};return Ve.ServerConnection.makeRequest(e,s,t).then(i=>{if(i.status===400)throw new Ve.ServerConnection.ResponseError(i,"Build aborted");if(i.status!==200){let o=`Build failed with ${i.status}.
|
|
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=[],d=null;for(let c=0;c<o.length;c++){let u=o[c],l=u.indexOf(n.CODE_BLOCK_MARKER)===0,h=d!=null;if(!(!l&&!h))if(h)d&&(l?(d.endLine=c-1,a.push(d),d=null):d.code+=u+`
|
|
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 $e=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 He=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=He(),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 Je=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,Je.validateProperty)(n,mr[e],"string")}function kl(n){(0,Je.validateProperty)(n,"metadata","object"),(0,Je.validateProperty)(n,"content","object"),(0,Je.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,Je.validateProperty)(s,t[i],...r)}}}function vr(n){(0,Je.validateProperty)(n,"name","string"),(0,Je.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 Ge=lt();function Ir(n){let e=n.spec;if(!e)throw new Error("Invalid kernel spec");(0,Ge.validateProperty)(n,"name","string"),(0,Ge.validateProperty)(n,"resources","object"),(0,Ge.validateProperty)(e,"language","string"),(0,Ge.validateProperty)(e,"display_name","string"),(0,Ge.validateProperty)(e,"argv","array");let t=null;e.hasOwnProperty("metadata")&&((0,Ge.validateProperty)(e,"metadata","object"),t=e.metadata);let s=null;return e.hasOwnProperty("env")&&((0,Ge.validateProperty)(e,"env","object"),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(),Ke=Y(),ze=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 Ke.PromiseDelegate,this._pendingMessages=[],this._statusChanged=new ze.Signal(this),this._connectionStatusChanged=new ze.Signal(this),this._disposed=new ze.Signal(this),this._iopubMessage=new ze.Signal(this),this._anyMessage=new ze.Signal(this),this._pendingInput=new ze.Signal(this),this._unhandledMessage=new ze.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:Ke.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(),ze.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 Ke.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=Ke.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:Ke.JSONExt.deepCopy(t.header),parent_header:Ke.JSONExt.deepCopy(t.parent_header),metadata:Ke.JSONExt.deepCopy(t.metadata),content:Ke.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=He(),Ur=ee(),Ar=Ae(),Gl=$e(),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=He(),Kr=ee(),lc=$e(),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(),Ve=de(),_c="api/build",ks=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ve.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 Ve.ServerConnection.makeRequest(e,{},t).then(i=>{if(i.status!==200)throw new Ve.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 Ve.ServerConnection.makeRequest(e,s,t).then(r=>{if(r.status===400)throw new Ve.ServerConnection.ResponseError(r,"Build aborted");if(r.status!==200){let o=`Build failed with ${r.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 Ve.ServerConnection.ResponseError(i,o)}})}cancel(){let{_url:e,serverSettings:t}=this,s={method:"DELETE"};return Ve.ServerConnection.makeRequest(e,s,t).then(i=>{if(i.status!==204)throw new Ve.ServerConnection.ResponseError(i)})}get _url(){let{baseUrl:e,appUrl:t}=this.serverSettings;return Es.URLExt.join(e,t,cc)}};vn.BuildManager=Is});var Ds=R(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.NbConvertManager=void 0;var Rs=te(),ks=he(),uc=Z(),hc="api/nbconvert",dc="nbconvert",Os=class{constructor(e={}){var t;this._exportFormats=null,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:ks.ServerConnection.makeSettings()}async fetchExportFormats(){this._requestingFormats=new uc.PromiseDelegate,this._exportFormats=null;let e=this.serverSettings.baseUrl,t=Rs.URLExt.join(e,hc),{serverSettings:s}=this,r=await ks.ServerConnection.makeRequest(t,{},s);if(r.status!==200)throw await ks.ServerConnection.ResponseError.create(r);let i=await r.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:s}=e,{download:r=!1}=e.exporterOptions||{},i=this.serverSettings.baseUrl,o=Rs.URLExt.encodeParts(s),a=Rs.URLExt.join(i,dc,t,o);r&&(a+="?download=true"),window==null||window.open(a,"_blank","noopener")}};yn.NbConvertManager=Os});var Bi=R(Vi=>{"use strict";Object.defineProperty(Vi,"__esModule",{value:!0})});var $i=R(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.validateModel=Wi;vt.updateLegacySessionModel=_c;vt.validateModels=pc;var fc=dn(),mt=lt();function Wi(n){(0,mt.validateProperty)(n,"id","string"),(0,mt.validateProperty)(n,"type","string"),(0,mt.validateProperty)(n,"name","string"),(0,mt.validateProperty)(n,"path","string"),(0,mt.validateProperty)(n,"kernel","object"),(0,fc.validateModel)(n.kernel)}function _c(n){n.path===void 0&&n.notebook!==void 0&&(n.path=n.notebook.path,n.type="notebook",n.name="")}function pc(n){if(!Array.isArray(n))throw new Error("Invalid session list");n.forEach(e=>Wi(e))}});var bn=R(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.SessionAPIClient=_e.SESSION_SERVICE_URL=void 0;_e.listRunning=Hi;_e.getSessionUrl=Sn;_e.shutdownSession=Ji;_e.getSessionModel=Gi;_e.startSession=Xi;_e.updateSession=Yi;var oe=he(),wn=te(),Be=$i();_e.SESSION_SERVICE_URL="api/sessions";async function Hi(n=oe.ServerConnection.makeSettings()){let e=wn.URLExt.join(n.baseUrl,_e.SESSION_SERVICE_URL),t=await oe.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await oe.ServerConnection.ResponseError.create(t);let s=await t.json();if(!Array.isArray(s))throw new Error("Invalid Session list");return s.forEach(r=>{(0,Be.updateLegacySessionModel)(r),(0,Be.validateModel)(r)}),s}function Sn(n,e){let t=wn.URLExt.join(n,_e.SESSION_SERVICE_URL),s=wn.URLExt.join(t,e);if(!s.startsWith(t))throw new Error("Can only be used for services requests");return s}async function Ji(n,e=oe.ServerConnection.makeSettings()){var t;let s=Sn(e.baseUrl,n),r={method:"DELETE"},i=await oe.ServerConnection.makeRequest(s,r,e);if(i.status===404){let a=(t=(await i.json()).message)!==null&&t!==void 0?t:`The session "${n}"" does not exist on the server`;console.warn(a)}else{if(i.status===410)throw new oe.ServerConnection.ResponseError(i,"The kernel was deleted but the session was not");if(i.status!==204)throw await oe.ServerConnection.ResponseError.create(i)}}async function Gi(n,e=oe.ServerConnection.makeSettings()){let t=Sn(e.baseUrl,n),s=await oe.ServerConnection.makeRequest(t,{},e);if(s.status!==200)throw await oe.ServerConnection.ResponseError.create(s);let r=await s.json();return(0,Be.updateLegacySessionModel)(r),(0,Be.validateModel)(r),r}async function Xi(n,e=oe.ServerConnection.makeSettings()){let t=wn.URLExt.join(e.baseUrl,_e.SESSION_SERVICE_URL),s={method:"POST",body:JSON.stringify(n)},r=await oe.ServerConnection.makeRequest(t,s,e);if(r.status!==201)throw await oe.ServerConnection.ResponseError.create(r);let i=await r.json();return(0,Be.updateLegacySessionModel)(i),(0,Be.validateModel)(i),i}async function Yi(n,e=oe.ServerConnection.makeSettings()){let t=Sn(e.baseUrl,n.id),s={method:"PATCH",body:JSON.stringify(n)},r=await oe.ServerConnection.makeRequest(t,s,e);if(r.status!==200)throw await oe.ServerConnection.ResponseError.create(r);let i=await r.json();return(0,Be.updateLegacySessionModel)(i),(0,Be.validateModel)(i),i}var qs=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:oe.ServerConnection.makeSettings()}async listRunning(){return Hi(this.serverSettings)}async getModel(e){return Gi(e,this.serverSettings)}async startNew(e){return Xi(e,this.serverSettings)}async shutdown(e){return Ji(e,this.serverSettings)}async update(e){return Yi(e,this.serverSettings)}};_e.SessionAPIClient=qs});var Qi=R(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.SessionConnection=void 0;var je=ee(),gc=Ae(),mc=Z(),vc=bn(),js=class{constructor(e){var t,s,r,i,o;this._id="",this._path="",this._name="",this._type="",this._kernel=null,this._isDisposed=!1,this._disposed=new je.Signal(this),this._kernelChanged=new je.Signal(this),this._statusChanged=new je.Signal(this),this._connectionStatusChanged=new je.Signal(this),this._pendingInput=new je.Signal(this),this._iopubMessage=new je.Signal(this),this._unhandledMessage=new je.Signal(this),this._anyMessage=new je.Signal(this),this._propertyChanged=new je.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:mc.UUID.uuid4(),this._connectToKernel=e.connectToKernel,this._kernelConnectionOptions=(r=e.kernelConnectionOptions)!==null&&r!==void 0?r:{},this.serverSettings=(i=e.serverSettings)!==null&&i!==void 0?i:gc.ServerConnection.makeSettings(),this._sessionAPIClient=(o=e.sessionAPIClient)!==null&&o!==void 0?o:new vc.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 r=this._kernel||null;this._kernelChanged.emit({name:"kernel",oldValue:s,newValue:r})}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})}je.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")}};Cn.SessionConnection=js});var eo=R(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.SessionManager=void 0;var yc=He(),Zi=ee(),wc=he(),Sc=$e(),bc=Qi(),Cc=bn(),yt=class extends Sc.BaseManager{constructor(e){var t,s;super(e),this._isReady=!1,this._sessionConnections=new Set,this._models=new Map,this._runningChanged=new Zi.Signal(this),this._connectionFailure=new Zi.Signal(this),this._connectToKernel=r=>this._kernelManager.connectTo(r),this._kernelManager=e.kernelManager,this._sessionAPIClient=(t=e.sessionAPIClient)!==null&&t!==void 0?t:new Cc.SessionAPIClient({serverSettings:e.serverSettings}),this._pollModels=new yc.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 bc.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(r=>r.path===e);if(s.length===1){let r=s[0].id;await this.shutdown(r)}}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(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}this.isDisposed||this._models.size===s.length&&s.every(r=>{var i,o,a,h;let c=this._models.get(r.id);return c?((i=c.kernel)===null||i===void 0?void 0:i.id)===((o=r.kernel)===null||o===void 0?void 0:o.id)&&((a=c.kernel)===null||a===void 0?void 0:a.name)===((h=r.kernel)===null||h===void 0?void 0:h.name)&&c.name===r.name&&c.path===r.path&&c.type===r.type:!1})||(this._models=new Map(s.map(r=>[r.id,r])),this._sessionConnections.forEach(r=>{this._models.has(r.id)?r.update(this._models.get(r.id)):r.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(()=>{})}};wt.SessionManager=yt;(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,r={}){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})(yt||(wt.SessionManager=yt={}))});var Ts=R(pe=>{"use strict";var to=pe&&pe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Pc=pe&&pe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),no=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)&&to(e,n,t);return Pc(e,n),e},Mc=pe&&pe.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&to(e,n,t)};Object.defineProperty(pe,"__esModule",{value:!0});pe.SessionAPI=pe.Session=void 0;var Ec=no(Bi());pe.Session=Ec;var Ic=no(bn());pe.SessionAPI=Ic;Mc(eo(),pe)});var so=R(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.DataConnector=void 0;var Us=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.")}};Pn.DataConnector=Us});var io=R(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0})});var ao=R((Mn,oo)=>{(function(n,e){typeof Mn=="object"&&typeof oo!="undefined"?e(Mn):typeof define=="function"&&define.amd?define(["exports"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_properties={}))})(Mn,function(n){"use strict";class e{constructor(r){this._pid=t.nextPID(),this.name=r.name,this._create=r.create,this._coerce=r.coerce||null,this._compare=r.compare||null,this._changed=r.changed||null}get(r){let i,o=t.ensureMap(r);return this._pid in o?i=o[this._pid]:i=o[this._pid]=this._createValue(r),i}set(r,i){let o,a=t.ensureMap(r);this._pid in a?o=a[this._pid]:o=a[this._pid]=this._createValue(r);let h=this._coerceValue(r,i);this._maybeNotify(r,o,a[this._pid]=h)}coerce(r){let i,o=t.ensureMap(r);this._pid in o?i=o[this._pid]:i=o[this._pid]=this._createValue(r);let a=this._coerceValue(r,i);this._maybeNotify(r,i,o[this._pid]=a)}_createValue(r){let i=this._create;return i(r)}_coerceValue(r,i){let o=this._coerce;return o?o(r,i):i}_compareValue(r,i){let o=this._compare;return o?o(r,i):r===i}_maybeNotify(r,i,o){let a=this._changed;a&&!this._compareValue(i,o)&&a(r,i,o)}}(function(s){function r(i){t.ownerData.delete(i)}s.clearData=r})(e||(e={}));var t;(function(s){s.ownerData=new WeakMap,s.nextPID=(()=>{let i=0;return()=>`pid-${`${Math.random()}`.slice(2)}-${i++}`})();function r(i){let o=s.ownerData.get(i);return o||(o=Object.create(null),s.ownerData.set(i,o),o)}s.ensureMap=r})(t||(t={})),n.AttachedProperty=e})});var co=R(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.RestorablePool=void 0;var Rc=Z(),lo=ao(),En=ee(),As=class{constructor(e){this._added=new En.Signal(this),this._current=null,this._currentChanged=new En.Signal(this),this._hasRestored=!1,this._isDisposed=!1,this._objects=new Set,this._restore=null,this._restored=new Rc.PromiseDelegate,this._updated=new En.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 r="A disposed object cannot be added.";throw console.warn(r,e),new Error(r)}if(this._objects.has(e)){let r="This object already exists in the pool.";throw console.warn(r,e),new Error(r)}if(this._objects.add(e),e.disposed.connect(this._onInstanceDisposed,this),!Te.injectedProperty.get(e)){if(this._restore){let{connector:r}=this._restore,i=this._restore.name(e);if(i){let o=`${this.namespace}:${i}`,a=(s=(t=this._restore).args)===null||s===void 0?void 0:s.call(t,e);Te.nameProperty.set(e,o),await r.save(o,{data:a})}}this._added.emit(e)}}dispose(){this.isDisposed||(this._current=null,this._isDisposed=!0,this._objects.clear(),En.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 Te.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:r,when:i}=e,o=this.namespace,a=i?[s.list(o)].concat(i):[s.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],v=d&&d.data;return v===void 0?s.remove(u):r.execute(t,v).catch(()=>s.remove(u))}));return this._restored.resolve(),c}async save(e){var t,s;let r=Te.injectedProperty.get(e);if(!this._restore||!this.has(e)||r)return;let{connector:i}=this._restore,o=this._restore.name(e),a=Te.nameProperty.get(e),h=o?`${this.namespace}:${o}`:"";if(a&&a!==h&&await i.remove(a),Te.nameProperty.set(e,h),h){let c=(s=(t=this._restore).args)===null||s===void 0?void 0:s.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)),Te.injectedProperty.get(e)||!this._restore)return;let{connector:t}=this._restore,s=Te.nameProperty.get(e);s&&t.remove(s)}};In.RestorablePool=As;var Te;(function(n){n.injectedProperty=new lo.AttachedProperty({name:"injected",create:()=>!1}),n.nameProperty=new lo.AttachedProperty({name:"name",create:()=>""})})(Te||(Te={}))});var uo=R(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.StateDB=void 0;var kc=ee(),St=class n{constructor(e={}){this._changed=new kc.Signal(this);let{connector:t,transform:s}=e;this._connector=t||new n.Connector,s?this._ready=s.then(r=>{let{contents:i,type:o}=r;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((s,r,i)=>(s[e[i]]=r,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(r=>JSON.parse(r).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}))}};bt.StateDB=St;(function(n){class e{constructor(){this._storage={}}async fetch(s){return this._storage[s]}async list(s=""){return Object.keys(this._storage).reduce((r,i)=>((s===""||s===i.split(":")[0])&&(r.ids.push(i),r.values.push(this._storage[i])),r),{ids:[],values:[]})}async remove(s){delete this._storage[s]}async save(s,r){this._storage[s]=r}}n.Connector=e})(St||(bt.StateDB=St={}))});var ho=R(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.IStateDB=void 0;var Oc=Z();Rn.IStateDB=new Oc.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 Ve.ServerConnection.ResponseError(r,o)}})}cancel(){let{_url:e,serverSettings:t}=this,s={method:"DELETE"};return Ve.ServerConnection.makeRequest(e,s,t).then(r=>{if(r.status!==204)throw new Ve.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(),Be=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,Be.updateLegacySessionModel)(i),(0,Be.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,Be.updateLegacySessionModel)(i),(0,Be.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,Be.updateLegacySessionModel)(r),(0,Be.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,Be.updateLegacySessionModel)(r),(0,Be.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=He(),no=ee(),Mc=de(),Ec=$e(),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.
|
|
8
8
|
Use this if you want to store data that will persist across page loads.
|
|
9
|
-
See "state database" for more information.`)});var Ns=R(Pe=>{"use strict";var Dc=Pe&&Pe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Ct=Pe&&Pe.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Dc(e,n,t)};Object.defineProperty(Pe,"__esModule",{value:!0});Ct(so(),Pe);Ct(io(),Pe);Ct(co(),Pe);Ct(uo(),Pe);Ct(ho(),Pe)});var Fs=R(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});On.SettingManager=void 0;var Ls=te(),qc=Ns(),kn=he(),jc="api/settings",xs=class extends qc.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:s,appUrl:r}=t,{makeRequest:i,ResponseError:o}=kn.ServerConnection,a=s+r,h=Pt.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,s,r,i;let{serverSettings:o}=this,{baseUrl:a,appUrl:h}=o,{makeRequest:c,ResponseError:u}=kn.ServerConnection,l=a+h,d=Pt.url(l,"",e==="ids"),v=await c(d,{},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(j=>j.id))!==null&&s!==void 0?s:[],I=[];return e||(I=(i=(r=m==null?void 0:m.settings)===null||r===void 0?void 0:r.map(j=>(j.data={composite:{},user:{}},j)))!==null&&i!==void 0?i:[]),{ids:q,values:I}}async save(e,t){let{serverSettings:s}=this,{baseUrl:r,appUrl:i}=s,{makeRequest:o,ResponseError:a}=kn.ServerConnection,h=r+i,c=Pt.url(h,e),u={body:JSON.stringify({raw:t}),method:"PUT"},l=await o(c,u,s);if(l.status!==204)throw new a(l)}};On.SettingManager=xs;var Pt;(function(n){function e(t,s,r){let i=r?Ls.URLExt.objectToQueryString({ids_only:!0}):"",o=Ls.URLExt.join(t,jc),a=Ls.URLExt.join(o,s);if(!a.startsWith(o))throw new Error("Can only be used for workspaces requests");return`${a}${i}`}n.url=e})(Pt||(Pt={}))});var It=R(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.TerminalAPIClient=ye.TERMINAL_SERVICE_URL=void 0;ye.isAvailable=zs;ye.startNew=fo;ye.listRunning=_o;ye.shutdownTerminal=po;var Mt=te(),Ue=he();ye.TERMINAL_SERVICE_URL="api/terminals";function zs(){return String(Mt.PageConfig.getOption("terminalsAvailable")).toLowerCase()==="true"}async function fo(n=Ue.ServerConnection.makeSettings(),e,t){Et.errorIfNotAvailable();let s=Mt.URLExt.join(n.baseUrl,ye.TERMINAL_SERVICE_URL),r={method:"POST",body:JSON.stringify({name:e,cwd:t})},i=await Ue.ServerConnection.makeRequest(s,r,n);if(i.status!==200)throw await Ue.ServerConnection.ResponseError.create(i);return await i.json()}async function _o(n=Ue.ServerConnection.makeSettings()){Et.errorIfNotAvailable();let e=Mt.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 po(n,e=Ue.ServerConnection.makeSettings()){var t;Et.errorIfNotAvailable();let s=Mt.URLExt.join(e.baseUrl,ye.TERMINAL_SERVICE_URL),r=Mt.URLExt.join(s,n);if(!r.startsWith(s))throw new Error("Can only be used for terminal requests");let i={method:"DELETE"},o=await Ue.ServerConnection.makeRequest(r,i,e);if(o.status===404){let h=(t=(await o.json()).message)!==null&&t!==void 0?t:`The terminal session "${n}"" does not exist on the server`;console.warn(h)}else if(o.status!==204)throw await Ue.ServerConnection.ResponseError.create(o)}var Ks=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ue.ServerConnection.makeSettings()}get isAvailable(){return zs()}async startNew(e={}){let{name:t,cwd:s}=e;return fo(this.serverSettings,t,s)}async listRunning(){return _o(this.serverSettings)}async shutdown(e){return po(e,this.serverSettings)}};ye.TerminalAPIClient=Ks;var Et;(function(n){function e(){if(!zs())throw new Error("Terminals Unavailable")}n.errorIfNotAvailable=e})(Et||(Et={}))});var go=R(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.isAvailable=void 0;var Tc=It();Object.defineProperty(Dn,"isAvailable",{enumerable:!0,get:function(){return Tc.isAvailable}})});var mo=R(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.TerminalConnection=void 0;var Uc=te(),Ac=Z(),qn=ee(),Nc=Ae(),Lc=It(),Vs=class n{constructor(e){var t,s;this._createSocket=()=>{this._errorIfDisposed(),this._clearSocket(),this._updateConnectionStatus("connecting");let r=this._name,i=this.serverSettings,o=Uc.URLExt.join(i.wsUrl,"terminals","websocket",encodeURIComponent(r)),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=r=>{if(this._isDisposed)return;let i=JSON.parse(r.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=r=>{console.warn(`Terminal websocket closed: ${r.code}`),this.isDisposed||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:Nc.ServerConnection.makeSettings(),this._terminalAPIClient=(s=e.terminalAPIClient)!==null&&s!==void 0?s:new Lc.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 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 Ac.PromiseDelegate,t=(s,r)=>{r==="connected"?(e.resolve(),this.connectionStatusChanged.disconnect(t,this)):r==="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=Bs.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=Vs;var Bs;(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})(Bs||(Bs={}))});var yo=R(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.TerminalManager=void 0;var xc=He(),vo=ee(),Fc=Ae(),Kc=$e(),zc=It(),Vc=mo(),Rt=class extends Kc.BaseManager{constructor(e={}){var t,s;if(super(e),this._isReady=!1,this._names=[],this._terminalConnections=new Set,this._runningChanged=new vo.Signal(this),this._connectionFailure=new vo.Signal(this),this._terminalAPIClient=(t=e.terminalAPIClient)!==null&&t!==void 0?t:new zc.TerminalAPIClient({serverSettings:this.serverSettings}),!this.isAvailable()){this._ready=Promise.reject("Terminals unavailable"),this._ready.catch(i=>{});return}let r=this._pollModels=new xc.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 r.start(),await r.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 Vc.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,r=await this._terminalAPIClient.startNew({name:t,cwd:s});return await this.refreshRunning(),this.connectTo({model:r})}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(i){throw(i instanceof Fc.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 r=s.map(({name:i})=>i).sort();r!==this._names&&(this._names=r,this._terminalConnections.forEach(i=>{r.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(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})(Rt||(kt.TerminalManager=Rt={}))});var Ws=R(ge=>{"use strict";var wo=ge&&ge.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Bc=ge&&ge.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),So=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)&&wo(e,n,t);return Bc(e,n),e},Wc=ge&&ge.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&wo(e,n,t)};Object.defineProperty(ge,"__esModule",{value:!0});ge.TerminalAPI=ge.Terminal=void 0;var $c=So(go());ge.Terminal=$c;var Hc=So(It());ge.TerminalAPI=Hc;Wc(yo(),ge)});var Co=R(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0})});var Hs=R(Tn=>{"use strict";Object.defineProperty(Tn,"__esModule",{value:!0});Tn.UserAPIClient=void 0;var Po=he(),Jc=te(),Gc="api/me",$s=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Po.ServerConnection.makeSettings()}async get(){let{baseUrl:e}=this.serverSettings,{makeRequest:t,ResponseError:s}=Po.ServerConnection,r=Jc.URLExt.join(e,Gc),i=await t(r,{},this.serverSettings);if(i.status!==200)throw await s.create(i);return await i.json()}};Tn.UserAPIClient=$s});var Eo=R(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.UserManager=void 0;var Xc=Z(),Yc=He(),Mo=ee(),Qc=$e(),Zc=Hs(),Js="@jupyterlab/services:UserManager#user",Gs=class extends Qc.BaseManager{constructor(e={}){var t,s;super(e),this._isReady=!1,this._userChanged=new Mo.Signal(this),this._connectionFailure=new Mo.Signal(this),this._userApiClient=(t=e.userApiClient)!==null&&t!==void 0?t:new Zc.UserAPIClient({serverSettings:this.serverSettings}),this._ready=this.requestUser().then(()=>{this.isDisposed||(this._isReady=!0)}).catch(r=>new Promise(()=>{})),this._pollUser=new Yc.Poll({auto:!1,factory:()=>this.requestUser(),frequency:{interval:61*1e3,backoff:!0,max:300*1e3},name:Js,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:r}=window,i=r.getItem(Js);if(i&&(!s.initials||!s.color)){let o=JSON.parse(i);s.initials=s.initials||o.initials||s.name.substring(0,1),s.color=s.color||o.color||Xs.getRandomColor()}Xc.JSONExt.deepEqual(t,e)||(this._identity=s,this._permissions=t.permissions,r.setItem(Js,JSON.stringify(s)),this._userChanged.emit(t))}};Un.UserManager=Gs;var Xs;(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)]})(Xs||(Xs={}))});var Ys=R(me=>{"use strict";var Io=me&&me.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),eu=me&&me.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Ro=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)&&Io(e,n,t);return eu(e,n),e},tu=me&&me.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Io(e,n,t)};Object.defineProperty(me,"__esModule",{value:!0});me.UserAPI=me.User=void 0;var nu=Ro(Co());me.User=nu;var su=Ro(Hs());me.UserAPI=su;tu(Eo(),me)});var Zs=R(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.WorkspaceManager=void 0;var ko=te(),ru=Ns(),Ot=he(),iu="api/workspaces",Qs=class extends ru.DataConnector{constructor(e={}){var t;super(),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ot.ServerConnection.makeSettings()}async fetch(e){let{serverSettings:t}=this,{baseUrl:s,appUrl:r}=t,{makeRequest:i,ResponseError:o}=Ot.ServerConnection,a=s+r,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:s}=e,{makeRequest:r,ResponseError:i}=Ot.ServerConnection,o=t+s,a=it.url(o,""),h=await r(a,{},e);if(h.status!==200)throw await i.create(h);return(await h.json()).workspaces}async remove(e){let{serverSettings:t}=this,{baseUrl:s,appUrl:r}=t,{makeRequest:i,ResponseError:o}=Ot.ServerConnection,a=s+r,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:s}=this,{baseUrl:r,appUrl:i}=s,{makeRequest:o,ResponseError:a}=Ot.ServerConnection,h=r+i,c=it.url(h,e),u={body:JSON.stringify(t),method:"PUT"},l=await o(c,u,s);if(l.status!==204)throw await a.create(l)}};An.WorkspaceManager=Qs;var it;(function(n){function e(t,s){let r=ko.URLExt.join(t,iu),i=ko.URLExt.join(r,s);if(!i.startsWith(r))throw new Error("Can only be used for workspaces requests");return i}n.url=e})(it||(it={}))});var Do=R(Nn=>{"use strict";Object.defineProperty(Nn,"__esModule",{value:!0});Nn.ServiceManager=void 0;var Oo=ee(),ou=zi(),au=ds(),lu=_s(),cu=Cs(),uu=Ms(),hu=Ds(),du=he(),fu=Ts(),_u=Fs(),pu=Ws(),gu=Ys(),mu=Zs(),er=class{constructor(e={}){var t,s;this._isDisposed=!1,this._connectionFailure=new Oo.Signal(this),this._isReady=!1;let r=e.defaultDrive,i=(t=e.serverSettings)!==null&&t!==void 0?t:du.ServerConnection.makeSettings(),o=(s=e.standby)!==null&&s!==void 0?s:"when-hidden",a={defaultDrive:r,serverSettings:i,standby:o};this.serverSettings=i,this.contents=e.contents||new au.ContentsManager(a),this.events=e.events||new lu.EventManager(a),this.kernels=e.kernels||new cu.KernelManager(a),this.sessions=e.sessions||new fu.SessionManager({...a,kernelManager:this.kernels}),this.settings=e.settings||new _u.SettingManager(a),this.terminals=e.terminals||new pu.TerminalManager(a),this.builder=e.builder||new ou.BuildManager(a),this.workspaces=e.workspaces||new mu.WorkspaceManager(a),this.nbconvert=e.nbconvert||new hu.NbConvertManager(a),this.kernelspecs=e.kernelspecs||new uu.KernelSpecManager(a),this.user=e.user||new gu.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,Oo.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)}};Nn.ServiceManager=er});var qo=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=Z();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 vu=$&&$.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}: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)&&vu(e,n,t)};Object.defineProperty($,"__esModule",{value:!0});ce($e(),$);ce(ni(),$);ce(si(),$);ce(ds(),$);ce(_s(),$);ce(Cs(),$);ce(Ms(),$);ce(Do(),$);ce(he(),$);ce(Ts(),$);ce(Fs(),$);ce(Ws(),$);ce(qo(),$);ce(Ys(),$);ce(Zs(),$);ce(Ds(),$)});function jo(n){return"node"in n}var To=sr(()=>{});var No={};Qo(No,{BLOCK_SIZE:()=>bu,ContentsAPI:()=>Kn,DRIVE_SEPARATOR:()=>Ao,DriveFS:()=>Dt,DriveFSEmscriptenNodeOps:()=>Fn,DriveFSEmscriptenStreamOps:()=>xn,ServiceWorkerContentsAPI:()=>zn});var Uo,Ao,bu,Cu,Pu,Ln,xn,Fn,Kn,zn,Dt,tr=sr(()=>{Uo=Wn(Z());To();Ao=":",bu=4096,Cu=new TextEncoder,Pu=new TextDecoder("utf-8"),Ln={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},xn=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 r=this.fs.API.get(s);e.file=r}catch{let i=(t=e.flags)!==null&&t!==void 0?t:e.shared.flags,o=typeof i=="string"?parseInt(i,10):i;o&=8191;let a=!0;if(o in Ln&&(a=Ln[o]),a){e.node=this.fs.node_ops.mknod(e.node.parent,e.node.name,e.node.mode,0);let h=this.fs.API.get(s);e.file=h}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),r=(t=e.flags)!==null&&t!==void 0?t:e.shared.flags,i=typeof r=="string"?parseInt(r,10):r;i&=8191;let o=!0;i in Ln&&(o=Ln[i]),o&&this.fs.API.put(s,e.file),e.file=void 0}read(e,t,s,r,i){if(r<=0||e.file===void 0||i>=(e.file.data.length||0))return 0;let o=Math.min(e.file.data.length-i,r);return t.set(e.file.data.subarray(i,i+o),s),o}write(e,t,s,r,i){var o;if(r<=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+r>(((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+r),e.file.data.set(h)}return e.file.data.set(t.subarray(s,s+r),i),r}llseek(e,t,s){var r;let i=t;if(s===1)i+=(r=e.position)!==null&&r!==void 0?r:e.shared.position;else if(s===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}},Fn=class{constructor(e){this.node=t=>jo(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 r=this.node(t);for(let[i,o]of Object.entries(s))switch(i){case"mode":r.mode=o;break;case"timestamp":r.timestamp=o;break;case"atime":r.atime=o;break;case"mtime":r.mtime=o;break;case"ctime":r.ctime=o;break;case"size":{let a=o,h=this.fs.realPath(r);if(this.fs.FS.isFile(r.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",r,"not yet implemented");break}case"dontFollow":break;default:console.warn("setattr",i,"of",o,"on",r,"not yet implemented");break}},this.lookup=(t,s)=>{let r=this.node(t),i=this.fs.PATH.join2(this.fs.realPath(r),s),o=this.fs.API.lookup(i);if(!o.ok)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.ENOENT);return this.fs.createNode(r,s,o.mode,0)},this.mknod=(t,s,r,i)=>{let o=this.node(t),a=this.fs.PATH.join2(this.fs.realPath(o),s);return this.fs.API.mknod(a,r),this.fs.createNode(o,s,r,i)},this.rename=(t,s,r)=>{let i=this.node(t),o=this.node(s);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),r)),i.name=r,i.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,r)=>{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}},Kn=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,r=t.format;switch(r){case"json":case"text":return{data:Cu.encode(s),format:r};case"base64":{let i=atob(s),o=i.length,a=new Uint8Array(o);for(let h=0;h<o;h++)a[h]=i.charCodeAt(h);return{data:a,format:r}}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:Pu.decode(t.data)}});case"base64":{let s="";for(let r=0;r<t.data.byteLength;r++)s+=String.fromCharCode(t.data[r]);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}${Ao}${e}`),e}},zn=class extends Kn{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=Uo.UUID.uuid4(),r={data:{...e,requestId:s},browsingContextId:this._browsingContextId,requestId:s};try{t.send(JSON.stringify(r))}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`}},Dt=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 Fn(this),this.stream_ops=new xn(this)}createAPI(e){if(!e.browsingContextId||!e.baseUrl)throw new Error("Cannot create service-worker API without current browsingContextId");return new zn(e)}mount(e){return this.createNode(null,e.mountpoint,16895,0)}createNode(e,t,s,r){let i=this.FS;if(!i.isDir(s)&&!i.isFile(s))throw new i.ErrnoError(this.ERRNO_CODES.EINVAL);let o=i.createNode(e,t,s,r);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 ir=Symbol("Comlink.proxy"),ea=Symbol("Comlink.endpoint"),ta=Symbol("Comlink.releaseProxy"),$n=Symbol("Comlink.finalizer"),jt=Symbol("Comlink.thrown"),or=n=>typeof n=="object"&&n!==null||typeof n=="function",na={canHandle:n=>or(n)&&n[ir],serialize(n){let{port1:e,port2:t}=new MessageChannel;return Nt(n,e),[t,[t]]},deserialize(n){return n.start(),oa(n)}},sa={canHandle:n=>or(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}},ar=new Map([["proxy",na],["throw",sa]]);function ra(n,e){for(let t of n)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function Nt(n,e=globalThis,t=["*"]){e.addEventListener("message",function s(r){if(!r||!r.data)return;if(!ra(t,r.origin)){console.warn(`Invalid origin '${r.origin}' for comlink proxy`);return}let{id:i,type:o,path:a}=Object.assign({path:[]},r.data),h=(r.data.argumentList||[]).map(We),c;try{let u=a.slice(0,-1).reduce((d,v)=>d[v],n),l=a.reduce((d,v)=>d[v],n);switch(o){case"GET":c=l;break;case"SET":u[a.slice(-1)[0]]=We(r.data.value),c=!0;break;case"APPLY":c=l.apply(u,h);break;case"CONSTRUCT":{let d=new l(...h);c=ha(d)}break;case"ENDPOINT":{let{port1:d,port2:v}=new MessageChannel;Nt(n,v),c=ua(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]=At(u);e.postMessage(Object.assign(Object.assign({},l),{id:i}),d),o==="RELEASE"&&(e.removeEventListener("message",s),lr(e),$n in n&&typeof n[$n]=="function"&&n[$n]())}).catch(u=>{let[l,d]=At({value:new TypeError("Unserializable return value"),[jt]:0});e.postMessage(Object.assign(Object.assign({},l),{id:i}),d)})}),e.start&&e.start()}function ia(n){return n.constructor.name==="MessagePort"}function lr(n){ia(n)&&n.close()}function oa(n,e){let t=new Map;return n.addEventListener("message",function(r){let{data:i}=r;if(!i||!i.id)return;let o=t.get(i.id);if(o)try{o(i)}finally{t.delete(i.id)}}),Hn(n,t,[],e)}function qt(n){if(n)throw new Error("Proxy has been released and is not useable")}function cr(n){return Xe(n,new Map,{type:"RELEASE"}).then(()=>{lr(n)})}var Tt=new WeakMap,Ut="FinalizationRegistry"in globalThis&&new FinalizationRegistry(n=>{let e=(Tt.get(n)||0)-1;Tt.set(n,e),e===0&&cr(n)});function aa(n,e){let t=(Tt.get(e)||0)+1;Tt.set(e,t),Ut&&Ut.register(n,e,n)}function la(n){Ut&&Ut.unregister(n)}function Hn(n,e,t=[],s=function(){}){let r=!1,i=new Proxy(s,{get(o,a){if(qt(r),a===ta)return()=>{la(i),cr(n),e.clear(),r=!0};if(a==="then"){if(t.length===0)return{then:()=>i};let h=Xe(n,e,{type:"GET",path:t.map(c=>c.toString())}).then(We);return h.then.bind(h)}return Hn(n,e,[...t,a])},set(o,a,h){qt(r);let[c,u]=At(h);return Xe(n,e,{type:"SET",path:[...t,a].map(l=>l.toString()),value:c},u).then(We)},apply(o,a,h){qt(r);let c=t[t.length-1];if(c===ea)return Xe(n,e,{type:"ENDPOINT"}).then(We);if(c==="bind")return Hn(n,e,t.slice(0,-1));let[u,l]=rr(h);return Xe(n,e,{type:"APPLY",path:t.map(d=>d.toString()),argumentList:u},l).then(We)},construct(o,a){qt(r);let[h,c]=rr(a);return Xe(n,e,{type:"CONSTRUCT",path:t.map(u=>u.toString()),argumentList:h},c).then(We)}});return aa(i,n),i}function ca(n){return Array.prototype.concat.apply([],n)}function rr(n){let e=n.map(At);return[e.map(t=>t[0]),ca(e.map(t=>t[1]))]}var ur=new WeakMap;function ua(n,e){return ur.set(n,e),n}function ha(n){return Object.assign(n,{[ir]:!0})}function At(n){for(let[e,t]of ar)if(t.canHandle(n)){let[s,r]=t.serialize(n);return[{type:"HANDLER",name:e,value:s},r]}return[{type:"RAW",value:n},ur.get(n)||[]]}function We(n){switch(n.type){case"HANDLER":return ar.get(n.name).deserialize(n.value);case"RAW":return n.value}}function Xe(n,e,t,s){return new Promise(r=>{let i=da();e.set(i,r),n.start&&n.start(),n.postMessage(Object.assign({id:i},t),s)})}function da(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var Lo=Wn(te()),xo=Wn(Ae());tr();var Vn=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,r;t.endsWith(".mjs")?r=(await import(t)).loadPyodide:(importScripts(t),r=self.loadPyodide),this._pyodide=await r({indexURL:s,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: ${
|
|
11
|
-
${
|
|
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=He(),So=ee(),Wc=Ae(),$c=$e(),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=He(),Ro=ee(),su=$e(),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($e(),$);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(We),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]]=We(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(We);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(We)},apply(o,a,d){Tt(i);let c=t[t.length-1];if(c===sa)return Xe(n,e,{type:"ENDPOINT"}).then(We);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(We)},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(We)}});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 We(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: ${r.name}
|
|
11
|
+
${r.message}
|
|
12
12
|
Stack trace:
|
|
13
|
-
${
|
|
13
|
+
${r.stack}`,this._logMessage({type:"text",level:"critical",data:o})}}async initPackageManager(e){if(!this._options)throw new Error("Uninitialized");let{pipliteWheelUrl:t,disablePyPIFallback:s,pipliteUrls:i,loadPyodideOptions:r}=this._options,o=(r||{}).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
18
|
piplite.piplite._PIPLITE_DISABLE_PYPI = ${s?"True":"False"}
|
|
19
|
-
piplite.piplite._PIPLITE_URLS = ${JSON.stringify(
|
|
20
|
-
`)}async initKernel(e){let t=(e.loadPyodideOptions||{}).packages||[],s=["sqlite3","ipykernel","comm","pyodide_kernel","jedi","ipython"],
|
|
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:s,PATH:
|
|
19
|
+
piplite.piplite._PIPLITE_URLS = ${JSON.stringify(i)}
|
|
20
|
+
`)}async initKernel(e){let t=(e.loadPyodideOptions||{}).packages||[],s=["sqlite3","ipykernel","comm","pyodide_kernel","jedi","ipython"],i=[];for(let r of s)t.includes(r)||i.push(`await piplite.install('${r}', keep_going=True)`);i.push("import pyodide_kernel"),e.mountDrive&&this._localPath&&i.push("import os",`os.chdir("${this._localPath}")`),await this._pyodide.runPythonAsync(i.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:s,PATH:i,ERRNO_CODES:r}=this._pyodide,{baseUrl:o}=e,{DriveFS:a}=await Promise.resolve().then(()=>(si(),Fo)),d=new a({FS:s,PATH:i,ERRNO_CODES:r,baseUrl:o,driveName:this._driveName,mountpoint:t,browsingContextId:this._browsingContextId});s.mkdirTree(t),s.mount(d,{},t),s.chdir(t),this._driveFS=d}}mapToObject(e){let t=e instanceof Array?[]:{},s=e instanceof Map?e.entries():Object.entries(e);for(let[i,r]of s)t[i]=r instanceof Map||r instanceof Array?this.mapToObject(r):r;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 s=(l,h,v)=>{let m={execution_count:l,data:this.formatResult(h),metadata:this.formatResult(v)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:m,type:"execute_result"})},i=(l,h,v)=>{let m={ename:l,evalue:h,traceback:v};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:m,type:"execute_error"})},r=l=>{let h={wait:this.formatResult(l)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:h,type:"clear_output"})},o=(l,h,v)=>{let m={data:this.formatResult(l),metadata:this.formatResult(h),transient:this.formatResult(v)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:m,type:"display_data"})},a=(l,h,v)=>{let m={data:this.formatResult(l),metadata:this.formatResult(h),transient:this.formatResult(v)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:m,type:"update_display_data"})},d=(l,h)=>{let v={name:this.formatResult(l),text:this.formatResult(h)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:v,type:"stream"})};this._stdout_stream.publish_stream_callback=d,this._stderr_stream.publish_stream_callback=d,this._interpreter.display_pub.clear_output_callback=r,this._interpreter.display_pub.display_data_callback=o,this._interpreter.display_pub.update_display_data_callback=a,this._interpreter.displayhook.publish_execution_result=s,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"&&i(u.ename,u.evalue,u.traceback),u}async complete(e,t){await this.setup(t);let s=this._kernel.complete(e.code,e.cursor_pos);return this.formatResult(s)}async inspect(e,t){await this.setup(t);let s=this._kernel.inspect(e.code,e.cursor_pos,e.detail_level);return this.formatResult(s)}async isComplete(e,t){await this.setup(t);let s=this._kernel.is_complete(e.code);return this.formatResult(s)}async commInfo(e,t){await this.setup(t);let s=this._kernel.comm_info(e.target_name);return{comms:this.formatResult(s),status:"ok"}}async commOpen(e,t){await this.setup(t);let s=this._kernel.comm_manager.comm_open(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(e));return this.formatResult(s)}async commMsg(e,t){await this.setup(t);let s=this._kernel.comm_manager.comm_msg(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(e));return this.formatResult(s)}async commClose(e,t){await this.setup(t);let s=this._kernel.comm_manager.comm_close(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(e));return this.formatResult(s)}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,s,i,r){this._sendWorkerMessage({type:e,content:this.formatResult(t),metadata:this.formatResult(s),ident:this.formatResult(i),buffers:this.formatResult(r),parentHeader:this.formatResult(this._kernel._parent_header).header})}};var ii=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:s,PATH:i,ERRNO_CODES:r}=this._pyodide,{baseUrl:o,browsingContextId:a}=e,d=new qt({FS:s,PATH:i,ERRNO_CODES:r,baseUrl:o,driveName:this._driveName,mountpoint:t,browsingContextId:a});s.mkdirTree(t),s.mount(d,{},t),s.chdir(t),this._driveFS=d}}sendInputRequest(e,t){var r,o;let s=this.formatResult(this._kernel._parent_header).header,i=zo.KernelMessage.createMessage({channel:"stdin",msgType:"input_request",session:(r=s==null?void 0:s.session)!=null?r:"",parentHeader:s,content:{prompt:e,password:t}});try{if(!this._options)throw new Error("Kernel options not set");let{baseUrl:a,browsingContextId:d}=this._options;if(!d)throw new Error("Kernel browsingContextId not set");let c=new XMLHttpRequest,u=Ko.URLExt.join(a,"/api/stdin/kernel");c.open("POST",u,!1);let l=JSON.stringify({browsingContextId:d,data:i});c.send(l);let h=JSON.parse(c.response);if("error"in h)throw new Error(h.error);return(o=h.content)==null?void 0:o.value}catch(a){console.warn(`Failed to request stdin via service worker: ${a}`);return}}},Ou=new ii;Lt(Ou);export{ii as PyodideComlinkKernel};
|
|
22
22
|
/*! Bundled license information:
|
|
23
23
|
|
|
24
24
|
comlink/dist/esm/comlink.mjs:
|