@aidotnet/server-darwin-arm64 0.13.6 → 0.14.1

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 (59) hide show
  1. package/bin/astra-server +2 -2
  2. package/bin/wwwroot/assets/ClientsPage-Bbx4JQCh.js +9 -0
  3. package/bin/wwwroot/assets/KeyPage-EhvcnnPs.js +1 -0
  4. package/bin/wwwroot/assets/ModelDetailPage-Bi6HMYd9.js +1 -0
  5. package/bin/wwwroot/assets/ModelsPage-BXY68Eiv.js +1 -0
  6. package/bin/wwwroot/assets/PluginsPage-CGYvvJ4L.js +2 -0
  7. package/bin/wwwroot/assets/PrivacyPage-DsoFM60K.js +1 -0
  8. package/bin/wwwroot/assets/ProviderDetailPage-DggKqw4-.js +3 -0
  9. package/bin/wwwroot/assets/ProvidersPage-BiX8gU3n.js +2 -0
  10. package/bin/wwwroot/assets/SettingsPage-Cg3fYnlZ.js +2 -0
  11. package/bin/wwwroot/assets/{SmartRoutingPage-C8UPuxod.js → SmartRoutingPage-7EE9Wv4s.js} +2 -2
  12. package/bin/wwwroot/assets/TokenDetailPage-BGBhv8pL.js +1 -0
  13. package/bin/wwwroot/assets/{TokenPoolEditor-CSR-HDQz.js → TokenPoolEditor-P5q4QPdp.js} +1 -1
  14. package/bin/wwwroot/assets/TokensPage-C85gZule.js +1 -0
  15. package/bin/wwwroot/assets/TracesPage-Cjalyj5v.js +8 -0
  16. package/bin/wwwroot/assets/TrayPanelPage-DpXBU7l9.js +1 -0
  17. package/bin/wwwroot/assets/TrayPanelView-B2Bc2IHk.js +1 -0
  18. package/bin/wwwroot/assets/alert-Clz2DftU.js +15 -0
  19. package/bin/wwwroot/assets/{arrow-down-DZLYQSjE.js → arrow-down-D4v2aNc0.js} +1 -1
  20. package/bin/wwwroot/assets/{arrow-left-D_GXSlab.js → arrow-left-B41OJQ5k.js} +1 -1
  21. package/bin/wwwroot/assets/{arrow-up-right-6yJy6Xdl.js → arrow-up-right-Bl1glSI-.js} +1 -1
  22. package/bin/wwwroot/assets/{checkbox-j5bCl2a6.js → checkbox-B4uUeJZd.js} +1 -1
  23. package/bin/wwwroot/assets/{cloud-download-D02pcV_l.js → cloud-download-BZA23qWN.js} +1 -1
  24. package/bin/wwwroot/assets/confirm-morph-BHc1Rk5D.js +1 -0
  25. package/bin/wwwroot/assets/{download-DDp7Ezie.js → download-1kPyvAIz.js} +1 -1
  26. package/bin/wwwroot/assets/{ellipsis-D10W7mYw.js → ellipsis-Dzh8eeEb.js} +1 -1
  27. package/bin/wwwroot/assets/{external-link-DTLyxO14.js → external-link-CP_HY9s9.js} +1 -1
  28. package/bin/wwwroot/assets/{folder-open-VpvxiCWo.js → folder-open-gI3OxPvC.js} +1 -1
  29. package/bin/wwwroot/assets/{index-CIeJgTvn.css → index-DUNJByVq.css} +1 -1
  30. package/bin/wwwroot/assets/{index-DL_p8MKk.js → index-LdSd2gU7.js} +8 -8
  31. package/bin/wwwroot/assets/{log-out-DOsFUSwe.js → log-out-CLSeCkdA.js} +1 -1
  32. package/bin/wwwroot/assets/minus-CXBFbKrB.js +1 -0
  33. package/bin/wwwroot/assets/overlays-UV1fYmtB.js +41 -0
  34. package/bin/wwwroot/assets/{pencil-Zf5QNEUX.js → pencil-C4YX2See.js} +1 -1
  35. package/bin/wwwroot/assets/{power-B2lC52A0.js → power-CmBUImgB.js} +1 -1
  36. package/bin/wwwroot/assets/radio-cards-B0VL-JIL.js +1 -0
  37. package/bin/wwwroot/assets/{rotate-ccw-DwTwYkU2.js → rotate-ccw-ClcBYxmg.js} +1 -1
  38. package/bin/wwwroot/assets/{sortable.esm-Btakc5-n.js → sortable.esm-DLqkwcx8.js} +1 -1
  39. package/bin/wwwroot/index.html +4 -4
  40. package/package.json +1 -1
  41. package/bin/wwwroot/assets/ClientsPage-DdK1X-Ec.js +0 -9
  42. package/bin/wwwroot/assets/KeyPage-dJ_528w9.js +0 -1
  43. package/bin/wwwroot/assets/ModelDetailPage-DesYkEp0.js +0 -1
  44. package/bin/wwwroot/assets/ModelsPage-CvBrKMJm.js +0 -1
  45. package/bin/wwwroot/assets/PluginsPage-Czuxiksr.js +0 -2
  46. package/bin/wwwroot/assets/PrivacyPage-CxAIxf_4.js +0 -1
  47. package/bin/wwwroot/assets/ProviderDetailPage-zjVraUzS.js +0 -3
  48. package/bin/wwwroot/assets/ProvidersPage-D1GpUvNb.js +0 -2
  49. package/bin/wwwroot/assets/SettingsPage-CDgCn_us.js +0 -2
  50. package/bin/wwwroot/assets/TokenDetailPage-ClqiNQNY.js +0 -1
  51. package/bin/wwwroot/assets/TokensPage-B62tF1Mb.js +0 -1
  52. package/bin/wwwroot/assets/TracesPage-Dadx7Tfx.js +0 -8
  53. package/bin/wwwroot/assets/TrayPanelPage-Ckj4lTgg.js +0 -1
  54. package/bin/wwwroot/assets/TrayPanelView-bAOrJBs5.js +0 -1
  55. package/bin/wwwroot/assets/alert-BF0mCqUl.js +0 -15
  56. package/bin/wwwroot/assets/confirm-morph-BPDPizy8.js +0 -1
  57. package/bin/wwwroot/assets/minus-CFFJg-m8.js +0 -1
  58. package/bin/wwwroot/assets/overlays-OPtjc9Yr.js +0 -41
  59. package/bin/wwwroot/assets/radio-cards-DAFCv1Xc.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: 51344880 bytes
4
- sha256: 207fd8b1f1e381252261edc5fd1fe69585dce28a3dd229144c5e0b2fc6d424a7
3
+ size: 52074272 bytes
4
+ sha256: 861d3dea5dcee27caaa24ea1b836b7ffa91c30f452c98cb410bad6d3e54d3515
@@ -0,0 +1,9 @@
1
+ import{Ba as e,Dr as t,Et as n,Fr as r,G as i,Gt as a,H as o,Ht as s,Ir as c,Jt as l,K as u,Kt as d,Mr as f,Qn as p,Ra as m,Ua as h,Ut as g,Vr as ee,Vt as _,Xt as v,Y as y,Yt as b,_ as x,ai as S,ar as C,bn as te,bt as w,c as T,ct as E,d as ne,dt as D,gn as re,gt as ie,lr as ae,m as O,mn as oe,n as k,ot as A,r as j,s as se,t as M,u as N,v as P,vr as ce,xt as F,y as I,za as L}from"./alert-Clz2DftU.js";import{a as R,gt as z,ht as le,i as ue,o as B,r as V}from"./overlays-UV1fYmtB.js";import{n as H}from"./ProvidersPage-BiX8gU3n.js";import{t as de}from"./download-1kPyvAIz.js";import{t as fe}from"./external-link-CP_HY9s9.js";import{t as pe}from"./folder-open-gI3OxPvC.js";import{a as me,c as U,d as W,f as he,i as G,l as K,n as ge,o as _e,p as q,r as ve,s as ye,t as be,u as xe}from"./sortable.esm-DLqkwcx8.js";import{t as Se}from"./rotate-ccw-ClcBYxmg.js";import{$ as Ce,B as we,H as Te,P as Ee,R as J,S as Y,U as De,V as Oe,Z as ke,b as Ae,et as je,h as Me,v as Ne,x as Pe,z as Fe}from"./index-LdSd2gU7.js";var Ie={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`}]]};Ie.node;var Le=F(Ie),Re={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`]};Re.node;var ze=F(Re),Be={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`}]]};Be.node;var Ve=F(Be),X=h(e(),1),Z=L(),He=`astra claude`;function Ue(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 We=e=>e.status===`active`&&e.enabled;function Ge(e,t){let n=[e.name||e.id,e.email?`· ${e.email}`:null,e.plan?`· ${e.plan}`:null].filter(Boolean).join(` `);return We(e)?n:`${n} · ${t}`}function Ke({enabled:e,gatewayEnabled:t}){let{t:n}=E(),{toast:r}=B(),i=Ce(),o=a(e),s=f(),[c,l]=(0,X.useState)(null),u=o.data?.mode??`gateway`,p=o.data?.accounts??[],m=o.data?.accountId??null??p.find(We)?.id??null,h=p.find(e=>e.id===m),g=u===`direct`,ee=t&&(g||o.data!=null),_=g&&h?.telemetryEnabled===!0,v=d(_?h?.id:null,_),y=s.isPending,b=e=>s.mutate(e,{onError:e=>r(R(e),`error`)});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(N,{title:n(`clients.claudeDirect.modeTitle`),footer:n(`clients.claudeDirect.modeFooter`),children:[(0,Z.jsx)(O,{label:n(`clients.claudeDirect.mode`),detail:n(g?`clients.claudeDirect.directDetail`:`clients.claudeDirect.gatewayDetail`),children:(0,Z.jsx)(x,{ariaLabel:n(`clients.claudeDirect.mode`),value:u,onChange:e=>{if(e===u||y||!o.data)return;let t=m??p.find(We)?.id??null;if(e===`direct`&&!t){r(n(`clients.claudeDirect.needAccountToast`),`error`);return}b({mode:e,accountId:t})},items:[{value:`gateway`,label:n(`clients.claudeDirect.gateway`)},{value:`direct`,label:n(`clients.claudeDirect.direct`)}]})}),(0,Z.jsx)(`p`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:n(`clients.claudeDirect.modeNote`)})]}),o.isLoading&&(0,Z.jsx)(P,{lines:3}),o.isError&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(M,{tone:`danger`,title:n(`clients.claudeDirect.loadFailed`),children:R(o.error)})}),ee&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(M,{tone:`warning`,title:n(`clients.claudeDirect.gatewayOnTitle`),children:n(`clients.claudeDirect.gatewayOnDetail`)})}),o.data&&(0,Z.jsx)(N,{title:n(`clients.claudeDirect.accountsTitle`),footer:n(`clients.claudeDirect.accountsFooter`),children:p.length===0?(0,Z.jsx)(T,{title:n(`clients.claudeDirect.noAccount`),detail:n(`clients.claudeDirect.noAccountDetail`),action:(0,Z.jsx)(j,{variant:`primary`,onClick:()=>i(`/providers`),children:n(`clients.claudeDirect.goProviders`)})}):(0,Z.jsx)(O,{label:n(`clients.claudeDirect.account`),children:(0,Z.jsx)(V,{className:`max-w-[300px]`,ariaLabel:n(`clients.claudeDirect.account`),value:m,onChange:e=>{y||e===m||b({mode:u,accountId:e})},options:p.map(e=>({value:e.id,label:Ge(e,n(`clients.claudeDirect.accountDisabledSuffix`,{status:n(`providers.subscription.status.${e.status}`)})),disabled:!We(e)}))})})}),o.data&&g&&h&&(0,Z.jsx)(N,{title:n(`clients.claudeDirect.launchTitle`),footer:n(`clients.claudeDirect.launchNote`),children:(0,Z.jsx)(qe,{command:He,copied:c,onCopy:async e=>{await z.copy(e)&&(l(e),r(n(`common.copied`)))}})}),o.data&&g&&h&&(0,Z.jsxs)(N,{title:n(`clients.claudeDirect.statsTitle`),footer:n(`clients.claudeDirect.statsFooter`),children:[(0,Z.jsx)(O,{label:n(`clients.claudeDirect.statsConsent`),detail:n(`clients.claudeDirect.statsConsentDetail`),children:(0,Z.jsx)(I,{label:n(`clients.claudeDirect.statsConsent`),checked:h.telemetryEnabled,disabled:y,onChange:e=>{h&&!y&&b({mode:u,accountId:h.id,telemetryEnabled:e})}})}),_&&(0,Z.jsx)(Je,{requests:v})]})]})}function qe({command:e,copied:t,onCopy:n}){let{t:r}=E();return(0,Z.jsx)(O,{label:(0,Z.jsx)(`span`,{className:`font-mono text-[12px] break-all selectable`,children:e}),children:(0,Z.jsx)(j,{size:`sm`,icon:(0,Z.jsx)(ie,{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 Je({requests:e}){let{t,locale:n}=E(),r=e.data??[],a=Ue(r);return e.isLoading?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(P,{lines:3})}):e.isError?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(M,{tone:`danger`,title:t(`clients.claudeDirect.statsFailed`),children:R(e.error)})}):r.length===0?(0,Z.jsx)(T,{icon:(0,Z.jsx)(Te,{className:`size-6`}),title:t(`clients.claudeDirect.statsEmpty`),detail:t(`clients.claudeDirect.statsEmptyDetail`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(O,{label:t(`clients.claudeDirect.statsTotals`,{count:y(a.requests)}),detail:t(`clients.claudeDirect.statsInDetail`,{input:y(a.totalInputTokens),cache:y(r.reduce((e,t)=>e+t.cacheReadTokens,0)),output:y(a.outputTokens)})}),(0,Z.jsx)(O,{label:t(`clients.claudeDirect.statsCost`),detail:t(`clients.claudeDirect.statsCostDetail`),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:u(r.some(e=>e.estimatedCostNanoUsd!=null)?a.estimatedCostNanoUsd:null)})}),a.failed>0&&(0,Z.jsx)(O,{label:t(`clients.claudeDirect.statsFailedCount`,{count:y(a.failed)}),children:(0,Z.jsx)(k,{tone:`red`,children:t(`clients.claudeDirect.statusError`)})}),r.map(e=>(0,Z.jsx)(O,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.model}),e.status===`error`?(0,Z.jsx)(k,{tone:`red`,children:t(`clients.claudeDirect.statusError`)}):(0,Z.jsx)(k,{tone:`green`,children:t(`status.success`)})]}),detail:(0,Z.jsx)(`span`,{className:`num`,children:[o(e.occurredAtUtc,n),t(`clients.claudeDirect.tokensDetail`,{input:y(e.inputTokens),output:y(e.outputTokens)}),e.durationMs==null?null:i(e.durationMs),e.accountUuid??null].filter(Boolean).join(` · `)}),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:u(e.estimatedCostNanoUsd)})},e.id))]})}function Ye({descriptors:e,values:t,onChange:n,enabled:r}){let{t:i}=E(),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,Z.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,Z.jsxs)(O,{label:n,detail:r,children:[e.type===`bool`&&(0,Z.jsx)(I,{label:n,checked:o===!0,onChange:t=>a(e.key,t)}),e.type===`int`&&(0,Z.jsx)(ne,{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,Z.jsx)(V,{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 Xe=[`openai-chat`,`openai-responses`,`anthropic`,`gemini`],Ze=e=>typeof e==`string`&&Xe.includes(e);function Qe(e){let t=e?.protocolOverrides,n={};if(!t||typeof t!=`object`)return n;for(let[e,r]of Object.entries(t))Ze(r)&&(n[e]=r);return n}function $e(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(Ze):[]})}return n}function et(e,t){let n=e.native.find(e=>t.includes(e));return n?{protocol:n,translated:!1}:{protocol:t[0],translated:!0}}var tt=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
2
+ `),nt=`auto`,rt=e=>H.find(t=>t.value===e)?.label??e;function it({models:e,supported:t,values:n,onChange:r,enabled:i}){let{t:a}=E(),o=(e,t)=>{let i={...n};t===nt?delete i[e]:i[e]=t,r(i)};return(0,Z.jsx)(N,{title:a(`clients.protocols.title`),footer:a(i?`clients.protocols.footerEnabled`:`clients.protocols.footer`),children:e.map(e=>{let r=et(e,t),i=e.native.filter(e=>t.includes(e));return(0,Z.jsx)(O,{label:e.name,detail:i.length>0?a(`clients.protocols.native`,{protocols:i.map(rt).join(` · `)}):a(`clients.protocols.noNative`),children:(0,Z.jsx)(V,{ariaLabel:e.name,className:`w-60`,value:n[e.id]&&t.includes(n[e.id])?n[e.id]:nt,onChange:t=>o(e.id,t),options:[{value:nt,label:a(r.translated?`clients.protocols.autoTranslated`:`clients.protocols.auto`,{protocol:rt(r.protocol)})},...t.map(e=>({value:e,label:rt(e)}))]})},e.id)})})}function at(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 ot=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
3
+ `),st=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`];function ct(e){let t=e?.models,n={};if(!t||typeof t!=`object`)return n;for(let e of st){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var lt=e=>st.map(t=>e[t]??``).join(`
4
+ `),Q=[`sonnet`,`opus`,`haiku`];function ut(e){let t=e?.roleMap,n={};if(!t||typeof t!=`object`)return n;for(let e of Q){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var $=e=>Q.map(t=>e[t]??``).join(`
5
+ `),dt=/(^|[-_.:/\s])(haiku|flash|mini|lite|nano|small|fast|air)($|[-_.:/\s])/i;function ft(e){if(e.length===0)return{};let t=t=>e.find(e=>e.toLowerCase().includes(t)),n=e.find(e=>!dt.test(e))??e[0],r=e.find(e=>dt.test(e))??n;return{sonnet:t(`sonnet`)??n,opus:t(`opus`)??t(`sonnet`)??n,haiku:t(`haiku`)??r}}function pt(){let{t:e}=E(),t=Ce(),{toast:n}=B(),r=je(),i=v(),a=g(),o=(0,X.useMemo)(()=>new Map((i.data??[]).map(e=>[e.kind,e])),[i.data]),s=ht(i.data).includes(r.kind)?r.kind:`codex`,c=o.get(s);return(0,X.useEffect)(()=>a.mutate(!1),[]),(0,Z.jsx)(Me,{title:e(`nav.clients`),subtitle:e(`clients.subtitle`),actions:(0,Z.jsx)(j,{icon:(0,Z.jsx)(Fe,{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(R(e),`error`)}),children:e(`clients.checkUpdates`)}),children:(0,Z.jsx)(`div`,{className:`@container mx-auto max-w-[1200px]`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-start @3xl:gap-5`,children:[(0,Z.jsx)(bt,{clients:i.data,loading:i.isLoading,selected:s,onSelect:e=>t(`/clients/${e}`,{replace:!0})}),(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-[760px] min-w-0 flex-1`,children:[i.isLoading&&(0,Z.jsx)(P,{lines:4}),i.isError&&(0,Z.jsx)(M,{tone:`danger`,title:e(`common.error`),children:R(i.error)}),c&&(0,Z.jsx)(wt,{client:c})]})]})})})}var mt=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 ht(e){let t=(e??[]).filter(e=>!Ne.includes(e.kind)).sort((e,t)=>e.name.localeCompare(t.name));return[...Ne,...t.map(e=>e.kind)]}var gt=[`installed`,`notInstalled`,`comingSoon`],_t=new Set([`notInstalled`]);function vt(e){return e.availability===`coming_soon`?`comingSoon`:e.detection.installed||e.enabled||e.install?.installed?`installed`:`notInstalled`}function yt(e){return e.install?.version??e.detection.version??null}function bt({clients:e,loading:t,selected:n,onSelect:r}){let{t:i}=E(),[a,o]=(0,X.useState)(new Set),s=new Map((e??[]).map(e=>[e.kind,e])),c=gt.map(t=>({group:t,items:ht(e).flatMap(e=>{let n=s.get(e);return n&&vt(n)===t?[n]:[]})})).filter(e=>e.items.length>0);return(0,Z.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,Z.jsx)(P,{lines:6,className:`p-2`}),(0,Z.jsx)(`div`,{className:`flex gap-1 overflow-x-auto @3xl:flex-col @3xl:gap-0 @3xl:overflow-visible`,children:c.map(({group:e,items:t})=>{let s=_t.has(e),c=!s||a.has(e)||t.some(e=>e.kind===n),l=`${i(`clients.group.${e}`)} · ${t.length}`;return(0,Z.jsxs)(`div`,{className:`contents @3xl:block`,children:[s?(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":c,"aria-label":i(c?`clients.group.collapse`:`clients.group.expand`,{group:l}),onClick:()=>o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),className:`flex shrink-0 items-center gap-1 rounded-[var(--radius-control)] px-2.5 py-1.5 text-[11px] font-medium whitespace-nowrap text-[var(--text-muted)] hover:bg-[var(--surface-muted)] @3xl:w-full @3xl:pt-2 @3xl:pb-1`,children:[(0,Z.jsx)(De,{size:12,className:A(`transition-transform`,c&&`rotate-90`)}),l]}):(0,Z.jsx)(`h3`,{className:`hidden px-2.5 pt-2 pb-1 text-[11px] font-medium text-[var(--text-muted)] @3xl:block`,children:l}),c&&t.map(e=>(0,Z.jsx)(xt,{client:e,active:e.kind===n,onSelect:()=>r(e.kind)},e.kind))]},e)})})]})}function xt({client:e,active:t,onSelect:n}){let{t:r}=E(),i=vt(e)!==`installed`,a=yt(e),o=e.install?.blocker===`shadowed`,s=e.install?.updateAvailable&&!o?e.install.latestVersion:null;return(0,Z.jsxs)(`button`,{type:`button`,"aria-label":Y(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,Z.jsx)(`span`,{className:A(`inline-flex`,i&&!t&&`opacity-60`),children:(0,Z.jsx)(Ae,{kind:e.kind,size:24})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:A(`block truncate text-[13px] whitespace-nowrap`,t&&`font-medium`),children:Y(e.kind,e.name)}),a&&(0,Z.jsxs)(`span`,{className:`hidden truncate text-[11px] text-[var(--text-secondary)] @3xl:block`,children:[a,s&&(0,Z.jsxs)(`span`,{className:`text-[var(--warning)]`,children:[` → `,s]})]})]}),e.install?.busy&&(0,Z.jsx)(St,{}),s&&!e.install?.busy&&(0,Z.jsx)(k,{tone:`orange`,title:r(`clients.updateTo`,{version:s}),children:r(`clients.updateBadge`)}),o&&!e.install?.busy&&(0,Z.jsx)(k,{tone:`orange`,title:r(`clients.shadowed.title`,{version:e.install?.latestVersion??``}),children:r(`clients.shadowedBadge`)}),e.status===`drifted`?(0,Z.jsx)(`span`,{title:r(`clients.drifted`),"aria-label":r(`clients.drifted`),className:`inline-flex`,children:(0,Z.jsx)(se,{tone:`orange`})}):e.enabled?(0,Z.jsx)(w,{className:`size-3.5 shrink-0 text-[var(--success)]`,strokeWidth:2.5,"aria-label":r(`clients.enabled`)}):null]})}function St(){return(0,Z.jsx)(Oe,{className:`size-3.5 shrink-0 animate-spin text-[var(--text-secondary)] motion-reduce:animate-none`,"aria-hidden":!0})}function Ct(e,t){return e.availability===`coming_soon`?(0,Z.jsx)(k,{children:t(`clients.comingSoon`)}):e.status===`drifted`?(0,Z.jsx)(k,{tone:`orange`,children:t(`clients.drifted`)}):e.enabled?(0,Z.jsx)(k,{tone:`green`,children:t(`clients.enabled`)}):(0,Z.jsx)(k,{children:t(`clients.disabled`)})}function wt({client:e}){let{t,locale:n}=E(),i=Ce(),{toast:s,confirm:c}=B(),l=ae(),u=r(),d=oe(),f=te(),p=ce(),m=S(),h=b(e.kind,!!e.providerId),[g,ee]=(0,X.useState)(e.selectedModel??null),[_,v]=(0,X.useState)(e.accountId??``),y=e.tokenId??`default`,[x,w]=(0,X.useState)(y),T=(m.data??[]).filter(e=>e.enabled||e.id===y).map(e=>({value:e.id,label:e.enabled?e.name:t(`clients.tokenDisabled`,{name:e.name}),disabled:!e.enabled})),[ne,D]=(0,X.useState)(!1),[re,A]=(0,X.useState)(!1),[se,F]=(0,X.useState)(null),I=e.availability===`coming_soon`,L=Y(e.kind,e.name),ue=(l.data??[]).filter(e=>e.enabled),H=e.detection.configPaths[0],de=ue.find(t=>t.id===e.providerId),fe=de?.authScheme===`oauth-subscription`||de?.authScheme===`plugin`,me=C(de?.id,fe),U=e.kind===`claude-desktop`,W=e.kind===`claude-code`,he=a(W),G=W&&he.data?.mode===`direct`,K=ut(e.extras),[ge,_e]=(0,X.useState)(K),q=Q.some(e=>ge[e]),ve=$(ge)!==$(K),ye=ct(e.extras),[be,xe]=(0,X.useState)(ye),Se=(g??null)!==(e.selectedModel??null)||lt(be)!==lt(ye),we=W?st.filter(e=>e!==`ANTHROPIC_MODEL`):[],Ee=W?e.enabled?t(`clients.modelSlotsFooterEnabled`):t(`clients.modelSlotsFooter`):e.enabled?t(`clients.modelFooterEnabled`):t(`clients.modelFooter`),J=e.options??[],De=at(e.extras,J),[Oe,ke]=(0,X.useState)(De),je=ot(Oe)!==ot(De),Me=e.protocols??[],Ne=Me.length>1?$e(e.extras):[],Pe=Qe(e.extras),[Fe,Ie]=(0,X.useState)(Pe),Re=tt(Fe)!==tt(Pe),ze=U?{...e.extras,roleMap:ge}:W?{...e.extras,models:be,options:Oe}:J.length>0||Me.length>1?{...e.extras,...J.length>0?{options:Oe}:{},...Me.length>1?{protocolOverrides:Fe}:{}}:void 0;(0,X.useEffect)(()=>ee(e.selectedModel??null),[e.kind,e.selectedModel]),(0,X.useEffect)(()=>v(e.accountId??``),[e.kind,e.providerId,e.accountId]),(0,X.useEffect)(()=>w(y),[e.kind,y]),(0,X.useEffect)(()=>_e(ut(e.extras)),[e.kind,$(K)]);let Be=(0,X.useRef)({});(0,X.useEffect)(()=>{if(!U||e.enabled||Q.some(e=>K[e]))return;let t=Be.current,n=ft(h.data??[]);Be.current=n,_e(e=>(!Q.some(t=>e[t])||$(e)===$(t))&&$(e)!==$(n)?n:e)},[e.kind,e.enabled,$(K),(h.data??[]).join(`
6
+ `)]),(0,X.useEffect)(()=>xe(ct(e.extras)),[e.kind,lt(ye)]),(0,X.useEffect)(()=>ke(at(e.extras,e.options)),[e.kind,ot(De)]),(0,X.useEffect)(()=>Ie(Qe(e.extras)),[e.kind,tt(Pe)]);let Ve=()=>{e.providerId&&u.mutate({kind:e.kind,providerId:e.providerId,accountId:_},{onSuccess:()=>s(t(`common.saved`),`success`),onError:e=>s(R(e),`error`)})},He=async()=>{await c({title:t(`clients.disableConfirm`,{name:L}),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:L}),`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:L}),`success`),onError:e=>s(R(e),`error`)})},onError:e=>s(R(e),`error`)})},Ue=async()=>{H&&(z.canOpenPaths?await z.openPath(le(H)):await z.copy(H)&&s(t(`common.copied`)))};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(N,{children:[(0,Z.jsxs)(O,{icon:(0,Z.jsx)(Ae,{kind:e.kind,size:36}),label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[15px] font-medium`,children:L}),G?(0,Z.jsx)(k,{children:t(`clients.claudeDirect.direct`)}):Ct(e,t)]}),detail:I?e.availabilityReason??t(`clients.comingSoonDetail`):[vt(e)===`installed`?t(`clients.detected`,{version:yt(e)??``}):t(`clients.notDetected`),G?null:H].filter(Boolean).join(` · `),className:`py-3`,children:[!I&&(0,Z.jsx)(At,{client:e,onOpen:F}),G?(0,Z.jsx)(j,{variant:`primary`,onClick:()=>document.getElementById(Mt)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:t(`clients.claudeDirect.configure`)}):e.enabled?(0,Z.jsx)(j,{onClick:()=>void He(),loading:d.isPending,children:t(`clients.disableRestore`)}):(0,Z.jsx)(j,{variant:`primary`,disabled:I||!e.providerId||U&&!q,onClick:()=>D(!0),title:e.providerId?U&&!q?t(`clients.roleMapRequired`):void 0:t(`clients.pickProviderFirst`),children:t(`clients.enable`)})]}),!G&&e.appliedAt&&(0,Z.jsx)(O,{label:(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`clients.appliedAt`,{time:o(e.appliedAt,n)})})})]}),!I&&!e.enabled&&U&&e.providerId&&!q&&(0,Z.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Z.jsx)(M,{tone:`info`,className:`self-stretch`,title:t(`clients.roleMapHint`)}),(0,Z.jsx)(j,{onClick:()=>document.getElementById(Nt)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:t(`clients.roleMapGoto`)})]}),(e.repairs?.length??0)>0&&(0,Z.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Z.jsxs)(M,{tone:`danger`,className:`self-stretch`,title:t(`clients.repair.title`,{name:L}),children:[e.repairs?.map(e=>(0,Z.jsxs)(`span`,{className:`block break-all`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.file}),` — `,t(`clients.repair.problem.${e.problem}`,{line:e.line})]},e.file)),(0,Z.jsx)(`span`,{className:`block`,children:t(`clients.repair.hint`)})]}),(0,Z.jsx)(j,{variant:`primary`,loading:p.isPending,onClick:()=>p.mutate(e.kind,{onSuccess:()=>s(t(`clients.repair.done`,{name:L}),`success`),onError:e=>s(R(e),`error`)}),children:t(`clients.repair.action`)})]}),!G&&e.warnings.length>0&&(0,Z.jsx)(`div`,{className:`mb-5 flex flex-col gap-2`,children:e.warnings.map((e,t)=>(0,Z.jsx)(M,{tone:`warning`,title:e},t))}),!G&&(0,Z.jsx)(Ot,{client:e,providers:l.data??[],loading:l.isLoading,soon:I}),!G&&fe&&(0,Z.jsx)(N,{title:t(`clients.accountTitle`),footer:t(`clients.accountFooter`),children:me.isLoading?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(P,{lines:2})}):(0,Z.jsxs)(O,{label:t(`clients.account`),children:[(0,Z.jsx)(V,{className:`max-w-[300px]`,ariaLabel:t(`clients.account`),value:_,onChange:v,options:[{value:``,label:t(`clients.accountDefault`)},...(me.data??[]).map(e=>({value:e.id,label:(e.displayName||e.id)+(e.status===`active`?``:` · ${t(`providers.subscription.status.${e.status}`)}`)}))]}),_!==(e.accountId??``)&&(0,Z.jsx)(j,{size:`sm`,variant:`primary`,loading:u.isPending,onClick:Ve,children:t(`common.apply`)})]})}),!I&&!G&&(0,Z.jsxs)(N,{title:t(`clients.tokenTitle`),footer:e.enabled?t(`clients.tokenFooterEnabled`):t(`clients.tokenFooter`),children:[(0,Z.jsxs)(O,{label:t(`clients.token`),children:[(0,Z.jsx)(V,{className:`max-w-[300px]`,ariaLabel:t(`clients.token`),value:x,onChange:w,options:T}),e.enabled&&x!==y&&(0,Z.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>D(!0),children:t(`common.apply`)})]}),(0,Z.jsx)(O,{icon:(0,Z.jsx)(Te,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.manageTokens`),onClick:()=>i(`/tokens`)})]}),!I&&!G&&e.providerId&&U&&(0,Z.jsx)(`div`,{id:Nt,children:(0,Z.jsxs)(N,{title:t(`clients.roleMapTitle`),footer:e.enabled?t(`clients.roleMapFooterEnabled`):t(`clients.roleMapFooter`),children:[Q.map(e=>(0,Z.jsx)(O,{label:t(`clients.role.${e}`),children:(0,Z.jsx)(V,{ariaLabel:t(`clients.role.${e}`),value:ge[e]??``,onChange:t=>_e(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&&ve&&(0,Z.jsx)(O,{label:q?``:(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--warning)]`,children:t(`clients.roleMapRequired`)}),children:(0,Z.jsx)(j,{size:`sm`,variant:`primary`,disabled:!q,onClick:()=>D(!0),children:t(`common.apply`)})})]})}),!I&&!G&&e.providerId&&!U&&(0,Z.jsxs)(N,{title:t(`clients.modelTitle`),footer:Ee,children:[(0,Z.jsx)(O,{label:t(`clients.defaultModel`),children:(0,Z.jsx)(V,{value:g??``,onChange:e=>ee(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,Z.jsx)(O,{label:t(`clients.modelSlot.${e}`),children:(0,Z.jsx)(V,{ariaLabel:t(`clients.modelSlot.${e}`),value:be[e]??``,onChange:t=>xe(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&&(W?Se:(g??null)!==(e.selectedModel??null))&&(0,Z.jsx)(O,{label:``,children:(0,Z.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>D(!0),children:t(`common.apply`)})})]}),!I&&!G&&J.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ye,{descriptors:J,values:Oe,onChange:ke,enabled:e.enabled}),e.enabled&&je&&(0,Z.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Z.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>D(!0),children:t(`common.apply`)})})]}),!I&&Ne.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(it,{models:Ne,supported:Me,values:Fe,onChange:Ie,enabled:e.enabled}),e.enabled&&Re&&(0,Z.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Z.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>D(!0),children:t(`common.apply`)})})]}),!I&&e.install&&(0,Z.jsx)(Ft,{client:e,onShowLog:()=>F(`log`),onUninstall:()=>F(`uninstall`)}),W&&(0,Z.jsx)(`div`,{id:Mt,children:(0,Z.jsx)(Ke,{enabled:W,gatewayEnabled:e.enabled})}),!I&&!G&&(0,Z.jsxs)(N,{title:t(`clients.maintenance`),children:[H&&(0,Z.jsx)(O,{icon:z.canOpenPaths?(0,Z.jsx)(pe,{className:`size-4 text-[var(--text-secondary)]`}):(0,Z.jsx)(ie,{className:`size-4 text-[var(--text-secondary)]`}),label:z.canOpenPaths?t(`clients.openConfigDir`):t(`clients.copyConfigPath`),detail:H,onClick:()=>void Ue()}),(0,Z.jsx)(O,{icon:(0,Z.jsx)(Le,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.backups`),detail:t(`clients.backupsDetail`),onClick:()=>A(!0)})]}),(0,Z.jsx)(Lt,{open:ne,onOpenChange:D,client:e,model:g,extras:ze,tokenId:x}),(0,Z.jsx)(Bt,{open:re,onOpenChange:A,client:e}),(0,Z.jsx)(It,{mode:se,onClose:()=>F(null),client:e})]})}var Tt={install:`clients.installTitle`,update:`clients.updateTitle`,uninstall:`clients.uninstallTitle`},Et={install:`clients.installedToast`,update:`clients.updatedToast`,uninstall:`clients.uninstalledToast`};function Dt(e,t){return[e.priceKey??e.templateId,t(`providers.modelCount`,{count:e.modelCount}),e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `)}function Ot({client:e,providers:t,loading:n,soon:r}){let{t:i}=E(),{toast:a}=B(),o=c(),s=(0,X.useMemo)(()=>e.bindings??(e.providerId?[{providerId:e.providerId,accountId:e.accountId}]:[]),[e.bindings,e.providerId,e.accountId]),[l,u]=(0,X.useState)(s);(0,X.useEffect)(()=>u(s),[s]);let d=(0,X.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]),f=l.flatMap(e=>{let t=d.get(e.providerId);return t?[{binding:e,provider:t}]:[]}),p=t.filter(e=>e.enabled&&!l.some(t=>t.providerId===e.id)),m=W(xe(U,{activationConstraint:{distance:4}}),xe(ye,{coordinateGetter:ve})),h=r||o.isPending,g=(t,n)=>{let r=l;u(t),o.mutate({kind:e.kind,bindings:t},{onSuccess:()=>a(mt.has(e.kind)&&e.enabled?i(`clients.providersModelsSynced`,{client:Y(e.kind,e.name)}):n),onError:e=>{u(r),a(R(e),`error`)}})},ee=({active:e,over:t})=>{if(!t||e.id===t.id)return;let n=l.findIndex(t=>t.providerId===e.id),r=l.findIndex(e=>e.providerId===t.id);n<0||r<0||g(ge(l,n,r),i(`clients.providerOrderSaved`))},_=e=>g([...l,{providerId:e.id}],i(`clients.providerAdded`,{provider:e.name})),v=e=>g(l.filter(t=>t.providerId!==e.id),i(`clients.providerRemoved`,{provider:e.name})),y=p.map(e=>(0,Z.jsx)(O,{icon:(0,Z.jsx)(Pe,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24}),label:e.name,detail:Dt(e,i),onClick:h?void 0:()=>_(e),children:!r&&(0,Z.jsx)(we,{className:`size-4 text-[var(--text-secondary)]`,"aria-label":i(`common.add`)})},e.id));return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(N,{title:i(`clients.providerTitle`),footer:i(`clients.providerFooter`),children:[n&&(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(P,{lines:2})}),!n&&f.length===0&&p.length===0&&(0,Z.jsx)(T,{title:i(`clients.noProviders`),detail:i(`clients.noProvidersDetail`),action:(0,Z.jsx)(ke,{to:`/providers?new=1`,children:(0,Z.jsx)(j,{variant:`primary`,icon:(0,Z.jsx)(we,{className:`size-3.5`}),children:i(`providers.add`)})})}),f.length>0&&(0,Z.jsx)(_e,{sensors:m,collisionDetection:K,onDragEnd:ee,children:(0,Z.jsx)(be,{items:f.map(e=>e.provider.id),strategy:me,children:f.map(({provider:e},t)=>(0,Z.jsx)(kt,{provider:e,primary:t===0,disabled:h,onRemove:f.length>1?()=>v(e):void 0},e.id))})}),!n&&f.length===0&&y]}),f.length>0&&p.length>0&&(0,Z.jsx)(N,{title:i(`clients.moreProvidersTitle`),children:y})]})}function kt({provider:e,primary:t,disabled:n,onRemove:r}){let{t:i}=E(),{attributes:a,listeners:o,setNodeRef:s,setActivatorNodeRef:c,transform:l,transition:u,isDragging:d}=G({id:e.id,disabled:n});return(0,Z.jsx)(`div`,{ref:s,style:{transform:he.Transform.toString(l),transition:u},className:A(d&&`relative z-10 bg-[var(--surface)] shadow-lg`),children:(0,Z.jsx)(O,{icon:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.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,Z.jsx)(q,{className:`size-4`})}),(0,Z.jsx)(Pe,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24})]}),label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.name}),t&&(0,Z.jsx)(k,{tone:`accent`,children:i(`clients.primaryProvider`)}),!e.enabled&&(0,Z.jsx)(k,{tone:`orange`,children:i(`clients.providerDisabledBadge`)})]}),detail:Dt(e,i),children:r&&(0,Z.jsx)(j,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(D,{className:`size-3.5`}),"aria-label":i(`clients.removeProvider`,{provider:e.name}),title:i(`clients.removeProvider`,{provider:e.name}),disabled:n,onClick:r})})})}function At({client:e,onOpen:t}){let{t:n}=E(),r=e.install;if(!r)return null;let i=r.needsAdmin?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-[var(--warning)]`,children:[(0,Z.jsx)(Ve,{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,Z.jsx)(j,{icon:(0,Z.jsx)(St,{}),onClick:()=>t(`log`),children:n(`clients.installRunning`)}):r.updateAvailable&&r.updateCommand&&r.latestVersion?(0,Z.jsxs)(j,{icon:(0,Z.jsx)(ze,{className:`size-3.5`}),title:a,onClick:()=>t(`update`),children:[n(`clients.updateTo`,{version:r.latestVersion}),i]}):r.updateAvailable&&r.blocker===`shadowed`?(0,Z.jsx)(j,{icon:(0,Z.jsx)(Ve,{className:`size-3.5`}),onClick:()=>document.getElementById(jt)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:n(`clients.shadowedBadge`)}):!r.installed&&r.installCommand?(0,Z.jsxs)(j,{icon:(0,Z.jsx)(de,{className:`size-3.5`}),title:a,onClick:()=>t(`install`),children:[n(`clients.install`),i]}):!r.installed&&r.method===`manual`?(0,Z.jsx)(j,{icon:(0,Z.jsx)(fe,{className:`size-3.5`}),onClick:()=>window.open(r.homepageUrl,`_blank`,`noreferrer`),children:n(`clients.download`)}):null}var jt=`client-shadowed-alert`,Mt=`claude-direct-panel`,Nt=`client-role-map`;function Pt(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 Ft({client:e,onShowLog:t,onUninstall:n}){let{t:r,locale:i}=E(),a=e.install,s=l(e.kind),c=(e,t=!1)=>(0,Z.jsx)(`span`,{className:A(`text-[13px] tabular-nums selectable`,t&&`text-[var(--text-secondary)]`),children:e}),u=a.blocker===`external-install`?r(`clients.blocker.external-install`,{path:a.executable??``}):a.blocker?r(`clients.blocker.${a.blocker}`):void 0,d=a.otherCopies??[],f=d.find(e=>e.newer);return(0,Z.jsxs)(Z.Fragment,{children:[f&&(0,Z.jsx)(`div`,{id:jt,className:`mb-3`,children:(0,Z.jsx)(M,{tone:`warning`,title:r(`clients.shadowed.title`,{version:f.version}),children:r(`clients.shadowed.detail`,{path:a.executable??``,version:a.version??``,other:f.path,dir:le(f.path)})})}),!f&&a.notOnPath&&a.executable&&(0,Z.jsx)(`div`,{className:`mb-3`,children:(0,Z.jsx)(M,{tone:`warning`,title:r(`clients.notOnPath.title`),children:r(`clients.notOnPath.detail`,{dir:le(a.executable)})})}),(0,Z.jsxs)(N,{title:r(`clients.versionTitle`),footer:u,children:[(0,Z.jsx)(O,{label:r(`clients.currentVersion`),detail:a.installed?a.executable:void 0,children:a.installed?c(a.version??r(`clients.versionUnknown`),!a.version):c(r(`clients.notInstalled`),!0)}),d.map(e=>(0,Z.jsxs)(O,{label:r(`clients.otherCopy`),detail:e.path,children:[e.newer&&(0,Z.jsx)(k,{tone:`orange`,children:r(`clients.otherCopyNewer`)}),c(e.version,!e.newer)]},e.path)),(a.method===`npm`||a.method===`script`)&&(0,Z.jsxs)(O,{label:r(`clients.latestVersion`),detail:a.latestError??(a.latestCheckedAt?r(`clients.checkedAt`,{time:o(a.latestCheckedAt,i)}):void 0),children:[a.updateAvailable&&(0,Z.jsx)(k,{tone:`orange`,children:r(`clients.updateBadge`)}),c(a.latestVersion??r(`clients.latestUnknown`),!a.latestVersion)]}),(0,Z.jsx)(O,{label:r(`clients.installMethod`),detail:r(`clients.method.${a.method}`,{package:a.package??``}),children:(0,Z.jsx)(j,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(fe,{className:`size-3`}),onClick:()=>window.open(a.homepageUrl,`_blank`,`noreferrer`),children:r(`clients.homepage`)})}),a.installed&&(0,Z.jsx)(O,{label:r(`clients.uninstall`),detail:a.uninstallCommand??Pt(a,r),children:a.uninstallCommand&&(0,Z.jsx)(j,{size:`sm`,variant:`destructive`,icon:(0,Z.jsx)(Ee,{className:`size-3`}),disabled:a.busy,onClick:n,children:r(`clients.uninstall`)})}),s.data&&(0,Z.jsx)(O,{icon:(0,Z.jsx)(J,{className:`size-4 text-[var(--text-secondary)]`}),label:r(`clients.installLog`),detail:`${s.data.command} · ${r(`clients.job.${s.data.state}`)}`,onClick:t})]})]})}function It({mode:e,onClose:t,client:r}){let{t:i}=E(),{toast:a}=B(),o=m(),c=e!==null,u=l(r.kind,c||!!r.install?.busy),d=ee(),f=s(),[p,h]=(0,X.useState)(!1),g=(0,X.useRef)(null),_=(0,X.useRef)(void 0),v=Y(r.kind,r.name),y=r.install,b=e===`log`?null:e,x=b===`install`?y?.installCommand:b===`update`?y?.updateCommand:b===`uninstall`?y?.uninstallCommand:null,S=b===`uninstall`,C=u.data,te=b!==null&&!p&&C?.state!==`running`,w=!!y?.needsAdmin,ne=!!y?.adminAvailable,D=C?.state===`failed`&&C.hint===`permission-denied`&&!C.elevated&&ne;(0,X.useEffect)(()=>{c&&h(!1)},[c,e]),(0,X.useEffect)(()=>{let e=C?.state;_.current===`running`&&e&&e!==`running`&&(o.invalidateQueries({queryKey:n.clients}),e===`succeeded`&&C.hint?a(i(`clients.notEffectiveToast`,{name:v})):e===`succeeded`&&a(i(Et[C.action],{name:v}),`success`)),_.current=e},[C?.state,C?.action,C?.hint,v,o,i,a]),(0,X.useEffect)(()=>{let e=g.current;e&&(e.scrollTop=e.scrollHeight)},[C?.log.length]);let re=(e,t)=>d.mutate({kind:r.kind,action:e,elevated:t},{onSuccess:()=>h(!0),onError:e=>a(R(e),`error`)}),ae=async e=>{await z.copy(e)&&a(i(`common.copied`))},O=i(Tt[b??C?.action??`install`],{name:v}),oe={running:`info`,succeeded:`success`,failed:`danger`,cancelled:`warning`},k=`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`,se=y?.adminFixCommand?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-secondary)]`,children:i(`clients.admin.fixTip`)}),(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(`pre`,{className:A(k,`min-w-0 flex-1`),children:y.adminFixCommand}),(0,Z.jsx)(j,{size:`sm`,icon:(0,Z.jsx)(ie,{className:`size-3`}),"aria-label":i(`common.copy`),onClick:()=>void ae(y.adminFixCommand)})]})]}):null;return(0,Z.jsx)(ue,{open:c,onOpenChange:e=>!e&&t(),width:620,title:O,description:te?i(S?`clients.uninstallRunDetail`:`clients.installRunDetail`):void 0,footer:te?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(j,{onClick:t,children:i(`common.cancel`)}),w&&!ne?(0,Z.jsx)(j,{variant:`primary`,icon:(0,Z.jsx)(ie,{className:`size-3.5`}),disabled:!x,onClick:()=>void ae(`sudo ${x}`),children:i(`clients.admin.copyCommand`)}):(0,Z.jsx)(j,{variant:S?`destructive`:`primary`,icon:w?(0,Z.jsx)(Ve,{className:`size-3.5`}):void 0,disabled:!x,loading:d.isPending,onClick:()=>b&&re(b,w),children:i(w?`clients.admin.start`:S?`clients.uninstall`:`clients.installStart`)})]}):C?.state===`running`?(0,Z.jsxs)(Z.Fragment,{children:[!C.elevated&&(0,Z.jsx)(j,{variant:`destructive`,loading:f.isPending,onClick:()=>f.mutate(r.kind,{onError:e=>a(R(e),`error`)}),children:i(`clients.installStop`)}),(0,Z.jsx)(j,{onClick:t,children:i(`common.close`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(j,{onClick:t,children:i(`common.done`)}),D&&(0,Z.jsx)(j,{variant:`primary`,icon:(0,Z.jsx)(Ve,{className:`size-3.5`}),loading:d.isPending,onClick:()=>re(C.action,!0),children:i(`clients.admin.retry`)})]}),children:te?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[S&&r.enabled&&(0,Z.jsx)(M,{tone:`warning`,title:i(`clients.uninstallRestoreTitle`),children:i(`clients.uninstallRestoreDetail`,{name:v})}),w&&(0,Z.jsx)(M,{tone:`warning`,title:i(`clients.admin.title`),children:i(ne?`clients.admin.prompt`:`clients.admin.manual`)}),x?(0,Z.jsx)(`pre`,{className:k,children:w?`sudo ${x}`:x}):(0,Z.jsx)(M,{tone:`warning`,title:i(`clients.installUnavailable`)}),S?(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`clients.uninstallKeepsData`)}):y?.method===`npm`&&(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`clients.installNpmNote`)}),w&&se]}):C?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(M,{tone:C.state===`succeeded`&&C.hint?`warning`:oe[C.state],title:i(C.state===`succeeded`&&C.hint?`clients.job.notEffective`:`clients.job.${C.state}`),children:C.state===`running`&&C.elevated?i(`clients.admin.running`):C.hint?i(`clients.hint.${C.hint}`)+(D?i(`clients.admin.retryHint`):``):void 0}),(0,Z.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:C.log.join(`
7
+ `)}),C.hint===`permission-denied`&&se]}):u.isLoading?(0,Z.jsx)(P,{lines:4}):(0,Z.jsx)(T,{icon:(0,Z.jsx)(J,{className:`size-6`}),title:i(`clients.noInstallLog`)})})}function Lt({open:e,onOpenChange:t,client:n,model:r,extras:i,tokenId:a}){let{t:o}=E(),{toast:s}=B(),c=p(),l=re(),u=Y(n.kind,n.name),d=i?{providerId:n.providerId,model:r,extras:i,tokenId:a}:{providerId:n.providerId,model:r,tokenId:a};return(0,X.useEffect)(()=>{e&&c.mutate({kind:n.kind,req:d})},[e]),(0,Z.jsxs)(ue,{open:e,onOpenChange:t,width:620,title:o(`clients.enableTitle`,{name:u}),description:o(`clients.enableDetail`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(j,{onClick:()=>t(!1),children:o(`common.cancel`)}),(0,Z.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(R(e),`error`)}),children:n.enabled?o(`common.apply`):o(`clients.enable`)})]}),children:[c.isPending&&(0,Z.jsx)(P,{lines:4}),c.isError&&(0,Z.jsx)(M,{tone:`danger`,title:o(`common.error`),children:R(c.error)}),c.data&&(0,Z.jsx)(Rt,{preview:c.data})]})}function Rt({preview:e}){let{t}=E();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.warnings.map((e,t)=>(0,Z.jsx)(M,{tone:`warning`,title:e},t)),e.changes.length===0&&(0,Z.jsx)(M,{tone:`info`,title:t(`clients.noChanges`)}),e.diffs.map(e=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`mb-2 font-mono text-[11px] text-[var(--text-secondary)]`,children:e.file}),(0,Z.jsx)(zt,{diff:e.unifiedDiff})]},e.file))]})}function zt({diff:e}){return(0,Z.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,Z.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 Bt({open:e,onOpenChange:n,client:r}){let{t:i,locale:a}=E(),{toast:s,confirm:c}=B(),l=_(r.kind,e),u=t();return(0,Z.jsxs)(ue,{open:e,onOpenChange:n,width:520,title:i(`clients.backups`),description:i(`clients.backupsDetail`),footer:(0,Z.jsx)(j,{onClick:()=>n(!1),children:i(`common.done`)}),children:[l.isLoading&&(0,Z.jsx)(P,{lines:3}),l.isError&&(0,Z.jsx)(M,{tone:`danger`,title:i(`common.error`),children:R(l.error)}),l.data?.length===0&&(0,Z.jsx)(T,{icon:(0,Z.jsx)(Le,{className:`size-6`}),title:i(`clients.noBackups`)}),(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:l.data?.map(e=>(0,Z.jsx)(O,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[o(e.createdAt,a),e.firstWrite&&(0,Z.jsx)(k,{tone:`accent`,children:i(`clients.firstWrite`)})]}),detail:e.files.join(`, `),children:(0,Z.jsx)(j,{size:`sm`,icon:(0,Z.jsx)(Se,{className:`size-3`}),loading:u.isPending&&u.variables?.id===e.id,onClick:async()=>{await c({title:i(`clients.restoreConfirm`),detail:e.files.join(`
9
+ `),destructive:!0,confirmLabel:i(`clients.restore`)})&&u.mutate({kind:r.kind,id:e.id},{onSuccess:()=>s(i(`clients.restored`),`success`),onError:e=>s(R(e),`error`)})},children:i(`clients.restore`)})},e.id))})]})}export{pt as ClientsPage};
@@ -0,0 +1 @@
1
+ import{Ba as e,Ct as t,G as n,H as r,J as i,Q as a,St as o,Tt as s,Ua as c,Y as l,_ as u,ct as d,n as f,q as p,r as m,t as h,wt as g,za as _}from"./alert-Clz2DftU.js";import{_ as v,j as y,k as b}from"./index-LdSd2gU7.js";var x=c(e(),1),S=_(),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:e}=d(),[n,r]=(0,x.useState)(``),[i,a]=(0,x.useState)(null),[s,c]=(0,x.useState)(``),[l,u]=(0,x.useState)(null),[f,p]=(0,x.useState)(!1),g=(0,x.useCallback)(async n=>{let r=n.trim();if(r){p(!0),u(null);try{a(await t(r)),c(r),T(r)}catch(t){a(null),T(null),u(t instanceof o&&t.status===401?e(`key.invalid`):e(`key.error`,{error:t.message}))}finally{p(!1)}}},[e]);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),g(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)(y,{className:`size-10 rounded-[12px]`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-[17px] font-medium`,children:e(`key.title`)}),(0,S.jsx)(`p`,{className:`text-[13px] text-[var(--text-secondary)]`,children:e(`key.subtitle`)})]})]}),!i&&(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g(n)},className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(b,{label:e(`key.title`),placeholder:e(`key.placeholder`),autoFocus:!0,autoComplete:`off`,value:n,"aria-invalid":l?!0:void 0,onChange:e=>r(e.target.value)}),l&&(0,S.jsx)(h,{tone:`danger`,title:l}),(0,S.jsx)(m,{type:`submit`,variant:`primary`,loading:f,disabled:!n.trim(),children:e(`key.submit`)})]}),i&&(0,S.jsx)(D,{info:i,apiKey:s,onForget:()=>{T(null),a(null),r(``)}})]})})}function D({info:e,apiKey:t,onForget:n}){let{t:i,locale:o}=d(),[s,c]=(0,x.useState)(`overview`),p=e.allowedClients==null?i(`key.clientsAny`):e.allowedClients.length===0?i(`key.directOnly`):e.allowedClients.map(e=>v[e]?.name??e).join(`, `),h=[[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)(f,{tone:`orange`,children:i(`key.disabled`)}),(0,S.jsx)(m,{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`),`: `,p,` · `,i(`key.timeZone`,{zone:e.timeZone})]}),(0,S.jsx)(u,{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`?a(t):l(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,o)}):``]})]},`${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:h.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:a(t.costUsd)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:l(t.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:l(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} · ${a(e.costUsd)} · ${l(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}=d(),[r,i]=(0,x.useState)(`7d`),[o,c]=(0,x.useState)(null),[m,g]=(0,x.useState)(null);(0,x.useEffect)(()=>{let n=!0;return g(null),s(e,r).then(e=>n&&c(e),e=>n&&g(t(`key.error`,{error:e.message}))),()=>{n=!1}},[e,r,t]);let _=o?.summary,y=Math.max(...(o?.series??[]).map(e=>e.requests),0);return(0,S.jsxs)(`section`,{className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(u,{ariaLabel:t(`overview.range`),value:r,onChange:i,items:O.map(e=>({value:e,label:t(`range.${e}`)}))}),m&&(0,S.jsx)(h,{tone:`danger`,title:m}),!o||!_?!m&&(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:l(_.requests)}),(0,S.jsx)(A,{label:t(`key.stats.successRate`),value:_.requests?p(_.successRate):`—`}),(0,S.jsx)(A,{label:t(`key.cost`),value:a(_.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:o.series.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.bucket} · ${l(e.requests)} ${t(`key.requests`)} · ${a(e.costUsd)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${y>0?Math.max(2,e.requests/y*100):2}%`}},e.bucket))})]}),(0,S.jsx)(j,{title:t(`key.stats.byModel`),rows:o.models.map(e=>({name:e.model??`—`,...e}))}),(0,S.jsx)(j,{title:t(`key.stats.byClient`),rows:o.clients.map(e=>({name:e.client?v[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`)}),o.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:o.errors.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(f,{tone:`orange`,children:[t(`key.category.${e.category}`),` · `,l(e.count)]})},e.category))})]}),o.retentionDays!=null&&(0,S.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`key.stats.retention`,{days:o.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}=d();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:l(e.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:e.requests?p(e.successRequests/e.requests):`—`}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:l(e.inputTokens+e.outputTokens,!0)}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:a(e.costUsd)})]},e.name))})]})})}function M({apiKey:e}){let{t,locale:o}=d(),[s,c]=(0,x.useState)(`all`),[p,_]=(0,x.useState)([]),[y,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 g(e,{before:n,status:s===`failed`?N:void 0});_(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)(u,{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)(h,{tone:`danger`,title:T}),p.length===0&&!C&&!T&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`key.requests.empty`)}),p.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:p.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,o),children:i(e.time,o)}),(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?v[e.client]?.name??e.client:t(`key.stats.direct`)}),(0,S.jsx)(`td`,{className:`py-1.5`,children:e.errorCategory?(0,S.jsx)(f,{tone:`orange`,title:e.httpStatus?`HTTP ${e.httpStatus}`:void 0,children:t(`key.category.${e.errorCategory}`)}):(0,S.jsx)(f,{tone:`green`,children:t(`key.requests.success`)})}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right`,children:[l(e.inputTokens,!0),` / `,l(e.outputTokens,!0)]}),(0,S.jsx)(`td`,{className:`num py-1.5 text-right font-semibold`,children:a(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))})]})}),y&&(0,S.jsx)(`div`,{children:(0,S.jsx)(m,{size:`sm`,loading:C,onClick:()=>void D(y),children:t(`key.requests.more`)})})]})}var N=`upstream_error,gateway_error,client_cancelled,blocked`;export{E as KeyPage};
@@ -0,0 +1 @@
1
+ import{$n as e,Ba as t,Fn as n,H as r,Oi as i,Ua as a,ct as o,d as s,g as c,hi as l,l as u,m as d,n as f,on as p,p as m,r as h,rt as g,sn as _,t as v,u as y,v as b,wr as x,y as S,za as C}from"./alert-Clz2DftU.js";import{a as w,i as T,o as E,r as D}from"./overlays-UV1fYmtB.js";import{t as O}from"./arrow-left-B41OJQ5k.js";import{t as k}from"./pencil-C4YX2See.js";import{t as A}from"./rotate-ccw-ClcBYxmg.js";import{$ as j,B as M,P as N,Z as ee,et as te,h as P,i as ne,o as F}from"./index-LdSd2gU7.js";import{t as I}from"./checkbox-B4uUeJZd.js";import{t as L}from"./confirm-morph-BHc1Rk5D.js";var R=a(t(),1),z=C(),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}=o(),i=j(),{id:a=``}=te(),u=decodeURIComponent(a),_=n(u),C=l(u),T=x(u),D=p(),{toast:k}=E(),M=(0,R.useMemo)(()=>_.data?V(_.data):null,[_.data]),[N,L]=(0,R.useState)(M),[H,G]=(0,R.useState)(``);(0,R.useEffect)(()=>{L(M),G(M?.aliases?.join(`, `)??``)},[M]);let q=(0,z.jsx)(h,{variant:`glass`,icon:(0,z.jsx)(O,{className:`size-4`}),"aria-label":e(`common.back`),onClick:()=>i(`/models`)});if(_.isError)return(0,z.jsx)(P,{title:e(`nav.models`),leading:q,children:(0,z.jsx)(v,{tone:`danger`,title:e(`common.error`),children:w(_.error)})});let J=_.data;if(!J||!N)return(0,z.jsx)(P,{title:``,leading:q,children:(0,z.jsx)(b,{lines:5,className:`mx-auto max-w-[1100px]`})});let Y=e=>L(t=>({...t,...e})),X={...N,aliases:H.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)},Z=JSON.stringify(X)!==JSON.stringify(M),re=new Set(J.userModifiedFields),Q=J.source===`seed`,ie=()=>C.mutate(X,{onSuccess:()=>k(e(`common.saved`),`success`),onError:e=>k(w(e),`error`)}),$=t=>re.has(t)?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(f,{tone:`orange`,children:e(`models.modified`)}),Q&&(0,z.jsx)(h,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(A,{className:`size-3`}),title:e(`models.resetField`),"aria-label":e(`models.resetField`),onClick:()=>T.mutate(t,{onSuccess:()=>k(e(`models.fieldReset`)),onError:e=>k(w(e),`error`)})})]}):null;return(0,z.jsx)(P,{title:J.displayName,subtitle:`${J.id} · ${e(`models.source.${J.source}`)} · ${e(`models.updated`,{time:r(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 D.mutateAsync(J.id),i(`/models`)}}),Z&&(0,z.jsx)(h,{onClick:()=>{L(M),G(M?.aliases?.join(`, `)??``)},children:e(`common.revert`)}),(0,z.jsx)(h,{variant:`primary`,disabled:!Z,loading:C.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)(s,{className:`w-60`,"aria-label":e(`models.field.displayName`),value:N.displayName,onChange:e=>Y({displayName:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.vendor`),children:(0,z.jsx)(s,{className:`w-60`,"aria-label":e(`models.field.vendor`),value:N.vendor,onChange:e=>Y({vendor:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.family`),marker:$(`family`),children:(0,z.jsx)(s,{className:`w-60`,"aria-label":e(`models.field.family`),value:N.family??``,onChange:e=>Y({family:e.target.value||null})})}),(0,z.jsx)(U,{label:e(`models.field.aliases`),marker:$(`aliases`),children:(0,z.jsx)(s,{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)(m,{className:`w-36`,label:e(`models.field.contextWindow`),value:N.contextWindow,onChange:e=>Y({contextWindow:e})})}),(0,z.jsx)(U,{label:e(`models.field.maxOutputTokens`),marker:$(`maxOutputTokens`),children:(0,z.jsx)(m,{className:`w-36`,label:e(`models.field.maxOutputTokens`),value:N.maxOutputTokens,onChange:e=>Y({maxOutputTokens:e})})}),(0,z.jsx)(U,{label:e(`common.enabled`),children:(0,z.jsx)(S,{checked:N.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:!!N.capabilities?.[t.key],onCheckedChange:e=>Y({capabilities:{...N.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)(d,{label:(0,z.jsx)(ee,{className:`text-[var(--accent)]`,to:`/providers/${e.providerId}`,children:e.providerName}),detail:`${e.modelId} · ${g(e.pricing)}`},e.providerModelId))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(c,{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)(F,{value:N.pricing??null,onChange:e=>Y({pricing:e}),allowEmpty:!0})})]}),(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(c,{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)(d,{label:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e,t]}),children:n})}function W({model:e}){let{t}=o(),n=_(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)(h,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(M,{className:`size-3.5`}),onClick:()=>i(`new`),children:t(`common.add`)})]}),footer:t(`models.providerPricesFooter`),children:[e.providerPrices.length===0&&(0,z.jsx)(d,{label:(0,z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`models.noProviderPrices`)})}),e.providerPrices.map(e=>(0,z.jsxs)(d,{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)(f,{tone:`orange`,children:t(`models.modified`)})]}),detail:[g(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)(h,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(k,{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:a}=o(),{toast:c}=E(),l=e(),d=i(t.id),f=n===`new`,[p,m]=(0,R.useState)(``),[g,_]=(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)(T,{open:n!==null,onOpenChange:e=>!e&&r(),width:680,title:f?a(`models.addPrice`):a(`models.editPrice`,{key:p}),description:a(`models.priceSheetDetail`),footer:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(h,{onClick:r,children:a(`common.cancel`)}),(0,z.jsx)(h,{variant:`primary`,disabled:!p||!v,loading:d.isPending,onClick:()=>d.mutate({priceKey:p,upstreamModelId:g||null,pricing:v},{onSuccess:()=>{c(a(`common.saved`),`success`),r()},onError:e=>c(w(e),`error`)}),children:a(`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)(u,{label:a(`providers.priceKey`),children:f?(0,z.jsx)(D,{value:p,onChange:m,placeholder:a(`models.pickPriceKey`),options:(l.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey,disabled:b.has(e.priceKey)}))}):(0,z.jsx)(s,{value:p,disabled:!0,className:`font-mono`})}),(0,z.jsx)(u,{label:a(`models.upstreamId`),hint:a(`models.upstreamIdHint`),children:(0,z.jsx)(s,{className:`font-mono`,value:g,onChange:e=>_(e.target.value),placeholder:t.id})})]}),f&&(0,z.jsx)(s,{className:`font-mono`,"aria-label":a(`models.customPriceKey`),placeholder:a(`models.customPriceKey`),value:p,onChange:e=>m(e.target.value.trim())}),(0,z.jsx)(F,{value:v,onChange:y})]})})}function K({label:e,prompt:t,onConfirm:n}){let{t:r}=o();return(0,z.jsx)(L,{label:e,icon:(0,z.jsx)(N,{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};
@@ -0,0 +1 @@
1
+ import{Ba as e,In as t,Jr as n,Ua as r,V as i,Yr as a,Z as o,c as s,ct as c,d as l,en as u,h as d,l as f,n as p,nt as m,ot as h,p as g,r as _,t as v,v as y,za as b}from"./alert-Clz2DftU.js";import{a as x,i as S,o as C,r as w}from"./overlays-UV1fYmtB.js";import{t as T}from"./cloud-download-BZA23qWN.js";import{$ as E,B as D,D as O,G as k,M as A,N as j,U as M,h as N}from"./index-LdSd2gU7.js";import{t as P}from"./checkbox-B4uUeJZd.js";var F=r(e(),1),I=b();function L(){let{t:e}=c(),n=E(),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(``),[l,u]=(0,F.useState)(!1),[f,p]=(0,F.useState)(!1),m=(0,F.useRef)(null),h=j(r),g=t(),b=t(h,a),S=(0,F.useMemo)(()=>[...new Set((g.data??[]).map(e=>e.vendor))].sort(),[g.data]);return A(e=>{e===`find`&&m.current?.focus()}),(0,I.jsxs)(N,{title:e(`nav.models`),subtitle:b.data?e(`models.count`,{count:b.data.length}):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(d,{inputRef:m,className:`w-52`,value:r,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)(_,{icon:(0,I.jsx)(T,{className:`size-3.5`}),onClick:()=>p(!0),children:e(`models.sync`)}),(0,I.jsx)(_,{variant:`primary`,icon:(0,I.jsx)(D,{className:`size-3.5`}),onClick:()=>u(!0),children:e(`models.new`)})]}),children:[b.isLoading&&(0,I.jsx)(y,{lines:5}),b.isError&&(0,I.jsx)(v,{tone:`danger`,title:e(`common.error`),children:x(b.error)}),b.data?.length===0&&(0,I.jsx)(s,{icon:(0,I.jsx)(k,{className:`size-6`}),title:e(`models.empty`)}),b.data&&b.data.length>0&&(0,I.jsx)(O,{caption:e(`nav.models`),rowKey:`id`,rows:b.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=>n(`/models/${encodeURIComponent(e)}`))}),(0,I.jsx)(z,{open:l,onOpenChange:u,onCreated:e=>n(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:f,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:h(`truncate font-medium hover:text-[var(--accent)]`,!r.m.enabled&&`text-[var(--text-muted)]`),children:r.name}),r.m.source===`user`&&(0,I.jsx)(p,{tone:`accent`,children:e(`models.source.user`)}),r.m.userModifiedFields.length>0&&(0,I.jsx)(p,{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)=>i(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?`${o(n.input)} / ${o(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:e,onOpenChange:t,onCreated:n}){let{t:r}=c(),{toast:i}=C(),a=u(),[o,s]=(0,F.useState)(``),[d,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[v,y]=(0,F.useState)(null),[b,w]=(0,F.useState)(null),[T,E]=(0,F.useState)(null);return(0,I.jsx)(S,{open:e,onOpenChange:t,title:r(`models.new`),description:r(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(_,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,I.jsx)(_,{variant:`primary`,disabled:!o.trim()||!m.trim(),loading:a.isPending,onClick:()=>a.mutate({id:o.trim(),displayName:d.trim()||o.trim(),vendor:m.trim(),contextWindow:v,pricing:b!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:b,output:T}}:null},{onSuccess:e=>{t(!1),s(``),p(``),n(e.id)},onError:e=>i(x(e),`error`)}),children:r(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(f,{label:r(`models.field.id`),hint:r(`models.field.idHint`),children:(0,I.jsx)(l,{className:`font-mono`,value:o,onChange:e=>s(e.target.value),placeholder:`my-model-1`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsx)(f,{label:r(`models.field.displayName`),children:(0,I.jsx)(l,{value:d,onChange:e=>p(e.target.value)})}),(0,I.jsx)(f,{label:r(`models.field.vendor`),children:(0,I.jsx)(l,{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)(f,{label:r(`models.field.contextWindow`),children:(0,I.jsx)(g,{value:v,onChange:y})}),(0,I.jsx)(f,{label:r(`models.field.inputPrice`),children:(0,I.jsx)(g,{value:b,onChange:w})}),(0,I.jsx)(f,{label:r(`models.field.outputPrice`),children:(0,I.jsx)(g,{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}=c(),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:`${m(e)||`∅`}\n→\n${m(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}=c(),[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]),l=e=>{let t=e.filter(e=>n.has(e)).length;return t===0?!1:t===e.length||`indeterminate`},u=(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)(p,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(p,{tone:`orange`,children:i(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),m=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:l(m),onCheckedChange:e=>u(m,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:m.length,models:s.length})})]}),s.map(([e,r])=>{let o=r.map(e=>e.id),s=r.length===1?r[0]:void 0,c=!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:l(o),onCheckedChange:e=>u(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":c,onClick:()=>d(e),children:[(0,I.jsx)(M,{className:h(`size-3.5 shrink-0 text-[var(--text-muted)] transition-transform`,c&&`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&&c&&(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=>u([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}=c(),{toast:i}=C(),o=a(),s=n(),[l,u]=(0,F.useState)(new Set),d=()=>o.mutate(void 0,{onSuccess:e=>u(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),f=o.data?.changes??[];return(0,I.jsxs)(S,{open:e,onOpenChange:e=>{t(e),e&&!o.data&&d()},width:720,title:r(`models.sync`),description:r(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(_,{className:`mr-auto`,variant:`plain`,onClick:d,loading:o.isPending,children:r(`common.refresh`)}),(0,I.jsx)(_,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,I.jsx)(_,{variant:`primary`,disabled:l.size===0,loading:s.isPending,onClick:()=>s.mutate([...l],{onSuccess:e=>{i(r(`models.sync.applied`,{count:e.applied}),`success`),t(!1),o.reset()},onError:e=>i(x(e),`error`)}),children:r(`models.sync.apply`,{count:l.size})})]}),children:[e&&!o.data&&!o.isPending&&!o.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(_,{variant:`primary`,onClick:d,children:r(`models.sync.check`)})}),o.isPending&&(0,I.jsx)(y,{lines:4}),o.isError&&(0,I.jsx)(v,{tone:`danger`,title:r(`common.error`),children:x(o.error)}),o.data&&f.length===0&&(0,I.jsx)(v,{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:l,onChange:u})]})}export{L as ModelsPage};
@@ -0,0 +1,2 @@
1
+ import{Ba as e,Gn as t,H as n,Hn as r,Ln as i,Nt as a,On as o,Pn as s,Tn as c,Ua as l,Un as u,Vn as d,Yn as f,Zn as p,_ as m,b as h,bt as g,c as _,ct as v,d as y,f as b,gi as x,gr as S,h as C,hr as w,i as T,l as E,mt as D,n as O,ot as k,r as A,t as j,v as M,xt as N,y as P,za as ee}from"./alert-Clz2DftU.js";import{a as F,i as I,n as te,o as L}from"./overlays-UV1fYmtB.js";import{t as ne}from"./arrow-down-D4v2aNc0.js";import{t as re}from"./download-1kPyvAIz.js";import{t as ie}from"./ellipsis-Dzh8eeEb.js";import{t as ae}from"./external-link-CP_HY9s9.js";import{$ as R,B as oe,C as se,E as z,I as ce,P as le,T as B,Y as V,et as H,h as U,q as ue,tt as de,w as W,x as fe,z as G}from"./index-LdSd2gU7.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(e(),1),J=ee(),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`?ce:V,{className:`size-[55%]`,strokeWidth:1.75})}):(0,J.jsx)(fe,{name:e,icon:t,size:r})}function Z(){let{t:e}=v(),t=R(),{tab:n}=H(),r=n===`market`||n===`runtime`?n:`installed`,i=f(),a=x(),{toast:o}=L(),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[d,p]=(0,q.useState)(null);return(0,J.jsxs)(U,{title:e(`nav.plugins`),subtitle:e(`plugins.subtitle`),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{icon:(0,J.jsx)(G,{className:`size-3.5`}),onClick:()=>a.mutate(void 0,{onSuccess:e=>p(e.id),onError:e=>o(F(e),`error`)}),disabled:!i.data?.plugins.length,children:e(`plugins.updateAll`)}),(0,J.jsx)(A,{variant:`primary`,icon:(0,J.jsx)(oe,{className:`size-3.5`}),onClick:()=>c(!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)(se,{value:r,onValueChange:e=>t(e===`installed`?`/plugins`:`/plugins/${e}`,{replace:!0}),children:[(0,J.jsxs)(B,{"aria-label":e(`nav.plugins`),children:[(0,J.jsxs)(z,{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)(z,{value:`market`,children:e(`plugins.tab.market`)}),(0,J.jsx)(z,{value:`runtime`,children:e(`plugins.tab.runtime`)})]}),(0,J.jsxs)(W,{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:F(i.error)}),i.data&&(0,J.jsx)(ge,{plugins:i.data.plugins,preferences:i.data.preferences,onJob:p,onBrowse:()=>t(`/plugins/market`),onImport:()=>u(!0)})]}),(0,J.jsx)(W,{value:`market`,className:`pt-1`,children:(0,J.jsx)(Se,{installed:i.data?.plugins??[],onJob:p})}),(0,J.jsx)(W,{value:`runtime`,className:`pt-1`,children:(0,J.jsx)(Ce,{onJob:p})})]})]}),(0,J.jsx)(ye,{open:s,onOpenChange:c,onJob:p}),(0,J.jsx)(be,{open:l,onOpenChange:u,onJob:p}),(0,J.jsx)(xe,{id:d,onClose:()=>p(null)})]})}function ge({plugins:e,preferences:t,onJob:n,onBrowse:r,onImport:i}){let{t:a}=v(),o=d(e.some(e=>e.kinds.includes(`provider`)||e.kinds.includes(`pi`))),c=s(),l=S(),{toast:u}=L(),f=!!(c.data?.found&&c.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:c.data.plugins.filter(e=>!e.installed).length})}),(0,J.jsx)(A,{size:`sm`,icon:(0,J.jsx)(re,{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:[f,(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(_,{icon:(0,J.jsx)(D,{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 p=(t,n)=>{let r=e.map(e=>e.spec),[i]=r.splice(t,1);r.splice(t+n,0,i),l.mutate(r,{onError:e=>u(F(e),`error`)})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[f,(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?()=>p(i,-1):void 0,onDown:i<e.length-1?()=>p(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}=v(),c=R(),{toast:l,confirm:u}=L(),d=i(),f=x(),m=w(),h=p(),[g,_]=(0,q.useState)(!1),y=t?.plugins.find(t=>t.spec===e.spec),b=e.middleware,S=e.kinds[0]??`provider`,C=async()=>{await u({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=>l(F(e),`error`)})},T=[];return b&&!b.error&&T.push((0,J.jsxs)(Q,{label:s(`plugins.kind.middleware`),children:[s(`plugins.mw.stats`,{hooks:b.hooks.join(`, `),calls:b.calls,micros:b.avgMicros.toFixed(1),failures:b.failures}),b.lastError&&(0,J.jsx)(`span`,{className:`block text-[var(--danger)]`,children:s(`plugins.mw.lastError`,{error:b.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:()=>c(`/clients/${e.agent.kind}`),children:s(`plugins.agent.adds`,{name:e.agent.name??e.agent.id??``})})},`agent`)),y&&y.provides.length>0&&T.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)(A,{size:`sm`,onClick:()=>h.mutate({spec:e.spec,provider:t},{onError:e=>l(F(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:k(`flex gap-3 px-4 py-3.5`,!e.enabled&&`opacity-70`),children:[(0,J.jsx)(`div`,{className:k(`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)(O,{tone:he[e],children:s(Y[e])},e)),e.isPath&&(0,J.jsx)(O,{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:[b&&(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)(ue,{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)(ne,{className:`size-3.5`})})]}),(0,J.jsx)(P,{checked:e.enabled,label:s(`plugins.enabled`),onChange:t=>d.mutate({spec:e.spec,enabled:t},{onError:e=>l(F(e),`error`)})}),(0,J.jsx)(te,{label:s(`common.more`),iconOnly:!0,icon:(0,J.jsx)(ie,{className:`size-4`}),items:[{id:`options`,label:s(`plugins.options`),icon:(0,J.jsx)(pe,{className:`size-3.5`}),onSelect:()=>_(!0)},...e.isPath?[]:[{id:`update`,label:s(`plugins.update`),icon:(0,J.jsx)(G,{className:`size-3.5`}),onSelect:()=>f.mutate(e.spec,{onSuccess:e=>r(e.id),onError:e=>l(F(e),`error`)})}],{id:`remove`,label:s(`common.delete`),icon:(0,J.jsx)(le,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void C()}]})]})]}),e.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.cantLoad`),children:e.error}),y?.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.hostCantLoad`),children:y.error}),b?.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.mw.error`,{error:b.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:_})]})}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}=v(),{toast:a}=L(),o=i(),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(null);(0,q.useEffect)(()=>{t&&(c(JSON.stringify(e.options??e.optionsExample??{},null,2)),u(null))},[t,e.options,e.optionsExample]);let d=t=>o.mutate({spec:e.spec,options:t},{onSuccess:()=>(a(r(`plugins.optionsSaved`)),n(!1)),onError:e=>a(F(e),`error`)});return(0,J.jsxs)(I,{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(s||`{}`);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:o.isPending,children:r(`common.save`)})]}),children:[(0,J.jsx)(h,{mono:!0,rows:14,value:s,invalid:!!l,onChange:e=>(c(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}=v(),{toast:i}=L(),o=a(),[s,c]=(0,q.useState)(``);return(0,q.useEffect)(()=>{e&&c(``)},[e]),(0,J.jsxs)(I,{open:e,onOpenChange:t,title:r(`plugins.addTitle`),description:r(`plugins.addDetail`),footer:(0,J.jsx)(A,{variant:`primary`,disabled:!s.trim()||o.isPending,onClick:()=>o.mutate({spec:s.trim()},{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(F(e),`error`)}),children:r(`plugins.install`)}),children:[(0,J.jsx)(E,{label:r(`plugins.spec`),hint:r(`plugins.specHint`),children:(0,J.jsx)(y,{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}=v(),{toast:i}=L(),a=s(e),o=c(),[l,u]=(0,q.useState)(!1),d=a.data;return(0,J.jsxs)(I,{open:e,onOpenChange:t,title:r(`plugins.magpie.title`),description:d?.path,width:560,footer:(0,J.jsx)(A,{variant:`primary`,disabled:!d?.found||o.isPending,onClick:()=>o.mutate(l,{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(F(e),`error`)}),children:r(`plugins.magpie.import`)}),children:[a.isLoading&&(0,J.jsx)(M,{lines:3}),d?.error&&(0,J.jsx)(j,{tone:`danger`,title:r(`common.error`),children:d.error}),d&&(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:d.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)(O,{children:r(`plugins.magpie.off`)}),e.hasOptions&&(0,J.jsx)(O,{tone:`accent`,children:r(`plugins.options`)}),e.installed&&(0,J.jsx)(O,{tone:`green`,children:r(`plugins.installed`)})]},e.spec))}),d.signIns>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(P,{checked:l,onChange:u,label:r(`plugins.magpie.signIns`,{count:d.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}=v(),i=r(e).data;return(0,J.jsxs)(I,{open:!!e,onOpenChange:e=>!e&&t(),title:n(`plugins.job.title`),description:i?n(i.state===`running`?`plugins.job.running`:i.state===`succeeded`?`plugins.job.done`:`plugins.job.failed`,{target:i.target}):void 0,width:620,footer:(0,J.jsx)(A,{onClick:t,children:n(`common.close`)}),children:[!i&&(0,J.jsx)(M,{lines:3}),i&&(0,J.jsx)(T,{language:`text`,children:i.log.length?i.log.join(`
2
+ `):`…`}),i?.state===`failed`&&i.error&&(0,J.jsx)(j,{tone:`danger`,title:n(`plugins.job.failedTitle`),className:`mt-3`,children:i.error})]})}function Se({installed:e,onJob:n}){let{t:r,locale:i}=v(),{toast:o,confirm:s}=L(),c=u(),l=a(),[d,f]=(0,q.useState)(``),[p,h]=(0,q.useState)(``),[g,y]=(0,q.useState)(`all`);(0,q.useEffect)(()=>{let e=setTimeout(()=>h(d.trim()),400);return()=>clearTimeout(e)},[d]);let b=t(p),x=(0,q.useMemo)(()=>new Set(e.map(e=>e.name)),[e]),S=(t,n)=>x.has(n)||e.some(e=>e.spec===t),w=async(e,t)=>{await s({title:r(`plugins.installConfirm`,{name:e}),detail:r(`plugins.trustDetail`),confirmLabel:r(`plugins.install`)})&&l.mutate({spec:e,source:t},{onSuccess:e=>n(e.id),onError:e=>o(F(e),`error`)})},[T,E]=de(),O=T.get(`install`),k=(0,q.useRef)(null);(0,q.useEffect)(()=>{O&&k.current!==O&&(k.current=O,E({},{replace:!0}),me.test(O)?w(O,`market`):o(r(`plugins.linkInvalid`),`error`))},[O]);let A=(c.data??[]).filter(e=>g===`all`||e.kind===g),N=e=>(c.data??[]).filter(t=>e===`all`||t.kind===e).length,P=p.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)(C,{className:`min-w-[220px] flex-1`,value:d,onChange:f,placeholder:r(`plugins.searchPlaceholder`)}),!P&&(0,J.jsx)(m,{ariaLabel:r(`plugins.kindFilter`),value:g,onChange:y,items:[`all`,`provider`,`middleware`,`agent`].map(e=>({value:e,label:`${r(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)(_,{icon:(0,J.jsx)(D,{className:`size-6`}),title:r(`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:[r(Y[e.kind]),e.source===`github`?`★ ${e.stars}`:e.version?`v${e.version}`:``,e.source===`astra`?r(`plugins.origin.astra`):``],installed:S(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:r(`plugins.searchNote`)})]}):(0,J.jsxs)(J.Fragment,{children:[c.isLoading&&(0,J.jsx)(M,{lines:4}),c.isError&&(0,J.jsx)(j,{tone:`danger`,title:r(`common.error`),children:F(c.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[i]??e.summary.en??e.description??void 0,tags:[r(Y[e.kind]),e.latest?`v${e.latest}`:``,e.origin===`astra`?r(`plugins.origin.astra`):``,e.minAstraVersion?r(`plugins.minVersion`,{version:e.minAstraVersion}):``].filter(Boolean),installed:S(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:r(`plugins.marketNote`)})]})]})}function $({title:e,subtitle:t,icon:n,detail:r,tags:i,installed:a,onInstall:o}){let{t:s}=v();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)(O,{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)(g,{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}=v(),{toast:i}=L(),a=f(),s=d(),c=o(),l=a.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)(O,{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(F(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)(O,{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)(O,{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)(ae,{className:`size-3`}),` astragate-community/astra-gate-plugins`]})]})}export{Z as PluginsPage};
@@ -0,0 +1 @@
1
+ import{Ba as e,E as t,J as n,Ji as r,Ki as i,Qi as a,Ua as o,Xt as s,Y as c,Yi as l,Zi as u,_ as d,_i as f,b as p,bt as m,c as h,ct as g,d as _,dt as v,er as y,g as b,h as x,l as S,m as C,n as w,nr as T,ot as E,qi as D,qt as O,r as k,rr as ee,t as te,tr as A,u as j,v as M,xt as N,y as P,za as F}from"./alert-Clz2DftU.js";import{a as I,i as ne,o as L,r as R}from"./overlays-UV1fYmtB.js";import{$ as z,B as re,C as B,D as ie,E as ae,I as oe,N as V,P as se,T as H,U as ce,W as le,_ as ue,c as de,et as fe,h as pe,nt as me,r as he,rt as U,w as W,z as ge}from"./index-LdSd2gU7.js";var _e={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`}]]};_e.node;var ve=N(_e),G=o(e(),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=F(),J={duration:t.duration.standard,ease:[...t.ease.enter]},ye={duration:t.duration.instant,ease:[...t.ease.standard]},Y={duration:0},be={duration:t.duration.instant,ease:[...t.ease.standard]},X=e=>`blur(${e}px)`,xe=e=>Math.min(1,Math.max(0,e)),Se=e=>typeof e==`string`?{value:e}:e,Ce=e=>e.label??e.value,we=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:ye},transition:e?be:J});function Te({text:e}){let n=r()??!1,a=(0,G.useRef)(null),o=l(`auto`);return(0,G.useLayoutEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let r=null,i=new ResizeObserver(([i])=>{let a=Math.ceil(i.borderBoxSize?.[0]?.inlineSize??e.offsetWidth),s=r!==null&&r!==e.textContent;r=e.textContent,s&&!n?D(o,a,t.spring.morph):o.jump(a)});return i.observe(e),()=>i.disconnect()},[n,o]),(0,q.jsxs)(i.span,{className:K.morphText,style:{width:o},children:[(0,q.jsx)(`span`,{ref:a,className:K.measure,"aria-hidden":`true`,children:e}),(0,q.jsx)(u,{mode:`popLayout`,initial:!1,children:(0,q.jsx)(i.span,{className:K.morphValue,...we(n),children:e},e)})]})}function Ee(e,n,r){let i=l(`auto`);return(0,G.useLayoutEffect)(()=>{let a=e.current;if(!a||typeof ResizeObserver>`u`)return;let o=!1,s=new ResizeObserver(()=>{let e=a.offsetHeight;if(!o||r||performance.now()>n.current){o=!0,i.jump(e);return}D(i,e,t.spring.smooth)});return s.observe(a),()=>s.disconnect()},[n,i,e,r]),i}function De(e,n,r){(0,G.useLayoutEffect)(()=>{let i=e.current;if(!i||typeof ResizeObserver>`u`)return;let a=new Map,o=()=>{let e=performance.now();for(let o of Array.from(i.children)){let i=o.offsetLeft,s=o.offsetTop,c=a.get(o);if(!c){a.set(o,{x:i,y:s,dx:0,dy:0});continue}let l=c.x-i,u=c.y-s;if(c.x=i,c.y=s,r||e>n.current||Math.abs(u)<1&&Math.abs(l)<40)continue;c.stop?.();let d=c.dx+l,f=c.dy+u,p=e=>{c.dx=d*(1-e),c.dy=f*(1-e),o.style.translate=e>=1?``:`${c.dx}px ${c.dy}px`};p(0),c.stop=D(0,1,{...t.spring.smooth,onUpdate:p,onComplete:()=>p(1)}).stop}for(let e of a.keys())e.parentElement!==i&&a.delete(e)},s=new ResizeObserver(o),c=()=>{for(let e of Array.from(i.children))s.observe(e)},l=new MutationObserver(()=>{c(),o()});return s.observe(i),c(),l.observe(i,{childList:!0}),()=>{s.disconnect(),l.disconnect();for(let e of a.values())e.stop?.()}},[n,e,r])}var Oe=e=>e.valueLabel??e.value,ke=e=>Oe(e)?`${e.label}: ${Oe(e)}`:e.label,Ae={empty:`No filters applied`,clearAll:`Clear all`,back:`Back to fields`,noOptions:`No options available`,cleared:`All filters cleared`,remove:e=>`Remove ${ke(e)}`,added:e=>`Added ${ke(e)}`,changed:e=>`Changed ${ke(e)}`,removed:e=>`Removed ${ke(e)}`};function je(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 Me({rows:e,labelledBy:n,onChoose:o,onBack:s,onLeave:c,radio:l,emptyMessage:u}){let d=r()??!1,f=a(),p=(0,G.useRef)(null),m=(0,G.useRef)(!1),h=(0,G.useRef)({text:``,at:0}),[g,_]=(0,G.useState)(()=>Math.max(0,e.findIndex(e=>e.checked))),[v,y]=(0,G.useState)(null),b=()=>Array.from(p.current?.querySelectorAll(`[data-row]`)??[]),x=e=>{let t=p.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 S(t){let n=b(),r=n.indexOf(document.activeElement),i=e=>{t.preventDefault(),m.current=!1,x(n[e])};if(t.key===`ArrowDown`)return i(r<0?0:(r+1)%n.length);if(t.key===`ArrowUp`)return i(r<0?n.length-1:(r-1+n.length)%n.length);if(t.key===`Home`)return i(0);if(t.key===`End`)return i(n.length-1);if(t.key===`ArrowRight`&&r>=0&&e[r]?.drill){t.preventDefault(),o(e[r],!0);return}if(t.key===`ArrowLeft`&&s){t.preventDefault(),s(!0);return}if(t.key.length===1&&/\S/.test(t.key)&&!t.metaKey&&!t.ctrlKey&&!t.altKey){let e=performance.now();h.current={text:e-h.current.at<700?h.current.text+t.key.toLowerCase():t.key.toLowerCase(),at:e};let a=[...n.slice(r+(h.current.text.length>1?0:1)),...n.slice(0,r+(h.current.text.length>1?0:1))].find(e=>(e.dataset.text??``).toLowerCase().startsWith(h.current.text));a&&i(n.indexOf(a))}}function C(e){let t=e.target.closest(`[data-row]`);if(!t)return;_(b().indexOf(t));let n=m.current&&!d,r=!m.current&&t.matches(`:focus-visible`);y(e=>({top:t.offsetTop,height:t.offsetHeight,glide:n&&!!e?.shown,ring:r,shown:!0}))}function w(e){p.current?.contains(e.relatedTarget)||y(e=>e&&{...e,glide:!1,ring:!1,shown:!1})}return(0,q.jsxs)(`div`,{ref:p,className:K.list,role:`menu`,"aria-labelledby":n,"data-current":f?``:void 0,onKeyDown:S,onFocus:C,onBlur:w,onPointerLeave:()=>{m.current&&p.current?.contains(document.activeElement)&&c()},children:[(0,q.jsx)(i.span,{className:K.highlight,"data-ring":v?.ring||void 0,"aria-hidden":`true`,initial:!1,animate:v?{y:v.top,height:v.height,opacity:+!!v.shown}:{opacity:0},transition:{default:v?.glide?t.spring.snappy:Y,opacity:{duration:d?0:.08}}}),e.length===0?(0,q.jsx)(`p`,{className:K.noOptions,children:u}):null,e.map((e,t)=>(0,q.jsxs)(`button`,{type:`button`,className:K.item,role:l?`menuitemradio`:`menuitem`,"aria-checked":l?!!e.checked:void 0,tabIndex:t===g?0:-1,"data-row":e.key,"data-text":e.label,onPointerMove:e=>{m.current=!0,document.activeElement!==e.currentTarget&&e.currentTarget.focus({preventScroll:!0})},onClick:t=>o(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 Ne(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 Pe({fields:e,onSelect:n,active:a=[],label:o=`Add filter`,align:s=`end`,messages:c}){let d={...Ae,...c},f=r()??!1,p=(0,G.useId)(),h=`${p}panel`,g=`${p}title`,_=(0,G.useRef)(null),v=(0,G.useRef)(null),y=(0,G.useRef)(null),b=(0,G.useRef)(`closed`),x=(0,G.useRef)(0),S=(0,G.useRef)(null),[C,w]=(0,G.useState)(`closed`),[T,E]=(0,G.useState)(null),[O,k]=(0,G.useState)(1),[ee,te]=(0,G.useState)(!1),[A,j]=(0,G.useState)(`100% 0`),M=l(`100%`),N=l(`100%`),P=l(0),F=l(0),I=U(()=>F.get()-P.get()),ne=l(0),L=l(0),R=U(()=>{let e=M.get(),t=ne.get(),n=L.get();return typeof e==`number`?n>t?xe((e-t)/(n-t)):1:0}),z=U(()=>xe(R.get()/.35)),B=U(()=>xe((R.get()-.4)/.5)),ie={opacity:U(()=>1-z.get()),scale:U(()=>1-z.get()*.04),filter:U(()=>z.get()?X(z.get()*t.blur.subtle):`none`)},ae={opacity:B,transformOrigin:A,scale:U(()=>.96+B.get()*.04),y:U(()=>(1-B.get())*(ee?-6:6)),filter:U(()=>B.get()===1?`none`:X((1-B.get())*t.blur.soft))},oe=C===`open`,V=e.find(e=>e.id===T)??null,se=(0,G.useCallback)(e=>{let n=v.current,r=y.current;if(!n||!r)return;let i=n.getBoundingClientRect(),a=r.offsetWidth+2,o=r.offsetHeight+2,c=Ne(_.current??n),l=c.left+16-i.left,u=c.right-16-i.left-a,d=i.width-a,p=s===`end`?d>=l?d:0<=u?0:d:0<=u?0:d>=l?d:0;p=Math.round(Math.min(Math.max(p,l),Math.max(l,u)));let m=c.bottom-i.top,h=i.bottom-c.top,g=m<o+16&&h>m;b.current===`closed`&&(M.jump(i.width),N.jump(i.height),P.jump(0)),F.jump(p),ne.jump(i.width),L.jump(a),b.current=`open`,x.current+=1,S.current=e,w(`open`),te(g),E(null),k(-1),j(`${Math.round(i.width/2-p)}px ${g?`100%`:`0`}`);let C=f?Y:t.spring.morph;D(P,p,C),D(M,a,C),D(N,o,C)},[s,ne,N,P,f,F,L,M]),H=(0,G.useCallback)(e=>{let n=v.current;if(b.current!==`open`||!n)return;b.current=`closing`;let r=x.current+=1;w(`closing`),e&&n.focus({preventScroll:!0,focusVisible:e===`keyboard`});let i=f?Y:t.spring.snappy;D(P,0,i);let a=n.getBoundingClientRect();D(N,a.height,i),D(M,a.width,{...i,onComplete:()=>{r===x.current&&(b.current=`closed`,M.jump(`100%`),N.jump(`100%`),w(`closed`),E(null))}})},[N,P,f,M]);(0,G.useLayoutEffect)(()=>{let e=y.current;if(!e||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>{b.current===`open`&&D(N,e.offsetHeight+2,f?Y:t.spring.smooth)});return n.observe(e),()=>n.disconnect()},[N,f]),(0,G.useLayoutEffect)(()=>{let e=S.current,t=y.current;if(!e||!t||C!==`open`)return;if(S.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})},[C,T]),(0,G.useEffect)(()=>{if(C!==`open`)return;let e=e=>{let t=_.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))&&v.current?.focus({preventScroll:!0,focusVisible:!1})},0))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[H,C]);function ue(e){if(e.defaultPrevented)return;let t=Array.from(y.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(),de(!0))}function de(e){V&&(S.current=e?{key:V.id}:`panel`,k(-1),E(null))}function fe(e,t){S.current=t?`checked`:`panel`,k(1),E(e.key)}function pe(e,t){V&&(n({id:V.id,label:V.label,value:e.key,valueLabel:e.label},V),H(t?`keyboard`:`pointer`))}let me=e=>a.find(t=>t.id===e.id),he=e.map(e=>({key:e.id,label:e.label,icon:e.icon,drill:!0,meta:(0,q.jsxs)(q.Fragment,{children:[me(e)?(0,q.jsx)(`span`,{className:K.metaValue,children:Oe(me(e))}):null,(0,q.jsx)(ce,{size:15,strokeWidth:1.8,"aria-hidden":`true`})]})})),W=V?V.options.map(Se).map(e=>{let t=Ce(e),n=me(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)(m,{size:15,strokeWidth:2,"aria-hidden":`true`})})]}):null}}):[],ge={enter:e=>f?{opacity:0}:{opacity:0,x:e*18,filter:X(t.blur.soft)},center:{opacity:1,x:0,filter:X(0),transition:f?be:{...J,x:t.spring.smooth}},exit:e=>f?{opacity:0,transition:Y}:{opacity:0,x:e*-18,filter:X(t.blur.subtle),transition:ye}};return(0,q.jsxs)(`div`,{ref:_,className:K.menu,"data-state":C,"data-y":ee?`up`:`down`,onKeyDown:e=>{e.key===`Escape`&&b.current===`open`&&(e.preventDefault(),e.stopPropagation(),H(`keyboard`))},onBlur:e=>{let t=e.relatedTarget;b.current===`open`&&t&&!_.current?.contains(t)&&H(!1)},children:[(0,q.jsx)(`button`,{ref:v,type:`button`,className:K.trigger,"data-filter-trigger":``,"aria-haspopup":`dialog`,"aria-expanded":oe,"aria-controls":h,tabIndex:oe?-1:void 0,onClick:e=>{b.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)(i.span,{className:K.face,style:ie,children:[(0,q.jsx)(re,{size:15,strokeWidth:1.8,"aria-hidden":`true`}),o]})}),(0,q.jsx)(i.div,{className:K.surface,style:{left:P,width:M,height:N},children:(0,q.jsx)(i.div,{ref:y,id:h,className:K.panel,role:`dialog`,"aria-labelledby":g,tabIndex:-1,inert:!oe,style:{x:I},onKeyDown:ue,children:(0,q.jsxs)(i.div,{style:ae,children:[(0,q.jsxs)(`div`,{className:K.head,children:[(0,q.jsx)(u,{initial:!1,children:V?(0,q.jsx)(i.button,{type:`button`,className:K.back,"aria-label":d.back,onClick:e=>de(e.detail===0),initial:f?{opacity:0,width:28,marginRight:2}:{opacity:0,width:0,marginRight:0,scale:.6},animate:{opacity:1,width:28,marginRight:2,scale:1},exit:f?{opacity:0,transition:Y}:{opacity:0,width:0,marginRight:0,scale:.6,transition:{...t.spring.snappy,opacity:ye}},transition:f?be:{...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)(u,{mode:`popLayout`,initial:!1,children:(0,q.jsx)(i.span,{className:K.titleText,...we(f),children:V?V.label:o},V?.id??`fields`)})})]}),(0,q.jsx)(`div`,{className:K.stage,children:(0,q.jsx)(u,{mode:`popLayout`,initial:!1,custom:O,children:(0,q.jsx)(i.div,{className:K.step,custom:O,variants:ge,initial:`enter`,animate:`center`,exit:`exit`,children:V?(0,q.jsx)(Me,{rows:W,labelledBy:g,emptyMessage:d.noOptions,radio:!0,onChoose:pe,onBack:de,onLeave:()=>y.current?.focus({preventScroll:!0})}):(0,q.jsx)(Me,{rows:he,labelledBy:g,emptyMessage:d.noOptions,onChoose:fe,onLeave:()=>y.current?.focus({preventScroll:!0})})},V?.id??`fields`)})})]})})})]})}function Fe({filters:e,onRemove:n,onClearAll:a,leading:o,children:s,label:c=`Active filters`,addFilter:l,messages:d}){let f={...Ae,...d},p=r()??!1,m=(0,G.useRef)(null),h=(0,G.useRef)(null),g=(0,G.useRef)(0),_=(0,G.useRef)(null),[y,b]=(0,G.useState)(e),[x,S]=(0,G.useState)(``);if(y!==e){b(e);let t=je(y,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=Ee(h,g,p);De(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:ye},transition:p?T:{...J,scale:t.spring.snappy}},O=p?{...we(!0),initial:!1}:we(!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":c,children:[o?(0,q.jsx)(`div`,{className:K.leading,children:o}):null,(0,q.jsx)(i.div,{className:K.frame,style:{height:w},children:(0,q.jsxs)(`div`,{ref:h,className:K.chips,children:[(0,q.jsx)(u,{initial:!1,children:e.map((e,t)=>(0,q.jsx)(i.span,{className:K.slot,...E(8),children:(0,q.jsxs)(i.span,{className:K.chip,...D,children:[(0,q.jsxs)(`span`,{className:K.chipLabel,title:ke(e),children:[e.label,Oe(e)?(0,q.jsxs)(`span`,{className:K.value,children:[(0,q.jsx)(`span`,{className:K.separator,children:` · `}),(0,q.jsx)(Te,{text:Oe(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)(v,{size:14,strokeWidth:1.8,"aria-hidden":`true`})})]})},e.id))}),(0,q.jsx)(u,{initial:!1,children:e.length?null:(0,q.jsx)(i.span,{className:K.empty,...k,children:f.empty},`empty`)})]})}),(0,q.jsxs)(`div`,{className:K.actions,children:[l?(0,q.jsx)(Pe,{fields:l.fields,onSelect:l.onAdd,active:e,label:l.label,align:l.align,messages:f}):null,s,(0,q.jsx)(u,{initial:!1,children:e.length>0&&a?(0,q.jsx)(i.span,{className:K.slot,...E(12),children:(0,q.jsx)(`button`,{className:K.clear,type:`button`,onClick:()=>{_.current=-1,a?.()},children:(0,q.jsx)(i.span,{className:K.clearText,...O,children:f.clearAll})})},`clear`):null})]}),(0,q.jsx)(`span`,{className:K.srOnly,role:`status`,children:x})]})}var Ie={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`},Le={warn:`settings.privacy.action.warn`,block:`settings.privacy.action.block`,redact:`settings.privacy.action.redact`};function Z(){let{t:e}=g();return t=>{let n=Ie[t];return n?e(n):t}}function Re({action:e}){let{t}=g();return(0,q.jsx)(w,{tone:e===`block`?`red`:e===`redact`?`orange`:`neutral`,children:t(Le[e]??`settings.privacy.action.warn`)})}var ze=50,Be=[`block`,`redact`,`warn`];function Ve(){let{t:e,locale:t}=g(),r=Z(),[i,a]=(0,G.useState)(``),[o,l]=(0,G.useState)({client:``,category:``,action:``,blocked:``}),[u,d]=(0,G.useState)(1),[f,p]=(0,G.useState)(null),m=V(i),_=s(),v=y(),{toast:b,confirm:S}=L(),C=O(),w={model:m,...o,page:u,pageSize:ze},T=ee(w,u===1),D=T.data,A=D?Math.max(1,Math.ceil(D.total/ze)):1,j=e=>e?ue[e]?.name??e:`—`,N=[...new Set((v.data?.rules??[]).map(e=>e.category))],P={client:(_.data??[]).map(e=>({value:e.kind,label:e.name})),category:N.map(e=>({value:e,label:r(e)})),action:Be.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`)}]},F={client:e(`requests.col.client`),category:e(`privacy.stats.col.category`),action:e(`privacy.logs.col.action`),blocked:e(`privacy.logs.col.outcome`)},ne=Object.keys(P).map(e=>({id:e,label:F[e],options:P[e].map(e=>e.label)})),R=Object.keys(o).filter(e=>o[e]).map(e=>({id:e,label:F[e],value:P[e].find(t=>t.value===o[e])?.label??o[e]})),z=(e,t)=>{l(n=>({...n,[e]:t})),d(1)},re=(D?.items??[]).map(e=>({id:e.id,time:Date.parse(e.startedAtUtc),client:j(e.clientKind),model:e.requestedModel??``,outcome:He(e),hits:e.hits.reduce((e,t)=>e+t.count,0),e})),B=[{key:`time`,label:e(`requests.col.time`),width:92,render:(e,r)=>(0,q.jsx)(`span`,{className:`num`,children:n(r.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:()=>p(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:j(n.e.clientKind)})]})},{key:`outcome`,label:e(`privacy.logs.col.outcome`),width:130,render:(e,t)=>(0,q.jsx)(Ue,{event:t.e})},{key:`hits`,label:e(`privacy.logs.col.hits`),render:(e,t)=>(0,q.jsx)(We,{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)(x,{className:`w-52`,value:i,onChange:e=>{a(e),d(1)},placeholder:e(`requests.searchModel`)}),(0,q.jsx)(k,{variant:`plain`,icon:(0,q.jsx)(ge,{className:E(`size-4`,T.isFetching&&`animate-spin`)}),"aria-label":e(`common.refresh`),onClick:()=>void T.refetch()}),(0,q.jsx)(k,{variant:`plain`,className:`ml-auto`,icon:(0,q.jsx)(se,{className:`size-4`}),disabled:C.isPending||!D||D.total===0,onClick:async()=>{await S({title:e(`privacy.logs.clearConfirm`),detail:e(`privacy.logs.clearDetail`),confirmLabel:e(`privacy.logs.clear`),destructive:!0})&&C.mutate(void 0,{onSuccess:t=>{d(1),b(e(`privacy.logs.cleared`,{count:c(t.cleared)}),`success`)},onError:e=>b(I(e),`error`)})},children:e(`privacy.logs.clear`)})]}),(0,q.jsx)(`div`,{className:`mb-3`,children:(0,q.jsx)(Fe,{label:e(`requests.filters`),filters:R,onRemove:e=>z(e,``),onClearAll:()=>{l({client:``,category:``,action:``,blocked:``}),d(1)},addFilter:{fields:ne,label:e(`requests.addFilter`),onAdd:e=>{let t=e.id,n=P[t].find(t=>t.label===e.value)?.value;n&&z(t,n)}}})}),T.isLoading&&(0,q.jsx)(M,{lines:4,className:`py-6`}),T.isError&&(0,q.jsx)(te,{tone:`danger`,title:e(`common.error`),children:I(T.error)}),D&&D.items.length===0&&(0,q.jsx)(h,{icon:(0,q.jsx)(ve,{className:`size-6`}),title:e(`privacy.logs.empty`),detail:e(`privacy.logs.empty.detail`)}),D&&D.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:c(D.total)})}),(0,q.jsx)(ie,{caption:e(`privacy.tab.logs`),rows:re,columns:B,rowKey:`id`,emptyMessage:e(`privacy.logs.empty`)})]}),D&&A>1&&(0,q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,q.jsx)(de,{page:u,pageCount:A,onPageChange:d,label:e(`requests.page`,{page:u,pages:A})})}),(0,q.jsx)(he,{id:f,onClose:()=>p(null)})]})}function He(e){return e.blocked?`blocked`:e.redactions>0?`redact`:e.dryRun?`dryRun`:`warn`}function Ue({event:e}){let{t}=g();return e.blocked?(0,q.jsx)(w,{tone:`red`,children:t(`privacy.logs.outcome.blocked`)}):e.redactions>0?(0,q.jsx)(w,{tone:`orange`,children:t(`privacy.logs.outcome.redacted`,{count:e.redactions})}):e.dryRun?(0,q.jsx)(w,{tone:`neutral`,children:t(`privacy.logs.outcome.dryRun`)}):(0,q.jsx)(w,{tone:`neutral`,children:t(`settings.privacy.action.warn`)})}function We({event:e}){let t=Z(),{t:n}=g();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)(Re,{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`},Ge=[0,1,2,3,4,5,6,7,8,9],Ke={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]}}},qe={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}}},Je={...t.spring.smooth,visualDuration:t.duration.considered};function Ye(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 Xe({position:e,digit:n}){let r=U(e,e=>((n-e)%10+15)%10-5),a=U(r,e=>`${e}em`),o=U(r,e=>Math.max(0,1-Math.abs(e))),s=U(r,e=>Math.abs(e)>=1?`hidden`:`visible`),c=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)(i.span,{className:Q.glyph,style:{y:a,opacity:o,filter:c,visibility:s},children:n})}var Ze={initial:{width:0,opacity:0},animate:{width:`auto`,opacity:1},exit:{width:0,opacity:0}};function Qe({digit:e,direction:n,armed:r,delay:a,reduceMotion:o}){let s=l(r?0:e),c=(0,G.useRef)({digit:r?0:e,target:r?0:e,revealed:!r});return(0,G.useEffect)(()=>{let i=c.current;if(r||i.digit===e){r||(i.revealed=!0);return}i.target+=n<0&&i.revealed?-((i.digit-e+10)%10):(e-i.digit+10)%10,i.digit=e,o?s.jump(i.target):D(s,i.target,i.revealed?t.spring.smooth:{...Je,delay:a}),i.revealed=!0},[r,a,e,n,s,o]),(0,q.jsxs)(i.span,{className:Q.column,...Ze,transition:o?{duration:0}:t.spring.morph,children:[(0,q.jsx)(`span`,{className:Q.sizer,children:`0`}),Ge.map(e=>(0,q.jsx)(Xe,{position:s,digit:e},e))]})}function $e({value:e,label:n,prefix:a=``,suffix:o=``,decimals:s=0,animateOnView:c=!1,locale:l=`en-US`}){let d=(0,G.useRef)(null),f=me(d,{once:!0,amount:.6}),p=!!r(),[m,h]=(0,G.useState)(e),[g,_]=(0,G.useState)(1);e!==m&&(h(e),_(e>m?1:-1));let v=Ye(e,s,l),y=`${a}${v.map(e=>`text`in e?e.text:e.digit).join(``)}${o}`,b=c&&!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)(u,{mode:`popLayout`,initial:!1,children:(0,q.jsx)(i.span,{className:Q.labelText,variants:p?qe:Ke,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:[a&&(0,q.jsx)(`span`,{className:Q.symbol,children:a}),(0,q.jsx)(u,{initial:!1,children:v.map(e=>`digit`in e?(0,q.jsx)(Qe,{digit:e.digit,direction:g,armed:b,delay:Math.min(e.order*t.stagger.item,.25),reduceMotion:p},e.key):(0,q.jsx)(i.span,{className:Q.symbol,...Ze,transition:p?{duration:0}:t.spring.morph,children:e.text},e.key))}),o&&(0,q.jsx)(`span`,{className:Q.symbol,children:o})]})]})}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`},et={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]}})},tt={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}}},nt=e=>Number(e.replace(/,/g,``).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN);function rt({text:e,morph:n=!1,block:a=!1}){let o=!!r(),s=(0,G.useRef)(null),c=l(`auto`),[d,f]=(0,G.useState)({text:e,direction:1});return d.text!==e&&f({text:e,direction:nt(e)<nt(d.text)?-1:1}),(0,G.useEffect)(()=>{let e=s.current;if(!e||typeof ResizeObserver>`u`)return;let n=null,r=new ResizeObserver(([r])=>{let i=r.borderBoxSize?.[0]?.inlineSize??e.offsetWidth;i&&n!==null&&n!==e.textContent&&!o?D(c,i,t.spring.morph):c.jump(i||`auto`),n=i?e.textContent:null});return r.observe(e),()=>r.disconnect()},[n,o,c]),(0,q.jsxs)(i.span,{className:a?$.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)(u,{mode:`popLayout`,initial:!1,custom:d.direction,children:(0,q.jsx)(i.span,{className:$.text,custom:d.direction,variants:o?tt:et,initial:`hidden`,animate:`shown`,exit:`gone`,children:e},e)})]})}function it({label:e,value:n,suffix:a,context:o,change:s}){let c=!!r();return(0,q.jsxs)(`article`,{className:$.card,children:[(0,q.jsxs)(`div`,{className:$.top,children:[(0,q.jsx)(`span`,{children:(0,q.jsx)(rt,{text:e,block:!0})}),(0,q.jsx)(u,{initial:!1,children:s&&(0,q.jsx)(i.small,{"data-trend":/^[+]/.test(s)?`up`:/^[-−]/.test(s)?`down`:void 0,initial:{opacity:0,scale:c?1:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:c?1:.96,transition:{duration:t.duration.fast,ease:[...t.ease.standard]}},transition:c?{duration:0}:t.spring.snappy,children:(0,q.jsx)(rt,{text:s,morph:!0})},`change`)})]}),(0,q.jsx)($e,{value:n,suffix:a,animateOnView:!0}),(0,q.jsx)(`p`,{children:(0,q.jsx)(rt,{text:o,block:!0})})]})}var at=[{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}`}],ot=[`off`,`warn`,`block`,`redact`],st=Le;function ct(){let{t:e}=g(),{toast:t}=L(),n=y(),r=f(),i=n.data?.settings,a=e=>{i&&r.mutate({...i,...e},{onError:e=>t(I(e),`error`)})},o=ot.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:st[t])}));return(0,q.jsxs)(j,{title:e(`settings.privacy`),footer:e(`settings.privacy.footer`),children:[n.isLoading&&(0,q.jsx)(M,{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)(C,{label:e(`settings.privacy.enabled`),detail:e(`settings.privacy.enabledHint`),children:(0,q.jsx)(P,{checked:i.enabled,label:e(`settings.privacy.enabled`),onChange:e=>a({enabled:e})})}),(0,q.jsx)(C,{label:e(`settings.privacy.dryRun`),detail:e(`settings.privacy.dryRunHint`),children:(0,q.jsx)(P,{checked:i.dryRun,disabled:!i.enabled,label:e(`settings.privacy.dryRun`),onChange:e=>a({dryRun:e})})}),(0,q.jsx)(C,{label:e(`settings.privacy.restore`),detail:e(`settings.privacy.restoreHint`),children:(0,q.jsx)(P,{checked:i.restoreResponses,disabled:!i.enabled,label:e(`settings.privacy.restore`),onChange:e=>a({restoreResponses:e})})}),(0,q.jsx)(C,{label:e(`settings.privacy.recordSamples`),detail:e(`settings.privacy.recordSamplesHint`),children:(0,q.jsx)(P,{checked:i.recordSamples,disabled:!i.enabled,label:e(`settings.privacy.recordSamples`),onChange:e=>a({recordSamples:e})})}),(0,q.jsx)(C,{label:e(`settings.privacy.recordFullSamples`),detail:e(`settings.privacy.recordFullSamplesHint`),children:(0,q.jsx)(P,{checked:i.recordFullSamples,disabled:!i.enabled||!i.recordSamples,label:e(`settings.privacy.recordFullSamples`),onChange:e=>a({recordFullSamples:e})})}),(0,q.jsx)(C,{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 lt(){let{t:e}=g(),{toast:t}=L(),n=y(),r=f(),i=n.data?.settings,a=Z(),o=e=>{i&&r.mutate({...i,...e},{onError:e=>t(I(e),`error`)})},s=(e,t)=>o({categoryActions:{...i?.categoryActions,[e]:t}}),c=ot.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:st[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)(M,{className:`my-4`})}):i?(0,q.jsxs)(`div`,{className:`mx-auto flex max-w-[720px] flex-col gap-4`,children:[(0,q.jsx)(j,{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)(C,{label:a(t),detail:u(t),children:[n===`off`?(0,q.jsx)(w,{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)(k,{size:`sm`,variant:`plain`,disabled:!i.enabled,onClick:()=>s(t,i.categoryActions[t]??i.defaultAction),children:e(`settings.privacy.enableCategory`)})]},t)})}),(0,q.jsx)(ut,{s:i,onPatch:o})]}):null}function ut({s:e,onPatch:t}){let{t:n}=g(),{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)(j,{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)(C,{label:t.name,detail:t.pattern,children:[(0,q.jsx)(P,{checked:t.enabled,disabled:!e.enabled,label:t.name,onChange:e=>o(t,e)}),(0,q.jsx)(k,{size:`sm`,variant:`plain`,icon:(0,q.jsx)(se,{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)(k,{size:`sm`,icon:(0,q.jsx)(re,{className:`size-3.5`}),disabled:!e.enabled,onClick:()=>a(!0),children:n(`settings.privacy.addRule`)})}),(0,q.jsx)(dt,{open:i,onOpenChange:a,onAdd:n=>t({customRules:[...e.customRules,n]})})]})}function dt({open:e,onOpenChange:t,onAdd:n}){let{t:r}=g(),{toast:i}=L(),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(``);return(0,q.jsx)(ne,{open:e,onOpenChange:t,title:r(`settings.privacy.addRule`),width:480,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(k,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,q.jsx)(k,{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)(S,{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=at.find(t=>t.id===e);t&&(o(r(t.nameKey)),c(t.pattern))},options:[{value:``,label:r(`settings.privacy.ruleTemplateNone`)},...at.map(e=>({value:e.id,label:r(e.nameKey)}))]})}),(0,q.jsx)(_,{label:r(`settings.privacy.ruleName`),value:a,onChange:e=>o(e.target.value),autoFocus:!0}),(0,q.jsx)(S,{label:r(`settings.privacy.rulePattern`),hint:r(`settings.privacy.rulePatternHint`),children:(0,q.jsx)(p,{mono:!0,rows:3,value:s,onChange:e=>c(e.target.value)})})]})})}function ft(){let{t:e}=g(),{toast:t}=L(),n=Z(),r=y(),i=A(),[a,o]=(0,G.useState)(``),s=i.data,c=r.data?.settings.enabled??!1;return(0,q.jsx)(j,{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)(p,{"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)(k,{icon:(0,q.jsx)(oe,{className:`size-3.5`}),disabled:!c||!a.trim(),loading:i.isPending,onClick:()=>i.mutate({text:a},{onError:e=>t(I(e),`error`)}),children:e(`settings.privacy.runTest`)})}),s&&(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:[s.blocked&&(0,q.jsx)(w,{tone:`red`,children:e(`settings.privacy.wouldBlock`)}),s.wouldRedact>0&&(0,q.jsx)(w,{tone:`orange`,children:e(`settings.privacy.wouldRedact`,{count:s.wouldRedact})}),!s.blocked&&s.wouldRedact===0&&(0,q.jsx)(w,{tone:`green`,children:e(`settings.privacy.noHits`)})]}),s.hits.length>0&&(0,q.jsx)(`ul`,{className:`mt-2 space-y-1`,children:s.hits.map(t=>(0,q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(w,{tone:t.action===`block`?`red`:t.action===`redact`?`orange`:`neutral`,children:e(st[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 pt=[`today`,`7d`,`30d`,`all`];function mt(){let{t:e}=g(),t=Z(),[n,r]=(0,G.useState)(`7d`),i=T(n),a=i.data,o=[{key:`category`,label:e(`privacy.stats.col.category`),render:e=>t(String(e))},{key:`requests`,label:e(`privacy.stats.col.requests`),numeric:!0,width:110},{key:`hits`,label:e(`privacy.stats.col.hits`),numeric:!0,width:96},{key:`warnHits`,label:e(`privacy.stats.col.warn`),numeric:!0,width:84},{key:`blockHits`,label:e(`privacy.stats.col.block`),numeric:!0,width:84},{key:`redactHits`,label:e(`privacy.stats.col.redact`),numeric:!0,width:84}],s=(a?.categories??[]).map(e=>({...e}));return(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`section`,{children:[(0,q.jsx)(b,{action:(0,q.jsx)(d,{ariaLabel:e(`overview.range`),value:n,onChange:r,items:pt.map(t=>({value:t,label:e(`range.${t}`)}))}),children:e(`privacy.stats`)}),i.isLoading&&(0,q.jsx)(M,{lines:3,className:`py-4`}),i.isError&&(0,q.jsx)(te,{tone:`danger`,title:e(`common.error`),children:I(i.error)}),a&&(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,q.jsx)(it,{label:e(`privacy.stats.events`),value:a.events,context:e(`range.${n}`)}),(0,q.jsx)(it,{label:e(`privacy.stats.blocked`),value:a.blocked,context:e(`range.${n}`)}),(0,q.jsx)(it,{label:e(`privacy.stats.redactions`),value:a.redactions,context:e(`range.${n}`)}),(0,q.jsx)(it,{label:e(`privacy.stats.dryRun`),value:a.dryRun,context:e(`range.${n}`)})]})]}),(0,q.jsxs)(`section`,{children:[(0,q.jsx)(b,{children:e(`privacy.stats.byCategory`)}),a&&a.categories.length===0&&(0,q.jsx)(`div`,{className:`card`,children:(0,q.jsx)(ht,{})}),a&&a.categories.length>0&&(0,q.jsx)(ie,{caption:e(`privacy.stats.byCategory`),rows:s,columns:o,rowKey:`category`,defaultSort:{key:`hits`,direction:`desc`}})]}),(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-[720px]`,children:(0,q.jsx)(ct,{})})]})}function ht(){let{t:e}=g();return(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-center`,children:[(0,q.jsx)(oe,{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 gt=[`overview`,`logs`,`rules`,`tester`];function _t(){let{t:e}=g(),{tab:t}=fe(),n=z(),r=gt.includes(t)?t:`overview`;return(0,q.jsx)(pe,{title:e(`nav.privacy`),subtitle:e(`settings.privacy.footer`),children:(0,q.jsxs)(B,{value:r,onValueChange:e=>n(`/privacy/${e}`,{replace:!0}),children:[(0,q.jsx)(H,{"aria-label":e(`nav.privacy`),children:gt.map(t=>(0,q.jsx)(ae,{value:t,children:e(`privacy.tab.${t}`)},t))}),(0,q.jsx)(W,{value:`overview`,className:`pt-5`,children:(0,q.jsx)(mt,{})}),(0,q.jsx)(W,{value:`logs`,className:`pt-4`,children:(0,q.jsx)(Ve,{})}),(0,q.jsx)(W,{value:`rules`,className:`pt-5`,children:(0,q.jsx)(lt,{})}),(0,q.jsx)(W,{value:`tester`,className:`pt-5 [&>div]:mx-auto [&>div]:max-w-[680px]`,children:(0,q.jsx)(ft,{})})]})})}export{_t as PrivacyPage};
@@ -0,0 +1,3 @@
1
+ import{$n as e,An as t,At as n,Ba as r,Bn as i,Cn as a,Cr as o,Dt as s,Et as c,Gr as l,H as u,Hr as d,In as f,Jn as p,Kn as m,Kr as h,Lr as g,Mi as _,Ot as v,Pt as y,Q as b,Qt as ee,Ra as te,Rn as ne,Rt as re,Sn as ie,Ua as x,Ur as ae,V as S,Wn as oe,Xn as se,Xr as C,Y as ce,Zt as le,_ as ue,_n as de,_r as fe,a as w,ar as pe,b as me,bi as he,c as ge,cn as _e,cr as ve,ct as T,d as E,dt as ye,f as D,gt as be,h as xe,hn as Se,ht as Ce,i as we,ir as Te,it as Ee,jn as De,jt as Oe,l as O,ln as ke,m as k,mr as Ae,n as A,nt as je,or as j,ot as M,p as N,pr as Me,qn as P,r as F,rt as Ne,t as I,u as L,un as Pe,v as R,vi as Fe,vn as Ie,wi as Le,wn as Re,xt as z,y as B,yi as ze,za as Be,zn as Ve}from"./alert-Clz2DftU.js";import{a as V,gt as He,i as H,n as Ue,o as U,r as W}from"./overlays-UV1fYmtB.js";import{a as G,c as K,i as q,l as We,n as Ge,o as Ke,s as qe,t as Je}from"./ProvidersPage-BiX8gU3n.js";import{t as Ye}from"./arrow-down-D4v2aNc0.js";import{t as Xe}from"./arrow-left-B41OJQ5k.js";import{t as Ze}from"./cloud-download-BZA23qWN.js";import{t as Qe}from"./download-1kPyvAIz.js";import{t as $e}from"./ellipsis-Dzh8eeEb.js";import{t as et}from"./external-link-CP_HY9s9.js";import{n as tt}from"./radio-cards-B0VL-JIL.js";import{t as nt}from"./log-out-CLSeCkdA.js";import{t as rt}from"./power-CmBUImgB.js";import{t as it}from"./rotate-ccw-ClcBYxmg.js";import{$ as J,B as Y,C as at,E as ot,H as st,J as ct,P as X,T as Z,_ as lt,a as ut,et as dt,h as ft,o as pt,q as mt,s as ht,w as gt}from"./index-LdSd2gU7.js";import{t as _t}from"./checkbox-B4uUeJZd.js";import{t as vt}from"./confirm-morph-BHc1Rk5D.js";var yt={name:`arrow-left-right`,size:24,node:[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]};yt.node;var bt=z(yt),xt={name:`arrow-right-left`,size:24,node:[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]};xt.node;var St=z(xt),Ct={name:`gift`,size:24,node:[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8`,key:`1sqzm4`}],[`path`,{d:`M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5`,key:`kc0143`}],[`rect`,{x:`3`,y:`7`,width:`18`,height:`4`,rx:`1`,key:`1hberx`}]]};Ct.node;var wt=z(Ct),Tt={name:`list-plus`,size:24,node:[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`M18 9v6`,key:`1twb98`}],[`path`,{d:`M21 12h-6`,key:`bt1uis`}]]};Tt.node;var Et=z(Tt),Dt={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};Dt.node;var Ot=z(Dt),kt={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};kt.node;var At=z(kt),jt={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};jt.node;var Mt=z(jt),Nt={name:`ticket`,size:24,node:[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]};Nt.node;var Pt=z(Nt),Ft={name:`upload`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]};Ft.node;var It=z(Ft),Q=x(r(),1),$=Be();function Lt({usage:e,compact:t=!1}){let{t:n}=T(),r=[{label:n(`providers.usage.requests`),values:[e?.today.requests,e?.total.requests],format:(e,n=t)=>ce(e,n)},{label:n(`providers.usage.tokens`),values:[e?.today.tokens,e?.total.tokens],format:(e,n=t)=>ce(e,n)},{label:n(`providers.usage.cost`),values:[e?.today.costNanoUsd,e?.total.costNanoUsd],format:(e,n=t)=>b(Ee(e),{compact:n})}];return(0,$.jsxs)(`table`,{className:M(`w-full table-fixed text-right tabular-nums`,t?`text-[11px]`:`text-[12px]`),"aria-label":n(`providers.usage.title`),children:[(0,$.jsx)(`thead`,{className:`text-[var(--text-muted)]`,children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{scope:`col`,className:`w-[34%] pb-1 text-left font-normal`,children:(0,$.jsx)(`span`,{className:`sr-only`,children:n(`providers.usage.title`)})}),(0,$.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:n(`providers.usage.today`)}),(0,$.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:n(`providers.usage.total`)})]})}),(0,$.jsx)(`tbody`,{children:r.map(e=>(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{scope:`row`,className:`py-0.5 text-left font-normal text-[var(--text-secondary)]`,children:e.label}),e.values.map((t,n)=>(0,$.jsx)(`td`,{className:`truncate py-0.5 pl-1 font-mono`,title:t==null?void 0:e.format(t,!1),children:t==null?`—`:e.format(t)},n))]},e.label))})]})}function Rt({timeZone:e}){let{t}=T();return(0,$.jsxs)(`p`,{className:`text-[11px] leading-relaxed text-[var(--text-muted)]`,children:[t(`providers.usage.hint`),e&&(0,$.jsxs)($.Fragment,{children:[` `,t(`providers.usage.dayHint`,{zone:e})]})]})}var zt={imported:`providers.subscription.importBatchStatus.imported`,updated:`providers.subscription.importBatchStatus.updated`,duplicate:`providers.subscription.importBatchStatus.duplicate`,invalid_format:`providers.subscription.importBatchStatus.invalid_format`,failed:`providers.subscription.importBatchStatus.failed`,ready:`providers.subscription.importBatchStatus.ready`},Bt={imported:`green`,updated:`accent`,ready:`accent`,duplicate:`neutral`,invalid_format:`orange`,failed:`red`},Vt={batch:`providers.accounts.import.batchTitle`,token:`providers.accounts.import.tokenTitle`,apiKey:`providers.accounts.import.apiKeyTitle`};function Ht(e){return e.split(/[,\s]+/).flatMap(e=>{let t=e.replace(/^["']+|["']+$/g,``);return t.startsWith(`tid=`)||t.startsWith(`exp=`)?[t]:t.split(`;`)}).filter(e=>e.replace(/^["']+|["']+$/g,``).length>0).length}function Ut(e){let t=e.trim();if(t.length===0)return 0;if(t.startsWith(`{`)||t.startsWith(`[`))try{let e=JSON.parse(t);if(Array.isArray(e))return e.filter(e=>typeof e==`object`&&!!e||typeof e==`string`&&e.trim().length>0).length;if(typeof e==`object`&&e)return 1}catch{}let n=0;for(let t of e.split(`
2
+ `)){let e=t.trim();e.length===0||e.startsWith(`#`)||(n+=e.startsWith(`{`)?1:Ht(e))}return n}function Wt({providerId:e,info:t,mode:n,providerProxy:r,onClose:i}){let{t:a}=T(),{toast:o}=U(),s=ie(e),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(null),m=(0,Q.useMemo)(()=>Ut(c),[c]);if((0,Q.useEffect)(()=>{n!==null&&(l(``),p(null))},[n]),n===null)return(0,$.jsx)(H,{open:!1,onOpenChange:i,title:``});let h=n===`apiKey`,g=h?t.formats.filter(e=>e.endsWith(`-api-key`)):t.formats,_=!h&&t.formats.some(e=>e.includes(`refresh-token`)||e.endsWith(`-json`)),v=a(h?`providers.accounts.import.apiKeyLabel`:`providers.accounts.import.label`),y=e=>s.mutate({text:c,asApiKey:h||void 0,dryRun:e||void 0,httpProxy:u.trim()||void 0},{onSuccess:t=>{p({...t,dryRun:e}),!e&&(o(a(`providers.accounts.import.summary`,{ok:t.imported,dup:t.duplicates,fail:t.failed}),t.failed>0?`info`:`success`),!(t.failed>0)&&(n===`batch`?l(``):i()))},onError:e=>o(V(e),`error`)});return(0,$.jsx)(H,{open:!0,onOpenChange:e=>!e&&i(),title:a(Vt[n]),description:a(`providers.accounts.import.desc`),width:560,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[g.length>0&&(0,$.jsx)(`p`,{className:`text-[11.5px] text-[var(--text-secondary)]`,children:a(`providers.accounts.import.formats`,{formats:g.map(e=>a(`providers.accounts.format.${e}`)).join(` · `)})}),(0,$.jsx)(me,{mono:!0,rows:n===`batch`?8:3,value:c,onChange:e=>l(e.target.value),"aria-label":v,placeholder:v,spellCheck:!1}),(0,$.jsx)(E,{mono:!0,label:a(`providers.accounts.import.proxy`),placeholder:r||a(`providers.accounts.proxyFallbackSystem`),value:u,onChange:e=>d(e.target.value)}),_&&(0,$.jsx)(I,{tone:`info`,title:a(`providers.accounts.import.rotateWarning`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:a(`providers.accounts.import.count`,{n:m})}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[n===`batch`&&(0,$.jsx)(F,{disabled:m===0,loading:s.isPending&&s.variables?.dryRun===!0,onClick:()=>y(!0),children:a(`providers.accounts.import.preview`)}),(0,$.jsx)(F,{variant:`primary`,disabled:m===0||m>t.maxBatch,loading:s.isPending&&!s.variables?.dryRun,onClick:()=>y(!1),children:a(`providers.accounts.import.run`)})]})]}),f&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`div`,{className:`text-[12px] font-medium`,children:a(f.dryRun?`providers.accounts.import.previewSummary`:`providers.accounts.import.summary`,{ok:f.imported,dup:f.duplicates,fail:f.failed})}),(0,$.jsx)(`ul`,{className:`card max-h-72 divide-y divide-[var(--border)] overflow-auto`,children:f.items.map(e=>(0,$.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-1.5 text-[12px]`,children:[(0,$.jsx)(`span`,{className:`w-6 shrink-0 text-[var(--text-muted)]`,children:e.index}),(0,$.jsx)(`span`,{className:`selectable w-28 shrink-0 truncate font-mono`,children:e.source}),(0,$.jsx)(A,{tone:Bt[e.status],children:a(zt[e.status])}),e.kind&&(0,$.jsx)(`span`,{className:`shrink-0 text-[11px] text-[var(--text-muted)]`,children:a(`providers.accounts.credential.${e.kind}`)}),(0,$.jsx)(`span`,{className:`selectable min-w-0 flex-1 break-words text-[var(--text-secondary)]`,children:e.account?.displayName&&(e.status===`imported`||e.status===`updated`)?`${e.account.displayName}${e.message?` · ${e.message}`:``}`:e.message??``})]},e.index))})]})]})})}function Gt(e,t=Date.now()){return e.enabled?e.status===`active`?e.cooldownUntilUtc&&new Date(e.cooldownUntilUtc).getTime()>t?`cooling`:`usable`:`dead`:`disabled`}var Kt={usable:`var(--success)`,cooling:`var(--warning)`,dead:`var(--danger)`,disabled:`var(--text-muted)`},qt={active:`providers.subscription.status.active`,expired:`providers.subscription.status.expired`,revoked:`providers.subscription.status.revoked`};function Jt(e,t){let n=(e??``).toLowerCase(),r=t?`110,115,135`:/max|ultra/.test(n)?`47,124,246`:/pro|plus|premium/.test(n)?`52,195,143`:/team|business|enterprise|allegro|vivace/.test(n)?`130,100,230`:`110,115,135`;return`linear-gradient(135deg, rgba(${r},.34), rgba(${r},.08))`}function Yt({account:e,index:t,actions:n,selected:r,selecting:i,onToggleSelect:a,onMove:o,quotaPending:s,usage:c}){let{t:l,locale:d}=T(),f=Gt(e),p=e.displayName||e.accountEmail||e.keyMasked||e.id,m=e.kind===`api_key`,h=e.plan?.trim(),g=f===`cooling`?{text:l(`providers.subscription.cooldown`,{when:u(e.cooldownUntilUtc,d)}),tone:`var(--warning)`}:f===`dead`?{text:e.lastError||l(qt[e.status]),tone:`var(--danger)`}:m?{text:e.keyMasked??l(`providers.accounts.neverExpires`),tone:void 0}:e.expiresAtUtc?{text:l(`providers.accounts.expiresAt`,{when:u(e.expiresAtUtc,d)}),tone:void 0}:null,_=[{id:`activate`,label:l(`providers.subscription.activate`),icon:(0,$.jsx)(St,{className:`size-3.5`}),disabled:e.isCurrent||f===`dead`,onSelect:()=>n.activate(e)},{id:`toggle`,label:l(e.enabled?`providers.subscription.disable`:`providers.subscription.enable`),icon:(0,$.jsx)(rt,{className:`size-3.5`}),onSelect:()=>n.toggleEnabled(e)},...o?[{id:`up`,label:l(`providers.subscription.moveUp`),icon:(0,$.jsx)(mt,{className:`size-3.5`}),disabled:!o.up,onSelect:()=>o.up?.()},{id:`down`,label:l(`providers.subscription.moveDown`),icon:(0,$.jsx)(Ye,{className:`size-3.5`}),disabled:!o.down,onSelect:()=>o.down?.()}]:[],{id:`quota`,separatorBefore:!0,label:l(`providers.subscription.quotaRefresh`),icon:(0,$.jsx)(We,{className:`size-3.5`}),disabled:f===`dead`,onSelect:()=>n.refreshQuota(e)},...m?[]:[{id:`refresh`,label:l(`providers.subscription.refreshToken`),icon:(0,$.jsx)(it,{className:`size-3.5`}),disabled:e.status===`revoked`,onSelect:()=>n.refreshToken(e)},{id:`relogin`,label:l(`providers.subscription.relogin`),disabled:e.status===`active`,onSelect:()=>n.relogin(e)}],{id:`remove`,label:l(`providers.subscription.logout`),icon:(0,$.jsx)(X,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>n.remove(e)}],v=l(f===`disabled`?`providers.subscription.disabled`:qt[e.status]),y=l(m?`providers.accounts.kind.api_key`:`providers.accounts.kind.oauth`),b=e.quota?.session?.usedPercent!=null||e.quota?.weekly?.usedPercent!=null||e.quota?.credits?.usedPercent!=null;return(0,$.jsxs)(`div`,{"data-testid":`account-card`,className:M(`group card relative flex min-h-[292px] min-w-0 cursor-pointer flex-col overflow-hidden transition-colors hover:bg-[var(--fill)]`,e.isCurrent&&`ring-1 ring-[var(--accent)]`,r&&`bg-[var(--accent-subtle)]`,f===`disabled`&&`opacity-55`),onClick:()=>i?a(e.id):n.open(e),children:[(0,$.jsxs)(`div`,{className:`relative shrink-0 px-3 pb-3 pt-2.5`,style:{background:Jt(h,m)},children:[(f===`cooling`||f===`dead`)&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-y-0 left-0 w-[3px]`,style:{background:Kt[f]}}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:M(`flex size-5 items-center justify-center`,!i&&!r&&`hidden group-hover:flex`),onClick:e=>e.stopPropagation(),children:(0,$.jsx)(_t,{checked:r,onCheckedChange:()=>a(e.id),"aria-label":l(`providers.accounts.select`,{name:p})})}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(`span`,{role:`img`,"aria-label":v,className:`size-1.5 shrink-0 rounded-full`,style:{background:Kt[f]}}),(0,$.jsx)(`span`,{"aria-hidden":!0,children:v})]}),e.httpProxy&&(0,$.jsx)(`span`,{title:`${l(`providers.accounts.proxyBadge`)}: ${e.httpProxy}`,className:`shrink-0 text-[var(--text-muted)]`,children:(0,$.jsx)(Ce,{className:`size-3.5`,"aria-label":l(`providers.accounts.proxyBadge`)})}),(0,$.jsx)(`span`,{className:`-mr-1.5 ml-auto shrink-0`,onClick:e=>e.stopPropagation(),children:(0,$.jsx)(Ue,{iconOnly:!0,label:l(`common.more`),icon:(0,$.jsx)($e,{className:`size-4`}),items:_})})]}),(0,$.jsx)(`div`,{className:`mt-1.5 truncate text-[17px] font-bold tracking-[.01em]`,title:h||y,children:h||y})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pb-3 pt-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-[13px] font-medium outline-none focus-visible:underline`,title:p,onClick:t=>{t.stopPropagation(),i?a(e.id):n.open(e)},children:p}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 items-center gap-1 whitespace-nowrap text-[11px] text-[var(--text-muted)]`,children:[e.isCurrent&&(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[var(--success)]`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`●`}),(0,$.jsx)(`span`,{children:l(`providers.subscription.current`)})]}),e.isCurrent&&(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0`,children:y}),e.source&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{className:`truncate`,children:l(`providers.accounts.source.${e.source}`)})]}),(0,$.jsx)(`span`,{className:`ml-auto shrink-0 pl-1 opacity-0 group-hover:opacity-100`,children:l(`providers.accounts.order`,{n:t+1})})]}),(0,$.jsx)(`div`,{className:`mt-1.5 min-h-[28px]`,children:g&&(f===`cooling`||f===`dead`||!b)&&(0,$.jsx)(`div`,{className:`line-clamp-2 text-[11px] leading-snug`,style:{color:g.tone??`var(--text-muted)`},title:g.text,children:g.text})}),(0,$.jsx)(`div`,{className:`mt-3 shrink-0 border-t border-[var(--border-subtle)] pt-2`,children:(0,$.jsx)(Lt,{usage:c,compact:!0})}),f===`dead`?(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:l(`providers.accounts.signedOut`)}),!m&&(0,$.jsx)(F,{size:`sm`,className:`ml-auto`,onClick:t=>{t.stopPropagation(),n.relogin(e)},children:l(`providers.subscription.relogin`)})]}):(0,$.jsx)(Zt,{quota:e.quota??null,pending:s})]})]})}var Xt=10;function Zt({quota:e,pending:t}){let{t:n,locale:r}=T(),i=[];return e?.session?.usedPercent!=null&&i.push({key:`session`,label:e.session.windowMinutes?`${Math.round(e.session.windowMinutes/60)}h`:n(`providers.accounts.quotaShortSession`),percent:e.session.usedPercent,reset:e.session.resetsAtUtc}),e?.weekly?.usedPercent!=null&&i.push({key:`weekly`,label:n(`providers.accounts.quotaShortWeekly`),percent:e.weekly.usedPercent,reset:e.weekly.resetsAtUtc}),i.length<2&&e?.credits?.usedPercent!=null&&i.push({key:`credits`,label:n(e.entitlement==null?`providers.accounts.quotaShortCredits`:`providers.accounts.quotaShortPremium`),percent:e.credits.usedPercent,reset:e.credits.resetsAtUtc}),i.length===0?null:(0,$.jsx)(`div`,{className:M(`mt-auto flex flex-col gap-2 pt-2`,t&&`opacity-60`),children:i.slice(0,2).map(e=>{let t=Math.max(0,Math.min(100,Math.round(e.percent))),i=t>=90?`var(--danger)`:t>=70?`var(--warning)`:`var(--accent)`,a=Math.round(t/100*Xt),o=e.reset?n(`providers.subscription.quotaResets`,{when:u(e.reset,r)}):void 0;return(0,$.jsxs)(`div`,{className:`min-w-0`,title:o,children:[(0,$.jsxs)(`div`,{className:`flex justify-between text-[11px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(`span`,{children:e.label}),(0,$.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[t,`%`]})]}),(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":e.label,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,className:`mt-0.5 flex gap-[3px]`,children:Array.from({length:Xt},(e,t)=>(0,$.jsx)(`i`,{className:`h-[5px] flex-1 rounded-[2px] bg-[var(--surface-muted)]`,style:t<a?{background:i}:void 0},t))})]},e.key)})})}function Qt({quota:e,className:t}){let{t:n,locale:r}=T(),i=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:n(`providers.subscription.quotaResets`,{when:t.toLocaleString(r)})},a=[];e.session?.usedPercent!=null&&a.push({key:`session`,label:n(`providers.subscription.quotaWindowSession`),window:e.session}),e.weekly?.usedPercent!=null&&a.push({key:`weekly`,label:n(`providers.subscription.quotaWindowWeekly`),window:e.weekly}),e.credits?.usedPercent!=null&&a.push({key:`credits`,label:e.entitlement==null?n(`providers.subscription.quotaWindowCredits`):n(`providers.subscription.quotaWindowPremium`),window:{usedPercent:e.credits.usedPercent,resetsAtUtc:e.credits.resetsAtUtc??null}});let o=e.credits?.prepaidBalance==null?null:n(`providers.subscription.quotaBalance`,{balance:e.credits.prepaidBalance}),s=e.entitlement!=null&&e.entitlement>=0?[n(`providers.subscription.quotaPremiumCount`,{used:Math.max(0,(e.entitlement??0)-(e.remaining??0)),total:e.entitlement}),e.overageUsed?n(`providers.subscription.quotaOverage`,{count:e.overageUsed}):null,e.overagePermitted===!1?n(`providers.subscription.quotaOverageOff`):null].filter(Boolean).join(` · `):null,c=e.planLabel??(e.fetchedAtUtc?n(`providers.subscription.quotaFetchedAt`,{when:new Date(e.fetchedAtUtc).toLocaleString(r)}):null);return(0,$.jsx)(`div`,{className:M(`px-4 py-1`,t),children:(0,$.jsxs)(`div`,{className:`card flex flex-col gap-3 p-3`,children:[(c||o)&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-[11px] text-[var(--text-secondary)]`,children:[c&&(0,$.jsx)(`span`,{children:c}),o&&(0,$.jsx)(`span`,{children:o})]}),a.length===0?(0,$.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`providers.subscription.quotaNoWindows`)}):a.map(e=>(0,$.jsx)($t,{label:e.label,window:e.window,reset:i(e.window.resetsAtUtc)},e.key)),s&&(0,$.jsx)(`div`,{className:`text-[10.5px] text-[var(--text-muted)]`,children:s})]})})}function $t({label:e,window:t,reset:n}){let r=Math.max(0,Math.min(100,Math.round(t.usedPercent??0))),[i,a]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches){a(r);return}let e=requestAnimationFrame(()=>a(r));return()=>cancelAnimationFrame(e)},[r]);let o=r>=90?`var(--danger)`:r>=70?`var(--warning)`:`var(--accent)`,s=t.windowMinutes?Math.round(t.windowMinutes/60):null;return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[11.5px]`,children:[(0,$.jsxs)(`span`,{className:`text-[var(--text-secondary)]`,children:[e,s!=null&&(0,$.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[` · `,s,`h`]})]}),(0,$.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[r,`%`]})]}),(0,$.jsx)(`div`,{role:`progressbar`,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-500 ease-out`,style:{width:`${i}%`,background:o}})}),n&&(0,$.jsx)(`div`,{className:`mt-1 text-[10.5px] text-[var(--text-muted)]`,children:n})]})}var en={available:`green`,redeemed:`neutral`,expired:`orange`};function tn({account:e,providerId:t}){let{t:n}=T(),{toast:r,confirm:i}=U(),a=o(e.id,e.status===`active`),s=ee(t),c=a.data?.credits??[],l=a.data?.available_count??c.filter(e=>e.status===`available`).length,u=async t=>{await i({title:n(`providers.subscription.credits.consumeConfirm`,{title:t.title??t.reset_type??``}),detail:n(`providers.subscription.credits.consumeDetail`),confirmLabel:n(`providers.subscription.credits.consume`),destructive:!0})&&s.mutate({accountId:e.id,creditId:t.id},{onSuccess:()=>r(n(`providers.subscription.credits.consumed`),`success`),onError:e=>r(e instanceof _&&e.status===409?V(e):`${n(`providers.subscription.credits.consumeFailed`)}:${V(e)}`,`error`)})};return(0,$.jsxs)(L,{title:n(`providers.subscription.credits.title`),footer:n(`providers.subscription.credits.footer`),children:[a.isLoading&&(0,$.jsx)(R,{className:`my-4`}),a.isError&&(0,$.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--text-secondary)]`,children:n(`providers.subscription.credits.unavailable`)}),a.data&&c.length===0&&(0,$.jsx)(`div`,{className:`px-4 py-5 text-center text-[12px] text-[var(--text-secondary)]`,children:n(`providers.subscription.credits.none`)}),c.map(e=>{let t=e.status!==`available`;return(0,$.jsxs)(k,{className:M(t&&`opacity-55`),label:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(wt,{className:`size-3.5 text-[var(--text-secondary)]`}),e.title??e.reset_type??e.id]}),detail:[e.description,e.expires_at?n(`providers.subscription.credits.expires`,{when:new Date(e.expires_at).toLocaleString()}):null,e.redeemed_at?n(`providers.subscription.credits.redeemedAt`,{when:new Date(e.redeemed_at).toLocaleString()}):null,e.is_supported_by_plan===!1?n(`providers.subscription.credits.notInPlan`):null].filter(Boolean).join(` · `),children:[(0,$.jsx)(A,{tone:en[e.status]??`neutral`,children:n(`providers.subscription.credits.status.${e.status}`)}),(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(Pt,{className:`size-3.5`}),disabled:t,loading:s.isPending&&s.variables?.creditId===e.id,onClick:()=>void u(e),children:n(`providers.subscription.credits.consume`)})]},e.id)}),a.data&&c.length>0&&(0,$.jsx)(`div`,{className:`px-4 py-2 text-[11px] text-[var(--text-muted)]`,children:n(`providers.subscription.credits.availableCount`,{count:l})})]})}var nn={active:`providers.subscription.status.active`,expired:`providers.subscription.status.expired`,revoked:`providers.subscription.status.revoked`};function rn({provider:e,account:t,index:n,actions:r,onClose:i,usage:a,usageTimeZone:o}){let{t:s,locale:c}=T(),{toast:l}=U(),d=ze(e.id),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``);if((0,Q.useEffect)(()=>{p(t?.displayName??``),h(t?.httpProxy??``)},[t?.id,t?.displayName,t?.httpProxy]),!t)return(0,$.jsx)(H,{open:!1,onOpenChange:i,title:``});let g=Gt(t),_=t.kind===`api_key`,v=e.templateId===`openai-subscription`,y=e.httpProxy||s(`providers.accounts.proxyFallbackSystem`),b=e=>e?u(e,c):`—`,ee=(e,n)=>d.mutate({id:t.id,...e},{onSuccess:()=>l(s(n),`success`),onError:e=>l(V(e),`error`)});return(0,$.jsx)(H,{open:!0,onOpenChange:e=>!e&&i(),title:t.displayName||t.keyMasked||t.id,description:[t.plan,s(_?`providers.accounts.kind.api_key`:`providers.accounts.kind.oauth`)].filter(Boolean).join(` · `),width:520,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,$.jsx)(F,{size:`sm`,icon:(0,$.jsx)(St,{className:`size-3.5`}),disabled:t.isCurrent||g===`dead`,onClick:()=>r.activate(t),children:s(`providers.subscription.activate`)}),(0,$.jsx)(F,{size:`sm`,icon:(0,$.jsx)(We,{className:`size-3.5`}),disabled:g===`dead`,onClick:()=>r.refreshQuota(t),children:s(`providers.subscription.quotaRefresh`)}),!_&&(0,$.jsx)(F,{size:`sm`,icon:(0,$.jsx)(it,{className:`size-3.5`}),disabled:t.status===`revoked`,onClick:()=>r.refreshToken(t),children:s(`providers.subscription.refreshToken`)}),!_&&t.status!==`active`&&(0,$.jsx)(F,{size:`sm`,variant:`primary`,onClick:()=>r.relogin(t),children:s(`providers.subscription.relogin`)}),(0,$.jsx)(F,{size:`sm`,variant:`plain`,className:`ml-auto text-[var(--danger)]`,icon:(0,$.jsx)(X,{className:`size-3.5`}),onClick:()=>r.remove(t),children:s(`providers.subscription.logout`)})]}),g===`dead`&&t.lastError&&(0,$.jsx)(I,{tone:`danger`,title:t.lastError}),(0,$.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h4`,{className:`text-[11px] font-medium text-[var(--text-secondary)]`,children:s(`providers.usage.title`)}),(0,$.jsx)(`div`,{className:`card px-3 py-2`,children:(0,$.jsx)(Lt,{usage:a})}),(0,$.jsx)(Rt,{timeZone:o})]}),(0,$.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h4`,{className:`text-[11px] font-medium text-[var(--text-secondary)]`,children:s(`providers.accounts.detail.identity`)}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,$.jsx)(E,{className:`flex-1`,label:s(`providers.accounts.detail.name`),value:f,onChange:e=>p(e.target.value)}),(0,$.jsx)(F,{disabled:f.trim().length===0||f.trim()===t.displayName,loading:d.isPending&&d.variables?.displayName!==void 0,onClick:()=>ee({displayName:f.trim()},`providers.accounts.renamed`),children:s(`common.save`)})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,$.jsx)(E,{className:`flex-1`,mono:!0,label:s(`providers.accounts.detail.proxy`),placeholder:y,value:m,onChange:e=>h(e.target.value)}),(0,$.jsx)(F,{disabled:m.trim()===(t.httpProxy??``),loading:d.isPending&&d.variables?.httpProxy!==void 0,onClick:()=>ee({httpProxy:m.trim()},`providers.accounts.proxySaved`),children:s(`common.save`)})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:s(`providers.accounts.detail.proxyHint`,{fallback:y})})]}),t.quota&&(0,$.jsxs)(`section`,{className:`-mx-4 flex flex-col gap-1`,children:[(0,$.jsx)(`h4`,{className:`px-4 text-[11px] font-medium text-[var(--text-secondary)]`,children:s(`providers.accounts.detail.quota`)}),(0,$.jsx)(Qt,{quota:t.quota})]}),v&&g!==`dead`&&(0,$.jsx)(`div`,{className:`-mx-4`,children:(0,$.jsx)(tn,{account:t,providerId:e.id})}),(0,$.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`h4`,{className:`text-[11px] font-medium text-[var(--text-secondary)]`,children:s(`providers.accounts.detail.credentials`)}),(0,$.jsxs)(`div`,{className:`card divide-y divide-[var(--border)] px-3`,children:[(0,$.jsx)(D,{label:s(`providers.accounts.detail.status`),children:(0,$.jsx)(A,{tone:g===`usable`?`green`:g===`cooling`?`orange`:g===`dead`?`red`:`neutral`,children:s(g===`disabled`?`providers.subscription.disabled`:nn[t.status])})}),t.source&&(0,$.jsx)(D,{label:s(`providers.accounts.detail.source`),children:s(`providers.accounts.source.${t.source}`)}),_?(0,$.jsx)(D,{label:s(`providers.accounts.detail.key`),mono:!0,children:t.keyMasked??`••••`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{label:s(`providers.accounts.detail.expires`),children:b(t.expiresAtUtc)}),(0,$.jsx)(D,{label:s(`providers.accounts.detail.lastRefresh`),children:b(t.lastRefreshAtUtc)})]}),g===`cooling`&&(0,$.jsx)(D,{label:s(`providers.accounts.filter.cooling`),children:b(t.cooldownUntilUtc)}),(0,$.jsx)(D,{label:s(`providers.accounts.detail.order`),children:s(`providers.accounts.order`,{n:n+1})}),(0,$.jsx)(D,{label:s(`providers.accounts.detail.created`),children:b(t.createdAt)}),t.lastError&&g!==`dead`&&(0,$.jsx)(D,{label:s(`providers.accounts.detail.lastError`),children:t.lastError})]})]})]})})}function an({provider:e}){let{t}=T(),{toast:n}=U(),r=e.authScheme===`oauth-subscription`,i=h(e.id,r),a=Le(e.id);if(!r||!i.data)return null;let o=i.data,s=e=>a.mutate(e,{onError:e=>n(V(e),`error`)}),c=o.claudeSubscription||o.clientPolicy===`claude-code-only`;return!c&&!o.claudeSubscription?null:(0,$.jsxs)(L,{title:t(`providers.subscription.policy.title`),footer:t(`providers.subscription.policy.footer`),children:[c&&(0,$.jsx)(k,{label:t(`providers.subscription.policy.claudeCodeOnly`),detail:t(`providers.subscription.policy.claudeCodeOnlyDetail`),children:(0,$.jsx)(B,{label:t(`providers.subscription.policy.claudeCodeOnly`),checked:o.clientPolicy===`claude-code-only`,disabled:a.isPending,onChange:e=>s({clientPolicy:e?`claude-code-only`:`any`})})}),o.claudeSubscription&&(0,$.jsx)(k,{label:t(`providers.subscription.policy.mimic`),detail:t(`providers.subscription.policy.mimicDetail`),children:(0,$.jsx)(B,{label:t(`providers.subscription.policy.mimic`),checked:o.mimicClaudeCode,disabled:a.isPending,onChange:e=>s({mimicClaudeCode:e})})}),c&&o.clientPolicy===`any`&&(0,$.jsx)(`div`,{className:`px-4 py-3`,children:o.mimicClaudeCode?(0,$.jsx)(I,{tone:`warning`,title:t(`providers.subscription.policy.mimicWarning`)}):(0,$.jsx)(I,{tone:`warning`,title:t(`providers.subscription.policy.anyWarning`)})})]})}var on=[{value:`all`,label:`providers.accounts.filter.all`},{value:`usable`,label:`providers.accounts.filter.usable`},{value:`cooling`,label:`providers.accounts.filter.cooling`},{value:`dead`,label:`providers.accounts.filter.dead`},{value:`disabled`,label:`providers.accounts.filter.disabled`}],sn=3e5;function cn({provider:e}){let{t:r}=T(),{toast:i,confirm:o}=U(),s=te(),l=e.authScheme===`oauth-subscription`,u=pe(e.id,l),d=ve(e.id,l),f=h(e.id,l),p=Le(e.id),m=n(e.id,l),g=ae(e.id),v=se(e.id),y=le(e.id),b=Ie(e.id),ee=Me(e.id),ne=ke(e.id),re=de(e.id),ie=Oe(e.id),x=ze(e.id),S=fe(e.id),oe=e.templateId===`openai-subscription`,C=t(l&&oe),ce=a(e.id),ue=e.templateId===`github-copilot-subscription`,w=De(l&&ue),me=Re(e.id),[he,ge]=(0,Q.useState)(`all`),[_e,ye]=(0,Q.useState)(``),[D,be]=(0,Q.useState)(new Set),[Se,Ce]=(0,Q.useState)(null),[we,Te]=(0,Q.useState)(null),[Ee,O]=(0,Q.useState)(!1),[k,Ae]=(0,Q.useState)(``),[A,je]=(0,Q.useState)(!1),[j,N]=(0,Q.useState)(!1),[P,Ne]=(0,Q.useState)(null),[L,Pe]=(0,Q.useState)(null),[Fe,z]=(0,Q.useState)(!1),[B,Be]=(0,Q.useState)(``),Ve=(0,Q.useRef)(new Set),W=(0,Q.useRef)(new Set),G=(0,Q.useMemo)(()=>u.data??[],[u.data]);if((0,Q.useEffect)(()=>{if(l)for(let e of G){if(e.status!==`active`||W.current.has(e.id))continue;let t=e.quota?.fetchedAtUtc?new Date(e.quota.fetchedAtUtc).getTime():0;Number.isFinite(t)&&Date.now()-t<sn||(W.current.add(e.id),b.mutate(e.id,{onError:()=>{}}))}},[G,l]),(0,Q.useEffect)(()=>{let e=new Set(G.map(e=>e.id));be(t=>Array.from(t).every(t=>e.has(t))?t:new Set(Array.from(t).filter(t=>e.has(t)))),Se&&!e.has(Se)&&Ce(null)},[G,Se]),(0,Q.useEffect)(()=>{if(!j||P?.mode!==`pkce`)return;let e=setInterval(()=>void u.refetch(),3e3);return()=>clearInterval(e)},[j,P,u]),(0,Q.useEffect)(()=>{if(!j||P?.mode!==`pkce`)return;let e=G.find(e=>!Ve.current.has(e.id));e&&q(!0,e.displayName||e.accountEmail||e.id)},[G,j,P]),(0,Q.useEffect)(()=>{if(!j||P?.mode!==`device`&&P?.mode!==`cli`)return;let e=!1,t=0,n=async()=>{try{let n=await v.mutateAsync(P.state);if(e)return;t=0,n.status===`done`?q(!0,n.account.displayName||n.account.accountEmail||n.account.id):n.status!==`pending`&&n.status!==`slow_down`&&q(!1,void 0,`error`in n?n.error??n.status:n.status)}catch(n){if(e)return;if(n instanceof _&&(n.status===404||n.status===400)){q(!1,void 0,V(n));return}++t>=5&&q(!1,void 0,V(n))}},r=setInterval(()=>void n(),Math.max(P.interval||5,3)*1e3);return()=>{e=!0,clearInterval(r)}},[j,P]),!l)return null;let K=e=>e.displayName||e.accountEmail||e.keyMasked||e.id,q=(t,n,a)=>{if(s.invalidateQueries({queryKey:c.providerAccounts(e.id)}),t){Ne(null),Pe(null),N(!1),i(r(`providers.subscription.loginOk`,{name:n??``}),`success`);return}a&&Pe(a)},We=(e,t)=>{Ve.current=new Set(G.map(e=>e.id)),Pe(null),g.mutate({accountId:e,httpProxy:t},{onSuccess:e=>{O(!1),Ne(e),N(!0),e.mode!==`device`&&window.open(e.authorizeUrl,`_blank`,`noopener`)},onError:e=>{e instanceof _&&e.details?.needsVerification?i(r(`providers.subscription.needsVerification`),`error`):i(V(e),`error`)}})},Ge=async()=>{if(P){z(!0);try{let e=await v.mutateAsync(P.state);e.status===`done`?q(!0,e.account.displayName||e.account.accountEmail||e.account.id):e.status===`pending`||e.status===`slow_down`?i(r(`providers.subscription.stillWaiting`),`info`):q(!1,void 0,`error`in e?e.error??e.status:e.status)}catch(e){if(e instanceof _&&e.status===404){let t=((await u.refetch()).data??[]).find(e=>!Ve.current.has(e.id));t?q(!0,t.displayName||t.accountEmail||t.id):q(!1,void 0,V(e))}else q(!1,void 0,V(e))}finally{z(!1)}}},Ke=async()=>{if(P&&P.mode===`paste`&&B.trim().length!==0){z(!0);try{let e=await y.mutateAsync({state:P.state,code:B.trim()});e.status===`done`?(Be(``),q(!0,e.account.displayName||e.account.accountEmail||e.account.id)):q(!1,void 0,`error`in e?e.error??e.status:e.status)}catch(e){q(!1,void 0,V(e))}finally{z(!1)}}},qe=()=>ce.mutate(void 0,{onSuccess:e=>{i(r(`providers.subscription.importOk`,{name:K(e.account)}),e.warning?`info`:`success`),e.warning&&i(e.warning,`error`),C.refetch()},onError:e=>i(V(e),`error`)}),Je=()=>me.mutate(``,{onSuccess:e=>{i(r(`providers.subscription.importOk`,{name:K(e.account)}),e.warning?`info`:`success`),e.warning&&i(e.warning,`error`)},onError:e=>i(V(e),`error`)}),Ye=(e,t)=>{let n=G.map(e=>e.id),r=e+t;r<0||r>=n.length||([n[e],n[r]]=[n[r],n[e]],S.mutate(n,{onError:e=>i(V(e),`error`)}))},Xe=async()=>{if(await o({title:r(`providers.accounts.exportConfirm`),detail:r(`providers.accounts.exportDetail`),confirmLabel:r(`providers.accounts.export`)}))try{let e=await re.mutateAsync();if(e.count===0){i(r(`providers.accounts.exportNone`),`info`);return}if(!await He.copy(e.text)){i(r(`providers.accounts.exportCopyFailed`),`error`);return}i(r(`providers.accounts.exportDone`,{n:e.count})+(e.skipped>0?r(`providers.accounts.exportSkipped`,{n:e.skipped}):``),`success`)}catch(e){i(V(e),`error`)}},Ze=async e=>{let t=K(e);await o({title:r(`providers.subscription.logoutConfirm`,{name:t}),destructive:!0,confirmLabel:r(`providers.subscription.logout`)})&&ne.mutate(e.id,{onError:e=>i(V(e),`error`)})},$e={open:e=>Ce(e.id),activate:e=>ie.mutate(e.id,{onSuccess:()=>i(r(`providers.subscription.activated`,{name:K(e)}),`success`),onError:e=>i(V(e),`error`)}),toggleEnabled:e=>x.mutate({id:e.id,enabled:!e.enabled},{onError:e=>i(V(e),`error`)}),refreshQuota:e=>b.mutate(e.id,{onError:e=>{e instanceof _&&e.status===501?i(r(`providers.subscription.quotaUnsupported`),`error`):i(V(e),`error`)}}),refreshToken:e=>ee.mutate(e.id,{onSuccess:()=>i(r(`providers.subscription.tokenRefreshed`),`success`),onError:e=>i(V(e),`error`)}),relogin:e=>We(e.id),remove:e=>void Ze(e)},et=e=>be(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),tt=async t=>{let n=G.filter(e=>D.has(e.id));je(!0);let a=0;for(let e of n)try{await t(e),a++}catch(t){i(`${K(e)}: ${V(t)}`,`error`)}je(!1),be(new Set),s.invalidateQueries({queryKey:c.providerAccounts(e.id)}),a>0&&i(r(`providers.accounts.bulkDone`,{n:a}),`success`)},nt=async()=>{await o({title:r(`providers.accounts.bulkDeleteConfirm`,{n:D.size}),detail:r(`providers.accounts.bulkDeleteDetail`),destructive:!0,confirmLabel:r(`common.delete`)})&&await tt(e=>ne.mutateAsync(e.id))},it=G.map(e=>Gt(e)),J=e=>e===`all`?G.length:it.filter(t=>t===e).length,at=_e.trim().toLowerCase(),ot=G.map((e,t)=>({a:e,index:t,state:it[t]})).filter(({a:e,state:t})=>(he===`all`||t===he)&&(at.length===0||[e.displayName,e.accountEmail,e.keyMasked,e.plan].some(e=>e?.toLowerCase().includes(at)))),ct=G.find(e=>e.id===Se)??null,Z=m.data,lt=D.size>0,ut=[{id:`login`,label:r(`providers.accounts.addLogin`),icon:(0,$.jsx)(Ot,{className:`size-3.5`}),onSelect:()=>We()},{id:`login-proxy`,label:r(`providers.accounts.addLoginProxy`),onSelect:()=>O(!0)},...oe&&C.data?.available?[{id:`codex`,separatorBefore:!0,label:r(`providers.subscription.importCodex`),icon:(0,$.jsx)(Qe,{className:`size-3.5`}),onSelect:qe}]:[],...ue?[{id:`copilot`,separatorBefore:!0,label:r(`providers.subscription.importCopilot`),icon:(0,$.jsx)(Qe,{className:`size-3.5`}),onSelect:Je}]:[],...Z?.supported?[{id:`token`,separatorBefore:!(oe&&C.data?.available)&&!ue,label:r(`providers.accounts.addToken`),onSelect:()=>Te(`token`)}]:[],...Z?.apiKey?[{id:`apikey`,label:r(`providers.accounts.addApiKey`),icon:(0,$.jsx)(st,{className:`size-3.5`}),onSelect:()=>Te(`apiKey`)}]:[]];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`card mb-3 flex flex-wrap items-center gap-x-4 gap-y-2 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`mr-auto flex flex-wrap items-center gap-x-3 gap-y-1 text-[12px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[var(--text)]`,children:r(`providers.accounts.statTotal`,{n:G.length})}),(0,$.jsx)(`span`,{style:{color:`var(--success)`},children:r(`providers.accounts.statUsable`,{n:J(`usable`)})}),J(`cooling`)>0&&(0,$.jsx)(`span`,{style:{color:`var(--warning)`},children:r(`providers.accounts.statCooling`,{n:J(`cooling`)})}),J(`dead`)>0&&(0,$.jsx)(`span`,{style:{color:`var(--danger)`},children:r(`providers.accounts.statDead`,{n:J(`dead`)})}),(0,$.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`providers.accounts.providerProxy`,{proxy:e.httpProxy||r(`providers.accounts.proxyFallbackSystem`)})})]}),f.data&&(0,$.jsx)(ln,{policy:f.data,onChange:e=>p.mutate({switchMode:e},{onError:e=>i(V(e),`error`)})})]}),f.data&&(0,$.jsx)(`p`,{className:`-mt-1 mb-3 px-1 text-[11px] text-[var(--text-muted)]`,children:r(f.data.switchMode===`balanced`?`providers.subscription.policy.balancedDetail`:f.data.switchMode===`failover`?`providers.subscription.policy.failoverDetail`:`providers.subscription.policy.manualDetail`)}),(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(xe,{className:`w-52`,value:_e,onChange:ye,placeholder:r(`providers.accounts.search`)}),(0,$.jsx)(`div`,{role:`group`,"aria-label":r(`providers.accounts.filterLabel`),className:`mr-auto flex flex-wrap gap-1`,children:on.filter(e=>e.value===`all`||J(e.value)>0).map(e=>(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":he===e.value,onClick:()=>ge(e.value),className:M(`rounded-full px-2.5 py-0.5 text-[11.5px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--fill)]`,he===e.value&&`bg-[var(--fill)] text-[var(--text)]`),children:[r(e.label),(0,$.jsx)(`span`,{className:`ml-1 text-[var(--text-muted)]`,children:J(e.value)})]},e.value))}),Z?.supported&&(0,$.jsx)(F,{size:`sm`,icon:(0,$.jsx)(Et,{className:`size-3.5`}),onClick:()=>Te(`batch`),children:r(`providers.accounts.batchImport`)}),Z?.supported&&G.length>0&&(0,$.jsx)(F,{size:`sm`,icon:(0,$.jsx)(It,{className:`size-3.5`}),disabled:re.isPending,onClick:()=>void Xe(),children:r(`providers.accounts.export`)}),(0,$.jsx)(Ue,{label:r(`providers.accounts.add`),icon:(0,$.jsx)(Y,{className:`size-3.5`}),items:ut})]}),oe&&C.data?.available&&(0,$.jsxs)(`p`,{className:`mb-2 px-1 text-[11px] text-[var(--text-muted)]`,children:[r(`providers.subscription.localCodexFound`,{who:C.data.accountEmail??C.data.plan??r(`providers.subscription.unknownAccount`)}),C.data.detail?` · ${C.data.detail}`:``]}),ue&&(0,$.jsxs)(`p`,{className:`mb-2 px-1 text-[11px] text-[var(--text-muted)]`,children:[w.data?.available?r(`providers.subscription.localCopilotFound`,{source:w.data.source??``}):r(`providers.subscription.localCopilotHint`),w.data?.detail?` · ${w.data.detail}`:``]}),u.isLoading?(0,$.jsx)(R,{className:`my-4`}):G.length===0?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>We(),className:`flex w-full flex-col items-center gap-1 rounded-[var(--radius-card,12px)] border border-dashed border-[var(--border)] px-4 py-6 text-[12px] text-[var(--text-secondary)] hover:border-[var(--accent)] hover:text-[var(--text)]`,children:[(0,$.jsx)(`span`,{children:r(`providers.subscription.none`)}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[var(--accent)]`,children:[(0,$.jsx)(Y,{className:`size-3.5`}),` `,r(`providers.subscription.login`)]})]}):ot.length===0?(0,$.jsx)(`div`,{className:`px-4 py-5 text-center text-[12px] text-[var(--text-secondary)]`,children:r(`providers.accounts.noMatch`)}):(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(190px,1fr))] gap-3`,children:ot.map(({a:e,index:t})=>(0,$.jsx)(Yt,{account:e,usage:d.data?.accounts.find(t=>t.accountId===e.id),index:t,actions:$e,selected:D.has(e.id),selecting:lt,onToggleSelect:et,quotaPending:b.isPending&&b.variables===e.id,onMove:G.length>1?{up:t>0?()=>Ye(t,-1):void 0,down:t<G.length-1?()=>Ye(t,1):void 0}:void 0},e.id))}),d.isError&&(0,$.jsx)(I,{tone:`danger`,title:r(`providers.usage.error`),children:V(d.error)}),G.length>0&&(0,$.jsx)(Rt,{timeZone:d.data?.timeZone}),(0,$.jsx)(`p`,{className:`mt-2 px-1 text-[11px] text-[var(--text-muted)]`,children:r(`providers.subscription.footer`)}),lt&&(0,$.jsxs)(`div`,{className:`card sticky bottom-3 z-10 mt-3 flex flex-wrap items-center gap-1.5 px-3 py-1.5 shadow-lg`,children:[(0,$.jsx)(`span`,{className:`mr-auto text-[12px] text-[var(--text-secondary)]`,children:r(`providers.accounts.selected`,{n:D.size})}),(0,$.jsx)(F,{size:`sm`,icon:(0,$.jsx)(rt,{className:`size-3.5`}),disabled:A,onClick:()=>void tt(e=>x.mutateAsync({id:e.id,enabled:!0})),children:r(`providers.subscription.enable`)}),(0,$.jsx)(F,{size:`sm`,disabled:A,onClick:()=>void tt(e=>x.mutateAsync({id:e.id,enabled:!1})),children:r(`providers.subscription.disable`)}),(0,$.jsx)(F,{size:`sm`,disabled:A,onClick:()=>void tt(e=>b.mutateAsync(e.id)),children:r(`providers.subscription.quotaRefresh`)}),(0,$.jsx)(F,{size:`sm`,className:`text-[var(--danger)]`,icon:(0,$.jsx)(X,{className:`size-3.5`}),disabled:A,onClick:()=>void nt(),children:r(`common.delete`)}),(0,$.jsx)(F,{size:`sm`,variant:`plain`,onClick:()=>be(new Set),children:r(`providers.accounts.clearSelection`)})]}),(0,$.jsx)(`div`,{className:`mt-5`,children:(0,$.jsx)(an,{provider:e})}),(0,$.jsx)(rn,{provider:e,account:ct,usage:d.data?.accounts.find(e=>e.accountId===ct?.id),usageTimeZone:d.data?.timeZone,index:ct?G.indexOf(ct):0,actions:$e,onClose:()=>Ce(null)}),Z&&(0,$.jsx)(Wt,{providerId:e.id,info:Z,mode:we,providerProxy:e.httpProxy,onClose:()=>Te(null)}),(0,$.jsx)(H,{open:Ee,onOpenChange:O,title:r(`providers.accounts.loginProxyTitle`),description:r(`providers.accounts.loginProxyDesc`),footer:(0,$.jsx)(F,{variant:`primary`,loading:g.isPending,disabled:k.trim().length===0,onClick:()=>We(void 0,k),children:r(`providers.accounts.loginProxyStart`)}),children:(0,$.jsx)(E,{mono:!0,label:r(`providers.accounts.detail.proxy`),placeholder:`socks5://127.0.0.1:1080`,value:k,onChange:e=>Ae(e.target.value)})}),(0,$.jsxs)(H,{open:j,onOpenChange:e=>{N(e),e||(Ne(null),Pe(null))},title:r(`providers.subscription.login`),description:r(`providers.subscription.loginDesc`),children:[L&&(0,$.jsx)(I,{tone:`danger`,title:r(`providers.subscription.loginFailed`),children:L}),P?.mode===`paste`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(I,{tone:`info`,title:r(`providers.subscription.pasteTitle`),children:r(`providers.subscription.pasteDetail`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsx)(F,{onClick:()=>window.open(P.authorizeUrl,`_blank`,`noopener`),children:r(`providers.subscription.openAuthorize`)})}),(0,$.jsx)(E,{mono:!0,value:B,onChange:e=>Be(e.target.value),placeholder:r(`providers.subscription.pastePlaceholder`),"aria-label":r(`providers.subscription.pasteCode`)}),(0,$.jsx)(F,{variant:`primary`,loading:Fe,onClick:()=>void Ke(),children:r(`providers.subscription.pasteSubmit`)})]}),P?.mode===`pkce`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(I,{tone:`info`,title:r(`providers.subscription.waiting`),children:r(`providers.subscription.waitingDetail`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(F,{onClick:()=>window.open(P.authorizeUrl,`_blank`,`noopener`),children:r(`providers.subscription.openAuthorize`)}),(0,$.jsx)(F,{variant:`primary`,onClick:()=>{s.invalidateQueries({queryKey:c.providerAccounts(e.id)}),u.refetch()},children:r(`providers.subscription.doneAuthorize`)})]})]}),P?.mode===`cli`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(I,{tone:`info`,title:r(`providers.subscription.waiting`),children:r(`providers.subscription.cliDetail`)}),(0,$.jsx)(F,{onClick:()=>window.open(P.authorizeUrl,`_blank`,`noopener`),children:r(`providers.subscription.openAuthorize`)})]}),P?.mode===`device`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-[11px] text-[var(--text-secondary)]`,children:r(`providers.subscription.deviceCode`)}),(0,$.jsx)(`div`,{className:`selectable font-mono text-[18px] font-medium tracking-wide`,children:P.userCode})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[P.verificationUrl&&(0,$.jsx)(F,{onClick:()=>window.open(P.verificationUrl??void 0,`_blank`,`noopener`),children:r(`providers.subscription.visitPage`)}),(0,$.jsx)(F,{variant:`primary`,loading:Fe,onClick:()=>void Ge(),children:r(`providers.subscription.checkNow`)})]}),(0,$.jsx)(I,{tone:`info`,title:r(`providers.subscription.waiting`),children:r(`providers.subscription.checkNowHint`)})]})]})]})}function ln({policy:e,onChange:t}){let{t:n}=T();return(0,$.jsx)(ue,{ariaLabel:n(`providers.subscription.policy.switchMode`),value:e.switchMode,onChange:t,items:[{value:`manual`,label:n(`providers.subscription.policy.manual`)},{value:`failover`,label:n(`providers.subscription.policy.failover`)},{value:`balanced`,label:n(`providers.subscription.policy.balanced`)}]})}function un({provider:e}){let{t}=T(),n=pe(e.id),r=ve(e.id),i=oe(e.id),a=h(e.id,!0),o=Le(e.id),{toast:s}=U(),[c,l]=(0,Q.useState)(null);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i.isLoading&&(0,$.jsx)(R,{lines:1}),i.isError&&(0,$.jsx)(I,{tone:`danger`,title:t(`pluginAccounts.noPlugin`),children:V(i.error)}),i.data?.map(e=>(0,$.jsx)(F,{variant:e.index===0?`primary`:void 0,icon:e.type===`api`?(0,$.jsx)(st,{className:`size-3.5`}):(0,$.jsx)(Ot,{className:`size-3.5`}),onClick:()=>l(e),children:e.label||t(e.type===`api`?`pluginAccounts.apiKey`:`pluginAccounts.browser`)},e.index))]}),n.isLoading&&(0,$.jsx)(R,{lines:3}),n.data?.length===0&&(0,$.jsx)(`div`,{className:`card`,children:(0,$.jsx)(ge,{icon:(0,$.jsx)(At,{className:`size-6`}),title:t(`pluginAccounts.empty`),detail:t(`pluginAccounts.emptyDetail`)})}),n.data&&n.data.length>1&&a.data&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 px-1`,children:[(0,$.jsx)(`p`,{className:`min-w-0 flex-1 text-[12px] text-[var(--text-secondary)]`,children:t(a.data.switchMode===`balanced`?`providers.subscription.policy.balancedDetail`:a.data.switchMode===`failover`?`providers.subscription.policy.failoverDetail`:`providers.subscription.policy.manualDetail`)}),(0,$.jsx)(ln,{policy:a.data,onChange:e=>o.mutate({switchMode:e},{onError:e=>s(V(e),`error`)})})]}),n.data&&n.data.length>0&&(0,$.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] overflow-hidden p-0`,children:n.data.map(t=>(0,$.jsx)(fn,{provider:e,account:t,gatewayUsage:r.data?.accounts.find(e=>e.accountId===t.id)},t.id))}),r.isError&&(0,$.jsx)(I,{tone:`danger`,title:t(`providers.usage.error`),children:V(r.error)}),n.data&&n.data.length>0&&(0,$.jsx)(Rt,{timeZone:r.data?.timeZone}),(0,$.jsx)(dn,{provider:e}),c&&(0,$.jsx)(pn,{provider:e,method:c,onClose:()=>l(null)})]})}function dn({provider:e}){let{t,locale:n}=T(),{toast:r}=U(),a=Ve(e.id),o=i(e.id);if(!a.data?.supported)return null;let s=e=>o.mutate(e,{onError:e=>r(V(e),`error`)}),c={claimed:`green`,done:`green`,ineligible:`neutral`,inactive:`neutral`,captcha:`orange`,failed:`red`};return(0,$.jsxs)(`section`,{className:`card divide-y divide-[var(--border-subtle)] overflow-hidden p-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-[13px] font-medium`,children:t(`pluginAccounts.checkin`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[12px] text-[var(--text-secondary)]`,children:t(`pluginAccounts.checkinDetail`)})]}),(0,$.jsx)(B,{checked:a.data.on,label:t(`pluginAccounts.checkinOn`),onChange:e=>s(e)}),(0,$.jsx)(F,{size:`sm`,loading:o.isPending,onClick:()=>s(),children:t(`pluginAccounts.checkinNow`)})]}),a.data.accounts.map(e=>{let r=[e.credit?t(`pluginAccounts.credit`,{credit:e.credit}):null,e.streak?t(`pluginAccounts.streak`,{days:e.streak}):null,e.message,e.at?u(e.at,n):null].filter(Boolean);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.account}),r.length>0&&(0,$.jsx)(`span`,{className:`min-w-0 truncate text-[12px] text-[var(--text-secondary)]`,children:r.join(` · `)}),e.outcome?(0,$.jsx)(A,{tone:c[e.outcome]??`neutral`,children:t(`pluginAccounts.outcome.${e.outcome}`)}):(0,$.jsx)(A,{children:t(`pluginAccounts.checkinNever`)})]},e.accountId)})]})}function fn({provider:e,account:t,gatewayUsage:n}){let{t:r,locale:i}=T(),{toast:a,confirm:o}=U(),s=P(e.id),[c,l]=(0,Q.useState)(!1),d=e.settings?.plugin?.usage===!0,f=p(e.id,t.id,c),m=async()=>{await o({title:r(`pluginAccounts.signOutConfirm`,{name:t.displayName}),confirmLabel:r(`pluginAccounts.signOut`),destructive:!0})&&s.mutate(t.id,{onError:e=>a(V(e),`error`)})};return(0,$.jsxs)(`article`,{className:`flex flex-col gap-2 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:t.displayName}),t.isCurrent&&(0,$.jsx)(A,{tone:`accent`,children:r(`pluginAccounts.current`)}),(0,$.jsx)(A,{tone:t.status===`active`?`green`:`red`,children:r(t.status===`active`?`pluginAccounts.active`:`pluginAccounts.lapsed`)}),d&&(0,$.jsx)(F,{size:`sm`,onClick:()=>l(e=>!e),children:r(`pluginAccounts.usage`)}),(0,$.jsx)(F,{size:`sm`,variant:`destructive`,icon:(0,$.jsx)(nt,{className:`size-3.5`}),onClick:()=>void m(),children:r(`pluginAccounts.signOut`)})]}),t.status!==`active`&&(0,$.jsx)(`p`,{className:`text-[12px] text-[var(--danger)]`,children:r(`pluginAccounts.lapsedDetail`)}),(0,$.jsx)(Lt,{usage:n}),c&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md bg-[var(--surface-muted)] px-3 py-2`,children:[f.isLoading&&(0,$.jsx)(R,{lines:2}),f.isError&&(0,$.jsx)(`span`,{className:`text-[12px] text-[var(--danger)]`,children:V(f.error)}),f.data?.error&&(0,$.jsx)(`span`,{className:`text-[12px] text-[var(--danger)]`,children:f.data.error}),f.data?.plan&&(0,$.jsx)(D,{label:r(`pluginAccounts.plan`),children:f.data.plan}),f.data?.until&&(0,$.jsx)(D,{label:r(`pluginAccounts.until`),children:u(f.data.until,i)}),f.data?.windows?.map(e=>(0,$.jsxs)(D,{label:e.name,children:[e.display??(e.limit?`${e.amount??e.used??0} / ${e.limit} ${e.unit??``}`:`${e.used??0}%`),e.resetsAt?` · ${r(`pluginAccounts.resets`,{at:u(new Date(e.resetsAt>0xe8d4a51000?e.resetsAt:e.resetsAt*1e3).toISOString(),i)})}`:``]},e.name))]})]})}function pn({provider:e,method:t,onClose:n}){let{t:r}=T(),{toast:i}=U(),[a,o]=(0,Q.useState)({}),[c,u]=(0,Q.useState)(void 0),[f,p]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(null),[_,y]=(0,Q.useState)(``),[b,ee]=(0,Q.useState)(``),[te,re]=(0,Q.useState)(null),ie=d(e.id),x=ne(e.id),ae=l(e.id),S=m(e.id,te).data;(0,Q.useEffect)(()=>{let n=!0;return s(e.id,t.index,a).then(e=>{n&&(u(e.prompt),p(e.prompt?.type===`select`?e.prompt.options?.[0]?.value??``:``))}).catch(e=>n&&i(V(e),`error`)),()=>{n=!1}},[e.id,t.index,a,i]),(0,Q.useEffect)(()=>{S?.state===`done`&&(i(r(`pluginAccounts.signedIn`),`success`),n())},[S?.state,n,r,i]);let oe=async()=>{if(!c)return;let n=await v(e.id,t.index,c.key,f).catch(()=>({error:null}));if(n.error)return g(n.error);g(null),o(e=>({...e,[c.key]:f}))};return(0,$.jsxs)(H,{open:!0,onOpenChange:e=>!e&&n(),title:r(`pluginAccounts.signInTitle`,{name:e.name}),description:t.label,width:520,children:[c===void 0&&(0,$.jsx)(R,{lines:2}),c&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(O,{label:c.message,error:h??void 0,children:c.type===`select`?(0,$.jsx)(W,{value:f,onChange:p,options:(c.options??[]).map(e=>({value:e.value,label:e.label,description:e.hint??void 0}))}):(0,$.jsx)(E,{value:f,placeholder:c.placeholder??void 0,onChange:e=>p(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(F,{variant:`primary`,onClick:()=>void oe(),children:r(`pluginAccounts.continue`)})})]}),c===null&&t.type===`api`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(O,{label:r(`pluginAccounts.key`),children:(0,$.jsx)(E,{mono:!0,type:`password`,value:_,placeholder:t.placeholder??void 0,onChange:e=>y(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(F,{variant:`primary`,disabled:!_.trim()||x.isPending,onClick:()=>x.mutate({method:t.index,inputs:a,key:_},{onSuccess:()=>(i(r(`pluginAccounts.signedIn`),`success`),n()),onError:e=>i(V(e),`error`)}),children:r(`pluginAccounts.signIn`)})})]}),c===null&&t.type!==`api`&&!S&&(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(F,{variant:`primary`,icon:(0,$.jsx)(et,{className:`size-3.5`}),disabled:ie.isPending,onClick:()=>ie.mutate({method:t.index,inputs:a},{onSuccess:e=>{re(e.id),e.url&&window.open(e.url,`_blank`,`noopener`)},onError:e=>i(V(e),`error`)}),children:r(`pluginAccounts.openPage`)})}),S&&S.state!==`done`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[S.instructions&&(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[12px] text-[var(--text-secondary)]`,children:S.instructions}),S.deviceCode&&(0,$.jsx)(D,{label:r(`pluginAccounts.deviceCode`),mono:!0,children:S.deviceCode}),S.url&&(0,$.jsx)(F,{icon:(0,$.jsx)(et,{className:`size-3.5`}),onClick:()=>window.open(S.url,`_blank`,`noopener`),children:r(`pluginAccounts.openAgain`)}),S.state===`waiting`&&S.pasteCode&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O,{label:r(`pluginAccounts.code`),children:(0,$.jsx)(E,{mono:!0,value:b,onChange:e=>ee(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(F,{variant:`primary`,disabled:!b.trim()||ae.isPending,onClick:()=>ae.mutate({flow:S.id,code:b.trim()},{onError:e=>i(V(e),`error`)}),children:r(`pluginAccounts.signIn`)})})]}),S.state===`waiting`&&!S.pasteCode&&(0,$.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`pluginAccounts.waiting`)}),S.state===`failed`&&(0,$.jsx)(I,{tone:`danger`,title:r(`pluginAccounts.failed`),children:S.error})]})]})}function mn(e){let t=e?.model_map,n={};if(!t||typeof t!=`object`||Array.isArray(t))return n;for(let[e,r]of Object.entries(t))e&&typeof r==`string`&&r&&(n[e]=r);return n}function hn(){let{t:e}=T(),{id:t=``}=dt(),n=J(),r=Te(t),[i,a]=(0,Q.useState)(`models`),[o,s]=(0,Q.useState)(null),c=j(t),l=c.data?.find(e=>e.id===o)??null;if(r.isError)return(0,$.jsx)(ft,{title:e(`nav.providers`),leading:(0,$.jsx)(gn,{onClick:()=>n(`/providers`)}),children:(0,$.jsx)(I,{tone:`danger`,title:e(`common.error`),children:V(r.error)})});let u=r.data;return(0,$.jsx)(ft,{title:u?u.name:``,subtitle:u?[u.templateId,u.priceKey?e(`providers.priceKeyShort`,{key:u.priceKey}):null].filter(Boolean).join(` · `):void 0,leading:(0,$.jsx)(gn,{onClick:()=>n(`/providers`)}),actions:u&&(0,$.jsx)(_n,{p:u}),children:u?(0,$.jsxs)(at,{className:`mx-auto max-w-[860px]`,value:i,onValueChange:e=>a(e),children:[(0,$.jsxs)(Z,{"aria-label":u.name,children:[(0,$.jsx)(ot,{value:`models`,children:e(`providers.tab.models`)}),(0,$.jsx)(ot,{value:`accounts`,children:e(u.authScheme===`oauth-subscription`||u.authScheme===`plugin`?`providers.tab.accounts`:`providers.tab.apiKey`)}),(0,$.jsx)(ot,{value:`settings`,children:e(`providers.tab.settings`)})]}),(0,$.jsx)(gt,{value:`models`,className:`pt-4`,children:(0,$.jsx)(yn,{provider:u,models:c.data,loading:c.isLoading,selected:o,onSelect:s})}),(0,$.jsx)(gt,{value:`accounts`,className:`pt-4`,children:u.authScheme===`plugin`?(0,$.jsx)(un,{provider:u}):u.authScheme===`oauth-subscription`?(0,$.jsx)(cn,{provider:u}):(0,$.jsx)(Dn,{provider:u})}),(0,$.jsx)(gt,{value:`settings`,className:`pt-4`,children:(0,$.jsx)(kn,{provider:u})}),(0,$.jsx)(En,{provider:u,pm:i===`models`?l:null,onClose:()=>s(null)})]}):(0,$.jsx)(R,{lines:4,className:`mx-auto mt-6 max-w-[860px]`})})}function gn({onClick:e}){let{t}=T();return(0,$.jsx)(F,{variant:`glass`,icon:(0,$.jsx)(Xe,{className:`size-4`}),"aria-label":t(`common.back`),onClick:e})}function _n({p:e}){let{t}=T(),n=J(),{toast:r,confirm:i}=U(),a=Se(),o=_e(),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),p=async()=>{await i({title:t(`providers.deleteConfirm`,{name:e.name}),detail:t(`providers.deleteDetail`),destructive:!0,confirmLabel:t(`common.delete`)})&&o.mutate(e.id,{onSuccess:()=>{r(t(`providers.deleted`)),n(`/providers`)},onError:e=>{let n=e instanceof _&&e.status===409?e.details?.boundClients??[]:[];r(n.length?t(`providers.deleteBound`,{clients:n.map(e=>lt[e]?.name??e).join(`, `)}):V(e),`error`)}})};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{icon:(0,$.jsx)(tt,{className:`size-3.5`}),onClick:()=>f(!0),children:t(`providers.test`)}),(0,$.jsx)(Ue,{label:t(`common.more`),icon:(0,$.jsx)($e,{className:`size-4`}),items:[{id:`dup`,label:t(`providers.duplicate`),icon:(0,$.jsx)(be,{className:`size-3.5`}),onSelect:()=>a.mutate(e.id,{onSuccess:e=>n(`/providers/${e.id}`),onError:e=>r(V(e),`error`)})},{id:`tpl`,label:t(`providers.templateUpdate`),icon:(0,$.jsx)(Mt,{className:`size-3.5`}),disabled:!e.templateId,onSelect:()=>c(!0)},{id:`switch`,label:t(`providers.templateSwitch`),icon:(0,$.jsx)(bt,{className:`size-3.5`}),disabled:!qe(e),onSelect:()=>u(!0)},{id:`del`,label:t(`common.delete`),icon:(0,$.jsx)(X,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void p()}]}),(0,$.jsx)(vn,{open:s,onOpenChange:c,provider:e}),(0,$.jsx)(Ke,{open:l,onOpenChange:u,provider:e}),(0,$.jsx)(q,{provider:e,open:d,onOpenChange:f})]})}function vn({open:e,onOpenChange:t,provider:n}){let{t:r}=T(),{toast:i}=U(),a=C(n.id,e),o=re(n.id),s=a.data&&a.data.latestVersion<=a.data.currentVersion;return(0,$.jsxs)(H,{open:e,onOpenChange:t,title:r(`providers.templateUpdate`),description:a.data?r(`providers.templateVersions`,{current:a.data.currentVersion,latest:a.data.latestVersion}):void 0,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:!a.data||s,loading:o.isPending,onClick:()=>o.mutate(void 0,{onSuccess:()=>{t(!1),i(r(`providers.templateApplied`),`success`)},onError:e=>i(V(e),`error`)}),children:r(`common.apply`)})]}),children:[a.isLoading&&(0,$.jsx)(R,{}),a.isError&&(0,$.jsx)(I,{tone:`danger`,title:r(`common.error`),children:V(a.error)}),s&&(0,$.jsx)(I,{tone:`success`,title:r(`providers.templateUpToDate`)}),a.data&&!s&&(0,$.jsx)(`ul`,{className:`list-disc pl-5 text-[12px]`,children:a.data.changes.map((e,t)=>(0,$.jsx)(`li`,{children:e},t))})]})}function yn({provider:e,models:t,loading:n,selected:r,onSelect:i}){let{t:a}=T(),{toast:o}=U(),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),p=he(e.id),m=(t??[]).filter(e=>!s||e.modelId.toLowerCase().includes(s.toLowerCase())||e.effective.displayName.toLowerCase().includes(s.toLowerCase()));return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(xe,{className:`w-56`,value:s,onChange:c,placeholder:a(`providers.searchModels`)}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(F,{icon:(0,$.jsx)(Y,{className:`size-3.5`}),onClick:()=>f(!0),children:a(`providers.addModels`)}),(0,$.jsx)(F,{variant:`primary`,icon:(0,$.jsx)(Ze,{className:`size-3.5`}),onClick:()=>u(!0),children:a(`providers.fetchRemote`)})]})]}),n&&(0,$.jsx)(R,{lines:4}),t?.length===0&&(0,$.jsx)(`div`,{className:`card`,children:(0,$.jsx)(ge,{title:a(`providers.noModels`),detail:a(`providers.noModelsDetail`)})}),m.length>0&&(0,$.jsx)(L,{footer:a(`providers.modelsFooter`),children:m.map(e=>(0,$.jsxs)(k,{selected:e.id===r,onClick:()=>i(e.id),label:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:M(`font-mono text-[12.5px]`,!e.enabled&&`text-[var(--text-muted)]`),children:e.modelId}),!e.systemModelId&&(0,$.jsx)(A,{tone:`orange`,children:a(`providers.unlinked`)})]}),detail:[e.effective.displayName===e.modelId?null:e.effective.displayName,e.effective.contextWindow?S(e.effective.contextWindow):null,Ne(e.effectivePricing)].filter(Boolean).join(` · `),children:[(0,$.jsx)(ut,{source:e.pricingSource,priceKey:e.priceKey}),(0,$.jsx)(B,{checked:e.enabled,label:a(`common.enabled`),onChange:t=>p.mutate({pmId:e.id,enabled:t},{onError:e=>o(V(e),`error`)})})]},e.id))}),(0,$.jsx)(bn,{provider:e}),t&&(0,$.jsx)(xn,{provider:e,models:t}),(0,$.jsx)(Cn,{open:d,onOpenChange:f,provider:e}),(0,$.jsx)(wn,{open:l,onOpenChange:u,provider:e})]})}function bn({provider:e}){let{t}=T(),{toast:n}=U(),r=Fe(e.id),i=typeof e.settings.alias==`string`?e.settings.alias:``,[a,o]=(0,Q.useState)(i);return(0,Q.useEffect)(()=>o(i),[i]),(0,$.jsx)(L,{title:t(`providers.alias.title`),footer:t(`providers.alias.footer`),children:(0,$.jsxs)(k,{label:t(`providers.alias.label`),detail:t(`providers.alias.hint`),children:[(0,$.jsx)(E,{className:`w-56`,mono:!0,maxLength:64,"aria-label":t(`providers.alias.label`),placeholder:e.name,value:a,onChange:e=>o(e.target.value)}),(0,$.jsx)(F,{size:`sm`,disabled:r.isPending||a.trim()===i,onClick:()=>{let i=a.trim(),o={...e.settings};i?o.alias=i:delete o.alias,r.mutate({settings:o},{onSuccess:()=>n(t(`providers.alias.saved`),`success`),onError:e=>n(V(e),`error`)})},children:t(`common.save`)})]})})}function xn({provider:e,models:t}){let{t:n}=T(),{toast:r}=U(),i=g(e.id),[a,o]=(0,Q.useState)(!1),s=mn(e.settings),c=Object.entries(s),l=new Set(t.map(e=>e.modelId)),u=(e,t)=>i.mutate(e,{onSuccess:()=>{t?.(),r(n(`providers.modelMap.saved`),`success`)},onError:e=>r(V(e),`error`)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(L,{title:n(`providers.modelMap.title`),footer:n(`providers.modelMap.footer`),children:[c.map(([e,t])=>(0,$.jsx)(k,{label:(0,$.jsxs)(`span`,{className:`flex items-center gap-2 font-mono text-[12.5px]`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e}),(0,$.jsx)(ct,{className:`size-3.5 shrink-0 text-[var(--text-muted)]`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:M(`truncate`,!l.has(t)&&`text-[var(--text-muted)]`),children:t}),!l.has(t)&&(0,$.jsx)(A,{tone:`orange`,children:n(`providers.modelMap.missingTarget`)})]}),children:(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(ye,{className:`size-3.5`}),"aria-label":n(`providers.modelMap.remove`,{from:e}),title:n(`providers.modelMap.remove`,{from:e}),disabled:i.isPending,onClick:()=>u(Object.fromEntries(c.filter(([t])=>t!==e)))})},e)),(0,$.jsx)(k,{icon:(0,$.jsx)(Y,{className:`size-4 text-[var(--text-secondary)]`}),label:n(`providers.modelMap.add`),detail:t.length===0?n(`providers.modelMap.needModels`):void 0,onClick:t.length===0?void 0:()=>o(!0)})]}),(0,$.jsx)(Sn,{open:a,onOpenChange:o,models:t,saving:i.isPending,onSave:(e,t)=>u({...s,[e]:t},()=>o(!1))})]})}function Sn({open:e,onOpenChange:t,models:n,saving:r,onSave:i}){let{t:a}=T(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&(s(``),l(``))},[e]);let u=o.trim();return(0,$.jsx)(H,{open:e,onOpenChange:t,title:a(`providers.modelMap.add`),description:a(`providers.modelMap.addDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{onClick:()=>t(!1),children:a(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:!u||!c||u===c,loading:r,onClick:()=>i(u,c),children:a(`common.save`)})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(E,{autoFocus:!0,mono:!0,label:a(`providers.modelMap.from`),placeholder:`deepseek-v4.1`,spellCheck:!1,value:o,onChange:e=>s(e.target.value)}),(0,$.jsx)(W,{label:a(`providers.modelMap.to`),value:c,onChange:l,placeholder:a(`providers.modelMap.toPlaceholder`),options:n.map(e=>({value:e.modelId,label:e.modelId}))})]})})}function Cn({open:e,onOpenChange:t,provider:n}){let{t:r}=T(),{toast:i}=U(),a=y(n.id),[o,s]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&s(``)},[e]);let c=[...new Set(o.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean))];return(0,$.jsx)(H,{open:e,onOpenChange:t,title:r(`providers.addModels`),description:r(`providers.addModelsDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:c.length===0,loading:a.isPending,onClick:()=>a.mutate(c,{onSuccess:e=>{t(!1),i(r(`providers.modelsAdded`,{count:e.length}),`success`)},onError:e=>i(V(e),`error`)}),children:r(`providers.addSelected`,{count:c.length})})]}),children:(0,$.jsx)(me,{autoFocus:!0,label:r(`providers.modelIds`),rows:6,spellCheck:!1,className:`w-full font-mono text-[12px]`,placeholder:`deepseek-v4-pro
3
+ claude-sonnet-4-6`,value:o,onChange:e=>s(e.target.value)})})}function wn({open:e,onOpenChange:t,provider:n}){let{t:r}=T(),{toast:i}=U(),a=Ae(n.id,e),o=y(n.id),[s,c]=(0,Q.useState)(new Set),[l,u]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&c(new Set)},[e]);let d=(a.data??[]).filter(e=>!l||e.id.toLowerCase().includes(l.toLowerCase())),f=e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,$.jsxs)(H,{open:e,onOpenChange:t,width:560,title:r(`providers.fetchRemote`),description:r(`providers.fetchRemoteDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{variant:`plain`,className:`mr-auto`,onClick:()=>c(new Set(d.filter(e=>!e.alreadyAdded).map(e=>e.id))),disabled:d.length===0,children:r(`common.selectAll`)}),(0,$.jsx)(F,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:s.size===0,loading:o.isPending,onClick:()=>o.mutate([...s],{onSuccess:e=>{t(!1),i(r(`providers.modelsAdded`,{count:e.length}),`success`)},onError:e=>i(V(e),`error`)}),children:r(`providers.addSelected`,{count:s.size})})]}),children:[(0,$.jsx)(xe,{className:`mb-3`,value:l,onChange:u,placeholder:r(`providers.searchModels`)}),a.isLoading&&(0,$.jsx)(R,{lines:4}),a.isError&&(0,$.jsx)(I,{tone:`danger`,title:r(`common.error`),children:V(a.error)}),a.error instanceof _&&(0,$.jsx)(G,{className:`mt-3`,provider:n,httpStatus:a.error.details?.httpStatus}),(0,$.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:d.map(e=>(0,$.jsx)(k,{onClick:e.alreadyAdded?void 0:()=>f(e.id),label:(0,$.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.id}),detail:e.linkedSystemModelId?r(`providers.linksTo`,{id:e.linkedSystemModelId}):r(`providers.noLink`),children:e.alreadyAdded?(0,$.jsx)(A,{children:r(`providers.added`)}):(0,$.jsx)(`span`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(_t,{"aria-label":e.id,checked:s.has(e.id),onCheckedChange:()=>f(e.id)})})},e.id))})]})}function Tn({origin:e}){let{t}=T();return e===`overridden`?(0,$.jsx)(A,{tone:`orange`,children:t(`origin.overridden`)}):e===`inherited`?(0,$.jsx)(A,{children:t(`origin.inherited`)}):(0,$.jsx)(A,{tone:`red`,children:t(`origin.unset`)})}function En({provider:e,pm:t,onClose:n}){let{t:r}=T(),{toast:i}=U(),a=he(e.id),o=Pe(e.id),s=f(),[c,l]=(0,Q.useState)({}),[u,d]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{t&&(l(t.overrides),d(t.systemModelId??``),m(t.overrides.pricing!=null))},[t]),!t)return(0,$.jsx)(H,{open:!1,onOpenChange:()=>n(),title:r(`providers.tab.models`)});let h={...c,pricing:p?c.pricing??null:null},g=JSON.stringify(h)!==JSON.stringify({...t.overrides,pricing:t.overrides.pricing??null})||u!==(t.systemModelId??``),_=()=>a.mutate({pmId:t.id,overrides:h,systemModelId:u||null},{onSuccess:()=>{i(r(`common.saved`),`success`),n()},onError:e=>i(V(e),`error`)}),v=(e,n,i)=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[13px] font-medium`,children:n}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Tn,{origin:c[e]==null?t.origins[e]===`overridden`?`inherited`:t.origins[e]:`overridden`}),c[e]!=null&&(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(it,{className:`size-3`}),title:r(`origin.reset`),"aria-label":r(`origin.reset`),onClick:()=>l({...c,[e]:null})})]})]}),i]});return(0,$.jsx)(H,{open:!0,onOpenChange:e=>!e&&n(),width:720,title:t.modelId,description:e.name,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mr-auto`,children:(0,$.jsx)(vt,{label:r(`providers.removeModelShort`),icon:(0,$.jsx)(X,{className:`size-4`}),prompt:r(`providers.removeModel`,{id:t.modelId}),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:async()=>{await o.mutateAsync(t.id),n()}})}),(0,$.jsx)(F,{onClick:n,children:r(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:!g,loading:a.isPending,onClick:_,children:r(`common.save`)})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(ut,{source:t.pricingSource,priceKey:t.priceKey}),t.multiplier!==1&&t.pricingSource!==`provider_override`&&(0,$.jsxs)(A,{children:[`×`,t.multiplier]})]}),(0,$.jsxs)(w,{title:r(`providers.linkedModel`),children:[(0,$.jsx)(W,{className:`w-full`,ariaLabel:r(`providers.linkedModel`),value:u,onChange:d,options:[{value:``,label:r(`providers.noLink`)},...(s.data??[]).map(e=>({value:e.id,label:e.id,detail:e.displayName}))]}),(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-[var(--text-muted)]`,children:r(`providers.linkedModelHint`)})]}),(0,$.jsx)(w,{title:r(`providers.overrides`),children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[v(`displayName`,r(`models.field.displayName`),(0,$.jsx)(E,{className:`w-full`,"aria-label":r(`models.field.displayName`),placeholder:t.effective.displayName,value:c.displayName??``,onChange:e=>l({...c,displayName:e.target.value||null})})),v(`contextWindow`,r(`models.field.contextWindow`),(0,$.jsx)(N,{className:`w-full`,label:r(`models.field.contextWindow`),placeholder:String(t.effective.contextWindow??``),value:c.contextWindow,onChange:e=>l({...c,contextWindow:e})})),v(`maxOutputTokens`,r(`models.field.maxOutputTokens`),(0,$.jsx)(N,{className:`w-full`,label:r(`models.field.maxOutputTokens`),placeholder:String(t.effective.maxOutputTokens??``),value:c.maxOutputTokens,onChange:e=>l({...c,maxOutputTokens:e})}))]})}),(0,$.jsxs)(w,{title:r(`providers.price`),action:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[r(`providers.customPrice`),(0,$.jsx)(B,{checked:p,label:r(`providers.customPrice`),onChange:e=>{m(e),e&&c.pricing==null&&l({...c,pricing:t.effectivePricing??{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}}})}})]}),children:[(0,$.jsx)(`p`,{className:`mb-3 text-[11px] text-[var(--text-muted)]`,children:r(p?`providers.customPriceHint`:`providers.inheritedPriceHint`)}),p?(0,$.jsx)(`div`,{className:`card p-4`,children:(0,$.jsx)(pt,{value:c.pricing??null,onChange:e=>l({...c,pricing:e})})}):t.effectivePricing?(0,$.jsx)(we,{maxHeight:220,children:je(t.effectivePricing)}):(0,$.jsx)(I,{tone:`warning`,title:r(`pricingSource.none`)})]})]})})}function Dn({provider:e}){let{t}=T(),{toast:n}=U(),r=Fe(e.id),i=ve(e.id),[a,o]=(0,Q.useState)(``);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{title:t(`providers.section.auth`),footer:t(`providers.apiKeyStored`),children:(0,$.jsx)(k,{label:t(`providers.apiKey`),detail:e.hasApiKey?e.apiKeyMasked??`••••`:t(`providers.noKey`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(E,{type:`password`,autoComplete:`off`,className:`w-64 font-mono`,"aria-label":t(`providers.apiKey`),placeholder:t(`providers.replaceKey`),value:a,onChange:e=>o(e.target.value)}),(0,$.jsx)(F,{variant:`primary`,disabled:a.trim().length===0,loading:r.isPending,onClick:()=>r.mutate({apiKey:a},{onSuccess:()=>{o(``),n(t(`common.saved`),`success`)},onError:e=>n(V(e),`error`)}),children:t(`common.save`)})]})})}),(0,$.jsxs)(`section`,{className:`card my-4 flex flex-col gap-2 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-[13px] font-medium`,children:t(`providers.usage.title`)}),i.isError&&(0,$.jsx)(I,{tone:`danger`,title:t(`providers.usage.error`),children:V(i.error)}),(0,$.jsx)(Lt,{usage:i.data?.accounts.find(e=>!e.accountId)}),(0,$.jsx)(Rt,{timeZone:i.data?.timeZone})]}),(0,$.jsx)(K,{provider:e})]})}function On(e){return{name:e.name,apiKey:``,endpoints:e.endpoints,preferredUpstreamProtocols:e.preferredUpstreamProtocols,authScheme:e.authScheme,extraHeaders:e.extraHeaders,httpProxy:e.httpProxy??null,priceMultiplier:e.priceMultiplier,priceKey:e.priceKey??null,settings:e.settings,enabled:e.enabled,notes:e.notes??null}}function kn({provider:t}){let{t:n}=T(),{toast:r}=U(),i=Fe(t.id),a=e(),o=(0,Q.useMemo)(()=>On(t),[t]),[s,c]=(0,Q.useState)(o),[l,u]=(0,Q.useState)(Object.entries(t.extraHeaders)),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{c(o),u(Object.entries(o.extraHeaders))},[o]);let h=e=>c(t=>({...t,...e})),g={...s,extraHeaders:Object.fromEntries(l.filter(([e])=>e.trim()))},_=JSON.stringify(g)!==JSON.stringify(o),v=()=>{let e={};for(let t of Object.keys(g))t!==`apiKey`&&JSON.stringify(g[t])!==JSON.stringify(o[t])&&(e[t]=g[t]);s.apiKey&&(e.apiKey=s.apiKey),i.mutate(e,{onSuccess:()=>r(n(`common.saved`),`success`),onError:e=>r(V(e),`error`)})},y=(e,t)=>h({endpoints:s.endpoints.map((n,r)=>r===e?{...n,...t}:n)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(L,{title:n(`providers.section.basic`),children:[(0,$.jsx)(k,{label:n(`providers.name`),children:(0,$.jsx)(E,{className:`w-64`,"aria-label":n(`providers.name`),value:s.name,onChange:e=>h({name:e.target.value})})}),(0,$.jsx)(k,{label:n(`common.enabled`),children:(0,$.jsx)(B,{checked:s.enabled,label:n(`common.enabled`),onChange:e=>h({enabled:e})})}),(0,$.jsx)(k,{label:n(`providers.notes`),children:(0,$.jsx)(E,{className:`w-64`,"aria-label":n(`providers.notes`),value:s.notes??``,onChange:e=>h({notes:e.target.value||null})})})]}),(0,$.jsx)(L,{title:n(`providers.section.auth`),children:(0,$.jsx)(k,{label:n(`providers.authScheme`),children:(0,$.jsx)(W,{className:`w-48`,value:s.authScheme,onChange:e=>h({authScheme:e}),options:Je})})}),(0,$.jsxs)(L,{title:n(`providers.section.endpoints`),footer:n(`providers.endpointsFooter`),children:[s.endpoints.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 py-3`,children:[(0,$.jsx)(W,{className:`w-48`,value:e.protocol,onChange:e=>y(t,{protocol:e}),options:Ge}),(0,$.jsx)(E,{className:`min-w-60 flex-1 font-mono`,"aria-label":n(`providers.baseUrl`),value:e.baseUrl,onChange:e=>y(t,{baseUrl:e.target.value})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(B,{checked:!!e.fullUrl,label:n(`providers.fullUrl`),onChange:e=>y(t,{fullUrl:e})}),n(`providers.fullUrl`)]}),(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(X,{className:`size-3.5`}),"aria-label":n(`common.delete`),onClick:()=>h({endpoints:s.endpoints.filter((e,n)=>n!==t)})})]},t)),(0,$.jsx)(`div`,{className:`px-4 py-2`,children:(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(Y,{className:`size-3.5`}),onClick:()=>f(!0),children:n(`providers.addEndpoint`)})}),(0,$.jsx)(k,{label:n(`providers.preferred`),detail:(0,$.jsxs)($.Fragment,{children:[n(`providers.preferredHint`),s.preferredUpstreamProtocols.filter(e=>!s.endpoints.some(t=>t.protocol===e)).map(e=>(0,$.jsx)(`span`,{className:`mt-1 block text-[var(--warning)]`,children:n(`providers.preferredMissing`,{protocol:Ge.find(t=>t.value===e)?.label??e})},e))]}),children:(0,$.jsx)(ht,{label:n(`providers.preferred`),options:Ge.map(e=>{let t=s.preferredUpstreamProtocols.indexOf(e.value);return{value:e.value,label:t>=0?`${t+1}. ${e.label}`:e.label}}),value:s.preferredUpstreamProtocols,onValueChange:e=>{let t=s.preferredUpstreamProtocols.filter(t=>e.includes(t)),n=e.filter(e=>!t.includes(e));h({preferredUpstreamProtocols:[...t,...n]})}})})]}),(0,$.jsxs)(L,{title:n(`providers.section.billing`),footer:n(`providers.billingFooter`),children:[(0,$.jsx)(k,{label:n(`providers.priceKey`),detail:n(`providers.priceKeyHint`),children:(0,$.jsx)(W,{className:`w-56`,value:s.priceKey==null?`inherit`:`price:${s.priceKey}`,onChange:e=>h({priceKey:e===`inherit`?null:e.slice(6)}),options:[{value:`inherit`,label:n(`providers.priceKeyDefault`,{id:t.templateId??`—`})},{value:`price:`,label:n(`providers.priceKeyNone`)},...(a.data??[]).map(e=>({value:`price:${e.priceKey}`,label:e.label,detail:e.priceKey}))]})}),(0,$.jsx)(k,{label:n(`providers.multiplier`),detail:n(`providers.multiplierHint`),children:(0,$.jsx)(N,{className:`w-28`,label:n(`providers.multiplier`),step:.01,min:0,value:s.priceMultiplier,onChange:e=>h({priceMultiplier:e??1})})})]}),(0,$.jsxs)(L,{title:n(`providers.section.advanced`),children:[(0,$.jsx)(k,{label:n(`providers.proxy`),detail:n(`providers.proxyHint`),children:(0,$.jsx)(E,{className:`w-64 font-mono`,"aria-label":n(`providers.proxy`),placeholder:`http://127.0.0.1:7890`,value:s.httpProxy??``,onChange:e=>h({httpProxy:e.target.value||null})})}),(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-[13px]`,children:n(`providers.headers`)}),l.map(([e,t],r)=>(0,$.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,$.jsx)(E,{className:`w-48 font-mono`,"aria-label":n(`providers.headerName`),placeholder:`Header`,value:e,onChange:e=>u(l.map((t,n)=>n===r?[e.target.value,t[1]]:t))}),(0,$.jsx)(E,{className:`flex-1 font-mono`,"aria-label":n(`providers.headerValue`),placeholder:`value`,value:t,onChange:e=>u(l.map((t,n)=>n===r?[t[0],e.target.value]:t))}),(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(X,{className:`size-3.5`}),"aria-label":n(`common.delete`),onClick:()=>u(l.filter((e,t)=>t!==r))})]},r)),(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(Y,{className:`size-3.5`}),onClick:()=>m(!0),children:n(`providers.addHeader`)})]}),Object.keys(t.settings).length>0&&(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsx)(me,{label:n(`providers.adapterSettings`),rows:4,className:`w-full font-mono`,defaultValue:je(s.settings),onBlur:e=>{try{h({settings:JSON.parse(e.target.value)})}catch{r(n(`common.invalidJson`),`error`)}}})})]}),(0,$.jsx)(L,{title:n(`providers.section.info`),children:(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(D,{label:`ID`,children:t.id}),t.adapterId&&(0,$.jsx)(D,{label:n(`providers.adapter`),children:t.adapterId}),(0,$.jsx)(D,{label:n(`providers.boundClients`),children:t.boundClients.map(e=>lt[e]?.name??e).join(`, `)||`—`})]})}),(0,$.jsx)(An,{open:d,onOpenChange:f,onAdd:e=>h({endpoints:[...s.endpoints,e]})}),(0,$.jsx)(jn,{open:p,onOpenChange:m,onAdd:e=>u([...l.filter(([t])=>t.toLowerCase()!==e[0].toLowerCase()),e])}),(0,$.jsx)(`div`,{className:`sticky bottom-2 flex justify-end`,children:_&&(0,$.jsxs)(`div`,{className:`glass flex items-center gap-2 rounded-full p-1 pl-4 text-[12px]`,children:[(0,$.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:n(`common.unsaved`)}),(0,$.jsx)(F,{size:`sm`,onClick:()=>{c(o),u(Object.entries(o.extraHeaders))},children:n(`common.revert`)}),(0,$.jsx)(F,{size:`sm`,variant:`primary`,loading:i.isPending,onClick:v,children:n(`common.save`)})]})})]})}function An({open:e,onOpenChange:t,onAdd:n}){let{t:r}=T(),[i,a]=(0,Q.useState)(`openai-chat`),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{e&&(s(``),l(!1))},[e]);let u=/^https?:\/\/\S+$/.test(o.trim());return(0,$.jsx)(H,{open:e,onOpenChange:t,title:r(`providers.addEndpoint`),description:r(`providers.addEndpointDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:!u,onClick:()=>{n({protocol:i,baseUrl:o.trim(),...c?{fullUrl:!0}:{}}),t(!1)},children:r(`common.add`)})]}),children:(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsx)(O,{label:r(`providers.protocol`),children:(0,$.jsx)(W,{value:i,onChange:a,options:Ge})}),(0,$.jsx)(O,{label:r(`providers.baseUrl`),hint:r(c?`providers.fullUrlHint`:`providers.baseUrlHint`),children:(0,$.jsx)(E,{autoFocus:!0,className:`font-mono`,placeholder:`https://api.example.com/v1`,value:o,invalid:o!==``&&!u,onChange:e=>s(e.target.value)})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(B,{checked:c,onChange:l,label:r(`providers.fullUrl`)}),r(`providers.fullUrl`)]})]})})}function jn({open:e,onOpenChange:t,onAdd:n}){let{t:r}=T(),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&(a(``),s(``))},[e]);let c=/^[A-Za-z0-9-]+$/.test(i.trim());return(0,$.jsx)(H,{open:e,onOpenChange:t,title:r(`providers.addHeader`),description:r(`providers.addHeaderDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:!c,onClick:()=>{n([i.trim(),o]),t(!1)},children:r(`common.add`)})]}),children:(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsx)(O,{label:r(`providers.headerName`),children:(0,$.jsx)(E,{autoFocus:!0,className:`font-mono`,placeholder:`X-Custom-Header`,value:i,invalid:i!==``&&!c,onChange:e=>a(e.target.value)})}),(0,$.jsx)(O,{label:r(`providers.headerValue`),children:(0,$.jsx)(E,{className:`font-mono`,value:o,onChange:e=>s(e.target.value)})})]})})}export{hn as ProviderDetailPage};