@bitkyc08/opencodex 2.43.0-preview.20260906 → 2.43.0
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.
|
@@ -109,4 +109,4 @@ default_mode_request_user_input = true`})]}),(0,J.jsxs)(`div`,{className:`codex-
|
|
|
109
109
|
}'`;return(0,J.jsxs)(`section`,{className:`panel api-panel awi-usage-panel`,children:[(0,J.jsx)(`h3`,{className:`panel-title`,children:n(`api.workspace.usageExamples`)}),(0,J.jsxs)(`div`,{className:`awi-usage-panel-body`,children:[(0,J.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,J.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageChatTitle`)}),(0,J.jsx)(B_,{text:i})]}),(0,J.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,J.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageResponsesTitle`)}),(0,J.jsx)(B_,{text:a})]}),t&&(0,J.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,J.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageMessagesTitle`)}),(0,J.jsx)(B_,{text:o})]})]})]})}function K_({client:e,apiBase:t,onOpenDetails:n,onCopy:r,onDownload:i}){let a=Z(),[o,s]=(0,_.useState)(0),c=[t,e,String(o)].join(`|`),[l,u]=(0,_.useState)(null);(0,_.useEffect)(()=>{let n=new AbortController,r=!1;return(async()=>{try{let i=await fetch(`${t}/api/client-config?client=${encodeURIComponent(e)}`,{signal:n.signal});if(!i.ok)throw Error(String(i.status));let a=await i.json();if(r)return;u({key:c,data:a,failed:!1})}catch{if(r)return;u({key:c,data:null,failed:!0})}})(),()=>{r=!0,n.abort()}},[t,e,c]);let d=l!==null&&l.key===c?l:null,f=d?.data??null,p=d?.failed??!1,m=d===null,h=a(c_[e]),g=l_[e],v=f?.text??``,y=(0,_.useCallback)(t=>{f&&n(e,f,v,t.currentTarget)},[e,f,v,n]);return(0,J.jsxs)(`li`,{className:`awi-clientconfig-row`,children:[(0,J.jsx)(`span`,{className:`awi-clientconfig-mark`,children:(0,J.jsx)(g_,{src:g??null,label:h,size:20})}),(0,J.jsxs)(`span`,{className:`awi-clientconfig-identity`,children:[(0,J.jsx)(`span`,{className:`awi-clientconfig-name`,children:h}),(0,J.jsx)(`span`,{className:`muted text-label awi-clientconfig-meta`,children:m?a(`api.clientConfig.loading`):p||!f?(0,J.jsx)(`span`,{role:`alert`,children:a(`api.clientConfig.rowError`,{client:h})}):a(`api.clientConfig.rowMeta`,{destination:f.destination,count:f.modelCount})})]}),(0,J.jsx)(`span`,{className:`awi-clientconfig-row-actions`,children:p&&!m?(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>s(e=>e+1),children:a(`common.retry`)}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":a(`api.clientConfig.copyAria`,{client:h}),disabled:!f,onClick:()=>{f&&r(e,v)},children:a(`api.clientConfig.copy`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-sm`,"aria-label":a(`api.clientConfig.downloadAria`,{client:h}),disabled:!f,onClick:()=>{f&&i(e,f,v)},children:a(`api.clientConfig.download`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"aria-label":a(`api.clientConfig.detailsAria`,{client:h}),disabled:!f,onClick:y,children:a(`api.clientConfig.details`)})]})})]})}function q_({client:e,envelope:t,json:n,hasKeys:r,onClose:i,onCopy:a,onDownload:o}){let s=Z(),c=(0,_.useRef)(null),l=`awi-clientconfig-dialog-${e}`;(0,_.useEffect)(()=>{let e=c.current;return e&&!e.open&&e.showModal(),()=>{e?.open&&e.close()}},[]);let u=(0,_.useCallback)(e=>{e.preventDefault(),i()},[i]);return(0,J.jsxs)(`dialog`,{ref:c,className:`modal-overlay`,"aria-labelledby":l,onCancel:u,children:[(0,J.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":s(`common.close`),tabIndex:-1,onClick:i}),(0,J.jsxs)(`div`,{className:`modal-card awi-clientconfig-dialog`,onClick:e=>e.stopPropagation(),role:`document`,children:[(0,J.jsxs)(`div`,{className:`modal-head`,children:[(0,J.jsx)(`h3`,{id:l,children:s(c_[e])}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:i,children:s(`common.close`)})]}),(0,J.jsx)(`pre`,{className:`api-code api-example-pre awi-clientconfig-json`,tabIndex:0,role:`group`,"aria-label":s(`api.clientConfig.jsonLabel`,{client:s(c_[e])}),children:n}),(0,J.jsx)(`p`,{className:`muted small awi-clientconfig-count`,children:s(`api.clientConfig.modelCount`,{count:t.modelCount})}),t.modelsWithoutLimits>0&&(0,J.jsx)(`p`,{className:`muted small awi-clientconfig-degraded`,children:s(`api.clientConfig.missingLimits`,{count:t.modelsWithoutLimits,total:t.modelCount})}),!r&&(0,J.jsx)(`p`,{className:`muted small awi-clientconfig-nokey`,children:s(`api.clientConfig.noKeyYet`,{env:t.apiKeyEnv})}),(0,J.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,J.jsx)(`span`,{className:`muted text-label`,children:s(`api.clientConfig.destination`)}),(0,J.jsx)(B_,{text:t.destination})]}),(0,J.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,J.jsx)(`span`,{className:`muted text-label`,children:s(`api.clientConfig.envHint`)}),(0,J.jsx)(B_,{text:t.exportHint})]}),(0,J.jsx)(`p`,{className:`muted small awi-clientconfig-merge`,children:s(`api.clientConfig.mergeWarning`)}),(0,J.jsx)(`p`,{className:`muted text-label awi-clientconfig-where-title`,children:s(`api.clientConfig.whereDisclosure`)}),(0,J.jsx)(`p`,{className:`muted small`,children:s(`api.clientConfig.whereBody`)}),(0,J.jsxs)(`div`,{className:`modal-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:a,children:s(`api.clientConfig.copy`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:o,children:s(`api.clientConfig.download`)})]})]})]})}function J_({apiBase:e,baseUrl:t,hasKeys:n}){let r=Z(),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(``),c=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(i!==null)return;let e=c.current;e&&(c.current=null,e.isConnected&&e.focus())},[i]);let l=(0,_.useCallback)(async(e,t,n)=>{try{await navigator.clipboard.writeText(t),s(n?r(`api.clientConfig.copiedAnnounceClient`,{client:r(c_[e])}):r(`api.clientConfig.copiedAnnounce`))}catch{s(r(`api.clientConfig.copyFailed`))}},[r]),u=(0,_.useCallback)((e,t,n)=>{let i=URL.createObjectURL(new Blob([n],{type:t.mediaType})),a=document.createElement(`a`);a.href=i,a.download=t.filename,a.click(),URL.revokeObjectURL(i),s(r(`api.clientConfig.downloadedAnnounce`,{filename:t.filename,destination:t.destination}))},[r]),d=(0,_.useCallback)(()=>a(null),[]),f=(0,_.useCallback)((e,t,n,r)=>{c.current=r,a({client:e,envelope:t,json:n})},[]);return(0,J.jsxs)(`section`,{className:`panel api-panel awi-clientconfig-panel`,children:[(0,J.jsx)(`div`,{className:`api-panel-head awi-clientconfig-head`,children:(0,J.jsx)(`h3`,{className:`panel-title`,children:r(`api.clientConfig.title`)})}),(0,J.jsx)(`ul`,{className:`awi-clientconfig-rows`,"aria-label":r(`api.clientConfig.rowsLabel`),children:s_.map(t=>(0,J.jsx)(K_,{client:t,apiBase:e,onOpenDetails:f,onCopy:(e,t)=>{l(e,t,!0)},onDownload:u},t))}),(0,J.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,J.jsx)(`span`,{className:`muted text-label`,children:r(`api.baseUrl`)}),(0,J.jsx)(B_,{text:t})]}),(0,J.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:o}),i&&(0,J.jsx)(q_,{client:i.client,envelope:i.envelope,json:i.json,hasKeys:n,onClose:d,onCopy:()=>{l(i.client,i.json,!1)},onDownload:()=>u(i.client,i.envelope,i.json)})]})}function Y_({keys:e,keysLoading:t,keysLoadFailed:n,attributionSince:r,localeTag:i,busy:a,onSelect:o}){let s=Z();return(0,J.jsxs)(`div`,{className:`panel api-panel awi-keylist-panel`,"aria-busy":t,children:[(0,J.jsx)(`div`,{className:`api-panel-head`,children:(0,J.jsx)(`h3`,{className:`panel-title`,children:t?s(`api.activeKeysLoading`):s(`api.activeKeys`,{count:e.length})})}),t?(0,J.jsx)(`div`,{className:`api-active-keys-skeleton`,role:`status`,"aria-label":s(`common.loading`)}):e.length===0?(0,J.jsx)(`p`,{className:`muted small`,children:s(n?`api.keysLoadFailed`:`api.noKeys`)}):(0,J.jsx)(`div`,{className:`tbl-wrap`,children:(0,J.jsxs)(`table`,{className:`tbl awi-keylist-table`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:s(`api.colName`)}),(0,J.jsx)(`th`,{children:s(`api.colKey`)}),(0,J.jsx)(`th`,{children:s(`api.attribution.requests7d`)}),(0,J.jsx)(`th`,{children:s(`api.attribution.lastUsed`)})]})}),(0,J.jsx)(`tbody`,{children:e.map(e=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsx)(`button`,{type:`button`,className:`awi-keylist-name`,disabled:a,onClick:()=>o(e.id),children:e.name})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(`code`,{children:e.prefix})}),(0,J.jsx)(`td`,{children:r?e.usage.ambiguous?s(`api.attribution.railAmbiguous`):e.usage.requests7d.toLocaleString(i):s(`api.attribution.unavailable`)}),(0,J.jsx)(`td`,{children:!r||e.usage.ambiguous?`—`:e.usage.lastUsedAt?L_(e.usage.lastUsedAt,i):s(`api.attribution.neverUsed`)})]},e.id))})]})})]})}function X_({keys:e,apiBase:t,attributionSince:n,historyTruncated:r,authMatrix:i,keysLoading:a,keysLoadFailed:o,endpoints:s,claudeCodeEnabled:c,localeTag:l,newName:u,creating:d,newKey:f,copied:p,rotationSecret:m=null,rotationCopied:h=!1,filteredModels:g,modelsLoading:v,modelsRefreshing:y=!1,modelsLoadFailed:b,modelCount:x,hasModelData:S,modelQuery:C,copiedModelId:w,modelTests:T,canTestModels:E,onNewNameChange:D,onCreate:O,onDismissNewKey:k,onCopyKey:A,onDelete:j,onRename:M,onRotationStart:N,onRotationCommit:P,onRotationAbort:F,onCopyRotationSecret:I,onDismissRotationSecret:L,onModelQueryChange:R,onCopyModelId:z,onTestModel:B,onRetryModels:V,sourceLabel:H,protocolLabel:U}){let W=Z(),[ee,G]=(0,_.useState)(null),[K,q]=(0,_.useState)(!1),[Y,te]=(0,_.useState)(!1),[ne,re]=(0,_.useState)(!1),[ie,ae]=(0,_.useState)(!1),[oe,se]=(0,_.useState)(``),[ce,le]=(0,_.useState)(!1),[ue,de]=(0,_.useState)(!1),[fe,pe]=(0,_.useState)(!1),[X,me]=(0,_.useState)(!1),[ge,_e]=(0,_.useState)(!1),ve=ee?e.find(e=>e.id===ee)??null:null,ye=ve?m?.id===ve.id?m.rotationId:ve.pendingRotation?.id:void 0,be=ne||ce||X,xe=async e=>{if(!(!ve||X)){me(!0),_e(!1);try{let t=ye;(e===`start`?await N?.(ve.id)??!1:t&&(await(e===`commit`?P:F)?.(ve.id,t)??!1))||_e(!0)}finally{me(!1)}}},Se=(0,_.useMemo)(()=>[{id:`keys`,label:W(`api.section.keys`),meta:a?void 0:String(e.length)},{id:`connect`,label:W(`api.section.connect`)},{id:`endpoints`,label:W(`api.section.endpoints`)},{id:`models`,label:W(`api.section.models`),meta:String(x)},{id:`examples`,label:W(`api.section.examples`)}],[W,e.length,a,x]),we=()=>{q(!1),te(!1)},Te=()=>{G(null),we(),ae(!1),de(!1),pe(!1)};(0,_.useEffect)(()=>{if(!K)return;let e=window.setTimeout(()=>te(!0),300);return()=>window.clearTimeout(e)},[K]);let Ee=()=>{ve&&q(!0)},De=async()=>{if(!(!ve||!Y||ne)){re(!0),pe(!1);try{await j(ve.id)?(we(),G(null)):pe(!0)}finally{re(!1)}}},Oe=()=>{ve&&(se(ve.name),de(!1),ae(!0))},ke=async()=>{if(!ve||ce)return;let e=oe.trim();if(!e||e===ve.name){ae(!1);return}le(!0),de(!1);try{await M(ve.id,e)?ae(!1):de(!0)}finally{le(!1)}};return(0,J.jsxs)(`div`,{className:`apikeys-workspace-shell`,children:[!ve&&(0,J.jsx)(Lp,{scope:`api`,items:Se,ariaLabel:W(`api.workspace.sections`)}),(0,J.jsx)(`div`,{className:`apikeys-workspace-root`,children:(0,J.jsx)(`section`,{className:`apikeys-workspace-main`,"aria-label":W(`api.workspace.details`),children:ve?(0,J.jsxs)(`div`,{className:`awi-detail`,children:[(0,J.jsx)(`div`,{className:`awi-detail-toolbar`,children:(0,J.jsxs)(`button`,{type:`button`,className:`awi-back`,onClick:Te,disabled:be,children:[(0,J.jsx)(Ce,{className:`awi-back-chevron`,"aria-hidden":`true`}),W(`modal.back`)]})}),(0,J.jsxs)(`div`,{className:`awi-detail-body`,children:[(0,J.jsxs)(`div`,{className:`awi-detail-head`,children:[(0,J.jsx)(`h2`,{className:`awi-detail-title`,children:ve.name}),(0,J.jsx)(`span`,{className:`awi-detail-actions`,children:K?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm awi-confirm-delete`,onClick:()=>{De()},disabled:!Y||ne,children:[(0,J.jsx)(he,{}),` `,W(ne?`api.key.deleting`:`api.confirm`)]},`confirm-delete`),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:we,disabled:ne,children:W(`common.cancel`)})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:Oe,disabled:ie,children:W(`api.key.rename`)},`rename`),(0,J.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,onClick:Ee,"aria-label":W(`api.deleteAria`),children:[(0,J.jsx)(he,{}),` `,W(`api.workspace.deleteKey`)]},`request-delete`)]})})]}),K&&(0,J.jsx)(`p`,{className:`muted awi-delete-hint`,children:W(`api.workspace.deleteConfirm`)}),fe&&(0,J.jsx)(`p`,{className:`awi-delete-error`,role:`alert`,children:W(`api.deleteFailed`)}),ie&&(0,J.jsxs)(`div`,{className:`awi-rename`,children:[(0,J.jsx)(`label`,{className:`awi-rename-label`,htmlFor:`awi-key-name`,children:W(`api.key.name`)}),(0,J.jsx)(`input`,{id:`awi-key-name`,className:`input`,type:`text`,value:oe,maxLength:64,disabled:ce,onChange:e=>se(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ke())}}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>{ke()},disabled:ce,children:W(ce?`api.key.renaming`:`api.key.saveName`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>ae(!1),disabled:ce,children:W(`common.cancel`)}),ue&&(0,J.jsx)(`p`,{className:`awi-rename-error`,role:`alert`,children:W(`api.key.renameFailed`)})]}),(0,J.jsxs)(`div`,{className:`awi-section`,children:[(0,J.jsx)(`h3`,{className:`awi-section-title`,children:W(`api.workspace.keyDetails`)}),(0,J.jsxs)(`dl`,{className:`awi-kv`,children:[(0,J.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,J.jsx)(`dt`,{children:W(`api.workspace.keyPrefix`)}),(0,J.jsx)(`dd`,{children:(0,J.jsx)(`code`,{children:ve.prefix})})]}),(0,J.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,J.jsx)(`dt`,{children:W(`api.colCreated`)}),(0,J.jsx)(`dd`,{children:L_(ve.createdAt,l)})]})]})]}),(0,J.jsxs)(`div`,{className:`awi-section`,"aria-live":`polite`,children:[(0,J.jsx)(`h3`,{className:`awi-section-title`,children:W(`api.rotation.title`)}),ye?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`muted`,children:W(`api.rotation.pending`)}),ve.pendingRotation&&(0,J.jsxs)(`p`,{className:`muted`,children:[W(`api.rotation.expires`),` `,L_(ve.pendingRotation.expiresAt,l)]}),m?.id===ve.id&&(0,J.jsxs)(`div`,{className:`api-key-reveal`,role:`status`,children:[(0,J.jsx)(`p`,{children:W(`api.rotation.secretOnce`)}),(0,J.jsx)(`code`,{children:m.key}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:I,children:W(h?`api.copied`:`api.copy`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:L,children:W(`common.close`)})]})]}),(0,J.jsxs)(`div`,{className:`awi-detail-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:X,onClick:()=>{xe(`commit`)},children:W(`api.rotation.commit`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:X,onClick:()=>{xe(`abort`)},children:W(`api.rotation.abort`)})]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`muted`,children:W(`api.rotation.description`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:X,onClick:()=>{xe(`start`)},children:W(X?`api.rotation.starting`:`api.rotation.start`)})]}),ge&&(0,J.jsx)(`p`,{className:`awi-delete-error`,role:`alert`,children:W(`api.rotation.failed`)})]}),(0,J.jsxs)(`div`,{className:`awi-section`,children:[(0,J.jsx)(`h3`,{className:`awi-section-title`,children:W(`api.attribution.title`)}),n?ve.usage.ambiguous?(0,J.jsx)(`p`,{className:`muted`,children:W(`api.attribution.ambiguous`)}):(0,J.jsxs)(`dl`,{className:`awi-kv`,children:[(0,J.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,J.jsx)(`dt`,{children:W(`api.attribution.requests7d`)}),(0,J.jsx)(`dd`,{children:ve.usage.requests7d.toLocaleString(l)})]}),(0,J.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,J.jsx)(`dt`,{children:W(r?`api.attribution.totalRequestsAvailable`:`api.attribution.totalRequests`)}),(0,J.jsx)(`dd`,{children:ve.usage.totalRequests.toLocaleString(l)})]}),(0,J.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,J.jsx)(`dt`,{children:W(`api.attribution.lastUsed`)}),(0,J.jsx)(`dd`,{children:ve.usage.lastUsedAt?L_(ve.usage.lastUsedAt,l):W(`api.attribution.neverUsed`)})]}),(0,J.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,J.jsx)(`dt`,{children:W(r?`api.attribution.sinceAvailable`:`api.attribution.since`)}),(0,J.jsx)(`dd`,{children:L_(n,l)})]})]}):(0,J.jsx)(`p`,{className:`muted`,children:W(`api.attribution.unavailableDetail`)})]})]})]}):(0,J.jsx)(`div`,{className:`awi-overview`,children:(0,J.jsxs)(`div`,{className:`awi-overview-section`,children:[(0,J.jsxs)(`div`,{id:Pp(`api`,`keys`),className:`awi-section-anchor`,children:[(0,J.jsx)(U_,{keys:e,keysLoading:a,keysLoadFailed:o,newName:u,creating:d,newKey:f,copied:p,confirmDelete:null,localeTag:l,showKeyList:!1,onNewNameChange:D,onCreate:O,onDismissNewKey:k,onCopyKey:A,onConfirmDelete:()=>{},onCancelDelete:()=>{},onDelete:()=>{}}),(0,J.jsx)(Y_,{keys:e,keysLoading:a,keysLoadFailed:o,attributionSince:n,localeTag:l,busy:be,onSelect:e=>{G(e),we(),ae(!1),de(!1),pe(!1)}})]}),(0,J.jsx)(`div`,{id:Pp(`api`,`connect`),className:`awi-section-anchor`,children:(0,J.jsx)(J_,{apiBase:t,baseUrl:s.baseUrl,hasKeys:e.length>0})}),(0,J.jsx)(`div`,{id:Pp(`api`,`endpoints`),className:`awi-section-anchor`,children:(0,J.jsx)(H_,{endpoints:s,claudeCodeEnabled:c,authMatrix:i})}),(0,J.jsx)(`div`,{id:Pp(`api`,`models`),className:`awi-section-anchor`,children:(0,J.jsx)(W_,{filteredModels:g,modelsLoading:v,modelsRefreshing:y,modelsLoadFailed:b,modelCount:x,hasModelData:S,modelQuery:C,copiedModelId:w,modelTests:T,claudeCodeEnabled:c,onModelQueryChange:R,onCopyModelId:z,onTestModel:B,onRetryModels:V,canTestModels:E,sourceLabel:H,protocolLabel:U})}),(0,J.jsx)(`div`,{id:Pp(`api`,`examples`),className:`awi-section-anchor`,children:(0,J.jsx)(G_,{endpoints:s,claudeCodeEnabled:c})})]})})})})]})}var Z_=[],Q_=15e3;function $_(e){let t=e.replace(/\/$/,``);if(!t)return F_;try{return new URL(t).host?I_(`${t}/v1/responses`):F_}catch{return F_}}function ev(e){return!e||!P_(e.authMatrix)||!Array.isArray(e.keys)||e.keys.some(e=>!e||!M_(e.usage)||!tv(e.pendingRotation))?null:e}function tv(e){if(e===void 0)return!0;if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&!!t.id&&typeof t.createdAt==`string`&&!Number.isNaN(Date.parse(t.createdAt))&&typeof t.expiresAt==`string`&&!Number.isNaN(Date.parse(t.expiresAt))}function nv({apiBase:e,active:t=!0}){let{t:n,locale:r}=ut(),i=nt.find(e=>e.code===r)?.htmlLang,a=`ocx.apikeys.list.v2:${e}`,o=`ocx.apikeys.models.v1:${e}`,s=`api-keys:${e}`,c=`api-models:${e}`,l=br(a),u=br(o),d=ev(l?.data??null),f=u?.data??null,[p,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)({}),[S,C]=(0,_.useState)(``),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(null),[O,k]=(0,_.useState)(!1),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)(!1),P=(0,_.useRef)(!1),F=(0,_.useCallback)(async t=>{let r=await Lt(await fetch(`${e}/api/keys`,{signal:t}));if(!r||!P_(r.authMatrix))throw Error(n(`api.keysLoadFailed`));let i=r.keys??[];if(i.some(e=>!M_(e.usage)||!tv(e.pendingRotation)))throw Error(n(`api.keysLoadFailed`));let o=i,s=I_(r.endpoint??``),c={keys:o,endpoints:{baseUrl:r.baseUrl??s.baseUrl,responses:r.responsesEndpoint??r.endpoint??F_.responses,chatCompletions:r.chatCompletionsEndpoint??s.chatCompletions,messages:r.messagesEndpoint??s.messages,models:r.modelsEndpoint??s.models},claudeCodeEnabled:r.claudeCodeEnabled!==!1,...r.attributionSince?{attributionSince:r.attributionSince}:{},...r.historyTruncated===!0?{historyTruncated:!0}:{},authMatrix:r.authMatrix};return xr(a,c),c},[e,a,n]),I=(0,_.useCallback)(async t=>{let r=await fetch(`${e}/v1/models`,{signal:t});if(!r.ok)throw Error(n(`api.modelsLoadFailed`));let i=await r.json(),a=Array.isArray(i)?i:typeof i==`object`&&i&&Array.isArray(i.data)?i.data:null;if(!a)throw Error(n(`api.modelsLoadFailed`));let s=a.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`).map(e=>A_(e)).sort((e,t)=>j_(e).localeCompare(j_(t)));return xr(o,s),s},[e,o,n]),L=$(s,[e],F,{isEmpty:e=>e.keys.length===0,initialData:d??void 0,initialDataCachedAt:l?.cachedAt??null,staleAfterMs:6e4,enabled:t}),R=$(c,[e],I,{isEmpty:e=>e.length===0,initialData:f??void 0,initialDataCachedAt:u?.cachedAt??null,staleAfterMs:6e4,enabled:t}),z=L.state,B=R.state,V=z.data??d,H=B.data??f??Z_,U=V?.keys??[],W=V?.endpoints??$_(e),ee=V?.claudeCodeEnabled??!0,G=V?.attributionSince,K=V?.historyTruncated===!0,q=V?.authMatrix??[],Y=L.refresh,te=R.refresh,ne=(0,_.useMemo)(()=>{let e=h.trim().toLowerCase();return e?H.filter(t=>j_(t).toLowerCase().includes(e)||t.displayName.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)):H},[h,H]),re=async t=>{if(P.current)return!1;P.current=!0,T(!0),m(null);try{let r=t??S,i=await It(await fetch(`${e}/api/keys`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:r||`default`})}),n(`api.createFailed`));return typeof i?.key!=`string`||i.key.length===0?(m(n(`api.createFailed`)),!1):(D(i.key),C(``),Y(),!0)}catch{return m(n(`api.createFailed`)),!1}finally{P.current=!1,T(!1)}},ie=async t=>{m(null);let n=Un(Q_);try{return(await fetch(`${e}/api/keys`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t}),signal:n.signal})).ok?(Y(),!0):!1}catch{return!1}finally{n.clear()}},ae=async(t,n)=>{m(null);let r=Un(Q_);try{return(await fetch(`${e}/api/keys`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t,name:n}),signal:r.signal})).ok?(Y(),!0):!1}catch{return!1}finally{r.clear()}},oe=async t=>{m(null);let r=Un(Q_);try{let i=await It(await fetch(`${e}/api/keys/rotate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t}),signal:r.signal}),n(`api.rotation.startFailed`));return!i||typeof i.key!=`string`||!i.key||typeof i.rotationId!=`string`||!i.rotationId?!1:(j({id:t,key:i.key,rotationId:i.rotationId}),Y(),!0)}catch{return!1}finally{r.clear()}},se=async(t,n,r)=>{m(null);let i=Un(Q_);try{return(await fetch(`${e}${r===`commit`?`/api/keys/rotate/commit`:`/api/keys/rotate`}`,{method:r===`commit`?`POST`:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t,rotationId:n}),signal:i.signal})).ok?(j(e=>e?.id===t?null:e),Y(),!0):!1}catch{return!1}finally{i.clear()}},ce=async()=>{if(A)try{await navigator.clipboard.writeText(A.key),N(!0),window.setTimeout(()=>N(!1),2e3)}catch{m(n(`api.key.copyFailed`))}},le=async()=>{if(E){m(null);try{await navigator.clipboard.writeText(E),k(!0),window.setTimeout(()=>k(!1),2e3)}catch{k(!1),m(n(`api.key.copyFailed`))}}},ue=async e=>{try{await navigator.clipboard.writeText(e),y(e),window.setTimeout(()=>y(t=>t===e?null:t),2e3)}catch{}},de=e=>e.native?n(`api.sourceNative`):e.provider===`combo`?n(`api.sourceCombo`):e.custom?n(`api.sourceCustom`):Nn(e.provider,n),fe=e=>n(e===`responses`?`api.protocolResponses`:e===`messages`?`api.protocolMessages`:`api.protocolChatCompletions`),pe=(e,t)=>e===`responses`?{url:W.responses,body:{model:t,input:`ping`,max_output_tokens:1,stream:!1}}:e===`messages`?{url:W.messages,body:{model:t,max_tokens:1,messages:[{role:`user`,content:`ping`}]}}:{url:W.chatCompletions,body:{model:t,messages:[{role:`user`,content:`ping`}],max_tokens:1,stream:!1}},X=(e,t,n)=>x(r=>({...r,[e]:{...r[e],[t]:n}})),me=async(e,t)=>{if(!E)return;let r=j_(e),i=pe(t,r);X(r,t,{state:`testing`});try{let e=await fetch(i.url,{method:`POST`,headers:{"Content-Type":`application/json`,"x-opencodex-api-key":E},body:JSON.stringify(i.body)});if(!e.ok){let n=await e.text();X(r,t,{state:`error`,detail:n.slice(0,160)||String(e.status)});return}X(r,t,{state:`ok`})}catch(e){X(r,t,{state:`error`,detail:e instanceof Error?e.message:n(`api.testFailed`)})}},he=n(`api.subtitle`).split(`{authHeader}`);return(0,J.jsxs)(`section`,{className:`api-page`,"aria-busy":z.refreshing||B.refreshing||void 0,children:[(0,J.jsx)(`div`,{className:`page-head`,children:(0,J.jsx)(`h2`,{children:n(`api.title`)})}),(0,J.jsxs)(`p`,{className:`page-sub`,children:[he[0],(0,J.jsx)(`code`,{children:`x-opencodex-api-key`}),he[1]]}),p&&(0,J.jsx)(Q,{tone:`err`,children:p}),z.showError&&V&&(0,J.jsx)(Q,{tone:`err`,children:n(`api.keysLoadFailed`)}),z.showSkeleton&&!V?(0,J.jsx)(Nl,{label:n(`api.activeKeysLoading`),rows:4}):z.kind===`failed-cold`&&!V?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Q,{tone:`err`,children:z.error instanceof Error?z.error.message:n(`api.keysLoadFailed`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>Y(),children:n(`common.retry`)})]}):(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(X_,{keys:U,apiBase:e,attributionSince:G,historyTruncated:K,authMatrix:q,keysLoading:!1,keysLoadFailed:z.showError,endpoints:W,claudeCodeEnabled:ee,localeTag:i,newName:S,creating:w,newKey:E,copied:O,rotationSecret:A,rotationCopied:M,filteredModels:ne,modelsLoading:B.showSkeleton&&!B.data&&!f,modelsRefreshing:B.refreshing&&B.showError&&(B.data!==void 0||f!==null),modelsLoadFailed:B.showError,modelCount:H.length,hasModelData:B.data!==void 0||f!==null,modelQuery:h,copiedModelId:v,modelTests:b,onNewNameChange:C,onCreate:()=>{re()},onDismissNewKey:()=>D(null),onCopyKey:()=>{le()},onDelete:ie,onRename:ae,...v_()?{onRotationStart:oe,onRotationCommit:(e,t)=>se(e,t,`commit`),onRotationAbort:(e,t)=>se(e,t,`abort`),onCopyRotationSecret:()=>{ce()},onDismissRotationSecret:()=>j(null)}:{},onModelQueryChange:g,onCopyModelId:e=>{ue(e)},onTestModel:(e,t)=>{me(e,t)},onRetryModels:()=>{te({forceLoading:!0})},canTestModels:E!==null,sourceLabel:de,protocolLabel:fe})})]})}function rv(e,t){let n=(e??[]).map(e=>({value:e,label:Al(e)}));return[{value:``,label:t},...n]}function iv(e){let t=e.autoConnectSupported===!0;return{autoConnectSupported:t,systemEnv:t&&e.systemEnv===!0}}function av(){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)}`}var ov=829800;function sv(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`}var cv=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`];function lv(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=cv.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??829800}`]:[],...i,`claude`].join(`
|
|
110
110
|
`)}function uv(e){return e?e.backend??`auto`:`inherit`}function dv(e,t){if(t!==`inherit`)return t===`auto`?{...e,backend:void 0}:{...e,backend:t}}function fv(e,t){return{...e,model:t}}function pv(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 mv({label:e,checked:t,onChange:n,disabled:r=!1,describedBy:i}){return(0,J.jsxs)(`label`,{className:`toggle`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:t,disabled:r,"aria-label":e,"aria-describedby":i,onChange:e=>n(e.target.checked)}),(0,J.jsx)(`span`,{className:`slider`,"aria-hidden":`true`})]})}function hv({supported:e,checked:t,onChange:n}){let r=Z(),i=e?void 0:`claude-system-env-unsupported`;return(0,J.jsxs)(`div`,{className:`setting-row`,children:[(0,J.jsxs)(`div`,{className:`setting-label`,children:[(0,J.jsx)(`span`,{className:`title`,children:r(`claude.systemEnv`)}),e?(0,J.jsx)(`span`,{className:`desc`,children:r(`claude.systemEnvDesc`)}):(0,J.jsx)(`span`,{className:`desc`,id:i,children:(0,J.jsx)(ft,{k:`claude.systemEnvUnsupported`,cmd:`ocx claude`})}),e&&t&&(0,J.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:r(`claude.systemEnvWarn`)})]}),(0,J.jsx)(mv,{label:r(`claude.systemEnv`),checked:e&&t,disabled:!e,describedBy:i,onChange:n})]})}function gv({value:e,tierHaikuModel:t,options:n,onChange:r}){let i=Z(),a=t??e;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:i(`claude.smallFastModelAccurateHint`)}),(0,J.jsx)(kt,{value:e,options:n,onChange:r,label:i(`claude.smallFastModel`),style:{maxWidth:420}}),a===``&&(0,J.jsx)(`p`,{className:`notice-warn`,role:`status`,style:{marginTop:8},children:i(`claude.smallFastModelNativeWarning`)})]})}function _v(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 vv({state:e,autoCompactOptions:t,availableModels:n,onStateChange:r}){let i=Z();return(0,J.jsxs)(`div`,{className:`card`,style:{overflow:`hidden`},children:[(0,J.jsxs)(`div`,{className:`setting-row`,children:[(0,J.jsxs)(`div`,{className:`setting-label`,children:[(0,J.jsx)(`span`,{className:`title`,children:i(`claude.authMode`)}),(0,J.jsx)(`span`,{className:`desc`,children:i(`claude.authModeHint`)})]}),(0,J.jsx)(`div`,{className:`setting-controls`,children:(0,J.jsx)(kt,{value:e.authMode,options:[{value:`auto`,label:i(`claude.authModeAuto`)},{value:`subscription`,label:i(`claude.authModeSubscription`)},{value:`proxy`,label:i(`claude.authModeProxy`)}],onChange:t=>r({...e,authMode:t}),label:i(`claude.authMode`),style:{minWidth:220},align:`right`,portal:!0})})]}),e.authModeOrigin&&(0,J.jsxs)(`div`,{className:`claude-effective-auth${e.authModeOrigin===`auto-unknown`?` warn`:``}`,role:`status`,children:[(0,J.jsx)(`span`,{className:`claude-effective-auth-label`,children:i(`claude.effectiveMode.label`)}),(0,J.jsxs)(`span`,{children:[e.authModeOrigin===`manual`?i(`claude.effectiveMode.manual`,{mode:e.markerMode===`proxy`?i(`claude.authModeProxy`):i(`claude.authModeSubscription`)}):e.authModeOrigin===`auto-present`?i(`claude.effectiveMode.autoPresent`,{source:_v(e.authFoundBy,i)}):e.authModeOrigin===`auto-absent`?i(`claude.effectiveMode.autoAbsent`):i(`claude.effectiveMode.autoUnknown`),e.admissionKeyActive===!0?` ${i(`claude.effectiveMode.admissionKey`)}`:``]})]}),(0,J.jsx)(hv,{supported:e.autoConnectSupported,checked:e.systemEnv,onChange:t=>r({...e,systemEnv:t})}),(0,J.jsxs)(`div`,{className:`setting-row`,children:[(0,J.jsxs)(`div`,{className:`setting-label`,children:[(0,J.jsx)(`span`,{className:`title`,children:i(`claude.fastMode`)}),(0,J.jsx)(`span`,{className:`desc`,children:i(`claude.fastModeDesc`)})]}),(0,J.jsx)(`div`,{className:`setting-controls`,children:(0,J.jsx)(kt,{value:e.fastMode===null?`auto`:e.fastMode?`on`:`off`,options:[{value:`auto`,label:i(`claude.fastAuto`)},{value:`on`,label:i(`claude.fastOn`)},{value:`off`,label:i(`claude.fastOff`)}],onChange:t=>r({...e,fastMode:t===`auto`?null:t===`on`}),label:i(`claude.fastMode`),style:{minWidth:140},align:`right`,portal:!0})})]}),(0,J.jsxs)(`div`,{className:`setting-row`,children:[(0,J.jsxs)(`div`,{className:`setting-label`,children:[(0,J.jsx)(`span`,{className:`title`,children:i(`claude.autoContext`)}),(0,J.jsx)(`span`,{className:`desc`,children:i(`claude.autoContextDesc`)}),e.maxContextTokens!==null&&(0,J.jsx)(`span`,{className:`desc`,style:{color:`var(--muted)`},children:i(`claude.autoContextInert`)})]}),(0,J.jsx)(mv,{label:i(`claude.autoContext`),checked:e.autoContext,onChange:t=>r({...e,autoContext:t})})]}),e.autoContext&&(0,J.jsxs)(`div`,{className:`setting-row`,children:[(0,J.jsxs)(`div`,{className:`setting-label`,children:[(0,J.jsx)(`span`,{className:`title`,children:i(`claude.autoCompactWindow`)}),(0,J.jsx)(`span`,{className:`desc`,children:i(`claude.autoCompactWindowDesc`)}),e.autoCompactWindow!==null&&(0,J.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:i(`claude.autoCompactWindowWarn`)})]}),(0,J.jsx)(`div`,{className:`setting-controls`,children:(0,J.jsx)(kt,{value:e.autoCompactWindow===null?``:String(e.autoCompactWindow),options:t,onChange:t=>r({...e,autoCompactWindow:t===``?null:Number(t)}),label:i(`claude.autoCompactWindow`),style:{minWidth:130},align:`right`,portal:!0})})]}),(0,J.jsxs)(`div`,{className:`setting-row`,children:[(0,J.jsxs)(`div`,{className:`setting-label`,children:[(0,J.jsx)(`span`,{className:`title`,children:i(`claude.injectAgents`)}),(0,J.jsx)(`span`,{className:`desc`,children:i(`claude.injectAgentsDesc`)})]}),(0,J.jsx)(mv,{label:i(`claude.injectAgents`),checked:e.injectAgents,onChange:t=>r({...e,injectAgents:t})})]}),[`webSearchSidecar`,`visionSidecar`].map(t=>{let a=e[t],o=t===`webSearchSidecar`?`claude.webSearchSidecar`:`claude.visionSidecar`,s=t===`webSearchSidecar`?`claude.webSearchSidecarHint`:`claude.visionSidecarHint`,c=`claude-sidecar-models-${t}`;return(0,J.jsxs)(`div`,{className:`setting-row`,style:{alignItems:`flex-start`},children:[(0,J.jsxs)(`div`,{className:`setting-label setting-copy`,style:{flex:1},children:[(0,J.jsx)(`span`,{className:`title`,children:i(o)}),(0,J.jsx)(`span`,{className:`desc`,children:i(s)})]}),(0,J.jsxs)(`div`,{className:`setting-controls`,style:{display:`flex`,gap:8},children:[(0,J.jsx)(kt,{value:uv(a),options:[{value:`inherit`,label:i(`claude.useMainSetting`)},{value:`auto`,label:i(`dash.backendAuto`)},{value:`openai`,label:i(`dash.backendOpenAI`)},{value:`anthropic`,label:i(`dash.backendAnthropic`)}],onChange:n=>{r({...e,[t]:dv(a,n)})},label:i(`dash.sidecarBackend`),portal:!0}),(0,J.jsx)(`input`,{className:`input mono`,value:a?.model??``,onChange:n=>{r({...e,[t]:fv(a,n.target.value)})},placeholder:i(`claude.sidecarModelPlaceholder`),disabled:!a,list:a?c:void 0,"aria-label":i(`dash.sidecarModel`),style:{minWidth:210},autoComplete:`off`}),a&&(0,J.jsx)(`datalist`,{id:c,children:n.map(e=>(0,J.jsx)(`option`,{value:e},e))})]})]},t)})]})}function yv({manualEnv:e}){let t=Z();return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:(0,J.jsx)(ft,{k:`claude.quickstartHint`,cmd:`ocx claude`})}),(0,J.jsx)(`pre`,{className:`mono card`,style:{padding:`10px 14px`,overflowX:`auto`,margin:0},children:`ocx claude`}),(0,J.jsxs)(`details`,{style:{margin:`10px 0 0`},children:[(0,J.jsx)(`summary`,{className:`muted text-label`,style:{cursor:`pointer`,padding:`2px 2px`},children:t(`claude.manualEnv`)}),(0,J.jsx)(`pre`,{className:`mono card text-label`,style:{padding:`10px 14px`,overflowX:`auto`,margin:`6px 0 0`},children:e})]})]})}function bv({rows:e,onRowsChange:t}){let n=Z();return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:n(`claude.modelMapHint`)}),(0,J.jsx)(`div`,{className:`stack`,style:{gap:8},children:e.map((r,i)=>(0,J.jsxs)(`div`,{className:`row`,style:{gap:8},children:[(0,J.jsx)(`input`,{className:`input mono`,value:r.from,placeholder:n(`claude.mapFrom`),"aria-label":n(`claude.mapFrom`),onChange:n=>t(e.map((e,t)=>t===i?{...e,from:n.target.value}:e)),style:{flex:1}}),(0,J.jsx)(`span`,{className:`muted`,"aria-hidden":!0,children:`→`}),(0,J.jsx)(`input`,{className:`input mono`,value:r.to,placeholder:n(`claude.mapTo`),"aria-label":n(`claude.mapTo`),onChange:n=>t(e.map((e,t)=>t===i?{...e,to:n.target.value}:e)),style:{flex:1}}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>t(e.filter((e,t)=>t!==i)),"aria-label":n(`claude.removeMapping`),style:{color:`var(--red)`},children:(0,J.jsx)(de,{})})]},r.id))}),(0,J.jsx)(`div`,{style:{marginTop:8},children:(0,J.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>t([...e,{id:av(),from:``,to:``}]),children:[(0,J.jsx)(fe,{}),` `,n(`claude.addMapping`)]})})]})}var xv=`etc`;function Sv(e){let t=new Map;for(let n of e){let e=/\(([^)]+)\)\s*$/.exec(n.display_name),r=e?e[1]:xv,i=t.get(r);i?i.push(n):t.set(r,[n])}return Array.from(t)}function Cv({aliases:e}){let t=Z();return(0,J.jsxs)(`div`,{className:`claude-aliases`,children:[(0,J.jsx)(`p`,{className:`muted text-label claude-aliases-hint`,children:t(`claude.aliasesHint`)}),e.length===0?(0,J.jsx)(`div`,{className:`muted text-label`,children:t(`claude.none`)}):(0,J.jsx)(`div`,{className:`claude-aliases-scroll`,children:Sv(e).map(([e,n])=>(0,J.jsxs)(`div`,{className:`claude-aliases-group`,children:[(0,J.jsxs)(`div`,{className:`claude-aliases-group-label`,children:[e===xv?t(`claude.aliasProviderOther`):e,(0,J.jsx)(`span`,{className:`claude-aliases-group-count`,children:n.length})]}),(0,J.jsx)(`div`,{className:`claude-aliases-chips`,children:n.map(e=>(0,J.jsxs)(`span`,{className:`claude-aliases-chip`,children:[(0,J.jsx)(`code`,{className:`claude-aliases-chip-id`,children:e.id}),e.display_name?(0,J.jsx)(`span`,{className:`claude-aliases-chip-name`,children:e.display_name}):null]},e.id))})]},e))})]})}function wv({apiBase:e,active:t=!0}){let n=Z(),{locale:r}=ut(),i=nt.find(e=>e.code===r)?.htmlLang??`en`,a=`ocx.claude-code.v1:${e}`,o=`claude-code:${e}`,s=(0,_.useMemo)(()=>br(a),[a]),c=s?.data??null,[l,u]=(0,_.useState)(()=>c?.state??null),[d,f]=(0,_.useState)(()=>c?.rows??[]),[p,m]=(0,_.useState)(!!c),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(`settings`),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(!1),T=(0,_.useCallback)(async t=>{let r=await It(await fetch(`${e}/api/claude-code`,{signal:t}),n(`claude.loadFail`));if(!r)throw Error(n(`claude.loadFail`));let i={...r,authMode:r.authMode===`proxy`||r.authMode===`subscription`?r.authMode:`auto`,...iv(r),fastMode:r.fastMode??null,maxContextTokens:r.maxContextTokens??null,autoContext:r.autoContext!==!1,autoCompactWindow:r.autoCompactWindow??null,injectAgents:r.injectAgents!==!1,effectiveModelEnv:r.effectiveModelEnv??{}},o=Object.entries(r.modelMap??{}).map(([e,t])=>({id:av(),from:e,to:String(t)})),s={state:i,rows:o};if(t.aborted)throw Error(`Claude Code request aborted`);return u(i),f(o),m(!0),xr(a,s),s},[e,a,n]),E=$(o,[e],T,{isEmpty:()=>!1,enabled:t,initialData:c??void 0,initialDataCachedAt:s?.cachedAt??null,staleAfterMs:6e4}),D=E.state,O=D.data??c,k=l??O?.state??null,A=p?d:O?.rows??d,j=(0,_.useMemo)(()=>rv(k?.available,n(`claude.smallFastModelUnsetOption`)),[k?.available,n]),M=(0,_.useMemo)(()=>{let e=[1e5,2e5,25e4,3e5,35e4,4e5,5e5,6e5,75e4,ov,9e5,1e6].sort((e,t)=>e-t),t=k?.autoCompactWindow??null,r=t!==null&&!e.includes(t)?[...e,t].sort((e,t)=>e-t):e;return[{value:``,label:n(`claude.autoCompactDefault`,{value:sv(ov,i)})},...r.map(e=>({value:String(e),label:sv(e,i)}))]},[k?.autoCompactWindow,n,i]),N=async()=>{if(!k||w.current)return;w.current=!0,C(!0),g(``);let t=!k.enabled;try{await It(await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})}),n(`claude.saveFailed`)),u({...k,enabled:t}),E.refresh()}catch(e){y(!1),g(e instanceof Error&&e.message?e.message:n(`claude.networkError`))}finally{w.current=!1,C(!1)}},P=async()=>{if(!k)return;g(``);let t={};for(let e of A)e.from.trim()&&e.to.trim()&&(t[e.from.trim()]=e.to.trim());try{await It(await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:k.enabled,authMode:k.authMode,systemEnv:k.systemEnv,fastMode:k.fastMode,autoContext:k.autoContext,autoCompactWindow:k.autoCompactWindow,injectAgents:k.injectAgents,smallFastModel:k.smallFastModel,modelMap:t,webSearchSidecar:pv(k.webSearchSidecar),visionSidecar:pv(k.visionSidecar)})}),n(`claude.saveFailed`)),y(!0),g(n(`claude.saved`)),E.refresh()}catch(e){y(!1),g(e instanceof Error&&e.message?e.message:n(`claude.networkError`))}};if(D.kind===`disabled`&&!O)return null;if(D.showSkeleton&&!O)return(0,J.jsx)(Nl,{label:n(`claude.loading`),rows:3});if(D.kind===`failed-cold`){let e=D.error instanceof Error?D.error.message:n(`claude.loadFail`);return(0,J.jsxs)(`div`,{className:`claudecode-workspace-shell`,children:[(0,J.jsx)(Q,{tone:`err`,children:e}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>E.refresh(),children:n(`common.retry`)})]})}if(!k)return null;let F=[{id:`settings`,label:n(`claude.workspace.settings`),body:(0,J.jsx)(vv,{state:k,autoCompactOptions:M,availableModels:k.available??[],onStateChange:u})},{id:`quickstart`,label:n(`claude.quickstart`),body:(0,J.jsx)(yv,{manualEnv:lv(k)})},{id:`smallFast`,label:n(`claude.smallFastModel`),body:(0,J.jsx)(gv,{value:k.smallFastModel,tierHaikuModel:k.tierModels?.haiku,options:j,onChange:e=>u({...k,smallFastModel:e})})},{id:`modelMap`,label:n(`claude.modelMap`),meta:String(A.length),body:(0,J.jsx)(bv,{rows:A,onRowsChange:e=>{m(!0),f(e)}})},{id:`aliases`,label:n(`claude.aliases`),meta:String(k.aliases.length),body:(0,J.jsx)(Cv,{aliases:k.aliases})}],I=F.find(e=>e.id===b)??F[0],L=b===`settings`||b===`smallFast`||b===`modelMap`;return(0,J.jsxs)(`div`,{className:`claudecode-workspace-shell`,children:[h&&(0,J.jsx)(Q,{tone:v?`ok`:`err`,children:h}),D.showError&&(0,J.jsx)(Q,{tone:`err`,children:n(`claude.loadFail`)}),k&&(0,J.jsxs)(`div`,{className:`claudecode-connection-head`,children:[(0,J.jsx)(`span`,{id:`claudecode-connection-label`,children:n(`claude.enabledLabel`)}),(0,J.jsx)(Dt,{on:k.enabled,onClick:()=>void N(),disabled:S,label:n(`claude.toggleAria`)})]}),(0,J.jsxs)(`div`,{className:`claudecode-workspace-root`,children:[(0,J.jsx)(`aside`,{className:`claudecode-workspace-rail`,"aria-label":n(`claude.pageTitle`),children:(0,J.jsx)(`div`,{className:`claudecode-workspace-rail-list`,children:F.map(e=>(0,J.jsx)(`button`,{type:`button`,className:`claudecode-workspace-rail-row${b===e.id?` claudecode-workspace-rail-row--selected`:``}`,onClick:()=>x(e.id),"aria-current":b===e.id?`true`:void 0,children:(0,J.jsx)(`span`,{className:`claudecode-workspace-rail-name`,children:e.label})},e.id))})}),(0,J.jsxs)(`section`,{className:`claudecode-workspace-main`,"aria-label":I.label,children:[(0,J.jsxs)(`div`,{className:`ccw-main-head`,children:[(0,J.jsxs)(`h3`,{className:`ccw-main-title`,children:[I.label,I.meta==null?null:(0,J.jsx)(`span`,{className:`count`,children:I.meta})]}),(0,J.jsx)(`div`,{className:`claudecode-workspace-save`,"data-visible":L?`true`:`false`,children:(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:!L,tabIndex:L?0:-1,"aria-hidden":!L,onClick:()=>{P()},children:n(`common.save`)})})]}),(0,J.jsx)(`div`,{className:`ccw-body`,children:I.body})]})]})]})}function Tv(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 Ev(e){return new Set(Object.keys(e))}function Dv(e,t){return t!==null&&e===t}function Ov(e){return e||(typeof localStorage>`u`?void 0:localStorage)}function kv(e){return{read(t){let n=Ov(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=Ov(n);if(r)try{r.setItem(e,JSON.stringify([...t]))}catch{}}}}function Av(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}var jv=[`opus`,`fable`,`sonnet`,`haiku`],Mv=kv(`ocx.claudeDesktop.collapsedFamilies.v2`),Nv={opus:`claudeDesktop.family.opus`,fable:`claudeDesktop.family.fable`,sonnet:`claudeDesktop.family.sonnet`,haiku:`claudeDesktop.family.haiku`};function Pv(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 Fv(e){let t={...e.profile.assignments};for(let n of e.models){let e=t[n.route]??n.assignment;t[n.route]={family:jv.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 Iv(e,t){return e&&typeof e==`object`&&`error`in e&&typeof e.error==`string`?e.error:t}function Lv(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 Rv(e){return br(e)?.data??null}function zv(e){return br(e)?.cachedAt??null}function Bv(e){let t=Rv(e);return{held:t,data:t?.data??null,profile:t?.profile??null,savedProfile:t?.profile?Pv(t.profile):null,destinations:t?.data?Object.fromEntries(t.data.models.map(e=>[e.route,t.profile.assignments[e.route]?.family??`opus`])):{}}}function Vv({apiBase:e,active:t=!0,onPortChange:n}){let{t:r,locale:i}=ut(),a=nt.find(e=>e.code===i)?.htmlLang,o=`ocx.claude-desktop.v1:${e}`,s=`claude-desktop:${e}`,c=(0,_.useMemo)(()=>Bv(o),[o]),[l,u]=(0,_.useState)(()=>c.profile),[d,f]=(0,_.useState)(()=>c.savedProfile),[p,m]=(0,_.useState)(()=>c.destinations),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)({}),[w,T]=(0,_.useState)({}),[E,D]=(0,_.useState)(()=>Mv.read()??new Set(jv)),[O,k]=(0,_.useState)({}),A=(0,_.useRef)(null),j=(0,_.useCallback)(async t=>{let n=await It(await fetch(`${e}/api/claude-desktop`,{signal:t}),r(`claudeDesktop.loadFail`));if(!n||!(`profile`in n)||!(`models`in n))throw Error(Iv(n,r(`claudeDesktop.loadFail`)));let i=Fv(n),a={data:n,profile:i};if(t.aborted)throw Error(`Claude Desktop request aborted`);if(u(i),f(Pv(i)),m(Object.fromEntries(n.models.map(e=>[e.route,i.assignments[e.route]?.family??`opus`]))),Mv.read()===null){let e=Object.fromEntries(jv.map(e=>[e,0]));for(let t of n.models)e[i.assignments[t.route]?.family??`opus`]+=1;D(Ev(e))}return xr(o,a),a},[e,o,r,m,u,f]),M=$(s,[e],j,{isEmpty:()=>!1,enabled:t,initialData:c.held??void 0,initialDataCachedAt:zv(o),staleAfterMs:6e4}),N=M.state,P=N.data??(c.data&&c.profile?{data:c.data,profile:c.profile}:null),F=P?.data??null,I=l??P?.profile??null,L=d??P?.profile??null,R=P?Object.fromEntries(P.data.models.map(e=>[e.route,P.profile.assignments[e.route]?.family??`opus`])):{},z=Object.keys(p).length>0?p:R;(0,_.useEffect)(()=>{if(n){if(typeof F?.port==`number`){n(F.port);return}N.kind===`failed-cold`&&n(null)}},[F?.port,N.kind,n]);let B=(0,_.useMemo)(()=>I!==null&&L!==null&&JSON.stringify(I)!==JSON.stringify(L),[I,L]),V=(0,_.useMemo)(()=>{let e=Object.fromEntries(jv.map(e=>[e,[]]));if(!F||!I)return e;for(let t of F.models)e[I.assignments[t.route]?.family??`opus`].push(t);return e},[F,I]),H=(0,_.useMemo)(()=>{let e={};for(let t of jv){let n=V[t].filter(e=>e.available).map(e=>e.route).sort(),r=I?.defaults[t]??null;e[t]=r&&n.includes(r)?r:n[0]??null}return e},[V,I]),U=`ocx.claude-desktop.status.v1:${e}`,W=`claude-desktop-status:${e}`,ee=br(U),G=$(W,[e],async t=>{let n=await Lt(await fetch(`${e}/api/claude-desktop/status`,{signal:t}));if(!n)throw Error(`Claude Desktop status unavailable`);return xr(U,n),n},{isEmpty:()=>!1,pollMs:5e3,enabled:t,initialData:ee?.data??void 0}),K=G.state,q=K.data??ee?.data??null,Y=K.showError,te=(e,t)=>{!I||I.assignments[e]?.family===t||(u(n=>{if(!n)return n;let r=n.assignments[e];if(!r||r.family===t)return n;let i={...n.assignments,[e]:{...r,family:t}},a={...n.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[t]===null&&(a[t]=e),{...n,assignments:i,defaults:a}}),m(n=>({...n,[e]:t})),y(r(`claudeDesktop.moved`,{route:e,family:r(Nv[t])})))},ne=e=>{let t=Av(E,e);Mv.write(t),D(t)},re=async t=>{if(!(!I||b)){x(`save`),g(null);try{await It(await fetch(`${e}/api/claude-desktop`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profile:I})}),r(`claudeDesktop.saveFailed`)),f(Pv(I)),t?(x(`apply`),(await It(await fetch(`${e}/api/claude-desktop/apply`,{method:`POST`}),r(`claudeDesktop.applyFailed`)))?.saved===!1?(g({tone:`warn`,text:r(`claudeDesktop.appliedMarkerUnsaved`)}),y(r(`claudeDesktop.appliedMarkerUnsaved`))):(g({tone:`ok`,text:r(`claudeDesktop.savedApplied`)}),y(r(`claudeDesktop.savedAppliedAnnounce`)))):(g({tone:`ok`,text:r(`claudeDesktop.saved`)}),y(r(`claudeDesktop.savedAnnounce`))),G.refresh()}catch(e){let t=e instanceof Error?e.message:r(`claudeDesktop.updateFailed`);g({tone:`err`,text:t}),y(t)}finally{x(null)}}},ie=()=>{if(!I)return;let e=URL.createObjectURL(new Blob([`${JSON.stringify(I,null,2)}\n`],{type:`application/json`})),t=document.createElement(`a`);t.href=e,t.download=`claude-desktop-profile.json`,t.click(),URL.revokeObjectURL(e),y(r(`claudeDesktop.exported`))},ae=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t)try{let e=JSON.parse(await t.text());if(e.version!==1||!e.assignments||!e.defaults)throw Error(r(`claudeDesktop.importExpected`));let n=Fv({...F,profile:e});u(n),g({tone:`ok`,text:r(`claudeDesktop.importReady`)}),y(r(`claudeDesktop.importedAnnounce`))}catch(e){let t=e instanceof Error?e.message:r(`claudeDesktop.importInvalid`);g({tone:`err`,text:t}),y(r(`claudeDesktop.importFailed`,{error:t}))}},oe=(e,t)=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);n&&te(n,t)};if(N.kind===`disabled`&&!P)return null;if(N.showSkeleton&&!P)return(0,J.jsx)(Nl,{label:r(`claudeDesktop.loading`),rows:4});if(N.kind===`failed-cold`){let e=N.error instanceof Error?N.error.message:r(`claudeDesktop.loadFail`);return(0,J.jsxs)(`div`,{className:`claude-desktop-error`,children:[(0,J.jsx)(Q,{tone:`err`,children:e}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>M.refresh(),children:r(`claudeDesktop.retry`)})]})}return!F||!I?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`claude-desktop-toolbar`,children:(0,J.jsxs)(`div`,{className:`claude-profile-tools`,children:[(0,J.jsx)(`input`,{ref:A,type:`file`,accept:`application/json,.json`,hidden:!0,onChange:e=>void ae(e)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A.current?.click(),children:r(`claudeDesktop.importJson`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:ie,children:r(`claudeDesktop.exportJson`)})]})}),(0,J.jsxs)(`div`,{className:`claude-status-bar ${Y&&!q?`not-applied`:q?q.desiredEnabled?q.activeProfile===!1?`not-applied`:q.stale?`stale`:q.applied?`applied`:`not-applied`:`not-applied`:`pending`}`,"aria-busy":!q&&!Y||void 0,children:[(0,J.jsx)(`span`,{className:`claude-status-dot`}),(0,J.jsx)(`span`,{children:Y&&!q?r(`claudeDesktop.loadFail`):q?q.desiredEnabled?q.activeProfile===!1?r(`claudeDesktop.status.notActiveProfile`):q.stale?r(`claudeDesktop.status.stale`):q.applied?r(`claudeDesktop.status.applied`):r(`claudeDesktop.status.notApplied`):r(`claudeDesktop.status.disabled`):r(`claudeDesktop.loading`)}),q?.health.lastRequestAt&&(0,J.jsxs)(`span`,{className:`claude-status-health`,children:[r(`claudeDesktop.health.lastRequest`),`:`,` `,new Date(q.health.lastRequestAt).toLocaleTimeString(a)]}),q&&q.health.requestCount>0&&(0,J.jsx)(`span`,{className:`claude-status-health`,children:r(`claudeDesktop.health.stats`,{count:q.health.requestCount,errors:q.health.errorCount})})]}),(0,J.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:v}),h&&(0,J.jsx)(Q,{tone:h.tone,children:h.text}),N.showError&&(0,J.jsx)(Q,{tone:`err`,children:r(`claudeDesktop.loadFail`)}),Y&&q&&(0,J.jsx)(Q,{tone:`err`,children:r(`claudeDesktop.loadFail`)}),(0,J.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,J.jsx)(`span`,{className:`claude-dirty${B?` active`:``}`,children:r(B?`claudeDesktop.unsaved`:`claudeDesktop.upToDate`)}),(0,J.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!B||b!==null,onClick:()=>void re(!1),children:r(b===`save`?`claudeDesktop.saving`:`common.save`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:b!==null,onClick:()=>void re(!0),children:b===`apply`?r(`claudeDesktop.applying`):b===`save`?r(`claudeDesktop.saving`):q?.desiredEnabled===!1?r(`claudeDesktop.enableApply`):r(`claudeDesktop.saveApply`)})]})]}),F.models.length===0&&(0,J.jsx)(At,{title:r(`claudeDesktop.emptyTitle`),children:r(`claudeDesktop.emptyHint`)}),(0,J.jsx)(`div`,{className:`ocx-group-stack`,"aria-label":r(`claudeDesktop.assignmentsLabel`),children:jv.map(e=>{let t=V[e],n=Tv(t,S[e]??``,w[e]??6),i=E.has(e),a=H[e];return(0,J.jsxs)(`section`,{className:`ocx-group${i?` collapsed`:``}`,"aria-labelledby":`claude-lane-${e}`,onDragOver:e=>e.preventDefault(),onDrop:t=>oe(t,e),children:[(0,J.jsxs)(`header`,{className:`ocx-group-head${i?``:` open`}`,children:[(0,J.jsx)(`h3`,{id:`claude-lane-${e}`,className:`ocx-group-heading`,children:(0,J.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!i,"aria-controls":`claude-lane-body-${e}`,onClick:()=>ne(e),children:[(0,J.jsx)(Ce,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:i?`none`:`rotate(90deg)`}}),(0,J.jsx)(`span`,{className:`ocx-group-name`,children:r(Nv[e])}),(0,J.jsx)(`span`,{className:`ocx-group-count`,children:r(t.length===1?`claudeDesktop.modelCountOne`:`claudeDesktop.modelCountMany`,{count:t.length})}),a&&(0,J.jsx)(`code`,{className:`claude-lane-default`,title:a,children:a})]})}),t.length>0&&I.defaults[e]===null&&(0,J.jsx)(`span`,{className:`claude-default-needed`,children:r(`claudeDesktop.chooseDefault`)}),a&&a!==I.defaults[e]&&(0,J.jsx)(`span`,{className:`claude-default-needed`,title:a,children:r(`claudeDesktop.temporaryDefault`)})]}),!i&&(0,J.jsxs)(`div`,{id:`claude-lane-body-${e}`,children:[n.showSearch&&(0,J.jsx)(`input`,{className:`input claude-lane-search`,type:`search`,placeholder:r(`models.search`),"aria-label":r(`models.search`),value:S[e]??``,onChange:t=>{let n=t.target.value;C(t=>({...t,[e]:n})),T(t=>({...t,[e]:6}))}}),(0,J.jsxs)(`div`,{className:`claude-lane-models`,children:[t.length===0?(0,J.jsx)(`div`,{className:`claude-lane-empty`,children:r(`claudeDesktop.laneEmpty`)}):n.noMatch?(0,J.jsx)(`div`,{className:`claude-lane-empty`,children:r(`claudeDesktop.laneNoMatch`)}):n.shown.map(t=>{let n=I.assignments[t.route],i=Lv(t.contextWindow,r),a=z[t.route]??`opus`,o=O[t.route]??Dv(t.route,H[e]);return(0,J.jsxs)(`article`,{className:`claude-model-card${o?` open`:``}`,draggable:t.available,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.route)},children:[(0,J.jsxs)(`button`,{type:`button`,className:`claude-model-summary`,"aria-expanded":o,"aria-controls":`claude-model-body-${t.route}`,onClick:()=>k(e=>({...e,[t.route]:!o})),children:[(0,J.jsx)(Ce,{className:`ocx-chevron`,width:12,height:12,"aria-hidden":`true`,style:{transform:o?`rotate(90deg)`:`none`}}),(0,J.jsxs)(`span`,{className:`claude-model-names`,children:[(0,J.jsx)(`strong`,{title:t.label,children:t.label}),(0,J.jsx)(`code`,{title:t.route,children:t.route})]}),i&&(0,J.jsx)(`span`,{className:`claude-model-context`,children:i}),!i&&(0,J.jsx)(`span`,{className:`claude-model-context claude-model-context-unknown`,children:r(`claudeDesktop.contextUnknown`)}),t.supports1m===!0&&(0,J.jsx)(`span`,{className:`claude-1m-chip`,children:r(`claudeDesktop.supports1m`)}),t.effortSupported===!1&&(0,J.jsx)(`span`,{className:`claude-effort-badge off`,children:r(`claudeDesktop.effort.displayOnly`)}),t.effortSupported===!0&&(0,J.jsx)(`span`,{className:`claude-effort-badge on`,children:r(`claudeDesktop.effort.supported`)}),I.defaults[e]===t.route&&(0,J.jsx)(`span`,{className:`claude-row-default`,children:r(`claudeDesktop.defaultBadge`)}),(0,J.jsx)(`span`,{className:`badge ${t.available?`badge-green`:`badge-muted`}`,children:t.available?r(`claudeDesktop.available`):r(`claudeDesktop.unavailable`)})]}),o&&(0,J.jsxs)(`div`,{className:`claude-model-body`,id:`claude-model-body-${t.route}`,children:[H[e]===t.route&&I.defaults[e]!==t.route&&(0,J.jsx)(`span`,{className:`claude-effective-default`,children:r(`claudeDesktop.temporaryDefault`)}),(0,J.jsxs)(`div`,{className:`claude-field`,children:[(0,J.jsx)(`span`,{children:r(`claudeDesktop.alias`)}),(0,J.jsx)(`code`,{className:`claude-alias`,title:n.alias,children:n.alias})]}),(0,J.jsxs)(`label`,{className:`claude-default-radio`,children:[(0,J.jsx)(`input`,{type:`radio`,name:`default-${e}`,checked:I.defaults[e]===t.route,disabled:!t.available,onChange:()=>u(n=>n&&{...n,defaults:{...n.defaults,[e]:t.route}})}),r(`claudeDesktop.useAsDefault`,{family:r(Nv[e])})]}),(0,J.jsxs)(`div`,{className:`claude-move-row`,children:[(0,J.jsx)(`label`,{htmlFor:`move-${t.route}`,children:r(`claudeDesktop.moveTo`)}),(0,J.jsx)(`select`,{id:`move-${t.route}`,className:`input`,value:a,disabled:!t.available,onChange:e=>m(n=>({...n,[t.route]:e.target.value})),children:jv.map(e=>(0,J.jsx)(`option`,{value:e,children:r(Nv[e])},e))}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:!t.available||a===e,onClick:()=>te(t.route,a),children:r(`claudeDesktop.move`)})]})]})]},t.route)}),n.hidden>0&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm claude-lane-more`,onClick:()=>T(t=>({...t,[e]:(t[e]??6)+6})),children:r(`models.showMore`,{n:n.hidden})})]})]})]},e)})})]})}var Hv=`integrations/claude`,Uv=`integrations/claude/desktop`;function Wv(e=typeof window<`u`?window.location.hash:``){return pt(e)===Uv?`desktop`:`code`}function Gv(e){let t=vr(`ocx.claude-desktop.v1:${e}`);return typeof t?.data?.port==`number`?t.data.port:null}function Kv({apiBase:e,active:t=!0}){let[n,r]=(0,_.useState)(Wv),i=Z(),a=(0,_.useRef)(null),o=(0,_.useRef)(null),s=Gv(e),[c,l]=(0,_.useState)(null),u=c?.base===e?c.port:s,d=c?.base===e,f=(0,_.useCallback)(t=>{l(n=>n?.base===e&&n.port===t?n:{base:e,port:t})},[e]);(0,_.useEffect)(()=>{let e=()=>r(Wv());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let p=e=>{ht(e===`desktop`?Uv:Hv),r(e),window.requestAnimationFrame(()=>{(e===`code`?a:o).current?.focus({preventScroll:!0})})},m=e=>{e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),p(n===`code`?`desktop`:`code`)):e.key===`Home`?(e.preventDefault(),p(`code`)):e.key===`End`&&(e.preventDefault(),p(`desktop`))};return(0,J.jsxs)(`section`,{className:`claude-page`,children:[(0,J.jsxs)(`div`,{className:`claude-page-intro`,children:[(0,J.jsx)(`div`,{className:`page-head`,children:(0,J.jsx)(`h2`,{children:i(n===`code`?`claude.pageTitle`:`claudeDesktop.title`)})}),n===`code`?(0,J.jsx)(`p`,{className:`page-sub`,children:i(`claude.subtitle`)}):(0,J.jsx)(`p`,{className:`page-sub`,children:u==null?i(d?`claudeDesktop.loadFail`:`claudeDesktop.loading`):i(`claudeDesktop.subtitle`,{port:u})})]}),(0,J.jsxs)(`div`,{className:`claude-tabs`,role:`tablist`,"aria-label":i(`claude.tabsLabel`),children:[(0,J.jsx)(`button`,{type:`button`,role:`tab`,ref:a,"aria-selected":n===`code`,"aria-controls":`claude-code-panel`,id:`claude-code-tab`,className:n===`code`?`active`:``,tabIndex:n===`code`?0:-1,onKeyDown:m,onClick:()=>p(`code`),children:i(`claude.tabCode`)}),(0,J.jsx)(`button`,{type:`button`,role:`tab`,ref:o,"aria-selected":n===`desktop`,"aria-controls":`claude-desktop-panel`,id:`claude-desktop-tab`,className:n===`desktop`?`active`:``,tabIndex:n===`desktop`?0:-1,onKeyDown:m,onClick:()=>p(`desktop`),children:i(`claude.tabDesktop`)})]}),(0,J.jsx)(`div`,{id:`claude-code-panel`,role:`tabpanel`,"aria-labelledby":`claude-code-tab`,hidden:n!==`code`,children:(0,J.jsx)(wv,{apiBase:e,active:t&&n===`code`},e)}),(0,J.jsx)(`div`,{id:`claude-desktop-panel`,role:`tabpanel`,"aria-labelledby":`claude-desktop-tab`,hidden:n!==`desktop`,children:(0,J.jsx)(Vv,{apiBase:e,active:t&&n===`desktop`,onPortChange:f},e)})]})}function qv(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 Jv=kv(`ocx.grok.collapsedGroups.v2`),Yv=[{id:`native`,tkey:`grok.groupNative`},{id:`routed`,tkey:`grok.groupRouted`}],Xv=new Set(Yv.map(e=>e.id));function Zv(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 Qv({apiBase:e,active:t=!0}){let n=Z(),r=`ocx.grok.status.v1:${e}`,i=br(r),a=i?.data??null,[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(()=>Jv.read()??new Set(Xv)),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(``),g=(0,_.useCallback)(async t=>{let i=await It(await fetch(`${e}/api/grok`,{signal:t}),n(`grok.loadFail`));if(!i)throw Error(n(`grok.loadFail`));let a={...i,candidates:i.candidates??[],excluded:i.excluded??[]};return xr(r,a),a},[e,r,n]),v=`grok-status:${e}`,y=$(v,[e],g,{isEmpty:()=>!1,initialData:a??void 0,initialDataCachedAt:i?.cachedAt??null,staleAfterMs:6e4,enabled:t}),{state:b}=y,x=y.refresh,S=b.data??a,C=(0,_.useMemo)(()=>new Set(S?.excluded??[]),[S]),w=o??C,T=(0,_.useMemo)(()=>o!==null&&(o.size!==C.size||[...o].some(e=>!C.has(e))),[o,C]),E=(0,_.useMemo)(()=>new Map((S?.models??[]).map(e=>[e.id,e.alias])),[S]),D=e=>{let t=Av(c,e);Jv.write(t),l(t)},O=e=>{let t=e?new Set(Yv.map(e=>e.id)):new Set;Jv.write(t),l(t)},k=(e,t)=>{s(n=>{let r=new Set(n??C);return t?r.delete(e):r.add(e),r})},A=async t=>{if(!u){d(`save`),p(null);try{await It(await fetch(`${e}/api/grok/selection`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({excluded:[...w]})}),n(`grok.saveFailed`));let i=[...w];if(S&&K(v,{...S,excluded:i}),s(null),t){d(`apply`);let t=await fetch(`${e}/api/grok/apply`,{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??e.error??n(`grok.applyFailed`))}let r=await t.json().catch(()=>({}));r.skippedReason?(p({tone:`err`,text:r.message??n(`grok.applySkipped`)}),h(r.message??n(`grok.applySkipped`))):(p({tone:`ok`,text:n(`grok.savedApplied`)}),h(n(`grok.savedApplied`))),await x()}else p({tone:`ok`,text:n(`grok.saved`)}),h(n(`grok.saved`)),S&&xr(r,{...S,excluded:i})}catch(e){let t=e instanceof Error?e.message:n(`grok.saveFailed`);p({tone:`err`,text:t}),h(t)}finally{d(null)}}};if(b.showSkeleton&&!S)return(0,J.jsx)(`section`,{className:`grok-page`,children:(0,J.jsx)(Nl,{label:n(`grok.loading`),rows:4})});if(b.kind===`failed-cold`){let e=b.error instanceof Error?b.error.message:n(`grok.loadFail`);return(0,J.jsxs)(`section`,{className:`grok-page`,children:[(0,J.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:e}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>x(),children:n(`common.retry`)})]})}return(0,J.jsxs)(`section`,{className:`grok-page`,"aria-busy":b.refreshing||void 0,children:[(0,J.jsx)(`h2`,{className:`page-title`,children:n(`grok.title`)}),(0,J.jsx)(`p`,{className:`page-sub`,children:n(`grok.subtitle`)}),(0,J.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:m}),f&&(0,J.jsx)(Q,{tone:f.tone,children:f.text}),b.showError&&(0,J.jsx)(Q,{tone:`err`,children:n(`grok.loadFail`)}),S&&S.candidates.length>0&&(0,J.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,J.jsx)(`span`,{className:`claude-dirty${T?` active`:``}`,children:n(T?`grok.unsaved`:`grok.upToDate`)}),(0,J.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!T||u!==null,onClick:()=>void A(!1),children:n(u===`save`?`grok.saving`:`common.save`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!T||u!==null,onClick:()=>void A(!0),children:n(u===`apply`?`grok.applying`:u===`save`?`grok.saving`:`grok.saveApply`)})]})]}),S?.present?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`grok-endpoint`,children:[(0,J.jsx)(`span`,{children:n(`grok.endpoint`)}),(0,J.jsx)(`code`,{children:S.baseUrl??`—`})]}),(0,J.jsx)(`p`,{className:`page-sub`,children:(0,J.jsx)(`code`,{children:S.configPath})})]}):(0,J.jsxs)(At,{title:n(`grok.notConfiguredTitle`),children:[n(`grok.notConfiguredHint`),(0,J.jsx)(`br`,{}),(0,J.jsx)(`code`,{children:S?.configPath})]}),S&&S.candidates.length>0&&(0,J.jsxs)(`div`,{className:`ocx-group-stack`,children:[(0,J.jsxs)(`div`,{className:`row`,style:{gap:6,margin:`2px 0 10px`},children:[(0,J.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>O(!0),disabled:u!==null,children:[(0,J.jsx)(Ce,{width:12,height:12,"aria-hidden":`true`}),` `,n(`models.collapseAll`)]}),(0,J.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>O(!1),disabled:u!==null,children:[(0,J.jsx)(Ce,{width:12,height:12,"aria-hidden":`true`,style:{transform:`rotate(90deg)`}}),` `,n(`models.expandAll`)]})]}),Yv.map(e=>{let t=qv(S.candidates,E,w,e.id);if(t.total===0)return null;let r=c.has(e.id);return(0,J.jsxs)(`section`,{className:`ocx-group${r?` collapsed`:``}`,"aria-labelledby":`grok-group-${e.id}`,children:[(0,J.jsx)(`header`,{className:`ocx-group-head${r?``:` open`}`,children:(0,J.jsx)(`h3`,{id:`grok-group-${e.id}`,className:`ocx-group-heading`,children:(0,J.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!r,"aria-controls":`grok-group-body-${e.id}`,onClick:()=>D(e.id),children:[(0,J.jsx)(Ce,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:r?`none`:`rotate(90deg)`}}),(0,J.jsx)(`span`,{className:`ocx-group-name`,children:n(e.tkey)}),(0,J.jsx)(`span`,{className:`ocx-group-count`,children:n(`grok.enabledCount`,{on:t.enabled,total:t.total})})]})})}),!r&&(0,J.jsx)(`div`,{id:`grok-group-body-${e.id}`,className:`grok-model-list`,children:t.rows.map(e=>(0,J.jsxs)(`div`,{className:`grok-model-row`,children:[(0,J.jsx)(Dt,{on:e.enabled,onClick:()=>k(e.id,!e.enabled),disabled:u!==null,label:n(`grok.toggleModel`,{id:e.id})}),(0,J.jsxs)(`span`,{className:`grok-model-names`,children:[(0,J.jsx)(`strong`,{title:e.id,children:e.id}),(0,J.jsx)(`code`,{title:e.alias??void 0,children:e.alias??`—`})]}),(0,J.jsx)(`span`,{className:`claude-model-context`,children:Zv(e.contextWindow,n)})]},e.id))})]},e.id)})]})]})}async function $v(e,t){try{let n=await fetch(`${e}/api/native-integrations/cursor`,{signal:t});if(!n.ok)return null;let r=await Lt(n);return!r||typeof r!=`object`||!r.gateway||!r.privateInference?null:r}catch{return null}}function ey({value:e,label:t}){let n=Z(),[r,i]=(0,_.useState)(!1),a=(0,_.useRef)(null);(0,_.useEffect)(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);let o=async()=>{try{await navigator.clipboard.writeText(e),i(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>i(!1),1500)}catch{i(!1)}};return(0,J.jsxs)(`div`,{className:`cursor-gateway-row`,children:[(0,J.jsx)(`span`,{className:`cursor-gateway-label`,children:t}),(0,J.jsx)(`code`,{className:`cursor-gateway-value`,children:e}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void o(),"aria-label":`${n(`integrations.cursor.copy`)} ${t}`,children:n(r?`integrations.cursor.copied`:`integrations.cursor.copy`)})]})}function ty({labelKey:e,installed:t,path:n,version:r}){let i=Z();return(0,J.jsxs)(`div`,{className:`cursor-detect-row`,"data-installed":t?`true`:`false`,children:[(0,J.jsx)(`span`,{className:`cursor-detect-name`,children:i(e)}),(0,J.jsx)(`span`,{className:`badge ${t?`badge-green`:`badge-muted`}`,children:i(t?`integrations.cursor.detected`:`integrations.cursor.notFound`)}),t&&n&&(0,J.jsxs)(`span`,{className:`cursor-detect-path muted`,children:[r?`${r} · `:``,n]})]})}function ny({apiBase:e,active:t}){let{t:n,locale:r}=ut(),[i,a]=(0,_.useState)(()=>Date.now()),o=(0,_.useCallback)(async t=>{let n=await $v(e,t);if(!n)throw Error(`cursor status unavailable`);return a(Date.now()),n},[e]),s=$(`integration-cursor-page:${e}`,[e],o,{isEmpty:()=>!1,enabled:t,pollMs:15e3,pauseWhenHidden:!0}),c=s.state.data??null,l=ki(n);return(0,J.jsxs)(`section`,{className:`integration-native-page cursor-page`,"aria-labelledby":`cursor-integration-title`,children:[(0,J.jsx)(`h3`,{id:`cursor-integration-title`,children:n(`integrations.cursor.title`)}),(0,J.jsx)(`p`,{children:n(`integrations.cursor.intro`)}),s.state.showError&&(0,J.jsx)(Q,{tone:`err`,children:n(`integrations.cursor.unavailable`)}),!c&&!s.state.showError&&(0,J.jsx)(Nl,{label:n(`integrations.cursor.loading`),rows:4}),c&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`cursor-card`,children:[(0,J.jsx)(`h4`,{children:n(`integrations.cursor.detection`)}),(0,J.jsx)(ty,{labelKey:`integrations.cursor.privateInference`,installed:c.privateInference.installed,path:c.privateInference.path,version:c.privateInference.version}),(0,J.jsx)(ty,{labelKey:`integrations.cursor.regular`,installed:c.regularCursor.installed,path:c.regularCursor.path,version:null}),!c.privateInference.installed&&(0,J.jsxs)(Q,{tone:`warn`,children:[n(c.regularCursor.installed?`integrations.cursor.regularOnly`:`integrations.cursor.nothingFound`),` `,(0,J.jsx)(`a`,{href:c.guideUrl,target:`_blank`,rel:`noreferrer`,"data-cursor-guide":`notice`,children:n(`integrations.cursor.guide`)})]})]}),(0,J.jsxs)(`div`,{className:`cursor-card`,children:[(0,J.jsx)(`h4`,{children:n(`integrations.cursor.gateway`)}),(0,J.jsx)(`p`,{className:`muted`,children:n(`integrations.cursor.gatewayHint`)}),(0,J.jsx)(ey,{label:n(`integrations.cursor.baseUrl`),value:c.gateway.baseUrl}),c.gateway.apiKeyMode===`placeholder`?(0,J.jsx)(ey,{label:n(`integrations.cursor.apiKey`),value:c.gateway.placeholder}):(0,J.jsxs)(`div`,{className:`cursor-gateway-row`,children:[(0,J.jsx)(`span`,{className:`cursor-gateway-label`,children:n(`integrations.cursor.apiKey`)}),(0,J.jsx)(`span`,{className:`cursor-gateway-value`,children:n(`integrations.cursor.apiKeyCredential`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>ht(`integrations/keys`),children:n(`integrations.tab.keys`)})]})]}),(0,J.jsxs)(`div`,{className:`cursor-card`,"data-seen":c.lastSeen?`true`:`false`,children:[(0,J.jsx)(`h4`,{children:n(`integrations.cursor.connection`)}),c.lastSeen?(0,J.jsx)(`p`,{children:(0,J.jsx)(`span`,{className:`badge ${i-c.lastSeen.at<864e5?`badge-green`:`badge-muted`}`,children:n(`integrations.cursor.seen`,{time:Oi(c.lastSeen.at,l,i),ua:c.lastSeen.userAgent})})}):(0,J.jsx)(`p`,{className:`muted`,children:n(`integrations.cursor.neverSeen`)})]}),(0,J.jsxs)(`div`,{className:`cursor-card`,children:[(0,J.jsx)(`h4`,{children:n(`integrations.cursor.models`)}),(0,J.jsx)(`p`,{className:`muted`,children:c.effortTable.source===`bundle`?n(`integrations.cursor.ladderFromBundle`,{version:c.effortTable.version??n(`integrations.cursor.unknownVersion`)}):n(`integrations.cursor.ladderFromStatic`)}),(0,J.jsxs)(`table`,{className:`cursor-model-table`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:n(`integrations.cursor.colModel`)}),(0,J.jsx)(`th`,{children:n(`integrations.cursor.colReasoning`)}),(0,J.jsx)(`th`,{children:n(`integrations.cursor.colContext`)})]})}),(0,J.jsx)(`tbody`,{children:c.models.map(e=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsx)(`code`,{children:e.id})}),(0,J.jsx)(`td`,{children:e.reasoning?e.reasoning.join(` · `):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`cursor-no-control`,title:n(`integrations.cursor.noControlTitle`),"aria-label":n(`integrations.cursor.noControlTitle`),children:n(`integrations.cursor.noControl`)}),e.effortRows.length>0?(0,J.jsx)(`span`,{className:`cursor-effort-rows`,children:n(e.effortRows.length===1?`integrations.cursor.effortRowsOne`:`integrations.cursor.effortRowsMany`,{n:e.effortRows.length})}):(0,J.jsx)(`span`,{className:`cursor-effort-rows muted`,children:n(`integrations.cursor.effortRowsOff`)})]})}),(0,J.jsx)(`td`,{children:e.context?`${Bn(e.context.defaultWindow,r)} · ${Bn(e.context.longWindow,r)}`:n(`integrations.cursor.singleWindow`)})]},e.id))})]}),c.models.some(e=>e.tableLess)&&(0,J.jsx)(`p`,{className:`muted`,"data-cursor-tableless-hint":!0,children:n(`integrations.cursor.tableLessHint`)})]}),(0,J.jsx)(`p`,{children:(0,J.jsx)(`a`,{href:c.guideUrl,target:`_blank`,rel:`noreferrer`,children:n(`integrations.cursor.guide`)})})]})]})}var ry={"not-installed":`integrations.state.notInstalled`,unknown:`integrations.state.unknown`,absent:`integrations.state.absent`,current:`integrations.state.current`,stale:`integrations.state.stale`,conflict:`integrations.state.conflict`,unsafe:`integrations.state.unsafe`},iy={"not-installed":`badge badge-muted`,unknown:`badge badge-muted`,absent:`badge badge-muted`,current:`badge badge-green`,stale:`badge badge-amber`,conflict:`badge integration-badge--danger`,unsafe:`badge integration-badge--danger-outline`};function ay({state:e,installed:t,id:n}){let r=Z(),i=e===`unknown`||e===`not-installed`||t?e:`not-installed`;return(0,J.jsx)(`span`,{id:n,className:iy[i],"data-integration-state":i,children:r(ry[i])})}function oy({copyKey:e,vars:t}){let n=Z()(e,t),r=t?.path;if(!r||!n.includes(r))return(0,J.jsx)(`p`,{children:n});let[i,...a]=n.split(r);return(0,J.jsxs)(`p`,{children:[i,(0,J.jsx)(`code`,{children:r}),a.join(r)]})}function sy({copy:e,onConfirm:t,onClose:n}){let r=Z(),i=(0,_.useRef)(null),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(null),l=`integration-consequence-dialog-title`;(0,_.useEffect)(()=>{let e=i.current;return e&&!e.open&&e.showModal(),()=>{e?.open&&e.close()}},[]);let u=(0,_.useCallback)(e=>{e.preventDefault(),a||n()},[n,a]),d=(0,_.useCallback)(async()=>{if(!a){o(!0),c(null);try{await t()}catch(e){c(e instanceof Error?e.message:r(`integrations.error.generic`)),o(!1)}}},[t,a,r]),f=[(0,J.jsx)(oy,{copyKey:e.changesKey,vars:e.vars},`changes`),(0,J.jsx)(oy,{copyKey:e.breakageKey,vars:e.vars},`breakage`),(0,J.jsx)(oy,{copyKey:e.undoKey,vars:e.vars},`undo`)];return e.sideEffectKey&&f.push((0,J.jsx)(oy,{copyKey:e.sideEffectKey,vars:e.vars},`side-effect`)),(0,J.jsxs)(`dialog`,{ref:i,className:`modal-overlay`,"aria-labelledby":l,onCancel:u,children:[(0,J.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":r(`common.close`),tabIndex:-1,onClick:()=>{a||n()}}),(0,J.jsxs)(`div`,{className:`modal-card integration-consequence-dialog`,role:`document`,children:[(0,J.jsxs)(`div`,{className:`modal-head`,children:[(0,J.jsx)(`h3`,{id:l,children:r(e.titleKey,e.vars)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:n,disabled:a,children:r(`common.close`)})]}),(0,J.jsx)(`div`,{className:`integration-consequence-body`,children:f}),s&&(0,J.jsx)(Q,{tone:`err`,children:s}),(0,J.jsx)(`div`,{className:`modal-actions`,children:(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>void d(),disabled:a,children:r(e.confirmKey)})})]})]})}var cy=[`opencode`,`pi`,`omp`,`hermes`,`openclaw`,`kimi`,`gajae`,`dsh`,`mcode`,`zcode`,`prime`,`aside`],ly=new Set([`not_installed`,`conflict`,`unsafe`,`non_loopback`,`drift_requires_confirm`,`snapshot_expired`,`write_failed`]),uy=new Set([`integration_unsafe`,`integration_conflict`,`integration_drift_confirmation_required`,`integration_snapshot_expired`,`integration_mutation_failed`]),dy=new Set([`absent`,`current`,`stale`,`conflict`,`unsafe`]);function fy(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function py(e){return!fy(e)||!ly.has(String(e.reason))?!1:typeof e.error==`string`&&uy.has(String(e.code))&&cy.includes(e.clientId)&&dy.has(String(e.state))&&typeof e.message==`string`}var my=class extends Error{refusal;status;body;constructor(e,t){let n=py(t)?t:null;super(n?.message??t.error??t.message??String(e)),this.name=`IntegrationApiError`,this.status=e,this.body=t,this.refusal=n}};function hy(e){return e instanceof my&&e.status===404&&e.body.code===`integration_operation_not_found`}async function gy(e){try{let t=await e.json();return fy(t)?t:{}}catch{return{}}}async function _y(e){if(!e.ok)throw new my(e.status,await gy(e));let t=await Lt(e);if(t==null)throw new my(e.status,{});return t}async function vy(e,t){return _y(await fetch(`${e}/api/client-integrations`,{signal:t}))}async function yy(e,t,n){return _y(await fetch(`${e}/api/client-integrations/${encodeURIComponent(t)}`,{signal:n}))}async function by(e,t,n){let r=t?`?client=${encodeURIComponent(t)}`:``;return _y(await fetch(`${e}/api/client-integrations/journal${r}`,{signal:n}))}async function xy(e,t,n,r,i){return _y(await fetch(`${e}/api/client-integrations/${encodeURIComponent(t)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i===!0?{enabled:n,overwriteConflict:!0}:{enabled:n}),signal:r}))}async function Sy(e,t,n=!1,r){return _y(await fetch(`${e}/api/client-integrations/restore`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({opId:t,confirmDrift:n}),signal:r}))}async function Cy(e,t,n){return _y(await fetch(`${e}/api/client-integrations/journal?opId=${encodeURIComponent(t)}`,{method:`DELETE`,signal:n}))}async function wy(e){try{let t=await e;return t.ok?await Lt(t)??null:null}catch{return null}}async function Ty(e,t){let n=await wy(fetch(`${e}/api/startup-health`,{signal:t}));return n?{routingInjected:n.routingInjected===!0,status:typeof n.status==`string`?n.status:void 0,recommendedCommand:typeof n.recommendedCommand==`string`?n.recommendedCommand:null}:null}async function Ey(e,t){let n=await fetch(`${e}/api/keys`,{signal:t});if(!n.ok)throw Error(`/api/keys responded ${n.status}`);let r=await Lt(n);if(!r||!Array.isArray(r.keys))throw Error(`/api/keys returned an unexpected body`);return r.keys.length}async function Dy(e,t){let n=await wy(fetch(`${e}/api/claude-code`,{signal:t}));return n?{enabled:n.enabled===!0,authMode:typeof n.authMode==`string`?n.authMode:void 0}:null}async function Oy(e,t){let n=await wy(fetch(`${e}/api/claude-desktop/status`,{signal:t}));return!n||typeof n.desiredEnabled!=`boolean`||typeof n.installed!=`boolean`||typeof n.observedKind!=`string`?null:{desiredEnabled:n.desiredEnabled,installed:n.installed,observedKind:n.observedKind,applied:n.applied===!0,stale:n.stale===!0,drift:n.drift===!0,driftReason:typeof n.driftReason==`string`?n.driftReason:null,activeProfile:typeof n.activeProfile==`boolean`?n.activeProfile:null,appliedAt:typeof n.appliedAt==`string`?n.appliedAt:null}}async function ky(e,t){let n=await wy(fetch(`${e}/api/grok`,{signal:t}));return n?{present:n.present===!0,models:Array.isArray(n.models)?n.models:[]}:null}var Ay=new Set([`claude`,`grok`,`codex`,`claude-desktop`]),jy=new Set([`native_integration_refused`,`native_integration_failed`]),My=new Set([`not_installed`,`orphaned_marker`,`home_mismatch`,`config_busy`,`write_failed`,`metadata_unreadable`,`cleanup_incomplete`,`desired_state_changed`]);function Ny(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Py(e){return Ny(e)?typeof e.error==`string`&&jy.has(String(e.code))&&Ay.has(String(e.clientId))&&My.has(String(e.reason))&&typeof e.message==`string`:!1}var Fy=class extends Error{refusal;status;body;constructor(e,t){let n=Py(t)?t:null;super(n?.message??t.error??t.message??String(e)),this.name=`NativeApiError`,this.status=e,this.body=t,this.refusal=n}};async function Iy(e){try{let t=await e;return t.ok?await Lt(t)??null:null}catch{return null}}async function Ly(e){try{let t=await e.json();return Ny(t)?t:{}}catch{return{}}}async function Ry(e){if(!e.ok)throw new Fy(e.status,await Ly(e));let t=await Lt(e);if(t==null)throw new Fy(e.status,{});return t}function zy(e,t){return Iy(fetch(`${e}/api/native-integrations`,{signal:t}))}async function By(e,t,n,r){return Ry(await fetch(`${e}/api/native-integrations/${encodeURIComponent(t)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n}),signal:r}))}var Vy={integration_mutation_busy:`integrations.error.busy`,integration_journal_newest_protected:`integrations.rollback.deleteNewest`,integration_operation_not_found:`integrations.rollback.deleteGone`};function Hy(e){return e instanceof my?e.refusal:null}function Uy(e){return e instanceof Fy?e.refusal:null}function Wy(e){return e===`conflict`?`integrations.error.conflict`:e===`unsafe`?`integrations.error.unsafe`:e===`non_loopback`?`integrations.error.nonLoopback`:`integrations.error.generic`}var Gy=new Set([`non_loopback`]);function Ky(e,t,n){return t.reason===`orphaned_marker`?e(`integrations.native.error.orphanedMarker`,{path:n??``}):t.reason===`home_mismatch`?`${e(`integrations.native.error.homeMismatch`)} ${t.message}`:t.reason===`not_installed`?e(`integrations.native.error.notInstalled`):t.reason===`config_busy`?e(`integrations.native.error.configBusy`):t.reason===`metadata_unreadable`?e(`integrations.native.error.desktopUnsafeMetadata`,{path:n??``}):t.reason===`cleanup_incomplete`?e(`integrations.native.error.desktopCleanupIncomplete`,{paths:(t.residualPaths??[]).join(`, `)}):t.message||e(`integrations.error.generic`)}function qy(e,t,n,r){let i=Uy(t);if(i)return Ky(e,i,r);let a=Hy(t);if(!a){let r=Vy[t instanceof my?String(t.body.code??``):``];return r?e(r):t instanceof Error&&t.message?t.message:n??e(`integrations.error.generic`)}let o=Gy.has(a.reason)?e(Wy(a.reason),{client:a.clientId}):a.message||e(Wy(a.reason));return a.snapshotPath?e(a.residual?`integrations.error.residual`:`integrations.error.recover`,{message:o,path:a.snapshotPath}):a.reason===`conflict`||a.reason===`unsafe`?`${e(Wy(a.reason))} ${o}`:o}function Jy({apiBase:e,row:t,onClose:n,onRestored:r}){let i=Z(),a=(0,_.useRef)(null),o=(0,_.useRef)(null),s=(0,_.useRef)(null),c=(0,_.useRef)(!1),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(null);(0,_.useEffect)(()=>{let e=a.current,t=document.activeElement;return o.current=t?.tagName===`BUTTON`?t:null,s.current=t?.closest?.(`section, [role='region'], main`)??null,e&&!e.open&&e.showModal(),()=>{e?.open&&e.close();let t=s.current;if(c.current&&t?.isConnected){t.hasAttribute(`tabindex`)||t.setAttribute(`tabindex`,`-1`),t.focus?.();return}let n=o.current;if(n?.isConnected){n.focus?.();return}t?.isConnected&&(t.hasAttribute(`tabindex`)||t.setAttribute(`tabindex`,`-1`),t.focus?.())}},[]);let h=(0,_.useCallback)(e=>{e.preventDefault(),d||n()},[n,d]),g=async()=>{if(!d){f(!0),m(null);try{await Sy(e,t.opId,l),c.current=!0,r(),n()}catch(e){if(Hy(e)?.reason===`drift_requires_confirm`){u(!0),f(!1);return}m(qy(i,e)),f(!1)}}};return(0,J.jsxs)(`dialog`,{ref:a,className:`modal-overlay`,"aria-labelledby":`integration-restore-title`,onCancel:h,children:[(0,J.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":i(`common.close`),tabIndex:-1,onClick:()=>{d||n()}}),(0,J.jsxs)(`div`,{className:`modal-card integration-restore-dialog`,role:`document`,children:[(0,J.jsx)(`div`,{className:`modal-head`,children:(0,J.jsx)(`h3`,{id:`integration-restore-title`,children:i(l?`integrations.restore.driftTitle`:`integrations.restore.title`)})}),(0,J.jsx)(`div`,{className:`modal-desc`,children:i(l?`integrations.restore.driftBody`:`integrations.restore.body`)}),(0,J.jsx)(`p`,{className:`integration-path`,children:t.configPath}),p&&(0,J.jsx)(Q,{tone:`err`,children:p}),(0,J.jsxs)(`div`,{className:`modal-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:n,disabled:d,children:i(`common.cancel`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>void g(),disabled:d,children:i(d?`integrations.restore.pending`:l?`integrations.restore.confirmDrift`:`integrations.restore.confirm`)})]})]})]})}var Yy={opencode:`integrations.tab.opencode`,pi:`integrations.tab.pi`,omp:`integrations.tab.omp`,hermes:`integrations.tab.hermes`,openclaw:`integrations.tab.openclaw`,kimi:`integrations.tab.kimi`,gajae:`integrations.tab.gajae`,dsh:`integrations.tab.dsh`,mcode:`integrations.tab.mcode`,zcode:`integrations.tab.zcode`,prime:`integrations.tab.prime`,aside:`integrations.tab.aside`},Xy={apply:`integrations.kind.apply`,disable:`integrations.kind.disable`,refresh:`integrations.kind.refresh`,restore:`integrations.kind.restore`,overwrite:`integrations.kind.overwrite`};function Zy(e){return e===`current`||e===`stale`}function Qy(e,t,n){let r={id:`codex`,hash:`integrations/codex`,labelKey:`integrations.tab.codex`,toggle:`codex`,toggleBlocked:t?.disableBlocked??null,togglePath:t?.configPath??null,status:null,detail:null,detailVars:null};if(n===void 0)return e?e.routingInjected===!0?{...r,state:e.status===`error`?`stale`:`current`,installed:!0,applied:!0,detailKey:`integrations.detail.codexRouted`}:{...r,state:`absent`,installed:!0,applied:!1,detail:e.recommendedCommand??null,detailKey:e.recommendedCommand?null:`integrations.detail.codexAbsent`}:{...r,state:`unknown`,installed:!1,applied:!1,detailKey:null};if(!n)return{...r,state:`unknown`,installed:!1,applied:!1,detailKey:null};if(!t)return{...r,toggle:null,state:`unknown`,installed:!1,applied:!1,detailKey:null};let i=t.desiredEnabled;return e?e.routingInjected===!0?{...r,state:e.status===`error`?`stale`:`current`,installed:t.installed,applied:!0,toggleOn:i,detailKey:`integrations.detail.codexRouted`}:{...r,state:`absent`,installed:t.installed,applied:!1,toggleOn:i,detail:e.recommendedCommand??null,detailKey:e.recommendedCommand?null:`integrations.detail.codexAbsent`}:{...r,state:`unknown`,installed:t.installed,applied:!1,toggleOn:i,detailKey:null}}function $y(e,t){let n={hash:`integrations/keys`,labelKey:`integrations.tab.keys`};return e===`checking`?{...n,state:`checking`,detailKey:`integrations.detail.keyChecking`,detailVars:null}:e===`unavailable`||t===null?{...n,state:`unavailable`,detailKey:`integrations.detail.keyUnavailable`,detailVars:null}:{...n,state:t>0?`issued`:`none-issued`,detailKey:t>0?`integrations.detail.keyCount`:`integrations.detail.keyNone`,detailVars:t>0?{count:String(t)}:null}}function eb(e){return e?e.enabled===!0?e.authMode===`subscription`?`claude.authModeSubscription`:e.authMode===`proxy`?`claude.authModeProxy`:e.authMode===`auto`?`claude.authModeAuto`:null:`integrations.detail.claudeOff`:null}function tb(e,t,n){let r={id:`claude`,hash:`integrations/claude`,labelKey:`integrations.tab.claude`,toggle:`claude`,toggleBlocked:t?.disableBlocked??null,togglePath:t?.configPath??null,status:null,detail:null,detailVars:null},i=eb(e);if(n===void 0){if(!e)return{...r,state:`unknown`,installed:!1,applied:!1,detailKey:i};let t=e.enabled===!0;return{...r,state:t?`current`:`absent`,installed:!0,applied:t,detailKey:i}}return n?t?{...r,state:t.state,installed:t.installed,applied:t.state===`current`,detailKey:i}:{...r,toggle:null,state:`unknown`,installed:!1,applied:!1,detailKey:i}:{...r,state:`unknown`,installed:!1,applied:!1,detailKey:i}}function nb(e,t,n){let r={id:`claudeDesktop`,hash:`integrations/claude/desktop`,labelKey:`claudeDesktop.title`,toggle:`claude-desktop`,toggleBlocked:t?.disableBlocked??null,togglePath:t?.configPath??null,status:null,detail:null,detailVars:null};if(!e||!n||!t||typeof e.desiredEnabled!=`boolean`)return{...r,toggle:null,state:`unknown`,installed:!1,applied:!1,detailKey:null};let i=e.desiredEnabled;if(!i)return e.applied===!0||e.driftReason===`desired_off_gateway_selected`?{...r,state:`stale`,installed:e.installed===!0,applied:!0,toggleOn:!1,detailKey:`integrations.detail.desktopDesiredOffCleanupPending`}:{...r,state:`absent`,installed:e.installed===!0,applied:!1,toggleOn:!1,detailKey:`integrations.detail.desktopDesiredOff`};if(e.applied!==!0)return{...r,state:`absent`,installed:e.installed===!0,applied:!1,toggleOn:i,detailKey:`integrations.detail.desktopDesiredOnNotApplied`};let a=e.stale===!0||e.activeProfile===!1;return{...r,state:a?`stale`:`current`,installed:!0,applied:!0,toggleOn:i,detailKey:e.activeProfile===!1?`integrations.detail.desktopNotServed`:a?`integrations.detail.desktopStale`:`integrations.detail.desktopCurrent`}}function rb(e){if(!e)return{detailKey:null,detailVars:null};let t=e.present===!0;return{detailKey:t?`integrations.detail.grokModels`:`integrations.detail.grokAbsent`,detailVars:t?{count:String(e.models?.length??0)}:null}}function ib(e,t,n){let r={id:`grok`,hash:`integrations/grok`,labelKey:`integrations.tab.grok`,toggle:`grok`,toggleBlocked:t?.disableBlocked??null,togglePath:t?.configPath??null,status:null,detail:null},i=rb(e);if(n===void 0){if(!e)return{...r,state:`unknown`,installed:!1,applied:!1,...i};let t=e.present===!0;return{...r,state:t?`current`:`absent`,installed:t,applied:t,...i}}return n?t?{...r,state:t.state,installed:t.installed,applied:t.state===`current`,...i}:{...r,toggle:null,state:`unknown`,installed:!1,applied:!1,...i}:{...r,state:`unknown`,installed:!1,applied:!1,...i}}function ab(e,t=Date.now()){let n={id:`cursor`,hash:`integrations/cursor`,labelKey:`integrations.tab.cursor`,toggle:null,toggleBlocked:null,togglePath:null,status:null,detail:null,detailVars:null};if(!e)return{...n,state:`unknown`,installed:!1,applied:!1,detailKey:null};if(!e.privateInference.installed)return{...n,state:`not-installed`,installed:!1,applied:!1,detailKey:`integrations.detail.cursorAbsent`};let r=e.lastSeen!==null&&t-e.lastSeen.at<864e5;return{...n,state:r?`current`:`absent`,installed:!0,applied:r,detailKey:r?`integrations.detail.cursorSeen`:`integrations.detail.cursorNeverSeen`}}function ob(e){return{id:e.clientId,hash:`integrations/${e.clientId}`,labelKey:Yy[e.clientId],state:e.installed?e.state:`not-installed`,installed:e.installed,applied:e.installed&&Zy(e.state),detail:e.configPath,detailKey:null,detailVars:null,toggle:e.clientId,toggleBlocked:null,togglePath:e.configPath,status:e}}function sb(e){let t=e.native?.find(e=>e.clientId===`codex`),n=e.native?.find(e=>e.clientId===`claude`),r=e.native?.find(e=>e.clientId===`grok`),i=new Map(e.clients.map(e=>[e.clientId,e])),a=[Qy(e.codex,t,e.nativeSettled),tb(e.claude,n,e.nativeSettled),nb(e.claudeDesktop,e.native?.find(e=>e.clientId===`claude-desktop`),e.nativeSettled),ib(e.grok,r,e.nativeSettled),ab(e.cursor)];for(let t of cy){let n=i.get(t);if(n){a.push(ob(n));continue}e.clientsSettled||a.push({id:t,hash:`integrations/${t}`,labelKey:Yy[t],state:`unknown`,installed:!1,applied:!1,detail:null,detailKey:null,detailVars:null,toggle:null,toggleBlocked:null,togglePath:null,status:null})}return{keysRow:$y(e.keyPhase,e.keyCount),rows:a}}function cb(e){return{detected:e.filter(e=>e.installed).length,applied:e.filter(e=>e.applied).length,stale:e.filter(e=>e.state===`stale`).length,unknown:e.filter(e=>e.state===`unknown`).length}}var lb=6;function ub({row:e,showClient:t,onRestore:n,onDelete:r}){let i=Z();return(0,J.jsxs)(`li`,{className:`integration-history-row`,children:[(0,J.jsx)(`span`,{className:`integration-history-kind`,children:i(Xy[e.kind])}),t&&(0,J.jsx)(`span`,{className:`integration-history-client`,children:e.clientId}),(0,J.jsx)(`span`,{className:`integration-history-at`,children:new Date(e.at).toLocaleString()}),e.snapshot===`expired`?(0,J.jsx)(`span`,{className:`badge badge-muted`,children:i(`integrations.action.snapshotExpired`)}):(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e),children:e.undoable?i(`integrations.action.undo`):i(`integrations.action.restorePoint`)}),e.deletable&&r&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>r(e),"aria-label":i(`integrations.rollback.deleteAria`,{at:new Date(e.at).toLocaleString()}),children:i(`integrations.rollback.delete`)})]})}function db({rows:e,showClient:t,onRestore:n,onDelete:r}){let i=Z(),[a,o]=(0,_.useState)(lb),[s,...c]=e;if(!s)return null;let l=c.slice(0,a),u=c.length-l.length;return(0,J.jsxs)(`div`,{className:`integration-history`,children:[(0,J.jsx)(`ul`,{className:`integration-history-list`,children:(0,J.jsx)(ub,{row:s,showClient:t,onRestore:n,onDelete:r})}),c.length>0&&(0,J.jsxs)(`details`,{className:`integration-history-older`,children:[(0,J.jsx)(`summary`,{children:i(`integrations.rollback.older`)}),(0,J.jsx)(`ul`,{className:`integration-history-list`,children:l.map(e=>(0,J.jsx)(ub,{row:e,showClient:t,onRestore:n,onDelete:r},e.opId))}),u>0&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm integration-history-more`,onClick:()=>o(e=>e+lb),children:i(`integrations.rollback.showMore`,{n:String(Math.min(u,lb))})})]})]})}var fb={titleKey:`integrations.dialog.grok.title`,changesKey:`integrations.dialog.grok.changes`,breakageKey:`integrations.dialog.grok.breakage`,undoKey:`integrations.dialog.grok.undo`,confirmKey:`integrations.dialog.grok.confirm`},pb={titleKey:`integrations.dialog.codex.title`,changesKey:`integrations.dialog.codex.changes`,breakageKey:`integrations.dialog.codex.breakage`,undoKey:`integrations.dialog.codex.undo`,sideEffectKey:`integrations.dialog.codex.sideEffect`,confirmKey:`integrations.dialog.codex.confirm`},mb={titleKey:`integrations.dialog.desktop.title`,changesKey:`integrations.dialog.desktop.changes`,breakageKey:`integrations.dialog.desktop.breakage`,undoKey:`integrations.dialog.desktop.undo`,sideEffectKey:`integrations.dialog.desktop.restart`,confirmKey:`integrations.dialog.desktop.confirm`};function hb(e){return e.state===`current`||e.state===`stale`}function gb({row:e,pending:t,result:n,onOpen:r,onToggle:i,onOverwrite:a}){let o=Z(),s=e.detail??(e.detailKey?o(e.detailKey,e.detailVars??void 0):null),c=e.toggleBlocked!==null&&(e.applied||e.toggleBlocked.reason===`orphaned_marker`),l=c&&e.toggleBlocked&&(e.toggle===`claude`||e.toggle===`grok`||e.toggle===`codex`)?qy(o,new Fy(409,{error:`native integration change refused`,code:`native_integration_refused`,clientId:e.toggle,reason:e.toggleBlocked.reason,message:e.toggleBlocked.message}),void 0,e.togglePath??void 0):null,u=e.toggleOn??e.applied;return(0,J.jsxs)(`li`,{className:`integration-card`,"data-client":e.id,children:[(0,J.jsxs)(`div`,{className:`integration-card-head`,children:[(0,J.jsx)(g_,{src:h_(e.id),label:o(e.labelKey),size:20}),(0,J.jsx)(`h4`,{children:(0,J.jsx)(`button`,{type:`button`,className:`integration-card-link`,onClick:r,children:o(e.labelKey)})}),(0,J.jsx)(ay,{state:e.state,installed:e.installed})]}),s&&(0,J.jsx)(`p`,{className:e.detail?`integration-path`:`integration-meta`,children:s}),n?.tone===`err`&&(0,J.jsx)(Q,{tone:`err`,children:n.text}),n?.tone===`ok`&&(0,J.jsx)(Q,{tone:`ok`,children:n.text}),(0,J.jsxs)(`div`,{className:`integration-card-actions`,children:[e.toggle&&i&&(0,J.jsxs)(`div`,{className:`integration-toggle-control`,children:[(0,J.jsx)(Dt,{on:u,onClick:i,disabled:e.state===`unknown`||!e.installed||e.state===`conflict`||e.state===`unsafe`||c||t,label:o(u?`integrations.action.disable`:`integrations.action.apply`)}),l&&(0,J.jsx)(`p`,{className:`integration-toggle-blocked`,children:l})]}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:r,tabIndex:-1,children:o(`integrations.action.settings`)}),a&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:a,disabled:t,children:o(`integrations.action.overwrite`)})]})]})}function _b({apiBase:e,active:t=!0}){let n=Z(),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)({}),[p,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(null),v=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(p!==null)return;let e=v.current;e&&(v.current=null,e.isConnected&&e.focus())},[p]);let y=(0,_.useCallback)(async t=>(await vy(e,t)).clients,[e]),b=(0,_.useCallback)(async t=>(await by(e,void 0,t)).operations,[e]),x=(0,_.useCallback)(t=>Ty(e,t),[e]),S=(0,_.useCallback)(t=>Ey(e,t),[e]),C=(0,_.useCallback)(t=>Dy(e,t),[e]),w=(0,_.useCallback)(t=>Oy(e,t),[e]),T=(0,_.useCallback)(t=>ky(e,t),[e]),E=(0,_.useCallback)(t=>$v(e,t),[e]),D=(0,_.useCallback)(async t=>(await zy(e,t))?.clients??null,[e]),O=$(`integration-states:${e}`,[e],y,{isEmpty:e=>e.length===0,enabled:t,sessionCacheKey:`ocx.integrations.states.v1:${e}`}),k=$(`integration-journal-all:${e}`,[e],b,{isEmpty:e=>e.length===0,enabled:t,sessionCacheKey:`ocx.integrations.journal.v1:${e}`}),A=$(`integration-codex:${e}`,[e],x,{isEmpty:e=>e===null,enabled:t,sessionCacheKey:`ocx.integrations.codex.v1:${e}`}),j=$(`integration-keys:${e}`,[e],S,{isEmpty:()=>!1,enabled:t,sessionCacheKey:`ocx.integrations.keys.v1:${e}`}),M=$(`integration-claude:${e}`,[e],C,{isEmpty:e=>e===null,enabled:t,sessionCacheKey:`ocx.integrations.claude.v1:${e}`}),N=$(`integration-claude-desktop:${e}`,[e],w,{isEmpty:e=>e===null,enabled:t,sessionCacheKey:`ocx.integrations.claude-desktop.v1:${e}`}),P=$(`integration-grok:${e}`,[e],T,{isEmpty:e=>e===null,enabled:t,sessionCacheKey:`ocx.integrations.grok.v1:${e}`}),F=$(`integration-cursor:${e}`,[e],E,{isEmpty:e=>e===null,enabled:t,sessionCacheKey:`ocx.integrations.cursor.v1:${e}`}),I=$(`integration-native:${e}`,[e],D,{isEmpty:e=>e===null,enabled:t,sessionCacheKey:`ocx.integrations.native.v1:${e}`}),L=O.state.data??[],R=k.state.data??[],z=L.filter(hb),B=L.filter(e=>e.installed),V=O.state.kind!==`cold`&&O.state.kind!==`retrying-cold`,H=I.state.data??null,U=H!==null,W=j.state.kind===`cold`||j.state.kind===`retrying-cold`?`checking`:j.state.kind===`failed-cold`||j.state.kind===`failed-with-stale`?`unavailable`:`settled`,{keysRow:ee,rows:G}=sb({clients:L,clientsSettled:V,codex:A.state.data??null,keyCount:j.state.data??null,keyPhase:W,claude:M.state.data??null,claudeDesktop:N.state.data??null,grok:P.state.data??null,cursor:F.state.data??null,native:H,nativeSettled:U}),K=cb(G),q=()=>{O.refresh(),k.refresh(),A.refresh(),j.refresh(),M.refresh(),N.refresh(),P.refresh(),I.refresh()},Y=async()=>{if(r||z.length===0)return;let t=[n(`integrations.bulk.title`),n(`integrations.bulk.body`)].join(`
|
|
111
111
|
|
|
112
|
-
`);if(!confirm(t))return;i(!0),o(null);let a=[];for(let t of z)try{await xy(e,t.clientId,!1)}catch(e){a.push(`${t.clientId}: ${qy(n,e)}`)}let s=!1;try{s=(await vy(e)).clients.some(hb)}catch{a.push(n(`integrations.error.stale`))}s&&a.length===0&&a.push(n(`integrations.error.stale`)),q(),i(!1),o(a.length===0?{tone:`ok`,text:n(`integrations.bulk.success`)}:{tone:`err`,text:n(`integrations.bulk.partial`,{clients:a.join(`; `)})})},te=R[0]?.at,[ne,re]=(0,_.useState)(null),ie=()=>{I.refresh(),A.refresh(),M.refresh(),P.refresh()},ae=(e,t)=>{f(n=>{let r={...n};return t?r[e]=t:delete r[e],r})},oe=async(t,r)=>{if(!ne&&t.toggle){re(t.id),ae(t.id,null);try{if(t.status)await xy(e,t.status.clientId,r),q();else if(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`){let i=await By(e,t.toggle,r);i.reason===`non_loopback_removed`?ae(t.id,{tone:`ok`,text:n(i.changed?`integrations.native.msg.nonLoopbackRemoved`:`integrations.native.msg.nonLoopbackRemovedNoop`)}):i.reason===`non_loopback_superseded`&&ae(t.id,{tone:`ok`,text:n(`integrations.native.msg.nonLoopbackSuperseded`)}),ie()}}catch(e){ae(t.id,{tone:`err`,text:qy(n,e,void 0,t.togglePath??void 0)}),(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`)&&ie()}finally{re(null)}}},se=(e,t)=>{if(e.status||t||e.id===`claude`||e.toggle===null){oe(e,t);return}let n=document.activeElement;v.current=n?.tagName===`BUTTON`?n:null,m(e)},ce=async t=>{if(t.status){re(t.id),ae(t.id,null);try{await xy(e,t.status.clientId,!0,void 0,!0),q()}catch(e){throw ae(t.id,{tone:`err`,text:qy(n,e,void 0,t.togglePath??void 0)}),e}finally{re(null)}}};return(0,J.jsxs)(`section`,{className:`integrations-overview`,children:[(0,J.jsxs)(`div`,{className:`integration-summary`,children:[(0,J.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,J.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.detected`)}),(0,J.jsx)(`strong`,{children:K.detected})]}),(0,J.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,J.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.applied`)}),(0,J.jsx)(`strong`,{children:K.applied})]}),(0,J.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,J.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.stale`)}),(0,J.jsx)(`strong`,{children:K.stale})]}),K.unknown>0&&(0,J.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,J.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.state.unknown`)}),(0,J.jsx)(`strong`,{children:K.unknown})]}),(0,J.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,J.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.lastChange`)}),(0,J.jsx)(`strong`,{children:te?new Date(te).toLocaleString():n(`integrations.status.unknown`)})]}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void Y(),disabled:r||z.length===0,children:n(`integrations.summary.disableAll`)})]}),(0,J.jsx)(`h3`,{children:n(`integrations.catalog.title`)}),(0,J.jsx)(vb,{row:ee}),(0,J.jsx)(`p`,{className:`page-sub`,children:n(`integrations.onboarding`)}),O.state.kind===`failed-cold`&&(0,J.jsx)(Q,{tone:`err`,children:n(`integrations.error.load`)}),O.state.kind===`failed-with-stale`&&(0,J.jsx)(Q,{tone:`err`,children:n(`integrations.error.stale`)}),a&&(0,J.jsx)(Q,{tone:a.tone,children:a.text}),G.length===0?O.state.kind===`failed-cold`?null:(0,J.jsx)(`p`,{className:`page-sub`,children:n(`common.loading`)}):(0,J.jsx)(`ul`,{className:`integration-cards`,children:G.map(e=>(0,J.jsx)(gb,{row:e,pending:ne!==null,result:d[e.id]??null,onOpen:()=>ht(e.hash),onToggle:e.toggle?()=>se(e,!(e.toggleOn??e.applied)):null,onOverwrite:e.status!==null&&e.status.state===`conflict`&&e.installed?()=>g(e):null},e.id))}),V&&B.length===0&&(0,J.jsxs)(`div`,{className:`integration-empty`,children:[(0,J.jsx)(`h4`,{children:n(`integrations.empty.title`)}),(0,J.jsx)(`p`,{children:n(`integrations.empty.body`)})]}),(0,J.jsx)(`h3`,{children:n(`integrations.rollback.title`)}),k.state.showSkeleton?(0,J.jsx)(Nl,{label:n(`integrations.rollback.title`),rows:2}):k.state.kind===`failed-cold`?(0,J.jsxs)(Q,{tone:`err`,children:[n(`integrations.rollback.failed`),` `,(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void k.refresh(),children:n(`common.retry`)})]}):R.length===0?(0,J.jsxs)(`div`,{className:`integration-empty`,children:[(0,J.jsx)(`p`,{children:n(`integrations.rollback.empty`)}),(0,J.jsx)(`p`,{className:`page-sub`,children:n(`integrations.rollback.emptyBody`)})]}):(0,J.jsx)(db,{rows:R,showClient:!0,onRestore:c,onDelete:u}),s&&(0,J.jsx)(Jy,{apiBase:e,row:s,onClose:()=>c(null),onRestored:q}),l&&(0,J.jsx)(sy,{copy:{titleKey:`integrations.dialog.deleteEntry.title`,changesKey:`integrations.dialog.deleteEntry.changes`,breakageKey:`integrations.dialog.deleteEntry.breakage`,undoKey:`integrations.dialog.deleteEntry.undo`,confirmKey:`integrations.dialog.deleteEntry.confirm`,vars:{path:l.configPath}},onClose:()=>u(null),onConfirm:async()=>{try{await Cy(e,l.opId)}catch(e){if(hy(e)){u(null),await k.refresh();return}throw Error(qy(n,e),{cause:e})}u(null),await k.refresh()}}),p&&(0,J.jsx)(sy,{copy:{...p.toggle===`claude-desktop`?mb:p.id===`codex`?pb:fb,vars:{path:p.togglePath??``}},onClose:()=>m(null),onConfirm:async()=>{await oe(p,!1),m(null)}}),h&&h.status&&(0,J.jsx)(sy,{copy:{titleKey:`integrations.dialog.overwrite.title`,changesKey:h.status.reason===`foreign-edit`?`integrations.dialog.overwrite.changesForeign`:`integrations.dialog.overwrite.changesUnowned`,breakageKey:`integrations.dialog.overwrite.breakage`,undoKey:`integrations.dialog.overwrite.undo`,confirmKey:`integrations.dialog.overwrite.confirm`,vars:{path:h.status.configPath}},onClose:()=>g(null),onConfirm:async()=>{await ce(h),g(null)}})]})}function vb({row:e}){let t=Z(),n=e.detailKey?t(e.detailKey,e.detailVars??void 0):null;return(0,J.jsxs)(`div`,{className:`integration-api-keys-row`,"data-client":`keys`,"data-key-state":e.state,children:[(0,J.jsxs)(`div`,{className:`integration-api-keys-copy`,children:[(0,J.jsx)(`h4`,{children:t(e.labelKey)}),n&&(0,J.jsx)(`p`,{className:`integration-meta`,children:n})]}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>ht(e.hash),children:t(`integrations.action.manageKeys`)})]})}function yb(e,t){return{titleKey:`integrations.dialog.overwrite.title`,changesKey:e===`foreign-edit`?`integrations.dialog.overwrite.changesForeign`:`integrations.dialog.overwrite.changesUnowned`,breakageKey:`integrations.dialog.overwrite.breakage`,undoKey:`integrations.dialog.overwrite.undo`,confirmKey:`integrations.dialog.overwrite.confirm`,vars:{path:t}}}var bb={opencode:`integrations.semantics.opencode`,pi:`integrations.semantics.pi`,omp:`integrations.semantics.omp`,hermes:`integrations.semantics.hermes`,openclaw:`integrations.semantics.openclaw`,kimi:`integrations.semantics.kimi`,gajae:`integrations.semantics.gajae`,dsh:`integrations.semantics.dsh`,mcode:`integrations.semantics.mcode`,zcode:`integrations.semantics.zcode`,prime:`integrations.semantics.prime`,aside:`integrations.semantics.aside`},xb={opencode:`integrations.tab.opencode`,pi:`integrations.tab.pi`,omp:`integrations.tab.omp`,hermes:`integrations.tab.hermes`,openclaw:`integrations.tab.openclaw`,kimi:`integrations.tab.kimi`,gajae:`integrations.tab.gajae`,dsh:`integrations.tab.dsh`,mcode:`integrations.tab.mcode`,zcode:`integrations.tab.zcode`,prime:`integrations.tab.prime`,aside:`integrations.tab.aside`};function Sb({apiBase:e,client:t,active:n=!0}){let r=Z(),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!1),m=(0,_.useCallback)(n=>yy(e,t,n),[e,t]),h=(0,_.useCallback)(async n=>(await by(e,t,n)).operations,[e,t]),g=$(`integration-state:${e}:${t}`,[e,t],m,{isEmpty:()=>!1,enabled:n,sessionCacheKey:`ocx.integrations.state.v1:${e}:${t}`}),v=$(`integration-journal:${e}:${t}`,[e,t],h,{isEmpty:e=>e.length===0,enabled:n,sessionCacheKey:`ocx.integrations.client-journal.v1:${e}:${t}`}),y=g.state.data??null,b=v.state.data??[],x=()=>{g.refresh(),v.refresh()},S=async n=>{if(!(!y||i)){a(!0),s(null);try{await xy(e,t,n),x()}catch(e){s(qy(r,e))}finally{a(!1)}}},C=async()=>{if(y){s(null);try{await xy(e,t,!0,void 0,!0),x()}catch(e){throw s(qy(r,e)),e}}},w=()=>void S(!(y&&(y.state===`current`||y.state===`stale`)));if(!y)return(0,J.jsx)(`section`,{className:`integration-client-page`,children:g.state.kind===`failed-cold`?(0,J.jsx)(Q,{tone:`err`,children:r(`integrations.error.load`)}):(0,J.jsx)(`p`,{className:`page-sub`,children:r(`common.loading`)})});let T=y.state===`current`||y.state===`stale`,E=!y.installed||y.state===`conflict`||y.state===`unsafe`;return(0,J.jsxs)(`section`,{className:`integration-client-page`,children:[(0,J.jsxs)(`div`,{className:`integration-client-head`,children:[(0,J.jsx)(g_,{src:h_(t),label:r(xb[t]),size:24}),(0,J.jsx)(`h3`,{children:r(xb[t])}),(0,J.jsx)(ay,{state:y.state,installed:y.installed,id:`integration-state-${t}`}),(0,J.jsx)(Dt,{on:T,onClick:w,disabled:E||i,label:r(T?`integrations.action.disable`:`integrations.action.apply`)})]}),y.state===`stale`&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void S(!0),disabled:i,children:r(`integrations.action.refresh`)}),y.installed&&y.state===`conflict`&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:()=>p(!0),disabled:i,children:r(`integrations.action.overwrite`)}),(0,J.jsx)(`p`,{className:`page-sub`,children:r(bb[t])}),(0,J.jsx)(`p`,{className:`integration-path`,children:y.configPath}),y.appliedAt&&(0,J.jsxs)(`p`,{className:`integration-meta`,children:[r(`integrations.status.appliedAt`),`: `,new Date(y.appliedAt).toLocaleString()]}),y.retentionDegraded&&(0,J.jsx)(Q,{tone:`err`,children:r(`integrations.retention.degraded`)}),o&&(0,J.jsx)(Q,{tone:`err`,children:o}),(0,J.jsx)(`h4`,{children:r(`integrations.rollback.title`)}),v.state.showSkeleton?(0,J.jsx)(Nl,{label:r(`integrations.rollback.title`),rows:2}):v.state.kind===`failed-cold`?(0,J.jsxs)(Q,{tone:`err`,children:[r(`integrations.rollback.failed`),` `,(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void v.refresh(),children:r(`common.retry`)})]}):b.length===0?(0,J.jsx)(`p`,{className:`page-sub`,children:r(`integrations.rollback.empty`)}):(0,J.jsx)(db,{rows:b,onRestore:l,onDelete:d}),c&&(0,J.jsx)(Jy,{apiBase:e,row:c,onClose:()=>l(null),onRestored:x}),u&&(0,J.jsx)(sy,{copy:{titleKey:`integrations.dialog.deleteEntry.title`,changesKey:`integrations.dialog.deleteEntry.changes`,breakageKey:`integrations.dialog.deleteEntry.breakage`,undoKey:`integrations.dialog.deleteEntry.undo`,confirmKey:`integrations.dialog.deleteEntry.confirm`,vars:{path:u.configPath}},onClose:()=>d(null),onConfirm:async()=>{try{await Cy(e,u.opId)}catch(e){if(hy(e)){d(null),await v.refresh();return}throw Error(qy(r,e),{cause:e})}d(null),await v.refresh()}}),f&&(0,J.jsx)(sy,{copy:yb(y.reason,y.configPath),onClose:()=>p(!1),onConfirm:async()=>{await C(),p(!1)}})]})}var Cb=[{id:`overview`,hash:`integrations`,labelKey:`integrations.tab.overview`},{id:`keys`,hash:`integrations/keys`,labelKey:`integrations.tab.keys`},{id:`codex`,hash:`integrations/codex`,labelKey:`integrations.tab.codex`},{id:`claude`,hash:`integrations/claude`,labelKey:`integrations.tab.claude`},{id:`grok`,hash:`integrations/grok`,labelKey:`integrations.tab.grok`},{id:`cursor`,hash:`integrations/cursor`,labelKey:`integrations.tab.cursor`},{id:`opencode`,hash:`integrations/opencode`,labelKey:`integrations.tab.opencode`},{id:`pi`,hash:`integrations/pi`,labelKey:`integrations.tab.pi`},{id:`omp`,hash:`integrations/omp`,labelKey:`integrations.tab.omp`},{id:`hermes`,hash:`integrations/hermes`,labelKey:`integrations.tab.hermes`},{id:`openclaw`,hash:`integrations/openclaw`,labelKey:`integrations.tab.openclaw`},{id:`kimi`,hash:`integrations/kimi`,labelKey:`integrations.tab.kimi`},{id:`gajae`,hash:`integrations/gajae`,labelKey:`integrations.tab.gajae`},{id:`dsh`,hash:`integrations/dsh`,labelKey:`integrations.tab.dsh`},{id:`mcode`,hash:`integrations/mcode`,labelKey:`integrations.tab.mcode`},{id:`zcode`,hash:`integrations/zcode`,labelKey:`integrations.tab.zcode`},{id:`prime`,hash:`integrations/prime`,labelKey:`integrations.tab.prime`},{id:`aside`,hash:`integrations/aside`,labelKey:`integrations.tab.aside`}],wb=new Set([`opencode`,`pi`,`omp`,`hermes`,`openclaw`,`kimi`,`gajae`,`dsh`,`mcode`,`zcode`,`prime`,`aside`]);function Tb(e=window.location.hash){let t=pt(e);return t===`integrations/claude/desktop`?`claude`:Cb.find(e=>e.hash===t)?.id??`overview`}function Eb(e){return`integrations-tab-${e}`}function Db(e){return`integrations-panel-${e}`}function Ob(e){return e===`overview`||e===`keys`?null:f_[e]??null}function kb({apiBase:e,machineApiBase:t=e,connected:n=!1}){let r=Z(),[i,a]=(0,_.useState)(Tb),[o,s]=(0,_.useState)(()=>new Set([Tb()])),c=(0,_.useRef)(null),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(!1);c.current===null&&(c.current=new Map),(0,_.useEffect)(()=>{if(!n)return;let e=new AbortController;return fetch(`${t}/api/machine/clients`,{signal:e.signal}).then(e=>e.ok?e.json():null).then(t=>{!e.signal.aborted&&Array.isArray(t?.selectedClients)&&u(t.selectedClients.filter(e=>typeof e==`string`))}).catch(()=>{}),()=>e.abort()},[n,t]);let p=async()=>{f(!0);try{await fetch(`${t}/api/machine/sync`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`})}finally{f(!1)}},m=e=>{a(e),s(t=>t.has(e)?t:new Set([...t,e]))};(0,_.useEffect)(()=>{let e=()=>m(Tb());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let h=(e,t)=>{let n=Cb.find(t=>t.id===e);n&&(ht(n.hash),m(e),t&&window.requestAnimationFrame(()=>{c.current.get(e)?.focus({preventScroll:!0})}))},g=e=>{let t=Cb.findIndex(e=>e.id===i),n=null;e.key===`ArrowLeft`?n=(t-1+Cb.length)%Cb.length:e.key===`ArrowRight`?n=(t+1)%Cb.length:e.key===`Home`?n=0:e.key===`End`&&(n=Cb.length-1),n!==null&&(e.preventDefault(),h(Cb[n].id,!0))};return(0,J.jsxs)(`section`,{className:`integrations-page`,children:[(0,J.jsx)(`div`,{className:`page-head`,children:(0,J.jsx)(`h2`,{children:r(`nav.integrations`)})}),(0,J.jsx)(`p`,{className:`page-sub`,children:r(`integrations.subtitle`)}),n&&(0,J.jsxs)(`section`,{className:`notice`,"aria-label":r(`connection.clients.title`),children:[(0,J.jsx)(`strong`,{children:r(`connection.clients.title`)}),(0,J.jsx)(`span`,{children:l.length>0?l.join(`, `):r(`connection.clients.none`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:d,onClick:()=>void p(),children:r(d?`connection.clients.syncing`:`connection.clients.sync`)})]}),(0,J.jsx)(`div`,{className:`page-tabs`,role:`tablist`,"aria-label":r(`integrations.tabsLabel`),children:Cb.map(e=>(0,J.jsxs)(`button`,{ref:t=>{t?c.current.set(e.id,t):c.current.delete(e.id)},type:`button`,role:`tab`,id:Eb(e.id),"aria-selected":i===e.id,"aria-controls":Db(e.id),tabIndex:i===e.id?0:-1,className:`page-tab${i===e.id?` page-tab--active`:``}`,onClick:()=>h(e.id,!0),onKeyDown:g,children:[Ob(e.id)&&(0,J.jsx)(g_,{src:Ob(e.id),label:r(e.labelKey),size:14}),r(e.labelKey)]},e.id))}),Cb.map(t=>{if(!o.has(t.id))return null;let n=i===t.id;return(0,J.jsxs)(`div`,{role:`tabpanel`,id:Db(t.id),"aria-labelledby":Eb(t.id),hidden:!n,children:[t.id===`overview`&&(0,J.jsx)(_b,{apiBase:e,active:n}),t.id===`keys`&&(0,J.jsx)(nv,{apiBase:e,active:n}),t.id===`codex`&&(0,J.jsxs)(`section`,{className:`integration-native-page`,"aria-labelledby":`codex-integration-title`,children:[(0,J.jsx)(`h3`,{id:`codex-integration-title`,children:r(`integrations.codex.title`)}),(0,J.jsx)(`p`,{children:r(`integrations.codex.body`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>ht(`startup`),children:r(`integrations.codex.openService`)})]}),t.id===`claude`&&(0,J.jsx)(Kv,{apiBase:e,active:n}),t.id===`grok`&&(0,J.jsx)(Qv,{apiBase:e,active:n}),t.id===`cursor`&&(0,J.jsx)(ny,{apiBase:e,active:n}),wb.has(t.id)&&(0,J.jsx)(Sb,{apiBase:e,client:t.id,active:n})]},t.id)})]})}function Ab(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 jb={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},Mb={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},Nb={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function Pb({ok:e,yes:t,no:n}){return(0,J.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function Fb({failed:e,data:t}){let{t:n}=ut(),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`?_e:ue,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,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`section`,{className:`panel startup-hero ${r}`,"aria-live":`polite`,children:[(0,J.jsx)(`div`,{className:`startup-hero-icon`,children:(0,J.jsx)(i,{})}),(0,J.jsxs)(`div`,{className:`startup-hero-copy`,children:[(0,J.jsx)(`span`,{className:`badge ${e||t.status===`at-risk`?`badge-amber`:`badge-green`}`,children:n(e?`startup.status.atRisk`:jb[t.status])}),(0,J.jsx)(`h3`,{children:n(e?`startup.error`:Mb[t.status])}),(0,J.jsx)(`p`,{children:e?n(`startup.staleData`):t.status===`at-risk`?n(Cr(t)):n(`startup.safeDetail`)}),(0,J.jsxs)(`p`,{className:`muted startup-state-line`,children:[n(a),` · `,n(Nb[t.protection]),` · `,n(t.autostartEnabled?`startup.enabled`:`startup.disabled`)]}),(0,J.jsx)(`p`,{className:`muted text-label`,children:n(`startup.subtitle`)})]})]})})}function Ib({data:e,failed:t,loading:n=!1,installBusy:r,installResult:i,onInstall:a}){let{t:o}=ut(),s=e.serviceSupported&&e.serviceInstalled&&e.serviceStale&&!e.serviceConflict,c=e.shimInstalled&&!e.shimHealthy,l=r!==null||t||n;return(0,J.jsxs)(`section`,{className:`panel startup-details`,children:[(0,J.jsxs)(`div`,{className:`panel-head`,children:[(0,J.jsx)(`h3`,{className:`panel-title`,children:o(`startup.details`)}),(0,J.jsx)(`span`,{className:`muted mono`,children:e.platform})]}),(0,J.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:o(`startup.service`)}),(0,J.jsx)(`span`,{children:o(`startup.serviceHint`)})]}),(0,J.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,J.jsx)(Pb,{ok:e.serviceViable,yes:o(`startup.viable`),no:o(e.serviceConflict?`startup.conflict`:e.serviceStale?`startup.stale`:e.serviceInstalled?`startup.unhealthy`:e.serviceSupported?`startup.notInstalled`:`startup.unsupported`)}),e.serviceSupported&&!e.serviceInstalled&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-service`),children:o(r===`install-service`?`startup.installing`:`startup.install`)}),s&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-service`,{repair:!0}),children:o(r===`install-service`?`startup.repairing`:`startup.repair`)})]})]}),(0,J.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:o(`startup.shim`)}),(0,J.jsx)(`span`,{children:o(`startup.shimHint`)})]}),(0,J.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,J.jsx)(Pb,{ok:e.shimHealthy&&e.autostartEnabled,yes:o(e.shimCoverage===`cli-only`?`startup.cliOnly`:`startup.healthy`),no:o(e.shimInstalled?e.shimHealthy&&!e.autostartEnabled?`startup.installedDisabled`:`startup.stale`:`startup.notInstalled`)}),!e.shimInstalled&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-shim`),children:o(r===`install-shim`?`startup.installing`:`startup.install`)}),c&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-shim`,{repair:!0}),children:o(r===`install-shim`?`startup.repairing`:`startup.repair`)})]})]}),i&&(0,J.jsx)(`div`,{className:`notice ${i.kind===`success`?`notice-ok`:`notice-warn`} startup-action-notice`,role:`status`,"aria-live":`polite`,children:i.kind===`success`?i.action===`install-service`?o(i.repair?`startup.serviceRepaired`:`startup.serviceInstalled`):o(i.repair?`startup.shimRepaired`:`startup.shimInstalled`):`${o(`startup.installFailed`)} ${i.detail??``}`})]})}function Lb({tray:e,trayLoading:t,trayError:n,trayBusy:r,onTrayAction:i}){let{t:a}=ut();return(0,J.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,J.jsxs)(`div`,{className:`panel-head`,children:[(0,J.jsx)(`h3`,{className:`panel-title`,children:a(`startup.tray.title`)}),(0,J.jsx)(Te,{})]}),(0,J.jsx)(`p`,{className:`muted`,children:a(`startup.tray.hint`)}),(0,J.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:a(`startup.tray.login`)}),(0,J.jsx)(`span`,{children:a(`startup.tray.notProtection`)})]}),t||n||!e?(0,J.jsx)(`span`,{className:`badge badge-amber`,children:a(t?`startup.tray.loading`:`startup.tray.unavailable`)}):(0,J.jsx)(Pb,{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,J.jsxs)(`div`,{className:`startup-tray-buttons`,children:[!t&&!n&&e&&!e.installed&&!e.stale&&(0,J.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,J.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,J.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,J.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,J.jsx)(`div`,{className:`notice notice-warn startup-tray-error`,role:`alert`,children:a(`startup.tray.error`)})]})}function Rb({data:e,copied:t,onCopy:n}){let{t:r}=ut(),i=e.serviceInstalled&&!e.serviceConflict?e.commands.repairService:e.commands.installService;return(0,J.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,J.jsxs)(`div`,{className:`panel-head`,children:[(0,J.jsx)(`h3`,{className:`panel-title`,children:r(`startup.recovery`)}),(0,J.jsx)(se,{})]}),(0,J.jsxs)(`details`,{className:`startup-recovery-details`,open:e.status!==`protected`,children:[(0,J.jsx)(`summary`,{className:`muted`,children:r(`startup.recoveryHint`)}),(0,J.jsxs)(`div`,{className:`startup-command-list`,children:[e.serviceSupported&&(0,J.jsxs)(`div`,{className:`startup-command-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r(`startup.command.service`)}),(0,J.jsx)(`code`,{children:i})]}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(i),children:r(t===i?`startup.copied`:`startup.copy`)})]}),(0,J.jsxs)(`div`,{className:`startup-command-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r(`startup.command.shim`)}),(0,J.jsx)(`code`,{children:e.commands.installShim})]}),(0,J.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,J.jsxs)(`div`,{className:`startup-command-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r(`startup.command.native`)}),(0,J.jsx)(`code`,{children:e.commands.restoreNative})]}),(0,J.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,J.jsxs)(`div`,{className:`notice notice-warn startup-action-notice`,role:`alert`,children:[(0,J.jsx)(Te,{}),` `,r(`startup.recommended`,{cmd:e.recommendedCommand??e.commands.installService})]})]})]})}var zb=`ocx.startup.page.v1:`;function Bb(e,t){let n=t===`win32`?`; `:` && `;return e.join(n)}function Vb(e,t,n){if(!e)return{warning:null,fix:null};let r=!!e.catalogClamp?.active,i=!!e.newerAvailable,a=(r?e.catalogClamp?.runtimeVersion:e.version)??e.version??`unknown`,o=(e.catalogClamp?.removedEfforts??[]).join(`, `),s=Bb([`ocx doctor --fix-codex-runtime`,`ocx sync`],n);return r?{warning:o?t(`startup.codexRuntime.clampHiddenWithEfforts`,{version:a,efforts:o}):t(`startup.codexRuntime.clampHidden`,{version:a}),fix:i?s:`ocx sync`}:i?{warning:t(`startup.codexRuntime.olderBinary`,{version:a}),fix:s}:{warning:null,fix:null}}function Hb({apiBase:e,machineApiBase:t=e,connected:n=!1}){let{t:r}=ut(),i=`${zb}${e}`,a=(0,_.useMemo)(()=>vr(i),[i]),o=`startup-page:${e}`,[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(()=>a?.tray??null),[d,f]=(0,_.useState)(()=>!a?.data),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(()=>a?.warning??null),[w,T]=(0,_.useState)(()=>a?.fix??null),[E,D]=(0,_.useState)(()=>!a?.data),O=(0,_.useRef)(!!a?.data),k=(0,_.useRef)(0),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)(!1);(0,_.useEffect)(()=>{if(!n)return;let e=new AbortController;return fetch(`${t}/api/machine/shim`,{signal:e.signal}).then(e=>e.ok?e.json():null).then(t=>{e.signal.aborted||j(t)}).catch(()=>{e.signal.aborted||j(null)}),()=>e.abort()},[n,t]);let P=async e=>{N(!0);try{let n=await fetch(`${t}/api/machine/shim`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:e})});if(n.ok){let e=await n.json();j(e.shim??null)}}finally{N(!1)}};(0,_.useEffect)(()=>()=>{k.current+=1},[e]);let F=(0,_.useCallback)(async t=>{let n=++k.current,a=O.current;a||(f(!0),D(!0));try{let a=fetch(`${e}/api/settings`,{signal:t}).then(async e=>e.ok?await e.json():null).catch(()=>null),o=await fetch(`${e}/api/startup-health`,{signal:t});if(!o.ok)throw Error(`fetch failed`);let s=await o.json();x(e=>e?.kind===`error`&&(s.status===`native`&&e.forLocalRouting===!0||(e.action===`install-service`?s.serviceViable:s.shimInstalled&&s.shimHealthy))?null:e),O.current=!0;let c=vr(i);Sr(i,{data:s,warning:c?.warning??null,fix:c?.fix??null,tray:c?.tray??null});let l=s.platform===`win32`?fetch(`${e}/api/windows-tray`,{signal:t}).then(async e=>{if(!e.ok)throw Error(`tray status failed`);let t=await e.json();if(!Ab(t))throw Error(`invalid tray status`);return{tray:t,error:!1}}).catch(()=>({tray:null,error:!0})):Promise.resolve({tray:null,error:!1});return Promise.all([a,l]).then(([e,a])=>{if(t.aborted||n!==k.current)return;let o=s.platform===`win32`?a.tray:null;if(s.platform===`win32`?(u(o),g(a.error)):(u(null),g(!1)),f(!1),D(!1),e){let t=Vb(e.codexRuntime,r,s.platform);C(t.warning),T(t.fix),Sr(i,{data:s,warning:t.warning,fix:t.fix,tray:o});return}let c=vr(i);Sr(i,{data:s,warning:c?.warning??null,fix:c?.fix??null,tray:o})}),s}catch(e){throw t.aborted?e:(a||(u(null),g(!0),C(null),T(null)),D(!1),f(!1),e)}},[e,i,r]),I=$(o,[e],F,{isEmpty:()=>!1,initialData:a?.data??void 0}),L=I.state,R=I.refresh,z=L.data??a?.data??null,B=L.refreshing,V=!!z?.diagnosticStale||L.showError;(0,_.useEffect)(()=>{if(!z?.diagnosticStale)return;let e=window.setTimeout(R,2e3);return()=>window.clearTimeout(e)},[z,R]);let H=async e=>{try{await navigator.clipboard.writeText(e),c(e),window.setTimeout(()=>c(t=>t===e?null:t),1600)}catch{c(null)}},U=async t=>{m(!0),g(!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(!Ab(r.status))throw Error(`invalid tray action status`);u(r.status),g(!1)}catch{u(null),g(!0)}finally{m(!1)}},W=async(t,n)=>{y(t),x(null);try{let r=await fetch(`${e}/api/startup-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t,repair:n?.repair===!0})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(typeof e?.error==`string`?e.error:`installation failed`)}x({kind:`success`,action:t,repair:n?.repair===!0}),R()}catch(e){x({kind:`error`,action:t,repair:n?.repair===!0,detail:e instanceof Error?e.message:String(e),forLocalRouting:z?.localRoutingDependency===!0})}finally{y(null)}};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`page-head`,children:[(0,J.jsx)(`h2`,{children:r(`startup.title`)}),(0,J.jsx)(`div`,{className:`startup-page-head-actions`,children:(0,J.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>R(),disabled:B,children:[(0,J.jsx)(pe,{}),` `,r(`startup.refresh`)]})})]}),n&&(0,J.jsxs)(`section`,{className:`notice startup-page-notice`,"aria-label":r(`connection.machine.title`),children:[(0,J.jsx)(`strong`,{children:r(`connection.machine.title`)}),(0,J.jsx)(`span`,{children:A?.healthy?r(`connection.machine.shimHealthy`):r(`connection.machine.shimNeedsAttention`)}),(0,J.jsxs)(`div`,{className:`startup-page-head-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:M,onClick:()=>void P(`repair`),children:r(`connection.machine.repairShim`)}),A?.installed&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:M,onClick:()=>void P(`uninstall`),children:r(`connection.machine.removeShim`)})]})]}),L.showSkeleton&&!z?(0,J.jsx)(Nl,{label:r(`startup.loading`),rows:5}):L.kind===`failed-cold`?(0,J.jsxs)(`div`,{className:`startup-page-notice`,children:[(0,J.jsx)(Q,{tone:`err`,children:L.error instanceof Error?L.error.message:r(`startup.error`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>R(),children:r(`common.retry`)})]}):z?(0,J.jsxs)(J.Fragment,{children:[L.showError&&(0,J.jsx)(Q,{tone:`err`,children:r(`startup.error`)}),V&&(0,J.jsx)(`div`,{className:`notice notice-warn startup-page-notice`,role:`alert`,children:r(`startup.staleData`)}),(E||S)&&(0,J.jsx)(`div`,{className:`startup-runtime-notice-slot${E&&!S?` startup-runtime-notice-slot--pending`:``}`,"aria-hidden":E&&!S?!0:void 0,children:S&&(0,J.jsxs)(`div`,{className:`notice notice-warn startup-page-notice startup-runtime-notice`,role:`status`,children:[(0,J.jsx)(`p`,{className:`startup-runtime-notice__text`,children:S}),w&&(0,J.jsxs)(`div`,{className:`startup-runtime-notice__fix`,children:[(0,J.jsx)(`code`,{children:w}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void H(w),children:r(s===w?`startup.copied`:`startup.copy`)})]})]})}),(0,J.jsx)(Fb,{failed:V,data:z}),(0,J.jsx)(Ib,{data:z,failed:V,loading:B,installBusy:v,installResult:b,onInstall:(e,t)=>{W(e,t)}}),z.platform===`win32`&&(0,J.jsx)(Lb,{tray:l,trayLoading:d,trayError:h,trayBusy:p,onTrayAction:e=>{U(e)}}),(0,J.jsx)(Rb,{data:z,copied:s,onCopy:e=>{H(e)}})]}):null]})}var Ub=3e5,Wb=6e5,Gb=`https://github.com/lidge-jun/opencodex`;async function Kb(e,t){let n=await fetch(e,{signal:t});return n.ok?await n.json():null}function qb({apiBase:e,onOpenUpdate:t}){let n=Z(),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),s=G(`sidebar-star:${e}`,[e],t=>Kb(`${e}/api/github/star`,t),{pollMs:Ub}),c=G(`sidebar-update-badge:${e}`,[e],t=>Kb(`${e}/api/update/badge`,t),{pollMs:Wb}),l=s.data?.state??null,u=a!==null&&a.basedOn===l?a.state:l??`not-starred`,d=s.data?.url??Gb,f=u===`starred`,p=c.data,m=p?.updateAvailable===!0,h=p?.latestVersion??null,g=()=>window.open(d,`_blank`,`noopener,noreferrer`),v=async()=>{if(!(f||r)){if(u===`unauthenticated`){g();return}i(!0);try{let t=await fetch(`${e}/api/github/star`,{method:`POST`}),n=t.ok?await t.json():null;if(n?.ok===!0){o({state:`starred`,basedOn:l});return}n?.state&&o({state:n.state,basedOn:l}),g()}catch{g()}finally{i(!1),s.refresh()}}},y=n(f?`sidebar.starred`:u===`unauthenticated`?`sidebar.starUnauthenticated`:`sidebar.star`),b=m&&h?n(`sidebar.updateAvailable`,{version:h}):n(`sidebar.checkUpdate`);return(0,J.jsxs)(`div`,{className:`sidebar-github-row`,children:[(0,J.jsxs)(`a`,{className:`sidebar-link sidebar-github-link`,href:d,target:`_blank`,rel:`noreferrer`,children:[(0,J.jsx)(we,{}),` `,n(`common.github`)]}),(0,J.jsxs)(`div`,{className:`sidebar-github-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb${f?` sidebar-orb--starred`:``}`,onClick:()=>{v()},disabled:r||f,"aria-label":y,"aria-pressed":f,title:y,children:(0,J.jsx)(Re,{"aria-hidden":`true`,...f?{fill:`currentColor`}:{}})}),(0,J.jsxs)(`button`,{type:`button`,className:`sidebar-orb${m?` sidebar-orb--update`:``}`,onClick:t,"aria-label":b,title:b,children:[(0,J.jsx)(Se,{"aria-hidden":`true`}),m&&(0,J.jsx)(`span`,{className:`sidebar-orb-dot`,"aria-hidden":`true`})]})]})]})}var Jb=`opencodex-admin-token-dialog`,Yb=`OpenCodex`,Xb=`https://opencodex.me/guides/web-dashboard/#finding-the-admin-token`;function Zb(e,t=ot()){let n=$e[t],r=n[`auth.adminTokenTitle`];return new Promise(t=>{let i=document.activeElement instanceof HTMLElement?document.activeElement:null,a=!1,o=document.createElement(`dialog`);o.id=Jb,o.className=`modal-overlay`,o.setAttribute(`aria-labelledby`,`${Jb}-title`);let s=document.createElement(`form`);s.className=`modal-card`,s.method=`post`,s.action=window.location.href,s.autocomplete=`on`;let c=document.createElement(`div`);c.className=`modal-head`;let l=document.createElement(`h3`);l.id=`${Jb}-title`,l.textContent=r,c.append(l);let u=document.createElement(`div`),d=document.createElement(`label`);d.className=`field-label`,d.htmlFor=`${Jb}-username`,d.textContent=n[`auth.adminAccountLabel`];let f=document.createElement(`input`);f.id=d.htmlFor,f.className=`input`,f.type=`text`,f.name=`username`,f.autocomplete=`username`,f.value=Yb,f.readOnly=!0,u.append(d,f);let p=document.createElement(`div`);p.style.marginTop=`var(--space-4)`;let m=document.createElement(`label`);m.className=`field-label`,m.htmlFor=`${Jb}-password`,m.textContent=n[`auth.adminTokenFieldLabel`];let h=document.createElement(`input`);h.id=m.htmlFor,h.className=`input`,h.type=`password`,h.name=`password`,h.autocomplete=`current-password`,h.required=!0,h.spellcheck=!1,h.autocapitalize=`none`,p.append(m,h);let g=document.createElement(`p`);g.className=`hint`,g.style.marginTop=`var(--space-2)`,g.textContent=n[`auth.adminTokenHelp`];let _=document.createElement(`a`);_.className=`text-control`,_.href=Xb,_.target=`_blank`,_.rel=`noreferrer`,_.style.color=`var(--accent)`,_.textContent=n[`auth.adminTokenDocsLink`],g.append(` `,_),p.append(g);let v=document.createElement(`div`);v.className=`notice notice-err`,v.setAttribute(`role`,`alert`),v.hidden=!0;let y=document.createElement(`div`);y.className=`modal-actions`;let b=document.createElement(`button`);b.type=`button`,b.className=`btn btn-ghost`,b.textContent=n[`common.cancel`];let x=document.createElement(`button`);x.type=`submit`,x.className=`btn btn-primary`,x.textContent=n[`common.ok`],y.append(b,x),s.append(c,u,p,v,y),o.append(s);let S=e=>{v.textContent=e??``,v.hidden=e===null},C=e=>{a||(a=!0,o.open&&o.close(),o.remove(),i?.focus(),t(e))};s.addEventListener(`submit`,t=>{t.preventDefault();let r=h.value.trim();if(!r){h.value=``,h.reportValidity();return}h.disabled=!0,x.disabled=!0,S(null),e(r).then(e=>{if(!a){if(e===`accepted`){C(r);return}h.value=``,h.disabled=!1,x.disabled=!1,S(e===`rejected`?n[`auth.adminTokenRejected`]:n[`auth.adminTokenUnavailable`]),h.focus()}}).catch(()=>{a||(h.value=``,h.disabled=!1,x.disabled=!1,S(n[`auth.adminTokenUnavailable`]),h.focus())})}),b.addEventListener(`click`,()=>C(null)),o.addEventListener(`cancel`,e=>{e.preventDefault(),C(null)}),document.body.append(o),typeof o.showModal==`function`?o.showModal():o.setAttribute(`open`,``),queueMicrotask(()=>h.focus())})}var Qb=`opencodex:session-unavailable`,$b=`opencodex-api-token`,ex=`/api/settings`,tx=1e4,nx=15e3,rx=`X-OpenCodex-Machine-Session`,ix=`X-OpenCodex-Machine-GUI-Origin`,ax=`X-OpenCodex-Machine-CSRF-Token`,ox=!1,sx=null,cx=null,lx=Zb,ux=tx,dx=nx,fx=new Map;function px(e){if(typeof window>`u`)return;let t=window.CustomEvent??(typeof CustomEvent==`function`?CustomEvent:null);if(t)try{window.dispatchEvent(new t(Qb,{detail:{plane:e}}))}catch{}}function mx(){return{token:null,csrfToken:null,browserOrigin:null,serverOrigin:null}}function hx(){return cx||_x(w_(``)),cx}function gx(e,t){return e.baseUrl===t.baseUrl&&e.serverOrigin===t.serverOrigin&&e.transport===t.transport}function _x(e){cx=e;for(let t of[`machine`,`shared`]){let n=fx.get(t);fx.set(t,n&&gx(n.target,e[t])?{...n,target:e[t]}:{target:e[t],session:mx(),resolutionInFlight:null,promptCancelled:!1})}}function vx(e){return hx(),fx.get(e)}function yx(e,t){let n=vx(e);t!==null&&n.session.token===t&&(n.session=mx())}function bx(e,t,n,r,i){let a=vx(e);return!t?.startsWith(`ocx_session_`)||!n||r!==window.location.origin||i!==a.target.serverOrigin?(a.session=mx(),!1):(a.session={token:t,csrfToken:n,browserOrigin:r,serverOrigin:i},a.promptCancelled=!1,!0)}function xx(e){return!!vx(e).session.token?.startsWith(`ocx_session_`)}async function Sx(e){let t=vx(e);if(!t.session.token?.startsWith(`ocx_session_`))return!1;let n=Un(tx);try{return(await window.fetch(`${t.target.baseUrl}/api/session/logout`,{method:`POST`,signal:n.signal})).ok?(t.session=mx(),t.promptCancelled=!1,!0):!1}catch{return!1}finally{n.clear()}}function Cx(e){let t=document.querySelector(`meta[name="${e}"]`),n=t?.content.trim()||null;return t?.remove(),n}function wx(){let e={token:Cx(`opencodex-session-token`),csrf:Cx(`opencodex-session-csrf`),browser:Cx(`opencodex-session-origin`),server:Cx(`opencodex-session-server-origin`)};for(let t of[`machine`,`shared`])vx(t).target.serverOrigin===e.server&&bx(t,e.token,e.csrf,e.browser,e.server)}function Tx(e,t){for(let n of e.match(/<meta\b[^>]*>/gi)??[])if(n.match(/\bname=["']([^"']+)["']/i)?.[1]===t)return n.match(/\bcontent=["']([^"']*)["']/i)?.[1]?.trim()||null;return null}function Ex(e,t){return bx(e,Tx(t,`opencodex-session-token`),Tx(t,`opencodex-session-csrf`),Tx(t,`opencodex-session-origin`),Tx(t,`opencodex-session-server-origin`))}function Dx(){try{sessionStorage.removeItem($b)}catch{}}function Ox(e){return new URL(e.baseUrl||`/`,window.location.href)}function kx(e,t){let n=Ox(e);if(t.origin!==n.origin)return!1;let r=n.pathname.replace(/\/$/,``);return r===``||t.pathname===r||t.pathname.startsWith(`${r}/`)}function Ax(e,t){if(!kx(e,t))return null;let n=Ox(e).pathname.replace(/\/$/,``);return t.pathname.slice(n.length)||`/`}function jx(e){let t;try{t=new URL(e instanceof Request?e.url:String(e),window.location.href)}catch{return null}let n=hx();return t.href===new URL(n.shared.bootstrapPath,window.location.href).href?{plane:`shared`,bootstrap:!0}:n.shared.transport===`relay`&&kx(n.shared,t)?{plane:`shared`,bootstrap:!1}:Ax(n.machine,t)?.startsWith(`/api/machine/`)?{plane:`machine`,bootstrap:!1}:Ax(n.shared,t)?.startsWith(`/api/`)?{plane:`shared`,bootstrap:!1}:t.href===new URL(n.machine.bootstrapPath,window.location.href).href?{plane:`machine`,bootstrap:!0}:null}function Mx(e,t,n,r){let i=vx(e),a=new Headers(n?.headers??(t instanceof Request?t.headers:void 0)),o=r===void 0?i.session.token:r,s=(n?.method??(t instanceof Request?t.method:`GET`)).toUpperCase();if(o&&a.set(`X-OpenCodex-API-Key`,o),o?.startsWith(`ocx_session_`)&&i.session.browserOrigin&&i.session.csrfToken&&(a.set(`X-OpenCodex-GUI-Origin`,i.session.browserOrigin),s!==`GET`&&s!==`HEAD`&&a.set(`X-OpenCodex-CSRF-Token`,i.session.csrfToken)),e===`shared`&&i.target.transport===`relay`){let e=vx(`machine`).session;e.token&&a.set(rx,e.token),e.browserOrigin&&a.set(ix,e.browserOrigin),s!==`GET`&&s!==`HEAD`&&e.csrfToken&&a.set(ax,e.csrfToken)}return a}function Nx(e,t,n,r){let i=Mx(e,t,n,r);return t instanceof Request?[new Request(t,{headers:i}),n?{...n,headers:i}:void 0]:[t,{...n,headers:i}]}async function Px(e){if(!sx)return{kind:`failed`};let t=vx(e),n=Un(ux);try{let[r,i]=Nx(e,t.target.bootstrapPath,{cache:`no-store`,signal:n.signal},null),a=await sx(r,i);return a.ok?Ex(e,await a.text())?{kind:`minted`,token:vx(e).session.token}:{kind:`unavailable`}:a.status>=400&&a.status<500?{kind:`unavailable`}:{kind:`failed`}}catch{return{kind:`failed`}}finally{n.clear()}}async function Fx(e,t){if(!sx)return`unavailable`;try{let[n,r]=Nx(e,`${vx(e).target.baseUrl}${ex}`,{cache:`no-store`},t),i=await sx(n,r);return i.status===401?`rejected`:i.ok?`accepted`:`unavailable`}catch{return`unavailable`}}async function Ix(e,t,n){let r=vx(e);if(r.promptCancelled||n?.aborted)return null;if(!r.resolutionInFlight){let n=(async()=>{let n=r.session.token;if(n&&n!==t)return n;let i,a=await Promise.race([Px(e),new Promise(e=>{i=setTimeout(()=>e({kind:`failed`}),dx)})]).finally(()=>clearTimeout(i));if(a.kind===`minted`)return a.token;if(a.kind===`failed`)return null;if(!y_())return r.promptCancelled=!0,px(e),null;let o=await lx(t=>Fx(e,t));return o?(r.session={token:o,csrfToken:null,browserOrigin:null,serverOrigin:r.target.serverOrigin},o):(r.promptCancelled=!0,null)})().finally(()=>{r.resolutionInFlight===n&&(r.resolutionInFlight=null)});r.resolutionInFlight=n}if(!n)return r.resolutionInFlight;let i,a=new Promise(e=>{i=()=>e(null),n.addEventListener(`abort`,i,{once:!0})});return Promise.race([r.resolutionInFlight,a]).finally(()=>{i&&n.removeEventListener(`abort`,i)})}function Lx(){if(ox)return;ox=!0,Dx(),hx(),wx();let e=window.fetch.bind(window);sx=e,window.fetch=async(t,n)=>{let r=jx(t);if(!r)return e(t,n);let i=vx(r.plane),a=i.session.token,[o,s]=Nx(r.plane,t,n),c=await e(o,s);if(r.bootstrap||c.status!==401)return c;let l=i.session.token;if(l&&l!==a){let[i,a]=Nx(r.plane,t,n),o=await e(i,a);if(o.status!==401)return o;yx(r.plane,l)}else yx(r.plane,a);let u=n?.signal??(t instanceof Request?t.signal:void 0),d=await Ix(r.plane,a,u??void 0);if(!d)return c;let[f,p]=Nx(r.plane,t,n,d),m=await e(f,p);return m.status===401&&yx(r.plane,d),m}}var Rx=/^ocx_pair_[A-Za-z0-9_-]{43}$/;async function zx(e,t,n){let r=t.trim();if(!Rx.test(r))throw Error(`pairing_code_invalid`);let i=await(n??((e,t)=>window.fetch(e,t)))(e.bootstrapPath,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`text/html`},body:JSON.stringify({grant:r})});if(!i.ok)throw Error(`pairing_refused`);if(!Ex(`shared`,await i.text()))throw Error(`pairing_response_invalid`);return!0}function Bx({target:e,onConnected:t}){let n=Z(),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1);return(0,_.createElement)(`section`,{className:`card connect-pairing`,"aria-labelledby":`connect-pairing-title`},(0,_.createElement)(`h2`,{id:`connect-pairing-title`},n(`connection.pairing.title`)),(0,_.createElement)(`p`,null,n(e.transport===`relay`?`connection.pairing.relayWarning`:`connection.pairing.body`)),(0,_.createElement)(`form`,{onSubmit:async n=>{if(n.preventDefault(),!a){o(!0),c(!1);try{await zx(e,r),t()}catch{c(!0)}finally{o(!1)}}},className:`api-form-row`},(0,_.createElement)(`label`,{htmlFor:`connect-pairing-code`,className:`field-label`},n(`connection.pairing.code`)),(0,_.createElement)(`input`,{id:`connect-pairing-code`,name:`pairingCode`,value:r,onChange:e=>i(e.currentTarget.value),autoComplete:`off`,spellCheck:!1,disabled:a,className:`input mono`,"aria-invalid":s||void 0,"aria-describedby":s?`connect-pairing-error`:void 0}),(0,_.createElement)(`button`,{type:`submit`,className:`btn btn-primary`,disabled:a||!r.trim()},n(a?`connection.pairing.submitting`:`connection.pairing.submit`)),s?(0,_.createElement)(`p`,{id:`connect-pairing-error`,className:`alert alert-err`,role:`alert`},n(`connection.pairing.error`)):null))}var Vx=new Set([`dashboard`,`startup`,`providers`,`models`,`subagents`,`logs`,`usage`,`storage`,`codex-set`,`integrations`]);function Hx(e){let t=pt(e??(typeof window<`u`?window.location.hash:``)).split(`/`)[0];return t===`debug`?`logs`:t===`codex-auth`?`codex-set`:t===`combos`||t===`routing`||t===`lab`?`models`:t===`api`||t===`claude`||t===`grok`?`integrations`:Vx.has(t)?t:`dashboard`}var Ux=[`dashboard/providers`,`dashboard/models`],Wx=[`models/combos`,`models/routing`,`models/compatibility`],Gx=[`integrations/keys`,`integrations/codex`,`integrations/claude`,`integrations/claude/desktop`,`integrations/grok`,`integrations/cursor`,`integrations/opencode`,`integrations/pi`,`integrations/omp`,`integrations/hermes`,`integrations/openclaw`,`integrations/kimi`,`integrations/gajae`,`integrations/dsh`,`integrations/mcode`,`integrations/zcode`,`integrations/prime`,`integrations/aside`];function Kx(e,t){return e===t||t===`logs`&&e===`logs/debug`||t===`codex-set`&&e===`codex-set/prompt`||t===`models`&&Wx.includes(e)||t===`dashboard`&&(e===`dashboard/update`||Ux.includes(e))||t===`integrations`&&Gx.includes(e)}function qx(e){let t=Hx(e);return e===`debug`||e.startsWith(`debug/`)?{page:`logs`,replaceTo:`logs/debug`}:e===`codex-auth`||e.startsWith(`codex-auth/`)?{page:`codex-set`,replaceTo:`codex-set`}:e===`combos`||e.startsWith(`combos/`)?{page:`models`,replaceTo:`models/combos`}:e===`routing`||e.startsWith(`routing/`)?{page:`models`,replaceTo:`models/routing`}:e===`lab`||e.startsWith(`lab/`)?{page:`models`,replaceTo:`models/compatibility`}:e===`api`?{page:`integrations`,replaceTo:`integrations/keys`}:e===`claude`?{page:`integrations`,replaceTo:`integrations/claude`}:e===`grok`?{page:`integrations`,replaceTo:`integrations/grok`}:e===`providers/workspace`?{page:`providers`,replaceTo:`providers`}:Kx(e,t)?{page:t,replaceTo:null}:{page:t,replaceTo:t}}var Jx=[`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 Yx(){try{for(let e of Jx)localStorage.removeItem(e)}catch{}}function Xx(){let[e,t]=(0,_.useState)(Hx);(0,_.useEffect)(()=>{Yx()},[]);let n=(0,_.useCallback)(e=>{let n=qx(e);n.replaceTo&&mt(n.replaceTo),t(n.page)},[]);return(0,_.useEffect)(()=>{let e=()=>{n(pt(window.location.hash))};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[n]),(0,_.useEffect)(()=>{let n=qx(pt(window.location.hash));n.replaceTo&&mt(n.replaceTo),n.page!==e&&t(n.page)},[e]),{page:e,setPageState:t,navigateToPage:(e,n)=>{ht(n?`${e}/${n}`:e),t(e)}}}var Zx=15e3;function Qx(e,t,n){return typeof e?.message==`string`&&e.message.trim()?e.message:typeof e?.error==`string`&&e.error.trim()?e.error:n(t)}function $x(e){return(e instanceof DOMException||e instanceof Error)&&e.name===`AbortError`}async function eS(e,t={}){let{fetchFn:n=fetch,timeoutMs:r=Zx,formatFailure:i=e=>`Failed to stop proxy (HTTP ${e}).`,mode:a=`standalone`}=t,o;try{o=await n(`${e}${a===`client`?`/api/machine/disconnect`:`/api/stop`}`,{method:`POST`,...a===`client`?{headers:{"Content-Type":`application/json`},body:`{}`}:{},signal:AbortSignal.timeout(r)})}catch(e){return $x(e),{accepted:!0}}let s=await o.json().catch(()=>null);return!o.ok||s?.success===!1?{accepted:!1,message:Qx(s,o.status,i)}:{accepted:!0}}var tS={dashboard:`nav.dashboard`,startup:`nav.startup`,providers:`nav.providers`,models:`nav.models`,subagents:`nav.subagents`,logs:`nav.logs`,usage:`nav.usage`,storage:`nav.storage`,"codex-set":`nav.codexSet`,integrations:`nav.integrations`},nS=``,rS=w_(nS);_x(rS),Lx();var iS=`ocx-theme`,aS=[{id:`dashboard`,tkey:`nav.dashboard`,Icon:te},{id:`codex-set`,tkey:`nav.codexSet`,Icon:Oe},{id:`providers`,tkey:`nav.providers`,Icon:ne},{id:`models`,tkey:`nav.models`,Icon:re},{id:`subagents`,tkey:`nav.subagents`,Icon:ie},{id:`logs`,tkey:`nav.logs`,Icon:ae},{id:`usage`,tkey:`nav.usage`,Icon:ce},{id:`storage`,tkey:`nav.storage`,Icon:le},{id:`integrations`,tkey:`nav.integrations`,Icon:Fe}],oS={light:Me,dark:Ne,system:Pe},sS={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function cS(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 lS(){let e=localStorage.getItem(iS);return e===`light`||e===`dark`?e:`system`}function uS(){let{page:e,navigateToPage:t}=Xx(),[n,r]=(0,_.useState)(Zf);(0,_.useEffect)(()=>{let e=()=>r(Zf());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let[i,a]=(0,_.useState)(lS),{locale:o,setLocale:s}=ut(),c=Z(),[l,u]=(0,_.useState)(rS),[d,f]=(0,_.useState)(()=>!v_()),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(()=>xx(`shared`)),[v,y]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=new AbortController;return O_(nS,e.signal).then(async t=>{if(_x(t),u(t),t.connected&&!xx(`shared`))try{let n=await fetch(t.shared.bootstrapPath,{cache:`no-store`,signal:AbortSignal.any([e.signal,AbortSignal.timeout(5e3)])});n.ok&&Ex(`shared`,await n.text())}catch{}e.signal.aborted||(g(xx(`shared`)),m(!1),f(!0))}).catch(()=>{e.signal.aborted||(m(!0),f(!0))}),()=>e.abort()},[]);let b=D_(`machine`,l),x=D_(`shared`,l),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(null),T=(0,_.useRef)(null),E=(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;i===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(iS)):(e.setAttribute(`data-theme`,i),localStorage.setItem(iS,i))},[i]);let D=G(`app-healthz:${b}`,[b,d],async e=>{let t=await fetch(`${b}/healthz`,{signal:e});return t.ok?cS(await t.json()):null},{pollMs:3e4,enabled:d}),O=()=>a(e=>e===`light`?`dark`:e===`dark`?`system`:`light`),k=oS[i],A=D.data??`2.43.0-preview.20260906`,[j,M]=(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){E.current=!0;let e=setTimeout(()=>T.current?.focus(),200);return()=>clearTimeout(e)}E.current&&(E.current=!1,w.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[N,P]=(0,_.useState)(0),{restarting:F,restart:I}=Tl(x,{onSettled:()=>P(e=>e+1)}),L=async()=>{if(!confirm(c(l.connected?`connection.disconnectConfirm`:`dash.stopConfirm`)))return;M(!0);let e=await eS(b,{formatFailure:e=>c(`dash.stopFailed`,{status:String(e)}),mode:l.connected?`client`:`standalone`});e.accepted||(M(!1),alert(e.message))},R=async()=>{if(v)return;y(!0);let e=await Sx(`shared`);y(!1),e?g(!1):alert(c(`connection.sessionLogoutFailed`))},z=(0,J.jsxs)(`button`,{type:`button`,className:`brand brand-home`,onClick:()=>{t(`dashboard`),C(!1)},"aria-label":c(`nav.goHome`),title:c(`nav.goHome`),...e===`dashboard`?{"aria-current":`page`}:{},children:[(0,J.jsx)(`span`,{className:`brand-logo`,role:`img`,"aria-label":c(`app.logoAria`)}),(0,J.jsx)(`span`,{className:`name`,children:`opencodex`}),(0,J.jsxs)(`span`,{className:`ver`,children:[`v`,A]})]});return(0,J.jsxs)(`div`,{className:`app`,children:[(0,J.jsxs)(`header`,{className:`mobile-topbar`,inert:S,children:[(0,J.jsx)(`button`,{ref:w,type:`button`,className:`menu-toggle`,onClick:()=>C(e=>!e),"aria-expanded":S,"aria-controls":`app-sidebar`,"aria-label":c(S?`nav.closeMenu`:`nav.openMenu`),title:c(S?`nav.closeMenu`:`nav.openMenu`),children:(0,J.jsx)(oe,{})}),z,(0,J.jsxs)(`div`,{className:`mobile-topbar-actions`,children:[l.connected&&h&&(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb`,onClick:()=>{R()},disabled:v,"aria-label":c(v?`connection.sessionLoggingOut`:`connection.sessionLogout`),title:c(`connection.sessionLogout`),children:(0,J.jsx)(de,{})}),(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb sidebar-orb--danger`,onClick:L,disabled:j,"aria-label":c(l.connected?`connection.disconnect`:`dash.stop`),title:c(l.connected?`connection.disconnect`:`dash.stop`),children:(0,J.jsx)(Te,{})}),(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb`,onClick:()=>{I()},disabled:F,"aria-label":c(`dash.codexRestart`),title:c(`dash.codexRestart`),children:(0,J.jsx)(pe,{})})]})]}),S&&(0,J.jsx)(`div`,{className:`drawer-scrim`,onClick:()=>C(!1),"aria-hidden":`true`}),(0,J.jsxs)(`aside`,{id:`app-sidebar`,className:`sidebar${S?` open`:``}`,ref:T,tabIndex:-1,children:[(0,J.jsxs)(`div`,{className:`drawer-head`,children:[z,(0,J.jsx)(`button`,{type:`button`,className:`menu-toggle drawer-close`,onClick:()=>C(!1),"aria-label":c(`nav.closeMenu`),title:c(`nav.closeMenu`),children:(0,J.jsx)(de,{})})]}),(0,J.jsx)(`nav`,{children:aS.map(n=>{let{id:r,tkey:i,Icon:a}=n,o=r===e;return(0,J.jsx)(`div`,{className:`nav-entry`,children:(0,J.jsxs)(`button`,{type:`button`,className:`nav-item${o?` active`:``}`,"data-page":r,onClick:()=>{t(r),C(!1)},"aria-current":o?`page`:void 0,children:[(0,J.jsx)(a,{}),` `,c(i)]})},r)})}),(0,J.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,J.jsxs)(`div`,{className:`lang-toggle`,children:[(0,J.jsx)(Fe,{"aria-hidden":!0}),(0,J.jsx)(kt,{value:o,options:nt.map(e=>({value:e.code,label:et(e.code)})),onChange:e=>s(e),label:c(`lang.label`),placement:`right`,portal:!1,style:{flex:1,minWidth:0,width:`100%`}})]}),(0,J.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:O,"aria-label":`${c(`theme.label`)}: ${c(sS[i])}`,title:`${c(`theme.label`)}: ${c(sS[i])}`,children:[(0,J.jsx)(k,{}),` `,(0,J.jsx)(`span`,{className:`mode`,children:c(sS[i])})]}),(0,J.jsxs)(`div`,{className:`sidebar-action-row`,children:[(0,J.jsx)(`span`,{className:`sidebar-action-label`,children:c(`dash.actions`)}),(0,J.jsxs)(`div`,{className:`sidebar-action-orbs`,children:[l.connected&&h&&(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb`,onClick:()=>{R()},disabled:v,"aria-label":c(v?`connection.sessionLoggingOut`:`connection.sessionLogout`),title:c(`connection.sessionLogout`),children:(0,J.jsx)(de,{})}),(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb sidebar-orb--danger`,onClick:L,disabled:j,"aria-label":c(j?`dash.stopping`:l.connected?`connection.disconnect`:`dash.stop`),title:c(j?`dash.stopping`:l.connected?`connection.disconnect`:`dash.stop`),children:(0,J.jsx)(Te,{})}),(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb`,onClick:()=>{I()},disabled:F,"aria-label":c(F?`dash.codexRestarting`:`dash.codexRestart`),title:c(F?`dash.codexRestarting`:`dash.codexRestart`),children:(0,J.jsx)(pe,{})})]})]}),(0,J.jsx)(qb,{apiBase:x,onOpenUpdate:()=>{C(!1),t(`dashboard`,`update`)}})]})]}),(0,J.jsx)(`main`,{className:`main`,inert:S,children:(0,J.jsx)(`div`,{className:`main-inner${e===`models`&&n===`combos`?` main-inner--combos`:``}`,children:(0,J.jsx)(Fl,{pageName:c(tS[e]),title:c(`errorBoundary.title`),message:c(`errorBoundary.message`),detailsLabel:c(`errorBoundary.details`),reloadLabel:c(`errorBoundary.reload`),children:d?(0,J.jsxs)(J.Fragment,{children:[p&&(0,J.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:c(`connection.machineUnavailable`)}),l.connected&&!h&&(0,J.jsx)(Bx,{target:l.shared,onConnected:()=>g(!0)}),e===`dashboard`&&(0,J.jsx)(Qr,{apiBase:x}),e===`startup`&&(0,J.jsx)(Hb,{apiBase:x,machineApiBase:b,connected:l.connected}),e===`providers`&&(0,J.jsx)(fl,{apiBase:x}),e===`models`&&(0,J.jsx)(Mp,{apiBase:x,restartEpoch:N},x),e===`subagents`&&(0,J.jsx)(Wp,{apiBase:x},x),e===`logs`&&(0,J.jsx)(bh,{apiBase:x}),e===`usage`&&(0,J.jsx)(Hh,{apiBase:x,connected:l.connected,apiKeyId:l.apiKeyId}),e===`storage`&&(0,J.jsx)(_g,{apiBase:x}),e===`codex-set`&&(0,J.jsx)(o_,{apiBase:x}),e===`integrations`&&(0,J.jsx)(kb,{apiBase:x,machineApiBase:b,connected:l.connected})]}):(0,J.jsx)(`div`,{className:`alert`,children:c(`connection.discovering`)})},e)})})]})}g.createRoot(document.getElementById(`root`)).render((0,J.jsx)(_.StrictMode,{children:(0,J.jsx)(dt,{children:(0,J.jsx)(uS,{})})}));
|
|
112
|
+
`);if(!confirm(t))return;i(!0),o(null);let a=[];for(let t of z)try{await xy(e,t.clientId,!1)}catch(e){a.push(`${t.clientId}: ${qy(n,e)}`)}let s=!1;try{s=(await vy(e)).clients.some(hb)}catch{a.push(n(`integrations.error.stale`))}s&&a.length===0&&a.push(n(`integrations.error.stale`)),q(),i(!1),o(a.length===0?{tone:`ok`,text:n(`integrations.bulk.success`)}:{tone:`err`,text:n(`integrations.bulk.partial`,{clients:a.join(`; `)})})},te=R[0]?.at,[ne,re]=(0,_.useState)(null),ie=()=>{I.refresh(),A.refresh(),M.refresh(),P.refresh()},ae=(e,t)=>{f(n=>{let r={...n};return t?r[e]=t:delete r[e],r})},oe=async(t,r)=>{if(!ne&&t.toggle){re(t.id),ae(t.id,null);try{if(t.status)await xy(e,t.status.clientId,r),q();else if(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`){let i=await By(e,t.toggle,r);i.reason===`non_loopback_removed`?ae(t.id,{tone:`ok`,text:n(i.changed?`integrations.native.msg.nonLoopbackRemoved`:`integrations.native.msg.nonLoopbackRemovedNoop`)}):i.reason===`non_loopback_superseded`&&ae(t.id,{tone:`ok`,text:n(`integrations.native.msg.nonLoopbackSuperseded`)}),ie()}}catch(e){ae(t.id,{tone:`err`,text:qy(n,e,void 0,t.togglePath??void 0)}),(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`)&&ie()}finally{re(null)}}},se=(e,t)=>{if(e.status||t||e.id===`claude`||e.toggle===null){oe(e,t);return}let n=document.activeElement;v.current=n?.tagName===`BUTTON`?n:null,m(e)},ce=async t=>{if(t.status){re(t.id),ae(t.id,null);try{await xy(e,t.status.clientId,!0,void 0,!0),q()}catch(e){throw ae(t.id,{tone:`err`,text:qy(n,e,void 0,t.togglePath??void 0)}),e}finally{re(null)}}};return(0,J.jsxs)(`section`,{className:`integrations-overview`,children:[(0,J.jsxs)(`div`,{className:`integration-summary`,children:[(0,J.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,J.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.detected`)}),(0,J.jsx)(`strong`,{children:K.detected})]}),(0,J.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,J.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.applied`)}),(0,J.jsx)(`strong`,{children:K.applied})]}),(0,J.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,J.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.stale`)}),(0,J.jsx)(`strong`,{children:K.stale})]}),K.unknown>0&&(0,J.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,J.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.state.unknown`)}),(0,J.jsx)(`strong`,{children:K.unknown})]}),(0,J.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,J.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.lastChange`)}),(0,J.jsx)(`strong`,{children:te?new Date(te).toLocaleString():n(`integrations.status.unknown`)})]}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void Y(),disabled:r||z.length===0,children:n(`integrations.summary.disableAll`)})]}),(0,J.jsx)(`h3`,{children:n(`integrations.catalog.title`)}),(0,J.jsx)(vb,{row:ee}),(0,J.jsx)(`p`,{className:`page-sub`,children:n(`integrations.onboarding`)}),O.state.kind===`failed-cold`&&(0,J.jsx)(Q,{tone:`err`,children:n(`integrations.error.load`)}),O.state.kind===`failed-with-stale`&&(0,J.jsx)(Q,{tone:`err`,children:n(`integrations.error.stale`)}),a&&(0,J.jsx)(Q,{tone:a.tone,children:a.text}),G.length===0?O.state.kind===`failed-cold`?null:(0,J.jsx)(`p`,{className:`page-sub`,children:n(`common.loading`)}):(0,J.jsx)(`ul`,{className:`integration-cards`,children:G.map(e=>(0,J.jsx)(gb,{row:e,pending:ne!==null,result:d[e.id]??null,onOpen:()=>ht(e.hash),onToggle:e.toggle?()=>se(e,!(e.toggleOn??e.applied)):null,onOverwrite:e.status!==null&&e.status.state===`conflict`&&e.installed?()=>g(e):null},e.id))}),V&&B.length===0&&(0,J.jsxs)(`div`,{className:`integration-empty`,children:[(0,J.jsx)(`h4`,{children:n(`integrations.empty.title`)}),(0,J.jsx)(`p`,{children:n(`integrations.empty.body`)})]}),(0,J.jsx)(`h3`,{children:n(`integrations.rollback.title`)}),k.state.showSkeleton?(0,J.jsx)(Nl,{label:n(`integrations.rollback.title`),rows:2}):k.state.kind===`failed-cold`?(0,J.jsxs)(Q,{tone:`err`,children:[n(`integrations.rollback.failed`),` `,(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void k.refresh(),children:n(`common.retry`)})]}):R.length===0?(0,J.jsxs)(`div`,{className:`integration-empty`,children:[(0,J.jsx)(`p`,{children:n(`integrations.rollback.empty`)}),(0,J.jsx)(`p`,{className:`page-sub`,children:n(`integrations.rollback.emptyBody`)})]}):(0,J.jsx)(db,{rows:R,showClient:!0,onRestore:c,onDelete:u}),s&&(0,J.jsx)(Jy,{apiBase:e,row:s,onClose:()=>c(null),onRestored:q}),l&&(0,J.jsx)(sy,{copy:{titleKey:`integrations.dialog.deleteEntry.title`,changesKey:`integrations.dialog.deleteEntry.changes`,breakageKey:`integrations.dialog.deleteEntry.breakage`,undoKey:`integrations.dialog.deleteEntry.undo`,confirmKey:`integrations.dialog.deleteEntry.confirm`,vars:{path:l.configPath}},onClose:()=>u(null),onConfirm:async()=>{try{await Cy(e,l.opId)}catch(e){if(hy(e)){u(null),await k.refresh();return}throw Error(qy(n,e),{cause:e})}u(null),await k.refresh()}}),p&&(0,J.jsx)(sy,{copy:{...p.toggle===`claude-desktop`?mb:p.id===`codex`?pb:fb,vars:{path:p.togglePath??``}},onClose:()=>m(null),onConfirm:async()=>{await oe(p,!1),m(null)}}),h&&h.status&&(0,J.jsx)(sy,{copy:{titleKey:`integrations.dialog.overwrite.title`,changesKey:h.status.reason===`foreign-edit`?`integrations.dialog.overwrite.changesForeign`:`integrations.dialog.overwrite.changesUnowned`,breakageKey:`integrations.dialog.overwrite.breakage`,undoKey:`integrations.dialog.overwrite.undo`,confirmKey:`integrations.dialog.overwrite.confirm`,vars:{path:h.status.configPath}},onClose:()=>g(null),onConfirm:async()=>{await ce(h),g(null)}})]})}function vb({row:e}){let t=Z(),n=e.detailKey?t(e.detailKey,e.detailVars??void 0):null;return(0,J.jsxs)(`div`,{className:`integration-api-keys-row`,"data-client":`keys`,"data-key-state":e.state,children:[(0,J.jsxs)(`div`,{className:`integration-api-keys-copy`,children:[(0,J.jsx)(`h4`,{children:t(e.labelKey)}),n&&(0,J.jsx)(`p`,{className:`integration-meta`,children:n})]}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>ht(e.hash),children:t(`integrations.action.manageKeys`)})]})}function yb(e,t){return{titleKey:`integrations.dialog.overwrite.title`,changesKey:e===`foreign-edit`?`integrations.dialog.overwrite.changesForeign`:`integrations.dialog.overwrite.changesUnowned`,breakageKey:`integrations.dialog.overwrite.breakage`,undoKey:`integrations.dialog.overwrite.undo`,confirmKey:`integrations.dialog.overwrite.confirm`,vars:{path:t}}}var bb={opencode:`integrations.semantics.opencode`,pi:`integrations.semantics.pi`,omp:`integrations.semantics.omp`,hermes:`integrations.semantics.hermes`,openclaw:`integrations.semantics.openclaw`,kimi:`integrations.semantics.kimi`,gajae:`integrations.semantics.gajae`,dsh:`integrations.semantics.dsh`,mcode:`integrations.semantics.mcode`,zcode:`integrations.semantics.zcode`,prime:`integrations.semantics.prime`,aside:`integrations.semantics.aside`},xb={opencode:`integrations.tab.opencode`,pi:`integrations.tab.pi`,omp:`integrations.tab.omp`,hermes:`integrations.tab.hermes`,openclaw:`integrations.tab.openclaw`,kimi:`integrations.tab.kimi`,gajae:`integrations.tab.gajae`,dsh:`integrations.tab.dsh`,mcode:`integrations.tab.mcode`,zcode:`integrations.tab.zcode`,prime:`integrations.tab.prime`,aside:`integrations.tab.aside`};function Sb({apiBase:e,client:t,active:n=!0}){let r=Z(),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!1),m=(0,_.useCallback)(n=>yy(e,t,n),[e,t]),h=(0,_.useCallback)(async n=>(await by(e,t,n)).operations,[e,t]),g=$(`integration-state:${e}:${t}`,[e,t],m,{isEmpty:()=>!1,enabled:n,sessionCacheKey:`ocx.integrations.state.v1:${e}:${t}`}),v=$(`integration-journal:${e}:${t}`,[e,t],h,{isEmpty:e=>e.length===0,enabled:n,sessionCacheKey:`ocx.integrations.client-journal.v1:${e}:${t}`}),y=g.state.data??null,b=v.state.data??[],x=()=>{g.refresh(),v.refresh()},S=async n=>{if(!(!y||i)){a(!0),s(null);try{await xy(e,t,n),x()}catch(e){s(qy(r,e))}finally{a(!1)}}},C=async()=>{if(y){s(null);try{await xy(e,t,!0,void 0,!0),x()}catch(e){throw s(qy(r,e)),e}}},w=()=>void S(!(y&&(y.state===`current`||y.state===`stale`)));if(!y)return(0,J.jsx)(`section`,{className:`integration-client-page`,children:g.state.kind===`failed-cold`?(0,J.jsx)(Q,{tone:`err`,children:r(`integrations.error.load`)}):(0,J.jsx)(`p`,{className:`page-sub`,children:r(`common.loading`)})});let T=y.state===`current`||y.state===`stale`,E=!y.installed||y.state===`conflict`||y.state===`unsafe`;return(0,J.jsxs)(`section`,{className:`integration-client-page`,children:[(0,J.jsxs)(`div`,{className:`integration-client-head`,children:[(0,J.jsx)(g_,{src:h_(t),label:r(xb[t]),size:24}),(0,J.jsx)(`h3`,{children:r(xb[t])}),(0,J.jsx)(ay,{state:y.state,installed:y.installed,id:`integration-state-${t}`}),(0,J.jsx)(Dt,{on:T,onClick:w,disabled:E||i,label:r(T?`integrations.action.disable`:`integrations.action.apply`)})]}),y.state===`stale`&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void S(!0),disabled:i,children:r(`integrations.action.refresh`)}),y.installed&&y.state===`conflict`&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:()=>p(!0),disabled:i,children:r(`integrations.action.overwrite`)}),(0,J.jsx)(`p`,{className:`page-sub`,children:r(bb[t])}),(0,J.jsx)(`p`,{className:`integration-path`,children:y.configPath}),y.appliedAt&&(0,J.jsxs)(`p`,{className:`integration-meta`,children:[r(`integrations.status.appliedAt`),`: `,new Date(y.appliedAt).toLocaleString()]}),y.retentionDegraded&&(0,J.jsx)(Q,{tone:`err`,children:r(`integrations.retention.degraded`)}),o&&(0,J.jsx)(Q,{tone:`err`,children:o}),(0,J.jsx)(`h4`,{children:r(`integrations.rollback.title`)}),v.state.showSkeleton?(0,J.jsx)(Nl,{label:r(`integrations.rollback.title`),rows:2}):v.state.kind===`failed-cold`?(0,J.jsxs)(Q,{tone:`err`,children:[r(`integrations.rollback.failed`),` `,(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void v.refresh(),children:r(`common.retry`)})]}):b.length===0?(0,J.jsx)(`p`,{className:`page-sub`,children:r(`integrations.rollback.empty`)}):(0,J.jsx)(db,{rows:b,onRestore:l,onDelete:d}),c&&(0,J.jsx)(Jy,{apiBase:e,row:c,onClose:()=>l(null),onRestored:x}),u&&(0,J.jsx)(sy,{copy:{titleKey:`integrations.dialog.deleteEntry.title`,changesKey:`integrations.dialog.deleteEntry.changes`,breakageKey:`integrations.dialog.deleteEntry.breakage`,undoKey:`integrations.dialog.deleteEntry.undo`,confirmKey:`integrations.dialog.deleteEntry.confirm`,vars:{path:u.configPath}},onClose:()=>d(null),onConfirm:async()=>{try{await Cy(e,u.opId)}catch(e){if(hy(e)){d(null),await v.refresh();return}throw Error(qy(r,e),{cause:e})}d(null),await v.refresh()}}),f&&(0,J.jsx)(sy,{copy:yb(y.reason,y.configPath),onClose:()=>p(!1),onConfirm:async()=>{await C(),p(!1)}})]})}var Cb=[{id:`overview`,hash:`integrations`,labelKey:`integrations.tab.overview`},{id:`keys`,hash:`integrations/keys`,labelKey:`integrations.tab.keys`},{id:`codex`,hash:`integrations/codex`,labelKey:`integrations.tab.codex`},{id:`claude`,hash:`integrations/claude`,labelKey:`integrations.tab.claude`},{id:`grok`,hash:`integrations/grok`,labelKey:`integrations.tab.grok`},{id:`cursor`,hash:`integrations/cursor`,labelKey:`integrations.tab.cursor`},{id:`opencode`,hash:`integrations/opencode`,labelKey:`integrations.tab.opencode`},{id:`pi`,hash:`integrations/pi`,labelKey:`integrations.tab.pi`},{id:`omp`,hash:`integrations/omp`,labelKey:`integrations.tab.omp`},{id:`hermes`,hash:`integrations/hermes`,labelKey:`integrations.tab.hermes`},{id:`openclaw`,hash:`integrations/openclaw`,labelKey:`integrations.tab.openclaw`},{id:`kimi`,hash:`integrations/kimi`,labelKey:`integrations.tab.kimi`},{id:`gajae`,hash:`integrations/gajae`,labelKey:`integrations.tab.gajae`},{id:`dsh`,hash:`integrations/dsh`,labelKey:`integrations.tab.dsh`},{id:`mcode`,hash:`integrations/mcode`,labelKey:`integrations.tab.mcode`},{id:`zcode`,hash:`integrations/zcode`,labelKey:`integrations.tab.zcode`},{id:`prime`,hash:`integrations/prime`,labelKey:`integrations.tab.prime`},{id:`aside`,hash:`integrations/aside`,labelKey:`integrations.tab.aside`}],wb=new Set([`opencode`,`pi`,`omp`,`hermes`,`openclaw`,`kimi`,`gajae`,`dsh`,`mcode`,`zcode`,`prime`,`aside`]);function Tb(e=window.location.hash){let t=pt(e);return t===`integrations/claude/desktop`?`claude`:Cb.find(e=>e.hash===t)?.id??`overview`}function Eb(e){return`integrations-tab-${e}`}function Db(e){return`integrations-panel-${e}`}function Ob(e){return e===`overview`||e===`keys`?null:f_[e]??null}function kb({apiBase:e,machineApiBase:t=e,connected:n=!1}){let r=Z(),[i,a]=(0,_.useState)(Tb),[o,s]=(0,_.useState)(()=>new Set([Tb()])),c=(0,_.useRef)(null),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(!1);c.current===null&&(c.current=new Map),(0,_.useEffect)(()=>{if(!n)return;let e=new AbortController;return fetch(`${t}/api/machine/clients`,{signal:e.signal}).then(e=>e.ok?e.json():null).then(t=>{!e.signal.aborted&&Array.isArray(t?.selectedClients)&&u(t.selectedClients.filter(e=>typeof e==`string`))}).catch(()=>{}),()=>e.abort()},[n,t]);let p=async()=>{f(!0);try{await fetch(`${t}/api/machine/sync`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`})}finally{f(!1)}},m=e=>{a(e),s(t=>t.has(e)?t:new Set([...t,e]))};(0,_.useEffect)(()=>{let e=()=>m(Tb());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let h=(e,t)=>{let n=Cb.find(t=>t.id===e);n&&(ht(n.hash),m(e),t&&window.requestAnimationFrame(()=>{c.current.get(e)?.focus({preventScroll:!0})}))},g=e=>{let t=Cb.findIndex(e=>e.id===i),n=null;e.key===`ArrowLeft`?n=(t-1+Cb.length)%Cb.length:e.key===`ArrowRight`?n=(t+1)%Cb.length:e.key===`Home`?n=0:e.key===`End`&&(n=Cb.length-1),n!==null&&(e.preventDefault(),h(Cb[n].id,!0))};return(0,J.jsxs)(`section`,{className:`integrations-page`,children:[(0,J.jsx)(`div`,{className:`page-head`,children:(0,J.jsx)(`h2`,{children:r(`nav.integrations`)})}),(0,J.jsx)(`p`,{className:`page-sub`,children:r(`integrations.subtitle`)}),n&&(0,J.jsxs)(`section`,{className:`notice`,"aria-label":r(`connection.clients.title`),children:[(0,J.jsx)(`strong`,{children:r(`connection.clients.title`)}),(0,J.jsx)(`span`,{children:l.length>0?l.join(`, `):r(`connection.clients.none`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:d,onClick:()=>void p(),children:r(d?`connection.clients.syncing`:`connection.clients.sync`)})]}),(0,J.jsx)(`div`,{className:`page-tabs`,role:`tablist`,"aria-label":r(`integrations.tabsLabel`),children:Cb.map(e=>(0,J.jsxs)(`button`,{ref:t=>{t?c.current.set(e.id,t):c.current.delete(e.id)},type:`button`,role:`tab`,id:Eb(e.id),"aria-selected":i===e.id,"aria-controls":Db(e.id),tabIndex:i===e.id?0:-1,className:`page-tab${i===e.id?` page-tab--active`:``}`,onClick:()=>h(e.id,!0),onKeyDown:g,children:[Ob(e.id)&&(0,J.jsx)(g_,{src:Ob(e.id),label:r(e.labelKey),size:14}),r(e.labelKey)]},e.id))}),Cb.map(t=>{if(!o.has(t.id))return null;let n=i===t.id;return(0,J.jsxs)(`div`,{role:`tabpanel`,id:Db(t.id),"aria-labelledby":Eb(t.id),hidden:!n,children:[t.id===`overview`&&(0,J.jsx)(_b,{apiBase:e,active:n}),t.id===`keys`&&(0,J.jsx)(nv,{apiBase:e,active:n}),t.id===`codex`&&(0,J.jsxs)(`section`,{className:`integration-native-page`,"aria-labelledby":`codex-integration-title`,children:[(0,J.jsx)(`h3`,{id:`codex-integration-title`,children:r(`integrations.codex.title`)}),(0,J.jsx)(`p`,{children:r(`integrations.codex.body`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>ht(`startup`),children:r(`integrations.codex.openService`)})]}),t.id===`claude`&&(0,J.jsx)(Kv,{apiBase:e,active:n}),t.id===`grok`&&(0,J.jsx)(Qv,{apiBase:e,active:n}),t.id===`cursor`&&(0,J.jsx)(ny,{apiBase:e,active:n}),wb.has(t.id)&&(0,J.jsx)(Sb,{apiBase:e,client:t.id,active:n})]},t.id)})]})}function Ab(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 jb={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},Mb={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},Nb={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function Pb({ok:e,yes:t,no:n}){return(0,J.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function Fb({failed:e,data:t}){let{t:n}=ut(),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`?_e:ue,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,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`section`,{className:`panel startup-hero ${r}`,"aria-live":`polite`,children:[(0,J.jsx)(`div`,{className:`startup-hero-icon`,children:(0,J.jsx)(i,{})}),(0,J.jsxs)(`div`,{className:`startup-hero-copy`,children:[(0,J.jsx)(`span`,{className:`badge ${e||t.status===`at-risk`?`badge-amber`:`badge-green`}`,children:n(e?`startup.status.atRisk`:jb[t.status])}),(0,J.jsx)(`h3`,{children:n(e?`startup.error`:Mb[t.status])}),(0,J.jsx)(`p`,{children:e?n(`startup.staleData`):t.status===`at-risk`?n(Cr(t)):n(`startup.safeDetail`)}),(0,J.jsxs)(`p`,{className:`muted startup-state-line`,children:[n(a),` · `,n(Nb[t.protection]),` · `,n(t.autostartEnabled?`startup.enabled`:`startup.disabled`)]}),(0,J.jsx)(`p`,{className:`muted text-label`,children:n(`startup.subtitle`)})]})]})})}function Ib({data:e,failed:t,loading:n=!1,installBusy:r,installResult:i,onInstall:a}){let{t:o}=ut(),s=e.serviceSupported&&e.serviceInstalled&&e.serviceStale&&!e.serviceConflict,c=e.shimInstalled&&!e.shimHealthy,l=r!==null||t||n;return(0,J.jsxs)(`section`,{className:`panel startup-details`,children:[(0,J.jsxs)(`div`,{className:`panel-head`,children:[(0,J.jsx)(`h3`,{className:`panel-title`,children:o(`startup.details`)}),(0,J.jsx)(`span`,{className:`muted mono`,children:e.platform})]}),(0,J.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:o(`startup.service`)}),(0,J.jsx)(`span`,{children:o(`startup.serviceHint`)})]}),(0,J.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,J.jsx)(Pb,{ok:e.serviceViable,yes:o(`startup.viable`),no:o(e.serviceConflict?`startup.conflict`:e.serviceStale?`startup.stale`:e.serviceInstalled?`startup.unhealthy`:e.serviceSupported?`startup.notInstalled`:`startup.unsupported`)}),e.serviceSupported&&!e.serviceInstalled&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-service`),children:o(r===`install-service`?`startup.installing`:`startup.install`)}),s&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-service`,{repair:!0}),children:o(r===`install-service`?`startup.repairing`:`startup.repair`)})]})]}),(0,J.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:o(`startup.shim`)}),(0,J.jsx)(`span`,{children:o(`startup.shimHint`)})]}),(0,J.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,J.jsx)(Pb,{ok:e.shimHealthy&&e.autostartEnabled,yes:o(e.shimCoverage===`cli-only`?`startup.cliOnly`:`startup.healthy`),no:o(e.shimInstalled?e.shimHealthy&&!e.autostartEnabled?`startup.installedDisabled`:`startup.stale`:`startup.notInstalled`)}),!e.shimInstalled&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-shim`),children:o(r===`install-shim`?`startup.installing`:`startup.install`)}),c&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-shim`,{repair:!0}),children:o(r===`install-shim`?`startup.repairing`:`startup.repair`)})]})]}),i&&(0,J.jsx)(`div`,{className:`notice ${i.kind===`success`?`notice-ok`:`notice-warn`} startup-action-notice`,role:`status`,"aria-live":`polite`,children:i.kind===`success`?i.action===`install-service`?o(i.repair?`startup.serviceRepaired`:`startup.serviceInstalled`):o(i.repair?`startup.shimRepaired`:`startup.shimInstalled`):`${o(`startup.installFailed`)} ${i.detail??``}`})]})}function Lb({tray:e,trayLoading:t,trayError:n,trayBusy:r,onTrayAction:i}){let{t:a}=ut();return(0,J.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,J.jsxs)(`div`,{className:`panel-head`,children:[(0,J.jsx)(`h3`,{className:`panel-title`,children:a(`startup.tray.title`)}),(0,J.jsx)(Te,{})]}),(0,J.jsx)(`p`,{className:`muted`,children:a(`startup.tray.hint`)}),(0,J.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:a(`startup.tray.login`)}),(0,J.jsx)(`span`,{children:a(`startup.tray.notProtection`)})]}),t||n||!e?(0,J.jsx)(`span`,{className:`badge badge-amber`,children:a(t?`startup.tray.loading`:`startup.tray.unavailable`)}):(0,J.jsx)(Pb,{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,J.jsxs)(`div`,{className:`startup-tray-buttons`,children:[!t&&!n&&e&&!e.installed&&!e.stale&&(0,J.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,J.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,J.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,J.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,J.jsx)(`div`,{className:`notice notice-warn startup-tray-error`,role:`alert`,children:a(`startup.tray.error`)})]})}function Rb({data:e,copied:t,onCopy:n}){let{t:r}=ut(),i=e.serviceInstalled&&!e.serviceConflict?e.commands.repairService:e.commands.installService;return(0,J.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,J.jsxs)(`div`,{className:`panel-head`,children:[(0,J.jsx)(`h3`,{className:`panel-title`,children:r(`startup.recovery`)}),(0,J.jsx)(se,{})]}),(0,J.jsxs)(`details`,{className:`startup-recovery-details`,open:e.status!==`protected`,children:[(0,J.jsx)(`summary`,{className:`muted`,children:r(`startup.recoveryHint`)}),(0,J.jsxs)(`div`,{className:`startup-command-list`,children:[e.serviceSupported&&(0,J.jsxs)(`div`,{className:`startup-command-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r(`startup.command.service`)}),(0,J.jsx)(`code`,{children:i})]}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(i),children:r(t===i?`startup.copied`:`startup.copy`)})]}),(0,J.jsxs)(`div`,{className:`startup-command-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r(`startup.command.shim`)}),(0,J.jsx)(`code`,{children:e.commands.installShim})]}),(0,J.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,J.jsxs)(`div`,{className:`startup-command-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r(`startup.command.native`)}),(0,J.jsx)(`code`,{children:e.commands.restoreNative})]}),(0,J.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,J.jsxs)(`div`,{className:`notice notice-warn startup-action-notice`,role:`alert`,children:[(0,J.jsx)(Te,{}),` `,r(`startup.recommended`,{cmd:e.recommendedCommand??e.commands.installService})]})]})]})}var zb=`ocx.startup.page.v1:`;function Bb(e,t){let n=t===`win32`?`; `:` && `;return e.join(n)}function Vb(e,t,n){if(!e)return{warning:null,fix:null};let r=!!e.catalogClamp?.active,i=!!e.newerAvailable,a=(r?e.catalogClamp?.runtimeVersion:e.version)??e.version??`unknown`,o=(e.catalogClamp?.removedEfforts??[]).join(`, `),s=Bb([`ocx doctor --fix-codex-runtime`,`ocx sync`],n);return r?{warning:o?t(`startup.codexRuntime.clampHiddenWithEfforts`,{version:a,efforts:o}):t(`startup.codexRuntime.clampHidden`,{version:a}),fix:i?s:`ocx sync`}:i?{warning:t(`startup.codexRuntime.olderBinary`,{version:a}),fix:s}:{warning:null,fix:null}}function Hb({apiBase:e,machineApiBase:t=e,connected:n=!1}){let{t:r}=ut(),i=`${zb}${e}`,a=(0,_.useMemo)(()=>vr(i),[i]),o=`startup-page:${e}`,[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(()=>a?.tray??null),[d,f]=(0,_.useState)(()=>!a?.data),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(()=>a?.warning??null),[w,T]=(0,_.useState)(()=>a?.fix??null),[E,D]=(0,_.useState)(()=>!a?.data),O=(0,_.useRef)(!!a?.data),k=(0,_.useRef)(0),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)(!1);(0,_.useEffect)(()=>{if(!n)return;let e=new AbortController;return fetch(`${t}/api/machine/shim`,{signal:e.signal}).then(e=>e.ok?e.json():null).then(t=>{e.signal.aborted||j(t)}).catch(()=>{e.signal.aborted||j(null)}),()=>e.abort()},[n,t]);let P=async e=>{N(!0);try{let n=await fetch(`${t}/api/machine/shim`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:e})});if(n.ok){let e=await n.json();j(e.shim??null)}}finally{N(!1)}};(0,_.useEffect)(()=>()=>{k.current+=1},[e]);let F=(0,_.useCallback)(async t=>{let n=++k.current,a=O.current;a||(f(!0),D(!0));try{let a=fetch(`${e}/api/settings`,{signal:t}).then(async e=>e.ok?await e.json():null).catch(()=>null),o=await fetch(`${e}/api/startup-health`,{signal:t});if(!o.ok)throw Error(`fetch failed`);let s=await o.json();x(e=>e?.kind===`error`&&(s.status===`native`&&e.forLocalRouting===!0||(e.action===`install-service`?s.serviceViable:s.shimInstalled&&s.shimHealthy))?null:e),O.current=!0;let c=vr(i);Sr(i,{data:s,warning:c?.warning??null,fix:c?.fix??null,tray:c?.tray??null});let l=s.platform===`win32`?fetch(`${e}/api/windows-tray`,{signal:t}).then(async e=>{if(!e.ok)throw Error(`tray status failed`);let t=await e.json();if(!Ab(t))throw Error(`invalid tray status`);return{tray:t,error:!1}}).catch(()=>({tray:null,error:!0})):Promise.resolve({tray:null,error:!1});return Promise.all([a,l]).then(([e,a])=>{if(t.aborted||n!==k.current)return;let o=s.platform===`win32`?a.tray:null;if(s.platform===`win32`?(u(o),g(a.error)):(u(null),g(!1)),f(!1),D(!1),e){let t=Vb(e.codexRuntime,r,s.platform);C(t.warning),T(t.fix),Sr(i,{data:s,warning:t.warning,fix:t.fix,tray:o});return}let c=vr(i);Sr(i,{data:s,warning:c?.warning??null,fix:c?.fix??null,tray:o})}),s}catch(e){throw t.aborted?e:(a||(u(null),g(!0),C(null),T(null)),D(!1),f(!1),e)}},[e,i,r]),I=$(o,[e],F,{isEmpty:()=>!1,initialData:a?.data??void 0}),L=I.state,R=I.refresh,z=L.data??a?.data??null,B=L.refreshing,V=!!z?.diagnosticStale||L.showError;(0,_.useEffect)(()=>{if(!z?.diagnosticStale)return;let e=window.setTimeout(R,2e3);return()=>window.clearTimeout(e)},[z,R]);let H=async e=>{try{await navigator.clipboard.writeText(e),c(e),window.setTimeout(()=>c(t=>t===e?null:t),1600)}catch{c(null)}},U=async t=>{m(!0),g(!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(!Ab(r.status))throw Error(`invalid tray action status`);u(r.status),g(!1)}catch{u(null),g(!0)}finally{m(!1)}},W=async(t,n)=>{y(t),x(null);try{let r=await fetch(`${e}/api/startup-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t,repair:n?.repair===!0})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(typeof e?.error==`string`?e.error:`installation failed`)}x({kind:`success`,action:t,repair:n?.repair===!0}),R()}catch(e){x({kind:`error`,action:t,repair:n?.repair===!0,detail:e instanceof Error?e.message:String(e),forLocalRouting:z?.localRoutingDependency===!0})}finally{y(null)}};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`page-head`,children:[(0,J.jsx)(`h2`,{children:r(`startup.title`)}),(0,J.jsx)(`div`,{className:`startup-page-head-actions`,children:(0,J.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>R(),disabled:B,children:[(0,J.jsx)(pe,{}),` `,r(`startup.refresh`)]})})]}),n&&(0,J.jsxs)(`section`,{className:`notice startup-page-notice`,"aria-label":r(`connection.machine.title`),children:[(0,J.jsx)(`strong`,{children:r(`connection.machine.title`)}),(0,J.jsx)(`span`,{children:A?.healthy?r(`connection.machine.shimHealthy`):r(`connection.machine.shimNeedsAttention`)}),(0,J.jsxs)(`div`,{className:`startup-page-head-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:M,onClick:()=>void P(`repair`),children:r(`connection.machine.repairShim`)}),A?.installed&&(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:M,onClick:()=>void P(`uninstall`),children:r(`connection.machine.removeShim`)})]})]}),L.showSkeleton&&!z?(0,J.jsx)(Nl,{label:r(`startup.loading`),rows:5}):L.kind===`failed-cold`?(0,J.jsxs)(`div`,{className:`startup-page-notice`,children:[(0,J.jsx)(Q,{tone:`err`,children:L.error instanceof Error?L.error.message:r(`startup.error`)}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>R(),children:r(`common.retry`)})]}):z?(0,J.jsxs)(J.Fragment,{children:[L.showError&&(0,J.jsx)(Q,{tone:`err`,children:r(`startup.error`)}),V&&(0,J.jsx)(`div`,{className:`notice notice-warn startup-page-notice`,role:`alert`,children:r(`startup.staleData`)}),(E||S)&&(0,J.jsx)(`div`,{className:`startup-runtime-notice-slot${E&&!S?` startup-runtime-notice-slot--pending`:``}`,"aria-hidden":E&&!S?!0:void 0,children:S&&(0,J.jsxs)(`div`,{className:`notice notice-warn startup-page-notice startup-runtime-notice`,role:`status`,children:[(0,J.jsx)(`p`,{className:`startup-runtime-notice__text`,children:S}),w&&(0,J.jsxs)(`div`,{className:`startup-runtime-notice__fix`,children:[(0,J.jsx)(`code`,{children:w}),(0,J.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void H(w),children:r(s===w?`startup.copied`:`startup.copy`)})]})]})}),(0,J.jsx)(Fb,{failed:V,data:z}),(0,J.jsx)(Ib,{data:z,failed:V,loading:B,installBusy:v,installResult:b,onInstall:(e,t)=>{W(e,t)}}),z.platform===`win32`&&(0,J.jsx)(Lb,{tray:l,trayLoading:d,trayError:h,trayBusy:p,onTrayAction:e=>{U(e)}}),(0,J.jsx)(Rb,{data:z,copied:s,onCopy:e=>{H(e)}})]}):null]})}var Ub=3e5,Wb=6e5,Gb=`https://github.com/lidge-jun/opencodex`;async function Kb(e,t){let n=await fetch(e,{signal:t});return n.ok?await n.json():null}function qb({apiBase:e,onOpenUpdate:t}){let n=Z(),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),s=G(`sidebar-star:${e}`,[e],t=>Kb(`${e}/api/github/star`,t),{pollMs:Ub}),c=G(`sidebar-update-badge:${e}`,[e],t=>Kb(`${e}/api/update/badge`,t),{pollMs:Wb}),l=s.data?.state??null,u=a!==null&&a.basedOn===l?a.state:l??`not-starred`,d=s.data?.url??Gb,f=u===`starred`,p=c.data,m=p?.updateAvailable===!0,h=p?.latestVersion??null,g=()=>window.open(d,`_blank`,`noopener,noreferrer`),v=async()=>{if(!(f||r)){if(u===`unauthenticated`){g();return}i(!0);try{let t=await fetch(`${e}/api/github/star`,{method:`POST`}),n=t.ok?await t.json():null;if(n?.ok===!0){o({state:`starred`,basedOn:l});return}n?.state&&o({state:n.state,basedOn:l}),g()}catch{g()}finally{i(!1),s.refresh()}}},y=n(f?`sidebar.starred`:u===`unauthenticated`?`sidebar.starUnauthenticated`:`sidebar.star`),b=m&&h?n(`sidebar.updateAvailable`,{version:h}):n(`sidebar.checkUpdate`);return(0,J.jsxs)(`div`,{className:`sidebar-github-row`,children:[(0,J.jsxs)(`a`,{className:`sidebar-link sidebar-github-link`,href:d,target:`_blank`,rel:`noreferrer`,children:[(0,J.jsx)(we,{}),` `,n(`common.github`)]}),(0,J.jsxs)(`div`,{className:`sidebar-github-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb${f?` sidebar-orb--starred`:``}`,onClick:()=>{v()},disabled:r||f,"aria-label":y,"aria-pressed":f,title:y,children:(0,J.jsx)(Re,{"aria-hidden":`true`,...f?{fill:`currentColor`}:{}})}),(0,J.jsxs)(`button`,{type:`button`,className:`sidebar-orb${m?` sidebar-orb--update`:``}`,onClick:t,"aria-label":b,title:b,children:[(0,J.jsx)(Se,{"aria-hidden":`true`}),m&&(0,J.jsx)(`span`,{className:`sidebar-orb-dot`,"aria-hidden":`true`})]})]})]})}var Jb=`opencodex-admin-token-dialog`,Yb=`OpenCodex`,Xb=`https://opencodex.me/guides/web-dashboard/#finding-the-admin-token`;function Zb(e,t=ot()){let n=$e[t],r=n[`auth.adminTokenTitle`];return new Promise(t=>{let i=document.activeElement instanceof HTMLElement?document.activeElement:null,a=!1,o=document.createElement(`dialog`);o.id=Jb,o.className=`modal-overlay`,o.setAttribute(`aria-labelledby`,`${Jb}-title`);let s=document.createElement(`form`);s.className=`modal-card`,s.method=`post`,s.action=window.location.href,s.autocomplete=`on`;let c=document.createElement(`div`);c.className=`modal-head`;let l=document.createElement(`h3`);l.id=`${Jb}-title`,l.textContent=r,c.append(l);let u=document.createElement(`div`),d=document.createElement(`label`);d.className=`field-label`,d.htmlFor=`${Jb}-username`,d.textContent=n[`auth.adminAccountLabel`];let f=document.createElement(`input`);f.id=d.htmlFor,f.className=`input`,f.type=`text`,f.name=`username`,f.autocomplete=`username`,f.value=Yb,f.readOnly=!0,u.append(d,f);let p=document.createElement(`div`);p.style.marginTop=`var(--space-4)`;let m=document.createElement(`label`);m.className=`field-label`,m.htmlFor=`${Jb}-password`,m.textContent=n[`auth.adminTokenFieldLabel`];let h=document.createElement(`input`);h.id=m.htmlFor,h.className=`input`,h.type=`password`,h.name=`password`,h.autocomplete=`current-password`,h.required=!0,h.spellcheck=!1,h.autocapitalize=`none`,p.append(m,h);let g=document.createElement(`p`);g.className=`hint`,g.style.marginTop=`var(--space-2)`,g.textContent=n[`auth.adminTokenHelp`];let _=document.createElement(`a`);_.className=`text-control`,_.href=Xb,_.target=`_blank`,_.rel=`noreferrer`,_.style.color=`var(--accent)`,_.textContent=n[`auth.adminTokenDocsLink`],g.append(` `,_),p.append(g);let v=document.createElement(`div`);v.className=`notice notice-err`,v.setAttribute(`role`,`alert`),v.hidden=!0;let y=document.createElement(`div`);y.className=`modal-actions`;let b=document.createElement(`button`);b.type=`button`,b.className=`btn btn-ghost`,b.textContent=n[`common.cancel`];let x=document.createElement(`button`);x.type=`submit`,x.className=`btn btn-primary`,x.textContent=n[`common.ok`],y.append(b,x),s.append(c,u,p,v,y),o.append(s);let S=e=>{v.textContent=e??``,v.hidden=e===null},C=e=>{a||(a=!0,o.open&&o.close(),o.remove(),i?.focus(),t(e))};s.addEventListener(`submit`,t=>{t.preventDefault();let r=h.value.trim();if(!r){h.value=``,h.reportValidity();return}h.disabled=!0,x.disabled=!0,S(null),e(r).then(e=>{if(!a){if(e===`accepted`){C(r);return}h.value=``,h.disabled=!1,x.disabled=!1,S(e===`rejected`?n[`auth.adminTokenRejected`]:n[`auth.adminTokenUnavailable`]),h.focus()}}).catch(()=>{a||(h.value=``,h.disabled=!1,x.disabled=!1,S(n[`auth.adminTokenUnavailable`]),h.focus())})}),b.addEventListener(`click`,()=>C(null)),o.addEventListener(`cancel`,e=>{e.preventDefault(),C(null)}),document.body.append(o),typeof o.showModal==`function`?o.showModal():o.setAttribute(`open`,``),queueMicrotask(()=>h.focus())})}var Qb=`opencodex:session-unavailable`,$b=`opencodex-api-token`,ex=`/api/settings`,tx=1e4,nx=15e3,rx=`X-OpenCodex-Machine-Session`,ix=`X-OpenCodex-Machine-GUI-Origin`,ax=`X-OpenCodex-Machine-CSRF-Token`,ox=!1,sx=null,cx=null,lx=Zb,ux=tx,dx=nx,fx=new Map;function px(e){if(typeof window>`u`)return;let t=window.CustomEvent??(typeof CustomEvent==`function`?CustomEvent:null);if(t)try{window.dispatchEvent(new t(Qb,{detail:{plane:e}}))}catch{}}function mx(){return{token:null,csrfToken:null,browserOrigin:null,serverOrigin:null}}function hx(){return cx||_x(w_(``)),cx}function gx(e,t){return e.baseUrl===t.baseUrl&&e.serverOrigin===t.serverOrigin&&e.transport===t.transport}function _x(e){cx=e;for(let t of[`machine`,`shared`]){let n=fx.get(t);fx.set(t,n&&gx(n.target,e[t])?{...n,target:e[t]}:{target:e[t],session:mx(),resolutionInFlight:null,promptCancelled:!1})}}function vx(e){return hx(),fx.get(e)}function yx(e,t){let n=vx(e);t!==null&&n.session.token===t&&(n.session=mx())}function bx(e,t,n,r,i){let a=vx(e);return!t?.startsWith(`ocx_session_`)||!n||r!==window.location.origin||i!==a.target.serverOrigin?(a.session=mx(),!1):(a.session={token:t,csrfToken:n,browserOrigin:r,serverOrigin:i},a.promptCancelled=!1,!0)}function xx(e){return!!vx(e).session.token?.startsWith(`ocx_session_`)}async function Sx(e){let t=vx(e);if(!t.session.token?.startsWith(`ocx_session_`))return!1;let n=Un(tx);try{return(await window.fetch(`${t.target.baseUrl}/api/session/logout`,{method:`POST`,signal:n.signal})).ok?(t.session=mx(),t.promptCancelled=!1,!0):!1}catch{return!1}finally{n.clear()}}function Cx(e){let t=document.querySelector(`meta[name="${e}"]`),n=t?.content.trim()||null;return t?.remove(),n}function wx(){let e={token:Cx(`opencodex-session-token`),csrf:Cx(`opencodex-session-csrf`),browser:Cx(`opencodex-session-origin`),server:Cx(`opencodex-session-server-origin`)};for(let t of[`machine`,`shared`])vx(t).target.serverOrigin===e.server&&bx(t,e.token,e.csrf,e.browser,e.server)}function Tx(e,t){for(let n of e.match(/<meta\b[^>]*>/gi)??[])if(n.match(/\bname=["']([^"']+)["']/i)?.[1]===t)return n.match(/\bcontent=["']([^"']*)["']/i)?.[1]?.trim()||null;return null}function Ex(e,t){return bx(e,Tx(t,`opencodex-session-token`),Tx(t,`opencodex-session-csrf`),Tx(t,`opencodex-session-origin`),Tx(t,`opencodex-session-server-origin`))}function Dx(){try{sessionStorage.removeItem($b)}catch{}}function Ox(e){return new URL(e.baseUrl||`/`,window.location.href)}function kx(e,t){let n=Ox(e);if(t.origin!==n.origin)return!1;let r=n.pathname.replace(/\/$/,``);return r===``||t.pathname===r||t.pathname.startsWith(`${r}/`)}function Ax(e,t){if(!kx(e,t))return null;let n=Ox(e).pathname.replace(/\/$/,``);return t.pathname.slice(n.length)||`/`}function jx(e){let t;try{t=new URL(e instanceof Request?e.url:String(e),window.location.href)}catch{return null}let n=hx();return t.href===new URL(n.shared.bootstrapPath,window.location.href).href?{plane:`shared`,bootstrap:!0}:n.shared.transport===`relay`&&kx(n.shared,t)?{plane:`shared`,bootstrap:!1}:Ax(n.machine,t)?.startsWith(`/api/machine/`)?{plane:`machine`,bootstrap:!1}:Ax(n.shared,t)?.startsWith(`/api/`)?{plane:`shared`,bootstrap:!1}:t.href===new URL(n.machine.bootstrapPath,window.location.href).href?{plane:`machine`,bootstrap:!0}:null}function Mx(e,t,n,r){let i=vx(e),a=new Headers(n?.headers??(t instanceof Request?t.headers:void 0)),o=r===void 0?i.session.token:r,s=(n?.method??(t instanceof Request?t.method:`GET`)).toUpperCase();if(o&&a.set(`X-OpenCodex-API-Key`,o),o?.startsWith(`ocx_session_`)&&i.session.browserOrigin&&i.session.csrfToken&&(a.set(`X-OpenCodex-GUI-Origin`,i.session.browserOrigin),s!==`GET`&&s!==`HEAD`&&a.set(`X-OpenCodex-CSRF-Token`,i.session.csrfToken)),e===`shared`&&i.target.transport===`relay`){let e=vx(`machine`).session;e.token&&a.set(rx,e.token),e.browserOrigin&&a.set(ix,e.browserOrigin),s!==`GET`&&s!==`HEAD`&&e.csrfToken&&a.set(ax,e.csrfToken)}return a}function Nx(e,t,n,r){let i=Mx(e,t,n,r);return t instanceof Request?[new Request(t,{headers:i}),n?{...n,headers:i}:void 0]:[t,{...n,headers:i}]}async function Px(e){if(!sx)return{kind:`failed`};let t=vx(e),n=Un(ux);try{let[r,i]=Nx(e,t.target.bootstrapPath,{cache:`no-store`,signal:n.signal},null),a=await sx(r,i);return a.ok?Ex(e,await a.text())?{kind:`minted`,token:vx(e).session.token}:{kind:`unavailable`}:a.status>=400&&a.status<500?{kind:`unavailable`}:{kind:`failed`}}catch{return{kind:`failed`}}finally{n.clear()}}async function Fx(e,t){if(!sx)return`unavailable`;try{let[n,r]=Nx(e,`${vx(e).target.baseUrl}${ex}`,{cache:`no-store`},t),i=await sx(n,r);return i.status===401?`rejected`:i.ok?`accepted`:`unavailable`}catch{return`unavailable`}}async function Ix(e,t,n){let r=vx(e);if(r.promptCancelled||n?.aborted)return null;if(!r.resolutionInFlight){let n=(async()=>{let n=r.session.token;if(n&&n!==t)return n;let i,a=await Promise.race([Px(e),new Promise(e=>{i=setTimeout(()=>e({kind:`failed`}),dx)})]).finally(()=>clearTimeout(i));if(a.kind===`minted`)return a.token;if(a.kind===`failed`)return null;if(!y_())return r.promptCancelled=!0,px(e),null;let o=await lx(t=>Fx(e,t));return o?(r.session={token:o,csrfToken:null,browserOrigin:null,serverOrigin:r.target.serverOrigin},o):(r.promptCancelled=!0,null)})().finally(()=>{r.resolutionInFlight===n&&(r.resolutionInFlight=null)});r.resolutionInFlight=n}if(!n)return r.resolutionInFlight;let i,a=new Promise(e=>{i=()=>e(null),n.addEventListener(`abort`,i,{once:!0})});return Promise.race([r.resolutionInFlight,a]).finally(()=>{i&&n.removeEventListener(`abort`,i)})}function Lx(){if(ox)return;ox=!0,Dx(),hx(),wx();let e=window.fetch.bind(window);sx=e,window.fetch=async(t,n)=>{let r=jx(t);if(!r)return e(t,n);let i=vx(r.plane),a=i.session.token,[o,s]=Nx(r.plane,t,n),c=await e(o,s);if(r.bootstrap||c.status!==401)return c;let l=i.session.token;if(l&&l!==a){let[i,a]=Nx(r.plane,t,n),o=await e(i,a);if(o.status!==401)return o;yx(r.plane,l)}else yx(r.plane,a);let u=n?.signal??(t instanceof Request?t.signal:void 0),d=await Ix(r.plane,a,u??void 0);if(!d)return c;let[f,p]=Nx(r.plane,t,n,d),m=await e(f,p);return m.status===401&&yx(r.plane,d),m}}var Rx=/^ocx_pair_[A-Za-z0-9_-]{43}$/;async function zx(e,t,n){let r=t.trim();if(!Rx.test(r))throw Error(`pairing_code_invalid`);let i=await(n??((e,t)=>window.fetch(e,t)))(e.bootstrapPath,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`text/html`},body:JSON.stringify({grant:r})});if(!i.ok)throw Error(`pairing_refused`);if(!Ex(`shared`,await i.text()))throw Error(`pairing_response_invalid`);return!0}function Bx({target:e,onConnected:t}){let n=Z(),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1);return(0,_.createElement)(`section`,{className:`card connect-pairing`,"aria-labelledby":`connect-pairing-title`},(0,_.createElement)(`h2`,{id:`connect-pairing-title`},n(`connection.pairing.title`)),(0,_.createElement)(`p`,null,n(e.transport===`relay`?`connection.pairing.relayWarning`:`connection.pairing.body`)),(0,_.createElement)(`form`,{onSubmit:async n=>{if(n.preventDefault(),!a){o(!0),c(!1);try{await zx(e,r),t()}catch{c(!0)}finally{o(!1)}}},className:`api-form-row`},(0,_.createElement)(`label`,{htmlFor:`connect-pairing-code`,className:`field-label`},n(`connection.pairing.code`)),(0,_.createElement)(`input`,{id:`connect-pairing-code`,name:`pairingCode`,value:r,onChange:e=>i(e.currentTarget.value),autoComplete:`off`,spellCheck:!1,disabled:a,className:`input mono`,"aria-invalid":s||void 0,"aria-describedby":s?`connect-pairing-error`:void 0}),(0,_.createElement)(`button`,{type:`submit`,className:`btn btn-primary`,disabled:a||!r.trim()},n(a?`connection.pairing.submitting`:`connection.pairing.submit`)),s?(0,_.createElement)(`p`,{id:`connect-pairing-error`,className:`alert alert-err`,role:`alert`},n(`connection.pairing.error`)):null))}var Vx=new Set([`dashboard`,`startup`,`providers`,`models`,`subagents`,`logs`,`usage`,`storage`,`codex-set`,`integrations`]);function Hx(e){let t=pt(e??(typeof window<`u`?window.location.hash:``)).split(`/`)[0];return t===`debug`?`logs`:t===`codex-auth`?`codex-set`:t===`combos`||t===`routing`||t===`lab`?`models`:t===`api`||t===`claude`||t===`grok`?`integrations`:Vx.has(t)?t:`dashboard`}var Ux=[`dashboard/providers`,`dashboard/models`],Wx=[`models/combos`,`models/routing`,`models/compatibility`],Gx=[`integrations/keys`,`integrations/codex`,`integrations/claude`,`integrations/claude/desktop`,`integrations/grok`,`integrations/cursor`,`integrations/opencode`,`integrations/pi`,`integrations/omp`,`integrations/hermes`,`integrations/openclaw`,`integrations/kimi`,`integrations/gajae`,`integrations/dsh`,`integrations/mcode`,`integrations/zcode`,`integrations/prime`,`integrations/aside`];function Kx(e,t){return e===t||t===`logs`&&e===`logs/debug`||t===`codex-set`&&e===`codex-set/prompt`||t===`models`&&Wx.includes(e)||t===`dashboard`&&(e===`dashboard/update`||Ux.includes(e))||t===`integrations`&&Gx.includes(e)}function qx(e){let t=Hx(e);return e===`debug`||e.startsWith(`debug/`)?{page:`logs`,replaceTo:`logs/debug`}:e===`codex-auth`||e.startsWith(`codex-auth/`)?{page:`codex-set`,replaceTo:`codex-set`}:e===`combos`||e.startsWith(`combos/`)?{page:`models`,replaceTo:`models/combos`}:e===`routing`||e.startsWith(`routing/`)?{page:`models`,replaceTo:`models/routing`}:e===`lab`||e.startsWith(`lab/`)?{page:`models`,replaceTo:`models/compatibility`}:e===`api`?{page:`integrations`,replaceTo:`integrations/keys`}:e===`claude`?{page:`integrations`,replaceTo:`integrations/claude`}:e===`grok`?{page:`integrations`,replaceTo:`integrations/grok`}:e===`providers/workspace`?{page:`providers`,replaceTo:`providers`}:Kx(e,t)?{page:t,replaceTo:null}:{page:t,replaceTo:t}}var Jx=[`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 Yx(){try{for(let e of Jx)localStorage.removeItem(e)}catch{}}function Xx(){let[e,t]=(0,_.useState)(Hx);(0,_.useEffect)(()=>{Yx()},[]);let n=(0,_.useCallback)(e=>{let n=qx(e);n.replaceTo&&mt(n.replaceTo),t(n.page)},[]);return(0,_.useEffect)(()=>{let e=()=>{n(pt(window.location.hash))};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[n]),(0,_.useEffect)(()=>{let n=qx(pt(window.location.hash));n.replaceTo&&mt(n.replaceTo),n.page!==e&&t(n.page)},[e]),{page:e,setPageState:t,navigateToPage:(e,n)=>{ht(n?`${e}/${n}`:e),t(e)}}}var Zx=15e3;function Qx(e,t,n){return typeof e?.message==`string`&&e.message.trim()?e.message:typeof e?.error==`string`&&e.error.trim()?e.error:n(t)}function $x(e){return(e instanceof DOMException||e instanceof Error)&&e.name===`AbortError`}async function eS(e,t={}){let{fetchFn:n=fetch,timeoutMs:r=Zx,formatFailure:i=e=>`Failed to stop proxy (HTTP ${e}).`,mode:a=`standalone`}=t,o;try{o=await n(`${e}${a===`client`?`/api/machine/disconnect`:`/api/stop`}`,{method:`POST`,...a===`client`?{headers:{"Content-Type":`application/json`},body:`{}`}:{},signal:AbortSignal.timeout(r)})}catch(e){return $x(e),{accepted:!0}}let s=await o.json().catch(()=>null);return!o.ok||s?.success===!1?{accepted:!1,message:Qx(s,o.status,i)}:{accepted:!0}}var tS={dashboard:`nav.dashboard`,startup:`nav.startup`,providers:`nav.providers`,models:`nav.models`,subagents:`nav.subagents`,logs:`nav.logs`,usage:`nav.usage`,storage:`nav.storage`,"codex-set":`nav.codexSet`,integrations:`nav.integrations`},nS=``,rS=w_(nS);_x(rS),Lx();var iS=`ocx-theme`,aS=[{id:`dashboard`,tkey:`nav.dashboard`,Icon:te},{id:`codex-set`,tkey:`nav.codexSet`,Icon:Oe},{id:`providers`,tkey:`nav.providers`,Icon:ne},{id:`models`,tkey:`nav.models`,Icon:re},{id:`subagents`,tkey:`nav.subagents`,Icon:ie},{id:`logs`,tkey:`nav.logs`,Icon:ae},{id:`usage`,tkey:`nav.usage`,Icon:ce},{id:`storage`,tkey:`nav.storage`,Icon:le},{id:`integrations`,tkey:`nav.integrations`,Icon:Fe}],oS={light:Me,dark:Ne,system:Pe},sS={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function cS(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 lS(){let e=localStorage.getItem(iS);return e===`light`||e===`dark`?e:`system`}function uS(){let{page:e,navigateToPage:t}=Xx(),[n,r]=(0,_.useState)(Zf);(0,_.useEffect)(()=>{let e=()=>r(Zf());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let[i,a]=(0,_.useState)(lS),{locale:o,setLocale:s}=ut(),c=Z(),[l,u]=(0,_.useState)(rS),[d,f]=(0,_.useState)(()=>!v_()),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(()=>xx(`shared`)),[v,y]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=new AbortController;return O_(nS,e.signal).then(async t=>{if(_x(t),u(t),t.connected&&!xx(`shared`))try{let n=await fetch(t.shared.bootstrapPath,{cache:`no-store`,signal:AbortSignal.any([e.signal,AbortSignal.timeout(5e3)])});n.ok&&Ex(`shared`,await n.text())}catch{}e.signal.aborted||(g(xx(`shared`)),m(!1),f(!0))}).catch(()=>{e.signal.aborted||(m(!0),f(!0))}),()=>e.abort()},[]);let b=D_(`machine`,l),x=D_(`shared`,l),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(null),T=(0,_.useRef)(null),E=(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;i===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(iS)):(e.setAttribute(`data-theme`,i),localStorage.setItem(iS,i))},[i]);let D=G(`app-healthz:${b}`,[b,d],async e=>{let t=await fetch(`${b}/healthz`,{signal:e});return t.ok?cS(await t.json()):null},{pollMs:3e4,enabled:d}),O=()=>a(e=>e===`light`?`dark`:e===`dark`?`system`:`light`),k=oS[i],A=D.data??`2.43.0`,[j,M]=(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){E.current=!0;let e=setTimeout(()=>T.current?.focus(),200);return()=>clearTimeout(e)}E.current&&(E.current=!1,w.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[N,P]=(0,_.useState)(0),{restarting:F,restart:I}=Tl(x,{onSettled:()=>P(e=>e+1)}),L=async()=>{if(!confirm(c(l.connected?`connection.disconnectConfirm`:`dash.stopConfirm`)))return;M(!0);let e=await eS(b,{formatFailure:e=>c(`dash.stopFailed`,{status:String(e)}),mode:l.connected?`client`:`standalone`});e.accepted||(M(!1),alert(e.message))},R=async()=>{if(v)return;y(!0);let e=await Sx(`shared`);y(!1),e?g(!1):alert(c(`connection.sessionLogoutFailed`))},z=(0,J.jsxs)(`button`,{type:`button`,className:`brand brand-home`,onClick:()=>{t(`dashboard`),C(!1)},"aria-label":c(`nav.goHome`),title:c(`nav.goHome`),...e===`dashboard`?{"aria-current":`page`}:{},children:[(0,J.jsx)(`span`,{className:`brand-logo`,role:`img`,"aria-label":c(`app.logoAria`)}),(0,J.jsx)(`span`,{className:`name`,children:`opencodex`}),(0,J.jsxs)(`span`,{className:`ver`,children:[`v`,A]})]});return(0,J.jsxs)(`div`,{className:`app`,children:[(0,J.jsxs)(`header`,{className:`mobile-topbar`,inert:S,children:[(0,J.jsx)(`button`,{ref:w,type:`button`,className:`menu-toggle`,onClick:()=>C(e=>!e),"aria-expanded":S,"aria-controls":`app-sidebar`,"aria-label":c(S?`nav.closeMenu`:`nav.openMenu`),title:c(S?`nav.closeMenu`:`nav.openMenu`),children:(0,J.jsx)(oe,{})}),z,(0,J.jsxs)(`div`,{className:`mobile-topbar-actions`,children:[l.connected&&h&&(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb`,onClick:()=>{R()},disabled:v,"aria-label":c(v?`connection.sessionLoggingOut`:`connection.sessionLogout`),title:c(`connection.sessionLogout`),children:(0,J.jsx)(de,{})}),(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb sidebar-orb--danger`,onClick:L,disabled:j,"aria-label":c(l.connected?`connection.disconnect`:`dash.stop`),title:c(l.connected?`connection.disconnect`:`dash.stop`),children:(0,J.jsx)(Te,{})}),(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb`,onClick:()=>{I()},disabled:F,"aria-label":c(`dash.codexRestart`),title:c(`dash.codexRestart`),children:(0,J.jsx)(pe,{})})]})]}),S&&(0,J.jsx)(`div`,{className:`drawer-scrim`,onClick:()=>C(!1),"aria-hidden":`true`}),(0,J.jsxs)(`aside`,{id:`app-sidebar`,className:`sidebar${S?` open`:``}`,ref:T,tabIndex:-1,children:[(0,J.jsxs)(`div`,{className:`drawer-head`,children:[z,(0,J.jsx)(`button`,{type:`button`,className:`menu-toggle drawer-close`,onClick:()=>C(!1),"aria-label":c(`nav.closeMenu`),title:c(`nav.closeMenu`),children:(0,J.jsx)(de,{})})]}),(0,J.jsx)(`nav`,{children:aS.map(n=>{let{id:r,tkey:i,Icon:a}=n,o=r===e;return(0,J.jsx)(`div`,{className:`nav-entry`,children:(0,J.jsxs)(`button`,{type:`button`,className:`nav-item${o?` active`:``}`,"data-page":r,onClick:()=>{t(r),C(!1)},"aria-current":o?`page`:void 0,children:[(0,J.jsx)(a,{}),` `,c(i)]})},r)})}),(0,J.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,J.jsxs)(`div`,{className:`lang-toggle`,children:[(0,J.jsx)(Fe,{"aria-hidden":!0}),(0,J.jsx)(kt,{value:o,options:nt.map(e=>({value:e.code,label:et(e.code)})),onChange:e=>s(e),label:c(`lang.label`),placement:`right`,portal:!1,style:{flex:1,minWidth:0,width:`100%`}})]}),(0,J.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:O,"aria-label":`${c(`theme.label`)}: ${c(sS[i])}`,title:`${c(`theme.label`)}: ${c(sS[i])}`,children:[(0,J.jsx)(k,{}),` `,(0,J.jsx)(`span`,{className:`mode`,children:c(sS[i])})]}),(0,J.jsxs)(`div`,{className:`sidebar-action-row`,children:[(0,J.jsx)(`span`,{className:`sidebar-action-label`,children:c(`dash.actions`)}),(0,J.jsxs)(`div`,{className:`sidebar-action-orbs`,children:[l.connected&&h&&(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb`,onClick:()=>{R()},disabled:v,"aria-label":c(v?`connection.sessionLoggingOut`:`connection.sessionLogout`),title:c(`connection.sessionLogout`),children:(0,J.jsx)(de,{})}),(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb sidebar-orb--danger`,onClick:L,disabled:j,"aria-label":c(j?`dash.stopping`:l.connected?`connection.disconnect`:`dash.stop`),title:c(j?`dash.stopping`:l.connected?`connection.disconnect`:`dash.stop`),children:(0,J.jsx)(Te,{})}),(0,J.jsx)(`button`,{type:`button`,className:`sidebar-orb`,onClick:()=>{I()},disabled:F,"aria-label":c(F?`dash.codexRestarting`:`dash.codexRestart`),title:c(F?`dash.codexRestarting`:`dash.codexRestart`),children:(0,J.jsx)(pe,{})})]})]}),(0,J.jsx)(qb,{apiBase:x,onOpenUpdate:()=>{C(!1),t(`dashboard`,`update`)}})]})]}),(0,J.jsx)(`main`,{className:`main`,inert:S,children:(0,J.jsx)(`div`,{className:`main-inner${e===`models`&&n===`combos`?` main-inner--combos`:``}`,children:(0,J.jsx)(Fl,{pageName:c(tS[e]),title:c(`errorBoundary.title`),message:c(`errorBoundary.message`),detailsLabel:c(`errorBoundary.details`),reloadLabel:c(`errorBoundary.reload`),children:d?(0,J.jsxs)(J.Fragment,{children:[p&&(0,J.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:c(`connection.machineUnavailable`)}),l.connected&&!h&&(0,J.jsx)(Bx,{target:l.shared,onConnected:()=>g(!0)}),e===`dashboard`&&(0,J.jsx)(Qr,{apiBase:x}),e===`startup`&&(0,J.jsx)(Hb,{apiBase:x,machineApiBase:b,connected:l.connected}),e===`providers`&&(0,J.jsx)(fl,{apiBase:x}),e===`models`&&(0,J.jsx)(Mp,{apiBase:x,restartEpoch:N},x),e===`subagents`&&(0,J.jsx)(Wp,{apiBase:x},x),e===`logs`&&(0,J.jsx)(bh,{apiBase:x}),e===`usage`&&(0,J.jsx)(Hh,{apiBase:x,connected:l.connected,apiKeyId:l.apiKeyId}),e===`storage`&&(0,J.jsx)(_g,{apiBase:x}),e===`codex-set`&&(0,J.jsx)(o_,{apiBase:x}),e===`integrations`&&(0,J.jsx)(kb,{apiBase:x,machineApiBase:b,connected:l.connected})]}):(0,J.jsx)(`div`,{className:`alert`,children:c(`connection.discovering`)})},e)})})]})}g.createRoot(document.getElementById(`root`)).render((0,J.jsx)(_.StrictMode,{children:(0,J.jsx)(dt,{children:(0,J.jsx)(uS,{})})}));
|
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-Djowl68T.js"></script>
|
|
20
20
|
<link rel="stylesheet" crossorigin href="/assets/index-DS1NE4Jn.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.43.0
|
|
3
|
+
"version": "2.43.0",
|
|
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",
|