@jeevanand/agent-browserbox-runtime 0.1.1 → 0.3.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.
Files changed (90) hide show
  1. package/README.md +18 -0
  2. package/dist/assets/{bridge-DY2WnNx7.js → bridge-DQLuopgW.js} +2 -2
  3. package/dist/assets/{build-BNa5TW3M.js → build-Bd5qSPS-.js} +2 -2
  4. package/dist/assets/bundle-CXrJ5BHI.js +1 -0
  5. package/dist/assets/{dev-impl-BRiXVAGb.js → dev-impl-DJx7S2dO.js} +4 -4
  6. package/dist/assets/embed-uUqwwabc.js +3 -0
  7. package/dist/assets/{html-R2xYS1Rp.js → html-Bd3_N2aN.js} +3 -3
  8. package/dist/assets/{instance-CppC8T8t.js → instance-Cu6oky-A.js} +1 -1
  9. package/dist/assets/main-CQvaEX7y.js +372 -0
  10. package/dist/assets/path-DGG-Mxbd.js +1 -0
  11. package/dist/assets/{pkg-esbuild-BuQjm7dB.js → pkg-esbuild-C-EHnLD8.js} +1 -1
  12. package/dist/assets/{pkg-git-jawfIVoq.js → pkg-git-BCxqHW9a.js} +9 -9
  13. package/dist/assets/pkg-python-B23D6vdG.js +6 -0
  14. package/dist/assets/{pkg-sqlite-BexM5lLo.js → pkg-sqlite-CKGWzcwt.js} +1 -1
  15. package/dist/assets/pkg-zip-CuNUYwRy.js +1 -0
  16. package/dist/assets/rolldown-runtime-WkwZ5CU-.js +1 -0
  17. package/dist/assets/server-DPVY2l_9.js +4 -0
  18. package/dist/embed/index.html +5 -5
  19. package/dist/kernel/bridge.html +2 -2
  20. package/dist/kernel/packages.json +1 -1
  21. package/lib/client/connect.d.ts +23 -0
  22. package/lib/client/connect.js +64 -0
  23. package/lib/client/index.d.ts +24 -0
  24. package/lib/client/index.js +17 -0
  25. package/lib/client/remote-kernel.d.ts +53 -0
  26. package/lib/client/remote-kernel.js +319 -0
  27. package/lib/config/origins.d.ts +13 -0
  28. package/lib/config/origins.js +35 -0
  29. package/lib/kernel/api.d.ts +153 -0
  30. package/lib/kernel/api.js +1 -0
  31. package/lib/kernel/bus.d.ts +6 -0
  32. package/lib/kernel/bus.js +24 -0
  33. package/lib/kernel/caps.d.ts +10 -0
  34. package/lib/kernel/caps.js +50 -0
  35. package/lib/kernel/dev/types.d.ts +71 -0
  36. package/lib/kernel/dev/types.js +8 -0
  37. package/lib/kernel/filetypes.d.ts +9 -0
  38. package/lib/kernel/filetypes.js +74 -0
  39. package/lib/kernel/format.d.ts +3 -0
  40. package/lib/kernel/format.js +23 -0
  41. package/lib/kernel/instance.d.ts +32 -0
  42. package/lib/kernel/instance.js +48 -0
  43. package/lib/kernel/kcore.d.ts +26 -0
  44. package/lib/kernel/kcore.js +105 -0
  45. package/lib/kernel/kcore.wasm +0 -0
  46. package/lib/kernel/paths.d.ts +3 -0
  47. package/lib/kernel/paths.js +3 -0
  48. package/lib/kernel/perms.d.ts +35 -0
  49. package/lib/kernel/perms.js +42 -0
  50. package/lib/kernel/proc.d.ts +45 -0
  51. package/lib/kernel/proc.js +69 -0
  52. package/lib/kernel/profiles.d.ts +31 -0
  53. package/lib/kernel/profiles.js +93 -0
  54. package/lib/kernel/settings.d.ts +29 -0
  55. package/lib/kernel/settings.js +94 -0
  56. package/lib/kernel/types.d.ts +54 -0
  57. package/lib/kernel/types.js +1 -0
  58. package/lib/kernel/vfs/path.d.ts +11 -0
  59. package/lib/kernel/vfs/path.js +72 -0
  60. package/lib/kernel/vfs/types.d.ts +34 -0
  61. package/lib/kernel/vfs/types.js +17 -0
  62. package/lib/kernel-worker/wire.d.ts +38 -0
  63. package/lib/kernel-worker/wire.js +2 -0
  64. package/lib/rpc/peer.d.ts +12 -0
  65. package/lib/rpc/peer.js +85 -0
  66. package/lib/sandbox/isolation.d.ts +8 -0
  67. package/lib/sandbox/isolation.js +12 -0
  68. package/lib/shell/ansi.d.ts +15 -0
  69. package/lib/shell/ansi.js +23 -0
  70. package/package.json +8 -3
  71. package/dist/assets/anthropic-S3ckT02t.js +0 -17
  72. package/dist/assets/bundle-8opp8__C.js +0 -1
  73. package/dist/assets/embed-CMbAHE2J.js +0 -3
  74. package/dist/assets/github-Dwhv0h55.js +0 -2
  75. package/dist/assets/lib-aA6_aWm_.js +0 -68
  76. package/dist/assets/main-VEpSfsM_.js +0 -482
  77. package/dist/assets/node.browser-1OJr47If.js +0 -1
  78. package/dist/assets/node.browser-cOXEGsLT.js +0 -1
  79. package/dist/assets/openai-CThAXVqN.js +0 -3
  80. package/dist/assets/pkg-python-CoNK0IjJ.js +0 -6
  81. package/dist/assets/pkg-zip-BdZ_Lkdk.js +0 -1
  82. package/dist/assets/publish-CHt_Qrq5.js +0 -2
  83. package/dist/assets/publish-impl-BqjdM7Ux.js +0 -7
  84. package/dist/assets/rolldown-runtime-XKyaHtl9.js +0 -1
  85. package/dist/assets/server-C5Sd62CK.js +0 -4
  86. package/dist/assets/webllm-wsrhCAP4.js +0 -11
  87. package/dist/icon.svg +0 -1
  88. package/dist/manifest.webmanifest +0 -10
  89. package/dist/preview/frame.html +0 -27
  90. package/dist/sw.js +0 -73
@@ -1,4 +1,4 @@
1
- import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";import{p as n,t as r,u as i}from"./main-VEpSfsM_.js";var a=/* @__PURE__ */ t((e=>{e.byteLength=c,e.toByteArray=u,e.fromByteArray=p;for(var t=[],n=[],r=typeof Uint8Array<`u`?Uint8Array:Array,i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,a=0,o=i.length;a<o;++a)t[a]=i[a],n[i.charCodeAt(a)]=a;n[45]=62,n[95]=63;function s(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function c(e){var t=s(e),n=t[0],r=t[1];return(n+r)*3/4-r}function l(e,t,n){return(t+n)*3/4-n}function u(e){for(var t,i=s(e),a=i[0],o=i[1],c=new r(l(e,a,o)),u=0,d=o>0?a-4:a,f=0;f<d;f+=4)t=n[e.charCodeAt(f)]<<18|n[e.charCodeAt(f+1)]<<12|n[e.charCodeAt(f+2)]<<6|n[e.charCodeAt(f+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=t&255;return o===2&&(t=n[e.charCodeAt(f)]<<2|n[e.charCodeAt(f+1)]>>4,c[u++]=t&255),o===1&&(t=n[e.charCodeAt(f)]<<10|n[e.charCodeAt(f+1)]<<4|n[e.charCodeAt(f+2)]>>2,c[u++]=t>>8&255,c[u++]=t&255),c}function d(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[e&63]}function f(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(d(r));return i.join(``)}function p(e){for(var n,r=e.length,i=r%3,a=[],o=16383,s=0,c=r-i;s<c;s+=o)a.push(f(e,s,s+o>c?c:s+o));return i===1?(n=e[r-1],a.push(t[n>>2]+t[n<<4&63]+`==`)):i===2&&(n=(e[r-2]<<8)+e[r-1],a.push(t[n>>10]+t[n>>4&63]+t[n<<2&63]+`=`)),a.join(``)}})),o=/* @__PURE__ */ t((e=>{
1
+ import{n as e,t}from"./rolldown-runtime-WkwZ5CU-.js";import{c as n,i as r,l as i}from"./main-CQvaEX7y.js";var a=/* @__PURE__ */ t((e=>{e.byteLength=c,e.toByteArray=u,e.fromByteArray=p;for(var t=[],n=[],r=typeof Uint8Array<`u`?Uint8Array:Array,i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,a=0,o=i.length;a<o;++a)t[a]=i[a],n[i.charCodeAt(a)]=a;n[45]=62,n[95]=63;function s(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function c(e){var t=s(e),n=t[0],r=t[1];return(n+r)*3/4-r}function l(e,t,n){return(t+n)*3/4-n}function u(e){for(var t,i=s(e),a=i[0],o=i[1],c=new r(l(e,a,o)),u=0,d=o>0?a-4:a,f=0;f<d;f+=4)t=n[e.charCodeAt(f)]<<18|n[e.charCodeAt(f+1)]<<12|n[e.charCodeAt(f+2)]<<6|n[e.charCodeAt(f+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=t&255;return o===2&&(t=n[e.charCodeAt(f)]<<2|n[e.charCodeAt(f+1)]>>4,c[u++]=t&255),o===1&&(t=n[e.charCodeAt(f)]<<10|n[e.charCodeAt(f+1)]<<4|n[e.charCodeAt(f+2)]>>2,c[u++]=t>>8&255,c[u++]=t&255),c}function d(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[e&63]}function f(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(d(r));return i.join(``)}function p(e){for(var n,r=e.length,i=r%3,a=[],o=16383,s=0,c=r-i;s<c;s+=o)a.push(f(e,s,s+o>c?c:s+o));return i===1?(n=e[r-1],a.push(t[n>>2]+t[n<<4&63]+`==`)):i===2&&(n=(e[r-2]<<8)+e[r-1],a.push(t[n>>10]+t[n>>4&63]+t[n<<2&63]+`=`)),a.join(``)}})),o=/* @__PURE__ */ t((e=>{
2
2
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
3
3
  e.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},e.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128}})),s=/* @__PURE__ */ t((e=>{
4
4
  /*!
@@ -95,16 +95,16 @@ gpgsig`+Nr(o)+`
95
95
  \tbare = ${t}\n`+(t?``:` logallrefupdates = true
96
96
  `)+` symlinks = false
97
97
  ignorecase = true
98
- `),await e.write(r+`/HEAD`,`ref: refs/heads/${i}\n`)}async function Ca({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,onPostCheckout:c,dir:l,gitdir:u,url:d,corsProxy:f,ref:p,remote:m,depth:h,since:g,exclude:_,relative:v,singleBranch:y,noCheckout:b,noTags:x,headers:S,nonBlocking:C,batchSize:w=100}){try{if(await Sa({fs:e,gitdir:u}),await Ai({fs:e,gitdir:u,remote:m,url:d,force:!1}),f){let t=await un.get({fs:e,gitdir:u});await t.set(`http.corsProxy`,f),await un.save({fs:e,gitdir:u,config:t})}let{defaultBranch:T,fetchHead:E}=await xa({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,gitdir:u,ref:p,remote:m,corsProxy:f,depth:h,since:g,exclude:_,relative:v,singleBranch:y,headers:S,tags:!x});if(E===null)return;p||=T,p=p.replace(`refs/heads/`,``),await Pi({fs:e,cache:t,onProgress:r,onPostCheckout:c,dir:l,gitdir:u,ref:p,remote:m,noCheckout:b,nonBlocking:C,batchSize:w})}catch(t){throw await e.rmdir(u,{recursive:!0,maxRetries:10}).catch(()=>void 0),t}}async function wa({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:s,dir:c,gitdir:l=Z(c,`.git`),url:u,corsProxy:d=void 0,ref:f=void 0,remote:p=`origin`,depth:m=void 0,since:h=void 0,exclude:g=[],relative:_=!1,singleBranch:v=!1,noCheckout:y=!1,noTags:b=!1,headers:x={},cache:S={},nonBlocking:C=!1,batchSize:w=100}){try{$(`fs`,e),$(`http`,t),$(`gitdir`,l),y||$(`dir`,c),$(`url`,u);let T=new ti(e);return await Ca({fs:T,cache:S,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:s,dir:c,gitdir:await ii({fsp:T,dotgit:l}),url:u,corsProxy:d,ref:f,remote:p,depth:m,since:h,exclude:g,relative:_,singleBranch:v,noCheckout:y,noTags:b,headers:x,nonBlocking:C,batchSize:w})}catch(e){throw e.caller=`git.clone`,e}}async function Ta({fs:e,onSign:t,dir:n,gitdir:r=Z(n,`.git`),message:i,author:a,committer:o,signingKey:s,amend:c=!1,dryRun:l=!1,noUpdateBranch:u=!1,disallowEmpty:d=!1,ref:f,parent:p,tree:m,cache:h={}}){try{$(`fs`,e),c||$(`message`,i),s&&$(`onSign`,t);let n=new ti(e);return await Ti({fs:n,cache:h,onSign:t,gitdir:await ii({fsp:n,dotgit:r}),message:i,author:a,committer:o,signingKey:s,amend:c,dryRun:l,noUpdateBranch:u,disallowEmpty:d,ref:f,parent:p,tree:m})}catch(e){throw e.caller=`git.commit`,e}}async function Ea({fs:e,dir:t,gitdir:n=Z(t,`.git`),fullname:r=!1,test:i=!1}){try{$(`fs`,e),$(`gitdir`,n);let t=new ti(e);return await Hi({fs:t,gitdir:await ii({fsp:t,dotgit:n}),fullname:r,test:i})}catch(e){throw e.caller=`git.currentBranch`,e}}async function Da({fs:e,filepath:t}){if(await e.exists(Z(t,`.git`)))return t;{let n=Et(t);if(n===t)throw new Mt(`git root for ${t}`);return Da({fs:e,filepath:n})}}async function Oa({fs:e,filepath:t}){try{return $(`fs`,e),$(`filepath`,t),await Da({fs:new ti(e),filepath:t})}catch(e){throw e.caller=`git.findRoot`,e}}async function ka({fs:e,bare:t=!1,dir:n,gitdir:r=t?n:Z(n,`.git`),defaultBranch:i=`master`}){try{$(`fs`,e),$(`gitdir`,r),t||$(`dir`,n);let a=new ti(e);return await Sa({fs:a,bare:t,dir:n,gitdir:await ii({fsp:a,dotgit:r}),defaultBranch:i})}catch(e){throw e.caller=`git.init`,e}}async function Aa({fs:e,dir:t,gitdir:n=Z(t,`.git`),remote:r}){try{$(`fs`,e),$(`gitdir`,n);let t=new ti(e),i=await ii({fsp:t,dotgit:n});return Q.listBranches({fs:t,gitdir:i,remote:r})}catch(e){throw e.caller=`git.listBranches`,e}}function ja(e,t){return e.committer.timestamp-t.committer.timestamp}async function Ma({fs:e,cache:t,gitdir:n,oid:r,fileId:i}){if(i===`e69de29bb2d1d6434b8b29ae775ad8c2e48c5391`)return;let a=r,o,s=await Ir({fs:e,cache:t,gitdir:n,oid:r}),c=s.tree;return i===s.oid?o=s.path:(o=await Na({fs:e,cache:t,gitdir:n,tree:c,fileId:i,oid:a}),Array.isArray(o)&&(o.length===0?o=void 0:o.length===1&&(o=o[0]))),o}async function Na({fs:e,cache:t,gitdir:n,tree:r,fileId:i,oid:a,filepaths:o=[],parentPath:s=``}){let c=r.entries().map(function(r){let c;return r.oid===i?(c=Z(s,r.path),o.push(c)):r.type===`tree`&&(c=Yn({fs:e,cache:t,gitdir:n,oid:r.oid}).then(function({object:c}){return Na({fs:e,cache:t,gitdir:n,tree:bn.from(c),fileId:i,oid:a,filepaths:o,parentPath:Z(s,r.path)})})),c});return await Promise.all(c),o}async function Pa({fs:e,cache:t,gitdir:n,filepath:r,ref:i,depth:a,since:o,author:s,force:c,follow:l,includeChanges:u}){let d=o===void 0?void 0:Math.floor(o.valueOf()/1e3),f=s==null?void 0:new RegExp(s,`i`),p=({commit:e})=>f===void 0?!0:e.author?f.test(`${e.author.name} <${e.author.email}>`):!1,m=[],h=e=>{p(e)&&m.push(e)},g=await ua.read({fs:e,gitdir:n}),_=[await wi({fs:e,cache:t,gitdir:n,oid:await Q.resolve({fs:e,gitdir:n,ref:i})})],v,y,b,x;function S(e){x&&r&&h(e)}for(;_.length>0;){let i=_.pop();if(d!==void 0&&i.commit.committer.timestamp<=d)break;if(r){let a;try{a=await Oi({fs:e,cache:t,gitdir:n,oid:i.commit.tree,filepath:r}),b&&(v!==a.oid||y!==a.mode)&&h(b),v=a.oid,y=a.mode,b=i,x=!0}catch(a){if(a instanceof Mt){let o=l&&v;if(o&&(o=await Ma({fs:e,cache:t,gitdir:n,oid:i.commit.tree,fileId:v}),o)){if(Array.isArray(o)){if(b){let i=await Ma({fs:e,cache:t,gitdir:n,oid:b.commit.tree,fileId:v});if(Array.isArray(i)){if(o=o.filter(e=>i.indexOf(e)===-1),o.length===1)o=o[0],r=o,b&&h(b);else{o=!1,b&&h(b);break}}}}else r=o,b&&h(b)}if(!o){if(x&&v&&(h(b),!c))break;if(!c&&!l)throw a}b=i,x=!1}else throw a}}else h(i);if(a!==void 0&&m.length===a){S(i);break}if(!g.has(i.oid))for(let r of i.commit.parent){let i=await wi({fs:e,cache:t,gitdir:n,oid:r});_.map(e=>e.oid).includes(i.oid)||_.push(i)}_.length===0&&S(i),_.sort((e,t)=>ja(e.commit,t.commit))}if(u)for(let r of m)r.commit.changes=await Fa({fs:e,cache:t,gitdir:n,commit:r,shallow:g.has(r.oid)});return m}async function Fa({fs:e,cache:t,gitdir:n,commit:r,shallow:i}){let a=i||!r.commit.parent[0]?`4b825dc642cb6eb9a060e54bf8d69288fbee4904`:r.commit.parent[0];return Gr({fs:e,cache:t,gitdir:n,trees:[Rr({ref:r.oid}),Rr({ref:a})],map:async(e,[t,n])=>{let[r,i]=await Promise.all([t&&t.type(),n&&n.type()]);if(r===`tree`)return i&&i!==`tree`?[null,await n.oid(),e]:void 0;if(i===`tree`)return r?[await t.oid(),null,e]:void 0;let[a,o]=await Promise.all([t?t.oid():null,n?n.oid():null]);if(a!==o)return[a,o,e]}})}async function Ia({fs:e,dir:t,gitdir:n=Z(t,`.git`),filepath:r,ref:i=`HEAD`,depth:a,since:o,author:s,force:c,follow:l,includeChanges:u=!1,cache:d={}}){try{$(`fs`,e),$(`gitdir`,n),$(`ref`,i);let t=new ti(e);return await Pa({fs:t,cache:d,gitdir:await ii({fsp:t,dotgit:n}),filepath:r,ref:i,depth:a,since:o,author:s,force:c,follow:l,includeChanges:u})}catch(e){throw e.caller=`git.log`,e}}async function La({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await Yn({fs:e,cache:t,gitdir:n,oid:r});if(i===`tag`)return r=Mr.from(a).parse().object,La({fs:e,cache:t,gitdir:n,oid:r});if(i!==`blob`)throw new Nt(r,i,`blob`);return{oid:r,blob:new Uint8Array(a)}}async function Ra({fs:e,cache:t,gitdir:n,oid:r,filepath:i=void 0}){return i!==void 0&&(r=await Di({fs:e,cache:t,gitdir:n,oid:r,filepath:i})),await La({fs:e,cache:t,gitdir:n,oid:r})}async function za({fs:e,dir:t,gitdir:n=Z(t,`.git`),oid:r,filepath:i,cache:a={}}){try{$(`fs`,e),$(`gitdir`,n),$(`oid`,r);let t=new ti(e);return await Ra({fs:t,cache:a,gitdir:await ii({fsp:t,dotgit:n}),oid:r,filepath:i})}catch(e){throw e.caller=`git.readBlob`,e}}async function Ba({fs:e,dir:t,gitdir:n=Z(t,`.git`),filepath:r,cache:i={}}){try{$(`fs`,e),$(`gitdir`,n),$(`filepath`,r);let t=new ti(e),a=await ii({fsp:t,dotgit:n});await wt.acquire({fs:t,gitdir:a,cache:i},async function(e){let t=Array.isArray(r)?r:[r];for(let n of t)e.delete({filepath:n})})}catch(e){throw e.caller=`git.remove`,e}}async function Va({fs:e,dir:t,gitdir:n=Z(t,`.git`),ref:r,depth:i}){try{$(`fs`,e),$(`gitdir`,n),$(`ref`,r);let t=new ti(e),a=await ii({fsp:t,dotgit:n});return await Q.resolve({fs:t,gitdir:a,ref:r,depth:i})}catch(e){throw e.caller=`git.resolveRef`,e}}async function Ha({fs:e,dir:t,gitdir:n=Z(t,`.git`),ref:r=`HEAD`,filepaths:i=[`.`],filter:a,cache:o={},ignored:s=!1,refresh:c=!0}){try{$(`fs`,e),$(`gitdir`,n),$(`ref`,r);let l=new ti(e);return await Gr({fs:l,cache:o,dir:t,gitdir:await ii({fsp:l,dotgit:n}),trees:[Rr({ref:r}),Br({refresh:c}),jt()],map:async function(e,[n,r,o]){if(!n&&!o&&r&&!s&&await ai.isIgnored({fs:l,dir:t,filepath:e})||!i.some(t=>Ni(e,t)))return null;if(a&&!a(e))return;let[c,u,d]=await Promise.all([n&&n.type(),r&&r.type(),o&&o.type()]),f=[c,u,d].includes(`blob`);if((c===`tree`||c===`special`)&&!f)return;if(c===`commit`)return null;if((u===`tree`||u===`special`)&&!f)return;if(d===`commit`)return null;if((d===`tree`||d===`special`)&&!f)return;let p=c===`blob`?await n.oid():void 0,m=d===`blob`?await o.oid():void 0,h;c!==`blob`&&u===`blob`&&d!==`blob`?h=`42`:u===`blob`&&(h=await r.oid());let g=[void 0,p,h,m],_=g.map(e=>g.indexOf(e));return _.shift(),[e,..._]}})}catch(e){throw e.caller=`git.statusMatrix`,e}}function Ua(e){let t=[e];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}function Wa(e){return e[Symbol.asyncIterator]?e[Symbol.asyncIterator]():e[Symbol.iterator]?e[Symbol.iterator]():e.next?e:Ua(e)}async function Ga(e,t){let n=Wa(e);for(;;){let{value:e,done:r}=await n.next();if(e&&await t(e),r)break}n.return&&n.return()}async function Ka(e){let t=0,n=[];await Ga(e,e=>{n.push(e),t+=e.byteLength});let r=new Uint8Array(t),i=0;for(let e of n)r.set(e,i),i+=e.byteLength;return r}function qa(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{next(){return t.read()},return(){return t.releaseLock(),{}},[Symbol.asyncIterator](){return this}}}async function Ja({onProgress:e,url:t,method:n=`GET`,headers:r={},fetchOptions:i={},body:a,signal:o}){a&&=await Ka(a);let s=await fetch(t,{...i,method:n,headers:r,body:a,signal:o??i.signal}),c=s.body&&s.body.getReader?qa(s.body):[new Uint8Array(await s.arrayBuffer())];r={};for(let[e,t]of s.headers.entries())r[e]=t;return{url:s.url,method:s.method,statusCode:s.status,statusMessage:s.statusText,body:c,headers:r}}var Ya={request:Ja};const Xa=`git.config`,Za={name:`BrowserBox User`,email:`user@browserbox.local`,corsProxy:``};function Qa(e){let t=e.fs,n=async e=>{let n=await t.stat(e);if(!n)throw new r(`ENOENT`,e);let i=n.kind===`dir`;return{type:i?`dir`:`file`,mode:i?16384:33188,size:n.size,ino:0,mtimeMs:n.mtime,ctimeMs:n.mtime,uid:1,gid:1,dev:1,isFile:()=>!i,isDirectory:()=>i,isSymbolicLink:()=>!1}};return{promises:{readFile:async(e,n)=>{let r=typeof n==`string`?n:n?.encoding,i=await t.readFile(e);return r===`utf8`?new TextDecoder().decode(i):i},writeFile:(e,n)=>t.writeFile(e,n),unlink:e=>t.rm(e),readdir:async e=>(await t.readdir(e)).map(e=>e.name),mkdir:e=>t.mkdir(e),rmdir:e=>t.rm(e),stat:n,lstat:n,readlink:async e=>{throw new r(`ENOENT`,e)},symlink:async(e,t)=>{throw new r(`EACCES`,t,`symbolic links are not supported`)},chmod:async()=>void 0}}}function $a(e,t){if(e.length*t.length>4e6)return[`${i.dim}(file too large to diff: ${e.length} → ${t.length} lines)${i.reset}`];let n=t.length+1,r=new Uint32Array((e.length+1)*n);for(let i=e.length-1;i>=0;i--)for(let a=t.length-1;a>=0;a--)r[i*n+a]=e[i]===t[a]?r[(i+1)*n+a+1]+1:Math.max(r[(i+1)*n+a],r[i*n+a+1]);let a=[],o=0,s=0;for(;o<e.length||s<t.length;)o<e.length&&s<t.length&&e[o]===t[s]?(o++,s++):s<t.length&&(o===e.length||r[o*n+s+1]>=r[(o+1)*n+s])?a.push(`${i.green}+${t[s++]}${i.reset}`):a.push(`${i.red}-${e[o++]}${i.reset}`);return a}var eo={commands:[{name:`git`,summary:`version control (local repositories; clone needs a relay)`,usage:`git init | status | add <path…> | commit -m "msg" [-a] | log [-n N] [--oneline] | diff [path] | branch [name] | checkout [-b] <name> | clone <url> [dir] | config <key> [value]`,async run(e){let[t,...r]=e.args,{os:a,out:o}=e,s=Qa(a),c={...Za,...a.settings.get(Xa,{})},l=async()=>{try{return await Oa({fs:s,filepath:e.shell.cwd})}catch{throw Error("not a git repository (run `git init`)")}},u=(t,n)=>{let r=e.path(n);return r===t?`.`:r.slice(t.length+1)},d=async e=>(await Ha({fs:s,dir:e})).filter(([,e,t,n])=>e!==1||t!==1||n!==1);switch(t){case`init`:{let t=e.path(r[0]??`.`);await ka({fs:s,dir:t,defaultBranch:`main`}),o(`Initialized empty Git repository in ${t}/.git/\n`);return}case`config`:{let e={"user.name":`name`,"user.email":`email`,"http.corsProxy":`corsProxy`},t=r[0]?e[r[0]]:void 0;if(!r[0])return void o(Object.entries(e).map(([e,t])=>`${e}=${c[t]}`).join(`
98
+ `),await e.write(r+`/HEAD`,`ref: refs/heads/${i}\n`)}async function Ca({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,onPostCheckout:c,dir:l,gitdir:u,url:d,corsProxy:f,ref:p,remote:m,depth:h,since:g,exclude:_,relative:v,singleBranch:y,noCheckout:b,noTags:x,headers:S,nonBlocking:C,batchSize:w=100}){try{if(await Sa({fs:e,gitdir:u}),await Ai({fs:e,gitdir:u,remote:m,url:d,force:!1}),f){let t=await un.get({fs:e,gitdir:u});await t.set(`http.corsProxy`,f),await un.save({fs:e,gitdir:u,config:t})}let{defaultBranch:T,fetchHead:E}=await xa({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,gitdir:u,ref:p,remote:m,corsProxy:f,depth:h,since:g,exclude:_,relative:v,singleBranch:y,headers:S,tags:!x});if(E===null)return;p||=T,p=p.replace(`refs/heads/`,``),await Pi({fs:e,cache:t,onProgress:r,onPostCheckout:c,dir:l,gitdir:u,ref:p,remote:m,noCheckout:b,nonBlocking:C,batchSize:w})}catch(t){throw await e.rmdir(u,{recursive:!0,maxRetries:10}).catch(()=>void 0),t}}async function wa({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:s,dir:c,gitdir:l=Z(c,`.git`),url:u,corsProxy:d=void 0,ref:f=void 0,remote:p=`origin`,depth:m=void 0,since:h=void 0,exclude:g=[],relative:_=!1,singleBranch:v=!1,noCheckout:y=!1,noTags:b=!1,headers:x={},cache:S={},nonBlocking:C=!1,batchSize:w=100}){try{$(`fs`,e),$(`http`,t),$(`gitdir`,l),y||$(`dir`,c),$(`url`,u);let T=new ti(e);return await Ca({fs:T,cache:S,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:s,dir:c,gitdir:await ii({fsp:T,dotgit:l}),url:u,corsProxy:d,ref:f,remote:p,depth:m,since:h,exclude:g,relative:_,singleBranch:v,noCheckout:y,noTags:b,headers:x,nonBlocking:C,batchSize:w})}catch(e){throw e.caller=`git.clone`,e}}async function Ta({fs:e,onSign:t,dir:n,gitdir:r=Z(n,`.git`),message:i,author:a,committer:o,signingKey:s,amend:c=!1,dryRun:l=!1,noUpdateBranch:u=!1,disallowEmpty:d=!1,ref:f,parent:p,tree:m,cache:h={}}){try{$(`fs`,e),c||$(`message`,i),s&&$(`onSign`,t);let n=new ti(e);return await Ti({fs:n,cache:h,onSign:t,gitdir:await ii({fsp:n,dotgit:r}),message:i,author:a,committer:o,signingKey:s,amend:c,dryRun:l,noUpdateBranch:u,disallowEmpty:d,ref:f,parent:p,tree:m})}catch(e){throw e.caller=`git.commit`,e}}async function Ea({fs:e,dir:t,gitdir:n=Z(t,`.git`),fullname:r=!1,test:i=!1}){try{$(`fs`,e),$(`gitdir`,n);let t=new ti(e);return await Hi({fs:t,gitdir:await ii({fsp:t,dotgit:n}),fullname:r,test:i})}catch(e){throw e.caller=`git.currentBranch`,e}}async function Da({fs:e,filepath:t}){if(await e.exists(Z(t,`.git`)))return t;{let n=Et(t);if(n===t)throw new Mt(`git root for ${t}`);return Da({fs:e,filepath:n})}}async function Oa({fs:e,filepath:t}){try{return $(`fs`,e),$(`filepath`,t),await Da({fs:new ti(e),filepath:t})}catch(e){throw e.caller=`git.findRoot`,e}}async function ka({fs:e,bare:t=!1,dir:n,gitdir:r=t?n:Z(n,`.git`),defaultBranch:i=`master`}){try{$(`fs`,e),$(`gitdir`,r),t||$(`dir`,n);let a=new ti(e);return await Sa({fs:a,bare:t,dir:n,gitdir:await ii({fsp:a,dotgit:r}),defaultBranch:i})}catch(e){throw e.caller=`git.init`,e}}async function Aa({fs:e,dir:t,gitdir:n=Z(t,`.git`),remote:r}){try{$(`fs`,e),$(`gitdir`,n);let t=new ti(e),i=await ii({fsp:t,dotgit:n});return Q.listBranches({fs:t,gitdir:i,remote:r})}catch(e){throw e.caller=`git.listBranches`,e}}function ja(e,t){return e.committer.timestamp-t.committer.timestamp}async function Ma({fs:e,cache:t,gitdir:n,oid:r,fileId:i}){if(i===`e69de29bb2d1d6434b8b29ae775ad8c2e48c5391`)return;let a=r,o,s=await Ir({fs:e,cache:t,gitdir:n,oid:r}),c=s.tree;return i===s.oid?o=s.path:(o=await Na({fs:e,cache:t,gitdir:n,tree:c,fileId:i,oid:a}),Array.isArray(o)&&(o.length===0?o=void 0:o.length===1&&(o=o[0]))),o}async function Na({fs:e,cache:t,gitdir:n,tree:r,fileId:i,oid:a,filepaths:o=[],parentPath:s=``}){let c=r.entries().map(function(r){let c;return r.oid===i?(c=Z(s,r.path),o.push(c)):r.type===`tree`&&(c=Yn({fs:e,cache:t,gitdir:n,oid:r.oid}).then(function({object:c}){return Na({fs:e,cache:t,gitdir:n,tree:bn.from(c),fileId:i,oid:a,filepaths:o,parentPath:Z(s,r.path)})})),c});return await Promise.all(c),o}async function Pa({fs:e,cache:t,gitdir:n,filepath:r,ref:i,depth:a,since:o,author:s,force:c,follow:l,includeChanges:u}){let d=o===void 0?void 0:Math.floor(o.valueOf()/1e3),f=s==null?void 0:new RegExp(s,`i`),p=({commit:e})=>f===void 0?!0:e.author?f.test(`${e.author.name} <${e.author.email}>`):!1,m=[],h=e=>{p(e)&&m.push(e)},g=await ua.read({fs:e,gitdir:n}),_=[await wi({fs:e,cache:t,gitdir:n,oid:await Q.resolve({fs:e,gitdir:n,ref:i})})],v,y,b,x;function S(e){x&&r&&h(e)}for(;_.length>0;){let i=_.pop();if(d!==void 0&&i.commit.committer.timestamp<=d)break;if(r){let a;try{a=await Oi({fs:e,cache:t,gitdir:n,oid:i.commit.tree,filepath:r}),b&&(v!==a.oid||y!==a.mode)&&h(b),v=a.oid,y=a.mode,b=i,x=!0}catch(a){if(a instanceof Mt){let o=l&&v;if(o&&(o=await Ma({fs:e,cache:t,gitdir:n,oid:i.commit.tree,fileId:v}),o)){if(Array.isArray(o)){if(b){let i=await Ma({fs:e,cache:t,gitdir:n,oid:b.commit.tree,fileId:v});if(Array.isArray(i)){if(o=o.filter(e=>i.indexOf(e)===-1),o.length===1)o=o[0],r=o,b&&h(b);else{o=!1,b&&h(b);break}}}}else r=o,b&&h(b)}if(!o){if(x&&v&&(h(b),!c))break;if(!c&&!l)throw a}b=i,x=!1}else throw a}}else h(i);if(a!==void 0&&m.length===a){S(i);break}if(!g.has(i.oid))for(let r of i.commit.parent){let i=await wi({fs:e,cache:t,gitdir:n,oid:r});_.map(e=>e.oid).includes(i.oid)||_.push(i)}_.length===0&&S(i),_.sort((e,t)=>ja(e.commit,t.commit))}if(u)for(let r of m)r.commit.changes=await Fa({fs:e,cache:t,gitdir:n,commit:r,shallow:g.has(r.oid)});return m}async function Fa({fs:e,cache:t,gitdir:n,commit:r,shallow:i}){let a=i||!r.commit.parent[0]?`4b825dc642cb6eb9a060e54bf8d69288fbee4904`:r.commit.parent[0];return Gr({fs:e,cache:t,gitdir:n,trees:[Rr({ref:r.oid}),Rr({ref:a})],map:async(e,[t,n])=>{let[r,i]=await Promise.all([t&&t.type(),n&&n.type()]);if(r===`tree`)return i&&i!==`tree`?[null,await n.oid(),e]:void 0;if(i===`tree`)return r?[await t.oid(),null,e]:void 0;let[a,o]=await Promise.all([t?t.oid():null,n?n.oid():null]);if(a!==o)return[a,o,e]}})}async function Ia({fs:e,dir:t,gitdir:n=Z(t,`.git`),filepath:r,ref:i=`HEAD`,depth:a,since:o,author:s,force:c,follow:l,includeChanges:u=!1,cache:d={}}){try{$(`fs`,e),$(`gitdir`,n),$(`ref`,i);let t=new ti(e);return await Pa({fs:t,cache:d,gitdir:await ii({fsp:t,dotgit:n}),filepath:r,ref:i,depth:a,since:o,author:s,force:c,follow:l,includeChanges:u})}catch(e){throw e.caller=`git.log`,e}}async function La({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await Yn({fs:e,cache:t,gitdir:n,oid:r});if(i===`tag`)return r=Mr.from(a).parse().object,La({fs:e,cache:t,gitdir:n,oid:r});if(i!==`blob`)throw new Nt(r,i,`blob`);return{oid:r,blob:new Uint8Array(a)}}async function Ra({fs:e,cache:t,gitdir:n,oid:r,filepath:i=void 0}){return i!==void 0&&(r=await Di({fs:e,cache:t,gitdir:n,oid:r,filepath:i})),await La({fs:e,cache:t,gitdir:n,oid:r})}async function za({fs:e,dir:t,gitdir:n=Z(t,`.git`),oid:r,filepath:i,cache:a={}}){try{$(`fs`,e),$(`gitdir`,n),$(`oid`,r);let t=new ti(e);return await Ra({fs:t,cache:a,gitdir:await ii({fsp:t,dotgit:n}),oid:r,filepath:i})}catch(e){throw e.caller=`git.readBlob`,e}}async function Ba({fs:e,dir:t,gitdir:n=Z(t,`.git`),filepath:r,cache:i={}}){try{$(`fs`,e),$(`gitdir`,n),$(`filepath`,r);let t=new ti(e),a=await ii({fsp:t,dotgit:n});await wt.acquire({fs:t,gitdir:a,cache:i},async function(e){let t=Array.isArray(r)?r:[r];for(let n of t)e.delete({filepath:n})})}catch(e){throw e.caller=`git.remove`,e}}async function Va({fs:e,dir:t,gitdir:n=Z(t,`.git`),ref:r,depth:i}){try{$(`fs`,e),$(`gitdir`,n),$(`ref`,r);let t=new ti(e),a=await ii({fsp:t,dotgit:n});return await Q.resolve({fs:t,gitdir:a,ref:r,depth:i})}catch(e){throw e.caller=`git.resolveRef`,e}}async function Ha({fs:e,dir:t,gitdir:n=Z(t,`.git`),ref:r=`HEAD`,filepaths:i=[`.`],filter:a,cache:o={},ignored:s=!1,refresh:c=!0}){try{$(`fs`,e),$(`gitdir`,n),$(`ref`,r);let l=new ti(e);return await Gr({fs:l,cache:o,dir:t,gitdir:await ii({fsp:l,dotgit:n}),trees:[Rr({ref:r}),Br({refresh:c}),jt()],map:async function(e,[n,r,o]){if(!n&&!o&&r&&!s&&await ai.isIgnored({fs:l,dir:t,filepath:e})||!i.some(t=>Ni(e,t)))return null;if(a&&!a(e))return;let[c,u,d]=await Promise.all([n&&n.type(),r&&r.type(),o&&o.type()]),f=[c,u,d].includes(`blob`);if((c===`tree`||c===`special`)&&!f)return;if(c===`commit`)return null;if((u===`tree`||u===`special`)&&!f)return;if(d===`commit`)return null;if((d===`tree`||d===`special`)&&!f)return;let p=c===`blob`?await n.oid():void 0,m=d===`blob`?await o.oid():void 0,h;c!==`blob`&&u===`blob`&&d!==`blob`?h=`42`:u===`blob`&&(h=await r.oid());let g=[void 0,p,h,m],_=g.map(e=>g.indexOf(e));return _.shift(),[e,..._]}})}catch(e){throw e.caller=`git.statusMatrix`,e}}function Ua(e){let t=[e];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}function Wa(e){return e[Symbol.asyncIterator]?e[Symbol.asyncIterator]():e[Symbol.iterator]?e[Symbol.iterator]():e.next?e:Ua(e)}async function Ga(e,t){let n=Wa(e);for(;;){let{value:e,done:r}=await n.next();if(e&&await t(e),r)break}n.return&&n.return()}async function Ka(e){let t=0,n=[];await Ga(e,e=>{n.push(e),t+=e.byteLength});let r=new Uint8Array(t),i=0;for(let e of n)r.set(e,i),i+=e.byteLength;return r}function qa(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{next(){return t.read()},return(){return t.releaseLock(),{}},[Symbol.asyncIterator](){return this}}}async function Ja({onProgress:e,url:t,method:n=`GET`,headers:r={},fetchOptions:i={},body:a,signal:o}){a&&=await Ka(a);let s=await fetch(t,{...i,method:n,headers:r,body:a,signal:o??i.signal}),c=s.body&&s.body.getReader?qa(s.body):[new Uint8Array(await s.arrayBuffer())];r={};for(let[e,t]of s.headers.entries())r[e]=t;return{url:s.url,method:s.method,statusCode:s.status,statusMessage:s.statusText,body:c,headers:r}}var Ya={request:Ja};const Xa=`git.config`,Za={name:`BrowserBox User`,email:`user@browserbox.local`,corsProxy:``};function Qa(e){let t=e.fs,n=async e=>{let n=await t.stat(e);if(!n)throw new i(`ENOENT`,e);let r=n.kind===`dir`;return{type:r?`dir`:`file`,mode:r?16384:33188,size:n.size,ino:0,mtimeMs:n.mtime,ctimeMs:n.mtime,uid:1,gid:1,dev:1,isFile:()=>!r,isDirectory:()=>r,isSymbolicLink:()=>!1}};return{promises:{readFile:async(e,n)=>{let r=typeof n==`string`?n:n?.encoding,i=await t.readFile(e);return r===`utf8`?new TextDecoder().decode(i):i},writeFile:(e,n)=>t.writeFile(e,n),unlink:e=>t.rm(e),readdir:async e=>(await t.readdir(e)).map(e=>e.name),mkdir:e=>t.mkdir(e),rmdir:e=>t.rm(e),stat:n,lstat:n,readlink:async e=>{throw new i(`ENOENT`,e)},symlink:async(e,t)=>{throw new i(`EACCES`,t,`symbolic links are not supported`)},chmod:async()=>void 0}}}function $a(e,t){if(e.length*t.length>4e6)return[`${n.dim}(file too large to diff: ${e.length} → ${t.length} lines)${n.reset}`];let r=t.length+1,i=new Uint32Array((e.length+1)*r);for(let n=e.length-1;n>=0;n--)for(let a=t.length-1;a>=0;a--)i[n*r+a]=e[n]===t[a]?i[(n+1)*r+a+1]+1:Math.max(i[(n+1)*r+a],i[n*r+a+1]);let a=[],o=0,s=0;for(;o<e.length||s<t.length;)o<e.length&&s<t.length&&e[o]===t[s]?(o++,s++):s<t.length&&(o===e.length||i[o*r+s+1]>=i[(o+1)*r+s])?a.push(`${n.green}+${t[s++]}${n.reset}`):a.push(`${n.red}-${e[o++]}${n.reset}`);return a}var eo={commands:[{name:`git`,summary:`version control (local repositories; clone needs a relay)`,usage:`git init | status | add <path…> | commit -m "msg" [-a] | log [-n N] [--oneline] | diff [path] | branch [name] | checkout [-b] <name> | clone <url> [dir] | config <key> [value]`,async run(e){let[t,...i]=e.args,{os:a,out:o}=e,s=Qa(a),c={...Za,...a.settings.get(Xa,{})},l=async()=>{try{return await Oa({fs:s,filepath:e.shell.cwd})}catch{throw Error("not a git repository (run `git init`)")}},u=(t,n)=>{let r=e.path(n);return r===t?`.`:r.slice(t.length+1)},d=async e=>(await Ha({fs:s,dir:e})).filter(([,e,t,n])=>e!==1||t!==1||n!==1);switch(t){case`init`:{let t=e.path(i[0]??`.`);await ka({fs:s,dir:t,defaultBranch:`main`}),o(`Initialized empty Git repository in ${t}/.git/\n`);return}case`config`:{let e={"user.name":`name`,"user.email":`email`,"http.corsProxy":`corsProxy`},t=i[0]?e[i[0]]:void 0;if(!i[0])return void o(Object.entries(e).map(([e,t])=>`${e}=${c[t]}`).join(`
99
99
  `)+`
100
- `);if(!t)throw Error(`unknown key (use ${Object.keys(e).join(`, `)})`);if(r[1]===void 0)return void o(c[t]+`
101
- `);a.settings.set(Xa,{...c,[t]:r.slice(1).join(` `)});return}case`clone`:{let t=r[0];if(!t)throw Error(`usage: git clone <url> [dir]`);if(!c.corsProxy)throw Error(`Git hosts block direct access from browsers, so cloning needs a relay you trust.
100
+ `);if(!t)throw Error(`unknown key (use ${Object.keys(e).join(`, `)})`);if(i[1]===void 0)return void o(c[t]+`
101
+ `);a.settings.set(Xa,{...c,[t]:i.slice(1).join(` `)});return}case`clone`:{let t=i[0];if(!t)throw Error(`usage: git clone <url> [dir]`);if(!c.corsProxy)throw Error(`Git hosts block direct access from browsers, so cloning needs a relay you trust.
102
102
  Set one with: git config http.corsProxy https://your-proxy.example
103
- (everything you clone passes through it)`);let n=e.path(r[1]??t.replace(/\/+$/,``).split(`/`).pop().replace(/\.git$/,``));o(`Cloning into '${n}'…\n`),await wa({fs:s,http:Ya,dir:n,url:t,corsProxy:c.corsProxy,singleBranch:!0,depth:50,onMessage:e=>o(i.dim+e+i.reset)}),o(`done.
103
+ (everything you clone passes through it)`);let r=e.path(i[1]??t.replace(/\/+$/,``).split(`/`).pop().replace(/\.git$/,``));o(`Cloning into '${r}'…\n`),await wa({fs:s,http:Ya,dir:r,url:t,corsProxy:c.corsProxy,singleBranch:!0,depth:50,onMessage:e=>o(n.dim+e+n.reset)}),o(`done.
104
104
  `);return}case`status`:{let e=await l();o(`On branch ${await Ea({fs:s,dir:e})??`(detached)`}\n`);let t=await d(e);if(!t.length)return void o(`nothing to commit, working tree clean
105
- `);for(let[e,n,r,a]of t){let t=a!==n&&(n!==0||a!==0);o(`${n===0&&a===0?`${i.red}?? `:r===0?`${t?i.green:i.red}D `:n===0?`${i.green}A `:`${t&&a===r?i.green:i.red}M `}${e}${i.reset}\n`)}return}case`add`:{let e=await l();if(!r.length)throw Error(`usage: git add <path…>`);for(let t of r){let n=u(e,t);for(let[t,,r]of await Ha({fs:s,dir:e,filepaths:[n]}))await(r===0?Ba({fs:s,dir:e,filepath:t}):pi({fs:s,dir:e,filepath:t}))}return}case`commit`:{let e=await l(),t=r.indexOf(`-m`),i=t>=0?r[t+1]:void 0;if(!i)throw Error(`usage: git commit -m "message" [-a]`);if(n(r).opts.has(`a`))for(let[t,n,r]of await d(e))n===1&&await(r===0?Ba({fs:s,dir:e,filepath:t}):pi({fs:s,dir:e,filepath:t}));if(!(await d(e)).some(([,e,,t])=>t!==e))throw Error("nothing staged to commit (use `git add`)");let a=await Ta({fs:s,dir:e,message:i,author:{name:c.name,email:c.email}});o(`[${await Ea({fs:s,dir:e})??`detached`} ${a.slice(0,7)}] ${i}\n`);return}case`log`:{let e=await l(),t=r.indexOf(`-n`),n=await Ia({fs:s,dir:e,depth:t>=0?Number(r[t+1])||10:20});for(let e of n)r.includes(`--oneline`)?o(`${i.yellow}${e.oid.slice(0,7)}${i.reset} ${e.commit.message.split(`
106
- `)[0]}\n`):o(`${i.yellow}commit ${e.oid}${i.reset}\nAuthor: ${e.commit.author.name} <${e.commit.author.email}>\nDate: ${(/* @__PURE__ */ new Date(e.commit.author.timestamp*1e3)).toISOString()}\n\n ${e.commit.message.trim().replace(/\n/g,`
107
- `)}\n\n`);return}case`diff`:{let e=await l(),t=r[0]?u(e,r[0]):null;for(let[n,r,c]of await d(e)){if(t&&n!==t&&!n.startsWith(t+`/`))continue;let l=r===1?new TextDecoder().decode((await za({fs:s,dir:e,oid:await Va({fs:s,dir:e,ref:`HEAD`}),filepath:n})).blob):``,u=c===0?``:await a.fs.readText(`${e}/${n}`);o(`${i.bold}--- ${r===1?`a/`+n:`/dev/null`}\n+++ ${c===0?`/dev/null`:`b/`+n}${i.reset}\n${$a(l?l.split(`
105
+ `);for(let[e,r,i,a]of t){let t=a!==r&&(r!==0||a!==0);o(`${r===0&&a===0?`${n.red}?? `:i===0?`${t?n.green:n.red}D `:r===0?`${n.green}A `:`${t&&a===i?n.green:n.red}M `}${e}${n.reset}\n`)}return}case`add`:{let e=await l();if(!i.length)throw Error(`usage: git add <path…>`);for(let t of i){let n=u(e,t);for(let[t,,r]of await Ha({fs:s,dir:e,filepaths:[n]}))await(r===0?Ba({fs:s,dir:e,filepath:t}):pi({fs:s,dir:e,filepath:t}))}return}case`commit`:{let e=await l(),t=i.indexOf(`-m`),n=t>=0?i[t+1]:void 0;if(!n)throw Error(`usage: git commit -m "message" [-a]`);if(r(i).opts.has(`a`))for(let[t,n,r]of await d(e))n===1&&await(r===0?Ba({fs:s,dir:e,filepath:t}):pi({fs:s,dir:e,filepath:t}));if(!(await d(e)).some(([,e,,t])=>t!==e))throw Error("nothing staged to commit (use `git add`)");let a=await Ta({fs:s,dir:e,message:n,author:{name:c.name,email:c.email}});o(`[${await Ea({fs:s,dir:e})??`detached`} ${a.slice(0,7)}] ${n}\n`);return}case`log`:{let e=await l(),t=i.indexOf(`-n`),r=await Ia({fs:s,dir:e,depth:t>=0?Number(i[t+1])||10:20});for(let e of r)i.includes(`--oneline`)?o(`${n.yellow}${e.oid.slice(0,7)}${n.reset} ${e.commit.message.split(`
106
+ `)[0]}\n`):o(`${n.yellow}commit ${e.oid}${n.reset}\nAuthor: ${e.commit.author.name} <${e.commit.author.email}>\nDate: ${(/* @__PURE__ */ new Date(e.commit.author.timestamp*1e3)).toISOString()}\n\n ${e.commit.message.trim().replace(/\n/g,`
107
+ `)}\n\n`);return}case`diff`:{let e=await l(),t=i[0]?u(e,i[0]):null;for(let[r,i,c]of await d(e)){if(t&&r!==t&&!r.startsWith(t+`/`))continue;let l=i===1?new TextDecoder().decode((await za({fs:s,dir:e,oid:await Va({fs:s,dir:e,ref:`HEAD`}),filepath:r})).blob):``,u=c===0?``:await a.fs.readText(`${e}/${r}`);o(`${n.bold}--- ${i===1?`a/`+r:`/dev/null`}\n+++ ${c===0?`/dev/null`:`b/`+r}${n.reset}\n${$a(l?l.split(`
108
108
  `):[],u?u.split(`
109
109
  `):[]).join(`
110
- `)}\n`)}return}case`branch`:{let e=await l();if(r[0])return void await Mi({fs:s,dir:e,ref:r[0]});let t=await Ea({fs:s,dir:e});for(let n of await Aa({fs:s,dir:e}))o(`${n===t?`${i.green}* `:` `}${n}${i.reset}\n`);return}case`checkout`:{let e=await l(),t=r[0]===`-b`,n=t?r[1]:r[0];if(!n)throw Error(`usage: git checkout [-b] <branch>`);t&&await Mi({fs:s,dir:e,ref:n}),await zi({fs:s,dir:e,ref:n}),o(`Switched to ${t?`a new `:``}branch '${n}'\n`);return}default:throw Error(t?`unsupported git command: ${t}\n${this.usage}`:`usage: ${this.usage}`)}}}]};export{eo as default};
110
+ `)}\n`)}return}case`branch`:{let e=await l();if(i[0])return void await Mi({fs:s,dir:e,ref:i[0]});let t=await Ea({fs:s,dir:e});for(let r of await Aa({fs:s,dir:e}))o(`${r===t?`${n.green}* `:` `}${r}${n.reset}\n`);return}case`checkout`:{let e=await l(),t=i[0]===`-b`,n=t?i[1]:i[0];if(!n)throw Error(`usage: git checkout [-b] <branch>`);t&&await Mi({fs:s,dir:e,ref:n}),await zi({fs:s,dir:e,ref:n}),o(`Switched to ${t?`a new `:``}branch '${n}'\n`);return}default:throw Error(t?`unsupported git command: ${t}\n${this.usage}`:`usage: ${this.usage}`)}}}]};export{eo as default};
@@ -0,0 +1,6 @@
1
+ import{a as e,i as t,r as n,s as r}from"./main-CQvaEX7y.js";function i(e,t){return t.value!==void 0&&t.value!==`None`&&e.out(t.value+`
2
+ `),t.error&&e.err(t.error+`
3
+ `),+!t.ok}const a=(e,t)=>r(e.os,t,{cwd:e.shell.cwd,env:n(e.shell.env),signal:e.signal,onStdout:e.out,onStderr:e.err}),o={name:`python`,summary:`run Python 3.13 (CPython on WebAssembly, via Pyodide)`,usage:`python file.py | python -c "code" | python -m pip install <pkg> | python -V (files in the cwd are visible; changes are written back)`,async run(e){let{opts:n,rest:r}=t(e.args);if(n.has(`V`)||n.has(`version`))return i(e,await a(e,`import sys, pyodide
4
+ print(f"Python {sys.version.split()[0]} (Pyodide {pyodide.__version__})")`));if(n.has(`m`))return r[0]===`pip`?s.run({...e,args:r.slice(1)}):i(e,await a(e,`import runpy, sys\nsys.argv = ${JSON.stringify(r)}\nrunpy.run_module(${JSON.stringify(r[0]??``)}, run_name="__main__")`));let o=n.has(`c`)?r[0]??``:r[0]?await e.os.fs.readText(e.path(r[0])):e.stdin;if(!o.trim())throw Error(`nothing to run: pass a file, -c "code", or pipe code in`);return i(e,await a(e,o))}},s={name:`pip`,summary:`install Python packages (PyPI pure-Python wheels and Pyodide builds) with micropip`,usage:`pip install <pkg>… | pip install -r requirements.txt | pip uninstall <pkg>… | pip list | pip show <pkg> | pip freeze`,async run(t){let[n=`help`,...r]=t.args,o=()=>t.os.settings.get(e,[]),c=e=>e.split(/[<>=!~\[; ]/)[0].toLowerCase();if(n===`install`){let n=[];for(let e=0;e<r.length;e++){let i=r[e];if(i===`-r`||i===`--requirement`){let i=await t.os.fs.readText(t.path(r[++e]??``));n.push(...i.split(`
5
+ `).map(e=>e.replace(/#.*/,``).trim()).filter(e=>e&&!e.startsWith(`-`)))}else i.startsWith(`-`)||n.push(i)}if(!n.length)throw Error(`usage: pip install <pkg>… | pip install -r requirements.txt`);t.out(`Installing ${n.join(`, `)}…\n`);let s=await a(t,`import micropip\nawait micropip.install(${JSON.stringify(n)}, keep_going=True)\ninstalled = micropip.list()\nfor s in ${JSON.stringify(n.map(c))}:\n p = installed.get(s) or installed.get(s.replace("_", "-"))\n print(f"Successfully installed {s}-{p.version}" if p else f"{s}: installed")`);if(!s.ok)return i(t,s);let l=o().filter(e=>!n.some(t=>c(t)===c(e)));return t.os.settings.set(e,[...l,...n]),i(t,s)}if(n===`uninstall`){let n=r.filter(e=>!e.startsWith(`-`));return t.os.settings.set(e,o().filter(e=>!n.some(t=>c(t)===c(e)))),i(t,await a(t,`import micropip\nfor n in ${JSON.stringify(n)}:\n try:\n micropip.uninstall(n); print(f"Successfully uninstalled {n}")\n except Exception as e:\n print(f"{n}: {e}")`))}return n===`list`||n===`freeze`?i(t,await a(t,`import micropip\n${n===`list`?`print(f"{'Package':<32} {'Version':<14} Source")
6
+ `:``}for name, p in sorted(micropip.list().items()):\n ${n===`freeze`?`print(f"{name}=={p.version}")`:`print(f"{name:<32} {p.version:<14} {p.source}")`}`)):n===`show`?i(t,await a(t,`import micropip\nfrom importlib import metadata\nfor n in ${JSON.stringify(r)}:\n try:\n m = metadata.metadata(n)\n print(f"Name: {m['Name']}\\nVersion: {m['Version']}\\nSummary: {m.get('Summary', '')}\\nRequires: {', '.join(metadata.requires(n) or [])}\\n")\n except metadata.PackageNotFoundError:\n print(f"WARNING: Package(s) not found: {n}")`)):(t.out(`${s.usage}\n\nRuns micropip in the Python sandbox: pure-Python wheels from PyPI and Pyodide's WebAssembly builds (numpy, pandas, scipy, matplotlib, scikit-learn…). Packages with other C extensions cannot install. Installed packages are reinstalled in each new interpreter.\n`),n===`help`?0:1)}};var c={commands:[o,{...o,name:`python3`},s,{...s,name:`pip3`}]};export{c as default};
@@ -1,4 +1,4 @@
1
- import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";var n=/* @__PURE__ */ e((/* @__PURE__ */ t(((e,t)=>{var n=void 0,r=function(e){return n||(n=new Promise(function(n,r){var i=e===void 0?{}:e,a=i.onAbort;i.onAbort=function(e){r(Error(e)),a&&a(e)},i.postRun=i.postRun||[],i.postRun.push(function(){n(i)}),t=void 0;var o;o||=i===void 0?{}:i;var s=!!globalThis.window,c=!!globalThis.WorkerGlobalScope;o.onRuntimeInitialized=function(){function e(e,t){Ee(e,t instanceof Error?t.message:String(t),-1)}function t(e,t){switch(typeof t){case`boolean`:Te(e,+!!t);break;case`number`:xe(e,t);break;case`string`:Ce(e,t,T(t),-1);break;case`object`:if(t===null)Se(e);else if(t.length!=null){var n=jt(t.length);b.set(t,n),we(e,n,t.length,-1),X(n)}else Ee(e,`Wrong API use : tried to return a value of an unknown type (`+t+`).`,-1);break;default:Se(e)}}function n(e,t){for(var n=[],r=0;r<e;r+=1){var i=G(t+4*r,`i32`),a=_e(i);if(a===1||a===2)i=be(i);else if(a===3)a=D(i),i=ve(i),i=C(i,a,!0);else if(a===4){a=i,i=D(a),a=ye(a);for(var o=new Uint8Array(i),s=0;s<i;s+=1)o[s]=b[a+s];i=o}else i=null;n.push(i)}return n}function r(e,t){this.Va=e,this.db=t,this.Ta=1,this.Eb=[]}function i(e,t){if(this.db=t,this.tb=K(e),this.tb===null)throw Error(`Unable to allocate memory for the SQL string`);this.zb=this.tb,this.fb=this.Kb=null}function a(e){this.filename=`dbfile_`+(4294967295*Math.random()>>>0),e!=null&&ct(this.filename,e),this.handleError(f(this.filename,u)),this.db=G(u,`i32`),l&&De(this.db),this.Bb={},this.ab=/* @__PURE__ */ new Map}function s(e,t){return e.replace(/[A-Z]/g,function(e){return e.toLowerCase()})+`:`+t}function c(e){e.forEach(Dt)}var l=o.useOldExtensionFunctions!==!1,u=Z(4),d=o.cwrap,f=d(`sqlite3_open`,`number`,[`string`,`number`]),p=d(`sqlite3_close_v2`,`number`,[`number`]),m=d(`sqlite3_backup_init`,`number`,[`number`,`string`,`number`,`string`]),h=d(`sqlite3_backup_step`,`number`,[`number`,`number`]),g=d(`sqlite3_backup_finish`,`number`,[`number`]),_=d(`sqlite3_exec`,`number`,[`number`,`number`,`number`,`number`,`number`]),ee=d(`sqlite3_changes`,`number`,[`number`]),te=d(`sqlite3_sql`,`string`,[`number`]),ne=d(`sqlite3_normalized_sql`,`string`,[`number`]),re=d(`sqlite3_prepare_v2`,`number`,[`number`,`number`,`number`,`number`,`number`]),v=d(`sqlite3_bind_text`,`number`,[`number`,`number`,`number`,`number`,`number`]),y=d(`sqlite3_bind_blob`,`number`,[`number`,`number`,`number`,`number`,`number`]),ie=d(`sqlite3_bind_double`,`number`,[`number`,`number`,`number`]),ae=d(`sqlite3_bind_int`,`number`,[`number`,`number`,`number`]),oe=d(`sqlite3_bind_parameter_index`,`number`,[`number`,`string`]),se=d(`sqlite3_step`,`number`,[`number`]),ce=d(`sqlite3_errmsg`,`string`,[`number`]),le=d(`sqlite3_column_count`,`number`,[`number`]),x=d(`sqlite3_data_count`,`number`,[`number`]),S=d(`sqlite3_column_double`,`number`,[`number`,`number`]),ue=d(`sqlite3_column_text`,`number`,[`number`,`number`]),de=d(`sqlite3_column_blob`,`number`,[`number`,`number`]),fe=d(`sqlite3_column_bytes`,`number`,[`number`,`number`]),pe=d(`sqlite3_column_type`,`number`,[`number`,`number`]),me=d(`sqlite3_column_name`,`string`,[`number`,`number`]),w=d(`sqlite3_reset`,`number`,[`number`]),he=d(`sqlite3_clear_bindings`,`number`,[`number`]),E=d(`sqlite3_finalize`,`number`,[`number`]),ge=d(`sqlite3_create_function_v2`,`number`,`number string number number number number number number number`.split(` `)),_e=d(`sqlite3_value_type`,`number`,[`number`]),D=d(`sqlite3_value_bytes`,`number`,[`number`]),ve=d(`sqlite3_value_text`,`number`,[`number`]),ye=d(`sqlite3_value_blob`,`number`,[`number`]),be=d(`sqlite3_value_double`,`number`,[`number`]),xe=d(`sqlite3_result_double`,``,[`number`,`number`]),Se=d(`sqlite3_result_null`,``,[`number`]),Ce=d(`sqlite3_result_text`,``,[`number`,`string`,`number`,`number`]),we=d(`sqlite3_result_blob`,``,[`number`,`number`,`number`,`number`]),Te=d(`sqlite3_result_int`,``,[`number`,`number`]),Ee=d(`sqlite3_result_error`,``,[`number`,`string`,`number`]),O=d(`sqlite3_aggregate_context`,`number`,[`number`,`number`]),De=d(`RegisterExtensionFunctions`,`number`,[`number`]),k=d(`sqlite3_update_hook`,`number`,[`number`,`number`,`number`]);r.prototype.bind=function(e){if(!this.Va)throw`Statement closed`;return this.reset(),Array.isArray(e)?this.bc(e):typeof e==`object`&&e?this.cc(e):!0},r.prototype.step=function(){if(!this.Va)throw`Statement closed`;this.Ta=1;var e=se(this.Va);switch(e){case 100:return!0;case 101:return!1;default:throw this.db.handleError(e)}},r.prototype.Ub=function(e){return e??(e=this.Ta,this.Ta+=1),S(this.Va,e)},r.prototype.oc=function(e){if(e??(e=this.Ta,this.Ta+=1),typeof BigInt!=`function`)throw Error(`BigInt is not supported`);return BigInt(this.Vb(e))},r.prototype.Vb=function(e){e??(e=this.Ta,this.Ta+=1);var t=ue(this.Va,e);return e=fe(this.Va,e),C(t,e,!0)},r.prototype.getBlob=function(e){e??(e=this.Ta,this.Ta+=1);var t=fe(this.Va,e);e=de(this.Va,e);for(var n=new Uint8Array(t),r=0;r<t;r+=1)n[r]=b[e+r];return n},r.prototype.get=function(e,t){t||={},e!=null&&this.bind(e)&&this.step(),e=[];for(var n=x(this.Va),r=0;r<n;r+=1)switch(pe(this.Va,r)){case 1:var i=t.useBigInt?this.oc(r):this.Ub(r);e.push(i);break;case 2:e.push(this.Ub(r));break;case 3:e.push(this.Vb(r));break;case 4:e.push(this.getBlob(r));break;default:e.push(null)}return e},r.prototype.Ib=function(){for(var e=[],t=le(this.Va),n=0;n<t;n+=1)e.push(me(this.Va,n));return e},r.prototype.Tb=function(e,t){var n=this.get(e,t);return e=this.Ib(),Object.fromEntries(e.map(function(e,t){return[e,n[t]]}))},r.prototype.tc=function(){return te(this.Va)},r.prototype.qc=function(){return ne(this.Va)},r.prototype.run=function(e){return e!=null&&this.bind(e),this.step(),this.reset()},r.prototype.Pb=function(e,t){t??(t=this.Ta,this.Ta+=1);var n=K(e);this.Eb.push(n),this.db.handleError(v(this.Va,t,n,T(e),0))},r.prototype.ac=function(e,t){t??(t=this.Ta,this.Ta+=1);var n=jt(e.length);b.set(e,n),this.Eb.push(n),this.db.handleError(y(this.Va,t,n,e.length,0))},r.prototype.Ob=function(e,t){t??(t=this.Ta,this.Ta+=1),this.db.handleError((e===(e|0)?ae:ie)(this.Va,t,e))},r.prototype.dc=function(e){e??(e=this.Ta,this.Ta+=1),y(this.Va,e,0,0,0)},r.prototype.Qb=function(e,t){switch(t??(t=this.Ta,this.Ta+=1),typeof e){case`string`:this.Pb(e,t);return;case`number`:this.Ob(e,t);return;case`bigint`:this.Pb(e.toString(),t);return;case`boolean`:this.Ob(e+0,t);return;case`object`:if(e===null){this.dc(t);return}if(e.length!=null){this.ac(e,t);return}}throw`Wrong API use : tried to bind a value of an unknown type (`+e+`).`},r.prototype.cc=function(e){var t=this;return Object.keys(e).forEach(function(n){var r=oe(t.Va,n);r!==0&&t.Qb(e[n],r)}),!0},r.prototype.bc=function(e){for(var t=0;t<e.length;t+=1)this.Qb(e[t],t+1);return!0},r.prototype.reset=function(){return this.Hb(),he(this.Va)===0&&w(this.Va)===0},r.prototype.Hb=function(){for(var e;(e=this.Eb.pop())!==void 0;)X(e)},r.prototype.jb=function(){this.Hb();var e=E(this.Va)===0;return delete this.db.Bb[this.Va],this.Va=0,e},i.prototype.next=function(){if(this.tb===null)return{done:!0};if(this.fb!==null&&(this.fb.jb(),this.fb=null),!this.db.db)throw this.ub(),Error(`Database closed`);var e=Q(),t=Z(4);wt(u),wt(t);try{this.db.handleError(re(this.db.db,this.zb,-1,u,t)),this.zb=G(t,`i32`);var n=G(u,`i32`);return n===0?(this.ub(),{done:!0}):(this.fb=new r(n,this.db),this.db.Bb[n]=this.fb,{value:this.fb,done:!1})}catch(e){throw this.Kb=C(this.zb),this.ub(),e}finally{Pt(e)}},i.prototype.ub=function(){X(this.tb),this.tb=null},i.prototype.return=function(){return this.fb!==null&&(this.fb.jb(),this.fb=null),this.ub(),{done:!0}},i.prototype.rc=function(){return this.Kb===null?C(this.zb):this.Kb},typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`&&(i.prototype[Symbol.iterator]=function(){return this}),a.prototype.run=function(e,t){if(!this.db)throw`Database closed`;if(t){e=this.Lb(e,t);try{e.step()}finally{e.jb()}}else{e=K(e);try{this.handleError(_(this.db,e,0,0,u))}finally{X(e)}}return this},a.prototype.exec=function(e,t,n){if(!this.db)throw`Database closed`;var i=Q(),a=null,o=null,s=null;try{s=o=K(e);var c=Z(4);for(e=[];G(s,`i8`)!==0;){wt(u),wt(c),this.handleError(re(this.db,s,-1,u,c));var l=G(u,`i32`);if(s=G(c,`i32`),l!==0){var d=null;for(a=new r(l,this),t!=null&&a.bind(t);a.step();)d===null&&(d={columns:a.Ib(),values:[]},e.push(d)),d.values.push(a.get(null,n));a.jb()}}return e}catch(e){throw a&&a.jb(),e}finally{o&&X(o),Pt(i)}},a.prototype.lc=function(e,t,n,r,i){typeof t==`function`&&(r=n,n=t,t=void 0),e=this.Lb(e,t);try{for(;e.step();)n(e.Tb(null,i))}finally{e.jb()}if(typeof r==`function`)return r()},a.prototype.Lb=function(e,t){e=K(e);try{wt(u),this.handleError(re(this.db,e,-1,u,0))}finally{X(e)}if(e=G(u,`i32`),e===0)throw`Nothing to prepare`;var n=new r(e,this);return t!=null&&n.bind(t),this.Bb[e]=n},a.prototype.wc=function(e){return new i(e,this)},a.prototype.nc=function(){if(!this.db)throw Error(`Database closed`);var e=this.filename+`_export`;ct(e,[]);var t=0,n=0;try{var r=M(e).node,i=null,a=r.Qa.write;r.Qa=Object.create(r.Qa),r.Qa.write=function(e,t,n,o,s){return i===null?a(e,t,n,o,s):(r.Ua.set(t.subarray(n,n+o),s),r.Wa=Math.max(r.Wa,s+o),o)};var o=f(e,u);if(t=G(u,`i32`),o!==0||(n=m(t,`main`,this.db,`main`),n===0))throw Error(ce(t));if(o=h(n,0),o===0){var s=this.exec(`PRAGMA main.page_count; PRAGMA main.page_size`);i=new Uint8Array(s[0].values[0][0]*s[1].values[0][0]),r.Ua=i,o=h(n,-1)}if(o===5||o===6)throw Error(`Unable to export: SQLite is busy or locked. Finish active write transactions before exporting.`);if(o!==101||(o=g(n),n=0,o!==0)||(o=p(t),o!==0))throw Error(ce(t));return t=0,i=new Uint8Array(r.Ua.buffer,r.Ua.byteOffset,r.Wa),i.length>0&&(i[18]=1,i[19]=1),i}finally{n!==0&&g(n),t!==0&&p(t),Qe(`/`+e)}},a.prototype.close=function(){this.db!==null&&(Object.values(this.Bb).forEach(function(e){e.jb()}),this.ab.forEach(c),this.ab.clear(),this.lb&&=(Dt(this.lb),void 0),this.handleError(p(this.db)),Qe(`/`+this.filename),this.db=null)},a.prototype.handleError=function(e){if(e===0)return null;throw e=ce(this.db),Error(e)},a.prototype.sc=function(){return ee(this.db)},a.prototype.jc=function(r,i){var a=s(r,i.length);this.ab.has(a)&&(c(this.ab.get(a)),this.ab.delete(a));var o=J(function(r,a,o){a=n(a,o);try{var s=i.apply(null,a)}catch(t){e(r,t);return}t(r,s)},`viii`);return this.ab.set(a,[o]),this.handleError(ge(this.db,r,i.length,1,0,o,0,0,0)),this},a.prototype.hc=function(r,i){function a(e){return d.has(e)||d.set(e,o()),d.get(e)}var o=i.init||function(){return null},l=i.finalize||function(e){return e},u=i.step;if(!u)throw`An aggregate function must have a step function in `+r;var d=/* @__PURE__ */ new Map;i=s(r,u.length-1),this.ab.has(i)&&(c(this.ab.get(i)),this.ab.delete(i));var f=J(function(t,r,i){var o=O(t,1),s=a(o);r=n(r,i),s=[s].concat(r);try{d.set(o,u.apply(null,s))}catch(n){d.delete(o),e(t,n)}},`viii`),p=J(function(n){var r=O(n,1);try{var i=l(a(r))}catch(t){d.delete(r),e(n,t);return}t(n,i),d.delete(r)},`vi`);return this.ab.set(i,[f,p]),this.handleError(ge(this.db,r,u.length-1,1,0,0,f,p,0)),this},a.prototype.Dc=function(e){return this.lb&&=(k(this.db,0,0),Dt(this.lb),void 0),e&&(this.lb=J(function(t,n,r,i,a){switch(n){case 18:t=`insert`;break;case 23:t=`update`;break;case 9:t=`delete`;break;default:throw`unknown operationCode in updateHook callback: `+n}if(r=C(r),i=C(i),a>2**53-1)throw`rowId too big to fit inside a Number`;e(t,r,i,Number(a))},`viiiij`),k(this.db,this.lb,0)),this},r.prototype.bind=r.prototype.bind,r.prototype.step=r.prototype.step,r.prototype.get=r.prototype.get,r.prototype.getColumnNames=r.prototype.Ib,r.prototype.getAsObject=r.prototype.Tb,r.prototype.getSQL=r.prototype.tc,r.prototype.getNormalizedSQL=r.prototype.qc,r.prototype.run=r.prototype.run,r.prototype.reset=r.prototype.reset,r.prototype.freemem=r.prototype.Hb,r.prototype.free=r.prototype.jb,i.prototype.next=i.prototype.next,i.prototype.getRemainingSQL=i.prototype.rc,a.prototype.run=a.prototype.run,a.prototype.exec=a.prototype.exec,a.prototype.each=a.prototype.lc,a.prototype.prepare=a.prototype.Lb,a.prototype.iterateStatements=a.prototype.wc,a.prototype.export=a.prototype.nc,a.prototype.close=a.prototype.close,a.prototype.handleError=a.prototype.handleError,a.prototype.getRowsModified=a.prototype.sc,a.prototype.create_function=a.prototype.jc,a.prototype.create_aggregate=a.prototype.hc,a.prototype.updateHook=a.prototype.Dc,o.Database=a};var l=`./this.program`,u=globalThis.document?.currentScript?.src;c&&(u=self.location.href);var d=``,f,p;if(s||c){try{d=new URL(`.`,u).href}catch{}c&&(p=e=>{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.responseType=`arraybuffer`,t.send(null),new Uint8Array(t.response)}),f=async e=>{if(e=await fetch(e,{credentials:`same-origin`}),e.ok)return e.arrayBuffer();throw Error(e.status+` : `+e.url)}}var m=console.log.bind(console),h=console.error.bind(console),g,_=!1,ee;function te(){if(!b?.buffer?.resizable){var e=Ft.buffer;b=new Int8Array(e),dt=new Int16Array(e),S=new Uint8Array(e),V=new Int32Array(e),U=new Uint32Array(e),St=new Float32Array(e),Ct=new Float64Array(e),H=new BigInt64Array(e)}}function ne(){var e=o.preRun;for(e&&(typeof e==`function`&&(e=[e]),le.push(...e)),e=le;e.length>0;)e.shift()(o)}function re(){var e=o.postRun;for(e&&(typeof e==`function`&&(e=[e]),ce.push(...e)),e=ce;e.length>0;)e.shift()(o)}function v(e){throw o.onAbort?.(e),e=`Aborted(${e})`,h(e),_=!0,new WebAssembly.RuntimeError(e+`. Build with -sASSERTIONS for more info.`)}var y;async function ie(e){if(!g)try{return await f(e)}catch{}if(e==y&&g)e=new Uint8Array(g);else if(p)e=p(e);else throw`both async and sync fetching of the wasm failed`;return e}async function ae(e,t){try{var n=await ie(e);return await WebAssembly.instantiate(n,t)}catch(e){h(`failed to asynchronously prepare wasm: ${e}`),v(e)}}async function oe(e){var t=y;if(!g)try{var n=fetch(t,{credentials:`same-origin`});return await WebAssembly.instantiateStreaming(n,e)}catch(e){h(`wasm streaming compile failed: ${e}`),h(`falling back to ArrayBuffer instantiation`)}return ae(t,e)}class se{name=`ExitStatus`;constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var b,ce=[],le=[],x=!0,S,ue=new TextDecoder,de=(e,t,n,r)=>{if(n=t+n,r)return n;for(;e[t]&&!(t>=n);)++t;return t},C=(e,t,n)=>e?ue.decode(S.subarray(e,de(S,e,t,n))):``,fe=(e,t)=>{for(var n=0,r=e.length-1;r>=0;r--){var i=e[r];i===`.`?e.splice(r,1):i===`..`?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n;n--)e.unshift(`..`);return e},pe=e=>{var t=e.charAt(0)===`/`,n=e.slice(-1)===`/`;return(e=fe(e.split(`/`).filter(e=>!!e),!t).join(`/`))||t||(e=`.`),e&&n&&(e+=`/`),(t?`/`:``)+e},me=e=>{var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],!e&&!t?`.`:(t&&=t.slice(0,-1),e+t)},w=e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],he=(...e)=>{for(var t=``,n=!1,r=e.length-1;r>=-1&&!n;r--){if(n=r>=0?e[r]:`/`,typeof n!=`string`)throw TypeError(`Arguments to path.resolve must be strings`);if(!n)return``;t=n+`/`+t,n=n.charAt(0)===`/`}return t=fe(t.split(`/`).filter(e=>!!e),!n).join(`/`),(n?`/`:``)+t||`.`},T=e=>{for(var t=0,n=0;n<e.length;++n){var r=e.codePointAt(n);r<=127?t++:r<=2047?t+=2:r<=65535?t+=3:(t+=4,n++)}return t},E=(e,t,n,r)=>{if(!(r>0))return 0;var i=n;r=n+r-1;for(var a=0;a<e.length;++a){var o=e.codePointAt(a);if(o<=127){if(n>=r)break;t[n++]=o}else if(o<=2047){if(n+1>=r)break;t[n++]=192|o>>6,t[n++]=128|o&63}else if(o<=65535){if(n+2>=r)break;t[n++]=224|o>>12,t[n++]=128|o>>6&63,t[n++]=128|o&63}else{if(n+3>=r)break;t[n++]=240|o>>18,t[n++]=128|o>>12&63,t[n++]=128|o>>6&63,t[n++]=128|o&63,a++}}return t[n]=0,n-i},ge=e=>{var t=Array(T(e)+1);return e=E(e,t,0,t.length),t.length=e,t},_e=(e,t)=>{var n=0;return e&&(n|=365),t&&(n|=146),n},D={cb:null,hb(){return D.createNode(null,`/`,16895,0)},createNode(e,t,n,r){if((n&61440)==24576||(n&61440)==4096)throw new j(63);return D.cb||={dir:{node:{$a:D.Ra.$a,eb:D.Ra.eb,rb:D.Ra.rb,wb:D.Ra.wb,Zb:D.Ra.Zb,Db:D.Ra.Db,Ab:D.Ra.Ab,Nb:D.Ra.Nb,Cb:D.Ra.Cb},stream:{bb:D.Qa.bb}},file:{node:{$a:D.Ra.$a,eb:D.Ra.eb},stream:{bb:D.Qa.bb,read:D.Qa.read,write:D.Qa.write,xb:D.Qa.xb,yb:D.Qa.yb}},link:{node:{$a:D.Ra.$a,eb:D.Ra.eb,kb:D.Ra.kb},stream:{}},Rb:{node:{$a:D.Ra.$a,eb:D.Ra.eb},stream:We}},n=Le(e,t,n,r),P(n.mode)?(n.Ra=D.cb.dir.node,n.Qa=D.cb.dir.stream,n.Ua={}):(n.mode&61440)==32768?(n.Ra=D.cb.file.node,n.Qa=D.cb.file.stream,n.Wa=0,n.Ua=D.mc??=/* @__PURE__ */ new Uint8Array):(n.mode&61440)==40960?(n.Ra=D.cb.link.node,n.Qa=D.cb.link.stream):(n.mode&61440)==8192&&(n.Ra=D.cb.Rb.node,n.Qa=D.cb.Rb.stream),n.gb=n.Ya=n.Xa=Date.now(),e&&(e.Ua[t]=n,e.gb=e.Ya=e.Xa=n.gb),n},Ra:{$a(e){var t={};return t.kc=(e.mode&61440)==8192?e.id:1,t.vc=e.id,t.mode=e.mode,t.yc=1,t.uid=0,t.uc=0,t.sb=e.sb,t.size=P(e.mode)?4096:(e.mode&61440)==32768?e.Wa:(e.mode&61440)==40960?e.link.length:0,t.gb=new Date(e.gb),t.Ya=new Date(e.Ya),t.Xa=new Date(e.Xa),t.ec=4096,t.fc=Math.ceil(t.size/t.ec),t},eb(e,t){for(var n of[`mode`,`atime`,`mtime`,`ctime`])t[n]!=null&&(e[n]=t[n]);t.size!==void 0&&(t=t.size,e.Wa!=t&&(n=e.Ua,e.Ua=new Uint8Array(t),e.Ua.set(n.subarray(0,Math.min(t,e.Wa))),e.Wa=t))},rb(){throw D.Fb||(D.Fb=new j(44),D.Fb.stack=`<generic error, no stack>`),D.Fb},wb(e,t,n,r){return D.createNode(e,t,n,r)},Zb(e,t,n){try{var r=N(t,n)}catch{}if(r&&P(e.mode))for(var i in r.Ua)throw new j(55);delete e.parent.Ua[e.name],t.Ua[n]=e,e.name=n,t.Xa=t.Ya=e.parent.Xa=e.parent.Ya=Date.now()},Db(e,t){delete e.Ua[t],e.Xa=e.Ya=Date.now()},Ab(e,t){var n=N(e,t),r;for(r in n.Ua)throw new j(55);delete e.Ua[t],e.Xa=e.Ya=Date.now()},Nb(e){return[`.`,`..`,...Object.keys(e.Ua)]},Cb(e,t,n){return e=D.createNode(e,t,41471,0),e.link=n,e},kb(e){if((e.mode&61440)!=40960)throw new j(28);return e.link}},Qa:{read(e,t,n,r,i){return i>=e.node.Wa?0:(r=Math.min(e.node.Wa-i,r),t.set(e.node.Ua.subarray(i,i+r),n),r)},write(e,t,n,r,i,a){if(t.buffer===b.buffer&&(a=!1),!r)return 0;if(e=e.node,e.Ya=e.Xa=Date.now(),a)e.Ua=t.subarray(n,n+r),e.Wa=r;else if(e.Wa||i){a=i+r;var o=e.Ua.length;o>=a||(a=Math.max(a,o*(o<1048576?2:1.125)>>>0),o&&(a=Math.max(a,256)),o=e.Ua.subarray(0,e.Wa),e.Ua=new Uint8Array(a),e.Ua.set(o)),e.Ua.set(t.subarray(n,n+r),i),e.Wa=Math.max(e.Wa,i+r)}else e.Ua=t.slice(n,n+r),e.Wa=r;return r},bb(e,t,n){if(n===1?t+=e.position:n===2&&(e.node.mode&61440)==32768&&(t+=e.node.Wa),t<0)throw new j(28);return t},xb(e,t,n,r,i){if((e.node.mode&61440)!=32768)throw new j(43);if(e=e.node.Ua,i&2||e.buffer!==b.buffer){i=!0,r=Math.ceil(t/65536)*65536;var a=Mt(65536,r);if(a&&S.fill(0,a,a+r),r=a,!r)throw new j(48);e&&((n>0||n+t<e.length)&&(e=e.subarray?e.subarray(n,n+t):e.slice(n,n+t)),b.set(e,r))}else i=!1,r=e.byteOffset;return{Bc:r,$b:i}},yb(e,t,n,r){return D.Qa.write(e,t,0,r,n,!1),0}}},ve=[],ye=e=>{var t=de(e,0);return ue.decode(e.buffer?e.subarray(0,t):new Uint8Array(e.slice(0,t)))},be=[];function xe(e,t){be[e]={input:[],output:[],pb:t},Ge(e,Se)}var Se={open(e){var t=be[e.node.sb];if(!t)throw new j(43);e.Za=t,e.seekable=!1},close(e){e.Za.pb.qb(e.Za)},qb(e){e.Za.pb.qb(e.Za)},read(e,t,n,r){if(!e.Za||!e.Za.pb.Wb)throw new j(60);for(var i=0,a=0;a<r;a++){try{var o=e.Za.pb.Wb(e.Za)}catch{throw new j(29)}if(o===void 0&&!i)throw new j(6);if(o==null||(i++,t[n+a]=o,o===10))break}return i&&(e.node.gb=Date.now()),i},write(e,t,n,r){if(!e.Za||!e.Za.pb.Mb)throw new j(60);try{for(var i=0;i<r;i++)e.Za.pb.Mb(e.Za,t[n+i])}catch{throw new j(29)}return r&&(e.node.Ya=e.node.Xa=Date.now()),i}},Ce={Wb(){a:{if(!ve.length){var e=null;if(globalThis.window?.prompt&&(e=window.prompt(`Input: `),e!==null&&(e+=`
1
+ import{n as e,t}from"./rolldown-runtime-WkwZ5CU-.js";var n=/* @__PURE__ */ e((/* @__PURE__ */ t(((e,t)=>{var n=void 0,r=function(e){return n||(n=new Promise(function(n,r){var i=e===void 0?{}:e,a=i.onAbort;i.onAbort=function(e){r(Error(e)),a&&a(e)},i.postRun=i.postRun||[],i.postRun.push(function(){n(i)}),t=void 0;var o;o||=i===void 0?{}:i;var s=!!globalThis.window,c=!!globalThis.WorkerGlobalScope;o.onRuntimeInitialized=function(){function e(e,t){Ee(e,t instanceof Error?t.message:String(t),-1)}function t(e,t){switch(typeof t){case`boolean`:Te(e,+!!t);break;case`number`:xe(e,t);break;case`string`:Ce(e,t,T(t),-1);break;case`object`:if(t===null)Se(e);else if(t.length!=null){var n=jt(t.length);b.set(t,n),we(e,n,t.length,-1),X(n)}else Ee(e,`Wrong API use : tried to return a value of an unknown type (`+t+`).`,-1);break;default:Se(e)}}function n(e,t){for(var n=[],r=0;r<e;r+=1){var i=G(t+4*r,`i32`),a=_e(i);if(a===1||a===2)i=be(i);else if(a===3)a=D(i),i=ve(i),i=C(i,a,!0);else if(a===4){a=i,i=D(a),a=ye(a);for(var o=new Uint8Array(i),s=0;s<i;s+=1)o[s]=b[a+s];i=o}else i=null;n.push(i)}return n}function r(e,t){this.Va=e,this.db=t,this.Ta=1,this.Eb=[]}function i(e,t){if(this.db=t,this.tb=K(e),this.tb===null)throw Error(`Unable to allocate memory for the SQL string`);this.zb=this.tb,this.fb=this.Kb=null}function a(e){this.filename=`dbfile_`+(4294967295*Math.random()>>>0),e!=null&&ct(this.filename,e),this.handleError(f(this.filename,u)),this.db=G(u,`i32`),l&&De(this.db),this.Bb={},this.ab=/* @__PURE__ */ new Map}function s(e,t){return e.replace(/[A-Z]/g,function(e){return e.toLowerCase()})+`:`+t}function c(e){e.forEach(Dt)}var l=o.useOldExtensionFunctions!==!1,u=Z(4),d=o.cwrap,f=d(`sqlite3_open`,`number`,[`string`,`number`]),p=d(`sqlite3_close_v2`,`number`,[`number`]),m=d(`sqlite3_backup_init`,`number`,[`number`,`string`,`number`,`string`]),h=d(`sqlite3_backup_step`,`number`,[`number`,`number`]),g=d(`sqlite3_backup_finish`,`number`,[`number`]),_=d(`sqlite3_exec`,`number`,[`number`,`number`,`number`,`number`,`number`]),ee=d(`sqlite3_changes`,`number`,[`number`]),te=d(`sqlite3_sql`,`string`,[`number`]),ne=d(`sqlite3_normalized_sql`,`string`,[`number`]),re=d(`sqlite3_prepare_v2`,`number`,[`number`,`number`,`number`,`number`,`number`]),v=d(`sqlite3_bind_text`,`number`,[`number`,`number`,`number`,`number`,`number`]),y=d(`sqlite3_bind_blob`,`number`,[`number`,`number`,`number`,`number`,`number`]),ie=d(`sqlite3_bind_double`,`number`,[`number`,`number`,`number`]),ae=d(`sqlite3_bind_int`,`number`,[`number`,`number`,`number`]),oe=d(`sqlite3_bind_parameter_index`,`number`,[`number`,`string`]),se=d(`sqlite3_step`,`number`,[`number`]),ce=d(`sqlite3_errmsg`,`string`,[`number`]),le=d(`sqlite3_column_count`,`number`,[`number`]),x=d(`sqlite3_data_count`,`number`,[`number`]),S=d(`sqlite3_column_double`,`number`,[`number`,`number`]),ue=d(`sqlite3_column_text`,`number`,[`number`,`number`]),de=d(`sqlite3_column_blob`,`number`,[`number`,`number`]),fe=d(`sqlite3_column_bytes`,`number`,[`number`,`number`]),pe=d(`sqlite3_column_type`,`number`,[`number`,`number`]),me=d(`sqlite3_column_name`,`string`,[`number`,`number`]),w=d(`sqlite3_reset`,`number`,[`number`]),he=d(`sqlite3_clear_bindings`,`number`,[`number`]),E=d(`sqlite3_finalize`,`number`,[`number`]),ge=d(`sqlite3_create_function_v2`,`number`,`number string number number number number number number number`.split(` `)),_e=d(`sqlite3_value_type`,`number`,[`number`]),D=d(`sqlite3_value_bytes`,`number`,[`number`]),ve=d(`sqlite3_value_text`,`number`,[`number`]),ye=d(`sqlite3_value_blob`,`number`,[`number`]),be=d(`sqlite3_value_double`,`number`,[`number`]),xe=d(`sqlite3_result_double`,``,[`number`,`number`]),Se=d(`sqlite3_result_null`,``,[`number`]),Ce=d(`sqlite3_result_text`,``,[`number`,`string`,`number`,`number`]),we=d(`sqlite3_result_blob`,``,[`number`,`number`,`number`,`number`]),Te=d(`sqlite3_result_int`,``,[`number`,`number`]),Ee=d(`sqlite3_result_error`,``,[`number`,`string`,`number`]),O=d(`sqlite3_aggregate_context`,`number`,[`number`,`number`]),De=d(`RegisterExtensionFunctions`,`number`,[`number`]),k=d(`sqlite3_update_hook`,`number`,[`number`,`number`,`number`]);r.prototype.bind=function(e){if(!this.Va)throw`Statement closed`;return this.reset(),Array.isArray(e)?this.bc(e):typeof e==`object`&&e?this.cc(e):!0},r.prototype.step=function(){if(!this.Va)throw`Statement closed`;this.Ta=1;var e=se(this.Va);switch(e){case 100:return!0;case 101:return!1;default:throw this.db.handleError(e)}},r.prototype.Ub=function(e){return e??(e=this.Ta,this.Ta+=1),S(this.Va,e)},r.prototype.oc=function(e){if(e??(e=this.Ta,this.Ta+=1),typeof BigInt!=`function`)throw Error(`BigInt is not supported`);return BigInt(this.Vb(e))},r.prototype.Vb=function(e){e??(e=this.Ta,this.Ta+=1);var t=ue(this.Va,e);return e=fe(this.Va,e),C(t,e,!0)},r.prototype.getBlob=function(e){e??(e=this.Ta,this.Ta+=1);var t=fe(this.Va,e);e=de(this.Va,e);for(var n=new Uint8Array(t),r=0;r<t;r+=1)n[r]=b[e+r];return n},r.prototype.get=function(e,t){t||={},e!=null&&this.bind(e)&&this.step(),e=[];for(var n=x(this.Va),r=0;r<n;r+=1)switch(pe(this.Va,r)){case 1:var i=t.useBigInt?this.oc(r):this.Ub(r);e.push(i);break;case 2:e.push(this.Ub(r));break;case 3:e.push(this.Vb(r));break;case 4:e.push(this.getBlob(r));break;default:e.push(null)}return e},r.prototype.Ib=function(){for(var e=[],t=le(this.Va),n=0;n<t;n+=1)e.push(me(this.Va,n));return e},r.prototype.Tb=function(e,t){var n=this.get(e,t);return e=this.Ib(),Object.fromEntries(e.map(function(e,t){return[e,n[t]]}))},r.prototype.tc=function(){return te(this.Va)},r.prototype.qc=function(){return ne(this.Va)},r.prototype.run=function(e){return e!=null&&this.bind(e),this.step(),this.reset()},r.prototype.Pb=function(e,t){t??(t=this.Ta,this.Ta+=1);var n=K(e);this.Eb.push(n),this.db.handleError(v(this.Va,t,n,T(e),0))},r.prototype.ac=function(e,t){t??(t=this.Ta,this.Ta+=1);var n=jt(e.length);b.set(e,n),this.Eb.push(n),this.db.handleError(y(this.Va,t,n,e.length,0))},r.prototype.Ob=function(e,t){t??(t=this.Ta,this.Ta+=1),this.db.handleError((e===(e|0)?ae:ie)(this.Va,t,e))},r.prototype.dc=function(e){e??(e=this.Ta,this.Ta+=1),y(this.Va,e,0,0,0)},r.prototype.Qb=function(e,t){switch(t??(t=this.Ta,this.Ta+=1),typeof e){case`string`:this.Pb(e,t);return;case`number`:this.Ob(e,t);return;case`bigint`:this.Pb(e.toString(),t);return;case`boolean`:this.Ob(e+0,t);return;case`object`:if(e===null){this.dc(t);return}if(e.length!=null){this.ac(e,t);return}}throw`Wrong API use : tried to bind a value of an unknown type (`+e+`).`},r.prototype.cc=function(e){var t=this;return Object.keys(e).forEach(function(n){var r=oe(t.Va,n);r!==0&&t.Qb(e[n],r)}),!0},r.prototype.bc=function(e){for(var t=0;t<e.length;t+=1)this.Qb(e[t],t+1);return!0},r.prototype.reset=function(){return this.Hb(),he(this.Va)===0&&w(this.Va)===0},r.prototype.Hb=function(){for(var e;(e=this.Eb.pop())!==void 0;)X(e)},r.prototype.jb=function(){this.Hb();var e=E(this.Va)===0;return delete this.db.Bb[this.Va],this.Va=0,e},i.prototype.next=function(){if(this.tb===null)return{done:!0};if(this.fb!==null&&(this.fb.jb(),this.fb=null),!this.db.db)throw this.ub(),Error(`Database closed`);var e=Q(),t=Z(4);wt(u),wt(t);try{this.db.handleError(re(this.db.db,this.zb,-1,u,t)),this.zb=G(t,`i32`);var n=G(u,`i32`);return n===0?(this.ub(),{done:!0}):(this.fb=new r(n,this.db),this.db.Bb[n]=this.fb,{value:this.fb,done:!1})}catch(e){throw this.Kb=C(this.zb),this.ub(),e}finally{Pt(e)}},i.prototype.ub=function(){X(this.tb),this.tb=null},i.prototype.return=function(){return this.fb!==null&&(this.fb.jb(),this.fb=null),this.ub(),{done:!0}},i.prototype.rc=function(){return this.Kb===null?C(this.zb):this.Kb},typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`&&(i.prototype[Symbol.iterator]=function(){return this}),a.prototype.run=function(e,t){if(!this.db)throw`Database closed`;if(t){e=this.Lb(e,t);try{e.step()}finally{e.jb()}}else{e=K(e);try{this.handleError(_(this.db,e,0,0,u))}finally{X(e)}}return this},a.prototype.exec=function(e,t,n){if(!this.db)throw`Database closed`;var i=Q(),a=null,o=null,s=null;try{s=o=K(e);var c=Z(4);for(e=[];G(s,`i8`)!==0;){wt(u),wt(c),this.handleError(re(this.db,s,-1,u,c));var l=G(u,`i32`);if(s=G(c,`i32`),l!==0){var d=null;for(a=new r(l,this),t!=null&&a.bind(t);a.step();)d===null&&(d={columns:a.Ib(),values:[]},e.push(d)),d.values.push(a.get(null,n));a.jb()}}return e}catch(e){throw a&&a.jb(),e}finally{o&&X(o),Pt(i)}},a.prototype.lc=function(e,t,n,r,i){typeof t==`function`&&(r=n,n=t,t=void 0),e=this.Lb(e,t);try{for(;e.step();)n(e.Tb(null,i))}finally{e.jb()}if(typeof r==`function`)return r()},a.prototype.Lb=function(e,t){e=K(e);try{wt(u),this.handleError(re(this.db,e,-1,u,0))}finally{X(e)}if(e=G(u,`i32`),e===0)throw`Nothing to prepare`;var n=new r(e,this);return t!=null&&n.bind(t),this.Bb[e]=n},a.prototype.wc=function(e){return new i(e,this)},a.prototype.nc=function(){if(!this.db)throw Error(`Database closed`);var e=this.filename+`_export`;ct(e,[]);var t=0,n=0;try{var r=M(e).node,i=null,a=r.Qa.write;r.Qa=Object.create(r.Qa),r.Qa.write=function(e,t,n,o,s){return i===null?a(e,t,n,o,s):(r.Ua.set(t.subarray(n,n+o),s),r.Wa=Math.max(r.Wa,s+o),o)};var o=f(e,u);if(t=G(u,`i32`),o!==0||(n=m(t,`main`,this.db,`main`),n===0))throw Error(ce(t));if(o=h(n,0),o===0){var s=this.exec(`PRAGMA main.page_count; PRAGMA main.page_size`);i=new Uint8Array(s[0].values[0][0]*s[1].values[0][0]),r.Ua=i,o=h(n,-1)}if(o===5||o===6)throw Error(`Unable to export: SQLite is busy or locked. Finish active write transactions before exporting.`);if(o!==101||(o=g(n),n=0,o!==0)||(o=p(t),o!==0))throw Error(ce(t));return t=0,i=new Uint8Array(r.Ua.buffer,r.Ua.byteOffset,r.Wa),i.length>0&&(i[18]=1,i[19]=1),i}finally{n!==0&&g(n),t!==0&&p(t),Qe(`/`+e)}},a.prototype.close=function(){this.db!==null&&(Object.values(this.Bb).forEach(function(e){e.jb()}),this.ab.forEach(c),this.ab.clear(),this.lb&&=(Dt(this.lb),void 0),this.handleError(p(this.db)),Qe(`/`+this.filename),this.db=null)},a.prototype.handleError=function(e){if(e===0)return null;throw e=ce(this.db),Error(e)},a.prototype.sc=function(){return ee(this.db)},a.prototype.jc=function(r,i){var a=s(r,i.length);this.ab.has(a)&&(c(this.ab.get(a)),this.ab.delete(a));var o=J(function(r,a,o){a=n(a,o);try{var s=i.apply(null,a)}catch(t){e(r,t);return}t(r,s)},`viii`);return this.ab.set(a,[o]),this.handleError(ge(this.db,r,i.length,1,0,o,0,0,0)),this},a.prototype.hc=function(r,i){function a(e){return d.has(e)||d.set(e,o()),d.get(e)}var o=i.init||function(){return null},l=i.finalize||function(e){return e},u=i.step;if(!u)throw`An aggregate function must have a step function in `+r;var d=/* @__PURE__ */ new Map;i=s(r,u.length-1),this.ab.has(i)&&(c(this.ab.get(i)),this.ab.delete(i));var f=J(function(t,r,i){var o=O(t,1),s=a(o);r=n(r,i),s=[s].concat(r);try{d.set(o,u.apply(null,s))}catch(n){d.delete(o),e(t,n)}},`viii`),p=J(function(n){var r=O(n,1);try{var i=l(a(r))}catch(t){d.delete(r),e(n,t);return}t(n,i),d.delete(r)},`vi`);return this.ab.set(i,[f,p]),this.handleError(ge(this.db,r,u.length-1,1,0,0,f,p,0)),this},a.prototype.Dc=function(e){return this.lb&&=(k(this.db,0,0),Dt(this.lb),void 0),e&&(this.lb=J(function(t,n,r,i,a){switch(n){case 18:t=`insert`;break;case 23:t=`update`;break;case 9:t=`delete`;break;default:throw`unknown operationCode in updateHook callback: `+n}if(r=C(r),i=C(i),a>2**53-1)throw`rowId too big to fit inside a Number`;e(t,r,i,Number(a))},`viiiij`),k(this.db,this.lb,0)),this},r.prototype.bind=r.prototype.bind,r.prototype.step=r.prototype.step,r.prototype.get=r.prototype.get,r.prototype.getColumnNames=r.prototype.Ib,r.prototype.getAsObject=r.prototype.Tb,r.prototype.getSQL=r.prototype.tc,r.prototype.getNormalizedSQL=r.prototype.qc,r.prototype.run=r.prototype.run,r.prototype.reset=r.prototype.reset,r.prototype.freemem=r.prototype.Hb,r.prototype.free=r.prototype.jb,i.prototype.next=i.prototype.next,i.prototype.getRemainingSQL=i.prototype.rc,a.prototype.run=a.prototype.run,a.prototype.exec=a.prototype.exec,a.prototype.each=a.prototype.lc,a.prototype.prepare=a.prototype.Lb,a.prototype.iterateStatements=a.prototype.wc,a.prototype.export=a.prototype.nc,a.prototype.close=a.prototype.close,a.prototype.handleError=a.prototype.handleError,a.prototype.getRowsModified=a.prototype.sc,a.prototype.create_function=a.prototype.jc,a.prototype.create_aggregate=a.prototype.hc,a.prototype.updateHook=a.prototype.Dc,o.Database=a};var l=`./this.program`,u=globalThis.document?.currentScript?.src;c&&(u=self.location.href);var d=``,f,p;if(s||c){try{d=new URL(`.`,u).href}catch{}c&&(p=e=>{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.responseType=`arraybuffer`,t.send(null),new Uint8Array(t.response)}),f=async e=>{if(e=await fetch(e,{credentials:`same-origin`}),e.ok)return e.arrayBuffer();throw Error(e.status+` : `+e.url)}}var m=console.log.bind(console),h=console.error.bind(console),g,_=!1,ee;function te(){if(!b?.buffer?.resizable){var e=Ft.buffer;b=new Int8Array(e),dt=new Int16Array(e),S=new Uint8Array(e),V=new Int32Array(e),U=new Uint32Array(e),St=new Float32Array(e),Ct=new Float64Array(e),H=new BigInt64Array(e)}}function ne(){var e=o.preRun;for(e&&(typeof e==`function`&&(e=[e]),le.push(...e)),e=le;e.length>0;)e.shift()(o)}function re(){var e=o.postRun;for(e&&(typeof e==`function`&&(e=[e]),ce.push(...e)),e=ce;e.length>0;)e.shift()(o)}function v(e){throw o.onAbort?.(e),e=`Aborted(${e})`,h(e),_=!0,new WebAssembly.RuntimeError(e+`. Build with -sASSERTIONS for more info.`)}var y;async function ie(e){if(!g)try{return await f(e)}catch{}if(e==y&&g)e=new Uint8Array(g);else if(p)e=p(e);else throw`both async and sync fetching of the wasm failed`;return e}async function ae(e,t){try{var n=await ie(e);return await WebAssembly.instantiate(n,t)}catch(e){h(`failed to asynchronously prepare wasm: ${e}`),v(e)}}async function oe(e){var t=y;if(!g)try{var n=fetch(t,{credentials:`same-origin`});return await WebAssembly.instantiateStreaming(n,e)}catch(e){h(`wasm streaming compile failed: ${e}`),h(`falling back to ArrayBuffer instantiation`)}return ae(t,e)}class se{name=`ExitStatus`;constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var b,ce=[],le=[],x=!0,S,ue=new TextDecoder,de=(e,t,n,r)=>{if(n=t+n,r)return n;for(;e[t]&&!(t>=n);)++t;return t},C=(e,t,n)=>e?ue.decode(S.subarray(e,de(S,e,t,n))):``,fe=(e,t)=>{for(var n=0,r=e.length-1;r>=0;r--){var i=e[r];i===`.`?e.splice(r,1):i===`..`?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n;n--)e.unshift(`..`);return e},pe=e=>{var t=e.charAt(0)===`/`,n=e.slice(-1)===`/`;return(e=fe(e.split(`/`).filter(e=>!!e),!t).join(`/`))||t||(e=`.`),e&&n&&(e+=`/`),(t?`/`:``)+e},me=e=>{var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],!e&&!t?`.`:(t&&=t.slice(0,-1),e+t)},w=e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],he=(...e)=>{for(var t=``,n=!1,r=e.length-1;r>=-1&&!n;r--){if(n=r>=0?e[r]:`/`,typeof n!=`string`)throw TypeError(`Arguments to path.resolve must be strings`);if(!n)return``;t=n+`/`+t,n=n.charAt(0)===`/`}return t=fe(t.split(`/`).filter(e=>!!e),!n).join(`/`),(n?`/`:``)+t||`.`},T=e=>{for(var t=0,n=0;n<e.length;++n){var r=e.codePointAt(n);r<=127?t++:r<=2047?t+=2:r<=65535?t+=3:(t+=4,n++)}return t},E=(e,t,n,r)=>{if(!(r>0))return 0;var i=n;r=n+r-1;for(var a=0;a<e.length;++a){var o=e.codePointAt(a);if(o<=127){if(n>=r)break;t[n++]=o}else if(o<=2047){if(n+1>=r)break;t[n++]=192|o>>6,t[n++]=128|o&63}else if(o<=65535){if(n+2>=r)break;t[n++]=224|o>>12,t[n++]=128|o>>6&63,t[n++]=128|o&63}else{if(n+3>=r)break;t[n++]=240|o>>18,t[n++]=128|o>>12&63,t[n++]=128|o>>6&63,t[n++]=128|o&63,a++}}return t[n]=0,n-i},ge=e=>{var t=Array(T(e)+1);return e=E(e,t,0,t.length),t.length=e,t},_e=(e,t)=>{var n=0;return e&&(n|=365),t&&(n|=146),n},D={cb:null,hb(){return D.createNode(null,`/`,16895,0)},createNode(e,t,n,r){if((n&61440)==24576||(n&61440)==4096)throw new j(63);return D.cb||={dir:{node:{$a:D.Ra.$a,eb:D.Ra.eb,rb:D.Ra.rb,wb:D.Ra.wb,Zb:D.Ra.Zb,Db:D.Ra.Db,Ab:D.Ra.Ab,Nb:D.Ra.Nb,Cb:D.Ra.Cb},stream:{bb:D.Qa.bb}},file:{node:{$a:D.Ra.$a,eb:D.Ra.eb},stream:{bb:D.Qa.bb,read:D.Qa.read,write:D.Qa.write,xb:D.Qa.xb,yb:D.Qa.yb}},link:{node:{$a:D.Ra.$a,eb:D.Ra.eb,kb:D.Ra.kb},stream:{}},Rb:{node:{$a:D.Ra.$a,eb:D.Ra.eb},stream:We}},n=Le(e,t,n,r),P(n.mode)?(n.Ra=D.cb.dir.node,n.Qa=D.cb.dir.stream,n.Ua={}):(n.mode&61440)==32768?(n.Ra=D.cb.file.node,n.Qa=D.cb.file.stream,n.Wa=0,n.Ua=D.mc??=/* @__PURE__ */ new Uint8Array):(n.mode&61440)==40960?(n.Ra=D.cb.link.node,n.Qa=D.cb.link.stream):(n.mode&61440)==8192&&(n.Ra=D.cb.Rb.node,n.Qa=D.cb.Rb.stream),n.gb=n.Ya=n.Xa=Date.now(),e&&(e.Ua[t]=n,e.gb=e.Ya=e.Xa=n.gb),n},Ra:{$a(e){var t={};return t.kc=(e.mode&61440)==8192?e.id:1,t.vc=e.id,t.mode=e.mode,t.yc=1,t.uid=0,t.uc=0,t.sb=e.sb,t.size=P(e.mode)?4096:(e.mode&61440)==32768?e.Wa:(e.mode&61440)==40960?e.link.length:0,t.gb=new Date(e.gb),t.Ya=new Date(e.Ya),t.Xa=new Date(e.Xa),t.ec=4096,t.fc=Math.ceil(t.size/t.ec),t},eb(e,t){for(var n of[`mode`,`atime`,`mtime`,`ctime`])t[n]!=null&&(e[n]=t[n]);t.size!==void 0&&(t=t.size,e.Wa!=t&&(n=e.Ua,e.Ua=new Uint8Array(t),e.Ua.set(n.subarray(0,Math.min(t,e.Wa))),e.Wa=t))},rb(){throw D.Fb||(D.Fb=new j(44),D.Fb.stack=`<generic error, no stack>`),D.Fb},wb(e,t,n,r){return D.createNode(e,t,n,r)},Zb(e,t,n){try{var r=N(t,n)}catch{}if(r&&P(e.mode))for(var i in r.Ua)throw new j(55);delete e.parent.Ua[e.name],t.Ua[n]=e,e.name=n,t.Xa=t.Ya=e.parent.Xa=e.parent.Ya=Date.now()},Db(e,t){delete e.Ua[t],e.Xa=e.Ya=Date.now()},Ab(e,t){var n=N(e,t),r;for(r in n.Ua)throw new j(55);delete e.Ua[t],e.Xa=e.Ya=Date.now()},Nb(e){return[`.`,`..`,...Object.keys(e.Ua)]},Cb(e,t,n){return e=D.createNode(e,t,41471,0),e.link=n,e},kb(e){if((e.mode&61440)!=40960)throw new j(28);return e.link}},Qa:{read(e,t,n,r,i){return i>=e.node.Wa?0:(r=Math.min(e.node.Wa-i,r),t.set(e.node.Ua.subarray(i,i+r),n),r)},write(e,t,n,r,i,a){if(t.buffer===b.buffer&&(a=!1),!r)return 0;if(e=e.node,e.Ya=e.Xa=Date.now(),a)e.Ua=t.subarray(n,n+r),e.Wa=r;else if(e.Wa||i){a=i+r;var o=e.Ua.length;o>=a||(a=Math.max(a,o*(o<1048576?2:1.125)>>>0),o&&(a=Math.max(a,256)),o=e.Ua.subarray(0,e.Wa),e.Ua=new Uint8Array(a),e.Ua.set(o)),e.Ua.set(t.subarray(n,n+r),i),e.Wa=Math.max(e.Wa,i+r)}else e.Ua=t.slice(n,n+r),e.Wa=r;return r},bb(e,t,n){if(n===1?t+=e.position:n===2&&(e.node.mode&61440)==32768&&(t+=e.node.Wa),t<0)throw new j(28);return t},xb(e,t,n,r,i){if((e.node.mode&61440)!=32768)throw new j(43);if(e=e.node.Ua,i&2||e.buffer!==b.buffer){i=!0,r=Math.ceil(t/65536)*65536;var a=Mt(65536,r);if(a&&S.fill(0,a,a+r),r=a,!r)throw new j(48);e&&((n>0||n+t<e.length)&&(e=e.subarray?e.subarray(n,n+t):e.slice(n,n+t)),b.set(e,r))}else i=!1,r=e.byteOffset;return{Bc:r,$b:i}},yb(e,t,n,r){return D.Qa.write(e,t,0,r,n,!1),0}}},ve=[],ye=e=>{var t=de(e,0);return ue.decode(e.buffer?e.subarray(0,t):new Uint8Array(e.slice(0,t)))},be=[];function xe(e,t){be[e]={input:[],output:[],pb:t},Ge(e,Se)}var Se={open(e){var t=be[e.node.sb];if(!t)throw new j(43);e.Za=t,e.seekable=!1},close(e){e.Za.pb.qb(e.Za)},qb(e){e.Za.pb.qb(e.Za)},read(e,t,n,r){if(!e.Za||!e.Za.pb.Wb)throw new j(60);for(var i=0,a=0;a<r;a++){try{var o=e.Za.pb.Wb(e.Za)}catch{throw new j(29)}if(o===void 0&&!i)throw new j(6);if(o==null||(i++,t[n+a]=o,o===10))break}return i&&(e.node.gb=Date.now()),i},write(e,t,n,r){if(!e.Za||!e.Za.pb.Mb)throw new j(60);try{for(var i=0;i<r;i++)e.Za.pb.Mb(e.Za,t[n+i])}catch{throw new j(29)}return r&&(e.node.Ya=e.node.Xa=Date.now()),i}},Ce={Wb(){a:{if(!ve.length){var e=null;if(globalThis.window?.prompt&&(e=window.prompt(`Input: `),e!==null&&(e+=`
2
2
  `)),!e){e=null;break a}ve=ge(e)}e=ve.shift()}return e},Mb(e,t){t===null||t===10?(m(ye(e.output)),e.output=[]):t!=0&&e.output.push(t)},qb(e){e.output?.length>0&&(m(ye(e.output)),e.output=[])},Kc(){return{Gc:25856,Ic:5,Fc:191,Hc:35387,Ec:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},Lc(){return 0},Mc(){return[24,80]}},we={Mb(e,t){t===null||t===10?(h(ye(e.output)),e.output=[]):t!=0&&e.output.push(t)},qb(e){e.output?.length>0&&(h(ye(e.output)),e.output=[])}},Te=()=>e=>(crypto.getRandomValues(e),0),Ee=e=>(Ee=Te())(e),O=null,De={},k=[],Oe=1,A=[],ke=!1,Ae=!0,je={},j=class{name=`ErrnoError`;constructor(e){this.Sa=e}},Me=class{shared={};node=null;get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},Ne=class{Ra={};Qa={};nb=null;constructor(e,t,n,r){e||=this,this.parent=e,this.hb=e.hb,this.id=Oe++,this.name=t,this.mode=n,this.sb=r,this.gb=this.Ya=this.Xa=Date.now()}get read(){return(this.mode&365)==365}set read(e){e?this.mode|=365:this.mode&=-366}get write(){return(this.mode&146)==146}set write(e){e?this.mode|=146:this.mode&=-147}Ac(){}};function M(e,t={}){if(!e)throw new j(44);t.Gb??=!0,e.charAt(0)===`/`||(e=`//`+e);var n=0;a:for(;n<40;n++){e=e.split(`/`).filter(e=>!!e);for(var r=O,i=`/`,a=0;a<e.length;a++){var o=a===e.length-1;if(o&&t.parent)break;if(e[a]!==`.`){if(e[a]===`..`){if(i=me(i),r===r.parent){e=i+`/`+e.slice(a+1).join(`/`),n--;continue a}r=r.parent}else{i=pe(i+`/`+e[a]);try{r=N(r,e[a])}catch(e){if(e?.Sa===44&&o&&t.zc)return{path:i};throw e}if(!r.nb||o&&!t.Gb||(r=r.nb.root),(r.mode&61440)==40960&&(!o||t.mb)){if(!r.Ra.kb)throw new j(52);r=r.Ra.kb(r),r.charAt(0)===`/`||(r=me(i)+`/`+r),e=r+`/`+e.slice(a+1).join(`/`);continue a}}}}return{path:i,node:r}}throw new j(32)}function Pe(e){for(var t;;){if(e===e.parent)return e=e.hb.Yb,t?e[e.length-1]===`/`?e+t:`${e}/${t}`:e;t=t?`${e.name}/${t}`:e.name,e=e.parent}}function Fe(e,t){for(var n=0,r=0;r<t.length;r++)n=(n<<5)-n+t.charCodeAt(r)|0;return(e+n>>>0)%A.length}function Ie(e){var t=Fe(e.parent.id,e.name);if(A[t]===e)A[t]=e.ob;else for(t=A[t];t;){if(t.ob===e){t.ob=e.ob;break}t=t.ob}}function N(e,t){var n=P(e.mode)?(n=F(e,`x`))?n:e.Ra.rb?0:2:54;if(n)throw new j(n);for(n=A[Fe(e.id,t)];n;n=n.ob){var r=n.name;if(n.parent.id===e.id&&r===t)return n}return e.Ra.rb(e,t)}function Le(e,t,n,r){return e=new Ne(e,t,n,r),t=Fe(e.parent.id,e.name),e.ob=A[t],A[t]=e}function P(e){return(e&61440)==16384}function F(e,t){return Ae?0:t.includes(`r`)&&!(e.mode&292)||t.includes(`w`)&&!(e.mode&146)||t.includes(`x`)&&!(e.mode&73)?2:0}function Re(e,t){if(!P(e.mode))return 54;try{return N(e,t),20}catch{}return F(e,`wx`)}function ze(e,t,n){try{var r=N(e,t)}catch(e){return e.Sa}if(e=F(e,`wx`))return e;if(n){if(!P(r.mode))return 54;if(r===r.parent||Pe(r)===`/`)return 10}else if(P(r.mode))return 31;return 0}function Be(e){if(!e)throw new j(63);return e}function I(e){if(e=k[e],!e)throw new j(8);return e}function Ve(e,t=-1){if(e=Object.assign(new Me,e),t==-1)a:{for(t=0;t<=4096;t++)if(!k[t])break a;throw new j(33)}return e.ib=t,k[t]=e}function He(e,t=-1){return e=Ve(e,t),e.Qa?.Jc?.(e),e}function Ue(e,t,n){var r=e?.Qa.eb;e=r?e:t,r??=t.Ra.eb,Be(r);try{r(e,n)}catch(e){throw e instanceof RangeError?new j(22):e}}var We={open(e){e.Qa=De[e.node.sb].Qa,e.Qa.open?.(e)},bb(){throw new j(70)}};function Ge(e,t){De[e]={Qa:t}}function Ke(e,t){var n=t===`/`;if(n&&O)throw new j(10);if(!n&&t){var r=M(t,{Gb:!1});if(t=r.path,r=r.node,r.nb)throw new j(10);if(!P(r.mode))throw new j(54)}t={type:e,Nc:{},Yb:t,xc:[]},e=e.hb(t),e.hb=t,t.root=e,n?O=e:r&&(r.nb=t,r.hb&&r.hb.xc.push(t))}function qe(e,t,n){var r=M(e,{parent:!0}).node;if(e=w(e),!e)throw new j(28);if(e===`.`||e===`..`)throw new j(20);var i=Re(r,e);if(i)throw new j(i);if(!r.Ra.wb)throw new j(63);return r.Ra.wb(r,e,t,n)}function Je(e,t=438){return qe(e,t&4095|32768,0)}function L(e,t=511){return qe(e,t&1023|16384,0)}function Ye(e,t,n){n===void 0&&(n=t,t=438),qe(e,t|8192,n)}function Xe(e,t){if(!he(e))throw new j(44);var n=M(t,{parent:!0}).node;if(!n)throw new j(44);t=w(t);var r=Re(n,t);if(r)throw new j(r);if(!n.Ra.Cb)throw new j(63);n.Ra.Cb(n,t,e)}function Ze(e){var t=M(e,{parent:!0}).node;e=w(e);var n=N(t,e),r=ze(t,e,!0);if(r)throw new j(r);if(!t.Ra.Ab)throw new j(63);if(n.nb)throw new j(10);t.Ra.Ab(t,e),Ie(n)}function Qe(e){var t=M(e,{parent:!0}).node;if(!t)throw new j(44);e=w(e);var n=N(t,e),r=ze(t,e,!1);if(r)throw new j(r);if(!t.Ra.Db)throw new j(63);if(n.nb)throw new j(10);t.Ra.Db(t,e),Ie(n)}function $e(e,t=!1){return e=M(e,{mb:!t}).node,Be(e.Ra.$a)(e)}function et(e,t,n){Ue(e,t,{mode:n&4095|t.mode&-4096,Xa:Date.now(),Sb:!1})}function tt(e,t){e=typeof e==`string`?M(e,{mb:!0}).node:e,et(null,e,t)}function nt(e,t,n){if(P(t.mode))throw new j(31);if((t.mode&61440)!=32768)throw new j(28);var r=F(t,`w`);if(r)throw new j(r);Ue(e,t,{size:n,timestamp:Date.now()})}function rt(e,t,n,r=!1){e=M(e,{mb:!r}),Ue(null,e.node,{gb:t,Ya:n,Sb:r})}function R(e,t,n=438){if(e===``)throw new j(44);if(typeof t==`string`){var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[t];if(r===void 0)throw Error(`Unknown file open mode: ${t}`);t=r}if(n=t&64?n&4095|32768:0,typeof e==`object`)r=e;else{var i=e.endsWith(`/`);e=M(e,{mb:!(t&131072),zc:!0}),r=e.node,e=e.path}var a=!1;if(t&64){if(r){if(t&128)throw new j(20)}else{if(i)throw new j(31);r=qe(e,n|511,0),a=!0}}if(!r)throw new j(44);if((r.mode&61440)==8192&&(t&=-513),t&65536&&!P(r.mode))throw new j(54);if(!a&&(r?(r.mode&61440)==40960?i=32:(i=[`r`,`w`,`rw`][t&3],t&512&&(i+=`w`),i=P(r.mode)&&(i!==`r`||t&576)?31:F(r,i)):i=44,i))throw new j(i);return t&512&&!a&&(i=r,i=typeof i==`string`?M(i,{mb:!0}).node:i,nt(null,i,0)),t&=-131713,i=Ve({node:r,path:Pe(r),flags:t,seekable:!0,position:0,Qa:r.Qa,Cc:[],error:!1}),i.Qa.open&&i.Qa.open(i),a&&tt(r,n&511),!o.logReadFiles||t&1||e in je||(je[e]=1,h(`read file: ${e}`)),i}function it(e){if(e.ib===null)throw new j(8);e.Jb&&=null,e.node?.Ac();try{e.Qa.close&&e.Qa.close(e)}catch(e){throw e}finally{k[e.ib]=null}e.ib=null}function at(e,t,n){if(e.ib===null)throw new j(8);if(!e.seekable||!e.Qa.bb)throw new j(70);if(n!=0&&n!=1&&n!=2)throw new j(28);e.position=e.Qa.bb(e,t,n),e.Cc=[]}function ot(e,t,n,r,i){if(r<0||i<0)throw new j(28);if(e.ib===null||!(e.flags&2097155))throw new j(8);if(P(e.node.mode))throw new j(31);if(!e.Qa.write)throw new j(28);e.seekable&&e.flags&1024&&at(e,0,2);var a=i!==void 0;if(!a)i=e.position;else if(!e.seekable)throw new j(70);return t=e.Qa.write(e,t,n,r,i,void 0),a||(e.position+=t),t}function st(){var e,t,n;ke=!0,e??=o.stdin,t??=o.stdout,n??=o.stderr,e?z(`stdin`,e):Xe(`/dev/tty`,`/dev/stdin`),t?z(`stdout`,null,t):Xe(`/dev/tty`,`/dev/stdout`),n?z(`stderr`,null,n):Xe(`/dev/tty1`,`/dev/stderr`),R(`/dev/stdin`,0),R(`/dev/stdout`,1),R(`/dev/stderr`,1)}function ct(e,t){var n=`/`,r=e;n&&(n=typeof n==`string`?n:Pe(n),r=e?pe(n+`/`+e):n),e=_e(!0,!0),r=Je(r,e),t&&(typeof t==`string`&&(t=ge(t)),t.subarray||(t=new Uint8Array(t)),tt(r,e|146),n=R(r,577),ot(n,t,0,t.length,0),it(n),tt(r,e))}function z(e,t,n){e=pe(`/dev/`+e);var r=_e(!!t,!!n);z.Xb??=64;var i=z.Xb++<<8;Ge(i,{open(e){e.seekable=!1},close(){n?.buffer?.length&&n(10)},read(e,n,r,i){for(var a=0,o=0;o<i;o++){try{var s=t()}catch{throw new j(29)}if(s===void 0&&!a)throw new j(6);if(s==null)break;a++,n[r+o]=s}return a&&(e.node.gb=Date.now()),a},write(e,t,r,i){for(var a=0;a<i;a++)try{n(t[r+a])}catch{throw new j(29)}return i&&(e.node.Ya=e.node.Xa=Date.now()),a}}),Ye(e,r,i)}var B={},V,H,U;function W(e,t,n=!1){if(t.charAt(0)===`/`)return t;if(e=e===-100?`/`:I(e).path,t.length==0){if(!n)throw new j(44);return e}return e+`/`+t}function lt(e,t){U[e>>2]=t.kc,U[e+4>>2]=t.mode,U[e+8>>2]=t.yc,U[e+12>>2]=t.uid,U[e+16>>2]=t.uc,U[e+20>>2]=t.sb,H[e+24>>3]=BigInt(t.size),V[e+32>>2]=4096,V[e+36>>2]=t.fc;var n=t.gb.getTime(),r=t.Ya.getTime(),i=t.Xa.getTime();return H[e+40>>3]=BigInt(Math.floor(n/1e3)),U[e+48>>2]=n%1e3*1e3*1e3,H[e+56>>3]=BigInt(Math.floor(r/1e3)),U[e+64>>2]=r%1e3*1e3*1e3,H[e+72>>3]=BigInt(Math.floor(i/1e3)),U[e+80>>2]=i%1e3*1e3*1e3,H[e+88>>3]=BigInt(t.vc),0}var ut=void 0,dt,ft=()=>{var e=V[ut>>2];return ut+=4,e},pt=0,mt=[0,31,60,91,121,152,182,213,244,274,305,335],ht=[0,31,59,90,120,151,181,212,243,273,304,334],gt=e=>{if(!(e instanceof se||e==`unwind`))throw e},_t=e=>{throw ee=e,x||pt>0||(o.onExit?.(e),_=!0),new se(e)},vt={},yt={},bt=()=>{if(!xt){var e={USER:`web_user`,LOGNAME:`web_user`,PATH:`/`,PWD:`/`,HOME:`/home/web_user`,LANG:(globalThis.navigator?.language??`C`).replace(`-`,`_`)+`.UTF-8`,_:l},t;for(t in yt)yt[t]===void 0?delete e[t]:e[t]=yt[t];var n=[];for(t in e)n.push(`${t}=${e[t]}`);xt=n}return xt},xt,St,Ct;function wt(e){var t=`i32`;switch(t.endsWith(`*`)&&(t=`*`),t){case`i1`:b[e]=0;break;case`i8`:b[e]=0;break;case`i16`:dt[e>>1]=0;break;case`i32`:V[e>>2]=0;break;case`i64`:H[e>>3]=BigInt(0);break;case`float`:St[e>>2]=0;break;case`double`:Ct[e>>3]=0;break;case`*`:U[e>>2]=0;break;default:v(`invalid type for setValue: ${t}`)}}function G(e,t=`i8`){switch(t.endsWith(`*`)&&(t=`*`),t){case`i1`:return b[e];case`i8`:return b[e];case`i16`:return dt[e>>1];case`i32`:return V[e>>2];case`i64`:return H[e>>3];case`float`:return St[e>>2];case`double`:return Ct[e>>3];case`*`:return U[e>>2];default:v(`invalid type for getValue: ${t}`)}}var Tt=(e,t,n,r)=>{var i={string:e=>{var t=0;if(e!=null&&e!==0){t=T(e)+1;var n=Z(t);E(e,S,n,t),t=n}return t},array:e=>{var t=Z(e.length);return b.set(e,t),t}};e=o[`_`+e];var a=[],s=0;if(r)for(var c=0;c<r.length;c++){var l=i[n[c]];l?(s||=Q(),a[c]=l(r[c])):a[c]=r[c]}return n=e(...a),n=function(e){return s&&Pt(s),t===`string`?C(e):t===`boolean`?!!e:e}(n)},K=e=>{var t=T(e)+1,n=jt(t);return n&&E(e,S,n,t),n},Et=[],q,Dt=e=>{q.delete($.get(e)),$.set(e,null),Et.push(e)},Ot=e=>{var t=e.length;return[t%128|128,t>>7,...e]},kt={i:127,p:127,j:126,f:125,d:124,e:111},At=e=>Ot(Array.from(e,e=>kt[e])),J=(e,t)=>{if(!q){q=/* @__PURE__ */ new WeakMap;var n=$.length;if(q)for(var r=0;r<0+n;r++){var i=$.get(r);i&&q.set(i,r)}}if(n=q.get(e)||0)return n;n=Et.length?Et.pop():$.grow(1);try{$.set(n,e)}catch(r){if(!(r instanceof TypeError))throw r;t=Uint8Array.of(0,97,115,109,1,0,0,0,1,...Ot([1,96,...At(t.slice(1)),...At(t[0]===`v`?``:t[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),t=new WebAssembly.Module(t),t=new WebAssembly.Instance(t,{e:{f:e}}).exports.f,$.set(n,t)}return q.set(e,n),n};A.length=4096,Ke(D,`/`),L(`/tmp`),L(`/home`),L(`/home/web_user`),(function(){L(`/dev`),Ge(259,{read:()=>0,write:(e,t,n,r)=>r,bb:()=>0}),Ye(`/dev/null`,259),xe(1280,Ce),xe(1536,we),Ye(`/dev/tty`,1280),Ye(`/dev/tty1`,1536);var e=/* @__PURE__ */ new Uint8Array(1024),t=0,n=()=>(t||=(Ee(e),e.byteLength),e[--t]);z(`random`,n),z(`urandom`,n),L(`/dev/shm`),L(`/dev/shm/tmp`)})(),(function(){L(`/proc`);var e=L(`/proc/self`);L(`/proc/self/fd`),Ke({hb(){var t=Le(e,`fd`,16895,73);return t.Qa={bb:D.Qa.bb},t.Ra={rb(e,t){e=+t;var n=I(e);return e={parent:null,hb:{Yb:`fake`},Ra:{kb:()=>n.path},id:e+1},e.parent=e},Nb(){return Array.from(k.entries()).filter(([,e])=>e).map(([e])=>e.toString())}},t}},`/proc/self/fd`)})(),o.noExitRuntime&&(x=o.noExitRuntime),o.print&&(m=o.print),o.printErr&&(h=o.printErr),o.wasmBinary&&(g=o.wasmBinary),o.thisProgram&&(l=o.thisProgram);var Y=o.preInit;if(Y)for(typeof Y==`function`&&(o.preInit=Y=[Y]);Y.length>0;)Y.shift()();o.stackSave=()=>Q(),o.stackRestore=e=>Pt(e),o.stackAlloc=e=>Z(e),o.cwrap=(e,t,n,r)=>{var i=!n||n.every(e=>e===`number`||e===`boolean`);return t!==`string`&&i&&!r?o[`_`+e]:(...r)=>Tt(e,t,n,r)},o.addFunction=J,o.removeFunction=Dt,o.UTF8ToString=C,o.lengthBytesUTF8=T,o.stringToNewUTF8=K,o.writeArrayToMemory=(e,t)=>{b.set(e,t)};var jt,X,Mt,Nt,Pt,Z,Q,Ft,$,It={a:(e,t,n,r)=>v(`Assertion failed: ${C(e)}, at: `+[t?C(t):`unknown filename`,n,r?C(r):`unknown function`]),i:function(e,t){try{return e=C(e),tt(e,t),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},D:function(e,t,n){try{if(t=C(t),t=W(e,t),n&-8)return-28;var r=M(t,{mb:!0}).node;return r?(e=``,n&4&&(e+=`r`),n&2&&(e+=`w`),n&1&&(e+=`x`),e&&F(r,e)?-2:0):-44}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},j:function(e,t){try{var n=I(e);return et(n,n.node,t),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},h:function(e){try{var t=I(e);return Ue(t,t.node,{timestamp:Date.now(),Sb:!1}),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},b:function(e,t,n){ut=n;try{var r=I(e);switch(t){case 0:var i=ft();if(i<0)break;for(;k[i];)i++;return He(r,i).ib;case 1:case 2:return 0;case 3:return r.flags;case 4:return i=ft(),r.flags=r.flags&-289793|i&289792,0;case 12:return i=ft(),dt[i+0>>1]=2,0;case 13:case 14:return 0}return-28}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},g:function(e,t){try{var n=I(e),r=n.node,i=n.Qa.$a;return e=i?n:r,i??=r.Ra.$a,Be(i),lt(t,i(e))}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},J:function(e,t){t=t<-9007199254740992||t>9007199254740992?NaN:Number(t);try{if(isNaN(t))return-22;var n=I(e);if(t<0||!(n.flags&2097155))throw new j(28);return nt(n,n.node,t),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},I:function(e,t){try{if(!t)return-28;var n=T(`/`)+1;return t<n?-68:(E(`/`,S,e,t),n)}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},F:()=>0,M:function(e,t){try{return e=C(e),lt(t,$e(e,!0))}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},C:function(e,t,n){try{return t=C(t),t=W(e,t),L(t,n&-19),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},L:function(e,t,n,r){try{t=C(t);var i=r&256;return t=W(e,t,r&4096),lt(n,i?$e(t,!0):$e(t))}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},x:function(e,t,n,r){ut=r;try{t=C(t),t=W(e,t);var i=r?ft():0;return n&64&&(i&=-19),R(t,n,i).ib}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},s:function(e,t,n,r){try{if(t=C(t),t=W(e,t),r<=0)return-28;var i=M(t).node;if(!i)throw new j(44);if(!i.Ra.kb)throw new j(28);var a=i.Ra.kb(i),o=Math.min(r,T(a)),s=b[n+o];return E(a,S,n,r+1),b[n+o]=s,o}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},r:function(e){try{return e=C(e),Ze(e),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},N:function(e,t){try{return e=C(e),lt(t,$e(e))}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},o:function(e,t,n){try{if(t=C(t),t=W(e,t),n){if(n===512)Ze(t);else return-28}else Qe(t);return 0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},n:function(e,t,n,r){try{r&=256,t=C(t),t=W(e,t,!0);var i=Date.now();if(n){function e(e){var t=V[e+8>>2];return t==1073741823?i:t==1073741822?null:(U[e>>2]+V[e+4>>2]*4294967296)*1e3+Math.floor(t/1e6)}var a=e(n),o=e(n+16)}else o=a=i;return(o??a)!==null&&rt(t,a,o,r),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},w:()=>v(``),v:()=>{x=!1,pt=0},A:function(e,t){if(e=e<-9007199254740992||e>9007199254740992?NaN:Number(e),e=/* @__PURE__ */ new Date(e*1e3),isNaN(e.getTime()))return 1;V[t>>2]=e.getSeconds(),V[t+4>>2]=e.getMinutes(),V[t+8>>2]=e.getHours(),V[t+12>>2]=e.getDate(),V[t+16>>2]=e.getMonth(),V[t+20>>2]=e.getFullYear()-1900,V[t+24>>2]=e.getDay();var n=e.getFullYear();V[t+28>>2]=(n%4!=0||n%100==0&&n%400!=0?ht:mt)[e.getMonth()]+e.getDate()-1|0,V[t+36>>2]=-(e.getTimezoneOffset()*60),n=new Date(e.getFullYear(),6,1).getTimezoneOffset();var r=new Date(e.getFullYear(),0,1).getTimezoneOffset();return V[t+32>>2]=(n!=r&&e.getTimezoneOffset()==Math.min(r,n))|0,0},y:function(e,t,n,r,i,a,o){i=i<-9007199254740992||i>9007199254740992?NaN:Number(i);try{var s=I(r);if(t&2&&!(n&2)&&(s.flags&2097155)!=2||(s.flags&2097155)==1)throw new j(2);if(!s.Qa.xb)throw new j(43);if(!e)throw new j(28);var c=s.Qa.xb(s,e,i,t,n),l=c.Bc;return V[a>>2]=c.$b,U[o>>2]=l,0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},z:function(e,t,n,r,i,a){a=a<-9007199254740992||a>9007199254740992?NaN:Number(a);try{var o=I(i);if(n&2){if((o.node.mode&61440)!=32768)throw new j(43);r&2||o.Qa.yb&&o.Qa.yb(o,S.subarray(e,e+t),a,t,r)}}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},k:(e,t)=>(vt[e]&&(clearTimeout(vt[e].id),delete vt[e]),t&&(vt[e]={id:setTimeout(()=>{delete vt[e];var t=[e,performance.now()],n=Nt;if(!_)try{n(...t)}catch(e){gt(e)}finally{if(!(x||pt>0))try{ee=t=ee,_t(t)}catch(e){gt(e)}}},t),Oc:t}),0),B:(e,t,n,r)=>{var i=(/* @__PURE__ */ new Date()).getFullYear(),a=new Date(i,0,1).getTimezoneOffset();i=new Date(i,6,1).getTimezoneOffset(),U[e>>2]=Math.max(a,i)*60,V[t>>2]=Number(a!=i),t=e=>{var t=Math.abs(e);return`UTC${e>=0?`-`:`+`}${String(Math.floor(t/60)).padStart(2,`0`)}${String(t%60).padStart(2,`0`)}`},e=t(a),t=t(i),i<a?(E(e,S,n,17),E(t,S,r,17)):(E(e,S,r,17),E(t,S,n,17))},d:()=>Date.now(),p:()=>2147483648,c:()=>performance.now(),l:e=>{var t=S.length;if(e>>>=0,e>2147483648)return!1;for(var n=1;n<=4;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);a:{r=(Math.min(2147483648,Math.ceil(Math.max(e,r)/65536)*65536)-Ft.buffer.byteLength+65535)/65536|0;try{Ft.grow(r),te();var i=1;break a}catch{}i=void 0}if(i)return!0}return!1},G:(e,t)=>{var n=0,r=0,i;for(i of bt()){var a=t+n;U[e+r>>2]=a,n+=E(i,S,a,1/0)+1,r+=4}return 0},H:(e,t)=>{var n=bt();U[e>>2]=n.length,e=0;for(var r of n)e+=T(r)+1;return U[t>>2]=e,0},e:function(e){try{return it(I(e)),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return e.Sa}},m:function(e,t){try{var n=I(e);return b[t]=n.Za?2:P(n.mode)?3:(n.mode&61440)==40960?7:4,dt[t+2>>1]=0,H[t+8>>3]=BigInt(0),H[t+16>>3]=BigInt(0),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return e.Sa}},t:function(e,t,n,r){try{a:{var i=I(e);e=t;for(var a,o=t=0;o<n;o++){var s=U[e>>2],c=U[e+4>>2];e+=8;try{var l=i,u=s,d=c,f=a,p=b;if(d<0||f<0)throw new j(28);if(l.ib===null||(l.flags&2097155)==1)throw new j(8);if(P(l.node.mode))throw new j(31);if(!l.Qa.read)throw new j(28);var m=f!==void 0;if(!m)f=l.position;else if(!l.seekable)throw new j(70);var h=l.Qa.read(l,p,u,d,f);m||(l.position+=h);var g=h}catch(e){if(t>0&&e instanceof j&&(e.Sa==6||e.Sa==6))break;throw e}if(g<0){var _=-1;break a}if(t+=g,g<c)break;a!==void 0&&(a+=g)}_=t}return U[r>>2]=_,0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return e.Sa}},E:function(e,t,n,r){t=t<-9007199254740992||t>9007199254740992?NaN:Number(t);try{if(isNaN(t))return 22;var i=I(e);return at(i,t,n),H[r>>3]=BigInt(i.position),i.Jb&&!t&&n===0&&(i.Jb=null),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return e.Sa}},K:function(e){try{var t=I(e);return t.Qa?.qb?.(t)}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return e.Sa}},q:function(e,t,n,r){try{var i=I(e);if(e=t,n==1)var a=ot(i,b,U[e>>2],U[e+4>>2]);else{for(var o=t=0,s=e;o<n;o++,s+=8)t+=U[s+4>>2];var c=new Uint8Array(t);for(o=s=0;o<n;o++,e+=8){var l=U[e>>2],u=U[e+4>>2];c.set(S.subarray(l,l+u),s),s+=u}a=ot(i,c,0,t)}return U[r>>2]=a,0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return e.Sa}},u:_t,f:function(e){console.warn(`sql.js: legacy function `+C(e)+`() is deprecated and will be disabled by default in the next major version. Initialize with useOldExtensionFunctions: false to use native SQLite functions. See https://github.com/sql-js/sql.js/pull/647`)}};async function Lt(){ne();var e=o.setStatus;e&&(e(`Running...`),await new Promise(e=>setTimeout(e,1)),setTimeout(e,1,``)),_||(o.noFSInit||ke||st(),Rt.P(),Ae=!1,o.onRuntimeInitialized?.(),re())}var Rt;return(async function(){function e(e){return e=Rt=e.exports,o._sqlite3_free=e.R,o._sqlite3_value_text=e.S,o._sqlite3_prepare_v2=e.T,o._sqlite3_step=e.U,o._sqlite3_reset=e.V,o._sqlite3_exec=e.W,o._sqlite3_finalize=e.X,o._sqlite3_column_name=e.Y,o._sqlite3_column_text=e.Z,o._sqlite3_column_type=e._,o._sqlite3_errmsg=e.$,o._sqlite3_backup_init=e.aa,o._sqlite3_backup_step=e.ba,o._sqlite3_backup_finish=e.ca,o._sqlite3_clear_bindings=e.da,o._sqlite3_value_blob=e.ea,o._sqlite3_value_bytes=e.fa,o._sqlite3_value_double=e.ga,o._sqlite3_value_int=e.ha,o._sqlite3_value_type=e.ia,o._sqlite3_result_blob=e.ja,o._sqlite3_result_double=e.ka,o._sqlite3_result_error=e.la,o._sqlite3_result_int=e.ma,o._sqlite3_result_int64=e.na,o._sqlite3_result_null=e.oa,o._sqlite3_result_text=e.pa,o._sqlite3_aggregate_context=e.qa,o._sqlite3_column_count=e.ra,o._sqlite3_data_count=e.sa,o._sqlite3_column_blob=e.ta,o._sqlite3_column_bytes=e.ua,o._sqlite3_column_double=e.va,o._sqlite3_bind_blob=e.wa,o._sqlite3_bind_double=e.xa,o._sqlite3_bind_int=e.ya,o._sqlite3_bind_text=e.za,o._sqlite3_bind_parameter_index=e.Aa,o._sqlite3_sql=e.Ba,o._sqlite3_normalized_sql=e.Ca,o._sqlite3_changes=e.Da,o._sqlite3_close_v2=e.Ea,o._sqlite3_create_function_v2=e.Fa,o._sqlite3_update_hook=e.Ga,o._sqlite3_open=e.Ha,jt=o._malloc=e.Ia,X=o._free=e.Ja,o._RegisterExtensionFunctions=e.Ka,Mt=e.La,Nt=e.Ma,Pt=e.Na,Z=e.Oa,Q=e.Pa,Ft=e.O,$=e.Q,te(),Rt}var t={a:It},n=o.instantiateWasm;return n?new Promise(r=>{n(t,t=>r(e(t)))}):(y??=o.locateFile?o.locateFile(`sql-wasm-browser.wasm`,d):d+`sql-wasm-browser.wasm`,function(t){return e(t.instance)}(await oe(t)))})().then(()=>Lt()),i}),n)};typeof e==`object`&&typeof t==`object`?(t.exports=r,t.exports.default=r):typeof define==`function`&&define.amd?define([],function(){return r}):typeof e==`object`&&(e.Module=r)})))(),1),r=new URL(`sql-wasm-CXIAVl5-.wasm`,import.meta.url).href,i={commands:[{name:`sqlite3`,summary:`query a SQLite database file`,usage:`sqlite3 [-header] file.db "SQL" (or pipe SQL in; .tables and .schema work)`,async run(e){let t=e.args.includes(`-header`),i=e.args.filter(e=>e!==`-header`),a=i[0],o=(i.slice(1).join(` `)||e.stdin).trim();if(!a||!o)throw Error(`usage: sqlite3 [-header] file.db "SQL"`);if(o===`.tables`)o=`SELECT name FROM sqlite_master WHERE type IN ('table','view') ORDER BY name`;else if(o.startsWith(`.schema`))o=`SELECT sql FROM sqlite_master WHERE sql IS NOT NULL ORDER BY name`;else if(o.startsWith(`.`))throw Error(`unsupported dot-command: ${o.split(` `)[0]}`);let s=await(0,n.default)({locateFile:()=>r}),c=e.path(a),l=await e.os.fs.readFile(c).catch(()=>null),u=new s.Database(l??void 0);try{for(let n of u.exec(o)){t&&e.out(n.columns.join(`|`)+`
3
3
  `);for(let t of n.values)e.out(t.map(e=>e===null?``:e instanceof Uint8Array?`<blob ${e.length}>`:String(e)).join(`|`)+`
4
4
  `)}(u.getRowsModified()>0||!l||/^\s*(create|drop|alter|insert|update|delete|replace|vacuum)/i.test(o))&&await e.os.fs.writeFile(c,u.export())}finally{u.close()}}}]};export{i as default};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./path-DGG-Mxbd.js";import{i as n,n as r}from"./main-CQvaEX7y.js";var i=Uint8Array,a=Uint16Array,o=Int32Array,s=new i([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),c=new i([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),l=new i([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=function(e,t){for(var n=new a(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new o(n[30]),r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return{b:n,r:i}},d=u(s,2),f=d.b,p=d.r;f[28]=258,p[258]=28;for(var m=u(c,0),h=m.b,g=m.r,_=new a(32768),v=0;v<32768;++v){var y=(v&43690)>>1|(v&21845)<<1;y=(y&52428)>>2|(y&13107)<<2,y=(y&61680)>>4|(y&3855)<<4,_[v]=((y&65280)>>8|(y&255)<<8)>>1}for(var b=(function(e,t,n){for(var r=e.length,i=0,o=new a(t);i<r;++i)e[i]&&++o[e[i]-1];var s=new a(t);for(i=1;i<t;++i)s[i]=s[i-1]+o[i-1]<<1;var c;if(n){c=new a(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var u=i<<4|e[i],d=t-e[i],f=s[e[i]-1]++<<d,p=f|(1<<d)-1;f<=p;++f)c[_[f]>>l]=u}else for(c=new a(r),i=0;i<r;++i)e[i]&&(c[i]=_[s[e[i]-1]++]>>15-e[i]);return c}),x=new i(288),v=0;v<144;++v)x[v]=8;for(var v=144;v<256;++v)x[v]=9;for(var v=256;v<280;++v)x[v]=7;for(var v=280;v<288;++v)x[v]=8;for(var S=new i(32),v=0;v<32;++v)S[v]=5;var C=/*#__PURE__*/ b(x,9,0),w=/*#__PURE__*/ b(x,9,1),T=/*#__PURE__*/ b(S,5,0),ee=/*#__PURE__*/ b(S,5,1),E=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},D=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},O=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},te=function(e){return(e+7)/8|0},ne=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new i(e.subarray(t,n))},k=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],A=function(e,t,n){var r=Error(t||k[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,A),!n)throw r;return r},j=function(e,t,n,r){var a=e.length,o=r?r.length:0;if(!a||t.f&&!t.l)return n||new i(0);var u=!n,d=u||t.i!=2,p=t.i;u&&(n=new i(a*3));var m=function(e){var t=n.length;if(e>t){var r=new i(Math.max(t*2,e));r.set(n),n=r}},g=t.f||0,_=t.p||0,v=t.b||0,y=t.l,x=t.d,S=t.m,C=t.n,T=a*8;do{if(!y){g=D(e,_,1);var k=D(e,_+1,3);if(_+=3,!k){var j=te(_)+4,M=e[j-4]|e[j-3]<<8,N=j+M;if(N>a){p&&A(0);break}d&&m(v+M),n.set(e.subarray(j,N),v),t.b=v+=M,t.p=_=N*8,t.f=g;continue}if(k==1)y=w,x=ee,S=9,C=5;else if(k==2){var P=D(e,_,31)+257,F=D(e,_+10,15)+4,I=P+D(e,_+5,31)+1;_+=14;for(var L=new i(I),re=new i(19),R=0;R<F;++R)re[l[R]]=D(e,_+R*3,7);_+=F*3;for(var z=E(re),B=(1<<z)-1,V=b(re,z,1),R=0;R<I;){var H=V[D(e,_,B)];_+=H&15;var j=H>>4;if(j<16)L[R++]=j;else{var U=0,W=0;for(j==16?(W=3+D(e,_,3),_+=2,U=L[R-1]):j==17?(W=3+D(e,_,7),_+=3):j==18&&(W=11+D(e,_,127),_+=7);W--;)L[R++]=U}}var G=L.subarray(0,P),K=L.subarray(P);S=E(G),C=E(K),y=b(G,S,1),x=b(K,C,1)}else A(1);if(_>T){p&&A(0);break}}d&&m(v+131072);for(var q=(1<<S)-1,ie=(1<<C)-1,J=_;;J=_){var U=y[O(e,_)&q],Y=U>>4;if(_+=U&15,_>T){p&&A(0);break}if(U||A(2),Y<256)n[v++]=Y;else if(Y==256){J=_,y=null;break}else{var X=Y-254;if(Y>264){var R=Y-257,Z=s[R];X=D(e,_,(1<<Z)-1)+f[R],_+=Z}var Q=x[O(e,_)&ie],$=Q>>4;Q||A(3),_+=Q&15;var K=h[$];if($>3){var Z=c[$];K+=O(e,_)&(1<<Z)-1,_+=Z}if(_>T){p&&A(0);break}d&&m(v+131072);var ae=v+X;if(v<K){var oe=o-K,se=Math.min(K,ae);for(oe+v<0&&A(3);v<se;++v)n[v]=r[oe+v]}for(;v<ae;++v)n[v]=n[v-K]}}t.l=y,t.p=J,t.b=v,t.f=g,y&&(g=1,t.m=S,t.d=x,t.n=C)}while(!g);return v!=n.length&&u?ne(n,0,v):n.subarray(0,v)},M=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},N=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},P=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,s=n.slice();if(!o)return{t:B,l:0};if(o==1){var c=new i(n[0].s+1);return c[n[0].s]=1,{t:c,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var l=n[0],u=n[1],d=0,f=1,p=2;for(n[0]={s:-1,f:l.f+u.f,l,r:u};f!=o-1;)l=n[n[d].f<n[p].f?d++:p++],u=n[d!=f&&n[d].f<n[p].f?d++:p++],n[f++]={s:-1,f:l.f+u.f,l,r:u};for(var m=s[0].s,r=1;r<o;++r)s[r].s>m&&(m=s[r].s);var h=new a(m+1),g=F(n[f-1],h,0);if(g>t){var r=0,_=0,v=g-t,y=1<<v;for(s.sort(function(e,t){return h[t.s]-h[e.s]||e.f-t.f});r<o;++r){var b=s[r].s;if(h[b]>t)_+=y-(1<<g-h[b]),h[b]=t;else break}for(_>>=v;_>0;){var x=s[r].s;h[x]<t?_-=1<<t-h[x]++-1:++r}for(;r>=0&&_;--r){var S=s[r].s;h[S]==t&&(--h[S],++_)}g=t}return{t:new i(h),l:g}},F=function(e,t,n){return e.s==-1?Math.max(F(e.l,t,n+1),F(e.r,t,n+1)):t[e.s]=n},I=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new a(++t),r=0,i=e[0],o=1,s=function(e){n[r++]=e},c=1;c<=t;++c)if(e[c]==i&&c!=t)++o;else{if(!i&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(i),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(i);o=1,i=e[c]}return{c:n.subarray(0,r),n:t}},L=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},re=function(e,t,n){var r=n.length,i=te(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},R=function(e,t,n,r,i,o,u,d,f,p,m){M(t,m++,n),++i[256];for(var h=P(i,15),g=h.t,_=h.l,v=P(o,15),y=v.t,w=v.l,ee=I(g),E=ee.c,D=ee.n,O=I(y),te=O.c,ne=O.n,k=new a(19),A=0;A<E.length;++A)++k[E[A]&31];for(var A=0;A<te.length;++A)++k[te[A]&31];for(var j=P(k,7),F=j.t,R=j.l,z=19;z>4&&!F[l[z-1]];--z);var B=p+5<<3,V=L(i,x)+L(o,S)+u,H=L(i,g)+L(o,y)+u+14+3*z+L(k,F)+2*k[16]+3*k[17]+7*k[18];if(f>=0&&B<=V&&B<=H)return re(t,m,e.subarray(f,f+p));var U,W,G,K;if(M(t,m,1+(H<V)),m+=2,H<V){U=b(g,_,0),W=g,G=b(y,w,0),K=y;var q=b(F,R,0);M(t,m,D-257),M(t,m+5,ne-1),M(t,m+10,z-4),m+=14;for(var A=0;A<z;++A)M(t,m+3*A,F[l[A]]);m+=3*z;for(var ie=[E,te],J=0;J<2;++J)for(var Y=ie[J],A=0;A<Y.length;++A){var X=Y[A]&31;M(t,m,q[X]),m+=F[X],X>15&&(M(t,m,Y[A]>>5&127),m+=Y[A]>>12)}}else U=C,W=x,G=T,K=S;for(var A=0;A<d;++A){var Z=r[A];if(Z>255){var X=Z>>18&31;N(t,m,U[X+257]),m+=W[X+257],X>7&&(M(t,m,Z>>23&31),m+=s[X]);var Q=Z&31;N(t,m,G[Q]),m+=K[Q],Q>3&&(N(t,m,Z>>5&8191),m+=c[Q])}else N(t,m,U[Z]),m+=W[Z]}return N(t,m,U[256]),m+W[256]},z=/*#__PURE__*/ new o([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),B=/*#__PURE__*/ new i(0),V=function(e,t,n,r,l,u){var d=u.z||e.length,f=new i(r+d+5*(1+Math.ceil(d/7e3))+l),m=f.subarray(r,f.length-l),h=u.l,_=(u.r||0)&7;if(t){_&&(m[0]=u.r>>3);for(var v=z[t-1],y=v>>13,b=v&8191,x=(1<<n)-1,S=u.p||new a(32768),C=u.h||new a(x+1),w=Math.ceil(n/3),T=2*w,ee=function(t){return(e[t]^e[t+1]<<w^e[t+2]<<T)&x},E=new o(25e3),D=new a(288),O=new a(32),k=0,A=0,j=u.i||0,M=0,N=u.w||0,P=0;j+2<d;++j){var F=ee(j),I=j&32767,L=C[F];if(S[I]=L,C[F]=I,N<=j){var B=d-j;if((k>7e3||M>24576)&&(B>423||!h)){_=R(e,m,0,E,D,O,A,M,P,j-P,_),M=k=A=0,P=j;for(var V=0;V<286;++V)D[V]=0;for(var V=0;V<30;++V)O[V]=0}var H=2,U=0,W=b,G=I-L&32767;if(B>2&&F==ee(j-G))for(var K=Math.min(y,B)-1,q=Math.min(32767,j),ie=Math.min(258,B);G<=q&&--W&&I!=L;){if(e[j+H]==e[j+H-G]){for(var J=0;J<ie&&e[j+J]==e[j+J-G];++J);if(J>H){if(H=J,U=G,J>K)break;for(var Y=Math.min(G,J-2),X=0,V=0;V<Y;++V){var Z=j-G+V&32767,Q=Z-S[Z]&32767;Q>X&&(X=Q,L=Z)}}}I=L,L=S[I],G+=I-L&32767}if(U){E[M++]=268435456|p[H]<<18|g[U];var $=p[H]&31,ae=g[U]&31;A+=s[$]+c[ae],++D[257+$],++O[ae],N=j+H,++k}else E[M++]=e[j],++D[e[j]]}}for(j=Math.max(j,N);j<d;++j)E[M++]=e[j],++D[e[j]];_=R(e,m,h,E,D,O,A,M,P,j-P,_),h||(u.r=_&7|m[_/8|0]<<3,_-=7,u.h=C,u.p=S,u.i=j,u.w=N)}else{for(var j=u.w||0;j<d+h;j+=65535){var oe=j+65535;oe>=d&&(m[_/8|0]=h,oe=d),_=re(m,_+1,e.subarray(j,oe))}u.i=d}return ne(f,0,r+te(_)+l)},H=/*#__PURE__*/ (function(){for(var e=/* @__PURE__ */ new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),U=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=H[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},W=function(e,t,n,r,a){if(!a&&(a={l:1},t.dictionary)){var o=t.dictionary.subarray(-32768),s=new i(o.length+e.length);s.set(o),s.set(e,o.length),e=s,a.w=o.length}return V(e,t.level==null?6:t.level,t.mem==null?a.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,a)},G=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},K=function(e,t){return e[t]|e[t+1]<<8},q=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},ie=function(e,t){return q(e,t)+q(e,t+4)*4294967296},J=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Y(e,t){return W(e,t||{},0,0)}function X(e,t){return j(e,{i:2},t&&t.out,t&&t.dictionary)}var Z=function(e,t,n,r){for(var a in e){var o=e[a],s=t+a,c=r;Array.isArray(o)&&(c=G(r,o[1]),o=o[0]),ArrayBuffer.isView(o)?n[s]=[o,c]:(n[s+=`/`]=[new i(0),c],Z(o,s,n,r))}},Q=typeof TextEncoder<`u`&&/*#__PURE__*/ new TextEncoder,$=typeof TextDecoder<`u`&&/*#__PURE__*/ new TextDecoder;try{$.decode(B,{stream:!0})}catch{}var ae=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:ne(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function oe(e,t){if(t){for(var n=new i(e.length),r=0;r<e.length;++r)n[r]=e.charCodeAt(r);return n}if(Q)return Q.encode(e);for(var a=e.length,o=new i(e.length+(e.length>>1)),s=0,c=function(e){o[s++]=e},r=0;r<a;++r){if(s+5>o.length){var l=new i(s+8+(a-r<<1));l.set(o),o=l}var u=e.charCodeAt(r);u<128||t?c(u):u<2048?(c(192|u>>6),c(128|u&63)):u>55295&&u<57344?(u=65536+(u&1047552)|e.charCodeAt(++r)&1023,c(240|u>>18),c(128|u>>12&63),c(128|u>>6&63),c(128|u&63)):(c(224|u>>12),c(128|u>>6&63),c(128|u&63))}return ne(o,0,s)}function se(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if($)return $.decode(e);var i=ae(e),a=i.s,n=i.r;return n.length&&A(8),a}var ce=function(e,t){return t+30+K(e,t+26)+K(e,t+28)},le=function(e,t,n){var r=K(e,t+28),i=K(e,t+30),a=se(e.subarray(t+46,t+46+r),!(K(e,t+8)&2048)),o=t+46+r,s=ue(e,o,i,n,q(e,t+20),q(e,t+24),q(e,t+42)),c=s[0],l=s[1],u=s[2];return[K(e,t+10),c,l,a,o+i+K(e,t+32),u]},ue=function(e,t,n,r,i,a,o){var s=i==4294967295,c=a==4294967295,l=o==4294967295,u=t+n,d=s+c+l;if(r&&d){for(;t+4<u;t+=4+K(e,t+2))if(K(e,t)==1)return[s?ie(e,t+4+8*c):i,c?ie(e,t+4):a,l?ie(e,t+4+8*(c+s)):o,1];r<2&&A(13)}return[i,a,o,0]},de=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&A(9),t+=r+4}return t},fe=function(e,t,n,r,i,a,o,s){var c=r.length,l=n.extra,u=s&&s.length,d=de(l);J(e,t,o==null?67324752:33639248),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&A(10),J(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(J(e,t,n.crc),J(e,t+4,a<0?-a-2:a),J(e,t+8,n.size)),J(e,t+12,c),J(e,t+14,d),t+=16,o!=null&&(J(e,t,u),J(e,t+6,n.attrs),J(e,t+10,o),t+=14),e.set(r,t),t+=c,d)for(var m in l){var h=l[m],g=h.length;J(e,t,+m),J(e,t+2,g),e.set(h,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},pe=function(e,t,n,r,i){J(e,t,101010256),J(e,t+8,n),J(e,t+10,n),J(e,t+12,r),J(e,t+16,i)};function me(e,t){t||={};var n={},r=[];Z(e,``,n,t);var a=0,o=0;for(var s in n){var c=n[s],l=c[0],u=c[1],d=u.level==0?0:8,f=oe(s),p=f.length,m=u.comment,h=m&&oe(m),g=h&&h.length,_=de(u.extra);p>65535&&A(11);var v=d?Y(l,u):l,y=v.length,b=U();b.p(l),r.push(G(u,{size:l.length,crc:b.d(),c:v,f,m:h,u:p!=s.length||h&&m.length!=g,o:a,compression:d})),a+=30+p+_+y,o+=76+2*(p+_)+(g||0)+y}for(var x=new i(o+22),S=a,C=o-a,w=0;w<r.length;++w){var f=r[w];fe(x,f.o,f,f.f,f.u,f.c.length);var T=30+f.f.length+de(f.extra);x.set(f.c,f.o+T),fe(x,a,f,f.f,f.u,f.c.length,f.o,f.m),a+=16+T+(f.m?f.m.length:0)}return pe(x,a,r.length,C,S),x}function he(e,t){for(var n={},r=e.length-22;q(e,r)!=101010256;--r)(!r||e.length-r>65558)&&A(13);var a=K(e,r+8);if(!a)return{};var o=q(e,r+16),s=q(e,r-20)==117853008;if(s){var c=q(e,r-12);s=q(e,c)==101075792,s&&(a=q(e,c+32),o=q(e,c+48))}for(var l=t&&t.filter,u=0;u<a;++u){var d=le(e,o,s),f=d[0],p=d[1],m=d[2],h=d[3],g=d[4],_=d[5],v=ce(e,_);o=g,(!l||l({name:h,size:p,originalSize:m,compression:f}))&&(f?f==8?n[h]=X(e.subarray(v,v+p),{out:new i(m)}):A(14,`unknown compression type `+f):n[h]=ne(e,v,v+p))}return n}var ge={commands:[{name:`zip`,summary:`create a zip archive`,usage:`zip [-r] archive.zip path…`,async run(t){let{rest:i}=n(t.args),a=i.shift();if(!a||!i.length)throw Error(`usage: zip [-r] archive.zip path…`);let o={};for(let n of i){let r=t.path(n),i=await t.os.fs.stat(r);if(!i)throw Error(`${n}: no such file or directory`);let a=e(r)===`/`?`/`:e(r)+`/`;if(i.kind===`file`)o[r.slice(a.length)]=await t.os.fs.readFile(r);else for await(let e of t.os.fs.walk(r,{signal:t.signal}))e.kind===`file`&&(o[e.path.slice(a.length)]=await t.os.fs.readFile(e.path))}let s=me(o);await t.os.fs.writeFile(t.path(a),s),t.out(`${Object.keys(o).length} files → ${a} (${r(s.length)})\n`)}},{name:`unzip`,summary:`list or extract a zip archive`,usage:`unzip [-l] archive.zip [-d dir]`,async run(e){let n=e.args.indexOf(`-d`),r=e.path(n>=0?e.args[n+1]??`.`:`.`),i=e.args.filter((e,t)=>e!==`-l`&&t!==n&&t!==n+1);if(!i[0])throw Error(`usage: unzip [-l] archive.zip [-d dir]`);let a=he(await e.os.fs.readFile(e.path(i[0]))),o=0;for(let[n,i]of Object.entries(a))n.endsWith(`/`)||(o++,e.args.includes(`-l`)?e.out(`${String(i.length).padStart(10)} ${n}\n`):await e.os.fs.writeFile(t(r,t(`/`,n)),i));e.out(`${o} file${o===1?``:`s`}${e.args.includes(`-l`)?``:` extracted to ${r}`}\n`)}}]};export{ge as default};
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));export{c as n,o as t};
@@ -0,0 +1,4 @@
1
+ import{n as e,t}from"./html-Bd3_N2aN.js";import{o as n}from"./main-CQvaEX7y.js";import{a as r,o as i,r as a,s as o,t as s}from"./path-DGG-Mxbd.js";import{t as c}from"./bundle-CXrJ5BHI.js";const l=[`server.ts`,`server.js`,`server.mjs`,`api/index.ts`,`api/index.js`];function u(e){let t=e.replace(/("(?:\\.|[^"\\])*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//g,(e,t)=>t??``).replace(/,(\s*[}\]])/g,`$1`);return JSON.parse(t)}function d(e){let t={};for(let n of e.split(`
2
+ `)){let e=/^\s*(?:export\s+)?([\w.]+)\s*=\s*(.*?)\s*$/.exec(n);e&&!n.trim().startsWith(`#`)&&(t[e[1]]=e[2].replace(/^(['"])(.*)\1$/,`$2`))}return t}const f=(e,t,n=`text/plain; charset=utf-8`)=>({status:e,headers:[[`content-type`,n]],body:new TextEncoder().encode(t)});var p=class{os;#e=/* @__PURE__ */ new Map;constructor(e){this.os=e,e.bus.on(`proc:exit`,({proc:t})=>{for(let[r,i]of this.#e)i.info.pid===t.pid&&(this.#e.delete(r),n(e,`stop`,String(r),{}),this.#t())}),e.bus.on(`fs:change`,({path:e})=>{for(let t of this.#e.values()){if(!r(t.info.root,e))continue;let n=e.slice(t.info.root.length+1);(t.backendInputs.has(e)||l.includes(n)||n===`package.json`||n.startsWith(`.env`))&&(t.backendReady=!1)}})}#t(){this.os.bus.emit(`dev:update`,[...this.#e.values()].map(e=>({...e.info})))}#n(e){let t=this.#e.get(e);if(!t)throw Error(`nothing is serving on port ${e} (see: serve list)`);return t}async start(e){let t=o(e.root);if((await this.os.fs.stat(t))?.kind!==`dir`)throw Error(`${t} is not a folder`);for(let e of this.#e.values())if(e.info.root===t)return{...e.info};let n=e.port??3e3;if(e.port!==void 0&&this.#e.has(n))throw Error(`port ${n} is in use by ${this.#e.get(n).info.root}`);for(;this.#e.has(n);)n++;let r=this.os.procs.spawn({name:`serve :${n}`,kind:`service`,ppid:e.ppid,detail:t});this.os.procs.update(r.pid,{state:`idle`});let i={port:n,root:t,pid:r.pid,url:`http://localhost:${n}/`,backend:await this.#a(t),network:!!e.network};return this.#e.set(n,{info:i,logs:[],seq:0,backendReady:!1,backendInputs:/* @__PURE__ */ new Set,queue:Promise.resolve()}),this.os.log(`dev`,`serving ${t} on :${n}${i.backend?` (backend ${i.backend})`:``}`),this.#t(),{...i}}async stop(e){let t=this.#e.get(e);return t?(this.os.procs.kill(t.info.pid,`stopped`),this.#e.delete(e),n(this.os,`stop`,String(e),{}),this.#t(),!0):!1}async list(){return[...this.#e.values()].map(e=>({...e.info}))}log(e,t){let n=this.#e.get(e);if(n)for(let r of t){let t={seq:++n.seq,t:Date.now(),level:r.level,source:r.source,text:String(r.text).slice(0,8e3)};n.logs.push(t),n.logs.length>500&&n.logs.shift(),this.os.bus.emit(`dev:log`,{port:e,entry:t})}}async logs(e,t={}){let n=this.#n(e).logs.filter(e=>e.seq>(t.after??0));return t.limit?n.slice(-t.limit):n}async#r(e){let t=t=>this.os.fs.readText(i(e,t)).catch(()=>null),[n,r,a,...o]=await Promise.all([t(`package.json`),t(`tsconfig.json`),t(`jsconfig.json`),t(`.env`),t(`.env.development`),t(`.env.local`)]),s=(e,t)=>{if(!e)return null;try{return u(e)}catch(e){throw Error(`${t} is not valid JSON: ${e.message}`)}},c={...this.os.settings.get(`env.vars`,{})};for(let e of o)e&&Object.assign(c,d(e));return{pkg:s(n,`package.json`),tsconfig:s(r??a,r?`tsconfig.json`:`jsconfig.json`),env:c}}async#i(e){return(await this.os.fs.stat(e).catch(()=>null))?.kind===`file`}async#a(e){for(let t of l)if(await this.#i(i(e,t)))return t;return null}async page(n,r=`/`){let a=this.#n(n),l=a.info.root,u=o(decodeURIComponent(r.split(/[?#]/)[0]||`/`)),d=i(l,u),f=null,p=await this.os.fs.stat(d).catch(()=>null);if(p?.kind===`dir`&&await this.#i(i(d,`index.html`)))f=i(d,`index.html`);else if(p?.kind===`file`&&/\.html?$/i.test(d))f=d;else if(await this.#i(`${d}.html`))f=`${d}.html`;else if(p?.kind===`file`){let r=e(d).startsWith(`image/`)?`<img src="${u}" alt="" style="max-width:100%">`:`<pre id="t" style="white-space:pre-wrap;font:13px ui-monospace,monospace"></pre><script>fetch(${JSON.stringify(u)}).then(r=>r.text()).then(t=>document.getElementById('t').textContent=t)<\/script>`,i=`<!doctype html><html><head><meta charset="utf-8"><title>${s(d)}</title></head><body style="margin:0;padding:12px">${r}</body></html>`;return t(this.os.fs,{root:l,htmlPath:null,html:i,path:u,port:n,bundle:async()=>({js:``,css:``,errors:[],warnings:[],inputs:[]})})}!f&&p?.kind!==`file`&&await this.#i(i(l,`index.html`))&&(f=i(l,`index.html`));let m;try{m=await this.#r(l)}catch(e){m={pkg:null,tsconfig:null,env:{}},this.log(n,[{level:`error`,source:`build`,text:e.message}])}let h=Object.fromEntries(Object.entries(m.env).filter(([e])=>/^(VITE_|PUBLIC_)/.test(e))),g=performance.now(),_=await t(this.os.fs,{root:l,htmlPath:f,path:u+(r.includes(`?`)?r.slice(r.indexOf(`?`)):``),port:n,bundle:e=>c({fs:this.os.fs,root:l,entry:e,target:`browser`,env:h,pkg:m.pkg,tsconfig:m.tsconfig})});return this.os.procs.account(a.info.pid,performance.now()-g),_.errors.length&&this.log(n,_.errors.map(e=>({level:`error`,source:`build`,text:e}))),{html:_.html,errors:_.errors}}async request(t,n){let o=this.#n(t),s=o.info.root,c=new URL(n.url,`http://localhost`),l;try{l=decodeURIComponent(c.pathname)}catch{return f(400,`Bad request`)}let u=i(s,l),d=u.slice(s.length).split(`/`).some(e=>e.startsWith(`.`));if(r(s,u)&&!d&&/^(GET|HEAD)$/i.test(n.method)){let t=u;if((await this.os.fs.stat(t).catch(()=>null))?.kind===`dir`&&(t=i(t,`index.html`)),await this.#i(t)){let r=n.method.toUpperCase()===`HEAD`?null:await this.os.fs.readFile(t);return{status:200,headers:[[`content-type`,e(t)+(/^text\/|json|javascript|xml/.test(e(t))?`; charset=utf-8`:``)]],body:r}}}if(o.backendReady||(o.info.backend=await this.#a(s)),o.info.backend){let e=o.queue.then(()=>this.#c(o,n,c));return o.queue=e.catch(()=>void 0),e}return this.log(t,[{level:`warn`,source:`network`,text:`${n.method} ${n.url} → 404 (no such file${a(l)?``:`, and no backend: add server.ts to answer requests`})`}]),f(404,`Not found: ${l}`)}async#o(e){let{root:t,port:r,pid:a,network:o}=e.info,s=await this.#r(t),l=await c({fs:this.os.fs,root:t,entry:i(t,e.info.backend),target:`server`,env:s.env,pkg:s.pkg,tsconfig:s.tsconfig});if(e.backendInputs=new Set(l.inputs),l.errors.length)return`The backend (${e.info.backend}) failed to build:\n\n${l.errors.join(`
3
+
4
+ `)}`;let u=await n(this.os,`load`,String(r),{code:l.js,env:s.env,network:o,ppid:a},{cwd:t,onStdout:e=>this.#s(r,`log`,e),onStderr:e=>this.#s(r,`error`,e)});return u.ok?(e.backendReady=!0,this.os.log(`dev`,`:${r} backend ${e.info.backend} loaded`),null):`The backend (${e.info.backend}) failed to start: ${u.error??u.stderr}`}#s(e,t,n){let r=n.replace(/\n$/,``);r&&this.log(e,[{level:t,source:`server`,text:r}])}async#c(e,t,r){let{port:i,root:a}=e.info,o=e=>(this.log(i,[{level:`error`,source:`server`,text:e}]),f(500,e));for(let s=0;s<2;s++){if(!e.backendReady){let t=await this.#o(e);if(t)return o(t)}let s=performance.now(),c=await n(this.os,`request`,String(i),{req:t,origin:`http://localhost:${i}`},{cwd:a,onStdout:e=>this.#s(i,`log`,e),onStderr:e=>this.#s(i,`error`,e)});if(this.os.procs.account(e.info.pid,performance.now()-s),c.error===`backend not loaded`){e.backendReady=!1;continue}if(c.error)return o(`${t.method} ${r.pathname}: ${c.error}`);let l=c.response;return l?(l.status>=400&&this.log(i,[{level:l.status>=500?`error`:`warn`,source:`network`,text:`${t.method} ${t.url} → ${l.status}`}]),l):(this.log(i,[{level:`warn`,source:`network`,text:`${t.method} ${t.url} → 404 (no file, and the backend did not answer)`}]),f(404,`Not found: ${r.pathname}`))}return o(`the backend could not be started`)}};export{p as DevServers};
@@ -4,11 +4,11 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>BrowserBox runtime</title>
7
- <script type="module" crossorigin src="../assets/embed-CMbAHE2J.js"></script>
8
- <link rel="modulepreload" crossorigin href="../assets/instance-CppC8T8t.js">
9
- <link rel="modulepreload" href="../assets/bridge-DY2WnNx7.js" />
10
- <link rel="modulepreload" href="../assets/instance-CppC8T8t.js" />
11
- <link rel="modulepreload" href="../assets/main-VEpSfsM_.js" />
7
+ <script type="module" crossorigin src="../assets/embed-uUqwwabc.js"></script>
8
+ <link rel="modulepreload" crossorigin href="../assets/instance-Cu6oky-A.js">
9
+ <link rel="modulepreload" href="../assets/bridge-DQLuopgW.js" />
10
+ <link rel="modulepreload" href="../assets/instance-Cu6oky-A.js" />
11
+ <link rel="modulepreload" href="../assets/main-CQvaEX7y.js" />
12
12
  </head>
13
13
  <body>
14
14
  </body>
@@ -4,8 +4,8 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; connect-src *; frame-src 'self'; worker-src 'self' blob:; object-src 'none'; base-uri 'self'" />
6
6
  <title>BrowserBox kernel bridge</title>
7
- <script type="module" crossorigin src="../assets/bridge-DY2WnNx7.js"></script>
8
- <link rel="modulepreload" crossorigin href="../assets/instance-CppC8T8t.js">
7
+ <script type="module" crossorigin src="../assets/bridge-DQLuopgW.js"></script>
8
+ <link rel="modulepreload" crossorigin href="../assets/instance-Cu6oky-A.js">
9
9
  </head>
10
10
  <body>
11
11
  <!-- No UI. Embedded as a hidden frame by every BrowserBox window; see src/kernel-host/bridge.ts. -->
@@ -1 +1 @@
1
- {"esbuild":[{"url":"assets/pkg-esbuild-BuQjm7dB.js","bytes":1164},{"url":"assets/bundle-8opp8__C.js","bytes":4265},{"url":"assets/npm-DF8ts_uH.js","bytes":1459}],"git":[{"url":"assets/pkg-git-jawfIVoq.js","bytes":219526}],"python":[{"url":"assets/pkg-python-CoNK0IjJ.js","bytes":4488}],"sqlite":[{"url":"assets/pkg-sqlite-BexM5lLo.js","bytes":41858},{"url":"assets/sql-wasm-CXIAVl5-.wasm","bytes":688197}],"zip":[{"url":"assets/pkg-zip-BdZ_Lkdk.js","bytes":13845}]}
1
+ {"esbuild":[{"url":"assets/pkg-esbuild-C-EHnLD8.js","bytes":1164},{"url":"assets/bundle-CXrJ5BHI.js","bytes":4297},{"url":"assets/npm-DF8ts_uH.js","bytes":1459}],"git":[{"url":"assets/pkg-git-BCxqHW9a.js","bytes":219526},{"url":"assets/rolldown-runtime-WkwZ5CU-.js","bytes":599}],"python":[{"url":"assets/pkg-python-B23D6vdG.js","bytes":3681}],"sqlite":[{"url":"assets/pkg-sqlite-CKGWzcwt.js","bytes":41858},{"url":"assets/sql-wasm-CXIAVl5-.wasm","bytes":688197},{"url":"assets/rolldown-runtime-WkwZ5CU-.js","bytes":599}],"zip":[{"url":"assets/pkg-zip-CuNUYwRy.js","bytes":13877}]}
@@ -0,0 +1,23 @@
1
+ import { type KernelInstance } from '../kernel/instance';
2
+ export interface ConnectOptions {
3
+ /** Where the kernel is served. Defaults to the build-time KERNEL_URL. */
4
+ kernelUrl?: string;
5
+ /** Which kernel: the app's (default) or an SDK box. */
6
+ instance?: KernelInstance;
7
+ }
8
+ export interface KernelLink {
9
+ port: MessagePort;
10
+ /** Name of the Web Lock the bridge holds for as long as this window lives. */
11
+ lock: string;
12
+ /** False when each window runs its own kernel (no SharedWorker support). */
13
+ shared: boolean;
14
+ /** Asks the same bridge for one more port to the same kernel (a separate client). */
15
+ more?(): Promise<KernelLink>;
16
+ }
17
+ /**
18
+ * Connects this window to the kernel. A hidden frame served from the kernel's
19
+ * origin starts (or joins) the kernel worker and hands back a message port.
20
+ * Going through a frame is what lets the window live on a different origin
21
+ * from the kernel: it never touches the kernel's storage, only this port.
22
+ */
23
+ export declare function connectKernel(opts?: ConnectOptions): Promise<KernelLink>;
@@ -0,0 +1,64 @@
1
+ import { KERNEL_URL } from '../config/origins';
2
+ import { APP_KERNEL, toSearch } from '../kernel/instance';
3
+ /**
4
+ * Connects this window to the kernel. A hidden frame served from the kernel's
5
+ * origin starts (or joins) the kernel worker and hands back a message port.
6
+ * Going through a frame is what lets the window live on a different origin
7
+ * from the kernel: it never touches the kernel's storage, only this port.
8
+ */
9
+ export function connectKernel(opts = {}) {
10
+ const kernelUrl = opts.kernelUrl ?? KERNEL_URL;
11
+ const base = kernelUrl.endsWith('/') ? kernelUrl : `${kernelUrl}/`;
12
+ const origin = new URL(base).origin;
13
+ return new Promise((resolve, reject) => {
14
+ const src = new URL(`bridge.html${toSearch(opts.instance ?? APP_KERNEL)}`, base).href;
15
+ // The page's HTML normally pre-starts the bridge so the kernel boots in parallel with our script.
16
+ const early = document.getElementById('bbx-bridge');
17
+ const frame = early?.src === src ? early : document.createElement('iframe');
18
+ if (frame !== early) {
19
+ frame.src = src;
20
+ frame.title = 'BrowserBox kernel bridge';
21
+ frame.setAttribute('aria-hidden', 'true');
22
+ frame.hidden = true;
23
+ }
24
+ const timer = setTimeout(() => reject(new Error(`The kernel at ${base} did not respond.`)), 20000);
25
+ let nextReq = 1;
26
+ const waiting = new Map();
27
+ const link = (data, port) => ({
28
+ port,
29
+ lock: String(data.lock),
30
+ shared: Boolean(data.shared),
31
+ more: () => new Promise((res) => {
32
+ const req = nextReq++;
33
+ waiting.set(req, res);
34
+ frame.contentWindow.postMessage({ type: 'bbx:connect', req }, origin);
35
+ }),
36
+ });
37
+ let first = true;
38
+ addEventListener('message', (e) => {
39
+ if (e.source !== frame.contentWindow || e.origin !== origin)
40
+ return;
41
+ if (e.data?.type === 'bbx:ready' && first)
42
+ frame.contentWindow.postMessage({ type: 'bbx:connect' }, origin);
43
+ else if (e.data?.type === 'bbx:port' && e.ports[0]) {
44
+ if (typeof e.data.req === 'number') {
45
+ waiting.get(e.data.req)?.(link(e.data, e.ports[0]));
46
+ waiting.delete(e.data.req);
47
+ }
48
+ else if (first) {
49
+ first = false;
50
+ clearTimeout(timer);
51
+ resolve(link(e.data, e.ports[0]));
52
+ }
53
+ }
54
+ else if (e.data?.type === 'bbx:refused' && first) {
55
+ clearTimeout(timer);
56
+ reject(new Error(`The kernel refused this origin (${location.origin}). Add it to VITE_ALLOWED_ORIGINS.`));
57
+ }
58
+ });
59
+ if (frame === early)
60
+ frame.contentWindow?.postMessage({ type: 'bbx:connect' }, origin); // it may already be listening
61
+ else
62
+ (document.body ?? document.documentElement).append(frame);
63
+ });
64
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @jeevanand/agent-browserbox-runtime/client: everything an app may use from
3
+ * the runtime besides the SDK. A full kernel client for the SDK's kernel
4
+ * channel (box.kernelPort()), and the kernel's types and small helpers an app
5
+ * UI needs. The protocol is versioned with the runtime: use the client of the
6
+ * runtime version you run.
7
+ */
8
+ export { RemoteKernel } from './remote-kernel';
9
+ export type { KernelLink } from './connect';
10
+ export { Peer, type Handlers } from '../rpc/peer';
11
+ export type { Kernel, FsApi, MountInfo, ProcsApi, SecretsApi, SettingsApi, ShellHandle, ShellIo, ShellsApi } from '../kernel/api';
12
+ export type { Capability, PermDecision, PermMode, PermRequest, Prompter } from '../kernel/perms';
13
+ export type { Proc, ProcKind, ProcState, SpawnOptions } from '../kernel/proc';
14
+ export type { KernelEvents, KernelLogLine, LockState, Notice } from '../kernel/types';
15
+ export { createProfile, DEFAULT_PROFILE, deleteProfile, getProfile, lastProfile, listProfiles, setLastProfile, updateProfile, type Profile } from '../kernel/profiles';
16
+ export type { Stat } from '../kernel/vfs/types';
17
+ export type { DevApi, DevInfo, DevLog, DevLogLevel, DevPage, DevStartOptions, WireRequest, WireResponse } from '../kernel/dev/types';
18
+ export type { PlatformCap } from '../kernel/caps';
19
+ export { basename, dirname, extname, isInside, join, normalize, resolve } from '../kernel/vfs/path';
20
+ export { AGENT_HOME, HOME } from '../kernel/paths';
21
+ export * from '../kernel/filetypes';
22
+ export * from '../kernel/format';
23
+ export { C, plainText, stripAnsi } from '../shell/ansi';
24
+ export { embeddable } from '../sandbox/isolation';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @jeevanand/agent-browserbox-runtime/client: everything an app may use from
3
+ * the runtime besides the SDK. A full kernel client for the SDK's kernel
4
+ * channel (box.kernelPort()), and the kernel's types and small helpers an app
5
+ * UI needs. The protocol is versioned with the runtime: use the client of the
6
+ * runtime version you run.
7
+ */
8
+ export { RemoteKernel } from './remote-kernel';
9
+ export { Peer } from '../rpc/peer';
10
+ export { createProfile, DEFAULT_PROFILE, deleteProfile, getProfile, lastProfile, listProfiles, setLastProfile, updateProfile } from '../kernel/profiles';
11
+ // Small helpers: paths, file kinds, formatting, terminal text, frames.
12
+ export { basename, dirname, extname, isInside, join, normalize, resolve } from '../kernel/vfs/path';
13
+ export { AGENT_HOME, HOME } from '../kernel/paths';
14
+ export * from '../kernel/filetypes';
15
+ export * from '../kernel/format';
16
+ export { C, plainText, stripAnsi } from '../shell/ansi';
17
+ export { embeddable } from '../sandbox/isolation';
@@ -0,0 +1,53 @@
1
+ import type { DevApi } from '../kernel/dev/types';
2
+ import type { FsApi, Kernel, ProcsApi, SecretsApi, ShellsApi } from '../kernel/api';
3
+ import { Bus } from '../kernel/bus';
4
+ import { type PlatformCap } from '../kernel/caps';
5
+ import { KCore } from '../kernel/kcore';
6
+ import { Permissions } from '../kernel/perms';
7
+ import { Settings } from '../kernel/settings';
8
+ import type { KernelEvents, KernelLogLine, Notice } from '../kernel/types';
9
+ import { Peer, type Handlers } from '../rpc/peer';
10
+ import type { KernelLink } from './connect';
11
+ /**
12
+ * A window's handle on the kernel. Read-mostly state (settings, the process
13
+ * table, mounts) is mirrored locally so UI code can read it synchronously;
14
+ * everything else is an RPC to the kernel worker. It implements the same
15
+ * `Kernel` interface as the real kernel, so apps cannot tell the difference.
16
+ */
17
+ export declare class RemoteKernel implements Kernel {
18
+ #private;
19
+ version: string;
20
+ rootKind: 'opfs' | 'memory';
21
+ /** False when this window had to start a private kernel. */
22
+ shared: boolean;
23
+ readonly bootStart = 0;
24
+ readonly bootMarks: Array<{
25
+ name: string;
26
+ at: number;
27
+ }>;
28
+ readonly bus: Bus<KernelEvents>;
29
+ readonly settings: Settings;
30
+ readonly perms: Permissions;
31
+ /** Not loaded here: windows use its JS fallbacks; the WASM core runs in the kernel. */
32
+ readonly kcore: KCore;
33
+ readonly caps: PlatformCap[];
34
+ readonly ready: Promise<void>;
35
+ /** The kernel log as of connecting, kept current by `kmsg` events. */
36
+ readonly kernelLog: KernelLogLine[];
37
+ constructor(link: Promise<KernelLink>, role?: 'ui' | 'sdk' | 'host');
38
+ /** Calls a kernel method once connected. */
39
+ call<T = unknown>(method: string, ...args: unknown[]): Promise<T>;
40
+ /** Lets the kernel call into this window (used by the sandbox host). */
41
+ handle(handlers: Handlers): Promise<Peer>;
42
+ readonly procs: ProcsApi;
43
+ readonly fs: FsApi;
44
+ readonly secrets: SecretsApi;
45
+ readonly dev: DevApi;
46
+ readonly shells: ShellsApi;
47
+ mark(name: string): void;
48
+ hasCap(id: string): boolean;
49
+ notify(notice: Notice | string): void;
50
+ openApp(id: string, args?: Record<string, unknown>): void;
51
+ /** Shows the folder picker here (it needs a window) and hands the folder to the kernel. */
52
+ mountNativeFolder(): Promise<string>;
53
+ }