import{getLevelsForSelectedModel}from'./model-selection-utils.js';export const USE_DEFAULT_SENTINEL='__use_default__';export const RESUBMIT_PROVIDERS=[{'agent':'claude','modelEnv':'CLAUDE_MODEL','levelEnv':'CLAUDE_CODE_EFFORT_LEVEL','modelSelectId':'resubmit-claude-model','levelSelectId':'resubmit-effort-level','countInputId':'resubmit-claude-count'},{'agent':'codex','modelEnv':'OPENAI_MODEL','levelEnv':'CODEX_REASONING_LEVEL','modelSelectId':'resubmit-codex-model','levelSelectId':'resubmit-reasoning-level','countInputId':'resubmit-codex-count'},{'agent':'grok','modelEnv':'GROK_MODEL','levelEnv':'GROK_EFFORT_LEVEL','modelSelectId':'resubmit-grok-model','levelSelectId':'resubmit-grok-effort-level','countInputId':'resubmit-grok-count'}];export function stripModelDefaultLabel(_0x2a9746){return String(_0x2a9746||'')['replace'](/\s*\(default\)\s*$/i,'');}function defaultEscape(_0x2f25c2){return String(_0x2f25c2==null?'':_0x2f25c2)['replace'](/&/g,'&amp;')['replace'](/</g,'&lt;')['replace'](/>/g,'&gt;')['replace'](/"/g,'&quot;')['replace'](/'/g,'&#39;');}export function findProviderModel(_0x1ae028,_0x1705c8){if(!_0x1705c8)return null;return(_0x1ae028?.['models']||[])['find'](_0x4f6044=>_0x4f6044?.['id']===_0x1705c8)||null;}export function findProviderLevel(_0x1321da,_0x179323,_0x5515f1){if(!_0x5515f1)return null;return getLevelsForSelectedModel(_0x1321da,_0x179323)['find'](_0x3f53ff=>_0x3f53ff?.['id']===_0x5515f1)||null;}export function isLevelIncompatible(_0x199949,_0x395ba1,_0x395afc){if(!_0x395afc)return![];const _0x32796a=getLevelsForSelectedModel(_0x199949,_0x395ba1);if(!_0x32796a['length'])return![];return!_0x32796a['some'](_0x51c1c9=>_0x51c1c9?.['id']===_0x395afc);}function buildOption(_0xc7665,_0x40b17c,_0x4af66d){return'<option\x20value=\x22'+_0x4af66d(_0xc7665)+'\x22>'+_0x4af66d(stripModelDefaultLabel(_0x40b17c))+'</option>';}function buildEmptyOption(_0x2a53d2,_0x478115,_0x24c396='Same\x20as\x20original'){const _0x587276=_0x2a53d2?'\x20('+_0x478115(_0x2a53d2)+')':'';return'<option\x20value=\x22\x22>'+_0x478115(_0x24c396)+_0x587276+'</option>';}function buildUseDefaultOption(_0x587708){return'<option\x20value=\x22'+_0x587708(USE_DEFAULT_SENTINEL)+'\x22>Use\x20server\x20default</option>';}export function buildModelOptionsHtml(_0x1b4bd0,_0x5cb641,{escape:escape=defaultEscape,emptyLabel:emptyLabel='Same\x20as\x20original'}={}){const _0x510f2b=_0x1b4bd0?.['models']||[],_0x1ef5a4=findProviderModel(_0x1b4bd0,_0x5cb641),_0x57d502=_0x1ef5a4?stripModelDefaultLabel(_0x1ef5a4['displayName']||_0x1ef5a4['id']):null,_0x579009=[buildEmptyOption(_0x57d502,escape,emptyLabel)];if(_0x5cb641)_0x579009['push'](buildUseDefaultOption(escape));for(const _0x45df62 of _0x510f2b){_0x579009['push'](buildOption(_0x45df62['id'],_0x45df62['displayName']||_0x45df62['id'],escape));}return _0x579009['join']('');}export function buildLevelOptionsHtml(_0x3d8700,_0x4f4757,_0x306824,{escape:escape=defaultEscape,emptyLabel:emptyLabel='Same\x20as\x20original'}={}){const _0x3ace20=getLevelsForSelectedModel(_0x3d8700,_0x4f4757),_0x53f9d4=findProviderLevel(_0x3d8700,_0x4f4757,_0x306824),_0x1c6a19=_0x53f9d4?stripModelDefaultLabel(_0x53f9d4['displayName']||_0x53f9d4['id']):null,_0x4c00fa=[buildEmptyOption(_0x1c6a19,escape,emptyLabel)];if(_0x306824)_0x4c00fa['push'](buildUseDefaultOption(escape));for(const _0x1ee0e3 of _0x3ace20){_0x4c00fa['push'](buildOption(_0x1ee0e3['id'],_0x1ee0e3['displayName']||_0x1ee0e3['id'],escape));}return _0x4c00fa['join']('');}export function collectModelOverrides({selections:selections={},agentCounts:agentCounts={},envVars:envVars={},availableModels:availableModels={}}={}){const _0x4c8306={},_0x14b46d=(_0x9acf19,_0x161d43)=>{if(_0x161d43==='')return;_0x4c8306[_0x9acf19]=_0x161d43===USE_DEFAULT_SENTINEL?'':_0x161d43;};for(const _0xf618c9 of RESUBMIT_PROVIDERS){if((agentCounts[_0xf618c9['agent']]||0x0)<=0x0)continue;const _0x19f48a=selections[_0xf618c9['modelEnv']]||'',_0x45d820=selections[_0xf618c9['levelEnv']]||'';_0x14b46d(_0xf618c9['modelEnv'],_0x19f48a),_0x14b46d(_0xf618c9['levelEnv'],_0x45d820);const _0x4389ab=_0x19f48a&&_0x19f48a!==USE_DEFAULT_SENTINEL;if(_0x4389ab&&_0x45d820===''){const _0x100469=envVars[_0xf618c9['levelEnv']],_0x28e193=availableModels[_0xf618c9['agent']];_0x100469&&_0x28e193&&isLevelIncompatible(_0x28e193,_0x19f48a,_0x100469)&&(_0x4c8306[_0xf618c9['levelEnv']]='');}}return _0x4c8306;}