export function toDisplayAgentName(_0x6b1c6b,{fallback:fallback='Unknown'}={}){const _0x4fd297=String(_0x6b1c6b||'')['trim']()['toLowerCase']();if(!_0x4fd297)return fallback;return _0x4fd297['charAt'](0x0)['toUpperCase']()+_0x4fd297['slice'](0x1);}export function escapeRegExp(_0x488e81){return String(_0x488e81)['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&');}export function compareJudgmentsForAliasOrder(_0x15507c,_0x53db9e){const _0x39e8b8=String(_0x15507c?.['createdAt']||''),_0x4bed31=String(_0x53db9e?.['createdAt']||'');if(_0x39e8b8!==_0x4bed31)return _0x39e8b8['localeCompare'](_0x4bed31);return String(_0x15507c?.['taskId']||'')['localeCompare'](String(_0x53db9e?.['taskId']||''));}export function parseJudgeAliasNumber(_0x5e91e6,_0x5475c7){const _0x101236=typeof _0x5e91e6==='string'?_0x5e91e6['trim']():'',_0x416fc0=toDisplayAgentName(_0x5475c7,{'fallback':''});if(!_0x101236||!_0x416fc0)return null;const _0x5ce7b5=_0x101236['toLowerCase'](),_0x30c294=_0x416fc0['toLowerCase']();if(_0x5ce7b5===_0x30c294||_0x5ce7b5===_0x30c294+'\x20judge')return 0x1;const _0x264ad2=[new RegExp('^'+escapeRegExp(_0x416fc0)+'\x5cs+(\x5cd+)$','i'),new RegExp('^'+escapeRegExp(_0x416fc0)+'\x5cs+Judge\x5cs+(\x5cd+)$','i')];for(const _0x47723b of _0x264ad2){const _0x3f5321=_0x101236['match'](_0x47723b);if(_0x3f5321){const _0x78983b=Number(_0x3f5321[0x1]);if(Number['isInteger'](_0x78983b)&&_0x78983b>0x0)return _0x78983b;}}return null;}export function formatJudgeDisplayName({alias:_0x485a0d,agent:_0x1a6e67,number:number=null,hasDuplicates:hasDuplicates=![]}={}){const _0x3e6886=toDisplayAgentName(_0x1a6e67,{'fallback':'Judge'}),_0x29c4af=typeof _0x485a0d==='string'?_0x485a0d['trim']():'';if(Number['isInteger'](number)&&number>0x0)return _0x3e6886+'\x20Judge\x20'+number;if(_0x29c4af)return/\bjudge\b/i['test'](_0x29c4af)?_0x29c4af:_0x29c4af+'\x20Judge';if(hasDuplicates)return _0x3e6886+'\x20Judge';return _0x3e6886==='Judge'?_0x3e6886:_0x3e6886+'\x20Judge';}export function buildJudgmentDisplayNameMap(_0x1d83b9=[]){const _0x549df3=Array['isArray'](_0x1d83b9)?_0x1d83b9['filter'](Boolean):[],_0x1f96da=new Map();_0x549df3['forEach'](_0x4fc029=>{const _0x2000fd=_0x4fc029?.['judgeAgent']||_0x4fc029?.['envVars']?.['CODER_AGENT']||'unknown',_0x55697b=String(_0x2000fd||'')['trim']()['toLowerCase']()||'unknown';!_0x1f96da['has'](_0x55697b)&&_0x1f96da['set'](_0x55697b,[]),_0x1f96da['get'](_0x55697b)['push'](_0x4fc029);});const _0x573b11=new Map();return _0x1f96da['forEach'](_0x56a531=>{const _0x31638e=[..._0x56a531]['sort'](compareJudgmentsForAliasOrder),_0x23bf4f=_0x31638e['length']>0x1,_0x5be2b3=new Set(),_0x292fb1=new Map();_0x23bf4f&&_0x31638e['forEach'](_0x53b7bb=>{const _0x49d804=parseJudgeAliasNumber(_0x53b7bb?.['judgeAlias'],_0x53b7bb?.['judgeAgent']);if(!Number['isInteger'](_0x49d804)||_0x49d804<=0x0||_0x5be2b3['has'](_0x49d804))return;_0x292fb1['set'](_0x53b7bb['taskId'],_0x49d804),_0x5be2b3['add'](_0x49d804);});let _0x426a9e=0x1;const _0x377dd8=()=>{while(_0x5be2b3['has'](_0x426a9e)){_0x426a9e+=0x1;}return _0x5be2b3['add'](_0x426a9e),_0x426a9e;};_0x31638e['forEach'](_0x50517f=>{let _0xa356a6=_0x292fb1['get'](_0x50517f['taskId'])||null;_0x23bf4f&&_0xa356a6===null&&!String(_0x50517f?.['judgeAlias']||'')['trim']()&&(_0xa356a6=_0x377dd8()),_0x573b11['set'](_0x50517f['taskId'],formatJudgeDisplayName({'alias':_0x50517f?.['judgeAlias']||null,'agent':_0x50517f?.['judgeAgent']||_0x50517f?.['envVars']?.['CODER_AGENT']||'unknown','number':_0xa356a6,'hasDuplicates':_0x23bf4f}));});}),_0x573b11;}export function buildTaskNavigationHref(_0x1cf1a9,{currentUrl:_0x75daf1,groupedTaskIds:groupedTaskIds=[],groupId:groupId=null}={}){const _0x3a12c2=new URL(_0x75daf1),_0x363d31=String(_0x1cf1a9||'')['trim'](),_0x4c0c88=String(groupId||'')['trim'](),_0x5ae881=Array['isArray'](groupedTaskIds)?groupedTaskIds['map'](_0xa0be67=>String(_0xa0be67||'')['trim']())['filter'](Boolean):[],_0x3fcdd5=Boolean(_0x4c0c88)||_0x5ae881['length']>0x1;if(!_0x3fcdd5)return _0x363d31&&_0x3a12c2['searchParams']['set']('id',_0x363d31),_0x3a12c2['searchParams']['delete']('groupId'),_0x3a12c2['toString']();const _0x566727=_0x5ae881['includes'](_0x363d31)?_0x5ae881:[..._0x5ae881,_0x363d31]['filter'](Boolean);if(_0x566727['length']>0x0)_0x3a12c2['searchParams']['set']('id',_0x566727['join'](','));else _0x363d31&&_0x3a12c2['searchParams']['set']('id',_0x363d31);return _0x4c0c88?_0x3a12c2['searchParams']['set']('groupId',_0x4c0c88):_0x3a12c2['searchParams']['delete']('groupId'),_0x3a12c2['toString']();}