@aidotnet/server-linux-arm64 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/bin/astra-server +2 -2
  2. package/bin/wwwroot/assets/{ClientsPage-CwrpIsjp.js → ClientsPage-B89Sa7jz.js} +2 -2
  3. package/bin/wwwroot/assets/{ModelDetailPage-CDrpIJ2a.js → ModelDetailPage-CIr2VLVH.js} +1 -1
  4. package/bin/wwwroot/assets/{ModelsPage-C0SIEL78.js → ModelsPage-DHoSwTY5.js} +1 -1
  5. package/bin/wwwroot/assets/{Page-D9s9brqr.js → Page-CnSErb_N.js} +1 -1
  6. package/bin/wwwroot/assets/PluginsPage-54tF_bjG.js +2 -0
  7. package/bin/wwwroot/assets/{PrivacyPage-B_Gvd1LU.js → PrivacyPage-D5paxuYA.js} +1 -1
  8. package/bin/wwwroot/assets/{ProviderDetailPage-VHzmmtBT.js → ProviderDetailPage-DhxcWbc_.js} +1 -1
  9. package/bin/wwwroot/assets/{ProvidersPage-Dj_CsU72.js → ProvidersPage-DfMcnoYT.js} +1 -1
  10. package/bin/wwwroot/assets/{SettingsPage-BKlK87nl.js → SettingsPage-a1XhJ-l9.js} +1 -1
  11. package/bin/wwwroot/assets/{TokensPage-RhLk-cLA.js → TokensPage-T2w5pi_o.js} +1 -1
  12. package/bin/wwwroot/assets/{TrayPanelPage-glZe4Vli.js → TrayPanelPage-DOmKXJLy.js} +1 -1
  13. package/bin/wwwroot/assets/{TrayPanelView-BPGmNn0R.js → TrayPanelView-BcmaqvCD.js} +1 -1
  14. package/bin/wwwroot/assets/{arrow-down-dwUtKoOn.js → arrow-down-CXkFrvO0.js} +1 -1
  15. package/bin/wwwroot/assets/{arrow-up-DFb4XkB6.js → arrow-up-BfREUNOR.js} +1 -1
  16. package/bin/wwwroot/assets/{checkbox-w2_7QuDk.js → checkbox-RGYPqY5w.js} +1 -1
  17. package/bin/wwwroot/assets/{cloud-download-C1VSdmBb.js → cloud-download-D865MmmV.js} +1 -1
  18. package/bin/wwwroot/assets/{confirm-morph-B9k3rCnO.js → confirm-morph-DUNuG_Io.js} +1 -1
  19. package/bin/wwwroot/assets/{download-DoTXPUWy.js → download-CMr38kbd.js} +1 -1
  20. package/bin/wwwroot/assets/{ellipsis-B2d4aPpF.js → ellipsis-zTWIrsa4.js} +1 -1
  21. package/bin/wwwroot/assets/{external-link-DhHaJlE-.js → external-link-BSHuW87X.js} +1 -1
  22. package/bin/wwwroot/assets/{folder-open-DC0j6uC-.js → folder-open-Ce_7X0wN.js} +1 -1
  23. package/bin/wwwroot/assets/{index-br322rzz.js → index-PfVyiY3J.js} +3 -3
  24. package/bin/wwwroot/assets/{index-C8BQ1yWd.css → index-uU60OHOr.css} +1 -1
  25. package/bin/wwwroot/assets/{log-out-CtwqdEhG.js → log-out-CXVs8bJY.js} +1 -1
  26. package/bin/wwwroot/assets/{overlays-CnzrFKmb.js → overlays-D1ZtG8Qn.js} +3 -3
  27. package/bin/wwwroot/assets/{pencil-nlLBeib5.js → pencil-DyidL-8l.js} +1 -1
  28. package/bin/wwwroot/assets/{power-DQiCs26X.js → power-CJZylS33.js} +1 -1
  29. package/bin/wwwroot/assets/{radio-cards-Byb8E5K7.js → radio-cards-QHFaDooy.js} +1 -1
  30. package/bin/wwwroot/assets/{rotate-ccw-BLaDyhPe.js → rotate-ccw-Dr0Xbikv.js} +1 -1
  31. package/bin/wwwroot/assets/{use-transform-C8au3Jv4.js → use-transform-DvOb1h9g.js} +1 -1
  32. package/bin/wwwroot/index.html +6 -6
  33. package/package.json +1 -1
  34. package/bin/wwwroot/assets/PluginsPage-CU6HnW-3.js +0 -2
@@ -1,2 +1,2 @@
1
- import{$t as e,A as t,An as n,B as r,C as i,Cn as a,D as o,Di as s,E as c,F as l,Fa as u,Fi as d,G as f,H as p,I as m,Ia as h,J as g,Jr as _,K as v,N as y,O as b,Oi as x,P as S,Pa as C,R as w,T,Tn as E,U as D,V as O,Vr as k,W as A,Wi as j,X as M,Xn as N,Xr as P,Y as F,Yr as ee,Z as I,Zt as L,a as R,aa as te,cr as z,di as B,dn as ne,dt as V,en as H,et as re,gr as U,hr as ie,i as ae,ia as W,k as oe,ki as se,lt as ce,mn as le,na as ue,nn as de,nt as G,o as fe,oa as K,r as pe,ra as me,rn as he,rt as ge,sn as _e,ta as q,tn as ve,w as ye,z as be,za as xe,zt as Se}from"./overlays-CnzrFKmb.js";import{t as Ce}from"./use-transform-C8au3Jv4.js";import{S as we,a as Te,b as Ee,f as De,n as Oe,s as ke,t as Ae}from"./Page-D9s9brqr.js";import{n as je,t as Me}from"./checkbox-w2_7QuDk.js";import{t as Ne}from"./download-DoTXPUWy.js";import{C as Pe,O as Fe,h as Ie,k as Le,m as Re,p as ze,u as Be,x as Ve}from"./index-br322rzz.js";import{t as He}from"./radio-cards-Byb8E5K7.js";var J=xe(h(),1);function Ue(e,t,n){(0,J.useInsertionEffect)(()=>e.on(t,n),[e,t,n])}var We={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};We.node;var Ge=V(We),Ke={name:`flask-conical`,size:24,node:[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]};Ke.node;var qe=V(Ke),Je={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};Je.node;var Ye=V(Je),Xe={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Xe.node;var Ze=V(Xe),Y={card:`_card_i7fo0_3`,trigger:`_trigger_i7fo0_6`,media:`_media_i7fo0_7`,zoom:`_zoom_i7fo0_8`,content:`_content_i7fo0_9`,description:`_description_i7fo0_12`,footer:`_footer_i7fo0_13`,title:`_title_i7fo0_15`,byline:`_byline_i7fo0_22`,avatar:`_avatar_i7fo0_23`,bylineText:`_bylineText_i7fo0_26`,meta:`_meta_i7fo0_27`,status:`_status_i7fo0_28`,roll:`_roll_i7fo0_30`,line:`_line_i7fo0_31`,word:`_word_i7fo0_32`,srOnly:`_srOnly_i7fo0_33`,action:`_action_i7fo0_34`,overlay:`_overlay_i7fo0_36`,panel:`_panel_i7fo0_38`,closeSlot:`_closeSlot_i7fo0_48`,close:`_close_i7fo0_48`,details:`_details_i7fo0_51`},X=u(),{blur:Qe,duration:Z,ease:$e,spring:et,stagger:tt}=G,nt={...et.smooth,visualDuration:.3},rt={...et.smooth,visualDuration:.26},it=300,at={duration:Z.instant},ot=1.04,st={duration:Z.considered*2,ease:[...$e.standard]},ct={duration:Z.considered,ease:[...$e.standard]},lt={delay:Z.instant,duration:Z.standard,ease:[...$e.enter]},ut={delay:Z.instant,duration:Z.fast,ease:[...$e.enter]},dt={enter:{},center:{},exit:{opacity:0,y:`-.3em`,filter:`blur(${Qe.subtle}px)`,transition:{duration:Z.fast,ease:[...$e.standard]}}},ft={enter:{opacity:0,y:`.3em`,filter:`blur(${Qe.soft}px)`},center:e=>({opacity:1,y:0,filter:`blur(0px)`,transition:{duration:Z.standard,ease:[...$e.enter],delay:e*tt.word}})};function pt({text:e,reduced:t}){return(0,X.jsxs)(`span`,{className:Y.status,role:`status`,children:[(0,X.jsx)(`span`,{className:Y.srOnly,children:e}),(0,X.jsx)(`span`,{className:Y.roll,"aria-hidden":`true`,children:(0,X.jsx)(K,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(q.span,{className:Y.line,variants:dt,initial:!t&&`enter`,animate:`center`,exit:t?void 0:`exit`,children:e.split(/(\s+)/).map((e,t)=>(0,X.jsx)(q.span,{className:Y.word,custom:t/2,variants:ft,children:e},t))},e)})})]})}function mt(e,t){let n=parseFloat(t);if(Number.isFinite(n))return t.trim().endsWith(`rem`)?n*parseFloat(getComputedStyle(e.ownerDocument.documentElement).fontSize):n}function ht({title:e,description:n,media:r,action:a,avatar:s,meta:l,status:u,details:d,open:f,defaultOpen:p=!1,onOpenChange:m,children:h,className:g,style:_,...v}){let y=me()??!1,x=(0,J.useId)(),S=(0,J.useRef)(null),C=(0,J.useRef)(null),[w,E]=(0,J.useState)(p),[D,O]=(0,J.useState)(!1),[k,A]=(0,J.useState)({}),[j,M]=(0,J.useState)(null),N=d?f??w:!1,P=!!d&&!y,F=!N&&j!==null,ee=!!n,I=(0,J.useCallback)(e=>{f===void 0&&E(e),m?.(e)},[f,m]);(0,J.useEffect)(()=>{let e=S.current,t=C.current;if(!P||!e||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>{let n=getComputedStyle(e),r=mt(e,n.borderTopLeftRadius),i=mt(e,n.getPropertyValue(`--radius-surface`)),a=t?.offsetWidth||void 0;A(e=>e.card!==void 0&&e.measure===a?e:{card:e.card??r,panel:e.panel??i,measure:a})});return n.observe(e),t&&n.observe(t),()=>n.disconnect()},[P,ee]);let L=(0,J.useRef)(N);(0,J.useLayoutEffect)(()=>{let e=L.current&&!N;L.current=N;let t=S.current;if(N)M(null);else if(e&&P&&t){let e=t.getBoundingClientRect();M({top:e.top,left:e.left,width:e.width,height:e.height})}},[N,P]),(0,J.useEffect)(()=>{if(!F)return;let e=window.setTimeout(()=>M(null),it);return()=>window.clearTimeout(e)},[F]);let R=(e,t,n=!0)=>P?{layoutId:e,layout:n,layoutCrossfade:!1,layoutDependency:t===`card`?N:F?`return`:`panel`,transition:{layout:t===`card`?rt:nt}}:{},z=e=>s||l||u||a?(0,X.jsxs)(`div`,{className:Y.footer,children:[s||l||u?(0,X.jsxs)(q.div,{className:Y.byline,...R(`byline`,e,`position`),children:[s?(0,X.jsx)(`span`,{className:Y.avatar,children:s}):null,(0,X.jsxs)(`span`,{className:Y.bylineText,children:[l?(0,X.jsx)(`span`,{className:Y.meta,children:l}):null,u?(0,X.jsx)(pt,{text:u,reduced:y}):null]})]}):null,a?(0,X.jsx)(q.div,{className:Y.action,...R(`action`,e,`position`),children:a}):null]}):null,B=(0,X.jsxs)(q.article,{...v,ref:S,className:[Y.card,g].filter(Boolean).join(` `),style:{..._,borderRadius:k.card??_?.borderRadius},"data-hover":D||void 0,whileHover:y?void 0:{y:-2},onHoverStart:()=>O(!0),onHoverEnd:()=>O(!1),...R(`card`,`card`),transition:{default:et.snappy,layout:rt},children:[r?(0,X.jsx)(q.div,{className:Y.media,...R(`media`,`card`),children:(0,X.jsx)(q.div,{className:Y.zoom,initial:!1,animate:{scale:D&&!y?ot:1},transition:D?st:ct,children:r})}):null,(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(q.h3,{className:Y.title,...R(`title`,`card`),children:d?(0,X.jsx)(t,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:Y.trigger,children:e})}):e}),n?(0,X.jsx)(q.p,{ref:C,className:Y.description,...R(`description`,`card`,`position`),children:n}):null,h,z(`card`)]})]});return d?(0,X.jsx)(i,{open:N,onOpenChange:I,children:(0,X.jsxs)(te,{id:x,children:[B,(0,X.jsx)(K,{children:(N||F)&&(0,X.jsxs)(b,{forceMount:!0,children:[(0,X.jsx)(K,{children:N&&(0,X.jsx)(o,{asChild:!0,forceMount:!0,children:(0,X.jsx)(q.div,{className:Y.overlay,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:y?at:{duration:Z.exit,ease:[...$e.standard]}},transition:y?at:{duration:Z.standard,ease:[...$e.enter]}})},`overlay`)}),(0,X.jsx)(T,{asChild:!0,forceMount:!0,...n?{}:{"aria-describedby":void 0},children:(0,X.jsxs)(q.div,{className:Y.panel,"data-framer-portal-id":x,"data-returning":F||void 0,layoutScroll:!0,style:{borderRadius:k.panel,"--card-measure":k.measure?`${k.measure}px`:void 0,...j&&F?{"--landing-top":`${j.top}px`,"--landing-left":`${j.left}px`,"--landing-width":`${j.width}px`,"--landing-height":`${j.height}px`}:{}},...P?{...R(`card`,`panel`),initial:!1,animate:k.card!==void 0&&k.panel!==void 0?{borderRadius:F?k.card:k.panel}:void 0,transition:{layout:F?rt:nt,borderRadius:F?rt:nt},exit:{opacity:0,transition:{duration:0}}}:{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:at},transition:at},children:[r?(0,X.jsx)(q.div,{className:Y.media,...R(`media`,`panel`),children:(0,X.jsx)(q.div,{className:Y.zoom,initial:{scale:D&&!y?ot:1},animate:{scale:1},transition:nt,children:r})}):null,(0,X.jsx)(q.span,{className:Y.closeSlot,initial:y?{opacity:0}:{opacity:0,scale:.9},animate:F?{opacity:0,scale:.9}:{opacity:1,scale:1},transition:F||y?at:ut,children:(0,X.jsx)(ye,{asChild:!0,children:(0,X.jsx)(q.button,{type:`button`,className:Y.close,"aria-label":`Close quick look`,whileTap:y?void 0:{scale:.94},transition:et.snappy,children:(0,X.jsx)(ge,{width:16,height:16,strokeWidth:1.75,"aria-hidden":`true`})})})}),(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(oe,{asChild:!0,children:(0,X.jsx)(q.h2,{className:Y.title,...R(`title`,`panel`),children:e})}),n?(0,X.jsx)(c,{asChild:!0,children:(0,X.jsx)(q.p,{className:Y.description,...R(`description`,`panel`,`position`),children:n})}):null,h,z(`panel`),(0,X.jsx)(q.div,{className:Y.details,initial:!y&&{opacity:0,y:6},animate:F?{opacity:0,y:0}:{opacity:1,y:0},exit:{opacity:0,transition:at},transition:F||y?at:lt,children:d})]})]})})]},`quick-look`)})]})}):B}var Q={figure:`_figure_1clu4_1`,caption:`_caption_1clu4_1`,label:`_label_1clu4_1`,accent:`_accent_1clu4_2`,success:`_success_1clu4_2`,warning:`_warning_1clu4_2`,danger:`_danger_1clu4_2`,point:`_point_1clu4_4`,roll:`_roll_1clu4_7`,track:`_track_1clu4_9`,slot:`_slot_1clu4_9`,glyph:`_glyph_1clu4_9`,sizer:`_sizer_1clu4_11`,plot:`_plot_1clu4_14`,chart:`_chart_1clu4_17`,baseline:`_baseline_1clu4_18`,area:`_area_1clu4_20`,line:`_line_1clu4_21`,trail:`_trail_1clu4_21`,cursor:`_cursor_1clu4_24`,end:`_end_1clu4_25`},gt={hidden:e=>({opacity:0,y:`${.3*e}em`,filter:`blur(${G.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:G.duration.standard,ease:[...G.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${G.blur.subtle}px)`,transition:{duration:G.duration.fast,ease:[...G.ease.standard]}})},_t={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:G.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:G.duration.instant}}},vt=e=>Number(e.replace(/,/g,``).replace(/−/g,`-`).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN),yt=new Intl.NumberFormat(`en-US`),bt={duration:G.duration.considered*1.75,ease:[...G.ease.inOut]},xt={duration:G.duration.fast,ease:[...G.ease.standard]};function St(e,t){if(!e)return[];if(t)return[{slot:`all`,key:e,text:e}];if(!/\p{L}/u.test(e))return[...e].map((e,t,n)=>({slot:`n${n.length-t}`,key:e,text:e}));let n=e.split(/(?<=\s)/);return n.map((e,t)=>({slot:`w${t}`,key:n.slice(0,t+1).join(``),text:e}))}function Ct({text:e,direction:t,whole:n=!1,morph:r=!1,tone:i}){let a=!!me(),o=(0,J.useRef)(null),s=W(`auto`),[c,l]=(0,J.useState)({text:e,direction:1});c.text!==e&&l({text:e,direction:t??(vt(e)<vt(c.text)?-1:1)}),(0,J.useEffect)(()=>{let e=o.current;if(!e||typeof ResizeObserver>`u`)return;let t=null,n=new ResizeObserver(([n])=>{if(!n)return;let r=n.borderBoxSize?.[0]?.inlineSize??e.offsetWidth;t!==null&&t!==e.textContent&&!a?ue(s,r,G.spring.morph):s.jump(r),t=e.textContent});return n.observe(e),()=>n.disconnect()},[r,a,s]);let u=!n&&!/\p{L}/u.test(e),d=a?_t:gt,f=u?`right`:`left`;return(0,X.jsxs)(q.span,{className:Q.roll,"data-end":u||void 0,"data-whole":n||void 0,style:r?{width:s}:void 0,children:[r&&(0,X.jsx)(`span`,{ref:o,className:Q.sizer,"aria-hidden":`true`,children:e}),(0,X.jsx)(`span`,{className:Q.track,children:(0,X.jsx)(K,{mode:`popLayout`,initial:!1,custom:c.direction,anchorX:f,children:St(e,n).map(e=>(0,X.jsx)(q.span,{className:Q.slot,custom:c.direction,variants:d,initial:`hidden`,animate:`shown`,exit:`gone`,children:(0,X.jsx)(K,{mode:`popLayout`,initial:!1,custom:c.direction,anchorX:f,children:(0,X.jsx)(q.span,{className:i?`${Q.glyph} ${i}`:Q.glyph,custom:c.direction,variants:d,initial:`hidden`,animate:`shown`,exit:`gone`,children:e.text},`${i??``}${e.key}`)})},e.slot))})})]})}var wt=5,Tt=1.25,Et=Array.from({length:161},(e,t)=>t/160);function Dt(e){let t=Math.min(...e),n=Math.max(...e)-t,r=e.map(e=>n?(e-t)/n:.5),i=r.length-1,a=1/i,o=r.slice(1).map((e,t)=>(e-r[t])/a),s=r.map((e,t)=>t===0||t===i?o[0]:(Math.sign(o[t-1])+Math.sign(o[t]))*Math.min(Math.abs(o[t-1]),Math.abs(o[t]),Math.abs(o[t-1]+o[t])/4)||0);i>1&&(s[0]=(3*o[0]-s[1])/2,s[i]=(3*o[i-1]-s[i-1])/2);let c=Math.max(1,Math.min(16,Math.round(128/i))),l=[];for(let e=0;e<i;e++)for(let t=0;t<c;t++){let n=t/c,i=n*n,o=i*n,u=(2*o-3*i+1)*r[e]+(o-2*i+n)*a*s[e]+(3*i-2*o)*r[e+1]+(o-i)*a*s[e+1];l.push([(e+n)*a,Math.min(1,Math.max(0,u))])}return l.push([1,r[i]]),l}function Ot(e,t){let n=0,r=e.length-1;if(t<=e[n][0])return e[n][1];if(t>=e[r][0])return e[r][1];for(;r-n>1;){let i=n+r>>1;e[i][0]<t?n=i:r=i}let[i,a]=e[n],[o,s]=e[r];return o===i?s:a+(s-a)*(t-i)/(o-i)}function kt(e,t,n,r){let i=e=>wt+(1-e)*(n-10),a=e.map(([e,n])=>[e*t,i(n)]),o=a.map(([e,t])=>`${e.toFixed(2)},${t.toFixed(2)}`),s=r*t,c=i(Ot(e,r));return{points:a,line:o.join(` `),trail:`M${o.join(`L`)}`,fill:`M${o.join(`L`)}L${t},${n}L0,${n}Z`,dot:`${s},${c} ${s},${c}`,cx:s}}function At(e,t){let n=e.slice(1).map(([t,n],r)=>Math.hypot(t-e[r][0],n-e[r][1])),r=t*n.reduce((e,t)=>e+t,0);for(let t=0;t<n.length;t++){let i=n[t],a=e[t][0];if(r<=i)return a+(e[t+1][0]-a)*(i?r/i:1);r-=i}return e[e.length-1][0]}function jt({data:e,label:t,value:n,change:r,tone:i=`accent`,width:a=160,height:o=52,labels:s,formatValue:c,area:l=!0,interactive:u=!0}){let d=e.length>1?e:[e[0]??0,e[0]??0],f=d.length-1,p=d.join(`,`),m=(0,J.useMemo)(()=>Dt(p.split(`,`).map(Number)),[p]),h=`${t}: ${n??d[f]}. ${r??``}`.trim(),g=`sparkline${(0,J.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,_=(0,J.useRef)(null),v=(0,J.useRef)(null),y=Le(_,{once:!0,amount:.5}),b=!!me(),[x,S]=(0,J.useState)({w:a,h:o}),[C,w]=(0,J.useState)(null),[T,E]=(0,J.useState)(!1),D=C===null?null:Math.min(C,f),[O,k]=(0,J.useState)({index:D,direction:1});O.index!==D&&k({index:D,direction:D===null||O.index===null?1:Math.sign(D-O.index)||1});let[A]=(0,J.useState)(()=>kt(m,a,o,1)),j=(0,J.useRef)(m),M=(0,J.useRef)(x),N=W(0),P=W(1),F=W(A.line),ee=W(A.trail),I=W(A.fill),L=W(A.dot),R=W(A.cx),te=W(A.cx+Tt+16),z=W(A.cx+Tt),B=W(0),ne=Ce(N,e=>+(e>.001)),V=(0,J.useCallback)(()=>{let{w:e,h:t}=M.current,n=N.get(),r=kt(j.current,e,t,P.get());F.set(r.line),ee.set(r.trail),I.set(r.fill),L.set(r.dot),R.set(r.cx),te.set(r.cx+Tt+16),z.set(r.cx+Tt),B.set(n>=1?e+32:At(r.points,n)+16)},[P,R,z,L,N,I,F,te,B,ee]);Ue(P,`change`,V),Ue(N,`change`,V),(0,J.useLayoutEffect)(()=>{let e=v.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=e.clientWidth;t&&S(e=>Math.abs(e.w-t)<.5?e:{w:t,h:t*o/a})});return t.observe(e),()=>t.disconnect()},[o,a]),(0,J.useLayoutEffect)(()=>{M.current=x,V()},[x,V]),(0,J.useEffect)(()=>{if(b){N.jump(1);let e=requestAnimationFrame(()=>E(!0));return()=>cancelAnimationFrame(e)}if(!y)return;let e=ue(N,1,{...bt,onComplete:()=>E(!0)});return()=>e.stop()},[N,y,b]),(0,J.useEffect)(()=>{let e=j.current;if(e===m)return;if(b){j.current=m,V();return}let t=[...new Set([...Et,...m.map(([e])=>e)])].sort((e,t)=>e-t),n=t.map(t=>Ot(e,t)),r=t.map(e=>Ot(m,e)),i=ue(0,1,{...G.spring.smooth,onUpdate:e=>{j.current=t.map((t,i)=>[t,n[i]+(r[i]-n[i])*e]),V()},onComplete:()=>{j.current=m,V()}});return()=>i.stop()},[V,b,m]),(0,J.useEffect)(()=>{let e=D===null?1:D/f;if(b){P.jump(e);return}let t=ue(P,e,G.spring.snappy);return()=>t.stop()},[P,D,f,b]);let H=D!==null,re=(e=>c?c(d[e],e):yt.format(d[e]))(D??f),U=s?.[D??f],ie=n===void 0?void 0:H?re:n,ae=D===null?r??``:n===void 0?[re,U].filter(Boolean).join(` · `):U??`${D+1} of ${f+1}`,oe=e=>{let t=v.current?.getBoundingClientRect();return t?.width?Math.max(0,Math.min(f,Math.round((e-t.left)/t.width*f))):f},se=u?{role:`slider`,tabIndex:0,"aria-label":`${t}, explore values`,"aria-valuemin":1,"aria-valuemax":f+1,"aria-valuenow":(D??f)+1,"aria-valuetext":`${U??(D===null?`Latest`:`Point ${D+1} of ${f+1}`)}: ${re}`,onPointerDown:e=>w(oe(e.clientX)),onPointerMove:e=>{(e.pointerType===`mouse`||e.buttons)&&w(oe(e.clientX))},onPointerUp:e=>{e.pointerType!==`mouse`&&w(null)},onPointerLeave:()=>w(null),onPointerCancel:()=>w(null),onBlur:()=>w(null),onKeyDown:e=>{if(e.key===`Escape`&&H){e.preventDefault(),w(null);return}let t=D??f,n=Math.max(1,Math.round((f+1)/6)),r={ArrowLeft:t-1,ArrowDown:t-1,ArrowRight:t+1,ArrowUp:t+1,PageDown:t-n,PageUp:t+n,Home:0,End:f}[e.key];r!==void 0&&(e.preventDefault(),w(Math.max(0,Math.min(f,r))))}}:{};return(0,X.jsxs)(`figure`,{ref:_,className:Q.figure,"aria-label":h,children:[(0,X.jsxs)(`figcaption`,{className:Q.caption,children:[(0,X.jsx)(`span`,{className:Q.label,children:(0,X.jsx)(Ct,{text:t,whole:!0})}),ie!==void 0&&(0,X.jsx)(`strong`,{children:(0,X.jsx)(Ct,{text:ie,morph:!0})}),(0,X.jsx)(`small`,{className:Q[i],children:(0,X.jsx)(Ct,{text:ae,direction:H?O.direction:void 0,tone:H?Q.point:void 0,morph:!0})})]}),(0,X.jsx)(`div`,{ref:v,className:Q.plot,"data-interactive":u||void 0,...se,children:(0,X.jsxs)(`svg`,{className:Q.chart,viewBox:`0 0 ${x.w} ${x.h}`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(`clipPath`,{id:`${g}-lit`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(q.rect,{x:-16,y:-16,width:te,height:x.h+32})}),(0,X.jsx)(`clipPath`,{id:`${g}-dim`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(q.rect,{x:z,y:-16,width:x.w+32,height:x.h+32})}),(0,X.jsx)(`clipPath`,{id:`${g}-fill`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(q.rect,{x:-16,y:-16,width:B,height:x.h+32})})]}),l&&(0,X.jsx)(q.path,{className:`${Q.area} ${Q[i]}`,d:I,clipPath:`url(#${g}-fill)`}),(0,X.jsx)(`line`,{className:Q.baseline,x1:`0`,y1:x.h-.5,x2:x.w,y2:x.h-.5}),(0,X.jsx)(q.path,{className:Q.trail,d:ee,clipPath:`url(#${g}-dim)`,initial:!1,animate:{opacity:H&&T?1:0},transition:b?{duration:0}:xt}),(0,X.jsx)(q.polyline,{className:[Q.line,Q[i]].join(` `),points:F,clipPath:`url(#${g}-lit)`,style:{pathLength:N,opacity:ne}}),(0,X.jsx)(q.line,{className:Q.cursor,x1:R,x2:R,y1:0,y2:x.h,initial:!1,animate:{opacity:+!!H},transition:b?{duration:0}:xt}),(0,X.jsx)(q.polyline,{className:[Q.end,Q[i]].join(` `),points:L,initial:!1,animate:{opacity:+!!T,strokeWidth:T?H?10:7:0},transition:b?{duration:0}:{opacity:xt,strokeWidth:G.spring.snappy},fill:`none`,strokeLinecap:`round`})]})})]})}var $={root:`_root_1cea8_1`,horizontal:`_horizontal_1cea8_3`,list:`_list_1cea8_4`,item:`_item_1cea8_5`,vertical:`_vertical_1cea8_7`,compact:`_compact_1cea8_8`,head:`_head_1cea8_11`,marker:`_marker_1cea8_20`,ring:`_ring_1cea8_21`,disc:`_disc_1cea8_22`,glyph:`_glyph_1cea8_23`,icon:`_icon_1cea8_24`,connector:`_connector_1cea8_31`,fill:`_fill_1cea8_35`,text:`_text_1cea8_40`,label:`_label_1cea8_43`,slot:`_slot_1cea8_47`,slotInner:`_slotInner_1cea8_48`,description:`_description_1cea8_49`,error:`_error_1cea8_49`,caption:`_caption_1cea8_53`,captionLabel:`_captionLabel_1cea8_54`,srOnly:`_srOnly_1cea8_63`},Mt=e=>`blur(${e}px)`,Nt={duration:0},Pt={duration:G.duration.fast,ease:[...G.ease.standard]},Ft={duration:G.duration.standard,ease:[...G.ease.enter]},It={opacity:0,y:`0.3em`,filter:Mt(G.blur.soft)},Lt={opacity:1,y:0,filter:Mt(0)},Rt={opacity:0,y:`-0.3em`,filter:Mt(G.blur.subtle)},zt={opacity:0,scale:.5,filter:Mt(G.blur.subtle)},Bt={opacity:1,scale:1,filter:Mt(0)};function Vt({text:e,className:t,reduced:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(0),a=W(`auto`);return(0,J.useLayoutEffect)(()=>{i.current=performance.now()+700},[e]),(0,J.useEffect)(()=>{let e=r.current,t=e?.parentElement;if(!e||!t||typeof ResizeObserver>`u`)return;let o=!1,s=new ResizeObserver(()=>{let t=e.offsetHeight;if(!o||n||performance.now()>i.current){o=!0,a.jump(t);return}ue(a,t,G.spring.smooth)});return s.observe(e),()=>s.disconnect()},[a,n]),(0,X.jsx)(q.span,{className:$.slot,style:{height:a},children:(0,X.jsx)(`span`,{ref:r,className:$.slotInner,children:(0,X.jsx)(K,{mode:`popLayout`,initial:!1,children:e?(0,X.jsx)(q.span,{className:t,initial:It,animate:Lt,exit:{...Rt,transition:n?Nt:Pt},transition:n?Nt:Ft,children:e},`${t}:${e}`):null})})})}function Ht({kind:e,number:t,delay:n,reduced:r}){let i=r?Nt:{scale:{...G.spring.snappy,delay:n},opacity:{duration:G.duration.fast,delay:n},filter:{duration:G.duration.fast,delay:n}},a={...zt,transition:r?Nt:Pt},o=r?Nt:{duration:G.duration.standard,ease:G.ease.enter,delay:n+.04};return e===`number`?(0,X.jsx)(q.span,{className:$.glyph,initial:zt,animate:Bt,exit:a,transition:i,children:t}):(0,X.jsx)(q.svg,{className:`${$.glyph} ${$.icon}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2.5,strokeLinecap:`round`,strokeLinejoin:`round`,initial:zt,animate:Bt,exit:a,transition:i,children:e===`check`?(0,X.jsx)(q.path,{d:`M5.5 12.5l4.25 4.25L18.5 8`,initial:{pathLength:0},animate:{pathLength:1},transition:o}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q.path,{d:`M12 6.75v6.5`,initial:{pathLength:0},animate:{pathLength:1},transition:o}),(0,X.jsx)(q.circle,{cx:12,cy:17.4,r:1.4,fill:`currentColor`,stroke:`none`,initial:{scale:0},animate:{scale:1},transition:r?Nt:{...G.spring.snappy,delay:n+.16}})]})})}function Ut({number:e,kind:t,current:n,glyphDelay:r,ringDelay:i,reduced:a}){return(0,X.jsxs)(`span`,{className:$.marker,"aria-hidden":`true`,children:[(0,X.jsx)(K,{initial:!1,children:n?(0,X.jsx)(q.span,{className:$.ring,initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:a?Nt:Pt},transition:a?Nt:{scale:{...G.spring.snappy,delay:i},opacity:{duration:G.duration.fast,delay:i}}},`ring`):null}),(0,X.jsx)(`span`,{className:$.disc,children:(0,X.jsx)(K,{initial:!1,children:(0,X.jsx)(Ht,{kind:t,number:e,delay:r,reduced:a},t)})})]})}var Wt={complete:`Completed`,current:``,upcoming:`Not started`,error:`Error`};function Gt({steps:e,current:t,orientation:n=`horizontal`,onStepSelect:r,details:i=`all`,compact:a=!1,label:o=`Progress`,completeLabel:s=`All steps complete`,className:c}){let l=me()??!1,u=e.length,d=Math.min(Math.max(Math.round(t),0),u),[f,p]=(0,J.useState)({to:d,from:d});f.to!==d&&p({to:d,from:f.to});let m=f.from,h=G.stagger.line,g=e=>l?0:d>m?e>=m&&e<d?(e-m)*h:0:e>=d&&e<m?(m-1-e)*h:0,_=l?0:Math.max(0,Math.abs(d-m)-1)*h+.12,v=!!r,y=n===`vertical`,b=d>=u?void 0:e[d];function x(e){let t=!y&&getComputedStyle(e.currentTarget).direction===`rtl`,n=[`ArrowUp`,t?`ArrowRight`:`ArrowLeft`],r=[`ArrowDown`,t?`ArrowLeft`:`ArrowRight`];if(![...n,...r,`Home`,`End`].includes(e.key))return;let i=Array.from(e.currentTarget.querySelectorAll(`button[data-reachable]`)),a=i.indexOf(e.target);a<0||(e.preventDefault(),i[e.key===`Home`?0:e.key===`End`?i.length-1:n.includes(e.key)?Math.max(0,a-1):Math.min(i.length-1,a+1)]?.focus())}let S=v?`nav`:`div`,C=[$.root,y?$.vertical:$.horizontal,a?$.compact:``,c].filter(Boolean).join(` `);return(0,X.jsxs)(S,{className:C,"aria-label":o,role:v?void 0:`group`,children:[(0,X.jsx)(`ol`,{className:$.list,style:y?void 0:{gridTemplateColumns:u>1?`repeat(${u-1}, minmax(0, 1fr)) auto`:`auto`},onKeyDown:v?x:void 0,children:e.map((e,t)=>{let a=t===d,o=e.error?`error`:t<d?`complete`:a?`current`:`upcoming`,s=v&&t<d,c=e.error??(i===`all`||a?e.description:void 0),f=e.error?`error`:t<d?`check`:`number`,p=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ut,{number:t+1,kind:f,current:a,glyphDelay:g(t),ringDelay:_,reduced:l}),(0,X.jsxs)(`span`,{className:$.text,children:[(0,X.jsx)(`span`,{className:$.label,children:e.label}),Wt[o]?(0,X.jsxs)(`span`,{className:$.srOnly,children:[`, `,Wt[o]]}):null,(0,X.jsx)(Vt,{text:c,className:e.error?$.error:$.description,reduced:l})]})]});return(0,X.jsxs)(`li`,{className:$.item,"data-status":o,children:[t<u-1?(0,X.jsx)(`span`,{className:$.connector,"aria-hidden":`true`,children:(0,X.jsx)(q.span,{className:$.fill,initial:!1,animate:y?{scaleY:+(t<d)}:{scaleX:+(t<d)},transition:l?Nt:{...G.spring.smooth,delay:g(t)}},n)}):null,v?(0,X.jsx)(`button`,{type:`button`,className:$.head,"data-clickable":s||void 0,"data-reachable":t<=d||void 0,"aria-current":a?`step`:void 0,"aria-disabled":!s||void 0,tabIndex:s?void 0:-1,onClick:s?()=>r?.(t):void 0,children:p}):(0,X.jsx)(`span`,{className:$.head,"aria-current":a?`step`:void 0,children:p})]},e.id)})}),y?null:(0,X.jsxs)(`span`,{className:$.caption,"aria-hidden":`true`,children:[(0,X.jsx)(Vt,{text:b?.label??s,className:$.captionLabel,reduced:l}),(0,X.jsx)(Vt,{text:b?.error??b?.description,className:b?.error?$.error:$.description,reduced:l})]}),(0,X.jsx)(`span`,{className:$.srOnly,"aria-live":`polite`,children:b?`Step ${d+1} of ${u}: ${b.label}`:s})]})}var Kt={"openai-chat":`Chat`,"openai-responses":`Responses`,anthropic:`Anthropic`,gemini:`Gemini`},qt={new:`green`,same:`neutral`,sameHost:`orange`,off:`neutral`,skip:`red`},Jt=e=>`${e.source}\u0000${e.ref}`,Yt=e=>e.status!==`skip`&&e.status!==`same`;function Xt(e){try{return new URL(e).host}catch{return e}}function Zt({open:e,onOpenChange:t}){let{t:n}=E(),{toast:r}=fe(),i=U(e),a=ie(),[o,s]=(0,J.useState)(``),[c,u]=(0,J.useState)(new Set),[d,f]=(0,J.useState)(null);(0,J.useEffect)(()=>{i.data&&u(new Set(i.data.flatMap(e=>e.items).filter(e=>e.status===`new`).map(Jt)))},[i.data]),(0,J.useEffect)(()=>{e&&(s(``),f(null))},[e]);let p=o.trim().toLowerCase(),m=e=>!p||e.name.toLowerCase().includes(p)||e.endpoints.some(e=>e.baseUrl.toLowerCase().includes(p)),h=(0,J.useMemo)(()=>(i.data??[]).flatMap(e=>e.items).filter(e=>c.has(Jt(e))&&Yt(e)),[i.data,c]),g=(e,t)=>u(n=>{let r=new Set(n);return t?r.add(Jt(e)):r.delete(Jt(e)),r});return(0,X.jsx)(ae,{open:e,onOpenChange:t,width:680,title:n(`import.title`),description:n(`import.detail`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{icon:(0,X.jsx)(Pe,{className:`size-3.5`}),onClick:()=>void i.refetch(),disabled:i.isFetching||a.isPending,children:n(`import.rescan`)}),(0,X.jsx)(l,{variant:`primary`,disabled:h.length===0||a.isPending,onClick:()=>{f(null),a.mutate(h.map(e=>({source:e.source,ref:e.ref})),{onSuccess:e=>{let i=e.skipped.length;r(i>0?n(`import.doneSkipped`,{count:e.added.length,skipped:i}):n(`import.done`,{count:e.added.length})),t(!1)},onError:e=>{f(R(e)),i.refetch()}})},children:n(`import.selected`,{count:h.length})})]}),children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(v,{value:o,onChange:s,placeholder:n(`import.search`)}),d&&(0,X.jsx)(y,{tone:`danger`,title:n(`common.error`),children:d}),i.isLoading&&(0,X.jsx)(F,{lines:3}),i.isError&&(0,X.jsx)(y,{tone:`danger`,title:n(`common.error`),children:R(i.error)}),(0,X.jsx)(`div`,{className:`grid max-h-[460px] gap-4 overflow-auto pr-1`,children:i.data?.map(e=>(0,X.jsx)(Qt,{source:e,matches:m,selected:c,onToggle:g,filtering:p.length>0},e.id))}),(0,X.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`import.footnote`)})]})})}function Qt({source:e,matches:t,selected:n,onToggle:r,filtering:i}){let{t:a}=E(),o=e.items.filter(t);return(0,X.jsxs)(`section`,{"aria-label":e.name,children:[(0,X.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 px-1`,children:[(0,X.jsx)(`h3`,{className:`text-[13px] font-medium`,children:e.name}),e.path&&(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-[var(--text-muted)]`,title:a(`import.path`,{path:e.path}),children:e.path})]}),e.error?(0,X.jsx)(y,{tone:`danger`,title:a(`import.sourceError`,{error:e.error})}):e.found?o.length===0?(0,X.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:a(i?`import.noMatch`:`import.noItems`)}):(0,X.jsx)(`ul`,{className:`card divide-y divide-[var(--border)]`,children:o.map(e=>(0,X.jsx)($t,{c:e,checked:n.has(Jt(e)),onToggle:t=>r(e,t)},Jt(e)))}):(0,X.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:a(`import.notFound`)})]})}function $t({c:e,checked:t,onToggle:n}){let{t:r}=E(),i=Yt(e),o=e.status===`skip`&&e.skipReason?r(`import.skip.${e.skipReason}`):e.status===`same`&&e.existing?r(`import.existing`,{name:e.existing.name}):e.status===`sameHost`&&e.existing?r(`import.sameHostHint`,{name:e.existing.name}):null,s=e.endpoints.map(e=>`${Kt[e.protocol]??e.protocol} · ${Xt(e.baseUrl)}`).join(` / `);return(0,X.jsxs)(`li`,{className:a(`flex items-start gap-3 px-4 py-3`,!i&&`opacity-60`),children:[(0,X.jsx)(Me,{checked:t&&i,disabled:!i,onCheckedChange:e=>n(e===!0),"aria-label":e.name}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,title:e.name,children:e.name}),(0,X.jsx)(S,{tone:qt[e.status],children:r(`import.status.${e.status}`)}),e.fromApp&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:e.fromApp})]}),s&&(0,X.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-[var(--text-muted)]`,title:s,children:s}),(0,X.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-3 text-[11px] text-[var(--text-muted)]`,children:[(0,X.jsx)(`span`,{className:`font-mono`,children:e.hasKey?e.keyMasked??`••••`:r(`import.noKey`)}),e.models.length>0&&(0,X.jsx)(`span`,{children:r(`import.models`,{count:e.models.length})}),e.templateId&&(0,X.jsx)(`span`,{children:r(`import.template`,{id:e.templateId})})]}),o&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--text-secondary,var(--text-muted))]`,children:o}),e.ignoredFields.length>0&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--warning)]`,children:r(`import.ignored`,{fields:e.ignoredFields.join(`, `)})})]})]})}var en=``,tn=`custom`,nn=[{name:`userId`,secret:!1,required:!1},{name:`accessToken`,secret:!0,required:!1}],rn={method:`GET`,url:`{{baseUrl}}/user/balance`,auth:`provider`,headers:{}},an={isValid:`is_active`,remaining:`balance`,unit:{$const:`USD`}},on=e=>JSON.stringify(e??{},null,2);function sn(e){return{enabled:e.enabled,template:e.template??en,intervalMinutes:e.intervalMinutes??null,timeoutSec:e.timeoutSec,baseUrl:e.baseUrl??``,params:{...e.params},secrets:{},method:e.request?.method??`GET`,url:e.request?.url??``,auth:e.request?.auth??`provider`,headers:on(e.request?.headers),extract:e.extract?on(e.extract):``}}function cn(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`&&!Array.isArray(t)?t:null}catch{return null}}function ln({provider:e}){let{t}=E(),{toast:n}=fe(),r=P(),i=B(e.id),a=x(e.id),o=z(),s=e.quotaConfig,c=(0,J.useMemo)(()=>sn(s),[s]),[u,d]=(0,J.useState)(c),[h,g]=(0,J.useState)(null);(0,J.useEffect)(()=>d(c),[c]);let _=r.data??[],v=_.find(e=>e.id===s.suggestedTemplate),b=u.template===en?v:_.find(e=>e.id===u.template),S=u.template===tn,C=S?nn:b?.params??[],w=e=>d(t=>({...t,...e})),T=JSON.stringify(u)!==JSON.stringify(c),k=e=>{if(e!==tn||u.url)return w({template:e});let t=b??v;w({template:e,method:t?.request.method??rn.method,url:t?.request.url??rn.url,auth:t?.request.auth??rn.auth,headers:on(t?.request.headers??rn.headers),extract:on(t?.extract??an)})},j=()=>{let e={enabled:u.enabled,template:u.template===en?null:u.template,intervalMinutes:u.intervalMinutes,timeoutSec:u.timeoutSec??10,baseUrl:u.baseUrl.trim()||null,params:Object.fromEntries(Object.entries(u.params).filter(([,e])=>e.trim()!==``).map(([e,t])=>[e,t.trim()])),secrets:Object.fromEntries(Object.entries(u.secrets).filter(([,e])=>e.trim()!==``))};if(S){let r=cn(u.headers),i=cn(u.extract);if(!r||!i)return n(t(`providers.quota.invalidJson`,{field:t(r?`providers.quota.extract`:`providers.quota.headers`)}),`error`),null;e.request={method:u.method,url:u.url.trim(),auth:u.auth,headers:r},e.extract=i}return e},N=()=>{let r=j();if(!r)return;let a=r.enabled&&!s.enabled;i.mutate(r,{onSuccess:()=>{n(t(`common.saved`),`success`),a&&o.mutate(e.id,{onError:e=>n(R(e),`error`)})},onError:e=>n(R(e),`error`)})},F=()=>{let e=j();e&&a.mutate(e,{onSuccess:g,onError:e=>n(R(e),`error`)})},ee=s.effectiveIntervalMinutes>0?t(`providers.quota.intervalEvery`,{minutes:s.effectiveIntervalMinutes}):t(`providers.quota.intervalOff`),te=[{value:en,label:v?t(`providers.quota.templateAuto`,{name:v.name}):t(`providers.quota.templateNone`)},..._.map(e=>({value:e.id,label:e.name,detail:t(`providers.quota.kind.${e.kind}`)})),{value:tn,label:t(`providers.quota.custom`)}];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(O,{title:t(`providers.quota.title`),footer:t(`providers.quota.footer`),children:[(0,X.jsx)(f,{label:t(`providers.quota.enable`),detail:t(`providers.quota.enableHint`),children:(0,X.jsx)(M,{checked:u.enabled,label:t(`providers.quota.enable`),onChange:e=>w({enabled:e})})}),(0,X.jsx)(f,{label:t(`providers.quota.template`),children:(0,X.jsx)(pe,{className:`w-64`,ariaLabel:t(`providers.quota.template`),value:u.template,onChange:k,options:te})}),C.map(e=>{let n=t(`providers.quota.param.${e.name}`),r=s.secrets.includes(e.name);return e.secret?(0,X.jsx)(f,{label:n,detail:r?t(`providers.quota.secretStored`):void 0,children:(0,X.jsx)(p,{type:`password`,autoComplete:`off`,className:`w-64 font-mono`,"aria-label":n,placeholder:r?`••••••••`:``,value:u.secrets[e.name]??``,onChange:t=>w({secrets:{...u.secrets,[e.name]:t.target.value}})})},e.name):(0,X.jsx)(f,{label:n,children:(0,X.jsx)(p,{className:`w-64 font-mono`,"aria-label":n,value:u.params[e.name]??``,onChange:t=>w({params:{...u.params,[e.name]:t.target.value}})})},e.name)}),C.length>0&&(0,X.jsx)(`div`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.paramsHint`)}),S&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(pe,{className:`w-28`,ariaLabel:t(`providers.quota.method`),value:u.method,onChange:e=>w({method:e}),options:[{value:`GET`,label:`GET`},{value:`POST`,label:`POST`}]}),(0,X.jsx)(p,{className:`min-w-60 flex-1 font-mono`,"aria-label":t(`providers.quota.url`),value:u.url,onChange:e=>w({url:e.target.value})}),(0,X.jsx)(pe,{className:`w-52`,ariaLabel:t(`providers.quota.auth`),value:u.auth,onChange:e=>w({auth:e}),options:[{value:`provider`,label:t(`providers.quota.auth.provider`)},{value:`none`,label:t(`providers.quota.auth.none`)}]})]}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.urlHint`)}),(0,X.jsx)(I,{label:t(`providers.quota.headers`),mono:!0,rows:3,value:u.headers,onChange:e=>w({headers:e.target.value})}),(0,X.jsx)(I,{label:t(`providers.quota.extract`),mono:!0,rows:8,value:u.extract,onChange:e=>w({extract:e.target.value})}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.extractHint`)})]}),(0,X.jsx)(f,{label:t(`providers.quota.interval`),detail:t(`providers.quota.intervalHint`,{value:ee}),children:(0,X.jsx)(A,{className:`w-28`,label:t(`providers.quota.interval`),min:0,step:1,value:u.intervalMinutes,onChange:e=>w({intervalMinutes:e})})}),(0,X.jsx)(f,{label:t(`providers.quota.timeout`),children:(0,X.jsx)(A,{className:`w-28`,label:t(`providers.quota.timeout`),min:1,step:1,value:u.timeoutSec,onChange:e=>w({timeoutSec:e})})}),(0,X.jsx)(f,{label:t(`providers.quota.baseUrl`),detail:t(`providers.quota.baseUrlHint`),children:(0,X.jsx)(p,{className:`w-64 font-mono`,"aria-label":t(`providers.quota.baseUrl`),placeholder:e.endpoints[0]?.baseUrl,value:u.baseUrl,onChange:e=>w({baseUrl:e.target.value})})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 py-3`,children:[(0,X.jsx)(l,{size:`sm`,variant:`primary`,disabled:!T,loading:i.isPending,onClick:N,children:t(`common.save`)}),(0,X.jsx)(l,{size:`sm`,icon:(0,X.jsx)(qe,{className:`size-3.5`}),loading:a.isPending,onClick:F,title:t(`providers.quota.testDesc`),children:t(`providers.quota.test`)}),(0,X.jsx)(l,{size:`sm`,icon:(0,X.jsx)(Ye,{className:`size-3.5`}),disabled:T,loading:o.isPending,onClick:()=>o.mutate(e.id,{onError:e=>n(R(e),`error`)}),children:t(`providers.quota.fetch`)})]}),(0,X.jsx)(`div`,{className:`px-4 pb-4`,children:(0,X.jsx)(un,{snapshot:e.quota,checkedAtUtc:e.quotaCheckedAtUtc})})]}),(0,X.jsx)(ae,{open:h!==null,onOpenChange:e=>!e&&g(null),title:t(`providers.quota.test`),description:t(`providers.quota.testDesc`),width:560,children:h&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(y,{tone:h.ok?`success`:`danger`,title:h.ok?t(`providers.quota.testOk`):t(`providers.quota.testFailed`),children:[!h.ok&&L({code:h.errorCode??null,message:h.error??``},t),!h.ok&&h.error&&h.errorCode&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] opacity-80`,children:h.error})]}),h.url&&(0,X.jsx)(D,{label:t(`providers.quota.requestUrl`),mono:!0,children:h.url}),h.httpStatus!=null&&(0,X.jsx)(D,{label:t(`providers.quota.httpStatus`),children:h.httpStatus}),h.snapshot&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[12px] text-[var(--text-secondary)]`,children:t(`providers.quota.extracted`)}),(0,X.jsx)(un,{snapshot:h.snapshot})]}),h.raw!==void 0&&h.raw!==null&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[12px] text-[var(--text-secondary)]`,children:t(`providers.quota.rawResponse`)}),(0,X.jsx)(m,{children:on(h.raw)})]})]})})]})}function un({snapshot:t,checkedAtUtc:n}){let{t:r,locale:i}=E(),a=de(t),o=t?.plans??[],s=t?.fetchedAtUtc?new Date(t.fetchedAtUtc).getTime():0;return!t&&!n?(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`providers.quota.never`)}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a&&(0,X.jsxs)(y,{tone:`warning`,title:r(`providers.quota.failed`,{error:L(a,r)}),children:[(0,X.jsx)(`span`,{className:`text-[11px]`,children:a.message}),o.length>0&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px]`,children:r(`providers.quota.lastGood`)})]}),t?.isValid===!1&&(0,X.jsx)(y,{tone:`warning`,title:r(`providers.quota.invalid`),children:t.invalidMessage}),o.length>0&&(0,X.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map((t,n)=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 text-[13px]`,children:[t.name&&(0,X.jsx)(S,{children:t.name}),(0,X.jsx)(`span`,{className:`num`,children:e(t,r,i)??`—`}),H(t,r,i)&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:H(t,r,i)}),t.extra&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:t.extra})]},n))}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-[var(--text-muted)]`,children:[t?.planLabel&&(0,X.jsx)(S,{tone:`accent`,children:t.planLabel}),s>0&&(0,X.jsx)(`span`,{children:r(`providers.quota.fetchedAt`,{time:Se(s,i,r(`tray.justNow`))??``})})]})]})}function dn({provider:e}){let{t,locale:n}=E(),{toast:r}=fe(),i=z();if(!ve(e))return null;let a=he(e.quota,t,n),o=de(e.quota);return(0,X.jsxs)(`div`,{className:`mt-3 flex min-w-0 items-center gap-2 text-[12px]`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a&&(0,X.jsx)(`div`,{className:`num truncate text-[var(--text-secondary)]`,title:a,children:a}),o&&(0,X.jsx)(`div`,{className:`truncate text-[var(--warning)]`,title:o.message,children:t(`providers.quota.failed`,{error:L(o,t)})}),!a&&!o&&(0,X.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:t(`providers.quota.never`)})]}),(0,X.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(Ye,{className:`size-3.5`}),"aria-label":t(`providers.quota.refresh`),title:t(`providers.quota.refresh`),loading:i.isPending,onClick:()=>i.mutate(e.id,{onError:e=>r(R(e),`error`)})})]})}var fn=[{value:`openai-chat`,label:`OpenAI Chat`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic`,label:`Anthropic Messages`},{value:`gemini`,label:`Gemini`}],pn=[{value:`bearer`,label:`Authorization: Bearer`},{value:`x-api-key`,label:`x-api-key`},{value:`x-goog-api-key`,label:`x-goog-api-key`},{value:`query-key`,label:`?key=`},{value:`none`,label:`—`},{value:`oauth-subscription`,label:`OAuth 订阅`}];function mn(){let{t:e}=E(),t=Ee(),[n,r]=we(),i=ee(),[a,o]=(0,J.useState)(n.get(`new`)===`1`),[s,c]=(0,J.useState)(!1);(0,J.useEffect)(()=>{n.get(`new`)===`1`&&(o(!0),n.delete(`new`),r(n,{replace:!0}))},[n,r]),De(e=>{e===`new-provider`&&o(!0)});let u=se(`7d`,`day`,`provider`),[d,f]=(0,J.useState)(null),p=(0,J.useMemo)(()=>{let e=gn(hn),t=new Map;for(let n of u.data??[]){let r=e.indexOf(n.bucket);if(r<0)continue;let i=t.get(n.key);i||t.set(n.key,i={requests:e.map(()=>0),costUsd:0}),i.requests[r]=(i.requests[r]??0)+n.requests,i.costUsd+=n.costUsd}return{days:e,byProvider:t}},[u.data]);return(0,X.jsxs)(Ae,{title:e(`nav.providers`),subtitle:i.data?e(`providers.count`,{count:i.data.length}):void 0,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{icon:(0,X.jsx)(Ne,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`providers.import`)}),(0,X.jsx)(l,{variant:`primary`,icon:(0,X.jsx)(ke,{className:`size-3.5`}),onClick:()=>o(!0),children:e(`providers.add`)})]}),children:[(0,X.jsxs)(`div`,{className:`mx-auto max-w-[1100px]`,children:[i.isLoading&&(0,X.jsx)(F,{lines:4}),i.isError&&(0,X.jsx)(y,{tone:`danger`,title:e(`common.error`),children:R(i.error)}),i.data?.length===0&&(0,X.jsx)(`div`,{className:`card`,children:(0,X.jsx)(be,{icon:(0,X.jsx)(Te,{className:`size-6`}),title:e(`providers.empty`),detail:e(`providers.emptyDetail`),action:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,X.jsx)(l,{variant:`primary`,icon:(0,X.jsx)(ke,{className:`size-3.5`}),onClick:()=>o(!0),children:e(`providers.add`)}),(0,X.jsx)(l,{icon:(0,X.jsx)(Ne,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`providers.import`)})]})})}),i.data&&i.data.length>0&&(0,X.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,260px),1fr))] gap-3`,children:i.data.map(e=>(0,X.jsx)(yn,{p:e,days:p.days,usage:p.byProvider.get(e.name),onOpen:()=>t(`/providers/${e.id}`),onTest:()=>f(e)},e.id))})]}),(0,X.jsx)(Zt,{open:s,onOpenChange:c}),(0,X.jsx)(Sn,{open:a,onOpenChange:o,onCreated:e=>t(`/providers/${e.id}`)}),d&&(0,X.jsx)(An,{provider:d,open:!0,onOpenChange:e=>!e&&f(null)})]})}var hn=7;function gn(e){let t=new Date;return Array.from({length:e},(n,r)=>{let i=new Date(t.getFullYear(),t.getMonth(),t.getDate()-(e-1-r));return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,`0`)}-${String(i.getDate()).padStart(2,`0`)}`})}function _n(e){if(!e)return null;try{return new URL(e).host}catch{return e}}var vn=e=>e.stopPropagation();function yn({p:e,days:t,usage:n,onOpen:r,onTest:i}){let{t:o}=E(),s=d(e.id),{toast:c}=fe(),u=[...new Set(e.endpoints.map(e=>e.protocol))],f=!e.hasApiKey&&e.authScheme!==`none`&&e.authScheme!==`oauth-subscription`&&e.authScheme!==`plugin`,p=[e.priceKey?o(`providers.priceKeyShort`,{key:e.priceKey}):null,e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `),m=e.authScheme===`plugin`?o(`providers.card.plugin`):e.authScheme===`oauth-subscription`?o(`providers.card.subscription`):e.authScheme===`none`?o(`providers.card.noAuth`):e.hasApiKey?e.apiKeyMasked??`••••`:o(`providers.noKey`),h=e.enabled?f?{tone:`orange`,label:o(`providers.noKey`)}:{tone:`green`,label:o(`providers.card.active`)}:{tone:`neutral`,label:o(`providers.card.disabled`)},g=n?.requests??t.map(()=>0),_=g.reduce((e,t)=>e+t,0),v=e.templateUpdateAvailable?5:8;return(0,X.jsxs)(ht,{className:`flex flex-col [&>div:first-child>div]:min-h-0! [&>div:last-child]:flex [&>div:last-child]:flex-1 [&>div:last-child]:flex-col [&>div:last-child]:p-3 [&>div:last-child>:last-child]:mt-auto! [&>div:last-child>:last-child]:min-h-[44px] [&>div:last-child>:last-child]:pt-2 [&>div:last-child>h3]:line-clamp-1 [&>div:last-child>h3]:text-[15px] [&>div:last-child>p]:line-clamp-2 [&>div:last-child>p]:min-h-[2lh] [&>div:last-child>p]:text-[12px]`,"data-density":`compact`,role:`button`,tabIndex:0,"aria-label":e.name,onClick:r,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},style:{backgroundColor:`var(--surface)`},title:e.name,description:u.map(e=>fn.find(t=>t.value===e)?.label??e).join(` / `),media:(0,X.jsxs)(`div`,{className:`flex flex-col justify-between gap-1.5 self-stretch justify-self-stretch px-3 py-2.5`,style:{background:`linear-gradient(135deg, color-mix(in oklab, var(--accent) 12%, transparent), transparent 70%)`},children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:a(`transition-[filter,opacity]`,!e.enabled&&`opacity-50 grayscale`),children:(0,X.jsx)(Re,{name:e.name,icon:e.icon,colorKey:e.templateId,size:28})}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-[var(--border)] bg-[color-mix(in_oklab,var(--surface)_80%,transparent)] px-2 py-0.5 text-[11px] text-[var(--text-secondary)]`,children:[(0,X.jsx)(w,{tone:h.tone}),h.label]})]}),(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[11px] text-[var(--text-muted)]`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:e.endpoints[0]?.baseUrl,children:_n(e.endpoints[0]?.baseUrl)??`—`}),(0,X.jsx)(`span`,{className:`shrink-0`,children:o(`providers.modelCount`,{count:e.modelCount})})]})]}),meta:(0,X.jsx)(`span`,{className:a(e.hasApiKey&&e.authScheme!==`oauth-subscription`&&`font-mono`),children:m}),status:p||void 0,action:(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,onClick:vn,children:[(0,X.jsx)(l,{variant:`plain`,size:`sm`,icon:(0,X.jsx)(qe,{className:`size-3.5`}),"aria-label":o(`providers.test`),title:o(`providers.test`),onClick:i}),(0,X.jsx)(`span`,{className:`ml-1 inline-flex`,children:(0,X.jsx)(M,{checked:e.enabled,label:o(`common.enabled`),onChange:e=>s.mutate({enabled:e},{onError:e=>c(R(e),`error`)})})})]}),children:[(0,X.jsxs)(`div`,{className:`mt-1.5 flex h-5 flex-nowrap items-center gap-1 overflow-hidden`,children:[e.templateUpdateAvailable&&(0,X.jsx)(S,{tone:`accent`,children:o(`providers.templateUpdate`)}),e.boundClients.slice(0,v).map(e=>e in Be?(0,X.jsx)(`span`,{title:Ie(e),className:`inline-flex shrink-0`,children:(0,X.jsx)(ze,{kind:e,size:18})},e):(0,X.jsx)(S,{tone:`green`,children:e},e)),e.boundClients.length>v&&(0,X.jsxs)(`span`,{title:e.boundClients.slice(v).map(e=>Be[e]?.name??e).join(`, `),className:`shrink-0 text-[11px] text-[var(--text-muted)]`,children:[`+`,e.boundClients.length-v]})]}),(0,X.jsx)(`div`,{className:`min-h-[32px] [&>div]:mt-1`,onClick:vn,children:(0,X.jsx)(dn,{provider:e})}),(0,X.jsx)(`div`,{className:`mt-2`,onClick:vn,children:_>0?(0,X.jsx)(jt,{label:o(`providers.card.requests7d`),data:g,labels:t.map(e=>e.slice(5)),value:ne(_,!0),change:le(n?.costUsd??0),width:320,height:28,formatValue:e=>ne(e,!0)}):(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(`div`,{className:`text-[13px] text-[var(--text-secondary)]`,children:o(`providers.card.requests7d`)}),(0,X.jsx)(`div`,{className:`grid aspect-[320/28] place-items-center border-b border-dashed border-[var(--border)] text-[11px] text-[var(--text-muted)]`,children:o(`providers.card.noRequests`)})]})})]})}var bn=`plugin:`,xn=[`recommended`,`official`,`subscription`,`cn`,`aggregator`,`local`,`custom`];function Sn({open:e,onOpenChange:t,onCreated:n}){let{t:i}=E(),{toast:a}=fe(),o=s(),c=k(),u=N(),d=ee(),f=(0,J.useMemo)(()=>new Set((d.data??[]).filter(e=>e.authScheme===`oauth-subscription`&&e.templateId).map(e=>e.templateId)),[d.data]),m=Ee(),[h,g]=(0,J.useState)(``),[_,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(null),[C,w]=(0,J.useState)(``),[T,D]=(0,J.useState)(``),[O,A]=(0,J.useState)(``),[j,M]=(0,J.useState)(``),[P,I]=(0,J.useState)(``),[L,te]=(0,J.useState)(`openai-chat`),[z,B]=(0,J.useState)(`bearer`);(0,J.useEffect)(()=>{e||(b(null),S(null),g(``),w(``),D(``),A(``),M(``),I(``))},[e]);let ne=(0,J.useMemo)(()=>{let e=h.trim().toLowerCase(),t=(o.data??[]).filter(t=>!e||t.name.toLowerCase().includes(e)||t.id.includes(e));return xn.map(e=>({category:e,items:t.filter(t=>t.category===e)})).filter(e=>e.items.length)},[o.data,h]),V=(0,J.useMemo)(()=>{let e=h.trim().toLowerCase();return(d.data??[]).filter(t=>t.authScheme===`plugin`&&!t.settings.plugin?.absent&&(!e||t.name.toLowerCase().includes(e)||t.id.includes(e)))},[d.data,h]),H=e=>{b(e),e===`custom`?(w(``),M(``),A(``)):(w(e.name),M(e.priceKey??e.id),A(``),B(e.auth.scheme))},re=()=>{let e=_===`custom`;u.mutate({templateId:e?null:_.id,variantId:O||null,name:C.trim()||null,apiKey:T.trim()||null,priceKey:j,...e?{endpoints:[{protocol:L,baseUrl:P.trim()}],authScheme:z}:{}},{onSuccess:e=>{t(!1),a(i(`providers.created`,{name:e.name}),`success`),n(e)},onError:e=>a(R(e),`error`)})},U=_&&_!==`custom`?_:null,ie=()=>{if(x===`custom`)H(`custom`);else if(x?.startsWith(bn)){let e=V.find(e=>bn+e.id===x);e&&(t(!1),n(e))}else{let e=(o.data??[]).find(e=>e.id===x);e&&!f.has(e.id)&&H(e)}},W=_!==null&&(_===`custom`?/^https?:\/\//.test(P.trim())&&C.trim()!==``:!U.requiresApiKey||T.trim()!==``);return(0,X.jsxs)(ae,{open:e,onOpenChange:t,width:640,title:i(_?`providers.addTitleDetails`:`providers.addTitle`),description:_?U?U.name:i(`providers.custom`):i(`providers.addDetail`),footer:_?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{className:`mr-auto`,variant:`plain`,onClick:()=>b(null),children:i(`common.back`)}),(0,X.jsx)(l,{onClick:()=>t(!1),children:i(`common.cancel`)}),(0,X.jsx)(l,{variant:`primary`,disabled:!W,loading:u.isPending,onClick:re,children:i(`providers.create`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{onClick:()=>t(!1),children:i(`common.cancel`)}),(0,X.jsx)(l,{variant:`primary`,disabled:!x,onClick:ie,children:i(`common.continue`)})]}),children:[(0,X.jsx)(Gt,{className:`mb-6`,label:i(`providers.addTitle`),current:+!!_,steps:[{id:`template`,label:i(`providers.step.template`)},{id:`details`,label:i(`providers.step.details`)}]}),_?(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(r,{label:i(`providers.name`),children:(0,X.jsx)(p,{value:C,onChange:e=>w(e.target.value)})}),U?.variants&&U.variants.length>0&&(0,X.jsx)(r,{label:i(`providers.variant`),children:(0,X.jsx)(pe,{value:O,onChange:e=>{A(e);let t=U.variants?.find(t=>t.id===e);M(t?.priceKey??U.priceKey??U.id)},options:[{value:``,label:i(`providers.variantDefault`)},...U.variants.map(e=>({value:e.id,label:e.name}))]})}),_===`custom`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{label:i(`providers.baseUrl`),hint:i(`providers.baseUrlHint`),children:(0,X.jsx)(p,{value:P,onChange:e=>I(e.target.value),placeholder:`https://api.example.com/v1`,className:`font-mono`})}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,X.jsx)(r,{label:i(`providers.protocol`),children:(0,X.jsx)(pe,{value:L,onChange:te,options:fn})}),(0,X.jsx)(r,{label:i(`providers.authScheme`),children:(0,X.jsx)(pe,{value:z,onChange:B,options:pn})})]})]}),U?.authScheme===`oauth-subscription`?(0,X.jsx)(y,{tone:`info`,title:i(`providers.subscriptionWizardHint`),children:i(`providers.subscriptionWizardDetail`)}):(0,X.jsxs)(`div`,{className:`font-mono`,children:[(0,X.jsx)(Ve,{label:i(`providers.apiKey`),description:i(`providers.apiKeyHint`),autoComplete:`off`,placeholder:`sk-…`,value:T,onChange:e=>D(e.target.value)}),U?.apiKeyUrl&&(0,X.jsx)(`a`,{className:`mt-2 inline-block font-sans text-[12px] text-[var(--accent)]`,href:U.apiKeyUrl,target:`_blank`,rel:`noreferrer`,children:i(`providers.getKey`)})]}),(0,X.jsx)(r,{label:i(`providers.priceKey`),hint:i(`providers.priceKeyHint`),children:(0,X.jsx)(pe,{value:j,onChange:M,options:[{value:``,label:i(`providers.priceKeyNone`)},...(c.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey}))]})}),U&&U.models.length>0&&(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:i(`providers.templateModels`,{count:U.models.length})})]}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsx)(v,{value:h,onChange:g,placeholder:i(`providers.searchTemplates`)}),o.isLoading&&(0,X.jsx)(F,{lines:4}),o.isError&&(0,X.jsx)(y,{tone:`danger`,title:i(`common.error`),children:R(o.error)}),ne.map(e=>(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:i(`providers.category.${e.category}`)}),(0,X.jsx)(He,{name:`provider-template`,"aria-label":i(`providers.category.${e.category}`),minColumnWidth:170,value:e.items.some(e=>e.id===x)?x:null,onValueChange:S,options:e.items.map(e=>({value:e.id,label:e.name,description:[...new Set(e.endpoints.map(e=>e.protocol))].join(` · `),icon:(0,X.jsx)(Re,{name:e.name,icon:e.icon,colorKey:e.id,size:24}),disabled:f.has(e.id),disabledReason:i(`providers.subscriptionAdded`)}))})]},e.category)),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:i(`providers.category.plugin`)}),V.length>0?(0,X.jsx)(He,{name:`provider-template-plugin`,"aria-label":i(`providers.category.plugin`),minColumnWidth:170,value:x?.startsWith(bn)?x:null,onValueChange:S,options:V.map(e=>({value:bn+e.id,label:e.name,description:i(`providers.pluginProvided`),icon:(0,X.jsx)(Re,{name:e.name,icon:e.icon,colorKey:e.id,size:24})}))}):(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-[var(--radius-md)] border border-dashed border-[var(--border)] px-3 py-2.5`,children:[(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-[12px] text-[var(--text-secondary)]`,children:i(`providers.pluginHint`)}),(0,X.jsx)(l,{size:`sm`,onClick:()=>{t(!1),m(`/plugins/market`)},children:i(`plugins.browseMarket`)})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:i(`providers.custom`)}),(0,X.jsx)(He,{name:`provider-template-custom`,"aria-label":i(`providers.custom`),layout:`list`,value:x===`custom`?`custom`:null,onValueChange:S,options:[{value:`custom`,label:i(`providers.custom`),description:i(`providers.customDetail`),icon:(0,X.jsx)(ke,{className:`size-4`})}]})]})]})]})}var Cn=3,wn=256,Tn=4096,En={idle:`providers.testDialog.status.idle`,queued:`providers.testDialog.status.queued`,running:`providers.testDialog.status.running`,success:`providers.testDialog.status.success`,failed:`providers.testDialog.status.failed`,cancelled:`providers.testDialog.status.cancelled`};function Dn(e){let t=e.endpoints.map(e=>e.protocol);return e.preferredUpstreamProtocols.find(e=>t.includes(e))??t[0]??`openai-chat`}var On=e=>typeof e==`number`?e:null,kn=e=>typeof e==`string`?e:null;function An({provider:e,open:t,onOpenChange:n}){let{t:i}=E(),a=C(),o=_(t?e.id:void 0),s=e.endpoints.map(e=>e.protocol),[c,u]=(0,J.useState)(`single`),[d,f]=(0,J.useState)(()=>Dn(e)),[p,m]=(0,J.useState)(!0),[h,v]=(0,J.useState)(``),[y,b]=(0,J.useState)(wn),[x,S]=(0,J.useState)(``),[w,T]=(0,J.useState)(null),[D,O]=(0,J.useState)({}),[k,A]=(0,J.useState)([]),[j,M]=(0,J.useState)(new Set),[N,P]=(0,J.useState)([]),[F,ee]=(0,J.useState)(``),[I,L]=(0,J.useState)(null),[R,te]=(0,J.useState)(!1),z=(0,J.useRef)(null),B=(0,J.useRef)(new Map),ne=(0,J.useRef)(!1),V=(0,J.useRef)(!1),H=(0,J.useMemo)(()=>{let e=[...o.data??[]].sort((e,t)=>Number(t.enabled)-Number(e.enabled)||e.sortOrder-t.sortOrder).map(e=>e.modelId);return[...e,...N.filter(t=>!e.includes(t))]},[o.data,N]);(0,J.useEffect)(()=>{if(t){S(e=>e||(o.data??[]).find(e=>e.enabled)?.modelId||(o.data??[])[0]?.modelId||``);return}V.current=!1,z.current?.abort();for(let e of B.current.values())e.abort();B.current.clear(),T(null),O({}),A([]),M(new Set),P([]),ee(``),L(null)},[t,o.data]);let re=(0,J.useCallback)(e=>({modelId:e,protocol:d,stream:p,prompt:h.trim()||null,maxOutputTokens:y??wn}),[d,p,h,y]),U=(0,J.useCallback)((t,n,r)=>zn(e.id,t,re(t),n,r),[e.id,re]),ie=()=>{let e=x.trim();if(!e)return;z.current?.abort();let t=new AbortController;z.current=t,V.current=!0,L(null),T({modelId:e,status:`running`,text:``,reasoning:``}),U(e,t.signal,e=>{e.status!==`running`&&e.status!==`queued`&&oe(),T(e)})},W=e=>{if(e.length===0)return;V.current=!0,ne.current=!1,L(null),A(e),O(Object.fromEntries(e.map(e=>[e,{modelId:e,status:`queued`,text:``,reasoning:``}])));let t=0;Promise.all(Array.from({length:Math.min(Cn,e.length)},async()=>{for(;;){if(!V.current)return;let n=e[t++];if(n===void 0)return;if(ne.current){O(e=>({...e,[n]:{...e[n],status:`cancelled`}}));continue}let r=new AbortController;B.current.set(n,r),await U(n,r.signal,e=>O(t=>({...t,[n]:e}))),B.current.delete(n),oe()}}))},oe=()=>void a.invalidateQueries({queryKey:[`requests`]}),se=()=>{ne.current=!0,O(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.status===`queued`?{...t,status:`cancelled`}:t])))},ce=w?.status===`running`||k.some(e=>D[e]?.status===`running`||D[e]?.status===`queued`&&!ne.current),le=k.filter(e=>D[e]&&D[e].status!==`queued`&&D[e].status!==`running`).length,ue=k.filter(e=>D[e]?.status===`success`).length,de=k.filter(e=>D[e]?.status===`failed`).length,G=(e,t)=>M(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),fe=()=>{ce||n(!1)},K=e=>e.stopPropagation();return(0,X.jsx)(`span`,{onClick:K,onKeyDown:K,children:(0,X.jsxs)(ae,{open:t,onOpenChange:e=>e?n(!0):fe(),width:1040,title:i(`providers.testDialog.title`,{name:e.name}),description:i(`providers.testDialog.subtitle`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mr-auto text-[11px] text-[var(--text-muted)]`,children:i(`providers.testDialog.realRequest`)}),(0,X.jsx)(l,{disabled:ce,onClick:()=>n(!1),icon:(0,X.jsx)(ge,{className:`size-3.5`}),children:i(`common.close`)}),c===`single`?ce?(0,X.jsx)(l,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:()=>z.current?.abort(),children:i(`providers.testDialog.stop`)}):(0,X.jsx)(l,{variant:`primary`,disabled:x.trim()===``,icon:(0,X.jsx)(qe,{className:`size-3.5`}),onClick:ie,children:i(w?`providers.testDialog.retest`:`providers.testDialog.start`)}):ce?(0,X.jsx)(l,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:se,children:i(`providers.testDialog.stopRest`)}):(0,X.jsx)(l,{variant:`primary`,disabled:j.size===0,icon:(0,X.jsx)(qe,{className:`size-3.5`}),onClick:()=>W([...j]),children:i(`providers.testDialog.testN`,{count:j.size})})]}),children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pb-4`,children:[(0,X.jsx)(Re,{name:e.name,icon:e.icon,colorKey:e.templateId,size:32}),(0,X.jsx)(g,{items:[{value:`single`,label:i(`providers.testDialog.modeSingle`)},{value:`batch`,label:i(`providers.testDialog.modeBatch`)}],value:c,onChange:e=>{u(e),L(null)},ariaLabel:i(`providers.testDialog.config`)})]}),c===`single`?(0,X.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,300px)_minmax(0,1fr)] gap-6`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 border-r border-[var(--border)] pr-6`,children:[(0,X.jsx)(`h3`,{className:`text-[13px] font-medium`,children:i(`providers.testDialog.config`)}),(0,X.jsx)(r,{label:i(`providers.testDialog.model`),children:(0,X.jsx)(jn,{value:x,models:H,onChange:S})}),(0,X.jsx)(Mn,{protocols:s,protocol:d,onProtocol:f,stream:p,onStream:m,maxTokens:y,onMaxTokens:b,prompt:h,onPrompt:v}),(0,X.jsx)(`p`,{className:`mt-auto text-[11px] text-[var(--text-muted)]`,children:i(`providers.testDialog.savedCredentials`)})]}),(0,X.jsx)(Nn,{run:w,onRetest:ie})]}):I===null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ln,{known:H,selected:j,onToggle:G,onSelectAll:e=>M(e?new Set(H):new Set),onClear:()=>M(new Set),search:F,onSearch:ee,onAdd:e=>{P(t=>t.includes(e)?t:[...t,e]),M(t=>new Set(t).add(e)),ee(``)},configOpen:R,onConfigOpen:te,protocols:s,protocol:d,onProtocol:f,stream:p,onStream:m,maxTokens:y,onMaxTokens:b,prompt:h,onPrompt:v}),k.length>0?(0,X.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:ce?i(`providers.testDialog.progress`,{done:le,total:k.length,ok:ue,failed:de}):i(`providers.testDialog.progressDone`,{total:k.length,ok:ue,failed:de})}),(0,X.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-strong)]`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full transition-[width]`,style:{width:`${le/k.length*100}%`,background:`var(--accent)`}})})]}):null,k.length>0?(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Rn,{order:k,runs:D,onView:L})}):null]}):(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(l,{variant:`plain`,icon:(0,X.jsx)(je,{className:`size-4`}),"aria-label":i(`common.back`),onClick:()=>L(null)}),(0,X.jsx)(`span`,{className:`font-mono text-[13px]`,children:I})]}),(0,X.jsx)(Nn,{run:D[I]??null})]})]})})}function jn({value:e,models:t,onChange:n}){let{t:r}=E(),[i,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(0),[l,u]=(0,J.useState)(null),d=l===null?t:t.filter(e=>e.toLowerCase().includes(l.trim().toLowerCase())),f=()=>{u(null),c(Math.max(0,t.indexOf(e))),o(!0)},m=e=>{n(e),u(null),o(!1)};return(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(p,{className:`pr-9 font-mono`,value:e,placeholder:r(`providers.testDialog.modelPlaceholder`),"aria-expanded":i,role:`combobox`,onFocus:f,onClick:f,onChange:e=>{n(e.target.value),u(e.target.value),c(0),o(!0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!i)return f();if(d.length===0)return;let t=e.key===`ArrowDown`?1:-1;c(e=>(e+t+d.length)%d.length)}else e.key===`Enter`&&i?(e.preventDefault(),d[s]&&m(d[s])):e.key===`Escape`&&o(!1)}}),(0,X.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 grid w-8 place-items-center text-[var(--text-muted)] hover:text-[var(--text)]`,"aria-label":r(`providers.testDialog.showModels`),onClick:()=>i?o(!1):f(),children:(0,X.jsx)(ce,{className:`size-4`})}),i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`fixed inset-0 z-40`,onMouseDown:()=>o(!1)}),(0,X.jsx)(`ul`,{className:`absolute inset-x-0 top-full z-50 mt-1 max-h-64 overflow-auto rounded-lg border border-[var(--border)] bg-[var(--surface-raised)] py-1 shadow-lg`,children:d.length===0?(0,X.jsx)(`li`,{className:`px-3 py-2 text-[12px] text-[var(--text-muted)]`,children:r(`providers.testDialog.noModels`)}):d.map((e,t)=>(0,X.jsx)(`li`,{children:(0,X.jsx)(`button`,{type:`button`,className:a(`block w-full truncate px-3 py-1.5 text-left font-mono text-[12px] hover:bg-[var(--surface-strong)]`,t===s&&`bg-[var(--surface-strong)]`),onMouseEnter:()=>c(t),onMouseDown:t=>{t.preventDefault(),m(e)},children:e})},e))})]})]})}function Mn({protocols:e,...t}){let{t:n}=E(),i=e.map(e=>({value:e,label:fn.find(t=>t.value===e)?.label??e}));return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{label:n(`providers.testDialog.protocol`),children:(0,X.jsx)(pe,{value:t.protocol,onChange:t.onProtocol,options:i})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:n(`providers.testDialog.stream`)}),(0,X.jsx)(M,{checked:t.stream,label:n(`providers.testDialog.stream`),onChange:t.onStream})]}),(0,X.jsx)(r,{label:n(`providers.testDialog.maxTokens`),children:(0,X.jsx)(A,{value:t.maxTokens,min:1,placeholder:String(wn),label:n(`providers.testDialog.maxTokens`),onChange:e=>t.onMaxTokens(e===null?null:Math.min(Tn,Math.max(1,Math.round(e))))})}),(0,X.jsx)(r,{label:n(`providers.testDialog.prompt`),hint:n(`providers.testDialog.promptHint`),children:(0,X.jsx)(I,{rows:4,value:t.prompt,placeholder:`Reply with OK.`,onChange:e=>t.onPrompt(e.target.value)})})]})}function Nn({run:e,onRetest:t}){let{t:n}=E(),[r,i]=(0,J.useState)(`preview`),a=e?.text??``,o=e?.raw??``,s=Object.entries(e?.headers??{}),c=e?.ttftMs!=null&&e?.httpMs!=null?Math.max(0,e.ttftMs-e.httpMs):null,u=r===`raw`?o:r===`headers`?s.map(([e,t])=>`${e}: ${t}`).join(`
1
+ import{$t as e,A as t,An as n,B as r,C as i,Cn as a,D as o,Di as s,E as c,F as l,Fa as u,Fi as d,G as f,H as p,I as m,Ia as h,J as g,Jr as _,K as v,N as y,O as b,Oi as x,P as S,Pa as C,R as w,T,Tn as E,U as D,V as O,Vr as k,W as A,Wi as j,X as M,Xn as N,Xr as P,Y as F,Yr as ee,Z as I,Zt as L,a as R,aa as te,cr as z,di as B,dn as ne,dt as V,en as H,et as re,gr as U,hr as ie,i as ae,ia as W,k as oe,ki as se,lt as ce,mn as le,na as ue,nn as de,nt as G,o as fe,oa as K,r as pe,ra as me,rn as he,rt as ge,sn as _e,ta as q,tn as ve,w as ye,z as be,za as xe,zt as Se}from"./overlays-D1ZtG8Qn.js";import{t as Ce}from"./use-transform-DvOb1h9g.js";import{S as we,a as Te,b as Ee,f as De,n as Oe,s as ke,t as Ae}from"./Page-CnSErb_N.js";import{n as je,t as Me}from"./checkbox-RGYPqY5w.js";import{t as Ne}from"./download-CMr38kbd.js";import{C as Pe,O as Fe,h as Ie,k as Le,m as Re,p as ze,u as Be,x as Ve}from"./index-PfVyiY3J.js";import{t as He}from"./radio-cards-QHFaDooy.js";var J=xe(h(),1);function Ue(e,t,n){(0,J.useInsertionEffect)(()=>e.on(t,n),[e,t,n])}var We={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};We.node;var Ge=V(We),Ke={name:`flask-conical`,size:24,node:[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]};Ke.node;var qe=V(Ke),Je={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};Je.node;var Ye=V(Je),Xe={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Xe.node;var Ze=V(Xe),Y={card:`_card_i7fo0_3`,trigger:`_trigger_i7fo0_6`,media:`_media_i7fo0_7`,zoom:`_zoom_i7fo0_8`,content:`_content_i7fo0_9`,description:`_description_i7fo0_12`,footer:`_footer_i7fo0_13`,title:`_title_i7fo0_15`,byline:`_byline_i7fo0_22`,avatar:`_avatar_i7fo0_23`,bylineText:`_bylineText_i7fo0_26`,meta:`_meta_i7fo0_27`,status:`_status_i7fo0_28`,roll:`_roll_i7fo0_30`,line:`_line_i7fo0_31`,word:`_word_i7fo0_32`,srOnly:`_srOnly_i7fo0_33`,action:`_action_i7fo0_34`,overlay:`_overlay_i7fo0_36`,panel:`_panel_i7fo0_38`,closeSlot:`_closeSlot_i7fo0_48`,close:`_close_i7fo0_48`,details:`_details_i7fo0_51`},X=u(),{blur:Qe,duration:Z,ease:$e,spring:et,stagger:tt}=G,nt={...et.smooth,visualDuration:.3},rt={...et.smooth,visualDuration:.26},it=300,at={duration:Z.instant},ot=1.04,st={duration:Z.considered*2,ease:[...$e.standard]},ct={duration:Z.considered,ease:[...$e.standard]},lt={delay:Z.instant,duration:Z.standard,ease:[...$e.enter]},ut={delay:Z.instant,duration:Z.fast,ease:[...$e.enter]},dt={enter:{},center:{},exit:{opacity:0,y:`-.3em`,filter:`blur(${Qe.subtle}px)`,transition:{duration:Z.fast,ease:[...$e.standard]}}},ft={enter:{opacity:0,y:`.3em`,filter:`blur(${Qe.soft}px)`},center:e=>({opacity:1,y:0,filter:`blur(0px)`,transition:{duration:Z.standard,ease:[...$e.enter],delay:e*tt.word}})};function pt({text:e,reduced:t}){return(0,X.jsxs)(`span`,{className:Y.status,role:`status`,children:[(0,X.jsx)(`span`,{className:Y.srOnly,children:e}),(0,X.jsx)(`span`,{className:Y.roll,"aria-hidden":`true`,children:(0,X.jsx)(K,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(q.span,{className:Y.line,variants:dt,initial:!t&&`enter`,animate:`center`,exit:t?void 0:`exit`,children:e.split(/(\s+)/).map((e,t)=>(0,X.jsx)(q.span,{className:Y.word,custom:t/2,variants:ft,children:e},t))},e)})})]})}function mt(e,t){let n=parseFloat(t);if(Number.isFinite(n))return t.trim().endsWith(`rem`)?n*parseFloat(getComputedStyle(e.ownerDocument.documentElement).fontSize):n}function ht({title:e,description:n,media:r,action:a,avatar:s,meta:l,status:u,details:d,open:f,defaultOpen:p=!1,onOpenChange:m,children:h,className:g,style:_,...v}){let y=me()??!1,x=(0,J.useId)(),S=(0,J.useRef)(null),C=(0,J.useRef)(null),[w,E]=(0,J.useState)(p),[D,O]=(0,J.useState)(!1),[k,A]=(0,J.useState)({}),[j,M]=(0,J.useState)(null),N=d?f??w:!1,P=!!d&&!y,F=!N&&j!==null,ee=!!n,I=(0,J.useCallback)(e=>{f===void 0&&E(e),m?.(e)},[f,m]);(0,J.useEffect)(()=>{let e=S.current,t=C.current;if(!P||!e||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>{let n=getComputedStyle(e),r=mt(e,n.borderTopLeftRadius),i=mt(e,n.getPropertyValue(`--radius-surface`)),a=t?.offsetWidth||void 0;A(e=>e.card!==void 0&&e.measure===a?e:{card:e.card??r,panel:e.panel??i,measure:a})});return n.observe(e),t&&n.observe(t),()=>n.disconnect()},[P,ee]);let L=(0,J.useRef)(N);(0,J.useLayoutEffect)(()=>{let e=L.current&&!N;L.current=N;let t=S.current;if(N)M(null);else if(e&&P&&t){let e=t.getBoundingClientRect();M({top:e.top,left:e.left,width:e.width,height:e.height})}},[N,P]),(0,J.useEffect)(()=>{if(!F)return;let e=window.setTimeout(()=>M(null),it);return()=>window.clearTimeout(e)},[F]);let R=(e,t,n=!0)=>P?{layoutId:e,layout:n,layoutCrossfade:!1,layoutDependency:t===`card`?N:F?`return`:`panel`,transition:{layout:t===`card`?rt:nt}}:{},z=e=>s||l||u||a?(0,X.jsxs)(`div`,{className:Y.footer,children:[s||l||u?(0,X.jsxs)(q.div,{className:Y.byline,...R(`byline`,e,`position`),children:[s?(0,X.jsx)(`span`,{className:Y.avatar,children:s}):null,(0,X.jsxs)(`span`,{className:Y.bylineText,children:[l?(0,X.jsx)(`span`,{className:Y.meta,children:l}):null,u?(0,X.jsx)(pt,{text:u,reduced:y}):null]})]}):null,a?(0,X.jsx)(q.div,{className:Y.action,...R(`action`,e,`position`),children:a}):null]}):null,B=(0,X.jsxs)(q.article,{...v,ref:S,className:[Y.card,g].filter(Boolean).join(` `),style:{..._,borderRadius:k.card??_?.borderRadius},"data-hover":D||void 0,whileHover:y?void 0:{y:-2},onHoverStart:()=>O(!0),onHoverEnd:()=>O(!1),...R(`card`,`card`),transition:{default:et.snappy,layout:rt},children:[r?(0,X.jsx)(q.div,{className:Y.media,...R(`media`,`card`),children:(0,X.jsx)(q.div,{className:Y.zoom,initial:!1,animate:{scale:D&&!y?ot:1},transition:D?st:ct,children:r})}):null,(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(q.h3,{className:Y.title,...R(`title`,`card`),children:d?(0,X.jsx)(t,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:Y.trigger,children:e})}):e}),n?(0,X.jsx)(q.p,{ref:C,className:Y.description,...R(`description`,`card`,`position`),children:n}):null,h,z(`card`)]})]});return d?(0,X.jsx)(i,{open:N,onOpenChange:I,children:(0,X.jsxs)(te,{id:x,children:[B,(0,X.jsx)(K,{children:(N||F)&&(0,X.jsxs)(b,{forceMount:!0,children:[(0,X.jsx)(K,{children:N&&(0,X.jsx)(o,{asChild:!0,forceMount:!0,children:(0,X.jsx)(q.div,{className:Y.overlay,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:y?at:{duration:Z.exit,ease:[...$e.standard]}},transition:y?at:{duration:Z.standard,ease:[...$e.enter]}})},`overlay`)}),(0,X.jsx)(T,{asChild:!0,forceMount:!0,...n?{}:{"aria-describedby":void 0},children:(0,X.jsxs)(q.div,{className:Y.panel,"data-framer-portal-id":x,"data-returning":F||void 0,layoutScroll:!0,style:{borderRadius:k.panel,"--card-measure":k.measure?`${k.measure}px`:void 0,...j&&F?{"--landing-top":`${j.top}px`,"--landing-left":`${j.left}px`,"--landing-width":`${j.width}px`,"--landing-height":`${j.height}px`}:{}},...P?{...R(`card`,`panel`),initial:!1,animate:k.card!==void 0&&k.panel!==void 0?{borderRadius:F?k.card:k.panel}:void 0,transition:{layout:F?rt:nt,borderRadius:F?rt:nt},exit:{opacity:0,transition:{duration:0}}}:{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:at},transition:at},children:[r?(0,X.jsx)(q.div,{className:Y.media,...R(`media`,`panel`),children:(0,X.jsx)(q.div,{className:Y.zoom,initial:{scale:D&&!y?ot:1},animate:{scale:1},transition:nt,children:r})}):null,(0,X.jsx)(q.span,{className:Y.closeSlot,initial:y?{opacity:0}:{opacity:0,scale:.9},animate:F?{opacity:0,scale:.9}:{opacity:1,scale:1},transition:F||y?at:ut,children:(0,X.jsx)(ye,{asChild:!0,children:(0,X.jsx)(q.button,{type:`button`,className:Y.close,"aria-label":`Close quick look`,whileTap:y?void 0:{scale:.94},transition:et.snappy,children:(0,X.jsx)(ge,{width:16,height:16,strokeWidth:1.75,"aria-hidden":`true`})})})}),(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(oe,{asChild:!0,children:(0,X.jsx)(q.h2,{className:Y.title,...R(`title`,`panel`),children:e})}),n?(0,X.jsx)(c,{asChild:!0,children:(0,X.jsx)(q.p,{className:Y.description,...R(`description`,`panel`,`position`),children:n})}):null,h,z(`panel`),(0,X.jsx)(q.div,{className:Y.details,initial:!y&&{opacity:0,y:6},animate:F?{opacity:0,y:0}:{opacity:1,y:0},exit:{opacity:0,transition:at},transition:F||y?at:lt,children:d})]})]})})]},`quick-look`)})]})}):B}var Q={figure:`_figure_1clu4_1`,caption:`_caption_1clu4_1`,label:`_label_1clu4_1`,accent:`_accent_1clu4_2`,success:`_success_1clu4_2`,warning:`_warning_1clu4_2`,danger:`_danger_1clu4_2`,point:`_point_1clu4_4`,roll:`_roll_1clu4_7`,track:`_track_1clu4_9`,slot:`_slot_1clu4_9`,glyph:`_glyph_1clu4_9`,sizer:`_sizer_1clu4_11`,plot:`_plot_1clu4_14`,chart:`_chart_1clu4_17`,baseline:`_baseline_1clu4_18`,area:`_area_1clu4_20`,line:`_line_1clu4_21`,trail:`_trail_1clu4_21`,cursor:`_cursor_1clu4_24`,end:`_end_1clu4_25`},gt={hidden:e=>({opacity:0,y:`${.3*e}em`,filter:`blur(${G.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:G.duration.standard,ease:[...G.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${G.blur.subtle}px)`,transition:{duration:G.duration.fast,ease:[...G.ease.standard]}})},_t={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:G.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:G.duration.instant}}},vt=e=>Number(e.replace(/,/g,``).replace(/−/g,`-`).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN),yt=new Intl.NumberFormat(`en-US`),bt={duration:G.duration.considered*1.75,ease:[...G.ease.inOut]},xt={duration:G.duration.fast,ease:[...G.ease.standard]};function St(e,t){if(!e)return[];if(t)return[{slot:`all`,key:e,text:e}];if(!/\p{L}/u.test(e))return[...e].map((e,t,n)=>({slot:`n${n.length-t}`,key:e,text:e}));let n=e.split(/(?<=\s)/);return n.map((e,t)=>({slot:`w${t}`,key:n.slice(0,t+1).join(``),text:e}))}function Ct({text:e,direction:t,whole:n=!1,morph:r=!1,tone:i}){let a=!!me(),o=(0,J.useRef)(null),s=W(`auto`),[c,l]=(0,J.useState)({text:e,direction:1});c.text!==e&&l({text:e,direction:t??(vt(e)<vt(c.text)?-1:1)}),(0,J.useEffect)(()=>{let e=o.current;if(!e||typeof ResizeObserver>`u`)return;let t=null,n=new ResizeObserver(([n])=>{if(!n)return;let r=n.borderBoxSize?.[0]?.inlineSize??e.offsetWidth;t!==null&&t!==e.textContent&&!a?ue(s,r,G.spring.morph):s.jump(r),t=e.textContent});return n.observe(e),()=>n.disconnect()},[r,a,s]);let u=!n&&!/\p{L}/u.test(e),d=a?_t:gt,f=u?`right`:`left`;return(0,X.jsxs)(q.span,{className:Q.roll,"data-end":u||void 0,"data-whole":n||void 0,style:r?{width:s}:void 0,children:[r&&(0,X.jsx)(`span`,{ref:o,className:Q.sizer,"aria-hidden":`true`,children:e}),(0,X.jsx)(`span`,{className:Q.track,children:(0,X.jsx)(K,{mode:`popLayout`,initial:!1,custom:c.direction,anchorX:f,children:St(e,n).map(e=>(0,X.jsx)(q.span,{className:Q.slot,custom:c.direction,variants:d,initial:`hidden`,animate:`shown`,exit:`gone`,children:(0,X.jsx)(K,{mode:`popLayout`,initial:!1,custom:c.direction,anchorX:f,children:(0,X.jsx)(q.span,{className:i?`${Q.glyph} ${i}`:Q.glyph,custom:c.direction,variants:d,initial:`hidden`,animate:`shown`,exit:`gone`,children:e.text},`${i??``}${e.key}`)})},e.slot))})})]})}var wt=5,Tt=1.25,Et=Array.from({length:161},(e,t)=>t/160);function Dt(e){let t=Math.min(...e),n=Math.max(...e)-t,r=e.map(e=>n?(e-t)/n:.5),i=r.length-1,a=1/i,o=r.slice(1).map((e,t)=>(e-r[t])/a),s=r.map((e,t)=>t===0||t===i?o[0]:(Math.sign(o[t-1])+Math.sign(o[t]))*Math.min(Math.abs(o[t-1]),Math.abs(o[t]),Math.abs(o[t-1]+o[t])/4)||0);i>1&&(s[0]=(3*o[0]-s[1])/2,s[i]=(3*o[i-1]-s[i-1])/2);let c=Math.max(1,Math.min(16,Math.round(128/i))),l=[];for(let e=0;e<i;e++)for(let t=0;t<c;t++){let n=t/c,i=n*n,o=i*n,u=(2*o-3*i+1)*r[e]+(o-2*i+n)*a*s[e]+(3*i-2*o)*r[e+1]+(o-i)*a*s[e+1];l.push([(e+n)*a,Math.min(1,Math.max(0,u))])}return l.push([1,r[i]]),l}function Ot(e,t){let n=0,r=e.length-1;if(t<=e[n][0])return e[n][1];if(t>=e[r][0])return e[r][1];for(;r-n>1;){let i=n+r>>1;e[i][0]<t?n=i:r=i}let[i,a]=e[n],[o,s]=e[r];return o===i?s:a+(s-a)*(t-i)/(o-i)}function kt(e,t,n,r){let i=e=>wt+(1-e)*(n-10),a=e.map(([e,n])=>[e*t,i(n)]),o=a.map(([e,t])=>`${e.toFixed(2)},${t.toFixed(2)}`),s=r*t,c=i(Ot(e,r));return{points:a,line:o.join(` `),trail:`M${o.join(`L`)}`,fill:`M${o.join(`L`)}L${t},${n}L0,${n}Z`,dot:`${s},${c} ${s},${c}`,cx:s}}function At(e,t){let n=e.slice(1).map(([t,n],r)=>Math.hypot(t-e[r][0],n-e[r][1])),r=t*n.reduce((e,t)=>e+t,0);for(let t=0;t<n.length;t++){let i=n[t],a=e[t][0];if(r<=i)return a+(e[t+1][0]-a)*(i?r/i:1);r-=i}return e[e.length-1][0]}function jt({data:e,label:t,value:n,change:r,tone:i=`accent`,width:a=160,height:o=52,labels:s,formatValue:c,area:l=!0,interactive:u=!0}){let d=e.length>1?e:[e[0]??0,e[0]??0],f=d.length-1,p=d.join(`,`),m=(0,J.useMemo)(()=>Dt(p.split(`,`).map(Number)),[p]),h=`${t}: ${n??d[f]}. ${r??``}`.trim(),g=`sparkline${(0,J.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,_=(0,J.useRef)(null),v=(0,J.useRef)(null),y=Le(_,{once:!0,amount:.5}),b=!!me(),[x,S]=(0,J.useState)({w:a,h:o}),[C,w]=(0,J.useState)(null),[T,E]=(0,J.useState)(!1),D=C===null?null:Math.min(C,f),[O,k]=(0,J.useState)({index:D,direction:1});O.index!==D&&k({index:D,direction:D===null||O.index===null?1:Math.sign(D-O.index)||1});let[A]=(0,J.useState)(()=>kt(m,a,o,1)),j=(0,J.useRef)(m),M=(0,J.useRef)(x),N=W(0),P=W(1),F=W(A.line),ee=W(A.trail),I=W(A.fill),L=W(A.dot),R=W(A.cx),te=W(A.cx+Tt+16),z=W(A.cx+Tt),B=W(0),ne=Ce(N,e=>+(e>.001)),V=(0,J.useCallback)(()=>{let{w:e,h:t}=M.current,n=N.get(),r=kt(j.current,e,t,P.get());F.set(r.line),ee.set(r.trail),I.set(r.fill),L.set(r.dot),R.set(r.cx),te.set(r.cx+Tt+16),z.set(r.cx+Tt),B.set(n>=1?e+32:At(r.points,n)+16)},[P,R,z,L,N,I,F,te,B,ee]);Ue(P,`change`,V),Ue(N,`change`,V),(0,J.useLayoutEffect)(()=>{let e=v.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=e.clientWidth;t&&S(e=>Math.abs(e.w-t)<.5?e:{w:t,h:t*o/a})});return t.observe(e),()=>t.disconnect()},[o,a]),(0,J.useLayoutEffect)(()=>{M.current=x,V()},[x,V]),(0,J.useEffect)(()=>{if(b){N.jump(1);let e=requestAnimationFrame(()=>E(!0));return()=>cancelAnimationFrame(e)}if(!y)return;let e=ue(N,1,{...bt,onComplete:()=>E(!0)});return()=>e.stop()},[N,y,b]),(0,J.useEffect)(()=>{let e=j.current;if(e===m)return;if(b){j.current=m,V();return}let t=[...new Set([...Et,...m.map(([e])=>e)])].sort((e,t)=>e-t),n=t.map(t=>Ot(e,t)),r=t.map(e=>Ot(m,e)),i=ue(0,1,{...G.spring.smooth,onUpdate:e=>{j.current=t.map((t,i)=>[t,n[i]+(r[i]-n[i])*e]),V()},onComplete:()=>{j.current=m,V()}});return()=>i.stop()},[V,b,m]),(0,J.useEffect)(()=>{let e=D===null?1:D/f;if(b){P.jump(e);return}let t=ue(P,e,G.spring.snappy);return()=>t.stop()},[P,D,f,b]);let H=D!==null,re=(e=>c?c(d[e],e):yt.format(d[e]))(D??f),U=s?.[D??f],ie=n===void 0?void 0:H?re:n,ae=D===null?r??``:n===void 0?[re,U].filter(Boolean).join(` · `):U??`${D+1} of ${f+1}`,oe=e=>{let t=v.current?.getBoundingClientRect();return t?.width?Math.max(0,Math.min(f,Math.round((e-t.left)/t.width*f))):f},se=u?{role:`slider`,tabIndex:0,"aria-label":`${t}, explore values`,"aria-valuemin":1,"aria-valuemax":f+1,"aria-valuenow":(D??f)+1,"aria-valuetext":`${U??(D===null?`Latest`:`Point ${D+1} of ${f+1}`)}: ${re}`,onPointerDown:e=>w(oe(e.clientX)),onPointerMove:e=>{(e.pointerType===`mouse`||e.buttons)&&w(oe(e.clientX))},onPointerUp:e=>{e.pointerType!==`mouse`&&w(null)},onPointerLeave:()=>w(null),onPointerCancel:()=>w(null),onBlur:()=>w(null),onKeyDown:e=>{if(e.key===`Escape`&&H){e.preventDefault(),w(null);return}let t=D??f,n=Math.max(1,Math.round((f+1)/6)),r={ArrowLeft:t-1,ArrowDown:t-1,ArrowRight:t+1,ArrowUp:t+1,PageDown:t-n,PageUp:t+n,Home:0,End:f}[e.key];r!==void 0&&(e.preventDefault(),w(Math.max(0,Math.min(f,r))))}}:{};return(0,X.jsxs)(`figure`,{ref:_,className:Q.figure,"aria-label":h,children:[(0,X.jsxs)(`figcaption`,{className:Q.caption,children:[(0,X.jsx)(`span`,{className:Q.label,children:(0,X.jsx)(Ct,{text:t,whole:!0})}),ie!==void 0&&(0,X.jsx)(`strong`,{children:(0,X.jsx)(Ct,{text:ie,morph:!0})}),(0,X.jsx)(`small`,{className:Q[i],children:(0,X.jsx)(Ct,{text:ae,direction:H?O.direction:void 0,tone:H?Q.point:void 0,morph:!0})})]}),(0,X.jsx)(`div`,{ref:v,className:Q.plot,"data-interactive":u||void 0,...se,children:(0,X.jsxs)(`svg`,{className:Q.chart,viewBox:`0 0 ${x.w} ${x.h}`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(`clipPath`,{id:`${g}-lit`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(q.rect,{x:-16,y:-16,width:te,height:x.h+32})}),(0,X.jsx)(`clipPath`,{id:`${g}-dim`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(q.rect,{x:z,y:-16,width:x.w+32,height:x.h+32})}),(0,X.jsx)(`clipPath`,{id:`${g}-fill`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(q.rect,{x:-16,y:-16,width:B,height:x.h+32})})]}),l&&(0,X.jsx)(q.path,{className:`${Q.area} ${Q[i]}`,d:I,clipPath:`url(#${g}-fill)`}),(0,X.jsx)(`line`,{className:Q.baseline,x1:`0`,y1:x.h-.5,x2:x.w,y2:x.h-.5}),(0,X.jsx)(q.path,{className:Q.trail,d:ee,clipPath:`url(#${g}-dim)`,initial:!1,animate:{opacity:H&&T?1:0},transition:b?{duration:0}:xt}),(0,X.jsx)(q.polyline,{className:[Q.line,Q[i]].join(` `),points:F,clipPath:`url(#${g}-lit)`,style:{pathLength:N,opacity:ne}}),(0,X.jsx)(q.line,{className:Q.cursor,x1:R,x2:R,y1:0,y2:x.h,initial:!1,animate:{opacity:+!!H},transition:b?{duration:0}:xt}),(0,X.jsx)(q.polyline,{className:[Q.end,Q[i]].join(` `),points:L,initial:!1,animate:{opacity:+!!T,strokeWidth:T?H?10:7:0},transition:b?{duration:0}:{opacity:xt,strokeWidth:G.spring.snappy},fill:`none`,strokeLinecap:`round`})]})})]})}var $={root:`_root_1cea8_1`,horizontal:`_horizontal_1cea8_3`,list:`_list_1cea8_4`,item:`_item_1cea8_5`,vertical:`_vertical_1cea8_7`,compact:`_compact_1cea8_8`,head:`_head_1cea8_11`,marker:`_marker_1cea8_20`,ring:`_ring_1cea8_21`,disc:`_disc_1cea8_22`,glyph:`_glyph_1cea8_23`,icon:`_icon_1cea8_24`,connector:`_connector_1cea8_31`,fill:`_fill_1cea8_35`,text:`_text_1cea8_40`,label:`_label_1cea8_43`,slot:`_slot_1cea8_47`,slotInner:`_slotInner_1cea8_48`,description:`_description_1cea8_49`,error:`_error_1cea8_49`,caption:`_caption_1cea8_53`,captionLabel:`_captionLabel_1cea8_54`,srOnly:`_srOnly_1cea8_63`},Mt=e=>`blur(${e}px)`,Nt={duration:0},Pt={duration:G.duration.fast,ease:[...G.ease.standard]},Ft={duration:G.duration.standard,ease:[...G.ease.enter]},It={opacity:0,y:`0.3em`,filter:Mt(G.blur.soft)},Lt={opacity:1,y:0,filter:Mt(0)},Rt={opacity:0,y:`-0.3em`,filter:Mt(G.blur.subtle)},zt={opacity:0,scale:.5,filter:Mt(G.blur.subtle)},Bt={opacity:1,scale:1,filter:Mt(0)};function Vt({text:e,className:t,reduced:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(0),a=W(`auto`);return(0,J.useLayoutEffect)(()=>{i.current=performance.now()+700},[e]),(0,J.useEffect)(()=>{let e=r.current,t=e?.parentElement;if(!e||!t||typeof ResizeObserver>`u`)return;let o=!1,s=new ResizeObserver(()=>{let t=e.offsetHeight;if(!o||n||performance.now()>i.current){o=!0,a.jump(t);return}ue(a,t,G.spring.smooth)});return s.observe(e),()=>s.disconnect()},[a,n]),(0,X.jsx)(q.span,{className:$.slot,style:{height:a},children:(0,X.jsx)(`span`,{ref:r,className:$.slotInner,children:(0,X.jsx)(K,{mode:`popLayout`,initial:!1,children:e?(0,X.jsx)(q.span,{className:t,initial:It,animate:Lt,exit:{...Rt,transition:n?Nt:Pt},transition:n?Nt:Ft,children:e},`${t}:${e}`):null})})})}function Ht({kind:e,number:t,delay:n,reduced:r}){let i=r?Nt:{scale:{...G.spring.snappy,delay:n},opacity:{duration:G.duration.fast,delay:n},filter:{duration:G.duration.fast,delay:n}},a={...zt,transition:r?Nt:Pt},o=r?Nt:{duration:G.duration.standard,ease:G.ease.enter,delay:n+.04};return e===`number`?(0,X.jsx)(q.span,{className:$.glyph,initial:zt,animate:Bt,exit:a,transition:i,children:t}):(0,X.jsx)(q.svg,{className:`${$.glyph} ${$.icon}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2.5,strokeLinecap:`round`,strokeLinejoin:`round`,initial:zt,animate:Bt,exit:a,transition:i,children:e===`check`?(0,X.jsx)(q.path,{d:`M5.5 12.5l4.25 4.25L18.5 8`,initial:{pathLength:0},animate:{pathLength:1},transition:o}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q.path,{d:`M12 6.75v6.5`,initial:{pathLength:0},animate:{pathLength:1},transition:o}),(0,X.jsx)(q.circle,{cx:12,cy:17.4,r:1.4,fill:`currentColor`,stroke:`none`,initial:{scale:0},animate:{scale:1},transition:r?Nt:{...G.spring.snappy,delay:n+.16}})]})})}function Ut({number:e,kind:t,current:n,glyphDelay:r,ringDelay:i,reduced:a}){return(0,X.jsxs)(`span`,{className:$.marker,"aria-hidden":`true`,children:[(0,X.jsx)(K,{initial:!1,children:n?(0,X.jsx)(q.span,{className:$.ring,initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:a?Nt:Pt},transition:a?Nt:{scale:{...G.spring.snappy,delay:i},opacity:{duration:G.duration.fast,delay:i}}},`ring`):null}),(0,X.jsx)(`span`,{className:$.disc,children:(0,X.jsx)(K,{initial:!1,children:(0,X.jsx)(Ht,{kind:t,number:e,delay:r,reduced:a},t)})})]})}var Wt={complete:`Completed`,current:``,upcoming:`Not started`,error:`Error`};function Gt({steps:e,current:t,orientation:n=`horizontal`,onStepSelect:r,details:i=`all`,compact:a=!1,label:o=`Progress`,completeLabel:s=`All steps complete`,className:c}){let l=me()??!1,u=e.length,d=Math.min(Math.max(Math.round(t),0),u),[f,p]=(0,J.useState)({to:d,from:d});f.to!==d&&p({to:d,from:f.to});let m=f.from,h=G.stagger.line,g=e=>l?0:d>m?e>=m&&e<d?(e-m)*h:0:e>=d&&e<m?(m-1-e)*h:0,_=l?0:Math.max(0,Math.abs(d-m)-1)*h+.12,v=!!r,y=n===`vertical`,b=d>=u?void 0:e[d];function x(e){let t=!y&&getComputedStyle(e.currentTarget).direction===`rtl`,n=[`ArrowUp`,t?`ArrowRight`:`ArrowLeft`],r=[`ArrowDown`,t?`ArrowLeft`:`ArrowRight`];if(![...n,...r,`Home`,`End`].includes(e.key))return;let i=Array.from(e.currentTarget.querySelectorAll(`button[data-reachable]`)),a=i.indexOf(e.target);a<0||(e.preventDefault(),i[e.key===`Home`?0:e.key===`End`?i.length-1:n.includes(e.key)?Math.max(0,a-1):Math.min(i.length-1,a+1)]?.focus())}let S=v?`nav`:`div`,C=[$.root,y?$.vertical:$.horizontal,a?$.compact:``,c].filter(Boolean).join(` `);return(0,X.jsxs)(S,{className:C,"aria-label":o,role:v?void 0:`group`,children:[(0,X.jsx)(`ol`,{className:$.list,style:y?void 0:{gridTemplateColumns:u>1?`repeat(${u-1}, minmax(0, 1fr)) auto`:`auto`},onKeyDown:v?x:void 0,children:e.map((e,t)=>{let a=t===d,o=e.error?`error`:t<d?`complete`:a?`current`:`upcoming`,s=v&&t<d,c=e.error??(i===`all`||a?e.description:void 0),f=e.error?`error`:t<d?`check`:`number`,p=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ut,{number:t+1,kind:f,current:a,glyphDelay:g(t),ringDelay:_,reduced:l}),(0,X.jsxs)(`span`,{className:$.text,children:[(0,X.jsx)(`span`,{className:$.label,children:e.label}),Wt[o]?(0,X.jsxs)(`span`,{className:$.srOnly,children:[`, `,Wt[o]]}):null,(0,X.jsx)(Vt,{text:c,className:e.error?$.error:$.description,reduced:l})]})]});return(0,X.jsxs)(`li`,{className:$.item,"data-status":o,children:[t<u-1?(0,X.jsx)(`span`,{className:$.connector,"aria-hidden":`true`,children:(0,X.jsx)(q.span,{className:$.fill,initial:!1,animate:y?{scaleY:+(t<d)}:{scaleX:+(t<d)},transition:l?Nt:{...G.spring.smooth,delay:g(t)}},n)}):null,v?(0,X.jsx)(`button`,{type:`button`,className:$.head,"data-clickable":s||void 0,"data-reachable":t<=d||void 0,"aria-current":a?`step`:void 0,"aria-disabled":!s||void 0,tabIndex:s?void 0:-1,onClick:s?()=>r?.(t):void 0,children:p}):(0,X.jsx)(`span`,{className:$.head,"aria-current":a?`step`:void 0,children:p})]},e.id)})}),y?null:(0,X.jsxs)(`span`,{className:$.caption,"aria-hidden":`true`,children:[(0,X.jsx)(Vt,{text:b?.label??s,className:$.captionLabel,reduced:l}),(0,X.jsx)(Vt,{text:b?.error??b?.description,className:b?.error?$.error:$.description,reduced:l})]}),(0,X.jsx)(`span`,{className:$.srOnly,"aria-live":`polite`,children:b?`Step ${d+1} of ${u}: ${b.label}`:s})]})}var Kt={"openai-chat":`Chat`,"openai-responses":`Responses`,anthropic:`Anthropic`,gemini:`Gemini`},qt={new:`green`,same:`neutral`,sameHost:`orange`,off:`neutral`,skip:`red`},Jt=e=>`${e.source}\u0000${e.ref}`,Yt=e=>e.status!==`skip`&&e.status!==`same`;function Xt(e){try{return new URL(e).host}catch{return e}}function Zt({open:e,onOpenChange:t}){let{t:n}=E(),{toast:r}=fe(),i=U(e),a=ie(),[o,s]=(0,J.useState)(``),[c,u]=(0,J.useState)(new Set),[d,f]=(0,J.useState)(null);(0,J.useEffect)(()=>{i.data&&u(new Set(i.data.flatMap(e=>e.items).filter(e=>e.status===`new`).map(Jt)))},[i.data]),(0,J.useEffect)(()=>{e&&(s(``),f(null))},[e]);let p=o.trim().toLowerCase(),m=e=>!p||e.name.toLowerCase().includes(p)||e.endpoints.some(e=>e.baseUrl.toLowerCase().includes(p)),h=(0,J.useMemo)(()=>(i.data??[]).flatMap(e=>e.items).filter(e=>c.has(Jt(e))&&Yt(e)),[i.data,c]),g=(e,t)=>u(n=>{let r=new Set(n);return t?r.add(Jt(e)):r.delete(Jt(e)),r});return(0,X.jsx)(ae,{open:e,onOpenChange:t,width:680,title:n(`import.title`),description:n(`import.detail`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{icon:(0,X.jsx)(Pe,{className:`size-3.5`}),onClick:()=>void i.refetch(),disabled:i.isFetching||a.isPending,children:n(`import.rescan`)}),(0,X.jsx)(l,{variant:`primary`,disabled:h.length===0||a.isPending,onClick:()=>{f(null),a.mutate(h.map(e=>({source:e.source,ref:e.ref})),{onSuccess:e=>{let i=e.skipped.length;r(i>0?n(`import.doneSkipped`,{count:e.added.length,skipped:i}):n(`import.done`,{count:e.added.length})),t(!1)},onError:e=>{f(R(e)),i.refetch()}})},children:n(`import.selected`,{count:h.length})})]}),children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(v,{value:o,onChange:s,placeholder:n(`import.search`)}),d&&(0,X.jsx)(y,{tone:`danger`,title:n(`common.error`),children:d}),i.isLoading&&(0,X.jsx)(F,{lines:3}),i.isError&&(0,X.jsx)(y,{tone:`danger`,title:n(`common.error`),children:R(i.error)}),(0,X.jsx)(`div`,{className:`grid max-h-[460px] gap-4 overflow-auto pr-1`,children:i.data?.map(e=>(0,X.jsx)(Qt,{source:e,matches:m,selected:c,onToggle:g,filtering:p.length>0},e.id))}),(0,X.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`import.footnote`)})]})})}function Qt({source:e,matches:t,selected:n,onToggle:r,filtering:i}){let{t:a}=E(),o=e.items.filter(t);return(0,X.jsxs)(`section`,{"aria-label":e.name,children:[(0,X.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 px-1`,children:[(0,X.jsx)(`h3`,{className:`text-[13px] font-medium`,children:e.name}),e.path&&(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-[var(--text-muted)]`,title:a(`import.path`,{path:e.path}),children:e.path})]}),e.error?(0,X.jsx)(y,{tone:`danger`,title:a(`import.sourceError`,{error:e.error})}):e.found?o.length===0?(0,X.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:a(i?`import.noMatch`:`import.noItems`)}):(0,X.jsx)(`ul`,{className:`card divide-y divide-[var(--border)]`,children:o.map(e=>(0,X.jsx)($t,{c:e,checked:n.has(Jt(e)),onToggle:t=>r(e,t)},Jt(e)))}):(0,X.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:a(`import.notFound`)})]})}function $t({c:e,checked:t,onToggle:n}){let{t:r}=E(),i=Yt(e),o=e.status===`skip`&&e.skipReason?r(`import.skip.${e.skipReason}`):e.status===`same`&&e.existing?r(`import.existing`,{name:e.existing.name}):e.status===`sameHost`&&e.existing?r(`import.sameHostHint`,{name:e.existing.name}):null,s=e.endpoints.map(e=>`${Kt[e.protocol]??e.protocol} · ${Xt(e.baseUrl)}`).join(` / `);return(0,X.jsxs)(`li`,{className:a(`flex items-start gap-3 px-4 py-3`,!i&&`opacity-60`),children:[(0,X.jsx)(Me,{checked:t&&i,disabled:!i,onCheckedChange:e=>n(e===!0),"aria-label":e.name}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,title:e.name,children:e.name}),(0,X.jsx)(S,{tone:qt[e.status],children:r(`import.status.${e.status}`)}),e.fromApp&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:e.fromApp})]}),s&&(0,X.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-[var(--text-muted)]`,title:s,children:s}),(0,X.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-3 text-[11px] text-[var(--text-muted)]`,children:[(0,X.jsx)(`span`,{className:`font-mono`,children:e.hasKey?e.keyMasked??`••••`:r(`import.noKey`)}),e.models.length>0&&(0,X.jsx)(`span`,{children:r(`import.models`,{count:e.models.length})}),e.templateId&&(0,X.jsx)(`span`,{children:r(`import.template`,{id:e.templateId})})]}),o&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--text-secondary,var(--text-muted))]`,children:o}),e.ignoredFields.length>0&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--warning)]`,children:r(`import.ignored`,{fields:e.ignoredFields.join(`, `)})})]})]})}var en=``,tn=`custom`,nn=[{name:`userId`,secret:!1,required:!1},{name:`accessToken`,secret:!0,required:!1}],rn={method:`GET`,url:`{{baseUrl}}/user/balance`,auth:`provider`,headers:{}},an={isValid:`is_active`,remaining:`balance`,unit:{$const:`USD`}},on=e=>JSON.stringify(e??{},null,2);function sn(e){return{enabled:e.enabled,template:e.template??en,intervalMinutes:e.intervalMinutes??null,timeoutSec:e.timeoutSec,baseUrl:e.baseUrl??``,params:{...e.params},secrets:{},method:e.request?.method??`GET`,url:e.request?.url??``,auth:e.request?.auth??`provider`,headers:on(e.request?.headers),extract:e.extract?on(e.extract):``}}function cn(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`&&!Array.isArray(t)?t:null}catch{return null}}function ln({provider:e}){let{t}=E(),{toast:n}=fe(),r=P(),i=B(e.id),a=x(e.id),o=z(),s=e.quotaConfig,c=(0,J.useMemo)(()=>sn(s),[s]),[u,d]=(0,J.useState)(c),[h,g]=(0,J.useState)(null);(0,J.useEffect)(()=>d(c),[c]);let _=r.data??[],v=_.find(e=>e.id===s.suggestedTemplate),b=u.template===en?v:_.find(e=>e.id===u.template),S=u.template===tn,C=S?nn:b?.params??[],w=e=>d(t=>({...t,...e})),T=JSON.stringify(u)!==JSON.stringify(c),k=e=>{if(e!==tn||u.url)return w({template:e});let t=b??v;w({template:e,method:t?.request.method??rn.method,url:t?.request.url??rn.url,auth:t?.request.auth??rn.auth,headers:on(t?.request.headers??rn.headers),extract:on(t?.extract??an)})},j=()=>{let e={enabled:u.enabled,template:u.template===en?null:u.template,intervalMinutes:u.intervalMinutes,timeoutSec:u.timeoutSec??10,baseUrl:u.baseUrl.trim()||null,params:Object.fromEntries(Object.entries(u.params).filter(([,e])=>e.trim()!==``).map(([e,t])=>[e,t.trim()])),secrets:Object.fromEntries(Object.entries(u.secrets).filter(([,e])=>e.trim()!==``))};if(S){let r=cn(u.headers),i=cn(u.extract);if(!r||!i)return n(t(`providers.quota.invalidJson`,{field:t(r?`providers.quota.extract`:`providers.quota.headers`)}),`error`),null;e.request={method:u.method,url:u.url.trim(),auth:u.auth,headers:r},e.extract=i}return e},N=()=>{let r=j();if(!r)return;let a=r.enabled&&!s.enabled;i.mutate(r,{onSuccess:()=>{n(t(`common.saved`),`success`),a&&o.mutate(e.id,{onError:e=>n(R(e),`error`)})},onError:e=>n(R(e),`error`)})},F=()=>{let e=j();e&&a.mutate(e,{onSuccess:g,onError:e=>n(R(e),`error`)})},ee=s.effectiveIntervalMinutes>0?t(`providers.quota.intervalEvery`,{minutes:s.effectiveIntervalMinutes}):t(`providers.quota.intervalOff`),te=[{value:en,label:v?t(`providers.quota.templateAuto`,{name:v.name}):t(`providers.quota.templateNone`)},..._.map(e=>({value:e.id,label:e.name,detail:t(`providers.quota.kind.${e.kind}`)})),{value:tn,label:t(`providers.quota.custom`)}];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(O,{title:t(`providers.quota.title`),footer:t(`providers.quota.footer`),children:[(0,X.jsx)(f,{label:t(`providers.quota.enable`),detail:t(`providers.quota.enableHint`),children:(0,X.jsx)(M,{checked:u.enabled,label:t(`providers.quota.enable`),onChange:e=>w({enabled:e})})}),(0,X.jsx)(f,{label:t(`providers.quota.template`),children:(0,X.jsx)(pe,{className:`w-64`,ariaLabel:t(`providers.quota.template`),value:u.template,onChange:k,options:te})}),C.map(e=>{let n=t(`providers.quota.param.${e.name}`),r=s.secrets.includes(e.name);return e.secret?(0,X.jsx)(f,{label:n,detail:r?t(`providers.quota.secretStored`):void 0,children:(0,X.jsx)(p,{type:`password`,autoComplete:`off`,className:`w-64 font-mono`,"aria-label":n,placeholder:r?`••••••••`:``,value:u.secrets[e.name]??``,onChange:t=>w({secrets:{...u.secrets,[e.name]:t.target.value}})})},e.name):(0,X.jsx)(f,{label:n,children:(0,X.jsx)(p,{className:`w-64 font-mono`,"aria-label":n,value:u.params[e.name]??``,onChange:t=>w({params:{...u.params,[e.name]:t.target.value}})})},e.name)}),C.length>0&&(0,X.jsx)(`div`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.paramsHint`)}),S&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(pe,{className:`w-28`,ariaLabel:t(`providers.quota.method`),value:u.method,onChange:e=>w({method:e}),options:[{value:`GET`,label:`GET`},{value:`POST`,label:`POST`}]}),(0,X.jsx)(p,{className:`min-w-60 flex-1 font-mono`,"aria-label":t(`providers.quota.url`),value:u.url,onChange:e=>w({url:e.target.value})}),(0,X.jsx)(pe,{className:`w-52`,ariaLabel:t(`providers.quota.auth`),value:u.auth,onChange:e=>w({auth:e}),options:[{value:`provider`,label:t(`providers.quota.auth.provider`)},{value:`none`,label:t(`providers.quota.auth.none`)}]})]}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.urlHint`)}),(0,X.jsx)(I,{label:t(`providers.quota.headers`),mono:!0,rows:3,value:u.headers,onChange:e=>w({headers:e.target.value})}),(0,X.jsx)(I,{label:t(`providers.quota.extract`),mono:!0,rows:8,value:u.extract,onChange:e=>w({extract:e.target.value})}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.extractHint`)})]}),(0,X.jsx)(f,{label:t(`providers.quota.interval`),detail:t(`providers.quota.intervalHint`,{value:ee}),children:(0,X.jsx)(A,{className:`w-28`,label:t(`providers.quota.interval`),min:0,step:1,value:u.intervalMinutes,onChange:e=>w({intervalMinutes:e})})}),(0,X.jsx)(f,{label:t(`providers.quota.timeout`),children:(0,X.jsx)(A,{className:`w-28`,label:t(`providers.quota.timeout`),min:1,step:1,value:u.timeoutSec,onChange:e=>w({timeoutSec:e})})}),(0,X.jsx)(f,{label:t(`providers.quota.baseUrl`),detail:t(`providers.quota.baseUrlHint`),children:(0,X.jsx)(p,{className:`w-64 font-mono`,"aria-label":t(`providers.quota.baseUrl`),placeholder:e.endpoints[0]?.baseUrl,value:u.baseUrl,onChange:e=>w({baseUrl:e.target.value})})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 py-3`,children:[(0,X.jsx)(l,{size:`sm`,variant:`primary`,disabled:!T,loading:i.isPending,onClick:N,children:t(`common.save`)}),(0,X.jsx)(l,{size:`sm`,icon:(0,X.jsx)(qe,{className:`size-3.5`}),loading:a.isPending,onClick:F,title:t(`providers.quota.testDesc`),children:t(`providers.quota.test`)}),(0,X.jsx)(l,{size:`sm`,icon:(0,X.jsx)(Ye,{className:`size-3.5`}),disabled:T,loading:o.isPending,onClick:()=>o.mutate(e.id,{onError:e=>n(R(e),`error`)}),children:t(`providers.quota.fetch`)})]}),(0,X.jsx)(`div`,{className:`px-4 pb-4`,children:(0,X.jsx)(un,{snapshot:e.quota,checkedAtUtc:e.quotaCheckedAtUtc})})]}),(0,X.jsx)(ae,{open:h!==null,onOpenChange:e=>!e&&g(null),title:t(`providers.quota.test`),description:t(`providers.quota.testDesc`),width:560,children:h&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(y,{tone:h.ok?`success`:`danger`,title:h.ok?t(`providers.quota.testOk`):t(`providers.quota.testFailed`),children:[!h.ok&&L({code:h.errorCode??null,message:h.error??``},t),!h.ok&&h.error&&h.errorCode&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] opacity-80`,children:h.error})]}),h.url&&(0,X.jsx)(D,{label:t(`providers.quota.requestUrl`),mono:!0,children:h.url}),h.httpStatus!=null&&(0,X.jsx)(D,{label:t(`providers.quota.httpStatus`),children:h.httpStatus}),h.snapshot&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[12px] text-[var(--text-secondary)]`,children:t(`providers.quota.extracted`)}),(0,X.jsx)(un,{snapshot:h.snapshot})]}),h.raw!==void 0&&h.raw!==null&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[12px] text-[var(--text-secondary)]`,children:t(`providers.quota.rawResponse`)}),(0,X.jsx)(m,{children:on(h.raw)})]})]})})]})}function un({snapshot:t,checkedAtUtc:n}){let{t:r,locale:i}=E(),a=de(t),o=t?.plans??[],s=t?.fetchedAtUtc?new Date(t.fetchedAtUtc).getTime():0;return!t&&!n?(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`providers.quota.never`)}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a&&(0,X.jsxs)(y,{tone:`warning`,title:r(`providers.quota.failed`,{error:L(a,r)}),children:[(0,X.jsx)(`span`,{className:`text-[11px]`,children:a.message}),o.length>0&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px]`,children:r(`providers.quota.lastGood`)})]}),t?.isValid===!1&&(0,X.jsx)(y,{tone:`warning`,title:r(`providers.quota.invalid`),children:t.invalidMessage}),o.length>0&&(0,X.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map((t,n)=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 text-[13px]`,children:[t.name&&(0,X.jsx)(S,{children:t.name}),(0,X.jsx)(`span`,{className:`num`,children:e(t,r,i)??`—`}),H(t,r,i)&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:H(t,r,i)}),t.extra&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:t.extra})]},n))}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-[var(--text-muted)]`,children:[t?.planLabel&&(0,X.jsx)(S,{tone:`accent`,children:t.planLabel}),s>0&&(0,X.jsx)(`span`,{children:r(`providers.quota.fetchedAt`,{time:Se(s,i,r(`tray.justNow`))??``})})]})]})}function dn({provider:e}){let{t,locale:n}=E(),{toast:r}=fe(),i=z();if(!ve(e))return null;let a=he(e.quota,t,n),o=de(e.quota);return(0,X.jsxs)(`div`,{className:`mt-3 flex min-w-0 items-center gap-2 text-[12px]`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a&&(0,X.jsx)(`div`,{className:`num truncate text-[var(--text-secondary)]`,title:a,children:a}),o&&(0,X.jsx)(`div`,{className:`truncate text-[var(--warning)]`,title:o.message,children:t(`providers.quota.failed`,{error:L(o,t)})}),!a&&!o&&(0,X.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:t(`providers.quota.never`)})]}),(0,X.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(Ye,{className:`size-3.5`}),"aria-label":t(`providers.quota.refresh`),title:t(`providers.quota.refresh`),loading:i.isPending,onClick:()=>i.mutate(e.id,{onError:e=>r(R(e),`error`)})})]})}var fn=[{value:`openai-chat`,label:`OpenAI Chat`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic`,label:`Anthropic Messages`},{value:`gemini`,label:`Gemini`}],pn=[{value:`bearer`,label:`Authorization: Bearer`},{value:`x-api-key`,label:`x-api-key`},{value:`x-goog-api-key`,label:`x-goog-api-key`},{value:`query-key`,label:`?key=`},{value:`none`,label:`—`},{value:`oauth-subscription`,label:`OAuth 订阅`}];function mn(){let{t:e}=E(),t=Ee(),[n,r]=we(),i=ee(),[a,o]=(0,J.useState)(n.get(`new`)===`1`),[s,c]=(0,J.useState)(!1);(0,J.useEffect)(()=>{n.get(`new`)===`1`&&(o(!0),n.delete(`new`),r(n,{replace:!0}))},[n,r]),De(e=>{e===`new-provider`&&o(!0)});let u=se(`7d`,`day`,`provider`),[d,f]=(0,J.useState)(null),p=(0,J.useMemo)(()=>{let e=gn(hn),t=new Map;for(let n of u.data??[]){let r=e.indexOf(n.bucket);if(r<0)continue;let i=t.get(n.key);i||t.set(n.key,i={requests:e.map(()=>0),costUsd:0}),i.requests[r]=(i.requests[r]??0)+n.requests,i.costUsd+=n.costUsd}return{days:e,byProvider:t}},[u.data]);return(0,X.jsxs)(Ae,{title:e(`nav.providers`),subtitle:i.data?e(`providers.count`,{count:i.data.length}):void 0,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{icon:(0,X.jsx)(Ne,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`providers.import`)}),(0,X.jsx)(l,{variant:`primary`,icon:(0,X.jsx)(ke,{className:`size-3.5`}),onClick:()=>o(!0),children:e(`providers.add`)})]}),children:[(0,X.jsxs)(`div`,{className:`mx-auto max-w-[1100px]`,children:[i.isLoading&&(0,X.jsx)(F,{lines:4}),i.isError&&(0,X.jsx)(y,{tone:`danger`,title:e(`common.error`),children:R(i.error)}),i.data?.length===0&&(0,X.jsx)(`div`,{className:`card`,children:(0,X.jsx)(be,{icon:(0,X.jsx)(Te,{className:`size-6`}),title:e(`providers.empty`),detail:e(`providers.emptyDetail`),action:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,X.jsx)(l,{variant:`primary`,icon:(0,X.jsx)(ke,{className:`size-3.5`}),onClick:()=>o(!0),children:e(`providers.add`)}),(0,X.jsx)(l,{icon:(0,X.jsx)(Ne,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`providers.import`)})]})})}),i.data&&i.data.length>0&&(0,X.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,260px),1fr))] gap-3`,children:i.data.map(e=>(0,X.jsx)(yn,{p:e,days:p.days,usage:p.byProvider.get(e.name),onOpen:()=>t(`/providers/${e.id}`),onTest:()=>f(e)},e.id))})]}),(0,X.jsx)(Zt,{open:s,onOpenChange:c}),(0,X.jsx)(Sn,{open:a,onOpenChange:o,onCreated:e=>t(`/providers/${e.id}`)}),d&&(0,X.jsx)(An,{provider:d,open:!0,onOpenChange:e=>!e&&f(null)})]})}var hn=7;function gn(e){let t=new Date;return Array.from({length:e},(n,r)=>{let i=new Date(t.getFullYear(),t.getMonth(),t.getDate()-(e-1-r));return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,`0`)}-${String(i.getDate()).padStart(2,`0`)}`})}function _n(e){if(!e)return null;try{return new URL(e).host}catch{return e}}var vn=e=>e.stopPropagation();function yn({p:e,days:t,usage:n,onOpen:r,onTest:i}){let{t:o}=E(),s=d(e.id),{toast:c}=fe(),u=[...new Set(e.endpoints.map(e=>e.protocol))],f=!e.hasApiKey&&e.authScheme!==`none`&&e.authScheme!==`oauth-subscription`&&e.authScheme!==`plugin`,p=[e.priceKey?o(`providers.priceKeyShort`,{key:e.priceKey}):null,e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `),m=e.authScheme===`plugin`?o(`providers.card.plugin`):e.authScheme===`oauth-subscription`?o(`providers.card.subscription`):e.authScheme===`none`?o(`providers.card.noAuth`):e.hasApiKey?e.apiKeyMasked??`••••`:o(`providers.noKey`),h=e.enabled?f?{tone:`orange`,label:o(`providers.noKey`)}:{tone:`green`,label:o(`providers.card.active`)}:{tone:`neutral`,label:o(`providers.card.disabled`)},g=n?.requests??t.map(()=>0),_=g.reduce((e,t)=>e+t,0),v=e.templateUpdateAvailable?5:8;return(0,X.jsxs)(ht,{className:`flex flex-col [&>div:first-child>div]:min-h-0! [&>div:last-child]:flex [&>div:last-child]:flex-1 [&>div:last-child]:flex-col [&>div:last-child]:p-3 [&>div:last-child>:last-child]:mt-auto! [&>div:last-child>:last-child]:min-h-[44px] [&>div:last-child>:last-child]:pt-2 [&>div:last-child>h3]:line-clamp-1 [&>div:last-child>h3]:text-[15px] [&>div:last-child>p]:line-clamp-2 [&>div:last-child>p]:min-h-[2lh] [&>div:last-child>p]:text-[12px]`,"data-density":`compact`,role:`button`,tabIndex:0,"aria-label":e.name,onClick:r,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},style:{backgroundColor:`var(--surface)`},title:e.name,description:u.map(e=>fn.find(t=>t.value===e)?.label??e).join(` / `),media:(0,X.jsxs)(`div`,{className:`flex flex-col justify-between gap-1.5 self-stretch justify-self-stretch px-3 py-2.5`,style:{background:`linear-gradient(135deg, color-mix(in oklab, var(--accent) 12%, transparent), transparent 70%)`},children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:a(`transition-[filter,opacity]`,!e.enabled&&`opacity-50 grayscale`),children:(0,X.jsx)(Re,{name:e.name,icon:e.icon,colorKey:e.templateId,size:28})}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-[var(--border)] bg-[color-mix(in_oklab,var(--surface)_80%,transparent)] px-2 py-0.5 text-[11px] text-[var(--text-secondary)]`,children:[(0,X.jsx)(w,{tone:h.tone}),h.label]})]}),(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[11px] text-[var(--text-muted)]`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:e.endpoints[0]?.baseUrl,children:_n(e.endpoints[0]?.baseUrl)??`—`}),(0,X.jsx)(`span`,{className:`shrink-0`,children:o(`providers.modelCount`,{count:e.modelCount})})]})]}),meta:(0,X.jsx)(`span`,{className:a(e.hasApiKey&&e.authScheme!==`oauth-subscription`&&`font-mono`),children:m}),status:p||void 0,action:(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,onClick:vn,children:[(0,X.jsx)(l,{variant:`plain`,size:`sm`,icon:(0,X.jsx)(qe,{className:`size-3.5`}),"aria-label":o(`providers.test`),title:o(`providers.test`),onClick:i}),(0,X.jsx)(`span`,{className:`ml-1 inline-flex`,children:(0,X.jsx)(M,{checked:e.enabled,label:o(`common.enabled`),onChange:e=>s.mutate({enabled:e},{onError:e=>c(R(e),`error`)})})})]}),children:[(0,X.jsxs)(`div`,{className:`mt-1.5 flex h-5 flex-nowrap items-center gap-1 overflow-hidden`,children:[e.templateUpdateAvailable&&(0,X.jsx)(S,{tone:`accent`,children:o(`providers.templateUpdate`)}),e.boundClients.slice(0,v).map(e=>e in Be?(0,X.jsx)(`span`,{title:Ie(e),className:`inline-flex shrink-0`,children:(0,X.jsx)(ze,{kind:e,size:18})},e):(0,X.jsx)(S,{tone:`green`,children:e},e)),e.boundClients.length>v&&(0,X.jsxs)(`span`,{title:e.boundClients.slice(v).map(e=>Be[e]?.name??e).join(`, `),className:`shrink-0 text-[11px] text-[var(--text-muted)]`,children:[`+`,e.boundClients.length-v]})]}),(0,X.jsx)(`div`,{className:`min-h-[32px] [&>div]:mt-1`,onClick:vn,children:(0,X.jsx)(dn,{provider:e})}),(0,X.jsx)(`div`,{className:`mt-2`,onClick:vn,children:_>0?(0,X.jsx)(jt,{label:o(`providers.card.requests7d`),data:g,labels:t.map(e=>e.slice(5)),value:ne(_,!0),change:le(n?.costUsd??0),width:320,height:28,formatValue:e=>ne(e,!0)}):(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(`div`,{className:`text-[13px] text-[var(--text-secondary)]`,children:o(`providers.card.requests7d`)}),(0,X.jsx)(`div`,{className:`grid aspect-[320/28] place-items-center border-b border-dashed border-[var(--border)] text-[11px] text-[var(--text-muted)]`,children:o(`providers.card.noRequests`)})]})})]})}var bn=`plugin:`,xn=[`recommended`,`official`,`subscription`,`cn`,`aggregator`,`local`,`custom`];function Sn({open:e,onOpenChange:t,onCreated:n}){let{t:i}=E(),{toast:a}=fe(),o=s(),c=k(),u=N(),d=ee(),f=(0,J.useMemo)(()=>new Set((d.data??[]).filter(e=>e.authScheme===`oauth-subscription`&&e.templateId).map(e=>e.templateId)),[d.data]),m=Ee(),[h,g]=(0,J.useState)(``),[_,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(null),[C,w]=(0,J.useState)(``),[T,D]=(0,J.useState)(``),[O,A]=(0,J.useState)(``),[j,M]=(0,J.useState)(``),[P,I]=(0,J.useState)(``),[L,te]=(0,J.useState)(`openai-chat`),[z,B]=(0,J.useState)(`bearer`);(0,J.useEffect)(()=>{e||(b(null),S(null),g(``),w(``),D(``),A(``),M(``),I(``))},[e]);let ne=(0,J.useMemo)(()=>{let e=h.trim().toLowerCase(),t=(o.data??[]).filter(t=>!e||t.name.toLowerCase().includes(e)||t.id.includes(e));return xn.map(e=>({category:e,items:t.filter(t=>t.category===e)})).filter(e=>e.items.length)},[o.data,h]),V=(0,J.useMemo)(()=>{let e=h.trim().toLowerCase();return(d.data??[]).filter(t=>t.authScheme===`plugin`&&!t.settings.plugin?.absent&&(!e||t.name.toLowerCase().includes(e)||t.id.includes(e)))},[d.data,h]),H=e=>{b(e),e===`custom`?(w(``),M(``),A(``)):(w(e.name),M(e.priceKey??e.id),A(``),B(e.auth.scheme))},re=()=>{let e=_===`custom`;u.mutate({templateId:e?null:_.id,variantId:O||null,name:C.trim()||null,apiKey:T.trim()||null,priceKey:j,...e?{endpoints:[{protocol:L,baseUrl:P.trim()}],authScheme:z}:{}},{onSuccess:e=>{t(!1),a(i(`providers.created`,{name:e.name}),`success`),n(e)},onError:e=>a(R(e),`error`)})},U=_&&_!==`custom`?_:null,ie=()=>{if(x===`custom`)H(`custom`);else if(x?.startsWith(bn)){let e=V.find(e=>bn+e.id===x);e&&(t(!1),n(e))}else{let e=(o.data??[]).find(e=>e.id===x);e&&!f.has(e.id)&&H(e)}},W=_!==null&&(_===`custom`?/^https?:\/\//.test(P.trim())&&C.trim()!==``:!U.requiresApiKey||T.trim()!==``);return(0,X.jsxs)(ae,{open:e,onOpenChange:t,width:640,title:i(_?`providers.addTitleDetails`:`providers.addTitle`),description:_?U?U.name:i(`providers.custom`):i(`providers.addDetail`),footer:_?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{className:`mr-auto`,variant:`plain`,onClick:()=>b(null),children:i(`common.back`)}),(0,X.jsx)(l,{onClick:()=>t(!1),children:i(`common.cancel`)}),(0,X.jsx)(l,{variant:`primary`,disabled:!W,loading:u.isPending,onClick:re,children:i(`providers.create`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{onClick:()=>t(!1),children:i(`common.cancel`)}),(0,X.jsx)(l,{variant:`primary`,disabled:!x,onClick:ie,children:i(`common.continue`)})]}),children:[(0,X.jsx)(Gt,{className:`mb-6`,label:i(`providers.addTitle`),current:+!!_,steps:[{id:`template`,label:i(`providers.step.template`)},{id:`details`,label:i(`providers.step.details`)}]}),_?(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(r,{label:i(`providers.name`),children:(0,X.jsx)(p,{value:C,onChange:e=>w(e.target.value)})}),U?.variants&&U.variants.length>0&&(0,X.jsx)(r,{label:i(`providers.variant`),children:(0,X.jsx)(pe,{value:O,onChange:e=>{A(e);let t=U.variants?.find(t=>t.id===e);M(t?.priceKey??U.priceKey??U.id)},options:[{value:``,label:i(`providers.variantDefault`)},...U.variants.map(e=>({value:e.id,label:e.name}))]})}),_===`custom`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{label:i(`providers.baseUrl`),hint:i(`providers.baseUrlHint`),children:(0,X.jsx)(p,{value:P,onChange:e=>I(e.target.value),placeholder:`https://api.example.com/v1`,className:`font-mono`})}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,X.jsx)(r,{label:i(`providers.protocol`),children:(0,X.jsx)(pe,{value:L,onChange:te,options:fn})}),(0,X.jsx)(r,{label:i(`providers.authScheme`),children:(0,X.jsx)(pe,{value:z,onChange:B,options:pn})})]})]}),U?.authScheme===`oauth-subscription`?(0,X.jsx)(y,{tone:`info`,title:i(`providers.subscriptionWizardHint`),children:i(`providers.subscriptionWizardDetail`)}):(0,X.jsxs)(`div`,{className:`font-mono`,children:[(0,X.jsx)(Ve,{label:i(`providers.apiKey`),description:i(`providers.apiKeyHint`),autoComplete:`off`,placeholder:`sk-…`,value:T,onChange:e=>D(e.target.value)}),U?.apiKeyUrl&&(0,X.jsx)(`a`,{className:`mt-2 inline-block font-sans text-[12px] text-[var(--accent)]`,href:U.apiKeyUrl,target:`_blank`,rel:`noreferrer`,children:i(`providers.getKey`)})]}),(0,X.jsx)(r,{label:i(`providers.priceKey`),hint:i(`providers.priceKeyHint`),children:(0,X.jsx)(pe,{value:j,onChange:M,options:[{value:``,label:i(`providers.priceKeyNone`)},...(c.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey}))]})}),U&&U.models.length>0&&(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:i(`providers.templateModels`,{count:U.models.length})})]}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsx)(v,{value:h,onChange:g,placeholder:i(`providers.searchTemplates`)}),o.isLoading&&(0,X.jsx)(F,{lines:4}),o.isError&&(0,X.jsx)(y,{tone:`danger`,title:i(`common.error`),children:R(o.error)}),ne.map(e=>(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:i(`providers.category.${e.category}`)}),(0,X.jsx)(He,{name:`provider-template`,"aria-label":i(`providers.category.${e.category}`),minColumnWidth:170,value:e.items.some(e=>e.id===x)?x:null,onValueChange:S,options:e.items.map(e=>({value:e.id,label:e.name,description:[...new Set(e.endpoints.map(e=>e.protocol))].join(` · `),icon:(0,X.jsx)(Re,{name:e.name,icon:e.icon,colorKey:e.id,size:24}),disabled:f.has(e.id),disabledReason:i(`providers.subscriptionAdded`)}))})]},e.category)),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:i(`providers.category.plugin`)}),V.length>0?(0,X.jsx)(He,{name:`provider-template-plugin`,"aria-label":i(`providers.category.plugin`),minColumnWidth:170,value:x?.startsWith(bn)?x:null,onValueChange:S,options:V.map(e=>({value:bn+e.id,label:e.name,description:i(`providers.pluginProvided`),icon:(0,X.jsx)(Re,{name:e.name,icon:e.icon,colorKey:e.id,size:24})}))}):(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-[var(--radius-md)] border border-dashed border-[var(--border)] px-3 py-2.5`,children:[(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-[12px] text-[var(--text-secondary)]`,children:i(`providers.pluginHint`)}),(0,X.jsx)(l,{size:`sm`,onClick:()=>{t(!1),m(`/plugins/market`)},children:i(`plugins.browseMarket`)})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:i(`providers.custom`)}),(0,X.jsx)(He,{name:`provider-template-custom`,"aria-label":i(`providers.custom`),layout:`list`,value:x===`custom`?`custom`:null,onValueChange:S,options:[{value:`custom`,label:i(`providers.custom`),description:i(`providers.customDetail`),icon:(0,X.jsx)(ke,{className:`size-4`})}]})]})]})]})}var Cn=3,wn=256,Tn=4096,En={idle:`providers.testDialog.status.idle`,queued:`providers.testDialog.status.queued`,running:`providers.testDialog.status.running`,success:`providers.testDialog.status.success`,failed:`providers.testDialog.status.failed`,cancelled:`providers.testDialog.status.cancelled`};function Dn(e){let t=e.endpoints.map(e=>e.protocol);return e.preferredUpstreamProtocols.find(e=>t.includes(e))??t[0]??`openai-chat`}var On=e=>typeof e==`number`?e:null,kn=e=>typeof e==`string`?e:null;function An({provider:e,open:t,onOpenChange:n}){let{t:i}=E(),a=C(),o=_(t?e.id:void 0),s=e.endpoints.map(e=>e.protocol),[c,u]=(0,J.useState)(`single`),[d,f]=(0,J.useState)(()=>Dn(e)),[p,m]=(0,J.useState)(!0),[h,v]=(0,J.useState)(``),[y,b]=(0,J.useState)(wn),[x,S]=(0,J.useState)(``),[w,T]=(0,J.useState)(null),[D,O]=(0,J.useState)({}),[k,A]=(0,J.useState)([]),[j,M]=(0,J.useState)(new Set),[N,P]=(0,J.useState)([]),[F,ee]=(0,J.useState)(``),[I,L]=(0,J.useState)(null),[R,te]=(0,J.useState)(!1),z=(0,J.useRef)(null),B=(0,J.useRef)(new Map),ne=(0,J.useRef)(!1),V=(0,J.useRef)(!1),H=(0,J.useMemo)(()=>{let e=[...o.data??[]].sort((e,t)=>Number(t.enabled)-Number(e.enabled)||e.sortOrder-t.sortOrder).map(e=>e.modelId);return[...e,...N.filter(t=>!e.includes(t))]},[o.data,N]);(0,J.useEffect)(()=>{if(t){S(e=>e||(o.data??[]).find(e=>e.enabled)?.modelId||(o.data??[])[0]?.modelId||``);return}V.current=!1,z.current?.abort();for(let e of B.current.values())e.abort();B.current.clear(),T(null),O({}),A([]),M(new Set),P([]),ee(``),L(null)},[t,o.data]);let re=(0,J.useCallback)(e=>({modelId:e,protocol:d,stream:p,prompt:h.trim()||null,maxOutputTokens:y??wn}),[d,p,h,y]),U=(0,J.useCallback)((t,n,r)=>zn(e.id,t,re(t),n,r),[e.id,re]),ie=()=>{let e=x.trim();if(!e)return;z.current?.abort();let t=new AbortController;z.current=t,V.current=!0,L(null),T({modelId:e,status:`running`,text:``,reasoning:``}),U(e,t.signal,e=>{e.status!==`running`&&e.status!==`queued`&&oe(),T(e)})},W=e=>{if(e.length===0)return;V.current=!0,ne.current=!1,L(null),A(e),O(Object.fromEntries(e.map(e=>[e,{modelId:e,status:`queued`,text:``,reasoning:``}])));let t=0;Promise.all(Array.from({length:Math.min(Cn,e.length)},async()=>{for(;;){if(!V.current)return;let n=e[t++];if(n===void 0)return;if(ne.current){O(e=>({...e,[n]:{...e[n],status:`cancelled`}}));continue}let r=new AbortController;B.current.set(n,r),await U(n,r.signal,e=>O(t=>({...t,[n]:e}))),B.current.delete(n),oe()}}))},oe=()=>void a.invalidateQueries({queryKey:[`requests`]}),se=()=>{ne.current=!0,O(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.status===`queued`?{...t,status:`cancelled`}:t])))},ce=w?.status===`running`||k.some(e=>D[e]?.status===`running`||D[e]?.status===`queued`&&!ne.current),le=k.filter(e=>D[e]&&D[e].status!==`queued`&&D[e].status!==`running`).length,ue=k.filter(e=>D[e]?.status===`success`).length,de=k.filter(e=>D[e]?.status===`failed`).length,G=(e,t)=>M(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),fe=()=>{ce||n(!1)},K=e=>e.stopPropagation();return(0,X.jsx)(`span`,{onClick:K,onKeyDown:K,children:(0,X.jsxs)(ae,{open:t,onOpenChange:e=>e?n(!0):fe(),width:1040,title:i(`providers.testDialog.title`,{name:e.name}),description:i(`providers.testDialog.subtitle`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mr-auto text-[11px] text-[var(--text-muted)]`,children:i(`providers.testDialog.realRequest`)}),(0,X.jsx)(l,{disabled:ce,onClick:()=>n(!1),icon:(0,X.jsx)(ge,{className:`size-3.5`}),children:i(`common.close`)}),c===`single`?ce?(0,X.jsx)(l,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:()=>z.current?.abort(),children:i(`providers.testDialog.stop`)}):(0,X.jsx)(l,{variant:`primary`,disabled:x.trim()===``,icon:(0,X.jsx)(qe,{className:`size-3.5`}),onClick:ie,children:i(w?`providers.testDialog.retest`:`providers.testDialog.start`)}):ce?(0,X.jsx)(l,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:se,children:i(`providers.testDialog.stopRest`)}):(0,X.jsx)(l,{variant:`primary`,disabled:j.size===0,icon:(0,X.jsx)(qe,{className:`size-3.5`}),onClick:()=>W([...j]),children:i(`providers.testDialog.testN`,{count:j.size})})]}),children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pb-4`,children:[(0,X.jsx)(Re,{name:e.name,icon:e.icon,colorKey:e.templateId,size:32}),(0,X.jsx)(g,{items:[{value:`single`,label:i(`providers.testDialog.modeSingle`)},{value:`batch`,label:i(`providers.testDialog.modeBatch`)}],value:c,onChange:e=>{u(e),L(null)},ariaLabel:i(`providers.testDialog.config`)})]}),c===`single`?(0,X.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,300px)_minmax(0,1fr)] gap-6`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 border-r border-[var(--border)] pr-6`,children:[(0,X.jsx)(`h3`,{className:`text-[13px] font-medium`,children:i(`providers.testDialog.config`)}),(0,X.jsx)(r,{label:i(`providers.testDialog.model`),children:(0,X.jsx)(jn,{value:x,models:H,onChange:S})}),(0,X.jsx)(Mn,{protocols:s,protocol:d,onProtocol:f,stream:p,onStream:m,maxTokens:y,onMaxTokens:b,prompt:h,onPrompt:v}),(0,X.jsx)(`p`,{className:`mt-auto text-[11px] text-[var(--text-muted)]`,children:i(`providers.testDialog.savedCredentials`)})]}),(0,X.jsx)(Nn,{run:w,onRetest:ie})]}):I===null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ln,{known:H,selected:j,onToggle:G,onSelectAll:e=>M(e?new Set(H):new Set),onClear:()=>M(new Set),search:F,onSearch:ee,onAdd:e=>{P(t=>t.includes(e)?t:[...t,e]),M(t=>new Set(t).add(e)),ee(``)},configOpen:R,onConfigOpen:te,protocols:s,protocol:d,onProtocol:f,stream:p,onStream:m,maxTokens:y,onMaxTokens:b,prompt:h,onPrompt:v}),k.length>0?(0,X.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:ce?i(`providers.testDialog.progress`,{done:le,total:k.length,ok:ue,failed:de}):i(`providers.testDialog.progressDone`,{total:k.length,ok:ue,failed:de})}),(0,X.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-strong)]`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full transition-[width]`,style:{width:`${le/k.length*100}%`,background:`var(--accent)`}})})]}):null,k.length>0?(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Rn,{order:k,runs:D,onView:L})}):null]}):(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(l,{variant:`plain`,icon:(0,X.jsx)(je,{className:`size-4`}),"aria-label":i(`common.back`),onClick:()=>L(null)}),(0,X.jsx)(`span`,{className:`font-mono text-[13px]`,children:I})]}),(0,X.jsx)(Nn,{run:D[I]??null})]})]})})}function jn({value:e,models:t,onChange:n}){let{t:r}=E(),[i,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(0),[l,u]=(0,J.useState)(null),d=l===null?t:t.filter(e=>e.toLowerCase().includes(l.trim().toLowerCase())),f=()=>{u(null),c(Math.max(0,t.indexOf(e))),o(!0)},m=e=>{n(e),u(null),o(!1)};return(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(p,{className:`pr-9 font-mono`,value:e,placeholder:r(`providers.testDialog.modelPlaceholder`),"aria-expanded":i,role:`combobox`,onFocus:f,onClick:f,onChange:e=>{n(e.target.value),u(e.target.value),c(0),o(!0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!i)return f();if(d.length===0)return;let t=e.key===`ArrowDown`?1:-1;c(e=>(e+t+d.length)%d.length)}else e.key===`Enter`&&i?(e.preventDefault(),d[s]&&m(d[s])):e.key===`Escape`&&o(!1)}}),(0,X.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 grid w-8 place-items-center text-[var(--text-muted)] hover:text-[var(--text)]`,"aria-label":r(`providers.testDialog.showModels`),onClick:()=>i?o(!1):f(),children:(0,X.jsx)(ce,{className:`size-4`})}),i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`fixed inset-0 z-40`,onMouseDown:()=>o(!1)}),(0,X.jsx)(`ul`,{className:`absolute inset-x-0 top-full z-50 mt-1 max-h-64 overflow-auto rounded-lg border border-[var(--border)] bg-[var(--surface-raised)] py-1 shadow-lg`,children:d.length===0?(0,X.jsx)(`li`,{className:`px-3 py-2 text-[12px] text-[var(--text-muted)]`,children:r(`providers.testDialog.noModels`)}):d.map((e,t)=>(0,X.jsx)(`li`,{children:(0,X.jsx)(`button`,{type:`button`,className:a(`block w-full truncate px-3 py-1.5 text-left font-mono text-[12px] hover:bg-[var(--surface-strong)]`,t===s&&`bg-[var(--surface-strong)]`),onMouseEnter:()=>c(t),onMouseDown:t=>{t.preventDefault(),m(e)},children:e})},e))})]})]})}function Mn({protocols:e,...t}){let{t:n}=E(),i=e.map(e=>({value:e,label:fn.find(t=>t.value===e)?.label??e}));return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{label:n(`providers.testDialog.protocol`),children:(0,X.jsx)(pe,{value:t.protocol,onChange:t.onProtocol,options:i})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:n(`providers.testDialog.stream`)}),(0,X.jsx)(M,{checked:t.stream,label:n(`providers.testDialog.stream`),onChange:t.onStream})]}),(0,X.jsx)(r,{label:n(`providers.testDialog.maxTokens`),children:(0,X.jsx)(A,{value:t.maxTokens,min:1,placeholder:String(wn),label:n(`providers.testDialog.maxTokens`),onChange:e=>t.onMaxTokens(e===null?null:Math.min(Tn,Math.max(1,Math.round(e))))})}),(0,X.jsx)(r,{label:n(`providers.testDialog.prompt`),hint:n(`providers.testDialog.promptHint`),children:(0,X.jsx)(I,{rows:4,value:t.prompt,placeholder:`Reply with OK.`,onChange:e=>t.onPrompt(e.target.value)})})]})}function Nn({run:e,onRetest:t}){let{t:n}=E(),[r,i]=(0,J.useState)(`preview`),a=e?.text??``,o=e?.raw??``,s=Object.entries(e?.headers??{}),c=e?.ttftMs!=null&&e?.httpMs!=null?Math.max(0,e.ttftMs-e.httpMs):null,u=r===`raw`?o:r===`headers`?s.map(([e,t])=>`${e}: ${t}`).join(`
2
2
  `):a;return(0,X.jsxs)(`div`,{className:`grid min-w-0 content-start gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[t&&e&&e.status!==`running`?(0,X.jsx)(l,{size:`sm`,icon:(0,X.jsx)(qe,{className:`size-3.5`}),onClick:t,children:n(`providers.testDialog.retest`)}):null,(0,X.jsx)(Oe,{content:n(`providers.testDialog.metricsHelp`),children:(0,X.jsx)(`span`,{className:`inline-flex size-4 items-center justify-center text-[var(--text-muted)]`,tabIndex:0,children:(0,X.jsx)(Ge,{className:`size-4`})})}),(0,X.jsx)(In,{run:e}),e?.httpStatus?(0,X.jsxs)(S,{tone:`neutral`,children:[`HTTP `,e.httpStatus]}):null]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-px overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--border)] sm:grid-cols-4`,children:[(0,X.jsx)(Fn,{label:n(`providers.testDialog.metrics.http`),value:e?.httpMs}),(0,X.jsx)(Fn,{label:n(`providers.testDialog.metrics.firstWait`),value:c}),(0,X.jsx)(Fn,{label:n(`providers.testDialog.metrics.ttft`),value:e?.ttftMs}),(0,X.jsx)(Fn,{label:n(`providers.testDialog.metrics.total`),value:e?.totalMs})]}),(0,X.jsxs)(`section`,{className:`card overflow-hidden`,children:[(0,X.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2 border-b border-[var(--border)] px-4 py-2.5`,children:[(0,X.jsx)(`h3`,{className:`text-[12px] font-medium`,children:n(`providers.testDialog.reply`)}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,X.jsx)(g,{items:[{value:`preview`,label:n(`providers.testDialog.preview`)},{value:`raw`,label:n(`providers.testDialog.raw`)},{value:`headers`,label:n(`providers.testDialog.headers`)}],value:r,onChange:i,ariaLabel:n(`providers.testDialog.reply`)}),(0,X.jsx)(re,{value:u,label:n(r===`headers`?`providers.testDialog.headers`:`providers.testDialog.reply`),iconOnly:!0})]})]}),(0,X.jsx)(`div`,{className:`h-[360px] overflow-auto px-4 py-3`,children:r===`headers`?s.length===0?(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`providers.testDialog.headersEmpty`)}):(0,X.jsx)(`table`,{className:`w-full text-[11px]`,children:(0,X.jsx)(`tbody`,{children:s.map(([e,t])=>(0,X.jsxs)(`tr`,{className:`border-b border-[var(--border)] last:border-0 align-top`,children:[(0,X.jsx)(`th`,{className:`w-[220px] py-1.5 pr-4 text-left font-mono font-normal text-[var(--text-secondary)]`,children:e}),(0,X.jsx)(`td`,{className:`py-1.5 font-mono break-all whitespace-pre-wrap selectable`,children:t})]},e))})}):r===`raw`?o?(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsxs)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:[n(`providers.testDialog.rawNote`),e?.contentType?` · ${e.contentType}`:``]}),(0,X.jsx)(`pre`,{className:`font-mono text-[11px] leading-[1.6] break-all whitespace-pre-wrap selectable`,children:o}),e?.rawTruncated?(0,X.jsx)(`p`,{className:`text-[11px] text-[var(--warning)]`,children:n(`providers.testDialog.rawTruncated`)}):null]}):(0,X.jsx)(Pn,{run:e}):e?.error?(0,X.jsx)(y,{tone:`danger`,title:n(`providers.testDialog.status.failed`),children:e.error}):a||e?.reasoning?(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[e?.reasoning?(0,X.jsxs)(`div`,{className:`rounded-md border border-[var(--border)] bg-[var(--surface-strong)] p-3`,children:[(0,X.jsx)(`div`,{className:`mb-1 text-[11px] text-[var(--text-muted)]`,children:n(`providers.testDialog.reasoning`)}),(0,X.jsx)(`pre`,{className:`font-mono text-[11px] leading-[1.6] whitespace-pre-wrap selectable`,children:e.reasoning})]}):null,a?(0,X.jsx)(`pre`,{className:`font-mono text-[12px] leading-[1.7] break-words whitespace-pre-wrap selectable`,children:a}):null]}):e?.status===`success`?(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`providers.testDialog.noText`)}):(0,X.jsx)(Pn,{run:e})})]})]})}function Pn({run:e}){let{t}=E();return e?.status===`running`||e?.status===`queued`?(0,X.jsx)(`div`,{className:`grid h-full place-items-center text-[12px] text-[var(--text-muted)]`,children:t(En[e.status])}):(0,X.jsxs)(`div`,{className:`grid h-full place-items-center content-center gap-2 text-center`,children:[(0,X.jsx)(Fe,{className:`mx-auto size-6 text-[var(--text-muted)]`}),(0,X.jsx)(`div`,{className:`text-[13px]`,children:t(`providers.testDialog.emptyTitle`)}),(0,X.jsx)(`p`,{className:`mx-auto max-w-[320px] text-[11px] text-[var(--text-muted)]`,children:t(`providers.testDialog.emptyDetail`)})]})}function Fn({label:e,value:t}){return(0,X.jsxs)(`div`,{className:`bg-[var(--surface)] px-4 py-3`,children:[(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:e}),(0,X.jsx)(`div`,{className:`mt-1 font-mono text-[15px] tabular-nums`,children:t==null?`—`:_e(t)})]})}function In({run:e}){let{t}=E(),n=e?.status??`idle`;return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[12px] text-[var(--text-secondary)]`,children:[(0,X.jsx)(w,{tone:n===`success`?`green`:n===`failed`?`red`:n===`running`?`orange`:`neutral`}),t(En[n])]})}function Ln({known:e,selected:t,onToggle:n,onSelectAll:r,onClear:i,search:a,onSearch:o,onAdd:s,configOpen:c,onConfigOpen:u,...d}){let{t:f}=E(),p=a.trim(),m=p.toLowerCase(),h=m?e.filter(e=>e.toLowerCase().includes(m)):e,g=p!==``&&!e.some(e=>e.toLowerCase()===m);return(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-[12px] text-[var(--text-secondary)]`,children:f(`providers.testDialog.selected`,{n:t.size,total:e.length})}),(0,X.jsx)(`div`,{className:`min-w-[220px] flex-1`,children:(0,X.jsx)(v,{value:a,onChange:o,placeholder:f(`providers.testDialog.searchModels`)})}),(0,X.jsx)(l,{variant:`plain`,disabled:t.size===0,onClick:i,children:f(`providers.testDialog.clearSelection`)}),(0,X.jsx)(l,{icon:(0,X.jsx)(qe,{className:`size-3.5`}),onClick:()=>u(!0),children:f(`providers.testDialog.config`)})]}),(0,X.jsx)(`div`,{className:`card max-h-[420px] overflow-auto`,children:h.length===0&&!g?(0,X.jsx)(`p`,{className:`px-4 py-6 text-center text-[12px] text-[var(--text-muted)]`,children:f(`providers.testDialog.noModels`)}):(0,X.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2`,children:[(0,X.jsx)(Me,{checked:t.size===e.length&&e.length>0||t.size!==0&&`indeterminate`,onCheckedChange:e=>r(e!==!1),"aria-label":f(`providers.testDialog.clearSelection`)}),(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:f(`providers.testDialog.ownFilter`)})]}),g?(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,X.jsx)(ke,{className:`size-3.5 shrink-0 text-[var(--accent)]`}),(0,X.jsx)(`button`,{type:`button`,className:`text-left font-mono text-[12px] text-[var(--accent)]`,onClick:()=>s(p),children:f(`providers.testDialog.addModel`,{id:p})})]}):null,h.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,X.jsx)(Me,{checked:t.has(e),onCheckedChange:t=>n(e,t!==!1),"aria-label":e}),(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[12px]`,title:e,children:e})]},e))]})}),(0,X.jsx)(ae,{open:c,onOpenChange:u,width:480,title:f(`providers.testDialog.config`),description:f(`providers.testDialog.savedCredentials`),children:(0,X.jsx)(`div`,{className:`grid gap-4`,children:(0,X.jsx)(Mn,{...d})})})]})}function Rn({order:e,runs:t,onView:n}){let{t:r}=E();return(0,X.jsx)(`div`,{className:`card overflow-hidden`,children:(0,X.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-[var(--border)] text-left text-[11px] text-[var(--text-muted)]`,children:[(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.model`)}),(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.statusColumn`)}),(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.metrics.ttft`)}),(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.metrics.total`)}),(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.reply`)})]})}),(0,X.jsx)(`tbody`,{children:e.map(e=>{let i=t[e];return(0,X.jsxs)(`tr`,{className:`border-b border-[var(--border)] last:border-0`,children:[(0,X.jsx)(`td`,{className:`px-4 py-2 font-mono`,children:e}),(0,X.jsx)(`td`,{className:`px-4 py-2`,children:(0,X.jsx)(In,{run:i??null})}),(0,X.jsx)(`td`,{className:`px-4 py-2 font-mono tabular-nums`,children:i?.ttftMs==null?`—`:_e(i.ttftMs)}),(0,X.jsx)(`td`,{className:`px-4 py-2 font-mono tabular-nums`,children:i?.totalMs==null?`—`:_e(i.totalMs)}),(0,X.jsx)(`td`,{className:`px-4 py-2`,children:(0,X.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] disabled:text-[var(--text-muted)]`,disabled:!i,onClick:()=>n(e),children:r(`providers.testDialog.view`)})})]},e)})})]})})}async function zn(e,t,r,i,a){let o={modelId:t,status:`running`,text:``,reasoning:``};a(o);let s=e=>{o={...o,...e},a(o)};try{await n(e,r,e=>{let t=e.data??{};switch(e.event){case`headers`:s({httpStatus:On(t.httpStatus),httpMs:On(t.httpMs),contentType:kn(t.contentType),headers:Bn(t.headers)});break;case`delta`:{let e=kn(t.text)??``;kn(t.kind)===`reasoning`?s({reasoning:o.reasoning+e}):s({text:o.text+e});break}case`done`:{let t=e.data;s({status:t.ok?`success`:`failed`,error:t.error??null,httpStatus:t.httpStatus??null,httpMs:t.httpMs??null,ttftMs:t.ttftMs??null,totalMs:t.totalMs??null,text:t.text??``,reasoning:t.reasoning??``,raw:t.raw??``,rawTruncated:t.rawTruncated??!1,contentType:t.contentType??null,headers:Bn(t.headers)});break}}},i)}catch(e){e?.name===`AbortError`?s({status:`cancelled`,error:null}):s({status:`failed`,error:e instanceof j?e.message:String(e)})}}function Bn(e){if(typeof e!=`object`||!e)return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`string`?t[n]=r:r!=null&&(t[n]=String(r));return t}export{pn as AUTH_OPTIONS,fn as PROTOCOL_OPTIONS,mn as ProvidersPage,qe as i,ln as n,Ye as r,An as t};
@@ -1 +1 @@
1
- import{Dn as e,Dt as t,Et as n,F as r,Fa as i,G as a,H as o,Ia as s,J as c,Ji as l,Ki as u,Ln as d,Ot as f,Pa as p,Ri as m,Sn as h,Tn as g,Tt as _,Ui as v,V as y,Vn as b,X as x,Y as ee,Yi as S,a as C,dt as te,gi as w,ia as T,kt as E,na as D,nt as O,o as k,oa as A,r as ne,ra as j,st as re,ta as M,wt as ie,xr as ae,za as oe,zi as se}from"./overlays-CnzrFKmb.js";import{t as ce}from"./use-transform-C8au3Jv4.js";import{b as le,s as ue,t as de,x as fe}from"./Page-D9s9brqr.js";import{t as pe}from"./TrayPanelView-BPGmNn0R.js";import{t as me}from"./download-DoTXPUWy.js";import{t as he}from"./folder-open-DC0j6uC-.js";import{t as ge}from"./log-out-CtwqdEhG.js";import{t as _e}from"./rotate-ccw-BLaDyhPe.js";import{C as ve,_ as ye,g as N,n as be,t as P,v as xe,y as F}from"./index-br322rzz.js";import{t as Se}from"./radio-cards-Byb8E5K7.js";var Ce={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Ce.node;var we=te(Ce),I={name:`panel-top`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};I.node;var Te=te(I),Ee={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};Ee.node;var L=te(Ee),R=oe(s(),1),z={field:`_field_bhhp1_1`,head:`_head_bhhp1_6`,label:`_label_bhhp1_7`,limit:`_limit_bhhp1_9`,control:`_control_bhhp1_14`,step:`_step_bhhp1_22`,icon:`_icon_bhhp1_23`,valueWrap:`_valueWrap_bhhp1_34`,value:`_value_bhhp1_34`,affix:`_affix_bhhp1_38`,char:`_char_bhhp1_39`,number:`_number_bhhp1_42`,display:`_display_bhhp1_43`,mirror:`_mirror_bhhp1_45`,input:`_input_bhhp1_46`,column:`_column_bhhp1_52`,sizer:`_sizer_bhhp1_53`,glyph:`_glyph_bhhp1_54`,symbol:`_symbol_bhhp1_55`,messageSlot:`_messageSlot_bhhp1_57`,hint:`_hint_bhhp1_58`,words:`_words_bhhp1_60`,wordSlot:`_wordSlot_bhhp1_61`,wordSizer:`_wordSizer_bhhp1_62`,word:`_word_bhhp1_60`,srOnly:`_srOnly_bhhp1_64`},B=i(),{spring:V,duration:H,blur:U}=O,W=[...O.ease.enter],G=[...O.ease.standard],De=[0,1,2,3,4,5,6,7,8,9],Oe=6,ke=400,Ae=40,je=240,Me=1500,Ne=700,Pe=700,Fe=.22,Ie=4,Le=130,Re=(()=>{let e=2*Math.PI/(V.morph.visualDuration*1.2);return{type:`spring`,stiffness:e*e,damping:2*(1-V.morph.bounce)*e}})(),ze=e=>(String(e).split(`.`)[1]??``).length,Be=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,`\\$&`),Ve=(e,t)=>typeof e==`function`?e(t):e??``,He=(e,t=10)=>Math.sign(e)*(1-1/(Math.abs(e)*.55/t+1))*t;function Ue(e,t){let n=t.formatToParts(e),r=n.reduce((e,t)=>e+(t.type===`integer`?t.value.length:0),0),i=0;return n.flatMap((e,t)=>e.type===`integer`?[...e.value].map(e=>({key:`i${--r}`,digit:Number(e)})):e.type===`fraction`?[...e.value].map(e=>({key:`f${i++}`,digit:Number(e)})):[{key:e.type===`group`?`g${r}`:e.type===`decimal`?`d`:e.type===`minusSign`?`m`:`${e.type}${t}`,text:e.value}])}var We={enter:e=>({width:0,scale:.6,opacity:0,y:`${e*.3}em`,filter:`blur(${U.soft}px)`}),center:{width:`auto`,scale:1,opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`},transition:{width:V.morph,scale:V.morph,opacity:V.morph,y:V.snappy,filter:{duration:.3,ease:G}}},exit:e=>({width:0,scale:.6,opacity:0,y:`${e*-.3}em`,filter:`blur(${U.subtle}px)`,transition:{width:V.smooth,scale:V.smooth,y:{duration:H.fast,ease:G},opacity:{duration:H.instant},filter:{duration:H.instant}}})},K=e=>({width:`auto`,scale:1,opacity:e,y:0,filter:`none`}),q={enter:K(0),center:{...K(1),transition:{duration:H.instant}},exit:{width:0,opacity:0,transition:{duration:0}}},Ge={enter:K(1),center:{...K(1),transition:{duration:0}},exit:{width:0,opacity:0,transition:{duration:0}}};function Ke({position:e,digit:t}){let n=e=>((t-e)%10+15)%10-5,r=ce(e,e=>`${n(e)*1.05}em`),i=ce(e,e=>Math.max(0,1-Math.abs(n(e))**1.5*1.1)),a=ce(e,e=>Math.abs(n(e))>=1?`hidden`:`visible`),o=ce(e,e=>{let t=Math.abs(n(e));return t<.02||t>=1?`none`:`blur(${(t*U.soft*.75).toFixed(2)}px)`});return(0,B.jsx)(M.span,{className:z.glyph,style:{y:r,opacity:i,filter:o,visibility:a},children:t})}function qe({digit:e,direction:t,instant:n}){let r=j(),i=T(e),a=(0,R.useRef)({digit:e,target:e});return(0,R.useLayoutEffect)(()=>{let o=a.current;if(o.digit===e)return;let s=t>0?(e-o.digit+10)%10:-((o.digit-e+10)%10);Math.abs(s)>5&&(s-=Math.sign(s)*10),o.target+=s,o.digit=e,n||r?i.jump(o.target):D(i,o.target,V.snappy)},[e,t,n,i,r]),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:z.sizer,children:`0`}),De.map(e=>(0,B.jsx)(Ke,{position:i,digit:e},e))]})}function Je({value:e,format:t,direction:n,instant:r}){let i=j(),a=r?Ge:i?q:We;return(0,B.jsx)(A,{initial:!1,custom:n,children:Ue(e,t).map(e=>(0,B.jsx)(M.span,{className:`digit`in e?z.column:z.symbol,custom:n,variants:a,initial:`enter`,animate:`center`,exit:`exit`,children:`digit`in e?(0,B.jsx)(qe,{digit:e.digit,direction:n,instant:r}):e.text},e.key))})}function Ye({text:e,direction:t,className:n}){let r=j();return(0,B.jsx)(`span`,{className:n,children:(0,B.jsx)(A,{initial:!1,custom:t,children:[...e].map((e,n)=>(0,B.jsx)(M.span,{className:z.char,custom:t,variants:r?q:We,initial:`enter`,animate:`center`,exit:`exit`,children:e},`${n}:${e}`))})})}var Xe=e=>{let t=e?.replace(/[^\d.-]/g,``);return t&&/\d/.test(t)&&Number.isFinite(Number(t))?Number(t):null},J=(e,t)=>{let n=e.split(` `);return t.split(` `).map((e,t)=>{let r=Xe(n[t]),i=Xe(e);return r!==null&&i!==null&&i<r?-1:1})},Ze={enter:e=>({opacity:0,y:`${e*.3}em`,filter:`blur(${U.soft}px)`}),center:{opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`},transition:{duration:.22,ease:W,opacity:V.morph}},exit:e=>({opacity:0,y:`${e*-.3}em`,filter:`blur(${U.subtle}px)`,transition:{duration:.14,ease:G}})},Qe={enter:{opacity:0,y:0,filter:`none`},center:{opacity:1,y:0,filter:`none`,transition:{duration:H.instant}},exit:{opacity:0,transition:{duration:0}}};function Y({word:e,direction:t}){let n=j(),r=(0,R.useRef)(null),i=T(`auto`),a=(0,R.useRef)(!1);return(0,R.useLayoutEffect)(()=>{let e=r.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{!a.current||n?i.jump(e.offsetWidth):D(i,e.offsetWidth,V.morph),a.current=!0});return t.observe(e),()=>t.disconnect()},[n,i]),(0,B.jsxs)(M.span,{className:z.wordSlot,style:{width:i},children:[(0,B.jsx)(`span`,{ref:r,className:z.wordSizer,children:e}),(0,B.jsx)(A,{initial:!1,mode:`popLayout`,custom:t,children:(0,B.jsx)(M.span,{className:z.word,custom:t,variants:n?Qe:Ze,initial:`enter`,animate:`center`,exit:`exit`,children:e},e)})]})}function X({text:e}){let[t,n]=(0,R.useState)({text:e,directions:[]});t.text!==e&&n({text:e,directions:J(t.text,e)});let r=t.text===e?t.directions:J(t.text,e),i=e.split(` `);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:z.srOnly,children:e}),(0,B.jsx)(`span`,{className:z.words,"aria-hidden":`true`,children:i.map((e,t)=>(0,B.jsxs)(R.Fragment,{children:[t>0&&` `,(0,B.jsx)(Y,{word:e,direction:r[t]??1})]},t))})]})}function $e({id:e,text:t,className:n}){return(0,B.jsx)(A,{initial:!1,children:t?(0,B.jsx)(et,{id:e,text:t,className:n},`message`):null})}function et({id:e,text:t,className:n}){let r=j(),i=(0,R.useRef)(null),[a,o]=(0,R.useState)(`auto`);return(0,R.useLayoutEffect)(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(([t])=>o(t.borderBoxSize?.[0]?.blockSize??e.offsetHeight));return t.observe(e),()=>t.disconnect()},[]),(0,B.jsx)(M.span,{className:z.messageSlot,initial:{height:0,opacity:0},animate:{height:a,opacity:1},exit:{height:0,opacity:0,transition:r?{duration:0}:{height:V.smooth,opacity:{duration:H.instant}}},transition:r?{duration:0}:{height:V.smooth,opacity:{duration:H.fast}},children:(0,B.jsx)(M.span,{ref:i,id:e,className:n,initial:!r&&{y:`0.35em`,filter:`blur(${U.soft}px)`},animate:{y:0,filter:`blur(0px)`},transition:{duration:r?0:H.standard,ease:W},children:(0,B.jsx)(X,{text:t})})})}function tt({id:e,edge:t,text:n}){let r=j();return(0,B.jsx)(A,{initial:!1,children:t!==0&&(0,B.jsx)(M.span,{id:e,className:z.limit,initial:r?{opacity:0}:{opacity:0,y:`${t*.45}em`,filter:`blur(${U.subtle}px)`},animate:{opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`}},exit:{opacity:0,transition:{duration:r?H.instant:H.standard,ease:G}},transition:r?{duration:H.instant}:{y:V.snappy,opacity:{duration:H.fast},filter:{duration:H.fast}},children:n},`limit`)})}function nt({toward:e,label:t,disabled:n,controls:r,limit:i,pressed:a,iconRef:o,onPress:s,onRelease:c,onActivate:l}){let u=e>0?ue:we;return(0,B.jsx)(`button`,{type:`button`,className:z.step,disabled:n,"aria-controls":r,"aria-label":`${e>0?`Increase`:`Decrease`} ${t}`,"aria-disabled":i||void 0,"data-pressed":a||void 0,onPointerDown:e=>{e.button===0&&s()},onPointerUp:c,onPointerLeave:c,onPointerCancel:c,onMouseDown:e=>e.preventDefault(),onClick:e=>{e.detail===0&&l()},onContextMenu:e=>e.preventDefault(),children:(0,B.jsx)(`span`,{ref:o,className:z.icon,children:(0,B.jsx)(u,{size:16,strokeWidth:1.75,"aria-hidden":`true`})})})}function rt({label:e,value:t,defaultValue:n=0,onValueChange:r,min:i=0,max:a=2**53-1,step:o=1,largeStep:s,description:c,disabled:l,id:u,prefix:d,suffix:f,scrub:p=!1,locale:m=`en-US`,formatOptions:h,size:g=`md`,limitHint:_=!0}){let v=j(),y=(0,R.useId)(),b=u??y,x=c?`${b}-description`:void 0,ee=`${b}-limit`,S=o>0?o:1,[C,te]=(0,R.useState)(n),w=t??C,[E,O]=(0,R.useState)(``),[k,A]=(0,R.useState)(!1),[ne,re]=(0,R.useState)(0),[ie,ae]=(0,R.useState)(!1),[oe,se]=(0,R.useState)(``),[le,ue]=(0,R.useState)(0),[de,fe]=(0,R.useState)(!1),pe=(0,R.useRef)(null),me=(0,R.useRef)(null),he=(0,R.useRef)(null),ge=(0,R.useRef)(void 0),_e=(0,R.useRef)(void 0),ve=(0,R.useRef)(void 0),ye=(0,R.useRef)({edge:0,count:0,at:0}),N=(0,R.useRef)(null),be=(0,R.useRef)(null),P=(0,R.useRef)(w),xe=(0,R.useRef)(w),F=(0,R.useRef)(void 0),Se=(0,R.useRef)(null),Ce=(0,R.useRef)(!1),we=(0,R.useRef)(null),I=(0,R.useRef)(!1),Te=(0,R.useRef)(()=>!1),Ee=T(0),L=T(0),H=T(0),U=ce(()=>L.get()+H.get()),W=Number.isFinite(i)?i:0,G=Math.max(ze(S),ze(W)),De=h?.minimumFractionDigits??G,Ue=Math.max(De,h?.maximumFractionDigits??G),We=h?.useGrouping??!0,K=(0,R.useMemo)(()=>new Intl.NumberFormat(m,{minimumFractionDigits:De,maximumFractionDigits:Ue,useGrouping:We,numberingSystem:`latn`}),[m,De,Ue,We]),q=(0,R.useMemo)(()=>{let e=new Intl.NumberFormat(m).formatToParts(-1234.5);return{group:e.find(e=>e.type===`group`)?.value??`,`,decimal:e.find(e=>e.type===`decimal`)?.value??`.`}},[m]),Ge=e=>Number(e.toFixed(G))||0,Ke=e=>Math.min(a,Math.max(i,e)),qe=e=>Ge(W+Math.round((e-W)/S)*S),Xe=(e,t)=>{let n=(e-W)/S;return Ge(W+((t>0?Math.floor(n+1e-7):Math.ceil(n-1e-7))+t)*S)},J=e=>`${Ve(d,e)}${K.format(e)}${Ve(f,e)}`.trim();function Ze(e){let t=e.split(q.group).join(``).replace(q.decimal,`.`).replace(/[^\d.-]/g,``);if(!/\d/.test(t))return null;let n=Number(t);return Number.isFinite(n)?n:null}let Qe=k?Ze(E):null,Y=Qe??w,[X,et]=(0,R.useState)({value:Y,direction:1});X.value!==Y&&et({value:Y,direction:Y>X.value?1:-1});let rt=X.value===Y?X.direction:Y>X.value?1:-1;(0,R.useEffect)(()=>()=>{window.clearTimeout(F.current),window.clearTimeout(ge.current),window.clearTimeout(_e.current),window.clearTimeout(ve.current)},[]);function it(e,t){let n=performance.now(),r=ye.current;r.count=r.edge===e&&n-r.at<Pe?r.count+1:1,r.edge=e,r.at=n;let i=pe.current;if(i&&(i.dataset.strain=e>0?`max`:`min`,window.clearTimeout(ve.current),ve.current=window.setTimeout(()=>{delete i.dataset.strain},420)),!v){D(Ee,0,{...Re,velocity:-e*Le*(1+Math.min(r.count-1,Ie)*Fe)});let n=(e>0?he:me).current;n&&(t===`button`||t===`key`)&&D(n,{x:[0,-2.5,2.5,-1.5,1,0]},{duration:.32,ease:`easeOut`})}_&&(ue(e),window.clearTimeout(ge.current),ge.current=window.setTimeout(()=>ue(0),Me))}function Z(e,n){if(!Number.isFinite(e))return!1;let i=Ke(e),a=Math.sign(e-i);return a&&n!==`scrub`?(it(a>0?1:-1,n),se(`${J(i)}, ${a>0?`maximum`:`minimum`}`)):n===`button`&&i!==P.current&&se(J(i)),i!==P.current&&(P.current=i,t===void 0&&te(i),r?.(i),!0)}let Q=(e,t,n)=>Z(Xe(P.current,e*t),n);(0,R.useLayoutEffect)(()=>{P.current=w,Te.current=Q});function at(){let e=be.current;e&&we.current===null&&(we.current=e.getBoundingClientRect().left-L.get()-H.get())}(0,R.useLayoutEffect)(()=>{let e=we.current,t=be.current;if(we.current=null,I.current){I.current=!1;let e=N.current;if(e&&document.activeElement===e){let t=e.value.length;e.setSelectionRange(t,t)}}if(e===null||!t)return;let n=e-(t.getBoundingClientRect().left-L.get()-H.get());Math.abs(n)<.5||(H.set(H.get()+n),v?H.jump(0):D(H,0,V.morph))});function ot(){window.clearTimeout(_e.current),fe(!1)}function $(){if(!k)return;at(),A(!1),ot();let e=Ze(E);e!==null&&Z(qe(e),`type`)}function st(){window.clearTimeout(F.current),F.current=void 0,re(0)}function ct(e,t,n){st(),$();let r=Math.max(1,Math.round(t/S));n===`button`&&re(e);let i=0,a=()=>{let t=Te.current(e,r,n);F.current=window.setTimeout(a,t?Math.max(Ae,150*.86**++i):je)};F.current=window.setTimeout(a,Q(e,r,n)?ke:360)}function lt(e){let t=s??S*10,n={ArrowUp:[1,e.shiftKey?t:S],ArrowDown:[-1,e.shiftKey?t:S],PageUp:[1,t],PageDown:[-1,t]}[e.key];if(n){e.preventDefault(),e.repeat||ct(n[0],n[1],`key`);return}if(!k&&(e.key===`Home`&&Number.isFinite(i)||e.key===`End`&&a<2**53-1)){e.preventDefault(),Z(e.key===`Home`?i:a,`key`);return}e.key===`Enter`&&(e.preventDefault(),k?(I.current=!0,$()):e.currentTarget.select()),e.key===`Escape`&&k&&(e.preventDefault(),at(),A(!1),ot(),I.current=!0,Z(xe.current,`type`))}function ut(e){let t=RegExp(`[^0-9${Be(q.group)}${G||Ue?Be(q.decimal):``}${i<0?`\\-`:``}]`,`g`),n=e.replace(t,``);k||(xe.current=w),at(),O(n),A(!0);let r=Ze(n);r!==null&&r>=i&&r<=a&&qe(r)===r&&Z(r,`type`),ot(),r!==null&&r<i&&(_e.current=window.setTimeout(()=>fe(!0),Ne))}function dt(e){Ce.current=!1,p&&!l&&e.button===0&&($(),Se.current={pointer:e.pointerId,x:e.clientX,from:P.current,active:!1},e.currentTarget.setPointerCapture(e.pointerId))}function ft(e){let t=Se.current;if(!t||t.pointer!==e.pointerId)return;let n=e.clientX-t.x;if(!t.active){if(Math.abs(n)<3)return;t.active=!0,ae(!0)}let r=n/Oe,o=Math.trunc(r);Z(o?Xe(t.from,o):t.from,`scrub`);let s=t.from+r*S,c=s>a?(s-a)/S*Oe:s<i?(s-i)/S*Oe:0;L.set(v?0:He(c))}function pt(e){let t=Se.current;t&&t.pointer===e.pointerId&&(Se.current=null,t.active&&(Ce.current=!0,ae(!1),D(L,0,v?{duration:0}:V.snappy),se(J(P.current))))}let mt=t=>({toward:t,label:e,disabled:l,controls:b,limit:t>0?Y>=a:Y<=i,pressed:ne===t}),ht=Qe===null?0:Qe>a?1:Qe<i&&de?-1:0,gt=_?ht||le:0,_t=gt>0?a:i,vt=gt?typeof _==`function`?_(gt>0?`max`:`min`,_t):`${gt>0?`Max`:`Min`} ${J(_t)}`:``,yt=[x,ht&&_?ee:void 0].filter(Boolean).join(` `)||void 0;return(0,B.jsxs)(`div`,{className:z.field,"data-size":g,children:[(0,B.jsxs)(`div`,{className:z.head,children:[(0,B.jsx)(`label`,{htmlFor:b,className:z.label,"data-scrub":p&&!l||void 0,onPointerDown:dt,onPointerMove:ft,onPointerUp:pt,onPointerCancel:pt,onClick:e=>{Ce.current&&=(e.preventDefault(),!1)},children:e}),(0,B.jsx)(tt,{id:ee,edge:gt,text:vt})]}),(0,B.jsxs)(`div`,{ref:pe,className:z.control,"data-scrubbing":ie||void 0,"data-disabled":l||void 0,"data-warn":ht?ht>0?`max`:`min`:void 0,children:[(0,B.jsx)(nt,{...mt(-1),iconRef:me,onPress:()=>ct(-1,S,`button`),onRelease:st,onActivate:()=>{$(),Q(-1,1,`button`)}}),(0,B.jsx)(`div`,{className:z.valueWrap,onMouseDown:e=>{e.target!==N.current&&e.preventDefault()},onClick:e=>{!l&&e.target!==N.current&&(N.current?.focus(),N.current?.select())},children:(0,B.jsxs)(M.span,{ref:be,className:z.value,style:{x:U,y:Ee},children:[(0,B.jsx)(Ye,{text:Ve(d,Y),direction:rt,className:z.affix}),(0,B.jsxs)(`span`,{className:z.number,children:[(0,B.jsx)(`span`,{className:z.display,"data-hidden":k||void 0,"aria-hidden":`true`,children:(0,B.jsx)(Je,{value:Y,format:K,direction:rt,instant:k})}),k&&(0,B.jsx)(`span`,{className:z.mirror,"aria-hidden":`true`,children:E}),(0,B.jsx)(`input`,{ref:N,id:b,className:z.input,type:`text`,role:`spinbutton`,inputMode:i<0?`text`:G||Ue?`decimal`:`numeric`,autoComplete:`off`,spellCheck:!1,value:k?E:K.format(w),disabled:l,"aria-describedby":yt,"aria-invalid":ht?!0:void 0,"aria-valuenow":w,"aria-valuetext":J(w),"aria-valuemin":Number.isFinite(i)?i:void 0,"aria-valuemax":a<2**53-1?a:void 0,onChange:e=>ut(e.currentTarget.value),onKeyDown:lt,onKeyUp:e=>{/^(Arrow(Up|Down)|Page(Up|Down))$/.test(e.key)&&st()},onBlur:()=>{st(),$()}})]}),(0,B.jsx)(Ye,{text:Ve(f,Y),direction:rt,className:z.affix})]})}),(0,B.jsx)(nt,{...mt(1),iconRef:he,onPress:()=>ct(1,S,`button`),onRelease:st,onActivate:()=>{$(),Q(1,1,`button`)}})]}),(0,B.jsx)($e,{id:x,text:c,className:z.hint}),(0,B.jsx)(`span`,{className:z.srOnly,"aria-live":`polite`,"aria-atomic":`true`,children:oe})]})}var it=[`overview`,`cost`,`chart`,`topModel`,`compareYesterday`,`cacheHitRate`,`quota`];function Z(){let{t:e}=g(),n=p(),[i,o]=t(),s=f(),c=ie(i,{enabled:s.running,background:!1,live:!0}),l=t=>(0,B.jsx)(a,{label:e(`settings.tray.section.${t}`),detail:e(`settings.tray.section.${t}.hint`),children:(0,B.jsx)(x,{checked:i.sections[t],label:e(`settings.tray.section.${t}`),onChange:e=>o(E(i,t,e))})},t);return(0,B.jsxs)(`div`,{className:`mx-auto grid max-w-[1120px] items-start gap-4 lg:grid-cols-[minmax(0,1fr)_392px]`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,B.jsx)(Q,{title:e(`settings.tray.titleHeading`),hint:e(`settings.tray.titleHint`),children:(0,B.jsx)(`div`,{className:`p-4`,children:(0,B.jsx)(Se,{"aria-label":e(`settings.tray.titleHeading`),minColumnWidth:150,value:i.title,onValueChange:e=>o({...i,title:e}),options:u.map(t=>({value:t,label:e(`settings.tray.title.${t}`),description:e(`settings.tray.title.${t}.hint`)}))})})}),(0,B.jsx)(Q,{title:e(`settings.tray.usageHeading`),children:(0,B.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:it.map(l)})}),(0,B.jsx)(Q,{title:e(`settings.tray.clientsHeading`),children:(0,B.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:l(`clients`)})}),(0,B.jsx)(`div`,{children:(0,B.jsx)(r,{size:`sm`,variant:`plain`,icon:(0,B.jsx)(_e,{className:`size-3.5`}),onClick:()=>o(_),children:e(`settings.tray.reset`)})})]}),(0,B.jsx)(`div`,{className:`lg:sticky lg:top-0`,children:(0,B.jsxs)(Q,{title:e(`settings.tray.previewHeading`),hint:e(`settings.tray.previewHint`),children:[(0,B.jsx)(`div`,{className:`flex justify-center bg-[var(--surface-muted)] px-4 py-5`,children:(0,B.jsx)(pe,{preview:!0,className:`w-[360px] max-w-full shadow-[0_12px_40px_rgb(0_0_0/0.25)]`,prefs:i,state:s,data:c,onRefresh:()=>void n.invalidateQueries({queryKey:[`stats`]})})}),(0,B.jsx)(`p`,{className:`border-t border-[var(--border)] px-4 py-2.5 text-[11px] text-[var(--text-muted)]`,children:e(`settings.tray.previewFooter`)})]})})]})}function Q({title:e,hint:t,children:n}){let{t:r}=g();return(0,B.jsxs)(`section`,{className:`card`,children:[(0,B.jsxs)(`header`,{className:`border-b border-[var(--border)] px-4 py-3`,children:[(0,B.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`settings.tab.tray`)}),(0,B.jsx)(`h3`,{className:`text-[14px] font-semibold`,children:e}),t&&(0,B.jsx)(`p`,{className:`mt-0.5 text-[12px] text-[var(--text-secondary)]`,children:t})]}),n]})}var at=[`general`,`tray`];function ot(){let{t:e}=g(),{tab:t}=fe(),r=le(),i=n(),a=i&&at.includes(t)?t:`general`;return i?(0,B.jsx)(de,{title:e(`nav.settings`),children:(0,B.jsxs)(N,{value:a,onValueChange:e=>r(e===`general`?`/settings`:`/settings/${e}`,{replace:!0}),children:[(0,B.jsxs)(xe,{"aria-label":e(`nav.settings`),children:[(0,B.jsx)(F,{value:`general`,children:(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(L,{className:`size-3.5`}),e(`settings.tab.general`)]})}),(0,B.jsx)(F,{value:`tray`,children:(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Te,{className:`size-3.5`}),e(`settings.tab.tray`)]})})]}),(0,B.jsx)(ye,{value:`general`,className:`pt-5`,children:(0,B.jsx)($,{})}),(0,B.jsx)(ye,{value:`tray`,className:`pt-5`,children:(0,B.jsx)(Z,{})})]})}):(0,B.jsx)(de,{title:e(`nav.settings`),children:(0,B.jsx)($,{})})}function $(){let{t,locale:n,setLocale:i}=g(),o=be(),s=w(),u=m(),f=p(),_=v(),b=d(),te=ae(),{toast:T,confirm:E}=k(),D=s.data,O=e=>u.mutate(e,{onError:e=>T(C(e),`error`)}),A=e=>{i(e),O({locale:e})},j=async e=>{await h.copy(e)&&T(t(`common.copied`))};return(0,B.jsxs)(`div`,{className:`mx-auto max-w-[680px]`,children:[(0,B.jsxs)(y,{title:t(`settings.appearance`),children:[(0,B.jsx)(a,{label:t(`settings.theme`),children:(0,B.jsx)(c,{ariaLabel:t(`settings.theme`),value:o.theme,onChange:o.setTheme,items:[{value:`system`,label:t(`settings.theme.system`)},{value:`light`,label:t(`settings.theme.light`)},{value:`dark`,label:t(`settings.theme.dark`)}]})}),(0,B.jsx)(a,{label:t(`settings.accent`),detail:o.accentChoice===`system`?o.systemAccent?t(`settings.accent.followingSystem`):t(`settings.accent.systemUnavailable`):void 0,children:(0,B.jsx)(ne,{className:`w-40`,ariaLabel:t(`settings.accent`),value:o.accentChoice,onChange:o.setAccentChoice,options:[{value:`system`,label:t(`settings.accent.system`)},...P.map(e=>({value:e.color,label:t(`settings.accent.${e.id}`)}))]})}),(0,B.jsx)(a,{label:t(`settings.language`),detail:t(`settings.languageHint`),children:(0,B.jsx)(c,{ariaLabel:t(`settings.language`),value:n,onChange:A,items:[{value:`zh`,label:`中文`},{value:`en`,label:`English`}]})})]}),D?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(y,{title:t(`settings.gateway`),footer:t(`settings.gatewayFooter`),children:[(0,B.jsx)(a,{label:t(`settings.gatewayUrl`),detail:`${D.gatewayBaseUrl}/v1`,children:(0,B.jsx)(r,{size:`sm`,variant:`plain`,icon:(0,B.jsx)(re,{className:`size-3.5`}),"aria-label":t(`common.copy`),onClick:()=>void j(`${D.gatewayBaseUrl}/v1`)})}),(0,B.jsx)(a,{label:t(`settings.listen`),detail:`${D.host}:${D.port}`}),(0,B.jsx)(a,{label:t(`settings.dataDir`),detail:D.dataDir,children:h.canOpenPaths?(0,B.jsx)(r,{size:`sm`,variant:`plain`,icon:(0,B.jsx)(he,{className:`size-3.5`}),"aria-label":t(`settings.openFolder`),onClick:()=>void h.openPath(D.dataDir)}):(0,B.jsx)(r,{size:`sm`,variant:`plain`,icon:(0,B.jsx)(re,{className:`size-3.5`}),"aria-label":t(`common.copy`),onClick:()=>void j(D.dataDir)})}),(0,B.jsx)(a,{label:t(`settings.requireKey`),detail:t(`settings.requireKeyHint`),children:(0,B.jsx)(x,{checked:D.requireGatewayKey,label:t(`settings.requireKey`),onChange:async e=>{(e||await E({title:t(`settings.requireKeyOffConfirm`),detail:t(`settings.requireKeyOffDetail`),confirmLabel:t(`settings.requireKeyOff`),destructive:!0}))&&O({requireGatewayKey:e})}})}),(0,B.jsx)(a,{label:t(`settings.streamIdle`),detail:t(`settings.streamIdleHint`),children:(0,B.jsx)(lt,{label:t(`settings.streamIdle`),value:D.streamIdleTimeoutSec,onCommit:e=>O({streamIdleTimeoutSec:e??300}),suffix:` s`})})]}),(0,B.jsx)(ct,{settings:D}),(0,B.jsx)(y,{title:t(`settings.quota`),footer:t(`settings.quota.autoIntervalHint`),children:(0,B.jsx)(a,{label:t(`settings.quota.autoInterval`),children:(0,B.jsx)(lt,{label:t(`settings.quota.autoInterval`),value:D.quotaAutoIntervalMinutes,onCommit:t=>u.mutate({quotaAutoIntervalMinutes:t??30},{onSuccess:()=>void f.invalidateQueries({queryKey:e.providers}),onError:e=>T(C(e),`error`)}),suffix:` ${t(`settings.minutes`)}`})})}),(0,B.jsxs)(y,{title:t(`settings.logging`),footer:t(`settings.debugBodiesHint`),children:[(0,B.jsx)(a,{label:t(`settings.debugBodies`),children:(0,B.jsx)(x,{checked:D.debugBodies,label:t(`settings.debugBodies`),onChange:e=>O({debugBodies:e})})}),(0,B.jsx)(a,{label:t(`settings.bodyRetention`),children:(0,B.jsx)(lt,{label:t(`settings.bodyRetention`),value:D.bodyRetentionDays,onCommit:e=>O({bodyRetentionDays:e??7}),suffix:` ${t(`settings.days`)}`})}),(0,B.jsxs)(a,{label:t(`settings.requestRetention`),detail:D.requestRetentionDays==null?t(`settings.keepForever`):void 0,children:[(0,B.jsx)(x,{checked:D.requestRetentionDays!=null,label:t(`settings.requestRetention`),onChange:e=>O({requestRetentionDays:e?90:null})}),D.requestRetentionDays!=null&&(0,B.jsx)(lt,{label:t(`settings.requestRetention`),value:D.requestRetentionDays,onCommit:e=>O({requestRetentionDays:e??90}),suffix:` ${t(`settings.days`)}`})]})]}),(0,B.jsx)(y,{title:t(`settings.effort`),footer:t(`settings.effortHint`),children:[`low`,`medium`,`high`].map(e=>(0,B.jsx)(a,{label:t(`settings.effort.${e}`),children:(0,B.jsx)(lt,{label:t(`settings.effort.${e}`),value:D.effortBudgets[e],onCommit:t=>O({effortBudgets:{...D.effortBudgets,[e]:t??D.effortBudgets[e]}}),suffix:` tokens`,step:1024})},e))})]}):s.isError?(0,B.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:C(s.error)}):(0,B.jsx)(ee,{className:`mx-auto my-8`}),(0,B.jsxs)(y,{title:t(`settings.about`),children:[(0,B.jsx)(a,{label:t(`settings.serverVersion`),detail:_.data?`${_.data.version} · API ${_.data.apiVersion}`:`—`}),S&&(0,B.jsx)(a,{label:t(`settings.desktopVersion`),detail:l()?.version||`—`}),(0,B.jsx)(st,{}),S&&(0,B.jsx)(a,{label:t(`settings.logs`),onClick:()=>void h.revealLogs(),children:(0,B.jsx)(he,{className:`size-4 text-[var(--text-secondary)]`})}),b.data?.required&&(0,B.jsx)(a,{label:t(`settings.logout`),onClick:()=>te.mutate(),children:(0,B.jsx)(ge,{className:`size-4 text-[var(--text-secondary)]`})})]})]})}function st(){let{t}=g(),{toast:n}=k(),i=p(),o=m(),s=se(),c=b(),u=s.data,d=l()?.updates??null,[f,h]=(0,R.useState)(!1),_=()=>c.mutate(void 0,{onSuccess:e=>n(e.available?t(`settings.updateAvailable`,{version:e.available}):t(`settings.upToDate`)),onError:e=>n(C(e),`error`)}),v=()=>{d&&!f&&(h(!0),d.apply().then(r=>{r===`server`?(n(t(`settings.updateApplied`)),i.invalidateQueries({queryKey:e.version}),i.invalidateQueries({queryKey:e.update})):n(t(r===`desktop`?`settings.updateDesktopRelaunch`:`settings.upToDate`))}).catch(e=>n(C(e),`error`)).finally(()=>h(!1)))},y=u?.lastCheckAt?new Date(u.lastCheckAt).toLocaleString():void 0,S=u?.available?d?t(`settings.updateAvailable`,{version:u.available}):`${t(`settings.updateAvailable`,{version:u.available})} ${t(`settings.updateApplyHint`)}`:void 0;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(a,{label:t(`settings.autoCheck`),detail:u&&!u.feedConfigured?t(`settings.updateCheckFailed`,{error:`feed-not-configured`}):void 0,children:(0,B.jsx)(x,{checked:u?.autoCheck??!0,label:t(`settings.autoCheck`),onChange:e=>o.mutate({updateAutoCheck:e},{onError:e=>n(C(e),`error`)})})}),(0,B.jsxs)(a,{label:t(`settings.checkUpdates`),detail:c.isError?t(`settings.updateCheckFailed`,{error:C(c.error)}):u?.available?S:y?t(`settings.lastChecked`,{time:y}):void 0,children:[(0,B.jsx)(r,{size:`sm`,variant:`plain`,disabled:c.isPending,onClick:_,children:c.isPending?(0,B.jsx)(ee,{className:`size-3.5`}):(0,B.jsx)(ve,{className:`size-3.5`})}),d&&u?.available&&(0,B.jsx)(r,{size:`sm`,variant:`plain`,disabled:f,"aria-label":t(`settings.updateApply`),onClick:v,children:f?(0,B.jsx)(ee,{className:`size-3.5`}):(0,B.jsx)(me,{className:`size-3.5`})})]})]})}function ct({settings:e}){let{t}=g(),{toast:n}=k(),i=m(),[s,l]=(0,R.useState)(e.proxyMode),[u,d]=(0,R.useState)({url:e.proxyUrl??``,username:e.proxyUsername??``,password:``,bypass:e.proxyBypass??``});(0,R.useEffect)(()=>l(e.proxyMode),[e.proxyMode]),(0,R.useEffect)(()=>d({url:e.proxyUrl??``,username:e.proxyUsername??``,password:``,bypass:e.proxyBypass??``}),[e.proxyUrl,e.proxyUsername,e.proxyBypass,e.hasProxyPassword]);let f=t=>{l(t),(t!==`custom`||e.proxyUrl)&&i.mutate({proxyMode:t},{onError:e=>n(C(e),`error`)})},p=()=>i.mutate({proxyMode:`custom`,proxyUrl:u.url.trim()||null,proxyUsername:u.username.trim()||null,proxyBypass:u.bypass.trim()||null,...u.password?{proxyPassword:u.password}:{}},{onSuccess:()=>n(t(`settings.proxy.saved`)),onError:e=>n(C(e),`error`)}),h=s!==e.proxyMode||u.url!==(e.proxyUrl??``)||u.username!==(e.proxyUsername??``)||u.password!==``||u.bypass!==(e.proxyBypass??``);return(0,B.jsxs)(y,{title:t(`settings.proxy`),footer:t(`settings.proxy.footer`),children:[(0,B.jsx)(a,{label:t(`settings.proxy.mode`),detail:t(`settings.proxy.mode.${s}.hint`),children:(0,B.jsx)(c,{ariaLabel:t(`settings.proxy.mode`),value:s,onChange:f,items:[{value:`system`,label:t(`settings.proxy.mode.system`)},{value:`custom`,label:t(`settings.proxy.mode.custom`)},{value:`direct`,label:t(`settings.proxy.mode.direct`)}]})}),s===`custom`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(a,{label:t(`settings.proxy.url`),detail:t(`settings.proxy.urlHint`),children:(0,B.jsx)(o,{className:`w-64`,mono:!0,"aria-label":t(`settings.proxy.url`),placeholder:`http://127.0.0.1:7890`,value:u.url,onChange:e=>d({...u,url:e.target.value})})}),(0,B.jsx)(a,{label:t(`settings.proxy.username`),detail:t(`settings.proxy.optional`),children:(0,B.jsx)(o,{className:`w-64`,autoComplete:`off`,"aria-label":t(`settings.proxy.username`),value:u.username,onChange:e=>d({...u,username:e.target.value})})}),(0,B.jsx)(a,{label:t(`settings.proxy.password`),detail:e.hasProxyPassword?t(`settings.proxy.passwordSaved`):t(`settings.proxy.optional`),children:(0,B.jsx)(o,{className:`w-64`,type:`password`,autoComplete:`new-password`,"aria-label":t(`settings.proxy.password`),placeholder:e.hasProxyPassword?`••••••••`:void 0,value:u.password,onChange:e=>d({...u,password:e.target.value})})}),(0,B.jsx)(a,{label:t(`settings.proxy.bypass`),detail:t(`settings.proxy.bypassHint`),children:(0,B.jsx)(o,{className:`w-64`,mono:!0,"aria-label":t(`settings.proxy.bypass`),placeholder:`example.com, *.lan`,value:u.bypass,onChange:e=>d({...u,bypass:e.target.value})})}),(0,B.jsx)(`div`,{className:`flex justify-end px-4 py-2`,children:(0,B.jsx)(r,{size:`sm`,disabled:!h||!u.url.trim()||i.isPending,onClick:p,children:t(`common.save`)})})]})]})}function lt({label:e,value:t,onCommit:n,suffix:r,step:i=1}){let[a,o]=(0,R.useState)(t);(0,R.useEffect)(()=>o(t),[t]);let s=(0,R.useRef)(n);return(0,R.useEffect)(()=>{s.current=n}),(0,R.useEffect)(()=>{if(a===t)return;let e=setTimeout(()=>s.current(a),600);return()=>clearTimeout(e)},[a,t]),(0,B.jsx)(`div`,{className:`astra-label-hidden w-36`,children:(0,B.jsx)(rt,{label:e,size:`sm`,value:a,onValueChange:o,min:0,step:i,suffix:r})})}export{ot as SettingsPage};
1
+ import{Dn as e,Dt as t,Et as n,F as r,Fa as i,G as a,H as o,Ia as s,J as c,Ji as l,Ki as u,Ln as d,Ot as f,Pa as p,Ri as m,Sn as h,Tn as g,Tt as _,Ui as v,V as y,Vn as b,X as x,Y as ee,Yi as S,a as C,dt as te,gi as w,ia as T,kt as E,na as D,nt as O,o as k,oa as A,r as ne,ra as j,st as re,ta as M,wt as ie,xr as ae,za as oe,zi as se}from"./overlays-D1ZtG8Qn.js";import{t as ce}from"./use-transform-DvOb1h9g.js";import{b as le,s as ue,t as de,x as fe}from"./Page-CnSErb_N.js";import{t as pe}from"./TrayPanelView-BcmaqvCD.js";import{t as me}from"./download-CMr38kbd.js";import{t as he}from"./folder-open-Ce_7X0wN.js";import{t as ge}from"./log-out-CXVs8bJY.js";import{t as _e}from"./rotate-ccw-Dr0Xbikv.js";import{C as ve,_ as ye,g as N,n as be,t as P,v as xe,y as F}from"./index-PfVyiY3J.js";import{t as Se}from"./radio-cards-QHFaDooy.js";var Ce={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Ce.node;var we=te(Ce),I={name:`panel-top`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};I.node;var Te=te(I),Ee={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};Ee.node;var L=te(Ee),R=oe(s(),1),z={field:`_field_bhhp1_1`,head:`_head_bhhp1_6`,label:`_label_bhhp1_7`,limit:`_limit_bhhp1_9`,control:`_control_bhhp1_14`,step:`_step_bhhp1_22`,icon:`_icon_bhhp1_23`,valueWrap:`_valueWrap_bhhp1_34`,value:`_value_bhhp1_34`,affix:`_affix_bhhp1_38`,char:`_char_bhhp1_39`,number:`_number_bhhp1_42`,display:`_display_bhhp1_43`,mirror:`_mirror_bhhp1_45`,input:`_input_bhhp1_46`,column:`_column_bhhp1_52`,sizer:`_sizer_bhhp1_53`,glyph:`_glyph_bhhp1_54`,symbol:`_symbol_bhhp1_55`,messageSlot:`_messageSlot_bhhp1_57`,hint:`_hint_bhhp1_58`,words:`_words_bhhp1_60`,wordSlot:`_wordSlot_bhhp1_61`,wordSizer:`_wordSizer_bhhp1_62`,word:`_word_bhhp1_60`,srOnly:`_srOnly_bhhp1_64`},B=i(),{spring:V,duration:H,blur:U}=O,W=[...O.ease.enter],G=[...O.ease.standard],De=[0,1,2,3,4,5,6,7,8,9],Oe=6,ke=400,Ae=40,je=240,Me=1500,Ne=700,Pe=700,Fe=.22,Ie=4,Le=130,Re=(()=>{let e=2*Math.PI/(V.morph.visualDuration*1.2);return{type:`spring`,stiffness:e*e,damping:2*(1-V.morph.bounce)*e}})(),ze=e=>(String(e).split(`.`)[1]??``).length,Be=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,`\\$&`),Ve=(e,t)=>typeof e==`function`?e(t):e??``,He=(e,t=10)=>Math.sign(e)*(1-1/(Math.abs(e)*.55/t+1))*t;function Ue(e,t){let n=t.formatToParts(e),r=n.reduce((e,t)=>e+(t.type===`integer`?t.value.length:0),0),i=0;return n.flatMap((e,t)=>e.type===`integer`?[...e.value].map(e=>({key:`i${--r}`,digit:Number(e)})):e.type===`fraction`?[...e.value].map(e=>({key:`f${i++}`,digit:Number(e)})):[{key:e.type===`group`?`g${r}`:e.type===`decimal`?`d`:e.type===`minusSign`?`m`:`${e.type}${t}`,text:e.value}])}var We={enter:e=>({width:0,scale:.6,opacity:0,y:`${e*.3}em`,filter:`blur(${U.soft}px)`}),center:{width:`auto`,scale:1,opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`},transition:{width:V.morph,scale:V.morph,opacity:V.morph,y:V.snappy,filter:{duration:.3,ease:G}}},exit:e=>({width:0,scale:.6,opacity:0,y:`${e*-.3}em`,filter:`blur(${U.subtle}px)`,transition:{width:V.smooth,scale:V.smooth,y:{duration:H.fast,ease:G},opacity:{duration:H.instant},filter:{duration:H.instant}}})},K=e=>({width:`auto`,scale:1,opacity:e,y:0,filter:`none`}),q={enter:K(0),center:{...K(1),transition:{duration:H.instant}},exit:{width:0,opacity:0,transition:{duration:0}}},Ge={enter:K(1),center:{...K(1),transition:{duration:0}},exit:{width:0,opacity:0,transition:{duration:0}}};function Ke({position:e,digit:t}){let n=e=>((t-e)%10+15)%10-5,r=ce(e,e=>`${n(e)*1.05}em`),i=ce(e,e=>Math.max(0,1-Math.abs(n(e))**1.5*1.1)),a=ce(e,e=>Math.abs(n(e))>=1?`hidden`:`visible`),o=ce(e,e=>{let t=Math.abs(n(e));return t<.02||t>=1?`none`:`blur(${(t*U.soft*.75).toFixed(2)}px)`});return(0,B.jsx)(M.span,{className:z.glyph,style:{y:r,opacity:i,filter:o,visibility:a},children:t})}function qe({digit:e,direction:t,instant:n}){let r=j(),i=T(e),a=(0,R.useRef)({digit:e,target:e});return(0,R.useLayoutEffect)(()=>{let o=a.current;if(o.digit===e)return;let s=t>0?(e-o.digit+10)%10:-((o.digit-e+10)%10);Math.abs(s)>5&&(s-=Math.sign(s)*10),o.target+=s,o.digit=e,n||r?i.jump(o.target):D(i,o.target,V.snappy)},[e,t,n,i,r]),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:z.sizer,children:`0`}),De.map(e=>(0,B.jsx)(Ke,{position:i,digit:e},e))]})}function Je({value:e,format:t,direction:n,instant:r}){let i=j(),a=r?Ge:i?q:We;return(0,B.jsx)(A,{initial:!1,custom:n,children:Ue(e,t).map(e=>(0,B.jsx)(M.span,{className:`digit`in e?z.column:z.symbol,custom:n,variants:a,initial:`enter`,animate:`center`,exit:`exit`,children:`digit`in e?(0,B.jsx)(qe,{digit:e.digit,direction:n,instant:r}):e.text},e.key))})}function Ye({text:e,direction:t,className:n}){let r=j();return(0,B.jsx)(`span`,{className:n,children:(0,B.jsx)(A,{initial:!1,custom:t,children:[...e].map((e,n)=>(0,B.jsx)(M.span,{className:z.char,custom:t,variants:r?q:We,initial:`enter`,animate:`center`,exit:`exit`,children:e},`${n}:${e}`))})})}var Xe=e=>{let t=e?.replace(/[^\d.-]/g,``);return t&&/\d/.test(t)&&Number.isFinite(Number(t))?Number(t):null},J=(e,t)=>{let n=e.split(` `);return t.split(` `).map((e,t)=>{let r=Xe(n[t]),i=Xe(e);return r!==null&&i!==null&&i<r?-1:1})},Ze={enter:e=>({opacity:0,y:`${e*.3}em`,filter:`blur(${U.soft}px)`}),center:{opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`},transition:{duration:.22,ease:W,opacity:V.morph}},exit:e=>({opacity:0,y:`${e*-.3}em`,filter:`blur(${U.subtle}px)`,transition:{duration:.14,ease:G}})},Qe={enter:{opacity:0,y:0,filter:`none`},center:{opacity:1,y:0,filter:`none`,transition:{duration:H.instant}},exit:{opacity:0,transition:{duration:0}}};function Y({word:e,direction:t}){let n=j(),r=(0,R.useRef)(null),i=T(`auto`),a=(0,R.useRef)(!1);return(0,R.useLayoutEffect)(()=>{let e=r.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{!a.current||n?i.jump(e.offsetWidth):D(i,e.offsetWidth,V.morph),a.current=!0});return t.observe(e),()=>t.disconnect()},[n,i]),(0,B.jsxs)(M.span,{className:z.wordSlot,style:{width:i},children:[(0,B.jsx)(`span`,{ref:r,className:z.wordSizer,children:e}),(0,B.jsx)(A,{initial:!1,mode:`popLayout`,custom:t,children:(0,B.jsx)(M.span,{className:z.word,custom:t,variants:n?Qe:Ze,initial:`enter`,animate:`center`,exit:`exit`,children:e},e)})]})}function X({text:e}){let[t,n]=(0,R.useState)({text:e,directions:[]});t.text!==e&&n({text:e,directions:J(t.text,e)});let r=t.text===e?t.directions:J(t.text,e),i=e.split(` `);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:z.srOnly,children:e}),(0,B.jsx)(`span`,{className:z.words,"aria-hidden":`true`,children:i.map((e,t)=>(0,B.jsxs)(R.Fragment,{children:[t>0&&` `,(0,B.jsx)(Y,{word:e,direction:r[t]??1})]},t))})]})}function $e({id:e,text:t,className:n}){return(0,B.jsx)(A,{initial:!1,children:t?(0,B.jsx)(et,{id:e,text:t,className:n},`message`):null})}function et({id:e,text:t,className:n}){let r=j(),i=(0,R.useRef)(null),[a,o]=(0,R.useState)(`auto`);return(0,R.useLayoutEffect)(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(([t])=>o(t.borderBoxSize?.[0]?.blockSize??e.offsetHeight));return t.observe(e),()=>t.disconnect()},[]),(0,B.jsx)(M.span,{className:z.messageSlot,initial:{height:0,opacity:0},animate:{height:a,opacity:1},exit:{height:0,opacity:0,transition:r?{duration:0}:{height:V.smooth,opacity:{duration:H.instant}}},transition:r?{duration:0}:{height:V.smooth,opacity:{duration:H.fast}},children:(0,B.jsx)(M.span,{ref:i,id:e,className:n,initial:!r&&{y:`0.35em`,filter:`blur(${U.soft}px)`},animate:{y:0,filter:`blur(0px)`},transition:{duration:r?0:H.standard,ease:W},children:(0,B.jsx)(X,{text:t})})})}function tt({id:e,edge:t,text:n}){let r=j();return(0,B.jsx)(A,{initial:!1,children:t!==0&&(0,B.jsx)(M.span,{id:e,className:z.limit,initial:r?{opacity:0}:{opacity:0,y:`${t*.45}em`,filter:`blur(${U.subtle}px)`},animate:{opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`}},exit:{opacity:0,transition:{duration:r?H.instant:H.standard,ease:G}},transition:r?{duration:H.instant}:{y:V.snappy,opacity:{duration:H.fast},filter:{duration:H.fast}},children:n},`limit`)})}function nt({toward:e,label:t,disabled:n,controls:r,limit:i,pressed:a,iconRef:o,onPress:s,onRelease:c,onActivate:l}){let u=e>0?ue:we;return(0,B.jsx)(`button`,{type:`button`,className:z.step,disabled:n,"aria-controls":r,"aria-label":`${e>0?`Increase`:`Decrease`} ${t}`,"aria-disabled":i||void 0,"data-pressed":a||void 0,onPointerDown:e=>{e.button===0&&s()},onPointerUp:c,onPointerLeave:c,onPointerCancel:c,onMouseDown:e=>e.preventDefault(),onClick:e=>{e.detail===0&&l()},onContextMenu:e=>e.preventDefault(),children:(0,B.jsx)(`span`,{ref:o,className:z.icon,children:(0,B.jsx)(u,{size:16,strokeWidth:1.75,"aria-hidden":`true`})})})}function rt({label:e,value:t,defaultValue:n=0,onValueChange:r,min:i=0,max:a=2**53-1,step:o=1,largeStep:s,description:c,disabled:l,id:u,prefix:d,suffix:f,scrub:p=!1,locale:m=`en-US`,formatOptions:h,size:g=`md`,limitHint:_=!0}){let v=j(),y=(0,R.useId)(),b=u??y,x=c?`${b}-description`:void 0,ee=`${b}-limit`,S=o>0?o:1,[C,te]=(0,R.useState)(n),w=t??C,[E,O]=(0,R.useState)(``),[k,A]=(0,R.useState)(!1),[ne,re]=(0,R.useState)(0),[ie,ae]=(0,R.useState)(!1),[oe,se]=(0,R.useState)(``),[le,ue]=(0,R.useState)(0),[de,fe]=(0,R.useState)(!1),pe=(0,R.useRef)(null),me=(0,R.useRef)(null),he=(0,R.useRef)(null),ge=(0,R.useRef)(void 0),_e=(0,R.useRef)(void 0),ve=(0,R.useRef)(void 0),ye=(0,R.useRef)({edge:0,count:0,at:0}),N=(0,R.useRef)(null),be=(0,R.useRef)(null),P=(0,R.useRef)(w),xe=(0,R.useRef)(w),F=(0,R.useRef)(void 0),Se=(0,R.useRef)(null),Ce=(0,R.useRef)(!1),we=(0,R.useRef)(null),I=(0,R.useRef)(!1),Te=(0,R.useRef)(()=>!1),Ee=T(0),L=T(0),H=T(0),U=ce(()=>L.get()+H.get()),W=Number.isFinite(i)?i:0,G=Math.max(ze(S),ze(W)),De=h?.minimumFractionDigits??G,Ue=Math.max(De,h?.maximumFractionDigits??G),We=h?.useGrouping??!0,K=(0,R.useMemo)(()=>new Intl.NumberFormat(m,{minimumFractionDigits:De,maximumFractionDigits:Ue,useGrouping:We,numberingSystem:`latn`}),[m,De,Ue,We]),q=(0,R.useMemo)(()=>{let e=new Intl.NumberFormat(m).formatToParts(-1234.5);return{group:e.find(e=>e.type===`group`)?.value??`,`,decimal:e.find(e=>e.type===`decimal`)?.value??`.`}},[m]),Ge=e=>Number(e.toFixed(G))||0,Ke=e=>Math.min(a,Math.max(i,e)),qe=e=>Ge(W+Math.round((e-W)/S)*S),Xe=(e,t)=>{let n=(e-W)/S;return Ge(W+((t>0?Math.floor(n+1e-7):Math.ceil(n-1e-7))+t)*S)},J=e=>`${Ve(d,e)}${K.format(e)}${Ve(f,e)}`.trim();function Ze(e){let t=e.split(q.group).join(``).replace(q.decimal,`.`).replace(/[^\d.-]/g,``);if(!/\d/.test(t))return null;let n=Number(t);return Number.isFinite(n)?n:null}let Qe=k?Ze(E):null,Y=Qe??w,[X,et]=(0,R.useState)({value:Y,direction:1});X.value!==Y&&et({value:Y,direction:Y>X.value?1:-1});let rt=X.value===Y?X.direction:Y>X.value?1:-1;(0,R.useEffect)(()=>()=>{window.clearTimeout(F.current),window.clearTimeout(ge.current),window.clearTimeout(_e.current),window.clearTimeout(ve.current)},[]);function it(e,t){let n=performance.now(),r=ye.current;r.count=r.edge===e&&n-r.at<Pe?r.count+1:1,r.edge=e,r.at=n;let i=pe.current;if(i&&(i.dataset.strain=e>0?`max`:`min`,window.clearTimeout(ve.current),ve.current=window.setTimeout(()=>{delete i.dataset.strain},420)),!v){D(Ee,0,{...Re,velocity:-e*Le*(1+Math.min(r.count-1,Ie)*Fe)});let n=(e>0?he:me).current;n&&(t===`button`||t===`key`)&&D(n,{x:[0,-2.5,2.5,-1.5,1,0]},{duration:.32,ease:`easeOut`})}_&&(ue(e),window.clearTimeout(ge.current),ge.current=window.setTimeout(()=>ue(0),Me))}function Z(e,n){if(!Number.isFinite(e))return!1;let i=Ke(e),a=Math.sign(e-i);return a&&n!==`scrub`?(it(a>0?1:-1,n),se(`${J(i)}, ${a>0?`maximum`:`minimum`}`)):n===`button`&&i!==P.current&&se(J(i)),i!==P.current&&(P.current=i,t===void 0&&te(i),r?.(i),!0)}let Q=(e,t,n)=>Z(Xe(P.current,e*t),n);(0,R.useLayoutEffect)(()=>{P.current=w,Te.current=Q});function at(){let e=be.current;e&&we.current===null&&(we.current=e.getBoundingClientRect().left-L.get()-H.get())}(0,R.useLayoutEffect)(()=>{let e=we.current,t=be.current;if(we.current=null,I.current){I.current=!1;let e=N.current;if(e&&document.activeElement===e){let t=e.value.length;e.setSelectionRange(t,t)}}if(e===null||!t)return;let n=e-(t.getBoundingClientRect().left-L.get()-H.get());Math.abs(n)<.5||(H.set(H.get()+n),v?H.jump(0):D(H,0,V.morph))});function ot(){window.clearTimeout(_e.current),fe(!1)}function $(){if(!k)return;at(),A(!1),ot();let e=Ze(E);e!==null&&Z(qe(e),`type`)}function st(){window.clearTimeout(F.current),F.current=void 0,re(0)}function ct(e,t,n){st(),$();let r=Math.max(1,Math.round(t/S));n===`button`&&re(e);let i=0,a=()=>{let t=Te.current(e,r,n);F.current=window.setTimeout(a,t?Math.max(Ae,150*.86**++i):je)};F.current=window.setTimeout(a,Q(e,r,n)?ke:360)}function lt(e){let t=s??S*10,n={ArrowUp:[1,e.shiftKey?t:S],ArrowDown:[-1,e.shiftKey?t:S],PageUp:[1,t],PageDown:[-1,t]}[e.key];if(n){e.preventDefault(),e.repeat||ct(n[0],n[1],`key`);return}if(!k&&(e.key===`Home`&&Number.isFinite(i)||e.key===`End`&&a<2**53-1)){e.preventDefault(),Z(e.key===`Home`?i:a,`key`);return}e.key===`Enter`&&(e.preventDefault(),k?(I.current=!0,$()):e.currentTarget.select()),e.key===`Escape`&&k&&(e.preventDefault(),at(),A(!1),ot(),I.current=!0,Z(xe.current,`type`))}function ut(e){let t=RegExp(`[^0-9${Be(q.group)}${G||Ue?Be(q.decimal):``}${i<0?`\\-`:``}]`,`g`),n=e.replace(t,``);k||(xe.current=w),at(),O(n),A(!0);let r=Ze(n);r!==null&&r>=i&&r<=a&&qe(r)===r&&Z(r,`type`),ot(),r!==null&&r<i&&(_e.current=window.setTimeout(()=>fe(!0),Ne))}function dt(e){Ce.current=!1,p&&!l&&e.button===0&&($(),Se.current={pointer:e.pointerId,x:e.clientX,from:P.current,active:!1},e.currentTarget.setPointerCapture(e.pointerId))}function ft(e){let t=Se.current;if(!t||t.pointer!==e.pointerId)return;let n=e.clientX-t.x;if(!t.active){if(Math.abs(n)<3)return;t.active=!0,ae(!0)}let r=n/Oe,o=Math.trunc(r);Z(o?Xe(t.from,o):t.from,`scrub`);let s=t.from+r*S,c=s>a?(s-a)/S*Oe:s<i?(s-i)/S*Oe:0;L.set(v?0:He(c))}function pt(e){let t=Se.current;t&&t.pointer===e.pointerId&&(Se.current=null,t.active&&(Ce.current=!0,ae(!1),D(L,0,v?{duration:0}:V.snappy),se(J(P.current))))}let mt=t=>({toward:t,label:e,disabled:l,controls:b,limit:t>0?Y>=a:Y<=i,pressed:ne===t}),ht=Qe===null?0:Qe>a?1:Qe<i&&de?-1:0,gt=_?ht||le:0,_t=gt>0?a:i,vt=gt?typeof _==`function`?_(gt>0?`max`:`min`,_t):`${gt>0?`Max`:`Min`} ${J(_t)}`:``,yt=[x,ht&&_?ee:void 0].filter(Boolean).join(` `)||void 0;return(0,B.jsxs)(`div`,{className:z.field,"data-size":g,children:[(0,B.jsxs)(`div`,{className:z.head,children:[(0,B.jsx)(`label`,{htmlFor:b,className:z.label,"data-scrub":p&&!l||void 0,onPointerDown:dt,onPointerMove:ft,onPointerUp:pt,onPointerCancel:pt,onClick:e=>{Ce.current&&=(e.preventDefault(),!1)},children:e}),(0,B.jsx)(tt,{id:ee,edge:gt,text:vt})]}),(0,B.jsxs)(`div`,{ref:pe,className:z.control,"data-scrubbing":ie||void 0,"data-disabled":l||void 0,"data-warn":ht?ht>0?`max`:`min`:void 0,children:[(0,B.jsx)(nt,{...mt(-1),iconRef:me,onPress:()=>ct(-1,S,`button`),onRelease:st,onActivate:()=>{$(),Q(-1,1,`button`)}}),(0,B.jsx)(`div`,{className:z.valueWrap,onMouseDown:e=>{e.target!==N.current&&e.preventDefault()},onClick:e=>{!l&&e.target!==N.current&&(N.current?.focus(),N.current?.select())},children:(0,B.jsxs)(M.span,{ref:be,className:z.value,style:{x:U,y:Ee},children:[(0,B.jsx)(Ye,{text:Ve(d,Y),direction:rt,className:z.affix}),(0,B.jsxs)(`span`,{className:z.number,children:[(0,B.jsx)(`span`,{className:z.display,"data-hidden":k||void 0,"aria-hidden":`true`,children:(0,B.jsx)(Je,{value:Y,format:K,direction:rt,instant:k})}),k&&(0,B.jsx)(`span`,{className:z.mirror,"aria-hidden":`true`,children:E}),(0,B.jsx)(`input`,{ref:N,id:b,className:z.input,type:`text`,role:`spinbutton`,inputMode:i<0?`text`:G||Ue?`decimal`:`numeric`,autoComplete:`off`,spellCheck:!1,value:k?E:K.format(w),disabled:l,"aria-describedby":yt,"aria-invalid":ht?!0:void 0,"aria-valuenow":w,"aria-valuetext":J(w),"aria-valuemin":Number.isFinite(i)?i:void 0,"aria-valuemax":a<2**53-1?a:void 0,onChange:e=>ut(e.currentTarget.value),onKeyDown:lt,onKeyUp:e=>{/^(Arrow(Up|Down)|Page(Up|Down))$/.test(e.key)&&st()},onBlur:()=>{st(),$()}})]}),(0,B.jsx)(Ye,{text:Ve(f,Y),direction:rt,className:z.affix})]})}),(0,B.jsx)(nt,{...mt(1),iconRef:he,onPress:()=>ct(1,S,`button`),onRelease:st,onActivate:()=>{$(),Q(1,1,`button`)}})]}),(0,B.jsx)($e,{id:x,text:c,className:z.hint}),(0,B.jsx)(`span`,{className:z.srOnly,"aria-live":`polite`,"aria-atomic":`true`,children:oe})]})}var it=[`overview`,`cost`,`chart`,`topModel`,`compareYesterday`,`cacheHitRate`,`quota`];function Z(){let{t:e}=g(),n=p(),[i,o]=t(),s=f(),c=ie(i,{enabled:s.running,background:!1,live:!0}),l=t=>(0,B.jsx)(a,{label:e(`settings.tray.section.${t}`),detail:e(`settings.tray.section.${t}.hint`),children:(0,B.jsx)(x,{checked:i.sections[t],label:e(`settings.tray.section.${t}`),onChange:e=>o(E(i,t,e))})},t);return(0,B.jsxs)(`div`,{className:`mx-auto grid max-w-[1120px] items-start gap-4 lg:grid-cols-[minmax(0,1fr)_392px]`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,B.jsx)(Q,{title:e(`settings.tray.titleHeading`),hint:e(`settings.tray.titleHint`),children:(0,B.jsx)(`div`,{className:`p-4`,children:(0,B.jsx)(Se,{"aria-label":e(`settings.tray.titleHeading`),minColumnWidth:150,value:i.title,onValueChange:e=>o({...i,title:e}),options:u.map(t=>({value:t,label:e(`settings.tray.title.${t}`),description:e(`settings.tray.title.${t}.hint`)}))})})}),(0,B.jsx)(Q,{title:e(`settings.tray.usageHeading`),children:(0,B.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:it.map(l)})}),(0,B.jsx)(Q,{title:e(`settings.tray.clientsHeading`),children:(0,B.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:l(`clients`)})}),(0,B.jsx)(`div`,{children:(0,B.jsx)(r,{size:`sm`,variant:`plain`,icon:(0,B.jsx)(_e,{className:`size-3.5`}),onClick:()=>o(_),children:e(`settings.tray.reset`)})})]}),(0,B.jsx)(`div`,{className:`lg:sticky lg:top-0`,children:(0,B.jsxs)(Q,{title:e(`settings.tray.previewHeading`),hint:e(`settings.tray.previewHint`),children:[(0,B.jsx)(`div`,{className:`flex justify-center bg-[var(--surface-muted)] px-4 py-5`,children:(0,B.jsx)(pe,{preview:!0,className:`w-[360px] max-w-full shadow-[0_12px_40px_rgb(0_0_0/0.25)]`,prefs:i,state:s,data:c,onRefresh:()=>void n.invalidateQueries({queryKey:[`stats`]})})}),(0,B.jsx)(`p`,{className:`border-t border-[var(--border)] px-4 py-2.5 text-[11px] text-[var(--text-muted)]`,children:e(`settings.tray.previewFooter`)})]})})]})}function Q({title:e,hint:t,children:n}){let{t:r}=g();return(0,B.jsxs)(`section`,{className:`card`,children:[(0,B.jsxs)(`header`,{className:`border-b border-[var(--border)] px-4 py-3`,children:[(0,B.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`settings.tab.tray`)}),(0,B.jsx)(`h3`,{className:`text-[14px] font-semibold`,children:e}),t&&(0,B.jsx)(`p`,{className:`mt-0.5 text-[12px] text-[var(--text-secondary)]`,children:t})]}),n]})}var at=[`general`,`tray`];function ot(){let{t:e}=g(),{tab:t}=fe(),r=le(),i=n(),a=i&&at.includes(t)?t:`general`;return i?(0,B.jsx)(de,{title:e(`nav.settings`),children:(0,B.jsxs)(N,{value:a,onValueChange:e=>r(e===`general`?`/settings`:`/settings/${e}`,{replace:!0}),children:[(0,B.jsxs)(xe,{"aria-label":e(`nav.settings`),children:[(0,B.jsx)(F,{value:`general`,children:(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(L,{className:`size-3.5`}),e(`settings.tab.general`)]})}),(0,B.jsx)(F,{value:`tray`,children:(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Te,{className:`size-3.5`}),e(`settings.tab.tray`)]})})]}),(0,B.jsx)(ye,{value:`general`,className:`pt-5`,children:(0,B.jsx)($,{})}),(0,B.jsx)(ye,{value:`tray`,className:`pt-5`,children:(0,B.jsx)(Z,{})})]})}):(0,B.jsx)(de,{title:e(`nav.settings`),children:(0,B.jsx)($,{})})}function $(){let{t,locale:n,setLocale:i}=g(),o=be(),s=w(),u=m(),f=p(),_=v(),b=d(),te=ae(),{toast:T,confirm:E}=k(),D=s.data,O=e=>u.mutate(e,{onError:e=>T(C(e),`error`)}),A=e=>{i(e),O({locale:e})},j=async e=>{await h.copy(e)&&T(t(`common.copied`))};return(0,B.jsxs)(`div`,{className:`mx-auto max-w-[680px]`,children:[(0,B.jsxs)(y,{title:t(`settings.appearance`),children:[(0,B.jsx)(a,{label:t(`settings.theme`),children:(0,B.jsx)(c,{ariaLabel:t(`settings.theme`),value:o.theme,onChange:o.setTheme,items:[{value:`system`,label:t(`settings.theme.system`)},{value:`light`,label:t(`settings.theme.light`)},{value:`dark`,label:t(`settings.theme.dark`)}]})}),(0,B.jsx)(a,{label:t(`settings.accent`),detail:o.accentChoice===`system`?o.systemAccent?t(`settings.accent.followingSystem`):t(`settings.accent.systemUnavailable`):void 0,children:(0,B.jsx)(ne,{className:`w-40`,ariaLabel:t(`settings.accent`),value:o.accentChoice,onChange:o.setAccentChoice,options:[{value:`system`,label:t(`settings.accent.system`)},...P.map(e=>({value:e.color,label:t(`settings.accent.${e.id}`)}))]})}),(0,B.jsx)(a,{label:t(`settings.language`),detail:t(`settings.languageHint`),children:(0,B.jsx)(c,{ariaLabel:t(`settings.language`),value:n,onChange:A,items:[{value:`zh`,label:`中文`},{value:`en`,label:`English`}]})})]}),D?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(y,{title:t(`settings.gateway`),footer:t(`settings.gatewayFooter`),children:[(0,B.jsx)(a,{label:t(`settings.gatewayUrl`),detail:`${D.gatewayBaseUrl}/v1`,children:(0,B.jsx)(r,{size:`sm`,variant:`plain`,icon:(0,B.jsx)(re,{className:`size-3.5`}),"aria-label":t(`common.copy`),onClick:()=>void j(`${D.gatewayBaseUrl}/v1`)})}),(0,B.jsx)(a,{label:t(`settings.listen`),detail:`${D.host}:${D.port}`}),(0,B.jsx)(a,{label:t(`settings.dataDir`),detail:D.dataDir,children:h.canOpenPaths?(0,B.jsx)(r,{size:`sm`,variant:`plain`,icon:(0,B.jsx)(he,{className:`size-3.5`}),"aria-label":t(`settings.openFolder`),onClick:()=>void h.openPath(D.dataDir)}):(0,B.jsx)(r,{size:`sm`,variant:`plain`,icon:(0,B.jsx)(re,{className:`size-3.5`}),"aria-label":t(`common.copy`),onClick:()=>void j(D.dataDir)})}),(0,B.jsx)(a,{label:t(`settings.requireKey`),detail:t(`settings.requireKeyHint`),children:(0,B.jsx)(x,{checked:D.requireGatewayKey,label:t(`settings.requireKey`),onChange:async e=>{(e||await E({title:t(`settings.requireKeyOffConfirm`),detail:t(`settings.requireKeyOffDetail`),confirmLabel:t(`settings.requireKeyOff`),destructive:!0}))&&O({requireGatewayKey:e})}})}),(0,B.jsx)(a,{label:t(`settings.streamIdle`),detail:t(`settings.streamIdleHint`),children:(0,B.jsx)(ut,{label:t(`settings.streamIdle`),value:D.streamIdleTimeoutSec,onCommit:e=>O({streamIdleTimeoutSec:e??300}),suffix:` s`})})]}),(0,B.jsx)(ct,{settings:D}),(0,B.jsx)(lt,{settings:D}),(0,B.jsx)(y,{title:t(`settings.quota`),footer:t(`settings.quota.autoIntervalHint`),children:(0,B.jsx)(a,{label:t(`settings.quota.autoInterval`),children:(0,B.jsx)(ut,{label:t(`settings.quota.autoInterval`),value:D.quotaAutoIntervalMinutes,onCommit:t=>u.mutate({quotaAutoIntervalMinutes:t??30},{onSuccess:()=>void f.invalidateQueries({queryKey:e.providers}),onError:e=>T(C(e),`error`)}),suffix:` ${t(`settings.minutes`)}`})})}),(0,B.jsxs)(y,{title:t(`settings.logging`),footer:t(`settings.debugBodiesHint`),children:[(0,B.jsx)(a,{label:t(`settings.debugBodies`),children:(0,B.jsx)(x,{checked:D.debugBodies,label:t(`settings.debugBodies`),onChange:e=>O({debugBodies:e})})}),(0,B.jsx)(a,{label:t(`settings.bodyRetention`),children:(0,B.jsx)(ut,{label:t(`settings.bodyRetention`),value:D.bodyRetentionDays,onCommit:e=>O({bodyRetentionDays:e??7}),suffix:` ${t(`settings.days`)}`})}),(0,B.jsxs)(a,{label:t(`settings.requestRetention`),detail:D.requestRetentionDays==null?t(`settings.keepForever`):void 0,children:[(0,B.jsx)(x,{checked:D.requestRetentionDays!=null,label:t(`settings.requestRetention`),onChange:e=>O({requestRetentionDays:e?90:null})}),D.requestRetentionDays!=null&&(0,B.jsx)(ut,{label:t(`settings.requestRetention`),value:D.requestRetentionDays,onCommit:e=>O({requestRetentionDays:e??90}),suffix:` ${t(`settings.days`)}`})]})]}),(0,B.jsx)(y,{title:t(`settings.effort`),footer:t(`settings.effortHint`),children:[`low`,`medium`,`high`].map(e=>(0,B.jsx)(a,{label:t(`settings.effort.${e}`),children:(0,B.jsx)(ut,{label:t(`settings.effort.${e}`),value:D.effortBudgets[e],onCommit:t=>O({effortBudgets:{...D.effortBudgets,[e]:t??D.effortBudgets[e]}}),suffix:` tokens`,step:1024})},e))})]}):s.isError?(0,B.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:C(s.error)}):(0,B.jsx)(ee,{className:`mx-auto my-8`}),(0,B.jsxs)(y,{title:t(`settings.about`),children:[(0,B.jsx)(a,{label:t(`settings.serverVersion`),detail:_.data?`${_.data.version} · API ${_.data.apiVersion}`:`—`}),S&&(0,B.jsx)(a,{label:t(`settings.desktopVersion`),detail:l()?.version||`—`}),(0,B.jsx)(st,{}),S&&(0,B.jsx)(a,{label:t(`settings.logs`),onClick:()=>void h.revealLogs(),children:(0,B.jsx)(he,{className:`size-4 text-[var(--text-secondary)]`})}),b.data?.required&&(0,B.jsx)(a,{label:t(`settings.logout`),onClick:()=>te.mutate(),children:(0,B.jsx)(ge,{className:`size-4 text-[var(--text-secondary)]`})})]})]})}function st(){let{t}=g(),{toast:n}=k(),i=p(),o=m(),s=se(),c=b(),u=s.data,d=l()?.updates??null,[f,h]=(0,R.useState)(!1),_=()=>c.mutate(void 0,{onSuccess:e=>n(e.available?t(`settings.updateAvailable`,{version:e.available}):t(`settings.upToDate`)),onError:e=>n(C(e),`error`)}),v=()=>{d&&!f&&(h(!0),d.apply().then(r=>{r===`server`?(n(t(`settings.updateApplied`)),i.invalidateQueries({queryKey:e.version}),i.invalidateQueries({queryKey:e.update})):n(t(r===`desktop`?`settings.updateDesktopRelaunch`:`settings.upToDate`))}).catch(e=>n(C(e),`error`)).finally(()=>h(!1)))},y=u?.lastCheckAt?new Date(u.lastCheckAt).toLocaleString():void 0,S=u?.available?d?t(`settings.updateAvailable`,{version:u.available}):`${t(`settings.updateAvailable`,{version:u.available})} ${t(`settings.updateApplyHint`)}`:void 0;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(a,{label:t(`settings.autoCheck`),detail:u&&!u.feedConfigured?t(`settings.updateCheckFailed`,{error:`feed-not-configured`}):void 0,children:(0,B.jsx)(x,{checked:u?.autoCheck??!0,label:t(`settings.autoCheck`),onChange:e=>o.mutate({updateAutoCheck:e},{onError:e=>n(C(e),`error`)})})}),(0,B.jsxs)(a,{label:t(`settings.checkUpdates`),detail:c.isError?t(`settings.updateCheckFailed`,{error:C(c.error)}):u?.available?S:y?t(`settings.lastChecked`,{time:y}):void 0,children:[(0,B.jsx)(r,{size:`sm`,variant:`plain`,disabled:c.isPending,onClick:_,children:c.isPending?(0,B.jsx)(ee,{className:`size-3.5`}):(0,B.jsx)(ve,{className:`size-3.5`})}),d&&u?.available&&(0,B.jsx)(r,{size:`sm`,variant:`plain`,disabled:f,"aria-label":t(`settings.updateApply`),onClick:v,children:f?(0,B.jsx)(ee,{className:`size-3.5`}):(0,B.jsx)(me,{className:`size-3.5`})})]})]})}function ct({settings:e}){let{t}=g(),{toast:n}=k(),i=m(),[s,l]=(0,R.useState)(e.proxyMode),[u,d]=(0,R.useState)({url:e.proxyUrl??``,username:e.proxyUsername??``,password:``,bypass:e.proxyBypass??``});(0,R.useEffect)(()=>l(e.proxyMode),[e.proxyMode]),(0,R.useEffect)(()=>d({url:e.proxyUrl??``,username:e.proxyUsername??``,password:``,bypass:e.proxyBypass??``}),[e.proxyUrl,e.proxyUsername,e.proxyBypass,e.hasProxyPassword]);let f=t=>{l(t),(t!==`custom`||e.proxyUrl)&&i.mutate({proxyMode:t},{onError:e=>n(C(e),`error`)})},p=()=>i.mutate({proxyMode:`custom`,proxyUrl:u.url.trim()||null,proxyUsername:u.username.trim()||null,proxyBypass:u.bypass.trim()||null,...u.password?{proxyPassword:u.password}:{}},{onSuccess:()=>n(t(`settings.proxy.saved`)),onError:e=>n(C(e),`error`)}),h=s!==e.proxyMode||u.url!==(e.proxyUrl??``)||u.username!==(e.proxyUsername??``)||u.password!==``||u.bypass!==(e.proxyBypass??``);return(0,B.jsxs)(y,{title:t(`settings.proxy`),footer:t(`settings.proxy.footer`),children:[(0,B.jsx)(a,{label:t(`settings.proxy.mode`),detail:t(`settings.proxy.mode.${s}.hint`),children:(0,B.jsx)(c,{ariaLabel:t(`settings.proxy.mode`),value:s,onChange:f,items:[{value:`system`,label:t(`settings.proxy.mode.system`)},{value:`custom`,label:t(`settings.proxy.mode.custom`)},{value:`direct`,label:t(`settings.proxy.mode.direct`)}]})}),s===`custom`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(a,{label:t(`settings.proxy.url`),detail:t(`settings.proxy.urlHint`),children:(0,B.jsx)(o,{className:`w-64`,mono:!0,"aria-label":t(`settings.proxy.url`),placeholder:`http://127.0.0.1:7890`,value:u.url,onChange:e=>d({...u,url:e.target.value})})}),(0,B.jsx)(a,{label:t(`settings.proxy.username`),detail:t(`settings.proxy.optional`),children:(0,B.jsx)(o,{className:`w-64`,autoComplete:`off`,"aria-label":t(`settings.proxy.username`),value:u.username,onChange:e=>d({...u,username:e.target.value})})}),(0,B.jsx)(a,{label:t(`settings.proxy.password`),detail:e.hasProxyPassword?t(`settings.proxy.passwordSaved`):t(`settings.proxy.optional`),children:(0,B.jsx)(o,{className:`w-64`,type:`password`,autoComplete:`new-password`,"aria-label":t(`settings.proxy.password`),placeholder:e.hasProxyPassword?`••••••••`:void 0,value:u.password,onChange:e=>d({...u,password:e.target.value})})}),(0,B.jsx)(a,{label:t(`settings.proxy.bypass`),detail:t(`settings.proxy.bypassHint`),children:(0,B.jsx)(o,{className:`w-64`,mono:!0,"aria-label":t(`settings.proxy.bypass`),placeholder:`example.com, *.lan`,value:u.bypass,onChange:e=>d({...u,bypass:e.target.value})})}),(0,B.jsx)(`div`,{className:`flex justify-end px-4 py-2`,children:(0,B.jsx)(r,{size:`sm`,disabled:!h||!u.url.trim()||i.isPending,onClick:p,children:t(`common.save`)})})]})]})}function lt({settings:e}){let{t}=g(),{toast:n}=k(),i=m(),s=e.pluginMarketUrl===``,[c,l]=(0,R.useState)(e.pluginMarketUrl??``);(0,R.useEffect)(()=>l(e.pluginMarketUrl??``),[e.pluginMarketUrl]);let u=(e,r=!1)=>i.mutate({pluginMarketUrl:e},{onSuccess:()=>r&&n(t(`settings.pluginMarket.saved`)),onError:e=>n(C(e),`error`)});return(0,B.jsxs)(y,{title:t(`settings.pluginMarket`),footer:t(`settings.pluginMarket.footer`),children:[(0,B.jsx)(a,{label:t(`settings.pluginMarket.offline`),detail:t(`settings.pluginMarket.offlineHint`),children:(0,B.jsx)(x,{checked:s,label:t(`settings.pluginMarket.offline`),onChange:e=>u(e?``:null)})}),!s&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(a,{label:t(`settings.pluginMarket.url`),detail:t(`settings.pluginMarket.urlHint`),children:(0,B.jsx)(o,{className:`w-80`,mono:!0,"aria-label":t(`settings.pluginMarket.url`),placeholder:e.pluginMarketDefaultUrl,value:c,onChange:e=>l(e.target.value)})}),(0,B.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-2`,children:[e.pluginMarketUrl!==null&&(0,B.jsx)(r,{size:`sm`,disabled:i.isPending,onClick:()=>u(null,!0),children:t(`settings.pluginMarket.reset`)}),(0,B.jsx)(r,{size:`sm`,disabled:i.isPending||c.trim()===(e.pluginMarketUrl??``),onClick:()=>u(c.trim()||null,!0),children:t(`common.save`)})]})]})]})}function ut({label:e,value:t,onCommit:n,suffix:r,step:i=1}){let[a,o]=(0,R.useState)(t);(0,R.useEffect)(()=>o(t),[t]);let s=(0,R.useRef)(n);return(0,R.useEffect)(()=>{s.current=n}),(0,R.useEffect)(()=>{if(a===t)return;let e=setTimeout(()=>s.current(a),600);return()=>clearTimeout(e)},[a,t]),(0,B.jsx)(`div`,{className:`astra-label-hidden w-36`,children:(0,B.jsx)(rt,{label:e,size:`sm`,value:a,onValueChange:o,min:0,step:i,suffix:r})})}export{ot as SettingsPage};
@@ -1 +1 @@
1
- import{Ai as e,B as t,F as n,Fa as r,H as i,Ia as a,N as o,P as s,Sn as c,Tn as l,Vi as u,Y as d,Yr as f,Zn as p,a as m,an as h,ci as g,dn as _,fn as v,gi as y,i as b,ln as x,mn as S,n as C,o as w,qr as T,r as E,rr as D,st as O,ui as k,un as A,z as j,za as M}from"./overlays-CnzrFKmb.js";import{c as N,s as P,t as F}from"./Page-D9s9brqr.js";import{t as I}from"./ellipsis-B2d4aPpF.js";import{t as L}from"./pencil-nlLBeib5.js";import{t as R}from"./power-DQiCs26X.js";import{t as z}from"./rotate-ccw-BLaDyhPe.js";import{S as B,T as V,f as H,u as U}from"./index-br322rzz.js";var W=M(a(),1),G=r();function K(){let{t}=l(),r=e(),i=y(),[a,s]=(0,W.useState)(!1),[c,u]=(0,W.useState)(null);return(0,G.jsxs)(F,{title:t(`nav.tokens`),subtitle:t(`tokens.subtitle`),actions:(0,G.jsx)(n,{variant:`primary`,icon:(0,G.jsx)(P,{className:`size-3.5`}),onClick:()=>s(!0),children:t(`tokens.add`)}),children:[(0,G.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col gap-4`,children:[i.data&&(0,G.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-secondary)]`,children:t(`tokens.directHint`,{url:`${i.data.gatewayBaseUrl}/v1`})}),r.isLoading&&(0,G.jsx)(d,{lines:4}),r.isError&&(0,G.jsx)(o,{tone:`danger`,title:t(`common.error`),children:m(r.error)}),r.data?.length===0&&(0,G.jsx)(`div`,{className:`card`,children:(0,G.jsx)(j,{icon:(0,G.jsx)(N,{className:`size-6`}),title:t(`tokens.empty`)})}),r.data&&r.data.length>0&&(0,G.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] overflow-hidden p-0`,children:r.data.map(e=>(0,G.jsx)(q,{token:e,defaultOpen:r.data.length===1,onEdit:()=>u(e)},e.id))})]}),(0,G.jsx)(Z,{open:a,onOpenChange:s}),(0,G.jsx)(Q,{token:c,onClose:()=>u(null)})]})}function q({token:e,defaultOpen:t,onEdit:r}){let{t:i,locale:a}=l(),{toast:o,confirm:d}=w(),p=f(),v=k(),y=u(),b=g(),x=D(),[T,E]=(0,W.useState)(t),j=(p.data??[]).find(t=>t.id===e.providerId),M=`token-detail-${e.id}`,N=(e,t)=>{o(t,`success`),e.skipped.length>0&&o(i(`tokens.skipped`,{clients:e.skipped.map(e=>U[e]?.name??e).join(`, `)}),`error`)},P=()=>v.mutate(e.id,{onSuccess:async({token:e})=>{await c.copy(e)&&o(i(`tokens.copied`))},onError:e=>o(m(e),`error`)}),F=async()=>{(!e.enabled||await d({title:i(`tokens.disableConfirm`,{name:e.name}),detail:i(`tokens.disableDetail`),confirmLabel:i(`tokens.disable`),destructive:!0}))&&y.mutate({id:e.id,enabled:!e.enabled},{onError:e=>o(m(e),`error`)})},K=async()=>{await d({title:i(`tokens.resetConfirm`,{name:e.name}),detail:i(`tokens.resetDetail`),confirmLabel:i(`tokens.reset`),destructive:!0})&&b.mutate(e.id,{onSuccess:e=>N(e,i(`tokens.resetDone`,{count:e.rewritten.length})),onError:e=>o(m(e),`error`)})},q=async()=>{await d({title:i(`tokens.deleteConfirm`,{name:e.name}),detail:i(`tokens.deleteDetail`),confirmLabel:i(`common.delete`),destructive:!0})&&x.mutate(e.id,{onSuccess:t=>N(t,i(`tokens.deleted`,{name:e.name})),onError:e=>o(m(e),`error`)})},X=e.lastUsedAt?h(e.lastUsedAt,a):i(`tokens.neverUsed`);return(0,G.jsxs)(`article`,{children:[(0,G.jsxs)(`div`,{className:`flex cursor-pointer flex-wrap items-center gap-x-5 gap-y-2 px-4 py-3 hover:bg-[var(--surface-muted)]`,onClick:()=>E(e=>!e),children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-56 items-start gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,className:`mt-0.5 rounded text-[var(--text-muted)]`,"aria-expanded":T,"aria-controls":M,"aria-label":i(`tokens.details`),onClick:e=>{e.stopPropagation(),E(e=>!e)},children:(0,G.jsx)(V,{className:`size-4 transition-transform ${T?`rotate-90`:``}`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`truncate text-[14px] font-medium ${e.enabled?``:`text-[var(--text-muted)]`}`,children:e.name}),e.isDefault&&(0,G.jsx)(s,{tone:`accent`,children:i(`tokens.default`)}),!e.enabled&&(0,G.jsx)(s,{tone:`orange`,children:i(`tokens.disabledBadge`)})]}),(0,G.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--text-secondary)] selectable`,children:e.keyMasked}),(0,G.jsx)(n,{size:`sm`,variant:`plain`,icon:(0,G.jsx)(O,{className:`size-3.5`}),"aria-label":i(`tokens.copy`),title:i(`tokens.copy`),loading:v.isPending,onClick:P})]})]})]}),(0,G.jsx)(`div`,{className:`hidden w-16 items-center gap-1.5 md:flex`,title:e.clients.map(e=>U[e]?.name??e).join(`, `)||i(`tokens.noClients`),children:e.clients.length===0?(0,G.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:`—`}):e.clients.map(e=>(0,G.jsx)(H,{kind:e,size:16},e))}),(0,G.jsx)(J,{label:i(`tokens.today`),value:S(e.today.costUsd),context:i(`tokens.requestsContext`,{count:_(e.today.requests)})}),(0,G.jsx)(J,{label:i(`tokens.total`),value:S(e.total.costUsd),context:`${_(e.total.totalTokens,!0)} Token`}),(0,G.jsx)(J,{label:i(`tokens.lastUsedTitle`),value:e.lastUsedAt?A(e.lastUsedAt,a):`—`,context:e.lastUsedAt?``:i(`tokens.neverUsed`),title:X}),(0,G.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,G.jsx)(C,{label:i(`common.more`),icon:(0,G.jsx)(I,{className:`size-4`}),items:[{id:`settings`,label:i(`tokens.settings`),icon:(0,G.jsx)(L,{className:`size-3.5`}),onSelect:r},{id:`toggle`,label:e.enabled?i(`tokens.disable`):i(`tokens.enable`),icon:(0,G.jsx)(R,{className:`size-3.5`}),onSelect:()=>void F()},{id:`reset`,label:i(`tokens.reset`),icon:(0,G.jsx)(z,{className:`size-3.5`}),onSelect:()=>void K()},...e.isDefault?[]:[{id:`delete`,label:i(`tokens.delete`),icon:(0,G.jsx)(B,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void q()}]]})})]}),T&&(0,G.jsxs)(`div`,{id:M,className:`border-t border-[var(--border-subtle)] bg-[var(--surface-muted)] px-4 py-3 md:pl-10`,children:[(0,G.jsxs)(`dl`,{className:`flex flex-wrap gap-x-8 gap-y-2 text-[12px]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:i(`tokens.clients`)}),(0,G.jsx)(`dd`,{className:`mt-0.5 flex min-h-5 flex-wrap items-center gap-x-3 gap-y-1 text-[var(--text-secondary)]`,children:e.clients.length===0?i(`tokens.noClients`):e.clients.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(H,{kind:e,size:14}),U[e]?.name??e]},e))})]}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:i(`tokens.directProvider`)}),(0,G.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:j?.name??(e.providerId?e.providerId:i(`tokens.directNone`))})]}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:i(`tokens.lastUsedTitle`)}),(0,G.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:X})]})]}),(0,G.jsx)(Y,{today:e.today,total:e.total})]})]})}function J({label:e,value:t,context:n,title:r}){return(0,G.jsxs)(`div`,{className:`w-24 min-w-0`,title:r,children:[(0,G.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,G.jsx)(`div`,{className:`num truncate text-[14px] leading-tight font-semibold`,children:t}),(0,G.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:n||`\xA0`})]})}function Y({today:e,total:t}){let{t:n}=l(),r=[[n(`tokens.today`),e],[n(`tokens.total`),t]],i=`px-3 py-1.5 text-right font-normal whitespace-nowrap text-[var(--text-muted)]`,a=`num px-3 py-1.5 text-right whitespace-nowrap`;return(0,G.jsx)(`div`,{className:`mt-3 overflow-x-auto rounded-[var(--radius-control)] bg-[var(--surface)]`,children:(0,G.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`border-b border-[var(--border-subtle)]`,children:[(0,G.jsx)(`th`,{className:`${i} text-left`}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.cost`)}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.requests`)}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.tokens`)}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.inOut`)}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.cacheHit`)}),(0,G.jsx)(`th`,{className:i,title:n(`tokens.tpsContext`),children:n(`tokens.tps`)})]})}),(0,G.jsx)(`tbody`,{children:r.map(([e,t])=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`row`,className:`px-3 py-1.5 text-left font-medium whitespace-nowrap text-[var(--text-secondary)]`,children:e}),(0,G.jsx)(`td`,{className:`${a} font-semibold selectable`,children:S(t.costUsd)}),(0,G.jsx)(`td`,{className:a,children:_(t.requests)}),(0,G.jsx)(`td`,{className:a,children:_(t.totalTokens,!0)}),(0,G.jsxs)(`td`,{className:`${a} text-[var(--text-secondary)]`,children:[_(t.inputTokens,!0),` / `,_(t.outputTokens,!0)]}),(0,G.jsx)(`td`,{className:a,title:n(`usage.cacheAmounts`,{read:_(t.cacheReadTokens,!0),write:_(t.cacheWriteTokens,!0)}),children:t.cacheHitRate==null?`—`:x(t.cacheHitRate)}),(0,G.jsx)(`td`,{className:a,children:t.tps==null?`—`:v(t.tps)})]},e))})]})})}function X(){let{t:e}=l(),t=(f().data??[]).filter(e=>e.enabled);return{providers:t,options:[{value:``,label:e(`tokens.directNone`)},...t.map(e=>({value:e.id,label:e.name}))]}}function Z({open:e,onOpenChange:r}){let{t:a}=l(),{toast:o}=w(),s=p(),{options:c}=X(),[u,d]=(0,W.useState)(``),[f,h]=(0,W.useState)(``);return(0,W.useEffect)(()=>{e&&(d(``),h(``))},[e]),(0,G.jsx)(b,{open:e,onOpenChange:r,title:a(`tokens.createTitle`),footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(n,{onClick:()=>r(!1),children:a(`common.cancel`)}),(0,G.jsx)(n,{variant:`primary`,disabled:!u.trim(),loading:s.isPending,onClick:()=>s.mutate({name:u.trim(),providerId:f||null},{onSuccess:e=>{r(!1),o(a(`tokens.created`,{name:e.name}),`success`)},onError:e=>o(m(e),`error`)}),children:a(`common.create`)})]}),children:(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsx)(t,{label:a(`tokens.name`),children:(0,G.jsx)(i,{value:u,maxLength:64,placeholder:a(`tokens.namePlaceholder`),onChange:e=>d(e.target.value)})}),(0,G.jsx)(t,{label:a(`tokens.directProvider`),children:(0,G.jsx)(E,{value:f,onChange:h,options:c})})]})})}function Q({token:e,onClose:r}){let{t:a}=l(),{toast:o}=w(),s=u(),{providers:c,options:d}=X(),[f,p]=(0,W.useState)(``),[h,g]=(0,W.useState)(``),[_,v]=(0,W.useState)(``),y=c.find(e=>e.id===h),x=y?.authScheme===`oauth-subscription`||y?.authScheme===`plugin`,S=T(y?.id,x);return(0,W.useEffect)(()=>{e&&(p(e.name),g(e.providerId??``),v(e.accountId??``))},[e]),(0,G.jsx)(b,{open:e!==null,onOpenChange:e=>!e&&r(),title:a(`tokens.settingsTitle`,{name:e?.name??``}),footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(n,{onClick:r,children:a(`common.cancel`)}),(0,G.jsx)(n,{variant:`primary`,disabled:!f.trim(),loading:s.isPending,onClick:()=>{e&&s.mutate({id:e.id,name:f.trim(),providerId:h||null,accountId:x&&_||null},{onSuccess:()=>{r(),o(a(`common.saved`),`success`)},onError:e=>o(m(e),`error`)})},children:a(`common.save`)})]}),children:(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsx)(t,{label:a(`tokens.name`),children:(0,G.jsx)(i,{value:f,maxLength:64,onChange:e=>p(e.target.value)})}),(0,G.jsx)(t,{label:a(`tokens.directProvider`),children:(0,G.jsx)(E,{value:h,onChange:e=>{g(e),v(``)},options:d})}),x&&(0,G.jsx)(t,{label:a(`tokens.directAccount`),children:(0,G.jsx)(E,{value:_,onChange:v,options:[{value:``,label:a(`clients.accountDefault`)},...(S.data??[]).map(e=>({value:e.id,label:e.displayName||e.id}))]})})]})})}export{K as TokensPage};
1
+ import{Ai as e,B as t,F as n,Fa as r,H as i,Ia as a,N as o,P as s,Sn as c,Tn as l,Vi as u,Y as d,Yr as f,Zn as p,a as m,an as h,ci as g,dn as _,fn as v,gi as y,i as b,ln as x,mn as S,n as C,o as w,qr as T,r as E,rr as D,st as O,ui as k,un as A,z as j,za as M}from"./overlays-D1ZtG8Qn.js";import{c as N,s as P,t as F}from"./Page-CnSErb_N.js";import{t as I}from"./ellipsis-zTWIrsa4.js";import{t as L}from"./pencil-DyidL-8l.js";import{t as R}from"./power-CJZylS33.js";import{t as z}from"./rotate-ccw-Dr0Xbikv.js";import{S as B,T as V,f as H,u as U}from"./index-PfVyiY3J.js";var W=M(a(),1),G=r();function K(){let{t}=l(),r=e(),i=y(),[a,s]=(0,W.useState)(!1),[c,u]=(0,W.useState)(null);return(0,G.jsxs)(F,{title:t(`nav.tokens`),subtitle:t(`tokens.subtitle`),actions:(0,G.jsx)(n,{variant:`primary`,icon:(0,G.jsx)(P,{className:`size-3.5`}),onClick:()=>s(!0),children:t(`tokens.add`)}),children:[(0,G.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col gap-4`,children:[i.data&&(0,G.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-secondary)]`,children:t(`tokens.directHint`,{url:`${i.data.gatewayBaseUrl}/v1`})}),r.isLoading&&(0,G.jsx)(d,{lines:4}),r.isError&&(0,G.jsx)(o,{tone:`danger`,title:t(`common.error`),children:m(r.error)}),r.data?.length===0&&(0,G.jsx)(`div`,{className:`card`,children:(0,G.jsx)(j,{icon:(0,G.jsx)(N,{className:`size-6`}),title:t(`tokens.empty`)})}),r.data&&r.data.length>0&&(0,G.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] overflow-hidden p-0`,children:r.data.map(e=>(0,G.jsx)(q,{token:e,defaultOpen:r.data.length===1,onEdit:()=>u(e)},e.id))})]}),(0,G.jsx)(Z,{open:a,onOpenChange:s}),(0,G.jsx)(Q,{token:c,onClose:()=>u(null)})]})}function q({token:e,defaultOpen:t,onEdit:r}){let{t:i,locale:a}=l(),{toast:o,confirm:d}=w(),p=f(),v=k(),y=u(),b=g(),x=D(),[T,E]=(0,W.useState)(t),j=(p.data??[]).find(t=>t.id===e.providerId),M=`token-detail-${e.id}`,N=(e,t)=>{o(t,`success`),e.skipped.length>0&&o(i(`tokens.skipped`,{clients:e.skipped.map(e=>U[e]?.name??e).join(`, `)}),`error`)},P=()=>v.mutate(e.id,{onSuccess:async({token:e})=>{await c.copy(e)&&o(i(`tokens.copied`))},onError:e=>o(m(e),`error`)}),F=async()=>{(!e.enabled||await d({title:i(`tokens.disableConfirm`,{name:e.name}),detail:i(`tokens.disableDetail`),confirmLabel:i(`tokens.disable`),destructive:!0}))&&y.mutate({id:e.id,enabled:!e.enabled},{onError:e=>o(m(e),`error`)})},K=async()=>{await d({title:i(`tokens.resetConfirm`,{name:e.name}),detail:i(`tokens.resetDetail`),confirmLabel:i(`tokens.reset`),destructive:!0})&&b.mutate(e.id,{onSuccess:e=>N(e,i(`tokens.resetDone`,{count:e.rewritten.length})),onError:e=>o(m(e),`error`)})},q=async()=>{await d({title:i(`tokens.deleteConfirm`,{name:e.name}),detail:i(`tokens.deleteDetail`),confirmLabel:i(`common.delete`),destructive:!0})&&x.mutate(e.id,{onSuccess:t=>N(t,i(`tokens.deleted`,{name:e.name})),onError:e=>o(m(e),`error`)})},X=e.lastUsedAt?h(e.lastUsedAt,a):i(`tokens.neverUsed`);return(0,G.jsxs)(`article`,{children:[(0,G.jsxs)(`div`,{className:`flex cursor-pointer flex-wrap items-center gap-x-5 gap-y-2 px-4 py-3 hover:bg-[var(--surface-muted)]`,onClick:()=>E(e=>!e),children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-56 items-start gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,className:`mt-0.5 rounded text-[var(--text-muted)]`,"aria-expanded":T,"aria-controls":M,"aria-label":i(`tokens.details`),onClick:e=>{e.stopPropagation(),E(e=>!e)},children:(0,G.jsx)(V,{className:`size-4 transition-transform ${T?`rotate-90`:``}`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`truncate text-[14px] font-medium ${e.enabled?``:`text-[var(--text-muted)]`}`,children:e.name}),e.isDefault&&(0,G.jsx)(s,{tone:`accent`,children:i(`tokens.default`)}),!e.enabled&&(0,G.jsx)(s,{tone:`orange`,children:i(`tokens.disabledBadge`)})]}),(0,G.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--text-secondary)] selectable`,children:e.keyMasked}),(0,G.jsx)(n,{size:`sm`,variant:`plain`,icon:(0,G.jsx)(O,{className:`size-3.5`}),"aria-label":i(`tokens.copy`),title:i(`tokens.copy`),loading:v.isPending,onClick:P})]})]})]}),(0,G.jsx)(`div`,{className:`hidden w-16 items-center gap-1.5 md:flex`,title:e.clients.map(e=>U[e]?.name??e).join(`, `)||i(`tokens.noClients`),children:e.clients.length===0?(0,G.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:`—`}):e.clients.map(e=>(0,G.jsx)(H,{kind:e,size:16},e))}),(0,G.jsx)(J,{label:i(`tokens.today`),value:S(e.today.costUsd),context:i(`tokens.requestsContext`,{count:_(e.today.requests)})}),(0,G.jsx)(J,{label:i(`tokens.total`),value:S(e.total.costUsd),context:`${_(e.total.totalTokens,!0)} Token`}),(0,G.jsx)(J,{label:i(`tokens.lastUsedTitle`),value:e.lastUsedAt?A(e.lastUsedAt,a):`—`,context:e.lastUsedAt?``:i(`tokens.neverUsed`),title:X}),(0,G.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,G.jsx)(C,{label:i(`common.more`),icon:(0,G.jsx)(I,{className:`size-4`}),items:[{id:`settings`,label:i(`tokens.settings`),icon:(0,G.jsx)(L,{className:`size-3.5`}),onSelect:r},{id:`toggle`,label:e.enabled?i(`tokens.disable`):i(`tokens.enable`),icon:(0,G.jsx)(R,{className:`size-3.5`}),onSelect:()=>void F()},{id:`reset`,label:i(`tokens.reset`),icon:(0,G.jsx)(z,{className:`size-3.5`}),onSelect:()=>void K()},...e.isDefault?[]:[{id:`delete`,label:i(`tokens.delete`),icon:(0,G.jsx)(B,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void q()}]]})})]}),T&&(0,G.jsxs)(`div`,{id:M,className:`border-t border-[var(--border-subtle)] bg-[var(--surface-muted)] px-4 py-3 md:pl-10`,children:[(0,G.jsxs)(`dl`,{className:`flex flex-wrap gap-x-8 gap-y-2 text-[12px]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:i(`tokens.clients`)}),(0,G.jsx)(`dd`,{className:`mt-0.5 flex min-h-5 flex-wrap items-center gap-x-3 gap-y-1 text-[var(--text-secondary)]`,children:e.clients.length===0?i(`tokens.noClients`):e.clients.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(H,{kind:e,size:14}),U[e]?.name??e]},e))})]}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:i(`tokens.directProvider`)}),(0,G.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:j?.name??(e.providerId?e.providerId:i(`tokens.directNone`))})]}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:i(`tokens.lastUsedTitle`)}),(0,G.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:X})]})]}),(0,G.jsx)(Y,{today:e.today,total:e.total})]})]})}function J({label:e,value:t,context:n,title:r}){return(0,G.jsxs)(`div`,{className:`w-24 min-w-0`,title:r,children:[(0,G.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,G.jsx)(`div`,{className:`num truncate text-[14px] leading-tight font-semibold`,children:t}),(0,G.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:n||`\xA0`})]})}function Y({today:e,total:t}){let{t:n}=l(),r=[[n(`tokens.today`),e],[n(`tokens.total`),t]],i=`px-3 py-1.5 text-right font-normal whitespace-nowrap text-[var(--text-muted)]`,a=`num px-3 py-1.5 text-right whitespace-nowrap`;return(0,G.jsx)(`div`,{className:`mt-3 overflow-x-auto rounded-[var(--radius-control)] bg-[var(--surface)]`,children:(0,G.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`border-b border-[var(--border-subtle)]`,children:[(0,G.jsx)(`th`,{className:`${i} text-left`}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.cost`)}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.requests`)}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.tokens`)}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.inOut`)}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.cacheHit`)}),(0,G.jsx)(`th`,{className:i,title:n(`tokens.tpsContext`),children:n(`tokens.tps`)})]})}),(0,G.jsx)(`tbody`,{children:r.map(([e,t])=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`row`,className:`px-3 py-1.5 text-left font-medium whitespace-nowrap text-[var(--text-secondary)]`,children:e}),(0,G.jsx)(`td`,{className:`${a} font-semibold selectable`,children:S(t.costUsd)}),(0,G.jsx)(`td`,{className:a,children:_(t.requests)}),(0,G.jsx)(`td`,{className:a,children:_(t.totalTokens,!0)}),(0,G.jsxs)(`td`,{className:`${a} text-[var(--text-secondary)]`,children:[_(t.inputTokens,!0),` / `,_(t.outputTokens,!0)]}),(0,G.jsx)(`td`,{className:a,title:n(`usage.cacheAmounts`,{read:_(t.cacheReadTokens,!0),write:_(t.cacheWriteTokens,!0)}),children:t.cacheHitRate==null?`—`:x(t.cacheHitRate)}),(0,G.jsx)(`td`,{className:a,children:t.tps==null?`—`:v(t.tps)})]},e))})]})})}function X(){let{t:e}=l(),t=(f().data??[]).filter(e=>e.enabled);return{providers:t,options:[{value:``,label:e(`tokens.directNone`)},...t.map(e=>({value:e.id,label:e.name}))]}}function Z({open:e,onOpenChange:r}){let{t:a}=l(),{toast:o}=w(),s=p(),{options:c}=X(),[u,d]=(0,W.useState)(``),[f,h]=(0,W.useState)(``);return(0,W.useEffect)(()=>{e&&(d(``),h(``))},[e]),(0,G.jsx)(b,{open:e,onOpenChange:r,title:a(`tokens.createTitle`),footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(n,{onClick:()=>r(!1),children:a(`common.cancel`)}),(0,G.jsx)(n,{variant:`primary`,disabled:!u.trim(),loading:s.isPending,onClick:()=>s.mutate({name:u.trim(),providerId:f||null},{onSuccess:e=>{r(!1),o(a(`tokens.created`,{name:e.name}),`success`)},onError:e=>o(m(e),`error`)}),children:a(`common.create`)})]}),children:(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsx)(t,{label:a(`tokens.name`),children:(0,G.jsx)(i,{value:u,maxLength:64,placeholder:a(`tokens.namePlaceholder`),onChange:e=>d(e.target.value)})}),(0,G.jsx)(t,{label:a(`tokens.directProvider`),children:(0,G.jsx)(E,{value:f,onChange:h,options:c})})]})})}function Q({token:e,onClose:r}){let{t:a}=l(),{toast:o}=w(),s=u(),{providers:c,options:d}=X(),[f,p]=(0,W.useState)(``),[h,g]=(0,W.useState)(``),[_,v]=(0,W.useState)(``),y=c.find(e=>e.id===h),x=y?.authScheme===`oauth-subscription`||y?.authScheme===`plugin`,S=T(y?.id,x);return(0,W.useEffect)(()=>{e&&(p(e.name),g(e.providerId??``),v(e.accountId??``))},[e]),(0,G.jsx)(b,{open:e!==null,onOpenChange:e=>!e&&r(),title:a(`tokens.settingsTitle`,{name:e?.name??``}),footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(n,{onClick:r,children:a(`common.cancel`)}),(0,G.jsx)(n,{variant:`primary`,disabled:!f.trim(),loading:s.isPending,onClick:()=>{e&&s.mutate({id:e.id,name:f.trim(),providerId:h||null,accountId:x&&_||null},{onSuccess:()=>{r(),o(a(`common.saved`),`success`)},onError:e=>o(m(e),`error`)})},children:a(`common.save`)})]}),children:(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsx)(t,{label:a(`tokens.name`),children:(0,G.jsx)(i,{value:f,maxLength:64,onChange:e=>p(e.target.value)})}),(0,G.jsx)(t,{label:a(`tokens.directProvider`),children:(0,G.jsx)(E,{value:h,onChange:e=>{g(e),v(``)},options:d})}),x&&(0,G.jsx)(t,{label:a(`tokens.directAccount`),children:(0,G.jsx)(E,{value:_,onChange:v,options:[{value:``,label:a(`clients.accountDefault`)},...(S.data??[]).map(e=>({value:e.id,label:e.displayName||e.id}))]})})]})})}export{K as TokensPage};
@@ -1 +1 @@
1
- import{Ct as e,Dn as t,Dt as n,Fa as r,Ia as i,Ji as a,Ot as o,Pa as s,Sn as c,Tn as l,a as u,o as d,pi as f,wt as p,za as m}from"./overlays-CnzrFKmb.js";import{t as h}from"./TrayPanelView-BPGmNn0R.js";var g=m(i(),1),_=r(),v=new Set([`astra.theme`,`astra.accent`,`astra.locale`]);function y(){let{t:r}=l(),i=s(),{toast:m}=d(),y=a(),[b]=n(),x=o(),[S,C]=(0,g.useState)(!1),[w,T]=(0,g.useState)(`overview`),E=p(b,{enabled:x.running,background:!0,live:S}),D=f(),O=(0,g.useRef)(null);(0,g.useLayoutEffect)(()=>{let e=document.documentElement;e.dataset.view=`tray`,e.style.background=`transparent`,document.body.style.background=`transparent`},[]);let k=(0,g.useCallback)(()=>{i.invalidateQueries({queryKey:[`stats`]}),i.invalidateQueries({queryKey:t.providers}),i.invalidateQueries({queryKey:t.clients}),i.invalidateQueries({queryKey:[`provider-accounts`]})},[i]);(0,g.useEffect)(()=>y?.tray.onVisibilityChanged(e=>{C(e),e&&(T(`overview`),k())}),[y,k]),(0,g.useEffect)(()=>{x.running&&k()},[x.running,k]),(0,g.useEffect)(()=>{let e=e=>{e.key&&v.has(e.key)&&window.location.reload()};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&y?.tray.command(`hide`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y]),(0,g.useLayoutEffect)(()=>{let e=O.current;if(!e||!y)return;let t=[`header`,`tabs`,`body`,`footer`].map(t=>e.querySelector(`[data-tray-part="${t}"]`)),n=()=>{let n=e.offsetHeight-e.clientHeight,r=t.reduce((e,t)=>e+(t?.offsetHeight??0),0)+n;y.tray.resize(r)},r=new ResizeObserver(n);for(let e of t)e&&r.observe(e);return n(),()=>r.disconnect()},[y]),e(b,x,E.summary,E.plans);let A=e=>void y?.tray.command(e),j=async()=>{E.settings&&await c.copy(`${E.settings.gatewayBaseUrl}/v1`)&&m(r(`common.copied`))},M=async e=>{let t=E.providers;if(t.length===0)return;let n=await c.contextMenu(t.map(t=>({id:t.id,label:t.enabled?t.name:r(`tray.disabledProvider`,{name:t.name}),type:`checkbox`,checked:t.id===e.providerId})));n&&n!==e.providerId&&D.mutate({kind:e.kind,providerId:n},{onError:e=>m(u(e),`error`)})};return(0,_.jsx)(`div`,{className:`h-full`,children:(0,_.jsx)(h,{ref:O,className:`h-full`,prefs:b,state:x,data:E,tab:w,onTabChange:T,onCommand:A,onRefresh:k,onCopyAddress:()=>void j(),onSwitchClient:e=>void M(e)})})}export{y as TrayPanelPage};
1
+ import{Ct as e,Dn as t,Dt as n,Fa as r,Ia as i,Ji as a,Ot as o,Pa as s,Sn as c,Tn as l,a as u,o as d,pi as f,wt as p,za as m}from"./overlays-D1ZtG8Qn.js";import{t as h}from"./TrayPanelView-BcmaqvCD.js";var g=m(i(),1),_=r(),v=new Set([`astra.theme`,`astra.accent`,`astra.locale`]);function y(){let{t:r}=l(),i=s(),{toast:m}=d(),y=a(),[b]=n(),x=o(),[S,C]=(0,g.useState)(!1),[w,T]=(0,g.useState)(`overview`),E=p(b,{enabled:x.running,background:!0,live:S}),D=f(),O=(0,g.useRef)(null);(0,g.useLayoutEffect)(()=>{let e=document.documentElement;e.dataset.view=`tray`,e.style.background=`transparent`,document.body.style.background=`transparent`},[]);let k=(0,g.useCallback)(()=>{i.invalidateQueries({queryKey:[`stats`]}),i.invalidateQueries({queryKey:t.providers}),i.invalidateQueries({queryKey:t.clients}),i.invalidateQueries({queryKey:[`provider-accounts`]})},[i]);(0,g.useEffect)(()=>y?.tray.onVisibilityChanged(e=>{C(e),e&&(T(`overview`),k())}),[y,k]),(0,g.useEffect)(()=>{x.running&&k()},[x.running,k]),(0,g.useEffect)(()=>{let e=e=>{e.key&&v.has(e.key)&&window.location.reload()};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&y?.tray.command(`hide`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y]),(0,g.useLayoutEffect)(()=>{let e=O.current;if(!e||!y)return;let t=[`header`,`tabs`,`body`,`footer`].map(t=>e.querySelector(`[data-tray-part="${t}"]`)),n=()=>{let n=e.offsetHeight-e.clientHeight,r=t.reduce((e,t)=>e+(t?.offsetHeight??0),0)+n;y.tray.resize(r)},r=new ResizeObserver(n);for(let e of t)e&&r.observe(e);return n(),()=>r.disconnect()},[y]),e(b,x,E.summary,E.plans);let A=e=>void y?.tray.command(e),j=async()=>{E.settings&&await c.copy(`${E.settings.gatewayBaseUrl}/v1`)&&m(r(`common.copied`))},M=async e=>{let t=E.providers;if(t.length===0)return;let n=await c.contextMenu(t.map(t=>({id:t.id,label:t.enabled?t.name:r(`tray.disabledProvider`,{name:t.name}),type:`checkbox`,checked:t.id===e.providerId})));n&&n!==e.providerId&&D.mutate({kind:e.kind,providerId:n},{onError:e=>m(u(e),`error`)})};return(0,_.jsx)(`div`,{className:`h-full`,children:(0,_.jsx)(h,{ref:O,className:`h-full`,prefs:b,state:x,data:E,tab:w,onTabChange:T,onCommand:A,onRefresh:k,onCopyAddress:()=>void j(),onSwitchClient:e=>void M(e)})})}export{y as TrayPanelPage};