@aidotnet/server-linux-x64 0.14.3100 → 0.14.3102

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 (42) hide show
  1. package/bin/astra-server +2 -2
  2. package/bin/wwwroot/assets/{ClientsPage-GKLy8gVJ.js → ClientsPage-CcRyNV5u.js} +1 -1
  3. package/bin/wwwroot/assets/{KeyPage-BbUpGlKO.js → KeyPage-DBEozu4C.js} +1 -1
  4. package/bin/wwwroot/assets/{ModelDetailPage-BlmQDuE3.js → ModelDetailPage-DsuE2gLp.js} +1 -1
  5. package/bin/wwwroot/assets/{ModelsPage-Ckhg7YdH.js → ModelsPage--EjkhnLC.js} +1 -1
  6. package/bin/wwwroot/assets/{PluginsPage-Dwqhs5tw.js → PluginsPage-B4wswSWs.js} +1 -1
  7. package/bin/wwwroot/assets/{PrivacyPage-CJ5wbjXl.js → PrivacyPage-DtowG3QB.js} +1 -1
  8. package/bin/wwwroot/assets/ProviderDetailPage-Cc5KTl0J.js +3 -0
  9. package/bin/wwwroot/assets/{ProvidersPage-B7az1p0j.js → ProvidersPage-D4cQrTgo.js} +1 -1
  10. package/bin/wwwroot/assets/{SettingsPage-Dm7rhdEx.js → SettingsPage-Ab6k-ndX.js} +2 -2
  11. package/bin/wwwroot/assets/{SmartRoutingPage-Dww5ODy8.js → SmartRoutingPage-Ca6ZC-sk.js} +1 -1
  12. package/bin/wwwroot/assets/{TokenDetailPage-bcWwe6SL.js → TokenDetailPage-tNGeSuwb.js} +1 -1
  13. package/bin/wwwroot/assets/{TokenPoolEditor-DBLRdef1.js → TokenPoolEditor-BANCSW9l.js} +1 -1
  14. package/bin/wwwroot/assets/{TokensPage-DCaUOp7X.js → TokensPage-Ak52kWw6.js} +1 -1
  15. package/bin/wwwroot/assets/{TracesPage-CM7kpC2L.js → TracesPage-DgaPoaqm.js} +1 -1
  16. package/bin/wwwroot/assets/{TrayPanelPage-Dxk8NHwD.js → TrayPanelPage-j67xTz4h.js} +1 -1
  17. package/bin/wwwroot/assets/{TrayPanelView-BZQT4C-p.js → TrayPanelView-Cl2xyavV.js} +1 -1
  18. package/bin/wwwroot/assets/{alert-0ugPccg1.js → alert-DpRdHImb.js} +2 -2
  19. package/bin/wwwroot/assets/{arrow-down-BzJcdsh0.js → arrow-down-BxJ88yaJ.js} +1 -1
  20. package/bin/wwwroot/assets/{arrow-left-CvdkAxjP.js → arrow-left-B3Ql-3af.js} +1 -1
  21. package/bin/wwwroot/assets/{arrow-up-right-DEmTMRN5.js → arrow-up-right-QVW-fAFr.js} +1 -1
  22. package/bin/wwwroot/assets/{chart-column-4_Hcd7LI.js → chart-column-D6AP76ve.js} +1 -1
  23. package/bin/wwwroot/assets/{checkbox-DAvFpCMa.js → checkbox-3cbHcFXQ.js} +1 -1
  24. package/bin/wwwroot/assets/{cloud-download-D0cpRWOi.js → cloud-download-d2J3TjHp.js} +1 -1
  25. package/bin/wwwroot/assets/{confirm-morph-Df4YMElg.js → confirm-morph-Dpiz2iAT.js} +1 -1
  26. package/bin/wwwroot/assets/{download-DZCHLDt2.js → download-BF1gj38s.js} +1 -1
  27. package/bin/wwwroot/assets/{ellipsis-CdooFypb.js → ellipsis-2ewY1Pkj.js} +1 -1
  28. package/bin/wwwroot/assets/{external-link-CS7Gd3Z_.js → external-link-Ba13ucfD.js} +1 -1
  29. package/bin/wwwroot/assets/{folder-open-BZjDCbYy.js → folder-open-DTgeVtUv.js} +1 -1
  30. package/bin/wwwroot/assets/{index-COgqKK9s.js → index-YcD3CI_o.js} +3 -3
  31. package/bin/wwwroot/assets/{log-out-DVIVn0JF.js → log-out-DOtmyFi6.js} +1 -1
  32. package/bin/wwwroot/assets/minus-CSv_UD8H.js +1 -0
  33. package/bin/wwwroot/assets/{overlays-Dd-xCJQp.js → overlays-Ca_JSpnI.js} +1 -1
  34. package/bin/wwwroot/assets/{pencil-BbgAhLbU.js → pencil-CFjPUH1Y.js} +1 -1
  35. package/bin/wwwroot/assets/{power-CYbRvApU.js → power-10gcP_1M.js} +1 -1
  36. package/bin/wwwroot/assets/{radio-cards-C2kL9-Ki.js → radio-cards-CWs2Sjuq.js} +1 -1
  37. package/bin/wwwroot/assets/{rotate-ccw-CIB2qh-N.js → rotate-ccw-C3uEcj_6.js} +1 -1
  38. package/bin/wwwroot/assets/{sortable.esm-BXvWgOQ9.js → sortable.esm-Vg9V11Ab.js} +1 -1
  39. package/bin/wwwroot/index.html +3 -3
  40. package/package.json +1 -1
  41. package/bin/wwwroot/assets/ProviderDetailPage-Dxu9JADF.js +0 -3
  42. package/bin/wwwroot/assets/minus-P2gia-qN.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: 54279128 bytes
4
- sha256: fb650848d1e22a5ac7c19bce41681cca142d3fe49b8c5b5f940d3242a0b5c5d8
3
+ size: 54320808 bytes
4
+ sha256: e77c978cd460259ed308d4ce11d772ddbb880ccb811bfe7bc61de3f53587d844
@@ -1,4 +1,4 @@
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-0ugPccg1.js";import{a as R,ct as z,i as le,o as B,r as V,st as ue}from"./overlays-Dd-xCJQp.js";import{n as H}from"./ProvidersPage-B7az1p0j.js";import{t as de}from"./download-DZCHLDt2.js";import{t as fe}from"./external-link-CS7Gd3Z_.js";import{t as pe}from"./folder-open-BZjDCbYy.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-BXvWgOQ9.js";import{t as Se}from"./rotate-ccw-CIB2qh-N.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-COgqKK9s.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(`
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-DpRdHImb.js";import{a as R,ct as z,i as le,o as B,r as V,st as ue}from"./overlays-Ca_JSpnI.js";import{n as H}from"./ProvidersPage-D4cQrTgo.js";import{t as de}from"./download-BF1gj38s.js";import{t as fe}from"./external-link-Ba13ucfD.js";import{t as pe}from"./folder-open-DTgeVtUv.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-Vg9V11Ab.js";import{t as Se}from"./rotate-ccw-C3uEcj_6.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-YcD3CI_o.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
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
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
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(`
@@ -1 +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-0ugPccg1.js";import{_ as v,j as y,k as b}from"./index-COgqKK9s.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};
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-DpRdHImb.js";import{_ as v,j as y,k as b}from"./index-YcD3CI_o.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};
@@ -1 +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-0ugPccg1.js";import{a as w,i as T,o as E,r as D}from"./overlays-Dd-xCJQp.js";import{t as O}from"./arrow-left-CvdkAxjP.js";import{t as k}from"./pencil-BbgAhLbU.js";import{t as A}from"./rotate-ccw-CIB2qh-N.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-COgqKK9s.js";import{t as I}from"./checkbox-DAvFpCMa.js";import{t as L}from"./confirm-morph-Df4YMElg.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};
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-DpRdHImb.js";import{a as w,i as T,o as E,r as D}from"./overlays-Ca_JSpnI.js";import{t as O}from"./arrow-left-B3Ql-3af.js";import{t as k}from"./pencil-CFjPUH1Y.js";import{t as A}from"./rotate-ccw-C3uEcj_6.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-YcD3CI_o.js";import{t as I}from"./checkbox-3cbHcFXQ.js";import{t as L}from"./confirm-morph-Dpiz2iAT.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};
@@ -1 +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-0ugPccg1.js";import{a as x,i as S,o as C,r as w}from"./overlays-Dd-xCJQp.js";import{t as T}from"./cloud-download-D0cpRWOi.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-COgqKK9s.js";import{t as P}from"./checkbox-DAvFpCMa.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};
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-DpRdHImb.js";import{a as x,i as S,o as C,r as w}from"./overlays-Ca_JSpnI.js";import{t as T}from"./cloud-download-d2J3TjHp.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-YcD3CI_o.js";import{t as P}from"./checkbox-3cbHcFXQ.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};
@@ -1,2 +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-0ugPccg1.js";import{a as F,i as I,n as te,o as L}from"./overlays-Dd-xCJQp.js";import{t as ne}from"./arrow-down-BzJcdsh0.js";import{t as re}from"./download-DZCHLDt2.js";import{t as ie}from"./ellipsis-CdooFypb.js";import{t as ae}from"./external-link-CS7Gd3Z_.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-COgqKK9s.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(`
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-DpRdHImb.js";import{a as F,i as I,n as te,o as L}from"./overlays-Ca_JSpnI.js";import{t as ne}from"./arrow-down-BxJ88yaJ.js";import{t as re}from"./download-BF1gj38s.js";import{t as ie}from"./ellipsis-2ewY1Pkj.js";import{t as ae}from"./external-link-Ba13ucfD.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-YcD3CI_o.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
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};
@@ -1 +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-0ugPccg1.js";import{a as I,i as ne,o as L,r as R}from"./overlays-Dd-xCJQp.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-COgqKK9s.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};
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-DpRdHImb.js";import{a as I,i as ne,o as L,r as R}from"./overlays-Ca_JSpnI.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-YcD3CI_o.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};