export function toDisplayAgentName(_0x1b7ab7,{fallback:fallback='Unknown'}={}){const _0x27b7aa=String(_0x1b7ab7||'')['trim']()['toLowerCase']();if(!_0x27b7aa)return fallback;return _0x27b7aa['charAt'](0x0)['toUpperCase']()+_0x27b7aa['slice'](0x1);}export function escapeRegExp(_0x34ca03){return String(_0x34ca03)['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&');}export function compareJudgmentsForAliasOrder(_0x351265,_0x499a96){const _0x1eff0b=String(_0x351265?.['createdAt']||''),_0x12f34d=String(_0x499a96?.['createdAt']||'');if(_0x1eff0b!==_0x12f34d)return _0x1eff0b['localeCompare'](_0x12f34d);return String(_0x351265?.['taskId']||'')['localeCompare'](String(_0x499a96?.['taskId']||''));}export function parseJudgeAliasNumber(_0x24b364,_0x325773){const _0x48fd17=typeof _0x24b364==='string'?_0x24b364['trim']():'',_0x5d14af=toDisplayAgentName(_0x325773,{'fallback':''});if(!_0x48fd17||!_0x5d14af)return null;const _0x44604d=_0x48fd17['toLowerCase'](),_0x3db408=_0x5d14af['toLowerCase']();if(_0x44604d===_0x3db408||_0x44604d===_0x3db408+'\x20judge')return 0x1;const _0x13bf69=[new RegExp('^'+escapeRegExp(_0x5d14af)+'\x5cs+(\x5cd+)$','i'),new RegExp('^'+escapeRegExp(_0x5d14af)+'\x5cs+Judge\x5cs+(\x5cd+)$','i')];for(const _0x199f76 of _0x13bf69){const _0x55f2e9=_0x48fd17['match'](_0x199f76);if(_0x55f2e9){const _0x5f1509=Number(_0x55f2e9[0x1]);if(Number['isInteger'](_0x5f1509)&&_0x5f1509>0x0)return _0x5f1509;}}return null;}export function formatJudgeDisplayName({alias:_0x2f8370,agent:_0x5368a8,number:number=null,hasDuplicates:hasDuplicates=![]}={}){const _0x1db9d2=toDisplayAgentName(_0x5368a8,{'fallback':'Judge'}),_0x39099b=typeof _0x2f8370==='string'?_0x2f8370['trim']():'';if(Number['isInteger'](number)&&number>0x0)return _0x1db9d2+'\x20Judge\x20'+number;if(_0x39099b)return/\bjudge\b/i['test'](_0x39099b)?_0x39099b:_0x39099b+'\x20Judge';if(hasDuplicates)return _0x1db9d2+'\x20Judge';return _0x1db9d2==='Judge'?_0x1db9d2:_0x1db9d2+'\x20Judge';}export function buildJudgmentDisplayNameMap(_0x2a0e34=[]){const _0x557fcc=Array['isArray'](_0x2a0e34)?_0x2a0e34['filter'](Boolean):[],_0x30a470=new Map();_0x557fcc['forEach'](_0x175be7=>{const _0xe08e05=_0x175be7?.['judgeAgent']||_0x175be7?.['envVars']?.['CODER_AGENT']||'unknown',_0x4f0c27=String(_0xe08e05||'')['trim']()['toLowerCase']()||'unknown';!_0x30a470['has'](_0x4f0c27)&&_0x30a470['set'](_0x4f0c27,[]),_0x30a470['get'](_0x4f0c27)['push'](_0x175be7);});const _0x14a6d7=new Map();return _0x30a470['forEach'](_0x5e8a71=>{const _0x4b5cbb=[..._0x5e8a71]['sort'](compareJudgmentsForAliasOrder),_0x34387e=_0x4b5cbb['length']>0x1,_0x3fb92f=new Set(),_0x308844=new Map();_0x34387e&&_0x4b5cbb['forEach'](_0x4d1b8e=>{const _0x153a89=parseJudgeAliasNumber(_0x4d1b8e?.['judgeAlias'],_0x4d1b8e?.['judgeAgent']);if(!Number['isInteger'](_0x153a89)||_0x153a89<=0x0||_0x3fb92f['has'](_0x153a89))return;_0x308844['set'](_0x4d1b8e['taskId'],_0x153a89),_0x3fb92f['add'](_0x153a89);});let _0xf6e9d4=0x1;const _0x3ebb8a=()=>{while(_0x3fb92f['has'](_0xf6e9d4)){_0xf6e9d4+=0x1;}return _0x3fb92f['add'](_0xf6e9d4),_0xf6e9d4;};_0x4b5cbb['forEach'](_0x36ce06=>{let _0x4bcabd=_0x308844['get'](_0x36ce06['taskId'])||null;_0x34387e&&_0x4bcabd===null&&!String(_0x36ce06?.['judgeAlias']||'')['trim']()&&(_0x4bcabd=_0x3ebb8a()),_0x14a6d7['set'](_0x36ce06['taskId'],formatJudgeDisplayName({'alias':_0x36ce06?.['judgeAlias']||null,'agent':_0x36ce06?.['judgeAgent']||_0x36ce06?.['envVars']?.['CODER_AGENT']||'unknown','number':_0x4bcabd,'hasDuplicates':_0x34387e}));});}),_0x14a6d7;}export function buildTaskNavigationHref(_0x4ca6a9,{currentUrl:_0x5eca01,groupedTaskIds:groupedTaskIds=[],groupId:groupId=null}={}){const _0x30e4c2=new URL(_0x5eca01),_0x2b96f0=String(_0x4ca6a9||'')['trim'](),_0x5436ab=String(groupId||'')['trim'](),_0x5f387b=Array['isArray'](groupedTaskIds)?groupedTaskIds['map'](_0x131c0d=>String(_0x131c0d||'')['trim']())['filter'](Boolean):[],_0x576933=Boolean(_0x5436ab)||_0x5f387b['length']>0x1;if(!_0x576933)return _0x2b96f0&&_0x30e4c2['searchParams']['set']('id',_0x2b96f0),_0x30e4c2['searchParams']['delete']('groupId'),_0x30e4c2['toString']();const _0x33bd26=_0x5f387b['includes'](_0x2b96f0)?_0x5f387b:[..._0x5f387b,_0x2b96f0]['filter'](Boolean);if(_0x33bd26['length']>0x0)_0x30e4c2['searchParams']['set']('id',_0x33bd26['join'](','));else _0x2b96f0&&_0x30e4c2['searchParams']['set']('id',_0x2b96f0);return _0x5436ab?_0x30e4c2['searchParams']['set']('groupId',_0x5436ab):_0x30e4c2['searchParams']['delete']('groupId'),_0x30e4c2['toString']();}