@bitkyc08/opencodex 2.7.41-preview.20260726 → 2.7.41
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.
|
@@ -62,4 +62,4 @@ v2: spawn_agent を備えたマルチスレッドエージェント。すべて
|
|
|
62
62
|
"max_tokens": 64,
|
|
63
63
|
"messages": [{"role": "user", "content": ${r}}]
|
|
64
64
|
}'`})]})]})}function Sc({apiBase:e}){let{t,locale:n}=G(),r=ke.find(e=>e.code===n)?.htmlLang,[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(mc),[c,l]=(0,_.useState)(!0),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)([]),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)({}),[D,O]=(0,_.useState)(``),[k,A]=(0,_.useState)(!1),[j,M]=(0,_.useState)(null),[N,F]=(0,_.useState)(!1),[I,L]=(0,_.useState)(null),R=(0,_.useRef)(!1),z=(0,_.useCallback)(async()=>{try{let t=await tt(await fetch(`${e}/api/keys`));if(!t){d(!0);return}let n=hc(t.endpoint??``);a(t.keys??[]),s({baseUrl:t.baseUrl??n.baseUrl,responses:t.responsesEndpoint??t.endpoint??mc.responses,chatCompletions:t.chatCompletionsEndpoint??n.chatCompletions,messages:t.messagesEndpoint??n.messages,models:t.modelsEndpoint??n.models}),l(t.claudeCodeEnabled!==!1),d(!1)}catch{d(!0)}},[e]),ee=(0,_.useCallback)(async()=>{v(!0),b(!1);try{let t=await fetch(`${e}/v1/models`);if(!t.ok){h([]),b(!0);return}let n=await t.json(),r=Array.isArray(n)?n:typeof n==`object`&&n&&Array.isArray(n.data)?n.data:null;if(!r){h([]),b(!0);return}h(r.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`).map(e=>fc(e)).sort((e,t)=>pc(e).localeCompare(pc(t))))}catch{h([]),b(!0)}finally{v(!1)}},[e]);(0,_.useEffect)(()=>{let e=window.setTimeout(()=>{z(),ee()},0);return()=>window.clearTimeout(e)},[z,ee]);let te=(0,_.useMemo)(()=>{let e=x.trim().toLowerCase();return e?m.filter(t=>pc(t).toLowerCase().includes(e)||t.displayName.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)):m},[x,m]),B=async n=>{if(R.current)return!1;R.current=!0,A(!0),p(null);try{let r=n??D,i=await et(await fetch(`${e}/api/keys`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:r||`default`})}),t(`api.createFailed`));return typeof i?.key!=`string`||i.key.length===0?(p(t(`api.createFailed`)),!1):(M(i.key),O(``),z(),!0)}catch{return p(t(`api.createFailed`)),!1}finally{R.current=!1,A(!1)}},V=async n=>{p(null);try{if(!(await fetch(`${e}/api/keys`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:n})})).ok){p(t(`api.deleteFailed`));return}L(null),z()}catch{p(t(`api.deleteFailed`))}},H=()=>{j&&(navigator.clipboard.writeText(j),F(!0),setTimeout(()=>F(!1),2e3))},ne=async e=>{try{await navigator.clipboard.writeText(e),w(e),window.setTimeout(()=>w(t=>t===e?null:t),2e3)}catch{}},re=e=>e.native?t(`api.sourceNative`):e.provider===`combo`?t(`api.sourceCombo`):e.custom?t(`api.sourceCustom`):e.provider,ie=e=>t(e===`responses`?`api.protocolResponses`:e===`messages`?`api.protocolMessages`:`api.protocolChatCompletions`),ae=async e=>{let n=pc(e);E(e=>({...e,[n]:{state:`testing`}}));try{let e=await fetch(o.chatCompletions,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:n,messages:[{role:`user`,content:`ping`}],max_tokens:1,stream:!1})});if(!e.ok){let t=await e.text();E(r=>({...r,[n]:{state:`error`,detail:t.slice(0,160)||String(e.status)}}));return}E(e=>({...e,[n]:{state:`ok`}}))}catch(e){E(r=>({...r,[n]:{state:`error`,detail:e instanceof Error?e.message:t(`api.testFailed`)}}))}},oe=t(`api.subtitle`).split(/\{authHeader\}|\{altHeader\}/);return(0,P.jsxs)(`section`,{className:`api-page`,children:[(0,P.jsx)(`div`,{className:`page-head`,children:(0,P.jsx)(`h2`,{children:t(`api.title`)})}),(0,P.jsxs)(`p`,{className:`page-sub`,children:[oe[0],(0,P.jsx)(`code`,{children:`Authorization: Bearer ocx_...`}),oe[1],(0,P.jsx)(`code`,{children:`x-opencodex-api-key`}),oe[2]]}),(u||f)&&(0,P.jsx)(Xe,{tone:`err`,children:f??t(`api.keysLoadFailed`)}),(0,P.jsx)(_c,{endpoints:o,claudeCodeEnabled:c}),(0,P.jsx)(vc,{claudeCodeEnabled:c}),(0,P.jsx)(yc,{keys:i,keysLoadFailed:u,newName:D,creating:k,newKey:j,copied:N,confirmDelete:I,localeTag:r,onNewNameChange:O,onCreate:()=>{B()},onDismissNewKey:()=>M(null),onCopyKey:H,onConfirmDelete:L,onCancelDelete:()=>L(null),onDelete:e=>{V(e)}}),(0,P.jsx)(bc,{filteredModels:te,modelsLoading:g,modelsLoadFailed:y,modelQuery:x,copiedModelId:C,modelTests:T,claudeCodeEnabled:c,onModelQueryChange:S,onCopyModelId:e=>{ne(e)},onTestModel:e=>{ae(e)},sourceLabel:re,protocolLabel:ie}),(0,P.jsx)(xc,{endpoints:o,claudeCodeEnabled:c})]})}function Cc(e){let t=e.autoConnectSupported===!0;return{autoConnectSupported:t,systemEnv:t&&e.systemEnv===!0}}var wc=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`];function Tc(e){let t=`http://127.0.0.1:${e.port}`,n=e.authMode===`auto`?e.markerMode??`subscription`:e.authMode,r=e.autoContext&&e.maxContextTokens===null,i=wc.filter(t=>e.effectiveModelEnv[t]).map(t=>`export ${t}=${e.effectiveModelEnv[t]}`);return[`export ANTHROPIC_BASE_URL=${t}`,...n===`proxy`?[`export ANTHROPIC_AUTH_TOKEN=opencodex-proxy`]:[`# no ANTHROPIC_AUTH_TOKEN: your claude.ai login (and connectors) stay active`],`export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1`,...n===`proxy`?['[ -z "${CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST+x}" ] && export CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1']:[],...r?[`export CLAUDE_CODE_AUTO_COMPACT_WINDOW=${e.autoCompactWindow??35e4}`]:[],...i,`claude`].join(`
|
|
65
|
-
`)}function Ec(e){return e?e.backend??`auto`:`inherit`}function Dc(e,t){if(t!==`inherit`)return t===`auto`?{...e,backend:void 0}:{...e,backend:t}}function Oc(e,t){return{...e,model:t}}function kc(e){if(!e)return null;let t=(e.model??``).trim();return e.backend?{backend:e.backend,model:t}:t?{backend:null,model:t}:null}function Ac({label:e,checked:t,onChange:n,disabled:r=!1,describedBy:i}){return(0,P.jsxs)(`label`,{className:`toggle`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:t,disabled:r,"aria-label":e,"aria-describedby":i,onChange:e=>n(e.target.checked)}),(0,P.jsx)(`span`,{className:`slider`,"aria-hidden":`true`})]})}function jc({supported:e,checked:t,onChange:n}){let r=K(),i=e?void 0:`claude-system-env-unsupported`;return(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.systemEnv`)}),e?(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.systemEnvDesc`)}):(0,P.jsx)(`span`,{className:`desc`,id:i,children:(0,P.jsx)(Fe,{k:`claude.systemEnvUnsupported`,cmd:`ocx claude`})}),e&&t&&(0,P.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:r(`claude.systemEnvWarn`)})]}),(0,P.jsx)(Ac,{label:r(`claude.systemEnv`),checked:e&&t,disabled:!e,describedBy:i,onChange:n})]})}function Mc({value:e,tierHaikuModel:t,options:n,onChange:r}){let i=K(),a=t??e;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`h-section`,children:i(`claude.smallFastModel`)}),(0,P.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:i(`claude.smallFastModelAccurateHint`)}),(0,P.jsx)(Ze,{value:e,options:n,onChange:r,label:i(`claude.smallFastModel`),style:{maxWidth:420}}),a===``&&(0,P.jsx)(`p`,{className:`notice-warn`,role:`status`,style:{marginTop:8},children:i(`claude.smallFastModelNativeWarning`)})]})}function Nc(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)try{return crypto.randomUUID()}catch{}let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Pc(e,t=`en`){if(e>=1e6){let n=e/1e6,r=n.toFixed(1).replace(/\.0$/,``);return Number.isInteger(n)||Number(r)*1e6===e?new Intl.NumberFormat(t,{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:+!Number.isInteger(n)}).format(e):`${Math.round(e/1e3)}k`}return`${Math.round(e/1e3)}k`}function Fc(e,t){return e&&[`claude-json-oauth`,`claude-credentials-file`,`macos-keychain`,`exported-env`].includes(e)?t(`claude.authSource.${e}`):t(`claude.authSource.unknown`)}function Ic({state:e,autoCompactOptions:t,onStateChange:n}){let r=K();return(0,P.jsxs)(`div`,{className:`card`,style:{overflow:`hidden`},children:[(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.enabledLabel`)}),(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.enabledHint`)})]}),(0,P.jsx)(Ac,{label:r(`claude.enabledLabel`),checked:e.enabled,onChange:t=>n({...e,enabled:t})})]}),(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.authMode`)}),(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.authModeHint`)})]}),(0,P.jsx)(Ze,{value:e.authMode,options:[{value:`auto`,label:r(`claude.authModeAuto`)},{value:`subscription`,label:r(`claude.authModeSubscription`)},{value:`proxy`,label:r(`claude.authModeProxy`)}],onChange:t=>n({...e,authMode:t}),label:r(`claude.authMode`),style:{minWidth:220},portal:!0})]}),e.authModeOrigin&&(0,P.jsx)(`div`,{className:`setting-row`,children:(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.effectiveMode.label`)}),(0,P.jsxs)(`span`,{className:`desc${e.authModeOrigin===`auto-unknown`?` warn`:``}`,children:[e.authModeOrigin===`manual`?r(`claude.effectiveMode.manual`,{mode:e.markerMode===`proxy`?r(`claude.authModeProxy`):r(`claude.authModeSubscription`)}):e.authModeOrigin===`auto-present`?r(`claude.effectiveMode.autoPresent`,{source:Fc(e.authFoundBy,r)}):e.authModeOrigin===`auto-absent`?r(`claude.effectiveMode.autoAbsent`):r(`claude.effectiveMode.autoUnknown`),e.admissionKeyActive===!0?` ${r(`claude.effectiveMode.admissionKey`)}`:``]})]})}),(0,P.jsx)(jc,{supported:e.autoConnectSupported,checked:e.systemEnv,onChange:t=>n({...e,systemEnv:t})}),(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.fastMode`)}),(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.fastModeDesc`)})]}),(0,P.jsxs)(`select`,{value:e.fastMode===null?`auto`:e.fastMode?`on`:`off`,onChange:t=>{let r=t.target.value;n({...e,fastMode:r===`auto`?null:r===`on`})},className:`text-label font-medium`,"aria-label":r(`claude.fastMode`),style:{padding:`5px 10px`,borderRadius:`var(--radius-xs)`,border:`1px solid var(--border)`,background:`var(--surface)`,color:`var(--text)`},children:[(0,P.jsx)(`option`,{value:`auto`,children:r(`claude.fastAuto`)}),(0,P.jsx)(`option`,{value:`on`,children:r(`claude.fastOn`)}),(0,P.jsx)(`option`,{value:`off`,children:r(`claude.fastOff`)})]})]}),(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.autoContext`)}),(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.autoContextDesc`)}),e.maxContextTokens!==null&&(0,P.jsx)(`span`,{className:`desc`,style:{color:`var(--muted)`},children:r(`claude.autoContextInert`)})]}),(0,P.jsx)(Ac,{label:r(`claude.autoContext`),checked:e.autoContext,onChange:t=>n({...e,autoContext:t})})]}),e.autoContext&&(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.autoCompactWindow`)}),(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.autoCompactWindowDesc`)}),e.autoCompactWindow!==null&&(0,P.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:r(`claude.autoCompactWindowWarn`)})]}),(0,P.jsx)(Ze,{value:e.autoCompactWindow===null?``:String(e.autoCompactWindow),options:t,onChange:t=>n({...e,autoCompactWindow:t===``?null:Number(t)}),label:r(`claude.autoCompactWindow`),style:{minWidth:130},portal:!0})]}),(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.injectAgents`)}),(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.injectAgentsDesc`)})]}),(0,P.jsx)(Ac,{label:r(`claude.injectAgents`),checked:e.injectAgents,onChange:t=>n({...e,injectAgents:t})})]}),[`webSearchSidecar`,`visionSidecar`].map(t=>{let i=e[t],a=t===`webSearchSidecar`?`claude.webSearchSidecar`:`claude.visionSidecar`,o=t===`webSearchSidecar`?`claude.webSearchSidecarHint`:`claude.visionSidecarHint`;return(0,P.jsxs)(`div`,{className:`setting-row`,style:{alignItems:`flex-start`},children:[(0,P.jsxs)(`div`,{className:`setting-label setting-copy`,style:{flex:1},children:[(0,P.jsx)(`span`,{className:`title`,children:r(a)}),(0,P.jsx)(`span`,{className:`desc`,children:r(o)})]}),(0,P.jsxs)(`div`,{className:`setting-controls`,style:{display:`flex`,gap:8},children:[(0,P.jsx)(Ze,{value:Ec(i),options:[{value:`inherit`,label:r(`claude.useMainSetting`)},{value:`auto`,label:r(`dash.backendAuto`)},{value:`openai`,label:r(`dash.backendOpenAI`)},{value:`anthropic`,label:r(`dash.backendAnthropic`)}],onChange:r=>{n({...e,[t]:Dc(i,r)})},label:r(`dash.sidecarBackend`),portal:!0}),(0,P.jsx)(`input`,{className:`input mono`,value:i?.model??``,onChange:r=>{n({...e,[t]:Oc(i,r.target.value)})},placeholder:r(`claude.sidecarModelPlaceholder`),disabled:!i,"aria-label":r(`dash.sidecarModel`),style:{minWidth:210}})]})]},t)})]})}function Lc({manualEnv:e}){let t=K();return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`h-section`,children:t(`claude.quickstart`)}),(0,P.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:(0,P.jsx)(Fe,{k:`claude.quickstartHint`,cmd:`ocx claude`})}),(0,P.jsx)(`pre`,{className:`mono card`,style:{padding:`10px 14px`,overflowX:`auto`,margin:0},children:`ocx claude`}),(0,P.jsxs)(`details`,{style:{margin:`10px 0 0`},children:[(0,P.jsx)(`summary`,{className:`muted text-label`,style:{cursor:`pointer`,padding:`2px 2px`},children:t(`claude.manualEnv`)}),(0,P.jsx)(`pre`,{className:`mono card text-label`,style:{padding:`10px 14px`,overflowX:`auto`,margin:`6px 0 0`},children:e})]})]})}function Rc({rows:e,onRowsChange:t,onSave:n}){let r=K();return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`h-section`,children:[r(`claude.modelMap`),` `,(0,P.jsx)(`span`,{className:`count`,children:e.length})]}),(0,P.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:r(`claude.modelMapHint`)}),(0,P.jsx)(`div`,{className:`stack`,style:{gap:8},children:e.map((n,i)=>(0,P.jsxs)(`div`,{className:`row`,style:{gap:8},children:[(0,P.jsx)(`input`,{className:`input mono`,value:n.from,placeholder:r(`claude.mapFrom`),"aria-label":r(`claude.mapFrom`),onChange:n=>t(e.map((e,t)=>t===i?{...e,from:n.target.value}:e)),style:{flex:1}}),(0,P.jsx)(`span`,{className:`muted`,"aria-hidden":!0,children:`→`}),(0,P.jsx)(`input`,{className:`input mono`,value:n.to,placeholder:r(`claude.mapTo`),"aria-label":r(`claude.mapTo`),onChange:n=>t(e.map((e,t)=>t===i?{...e,to:n.target.value}:e)),style:{flex:1}}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>t(e.filter((e,t)=>t!==i)),"aria-label":r(`claude.removeMapping`),style:{color:`var(--red)`},children:(0,P.jsx)(re,{})})]},n.id))}),(0,P.jsx)(`div`,{style:{marginTop:8},children:(0,P.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>t([...e,{id:Nc(),from:``,to:``}]),children:[(0,P.jsx)(ie,{}),` `,r(`claude.addMapping`)]})}),(0,P.jsx)(`div`,{style:{marginTop:14},children:(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:n,children:r(`common.save`)})})]})}var zc=`etc`;function Bc(e){let t=new Map;for(let n of e){let e=/\(([^)]+)\)\s*$/.exec(n.display_name),r=e?e[1]:zc,i=t.get(r);i?i.push(n):t.set(r,[n])}return Array.from(t)}function Vc({aliases:e}){let t=K();return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`h-section`,children:[t(`claude.aliases`),` `,(0,P.jsx)(`span`,{className:`count`,children:e.length})]}),(0,P.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:t(`claude.aliasesHint`)}),e.length===0?(0,P.jsx)(`div`,{className:`muted text-label`,children:t(`claude.none`)}):(0,P.jsx)(`div`,{className:`stack`,style:{gap:6,maxHeight:320,overflowY:`auto`},children:Bc(e).map(([e,n])=>(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`muted text-caption font-semibold`,style:{textTransform:`uppercase`,letterSpacing:`var(--tracking-wide)`,margin:`6px 2px 4px`},children:[e===zc?t(`claude.aliasProviderOther`):e,` · `,n.length]}),(0,P.jsx)(`div`,{className:`stack`,style:{gap:4},children:n.map(e=>(0,P.jsxs)(`div`,{className:`card row`,style:{padding:`6px 12px`,gap:10},children:[(0,P.jsx)(`code`,{className:`mono text-label`,style:{flex:1},children:e.id}),(0,P.jsx)(`span`,{className:`muted text-label`,children:e.display_name})]},e.id))})]},e))})]})}function Hc({apiBase:e}){let t=K(),{locale:n}=G(),r=ke.find(e=>e.code===n)?.htmlLang??`en`,[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!0),m=(0,_.useCallback)(async()=>{try{let n=await et(await fetch(`${e}/api/claude-code`),t(`claude.loadFail`));if(!n){d(!1),l(t(`claude.loadFail`));return}a({...n,authMode:n.authMode===`proxy`||n.authMode===`subscription`?n.authMode:`auto`,...Cc(n),fastMode:n.fastMode??null,maxContextTokens:n.maxContextTokens??null,autoContext:n.autoContext!==!1,autoCompactWindow:n.autoCompactWindow??null,injectAgents:n.injectAgents!==!1,effectiveModelEnv:n.effectiveModelEnv??{}}),s(Object.entries(n.modelMap??{}).map(([e,t])=>({id:Nc(),from:e,to:String(t)})))}catch(e){d(!1),l(e instanceof Error&&e.message?e.message:t(`claude.loadFail`))}finally{p(!1)}},[e,t]);(0,_.useEffect)(()=>{let e=window.setTimeout(()=>{m()},0);return()=>window.clearTimeout(e)},[m]);let h=(0,_.useMemo)(()=>{let e=(i?.available??[]).map(e=>({value:e,label:String(ba(e))}));return[{value:``,label:t(`claude.smallFastModelUnsetOption`)},...e]},[i?.available,t]),g=(0,_.useMemo)(()=>{let e=[1e5,2e5,25e4,3e5,35e4,4e5,5e5,6e5,75e4,9e5,1e6],n=i?.autoCompactWindow??null,a=n!==null&&!e.includes(n)?[...e,n].sort((e,t)=>e-t):e;return[{value:``,label:t(`claude.autoCompactDefault`)},...a.map(e=>({value:String(e),label:Pc(e,r)}))]},[i?.autoCompactWindow,t,r]),v=async()=>{if(!i)return;l(``);let n={};for(let e of o)e.from.trim()&&e.to.trim()&&(n[e.from.trim()]=e.to.trim());try{await et(await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:i.enabled,authMode:i.authMode,systemEnv:i.systemEnv,fastMode:i.fastMode,autoContext:i.autoContext,autoCompactWindow:i.autoCompactWindow,injectAgents:i.injectAgents,smallFastModel:i.smallFastModel,modelMap:n,webSearchSidecar:kc(i.webSearchSidecar),visionSidecar:kc(i.visionSidecar)})}),t(`claude.saveFailed`)),d(!0),l(t(`claude.saved`)),await m()}catch(e){d(!1),l(e instanceof Error&&e.message?e.message:t(`claude.networkError`))}};return f?(0,P.jsx)(`div`,{className:`muted`,style:{padding:8},children:t(`claude.loading`)}):i?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`page-head`,children:(0,P.jsx)(`h2`,{children:t(`claude.pageTitle`)})}),(0,P.jsx)(`p`,{className:`page-sub`,children:t(`claude.subtitle`)}),c&&(0,P.jsx)(Xe,{tone:u?`ok`:`err`,children:c}),(0,P.jsx)(Ic,{state:i,autoCompactOptions:g,onStateChange:a}),(0,P.jsx)(Lc,{manualEnv:Tc(i)}),(0,P.jsx)(Mc,{value:i.smallFastModel,tierHaikuModel:i.tierModels?.haiku,options:h,onChange:e=>a({...i,smallFastModel:e})}),(0,P.jsx)(Rc,{rows:o,onRowsChange:s,onSave:()=>{v()}}),(0,P.jsx)(Vc,{aliases:i.aliases})]}):(0,P.jsx)(Xe,{tone:`err`,children:c||t(`claude.loadFail`)})}function Uc(e,t,n){let r=t.trim().toLowerCase(),i=(r?e.filter(e=>e.label.toLowerCase().includes(r)||e.route.toLowerCase().includes(r)):e).toSorted((e,t)=>Number(!e.available)-Number(!t.available)),a=i.slice(0,n);return{total:e.length,showSearch:e.length>4,shown:a,hidden:i.length-a.length,noMatch:e.length>0&&i.length===0}}function Wc(e){return new Set(Object.keys(e).filter(t=>e[t]===0))}function Gc(e,t){return t!==null&&e===t}function Kc(e){return e||(typeof localStorage>`u`?void 0:localStorage)}function qc(e){return{read(t){let n=Kc(t);if(!n)return null;try{let t=n.getItem(e);if(t===null)return null;let r=JSON.parse(t);return Array.isArray(r)?new Set(r.filter(e=>typeof e==`string`)):null}catch{return null}},write(t,n){let r=Kc(n);if(r)try{r.setItem(e,JSON.stringify([...t]))}catch{}}}}function Jc(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}var Yc=[`opus`,`fable`,`sonnet`,`haiku`],Xc=qc(`ocx.claudeDesktop.collapsedFamilies.v1`),Zc={opus:`claudeDesktop.family.opus`,fable:`claudeDesktop.family.fable`,sonnet:`claudeDesktop.family.sonnet`,haiku:`claudeDesktop.family.haiku`};function Qc(e){return{version:1,assignments:Object.fromEntries(Object.entries(e.assignments).map(([e,t])=>[e,{...t}])),defaults:{...e.defaults},...e.appliedFingerprint===void 0?{}:{appliedFingerprint:e.appliedFingerprint},...e.appliedAt===void 0?{}:{appliedAt:e.appliedAt}}}function $c(e){let t={...e.profile.assignments};for(let n of e.models){let e=t[n.route]??n.assignment;t[n.route]={family:Yc.includes(e?.family)?e.family:`opus`,alias:typeof e?.alias==`string`?e.alias:``}}return{version:1,assignments:t,defaults:{opus:e.profile.defaults.opus??null,fable:e.profile.defaults.fable??null,sonnet:e.profile.defaults.sonnet??null,haiku:e.profile.defaults.haiku??null}}}function el(e,t){return e&&typeof e==`object`&&`error`in e&&typeof e.error==`string`?e.error:t}function tl(e,t){return e?e>=1048576?t(`claudeDesktop.contextM`,{n:Math.round(e/1048576)}):e>=1e6?t(`claudeDesktop.contextM`,{n:e/1e6}):t(`claudeDesktop.contextK`,{n:Math.round(e/1e3)}):null}function nl({apiBase:e}){let t=K(),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)({}),[f,p]=(0,_.useState)(!0),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)({}),[T,E]=(0,_.useState)({}),[D,O]=(0,_.useState)(()=>Xc.read()??new Set),[k,A]=(0,_.useState)({}),j=(0,_.useRef)(null),M=(0,_.useCallback)(async()=>{p(!0),h(``);try{let n=await fetch(`${e}/api/claude-desktop`),r=await n.json();if(!n.ok||!(`profile`in r)||!(`models`in r))throw Error(el(r,t(`claudeDesktop.loadFail`)));let i=$c(r);if(a(r),s(i),l(Qc(i)),d(Object.fromEntries(r.models.map(e=>[e.route,i.assignments[e.route]?.family??`opus`]))),Xc.read()===null){let e=Object.fromEntries(Yc.map(e=>[e,0]));for(let t of r.models)e[i.assignments[t.route]?.family??`opus`]+=1;O(Wc(e))}}catch(e){h(e instanceof Error?e.message:t(`claudeDesktop.loadFail`))}finally{p(!1)}},[e,t]);(0,_.useEffect)(()=>{let e=window.setTimeout(()=>{M()},0);return()=>window.clearTimeout(e)},[M]);let N=(0,_.useMemo)(()=>o!==null&&c!==null&&JSON.stringify(o)!==JSON.stringify(c),[o,c]),F=(0,_.useMemo)(()=>{let e=Object.fromEntries(Yc.map(e=>[e,[]]));if(!i||!o)return e;for(let t of i.models)e[o.assignments[t.route]?.family??`opus`].push(t);return e},[i,o]),I=(0,_.useMemo)(()=>{let e={};for(let t of Yc){let n=F[t].filter(e=>e.available).map(e=>e.route).sort(),r=o?.defaults[t]??null;e[t]=r&&n.includes(r)?r:n[0]??null}return e},[F,o]);(0,_.useEffect)(()=>{let t=!1,n=()=>fetch(`${e}/api/claude-desktop/status`).then(e=>e.json()).then(e=>{t||r(e)}).catch(()=>{});n();let i=setInterval(n,5e3);return()=>{t=!0,clearInterval(i)}},[e]);let L=(e,n)=>{!o||o.assignments[e]?.family===n||(s(t=>{if(!t)return t;let r=t.assignments[e];if(!r||r.family===n)return t;let i={...t.assignments,[e]:{...r,family:n}},a={...t.defaults};return a[r.family]===e&&(a[r.family]=Object.keys(i).filter(t=>t!==e&&i[t].family===r.family).sort()[0]??null),a[n]===null&&(a[n]=e),{...t,assignments:i,defaults:a}}),d(t=>({...t,[e]:n})),b(t(`claudeDesktop.moved`,{route:e,family:t(Zc[n])})))},R=e=>{let t=Jc(D,e);Xc.write(t),O(t)},z=async n=>{if(!(!o||x)){S(`save`),v(null);try{let r=await fetch(`${e}/api/claude-desktop`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profile:o})}),i=await r.json().catch(()=>({}));if(!r.ok)throw Error(el(i,t(`claudeDesktop.saveFailed`)));if(l(Qc(o)),n){S(`apply`);let n=await fetch(`${e}/api/claude-desktop/apply`,{method:`POST`}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(el(r,t(`claudeDesktop.applyFailed`)));v({tone:`ok`,text:t(`claudeDesktop.savedApplied`)}),b(t(`claudeDesktop.savedAppliedAnnounce`))}else v({tone:`ok`,text:t(`claudeDesktop.saved`)}),b(t(`claudeDesktop.savedAnnounce`))}catch(e){let n=e instanceof Error?e.message:t(`claudeDesktop.updateFailed`);v({tone:`err`,text:n}),b(n)}finally{S(null)}}},ee=()=>{if(!o)return;let e=URL.createObjectURL(new Blob([`${JSON.stringify(o,null,2)}\n`],{type:`application/json`})),n=document.createElement(`a`);n.href=e,n.download=`claude-desktop-profile.json`,n.click(),URL.revokeObjectURL(e),b(t(`claudeDesktop.exported`))},te=async e=>{let n=e.target.files?.[0];if(e.target.value=``,n)try{let e=JSON.parse(await n.text());if(e.version!==1||!e.assignments||!e.defaults)throw Error(t(`claudeDesktop.importExpected`));s($c({...i,profile:e})),v({tone:`ok`,text:t(`claudeDesktop.importReady`)}),b(t(`claudeDesktop.importedAnnounce`))}catch(e){let n=e instanceof Error?e.message:t(`claudeDesktop.importInvalid`);v({tone:`err`,text:n}),b(t(`claudeDesktop.importFailed`,{error:n}))}},B=(e,t)=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);n&&L(n,t)};return f?(0,P.jsx)(`div`,{className:`claude-desktop-loading`,role:`status`,children:t(`claudeDesktop.loading`)}):m||!i||!o?(0,P.jsxs)(`div`,{className:`claude-desktop-error`,children:[(0,P.jsx)(Xe,{tone:`err`,children:m||t(`claudeDesktop.loadFail`)}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void M(),children:t(`claudeDesktop.retry`)})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`page-head claude-desktop-head`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{children:t(`claudeDesktop.title`)}),(0,P.jsx)(`p`,{className:`page-sub`,children:t(`claudeDesktop.subtitle`,{port:i.port})})]}),(0,P.jsxs)(`div`,{className:`claude-profile-tools`,children:[(0,P.jsx)(`input`,{ref:j,type:`file`,accept:`application/json,.json`,hidden:!0,onChange:e=>void te(e)}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>j.current?.click(),children:t(`claudeDesktop.importJson`)}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:ee,children:t(`claudeDesktop.exportJson`)})]})]}),n&&(0,P.jsxs)(`div`,{className:`claude-status-bar ${n.stale?`stale`:n.applied?`applied`:`not-applied`}`,children:[(0,P.jsx)(`span`,{className:`claude-status-dot`}),(0,P.jsx)(`span`,{children:n.stale?t(`claudeDesktop.status.stale`):n.applied?t(`claudeDesktop.status.applied`):t(`claudeDesktop.status.notApplied`)}),n.health.lastRequestAt&&(0,P.jsxs)(`span`,{className:`claude-status-health`,children:[t(`claudeDesktop.health.lastRequest`),`: `,new Date(n.health.lastRequestAt).toLocaleTimeString()]}),n.health.requestCount>0&&(0,P.jsx)(`span`,{className:`claude-status-health`,children:t(`claudeDesktop.health.stats`,{count:n.health.requestCount,errors:n.health.errorCount})})]}),(0,P.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:y}),g&&(0,P.jsx)(Xe,{tone:g.tone,children:g.text}),(0,P.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,P.jsx)(`span`,{className:`claude-dirty${N?` active`:``}`,children:t(N?`claudeDesktop.unsaved`:`claudeDesktop.upToDate`)}),(0,P.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!N||x!==null,onClick:()=>void z(!1),children:t(x===`save`?`claudeDesktop.saving`:`common.save`)}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:x!==null,onClick:()=>void z(!0),children:t(x===`apply`?`claudeDesktop.applying`:x===`save`?`claudeDesktop.saving`:`claudeDesktop.saveApply`)})]})]}),i.models.length===0&&(0,P.jsx)(q,{title:t(`claudeDesktop.emptyTitle`),children:t(`claudeDesktop.emptyHint`)}),(0,P.jsx)(`div`,{className:`ocx-group-stack`,"aria-label":t(`claudeDesktop.assignmentsLabel`),children:Yc.map(e=>{let n=F[e],r=Uc(n,C[e]??``,T[e]??6),i=D.has(e),a=I[e];return(0,P.jsxs)(`section`,{className:`ocx-group${i?` collapsed`:``}`,"aria-labelledby":`claude-lane-${e}`,onDragOver:e=>e.preventDefault(),onDrop:t=>B(t,e),children:[(0,P.jsxs)(`header`,{className:`ocx-group-head${i?``:` open`}`,children:[(0,P.jsx)(`h3`,{id:`claude-lane-${e}`,className:`ocx-group-heading`,children:(0,P.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!i,"aria-controls":`claude-lane-body-${e}`,onClick:()=>R(e),children:[(0,P.jsx)(W,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:i?`none`:`rotate(90deg)`}}),(0,P.jsx)(`span`,{className:`ocx-group-name`,children:t(Zc[e])}),(0,P.jsx)(`span`,{className:`ocx-group-count`,children:t(n.length===1?`claudeDesktop.modelCountOne`:`claudeDesktop.modelCountMany`,{count:n.length})}),a&&(0,P.jsx)(`code`,{className:`claude-lane-default`,title:a,children:a})]})}),n.length>0&&o.defaults[e]===null&&(0,P.jsx)(`span`,{className:`claude-default-needed`,children:t(`claudeDesktop.chooseDefault`)}),a&&a!==o.defaults[e]&&(0,P.jsx)(`span`,{className:`claude-default-needed`,title:a,children:t(`claudeDesktop.temporaryDefault`)})]}),!i&&(0,P.jsxs)(`div`,{id:`claude-lane-body-${e}`,children:[r.showSearch&&(0,P.jsx)(`input`,{className:`input claude-lane-search`,type:`search`,placeholder:t(`models.search`),"aria-label":t(`models.search`),value:C[e]??``,onChange:t=>{let n=t.target.value;w(t=>({...t,[e]:n})),E(t=>({...t,[e]:6}))}}),(0,P.jsxs)(`div`,{className:`claude-lane-models`,children:[n.length===0?(0,P.jsx)(`div`,{className:`claude-lane-empty`,children:t(`claudeDesktop.laneEmpty`)}):r.noMatch?(0,P.jsx)(`div`,{className:`claude-lane-empty`,children:t(`claudeDesktop.laneNoMatch`)}):r.shown.map(n=>{let r=o.assignments[n.route],i=tl(n.contextWindow,t),a=u[n.route]??`opus`,c=k[n.route]??Gc(n.route,I[e]);return(0,P.jsxs)(`article`,{className:`claude-model-card${c?` open`:``}`,draggable:n.available,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,n.route)},children:[(0,P.jsxs)(`button`,{type:`button`,className:`claude-model-summary`,"aria-expanded":c,"aria-controls":`claude-model-body-${n.route}`,onClick:()=>A(e=>({...e,[n.route]:!c})),children:[(0,P.jsx)(W,{className:`ocx-chevron`,width:12,height:12,"aria-hidden":`true`,style:{transform:c?`rotate(90deg)`:`none`}}),(0,P.jsxs)(`span`,{className:`claude-model-names`,children:[(0,P.jsx)(`strong`,{title:n.label,children:n.label}),(0,P.jsx)(`code`,{title:n.route,children:n.route})]}),i&&(0,P.jsx)(`span`,{className:`claude-model-context`,children:i}),!i&&(0,P.jsx)(`span`,{className:`claude-model-context claude-model-context-unknown`,children:t(`claudeDesktop.contextUnknown`)}),n.supports1m===!0&&(0,P.jsx)(`span`,{className:`claude-1m-chip`,children:t(`claudeDesktop.supports1m`)}),n.effortSupported===!1&&(0,P.jsx)(`span`,{className:`claude-effort-badge off`,children:t(`claudeDesktop.effort.displayOnly`)}),n.effortSupported===!0&&(0,P.jsx)(`span`,{className:`claude-effort-badge on`,children:t(`claudeDesktop.effort.supported`)}),o.defaults[e]===n.route&&(0,P.jsx)(`span`,{className:`claude-row-default`,children:t(`claudeDesktop.defaultBadge`)}),(0,P.jsx)(`span`,{className:`badge ${n.available?`badge-green`:`badge-muted`}`,children:n.available?t(`claudeDesktop.available`):t(`claudeDesktop.unavailable`)})]}),c&&(0,P.jsxs)(`div`,{className:`claude-model-body`,id:`claude-model-body-${n.route}`,children:[I[e]===n.route&&o.defaults[e]!==n.route&&(0,P.jsx)(`span`,{className:`claude-effective-default`,children:t(`claudeDesktop.temporaryDefault`)}),(0,P.jsxs)(`div`,{className:`claude-field`,children:[(0,P.jsx)(`span`,{children:t(`claudeDesktop.alias`)}),(0,P.jsx)(`code`,{className:`claude-alias`,title:r.alias,children:r.alias})]}),(0,P.jsxs)(`label`,{className:`claude-default-radio`,children:[(0,P.jsx)(`input`,{type:`radio`,name:`default-${e}`,checked:o.defaults[e]===n.route,disabled:!n.available,onChange:()=>s(t=>t&&{...t,defaults:{...t.defaults,[e]:n.route}})}),t(`claudeDesktop.useAsDefault`,{family:t(Zc[e])})]}),(0,P.jsxs)(`div`,{className:`claude-move-row`,children:[(0,P.jsx)(`label`,{htmlFor:`move-${n.route}`,children:t(`claudeDesktop.moveTo`)}),(0,P.jsx)(`select`,{id:`move-${n.route}`,className:`input`,value:a,disabled:!n.available,onChange:e=>d(t=>({...t,[n.route]:e.target.value})),children:Yc.map(e=>(0,P.jsx)(`option`,{value:e,children:t(Zc[e])},e))}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:!n.available||a===e,onClick:()=>L(n.route,a),children:t(`claudeDesktop.move`)})]})]})]},n.route)}),r.hidden>0&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm claude-lane-more`,onClick:()=>E(t=>({...t,[e]:(t[e]??6)+6})),children:t(`models.showMore`,{n:r.hidden})})]})]})]},e)})})]})}function rl({apiBase:e}){let[t,n]=(0,_.useState)(`code`),r=K(),i=(0,_.useRef)(null),a=(0,_.useRef)(null),o=e=>{n(e),window.requestAnimationFrame(()=>(e===`code`?i:a).current?.focus())},s=e=>{e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),o(t===`code`?`desktop`:`code`)):e.key===`Home`?(e.preventDefault(),o(`code`)):e.key===`End`&&(e.preventDefault(),o(`desktop`))};return(0,P.jsxs)(`section`,{className:`claude-page`,children:[(0,P.jsxs)(`div`,{className:`claude-tabs`,role:`tablist`,"aria-label":r(`claude.tabsLabel`),children:[(0,P.jsx)(`button`,{type:`button`,role:`tab`,ref:i,"aria-selected":t===`code`,"aria-controls":`claude-code-panel`,id:`claude-code-tab`,className:t===`code`?`active`:``,tabIndex:t===`code`?0:-1,onKeyDown:s,onClick:()=>o(`code`),children:r(`claude.tabCode`)}),(0,P.jsx)(`button`,{type:`button`,role:`tab`,ref:a,"aria-selected":t===`desktop`,"aria-controls":`claude-desktop-panel`,id:`claude-desktop-tab`,className:t===`desktop`?`active`:``,tabIndex:t===`desktop`?0:-1,onKeyDown:s,onClick:()=>o(`desktop`),children:r(`claude.tabDesktop`)})]}),(0,P.jsx)(`div`,{id:`claude-code-panel`,role:`tabpanel`,"aria-labelledby":`claude-code-tab`,hidden:t!==`code`,children:t===`code`&&(0,P.jsx)(Hc,{apiBase:e})}),(0,P.jsx)(`div`,{id:`claude-desktop-panel`,role:`tabpanel`,"aria-labelledby":`claude-desktop-tab`,hidden:t!==`desktop`,children:t===`desktop`&&(0,P.jsx)(nl,{apiBase:e})})]})}function il(e,t,n,r){let i=e.filter(e=>r===`native`===e.native).map(e=>({...e,alias:t.get(e.id)??null,enabled:!n.has(e.id)})).toSorted((e,t)=>Number(!e.enabled)-Number(!t.enabled));return{rows:i,total:i.length,enabled:i.filter(e=>e.enabled).length}}var al=qc(`ocx.grok.collapsedGroups.v1`),ol=[{id:`native`,tkey:`grok.groupNative`},{id:`routed`,tkey:`grok.groupRouted`}];function sl(e,t){return e?e>=1048576?t(`claudeDesktop.contextM`,{n:Math.round(e/1048576)}):e>=1e6?t(`claudeDesktop.contextM`,{n:e/1e6}):t(`claudeDesktop.contextK`,{n:Math.round(e/1e3)}):`—`}function cl({apiBase:e}){let t=K(),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(new Set),[u,d]=(0,_.useState)(new Set),[f,p]=(0,_.useState)(()=>al.read()??new Set),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(``),x=(0,_.useCallback)(async()=>{a(!0),s(``);try{let n=await fetch(`${e}/api/grok`),i=await n.json();if(!n.ok)throw Error(i.error||t(`grok.loadFail`));r({...i,candidates:i.candidates??[],excluded:i.excluded??[]});let a=new Set(i.excluded??[]);l(a),d(a)}catch(e){s(e instanceof Error?e.message:t(`grok.loadFail`))}finally{a(!1)}},[e,t]);(0,_.useEffect)(()=>{let e=window.setTimeout(()=>{x()},0);return()=>window.clearTimeout(e)},[x]);let S=(0,_.useMemo)(()=>c.size!==u.size||[...c].some(e=>!u.has(e)),[c,u]),C=(0,_.useMemo)(()=>new Map((n?.models??[]).map(e=>[e.id,e.alias])),[n]),w=e=>{let t=Jc(f,e);al.write(t),p(t)},T=(e,t)=>{l(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})},E=async n=>{if(!m){h(`save`),v(null);try{let r=await fetch(`${e}/api/grok/selection`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({excluded:[...c]})}),i=await r.json().catch(()=>({}));if(!r.ok)throw Error(i.error??t(`grok.saveFailed`));if(d(new Set(c)),n){h(`apply`);let n=await fetch(`${e}/api/grok/apply`,{method:`POST`}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.message??t(`grok.applyFailed`));r.skippedReason?(v({tone:`err`,text:r.message??t(`grok.applySkipped`)}),b(r.message??t(`grok.applySkipped`))):(v({tone:`ok`,text:t(`grok.savedApplied`)}),b(t(`grok.savedApplied`))),await x()}else v({tone:`ok`,text:t(`grok.saved`)}),b(t(`grok.saved`))}catch(e){let n=e instanceof Error?e.message:t(`grok.saveFailed`);v({tone:`err`,text:n}),b(n)}finally{h(null)}}};return i?(0,P.jsx)(`section`,{className:`grok-page`,children:(0,P.jsx)(`p`,{className:`page-sub`,children:t(`grok.loading`)})}):o?(0,P.jsxs)(`section`,{className:`grok-page`,children:[(0,P.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:o}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void x(),children:t(`common.retry`)})]}):(0,P.jsxs)(`section`,{className:`grok-page`,children:[(0,P.jsx)(`h2`,{className:`page-title`,children:t(`grok.title`)}),(0,P.jsx)(`p`,{className:`page-sub`,children:t(`grok.subtitle`)}),(0,P.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:y}),g&&(0,P.jsx)(Xe,{tone:g.tone,children:g.text}),n&&n.candidates.length>0&&(0,P.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,P.jsx)(`span`,{className:`claude-dirty${S?` active`:``}`,children:t(S?`grok.unsaved`:`grok.upToDate`)}),(0,P.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!S||m!==null,onClick:()=>void E(!1),children:t(m===`save`?`grok.saving`:`common.save`)}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!S||m!==null,onClick:()=>void E(!0),children:t(m===`apply`?`grok.applying`:m===`save`?`grok.saving`:`grok.saveApply`)})]})]}),n?.present?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`grok-endpoint`,children:[(0,P.jsx)(`span`,{children:t(`grok.endpoint`)}),(0,P.jsx)(`code`,{children:n.baseUrl??`—`})]}),(0,P.jsx)(`p`,{className:`page-sub`,children:(0,P.jsx)(`code`,{children:n.configPath})})]}):(0,P.jsxs)(q,{title:t(`grok.notConfiguredTitle`),children:[t(`grok.notConfiguredHint`),(0,P.jsx)(`br`,{}),(0,P.jsx)(`code`,{children:n?.configPath})]}),n&&n.candidates.length>0&&(0,P.jsx)(`div`,{className:`ocx-group-stack`,children:ol.map(e=>{let r=il(n.candidates,C,c,e.id);if(r.total===0)return null;let i=f.has(e.id);return(0,P.jsxs)(`section`,{className:`ocx-group${i?` collapsed`:``}`,"aria-labelledby":`grok-group-${e.id}`,children:[(0,P.jsx)(`header`,{className:`ocx-group-head${i?``:` open`}`,children:(0,P.jsx)(`h3`,{id:`grok-group-${e.id}`,className:`ocx-group-heading`,children:(0,P.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!i,"aria-controls":`grok-group-body-${e.id}`,onClick:()=>w(e.id),children:[(0,P.jsx)(W,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:i?`none`:`rotate(90deg)`}}),(0,P.jsx)(`span`,{className:`ocx-group-name`,children:t(e.tkey)}),(0,P.jsx)(`span`,{className:`ocx-group-count`,children:t(`grok.enabledCount`,{on:r.enabled,total:r.total})})]})})}),!i&&(0,P.jsx)(`div`,{id:`grok-group-body-${e.id}`,className:`grok-model-list`,children:r.rows.map(e=>(0,P.jsxs)(`div`,{className:`grok-model-row`,children:[(0,P.jsx)(Ye,{on:e.enabled,onClick:()=>T(e.id,!e.enabled),disabled:m!==null,label:t(`grok.toggleModel`,{id:e.id})}),(0,P.jsxs)(`span`,{className:`grok-model-names`,children:[(0,P.jsx)(`strong`,{title:e.id,children:e.id}),(0,P.jsx)(`code`,{title:e.alias??void 0,children:e.alias??`—`})]}),(0,P.jsx)(`span`,{className:`claude-model-context`,children:sl(e.contextWindow,t)})]},e.id))})]},e.id)})})]})}function ll(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.supported==`boolean`&&typeof t.installed==`boolean`&&typeof t.running==`boolean`&&typeof t.stale==`boolean`&&typeof t.summary==`string`}var ul={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},dl={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},fl={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function pl({ok:e,yes:t,no:n}){return(0,P.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function ml({failed:e,data:t}){let{t:n}=G(),r=e?`startup-hero--risk`:t.status===`protected`?`startup-hero--safe`:t.status===`at-risk`?`startup-hero--risk`:`startup-hero--native`,i=e||t.status===`at-risk`?U:ne,a=t.routingKind===`opencodex-local`?`startup.routing.proxy`:t.routingKind===`custom-local`?`startup.routing.customLocal`:t.routingKind===`custom-remote`?`startup.routing.customRemote`:t.routingKind===`unknown`?`startup.routing.unknown`:`startup.routing.native`;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`section`,{className:`panel startup-hero ${r}`,"aria-live":`polite`,children:[(0,P.jsx)(`div`,{className:`startup-hero-icon`,children:(0,P.jsx)(i,{})}),(0,P.jsxs)(`div`,{className:`startup-hero-copy`,children:[(0,P.jsx)(`span`,{className:`badge ${e||t.status===`at-risk`?`badge-amber`:`badge-green`}`,children:n(e?`startup.status.atRisk`:ul[t.status])}),(0,P.jsx)(`h3`,{children:n(e?`startup.error`:dl[t.status])}),(0,P.jsx)(`p`,{children:e?n(`startup.staleData`):t.status===`at-risk`?n(zt(t)):n(`startup.safeDetail`)})]})]}),(0,P.jsxs)(`div`,{className:`startup-state-grid`,children:[(0,P.jsxs)(`section`,{className:`stat`,children:[(0,P.jsx)(`div`,{className:`label`,children:n(`startup.routing`)}),(0,P.jsx)(`div`,{className:`value`,children:n(a)})]}),(0,P.jsxs)(`section`,{className:`stat`,children:[(0,P.jsx)(`div`,{className:`label`,children:n(`startup.restartProtection`)}),(0,P.jsx)(`div`,{className:`value`,children:n(fl[t.protection])})]}),(0,P.jsxs)(`section`,{className:`stat`,children:[(0,P.jsx)(`div`,{className:`label`,children:n(`startup.preference`)}),(0,P.jsx)(`div`,{className:`value`,children:n(t.autostartEnabled?`startup.enabled`:`startup.disabled`)})]})]})]})}function hl({data:e,failed:t,installBusy:n,installResult:r,onInstall:i}){let{t:a}=G();return(0,P.jsxs)(`section`,{className:`panel startup-details`,children:[(0,P.jsxs)(`div`,{className:`panel-head`,children:[(0,P.jsx)(`h3`,{className:`panel-title`,children:a(`startup.details`)}),(0,P.jsx)(`span`,{className:`muted mono`,children:e.platform})]}),(0,P.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:a(`startup.service`)}),(0,P.jsx)(`span`,{children:a(`startup.serviceHint`)})]}),(0,P.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,P.jsx)(pl,{ok:e.serviceViable,yes:a(`startup.viable`),no:a(e.serviceConflict?`startup.conflict`:e.serviceStale?`startup.stale`:e.serviceInstalled?`startup.unhealthy`:e.serviceSupported?`startup.notInstalled`:`startup.unsupported`)}),e.serviceSupported&&!e.serviceInstalled&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${a(`startup.service`)} - ${a(`startup.install`)}`,disabled:n!==null||t,onClick:()=>i(`install-service`),children:a(n===`install-service`?`startup.installing`:`startup.install`)})]})]}),(0,P.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:a(`startup.shim`)}),(0,P.jsx)(`span`,{children:a(`startup.shimHint`)})]}),(0,P.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,P.jsx)(pl,{ok:e.shimHealthy&&e.autostartEnabled,yes:a(e.shimCoverage===`cli-only`?`startup.cliOnly`:`startup.healthy`),no:a(e.shimInstalled?e.shimHealthy&&!e.autostartEnabled?`startup.installedDisabled`:`startup.stale`:`startup.notInstalled`)}),!e.shimInstalled&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${a(`startup.shim`)} - ${a(`startup.install`)}`,disabled:n!==null||t,onClick:()=>i(`install-shim`),children:a(n===`install-shim`?`startup.installing`:`startup.install`)})]})]}),r&&(0,P.jsx)(`div`,{className:`notice ${r.kind===`success`?`notice-ok`:`notice-warn`} startup-action-notice`,role:`status`,"aria-live":`polite`,children:r.kind===`success`?a(r.action===`install-service`?`startup.serviceInstalled`:`startup.shimInstalled`):`${a(`startup.installFailed`)} ${r.detail??``}`})]})}function gl({tray:e,trayLoading:t,trayError:n,trayBusy:r,onTrayAction:i}){let{t:a}=G();return(0,P.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,P.jsxs)(`div`,{className:`panel-head`,children:[(0,P.jsx)(`h3`,{className:`panel-title`,children:a(`startup.tray.title`)}),(0,P.jsx)(fe,{})]}),(0,P.jsx)(`p`,{className:`muted`,children:a(`startup.tray.hint`)}),(0,P.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:a(`startup.tray.login`)}),(0,P.jsx)(`span`,{children:a(`startup.tray.notProtection`)})]}),t||n||!e?(0,P.jsx)(`span`,{className:`badge badge-amber`,children:a(t?`startup.tray.loading`:`startup.tray.unavailable`)}):(0,P.jsx)(pl,{ok:e.running&&!e.stale,yes:a(`startup.tray.running`),no:a(e.stale?`startup.tray.stale`:e.installed?`startup.tray.stopped`:`startup.tray.notInstalled`)})]}),(0,P.jsxs)(`div`,{className:`startup-tray-buttons`,children:[!t&&!n&&e&&!e.installed&&!e.stale&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`install`),children:a(`startup.tray.install`)}),!t&&!n&&e?.installed&&!e.stale&&!e.running&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`start`),children:a(`startup.tray.start`)}),!t&&!n&&e?.running&&!e.stale&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:r,onClick:()=>i(`stop`),children:a(`startup.tray.stop`)}),!t&&!n&&e&&(e.installed||e.stale)&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-danger`,disabled:r,onClick:()=>{window.confirm(a(`startup.tray.uninstall`))&&i(`uninstall`)},children:a(`startup.tray.uninstall`)})]}),(n||e?.stale)&&(0,P.jsx)(`div`,{className:`notice notice-warn`,role:`alert`,children:a(`startup.tray.error`)})]})}function _l({data:e,copied:t,onCopy:n}){let{t:r}=G();return(0,P.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,P.jsxs)(`div`,{className:`panel-head`,children:[(0,P.jsx)(`h3`,{className:`panel-title`,children:r(`startup.recovery`)}),(0,P.jsx)(B,{})]}),(0,P.jsx)(`p`,{className:`muted`,children:r(`startup.recoveryHint`)}),(0,P.jsxs)(`div`,{className:`startup-command-list`,children:[e.serviceSupported&&(0,P.jsxs)(`div`,{className:`startup-command-row`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:r(`startup.command.service`)}),(0,P.jsx)(`code`,{children:e.commands.installService})]}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.installService),children:t===e.commands.installService?r(`startup.copied`):r(`startup.copy`)})]}),(0,P.jsxs)(`div`,{className:`startup-command-row`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:r(`startup.command.shim`)}),(0,P.jsx)(`code`,{children:e.commands.installShim})]}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.installShim),children:t===e.commands.installShim?r(`startup.copied`):r(`startup.copy`)})]}),(0,P.jsxs)(`div`,{className:`startup-command-row`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:r(`startup.command.native`)}),(0,P.jsx)(`code`,{children:e.commands.restoreNative})]}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.restoreNative),children:t===e.commands.restoreNative?r(`startup.copied`):r(`startup.copy`)})]})]}),e.status===`at-risk`&&(0,P.jsxs)(`div`,{className:`notice notice-warn startup-action-notice`,role:`alert`,children:[(0,P.jsx)(fe,{}),` `,r(`startup.recommended`,{cmd:e.recommendedCommand??e.commands.installService})]})]})}function vl({apiBase:e}){let{t}=G(),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!0),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(null),D=(0,_.useRef)(0),O=(0,_.useCallback)(async n=>{let i=++D.current;a(!0),p(!0);try{let a=await fetch(`${e}/api/startup-health`,{signal:n});if(!a.ok)throw Error(`fetch failed`);let o=await a.json();if(n?.aborted||i!==D.current)return;r(o),s(o.diagnosticStale);try{let r=await fetch(`${e}/api/settings`,{signal:n});if(r.ok){let e=await r.json();if(!n?.aborted&&i===D.current){let n=e.codexRuntime,r=!!n?.catalogClamp?.active,i=!!n?.newerAvailable,a=(r?n?.catalogClamp?.runtimeVersion:n?.version)??n?.version??`unknown`,o=(n?.catalogClamp?.removedEfforts??[]).join(`, `);w(r?o?t(`startup.codexRuntime.clampHiddenWithEfforts`,{version:a,efforts:o}):t(`startup.codexRuntime.clampHidden`,{version:a}):i?t(`startup.codexRuntime.olderBinary`,{version:a}):null),E(i?`ocx doctor --fix-codex-runtime && ocx sync`:r?`ocx sync`:null)}}else!n?.aborted&&i===D.current&&(w(null),E(null))}catch{!n?.aborted&&i===D.current&&(w(null),E(null))}if(o.platform===`win32`){v(!1);try{let t=await fetch(`${e}/api/windows-tray`,{signal:n});if(!t.ok)throw Error(`tray status failed`);let r=await t.json();if(!ll(r))throw Error(`invalid tray status`);!n?.aborted&&i===D.current&&(d(r),v(!1))}catch{!n?.aborted&&i===D.current&&(d(null),v(!0))}}}catch{if(n?.aborted||i!==D.current)return;s(!0),d(null),v(!0)}finally{i===D.current&&(p(!1),a(!1))}},[e,t]);(0,_.useEffect)(()=>{let e=new AbortController,t=window.setTimeout(()=>{O(e.signal)},0);return()=>{window.clearTimeout(t),D.current+=1,e.abort()}},[O]),(0,_.useEffect)(()=>{if(!n?.diagnosticStale)return;let e=window.setTimeout(()=>{O()},2e3);return()=>window.clearTimeout(e)},[n,O]);let k=async e=>{try{await navigator.clipboard.writeText(e),l(e),window.setTimeout(()=>l(t=>t===e?null:t),1600)}catch{l(null)}},A=async t=>{h(!0),v(!1);try{let n=await fetch(`${e}/api/windows-tray`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t})});if(!n.ok)throw Error(`tray action failed`);let r=await n.json();if(!ll(r.status))throw Error(`invalid tray action status`);d(r.status),v(!1)}catch{d(null),v(!0)}finally{h(!1)}},j=async t=>{b(t),S(null);try{let n=await fetch(`${e}/api/startup-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(typeof e?.error==`string`?e.error:`installation failed`)}S({kind:`success`,action:t}),await O()}catch(e){S({kind:`error`,action:t,detail:e instanceof Error?e.message:String(e)})}finally{b(null)}};return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`page-head`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{children:t(`startup.title`)}),(0,P.jsx)(`p`,{className:`page-sub startup-page-sub`,children:t(`startup.subtitle`)})]}),(0,P.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void O(),disabled:i,children:[(0,P.jsx)(ae,{}),` `,t(`startup.refresh`)]})]}),i&&!n?(0,P.jsx)(q,{title:t(`startup.loading`)}):o&&!n?(0,P.jsx)(q,{title:t(`startup.error`)}):n?(0,P.jsxs)(P.Fragment,{children:[o&&(0,P.jsx)(`div`,{className:`notice notice-warn`,role:`alert`,children:t(`startup.staleData`)}),C&&(0,P.jsxs)(`div`,{className:`notice notice-warn`,role:`status`,children:[(0,P.jsx)(`p`,{children:C}),T&&(0,P.jsxs)(`p`,{children:[(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void k(T),children:t(c===T?`startup.copied`:`startup.copy`)}),(0,P.jsx)(`code`,{style:{marginLeft:`0.5rem`},children:T})]})]}),(0,P.jsx)(ml,{failed:o,data:n}),(0,P.jsx)(hl,{data:n,failed:o,installBusy:y,installResult:x,onInstall:e=>{j(e)}}),n.platform===`win32`&&(0,P.jsx)(gl,{tray:u,trayLoading:f,trayError:g,trayBusy:m,onTrayAction:e=>{A(e)}}),(0,P.jsx)(_l,{data:n,copied:c,onCopy:e=>{k(e)}})]}):null]})}var yl=class extends _.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}reload=()=>{this.setState({error:null})};render(){return this.state.error?(0,P.jsxs)(`section`,{className:`card`,role:`alert`,style:{maxWidth:720,padding:`var(--space-6)`},children:[(0,P.jsxs)(`h2`,{style:{margin:`0 0 var(--space-2)`,fontSize:`var(--text-title)`},children:[this.props.pageName,`: `,this.props.title]}),(0,P.jsx)(`p`,{className:`muted`,style:{margin:`0 0 var(--space-4)`},children:this.props.message}),(0,P.jsxs)(`p`,{style:{margin:`0 0 var(--space-5)`,overflowWrap:`anywhere`},children:[(0,P.jsxs)(`strong`,{children:[this.props.detailsLabel,`:`]}),` `,this.state.error.message]}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:this.reload,children:this.props.reloadLabel})]}):this.props.children}},bl=!1,xl=null;function Sl(e){try{let t=e instanceof Request?e.url:String(e),n=new URL(t,window.location.href);return n.origin===window.location.origin?n.pathname.startsWith(`/api/`)||n.pathname.startsWith(`/v1/`):!1}catch{return!1}}var Cl=`opencodex-api-token`,wl=null;function Tl(){return wl}function El(e){wl=e}function Dl(){wl=null}function Ol(){try{sessionStorage.removeItem(Cl)}catch{}}function kl(e,t,n){let r=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));return r.set(`X-OpenCodex-API-Key`,n),e instanceof Request?[new Request(e,{headers:r}),t?{...t,headers:r}:void 0]:[e,{...t,headers:r}]}async function Al(){return xl||(xl=Promise.resolve().then(()=>window.prompt(`OpenCodex API token`)?.trim()||null).finally(()=>{xl=null}),xl)}function jl(){if(bl)return;bl=!0,Ol();let e=window.fetch.bind(window);window.fetch=async(t,n)=>{if(!Sl(t))return e(t,n);let r=Tl(),[i,a]=r?kl(t,n,r):[t,n],o=await e(i,a);if(o.status!==401)return o;r&&Dl();let s=await Al();if(!s)return o;El(s);let[c,l]=kl(t,n,s),u=await e(c,l);return u.status===401&&Dl(),u}}var Ml=new Set([`dashboard`,`startup`,`providers`,`models`,`combos`,`subagents`,`logs`,`usage`,`storage`,`codex-auth`,`api`,`claude`,`grok`]);function Nl(e){let t=Ie(e??(typeof window<`u`?window.location.hash:``)).split(`/`)[0];return t===`debug`?`logs`:Ml.has(t)?t:`dashboard`}var Pl=[`dashboard/providers`,`dashboard/models`];function X(e,t){return e===t||t===`logs`&&e===`logs/debug`||t===`dashboard`&&Pl.includes(e)}function Fl(e){let t=Nl(e);return e===`debug`||e.startsWith(`debug/`)?{page:`logs`,replaceTo:`logs/debug`}:e===`providers/workspace`?{page:`providers`,replaceTo:`providers`}:X(e,t)?{page:t,replaceTo:null}:{page:t,replaceTo:t}}var Z=[`ocx-global-view`,`ocx-view`,`ocx-providers-view`,`ocx-subagents-view`,`ocx-storage-view`,`ocx-codexauth-view`,`ocx-apikeys-view`,`ocx-claudecode-view`,`ocx-usage-view`,`ocx-logs-view`,`ocx-models-view`,`ocx-dashboard-view`];function Q(){try{for(let e of Z)localStorage.removeItem(e)}catch{}}function Il(){let[e,t]=(0,_.useState)(Nl);(0,_.useEffect)(()=>{Q()},[]);let n=(0,_.useCallback)(e=>{let n=Fl(e);n.replaceTo&&Le(n.replaceTo),t(n.page)},[]);return(0,_.useEffect)(()=>{let e=()=>{n(Ie(window.location.hash))};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[n]),(0,_.useEffect)(()=>{let t=Ie(window.location.hash);if(t===`debug`||t.startsWith(`debug/`)){Le(`logs/debug`);return}if(t===`providers/workspace`){Le(`providers`);return}X(t,e)||Le(e)},[e]),{page:e,setPageState:t,navigateToPage:e=>{Re(e),t(e)}}}jl();var Ll={dashboard:`nav.dashboard`,startup:`nav.startup`,providers:`nav.providers`,models:`nav.models`,combos:`nav.combos`,subagents:`nav.subagents`,logs:`nav.logs`,usage:`nav.usage`,storage:`nav.storage`,"codex-auth":`nav.codexAuth`,api:`nav.api`,claude:`nav.claude`,grok:`nav.grok`},Rl=``,zl=`ocx-theme`,Bl=[{id:`dashboard`,tkey:`nav.dashboard`,Icon:I},{id:`codex-auth`,tkey:`nav.codexAuth`,Icon:me},{id:`providers`,tkey:`nav.providers`,Icon:L},{id:`models`,tkey:`nav.models`,Icon:R},{id:`subagents`,tkey:`nav.subagents`,Icon:z},{id:`logs`,tkey:`nav.logs`,Icon:ee},{id:`usage`,tkey:`nav.usage`,Icon:V},{id:`storage`,tkey:`nav.storage`,Icon:H},{id:`api`,tkey:`nav.api`,Icon:xe},{id:`claude`,tkey:`nav.claude`,Icon:Se},{id:`grok`,tkey:`nav.grok`,Icon:R}],Vl={light:ve,dark:ye,system:be},Hl={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function Ul(e){if(!e||typeof e!=`object`||!(`version`in e))return null;let t=e.version;return typeof t==`string`&&t.length>0?t:null}function Wl(){let e=localStorage.getItem(zl);return e===`light`||e===`dark`?e:`system`}function Gl(){let{page:e,navigateToPage:t}=Il(),[n,r]=(0,_.useState)(Wl),{locale:i,setLocale:a}=G(),o=K(),[s,c]=(0,_.useState)(!1),l=(0,_.useRef)(null),u=(0,_.useRef)(null),d=(0,_.useRef)(!1);(0,_.useEffect)(()=>{let e=()=>c(!1);return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]),(0,_.useEffect)(()=>{let e=document.documentElement;n===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(zl)):(e.setAttribute(`data-theme`,n),localStorage.setItem(zl,n))},[n]);let f=j(`app-healthz:${Rl}`,[],async e=>{let t=await fetch(`${Rl}/healthz`,{signal:e});return t.ok?Ul(await t.json()):null},{pollMs:3e4}),p=()=>r(e=>e===`light`?`dark`:e===`dark`?`system`:`light`),m=Vl[n],h=f.data??`2.7.41-preview.20260726`,[g,v]=(0,_.useState)(!1),y=(0,_.useCallback)(async e=>{let t=await tt(await fetch(`${Rl}/api/claude-code`,{signal:e}));return t&&typeof t.enabled==`boolean`?t.enabled:null},[]),b=j(`app-claude-code:${Rl}`,[],y).data??null,x=(0,_.useRef)(!1),[S,C]=(0,_.useState)(!1);(0,_.useEffect)(()=>{if(!s)return;let e=e=>{e.key===`Escape`&&c(!1)};window.addEventListener(`keydown`,e);let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{window.removeEventListener(`keydown`,e),document.body.style.overflow=t}},[s]),(0,_.useEffect)(()=>{if(s){d.current=!0;let e=setTimeout(()=>u.current?.focus(),200);return()=>clearTimeout(e)}d.current&&(d.current=!1,l.current?.focus())},[s]),(0,_.useEffect)(()=>{let e=window.matchMedia(`(min-width: 761px)`),t=()=>{e.matches&&c(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let w=async()=>{if(b===null||x.current)return;x.current=!0,C(!0);let e=!b;M(`app-claude-code:${Rl}`,e);try{(await fetch(`${Rl}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})})).ok||M(`app-claude-code:${Rl}`,!e)}catch{M(`app-claude-code:${Rl}`,!e)}finally{x.current=!1,C(!1)}},T=async()=>{if(confirm(o(`dash.stopConfirm`))){v(!0);try{let e=await fetch(`${Rl}/api/stop`,{method:`POST`});if(!e.ok){v(!1);let t=await e.json().catch(()=>null);t?.message&&alert(t.message)}}catch{}}},E=(0,P.jsxs)(`div`,{className:`brand`,children:[(0,P.jsx)(`span`,{className:`brand-logo`,role:`img`,"aria-label":o(`app.logoAria`)}),(0,P.jsx)(`span`,{className:`name`,children:`opencodex`}),(0,P.jsxs)(`span`,{className:`ver`,children:[`v`,h]})]});return(0,P.jsxs)(`div`,{className:`app`,children:[(0,P.jsxs)(`header`,{className:`mobile-topbar`,inert:s,children:[(0,P.jsx)(`button`,{ref:l,type:`button`,className:`menu-toggle`,onClick:()=>c(e=>!e),"aria-expanded":s,"aria-controls":`app-sidebar`,"aria-label":o(s?`nav.closeMenu`:`nav.openMenu`),title:o(s?`nav.closeMenu`:`nav.openMenu`),children:(0,P.jsx)(te,{})}),E,(0,P.jsx)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:T,disabled:g,"aria-label":o(`dash.stop`),title:o(`dash.stop`),children:(0,P.jsx)(fe,{})})]}),s&&(0,P.jsx)(`div`,{className:`drawer-scrim`,onClick:()=>c(!1),"aria-hidden":`true`}),(0,P.jsxs)(`aside`,{id:`app-sidebar`,className:`sidebar${s?` open`:``}`,ref:u,tabIndex:-1,children:[(0,P.jsxs)(`div`,{className:`drawer-head`,children:[E,(0,P.jsx)(`button`,{type:`button`,className:`menu-toggle drawer-close`,onClick:()=>c(!1),"aria-label":o(`nav.closeMenu`),title:o(`nav.closeMenu`),children:(0,P.jsx)(re,{})})]}),(0,P.jsx)(`nav`,{children:Bl.map(({id:n,tkey:r,Icon:i})=>(0,P.jsxs)(`div`,{className:`nav-entry${n===`claude`?` nav-entry-claude${e===n?` active`:``}`:``}`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`nav-item${e===n?` active`:``}`,"data-page":n,onClick:()=>{t(n),c(!1)},"aria-current":e===n?`page`:void 0,children:[(0,P.jsx)(i,{}),` `,o(r)]}),n===`claude`&&b!==null&&(0,P.jsx)(Ye,{on:b,onClick:()=>void w(),disabled:S,label:o(`claude.toggleAria`)})]},n))}),(0,P.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,P.jsxs)(`div`,{className:`lang-toggle`,children:[(0,P.jsx)(xe,{"aria-hidden":!0}),(0,P.jsx)(Ze,{value:i,options:ke.map(e=>({value:e.code,label:e.name})),onChange:e=>a(e),label:o(`lang.label`),placement:`right`,portal:!1,style:{flex:1,minWidth:0,width:`100%`}})]}),(0,P.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:p,"aria-label":`${o(`theme.label`)}: ${o(Hl[n])}`,title:`${o(`theme.label`)}: ${o(Hl[n])}`,children:[(0,P.jsx)(m,{}),` `,(0,P.jsx)(`span`,{className:`mode`,children:o(Hl[n])})]}),(0,P.jsxs)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:T,disabled:g,"aria-label":o(`dash.stop`),title:o(`dash.stop`),children:[(0,P.jsx)(fe,{}),` `,(0,P.jsx)(`span`,{className:`mode`,children:o(g?`dash.stopping`:`dash.stop`)})]}),(0,P.jsxs)(`a`,{className:`sidebar-link`,href:`https://github.com/lidge-jun/opencodex`,target:`_blank`,rel:`noreferrer`,children:[(0,P.jsx)(de,{}),` `,o(`common.github`)]})]})]}),(0,P.jsx)(`main`,{className:`main`,inert:s,children:(0,P.jsx)(`div`,{className:`main-inner${e===`combos`?` main-inner--combos`:``}`,children:(0,P.jsxs)(yl,{pageName:o(Ll[e]),title:o(`errorBoundary.title`),message:o(`errorBoundary.message`),detailsLabel:o(`errorBoundary.details`),reloadLabel:o(`errorBoundary.reload`),children:[e===`dashboard`&&(0,P.jsx)(Qt,{apiBase:Rl}),e===`startup`&&(0,P.jsx)(vl,{apiBase:Rl}),e===`providers`&&(0,P.jsx)(ha,{apiBase:Rl}),e===`models`&&(0,P.jsx)(mo,{apiBase:Rl}),e===`combos`&&(0,P.jsx)(Ao,{apiBase:Rl}),e===`subagents`&&(0,P.jsx)(jo,{apiBase:Rl}),e===`logs`&&(0,P.jsx)(Ls,{apiBase:Rl}),e===`usage`&&(0,P.jsx)($s,{apiBase:Rl}),e===`storage`&&(0,P.jsx)(oc,{apiBase:Rl}),e===`codex-auth`&&(0,P.jsx)(uc,{apiBase:Rl}),e===`api`&&(0,P.jsx)(Sc,{apiBase:Rl}),e===`claude`&&(0,P.jsx)(rl,{apiBase:Rl}),e===`grok`&&(0,P.jsx)(cl,{apiBase:Rl})]},e)})})]})}g.createRoot(document.getElementById(`root`)).render((0,P.jsx)(_.StrictMode,{children:(0,P.jsx)(Pe,{children:(0,P.jsx)(Gl,{})})}));
|
|
65
|
+
`)}function Ec(e){return e?e.backend??`auto`:`inherit`}function Dc(e,t){if(t!==`inherit`)return t===`auto`?{...e,backend:void 0}:{...e,backend:t}}function Oc(e,t){return{...e,model:t}}function kc(e){if(!e)return null;let t=(e.model??``).trim();return e.backend?{backend:e.backend,model:t}:t?{backend:null,model:t}:null}function Ac({label:e,checked:t,onChange:n,disabled:r=!1,describedBy:i}){return(0,P.jsxs)(`label`,{className:`toggle`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:t,disabled:r,"aria-label":e,"aria-describedby":i,onChange:e=>n(e.target.checked)}),(0,P.jsx)(`span`,{className:`slider`,"aria-hidden":`true`})]})}function jc({supported:e,checked:t,onChange:n}){let r=K(),i=e?void 0:`claude-system-env-unsupported`;return(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.systemEnv`)}),e?(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.systemEnvDesc`)}):(0,P.jsx)(`span`,{className:`desc`,id:i,children:(0,P.jsx)(Fe,{k:`claude.systemEnvUnsupported`,cmd:`ocx claude`})}),e&&t&&(0,P.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:r(`claude.systemEnvWarn`)})]}),(0,P.jsx)(Ac,{label:r(`claude.systemEnv`),checked:e&&t,disabled:!e,describedBy:i,onChange:n})]})}function Mc({value:e,tierHaikuModel:t,options:n,onChange:r}){let i=K(),a=t??e;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`h-section`,children:i(`claude.smallFastModel`)}),(0,P.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:i(`claude.smallFastModelAccurateHint`)}),(0,P.jsx)(Ze,{value:e,options:n,onChange:r,label:i(`claude.smallFastModel`),style:{maxWidth:420}}),a===``&&(0,P.jsx)(`p`,{className:`notice-warn`,role:`status`,style:{marginTop:8},children:i(`claude.smallFastModelNativeWarning`)})]})}function Nc(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)try{return crypto.randomUUID()}catch{}let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Pc(e,t=`en`){if(e>=1e6){let n=e/1e6,r=n.toFixed(1).replace(/\.0$/,``);return Number.isInteger(n)||Number(r)*1e6===e?new Intl.NumberFormat(t,{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:+!Number.isInteger(n)}).format(e):`${Math.round(e/1e3)}k`}return`${Math.round(e/1e3)}k`}function Fc(e,t){return e&&[`claude-json-oauth`,`claude-credentials-file`,`macos-keychain`,`exported-env`].includes(e)?t(`claude.authSource.${e}`):t(`claude.authSource.unknown`)}function Ic({state:e,autoCompactOptions:t,onStateChange:n}){let r=K();return(0,P.jsxs)(`div`,{className:`card`,style:{overflow:`hidden`},children:[(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.enabledLabel`)}),(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.enabledHint`)})]}),(0,P.jsx)(Ac,{label:r(`claude.enabledLabel`),checked:e.enabled,onChange:t=>n({...e,enabled:t})})]}),(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.authMode`)}),(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.authModeHint`)})]}),(0,P.jsx)(Ze,{value:e.authMode,options:[{value:`auto`,label:r(`claude.authModeAuto`)},{value:`subscription`,label:r(`claude.authModeSubscription`)},{value:`proxy`,label:r(`claude.authModeProxy`)}],onChange:t=>n({...e,authMode:t}),label:r(`claude.authMode`),style:{minWidth:220},portal:!0})]}),e.authModeOrigin&&(0,P.jsx)(`div`,{className:`setting-row`,children:(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.effectiveMode.label`)}),(0,P.jsxs)(`span`,{className:`desc${e.authModeOrigin===`auto-unknown`?` warn`:``}`,children:[e.authModeOrigin===`manual`?r(`claude.effectiveMode.manual`,{mode:e.markerMode===`proxy`?r(`claude.authModeProxy`):r(`claude.authModeSubscription`)}):e.authModeOrigin===`auto-present`?r(`claude.effectiveMode.autoPresent`,{source:Fc(e.authFoundBy,r)}):e.authModeOrigin===`auto-absent`?r(`claude.effectiveMode.autoAbsent`):r(`claude.effectiveMode.autoUnknown`),e.admissionKeyActive===!0?` ${r(`claude.effectiveMode.admissionKey`)}`:``]})]})}),(0,P.jsx)(jc,{supported:e.autoConnectSupported,checked:e.systemEnv,onChange:t=>n({...e,systemEnv:t})}),(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.fastMode`)}),(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.fastModeDesc`)})]}),(0,P.jsxs)(`select`,{value:e.fastMode===null?`auto`:e.fastMode?`on`:`off`,onChange:t=>{let r=t.target.value;n({...e,fastMode:r===`auto`?null:r===`on`})},className:`text-label font-medium`,"aria-label":r(`claude.fastMode`),style:{padding:`5px 10px`,borderRadius:`var(--radius-xs)`,border:`1px solid var(--border)`,background:`var(--surface)`,color:`var(--text)`},children:[(0,P.jsx)(`option`,{value:`auto`,children:r(`claude.fastAuto`)}),(0,P.jsx)(`option`,{value:`on`,children:r(`claude.fastOn`)}),(0,P.jsx)(`option`,{value:`off`,children:r(`claude.fastOff`)})]})]}),(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.autoContext`)}),(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.autoContextDesc`)}),e.maxContextTokens!==null&&(0,P.jsx)(`span`,{className:`desc`,style:{color:`var(--muted)`},children:r(`claude.autoContextInert`)})]}),(0,P.jsx)(Ac,{label:r(`claude.autoContext`),checked:e.autoContext,onChange:t=>n({...e,autoContext:t})})]}),e.autoContext&&(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.autoCompactWindow`)}),(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.autoCompactWindowDesc`)}),e.autoCompactWindow!==null&&(0,P.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:r(`claude.autoCompactWindowWarn`)})]}),(0,P.jsx)(Ze,{value:e.autoCompactWindow===null?``:String(e.autoCompactWindow),options:t,onChange:t=>n({...e,autoCompactWindow:t===``?null:Number(t)}),label:r(`claude.autoCompactWindow`),style:{minWidth:130},portal:!0})]}),(0,P.jsxs)(`div`,{className:`setting-row`,children:[(0,P.jsxs)(`div`,{className:`setting-label`,children:[(0,P.jsx)(`span`,{className:`title`,children:r(`claude.injectAgents`)}),(0,P.jsx)(`span`,{className:`desc`,children:r(`claude.injectAgentsDesc`)})]}),(0,P.jsx)(Ac,{label:r(`claude.injectAgents`),checked:e.injectAgents,onChange:t=>n({...e,injectAgents:t})})]}),[`webSearchSidecar`,`visionSidecar`].map(t=>{let i=e[t],a=t===`webSearchSidecar`?`claude.webSearchSidecar`:`claude.visionSidecar`,o=t===`webSearchSidecar`?`claude.webSearchSidecarHint`:`claude.visionSidecarHint`;return(0,P.jsxs)(`div`,{className:`setting-row`,style:{alignItems:`flex-start`},children:[(0,P.jsxs)(`div`,{className:`setting-label setting-copy`,style:{flex:1},children:[(0,P.jsx)(`span`,{className:`title`,children:r(a)}),(0,P.jsx)(`span`,{className:`desc`,children:r(o)})]}),(0,P.jsxs)(`div`,{className:`setting-controls`,style:{display:`flex`,gap:8},children:[(0,P.jsx)(Ze,{value:Ec(i),options:[{value:`inherit`,label:r(`claude.useMainSetting`)},{value:`auto`,label:r(`dash.backendAuto`)},{value:`openai`,label:r(`dash.backendOpenAI`)},{value:`anthropic`,label:r(`dash.backendAnthropic`)}],onChange:r=>{n({...e,[t]:Dc(i,r)})},label:r(`dash.sidecarBackend`),portal:!0}),(0,P.jsx)(`input`,{className:`input mono`,value:i?.model??``,onChange:r=>{n({...e,[t]:Oc(i,r.target.value)})},placeholder:r(`claude.sidecarModelPlaceholder`),disabled:!i,"aria-label":r(`dash.sidecarModel`),style:{minWidth:210}})]})]},t)})]})}function Lc({manualEnv:e}){let t=K();return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`h-section`,children:t(`claude.quickstart`)}),(0,P.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:(0,P.jsx)(Fe,{k:`claude.quickstartHint`,cmd:`ocx claude`})}),(0,P.jsx)(`pre`,{className:`mono card`,style:{padding:`10px 14px`,overflowX:`auto`,margin:0},children:`ocx claude`}),(0,P.jsxs)(`details`,{style:{margin:`10px 0 0`},children:[(0,P.jsx)(`summary`,{className:`muted text-label`,style:{cursor:`pointer`,padding:`2px 2px`},children:t(`claude.manualEnv`)}),(0,P.jsx)(`pre`,{className:`mono card text-label`,style:{padding:`10px 14px`,overflowX:`auto`,margin:`6px 0 0`},children:e})]})]})}function Rc({rows:e,onRowsChange:t,onSave:n}){let r=K();return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`h-section`,children:[r(`claude.modelMap`),` `,(0,P.jsx)(`span`,{className:`count`,children:e.length})]}),(0,P.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:r(`claude.modelMapHint`)}),(0,P.jsx)(`div`,{className:`stack`,style:{gap:8},children:e.map((n,i)=>(0,P.jsxs)(`div`,{className:`row`,style:{gap:8},children:[(0,P.jsx)(`input`,{className:`input mono`,value:n.from,placeholder:r(`claude.mapFrom`),"aria-label":r(`claude.mapFrom`),onChange:n=>t(e.map((e,t)=>t===i?{...e,from:n.target.value}:e)),style:{flex:1}}),(0,P.jsx)(`span`,{className:`muted`,"aria-hidden":!0,children:`→`}),(0,P.jsx)(`input`,{className:`input mono`,value:n.to,placeholder:r(`claude.mapTo`),"aria-label":r(`claude.mapTo`),onChange:n=>t(e.map((e,t)=>t===i?{...e,to:n.target.value}:e)),style:{flex:1}}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>t(e.filter((e,t)=>t!==i)),"aria-label":r(`claude.removeMapping`),style:{color:`var(--red)`},children:(0,P.jsx)(re,{})})]},n.id))}),(0,P.jsx)(`div`,{style:{marginTop:8},children:(0,P.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>t([...e,{id:Nc(),from:``,to:``}]),children:[(0,P.jsx)(ie,{}),` `,r(`claude.addMapping`)]})}),(0,P.jsx)(`div`,{style:{marginTop:14},children:(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:n,children:r(`common.save`)})})]})}var zc=`etc`;function Bc(e){let t=new Map;for(let n of e){let e=/\(([^)]+)\)\s*$/.exec(n.display_name),r=e?e[1]:zc,i=t.get(r);i?i.push(n):t.set(r,[n])}return Array.from(t)}function Vc({aliases:e}){let t=K();return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`h-section`,children:[t(`claude.aliases`),` `,(0,P.jsx)(`span`,{className:`count`,children:e.length})]}),(0,P.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:t(`claude.aliasesHint`)}),e.length===0?(0,P.jsx)(`div`,{className:`muted text-label`,children:t(`claude.none`)}):(0,P.jsx)(`div`,{className:`stack`,style:{gap:6,maxHeight:320,overflowY:`auto`},children:Bc(e).map(([e,n])=>(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`muted text-caption font-semibold`,style:{textTransform:`uppercase`,letterSpacing:`var(--tracking-wide)`,margin:`6px 2px 4px`},children:[e===zc?t(`claude.aliasProviderOther`):e,` · `,n.length]}),(0,P.jsx)(`div`,{className:`stack`,style:{gap:4},children:n.map(e=>(0,P.jsxs)(`div`,{className:`card row`,style:{padding:`6px 12px`,gap:10},children:[(0,P.jsx)(`code`,{className:`mono text-label`,style:{flex:1},children:e.id}),(0,P.jsx)(`span`,{className:`muted text-label`,children:e.display_name})]},e.id))})]},e))})]})}function Hc({apiBase:e}){let t=K(),{locale:n}=G(),r=ke.find(e=>e.code===n)?.htmlLang??`en`,[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!0),m=(0,_.useCallback)(async()=>{try{let n=await et(await fetch(`${e}/api/claude-code`),t(`claude.loadFail`));if(!n){d(!1),l(t(`claude.loadFail`));return}a({...n,authMode:n.authMode===`proxy`||n.authMode===`subscription`?n.authMode:`auto`,...Cc(n),fastMode:n.fastMode??null,maxContextTokens:n.maxContextTokens??null,autoContext:n.autoContext!==!1,autoCompactWindow:n.autoCompactWindow??null,injectAgents:n.injectAgents!==!1,effectiveModelEnv:n.effectiveModelEnv??{}}),s(Object.entries(n.modelMap??{}).map(([e,t])=>({id:Nc(),from:e,to:String(t)})))}catch(e){d(!1),l(e instanceof Error&&e.message?e.message:t(`claude.loadFail`))}finally{p(!1)}},[e,t]);(0,_.useEffect)(()=>{let e=window.setTimeout(()=>{m()},0);return()=>window.clearTimeout(e)},[m]);let h=(0,_.useMemo)(()=>{let e=(i?.available??[]).map(e=>({value:e,label:String(ba(e))}));return[{value:``,label:t(`claude.smallFastModelUnsetOption`)},...e]},[i?.available,t]),g=(0,_.useMemo)(()=>{let e=[1e5,2e5,25e4,3e5,35e4,4e5,5e5,6e5,75e4,9e5,1e6],n=i?.autoCompactWindow??null,a=n!==null&&!e.includes(n)?[...e,n].sort((e,t)=>e-t):e;return[{value:``,label:t(`claude.autoCompactDefault`)},...a.map(e=>({value:String(e),label:Pc(e,r)}))]},[i?.autoCompactWindow,t,r]),v=async()=>{if(!i)return;l(``);let n={};for(let e of o)e.from.trim()&&e.to.trim()&&(n[e.from.trim()]=e.to.trim());try{await et(await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:i.enabled,authMode:i.authMode,systemEnv:i.systemEnv,fastMode:i.fastMode,autoContext:i.autoContext,autoCompactWindow:i.autoCompactWindow,injectAgents:i.injectAgents,smallFastModel:i.smallFastModel,modelMap:n,webSearchSidecar:kc(i.webSearchSidecar),visionSidecar:kc(i.visionSidecar)})}),t(`claude.saveFailed`)),d(!0),l(t(`claude.saved`)),await m()}catch(e){d(!1),l(e instanceof Error&&e.message?e.message:t(`claude.networkError`))}};return f?(0,P.jsx)(`div`,{className:`muted`,style:{padding:8},children:t(`claude.loading`)}):i?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`page-head`,children:(0,P.jsx)(`h2`,{children:t(`claude.pageTitle`)})}),(0,P.jsx)(`p`,{className:`page-sub`,children:t(`claude.subtitle`)}),c&&(0,P.jsx)(Xe,{tone:u?`ok`:`err`,children:c}),(0,P.jsx)(Ic,{state:i,autoCompactOptions:g,onStateChange:a}),(0,P.jsx)(Lc,{manualEnv:Tc(i)}),(0,P.jsx)(Mc,{value:i.smallFastModel,tierHaikuModel:i.tierModels?.haiku,options:h,onChange:e=>a({...i,smallFastModel:e})}),(0,P.jsx)(Rc,{rows:o,onRowsChange:s,onSave:()=>{v()}}),(0,P.jsx)(Vc,{aliases:i.aliases})]}):(0,P.jsx)(Xe,{tone:`err`,children:c||t(`claude.loadFail`)})}function Uc(e,t,n){let r=t.trim().toLowerCase(),i=(r?e.filter(e=>e.label.toLowerCase().includes(r)||e.route.toLowerCase().includes(r)):e).toSorted((e,t)=>Number(!e.available)-Number(!t.available)),a=i.slice(0,n);return{total:e.length,showSearch:e.length>4,shown:a,hidden:i.length-a.length,noMatch:e.length>0&&i.length===0}}function Wc(e){return new Set(Object.keys(e).filter(t=>e[t]===0))}function Gc(e,t){return t!==null&&e===t}function Kc(e){return e||(typeof localStorage>`u`?void 0:localStorage)}function qc(e){return{read(t){let n=Kc(t);if(!n)return null;try{let t=n.getItem(e);if(t===null)return null;let r=JSON.parse(t);return Array.isArray(r)?new Set(r.filter(e=>typeof e==`string`)):null}catch{return null}},write(t,n){let r=Kc(n);if(r)try{r.setItem(e,JSON.stringify([...t]))}catch{}}}}function Jc(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}var Yc=[`opus`,`fable`,`sonnet`,`haiku`],Xc=qc(`ocx.claudeDesktop.collapsedFamilies.v1`),Zc={opus:`claudeDesktop.family.opus`,fable:`claudeDesktop.family.fable`,sonnet:`claudeDesktop.family.sonnet`,haiku:`claudeDesktop.family.haiku`};function Qc(e){return{version:1,assignments:Object.fromEntries(Object.entries(e.assignments).map(([e,t])=>[e,{...t}])),defaults:{...e.defaults},...e.appliedFingerprint===void 0?{}:{appliedFingerprint:e.appliedFingerprint},...e.appliedAt===void 0?{}:{appliedAt:e.appliedAt}}}function $c(e){let t={...e.profile.assignments};for(let n of e.models){let e=t[n.route]??n.assignment;t[n.route]={family:Yc.includes(e?.family)?e.family:`opus`,alias:typeof e?.alias==`string`?e.alias:``}}return{version:1,assignments:t,defaults:{opus:e.profile.defaults.opus??null,fable:e.profile.defaults.fable??null,sonnet:e.profile.defaults.sonnet??null,haiku:e.profile.defaults.haiku??null}}}function el(e,t){return e&&typeof e==`object`&&`error`in e&&typeof e.error==`string`?e.error:t}function tl(e,t){return e?e>=1048576?t(`claudeDesktop.contextM`,{n:Math.round(e/1048576)}):e>=1e6?t(`claudeDesktop.contextM`,{n:e/1e6}):t(`claudeDesktop.contextK`,{n:Math.round(e/1e3)}):null}function nl({apiBase:e}){let t=K(),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)({}),[f,p]=(0,_.useState)(!0),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)({}),[T,E]=(0,_.useState)({}),[D,O]=(0,_.useState)(()=>Xc.read()??new Set),[k,A]=(0,_.useState)({}),j=(0,_.useRef)(null),M=(0,_.useCallback)(async()=>{p(!0),h(``);try{let n=await fetch(`${e}/api/claude-desktop`),r=await n.json();if(!n.ok||!(`profile`in r)||!(`models`in r))throw Error(el(r,t(`claudeDesktop.loadFail`)));let i=$c(r);if(a(r),s(i),l(Qc(i)),d(Object.fromEntries(r.models.map(e=>[e.route,i.assignments[e.route]?.family??`opus`]))),Xc.read()===null){let e=Object.fromEntries(Yc.map(e=>[e,0]));for(let t of r.models)e[i.assignments[t.route]?.family??`opus`]+=1;O(Wc(e))}}catch(e){h(e instanceof Error?e.message:t(`claudeDesktop.loadFail`))}finally{p(!1)}},[e,t]);(0,_.useEffect)(()=>{let e=window.setTimeout(()=>{M()},0);return()=>window.clearTimeout(e)},[M]);let N=(0,_.useMemo)(()=>o!==null&&c!==null&&JSON.stringify(o)!==JSON.stringify(c),[o,c]),F=(0,_.useMemo)(()=>{let e=Object.fromEntries(Yc.map(e=>[e,[]]));if(!i||!o)return e;for(let t of i.models)e[o.assignments[t.route]?.family??`opus`].push(t);return e},[i,o]),I=(0,_.useMemo)(()=>{let e={};for(let t of Yc){let n=F[t].filter(e=>e.available).map(e=>e.route).sort(),r=o?.defaults[t]??null;e[t]=r&&n.includes(r)?r:n[0]??null}return e},[F,o]);(0,_.useEffect)(()=>{let t=!1,n=()=>fetch(`${e}/api/claude-desktop/status`).then(e=>e.json()).then(e=>{t||r(e)}).catch(()=>{});n();let i=setInterval(n,5e3);return()=>{t=!0,clearInterval(i)}},[e]);let L=(e,n)=>{!o||o.assignments[e]?.family===n||(s(t=>{if(!t)return t;let r=t.assignments[e];if(!r||r.family===n)return t;let i={...t.assignments,[e]:{...r,family:n}},a={...t.defaults};return a[r.family]===e&&(a[r.family]=Object.keys(i).filter(t=>t!==e&&i[t].family===r.family).sort()[0]??null),a[n]===null&&(a[n]=e),{...t,assignments:i,defaults:a}}),d(t=>({...t,[e]:n})),b(t(`claudeDesktop.moved`,{route:e,family:t(Zc[n])})))},R=e=>{let t=Jc(D,e);Xc.write(t),O(t)},z=async n=>{if(!(!o||x)){S(`save`),v(null);try{let r=await fetch(`${e}/api/claude-desktop`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profile:o})}),i=await r.json().catch(()=>({}));if(!r.ok)throw Error(el(i,t(`claudeDesktop.saveFailed`)));if(l(Qc(o)),n){S(`apply`);let n=await fetch(`${e}/api/claude-desktop/apply`,{method:`POST`}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(el(r,t(`claudeDesktop.applyFailed`)));v({tone:`ok`,text:t(`claudeDesktop.savedApplied`)}),b(t(`claudeDesktop.savedAppliedAnnounce`))}else v({tone:`ok`,text:t(`claudeDesktop.saved`)}),b(t(`claudeDesktop.savedAnnounce`))}catch(e){let n=e instanceof Error?e.message:t(`claudeDesktop.updateFailed`);v({tone:`err`,text:n}),b(n)}finally{S(null)}}},ee=()=>{if(!o)return;let e=URL.createObjectURL(new Blob([`${JSON.stringify(o,null,2)}\n`],{type:`application/json`})),n=document.createElement(`a`);n.href=e,n.download=`claude-desktop-profile.json`,n.click(),URL.revokeObjectURL(e),b(t(`claudeDesktop.exported`))},te=async e=>{let n=e.target.files?.[0];if(e.target.value=``,n)try{let e=JSON.parse(await n.text());if(e.version!==1||!e.assignments||!e.defaults)throw Error(t(`claudeDesktop.importExpected`));s($c({...i,profile:e})),v({tone:`ok`,text:t(`claudeDesktop.importReady`)}),b(t(`claudeDesktop.importedAnnounce`))}catch(e){let n=e instanceof Error?e.message:t(`claudeDesktop.importInvalid`);v({tone:`err`,text:n}),b(t(`claudeDesktop.importFailed`,{error:n}))}},B=(e,t)=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);n&&L(n,t)};return f?(0,P.jsx)(`div`,{className:`claude-desktop-loading`,role:`status`,children:t(`claudeDesktop.loading`)}):m||!i||!o?(0,P.jsxs)(`div`,{className:`claude-desktop-error`,children:[(0,P.jsx)(Xe,{tone:`err`,children:m||t(`claudeDesktop.loadFail`)}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void M(),children:t(`claudeDesktop.retry`)})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`page-head claude-desktop-head`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{children:t(`claudeDesktop.title`)}),(0,P.jsx)(`p`,{className:`page-sub`,children:t(`claudeDesktop.subtitle`,{port:i.port})})]}),(0,P.jsxs)(`div`,{className:`claude-profile-tools`,children:[(0,P.jsx)(`input`,{ref:j,type:`file`,accept:`application/json,.json`,hidden:!0,onChange:e=>void te(e)}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>j.current?.click(),children:t(`claudeDesktop.importJson`)}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:ee,children:t(`claudeDesktop.exportJson`)})]})]}),n&&(0,P.jsxs)(`div`,{className:`claude-status-bar ${n.stale?`stale`:n.applied?`applied`:`not-applied`}`,children:[(0,P.jsx)(`span`,{className:`claude-status-dot`}),(0,P.jsx)(`span`,{children:n.stale?t(`claudeDesktop.status.stale`):n.applied?t(`claudeDesktop.status.applied`):t(`claudeDesktop.status.notApplied`)}),n.health.lastRequestAt&&(0,P.jsxs)(`span`,{className:`claude-status-health`,children:[t(`claudeDesktop.health.lastRequest`),`: `,new Date(n.health.lastRequestAt).toLocaleTimeString()]}),n.health.requestCount>0&&(0,P.jsx)(`span`,{className:`claude-status-health`,children:t(`claudeDesktop.health.stats`,{count:n.health.requestCount,errors:n.health.errorCount})})]}),(0,P.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:y}),g&&(0,P.jsx)(Xe,{tone:g.tone,children:g.text}),(0,P.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,P.jsx)(`span`,{className:`claude-dirty${N?` active`:``}`,children:t(N?`claudeDesktop.unsaved`:`claudeDesktop.upToDate`)}),(0,P.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!N||x!==null,onClick:()=>void z(!1),children:t(x===`save`?`claudeDesktop.saving`:`common.save`)}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:x!==null,onClick:()=>void z(!0),children:t(x===`apply`?`claudeDesktop.applying`:x===`save`?`claudeDesktop.saving`:`claudeDesktop.saveApply`)})]})]}),i.models.length===0&&(0,P.jsx)(q,{title:t(`claudeDesktop.emptyTitle`),children:t(`claudeDesktop.emptyHint`)}),(0,P.jsx)(`div`,{className:`ocx-group-stack`,"aria-label":t(`claudeDesktop.assignmentsLabel`),children:Yc.map(e=>{let n=F[e],r=Uc(n,C[e]??``,T[e]??6),i=D.has(e),a=I[e];return(0,P.jsxs)(`section`,{className:`ocx-group${i?` collapsed`:``}`,"aria-labelledby":`claude-lane-${e}`,onDragOver:e=>e.preventDefault(),onDrop:t=>B(t,e),children:[(0,P.jsxs)(`header`,{className:`ocx-group-head${i?``:` open`}`,children:[(0,P.jsx)(`h3`,{id:`claude-lane-${e}`,className:`ocx-group-heading`,children:(0,P.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!i,"aria-controls":`claude-lane-body-${e}`,onClick:()=>R(e),children:[(0,P.jsx)(W,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:i?`none`:`rotate(90deg)`}}),(0,P.jsx)(`span`,{className:`ocx-group-name`,children:t(Zc[e])}),(0,P.jsx)(`span`,{className:`ocx-group-count`,children:t(n.length===1?`claudeDesktop.modelCountOne`:`claudeDesktop.modelCountMany`,{count:n.length})}),a&&(0,P.jsx)(`code`,{className:`claude-lane-default`,title:a,children:a})]})}),n.length>0&&o.defaults[e]===null&&(0,P.jsx)(`span`,{className:`claude-default-needed`,children:t(`claudeDesktop.chooseDefault`)}),a&&a!==o.defaults[e]&&(0,P.jsx)(`span`,{className:`claude-default-needed`,title:a,children:t(`claudeDesktop.temporaryDefault`)})]}),!i&&(0,P.jsxs)(`div`,{id:`claude-lane-body-${e}`,children:[r.showSearch&&(0,P.jsx)(`input`,{className:`input claude-lane-search`,type:`search`,placeholder:t(`models.search`),"aria-label":t(`models.search`),value:C[e]??``,onChange:t=>{let n=t.target.value;w(t=>({...t,[e]:n})),E(t=>({...t,[e]:6}))}}),(0,P.jsxs)(`div`,{className:`claude-lane-models`,children:[n.length===0?(0,P.jsx)(`div`,{className:`claude-lane-empty`,children:t(`claudeDesktop.laneEmpty`)}):r.noMatch?(0,P.jsx)(`div`,{className:`claude-lane-empty`,children:t(`claudeDesktop.laneNoMatch`)}):r.shown.map(n=>{let r=o.assignments[n.route],i=tl(n.contextWindow,t),a=u[n.route]??`opus`,c=k[n.route]??Gc(n.route,I[e]);return(0,P.jsxs)(`article`,{className:`claude-model-card${c?` open`:``}`,draggable:n.available,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,n.route)},children:[(0,P.jsxs)(`button`,{type:`button`,className:`claude-model-summary`,"aria-expanded":c,"aria-controls":`claude-model-body-${n.route}`,onClick:()=>A(e=>({...e,[n.route]:!c})),children:[(0,P.jsx)(W,{className:`ocx-chevron`,width:12,height:12,"aria-hidden":`true`,style:{transform:c?`rotate(90deg)`:`none`}}),(0,P.jsxs)(`span`,{className:`claude-model-names`,children:[(0,P.jsx)(`strong`,{title:n.label,children:n.label}),(0,P.jsx)(`code`,{title:n.route,children:n.route})]}),i&&(0,P.jsx)(`span`,{className:`claude-model-context`,children:i}),!i&&(0,P.jsx)(`span`,{className:`claude-model-context claude-model-context-unknown`,children:t(`claudeDesktop.contextUnknown`)}),n.supports1m===!0&&(0,P.jsx)(`span`,{className:`claude-1m-chip`,children:t(`claudeDesktop.supports1m`)}),n.effortSupported===!1&&(0,P.jsx)(`span`,{className:`claude-effort-badge off`,children:t(`claudeDesktop.effort.displayOnly`)}),n.effortSupported===!0&&(0,P.jsx)(`span`,{className:`claude-effort-badge on`,children:t(`claudeDesktop.effort.supported`)}),o.defaults[e]===n.route&&(0,P.jsx)(`span`,{className:`claude-row-default`,children:t(`claudeDesktop.defaultBadge`)}),(0,P.jsx)(`span`,{className:`badge ${n.available?`badge-green`:`badge-muted`}`,children:n.available?t(`claudeDesktop.available`):t(`claudeDesktop.unavailable`)})]}),c&&(0,P.jsxs)(`div`,{className:`claude-model-body`,id:`claude-model-body-${n.route}`,children:[I[e]===n.route&&o.defaults[e]!==n.route&&(0,P.jsx)(`span`,{className:`claude-effective-default`,children:t(`claudeDesktop.temporaryDefault`)}),(0,P.jsxs)(`div`,{className:`claude-field`,children:[(0,P.jsx)(`span`,{children:t(`claudeDesktop.alias`)}),(0,P.jsx)(`code`,{className:`claude-alias`,title:r.alias,children:r.alias})]}),(0,P.jsxs)(`label`,{className:`claude-default-radio`,children:[(0,P.jsx)(`input`,{type:`radio`,name:`default-${e}`,checked:o.defaults[e]===n.route,disabled:!n.available,onChange:()=>s(t=>t&&{...t,defaults:{...t.defaults,[e]:n.route}})}),t(`claudeDesktop.useAsDefault`,{family:t(Zc[e])})]}),(0,P.jsxs)(`div`,{className:`claude-move-row`,children:[(0,P.jsx)(`label`,{htmlFor:`move-${n.route}`,children:t(`claudeDesktop.moveTo`)}),(0,P.jsx)(`select`,{id:`move-${n.route}`,className:`input`,value:a,disabled:!n.available,onChange:e=>d(t=>({...t,[n.route]:e.target.value})),children:Yc.map(e=>(0,P.jsx)(`option`,{value:e,children:t(Zc[e])},e))}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:!n.available||a===e,onClick:()=>L(n.route,a),children:t(`claudeDesktop.move`)})]})]})]},n.route)}),r.hidden>0&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm claude-lane-more`,onClick:()=>E(t=>({...t,[e]:(t[e]??6)+6})),children:t(`models.showMore`,{n:r.hidden})})]})]})]},e)})})]})}function rl({apiBase:e}){let[t,n]=(0,_.useState)(`code`),r=K(),i=(0,_.useRef)(null),a=(0,_.useRef)(null),o=e=>{n(e),window.requestAnimationFrame(()=>(e===`code`?i:a).current?.focus())},s=e=>{e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),o(t===`code`?`desktop`:`code`)):e.key===`Home`?(e.preventDefault(),o(`code`)):e.key===`End`&&(e.preventDefault(),o(`desktop`))};return(0,P.jsxs)(`section`,{className:`claude-page`,children:[(0,P.jsxs)(`div`,{className:`claude-tabs`,role:`tablist`,"aria-label":r(`claude.tabsLabel`),children:[(0,P.jsx)(`button`,{type:`button`,role:`tab`,ref:i,"aria-selected":t===`code`,"aria-controls":`claude-code-panel`,id:`claude-code-tab`,className:t===`code`?`active`:``,tabIndex:t===`code`?0:-1,onKeyDown:s,onClick:()=>o(`code`),children:r(`claude.tabCode`)}),(0,P.jsx)(`button`,{type:`button`,role:`tab`,ref:a,"aria-selected":t===`desktop`,"aria-controls":`claude-desktop-panel`,id:`claude-desktop-tab`,className:t===`desktop`?`active`:``,tabIndex:t===`desktop`?0:-1,onKeyDown:s,onClick:()=>o(`desktop`),children:r(`claude.tabDesktop`)})]}),(0,P.jsx)(`div`,{id:`claude-code-panel`,role:`tabpanel`,"aria-labelledby":`claude-code-tab`,hidden:t!==`code`,children:t===`code`&&(0,P.jsx)(Hc,{apiBase:e})}),(0,P.jsx)(`div`,{id:`claude-desktop-panel`,role:`tabpanel`,"aria-labelledby":`claude-desktop-tab`,hidden:t!==`desktop`,children:t===`desktop`&&(0,P.jsx)(nl,{apiBase:e})})]})}function il(e,t,n,r){let i=e.filter(e=>r===`native`===e.native).map(e=>({...e,alias:t.get(e.id)??null,enabled:!n.has(e.id)})).toSorted((e,t)=>Number(!e.enabled)-Number(!t.enabled));return{rows:i,total:i.length,enabled:i.filter(e=>e.enabled).length}}var al=qc(`ocx.grok.collapsedGroups.v1`),ol=[{id:`native`,tkey:`grok.groupNative`},{id:`routed`,tkey:`grok.groupRouted`}];function sl(e,t){return e?e>=1048576?t(`claudeDesktop.contextM`,{n:Math.round(e/1048576)}):e>=1e6?t(`claudeDesktop.contextM`,{n:e/1e6}):t(`claudeDesktop.contextK`,{n:Math.round(e/1e3)}):`—`}function cl({apiBase:e}){let t=K(),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(new Set),[u,d]=(0,_.useState)(new Set),[f,p]=(0,_.useState)(()=>al.read()??new Set),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(``),x=(0,_.useCallback)(async()=>{a(!0),s(``);try{let n=await fetch(`${e}/api/grok`),i=await n.json();if(!n.ok)throw Error(i.error||t(`grok.loadFail`));r({...i,candidates:i.candidates??[],excluded:i.excluded??[]});let a=new Set(i.excluded??[]);l(a),d(a)}catch(e){s(e instanceof Error?e.message:t(`grok.loadFail`))}finally{a(!1)}},[e,t]);(0,_.useEffect)(()=>{let e=window.setTimeout(()=>{x()},0);return()=>window.clearTimeout(e)},[x]);let S=(0,_.useMemo)(()=>c.size!==u.size||[...c].some(e=>!u.has(e)),[c,u]),C=(0,_.useMemo)(()=>new Map((n?.models??[]).map(e=>[e.id,e.alias])),[n]),w=e=>{let t=Jc(f,e);al.write(t),p(t)},T=(e,t)=>{l(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})},E=async n=>{if(!m){h(`save`),v(null);try{let r=await fetch(`${e}/api/grok/selection`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({excluded:[...c]})}),i=await r.json().catch(()=>({}));if(!r.ok)throw Error(i.error??t(`grok.saveFailed`));if(d(new Set(c)),n){h(`apply`);let n=await fetch(`${e}/api/grok/apply`,{method:`POST`}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.message??t(`grok.applyFailed`));r.skippedReason?(v({tone:`err`,text:r.message??t(`grok.applySkipped`)}),b(r.message??t(`grok.applySkipped`))):(v({tone:`ok`,text:t(`grok.savedApplied`)}),b(t(`grok.savedApplied`))),await x()}else v({tone:`ok`,text:t(`grok.saved`)}),b(t(`grok.saved`))}catch(e){let n=e instanceof Error?e.message:t(`grok.saveFailed`);v({tone:`err`,text:n}),b(n)}finally{h(null)}}};return i?(0,P.jsx)(`section`,{className:`grok-page`,children:(0,P.jsx)(`p`,{className:`page-sub`,children:t(`grok.loading`)})}):o?(0,P.jsxs)(`section`,{className:`grok-page`,children:[(0,P.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:o}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void x(),children:t(`common.retry`)})]}):(0,P.jsxs)(`section`,{className:`grok-page`,children:[(0,P.jsx)(`h2`,{className:`page-title`,children:t(`grok.title`)}),(0,P.jsx)(`p`,{className:`page-sub`,children:t(`grok.subtitle`)}),(0,P.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:y}),g&&(0,P.jsx)(Xe,{tone:g.tone,children:g.text}),n&&n.candidates.length>0&&(0,P.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,P.jsx)(`span`,{className:`claude-dirty${S?` active`:``}`,children:t(S?`grok.unsaved`:`grok.upToDate`)}),(0,P.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!S||m!==null,onClick:()=>void E(!1),children:t(m===`save`?`grok.saving`:`common.save`)}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!S||m!==null,onClick:()=>void E(!0),children:t(m===`apply`?`grok.applying`:m===`save`?`grok.saving`:`grok.saveApply`)})]})]}),n?.present?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`grok-endpoint`,children:[(0,P.jsx)(`span`,{children:t(`grok.endpoint`)}),(0,P.jsx)(`code`,{children:n.baseUrl??`—`})]}),(0,P.jsx)(`p`,{className:`page-sub`,children:(0,P.jsx)(`code`,{children:n.configPath})})]}):(0,P.jsxs)(q,{title:t(`grok.notConfiguredTitle`),children:[t(`grok.notConfiguredHint`),(0,P.jsx)(`br`,{}),(0,P.jsx)(`code`,{children:n?.configPath})]}),n&&n.candidates.length>0&&(0,P.jsx)(`div`,{className:`ocx-group-stack`,children:ol.map(e=>{let r=il(n.candidates,C,c,e.id);if(r.total===0)return null;let i=f.has(e.id);return(0,P.jsxs)(`section`,{className:`ocx-group${i?` collapsed`:``}`,"aria-labelledby":`grok-group-${e.id}`,children:[(0,P.jsx)(`header`,{className:`ocx-group-head${i?``:` open`}`,children:(0,P.jsx)(`h3`,{id:`grok-group-${e.id}`,className:`ocx-group-heading`,children:(0,P.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!i,"aria-controls":`grok-group-body-${e.id}`,onClick:()=>w(e.id),children:[(0,P.jsx)(W,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:i?`none`:`rotate(90deg)`}}),(0,P.jsx)(`span`,{className:`ocx-group-name`,children:t(e.tkey)}),(0,P.jsx)(`span`,{className:`ocx-group-count`,children:t(`grok.enabledCount`,{on:r.enabled,total:r.total})})]})})}),!i&&(0,P.jsx)(`div`,{id:`grok-group-body-${e.id}`,className:`grok-model-list`,children:r.rows.map(e=>(0,P.jsxs)(`div`,{className:`grok-model-row`,children:[(0,P.jsx)(Ye,{on:e.enabled,onClick:()=>T(e.id,!e.enabled),disabled:m!==null,label:t(`grok.toggleModel`,{id:e.id})}),(0,P.jsxs)(`span`,{className:`grok-model-names`,children:[(0,P.jsx)(`strong`,{title:e.id,children:e.id}),(0,P.jsx)(`code`,{title:e.alias??void 0,children:e.alias??`—`})]}),(0,P.jsx)(`span`,{className:`claude-model-context`,children:sl(e.contextWindow,t)})]},e.id))})]},e.id)})})]})}function ll(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.supported==`boolean`&&typeof t.installed==`boolean`&&typeof t.running==`boolean`&&typeof t.stale==`boolean`&&typeof t.summary==`string`}var ul={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},dl={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},fl={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function pl({ok:e,yes:t,no:n}){return(0,P.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function ml({failed:e,data:t}){let{t:n}=G(),r=e?`startup-hero--risk`:t.status===`protected`?`startup-hero--safe`:t.status===`at-risk`?`startup-hero--risk`:`startup-hero--native`,i=e||t.status===`at-risk`?U:ne,a=t.routingKind===`opencodex-local`?`startup.routing.proxy`:t.routingKind===`custom-local`?`startup.routing.customLocal`:t.routingKind===`custom-remote`?`startup.routing.customRemote`:t.routingKind===`unknown`?`startup.routing.unknown`:`startup.routing.native`;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`section`,{className:`panel startup-hero ${r}`,"aria-live":`polite`,children:[(0,P.jsx)(`div`,{className:`startup-hero-icon`,children:(0,P.jsx)(i,{})}),(0,P.jsxs)(`div`,{className:`startup-hero-copy`,children:[(0,P.jsx)(`span`,{className:`badge ${e||t.status===`at-risk`?`badge-amber`:`badge-green`}`,children:n(e?`startup.status.atRisk`:ul[t.status])}),(0,P.jsx)(`h3`,{children:n(e?`startup.error`:dl[t.status])}),(0,P.jsx)(`p`,{children:e?n(`startup.staleData`):t.status===`at-risk`?n(zt(t)):n(`startup.safeDetail`)})]})]}),(0,P.jsxs)(`div`,{className:`startup-state-grid`,children:[(0,P.jsxs)(`section`,{className:`stat`,children:[(0,P.jsx)(`div`,{className:`label`,children:n(`startup.routing`)}),(0,P.jsx)(`div`,{className:`value`,children:n(a)})]}),(0,P.jsxs)(`section`,{className:`stat`,children:[(0,P.jsx)(`div`,{className:`label`,children:n(`startup.restartProtection`)}),(0,P.jsx)(`div`,{className:`value`,children:n(fl[t.protection])})]}),(0,P.jsxs)(`section`,{className:`stat`,children:[(0,P.jsx)(`div`,{className:`label`,children:n(`startup.preference`)}),(0,P.jsx)(`div`,{className:`value`,children:n(t.autostartEnabled?`startup.enabled`:`startup.disabled`)})]})]})]})}function hl({data:e,failed:t,installBusy:n,installResult:r,onInstall:i}){let{t:a}=G();return(0,P.jsxs)(`section`,{className:`panel startup-details`,children:[(0,P.jsxs)(`div`,{className:`panel-head`,children:[(0,P.jsx)(`h3`,{className:`panel-title`,children:a(`startup.details`)}),(0,P.jsx)(`span`,{className:`muted mono`,children:e.platform})]}),(0,P.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:a(`startup.service`)}),(0,P.jsx)(`span`,{children:a(`startup.serviceHint`)})]}),(0,P.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,P.jsx)(pl,{ok:e.serviceViable,yes:a(`startup.viable`),no:a(e.serviceConflict?`startup.conflict`:e.serviceStale?`startup.stale`:e.serviceInstalled?`startup.unhealthy`:e.serviceSupported?`startup.notInstalled`:`startup.unsupported`)}),e.serviceSupported&&!e.serviceInstalled&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${a(`startup.service`)} - ${a(`startup.install`)}`,disabled:n!==null||t,onClick:()=>i(`install-service`),children:a(n===`install-service`?`startup.installing`:`startup.install`)})]})]}),(0,P.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:a(`startup.shim`)}),(0,P.jsx)(`span`,{children:a(`startup.shimHint`)})]}),(0,P.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,P.jsx)(pl,{ok:e.shimHealthy&&e.autostartEnabled,yes:a(e.shimCoverage===`cli-only`?`startup.cliOnly`:`startup.healthy`),no:a(e.shimInstalled?e.shimHealthy&&!e.autostartEnabled?`startup.installedDisabled`:`startup.stale`:`startup.notInstalled`)}),!e.shimInstalled&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${a(`startup.shim`)} - ${a(`startup.install`)}`,disabled:n!==null||t,onClick:()=>i(`install-shim`),children:a(n===`install-shim`?`startup.installing`:`startup.install`)})]})]}),r&&(0,P.jsx)(`div`,{className:`notice ${r.kind===`success`?`notice-ok`:`notice-warn`} startup-action-notice`,role:`status`,"aria-live":`polite`,children:r.kind===`success`?a(r.action===`install-service`?`startup.serviceInstalled`:`startup.shimInstalled`):`${a(`startup.installFailed`)} ${r.detail??``}`})]})}function gl({tray:e,trayLoading:t,trayError:n,trayBusy:r,onTrayAction:i}){let{t:a}=G();return(0,P.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,P.jsxs)(`div`,{className:`panel-head`,children:[(0,P.jsx)(`h3`,{className:`panel-title`,children:a(`startup.tray.title`)}),(0,P.jsx)(fe,{})]}),(0,P.jsx)(`p`,{className:`muted`,children:a(`startup.tray.hint`)}),(0,P.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:a(`startup.tray.login`)}),(0,P.jsx)(`span`,{children:a(`startup.tray.notProtection`)})]}),t||n||!e?(0,P.jsx)(`span`,{className:`badge badge-amber`,children:a(t?`startup.tray.loading`:`startup.tray.unavailable`)}):(0,P.jsx)(pl,{ok:e.running&&!e.stale,yes:a(`startup.tray.running`),no:a(e.stale?`startup.tray.stale`:e.installed?`startup.tray.stopped`:`startup.tray.notInstalled`)})]}),(0,P.jsxs)(`div`,{className:`startup-tray-buttons`,children:[!t&&!n&&e&&!e.installed&&!e.stale&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`install`),children:a(`startup.tray.install`)}),!t&&!n&&e?.installed&&!e.stale&&!e.running&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`start`),children:a(`startup.tray.start`)}),!t&&!n&&e?.running&&!e.stale&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:r,onClick:()=>i(`stop`),children:a(`startup.tray.stop`)}),!t&&!n&&e&&(e.installed||e.stale)&&(0,P.jsx)(`button`,{type:`button`,className:`btn btn-danger`,disabled:r,onClick:()=>{window.confirm(a(`startup.tray.uninstall`))&&i(`uninstall`)},children:a(`startup.tray.uninstall`)})]}),(n||e?.stale)&&(0,P.jsx)(`div`,{className:`notice notice-warn`,role:`alert`,children:a(`startup.tray.error`)})]})}function _l({data:e,copied:t,onCopy:n}){let{t:r}=G();return(0,P.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,P.jsxs)(`div`,{className:`panel-head`,children:[(0,P.jsx)(`h3`,{className:`panel-title`,children:r(`startup.recovery`)}),(0,P.jsx)(B,{})]}),(0,P.jsx)(`p`,{className:`muted`,children:r(`startup.recoveryHint`)}),(0,P.jsxs)(`div`,{className:`startup-command-list`,children:[e.serviceSupported&&(0,P.jsxs)(`div`,{className:`startup-command-row`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:r(`startup.command.service`)}),(0,P.jsx)(`code`,{children:e.commands.installService})]}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.installService),children:t===e.commands.installService?r(`startup.copied`):r(`startup.copy`)})]}),(0,P.jsxs)(`div`,{className:`startup-command-row`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:r(`startup.command.shim`)}),(0,P.jsx)(`code`,{children:e.commands.installShim})]}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.installShim),children:t===e.commands.installShim?r(`startup.copied`):r(`startup.copy`)})]}),(0,P.jsxs)(`div`,{className:`startup-command-row`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:r(`startup.command.native`)}),(0,P.jsx)(`code`,{children:e.commands.restoreNative})]}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.restoreNative),children:t===e.commands.restoreNative?r(`startup.copied`):r(`startup.copy`)})]})]}),e.status===`at-risk`&&(0,P.jsxs)(`div`,{className:`notice notice-warn startup-action-notice`,role:`alert`,children:[(0,P.jsx)(fe,{}),` `,r(`startup.recommended`,{cmd:e.recommendedCommand??e.commands.installService})]})]})}function vl({apiBase:e}){let{t}=G(),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!0),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(null),D=(0,_.useRef)(0),O=(0,_.useCallback)(async n=>{let i=++D.current;a(!0),p(!0);try{let a=await fetch(`${e}/api/startup-health`,{signal:n});if(!a.ok)throw Error(`fetch failed`);let o=await a.json();if(n?.aborted||i!==D.current)return;r(o),s(o.diagnosticStale);try{let r=await fetch(`${e}/api/settings`,{signal:n});if(r.ok){let e=await r.json();if(!n?.aborted&&i===D.current){let n=e.codexRuntime,r=!!n?.catalogClamp?.active,i=!!n?.newerAvailable,a=(r?n?.catalogClamp?.runtimeVersion:n?.version)??n?.version??`unknown`,o=(n?.catalogClamp?.removedEfforts??[]).join(`, `);w(r?o?t(`startup.codexRuntime.clampHiddenWithEfforts`,{version:a,efforts:o}):t(`startup.codexRuntime.clampHidden`,{version:a}):i?t(`startup.codexRuntime.olderBinary`,{version:a}):null),E(i?`ocx doctor --fix-codex-runtime && ocx sync`:r?`ocx sync`:null)}}else!n?.aborted&&i===D.current&&(w(null),E(null))}catch{!n?.aborted&&i===D.current&&(w(null),E(null))}if(o.platform===`win32`){v(!1);try{let t=await fetch(`${e}/api/windows-tray`,{signal:n});if(!t.ok)throw Error(`tray status failed`);let r=await t.json();if(!ll(r))throw Error(`invalid tray status`);!n?.aborted&&i===D.current&&(d(r),v(!1))}catch{!n?.aborted&&i===D.current&&(d(null),v(!0))}}}catch{if(n?.aborted||i!==D.current)return;s(!0),d(null),v(!0)}finally{i===D.current&&(p(!1),a(!1))}},[e,t]);(0,_.useEffect)(()=>{let e=new AbortController,t=window.setTimeout(()=>{O(e.signal)},0);return()=>{window.clearTimeout(t),D.current+=1,e.abort()}},[O]),(0,_.useEffect)(()=>{if(!n?.diagnosticStale)return;let e=window.setTimeout(()=>{O()},2e3);return()=>window.clearTimeout(e)},[n,O]);let k=async e=>{try{await navigator.clipboard.writeText(e),l(e),window.setTimeout(()=>l(t=>t===e?null:t),1600)}catch{l(null)}},A=async t=>{h(!0),v(!1);try{let n=await fetch(`${e}/api/windows-tray`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t})});if(!n.ok)throw Error(`tray action failed`);let r=await n.json();if(!ll(r.status))throw Error(`invalid tray action status`);d(r.status),v(!1)}catch{d(null),v(!0)}finally{h(!1)}},j=async t=>{b(t),S(null);try{let n=await fetch(`${e}/api/startup-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(typeof e?.error==`string`?e.error:`installation failed`)}S({kind:`success`,action:t}),await O()}catch(e){S({kind:`error`,action:t,detail:e instanceof Error?e.message:String(e)})}finally{b(null)}};return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`page-head`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{children:t(`startup.title`)}),(0,P.jsx)(`p`,{className:`page-sub startup-page-sub`,children:t(`startup.subtitle`)})]}),(0,P.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void O(),disabled:i,children:[(0,P.jsx)(ae,{}),` `,t(`startup.refresh`)]})]}),i&&!n?(0,P.jsx)(q,{title:t(`startup.loading`)}):o&&!n?(0,P.jsx)(q,{title:t(`startup.error`)}):n?(0,P.jsxs)(P.Fragment,{children:[o&&(0,P.jsx)(`div`,{className:`notice notice-warn`,role:`alert`,children:t(`startup.staleData`)}),C&&(0,P.jsxs)(`div`,{className:`notice notice-warn`,role:`status`,children:[(0,P.jsx)(`p`,{children:C}),T&&(0,P.jsxs)(`p`,{children:[(0,P.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void k(T),children:t(c===T?`startup.copied`:`startup.copy`)}),(0,P.jsx)(`code`,{style:{marginLeft:`0.5rem`},children:T})]})]}),(0,P.jsx)(ml,{failed:o,data:n}),(0,P.jsx)(hl,{data:n,failed:o,installBusy:y,installResult:x,onInstall:e=>{j(e)}}),n.platform===`win32`&&(0,P.jsx)(gl,{tray:u,trayLoading:f,trayError:g,trayBusy:m,onTrayAction:e=>{A(e)}}),(0,P.jsx)(_l,{data:n,copied:c,onCopy:e=>{k(e)}})]}):null]})}var yl=class extends _.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}reload=()=>{this.setState({error:null})};render(){return this.state.error?(0,P.jsxs)(`section`,{className:`card`,role:`alert`,style:{maxWidth:720,padding:`var(--space-6)`},children:[(0,P.jsxs)(`h2`,{style:{margin:`0 0 var(--space-2)`,fontSize:`var(--text-title)`},children:[this.props.pageName,`: `,this.props.title]}),(0,P.jsx)(`p`,{className:`muted`,style:{margin:`0 0 var(--space-4)`},children:this.props.message}),(0,P.jsxs)(`p`,{style:{margin:`0 0 var(--space-5)`,overflowWrap:`anywhere`},children:[(0,P.jsxs)(`strong`,{children:[this.props.detailsLabel,`:`]}),` `,this.state.error.message]}),(0,P.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:this.reload,children:this.props.reloadLabel})]}):this.props.children}},bl=!1,xl=null;function Sl(e){try{let t=e instanceof Request?e.url:String(e),n=new URL(t,window.location.href);return n.origin===window.location.origin?n.pathname.startsWith(`/api/`)||n.pathname.startsWith(`/v1/`):!1}catch{return!1}}var Cl=`opencodex-api-token`,wl=null;function Tl(){return wl}function El(e){wl=e}function Dl(){wl=null}function Ol(){try{sessionStorage.removeItem(Cl)}catch{}}function kl(e,t,n){let r=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));return r.set(`X-OpenCodex-API-Key`,n),e instanceof Request?[new Request(e,{headers:r}),t?{...t,headers:r}:void 0]:[e,{...t,headers:r}]}async function Al(){return xl||(xl=Promise.resolve().then(()=>window.prompt(`OpenCodex API token`)?.trim()||null).finally(()=>{xl=null}),xl)}function jl(){if(bl)return;bl=!0,Ol();let e=window.fetch.bind(window);window.fetch=async(t,n)=>{if(!Sl(t))return e(t,n);let r=Tl(),[i,a]=r?kl(t,n,r):[t,n],o=await e(i,a);if(o.status!==401)return o;r&&Dl();let s=await Al();if(!s)return o;El(s);let[c,l]=kl(t,n,s),u=await e(c,l);return u.status===401&&Dl(),u}}var Ml=new Set([`dashboard`,`startup`,`providers`,`models`,`combos`,`subagents`,`logs`,`usage`,`storage`,`codex-auth`,`api`,`claude`,`grok`]);function Nl(e){let t=Ie(e??(typeof window<`u`?window.location.hash:``)).split(`/`)[0];return t===`debug`?`logs`:Ml.has(t)?t:`dashboard`}var Pl=[`dashboard/providers`,`dashboard/models`];function X(e,t){return e===t||t===`logs`&&e===`logs/debug`||t===`dashboard`&&Pl.includes(e)}function Fl(e){let t=Nl(e);return e===`debug`||e.startsWith(`debug/`)?{page:`logs`,replaceTo:`logs/debug`}:e===`providers/workspace`?{page:`providers`,replaceTo:`providers`}:X(e,t)?{page:t,replaceTo:null}:{page:t,replaceTo:t}}var Z=[`ocx-global-view`,`ocx-view`,`ocx-providers-view`,`ocx-subagents-view`,`ocx-storage-view`,`ocx-codexauth-view`,`ocx-apikeys-view`,`ocx-claudecode-view`,`ocx-usage-view`,`ocx-logs-view`,`ocx-models-view`,`ocx-dashboard-view`];function Q(){try{for(let e of Z)localStorage.removeItem(e)}catch{}}function Il(){let[e,t]=(0,_.useState)(Nl);(0,_.useEffect)(()=>{Q()},[]);let n=(0,_.useCallback)(e=>{let n=Fl(e);n.replaceTo&&Le(n.replaceTo),t(n.page)},[]);return(0,_.useEffect)(()=>{let e=()=>{n(Ie(window.location.hash))};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[n]),(0,_.useEffect)(()=>{let t=Ie(window.location.hash);if(t===`debug`||t.startsWith(`debug/`)){Le(`logs/debug`);return}if(t===`providers/workspace`){Le(`providers`);return}X(t,e)||Le(e)},[e]),{page:e,setPageState:t,navigateToPage:e=>{Re(e),t(e)}}}jl();var Ll={dashboard:`nav.dashboard`,startup:`nav.startup`,providers:`nav.providers`,models:`nav.models`,combos:`nav.combos`,subagents:`nav.subagents`,logs:`nav.logs`,usage:`nav.usage`,storage:`nav.storage`,"codex-auth":`nav.codexAuth`,api:`nav.api`,claude:`nav.claude`,grok:`nav.grok`},Rl=``,zl=`ocx-theme`,Bl=[{id:`dashboard`,tkey:`nav.dashboard`,Icon:I},{id:`codex-auth`,tkey:`nav.codexAuth`,Icon:me},{id:`providers`,tkey:`nav.providers`,Icon:L},{id:`models`,tkey:`nav.models`,Icon:R},{id:`subagents`,tkey:`nav.subagents`,Icon:z},{id:`logs`,tkey:`nav.logs`,Icon:ee},{id:`usage`,tkey:`nav.usage`,Icon:V},{id:`storage`,tkey:`nav.storage`,Icon:H},{id:`api`,tkey:`nav.api`,Icon:xe},{id:`claude`,tkey:`nav.claude`,Icon:Se},{id:`grok`,tkey:`nav.grok`,Icon:R}],Vl={light:ve,dark:ye,system:be},Hl={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function Ul(e){if(!e||typeof e!=`object`||!(`version`in e))return null;let t=e.version;return typeof t==`string`&&t.length>0?t:null}function Wl(){let e=localStorage.getItem(zl);return e===`light`||e===`dark`?e:`system`}function Gl(){let{page:e,navigateToPage:t}=Il(),[n,r]=(0,_.useState)(Wl),{locale:i,setLocale:a}=G(),o=K(),[s,c]=(0,_.useState)(!1),l=(0,_.useRef)(null),u=(0,_.useRef)(null),d=(0,_.useRef)(!1);(0,_.useEffect)(()=>{let e=()=>c(!1);return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]),(0,_.useEffect)(()=>{let e=document.documentElement;n===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(zl)):(e.setAttribute(`data-theme`,n),localStorage.setItem(zl,n))},[n]);let f=j(`app-healthz:${Rl}`,[],async e=>{let t=await fetch(`${Rl}/healthz`,{signal:e});return t.ok?Ul(await t.json()):null},{pollMs:3e4}),p=()=>r(e=>e===`light`?`dark`:e===`dark`?`system`:`light`),m=Vl[n],h=f.data??`2.7.41`,[g,v]=(0,_.useState)(!1),y=(0,_.useCallback)(async e=>{let t=await tt(await fetch(`${Rl}/api/claude-code`,{signal:e}));return t&&typeof t.enabled==`boolean`?t.enabled:null},[]),b=j(`app-claude-code:${Rl}`,[],y).data??null,x=(0,_.useRef)(!1),[S,C]=(0,_.useState)(!1);(0,_.useEffect)(()=>{if(!s)return;let e=e=>{e.key===`Escape`&&c(!1)};window.addEventListener(`keydown`,e);let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{window.removeEventListener(`keydown`,e),document.body.style.overflow=t}},[s]),(0,_.useEffect)(()=>{if(s){d.current=!0;let e=setTimeout(()=>u.current?.focus(),200);return()=>clearTimeout(e)}d.current&&(d.current=!1,l.current?.focus())},[s]),(0,_.useEffect)(()=>{let e=window.matchMedia(`(min-width: 761px)`),t=()=>{e.matches&&c(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let w=async()=>{if(b===null||x.current)return;x.current=!0,C(!0);let e=!b;M(`app-claude-code:${Rl}`,e);try{(await fetch(`${Rl}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})})).ok||M(`app-claude-code:${Rl}`,!e)}catch{M(`app-claude-code:${Rl}`,!e)}finally{x.current=!1,C(!1)}},T=async()=>{if(confirm(o(`dash.stopConfirm`))){v(!0);try{let e=await fetch(`${Rl}/api/stop`,{method:`POST`});if(!e.ok){v(!1);let t=await e.json().catch(()=>null);t?.message&&alert(t.message)}}catch{}}},E=(0,P.jsxs)(`div`,{className:`brand`,children:[(0,P.jsx)(`span`,{className:`brand-logo`,role:`img`,"aria-label":o(`app.logoAria`)}),(0,P.jsx)(`span`,{className:`name`,children:`opencodex`}),(0,P.jsxs)(`span`,{className:`ver`,children:[`v`,h]})]});return(0,P.jsxs)(`div`,{className:`app`,children:[(0,P.jsxs)(`header`,{className:`mobile-topbar`,inert:s,children:[(0,P.jsx)(`button`,{ref:l,type:`button`,className:`menu-toggle`,onClick:()=>c(e=>!e),"aria-expanded":s,"aria-controls":`app-sidebar`,"aria-label":o(s?`nav.closeMenu`:`nav.openMenu`),title:o(s?`nav.closeMenu`:`nav.openMenu`),children:(0,P.jsx)(te,{})}),E,(0,P.jsx)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:T,disabled:g,"aria-label":o(`dash.stop`),title:o(`dash.stop`),children:(0,P.jsx)(fe,{})})]}),s&&(0,P.jsx)(`div`,{className:`drawer-scrim`,onClick:()=>c(!1),"aria-hidden":`true`}),(0,P.jsxs)(`aside`,{id:`app-sidebar`,className:`sidebar${s?` open`:``}`,ref:u,tabIndex:-1,children:[(0,P.jsxs)(`div`,{className:`drawer-head`,children:[E,(0,P.jsx)(`button`,{type:`button`,className:`menu-toggle drawer-close`,onClick:()=>c(!1),"aria-label":o(`nav.closeMenu`),title:o(`nav.closeMenu`),children:(0,P.jsx)(re,{})})]}),(0,P.jsx)(`nav`,{children:Bl.map(({id:n,tkey:r,Icon:i})=>(0,P.jsxs)(`div`,{className:`nav-entry${n===`claude`?` nav-entry-claude${e===n?` active`:``}`:``}`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`nav-item${e===n?` active`:``}`,"data-page":n,onClick:()=>{t(n),c(!1)},"aria-current":e===n?`page`:void 0,children:[(0,P.jsx)(i,{}),` `,o(r)]}),n===`claude`&&b!==null&&(0,P.jsx)(Ye,{on:b,onClick:()=>void w(),disabled:S,label:o(`claude.toggleAria`)})]},n))}),(0,P.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,P.jsxs)(`div`,{className:`lang-toggle`,children:[(0,P.jsx)(xe,{"aria-hidden":!0}),(0,P.jsx)(Ze,{value:i,options:ke.map(e=>({value:e.code,label:e.name})),onChange:e=>a(e),label:o(`lang.label`),placement:`right`,portal:!1,style:{flex:1,minWidth:0,width:`100%`}})]}),(0,P.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:p,"aria-label":`${o(`theme.label`)}: ${o(Hl[n])}`,title:`${o(`theme.label`)}: ${o(Hl[n])}`,children:[(0,P.jsx)(m,{}),` `,(0,P.jsx)(`span`,{className:`mode`,children:o(Hl[n])})]}),(0,P.jsxs)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:T,disabled:g,"aria-label":o(`dash.stop`),title:o(`dash.stop`),children:[(0,P.jsx)(fe,{}),` `,(0,P.jsx)(`span`,{className:`mode`,children:o(g?`dash.stopping`:`dash.stop`)})]}),(0,P.jsxs)(`a`,{className:`sidebar-link`,href:`https://github.com/lidge-jun/opencodex`,target:`_blank`,rel:`noreferrer`,children:[(0,P.jsx)(de,{}),` `,o(`common.github`)]})]})]}),(0,P.jsx)(`main`,{className:`main`,inert:s,children:(0,P.jsx)(`div`,{className:`main-inner${e===`combos`?` main-inner--combos`:``}`,children:(0,P.jsxs)(yl,{pageName:o(Ll[e]),title:o(`errorBoundary.title`),message:o(`errorBoundary.message`),detailsLabel:o(`errorBoundary.details`),reloadLabel:o(`errorBoundary.reload`),children:[e===`dashboard`&&(0,P.jsx)(Qt,{apiBase:Rl}),e===`startup`&&(0,P.jsx)(vl,{apiBase:Rl}),e===`providers`&&(0,P.jsx)(ha,{apiBase:Rl}),e===`models`&&(0,P.jsx)(mo,{apiBase:Rl}),e===`combos`&&(0,P.jsx)(Ao,{apiBase:Rl}),e===`subagents`&&(0,P.jsx)(jo,{apiBase:Rl}),e===`logs`&&(0,P.jsx)(Ls,{apiBase:Rl}),e===`usage`&&(0,P.jsx)($s,{apiBase:Rl}),e===`storage`&&(0,P.jsx)(oc,{apiBase:Rl}),e===`codex-auth`&&(0,P.jsx)(uc,{apiBase:Rl}),e===`api`&&(0,P.jsx)(Sc,{apiBase:Rl}),e===`claude`&&(0,P.jsx)(rl,{apiBase:Rl}),e===`grok`&&(0,P.jsx)(cl,{apiBase:Rl})]},e)})})]})}g.createRoot(document.getElementById(`root`)).render((0,P.jsx)(_.StrictMode,{children:(0,P.jsx)(Pe,{children:(0,P.jsx)(Gl,{})})}));
|
package/gui/dist/index.html
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
} catch (e) {}
|
|
17
17
|
})();
|
|
18
18
|
</script>
|
|
19
|
-
<script type="module" crossorigin src="/assets/index-
|
|
19
|
+
<script type="module" crossorigin src="/assets/index-BmvM6wRb.js"></script>
|
|
20
20
|
<link rel="stylesheet" crossorigin href="/assets/index-B2J4t3te.css">
|
|
21
21
|
</head>
|
|
22
22
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitkyc08/opencodex",
|
|
3
|
-
"version": "2.7.41
|
|
3
|
+
"version": "2.7.41",
|
|
4
4
|
"description": "Universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./bin/package-main.mjs",
|