@aidotnet/server-darwin-arm64 0.9.7 → 0.9.8

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 (40) hide show
  1. package/bin/astra-server +2 -2
  2. package/bin/wwwroot/assets/{ClientsPage-DEetiYfc.js → ClientsPage-CMvzWWAq.js} +2 -2
  3. package/bin/wwwroot/assets/{KeyPage-cq7HprCR.js → KeyPage-C8QfP545.js} +1 -1
  4. package/bin/wwwroot/assets/{ModelDetailPage-Uj6p-r8V.js → ModelDetailPage-Dj3Fuga6.js} +1 -1
  5. package/bin/wwwroot/assets/{ModelsPage-B-l5oEGF.js → ModelsPage-DIYCYGb2.js} +1 -1
  6. package/bin/wwwroot/assets/{PluginsPage-BH9KjyfC.js → PluginsPage-B2nac94b.js} +1 -1
  7. package/bin/wwwroot/assets/{PrivacyPage-C5XhVKZd.js → PrivacyPage-CeRqlQGU.js} +1 -1
  8. package/bin/wwwroot/assets/{ProviderDetailPage-uLPHWm2i.js → ProviderDetailPage-DWy8CIbx.js} +1 -1
  9. package/bin/wwwroot/assets/{ProvidersPage-CNU_ji4e.js → ProvidersPage-CeisTEUC.js} +1 -1
  10. package/bin/wwwroot/assets/{SettingsPage-B3tbYdLW.js → SettingsPage-Bcv3aAmF.js} +2 -2
  11. package/bin/wwwroot/assets/{TokenDetailPage-BVyb_-ev.js → TokenDetailPage-B9WJQ1HP.js} +1 -1
  12. package/bin/wwwroot/assets/{TokenPoolEditor-7LX143SO.js → TokenPoolEditor-D8mQHyNt.js} +1 -1
  13. package/bin/wwwroot/assets/TokensPage-Cx1hPs0r.js +1 -0
  14. package/bin/wwwroot/assets/{TracesPage-C9mYB_7E.js → TracesPage-Ckw0m9u0.js} +1 -1
  15. package/bin/wwwroot/assets/{TrayPanelPage-NIkRrLCt.js → TrayPanelPage-BfD_xXkg.js} +1 -1
  16. package/bin/wwwroot/assets/{TrayPanelView-BpQQa0qi.js → TrayPanelView-daUwEIRH.js} +1 -1
  17. package/bin/wwwroot/assets/{alert-CN1yWco4.js → alert-BzjF81CS.js} +3 -3
  18. package/bin/wwwroot/assets/{arrow-down-DP0xP3tk.js → arrow-down-BjT6LDhw.js} +1 -1
  19. package/bin/wwwroot/assets/{arrow-left-UUQiUGQ1.js → arrow-left-Bv8IR_At.js} +1 -1
  20. package/bin/wwwroot/assets/{checkbox-BEWRhO5r.js → checkbox-DQpzihMp.js} +1 -1
  21. package/bin/wwwroot/assets/{cloud-download-DebyBXx2.js → cloud-download-B7vzhwxM.js} +1 -1
  22. package/bin/wwwroot/assets/{confirm-morph-DwiVsert.js → confirm-morph-BOdW6fKN.js} +1 -1
  23. package/bin/wwwroot/assets/{download-C4--ZCHf.js → download-CI3oqkmw.js} +1 -1
  24. package/bin/wwwroot/assets/{ellipsis-D250KISp.js → ellipsis-Br3iFNj9.js} +1 -1
  25. package/bin/wwwroot/assets/{external-link-Bnshhxip.js → external-link-LUcufY2s.js} +1 -1
  26. package/bin/wwwroot/assets/{folder-open-BzVuhS53.js → folder-open-rO9o554n.js} +1 -1
  27. package/bin/wwwroot/assets/{index-CBrXkG99.js → index-D7HIE1TG.js} +3 -3
  28. package/bin/wwwroot/assets/{log-out-DEZofPIg.js → log-out-Ggrqw-Tp.js} +1 -1
  29. package/bin/wwwroot/assets/minus-2zK3DUtq.js +1 -0
  30. package/bin/wwwroot/assets/overlays-8ByMRpma.js +41 -0
  31. package/bin/wwwroot/assets/{pencil-DuD1bQje.js → pencil-o6T1_skE.js} +1 -1
  32. package/bin/wwwroot/assets/{power-LE8gLJKc.js → power-BJvJ4uzr.js} +1 -1
  33. package/bin/wwwroot/assets/{radio-cards-D1yOuSfh.js → radio-cards-CWiI0xhT.js} +1 -1
  34. package/bin/wwwroot/assets/{rotate-ccw-Cx9vNOkF.js → rotate-ccw-CqwU1cME.js} +1 -1
  35. package/bin/wwwroot/assets/{sortable.esm-B0eMzUNN.js → sortable.esm-BhxNcP2n.js} +1 -1
  36. package/bin/wwwroot/index.html +3 -3
  37. package/package.json +1 -1
  38. package/bin/wwwroot/assets/TokensPage-vRrXvqkK.js +0 -1
  39. package/bin/wwwroot/assets/minus-BAoIEc33.js +0 -1
  40. package/bin/wwwroot/assets/overlays-D2pWmtov.js +0 -41
@@ -1,2 +1,2 @@
1
- import{Ai as e,Br as t,Ca as n,E as r,Ea as i,Et as a,Hr as o,J as s,Mi as c,Ni as l,Pi as u,Sa as d,Ta as f,W as p,Z as m,Zt as h,_ as g,b as _,bn as v,c as y,ct as b,d as x,er as S,f as C,gi as w,gt as T,h as E,i as D,it as O,ji as k,ki as A,l as j,m as M,n as N,nr as P,ot as F,p as I,pn as L,qn as R,r as z,ri as B,rr as V,s as H,t as U,u as W,v as G,vt as ee,w as te,xa as ne,xn as K,xr as re,y as ie,zr as ae}from"./alert-CN1yWco4.js";import{A as oe,C as se,D as ce,E as le,O as ue,T as de,X as fe,a as q,ct as pe,dt as me,ft as he,i as ge,k as _e,mt as ve,o as ye,pt as be,r as xe,ut as Se,w as Ce}from"./overlays-D2pWmtov.js";import{t as we}from"./arrow-left-UUQiUGQ1.js";import{t as Te}from"./download-C4--ZCHf.js";import{n as Ee,t as De}from"./radio-cards-D1yOuSfh.js";import{$ as Oe,F as ke,J as Ae,L as je,R as Me,S as Ne,Z as Pe,_ as Fe,b as Ie,et as Le,g as Re,h as ze,j as Be,k as Ve,tt as He,x as Ue}from"./index-CBrXkG99.js";import{t as We}from"./checkbox-BEWRhO5r.js";var J=i(n(),1);function Ge(e,t,n){(0,J.useInsertionEffect)(()=>e.on(t,n),[e,t,n])}var Ke={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`]};Ke.node;var qe=ee(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=ee(Je),Xe={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Xe.node;var Ze=ee(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=d(),{blur:Qe,duration:Z,ease:$e,spring:et,stagger:tt}=r,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)(u,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(A.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)(A.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:t,media:n,action:r,avatar:i,meta:a,status:o,details:s,open:c,defaultOpen:d=!1,onOpenChange:f,children:p,className:m,style:h,...g}){let _=k()??!1,v=(0,J.useId)(),y=(0,J.useRef)(null),x=(0,J.useRef)(null),[S,C]=(0,J.useState)(d),[w,T]=(0,J.useState)(!1),[E,D]=(0,J.useState)({}),[O,j]=(0,J.useState)(null),M=s?c??S:!1,N=!!s&&!_,P=!M&&O!==null,F=!!t,I=(0,J.useCallback)(e=>{c===void 0&&C(e),f?.(e)},[c,f]);(0,J.useEffect)(()=>{let e=y.current,t=x.current;if(!N||!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;D(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()},[N,F]);let L=(0,J.useRef)(M);(0,J.useLayoutEffect)(()=>{let e=L.current&&!M;L.current=M;let t=y.current;if(M)j(null);else if(e&&N&&t){let e=t.getBoundingClientRect();j({top:e.top,left:e.left,width:e.width,height:e.height})}},[M,N]),(0,J.useEffect)(()=>{if(!P)return;let e=window.setTimeout(()=>j(null),it);return()=>window.clearTimeout(e)},[P]);let R=(e,t,n=!0)=>N?{layoutId:e,layout:n,layoutCrossfade:!1,layoutDependency:t===`card`?M:P?`return`:`panel`,transition:{layout:t===`card`?rt:nt}}:{},z=e=>i||a||o||r?(0,X.jsxs)(`div`,{className:Y.footer,children:[i||a||o?(0,X.jsxs)(A.div,{className:Y.byline,...R(`byline`,e,`position`),children:[i?(0,X.jsx)(`span`,{className:Y.avatar,children:i}):null,(0,X.jsxs)(`span`,{className:Y.bylineText,children:[a?(0,X.jsx)(`span`,{className:Y.meta,children:a}):null,o?(0,X.jsx)(pt,{text:o,reduced:_}):null]})]}):null,r?(0,X.jsx)(A.div,{className:Y.action,...R(`action`,e,`position`),children:r}):null]}):null,B=(0,X.jsxs)(A.article,{...g,ref:y,className:[Y.card,m].filter(Boolean).join(` `),style:{...h,borderRadius:E.card??h?.borderRadius},"data-hover":w||void 0,whileHover:_?void 0:{y:-2},onHoverStart:()=>T(!0),onHoverEnd:()=>T(!1),...R(`card`,`card`),transition:{default:et.snappy,layout:rt},children:[n?(0,X.jsx)(A.div,{className:Y.media,...R(`media`,`card`),children:(0,X.jsx)(A.div,{className:Y.zoom,initial:!1,animate:{scale:w&&!_?ot:1},transition:w?st:ct,children:n})}):null,(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(A.h3,{className:Y.title,...R(`title`,`card`),children:s?(0,X.jsx)(oe,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:Y.trigger,children:e})}):e}),t?(0,X.jsx)(A.p,{ref:x,className:Y.description,...R(`description`,`card`,`position`),children:t}):null,p,z(`card`)]})]});return s?(0,X.jsx)(se,{open:M,onOpenChange:I,children:(0,X.jsxs)(l,{id:v,children:[B,(0,X.jsx)(u,{children:(M||P)&&(0,X.jsxs)(ue,{forceMount:!0,children:[(0,X.jsx)(u,{children:M&&(0,X.jsx)(ce,{asChild:!0,forceMount:!0,children:(0,X.jsx)(A.div,{className:Y.overlay,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:_?at:{duration:Z.exit,ease:[...$e.standard]}},transition:_?at:{duration:Z.standard,ease:[...$e.enter]}})},`overlay`)}),(0,X.jsx)(de,{asChild:!0,forceMount:!0,...t?{}:{"aria-describedby":void 0},children:(0,X.jsxs)(A.div,{className:Y.panel,"data-framer-portal-id":v,"data-returning":P||void 0,layoutScroll:!0,style:{borderRadius:E.panel,"--card-measure":E.measure?`${E.measure}px`:void 0,...O&&P?{"--landing-top":`${O.top}px`,"--landing-left":`${O.left}px`,"--landing-width":`${O.width}px`,"--landing-height":`${O.height}px`}:{}},...N?{...R(`card`,`panel`),initial:!1,animate:E.card!==void 0&&E.panel!==void 0?{borderRadius:P?E.card:E.panel}:void 0,transition:{layout:P?rt:nt,borderRadius:P?rt:nt},exit:{opacity:0,transition:{duration:0}}}:{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:at},transition:at},children:[n?(0,X.jsx)(A.div,{className:Y.media,...R(`media`,`panel`),children:(0,X.jsx)(A.div,{className:Y.zoom,initial:{scale:w&&!_?ot:1},animate:{scale:1},transition:nt,children:n})}):null,(0,X.jsx)(A.span,{className:Y.closeSlot,initial:_?{opacity:0}:{opacity:0,scale:.9},animate:P?{opacity:0,scale:.9}:{opacity:1,scale:1},transition:P||_?at:ut,children:(0,X.jsx)(Ce,{asChild:!0,children:(0,X.jsx)(A.button,{type:`button`,className:Y.close,"aria-label":`Close quick look`,whileTap:_?void 0:{scale:.94},transition:et.snappy,children:(0,X.jsx)(b,{width:16,height:16,strokeWidth:1.75,"aria-hidden":`true`})})})}),(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(_e,{asChild:!0,children:(0,X.jsx)(A.h2,{className:Y.title,...R(`title`,`panel`),children:e})}),t?(0,X.jsx)(le,{asChild:!0,children:(0,X.jsx)(A.p,{className:Y.description,...R(`description`,`panel`,`position`),children:t})}):null,p,z(`panel`),(0,X.jsx)(A.div,{className:Y.details,initial:!_&&{opacity:0,y:6},animate:P?{opacity:0,y:0}:{opacity:1,y:0},exit:{opacity:0,transition:at},transition:P||_?at:lt,children:s})]})]})})]},`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(${r.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:r.duration.standard,ease:[...r.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${r.blur.subtle}px)`,transition:{duration:r.duration.fast,ease:[...r.ease.standard]}})},_t={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:r.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:r.duration.instant}}},vt=e=>Number(e.replace(/,/g,``).replace(/−/g,`-`).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN),yt=new Intl.NumberFormat(`en-US`),bt={duration:r.duration.considered*1.75,ease:[...r.ease.inOut]},xt={duration:r.duration.fast,ease:[...r.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:t,direction:n,whole:i=!1,morph:a=!1,tone:o}){let s=!!k(),l=(0,J.useRef)(null),d=c(`auto`),[f,p]=(0,J.useState)({text:t,direction:1});f.text!==t&&p({text:t,direction:n??(vt(t)<vt(f.text)?-1:1)}),(0,J.useEffect)(()=>{let t=l.current;if(!t||typeof ResizeObserver>`u`)return;let n=null,i=new ResizeObserver(([i])=>{if(!i)return;let a=i.borderBoxSize?.[0]?.inlineSize??t.offsetWidth;n!==null&&n!==t.textContent&&!s?e(d,a,r.spring.morph):d.jump(a),n=t.textContent});return i.observe(t),()=>i.disconnect()},[a,s,d]);let m=!i&&!/\p{L}/u.test(t),h=s?_t:gt,g=m?`right`:`left`;return(0,X.jsxs)(A.span,{className:Q.roll,"data-end":m||void 0,"data-whole":i||void 0,style:a?{width:d}:void 0,children:[a&&(0,X.jsx)(`span`,{ref:l,className:Q.sizer,"aria-hidden":`true`,children:t}),(0,X.jsx)(`span`,{className:Q.track,children:(0,X.jsx)(u,{mode:`popLayout`,initial:!1,custom:f.direction,anchorX:g,children:St(t,i).map(e=>(0,X.jsx)(A.span,{className:Q.slot,custom:f.direction,variants:h,initial:`hidden`,animate:`shown`,exit:`gone`,children:(0,X.jsx)(u,{mode:`popLayout`,initial:!1,custom:f.direction,anchorX:g,children:(0,X.jsx)(A.span,{className:o?`${Q.glyph} ${o}`:Q.glyph,custom:f.direction,variants:h,initial:`hidden`,animate:`shown`,exit:`gone`,children:e.text},`${o??``}${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:t,label:n,value:i,change:a,tone:o=`accent`,width:s=160,height:l=52,labels:u,formatValue:d,area:f=!0,interactive:p=!0}){let m=t.length>1?t:[t[0]??0,t[0]??0],h=m.length-1,g=m.join(`,`),_=(0,J.useMemo)(()=>Dt(g.split(`,`).map(Number)),[g]),v=`${n}: ${i??m[h]}. ${a??``}`.trim(),y=`sparkline${(0,J.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,b=(0,J.useRef)(null),x=(0,J.useRef)(null),S=Le(b,{once:!0,amount:.5}),C=!!k(),[w,T]=(0,J.useState)({w:s,h:l}),[E,D]=(0,J.useState)(null),[O,j]=(0,J.useState)(!1),M=E===null?null:Math.min(E,h),[N,P]=(0,J.useState)({index:M,direction:1});N.index!==M&&P({index:M,direction:M===null||N.index===null?1:Math.sign(M-N.index)||1});let[F]=(0,J.useState)(()=>kt(_,s,l,1)),I=(0,J.useRef)(_),L=(0,J.useRef)(w),R=c(0),z=c(1),B=c(F.line),V=c(F.trail),H=c(F.fill),U=c(F.dot),W=c(F.cx),G=c(F.cx+Tt+16),ee=c(F.cx+Tt),te=c(0),ne=He(R,e=>+(e>.001)),K=(0,J.useCallback)(()=>{let{w:e,h:t}=L.current,n=R.get(),r=kt(I.current,e,t,z.get());B.set(r.line),V.set(r.trail),H.set(r.fill),U.set(r.dot),W.set(r.cx),G.set(r.cx+Tt+16),ee.set(r.cx+Tt),te.set(n>=1?e+32:At(r.points,n)+16)},[z,W,ee,U,R,H,B,G,te,V]);Ge(z,`change`,K),Ge(R,`change`,K),(0,J.useLayoutEffect)(()=>{let e=x.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=e.clientWidth;t&&T(e=>Math.abs(e.w-t)<.5?e:{w:t,h:t*l/s})});return t.observe(e),()=>t.disconnect()},[l,s]),(0,J.useLayoutEffect)(()=>{L.current=w,K()},[w,K]),(0,J.useEffect)(()=>{if(C){R.jump(1);let e=requestAnimationFrame(()=>j(!0));return()=>cancelAnimationFrame(e)}if(!S)return;let t=e(R,1,{...bt,onComplete:()=>j(!0)});return()=>t.stop()},[R,S,C]),(0,J.useEffect)(()=>{let t=I.current;if(t===_)return;if(C){I.current=_,K();return}let n=[...new Set([...Et,..._.map(([e])=>e)])].sort((e,t)=>e-t),i=n.map(e=>Ot(t,e)),a=n.map(e=>Ot(_,e)),o=e(0,1,{...r.spring.smooth,onUpdate:e=>{I.current=n.map((t,n)=>[t,i[n]+(a[n]-i[n])*e]),K()},onComplete:()=>{I.current=_,K()}});return()=>o.stop()},[K,C,_]),(0,J.useEffect)(()=>{let t=M===null?1:M/h;if(C){z.jump(t);return}let n=e(z,t,r.spring.snappy);return()=>n.stop()},[z,M,h,C]);let re=M!==null,ie=(e=>d?d(m[e],e):yt.format(m[e]))(M??h),ae=u?.[M??h],oe=i===void 0?void 0:re?ie:i,se=M===null?a??``:i===void 0?[ie,ae].filter(Boolean).join(` · `):ae??`${M+1} of ${h+1}`,ce=e=>{let t=x.current?.getBoundingClientRect();return t?.width?Math.max(0,Math.min(h,Math.round((e-t.left)/t.width*h))):h},le=p?{role:`slider`,tabIndex:0,"aria-label":`${n}, explore values`,"aria-valuemin":1,"aria-valuemax":h+1,"aria-valuenow":(M??h)+1,"aria-valuetext":`${ae??(M===null?`Latest`:`Point ${M+1} of ${h+1}`)}: ${ie}`,onPointerDown:e=>D(ce(e.clientX)),onPointerMove:e=>{(e.pointerType===`mouse`||e.buttons)&&D(ce(e.clientX))},onPointerUp:e=>{e.pointerType!==`mouse`&&D(null)},onPointerLeave:()=>D(null),onPointerCancel:()=>D(null),onBlur:()=>D(null),onKeyDown:e=>{if(e.key===`Escape`&&re){e.preventDefault(),D(null);return}let t=M??h,n=Math.max(1,Math.round((h+1)/6)),r={ArrowLeft:t-1,ArrowDown:t-1,ArrowRight:t+1,ArrowUp:t+1,PageDown:t-n,PageUp:t+n,Home:0,End:h}[e.key];r!==void 0&&(e.preventDefault(),D(Math.max(0,Math.min(h,r))))}}:{};return(0,X.jsxs)(`figure`,{ref:b,className:Q.figure,"aria-label":v,children:[(0,X.jsxs)(`figcaption`,{className:Q.caption,children:[(0,X.jsx)(`span`,{className:Q.label,children:(0,X.jsx)(Ct,{text:n,whole:!0})}),oe!==void 0&&(0,X.jsx)(`strong`,{children:(0,X.jsx)(Ct,{text:oe,morph:!0})}),(0,X.jsx)(`small`,{className:Q[o],children:(0,X.jsx)(Ct,{text:se,direction:re?N.direction:void 0,tone:re?Q.point:void 0,morph:!0})})]}),(0,X.jsx)(`div`,{ref:x,className:Q.plot,"data-interactive":p||void 0,...le,children:(0,X.jsxs)(`svg`,{className:Q.chart,viewBox:`0 0 ${w.w} ${w.h}`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(`clipPath`,{id:`${y}-lit`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(A.rect,{x:-16,y:-16,width:G,height:w.h+32})}),(0,X.jsx)(`clipPath`,{id:`${y}-dim`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(A.rect,{x:ee,y:-16,width:w.w+32,height:w.h+32})}),(0,X.jsx)(`clipPath`,{id:`${y}-fill`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(A.rect,{x:-16,y:-16,width:te,height:w.h+32})})]}),f&&(0,X.jsx)(A.path,{className:`${Q.area} ${Q[o]}`,d:H,clipPath:`url(#${y}-fill)`}),(0,X.jsx)(`line`,{className:Q.baseline,x1:`0`,y1:w.h-.5,x2:w.w,y2:w.h-.5}),(0,X.jsx)(A.path,{className:Q.trail,d:V,clipPath:`url(#${y}-dim)`,initial:!1,animate:{opacity:re&&O?1:0},transition:C?{duration:0}:xt}),(0,X.jsx)(A.polyline,{className:[Q.line,Q[o]].join(` `),points:B,clipPath:`url(#${y}-lit)`,style:{pathLength:R,opacity:ne}}),(0,X.jsx)(A.line,{className:Q.cursor,x1:W,x2:W,y1:0,y2:w.h,initial:!1,animate:{opacity:+!!re},transition:C?{duration:0}:xt}),(0,X.jsx)(A.polyline,{className:[Q.end,Q[o]].join(` `),points:U,initial:!1,animate:{opacity:+!!O,strokeWidth:O?re?10:7:0},transition:C?{duration:0}:{opacity:xt,strokeWidth:r.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:r.duration.fast,ease:[...r.ease.standard]},Ft={duration:r.duration.standard,ease:[...r.ease.enter]},It={opacity:0,y:`0.3em`,filter:Mt(r.blur.soft)},Lt={opacity:1,y:0,filter:Mt(0)},Rt={opacity:0,y:`-0.3em`,filter:Mt(r.blur.subtle)},zt={opacity:0,scale:.5,filter:Mt(r.blur.subtle)},Bt={opacity:1,scale:1,filter:Mt(0)};function Vt({text:t,className:n,reduced:i}){let a=(0,J.useRef)(null),o=(0,J.useRef)(0),s=c(`auto`);return(0,J.useLayoutEffect)(()=>{o.current=performance.now()+700},[t]),(0,J.useEffect)(()=>{let t=a.current,n=t?.parentElement;if(!t||!n||typeof ResizeObserver>`u`)return;let c=!1,l=new ResizeObserver(()=>{let n=t.offsetHeight;if(!c||i||performance.now()>o.current){c=!0,s.jump(n);return}e(s,n,r.spring.smooth)});return l.observe(t),()=>l.disconnect()},[s,i]),(0,X.jsx)(A.span,{className:$.slot,style:{height:s},children:(0,X.jsx)(`span`,{ref:a,className:$.slotInner,children:(0,X.jsx)(u,{mode:`popLayout`,initial:!1,children:t?(0,X.jsx)(A.span,{className:n,initial:It,animate:Lt,exit:{...Rt,transition:i?Nt:Pt},transition:i?Nt:Ft,children:t},`${n}:${t}`):null})})})}function Ht({kind:e,number:t,delay:n,reduced:i}){let a=i?Nt:{scale:{...r.spring.snappy,delay:n},opacity:{duration:r.duration.fast,delay:n},filter:{duration:r.duration.fast,delay:n}},o={...zt,transition:i?Nt:Pt},s=i?Nt:{duration:r.duration.standard,ease:r.ease.enter,delay:n+.04};return e===`number`?(0,X.jsx)(A.span,{className:$.glyph,initial:zt,animate:Bt,exit:o,transition:a,children:t}):(0,X.jsx)(A.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:o,transition:a,children:e===`check`?(0,X.jsx)(A.path,{d:`M5.5 12.5l4.25 4.25L18.5 8`,initial:{pathLength:0},animate:{pathLength:1},transition:s}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A.path,{d:`M12 6.75v6.5`,initial:{pathLength:0},animate:{pathLength:1},transition:s}),(0,X.jsx)(A.circle,{cx:12,cy:17.4,r:1.4,fill:`currentColor`,stroke:`none`,initial:{scale:0},animate:{scale:1},transition:i?Nt:{...r.spring.snappy,delay:n+.16}})]})})}function Ut({number:e,kind:t,current:n,glyphDelay:i,ringDelay:a,reduced:o}){return(0,X.jsxs)(`span`,{className:$.marker,"aria-hidden":`true`,children:[(0,X.jsx)(u,{initial:!1,children:n?(0,X.jsx)(A.span,{className:$.ring,initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:o?Nt:Pt},transition:o?Nt:{scale:{...r.spring.snappy,delay:a},opacity:{duration:r.duration.fast,delay:a}}},`ring`):null}),(0,X.jsx)(`span`,{className:$.disc,children:(0,X.jsx)(u,{initial:!1,children:(0,X.jsx)(Ht,{kind:t,number:e,delay:i,reduced:o},t)})})]})}var Wt={complete:`Completed`,current:``,upcoming:`Not started`,error:`Error`};function Gt({steps:e,current:t,orientation:n=`horizontal`,onStepSelect:i,details:a=`all`,compact:o=!1,label:s=`Progress`,completeLabel:c=`All steps complete`,className:l}){let u=k()??!1,d=e.length,f=Math.min(Math.max(Math.round(t),0),d),[p,m]=(0,J.useState)({to:f,from:f});p.to!==f&&m({to:f,from:p.to});let h=p.from,g=r.stagger.line,_=e=>u?0:f>h?e>=h&&e<f?(e-h)*g:0:e>=f&&e<h?(h-1-e)*g:0,v=u?0:Math.max(0,Math.abs(f-h)-1)*g+.12,y=!!i,b=n===`vertical`,x=f>=d?void 0:e[f];function S(e){let t=!b&&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 C=y?`nav`:`div`,w=[$.root,b?$.vertical:$.horizontal,o?$.compact:``,l].filter(Boolean).join(` `);return(0,X.jsxs)(C,{className:w,"aria-label":s,role:y?void 0:`group`,children:[(0,X.jsx)(`ol`,{className:$.list,style:b?void 0:{gridTemplateColumns:d>1?`repeat(${d-1}, minmax(0, 1fr)) auto`:`auto`},onKeyDown:y?S:void 0,children:e.map((e,t)=>{let o=t===f,s=e.error?`error`:t<f?`complete`:o?`current`:`upcoming`,c=y&&t<f,l=e.error??(a===`all`||o?e.description:void 0),p=e.error?`error`:t<f?`check`:`number`,m=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ut,{number:t+1,kind:p,current:o,glyphDelay:_(t),ringDelay:v,reduced:u}),(0,X.jsxs)(`span`,{className:$.text,children:[(0,X.jsx)(`span`,{className:$.label,children:e.label}),Wt[s]?(0,X.jsxs)(`span`,{className:$.srOnly,children:[`, `,Wt[s]]}):null,(0,X.jsx)(Vt,{text:l,className:e.error?$.error:$.description,reduced:u})]})]});return(0,X.jsxs)(`li`,{className:$.item,"data-status":s,children:[t<d-1?(0,X.jsx)(`span`,{className:$.connector,"aria-hidden":`true`,children:(0,X.jsx)(A.span,{className:$.fill,initial:!1,animate:b?{scaleY:+(t<f)}:{scaleX:+(t<f)},transition:u?Nt:{...r.spring.smooth,delay:_(t)}},n)}):null,y?(0,X.jsx)(`button`,{type:`button`,className:$.head,"data-clickable":c||void 0,"data-reachable":t<=f||void 0,"aria-current":o?`step`:void 0,"aria-disabled":!c||void 0,tabIndex:c?void 0:-1,onClick:c?()=>i?.(t):void 0,children:m}):(0,X.jsx)(`span`,{className:$.head,"aria-current":o?`step`:void 0,children:m})]},e.id)})}),b?null:(0,X.jsxs)(`span`,{className:$.caption,"aria-hidden":`true`,children:[(0,X.jsx)(Vt,{text:x?.label??c,className:$.captionLabel,reduced:u}),(0,X.jsx)(Vt,{text:x?.error??x?.description,className:x?.error?$.error:$.description,reduced:u})]}),(0,X.jsx)(`span`,{className:$.srOnly,"aria-live":`polite`,children:x?`Step ${f+1} of ${d}: ${x.label}`:c})]})}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}=F(),{toast:r}=ye(),i=K(e),a=v(),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(new Set),[u,d]=(0,J.useState)(null);(0,J.useEffect)(()=>{i.data&&l(new Set(i.data.flatMap(e=>e.items).filter(e=>e.status===`new`).map(Jt)))},[i.data]),(0,J.useEffect)(()=>{e&&(s(``),d(null))},[e]);let f=o.trim().toLowerCase(),p=e=>!f||e.name.toLowerCase().includes(f)||e.endpoints.some(e=>e.baseUrl.toLowerCase().includes(f)),m=(0,J.useMemo)(()=>(i.data??[]).flatMap(e=>e.items).filter(e=>c.has(Jt(e))&&Yt(e)),[i.data,c]),h=(e,t)=>l(n=>{let r=new Set(n);return t?r.add(Jt(e)):r.delete(Jt(e)),r});return(0,X.jsx)(ge,{open:e,onOpenChange:t,width:680,title:n(`import.title`),description:n(`import.detail`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{icon:(0,X.jsx)(je,{className:`size-3.5`}),onClick:()=>void i.refetch(),disabled:i.isFetching||a.isPending,children:n(`import.rescan`)}),(0,X.jsx)(z,{variant:`primary`,disabled:m.length===0||a.isPending,onClick:()=>{d(null),a.mutate(m.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=>{d(q(e)),i.refetch()}})},children:n(`import.selected`,{count:m.length})})]}),children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(E,{value:o,onChange:s,placeholder:n(`import.search`)}),u&&(0,X.jsx)(U,{tone:`danger`,title:n(`common.error`),children:u}),i.isLoading&&(0,X.jsx)(G,{lines:3}),i.isError&&(0,X.jsx)(U,{tone:`danger`,title:n(`common.error`),children:q(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:p,selected:c,onToggle:h,filtering:f.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}=F(),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)(U,{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}=F(),i=Yt(e),a=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,o=e.endpoints.map(e=>`${Kt[e.protocol]??e.protocol} · ${Xt(e.baseUrl)}`).join(` / `);return(0,X.jsxs)(`li`,{className:O(`flex items-start gap-3 px-4 py-3`,!i&&`opacity-60`),children:[(0,X.jsx)(We,{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)(N,{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})]}),o&&(0,X.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-[var(--text-muted)]`,title:o,children:o}),(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})})]}),a&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--text-secondary,var(--text-muted))]`,children:a}),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:n}=F(),{toast:r}=ye(),i=V(),a=re(e.id),o=t(e.id),s=L(),c=e.quotaConfig,l=(0,J.useMemo)(()=>sn(c),[c]),[u,d]=(0,J.useState)(l),[f,p]=(0,J.useState)(null);(0,J.useEffect)(()=>d(l),[l]);let m=i.data??[],h=m.find(e=>e.id===c.suggestedTemplate),g=u.template===en?h:m.find(e=>e.id===u.template),v=u.template===tn,y=v?nn:g?.params??[],b=e=>d(t=>({...t,...e})),S=JSON.stringify(u)!==JSON.stringify(l),w=e=>{if(e!==tn||u.url)return b({template:e});let t=g??h;b({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)})},T=()=>{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(v){let t=cn(u.headers),i=cn(u.extract);if(!t||!i)return r(n(`providers.quota.invalidJson`,{field:n(t?`providers.quota.extract`:`providers.quota.headers`)}),`error`),null;e.request={method:u.method,url:u.url.trim(),auth:u.auth,headers:t},e.extract=i}return e},E=()=>{let t=T();if(!t)return;let i=t.enabled&&!c.enabled;a.mutate(t,{onSuccess:()=>{r(n(`common.saved`),`success`),i&&s.mutate(e.id,{onError:e=>r(q(e),`error`)})},onError:e=>r(q(e),`error`)})},O=()=>{let e=T();e&&o.mutate(e,{onSuccess:p,onError:e=>r(q(e),`error`)})},k=c.effectiveIntervalMinutes>0?n(`providers.quota.intervalEvery`,{minutes:c.effectiveIntervalMinutes}):n(`providers.quota.intervalOff`),A=[{value:en,label:h?n(`providers.quota.templateAuto`,{name:h.name}):n(`providers.quota.templateNone`)},...m.map(e=>({value:e.id,label:e.name,detail:n(`providers.quota.kind.${e.kind}`)})),{value:tn,label:n(`providers.quota.custom`)}];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(W,{title:n(`providers.quota.title`),footer:n(`providers.quota.footer`),children:[(0,X.jsx)(M,{label:n(`providers.quota.enable`),detail:n(`providers.quota.enableHint`),children:(0,X.jsx)(ie,{checked:u.enabled,label:n(`providers.quota.enable`),onChange:e=>b({enabled:e})})}),(0,X.jsx)(M,{label:n(`providers.quota.template`),children:(0,X.jsx)(xe,{className:`w-64`,ariaLabel:n(`providers.quota.template`),value:u.template,onChange:w,options:A})}),y.map(e=>{let t=n(`providers.quota.param.${e.name}`),r=c.secrets.includes(e.name);return e.secret?(0,X.jsx)(M,{label:t,detail:r?n(`providers.quota.secretStored`):void 0,children:(0,X.jsx)(x,{type:`password`,autoComplete:`off`,className:`w-64 font-mono`,"aria-label":t,placeholder:r?`••••••••`:``,value:u.secrets[e.name]??``,onChange:t=>b({secrets:{...u.secrets,[e.name]:t.target.value}})})},e.name):(0,X.jsx)(M,{label:t,children:(0,X.jsx)(x,{className:`w-64 font-mono`,"aria-label":t,value:u.params[e.name]??``,onChange:t=>b({params:{...u.params,[e.name]:t.target.value}})})},e.name)}),y.length>0&&(0,X.jsx)(`div`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:n(`providers.quota.paramsHint`)}),v&&(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)(xe,{className:`w-28`,ariaLabel:n(`providers.quota.method`),value:u.method,onChange:e=>b({method:e}),options:[{value:`GET`,label:`GET`},{value:`POST`,label:`POST`}]}),(0,X.jsx)(x,{className:`min-w-60 flex-1 font-mono`,"aria-label":n(`providers.quota.url`),value:u.url,onChange:e=>b({url:e.target.value})}),(0,X.jsx)(xe,{className:`w-52`,ariaLabel:n(`providers.quota.auth`),value:u.auth,onChange:e=>b({auth:e}),options:[{value:`provider`,label:n(`providers.quota.auth.provider`)},{value:`none`,label:n(`providers.quota.auth.none`)}]})]}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`providers.quota.urlHint`)}),(0,X.jsx)(_,{label:n(`providers.quota.headers`),mono:!0,rows:3,value:u.headers,onChange:e=>b({headers:e.target.value})}),(0,X.jsx)(_,{label:n(`providers.quota.extract`),mono:!0,rows:8,value:u.extract,onChange:e=>b({extract:e.target.value})}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`providers.quota.extractHint`)})]}),(0,X.jsx)(M,{label:n(`providers.quota.interval`),detail:n(`providers.quota.intervalHint`,{value:k}),children:(0,X.jsx)(I,{className:`w-28`,label:n(`providers.quota.interval`),min:0,step:1,value:u.intervalMinutes,onChange:e=>b({intervalMinutes:e})})}),(0,X.jsx)(M,{label:n(`providers.quota.timeout`),children:(0,X.jsx)(I,{className:`w-28`,label:n(`providers.quota.timeout`),min:1,step:1,value:u.timeoutSec,onChange:e=>b({timeoutSec:e})})}),(0,X.jsx)(M,{label:n(`providers.quota.baseUrl`),detail:n(`providers.quota.baseUrlHint`),children:(0,X.jsx)(x,{className:`w-64 font-mono`,"aria-label":n(`providers.quota.baseUrl`),placeholder:e.endpoints[0]?.baseUrl,value:u.baseUrl,onChange:e=>b({baseUrl:e.target.value})})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 py-3`,children:[(0,X.jsx)(z,{size:`sm`,variant:`primary`,disabled:!S,loading:a.isPending,onClick:E,children:n(`common.save`)}),(0,X.jsx)(z,{size:`sm`,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),loading:o.isPending,onClick:O,title:n(`providers.quota.testDesc`),children:n(`providers.quota.test`)}),(0,X.jsx)(z,{size:`sm`,icon:(0,X.jsx)(Ye,{className:`size-3.5`}),disabled:S,loading:s.isPending,onClick:()=>s.mutate(e.id,{onError:e=>r(q(e),`error`)}),children:n(`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)(ge,{open:f!==null,onOpenChange:e=>!e&&p(null),title:n(`providers.quota.test`),description:n(`providers.quota.testDesc`),width:560,children:f&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(U,{tone:f.ok?`success`:`danger`,title:f.ok?n(`providers.quota.testOk`):n(`providers.quota.testFailed`),children:[!f.ok&&pe({code:f.errorCode??null,message:f.error??``},n),!f.ok&&f.error&&f.errorCode&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] opacity-80`,children:f.error})]}),f.url&&(0,X.jsx)(C,{label:n(`providers.quota.requestUrl`),mono:!0,children:f.url}),f.httpStatus!=null&&(0,X.jsx)(C,{label:n(`providers.quota.httpStatus`),children:f.httpStatus}),f.snapshot&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[12px] text-[var(--text-secondary)]`,children:n(`providers.quota.extracted`)}),(0,X.jsx)(un,{snapshot:f.snapshot})]}),f.raw!==void 0&&f.raw!==null&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[12px] text-[var(--text-secondary)]`,children:n(`providers.quota.rawResponse`)}),(0,X.jsx)(D,{children:on(f.raw)})]})]})})]})}function un({snapshot:e,checkedAtUtc:t}){let{t:n,locale:r}=F(),i=be(e),a=e?.plans??[],o=e?.fetchedAtUtc?new Date(e.fetchedAtUtc).getTime():0;return!e&&!t?(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`providers.quota.never`)}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i&&(0,X.jsxs)(U,{tone:`warning`,title:n(`providers.quota.failed`,{error:pe(i,n)}),children:[(0,X.jsx)(`span`,{className:`text-[11px]`,children:i.message}),a.length>0&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px]`,children:n(`providers.quota.lastGood`)})]}),e?.isValid===!1&&(0,X.jsx)(U,{tone:`warning`,title:n(`providers.quota.invalid`),children:e.invalidMessage}),a.length>0&&(0,X.jsx)(`div`,{className:`flex flex-col gap-1`,children:a.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 text-[13px]`,children:[e.name&&(0,X.jsx)(N,{children:e.name}),(0,X.jsx)(`span`,{className:`num`,children:Se(e,n,r)??`—`}),me(e,n,r)&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:me(e,n,r)}),e.extra&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:e.extra})]},t))}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-[var(--text-muted)]`,children:[e?.planLabel&&(0,X.jsx)(N,{tone:`accent`,children:e.planLabel}),o>0&&(0,X.jsx)(`span`,{children:n(`providers.quota.fetchedAt`,{time:fe(o,r,n(`tray.justNow`))??``})})]})]})}function dn({provider:e}){let{t,locale:n}=F(),{toast:r}=ye(),i=L();if(!he(e))return null;let a=ve(e.quota,t,n),o=be(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:pe(o,t)})}),!a&&!o&&(0,X.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:t(`providers.quota.never`)})]}),(0,X.jsx)(z,{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(q(e),`error`)})})]})}var fn=3,pn=256,mn=4096,hn={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 gn(e){let t=e.endpoints.map(e=>e.protocol);return e.preferredUpstreamProtocols.find(e=>t.includes(e))??t[0]??`openai-chat`}var _n=e=>typeof e==`number`?e:null,vn=e=>typeof e==`string`?e:null;function yn({provider:e,open:t,onOpenChange:n}){let{t:r}=F(),i=ne(),a=S(t?e.id:void 0),o=e.endpoints.map(e=>e.protocol),[s,c]=(0,J.useState)(`single`),[l,u]=(0,J.useState)(()=>gn(e)),[d,f]=(0,J.useState)(!0),[p,m]=(0,J.useState)(``),[h,_]=(0,J.useState)(pn),[v,y]=(0,J.useState)(``),[x,C]=(0,J.useState)(null),[w,T]=(0,J.useState)({}),[E,D]=(0,J.useState)([]),[O,k]=(0,J.useState)(new Set),[A,M]=(0,J.useState)([]),[N,P]=(0,J.useState)(``),[I,L]=(0,J.useState)(null),[R,B]=(0,J.useState)(!1),V=(0,J.useRef)(null),H=(0,J.useRef)(new Map),U=(0,J.useRef)(!1),W=(0,J.useRef)(!1),G=(0,J.useMemo)(()=>{let e=[...a.data??[]].sort((e,t)=>Number(t.enabled)-Number(e.enabled)||e.sortOrder-t.sortOrder).map(e=>e.modelId);return[...e,...A.filter(t=>!e.includes(t))]},[a.data,A]);(0,J.useEffect)(()=>{if(t){y(e=>e||(a.data??[]).find(e=>e.enabled)?.modelId||(a.data??[])[0]?.modelId||``);return}W.current=!1,V.current?.abort();for(let e of H.current.values())e.abort();H.current.clear(),C(null),T({}),D([]),k(new Set),M([]),P(``),L(null)},[t,a.data]);let ee=(0,J.useCallback)(e=>({modelId:e,protocol:l,stream:d,prompt:p.trim()||null,maxOutputTokens:h??pn}),[l,d,p,h]),te=(0,J.useCallback)((t,n,r)=>On(e.id,t,ee(t),n,r),[e.id,ee]),K=()=>{let e=v.trim();if(!e)return;V.current?.abort();let t=new AbortController;V.current=t,W.current=!0,L(null),C({modelId:e,status:`running`,text:``,reasoning:``}),te(e,t.signal,e=>{e.status!==`running`&&e.status!==`queued`&&ie(),C(e)})},re=e=>{if(e.length===0)return;W.current=!0,U.current=!1,L(null),D(e),T(Object.fromEntries(e.map(e=>[e,{modelId:e,status:`queued`,text:``,reasoning:``}])));let t=0;Promise.all(Array.from({length:Math.min(fn,e.length)},async()=>{for(;;){if(!W.current)return;let n=e[t++];if(n===void 0)return;if(U.current){T(e=>({...e,[n]:{...e[n],status:`cancelled`}}));continue}let r=new AbortController;H.current.set(n,r),await te(n,r.signal,e=>T(t=>({...t,[n]:e}))),H.current.delete(n),ie()}}))},ie=()=>void i.invalidateQueries({queryKey:[`requests`]}),ae=()=>{U.current=!0,T(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.status===`queued`?{...t,status:`cancelled`}:t])))},oe=x?.status===`running`||E.some(e=>w[e]?.status===`running`||w[e]?.status===`queued`&&!U.current),se=E.filter(e=>w[e]&&w[e].status!==`queued`&&w[e].status!==`running`).length,ce=E.filter(e=>w[e]?.status===`success`).length,le=E.filter(e=>w[e]?.status===`failed`).length,ue=(e,t)=>k(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),de=()=>{oe||n(!1)},fe=e=>e.stopPropagation();return(0,X.jsx)(`span`,{onClick:fe,onKeyDown:fe,children:(0,X.jsxs)(ge,{open:t,onOpenChange:e=>e?n(!0):de(),width:1040,title:r(`providers.testDialog.title`,{name:e.name}),description:r(`providers.testDialog.subtitle`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mr-auto text-[11px] text-[var(--text-muted)]`,children:r(`providers.testDialog.realRequest`)}),(0,X.jsx)(z,{disabled:oe,onClick:()=>n(!1),icon:(0,X.jsx)(b,{className:`size-3.5`}),children:r(`common.close`)}),s===`single`?oe?(0,X.jsx)(z,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:()=>V.current?.abort(),children:r(`providers.testDialog.stop`)}):(0,X.jsx)(z,{variant:`primary`,disabled:v.trim()===``,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:K,children:r(x?`providers.testDialog.retest`:`providers.testDialog.start`)}):oe?(0,X.jsx)(z,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:ae,children:r(`providers.testDialog.stopRest`)}):(0,X.jsx)(z,{variant:`primary`,disabled:O.size===0,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:()=>re([...O]),children:r(`providers.testDialog.testN`,{count:O.size})})]}),children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pb-4`,children:[(0,X.jsx)(Ue,{name:e.name,icon:e.icon,colorKey:e.templateId,size:32}),(0,X.jsx)(g,{items:[{value:`single`,label:r(`providers.testDialog.modeSingle`)},{value:`batch`,label:r(`providers.testDialog.modeBatch`)}],value:s,onChange:e=>{c(e),L(null)},ariaLabel:r(`providers.testDialog.config`)})]}),s===`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:r(`providers.testDialog.config`)}),(0,X.jsx)(j,{label:r(`providers.testDialog.model`),children:(0,X.jsx)(bn,{value:v,models:G,onChange:y})}),(0,X.jsx)(xn,{protocols:o,protocol:l,onProtocol:u,stream:d,onStream:f,maxTokens:h,onMaxTokens:_,prompt:p,onPrompt:m}),(0,X.jsx)(`p`,{className:`mt-auto text-[11px] text-[var(--text-muted)]`,children:r(`providers.testDialog.savedCredentials`)})]}),(0,X.jsx)(Sn,{run:x,onRetest:K})]}):I===null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(En,{known:G,selected:O,onToggle:ue,onSelectAll:e=>k(e?new Set(G):new Set),onClear:()=>k(new Set),search:N,onSearch:P,onAdd:e=>{M(t=>t.includes(e)?t:[...t,e]),k(t=>new Set(t).add(e)),P(``)},configOpen:R,onConfigOpen:B,protocols:o,protocol:l,onProtocol:u,stream:d,onStream:f,maxTokens:h,onMaxTokens:_,prompt:p,onPrompt:m}),E.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:oe?r(`providers.testDialog.progress`,{done:se,total:E.length,ok:ce,failed:le}):r(`providers.testDialog.progressDone`,{total:E.length,ok:ce,failed:le})}),(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:`${se/E.length*100}%`,background:`var(--accent)`}})})]}):null,E.length>0?(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Dn,{order:E,runs:w,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)(z,{variant:`plain`,icon:(0,X.jsx)(we,{className:`size-4`}),"aria-label":r(`common.back`),onClick:()=>L(null)}),(0,X.jsx)(`span`,{className:`font-mono text-[13px]`,children:I})]}),(0,X.jsx)(Sn,{run:w[I]??null})]})]})})}function bn({value:e,models:t,onChange:n}){let{t:r}=F(),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(0),[c,l]=(0,J.useState)(null),u=c===null?t:t.filter(e=>e.toLowerCase().includes(c.trim().toLowerCase())),d=()=>{l(null),s(Math.max(0,t.indexOf(e))),a(!0)},f=e=>{n(e),l(null),a(!1)};return(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(x,{className:`pr-9 font-mono`,value:e,placeholder:r(`providers.testDialog.modelPlaceholder`),"aria-expanded":i,role:`combobox`,onFocus:d,onClick:d,onChange:e=>{n(e.target.value),l(e.target.value),s(0),a(!0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!i)return d();if(u.length===0)return;let t=e.key===`ArrowDown`?1:-1;s(e=>(e+t+u.length)%u.length)}else e.key===`Enter`&&i?(e.preventDefault(),u[o]&&f(u[o])):e.key===`Escape`&&a(!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?a(!1):d(),children:(0,X.jsx)(T,{className:`size-4`})}),i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`fixed inset-0 z-40`,onMouseDown:()=>a(!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:u.length===0?(0,X.jsx)(`li`,{className:`px-3 py-2 text-[12px] text-[var(--text-muted)]`,children:r(`providers.testDialog.noModels`)}):u.map((e,t)=>(0,X.jsx)(`li`,{children:(0,X.jsx)(`button`,{type:`button`,className:O(`block w-full truncate px-3 py-1.5 text-left font-mono text-[12px] hover:bg-[var(--surface-strong)]`,t===o&&`bg-[var(--surface-strong)]`),onMouseEnter:()=>s(t),onMouseDown:t=>{t.preventDefault(),f(e)},children:e})},e))})]})]})}function xn({protocols:e,...t}){let{t:n}=F(),r=e.map(e=>({value:e,label:jn.find(t=>t.value===e)?.label??e}));return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{label:n(`providers.testDialog.protocol`),children:(0,X.jsx)(xe,{value:t.protocol,onChange:t.onProtocol,options:r})}),(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)(ie,{checked:t.stream,label:n(`providers.testDialog.stream`),onChange:t.onStream})]}),(0,X.jsx)(j,{label:n(`providers.testDialog.maxTokens`),children:(0,X.jsx)(I,{value:t.maxTokens,min:1,placeholder:String(pn),label:n(`providers.testDialog.maxTokens`),onChange:e=>t.onMaxTokens(e===null?null:Math.min(mn,Math.max(1,Math.round(e))))})}),(0,X.jsx)(j,{label:n(`providers.testDialog.prompt`),hint:n(`providers.testDialog.promptHint`),children:(0,X.jsx)(_,{rows:4,value:t.prompt,placeholder:`Reply with OK.`,onChange:e=>t.onPrompt(e.target.value)})})]})}function Sn({run:e,onRetest:t}){let{t:n}=F(),[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,l=r===`raw`?o:r===`headers`?s.map(([e,t])=>`${e}: ${t}`).join(`
1
+ import{Ai as e,Br as t,Ca as n,E as r,Ea as i,Et as a,Hr as o,J as s,Mi as c,Ni as l,Pi as u,Sa as d,Ta as f,W as p,Z as m,Zt as h,_ as g,b as _,bn as v,c as y,ct as b,d as x,er as S,f as C,gi as w,gt as T,h as E,i as D,it as O,ji as k,ki as A,l as j,m as M,n as N,nr as P,ot as F,p as I,pn as L,qn as R,r as z,ri as B,rr as V,s as H,t as U,u as W,v as G,vt as ee,w as te,xa as ne,xn as K,xr as re,y as ie,zr as ae}from"./alert-BzjF81CS.js";import{A as oe,C as se,D as ce,E as le,O as ue,T as de,X as fe,a as q,ct as pe,dt as me,ft as he,i as ge,k as _e,mt as ve,o as ye,pt as be,r as xe,ut as Se,w as Ce}from"./overlays-8ByMRpma.js";import{t as we}from"./arrow-left-Bv8IR_At.js";import{t as Te}from"./download-CI3oqkmw.js";import{n as Ee,t as De}from"./radio-cards-CWiI0xhT.js";import{$ as Oe,F as ke,J as Ae,L as je,R as Me,S as Ne,Z as Pe,_ as Fe,b as Ie,et as Le,g as Re,h as ze,j as Be,k as Ve,tt as He,x as Ue}from"./index-D7HIE1TG.js";import{t as We}from"./checkbox-DQpzihMp.js";var J=i(n(),1);function Ge(e,t,n){(0,J.useInsertionEffect)(()=>e.on(t,n),[e,t,n])}var Ke={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`]};Ke.node;var qe=ee(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=ee(Je),Xe={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Xe.node;var Ze=ee(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=d(),{blur:Qe,duration:Z,ease:$e,spring:et,stagger:tt}=r,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)(u,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(A.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)(A.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:t,media:n,action:r,avatar:i,meta:a,status:o,details:s,open:c,defaultOpen:d=!1,onOpenChange:f,children:p,className:m,style:h,...g}){let _=k()??!1,v=(0,J.useId)(),y=(0,J.useRef)(null),x=(0,J.useRef)(null),[S,C]=(0,J.useState)(d),[w,T]=(0,J.useState)(!1),[E,D]=(0,J.useState)({}),[O,j]=(0,J.useState)(null),M=s?c??S:!1,N=!!s&&!_,P=!M&&O!==null,F=!!t,I=(0,J.useCallback)(e=>{c===void 0&&C(e),f?.(e)},[c,f]);(0,J.useEffect)(()=>{let e=y.current,t=x.current;if(!N||!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;D(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()},[N,F]);let L=(0,J.useRef)(M);(0,J.useLayoutEffect)(()=>{let e=L.current&&!M;L.current=M;let t=y.current;if(M)j(null);else if(e&&N&&t){let e=t.getBoundingClientRect();j({top:e.top,left:e.left,width:e.width,height:e.height})}},[M,N]),(0,J.useEffect)(()=>{if(!P)return;let e=window.setTimeout(()=>j(null),it);return()=>window.clearTimeout(e)},[P]);let R=(e,t,n=!0)=>N?{layoutId:e,layout:n,layoutCrossfade:!1,layoutDependency:t===`card`?M:P?`return`:`panel`,transition:{layout:t===`card`?rt:nt}}:{},z=e=>i||a||o||r?(0,X.jsxs)(`div`,{className:Y.footer,children:[i||a||o?(0,X.jsxs)(A.div,{className:Y.byline,...R(`byline`,e,`position`),children:[i?(0,X.jsx)(`span`,{className:Y.avatar,children:i}):null,(0,X.jsxs)(`span`,{className:Y.bylineText,children:[a?(0,X.jsx)(`span`,{className:Y.meta,children:a}):null,o?(0,X.jsx)(pt,{text:o,reduced:_}):null]})]}):null,r?(0,X.jsx)(A.div,{className:Y.action,...R(`action`,e,`position`),children:r}):null]}):null,B=(0,X.jsxs)(A.article,{...g,ref:y,className:[Y.card,m].filter(Boolean).join(` `),style:{...h,borderRadius:E.card??h?.borderRadius},"data-hover":w||void 0,whileHover:_?void 0:{y:-2},onHoverStart:()=>T(!0),onHoverEnd:()=>T(!1),...R(`card`,`card`),transition:{default:et.snappy,layout:rt},children:[n?(0,X.jsx)(A.div,{className:Y.media,...R(`media`,`card`),children:(0,X.jsx)(A.div,{className:Y.zoom,initial:!1,animate:{scale:w&&!_?ot:1},transition:w?st:ct,children:n})}):null,(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(A.h3,{className:Y.title,...R(`title`,`card`),children:s?(0,X.jsx)(oe,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:Y.trigger,children:e})}):e}),t?(0,X.jsx)(A.p,{ref:x,className:Y.description,...R(`description`,`card`,`position`),children:t}):null,p,z(`card`)]})]});return s?(0,X.jsx)(se,{open:M,onOpenChange:I,children:(0,X.jsxs)(l,{id:v,children:[B,(0,X.jsx)(u,{children:(M||P)&&(0,X.jsxs)(ue,{forceMount:!0,children:[(0,X.jsx)(u,{children:M&&(0,X.jsx)(ce,{asChild:!0,forceMount:!0,children:(0,X.jsx)(A.div,{className:Y.overlay,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:_?at:{duration:Z.exit,ease:[...$e.standard]}},transition:_?at:{duration:Z.standard,ease:[...$e.enter]}})},`overlay`)}),(0,X.jsx)(de,{asChild:!0,forceMount:!0,...t?{}:{"aria-describedby":void 0},children:(0,X.jsxs)(A.div,{className:Y.panel,"data-framer-portal-id":v,"data-returning":P||void 0,layoutScroll:!0,style:{borderRadius:E.panel,"--card-measure":E.measure?`${E.measure}px`:void 0,...O&&P?{"--landing-top":`${O.top}px`,"--landing-left":`${O.left}px`,"--landing-width":`${O.width}px`,"--landing-height":`${O.height}px`}:{}},...N?{...R(`card`,`panel`),initial:!1,animate:E.card!==void 0&&E.panel!==void 0?{borderRadius:P?E.card:E.panel}:void 0,transition:{layout:P?rt:nt,borderRadius:P?rt:nt},exit:{opacity:0,transition:{duration:0}}}:{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:at},transition:at},children:[n?(0,X.jsx)(A.div,{className:Y.media,...R(`media`,`panel`),children:(0,X.jsx)(A.div,{className:Y.zoom,initial:{scale:w&&!_?ot:1},animate:{scale:1},transition:nt,children:n})}):null,(0,X.jsx)(A.span,{className:Y.closeSlot,initial:_?{opacity:0}:{opacity:0,scale:.9},animate:P?{opacity:0,scale:.9}:{opacity:1,scale:1},transition:P||_?at:ut,children:(0,X.jsx)(Ce,{asChild:!0,children:(0,X.jsx)(A.button,{type:`button`,className:Y.close,"aria-label":`Close quick look`,whileTap:_?void 0:{scale:.94},transition:et.snappy,children:(0,X.jsx)(b,{width:16,height:16,strokeWidth:1.75,"aria-hidden":`true`})})})}),(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(_e,{asChild:!0,children:(0,X.jsx)(A.h2,{className:Y.title,...R(`title`,`panel`),children:e})}),t?(0,X.jsx)(le,{asChild:!0,children:(0,X.jsx)(A.p,{className:Y.description,...R(`description`,`panel`,`position`),children:t})}):null,p,z(`panel`),(0,X.jsx)(A.div,{className:Y.details,initial:!_&&{opacity:0,y:6},animate:P?{opacity:0,y:0}:{opacity:1,y:0},exit:{opacity:0,transition:at},transition:P||_?at:lt,children:s})]})]})})]},`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(${r.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:r.duration.standard,ease:[...r.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${r.blur.subtle}px)`,transition:{duration:r.duration.fast,ease:[...r.ease.standard]}})},_t={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:r.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:r.duration.instant}}},vt=e=>Number(e.replace(/,/g,``).replace(/−/g,`-`).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN),yt=new Intl.NumberFormat(`en-US`),bt={duration:r.duration.considered*1.75,ease:[...r.ease.inOut]},xt={duration:r.duration.fast,ease:[...r.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:t,direction:n,whole:i=!1,morph:a=!1,tone:o}){let s=!!k(),l=(0,J.useRef)(null),d=c(`auto`),[f,p]=(0,J.useState)({text:t,direction:1});f.text!==t&&p({text:t,direction:n??(vt(t)<vt(f.text)?-1:1)}),(0,J.useEffect)(()=>{let t=l.current;if(!t||typeof ResizeObserver>`u`)return;let n=null,i=new ResizeObserver(([i])=>{if(!i)return;let a=i.borderBoxSize?.[0]?.inlineSize??t.offsetWidth;n!==null&&n!==t.textContent&&!s?e(d,a,r.spring.morph):d.jump(a),n=t.textContent});return i.observe(t),()=>i.disconnect()},[a,s,d]);let m=!i&&!/\p{L}/u.test(t),h=s?_t:gt,g=m?`right`:`left`;return(0,X.jsxs)(A.span,{className:Q.roll,"data-end":m||void 0,"data-whole":i||void 0,style:a?{width:d}:void 0,children:[a&&(0,X.jsx)(`span`,{ref:l,className:Q.sizer,"aria-hidden":`true`,children:t}),(0,X.jsx)(`span`,{className:Q.track,children:(0,X.jsx)(u,{mode:`popLayout`,initial:!1,custom:f.direction,anchorX:g,children:St(t,i).map(e=>(0,X.jsx)(A.span,{className:Q.slot,custom:f.direction,variants:h,initial:`hidden`,animate:`shown`,exit:`gone`,children:(0,X.jsx)(u,{mode:`popLayout`,initial:!1,custom:f.direction,anchorX:g,children:(0,X.jsx)(A.span,{className:o?`${Q.glyph} ${o}`:Q.glyph,custom:f.direction,variants:h,initial:`hidden`,animate:`shown`,exit:`gone`,children:e.text},`${o??``}${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:t,label:n,value:i,change:a,tone:o=`accent`,width:s=160,height:l=52,labels:u,formatValue:d,area:f=!0,interactive:p=!0}){let m=t.length>1?t:[t[0]??0,t[0]??0],h=m.length-1,g=m.join(`,`),_=(0,J.useMemo)(()=>Dt(g.split(`,`).map(Number)),[g]),v=`${n}: ${i??m[h]}. ${a??``}`.trim(),y=`sparkline${(0,J.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,b=(0,J.useRef)(null),x=(0,J.useRef)(null),S=Le(b,{once:!0,amount:.5}),C=!!k(),[w,T]=(0,J.useState)({w:s,h:l}),[E,D]=(0,J.useState)(null),[O,j]=(0,J.useState)(!1),M=E===null?null:Math.min(E,h),[N,P]=(0,J.useState)({index:M,direction:1});N.index!==M&&P({index:M,direction:M===null||N.index===null?1:Math.sign(M-N.index)||1});let[F]=(0,J.useState)(()=>kt(_,s,l,1)),I=(0,J.useRef)(_),L=(0,J.useRef)(w),R=c(0),z=c(1),B=c(F.line),V=c(F.trail),H=c(F.fill),U=c(F.dot),W=c(F.cx),G=c(F.cx+Tt+16),ee=c(F.cx+Tt),te=c(0),ne=He(R,e=>+(e>.001)),K=(0,J.useCallback)(()=>{let{w:e,h:t}=L.current,n=R.get(),r=kt(I.current,e,t,z.get());B.set(r.line),V.set(r.trail),H.set(r.fill),U.set(r.dot),W.set(r.cx),G.set(r.cx+Tt+16),ee.set(r.cx+Tt),te.set(n>=1?e+32:At(r.points,n)+16)},[z,W,ee,U,R,H,B,G,te,V]);Ge(z,`change`,K),Ge(R,`change`,K),(0,J.useLayoutEffect)(()=>{let e=x.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=e.clientWidth;t&&T(e=>Math.abs(e.w-t)<.5?e:{w:t,h:t*l/s})});return t.observe(e),()=>t.disconnect()},[l,s]),(0,J.useLayoutEffect)(()=>{L.current=w,K()},[w,K]),(0,J.useEffect)(()=>{if(C){R.jump(1);let e=requestAnimationFrame(()=>j(!0));return()=>cancelAnimationFrame(e)}if(!S)return;let t=e(R,1,{...bt,onComplete:()=>j(!0)});return()=>t.stop()},[R,S,C]),(0,J.useEffect)(()=>{let t=I.current;if(t===_)return;if(C){I.current=_,K();return}let n=[...new Set([...Et,..._.map(([e])=>e)])].sort((e,t)=>e-t),i=n.map(e=>Ot(t,e)),a=n.map(e=>Ot(_,e)),o=e(0,1,{...r.spring.smooth,onUpdate:e=>{I.current=n.map((t,n)=>[t,i[n]+(a[n]-i[n])*e]),K()},onComplete:()=>{I.current=_,K()}});return()=>o.stop()},[K,C,_]),(0,J.useEffect)(()=>{let t=M===null?1:M/h;if(C){z.jump(t);return}let n=e(z,t,r.spring.snappy);return()=>n.stop()},[z,M,h,C]);let re=M!==null,ie=(e=>d?d(m[e],e):yt.format(m[e]))(M??h),ae=u?.[M??h],oe=i===void 0?void 0:re?ie:i,se=M===null?a??``:i===void 0?[ie,ae].filter(Boolean).join(` · `):ae??`${M+1} of ${h+1}`,ce=e=>{let t=x.current?.getBoundingClientRect();return t?.width?Math.max(0,Math.min(h,Math.round((e-t.left)/t.width*h))):h},le=p?{role:`slider`,tabIndex:0,"aria-label":`${n}, explore values`,"aria-valuemin":1,"aria-valuemax":h+1,"aria-valuenow":(M??h)+1,"aria-valuetext":`${ae??(M===null?`Latest`:`Point ${M+1} of ${h+1}`)}: ${ie}`,onPointerDown:e=>D(ce(e.clientX)),onPointerMove:e=>{(e.pointerType===`mouse`||e.buttons)&&D(ce(e.clientX))},onPointerUp:e=>{e.pointerType!==`mouse`&&D(null)},onPointerLeave:()=>D(null),onPointerCancel:()=>D(null),onBlur:()=>D(null),onKeyDown:e=>{if(e.key===`Escape`&&re){e.preventDefault(),D(null);return}let t=M??h,n=Math.max(1,Math.round((h+1)/6)),r={ArrowLeft:t-1,ArrowDown:t-1,ArrowRight:t+1,ArrowUp:t+1,PageDown:t-n,PageUp:t+n,Home:0,End:h}[e.key];r!==void 0&&(e.preventDefault(),D(Math.max(0,Math.min(h,r))))}}:{};return(0,X.jsxs)(`figure`,{ref:b,className:Q.figure,"aria-label":v,children:[(0,X.jsxs)(`figcaption`,{className:Q.caption,children:[(0,X.jsx)(`span`,{className:Q.label,children:(0,X.jsx)(Ct,{text:n,whole:!0})}),oe!==void 0&&(0,X.jsx)(`strong`,{children:(0,X.jsx)(Ct,{text:oe,morph:!0})}),(0,X.jsx)(`small`,{className:Q[o],children:(0,X.jsx)(Ct,{text:se,direction:re?N.direction:void 0,tone:re?Q.point:void 0,morph:!0})})]}),(0,X.jsx)(`div`,{ref:x,className:Q.plot,"data-interactive":p||void 0,...le,children:(0,X.jsxs)(`svg`,{className:Q.chart,viewBox:`0 0 ${w.w} ${w.h}`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(`clipPath`,{id:`${y}-lit`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(A.rect,{x:-16,y:-16,width:G,height:w.h+32})}),(0,X.jsx)(`clipPath`,{id:`${y}-dim`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(A.rect,{x:ee,y:-16,width:w.w+32,height:w.h+32})}),(0,X.jsx)(`clipPath`,{id:`${y}-fill`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(A.rect,{x:-16,y:-16,width:te,height:w.h+32})})]}),f&&(0,X.jsx)(A.path,{className:`${Q.area} ${Q[o]}`,d:H,clipPath:`url(#${y}-fill)`}),(0,X.jsx)(`line`,{className:Q.baseline,x1:`0`,y1:w.h-.5,x2:w.w,y2:w.h-.5}),(0,X.jsx)(A.path,{className:Q.trail,d:V,clipPath:`url(#${y}-dim)`,initial:!1,animate:{opacity:re&&O?1:0},transition:C?{duration:0}:xt}),(0,X.jsx)(A.polyline,{className:[Q.line,Q[o]].join(` `),points:B,clipPath:`url(#${y}-lit)`,style:{pathLength:R,opacity:ne}}),(0,X.jsx)(A.line,{className:Q.cursor,x1:W,x2:W,y1:0,y2:w.h,initial:!1,animate:{opacity:+!!re},transition:C?{duration:0}:xt}),(0,X.jsx)(A.polyline,{className:[Q.end,Q[o]].join(` `),points:U,initial:!1,animate:{opacity:+!!O,strokeWidth:O?re?10:7:0},transition:C?{duration:0}:{opacity:xt,strokeWidth:r.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:r.duration.fast,ease:[...r.ease.standard]},Ft={duration:r.duration.standard,ease:[...r.ease.enter]},It={opacity:0,y:`0.3em`,filter:Mt(r.blur.soft)},Lt={opacity:1,y:0,filter:Mt(0)},Rt={opacity:0,y:`-0.3em`,filter:Mt(r.blur.subtle)},zt={opacity:0,scale:.5,filter:Mt(r.blur.subtle)},Bt={opacity:1,scale:1,filter:Mt(0)};function Vt({text:t,className:n,reduced:i}){let a=(0,J.useRef)(null),o=(0,J.useRef)(0),s=c(`auto`);return(0,J.useLayoutEffect)(()=>{o.current=performance.now()+700},[t]),(0,J.useEffect)(()=>{let t=a.current,n=t?.parentElement;if(!t||!n||typeof ResizeObserver>`u`)return;let c=!1,l=new ResizeObserver(()=>{let n=t.offsetHeight;if(!c||i||performance.now()>o.current){c=!0,s.jump(n);return}e(s,n,r.spring.smooth)});return l.observe(t),()=>l.disconnect()},[s,i]),(0,X.jsx)(A.span,{className:$.slot,style:{height:s},children:(0,X.jsx)(`span`,{ref:a,className:$.slotInner,children:(0,X.jsx)(u,{mode:`popLayout`,initial:!1,children:t?(0,X.jsx)(A.span,{className:n,initial:It,animate:Lt,exit:{...Rt,transition:i?Nt:Pt},transition:i?Nt:Ft,children:t},`${n}:${t}`):null})})})}function Ht({kind:e,number:t,delay:n,reduced:i}){let a=i?Nt:{scale:{...r.spring.snappy,delay:n},opacity:{duration:r.duration.fast,delay:n},filter:{duration:r.duration.fast,delay:n}},o={...zt,transition:i?Nt:Pt},s=i?Nt:{duration:r.duration.standard,ease:r.ease.enter,delay:n+.04};return e===`number`?(0,X.jsx)(A.span,{className:$.glyph,initial:zt,animate:Bt,exit:o,transition:a,children:t}):(0,X.jsx)(A.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:o,transition:a,children:e===`check`?(0,X.jsx)(A.path,{d:`M5.5 12.5l4.25 4.25L18.5 8`,initial:{pathLength:0},animate:{pathLength:1},transition:s}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A.path,{d:`M12 6.75v6.5`,initial:{pathLength:0},animate:{pathLength:1},transition:s}),(0,X.jsx)(A.circle,{cx:12,cy:17.4,r:1.4,fill:`currentColor`,stroke:`none`,initial:{scale:0},animate:{scale:1},transition:i?Nt:{...r.spring.snappy,delay:n+.16}})]})})}function Ut({number:e,kind:t,current:n,glyphDelay:i,ringDelay:a,reduced:o}){return(0,X.jsxs)(`span`,{className:$.marker,"aria-hidden":`true`,children:[(0,X.jsx)(u,{initial:!1,children:n?(0,X.jsx)(A.span,{className:$.ring,initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:o?Nt:Pt},transition:o?Nt:{scale:{...r.spring.snappy,delay:a},opacity:{duration:r.duration.fast,delay:a}}},`ring`):null}),(0,X.jsx)(`span`,{className:$.disc,children:(0,X.jsx)(u,{initial:!1,children:(0,X.jsx)(Ht,{kind:t,number:e,delay:i,reduced:o},t)})})]})}var Wt={complete:`Completed`,current:``,upcoming:`Not started`,error:`Error`};function Gt({steps:e,current:t,orientation:n=`horizontal`,onStepSelect:i,details:a=`all`,compact:o=!1,label:s=`Progress`,completeLabel:c=`All steps complete`,className:l}){let u=k()??!1,d=e.length,f=Math.min(Math.max(Math.round(t),0),d),[p,m]=(0,J.useState)({to:f,from:f});p.to!==f&&m({to:f,from:p.to});let h=p.from,g=r.stagger.line,_=e=>u?0:f>h?e>=h&&e<f?(e-h)*g:0:e>=f&&e<h?(h-1-e)*g:0,v=u?0:Math.max(0,Math.abs(f-h)-1)*g+.12,y=!!i,b=n===`vertical`,x=f>=d?void 0:e[f];function S(e){let t=!b&&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 C=y?`nav`:`div`,w=[$.root,b?$.vertical:$.horizontal,o?$.compact:``,l].filter(Boolean).join(` `);return(0,X.jsxs)(C,{className:w,"aria-label":s,role:y?void 0:`group`,children:[(0,X.jsx)(`ol`,{className:$.list,style:b?void 0:{gridTemplateColumns:d>1?`repeat(${d-1}, minmax(0, 1fr)) auto`:`auto`},onKeyDown:y?S:void 0,children:e.map((e,t)=>{let o=t===f,s=e.error?`error`:t<f?`complete`:o?`current`:`upcoming`,c=y&&t<f,l=e.error??(a===`all`||o?e.description:void 0),p=e.error?`error`:t<f?`check`:`number`,m=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ut,{number:t+1,kind:p,current:o,glyphDelay:_(t),ringDelay:v,reduced:u}),(0,X.jsxs)(`span`,{className:$.text,children:[(0,X.jsx)(`span`,{className:$.label,children:e.label}),Wt[s]?(0,X.jsxs)(`span`,{className:$.srOnly,children:[`, `,Wt[s]]}):null,(0,X.jsx)(Vt,{text:l,className:e.error?$.error:$.description,reduced:u})]})]});return(0,X.jsxs)(`li`,{className:$.item,"data-status":s,children:[t<d-1?(0,X.jsx)(`span`,{className:$.connector,"aria-hidden":`true`,children:(0,X.jsx)(A.span,{className:$.fill,initial:!1,animate:b?{scaleY:+(t<f)}:{scaleX:+(t<f)},transition:u?Nt:{...r.spring.smooth,delay:_(t)}},n)}):null,y?(0,X.jsx)(`button`,{type:`button`,className:$.head,"data-clickable":c||void 0,"data-reachable":t<=f||void 0,"aria-current":o?`step`:void 0,"aria-disabled":!c||void 0,tabIndex:c?void 0:-1,onClick:c?()=>i?.(t):void 0,children:m}):(0,X.jsx)(`span`,{className:$.head,"aria-current":o?`step`:void 0,children:m})]},e.id)})}),b?null:(0,X.jsxs)(`span`,{className:$.caption,"aria-hidden":`true`,children:[(0,X.jsx)(Vt,{text:x?.label??c,className:$.captionLabel,reduced:u}),(0,X.jsx)(Vt,{text:x?.error??x?.description,className:x?.error?$.error:$.description,reduced:u})]}),(0,X.jsx)(`span`,{className:$.srOnly,"aria-live":`polite`,children:x?`Step ${f+1} of ${d}: ${x.label}`:c})]})}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}=F(),{toast:r}=ye(),i=K(e),a=v(),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(new Set),[u,d]=(0,J.useState)(null);(0,J.useEffect)(()=>{i.data&&l(new Set(i.data.flatMap(e=>e.items).filter(e=>e.status===`new`).map(Jt)))},[i.data]),(0,J.useEffect)(()=>{e&&(s(``),d(null))},[e]);let f=o.trim().toLowerCase(),p=e=>!f||e.name.toLowerCase().includes(f)||e.endpoints.some(e=>e.baseUrl.toLowerCase().includes(f)),m=(0,J.useMemo)(()=>(i.data??[]).flatMap(e=>e.items).filter(e=>c.has(Jt(e))&&Yt(e)),[i.data,c]),h=(e,t)=>l(n=>{let r=new Set(n);return t?r.add(Jt(e)):r.delete(Jt(e)),r});return(0,X.jsx)(ge,{open:e,onOpenChange:t,width:680,title:n(`import.title`),description:n(`import.detail`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{icon:(0,X.jsx)(je,{className:`size-3.5`}),onClick:()=>void i.refetch(),disabled:i.isFetching||a.isPending,children:n(`import.rescan`)}),(0,X.jsx)(z,{variant:`primary`,disabled:m.length===0||a.isPending,onClick:()=>{d(null),a.mutate(m.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=>{d(q(e)),i.refetch()}})},children:n(`import.selected`,{count:m.length})})]}),children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(E,{value:o,onChange:s,placeholder:n(`import.search`)}),u&&(0,X.jsx)(U,{tone:`danger`,title:n(`common.error`),children:u}),i.isLoading&&(0,X.jsx)(G,{lines:3}),i.isError&&(0,X.jsx)(U,{tone:`danger`,title:n(`common.error`),children:q(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:p,selected:c,onToggle:h,filtering:f.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}=F(),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)(U,{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}=F(),i=Yt(e),a=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,o=e.endpoints.map(e=>`${Kt[e.protocol]??e.protocol} · ${Xt(e.baseUrl)}`).join(` / `);return(0,X.jsxs)(`li`,{className:O(`flex items-start gap-3 px-4 py-3`,!i&&`opacity-60`),children:[(0,X.jsx)(We,{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)(N,{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})]}),o&&(0,X.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-[var(--text-muted)]`,title:o,children:o}),(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})})]}),a&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--text-secondary,var(--text-muted))]`,children:a}),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:n}=F(),{toast:r}=ye(),i=V(),a=re(e.id),o=t(e.id),s=L(),c=e.quotaConfig,l=(0,J.useMemo)(()=>sn(c),[c]),[u,d]=(0,J.useState)(l),[f,p]=(0,J.useState)(null);(0,J.useEffect)(()=>d(l),[l]);let m=i.data??[],h=m.find(e=>e.id===c.suggestedTemplate),g=u.template===en?h:m.find(e=>e.id===u.template),v=u.template===tn,y=v?nn:g?.params??[],b=e=>d(t=>({...t,...e})),S=JSON.stringify(u)!==JSON.stringify(l),w=e=>{if(e!==tn||u.url)return b({template:e});let t=g??h;b({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)})},T=()=>{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(v){let t=cn(u.headers),i=cn(u.extract);if(!t||!i)return r(n(`providers.quota.invalidJson`,{field:n(t?`providers.quota.extract`:`providers.quota.headers`)}),`error`),null;e.request={method:u.method,url:u.url.trim(),auth:u.auth,headers:t},e.extract=i}return e},E=()=>{let t=T();if(!t)return;let i=t.enabled&&!c.enabled;a.mutate(t,{onSuccess:()=>{r(n(`common.saved`),`success`),i&&s.mutate(e.id,{onError:e=>r(q(e),`error`)})},onError:e=>r(q(e),`error`)})},O=()=>{let e=T();e&&o.mutate(e,{onSuccess:p,onError:e=>r(q(e),`error`)})},k=c.effectiveIntervalMinutes>0?n(`providers.quota.intervalEvery`,{minutes:c.effectiveIntervalMinutes}):n(`providers.quota.intervalOff`),A=[{value:en,label:h?n(`providers.quota.templateAuto`,{name:h.name}):n(`providers.quota.templateNone`)},...m.map(e=>({value:e.id,label:e.name,detail:n(`providers.quota.kind.${e.kind}`)})),{value:tn,label:n(`providers.quota.custom`)}];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(W,{title:n(`providers.quota.title`),footer:n(`providers.quota.footer`),children:[(0,X.jsx)(M,{label:n(`providers.quota.enable`),detail:n(`providers.quota.enableHint`),children:(0,X.jsx)(ie,{checked:u.enabled,label:n(`providers.quota.enable`),onChange:e=>b({enabled:e})})}),(0,X.jsx)(M,{label:n(`providers.quota.template`),children:(0,X.jsx)(xe,{className:`w-64`,ariaLabel:n(`providers.quota.template`),value:u.template,onChange:w,options:A})}),y.map(e=>{let t=n(`providers.quota.param.${e.name}`),r=c.secrets.includes(e.name);return e.secret?(0,X.jsx)(M,{label:t,detail:r?n(`providers.quota.secretStored`):void 0,children:(0,X.jsx)(x,{type:`password`,autoComplete:`off`,className:`w-64 font-mono`,"aria-label":t,placeholder:r?`••••••••`:``,value:u.secrets[e.name]??``,onChange:t=>b({secrets:{...u.secrets,[e.name]:t.target.value}})})},e.name):(0,X.jsx)(M,{label:t,children:(0,X.jsx)(x,{className:`w-64 font-mono`,"aria-label":t,value:u.params[e.name]??``,onChange:t=>b({params:{...u.params,[e.name]:t.target.value}})})},e.name)}),y.length>0&&(0,X.jsx)(`div`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:n(`providers.quota.paramsHint`)}),v&&(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)(xe,{className:`w-28`,ariaLabel:n(`providers.quota.method`),value:u.method,onChange:e=>b({method:e}),options:[{value:`GET`,label:`GET`},{value:`POST`,label:`POST`}]}),(0,X.jsx)(x,{className:`min-w-60 flex-1 font-mono`,"aria-label":n(`providers.quota.url`),value:u.url,onChange:e=>b({url:e.target.value})}),(0,X.jsx)(xe,{className:`w-52`,ariaLabel:n(`providers.quota.auth`),value:u.auth,onChange:e=>b({auth:e}),options:[{value:`provider`,label:n(`providers.quota.auth.provider`)},{value:`none`,label:n(`providers.quota.auth.none`)}]})]}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`providers.quota.urlHint`)}),(0,X.jsx)(_,{label:n(`providers.quota.headers`),mono:!0,rows:3,value:u.headers,onChange:e=>b({headers:e.target.value})}),(0,X.jsx)(_,{label:n(`providers.quota.extract`),mono:!0,rows:8,value:u.extract,onChange:e=>b({extract:e.target.value})}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`providers.quota.extractHint`)})]}),(0,X.jsx)(M,{label:n(`providers.quota.interval`),detail:n(`providers.quota.intervalHint`,{value:k}),children:(0,X.jsx)(I,{className:`w-28`,label:n(`providers.quota.interval`),min:0,step:1,value:u.intervalMinutes,onChange:e=>b({intervalMinutes:e})})}),(0,X.jsx)(M,{label:n(`providers.quota.timeout`),children:(0,X.jsx)(I,{className:`w-28`,label:n(`providers.quota.timeout`),min:1,step:1,value:u.timeoutSec,onChange:e=>b({timeoutSec:e})})}),(0,X.jsx)(M,{label:n(`providers.quota.baseUrl`),detail:n(`providers.quota.baseUrlHint`),children:(0,X.jsx)(x,{className:`w-64 font-mono`,"aria-label":n(`providers.quota.baseUrl`),placeholder:e.endpoints[0]?.baseUrl,value:u.baseUrl,onChange:e=>b({baseUrl:e.target.value})})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 py-3`,children:[(0,X.jsx)(z,{size:`sm`,variant:`primary`,disabled:!S,loading:a.isPending,onClick:E,children:n(`common.save`)}),(0,X.jsx)(z,{size:`sm`,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),loading:o.isPending,onClick:O,title:n(`providers.quota.testDesc`),children:n(`providers.quota.test`)}),(0,X.jsx)(z,{size:`sm`,icon:(0,X.jsx)(Ye,{className:`size-3.5`}),disabled:S,loading:s.isPending,onClick:()=>s.mutate(e.id,{onError:e=>r(q(e),`error`)}),children:n(`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)(ge,{open:f!==null,onOpenChange:e=>!e&&p(null),title:n(`providers.quota.test`),description:n(`providers.quota.testDesc`),width:560,children:f&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(U,{tone:f.ok?`success`:`danger`,title:f.ok?n(`providers.quota.testOk`):n(`providers.quota.testFailed`),children:[!f.ok&&pe({code:f.errorCode??null,message:f.error??``},n),!f.ok&&f.error&&f.errorCode&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] opacity-80`,children:f.error})]}),f.url&&(0,X.jsx)(C,{label:n(`providers.quota.requestUrl`),mono:!0,children:f.url}),f.httpStatus!=null&&(0,X.jsx)(C,{label:n(`providers.quota.httpStatus`),children:f.httpStatus}),f.snapshot&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[12px] text-[var(--text-secondary)]`,children:n(`providers.quota.extracted`)}),(0,X.jsx)(un,{snapshot:f.snapshot})]}),f.raw!==void 0&&f.raw!==null&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[12px] text-[var(--text-secondary)]`,children:n(`providers.quota.rawResponse`)}),(0,X.jsx)(D,{children:on(f.raw)})]})]})})]})}function un({snapshot:e,checkedAtUtc:t}){let{t:n,locale:r}=F(),i=be(e),a=e?.plans??[],o=e?.fetchedAtUtc?new Date(e.fetchedAtUtc).getTime():0;return!e&&!t?(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`providers.quota.never`)}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i&&(0,X.jsxs)(U,{tone:`warning`,title:n(`providers.quota.failed`,{error:pe(i,n)}),children:[(0,X.jsx)(`span`,{className:`text-[11px]`,children:i.message}),a.length>0&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px]`,children:n(`providers.quota.lastGood`)})]}),e?.isValid===!1&&(0,X.jsx)(U,{tone:`warning`,title:n(`providers.quota.invalid`),children:e.invalidMessage}),a.length>0&&(0,X.jsx)(`div`,{className:`flex flex-col gap-1`,children:a.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 text-[13px]`,children:[e.name&&(0,X.jsx)(N,{children:e.name}),(0,X.jsx)(`span`,{className:`num`,children:Se(e,n,r)??`—`}),me(e,n,r)&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:me(e,n,r)}),e.extra&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:e.extra})]},t))}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-[var(--text-muted)]`,children:[e?.planLabel&&(0,X.jsx)(N,{tone:`accent`,children:e.planLabel}),o>0&&(0,X.jsx)(`span`,{children:n(`providers.quota.fetchedAt`,{time:fe(o,r,n(`tray.justNow`))??``})})]})]})}function dn({provider:e}){let{t,locale:n}=F(),{toast:r}=ye(),i=L();if(!he(e))return null;let a=ve(e.quota,t,n),o=be(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:pe(o,t)})}),!a&&!o&&(0,X.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:t(`providers.quota.never`)})]}),(0,X.jsx)(z,{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(q(e),`error`)})})]})}var fn=3,pn=256,mn=4096,hn={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 gn(e){let t=e.endpoints.map(e=>e.protocol);return e.preferredUpstreamProtocols.find(e=>t.includes(e))??t[0]??`openai-chat`}var _n=e=>typeof e==`number`?e:null,vn=e=>typeof e==`string`?e:null;function yn({provider:e,open:t,onOpenChange:n}){let{t:r}=F(),i=ne(),a=S(t?e.id:void 0),o=e.endpoints.map(e=>e.protocol),[s,c]=(0,J.useState)(`single`),[l,u]=(0,J.useState)(()=>gn(e)),[d,f]=(0,J.useState)(!0),[p,m]=(0,J.useState)(``),[h,_]=(0,J.useState)(pn),[v,y]=(0,J.useState)(``),[x,C]=(0,J.useState)(null),[w,T]=(0,J.useState)({}),[E,D]=(0,J.useState)([]),[O,k]=(0,J.useState)(new Set),[A,M]=(0,J.useState)([]),[N,P]=(0,J.useState)(``),[I,L]=(0,J.useState)(null),[R,B]=(0,J.useState)(!1),V=(0,J.useRef)(null),H=(0,J.useRef)(new Map),U=(0,J.useRef)(!1),W=(0,J.useRef)(!1),G=(0,J.useMemo)(()=>{let e=[...a.data??[]].sort((e,t)=>Number(t.enabled)-Number(e.enabled)||e.sortOrder-t.sortOrder).map(e=>e.modelId);return[...e,...A.filter(t=>!e.includes(t))]},[a.data,A]);(0,J.useEffect)(()=>{if(t){y(e=>e||(a.data??[]).find(e=>e.enabled)?.modelId||(a.data??[])[0]?.modelId||``);return}W.current=!1,V.current?.abort();for(let e of H.current.values())e.abort();H.current.clear(),C(null),T({}),D([]),k(new Set),M([]),P(``),L(null)},[t,a.data]);let ee=(0,J.useCallback)(e=>({modelId:e,protocol:l,stream:d,prompt:p.trim()||null,maxOutputTokens:h??pn}),[l,d,p,h]),te=(0,J.useCallback)((t,n,r)=>On(e.id,t,ee(t),n,r),[e.id,ee]),K=()=>{let e=v.trim();if(!e)return;V.current?.abort();let t=new AbortController;V.current=t,W.current=!0,L(null),C({modelId:e,status:`running`,text:``,reasoning:``}),te(e,t.signal,e=>{e.status!==`running`&&e.status!==`queued`&&ie(),C(e)})},re=e=>{if(e.length===0)return;W.current=!0,U.current=!1,L(null),D(e),T(Object.fromEntries(e.map(e=>[e,{modelId:e,status:`queued`,text:``,reasoning:``}])));let t=0;Promise.all(Array.from({length:Math.min(fn,e.length)},async()=>{for(;;){if(!W.current)return;let n=e[t++];if(n===void 0)return;if(U.current){T(e=>({...e,[n]:{...e[n],status:`cancelled`}}));continue}let r=new AbortController;H.current.set(n,r),await te(n,r.signal,e=>T(t=>({...t,[n]:e}))),H.current.delete(n),ie()}}))},ie=()=>void i.invalidateQueries({queryKey:[`requests`]}),ae=()=>{U.current=!0,T(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.status===`queued`?{...t,status:`cancelled`}:t])))},oe=x?.status===`running`||E.some(e=>w[e]?.status===`running`||w[e]?.status===`queued`&&!U.current),se=E.filter(e=>w[e]&&w[e].status!==`queued`&&w[e].status!==`running`).length,ce=E.filter(e=>w[e]?.status===`success`).length,le=E.filter(e=>w[e]?.status===`failed`).length,ue=(e,t)=>k(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),de=()=>{oe||n(!1)},fe=e=>e.stopPropagation();return(0,X.jsx)(`span`,{onClick:fe,onKeyDown:fe,children:(0,X.jsxs)(ge,{open:t,onOpenChange:e=>e?n(!0):de(),width:1040,title:r(`providers.testDialog.title`,{name:e.name}),description:r(`providers.testDialog.subtitle`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mr-auto text-[11px] text-[var(--text-muted)]`,children:r(`providers.testDialog.realRequest`)}),(0,X.jsx)(z,{disabled:oe,onClick:()=>n(!1),icon:(0,X.jsx)(b,{className:`size-3.5`}),children:r(`common.close`)}),s===`single`?oe?(0,X.jsx)(z,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:()=>V.current?.abort(),children:r(`providers.testDialog.stop`)}):(0,X.jsx)(z,{variant:`primary`,disabled:v.trim()===``,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:K,children:r(x?`providers.testDialog.retest`:`providers.testDialog.start`)}):oe?(0,X.jsx)(z,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:ae,children:r(`providers.testDialog.stopRest`)}):(0,X.jsx)(z,{variant:`primary`,disabled:O.size===0,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:()=>re([...O]),children:r(`providers.testDialog.testN`,{count:O.size})})]}),children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pb-4`,children:[(0,X.jsx)(Ue,{name:e.name,icon:e.icon,colorKey:e.templateId,size:32}),(0,X.jsx)(g,{items:[{value:`single`,label:r(`providers.testDialog.modeSingle`)},{value:`batch`,label:r(`providers.testDialog.modeBatch`)}],value:s,onChange:e=>{c(e),L(null)},ariaLabel:r(`providers.testDialog.config`)})]}),s===`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:r(`providers.testDialog.config`)}),(0,X.jsx)(j,{label:r(`providers.testDialog.model`),children:(0,X.jsx)(bn,{value:v,models:G,onChange:y})}),(0,X.jsx)(xn,{protocols:o,protocol:l,onProtocol:u,stream:d,onStream:f,maxTokens:h,onMaxTokens:_,prompt:p,onPrompt:m}),(0,X.jsx)(`p`,{className:`mt-auto text-[11px] text-[var(--text-muted)]`,children:r(`providers.testDialog.savedCredentials`)})]}),(0,X.jsx)(Sn,{run:x,onRetest:K})]}):I===null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(En,{known:G,selected:O,onToggle:ue,onSelectAll:e=>k(e?new Set(G):new Set),onClear:()=>k(new Set),search:N,onSearch:P,onAdd:e=>{M(t=>t.includes(e)?t:[...t,e]),k(t=>new Set(t).add(e)),P(``)},configOpen:R,onConfigOpen:B,protocols:o,protocol:l,onProtocol:u,stream:d,onStream:f,maxTokens:h,onMaxTokens:_,prompt:p,onPrompt:m}),E.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:oe?r(`providers.testDialog.progress`,{done:se,total:E.length,ok:ce,failed:le}):r(`providers.testDialog.progressDone`,{total:E.length,ok:ce,failed:le})}),(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:`${se/E.length*100}%`,background:`var(--accent)`}})})]}):null,E.length>0?(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Dn,{order:E,runs:w,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)(z,{variant:`plain`,icon:(0,X.jsx)(we,{className:`size-4`}),"aria-label":r(`common.back`),onClick:()=>L(null)}),(0,X.jsx)(`span`,{className:`font-mono text-[13px]`,children:I})]}),(0,X.jsx)(Sn,{run:w[I]??null})]})]})})}function bn({value:e,models:t,onChange:n}){let{t:r}=F(),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(0),[c,l]=(0,J.useState)(null),u=c===null?t:t.filter(e=>e.toLowerCase().includes(c.trim().toLowerCase())),d=()=>{l(null),s(Math.max(0,t.indexOf(e))),a(!0)},f=e=>{n(e),l(null),a(!1)};return(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(x,{className:`pr-9 font-mono`,value:e,placeholder:r(`providers.testDialog.modelPlaceholder`),"aria-expanded":i,role:`combobox`,onFocus:d,onClick:d,onChange:e=>{n(e.target.value),l(e.target.value),s(0),a(!0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!i)return d();if(u.length===0)return;let t=e.key===`ArrowDown`?1:-1;s(e=>(e+t+u.length)%u.length)}else e.key===`Enter`&&i?(e.preventDefault(),u[o]&&f(u[o])):e.key===`Escape`&&a(!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?a(!1):d(),children:(0,X.jsx)(T,{className:`size-4`})}),i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`fixed inset-0 z-40`,onMouseDown:()=>a(!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:u.length===0?(0,X.jsx)(`li`,{className:`px-3 py-2 text-[12px] text-[var(--text-muted)]`,children:r(`providers.testDialog.noModels`)}):u.map((e,t)=>(0,X.jsx)(`li`,{children:(0,X.jsx)(`button`,{type:`button`,className:O(`block w-full truncate px-3 py-1.5 text-left font-mono text-[12px] hover:bg-[var(--surface-strong)]`,t===o&&`bg-[var(--surface-strong)]`),onMouseEnter:()=>s(t),onMouseDown:t=>{t.preventDefault(),f(e)},children:e})},e))})]})]})}function xn({protocols:e,...t}){let{t:n}=F(),r=e.map(e=>({value:e,label:jn.find(t=>t.value===e)?.label??e}));return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{label:n(`providers.testDialog.protocol`),children:(0,X.jsx)(xe,{value:t.protocol,onChange:t.onProtocol,options:r})}),(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)(ie,{checked:t.stream,label:n(`providers.testDialog.stream`),onChange:t.onStream})]}),(0,X.jsx)(j,{label:n(`providers.testDialog.maxTokens`),children:(0,X.jsx)(I,{value:t.maxTokens,min:1,placeholder:String(pn),label:n(`providers.testDialog.maxTokens`),onChange:e=>t.onMaxTokens(e===null?null:Math.min(mn,Math.max(1,Math.round(e))))})}),(0,X.jsx)(j,{label:n(`providers.testDialog.prompt`),hint:n(`providers.testDialog.promptHint`),children:(0,X.jsx)(_,{rows:4,value:t.prompt,placeholder:`Reply with OK.`,onChange:e=>t.onPrompt(e.target.value)})})]})}function Sn({run:e,onRetest:t}){let{t:n}=F(),[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,l=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)(z,{size:`sm`,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:t,children:n(`providers.testDialog.retest`)}):null,(0,X.jsx)(Re,{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)(qe,{className:`size-4`})})}),(0,X.jsx)(Tn,{run:e}),e?.httpStatus?(0,X.jsxs)(N,{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)(wn,{label:n(`providers.testDialog.metrics.http`),value:e?.httpMs}),(0,X.jsx)(wn,{label:n(`providers.testDialog.metrics.firstWait`),value:c}),(0,X.jsx)(wn,{label:n(`providers.testDialog.metrics.ttft`),value:e?.ttftMs}),(0,X.jsx)(wn,{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)(te,{value:l,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)(Cn,{run:e}):e?.error?(0,X.jsx)(U,{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)(Cn,{run:e})})]})]})}function Cn({run:e}){let{t}=F();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(hn[e.status])}):(0,X.jsxs)(`div`,{className:`grid h-full place-items-center content-center gap-2 text-center`,children:[(0,X.jsx)(Ae,{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 wn({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?`—`:p(t)})]})}function Tn({run:e}){let{t}=F(),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)(H,{tone:n===`success`?`green`:n===`failed`?`red`:n===`running`?`orange`:`neutral`}),t(hn[n])]})}function En({known:e,selected:t,onToggle:n,onSelectAll:r,onClear:i,search:a,onSearch:o,onAdd:s,configOpen:c,onConfigOpen:l,...u}){let{t:d}=F(),f=a.trim(),p=f.toLowerCase(),m=p?e.filter(e=>e.toLowerCase().includes(p)):e,h=f!==``&&!e.some(e=>e.toLowerCase()===p);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:d(`providers.testDialog.selected`,{n:t.size,total:e.length})}),(0,X.jsx)(`div`,{className:`min-w-[220px] flex-1`,children:(0,X.jsx)(E,{value:a,onChange:o,placeholder:d(`providers.testDialog.searchModels`)})}),(0,X.jsx)(z,{variant:`plain`,disabled:t.size===0,onClick:i,children:d(`providers.testDialog.clearSelection`)}),(0,X.jsx)(z,{icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:()=>l(!0),children:d(`providers.testDialog.config`)})]}),(0,X.jsx)(`div`,{className:`card max-h-[420px] overflow-auto`,children:m.length===0&&!h?(0,X.jsx)(`p`,{className:`px-4 py-6 text-center text-[12px] text-[var(--text-muted)]`,children:d(`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)(We,{checked:t.size===e.length&&e.length>0||t.size!==0&&`indeterminate`,onCheckedChange:e=>r(e!==!1),"aria-label":d(`providers.testDialog.clearSelection`)}),(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:d(`providers.testDialog.ownFilter`)})]}),h?(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,X.jsx)(Me,{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(f),children:d(`providers.testDialog.addModel`,{id:f})})]}):null,m.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,X.jsx)(We,{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)(ge,{open:c,onOpenChange:l,width:480,title:d(`providers.testDialog.config`),description:d(`providers.testDialog.savedCredentials`),children:(0,X.jsx)(`div`,{className:`grid gap-4`,children:(0,X.jsx)(xn,{...u})})})]})}function Dn({order:e,runs:t,onView:n}){let{t:r}=F();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)(Tn,{run:i??null})}),(0,X.jsx)(`td`,{className:`px-4 py-2 font-mono tabular-nums`,children:i?.ttftMs==null?`—`:p(i.ttftMs)}),(0,X.jsx)(`td`,{className:`px-4 py-2 font-mono tabular-nums`,children:i?.totalMs==null?`—`:p(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 On(e,t,n,r,i){let o={modelId:t,status:`running`,text:``,reasoning:``};i(o);let s=e=>{o={...o,...e},i(o)};try{await a(e,n,e=>{let t=e.data??{};switch(e.event){case`headers`:s({httpStatus:_n(t.httpStatus),httpMs:_n(t.httpMs),contentType:vn(t.contentType),headers:kn(t.headers)});break;case`delta`:{let e=vn(t.text)??``;vn(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:kn(t.headers)});break}}},r)}catch(e){e?.name===`AbortError`?s({status:`cancelled`,error:null}):s({status:`failed`,error:e instanceof w?e.message:String(e)})}}function kn(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}var An=f({AUTH_OPTIONS:()=>Mn,PROTOCOL_OPTIONS:()=>jn,ProvidersPage:()=>Nn}),jn=[{value:`openai-chat`,label:`OpenAI Chat`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic`,label:`Anthropic Messages`},{value:`gemini`,label:`Gemini`}],Mn=[{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 Nn(){let{t:e}=F(),t=Pe(),[n,r]=Oe(),i=P(),[a,s]=(0,J.useState)(n.get(`new`)===`1`),[c,l]=(0,J.useState)(!1);(0,J.useEffect)(()=>{n.get(`new`)===`1`&&(s(!0),n.delete(`new`),r(n,{replace:!0}))},[n,r]),Be(e=>{e===`new-provider`&&s(!0)});let u=o(`7d`,`day`,`provider`),[d,f]=(0,J.useState)(null),p=(0,J.useMemo)(()=>{let e=Fn(Pn),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)(ze,{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)(z,{icon:(0,X.jsx)(Te,{className:`size-3.5`}),onClick:()=>l(!0),children:e(`providers.import`)}),(0,X.jsx)(z,{variant:`primary`,icon:(0,X.jsx)(Me,{className:`size-3.5`}),onClick:()=>s(!0),children:e(`providers.add`)})]}),children:[(0,X.jsxs)(`div`,{className:`mx-auto max-w-[1100px]`,children:[i.isLoading&&(0,X.jsx)(G,{lines:4}),i.isError&&(0,X.jsx)(U,{tone:`danger`,title:e(`common.error`),children:q(i.error)}),i.data?.length===0&&(0,X.jsx)(`div`,{className:`card`,children:(0,X.jsx)(y,{icon:(0,X.jsx)(ke,{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)(z,{variant:`primary`,icon:(0,X.jsx)(Me,{className:`size-3.5`}),onClick:()=>s(!0),children:e(`providers.add`)}),(0,X.jsx)(z,{icon:(0,X.jsx)(Te,{className:`size-3.5`}),onClick:()=>l(!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)(Rn,{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:c,onOpenChange:l}),(0,X.jsx)(Gn,{open:a,onOpenChange:s,onCreated:e=>t(`/providers/${e.id}`)}),d&&(0,X.jsx)(yn,{provider:d,open:!0,onOpenChange:e=>!e&&f(null)})]})}var Pn=7;function Fn(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 In(e){if(!e)return null;try{return new URL(e).host}catch{return e}}var Ln=e=>e.stopPropagation();function Rn({p:e,days:t,usage:n,onOpen:r,onTest:i}){let{t:a}=F(),o=B(e.id),{toast:c}=ye(),l=[...new Set(e.endpoints.map(e=>e.protocol))],u=!e.hasApiKey&&e.authScheme!==`none`&&e.authScheme!==`oauth-subscription`&&e.authScheme!==`plugin`,d=[e.priceKey?a(`providers.priceKeyShort`,{key:e.priceKey}):null,e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `),f=e.authScheme===`plugin`?a(`providers.card.plugin`):e.authScheme===`oauth-subscription`?a(`providers.card.subscription`):e.authScheme===`none`?a(`providers.card.noAuth`):e.hasApiKey?e.apiKeyMasked??`••••`:a(`providers.noKey`),p=e.enabled?u?{tone:`orange`,label:a(`providers.noKey`)}:{tone:`green`,label:a(`providers.card.active`)}:{tone:`neutral`,label:a(`providers.card.disabled`)},h=n?.requests??t.map(()=>0),g=h.reduce((e,t)=>e+t,0),_=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:l.map(e=>jn.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:O(`transition-[filter,opacity]`,!e.enabled&&`opacity-50 grayscale`),children:(0,X.jsx)(Ue,{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)(H,{tone:p.tone}),p.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:In(e.endpoints[0]?.baseUrl)??`—`}),(0,X.jsx)(`span`,{className:`shrink-0`,children:a(`providers.modelCount`,{count:e.modelCount})})]})]}),meta:(0,X.jsx)(`span`,{className:O(e.hasApiKey&&e.authScheme!==`oauth-subscription`&&`font-mono`),children:f}),status:d||void 0,action:(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,onClick:Ln,children:[(0,X.jsx)(z,{variant:`plain`,size:`sm`,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),"aria-label":a(`providers.test`),title:a(`providers.test`),onClick:i}),(0,X.jsx)(`span`,{className:`ml-1 inline-flex`,children:(0,X.jsx)(ie,{checked:e.enabled,label:a(`common.enabled`),onChange:e=>o.mutate({enabled:e},{onError:e=>c(q(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)(N,{tone:`accent`,children:a(`providers.templateUpdate`)}),e.boundClients.slice(0,_).map(e=>e in Fe?(0,X.jsx)(`span`,{title:Ne(e),className:`inline-flex shrink-0`,children:(0,X.jsx)(Ie,{kind:e,size:18})},e):(0,X.jsx)(N,{tone:`green`,children:e},e)),e.boundClients.length>_&&(0,X.jsxs)(`span`,{title:e.boundClients.slice(_).map(e=>Fe[e]?.name??e).join(`, `),className:`shrink-0 text-[11px] text-[var(--text-muted)]`,children:[`+`,e.boundClients.length-_]})]}),(0,X.jsx)(`div`,{className:`min-h-[32px] [&>div]:mt-1`,onClick:Ln,children:(0,X.jsx)(dn,{provider:e})}),(0,X.jsx)(`div`,{className:`mt-2`,onClick:Ln,children:g>0?(0,X.jsx)(jt,{label:a(`providers.card.requests7d`),data:h,labels:t.map(e=>e.slice(5)),value:s(g,!0),change:m(n?.costUsd??0),width:320,height:28,formatValue:e=>s(e,!0)}):(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(`div`,{className:`text-[13px] text-[var(--text-secondary)]`,children:a(`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:a(`providers.card.noRequests`)})]})})]})}var zn=`plugin:`,Bn=[`recommended`,`official`,`subscription`,`coding`,`cn`,`aggregator`,`inference`,`local`,`custom`],Vn={"openai-chat":`Chat`,"openai-responses":`Responses`,anthropic:`Anthropic`,gemini:`Gemini`},Hn=e=>jn.find(t=>t.value===e)?.label??e,Un=e=>(0,X.jsx)(`span`,{title:e,children:e}),Wn=e=>{let t=/^(.+?)\s*[((]([^()()]+)[))]$/.exec(e);return t?[t[1],t[2]]:[e,null]};function Gn({open:e,onOpenChange:t,onCreated:n}){let{t:r}=F(),{toast:i}=ye(),a=ae(),o=R(),s=h(),c=P(),l=(0,J.useMemo)(()=>new Set((c.data??[]).filter(e=>e.authScheme===`oauth-subscription`&&e.templateId).map(e=>e.templateId)),[c.data]),u=Pe(),[d,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(``),[b,S]=(0,J.useState)(``),[C,w]=(0,J.useState)(``),[T,D]=(0,J.useState)(``),[O,k]=(0,J.useState)(``),[A,M]=(0,J.useState)(`openai-chat`),[N,I]=(0,J.useState)(`bearer`);(0,J.useEffect)(()=>{e||(m(null),_(null),f(``),y(``),S(``),w(``),D(``),k(``))},[e]);let L=(0,J.useMemo)(()=>{let e=d.trim().toLowerCase(),t=(a.data??[]).filter(t=>!e||t.name.toLowerCase().includes(e)||t.id.includes(e));return Bn.map(e=>({category:e,items:t.filter(t=>t.category===e)})).filter(e=>e.items.length)},[a.data,d]),B=(0,J.useMemo)(()=>{let e=d.trim().toLowerCase();return(c.data??[]).filter(t=>t.authScheme===`plugin`&&!t.settings.plugin?.absent&&(!e||t.name.toLowerCase().includes(e)||t.id.includes(e)))},[c.data,d]),V=e=>{m(e),e===`custom`?(y(``),D(``),w(``)):(y(e.name),D(e.priceKey??e.id),w(``),I(e.auth.scheme))},H=()=>{let e=p===`custom`;s.mutate({templateId:e?null:p.id,variantId:C||null,name:v.trim()||null,apiKey:b.trim()||null,priceKey:T,...e?{endpoints:[{protocol:A,baseUrl:O.trim()}],authScheme:N}:{}},{onSuccess:e=>{t(!1),i(r(`providers.created`,{name:e.name}),`success`),n(e)},onError:e=>i(q(e),`error`)})},W=p&&p!==`custom`?p:null,ee=()=>{if(g===`custom`)V(`custom`);else if(g?.startsWith(zn)){let e=B.find(e=>zn+e.id===g);e&&(t(!1),n(e))}else{let e=(a.data??[]).find(e=>e.id===g);e&&!l.has(e.id)&&V(e)}},te=p!==null&&(p===`custom`?/^https?:\/\//.test(O.trim())&&v.trim()!==``:!W.requiresApiKey||b.trim()!==``);return(0,X.jsxs)(ge,{open:e,onOpenChange:t,width:640,title:r(p?`providers.addTitleDetails`:`providers.addTitle`),description:p?W?W.name:r(`providers.custom`):r(`providers.addDetail`),footer:p?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{className:`mr-auto`,variant:`plain`,onClick:()=>m(null),children:r(`common.back`)}),(0,X.jsx)(z,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,X.jsx)(z,{variant:`primary`,disabled:!te,loading:s.isPending,onClick:H,children:r(`providers.create`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,X.jsx)(z,{variant:`primary`,disabled:!g,onClick:ee,children:r(`common.continue`)})]}),children:[(0,X.jsx)(Gt,{className:`mb-6`,label:r(`providers.addTitle`),current:+!!p,steps:[{id:`template`,label:r(`providers.step.template`)},{id:`details`,label:r(`providers.step.details`)}]}),p?(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(j,{label:r(`providers.name`),children:(0,X.jsx)(x,{value:v,onChange:e=>y(e.target.value)})}),W?.variants&&W.variants.length>0&&(0,X.jsx)(j,{label:r(`providers.variant`),children:(0,X.jsx)(xe,{value:C,onChange:e=>{w(e);let t=W.variants?.find(t=>t.id===e);D(t?.priceKey??W.priceKey??W.id)},options:[{value:``,label:r(`providers.variantDefault`)},...W.variants.map(e=>({value:e.id,label:e.name}))]})}),p===`custom`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{label:r(`providers.baseUrl`),hint:r(`providers.baseUrlHint`),children:(0,X.jsx)(x,{value:O,onChange:e=>k(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)(j,{label:r(`providers.protocol`),children:(0,X.jsx)(xe,{value:A,onChange:M,options:jn})}),(0,X.jsx)(j,{label:r(`providers.authScheme`),children:(0,X.jsx)(xe,{value:N,onChange:I,options:Mn})})]})]}),W?.authScheme===`oauth-subscription`?(0,X.jsx)(U,{tone:`info`,title:r(`providers.subscriptionWizardHint`),children:r(`providers.subscriptionWizardDetail`)}):(0,X.jsxs)(`div`,{className:`font-mono`,children:[(0,X.jsx)(Ve,{label:r(`providers.apiKey`),description:r(`providers.apiKeyHint`),autoComplete:`off`,placeholder:`sk-…`,value:b,onChange:e=>S(e.target.value)}),W?.apiKeyUrl&&(0,X.jsx)(`a`,{className:`mt-2 inline-block font-sans text-[12px] text-[var(--accent)]`,href:W.apiKeyUrl,target:`_blank`,rel:`noreferrer`,children:r(`providers.getKey`)})]}),(0,X.jsx)(j,{label:r(`providers.priceKey`),hint:r(`providers.priceKeyHint`),children:(0,X.jsx)(xe,{value:T,onChange:D,options:[{value:``,label:r(`providers.priceKeyNone`)},...(o.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey}))]})}),W&&W.models.length>0&&(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`providers.templateModels`,{count:W.models.length})})]}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(E,{value:d,onChange:f,placeholder:r(`providers.searchTemplates`)}),a.isLoading&&(0,X.jsx)(G,{lines:4}),a.isError&&(0,X.jsx)(U,{tone:`danger`,title:r(`common.error`),children:q(a.error)}),L.map(e=>(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:r(`providers.category.${e.category}`)}),(0,X.jsx)(De,{name:`provider-template`,"aria-label":r(`providers.category.${e.category}`),density:`compact`,minColumnWidth:168,value:e.items.some(e=>e.id===g)?g:null,onValueChange:_,options:e.items.map(e=>{let t=[...new Set(e.endpoints.map(e=>e.protocol))],[n,i]=Wn(e.name);return{value:e.id,label:(0,X.jsx)(`span`,{title:e.name,children:n}),description:(0,X.jsx)(`span`,{title:t.map(Hn).join(` · `),children:i??t.map(e=>Vn[e]).join(` · `)}),icon:(0,X.jsx)(Ue,{name:e.name,icon:e.icon,colorKey:e.id,size:28}),disabled:l.has(e.id),disabledReason:Un(r(`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:r(`providers.category.plugin`)}),B.length>0?(0,X.jsx)(De,{name:`provider-template-plugin`,"aria-label":r(`providers.category.plugin`),density:`compact`,minColumnWidth:168,value:g?.startsWith(zn)?g:null,onValueChange:_,options:B.map(e=>({value:zn+e.id,label:Un(e.name),description:Un(r(`providers.pluginProvided`)),icon:(0,X.jsx)(Ue,{name:e.name,icon:e.icon,colorKey:e.id,size:28})}))}):(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:r(`providers.pluginHint`)}),(0,X.jsx)(z,{size:`sm`,onClick:()=>{t(!1),u(`/plugins/market`)},children:r(`plugins.browseMarket`)})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:r(`providers.custom`)}),(0,X.jsx)(De,{name:`provider-template-custom`,"aria-label":r(`providers.custom`),layout:`list`,density:`compact`,value:g===`custom`?`custom`:null,onValueChange:_,options:[{value:`custom`,label:r(`providers.custom`),description:r(`providers.customDetail`),icon:(0,X.jsx)(`span`,{className:`inline-flex size-7 items-center justify-center rounded-[8px] border border-dashed border-[var(--border-strong)] text-[var(--text-secondary)]`,children:(0,X.jsx)(Me,{className:`size-4`})})}]})]})]})]})}export{ln as a,yn as i,jn as n,Ye as o,An as r,Mn as t};