@jutge.org/toolkit 4.2.9 → 4.2.10
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/latex/root-pdf.tpl.tex +11 -6
- package/assets/latex/root-text-short.tpl.tex +22 -0
- package/assets/latex/root-text.tpl.tex +13 -6
- package/assets/sty/jutge.ca.sty +3 -3
- package/assets/sty/jutge.de.sty +3 -3
- package/assets/sty/jutge.en.sty +3 -3
- package/assets/sty/jutge.es.sty +3 -3
- package/assets/sty/jutge.fr.sty +4 -5
- package/dist/index.js +3 -3
- package/package.json +1 -1
- package/toolkit/make.ts +3 -2
|
@@ -14,16 +14,21 @@
|
|
|
14
14
|
|
|
15
15
|
\ProblemInformation
|
|
16
16
|
|
|
17
|
-
\Author
|
|
18
|
-
|
|
17
|
+
\Author\ {{author}}
|
|
19
18
|
{{#if translator}}
|
|
20
|
-
|
|
19
|
+
\\
|
|
20
|
+
\Translator {{translator}}
|
|
21
21
|
{{/if}}
|
|
22
22
|
|
|
23
|
-
\
|
|
23
|
+
\bigskip
|
|
24
|
+
|
|
25
|
+
\Generation {{date}}
|
|
26
|
+
|
|
27
|
+
\bigskip
|
|
24
28
|
|
|
25
|
-
\
|
|
29
|
+
\copyright\ \emph{Jutge.org}, 2006--{{year}}.
|
|
30
|
+
\\
|
|
31
|
+
\href{https://jutge.org}{https://jutge.org}
|
|
26
32
|
|
|
27
|
-
Draft generated with \textbf{new-jutge-toolkit}.
|
|
28
33
|
|
|
29
34
|
\end{document}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
\documentclass[11pt]{article}
|
|
3
|
+
|
|
4
|
+
\usepackage{jutge}
|
|
5
|
+
\usepackage{{curly jutgeLanguage}}
|
|
6
|
+
|
|
7
|
+
% redefine commands to simplify text output
|
|
8
|
+
\renewcommand{\Sample}{}
|
|
9
|
+
\renewcommand{\Statement}{}
|
|
10
|
+
\renewcommand{\Problem}[1]{}. % hide problem title
|
|
11
|
+
\ProblemId{} % hide problem id
|
|
12
|
+
|
|
13
|
+
% redefine figure commands to avoid troubles with \parpic
|
|
14
|
+
\renewcommand{\FigureL}[2]{\includegraphics[#1]{#2}}
|
|
15
|
+
\renewcommand{\FigureC}[2]{\includegraphics[#1]{#2}}
|
|
16
|
+
\renewcommand{\FigureR}[2]{\includegraphics[#1]{#2}}
|
|
17
|
+
|
|
18
|
+
\begin{document}
|
|
19
|
+
|
|
20
|
+
\DoProblem{{curly language}}
|
|
21
|
+
|
|
22
|
+
\end{document}
|
|
@@ -19,16 +19,23 @@
|
|
|
19
19
|
|
|
20
20
|
\DoProblem{{curly language}}
|
|
21
21
|
|
|
22
|
+
\ProblemInformation
|
|
22
23
|
|
|
23
|
-
\
|
|
24
|
-
{{author}}
|
|
25
|
-
|
|
24
|
+
\Author\ {{author}}
|
|
26
25
|
{{#if translator}}
|
|
27
|
-
|
|
26
|
+
\\
|
|
27
|
+
\Translator {{translator}}
|
|
28
28
|
{{/if}}
|
|
29
29
|
|
|
30
|
-
\
|
|
30
|
+
\bigskip
|
|
31
|
+
|
|
32
|
+
\Generation {{date}}
|
|
33
|
+
|
|
34
|
+
\bigskip
|
|
35
|
+
|
|
36
|
+
\copyright\ \emph{Jutge.org}, 2006--{{year}}.
|
|
37
|
+
\\
|
|
38
|
+
\href{https://jutge.org}{https://jutge.org}
|
|
31
39
|
|
|
32
|
-
Draft generated with \textbf{new-jutge-toolkit}.
|
|
33
40
|
|
|
34
41
|
\end{document}
|
package/assets/sty/jutge.ca.sty
CHANGED
|
@@ -49,6 +49,6 @@
|
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
\newcommand{\TxtProblemInformation}{Informació del problema}
|
|
52
|
-
\newcommand{\TxtAuthor}{
|
|
53
|
-
\newcommand{\TxtTranslator}{
|
|
54
|
-
\newcommand{\TxtGeneration}{
|
|
52
|
+
\newcommand{\TxtAuthor}{Autoria:}
|
|
53
|
+
\newcommand{\TxtTranslator}{Traducció:}
|
|
54
|
+
\newcommand{\TxtGeneration}{Generació:}
|
package/assets/sty/jutge.de.sty
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
%\usepackage[ngerman]{babel}
|
|
5
5
|
|
|
6
6
|
\newcommand{\TxtProblemInformation}{Informationen zum Problem}
|
|
7
|
-
\newcommand{\TxtAuthor}{Autor}
|
|
8
|
-
\newcommand{\TxtTranslator}{Übersetzer}
|
|
9
|
-
\newcommand{\TxtGeneration}{Erstellt}
|
|
7
|
+
\newcommand{\TxtAuthor}{Autor:}
|
|
8
|
+
\newcommand{\TxtTranslator}{Übersetzer:}
|
|
9
|
+
\newcommand{\TxtGeneration}{Erstellt:}
|
|
10
10
|
\newcommand{\TxtInterface}{Interface}
|
|
11
11
|
|
|
12
12
|
\newcommand{\TxtInput}{Eingabe}
|
package/assets/sty/jutge.en.sty
CHANGED
|
@@ -55,6 +55,6 @@
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
\newcommand{\TxtProblemInformation}{Problem information}
|
|
58
|
-
\newcommand{\TxtAuthor}{Author}
|
|
59
|
-
\newcommand{\TxtTranslator}{Translator}
|
|
60
|
-
\newcommand{\TxtGeneration}{Generation}
|
|
58
|
+
\newcommand{\TxtAuthor}{Author:}
|
|
59
|
+
\newcommand{\TxtTranslator}{Translator:}
|
|
60
|
+
\newcommand{\TxtGeneration}{Generation:}
|
package/assets/sty/jutge.es.sty
CHANGED
|
@@ -49,6 +49,6 @@
|
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
\newcommand{\TxtProblemInformation}{Información del problema}
|
|
52
|
-
\newcommand{\TxtAuthor}{
|
|
53
|
-
\newcommand{\TxtTranslator}{
|
|
54
|
-
\newcommand{\TxtGeneration}{Generación}
|
|
52
|
+
\newcommand{\TxtAuthor}{Autoría:}
|
|
53
|
+
\newcommand{\TxtTranslator}{Traducción:}
|
|
54
|
+
\newcommand{\TxtGeneration}{Generación:}
|
package/assets/sty/jutge.fr.sty
CHANGED
|
@@ -52,8 +52,7 @@
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
\newcommand{\TxtProblemInformation}{
|
|
56
|
-
\newcommand{\TxtAuthor}{
|
|
57
|
-
\newcommand{\TxtTranslator}{
|
|
58
|
-
\newcommand{\TxtGeneration}{
|
|
59
|
-
|
|
55
|
+
\newcommand{\TxtProblemInformation}{Information du problème}
|
|
56
|
+
\newcommand{\TxtAuthor}{Auteur:}
|
|
57
|
+
\newcommand{\TxtTranslator}{Traducteur:}
|
|
58
|
+
\newcommand{\TxtGeneration}{Génération:}
|
package/dist/index.js
CHANGED
|
@@ -3851,13 +3851,13 @@ main = do
|
|
|
3851
3851
|
`))if(W.trim()==="")J+=`
|
|
3852
3852
|
`;else J+=`(println ${W})
|
|
3853
3853
|
`;await f3(ke($,Y),J)}}class ge extends a${id(){return"Verilog"}name(){return"Verilog"}type(){return"formal methods"}language(){return"Verilog"}async version(){return await c9(),"Verilog Fake Compiler"}flags1(){return""}flags2(){return""}tool(){return"Verilog"}extension(){return"v"}async compileNormal($,q,K){let Y=`${K}.exe`;return await Vq(q,Y,`echo "This is a fake executable for Verilog source ${K}"
|
|
3854
|
-
`),Y}async execute($,q,K,Y,w){}}var vB={C:ve,"C++":Ee,Python3:je,Haskell:Ie,Clojure:Re,Java:Le,Rust:Se,Verilog:ge,RunPython:EG6,RunHaskell:jG6,RunClojure:IG6},ra1={c:ve,cc:Ee,py:je,hs:Ie,clj:Re,java:Le,rs:Se,v:ge};function EB($){let q=vB[$];if(!q)throw Error(`Compiler '${$}' is not defined`);return new q}function RG6($){let q=ra1[$];if(!q)throw Error(`No compiler defined for extension '.${$}'`);return new q}async function cR8(){return await c9(),Object.keys(vB)}async function lR8(){let $=[];for(let q of Object.keys(vB))if(await new vB[q]().available())$.push(q);return $}async function oa1($){let q=EB($);if(!q)throw Error(`Compiler '${$}' is not defined`);return await q.info()}async function pR8(){let $={};for(let q of Object.keys(vB))$[q]=await oa1(q);return $}KZ();import{exists as BI,glob as uG6}from"fs/promises";import{basename as sa1,join as j0,normalize as eR8,sep as $L8}from"path";KZ();async function _H($){let q=new qL8($);return await q.load(),q}class qL8{directory;structure="multi";language=null;handler;languages=[];originalLanguage=null;problemYml=null;problemLangYmls={};solutions=[];goldenSolution=null;testcases=[];constructor($){if($==="."||$==="./"||!$)this.directory=eR8(process.cwd());else this.directory=eR8(j0($,"."))}async load(){await B.section(`Loading problem from ${this.directory}`,async()=>{await this.loadStructure(),await this.loadLanguages(),await this.loadHandler(),await this.loadProblemYml(),await this.loadOriginalLanguage(),await this.loadSolutions(),await this.loadGoldenSolution(),await this.loadTestcases(),await this.loadScores(),await this.loadAwards()});let $=!1;if(!this.originalLanguage)B.error("No original language found"),$=!0;if(!this.goldenSolution)B.error("No golden solution found"),$=!0;if($)throw Error("Inspection failed due to errors")}async loadStructure(){await B.section("Determining structure",async()=>{if(await c9(),this.directory.endsWith(".pbm"))this.structure="multi";else this.structure="single";console.log(this.structure)})}async loadLanguages(){await B.section("Loading languages",async()=>{if(this.structure==="multi")await this.loadLanguagesMulti();else await this.loadLanguagesSingle()})}async loadLanguagesMulti(){let q=(await Array.fromAsync(uG6("problem.*.yml",{cwd:this.directory}))).map((K)=>{let Y=K.match(/problem\.(.+)\.yml/);return Y?Y[1]:null}).filter((K)=>K&&(K in s5));this.languages=q,B.yaml(this.languages);for(let K of this.languages)await B.section(`Loading problem.${K}.yml`,async()=>{this.problemLangYmls[K]=await pJ(this.directory,`problem.${K}.yml`),B.yaml(this.problemLangYmls[K])})}async loadLanguagesSingle(){for(let $ of Object.keys(s5)){let q=j0(this.directory,"..",$,`problem.${$}.yml`);if(await BI(q))this.languages.push($)}B.yaml(this.languages);for(let $ of this.languages)await B.section(`Loading ..${$L8}${$}${$L8}problem.${$}.yml`,async()=>{this.problemLangYmls[$]=await pJ(j0(this.directory,"..",$),`problem.${$}.yml`),B.yaml(this.problemLangYmls[$])});this.language=sa1(this.directory)}async loadHandler(){await B.section("Loading handler.yml",async()=>{let $=await pJ(this.directory,"handler.yml");if(this.handler=ek6.parse($),this.handler.source_modifier==="structs")B.warning('source_modifier "structs" is deprecated, using "no_main" instead. please update handler.yml'),this.handler.source_modifier="no_main";if(this.handler.handler==="circuits")this.handler.solution="Verilog";if(B.yaml(this.handler),this.handler.handler==="quiz")throw Error('Handler "quiz" is not supported yet')})}async loadScores(){await B.section("Loading scores.yml",async()=>{if(await BI(j0(this.directory,"scores.yml"))){let $=await pJ(this.directory,"scores.yml"),q=$g6.parse($);B.yaml(q)}else B.print("scores.yml not defined")})}async loadProblemYml(){await B.section("Loading problem.yml",async()=>{if(await BI(j0(this.directory,"problem.yml"))){let $=await pJ(this.directory,"problem.yml"),q=xd.parse($);B.yaml(q)}else B.print("problem.yml not defined")})}async loadOriginalLanguage(){await B.section("Determining original language",async()=>{await c9();for(let $ of this.languages)if("author"in this.problemLangYmls[$]){this.originalLanguage=$;break}if(!this.originalLanguage)throw Error("No original language found (a language with an author field)");B.print(this.originalLanguage)})}async loadSolutions(){await B.section("Loading solutions",async()=>{let{proglangNames:$}=await Promise.resolve().then(() => (KZ(),yG6)),q=Object.keys($).join(","),K=await Array.fromAsync(uG6(`solution.{${q}}`,{cwd:this.directory}));if(this.solutions=K.sort(),B.yaml(this.solutions),this.solutions.length===0)throw Error("No solutions found")})}async loadGoldenSolution(){await B.section("Determining golden solution",async()=>{let{proglangExtensions:$}=await Promise.resolve().then(() => (KZ(),yG6));if(this.handler.handler==="circuits")this.goldenSolution="solution.v";else if(this.handler.compilers==="RunPython")this.goldenSolution="solution.py";else if(this.handler.compilers==="RunHaskell"||this.handler.compilers==="GHC")this.goldenSolution="solution.hs";else if(this.handler.compilers==="RunClojure"||this.handler.compilers==="Clojure")this.goldenSolution="solution.clj";else{let q=this.handler.solution,K=$[q];if(!K)throw Error(`Unknown programming language ${q} for solution`);let Y=j0(this.directory,`solution.${K}`);if(!await BI(Y))throw Error(`Golden solution file ${Y} not found`);this.goldenSolution=`solution.${K}`}B.print(this.goldenSolution)})}async loadTestcases(){await B.section("Loading testcases",async()=>{let $=await Array.fromAsync(uG6("*.inp",{cwd:this.directory}));this.testcases=$.map((q)=>q.replace(".inp","")).sort(),B.yaml(this.testcases)})}async loadAwards(){await B.section("Loading awards",async()=>{if(await BI(j0(this.directory,"award.html")))B.success(B.hyperlink(this.directory,"award.html")+" found");else B.warning("award.html not found");if(await BI(j0(this.directory,"award.png"))){B.success(B.hyperlink(this.directory,"award.png")+" found");let $=await fe(j0(this.directory,"award.png"));await B.image(j0(this.directory,"award.png"),6,3),B.print(`${$.width}x${$.height}`)}else B.warning("award.png not found")})}}var PT=/\r?\n/;function I0($,q){let K=new Map;return(...Y)=>{let w=q?q(...Y):JSON.stringify(Y);if(!K.has(w))K.set(w,$(...Y));return K.get(w)}}async function ea1(){let{stdout:$}=await l1({reject:!1})`python3 --version`,q=$.trim();return{result:q.startsWith("Python 3"),version:q,stdout:$}}var $r1=I0(ea1);async function qr1($){let{exitCode:q,stdout:K,stderr:Y}=await l1({reject:!1})`python3 -m pip show ${$}`;return{result:q===0,version:q===0?"installed":"not installed",stdout:K,stderr:Y}}var Kr1=I0(qr1,($)=>$);async function _r1(){let{stdout:$}=await l1({reject:!1})`g++ --version`,q=$.split(PT)[0].trim();return{result:$.startsWith("Apple clang")||$.startsWith("g++"),version:q,stdout:$}}var Yr1=I0(_r1);async function wr1(){let{stdout:$}=await l1({reject:!1})`ghc --version`,q=$.split(PT)[0].trim();return{result:$.startsWith("The Glorious Glasgow Haskell Compilation System"),version:q,stdout:$}}var Hr1=I0(wr1);async function Jr1(){let{stdout:$}=await l1({reject:!1})`clj --version`,q=$.split(PT)[0].trim();return{result:$.startsWith("Clojure"),version:q,stdout:$}}var Wr1=I0(Jr1);async function Pr1(){let{stdout:$,stderr:q}=await l1({reject:!1})`javac -version`,K=$||q,Y=K.split(PT)[0].trim();return{result:K.startsWith("javac"),version:Y,stdout:$,stderr:q}}var Xr1=I0(Pr1);async function Or1(){let{stdout:$}=await l1({reject:!1})`rustc --version`,q=$.split(PT)[0].trim();return{result:$.startsWith("rustc"),version:q,stdout:$}}var Dr1=I0(Or1);async function Zr1(){let{stdout:$}=await l1({reject:!1})`pdflatex --version`,q=$.split(PT)[0].trim();return{result:$.includes("pdfTeX"),version:q,stdout:$}}var Gr1=I0(Zr1);async function zr1(){let{stdout:$}=await l1({reject:!1})`xelatex --version`,q=$.split(PT)[0].trim();return{result:$.includes("XeTeX"),version:q,stdout:$}}var KL8=I0(zr1);async function _L8(){let{result:$}=await KL8();return $}async function Tr1(){let{stdout:$}=await l1({reject:!1})`pandoc --version`,q=$.split(PT)[0].trim();return{result:$.startsWith("pandoc")&&$.includes("+lua"),version:q,stdout:$}}var YL8=I0(Tr1);async function wL8(){let{result:$}=await YL8();return $}async function HL8(){B.command("python3 --version");let{result:$,version:q}=await $r1();if(console.log(q),$){B.success("Python3 seems installed");let K="turtle-pil yogi easyinput".split(" ");for(let Y of K){B.command(`python3 -m pip show ${Y}`);let{result:w}=await Kr1(Y);if(w)B.success(`Module ${Y} is installed`);else B.warning(`Module ${Y} is not installed`)}}else B.warning("Python3 does not appear to be installed"),B.print("This is not a problem if you do not plan to use Python solutions"),B.print("See https://www.python.org/downloads/")}async function JL8(){B.command("g++ --version");let{result:$,version:q}=await Yr1();if(console.log(q),$)B.success("C/C++ seems installed");else B.warning("C/C++ does not appear to be installed"),B.print("This is not a problem if you do not plan to use C or C++ solutions"),B.print("Please install GCC or Clang")}async function WL8(){B.command("ghc --version");let{result:$,version:q}=await Hr1();if(console.log(q),$)B.success("Haskell seems installed");else B.warning("Haskell does not appear to be installed"),B.print("This is not a problem if you do not plan to use Haskell solutions"),B.print("See https://www.haskell.org/ghc/download.html")}async function PL8(){B.command("clj --version");let{result:$,version:q}=await Wr1();if(console.log(q),$)B.success("Clojure seems installed");else B.warning("Clojure does not appear to be installed"),B.print("This is not a problem if you do not plan to use Clojure solutions"),B.print("See https://clojure.org/guides/getting_started")}async function XL8(){B.command("javac -version");let{result:$,version:q}=await Xr1();if(console.log(q),$)B.success("Java seems installed");else B.warning("Java does not appear to be installed"),B.print("You will not be able to compile/execute Java solutions"),B.print("See https://www.oracle.com/java/technologies/javase-jdk11-downloads.html")}async function OL8(){B.command("rustc --version");let{result:$,version:q}=await Dr1();if(console.log(q),$)B.success("Rust seems installed");else B.warning("Rust does not appear to be installed"),B.print("You will not be able to compile/execute Rust solutions"),B.print("See https://www.rust-lang.org/tools/install")}async function DL8(){B.command("pdflatex --version");let{result:$,version:q}=await Gr1();if(console.log(q),$)B.success("LaTeX seems installed");else B.warning("LaTeX does not appear to be installed"),B.print("You will not be able to generate PDF statements"),B.print("TODO: Provide instructions for installing LaTeX")}async function ZL8(){B.command("xelatex --version");let{result:$,version:q}=await KL8();if(console.log(q),$)B.success("XeLaTeX seems installed");else B.warning("XeLaTeX does not appear to be installed"),B.print("You will not be able to generate PDF statements with Unicode support"),B.print("TODO: Provide instructions for installing XeLaTeX")}async function GL8(){B.command("pandoc --version");let{result:$,version:q}=await YL8();if(console.log(q),$)B.success("Pandoc with Lua support seems installed");else B.warning("Pandoc with Lua support does not appear to be installed"),B.print("You will not be able to generate text statements (HTML, TXT, MD)"),B.print("See https://pandoc.org/installing.html")}async function zL8(){await c9();let $=["OPENAI_API_KEY","GEMINI_API_KEY"];for(let q of $)if(process.env[q])B.success(`${q} environment variable is set`);else B.warning(`${q} environment variable is not set`),B.print("You will not be able to use related AI models")}async function TL8(){if(await c9(),process.stdout.isTTY)B.success("Terminal supports TTY");else B.warning("Terminal does not support TTY"),B.print("Some output features may not work as expected");if(bH.isSupported)B.success("Terminal supports hyperlinks");else B.warning("Terminal does not support hyperlinks"),B.print("Links to files may not be clickable");let $=["EDITOR","VISUAL"];for(let q of $)if(process.env[q])B.success(`${q} environment variable is set to "${process.env[q]}"`);else B.warning(`${q} environment variable is not set`)}var fL8=i1(m$(),"assets","latex");async function Be($){let q=await _H($);return new CL8(q)}class CL8{problem;constructor($){this.problem=$}async showDirectory(){await B.section("Directory",async()=>{await c9(),B.directory(ML8(this.problem.directory));let $=Mr1(ML8(this.problem.directory));if(!$.endsWith(".pbm")){let q=Vr1($),K=Nr1($);if(!Object.keys(s5).includes(q)||!K.endsWith(".pbm"))throw Error("The problem directory should end with .pbm or be a language id inside a .pbm directory")}})}async makeProblem(){await this.makeGoldenExecutable(),await this.makeCorrectOutputs(),await this.checkSolutions(),await this.makePdfStatements(),await this.makeTextualStatements()}async makeExecutable($){let q=this.selectCompiler(),K=`${d$()}-${$}`;await B.section(`Copying ${B.hyperlink(this.problem.directory,$)} to ${B.hyperlink(this.problem.directory,K)}`,async()=>{await FW(i1(this.problem.directory,$),i1(this.problem.directory,K))}),await B.section(`Compiling ${B.hyperlink(this.problem.directory,K)} with ${q.name()} (${this.problem.handler.source_modifier})`,async()=>{try{let Y;if(this.problem.handler.source_modifier==="none")Y=await q.compileNormal(this.problem.handler,this.problem.directory,K);else if(this.problem.handler.source_modifier==="no_main")Y=await q.compileWithMain(this.problem.handler,this.problem.directory,K);else throw Error(`Unknown source modifier: ${this.problem.handler.source_modifier}`);if(!await VL8(i1(this.problem.directory,Y)))throw Error(`Compilation failed for ${K}`);B.success(`Compiled ${K} to ${Y}`)}catch(Y){throw Error("Compilation failed")}})}async makeExecutables(){await B.section("Compiling solutions",async()=>{for(let $ of this.problem.solutions)await this.makeExecutable($)})}async makeGoldenExecutable(){await B.section(`Compiling golden solution from ${B.hyperlink(this.problem.directory,this.problem.goldenSolution)}`,async()=>{if(!this.problem.goldenSolution)throw Error("Golden solution not set");await this.makeExecutable(this.problem.goldenSolution)})}async checkSolutions(){for(let $ of this.problem.solutions)if($!==this.problem.goldenSolution)await this.verifyCandidate($)}async makeCorrectOutput($,q,K){return await this.runTestcase($,`${$}.inp`,`${$}.cor`,q,d$()+"-"+K)}async runTestcase($,q,K,Y,w){let H=!1,J=Date.now();try{await Y.execute(this.problem.handler,this.problem.directory,w,q,K)}catch(D){B.error(`Execution failed for testcase '${$}'`),H=!0}let P=Date.now()-J;if(this.problem.handler.handler==="graphic")await Ar1(i1(this.problem.directory,"output.png"),i1(this.problem.directory,K));let X=await R_6(i1(this.problem.directory,q)),O=await R_6(i1(this.problem.directory,K));return{testcase:$,error:H,time:P,inputSize:X,outputSize:O}}selectCompiler(){if(this.problem.handler.compilers==="RunPython")return EB("RunPython");else if(this.problem.handler.compilers==="RunHaskell")return EB("RunHaskell");else if(this.problem.handler.compilers==="RunClojure")return EB("RunClojure");else{let $=this.problem.goldenSolution.split(".").pop();return RG6($)}}async makeCorrectOutputs(){let $=this.selectCompiler();await B.section("Making correct outputs with golden solution",async()=>{await B.section(`Using ${$.name()}`,async()=>{let q=[];for(let Y of this.problem.testcases)q.push(await this.makeCorrectOutput(Y,$,this.problem.goldenSolution));console.log(),console.log("testcase time input output");for(let Y of q){let w=YC(Y.time),H=Ce(Y.inputSize).replace(" ",""),J=Ce(Y.outputSize).replace(" ","");console.log((Y.error?d5.red:d5.green)(`${Y.testcase.padEnd(12)} ${w.padStart(10)} ${H.padStart(10)} ${J.padStart(10)}`))}let K=q.filter((Y)=>Y.error).length;if(K>0)throw console.log(),Error(`${K} errors occurred while making correct answers`)})})}async makePdfStatements(){await B.section("Making PDF statements",async()=>{let $=i1(this.problem.directory,d$()+"-pdf",CC());await ue($,{recursive:!0}),await B.section("Creating working directory",async()=>{await c9(),B.directory($)});for(let q of this.problem.languages)if(this.problem.structure==="multi"||this.problem.structure==="single"&&q===this.problem.language)await B.section(`Making PDF statement for ${s5[q]}`,async()=>{await this.makePdfStatement($,q)})})}async makeSamples($,q){let K=this.problem.handler.handler==="graphic",Y=[],w=[],H=1;for(let J of this.problem.testcases)if(J.startsWith("sample")){let W="";if(K){await FW(i1(this.problem.directory,`${J}.cor`),i1($,`${J}.cor.png`));let P=await fe(i1($,`${J}.cor.png`));W=`(${P.width}$\\times$${P.height})`}Y.push(`
|
|
3854
|
+
`),Y}async execute($,q,K,Y,w){}}var vB={C:ve,"C++":Ee,Python3:je,Haskell:Ie,Clojure:Re,Java:Le,Rust:Se,Verilog:ge,RunPython:EG6,RunHaskell:jG6,RunClojure:IG6},ra1={c:ve,cc:Ee,py:je,hs:Ie,clj:Re,java:Le,rs:Se,v:ge};function EB($){let q=vB[$];if(!q)throw Error(`Compiler '${$}' is not defined`);return new q}function RG6($){let q=ra1[$];if(!q)throw Error(`No compiler defined for extension '.${$}'`);return new q}async function cR8(){return await c9(),Object.keys(vB)}async function lR8(){let $=[];for(let q of Object.keys(vB))if(await new vB[q]().available())$.push(q);return $}async function oa1($){let q=EB($);if(!q)throw Error(`Compiler '${$}' is not defined`);return await q.info()}async function pR8(){let $={};for(let q of Object.keys(vB))$[q]=await oa1(q);return $}KZ();import{exists as BI,glob as uG6}from"fs/promises";import{basename as sa1,join as j0,normalize as eR8,sep as $L8}from"path";KZ();async function _H($){let q=new qL8($);return await q.load(),q}class qL8{directory;structure="multi";language=null;handler;languages=[];originalLanguage=null;problemYml=null;problemLangYmls={};solutions=[];goldenSolution=null;testcases=[];constructor($){if($==="."||$==="./"||!$)this.directory=eR8(process.cwd());else this.directory=eR8(j0($,"."))}async load(){await B.section(`Loading problem from ${this.directory}`,async()=>{await this.loadStructure(),await this.loadLanguages(),await this.loadHandler(),await this.loadProblemYml(),await this.loadOriginalLanguage(),await this.loadSolutions(),await this.loadGoldenSolution(),await this.loadTestcases(),await this.loadScores(),await this.loadAwards()});let $=!1;if(!this.originalLanguage)B.error("No original language found"),$=!0;if(!this.goldenSolution)B.error("No golden solution found"),$=!0;if($)throw Error("Inspection failed due to errors")}async loadStructure(){await B.section("Determining structure",async()=>{if(await c9(),this.directory.endsWith(".pbm"))this.structure="multi";else this.structure="single";console.log(this.structure)})}async loadLanguages(){await B.section("Loading languages",async()=>{if(this.structure==="multi")await this.loadLanguagesMulti();else await this.loadLanguagesSingle()})}async loadLanguagesMulti(){let q=(await Array.fromAsync(uG6("problem.*.yml",{cwd:this.directory}))).map((K)=>{let Y=K.match(/problem\.(.+)\.yml/);return Y?Y[1]:null}).filter((K)=>K&&(K in s5));this.languages=q,B.yaml(this.languages);for(let K of this.languages)await B.section(`Loading problem.${K}.yml`,async()=>{this.problemLangYmls[K]=await pJ(this.directory,`problem.${K}.yml`),B.yaml(this.problemLangYmls[K])})}async loadLanguagesSingle(){for(let $ of Object.keys(s5)){let q=j0(this.directory,"..",$,`problem.${$}.yml`);if(await BI(q))this.languages.push($)}B.yaml(this.languages);for(let $ of this.languages)await B.section(`Loading ..${$L8}${$}${$L8}problem.${$}.yml`,async()=>{this.problemLangYmls[$]=await pJ(j0(this.directory,"..",$),`problem.${$}.yml`),B.yaml(this.problemLangYmls[$])});this.language=sa1(this.directory)}async loadHandler(){await B.section("Loading handler.yml",async()=>{let $=await pJ(this.directory,"handler.yml");if(this.handler=ek6.parse($),this.handler.source_modifier==="structs")B.warning('source_modifier "structs" is deprecated, using "no_main" instead. please update handler.yml'),this.handler.source_modifier="no_main";if(this.handler.handler==="circuits")this.handler.solution="Verilog";if(B.yaml(this.handler),this.handler.handler==="quiz")throw Error('Handler "quiz" is not supported yet')})}async loadScores(){await B.section("Loading scores.yml",async()=>{if(await BI(j0(this.directory,"scores.yml"))){let $=await pJ(this.directory,"scores.yml"),q=$g6.parse($);B.yaml(q)}else B.print("scores.yml not defined")})}async loadProblemYml(){await B.section("Loading problem.yml",async()=>{if(await BI(j0(this.directory,"problem.yml"))){let $=await pJ(this.directory,"problem.yml"),q=xd.parse($);B.yaml(q)}else B.print("problem.yml not defined")})}async loadOriginalLanguage(){await B.section("Determining original language",async()=>{await c9();for(let $ of this.languages)if("author"in this.problemLangYmls[$]){this.originalLanguage=$;break}if(!this.originalLanguage)throw Error("No original language found (a language with an author field)");B.print(this.originalLanguage)})}async loadSolutions(){await B.section("Loading solutions",async()=>{let{proglangNames:$}=await Promise.resolve().then(() => (KZ(),yG6)),q=Object.keys($).join(","),K=await Array.fromAsync(uG6(`solution.{${q}}`,{cwd:this.directory}));if(this.solutions=K.sort(),B.yaml(this.solutions),this.solutions.length===0)throw Error("No solutions found")})}async loadGoldenSolution(){await B.section("Determining golden solution",async()=>{let{proglangExtensions:$}=await Promise.resolve().then(() => (KZ(),yG6));if(this.handler.handler==="circuits")this.goldenSolution="solution.v";else if(this.handler.compilers==="RunPython")this.goldenSolution="solution.py";else if(this.handler.compilers==="RunHaskell"||this.handler.compilers==="GHC")this.goldenSolution="solution.hs";else if(this.handler.compilers==="RunClojure"||this.handler.compilers==="Clojure")this.goldenSolution="solution.clj";else{let q=this.handler.solution,K=$[q];if(!K)throw Error(`Unknown programming language ${q} for solution`);let Y=j0(this.directory,`solution.${K}`);if(!await BI(Y))throw Error(`Golden solution file ${Y} not found`);this.goldenSolution=`solution.${K}`}B.print(this.goldenSolution)})}async loadTestcases(){await B.section("Loading testcases",async()=>{let $=await Array.fromAsync(uG6("*.inp",{cwd:this.directory}));this.testcases=$.map((q)=>q.replace(".inp","")).sort(),B.yaml(this.testcases)})}async loadAwards(){await B.section("Loading awards",async()=>{if(await BI(j0(this.directory,"award.html")))B.success(B.hyperlink(this.directory,"award.html")+" found");else B.warning("award.html not found");if(await BI(j0(this.directory,"award.png"))){B.success(B.hyperlink(this.directory,"award.png")+" found");let $=await fe(j0(this.directory,"award.png"));await B.image(j0(this.directory,"award.png"),6,3),B.print(`${$.width}x${$.height}`)}else B.warning("award.png not found")})}}var PT=/\r?\n/;function I0($,q){let K=new Map;return(...Y)=>{let w=q?q(...Y):JSON.stringify(Y);if(!K.has(w))K.set(w,$(...Y));return K.get(w)}}async function ea1(){let{stdout:$}=await l1({reject:!1})`python3 --version`,q=$.trim();return{result:q.startsWith("Python 3"),version:q,stdout:$}}var $r1=I0(ea1);async function qr1($){let{exitCode:q,stdout:K,stderr:Y}=await l1({reject:!1})`python3 -m pip show ${$}`;return{result:q===0,version:q===0?"installed":"not installed",stdout:K,stderr:Y}}var Kr1=I0(qr1,($)=>$);async function _r1(){let{stdout:$}=await l1({reject:!1})`g++ --version`,q=$.split(PT)[0].trim();return{result:$.startsWith("Apple clang")||$.startsWith("g++"),version:q,stdout:$}}var Yr1=I0(_r1);async function wr1(){let{stdout:$}=await l1({reject:!1})`ghc --version`,q=$.split(PT)[0].trim();return{result:$.startsWith("The Glorious Glasgow Haskell Compilation System"),version:q,stdout:$}}var Hr1=I0(wr1);async function Jr1(){let{stdout:$}=await l1({reject:!1})`clj --version`,q=$.split(PT)[0].trim();return{result:$.startsWith("Clojure"),version:q,stdout:$}}var Wr1=I0(Jr1);async function Pr1(){let{stdout:$,stderr:q}=await l1({reject:!1})`javac -version`,K=$||q,Y=K.split(PT)[0].trim();return{result:K.startsWith("javac"),version:Y,stdout:$,stderr:q}}var Xr1=I0(Pr1);async function Or1(){let{stdout:$}=await l1({reject:!1})`rustc --version`,q=$.split(PT)[0].trim();return{result:$.startsWith("rustc"),version:q,stdout:$}}var Dr1=I0(Or1);async function Zr1(){let{stdout:$}=await l1({reject:!1})`pdflatex --version`,q=$.split(PT)[0].trim();return{result:$.includes("pdfTeX"),version:q,stdout:$}}var Gr1=I0(Zr1);async function zr1(){let{stdout:$}=await l1({reject:!1})`xelatex --version`,q=$.split(PT)[0].trim();return{result:$.includes("XeTeX"),version:q,stdout:$}}var KL8=I0(zr1);async function _L8(){let{result:$}=await KL8();return $}async function Tr1(){let{stdout:$}=await l1({reject:!1})`pandoc --version`,q=$.split(PT)[0].trim();return{result:$.startsWith("pandoc")&&$.includes("+lua"),version:q,stdout:$}}var YL8=I0(Tr1);async function wL8(){let{result:$}=await YL8();return $}async function HL8(){B.command("python3 --version");let{result:$,version:q}=await $r1();if(console.log(q),$){B.success("Python3 seems installed");let K="turtle-pil yogi easyinput".split(" ");for(let Y of K){B.command(`python3 -m pip show ${Y}`);let{result:w}=await Kr1(Y);if(w)B.success(`Module ${Y} is installed`);else B.warning(`Module ${Y} is not installed`)}}else B.warning("Python3 does not appear to be installed"),B.print("This is not a problem if you do not plan to use Python solutions"),B.print("See https://www.python.org/downloads/")}async function JL8(){B.command("g++ --version");let{result:$,version:q}=await Yr1();if(console.log(q),$)B.success("C/C++ seems installed");else B.warning("C/C++ does not appear to be installed"),B.print("This is not a problem if you do not plan to use C or C++ solutions"),B.print("Please install GCC or Clang")}async function WL8(){B.command("ghc --version");let{result:$,version:q}=await Hr1();if(console.log(q),$)B.success("Haskell seems installed");else B.warning("Haskell does not appear to be installed"),B.print("This is not a problem if you do not plan to use Haskell solutions"),B.print("See https://www.haskell.org/ghc/download.html")}async function PL8(){B.command("clj --version");let{result:$,version:q}=await Wr1();if(console.log(q),$)B.success("Clojure seems installed");else B.warning("Clojure does not appear to be installed"),B.print("This is not a problem if you do not plan to use Clojure solutions"),B.print("See https://clojure.org/guides/getting_started")}async function XL8(){B.command("javac -version");let{result:$,version:q}=await Xr1();if(console.log(q),$)B.success("Java seems installed");else B.warning("Java does not appear to be installed"),B.print("You will not be able to compile/execute Java solutions"),B.print("See https://www.oracle.com/java/technologies/javase-jdk11-downloads.html")}async function OL8(){B.command("rustc --version");let{result:$,version:q}=await Dr1();if(console.log(q),$)B.success("Rust seems installed");else B.warning("Rust does not appear to be installed"),B.print("You will not be able to compile/execute Rust solutions"),B.print("See https://www.rust-lang.org/tools/install")}async function DL8(){B.command("pdflatex --version");let{result:$,version:q}=await Gr1();if(console.log(q),$)B.success("LaTeX seems installed");else B.warning("LaTeX does not appear to be installed"),B.print("You will not be able to generate PDF statements"),B.print("TODO: Provide instructions for installing LaTeX")}async function ZL8(){B.command("xelatex --version");let{result:$,version:q}=await KL8();if(console.log(q),$)B.success("XeLaTeX seems installed");else B.warning("XeLaTeX does not appear to be installed"),B.print("You will not be able to generate PDF statements with Unicode support"),B.print("TODO: Provide instructions for installing XeLaTeX")}async function GL8(){B.command("pandoc --version");let{result:$,version:q}=await YL8();if(console.log(q),$)B.success("Pandoc with Lua support seems installed");else B.warning("Pandoc with Lua support does not appear to be installed"),B.print("You will not be able to generate text statements (HTML, TXT, MD)"),B.print("See https://pandoc.org/installing.html")}async function zL8(){await c9();let $=["OPENAI_API_KEY","GEMINI_API_KEY"];for(let q of $)if(process.env[q])B.success(`${q} environment variable is set`);else B.warning(`${q} environment variable is not set`),B.print("You will not be able to use related AI models")}async function TL8(){if(await c9(),process.stdout.isTTY)B.success("Terminal supports TTY");else B.warning("Terminal does not support TTY"),B.print("Some output features may not work as expected");if(bH.isSupported)B.success("Terminal supports hyperlinks");else B.warning("Terminal does not support hyperlinks"),B.print("Links to files may not be clickable");let $=["EDITOR","VISUAL"];for(let q of $)if(process.env[q])B.success(`${q} environment variable is set to "${process.env[q]}"`);else B.warning(`${q} environment variable is not set`)}var fL8=i1(m$(),"assets","latex");async function Be($,q){let K=await _H($);return new CL8(K,q)}class CL8{problem;problem_nm;constructor($,q){this.problem=$,this.problem_nm=q}async showDirectory(){await B.section("Directory",async()=>{await c9(),B.directory(ML8(this.problem.directory));let $=Mr1(ML8(this.problem.directory));if(!$.endsWith(".pbm")){let q=Vr1($),K=Nr1($);if(!Object.keys(s5).includes(q)||!K.endsWith(".pbm"))throw Error("The problem directory should end with .pbm or be a language id inside a .pbm directory")}})}async makeProblem(){await this.makeGoldenExecutable(),await this.makeCorrectOutputs(),await this.checkSolutions(),await this.makePdfStatements(),await this.makeTextualStatements()}async makeExecutable($){let q=this.selectCompiler(),K=`${d$()}-${$}`;await B.section(`Copying ${B.hyperlink(this.problem.directory,$)} to ${B.hyperlink(this.problem.directory,K)}`,async()=>{await FW(i1(this.problem.directory,$),i1(this.problem.directory,K))}),await B.section(`Compiling ${B.hyperlink(this.problem.directory,K)} with ${q.name()} (${this.problem.handler.source_modifier})`,async()=>{try{let Y;if(this.problem.handler.source_modifier==="none")Y=await q.compileNormal(this.problem.handler,this.problem.directory,K);else if(this.problem.handler.source_modifier==="no_main")Y=await q.compileWithMain(this.problem.handler,this.problem.directory,K);else throw Error(`Unknown source modifier: ${this.problem.handler.source_modifier}`);if(!await VL8(i1(this.problem.directory,Y)))throw Error(`Compilation failed for ${K}`);B.success(`Compiled ${K} to ${Y}`)}catch(Y){throw Error("Compilation failed")}})}async makeExecutables(){await B.section("Compiling solutions",async()=>{for(let $ of this.problem.solutions)await this.makeExecutable($)})}async makeGoldenExecutable(){await B.section(`Compiling golden solution from ${B.hyperlink(this.problem.directory,this.problem.goldenSolution)}`,async()=>{if(!this.problem.goldenSolution)throw Error("Golden solution not set");await this.makeExecutable(this.problem.goldenSolution)})}async checkSolutions(){for(let $ of this.problem.solutions)if($!==this.problem.goldenSolution)await this.verifyCandidate($)}async makeCorrectOutput($,q,K){return await this.runTestcase($,`${$}.inp`,`${$}.cor`,q,d$()+"-"+K)}async runTestcase($,q,K,Y,w){let H=!1,J=Date.now();try{await Y.execute(this.problem.handler,this.problem.directory,w,q,K)}catch(D){B.error(`Execution failed for testcase '${$}'`),H=!0}let P=Date.now()-J;if(this.problem.handler.handler==="graphic")await Ar1(i1(this.problem.directory,"output.png"),i1(this.problem.directory,K));let X=await R_6(i1(this.problem.directory,q)),O=await R_6(i1(this.problem.directory,K));return{testcase:$,error:H,time:P,inputSize:X,outputSize:O}}selectCompiler(){if(this.problem.handler.compilers==="RunPython")return EB("RunPython");else if(this.problem.handler.compilers==="RunHaskell")return EB("RunHaskell");else if(this.problem.handler.compilers==="RunClojure")return EB("RunClojure");else{let $=this.problem.goldenSolution.split(".").pop();return RG6($)}}async makeCorrectOutputs(){let $=this.selectCompiler();await B.section("Making correct outputs with golden solution",async()=>{await B.section(`Using ${$.name()}`,async()=>{let q=[];for(let Y of this.problem.testcases)q.push(await this.makeCorrectOutput(Y,$,this.problem.goldenSolution));console.log(),console.log("testcase time input output");for(let Y of q){let w=YC(Y.time),H=Ce(Y.inputSize).replace(" ",""),J=Ce(Y.outputSize).replace(" ","");console.log((Y.error?d5.red:d5.green)(`${Y.testcase.padEnd(12)} ${w.padStart(10)} ${H.padStart(10)} ${J.padStart(10)}`))}let K=q.filter((Y)=>Y.error).length;if(K>0)throw console.log(),Error(`${K} errors occurred while making correct answers`)})})}async makePdfStatements(){await B.section("Making PDF statements",async()=>{let $=i1(this.problem.directory,d$()+"-pdf",CC());await ue($,{recursive:!0}),await B.section("Creating working directory",async()=>{await c9(),B.directory($)});for(let q of this.problem.languages)if(this.problem.structure==="multi"||this.problem.structure==="single"&&q===this.problem.language)await B.section(`Making PDF statement for ${s5[q]}`,async()=>{await this.makePdfStatement($,q)})})}async makeSamples($,q){let K=this.problem.handler.handler==="graphic",Y=[],w=[],H=1;for(let J of this.problem.testcases)if(J.startsWith("sample")){let W="";if(K){await FW(i1(this.problem.directory,`${J}.cor`),i1($,`${J}.cor.png`));let P=await fe(i1($,`${J}.cor.png`));W=`(${P.width}$\\times$${P.height})`}Y.push(`
|
|
3855
3855
|
\\SampleOneColInputOutput[${W}]{${J}}{${H}}
|
|
3856
3856
|
`),w.push(`
|
|
3857
3857
|
\\SampleTwoColInputOutput[${W}]{${J}}{${H}}
|
|
3858
3858
|
`),H++}return[Y.join(`
|
|
3859
3859
|
`),w.join(`
|
|
3860
|
-
`)]}async makePdfStatement($,q){let K=i1($,q);await ue(K);let Y=new Date().toISOString().substring(0,10),w=new Date().getFullYear(),H=this.problem.problemLangYmls[q].author||"Unknown",J=this.problem.problemLangYmls[q].author_email||"unknown email",W=this.problem.problemLangYmls[q].translator||"",[P,X]=await this.makeSamples(K,q),O=await l7(i1(fL8,"root-pdf.tpl.tex"));IB.default.registerHelper("curly",function(A){return"{"+A+"}"});let D=IB.default.compile(O)({language:q,jutgeLanguage:`jutge.${q}`,id:`DRAFT (${q})`,samples1c:P,samples2c:X,author:H,translator:W,date:Y});for await(let A of NL8("*",{cwd:this.problem.directory})){if(A.startsWith(d$())||A.endsWith(".exe")||A.endsWith(".html")||A.endsWith(".md")||A.endsWith(".txt")||await L_6(this.problem.directory,A))continue;await FW(i1(this.problem.directory,A),i1(K,A))}await f3(i1(K,"root.tex"),D);let z=(await l7(i1(K,`problem.${q}.tex`))).replace(/\\begin{htmlonly}[\s\S]*?\\end{htmlonly}/g,"").replace(/\\begin{latexonly}/g,"").replace(/\\end{latexonly}/g,"").replace(/\.eps}/g,"}");if(await f3(i1(K,`problem.${q}.tex`),z),await this.copyStyleFiles(K,q),!await _L8()){B.error("xelatex not found");return}try{B.command("xelatex -interaction=nonstopmode -file-line-error root.tex"),await l1({stderr:"inherit",cwd:K})`xelatex -interaction=nonstopmode -file-line-error root.tex`,await FW(i1(K,"root.pdf"),i1(this.problem.directory,`problem.${q}.pdf`)),B.success(`Generated ${B.hyperlink(this.problem.directory,`problem.${q}.pdf`)} see ${B.hyperlink(K,"root.log")}`)}catch(A){B.error(`Error in LaTeX: ${B.hyperlink(K,"root.log")}`)}}async copyStyleFiles($,q){let K=async(Y)=>{let w=i1(m$(),"assets","sty",Y);await FW(w,i1($,Y))};if(await K("picins.sty"),await K("jutge.sty"),q==="ca")await K("jutge.ca.sty");if(q==="es")await K("jutge.es.sty");if(q==="en")await K("jutge.en.sty");if(q==="fr")await K("jutge.fr.sty");if(q==="de")await K("jutge.de.sty")}async makeTextualStatements($=["txt","html","md"]){await B.section("Making textual statements",async()=>{let q=i1(this.problem.directory,d$()+"-text",CC());await ue(q,{recursive:!0}),await B.section("Creating working directory",async()=>{await c9(),B.directory(q)});try{for(let K of this.problem.languages)if(this.problem.structure==="multi"||this.problem.structure==="single"&&K===this.problem.language)await B.section(`Making textual statements for ${s5[K]}`,async()=>{await this.makeTextualStatement(q,K,$)})}finally{}})}async makeTextualStatement($,q,K){let Y=i1($,q);await ue(Y);let w=new Date().toISOString().substring(0,10),H=new Date().getFullYear(),J=this.problem.problemLangYmls[q].author||"Unknown",W=this.problem.problemLangYmls[q].author_email||"unknown email",P=this.problem.problemLangYmls[q].translator||"",X=await l7(i1(fL8,"root-text.tpl.tex"));IB.default.registerHelper("curly",function(A){return"{"+A+"}"});let O=IB.default.compile(X)({language:q,jutgeLanguage:`jutge.${q}`,id:`DRAFT (${q})`,author:J,translator:P,date:w});for await(let A of NL8("*",{cwd:this.problem.directory})){if(A.startsWith(d$())||A.endsWith(".pdf")||A.endsWith(".exe")||A.endsWith(".html")||A.endsWith(".md")||A.endsWith(".txt")||await L_6(this.problem.directory,A))continue;await FW(i1(this.problem.directory,A),i1(Y,A))}await f3(i1(Y,"root.tex"),O);let Z=(await l7(i1(Y,`problem.${q}.tex`))).replace(/\\begin{latexonly}[\s\S]*?\\end{latexonly}/g,"").replace(/\\begin{htmlonly}/g,"").replace(/\\end{htmlonly}/g,"").replace(/\\begin{minipage}/g,"").replace(/\\end{minipage}/g,"");if(await f3(i1(Y,`problem.${q}.tex`),Z),await this.copyStyleFiles(Y,q),!await wL8()){B.error("pandoc with lua support not found");return}let z=i1(m$(),"assets","lua","fixCodeBlocks.lua");if(await FW(z,i1(Y,"fixCodeBlocks.lua")),K.includes("txt"))try{B.command("pandoc --quiet root.tex --to plain --output root.txt"),await l1({cwd:Y})`pandoc --quiet root.tex --to plain --output root.txt`,await FW(i1(Y,"root.txt"),i1(this.problem.directory,`problem.${q}.txt`)),B.success("Generated "+B.hyperlink(this.problem.directory,`problem.${q}.txt`))}catch(A){console.error("pandoc error",A)}if(K.includes("md"))try{B.command("pandoc --quiet root.tex --to markdown --to markdown-header_attributes --lua-filter=fixCodeBlocks.lua --output root.md"),await l1({cwd:Y})`pandoc --quiet root.tex --to markdown --to markdown-header_attributes --lua-filter=fixCodeBlocks.lua --output root.md`,await FW(i1(Y,"root.md"),i1(this.problem.directory,`problem.${q}.md`)),B.success("Generated "+B.hyperlink(this.problem.directory,`problem.${q}.md`))}catch(A){console.error("pandoc error",A)}if(K.includes("html"))try{B.command("pandoc --quiet root.tex --to html --mathml --embed-resources --output root.html"),await l1({cwd:Y})`pandoc --quiet root.tex --to html --mathml --embed-resources --output root.html`,await FW(i1(Y,"root.html"),i1(this.problem.directory,`problem.${q}.html`)),B.success("Generated "+B.hyperlink(this.problem.directory,`problem.${q}.html`))}catch(A){console.error("pandoc error",A)}}async verifyCandidate($){await B.section(`Verifying ${$}`,async()=>{let q=$.split(".").pop(),K=RG6(q),Y=`${d$()}-${$}`;await B.section(`Copying ${B.hyperlink(this.problem.directory,$)} to ${B.hyperlink(this.problem.directory,Y)}`,async()=>{await FW(i1(this.problem.directory,$),i1(this.problem.directory,Y))}),await B.section(`Using compiler ${K.name()} to compile ${B.hyperlink(this.problem.directory,Y)}`,async()=>{try{let H;if(this.problem.handler.source_modifier==="none")H=await K.compileNormal(this.problem.handler,this.problem.directory,Y);else if(this.problem.handler.source_modifier==="no_main")H=await K.compileWithMain(this.problem.handler,this.problem.directory,Y);else throw Error(`Unknown source modifier: ${this.problem.handler.source_modifier}`);if(!await VL8(i1(this.problem.directory,H)))throw Error(`Compilation failed for ${Y}`);B.success(`Compiled ${Y} to ${H}`)}catch(H){throw Error("Compilation failed")}});let w=[];await B.section("Executing testcases",async()=>{for(let J of this.problem.testcases)w.push(await this.runTestcase(J,`${J}.inp`,`${d$()}-${J}.${q}.out`,K,Y));console.log(),console.log("testcase time status");let H=0;for(let J of w){let W=J.error?"EE":await ak6(i1(this.problem.directory,`${J.testcase}.cor`),i1(this.problem.directory,`${d$()}-${J.testcase}.${q}.out`))?"OK":"WA",P=YC(J.time);if(console.log((W!=="OK"?d5.red:d5.green)(`${J.testcase.padEnd(12)} ${P.padStart(10)} ${W.padStart(10)}`)),W!=="OK")H++}if(console.log(),H)B.error(`${H} errors found for ${$}`);else B.success(`All testcases passed successfully for ${$}`)})})}}var vL8=new R5("verify").description("Verify programs against golden solution").argument("<programs...>","source programs to verify").option("-d, --directory <path>","problem directory",".").action(async($,{directory:q})=>{let K=await Be(q);for(let Y of $)await K.verifyCandidate(Y)});import rs1 from"path";var RB=($,q=[])=>$.name==="up"||q.includes("vim")&&$.name==="k"||q.includes("emacs")&&$.ctrl&&$.name==="p",xe=($,q=[])=>$.name==="down"||q.includes("vim")&&$.name==="j"||q.includes("emacs")&&$.ctrl&&$.name==="n",BG6=($)=>$.name==="space";var xG6=($)=>"1234567890".includes($.name),FG6=($)=>$.name==="enter"||$.name==="return";class UG6 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor($){super();this.cause=$?.cause}}class QG6 extends Error{name="CancelPromptError";message="Prompt was canceled"}class Fe extends Error{name="ExitPromptError"}class mG6 extends Error{name="HookError"}class LB extends Error{name="ValidationError"}import{AsyncResource as Er1}from"async_hooks";import{AsyncLocalStorage as fr1,AsyncResource as Cr1}from"async_hooks";var EL8=new fr1;function vr1($){return{rl:$,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function jL8($,q){let K=vr1($);return EL8.run(K,()=>{function Y(w){K.handleChange=()=>{K.index=0,w()},K.handleChange()}return q(Y)})}function oN(){let $=EL8.getStore();if(!$)throw new mG6("[Inquirer] Hook functions can only be called from within a prompt");return $}function dG6(){return oN().rl}function cG6($){let q=(...K)=>{let Y=oN(),w=!1,H=Y.handleChange;Y.handleChange=()=>{w=!0};let J=$(...K);if(w)H();return Y.handleChange=H,J};return Cr1.bind(q)}function xI($){let q=oN(),{index:K}=q,Y={get(){return q.hooks[K]},set(H){q.hooks[K]=H},initialized:K in q.hooks},w=$(Y);return q.index++,w}function IL8(){oN().handleChange()}var tN={queue($){let q=oN(),{index:K}=q;q.hooksEffect.push(()=>{q.hooksCleanup[K]?.();let Y=$(dG6());if(Y!=null&&typeof Y!=="function")throw new LB("useEffect return value must be a cleanup function or nothing.");q.hooksCleanup[K]=Y})},run(){let $=oN();cG6(()=>{$.hooksEffect.forEach((q)=>{q()}),$.hooksEffect.length=0})()},clearAll(){let $=oN();$.hooksCleanup.forEach((q)=>{q?.()}),$.hooksEffect.length=0,$.hooksCleanup.length=0}};function UW($){return xI((q)=>{let K=Er1.bind(function(H){if(q.get()!==H)q.set(H),IL8()});if(q.initialized)return[q.get(),K];let Y=typeof $==="function"?$():$;return q.set(Y),[Y,K]})}function Ue($,q){xI((K)=>{let Y=K.get();if(!Array.isArray(Y)||q.some((H,J)=>!Object.is(H,Y[J])))tN.queue($);K.set(q)})}import{styleText as QW}from"util";import R0 from"process";function jr1(){if(R0.platform!=="win32")return R0.env.TERM!=="linux";return Boolean(R0.env.WT_SESSION)||Boolean(R0.env.TERMINUS_SUBLIME)||R0.env.ConEmuTask==="{cmd::Cmder}"||R0.env.TERM_PROGRAM==="Terminus-Sublime"||R0.env.TERM_PROGRAM==="vscode"||R0.env.TERM==="xterm-256color"||R0.env.TERM==="alacritty"||R0.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var RL8={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"},LL8={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"},Ir1={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"},Rr1={...RL8,...LL8},Lr1={...RL8,...Ir1},Sr1=jr1(),br1=Sr1?Rr1:Lr1,XT=br1,JZ9=Object.entries(LL8);var SL8={prefix:{idle:QW("blue","?"),done:QW("green",XT.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map(($)=>QW("yellow",$))},style:{answer:($)=>QW("cyan",$),message:($)=>QW("bold",$),error:($)=>QW("red",`> ${$}`),defaultAnswer:($)=>QW("dim",`(${$})`),help:($)=>QW("dim",$),highlight:($)=>QW("cyan",$),key:($)=>QW("cyan",QW("bold",`<${$}>`))}};function bL8($){if(typeof $!=="object"||$===null)return!1;let q=$;while(Object.getPrototypeOf(q)!==null)q=Object.getPrototypeOf(q);return Object.getPrototypeOf($)===q}function hL8(...$){let q={};for(let K of $)for(let[Y,w]of Object.entries(K)){let H=q[Y];q[Y]=bL8(H)&&bL8(w)?hL8(H,w):w}return q}function SB(...$){let q=[SL8,...$.filter((K)=>K!=null)];return hL8(...q)}function lG6({status:$="idle",theme:q}){let[K,Y]=UW(!1),[w,H]=UW(0),{prefix:J,spinner:W}=SB(q);if(Ue(()=>{if($==="loading"){let X,O=-1,D=setTimeout(()=>{Y(!0),X=setInterval(()=>{O=O+1,H(O%W.frames.length)},W.interval)},300);return()=>{clearTimeout(D),clearInterval(X)}}else Y(!1)},[$]),K)return W.frames[w];return typeof J==="string"?J:J[$==="loading"?"idle":$]??J.idle}function pG6($,q){return xI((K)=>{let Y=K.get();if(!Y||Y.dependencies.length!==q.length||Y.dependencies.some((w,H)=>w!==q[H])){let w=$();return K.set({value:w,dependencies:q}),w}return Y.value})}function Qe($){return UW({current:$})[0]}function iG6($){let q=Qe($);q.current=$,Ue((K)=>{let Y=!1,w=cG6((H,J)=>{if(Y)return;q.current(J,K)});return K.input.on("keypress",w),()=>{Y=!0,K.input.removeListener("keypress",w)}},[])}var gL8=Z1(OT(),1);function bB($,q){return $.split(`
|
|
3860
|
+
`)]}async makePdfStatement($,q){let K=i1($,q);await ue(K);let Y=new Date().toISOString(),w=new Date().getFullYear(),H=this.problem.problemLangYmls[this.problem.originalLanguage].author||"Unknown",J=this.problem.problemLangYmls[this.problem.originalLanguage].author_email||"unknown email",W=this.problem.problemLangYmls[q].translator||"",[P,X]=await this.makeSamples(K,q),O=await l7(i1(fL8,"root-pdf.tpl.tex"));IB.default.registerHelper("curly",function(A){return"{"+A+"}"});let D=IB.default.compile(O)({language:q,jutgeLanguage:`jutge.${q}`,id:`${this.problem_nm}\\_${q}`,samples1c:P,samples2c:X,author:H,translator:W,date:Y,year:w});for await(let A of NL8("*",{cwd:this.problem.directory})){if(A.startsWith(d$())||A.endsWith(".exe")||A.endsWith(".html")||A.endsWith(".md")||A.endsWith(".txt")||await L_6(this.problem.directory,A))continue;await FW(i1(this.problem.directory,A),i1(K,A))}await f3(i1(K,"root.tex"),D);let z=(await l7(i1(K,`problem.${q}.tex`))).replace(/\\begin{htmlonly}[\s\S]*?\\end{htmlonly}/g,"").replace(/\\begin{latexonly}/g,"").replace(/\\end{latexonly}/g,"").replace(/\.eps}/g,"}");if(await f3(i1(K,`problem.${q}.tex`),z),await this.copyStyleFiles(K,q),!await _L8()){B.error("xelatex not found");return}try{B.command("xelatex -interaction=nonstopmode -file-line-error root.tex"),await l1({stderr:"inherit",cwd:K})`xelatex -interaction=nonstopmode -file-line-error root.tex`,await FW(i1(K,"root.pdf"),i1(this.problem.directory,`problem.${q}.pdf`)),B.success(`Generated ${B.hyperlink(this.problem.directory,`problem.${q}.pdf`)} see ${B.hyperlink(K,"root.log")}`)}catch(A){B.error(`Error in LaTeX: ${B.hyperlink(K,"root.log")}`)}}async copyStyleFiles($,q){let K=async(Y)=>{let w=i1(m$(),"assets","sty",Y);await FW(w,i1($,Y))};if(await K("picins.sty"),await K("jutge.sty"),q==="ca")await K("jutge.ca.sty");if(q==="es")await K("jutge.es.sty");if(q==="en")await K("jutge.en.sty");if(q==="fr")await K("jutge.fr.sty");if(q==="de")await K("jutge.de.sty")}async makeTextualStatements($=["txt","html","md"]){await B.section("Making textual statements",async()=>{let q=i1(this.problem.directory,d$()+"-text",CC());await ue(q,{recursive:!0}),await B.section("Creating working directory",async()=>{await c9(),B.directory(q)});try{for(let K of this.problem.languages)if(this.problem.structure==="multi"||this.problem.structure==="single"&&K===this.problem.language)await B.section(`Making textual statements for ${s5[K]}`,async()=>{await this.makeTextualStatement(q,K,$)})}finally{}})}async makeTextualStatement($,q,K){let Y=i1($,q);await ue(Y);let w=new Date().toISOString(),H=new Date().getFullYear(),J=this.problem.problemLangYmls[q].author||"Unknown",W=this.problem.problemLangYmls[q].author_email||"unknown email",P=this.problem.problemLangYmls[q].translator||"",X=await l7(i1(fL8,"root-text-short.tpl.tex"));IB.default.registerHelper("curly",function(A){return"{"+A+"}"});let O=IB.default.compile(X)({language:q,jutgeLanguage:`jutge.${q}`,id:`${this.problem_nm}\\_${q}`,year:H,author:J,translator:P,date:w});for await(let A of NL8("*",{cwd:this.problem.directory})){if(A.startsWith(d$())||A.endsWith(".pdf")||A.endsWith(".exe")||A.endsWith(".html")||A.endsWith(".md")||A.endsWith(".txt")||await L_6(this.problem.directory,A))continue;await FW(i1(this.problem.directory,A),i1(Y,A))}await f3(i1(Y,"root.tex"),O);let Z=(await l7(i1(Y,`problem.${q}.tex`))).replace(/\\begin{latexonly}[\s\S]*?\\end{latexonly}/g,"").replace(/\\begin{htmlonly}/g,"").replace(/\\end{htmlonly}/g,"").replace(/\\begin{minipage}/g,"").replace(/\\end{minipage}/g,"");if(await f3(i1(Y,`problem.${q}.tex`),Z),await this.copyStyleFiles(Y,q),!await wL8()){B.error("pandoc with lua support not found");return}let z=i1(m$(),"assets","lua","fixCodeBlocks.lua");if(await FW(z,i1(Y,"fixCodeBlocks.lua")),K.includes("txt"))try{B.command("pandoc --quiet root.tex --to plain --output root.txt"),await l1({cwd:Y})`pandoc --quiet root.tex --to plain --output root.txt`,await FW(i1(Y,"root.txt"),i1(this.problem.directory,`problem.${q}.txt`)),B.success("Generated "+B.hyperlink(this.problem.directory,`problem.${q}.txt`))}catch(A){console.error("pandoc error",A)}if(K.includes("md"))try{B.command("pandoc --quiet root.tex --to markdown --to markdown-header_attributes --lua-filter=fixCodeBlocks.lua --output root.md"),await l1({cwd:Y})`pandoc --quiet root.tex --to markdown --to markdown-header_attributes --lua-filter=fixCodeBlocks.lua --output root.md`,await FW(i1(Y,"root.md"),i1(this.problem.directory,`problem.${q}.md`)),B.success("Generated "+B.hyperlink(this.problem.directory,`problem.${q}.md`))}catch(A){console.error("pandoc error",A)}if(K.includes("html"))try{B.command("pandoc --quiet root.tex --to html --mathml --embed-resources --output root.html"),await l1({cwd:Y})`pandoc --quiet root.tex --to html --mathml --embed-resources --output root.html`,await FW(i1(Y,"root.html"),i1(this.problem.directory,`problem.${q}.html`)),B.success("Generated "+B.hyperlink(this.problem.directory,`problem.${q}.html`))}catch(A){console.error("pandoc error",A)}}async verifyCandidate($){await B.section(`Verifying ${$}`,async()=>{let q=$.split(".").pop(),K=RG6(q),Y=`${d$()}-${$}`;await B.section(`Copying ${B.hyperlink(this.problem.directory,$)} to ${B.hyperlink(this.problem.directory,Y)}`,async()=>{await FW(i1(this.problem.directory,$),i1(this.problem.directory,Y))}),await B.section(`Using compiler ${K.name()} to compile ${B.hyperlink(this.problem.directory,Y)}`,async()=>{try{let H;if(this.problem.handler.source_modifier==="none")H=await K.compileNormal(this.problem.handler,this.problem.directory,Y);else if(this.problem.handler.source_modifier==="no_main")H=await K.compileWithMain(this.problem.handler,this.problem.directory,Y);else throw Error(`Unknown source modifier: ${this.problem.handler.source_modifier}`);if(!await VL8(i1(this.problem.directory,H)))throw Error(`Compilation failed for ${Y}`);B.success(`Compiled ${Y} to ${H}`)}catch(H){throw Error("Compilation failed")}});let w=[];await B.section("Executing testcases",async()=>{for(let J of this.problem.testcases)w.push(await this.runTestcase(J,`${J}.inp`,`${d$()}-${J}.${q}.out`,K,Y));console.log(),console.log("testcase time status");let H=0;for(let J of w){let W=J.error?"EE":await ak6(i1(this.problem.directory,`${J.testcase}.cor`),i1(this.problem.directory,`${d$()}-${J.testcase}.${q}.out`))?"OK":"WA",P=YC(J.time);if(console.log((W!=="OK"?d5.red:d5.green)(`${J.testcase.padEnd(12)} ${P.padStart(10)} ${W.padStart(10)}`)),W!=="OK")H++}if(console.log(),H)B.error(`${H} errors found for ${$}`);else B.success(`All testcases passed successfully for ${$}`)})})}}var vL8=new R5("verify").description("Verify programs against golden solution").argument("<programs...>","source programs to verify").option("-d, --directory <path>","problem directory",".").action(async($,{directory:q})=>{let K=await Be(q);for(let Y of $)await K.verifyCandidate(Y)});import rs1 from"path";var RB=($,q=[])=>$.name==="up"||q.includes("vim")&&$.name==="k"||q.includes("emacs")&&$.ctrl&&$.name==="p",xe=($,q=[])=>$.name==="down"||q.includes("vim")&&$.name==="j"||q.includes("emacs")&&$.ctrl&&$.name==="n",BG6=($)=>$.name==="space";var xG6=($)=>"1234567890".includes($.name),FG6=($)=>$.name==="enter"||$.name==="return";class UG6 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor($){super();this.cause=$?.cause}}class QG6 extends Error{name="CancelPromptError";message="Prompt was canceled"}class Fe extends Error{name="ExitPromptError"}class mG6 extends Error{name="HookError"}class LB extends Error{name="ValidationError"}import{AsyncResource as Er1}from"async_hooks";import{AsyncLocalStorage as fr1,AsyncResource as Cr1}from"async_hooks";var EL8=new fr1;function vr1($){return{rl:$,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function jL8($,q){let K=vr1($);return EL8.run(K,()=>{function Y(w){K.handleChange=()=>{K.index=0,w()},K.handleChange()}return q(Y)})}function oN(){let $=EL8.getStore();if(!$)throw new mG6("[Inquirer] Hook functions can only be called from within a prompt");return $}function dG6(){return oN().rl}function cG6($){let q=(...K)=>{let Y=oN(),w=!1,H=Y.handleChange;Y.handleChange=()=>{w=!0};let J=$(...K);if(w)H();return Y.handleChange=H,J};return Cr1.bind(q)}function xI($){let q=oN(),{index:K}=q,Y={get(){return q.hooks[K]},set(H){q.hooks[K]=H},initialized:K in q.hooks},w=$(Y);return q.index++,w}function IL8(){oN().handleChange()}var tN={queue($){let q=oN(),{index:K}=q;q.hooksEffect.push(()=>{q.hooksCleanup[K]?.();let Y=$(dG6());if(Y!=null&&typeof Y!=="function")throw new LB("useEffect return value must be a cleanup function or nothing.");q.hooksCleanup[K]=Y})},run(){let $=oN();cG6(()=>{$.hooksEffect.forEach((q)=>{q()}),$.hooksEffect.length=0})()},clearAll(){let $=oN();$.hooksCleanup.forEach((q)=>{q?.()}),$.hooksEffect.length=0,$.hooksCleanup.length=0}};function UW($){return xI((q)=>{let K=Er1.bind(function(H){if(q.get()!==H)q.set(H),IL8()});if(q.initialized)return[q.get(),K];let Y=typeof $==="function"?$():$;return q.set(Y),[Y,K]})}function Ue($,q){xI((K)=>{let Y=K.get();if(!Array.isArray(Y)||q.some((H,J)=>!Object.is(H,Y[J])))tN.queue($);K.set(q)})}import{styleText as QW}from"util";import R0 from"process";function jr1(){if(R0.platform!=="win32")return R0.env.TERM!=="linux";return Boolean(R0.env.WT_SESSION)||Boolean(R0.env.TERMINUS_SUBLIME)||R0.env.ConEmuTask==="{cmd::Cmder}"||R0.env.TERM_PROGRAM==="Terminus-Sublime"||R0.env.TERM_PROGRAM==="vscode"||R0.env.TERM==="xterm-256color"||R0.env.TERM==="alacritty"||R0.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var RL8={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"},LL8={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"},Ir1={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"},Rr1={...RL8,...LL8},Lr1={...RL8,...Ir1},Sr1=jr1(),br1=Sr1?Rr1:Lr1,XT=br1,JZ9=Object.entries(LL8);var SL8={prefix:{idle:QW("blue","?"),done:QW("green",XT.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map(($)=>QW("yellow",$))},style:{answer:($)=>QW("cyan",$),message:($)=>QW("bold",$),error:($)=>QW("red",`> ${$}`),defaultAnswer:($)=>QW("dim",`(${$})`),help:($)=>QW("dim",$),highlight:($)=>QW("cyan",$),key:($)=>QW("cyan",QW("bold",`<${$}>`))}};function bL8($){if(typeof $!=="object"||$===null)return!1;let q=$;while(Object.getPrototypeOf(q)!==null)q=Object.getPrototypeOf(q);return Object.getPrototypeOf($)===q}function hL8(...$){let q={};for(let K of $)for(let[Y,w]of Object.entries(K)){let H=q[Y];q[Y]=bL8(H)&&bL8(w)?hL8(H,w):w}return q}function SB(...$){let q=[SL8,...$.filter((K)=>K!=null)];return hL8(...q)}function lG6({status:$="idle",theme:q}){let[K,Y]=UW(!1),[w,H]=UW(0),{prefix:J,spinner:W}=SB(q);if(Ue(()=>{if($==="loading"){let X,O=-1,D=setTimeout(()=>{Y(!0),X=setInterval(()=>{O=O+1,H(O%W.frames.length)},W.interval)},300);return()=>{clearTimeout(D),clearInterval(X)}}else Y(!1)},[$]),K)return W.frames[w];return typeof J==="string"?J:J[$==="loading"?"idle":$]??J.idle}function pG6($,q){return xI((K)=>{let Y=K.get();if(!Y||Y.dependencies.length!==q.length||Y.dependencies.some((w,H)=>w!==q[H])){let w=$();return K.set({value:w,dependencies:q}),w}return Y.value})}function Qe($){return UW({current:$})[0]}function iG6($){let q=Qe($);q.current=$,Ue((K)=>{let Y=!1,w=cG6((H,J)=>{if(Y)return;q.current(J,K)});return K.input.on("keypress",w),()=>{Y=!0,K.input.removeListener("keypress",w)}},[])}var gL8=Z1(OT(),1);function bB($,q){return $.split(`
|
|
3861
3861
|
`).flatMap((K)=>y_(K,q,{trim:!1,hard:!0}).split(`
|
|
3862
3862
|
`).map((Y)=>Y.trimEnd())).join(`
|
|
3863
3863
|
`)}function me(){return gL8.default({defaultWidth:80,output:dG6().output})}function gr1({active:$,renderedItems:q,pageSize:K,loop:Y}){let w=Qe({lastPointer:$,lastActive:void 0}),{lastPointer:H,lastActive:J}=w.current,W=Math.floor(K/2),P=q.reduce((D,Z)=>D+Z.length,0),X=q.slice(0,$).reduce((D,Z)=>D+Z.length,0),O=X;if(P>K)if(Y){if(O=H,J!=null&&J<$&&$-J<K)O=Math.min(W,Math.abs($-J)===1?Math.min(H+(q[J]?.length??0),Math.max(X,H)):H+$-J)}else{let D=q.slice($).reduce((Z,z)=>Z+z.length,0);O=D<K-W?K-D:Math.min(X,W)}return w.current.lastPointer=O,w.current.lastActive=$,O}function nG6({items:$,active:q,renderItem:K,pageSize:Y,loop:w=!0}){let H=me(),J=(v)=>(v%$.length+$.length)%$.length,W=$.map((v,j)=>{if(v==null)return[];return bB(K({item:v,index:j,isActive:j===q}),H).split(`
|
|
@@ -4069,7 +4069,7 @@ Provide an interesting prompt to customize the message content. For example:
|
|
|
4069
4069
|
- "A congratulatory message for completing a difficult task."
|
|
4070
4070
|
- "A motivational quote to inspire further learning."
|
|
4071
4071
|
|
|
4072
|
-
The new message will be saved as award.html in the problem directory, overriding any existing file.`).option("-d, --directory <path>","problem directory",".").argument("[prompt]","prompt to generate the award message","Only provide a short encouraging message after having solved a challenge or a problem. Nothing else!").option("-m, --model <model>","AI model to use",u7.defaultModel).action(async($,{directory:q,model:K})=>{let Y=Mg8(q,"award.html"),w=await _H(q),H=await BW(K,"",$);B.print(H),await f3(Y,H),B.success(`Added ${Y}`)});import{join as O67,resolve as D67}from"path";var Cg8=new R5("make").description("Make problem elements").argument("[tasks...]","tasks to make: all|info|exe|cor|pdf|txt|md|html",["all"]).option("-d, --directories <directories...>","problem directories",["."]).option("-i, --ignore-errors","ignore errors on a directory and continue processing",!1).option("-e, --only-errors","only show errors at the final summary",!1).action(async($,{directories:q,ignoreErrors:K,onlyErrors:Y})=>{if($.length===0)$=["all"];if($.includes("all")&&$.length>1)throw Error("When 'all' is specified, no other tasks should be provided");if(!$.every((J)=>["all","info","exe","cor","pdf","txt","md","html"].includes(J)))throw Error("Tasks must be one of: all, info, exe, cor, pdf, txt, md, html");console.log(),await B.image(O67(m$(),"assets","images","jutge-toolkit.png"),8,4);let w={},H=await rW(q);for(let J of H){try{B.title(`Making problem in directory ${B.hyperlink(J,D67(J))}`);let W=await Be(J);if($.includes("all"))await W.makeProblem();else{if($.includes("info"));if($.includes("exe"))await W.makeExecutables();if($.includes("cor"))await W.makeCorrectOutputs();if($.includes("pdf"))await W.makePdfStatements();if($.includes("txt")||$.includes("html")||$.includes("md"))await W.makeTextualStatements($.filter((P)=>["txt","html","md"].includes(P)))}}catch(W){let P=W instanceof Error?W.message:String(W);if(K)w[J]=P,B.error(`Error: ${P}`);else throw W}console.log()}B.title("Summary"),await B.section("",async()=>{if(await c9(),H.length===0)B.warning("No problem directories found");for(let J of H)if(w[J])B.directory(J),B.error(` ${w[J]}`);else if(!Y)B.directory(J),B.success(" No errors found")})});yI();import Z67 from"path";async function vg8($){let q={};if(await B.section(`Validating ${B.hyperlink($,"quiz.yml")}`,async()=>{try{let K=await pJ($,"quiz.yml");q=b_6.parse(K),B.success("quiz.yml is valid")}catch(K){if(K instanceof Error)if(K instanceof $G)B.error(ZA(K).toString());else B.error(K.message);else B.error(String(K))}}),!q.questions)return;for(let[K,Y]of q.questions.entries()){let w=`${Y.file}.yml`;await B.section(`Validating ${B.hyperlink($,w)}`,async()=>{try{let H=await pJ($,w),J=h_6.parse(H);B.success(`${w} is valid`)}catch(H){if(H instanceof Error)if(H instanceof $G)B.error(ZA(H).toString());else B.error(H.message);else B.error(String(H))}})}}async function Eg8($,q){let K=await pJ($,"quiz.yml"),Y=b_6.parse(K);if(Y.shuffle)hG6(Y.questions);let w={title:Y.title,statement:Y.statement,shuffle:Y.shuffle,seed:q,"time-generation":new Date().toISOString(),questions:[]};for(let H of Y.questions)w.questions.push(await G67($,H,q));console.log(JSON.stringify(w,null,4))}async function G67($,q,K){let Y=await pJ($,`${q.file}.yml`),w=h_6.parse(Y),H=await h_($,`${q.file}.py`),J=await T67(H);return{title:q.title,file:q.file,score:q.score,points:0,q:z67(w,J,K),a:{}}}function z67($,q,K){return{...$,text:A67($.text,q)}}async function T67($){let q=Z67.join(m$(),"assets","python","pyexec.py"),{exitCode:K,stdout:Y}=await l1({reject:!1,input:$,stderr:"inherit"})`python3 ${q}`;return JSON.parse(Y)}function A67($,q){return $.replace(/\$\{?(\w+)\}?/g,(K,Y)=>{return Y in q?q[Y]:K})}yI();var Yx=new R5("quiz").description("Commands related to quizzes").action(()=>{Yx.help()});Yx.command("validate").description("Validate a quiz problem").option("-d, --directories <directories...>","problem directories",["."]).action(async({directories:$})=>{let q=await rW($);for(let K of q)await B.section(`Validating quiz in directory ${B.hyperlink(K)}`,async()=>{await vg8(K)})});Yx.command("make").description("Make a quiz problem").option("-d, --directory <directory>","problem directory",".").option("-s, --seed <seed>","random seed").action(async({directory:$,seed:q})=>{B.warning("The quiz make command is work-in-progress and may not work as expected yet.");let K=await rW([$]),Y=q?parseInt(q,10):bG6(1e6,9999999);for(let w of K){await Eg8(w,Y);return}});var jg8=new R5("upgrade").description("Upgrade to the latest version").action(async()=>{await Gi6()});var Mi8=Z1(Yy8(),1);import{exists as eP7,glob as y46,mkdir as fi8}from"fs/promises";import{basename as g46,join as RJ,normalize as $07}from"path";class r66 extends Error{message;name="UnauthorizedError";constructor($="Unauthorized"){super($);this.message=$}}class wy8 extends Error{message;name="InfoError";constructor($){super($);this.message=$}}class Hy8 extends Error{message;name="NotFoundError";constructor($){super($);this.message=$}}class Jy8 extends Error{message;name="InputError";constructor($){super($);this.message=$}}class Wy8 extends Error{message;name="ProtocolError";constructor($){super($);this.message=$}}class Px{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,K=[]){let Y=this.useCache&&this.clientTTLs.has($)&&K.length===0;if(Y){let C=JSON.stringify({func:$,input:q}),v=this.cache.get(C);if(v!==void 0){if(this.logCache)console.log("found");let j=this.clientTTLs.get($);if(v.epoch+j*1000>new Date().valueOf()){if(this.logCache)console.log("used");return[v.output,v.ofiles]}else{if(this.logCache)console.log("expired");this.cache.delete(C)}}}if(this.logCache)console.log("fetch");let w=new FormData,H={func:$,input:q,meta:this.meta};w.append("data",JSON.stringify(H));for(let C in K)w.append(`file_${C}`,K[C]);let J=await fetch(this.JUTGE_API_URL,{method:"POST",body:w,headers:this.headers});if(J.headers.get("content-type")?.split(";")[0].toLowerCase()!=="multipart/form-data")throw new Wy8("The content type is not multipart/form-data");let P=await J.formData(),X=P.get("data"),{output:O,error:D,duration:Z,operation_id:z,time:A}=JSON.parse(X);if(D)this.throwError(D,z);let N=[];for(let C of P.keys()){let v=P.get(C);if(v instanceof File)N.push({data:new Uint8Array(await v.arrayBuffer()),name:v.name,type:v.type})}if(Y){if(this.logCache)console.log("saved");let C=JSON.stringify({func:$,input:q});this.cache.set(C,{output:O,ofiles:N,epoch:new Date().valueOf()})}return[O,N]}throwError($,q){let K=$.message||"Unknown error";if($.name==="UnauthorizedError")throw new r66(K);else if($.name==="InfoError")throw new wy8(K);else if($.name==="NotFoundError")throw new Hy8(K);else if($.name==="InputError")throw new Jy8(K);else throw Error(K)}async login({email:$,password:q}){let[K,Y]=await this.execute("auth.login",{email:$,password:q});if(K.error)throw new r66(K.error);return this.meta={token:K.token},K}async loginExam({email:$,password:q,exam:K,exam_password:Y}){let[w,H]=await this.execute("auth.loginExam",{email:$,password:q,exam:K,exam_password:Y});if(w.error)throw new r66(w.error);return this.meta={token:w.token},w}async logout(){await this.execute("auth.logout",null),this.meta=null}clearCache(){if(this.logCache)console.log("clear");this.cache=new Map}setCache($){let q=JSON.parse($);this.cache=new Map(Object.entries(q)),this.removeExpired()}getCache(){this.removeExpired();let $=Object.fromEntries(this.cache.entries());return JSON.stringify($)}removeExpired(){for(let[$,q]of this.cache){let{func:K}=JSON.parse($),Y=this.clientTTLs.get(K);if(Y!==void 0&&q.epoch+Y*1000<new Date().getTime())this.cache.delete($)}}clients;auth;misc;tables;problems;student;instructor;admin;testing;constructor(){this.clients=new Py8(this),this.auth=new Xy8(this),this.misc=new Oy8(this),this.tables=new Dy8(this),this.problems=new Zy8(this),this.student=new Gy8(this),this.instructor=new Ey8(this),this.admin=new ky8(this),this.testing=new Qy8(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 Py8{root;constructor($){this.root=$}async python(){let[$,q]=await this.root.execute("clients.python",null);return q[0]}async typescript(){let[$,q]=await this.root.execute("clients.typescript",null);return q[0]}async javascript(){let[$,q]=await this.root.execute("clients.javascript",null);return q[0]}async java(){let[$,q]=await this.root.execute("clients.java",null);return q[0]}async cpp(){let[$,q]=await this.root.execute("clients.cpp",null);return q[0]}async php(){let[$,q]=await this.root.execute("clients.php",null);return q[0]}}class Xy8{root;constructor($){this.root=$}async login($){let[q,K]=await this.root.execute("auth.login",$);return q}async logout(){let[$,q]=await this.root.execute("auth.logout",null);return $}async loginExam($){let[q,K]=await this.root.execute("auth.loginExam",$);return q}}class Oy8{root;constructor($){this.root=$}async getApiVersion(){let[$,q]=await this.root.execute("misc.getApiVersion",null);return $}async getRequestInformation(){let[$,q]=await this.root.execute("misc.getRequestInformation",null);return $}async getFortune(){let[$,q]=await this.root.execute("misc.getFortune",null);return $}async getTime(){let[$,q]=await this.root.execute("misc.getTime",null);return $}async getHomepageStats(){let[$,q]=await this.root.execute("misc.getHomepageStats",null);return $}async getLogo(){let[$,q]=await this.root.execute("misc.getLogo",null);return q[0]}async getAvatarPacks(){let[$,q]=await this.root.execute("misc.getAvatarPacks",null);return $}async getExamIcons(){let[$,q]=await this.root.execute("misc.getExamIcons",null);return $}async getColors(){let[$,q]=await this.root.execute("misc.getColors",null);return $}async getHexColors(){let[$,q]=await this.root.execute("misc.getHexColors",null);return $}async getDemosForCompiler($){let[q,K]=await this.root.execute("misc.getDemosForCompiler",$);return q}}class Dy8{root;constructor($){this.root=$}async get(){let[$,q]=await this.root.execute("tables.get",null);return $}async getLanguages(){let[$,q]=await this.root.execute("tables.getLanguages",null);return $}async getCountries(){let[$,q]=await this.root.execute("tables.getCountries",null);return $}async getCompilers(){let[$,q]=await this.root.execute("tables.getCompilers",null);return $}async getDrivers(){let[$,q]=await this.root.execute("tables.getDrivers",null);return $}async getVerdicts(){let[$,q]=await this.root.execute("tables.getVerdicts",null);return $}async getProglangs(){let[$,q]=await this.root.execute("tables.getProglangs",null);return $}}class Zy8{root;constructor($){this.root=$}async getAllAbstractProblems(){let[$,q]=await this.root.execute("problems.getAllAbstractProblems",null);return $}async getAbstractProblems($){let[q,K]=await this.root.execute("problems.getAbstractProblems",$);return q}async getAbstractProblemsInList($){let[q,K]=await this.root.execute("problems.getAbstractProblemsInList",$);return q}async getAbstractProblem($){let[q,K]=await this.root.execute("problems.getAbstractProblem",$);return q}async getAbstractProblemSuppl($){let[q,K]=await this.root.execute("problems.getAbstractProblemSuppl",$);return q}async getProblem($){let[q,K]=await this.root.execute("problems.getProblem",$);return q}async getProblemRich($){let[q,K]=await this.root.execute("problems.getProblemRich",$);return q}async getProblemSuppl($){let[q,K]=await this.root.execute("problems.getProblemSuppl",$);return q}async getSampleTestcases($){let[q,K]=await this.root.execute("problems.getSampleTestcases",$);return q}async getPublicTestcases($){let[q,K]=await this.root.execute("problems.getPublicTestcases",$);return q}async getHtmlStatement($){let[q,K]=await this.root.execute("problems.getHtmlStatement",$);return q}async getTextStatement($){let[q,K]=await this.root.execute("problems.getTextStatement",$);return q}async getMarkdownStatement($){let[q,K]=await this.root.execute("problems.getMarkdownStatement",$);return q}async getPdfStatement($){let[q,K]=await this.root.execute("problems.getPdfStatement",$);return K[0]}async getZipStatement($){let[q,K]=await this.root.execute("problems.getZipStatement",$);return K[0]}async getTemplates($){let[q,K]=await this.root.execute("problems.getTemplates",$);return q}async getTemplate($){let[q,K]=await this.root.execute("problems.getTemplate",$);return K[0]}async semanticSearch($){let[q,K]=await this.root.execute("problems.semanticSearch",$);return q}async fullTextSearch($){let[q,K]=await this.root.execute("problems.fullTextSearch",$);return q}}class Gy8{root;keys;profile;dashboard;submissions;courses;lists;exam;statuses;awards;constructor($){this.root=$,this.keys=new zy8($),this.profile=new Ty8($),this.dashboard=new Ay8($),this.submissions=new Vy8($),this.courses=new Ny8($),this.lists=new My8($),this.exam=new fy8($),this.statuses=new Cy8($),this.awards=new vy8($)}}class zy8{root;constructor($){this.root=$}async get(){let[$,q]=await this.root.execute("student.keys.get",null);return $}async getProblems(){let[$,q]=await this.root.execute("student.keys.getProblems",null);return $}async getEnrolledCourses(){let[$,q]=await this.root.execute("student.keys.getEnrolledCourses",null);return $}async getAvailableCourses(){let[$,q]=await this.root.execute("student.keys.getAvailableCourses",null);return $}async getLists(){let[$,q]=await this.root.execute("student.keys.getLists",null);return $}}class Ty8{root;constructor($){this.root=$}async get(){let[$,q]=await this.root.execute("student.profile.get",null);return $}async getAvatar(){let[$,q]=await this.root.execute("student.profile.getAvatar",null);return q[0]}async update($){let[q,K]=await this.root.execute("student.profile.update",$);return q}async updateAvatar($){let[q,K]=await this.root.execute("student.profile.updateAvatar",null,[$]);return q}async updatePassword($){let[q,K]=await this.root.execute("student.profile.updatePassword",$);return q}}class Ay8{root;constructor($){this.root=$}async getAbsoluteRanking(){let[$,q]=await this.root.execute("student.dashboard.getAbsoluteRanking",null);return $}async getAllDistributions(){let[$,q]=await this.root.execute("student.dashboard.getAllDistributions",null);return $}async getCompilersDistribution(){let[$,q]=await this.root.execute("student.dashboard.getCompilersDistribution",null);return $}async getDashboard(){let[$,q]=await this.root.execute("student.dashboard.getDashboard",null);return $}async getHeatmapCalendar(){let[$,q]=await this.root.execute("student.dashboard.getHeatmapCalendar",null);return $}async getProglangsDistribution(){let[$,q]=await this.root.execute("student.dashboard.getProglangsDistribution",null);return $}async getStats(){let[$,q]=await this.root.execute("student.dashboard.getStats",null);return $}async getLevel(){let[$,q]=await this.root.execute("student.dashboard.getLevel",null);return $}async getSubmissionsByHour(){let[$,q]=await this.root.execute("student.dashboard.getSubmissionsByHour",null);return $}async getSubmissionsByWeekDay(){let[$,q]=await this.root.execute("student.dashboard.getSubmissionsByWeekDay",null);return $}async getVerdictsDistribution(){let[$,q]=await this.root.execute("student.dashboard.getVerdictsDistribution",null);return $}}class Vy8{root;constructor($){this.root=$}async indexForAbstractProblem($){let[q,K]=await this.root.execute("student.submissions.indexForAbstractProblem",$);return q}async indexForProblem($){let[q,K]=await this.root.execute("student.submissions.indexForProblem",$);return q}async getAll(){let[$,q]=await this.root.execute("student.submissions.getAll",null);return $}async submit($){let[q,K]=await this.root.execute("student.submissions.submit",$);return q}async submitFull($,q){let[K,Y]=await this.root.execute("student.submissions.submitFull",$,[q]);return K}async get($){let[q,K]=await this.root.execute("student.submissions.get",$);return q}async getCodeAsB64($){let[q,K]=await this.root.execute("student.submissions.getCodeAsB64",$);return q}async getCodeMetrics($){let[q,K]=await this.root.execute("student.submissions.getCodeMetrics",$);return q}async getAwards($){let[q,K]=await this.root.execute("student.submissions.getAwards",$);return q}async getAnalysis($){let[q,K]=await this.root.execute("student.submissions.getAnalysis",$);return q}async getTestcaseAnalysis($){let[q,K]=await this.root.execute("student.submissions.getTestcaseAnalysis",$);return q}}class Ny8{root;constructor($){this.root=$}async indexAvailable(){let[$,q]=await this.root.execute("student.courses.indexAvailable",null);return $}async indexEnrolled(){let[$,q]=await this.root.execute("student.courses.indexEnrolled",null);return $}async getAvailable($){let[q,K]=await this.root.execute("student.courses.getAvailable",$);return q}async getEnrolled($){let[q,K]=await this.root.execute("student.courses.getEnrolled",$);return q}async enroll($){let[q,K]=await this.root.execute("student.courses.enroll",$);return q}async unenroll($){let[q,K]=await this.root.execute("student.courses.unenroll",$);return q}}class My8{root;constructor($){this.root=$}async getAll(){let[$,q]=await this.root.execute("student.lists.getAll",null);return $}async get($){let[q,K]=await this.root.execute("student.lists.get",$);return q}}class fy8{root;constructor($){this.root=$}async getReadyExams(){let[$,q]=await this.root.execute("student.exam.getReadyExams",null);return $}async get(){let[$,q]=await this.root.execute("student.exam.get",null);return $}async getDocument($){let[q,K]=await this.root.execute("student.exam.getDocument",$);return q}async getDocumentPdf($){let[q,K]=await this.root.execute("student.exam.getDocumentPdf",$);return K[0]}async getRanking(){let[$,q]=await this.root.execute("student.exam.getRanking",null);return $}}class Cy8{root;constructor($){this.root=$}async getAll(){let[$,q]=await this.root.execute("student.statuses.getAll",null);return $}async getForAbstractProblem($){let[q,K]=await this.root.execute("student.statuses.getForAbstractProblem",$);return q}async getForProblem($){let[q,K]=await this.root.execute("student.statuses.getForProblem",$);return q}}class vy8{root;constructor($){this.root=$}async getAll(){let[$,q]=await this.root.execute("student.awards.getAll",null);return $}async get($){let[q,K]=await this.root.execute("student.awards.get",$);return q}}class Ey8{root;documents;lists;courses;exams;problems;queries;tags;constructor($){this.root=$,this.documents=new jy8($),this.lists=new Iy8($),this.courses=new Ry8($),this.exams=new Ly8($),this.problems=new Sy8($),this.queries=new by8($),this.tags=new hy8($)}}class jy8{root;constructor($){this.root=$}async index(){let[$,q]=await this.root.execute("instructor.documents.index",null);return $}async get($){let[q,K]=await this.root.execute("instructor.documents.get",$);return q}async getPdf($){let[q,K]=await this.root.execute("instructor.documents.getPdf",$);return K[0]}async create($,q){let[K,Y]=await this.root.execute("instructor.documents.create",$,[q]);return K}async update($,q){let[K,Y]=await this.root.execute("instructor.documents.update",$,[q]);return K}async remove($){let[q,K]=await this.root.execute("instructor.documents.remove",$);return q}}class Iy8{root;constructor($){this.root=$}async index(){let[$,q]=await this.root.execute("instructor.lists.index",null);return $}async get($){let[q,K]=await this.root.execute("instructor.lists.get",$);return q}async create($){let[q,K]=await this.root.execute("instructor.lists.create",$);return q}async update($){let[q,K]=await this.root.execute("instructor.lists.update",$);return q}async remove($){let[q,K]=await this.root.execute("instructor.lists.remove",$);return q}async getArchived(){let[$,q]=await this.root.execute("instructor.lists.getArchived",null);return $}async archive($){let[q,K]=await this.root.execute("instructor.lists.archive",$);return q}async unarchive($){let[q,K]=await this.root.execute("instructor.lists.unarchive",$);return q}}class Ry8{root;constructor($){this.root=$}async index(){let[$,q]=await this.root.execute("instructor.courses.index",null);return $}async get($){let[q,K]=await this.root.execute("instructor.courses.get",$);return q}async create($){let[q,K]=await this.root.execute("instructor.courses.create",$);return q}async update($){let[q,K]=await this.root.execute("instructor.courses.update",$);return q}async remove($){let[q,K]=await this.root.execute("instructor.courses.remove",$);return q}async sendInviteToStudents($){let[q,K]=await this.root.execute("instructor.courses.sendInviteToStudents",$);return q}async sendInviteToTutors($){let[q,K]=await this.root.execute("instructor.courses.sendInviteToTutors",$);return q}async getStudentProfiles($){let[q,K]=await this.root.execute("instructor.courses.getStudentProfiles",$);return q}async getTutorProfiles($){let[q,K]=await this.root.execute("instructor.courses.getTutorProfiles",$);return q}async getArchived(){let[$,q]=await this.root.execute("instructor.courses.getArchived",null);return $}async archive($){let[q,K]=await this.root.execute("instructor.courses.archive",$);return q}async unarchive($){let[q,K]=await this.root.execute("instructor.courses.unarchive",$);return q}}class Ly8{root;constructor($){this.root=$}async index(){let[$,q]=await this.root.execute("instructor.exams.index",null);return $}async get($){let[q,K]=await this.root.execute("instructor.exams.get",$);return q}async getDocuments($){let[q,K]=await this.root.execute("instructor.exams.getDocuments",$);return q}async getProblems($){let[q,K]=await this.root.execute("instructor.exams.getProblems",$);return q}async getStudents($){let[q,K]=await this.root.execute("instructor.exams.getStudents",$);return q}async getStudent($){let[q,K]=await this.root.execute("instructor.exams.getStudent",$);return q}async getSubmissions($){let[q,K]=await this.root.execute("instructor.exams.getSubmissions",$);return q}async getSubmissionsPack($){let[q,K]=await this.root.execute("instructor.exams.getSubmissionsPack",$);return q}async getStatistics($){let[q,K]=await this.root.execute("instructor.exams.getStatistics",$);return q}async create($){let[q,K]=await this.root.execute("instructor.exams.create",$);return q}async update($){let[q,K]=await this.root.execute("instructor.exams.update",$);return q}async updateDocuments($){let[q,K]=await this.root.execute("instructor.exams.updateDocuments",$);return q}async updateCompilers($){let[q,K]=await this.root.execute("instructor.exams.updateCompilers",$);return q}async updateProblems($){let[q,K]=await this.root.execute("instructor.exams.updateProblems",$);return q}async updateStudents($){let[q,K]=await this.root.execute("instructor.exams.updateStudents",$);return q}async addStudents($){let[q,K]=await this.root.execute("instructor.exams.addStudents",$);return q}async removeStudents($){let[q,K]=await this.root.execute("instructor.exams.removeStudents",$);return q}async remove($){let[q,K]=await this.root.execute("instructor.exams.remove",$);return q}async getArchived(){let[$,q]=await this.root.execute("instructor.exams.getArchived",null);return $}async archive($){let[q,K]=await this.root.execute("instructor.exams.archive",$);return q}async unarchive($){let[q,K]=await this.root.execute("instructor.exams.unarchive",$);return q}async getRanking($){let[q,K]=await this.root.execute("instructor.exams.getRanking",$);return q}}class Sy8{root;constructor($){this.root=$}async getOwnProblems(){let[$,q]=await this.root.execute("instructor.problems.getOwnProblems",null);return $}async getOwnProblemsWithPasscode(){let[$,q]=await this.root.execute("instructor.problems.getOwnProblemsWithPasscode",null);return $}async getPasscode($){let[q,K]=await this.root.execute("instructor.problems.getPasscode",$);return q}async setPasscode($){let[q,K]=await this.root.execute("instructor.problems.setPasscode",$);return q}async removePasscode($){let[q,K]=await this.root.execute("instructor.problems.removePasscode",$);return q}async sharePasscode($){let[q,K]=await this.root.execute("instructor.problems.sharePasscode",$);return q}async deprecate($){let[q,K]=await this.root.execute("instructor.problems.deprecate",$);return q}async undeprecate($){let[q,K]=await this.root.execute("instructor.problems.undeprecate",$);return q}async download($){let[q,K]=await this.root.execute("instructor.problems.download",$);return K[0]}async legacyCreate($,q){let[K,Y]=await this.root.execute("instructor.problems.legacyCreate",$,[q]);return K}async legacyUpdate($,q){let[K,Y]=await this.root.execute("instructor.problems.legacyUpdate",$,[q]);return K}async legacyCreateWithTerminal($,q){let[K,Y]=await this.root.execute("instructor.problems.legacyCreateWithTerminal",$,[q]);return K}async legacyUpdateWithTerminal($,q){let[K,Y]=await this.root.execute("instructor.problems.legacyUpdateWithTerminal",$,[q]);return K}async generateProblemWithJutgeAI($){let[q,K]=await this.root.execute("instructor.problems.generateProblemWithJutgeAI",$);return q}}class by8{root;constructor($){this.root=$}async getCourseProblemSubmissions($){let[q,K]=await this.root.execute("instructor.queries.getCourseProblemSubmissions",$);return q}async getCourseListSubmissions($){let[q,K]=await this.root.execute("instructor.queries.getCourseListSubmissions",$);return q}}class hy8{root;constructor($){this.root=$}async index(){let[$,q]=await this.root.execute("instructor.tags.index",null);return $}async getDict(){let[$,q]=await this.root.execute("instructor.tags.getDict",null);return $}async get($){let[q,K]=await this.root.execute("instructor.tags.get",$);return q}}class ky8{root;instructors;users;dashboard;queue;tasks;stats;problems;constructor($){this.root=$,this.instructors=new gy8($),this.users=new yy8($),this.dashboard=new uy8($),this.queue=new By8($),this.tasks=new xy8($),this.stats=new Fy8($),this.problems=new Uy8($)}}class gy8{root;constructor($){this.root=$}async get(){let[$,q]=await this.root.execute("admin.instructors.get",null);return $}async add($){let[q,K]=await this.root.execute("admin.instructors.add",$);return q}async remove($){let[q,K]=await this.root.execute("admin.instructors.remove",$);return q}}class yy8{root;constructor($){this.root=$}async count(){let[$,q]=await this.root.execute("admin.users.count",null);return $}async create($){let[q,K]=await this.root.execute("admin.users.create",$);return q}async remove($){let[q,K]=await this.root.execute("admin.users.remove",$);return q}async setPassword($){let[q,K]=await this.root.execute("admin.users.setPassword",$);return q}async getProfiles($){let[q,K]=await this.root.execute("admin.users.getProfiles",$);return q}async getAllWithEmail($){let[q,K]=await this.root.execute("admin.users.getAllWithEmail",$);return q}async getSpamUsers(){let[$,q]=await this.root.execute("admin.users.getSpamUsers",null);return $}async removeSpamUsers($){let[q,K]=await this.root.execute("admin.users.removeSpamUsers",$);return q}}class uy8{root;constructor($){this.root=$}async getAll(){let[$,q]=await this.root.execute("admin.dashboard.getAll",null);return $}async getDatabasesInfo(){let[$,q]=await this.root.execute("admin.dashboard.getDatabasesInfo",null);return $}async getFreeDiskSpace(){let[$,q]=await this.root.execute("admin.dashboard.getFreeDiskSpace",null);return $}async getRecentConnectedUsers(){let[$,q]=await this.root.execute("admin.dashboard.getRecentConnectedUsers",null);return $}async getRecentLoadAverages(){let[$,q]=await this.root.execute("admin.dashboard.getRecentLoadAverages",null);return $}async getRecentSubmissions(){let[$,q]=await this.root.execute("admin.dashboard.getRecentSubmissions",null);return $}async getSubmissionsHistograms(){let[$,q]=await this.root.execute("admin.dashboard.getSubmissionsHistograms",null);return $}async getZombies(){let[$,q]=await this.root.execute("admin.dashboard.getZombies",null);return $}async getUpcomingExams($){let[q,K]=await this.root.execute("admin.dashboard.getUpcomingExams",$);return q}async getPM2Status(){let[$,q]=await this.root.execute("admin.dashboard.getPM2Status",null);return $}async getDockerStatus(){let[$,q]=await this.root.execute("admin.dashboard.getDockerStatus",null);return $}}class By8{root;constructor($){this.root=$}async getQueue($){let[q,K]=await this.root.execute("admin.queue.getQueue",$);return q}}class xy8{root;constructor($){this.root=$}async purgeAuthTokens(){let[$,q]=await this.root.execute("admin.tasks.purgeAuthTokens",null);return $}async clearCaches(){let[$,q]=await this.root.execute("admin.tasks.clearCaches",null);return $}async fatalizeIEs(){let[$,q]=await this.root.execute("admin.tasks.fatalizeIEs",null);return $}async fatalizePendings(){let[$,q]=await this.root.execute("admin.tasks.fatalizePendings",null);return $}async resubmitIEs(){let[$,q]=await this.root.execute("admin.tasks.resubmitIEs",null);return $}async resubmitPendings(){let[$,q]=await this.root.execute("admin.tasks.resubmitPendings",null);return $}async getFullTextSearchDatabase(){let[$,q]=await this.root.execute("admin.tasks.getFullTextSearchDatabase",null);return q[0]}async updateSemanticSearchDatabase($,q){let[K,Y]=await this.root.execute("admin.tasks.updateSemanticSearchDatabase",$,[q]);return K}}class Fy8{root;constructor($){this.root=$}async getCounters(){let[$,q]=await this.root.execute("admin.stats.getCounters",null);return $}async getDistributionOfVerdicts(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfVerdicts",null);return $}async getDistributionOfVerdictsByYear(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfVerdictsByYear",null);return $}async getDistributionOfCompilers(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfCompilers",null);return $}async getDistributionOfProglangs(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfProglangs",null);return $}async getDistributionOfUsersByYear(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfUsersByYear",null);return $}async getDistributionOfUsersByCountry(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfUsersByCountry",null);return $}async getDistributionOfUsersBySubmissions($){let[q,K]=await this.root.execute("admin.stats.getDistributionOfUsersBySubmissions",$);return q}async getRankingOfUsers($){let[q,K]=await this.root.execute("admin.stats.getRankingOfUsers",$);return q}async getDistributionOfSubmissionsByHour(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByHour",null);return $}async getDistributionOfSubmissionsByProglang(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByProglang",null);return $}async getDistributionOfSubmissionsByCompiler(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByCompiler",null);return $}async getDistributionOfSubmissionsByWeekday(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByWeekday",null);return $}async getDistributionOfSubmissionsByYear(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByYear",null);return $}async getDistributionOfSubmissionsByYearForProglang($){let[q,K]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByYearForProglang",$);return q}async getDistributionOfSubmissionsByDay(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByDay",null);return $}async getHeatmapCalendarOfSubmissions($){let[q,K]=await this.root.execute("admin.stats.getHeatmapCalendarOfSubmissions",$);return q}async getDistributionOfDomains(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfDomains",null);return $}}class Uy8{root;constructor($){this.root=$}async getSolutions($){let[q,K]=await this.root.execute("admin.problems.getSolutions",$);return q}async getSolutionAsB64($){let[q,K]=await this.root.execute("admin.problems.getSolutionAsB64",$);return q}async getSolutionAsFile($){let[q,K]=await this.root.execute("admin.problems.getSolutionAsFile",$);return K[0]}async prepareProblemSummary($){let[q,K]=await this.root.execute("admin.problems.prepareProblemSummary",$);return q}async getProblemSummary($){let[q,K]=await this.root.execute("admin.problems.getProblemSummary",$);return q}async getProblemsWithSummary(){let[$,q]=await this.root.execute("admin.problems.getProblemsWithSummary",null);return $}async getProblemsWithoutSummary(){let[$,q]=await this.root.execute("admin.problems.getProblemsWithoutSummary",null);return $}async prepareAbstractProblemSolutionTags($){let[q,K]=await this.root.execute("admin.problems.prepareAbstractProblemSolutionTags",$);return q}async getAbstractProblemSolutionTags($){let[q,K]=await this.root.execute("admin.problems.getAbstractProblemSolutionTags",$);return q}async getAbstractProblemsWithSolutionTags(){let[$,q]=await this.root.execute("admin.problems.getAbstractProblemsWithSolutionTags",null);return $}async getAbstractProblemsWithoutSolutionTags(){let[$,q]=await this.root.execute("admin.problems.getAbstractProblemsWithoutSolutionTags",null);return $}}class Qy8{root;check;playground;constructor($){this.root=$,this.check=new my8($),this.playground=new dy8($)}}class my8{root;constructor($){this.root=$}async checkUser(){let[$,q]=await this.root.execute("testing.check.checkUser",null);return $}async checkInstructor(){let[$,q]=await this.root.execute("testing.check.checkInstructor",null);return $}async checkAdmin(){let[$,q]=await this.root.execute("testing.check.checkAdmin",null);return $}async throwError($){let[q,K]=await this.root.execute("testing.check.throwError",$);return q}}class dy8{root;constructor($){this.root=$}async upload($,q){let[K,Y]=await this.root.execute("testing.playground.upload",$,[q]);return K}async negate($){let[q,K]=await this.root.execute("testing.playground.negate",null,[$]);return K[0]}async download($){let[q,K]=await this.root.execute("testing.playground.download",$);return K[0]}async download2($){let[q,K]=await this.root.execute("testing.playground.download2",$);return[q,K[0]]}async ping(){let[$,q]=await this.root.execute("testing.playground.ping",null);return $}async toUpperCase($){let[q,K]=await this.root.execute("testing.playground.toUpperCase",$);return q}async add2i($){let[q,K]=await this.root.execute("testing.playground.add2i",$);return q}async add2f($){let[q,K]=await this.root.execute("testing.playground.add2f",$);return q}async inc($){let[q,K]=await this.root.execute("testing.playground.inc",$);return q}async add3i($){let[q,K]=await this.root.execute("testing.playground.add3i",$);return q}async something($){let[q,K]=await this.root.execute("testing.playground.something",$);return q}async clock(){let[$,q]=await this.root.execute("testing.playground.clock",null);return $}}var Ni8=Z1(Vi8(),1);import{createWriteStream as sP7}from"fs";async function Pf6($,q){let K=sP7(q),Y=Ni8.default("zip",{zlib:{level:9}}),w=new Promise((H,J)=>{K.on("close",()=>H()),K.on("error",J),Y.on("error",J),Y.on("warning",(W)=>{if(W.code==="ENOENT")console.warn(W);else J(W)})});Y.pipe(K);for(let H of $)Y.file(H.sourcePath,{name:H.archivePath});await Y.finalize(),await w}async function Ci8($){let q=[],K=[];for(let w of await rW([$])){let H=await _H(w),J=await w07(H);K.push(H),q.push(J)}if(K.length===0)throw Error(`No problem found in directory ${$}`);if(K.length>=1&&K[0].structure==="single")await q07(K,q);else await K07(K[0].directory,K[0],q[0])}async function q07($,q){let K=$[0],Y=$07(RJ(K.directory,"..")),w=RJ(Y,d$()+"-zip",CC());await fi8(w,{recursive:!0}),await _07($,q,w);let H=await Y07($,w,Y),J=await vi8(Y,H);Ei8(J,K.languages)}async function K07($,q,K){let Y=await vi8($,K,q.problemYml);Ei8(Y,q.languages)}async function _07($,q,K){for(let Y=0;Y<$.length;Y++){let w=q[Y],H=$[Y];await Mi8.default(w,{dir:RJ(K,H.language)})}}async function Y07($,q,K){let Y=RJ(q,`${g46(K)}.zip`),w=[];for(let H of $){let J=RJ(q,H.language),W=await Array.fromAsync(y46("*/*",{cwd:J}));for(let P of W)w.push({sourcePath:RJ(J,P),archivePath:RJ(g46(K),H.language,g46(P))})}return await Pf6(w,Y),Y}async function vi8($,q,K){let Y=RJ($,"problem.yml");if(K||await eP7(Y)){let w=K||xd.parse(await bA(Y));return await P07($,w,q)}else return await W07($,q)}function Ei8($,q){B.yaml($),B.url(`https://jutge.org/problems/${$.problem_nm}`);for(let K of q)B.url(`https://jutge.org/problems/${$.problem_nm}_${K}`)}async function w07($){return await B.section("Ziping problem",async()=>{await H07($.directory);let q=RJ($.directory,d$()+"-zip",CC()),K=g46(process.cwd()),Y=RJ(q,`${K}.zip`);return await fi8(q,{recursive:!0}),await B.section("Creating zip file",async()=>{B.directory(q),await J07($.directory,Y,K),B.success(`Created zip file ${K}.zip at ${B.hyperlink(q)}`)}),Y})}async function H07($){await B.section("Checking .inp/.cor files",async()=>{let q=await Array.fromAsync(y46("*.inp",{cwd:$})),K=await Array.fromAsync(y46("*.cor",{cwd:$}));if(q.length!==K.length)throw Error(`Number of .inp files (${q.length}) does not match number of .cor files (${K.length})`);B.success("Looks good")})}async function J07($,q,K){let Y=["README.{md,txt}","problem.yml","handler.yml","problem.[a-z][a-z].{yml,tex}","solution.*","main.*","proto.txt","problem.v","*.{inp,cor}","award.{html,png}","*.{png,jpg,jpeg,gif,svg,pdf,eps}"],w=[".exe",".o",".hi","~"],H=[];for(let J of Y){let P=(await Array.fromAsync(y46(J,{cwd:$}))).sort();for(let X of P){if(w.some((O)=>X.endsWith(O)))continue;B.print(` add ${X}`),H.push({sourcePath:RJ($,X),archivePath:RJ(K,X)})}}await Pf6(H,q)}async function W07($,q){return await B.section("Creating problem in Jutge.org",async()=>{let K={problem_nm:"",passcode:tk6(),created_at:"",updated_at:""},Y=new Px;return await Ii8(Y),await B.section("Creating problem in Jutge.org",async()=>{let w=await S_6(q,"application/zip"),{id:H}=await Y.instructor.problems.legacyCreateWithTerminal(K.passcode,w),J=await Ri8(H);if(!J)throw Error("Failed to get problem name");K.problem_nm=J,K.created_at=new Date().toISOString(),K.updated_at=new Date().toISOString()}),await ji8($,K,"Created"),B.print(""),B.success(`Problem ${K.problem_nm} created successfully`),K})}async function P07($,q,K){return await B.section("Updating problem in Jutge.org",async()=>{let Y=new Px;return await Ii8(Y),await B.section("Updating problem in Jutge.org",async()=>{let w=await S_6(K,"application/zip"),{id:H}=await Y.instructor.problems.legacyUpdateWithTerminal(q.problem_nm,w);await Ri8(H),q.updated_at=new Date().toISOString()}),await ji8($,q,"Updated"),B.print(""),B.success(`Problem ${q.problem_nm} updated successfully`),q})}async function ji8($,q,K){await B.section(`${K==="Created"?"Creating":"Updating"} problem.yml`,async()=>{await zG($,"problem.yml",q),B.success(`${K} problem.yml`)})}async function Ii8($){await B.section("Loging in into Jutge.org",async()=>{let q=process.env.JUTGE_EMAIL,K=process.env.JUTGE_PASSWORD;if(!q||!K)B.warning("set JUTGE_EMAIL and JUTGE_PASSWORD environment variables to login without prompt"),q=await zT({message:"Jutge.org email:",default:u7.email||""}),K=await cT6({message:"Jutge.org password:"});await $.login({email:q,password:K})})}async function Ri8($){let q=new Px,K=await fetch(`${q.JUTGE_API_URL}/webstreams/${$}`);if(K.body===null)return null;let Y=void 0,w=K.body.getReader();while(!0){let{done:H,value:J}=await w.read();if(H)return Y||null;let W=new TextDecoder().decode(J);B.print(W);let P=W.match(/Problem ([A-Z]\d{5}) created\./);if(P)Y=P[1];let X=W.match(/Problem ([A-Z]\d{5}) updated\./);if(X)Y=X[1]}}var Li8=new R5("upload").summary("Upload problem to Jutge.org").description(`Upload problem to Jutge.org
|
|
4072
|
+
The new message will be saved as award.html in the problem directory, overriding any existing file.`).option("-d, --directory <path>","problem directory",".").argument("[prompt]","prompt to generate the award message","Only provide a short encouraging message after having solved a challenge or a problem. Nothing else!").option("-m, --model <model>","AI model to use",u7.defaultModel).action(async($,{directory:q,model:K})=>{let Y=Mg8(q,"award.html"),w=await _H(q),H=await BW(K,"",$);B.print(H),await f3(Y,H),B.success(`Added ${Y}`)});import{join as O67,resolve as D67}from"path";var Cg8=new R5("make").description("Make problem elements").argument("[tasks...]","tasks to make: all|info|exe|cor|pdf|txt|md|html",["all"]).option("-d, --directories <directories...>","problem directories",["."]).option("-i, --ignore-errors","ignore errors on a directory and continue processing",!1).option("-e, --only-errors","only show errors at the final summary",!1).option("-p, --problem_nm <problem_nm>","problem nm","DRAFT").action(async($,{directories:q,ignoreErrors:K,onlyErrors:Y,problem_nm:w})=>{if($.length===0)$=["all"];if($.includes("all")&&$.length>1)throw Error("When 'all' is specified, no other tasks should be provided");if(!$.every((W)=>["all","info","exe","cor","pdf","txt","md","html"].includes(W)))throw Error("Tasks must be one of: all, info, exe, cor, pdf, txt, md, html");console.log(),await B.image(O67(m$(),"assets","images","jutge-toolkit.png"),8,4);let H={},J=await rW(q);for(let W of J){try{B.title(`Making problem in directory ${B.hyperlink(W,D67(W))}`);let P=await Be(W,w);if($.includes("all"))await P.makeProblem();else{if($.includes("info"));if($.includes("exe"))await P.makeExecutables();if($.includes("cor"))await P.makeCorrectOutputs();if($.includes("pdf"))await P.makePdfStatements();if($.includes("txt")||$.includes("html")||$.includes("md"))await P.makeTextualStatements($.filter((X)=>["txt","html","md"].includes(X)))}}catch(P){let X=P instanceof Error?P.message:String(P);if(K)H[W]=X,B.error(`Error: ${X}`);else throw P}console.log()}B.title("Summary"),await B.section("",async()=>{if(await c9(),J.length===0)B.warning("No problem directories found");for(let W of J)if(H[W])B.directory(W),B.error(` ${H[W]}`);else if(!Y)B.directory(W),B.success(" No errors found")})});yI();import Z67 from"path";async function vg8($){let q={};if(await B.section(`Validating ${B.hyperlink($,"quiz.yml")}`,async()=>{try{let K=await pJ($,"quiz.yml");q=b_6.parse(K),B.success("quiz.yml is valid")}catch(K){if(K instanceof Error)if(K instanceof $G)B.error(ZA(K).toString());else B.error(K.message);else B.error(String(K))}}),!q.questions)return;for(let[K,Y]of q.questions.entries()){let w=`${Y.file}.yml`;await B.section(`Validating ${B.hyperlink($,w)}`,async()=>{try{let H=await pJ($,w),J=h_6.parse(H);B.success(`${w} is valid`)}catch(H){if(H instanceof Error)if(H instanceof $G)B.error(ZA(H).toString());else B.error(H.message);else B.error(String(H))}})}}async function Eg8($,q){let K=await pJ($,"quiz.yml"),Y=b_6.parse(K);if(Y.shuffle)hG6(Y.questions);let w={title:Y.title,statement:Y.statement,shuffle:Y.shuffle,seed:q,"time-generation":new Date().toISOString(),questions:[]};for(let H of Y.questions)w.questions.push(await G67($,H,q));console.log(JSON.stringify(w,null,4))}async function G67($,q,K){let Y=await pJ($,`${q.file}.yml`),w=h_6.parse(Y),H=await h_($,`${q.file}.py`),J=await T67(H);return{title:q.title,file:q.file,score:q.score,points:0,q:z67(w,J,K),a:{}}}function z67($,q,K){return{...$,text:A67($.text,q)}}async function T67($){let q=Z67.join(m$(),"assets","python","pyexec.py"),{exitCode:K,stdout:Y}=await l1({reject:!1,input:$,stderr:"inherit"})`python3 ${q}`;return JSON.parse(Y)}function A67($,q){return $.replace(/\$\{?(\w+)\}?/g,(K,Y)=>{return Y in q?q[Y]:K})}yI();var Yx=new R5("quiz").description("Commands related to quizzes").action(()=>{Yx.help()});Yx.command("validate").description("Validate a quiz problem").option("-d, --directories <directories...>","problem directories",["."]).action(async({directories:$})=>{let q=await rW($);for(let K of q)await B.section(`Validating quiz in directory ${B.hyperlink(K)}`,async()=>{await vg8(K)})});Yx.command("make").description("Make a quiz problem").option("-d, --directory <directory>","problem directory",".").option("-s, --seed <seed>","random seed").action(async({directory:$,seed:q})=>{B.warning("The quiz make command is work-in-progress and may not work as expected yet.");let K=await rW([$]),Y=q?parseInt(q,10):bG6(1e6,9999999);for(let w of K){await Eg8(w,Y);return}});var jg8=new R5("upgrade").description("Upgrade to the latest version").action(async()=>{await Gi6()});var Mi8=Z1(Yy8(),1);import{exists as eP7,glob as y46,mkdir as fi8}from"fs/promises";import{basename as g46,join as RJ,normalize as $07}from"path";class r66 extends Error{message;name="UnauthorizedError";constructor($="Unauthorized"){super($);this.message=$}}class wy8 extends Error{message;name="InfoError";constructor($){super($);this.message=$}}class Hy8 extends Error{message;name="NotFoundError";constructor($){super($);this.message=$}}class Jy8 extends Error{message;name="InputError";constructor($){super($);this.message=$}}class Wy8 extends Error{message;name="ProtocolError";constructor($){super($);this.message=$}}class Px{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,K=[]){let Y=this.useCache&&this.clientTTLs.has($)&&K.length===0;if(Y){let C=JSON.stringify({func:$,input:q}),v=this.cache.get(C);if(v!==void 0){if(this.logCache)console.log("found");let j=this.clientTTLs.get($);if(v.epoch+j*1000>new Date().valueOf()){if(this.logCache)console.log("used");return[v.output,v.ofiles]}else{if(this.logCache)console.log("expired");this.cache.delete(C)}}}if(this.logCache)console.log("fetch");let w=new FormData,H={func:$,input:q,meta:this.meta};w.append("data",JSON.stringify(H));for(let C in K)w.append(`file_${C}`,K[C]);let J=await fetch(this.JUTGE_API_URL,{method:"POST",body:w,headers:this.headers});if(J.headers.get("content-type")?.split(";")[0].toLowerCase()!=="multipart/form-data")throw new Wy8("The content type is not multipart/form-data");let P=await J.formData(),X=P.get("data"),{output:O,error:D,duration:Z,operation_id:z,time:A}=JSON.parse(X);if(D)this.throwError(D,z);let N=[];for(let C of P.keys()){let v=P.get(C);if(v instanceof File)N.push({data:new Uint8Array(await v.arrayBuffer()),name:v.name,type:v.type})}if(Y){if(this.logCache)console.log("saved");let C=JSON.stringify({func:$,input:q});this.cache.set(C,{output:O,ofiles:N,epoch:new Date().valueOf()})}return[O,N]}throwError($,q){let K=$.message||"Unknown error";if($.name==="UnauthorizedError")throw new r66(K);else if($.name==="InfoError")throw new wy8(K);else if($.name==="NotFoundError")throw new Hy8(K);else if($.name==="InputError")throw new Jy8(K);else throw Error(K)}async login({email:$,password:q}){let[K,Y]=await this.execute("auth.login",{email:$,password:q});if(K.error)throw new r66(K.error);return this.meta={token:K.token},K}async loginExam({email:$,password:q,exam:K,exam_password:Y}){let[w,H]=await this.execute("auth.loginExam",{email:$,password:q,exam:K,exam_password:Y});if(w.error)throw new r66(w.error);return this.meta={token:w.token},w}async logout(){await this.execute("auth.logout",null),this.meta=null}clearCache(){if(this.logCache)console.log("clear");this.cache=new Map}setCache($){let q=JSON.parse($);this.cache=new Map(Object.entries(q)),this.removeExpired()}getCache(){this.removeExpired();let $=Object.fromEntries(this.cache.entries());return JSON.stringify($)}removeExpired(){for(let[$,q]of this.cache){let{func:K}=JSON.parse($),Y=this.clientTTLs.get(K);if(Y!==void 0&&q.epoch+Y*1000<new Date().getTime())this.cache.delete($)}}clients;auth;misc;tables;problems;student;instructor;admin;testing;constructor(){this.clients=new Py8(this),this.auth=new Xy8(this),this.misc=new Oy8(this),this.tables=new Dy8(this),this.problems=new Zy8(this),this.student=new Gy8(this),this.instructor=new Ey8(this),this.admin=new ky8(this),this.testing=new Qy8(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 Py8{root;constructor($){this.root=$}async python(){let[$,q]=await this.root.execute("clients.python",null);return q[0]}async typescript(){let[$,q]=await this.root.execute("clients.typescript",null);return q[0]}async javascript(){let[$,q]=await this.root.execute("clients.javascript",null);return q[0]}async java(){let[$,q]=await this.root.execute("clients.java",null);return q[0]}async cpp(){let[$,q]=await this.root.execute("clients.cpp",null);return q[0]}async php(){let[$,q]=await this.root.execute("clients.php",null);return q[0]}}class Xy8{root;constructor($){this.root=$}async login($){let[q,K]=await this.root.execute("auth.login",$);return q}async logout(){let[$,q]=await this.root.execute("auth.logout",null);return $}async loginExam($){let[q,K]=await this.root.execute("auth.loginExam",$);return q}}class Oy8{root;constructor($){this.root=$}async getApiVersion(){let[$,q]=await this.root.execute("misc.getApiVersion",null);return $}async getRequestInformation(){let[$,q]=await this.root.execute("misc.getRequestInformation",null);return $}async getFortune(){let[$,q]=await this.root.execute("misc.getFortune",null);return $}async getTime(){let[$,q]=await this.root.execute("misc.getTime",null);return $}async getHomepageStats(){let[$,q]=await this.root.execute("misc.getHomepageStats",null);return $}async getLogo(){let[$,q]=await this.root.execute("misc.getLogo",null);return q[0]}async getAvatarPacks(){let[$,q]=await this.root.execute("misc.getAvatarPacks",null);return $}async getExamIcons(){let[$,q]=await this.root.execute("misc.getExamIcons",null);return $}async getColors(){let[$,q]=await this.root.execute("misc.getColors",null);return $}async getHexColors(){let[$,q]=await this.root.execute("misc.getHexColors",null);return $}async getDemosForCompiler($){let[q,K]=await this.root.execute("misc.getDemosForCompiler",$);return q}}class Dy8{root;constructor($){this.root=$}async get(){let[$,q]=await this.root.execute("tables.get",null);return $}async getLanguages(){let[$,q]=await this.root.execute("tables.getLanguages",null);return $}async getCountries(){let[$,q]=await this.root.execute("tables.getCountries",null);return $}async getCompilers(){let[$,q]=await this.root.execute("tables.getCompilers",null);return $}async getDrivers(){let[$,q]=await this.root.execute("tables.getDrivers",null);return $}async getVerdicts(){let[$,q]=await this.root.execute("tables.getVerdicts",null);return $}async getProglangs(){let[$,q]=await this.root.execute("tables.getProglangs",null);return $}}class Zy8{root;constructor($){this.root=$}async getAllAbstractProblems(){let[$,q]=await this.root.execute("problems.getAllAbstractProblems",null);return $}async getAbstractProblems($){let[q,K]=await this.root.execute("problems.getAbstractProblems",$);return q}async getAbstractProblemsInList($){let[q,K]=await this.root.execute("problems.getAbstractProblemsInList",$);return q}async getAbstractProblem($){let[q,K]=await this.root.execute("problems.getAbstractProblem",$);return q}async getAbstractProblemSuppl($){let[q,K]=await this.root.execute("problems.getAbstractProblemSuppl",$);return q}async getProblem($){let[q,K]=await this.root.execute("problems.getProblem",$);return q}async getProblemRich($){let[q,K]=await this.root.execute("problems.getProblemRich",$);return q}async getProblemSuppl($){let[q,K]=await this.root.execute("problems.getProblemSuppl",$);return q}async getSampleTestcases($){let[q,K]=await this.root.execute("problems.getSampleTestcases",$);return q}async getPublicTestcases($){let[q,K]=await this.root.execute("problems.getPublicTestcases",$);return q}async getHtmlStatement($){let[q,K]=await this.root.execute("problems.getHtmlStatement",$);return q}async getTextStatement($){let[q,K]=await this.root.execute("problems.getTextStatement",$);return q}async getMarkdownStatement($){let[q,K]=await this.root.execute("problems.getMarkdownStatement",$);return q}async getPdfStatement($){let[q,K]=await this.root.execute("problems.getPdfStatement",$);return K[0]}async getZipStatement($){let[q,K]=await this.root.execute("problems.getZipStatement",$);return K[0]}async getTemplates($){let[q,K]=await this.root.execute("problems.getTemplates",$);return q}async getTemplate($){let[q,K]=await this.root.execute("problems.getTemplate",$);return K[0]}async semanticSearch($){let[q,K]=await this.root.execute("problems.semanticSearch",$);return q}async fullTextSearch($){let[q,K]=await this.root.execute("problems.fullTextSearch",$);return q}}class Gy8{root;keys;profile;dashboard;submissions;courses;lists;exam;statuses;awards;constructor($){this.root=$,this.keys=new zy8($),this.profile=new Ty8($),this.dashboard=new Ay8($),this.submissions=new Vy8($),this.courses=new Ny8($),this.lists=new My8($),this.exam=new fy8($),this.statuses=new Cy8($),this.awards=new vy8($)}}class zy8{root;constructor($){this.root=$}async get(){let[$,q]=await this.root.execute("student.keys.get",null);return $}async getProblems(){let[$,q]=await this.root.execute("student.keys.getProblems",null);return $}async getEnrolledCourses(){let[$,q]=await this.root.execute("student.keys.getEnrolledCourses",null);return $}async getAvailableCourses(){let[$,q]=await this.root.execute("student.keys.getAvailableCourses",null);return $}async getLists(){let[$,q]=await this.root.execute("student.keys.getLists",null);return $}}class Ty8{root;constructor($){this.root=$}async get(){let[$,q]=await this.root.execute("student.profile.get",null);return $}async getAvatar(){let[$,q]=await this.root.execute("student.profile.getAvatar",null);return q[0]}async update($){let[q,K]=await this.root.execute("student.profile.update",$);return q}async updateAvatar($){let[q,K]=await this.root.execute("student.profile.updateAvatar",null,[$]);return q}async updatePassword($){let[q,K]=await this.root.execute("student.profile.updatePassword",$);return q}}class Ay8{root;constructor($){this.root=$}async getAbsoluteRanking(){let[$,q]=await this.root.execute("student.dashboard.getAbsoluteRanking",null);return $}async getAllDistributions(){let[$,q]=await this.root.execute("student.dashboard.getAllDistributions",null);return $}async getCompilersDistribution(){let[$,q]=await this.root.execute("student.dashboard.getCompilersDistribution",null);return $}async getDashboard(){let[$,q]=await this.root.execute("student.dashboard.getDashboard",null);return $}async getHeatmapCalendar(){let[$,q]=await this.root.execute("student.dashboard.getHeatmapCalendar",null);return $}async getProglangsDistribution(){let[$,q]=await this.root.execute("student.dashboard.getProglangsDistribution",null);return $}async getStats(){let[$,q]=await this.root.execute("student.dashboard.getStats",null);return $}async getLevel(){let[$,q]=await this.root.execute("student.dashboard.getLevel",null);return $}async getSubmissionsByHour(){let[$,q]=await this.root.execute("student.dashboard.getSubmissionsByHour",null);return $}async getSubmissionsByWeekDay(){let[$,q]=await this.root.execute("student.dashboard.getSubmissionsByWeekDay",null);return $}async getVerdictsDistribution(){let[$,q]=await this.root.execute("student.dashboard.getVerdictsDistribution",null);return $}}class Vy8{root;constructor($){this.root=$}async indexForAbstractProblem($){let[q,K]=await this.root.execute("student.submissions.indexForAbstractProblem",$);return q}async indexForProblem($){let[q,K]=await this.root.execute("student.submissions.indexForProblem",$);return q}async getAll(){let[$,q]=await this.root.execute("student.submissions.getAll",null);return $}async submit($){let[q,K]=await this.root.execute("student.submissions.submit",$);return q}async submitFull($,q){let[K,Y]=await this.root.execute("student.submissions.submitFull",$,[q]);return K}async get($){let[q,K]=await this.root.execute("student.submissions.get",$);return q}async getCodeAsB64($){let[q,K]=await this.root.execute("student.submissions.getCodeAsB64",$);return q}async getCodeMetrics($){let[q,K]=await this.root.execute("student.submissions.getCodeMetrics",$);return q}async getAwards($){let[q,K]=await this.root.execute("student.submissions.getAwards",$);return q}async getAnalysis($){let[q,K]=await this.root.execute("student.submissions.getAnalysis",$);return q}async getTestcaseAnalysis($){let[q,K]=await this.root.execute("student.submissions.getTestcaseAnalysis",$);return q}}class Ny8{root;constructor($){this.root=$}async indexAvailable(){let[$,q]=await this.root.execute("student.courses.indexAvailable",null);return $}async indexEnrolled(){let[$,q]=await this.root.execute("student.courses.indexEnrolled",null);return $}async getAvailable($){let[q,K]=await this.root.execute("student.courses.getAvailable",$);return q}async getEnrolled($){let[q,K]=await this.root.execute("student.courses.getEnrolled",$);return q}async enroll($){let[q,K]=await this.root.execute("student.courses.enroll",$);return q}async unenroll($){let[q,K]=await this.root.execute("student.courses.unenroll",$);return q}}class My8{root;constructor($){this.root=$}async getAll(){let[$,q]=await this.root.execute("student.lists.getAll",null);return $}async get($){let[q,K]=await this.root.execute("student.lists.get",$);return q}}class fy8{root;constructor($){this.root=$}async getReadyExams(){let[$,q]=await this.root.execute("student.exam.getReadyExams",null);return $}async get(){let[$,q]=await this.root.execute("student.exam.get",null);return $}async getDocument($){let[q,K]=await this.root.execute("student.exam.getDocument",$);return q}async getDocumentPdf($){let[q,K]=await this.root.execute("student.exam.getDocumentPdf",$);return K[0]}async getRanking(){let[$,q]=await this.root.execute("student.exam.getRanking",null);return $}}class Cy8{root;constructor($){this.root=$}async getAll(){let[$,q]=await this.root.execute("student.statuses.getAll",null);return $}async getForAbstractProblem($){let[q,K]=await this.root.execute("student.statuses.getForAbstractProblem",$);return q}async getForProblem($){let[q,K]=await this.root.execute("student.statuses.getForProblem",$);return q}}class vy8{root;constructor($){this.root=$}async getAll(){let[$,q]=await this.root.execute("student.awards.getAll",null);return $}async get($){let[q,K]=await this.root.execute("student.awards.get",$);return q}}class Ey8{root;documents;lists;courses;exams;problems;queries;tags;constructor($){this.root=$,this.documents=new jy8($),this.lists=new Iy8($),this.courses=new Ry8($),this.exams=new Ly8($),this.problems=new Sy8($),this.queries=new by8($),this.tags=new hy8($)}}class jy8{root;constructor($){this.root=$}async index(){let[$,q]=await this.root.execute("instructor.documents.index",null);return $}async get($){let[q,K]=await this.root.execute("instructor.documents.get",$);return q}async getPdf($){let[q,K]=await this.root.execute("instructor.documents.getPdf",$);return K[0]}async create($,q){let[K,Y]=await this.root.execute("instructor.documents.create",$,[q]);return K}async update($,q){let[K,Y]=await this.root.execute("instructor.documents.update",$,[q]);return K}async remove($){let[q,K]=await this.root.execute("instructor.documents.remove",$);return q}}class Iy8{root;constructor($){this.root=$}async index(){let[$,q]=await this.root.execute("instructor.lists.index",null);return $}async get($){let[q,K]=await this.root.execute("instructor.lists.get",$);return q}async create($){let[q,K]=await this.root.execute("instructor.lists.create",$);return q}async update($){let[q,K]=await this.root.execute("instructor.lists.update",$);return q}async remove($){let[q,K]=await this.root.execute("instructor.lists.remove",$);return q}async getArchived(){let[$,q]=await this.root.execute("instructor.lists.getArchived",null);return $}async archive($){let[q,K]=await this.root.execute("instructor.lists.archive",$);return q}async unarchive($){let[q,K]=await this.root.execute("instructor.lists.unarchive",$);return q}}class Ry8{root;constructor($){this.root=$}async index(){let[$,q]=await this.root.execute("instructor.courses.index",null);return $}async get($){let[q,K]=await this.root.execute("instructor.courses.get",$);return q}async create($){let[q,K]=await this.root.execute("instructor.courses.create",$);return q}async update($){let[q,K]=await this.root.execute("instructor.courses.update",$);return q}async remove($){let[q,K]=await this.root.execute("instructor.courses.remove",$);return q}async sendInviteToStudents($){let[q,K]=await this.root.execute("instructor.courses.sendInviteToStudents",$);return q}async sendInviteToTutors($){let[q,K]=await this.root.execute("instructor.courses.sendInviteToTutors",$);return q}async getStudentProfiles($){let[q,K]=await this.root.execute("instructor.courses.getStudentProfiles",$);return q}async getTutorProfiles($){let[q,K]=await this.root.execute("instructor.courses.getTutorProfiles",$);return q}async getArchived(){let[$,q]=await this.root.execute("instructor.courses.getArchived",null);return $}async archive($){let[q,K]=await this.root.execute("instructor.courses.archive",$);return q}async unarchive($){let[q,K]=await this.root.execute("instructor.courses.unarchive",$);return q}}class Ly8{root;constructor($){this.root=$}async index(){let[$,q]=await this.root.execute("instructor.exams.index",null);return $}async get($){let[q,K]=await this.root.execute("instructor.exams.get",$);return q}async getDocuments($){let[q,K]=await this.root.execute("instructor.exams.getDocuments",$);return q}async getProblems($){let[q,K]=await this.root.execute("instructor.exams.getProblems",$);return q}async getStudents($){let[q,K]=await this.root.execute("instructor.exams.getStudents",$);return q}async getStudent($){let[q,K]=await this.root.execute("instructor.exams.getStudent",$);return q}async getSubmissions($){let[q,K]=await this.root.execute("instructor.exams.getSubmissions",$);return q}async getSubmissionsPack($){let[q,K]=await this.root.execute("instructor.exams.getSubmissionsPack",$);return q}async getStatistics($){let[q,K]=await this.root.execute("instructor.exams.getStatistics",$);return q}async create($){let[q,K]=await this.root.execute("instructor.exams.create",$);return q}async update($){let[q,K]=await this.root.execute("instructor.exams.update",$);return q}async updateDocuments($){let[q,K]=await this.root.execute("instructor.exams.updateDocuments",$);return q}async updateCompilers($){let[q,K]=await this.root.execute("instructor.exams.updateCompilers",$);return q}async updateProblems($){let[q,K]=await this.root.execute("instructor.exams.updateProblems",$);return q}async updateStudents($){let[q,K]=await this.root.execute("instructor.exams.updateStudents",$);return q}async addStudents($){let[q,K]=await this.root.execute("instructor.exams.addStudents",$);return q}async removeStudents($){let[q,K]=await this.root.execute("instructor.exams.removeStudents",$);return q}async remove($){let[q,K]=await this.root.execute("instructor.exams.remove",$);return q}async getArchived(){let[$,q]=await this.root.execute("instructor.exams.getArchived",null);return $}async archive($){let[q,K]=await this.root.execute("instructor.exams.archive",$);return q}async unarchive($){let[q,K]=await this.root.execute("instructor.exams.unarchive",$);return q}async getRanking($){let[q,K]=await this.root.execute("instructor.exams.getRanking",$);return q}}class Sy8{root;constructor($){this.root=$}async getOwnProblems(){let[$,q]=await this.root.execute("instructor.problems.getOwnProblems",null);return $}async getOwnProblemsWithPasscode(){let[$,q]=await this.root.execute("instructor.problems.getOwnProblemsWithPasscode",null);return $}async getPasscode($){let[q,K]=await this.root.execute("instructor.problems.getPasscode",$);return q}async setPasscode($){let[q,K]=await this.root.execute("instructor.problems.setPasscode",$);return q}async removePasscode($){let[q,K]=await this.root.execute("instructor.problems.removePasscode",$);return q}async sharePasscode($){let[q,K]=await this.root.execute("instructor.problems.sharePasscode",$);return q}async deprecate($){let[q,K]=await this.root.execute("instructor.problems.deprecate",$);return q}async undeprecate($){let[q,K]=await this.root.execute("instructor.problems.undeprecate",$);return q}async download($){let[q,K]=await this.root.execute("instructor.problems.download",$);return K[0]}async legacyCreate($,q){let[K,Y]=await this.root.execute("instructor.problems.legacyCreate",$,[q]);return K}async legacyUpdate($,q){let[K,Y]=await this.root.execute("instructor.problems.legacyUpdate",$,[q]);return K}async legacyCreateWithTerminal($,q){let[K,Y]=await this.root.execute("instructor.problems.legacyCreateWithTerminal",$,[q]);return K}async legacyUpdateWithTerminal($,q){let[K,Y]=await this.root.execute("instructor.problems.legacyUpdateWithTerminal",$,[q]);return K}async generateProblemWithJutgeAI($){let[q,K]=await this.root.execute("instructor.problems.generateProblemWithJutgeAI",$);return q}}class by8{root;constructor($){this.root=$}async getCourseProblemSubmissions($){let[q,K]=await this.root.execute("instructor.queries.getCourseProblemSubmissions",$);return q}async getCourseListSubmissions($){let[q,K]=await this.root.execute("instructor.queries.getCourseListSubmissions",$);return q}}class hy8{root;constructor($){this.root=$}async index(){let[$,q]=await this.root.execute("instructor.tags.index",null);return $}async getDict(){let[$,q]=await this.root.execute("instructor.tags.getDict",null);return $}async get($){let[q,K]=await this.root.execute("instructor.tags.get",$);return q}}class ky8{root;instructors;users;dashboard;queue;tasks;stats;problems;constructor($){this.root=$,this.instructors=new gy8($),this.users=new yy8($),this.dashboard=new uy8($),this.queue=new By8($),this.tasks=new xy8($),this.stats=new Fy8($),this.problems=new Uy8($)}}class gy8{root;constructor($){this.root=$}async get(){let[$,q]=await this.root.execute("admin.instructors.get",null);return $}async add($){let[q,K]=await this.root.execute("admin.instructors.add",$);return q}async remove($){let[q,K]=await this.root.execute("admin.instructors.remove",$);return q}}class yy8{root;constructor($){this.root=$}async count(){let[$,q]=await this.root.execute("admin.users.count",null);return $}async create($){let[q,K]=await this.root.execute("admin.users.create",$);return q}async remove($){let[q,K]=await this.root.execute("admin.users.remove",$);return q}async setPassword($){let[q,K]=await this.root.execute("admin.users.setPassword",$);return q}async getProfiles($){let[q,K]=await this.root.execute("admin.users.getProfiles",$);return q}async getAllWithEmail($){let[q,K]=await this.root.execute("admin.users.getAllWithEmail",$);return q}async getSpamUsers(){let[$,q]=await this.root.execute("admin.users.getSpamUsers",null);return $}async removeSpamUsers($){let[q,K]=await this.root.execute("admin.users.removeSpamUsers",$);return q}}class uy8{root;constructor($){this.root=$}async getAll(){let[$,q]=await this.root.execute("admin.dashboard.getAll",null);return $}async getDatabasesInfo(){let[$,q]=await this.root.execute("admin.dashboard.getDatabasesInfo",null);return $}async getFreeDiskSpace(){let[$,q]=await this.root.execute("admin.dashboard.getFreeDiskSpace",null);return $}async getRecentConnectedUsers(){let[$,q]=await this.root.execute("admin.dashboard.getRecentConnectedUsers",null);return $}async getRecentLoadAverages(){let[$,q]=await this.root.execute("admin.dashboard.getRecentLoadAverages",null);return $}async getRecentSubmissions(){let[$,q]=await this.root.execute("admin.dashboard.getRecentSubmissions",null);return $}async getSubmissionsHistograms(){let[$,q]=await this.root.execute("admin.dashboard.getSubmissionsHistograms",null);return $}async getZombies(){let[$,q]=await this.root.execute("admin.dashboard.getZombies",null);return $}async getUpcomingExams($){let[q,K]=await this.root.execute("admin.dashboard.getUpcomingExams",$);return q}async getPM2Status(){let[$,q]=await this.root.execute("admin.dashboard.getPM2Status",null);return $}async getDockerStatus(){let[$,q]=await this.root.execute("admin.dashboard.getDockerStatus",null);return $}}class By8{root;constructor($){this.root=$}async getQueue($){let[q,K]=await this.root.execute("admin.queue.getQueue",$);return q}}class xy8{root;constructor($){this.root=$}async purgeAuthTokens(){let[$,q]=await this.root.execute("admin.tasks.purgeAuthTokens",null);return $}async clearCaches(){let[$,q]=await this.root.execute("admin.tasks.clearCaches",null);return $}async fatalizeIEs(){let[$,q]=await this.root.execute("admin.tasks.fatalizeIEs",null);return $}async fatalizePendings(){let[$,q]=await this.root.execute("admin.tasks.fatalizePendings",null);return $}async resubmitIEs(){let[$,q]=await this.root.execute("admin.tasks.resubmitIEs",null);return $}async resubmitPendings(){let[$,q]=await this.root.execute("admin.tasks.resubmitPendings",null);return $}async getFullTextSearchDatabase(){let[$,q]=await this.root.execute("admin.tasks.getFullTextSearchDatabase",null);return q[0]}async updateSemanticSearchDatabase($,q){let[K,Y]=await this.root.execute("admin.tasks.updateSemanticSearchDatabase",$,[q]);return K}}class Fy8{root;constructor($){this.root=$}async getCounters(){let[$,q]=await this.root.execute("admin.stats.getCounters",null);return $}async getDistributionOfVerdicts(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfVerdicts",null);return $}async getDistributionOfVerdictsByYear(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfVerdictsByYear",null);return $}async getDistributionOfCompilers(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfCompilers",null);return $}async getDistributionOfProglangs(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfProglangs",null);return $}async getDistributionOfUsersByYear(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfUsersByYear",null);return $}async getDistributionOfUsersByCountry(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfUsersByCountry",null);return $}async getDistributionOfUsersBySubmissions($){let[q,K]=await this.root.execute("admin.stats.getDistributionOfUsersBySubmissions",$);return q}async getRankingOfUsers($){let[q,K]=await this.root.execute("admin.stats.getRankingOfUsers",$);return q}async getDistributionOfSubmissionsByHour(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByHour",null);return $}async getDistributionOfSubmissionsByProglang(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByProglang",null);return $}async getDistributionOfSubmissionsByCompiler(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByCompiler",null);return $}async getDistributionOfSubmissionsByWeekday(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByWeekday",null);return $}async getDistributionOfSubmissionsByYear(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByYear",null);return $}async getDistributionOfSubmissionsByYearForProglang($){let[q,K]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByYearForProglang",$);return q}async getDistributionOfSubmissionsByDay(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfSubmissionsByDay",null);return $}async getHeatmapCalendarOfSubmissions($){let[q,K]=await this.root.execute("admin.stats.getHeatmapCalendarOfSubmissions",$);return q}async getDistributionOfDomains(){let[$,q]=await this.root.execute("admin.stats.getDistributionOfDomains",null);return $}}class Uy8{root;constructor($){this.root=$}async getSolutions($){let[q,K]=await this.root.execute("admin.problems.getSolutions",$);return q}async getSolutionAsB64($){let[q,K]=await this.root.execute("admin.problems.getSolutionAsB64",$);return q}async getSolutionAsFile($){let[q,K]=await this.root.execute("admin.problems.getSolutionAsFile",$);return K[0]}async prepareProblemSummary($){let[q,K]=await this.root.execute("admin.problems.prepareProblemSummary",$);return q}async getProblemSummary($){let[q,K]=await this.root.execute("admin.problems.getProblemSummary",$);return q}async getProblemsWithSummary(){let[$,q]=await this.root.execute("admin.problems.getProblemsWithSummary",null);return $}async getProblemsWithoutSummary(){let[$,q]=await this.root.execute("admin.problems.getProblemsWithoutSummary",null);return $}async prepareAbstractProblemSolutionTags($){let[q,K]=await this.root.execute("admin.problems.prepareAbstractProblemSolutionTags",$);return q}async getAbstractProblemSolutionTags($){let[q,K]=await this.root.execute("admin.problems.getAbstractProblemSolutionTags",$);return q}async getAbstractProblemsWithSolutionTags(){let[$,q]=await this.root.execute("admin.problems.getAbstractProblemsWithSolutionTags",null);return $}async getAbstractProblemsWithoutSolutionTags(){let[$,q]=await this.root.execute("admin.problems.getAbstractProblemsWithoutSolutionTags",null);return $}}class Qy8{root;check;playground;constructor($){this.root=$,this.check=new my8($),this.playground=new dy8($)}}class my8{root;constructor($){this.root=$}async checkUser(){let[$,q]=await this.root.execute("testing.check.checkUser",null);return $}async checkInstructor(){let[$,q]=await this.root.execute("testing.check.checkInstructor",null);return $}async checkAdmin(){let[$,q]=await this.root.execute("testing.check.checkAdmin",null);return $}async throwError($){let[q,K]=await this.root.execute("testing.check.throwError",$);return q}}class dy8{root;constructor($){this.root=$}async upload($,q){let[K,Y]=await this.root.execute("testing.playground.upload",$,[q]);return K}async negate($){let[q,K]=await this.root.execute("testing.playground.negate",null,[$]);return K[0]}async download($){let[q,K]=await this.root.execute("testing.playground.download",$);return K[0]}async download2($){let[q,K]=await this.root.execute("testing.playground.download2",$);return[q,K[0]]}async ping(){let[$,q]=await this.root.execute("testing.playground.ping",null);return $}async toUpperCase($){let[q,K]=await this.root.execute("testing.playground.toUpperCase",$);return q}async add2i($){let[q,K]=await this.root.execute("testing.playground.add2i",$);return q}async add2f($){let[q,K]=await this.root.execute("testing.playground.add2f",$);return q}async inc($){let[q,K]=await this.root.execute("testing.playground.inc",$);return q}async add3i($){let[q,K]=await this.root.execute("testing.playground.add3i",$);return q}async something($){let[q,K]=await this.root.execute("testing.playground.something",$);return q}async clock(){let[$,q]=await this.root.execute("testing.playground.clock",null);return $}}var Ni8=Z1(Vi8(),1);import{createWriteStream as sP7}from"fs";async function Pf6($,q){let K=sP7(q),Y=Ni8.default("zip",{zlib:{level:9}}),w=new Promise((H,J)=>{K.on("close",()=>H()),K.on("error",J),Y.on("error",J),Y.on("warning",(W)=>{if(W.code==="ENOENT")console.warn(W);else J(W)})});Y.pipe(K);for(let H of $)Y.file(H.sourcePath,{name:H.archivePath});await Y.finalize(),await w}async function Ci8($){let q=[],K=[];for(let w of await rW([$])){let H=await _H(w),J=await w07(H);K.push(H),q.push(J)}if(K.length===0)throw Error(`No problem found in directory ${$}`);if(K.length>=1&&K[0].structure==="single")await q07(K,q);else await K07(K[0].directory,K[0],q[0])}async function q07($,q){let K=$[0],Y=$07(RJ(K.directory,"..")),w=RJ(Y,d$()+"-zip",CC());await fi8(w,{recursive:!0}),await _07($,q,w);let H=await Y07($,w,Y),J=await vi8(Y,H);Ei8(J,K.languages)}async function K07($,q,K){let Y=await vi8($,K,q.problemYml);Ei8(Y,q.languages)}async function _07($,q,K){for(let Y=0;Y<$.length;Y++){let w=q[Y],H=$[Y];await Mi8.default(w,{dir:RJ(K,H.language)})}}async function Y07($,q,K){let Y=RJ(q,`${g46(K)}.zip`),w=[];for(let H of $){let J=RJ(q,H.language),W=await Array.fromAsync(y46("*/*",{cwd:J}));for(let P of W)w.push({sourcePath:RJ(J,P),archivePath:RJ(g46(K),H.language,g46(P))})}return await Pf6(w,Y),Y}async function vi8($,q,K){let Y=RJ($,"problem.yml");if(K||await eP7(Y)){let w=K||xd.parse(await bA(Y));return await P07($,w,q)}else return await W07($,q)}function Ei8($,q){B.yaml($),B.url(`https://jutge.org/problems/${$.problem_nm}`);for(let K of q)B.url(`https://jutge.org/problems/${$.problem_nm}_${K}`)}async function w07($){return await B.section("Ziping problem",async()=>{await H07($.directory);let q=RJ($.directory,d$()+"-zip",CC()),K=g46(process.cwd()),Y=RJ(q,`${K}.zip`);return await fi8(q,{recursive:!0}),await B.section("Creating zip file",async()=>{B.directory(q),await J07($.directory,Y,K),B.success(`Created zip file ${K}.zip at ${B.hyperlink(q)}`)}),Y})}async function H07($){await B.section("Checking .inp/.cor files",async()=>{let q=await Array.fromAsync(y46("*.inp",{cwd:$})),K=await Array.fromAsync(y46("*.cor",{cwd:$}));if(q.length!==K.length)throw Error(`Number of .inp files (${q.length}) does not match number of .cor files (${K.length})`);B.success("Looks good")})}async function J07($,q,K){let Y=["README.{md,txt}","problem.yml","handler.yml","problem.[a-z][a-z].{yml,tex}","solution.*","main.*","code.*","*.{inp,cor}","award.{html,png}","*.{png,jpg,jpeg,gif,svg,pdf,eps}"],w=[".exe",".o",".hi","~"],H=[];for(let J of Y){let P=(await Array.fromAsync(y46(J,{cwd:$}))).sort();for(let X of P){if(w.some((O)=>X.endsWith(O)))continue;B.print(` add ${X}`),H.push({sourcePath:RJ($,X),archivePath:RJ(K,X)})}}await Pf6(H,q)}async function W07($,q){return await B.section("Creating problem in Jutge.org",async()=>{let K={problem_nm:"",passcode:tk6(),created_at:"",updated_at:""},Y=new Px;return await Ii8(Y),await B.section("Creating problem in Jutge.org",async()=>{let w=await S_6(q,"application/zip"),{id:H}=await Y.instructor.problems.legacyCreateWithTerminal(K.passcode,w),J=await Ri8(H);if(!J)throw Error("Failed to get problem name");K.problem_nm=J,K.created_at=new Date().toISOString(),K.updated_at=new Date().toISOString()}),await ji8($,K,"Created"),B.print(""),B.success(`Problem ${K.problem_nm} created successfully`),K})}async function P07($,q,K){return await B.section("Updating problem in Jutge.org",async()=>{let Y=new Px;return await Ii8(Y),await B.section("Updating problem in Jutge.org",async()=>{let w=await S_6(K,"application/zip"),{id:H}=await Y.instructor.problems.legacyUpdateWithTerminal(q.problem_nm,w);await Ri8(H),q.updated_at=new Date().toISOString()}),await ji8($,q,"Updated"),B.print(""),B.success(`Problem ${q.problem_nm} updated successfully`),q})}async function ji8($,q,K){await B.section(`${K==="Created"?"Creating":"Updating"} problem.yml`,async()=>{await zG($,"problem.yml",q),B.success(`${K} problem.yml`)})}async function Ii8($){await B.section("Loging in into Jutge.org",async()=>{let q=process.env.JUTGE_EMAIL,K=process.env.JUTGE_PASSWORD;if(!q||!K)B.warning("set JUTGE_EMAIL and JUTGE_PASSWORD environment variables to login without prompt"),q=await zT({message:"Jutge.org email:",default:u7.email||""}),K=await cT6({message:"Jutge.org password:"});await $.login({email:q,password:K})})}async function Ri8($){let q=new Px,K=await fetch(`${q.JUTGE_API_URL}/webstreams/${$}`);if(K.body===null)return null;let Y=void 0,w=K.body.getReader();while(!0){let{done:H,value:J}=await w.read();if(H)return Y||null;let W=new TextDecoder().decode(J);B.print(W);let P=W.match(/Problem ([A-Z]\d{5}) created\./);if(P)Y=P[1];let X=W.match(/Problem ([A-Z]\d{5}) updated\./);if(X)Y=X[1]}}var Li8=new R5("upload").summary("Upload problem to Jutge.org").description(`Upload problem to Jutge.org
|
|
4073
4073
|
|
|
4074
4074
|
If problem.yml exists, the problem will be updated at Jutge.org using that information (which includes its problem id).
|
|
4075
4075
|
If problem.yml does not exist, a new problem will be created at Jutge.org and problem.yml will be generated.
|
package/package.json
CHANGED
package/toolkit/make.ts
CHANGED
|
@@ -12,8 +12,9 @@ export const makeCmd = new Command('make')
|
|
|
12
12
|
.option('-d, --directories <directories...>', 'problem directories', ['.'])
|
|
13
13
|
.option('-i, --ignore-errors', 'ignore errors on a directory and continue processing', false)
|
|
14
14
|
.option('-e, --only-errors', 'only show errors at the final summary', false)
|
|
15
|
+
.option('-p, --problem_nm <problem_nm>', 'problem nm', 'DRAFT')
|
|
15
16
|
|
|
16
|
-
.action(async (tasks, { directories, ignoreErrors, onlyErrors }) => {
|
|
17
|
+
.action(async (tasks, { directories, ignoreErrors, onlyErrors, problem_nm }) => {
|
|
17
18
|
if (tasks.length === 0) {
|
|
18
19
|
tasks = ['all']
|
|
19
20
|
}
|
|
@@ -35,7 +36,7 @@ export const makeCmd = new Command('make')
|
|
|
35
36
|
try {
|
|
36
37
|
tui.title(`Making problem in directory ${tui.hyperlink(directory, resolve(directory))}`)
|
|
37
38
|
|
|
38
|
-
const maker = await newMaker(directory)
|
|
39
|
+
const maker = await newMaker(directory, problem_nm)
|
|
39
40
|
|
|
40
41
|
// If tasks include 'all', run makeProblem
|
|
41
42
|
if (tasks.includes('all')) {
|