@jupyterlite/xeus 0.1.0-a1 → 0.1.0-a2

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/README.md CHANGED
@@ -95,12 +95,12 @@ micromamba create -n xeus-python-dev \
95
95
  --yes \
96
96
  "python>=3.11" pybind11 nlohmann_json pybind11_json numpy pytest \
97
97
  bzip2 sqlite zlib libffi xtl pyjs \
98
- xeus xeus-sqlite
98
+ xeus xeus-sqlite xeus-lite
99
99
  ```
100
100
 
101
101
  #### Build the kernel
102
102
 
103
- This dependes on your kernel but will look smth like this:
103
+ This depends on your kernel but will look something like this:
104
104
 
105
105
  ```bash
106
106
  # path to your emscripten emsdk
@@ -120,15 +120,31 @@ cd build_wasm
120
120
  emcmake cmake \
121
121
  -DCMAKE_BUILD_TYPE=Release \
122
122
  -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
123
- -DCMAKE_INSTALL_PREFIX=$PREFIX
123
+ -DCMAKE_INSTALL_PREFIX=$PREFIX \
124
124
  ..
125
125
  emmake make -j8 install
126
126
  ```
127
127
 
128
+ #### Build the JupyterLite site
129
+
130
+ You will need to create a new environment with the dependencies to build the JupyterLite site.
131
+
132
+ ```bash
133
+ # create new environment
134
+ micromamba create -n xeus-lite-host \
135
+ jupyterlite-core
136
+
137
+ # activate the environment
138
+ micromamba activate xeus-lite-host
139
+
140
+ # install jupyterlite_xeus via pip
141
+ python -m pip install jupyterlite-xeus
142
+ ```
143
+
128
144
  When running `jupyter lite build` we pass the `prefix` options and point it to the local environment / prefix we just created:
129
145
 
130
146
  ```bash
131
- jupyter lite build --XeusAddon.prefix=$WASM_ENV_PREFIX
147
+ jupyter lite build --XeusAddon.prefix=$WASM_ENV_PREFIX
132
148
  ```
133
149
 
134
150
  ### Mounting additional files
package/lib/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { JupyterLiteServerPlugin } from '@jupyterlite/server';
2
- declare const plugins: JupyterLiteServerPlugin<any>[];
2
+ declare const plugins: JupyterLiteServerPlugin<void>[];
3
3
  export default plugins;
package/lib/index.js CHANGED
@@ -1,55 +1,41 @@
1
1
  // Copyright (c) Thorsten Beier
2
2
  // Copyright (c) JupyterLite Contributors
3
3
  // Distributed under the terms of the Modified BSD License.
4
+ import { PageConfig, URLExt } from '@jupyterlab/coreutils';
4
5
  import { IServiceWorkerManager } from '@jupyterlite/server';
5
6
  import { IBroadcastChannelWrapper } from '@jupyterlite/contents';
6
7
  import { IKernelSpecs } from '@jupyterlite/kernel';
7
8
  import { WebWorkerKernel } from './web_worker_kernel';
8
- const EXTENSION_NAME = 'xeus';
9
- const EXTENSION_STATIC_DIR = `../extensions/@jupyterlite/${EXTENSION_NAME}/static/`;
10
- // helper function to fetch json
11
- function getPkgJson(url) {
12
- const json_url = EXTENSION_STATIC_DIR + url;
9
+ function getJson(url) {
10
+ const json_url = URLExt.join(PageConfig.getBaseUrl(), url);
13
11
  const xhr = new XMLHttpRequest();
14
12
  xhr.open('GET', json_url, false);
15
13
  xhr.send(null);
16
14
  return JSON.parse(xhr.responseText);
17
15
  }
18
- let kernel_dir = [];
16
+ let kernel_list = [];
19
17
  try {
20
- kernel_dir = getPkgJson('share/jupyter/kernels.json');
18
+ kernel_list = getJson('xeus/kernels.json');
21
19
  }
22
20
  catch (err) {
23
- console.log(err);
24
- console.log('could not fetch share/jupyter/kernels/kernels.json');
25
- kernel_dir = [];
21
+ console.log(`Could not fetch xeus/kernels.json: ${err}`);
26
22
  throw err;
27
23
  }
28
- // fetch kernel spec for each kernel
29
- const kernel_specs = kernel_dir.map(kernel_dir => {
30
- const spec = getPkgJson('share/jupyter/kernels/' + kernel_dir + '/kernel.json');
31
- spec.name = kernel_dir;
32
- spec.dir = kernel_dir;
33
- spec.resources = {
34
- 'logo-32x32': EXTENSION_STATIC_DIR +
35
- 'share/jupyter/kernels/' +
36
- kernel_dir +
37
- '/logo-32x32.png',
38
- 'logo-64x64': EXTENSION_STATIC_DIR +
39
- 'share/jupyter/kernels/' +
40
- kernel_dir +
41
- '/logo-64x64.png'
42
- };
43
- return spec;
44
- });
45
- const server_kernels = kernel_specs.map(kernelspec => {
46
- const server_kernel = {
47
- // use name from spec
48
- id: `@jupyterlite/${kernelspec.name}-extension:kernel`,
24
+ const plugins = kernel_list.map((kernel) => {
25
+ return {
26
+ id: `@jupyterlite/xeus-${kernel}:register`,
49
27
  autoStart: true,
50
28
  requires: [IKernelSpecs],
51
29
  optional: [IServiceWorkerManager, IBroadcastChannelWrapper],
52
30
  activate: (app, kernelspecs, serviceWorker, broadcastChannel) => {
31
+ // Fetch kernel spec
32
+ const kernelspec = getJson('xeus/kernels/' + kernel + '/kernel.json');
33
+ kernelspec.name = kernel;
34
+ kernelspec.dir = kernel;
35
+ kernelspec.resources = {
36
+ 'logo-32x32': URLExt.join(PageConfig.getBaseUrl(), 'xeus/kernels/' + kernel + '/logo-32x32.png'),
37
+ 'logo-64x64': URLExt.join(PageConfig.getBaseUrl(), 'xeus/kernels/' + kernel + '/logo-64x64.png')
38
+ };
53
39
  kernelspecs.register({
54
40
  spec: kernelspec,
55
41
  create: async (options) => {
@@ -69,7 +55,5 @@ const server_kernels = kernel_specs.map(kernelspec => {
69
55
  });
70
56
  }
71
57
  };
72
- return server_kernel;
73
58
  });
74
- const plugins = server_kernels;
75
59
  export default plugins;
@@ -17,24 +17,19 @@ export class WebWorkerKernel {
17
17
  this._executeDelegate = new PromiseDelegate();
18
18
  this._parentHeader = undefined;
19
19
  this._parent = undefined;
20
- console.log('constructing WebWorkerKernel kernel');
21
20
  const { id, name, sendMessage, location } = options;
22
21
  this._id = id;
23
22
  this._name = name;
24
23
  this._location = location;
25
24
  this._kernelspec = options.kernelspec;
26
25
  this._sendMessage = sendMessage;
27
- console.log('constructing WebWorkerKernel worker');
28
26
  this._worker = new Worker(new URL('./worker.js', import.meta.url), {
29
27
  type: 'module'
30
28
  });
31
- console.log('constructing WebWorkerKernel done');
32
29
  this._worker.onmessage = e => {
33
30
  this._processWorkerMessage(e.data);
34
31
  };
35
- console.log('wrap');
36
32
  this._remote = wrap(this._worker);
37
- console.log('wrap done');
38
33
  this._remote.processMessage({
39
34
  msg: {
40
35
  header: {
@@ -43,26 +38,19 @@ export class WebWorkerKernel {
43
38
  kernelspec: this._kernelspec
44
39
  }
45
40
  });
46
- console.log('init filesystem');
47
41
  this.initFileSystem(options);
48
- console.log('constructing WebWorkerKernel done2');
49
42
  }
50
43
  async handleMessage(msg) {
51
- console.log('handleMessage', msg);
52
44
  this._parent = msg;
53
45
  this._parentHeader = msg.header;
54
- console.log('send message to worker');
55
46
  await this._sendMessageToWorker(msg);
56
- console.log('send message to worker awaiting done');
57
47
  }
58
48
  async _sendMessageToWorker(msg) {
59
49
  // TODO Remove this??
60
50
  if (msg.header.msg_type !== 'input_reply') {
61
51
  this._executeDelegate = new PromiseDelegate();
62
52
  }
63
- console.log(' this._remote.processMessage({ msg, parent: this.parent });');
64
53
  await this._remote.processMessage({ msg, parent: this.parent });
65
- console.log(' this._remote.processMessage({ msg, parent: this.parent }); done');
66
54
  if (msg.header.msg_type !== 'input_reply') {
67
55
  return await this._executeDelegate.promise;
68
56
  }
@@ -92,7 +80,6 @@ export class WebWorkerKernel {
92
80
  */
93
81
  _processWorkerMessage(msg) {
94
82
  var _a, _b, _c, _d;
95
- console.log('processWorkerMessage', msg);
96
83
  if (!msg.header) {
97
84
  return;
98
85
  }
package/lib/worker.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see worker.js.LICENSE.txt */
2
- define((()=>(()=>{"use strict";var e={};(e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})})(e);const t=Symbol("Comlink.proxy"),r=Symbol("Comlink.endpoint"),s=Symbol("Comlink.releaseProxy"),n=Symbol("Comlink.finalizer"),i=Symbol("Comlink.thrown"),o=e=>"object"==typeof e&&null!==e||"function"==typeof e,a=new Map([["proxy",{canHandle:e=>o(e)&&e[t],serialize(e){const{port1:t,port2:r}=new MessageChannel;return l(e,t),[r,[r]]},deserialize:e=>(e.start(),p(e,[],undefined))}],["throw",{canHandle:e=>o(e)&&i in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function l(e,r=globalThis,s=["*"]){r.addEventListener("message",(function o(a){if(!a||!a.data)return;if(!function(e,t){for(const r of e){if(t===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(t))return!0}return!1}(s,a.origin))return void console.warn(`Invalid origin '${a.origin}' for comlink proxy`);const{id:u,type:d,path:c}=Object.assign({path:[]},a.data),m=(a.data.argumentList||[]).map(w);let p;try{const r=c.slice(0,-1).reduce(((e,t)=>e[t]),e),s=c.reduce(((e,t)=>e[t]),e);switch(d){case"GET":p=s;break;case"SET":r[c.slice(-1)[0]]=w(a.data.value),p=!0;break;case"APPLY":p=s.apply(r,m);break;case"CONSTRUCT":p=function(e){return Object.assign(e,{[t]:!0})}(new s(...m));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;l(e,r),p=function(e,t){return g.set(e,t),e}(t,[t])}break;case"RELEASE":p=void 0;break;default:return}}catch(e){p={value:e,[i]:0}}Promise.resolve(p).catch((e=>({value:e,[i]:0}))).then((t=>{const[s,i]=E(t);r.postMessage(Object.assign(Object.assign({},s),{id:u}),i),"RELEASE"===d&&(r.removeEventListener("message",o),h(r),n in e&&"function"==typeof e[n]&&e[n]())})).catch((e=>{const[t,s]=E({value:new TypeError("Unserializable return value"),[i]:0});r.postMessage(Object.assign(Object.assign({},t),{id:u}),s)}))})),r.start&&r.start()}function h(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function u(e){if(e)throw new Error("Proxy has been released and is not useable")}function d(e){return y(e,{type:"RELEASE"}).then((()=>{h(e)}))}const c=new WeakMap,m="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(c.get(e)||0)-1;c.set(e,t),0===t&&d(e)}));function p(e,t=[],n=function(){}){let i=!1;const o=new Proxy(n,{get(r,n){if(u(i),n===s)return()=>{!function(e){m&&m.unregister(e)}(o),d(e),i=!0};if("then"===n){if(0===t.length)return{then:()=>o};const r=y(e,{type:"GET",path:t.map((e=>e.toString()))}).then(w);return r.then.bind(r)}return p(e,[...t,n])},set(r,s,n){u(i);const[o,a]=E(n);return y(e,{type:"SET",path:[...t,s].map((e=>e.toString())),value:o},a).then(w)},apply(s,n,o){u(i);const a=t[t.length-1];if(a===r)return y(e,{type:"ENDPOINT"}).then(w);if("bind"===a)return p(e,t.slice(0,-1));const[l,h]=f(o);return y(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:l},h).then(w)},construct(r,s){u(i);const[n,o]=f(s);return y(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:n},o).then(w)}});return function(e,t){const r=(c.get(t)||0)+1;c.set(t,r),m&&m.register(e,t,e)}(o,e),o}function f(e){const t=e.map(E);return[t.map((e=>e[0])),(r=t.map((e=>e[1])),Array.prototype.concat.apply([],r))];var r}const g=new WeakMap;function E(e){for(const[t,r]of a)if(r.canHandle(e)){const[s,n]=r.serialize(e);return[{type:"HANDLER",name:t,value:s},n]}return[{type:"RAW",value:e},g.get(e)||[]]}function w(e){switch(e.type){case"HANDLER":return a.get(e.name).deserialize(e.value);case"RAW":return e.value}}function y(e,t,r){return new Promise((s=>{const n=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(r){r.data&&r.data.id&&r.data.id===n&&(e.removeEventListener("message",t),s(r.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:n},t),r)}))}const _=new TextEncoder,b=new TextDecoder("utf-8"),v={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};class P{constructor(e){this.fs=e}open(e){const t=this.fs.realPath(e.node);this.fs.FS.isFile(e.node.mode)&&(e.file=this.fs.API.get(t))}close(e){if(!this.fs.FS.isFile(e.node.mode)||!e.file)return;const t=this.fs.realPath(e.node),r=e.flags;let s="string"==typeof r?parseInt(r,10):r;s&=8191;let n=!0;s in v&&(n=v[s]),n&&this.fs.API.put(t,e.file),e.file=void 0}read(e,t,r,s,n){if(s<=0||void 0===e.file||n>=(e.file.data.length||0))return 0;const i=Math.min(e.file.data.length-n,s);return t.set(e.file.data.subarray(n,n+i),r),i}write(e,t,r,s,n){var i;if(s<=0||void 0===e.file)return 0;if(e.node.timestamp=Date.now(),n+s>((null===(i=e.file)||void 0===i?void 0:i.data.length)||0)){const t=e.file.data?e.file.data:new Uint8Array;e.file.data=new Uint8Array(n+s),e.file.data.set(t)}return e.file.data.set(t.subarray(r,r+s),n),s}llseek(e,t,r){let s=t;if(1===r)s+=e.position;else if(2===r&&this.fs.FS.isFile(e.node.mode)){if(void 0===e.file)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM);s+=e.file.data.length}if(s<0)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EINVAL);return s}}class S{constructor(e){this.fs=e}getattr(e){return{...this.fs.API.getattr(this.fs.realPath(e)),mode:e.mode,ino:e.id}}setattr(e,t){for(const[r,s]of Object.entries(t))switch(r){case"mode":e.mode=s;break;case"timestamp":e.timestamp=s;break;default:console.warn("setattr",r,"of",s,"on",e,"not yet implemented")}}lookup(e,t){const r=this.fs.PATH.join2(this.fs.realPath(e),t),s=this.fs.API.lookup(r);if(!s.ok)throw this.fs.FS.genericErrors[this.fs.ERRNO_CODES.ENOENT];return this.fs.createNode(e,t,s.mode,0)}mknod(e,t,r,s){const n=this.fs.PATH.join2(this.fs.realPath(e),t);return this.fs.API.mknod(n,r),this.fs.createNode(e,t,r,s)}rename(e,t,r){this.fs.API.rename(e.parent?this.fs.PATH.join2(this.fs.realPath(e.parent),e.name):e.name,this.fs.PATH.join2(this.fs.realPath(t),r)),e.name=r,e.parent=t}unlink(e,t){this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(e),t))}rmdir(e,t){this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(e),t))}readdir(e){return this.fs.API.readdir(this.fs.realPath(e))}symlink(e,t,r){throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM)}readlink(e){throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM)}}class T{constructor(e,t,r,s,n){this._baseUrl=e,this._driveName=t,this._mountpoint=r,this.FS=s,this.ERRNO_CODES=n}request(e){const t=new XMLHttpRequest;t.open("POST",encodeURI(this.endpoint),!1);try{t.send(JSON.stringify(e))}catch(e){console.error(e)}if(t.status>=400)throw new this.FS.ErrnoError(this.ERRNO_CODES.EINVAL);return JSON.parse(t.responseText)}lookup(e){return this.request({method:"lookup",path:this.normalizePath(e)})}getmode(e){return Number.parseInt(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){const 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){const t=this.request({method:"get",path:this.normalizePath(e)}),r=t.content,s=t.format;switch(s){case"json":case"text":return{data:_.encode(r),format:s};case"base64":{const e=atob(r),t=e.length,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);return{data:n,format:s}}default:throw new this.FS.ErrnoError(this.ERRNO_CODES.ENOENT)}}put(e,t){switch(t.format){case"json":case"text":return this.request({method:"put",path:this.normalizePath(e),data:{format:t.format,data:b.decode(t.data)}});case"base64":{let r="";for(let e=0;e<t.data.byteLength;e++)r+=String.fromCharCode(t.data[e]);return this.request({method:"put",path:this.normalizePath(e),data:{format:t.format,data:btoa(r)}})}}}getattr(e){const t=this.request({method:"getattr",path:this.normalizePath(e)});return t.atime=new Date(t.atime),t.mtime=new Date(t.mtime),t.ctime=new Date(t.ctime),t.size=t.size||0,t}normalizePath(e){return e.startsWith(this._mountpoint)&&(e=e.slice(this._mountpoint.length)),this._driveName&&(e=`${this._driveName}:${e}`),e}get endpoint(){return`${this._baseUrl}api/drive`}}class N{constructor(e){this.FS=e.FS,this.PATH=e.PATH,this.ERRNO_CODES=e.ERRNO_CODES,this.API=new T(e.baseUrl,e.driveName,e.mountpoint,this.FS,this.ERRNO_CODES),this.driveName=e.driveName,this.node_ops=new S(this),this.stream_ops=new P(this)}mount(e){return this.createNode(null,e.mountpoint,16895,0)}createNode(e,t,r,s){const n=this.FS;if(!n.isDir(r)&&!n.isFile(r))throw new n.ErrnoError(this.ERRNO_CODES.EINVAL);const i=n.createNode(e,t,r,s);return i.node_ops=this.node_ops,i.stream_ops=this.stream_ops,i}getMode(e){return this.API.getmode(e)}realPath(e){const t=[];let r=e;for(t.push(r.name);r.parent!==r;)r=r.parent,t.push(r.name);return t.reverse(),this.PATH.join.apply(null,t)}}console.log("worker loaded"),globalThis.Module={};class R extends S{getNode(e){return e.node?e.node:e}lookup(e,t){return super.lookup(this.getNode(e),t)}getattr(e){return super.getattr(this.getNode(e))}setattr(e,t){super.setattr(this.getNode(e),t)}mknod(e,t,r,s){return super.mknod(this.getNode(e),t,r,s)}rename(e,t,r){super.rename(this.getNode(e),this.getNode(t),r)}rmdir(e,t){super.rmdir(this.getNode(e),t)}readdir(e){return super.readdir(this.getNode(e))}}class k extends N{constructor(e){super(e),this.node_ops=new R(this)}}let O;globalThis.toplevel_promise=null,globalThis.toplevel_promise_py_proxy=null,self.get_stdin=async function(){return new Promise((e=>{O=e}))};class A{constructor(e){this._drive=null,console.log("constructing kernel"),this._resolve=e}async ready(){return await globalThis.ready}mount(e,t,r){console.log("mounting drive");const{FS:s,PATH:n,ERRNO_CODES:i}=globalThis.Module;s&&(this._drive=new k({FS:s,PATH:n,ERRNO_CODES:i,baseUrl:r,driveName:e,mountpoint:t}),s.mkdir(t),s.mount(this._drive,{},t),s.chdir(t))}cd(e){e&&globalThis.Module.FS&&globalThis.Module.FS.chdir(e)}async processMessage(e){const t=e.msg.header.msg_type;if("__initialize__"===t)return this._kernelspec=e.msg.kernelspec,void await this.initialize();await this.ready(),null!==globalThis.toplevel_promise&&null!==globalThis.toplevel_promise_py_proxy&&(await globalThis.toplevel_promise,globalThis.toplevel_promise_py_proxy.delete(),globalThis.toplevel_promise_py_proxy=null,globalThis.toplevel_promise=null),"input_reply"===t?O(e.msg):this._raw_xserver.notify_listener(e.msg)}async initialize(){const e=this._kernelspec.dir,t=this._kernelspec.argv[0],r=t.replace(".js",".wasm");importScripts(t),globalThis.Module=await createXeusModule({locateFile:e=>e.endsWith(".wasm")?r:e});try{if(await this.waitRunDependency(),console.log(globalThis.Module),void 0!==globalThis.Module.async_init){const t=`share/jupyter/kernels/${e}`,r="share/jupyter/kernel_packages",s=!0;await globalThis.Module.async_init(t,r,s)}await this.waitRunDependency(),this._raw_xkernel=new globalThis.Module.xkernel,this._raw_xserver=this._raw_xkernel.get_server(),this._raw_xkernel||console.error("Failed to start kernel!"),this._raw_xkernel.start()}catch(e){if("number"==typeof e){const t=globalThis.Module.get_exception_message(e);throw console.error(t),new Error(t)}throw console.error(e),e}this._resolve()}async waitRunDependency(){const e=new Promise((e=>{globalThis.Module.monitorRunDependencies=t=>{0===t&&e()}}));return globalThis.Module.addRunDependency("dummy"),globalThis.Module.removeRunDependency("dummy"),e}}return globalThis.ready=new Promise((e=>{console.log("expose(new XeusKernel(resolve));"),l(new A(e))})),e})()));
2
+ define((()=>(()=>{var __webpack_modules__={542:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ActivityMonitor=void 0;const r=n(521);t.ActivityMonitor=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)}}},622:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(542),t),o(n(86),t),o(n(390),t),o(n(458),t),o(n(176),t),o(n(643),t),o(n(846),t),o(n(533),t),o(n(319),t)},86:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},390:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MarkdownCodeBlocks=void 0,function(e){e.CODE_BLOCK_MARKER="```";const t=[".markdown",".mdown",".mkdn",".md",".mkd",".mdwn",".mdtxt",".mdtext",".text",".txt",".Rmd"];class n{constructor(e){this.startLine=e,this.code="",this.endLine=-1}}e.MarkdownCodeBlock=n,e.isMarkdown=function(e){return t.indexOf(e)>-1},e.findMarkdownCodeBlocks=function(t){if(!t||""===t)return[];const r=t.split("\n"),o=[];let i=null;for(let t=0;t<r.length;t++){const s=r[t],a=0===s.indexOf(e.CODE_BLOCK_MARKER),l=null!=i;if(a||l)if(l)i&&(a?(i.endLine=t-1,o.push(i),i=null):i.code+=s+"\n");else{i=new n(t);const r=s.indexOf(e.CODE_BLOCK_MARKER),a=s.lastIndexOf(e.CODE_BLOCK_MARKER);r!==a&&(i.code=s.substring(r+e.CODE_BLOCK_MARKER.length,a),i.endLine=t,o.push(i),i=null)}}return o}}(t.MarkdownCodeBlocks||(t.MarkdownCodeBlocks={}))},458:function(__unused_webpack_module,exports,__webpack_require__){"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageConfig=void 0;const coreutils_1=__webpack_require__(82),minimist_1=__importDefault(__webpack_require__(562)),url_1=__webpack_require__(319);var PageConfig;(function(PageConfig){function getOption(name){if(configData)return configData[name]||getBodyData(name);configData=Object.create(null);let found=!1;if("undefined"!=typeof document&&document){const e=document.getElementById("jupyter-config-data");e&&(configData=JSON.parse(e.textContent||""),found=!0)}if(!found&&"undefined"!=typeof process&&process.argv)try{const cli=(0,minimist_1.default)(process.argv.slice(2)),path=__webpack_require__(470);let 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(e){console.error(e)}if(coreutils_1.JSONExt.isObject(configData))for(const e in configData)"string"!=typeof configData[e]&&(configData[e]=JSON.stringify(configData[e]));else configData=Object.create(null);return configData[name]||getBodyData(name)}function setOption(e,t){const n=getOption(e);return configData[e]=t,n}function getBaseUrl(){return url_1.URLExt.normalize(getOption("baseUrl")||"/")}function getTreeUrl(){return url_1.URLExt.join(getBaseUrl(),getOption("treeUrl"))}function getShareUrl(){return url_1.URLExt.normalize(getOption("shareUrl")||getBaseUrl())}function getTreeShareUrl(){return url_1.URLExt.normalize(url_1.URLExt.join(getShareUrl(),getOption("treeUrl")))}function getUrl(e){var t,n,r,o;let i=e.toShare?getShareUrl():getBaseUrl();const s=null!==(t=e.mode)&&void 0!==t?t:getOption("mode"),a=null!==(n=e.workspace)&&void 0!==n?n:getOption("workspace"),l="single-document"===s?"doc":"lab";i=url_1.URLExt.join(i,l),a!==PageConfig.defaultWorkspace&&(i=url_1.URLExt.join(i,"workspaces",encodeURIComponent(null!==(r=getOption("workspace"))&&void 0!==r?r:PageConfig.defaultWorkspace)));const c=null!==(o=e.treePath)&&void 0!==o?o:getOption("treePath");return c&&(i=url_1.URLExt.join(i,"tree",url_1.URLExt.encodeParts(c))),i}function getWsUrl(e){let t=getOption("wsUrl");if(!t){if(0!==(e=e?url_1.URLExt.normalize(e):getBaseUrl()).indexOf("http"))return"";t="ws"+e.slice(4)}return url_1.URLExt.normalize(t)}function getNBConvertURL({path:e,format:t,download:n}){const r=url_1.URLExt.encodeParts(e),o=url_1.URLExt.join(getBaseUrl(),"nbconvert",t,r);return n?o+"?download=true":o}function getToken(){return getOption("token")||getBodyData("jupyterApiToken")}function getNotebookVersion(){const e=getOption("notebookVersion");return""===e?[0,0,0]:JSON.parse(e)}PageConfig.getOption=getOption,PageConfig.setOption=setOption,PageConfig.getBaseUrl=getBaseUrl,PageConfig.getTreeUrl=getTreeUrl,PageConfig.getShareUrl=getShareUrl,PageConfig.getTreeShareUrl=getTreeShareUrl,PageConfig.getUrl=getUrl,PageConfig.defaultWorkspace="default",PageConfig.getWsUrl=getWsUrl,PageConfig.getNBConvertURL=getNBConvertURL,PageConfig.getToken=getToken,PageConfig.getNotebookVersion=getNotebookVersion;let configData=null,Extension;function getBodyData(e){if("undefined"==typeof document||!document.body)return"";const t=document.body.dataset[e];return void 0===t?"":decodeURIComponent(t)}!function(e){function t(e){try{const t=getOption(e);if(t)return JSON.parse(t)}catch(t){console.warn(`Unable to parse ${e}.`,t)}return[]}e.deferred=t("deferredExtensions"),e.disabled=t("disabledExtensions"),e.isDeferred=function(t){const n=t.indexOf(":");let r="";return-1!==n&&(r=t.slice(0,n)),e.deferred.some((e=>e===t||r&&e===r))},e.isDisabled=function(t){const n=t.indexOf(":");let r="";return-1!==n&&(r=t.slice(0,n)),e.disabled.some((e=>e===t||r&&e===r))}}(Extension=PageConfig.Extension||(PageConfig.Extension={}))})(PageConfig=exports.PageConfig||(exports.PageConfig={}))},176:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PathExt=void 0;const r=n(470);!function(e){function t(e){return 0===e.indexOf("/")&&(e=e.slice(1)),e}e.join=function(...e){const n=r.posix.join(...e);return"."===n?"":t(n)},e.basename=function(e,t){return r.posix.basename(e,t)},e.dirname=function(e){const n=t(r.posix.dirname(e));return"."===n?"":n},e.extname=function(e){return r.posix.extname(e)},e.normalize=function(e){return""===e?"":t(r.posix.normalize(e))},e.resolve=function(...e){return t(r.posix.resolve(...e))},e.relative=function(e,n){return t(r.posix.relative(e,n))},e.normalizeExtension=function(e){return e.length>0&&0!==e.indexOf(".")&&(e=`.${e}`),e},e.removeSlash=t}(t.PathExt||(t.PathExt={}))},643:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.signalToPromise=void 0;const r=n(82);t.signalToPromise=function(e,t){const n=new r.PromiseDelegate;function o(){e.disconnect(i)}function i(e,t){o(),n.resolve([e,t])}return e.connect(i),(null!=t?t:0)>0&&setTimeout((()=>{o(),n.reject(`Signal not emitted within ${t} ms.`)}),t),n.promise}},846:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.Text=void 0,(n=t.Text||(t.Text={})).jsIndexToCharIndex=function(e,t){return e},n.charIndexToJsIndex=function(e,t){return e},n.camelCase=function(e,t=!1){return e.replace(/^(\w)|[\s-_:]+(\w)/g,(function(e,n,r){return r?r.toUpperCase():t?n.toUpperCase():n.toLowerCase()}))},n.titleCase=function(e){return(e||"").toLowerCase().split(" ").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" ")}},533:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Time=void 0;const n=[{name:"years",milliseconds:31536e6},{name:"months",milliseconds:2592e6},{name:"days",milliseconds:864e5},{name:"hours",milliseconds:36e5},{name:"minutes",milliseconds:6e4},{name:"seconds",milliseconds:1e3}];var r;(r=t.Time||(t.Time={})).formatHuman=function(e){const t=document.documentElement.lang||"en",r=new Intl.RelativeTimeFormat(t,{numeric:"auto"}),o=new Date(e).getTime()-Date.now();for(let e of n){const t=Math.ceil(o/e.milliseconds);if(0!==t)return r.format(t,e.name)}return r.format(0,"seconds")},r.format=function(e){const t=document.documentElement.lang||"en";return new Intl.DateTimeFormat(t,{dateStyle:"short",timeStyle:"short"}).format(new Date(e))}},319:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.URLExt=void 0;const o=n(470),i=r(n(564));!function(e){function t(e){if("undefined"!=typeof document&&document){const t=document.createElement("a");return t.href=e,t}return(0,i.default)(e)}function n(...e){let t=(0,i.default)(e[0],{});const n=""===t.protocol&&t.slashes;n&&(t=(0,i.default)(e[0],"https:"+e[0]));const r=`${n?"":t.protocol}${t.slashes?"//":""}${t.auth}${t.auth?"@":""}${t.host}`,s=o.posix.join(`${r&&"/"!==t.pathname[0]?"/":""}${t.pathname}`,...e.slice(1));return`${r}${"."===s?"":s}`}e.parse=t,e.getHostName=function(e){return(0,i.default)(e).hostname},e.normalize=function(e){return e&&t(e).toString()},e.join=n,e.encodeParts=function(e){return n(...e.split("/").map(encodeURIComponent))},e.objectToQueryString=function(e){const t=Object.keys(e).filter((e=>e.length>0));return t.length?"?"+t.map((t=>{const n=encodeURIComponent(String(e[t]));return t+(n?"="+n:"")})).join("&"):""},e.queryStringToObject=function(e){return e.replace(/^\?/,"").split("&").reduce(((e,t)=>{const[n,r]=t.split("=");return n.length>0&&(e[n]=decodeURIComponent(r||"")),e}),{})},e.isLocal=function(e){const{protocol:n}=t(e);return(!n||0!==e.toLowerCase().indexOf(n))&&0!==e.indexOf("/")}}(t.URLExt||(t.URLExt={}))},82:function(e,t){!function(e){"use strict";e.JSONExt=void 0,function(e){function t(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e}function n(e){return Array.isArray(e)}function r(e,o){if(e===o)return!0;if(t(e)||t(o))return!1;let i=n(e),s=n(o);return i===s&&(i&&s?function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0,o=e.length;n<o;++n)if(!r(e[n],t[n]))return!1;return!0}(e,o):function(e,t){if(e===t)return!0;for(let n in e)if(void 0!==e[n]&&!(n in t))return!1;for(let n in t)if(void 0!==t[n]&&!(n in e))return!1;for(let n in e){let o=e[n],i=t[n];if(void 0!==o||void 0!==i){if(void 0===o||void 0===i)return!1;if(!r(o,i))return!1}}return!0}(e,o))}function o(e){return t(e)?e:n(e)?function(e){let t=new Array(e.length);for(let n=0,r=e.length;n<r;++n)t[n]=o(e[n]);return t}(e):function(e){let t={};for(let n in e){let r=e[n];void 0!==r&&(t[n]=o(r))}return t}(e)}e.emptyObject=Object.freeze({}),e.emptyArray=Object.freeze([]),e.isPrimitive=t,e.isArray=n,e.isObject=function(e){return!t(e)&&!n(e)},e.deepEqual=r,e.deepCopy=o}(e.JSONExt||(e.JSONExt={}));function t(e){let t=0;for(let n=0,r=e.length;n<r;++n)n%4==0&&(t=4294967295*Math.random()>>>0),e[n]=255&t,t>>>=8}e.Random=void 0,(e.Random||(e.Random={})).getRandomValues=(()=>{const e="undefined"!=typeof window&&(window.crypto||window.msCrypto)||null;return e&&"function"==typeof e.getRandomValues?function(t){return e.getRandomValues(t)}:t})(),e.UUID=void 0,(e.UUID||(e.UUID={})).uuid4=function(e){const t=new Uint8Array(16),n=new Array(256);for(let e=0;e<16;++e)n[e]="0"+e.toString(16);for(let e=16;e<256;++e)n[e]=e.toString(16);return function(){return e(t),t[6]=64|15&t[6],t[8]=128|63&t[8],n[t[0]]+n[t[1]]+n[t[2]]+n[t[3]]+"-"+n[t[4]]+n[t[5]]+"-"+n[t[6]]+n[t[7]]+"-"+n[t[8]]+n[t[9]]+"-"+n[t[10]]+n[t[11]]+n[t[12]]+n[t[13]]+n[t[14]]+n[t[15]]}}(e.Random.getRandomValues),e.MimeData=class{constructor(){this._types=[],this._values=[]}types(){return this._types.slice()}hasData(e){return-1!==this._types.indexOf(e)}getData(e){let t=this._types.indexOf(e);return-1!==t?this._values[t]:void 0}setData(e,t){this.clearData(e),this._types.push(e),this._values.push(t)}clearData(e){let t=this._types.indexOf(e);-1!==t&&(this._types.splice(t,1),this._values.splice(t,1))}clear(){this._types.length=0,this._values.length=0}},e.PromiseDelegate=class{constructor(){this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}resolve(e){(0,this._resolve)(e)}reject(e){(0,this._reject)(e)}},e.Token=class{constructor(e,t){this.name=e,this.description=null!=t?t:"",this._tokenStructuralPropertyT=null}}}(t)},521:(e,t,n)=>{"use strict";var r,o,i;n.r(t),n.d(t,{Signal:()=>l,Stream:()=>c}),function(e){function t(e,t,n=0,r=-1){let o,i=e.length;if(0===i)return-1;n=n<0?Math.max(0,n+i):Math.min(n,i-1),o=(r=r<0?Math.max(0,r+i):Math.min(r,i-1))<n?r+1+(i-n):r-n+1;for(let r=0;r<o;++r){let o=(n+r)%i;if(e[o]===t)return o}return-1}function n(e,t,n=-1,r=0){let o,i=e.length;if(0===i)return-1;o=(n=n<0?Math.max(0,n+i):Math.min(n,i-1))<(r=r<0?Math.max(0,r+i):Math.min(r,i-1))?n+1+(i-r):n-r+1;for(let r=0;r<o;++r){let o=(n-r+i)%i;if(e[o]===t)return o}return-1}function r(e,t,n=0,r=-1){let o,i=e.length;if(0===i)return-1;n=n<0?Math.max(0,n+i):Math.min(n,i-1),o=(r=r<0?Math.max(0,r+i):Math.min(r,i-1))<n?r+1+(i-n):r-n+1;for(let r=0;r<o;++r){let o=(n+r)%i;if(t(e[o],o))return o}return-1}function o(e,t,n=-1,r=0){let o,i=e.length;if(0===i)return-1;o=(n=n<0?Math.max(0,n+i):Math.min(n,i-1))<(r=r<0?Math.max(0,r+i):Math.min(r,i-1))?n+1+(i-r):n-r+1;for(let r=0;r<o;++r){let o=(n-r+i)%i;if(t(e[o],o))return o}return-1}function i(e,t=0,n=-1){let r=e.length;if(!(r<=1))for(t=t<0?Math.max(0,t+r):Math.min(t,r-1),n=n<0?Math.max(0,n+r):Math.min(n,r-1);t<n;){let r=e[t],o=e[n];e[t++]=o,e[n--]=r}}function s(e,t){let n=e.length;if(t<0&&(t+=n),t<0||t>=n)return;let r=e[t];for(let r=t+1;r<n;++r)e[r-1]=e[r];return e.length=n-1,r}e.firstIndexOf=t,e.lastIndexOf=n,e.findFirstIndex=r,e.findLastIndex=o,e.findFirstValue=function(e,t,n=0,o=-1){let i=r(e,t,n,o);return-1!==i?e[i]:void 0},e.findLastValue=function(e,t,n=-1,r=0){let i=o(e,t,n,r);return-1!==i?e[i]:void 0},e.lowerBound=function(e,t,n,r=0,o=-1){let i=e.length;if(0===i)return 0;let s=r=r<0?Math.max(0,r+i):Math.min(r,i-1),a=(o=o<0?Math.max(0,o+i):Math.min(o,i-1))-r+1;for(;a>0;){let r=a>>1,o=s+r;n(e[o],t)<0?(s=o+1,a-=r+1):a=r}return s},e.upperBound=function(e,t,n,r=0,o=-1){let i=e.length;if(0===i)return 0;let s=r=r<0?Math.max(0,r+i):Math.min(r,i-1),a=(o=o<0?Math.max(0,o+i):Math.min(o,i-1))-r+1;for(;a>0;){let r=a>>1,o=s+r;n(e[o],t)>0?a=r:(s=o+1,a-=r+1)}return s},e.shallowEqual=function(e,t,n){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0,o=e.length;r<o;++r)if(n?!n(e[r],t[r]):e[r]!==t[r])return!1;return!0},e.slice=function(e,t={}){let{start:n,stop:r,step:o}=t;if(void 0===o&&(o=1),0===o)throw new Error("Slice `step` cannot be zero.");let i,s=e.length;void 0===n?n=o<0?s-1:0:n<0?n=Math.max(n+s,o<0?-1:0):n>=s&&(n=o<0?s-1:s),void 0===r?r=o<0?-1:s:r<0?r=Math.max(r+s,o<0?-1:0):r>=s&&(r=o<0?s-1:s),i=o<0&&r>=n||o>0&&n>=r?0:o<0?Math.floor((r-n+1)/o+1):Math.floor((r-n-1)/o+1);let a=[];for(let t=0;t<i;++t)a[t]=e[n+t*o];return a},e.move=function(e,t,n){let r=e.length;if(r<=1)return;if((t=t<0?Math.max(0,t+r):Math.min(t,r-1))===(n=n<0?Math.max(0,n+r):Math.min(n,r-1)))return;let o=e[t],i=t<n?1:-1;for(let r=t;r!==n;r+=i)e[r]=e[r+i];e[n]=o},e.reverse=i,e.rotate=function(e,t,n=0,r=-1){let o=e.length;if(o<=1)return;if((n=n<0?Math.max(0,n+o):Math.min(n,o-1))>=(r=r<0?Math.max(0,r+o):Math.min(r,o-1)))return;let s=r-n+1;if(t>0?t%=s:t<0&&(t=(t%s+s)%s),0===t)return;let a=n+t;i(e,n,a-1),i(e,a,r),i(e,n,r)},e.fill=function(e,t,n=0,r=-1){let o,i=e.length;if(0!==i){n=n<0?Math.max(0,n+i):Math.min(n,i-1),o=(r=r<0?Math.max(0,r+i):Math.min(r,i-1))<n?r+1+(i-n):r-n+1;for(let r=0;r<o;++r)e[(n+r)%i]=t}},e.insert=function(e,t,n){let r=e.length;t=t<0?Math.max(0,t+r):Math.min(t,r);for(let n=r;n>t;--n)e[n]=e[n-1];e[t]=n},e.removeAt=s,e.removeFirstOf=function(e,n,r=0,o=-1){let i=t(e,n,r,o);return-1!==i&&s(e,i),i},e.removeLastOf=function(e,t,r=-1,o=0){let i=n(e,t,r,o);return-1!==i&&s(e,i),i},e.removeAllOf=function(e,t,n=0,r=-1){let o=e.length;if(0===o)return 0;n=n<0?Math.max(0,n+o):Math.min(n,o-1),r=r<0?Math.max(0,r+o):Math.min(r,o-1);let i=0;for(let s=0;s<o;++s)n<=r&&s>=n&&s<=r&&e[s]===t||r<n&&(s<=r||s>=n)&&e[s]===t?i++:i>0&&(e[s-i]=e[s]);return i>0&&(e.length=o-i),i},e.removeFirstWhere=function(e,t,n=0,o=-1){let i,a=r(e,t,n,o);return-1!==a&&(i=s(e,a)),{index:a,value:i}},e.removeLastWhere=function(e,t,n=-1,r=0){let i,a=o(e,t,n,r);return-1!==a&&(i=s(e,a)),{index:a,value:i}},e.removeAllWhere=function(e,t,n=0,r=-1){let o=e.length;if(0===o)return 0;n=n<0?Math.max(0,n+o):Math.min(n,o-1),r=r<0?Math.max(0,r+o):Math.min(r,o-1);let i=0;for(let s=0;s<o;++s)n<=r&&s>=n&&s<=r&&t(e[s],s)||r<n&&(s<=r||s>=n)&&t(e[s],s)?i++:i>0&&(e[s-i]=e[s]);return i>0&&(e.length=o-i),i}}(r||(r={})),function(e){e.rangeLength=function(e,t,n){return 0===n?1/0:e>t&&n>0||e<t&&n<0?0:Math.ceil((t-e)/n)}}(o||(o={})),function(e){function t(e,t,n=0){let r=new Array(t.length);for(let o=0,i=n,s=t.length;o<s;++o,++i){if(i=e.indexOf(t[o],i),-1===i)return null;r[o]=i}return r}e.findIndices=t,e.matchSumOfSquares=function(e,n,r=0){let o=t(e,n,r);if(!o)return null;let i=0;for(let e=0,t=o.length;e<t;++e){let t=o[e]-r;i+=t*t}return{score:i,indices:o}},e.matchSumOfDeltas=function(e,n,r=0){let o=t(e,n,r);if(!o)return null;let i=0,s=r-1;for(let e=0,t=o.length;e<t;++e){let t=o[e];i+=t-s-1,s=t}return{score:i,indices:o}},e.highlight=function(e,t,n){let r=[],o=0,i=0,s=t.length;for(;o<s;){let a=t[o],l=t[o];for(;++o<s&&t[o]===l+1;)l++;i<a&&r.push(e.slice(i,a)),a<l+1&&r.push(n(e.slice(a,l+1))),i=l+1}return i<e.length&&r.push(e.slice(i)),r},e.cmp=function(e,t){return e<t?-1:e>t?1:0}}(i||(i={}));var s,a=n(82);class l{constructor(e){this.sender=e}connect(e,t){return s.connect(this,e,t)}disconnect(e,t){return s.disconnect(this,e,t)}emit(e){s.emit(this,e)}}!function(e){e.disconnectBetween=function(e,t){s.disconnectBetween(e,t)},e.disconnectSender=function(e){s.disconnectSender(e)},e.disconnectReceiver=function(e){s.disconnectReceiver(e)},e.disconnectAll=function(e){s.disconnectAll(e)},e.clearData=function(e){s.disconnectAll(e)},e.getExceptionHandler=function(){return s.exceptionHandler},e.setExceptionHandler=function(e){let t=s.exceptionHandler;return s.exceptionHandler=e,t}}(l||(l={}));class c extends l{constructor(){super(...arguments),this._pending=new a.PromiseDelegate}async*[Symbol.asyncIterator](){let e=this._pending;for(;;)try{const{args:t,next:n}=await e.promise;e=n,yield t}catch(e){return}}emit(e){const t=this._pending,n=this._pending=new a.PromiseDelegate;t.resolve({args:e,next:n}),super.emit(e)}stop(){this._pending.promise.catch((()=>{})),this._pending.reject("stop"),this._pending=new a.PromiseDelegate}}!function(e){function t(e){let t=o.get(e);if(t&&0!==t.length){for(const e of t){if(!e.signal)continue;let t=e.thisArg||e.slot;e.signal=null,u(i.get(t))}u(t)}}function n(e){let t=i.get(e);if(t&&0!==t.length){for(const e of t){if(!e.signal)continue;let t=e.signal.sender;e.signal=null,u(o.get(t))}u(t)}}e.exceptionHandler=e=>{console.error(e)},e.connect=function(e,t,n){n=n||void 0;let r=o.get(e.sender);if(r||(r=[],o.set(e.sender,r)),l(r,e,t,n))return!1;let s=n||t,a=i.get(s);a||(a=[],i.set(s,a));let c={signal:e,slot:t,thisArg:n};return r.push(c),a.push(c),!0},e.disconnect=function(e,t,n){n=n||void 0;let r=o.get(e.sender);if(!r||0===r.length)return!1;let s=l(r,e,t,n);if(!s)return!1;let a=n||t,c=i.get(a);return s.signal=null,u(r),u(c),!0},e.disconnectBetween=function(e,t){let n=o.get(e);if(!n||0===n.length)return;let r=i.get(t);if(r&&0!==r.length){for(const t of r)t.signal&&t.signal.sender===e&&(t.signal=null);u(n),u(r)}},e.disconnectSender=t,e.disconnectReceiver=n,e.disconnectAll=function(e){t(e),n(e)},e.emit=function(e,t){let n=o.get(e.sender);if(n&&0!==n.length)for(let r=0,o=n.length;r<o;++r){let o=n[r];o.signal===e&&c(o,t)}};const o=new WeakMap,i=new WeakMap,s=new Set,a="function"==typeof requestAnimationFrame?requestAnimationFrame:setImmediate;function l(e,t,n,r){return function(e,o){for(const o of e)if((i=o).signal===t&&i.slot===n&&i.thisArg===r)return o;var i}(e)}function c(t,n){let{signal:r,slot:o,thisArg:i}=t;try{o.call(i,r.sender,n)}catch(t){e.exceptionHandler(t)}}function u(e){0===s.size&&a(f),s.add(e)}function f(){s.forEach(h),s.clear()}function h(e){r.removeAllWhere(e,d)}function d(e){return null===e.signal}}(s||(s={}))},562:e=>{"use strict";function t(e){return"number"==typeof e||!!/^0x[0-9a-f]+$/i.test(e)||/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function n(e,t){return"constructor"===t&&"function"==typeof e[t]||"__proto__"===t}e.exports=function(e,r){r||(r={});var o={bools:{},strings:{},unknownFn:null};"function"==typeof r.unknown&&(o.unknownFn=r.unknown),"boolean"==typeof r.boolean&&r.boolean?o.allBools=!0:[].concat(r.boolean).filter(Boolean).forEach((function(e){o.bools[e]=!0}));var i={};function s(e){return i[e].some((function(e){return o.bools[e]}))}Object.keys(r.alias||{}).forEach((function(e){i[e]=[].concat(r.alias[e]),i[e].forEach((function(t){i[t]=[e].concat(i[e].filter((function(e){return t!==e})))}))})),[].concat(r.string).filter(Boolean).forEach((function(e){o.strings[e]=!0,i[e]&&[].concat(i[e]).forEach((function(e){o.strings[e]=!0}))}));var a=r.default||{},l={_:[]};function c(e,t,r){for(var i=e,s=0;s<t.length-1;s++){var a=t[s];if(n(i,a))return;void 0===i[a]&&(i[a]={}),i[a]!==Object.prototype&&i[a]!==Number.prototype&&i[a]!==String.prototype||(i[a]={}),i[a]===Array.prototype&&(i[a]=[]),i=i[a]}var l=t[t.length-1];n(i,l)||(i!==Object.prototype&&i!==Number.prototype&&i!==String.prototype||(i={}),i===Array.prototype&&(i=[]),void 0===i[l]||o.bools[l]||"boolean"==typeof i[l]?i[l]=r:Array.isArray(i[l])?i[l].push(r):i[l]=[i[l],r])}function u(e,n,r){if(!r||!o.unknownFn||function(e,t){return o.allBools&&/^--[^=]+$/.test(t)||o.strings[e]||o.bools[e]||i[e]}(e,r)||!1!==o.unknownFn(r)){var s=!o.strings[e]&&t(n)?Number(n):n;c(l,e.split("."),s),(i[e]||[]).forEach((function(e){c(l,e.split("."),s)}))}}Object.keys(o.bools).forEach((function(e){u(e,void 0!==a[e]&&a[e])}));var f=[];-1!==e.indexOf("--")&&(f=e.slice(e.indexOf("--")+1),e=e.slice(0,e.indexOf("--")));for(var h=0;h<e.length;h++){var d,p,m=e[h];if(/^--.+=/.test(m)){var g=m.match(/^--([^=]+)=([\s\S]*)$/);d=g[1];var _=g[2];o.bools[d]&&(_="false"!==_),u(d,_,m)}else if(/^--no-.+/.test(m))u(d=m.match(/^--no-(.+)/)[1],!1,m);else if(/^--.+/.test(m))d=m.match(/^--(.+)/)[1],void 0===(p=e[h+1])||/^(-|--)[^-]/.test(p)||o.bools[d]||o.allBools||i[d]&&s(d)?/^(true|false)$/.test(p)?(u(d,"true"===p,m),h+=1):u(d,!o.strings[d]||"",m):(u(d,p,m),h+=1);else if(/^-[^-]+/.test(m)){for(var v=m.slice(1,-1).split(""),y=!1,w=0;w<v.length;w++)if("-"!==(p=m.slice(w+2))){if(/[A-Za-z]/.test(v[w])&&"="===p[0]){u(v[w],p.slice(1),m),y=!0;break}if(/[A-Za-z]/.test(v[w])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(p)){u(v[w],p,m),y=!0;break}if(v[w+1]&&v[w+1].match(/\W/)){u(v[w],m.slice(w+2),m),y=!0;break}u(v[w],!o.strings[v[w]]||"",m)}else u(v[w],p,m);d=m.slice(-1)[0],y||"-"===d||(!e[h+1]||/^(-|--)[^-]/.test(e[h+1])||o.bools[d]||i[d]&&s(d)?e[h+1]&&/^(true|false)$/.test(e[h+1])?(u(d,"true"===e[h+1],m),h+=1):u(d,!o.strings[d]||"",m):(u(d,e[h+1],m),h+=1))}else if(o.unknownFn&&!1===o.unknownFn(m)||l._.push(o.strings._||!t(m)?m:Number(m)),r.stopEarly){l._.push.apply(l._,e.slice(h+1));break}}return Object.keys(a).forEach((function(e){var t,n,r;t=l,n=e.split("."),r=t,n.slice(0,-1).forEach((function(e){r=r[e]||{}})),n[n.length-1]in r||(c(l,e.split("."),a[e]),(i[e]||[]).forEach((function(t){c(l,t.split("."),a[e])})))})),r["--"]?l["--"]=f.slice():f.forEach((function(e){l._.push(e)})),l}},470:e=>{"use strict";function t(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function n(e,t){for(var n,r="",o=0,i=-1,s=0,a=0;a<=e.length;++a){if(a<e.length)n=e.charCodeAt(a);else{if(47===n)break;n=47}if(47===n){if(i===a-1||1===s);else if(i!==a-1&&2===s){if(r.length<2||2!==o||46!==r.charCodeAt(r.length-1)||46!==r.charCodeAt(r.length-2))if(r.length>2){var l=r.lastIndexOf("/");if(l!==r.length-1){-1===l?(r="",o=0):o=(r=r.slice(0,l)).length-1-r.lastIndexOf("/"),i=a,s=0;continue}}else if(2===r.length||1===r.length){r="",o=0,i=a,s=0;continue}t&&(r.length>0?r+="/..":r="..",o=2)}else r.length>0?r+="/"+e.slice(i+1,a):r=e.slice(i+1,a),o=a-i-1;i=a,s=0}else 46===n&&-1!==s?++s:s=-1}return r}var r={resolve:function(){for(var e,r="",o=!1,i=arguments.length-1;i>=-1&&!o;i--){var s;i>=0?s=arguments[i]:(void 0===e&&(e=process.cwd()),s=e),t(s),0!==s.length&&(r=s+"/"+r,o=47===s.charCodeAt(0))}return r=n(r,!o),o?r.length>0?"/"+r:"/":r.length>0?r:"."},normalize:function(e){if(t(e),0===e.length)return".";var r=47===e.charCodeAt(0),o=47===e.charCodeAt(e.length-1);return 0!==(e=n(e,!r)).length||r||(e="."),e.length>0&&o&&(e+="/"),r?"/"+e:e},isAbsolute:function(e){return t(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,n=0;n<arguments.length;++n){var o=arguments[n];t(o),o.length>0&&(void 0===e?e=o:e+="/"+o)}return void 0===e?".":r.normalize(e)},relative:function(e,n){if(t(e),t(n),e===n)return"";if((e=r.resolve(e))===(n=r.resolve(n)))return"";for(var o=1;o<e.length&&47===e.charCodeAt(o);++o);for(var i=e.length,s=i-o,a=1;a<n.length&&47===n.charCodeAt(a);++a);for(var l=n.length-a,c=s<l?s:l,u=-1,f=0;f<=c;++f){if(f===c){if(l>c){if(47===n.charCodeAt(a+f))return n.slice(a+f+1);if(0===f)return n.slice(a+f)}else s>c&&(47===e.charCodeAt(o+f)?u=f:0===f&&(u=0));break}var h=e.charCodeAt(o+f);if(h!==n.charCodeAt(a+f))break;47===h&&(u=f)}var d="";for(f=o+u+1;f<=i;++f)f!==i&&47!==e.charCodeAt(f)||(0===d.length?d+="..":d+="/..");return d.length>0?d+n.slice(a+u):(a+=u,47===n.charCodeAt(a)&&++a,n.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(t(e),0===e.length)return".";for(var n=e.charCodeAt(0),r=47===n,o=-1,i=!0,s=e.length-1;s>=1;--s)if(47===(n=e.charCodeAt(s))){if(!i){o=s;break}}else i=!1;return-1===o?r?"/":".":r&&1===o?"//":e.slice(0,o)},basename:function(e,n){if(void 0!==n&&"string"!=typeof n)throw new TypeError('"ext" argument must be a string');t(e);var r,o=0,i=-1,s=!0;if(void 0!==n&&n.length>0&&n.length<=e.length){if(n.length===e.length&&n===e)return"";var a=n.length-1,l=-1;for(r=e.length-1;r>=0;--r){var c=e.charCodeAt(r);if(47===c){if(!s){o=r+1;break}}else-1===l&&(s=!1,l=r+1),a>=0&&(c===n.charCodeAt(a)?-1==--a&&(i=r):(a=-1,i=l))}return o===i?i=l:-1===i&&(i=e.length),e.slice(o,i)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!s){o=r+1;break}}else-1===i&&(s=!1,i=r+1);return-1===i?"":e.slice(o,i)},extname:function(e){t(e);for(var n=-1,r=0,o=-1,i=!0,s=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===o&&(i=!1,o=a+1),46===l?-1===n?n=a:1!==s&&(s=1):-1!==n&&(s=-1);else if(!i){r=a+1;break}}return-1===n||-1===o||0===s||1===s&&n===o-1&&n===r+1?"":e.slice(n,o)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+r:n+"/"+r:r}(0,e)},parse:function(e){t(e);var n={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return n;var r,o=e.charCodeAt(0),i=47===o;i?(n.root="/",r=1):r=0;for(var s=-1,a=0,l=-1,c=!0,u=e.length-1,f=0;u>=r;--u)if(47!==(o=e.charCodeAt(u)))-1===l&&(c=!1,l=u+1),46===o?-1===s?s=u:1!==f&&(f=1):-1!==s&&(f=-1);else if(!c){a=u+1;break}return-1===s||-1===l||0===f||1===f&&s===l-1&&s===a+1?-1!==l&&(n.base=n.name=0===a&&i?e.slice(1,l):e.slice(a,l)):(0===a&&i?(n.name=e.slice(1,s),n.base=e.slice(1,l)):(n.name=e.slice(a,s),n.base=e.slice(a,l)),n.ext=e.slice(s,l)),a>0?n.dir=e.slice(0,a-1):i&&(n.dir="/"),n},sep:"/",delimiter:":",win32:null,posix:null};r.posix=r,e.exports=r},129:(e,t)=>{"use strict";var n=Object.prototype.hasOwnProperty;function r(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function o(e){try{return encodeURIComponent(e)}catch(e){return null}}t.stringify=function(e,t){t=t||"";var r,i,s=[];for(i in"string"!=typeof t&&(t="?"),e)if(n.call(e,i)){if((r=e[i])||null!=r&&!isNaN(r)||(r=""),i=o(i),r=o(r),null===i||null===r)continue;s.push(i+"="+r)}return s.length?t+s.join("&"):""},t.parse=function(e){for(var t,n=/([^=?#&]+)=?([^&]*)/g,o={};t=n.exec(e);){var i=r(t[1]),s=r(t[2]);null===i||null===s||i in o||(o[i]=s)}return o}},418:e=>{"use strict";e.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},564:(e,t,n)=>{"use strict";var r=n(418),o=n(129),i=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,s=/[\n\r\t]/g,a=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,l=/:\d+$/,c=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,u=/^[a-zA-Z]:/;function f(e){return(e||"").toString().replace(i,"")}var h=[["#","hash"],["?","query"],function(e,t){return m(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]],d={hash:1,query:1};function p(e){var t,r=("undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{}).location||{},o={},i=typeof(e=e||r);if("blob:"===e.protocol)o=new _(unescape(e.pathname),{});else if("string"===i)for(t in o=new _(e,{}),d)delete o[t];else if("object"===i){for(t in e)t in d||(o[t]=e[t]);void 0===o.slashes&&(o.slashes=a.test(e.href))}return o}function m(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function g(e,t){e=(e=f(e)).replace(s,""),t=t||{};var n,r=c.exec(e),o=r[1]?r[1].toLowerCase():"",i=!!r[2],a=!!r[3],l=0;return i?a?(n=r[2]+r[3]+r[4],l=r[2].length+r[3].length):(n=r[2]+r[4],l=r[2].length):a?(n=r[3]+r[4],l=r[3].length):n=r[4],"file:"===o?l>=2&&(n=n.slice(2)):m(o)?n=r[4]:o?i&&(n=n.slice(2)):l>=2&&m(t.protocol)&&(n=r[4]),{protocol:o,slashes:i||m(o),slashesCount:l,rest:n}}function _(e,t,n){if(e=(e=f(e)).replace(s,""),!(this instanceof _))return new _(e,t,n);var i,a,l,c,d,v,y=h.slice(),w=typeof t,b=this,x=0;for("object"!==w&&"string"!==w&&(n=t,t=null),n&&"function"!=typeof n&&(n=o.parse),i=!(a=g(e||"",t=p(t))).protocol&&!a.slashes,b.slashes=a.slashes||i&&t.slashes,b.protocol=a.protocol||t.protocol||"",e=a.rest,("file:"===a.protocol&&(2!==a.slashesCount||u.test(e))||!a.slashes&&(a.protocol||a.slashesCount<2||!m(b.protocol)))&&(y[3]=[/(.*)/,"pathname"]);x<y.length;x++)"function"!=typeof(c=y[x])?(l=c[0],v=c[1],l!=l?b[v]=e:"string"==typeof l?~(d="@"===l?e.lastIndexOf(l):e.indexOf(l))&&("number"==typeof c[2]?(b[v]=e.slice(0,d),e=e.slice(d+c[2])):(b[v]=e.slice(d),e=e.slice(0,d))):(d=l.exec(e))&&(b[v]=d[1],e=e.slice(0,d.index)),b[v]=b[v]||i&&c[3]&&t[v]||"",c[4]&&(b[v]=b[v].toLowerCase())):e=c(e,b);n&&(b.query=n(b.query)),i&&t.slashes&&"/"!==b.pathname.charAt(0)&&(""!==b.pathname||""!==t.pathname)&&(b.pathname=function(e,t){if(""===e)return t;for(var n=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=n.length,o=n[r-1],i=!1,s=0;r--;)"."===n[r]?n.splice(r,1):".."===n[r]?(n.splice(r,1),s++):s&&(0===r&&(i=!0),n.splice(r,1),s--);return i&&n.unshift(""),"."!==o&&".."!==o||n.push(""),n.join("/")}(b.pathname,t.pathname)),"/"!==b.pathname.charAt(0)&&m(b.protocol)&&(b.pathname="/"+b.pathname),r(b.port,b.protocol)||(b.host=b.hostname,b.port=""),b.username=b.password="",b.auth&&(~(d=b.auth.indexOf(":"))?(b.username=b.auth.slice(0,d),b.username=encodeURIComponent(decodeURIComponent(b.username)),b.password=b.auth.slice(d+1),b.password=encodeURIComponent(decodeURIComponent(b.password))):b.username=encodeURIComponent(decodeURIComponent(b.auth)),b.auth=b.password?b.username+":"+b.password:b.username),b.origin="file:"!==b.protocol&&m(b.protocol)&&b.host?b.protocol+"//"+b.host:"null",b.href=b.toString()}_.prototype={set:function(e,t,n){var i=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(n||o.parse)(t)),i[e]=t;break;case"port":i[e]=t,r(t,i.protocol)?t&&(i.host=i.hostname+":"+t):(i.host=i.hostname,i[e]="");break;case"hostname":i[e]=t,i.port&&(t+=":"+i.port),i.host=t;break;case"host":i[e]=t,l.test(t)?(t=t.split(":"),i.port=t.pop(),i.hostname=t.join(":")):(i.hostname=t,i.port="");break;case"protocol":i.protocol=t.toLowerCase(),i.slashes=!n;break;case"pathname":case"hash":if(t){var s="pathname"===e?"/":"#";i[e]=t.charAt(0)!==s?s+t:t}else i[e]=t;break;case"username":case"password":i[e]=encodeURIComponent(t);break;case"auth":var a=t.indexOf(":");~a?(i.username=t.slice(0,a),i.username=encodeURIComponent(decodeURIComponent(i.username)),i.password=t.slice(a+1),i.password=encodeURIComponent(decodeURIComponent(i.password))):i.username=encodeURIComponent(decodeURIComponent(t))}for(var c=0;c<h.length;c++){var u=h[c];u[4]&&(i[u[1]]=i[u[1]].toLowerCase())}return i.auth=i.password?i.username+":"+i.password:i.username,i.origin="file:"!==i.protocol&&m(i.protocol)&&i.host?i.protocol+"//"+i.host:"null",i.href=i.toString(),i},toString:function(e){e&&"function"==typeof e||(e=o.stringify);var t,n=this,r=n.host,i=n.protocol;i&&":"!==i.charAt(i.length-1)&&(i+=":");var s=i+(n.protocol&&n.slashes||m(n.protocol)?"//":"");return n.username?(s+=n.username,n.password&&(s+=":"+n.password),s+="@"):n.password?(s+=":"+n.password,s+="@"):"file:"!==n.protocol&&m(n.protocol)&&!r&&"/"!==n.pathname&&(s+="@"),(":"===r[r.length-1]||l.test(n.hostname)&&!n.port)&&(r+=":"),s+=r+n.pathname,(t="object"==typeof n.query?e(n.query):n.query)&&(s+="?"!==t.charAt(0)?"?"+t:t),n.hash&&(s+=n.hash),s}},_.extractProtocol=g,_.location=p,_.trimLeft=f,_.qs=o,e.exports=_}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};return(()=>{"use strict";__webpack_require__.r(__webpack_exports__);const e=Symbol("Comlink.proxy"),t=Symbol("Comlink.endpoint"),n=Symbol("Comlink.releaseProxy"),r=Symbol("Comlink.finalizer"),o=Symbol("Comlink.thrown"),i=e=>"object"==typeof e&&null!==e||"function"==typeof e,s=new Map([["proxy",{canHandle:t=>i(t)&&t[e],serialize(e){const{port1:t,port2:n}=new MessageChannel;return a(e,t),[n,[n]]},deserialize:e=>(e.start(),d(e,[],undefined))}],["throw",{canHandle:e=>i(e)&&o in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function a(t,n=globalThis,i=["*"]){n.addEventListener("message",(function s(c){if(!c||!c.data)return;if(!function(e,t){for(const n of e){if(t===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}return!1}(i,c.origin))return void console.warn(`Invalid origin '${c.origin}' for comlink proxy`);const{id:u,type:f,path:h}=Object.assign({path:[]},c.data),d=(c.data.argumentList||[]).map(_);let p;try{const n=h.slice(0,-1).reduce(((e,t)=>e[t]),t),r=h.reduce(((e,t)=>e[t]),t);switch(f){case"GET":p=r;break;case"SET":n[h.slice(-1)[0]]=_(c.data.value),p=!0;break;case"APPLY":p=r.apply(n,d);break;case"CONSTRUCT":p=function(t){return Object.assign(t,{[e]:!0})}(new r(...d));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;a(t,n),p=function(e,t){return m.set(e,t),e}(e,[e])}break;case"RELEASE":p=void 0;break;default:return}}catch(e){p={value:e,[o]:0}}Promise.resolve(p).catch((e=>({value:e,[o]:0}))).then((e=>{const[o,i]=g(e);n.postMessage(Object.assign(Object.assign({},o),{id:u}),i),"RELEASE"===f&&(n.removeEventListener("message",s),l(n),r in t&&"function"==typeof t[r]&&t[r]())})).catch((e=>{const[t,r]=g({value:new TypeError("Unserializable return value"),[o]:0});n.postMessage(Object.assign(Object.assign({},t),{id:u}),r)}))})),n.start&&n.start()}function l(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function c(e){if(e)throw new Error("Proxy has been released and is not useable")}function u(e){return v(e,{type:"RELEASE"}).then((()=>{l(e)}))}const f=new WeakMap,h="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(f.get(e)||0)-1;f.set(e,t),0===t&&u(e)}));function d(e,r=[],o=function(){}){let i=!1;const s=new Proxy(o,{get(t,o){if(c(i),o===n)return()=>{!function(e){h&&h.unregister(e)}(s),u(e),i=!0};if("then"===o){if(0===r.length)return{then:()=>s};const t=v(e,{type:"GET",path:r.map((e=>e.toString()))}).then(_);return t.then.bind(t)}return d(e,[...r,o])},set(t,n,o){c(i);const[s,a]=g(o);return v(e,{type:"SET",path:[...r,n].map((e=>e.toString())),value:s},a).then(_)},apply(n,o,s){c(i);const a=r[r.length-1];if(a===t)return v(e,{type:"ENDPOINT"}).then(_);if("bind"===a)return d(e,r.slice(0,-1));const[l,u]=p(s);return v(e,{type:"APPLY",path:r.map((e=>e.toString())),argumentList:l},u).then(_)},construct(t,n){c(i);const[o,s]=p(n);return v(e,{type:"CONSTRUCT",path:r.map((e=>e.toString())),argumentList:o},s).then(_)}});return function(e,t){const n=(f.get(t)||0)+1;f.set(t,n),h&&h.register(e,t,e)}(s,e),s}function p(e){const t=e.map(g);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const m=new WeakMap;function g(e){for(const[t,n]of s)if(n.canHandle(e)){const[r,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},o]}return[{type:"RAW",value:e},m.get(e)||[]]}function _(e){switch(e.type){case"HANDLER":return s.get(e.name).deserialize(e.value);case"RAW":return e.value}}function v(e,t,n){return new Promise((r=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(n){n.data&&n.data.id&&n.data.id===o&&(e.removeEventListener("message",t),r(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:o},t),n)}))}const y=new TextEncoder,w=new TextDecoder("utf-8"),b={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};class x{constructor(e){this.fs=e}open(e){const t=this.fs.realPath(e.node);this.fs.FS.isFile(e.node.mode)&&(e.file=this.fs.API.get(t))}close(e){if(!this.fs.FS.isFile(e.node.mode)||!e.file)return;const t=this.fs.realPath(e.node),n=e.flags;let r="string"==typeof n?parseInt(n,10):n;r&=8191;let o=!0;r in b&&(o=b[r]),o&&this.fs.API.put(t,e.file),e.file=void 0}read(e,t,n,r,o){if(r<=0||void 0===e.file||o>=(e.file.data.length||0))return 0;const i=Math.min(e.file.data.length-o,r);return t.set(e.file.data.subarray(o,o+i),n),i}write(e,t,n,r,o){var i;if(r<=0||void 0===e.file)return 0;if(e.node.timestamp=Date.now(),o+r>((null===(i=e.file)||void 0===i?void 0:i.data.length)||0)){const t=e.file.data?e.file.data:new Uint8Array;e.file.data=new Uint8Array(o+r),e.file.data.set(t)}return e.file.data.set(t.subarray(n,n+r),o),r}llseek(e,t,n){let r=t;if(1===n)r+=e.position;else if(2===n&&this.fs.FS.isFile(e.node.mode)){if(void 0===e.file)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM);r+=e.file.data.length}if(r<0)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EINVAL);return r}}class E{constructor(e){this.fs=e}getattr(e){return{...this.fs.API.getattr(this.fs.realPath(e)),mode:e.mode,ino:e.id}}setattr(e,t){for(const[n,r]of Object.entries(t))switch(n){case"mode":e.mode=r;break;case"timestamp":e.timestamp=r;break;default:console.warn("setattr",n,"of",r,"on",e,"not yet implemented")}}lookup(e,t){const n=this.fs.PATH.join2(this.fs.realPath(e),t),r=this.fs.API.lookup(n);if(!r.ok)throw this.fs.FS.genericErrors[this.fs.ERRNO_CODES.ENOENT];return this.fs.createNode(e,t,r.mode,0)}mknod(e,t,n,r){const o=this.fs.PATH.join2(this.fs.realPath(e),t);return this.fs.API.mknod(o,n),this.fs.createNode(e,t,n,r)}rename(e,t,n){this.fs.API.rename(e.parent?this.fs.PATH.join2(this.fs.realPath(e.parent),e.name):e.name,this.fs.PATH.join2(this.fs.realPath(t),n)),e.name=n,e.parent=t}unlink(e,t){this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(e),t))}rmdir(e,t){this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(e),t))}readdir(e){return this.fs.API.readdir(this.fs.realPath(e))}symlink(e,t,n){throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM)}readlink(e){throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM)}}class O{constructor(e,t,n,r,o){this._baseUrl=e,this._driveName=t,this._mountpoint=n,this.FS=r,this.ERRNO_CODES=o}request(e){const t=new XMLHttpRequest;t.open("POST",encodeURI(this.endpoint),!1);try{t.send(JSON.stringify(e))}catch(e){console.error(e)}if(t.status>=400)throw new this.FS.ErrnoError(this.ERRNO_CODES.EINVAL);return JSON.parse(t.responseText)}lookup(e){return this.request({method:"lookup",path:this.normalizePath(e)})}getmode(e){return Number.parseInt(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){const 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){const t=this.request({method:"get",path:this.normalizePath(e)}),n=t.content,r=t.format;switch(r){case"json":case"text":return{data:y.encode(n),format:r};case"base64":{const e=atob(n),t=e.length,o=new Uint8Array(t);for(let n=0;n<t;n++)o[n]=e.charCodeAt(n);return{data:o,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:w.decode(t.data)}});case"base64":{let n="";for(let e=0;e<t.data.byteLength;e++)n+=String.fromCharCode(t.data[e]);return this.request({method:"put",path:this.normalizePath(e),data:{format:t.format,data:btoa(n)}})}}}getattr(e){const t=this.request({method:"getattr",path:this.normalizePath(e)});return t.atime=new Date(t.atime),t.mtime=new Date(t.mtime),t.ctime=new Date(t.ctime),t.size=t.size||0,t}normalizePath(e){return e.startsWith(this._mountpoint)&&(e=e.slice(this._mountpoint.length)),this._driveName&&(e=`${this._driveName}:${e}`),e}get endpoint(){return`${this._baseUrl}api/drive`}}class k{constructor(e){this.FS=e.FS,this.PATH=e.PATH,this.ERRNO_CODES=e.ERRNO_CODES,this.API=new O(e.baseUrl,e.driveName,e.mountpoint,this.FS,this.ERRNO_CODES),this.driveName=e.driveName,this.node_ops=new E(this),this.stream_ops=new x(this)}mount(e){return this.createNode(null,e.mountpoint,16895,0)}createNode(e,t,n,r){const o=this.FS;if(!o.isDir(n)&&!o.isFile(n))throw new o.ErrnoError(this.ERRNO_CODES.EINVAL);const i=o.createNode(e,t,n,r);return i.node_ops=this.node_ops,i.stream_ops=this.stream_ops,i}getMode(e){return this.API.getmode(e)}realPath(e){const t=[];let n=e;for(t.push(n.name);n.parent!==n;)n=n.parent,t.push(n.name);return t.reverse(),this.PATH.join.apply(null,t)}}var C=__webpack_require__(622);globalThis.Module={};class P extends E{getNode(e){return e.node?e.node:e}lookup(e,t){return super.lookup(this.getNode(e),t)}getattr(e){return super.getattr(this.getNode(e))}setattr(e,t){super.setattr(this.getNode(e),t)}mknod(e,t,n,r){return super.mknod(this.getNode(e),t,n,r)}rename(e,t,n){super.rename(this.getNode(e),this.getNode(t),n)}rmdir(e,t){super.rmdir(this.getNode(e),t)}readdir(e){return super.readdir(this.getNode(e))}}class R extends k{constructor(e){super(e),this.node_ops=new P(this)}}let M;globalThis.toplevel_promise=null,globalThis.toplevel_promise_py_proxy=null,self.get_stdin=async function(){return new Promise((e=>{M=e}))};class S{constructor(e){this._drive=null,this._resolve=e}async ready(){return await globalThis.ready}mount(e,t,n){const{FS:r,PATH:o,ERRNO_CODES:i}=globalThis.Module;r&&(this._drive=new R({FS:r,PATH:o,ERRNO_CODES:i,baseUrl:n,driveName:e,mountpoint:t}),r.mkdir(t),r.mount(this._drive,{},t),r.chdir(t))}cd(e){e&&globalThis.Module.FS&&globalThis.Module.FS.chdir(e)}async processMessage(e){const t=e.msg.header.msg_type;if("__initialize__"===t)return this._kernelspec=e.msg.kernelspec,void await this.initialize();await this.ready(),null!==globalThis.toplevel_promise&&null!==globalThis.toplevel_promise_py_proxy&&(await globalThis.toplevel_promise,globalThis.toplevel_promise_py_proxy.delete(),globalThis.toplevel_promise_py_proxy=null,globalThis.toplevel_promise=null),"input_reply"===t?M(e.msg):this._raw_xserver.notify_listener(e.msg)}async initialize(){const e=this._kernelspec.dir,t=C.URLExt.join(C.PageConfig.getBaseUrl(),this._kernelspec.argv[0]),n=t.replace(".js",".wasm");importScripts(t),globalThis.Module=await createXeusModule({locateFile:e=>e.endsWith(".wasm")?n:e});try{if(await this.waitRunDependency(),void 0!==globalThis.Module.async_init){const t=C.URLExt.join(C.PageConfig.getBaseUrl(),`xeus/kernels/${e}`),n=C.URLExt.join(C.PageConfig.getBaseUrl(),"xeus/kernel_packages"),r=!0;await globalThis.Module.async_init(t,n,r)}await this.waitRunDependency(),this._raw_xkernel=new globalThis.Module.xkernel,this._raw_xserver=this._raw_xkernel.get_server(),this._raw_xkernel||console.error("Failed to start kernel!"),this._raw_xkernel.start()}catch(e){if("number"==typeof e){const t=globalThis.Module.get_exception_message(e);throw console.error(t),new Error(t)}throw console.error(e),e}this._resolve()}async waitRunDependency(){const e=new Promise((e=>{globalThis.Module.monitorRunDependencies=t=>{0===t&&e()}}));return globalThis.Module.addRunDependency("dummy"),globalThis.Module.removeRunDependency("dummy"),e}}globalThis.ready=new Promise((e=>{a(new S(e))}))})(),__webpack_exports__})()));
3
3
  //# sourceMappingURL=worker.js.map