@aidotnet/server-linux-x64 0.13.2 → 0.13.3

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.
Files changed (54) hide show
  1. package/bin/astra-server +2 -2
  2. package/bin/wwwroot/assets/{ClientsPage-21FrObYM.js → ClientsPage-CnHLR9_Q.js} +6 -6
  3. package/bin/wwwroot/assets/KeyPage-zIb63Of5.js +1 -0
  4. package/bin/wwwroot/assets/ModelDetailPage-BcXehC4E.js +1 -0
  5. package/bin/wwwroot/assets/{ModelsPage-WkYlY7Qd.js → ModelsPage-BWIb4L9N.js} +1 -1
  6. package/bin/wwwroot/assets/{PluginsPage-BqRvWqrx.js → PluginsPage-BaoJMLzq.js} +2 -2
  7. package/bin/wwwroot/assets/PrivacyPage-BmqVk2pi.js +1 -0
  8. package/bin/wwwroot/assets/{ProviderDetailPage-BpF5X0Bn.js → ProviderDetailPage-BLCMpahq.js} +3 -3
  9. package/bin/wwwroot/assets/ProvidersPage-CnBPj_Jb.js +2 -0
  10. package/bin/wwwroot/assets/SettingsPage-CcEs-Ivi.js +2 -0
  11. package/bin/wwwroot/assets/SmartRoutingPage-BEf8F6eE.js +2 -0
  12. package/bin/wwwroot/assets/{TokenDetailPage-BUFC4sTY.js → TokenDetailPage-CnwCepbj.js} +1 -1
  13. package/bin/wwwroot/assets/{TokenPoolEditor-CH3L-iQ5.js → TokenPoolEditor-B5YYbTBI.js} +1 -1
  14. package/bin/wwwroot/assets/{TokensPage-DqFNHl8B.js → TokensPage-IYF5mfUz.js} +1 -1
  15. package/bin/wwwroot/assets/TracesPage-RdQ1uzTo.js +8 -0
  16. package/bin/wwwroot/assets/{TracesPage-CIQ1PxNA.css → TracesPage-yYSP_wpw.css} +1 -1
  17. package/bin/wwwroot/assets/{TrayPanelPage-C-saKyBN.js → TrayPanelPage-DF3TZ-Mi.js} +1 -1
  18. package/bin/wwwroot/assets/TrayPanelView-ctysAPlQ.js +1 -0
  19. package/bin/wwwroot/assets/alert-CMMOyMsp.js +15 -0
  20. package/bin/wwwroot/assets/{arrow-down-wREAClBx.js → arrow-down-rd1gJD55.js} +1 -1
  21. package/bin/wwwroot/assets/{arrow-left-BwL0MdoM.js → arrow-left-BYi8J86q.js} +1 -1
  22. package/bin/wwwroot/assets/arrow-up-right-DNaPmTcJ.js +1 -0
  23. package/bin/wwwroot/assets/checkbox--x0D0yfB.js +1 -0
  24. package/bin/wwwroot/assets/{cloud-download-BCNvV9ef.js → cloud-download-BkOTPIzF.js} +1 -1
  25. package/bin/wwwroot/assets/{confirm-morph-DWp2gsoG.js → confirm-morph-BLco2mdX.js} +1 -1
  26. package/bin/wwwroot/assets/{download-BGSlqgxA.js → download-CSRdoXEJ.js} +1 -1
  27. package/bin/wwwroot/assets/{ellipsis-COWYoRP4.js → ellipsis-BI50R2Bc.js} +1 -1
  28. package/bin/wwwroot/assets/{external-link-OKfamryM.js → external-link-Bzx5-ExU.js} +1 -1
  29. package/bin/wwwroot/assets/{folder-open-BWX9PzRK.js → folder-open-BxXgq-F4.js} +1 -1
  30. package/bin/wwwroot/assets/{index-Bw0Y3RgL.css → index-CIeJgTvn.css} +1 -1
  31. package/bin/wwwroot/assets/{index-DorAVedK.js → index-Ck4Qlg9B.js} +8 -8
  32. package/bin/wwwroot/assets/{log-out-BrzYb7oI.js → log-out-DzOM9UKH.js} +1 -1
  33. package/bin/wwwroot/assets/minus-CYKTpU0K.js +1 -0
  34. package/bin/wwwroot/assets/overlays-BFrvqpMl.js +41 -0
  35. package/bin/wwwroot/assets/{pencil-DkOcGe5U.js → pencil-BMnmsFVj.js} +1 -1
  36. package/bin/wwwroot/assets/{power-eNwK6WyW.js → power-CznSHqkx.js} +1 -1
  37. package/bin/wwwroot/assets/radio-cards-DNOgi4px.js +1 -0
  38. package/bin/wwwroot/assets/{rotate-ccw-CkH5KeQH.js → rotate-ccw-Bhx85LK2.js} +1 -1
  39. package/bin/wwwroot/assets/{sortable.esm-yo5QAK_F.js → sortable.esm-BY9yO4Eq.js} +1 -1
  40. package/bin/wwwroot/index.html +4 -4
  41. package/package.json +1 -1
  42. package/bin/wwwroot/assets/KeyPage-8kx7w7Gr.js +0 -1
  43. package/bin/wwwroot/assets/ModelDetailPage-DQvXw1BZ.js +0 -1
  44. package/bin/wwwroot/assets/PrivacyPage-9-TLgfJ3.js +0 -1
  45. package/bin/wwwroot/assets/ProvidersPage-CEE09LSY.js +0 -2
  46. package/bin/wwwroot/assets/SettingsPage-7YVXpvQ_.js +0 -2
  47. package/bin/wwwroot/assets/SmartRoutingPage-Yi6ObQgs.js +0 -2
  48. package/bin/wwwroot/assets/TracesPage-Dyh2sMvS.js +0 -7
  49. package/bin/wwwroot/assets/TrayPanelView-BKhhqBGh.js +0 -1
  50. package/bin/wwwroot/assets/alert-DRuYOIBF.js +0 -15
  51. package/bin/wwwroot/assets/checkbox-BP7SY0L6.js +0 -1
  52. package/bin/wwwroot/assets/minus-CKLCHvmT.js +0 -1
  53. package/bin/wwwroot/assets/overlays-CHP5oojo.js +0 -41
  54. package/bin/wwwroot/assets/radio-cards-BXMylVDk.js +0 -1
package/bin/astra-server CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/astra-server
3
- size: 53032624 bytes
4
- sha256: 1ee664383b30083c1047928399ada8c15c27ab63d426cb96dc140de3103ec8b3
3
+ size: 53288592 bytes
4
+ sha256: e43cfbd153b65ff87b8559daa1a463643c2d11271eb3d8d38e4925a36bffb937
@@ -1,9 +1,9 @@
1
- import{Et as e,G as t,Gt as n,H as r,Ht as i,Jt as a,K as o,Kt as s,La as c,Lr as l,Ma as u,Mr as d,Na as f,Or as p,Pa as m,Ut as h,Vt as g,Y as _,Yn as v,Yt as y,_ as b,_n as x,bt as S,c as C,ct as w,d as T,dt as ee,ei as E,fn as te,gt as ne,hr as re,jr as ie,m as D,mn as O,n as k,nr as ae,or as oe,ot as A,qt as se,r as j,s as ce,t as M,u as N,v as P,wr as le,xt as F,y as I}from"./alert-DRuYOIBF.js";import{a as L,gt as R,ht as ue,i as de,o as z,r as B}from"./overlays-CHP5oojo.js";import{n as V}from"./ProvidersPage-CEE09LSY.js";import{t as fe}from"./download-BGSlqgxA.js";import{t as pe}from"./external-link-OKfamryM.js";import{t as me}from"./folder-open-BWX9PzRK.js";import{a as he,c as H,d as U,f as ge,i as W,l as G,n as _e,o as ve,p as K,r as ye,s as be,t as xe,u as Se}from"./sortable.esm-yo5QAK_F.js";import{t as Ce}from"./rotate-ccw-CkH5KeQH.js";import{$ as we,B as Te,L as q,N as Ee,Q as De,R as Oe,S as J,V as ke,X as Ae,b as je,h as Me,v as Y,x as Ne,z as Pe}from"./index-DorAVedK.js";var Fe={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};Fe.node;var Ie=F(Fe),Le={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};Le.node;var Re=F(Le),ze={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};ze.node;var X=F(ze),Z=c(m(),1),Q=f(),Be=`astra claude`;function Ve(e){return e.reduce((e,t)=>({requests:e.requests+1,inputTokens:e.inputTokens+t.inputTokens,totalInputTokens:e.totalInputTokens+t.inputTokens+t.cacheReadTokens+t.cacheCreationTokens,outputTokens:e.outputTokens+t.outputTokens,failed:e.failed+ +(t.status===`error`),estimatedCostNanoUsd:e.estimatedCostNanoUsd+(t.estimatedCostNanoUsd??0)}),{requests:0,inputTokens:0,totalInputTokens:0,outputTokens:0,failed:0,estimatedCostNanoUsd:0})}var He=e=>e.status===`active`&&e.enabled;function Ue(e,t){let n=[e.name||e.id,e.email?`· ${e.email}`:null,e.plan?`· ${e.plan}`:null].filter(Boolean).join(` `);return He(e)?n:`${n} · ${t}`}function We({enabled:e,gatewayEnabled:t}){let{t:r}=w(),{toast:i}=z(),a=De(),o=n(e),c=p(),[l,u]=(0,Z.useState)(null),d=o.data?.mode??`gateway`,f=o.data?.accounts??[],m=o.data?.accountId??null??f.find(He)?.id??null,h=f.find(e=>e.id===m),g=d===`direct`,_=t&&(g||o.data!=null),v=g&&h?.telemetryEnabled===!0,y=s(v?h?.id:null,v),x=c.isPending,S=e=>c.mutate(e,{onError:e=>i(L(e),`error`)});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(N,{title:r(`clients.claudeDirect.modeTitle`),footer:r(`clients.claudeDirect.modeFooter`),children:[(0,Q.jsx)(D,{label:r(`clients.claudeDirect.mode`),detail:r(g?`clients.claudeDirect.directDetail`:`clients.claudeDirect.gatewayDetail`),children:(0,Q.jsx)(b,{ariaLabel:r(`clients.claudeDirect.mode`),value:d,onChange:e=>{if(e===d||x||!o.data)return;let t=m??f.find(He)?.id??null;if(e===`direct`&&!t){i(r(`clients.claudeDirect.needAccountToast`),`error`);return}S({mode:e,accountId:t})},items:[{value:`gateway`,label:r(`clients.claudeDirect.gateway`)},{value:`direct`,label:r(`clients.claudeDirect.direct`)}]})}),(0,Q.jsx)(`p`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:r(`clients.claudeDirect.modeNote`)})]}),o.isLoading&&(0,Q.jsx)(P,{lines:3}),o.isError&&(0,Q.jsx)(`div`,{className:`mb-5`,children:(0,Q.jsx)(M,{tone:`danger`,title:r(`clients.claudeDirect.loadFailed`),children:L(o.error)})}),_&&(0,Q.jsx)(`div`,{className:`mb-5`,children:(0,Q.jsx)(M,{tone:`warning`,title:r(`clients.claudeDirect.gatewayOnTitle`),children:r(`clients.claudeDirect.gatewayOnDetail`)})}),o.data&&(0,Q.jsx)(N,{title:r(`clients.claudeDirect.accountsTitle`),footer:r(`clients.claudeDirect.accountsFooter`),children:f.length===0?(0,Q.jsx)(C,{title:r(`clients.claudeDirect.noAccount`),detail:r(`clients.claudeDirect.noAccountDetail`),action:(0,Q.jsx)(j,{variant:`primary`,onClick:()=>a(`/providers`),children:r(`clients.claudeDirect.goProviders`)})}):(0,Q.jsx)(D,{label:r(`clients.claudeDirect.account`),children:(0,Q.jsx)(B,{className:`max-w-[300px]`,ariaLabel:r(`clients.claudeDirect.account`),value:m,onChange:e=>{x||e===m||S({mode:d,accountId:e})},options:f.map(e=>({value:e.id,label:Ue(e,r(`clients.claudeDirect.accountDisabledSuffix`,{status:r(`providers.subscription.status.${e.status}`)})),disabled:!He(e)}))})})}),o.data&&g&&h&&(0,Q.jsx)(N,{title:r(`clients.claudeDirect.launchTitle`),footer:r(`clients.claudeDirect.launchNote`),children:(0,Q.jsx)(Ge,{command:Be,copied:l,onCopy:async e=>{await R.copy(e)&&(u(e),i(r(`common.copied`)))}})}),o.data&&g&&h&&(0,Q.jsxs)(N,{title:r(`clients.claudeDirect.statsTitle`),footer:r(`clients.claudeDirect.statsFooter`),children:[(0,Q.jsx)(D,{label:r(`clients.claudeDirect.statsConsent`),detail:r(`clients.claudeDirect.statsConsentDetail`),children:(0,Q.jsx)(I,{label:r(`clients.claudeDirect.statsConsent`),checked:h.telemetryEnabled,disabled:x,onChange:e=>{h&&!x&&S({mode:d,accountId:h.id,telemetryEnabled:e})}})}),v&&(0,Q.jsx)(Ke,{requests:y})]})]})}function Ge({command:e,copied:t,onCopy:n}){let{t:r}=w();return(0,Q.jsx)(D,{label:(0,Q.jsx)(`span`,{className:`font-mono text-[12px] break-all selectable`,children:e}),children:(0,Q.jsx)(j,{size:`sm`,icon:(0,Q.jsx)(ne,{className:`size-3`}),variant:t===e?`primary`:`glass`,"aria-label":r(`common.copy`),title:r(`common.copy`),onClick:()=>void n(e),children:r(t===e?`common.copied`:`common.copy`)})})}function Ke({requests:e}){let{t:n,locale:i}=w(),a=e.data??[],s=Ve(a);return e.isLoading?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(P,{lines:3})}):e.isError?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(M,{tone:`danger`,title:n(`clients.claudeDirect.statsFailed`),children:L(e.error)})}):a.length===0?(0,Q.jsx)(C,{icon:(0,Q.jsx)(ke,{className:`size-6`}),title:n(`clients.claudeDirect.statsEmpty`),detail:n(`clients.claudeDirect.statsEmptyDetail`)}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(D,{label:n(`clients.claudeDirect.statsTotals`,{count:_(s.requests)}),detail:n(`clients.claudeDirect.statsInDetail`,{input:_(s.totalInputTokens),cache:_(a.reduce((e,t)=>e+t.cacheReadTokens,0)),output:_(s.outputTokens)})}),(0,Q.jsx)(D,{label:n(`clients.claudeDirect.statsCost`),detail:n(`clients.claudeDirect.statsCostDetail`),children:(0,Q.jsx)(`span`,{className:`num text-[13px]`,children:o(a.some(e=>e.estimatedCostNanoUsd!=null)?s.estimatedCostNanoUsd:null)})}),s.failed>0&&(0,Q.jsx)(D,{label:n(`clients.claudeDirect.statsFailedCount`,{count:_(s.failed)}),children:(0,Q.jsx)(k,{tone:`red`,children:n(`clients.claudeDirect.statusError`)})}),a.map(e=>(0,Q.jsx)(D,{label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.model}),e.status===`error`?(0,Q.jsx)(k,{tone:`red`,children:n(`clients.claudeDirect.statusError`)}):(0,Q.jsx)(k,{tone:`green`,children:n(`status.success`)})]}),detail:(0,Q.jsx)(`span`,{className:`num`,children:[r(e.occurredAtUtc,i),n(`clients.claudeDirect.tokensDetail`,{input:_(e.inputTokens),output:_(e.outputTokens)}),e.durationMs==null?null:t(e.durationMs),e.accountUuid??null].filter(Boolean).join(` · `)}),children:(0,Q.jsx)(`span`,{className:`num text-[13px]`,children:o(e.estimatedCostNanoUsd)})},e.id))]})}function qe({descriptors:e,values:t,onChange:n,enabled:r}){let{t:i}=w(),a=(e,r)=>{let i={...t};r===void 0||r===!1||r===0||r==="default"||r===``?delete i[e]:i[e]=r,n(i)};return(0,Q.jsx)(N,{title:i(`clients.options.title`),footer:i(r?`clients.options.footerEnabled`:`clients.options.footer`),children:e.map(e=>{let n=i(`clients.option.${e.key}`),r=i(`clients.option.${e.key}.hint`),o=t[e.key];return(0,Q.jsxs)(D,{label:n,detail:r,children:[e.type===`bool`&&(0,Q.jsx)(I,{label:n,checked:o===!0,onChange:t=>a(e.key,t)}),e.type===`int`&&(0,Q.jsx)(T,{className:`w-36`,mono:!0,inputMode:`numeric`,"aria-label":n,placeholder:i(`clients.options.unset`),value:typeof o==`number`?String(o):``,onChange:t=>{let n=Number.parseInt(t.target.value.replace(/\D/g,``),10);a(e.key,Number.isFinite(n)?n:void 0)}}),e.type===`enum`&&(0,Q.jsx)(B,{ariaLabel:n,value:typeof o==`string`?o:`default`,onChange:t=>a(e.key,t),options:(e.choices??[]).map(e=>({value:e,label:i(`clients.optionChoice.${e}`)})),className:`w-36`})]},e.key)})})}var Je=[`openai-chat`,`openai-responses`,`anthropic`,`gemini`],Ye=e=>typeof e==`string`&&Je.includes(e);function Xe(e){let t=e?.protocolOverrides,n={};if(!t||typeof t!=`object`)return n;for(let[e,r]of Object.entries(t))Ye(r)&&(n[e]=r);return n}function Ze(e){let t=e?.models;if(!t||typeof t!=`object`)return[];let n=[];for(let e of Object.values(t)){if(!e||typeof e!=`object`)continue;let t=e;typeof t.id==`string`&&t.id&&!n.some(e=>e.id===t.id)&&n.push({id:t.id,name:typeof t.name==`string`&&t.name?t.name:t.id,native:Array.isArray(t.protocols)?t.protocols.filter(Ye):[]})}return n}function Qe(e,t){let n=e.native.find(e=>t.includes(e));return n?{protocol:n,translated:!1}:{protocol:t[0],translated:!0}}var $e=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
1
+ import{Et as e,Fa as t,G as n,Gt as r,H as i,Ht as a,Jt as o,K as s,Kt as c,Lr as l,Mr as u,Na as d,Or as f,Pa as p,Ra as m,Ut as h,Vt as g,Y as _,Yn as v,Yt as y,_ as b,_n as x,bt as S,c as C,ct as w,d as T,dt as ee,ei as E,fn as te,gt as ne,hr as re,jr as ie,m as D,mn as O,n as k,nr as ae,or as oe,ot as A,qt as se,r as j,s as ce,t as M,u as N,v as P,wr as le,xt as F,y as I}from"./alert-CMMOyMsp.js";import{a as L,gt as R,ht as ue,i as de,o as z,r as B}from"./overlays-BFrvqpMl.js";import{n as V}from"./ProvidersPage-CnBPj_Jb.js";import{t as fe}from"./download-CSRdoXEJ.js";import{t as pe}from"./external-link-Bzx5-ExU.js";import{t as me}from"./folder-open-BxXgq-F4.js";import{a as he,c as H,d as U,f as ge,i as W,l as G,n as _e,o as ve,p as K,r as ye,s as be,t as xe,u as Se}from"./sortable.esm-BY9yO4Eq.js";import{t as Ce}from"./rotate-ccw-Bhx85LK2.js";import{$ as we,B as Te,L as q,N as Ee,Q as De,R as Oe,S as J,V as ke,X as Ae,b as je,h as Me,v as Y,x as Ne,z as Pe}from"./index-Ck4Qlg9B.js";var Fe={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};Fe.node;var Ie=F(Fe),Le={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};Le.node;var Re=F(Le),ze={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};ze.node;var X=F(ze),Z=m(t(),1),Q=p(),Be=`astra claude`;function Ve(e){return e.reduce((e,t)=>({requests:e.requests+1,inputTokens:e.inputTokens+t.inputTokens,totalInputTokens:e.totalInputTokens+t.inputTokens+t.cacheReadTokens+t.cacheCreationTokens,outputTokens:e.outputTokens+t.outputTokens,failed:e.failed+ +(t.status===`error`),estimatedCostNanoUsd:e.estimatedCostNanoUsd+(t.estimatedCostNanoUsd??0)}),{requests:0,inputTokens:0,totalInputTokens:0,outputTokens:0,failed:0,estimatedCostNanoUsd:0})}var He=e=>e.status===`active`&&e.enabled;function Ue(e,t){let n=[e.name||e.id,e.email?`· ${e.email}`:null,e.plan?`· ${e.plan}`:null].filter(Boolean).join(` `);return He(e)?n:`${n} · ${t}`}function We({enabled:e,gatewayEnabled:t}){let{t:n}=w(),{toast:i}=z(),a=De(),o=r(e),s=f(),[l,u]=(0,Z.useState)(null),d=o.data?.mode??`gateway`,p=o.data?.accounts??[],m=o.data?.accountId??null??p.find(He)?.id??null,h=p.find(e=>e.id===m),g=d===`direct`,_=t&&(g||o.data!=null),v=g&&h?.telemetryEnabled===!0,y=c(v?h?.id:null,v),x=s.isPending,S=e=>s.mutate(e,{onError:e=>i(L(e),`error`)});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(N,{title:n(`clients.claudeDirect.modeTitle`),footer:n(`clients.claudeDirect.modeFooter`),children:[(0,Q.jsx)(D,{label:n(`clients.claudeDirect.mode`),detail:n(g?`clients.claudeDirect.directDetail`:`clients.claudeDirect.gatewayDetail`),children:(0,Q.jsx)(b,{ariaLabel:n(`clients.claudeDirect.mode`),value:d,onChange:e=>{if(e===d||x||!o.data)return;let t=m??p.find(He)?.id??null;if(e===`direct`&&!t){i(n(`clients.claudeDirect.needAccountToast`),`error`);return}S({mode:e,accountId:t})},items:[{value:`gateway`,label:n(`clients.claudeDirect.gateway`)},{value:`direct`,label:n(`clients.claudeDirect.direct`)}]})}),(0,Q.jsx)(`p`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:n(`clients.claudeDirect.modeNote`)})]}),o.isLoading&&(0,Q.jsx)(P,{lines:3}),o.isError&&(0,Q.jsx)(`div`,{className:`mb-5`,children:(0,Q.jsx)(M,{tone:`danger`,title:n(`clients.claudeDirect.loadFailed`),children:L(o.error)})}),_&&(0,Q.jsx)(`div`,{className:`mb-5`,children:(0,Q.jsx)(M,{tone:`warning`,title:n(`clients.claudeDirect.gatewayOnTitle`),children:n(`clients.claudeDirect.gatewayOnDetail`)})}),o.data&&(0,Q.jsx)(N,{title:n(`clients.claudeDirect.accountsTitle`),footer:n(`clients.claudeDirect.accountsFooter`),children:p.length===0?(0,Q.jsx)(C,{title:n(`clients.claudeDirect.noAccount`),detail:n(`clients.claudeDirect.noAccountDetail`),action:(0,Q.jsx)(j,{variant:`primary`,onClick:()=>a(`/providers`),children:n(`clients.claudeDirect.goProviders`)})}):(0,Q.jsx)(D,{label:n(`clients.claudeDirect.account`),children:(0,Q.jsx)(B,{className:`max-w-[300px]`,ariaLabel:n(`clients.claudeDirect.account`),value:m,onChange:e=>{x||e===m||S({mode:d,accountId:e})},options:p.map(e=>({value:e.id,label:Ue(e,n(`clients.claudeDirect.accountDisabledSuffix`,{status:n(`providers.subscription.status.${e.status}`)})),disabled:!He(e)}))})})}),o.data&&g&&h&&(0,Q.jsx)(N,{title:n(`clients.claudeDirect.launchTitle`),footer:n(`clients.claudeDirect.launchNote`),children:(0,Q.jsx)(Ge,{command:Be,copied:l,onCopy:async e=>{await R.copy(e)&&(u(e),i(n(`common.copied`)))}})}),o.data&&g&&h&&(0,Q.jsxs)(N,{title:n(`clients.claudeDirect.statsTitle`),footer:n(`clients.claudeDirect.statsFooter`),children:[(0,Q.jsx)(D,{label:n(`clients.claudeDirect.statsConsent`),detail:n(`clients.claudeDirect.statsConsentDetail`),children:(0,Q.jsx)(I,{label:n(`clients.claudeDirect.statsConsent`),checked:h.telemetryEnabled,disabled:x,onChange:e=>{h&&!x&&S({mode:d,accountId:h.id,telemetryEnabled:e})}})}),v&&(0,Q.jsx)(Ke,{requests:y})]})]})}function Ge({command:e,copied:t,onCopy:n}){let{t:r}=w();return(0,Q.jsx)(D,{label:(0,Q.jsx)(`span`,{className:`font-mono text-[12px] break-all selectable`,children:e}),children:(0,Q.jsx)(j,{size:`sm`,icon:(0,Q.jsx)(ne,{className:`size-3`}),variant:t===e?`primary`:`glass`,"aria-label":r(`common.copy`),title:r(`common.copy`),onClick:()=>void n(e),children:r(t===e?`common.copied`:`common.copy`)})})}function Ke({requests:e}){let{t,locale:r}=w(),a=e.data??[],o=Ve(a);return e.isLoading?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(P,{lines:3})}):e.isError?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(M,{tone:`danger`,title:t(`clients.claudeDirect.statsFailed`),children:L(e.error)})}):a.length===0?(0,Q.jsx)(C,{icon:(0,Q.jsx)(ke,{className:`size-6`}),title:t(`clients.claudeDirect.statsEmpty`),detail:t(`clients.claudeDirect.statsEmptyDetail`)}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(D,{label:t(`clients.claudeDirect.statsTotals`,{count:_(o.requests)}),detail:t(`clients.claudeDirect.statsInDetail`,{input:_(o.totalInputTokens),cache:_(a.reduce((e,t)=>e+t.cacheReadTokens,0)),output:_(o.outputTokens)})}),(0,Q.jsx)(D,{label:t(`clients.claudeDirect.statsCost`),detail:t(`clients.claudeDirect.statsCostDetail`),children:(0,Q.jsx)(`span`,{className:`num text-[13px]`,children:s(a.some(e=>e.estimatedCostNanoUsd!=null)?o.estimatedCostNanoUsd:null)})}),o.failed>0&&(0,Q.jsx)(D,{label:t(`clients.claudeDirect.statsFailedCount`,{count:_(o.failed)}),children:(0,Q.jsx)(k,{tone:`red`,children:t(`clients.claudeDirect.statusError`)})}),a.map(e=>(0,Q.jsx)(D,{label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.model}),e.status===`error`?(0,Q.jsx)(k,{tone:`red`,children:t(`clients.claudeDirect.statusError`)}):(0,Q.jsx)(k,{tone:`green`,children:t(`status.success`)})]}),detail:(0,Q.jsx)(`span`,{className:`num`,children:[i(e.occurredAtUtc,r),t(`clients.claudeDirect.tokensDetail`,{input:_(e.inputTokens),output:_(e.outputTokens)}),e.durationMs==null?null:n(e.durationMs),e.accountUuid??null].filter(Boolean).join(` · `)}),children:(0,Q.jsx)(`span`,{className:`num text-[13px]`,children:s(e.estimatedCostNanoUsd)})},e.id))]})}function qe({descriptors:e,values:t,onChange:n,enabled:r}){let{t:i}=w(),a=(e,r)=>{let i={...t};r===void 0||r===!1||r===0||r==="default"||r===``?delete i[e]:i[e]=r,n(i)};return(0,Q.jsx)(N,{title:i(`clients.options.title`),footer:i(r?`clients.options.footerEnabled`:`clients.options.footer`),children:e.map(e=>{let n=i(`clients.option.${e.key}`),r=i(`clients.option.${e.key}.hint`),o=t[e.key];return(0,Q.jsxs)(D,{label:n,detail:r,children:[e.type===`bool`&&(0,Q.jsx)(I,{label:n,checked:o===!0,onChange:t=>a(e.key,t)}),e.type===`int`&&(0,Q.jsx)(T,{className:`w-36`,mono:!0,inputMode:`numeric`,"aria-label":n,placeholder:i(`clients.options.unset`),value:typeof o==`number`?String(o):``,onChange:t=>{let n=Number.parseInt(t.target.value.replace(/\D/g,``),10);a(e.key,Number.isFinite(n)?n:void 0)}}),e.type===`enum`&&(0,Q.jsx)(B,{ariaLabel:n,value:typeof o==`string`?o:`default`,onChange:t=>a(e.key,t),options:(e.choices??[]).map(e=>({value:e,label:i(`clients.optionChoice.${e}`)})),className:`w-36`})]},e.key)})})}var Je=[`openai-chat`,`openai-responses`,`anthropic`,`gemini`],Ye=e=>typeof e==`string`&&Je.includes(e);function Xe(e){let t=e?.protocolOverrides,n={};if(!t||typeof t!=`object`)return n;for(let[e,r]of Object.entries(t))Ye(r)&&(n[e]=r);return n}function Ze(e){let t=e?.models;if(!t||typeof t!=`object`)return[];let n=[];for(let e of Object.values(t)){if(!e||typeof e!=`object`)continue;let t=e;typeof t.id==`string`&&t.id&&!n.some(e=>e.id===t.id)&&n.push({id:t.id,name:typeof t.name==`string`&&t.name?t.name:t.id,native:Array.isArray(t.protocols)?t.protocols.filter(Ye):[]})}return n}function Qe(e,t){let n=e.native.find(e=>t.includes(e));return n?{protocol:n,translated:!1}:{protocol:t[0],translated:!0}}var $e=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
2
2
  `),et=`auto`,tt=e=>V.find(t=>t.value===e)?.label??e;function nt({models:e,supported:t,values:n,onChange:r,enabled:i}){let{t:a}=w(),o=(e,t)=>{let i={...n};t===et?delete i[e]:i[e]=t,r(i)};return(0,Q.jsx)(N,{title:a(`clients.protocols.title`),footer:a(i?`clients.protocols.footerEnabled`:`clients.protocols.footer`),children:e.map(e=>{let r=Qe(e,t),i=e.native.filter(e=>t.includes(e));return(0,Q.jsx)(D,{label:e.name,detail:i.length>0?a(`clients.protocols.native`,{protocols:i.map(tt).join(` · `)}):a(`clients.protocols.noNative`),children:(0,Q.jsx)(B,{ariaLabel:e.name,className:`w-60`,value:n[e.id]&&t.includes(n[e.id])?n[e.id]:et,onChange:t=>o(e.id,t),options:[{value:et,label:a(r.translated?`clients.protocols.autoTranslated`:`clients.protocols.auto`,{protocol:tt(r.protocol)})},...t.map(e=>({value:e,label:tt(e)}))]})},e.id)})})}function rt(e,t){let n=e?.options,r={};if(!n||typeof n!=`object`)return r;for(let e of t??[]){let t=n[e.key];e.type===`bool`&&t===!0?r[e.key]=!0:(e.type===`int`&&typeof t==`number`&&t>0||e.type===`enum`&&typeof t==`string`&&t!=="default"&&e.choices?.includes(t))&&(r[e.key]=t)}return r}var it=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
3
3
  `),at=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`];function ot(e){let t=e?.models,n={};if(!t||typeof t!=`object`)return n;for(let e of at){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var st=e=>at.map(t=>e[t]??``).join(`
4
4
  `),ct=[`sonnet`,`opus`,`haiku`];function lt(e){let t=e?.roleMap,n={};if(!t||typeof t!=`object`)return n;for(let e of ct){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var $=e=>ct.map(t=>e[t]??``).join(`
5
- `),ut=/(^|[-_.:/\s])(haiku|flash|mini|lite|nano|small|fast|air)($|[-_.:/\s])/i;function dt(e){if(e.length===0)return{};let t=t=>e.find(e=>e.toLowerCase().includes(t)),n=e.find(e=>!ut.test(e))??e[0],r=e.find(e=>ut.test(e))??n;return{sonnet:t(`sonnet`)??n,opus:t(`opus`)??t(`sonnet`)??n,haiku:t(`haiku`)??r}}function ft(){let{t:e}=w(),t=De(),{toast:n}=z(),r=we(),i=y(),a=h(),o=(0,Z.useMemo)(()=>new Map((i.data??[]).map(e=>[e.kind,e])),[i.data]),s=mt(i.data).includes(r.kind)?r.kind:`codex`,c=o.get(s);return(0,Z.useEffect)(()=>a.mutate(!1),[]),(0,Q.jsx)(Me,{title:e(`nav.clients`),subtitle:e(`clients.subtitle`),actions:(0,Q.jsx)(j,{icon:(0,Q.jsx)(Oe,{className:`size-3.5`}),loading:a.isPending,onClick:()=>a.mutate(!0,{onSuccess:t=>{let r=t.filter(e=>e.install?.updateAvailable&&e.install.blocker!==`shadowed`).length;n(r>0?e(`clients.updatesFound`,{count:r}):e(`clients.allUpToDate`),r>0?void 0:`success`)},onError:e=>n(L(e),`error`)}),children:e(`clients.checkUpdates`)}),children:(0,Q.jsx)(`div`,{className:`@container mx-auto max-w-[1200px]`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-start @3xl:gap-5`,children:[(0,Q.jsx)(vt,{clients:i.data,loading:i.isLoading,selected:s,onSelect:e=>t(`/clients/${e}`,{replace:!0})}),(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-[760px] min-w-0 flex-1`,children:[i.isLoading&&(0,Q.jsx)(P,{lines:4}),i.isError&&(0,Q.jsx)(M,{tone:`danger`,title:e(`common.error`),children:L(i.error)}),c&&(0,Q.jsx)(St,{client:c})]})]})})})}var pt=new Set([`opencode`,`pi`,`minimax-code`,`copilot-cli`,`vscode-copilot`,`crush`,`qwen-code`,`droid`,`kimi-code`,`zed`,`vscode-insiders`,`vscodium`,`omp`,`mimo-code`,`deepseek-harness`,`workbuddy`,`workbuddy-ai`,`nextcowork`,`paseo`,`zcode`,`tkcode`,`muse-code`,`codex`,`grok-build`,`hermes-agent`]);function mt(e){let t=(e??[]).filter(e=>!Y.includes(e.kind)).sort((e,t)=>e.name.localeCompare(t.name));return[...Y,...t.map(e=>e.kind)]}var ht=[`installed`,`notInstalled`,`comingSoon`];function gt(e){return e.availability===`coming_soon`?`comingSoon`:e.detection.installed||e.enabled||e.install?.installed?`installed`:`notInstalled`}function _t(e){return e.install?.version??e.detection.version??null}function vt({clients:e,loading:t,selected:n,onSelect:r}){let{t:i}=w(),a=new Map((e??[]).map(e=>[e.kind,e])),o=ht.map(t=>({group:t,items:mt(e).flatMap(e=>{let n=a.get(e);return n&&gt(n)===t?[n]:[]})})).filter(e=>e.items.length>0);return(0,Q.jsxs)(`nav`,{"aria-label":i(`nav.clients`),className:`card shrink-0 p-1.5 @3xl:sticky @3xl:top-0 @3xl:w-[232px]`,children:[t&&(0,Q.jsx)(P,{lines:6,className:`p-2`}),(0,Q.jsx)(`div`,{className:`flex gap-1 overflow-x-auto @3xl:flex-col @3xl:gap-0 @3xl:overflow-visible`,children:o.map(({group:e,items:t})=>(0,Q.jsxs)(`div`,{className:`contents @3xl:block`,children:[(0,Q.jsxs)(`h3`,{className:`hidden px-2.5 pt-2 pb-1 text-[11px] font-medium text-[var(--text-muted)] @3xl:block`,children:[i(`clients.group.${e}`),` · `,t.length]}),t.map(e=>(0,Q.jsx)(yt,{client:e,active:e.kind===n,onSelect:()=>r(e.kind)},e.kind))]},e))})]})}function yt({client:e,active:t,onSelect:n}){let{t:r}=w(),i=gt(e)!==`installed`,a=_t(e),o=e.install?.blocker===`shadowed`,s=e.install?.updateAvailable&&!o?e.install.latestVersion:null;return(0,Q.jsxs)(`button`,{type:`button`,"aria-label":J(e.kind,e.name),"aria-current":t?`page`:void 0,onClick:n,className:A(`flex shrink-0 items-center gap-2.5 rounded-[var(--radius-control)] px-2.5 py-1.5 text-left transition-colors @3xl:w-full`,t?`bg-[var(--accent-subtle)]`:`hover:bg-[var(--surface-muted)]`),children:[(0,Q.jsx)(`span`,{className:A(`inline-flex`,i&&!t&&`opacity-60`),children:(0,Q.jsx)(je,{kind:e.kind,size:24})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:A(`block truncate text-[13px] whitespace-nowrap`,t&&`font-medium`),children:J(e.kind,e.name)}),a&&(0,Q.jsxs)(`span`,{className:`hidden truncate text-[11px] text-[var(--text-secondary)] @3xl:block`,children:[a,s&&(0,Q.jsxs)(`span`,{className:`text-[var(--warning)]`,children:[` → `,s]})]})]}),e.install?.busy&&(0,Q.jsx)(bt,{}),s&&!e.install?.busy&&(0,Q.jsx)(k,{tone:`orange`,title:r(`clients.updateTo`,{version:s}),children:r(`clients.updateBadge`)}),o&&!e.install?.busy&&(0,Q.jsx)(k,{tone:`orange`,title:r(`clients.shadowed.title`,{version:e.install?.latestVersion??``}),children:r(`clients.shadowedBadge`)}),e.status===`drifted`?(0,Q.jsx)(`span`,{title:r(`clients.drifted`),"aria-label":r(`clients.drifted`),className:`inline-flex`,children:(0,Q.jsx)(ce,{tone:`orange`})}):e.enabled?(0,Q.jsx)(S,{className:`size-3.5 shrink-0 text-[var(--success)]`,strokeWidth:2.5,"aria-label":r(`clients.enabled`)}):null]})}function bt(){return(0,Q.jsx)(Te,{className:`size-3.5 shrink-0 animate-spin text-[var(--text-secondary)] motion-reduce:animate-none`,"aria-hidden":!0})}function xt(e,t){return e.availability===`coming_soon`?(0,Q.jsx)(k,{children:t(`clients.comingSoon`)}):e.status===`drifted`?(0,Q.jsx)(k,{tone:`orange`,children:t(`clients.drifted`)}):e.enabled?(0,Q.jsx)(k,{tone:`green`,children:t(`clients.enabled`)}):(0,Q.jsx)(k,{children:t(`clients.disabled`)})}function St({client:e}){let{t,locale:i}=w(),o=De(),{toast:s,confirm:c}=z(),l=oe(),u=ie(),d=te(),f=x(),p=re(),m=E(),h=a(e.kind,!!e.providerId),[g,_]=(0,Z.useState)(e.selectedModel??null),[v,y]=(0,Z.useState)(e.accountId??``),b=e.tokenId??`default`,[S,C]=(0,Z.useState)(b),T=(m.data??[]).filter(e=>e.enabled||e.id===b).map(e=>({value:e.id,label:e.enabled?e.name:t(`clients.tokenDisabled`,{name:e.name}),disabled:!e.enabled})),[ee,O]=(0,Z.useState)(!1),[A,se]=(0,Z.useState)(!1),[ce,le]=(0,Z.useState)(null),F=e.availability===`coming_soon`,I=J(e.kind,e.name),de=(l.data??[]).filter(e=>e.enabled),V=e.detection.configPaths[0],fe=de.find(t=>t.id===e.providerId),pe=fe?.authScheme===`oauth-subscription`||fe?.authScheme===`plugin`,he=ae(fe?.id,pe),H=e.kind===`claude-desktop`,U=e.kind===`claude-code`,ge=n(U),W=U&&ge.data?.mode===`direct`,G=lt(e.extras),[_e,ve]=(0,Z.useState)(G),K=ct.some(e=>_e[e]),ye=$(_e)!==$(G),be=ot(e.extras),[xe,Se]=(0,Z.useState)(be),Ce=(g??null)!==(e.selectedModel??null)||st(xe)!==st(be),we=U?at.filter(e=>e!==`ANTHROPIC_MODEL`):[],Te=U?e.enabled?t(`clients.modelSlotsFooterEnabled`):t(`clients.modelSlotsFooter`):e.enabled?t(`clients.modelFooterEnabled`):t(`clients.modelFooter`),q=e.options??[],Ee=rt(e.extras,q),[Oe,Ae]=(0,Z.useState)(Ee),Me=it(Oe)!==it(Ee),Y=e.protocols??[],Ne=Y.length>1?Ze(e.extras):[],Pe=Xe(e.extras),[Fe,Le]=(0,Z.useState)(Pe),Re=$e(Fe)!==$e(Pe),ze=H?{...e.extras,roleMap:_e}:U?{...e.extras,models:xe,options:Oe}:q.length>0||Y.length>1?{...e.extras,...q.length>0?{options:Oe}:{},...Y.length>1?{protocolOverrides:Fe}:{}}:void 0;(0,Z.useEffect)(()=>_(e.selectedModel??null),[e.kind,e.selectedModel]),(0,Z.useEffect)(()=>y(e.accountId??``),[e.kind,e.providerId,e.accountId]),(0,Z.useEffect)(()=>C(b),[e.kind,b]),(0,Z.useEffect)(()=>ve(lt(e.extras)),[e.kind,$(G)]);let X=(0,Z.useRef)({});(0,Z.useEffect)(()=>{if(!H||e.enabled||ct.some(e=>G[e]))return;let t=X.current,n=dt(h.data??[]);X.current=n,ve(e=>(!ct.some(t=>e[t])||$(e)===$(t))&&$(e)!==$(n)?n:e)},[e.kind,e.enabled,$(G),(h.data??[]).join(`
6
- `)]),(0,Z.useEffect)(()=>Se(ot(e.extras)),[e.kind,st(be)]),(0,Z.useEffect)(()=>Ae(rt(e.extras,e.options)),[e.kind,it(Ee)]),(0,Z.useEffect)(()=>Le(Xe(e.extras)),[e.kind,$e(Pe)]);let Be=()=>{e.providerId&&u.mutate({kind:e.kind,providerId:e.providerId,accountId:v},{onSuccess:()=>s(t(`common.saved`),`success`),onError:e=>s(L(e),`error`)})},Ve=async()=>{await c({title:t(`clients.disableConfirm`,{name:I}),detail:t(`clients.disableDetail`),confirmLabel:t(`clients.disable`)})&&d.mutate(e.kind,{onSuccess:async n=>{if(n.drifted.length===0){s(t(`clients.disabledToast`,{name:I}),`success`);return}await c({title:t(`clients.driftTitle`),detail:t(`clients.driftDetail`,{keys:n.drifted.join(`, `)}),confirmLabel:t(`clients.forceRestore`),destructive:!0})&&f.mutate(e.kind,{onSuccess:()=>s(t(`clients.disabledToast`,{name:I}),`success`),onError:e=>s(L(e),`error`)})},onError:e=>s(L(e),`error`)})},He=async()=>{V&&(R.canOpenPaths?await R.openPath(ue(V)):await R.copy(V)&&s(t(`common.copied`)))};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(D,{icon:(0,Q.jsx)(je,{kind:e.kind,size:36}),label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[15px] font-medium`,children:I}),W?(0,Q.jsx)(k,{children:t(`clients.claudeDirect.direct`)}):xt(e,t)]}),detail:F?e.availabilityReason??t(`clients.comingSoonDetail`):[gt(e)===`installed`?t(`clients.detected`,{version:_t(e)??``}):t(`clients.notDetected`),W?null:V].filter(Boolean).join(` · `),className:`py-3`,children:[!F&&(0,Q.jsx)(Ot,{client:e,onOpen:le}),W?(0,Q.jsx)(j,{variant:`primary`,onClick:()=>document.getElementById(At)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:t(`clients.claudeDirect.configure`)}):e.enabled?(0,Q.jsx)(j,{onClick:()=>void Ve(),loading:d.isPending,children:t(`clients.disableRestore`)}):(0,Q.jsx)(j,{variant:`primary`,disabled:F||!e.providerId||H&&!K,onClick:()=>O(!0),title:e.providerId?H&&!K?t(`clients.roleMapRequired`):void 0:t(`clients.pickProviderFirst`),children:t(`clients.enable`)})]}),!W&&e.appliedAt&&(0,Q.jsx)(D,{label:(0,Q.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`clients.appliedAt`,{time:r(e.appliedAt,i)})})})]}),!F&&!e.enabled&&H&&e.providerId&&!K&&(0,Q.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Q.jsx)(M,{tone:`info`,className:`self-stretch`,title:t(`clients.roleMapHint`)}),(0,Q.jsx)(j,{onClick:()=>document.getElementById(jt)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:t(`clients.roleMapGoto`)})]}),(e.repairs?.length??0)>0&&(0,Q.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Q.jsxs)(M,{tone:`danger`,className:`self-stretch`,title:t(`clients.repair.title`,{name:I}),children:[e.repairs?.map(e=>(0,Q.jsxs)(`span`,{className:`block break-all`,children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.file}),` — `,t(`clients.repair.problem.${e.problem}`,{line:e.line})]},e.file)),(0,Q.jsx)(`span`,{className:`block`,children:t(`clients.repair.hint`)})]}),(0,Q.jsx)(j,{variant:`primary`,loading:p.isPending,onClick:()=>p.mutate(e.kind,{onSuccess:()=>s(t(`clients.repair.done`,{name:I}),`success`),onError:e=>s(L(e),`error`)}),children:t(`clients.repair.action`)})]}),!W&&e.warnings.length>0&&(0,Q.jsx)(`div`,{className:`mb-5 flex flex-col gap-2`,children:e.warnings.map((e,t)=>(0,Q.jsx)(M,{tone:`warning`,title:e},t))}),!W&&(0,Q.jsx)(Et,{client:e,providers:l.data??[],loading:l.isLoading,soon:F}),!W&&pe&&(0,Q.jsx)(N,{title:t(`clients.accountTitle`),footer:t(`clients.accountFooter`),children:he.isLoading?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(P,{lines:2})}):(0,Q.jsxs)(D,{label:t(`clients.account`),children:[(0,Q.jsx)(B,{className:`max-w-[300px]`,ariaLabel:t(`clients.account`),value:v,onChange:y,options:[{value:``,label:t(`clients.accountDefault`)},...(he.data??[]).map(e=>({value:e.id,label:(e.displayName||e.id)+(e.status===`active`?``:` · ${t(`providers.subscription.status.${e.status}`)}`)}))]}),v!==(e.accountId??``)&&(0,Q.jsx)(j,{size:`sm`,variant:`primary`,loading:u.isPending,onClick:Be,children:t(`common.apply`)})]})}),!F&&!W&&(0,Q.jsxs)(N,{title:t(`clients.tokenTitle`),footer:e.enabled?t(`clients.tokenFooterEnabled`):t(`clients.tokenFooter`),children:[(0,Q.jsxs)(D,{label:t(`clients.token`),children:[(0,Q.jsx)(B,{className:`max-w-[300px]`,ariaLabel:t(`clients.token`),value:S,onChange:C,options:T}),e.enabled&&S!==b&&(0,Q.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>O(!0),children:t(`common.apply`)})]}),(0,Q.jsx)(D,{icon:(0,Q.jsx)(ke,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.manageTokens`),onClick:()=>o(`/tokens`)})]}),!F&&!W&&e.providerId&&H&&(0,Q.jsx)(`div`,{id:jt,children:(0,Q.jsxs)(N,{title:t(`clients.roleMapTitle`),footer:e.enabled?t(`clients.roleMapFooterEnabled`):t(`clients.roleMapFooter`),children:[ct.map(e=>(0,Q.jsx)(D,{label:t(`clients.role.${e}`),children:(0,Q.jsx)(B,{ariaLabel:t(`clients.role.${e}`),value:_e[e]??``,onChange:t=>ve(n=>({...n,[e]:t||void 0})),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(h.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&ye&&(0,Q.jsx)(D,{label:K?``:(0,Q.jsx)(`span`,{className:`text-[12px] text-[var(--warning)]`,children:t(`clients.roleMapRequired`)}),children:(0,Q.jsx)(j,{size:`sm`,variant:`primary`,disabled:!K,onClick:()=>O(!0),children:t(`common.apply`)})})]})}),!F&&!W&&e.providerId&&!H&&(0,Q.jsxs)(N,{title:t(`clients.modelTitle`),footer:Te,children:[(0,Q.jsx)(D,{label:t(`clients.defaultModel`),children:(0,Q.jsx)(B,{value:g??``,onChange:e=>_(e||null),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(h.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})}),we.map(e=>(0,Q.jsx)(D,{label:t(`clients.modelSlot.${e}`),children:(0,Q.jsx)(B,{ariaLabel:t(`clients.modelSlot.${e}`),value:xe[e]??``,onChange:t=>Se(n=>({...n,[e]:t||void 0})),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(h.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&(U?Ce:(g??null)!==(e.selectedModel??null))&&(0,Q.jsx)(D,{label:``,children:(0,Q.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>O(!0),children:t(`common.apply`)})})]}),!F&&!W&&q.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qe,{descriptors:q,values:Oe,onChange:Ae,enabled:e.enabled}),e.enabled&&Me&&(0,Q.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Q.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>O(!0),children:t(`common.apply`)})})]}),!F&&Ne.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(nt,{models:Ne,supported:Y,values:Fe,onChange:Le,enabled:e.enabled}),e.enabled&&Re&&(0,Q.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Q.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>O(!0),children:t(`common.apply`)})})]}),!F&&e.install&&(0,Q.jsx)(Nt,{client:e,onShowLog:()=>le(`log`),onUninstall:()=>le(`uninstall`)}),U&&(0,Q.jsx)(`div`,{id:At,children:(0,Q.jsx)(We,{enabled:U,gatewayEnabled:e.enabled})}),!F&&!W&&(0,Q.jsxs)(N,{title:t(`clients.maintenance`),children:[V&&(0,Q.jsx)(D,{icon:R.canOpenPaths?(0,Q.jsx)(me,{className:`size-4 text-[var(--text-secondary)]`}):(0,Q.jsx)(ne,{className:`size-4 text-[var(--text-secondary)]`}),label:R.canOpenPaths?t(`clients.openConfigDir`):t(`clients.copyConfigPath`),detail:V,onClick:()=>void He()}),(0,Q.jsx)(D,{icon:(0,Q.jsx)(Ie,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.backups`),detail:t(`clients.backupsDetail`),onClick:()=>se(!0)})]}),(0,Q.jsx)(Ft,{open:ee,onOpenChange:O,client:e,model:g,extras:ze,tokenId:S}),(0,Q.jsx)(Rt,{open:A,onOpenChange:se,client:e}),(0,Q.jsx)(Pt,{mode:ce,onClose:()=>le(null),client:e})]})}var Ct={install:`clients.installTitle`,update:`clients.updateTitle`,uninstall:`clients.uninstallTitle`},wt={install:`clients.installedToast`,update:`clients.updatedToast`,uninstall:`clients.uninstalledToast`};function Tt(e,t){return[e.priceKey??e.templateId,t(`providers.modelCount`,{count:e.modelCount}),e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `)}function Et({client:e,providers:t,loading:n,soon:r}){let{t:i}=w(),{toast:a}=z(),o=d(),s=(0,Z.useMemo)(()=>e.bindings??(e.providerId?[{providerId:e.providerId,accountId:e.accountId}]:[]),[e.bindings,e.providerId,e.accountId]),[c,l]=(0,Z.useState)(s);(0,Z.useEffect)(()=>l(s),[s]);let u=(0,Z.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]),f=c.flatMap(e=>{let t=u.get(e.providerId);return t?[{binding:e,provider:t}]:[]}),p=t.filter(e=>e.enabled&&!c.some(t=>t.providerId===e.id)),m=U(Se(H,{activationConstraint:{distance:4}}),Se(be,{coordinateGetter:ye})),h=r||o.isPending,g=(t,n)=>{let r=c;l(t),o.mutate({kind:e.kind,bindings:t},{onSuccess:()=>a(pt.has(e.kind)&&e.enabled?i(`clients.providersModelsSynced`,{client:J(e.kind,e.name)}):n),onError:e=>{l(r),a(L(e),`error`)}})},_=({active:e,over:t})=>{if(!t||e.id===t.id)return;let n=c.findIndex(t=>t.providerId===e.id),r=c.findIndex(e=>e.providerId===t.id);n<0||r<0||g(_e(c,n,r),i(`clients.providerOrderSaved`))},v=e=>g([...c,{providerId:e.id}],i(`clients.providerAdded`,{provider:e.name})),y=e=>g(c.filter(t=>t.providerId!==e.id),i(`clients.providerRemoved`,{provider:e.name})),b=p.map(e=>(0,Q.jsx)(D,{icon:(0,Q.jsx)(Ne,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24}),label:e.name,detail:Tt(e,i),onClick:h?void 0:()=>v(e),children:!r&&(0,Q.jsx)(Pe,{className:`size-4 text-[var(--text-secondary)]`,"aria-label":i(`common.add`)})},e.id));return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(N,{title:i(`clients.providerTitle`),footer:i(`clients.providerFooter`),children:[n&&(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(P,{lines:2})}),!n&&f.length===0&&p.length===0&&(0,Q.jsx)(C,{title:i(`clients.noProviders`),detail:i(`clients.noProvidersDetail`),action:(0,Q.jsx)(Ae,{to:`/providers?new=1`,children:(0,Q.jsx)(j,{variant:`primary`,icon:(0,Q.jsx)(Pe,{className:`size-3.5`}),children:i(`providers.add`)})})}),f.length>0&&(0,Q.jsx)(ve,{sensors:m,collisionDetection:G,onDragEnd:_,children:(0,Q.jsx)(xe,{items:f.map(e=>e.provider.id),strategy:he,children:f.map(({provider:e},t)=>(0,Q.jsx)(Dt,{provider:e,primary:t===0,disabled:h,onRemove:f.length>1?()=>y(e):void 0},e.id))})}),!n&&f.length===0&&b]}),f.length>0&&p.length>0&&(0,Q.jsx)(N,{title:i(`clients.moreProvidersTitle`),children:b})]})}function Dt({provider:e,primary:t,disabled:n,onRemove:r}){let{t:i}=w(),{attributes:a,listeners:o,setNodeRef:s,setActivatorNodeRef:c,transform:l,transition:u,isDragging:d}=W({id:e.id,disabled:n});return(0,Q.jsx)(`div`,{ref:s,style:{transform:ge.Transform.toString(l),transition:u},className:A(d&&`relative z-10 bg-[var(--surface)] shadow-lg`),children:(0,Q.jsx)(D,{icon:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{ref:c,type:`button`,"aria-label":i(`clients.dragToReorder`,{provider:e.name}),title:i(`clients.dragToReorder`,{provider:e.name}),className:`-ml-1 inline-flex cursor-grab touch-none text-[var(--text-muted)] hover:text-[var(--text-secondary)] active:cursor-grabbing disabled:cursor-default disabled:opacity-50`,...a,...o,children:(0,Q.jsx)(K,{className:`size-4`})}),(0,Q.jsx)(Ne,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24})]}),label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),t&&(0,Q.jsx)(k,{tone:`accent`,children:i(`clients.primaryProvider`)}),!e.enabled&&(0,Q.jsx)(k,{tone:`orange`,children:i(`clients.providerDisabledBadge`)})]}),detail:Tt(e,i),children:r&&(0,Q.jsx)(j,{size:`sm`,variant:`plain`,icon:(0,Q.jsx)(ee,{className:`size-3.5`}),"aria-label":i(`clients.removeProvider`,{provider:e.name}),title:i(`clients.removeProvider`,{provider:e.name}),disabled:n,onClick:r})})})}function Ot({client:e,onOpen:t}){let{t:n}=w(),r=e.install;if(!r)return null;let i=r.needsAdmin?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-[var(--warning)]`,children:[(0,Q.jsx)(X,{className:`size-3`,"aria-hidden":!0}),n(`clients.admin.badge`)]}):null,a=r.needsAdmin?n(r.adminAvailable?`clients.admin.tip`:`clients.admin.tipManual`):void 0;return r.busy?(0,Q.jsx)(j,{icon:(0,Q.jsx)(bt,{}),onClick:()=>t(`log`),children:n(`clients.installRunning`)}):r.updateAvailable&&r.updateCommand&&r.latestVersion?(0,Q.jsxs)(j,{icon:(0,Q.jsx)(Re,{className:`size-3.5`}),title:a,onClick:()=>t(`update`),children:[n(`clients.updateTo`,{version:r.latestVersion}),i]}):r.updateAvailable&&r.blocker===`shadowed`?(0,Q.jsx)(j,{icon:(0,Q.jsx)(X,{className:`size-3.5`}),onClick:()=>document.getElementById(kt)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:n(`clients.shadowedBadge`)}):!r.installed&&r.installCommand?(0,Q.jsxs)(j,{icon:(0,Q.jsx)(fe,{className:`size-3.5`}),title:a,onClick:()=>t(`install`),children:[n(`clients.install`),i]}):!r.installed&&r.method===`manual`?(0,Q.jsx)(j,{icon:(0,Q.jsx)(pe,{className:`size-3.5`}),onClick:()=>window.open(r.homepageUrl,`_blank`,`noreferrer`),children:n(`clients.download`)}):null}var kt=`client-shadowed-alert`,At=`claude-direct-panel`,jt=`client-role-map`;function Mt(e,t){return!e.installed||e.uninstallCommand?null:e.method===`npm`?t(`clients.uninstallExternal`,{path:e.executable??``}):e.method===`vscode-extension`?t(`clients.uninstallBuiltIn`):t(`clients.uninstallManual`)}function Nt({client:e,onShowLog:t,onUninstall:n}){let{t:i,locale:a}=w(),o=e.install,s=se(e.kind),c=(e,t=!1)=>(0,Q.jsx)(`span`,{className:A(`text-[13px] tabular-nums selectable`,t&&`text-[var(--text-secondary)]`),children:e}),l=o.blocker===`external-install`?i(`clients.blocker.external-install`,{path:o.executable??``}):o.blocker?i(`clients.blocker.${o.blocker}`):void 0,u=o.otherCopies??[],d=u.find(e=>e.newer);return(0,Q.jsxs)(Q.Fragment,{children:[d&&(0,Q.jsx)(`div`,{id:kt,className:`mb-3`,children:(0,Q.jsx)(M,{tone:`warning`,title:i(`clients.shadowed.title`,{version:d.version}),children:i(`clients.shadowed.detail`,{path:o.executable??``,version:o.version??``,other:d.path,dir:ue(d.path)})})}),!d&&o.notOnPath&&o.executable&&(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(M,{tone:`warning`,title:i(`clients.notOnPath.title`),children:i(`clients.notOnPath.detail`,{dir:ue(o.executable)})})}),(0,Q.jsxs)(N,{title:i(`clients.versionTitle`),footer:l,children:[(0,Q.jsx)(D,{label:i(`clients.currentVersion`),detail:o.installed?o.executable:void 0,children:o.installed?c(o.version??i(`clients.versionUnknown`),!o.version):c(i(`clients.notInstalled`),!0)}),u.map(e=>(0,Q.jsxs)(D,{label:i(`clients.otherCopy`),detail:e.path,children:[e.newer&&(0,Q.jsx)(k,{tone:`orange`,children:i(`clients.otherCopyNewer`)}),c(e.version,!e.newer)]},e.path)),(o.method===`npm`||o.method===`script`)&&(0,Q.jsxs)(D,{label:i(`clients.latestVersion`),detail:o.latestError??(o.latestCheckedAt?i(`clients.checkedAt`,{time:r(o.latestCheckedAt,a)}):void 0),children:[o.updateAvailable&&(0,Q.jsx)(k,{tone:`orange`,children:i(`clients.updateBadge`)}),c(o.latestVersion??i(`clients.latestUnknown`),!o.latestVersion)]}),(0,Q.jsx)(D,{label:i(`clients.installMethod`),detail:i(`clients.method.${o.method}`,{package:o.package??``}),children:(0,Q.jsx)(j,{size:`sm`,variant:`plain`,icon:(0,Q.jsx)(pe,{className:`size-3`}),onClick:()=>window.open(o.homepageUrl,`_blank`,`noreferrer`),children:i(`clients.homepage`)})}),o.installed&&(0,Q.jsx)(D,{label:i(`clients.uninstall`),detail:o.uninstallCommand??Mt(o,i),children:o.uninstallCommand&&(0,Q.jsx)(j,{size:`sm`,variant:`destructive`,icon:(0,Q.jsx)(Ee,{className:`size-3`}),disabled:o.busy,onClick:n,children:i(`clients.uninstall`)})}),s.data&&(0,Q.jsx)(D,{icon:(0,Q.jsx)(q,{className:`size-4 text-[var(--text-secondary)]`}),label:i(`clients.installLog`),detail:`${s.data.command} · ${i(`clients.job.${s.data.state}`)}`,onClick:t})]})]})}function Pt({mode:t,onClose:n,client:r}){let{t:a}=w(),{toast:o}=z(),s=u(),c=t!==null,d=se(r.kind,c||!!r.install?.busy),f=l(),p=i(),[m,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(null),_=(0,Z.useRef)(void 0),v=J(r.kind,r.name),y=r.install,b=t===`log`?null:t,x=b===`install`?y?.installCommand:b===`update`?y?.updateCommand:b===`uninstall`?y?.uninstallCommand:null,S=b===`uninstall`,T=d.data,ee=b!==null&&!m&&T?.state!==`running`,E=!!y?.needsAdmin,te=!!y?.adminAvailable,re=T?.state===`failed`&&T.hint===`permission-denied`&&!T.elevated&&te;(0,Z.useEffect)(()=>{c&&h(!1)},[c,t]),(0,Z.useEffect)(()=>{let t=T?.state;_.current===`running`&&t&&t!==`running`&&(s.invalidateQueries({queryKey:e.clients}),t===`succeeded`&&T.hint?o(a(`clients.notEffectiveToast`,{name:v})):t===`succeeded`&&o(a(wt[T.action],{name:v}),`success`)),_.current=t},[T?.state,T?.action,T?.hint,v,s,a,o]),(0,Z.useEffect)(()=>{let e=g.current;e&&(e.scrollTop=e.scrollHeight)},[T?.log.length]);let ie=(e,t)=>f.mutate({kind:r.kind,action:e,elevated:t},{onSuccess:()=>h(!0),onError:e=>o(L(e),`error`)}),D=async e=>{await R.copy(e)&&o(a(`common.copied`))},O=a(Ct[b??T?.action??`install`],{name:v}),k={running:`info`,succeeded:`success`,failed:`danger`,cancelled:`warning`},ae=`rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] px-3 py-2 font-mono text-[12px] break-all whitespace-pre-wrap selectable`,oe=y?.adminFixCommand?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] text-[var(--text-secondary)]`,children:a(`clients.admin.fixTip`)}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`pre`,{className:A(ae,`min-w-0 flex-1`),children:y.adminFixCommand}),(0,Q.jsx)(j,{size:`sm`,icon:(0,Q.jsx)(ne,{className:`size-3`}),"aria-label":a(`common.copy`),onClick:()=>void D(y.adminFixCommand)})]})]}):null;return(0,Q.jsx)(de,{open:c,onOpenChange:e=>!e&&n(),width:620,title:O,description:ee?a(S?`clients.uninstallRunDetail`:`clients.installRunDetail`):void 0,footer:ee?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{onClick:n,children:a(`common.cancel`)}),E&&!te?(0,Q.jsx)(j,{variant:`primary`,icon:(0,Q.jsx)(ne,{className:`size-3.5`}),disabled:!x,onClick:()=>void D(`sudo ${x}`),children:a(`clients.admin.copyCommand`)}):(0,Q.jsx)(j,{variant:S?`destructive`:`primary`,icon:E?(0,Q.jsx)(X,{className:`size-3.5`}):void 0,disabled:!x,loading:f.isPending,onClick:()=>b&&ie(b,E),children:a(E?`clients.admin.start`:S?`clients.uninstall`:`clients.installStart`)})]}):T?.state===`running`?(0,Q.jsxs)(Q.Fragment,{children:[!T.elevated&&(0,Q.jsx)(j,{variant:`destructive`,loading:p.isPending,onClick:()=>p.mutate(r.kind,{onError:e=>o(L(e),`error`)}),children:a(`clients.installStop`)}),(0,Q.jsx)(j,{onClick:n,children:a(`common.close`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{onClick:n,children:a(`common.done`)}),re&&(0,Q.jsx)(j,{variant:`primary`,icon:(0,Q.jsx)(X,{className:`size-3.5`}),loading:f.isPending,onClick:()=>ie(T.action,!0),children:a(`clients.admin.retry`)})]}),children:ee?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[S&&r.enabled&&(0,Q.jsx)(M,{tone:`warning`,title:a(`clients.uninstallRestoreTitle`),children:a(`clients.uninstallRestoreDetail`,{name:v})}),E&&(0,Q.jsx)(M,{tone:`warning`,title:a(`clients.admin.title`),children:a(te?`clients.admin.prompt`:`clients.admin.manual`)}),x?(0,Q.jsx)(`pre`,{className:ae,children:E?`sudo ${x}`:x}):(0,Q.jsx)(M,{tone:`warning`,title:a(`clients.installUnavailable`)}),S?(0,Q.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:a(`clients.uninstallKeepsData`)}):y?.method===`npm`&&(0,Q.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:a(`clients.installNpmNote`)}),E&&oe]}):T?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(M,{tone:T.state===`succeeded`&&T.hint?`warning`:k[T.state],title:a(T.state===`succeeded`&&T.hint?`clients.job.notEffective`:`clients.job.${T.state}`),children:T.state===`running`&&T.elevated?a(`clients.admin.running`):T.hint?a(`clients.hint.${T.hint}`)+(re?a(`clients.admin.retryHint`):``):void 0}),(0,Q.jsx)(`pre`,{ref:g,className:`scroll max-h-[340px] min-h-[160px] rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] px-3 py-2 font-mono text-[11px] leading-relaxed break-all whitespace-pre-wrap selectable`,children:T.log.join(`
7
- `)}),T.hint===`permission-denied`&&oe]}):d.isLoading?(0,Q.jsx)(P,{lines:4}):(0,Q.jsx)(C,{icon:(0,Q.jsx)(q,{className:`size-6`}),title:a(`clients.noInstallLog`)})})}function Ft({open:e,onOpenChange:t,client:n,model:r,extras:i,tokenId:a}){let{t:o}=w(),{toast:s}=z(),c=v(),l=O(),u=J(n.kind,n.name),d=i?{providerId:n.providerId,model:r,extras:i,tokenId:a}:{providerId:n.providerId,model:r,tokenId:a};return(0,Z.useEffect)(()=>{e&&c.mutate({kind:n.kind,req:d})},[e]),(0,Q.jsxs)(de,{open:e,onOpenChange:t,width:620,title:o(`clients.enableTitle`,{name:u}),description:o(`clients.enableDetail`),footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{onClick:()=>t(!1),children:o(`common.cancel`)}),(0,Q.jsx)(j,{variant:`primary`,disabled:!c.data,loading:l.isPending,onClick:()=>l.mutate({kind:n.kind,req:d},{onSuccess:e=>{t(!1),s(e.requiresRestart?o(`clients.enabledRestart`,{name:u}):o(`clients.enabledToast`,{name:u}),`success`)},onError:e=>s(L(e),`error`)}),children:n.enabled?o(`common.apply`):o(`clients.enable`)})]}),children:[c.isPending&&(0,Q.jsx)(P,{lines:4}),c.isError&&(0,Q.jsx)(M,{tone:`danger`,title:o(`common.error`),children:L(c.error)}),c.data&&(0,Q.jsx)(It,{preview:c.data})]})}function It({preview:e}){let{t}=w();return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.warnings.map((e,t)=>(0,Q.jsx)(M,{tone:`warning`,title:e},t)),e.changes.length===0&&(0,Q.jsx)(M,{tone:`info`,title:t(`clients.noChanges`)}),e.diffs.map(e=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`mb-2 font-mono text-[11px] text-[var(--text-secondary)]`,children:e.file}),(0,Q.jsx)(Lt,{diff:e.unifiedDiff})]},e.file))]})}function Lt({diff:e}){return(0,Q.jsx)(`pre`,{className:`scroll max-h-[300px] rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] py-2 font-mono text-[11px] leading-relaxed selectable`,children:e.split(`
8
- `).map((e,t)=>(0,Q.jsx)(`div`,{className:A(`px-3 whitespace-pre-wrap break-all`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-[color-mix(in_oklab,var(--success)_12%,transparent)] text-[var(--success)]`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-[color-mix(in_oklab,var(--danger)_10%,transparent)] text-[var(--danger)]`,e.startsWith(`@@`)&&`text-[var(--text-muted)]`),children:e||` `},t))})}function Rt({open:e,onOpenChange:t,client:n}){let{t:i,locale:a}=w(),{toast:o,confirm:s}=z(),c=g(n.kind,e),l=le();return(0,Q.jsxs)(de,{open:e,onOpenChange:t,width:520,title:i(`clients.backups`),description:i(`clients.backupsDetail`),footer:(0,Q.jsx)(j,{onClick:()=>t(!1),children:i(`common.done`)}),children:[c.isLoading&&(0,Q.jsx)(P,{lines:3}),c.isError&&(0,Q.jsx)(M,{tone:`danger`,title:i(`common.error`),children:L(c.error)}),c.data?.length===0&&(0,Q.jsx)(C,{icon:(0,Q.jsx)(Ie,{className:`size-6`}),title:i(`clients.noBackups`)}),(0,Q.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:c.data?.map(e=>(0,Q.jsx)(D,{label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[r(e.createdAt,a),e.firstWrite&&(0,Q.jsx)(k,{tone:`accent`,children:i(`clients.firstWrite`)})]}),detail:e.files.join(`, `),children:(0,Q.jsx)(j,{size:`sm`,icon:(0,Q.jsx)(Ce,{className:`size-3`}),loading:l.isPending&&l.variables?.id===e.id,onClick:async()=>{await s({title:i(`clients.restoreConfirm`),detail:e.files.join(`
9
- `),destructive:!0,confirmLabel:i(`clients.restore`)})&&l.mutate({kind:n.kind,id:e.id},{onSuccess:()=>o(i(`clients.restored`),`success`),onError:e=>o(L(e),`error`)})},children:i(`clients.restore`)})},e.id))})]})}export{ft as ClientsPage};
5
+ `),ut=/(^|[-_.:/\s])(haiku|flash|mini|lite|nano|small|fast|air)($|[-_.:/\s])/i;function dt(e){if(e.length===0)return{};let t=t=>e.find(e=>e.toLowerCase().includes(t)),n=e.find(e=>!ut.test(e))??e[0],r=e.find(e=>ut.test(e))??n;return{sonnet:t(`sonnet`)??n,opus:t(`opus`)??t(`sonnet`)??n,haiku:t(`haiku`)??r}}function ft(){let{t:e}=w(),t=De(),{toast:n}=z(),r=we(),i=y(),a=h(),o=(0,Z.useMemo)(()=>new Map((i.data??[]).map(e=>[e.kind,e])),[i.data]),s=mt(i.data).includes(r.kind)?r.kind:`codex`,c=o.get(s);return(0,Z.useEffect)(()=>a.mutate(!1),[]),(0,Q.jsx)(Me,{title:e(`nav.clients`),subtitle:e(`clients.subtitle`),actions:(0,Q.jsx)(j,{icon:(0,Q.jsx)(Oe,{className:`size-3.5`}),loading:a.isPending,onClick:()=>a.mutate(!0,{onSuccess:t=>{let r=t.filter(e=>e.install?.updateAvailable&&e.install.blocker!==`shadowed`).length;n(r>0?e(`clients.updatesFound`,{count:r}):e(`clients.allUpToDate`),r>0?void 0:`success`)},onError:e=>n(L(e),`error`)}),children:e(`clients.checkUpdates`)}),children:(0,Q.jsx)(`div`,{className:`@container mx-auto max-w-[1200px]`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-start @3xl:gap-5`,children:[(0,Q.jsx)(vt,{clients:i.data,loading:i.isLoading,selected:s,onSelect:e=>t(`/clients/${e}`,{replace:!0})}),(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-[760px] min-w-0 flex-1`,children:[i.isLoading&&(0,Q.jsx)(P,{lines:4}),i.isError&&(0,Q.jsx)(M,{tone:`danger`,title:e(`common.error`),children:L(i.error)}),c&&(0,Q.jsx)(St,{client:c})]})]})})})}var pt=new Set([`opencode`,`pi`,`minimax-code`,`copilot-cli`,`vscode-copilot`,`crush`,`qwen-code`,`droid`,`kimi-code`,`zed`,`vscode-insiders`,`vscodium`,`omp`,`mimo-code`,`deepseek-harness`,`workbuddy`,`workbuddy-ai`,`nextcowork`,`paseo`,`zcode`,`tkcode`,`muse-code`,`codex`,`grok-build`,`hermes-agent`]);function mt(e){let t=(e??[]).filter(e=>!Y.includes(e.kind)).sort((e,t)=>e.name.localeCompare(t.name));return[...Y,...t.map(e=>e.kind)]}var ht=[`installed`,`notInstalled`,`comingSoon`];function gt(e){return e.availability===`coming_soon`?`comingSoon`:e.detection.installed||e.enabled||e.install?.installed?`installed`:`notInstalled`}function _t(e){return e.install?.version??e.detection.version??null}function vt({clients:e,loading:t,selected:n,onSelect:r}){let{t:i}=w(),a=new Map((e??[]).map(e=>[e.kind,e])),o=ht.map(t=>({group:t,items:mt(e).flatMap(e=>{let n=a.get(e);return n&&gt(n)===t?[n]:[]})})).filter(e=>e.items.length>0);return(0,Q.jsxs)(`nav`,{"aria-label":i(`nav.clients`),className:`card shrink-0 p-1.5 @3xl:sticky @3xl:top-0 @3xl:w-[232px]`,children:[t&&(0,Q.jsx)(P,{lines:6,className:`p-2`}),(0,Q.jsx)(`div`,{className:`flex gap-1 overflow-x-auto @3xl:flex-col @3xl:gap-0 @3xl:overflow-visible`,children:o.map(({group:e,items:t})=>(0,Q.jsxs)(`div`,{className:`contents @3xl:block`,children:[(0,Q.jsxs)(`h3`,{className:`hidden px-2.5 pt-2 pb-1 text-[11px] font-medium text-[var(--text-muted)] @3xl:block`,children:[i(`clients.group.${e}`),` · `,t.length]}),t.map(e=>(0,Q.jsx)(yt,{client:e,active:e.kind===n,onSelect:()=>r(e.kind)},e.kind))]},e))})]})}function yt({client:e,active:t,onSelect:n}){let{t:r}=w(),i=gt(e)!==`installed`,a=_t(e),o=e.install?.blocker===`shadowed`,s=e.install?.updateAvailable&&!o?e.install.latestVersion:null;return(0,Q.jsxs)(`button`,{type:`button`,"aria-label":J(e.kind,e.name),"aria-current":t?`page`:void 0,onClick:n,className:A(`flex shrink-0 items-center gap-2.5 rounded-[var(--radius-control)] px-2.5 py-1.5 text-left transition-colors @3xl:w-full`,t?`bg-[var(--accent-subtle)]`:`hover:bg-[var(--surface-muted)]`),children:[(0,Q.jsx)(`span`,{className:A(`inline-flex`,i&&!t&&`opacity-60`),children:(0,Q.jsx)(je,{kind:e.kind,size:24})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:A(`block truncate text-[13px] whitespace-nowrap`,t&&`font-medium`),children:J(e.kind,e.name)}),a&&(0,Q.jsxs)(`span`,{className:`hidden truncate text-[11px] text-[var(--text-secondary)] @3xl:block`,children:[a,s&&(0,Q.jsxs)(`span`,{className:`text-[var(--warning)]`,children:[` → `,s]})]})]}),e.install?.busy&&(0,Q.jsx)(bt,{}),s&&!e.install?.busy&&(0,Q.jsx)(k,{tone:`orange`,title:r(`clients.updateTo`,{version:s}),children:r(`clients.updateBadge`)}),o&&!e.install?.busy&&(0,Q.jsx)(k,{tone:`orange`,title:r(`clients.shadowed.title`,{version:e.install?.latestVersion??``}),children:r(`clients.shadowedBadge`)}),e.status===`drifted`?(0,Q.jsx)(`span`,{title:r(`clients.drifted`),"aria-label":r(`clients.drifted`),className:`inline-flex`,children:(0,Q.jsx)(ce,{tone:`orange`})}):e.enabled?(0,Q.jsx)(S,{className:`size-3.5 shrink-0 text-[var(--success)]`,strokeWidth:2.5,"aria-label":r(`clients.enabled`)}):null]})}function bt(){return(0,Q.jsx)(Te,{className:`size-3.5 shrink-0 animate-spin text-[var(--text-secondary)] motion-reduce:animate-none`,"aria-hidden":!0})}function xt(e,t){return e.availability===`coming_soon`?(0,Q.jsx)(k,{children:t(`clients.comingSoon`)}):e.status===`drifted`?(0,Q.jsx)(k,{tone:`orange`,children:t(`clients.drifted`)}):e.enabled?(0,Q.jsx)(k,{tone:`green`,children:t(`clients.enabled`)}):(0,Q.jsx)(k,{children:t(`clients.disabled`)})}function St({client:e}){let{t,locale:n}=w(),a=De(),{toast:s,confirm:c}=z(),l=oe(),u=ie(),d=te(),f=x(),p=re(),m=E(),h=o(e.kind,!!e.providerId),[g,_]=(0,Z.useState)(e.selectedModel??null),[v,y]=(0,Z.useState)(e.accountId??``),b=e.tokenId??`default`,[S,C]=(0,Z.useState)(b),T=(m.data??[]).filter(e=>e.enabled||e.id===b).map(e=>({value:e.id,label:e.enabled?e.name:t(`clients.tokenDisabled`,{name:e.name}),disabled:!e.enabled})),[ee,O]=(0,Z.useState)(!1),[A,se]=(0,Z.useState)(!1),[ce,le]=(0,Z.useState)(null),F=e.availability===`coming_soon`,I=J(e.kind,e.name),de=(l.data??[]).filter(e=>e.enabled),V=e.detection.configPaths[0],fe=de.find(t=>t.id===e.providerId),pe=fe?.authScheme===`oauth-subscription`||fe?.authScheme===`plugin`,he=ae(fe?.id,pe),H=e.kind===`claude-desktop`,U=e.kind===`claude-code`,ge=r(U),W=U&&ge.data?.mode===`direct`,G=lt(e.extras),[_e,ve]=(0,Z.useState)(G),K=ct.some(e=>_e[e]),ye=$(_e)!==$(G),be=ot(e.extras),[xe,Se]=(0,Z.useState)(be),Ce=(g??null)!==(e.selectedModel??null)||st(xe)!==st(be),we=U?at.filter(e=>e!==`ANTHROPIC_MODEL`):[],Te=U?e.enabled?t(`clients.modelSlotsFooterEnabled`):t(`clients.modelSlotsFooter`):e.enabled?t(`clients.modelFooterEnabled`):t(`clients.modelFooter`),q=e.options??[],Ee=rt(e.extras,q),[Oe,Ae]=(0,Z.useState)(Ee),Me=it(Oe)!==it(Ee),Y=e.protocols??[],Ne=Y.length>1?Ze(e.extras):[],Pe=Xe(e.extras),[Fe,Le]=(0,Z.useState)(Pe),Re=$e(Fe)!==$e(Pe),ze=H?{...e.extras,roleMap:_e}:U?{...e.extras,models:xe,options:Oe}:q.length>0||Y.length>1?{...e.extras,...q.length>0?{options:Oe}:{},...Y.length>1?{protocolOverrides:Fe}:{}}:void 0;(0,Z.useEffect)(()=>_(e.selectedModel??null),[e.kind,e.selectedModel]),(0,Z.useEffect)(()=>y(e.accountId??``),[e.kind,e.providerId,e.accountId]),(0,Z.useEffect)(()=>C(b),[e.kind,b]),(0,Z.useEffect)(()=>ve(lt(e.extras)),[e.kind,$(G)]);let X=(0,Z.useRef)({});(0,Z.useEffect)(()=>{if(!H||e.enabled||ct.some(e=>G[e]))return;let t=X.current,n=dt(h.data??[]);X.current=n,ve(e=>(!ct.some(t=>e[t])||$(e)===$(t))&&$(e)!==$(n)?n:e)},[e.kind,e.enabled,$(G),(h.data??[]).join(`
6
+ `)]),(0,Z.useEffect)(()=>Se(ot(e.extras)),[e.kind,st(be)]),(0,Z.useEffect)(()=>Ae(rt(e.extras,e.options)),[e.kind,it(Ee)]),(0,Z.useEffect)(()=>Le(Xe(e.extras)),[e.kind,$e(Pe)]);let Be=()=>{e.providerId&&u.mutate({kind:e.kind,providerId:e.providerId,accountId:v},{onSuccess:()=>s(t(`common.saved`),`success`),onError:e=>s(L(e),`error`)})},Ve=async()=>{await c({title:t(`clients.disableConfirm`,{name:I}),detail:t(`clients.disableDetail`),confirmLabel:t(`clients.disable`)})&&d.mutate(e.kind,{onSuccess:async n=>{if(n.drifted.length===0){s(t(`clients.disabledToast`,{name:I}),`success`);return}await c({title:t(`clients.driftTitle`),detail:t(`clients.driftDetail`,{keys:n.drifted.join(`, `)}),confirmLabel:t(`clients.forceRestore`),destructive:!0})&&f.mutate(e.kind,{onSuccess:()=>s(t(`clients.disabledToast`,{name:I}),`success`),onError:e=>s(L(e),`error`)})},onError:e=>s(L(e),`error`)})},He=async()=>{V&&(R.canOpenPaths?await R.openPath(ue(V)):await R.copy(V)&&s(t(`common.copied`)))};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(D,{icon:(0,Q.jsx)(je,{kind:e.kind,size:36}),label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[15px] font-medium`,children:I}),W?(0,Q.jsx)(k,{children:t(`clients.claudeDirect.direct`)}):xt(e,t)]}),detail:F?e.availabilityReason??t(`clients.comingSoonDetail`):[gt(e)===`installed`?t(`clients.detected`,{version:_t(e)??``}):t(`clients.notDetected`),W?null:V].filter(Boolean).join(` · `),className:`py-3`,children:[!F&&(0,Q.jsx)(Ot,{client:e,onOpen:le}),W?(0,Q.jsx)(j,{variant:`primary`,onClick:()=>document.getElementById(At)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:t(`clients.claudeDirect.configure`)}):e.enabled?(0,Q.jsx)(j,{onClick:()=>void Ve(),loading:d.isPending,children:t(`clients.disableRestore`)}):(0,Q.jsx)(j,{variant:`primary`,disabled:F||!e.providerId||H&&!K,onClick:()=>O(!0),title:e.providerId?H&&!K?t(`clients.roleMapRequired`):void 0:t(`clients.pickProviderFirst`),children:t(`clients.enable`)})]}),!W&&e.appliedAt&&(0,Q.jsx)(D,{label:(0,Q.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`clients.appliedAt`,{time:i(e.appliedAt,n)})})})]}),!F&&!e.enabled&&H&&e.providerId&&!K&&(0,Q.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Q.jsx)(M,{tone:`info`,className:`self-stretch`,title:t(`clients.roleMapHint`)}),(0,Q.jsx)(j,{onClick:()=>document.getElementById(jt)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:t(`clients.roleMapGoto`)})]}),(e.repairs?.length??0)>0&&(0,Q.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Q.jsxs)(M,{tone:`danger`,className:`self-stretch`,title:t(`clients.repair.title`,{name:I}),children:[e.repairs?.map(e=>(0,Q.jsxs)(`span`,{className:`block break-all`,children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.file}),` — `,t(`clients.repair.problem.${e.problem}`,{line:e.line})]},e.file)),(0,Q.jsx)(`span`,{className:`block`,children:t(`clients.repair.hint`)})]}),(0,Q.jsx)(j,{variant:`primary`,loading:p.isPending,onClick:()=>p.mutate(e.kind,{onSuccess:()=>s(t(`clients.repair.done`,{name:I}),`success`),onError:e=>s(L(e),`error`)}),children:t(`clients.repair.action`)})]}),!W&&e.warnings.length>0&&(0,Q.jsx)(`div`,{className:`mb-5 flex flex-col gap-2`,children:e.warnings.map((e,t)=>(0,Q.jsx)(M,{tone:`warning`,title:e},t))}),!W&&(0,Q.jsx)(Et,{client:e,providers:l.data??[],loading:l.isLoading,soon:F}),!W&&pe&&(0,Q.jsx)(N,{title:t(`clients.accountTitle`),footer:t(`clients.accountFooter`),children:he.isLoading?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(P,{lines:2})}):(0,Q.jsxs)(D,{label:t(`clients.account`),children:[(0,Q.jsx)(B,{className:`max-w-[300px]`,ariaLabel:t(`clients.account`),value:v,onChange:y,options:[{value:``,label:t(`clients.accountDefault`)},...(he.data??[]).map(e=>({value:e.id,label:(e.displayName||e.id)+(e.status===`active`?``:` · ${t(`providers.subscription.status.${e.status}`)}`)}))]}),v!==(e.accountId??``)&&(0,Q.jsx)(j,{size:`sm`,variant:`primary`,loading:u.isPending,onClick:Be,children:t(`common.apply`)})]})}),!F&&!W&&(0,Q.jsxs)(N,{title:t(`clients.tokenTitle`),footer:e.enabled?t(`clients.tokenFooterEnabled`):t(`clients.tokenFooter`),children:[(0,Q.jsxs)(D,{label:t(`clients.token`),children:[(0,Q.jsx)(B,{className:`max-w-[300px]`,ariaLabel:t(`clients.token`),value:S,onChange:C,options:T}),e.enabled&&S!==b&&(0,Q.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>O(!0),children:t(`common.apply`)})]}),(0,Q.jsx)(D,{icon:(0,Q.jsx)(ke,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.manageTokens`),onClick:()=>a(`/tokens`)})]}),!F&&!W&&e.providerId&&H&&(0,Q.jsx)(`div`,{id:jt,children:(0,Q.jsxs)(N,{title:t(`clients.roleMapTitle`),footer:e.enabled?t(`clients.roleMapFooterEnabled`):t(`clients.roleMapFooter`),children:[ct.map(e=>(0,Q.jsx)(D,{label:t(`clients.role.${e}`),children:(0,Q.jsx)(B,{ariaLabel:t(`clients.role.${e}`),value:_e[e]??``,onChange:t=>ve(n=>({...n,[e]:t||void 0})),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(h.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&ye&&(0,Q.jsx)(D,{label:K?``:(0,Q.jsx)(`span`,{className:`text-[12px] text-[var(--warning)]`,children:t(`clients.roleMapRequired`)}),children:(0,Q.jsx)(j,{size:`sm`,variant:`primary`,disabled:!K,onClick:()=>O(!0),children:t(`common.apply`)})})]})}),!F&&!W&&e.providerId&&!H&&(0,Q.jsxs)(N,{title:t(`clients.modelTitle`),footer:Te,children:[(0,Q.jsx)(D,{label:t(`clients.defaultModel`),children:(0,Q.jsx)(B,{value:g??``,onChange:e=>_(e||null),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(h.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})}),we.map(e=>(0,Q.jsx)(D,{label:t(`clients.modelSlot.${e}`),children:(0,Q.jsx)(B,{ariaLabel:t(`clients.modelSlot.${e}`),value:xe[e]??``,onChange:t=>Se(n=>({...n,[e]:t||void 0})),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(h.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&(U?Ce:(g??null)!==(e.selectedModel??null))&&(0,Q.jsx)(D,{label:``,children:(0,Q.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>O(!0),children:t(`common.apply`)})})]}),!F&&!W&&q.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qe,{descriptors:q,values:Oe,onChange:Ae,enabled:e.enabled}),e.enabled&&Me&&(0,Q.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Q.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>O(!0),children:t(`common.apply`)})})]}),!F&&Ne.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(nt,{models:Ne,supported:Y,values:Fe,onChange:Le,enabled:e.enabled}),e.enabled&&Re&&(0,Q.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Q.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>O(!0),children:t(`common.apply`)})})]}),!F&&e.install&&(0,Q.jsx)(Nt,{client:e,onShowLog:()=>le(`log`),onUninstall:()=>le(`uninstall`)}),U&&(0,Q.jsx)(`div`,{id:At,children:(0,Q.jsx)(We,{enabled:U,gatewayEnabled:e.enabled})}),!F&&!W&&(0,Q.jsxs)(N,{title:t(`clients.maintenance`),children:[V&&(0,Q.jsx)(D,{icon:R.canOpenPaths?(0,Q.jsx)(me,{className:`size-4 text-[var(--text-secondary)]`}):(0,Q.jsx)(ne,{className:`size-4 text-[var(--text-secondary)]`}),label:R.canOpenPaths?t(`clients.openConfigDir`):t(`clients.copyConfigPath`),detail:V,onClick:()=>void He()}),(0,Q.jsx)(D,{icon:(0,Q.jsx)(Ie,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.backups`),detail:t(`clients.backupsDetail`),onClick:()=>se(!0)})]}),(0,Q.jsx)(Ft,{open:ee,onOpenChange:O,client:e,model:g,extras:ze,tokenId:S}),(0,Q.jsx)(Rt,{open:A,onOpenChange:se,client:e}),(0,Q.jsx)(Pt,{mode:ce,onClose:()=>le(null),client:e})]})}var Ct={install:`clients.installTitle`,update:`clients.updateTitle`,uninstall:`clients.uninstallTitle`},wt={install:`clients.installedToast`,update:`clients.updatedToast`,uninstall:`clients.uninstalledToast`};function Tt(e,t){return[e.priceKey??e.templateId,t(`providers.modelCount`,{count:e.modelCount}),e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `)}function Et({client:e,providers:t,loading:n,soon:r}){let{t:i}=w(),{toast:a}=z(),o=u(),s=(0,Z.useMemo)(()=>e.bindings??(e.providerId?[{providerId:e.providerId,accountId:e.accountId}]:[]),[e.bindings,e.providerId,e.accountId]),[c,l]=(0,Z.useState)(s);(0,Z.useEffect)(()=>l(s),[s]);let d=(0,Z.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]),f=c.flatMap(e=>{let t=d.get(e.providerId);return t?[{binding:e,provider:t}]:[]}),p=t.filter(e=>e.enabled&&!c.some(t=>t.providerId===e.id)),m=U(Se(H,{activationConstraint:{distance:4}}),Se(be,{coordinateGetter:ye})),h=r||o.isPending,g=(t,n)=>{let r=c;l(t),o.mutate({kind:e.kind,bindings:t},{onSuccess:()=>a(pt.has(e.kind)&&e.enabled?i(`clients.providersModelsSynced`,{client:J(e.kind,e.name)}):n),onError:e=>{l(r),a(L(e),`error`)}})},_=({active:e,over:t})=>{if(!t||e.id===t.id)return;let n=c.findIndex(t=>t.providerId===e.id),r=c.findIndex(e=>e.providerId===t.id);n<0||r<0||g(_e(c,n,r),i(`clients.providerOrderSaved`))},v=e=>g([...c,{providerId:e.id}],i(`clients.providerAdded`,{provider:e.name})),y=e=>g(c.filter(t=>t.providerId!==e.id),i(`clients.providerRemoved`,{provider:e.name})),b=p.map(e=>(0,Q.jsx)(D,{icon:(0,Q.jsx)(Ne,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24}),label:e.name,detail:Tt(e,i),onClick:h?void 0:()=>v(e),children:!r&&(0,Q.jsx)(Pe,{className:`size-4 text-[var(--text-secondary)]`,"aria-label":i(`common.add`)})},e.id));return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(N,{title:i(`clients.providerTitle`),footer:i(`clients.providerFooter`),children:[n&&(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(P,{lines:2})}),!n&&f.length===0&&p.length===0&&(0,Q.jsx)(C,{title:i(`clients.noProviders`),detail:i(`clients.noProvidersDetail`),action:(0,Q.jsx)(Ae,{to:`/providers?new=1`,children:(0,Q.jsx)(j,{variant:`primary`,icon:(0,Q.jsx)(Pe,{className:`size-3.5`}),children:i(`providers.add`)})})}),f.length>0&&(0,Q.jsx)(ve,{sensors:m,collisionDetection:G,onDragEnd:_,children:(0,Q.jsx)(xe,{items:f.map(e=>e.provider.id),strategy:he,children:f.map(({provider:e},t)=>(0,Q.jsx)(Dt,{provider:e,primary:t===0,disabled:h,onRemove:f.length>1?()=>y(e):void 0},e.id))})}),!n&&f.length===0&&b]}),f.length>0&&p.length>0&&(0,Q.jsx)(N,{title:i(`clients.moreProvidersTitle`),children:b})]})}function Dt({provider:e,primary:t,disabled:n,onRemove:r}){let{t:i}=w(),{attributes:a,listeners:o,setNodeRef:s,setActivatorNodeRef:c,transform:l,transition:u,isDragging:d}=W({id:e.id,disabled:n});return(0,Q.jsx)(`div`,{ref:s,style:{transform:ge.Transform.toString(l),transition:u},className:A(d&&`relative z-10 bg-[var(--surface)] shadow-lg`),children:(0,Q.jsx)(D,{icon:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{ref:c,type:`button`,"aria-label":i(`clients.dragToReorder`,{provider:e.name}),title:i(`clients.dragToReorder`,{provider:e.name}),className:`-ml-1 inline-flex cursor-grab touch-none text-[var(--text-muted)] hover:text-[var(--text-secondary)] active:cursor-grabbing disabled:cursor-default disabled:opacity-50`,...a,...o,children:(0,Q.jsx)(K,{className:`size-4`})}),(0,Q.jsx)(Ne,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24})]}),label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),t&&(0,Q.jsx)(k,{tone:`accent`,children:i(`clients.primaryProvider`)}),!e.enabled&&(0,Q.jsx)(k,{tone:`orange`,children:i(`clients.providerDisabledBadge`)})]}),detail:Tt(e,i),children:r&&(0,Q.jsx)(j,{size:`sm`,variant:`plain`,icon:(0,Q.jsx)(ee,{className:`size-3.5`}),"aria-label":i(`clients.removeProvider`,{provider:e.name}),title:i(`clients.removeProvider`,{provider:e.name}),disabled:n,onClick:r})})})}function Ot({client:e,onOpen:t}){let{t:n}=w(),r=e.install;if(!r)return null;let i=r.needsAdmin?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-[var(--warning)]`,children:[(0,Q.jsx)(X,{className:`size-3`,"aria-hidden":!0}),n(`clients.admin.badge`)]}):null,a=r.needsAdmin?n(r.adminAvailable?`clients.admin.tip`:`clients.admin.tipManual`):void 0;return r.busy?(0,Q.jsx)(j,{icon:(0,Q.jsx)(bt,{}),onClick:()=>t(`log`),children:n(`clients.installRunning`)}):r.updateAvailable&&r.updateCommand&&r.latestVersion?(0,Q.jsxs)(j,{icon:(0,Q.jsx)(Re,{className:`size-3.5`}),title:a,onClick:()=>t(`update`),children:[n(`clients.updateTo`,{version:r.latestVersion}),i]}):r.updateAvailable&&r.blocker===`shadowed`?(0,Q.jsx)(j,{icon:(0,Q.jsx)(X,{className:`size-3.5`}),onClick:()=>document.getElementById(kt)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:n(`clients.shadowedBadge`)}):!r.installed&&r.installCommand?(0,Q.jsxs)(j,{icon:(0,Q.jsx)(fe,{className:`size-3.5`}),title:a,onClick:()=>t(`install`),children:[n(`clients.install`),i]}):!r.installed&&r.method===`manual`?(0,Q.jsx)(j,{icon:(0,Q.jsx)(pe,{className:`size-3.5`}),onClick:()=>window.open(r.homepageUrl,`_blank`,`noreferrer`),children:n(`clients.download`)}):null}var kt=`client-shadowed-alert`,At=`claude-direct-panel`,jt=`client-role-map`;function Mt(e,t){return!e.installed||e.uninstallCommand?null:e.method===`npm`?t(`clients.uninstallExternal`,{path:e.executable??``}):e.method===`vscode-extension`?t(`clients.uninstallBuiltIn`):t(`clients.uninstallManual`)}function Nt({client:e,onShowLog:t,onUninstall:n}){let{t:r,locale:a}=w(),o=e.install,s=se(e.kind),c=(e,t=!1)=>(0,Q.jsx)(`span`,{className:A(`text-[13px] tabular-nums selectable`,t&&`text-[var(--text-secondary)]`),children:e}),l=o.blocker===`external-install`?r(`clients.blocker.external-install`,{path:o.executable??``}):o.blocker?r(`clients.blocker.${o.blocker}`):void 0,u=o.otherCopies??[],d=u.find(e=>e.newer);return(0,Q.jsxs)(Q.Fragment,{children:[d&&(0,Q.jsx)(`div`,{id:kt,className:`mb-3`,children:(0,Q.jsx)(M,{tone:`warning`,title:r(`clients.shadowed.title`,{version:d.version}),children:r(`clients.shadowed.detail`,{path:o.executable??``,version:o.version??``,other:d.path,dir:ue(d.path)})})}),!d&&o.notOnPath&&o.executable&&(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(M,{tone:`warning`,title:r(`clients.notOnPath.title`),children:r(`clients.notOnPath.detail`,{dir:ue(o.executable)})})}),(0,Q.jsxs)(N,{title:r(`clients.versionTitle`),footer:l,children:[(0,Q.jsx)(D,{label:r(`clients.currentVersion`),detail:o.installed?o.executable:void 0,children:o.installed?c(o.version??r(`clients.versionUnknown`),!o.version):c(r(`clients.notInstalled`),!0)}),u.map(e=>(0,Q.jsxs)(D,{label:r(`clients.otherCopy`),detail:e.path,children:[e.newer&&(0,Q.jsx)(k,{tone:`orange`,children:r(`clients.otherCopyNewer`)}),c(e.version,!e.newer)]},e.path)),(o.method===`npm`||o.method===`script`)&&(0,Q.jsxs)(D,{label:r(`clients.latestVersion`),detail:o.latestError??(o.latestCheckedAt?r(`clients.checkedAt`,{time:i(o.latestCheckedAt,a)}):void 0),children:[o.updateAvailable&&(0,Q.jsx)(k,{tone:`orange`,children:r(`clients.updateBadge`)}),c(o.latestVersion??r(`clients.latestUnknown`),!o.latestVersion)]}),(0,Q.jsx)(D,{label:r(`clients.installMethod`),detail:r(`clients.method.${o.method}`,{package:o.package??``}),children:(0,Q.jsx)(j,{size:`sm`,variant:`plain`,icon:(0,Q.jsx)(pe,{className:`size-3`}),onClick:()=>window.open(o.homepageUrl,`_blank`,`noreferrer`),children:r(`clients.homepage`)})}),o.installed&&(0,Q.jsx)(D,{label:r(`clients.uninstall`),detail:o.uninstallCommand??Mt(o,r),children:o.uninstallCommand&&(0,Q.jsx)(j,{size:`sm`,variant:`destructive`,icon:(0,Q.jsx)(Ee,{className:`size-3`}),disabled:o.busy,onClick:n,children:r(`clients.uninstall`)})}),s.data&&(0,Q.jsx)(D,{icon:(0,Q.jsx)(q,{className:`size-4 text-[var(--text-secondary)]`}),label:r(`clients.installLog`),detail:`${s.data.command} · ${r(`clients.job.${s.data.state}`)}`,onClick:t})]})]})}function Pt({mode:t,onClose:n,client:r}){let{t:i}=w(),{toast:o}=z(),s=d(),c=t!==null,u=se(r.kind,c||!!r.install?.busy),f=l(),p=a(),[m,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(null),_=(0,Z.useRef)(void 0),v=J(r.kind,r.name),y=r.install,b=t===`log`?null:t,x=b===`install`?y?.installCommand:b===`update`?y?.updateCommand:b===`uninstall`?y?.uninstallCommand:null,S=b===`uninstall`,T=u.data,ee=b!==null&&!m&&T?.state!==`running`,E=!!y?.needsAdmin,te=!!y?.adminAvailable,re=T?.state===`failed`&&T.hint===`permission-denied`&&!T.elevated&&te;(0,Z.useEffect)(()=>{c&&h(!1)},[c,t]),(0,Z.useEffect)(()=>{let t=T?.state;_.current===`running`&&t&&t!==`running`&&(s.invalidateQueries({queryKey:e.clients}),t===`succeeded`&&T.hint?o(i(`clients.notEffectiveToast`,{name:v})):t===`succeeded`&&o(i(wt[T.action],{name:v}),`success`)),_.current=t},[T?.state,T?.action,T?.hint,v,s,i,o]),(0,Z.useEffect)(()=>{let e=g.current;e&&(e.scrollTop=e.scrollHeight)},[T?.log.length]);let ie=(e,t)=>f.mutate({kind:r.kind,action:e,elevated:t},{onSuccess:()=>h(!0),onError:e=>o(L(e),`error`)}),D=async e=>{await R.copy(e)&&o(i(`common.copied`))},O=i(Ct[b??T?.action??`install`],{name:v}),k={running:`info`,succeeded:`success`,failed:`danger`,cancelled:`warning`},ae=`rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] px-3 py-2 font-mono text-[12px] break-all whitespace-pre-wrap selectable`,oe=y?.adminFixCommand?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] text-[var(--text-secondary)]`,children:i(`clients.admin.fixTip`)}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`pre`,{className:A(ae,`min-w-0 flex-1`),children:y.adminFixCommand}),(0,Q.jsx)(j,{size:`sm`,icon:(0,Q.jsx)(ne,{className:`size-3`}),"aria-label":i(`common.copy`),onClick:()=>void D(y.adminFixCommand)})]})]}):null;return(0,Q.jsx)(de,{open:c,onOpenChange:e=>!e&&n(),width:620,title:O,description:ee?i(S?`clients.uninstallRunDetail`:`clients.installRunDetail`):void 0,footer:ee?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{onClick:n,children:i(`common.cancel`)}),E&&!te?(0,Q.jsx)(j,{variant:`primary`,icon:(0,Q.jsx)(ne,{className:`size-3.5`}),disabled:!x,onClick:()=>void D(`sudo ${x}`),children:i(`clients.admin.copyCommand`)}):(0,Q.jsx)(j,{variant:S?`destructive`:`primary`,icon:E?(0,Q.jsx)(X,{className:`size-3.5`}):void 0,disabled:!x,loading:f.isPending,onClick:()=>b&&ie(b,E),children:i(E?`clients.admin.start`:S?`clients.uninstall`:`clients.installStart`)})]}):T?.state===`running`?(0,Q.jsxs)(Q.Fragment,{children:[!T.elevated&&(0,Q.jsx)(j,{variant:`destructive`,loading:p.isPending,onClick:()=>p.mutate(r.kind,{onError:e=>o(L(e),`error`)}),children:i(`clients.installStop`)}),(0,Q.jsx)(j,{onClick:n,children:i(`common.close`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{onClick:n,children:i(`common.done`)}),re&&(0,Q.jsx)(j,{variant:`primary`,icon:(0,Q.jsx)(X,{className:`size-3.5`}),loading:f.isPending,onClick:()=>ie(T.action,!0),children:i(`clients.admin.retry`)})]}),children:ee?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[S&&r.enabled&&(0,Q.jsx)(M,{tone:`warning`,title:i(`clients.uninstallRestoreTitle`),children:i(`clients.uninstallRestoreDetail`,{name:v})}),E&&(0,Q.jsx)(M,{tone:`warning`,title:i(`clients.admin.title`),children:i(te?`clients.admin.prompt`:`clients.admin.manual`)}),x?(0,Q.jsx)(`pre`,{className:ae,children:E?`sudo ${x}`:x}):(0,Q.jsx)(M,{tone:`warning`,title:i(`clients.installUnavailable`)}),S?(0,Q.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`clients.uninstallKeepsData`)}):y?.method===`npm`&&(0,Q.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`clients.installNpmNote`)}),E&&oe]}):T?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(M,{tone:T.state===`succeeded`&&T.hint?`warning`:k[T.state],title:i(T.state===`succeeded`&&T.hint?`clients.job.notEffective`:`clients.job.${T.state}`),children:T.state===`running`&&T.elevated?i(`clients.admin.running`):T.hint?i(`clients.hint.${T.hint}`)+(re?i(`clients.admin.retryHint`):``):void 0}),(0,Q.jsx)(`pre`,{ref:g,className:`scroll max-h-[340px] min-h-[160px] rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] px-3 py-2 font-mono text-[11px] leading-relaxed break-all whitespace-pre-wrap selectable`,children:T.log.join(`
7
+ `)}),T.hint===`permission-denied`&&oe]}):u.isLoading?(0,Q.jsx)(P,{lines:4}):(0,Q.jsx)(C,{icon:(0,Q.jsx)(q,{className:`size-6`}),title:i(`clients.noInstallLog`)})})}function Ft({open:e,onOpenChange:t,client:n,model:r,extras:i,tokenId:a}){let{t:o}=w(),{toast:s}=z(),c=v(),l=O(),u=J(n.kind,n.name),d=i?{providerId:n.providerId,model:r,extras:i,tokenId:a}:{providerId:n.providerId,model:r,tokenId:a};return(0,Z.useEffect)(()=>{e&&c.mutate({kind:n.kind,req:d})},[e]),(0,Q.jsxs)(de,{open:e,onOpenChange:t,width:620,title:o(`clients.enableTitle`,{name:u}),description:o(`clients.enableDetail`),footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{onClick:()=>t(!1),children:o(`common.cancel`)}),(0,Q.jsx)(j,{variant:`primary`,disabled:!c.data,loading:l.isPending,onClick:()=>l.mutate({kind:n.kind,req:d},{onSuccess:e=>{t(!1),s(e.requiresRestart?o(`clients.enabledRestart`,{name:u}):o(`clients.enabledToast`,{name:u}),`success`)},onError:e=>s(L(e),`error`)}),children:n.enabled?o(`common.apply`):o(`clients.enable`)})]}),children:[c.isPending&&(0,Q.jsx)(P,{lines:4}),c.isError&&(0,Q.jsx)(M,{tone:`danger`,title:o(`common.error`),children:L(c.error)}),c.data&&(0,Q.jsx)(It,{preview:c.data})]})}function It({preview:e}){let{t}=w();return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.warnings.map((e,t)=>(0,Q.jsx)(M,{tone:`warning`,title:e},t)),e.changes.length===0&&(0,Q.jsx)(M,{tone:`info`,title:t(`clients.noChanges`)}),e.diffs.map(e=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`mb-2 font-mono text-[11px] text-[var(--text-secondary)]`,children:e.file}),(0,Q.jsx)(Lt,{diff:e.unifiedDiff})]},e.file))]})}function Lt({diff:e}){return(0,Q.jsx)(`pre`,{className:`scroll max-h-[300px] rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] py-2 font-mono text-[11px] leading-relaxed selectable`,children:e.split(`
8
+ `).map((e,t)=>(0,Q.jsx)(`div`,{className:A(`px-3 whitespace-pre-wrap break-all`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-[color-mix(in_oklab,var(--success)_12%,transparent)] text-[var(--success)]`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-[color-mix(in_oklab,var(--danger)_10%,transparent)] text-[var(--danger)]`,e.startsWith(`@@`)&&`text-[var(--text-muted)]`),children:e||` `},t))})}function Rt({open:e,onOpenChange:t,client:n}){let{t:r,locale:a}=w(),{toast:o,confirm:s}=z(),c=g(n.kind,e),l=le();return(0,Q.jsxs)(de,{open:e,onOpenChange:t,width:520,title:r(`clients.backups`),description:r(`clients.backupsDetail`),footer:(0,Q.jsx)(j,{onClick:()=>t(!1),children:r(`common.done`)}),children:[c.isLoading&&(0,Q.jsx)(P,{lines:3}),c.isError&&(0,Q.jsx)(M,{tone:`danger`,title:r(`common.error`),children:L(c.error)}),c.data?.length===0&&(0,Q.jsx)(C,{icon:(0,Q.jsx)(Ie,{className:`size-6`}),title:r(`clients.noBackups`)}),(0,Q.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:c.data?.map(e=>(0,Q.jsx)(D,{label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[i(e.createdAt,a),e.firstWrite&&(0,Q.jsx)(k,{tone:`accent`,children:r(`clients.firstWrite`)})]}),detail:e.files.join(`, `),children:(0,Q.jsx)(j,{size:`sm`,icon:(0,Q.jsx)(Ce,{className:`size-3`}),loading:l.isPending&&l.variables?.id===e.id,onClick:async()=>{await s({title:r(`clients.restoreConfirm`),detail:e.files.join(`
9
+ `),destructive:!0,confirmLabel:r(`clients.restore`)})&&l.mutate({kind:n.kind,id:e.id},{onSuccess:()=>o(r(`clients.restored`),`success`),onError:e=>o(L(e),`error`)})},children:r(`clients.restore`)})},e.id))})]})}export{ft as ClientsPage};
@@ -0,0 +1 @@
1
+ import{Ct as e,Fa as t,G as n,H as r,J as i,Pa as a,Q as o,Ra as s,St as c,Tt as l,Y as u,_ as d,ct as f,n as p,q as m,r as h,t as g,wt as _}from"./alert-CMMOyMsp.js";import{A as v,_ as y,k as b}from"./index-Ck4Qlg9B.js";var x=s(t(),1),S=a(),C=`astra.keyLookup`;function w(){try{return sessionStorage.getItem(C)??``}catch{return``}}function T(e){try{e?sessionStorage.setItem(C,e):sessionStorage.removeItem(C)}catch{}}function E(){let{t}=f(),[n,r]=(0,x.useState)(``),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(``),[l,u]=(0,x.useState)(null),[d,p]=(0,x.useState)(!1),m=(0,x.useCallback)(async n=>{let r=n.trim();if(r){p(!0),u(null);try{a(await e(r)),s(r),T(r)}catch(e){a(null),T(null),u(e instanceof c&&e.status===401?t(`key.invalid`):t(`key.error`,{error:e.message}))}finally{p(!1)}}},[t]);return(0,x.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`key`);e&&window.history.replaceState(null,``,window.location.pathname);let t=e??w();t&&(r(t),m(t))},[]),(0,S.jsx)(`div`,{className:`wallpaper flex min-h-full justify-center overflow-y-auto p-4 sm:items-start sm:py-12`,children:(0,S.jsxs)(`div`,{className:`flex w-full max-w-[720px] flex-col gap-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(v,{className:`size-10 rounded-[12px]`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-[17px] font-medium`,children:t(`key.title`)}),(0,S.jsx)(`p`,{className:`text-[13px] text-[var(--text-secondary)]`,children:t(`key.subtitle`)})]})]}),!i&&(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m(n)},className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(b,{label:t(`key.title`),placeholder:t(`key.placeholder`),autoFocus:!0,autoComplete:`off`,value:n,"aria-invalid":l?!0:void 0,onChange:e=>r(e.target.value)}),l&&(0,S.jsx)(g,{tone:`danger`,title:l}),(0,S.jsx)(h,{type:`submit`,variant:`primary`,loading:d,disabled:!n.trim(),children:t(`key.submit`)})]}),i&&(0,S.jsx)(D,{info:i,apiKey:o,onForget:()=>{T(null),a(null),r(``)}})]})})}function D({info:e,apiKey:t,onForget:n}){let{t:i,locale:a}=f(),[s,c]=(0,x.useState)(`overview`),l=e.allowedClients==null?i(`key.clientsAny`):e.allowedClients.length===0?i(`key.directOnly`):e.allowedClients.map(e=>y[e]?.name??e).join(`, `),m=[[i(`key.today`),e.usage.today],[i(`key.week`),e.usage.week],[i(`key.month`),e.usage.month],[i(`key.total`),e.usage.total]],g=Math.max(...e.daily.map(e=>e.costUsd),0);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`h2`,{className:`text-[15px] font-medium`,children:e.name}),(0,S.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--text-secondary)]`,children:e.keyPrefix}),!e.enabled&&(0,S.jsx)(p,{tone:`orange`,children:i(`key.disabled`)}),(0,S.jsx)(h,{size:`sm`,variant:`plain`,className:`ml-auto`,onClick:n,children:i(`key.forget`)})]}),(0,S.jsxs)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:[i(`key.clients`),`: `,l,` · `,i(`key.timeZone`,{zone:e.timeZone})]}),(0,S.jsx)(d,{ariaLabel:i(`key.title`),value:s,onChange:c,items:[{value:`overview`,label:i(`key.tab.overview`)},{value:`stats`,label:i(`key.tab.stats`)},{value:`requests`,label:i(`key.tab.requests`)}]})]}),s===`stats`&&(0,S.jsx)(k,{apiKey:t}),s===`requests`&&(0,S.jsx)(M,{apiKey:t}),s===`overview`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:i(`key.limits`)}),e.limits.length===0&&e.rpm==null&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:i(`key.unlimited`)}),(0,S.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:e.limits.map(e=>{let t=t=>e.metric===`cost`?o(t):u(t,!0),n=Math.max(0,Math.min(100,Math.round(e.usedPercent))),s=n>=90?`var(--danger)`:n>=70?`var(--warning)`:`var(--accent)`,c=`${i(`tokens.period.${e.period}`)} · ${i(`tokens.metric.${e.metric}`)}`;return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[12px]`,children:[(0,S.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:c}),(0,S.jsxs)(`span`,{className:`num`,children:[t(e.used),` / `,t(e.limit)]})]}),(0,S.jsx)(`div`,{role:`progressbar`,"aria-label":c,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${n}%`,background:s}})}),(0,S.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:[e.exhausted?i(`key.exhausted`):``,e.exhausted&&e.resetsAt?` · `:``,e.resetsAt?i(`key.resets`,{time:r(e.resetsAt,a)}):``]})]},`${e.metric}:${e.period}`)})}),e.rpm&&(0,S.jsx)(`p`,{className:`num text-[12px] text-[var(--text-secondary)]`,children:i(`key.rpm`,{used:e.rpm.used,limit:e.rpm.limit})})]}),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:i(`key.usage`)}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.tokens`)})]})}),(0,S.jsx)(`tbody`,{children:m.map(([e,t])=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`py-1 text-left font-medium text-[var(--text-secondary)]`,children:e}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:o(t.costUsd)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(t.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(t.inputTokens+t.outputTokens,!0)})]},e))})]})}),(0,S.jsx)(`h4`,{className:`mt-2 text-[12px] text-[var(--text-muted)]`,children:i(`key.daily`)}),(0,S.jsx)(`div`,{className:`flex h-24 items-end gap-[2px]`,role:`list`,"aria-label":i(`key.daily`),children:e.daily.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.day} · ${o(e.costUsd)} · ${u(e.requests)} ${i(`key.requests`)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${g>0?Math.max(2,e.costUsd/g*100):2}%`,opacity:e.costUsd>0?1:.25}},e.day))})]})]})]})}var O=[`today`,`7d`,`30d`,`90d`];function k({apiKey:e}){let{t}=f(),[r,i]=(0,x.useState)(`7d`),[a,s]=(0,x.useState)(null),[c,h]=(0,x.useState)(null);(0,x.useEffect)(()=>{let n=!0;return h(null),l(e,r).then(e=>n&&s(e),e=>n&&h(t(`key.error`,{error:e.message}))),()=>{n=!1}},[e,r,t]);let _=a?.summary,v=Math.max(...(a?.series??[]).map(e=>e.requests),0);return(0,S.jsxs)(`section`,{className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(d,{ariaLabel:t(`overview.range`),value:r,onChange:i,items:O.map(e=>({value:e,label:t(`range.${e}`)}))}),c&&(0,S.jsx)(g,{tone:`danger`,title:c}),!a||!_?!c&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:`…`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,S.jsx)(A,{label:t(`key.stats.requests`),value:u(_.requests)}),(0,S.jsx)(A,{label:t(`key.stats.successRate`),value:_.requests?m(_.successRate):`—`}),(0,S.jsx)(A,{label:t(`key.cost`),value:o(_.costUsd)}),(0,S.jsx)(A,{label:t(`key.stats.avgTtft`),value:n(_.avgTtftMs)})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.trend`)}),(0,S.jsx)(`div`,{className:`flex h-20 items-end gap-[2px]`,role:`list`,"aria-label":t(`key.stats.trend`),children:a.series.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.bucket} · ${u(e.requests)} ${t(`key.requests`)} · ${o(e.costUsd)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${v>0?Math.max(2,e.requests/v*100):2}%`}},e.bucket))})]}),(0,S.jsx)(j,{title:t(`key.stats.byModel`),rows:a.models.map(e=>({name:e.model??`—`,...e}))}),(0,S.jsx)(j,{title:t(`key.stats.byClient`),rows:a.clients.map(e=>({name:e.client?y[e.client]?.name??e.client:t(`key.stats.direct`),...e}))}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.errors`)}),a.errors.length===0?(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`key.stats.noErrors`)}):(0,S.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:a.errors.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(p,{tone:`orange`,children:[t(`key.category.${e.category}`),` · `,u(e.count)]})},e.category))})]}),a.retentionDays!=null&&(0,S.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`key.stats.retention`,{days:a.retentionDays})})]})]})}function A({label:e,value:t}){return(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`div`,{className:`num truncate text-[17px] font-semibold`,children:t})]})}function j({title:e,rows:t}){let{t:n}=f();return t.length===0?null:(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`caption`,{className:`mb-1 text-left text-[12px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.stats.successRate`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.cost`)})]})}),(0,S.jsx)(`tbody`,{children:t.map(e=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`max-w-[240px] truncate py-1 text-left font-medium text-[var(--text-secondary)]`,children:e.name}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(e.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:e.requests?m(e.successRequests/e.requests):`—`}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(e.inputTokens+e.outputTokens,!0)}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:o(e.costUsd)})]},e.name))})]})})}function M({apiKey:e}){let{t,locale:a}=f(),[s,c]=(0,x.useState)(`all`),[l,m]=(0,x.useState)([]),[v,b]=(0,x.useState)(null),[C,w]=(0,x.useState)(!1),[T,E]=(0,x.useState)(null),D=(0,x.useCallback)(async n=>{w(!0),E(null);try{let t=await _(e,{before:n,status:s===`failed`?N:void 0});m(e=>n?[...e,...t.items]:t.items),b(t.nextBefore??null)}catch(e){E(t(`key.error`,{error:e.message}))}finally{w(!1)}},[e,s,t]);return(0,x.useEffect)(()=>{D(null)},[D]),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(d,{ariaLabel:t(`key.requests.status`),value:s,onChange:c,items:[{value:`all`,label:t(`key.requests.all`)},{value:`failed`,label:t(`key.requests.failed`)}]}),T&&(0,S.jsx)(g,{tone:`danger`,title:T}),l.length===0&&!C&&!T&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`key.requests.empty`)}),l.length>0&&(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.time`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.model`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.client`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.status`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.latency`)})]})}),(0,S.jsx)(`tbody`,{children:l.map(e=>(0,S.jsxs)(`tr`,{className:`border-t border-[var(--border-subtle)]`,children:[(0,S.jsx)(`td`,{className:`py-1.5 whitespace-nowrap text-[var(--text-secondary)]`,title:r(e.time,a),children:i(e.time,a)}),(0,S.jsx)(`td`,{className:`max-w-[200px] truncate py-1.5 font-mono`,title:e.model??``,children:e.model??`—`}),(0,S.jsx)(`td`,{className:`py-1.5 text-[var(--text-secondary)]`,children:e.client?y[e.client]?.name??e.client:t(`key.stats.direct`)}),(0,S.jsx)(`td`,{className:`py-1.5`,children:e.errorCategory?(0,S.jsx)(p,{tone:`orange`,title:e.httpStatus?`HTTP ${e.httpStatus}`:void 0,children:t(`key.category.${e.errorCategory}`)}):(0,S.jsx)(p,{tone:`green`,children:t(`key.requests.success`)})}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right`,children:[u(e.inputTokens,!0),` / `,u(e.outputTokens,!0)]}),(0,S.jsx)(`td`,{className:`num py-1.5 text-right font-semibold`,children:o(e.costUsd)}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right text-[var(--text-secondary)]`,children:[n(e.ttftMs),` / `,n(e.totalMs)]})]},e.id))})]})}),v&&(0,S.jsx)(`div`,{children:(0,S.jsx)(h,{size:`sm`,loading:C,onClick:()=>void D(v),children:t(`key.requests.more`)})})]})}var N=`upstream_error,gateway_error,client_cancelled,blocked`;export{E as KeyPage};
@@ -0,0 +1 @@
1
+ import{Ci as e,Fa as t,H as n,Mn as r,Pa as i,Ra as a,Xn as o,an as s,ct as c,d as l,g as u,in as d,l as f,m as p,n as m,p as h,r as g,rt as _,t as v,u as y,ui as b,v as x,xr as S,y as ee}from"./alert-CMMOyMsp.js";import{a as C,i as w,o as T,r as E}from"./overlays-BFrvqpMl.js";import{t as D}from"./arrow-left-BYi8J86q.js";import{t as O}from"./pencil-BMnmsFVj.js";import{t as k}from"./rotate-ccw-Bhx85LK2.js";import{$ as A,N as j,Q as M,X as te,h as N,i as ne,o as P,z as F}from"./index-Ck4Qlg9B.js";import{t as I}from"./checkbox--x0D0yfB.js";import{t as L}from"./confirm-morph-BLco2mdX.js";var R=a(t(),1),z=i(),B=[{key:`vision`,label:`cap.vision`},{key:`tools`,label:`cap.tools`},{key:`reasoning`,label:`cap.reasoning`},{key:`promptCache`,label:`cap.promptCache`},{key:`audio`,label:`cap.audio`},{key:`pdf`,label:`cap.pdf`},{key:`structuredOutput`,label:`cap.structuredOutput`}];function V(e){return{displayName:e.displayName,vendor:e.vendor,family:e.family??null,aliases:e.aliases,contextWindow:e.contextWindow??null,maxOutputTokens:e.maxOutputTokens??null,capabilities:e.capabilities,pricing:e.pricing??null,enabled:e.enabled}}function H(){let{t:e,locale:t}=c(),i=M(),{id:a=``}=A(),o=decodeURIComponent(a),s=r(o),f=b(o),w=S(o),E=d(),{toast:O}=T(),j=(0,R.useMemo)(()=>s.data?V(s.data):null,[s.data]),[F,L]=(0,R.useState)(j),[H,G]=(0,R.useState)(``);(0,R.useEffect)(()=>{L(j),G(j?.aliases?.join(`, `)??``)},[j]);let q=(0,z.jsx)(g,{variant:`glass`,icon:(0,z.jsx)(D,{className:`size-4`}),"aria-label":e(`common.back`),onClick:()=>i(`/models`)});if(s.isError)return(0,z.jsx)(N,{title:e(`nav.models`),leading:q,children:(0,z.jsx)(v,{tone:`danger`,title:e(`common.error`),children:C(s.error)})});let J=s.data;if(!J||!F)return(0,z.jsx)(N,{title:``,leading:q,children:(0,z.jsx)(x,{lines:5,className:`mx-auto max-w-[1100px]`})});let Y=e=>L(t=>({...t,...e})),X={...F,aliases:H.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)},Z=JSON.stringify(X)!==JSON.stringify(j),re=new Set(J.userModifiedFields),Q=J.source===`seed`,ie=()=>f.mutate(X,{onSuccess:()=>O(e(`common.saved`),`success`),onError:e=>O(C(e),`error`)}),$=t=>re.has(t)?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(m,{tone:`orange`,children:e(`models.modified`)}),Q&&(0,z.jsx)(g,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(k,{className:`size-3`}),title:e(`models.resetField`),"aria-label":e(`models.resetField`),onClick:()=>w.mutate(t,{onSuccess:()=>O(e(`models.fieldReset`)),onError:e=>O(C(e),`error`)})})]}):null;return(0,z.jsx)(N,{title:J.displayName,subtitle:`${J.id} · ${e(`models.source.${J.source}`)} · ${e(`models.updated`,{time:n(J.updatedAt,t)})}`,leading:q,actions:(0,z.jsxs)(z.Fragment,{children:[J.source===`user`&&(0,z.jsx)(K,{label:e(`common.delete`),prompt:e(`models.deleteConfirm`,{id:J.id}),onConfirm:async()=>{await E.mutateAsync(J.id),i(`/models`)}}),Z&&(0,z.jsx)(g,{onClick:()=>{L(j),G(j?.aliases?.join(`, `)??``)},children:e(`common.revert`)}),(0,z.jsx)(g,{variant:`primary`,disabled:!Z,loading:f.isPending,onClick:ie,children:e(`common.save`)})]}),children:(0,z.jsxs)(`div`,{className:`mx-auto grid max-w-[1100px] gap-x-6 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(y,{title:e(`models.section.basic`),footer:Q?e(`models.modifiedFooter`):void 0,children:[(0,z.jsx)(U,{label:e(`models.field.displayName`),marker:$(`displayName`),children:(0,z.jsx)(l,{className:`w-60`,"aria-label":e(`models.field.displayName`),value:F.displayName,onChange:e=>Y({displayName:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.vendor`),children:(0,z.jsx)(l,{className:`w-60`,"aria-label":e(`models.field.vendor`),value:F.vendor,onChange:e=>Y({vendor:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.family`),marker:$(`family`),children:(0,z.jsx)(l,{className:`w-60`,"aria-label":e(`models.field.family`),value:F.family??``,onChange:e=>Y({family:e.target.value||null})})}),(0,z.jsx)(U,{label:e(`models.field.aliases`),marker:$(`aliases`),children:(0,z.jsx)(l,{className:`w-60 font-mono`,"aria-label":e(`models.field.aliases`),value:H,onChange:e=>G(e.target.value),placeholder:`a, b, c`})}),(0,z.jsx)(U,{label:e(`models.field.contextWindow`),marker:$(`contextWindow`),children:(0,z.jsx)(h,{className:`w-36`,label:e(`models.field.contextWindow`),value:F.contextWindow,onChange:e=>Y({contextWindow:e})})}),(0,z.jsx)(U,{label:e(`models.field.maxOutputTokens`),marker:$(`maxOutputTokens`),children:(0,z.jsx)(h,{className:`w-36`,label:e(`models.field.maxOutputTokens`),value:F.maxOutputTokens,onChange:e=>Y({maxOutputTokens:e})})}),(0,z.jsx)(U,{label:e(`common.enabled`),children:(0,z.jsx)(ee,{checked:F.enabled??!0,label:e(`common.enabled`),onChange:e=>Y({enabled:e})})})]}),(0,z.jsx)(y,{title:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e(`models.section.capabilities`),` `,$(`capabilities`)]}),children:(0,z.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 px-4 py-4`,children:B.map(t=>(0,z.jsx)(I,{label:e(t.label),checked:!!F.capabilities?.[t.key],onCheckedChange:e=>Y({capabilities:{...F.capabilities,[t.key]:e===!0}})},t.key))})}),(0,z.jsx)(W,{model:J}),J.providerOverrides.length>0&&(0,z.jsx)(y,{title:e(`models.section.overrides`),footer:e(`models.overridesFooter`),children:J.providerOverrides.map(e=>(0,z.jsx)(p,{label:(0,z.jsx)(te,{className:`text-[var(--accent)]`,to:`/providers/${e.providerId}`,children:e.providerName}),detail:`${e.modelId} · ${_(e.pricing)}`},e.providerModelId))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(u,{action:$(`pricing`),children:e(`models.section.pricing`)}),(0,z.jsx)(`p`,{className:`mb-3 px-1 text-[12px] text-[var(--text-secondary)]`,children:e(`models.pricingHint`)}),(0,z.jsx)(`div`,{className:`card p-4`,children:(0,z.jsx)(P,{value:F.pricing??null,onChange:e=>Y({pricing:e}),allowEmpty:!0})})]}),(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(u,{children:e(`models.section.simulator`)}),(0,z.jsxs)(`div`,{className:`card p-4`,children:[(0,z.jsx)(ne,{modelId:Z?void 0:J.id,pricing:Z?X.pricing:null}),Z&&(0,z.jsx)(`p`,{className:`mt-3 text-[12px] text-[var(--text-muted)]`,children:e(`models.simulatorUnsaved`)})]})]})]})]})})}function U({label:e,marker:t,children:n}){return(0,z.jsx)(p,{label:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e,t]}),children:n})}function W({model:e}){let{t}=c(),n=s(e.id),[r,i]=(0,R.useState)(null);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(y,{title:(0,z.jsxs)(`span`,{className:`flex items-center justify-between`,children:[t(`models.section.providerPrices`),(0,z.jsx)(g,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(F,{className:`size-3.5`}),onClick:()=>i(`new`),children:t(`common.add`)})]}),footer:t(`models.providerPricesFooter`),children:[e.providerPrices.length===0&&(0,z.jsx)(p,{label:(0,z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`models.noProviderPrices`)})}),e.providerPrices.map(e=>(0,z.jsxs)(p,{label:(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[12.5px]`,children:e.priceKey}),e.userModified&&(0,z.jsx)(m,{tone:`orange`,children:t(`models.modified`)})]}),detail:[_(e.pricing),e.upstreamModelId,e.pricing.time_windows?.length?t(`models.hasTimeWindows`):null,e.pricing.context_tiers?.length?t(`models.hasTiers`):null].filter(Boolean).join(` · `),children:[(0,z.jsx)(g,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(O,{className:`size-3.5`}),"aria-label":t(`common.edit`),onClick:()=>i(e)}),(0,z.jsx)(K,{label:t(`common.delete`),prompt:t(`models.deletePrice`,{key:e.priceKey}),onConfirm:()=>n.mutateAsync(e.priceKey)})]},e.priceKey))]}),(0,z.jsx)(G,{model:e,editing:r,onClose:()=>i(null)})]})}function G({model:t,editing:n,onClose:r}){let{t:i}=c(),{toast:a}=T(),s=o(),u=e(t.id),d=n===`new`,[p,m]=(0,R.useState)(``),[h,_]=(0,R.useState)(``),[v,y]=(0,R.useState)(null);(0,R.useEffect)(()=>{n&&(n===`new`?(m(``),_(``),y(t.pricing?structuredClone(t.pricing):{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}})):(m(n.priceKey),_(n.upstreamModelId??``),y(structuredClone(n.pricing))))},[n,t.pricing]);let b=new Set(t.providerPrices.map(e=>e.priceKey));return(0,z.jsx)(w,{open:n!==null,onOpenChange:e=>!e&&r(),width:680,title:d?i(`models.addPrice`):i(`models.editPrice`,{key:p}),description:i(`models.priceSheetDetail`),footer:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(g,{onClick:r,children:i(`common.cancel`)}),(0,z.jsx)(g,{variant:`primary`,disabled:!p||!v,loading:u.isPending,onClick:()=>u.mutate({priceKey:p,upstreamModelId:h||null,pricing:v},{onSuccess:()=>{a(i(`common.saved`),`success`),r()},onError:e=>a(C(e),`error`)}),children:i(`common.save`)})]}),children:(0,z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,z.jsx)(f,{label:i(`providers.priceKey`),children:d?(0,z.jsx)(E,{value:p,onChange:m,placeholder:i(`models.pickPriceKey`),options:(s.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey,disabled:b.has(e.priceKey)}))}):(0,z.jsx)(l,{value:p,disabled:!0,className:`font-mono`})}),(0,z.jsx)(f,{label:i(`models.upstreamId`),hint:i(`models.upstreamIdHint`),children:(0,z.jsx)(l,{className:`font-mono`,value:h,onChange:e=>_(e.target.value),placeholder:t.id})})]}),d&&(0,z.jsx)(l,{className:`font-mono`,"aria-label":i(`models.customPriceKey`),placeholder:i(`models.customPriceKey`),value:p,onChange:e=>m(e.target.value.trim())}),(0,z.jsx)(P,{value:v,onChange:y})]})})}function K({label:e,prompt:t,onConfirm:n}){let{t:r}=c();return(0,z.jsx)(L,{label:e,icon:(0,z.jsx)(j,{className:`size-4`}),prompt:t,confirmLabel:r(`common.delete`),cancelLabel:r(`common.cancel`),pendingLabel:r(`common.deleting`),doneLabel:r(`common.deleted`),errorLabel:r(`common.error`),retryLabel:r(`common.retry`),onConfirm:n})}export{H as ModelDetailPage};
@@ -1 +1 @@
1
- import{$t as e,Gr as t,La as n,Na as r,Nn as i,Pa as a,V as o,Wr as s,Z as c,c as l,ct as u,d,h as f,l as p,n as m,nt as h,ot as g,p as _,r as v,t as y,v as b}from"./alert-DRuYOIBF.js";import{a as x,i as S,o as C,r as w}from"./overlays-CHP5oojo.js";import{t as T}from"./cloud-download-BCNvV9ef.js";import{D as E,H as D,M as O,Q as k,W as A,h as j,j as M,z as N}from"./index-DorAVedK.js";import{t as P}from"./checkbox-BP7SY0L6.js";var F=n(a(),1),I=r();function L(){let{t:e}=u(),t=k(),[n,r]=(0,F.useState)(``),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(!1),[d,p]=(0,F.useState)(!1),m=(0,F.useRef)(null),h=O(n),g=i(),_=i(h,a),S=(0,F.useMemo)(()=>[...new Set((g.data??[]).map(e=>e.vendor))].sort(),[g.data]);return M(e=>{e===`find`&&m.current?.focus()}),(0,I.jsxs)(j,{title:e(`nav.models`),subtitle:_.data?e(`models.count`,{count:_.data.length}):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(f,{inputRef:m,className:`w-52`,value:n,onChange:r,placeholder:e(`models.search`)}),(0,I.jsx)(w,{value:a,onChange:o,options:[{value:``,label:e(`models.allVendors`)},...S.map(e=>({value:e,label:e}))]}),(0,I.jsx)(v,{icon:(0,I.jsx)(T,{className:`size-3.5`}),onClick:()=>p(!0),children:e(`models.sync`)}),(0,I.jsx)(v,{variant:`primary`,icon:(0,I.jsx)(N,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`models.new`)})]}),children:[_.isLoading&&(0,I.jsx)(b,{lines:5}),_.isError&&(0,I.jsx)(y,{tone:`danger`,title:e(`common.error`),children:x(_.error)}),_.data?.length===0&&(0,I.jsx)(l,{icon:(0,I.jsx)(A,{className:`size-6`}),title:e(`models.empty`)}),_.data&&_.data.length>0&&(0,I.jsx)(E,{caption:e(`nav.models`),rowKey:`id`,rows:_.data.map(e=>({id:e.id,name:e.displayName,vendor:e.vendor,context:e.contextWindow??0,input:e.pricing?.base.input??0,providerPrices:e.providerPriceKeys.length,m:e})),columns:R(e,e=>t(`/models/${encodeURIComponent(e)}`))}),(0,I.jsx)(z,{open:s,onOpenChange:c,onCreated:e=>t(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:d,onOpenChange:p})]})}function R(e,t){return[{key:`name`,label:e(`models.col.model`),render:(n,r)=>(0,I.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>t(r.id),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:g(`truncate font-medium hover:text-[var(--accent)]`,!r.m.enabled&&`text-[var(--text-muted)]`),children:r.name}),r.m.source===`user`&&(0,I.jsx)(m,{tone:`accent`,children:e(`models.source.user`)}),r.m.userModifiedFields.length>0&&(0,I.jsx)(m,{tone:`orange`,children:e(`models.modified`)})]}),(0,I.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-[var(--text-muted)]`,children:r.id})]})},{key:`vendor`,label:e(`models.col.vendor`),width:120},{key:`context`,label:e(`models.col.context`),numeric:!0,width:96,render:(e,t)=>o(t.m.contextWindow)},{key:`input`,label:e(`models.col.price`),numeric:!0,width:150,render:(e,t)=>{let n=t.m.pricing?.base;return n?`${c(n.input)} / ${c(n.output)}`:`—`}},{key:`providerPrices`,label:e(`models.col.providerPrices`),numeric:!0,width:130,render:(t,n)=>n.providerPrices?e(`models.providerPriceCount`,{count:n.providerPrices}):`—`}]}function z({open:t,onOpenChange:n,onCreated:r}){let{t:i}=u(),{toast:a}=C(),o=e(),[s,c]=(0,F.useState)(``),[l,f]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[g,y]=(0,F.useState)(null),[b,w]=(0,F.useState)(null),[T,E]=(0,F.useState)(null);return(0,I.jsx)(S,{open:t,onOpenChange:n,title:i(`models.new`),description:i(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(v,{onClick:()=>n(!1),children:i(`common.cancel`)}),(0,I.jsx)(v,{variant:`primary`,disabled:!s.trim()||!m.trim(),loading:o.isPending,onClick:()=>o.mutate({id:s.trim(),displayName:l.trim()||s.trim(),vendor:m.trim(),contextWindow:g,pricing:b!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:b,output:T}}:null},{onSuccess:e=>{n(!1),c(``),f(``),r(e.id)},onError:e=>a(x(e),`error`)}),children:i(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(p,{label:i(`models.field.id`),hint:i(`models.field.idHint`),children:(0,I.jsx)(d,{className:`font-mono`,value:s,onChange:e=>c(e.target.value),placeholder:`my-model-1`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsx)(p,{label:i(`models.field.displayName`),children:(0,I.jsx)(d,{value:l,onChange:e=>f(e.target.value)})}),(0,I.jsx)(p,{label:i(`models.field.vendor`),children:(0,I.jsx)(d,{value:m,onChange:e=>h(e.target.value),placeholder:`openai`})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,I.jsx)(p,{label:i(`models.field.contextWindow`),children:(0,I.jsx)(_,{value:g,onChange:y})}),(0,I.jsx)(p,{label:i(`models.field.inputPrice`),children:(0,I.jsx)(_,{value:b,onChange:w})}),(0,I.jsx)(p,{label:i(`models.field.outputPrice`),children:(0,I.jsx)(_,{value:T,onChange:E})})]})]})})}var B=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function V(e,t=``,n=new Map){if(B(e)&&Object.keys(e).length>0)for(let[r,i]of Object.entries(e))V(i,t?`${t}.${r}`:r,n);else e!=null&&n.set(t,e);return n}function H(e,t){let n=V(e),r=V(t);return[...r.keys(),...[...n.keys()].filter(e=>!r.has(e))].filter(e=>JSON.stringify(n.get(e))!==JSON.stringify(r.get(e))).map(e=>({path:e.replace(/^pricing\./,``),before:n.get(e),after:r.get(e)}))}var U=e=>typeof e==`string`?e:JSON.stringify(e),W=4;function G({before:e,after:t}){let{t:n}=u(),r=H(e,t),i=r.length-W;return(0,I.jsxs)(`span`,{className:`flex w-full min-w-0 flex-col gap-0.5 font-mono text-[11px] leading-snug`,title:`${h(e)||`∅`}\n→\n${h(t)||`∅`}`,children:[r.slice(0,W).map(e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5 whitespace-nowrap`,children:[e.path&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e.path}),e.before!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--danger)] line-through opacity-80`,children:U(e.before)}),e.before!==void 0&&e.after!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:`→`}),e.after!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--success)]`,children:U(e.after)})]},e.path)),i>0&&(0,I.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:n(`models.sync.more`,{n:i})})]})}function K({changes:e,label:t,checked:n,onChange:r}){let{t:i}=u(),[a,o]=(0,F.useState)(new Set),s=(0,F.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.modelId,[...t.get(n.modelId)??[],n]);return[...t]},[e]),c=e=>{let t=e.filter(e=>n.has(e)).length;return t===0?!1:t===e.length||`indeterminate`},l=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n):i.delete(n);r(i)},d=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),f=e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1`,children:[(0,I.jsxs)(`span`,{className:`flex flex-wrap gap-1`,children:[(0,I.jsx)(m,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(m,{tone:`orange`,children:i(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),p=e.map(e=>e.id);return(0,I.jsx)(`div`,{className:`card max-h-[520px] overflow-auto`,children:(0,I.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,I.jsxs)(`li`,{className:`sticky top-0 z-10 flex items-center gap-3 bg-[var(--surface)] px-4 py-2`,children:[(0,I.jsx)(P,{checked:c(p),onCheckedChange:e=>l(p,e!==!1),"aria-label":i(`models.sync.selectAll`)}),(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`models.sync.selectedOf`,{n:n.size,total:p.length,models:s.length})})]}),s.map(([e,r])=>{let o=r.map(e=>e.id),s=r.length===1?r[0]:void 0,u=!a.has(e);return(0,I.jsxs)(`li`,{className:`px-4 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:c(o),onCheckedChange:e=>l(o,e!==!1),"aria-label":e,className:`mt-0.5`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[s?(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}):(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-1 text-left`,"aria-expanded":u,onClick:()=>d(e),children:[(0,I.jsx)(D,{className:g(`size-3.5 shrink-0 text-[var(--text-muted)] transition-transform`,u&&`rotate-90`)}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}),(0,I.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-[var(--text-muted)]`,children:i(`models.sync.groupCount`,{n:r.length})})]}),s&&f(s)]})]}),!s&&u&&(0,I.jsx)(`ul`,{className:`mt-2 ml-7 flex flex-col gap-2 border-l border-[var(--border)] pl-3`,children:r.map(r=>(0,I.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:n.has(r.id),onCheckedChange:e=>l([r.id],e!==!1),"aria-label":`${e} ${t(r)}`,className:`mt-0.5`}),f(r)]},r.id))})]},e)})]})})}function q({open:e,onOpenChange:n}){let{t:r}=u(),{toast:i}=C(),a=t(),o=s(),[c,l]=(0,F.useState)(new Set),d=()=>a.mutate(void 0,{onSuccess:e=>l(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),f=a.data?.changes??[];return(0,I.jsxs)(S,{open:e,onOpenChange:e=>{n(e),e&&!a.data&&d()},width:720,title:r(`models.sync`),description:r(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(v,{className:`mr-auto`,variant:`plain`,onClick:d,loading:a.isPending,children:r(`common.refresh`)}),(0,I.jsx)(v,{onClick:()=>n(!1),children:r(`common.cancel`)}),(0,I.jsx)(v,{variant:`primary`,disabled:c.size===0,loading:o.isPending,onClick:()=>o.mutate([...c],{onSuccess:e=>{i(r(`models.sync.applied`,{count:e.applied}),`success`),n(!1),a.reset()},onError:e=>i(x(e),`error`)}),children:r(`models.sync.apply`,{count:c.size})})]}),children:[e&&!a.data&&!a.isPending&&!a.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(v,{variant:`primary`,onClick:d,children:r(`models.sync.check`)})}),a.isPending&&(0,I.jsx)(b,{lines:4}),a.isError&&(0,I.jsx)(y,{tone:`danger`,title:r(`common.error`),children:x(a.error)}),a.data&&f.length===0&&(0,I.jsx)(y,{tone:`success`,title:r(`models.sync.none`)}),f.length>0&&(0,I.jsx)(K,{changes:f,label:e=>e.kind===`new_model`?r(`models.sync.newModel`):e.kind===`price`?r(`models.sync.price`,{key:e.priceKey??``}):r(`models.sync.field`,{field:e.field??``}),checked:c,onChange:l})]})}export{L as ModelsPage};
1
+ import{$t as e,Fa as t,Gr as n,Nn as r,Pa as i,Ra as a,V as o,Wr as s,Z as c,c as l,ct as u,d,h as f,l as p,n as m,nt as h,ot as g,p as _,r as v,t as y,v as b}from"./alert-CMMOyMsp.js";import{a as x,i as S,o as C,r as w}from"./overlays-BFrvqpMl.js";import{t as T}from"./cloud-download-BkOTPIzF.js";import{D as E,H as D,M as O,Q as k,W as A,h as j,j as M,z as N}from"./index-Ck4Qlg9B.js";import{t as P}from"./checkbox--x0D0yfB.js";var F=a(t(),1),I=i();function L(){let{t:e}=u(),t=k(),[n,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(!1),[d,p]=(0,F.useState)(!1),m=(0,F.useRef)(null),h=O(n),g=r(),_=r(h,a),S=(0,F.useMemo)(()=>[...new Set((g.data??[]).map(e=>e.vendor))].sort(),[g.data]);return M(e=>{e===`find`&&m.current?.focus()}),(0,I.jsxs)(j,{title:e(`nav.models`),subtitle:_.data?e(`models.count`,{count:_.data.length}):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(f,{inputRef:m,className:`w-52`,value:n,onChange:i,placeholder:e(`models.search`)}),(0,I.jsx)(w,{value:a,onChange:o,options:[{value:``,label:e(`models.allVendors`)},...S.map(e=>({value:e,label:e}))]}),(0,I.jsx)(v,{icon:(0,I.jsx)(T,{className:`size-3.5`}),onClick:()=>p(!0),children:e(`models.sync`)}),(0,I.jsx)(v,{variant:`primary`,icon:(0,I.jsx)(N,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`models.new`)})]}),children:[_.isLoading&&(0,I.jsx)(b,{lines:5}),_.isError&&(0,I.jsx)(y,{tone:`danger`,title:e(`common.error`),children:x(_.error)}),_.data?.length===0&&(0,I.jsx)(l,{icon:(0,I.jsx)(A,{className:`size-6`}),title:e(`models.empty`)}),_.data&&_.data.length>0&&(0,I.jsx)(E,{caption:e(`nav.models`),rowKey:`id`,rows:_.data.map(e=>({id:e.id,name:e.displayName,vendor:e.vendor,context:e.contextWindow??0,input:e.pricing?.base.input??0,providerPrices:e.providerPriceKeys.length,m:e})),columns:R(e,e=>t(`/models/${encodeURIComponent(e)}`))}),(0,I.jsx)(z,{open:s,onOpenChange:c,onCreated:e=>t(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:d,onOpenChange:p})]})}function R(e,t){return[{key:`name`,label:e(`models.col.model`),render:(n,r)=>(0,I.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>t(r.id),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:g(`truncate font-medium hover:text-[var(--accent)]`,!r.m.enabled&&`text-[var(--text-muted)]`),children:r.name}),r.m.source===`user`&&(0,I.jsx)(m,{tone:`accent`,children:e(`models.source.user`)}),r.m.userModifiedFields.length>0&&(0,I.jsx)(m,{tone:`orange`,children:e(`models.modified`)})]}),(0,I.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-[var(--text-muted)]`,children:r.id})]})},{key:`vendor`,label:e(`models.col.vendor`),width:120},{key:`context`,label:e(`models.col.context`),numeric:!0,width:96,render:(e,t)=>o(t.m.contextWindow)},{key:`input`,label:e(`models.col.price`),numeric:!0,width:150,render:(e,t)=>{let n=t.m.pricing?.base;return n?`${c(n.input)} / ${c(n.output)}`:`—`}},{key:`providerPrices`,label:e(`models.col.providerPrices`),numeric:!0,width:130,render:(t,n)=>n.providerPrices?e(`models.providerPriceCount`,{count:n.providerPrices}):`—`}]}function z({open:t,onOpenChange:n,onCreated:r}){let{t:i}=u(),{toast:a}=C(),o=e(),[s,c]=(0,F.useState)(``),[l,f]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[g,y]=(0,F.useState)(null),[b,w]=(0,F.useState)(null),[T,E]=(0,F.useState)(null);return(0,I.jsx)(S,{open:t,onOpenChange:n,title:i(`models.new`),description:i(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(v,{onClick:()=>n(!1),children:i(`common.cancel`)}),(0,I.jsx)(v,{variant:`primary`,disabled:!s.trim()||!m.trim(),loading:o.isPending,onClick:()=>o.mutate({id:s.trim(),displayName:l.trim()||s.trim(),vendor:m.trim(),contextWindow:g,pricing:b!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:b,output:T}}:null},{onSuccess:e=>{n(!1),c(``),f(``),r(e.id)},onError:e=>a(x(e),`error`)}),children:i(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(p,{label:i(`models.field.id`),hint:i(`models.field.idHint`),children:(0,I.jsx)(d,{className:`font-mono`,value:s,onChange:e=>c(e.target.value),placeholder:`my-model-1`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsx)(p,{label:i(`models.field.displayName`),children:(0,I.jsx)(d,{value:l,onChange:e=>f(e.target.value)})}),(0,I.jsx)(p,{label:i(`models.field.vendor`),children:(0,I.jsx)(d,{value:m,onChange:e=>h(e.target.value),placeholder:`openai`})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,I.jsx)(p,{label:i(`models.field.contextWindow`),children:(0,I.jsx)(_,{value:g,onChange:y})}),(0,I.jsx)(p,{label:i(`models.field.inputPrice`),children:(0,I.jsx)(_,{value:b,onChange:w})}),(0,I.jsx)(p,{label:i(`models.field.outputPrice`),children:(0,I.jsx)(_,{value:T,onChange:E})})]})]})})}var B=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function V(e,t=``,n=new Map){if(B(e)&&Object.keys(e).length>0)for(let[r,i]of Object.entries(e))V(i,t?`${t}.${r}`:r,n);else e!=null&&n.set(t,e);return n}function H(e,t){let n=V(e),r=V(t);return[...r.keys(),...[...n.keys()].filter(e=>!r.has(e))].filter(e=>JSON.stringify(n.get(e))!==JSON.stringify(r.get(e))).map(e=>({path:e.replace(/^pricing\./,``),before:n.get(e),after:r.get(e)}))}var U=e=>typeof e==`string`?e:JSON.stringify(e),W=4;function G({before:e,after:t}){let{t:n}=u(),r=H(e,t),i=r.length-W;return(0,I.jsxs)(`span`,{className:`flex w-full min-w-0 flex-col gap-0.5 font-mono text-[11px] leading-snug`,title:`${h(e)||`∅`}\n→\n${h(t)||`∅`}`,children:[r.slice(0,W).map(e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5 whitespace-nowrap`,children:[e.path&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e.path}),e.before!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--danger)] line-through opacity-80`,children:U(e.before)}),e.before!==void 0&&e.after!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:`→`}),e.after!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--success)]`,children:U(e.after)})]},e.path)),i>0&&(0,I.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:n(`models.sync.more`,{n:i})})]})}function K({changes:e,label:t,checked:n,onChange:r}){let{t:i}=u(),[a,o]=(0,F.useState)(new Set),s=(0,F.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.modelId,[...t.get(n.modelId)??[],n]);return[...t]},[e]),c=e=>{let t=e.filter(e=>n.has(e)).length;return t===0?!1:t===e.length||`indeterminate`},l=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n):i.delete(n);r(i)},d=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),f=e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1`,children:[(0,I.jsxs)(`span`,{className:`flex flex-wrap gap-1`,children:[(0,I.jsx)(m,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(m,{tone:`orange`,children:i(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),p=e.map(e=>e.id);return(0,I.jsx)(`div`,{className:`card max-h-[520px] overflow-auto`,children:(0,I.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,I.jsxs)(`li`,{className:`sticky top-0 z-10 flex items-center gap-3 bg-[var(--surface)] px-4 py-2`,children:[(0,I.jsx)(P,{checked:c(p),onCheckedChange:e=>l(p,e!==!1),"aria-label":i(`models.sync.selectAll`)}),(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`models.sync.selectedOf`,{n:n.size,total:p.length,models:s.length})})]}),s.map(([e,r])=>{let o=r.map(e=>e.id),s=r.length===1?r[0]:void 0,u=!a.has(e);return(0,I.jsxs)(`li`,{className:`px-4 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:c(o),onCheckedChange:e=>l(o,e!==!1),"aria-label":e,className:`mt-0.5`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[s?(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}):(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-1 text-left`,"aria-expanded":u,onClick:()=>d(e),children:[(0,I.jsx)(D,{className:g(`size-3.5 shrink-0 text-[var(--text-muted)] transition-transform`,u&&`rotate-90`)}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}),(0,I.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-[var(--text-muted)]`,children:i(`models.sync.groupCount`,{n:r.length})})]}),s&&f(s)]})]}),!s&&u&&(0,I.jsx)(`ul`,{className:`mt-2 ml-7 flex flex-col gap-2 border-l border-[var(--border)] pl-3`,children:r.map(r=>(0,I.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:n.has(r.id),onCheckedChange:e=>l([r.id],e!==!1),"aria-label":`${e} ${t(r)}`,className:`mt-0.5`}),f(r)]},r.id))})]},e)})]})})}function q({open:e,onOpenChange:t}){let{t:r}=u(),{toast:i}=C(),a=n(),o=s(),[c,l]=(0,F.useState)(new Set),d=()=>a.mutate(void 0,{onSuccess:e=>l(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),f=a.data?.changes??[];return(0,I.jsxs)(S,{open:e,onOpenChange:e=>{t(e),e&&!a.data&&d()},width:720,title:r(`models.sync`),description:r(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(v,{className:`mr-auto`,variant:`plain`,onClick:d,loading:a.isPending,children:r(`common.refresh`)}),(0,I.jsx)(v,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,I.jsx)(v,{variant:`primary`,disabled:c.size===0,loading:o.isPending,onClick:()=>o.mutate([...c],{onSuccess:e=>{i(r(`models.sync.applied`,{count:e.applied}),`success`),t(!1),a.reset()},onError:e=>i(x(e),`error`)}),children:r(`models.sync.apply`,{count:c.size})})]}),children:[e&&!a.data&&!a.isPending&&!a.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(v,{variant:`primary`,onClick:d,children:r(`models.sync.check`)})}),a.isPending&&(0,I.jsx)(b,{lines:4}),a.isError&&(0,I.jsx)(y,{tone:`danger`,title:r(`common.error`),children:x(a.error)}),a.data&&f.length===0&&(0,I.jsx)(y,{tone:`success`,title:r(`models.sync.none`)}),f.length>0&&(0,I.jsx)(K,{changes:f,label:e=>e.kind===`new_model`?r(`models.sync.newModel`):e.kind===`price`?r(`models.sync.price`,{key:e.priceKey??``}):r(`models.sync.field`,{field:e.field??``}),checked:c,onChange:l})]})}export{L as ModelsPage};
@@ -1,2 +1,2 @@
1
- import{Bn as e,H as t,Hn as n,Jn as r,Kn as i,La as a,Na as o,Nt as s,Pa as c,Pn as l,Rn as u,Sn as d,Tn as f,_ as p,b as m,bt as h,c as g,ct as _,d as v,f as y,fr as b,h as x,i as S,jn as C,l as w,mt as T,n as E,ot as D,pr as O,r as k,t as A,ui as j,v as M,xt as N,y as P,zn as F}from"./alert-DRuYOIBF.js";import{a as I,i as L,n as ee,o as R}from"./overlays-CHP5oojo.js";import{t as z}from"./arrow-down-wREAClBx.js";import{t as te}from"./download-BGSlqgxA.js";import{t as ne}from"./ellipsis-COWYoRP4.js";import{t as re}from"./external-link-OKfamryM.js";import{$ as ie,C as ae,E as B,F as oe,J as se,K as ce,N as V,Q as H,R as U,T as W,et as le,h as ue,w as G,x as de,z as fe}from"./index-DorAVedK.js";var K={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};K.node;var pe=N(K),q=a(c(),1),J=o(),me=/^(?:(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*|github:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)$/,Y={provider:`plugins.kind.provider`,middleware:`plugins.kind.middleware`,agent:`plugins.kind.agent`,pi:`plugins.kind.pi`},he={provider:`neutral`,middleware:`accent`,agent:`green`,pi:`orange`};function X({name:e,icon:t,kind:n,size:r=32}){let i=Math.round(r*.28);return t&&/^(https:|data:image\/)/i.test(t)?(0,J.jsx)(`img`,{src:t,alt:``,width:r,height:r,className:`shrink-0 object-contain`,style:{borderRadius:i},draggable:!1}):n===`middleware`||n===`agent`?(0,J.jsx)(`span`,{"aria-hidden":!0,className:`inline-flex shrink-0 items-center justify-center text-white`,style:{width:r,height:r,borderRadius:i,background:n===`middleware`?`#0a84ff`:`#30b0a0`},children:(0,J.jsx)(n===`middleware`?oe:se,{className:`size-[55%]`,strokeWidth:1.75})}):(0,J.jsx)(de,{name:e,icon:t,size:r})}function Z(){let{t:e}=_(),t=H(),{tab:n}=ie(),r=n===`market`||n===`runtime`?n:`installed`,a=i(),o=j(),{toast:s}=R(),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(null);return(0,J.jsxs)(ue,{title:e(`nav.plugins`),subtitle:e(`plugins.subtitle`),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(k,{icon:(0,J.jsx)(U,{className:`size-3.5`}),onClick:()=>o.mutate(void 0,{onSuccess:e=>p(e.id),onError:e=>s(I(e),`error`)}),disabled:!a.data?.plugins.length,children:e(`plugins.updateAll`)}),(0,J.jsx)(k,{variant:`primary`,icon:(0,J.jsx)(fe,{className:`size-3.5`}),onClick:()=>l(!0),children:e(`plugins.add`)})]}),children:[(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col`,children:[a.data?.off&&(0,J.jsx)(A,{className:`mb-4`,tone:`warning`,title:e(`plugins.off`),children:e(`plugins.offDetail`)}),(0,J.jsxs)(ae,{value:r,onValueChange:e=>t(e===`installed`?`/plugins`:`/plugins/${e}`,{replace:!0}),children:[(0,J.jsxs)(W,{"aria-label":e(`nav.plugins`),children:[(0,J.jsxs)(B,{value:`installed`,children:[e(`plugins.tab.installed`),a.data&&a.data.plugins.length>0&&(0,J.jsx)(`span`,{className:`ml-1.5 tabular-nums opacity-60`,children:a.data.plugins.length})]}),(0,J.jsx)(B,{value:`market`,children:e(`plugins.tab.market`)}),(0,J.jsx)(B,{value:`runtime`,children:e(`plugins.tab.runtime`)})]}),(0,J.jsxs)(G,{value:`installed`,className:`pt-1`,children:[a.isLoading&&(0,J.jsx)(M,{lines:4}),a.isError&&(0,J.jsx)(A,{tone:`danger`,title:e(`common.error`),children:I(a.error)}),a.data&&(0,J.jsx)(ge,{plugins:a.data.plugins,preferences:a.data.preferences,onJob:p,onBrowse:()=>t(`/plugins/market`),onImport:()=>d(!0)})]}),(0,J.jsx)(G,{value:`market`,className:`pt-1`,children:(0,J.jsx)(Se,{installed:a.data?.plugins??[],onJob:p})}),(0,J.jsx)(G,{value:`runtime`,className:`pt-1`,children:(0,J.jsx)(Ce,{onJob:p})})]})]}),(0,J.jsx)(ye,{open:c,onOpenChange:l,onJob:p}),(0,J.jsx)(be,{open:u,onOpenChange:d,onJob:p}),(0,J.jsx)(xe,{id:f,onClose:()=>p(null)})]})}function ge({plugins:e,preferences:t,onJob:n,onBrowse:r,onImport:i}){let{t:a}=_(),o=u(e.some(e=>e.kinds.includes(`provider`)||e.kinds.includes(`pi`))),s=C(),c=O(),{toast:l}=R(),d=!!(s.data?.found&&s.data.plugins.some(e=>!e.installed))&&(0,J.jsxs)(`div`,{className:`card flex flex-wrap items-center gap-3 p-4`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:a(`plugins.magpie.banner`,{count:s.data.plugins.filter(e=>!e.installed).length})}),(0,J.jsx)(k,{size:`sm`,icon:(0,J.jsx)(te,{className:`size-3.5`}),onClick:i,children:a(`plugins.magpie.import`)})]});if(e.length===0)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(g,{icon:(0,J.jsx)(T,{className:`size-6`}),title:a(`plugins.empty`),detail:a(`plugins.emptyDetail`),action:(0,J.jsx)(k,{variant:`primary`,onClick:r,children:a(`plugins.browseMarket`)})})})]});let f=(t,n)=>{let r=e.map(e=>e.spec),[i]=r.splice(t,1);r.splice(t+n,0,i),c.mutate(r,{onError:e=>l(I(e),`error`)})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:e.map((r,i)=>(0,J.jsx)(_e,{plugin:r,host:o.data,preferences:t,onJob:n,onUp:i>0?()=>f(i,-1):void 0,onDown:i<e.length-1?()=>f(i,1):void 0},r.spec))}),e.some(e=>e.middleware)&&(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:a(`plugins.orderHint`)})]})}function _e({plugin:e,host:t,preferences:n,onJob:i,onUp:a,onDown:o}){let{t:s}=_(),c=H(),{toast:u,confirm:d}=R(),f=l(),p=j(),m=b(),h=r(),[g,v]=(0,q.useState)(!1),y=t?.plugins.find(t=>t.spec===e.spec),x=e.middleware,S=e.kinds[0]??`provider`,C=async()=>{await d({title:s(`plugins.removeConfirm`,{name:e.shortName}),detail:s(`plugins.removeDetail`),confirmLabel:s(`common.delete`),destructive:!0})&&m.mutate(e.spec,{onSuccess:e=>i(e.id),onError:e=>u(I(e),`error`)})},w=[];return x&&!x.error&&w.push((0,J.jsxs)(Q,{label:s(`plugins.kind.middleware`),children:[s(`plugins.mw.stats`,{hooks:x.hooks.join(`, `),calls:x.calls,micros:x.avgMicros.toFixed(1),failures:x.failures}),x.lastError&&(0,J.jsx)(`span`,{className:`block text-[var(--danger)]`,children:s(`plugins.mw.lastError`,{error:x.lastError})})]},`mw`)),e.agent?.kind&&w.push((0,J.jsx)(Q,{label:s(`plugins.kind.agent`),children:(0,J.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>c(`/clients/${e.agent.kind}`),children:s(`plugins.agent.adds`,{name:e.agent.name??e.agent.id??``})})},`agent`)),y&&y.provides.length>0&&w.push((0,J.jsxs)(Q,{label:s(`plugins.kind.provider`),children:[(0,J.jsx)(`span`,{children:s(`plugins.provides`,{providers:y.provides.join(`, `)})}),(0,J.jsx)(`button`,{type:`button`,className:`ml-2 text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>c(`/providers`),children:s(`plugins.openProviders`)}),Object.entries(y.servedBy).map(([t,n])=>(0,J.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[var(--warning)]`,children:[s(`plugins.servedBy`,{provider:t,other:n}),(0,J.jsx)(k,{size:`sm`,onClick:()=>h.mutate({spec:e.spec,provider:t},{onError:e=>u(I(e),`error`)}),children:s(`plugins.useFor`,{provider:t})})]},t)),y.provides.some(t=>n[t]===e.spec)&&(0,J.jsx)(`span`,{className:`block text-[var(--text-muted)]`,children:s(`plugins.picked`)})]},`provides`)),(0,J.jsxs)(`article`,{className:D(`flex gap-3 px-4 py-3.5`,!e.enabled&&`opacity-70`),children:[(0,J.jsx)(`div`,{className:D(`pt-0.5`,!e.enabled&&`grayscale`),children:(0,J.jsx)(X,{name:e.shortName,icon:e.icon,kind:S})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-56 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:e.shortName}),e.version&&(0,J.jsxs)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:[`v`,e.version]}),e.kinds.map(e=>(0,J.jsx)(E,{tone:he[e],children:s(Y[e])},e)),e.isPath&&(0,J.jsx)(E,{tone:`orange`,children:s(`plugins.local`)})]}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:e.spec,children:e.spec})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[x&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(k,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveUp`),title:s(`plugins.moveUp`),disabled:!a,onClick:a,icon:(0,J.jsx)(ce,{className:`size-3.5`})}),(0,J.jsx)(k,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveDown`),title:s(`plugins.moveDown`),disabled:!o,onClick:o,icon:(0,J.jsx)(z,{className:`size-3.5`})})]}),(0,J.jsx)(P,{checked:e.enabled,label:s(`plugins.enabled`),onChange:t=>f.mutate({spec:e.spec,enabled:t},{onError:e=>u(I(e),`error`)})}),(0,J.jsx)(ee,{label:s(`common.more`),iconOnly:!0,icon:(0,J.jsx)(ne,{className:`size-4`}),items:[{id:`options`,label:s(`plugins.options`),icon:(0,J.jsx)(pe,{className:`size-3.5`}),onSelect:()=>v(!0)},...e.isPath?[]:[{id:`update`,label:s(`plugins.update`),icon:(0,J.jsx)(U,{className:`size-3.5`}),onSelect:()=>p.mutate(e.spec,{onSuccess:e=>i(e.id),onError:e=>u(I(e),`error`)})}],{id:`remove`,label:s(`common.delete`),icon:(0,J.jsx)(V,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void C()}]})]})]}),e.error&&(0,J.jsx)(A,{tone:`danger`,title:s(`plugins.cantLoad`),children:e.error}),y?.error&&(0,J.jsx)(A,{tone:`danger`,title:s(`plugins.hostCantLoad`),children:y.error}),x?.error&&(0,J.jsx)(A,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.mw.error`,{error:x.error})}),e.agent?.error&&(0,J.jsx)(A,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.agent.error`,{error:e.agent.error})}),w.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-[var(--surface-muted)] px-3 py-2`,children:w})]}),(0,J.jsx)(ve,{plugin:e,open:g,onOpenChange:v})]})}function Q({label:e,children:t}){return(0,J.jsxs)(`div`,{className:`flex gap-3 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`w-14 shrink-0 text-[var(--text-muted)]`,children:e}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 text-[var(--text-secondary)]`,children:t})]})}function ve({plugin:e,open:t,onOpenChange:n}){let{t:r}=_(),{toast:i}=R(),a=l(),[o,s]=(0,q.useState)(``),[c,u]=(0,q.useState)(null);(0,q.useEffect)(()=>{t&&(s(JSON.stringify(e.options??e.optionsExample??{},null,2)),u(null))},[t,e.options,e.optionsExample]);let d=t=>a.mutate({spec:e.spec,options:t},{onSuccess:()=>(i(r(`plugins.optionsSaved`)),n(!1)),onError:e=>i(I(e),`error`)});return(0,J.jsxs)(L,{open:t,onOpenChange:n,title:r(`plugins.optionsTitle`,{name:e.shortName}),description:e.options?void 0:e.optionsExample?r(`plugins.optionsExample`):r(`plugins.optionsNone`),width:560,footer:(0,J.jsxs)(J.Fragment,{children:[e.options&&(0,J.jsx)(k,{onClick:()=>d(null),children:r(`plugins.optionsClear`)}),(0,J.jsx)(k,{variant:`primary`,onClick:()=>{try{let e=JSON.parse(o||`{}`);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(r(`plugins.optionsObject`));d(e)}catch(e){u(e instanceof Error?e.message:String(e))}},disabled:a.isPending,children:r(`common.save`)})]}),children:[(0,J.jsx)(m,{mono:!0,rows:14,value:o,invalid:!!c,onChange:e=>(s(e.target.value),u(null)),label:r(`plugins.options`)}),c&&(0,J.jsx)(`p`,{className:`mt-2 text-[12px] text-[var(--danger)]`,children:c})]})}function ye({open:e,onOpenChange:t,onJob:n}){let{t:r}=_(),{toast:i}=R(),a=s(),[o,c]=(0,q.useState)(``);return(0,q.useEffect)(()=>{e&&c(``)},[e]),(0,J.jsxs)(L,{open:e,onOpenChange:t,title:r(`plugins.addTitle`),description:r(`plugins.addDetail`),footer:(0,J.jsx)(k,{variant:`primary`,disabled:!o.trim()||a.isPending,onClick:()=>a.mutate({spec:o.trim()},{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(I(e),`error`)}),children:r(`plugins.install`)}),children:[(0,J.jsx)(w,{label:r(`plugins.spec`),hint:r(`plugins.specHint`),children:(0,J.jsx)(v,{mono:!0,value:o,onChange:e=>c(e.target.value),placeholder:`@astragate-community/middleware-word-guard`,autoFocus:!0})}),(0,J.jsx)(A,{tone:`warning`,title:r(`plugins.trustTitle`),className:`mt-4`,children:r(`plugins.trustDetail`)})]})}function be({open:e,onOpenChange:t,onJob:n}){let{t:r}=_(),{toast:i}=R(),a=C(e),o=d(),[s,c]=(0,q.useState)(!1),l=a.data;return(0,J.jsxs)(L,{open:e,onOpenChange:t,title:r(`plugins.magpie.title`),description:l?.path,width:560,footer:(0,J.jsx)(k,{variant:`primary`,disabled:!l?.found||o.isPending,onClick:()=>o.mutate(s,{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(I(e),`error`)}),children:r(`plugins.magpie.import`)}),children:[a.isLoading&&(0,J.jsx)(M,{lines:3}),l?.error&&(0,J.jsx)(A,{tone:`danger`,title:r(`common.error`),children:l.error}),l&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:l.plugins.map(e=>(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.spec}),e.off&&(0,J.jsx)(E,{children:r(`plugins.magpie.off`)}),e.hasOptions&&(0,J.jsx)(E,{tone:`accent`,children:r(`plugins.options`)}),e.installed&&(0,J.jsx)(E,{tone:`green`,children:r(`plugins.installed`)})]},e.spec))}),l.signIns>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(P,{checked:s,onChange:c,label:r(`plugins.magpie.signIns`,{count:l.signIns})}),(0,J.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`plugins.magpie.signInsDetail`)})]})]})]})}function xe({id:e,onClose:t}){let{t:n}=_(),r=F(e).data;return(0,J.jsxs)(L,{open:!!e,onOpenChange:e=>!e&&t(),title:n(`plugins.job.title`),description:r?n(r.state===`running`?`plugins.job.running`:r.state===`succeeded`?`plugins.job.done`:`plugins.job.failed`,{target:r.target}):void 0,width:620,footer:(0,J.jsx)(k,{onClick:t,children:n(`common.close`)}),children:[!r&&(0,J.jsx)(M,{lines:3}),r&&(0,J.jsx)(S,{language:`text`,children:r.log.length?r.log.join(`
2
- `):`…`}),r?.state===`failed`&&r.error&&(0,J.jsx)(A,{tone:`danger`,title:n(`plugins.job.failedTitle`),className:`mt-3`,children:r.error})]})}function Se({installed:t,onJob:r}){let{t:i,locale:a}=_(),{toast:o,confirm:c}=R(),l=e(),u=s(),[d,f]=(0,q.useState)(``),[m,h]=(0,q.useState)(``),[v,y]=(0,q.useState)(`all`);(0,q.useEffect)(()=>{let e=setTimeout(()=>h(d.trim()),400);return()=>clearTimeout(e)},[d]);let b=n(m),S=(0,q.useMemo)(()=>new Set(t.map(e=>e.name)),[t]),C=(e,n)=>S.has(n)||t.some(t=>t.spec===e),w=async(e,t)=>{await c({title:i(`plugins.installConfirm`,{name:e}),detail:i(`plugins.trustDetail`),confirmLabel:i(`plugins.install`)})&&u.mutate({spec:e,source:t},{onSuccess:e=>r(e.id),onError:e=>o(I(e),`error`)})},[E,D]=le(),O=E.get(`install`),k=(0,q.useRef)(null);(0,q.useEffect)(()=>{O&&k.current!==O&&(k.current=O,D({},{replace:!0}),me.test(O)?w(O,`market`):o(i(`plugins.linkInvalid`),`error`))},[O]);let j=(l.data??[]).filter(e=>v===`all`||e.kind===v),N=e=>(l.data??[]).filter(t=>e===`all`||t.kind===e).length,P=m.length>=2;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,J.jsx)(x,{className:`min-w-[220px] flex-1`,value:d,onChange:f,placeholder:i(`plugins.searchPlaceholder`)}),!P&&(0,J.jsx)(p,{ariaLabel:i(`plugins.kindFilter`),value:v,onChange:y,items:[`all`,`provider`,`middleware`,`agent`].map(e=>({value:e,label:`${i(e===`all`?`plugins.kind.all`:Y[e])} ${N(e)}`}))})]}),P?(0,J.jsxs)(J.Fragment,{children:[b.isLoading&&(0,J.jsx)(M,{lines:3}),b.data?.length===0&&(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(g,{icon:(0,J.jsx)(T,{className:`size-6`}),title:i(`plugins.noResults`)})}),b.data&&b.data.length>0&&(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:b.data.map(e=>(0,J.jsx)($,{title:e.name,subtitle:e.spec,icon:(0,J.jsx)(X,{name:e.name,kind:e.kind}),detail:e.description??void 0,tags:[i(Y[e.kind]),e.source===`github`?`★ ${e.stars}`:e.version?`v${e.version}`:``,e.source===`astra`?i(`plugins.origin.astra`):``],installed:C(e.spec,e.name),onInstall:()=>void w(e.spec,e.source===`github`?`github`:e.source===`astra`?`market`:`npm`)},e.spec))}),(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:i(`plugins.searchNote`)})]}):(0,J.jsxs)(J.Fragment,{children:[l.isLoading&&(0,J.jsx)(M,{lines:4}),l.isError&&(0,J.jsx)(A,{tone:`danger`,title:i(`common.error`),children:I(l.error)}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:j.map(e=>(0,J.jsx)($,{title:e.name,subtitle:e.package,icon:(0,J.jsx)(X,{name:e.name,icon:e.icon,kind:e.kind}),detail:e.summary[a]??e.summary.en??e.description??void 0,tags:[i(Y[e.kind]),e.latest?`v${e.latest}`:``,e.origin===`astra`?i(`plugins.origin.astra`):``,e.minAstraVersion?i(`plugins.minVersion`,{version:e.minAstraVersion}):``].filter(Boolean),installed:C(e.package,e.package),onInstall:()=>void w(e.package,`market`)},e.package))}),(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:i(`plugins.marketNote`)})]})]})}function $({title:e,subtitle:t,icon:n,detail:r,tags:i,installed:a,onInstall:o}){let{t:s}=_();return(0,J.jsxs)(`div`,{className:`card flex flex-col gap-3 p-4 transition-colors hover:border-[var(--border)]`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[n,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,title:e,children:e}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:t,children:t})]})]}),(0,J.jsx)(`p`,{className:`line-clamp-2 min-h-[2lh] text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:r??``}),(0,J.jsxs)(`div`,{className:`mt-auto flex items-center gap-1.5`,children:[i.filter(Boolean).map(e=>(0,J.jsx)(E,{children:e},e)),(0,J.jsx)(`span`,{className:`flex-1`}),a?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12px] text-[var(--success)]`,children:[(0,J.jsx)(h,{className:`size-3.5`}),s(`plugins.installed`)]}):(0,J.jsx)(k,{size:`sm`,variant:`primary`,onClick:o,children:s(`plugins.install`)})]})]})}function Ce({onJob:e}){let{t:n,locale:r}=_(),{toast:a}=R(),o=i(),s=u(),c=f(),l=o.data?.runtime;return(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,J.jsxs)(`section`,{className:`card flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`flex-1 text-[14px] font-medium`,children:`Bun`}),l&&(0,J.jsx)(E,{tone:l.path?`green`:`neutral`,children:l.path?n(`plugins.bunReady`):n(`plugins.bunMissing`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:n(`plugins.bunDetail`)}),l&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l.path&&(0,J.jsx)(y,{label:n(`plugins.bunPath`),mono:!0,children:l.path}),l.version&&(0,J.jsx)(y,{label:n(`plugins.bunVersion`),mono:!0,children:l.version}),(0,J.jsx)(y,{label:n(`plugins.bunTarget`),mono:!0,children:l.target??n(`plugins.bunNoBuild`)})]}),l?.error&&(0,J.jsx)(A,{tone:`danger`,title:n(`plugins.bunFailed`),children:l.error}),l&&!l.path&&(0,J.jsx)(`div`,{children:(0,J.jsx)(k,{variant:`primary`,disabled:l.downloading||c.isPending||!l.target,onClick:()=>c.mutate(void 0,{onSuccess:t=>e(t.id),onError:e=>a(I(e),`error`)}),children:l.downloading?n(`plugins.bunDownloading`):n(`plugins.bunDownload`,{version:l.version??``})})})]}),(0,J.jsxs)(`section`,{className:`card flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`flex-1 text-[14px] font-medium`,children:n(`plugins.host`)}),s.data&&(0,J.jsx)(E,{tone:s.data.running?`green`:`neutral`,children:s.data.running?n(`plugins.hostRunning`):n(`plugins.hostStopped`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:n(`plugins.hostDetail`)}),s.data?.startError&&(0,J.jsx)(A,{tone:`danger`,title:n(`plugins.hostStartFailed`),children:s.data.startError}),s.data?.goneReason&&(0,J.jsx)(A,{tone:`warning`,title:n(`plugins.hostGone`),children:s.data.goneReason}),s.data&&s.data.plugins.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:s.data.plugins.map(e=>(0,J.jsx)(y,{label:e.spec,mono:!0,children:e.error?n(`plugins.hostPluginError`,{error:e.error}):e.provides.join(`, `)||`—`},e.spec))}),s.data?.recent&&s.data.recent.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-t border-[var(--border-subtle)] pt-3`,children:[(0,J.jsx)(`h4`,{className:`text-[12px] font-medium text-[var(--text-secondary)]`,children:n(`plugins.hostRecent`)}),s.data.recent.map((e,n)=>(0,J.jsxs)(`div`,{className:`flex items-start gap-2 text-[12px]`,children:[(0,J.jsx)(E,{tone:e.variant===`error`?`red`:e.variant===`warning`?`orange`:e.variant===`success`?`green`:`neutral`,children:t(e.at,r)}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[e.title&&(0,J.jsxs)(`span`,{className:`font-medium`,children:[e.title,` `]}),e.message]})]},n))]})]}),(0,J.jsxs)(`a`,{className:`flex items-center gap-1 px-1 text-[12px] text-[var(--text-muted)] hover:text-[var(--accent)] lg:col-span-2`,href:`https://github.com/astragate-community/astra-gate-plugins`,target:`_blank`,rel:`noreferrer`,children:[(0,J.jsx)(re,{className:`size-3`}),` astragate-community/astra-gate-plugins`]})]})}export{Z as PluginsPage};
1
+ import{Bn as e,Fa as t,H as n,Hn as r,Jn as i,Kn as a,Nt as o,Pa as s,Pn as c,Ra as l,Rn as u,Sn as d,Tn as f,_ as p,b as m,bt as h,c as g,ct as _,d as v,di as y,f as b,fr as x,h as S,i as C,jn as w,l as T,mt as E,n as D,ot as O,pr as k,r as A,t as j,v as M,xt as N,y as P,zn as F}from"./alert-CMMOyMsp.js";import{a as I,i as L,n as ee,o as R}from"./overlays-BFrvqpMl.js";import{t as z}from"./arrow-down-rd1gJD55.js";import{t as te}from"./download-CSRdoXEJ.js";import{t as ne}from"./ellipsis-BI50R2Bc.js";import{t as re}from"./external-link-Bzx5-ExU.js";import{$ as ie,C as ae,E as B,F as oe,J as se,K as ce,N as V,Q as H,R as U,T as W,et as le,h as ue,w as G,x as de,z as fe}from"./index-Ck4Qlg9B.js";var K={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};K.node;var pe=N(K),q=l(t(),1),J=s(),me=/^(?:(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*|github:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)$/,Y={provider:`plugins.kind.provider`,middleware:`plugins.kind.middleware`,agent:`plugins.kind.agent`,pi:`plugins.kind.pi`},he={provider:`neutral`,middleware:`accent`,agent:`green`,pi:`orange`};function X({name:e,icon:t,kind:n,size:r=32}){let i=Math.round(r*.28);return t&&/^(https:|data:image\/)/i.test(t)?(0,J.jsx)(`img`,{src:t,alt:``,width:r,height:r,className:`shrink-0 object-contain`,style:{borderRadius:i},draggable:!1}):n===`middleware`||n===`agent`?(0,J.jsx)(`span`,{"aria-hidden":!0,className:`inline-flex shrink-0 items-center justify-center text-white`,style:{width:r,height:r,borderRadius:i,background:n===`middleware`?`#0a84ff`:`#30b0a0`},children:(0,J.jsx)(n===`middleware`?oe:se,{className:`size-[55%]`,strokeWidth:1.75})}):(0,J.jsx)(de,{name:e,icon:t,size:r})}function Z(){let{t:e}=_(),t=H(),{tab:n}=ie(),r=n===`market`||n===`runtime`?n:`installed`,i=a(),o=y(),{toast:s}=R(),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(null);return(0,J.jsxs)(ue,{title:e(`nav.plugins`),subtitle:e(`plugins.subtitle`),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{icon:(0,J.jsx)(U,{className:`size-3.5`}),onClick:()=>o.mutate(void 0,{onSuccess:e=>p(e.id),onError:e=>s(I(e),`error`)}),disabled:!i.data?.plugins.length,children:e(`plugins.updateAll`)}),(0,J.jsx)(A,{variant:`primary`,icon:(0,J.jsx)(fe,{className:`size-3.5`}),onClick:()=>l(!0),children:e(`plugins.add`)})]}),children:[(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col`,children:[i.data?.off&&(0,J.jsx)(j,{className:`mb-4`,tone:`warning`,title:e(`plugins.off`),children:e(`plugins.offDetail`)}),(0,J.jsxs)(ae,{value:r,onValueChange:e=>t(e===`installed`?`/plugins`:`/plugins/${e}`,{replace:!0}),children:[(0,J.jsxs)(W,{"aria-label":e(`nav.plugins`),children:[(0,J.jsxs)(B,{value:`installed`,children:[e(`plugins.tab.installed`),i.data&&i.data.plugins.length>0&&(0,J.jsx)(`span`,{className:`ml-1.5 tabular-nums opacity-60`,children:i.data.plugins.length})]}),(0,J.jsx)(B,{value:`market`,children:e(`plugins.tab.market`)}),(0,J.jsx)(B,{value:`runtime`,children:e(`plugins.tab.runtime`)})]}),(0,J.jsxs)(G,{value:`installed`,className:`pt-1`,children:[i.isLoading&&(0,J.jsx)(M,{lines:4}),i.isError&&(0,J.jsx)(j,{tone:`danger`,title:e(`common.error`),children:I(i.error)}),i.data&&(0,J.jsx)(ge,{plugins:i.data.plugins,preferences:i.data.preferences,onJob:p,onBrowse:()=>t(`/plugins/market`),onImport:()=>d(!0)})]}),(0,J.jsx)(G,{value:`market`,className:`pt-1`,children:(0,J.jsx)(Se,{installed:i.data?.plugins??[],onJob:p})}),(0,J.jsx)(G,{value:`runtime`,className:`pt-1`,children:(0,J.jsx)(Ce,{onJob:p})})]})]}),(0,J.jsx)(ye,{open:c,onOpenChange:l,onJob:p}),(0,J.jsx)(be,{open:u,onOpenChange:d,onJob:p}),(0,J.jsx)(xe,{id:f,onClose:()=>p(null)})]})}function ge({plugins:e,preferences:t,onJob:n,onBrowse:r,onImport:i}){let{t:a}=_(),o=u(e.some(e=>e.kinds.includes(`provider`)||e.kinds.includes(`pi`))),s=w(),c=k(),{toast:l}=R(),d=!!(s.data?.found&&s.data.plugins.some(e=>!e.installed))&&(0,J.jsxs)(`div`,{className:`card flex flex-wrap items-center gap-3 p-4`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:a(`plugins.magpie.banner`,{count:s.data.plugins.filter(e=>!e.installed).length})}),(0,J.jsx)(A,{size:`sm`,icon:(0,J.jsx)(te,{className:`size-3.5`}),onClick:i,children:a(`plugins.magpie.import`)})]});if(e.length===0)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(g,{icon:(0,J.jsx)(E,{className:`size-6`}),title:a(`plugins.empty`),detail:a(`plugins.emptyDetail`),action:(0,J.jsx)(A,{variant:`primary`,onClick:r,children:a(`plugins.browseMarket`)})})})]});let f=(t,n)=>{let r=e.map(e=>e.spec),[i]=r.splice(t,1);r.splice(t+n,0,i),c.mutate(r,{onError:e=>l(I(e),`error`)})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:e.map((r,i)=>(0,J.jsx)(_e,{plugin:r,host:o.data,preferences:t,onJob:n,onUp:i>0?()=>f(i,-1):void 0,onDown:i<e.length-1?()=>f(i,1):void 0},r.spec))}),e.some(e=>e.middleware)&&(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:a(`plugins.orderHint`)})]})}function _e({plugin:e,host:t,preferences:n,onJob:r,onUp:a,onDown:o}){let{t:s}=_(),l=H(),{toast:u,confirm:d}=R(),f=c(),p=y(),m=x(),h=i(),[g,v]=(0,q.useState)(!1),b=t?.plugins.find(t=>t.spec===e.spec),S=e.middleware,C=e.kinds[0]??`provider`,w=async()=>{await d({title:s(`plugins.removeConfirm`,{name:e.shortName}),detail:s(`plugins.removeDetail`),confirmLabel:s(`common.delete`),destructive:!0})&&m.mutate(e.spec,{onSuccess:e=>r(e.id),onError:e=>u(I(e),`error`)})},T=[];return S&&!S.error&&T.push((0,J.jsxs)(Q,{label:s(`plugins.kind.middleware`),children:[s(`plugins.mw.stats`,{hooks:S.hooks.join(`, `),calls:S.calls,micros:S.avgMicros.toFixed(1),failures:S.failures}),S.lastError&&(0,J.jsx)(`span`,{className:`block text-[var(--danger)]`,children:s(`plugins.mw.lastError`,{error:S.lastError})})]},`mw`)),e.agent?.kind&&T.push((0,J.jsx)(Q,{label:s(`plugins.kind.agent`),children:(0,J.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>l(`/clients/${e.agent.kind}`),children:s(`plugins.agent.adds`,{name:e.agent.name??e.agent.id??``})})},`agent`)),b&&b.provides.length>0&&T.push((0,J.jsxs)(Q,{label:s(`plugins.kind.provider`),children:[(0,J.jsx)(`span`,{children:s(`plugins.provides`,{providers:b.provides.join(`, `)})}),(0,J.jsx)(`button`,{type:`button`,className:`ml-2 text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>l(`/providers`),children:s(`plugins.openProviders`)}),Object.entries(b.servedBy).map(([t,n])=>(0,J.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[var(--warning)]`,children:[s(`plugins.servedBy`,{provider:t,other:n}),(0,J.jsx)(A,{size:`sm`,onClick:()=>h.mutate({spec:e.spec,provider:t},{onError:e=>u(I(e),`error`)}),children:s(`plugins.useFor`,{provider:t})})]},t)),b.provides.some(t=>n[t]===e.spec)&&(0,J.jsx)(`span`,{className:`block text-[var(--text-muted)]`,children:s(`plugins.picked`)})]},`provides`)),(0,J.jsxs)(`article`,{className:O(`flex gap-3 px-4 py-3.5`,!e.enabled&&`opacity-70`),children:[(0,J.jsx)(`div`,{className:O(`pt-0.5`,!e.enabled&&`grayscale`),children:(0,J.jsx)(X,{name:e.shortName,icon:e.icon,kind:C})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-56 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:e.shortName}),e.version&&(0,J.jsxs)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:[`v`,e.version]}),e.kinds.map(e=>(0,J.jsx)(D,{tone:he[e],children:s(Y[e])},e)),e.isPath&&(0,J.jsx)(D,{tone:`orange`,children:s(`plugins.local`)})]}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:e.spec,children:e.spec})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[S&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveUp`),title:s(`plugins.moveUp`),disabled:!a,onClick:a,icon:(0,J.jsx)(ce,{className:`size-3.5`})}),(0,J.jsx)(A,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveDown`),title:s(`plugins.moveDown`),disabled:!o,onClick:o,icon:(0,J.jsx)(z,{className:`size-3.5`})})]}),(0,J.jsx)(P,{checked:e.enabled,label:s(`plugins.enabled`),onChange:t=>f.mutate({spec:e.spec,enabled:t},{onError:e=>u(I(e),`error`)})}),(0,J.jsx)(ee,{label:s(`common.more`),iconOnly:!0,icon:(0,J.jsx)(ne,{className:`size-4`}),items:[{id:`options`,label:s(`plugins.options`),icon:(0,J.jsx)(pe,{className:`size-3.5`}),onSelect:()=>v(!0)},...e.isPath?[]:[{id:`update`,label:s(`plugins.update`),icon:(0,J.jsx)(U,{className:`size-3.5`}),onSelect:()=>p.mutate(e.spec,{onSuccess:e=>r(e.id),onError:e=>u(I(e),`error`)})}],{id:`remove`,label:s(`common.delete`),icon:(0,J.jsx)(V,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void w()}]})]})]}),e.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.cantLoad`),children:e.error}),b?.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.hostCantLoad`),children:b.error}),S?.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.mw.error`,{error:S.error})}),e.agent?.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.agent.error`,{error:e.agent.error})}),T.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-[var(--surface-muted)] px-3 py-2`,children:T})]}),(0,J.jsx)(ve,{plugin:e,open:g,onOpenChange:v})]})}function Q({label:e,children:t}){return(0,J.jsxs)(`div`,{className:`flex gap-3 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`w-14 shrink-0 text-[var(--text-muted)]`,children:e}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 text-[var(--text-secondary)]`,children:t})]})}function ve({plugin:e,open:t,onOpenChange:n}){let{t:r}=_(),{toast:i}=R(),a=c(),[o,s]=(0,q.useState)(``),[l,u]=(0,q.useState)(null);(0,q.useEffect)(()=>{t&&(s(JSON.stringify(e.options??e.optionsExample??{},null,2)),u(null))},[t,e.options,e.optionsExample]);let d=t=>a.mutate({spec:e.spec,options:t},{onSuccess:()=>(i(r(`plugins.optionsSaved`)),n(!1)),onError:e=>i(I(e),`error`)});return(0,J.jsxs)(L,{open:t,onOpenChange:n,title:r(`plugins.optionsTitle`,{name:e.shortName}),description:e.options?void 0:e.optionsExample?r(`plugins.optionsExample`):r(`plugins.optionsNone`),width:560,footer:(0,J.jsxs)(J.Fragment,{children:[e.options&&(0,J.jsx)(A,{onClick:()=>d(null),children:r(`plugins.optionsClear`)}),(0,J.jsx)(A,{variant:`primary`,onClick:()=>{try{let e=JSON.parse(o||`{}`);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(r(`plugins.optionsObject`));d(e)}catch(e){u(e instanceof Error?e.message:String(e))}},disabled:a.isPending,children:r(`common.save`)})]}),children:[(0,J.jsx)(m,{mono:!0,rows:14,value:o,invalid:!!l,onChange:e=>(s(e.target.value),u(null)),label:r(`plugins.options`)}),l&&(0,J.jsx)(`p`,{className:`mt-2 text-[12px] text-[var(--danger)]`,children:l})]})}function ye({open:e,onOpenChange:t,onJob:n}){let{t:r}=_(),{toast:i}=R(),a=o(),[s,c]=(0,q.useState)(``);return(0,q.useEffect)(()=>{e&&c(``)},[e]),(0,J.jsxs)(L,{open:e,onOpenChange:t,title:r(`plugins.addTitle`),description:r(`plugins.addDetail`),footer:(0,J.jsx)(A,{variant:`primary`,disabled:!s.trim()||a.isPending,onClick:()=>a.mutate({spec:s.trim()},{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(I(e),`error`)}),children:r(`plugins.install`)}),children:[(0,J.jsx)(T,{label:r(`plugins.spec`),hint:r(`plugins.specHint`),children:(0,J.jsx)(v,{mono:!0,value:s,onChange:e=>c(e.target.value),placeholder:`@astragate-community/middleware-word-guard`,autoFocus:!0})}),(0,J.jsx)(j,{tone:`warning`,title:r(`plugins.trustTitle`),className:`mt-4`,children:r(`plugins.trustDetail`)})]})}function be({open:e,onOpenChange:t,onJob:n}){let{t:r}=_(),{toast:i}=R(),a=w(e),o=d(),[s,c]=(0,q.useState)(!1),l=a.data;return(0,J.jsxs)(L,{open:e,onOpenChange:t,title:r(`plugins.magpie.title`),description:l?.path,width:560,footer:(0,J.jsx)(A,{variant:`primary`,disabled:!l?.found||o.isPending,onClick:()=>o.mutate(s,{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(I(e),`error`)}),children:r(`plugins.magpie.import`)}),children:[a.isLoading&&(0,J.jsx)(M,{lines:3}),l?.error&&(0,J.jsx)(j,{tone:`danger`,title:r(`common.error`),children:l.error}),l&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:l.plugins.map(e=>(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.spec}),e.off&&(0,J.jsx)(D,{children:r(`plugins.magpie.off`)}),e.hasOptions&&(0,J.jsx)(D,{tone:`accent`,children:r(`plugins.options`)}),e.installed&&(0,J.jsx)(D,{tone:`green`,children:r(`plugins.installed`)})]},e.spec))}),l.signIns>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(P,{checked:s,onChange:c,label:r(`plugins.magpie.signIns`,{count:l.signIns})}),(0,J.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`plugins.magpie.signInsDetail`)})]})]})]})}function xe({id:e,onClose:t}){let{t:n}=_(),r=F(e).data;return(0,J.jsxs)(L,{open:!!e,onOpenChange:e=>!e&&t(),title:n(`plugins.job.title`),description:r?n(r.state===`running`?`plugins.job.running`:r.state===`succeeded`?`plugins.job.done`:`plugins.job.failed`,{target:r.target}):void 0,width:620,footer:(0,J.jsx)(A,{onClick:t,children:n(`common.close`)}),children:[!r&&(0,J.jsx)(M,{lines:3}),r&&(0,J.jsx)(C,{language:`text`,children:r.log.length?r.log.join(`
2
+ `):`…`}),r?.state===`failed`&&r.error&&(0,J.jsx)(j,{tone:`danger`,title:n(`plugins.job.failedTitle`),className:`mt-3`,children:r.error})]})}function Se({installed:t,onJob:n}){let{t:i,locale:a}=_(),{toast:s,confirm:c}=R(),l=e(),u=o(),[d,f]=(0,q.useState)(``),[m,h]=(0,q.useState)(``),[v,y]=(0,q.useState)(`all`);(0,q.useEffect)(()=>{let e=setTimeout(()=>h(d.trim()),400);return()=>clearTimeout(e)},[d]);let b=r(m),x=(0,q.useMemo)(()=>new Set(t.map(e=>e.name)),[t]),C=(e,n)=>x.has(n)||t.some(t=>t.spec===e),w=async(e,t)=>{await c({title:i(`plugins.installConfirm`,{name:e}),detail:i(`plugins.trustDetail`),confirmLabel:i(`plugins.install`)})&&u.mutate({spec:e,source:t},{onSuccess:e=>n(e.id),onError:e=>s(I(e),`error`)})},[T,D]=le(),O=T.get(`install`),k=(0,q.useRef)(null);(0,q.useEffect)(()=>{O&&k.current!==O&&(k.current=O,D({},{replace:!0}),me.test(O)?w(O,`market`):s(i(`plugins.linkInvalid`),`error`))},[O]);let A=(l.data??[]).filter(e=>v===`all`||e.kind===v),N=e=>(l.data??[]).filter(t=>e===`all`||t.kind===e).length,P=m.length>=2;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,J.jsx)(S,{className:`min-w-[220px] flex-1`,value:d,onChange:f,placeholder:i(`plugins.searchPlaceholder`)}),!P&&(0,J.jsx)(p,{ariaLabel:i(`plugins.kindFilter`),value:v,onChange:y,items:[`all`,`provider`,`middleware`,`agent`].map(e=>({value:e,label:`${i(e===`all`?`plugins.kind.all`:Y[e])} ${N(e)}`}))})]}),P?(0,J.jsxs)(J.Fragment,{children:[b.isLoading&&(0,J.jsx)(M,{lines:3}),b.data?.length===0&&(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(g,{icon:(0,J.jsx)(E,{className:`size-6`}),title:i(`plugins.noResults`)})}),b.data&&b.data.length>0&&(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:b.data.map(e=>(0,J.jsx)($,{title:e.name,subtitle:e.spec,icon:(0,J.jsx)(X,{name:e.name,kind:e.kind}),detail:e.description??void 0,tags:[i(Y[e.kind]),e.source===`github`?`★ ${e.stars}`:e.version?`v${e.version}`:``,e.source===`astra`?i(`plugins.origin.astra`):``],installed:C(e.spec,e.name),onInstall:()=>void w(e.spec,e.source===`github`?`github`:e.source===`astra`?`market`:`npm`)},e.spec))}),(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:i(`plugins.searchNote`)})]}):(0,J.jsxs)(J.Fragment,{children:[l.isLoading&&(0,J.jsx)(M,{lines:4}),l.isError&&(0,J.jsx)(j,{tone:`danger`,title:i(`common.error`),children:I(l.error)}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:A.map(e=>(0,J.jsx)($,{title:e.name,subtitle:e.package,icon:(0,J.jsx)(X,{name:e.name,icon:e.icon,kind:e.kind}),detail:e.summary[a]??e.summary.en??e.description??void 0,tags:[i(Y[e.kind]),e.latest?`v${e.latest}`:``,e.origin===`astra`?i(`plugins.origin.astra`):``,e.minAstraVersion?i(`plugins.minVersion`,{version:e.minAstraVersion}):``].filter(Boolean),installed:C(e.package,e.package),onInstall:()=>void w(e.package,`market`)},e.package))}),(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:i(`plugins.marketNote`)})]})]})}function $({title:e,subtitle:t,icon:n,detail:r,tags:i,installed:a,onInstall:o}){let{t:s}=_();return(0,J.jsxs)(`div`,{className:`card flex flex-col gap-3 p-4 transition-colors hover:border-[var(--border)]`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[n,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,title:e,children:e}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:t,children:t})]})]}),(0,J.jsx)(`p`,{className:`line-clamp-2 min-h-[2lh] text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:r??``}),(0,J.jsxs)(`div`,{className:`mt-auto flex items-center gap-1.5`,children:[i.filter(Boolean).map(e=>(0,J.jsx)(D,{children:e},e)),(0,J.jsx)(`span`,{className:`flex-1`}),a?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12px] text-[var(--success)]`,children:[(0,J.jsx)(h,{className:`size-3.5`}),s(`plugins.installed`)]}):(0,J.jsx)(A,{size:`sm`,variant:`primary`,onClick:o,children:s(`plugins.install`)})]})]})}function Ce({onJob:e}){let{t,locale:r}=_(),{toast:i}=R(),o=a(),s=u(),c=f(),l=o.data?.runtime;return(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,J.jsxs)(`section`,{className:`card flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`flex-1 text-[14px] font-medium`,children:`Bun`}),l&&(0,J.jsx)(D,{tone:l.path?`green`:`neutral`,children:l.path?t(`plugins.bunReady`):t(`plugins.bunMissing`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:t(`plugins.bunDetail`)}),l&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l.path&&(0,J.jsx)(b,{label:t(`plugins.bunPath`),mono:!0,children:l.path}),l.version&&(0,J.jsx)(b,{label:t(`plugins.bunVersion`),mono:!0,children:l.version}),(0,J.jsx)(b,{label:t(`plugins.bunTarget`),mono:!0,children:l.target??t(`plugins.bunNoBuild`)})]}),l?.error&&(0,J.jsx)(j,{tone:`danger`,title:t(`plugins.bunFailed`),children:l.error}),l&&!l.path&&(0,J.jsx)(`div`,{children:(0,J.jsx)(A,{variant:`primary`,disabled:l.downloading||c.isPending||!l.target,onClick:()=>c.mutate(void 0,{onSuccess:t=>e(t.id),onError:e=>i(I(e),`error`)}),children:l.downloading?t(`plugins.bunDownloading`):t(`plugins.bunDownload`,{version:l.version??``})})})]}),(0,J.jsxs)(`section`,{className:`card flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`flex-1 text-[14px] font-medium`,children:t(`plugins.host`)}),s.data&&(0,J.jsx)(D,{tone:s.data.running?`green`:`neutral`,children:s.data.running?t(`plugins.hostRunning`):t(`plugins.hostStopped`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:t(`plugins.hostDetail`)}),s.data?.startError&&(0,J.jsx)(j,{tone:`danger`,title:t(`plugins.hostStartFailed`),children:s.data.startError}),s.data?.goneReason&&(0,J.jsx)(j,{tone:`warning`,title:t(`plugins.hostGone`),children:s.data.goneReason}),s.data&&s.data.plugins.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:s.data.plugins.map(e=>(0,J.jsx)(b,{label:e.spec,mono:!0,children:e.error?t(`plugins.hostPluginError`,{error:e.error}):e.provides.join(`, `)||`—`},e.spec))}),s.data?.recent&&s.data.recent.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-t border-[var(--border-subtle)] pt-3`,children:[(0,J.jsx)(`h4`,{className:`text-[12px] font-medium text-[var(--text-secondary)]`,children:t(`plugins.hostRecent`)}),s.data.recent.map((e,t)=>(0,J.jsxs)(`div`,{className:`flex items-start gap-2 text-[12px]`,children:[(0,J.jsx)(D,{tone:e.variant===`error`?`red`:e.variant===`warning`?`orange`:e.variant===`success`?`green`:`neutral`,children:n(e.at,r)}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[e.title&&(0,J.jsxs)(`span`,{className:`font-medium`,children:[e.title,` `]}),e.message]})]},t))]})]}),(0,J.jsxs)(`a`,{className:`flex items-center gap-1 px-1 text-[12px] text-[var(--text-muted)] hover:text-[var(--accent)] lg:col-span-2`,href:`https://github.com/astragate-community/astra-gate-plugins`,target:`_blank`,rel:`noreferrer`,children:[(0,J.jsx)(re,{className:`size-3`}),` astragate-community/astra-gate-plugins`]})]})}export{Z as PluginsPage};
@@ -0,0 +1 @@
1
+ import{$n as e,E as t,Fa as n,Hi as r,J as i,Ki as a,Pa as o,Qn as s,Ra as c,Ui as l,Vi as u,Wi as d,Y as f,Yt as p,Zn as m,_ as h,b as g,bt as _,c as v,ct as y,d as b,dt as x,er as S,fi as C,g as w,h as T,l as E,m as D,n as O,ot as k,qi as A,r as j,t as ee,u as M,v as N,xt as P,y as F}from"./alert-CMMOyMsp.js";import{a as I,i as te,o as L,r as R}from"./overlays-BFrvqpMl.js";import{$ as ne,C as z,D as B,E as re,F as ie,H as ae,M as oe,N as V,Q as se,R as H,T as ce,U as le,_ as ue,c as de,h as fe,nt as U,r as pe,tt as me,w as W,z as he}from"./index-Ck4Qlg9B.js";var ge={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};ge.node;var _e=P(ge),G=c(n(),1),K={toolbar:`_toolbar_1p5c5_1`,leading:`_leading_1p5c5_2`,frame:`_frame_1p5c5_4`,chips:`_chips_1p5c5_5`,slot:`_slot_1p5c5_7`,chip:`_chip_1p5c5_5`,chipLabel:`_chipLabel_1p5c5_10`,value:`_value_1p5c5_11`,separator:`_separator_1p5c5_12`,morphText:`_morphText_1p5c5_13`,morphValue:`_morphValue_1p5c5_14`,measure:`_measure_1p5c5_15`,empty:`_empty_1p5c5_18`,actions:`_actions_1p5c5_19`,clear:`_clear_1p5c5_20`,clearText:`_clearText_1p5c5_21`,srOnly:`_srOnly_1p5c5_23`,menu:`_menu_1p5c5_27`,trigger:`_trigger_1p5c5_29`,face:`_face_1p5c5_31`,surface:`_surface_1p5c5_34`,panel:`_panel_1p5c5_42`,head:`_head_1p5c5_45`,back:`_back_1p5c5_47`,title:`_title_1p5c5_49`,titleText:`_titleText_1p5c5_50`,stage:`_stage_1p5c5_51`,step:`_step_1p5c5_52`,list:`_list_1p5c5_53`,highlight:`_highlight_1p5c5_54`,item:`_item_1p5c5_55`,itemIcon:`_itemIcon_1p5c5_57`,itemLabel:`_itemLabel_1p5c5_58`,itemMeta:`_itemMeta_1p5c5_59`,metaValue:`_metaValue_1p5c5_60`,hint:`_hint_1p5c5_61`,check:`_check_1p5c5_62`,noOptions:`_noOptions_1p5c5_64`},q=o(),J={duration:t.duration.standard,ease:[...t.ease.enter]},ve={duration:t.duration.instant,ease:[...t.ease.standard]},Y={duration:0},ye={duration:t.duration.instant,ease:[...t.ease.standard]},X=e=>`blur(${e}px)`,be=e=>Math.min(1,Math.max(0,e)),xe=e=>typeof e==`string`?{value:e}:e,Se=e=>e.label??e.value,Ce=e=>({initial:e?{opacity:0}:{opacity:0,y:`0.3em`,filter:X(t.blur.soft)},animate:{opacity:1,y:0,filter:X(0)},exit:e?{opacity:0,transition:Y}:{opacity:0,y:`-0.3em`,filter:X(t.blur.subtle),transition:ve},transition:e?ye:J});function we({text:e}){let n=l()??!1,i=(0,G.useRef)(null),o=d(`auto`);return(0,G.useLayoutEffect)(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let a=null,s=new ResizeObserver(([i])=>{let s=Math.ceil(i.borderBoxSize?.[0]?.inlineSize??e.offsetWidth),c=a!==null&&a!==e.textContent;a=e.textContent,c&&!n?r(o,s,t.spring.morph):o.jump(s)});return s.observe(e),()=>s.disconnect()},[n,o]),(0,q.jsxs)(u.span,{className:K.morphText,style:{width:o},children:[(0,q.jsx)(`span`,{ref:i,className:K.measure,"aria-hidden":`true`,children:e}),(0,q.jsx)(a,{mode:`popLayout`,initial:!1,children:(0,q.jsx)(u.span,{className:K.morphValue,...Ce(n),children:e},e)})]})}function Te(e,n,i){let a=d(`auto`);return(0,G.useLayoutEffect)(()=>{let o=e.current;if(!o||typeof ResizeObserver>`u`)return;let s=!1,c=new ResizeObserver(()=>{let e=o.offsetHeight;if(!s||i||performance.now()>n.current){s=!0,a.jump(e);return}r(a,e,t.spring.smooth)});return c.observe(o),()=>c.disconnect()},[n,a,e,i]),a}function Ee(e,n,i){(0,G.useLayoutEffect)(()=>{let a=e.current;if(!a||typeof ResizeObserver>`u`)return;let o=new Map,s=()=>{let e=performance.now();for(let s of Array.from(a.children)){let a=s.offsetLeft,c=s.offsetTop,l=o.get(s);if(!l){o.set(s,{x:a,y:c,dx:0,dy:0});continue}let u=l.x-a,d=l.y-c;if(l.x=a,l.y=c,i||e>n.current||Math.abs(d)<1&&Math.abs(u)<40)continue;l.stop?.();let f=l.dx+u,p=l.dy+d,m=e=>{l.dx=f*(1-e),l.dy=p*(1-e),s.style.translate=e>=1?``:`${l.dx}px ${l.dy}px`};m(0),l.stop=r(0,1,{...t.spring.smooth,onUpdate:m,onComplete:()=>m(1)}).stop}for(let e of o.keys())e.parentElement!==a&&o.delete(e)},c=new ResizeObserver(s),l=()=>{for(let e of Array.from(a.children))c.observe(e)},u=new MutationObserver(()=>{l(),s()});return c.observe(a),l(),u.observe(a,{childList:!0}),()=>{c.disconnect(),u.disconnect();for(let e of o.values())e.stop?.()}},[n,e,i])}var Z=e=>e.valueLabel??e.value,De=e=>Z(e)?`${e.label}: ${Z(e)}`:e.label,Oe={empty:`No filters applied`,clearAll:`Clear all`,back:`Back to fields`,noOptions:`No options available`,cleared:`All filters cleared`,remove:e=>`Remove ${De(e)}`,added:e=>`Added ${De(e)}`,changed:e=>`Changed ${De(e)}`,removed:e=>`Removed ${De(e)}`};function ke(e,t,n){let r=e.filter(e=>!t.some(t=>t.id===e.id));if(!t.length&&r.length>1)return n.cleared;let i=t.filter(t=>!e.some(e=>e.id===t.id)),a=t.filter(t=>e.some(e=>e.id===t.id&&e.value!==t.value));return[...i.map(n.added),...a.map(n.changed),...r.map(n.removed)].join(`. `)}function Ae({rows:e,labelledBy:n,onChoose:r,onBack:i,onLeave:a,radio:o,emptyMessage:s}){let c=l()??!1,d=A(),f=(0,G.useRef)(null),p=(0,G.useRef)(!1),m=(0,G.useRef)({text:``,at:0}),[h,g]=(0,G.useState)(()=>Math.max(0,e.findIndex(e=>e.checked))),[_,v]=(0,G.useState)(null),y=()=>Array.from(f.current?.querySelectorAll(`[data-row]`)??[]),b=e=>{let t=f.current;e&&t&&(e.focus({preventScroll:!0}),e.offsetTop<t.scrollTop?t.scrollTop=e.offsetTop:e.offsetTop+e.offsetHeight>t.scrollTop+t.clientHeight&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight))};function x(t){let n=y(),a=n.indexOf(document.activeElement),o=e=>{t.preventDefault(),p.current=!1,b(n[e])};if(t.key===`ArrowDown`)return o(a<0?0:(a+1)%n.length);if(t.key===`ArrowUp`)return o(a<0?n.length-1:(a-1+n.length)%n.length);if(t.key===`Home`)return o(0);if(t.key===`End`)return o(n.length-1);if(t.key===`ArrowRight`&&a>=0&&e[a]?.drill){t.preventDefault(),r(e[a],!0);return}if(t.key===`ArrowLeft`&&i){t.preventDefault(),i(!0);return}if(t.key.length===1&&/\S/.test(t.key)&&!t.metaKey&&!t.ctrlKey&&!t.altKey){let e=performance.now();m.current={text:e-m.current.at<700?m.current.text+t.key.toLowerCase():t.key.toLowerCase(),at:e};let r=[...n.slice(a+(m.current.text.length>1?0:1)),...n.slice(0,a+(m.current.text.length>1?0:1))].find(e=>(e.dataset.text??``).toLowerCase().startsWith(m.current.text));r&&o(n.indexOf(r))}}function S(e){let t=e.target.closest(`[data-row]`);if(!t)return;g(y().indexOf(t));let n=p.current&&!c,r=!p.current&&t.matches(`:focus-visible`);v(e=>({top:t.offsetTop,height:t.offsetHeight,glide:n&&!!e?.shown,ring:r,shown:!0}))}function C(e){f.current?.contains(e.relatedTarget)||v(e=>e&&{...e,glide:!1,ring:!1,shown:!1})}return(0,q.jsxs)(`div`,{ref:f,className:K.list,role:`menu`,"aria-labelledby":n,"data-current":d?``:void 0,onKeyDown:x,onFocus:S,onBlur:C,onPointerLeave:()=>{p.current&&f.current?.contains(document.activeElement)&&a()},children:[(0,q.jsx)(u.span,{className:K.highlight,"data-ring":_?.ring||void 0,"aria-hidden":`true`,initial:!1,animate:_?{y:_.top,height:_.height,opacity:+!!_.shown}:{opacity:0},transition:{default:_?.glide?t.spring.snappy:Y,opacity:{duration:c?0:.08}}}),e.length===0?(0,q.jsx)(`p`,{className:K.noOptions,children:s}):null,e.map((e,t)=>(0,q.jsxs)(`button`,{type:`button`,className:K.item,role:o?`menuitemradio`:`menuitem`,"aria-checked":o?!!e.checked:void 0,tabIndex:t===h?0:-1,"data-row":e.key,"data-text":e.label,onPointerMove:e=>{p.current=!0,document.activeElement!==e.currentTarget&&e.currentTarget.focus({preventScroll:!0})},onClick:t=>r(e,t.detail===0),children:[e.icon?(0,q.jsx)(`span`,{className:K.itemIcon,"aria-hidden":`true`,children:e.icon}):null,(0,q.jsx)(`span`,{className:K.itemLabel,children:e.label}),e.meta?(0,q.jsx)(`span`,{className:K.itemMeta,children:e.meta}):null]},e.key))]})}function je(e){let t={left:0,top:0,right:document.documentElement.clientWidth,bottom:window.innerHeight};for(let n=e.parentElement;n&&n!==document.body;n=n.parentElement){let e=getComputedStyle(n);if(e.overflowX===`visible`&&e.overflowY===`visible`)continue;let r=n.getBoundingClientRect();e.overflowX!==`visible`&&(t.left=Math.max(t.left,r.left),t.right=Math.min(t.right,r.right)),e.overflowY!==`visible`&&(t.top=Math.max(t.top,r.top),t.bottom=Math.min(t.bottom,r.bottom))}return t}function Me({fields:e,onSelect:n,active:i=[],label:o=`Add filter`,align:s=`end`,messages:c}){let f={...Oe,...c},p=l()??!1,m=(0,G.useId)(),h=`${m}panel`,g=`${m}title`,v=(0,G.useRef)(null),y=(0,G.useRef)(null),b=(0,G.useRef)(null),x=(0,G.useRef)(`closed`),S=(0,G.useRef)(0),C=(0,G.useRef)(null),[w,T]=(0,G.useState)(`closed`),[E,D]=(0,G.useState)(null),[O,k]=(0,G.useState)(1),[A,j]=(0,G.useState)(!1),[ee,M]=(0,G.useState)(`100% 0`),N=d(`100%`),P=d(`100%`),F=d(0),I=d(0),te=U(()=>I.get()-F.get()),L=d(0),R=d(0),ne=U(()=>{let e=N.get(),t=L.get(),n=R.get();return typeof e==`number`?n>t?be((e-t)/(n-t)):1:0}),z=U(()=>be(ne.get()/.35)),B=U(()=>be((ne.get()-.4)/.5)),re={opacity:U(()=>1-z.get()),scale:U(()=>1-z.get()*.04),filter:U(()=>z.get()?X(z.get()*t.blur.subtle):`none`)},ie={opacity:B,transformOrigin:ee,scale:U(()=>.96+B.get()*.04),y:U(()=>(1-B.get())*(A?-6:6)),filter:U(()=>B.get()===1?`none`:X((1-B.get())*t.blur.soft))},oe=w===`open`,V=e.find(e=>e.id===E)??null,se=(0,G.useCallback)(e=>{let n=y.current,i=b.current;if(!n||!i)return;let a=n.getBoundingClientRect(),o=i.offsetWidth+2,c=i.offsetHeight+2,l=je(v.current??n),u=l.left+16-a.left,d=l.right-16-a.left-o,f=a.width-o,m=s===`end`?f>=u?f:0<=d?0:f:0<=d?0:f>=u?f:0;m=Math.round(Math.min(Math.max(m,u),Math.max(u,d)));let h=l.bottom-a.top,g=a.bottom-l.top,_=h<c+16&&g>h;x.current===`closed`&&(N.jump(a.width),P.jump(a.height),F.jump(0)),I.jump(m),L.jump(a.width),R.jump(o),x.current=`open`,S.current+=1,C.current=e,T(`open`),j(_),D(null),k(-1),M(`${Math.round(a.width/2-m)}px ${_?`100%`:`0`}`);let w=p?Y:t.spring.morph;r(F,m,w),r(N,o,w),r(P,c,w)},[s,L,P,F,p,I,R,N]),H=(0,G.useCallback)(e=>{let n=y.current;if(x.current!==`open`||!n)return;x.current=`closing`;let i=S.current+=1;T(`closing`),e&&n.focus({preventScroll:!0,focusVisible:e===`keyboard`});let a=p?Y:t.spring.snappy;r(F,0,a);let o=n.getBoundingClientRect();r(P,o.height,a),r(N,o.width,{...a,onComplete:()=>{i===S.current&&(x.current=`closed`,N.jump(`100%`),P.jump(`100%`),T(`closed`),D(null))}})},[P,F,p,N]);(0,G.useLayoutEffect)(()=>{let e=b.current;if(!e||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>{x.current===`open`&&r(P,e.offsetHeight+2,p?Y:t.spring.smooth)});return n.observe(e),()=>n.disconnect()},[P,p]),(0,G.useLayoutEffect)(()=>{let e=C.current,t=b.current;if(!e||!t||w!==`open`)return;if(C.current=null,e===`panel`){t.focus({preventScroll:!0});return}let n=Array.from(t.querySelectorAll(`[data-current] [data-row]`));(e===`first`?n[0]:e===`last`?n.at(-1):e===`checked`?n.find(e=>e.getAttribute(`aria-checked`)===`true`)??n[0]:n.find(t=>t.dataset.row===e.key)??n[0])?.focus({preventScroll:!0})},[w,E]),(0,G.useEffect)(()=>{if(w!==`open`)return;let e=e=>{let t=v.current,n=e.target;!t||n&&t.contains(n)||(H(!1),n?.closest?.(`button, a[href], input, select, textarea, [tabindex], [contenteditable]`)||window.setTimeout(()=>{let e=document.activeElement;(!e||e===document.body||t.contains(e))&&y.current?.focus({preventScroll:!0,focusVisible:!1})},0))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[H,w]);function ce(e){if(e.defaultPrevented)return;let t=Array.from(b.current?.querySelectorAll(`[data-current] [data-row]`)??[]);(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),(e.key===`ArrowDown`?t[0]:t.at(-1))?.focus({preventScroll:!0})),e.key===`ArrowLeft`&&V&&(e.preventDefault(),ue(!0))}function ue(e){V&&(C.current=e?{key:V.id}:`panel`,k(-1),D(null))}function de(e,t){C.current=t?`checked`:`panel`,k(1),D(e.key)}function fe(e,t){V&&(n({id:V.id,label:V.label,value:e.key,valueLabel:e.label},V),H(t?`keyboard`:`pointer`))}let pe=e=>i.find(t=>t.id===e.id),me=e.map(e=>({key:e.id,label:e.label,icon:e.icon,drill:!0,meta:(0,q.jsxs)(q.Fragment,{children:[pe(e)?(0,q.jsx)(`span`,{className:K.metaValue,children:Z(pe(e))}):null,(0,q.jsx)(ae,{size:15,strokeWidth:1.8,"aria-hidden":`true`})]})})),W=V?V.options.map(xe).map(e=>{let t=Se(e),n=pe(V)?.value===e.value;return{key:e.value,label:t,icon:e.icon,checked:n,meta:e.hint!=null||n?(0,q.jsxs)(q.Fragment,{children:[e.hint==null?null:(0,q.jsx)(`span`,{className:K.hint,children:e.hint}),(0,q.jsx)(`span`,{className:K.check,"data-on":n||void 0,children:(0,q.jsx)(_,{size:15,strokeWidth:2,"aria-hidden":`true`})})]}):null}}):[],ge={enter:e=>p?{opacity:0}:{opacity:0,x:e*18,filter:X(t.blur.soft)},center:{opacity:1,x:0,filter:X(0),transition:p?ye:{...J,x:t.spring.smooth}},exit:e=>p?{opacity:0,transition:Y}:{opacity:0,x:e*-18,filter:X(t.blur.subtle),transition:ve}};return(0,q.jsxs)(`div`,{ref:v,className:K.menu,"data-state":w,"data-y":A?`up`:`down`,onKeyDown:e=>{e.key===`Escape`&&x.current===`open`&&(e.preventDefault(),e.stopPropagation(),H(`keyboard`))},onBlur:e=>{let t=e.relatedTarget;x.current===`open`&&t&&!v.current?.contains(t)&&H(!1)},children:[(0,q.jsx)(`button`,{ref:y,type:`button`,className:K.trigger,"data-filter-trigger":``,"aria-haspopup":`dialog`,"aria-expanded":oe,"aria-controls":h,tabIndex:oe?-1:void 0,onClick:e=>{x.current!==`open`&&se(e.detail===0?`first`:`panel`)},onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),se(e.key===`ArrowDown`?`first`:`last`))},children:(0,q.jsxs)(u.span,{className:K.face,style:re,children:[(0,q.jsx)(he,{size:15,strokeWidth:1.8,"aria-hidden":`true`}),o]})}),(0,q.jsx)(u.div,{className:K.surface,style:{left:F,width:N,height:P},children:(0,q.jsx)(u.div,{ref:b,id:h,className:K.panel,role:`dialog`,"aria-labelledby":g,tabIndex:-1,inert:!oe,style:{x:te},onKeyDown:ce,children:(0,q.jsxs)(u.div,{style:ie,children:[(0,q.jsxs)(`div`,{className:K.head,children:[(0,q.jsx)(a,{initial:!1,children:V?(0,q.jsx)(u.button,{type:`button`,className:K.back,"aria-label":f.back,onClick:e=>ue(e.detail===0),initial:p?{opacity:0,width:28,marginRight:2}:{opacity:0,width:0,marginRight:0,scale:.6},animate:{opacity:1,width:28,marginRight:2,scale:1},exit:p?{opacity:0,transition:Y}:{opacity:0,width:0,marginRight:0,scale:.6,transition:{...t.spring.snappy,opacity:ve}},transition:p?ye:{...t.spring.snappy,opacity:J},children:(0,q.jsx)(le,{size:16,strokeWidth:1.8,"aria-hidden":`true`})},`back`):null}),(0,q.jsx)(`span`,{className:K.title,id:g,children:(0,q.jsx)(a,{mode:`popLayout`,initial:!1,children:(0,q.jsx)(u.span,{className:K.titleText,...Ce(p),children:V?V.label:o},V?.id??`fields`)})})]}),(0,q.jsx)(`div`,{className:K.stage,children:(0,q.jsx)(a,{mode:`popLayout`,initial:!1,custom:O,children:(0,q.jsx)(u.div,{className:K.step,custom:O,variants:ge,initial:`enter`,animate:`center`,exit:`exit`,children:V?(0,q.jsx)(Ae,{rows:W,labelledBy:g,emptyMessage:f.noOptions,radio:!0,onChoose:fe,onBack:ue,onLeave:()=>b.current?.focus({preventScroll:!0})}):(0,q.jsx)(Ae,{rows:me,labelledBy:g,emptyMessage:f.noOptions,onChoose:de,onLeave:()=>b.current?.focus({preventScroll:!0})})},V?.id??`fields`)})})]})})})]})}function Ne({filters:e,onRemove:n,onClearAll:r,leading:i,children:o,label:s=`Active filters`,addFilter:c,messages:d}){let f={...Oe,...d},p=l()??!1,m=(0,G.useRef)(null),h=(0,G.useRef)(null),g=(0,G.useRef)(0),_=(0,G.useRef)(null),[v,y]=(0,G.useState)(e),[b,S]=(0,G.useState)(``);if(v!==e){y(e);let t=ke(v,e,f);t&&S(t)}let C=e.map(e=>`${e.id}:${e.value??``}`).join(`|`);(0,G.useLayoutEffect)(()=>{g.current=performance.now()+900},[C]);let w=Te(h,g,p);Ee(h,g,p),(0,G.useLayoutEffect)(()=>{let t=_.current,n=m.current;if(t===null||!n)return;_.current=null;let r=e[Math.min(t,e.length-1)];(r?n.querySelector(`[data-chip-remove="${CSS.escape(r.id)}"]`):n.querySelector(`[data-filter-trigger]`))?.focus({preventScroll:!0})},[e]);let T={duration:0},E=e=>({initial:!p&&{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1},animate:{width:`auto`,marginRight:0,transitionEnd:{overflow:`visible`,"--slot-moving":0}},exit:p?{opacity:0,transition:T}:{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1,pointerEvents:`none`,transition:{...t.spring.smooth,"--slot-moving":T}},transition:p?T:t.spring.smooth}),D={initial:!p&&{opacity:0,scale:.9,filter:X(t.blur.soft)},animate:{opacity:1,scale:1,filter:X(0)},exit:p?{opacity:0,transition:T}:{opacity:0,scale:.9,filter:X(t.blur.subtle),transition:ve},transition:p?T:{...J,scale:t.spring.snappy}},O=p?{...Ce(!0),initial:!1}:Ce(!1),k=p?O:{...O,transition:{...J,delay:t.duration.instant*.75}};return(0,q.jsxs)(`div`,{ref:m,className:K.toolbar,role:`group`,"aria-label":s,children:[i?(0,q.jsx)(`div`,{className:K.leading,children:i}):null,(0,q.jsx)(u.div,{className:K.frame,style:{height:w},children:(0,q.jsxs)(`div`,{ref:h,className:K.chips,children:[(0,q.jsx)(a,{initial:!1,children:e.map((e,t)=>(0,q.jsx)(u.span,{className:K.slot,...E(8),children:(0,q.jsxs)(u.span,{className:K.chip,...D,children:[(0,q.jsxs)(`span`,{className:K.chipLabel,title:De(e),children:[e.label,Z(e)?(0,q.jsxs)(`span`,{className:K.value,children:[(0,q.jsx)(`span`,{className:K.separator,children:` · `}),(0,q.jsx)(we,{text:Z(e)})]}):null]}),(0,q.jsx)(`button`,{type:`button`,"data-chip-remove":e.id,"aria-label":f.remove(e),onClick:r=>{document.activeElement===r.currentTarget&&(_.current=t),n(e.id)},children:(0,q.jsx)(x,{size:14,strokeWidth:1.8,"aria-hidden":`true`})})]})},e.id))}),(0,q.jsx)(a,{initial:!1,children:e.length?null:(0,q.jsx)(u.span,{className:K.empty,...k,children:f.empty},`empty`)})]})}),(0,q.jsxs)(`div`,{className:K.actions,children:[c?(0,q.jsx)(Me,{fields:c.fields,onSelect:c.onAdd,active:e,label:c.label,align:c.align,messages:f}):null,o,(0,q.jsx)(a,{initial:!1,children:e.length>0&&r?(0,q.jsx)(u.span,{className:K.slot,...E(12),children:(0,q.jsx)(`button`,{className:K.clear,type:`button`,onClick:()=>{_.current=-1,r?.()},children:(0,q.jsx)(u.span,{className:K.clearText,...O,children:f.clearAll})})},`clear`):null})]}),(0,q.jsx)(`span`,{className:K.srOnly,role:`status`,children:b})]})}var Pe={api_key:`settings.privacy.category.api_key`,aws_key:`settings.privacy.category.aws_key`,jwt:`settings.privacy.category.jwt`,private_key:`settings.privacy.category.private_key`,email:`settings.privacy.category.email`,phone:`settings.privacy.category.phone`,intranet:`settings.privacy.category.intranet`,credit_card:`settings.privacy.category.credit_card`,national_id:`settings.privacy.category.national_id`,credential:`settings.privacy.category.credential`,custom:`settings.privacy.category.custom`},Fe={warn:`settings.privacy.action.warn`,block:`settings.privacy.action.block`,redact:`settings.privacy.action.redact`};function Ie(){let{t:e}=y();return t=>{let n=Pe[t];return n?e(n):t}}function Le({action:e}){let{t}=y();return(0,q.jsx)(O,{tone:e===`block`?`red`:e===`redact`?`orange`:`neutral`,children:t(Fe[e]??`settings.privacy.action.warn`)})}var Re=50,ze=[`block`,`redact`,`warn`];function Be(){let{t:e,locale:t}=y(),n=Ie(),[r,a]=(0,G.useState)(``),[o,s]=(0,G.useState)({client:``,category:``,action:``,blocked:``}),[c,l]=(0,G.useState)(1),[u,d]=(0,G.useState)(null),h=oe(r),g=p(),_=m(),b={model:h,...o,page:c,pageSize:Re},x=S(b,c===1),C=x.data,w=C?Math.max(1,Math.ceil(C.total/Re)):1,E=e=>e?ue[e]?.name??e:`—`,D=[...new Set((_.data?.rules??[]).map(e=>e.category))],O={client:(g.data??[]).map(e=>({value:e.kind,label:e.name})),category:D.map(e=>({value:e,label:n(e)})),action:ze.map(t=>({value:t,label:e(`settings.privacy.action.${t}`)})),blocked:[{value:`true`,label:e(`privacy.logs.blockedOnly`)},{value:`false`,label:e(`privacy.logs.passedOnly`)}]},A={client:e(`requests.col.client`),category:e(`privacy.stats.col.category`),action:e(`privacy.logs.col.action`),blocked:e(`privacy.logs.col.outcome`)},M=Object.keys(O).map(e=>({id:e,label:A[e],options:O[e].map(e=>e.label)})),P=Object.keys(o).filter(e=>o[e]).map(e=>({id:e,label:A[e],value:O[e].find(t=>t.value===o[e])?.label??o[e]})),F=(e,t)=>{s(n=>({...n,[e]:t})),l(1)},te=(C?.items??[]).map(e=>({id:e.id,time:Date.parse(e.startedAtUtc),client:E(e.clientKind),model:e.requestedModel??``,outcome:Ve(e),hits:e.hits.reduce((e,t)=>e+t.count,0),e})),L=[{key:`time`,label:e(`requests.col.time`),width:92,render:(e,n)=>(0,q.jsx)(`span`,{className:`num`,children:i(n.e.startedAtUtc,t)})},{key:`model`,label:e(`requests.col.model`),render:(t,n)=>(0,q.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>d(n.id),"aria-label":e(`privacy.logs.viewRequest`,{model:n.model||n.id}),children:[(0,q.jsx)(`span`,{className:`block truncate font-medium hover:text-[var(--accent)]`,children:n.model||`—`}),(0,q.jsx)(`span`,{className:`block truncate text-[11px] text-[var(--text-muted)]`,children:E(n.e.clientKind)})]})},{key:`outcome`,label:e(`privacy.logs.col.outcome`),width:130,render:(e,t)=>(0,q.jsx)(He,{event:t.e})},{key:`hits`,label:e(`privacy.logs.col.hits`),render:(e,t)=>(0,q.jsx)(Ue,{event:t.e})},{key:`client`,label:e(`requests.col.client`),width:110,render:e=>(0,q.jsx)(`span`,{className:`block truncate`,children:String(e||`—`)})}];return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,q.jsx)(T,{className:`w-52`,value:r,onChange:e=>{a(e),l(1)},placeholder:e(`requests.searchModel`)}),(0,q.jsx)(j,{variant:`plain`,icon:(0,q.jsx)(H,{className:k(`size-4`,x.isFetching&&`animate-spin`)}),"aria-label":e(`common.refresh`),onClick:()=>void x.refetch()})]}),(0,q.jsx)(`div`,{className:`mb-3`,children:(0,q.jsx)(Ne,{label:e(`requests.filters`),filters:P,onRemove:e=>F(e,``),onClearAll:()=>{s({client:``,category:``,action:``,blocked:``}),l(1)},addFilter:{fields:M,label:e(`requests.addFilter`),onAdd:e=>{let t=e.id,n=O[t].find(t=>t.label===e.value)?.value;n&&F(t,n)}}})}),x.isLoading&&(0,q.jsx)(N,{lines:4,className:`py-6`}),x.isError&&(0,q.jsx)(ee,{tone:`danger`,title:e(`common.error`),children:I(x.error)}),C&&C.items.length===0&&(0,q.jsx)(v,{icon:(0,q.jsx)(_e,{className:`size-6`}),title:e(`privacy.logs.empty`),detail:e(`privacy.logs.empty.detail`)}),C&&C.items.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mb-2 text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.total`,{count:f(C.total)})}),(0,q.jsx)(B,{caption:e(`privacy.tab.logs`),rows:te,columns:L,rowKey:`id`,emptyMessage:e(`privacy.logs.empty`)})]}),C&&w>1&&(0,q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,q.jsx)(de,{page:c,pageCount:w,onPageChange:l,label:e(`requests.page`,{page:c,pages:w})})}),(0,q.jsx)(pe,{id:u,onClose:()=>d(null)})]})}function Ve(e){return e.blocked?`blocked`:e.redactions>0?`redact`:e.dryRun?`dryRun`:`warn`}function He({event:e}){let{t}=y();return e.blocked?(0,q.jsx)(O,{tone:`red`,children:t(`privacy.logs.outcome.blocked`)}):e.redactions>0?(0,q.jsx)(O,{tone:`orange`,children:t(`privacy.logs.outcome.redacted`,{count:e.redactions})}):e.dryRun?(0,q.jsx)(O,{tone:`neutral`,children:t(`privacy.logs.outcome.dryRun`)}):(0,q.jsx)(O,{tone:`neutral`,children:t(`settings.privacy.action.warn`)})}function Ue({event:e}){let t=Ie(),{t:n}=y();if(e.hits.length===0)return(0,q.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`—`});let r=e.hits.slice(0,2),i=e.hits.length-r.length;return(0,q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px]`,children:[r.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,q.jsx)(Le,{action:e.action}),(0,q.jsxs)(`span`,{children:[t(e.category),` × `,e.count]}),e.samples&&e.samples.length>0&&(0,q.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:e.samples.slice(0,2).join(` `)})]},`${e.ruleId}:${e.action}`)),i>0&&(0,q.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:n(`privacy.logs.moreHits`,{count:i})})]})}var Q={counter:`_counter_dnoch_1`,label:`_label_dnoch_2`,value:`_value_dnoch_4`,column:`_column_dnoch_6`,sizer:`_sizer_dnoch_7`,glyph:`_glyph_dnoch_8`,labelText:`_labelText_dnoch_9`,labelSwap:`_labelSwap_dnoch_10`,symbol:`_symbol_dnoch_11`,srOnly:`_srOnly_dnoch_12`},We=[0,1,2,3,4,5,6,7,8,9],Ge={hidden:{opacity:0,y:`0.3em`,filter:`blur(${t.blur.soft}px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:t.duration.standard,ease:[...t.ease.enter]}},gone:{opacity:0,y:`-0.3em`,filter:`blur(${t.blur.subtle}px)`,transition:{duration:t.duration.fast,ease:[...t.ease.standard]}}},Ke={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:t.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:t.duration.instant}}},qe={...t.spring.smooth,visualDuration:t.duration.considered};function Je(e,t,n){let r=new Intl.NumberFormat(n,{minimumFractionDigits:t,maximumFractionDigits:t,numberingSystem:`latn`}).formatToParts(e),i=r.reduce((e,t)=>e+(t.type===`integer`?t.value.length:0),0),a=0,o=0;return r.flatMap((e,t)=>e.type===`integer`?[...e.value].map(e=>({key:`i${--i}`,digit:Number(e),order:o++})):e.type===`fraction`?[...e.value].map(e=>({key:`f${a++}`,digit:Number(e),order:o++})):[{key:e.type===`group`?`g${i}`:e.type===`decimal`?`d`:`${e.type}${t}`,text:e.value}])}function Ye({position:e,digit:n}){let r=U(e,e=>((n-e)%10+15)%10-5),i=U(r,e=>`${e}em`),a=U(r,e=>Math.max(0,1-Math.abs(e))),o=U(r,e=>Math.abs(e)>=1?`hidden`:`visible`),s=U(r,e=>Math.abs(e)<.02||Math.abs(e)>=1?`none`:`blur(${(Math.abs(e)*t.blur.subtle).toFixed(2)}px)`);return(0,q.jsx)(u.span,{className:Q.glyph,style:{y:i,opacity:a,filter:s,visibility:o},children:n})}var Xe={initial:{width:0,opacity:0},animate:{width:`auto`,opacity:1},exit:{width:0,opacity:0}};function Ze({digit:e,direction:n,armed:i,delay:a,reduceMotion:o}){let s=d(i?0:e),c=(0,G.useRef)({digit:i?0:e,target:i?0:e,revealed:!i});return(0,G.useEffect)(()=>{let l=c.current;if(i||l.digit===e){i||(l.revealed=!0);return}l.target+=n<0&&l.revealed?-((l.digit-e+10)%10):(e-l.digit+10)%10,l.digit=e,o?s.jump(l.target):r(s,l.target,l.revealed?t.spring.smooth:{...qe,delay:a}),l.revealed=!0},[i,a,e,n,s,o]),(0,q.jsxs)(u.span,{className:Q.column,...Xe,transition:o?{duration:0}:t.spring.morph,children:[(0,q.jsx)(`span`,{className:Q.sizer,children:`0`}),We.map(e=>(0,q.jsx)(Ye,{position:s,digit:e},e))]})}function Qe({value:e,label:n,prefix:r=``,suffix:i=``,decimals:o=0,animateOnView:s=!1,locale:c=`en-US`}){let d=(0,G.useRef)(null),f=me(d,{once:!0,amount:.6}),p=!!l(),[m,h]=(0,G.useState)(e),[g,_]=(0,G.useState)(1);e!==m&&(h(e),_(e>m?1:-1));let v=Je(e,o,c),y=`${r}${v.map(e=>`text`in e?e.text:e.digit).join(``)}${i}`,b=s&&!f;return(0,q.jsxs)(`span`,{ref:d,className:Q.counter,children:[n&&(0,q.jsx)(`span`,{className:Q.label,children:(0,q.jsx)(`span`,{className:Q.labelSwap,children:(0,q.jsx)(a,{mode:`popLayout`,initial:!1,children:(0,q.jsx)(u.span,{className:Q.labelText,variants:p?Ke:Ge,initial:`hidden`,animate:`shown`,exit:`gone`,children:n},n)})})}),(0,q.jsx)(`span`,{className:Q.srOnly,children:y}),(0,q.jsxs)(`span`,{className:Q.value,"aria-hidden":`true`,children:[r&&(0,q.jsx)(`span`,{className:Q.symbol,children:r}),(0,q.jsx)(a,{initial:!1,children:v.map(e=>`digit`in e?(0,q.jsx)(Ze,{digit:e.digit,direction:g,armed:b,delay:Math.min(e.order*t.stagger.item,.25),reduceMotion:p},e.key):(0,q.jsx)(u.span,{className:Q.symbol,...Xe,transition:p?{duration:0}:t.spring.morph,children:e.text},e.key))}),i&&(0,q.jsx)(`span`,{className:Q.symbol,children:i})]})]})}var $={card:`_card_1r6t9_1`,top:`_top_1r6t9_2`,swap:`_swap_1r6t9_8`,swapBlock:`_swapBlock_1r6t9_8`,text:`_text_1r6t9_11`,sizer:`_sizer_1r6t9_13`},$e={hidden:e=>({opacity:0,y:`${.3*e}em`,filter:`blur(${t.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:t.duration.standard,ease:[...t.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${t.blur.subtle}px)`,transition:{duration:t.duration.fast,ease:[...t.ease.standard]}})},et={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:t.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:t.duration.instant}}},tt=e=>Number(e.replace(/,/g,``).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN);function nt({text:e,morph:n=!1,block:i=!1}){let o=!!l(),s=(0,G.useRef)(null),c=d(`auto`),[f,p]=(0,G.useState)({text:e,direction:1});return f.text!==e&&p({text:e,direction:tt(e)<tt(f.text)?-1:1}),(0,G.useEffect)(()=>{let e=s.current;if(!e||typeof ResizeObserver>`u`)return;let n=null,i=new ResizeObserver(([i])=>{let a=i.borderBoxSize?.[0]?.inlineSize??e.offsetWidth;a&&n!==null&&n!==e.textContent&&!o?r(c,a,t.spring.morph):c.jump(a||`auto`),n=a?e.textContent:null});return i.observe(e),()=>i.disconnect()},[n,o,c]),(0,q.jsxs)(u.span,{className:i?$.swapBlock:$.swap,style:n?{width:c}:void 0,children:[n&&(0,q.jsx)(`span`,{ref:s,className:$.sizer,"aria-hidden":`true`,children:e}),(0,q.jsx)(a,{mode:`popLayout`,initial:!1,custom:f.direction,children:(0,q.jsx)(u.span,{className:$.text,custom:f.direction,variants:o?et:$e,initial:`hidden`,animate:`shown`,exit:`gone`,children:e},e)})]})}function rt({label:e,value:n,suffix:r,context:i,change:o}){let s=!!l();return(0,q.jsxs)(`article`,{className:$.card,children:[(0,q.jsxs)(`div`,{className:$.top,children:[(0,q.jsx)(`span`,{children:(0,q.jsx)(nt,{text:e,block:!0})}),(0,q.jsx)(a,{initial:!1,children:o&&(0,q.jsx)(u.small,{"data-trend":/^[+]/.test(o)?`up`:/^[-−]/.test(o)?`down`:void 0,initial:{opacity:0,scale:s?1:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:s?1:.96,transition:{duration:t.duration.fast,ease:[...t.ease.standard]}},transition:s?{duration:0}:t.spring.snappy,children:(0,q.jsx)(nt,{text:o,morph:!0})},`change`)})]}),(0,q.jsx)(Qe,{value:n,suffix:r,animateOnView:!0}),(0,q.jsx)(`p`,{children:(0,q.jsx)(nt,{text:i,block:!0})})]})}var it=[{id:`ipv4-all`,nameKey:`settings.privacy.template.ipv4All`,hintKey:`settings.privacy.template.ipv4AllHint`,pattern:String.raw`(?<![\d.])(?:\d{1,3}\.){3}\d{1,3}(?![\d.])`},{id:`landline`,nameKey:`settings.privacy.template.landline`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<!\d)0\d{2,3}[- ]?\d{7,8}(?!\d)`},{id:`license-plate`,nameKey:`settings.privacy.template.licensePlate`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]`},{id:`passport-cn`,nameKey:`settings.privacy.template.passportCn`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])[EG]\d{8}(?!\d)`},{id:`uscc`,nameKey:`settings.privacy.template.uscc`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![0-9A-HJ-NPQRTUWXY])[0-9A-HJ-NPQRTUWXY]{18}(?![0-9A-HJ-NPQRTUWXY])`},{id:`long-token`,nameKey:`settings.privacy.template.longToken`,hintKey:`settings.privacy.template.longTokenHint`,pattern:String.raw`(?<![A-Za-z0-9])[A-Za-z0-9_\-]{32,}(?![A-Za-z0-9])`},{id:`mac-address`,nameKey:`settings.privacy.template.macAddress`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![0-9A-Fa-f:])(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}(?![0-9A-Fa-f:])`},{id:`unix-home`,nameKey:`settings.privacy.template.unixHome`,hintKey:`settings.privacy.template.unixHomeHint`,pattern:String.raw`/(?:Users|home)/[A-Za-z0-9_.\-]+`},{id:`windows-profile`,nameKey:`settings.privacy.template.windowsProfile`,hintKey:`settings.privacy.template.unixHomeHint`,pattern:String.raw`[A-Za-z]:\\+Users\\+[A-Za-z0-9_.\-]+`},{id:`cloud-accesskey`,nameKey:`settings.privacy.template.cloudAccessKey`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])(?:LTAI[A-Za-z0-9]{12,20}|AKID[A-Za-z0-9]{13,40})(?![A-Za-z0-9])`},{id:`aws-secret-key`,nameKey:`settings.privacy.template.awsSecretKey`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9/+=])[A-Za-z0-9/+=]{40}(?![A-Za-z0-9/+=])`},{id:`im-webhook`,nameKey:`settings.privacy.template.imWebhook`,hintKey:`settings.privacy.template.imWebhookHint`,pattern:String.raw`oapi\.dingtalk\.com/robot/send\?access_token=[0-9a-f]{64}|qyapi\.weixin\.qq\.com/cgi-bin/webhook/send\?key=[0-9a-f]{32}|open\.feishu\.cn/open-apis/bot/v2/hook/[0-9a-f\-]{20,}|hooks\.slack\.com/services/T[A-Za-z0-9]+/B[A-Za-z0-9]+/[A-Za-z0-9]+`},{id:`internal-service`,nameKey:`settings.privacy.template.internalService`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?:gitlab|jenkins|jira|confluence|wiki|nexus|harbor|grafana|kibana|sonarqube|oa|sso)\.[A-Za-z0-9\-]+(?:\.[A-Za-z0-9\-]+)+`},{id:`jdbc-conn`,nameKey:`settings.privacy.template.jdbcConn`,hintKey:`settings.privacy.template.jdbcHint`,pattern:String.raw`jdbc:[A-Za-z0-9]+:[^\s"']*(?:[Uu]ser(?:[ _]?[Ii][Dd])?|[Pp]assword)=[^\s"&';]+`},{id:`smtp-conn`,nameKey:`settings.privacy.template.smtpConn`,hintKey:`settings.privacy.template.jdbcHint`,pattern:String.raw`(?:smtp|imap|pop3)s?://[^\s:@/]+:[^\s@]+@[^\s]+`},{id:`key-file-ref`,nameKey:`settings.privacy.template.keyFileRef`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`[A-Za-z0-9_\-./\\]+\.(?:pem|key|pfx|p12|jks|keystore)\b`},{id:`confidential-marker`,nameKey:`settings.privacy.template.confidentialMarker`,hintKey:`settings.privacy.template.confidentialHint`,pattern:String.raw`(?:绝密|机密|商业秘密|内部资料|内部公开|仅限内部|请勿外传|Confidential|Internal Use Only|Internal Only|Company Private)`},{id:`employee-id`,nameKey:`settings.privacy.template.employeeId`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])(?:[Ee][Mm][Pp]|工号)[::\- ]?\d{4,10}(?!\d)`},{id:`labeled-number`,nameKey:`settings.privacy.template.labeledNumber`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?:合同|订单|采购单|工单|项目)编号[::]?\s*[A-Za-z0-9_\-]{4,32}`}],at=[`off`,`warn`,`block`,`redact`],ot=Fe;function st(){let{t:e}=y(),{toast:t}=L(),n=m(),r=C(),i=n.data?.settings,a=e=>{i&&r.mutate({...i,...e},{onError:e=>t(I(e),`error`)})},o=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])}));return(0,q.jsxs)(M,{title:e(`settings.privacy`),footer:e(`settings.privacy.footer`),children:[n.isLoading&&(0,q.jsx)(N,{className:`my-4`}),n.isError&&(0,q.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--danger)]`,children:I(n.error)}),i&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(D,{label:e(`settings.privacy.enabled`),detail:e(`settings.privacy.enabledHint`),children:(0,q.jsx)(F,{checked:i.enabled,label:e(`settings.privacy.enabled`),onChange:e=>a({enabled:e})})}),(0,q.jsx)(D,{label:e(`settings.privacy.dryRun`),detail:e(`settings.privacy.dryRunHint`),children:(0,q.jsx)(F,{checked:i.dryRun,disabled:!i.enabled,label:e(`settings.privacy.dryRun`),onChange:e=>a({dryRun:e})})}),(0,q.jsx)(D,{label:e(`settings.privacy.restore`),detail:e(`settings.privacy.restoreHint`),children:(0,q.jsx)(F,{checked:i.restoreResponses,disabled:!i.enabled,label:e(`settings.privacy.restore`),onChange:e=>a({restoreResponses:e})})}),(0,q.jsx)(D,{label:e(`settings.privacy.recordSamples`),detail:e(`settings.privacy.recordSamplesHint`),children:(0,q.jsx)(F,{checked:i.recordSamples,disabled:!i.enabled,label:e(`settings.privacy.recordSamples`),onChange:e=>a({recordSamples:e})})}),(0,q.jsx)(D,{label:e(`settings.privacy.recordFullSamples`),detail:e(`settings.privacy.recordFullSamplesHint`),children:(0,q.jsx)(F,{checked:i.recordFullSamples,disabled:!i.enabled||!i.recordSamples,label:e(`settings.privacy.recordFullSamples`),onChange:e=>a({recordFullSamples:e})})}),(0,q.jsx)(D,{label:e(`settings.privacy.defaultAction`),children:(0,q.jsx)(R,{className:`w-36`,ariaLabel:e(`settings.privacy.defaultAction`),value:i.defaultAction,disabled:!i.enabled,onChange:e=>a({defaultAction:e}),options:o})})]})]})}function ct(){let{t:e}=y(),{toast:t}=L(),n=m(),r=C(),i=n.data?.settings,a=Ie(),o=e=>{i&&r.mutate({...i,...e},{onError:e=>t(I(e),`error`)})},s=(e,t)=>o({categoryActions:{...i?.categoryActions,[e]:t}}),c=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])})),l=[...new Set((n.data?.rules??[]).map(e=>e.category))],u=e=>n.data?.rules.find(t=>t.category===e)?.description;return n.isLoading?(0,q.jsx)(`div`,{className:`mx-auto max-w-[720px]`,children:(0,q.jsx)(N,{className:`my-4`})}):i?(0,q.jsxs)(`div`,{className:`mx-auto flex max-w-[720px] flex-col gap-4`,children:[(0,q.jsx)(M,{title:e(`settings.privacy.categories`),children:l.map(t=>{let n=i.categoryActions[t]??i.defaultAction,r=!i.enabled||n===`off`;return(0,q.jsxs)(D,{label:a(t),detail:u(t),children:[n===`off`?(0,q.jsx)(O,{children:e(`settings.privacy.action.off`)}):(0,q.jsx)(R,{className:`w-36`,ariaLabel:a(t),value:n,disabled:!i.enabled,onChange:e=>s(t,e),options:c.filter(e=>e.value!==`off`)}),r&&(0,q.jsx)(j,{size:`sm`,variant:`plain`,disabled:!i.enabled,onClick:()=>s(t,i.categoryActions[t]??i.defaultAction),children:e(`settings.privacy.enableCategory`)})]},t)})}),(0,q.jsx)(lt,{s:i,onPatch:o})]}):null}function lt({s:e,onPatch:t}){let{t:n}=y(),{confirm:r}=L(),[i,a]=(0,G.useState)(!1),o=(n,r)=>t({customRules:e.customRules.map(e=>e.id===n.id?{...e,enabled:r}:e)}),s=async i=>{await r({title:n(`settings.privacy.deleteRuleConfirm`,{name:i.name}),destructive:!0,confirmLabel:n(`common.delete`)})&&t({customRules:e.customRules.filter(e=>e.id!==i.id)})};return(0,q.jsxs)(M,{title:n(`settings.privacy.customRules`),children:[e.customRules.length===0&&(0,q.jsx)(`div`,{className:`px-4 py-4 text-[12px] text-[var(--text-secondary)]`,children:n(`settings.privacy.noCustomRules`)}),e.customRules.map(t=>(0,q.jsxs)(D,{label:t.name,detail:t.pattern,children:[(0,q.jsx)(F,{checked:t.enabled,disabled:!e.enabled,label:t.name,onChange:e=>o(t,e)}),(0,q.jsx)(j,{size:`sm`,variant:`plain`,icon:(0,q.jsx)(V,{className:`size-3.5`}),"aria-label":`${n(`common.delete`)} ${t.name}`,onClick:()=>void s(t)})]},t.id)),(0,q.jsx)(`div`,{className:`px-4 py-2`,children:(0,q.jsx)(j,{size:`sm`,icon:(0,q.jsx)(he,{className:`size-3.5`}),disabled:!e.enabled,onClick:()=>a(!0),children:n(`settings.privacy.addRule`)})}),(0,q.jsx)(ut,{open:i,onOpenChange:a,onAdd:n=>t({customRules:[...e.customRules,n]})})]})}function ut({open:e,onOpenChange:t,onAdd:n}){let{t:r}=y(),{toast:i}=L(),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(``);return(0,q.jsx)(te,{open:e,onOpenChange:t,title:r(`settings.privacy.addRule`),width:480,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(j,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,q.jsx)(j,{variant:`primary`,disabled:!a.trim()||!s.trim(),onClick:()=>{if(a.trim()&&s.trim()){try{new RegExp(s)}catch(e){i(`${r(`settings.privacy.invalidPattern`)}: ${I(e)}`,`error`);return}n({id:`custom-${Date.now().toString(36)}`,name:a.trim(),pattern:s.trim(),enabled:!0}),o(``),c(``),u(``),t(!1)}},children:r(`common.create`)})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(E,{label:r(`settings.privacy.ruleTemplates`),hint:r(`settings.privacy.ruleTemplatesHint`),children:(0,q.jsx)(R,{ariaLabel:r(`settings.privacy.ruleTemplates`),value:l,onChange:e=>{u(e);let t=it.find(t=>t.id===e);t&&(o(r(t.nameKey)),c(t.pattern))},options:[{value:``,label:r(`settings.privacy.ruleTemplateNone`)},...it.map(e=>({value:e.id,label:r(e.nameKey)}))]})}),(0,q.jsx)(b,{label:r(`settings.privacy.ruleName`),value:a,onChange:e=>o(e.target.value),autoFocus:!0}),(0,q.jsx)(E,{label:r(`settings.privacy.rulePattern`),hint:r(`settings.privacy.rulePatternHint`),children:(0,q.jsx)(g,{mono:!0,rows:3,value:s,onChange:e=>c(e.target.value)})})]})})}function dt(){let{t:e}=y(),{toast:t}=L(),n=Ie(),r=m(),i=s(),[a,o]=(0,G.useState)(``),c=i.data,l=r.data?.settings.enabled??!1;return(0,q.jsx)(M,{title:e(`settings.privacy.tester`),footer:e(`settings.privacy.testerHint`),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,q.jsx)(g,{"aria-label":e(`settings.privacy.tester`),placeholder:e(`settings.privacy.testerPlaceholder`),rows:4,mono:!0,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(`div`,{children:(0,q.jsx)(j,{icon:(0,q.jsx)(ie,{className:`size-3.5`}),disabled:!l||!a.trim(),loading:i.isPending,onClick:()=>i.mutate({text:a},{onError:e=>t(I(e),`error`)}),children:e(`settings.privacy.runTest`)})}),c&&(0,q.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] px-3 py-2 text-[12px]`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c.blocked&&(0,q.jsx)(O,{tone:`red`,children:e(`settings.privacy.wouldBlock`)}),c.wouldRedact>0&&(0,q.jsx)(O,{tone:`orange`,children:e(`settings.privacy.wouldRedact`,{count:c.wouldRedact})}),!c.blocked&&c.wouldRedact===0&&(0,q.jsx)(O,{tone:`green`,children:e(`settings.privacy.noHits`)})]}),c.hits.length>0&&(0,q.jsx)(`ul`,{className:`mt-2 space-y-1`,children:c.hits.map(t=>(0,q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(O,{tone:t.action===`block`?`red`:t.action===`redact`?`orange`:`neutral`,children:e(ot[t.action])}),(0,q.jsxs)(`span`,{children:[n(t.category),` · `,t.ruleId,` × `,t.count]}),t.samples&&t.samples.length>0&&(0,q.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:t.samples.join(` `)})]},`${t.ruleId}:${t.action}`))})]})]})})}var ft=[`today`,`7d`,`30d`,`all`];function pt(){let{t}=y(),n=Ie(),[r,i]=(0,G.useState)(`7d`),a=e(r),o=a.data,s=[{key:`category`,label:t(`privacy.stats.col.category`),render:e=>n(String(e))},{key:`requests`,label:t(`privacy.stats.col.requests`),numeric:!0,width:110},{key:`hits`,label:t(`privacy.stats.col.hits`),numeric:!0,width:96},{key:`warnHits`,label:t(`privacy.stats.col.warn`),numeric:!0,width:84},{key:`blockHits`,label:t(`privacy.stats.col.block`),numeric:!0,width:84},{key:`redactHits`,label:t(`privacy.stats.col.redact`),numeric:!0,width:84}],c=(o?.categories??[]).map(e=>({...e}));return(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`section`,{children:[(0,q.jsx)(w,{action:(0,q.jsx)(h,{ariaLabel:t(`overview.range`),value:r,onChange:i,items:ft.map(e=>({value:e,label:t(`range.${e}`)}))}),children:t(`privacy.stats`)}),a.isLoading&&(0,q.jsx)(N,{lines:3,className:`py-4`}),a.isError&&(0,q.jsx)(ee,{tone:`danger`,title:t(`common.error`),children:I(a.error)}),o&&(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,q.jsx)(rt,{label:t(`privacy.stats.events`),value:o.events,context:t(`range.${r}`)}),(0,q.jsx)(rt,{label:t(`privacy.stats.blocked`),value:o.blocked,context:t(`range.${r}`)}),(0,q.jsx)(rt,{label:t(`privacy.stats.redactions`),value:o.redactions,context:t(`range.${r}`)}),(0,q.jsx)(rt,{label:t(`privacy.stats.dryRun`),value:o.dryRun,context:t(`range.${r}`)})]})]}),(0,q.jsxs)(`section`,{children:[(0,q.jsx)(w,{children:t(`privacy.stats.byCategory`)}),o&&o.categories.length===0&&(0,q.jsx)(`div`,{className:`card`,children:(0,q.jsx)(mt,{})}),o&&o.categories.length>0&&(0,q.jsx)(B,{caption:t(`privacy.stats.byCategory`),rows:c,columns:s,rowKey:`category`,defaultSort:{key:`hits`,direction:`desc`}})]}),(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-[720px]`,children:(0,q.jsx)(st,{})})]})}function mt(){let{t:e}=y();return(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-center`,children:[(0,q.jsx)(ie,{className:`size-6 text-[var(--text-muted)]`}),(0,q.jsx)(`div`,{className:`text-[13px]`,children:e(`privacy.logs.empty`)}),(0,q.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.empty.detail`)})]})}var ht=[`overview`,`logs`,`rules`,`tester`];function gt(){let{t:e}=y(),{tab:t}=ne(),n=se(),r=ht.includes(t)?t:`overview`;return(0,q.jsx)(fe,{title:e(`nav.privacy`),subtitle:e(`settings.privacy.footer`),children:(0,q.jsxs)(z,{value:r,onValueChange:e=>n(`/privacy/${e}`,{replace:!0}),children:[(0,q.jsx)(ce,{"aria-label":e(`nav.privacy`),children:ht.map(t=>(0,q.jsx)(re,{value:t,children:e(`privacy.tab.${t}`)},t))}),(0,q.jsx)(W,{value:`overview`,className:`pt-5`,children:(0,q.jsx)(pt,{})}),(0,q.jsx)(W,{value:`logs`,className:`pt-4`,children:(0,q.jsx)(Be,{})}),(0,q.jsx)(W,{value:`rules`,className:`pt-5`,children:(0,q.jsx)(ct,{})}),(0,q.jsx)(W,{value:`tester`,className:`pt-5 [&>div]:mx-auto [&>div]:max-w-[680px]`,children:(0,q.jsx)(dt,{})})]})})}export{gt as PrivacyPage};