import{k as H,r as T,j as o,h as f,a1 as O,F as y,M as a,D as x,a0 as N,Z as C,B as $}from"./vendor.e6eaca24.js";import{u as F}from"./index.b18eeccd.js";import{u as k}from"./index.c6944236.js";import{C as g}from"./CodeLanguage.24acdb11.js";import{T as M}from"./SubtasksEditor.6cc060ee.js";import{v as D}from"./v4.90f1a8cc.js";const w="_menu_tfgn_1",J="_itemTitle_tfgn_11",P="_itemWithIcon_tfgn_19",U="_menuHeader_tfgn_23",W="_menuFooter_tfgn_24",A="_color_0_tfgn_32",B="_color_1_tfgn_35",z="_color_2_tfgn_38",Z="_color_3_tfgn_41",q="_color_4_tfgn_44",G="_color_5_tfgn_47",K="_color_6_tfgn_50",Q="_color_7_tfgn_53",R="_color_8_tfgn_56",X="_color_9_tfgn_59",Y="_color_10_tfgn_62",V="_itemSearchDropdown_tfgn_65",L="_iconInputOrOutput_tfgn_83",ee="_dialogHeader_tfgn_95",te="_dialogHeaderInfo_tfgn_98",oe="_dialogMessage_tfgn_106",re="_labeledInput_tfgn_110",ne="_extraSourceFilesItem_tfgn_117",ce="_language_tfgn_120",le="_dropdown_tfgn_92",se="_input_tfgn_128";var l={menu:w,itemTitle:J,itemWithIcon:P,menuHeader:U,menuFooter:W,color_0:A,color_1:B,color_2:z,color_3:Z,color_4:q,color_5:G,color_6:K,color_7:Q,color_8:R,color_9:X,color_10:Y,itemSearchDropdown:V,iconInputOrOutput:L,dialogHeader:ee,dialogHeaderInfo:te,dialogMessage:oe,labeledInput:re,extraSourceFilesItem:ne,language:ce,dropdown:le,input:se};let S=t=>{const n=k("problem_judge_settings"),[r,b]=T.exports.useState(Object.fromEntries(Object.values(g).map(e=>t.judgeInfo.extraSourceFiles?[e,Object.entries(t.judgeInfo.extraSourceFiles[e]||{}).map(s=>[D(),...s])]:[e,[]])));function d(e,s){t.onUpdateJudgeInfo({extraSourceFiles:Object.fromEntries(Object.values(g).map(c=>e[c].length>0?[c,Object.fromEntries(e[c].map(i=>i.slice(1)))]:null).filter(c=>c))})}function p(e){b(e),d(e)}function E(){t.pending||(t.judgeInfo.extraSourceFiles?t.onUpdateJudgeInfo({extraSourceFiles:null}):d(r))}function m(e,s,c,i){if(s==="ADD")p(F(r,{[e]:{$push:[[D(),"",""]]}}));else if(s==="DEL")p(F(r,{[e]:{$splice:[[c,1]]}}));else{const _=r[e][c],h=i.dst==null?_[1]:i.dst,I=i.src==null?_[2]:i.src;p(F(r,{[e]:{[c]:{$set:[_[0],h,I]}}}))}}return o("div",{children:f(O,{children:[o(O.Checkbox,{checked:!!t.judgeInfo.extraSourceFiles,label:n(".extra_source_files.option"),onChange:()=>E()}),t.judgeInfo.extraSourceFiles&&f(y,{children:[f(a,{className:l.menu+" "+l.menuHeader+" "+l.color_6,attached:"top",children:[o(a.Item,{className:l.itemTitle,children:o("strong",{children:n(".extra_source_files.title")})}),o(a.Menu,{position:"right",children:o(x,{item:!0,icon:"plus",className:`icon ${l.itemWithIcon}`,children:o(x.Menu,{children:Object.values(g).map(e=>o(x.Item,{text:n(`code_language.${e}.name`),onClick:()=>m(e,"ADD")},e))})})})]}),r&&Object.entries(r).map(([e,s],c,{length:i})=>s.map(([_,h,I],u)=>f(a,{className:l.extraSourceFilesItem,attached:u==s.length-1&&c===i-1?"bottom":!0,children:[o(a.Item,{className:l.itemTitle+" "+l.language,style:u==0?{height:41*s.length-1}:{visibility:"hidden"},children:n(`code_language.${e}.name`)}),o(M,{type:"ItemSearchDropdown",className:l.dropdown,testData:t.testData,placeholder:n(".extra_source_files.src"),value:I,onChange:j=>m(e,"UPDATE",u,{src:j})}),o(a.Item,{className:l.input,children:o(N,{icon:"long arrow alternate right",iconPosition:"left",transparent:!0,placeholder:n(".extra_source_files.dst"),value:h,onChange:(j,{value:v})=>m(e,"UPDATE",u,{dst:v})})}),o(a.Menu,{position:"right",children:o(C,{trigger:o(a.Item,{className:`icon ${l.itemWithIcon}`,icon:"delete",title:n(".extra_source_files.delete")}),content:o($,{negative:!0,content:n(".extra_source_files.confirm_delete"),onClick:()=>m(e,"DEL",u)}),on:"click",position:"top center"})})]},_)))]})]})})};S=H(S);const ie={parseJudgeInfo(t){return{extraSourceFiles:t.extraSourceFiles&&typeof t.extraSourceFiles=="object"?Object.fromEntries(Object.entries(t.extraSourceFiles).filter(([n,r])=>Object.values(g).includes(n)&&r&&typeof r=="object").map(([n,r])=>[n,Object.fromEntries(Object.entries(r).filter(([b,d])=>typeof d=="string"))]).filter(([n,r])=>Object.keys(r).length>0)):null}},normalizeJudgeInfo(t){t.extraSourceFiles||delete t.extraSourceFiles}};var ge=Object.assign(S,ie);export{ge as E};
