@jutge.org/toolkit 4.4.45 → 4.4.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/prompts/io/creators/create-solution.tpl.txt +2 -0
- package/assets/prompts/io/proglangs/cc.md +3 -1
- package/assets/prompts/io/proglangs/py.md +6 -0
- package/dist/index.js +4 -4
- package/docs/reference.md +1 -1
- package/package.json +1 -1
- package/toolkit/about.ts +1 -1
- package/toolkit/index.ts +1 -1
|
@@ -10,6 +10,8 @@ Take these instructions into account:
|
|
|
10
10
|
|
|
11
11
|
- The code must be well written and easy to understand to novices. It cannot use advanced constructs.
|
|
12
12
|
|
|
13
|
+
- Never overoptimize.
|
|
14
|
+
|
|
13
15
|
- The code does not have to check the preconditions stated in the problem statement.
|
|
14
16
|
|
|
15
17
|
- Do not use any non-standard libraries.
|
|
@@ -4,4 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
- Add a `using namespace std;` declaration after the include section and do not use `std::` prefixes.
|
|
6
6
|
|
|
7
|
-
- Avoid the use of long long
|
|
7
|
+
- Avoid the use of `long long int` and use `int` instead.
|
|
8
|
+
|
|
9
|
+
- Avoid using `break`, `continue` and exceptions.
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
- Use type hints for function definitions. Do not use old-style type hints such as `List[int]` with `List` imported from `typing`, but use modern syntax such as `list[int]`.
|
|
6
6
|
|
|
7
|
+
- Use `type` keyword or `TypeAlias` with a suitable semantic name rather than repeating raw complex types. For instance, use `type Temperatures = list[float]` instead of `list[float]`.
|
|
8
|
+
|
|
9
|
+
- Avoid using `break`, `continue` and exceptions.
|
|
10
|
+
|
|
7
11
|
- Ensure that the generated Python3 code follows best practices, including proper indentation, use of functions, use of docstrings, and adherence to PEP 8 style guidelines.
|
|
8
12
|
|
|
9
13
|
# Very important
|
|
@@ -41,4 +45,6 @@ for x in tokens(int): # iterates over all integers in the input
|
|
|
41
45
|
print(s) # prints the sum of all the integers in the input
|
|
42
46
|
```
|
|
43
47
|
|
|
48
|
+
Priorize `tokens(type)` over `scan(type)` when possible.
|
|
49
|
+
|
|
44
50
|
In yogi functions, `type` can be `int`, `float`, or `str`.
|
package/dist/index.js
CHANGED
|
@@ -583,7 +583,7 @@ ${q}
|
|
|
583
583
|
</html>
|
|
584
584
|
`;async function sG6(q){l3(T8.parse(q));let $=await cG6.parse(q),w=eG6($),f=LG6(mG6(),`jutge-markdown-${$q()}.html`);await SG6(f,w,"utf8")}function _A6(q){let $=mZ_.default.stringify(q,null,4).trim();l3(Mx.highlight($,{language:"yaml",theme:{string:y_.white}}))}function qA6(q){let $=JSON.stringify(q,null,4);l3(Mx.highlight($,{language:"json"}))}async function $A6(q,$,w){}function dZ_(q,$){if($)return zq($,"file://"+SZ_(q,$));else return zq(q,"file://"+SZ_(q))}function wA6(q,$){return zq($,q)}function fA6(q){l3(y_.blue(q),!1)}function KA6(){process.stdout.write(y_.green(` \u2713
|
|
585
585
|
`))}function zA6(){process.stdout.write(y_.red(` \u2717
|
|
586
|
-
`))}var u={getIndentationLevel:LZ_,getIndentationLevelAsString:dG6,sectionStart:cZ_,sectionEnd:xZ_,section:rG6,title:pG6,command:iG6,directory:nG6,url:aG6,link:BG6,warning:FG6,error:oG6,gray:tG6,success:UG6,action:QG6,print:l3,markdown:sG6,yaml:_A6,json:qA6,image:$A6,hyperlink:dZ_,weblink:wA6,tryTo:fA6,trySuccess:KA6,tryFailure:zA6};var r3=qS.parse(await OX(PA6(H8(),"package.json")));async function DA6(){return await a6(),r3.version}async function YA6(){return(await(await fetch(`https://registry.npmjs.org/${r3.name}/latest`)).json()).version}async function rZ_(){let q=await DA6(),$=await YA6();if(hx.default.eq(q,$))u.success(`You already have the latest version (${q})`);else if(hx.default.gt(q,$))u.success(`You have a newer version (${q}) than the latest published version (${$})`);else if(u.action(`Upgrading from version ${q} to ${$}`),lZ_(`bun install --global ${r3.name}@latest`,{stdio:"inherit"}),u.success(`Successfully upgraded to version ${$}`),u.print(),await G3({message:"Install shell completions (Bash, Zsh, Fish, PowerShell) now?",default:!0}))lZ_("jtk completion install",{stdio:"inherit"});else u.print("To install or update shell completions later, run:"),u.print(" jtk completion install")}var iZ_=new G6("about").description("Get information about jutge-toolkit").action(async()=>{await a6(),u.print(y_.bold(`jutge-toolkit ${r3.version}`)),u.print(r3.description),u.print(""),u.url(r3.homepage),u.print(""),u.print("Author:"),pZ_(r3.author),u.print(""),u.print("Contributors:");for(let q of r3.contributors)pZ_(q);u.print(""),u.print("Documentation:"),u.url("https://github.com/jutge-org/
|
|
586
|
+
`))}var u={getIndentationLevel:LZ_,getIndentationLevelAsString:dG6,sectionStart:cZ_,sectionEnd:xZ_,section:rG6,title:pG6,command:iG6,directory:nG6,url:aG6,link:BG6,warning:FG6,error:oG6,gray:tG6,success:UG6,action:QG6,print:l3,markdown:sG6,yaml:_A6,json:qA6,image:$A6,hyperlink:dZ_,weblink:wA6,tryTo:fA6,trySuccess:KA6,tryFailure:zA6};var r3=qS.parse(await OX(PA6(H8(),"package.json")));async function DA6(){return await a6(),r3.version}async function YA6(){return(await(await fetch(`https://registry.npmjs.org/${r3.name}/latest`)).json()).version}async function rZ_(){let q=await DA6(),$=await YA6();if(hx.default.eq(q,$))u.success(`You already have the latest version (${q})`);else if(hx.default.gt(q,$))u.success(`You have a newer version (${q}) than the latest published version (${$})`);else if(u.action(`Upgrading from version ${q} to ${$}`),lZ_(`bun install --global ${r3.name}@latest`,{stdio:"inherit"}),u.success(`Successfully upgraded to version ${$}`),u.print(),await G3({message:"Install shell completions (Bash, Zsh, Fish, PowerShell) now?",default:!0}))lZ_("jtk completion install",{stdio:"inherit"});else u.print("To install or update shell completions later, run:"),u.print(" jtk completion install")}var iZ_=new G6("about").description("Get information about jutge-toolkit").action(async()=>{await a6(),u.print(y_.bold(`jutge-toolkit ${r3.version}`)),u.print(r3.description),u.print(""),u.url(r3.homepage),u.print(""),u.print("Author:"),pZ_(r3.author),u.print(""),u.print("Contributors:");for(let q of r3.contributors)pZ_(q);u.print(""),u.print("Documentation:"),u.url("https://github.com/jutge-org/jutge-toolkit/tree/main/docs")});function pZ_(q){let $=" - ";if(typeof q==="string")$+=q;else{if($+=q.name,q.email)$+=` <${u.link("mailto://"+q.email,q.email)}>`;if(q.url)$+=` (${u.link(q.url)})`}u.print($)}var jk=z6(Jk(),1);import{cp as Jq,exists as qA,glob as bd,mkdir as Xk,rename as sE6,rm as _g6}from"fs/promises";import*as wW_ from"fs";import*as fW_ from"path";var oN6=new TextDecoder,S8=(q,$=0,w=q.length)=>oN6.decode(q.slice($,w)),HD=(q,$=0,w=q.length)=>q.slice($,w).reduce((f,K)=>f+`0${K.toString(16)}`.slice(-2),""),x5=(q,$)=>new DataView(q.buffer,q.byteOffset+$),UO_=(q,$=0)=>x5(q,$).getInt16(0,!0),mG=(q,$=0)=>x5(q,$).getUint16(0,!1),d1=(q,$=0)=>x5(q,$).getUint16(0,!0),QO_=(q,$=0)=>{let w=x5(q,$);return w.getUint16(0,!0)+(w.getUint8(2)<<16)},UN6=(q,$=0)=>x5(q,$).getInt32(0,!0),J3=(q,$=0)=>x5(q,$).getUint32(0,!1),Ff=(q,$=0)=>x5(q,$).getUint32(0,!0),jd=(q,$,w)=>x5(q,$).getBigUint64(0,!w),QN6={readUInt16BE:mG,readUInt16LE:d1,readUInt32BE:J3,readUInt32LE:Ff};function x1(q,$,w=0,f=!1){let z=`readUInt${$}${f?"BE":"LE"}`;return QN6[z](q,w)}function tN6(q,$){if(q.length-$<4)return;let w=J3(q,$);if(q.length-$<w)return;return{name:S8(q,4+$,8+$),offset:$,size:w}}function eq(q,$,w){while(w<q.length){let f=tN6(q,w);if(!f)break;if(f.name===$)return f;w+=f.size>0?f.size:8}}var eN6={validate:(q)=>S8(q,0,2)==="BM",calculate:(q)=>({height:Math.abs(UN6(q,22)),width:Ff(q,18)})},sN6=1,_h6=6,qh6=16;function tO_(q,$){let w=q[$];return w===0?256:w}function eO_(q,$){let w=_h6+$*qh6;return{height:tO_(q,w+1),width:tO_(q,w)}}var KW_={validate(q){let $=d1(q,0),w=d1(q,4);if($!==0||w===0)return!1;return d1(q,2)===sN6},calculate(q){let $=d1(q,4),w=eO_(q,0);if($===1)return w;let f=[];for(let K=0;K<$;K+=1)f.push(eO_(q,K));return{width:w.width,height:w.height,images:f}}},$h6=2,wh6={validate(q){let $=d1(q,0),w=d1(q,4);if($!==0||w===0)return!1;return d1(q,2)===$h6},calculate:(q)=>KW_.calculate(q)},fh6={validate:(q)=>Ff(q,0)===542327876,calculate:(q)=>({height:Ff(q,12),width:Ff(q,16)})},Kh6=/^GIF8[79]a/,zh6={validate:(q)=>Kh6.test(S8(q,0,6)),calculate:(q)=>({height:d1(q,8),width:d1(q,6)})},Ph6={avif:"avif",mif1:"heif",msf1:"heif",heic:"heic",heix:"heic",hevc:"heic",hevx:"heic"},Dh6={validate(q){if(S8(q,4,8)!=="ftyp")return!1;let w=eq(q,"ftyp",0);if(!w)return!1;return S8(q,w.offset+8,w.offset+12)in Ph6},calculate(q){let $=eq(q,"meta",0),w=$&&eq(q,"iprp",$.offset+12),f=w&&eq(q,"ipco",w.offset+8);if(!f)throw TypeError("Invalid HEIF, no ipco box found");let K=S8(q,8,12),z=[],P=f.offset+8;while(P<f.offset+f.size){let D=eq(q,"ispe",P);if(!D)break;let Y=J3(q,D.offset+12),J=J3(q,D.offset+16),Z=eq(q,"clap",P),k=Y,W=J;if(Z&&Z.offset<f.offset+f.size){let v=J3(q,Z.offset+12);k=Y-v}z.push({height:W,width:k}),P=D.offset+D.size}if(z.length===0)throw TypeError("Invalid HEIF, no sizes found");return{width:z[0].width,height:z[0].height,type:K,...z.length>1?{images:z}:{}}}},Yh6=8,Jh6=4,Hh6=4,Zh6={ICON:32,"ICN#":32,"icm#":16,icm4:16,icm8:16,"ics#":16,ics4:16,ics8:16,is32:16,s8mk:16,icp4:16,icl4:32,icl8:32,il32:32,l8mk:32,icp5:32,ic11:32,ich4:48,ich8:48,ih32:48,h8mk:48,icp6:64,ic12:32,it32:128,t8mk:128,ic07:128,ic08:256,ic13:256,ic09:512,ic14:512,ic10:1024};function kh6(q,$){let w=$+Hh6;return[S8(q,$,w),J3(q,w)]}function Oh6(q){let $=Zh6[q];return{width:$,height:$,type:q}}var Wh6={validate:(q)=>S8(q,0,4)==="icns",calculate(q){let $=q.length,w=J3(q,Jh6),f=Yh6,K=[];while(f<w&&f<$){let z=kh6(q,f),P=Oh6(z[0]);K.push(P),f+=z[1]}if(K.length===0)throw TypeError("Invalid ICNS, no sizes found");return{width:K[0].width,height:K[0].height,...K.length>1?{images:K}:{}}}},vh6={validate:(q)=>J3(q,0)===4283432785,calculate:(q)=>({height:J3(q,12),width:J3(q,8)})},Th6={validate(q){if(S8(q,4,8)!=="jP ")return!1;let w=eq(q,"ftyp",0);if(!w)return!1;return S8(q,w.offset+8,w.offset+12)==="jp2 "},calculate(q){let $=eq(q,"jp2h",0),w=$&&eq(q,"ihdr",$.offset+8);if(w)return{height:J3(q,w.offset+8),width:J3(q,w.offset+12)};throw TypeError("Unsupported JPEG 2000 format")}},Xh6="45786966",jh6=2,Td=6,Gh6=2,Ah6="4d4d",uh6="4949",sO_=12,Ch6=2;function Vh6(q){return HD(q,2,6)===Xh6}function Mh6(q,$){return{height:mG(q,$),width:mG(q,$+2)}}function Nh6(q,$){let f=Td+8,K=x1(q,16,f,$);for(let z=0;z<K;z++){let P=f+Ch6+z*sO_,D=P+sO_;if(P>q.length)return;let Y=q.slice(P,D);if(x1(Y,16,0,$)===274){if(x1(Y,16,2,$)!==3)return;if(x1(Y,32,4,$)!==1)return;return x1(Y,16,8,$)}}}function hh6(q,$){let w=q.slice(jh6,$),f=HD(w,Td,Td+Gh6),K=f===Ah6;if(K||f===uh6)return Nh6(w,K)}function Eh6(q,$){if($>q.length)throw TypeError("Corrupt JPG, exceeded buffer limits")}var gh6={validate:(q)=>HD(q,0,2)==="ffd8",calculate(q){let $=q.slice(4),w,f;while($.length){let K=mG($,0);if(Eh6($,K),$[K]!==255){$=$.slice(1);continue}if(Vh6($))w=hh6($,K);if(f=$[K+1],f===192||f===193||f===194){let z=Mh6($,K+5);if(!w)return z;return{height:z.height,orientation:w,width:z.width}}$=$.slice(K+2)}throw TypeError("Invalid JPG, no size found")}},Rh6=class{constructor(q,$){this.input=q,this.endianness=$,this.byteOffset=2,this.bitOffset=0}getBits(q=1){let $=0,w=0;while(w<q){if(this.byteOffset>=this.input.length)throw Error("Reached end of input");let f=this.input[this.byteOffset],K=8-this.bitOffset,z=Math.min(q-w,K);if(this.endianness==="little-endian"){let P=(1<<z)-1,D=f>>this.bitOffset&P;$|=D<<w}else{let P=(1<<z)-1<<8-this.bitOffset-z,D=(f&P)>>8-this.bitOffset-z;$=$<<z|D}if(w+=z,this.bitOffset+=z,this.bitOffset===8)this.byteOffset++,this.bitOffset=0}return $}};function zW_(q,$){if($)return 8*(1+q.getBits(5));let w=q.getBits(2),f=[9,13,18,30][w];return 1+q.getBits(f)}function bh6(q,$,w,f){if($&&w===0)return 8*(1+q.getBits(5));if(w===0)return zW_(q,!1);return Math.floor(f*[1,1.2,1.3333333333333333,1.5,1.7777777777777777,1.25,2][w-1])}var PW_={validate:(q)=>{return HD(q,0,2)==="ff0a"},calculate(q){let $=new Rh6(q,"little-endian"),w=$.getBits(1)===1,f=zW_($,w),K=$.getBits(3);return{width:bh6($,w,K,f),height:f}}};function Ih6(q){let $=eq(q,"jxlc",0);if($)return q.slice($.offset+8,$.offset+$.size);let w=yh6(q);if(w.length>0)return Sh6(w);return}function yh6(q){let $=[],w=0;while(w<q.length){let f=eq(q,"jxlp",w);if(!f)break;$.push(q.slice(f.offset+12,f.offset+f.size)),w=f.offset+f.size}return $}function Sh6(q){let $=q.reduce((K,z)=>K+z.length,0),w=new Uint8Array($),f=0;for(let K of q)w.set(K,f),f+=K.length;return w}var mh6={validate:(q)=>{if(S8(q,4,8)!=="JXL ")return!1;let w=eq(q,"ftyp",0);if(!w)return!1;return S8(q,w.offset+8,w.offset+12)==="jxl "},calculate(q){let $=Ih6(q);if($)return PW_.calculate($);throw Error("No codestream found in JXL container")}},Lh6={validate:(q)=>{let $=S8(q,1,7);return["KTX 11","KTX 20"].includes($)},calculate:(q)=>{let $=q[5]===49?"ktx":"ktx2",w=$==="ktx"?36:20;return{height:Ff(q,w+4),width:Ff(q,w),type:$}}},ch6=`PNG\r
|
|
587
587
|
\x1A
|
|
588
588
|
`,xh6="IHDR",_W_="CgBI",dh6={validate(q){if(ch6===S8(q,1,8)){let $=S8(q,12,16);if($===_W_)$=S8(q,28,32);if($!==xh6)throw TypeError("Invalid PNG");return!0}return!1},calculate(q){if(S8(q,12,16)===_W_)return{height:J3(q,36),width:J3(q,32)};return{height:J3(q,20),width:J3(q,16)}}},qW_={P1:"pbm/ascii",P2:"pgm/ascii",P3:"ppm/ascii",P4:"pbm",P5:"pgm",P6:"ppm",P7:"pam",PF:"pfm"},$W_={default:(q)=>{let $=[];while(q.length>0){let w=q.shift();if(w[0]==="#")continue;$=w.split(" ");break}if($.length===2)return{height:Number.parseInt($[1],10),width:Number.parseInt($[0],10)};throw TypeError("Invalid PNM")},pam:(q)=>{let $={};while(q.length>0){let w=q.shift();if(w.length>16||w.charCodeAt(0)>128)continue;let[f,K]=w.split(" ");if(f&&K)$[f.toLowerCase()]=Number.parseInt(K,10);if($.height&&$.width)break}if($.height&&$.width)return{height:$.height,width:$.width};throw TypeError("Invalid PAM")}},lh6={validate:(q)=>(S8(q,0,2)in qW_),calculate(q){let $=S8(q,0,2),w=qW_[$],f=S8(q,3).split(/[\r\n]+/);return($W_[w]||$W_.default)(f)}},rh6={validate:(q)=>S8(q,0,4)==="8BPS",calculate:(q)=>({height:J3(q,14),width:J3(q,18)})},DW_=/<svg\s([^>"']|"[^"]*"|'[^']*')*>/,SG={height:/\sheight=(['"])([^%]+?)\1/,root:DW_,viewbox:/\sviewBox=(['"])(.+?)\1/i,width:/\swidth=(['"])([^%]+?)\1/},vd=2.54,YW_={in:96,cm:96/vd,em:16,ex:8,m:96/vd*100,mm:96/vd/10,pc:0.1111111111111111,pt:1.3333333333333333,px:1},ph6=new RegExp(`^([0-9.]+(?:e\\d+)?)(${Object.keys(YW_).join("|")})?$`);function LG(q){let $=ph6.exec(q);if(!$)return;return Math.round(Number($[1])*(YW_[$[2]]||1))}function ih6(q){let $=q.split(" ");return{height:LG($[3]),width:LG($[2])}}function nh6(q){let $=q.match(SG.width),w=q.match(SG.height),f=q.match(SG.viewbox);return{height:w&&LG(w[2]),viewbox:f&&ih6(f[2]),width:$&&LG($[2])}}function ah6(q){return{height:q.height,width:q.width}}function Bh6(q,$){let w=$.width/$.height;if(q.width)return{height:Math.floor(q.width/w),width:q.width};if(q.height)return{height:q.height,width:Math.floor(q.height*w)};return{height:$.height,width:$.width}}var Fh6={validate:(q)=>DW_.test(S8(q,0,1000)),calculate(q){let $=S8(q).match(SG.root);if($){let w=nh6($[0]);if(w.width&&w.height)return ah6(w);if(w.viewbox)return Bh6(w,w.viewbox)}throw TypeError("Invalid SVG")}},oh6={validate(q){return d1(q,0)===0&&d1(q,4)===0},calculate(q){return{height:d1(q,14),width:d1(q,12)}}},l1={TAG:{WIDTH:256,HEIGHT:257,COMPRESSION:259},TYPE:{SHORT:3,LONG:4,LONG8:16},ENTRY_SIZE:{STANDARD:12,BIG:20},COUNT_SIZE:{STANDARD:2,BIG:8}};function Uh6(q,{isBigEndian:$,isBigTiff:w}){let f=w?Number(jd(q,8,$)):x1(q,32,4,$),K=w?l1.COUNT_SIZE.BIG:l1.COUNT_SIZE.STANDARD;return q.slice(f+K)}function Qh6(q,$,w,f){switch($){case l1.TYPE.SHORT:return x1(q,16,w,f);case l1.TYPE.LONG:return x1(q,32,w,f);case l1.TYPE.LONG8:{let K=Number(jd(q,w,f));if(K>Number.MAX_SAFE_INTEGER)throw TypeError("Value too large");return K}default:return 0}}function th6(q,$){let w=$?l1.ENTRY_SIZE.BIG:l1.ENTRY_SIZE.STANDARD;if(q.length>w)return q.slice(w)}function eh6(q,{isBigEndian:$,isBigTiff:w}){let f={},K=q;while(K?.length){let z=x1(K,16,0,$),P=x1(K,16,2,$),D=w?Number(jd(K,4,$)):x1(K,32,4,$);if(z===0)break;if(D===1&&(P===l1.TYPE.SHORT||P===l1.TYPE.LONG||w&&P===l1.TYPE.LONG8)){let Y=w?12:8;f[z]=Qh6(K,P,Y,$)}K=th6(K,w)}return f}function sh6(q){let $=S8(q,0,2),w=x1(q,16,2,$==="MM");return{isBigEndian:$==="MM",isBigTiff:w===43}}function _E6(q,$){let w=x1(q,16,4,$),f=x1(q,16,6,$);if(w!==8||f!==0)throw TypeError("Invalid BigTIFF header")}var qE6=new Set(["49492a00","4d4d002a","49492b00","4d4d002b"]),$E6={validate:(q)=>{let $=HD(q,0,4);return qE6.has($)},calculate(q){let $=sh6(q);if($.isBigTiff)_E6(q,$.isBigEndian);let w=Uh6(q,$),f=eh6(w,$),K={height:f[l1.TAG.HEIGHT],width:f[l1.TAG.WIDTH],type:$.isBigTiff?"bigtiff":"tiff"};if(f[l1.TAG.COMPRESSION])K.compression=f[l1.TAG.COMPRESSION];if(!K.width||!K.height)throw TypeError("Invalid Tiff. Missing tags");return K}};function wE6(q){return{height:1+QO_(q,7),width:1+QO_(q,4)}}function fE6(q){return{height:1+((q[4]&15)<<10|q[3]<<2|(q[2]&192)>>6),width:1+((q[2]&63)<<8|q[1])}}function KE6(q){return{height:UO_(q,8)&16383,width:UO_(q,6)&16383}}var zE6={validate(q){let $=S8(q,0,4)==="RIFF",w=S8(q,8,12)==="WEBP",f=S8(q,12,15)==="VP8";return $&&w&&f},calculate(q){let $=S8(q,12,16),w=q.slice(20,30);if($==="VP8X"){let K=w[0],z=(K&192)===0,P=(K&1)===0;if(z&&P)return wE6(w);throw TypeError("Invalid WebP")}if($==="VP8 "&&w[0]!==47)return KE6(w);let f=HD(w,3,6);if($==="VP8L"&&f!=="9d012a")return fE6(w);throw TypeError("Invalid WebP")}},cG=new Map([["bmp",eN6],["cur",wh6],["dds",fh6],["gif",zh6],["heif",Dh6],["icns",Wh6],["ico",KW_],["j2c",vh6],["jp2",Th6],["jpg",gh6],["jxl",mh6],["jxl-stream",PW_],["ktx",Lh6],["png",dh6],["pnm",lh6],["psd",rh6],["svg",Fh6],["tga",oh6],["tiff",$E6],["webp",zE6]]),PE6=Array.from(cG.keys()),DE6=new Map([[0,"heif"],[56,"psd"],[66,"bmp"],[68,"dds"],[71,"gif"],[73,"tiff"],[77,"tiff"],[82,"webp"],[105,"icns"],[137,"png"],[255,"jpg"]]);function YE6(q){let $=q[0],w=DE6.get($);if(w&&cG.get(w).validate(q))return w;return PE6.find((f)=>cG.get(f).validate(q))}var JE6={disabledTypes:[]};function HE6(q){let $=YE6(q);if(typeof $<"u"){if(JE6.disabledTypes.indexOf($)>-1)throw TypeError(`disabled file type: ${$}`);let w=cG.get($).calculate(q);if(w!==void 0){if(w.type=w.type??$,w.images&&w.images.length>1){let f=w.images.reduce((K,z)=>{return z.width*z.height>K.width*K.height?z:K},w.images[0]);w.width=f.width,w.height=f.height}return w}}throw TypeError(`unsupported file type: ${$}`)}var ZE6=524288,Xd=[],kE6=100;var JW_=async()=>{let $=Xd.splice(0,kE6).map(async({filePath:w,resolve:f,reject:K})=>{let z;try{z=await wW_.promises.open(fW_.resolve(w),"r")}catch(P){return K(P)}try{let{size:P}=await z.stat();if(P<=0)throw Error("Empty file");let D=Math.min(P,ZE6),Y=new Uint8Array(D);await z.read(Y,0,D,0),f(HE6(Y))}catch(P){K(P)}finally{await z.close()}});if(await Promise.allSettled($),Xd.length)setTimeout(JW_,100)},xG=async(q)=>new Promise(($,w)=>{Xd.push({filePath:q,resolve:$,reject:w}),JW_()});import{basename as qg6,dirname as $g6,join as Z6,normalize as wg6,resolve as Hv_}from"path";var OE6=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],WE6=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],vE6=["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],TE6=["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],HW_=(q,$,w)=>{let f=q;if(typeof $==="string"||Array.isArray($))f=q.toLocaleString($,w);else if($===!0||w!==void 0)f=q.toLocaleString(void 0,w);return f},kW_=(q)=>{if(typeof q==="number")return Math.log10(q);let $=q.toString(10);return $.length+Math.log10(`0.${$.slice(0,15)}`)},XE6=(q)=>{if(typeof q==="number")return Math.log(q);return kW_(q)*Math.log(10)},jE6=(q,$)=>{if(typeof q==="number")return q/$;let w=q/BigInt($),f=q%BigInt($);return Number(w)+Number(f)/$},ZW_=(q,$)=>{if($===void 0)return q;if(typeof $!=="number"||!Number.isSafeInteger($)||$<0)throw TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof $}: ${$}`);if($===0)return q;return q.length<$?q.padStart($," "):q},GE6=(q)=>{let{minimumFractionDigits:$,maximumFractionDigits:w}=q;if($===void 0&&w===void 0)return;return{...$!==void 0&&{minimumFractionDigits:$},...w!==void 0&&{maximumFractionDigits:w},roundingMode:"trunc"}};function ZD(q,$){if(typeof q!=="bigint"&&!Number.isFinite(q))throw TypeError(`Expected a finite number, got ${typeof q}: ${q}`);$={bits:!1,binary:!1,space:!0,nonBreakingSpace:!1,...$};let w=$.bits?$.binary?TE6:vE6:$.binary?WE6:OE6,f=$.space?$.nonBreakingSpace?"\xA0":" ":"",K=typeof q==="number"?q===0:q===0n;if($.signed&&K){let J=` 0${f}${w[0]}`;return ZW_(J,$.fixedWidth)}let z=q<0,P=z?"-":$.signed?"+":"";if(z)q=-q;let D=GE6($),Y;if(q<1){let J=HW_(q,$.locale,D);Y=P+J+f+w[0]}else{let J=Math.min(Math.floor($.binary?XE6(q)/Math.log(1024):kW_(q)/3),w.length-1);if(q=jE6(q,($.binary?1024:1000)**J),!D){let W=Math.max(3,Math.floor(q).toString().length);q=q.toPrecision(W)}let Z=HW_(Number(q),$.locale,D),k=w[J];Y=P+Z+f+k}return ZW_(Y,$.fixedWidth)}import{exists as AE6,rm as uE6}from"fs/promises";import{join as of,resolve as CE6}from"path";class N8{warning(){return""}async available(){return await this.version()!=="not found"}async info(){return{compiler_id:this.id(),name:this.name(),language:this.language(),version:await this.version(),flags1:this.flags1(),flags2:this.flags2(),extension:this.extension(),type:this.type(),warning:this.warning()}}async compileNormal(q,$,w){let f=`${w}.exe`;return await this.rmInDir($,f),u.command(`${this.tool()} ${this.flags1()} ${w} -o ${f}`),await p_({reject:!1,stderr:"inherit",stdout:"inherit",cwd:$})`${this.tool()} ${this.flags1().split(" ")} ${w} -o ${f}`,f}async compileWithMain(q,$,w){let f=`${w}.exe`;return u.command(`add main.${this.extension()} to ${w}`),await this.concatText($,[w,`main.${this.extension()}`],w),u.command(`${this.tool()} ${this.flags1()} ${w} -o ${f}`),await p_({reject:!1,stderr:"inherit",stdout:"inherit",cwd:$})`${this.tool()} ${this.flags1().split(" ")} ${w} -o ${f}`,f}async execute(q,$,w,f,K){let z=`${w}.exe`,P=CE6(of($,z));await this.rmInDir($,K);let D=await this.getInput($,f);u.command(`${P} < ${f} > ${K}`);let{exitCode:Y}=await p_({reject:!1,input:D,stdout:{file:of($,K)},stderr:"inherit",cwd:$})`${P}`;if(Y!==0)throw Error(`Execution failed for ${z} with exit code ${Y}`)}async getVersion(q,$){try{let{stdout:w}=await p_`${q.split(" ")}`;return w.split(`
|
|
589
589
|
`)[$]?.trim()||"Unknown version"}catch{return"not found"}}getInput(q,$){return j6(of(q,$))}rmInDir(q,$){return uE6(of(q,$),{force:!0})}existsInDir(q,$){return AE6(of(q,$))}async concatText(q,$,w,f=`
|
|
@@ -622,8 +622,8 @@ main = do
|
|
|
622
622
|
|
|
623
623
|
The actual configuration file is stored at ${dH()}`).action(()=>{r5.help()});r5.command("show").alias("list").description("Show configuration options").action(async()=>{let q=await xy();u.yaml(q)});r5.command("get <key>").description("Get the value of a configuration option").action((q)=>{if(!(q in z8))throw Error(`Configuration key ${q} does not exist`);console.log(z8[q])});r5.command("set <key> <value>").description("Set the value of a configuration option").action(async(q,$)=>{if(!(q in z8))throw Error(`Configuration key ${q} does not exist`);let w=b8_($),f=C$.parse({...z8,[q]:w});await lH(f),u.success(`Configuration key ${q} updated successfully`)});r5.command("edit").description("Open an editor (uses $EDITOR or $VISUAL) to modify the configuration options").action(async()=>{let q=md.default.stringify(z8,null,4);while(!0){let $=await M5({message:"Edit configuration",default:q,postfix:".yml",waitForUserInput:!1});try{let w=C$.parse(md.default.parse($));await lH(w),u.success("Configuration options updated successfully");return}catch(w){if(w instanceof d7)console.error(D5(w).toString());else console.error(w);if(!await G3({message:"Edit again?",default:!0})){u.warning("No changes made to the configuration options");return}q=$}}});r5.command("reset").description("Reset configuration to default values").option("-f, --force","force reset without confirmation",!1).action(async({force:q})=>{if(!q){if(!await G3({message:"Are you sure you want to reset the configuration to default values?",default:!1})){u.warning("Reset cancelled");return}}let $=C$.parse({});await lH($),u.success("Configuration reset to default values successfully")});sq();var Ld=z6(XD(),1);import{cp as Vg6,exists as bv_,glob as Iv_}from"fs/promises";import Ak from"path";var fA=Ak.join(H8(),"assets","problems");async function Mg6(q){let $=[],w=await Array.fromAsync(Iv_("*",{cwd:fA}));w.sort();for(let K of w){$.push(new S1(gd(K)));let z=await Array.fromAsync(Iv_("*.pbm",{cwd:Ak.join(fA,K)}));z.sort();for(let P of z)$.push({name:P,value:Ak.join(K,P)})}let f=void 0;while(!0){f=await x4({message:"Select a template to clone:",choices:$,default:f});let K=Ak.join(fA,f),z=await F8(K,"README.md"),P=Ld.default(K,{allFiles:!0,dirsFirst:!1});if(console.log(),await u.markdown(z),console.log(P),await G3({message:`Clone template ${f} to ${q}?`,default:!0}))return f}}async function yv_(q,$){if(await bv_(q))throw Error(`Directory ${q} already exists`);if(!q.endsWith(".pbm"))throw Error("The output directory must end with .pbm");if(!$)$=await Mg6(q);let w=Ak.join(fA,$);if(!await bv_(w))throw Error(`Template ${$} does not exist`);await Vg6(w,q,{recursive:!0}),await XP(q),u.success(`Created problem ${u.hyperlink(q)} from template ${$}`);let f=Ld.default(q,{allFiles:!0,dirsFirst:!1});console.log(f)}var Sv_=new G6("clone").description("Clone a template into a new problem").argument("[template]","template to use (empty to interactive selection)").option("-d, --directory <path>","output directory","new-problem.pbm").action(async(q,{directory:$})=>{await yv_($,q)});var GT_=z6(k0_(),1);import{cp as jT_,exists as FR6,mkdir as oR6,readdir as AT_,rm as UR6,stat as QR6}from"fs/promises";import sd from"process";import b0_ from"path";import{fileURLToPath as gR6}from"url";import RR6 from"child_process";import bR6,{constants as IR6}from"fs/promises";import{promisify as DR6}from"util";import YR6 from"child_process";import ad,{constants as G0_}from"fs/promises";import v0_ from"process";import $R6 from"os";import wR6 from"fs";import _R6 from"fs";import O0_ from"fs";var rd;function eg6(){try{return O0_.statSync("/.dockerenv"),!0}catch{return!1}}function sg6(){try{return O0_.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function pd(){if(rd===void 0)rd=eg6()||sg6();return rd}var id,qR6=()=>{try{return _R6.statSync("/run/.containerenv"),!0}catch{return!1}};function uD(){if(id===void 0)id=qR6()||pd();return id}var W0_=()=>{if(v0_.platform!=="linux")return!1;if($R6.release().toLowerCase().includes("microsoft")){if(uD())return!1;return!0}try{return wR6.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!uD():!1}catch{return!1}},H9=v0_.env.__IS_WSL_TEST__?W0_:W0_();import T0_ from"process";import{Buffer as fR6}from"buffer";import{promisify as KR6}from"util";import zR6 from"child_process";var PR6=KR6(zR6.execFile),nd=()=>`${T0_.env.SYSTEMROOT||T0_.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;var Hq=async(q,$={})=>{let{powerShellPath:w,...f}=$,K=Hq.encodeCommand(q);return PR6(w??nd(),[...Hq.argumentsPrefix,K],{encoding:"utf8",...f})};Hq.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];Hq.encodeCommand=(q)=>fR6.from(q,"utf16le").toString("base64");Hq.escapeArgument=(q)=>`'${String(q).replaceAll("'","''")}'`;function X0_(q){for(let $ of q.split(`
|
|
624
624
|
`)){if(/^\s*#/.test($))continue;let w=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec($);if(!w)continue;return w.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}var JR6=DR6(YR6.execFile),HR6=(()=>{let $;return async function(){if($)return $;let w="/etc/wsl.conf",f=!1;try{await ad.access(w,G0_.F_OK),f=!0}catch{}if(!f)return"/mnt/";let K=await ad.readFile(w,{encoding:"utf8"}),z=X0_(K);if(z===void 0)return"/mnt/";return $=z,$=$.endsWith("/")?$:`${$}/`,$}})(),ZR6=async()=>{return`${await HR6()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`},DA=H9?ZR6:nd,j0_,A0_=async()=>{return j0_??=(async()=>{try{let q=await DA();return await ad.access(q,G0_.X_OK),!0}catch{return!1}})(),j0_},u0_=async()=>{let q=await DA(),$=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:w}=await Hq($,{powerShellPath:q});return w.trim()},C0_=async(q)=>{if(/^[a-z]+:\/\//i.test(q))return q;try{let{stdout:$}=await JR6("wslpath",["-aw",q],{encoding:"utf8"});return $.trim()}catch{return q}};function _K(q,$,w){let f=(K)=>Object.defineProperty(q,$,{value:K,enumerable:!0,writable:!0});return Object.defineProperty(q,$,{configurable:!0,enumerable:!0,get(){let K=w();return f(K),K},set(K){f(K)}}),q}import{promisify as VR6}from"util";import Qd from"process";import{execFile as MR6}from"child_process";import{promisify as kR6}from"util";import OR6 from"process";import{execFile as WR6}from"child_process";var vR6=kR6(WR6);async function Bd(){if(OR6.platform!=="darwin")throw Error("macOS only");let{stdout:q}=await vR6("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),w=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(q)?.groups.id??"com.apple.Safari";if(w==="com.apple.safari")return"com.apple.Safari";return w}import TR6 from"process";import{promisify as XR6}from"util";import{execFile as jR6,execFileSync as WI8}from"child_process";var GR6=XR6(jR6);async function V0_(q,{humanReadableOutput:$=!0,signal:w}={}){if(TR6.platform!=="darwin")throw Error("macOS only");let f=$?[]:["-ss"],K={};if(w)K.signal=w;let{stdout:z}=await GR6("osascript",["-e",q,f],K);return z.trim()}async function Fd(q){return V0_(`tell application "Finder" to set app_path to application file id "${q}" as string
|
|
625
|
-
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as AR6}from"util";import{execFile as uR6}from"child_process";var CR6=AR6(uR6),M0_={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},YA=new Map(Object.entries(M0_));class od extends Error{}async function Ud(q=CR6){let{stdout:$}=await q("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),w=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec($);if(!w)throw new od(`Cannot find Windows browser in stdout: ${JSON.stringify($)}`);let{id:f}=w.groups,K=M0_[f];if(!K)throw new od(`Unknown browser ID: ${f}`);return K}var NR6=VR6(MR6),hR6=(q)=>q.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,($)=>$.toUpperCase());async function td(){if(Qd.platform==="darwin"){let q=await Bd();return{name:await Fd(q),id:q}}if(Qd.platform==="linux"){let{stdout:q}=await NR6("xdg-mime",["query","default","x-scheme-handler/http"]),$=q.trim();return{name:hR6($.replace(/.desktop$/,"").replace("-"," ")),id:$}}if(Qd.platform==="win32")return Ud();throw Error("Only macOS, Linux, and Windows are supported")}import ed from"process";var ER6=Boolean(ed.env.SSH_CONNECTION||ed.env.SSH_CLIENT||ed.env.SSH_TTY),N0_=ER6;var JA=Symbol("fallbackAttempt"),_l=import.meta.url?b0_.dirname(gR6(import.meta.url)):"",h0_=b0_.join(_l,"xdg-open"),{platform:CD,arch:E0_}=sd,g0_=async(q,$)=>{if(q.length===0)return;let w=[];for(let f of q)try{return await $(f)}catch(K){w.push(K)}throw AggregateError(w,"Failed to open in all supported apps")},HA=async(q)=>{q={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...q};let $=q[JA]===!0;if(delete q[JA],Array.isArray(q.app))return g0_(q.app,(J)=>HA({...q,app:J,[JA]:!0}));let{name:w,arguments:f=[]}=q.app??{};if(f=[...f],Array.isArray(w))return g0_(w,(J)=>HA({...q,app:{name:J,arguments:f},[JA]:!0}));if(w==="browser"||w==="browserPrivate"){let J={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},Z={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},k;if(H9){let W=await u0_();k=YA.get(W)??{}}else k=await td();if(k.id in J){let W=J[k.id.toLowerCase()];if(w==="browserPrivate"){if(W==="safari")throw Error("Safari doesn't support opening in private mode via command line");f.push(Z[W])}return HA({...q,app:{name:VD[W],arguments:f}})}throw Error(`${k.name} is not supported as a default browser`)}let K,z=[],P={},D=!1;if(H9&&!uD()&&!N0_&&!w)D=await A0_();if(CD==="darwin"){if(K="open",q.wait)z.push("--wait-apps");if(q.background)z.push("--background");if(q.newInstance)z.push("--new");if(w)z.push("-a",w)}else if(CD==="win32"||D){if(K=await DA(),z.push(...Hq.argumentsPrefix),!H9)P.windowsVerbatimArguments=!0;if(H9&&q.target)q.target=await C0_(q.target);let J=["$ProgressPreference = 'SilentlyContinue';","Start"];if(q.wait)J.push("-Wait");if(w){if(J.push(Hq.escapeArgument(w)),q.target)f.push(q.target)}else if(q.target)J.push(Hq.escapeArgument(q.target));if(f.length>0)f=f.map((Z)=>Hq.escapeArgument(Z)),J.push("-ArgumentList",f.join(","));if(q.target=Hq.encodeCommand(J.join(" ")),!q.wait)P.stdio="ignore"}else{if(w)K=w;else{let J=!_l||_l==="/",Z=!1;try{await bR6.access(h0_,IR6.X_OK),Z=!0}catch{}K=sd.versions.electron??(CD==="android"||J||!Z)?"xdg-open":h0_}if(f.length>0)z.push(...f);if(!q.wait)P.stdio="ignore",P.detached=!0}if(CD==="darwin"&&f.length>0)z.push("--args",...f);if(q.target)z.push(q.target);let Y=RR6.spawn(K,z,P);if(q.wait)return new Promise((J,Z)=>{Y.once("error",Z),Y.once("close",(k)=>{if(!q.allowNonzeroExitCode&&k!==0){Z(Error(`Exited with code ${k}`));return}J(Y)})});if($)return new Promise((J,Z)=>{Y.once("error",Z),Y.once("spawn",()=>{Y.once("close",(k)=>{if(Y.off("error",Z),k!==0){Z(Error(`Exited with code ${k}`));return}Y.unref(),J(Y)})})});return Y.unref(),new Promise((J,Z)=>{Y.once("error",Z),Y.once("spawn",()=>{Y.off("error",Z),J(Y)})})},yR6=(q,$)=>{if(typeof q!=="string")throw TypeError("Expected a `target`");return HA({...$,target:q})};function R0_(q){if(typeof q==="string"||Array.isArray(q))return q;let{[E0_]:$}=q;if(!$)throw Error(`${E0_} is not supported`);return $}function Ck({[CD]:q},{wsl:$}={}){if($&&H9)return R0_($);if(!q)throw Error(`${CD} is not supported`);return R0_(q)}var VD={browser:"browser",browserPrivate:"browserPrivate"};_K(VD,"chrome",()=>Ck({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));_K(VD,"brave",()=>Ck({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));_K(VD,"firefox",()=>Ck({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));_K(VD,"edge",()=>Ck({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));_K(VD,"safari",()=>Ck({darwin:"Safari"}));var MD=yR6;var uT_=z6(XD(),1);import{join as ql}from"path";import{exists as SR6}from"fs/promises";import{join as mR6}from"path";class ZA extends Error{message;name="UnauthorizedError";constructor(q="Unauthorized"){super(q);this.message=q}}class I0_ extends Error{message;name="InfoError";constructor(q){super(q);this.message=q}}class y0_ extends Error{message;name="NotFoundError";constructor(q){super(q);this.message=q}}class S0_ extends Error{message;name="InputError";constructor(q){super(q);this.message=q}}class m0_ extends Error{message;name="ProtocolError";constructor(q){super(q);this.message=q}}class qK{clientTTLs=new Map;useCache=!0;logCache=!1;cache=new Map;JUTGE_API_URL=process.env.JUTGE_API_URL||"https://api.jutge.org/api";headers={};meta=null;async execute(q,$,w=[]){let f=this.useCache&&this.clientTTLs.has(q)&&w.length===0;if(f){let A=JSON.stringify({func:q,input:$}),C=this.cache.get(A);if(C!==void 0){if(this.logCache)console.log("found");let N=this.clientTTLs.get(q);if(C.epoch+N*1000>new Date().valueOf()){if(this.logCache)console.log("used");return[C.output,C.ofiles]}else{if(this.logCache)console.log("expired");this.cache.delete(A)}}}if(this.logCache)console.log("fetch");let K=new FormData,z={func:q,input:$,meta:this.meta};K.append("data",JSON.stringify(z));for(let A in w)K.append(`file_${A}`,w[A]);let P=await fetch(this.JUTGE_API_URL,{method:"POST",body:K,headers:this.headers});if(P.headers.get("content-type")?.split(";")[0].toLowerCase()!=="multipart/form-data")throw new m0_("The content type is not multipart/form-data");let Y=await P.formData(),J=Y.get("data"),{output:Z,error:k,duration:W,operation_id:v,time:X}=JSON.parse(J);if(k)this.throwError(k,v);let j=[];for(let A of Y.keys()){let C=Y.get(A);if(C instanceof File)j.push({data:new Uint8Array(await C.arrayBuffer()),name:C.name,type:C.type})}if(f){if(this.logCache)console.log("saved");let A=JSON.stringify({func:q,input:$});this.cache.set(A,{output:Z,ofiles:j,epoch:new Date().valueOf()})}return[Z,j]}throwError(q,$){let w=q.message||"Unknown error";if(q.name==="UnauthorizedError")throw new ZA(w);else if(q.name==="InfoError")throw new I0_(w);else if(q.name==="NotFoundError")throw new y0_(w);else if(q.name==="InputError")throw new S0_(w);else throw Error(w)}async login({email:q,password:$}){let[w,f]=await this.execute("auth.login",{email:q,password:$});if(w.error)throw new ZA(w.error);return this.meta={token:w.token},w}async loginExam({email:q,password:$,exam:w,exam_password:f}){let[K,z]=await this.execute("auth.loginExam",{email:q,password:$,exam:w,exam_password:f});if(K.error)throw new ZA(K.error);return this.meta={token:K.token},K}async logout(){await this.execute("auth.logout",null),this.meta=null}clearCache(){if(this.logCache)console.log("clear");this.cache=new Map}setCache(q){let $=JSON.parse(q);this.cache=new Map(Object.entries($)),this.removeExpired()}getCache(){this.removeExpired();let q=Object.fromEntries(this.cache.entries());return JSON.stringify(q)}removeExpired(){for(let[q,$]of this.cache){let{func:w}=JSON.parse(q),f=this.clientTTLs.get(w);if(f!==void 0&&$.epoch+f*1000<new Date().getTime())this.cache.delete(q)}}clients;auth;misc;tables;problems;student;instructor;games;admin;testing;constructor(){this.clients=new L0_(this),this.auth=new c0_(this),this.misc=new x0_(this),this.tables=new d0_(this),this.problems=new l0_(this),this.student=new r0_(this),this.instructor=new t0_(this),this.games=new zT_(this),this.admin=new PT_(this),this.testing=new WT_(this),this.clientTTLs.set("misc.getAvatarPacks",3600),this.clientTTLs.set("misc.getExamIcons",3600),this.clientTTLs.set("misc.getDemosForCompiler",3600),this.clientTTLs.set("tables.get",300),this.clientTTLs.set("tables.getLanguages",300),this.clientTTLs.set("tables.getCountries",300),this.clientTTLs.set("tables.getCompilers",300),this.clientTTLs.set("tables.getDrivers",300),this.clientTTLs.set("tables.getVerdicts",300),this.clientTTLs.set("tables.getProglangs",300),this.clientTTLs.set("problems.getAllAbstractProblems",3600)}}class L0_{root;constructor(q){this.root=q}async python(){let[q,$]=await this.root.execute("clients.python",null);return $[0]}async typescript(){let[q,$]=await this.root.execute("clients.typescript",null);return $[0]}async javascript(){let[q,$]=await this.root.execute("clients.javascript",null);return $[0]}async java(){let[q,$]=await this.root.execute("clients.java",null);return $[0]}async cpp(){let[q,$]=await this.root.execute("clients.cpp",null);return $[0]}async php(){let[q,$]=await this.root.execute("clients.php",null);return $[0]}}class c0_{root;constructor(q){this.root=q}async login(q){let[$,w]=await this.root.execute("auth.login",q);return $}async logout(){let[q,$]=await this.root.execute("auth.logout",null);return q}async loginExam(q){let[$,w]=await this.root.execute("auth.loginExam",q);return $}async loginWithUsername(q){let[$,w]=await this.root.execute("auth.loginWithUsername",q);return $}}class x0_{root;constructor(q){this.root=q}async getApiVersion(){let[q,$]=await this.root.execute("misc.getApiVersion",null);return q}async getRequestInformation(){let[q,$]=await this.root.execute("misc.getRequestInformation",null);return q}async getFortune(){let[q,$]=await this.root.execute("misc.getFortune",null);return q}async getTime(){let[q,$]=await this.root.execute("misc.getTime",null);return q}async getHomepageStats(){let[q,$]=await this.root.execute("misc.getHomepageStats",null);return q}async getLogo(){let[q,$]=await this.root.execute("misc.getLogo",null);return $[0]}async getAvatarPacks(){let[q,$]=await this.root.execute("misc.getAvatarPacks",null);return q}async getExamIcons(){let[q,$]=await this.root.execute("misc.getExamIcons",null);return q}async getColors(){let[q,$]=await this.root.execute("misc.getColors",null);return q}async getHexColors(){let[q,$]=await this.root.execute("misc.getHexColors",null);return q}async getDemosForCompiler(q){let[$,w]=await this.root.execute("misc.getDemosForCompiler",q);return $}}class d0_{root;constructor(q){this.root=q}async get(){let[q,$]=await this.root.execute("tables.get",null);return q}async getLanguages(){let[q,$]=await this.root.execute("tables.getLanguages",null);return q}async getCountries(){let[q,$]=await this.root.execute("tables.getCountries",null);return q}async getCompilers(){let[q,$]=await this.root.execute("tables.getCompilers",null);return q}async getDrivers(){let[q,$]=await this.root.execute("tables.getDrivers",null);return q}async getVerdicts(){let[q,$]=await this.root.execute("tables.getVerdicts",null);return q}async getProglangs(){let[q,$]=await this.root.execute("tables.getProglangs",null);return q}}class l0_{root;constructor(q){this.root=q}async getAllAbstractProblems(){let[q,$]=await this.root.execute("problems.getAllAbstractProblems",null);return q}async getAbstractProblems(q){let[$,w]=await this.root.execute("problems.getAbstractProblems",q);return $}async getAbstractProblemsInList(q){let[$,w]=await this.root.execute("problems.getAbstractProblemsInList",q);return $}async getAbstractProblem(q){let[$,w]=await this.root.execute("problems.getAbstractProblem",q);return $}async getAbstractProblemSuppl(q){let[$,w]=await this.root.execute("problems.getAbstractProblemSuppl",q);return $}async getProblem(q){let[$,w]=await this.root.execute("problems.getProblem",q);return $}async getProblemSuppl(q){let[$,w]=await this.root.execute("problems.getProblemSuppl",q);return $}async getSampleTestcases(q){let[$,w]=await this.root.execute("problems.getSampleTestcases",q);return $}async getPublicTestcases(q){let[$,w]=await this.root.execute("problems.getPublicTestcases",q);return $}async getZipStatement(q){let[$,w]=await this.root.execute("problems.getZipStatement",q);return w[0]}async getPdfStatement(q){let[$,w]=await this.root.execute("problems.getPdfStatement",q);return w[0]}async getHtmlStatement(q){let[$,w]=await this.root.execute("problems.getHtmlStatement",q);return $}async getTextStatement(q){let[$,w]=await this.root.execute("problems.getTextStatement",q);return $}async getMarkdownStatement(q){let[$,w]=await this.root.execute("problems.getMarkdownStatement",q);return $}async getShortHtmlStatement(q){let[$,w]=await this.root.execute("problems.getShortHtmlStatement",q);return $}async getShortTextStatement(q){let[$,w]=await this.root.execute("problems.getShortTextStatement",q);return $}async getShortMarkdownStatement(q){let[$,w]=await this.root.execute("problems.getShortMarkdownStatement",q);return $}async getTemplates(q){let[$,w]=await this.root.execute("problems.getTemplates",q);return $}async getTemplate(q){let[$,w]=await this.root.execute("problems.getTemplate",q);return w[0]}async semanticSearch(q){let[$,w]=await this.root.execute("problems.semanticSearch",q);return $}async fullTextSearch(q){let[$,w]=await this.root.execute("problems.fullTextSearch",q);return $}}class r0_{root;keys;profile;dashboard;submissions;courses;lists;exam;statuses;awards;constructor(q){this.root=q,this.keys=new p0_(q),this.profile=new i0_(q),this.dashboard=new n0_(q),this.submissions=new a0_(q),this.courses=new B0_(q),this.lists=new F0_(q),this.exam=new o0_(q),this.statuses=new U0_(q),this.awards=new Q0_(q)}}class p0_{root;constructor(q){this.root=q}async get(){let[q,$]=await this.root.execute("student.keys.get",null);return q}async getProblems(){let[q,$]=await this.root.execute("student.keys.getProblems",null);return q}async getEnrolledCourses(){let[q,$]=await this.root.execute("student.keys.getEnrolledCourses",null);return q}async getAvailableCourses(){let[q,$]=await this.root.execute("student.keys.getAvailableCourses",null);return q}async getLists(){let[q,$]=await this.root.execute("student.keys.getLists",null);return q}}class i0_{root;constructor(q){this.root=q}async get(){let[q,$]=await this.root.execute("student.profile.get",null);return q}async getAvatar(){let[q,$]=await this.root.execute("student.profile.getAvatar",null);return $[0]}async update(q){let[$,w]=await this.root.execute("student.profile.update",q);return $}async updateAvatar(q){let[$,w]=await this.root.execute("student.profile.updateAvatar",null,[q]);return $}async updatePassword(q){let[$,w]=await this.root.execute("student.profile.updatePassword",q);return $}}class n0_{root;constructor(q){this.root=q}async getAbsoluteRanking(){let[q,$]=await this.root.execute("student.dashboard.getAbsoluteRanking",null);return q}async getAllDistributions(){let[q,$]=await this.root.execute("student.dashboard.getAllDistributions",null);return q}async getCompilersDistribution(){let[q,$]=await this.root.execute("student.dashboard.getCompilersDistribution",null);return q}async getDashboard(){let[q,$]=await this.root.execute("student.dashboard.getDashboard",null);return q}async getHeatmapCalendar(){let[q,$]=await this.root.execute("student.dashboard.getHeatmapCalendar",null);return q}async getProglangsDistribution(){let[q,$]=await this.root.execute("student.dashboard.getProglangsDistribution",null);return q}async getStats(){let[q,$]=await this.root.execute("student.dashboard.getStats",null);return q}async getLevel(){let[q,$]=await this.root.execute("student.dashboard.getLevel",null);return q}async getSubmissionsByHour(){let[q,$]=await this.root.execute("student.dashboard.getSubmissionsByHour",null);return q}async getSubmissionsByWeekDay(){let[q,$]=await this.root.execute("student.dashboard.getSubmissionsByWeekDay",null);return q}async getVerdictsDistribution(){let[q,$]=await this.root.execute("student.dashboard.getVerdictsDistribution",null);return q}}class a0_{root;constructor(q){this.root=q}async indexForAbstractProblem(q){let[$,w]=await this.root.execute("student.submissions.indexForAbstractProblem",q);return $}async indexForProblem(q){let[$,w]=await this.root.execute("student.submissions.indexForProblem",q);return $}async getAll(){let[q,$]=await this.root.execute("student.submissions.getAll",null);return q}async submit(q){let[$,w]=await this.root.execute("student.submissions.submit",q);return $}async submitFull(q,$){let[w,f]=await this.root.execute("student.submissions.submitFull",q,$);return w}async get(q){let[$,w]=await this.root.execute("student.submissions.get",q);return $}async getCodeAsB64(q){let[$,w]=await this.root.execute("student.submissions.getCodeAsB64",q);return $}async getCodeMetrics(q){let[$,w]=await this.root.execute("student.submissions.getCodeMetrics",q);return $}async getAwards(q){let[$,w]=await this.root.execute("student.submissions.getAwards",q);return $}async getAnalysis(q){let[$,w]=await this.root.execute("student.submissions.getAnalysis",q);return $}async getTestcaseAnalysis(q){let[$,w]=await this.root.execute("student.submissions.getTestcaseAnalysis",q);return $}async getGameResult(q){let[$,w]=await this.root.execute("student.submissions.getGameResult",q);return $}async getGameOutput(q){let[$,w]=await this.root.execute("student.submissions.getGameOutput",q);return $}}class B0_{root;constructor(q){this.root=q}async indexAvailable(){let[q,$]=await this.root.execute("student.courses.indexAvailable",null);return q}async indexEnrolled(){let[q,$]=await this.root.execute("student.courses.indexEnrolled",null);return q}async getAvailable(q){let[$,w]=await this.root.execute("student.courses.getAvailable",q);return $}async getEnrolled(q){let[$,w]=await this.root.execute("student.courses.getEnrolled",q);return $}async enroll(q){let[$,w]=await this.root.execute("student.courses.enroll",q);return $}async unenroll(q){let[$,w]=await this.root.execute("student.courses.unenroll",q);return $}}class F0_{root;constructor(q){this.root=q}async getAll(){let[q,$]=await this.root.execute("student.lists.getAll",null);return q}async get(q){let[$,w]=await this.root.execute("student.lists.get",q);return $}}class o0_{root;constructor(q){this.root=q}async getReadyExams(){let[q,$]=await this.root.execute("student.exam.getReadyExams",null);return q}async get(){let[q,$]=await this.root.execute("student.exam.get",null);return q}async getDocument(q){let[$,w]=await this.root.execute("student.exam.getDocument",q);return $}async getDocumentPdf(q){let[$,w]=await this.root.execute("student.exam.getDocumentPdf",q);return w[0]}async getRanking(){let[q,$]=await this.root.execute("student.exam.getRanking",null);return q}}class U0_{root;constructor(q){this.root=q}async getAll(){let[q,$]=await this.root.execute("student.statuses.getAll",null);return q}async getForAbstractProblem(q){let[$,w]=await this.root.execute("student.statuses.getForAbstractProblem",q);return $}async getForProblem(q){let[$,w]=await this.root.execute("student.statuses.getForProblem",q);return $}}class Q0_{root;constructor(q){this.root=q}async getAll(){let[q,$]=await this.root.execute("student.awards.getAll",null);return q}async get(q){let[$,w]=await this.root.execute("student.awards.get",q);return $}}class t0_{root;documents;lists;courses;exams;problems;queries;tags;jutgeai;constructor(q){this.root=q,this.documents=new e0_(q),this.lists=new s0_(q),this.courses=new _T_(q),this.exams=new qT_(q),this.problems=new $T_(q),this.queries=new wT_(q),this.tags=new fT_(q),this.jutgeai=new KT_(q)}}class e0_{root;constructor(q){this.root=q}async index(){let[q,$]=await this.root.execute("instructor.documents.index",null);return q}async get(q){let[$,w]=await this.root.execute("instructor.documents.get",q);return $}async getPdf(q){let[$,w]=await this.root.execute("instructor.documents.getPdf",q);return w[0]}async create(q,$){let[w,f]=await this.root.execute("instructor.documents.create",q,[$]);return w}async update(q,$){let[w,f]=await this.root.execute("instructor.documents.update",q,[$]);return w}async remove(q){let[$,w]=await this.root.execute("instructor.documents.remove",q);return $}}class s0_{root;constructor(q){this.root=q}async index(){let[q,$]=await this.root.execute("instructor.lists.index",null);return q}async get(q){let[$,w]=await this.root.execute("instructor.lists.get",q);return $}async create(q){let[$,w]=await this.root.execute("instructor.lists.create",q);return $}async update(q){let[$,w]=await this.root.execute("instructor.lists.update",q);return $}async remove(q){let[$,w]=await this.root.execute("instructor.lists.remove",q);return $}async getArchived(){let[q,$]=await this.root.execute("instructor.lists.getArchived",null);return q}async archive(q){let[$,w]=await this.root.execute("instructor.lists.archive",q);return $}async unarchive(q){let[$,w]=await this.root.execute("instructor.lists.unarchive",q);return $}}class _T_{root;constructor(q){this.root=q}async index(){let[q,$]=await this.root.execute("instructor.courses.index",null);return q}async get(q){let[$,w]=await this.root.execute("instructor.courses.get",q);return $}async create(q){let[$,w]=await this.root.execute("instructor.courses.create",q);return $}async update(q){let[$,w]=await this.root.execute("instructor.courses.update",q);return $}async remove(q){let[$,w]=await this.root.execute("instructor.courses.remove",q);return $}async sendInviteToStudents(q){let[$,w]=await this.root.execute("instructor.courses.sendInviteToStudents",q);return $}async sendInviteToTutors(q){let[$,w]=await this.root.execute("instructor.courses.sendInviteToTutors",q);return $}async getStudentProfiles(q){let[$,w]=await this.root.execute("instructor.courses.getStudentProfiles",q);return $}async getTutorProfiles(q){let[$,w]=await this.root.execute("instructor.courses.getTutorProfiles",q);return $}async getArchived(){let[q,$]=await this.root.execute("instructor.courses.getArchived",null);return q}async archive(q){let[$,w]=await this.root.execute("instructor.courses.archive",q);return $}async unarchive(q){let[$,w]=await this.root.execute("instructor.courses.unarchive",q);return $}}class qT_{root;constructor(q){this.root=q}async index(){let[q,$]=await this.root.execute("instructor.exams.index",null);return q}async get(q){let[$,w]=await this.root.execute("instructor.exams.get",q);return $}async getDocuments(q){let[$,w]=await this.root.execute("instructor.exams.getDocuments",q);return $}async getProblems(q){let[$,w]=await this.root.execute("instructor.exams.getProblems",q);return $}async getStudents(q){let[$,w]=await this.root.execute("instructor.exams.getStudents",q);return $}async getStudent(q){let[$,w]=await this.root.execute("instructor.exams.getStudent",q);return $}async getSubmissions(q){let[$,w]=await this.root.execute("instructor.exams.getSubmissions",q);return $}async getSubmissionsPack(q){let[$,w]=await this.root.execute("instructor.exams.getSubmissionsPack",q);return $}async getStatistics(q){let[$,w]=await this.root.execute("instructor.exams.getStatistics",q);return $}async create(q){let[$,w]=await this.root.execute("instructor.exams.create",q);return $}async update(q){let[$,w]=await this.root.execute("instructor.exams.update",q);return $}async updateDocuments(q){let[$,w]=await this.root.execute("instructor.exams.updateDocuments",q);return $}async updateCompilers(q){let[$,w]=await this.root.execute("instructor.exams.updateCompilers",q);return $}async updateProblems(q){let[$,w]=await this.root.execute("instructor.exams.updateProblems",q);return $}async updateStudents(q){let[$,w]=await this.root.execute("instructor.exams.updateStudents",q);return $}async addStudents(q){let[$,w]=await this.root.execute("instructor.exams.addStudents",q);return $}async removeStudents(q){let[$,w]=await this.root.execute("instructor.exams.removeStudents",q);return $}async remove(q){let[$,w]=await this.root.execute("instructor.exams.remove",q);return $}async getArchived(){let[q,$]=await this.root.execute("instructor.exams.getArchived",null);return q}async archive(q){let[$,w]=await this.root.execute("instructor.exams.archive",q);return $}async unarchive(q){let[$,w]=await this.root.execute("instructor.exams.unarchive",q);return $}async getRanking(q){let[$,w]=await this.root.execute("instructor.exams.getRanking",q);return $}}class $T_{root;constructor(q){this.root=q}async getOwnProblems(){let[q,$]=await this.root.execute("instructor.problems.getOwnProblems",null);return q}async setSharingSettings(q){let[$,w]=await this.root.execute("instructor.problems.setSharingSettings",q);return $}async getSharingSettings(q){let[$,w]=await this.root.execute("instructor.problems.getSharingSettings",q);return $}async getAllSharingSettings(){let[q,$]=await this.root.execute("instructor.problems.getAllSharingSettings",null);return q}async shareWith(q){let[$,w]=await this.root.execute("instructor.problems.shareWith",q);return $}async setDeprecation(q){let[$,w]=await this.root.execute("instructor.problems.setDeprecation",q);return $}async getAnonymousSubmissions(q){let[$,w]=await this.root.execute("instructor.problems.getAnonymousSubmissions",q);return $}async download(q){let[$,w]=await this.root.execute("instructor.problems.download",q);return w[0]}async create(q,$){let[w,f]=await this.root.execute("instructor.problems.create",q,[$]);return w}async update(q,$){let[w,f]=await this.root.execute("instructor.problems.update",q,[$]);return w}async remove(q){let[$,w]=await this.root.execute("instructor.problems.remove",q);return $}}class wT_{root;constructor(q){this.root=q}async getCourseProblemSubmissions(q){let[$,w]=await this.root.execute("instructor.queries.getCourseProblemSubmissions",q);return $}async getCourseListSubmissions(q){let[$,w]=await this.root.execute("instructor.queries.getCourseListSubmissions",q);return $}}class fT_{root;constructor(q){this.root=q}async index(){let[q,$]=await this.root.execute("instructor.tags.index",null);return q}async getDict(){let[q,$]=await this.root.execute("instructor.tags.getDict",null);return q}async get(q){let[$,w]=await this.root.execute("instructor.tags.get",q);return $}}class KT_{root;constructor(q){this.root=q}async supportedModels(){let[q,$]=await this.root.execute("instructor.jutgeai.supportedModels",null);return q}async supportedImageModels(){let[q,$]=await this.root.execute("instructor.jutgeai.supportedImageModels",null);return q}async chat(q){let[$,w]=await this.root.execute("instructor.jutgeai.chat",q);return $}async createImage(q){let[$,w]=await this.root.execute("instructor.jutgeai.createImage",q);return w[0]}async getLlmUsage(){let[q,$]=await this.root.execute("instructor.jutgeai.getLlmUsage",null);return q}}class zT_{root;constructor(q){this.root=q}async getGames(){let[q,$]=await this.root.execute("games.getGames",null);return q}async getDummy(q){let[$,w]=await this.root.execute("games.getDummy",q);return $}async getViewer(q){let[$,w]=await this.root.execute("games.getViewer",q);return w[0]}async submitMatch(q){let[$,w]=await this.root.execute("games.submitMatch",q);return $}}class PT_{root;instructors;users;dashboard;queue;tasks;stats;problems;constructor(q){this.root=q,this.instructors=new DT_(q),this.users=new YT_(q),this.dashboard=new JT_(q),this.queue=new HT_(q),this.tasks=new ZT_(q),this.stats=new kT_(q),this.problems=new OT_(q)}}class DT_{root;constructor(q){this.root=q}async get(){let[q,$]=await this.root.execute("admin.instructors.get",null);return q}async add(q){let[$,w]=await this.root.execute("admin.instructors.add",q);return $}async remove(q){let[$,w]=await this.root.execute("admin.instructors.remove",q);return $}}class YT_{root;constructor(q){this.root=q}async count(){let[q,$]=await this.root.execute("admin.users.count",null);return q}async create(q){let[$,w]=await this.root.execute("admin.users.create",q);return $}async remove(q){let[$,w]=await this.root.execute("admin.users.remove",q);return $}async setPassword(q){let[$,w]=await this.root.execute("admin.users.setPassword",q);return $}async getProfiles(q){let[$,w]=await this.root.execute("admin.users.getProfiles",q);return $}async getAllWithEmail(q){let[$,w]=await this.root.execute("admin.users.getAllWithEmail",q);return $}async getSpamUsers(){let[q,$]=await this.root.execute("admin.users.getSpamUsers",null);return q}async removeSpamUsers(q){let[$,w]=await this.root.execute("admin.users.removeSpamUsers",q);return $}}class JT_{root;constructor(q){this.root=q}async getAll(){let[q,$]=await this.root.execute("admin.dashboard.getAll",null);return q}async getDatabasesInfo(){let[q,$]=await this.root.execute("admin.dashboard.getDatabasesInfo",null);return q}async getFreeDiskSpace(){let[q,$]=await this.root.execute("admin.dashboard.getFreeDiskSpace",null);return q}async getRecentConnectedUsers(){let[q,$]=await this.root.execute("admin.dashboard.getRecentConnectedUsers",null);return q}async getRecentLoadAverages(){let[q,$]=await this.root.execute("admin.dashboard.getRecentLoadAverages",null);return q}async getRecentSubmissions(){let[q,$]=await this.root.execute("admin.dashboard.getRecentSubmissions",null);return q}async getSubmissionsHistograms(){let[q,$]=await this.root.execute("admin.dashboard.getSubmissionsHistograms",null);return q}async getZombies(){let[q,$]=await this.root.execute("admin.dashboard.getZombies",null);return q}async getUpcomingExams(q){let[$,w]=await this.root.execute("admin.dashboard.getUpcomingExams",q);return $}async getPM2Status(){let[q,$]=await this.root.execute("admin.dashboard.getPM2Status",null);return q}async getDockerStatus(){let[q,$]=await this.root.execute("admin.dashboard.getDockerStatus",null);return q}}class HT_{root;constructor(q){this.root=q}async getQueue(q){let[$,w]=await this.root.execute("admin.queue.getQueue",q);return $}}class ZT_{root;constructor(q){this.root=q}async purgeAuthTokens(){let[q,$]=await this.root.execute("admin.tasks.purgeAuthTokens",null);return q}async clearCaches(){let[q,$]=await this.root.execute("admin.tasks.clearCaches",null);return q}async fatalizeIEs(){let[q,$]=await this.root.execute("admin.tasks.fatalizeIEs",null);return q}async fatalizePendings(){let[q,$]=await this.root.execute("admin.tasks.fatalizePendings",null);return q}async resubmitIEs(){let[q,$]=await this.root.execute("admin.tasks.resubmitIEs",null);return q}async resubmitPendings(){let[q,$]=await this.root.execute("admin.tasks.resubmitPendings",null);return q}async getFullTextSearchDatabase(){let[q,$]=await this.root.execute("admin.tasks.getFullTextSearchDatabase",null);return $[0]}async updateSemanticSearchDatabase(q,$){let[w,f]=await this.root.execute("admin.tasks.updateSemanticSearchDatabase",q,[$]);return w}}class kT_{root;constructor(q){this.root=q}async getCounters(){let[q,$]=await this.root.execute("admin.stats.getCounters",null);return q}async getDistributionOfVerdicts(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfVerdicts",null);return q}async getDistributionOfVerdictsByYear(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfVerdictsByYear",null);return q}async getDistributionOfCompilers(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfCompilers",null);return q}async getDistributionOfProglangs(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfProglangs",null);return q}async getDistributionOfUsersByYear(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfUsersByYear",null);return q}async getDistributionOfUsersByCountry(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfUsersByCountry",null);return q}async getDistributionOfUsersBySubmissions(q){let[$,w]=await this.root.execute("admin.stats.getDistributionOfUsersBySubmissions",q);return $}async getRankingOfUsers(q){let[$,w]=await this.root.execute("admin.stats.getRankingOfUsers",q);return $}async getDistributionOfSubmissionsByHour(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByHour",null);return q}async getDistributionOfSubmissionsByProglang(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByProglang",null);return q}async getDistributionOfSubmissionsByCompiler(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByCompiler",null);return q}async getDistributionOfSubmissionsByWeekday(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByWeekday",null);return q}async getDistributionOfSubmissionsByYear(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByYear",null);return q}async getDistributionOfSubmissionsByYearForProglang(q){let[$,w]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByYearForProglang",q);return $}async getDistributionOfSubmissionsByDay(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByDay",null);return q}async getHeatmapCalendarOfSubmissions(q){let[$,w]=await this.root.execute("admin.stats.getHeatmapCalendarOfSubmissions",q);return $}async getDistributionOfDomains(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfDomains",null);return q}}class OT_{root;constructor(q){this.root=q}async getSolutions(q){let[$,w]=await this.root.execute("admin.problems.getSolutions",q);return $}async getSolutionAsB64(q){let[$,w]=await this.root.execute("admin.problems.getSolutionAsB64",q);return $}async getSolutionAsFile(q){let[$,w]=await this.root.execute("admin.problems.getSolutionAsFile",q);return w[0]}async getProblemSummary(q){let[$,w]=await this.root.execute("admin.problems.getProblemSummary",q);return $}async getProblemsWithSummary(){let[q,$]=await this.root.execute("admin.problems.getProblemsWithSummary",null);return q}async getProblemsWithoutSummary(){let[q,$]=await this.root.execute("admin.problems.getProblemsWithoutSummary",null);return q}async getAbstractProblemSolutionTags(q){let[$,w]=await this.root.execute("admin.problems.getAbstractProblemSolutionTags",q);return $}async getAbstractProblemsWithSolutionTags(){let[q,$]=await this.root.execute("admin.problems.getAbstractProblemsWithSolutionTags",null);return q}async getAbstractProblemsWithoutSolutionTags(){let[q,$]=await this.root.execute("admin.problems.getAbstractProblemsWithoutSolutionTags",null);return q}}class WT_{root;check;playground;constructor(q){this.root=q,this.check=new vT_(q),this.playground=new TT_(q)}}class vT_{root;constructor(q){this.root=q}async checkUser(){let[q,$]=await this.root.execute("testing.check.checkUser",null);return q}async checkInstructor(){let[q,$]=await this.root.execute("testing.check.checkInstructor",null);return q}async checkAdmin(){let[q,$]=await this.root.execute("testing.check.checkAdmin",null);return q}async throwError(q){let[$,w]=await this.root.execute("testing.check.throwError",q);return $}}class TT_{root;constructor(q){this.root=q}async upload(q,$){let[w,f]=await this.root.execute("testing.playground.upload",q,[$]);return w}async negate(q){let[$,w]=await this.root.execute("testing.playground.negate",null,[q]);return w[0]}async download(q){let[$,w]=await this.root.execute("testing.playground.download",q);return w[0]}async download2(q){let[$,w]=await this.root.execute("testing.playground.download2",q);return[$,w[0]]}async ping(){let[q,$]=await this.root.execute("testing.playground.ping",null);return q}async toUpperCase(q){let[$,w]=await this.root.execute("testing.playground.toUpperCase",q);return $}async add2i(q){let[$,w]=await this.root.execute("testing.playground.add2i",q);return $}async add2f(q){let[$,w]=await this.root.execute("testing.playground.add2f",q);return $}async inc(q){let[$,w]=await this.root.execute("testing.playground.inc",q);return $}async add3i(q){let[$,w]=await this.root.execute("testing.playground.add3i",q);return $}async something(q){let[$,w]=await this.root.execute("testing.playground.something",q);return $}async clock(){let[q,$]=await this.root.execute("testing.playground.clock",null);return q}}sq();async function LR6(q){u.tryTo("Try to get password from credentials file");let $=await cR6(q);if($)return u.trySuccess(),$;u.tryFailure(),u.tryTo("Try to get password from JUTGE_PASSWORD environment variable");let w=process.env.JUTGE_PASSWORD;if(w)return u.trySuccess(),w;u.tryFailure(),u.print("Prompting for password");let f=await rR6(q);if(f)return u.trySuccess(),f;u.tryFailure();return}async function cR6(q){let $=await kA();if(!$)return;let w=Object.values($).find((f)=>f.email===q);if(!w)return;if(!w.savedPassword)return;return atob(w.savedPassword)}async function xR6(){u.tryTo("Try to get email from JUTGE_EMAIL environment variable");let q=process.env.JUTGE_EMAIL;if(q)return u.trySuccess(),q;u.tryFailure(),u.tryTo("Try to get email from credentials file");let $=await dR6();if($)return u.trySuccess(),$;u.tryFailure(),u.print("Prompting for email");let w=await lR6();if(w)return w;return}async function dR6(){let q=await kA();if(!q)return;let $=Object.values(q).find((w)=>w.active===!0);if(!$)return;return $.email}async function XT_(){return await A3({message:"Jutge.org email:",default:z8.email||""})}async function lR6(){let q=await kA();if(!q||Object.values(q).length===0)return XT_();let $=Object.values(q).map((f)=>({name:f.email,value:f.email})).sort();$.push({name:"Other",value:"other"});let w=await x4({message:"Select email:",choices:$});if(w==="other")return XT_();return w}async function rR6(q){return await ZZ({message:`Jutge.org password for ${q}:`})}async function pR6(){u.tryTo("Try to get token from JUTGE_TOKEN environment variable");let q=process.env.JUTGE_TOKEN;if(q)return u.trySuccess(),q;u.tryFailure(),u.tryTo("Try to get token from credentials file");let $=await iR6();if($)return u.trySuccess(),$;u.tryFailure();return}async function iR6(){let q=await kA();if(!q)return;let $=Object.values(q).find((w)=>w.active===!0);if(!$)return;return $.token}async function nR6(){let q=tJ("jutge",{suffix:"cli"}),$=mR6(q.config,"credentials.json");if(!await SR6($))return;let w=await OX($);return y8_.parse(w)}var kA=Wk(nR6,{ttl:1000});async function aR6(q){let $=await u.section("Getting name from profile",async()=>{try{return await q.student.profile.get()}catch(w){throw u.error("Could not get profile, check your credentials or internet connection"),w}});u.success(`Logged in as ${$.name} with email ${$.email}`)}async function BR6(q){let $=await pR6();if($){let K={token:$};q.meta=K;return}let w=await xR6();if(!w)throw Error("Could not log in");u.success(`Email: ${w}`);let f=await LR6(w);if(!f)throw Error("Could not log in");u.success(`Password: ${"*".repeat(f.length)}`),await q.login({email:w,password:f});return}async function D4(){return await u.section("Logging in to Jutge.org",async()=>{let q=new qK;return await BR6(q),await aR6(q),q})}async function CT_(q,$){let w=await D4();await u.section(`Downloading problem ${q} from Jutge.org`,async()=>{let f=await w.instructor.problems.download(q);await tR6(f.data,$);let K=uT_.default($,{allFiles:!0,dirsFirst:!1});u.print(K),u.success(`Problem downloaded to ${u.hyperlink($)}`),await MD($)})}async function tR6(q,$){if(await FR6($))throw Error(`Directory ${$} already exists`);await oR6($,{recursive:!0}),new GT_.default(Buffer.from(q)).extractAllTo($,!0);let f=await AT_($);if(f.length===1){let K=ql($,f[0]);if(await my(K))await eR6($,K)}}async function eR6(q,$){let w=await AT_($);for(let f of w){let K=ql($,f),z=ql(q,f);if((await QR6(K)).isDirectory())await jT_(K,z,{recursive:!0});else await jT_(K,z)}await UR6($,{recursive:!0})}var VT_=new G6("download").summary("Download a problem from Jutge.org").argument("<problem_nm>","problem to download").option("-d, --directory <path>","output directory (default: <problem_nm>.pbm)").action(async(q,{directory:$})=>{let w=$??`${q}.pbm`;if(!w.endsWith(".pbm"))throw Error("Output directory must end with .pbm");await CT_(q,w)});var MT_=new G6("doctor").description("Diagnose status of the environment").action(async()=>{await u.section("Diagnosing environment",async()=>{await u.section("Checking Python3 installation",lW_),await u.section("Checking C/C++ installation",rW_),await u.section("Checking Haskell installation",pW_),await u.section("Checking Clojure installation",iW_),await u.section("Checking Java installation",nW_),await u.section("Checking Rust installation",aW_),await u.section("Checking Verilog installation",BW_),await u.section("Checking R installation",FW_),await u.section("Checking CodeMetrics installation",oW_),await u.section("Checking XeLaTeX installation",UW_),await u.section("Checking Pandoc installation",QW_),await u.section("Checking terminal",tW_)})});var QG_=z6(nj_(),1);import{exists as HL6}from"fs/promises";import{join as UG_}from"path";sq();async function kq(q,$,w,f,K){return await new cD(q,$,w,f).complete(K)}class cD{jutge;model;label;messages;constructor(q,$,w,f){this.jutge=q,this.model=$,this.label=w,this.messages=[{role:"system",content:f}]}async complete(q){this.messages.push({role:"user",content:q});let $=3,w="";for(let f=0;f<$;f++)try{w=await this.interact();break}catch(K){if(K instanceof Error)u.error(K.message);else u.error("An unknown error occurred");u.action("Retrying after 1 second..."),await Ok(1000)}if(w==="")return u.error(`Failed to get response after ${$} attempts`),"Failed to get response";return this.messages.push({role:"assistant",content:w}),w}async interact(){let q="";if(z8.showPrompts)u.print(`Prompt: (${this.messages.length})`),u.print(y_.gray(this.messages[this.messages.length-1].content)),u.print("Reading response...");let{id:$}=await this.jutge.instructor.jutgeai.chat({model:this.model,label:this.label,messages:this.messages,addUsage:!1}),w=await fetch(`${this.jutge.JUTGE_API_URL}/webstreams/${$}`,{method:"GET"});if(!w.body)throw Error("No response body");if(w.status!==200)throw u.error(`Failed to get response: Status ${w.status}`),Error("Failed to get response");let f=w.body.getReader();while(!0){let{done:K,value:z}=await f.read();if(K)break;let P=new TextDecoder().decode(z);if(q+=P,z8.showAnswers)process.stdout.write(y_.gray(P))}if(z8.showAnswers)process.stdout.write(`
|
|
626
|
-
`);return q}forgetLastInteraction(){if(this.messages.length>2)this.messages.pop(),this.messages.pop()}}function a4(q){let $=/^\n*```\w*\s*(.*?)\s*```\n*$/s;return q.replace($,"$1")}var aj_={"openai/gpt-5":{input:1.25,output:10},"openai/gpt-5-mini":{input:0.25,output:2},"openai/gpt-5-nano":{input:0.05,output:0.4},"openai/gpt-4.1":{input:2,output:8},"openai/gpt-4.1-mini":{input:0.4,output:1.6},"openai/gpt-4.1-nano":{input:0.1,output:0.4},"google/gemini-2.5-pro":{input:1.25,output:10},"google/gemini-2.5-flash":{input:0.3,output:2.5},"google/gemini-2.5-flash-lite":{input:0.1,output:0.4}};function Om6(q,$,w){if(!Object.keys(aj_).includes(w))throw Error(`Model not supported: ${w}`);let f=aj_[w],K=q*f.input/1e6,z=$*f.output/1e6;return K+z}async function Wm6(q){try{let f=(await(await fetch("https://api.frankfurter.dev/v1/latest?base=EUR&symbols=USD")).json()).rates.USD;return q/f}catch($){return u.error("Failed to convert dolars to euros"),q*0.85}}var vm6=Wk(Wm6);function Tm6(q){return q*1.21}async function bA(q,$,w){let f=Tm6(await vm6(Om6(q,$,w))),K=0.000833,z=22000,D=(q+$)*0.000833,Y=D*3600,J=445,Z=D*445/1000,k=Z/22000,W=Z/170,v=1.8,X=4.5,j=6.3,A=D*6.3/1000,C=20,V=D*3600/20/3600;return{inputTokens:q,outputTokens:$,model:w,priceEurTax:f,wattHours:D,joules:Y,co2Grams:Z,carKm:W,trees:k,waterLiters:A,brainHours:V}}var pD=z6(Jk(),1);import{exists as qL6,mkdir as $L6}from"fs/promises";var Rk=(q,$=[])=>q.name==="up"||$.includes("vim")&&q.name==="k"||$.includes("emacs")&&q.ctrl&&q.name==="p",IA=(q,$=[])=>q.name==="down"||$.includes("vim")&&q.name==="j"||$.includes("emacs")&&q.ctrl&&q.name==="n",hl=(q)=>q.name==="space";var El=(q)=>q.name==="enter"||q.name==="return";class gl extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(q){super();this.cause=q?.cause}}class Rl extends Error{name="CancelPromptError";message="Prompt was canceled"}class yA extends Error{name="ExitPromptError"}class bl extends Error{name="HookError"}class PK extends Error{name="ValidationError"}import{AsyncResource as Am6}from"async_hooks";import{AsyncLocalStorage as Xm6,AsyncResource as jm6}from"async_hooks";var Bj_=new Xm6;function Gm6(q){return{rl:q,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Fj_(q,$){let w=Gm6(q);return Bj_.run(w,()=>{function f(K){w.handleChange=()=>{w.index=0,K()},w.handleChange()}return $(f)})}function DK(){let q=Bj_.getStore();if(!q)throw new bl("[Inquirer] Hook functions can only be called from within a prompt");return q}function Il(){return DK().rl}function yl(q){let $=(...w)=>{let f=DK(),K=!1,z=f.handleChange;f.handleChange=()=>{K=!0};let P=q(...w);if(K)z();return f.handleChange=z,P};return jm6.bind($)}function xD(q){let $=DK(),{index:w}=$,f={get(){return $.hooks[w]},set(z){$.hooks[w]=z},initialized:w in $.hooks},K=q(f);return $.index++,K}function oj_(){DK().handleChange()}var YK={queue(q){let $=DK(),{index:w}=$;$.hooksEffect.push(()=>{$.hooksCleanup[w]?.();let f=q(Il());if(f!=null&&typeof f!=="function")throw new PK("useEffect return value must be a cleanup function or nothing.");$.hooksCleanup[w]=f})},run(){let q=DK();yl(()=>{q.hooksEffect.forEach(($)=>{$()}),q.hooksEffect.length=0})()},clearAll(){let q=DK();q.hooksCleanup.forEach(($)=>{$?.()}),q.hooksEffect.length=0,q.hooksCleanup.length=0}};function p1(q){return xD(($)=>{let w=Am6.bind(function(z){if($.get()!==z)$.set(z),oj_()});if($.initialized)return[$.get(),w];let f=typeof q==="function"?q():q;return $.set(f),[f,w]})}function JK(q,$){xD((w)=>{let f=w.get();if(!Array.isArray(f)||$.some((z,P)=>!Object.is(z,f[P])))YK.queue(q);w.set($)})}var q2=z6(Sl(),1);import t$ from"process";function Vm6(){if(t$.platform!=="win32")return t$.env.TERM!=="linux";return Boolean(t$.env.WT_SESSION)||Boolean(t$.env.TERMINUS_SUBLIME)||t$.env.ConEmuTask==="{cmd::Cmder}"||t$.env.TERM_PROGRAM==="Terminus-Sublime"||t$.env.TERM_PROGRAM==="vscode"||t$.env.TERM==="xterm-256color"||t$.env.TERM==="alacritty"||t$.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Qj_={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},tj_={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},Mm6={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},Nm6={...Qj_,...tj_},hm6={...Qj_,...Mm6},Em6=Vm6(),gm6=Em6?Nm6:hm6,v9=gm6,GS8=Object.entries(tj_);var ej_={prefix:{idle:q2.default.blue("?"),done:q2.default.green(v9.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map((q)=>q2.default.yellow(q))},style:{answer:q2.default.cyan,message:q2.default.bold,error:(q)=>q2.default.red(`> ${q}`),defaultAnswer:(q)=>q2.default.dim(`(${q})`),help:q2.default.dim,highlight:q2.default.cyan,key:(q)=>q2.default.cyan(q2.default.bold(`<${q}>`))}};function sj_(q){if(typeof q!=="object"||q===null)return!1;let $=q;while(Object.getPrototypeOf($)!==null)$=Object.getPrototypeOf($);return Object.getPrototypeOf(q)===$}function _G_(...q){let $={};for(let w of q)for(let[f,K]of Object.entries(w)){let z=$[f];$[f]=sj_(z)&&sj_(K)?_G_(z,K):K}return $}function bk(...q){let $=[ej_,...q.filter((w)=>w!=null)];return _G_(...$)}function ml({status:q="idle",theme:$}){let[w,f]=p1(!1),[K,z]=p1(0),{prefix:P,spinner:D}=bk($);if(JK(()=>{if(q==="loading"){let J,Z=-1,k=setTimeout(()=>{f(!0),J=setInterval(()=>{Z=Z+1,z(Z%D.frames.length)},D.interval)},300);return()=>{clearTimeout(k),clearInterval(J)}}else f(!1)},[q]),w)return D.frames[K];return typeof P==="string"?P:P[q==="loading"?"idle":q]??P.idle}function Ll(q,$){return xD((w)=>{let f=w.get();if(!f||f.dependencies.length!==$.length||f.dependencies.some((K,z)=>K!==$[z])){let K=q();return w.set({value:K,dependencies:$}),K}return f.value})}function SA(q){return p1({current:q})[0]}function cl(q){let $=SA(q);$.current=q,JK((w)=>{let f=!1,K=yl((z,P)=>{if(f)return;$.current(P,w)});return w.input.on("keypress",K),()=>{f=!0,w.input.removeListener("keypress",K)}},[])}var TG_=z6(C5(),1),XG_=z6(vG_(),1);function yk(q,$){return q.split(`
|
|
625
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as AR6}from"util";import{execFile as uR6}from"child_process";var CR6=AR6(uR6),M0_={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},YA=new Map(Object.entries(M0_));class od extends Error{}async function Ud(q=CR6){let{stdout:$}=await q("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),w=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec($);if(!w)throw new od(`Cannot find Windows browser in stdout: ${JSON.stringify($)}`);let{id:f}=w.groups,K=M0_[f];if(!K)throw new od(`Unknown browser ID: ${f}`);return K}var NR6=VR6(MR6),hR6=(q)=>q.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,($)=>$.toUpperCase());async function td(){if(Qd.platform==="darwin"){let q=await Bd();return{name:await Fd(q),id:q}}if(Qd.platform==="linux"){let{stdout:q}=await NR6("xdg-mime",["query","default","x-scheme-handler/http"]),$=q.trim();return{name:hR6($.replace(/.desktop$/,"").replace("-"," ")),id:$}}if(Qd.platform==="win32")return Ud();throw Error("Only macOS, Linux, and Windows are supported")}import ed from"process";var ER6=Boolean(ed.env.SSH_CONNECTION||ed.env.SSH_CLIENT||ed.env.SSH_TTY),N0_=ER6;var JA=Symbol("fallbackAttempt"),_l=import.meta.url?b0_.dirname(gR6(import.meta.url)):"",h0_=b0_.join(_l,"xdg-open"),{platform:CD,arch:E0_}=sd,g0_=async(q,$)=>{if(q.length===0)return;let w=[];for(let f of q)try{return await $(f)}catch(K){w.push(K)}throw AggregateError(w,"Failed to open in all supported apps")},HA=async(q)=>{q={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...q};let $=q[JA]===!0;if(delete q[JA],Array.isArray(q.app))return g0_(q.app,(J)=>HA({...q,app:J,[JA]:!0}));let{name:w,arguments:f=[]}=q.app??{};if(f=[...f],Array.isArray(w))return g0_(w,(J)=>HA({...q,app:{name:J,arguments:f},[JA]:!0}));if(w==="browser"||w==="browserPrivate"){let J={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},Z={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},k;if(H9){let W=await u0_();k=YA.get(W)??{}}else k=await td();if(k.id in J){let W=J[k.id.toLowerCase()];if(w==="browserPrivate"){if(W==="safari")throw Error("Safari doesn't support opening in private mode via command line");f.push(Z[W])}return HA({...q,app:{name:VD[W],arguments:f}})}throw Error(`${k.name} is not supported as a default browser`)}let K,z=[],P={},D=!1;if(H9&&!uD()&&!N0_&&!w)D=await A0_();if(CD==="darwin"){if(K="open",q.wait)z.push("--wait-apps");if(q.background)z.push("--background");if(q.newInstance)z.push("--new");if(w)z.push("-a",w)}else if(CD==="win32"||D){if(K=await DA(),z.push(...Hq.argumentsPrefix),!H9)P.windowsVerbatimArguments=!0;if(H9&&q.target)q.target=await C0_(q.target);let J=["$ProgressPreference = 'SilentlyContinue';","Start"];if(q.wait)J.push("-Wait");if(w){if(J.push(Hq.escapeArgument(w)),q.target)f.push(q.target)}else if(q.target)J.push(Hq.escapeArgument(q.target));if(f.length>0)f=f.map((Z)=>Hq.escapeArgument(Z)),J.push("-ArgumentList",f.join(","));if(q.target=Hq.encodeCommand(J.join(" ")),!q.wait)P.stdio="ignore"}else{if(w)K=w;else{let J=!_l||_l==="/",Z=!1;try{await bR6.access(h0_,IR6.X_OK),Z=!0}catch{}K=sd.versions.electron??(CD==="android"||J||!Z)?"xdg-open":h0_}if(f.length>0)z.push(...f);if(!q.wait)P.stdio="ignore",P.detached=!0}if(CD==="darwin"&&f.length>0)z.push("--args",...f);if(q.target)z.push(q.target);let Y=RR6.spawn(K,z,P);if(q.wait)return new Promise((J,Z)=>{Y.once("error",Z),Y.once("close",(k)=>{if(!q.allowNonzeroExitCode&&k!==0){Z(Error(`Exited with code ${k}`));return}J(Y)})});if($)return new Promise((J,Z)=>{Y.once("error",Z),Y.once("spawn",()=>{Y.once("close",(k)=>{if(Y.off("error",Z),k!==0){Z(Error(`Exited with code ${k}`));return}Y.unref(),J(Y)})})});return Y.unref(),new Promise((J,Z)=>{Y.once("error",Z),Y.once("spawn",()=>{Y.off("error",Z),J(Y)})})},yR6=(q,$)=>{if(typeof q!=="string")throw TypeError("Expected a `target`");return HA({...$,target:q})};function R0_(q){if(typeof q==="string"||Array.isArray(q))return q;let{[E0_]:$}=q;if(!$)throw Error(`${E0_} is not supported`);return $}function Ck({[CD]:q},{wsl:$}={}){if($&&H9)return R0_($);if(!q)throw Error(`${CD} is not supported`);return R0_(q)}var VD={browser:"browser",browserPrivate:"browserPrivate"};_K(VD,"chrome",()=>Ck({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));_K(VD,"brave",()=>Ck({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));_K(VD,"firefox",()=>Ck({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));_K(VD,"edge",()=>Ck({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));_K(VD,"safari",()=>Ck({darwin:"Safari"}));var MD=yR6;var uT_=z6(XD(),1);import{join as ql}from"path";import{exists as SR6}from"fs/promises";import{join as mR6}from"path";class ZA extends Error{message;name="UnauthorizedError";constructor(q="Unauthorized"){super(q);this.message=q}}class I0_ extends Error{message;name="InfoError";constructor(q){super(q);this.message=q}}class y0_ extends Error{message;name="NotFoundError";constructor(q){super(q);this.message=q}}class S0_ extends Error{message;name="InputError";constructor(q){super(q);this.message=q}}class m0_ extends Error{message;name="ProtocolError";constructor(q){super(q);this.message=q}}class qK{clientTTLs=new Map;useCache=!0;logCache=!1;cache=new Map;JUTGE_API_URL=process.env.JUTGE_API_URL||"https://api.jutge.org/api";headers={...process.env.JUTGE_DOMAIN?{"x-forwarded-host":process.env.JUTGE_DOMAIN}:{}};meta=null;async execute(q,$,w=[]){let f=this.useCache&&this.clientTTLs.has(q)&&w.length===0;if(f){let A=JSON.stringify({func:q,input:$}),C=this.cache.get(A);if(C!==void 0){if(this.logCache)console.log("found");let N=this.clientTTLs.get(q);if(C.epoch+N*1000>new Date().valueOf()){if(this.logCache)console.log("used");return[C.output,C.ofiles]}else{if(this.logCache)console.log("expired");this.cache.delete(A)}}}if(this.logCache)console.log("fetch");let K=new FormData,z={func:q,input:$,meta:this.meta};K.append("data",JSON.stringify(z));for(let A in w)K.append(`file_${A}`,w[A]);let P=await fetch(this.JUTGE_API_URL,{method:"POST",body:K,headers:this.headers});if(P.headers.get("content-type")?.split(";")[0].toLowerCase()!=="multipart/form-data")throw new m0_("The content type is not multipart/form-data");let Y=await P.formData(),J=Y.get("data"),{output:Z,error:k,duration:W,operation_id:v,time:X}=JSON.parse(J);if(k)this.throwError(k,v);let j=[];for(let A of Y.keys()){let C=Y.get(A);if(C instanceof File)j.push({data:new Uint8Array(await C.arrayBuffer()),name:C.name,type:C.type})}if(f){if(this.logCache)console.log("saved");let A=JSON.stringify({func:q,input:$});this.cache.set(A,{output:Z,ofiles:j,epoch:new Date().valueOf()})}return[Z,j]}throwError(q,$){let w=q.message||"Unknown error";if(q.name==="UnauthorizedError")throw new ZA(w);else if(q.name==="InfoError")throw new I0_(w);else if(q.name==="NotFoundError")throw new y0_(w);else if(q.name==="InputError")throw new S0_(w);else throw Error(w)}async login({email:q,password:$}){let[w,f]=await this.execute("auth.login",{email:q,password:$});if(w.error)throw new ZA(w.error);return this.meta={token:w.token,user_uid:w.user_uid},w}async loginExam({email:q,password:$,exam:w,exam_password:f}){let[K,z]=await this.execute("auth.loginExam",{email:q,password:$,exam:w,exam_password:f});if(K.error)throw new ZA(K.error);return this.meta={token:K.token,user_uid:K.user_uid},K}async logout(){await this.execute("auth.logout",null),this.meta=null}clearCache(){if(this.logCache)console.log("clear");this.cache=new Map}setCache(q){let $=JSON.parse(q);this.cache=new Map(Object.entries($)),this.removeExpired()}getCache(){this.removeExpired();let q=Object.fromEntries(this.cache.entries());return JSON.stringify(q)}removeExpired(){for(let[q,$]of this.cache){let{func:w}=JSON.parse(q),f=this.clientTTLs.get(w);if(f!==void 0&&$.epoch+f*1000<new Date().getTime())this.cache.delete(q)}}clients;auth;misc;tables;problems;student;instructor;games;admin;testing;constructor(){this.clients=new L0_(this),this.auth=new c0_(this),this.misc=new x0_(this),this.tables=new d0_(this),this.problems=new l0_(this),this.student=new r0_(this),this.instructor=new t0_(this),this.games=new zT_(this),this.admin=new PT_(this),this.testing=new WT_(this),this.clientTTLs.set("misc.getAvatarPacks",3600),this.clientTTLs.set("misc.getExamIcons",3600),this.clientTTLs.set("misc.getDemosForCompiler",3600),this.clientTTLs.set("tables.get",300),this.clientTTLs.set("tables.getLanguages",300),this.clientTTLs.set("tables.getCountries",300),this.clientTTLs.set("tables.getCompilers",300),this.clientTTLs.set("tables.getDrivers",300),this.clientTTLs.set("tables.getVerdicts",300),this.clientTTLs.set("tables.getProglangs",300),this.clientTTLs.set("problems.getAllAbstractProblems",3600)}}class L0_{root;constructor(q){this.root=q}async python(){let[q,$]=await this.root.execute("clients.python",null);return $[0]}async typescript(){let[q,$]=await this.root.execute("clients.typescript",null);return $[0]}async javascript(){let[q,$]=await this.root.execute("clients.javascript",null);return $[0]}async java(){let[q,$]=await this.root.execute("clients.java",null);return $[0]}async cpp(){let[q,$]=await this.root.execute("clients.cpp",null);return $[0]}async php(){let[q,$]=await this.root.execute("clients.php",null);return $[0]}}class c0_{root;constructor(q){this.root=q}async login(q){let[$,w]=await this.root.execute("auth.login",q);return $}async logout(){let[q,$]=await this.root.execute("auth.logout",null);return q}async loginExam(q){let[$,w]=await this.root.execute("auth.loginExam",q);return $}async getReadyExams(q){let[$,w]=await this.root.execute("auth.getReadyExams",q);return $}async loginWithUsername(q){let[$,w]=await this.root.execute("auth.loginWithUsername",q);return $}}class x0_{root;constructor(q){this.root=q}async getApiVersion(){let[q,$]=await this.root.execute("misc.getApiVersion",null);return q}async getRequestInformation(){let[q,$]=await this.root.execute("misc.getRequestInformation",null);return q}async getFortune(){let[q,$]=await this.root.execute("misc.getFortune",null);return q}async getTime(){let[q,$]=await this.root.execute("misc.getTime",null);return q}async getHomepageStats(){let[q,$]=await this.root.execute("misc.getHomepageStats",null);return q}async getLogo(){let[q,$]=await this.root.execute("misc.getLogo",null);return $[0]}async getAvatarPacks(){let[q,$]=await this.root.execute("misc.getAvatarPacks",null);return q}async getExamIcons(){let[q,$]=await this.root.execute("misc.getExamIcons",null);return q}async getColors(){let[q,$]=await this.root.execute("misc.getColors",null);return q}async getHexColors(){let[q,$]=await this.root.execute("misc.getHexColors",null);return q}async getDemosForCompiler(q){let[$,w]=await this.root.execute("misc.getDemosForCompiler",q);return $}}class d0_{root;constructor(q){this.root=q}async get(){let[q,$]=await this.root.execute("tables.get",null);return q}async getLanguages(){let[q,$]=await this.root.execute("tables.getLanguages",null);return q}async getCountries(){let[q,$]=await this.root.execute("tables.getCountries",null);return q}async getCompilers(){let[q,$]=await this.root.execute("tables.getCompilers",null);return q}async getDrivers(){let[q,$]=await this.root.execute("tables.getDrivers",null);return q}async getVerdicts(){let[q,$]=await this.root.execute("tables.getVerdicts",null);return q}async getProglangs(){let[q,$]=await this.root.execute("tables.getProglangs",null);return q}}class l0_{root;constructor(q){this.root=q}async getAllAbstractProblems(){let[q,$]=await this.root.execute("problems.getAllAbstractProblems",null);return q}async getAbstractProblems(q){let[$,w]=await this.root.execute("problems.getAbstractProblems",q);return $}async getAbstractProblemsInList(q){let[$,w]=await this.root.execute("problems.getAbstractProblemsInList",q);return $}async getAbstractProblem(q){let[$,w]=await this.root.execute("problems.getAbstractProblem",q);return $}async getAbstractProblemSuppl(q){let[$,w]=await this.root.execute("problems.getAbstractProblemSuppl",q);return $}async getProblem(q){let[$,w]=await this.root.execute("problems.getProblem",q);return $}async getProblemSuppl(q){let[$,w]=await this.root.execute("problems.getProblemSuppl",q);return $}async getSampleTestcases(q){let[$,w]=await this.root.execute("problems.getSampleTestcases",q);return $}async getPublicTestcases(q){let[$,w]=await this.root.execute("problems.getPublicTestcases",q);return $}async getZipStatement(q){let[$,w]=await this.root.execute("problems.getZipStatement",q);return w[0]}async getPdfStatement(q){let[$,w]=await this.root.execute("problems.getPdfStatement",q);return w[0]}async getHtmlStatement(q){let[$,w]=await this.root.execute("problems.getHtmlStatement",q);return $}async getTextStatement(q){let[$,w]=await this.root.execute("problems.getTextStatement",q);return $}async getMarkdownStatement(q){let[$,w]=await this.root.execute("problems.getMarkdownStatement",q);return $}async getShortHtmlStatement(q){let[$,w]=await this.root.execute("problems.getShortHtmlStatement",q);return $}async getShortTextStatement(q){let[$,w]=await this.root.execute("problems.getShortTextStatement",q);return $}async getShortMarkdownStatement(q){let[$,w]=await this.root.execute("problems.getShortMarkdownStatement",q);return $}async getTemplates(q){let[$,w]=await this.root.execute("problems.getTemplates",q);return $}async getTemplate(q){let[$,w]=await this.root.execute("problems.getTemplate",q);return w[0]}async semanticSearch(q){let[$,w]=await this.root.execute("problems.semanticSearch",q);return $}async fullTextSearch(q){let[$,w]=await this.root.execute("problems.fullTextSearch",q);return $}async getSolutions(q){let[$,w]=await this.root.execute("problems.getSolutions",q);return $}}class r0_{root;keys;profile;dashboard;submissions;courses;lists;exam;statuses;awards;constructor(q){this.root=q,this.keys=new p0_(q),this.profile=new i0_(q),this.dashboard=new n0_(q),this.submissions=new a0_(q),this.courses=new B0_(q),this.lists=new F0_(q),this.exam=new o0_(q),this.statuses=new U0_(q),this.awards=new Q0_(q)}}class p0_{root;constructor(q){this.root=q}async get(){let[q,$]=await this.root.execute("student.keys.get",null);return q}async getProblems(){let[q,$]=await this.root.execute("student.keys.getProblems",null);return q}async getEnrolledCourses(){let[q,$]=await this.root.execute("student.keys.getEnrolledCourses",null);return q}async getAvailableCourses(){let[q,$]=await this.root.execute("student.keys.getAvailableCourses",null);return q}async getLists(){let[q,$]=await this.root.execute("student.keys.getLists",null);return q}}class i0_{root;constructor(q){this.root=q}async get(){let[q,$]=await this.root.execute("student.profile.get",null);return q}async getAvatar(){let[q,$]=await this.root.execute("student.profile.getAvatar",null);return $[0]}async update(q){let[$,w]=await this.root.execute("student.profile.update",q);return $}async updateAvatar(q){let[$,w]=await this.root.execute("student.profile.updateAvatar",null,[q]);return $}async updatePassword(q){let[$,w]=await this.root.execute("student.profile.updatePassword",q);return $}}class n0_{root;constructor(q){this.root=q}async getAbsoluteRanking(){let[q,$]=await this.root.execute("student.dashboard.getAbsoluteRanking",null);return q}async getAllDistributions(){let[q,$]=await this.root.execute("student.dashboard.getAllDistributions",null);return q}async getCompilersDistribution(){let[q,$]=await this.root.execute("student.dashboard.getCompilersDistribution",null);return q}async getDashboard(){let[q,$]=await this.root.execute("student.dashboard.getDashboard",null);return q}async getHeatmapCalendar(){let[q,$]=await this.root.execute("student.dashboard.getHeatmapCalendar",null);return q}async getProglangsDistribution(){let[q,$]=await this.root.execute("student.dashboard.getProglangsDistribution",null);return q}async getStats(){let[q,$]=await this.root.execute("student.dashboard.getStats",null);return q}async getLevel(){let[q,$]=await this.root.execute("student.dashboard.getLevel",null);return q}async getSubmissionsByHour(){let[q,$]=await this.root.execute("student.dashboard.getSubmissionsByHour",null);return q}async getSubmissionsByWeekDay(){let[q,$]=await this.root.execute("student.dashboard.getSubmissionsByWeekDay",null);return q}async getVerdictsDistribution(){let[q,$]=await this.root.execute("student.dashboard.getVerdictsDistribution",null);return q}}class a0_{root;constructor(q){this.root=q}async indexForAbstractProblem(q){let[$,w]=await this.root.execute("student.submissions.indexForAbstractProblem",q);return $}async indexForProblem(q){let[$,w]=await this.root.execute("student.submissions.indexForProblem",q);return $}async getForAbstractProblems(q){let[$,w]=await this.root.execute("student.submissions.getForAbstractProblems",q);return $}async getAll(){let[q,$]=await this.root.execute("student.submissions.getAll",null);return q}async submit(q){let[$,w]=await this.root.execute("student.submissions.submit",q);return $}async submitFull(q,$){let[w,f]=await this.root.execute("student.submissions.submitFull",q,$);return w}async get(q){let[$,w]=await this.root.execute("student.submissions.get",q);return $}async getCodeAsB64(q){let[$,w]=await this.root.execute("student.submissions.getCodeAsB64",q);return $}async getCodeMetrics(q){let[$,w]=await this.root.execute("student.submissions.getCodeMetrics",q);return $}async getAwards(q){let[$,w]=await this.root.execute("student.submissions.getAwards",q);return $}async getAnalysis(q){let[$,w]=await this.root.execute("student.submissions.getAnalysis",q);return $}async getTestcaseAnalysis(q){let[$,w]=await this.root.execute("student.submissions.getTestcaseAnalysis",q);return $}async getGameResult(q){let[$,w]=await this.root.execute("student.submissions.getGameResult",q);return $}async getGameOutput(q){let[$,w]=await this.root.execute("student.submissions.getGameOutput",q);return $}}class B0_{root;constructor(q){this.root=q}async indexAvailable(){let[q,$]=await this.root.execute("student.courses.indexAvailable",null);return q}async indexEnrolled(){let[q,$]=await this.root.execute("student.courses.indexEnrolled",null);return q}async getAvailable(q){let[$,w]=await this.root.execute("student.courses.getAvailable",q);return $}async getEnrolled(q){let[$,w]=await this.root.execute("student.courses.getEnrolled",q);return $}async enroll(q){let[$,w]=await this.root.execute("student.courses.enroll",q);return $}async unenroll(q){let[$,w]=await this.root.execute("student.courses.unenroll",q);return $}}class F0_{root;constructor(q){this.root=q}async getAll(){let[q,$]=await this.root.execute("student.lists.getAll",null);return q}async get(q){let[$,w]=await this.root.execute("student.lists.get",q);return $}}class o0_{root;constructor(q){this.root=q}async getReadyExams(){let[q,$]=await this.root.execute("student.exam.getReadyExams",null);return q}async get(){let[q,$]=await this.root.execute("student.exam.get",null);return q}async getDocument(q){let[$,w]=await this.root.execute("student.exam.getDocument",q);return $}async getDocumentPdf(q){let[$,w]=await this.root.execute("student.exam.getDocumentPdf",q);return w[0]}async getRanking(){let[q,$]=await this.root.execute("student.exam.getRanking",null);return q}}class U0_{root;constructor(q){this.root=q}async getAll(){let[q,$]=await this.root.execute("student.statuses.getAll",null);return q}async getForAbstractProblem(q){let[$,w]=await this.root.execute("student.statuses.getForAbstractProblem",q);return $}async getForProblem(q){let[$,w]=await this.root.execute("student.statuses.getForProblem",q);return $}}class Q0_{root;constructor(q){this.root=q}async getAll(){let[q,$]=await this.root.execute("student.awards.getAll",null);return q}async get(q){let[$,w]=await this.root.execute("student.awards.get",q);return $}}class t0_{root;documents;lists;courses;exams;problems;queries;tags;jutgeai;constructor(q){this.root=q,this.documents=new e0_(q),this.lists=new s0_(q),this.courses=new _T_(q),this.exams=new qT_(q),this.problems=new $T_(q),this.queries=new wT_(q),this.tags=new fT_(q),this.jutgeai=new KT_(q)}}class e0_{root;constructor(q){this.root=q}async index(){let[q,$]=await this.root.execute("instructor.documents.index",null);return q}async get(q){let[$,w]=await this.root.execute("instructor.documents.get",q);return $}async getPdf(q){let[$,w]=await this.root.execute("instructor.documents.getPdf",q);return w[0]}async getZip(q){let[$,w]=await this.root.execute("instructor.documents.getZip",q);return w[0]}async create(q,$){let[w,f]=await this.root.execute("instructor.documents.create",q,[$]);return w}async update(q,$){let[w,f]=await this.root.execute("instructor.documents.update",q,[$]);return w}async remove(q){let[$,w]=await this.root.execute("instructor.documents.remove",q);return $}}class s0_{root;constructor(q){this.root=q}async index(){let[q,$]=await this.root.execute("instructor.lists.index",null);return q}async get(q){let[$,w]=await this.root.execute("instructor.lists.get",q);return $}async create(q){let[$,w]=await this.root.execute("instructor.lists.create",q);return $}async update(q){let[$,w]=await this.root.execute("instructor.lists.update",q);return $}async remove(q){let[$,w]=await this.root.execute("instructor.lists.remove",q);return $}async getArchived(){let[q,$]=await this.root.execute("instructor.lists.getArchived",null);return q}async archive(q){let[$,w]=await this.root.execute("instructor.lists.archive",q);return $}async unarchive(q){let[$,w]=await this.root.execute("instructor.lists.unarchive",q);return $}}class _T_{root;constructor(q){this.root=q}async index(){let[q,$]=await this.root.execute("instructor.courses.index",null);return q}async get(q){let[$,w]=await this.root.execute("instructor.courses.get",q);return $}async create(q){let[$,w]=await this.root.execute("instructor.courses.create",q);return $}async update(q){let[$,w]=await this.root.execute("instructor.courses.update",q);return $}async remove(q){let[$,w]=await this.root.execute("instructor.courses.remove",q);return $}async sendInviteToStudents(q){let[$,w]=await this.root.execute("instructor.courses.sendInviteToStudents",q);return $}async sendInviteToTutors(q){let[$,w]=await this.root.execute("instructor.courses.sendInviteToTutors",q);return $}async getStudentProfiles(q){let[$,w]=await this.root.execute("instructor.courses.getStudentProfiles",q);return $}async getTutorProfiles(q){let[$,w]=await this.root.execute("instructor.courses.getTutorProfiles",q);return $}async getArchived(){let[q,$]=await this.root.execute("instructor.courses.getArchived",null);return q}async archive(q){let[$,w]=await this.root.execute("instructor.courses.archive",q);return $}async unarchive(q){let[$,w]=await this.root.execute("instructor.courses.unarchive",q);return $}}class qT_{root;constructor(q){this.root=q}async index(){let[q,$]=await this.root.execute("instructor.exams.index",null);return q}async get(q){let[$,w]=await this.root.execute("instructor.exams.get",q);return $}async getDocuments(q){let[$,w]=await this.root.execute("instructor.exams.getDocuments",q);return $}async getProblems(q){let[$,w]=await this.root.execute("instructor.exams.getProblems",q);return $}async getStudents(q){let[$,w]=await this.root.execute("instructor.exams.getStudents",q);return $}async getStudent(q){let[$,w]=await this.root.execute("instructor.exams.getStudent",q);return $}async getSubmissions(q){let[$,w]=await this.root.execute("instructor.exams.getSubmissions",q);return $}async getSubmissionsPack(q){let[$,w]=await this.root.execute("instructor.exams.getSubmissionsPack",q);return $}async getStatistics(q){let[$,w]=await this.root.execute("instructor.exams.getStatistics",q);return $}async create(q){let[$,w]=await this.root.execute("instructor.exams.create",q);return $}async update(q){let[$,w]=await this.root.execute("instructor.exams.update",q);return $}async updateDocuments(q){let[$,w]=await this.root.execute("instructor.exams.updateDocuments",q);return $}async updateCompilers(q){let[$,w]=await this.root.execute("instructor.exams.updateCompilers",q);return $}async updateProblems(q){let[$,w]=await this.root.execute("instructor.exams.updateProblems",q);return $}async updateStudents(q){let[$,w]=await this.root.execute("instructor.exams.updateStudents",q);return $}async addStudents(q){let[$,w]=await this.root.execute("instructor.exams.addStudents",q);return $}async removeStudents(q){let[$,w]=await this.root.execute("instructor.exams.removeStudents",q);return $}async remove(q){let[$,w]=await this.root.execute("instructor.exams.remove",q);return $}async getArchived(){let[q,$]=await this.root.execute("instructor.exams.getArchived",null);return q}async archive(q){let[$,w]=await this.root.execute("instructor.exams.archive",q);return $}async unarchive(q){let[$,w]=await this.root.execute("instructor.exams.unarchive",q);return $}async getRanking(q){let[$,w]=await this.root.execute("instructor.exams.getRanking",q);return $}}class $T_{root;constructor(q){this.root=q}async getOwnProblems(){let[q,$]=await this.root.execute("instructor.problems.getOwnProblems",null);return q}async setSharingSettings(q){let[$,w]=await this.root.execute("instructor.problems.setSharingSettings",q);return $}async getSharingSettings(q){let[$,w]=await this.root.execute("instructor.problems.getSharingSettings",q);return $}async getAllSharingSettings(){let[q,$]=await this.root.execute("instructor.problems.getAllSharingSettings",null);return q}async getAlerts(q){let[$,w]=await this.root.execute("instructor.problems.getAlerts",q);return $}async getAllAlerts(){let[q,$]=await this.root.execute("instructor.problems.getAllAlerts",null);return q}async shareWith(q){let[$,w]=await this.root.execute("instructor.problems.shareWith",q);return $}async setDeprecation(q){let[$,w]=await this.root.execute("instructor.problems.setDeprecation",q);return $}async getProblemPopularityBuckets(){let[q,$]=await this.root.execute("instructor.problems.getProblemPopularityBuckets",null);return q}async getAnonymousSubmissions(q){let[$,w]=await this.root.execute("instructor.problems.getAnonymousSubmissions",q);return $}async download(q){let[$,w]=await this.root.execute("instructor.problems.download",q);return w[0]}async create(q,$){let[w,f]=await this.root.execute("instructor.problems.create",q,[$]);return w}async update(q,$){let[w,f]=await this.root.execute("instructor.problems.update",q,[$]);return w}async remove(q){let[$,w]=await this.root.execute("instructor.problems.remove",q);return $}}class wT_{root;constructor(q){this.root=q}async getCourseProblemSubmissions(q){let[$,w]=await this.root.execute("instructor.queries.getCourseProblemSubmissions",q);return $}async getCourseListSubmissions(q){let[$,w]=await this.root.execute("instructor.queries.getCourseListSubmissions",q);return $}}class fT_{root;constructor(q){this.root=q}async index(){let[q,$]=await this.root.execute("instructor.tags.index",null);return q}async getDict(){let[q,$]=await this.root.execute("instructor.tags.getDict",null);return q}async get(q){let[$,w]=await this.root.execute("instructor.tags.get",q);return $}}class KT_{root;constructor(q){this.root=q}async supportedModels(){let[q,$]=await this.root.execute("instructor.jutgeai.supportedModels",null);return q}async supportedImageModels(){let[q,$]=await this.root.execute("instructor.jutgeai.supportedImageModels",null);return q}async chat(q){let[$,w]=await this.root.execute("instructor.jutgeai.chat",q);return $}async createImage(q){let[$,w]=await this.root.execute("instructor.jutgeai.createImage",q);return w[0]}async getLlmUsage(){let[q,$]=await this.root.execute("instructor.jutgeai.getLlmUsage",null);return q}}class zT_{root;constructor(q){this.root=q}async getGames(){let[q,$]=await this.root.execute("games.getGames",null);return q}async getDummy(q){let[$,w]=await this.root.execute("games.getDummy",q);return $}async getViewer(q){let[$,w]=await this.root.execute("games.getViewer",q);return w[0]}}class PT_{root;instructors;users;dashboard;queue;tasks;stats;problems;constructor(q){this.root=q,this.instructors=new DT_(q),this.users=new YT_(q),this.dashboard=new JT_(q),this.queue=new HT_(q),this.tasks=new ZT_(q),this.stats=new kT_(q),this.problems=new OT_(q)}}class DT_{root;constructor(q){this.root=q}async get(){let[q,$]=await this.root.execute("admin.instructors.get",null);return q}async add(q){let[$,w]=await this.root.execute("admin.instructors.add",q);return $}async remove(q){let[$,w]=await this.root.execute("admin.instructors.remove",q);return $}}class YT_{root;constructor(q){this.root=q}async count(){let[q,$]=await this.root.execute("admin.users.count",null);return q}async create(q){let[$,w]=await this.root.execute("admin.users.create",q);return $}async remove(q){let[$,w]=await this.root.execute("admin.users.remove",q);return $}async setPassword(q){let[$,w]=await this.root.execute("admin.users.setPassword",q);return $}async getProfiles(q){let[$,w]=await this.root.execute("admin.users.getProfiles",q);return $}async getAllWithEmail(q){let[$,w]=await this.root.execute("admin.users.getAllWithEmail",q);return $}async getSpamUsers(){let[q,$]=await this.root.execute("admin.users.getSpamUsers",null);return q}async removeSpamUsers(q){let[$,w]=await this.root.execute("admin.users.removeSpamUsers",q);return $}}class JT_{root;constructor(q){this.root=q}async getAll(){let[q,$]=await this.root.execute("admin.dashboard.getAll",null);return q}async getDatabasesInfo(){let[q,$]=await this.root.execute("admin.dashboard.getDatabasesInfo",null);return q}async getFreeDiskSpace(){let[q,$]=await this.root.execute("admin.dashboard.getFreeDiskSpace",null);return q}async getRecentConnectedUsers(){let[q,$]=await this.root.execute("admin.dashboard.getRecentConnectedUsers",null);return q}async getRecentLoadAverages(){let[q,$]=await this.root.execute("admin.dashboard.getRecentLoadAverages",null);return q}async getRecentSubmissions(){let[q,$]=await this.root.execute("admin.dashboard.getRecentSubmissions",null);return q}async getSubmissionsHistograms(){let[q,$]=await this.root.execute("admin.dashboard.getSubmissionsHistograms",null);return q}async getZombies(){let[q,$]=await this.root.execute("admin.dashboard.getZombies",null);return q}async getUpcomingExams(q){let[$,w]=await this.root.execute("admin.dashboard.getUpcomingExams",q);return $}async getPM2Status(){let[q,$]=await this.root.execute("admin.dashboard.getPM2Status",null);return q}async getDockerStatus(){let[q,$]=await this.root.execute("admin.dashboard.getDockerStatus",null);return q}}class HT_{root;constructor(q){this.root=q}async getQueue(q){let[$,w]=await this.root.execute("admin.queue.getQueue",q);return $}}class ZT_{root;constructor(q){this.root=q}async purgeAuthTokens(){let[q,$]=await this.root.execute("admin.tasks.purgeAuthTokens",null);return q}async clearCaches(){let[q,$]=await this.root.execute("admin.tasks.clearCaches",null);return q}async fatalizeIEs(){let[q,$]=await this.root.execute("admin.tasks.fatalizeIEs",null);return q}async fatalizePendings(){let[q,$]=await this.root.execute("admin.tasks.fatalizePendings",null);return q}async resubmitIEs(){let[q,$]=await this.root.execute("admin.tasks.resubmitIEs",null);return q}async resubmitPendings(){let[q,$]=await this.root.execute("admin.tasks.resubmitPendings",null);return q}async getFullTextSearchDatabase(){let[q,$]=await this.root.execute("admin.tasks.getFullTextSearchDatabase",null);return $[0]}async updateSemanticSearchDatabase(q,$){let[w,f]=await this.root.execute("admin.tasks.updateSemanticSearchDatabase",q,[$]);return w}}class kT_{root;constructor(q){this.root=q}async getCounters(){let[q,$]=await this.root.execute("admin.stats.getCounters",null);return q}async getDistributionOfVerdicts(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfVerdicts",null);return q}async getDistributionOfVerdictsByYear(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfVerdictsByYear",null);return q}async getDistributionOfCompilers(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfCompilers",null);return q}async getDistributionOfProglangs(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfProglangs",null);return q}async getDistributionOfUsersByYear(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfUsersByYear",null);return q}async getDistributionOfUsersByCountry(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfUsersByCountry",null);return q}async getDistributionOfUsersBySubmissions(q){let[$,w]=await this.root.execute("admin.stats.getDistributionOfUsersBySubmissions",q);return $}async getRankingOfUsers(q){let[$,w]=await this.root.execute("admin.stats.getRankingOfUsers",q);return $}async getDistributionOfSubmissionsByHour(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByHour",null);return q}async getDistributionOfSubmissionsByProglang(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByProglang",null);return q}async getDistributionOfSubmissionsByCompiler(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByCompiler",null);return q}async getDistributionOfSubmissionsByWeekday(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByWeekday",null);return q}async getDistributionOfSubmissionsByYear(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByYear",null);return q}async getDistributionOfSubmissionsByYearForProglang(q){let[$,w]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByYearForProglang",q);return $}async getDistributionOfSubmissionsByDay(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByDay",null);return q}async getHeatmapCalendarOfSubmissions(q){let[$,w]=await this.root.execute("admin.stats.getHeatmapCalendarOfSubmissions",q);return $}async getDistributionOfDomains(){let[q,$]=await this.root.execute("admin.stats.getDistributionOfDomains",null);return q}}class OT_{root;constructor(q){this.root=q}async getSolutions(q){let[$,w]=await this.root.execute("admin.problems.getSolutions",q);return $}async getSolutionAsB64(q){let[$,w]=await this.root.execute("admin.problems.getSolutionAsB64",q);return $}async getSolutionAsFile(q){let[$,w]=await this.root.execute("admin.problems.getSolutionAsFile",q);return w[0]}async getProblemSummary(q){let[$,w]=await this.root.execute("admin.problems.getProblemSummary",q);return $}async getProblemsWithSummary(){let[q,$]=await this.root.execute("admin.problems.getProblemsWithSummary",null);return q}async getProblemsWithoutSummary(){let[q,$]=await this.root.execute("admin.problems.getProblemsWithoutSummary",null);return q}async getAbstractProblemSolutionTags(q){let[$,w]=await this.root.execute("admin.problems.getAbstractProblemSolutionTags",q);return $}async getAbstractProblemsWithSolutionTags(){let[q,$]=await this.root.execute("admin.problems.getAbstractProblemsWithSolutionTags",null);return q}async getAbstractProblemsWithoutSolutionTags(){let[q,$]=await this.root.execute("admin.problems.getAbstractProblemsWithoutSolutionTags",null);return q}}class WT_{root;check;playground;constructor(q){this.root=q,this.check=new vT_(q),this.playground=new TT_(q)}}class vT_{root;constructor(q){this.root=q}async checkUser(){let[q,$]=await this.root.execute("testing.check.checkUser",null);return q}async checkInstructor(){let[q,$]=await this.root.execute("testing.check.checkInstructor",null);return q}async checkAdmin(){let[q,$]=await this.root.execute("testing.check.checkAdmin",null);return q}async throwError(q){let[$,w]=await this.root.execute("testing.check.throwError",q);return $}}class TT_{root;constructor(q){this.root=q}async upload(q,$){let[w,f]=await this.root.execute("testing.playground.upload",q,[$]);return w}async negate(q){let[$,w]=await this.root.execute("testing.playground.negate",null,[q]);return w[0]}async download(q){let[$,w]=await this.root.execute("testing.playground.download",q);return w[0]}async download2(q){let[$,w]=await this.root.execute("testing.playground.download2",q);return[$,w[0]]}async ping(){let[q,$]=await this.root.execute("testing.playground.ping",null);return q}async toUpperCase(q){let[$,w]=await this.root.execute("testing.playground.toUpperCase",q);return $}async add2i(q){let[$,w]=await this.root.execute("testing.playground.add2i",q);return $}async add2f(q){let[$,w]=await this.root.execute("testing.playground.add2f",q);return $}async inc(q){let[$,w]=await this.root.execute("testing.playground.inc",q);return $}async add3i(q){let[$,w]=await this.root.execute("testing.playground.add3i",q);return $}async something(q){let[$,w]=await this.root.execute("testing.playground.something",q);return $}async clock(){let[q,$]=await this.root.execute("testing.playground.clock",null);return q}}sq();async function LR6(q){u.tryTo("Try to get password from credentials file");let $=await cR6(q);if($)return u.trySuccess(),$;u.tryFailure(),u.tryTo("Try to get password from JUTGE_PASSWORD environment variable");let w=process.env.JUTGE_PASSWORD;if(w)return u.trySuccess(),w;u.tryFailure(),u.print("Prompting for password");let f=await rR6(q);if(f)return u.trySuccess(),f;u.tryFailure();return}async function cR6(q){let $=await kA();if(!$)return;let w=Object.values($).find((f)=>f.email===q);if(!w)return;if(!w.savedPassword)return;return atob(w.savedPassword)}async function xR6(){u.tryTo("Try to get email from JUTGE_EMAIL environment variable");let q=process.env.JUTGE_EMAIL;if(q)return u.trySuccess(),q;u.tryFailure(),u.tryTo("Try to get email from credentials file");let $=await dR6();if($)return u.trySuccess(),$;u.tryFailure(),u.print("Prompting for email");let w=await lR6();if(w)return w;return}async function dR6(){let q=await kA();if(!q)return;let $=Object.values(q).find((w)=>w.active===!0);if(!$)return;return $.email}async function XT_(){return await A3({message:"Jutge.org email:",default:z8.email||""})}async function lR6(){let q=await kA();if(!q||Object.values(q).length===0)return XT_();let $=Object.values(q).map((f)=>({name:f.email,value:f.email})).sort();$.push({name:"Other",value:"other"});let w=await x4({message:"Select email:",choices:$});if(w==="other")return XT_();return w}async function rR6(q){return await ZZ({message:`Jutge.org password for ${q}:`})}async function pR6(){u.tryTo("Try to get token from JUTGE_TOKEN environment variable");let q=process.env.JUTGE_TOKEN;if(q)return u.trySuccess(),q;u.tryFailure(),u.tryTo("Try to get token from credentials file");let $=await iR6();if($)return u.trySuccess(),$;u.tryFailure();return}async function iR6(){let q=await kA();if(!q)return;let $=Object.values(q).find((w)=>w.active===!0);if(!$)return;return $.token}async function nR6(){let q=tJ("jutge",{suffix:"cli"}),$=mR6(q.config,"credentials.json");if(!await SR6($))return;let w=await OX($);return y8_.parse(w)}var kA=Wk(nR6,{ttl:1000});async function aR6(q){let $=await u.section("Getting name from profile",async()=>{try{return await q.student.profile.get()}catch(w){throw u.error("Could not get profile, check your credentials or internet connection"),w}});u.success(`Logged in as ${$.name} with email ${$.email}`)}async function BR6(q){let $=await pR6();if($){let K={token:$};q.meta=K;return}let w=await xR6();if(!w)throw Error("Could not log in");u.success(`Email: ${w}`);let f=await LR6(w);if(!f)throw Error("Could not log in");u.success(`Password: ${"*".repeat(f.length)}`),await q.login({email:w,password:f});return}async function D4(){return await u.section("Logging in to Jutge.org",async()=>{let q=new qK;return await BR6(q),await aR6(q),q})}async function CT_(q,$){let w=await D4();await u.section(`Downloading problem ${q} from Jutge.org`,async()=>{let f=await w.instructor.problems.download(q);await tR6(f.data,$);let K=uT_.default($,{allFiles:!0,dirsFirst:!1});u.print(K),u.success(`Problem downloaded to ${u.hyperlink($)}`),await MD($)})}async function tR6(q,$){if(await FR6($))throw Error(`Directory ${$} already exists`);await oR6($,{recursive:!0}),new GT_.default(Buffer.from(q)).extractAllTo($,!0);let f=await AT_($);if(f.length===1){let K=ql($,f[0]);if(await my(K))await eR6($,K)}}async function eR6(q,$){let w=await AT_($);for(let f of w){let K=ql($,f),z=ql(q,f);if((await QR6(K)).isDirectory())await jT_(K,z,{recursive:!0});else await jT_(K,z)}await UR6($,{recursive:!0})}var VT_=new G6("download").summary("Download a problem from Jutge.org").argument("<problem_nm>","problem to download").option("-d, --directory <path>","output directory (default: <problem_nm>.pbm)").action(async(q,{directory:$})=>{let w=$??`${q}.pbm`;if(!w.endsWith(".pbm"))throw Error("Output directory must end with .pbm");await CT_(q,w)});var MT_=new G6("doctor").description("Diagnose status of the environment").action(async()=>{await u.section("Diagnosing environment",async()=>{await u.section("Checking Python3 installation",lW_),await u.section("Checking C/C++ installation",rW_),await u.section("Checking Haskell installation",pW_),await u.section("Checking Clojure installation",iW_),await u.section("Checking Java installation",nW_),await u.section("Checking Rust installation",aW_),await u.section("Checking Verilog installation",BW_),await u.section("Checking R installation",FW_),await u.section("Checking CodeMetrics installation",oW_),await u.section("Checking XeLaTeX installation",UW_),await u.section("Checking Pandoc installation",QW_),await u.section("Checking terminal",tW_)})});var QG_=z6(nj_(),1);import{exists as HL6}from"fs/promises";import{join as UG_}from"path";sq();async function kq(q,$,w,f,K){return await new cD(q,$,w,f).complete(K)}class cD{jutge;model;label;messages;constructor(q,$,w,f){this.jutge=q,this.model=$,this.label=w,this.messages=[{role:"system",content:f}]}async complete(q){this.messages.push({role:"user",content:q});let $=3,w="";for(let f=0;f<$;f++)try{w=await this.interact();break}catch(K){if(K instanceof Error)u.error(K.message);else u.error("An unknown error occurred");u.action("Retrying after 1 second..."),await Ok(1000)}if(w==="")return u.error(`Failed to get response after ${$} attempts`),"Failed to get response";return this.messages.push({role:"assistant",content:w}),w}async interact(){let q="";if(z8.showPrompts)u.print(`Prompt: (${this.messages.length})`),u.print(y_.gray(this.messages[this.messages.length-1].content)),u.print("Reading response...");let{id:$}=await this.jutge.instructor.jutgeai.chat({model:this.model,label:this.label,messages:this.messages,addUsage:!1}),w=await fetch(`${this.jutge.JUTGE_API_URL}/webstreams/${$}`,{method:"GET"});if(!w.body)throw Error("No response body");if(w.status!==200)throw u.error(`Failed to get response: Status ${w.status}`),Error("Failed to get response");let f=w.body.getReader();while(!0){let{done:K,value:z}=await f.read();if(K)break;let P=new TextDecoder().decode(z);if(q+=P,z8.showAnswers)process.stdout.write(y_.gray(P))}if(z8.showAnswers)process.stdout.write(`
|
|
626
|
+
`);return q}forgetLastInteraction(){if(this.messages.length>2)this.messages.pop(),this.messages.pop()}}function a4(q){let $=/^\n*```\w*\s*(.*?)\s*```\n*$/s;return q.replace($,"$1")}var aj_={"openai/gpt-5.4":{input:2.5,output:15},"openai/gpt-5.4-mini":{input:0.75,output:4.5},"openai/gpt-5.4-nano":{input:0.2,output:1.25},"openai/gpt-4.1":{input:2,output:8},"openai/gpt-4.1-mini":{input:0.4,output:1.6},"openai/gpt-4.1-nano":{input:0.1,output:0.4},"openai/gpt-5":{input:1.25,output:10},"openai/gpt-5-mini":{input:0.25,output:2},"openai/gpt-5-nano":{input:0.05,output:0.4},"google/gemini-2.5-pro":{input:1.25,output:10},"google/gemini-2.5-flash":{input:0.3,output:2.5},"google/gemini-2.5-flash-lite":{input:0.1,output:0.4}};function Om6(q,$,w){if(!Object.keys(aj_).includes(w))throw Error(`Model not supported: ${w}`);let f=aj_[w],K=q*f.input/1e6,z=$*f.output/1e6;return K+z}async function Wm6(q){try{let f=(await(await fetch("https://api.frankfurter.dev/v1/latest?base=EUR&symbols=USD")).json()).rates.USD;return q/f}catch($){return u.error("Failed to convert dolars to euros"),q*0.85}}var vm6=Wk(Wm6);function Tm6(q){return q*1.21}async function bA(q,$,w){let f=Tm6(await vm6(Om6(q,$,w))),K=0.000833,z=22000,D=(q+$)*0.000833,Y=D*3600,J=445,Z=D*445/1000,k=Z/22000,W=Z/170,v=1.8,X=4.5,j=6.3,A=D*6.3/1000,C=20,V=D*3600/20/3600;return{inputTokens:q,outputTokens:$,model:w,priceEurTax:f,wattHours:D,joules:Y,co2Grams:Z,carKm:W,trees:k,waterLiters:A,brainHours:V}}var pD=z6(Jk(),1);import{exists as qL6,mkdir as $L6}from"fs/promises";var Rk=(q,$=[])=>q.name==="up"||$.includes("vim")&&q.name==="k"||$.includes("emacs")&&q.ctrl&&q.name==="p",IA=(q,$=[])=>q.name==="down"||$.includes("vim")&&q.name==="j"||$.includes("emacs")&&q.ctrl&&q.name==="n",hl=(q)=>q.name==="space";var El=(q)=>q.name==="enter"||q.name==="return";class gl extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(q){super();this.cause=q?.cause}}class Rl extends Error{name="CancelPromptError";message="Prompt was canceled"}class yA extends Error{name="ExitPromptError"}class bl extends Error{name="HookError"}class PK extends Error{name="ValidationError"}import{AsyncResource as Am6}from"async_hooks";import{AsyncLocalStorage as Xm6,AsyncResource as jm6}from"async_hooks";var Bj_=new Xm6;function Gm6(q){return{rl:q,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Fj_(q,$){let w=Gm6(q);return Bj_.run(w,()=>{function f(K){w.handleChange=()=>{w.index=0,K()},w.handleChange()}return $(f)})}function DK(){let q=Bj_.getStore();if(!q)throw new bl("[Inquirer] Hook functions can only be called from within a prompt");return q}function Il(){return DK().rl}function yl(q){let $=(...w)=>{let f=DK(),K=!1,z=f.handleChange;f.handleChange=()=>{K=!0};let P=q(...w);if(K)z();return f.handleChange=z,P};return jm6.bind($)}function xD(q){let $=DK(),{index:w}=$,f={get(){return $.hooks[w]},set(z){$.hooks[w]=z},initialized:w in $.hooks},K=q(f);return $.index++,K}function oj_(){DK().handleChange()}var YK={queue(q){let $=DK(),{index:w}=$;$.hooksEffect.push(()=>{$.hooksCleanup[w]?.();let f=q(Il());if(f!=null&&typeof f!=="function")throw new PK("useEffect return value must be a cleanup function or nothing.");$.hooksCleanup[w]=f})},run(){let q=DK();yl(()=>{q.hooksEffect.forEach(($)=>{$()}),q.hooksEffect.length=0})()},clearAll(){let q=DK();q.hooksCleanup.forEach(($)=>{$?.()}),q.hooksEffect.length=0,q.hooksCleanup.length=0}};function p1(q){return xD(($)=>{let w=Am6.bind(function(z){if($.get()!==z)$.set(z),oj_()});if($.initialized)return[$.get(),w];let f=typeof q==="function"?q():q;return $.set(f),[f,w]})}function JK(q,$){xD((w)=>{let f=w.get();if(!Array.isArray(f)||$.some((z,P)=>!Object.is(z,f[P])))YK.queue(q);w.set($)})}var q2=z6(Sl(),1);import t$ from"process";function Vm6(){if(t$.platform!=="win32")return t$.env.TERM!=="linux";return Boolean(t$.env.WT_SESSION)||Boolean(t$.env.TERMINUS_SUBLIME)||t$.env.ConEmuTask==="{cmd::Cmder}"||t$.env.TERM_PROGRAM==="Terminus-Sublime"||t$.env.TERM_PROGRAM==="vscode"||t$.env.TERM==="xterm-256color"||t$.env.TERM==="alacritty"||t$.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Qj_={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},tj_={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},Mm6={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},Nm6={...Qj_,...tj_},hm6={...Qj_,...Mm6},Em6=Vm6(),gm6=Em6?Nm6:hm6,v9=gm6,GS8=Object.entries(tj_);var ej_={prefix:{idle:q2.default.blue("?"),done:q2.default.green(v9.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map((q)=>q2.default.yellow(q))},style:{answer:q2.default.cyan,message:q2.default.bold,error:(q)=>q2.default.red(`> ${q}`),defaultAnswer:(q)=>q2.default.dim(`(${q})`),help:q2.default.dim,highlight:q2.default.cyan,key:(q)=>q2.default.cyan(q2.default.bold(`<${q}>`))}};function sj_(q){if(typeof q!=="object"||q===null)return!1;let $=q;while(Object.getPrototypeOf($)!==null)$=Object.getPrototypeOf($);return Object.getPrototypeOf(q)===$}function _G_(...q){let $={};for(let w of q)for(let[f,K]of Object.entries(w)){let z=$[f];$[f]=sj_(z)&&sj_(K)?_G_(z,K):K}return $}function bk(...q){let $=[ej_,...q.filter((w)=>w!=null)];return _G_(...$)}function ml({status:q="idle",theme:$}){let[w,f]=p1(!1),[K,z]=p1(0),{prefix:P,spinner:D}=bk($);if(JK(()=>{if(q==="loading"){let J,Z=-1,k=setTimeout(()=>{f(!0),J=setInterval(()=>{Z=Z+1,z(Z%D.frames.length)},D.interval)},300);return()=>{clearTimeout(k),clearInterval(J)}}else f(!1)},[q]),w)return D.frames[K];return typeof P==="string"?P:P[q==="loading"?"idle":q]??P.idle}function Ll(q,$){return xD((w)=>{let f=w.get();if(!f||f.dependencies.length!==$.length||f.dependencies.some((K,z)=>K!==$[z])){let K=q();return w.set({value:K,dependencies:$}),K}return f.value})}function SA(q){return p1({current:q})[0]}function cl(q){let $=SA(q);$.current=q,JK((w)=>{let f=!1,K=yl((z,P)=>{if(f)return;$.current(P,w)});return w.input.on("keypress",K),()=>{f=!0,w.input.removeListener("keypress",K)}},[])}var TG_=z6(C5(),1),XG_=z6(vG_(),1);function yk(q,$){return q.split(`
|
|
627
627
|
`).flatMap((w)=>XG_.default(w,$,{trim:!1,hard:!0}).split(`
|
|
628
628
|
`).map((f)=>f.trimEnd())).join(`
|
|
629
629
|
`)}function LA(){return TG_.default({defaultWidth:80,output:Il().output})}function lm6({active:q,renderedItems:$,pageSize:w,loop:f}){let K=SA({lastPointer:q,lastActive:void 0}),{lastPointer:z,lastActive:P}=K.current,D=Math.floor(w/2),Y=$.reduce((k,W)=>k+W.length,0),J=$.slice(0,q).reduce((k,W)=>k+W.length,0),Z=J;if(Y>w)if(f){if(Z=z,P!=null&&P<q&&q-P<w)Z=Math.min(D,Math.abs(q-P)===1?Math.min(z+($[P]?.length??0),Math.max(J,z)):z+q-P)}else{let k=$.slice(q).reduce((W,v)=>W+v.length,0);Z=k<w-D?w-k:Math.min(J,D)}return K.current.lastPointer=Z,K.current.lastActive=q,Z}function il({items:q,active:$,renderItem:w,pageSize:f,loop:K=!0}){let z=LA(),P=(C)=>(C%q.length+q.length)%q.length,D=q.map((C,N)=>{if(C==null)return[];return yk(w({item:C,index:N,isActive:N===$}),z).split(`
|
|
@@ -1047,4 +1047,4 @@ ${Z.join(`
|
|
|
1047
1047
|
`;await RS_(Y,(J??"")+k,"utf-8");let W=Z.length===2?"fpath and compinit":Z.length===1&&Z[0].includes("fpath")?"fpath":"compinit";u.success(`Updated ${u.hyperlink(Y)} (added ${W})`)}u.print("Restart your shell to use completions.")}else if($==="fish"){let z=Z7(w,".config","fish","completions"),P=Z7(z,"jtk.fish");await iC(z,{recursive:!0});let D=await K(P,SS_());u.success(D==="created"?`Created ${u.hyperlink(P)}`:`Updated ${u.hyperlink(P)}`),u.print("Restart your shell to use completions.")}else if($==="powershell"){let z=Z7(w,".config","powershell");await iC(z,{recursive:!0});let P=Z7(z,"jtk-completion.ps1"),D=await K(P,mS_());u.success(D==="created"?`Created ${u.hyperlink(P)}`:`Updated ${u.hyperlink(P)}`),u.print('Load it in this session: . "'+P.replace(/'/g,"''")+'"'),u.print("To load automatically, add the line above to your $PROFILE.")}else u.print(`Unknown or unsupported shell: ${$}`),u.print("Use: jtk completion install bash|zsh|fish|powershell")});function V88(){let q=process.env.SHELL||"";if(q.includes("fish"))return"fish";if(q.includes("zsh"))return"zsh";if(q.includes("bash"))return"bash";if(process.env.PSModulePath)return"powershell";return"bash"}function LS_(q){return q.createHelp().visibleCommands(q).filter((w)=>w.name()!=="help")}function xS_(q){return q.options.filter(($)=>!$.hidden&&$.long!=="help"&&$.long!=="version"&&!$.negate)}function M88(q){return[...q.registeredArguments]}function N88(q){let $=q.summary?.();if($)return $;let w=q.description();return w?w.split(`
|
|
1048
1048
|
`)[0].trim():q.name()}async function Bn(q,$){let w=$.length===0?q:cS_(q,$),f=LS_(w);if(f.length===0)return{path:$,cmd:w};let K=f.map((J)=>({name:`${J.name()} \u2014 ${N88(J)}`,value:J.name()})),z=await x4({message:$.length===0?"What do you want to do?":`Choose ${w.name()} subcommand:`,choices:[...K,{name:"\u2190 Back",value:"__back__"}]});if(z==="__back__"){if($.length===0)return{path:[],cmd:q};return Bn(q,$.slice(0,-1))}let P=[...$,z],D=cS_(q,P);if(LS_(D).length>0)return Bn(q,P);return{path:P,cmd:D}}function cS_(q,$){let w=q;for(let f of $){let K=w.commands.find((z)=>z.name()===f);if(!K)return null;w=K}return w}async function h88(q,$){let w=q.name(),f=q.description||w,K=q.defaultValue,z=q.argChoices,P=q.variadic,D=q.required,Y=f+(D?"":" (optional)");if(z&&z.length>0)return await x4({message:Y,choices:z.map((W)=>({name:W,value:W})),default:K!=null?Array.isArray(K)?K[0]:K:void 0});let J=K!=null?Array.isArray(K)?K.join(" "):String(K):D?void 0:"",Z=await A3({message:Y,default:J,validate:(k)=>D&&!k.trim()?"This argument is required":!0});if(P&&Z.includes(" "))return Z.trim().split(/\s+/).filter(Boolean);return Z.trim()||J}async function E88(q){let $=q.attributeName(),w=q.description||q.long||q.flags,f=q.defaultValue,K=q.argChoices;if(q.isBoolean()){let Y=await G3({message:w,default:f===!0});return{name:$,value:Y}}if(K&&K.length>0){let Y=await x4({message:w,choices:K.map((J)=>({name:J,value:J})),default:f!=null?String(f):void 0});return{name:$,value:Y}}let P=f!=null?String(f):"",D=await A3({message:w+(q.required?"":" (optional)"),default:P});if(D===""&&!q.required)return null;return{name:$,value:D}}function g88(q,$,w,f){let K=[...q],z=[];for(let P of w)if(Array.isArray(P))z.push(...P);else if(P!=="")z.push(P);K.push(...z);for(let P of xS_($)){let D=P.attributeName(),Y=f[D];if(Y===void 0)continue;if(P.isBoolean()){if(Y===!0)K.push(P.long.startsWith("--")?P.long:`--${P.long}`);else if(Y===!1){let J=$.options.find((Z)=>Z.negate&&Z.attributeName()===D);if(J?.long)K.push(J.long.startsWith("--")?J.long:`--${J.long}`)}}else if(Y!==""&&Y!=null){let J=P.long.startsWith("--")?P.long:`--${P.long}`;K.push(J,String(Y))}}return K}var dS_=new G6("for-dummies").alias("interactive").summary("Interactive menu for all toolkit tasks").description("Run a guided flow of menus and prompts to perform any toolkit task. Help and defaults are taken from the command definitions.").action(async function(){let q=this.parent;if(!q)throw Error("Dummies command must be run under the main program");let{path:$,cmd:w}=await Bn(q,[]);if($.length===0)return;let f=M88(w),K=xS_(w),z=[];for(let Y of f){let J=await h88(Y,z.flat(1));z.push(J)}let P={};for(let Y of K){let J=await E88(Y);if(J)P[J.name]=J.value}let D=g88($,w,z,P);await q.parseAsync(D,{from:"user"})});J8.name(Object.keys(r3.bin)[0]);J8.alias(Object.keys(r3.bin)[1]);J8.version(r3.version);J8.description(r3.description);J8.helpCommand("help [command]","Display help for command");J8.addHelpText("after",`
|
|
1049
1049
|
More documentation:
|
|
1050
|
-
https://github.com/jutge-org/
|
|
1050
|
+
https://github.com/jutge-org/jutge-toolkit/tree/main/docs`);J8.addCommand(VA_);J8.addCommand(Vy_);J8.addCommand(Ny_);J8.addCommand(dC);J8.addCommand(Xv_);J8.addCommand(Sv_);J8.addCommand(VT_);J8.addCommand(o2);J8.addCommand(Ov_);J8.addCommand(CA_);J8.addCommand(vS_);J8.addCommand(Iy_);J8.addCommand(lC);J8.addCommand(OS_);J8.addCommand(MT_);J8.addCommand(aD);if(z8.developer)J8.addCommand(wA);J8.addCommand(r5);J8.addCommand(yA_);J8.addCommand(Dw);J8.addCommand(iZ_);J8.addCommand(Sy_);J8.addCommand(bS_,{hidden:!0});J8.addCommand(dS_);try{await J8.parseAsync(),process.exit(process.exitCode??0)}catch(q){if(console.log(),console.error("An error occurred:"),q instanceof Error){if(q.name==="ExitPromptError")console.error("Operation cancelled by the user");else if(q instanceof d7)console.error(D5(q).toString());else if(console.error(q.message),z8.developer)console.error(q)}else console.error(q);process.exit(1)}
|
package/docs/reference.md
CHANGED
|
@@ -31,7 +31,7 @@ Global options on the main program:
|
|
|
31
31
|
- **`-V`, `--version`** — Print the toolkit version and exit.
|
|
32
32
|
- **`-h`, `--help`** — Show help.
|
|
33
33
|
|
|
34
|
-
More documentation: [toolkit docs on GitHub](https://github.com/jutge-org/
|
|
34
|
+
More documentation: [toolkit docs on GitHub](https://github.com/jutge-org/jutge-toolkit/tree/main/docs).
|
|
35
35
|
|
|
36
36
|
---
|
|
37
37
|
|
package/package.json
CHANGED
package/toolkit/about.ts
CHANGED
|
@@ -23,7 +23,7 @@ export const aboutCmd = new Command('about')
|
|
|
23
23
|
}
|
|
24
24
|
tui.print('')
|
|
25
25
|
tui.print('Documentation:')
|
|
26
|
-
tui.url('https://github.com/jutge-org/
|
|
26
|
+
tui.url('https://github.com/jutge-org/jutge-toolkit/tree/main/docs')
|
|
27
27
|
})
|
|
28
28
|
|
|
29
29
|
function showPerson(person: string | { name: string; email?: string; url?: string }) {
|
package/toolkit/index.ts
CHANGED
|
@@ -34,7 +34,7 @@ program.alias(Object.keys(packageJson.bin as Record<string, string>)[1] as strin
|
|
|
34
34
|
program.version(packageJson.version)
|
|
35
35
|
program.description(packageJson.description!)
|
|
36
36
|
program.helpCommand('help [command]', 'Display help for command') // To get the message with uppercase :-)
|
|
37
|
-
program.addHelpText('after', '\nMore documentation:\n https://github.com/jutge-org/
|
|
37
|
+
program.addHelpText('after', '\nMore documentation:\n https://github.com/jutge-org/jutge-toolkit/tree/main/docs')
|
|
38
38
|
|
|
39
39
|
program.addCommand(makeCmd)
|
|
40
40
|
program.addCommand(uploadCmd)
|