@aidotnet/server-linux-arm64 0.8.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/bin/astra-server +2 -2
  2. package/bin/wwwroot/assets/ClientsPage-Cwjn83RD.js +11 -0
  3. package/bin/wwwroot/assets/KeyPage-IsBY88jG.js +1 -0
  4. package/bin/wwwroot/assets/ModelDetailPage-BT8_QmLF.js +1 -0
  5. package/bin/wwwroot/assets/ModelsPage-a3SNBXwe.js +1 -0
  6. package/bin/wwwroot/assets/PluginsPage-CXRMCp_F.js +2 -0
  7. package/bin/wwwroot/assets/PrivacyPage-BfdLDJ63.js +1 -0
  8. package/bin/wwwroot/assets/ProviderDetailPage-C9eabWwn.js +3 -0
  9. package/bin/wwwroot/assets/ProvidersPage-CPw-h0Uz.js +2 -0
  10. package/bin/wwwroot/assets/SettingsPage-CTnL166S.js +2 -0
  11. package/bin/wwwroot/assets/TokensPage-TPaxzBMY.js +1 -0
  12. package/bin/wwwroot/assets/TrayPanelPage-BGDBeJs0.js +1 -0
  13. package/bin/wwwroot/assets/TrayPanelView-DP-m1Cui.js +1 -0
  14. package/bin/wwwroot/assets/alert-C-zJo-Vf.js +15 -0
  15. package/bin/wwwroot/assets/{overlays-Cnf3vGpI.css → alert-DwSJjne8.css} +1 -1
  16. package/bin/wwwroot/assets/arrow-down-DTsCyVhl.js +1 -0
  17. package/bin/wwwroot/assets/arrow-left-BlStTg-u.js +1 -0
  18. package/bin/wwwroot/assets/checkbox-B8UTLROZ.js +1 -0
  19. package/bin/wwwroot/assets/cloud-download-DoCH2MAL.js +1 -0
  20. package/bin/wwwroot/assets/confirm-morph-BZdvZ-wI.js +1 -0
  21. package/bin/wwwroot/assets/download-zacBMjpe.js +1 -0
  22. package/bin/wwwroot/assets/ellipsis-Dwk6_QlF.js +1 -0
  23. package/bin/wwwroot/assets/external-link-D-L32_ye.js +1 -0
  24. package/bin/wwwroot/assets/folder-open-ex39110T.js +1 -0
  25. package/bin/wwwroot/assets/index-CNdW2eN9.js +17 -0
  26. package/bin/wwwroot/assets/index-DSv7xAxU.css +1 -0
  27. package/bin/wwwroot/assets/log-out-CZSB5kqp.js +1 -0
  28. package/bin/wwwroot/assets/overlays-BBHZHl4R.js +41 -0
  29. package/bin/wwwroot/assets/overlays-BJrN5PWt.css +1 -0
  30. package/bin/wwwroot/assets/paseo-B9ieOk6E.png +0 -0
  31. package/bin/wwwroot/assets/pencil-C7HWLb95.js +1 -0
  32. package/bin/wwwroot/assets/power-BggG52OJ.js +1 -0
  33. package/bin/wwwroot/assets/radio-cards-BWCaBwfU.js +1 -0
  34. package/bin/wwwroot/assets/rotate-ccw-Xx5_g9bd.js +1 -0
  35. package/bin/wwwroot/index.html +6 -8
  36. package/package.json +1 -1
  37. package/bin/wwwroot/assets/ClientsPage-B89Sa7jz.js +0 -11
  38. package/bin/wwwroot/assets/ModelDetailPage-CIr2VLVH.js +0 -1
  39. package/bin/wwwroot/assets/ModelsPage-DHoSwTY5.js +0 -1
  40. package/bin/wwwroot/assets/Page-CnSErb_N.js +0 -3
  41. package/bin/wwwroot/assets/Page-CsiaycmK.css +0 -1
  42. package/bin/wwwroot/assets/PluginsPage-54tF_bjG.js +0 -2
  43. package/bin/wwwroot/assets/PrivacyPage-D5paxuYA.js +0 -1
  44. package/bin/wwwroot/assets/ProviderDetailPage-DhxcWbc_.js +0 -3
  45. package/bin/wwwroot/assets/ProvidersPage-DfMcnoYT.js +0 -2
  46. package/bin/wwwroot/assets/SettingsPage-a1XhJ-l9.js +0 -1
  47. package/bin/wwwroot/assets/TokensPage-T2w5pi_o.js +0 -1
  48. package/bin/wwwroot/assets/TrayPanelPage-DOmKXJLy.js +0 -1
  49. package/bin/wwwroot/assets/TrayPanelView-BcmaqvCD.js +0 -1
  50. package/bin/wwwroot/assets/arrow-down-CXkFrvO0.js +0 -1
  51. package/bin/wwwroot/assets/arrow-up-BfREUNOR.js +0 -1
  52. package/bin/wwwroot/assets/checkbox-RGYPqY5w.js +0 -1
  53. package/bin/wwwroot/assets/cloud-download-D865MmmV.js +0 -1
  54. package/bin/wwwroot/assets/confirm-morph-DUNuG_Io.js +0 -1
  55. package/bin/wwwroot/assets/download-CMr38kbd.js +0 -1
  56. package/bin/wwwroot/assets/ellipsis-zTWIrsa4.js +0 -1
  57. package/bin/wwwroot/assets/external-link-BSHuW87X.js +0 -1
  58. package/bin/wwwroot/assets/folder-open-Ce_7X0wN.js +0 -1
  59. package/bin/wwwroot/assets/index-PfVyiY3J.js +0 -15
  60. package/bin/wwwroot/assets/index-uU60OHOr.css +0 -1
  61. package/bin/wwwroot/assets/log-out-CXVs8bJY.js +0 -1
  62. package/bin/wwwroot/assets/overlays-D1ZtG8Qn.js +0 -55
  63. package/bin/wwwroot/assets/pencil-DyidL-8l.js +0 -1
  64. package/bin/wwwroot/assets/power-CJZylS33.js +0 -1
  65. package/bin/wwwroot/assets/radio-cards-QHFaDooy.js +0 -1
  66. package/bin/wwwroot/assets/rotate-ccw-Dr0Xbikv.js +0 -1
  67. package/bin/wwwroot/assets/use-transform-DvOb1h9g.js +0 -1
@@ -1 +0,0 @@
1
- import{B as e,Cn as t,F as n,Fa as r,G as i,Gr as a,H as o,Hr as s,Ia as c,J as l,K as u,Kn as d,N as f,P as p,Pi as m,Tn as h,Ur as g,V as _,Wr as v,X as y,Y as b,Z as x,a as S,dn as C,dt as ee,i as w,ia as T,na as E,nt as D,o as O,oa as k,q as A,r as j,ra as M,rt as N,sa as P,ta as F,un as te,ut as ne,z as re,za as ie}from"./overlays-D1ZtG8Qn.js";import{t as I}from"./use-transform-DvOb1h9g.js";import{b as ae,i as L,p as R,s as oe,t as se,x as ce}from"./Page-CnSErb_N.js";import{C as le,E as ue,S as z,T as de,_ as B,b as V,c as fe,g as pe,k as me,r as he,u as ge,v as _e,y as ve}from"./index-PfVyiY3J.js";var ye={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};ye.node;var be=ee(ye),H=ie(c(),1),U={toolbar:`_toolbar_1p5c5_1`,leading:`_leading_1p5c5_2`,frame:`_frame_1p5c5_4`,chips:`_chips_1p5c5_5`,slot:`_slot_1p5c5_7`,chip:`_chip_1p5c5_5`,chipLabel:`_chipLabel_1p5c5_10`,value:`_value_1p5c5_11`,separator:`_separator_1p5c5_12`,morphText:`_morphText_1p5c5_13`,morphValue:`_morphValue_1p5c5_14`,measure:`_measure_1p5c5_15`,empty:`_empty_1p5c5_18`,actions:`_actions_1p5c5_19`,clear:`_clear_1p5c5_20`,clearText:`_clearText_1p5c5_21`,srOnly:`_srOnly_1p5c5_23`,menu:`_menu_1p5c5_27`,trigger:`_trigger_1p5c5_29`,face:`_face_1p5c5_31`,surface:`_surface_1p5c5_34`,panel:`_panel_1p5c5_42`,head:`_head_1p5c5_45`,back:`_back_1p5c5_47`,title:`_title_1p5c5_49`,titleText:`_titleText_1p5c5_50`,stage:`_stage_1p5c5_51`,step:`_step_1p5c5_52`,list:`_list_1p5c5_53`,highlight:`_highlight_1p5c5_54`,item:`_item_1p5c5_55`,itemIcon:`_itemIcon_1p5c5_57`,itemLabel:`_itemLabel_1p5c5_58`,itemMeta:`_itemMeta_1p5c5_59`,metaValue:`_metaValue_1p5c5_60`,hint:`_hint_1p5c5_61`,check:`_check_1p5c5_62`,noOptions:`_noOptions_1p5c5_64`},W=r(),G={duration:D.duration.standard,ease:[...D.ease.enter]},K={duration:D.duration.instant,ease:[...D.ease.standard]},q={duration:0},xe={duration:D.duration.instant,ease:[...D.ease.standard]},J=e=>`blur(${e}px)`,Se=e=>Math.min(1,Math.max(0,e)),Ce=e=>typeof e==`string`?{value:e}:e,we=e=>e.label??e.value,Te=e=>({initial:e?{opacity:0}:{opacity:0,y:`0.3em`,filter:J(D.blur.soft)},animate:{opacity:1,y:0,filter:J(0)},exit:e?{opacity:0,transition:q}:{opacity:0,y:`-0.3em`,filter:J(D.blur.subtle),transition:K},transition:e?xe:G});function Ee({text:e}){let t=M()??!1,n=(0,H.useRef)(null),r=T(`auto`);return(0,H.useLayoutEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let i=null,a=new ResizeObserver(([n])=>{let a=Math.ceil(n.borderBoxSize?.[0]?.inlineSize??e.offsetWidth),o=i!==null&&i!==e.textContent;i=e.textContent,o&&!t?E(r,a,D.spring.morph):r.jump(a)});return a.observe(e),()=>a.disconnect()},[t,r]),(0,W.jsxs)(F.span,{className:U.morphText,style:{width:r},children:[(0,W.jsx)(`span`,{ref:n,className:U.measure,"aria-hidden":`true`,children:e}),(0,W.jsx)(k,{mode:`popLayout`,initial:!1,children:(0,W.jsx)(F.span,{className:U.morphValue,...Te(t),children:e},e)})]})}function De(e,t,n){let r=T(`auto`);return(0,H.useLayoutEffect)(()=>{let i=e.current;if(!i||typeof ResizeObserver>`u`)return;let a=!1,o=new ResizeObserver(()=>{let e=i.offsetHeight;if(!a||n||performance.now()>t.current){a=!0,r.jump(e);return}E(r,e,D.spring.smooth)});return o.observe(i),()=>o.disconnect()},[t,r,e,n]),r}function Oe(e,t,n){(0,H.useLayoutEffect)(()=>{let r=e.current;if(!r||typeof ResizeObserver>`u`)return;let i=new Map,a=()=>{let e=performance.now();for(let a of Array.from(r.children)){let r=a.offsetLeft,o=a.offsetTop,s=i.get(a);if(!s){i.set(a,{x:r,y:o,dx:0,dy:0});continue}let c=s.x-r,l=s.y-o;if(s.x=r,s.y=o,n||e>t.current||Math.abs(l)<1&&Math.abs(c)<40)continue;s.stop?.();let u=s.dx+c,d=s.dy+l,f=e=>{s.dx=u*(1-e),s.dy=d*(1-e),a.style.translate=e>=1?``:`${s.dx}px ${s.dy}px`};f(0),s.stop=E(0,1,{...D.spring.smooth,onUpdate:f,onComplete:()=>f(1)}).stop}for(let e of i.keys())e.parentElement!==r&&i.delete(e)},o=new ResizeObserver(a),s=()=>{for(let e of Array.from(r.children))o.observe(e)},c=new MutationObserver(()=>{s(),a()});return o.observe(r),s(),c.observe(r,{childList:!0}),()=>{o.disconnect(),c.disconnect();for(let e of i.values())e.stop?.()}},[t,e,n])}var Y=e=>e.valueLabel??e.value,X=e=>Y(e)?`${e.label}: ${Y(e)}`:e.label,ke={empty:`No filters applied`,clearAll:`Clear all`,back:`Back to fields`,noOptions:`No options available`,cleared:`All filters cleared`,remove:e=>`Remove ${X(e)}`,added:e=>`Added ${X(e)}`,changed:e=>`Changed ${X(e)}`,removed:e=>`Removed ${X(e)}`};function Ae(e,t,n){let r=e.filter(e=>!t.some(t=>t.id===e.id));if(!t.length&&r.length>1)return n.cleared;let i=t.filter(t=>!e.some(e=>e.id===t.id)),a=t.filter(t=>e.some(e=>e.id===t.id&&e.value!==t.value));return[...i.map(n.added),...a.map(n.changed),...r.map(n.removed)].join(`. `)}function je({rows:e,labelledBy:t,onChoose:n,onBack:r,onLeave:i,radio:a,emptyMessage:o}){let s=M()??!1,c=P(),l=(0,H.useRef)(null),u=(0,H.useRef)(!1),d=(0,H.useRef)({text:``,at:0}),[f,p]=(0,H.useState)(()=>Math.max(0,e.findIndex(e=>e.checked))),[m,h]=(0,H.useState)(null),g=()=>Array.from(l.current?.querySelectorAll(`[data-row]`)??[]),_=e=>{let t=l.current;e&&t&&(e.focus({preventScroll:!0}),e.offsetTop<t.scrollTop?t.scrollTop=e.offsetTop:e.offsetTop+e.offsetHeight>t.scrollTop+t.clientHeight&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight))};function v(t){let i=g(),a=i.indexOf(document.activeElement),o=e=>{t.preventDefault(),u.current=!1,_(i[e])};if(t.key===`ArrowDown`)return o(a<0?0:(a+1)%i.length);if(t.key===`ArrowUp`)return o(a<0?i.length-1:(a-1+i.length)%i.length);if(t.key===`Home`)return o(0);if(t.key===`End`)return o(i.length-1);if(t.key===`ArrowRight`&&a>=0&&e[a]?.drill){t.preventDefault(),n(e[a],!0);return}if(t.key===`ArrowLeft`&&r){t.preventDefault(),r(!0);return}if(t.key.length===1&&/\S/.test(t.key)&&!t.metaKey&&!t.ctrlKey&&!t.altKey){let e=performance.now();d.current={text:e-d.current.at<700?d.current.text+t.key.toLowerCase():t.key.toLowerCase(),at:e};let n=[...i.slice(a+(d.current.text.length>1?0:1)),...i.slice(0,a+(d.current.text.length>1?0:1))].find(e=>(e.dataset.text??``).toLowerCase().startsWith(d.current.text));n&&o(i.indexOf(n))}}function y(e){let t=e.target.closest(`[data-row]`);if(!t)return;p(g().indexOf(t));let n=u.current&&!s,r=!u.current&&t.matches(`:focus-visible`);h(e=>({top:t.offsetTop,height:t.offsetHeight,glide:n&&!!e?.shown,ring:r,shown:!0}))}function b(e){l.current?.contains(e.relatedTarget)||h(e=>e&&{...e,glide:!1,ring:!1,shown:!1})}return(0,W.jsxs)(`div`,{ref:l,className:U.list,role:`menu`,"aria-labelledby":t,"data-current":c?``:void 0,onKeyDown:v,onFocus:y,onBlur:b,onPointerLeave:()=>{u.current&&l.current?.contains(document.activeElement)&&i()},children:[(0,W.jsx)(F.span,{className:U.highlight,"data-ring":m?.ring||void 0,"aria-hidden":`true`,initial:!1,animate:m?{y:m.top,height:m.height,opacity:+!!m.shown}:{opacity:0},transition:{default:m?.glide?D.spring.snappy:q,opacity:{duration:s?0:.08}}}),e.length===0?(0,W.jsx)(`p`,{className:U.noOptions,children:o}):null,e.map((e,t)=>(0,W.jsxs)(`button`,{type:`button`,className:U.item,role:a?`menuitemradio`:`menuitem`,"aria-checked":a?!!e.checked:void 0,tabIndex:t===f?0:-1,"data-row":e.key,"data-text":e.label,onPointerMove:e=>{u.current=!0,document.activeElement!==e.currentTarget&&e.currentTarget.focus({preventScroll:!0})},onClick:t=>n(e,t.detail===0),children:[e.icon?(0,W.jsx)(`span`,{className:U.itemIcon,"aria-hidden":`true`,children:e.icon}):null,(0,W.jsx)(`span`,{className:U.itemLabel,children:e.label}),e.meta?(0,W.jsx)(`span`,{className:U.itemMeta,children:e.meta}):null]},e.key))]})}function Me(e){let t={left:0,top:0,right:document.documentElement.clientWidth,bottom:window.innerHeight};for(let n=e.parentElement;n&&n!==document.body;n=n.parentElement){let e=getComputedStyle(n);if(e.overflowX===`visible`&&e.overflowY===`visible`)continue;let r=n.getBoundingClientRect();e.overflowX!==`visible`&&(t.left=Math.max(t.left,r.left),t.right=Math.min(t.right,r.right)),e.overflowY!==`visible`&&(t.top=Math.max(t.top,r.top),t.bottom=Math.min(t.bottom,r.bottom))}return t}function Ne({fields:e,onSelect:t,active:n=[],label:r=`Add filter`,align:i=`end`,messages:a}){let o={...ke,...a},s=M()??!1,c=(0,H.useId)(),l=`${c}panel`,u=`${c}title`,d=(0,H.useRef)(null),f=(0,H.useRef)(null),p=(0,H.useRef)(null),m=(0,H.useRef)(`closed`),h=(0,H.useRef)(0),g=(0,H.useRef)(null),[_,v]=(0,H.useState)(`closed`),[y,b]=(0,H.useState)(null),[x,S]=(0,H.useState)(1),[C,ee]=(0,H.useState)(!1),[w,O]=(0,H.useState)(`100% 0`),A=T(`100%`),j=T(`100%`),N=T(0),P=T(0),te=I(()=>P.get()-N.get()),re=T(0),ie=T(0),ae=I(()=>{let e=A.get(),t=re.get(),n=ie.get();return typeof e==`number`?n>t?Se((e-t)/(n-t)):1:0}),L=I(()=>Se(ae.get()/.35)),R=I(()=>Se((ae.get()-.4)/.5)),se={opacity:I(()=>1-L.get()),scale:I(()=>1-L.get()*.04),filter:I(()=>L.get()?J(L.get()*D.blur.subtle):`none`)},ce={opacity:R,transformOrigin:w,scale:I(()=>.96+R.get()*.04),y:I(()=>(1-R.get())*(C?-6:6)),filter:I(()=>R.get()===1?`none`:J((1-R.get())*D.blur.soft))},le=_===`open`,z=e.find(e=>e.id===y)??null,B=(0,H.useCallback)(e=>{let t=f.current,n=p.current;if(!t||!n)return;let r=t.getBoundingClientRect(),a=n.offsetWidth+2,o=n.offsetHeight+2,c=Me(d.current??t),l=c.left+16-r.left,u=c.right-16-r.left-a,_=r.width-a,y=i===`end`?_>=l?_:0<=u?0:_:0<=u?0:_>=l?_:0;y=Math.round(Math.min(Math.max(y,l),Math.max(l,u)));let x=c.bottom-r.top,C=r.bottom-c.top,w=x<o+16&&C>x;m.current===`closed`&&(A.jump(r.width),j.jump(r.height),N.jump(0)),P.jump(y),re.jump(r.width),ie.jump(a),m.current=`open`,h.current+=1,g.current=e,v(`open`),ee(w),b(null),S(-1),O(`${Math.round(r.width/2-y)}px ${w?`100%`:`0`}`);let T=s?q:D.spring.morph;E(N,y,T),E(A,a,T),E(j,o,T)},[i,re,j,N,s,P,ie,A]),V=(0,H.useCallback)(e=>{let t=f.current;if(m.current!==`open`||!t)return;m.current=`closing`;let n=h.current+=1;v(`closing`),e&&t.focus({preventScroll:!0,focusVisible:e===`keyboard`});let r=s?q:D.spring.snappy;E(N,0,r);let i=t.getBoundingClientRect();E(j,i.height,r),E(A,i.width,{...r,onComplete:()=>{n===h.current&&(m.current=`closed`,A.jump(`100%`),j.jump(`100%`),v(`closed`),b(null))}})},[j,N,s,A]);(0,H.useLayoutEffect)(()=>{let e=p.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{m.current===`open`&&E(j,e.offsetHeight+2,s?q:D.spring.smooth)});return t.observe(e),()=>t.disconnect()},[j,s]),(0,H.useLayoutEffect)(()=>{let e=g.current,t=p.current;if(!e||!t||_!==`open`)return;if(g.current=null,e===`panel`){t.focus({preventScroll:!0});return}let n=Array.from(t.querySelectorAll(`[data-current] [data-row]`));(e===`first`?n[0]:e===`last`?n.at(-1):e===`checked`?n.find(e=>e.getAttribute(`aria-checked`)===`true`)??n[0]:n.find(t=>t.dataset.row===e.key)??n[0])?.focus({preventScroll:!0})},[_,y]),(0,H.useEffect)(()=>{if(_!==`open`)return;let e=e=>{let t=d.current,n=e.target;!t||n&&t.contains(n)||(V(!1),n?.closest?.(`button, a[href], input, select, textarea, [tabindex], [contenteditable]`)||window.setTimeout(()=>{let e=document.activeElement;(!e||e===document.body||t.contains(e))&&f.current?.focus({preventScroll:!0,focusVisible:!1})},0))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[V,_]);function fe(e){if(e.defaultPrevented)return;let t=Array.from(p.current?.querySelectorAll(`[data-current] [data-row]`)??[]);(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),(e.key===`ArrowDown`?t[0]:t.at(-1))?.focus({preventScroll:!0})),e.key===`ArrowLeft`&&z&&(e.preventDefault(),pe(!0))}function pe(e){z&&(g.current=e?{key:z.id}:`panel`,S(-1),b(null))}function me(e,t){g.current=t?`checked`:`panel`,S(1),b(e.key)}function he(e,n){z&&(t({id:z.id,label:z.label,value:e.key,valueLabel:e.label},z),V(n?`keyboard`:`pointer`))}let ge=e=>n.find(t=>t.id===e.id),_e=e.map(e=>({key:e.id,label:e.label,icon:e.icon,drill:!0,meta:(0,W.jsxs)(W.Fragment,{children:[ge(e)?(0,W.jsx)(`span`,{className:U.metaValue,children:Y(ge(e))}):null,(0,W.jsx)(de,{size:15,strokeWidth:1.8,"aria-hidden":`true`})]})})),ve=z?z.options.map(Ce).map(e=>{let t=we(e),n=ge(z)?.value===e.value;return{key:e.value,label:t,icon:e.icon,checked:n,meta:e.hint!=null||n?(0,W.jsxs)(W.Fragment,{children:[e.hint==null?null:(0,W.jsx)(`span`,{className:U.hint,children:e.hint}),(0,W.jsx)(`span`,{className:U.check,"data-on":n||void 0,children:(0,W.jsx)(ne,{size:15,strokeWidth:2,"aria-hidden":`true`})})]}):null}}):[],ye={enter:e=>s?{opacity:0}:{opacity:0,x:e*18,filter:J(D.blur.soft)},center:{opacity:1,x:0,filter:J(0),transition:s?xe:{...G,x:D.spring.smooth}},exit:e=>s?{opacity:0,transition:q}:{opacity:0,x:e*-18,filter:J(D.blur.subtle),transition:K}};return(0,W.jsxs)(`div`,{ref:d,className:U.menu,"data-state":_,"data-y":C?`up`:`down`,onKeyDown:e=>{e.key===`Escape`&&m.current===`open`&&(e.preventDefault(),e.stopPropagation(),V(`keyboard`))},onBlur:e=>{let t=e.relatedTarget;m.current===`open`&&t&&!d.current?.contains(t)&&V(!1)},children:[(0,W.jsx)(`button`,{ref:f,type:`button`,className:U.trigger,"data-filter-trigger":``,"aria-haspopup":`dialog`,"aria-expanded":le,"aria-controls":l,tabIndex:le?-1:void 0,onClick:e=>{m.current!==`open`&&B(e.detail===0?`first`:`panel`)},onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),B(e.key===`ArrowDown`?`first`:`last`))},children:(0,W.jsxs)(F.span,{className:U.face,style:se,children:[(0,W.jsx)(oe,{size:15,strokeWidth:1.8,"aria-hidden":`true`}),r]})}),(0,W.jsx)(F.div,{className:U.surface,style:{left:N,width:A,height:j},children:(0,W.jsx)(F.div,{ref:p,id:l,className:U.panel,role:`dialog`,"aria-labelledby":u,tabIndex:-1,inert:!le,style:{x:te},onKeyDown:fe,children:(0,W.jsxs)(F.div,{style:ce,children:[(0,W.jsxs)(`div`,{className:U.head,children:[(0,W.jsx)(k,{initial:!1,children:z?(0,W.jsx)(F.button,{type:`button`,className:U.back,"aria-label":o.back,onClick:e=>pe(e.detail===0),initial:s?{opacity:0,width:28,marginRight:2}:{opacity:0,width:0,marginRight:0,scale:.6},animate:{opacity:1,width:28,marginRight:2,scale:1},exit:s?{opacity:0,transition:q}:{opacity:0,width:0,marginRight:0,scale:.6,transition:{...D.spring.snappy,opacity:K}},transition:s?xe:{...D.spring.snappy,opacity:G},children:(0,W.jsx)(ue,{size:16,strokeWidth:1.8,"aria-hidden":`true`})},`back`):null}),(0,W.jsx)(`span`,{className:U.title,id:u,children:(0,W.jsx)(k,{mode:`popLayout`,initial:!1,children:(0,W.jsx)(F.span,{className:U.titleText,...Te(s),children:z?z.label:r},z?.id??`fields`)})})]}),(0,W.jsx)(`div`,{className:U.stage,children:(0,W.jsx)(k,{mode:`popLayout`,initial:!1,custom:x,children:(0,W.jsx)(F.div,{className:U.step,custom:x,variants:ye,initial:`enter`,animate:`center`,exit:`exit`,children:z?(0,W.jsx)(je,{rows:ve,labelledBy:u,emptyMessage:o.noOptions,radio:!0,onChoose:he,onBack:pe,onLeave:()=>p.current?.focus({preventScroll:!0})}):(0,W.jsx)(je,{rows:_e,labelledBy:u,emptyMessage:o.noOptions,onChoose:me,onLeave:()=>p.current?.focus({preventScroll:!0})})},z?.id??`fields`)})})]})})})]})}function Pe({filters:e,onRemove:t,onClearAll:n,leading:r,children:i,label:a=`Active filters`,addFilter:o,messages:s}){let c={...ke,...s},l=M()??!1,u=(0,H.useRef)(null),d=(0,H.useRef)(null),f=(0,H.useRef)(0),p=(0,H.useRef)(null),[m,h]=(0,H.useState)(e),[g,_]=(0,H.useState)(``);if(m!==e){h(e);let t=Ae(m,e,c);t&&_(t)}let v=e.map(e=>`${e.id}:${e.value??``}`).join(`|`);(0,H.useLayoutEffect)(()=>{f.current=performance.now()+900},[v]);let y=De(d,f,l);Oe(d,f,l),(0,H.useLayoutEffect)(()=>{let t=p.current,n=u.current;if(t===null||!n)return;p.current=null;let r=e[Math.min(t,e.length-1)];(r?n.querySelector(`[data-chip-remove="${CSS.escape(r.id)}"]`):n.querySelector(`[data-filter-trigger]`))?.focus({preventScroll:!0})},[e]);let b={duration:0},x=e=>({initial:!l&&{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1},animate:{width:`auto`,marginRight:0,transitionEnd:{overflow:`visible`,"--slot-moving":0}},exit:l?{opacity:0,transition:b}:{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1,pointerEvents:`none`,transition:{...D.spring.smooth,"--slot-moving":b}},transition:l?b:D.spring.smooth}),S={initial:!l&&{opacity:0,scale:.9,filter:J(D.blur.soft)},animate:{opacity:1,scale:1,filter:J(0)},exit:l?{opacity:0,transition:b}:{opacity:0,scale:.9,filter:J(D.blur.subtle),transition:K},transition:l?b:{...G,scale:D.spring.snappy}},C=l?{...Te(!0),initial:!1}:Te(!1),ee=l?C:{...C,transition:{...G,delay:D.duration.instant*.75}};return(0,W.jsxs)(`div`,{ref:u,className:U.toolbar,role:`group`,"aria-label":a,children:[r?(0,W.jsx)(`div`,{className:U.leading,children:r}):null,(0,W.jsx)(F.div,{className:U.frame,style:{height:y},children:(0,W.jsxs)(`div`,{ref:d,className:U.chips,children:[(0,W.jsx)(k,{initial:!1,children:e.map((e,n)=>(0,W.jsx)(F.span,{className:U.slot,...x(8),children:(0,W.jsxs)(F.span,{className:U.chip,...S,children:[(0,W.jsxs)(`span`,{className:U.chipLabel,title:X(e),children:[e.label,Y(e)?(0,W.jsxs)(`span`,{className:U.value,children:[(0,W.jsx)(`span`,{className:U.separator,children:` · `}),(0,W.jsx)(Ee,{text:Y(e)})]}):null]}),(0,W.jsx)(`button`,{type:`button`,"data-chip-remove":e.id,"aria-label":c.remove(e),onClick:r=>{document.activeElement===r.currentTarget&&(p.current=n),t(e.id)},children:(0,W.jsx)(N,{size:14,strokeWidth:1.8,"aria-hidden":`true`})})]})},e.id))}),(0,W.jsx)(k,{initial:!1,children:e.length?null:(0,W.jsx)(F.span,{className:U.empty,...ee,children:c.empty},`empty`)})]})}),(0,W.jsxs)(`div`,{className:U.actions,children:[o?(0,W.jsx)(Ne,{fields:o.fields,onSelect:o.onAdd,active:e,label:o.label,align:o.align,messages:c}):null,i,(0,W.jsx)(k,{initial:!1,children:e.length>0&&n?(0,W.jsx)(F.span,{className:U.slot,...x(12),children:(0,W.jsx)(`button`,{className:U.clear,type:`button`,onClick:()=>{p.current=-1,n?.()},children:(0,W.jsx)(F.span,{className:U.clearText,...C,children:c.clearAll})})},`clear`):null})]}),(0,W.jsx)(`span`,{className:U.srOnly,role:`status`,children:g})]})}var Fe={api_key:`settings.privacy.category.api_key`,aws_key:`settings.privacy.category.aws_key`,jwt:`settings.privacy.category.jwt`,private_key:`settings.privacy.category.private_key`,email:`settings.privacy.category.email`,phone:`settings.privacy.category.phone`,intranet:`settings.privacy.category.intranet`,credit_card:`settings.privacy.category.credit_card`,national_id:`settings.privacy.category.national_id`,credential:`settings.privacy.category.credential`,custom:`settings.privacy.category.custom`},Ie={warn:`settings.privacy.action.warn`,block:`settings.privacy.action.block`,redact:`settings.privacy.action.redact`};function Z(){let{t:e}=h();return t=>{let n=Fe[t];return n?e(n):t}}function Le({action:e}){let{t}=h();return(0,W.jsx)(p,{tone:e===`block`?`red`:e===`redact`?`orange`:`neutral`,children:t(Ie[e]??`settings.privacy.action.warn`)})}var Re=50,ze=[`block`,`redact`,`warn`];function Be(){let{t:e,locale:r}=h(),i=Z(),[o,c]=(0,H.useState)(``),[l,p]=(0,H.useState)({client:``,category:``,action:``,blocked:``}),[m,g]=(0,H.useState)(1),[_,v]=(0,H.useState)(null),y=R(o),x=d(),ee=s(),w={model:y,...l,page:m,pageSize:Re},T=a(w,m===1),E=T.data,D=E?Math.max(1,Math.ceil(E.total/Re)):1,O=e=>e?ge[e]?.name??e:`—`,k=[...new Set((ee.data?.rules??[]).map(e=>e.category))],A={client:(x.data??[]).map(e=>({value:e.kind,label:e.name})),category:k.map(e=>({value:e,label:i(e)})),action:ze.map(t=>({value:t,label:e(`settings.privacy.action.${t}`)})),blocked:[{value:`true`,label:e(`privacy.logs.blockedOnly`)},{value:`false`,label:e(`privacy.logs.passedOnly`)}]},j={client:e(`requests.col.client`),category:e(`privacy.stats.col.category`),action:e(`privacy.logs.col.action`),blocked:e(`privacy.logs.col.outcome`)},M=Object.keys(A).map(e=>({id:e,label:j[e],options:A[e].map(e=>e.label)})),N=Object.keys(l).filter(e=>l[e]).map(e=>({id:e,label:j[e],value:A[e].find(t=>t.value===l[e])?.label??l[e]})),P=(e,t)=>{p(n=>({...n,[e]:t})),g(1)},F=(E?.items??[]).map(e=>({id:e.id,time:Date.parse(e.startedAtUtc),client:O(e.clientKind),model:e.requestedModel??``,outcome:Ve(e),hits:e.hits.reduce((e,t)=>e+t.count,0),e})),ne=[{key:`time`,label:e(`requests.col.time`),width:92,render:(e,t)=>(0,W.jsx)(`span`,{className:`num`,children:te(t.e.startedAtUtc,r)})},{key:`model`,label:e(`requests.col.model`),render:(t,n)=>(0,W.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>v(n.id),"aria-label":e(`privacy.logs.viewRequest`,{model:n.model||n.id}),children:[(0,W.jsx)(`span`,{className:`block truncate font-medium hover:text-[var(--accent)]`,children:n.model||`—`}),(0,W.jsx)(`span`,{className:`block truncate text-[11px] text-[var(--text-muted)]`,children:O(n.e.clientKind)})]})},{key:`outcome`,label:e(`privacy.logs.col.outcome`),width:130,render:(e,t)=>(0,W.jsx)(He,{event:t.e})},{key:`hits`,label:e(`privacy.logs.col.hits`),render:(e,t)=>(0,W.jsx)(Ue,{event:t.e})},{key:`client`,label:e(`requests.col.client`),width:110,render:e=>(0,W.jsx)(`span`,{className:`block truncate`,children:String(e||`—`)})}];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,W.jsx)(u,{className:`w-52`,value:o,onChange:e=>{c(e),g(1)},placeholder:e(`requests.searchModel`)}),(0,W.jsx)(n,{variant:`plain`,icon:(0,W.jsx)(le,{className:t(`size-4`,T.isFetching&&`animate-spin`)}),"aria-label":e(`common.refresh`),onClick:()=>void T.refetch()})]}),(0,W.jsx)(`div`,{className:`mb-3`,children:(0,W.jsx)(Pe,{label:e(`requests.filters`),filters:N,onRemove:e=>P(e,``),onClearAll:()=>{p({client:``,category:``,action:``,blocked:``}),g(1)},addFilter:{fields:M,label:e(`requests.addFilter`),onAdd:e=>{let t=e.id,n=A[t].find(t=>t.label===e.value)?.value;n&&P(t,n)}}})}),T.isLoading&&(0,W.jsx)(b,{lines:4,className:`py-6`}),T.isError&&(0,W.jsx)(f,{tone:`danger`,title:e(`common.error`),children:S(T.error)}),E&&E.items.length===0&&(0,W.jsx)(re,{icon:(0,W.jsx)(be,{className:`size-6`}),title:e(`privacy.logs.empty`),detail:e(`privacy.logs.empty.detail`)}),E&&E.items.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.total`,{count:C(E.total)})}),(0,W.jsx)(V,{caption:e(`privacy.tab.logs`),rows:F,columns:ne,rowKey:`id`,emptyMessage:e(`privacy.logs.empty`)})]}),E&&D>1&&(0,W.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,W.jsx)(fe,{page:m,pageCount:D,onPageChange:g,label:e(`requests.page`,{page:m,pages:D})})}),(0,W.jsx)(he,{id:_,onClose:()=>v(null)})]})}function Ve(e){return e.blocked?`blocked`:e.redactions>0?`redact`:e.dryRun?`dryRun`:`warn`}function He({event:e}){let{t}=h();return e.blocked?(0,W.jsx)(p,{tone:`red`,children:t(`privacy.logs.outcome.blocked`)}):e.redactions>0?(0,W.jsx)(p,{tone:`orange`,children:t(`privacy.logs.outcome.redacted`,{count:e.redactions})}):e.dryRun?(0,W.jsx)(p,{tone:`neutral`,children:t(`privacy.logs.outcome.dryRun`)}):(0,W.jsx)(p,{tone:`neutral`,children:t(`settings.privacy.action.warn`)})}function Ue({event:e}){let t=Z(),{t:n}=h();if(e.hits.length===0)return(0,W.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`—`});let r=e.hits.slice(0,2),i=e.hits.length-r.length;return(0,W.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px]`,children:[r.map(e=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(Le,{action:e.action}),(0,W.jsxs)(`span`,{children:[t(e.category),` × `,e.count]}),e.samples&&e.samples.length>0&&(0,W.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:e.samples.slice(0,2).join(` `)})]},`${e.ruleId}:${e.action}`)),i>0&&(0,W.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:n(`privacy.logs.moreHits`,{count:i})})]})}var Q={counter:`_counter_dnoch_1`,label:`_label_dnoch_2`,value:`_value_dnoch_4`,column:`_column_dnoch_6`,sizer:`_sizer_dnoch_7`,glyph:`_glyph_dnoch_8`,labelText:`_labelText_dnoch_9`,labelSwap:`_labelSwap_dnoch_10`,symbol:`_symbol_dnoch_11`,srOnly:`_srOnly_dnoch_12`},We=[0,1,2,3,4,5,6,7,8,9],Ge={hidden:{opacity:0,y:`0.3em`,filter:`blur(${D.blur.soft}px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:D.duration.standard,ease:[...D.ease.enter]}},gone:{opacity:0,y:`-0.3em`,filter:`blur(${D.blur.subtle}px)`,transition:{duration:D.duration.fast,ease:[...D.ease.standard]}}},Ke={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:D.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:D.duration.instant}}},qe={...D.spring.smooth,visualDuration:D.duration.considered};function Je(e,t,n){let r=new Intl.NumberFormat(n,{minimumFractionDigits:t,maximumFractionDigits:t,numberingSystem:`latn`}).formatToParts(e),i=r.reduce((e,t)=>e+(t.type===`integer`?t.value.length:0),0),a=0,o=0;return r.flatMap((e,t)=>e.type===`integer`?[...e.value].map(e=>({key:`i${--i}`,digit:Number(e),order:o++})):e.type===`fraction`?[...e.value].map(e=>({key:`f${a++}`,digit:Number(e),order:o++})):[{key:e.type===`group`?`g${i}`:e.type===`decimal`?`d`:`${e.type}${t}`,text:e.value}])}function Ye({position:e,digit:t}){let n=I(e,e=>((t-e)%10+15)%10-5),r=I(n,e=>`${e}em`),i=I(n,e=>Math.max(0,1-Math.abs(e))),a=I(n,e=>Math.abs(e)>=1?`hidden`:`visible`),o=I(n,e=>Math.abs(e)<.02||Math.abs(e)>=1?`none`:`blur(${(Math.abs(e)*D.blur.subtle).toFixed(2)}px)`);return(0,W.jsx)(F.span,{className:Q.glyph,style:{y:r,opacity:i,filter:o,visibility:a},children:t})}var Xe={initial:{width:0,opacity:0},animate:{width:`auto`,opacity:1},exit:{width:0,opacity:0}};function Ze({digit:e,direction:t,armed:n,delay:r,reduceMotion:i}){let a=T(n?0:e),o=(0,H.useRef)({digit:n?0:e,target:n?0:e,revealed:!n});return(0,H.useEffect)(()=>{let s=o.current;if(n||s.digit===e){n||(s.revealed=!0);return}s.target+=t<0&&s.revealed?-((s.digit-e+10)%10):(e-s.digit+10)%10,s.digit=e,i?a.jump(s.target):E(a,s.target,s.revealed?D.spring.smooth:{...qe,delay:r}),s.revealed=!0},[n,r,e,t,a,i]),(0,W.jsxs)(F.span,{className:Q.column,...Xe,transition:i?{duration:0}:D.spring.morph,children:[(0,W.jsx)(`span`,{className:Q.sizer,children:`0`}),We.map(e=>(0,W.jsx)(Ye,{position:a,digit:e},e))]})}function Qe({value:e,label:t,prefix:n=``,suffix:r=``,decimals:i=0,animateOnView:a=!1,locale:o=`en-US`}){let s=(0,H.useRef)(null),c=me(s,{once:!0,amount:.6}),l=!!M(),[u,d]=(0,H.useState)(e),[f,p]=(0,H.useState)(1);e!==u&&(d(e),p(e>u?1:-1));let m=Je(e,i,o),h=`${n}${m.map(e=>`text`in e?e.text:e.digit).join(``)}${r}`,g=a&&!c;return(0,W.jsxs)(`span`,{ref:s,className:Q.counter,children:[t&&(0,W.jsx)(`span`,{className:Q.label,children:(0,W.jsx)(`span`,{className:Q.labelSwap,children:(0,W.jsx)(k,{mode:`popLayout`,initial:!1,children:(0,W.jsx)(F.span,{className:Q.labelText,variants:l?Ke:Ge,initial:`hidden`,animate:`shown`,exit:`gone`,children:t},t)})})}),(0,W.jsx)(`span`,{className:Q.srOnly,children:h}),(0,W.jsxs)(`span`,{className:Q.value,"aria-hidden":`true`,children:[n&&(0,W.jsx)(`span`,{className:Q.symbol,children:n}),(0,W.jsx)(k,{initial:!1,children:m.map(e=>`digit`in e?(0,W.jsx)(Ze,{digit:e.digit,direction:f,armed:g,delay:Math.min(e.order*D.stagger.item,.25),reduceMotion:l},e.key):(0,W.jsx)(F.span,{className:Q.symbol,...Xe,transition:l?{duration:0}:D.spring.morph,children:e.text},e.key))}),r&&(0,W.jsx)(`span`,{className:Q.symbol,children:r})]})]})}var $={card:`_card_1r6t9_1`,top:`_top_1r6t9_2`,swap:`_swap_1r6t9_8`,swapBlock:`_swapBlock_1r6t9_8`,text:`_text_1r6t9_11`,sizer:`_sizer_1r6t9_13`},$e={hidden:e=>({opacity:0,y:`${.3*e}em`,filter:`blur(${D.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:D.duration.standard,ease:[...D.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${D.blur.subtle}px)`,transition:{duration:D.duration.fast,ease:[...D.ease.standard]}})},et={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:D.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:D.duration.instant}}},tt=e=>Number(e.replace(/,/g,``).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN);function nt({text:e,morph:t=!1,block:n=!1}){let r=!!M(),i=(0,H.useRef)(null),a=T(`auto`),[o,s]=(0,H.useState)({text:e,direction:1});return o.text!==e&&s({text:e,direction:tt(e)<tt(o.text)?-1:1}),(0,H.useEffect)(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=null,n=new ResizeObserver(([n])=>{let i=n.borderBoxSize?.[0]?.inlineSize??e.offsetWidth;i&&t!==null&&t!==e.textContent&&!r?E(a,i,D.spring.morph):a.jump(i||`auto`),t=i?e.textContent:null});return n.observe(e),()=>n.disconnect()},[t,r,a]),(0,W.jsxs)(F.span,{className:n?$.swapBlock:$.swap,style:t?{width:a}:void 0,children:[t&&(0,W.jsx)(`span`,{ref:i,className:$.sizer,"aria-hidden":`true`,children:e}),(0,W.jsx)(k,{mode:`popLayout`,initial:!1,custom:o.direction,children:(0,W.jsx)(F.span,{className:$.text,custom:o.direction,variants:r?et:$e,initial:`hidden`,animate:`shown`,exit:`gone`,children:e},e)})]})}function rt({label:e,value:t,suffix:n,context:r,change:i}){let a=!!M();return(0,W.jsxs)(`article`,{className:$.card,children:[(0,W.jsxs)(`div`,{className:$.top,children:[(0,W.jsx)(`span`,{children:(0,W.jsx)(nt,{text:e,block:!0})}),(0,W.jsx)(k,{initial:!1,children:i&&(0,W.jsx)(F.small,{"data-trend":/^[+]/.test(i)?`up`:/^[-−]/.test(i)?`down`:void 0,initial:{opacity:0,scale:a?1:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:a?1:.96,transition:{duration:D.duration.fast,ease:[...D.ease.standard]}},transition:a?{duration:0}:D.spring.snappy,children:(0,W.jsx)(nt,{text:i,morph:!0})},`change`)})]}),(0,W.jsx)(Qe,{value:t,suffix:n,animateOnView:!0}),(0,W.jsx)(`p`,{children:(0,W.jsx)(nt,{text:r,block:!0})})]})}var it=[{id:`ipv4-all`,nameKey:`settings.privacy.template.ipv4All`,hintKey:`settings.privacy.template.ipv4AllHint`,pattern:String.raw`(?<![\d.])(?:\d{1,3}\.){3}\d{1,3}(?![\d.])`},{id:`landline`,nameKey:`settings.privacy.template.landline`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<!\d)0\d{2,3}[- ]?\d{7,8}(?!\d)`},{id:`license-plate`,nameKey:`settings.privacy.template.licensePlate`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]`},{id:`passport-cn`,nameKey:`settings.privacy.template.passportCn`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])[EG]\d{8}(?!\d)`},{id:`uscc`,nameKey:`settings.privacy.template.uscc`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![0-9A-HJ-NPQRTUWXY])[0-9A-HJ-NPQRTUWXY]{18}(?![0-9A-HJ-NPQRTUWXY])`},{id:`long-token`,nameKey:`settings.privacy.template.longToken`,hintKey:`settings.privacy.template.longTokenHint`,pattern:String.raw`(?<![A-Za-z0-9])[A-Za-z0-9_\-]{32,}(?![A-Za-z0-9])`},{id:`mac-address`,nameKey:`settings.privacy.template.macAddress`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![0-9A-Fa-f:])(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}(?![0-9A-Fa-f:])`},{id:`unix-home`,nameKey:`settings.privacy.template.unixHome`,hintKey:`settings.privacy.template.unixHomeHint`,pattern:String.raw`/(?:Users|home)/[A-Za-z0-9_.\-]+`},{id:`windows-profile`,nameKey:`settings.privacy.template.windowsProfile`,hintKey:`settings.privacy.template.unixHomeHint`,pattern:String.raw`[A-Za-z]:\\+Users\\+[A-Za-z0-9_.\-]+`},{id:`cloud-accesskey`,nameKey:`settings.privacy.template.cloudAccessKey`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])(?:LTAI[A-Za-z0-9]{12,20}|AKID[A-Za-z0-9]{13,40})(?![A-Za-z0-9])`},{id:`aws-secret-key`,nameKey:`settings.privacy.template.awsSecretKey`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9/+=])[A-Za-z0-9/+=]{40}(?![A-Za-z0-9/+=])`},{id:`im-webhook`,nameKey:`settings.privacy.template.imWebhook`,hintKey:`settings.privacy.template.imWebhookHint`,pattern:String.raw`oapi\.dingtalk\.com/robot/send\?access_token=[0-9a-f]{64}|qyapi\.weixin\.qq\.com/cgi-bin/webhook/send\?key=[0-9a-f]{32}|open\.feishu\.cn/open-apis/bot/v2/hook/[0-9a-f\-]{20,}|hooks\.slack\.com/services/T[A-Za-z0-9]+/B[A-Za-z0-9]+/[A-Za-z0-9]+`},{id:`internal-service`,nameKey:`settings.privacy.template.internalService`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?:gitlab|jenkins|jira|confluence|wiki|nexus|harbor|grafana|kibana|sonarqube|oa|sso)\.[A-Za-z0-9\-]+(?:\.[A-Za-z0-9\-]+)+`},{id:`jdbc-conn`,nameKey:`settings.privacy.template.jdbcConn`,hintKey:`settings.privacy.template.jdbcHint`,pattern:String.raw`jdbc:[A-Za-z0-9]+:[^\s"']*(?:[Uu]ser(?:[ _]?[Ii][Dd])?|[Pp]assword)=[^\s"&';]+`},{id:`smtp-conn`,nameKey:`settings.privacy.template.smtpConn`,hintKey:`settings.privacy.template.jdbcHint`,pattern:String.raw`(?:smtp|imap|pop3)s?://[^\s:@/]+:[^\s@]+@[^\s]+`},{id:`key-file-ref`,nameKey:`settings.privacy.template.keyFileRef`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`[A-Za-z0-9_\-./\\]+\.(?:pem|key|pfx|p12|jks|keystore)\b`},{id:`confidential-marker`,nameKey:`settings.privacy.template.confidentialMarker`,hintKey:`settings.privacy.template.confidentialHint`,pattern:String.raw`(?:绝密|机密|商业秘密|内部资料|内部公开|仅限内部|请勿外传|Confidential|Internal Use Only|Internal Only|Company Private)`},{id:`employee-id`,nameKey:`settings.privacy.template.employeeId`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])(?:[Ee][Mm][Pp]|工号)[::\- ]?\d{4,10}(?!\d)`},{id:`labeled-number`,nameKey:`settings.privacy.template.labeledNumber`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?:合同|订单|采购单|工单|项目)编号[::]?\s*[A-Za-z0-9_\-]{4,32}`}],at=[`off`,`warn`,`block`,`redact`],ot=Ie;function st(){let{t:e}=h(),{toast:t}=O(),n=s(),r=m(),a=n.data?.settings,o=e=>{a&&r.mutate({...a,...e},{onError:e=>t(S(e),`error`)})},c=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])}));return(0,W.jsxs)(_,{title:e(`settings.privacy`),footer:e(`settings.privacy.footer`),children:[n.isLoading&&(0,W.jsx)(b,{className:`my-4`}),n.isError&&(0,W.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--danger)]`,children:S(n.error)}),a&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(i,{label:e(`settings.privacy.enabled`),detail:e(`settings.privacy.enabledHint`),children:(0,W.jsx)(y,{checked:a.enabled,label:e(`settings.privacy.enabled`),onChange:e=>o({enabled:e})})}),(0,W.jsx)(i,{label:e(`settings.privacy.dryRun`),detail:e(`settings.privacy.dryRunHint`),children:(0,W.jsx)(y,{checked:a.dryRun,disabled:!a.enabled,label:e(`settings.privacy.dryRun`),onChange:e=>o({dryRun:e})})}),(0,W.jsx)(i,{label:e(`settings.privacy.restore`),detail:e(`settings.privacy.restoreHint`),children:(0,W.jsx)(y,{checked:a.restoreResponses,disabled:!a.enabled,label:e(`settings.privacy.restore`),onChange:e=>o({restoreResponses:e})})}),(0,W.jsx)(i,{label:e(`settings.privacy.recordSamples`),detail:e(`settings.privacy.recordSamplesHint`),children:(0,W.jsx)(y,{checked:a.recordSamples,disabled:!a.enabled,label:e(`settings.privacy.recordSamples`),onChange:e=>o({recordSamples:e})})}),(0,W.jsx)(i,{label:e(`settings.privacy.defaultAction`),children:(0,W.jsx)(j,{className:`w-36`,ariaLabel:e(`settings.privacy.defaultAction`),value:a.defaultAction,disabled:!a.enabled,onChange:e=>o({defaultAction:e}),options:c})})]})]})}function ct(){let{t:e}=h(),{toast:t}=O(),r=s(),a=m(),o=r.data?.settings,c=Z(),l=e=>{o&&a.mutate({...o,...e},{onError:e=>t(S(e),`error`)})},u=(e,t)=>l({categoryActions:{...o?.categoryActions,[e]:t}}),d=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])})),f=[...new Set((r.data?.rules??[]).map(e=>e.category))],g=e=>r.data?.rules.find(t=>t.category===e)?.description;return r.isLoading?(0,W.jsx)(`div`,{className:`mx-auto max-w-[720px]`,children:(0,W.jsx)(b,{className:`my-4`})}):o?(0,W.jsxs)(`div`,{className:`mx-auto flex max-w-[720px] flex-col gap-4`,children:[(0,W.jsx)(_,{title:e(`settings.privacy.categories`),children:f.map(t=>{let r=o.categoryActions[t]??o.defaultAction,a=!o.enabled||r===`off`;return(0,W.jsxs)(i,{label:c(t),detail:g(t),children:[r===`off`?(0,W.jsx)(p,{children:e(`settings.privacy.action.off`)}):(0,W.jsx)(j,{className:`w-36`,ariaLabel:c(t),value:r,disabled:!o.enabled,onChange:e=>u(t,e),options:d.filter(e=>e.value!==`off`)}),a&&(0,W.jsx)(n,{size:`sm`,variant:`plain`,disabled:!o.enabled,onClick:()=>u(t,o.categoryActions[t]??o.defaultAction),children:e(`settings.privacy.enableCategory`)})]},t)})}),(0,W.jsx)(lt,{s:o,onPatch:l})]}):null}function lt({s:e,onPatch:t}){let{t:r}=h(),{confirm:a}=O(),[o,s]=(0,H.useState)(!1),c=(n,r)=>t({customRules:e.customRules.map(e=>e.id===n.id?{...e,enabled:r}:e)}),l=async n=>{await a({title:r(`settings.privacy.deleteRuleConfirm`,{name:n.name}),destructive:!0,confirmLabel:r(`common.delete`)})&&t({customRules:e.customRules.filter(e=>e.id!==n.id)})};return(0,W.jsxs)(_,{title:r(`settings.privacy.customRules`),children:[e.customRules.length===0&&(0,W.jsx)(`div`,{className:`px-4 py-4 text-[12px] text-[var(--text-secondary)]`,children:r(`settings.privacy.noCustomRules`)}),e.customRules.map(t=>(0,W.jsxs)(i,{label:t.name,detail:t.pattern,children:[(0,W.jsx)(y,{checked:t.enabled,disabled:!e.enabled,label:t.name,onChange:e=>c(t,e)}),(0,W.jsx)(n,{size:`sm`,variant:`plain`,icon:(0,W.jsx)(z,{className:`size-3.5`}),"aria-label":`${r(`common.delete`)} ${t.name}`,onClick:()=>void l(t)})]},t.id)),(0,W.jsx)(`div`,{className:`px-4 py-2`,children:(0,W.jsx)(n,{size:`sm`,icon:(0,W.jsx)(oe,{className:`size-3.5`}),disabled:!e.enabled,onClick:()=>s(!0),children:r(`settings.privacy.addRule`)})}),(0,W.jsx)(ut,{open:o,onOpenChange:s,onAdd:n=>t({customRules:[...e.customRules,n]})})]})}function ut({open:t,onOpenChange:r,onAdd:i}){let{t:a}=h(),{toast:s}=O(),[c,l]=(0,H.useState)(``),[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(``);return(0,W.jsx)(w,{open:t,onOpenChange:r,title:a(`settings.privacy.addRule`),width:480,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(n,{onClick:()=>r(!1),children:a(`common.cancel`)}),(0,W.jsx)(n,{variant:`primary`,disabled:!c.trim()||!u.trim(),onClick:()=>{if(c.trim()&&u.trim()){try{new RegExp(u)}catch(e){s(`${a(`settings.privacy.invalidPattern`)}: ${S(e)}`,`error`);return}i({id:`custom-${Date.now().toString(36)}`,name:c.trim(),pattern:u.trim(),enabled:!0}),l(``),d(``),p(``),r(!1)}},children:a(`common.create`)})]}),children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsx)(e,{label:a(`settings.privacy.ruleTemplates`),hint:a(`settings.privacy.ruleTemplatesHint`),children:(0,W.jsx)(j,{ariaLabel:a(`settings.privacy.ruleTemplates`),value:f,onChange:e=>{p(e);let t=it.find(t=>t.id===e);t&&(l(a(t.nameKey)),d(t.pattern))},options:[{value:``,label:a(`settings.privacy.ruleTemplateNone`)},...it.map(e=>({value:e.id,label:a(e.nameKey)}))]})}),(0,W.jsx)(o,{label:a(`settings.privacy.ruleName`),value:c,onChange:e=>l(e.target.value),autoFocus:!0}),(0,W.jsx)(e,{label:a(`settings.privacy.rulePattern`),hint:a(`settings.privacy.rulePatternHint`),children:(0,W.jsx)(x,{mono:!0,rows:3,value:u,onChange:e=>d(e.target.value)})})]})})}function dt(){let{t:e}=h(),{toast:t}=O(),r=Z(),i=s(),a=g(),[o,c]=(0,H.useState)(``),l=a.data,u=i.data?.settings.enabled??!1;return(0,W.jsx)(_,{title:e(`settings.privacy.tester`),footer:e(`settings.privacy.testerHint`),children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,W.jsx)(x,{"aria-label":e(`settings.privacy.tester`),placeholder:e(`settings.privacy.testerPlaceholder`),rows:4,mono:!0,value:o,onChange:e=>c(e.target.value)}),(0,W.jsx)(`div`,{children:(0,W.jsx)(n,{icon:(0,W.jsx)(L,{className:`size-3.5`}),disabled:!u||!o.trim(),loading:a.isPending,onClick:()=>a.mutate({text:o},{onError:e=>t(S(e),`error`)}),children:e(`settings.privacy.runTest`)})}),l&&(0,W.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] px-3 py-2 text-[12px]`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l.blocked&&(0,W.jsx)(p,{tone:`red`,children:e(`settings.privacy.wouldBlock`)}),l.wouldRedact>0&&(0,W.jsx)(p,{tone:`orange`,children:e(`settings.privacy.wouldRedact`,{count:l.wouldRedact})}),!l.blocked&&l.wouldRedact===0&&(0,W.jsx)(p,{tone:`green`,children:e(`settings.privacy.noHits`)})]}),l.hits.length>0&&(0,W.jsx)(`ul`,{className:`mt-2 space-y-1`,children:l.hits.map(t=>(0,W.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(p,{tone:t.action===`block`?`red`:t.action===`redact`?`orange`:`neutral`,children:e(ot[t.action])}),(0,W.jsxs)(`span`,{children:[r(t.category),` · `,t.ruleId,` × `,t.count]}),t.samples&&t.samples.length>0&&(0,W.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:t.samples.join(` `)})]},`${t.ruleId}:${t.action}`))})]})]})})}var ft=[`today`,`7d`,`30d`,`all`];function pt(){let{t:e}=h(),t=Z(),[n,r]=(0,H.useState)(`7d`),i=v(n),a=i.data,o=[{key:`category`,label:e(`privacy.stats.col.category`),render:e=>t(String(e))},{key:`requests`,label:e(`privacy.stats.col.requests`),numeric:!0,width:110},{key:`hits`,label:e(`privacy.stats.col.hits`),numeric:!0,width:96},{key:`warnHits`,label:e(`privacy.stats.col.warn`),numeric:!0,width:84},{key:`blockHits`,label:e(`privacy.stats.col.block`),numeric:!0,width:84},{key:`redactHits`,label:e(`privacy.stats.col.redact`),numeric:!0,width:84}],s=(a?.categories??[]).map(e=>({...e}));return(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`section`,{children:[(0,W.jsx)(A,{action:(0,W.jsx)(l,{ariaLabel:e(`overview.range`),value:n,onChange:r,items:ft.map(t=>({value:t,label:e(`range.${t}`)}))}),children:e(`privacy.stats`)}),i.isLoading&&(0,W.jsx)(b,{lines:3,className:`py-4`}),i.isError&&(0,W.jsx)(f,{tone:`danger`,title:e(`common.error`),children:S(i.error)}),a&&(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,W.jsx)(rt,{label:e(`privacy.stats.events`),value:a.events,context:e(`range.${n}`)}),(0,W.jsx)(rt,{label:e(`privacy.stats.blocked`),value:a.blocked,context:e(`range.${n}`)}),(0,W.jsx)(rt,{label:e(`privacy.stats.redactions`),value:a.redactions,context:e(`range.${n}`)}),(0,W.jsx)(rt,{label:e(`privacy.stats.dryRun`),value:a.dryRun,context:e(`range.${n}`)})]})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(A,{children:e(`privacy.stats.byCategory`)}),a&&a.categories.length===0&&(0,W.jsx)(`div`,{className:`card`,children:(0,W.jsx)(mt,{})}),a&&a.categories.length>0&&(0,W.jsx)(V,{caption:e(`privacy.stats.byCategory`),rows:s,columns:o,rowKey:`category`,defaultSort:{key:`hits`,direction:`desc`}})]}),(0,W.jsx)(`div`,{className:`mx-auto w-full max-w-[720px]`,children:(0,W.jsx)(st,{})})]})}function mt(){let{t:e}=h();return(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-center`,children:[(0,W.jsx)(L,{className:`size-6 text-[var(--text-muted)]`}),(0,W.jsx)(`div`,{className:`text-[13px]`,children:e(`privacy.logs.empty`)}),(0,W.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.empty.detail`)})]})}var ht=[`overview`,`logs`,`rules`,`tester`];function gt(){let{t:e}=h(),{tab:t}=ce(),n=ae(),r=ht.includes(t)?t:`overview`;return(0,W.jsx)(se,{title:e(`nav.privacy`),subtitle:e(`settings.privacy.footer`),children:(0,W.jsxs)(pe,{value:r,onValueChange:e=>n(`/privacy/${e}`,{replace:!0}),children:[(0,W.jsx)(_e,{"aria-label":e(`nav.privacy`),children:ht.map(t=>(0,W.jsx)(ve,{value:t,children:e(`privacy.tab.${t}`)},t))}),(0,W.jsx)(B,{value:`overview`,className:`pt-5`,children:(0,W.jsx)(pt,{})}),(0,W.jsx)(B,{value:`logs`,className:`pt-4`,children:(0,W.jsx)(Be,{})}),(0,W.jsx)(B,{value:`rules`,className:`pt-5`,children:(0,W.jsx)(ct,{})}),(0,W.jsx)(B,{value:`tester`,className:`pt-5 [&>div]:mx-auto [&>div]:max-w-[680px]`,children:(0,W.jsx)(dt,{})})]})})}export{gt as PrivacyPage};
@@ -1,3 +0,0 @@
1
- import{$r as e,B as t,Bi as n,Ci as r,Cn as i,Dn as a,Dr as o,Ei as s,Er as c,F as l,Fa as u,Fi as d,Fn as f,Fr as p,G as m,H as h,I as g,Ia as _,Ii as v,In as y,Ir as b,J as x,Jn as S,Jr as ee,K as te,Kr as C,L as w,Li as T,Mn as ne,Mr as E,N as D,On as re,Or as ie,P as O,Pa as ae,Pr as oe,Qr as se,Rr as ce,Si as le,Tn as k,U as A,V as j,Vr as ue,W as M,Wi as N,X as P,Y as F,Z as I,a as L,an as R,ar as de,bi as fe,dr as pe,dt as z,er as me,fr as he,hi as ge,i as B,in as _e,jn as ve,kn as ye,n as be,ni as xe,nr as Se,o as V,oi as H,pr as Ce,qn as we,qr as Te,r as U,rt as W,sr as Ee,st as De,tr as Oe,vn as ke,vr as Ae,wr as je,yi as Me,yn as Ne,yr as Pe,z as Fe,za as Ie}from"./overlays-D1ZtG8Qn.js";import{b as Le,c as Re,s as G,t as ze,x as K}from"./Page-CnSErb_N.js";import{t as q}from"./arrow-down-CXkFrvO0.js";import{n as J,t as Y}from"./checkbox-RGYPqY5w.js";import{t as Be}from"./arrow-up-BfREUNOR.js";import{t as Ve}from"./cloud-download-D865MmmV.js";import{t as He}from"./download-CMr38kbd.js";import{t as Ue}from"./ellipsis-zTWIrsa4.js";import{t as We}from"./external-link-BSHuW87X.js";import{t as Ge}from"./log-out-CXVs8bJY.js";import{t as Ke}from"./power-CJZylS33.js";import{t as qe}from"./rotate-ccw-Dr0Xbikv.js";import{D as Je,S as X,_ as Ye,a as Xe,g as Ze,o as Qe,s as Z,u as $e,v as et,y as tt}from"./index-PfVyiY3J.js";import{t as nt}from"./confirm-morph-DUNuG_Io.js";import{AUTH_OPTIONS as rt,PROTOCOL_OPTIONS as it,i as at,n as ot,r as st,t as ct}from"./ProvidersPage-DfMcnoYT.js";var lt={name:`arrow-right-left`,size:24,node:[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]};lt.node;var ut=z(lt),dt={name:`gift`,size:24,node:[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8`,key:`1sqzm4`}],[`path`,{d:`M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5`,key:`kc0143`}],[`rect`,{x:`3`,y:`7`,width:`18`,height:`4`,rx:`1`,key:`1hberx`}]]};dt.node;var ft=z(dt),pt={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};pt.node;var mt=z(pt),ht={name:`list-plus`,size:24,node:[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`M18 9v6`,key:`1twb98`}],[`path`,{d:`M21 12h-6`,key:`bt1uis`}]]};ht.node;var gt=z(ht),_t={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};_t.node;var vt=z(_t),yt={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};yt.node;var bt=z(yt),xt={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};xt.node;var St=z(xt),Ct={name:`ticket`,size:24,node:[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]};Ct.node;var wt=z(Ct),Q=Ie(_(),1),$=u(),Tt={imported:`providers.subscription.importBatchStatus.imported`,updated:`providers.subscription.importBatchStatus.updated`,duplicate:`providers.subscription.importBatchStatus.duplicate`,invalid_format:`providers.subscription.importBatchStatus.invalid_format`,failed:`providers.subscription.importBatchStatus.failed`,ready:`providers.subscription.importBatchStatus.ready`},Et={imported:`green`,updated:`accent`,ready:`accent`,duplicate:`neutral`,invalid_format:`orange`,failed:`red`},Dt={batch:`providers.accounts.import.batchTitle`,token:`providers.accounts.import.tokenTitle`,apiKey:`providers.accounts.import.apiKeyTitle`};function Ot(e){return e.split(/[,\s]+/).flatMap(e=>{let t=e.replace(/^["']+|["']+$/g,``);return t.startsWith(`tid=`)||t.startsWith(`exp=`)?[t]:t.split(`;`)}).filter(e=>e.replace(/^["']+|["']+$/g,``).length>0).length}function kt(e){let t=e.trim();if(t.length===0)return 0;if(t.startsWith(`{`)||t.startsWith(`[`))try{let e=JSON.parse(t);if(Array.isArray(e))return e.filter(e=>typeof e==`object`&&!!e||typeof e==`string`&&e.trim().length>0).length;if(typeof e==`object`&&e)return 1}catch{}let n=0;for(let t of e.split(`
2
- `)){let e=t.trim();e.length===0||e.startsWith(`#`)||(n+=e.startsWith(`{`)?1:Ot(e))}return n}function At({providerId:e,info:t,mode:n,providerProxy:r,onClose:i}){let{t:a}=k(),{toast:o}=V(),s=pe(e),[c,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(null),g=(0,Q.useMemo)(()=>kt(c),[c]);if((0,Q.useEffect)(()=>{n!==null&&(u(``),m(null))},[n]),n===null)return(0,$.jsx)(B,{open:!1,onOpenChange:i,title:``});let _=n===`apiKey`,v=_?t.formats.filter(e=>e.endsWith(`-api-key`)):t.formats,y=!_&&t.formats.some(e=>e.includes(`refresh-token`)||e.endsWith(`-json`)),b=a(_?`providers.accounts.import.apiKeyLabel`:`providers.accounts.import.label`),x=e=>s.mutate({text:c,asApiKey:_||void 0,dryRun:e||void 0,httpProxy:d.trim()||void 0},{onSuccess:t=>{m({...t,dryRun:e}),!e&&(o(a(`providers.accounts.import.summary`,{ok:t.imported,dup:t.duplicates,fail:t.failed}),t.failed>0?`info`:`success`),!(t.failed>0)&&(n===`batch`?u(``):i()))},onError:e=>o(L(e),`error`)});return(0,$.jsx)(B,{open:!0,onOpenChange:e=>!e&&i(),title:a(Dt[n]),description:a(`providers.accounts.import.desc`),width:560,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[v.length>0&&(0,$.jsx)(`p`,{className:`text-[11.5px] text-[var(--text-secondary)]`,children:a(`providers.accounts.import.formats`,{formats:v.map(e=>a(`providers.accounts.format.${e}`)).join(` · `)})}),(0,$.jsx)(I,{mono:!0,rows:n===`batch`?8:3,value:c,onChange:e=>u(e.target.value),"aria-label":b,placeholder:b,spellCheck:!1}),(0,$.jsx)(h,{mono:!0,label:a(`providers.accounts.import.proxy`),placeholder:r||a(`providers.accounts.proxyFallbackSystem`),value:d,onChange:e=>f(e.target.value)}),y&&(0,$.jsx)(D,{tone:`info`,title:a(`providers.accounts.import.rotateWarning`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:a(`providers.accounts.import.count`,{n:g})}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[n===`batch`&&(0,$.jsx)(l,{disabled:g===0,loading:s.isPending&&s.variables?.dryRun===!0,onClick:()=>x(!0),children:a(`providers.accounts.import.preview`)}),(0,$.jsx)(l,{variant:`primary`,disabled:g===0||g>t.maxBatch,loading:s.isPending&&!s.variables?.dryRun,onClick:()=>x(!1),children:a(`providers.accounts.import.run`)})]})]}),p&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`div`,{className:`text-[12px] font-medium`,children:a(p.dryRun?`providers.accounts.import.previewSummary`:`providers.accounts.import.summary`,{ok:p.imported,dup:p.duplicates,fail:p.failed})}),(0,$.jsx)(`ul`,{className:`card max-h-72 divide-y divide-[var(--border)] overflow-auto`,children:p.items.map(e=>(0,$.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-1.5 text-[12px]`,children:[(0,$.jsx)(`span`,{className:`w-6 shrink-0 text-[var(--text-muted)]`,children:e.index}),(0,$.jsx)(`span`,{className:`selectable w-28 shrink-0 truncate font-mono`,children:e.source}),(0,$.jsx)(O,{tone:Et[e.status],children:a(Tt[e.status])}),e.kind&&(0,$.jsx)(`span`,{className:`shrink-0 text-[11px] text-[var(--text-muted)]`,children:a(`providers.accounts.credential.${e.kind}`)}),(0,$.jsx)(`span`,{className:`selectable min-w-0 flex-1 break-words text-[var(--text-secondary)]`,children:e.account?.displayName&&(e.status===`imported`||e.status===`updated`)?`${e.account.displayName}${e.message?` · ${e.message}`:``}`:e.message??``})]},e.index))})]})]})})}function jt(e,t=Date.now()){return e.enabled?e.status===`active`?e.cooldownUntilUtc&&new Date(e.cooldownUntilUtc).getTime()>t?`cooling`:`usable`:`dead`:`disabled`}var Mt={usable:`var(--success)`,cooling:`var(--warning)`,dead:`var(--danger)`,disabled:`var(--text-muted)`},Nt={active:`providers.subscription.status.active`,expired:`providers.subscription.status.expired`,revoked:`providers.subscription.status.revoked`};function Pt(e,t){let n=(e??``).toLowerCase(),r=t?`110,115,135`:/max|ultra/.test(n)?`47,124,246`:/pro|plus|premium/.test(n)?`52,195,143`:/team|business|enterprise|allegro|vivace/.test(n)?`130,100,230`:`110,115,135`;return`linear-gradient(135deg, rgba(${r},.34), rgba(${r},.08))`}function Ft({account:e,index:t,actions:n,selected:r,selecting:a,onToggleSelect:o,onMove:s,quotaPending:c}){let{t:u,locale:d}=k(),f=jt(e),p=e.displayName||e.accountEmail||e.keyMasked||e.id,m=e.kind===`api_key`,h=e.plan?.trim(),g=f===`cooling`?{text:u(`providers.subscription.cooldown`,{when:R(e.cooldownUntilUtc,d)}),tone:`var(--warning)`}:f===`dead`?{text:e.lastError||u(Nt[e.status]),tone:`var(--danger)`}:m?{text:e.keyMasked??u(`providers.accounts.neverExpires`),tone:void 0}:e.expiresAtUtc?{text:u(`providers.accounts.expiresAt`,{when:R(e.expiresAtUtc,d)}),tone:void 0}:null,_=[{id:`activate`,label:u(`providers.subscription.activate`),icon:(0,$.jsx)(ut,{className:`size-3.5`}),disabled:e.isCurrent||f===`dead`,onSelect:()=>n.activate(e)},{id:`toggle`,label:u(e.enabled?`providers.subscription.disable`:`providers.subscription.enable`),icon:(0,$.jsx)(Ke,{className:`size-3.5`}),onSelect:()=>n.toggleEnabled(e)},...s?[{id:`up`,label:u(`providers.subscription.moveUp`),icon:(0,$.jsx)(Be,{className:`size-3.5`}),disabled:!s.up,onSelect:()=>s.up?.()},{id:`down`,label:u(`providers.subscription.moveDown`),icon:(0,$.jsx)(q,{className:`size-3.5`}),disabled:!s.down,onSelect:()=>s.down?.()}]:[],{id:`quota`,separatorBefore:!0,label:u(`providers.subscription.quotaRefresh`),icon:(0,$.jsx)(st,{className:`size-3.5`}),disabled:f===`dead`,onSelect:()=>n.refreshQuota(e)},...m?[]:[{id:`refresh`,label:u(`providers.subscription.refreshToken`),icon:(0,$.jsx)(qe,{className:`size-3.5`}),disabled:e.status===`revoked`,onSelect:()=>n.refreshToken(e)},{id:`relogin`,label:u(`providers.subscription.relogin`),disabled:e.status===`active`,onSelect:()=>n.relogin(e)}],{id:`remove`,label:u(`providers.subscription.logout`),icon:(0,$.jsx)(X,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>n.remove(e)}],v=u(f===`disabled`?`providers.subscription.disabled`:Nt[e.status]),y=u(m?`providers.accounts.kind.api_key`:`providers.accounts.kind.oauth`),b=e.quota?.session?.usedPercent!=null||e.quota?.weekly?.usedPercent!=null||e.quota?.credits?.usedPercent!=null;return(0,$.jsxs)(`div`,{"data-testid":`account-card`,className:i(`group card relative flex aspect-square min-w-0 cursor-pointer flex-col overflow-hidden transition-colors hover:bg-[var(--fill)]`,e.isCurrent&&`ring-1 ring-[var(--accent)]`,r&&`bg-[var(--accent-subtle)]`,f===`disabled`&&`opacity-55`),onClick:()=>a?o(e.id):n.open(e),children:[(0,$.jsxs)(`div`,{className:`relative shrink-0 px-3 pb-3 pt-2.5`,style:{background:Pt(h,m)},children:[(f===`cooling`||f===`dead`)&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-y-0 left-0 w-[3px]`,style:{background:Mt[f]}}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:i(`flex size-5 items-center justify-center`,!a&&!r&&`hidden group-hover:flex`),onClick:e=>e.stopPropagation(),children:(0,$.jsx)(Y,{checked:r,onCheckedChange:()=>o(e.id),"aria-label":u(`providers.accounts.select`,{name:p})})}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(`span`,{role:`img`,"aria-label":v,className:`size-1.5 shrink-0 rounded-full`,style:{background:Mt[f]}}),(0,$.jsx)(`span`,{"aria-hidden":!0,children:v})]}),e.httpProxy&&(0,$.jsx)(`span`,{title:`${u(`providers.accounts.proxyBadge`)}: ${e.httpProxy}`,className:`shrink-0 text-[var(--text-muted)]`,children:(0,$.jsx)(mt,{className:`size-3.5`,"aria-label":u(`providers.accounts.proxyBadge`)})}),(0,$.jsx)(`span`,{className:`-mr-1.5 ml-auto shrink-0`,onClick:e=>e.stopPropagation(),children:(0,$.jsx)(be,{iconOnly:!0,label:u(`common.more`),icon:(0,$.jsx)(Ue,{className:`size-4`}),items:_})})]}),(0,$.jsx)(`div`,{className:`mt-1.5 truncate text-[17px] font-bold tracking-[.01em]`,title:h||y,children:h||y})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pb-3 pt-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-[13px] font-medium outline-none focus-visible:underline`,title:p,onClick:t=>{t.stopPropagation(),a?o(e.id):n.open(e)},children:p}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 items-center gap-1 whitespace-nowrap text-[11px] text-[var(--text-muted)]`,children:[e.isCurrent&&(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[var(--success)]`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`●`}),(0,$.jsx)(`span`,{children:u(`providers.subscription.current`)})]}),e.isCurrent&&(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0`,children:y}),e.source&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{className:`truncate`,children:u(`providers.accounts.source.${e.source}`)})]}),(0,$.jsx)(`span`,{className:`ml-auto shrink-0 pl-1 opacity-0 group-hover:opacity-100`,children:u(`providers.accounts.order`,{n:t+1})})]}),g&&(f===`cooling`||f===`dead`||!b)&&(0,$.jsx)(`div`,{className:`mt-1.5 line-clamp-2 text-[11px] leading-snug`,style:{color:g.tone??`var(--text-muted)`},title:g.text,children:g.text}),f===`dead`?(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:u(`providers.accounts.signedOut`)}),!m&&(0,$.jsx)(l,{size:`sm`,className:`ml-auto`,onClick:t=>{t.stopPropagation(),n.relogin(e)},children:u(`providers.subscription.relogin`)})]}):(0,$.jsx)(Lt,{quota:e.quota??null,pending:c})]})]})}var It=10;function Lt({quota:e,pending:t}){let{t:n,locale:r}=k(),a=[];return e?.session?.usedPercent!=null&&a.push({key:`session`,label:e.session.windowMinutes?`${Math.round(e.session.windowMinutes/60)}h`:n(`providers.accounts.quotaShortSession`),percent:e.session.usedPercent,reset:e.session.resetsAtUtc}),e?.weekly?.usedPercent!=null&&a.push({key:`weekly`,label:n(`providers.accounts.quotaShortWeekly`),percent:e.weekly.usedPercent,reset:e.weekly.resetsAtUtc}),a.length<2&&e?.credits?.usedPercent!=null&&a.push({key:`credits`,label:n(e.entitlement==null?`providers.accounts.quotaShortCredits`:`providers.accounts.quotaShortPremium`),percent:e.credits.usedPercent,reset:e.credits.resetsAtUtc}),a.length===0?null:(0,$.jsx)(`div`,{className:i(`mt-auto flex flex-col gap-2 pt-2`,t&&`opacity-60`),children:a.slice(0,2).map(e=>{let t=Math.max(0,Math.min(100,Math.round(e.percent))),i=t>=90?`var(--danger)`:t>=70?`var(--warning)`:`var(--accent)`,a=Math.round(t/100*It),o=e.reset?n(`providers.subscription.quotaResets`,{when:R(e.reset,r)}):void 0;return(0,$.jsxs)(`div`,{className:`min-w-0`,title:o,children:[(0,$.jsxs)(`div`,{className:`flex justify-between text-[11px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(`span`,{children:e.label}),(0,$.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[t,`%`]})]}),(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":e.label,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,className:`mt-0.5 flex gap-[3px]`,children:Array.from({length:It},(e,t)=>(0,$.jsx)(`i`,{className:`h-[5px] flex-1 rounded-[2px] bg-[var(--surface-muted)]`,style:t<a?{background:i}:void 0},t))})]},e.key)})})}function Rt({quota:e,className:t}){let{t:n,locale:r}=k(),a=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:n(`providers.subscription.quotaResets`,{when:t.toLocaleString(r)})},o=[];e.session?.usedPercent!=null&&o.push({key:`session`,label:n(`providers.subscription.quotaWindowSession`),window:e.session}),e.weekly?.usedPercent!=null&&o.push({key:`weekly`,label:n(`providers.subscription.quotaWindowWeekly`),window:e.weekly}),e.credits?.usedPercent!=null&&o.push({key:`credits`,label:e.entitlement==null?n(`providers.subscription.quotaWindowCredits`):n(`providers.subscription.quotaWindowPremium`),window:{usedPercent:e.credits.usedPercent,resetsAtUtc:e.credits.resetsAtUtc??null}});let s=e.credits?.prepaidBalance==null?null:n(`providers.subscription.quotaBalance`,{balance:e.credits.prepaidBalance}),c=e.entitlement!=null&&e.entitlement>=0?[n(`providers.subscription.quotaPremiumCount`,{used:Math.max(0,(e.entitlement??0)-(e.remaining??0)),total:e.entitlement}),e.overageUsed?n(`providers.subscription.quotaOverage`,{count:e.overageUsed}):null,e.overagePermitted===!1?n(`providers.subscription.quotaOverageOff`):null].filter(Boolean).join(` · `):null,l=e.planLabel??(e.fetchedAtUtc?n(`providers.subscription.quotaFetchedAt`,{when:new Date(e.fetchedAtUtc).toLocaleString(r)}):null);return(0,$.jsx)(`div`,{className:i(`px-4 py-1`,t),children:(0,$.jsxs)(`div`,{className:`card flex flex-col gap-3 p-3`,children:[(l||s)&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-[11px] text-[var(--text-secondary)]`,children:[l&&(0,$.jsx)(`span`,{children:l}),s&&(0,$.jsx)(`span`,{children:s})]}),o.length===0?(0,$.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`providers.subscription.quotaNoWindows`)}):o.map(e=>(0,$.jsx)(zt,{label:e.label,window:e.window,reset:a(e.window.resetsAtUtc)},e.key)),c&&(0,$.jsx)(`div`,{className:`text-[10.5px] text-[var(--text-muted)]`,children:c})]})})}function zt({label:e,window:t,reset:n}){let r=Math.max(0,Math.min(100,Math.round(t.usedPercent??0))),[i,a]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches){a(r);return}let e=requestAnimationFrame(()=>a(r));return()=>cancelAnimationFrame(e)},[r]);let o=r>=90?`var(--danger)`:r>=70?`var(--warning)`:`var(--accent)`,s=t.windowMinutes?Math.round(t.windowMinutes/60):null;return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[11.5px]`,children:[(0,$.jsxs)(`span`,{className:`text-[var(--text-secondary)]`,children:[e,s!=null&&(0,$.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[` · `,s,`h`]})]}),(0,$.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[r,`%`]})]}),(0,$.jsx)(`div`,{role:`progressbar`,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-500 ease-out`,style:{width:`${i}%`,background:o}})}),n&&(0,$.jsx)(`div`,{className:`mt-1 text-[10.5px] text-[var(--text-muted)]`,children:n})]})}var Bt={available:`green`,redeemed:`neutral`,expired:`orange`};function Vt({account:e,providerId:t}){let{t:n}=k(),{toast:r,confirm:a}=V(),o=H(e.id,e.status===`active`),s=S(t),c=o.data?.credits??[],u=o.data?.available_count??c.filter(e=>e.status===`available`).length,d=async t=>{await a({title:n(`providers.subscription.credits.consumeConfirm`,{title:t.title??t.reset_type??``}),detail:n(`providers.subscription.credits.consumeDetail`),confirmLabel:n(`providers.subscription.credits.consume`),destructive:!0})&&s.mutate({accountId:e.id,creditId:t.id},{onSuccess:()=>r(n(`providers.subscription.credits.consumed`),`success`),onError:e=>r(e instanceof N&&e.status===409?L(e):`${n(`providers.subscription.credits.consumeFailed`)}:${L(e)}`,`error`)})};return(0,$.jsxs)(j,{title:n(`providers.subscription.credits.title`),footer:n(`providers.subscription.credits.footer`),children:[o.isLoading&&(0,$.jsx)(F,{className:`my-4`}),o.isError&&(0,$.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--text-secondary)]`,children:n(`providers.subscription.credits.unavailable`)}),o.data&&c.length===0&&(0,$.jsx)(`div`,{className:`px-4 py-5 text-center text-[12px] text-[var(--text-secondary)]`,children:n(`providers.subscription.credits.none`)}),c.map(e=>{let t=e.status!==`available`;return(0,$.jsxs)(m,{className:i(t&&`opacity-55`),label:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ft,{className:`size-3.5 text-[var(--text-secondary)]`}),e.title??e.reset_type??e.id]}),detail:[e.description,e.expires_at?n(`providers.subscription.credits.expires`,{when:new Date(e.expires_at).toLocaleString()}):null,e.redeemed_at?n(`providers.subscription.credits.redeemedAt`,{when:new Date(e.redeemed_at).toLocaleString()}):null,e.is_supported_by_plan===!1?n(`providers.subscription.credits.notInPlan`):null].filter(Boolean).join(` · `),children:[(0,$.jsx)(O,{tone:Bt[e.status]??`neutral`,children:n(`providers.subscription.credits.status.${e.status}`)}),(0,$.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(wt,{className:`size-3.5`}),disabled:t,loading:s.isPending&&s.variables?.creditId===e.id,onClick:()=>void d(e),children:n(`providers.subscription.credits.consume`)})]},e.id)}),o.data&&c.length>0&&(0,$.jsx)(`div`,{className:`px-4 py-2 text-[11px] text-[var(--text-muted)]`,children:n(`providers.subscription.credits.availableCount`,{count:u})})]})}var Ht={active:`providers.subscription.status.active`,expired:`providers.subscription.status.expired`,revoked:`providers.subscription.status.revoked`};function Ut({provider:e,account:t,index:n,actions:r,onClose:i}){let{t:a,locale:o}=k(),{toast:s}=V(),c=v(e.id),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(``);if((0,Q.useEffect)(()=>{d(t?.displayName??``),p(t?.httpProxy??``)},[t?.id,t?.displayName,t?.httpProxy]),!t)return(0,$.jsx)(B,{open:!1,onOpenChange:i,title:``});let m=jt(t),g=t.kind===`api_key`,_=e.templateId===`openai-subscription`,y=e.httpProxy||a(`providers.accounts.proxyFallbackSystem`),b=e=>e?R(e,o):`—`,x=(e,n)=>c.mutate({id:t.id,...e},{onSuccess:()=>s(a(n),`success`),onError:e=>s(L(e),`error`)});return(0,$.jsx)(B,{open:!0,onOpenChange:e=>!e&&i(),title:t.displayName||t.keyMasked||t.id,description:[t.plan,a(g?`providers.accounts.kind.api_key`:`providers.accounts.kind.oauth`)].filter(Boolean).join(` · `),width:520,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,$.jsx)(l,{size:`sm`,icon:(0,$.jsx)(ut,{className:`size-3.5`}),disabled:t.isCurrent||m===`dead`,onClick:()=>r.activate(t),children:a(`providers.subscription.activate`)}),(0,$.jsx)(l,{size:`sm`,icon:(0,$.jsx)(st,{className:`size-3.5`}),disabled:m===`dead`,onClick:()=>r.refreshQuota(t),children:a(`providers.subscription.quotaRefresh`)}),!g&&(0,$.jsx)(l,{size:`sm`,icon:(0,$.jsx)(qe,{className:`size-3.5`}),disabled:t.status===`revoked`,onClick:()=>r.refreshToken(t),children:a(`providers.subscription.refreshToken`)}),!g&&t.status!==`active`&&(0,$.jsx)(l,{size:`sm`,variant:`primary`,onClick:()=>r.relogin(t),children:a(`providers.subscription.relogin`)}),(0,$.jsx)(l,{size:`sm`,variant:`plain`,className:`ml-auto text-[var(--danger)]`,icon:(0,$.jsx)(X,{className:`size-3.5`}),onClick:()=>r.remove(t),children:a(`providers.subscription.logout`)})]}),m===`dead`&&t.lastError&&(0,$.jsx)(D,{tone:`danger`,title:t.lastError}),(0,$.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h4`,{className:`text-[11px] font-medium text-[var(--text-secondary)]`,children:a(`providers.accounts.detail.identity`)}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,$.jsx)(h,{className:`flex-1`,label:a(`providers.accounts.detail.name`),value:u,onChange:e=>d(e.target.value)}),(0,$.jsx)(l,{disabled:u.trim().length===0||u.trim()===t.displayName,loading:c.isPending&&c.variables?.displayName!==void 0,onClick:()=>x({displayName:u.trim()},`providers.accounts.renamed`),children:a(`common.save`)})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,$.jsx)(h,{className:`flex-1`,mono:!0,label:a(`providers.accounts.detail.proxy`),placeholder:y,value:f,onChange:e=>p(e.target.value)}),(0,$.jsx)(l,{disabled:f.trim()===(t.httpProxy??``),loading:c.isPending&&c.variables?.httpProxy!==void 0,onClick:()=>x({httpProxy:f.trim()},`providers.accounts.proxySaved`),children:a(`common.save`)})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:a(`providers.accounts.detail.proxyHint`,{fallback:y})})]}),t.quota&&(0,$.jsxs)(`section`,{className:`-mx-4 flex flex-col gap-1`,children:[(0,$.jsx)(`h4`,{className:`px-4 text-[11px] font-medium text-[var(--text-secondary)]`,children:a(`providers.accounts.detail.quota`)}),(0,$.jsx)(Rt,{quota:t.quota})]}),_&&m!==`dead`&&(0,$.jsx)(`div`,{className:`-mx-4`,children:(0,$.jsx)(Vt,{account:t,providerId:e.id})}),(0,$.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`h4`,{className:`text-[11px] font-medium text-[var(--text-secondary)]`,children:a(`providers.accounts.detail.credentials`)}),(0,$.jsxs)(`div`,{className:`card divide-y divide-[var(--border)] px-3`,children:[(0,$.jsx)(A,{label:a(`providers.accounts.detail.status`),children:(0,$.jsx)(O,{tone:m===`usable`?`green`:m===`cooling`?`orange`:m===`dead`?`red`:`neutral`,children:a(m===`disabled`?`providers.subscription.disabled`:Ht[t.status])})}),t.source&&(0,$.jsx)(A,{label:a(`providers.accounts.detail.source`),children:a(`providers.accounts.source.${t.source}`)}),g?(0,$.jsx)(A,{label:a(`providers.accounts.detail.key`),mono:!0,children:t.keyMasked??`••••`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A,{label:a(`providers.accounts.detail.expires`),children:b(t.expiresAtUtc)}),(0,$.jsx)(A,{label:a(`providers.accounts.detail.lastRefresh`),children:b(t.lastRefreshAtUtc)})]}),m===`cooling`&&(0,$.jsx)(A,{label:a(`providers.accounts.filter.cooling`),children:b(t.cooldownUntilUtc)}),(0,$.jsx)(A,{label:a(`providers.accounts.detail.order`),children:a(`providers.accounts.order`,{n:n+1})}),(0,$.jsx)(A,{label:a(`providers.accounts.detail.created`),children:b(t.createdAt)}),t.lastError&&m!==`dead`&&(0,$.jsx)(A,{label:a(`providers.accounts.detail.lastError`),children:t.lastError})]})]})]})})}function Wt({provider:e}){let{t}=k(),{toast:i}=V(),a=e.authScheme===`oauth-subscription`,o=r(e.id,a),s=n(e.id);if(!a||!o.data)return null;let c=o.data,l=e=>s.mutate(e,{onError:e=>i(L(e),`error`)}),u=c.claudeSubscription||c.clientPolicy===`claude-code-only`;return!u&&!c.claudeSubscription?null:(0,$.jsxs)(j,{title:t(`providers.subscription.policy.title`),footer:t(`providers.subscription.policy.footer`),children:[u&&(0,$.jsx)(m,{label:t(`providers.subscription.policy.claudeCodeOnly`),detail:t(`providers.subscription.policy.claudeCodeOnlyDetail`),children:(0,$.jsx)(P,{label:t(`providers.subscription.policy.claudeCodeOnly`),checked:c.clientPolicy===`claude-code-only`,disabled:s.isPending,onChange:e=>l({clientPolicy:e?`claude-code-only`:`any`})})}),c.claudeSubscription&&(0,$.jsx)(m,{label:t(`providers.subscription.policy.mimic`),detail:t(`providers.subscription.policy.mimicDetail`),children:(0,$.jsx)(P,{label:t(`providers.subscription.policy.mimic`),checked:c.mimicClaudeCode,disabled:s.isPending,onChange:e=>l({mimicClaudeCode:e})})}),u&&c.clientPolicy===`any`&&(0,$.jsx)(`div`,{className:`px-4 py-3`,children:c.mimicClaudeCode?(0,$.jsx)(D,{tone:`warning`,title:t(`providers.subscription.policy.mimicWarning`)}):(0,$.jsx)(D,{tone:`warning`,title:t(`providers.subscription.policy.anyWarning`)})})]})}var Gt=[{value:`all`,label:`providers.accounts.filter.all`},{value:`usable`,label:`providers.accounts.filter.usable`},{value:`cooling`,label:`providers.accounts.filter.cooling`},{value:`dead`,label:`providers.accounts.filter.dead`},{value:`disabled`,label:`providers.accounts.filter.disabled`}],Kt=3e5;function qt({provider:e}){let{t}=k(),{toast:o,confirm:s}=V(),c=ae(),u=e.authScheme===`oauth-subscription`,d=Te(e.id,u),f=r(e.id,u),p=n(e.id),m=ve(e.id,u),g=fe(e.id),_=ce(e.id),y=we(e.id),b=Ee(e.id),x=se(e.id),S=Oe(e.id),ee=ne(e.id),C=v(e.id),w=xe(e.id),T=e.templateId===`openai-subscription`,E=Ae(u&&T),re=he(e.id),ie=e.templateId===`github-copilot-subscription`,O=Pe(u&&ie),oe=Ce(e.id),[le,A]=(0,Q.useState)(`all`),[j,ue]=(0,Q.useState)(``),[M,P]=(0,Q.useState)(new Set),[I,R]=(0,Q.useState)(null),[de,pe]=(0,Q.useState)(null),[z,me]=(0,Q.useState)(!1),[ge,_e]=(0,Q.useState)(``),[ye,Se]=(0,Q.useState)(!1),[H,U]=(0,Q.useState)(!1),[W,De]=(0,Q.useState)(null),[ke,je]=(0,Q.useState)(null),[Me,Ne]=(0,Q.useState)(!1),[Fe,Ie]=(0,Q.useState)(``),Le=(0,Q.useRef)(new Set),ze=(0,Q.useRef)(new Set),K=(0,Q.useMemo)(()=>d.data??[],[d.data]);if((0,Q.useEffect)(()=>{if(u)for(let e of K){if(e.status!==`active`||ze.current.has(e.id))continue;let t=e.quota?.fetchedAtUtc?new Date(e.quota.fetchedAtUtc).getTime():0;Number.isFinite(t)&&Date.now()-t<Kt||(ze.current.add(e.id),b.mutate(e.id,{onError:()=>{}}))}},[K,u]),(0,Q.useEffect)(()=>{let e=new Set(K.map(e=>e.id));P(t=>Array.from(t).every(t=>e.has(t))?t:new Set(Array.from(t).filter(t=>e.has(t)))),I&&!e.has(I)&&R(null)},[K,I]),(0,Q.useEffect)(()=>{if(!H||W?.mode!==`pkce`)return;let e=setInterval(()=>void d.refetch(),3e3);return()=>clearInterval(e)},[H,W,d]),(0,Q.useEffect)(()=>{if(!H||W?.mode!==`pkce`)return;let e=K.find(e=>!Le.current.has(e.id));e&&J(!0,e.displayName||e.accountEmail||e.id)},[K,H,W]),(0,Q.useEffect)(()=>{if(!H||W?.mode!==`device`&&W?.mode!==`cli`)return;let e=!1,t=0,n=async()=>{try{let n=await _.mutateAsync(W.state);if(e)return;t=0,n.status===`done`?J(!0,n.account.displayName||n.account.accountEmail||n.account.id):n.status!==`pending`&&n.status!==`slow_down`&&J(!1,void 0,`error`in n?n.error??n.status:n.status)}catch(n){if(e)return;if(n instanceof N&&(n.status===404||n.status===400)){J(!1,void 0,L(n));return}++t>=5&&J(!1,void 0,L(n))}},r=setInterval(()=>void n(),Math.max(W.interval||5,3)*1e3);return()=>{e=!0,clearInterval(r)}},[H,W]),!u)return null;let q=e=>e.displayName||e.accountEmail||e.keyMasked||e.id,J=(n,r,i)=>{if(c.invalidateQueries({queryKey:a.providerAccounts(e.id)}),n){De(null),je(null),U(!1),o(t(`providers.subscription.loginOk`,{name:r??``}),`success`);return}i&&je(i)},Y=(e,n)=>{Le.current=new Set(K.map(e=>e.id)),je(null),g.mutate({accountId:e,httpProxy:n},{onSuccess:e=>{me(!1),De(e),U(!0),e.mode!==`device`&&window.open(e.authorizeUrl,`_blank`,`noopener`)},onError:e=>{e instanceof N&&e.details?.needsVerification?o(t(`providers.subscription.needsVerification`),`error`):o(L(e),`error`)}})},Be=async()=>{if(W){Ne(!0);try{let e=await _.mutateAsync(W.state);e.status===`done`?J(!0,e.account.displayName||e.account.accountEmail||e.account.id):e.status===`pending`||e.status===`slow_down`?o(t(`providers.subscription.stillWaiting`),`info`):J(!1,void 0,`error`in e?e.error??e.status:e.status)}catch(e){if(e instanceof N&&e.status===404){let t=((await d.refetch()).data??[]).find(e=>!Le.current.has(e.id));t?J(!0,t.displayName||t.accountEmail||t.id):J(!1,void 0,L(e))}else J(!1,void 0,L(e))}finally{Ne(!1)}}},Ve=async()=>{if(W&&W.mode===`paste`&&Fe.trim().length!==0){Ne(!0);try{let e=await y.mutateAsync({state:W.state,code:Fe.trim()});e.status===`done`?(Ie(``),J(!0,e.account.displayName||e.account.accountEmail||e.account.id)):J(!1,void 0,`error`in e?e.error??e.status:e.status)}catch(e){J(!1,void 0,L(e))}finally{Ne(!1)}}},Ue=()=>re.mutate(void 0,{onSuccess:e=>{o(t(`providers.subscription.importOk`,{name:q(e.account)}),e.warning?`info`:`success`),e.warning&&o(e.warning,`error`),E.refetch()},onError:e=>o(L(e),`error`)}),We=()=>oe.mutate(``,{onSuccess:e=>{o(t(`providers.subscription.importOk`,{name:q(e.account)}),e.warning?`info`:`success`),e.warning&&o(e.warning,`error`)},onError:e=>o(L(e),`error`)}),Ge=(e,t)=>{let n=K.map(e=>e.id),r=e+t;r<0||r>=n.length||([n[e],n[r]]=[n[r],n[e]],w.mutate(n,{onError:e=>o(L(e),`error`)}))},qe=async e=>{let n=q(e);await s({title:t(`providers.subscription.logoutConfirm`,{name:n}),destructive:!0,confirmLabel:t(`providers.subscription.logout`)})&&S.mutate(e.id,{onError:e=>o(L(e),`error`)})},Je={open:e=>R(e.id),activate:e=>ee.mutate(e.id,{onSuccess:()=>o(t(`providers.subscription.activated`,{name:q(e)}),`success`),onError:e=>o(L(e),`error`)}),toggleEnabled:e=>C.mutate({id:e.id,enabled:!e.enabled},{onError:e=>o(L(e),`error`)}),refreshQuota:e=>b.mutate(e.id,{onError:e=>{e instanceof N&&e.status===501?o(t(`providers.subscription.quotaUnsupported`),`error`):o(L(e),`error`)}}),refreshToken:e=>x.mutate(e.id,{onSuccess:()=>o(t(`providers.subscription.tokenRefreshed`),`success`),onError:e=>o(L(e),`error`)}),relogin:e=>Y(e.id),remove:e=>void qe(e)},Ye=e=>P(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Xe=async n=>{let r=K.filter(e=>M.has(e.id));Se(!0);let i=0;for(let e of r)try{await n(e),i++}catch(t){o(`${q(e)}: ${L(t)}`,`error`)}Se(!1),P(new Set),c.invalidateQueries({queryKey:a.providerAccounts(e.id)}),i>0&&o(t(`providers.accounts.bulkDone`,{n:i}),`success`)},Ze=async()=>{await s({title:t(`providers.accounts.bulkDeleteConfirm`,{n:M.size}),detail:t(`providers.accounts.bulkDeleteDetail`),destructive:!0,confirmLabel:t(`common.delete`)})&&await Xe(e=>S.mutateAsync(e.id))},Qe=K.map(e=>jt(e)),Z=e=>e===`all`?K.length:Qe.filter(t=>t===e).length,$e=j.trim().toLowerCase(),et=K.map((e,t)=>({a:e,index:t,state:Qe[t]})).filter(({a:e,state:t})=>(le===`all`||t===le)&&($e.length===0||[e.displayName,e.accountEmail,e.keyMasked,e.plan].some(e=>e?.toLowerCase().includes($e)))),tt=K.find(e=>e.id===I)??null,nt=m.data,rt=M.size>0,it=[{id:`login`,label:t(`providers.accounts.addLogin`),icon:(0,$.jsx)(vt,{className:`size-3.5`}),onSelect:()=>Y()},{id:`login-proxy`,label:t(`providers.accounts.addLoginProxy`),onSelect:()=>me(!0)},...T&&E.data?.available?[{id:`codex`,separatorBefore:!0,label:t(`providers.subscription.importCodex`),icon:(0,$.jsx)(He,{className:`size-3.5`}),onSelect:Ue}]:[],...ie?[{id:`copilot`,separatorBefore:!0,label:t(`providers.subscription.importCopilot`),icon:(0,$.jsx)(He,{className:`size-3.5`}),onSelect:We}]:[],...nt?.supported?[{id:`token`,separatorBefore:!(T&&E.data?.available)&&!ie,label:t(`providers.accounts.addToken`),onSelect:()=>pe(`token`)}]:[],...nt?.apiKey?[{id:`apikey`,label:t(`providers.accounts.addApiKey`),icon:(0,$.jsx)(Re,{className:`size-3.5`}),onSelect:()=>pe(`apiKey`)}]:[]];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`card mb-3 flex flex-wrap items-center gap-x-4 gap-y-2 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`mr-auto flex flex-wrap items-center gap-x-3 gap-y-1 text-[12px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[var(--text)]`,children:t(`providers.accounts.statTotal`,{n:K.length})}),(0,$.jsx)(`span`,{style:{color:`var(--success)`},children:t(`providers.accounts.statUsable`,{n:Z(`usable`)})}),Z(`cooling`)>0&&(0,$.jsx)(`span`,{style:{color:`var(--warning)`},children:t(`providers.accounts.statCooling`,{n:Z(`cooling`)})}),Z(`dead`)>0&&(0,$.jsx)(`span`,{style:{color:`var(--danger)`},children:t(`providers.accounts.statDead`,{n:Z(`dead`)})}),(0,$.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`providers.accounts.providerProxy`,{proxy:e.httpProxy||t(`providers.accounts.proxyFallbackSystem`)})})]}),f.data&&(0,$.jsx)(Jt,{policy:f.data,onChange:e=>p.mutate({switchMode:e},{onError:e=>o(L(e),`error`)})})]}),f.data&&(0,$.jsx)(`p`,{className:`-mt-1 mb-3 px-1 text-[11px] text-[var(--text-muted)]`,children:t(f.data.switchMode===`balanced`?`providers.subscription.policy.balancedDetail`:f.data.switchMode===`failover`?`providers.subscription.policy.failoverDetail`:`providers.subscription.policy.manualDetail`)}),(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(te,{className:`w-52`,value:j,onChange:ue,placeholder:t(`providers.accounts.search`)}),(0,$.jsx)(`div`,{role:`group`,"aria-label":t(`providers.accounts.filterLabel`),className:`mr-auto flex flex-wrap gap-1`,children:Gt.filter(e=>e.value===`all`||Z(e.value)>0).map(e=>(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":le===e.value,onClick:()=>A(e.value),className:i(`rounded-full px-2.5 py-0.5 text-[11.5px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--fill)]`,le===e.value&&`bg-[var(--fill)] text-[var(--text)]`),children:[t(e.label),(0,$.jsx)(`span`,{className:`ml-1 text-[var(--text-muted)]`,children:Z(e.value)})]},e.value))}),nt?.supported&&(0,$.jsx)(l,{size:`sm`,icon:(0,$.jsx)(gt,{className:`size-3.5`}),onClick:()=>pe(`batch`),children:t(`providers.accounts.batchImport`)}),(0,$.jsx)(be,{label:t(`providers.accounts.add`),icon:(0,$.jsx)(G,{className:`size-3.5`}),items:it})]}),T&&E.data?.available&&(0,$.jsxs)(`p`,{className:`mb-2 px-1 text-[11px] text-[var(--text-muted)]`,children:[t(`providers.subscription.localCodexFound`,{who:E.data.accountEmail??E.data.plan??t(`providers.subscription.unknownAccount`)}),E.data.detail?` · ${E.data.detail}`:``]}),ie&&(0,$.jsxs)(`p`,{className:`mb-2 px-1 text-[11px] text-[var(--text-muted)]`,children:[O.data?.available?t(`providers.subscription.localCopilotFound`,{source:O.data.source??``}):t(`providers.subscription.localCopilotHint`),O.data?.detail?` · ${O.data.detail}`:``]}),d.isLoading?(0,$.jsx)(F,{className:`my-4`}):K.length===0?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Y(),className:`flex w-full flex-col items-center gap-1 rounded-[var(--radius-card,12px)] border border-dashed border-[var(--border)] px-4 py-6 text-[12px] text-[var(--text-secondary)] hover:border-[var(--accent)] hover:text-[var(--text)]`,children:[(0,$.jsx)(`span`,{children:t(`providers.subscription.none`)}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[var(--accent)]`,children:[(0,$.jsx)(G,{className:`size-3.5`}),` `,t(`providers.subscription.login`)]})]}):et.length===0?(0,$.jsx)(`div`,{className:`px-4 py-5 text-center text-[12px] text-[var(--text-secondary)]`,children:t(`providers.accounts.noMatch`)}):(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(190px,1fr))] gap-3`,children:et.map(({a:e,index:t})=>(0,$.jsx)(Ft,{account:e,index:t,actions:Je,selected:M.has(e.id),selecting:rt,onToggleSelect:Ye,quotaPending:b.isPending&&b.variables===e.id,onMove:K.length>1?{up:t>0?()=>Ge(t,-1):void 0,down:t<K.length-1?()=>Ge(t,1):void 0}:void 0},e.id))}),(0,$.jsx)(`p`,{className:`mt-2 px-1 text-[11px] text-[var(--text-muted)]`,children:t(`providers.subscription.footer`)}),rt&&(0,$.jsxs)(`div`,{className:`card sticky bottom-3 z-10 mt-3 flex flex-wrap items-center gap-1.5 px-3 py-1.5 shadow-lg`,children:[(0,$.jsx)(`span`,{className:`mr-auto text-[12px] text-[var(--text-secondary)]`,children:t(`providers.accounts.selected`,{n:M.size})}),(0,$.jsx)(l,{size:`sm`,icon:(0,$.jsx)(Ke,{className:`size-3.5`}),disabled:ye,onClick:()=>void Xe(e=>C.mutateAsync({id:e.id,enabled:!0})),children:t(`providers.subscription.enable`)}),(0,$.jsx)(l,{size:`sm`,disabled:ye,onClick:()=>void Xe(e=>C.mutateAsync({id:e.id,enabled:!1})),children:t(`providers.subscription.disable`)}),(0,$.jsx)(l,{size:`sm`,disabled:ye,onClick:()=>void Xe(e=>b.mutateAsync(e.id)),children:t(`providers.subscription.quotaRefresh`)}),(0,$.jsx)(l,{size:`sm`,className:`text-[var(--danger)]`,icon:(0,$.jsx)(X,{className:`size-3.5`}),disabled:ye,onClick:()=>void Ze(),children:t(`common.delete`)}),(0,$.jsx)(l,{size:`sm`,variant:`plain`,onClick:()=>P(new Set),children:t(`providers.accounts.clearSelection`)})]}),(0,$.jsx)(`div`,{className:`mt-5`,children:(0,$.jsx)(Wt,{provider:e})}),(0,$.jsx)(Ut,{provider:e,account:tt,index:tt?K.indexOf(tt):0,actions:Je,onClose:()=>R(null)}),nt&&(0,$.jsx)(At,{providerId:e.id,info:nt,mode:de,providerProxy:e.httpProxy,onClose:()=>pe(null)}),(0,$.jsx)(B,{open:z,onOpenChange:me,title:t(`providers.accounts.loginProxyTitle`),description:t(`providers.accounts.loginProxyDesc`),footer:(0,$.jsx)(l,{variant:`primary`,loading:g.isPending,disabled:ge.trim().length===0,onClick:()=>Y(void 0,ge),children:t(`providers.accounts.loginProxyStart`)}),children:(0,$.jsx)(h,{mono:!0,label:t(`providers.accounts.detail.proxy`),placeholder:`socks5://127.0.0.1:1080`,value:ge,onChange:e=>_e(e.target.value)})}),(0,$.jsxs)(B,{open:H,onOpenChange:e=>{U(e),e||(De(null),je(null))},title:t(`providers.subscription.login`),description:t(`providers.subscription.loginDesc`),children:[ke&&(0,$.jsx)(D,{tone:`danger`,title:t(`providers.subscription.loginFailed`),children:ke}),W?.mode===`paste`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(D,{tone:`info`,title:t(`providers.subscription.pasteTitle`),children:t(`providers.subscription.pasteDetail`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsx)(l,{onClick:()=>window.open(W.authorizeUrl,`_blank`,`noopener`),children:t(`providers.subscription.openAuthorize`)})}),(0,$.jsx)(h,{mono:!0,value:Fe,onChange:e=>Ie(e.target.value),placeholder:t(`providers.subscription.pastePlaceholder`),"aria-label":t(`providers.subscription.pasteCode`)}),(0,$.jsx)(l,{variant:`primary`,loading:Me,onClick:()=>void Ve(),children:t(`providers.subscription.pasteSubmit`)})]}),W?.mode===`pkce`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(D,{tone:`info`,title:t(`providers.subscription.waiting`),children:t(`providers.subscription.waitingDetail`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(l,{onClick:()=>window.open(W.authorizeUrl,`_blank`,`noopener`),children:t(`providers.subscription.openAuthorize`)}),(0,$.jsx)(l,{variant:`primary`,onClick:()=>{c.invalidateQueries({queryKey:a.providerAccounts(e.id)}),d.refetch()},children:t(`providers.subscription.doneAuthorize`)})]})]}),W?.mode===`cli`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(D,{tone:`info`,title:t(`providers.subscription.waiting`),children:t(`providers.subscription.cliDetail`)}),(0,$.jsx)(l,{onClick:()=>window.open(W.authorizeUrl,`_blank`,`noopener`),children:t(`providers.subscription.openAuthorize`)})]}),W?.mode===`device`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-[11px] text-[var(--text-secondary)]`,children:t(`providers.subscription.deviceCode`)}),(0,$.jsx)(`div`,{className:`selectable font-mono text-[18px] font-medium tracking-wide`,children:W.userCode})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[W.verificationUrl&&(0,$.jsx)(l,{onClick:()=>window.open(W.verificationUrl??void 0,`_blank`,`noopener`),children:t(`providers.subscription.visitPage`)}),(0,$.jsx)(l,{variant:`primary`,loading:Me,onClick:()=>void Be(),children:t(`providers.subscription.checkNow`)})]}),(0,$.jsx)(D,{tone:`info`,title:t(`providers.subscription.waiting`),children:t(`providers.subscription.checkNowHint`)})]})]})]})}function Jt({policy:e,onChange:t}){let{t:n}=k();return(0,$.jsx)(x,{ariaLabel:n(`providers.subscription.policy.switchMode`),value:e.switchMode,onChange:t,items:[{value:`manual`,label:n(`providers.subscription.policy.manual`)},{value:`failover`,label:n(`providers.subscription.policy.failover`)},{value:`balanced`,label:n(`providers.subscription.policy.balanced`)}]})}function Yt({provider:e}){let{t}=k(),i=Te(e.id),a=E(e.id),o=r(e.id,!0),s=n(e.id),{toast:c}=V(),[u,d]=(0,Q.useState)(null);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a.isLoading&&(0,$.jsx)(F,{lines:1}),a.isError&&(0,$.jsx)(D,{tone:`danger`,title:t(`pluginAccounts.noPlugin`),children:L(a.error)}),a.data?.map(e=>(0,$.jsx)(l,{variant:e.index===0?`primary`:void 0,icon:e.type===`api`?(0,$.jsx)(Re,{className:`size-3.5`}):(0,$.jsx)(vt,{className:`size-3.5`}),onClick:()=>d(e),children:e.label||t(e.type===`api`?`pluginAccounts.apiKey`:`pluginAccounts.browser`)},e.index))]}),i.isLoading&&(0,$.jsx)(F,{lines:3}),i.data?.length===0&&(0,$.jsx)(`div`,{className:`card`,children:(0,$.jsx)(Fe,{icon:(0,$.jsx)(bt,{className:`size-6`}),title:t(`pluginAccounts.empty`),detail:t(`pluginAccounts.emptyDetail`)})}),i.data&&i.data.length>1&&o.data&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 px-1`,children:[(0,$.jsx)(`p`,{className:`min-w-0 flex-1 text-[12px] text-[var(--text-secondary)]`,children:t(o.data.switchMode===`balanced`?`providers.subscription.policy.balancedDetail`:o.data.switchMode===`failover`?`providers.subscription.policy.failoverDetail`:`providers.subscription.policy.manualDetail`)}),(0,$.jsx)(Jt,{policy:o.data,onChange:e=>s.mutate({switchMode:e},{onError:e=>c(L(e),`error`)})})]}),i.data&&i.data.length>0&&(0,$.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] overflow-hidden p-0`,children:i.data.map(t=>(0,$.jsx)(Zt,{provider:e,account:t},t.id))}),(0,$.jsx)(Xt,{provider:e}),u&&(0,$.jsx)(Qt,{provider:e,method:u,onClose:()=>d(null)})]})}function Xt({provider:e}){let{t,locale:n}=k(),{toast:r}=V(),i=o(e.id),a=ie(e.id);if(!i.data?.supported)return null;let s=e=>a.mutate(e,{onError:e=>r(L(e),`error`)});return(0,$.jsxs)(`section`,{className:`card flex flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`flex-1 text-[13px] font-medium`,children:t(`pluginAccounts.checkin`)}),(0,$.jsx)(P,{checked:i.data.on,label:t(`pluginAccounts.checkinOn`),onChange:e=>s(e)}),(0,$.jsx)(l,{size:`sm`,disabled:a.isPending,onClick:()=>s(),children:t(`pluginAccounts.checkinNow`)})]}),(0,$.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`pluginAccounts.checkinDetail`)}),i.data.accounts.map(e=>(0,$.jsx)(A,{label:e.account,children:e.outcome?[t(`pluginAccounts.outcome.${e.outcome}`),e.credit?t(`pluginAccounts.credit`,{credit:e.credit}):null,e.streak?t(`pluginAccounts.streak`,{days:e.streak}):null,e.message,e.at?R(e.at,n):null].filter(Boolean).join(` · `):t(`pluginAccounts.checkinNever`)},e.accountId))]})}function Zt({provider:e,account:t}){let{t:n,locale:r}=k(),{toast:i,confirm:a}=V(),o=p(e.id),[s,c]=(0,Q.useState)(!1),u=e.settings?.plugin?.usage===!0,d=b(e.id,t.id,s),f=async()=>{await a({title:n(`pluginAccounts.signOutConfirm`,{name:t.displayName}),confirmLabel:n(`pluginAccounts.signOut`),destructive:!0})&&o.mutate(t.id,{onError:e=>i(L(e),`error`)})};return(0,$.jsxs)(`article`,{className:`flex flex-col gap-2 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:t.displayName}),t.isCurrent&&(0,$.jsx)(O,{tone:`accent`,children:n(`pluginAccounts.current`)}),(0,$.jsx)(O,{tone:t.status===`active`?`green`:`red`,children:n(t.status===`active`?`pluginAccounts.active`:`pluginAccounts.lapsed`)}),u&&(0,$.jsx)(l,{size:`sm`,onClick:()=>c(e=>!e),children:n(`pluginAccounts.usage`)}),(0,$.jsx)(l,{size:`sm`,variant:`destructive`,icon:(0,$.jsx)(Ge,{className:`size-3.5`}),onClick:()=>void f(),children:n(`pluginAccounts.signOut`)})]}),t.status!==`active`&&(0,$.jsx)(`p`,{className:`text-[12px] text-[var(--danger)]`,children:n(`pluginAccounts.lapsedDetail`)}),s&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md bg-[var(--surface-muted)] px-3 py-2`,children:[d.isLoading&&(0,$.jsx)(F,{lines:2}),d.isError&&(0,$.jsx)(`span`,{className:`text-[12px] text-[var(--danger)]`,children:L(d.error)}),d.data?.error&&(0,$.jsx)(`span`,{className:`text-[12px] text-[var(--danger)]`,children:d.data.error}),d.data?.plan&&(0,$.jsx)(A,{label:n(`pluginAccounts.plan`),children:d.data.plan}),d.data?.until&&(0,$.jsx)(A,{label:n(`pluginAccounts.until`),children:R(d.data.until,r)}),d.data?.windows?.map(e=>(0,$.jsxs)(A,{label:e.name,children:[e.display??(e.limit?`${e.amount??e.used??0} / ${e.limit} ${e.unit??``}`:`${e.used??0}%`),e.resetsAt?` · ${n(`pluginAccounts.resets`,{at:R(new Date(e.resetsAt>0xe8d4a51000?e.resetsAt:e.resetsAt*1e3).toISOString(),r)})}`:``]},e.name))]})]})}function Qt({provider:e,method:n,onClose:r}){let{t:i}=k(),{toast:a}=V(),[o,s]=(0,Q.useState)({}),[u,d]=(0,Q.useState)(void 0),[f,p]=(0,Q.useState)(``),[m,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(null),ee=Me(e.id),te=c(e.id),C=le(e.id),w=oe(e.id,x).data;(0,Q.useEffect)(()=>{let t=!0;return re(e.id,n.index,o).then(e=>{t&&(d(e.prompt),p(e.prompt?.type===`select`?e.prompt.options?.[0]?.value??``:``))}).catch(e=>t&&a(L(e),`error`)),()=>{t=!1}},[e.id,n.index,o,a]),(0,Q.useEffect)(()=>{w?.state===`done`&&(a(i(`pluginAccounts.signedIn`),`success`),r())},[w?.state,r,i,a]);let T=async()=>{if(!u)return;let t=await ye(e.id,n.index,u.key,f).catch(()=>({error:null}));if(t.error)return g(t.error);g(null),s(e=>({...e,[u.key]:f}))};return(0,$.jsxs)(B,{open:!0,onOpenChange:e=>!e&&r(),title:i(`pluginAccounts.signInTitle`,{name:e.name}),description:n.label,width:520,children:[u===void 0&&(0,$.jsx)(F,{lines:2}),u&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(t,{label:u.message,error:m??void 0,children:u.type===`select`?(0,$.jsx)(U,{value:f,onChange:p,options:(u.options??[]).map(e=>({value:e.value,label:e.label,description:e.hint??void 0}))}):(0,$.jsx)(h,{value:f,placeholder:u.placeholder??void 0,onChange:e=>p(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(l,{variant:`primary`,onClick:()=>void T(),children:i(`pluginAccounts.continue`)})})]}),u===null&&n.type===`api`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(t,{label:i(`pluginAccounts.key`),children:(0,$.jsx)(h,{mono:!0,type:`password`,value:_,placeholder:n.placeholder??void 0,onChange:e=>v(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(l,{variant:`primary`,disabled:!_.trim()||te.isPending,onClick:()=>te.mutate({method:n.index,inputs:o,key:_},{onSuccess:()=>(a(i(`pluginAccounts.signedIn`),`success`),r()),onError:e=>a(L(e),`error`)}),children:i(`pluginAccounts.signIn`)})})]}),u===null&&n.type!==`api`&&!w&&(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(l,{variant:`primary`,icon:(0,$.jsx)(We,{className:`size-3.5`}),disabled:ee.isPending,onClick:()=>ee.mutate({method:n.index,inputs:o},{onSuccess:e=>{S(e.id),e.url&&window.open(e.url,`_blank`,`noopener`)},onError:e=>a(L(e),`error`)}),children:i(`pluginAccounts.openPage`)})}),w&&w.state!==`done`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[w.instructions&&(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[12px] text-[var(--text-secondary)]`,children:w.instructions}),w.deviceCode&&(0,$.jsx)(A,{label:i(`pluginAccounts.deviceCode`),mono:!0,children:w.deviceCode}),w.url&&(0,$.jsx)(l,{icon:(0,$.jsx)(We,{className:`size-3.5`}),onClick:()=>window.open(w.url,`_blank`,`noopener`),children:i(`pluginAccounts.openAgain`)}),w.state===`waiting`&&w.pasteCode&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(t,{label:i(`pluginAccounts.code`),children:(0,$.jsx)(h,{mono:!0,value:y,onChange:e=>b(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(l,{variant:`primary`,disabled:!y.trim()||C.isPending,onClick:()=>C.mutate({flow:w.id,code:y.trim()},{onError:e=>a(L(e),`error`)}),children:i(`pluginAccounts.signIn`)})})]}),w.state===`waiting`&&!w.pasteCode&&(0,$.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:i(`pluginAccounts.waiting`)}),w.state===`failed`&&(0,$.jsx)(D,{tone:`danger`,title:i(`pluginAccounts.failed`),children:w.error})]})]})}function $t(e){let t=e?.model_map,n={};if(!t||typeof t!=`object`||Array.isArray(t))return n;for(let[e,r]of Object.entries(t))e&&typeof r==`string`&&r&&(n[e]=r);return n}function en(){let{t:e}=k(),{id:t=``}=K(),n=Le(),r=C(t),[i,a]=(0,Q.useState)(`models`),[o,s]=(0,Q.useState)(null),c=ee(t),l=c.data?.find(e=>e.id===o)??null;if(r.isError)return(0,$.jsx)(ze,{title:e(`nav.providers`),leading:(0,$.jsx)(tn,{onClick:()=>n(`/providers`)}),children:(0,$.jsx)(D,{tone:`danger`,title:e(`common.error`),children:L(r.error)})});let u=r.data;return(0,$.jsx)(ze,{title:u?u.name:``,subtitle:u?[u.templateId,u.priceKey?e(`providers.priceKeyShort`,{key:u.priceKey}):null].filter(Boolean).join(` · `):void 0,leading:(0,$.jsx)(tn,{onClick:()=>n(`/providers`)}),actions:u&&(0,$.jsx)(nn,{p:u}),children:u?(0,$.jsxs)(Ze,{className:`mx-auto max-w-[860px]`,value:i,onValueChange:e=>a(e),children:[(0,$.jsxs)(et,{"aria-label":u.name,children:[(0,$.jsx)(tt,{value:`models`,children:e(`providers.tab.models`)}),(0,$.jsx)(tt,{value:`accounts`,children:e(u.authScheme===`oauth-subscription`||u.authScheme===`plugin`?`providers.tab.accounts`:`providers.tab.apiKey`)}),(0,$.jsx)(tt,{value:`settings`,children:e(`providers.tab.settings`)})]}),(0,$.jsx)(Ye,{value:`models`,className:`pt-4`,children:(0,$.jsx)(an,{provider:u,models:c.data,loading:c.isLoading,selected:o,onSelect:s})}),(0,$.jsx)(Ye,{value:`accounts`,className:`pt-4`,children:u.authScheme===`plugin`?(0,$.jsx)(Yt,{provider:u}):u.authScheme===`oauth-subscription`?(0,$.jsx)(qt,{provider:u}):(0,$.jsx)(fn,{provider:u})}),(0,$.jsx)(Ye,{value:`settings`,className:`pt-4`,children:(0,$.jsx)(mn,{provider:u})}),(0,$.jsx)(dn,{provider:u,pm:i===`models`?l:null,onClose:()=>s(null)})]}):(0,$.jsx)(F,{lines:4,className:`mx-auto mt-6 max-w-[860px]`})})}function tn({onClick:e}){let{t}=k();return(0,$.jsx)(l,{variant:`glass`,icon:(0,$.jsx)(J,{className:`size-4`}),"aria-label":t(`common.back`),onClick:e})}function nn({p:e}){let{t}=k(),n=Le(),{toast:r,confirm:i}=V(),a=de(),o=me(),[s,c]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=async()=>{await i({title:t(`providers.deleteConfirm`,{name:e.name}),detail:t(`providers.deleteDetail`),destructive:!0,confirmLabel:t(`common.delete`)})&&o.mutate(e.id,{onSuccess:()=>{r(t(`providers.deleted`)),n(`/providers`)},onError:e=>{let n=e instanceof N&&e.status===409?e.details?.boundClients??[]:[];r(n.length?t(`providers.deleteBound`,{clients:n.map(e=>$e[e]?.name??e).join(`, `)}):L(e),`error`)}})};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{icon:(0,$.jsx)(at,{className:`size-3.5`}),onClick:()=>d(!0),children:t(`providers.test`)}),(0,$.jsx)(be,{label:t(`common.more`),icon:(0,$.jsx)(Ue,{className:`size-4`}),items:[{id:`dup`,label:t(`providers.duplicate`),icon:(0,$.jsx)(De,{className:`size-3.5`}),onSelect:()=>a.mutate(e.id,{onSuccess:e=>n(`/providers/${e.id}`),onError:e=>r(L(e),`error`)})},{id:`tpl`,label:t(`providers.templateUpdate`),icon:(0,$.jsx)(St,{className:`size-3.5`}),disabled:!e.templateId,onSelect:()=>c(!0)},{id:`del`,label:t(`common.delete`),icon:(0,$.jsx)(X,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void f()}]}),(0,$.jsx)(rn,{open:s,onOpenChange:c,provider:e}),(0,$.jsx)(ct,{provider:e,open:u,onOpenChange:d})]})}function rn({open:e,onOpenChange:t,provider:n}){let{t:r}=k(),{toast:i}=V(),a=s(n.id,e),o=y(n.id),c=a.data&&a.data.latestVersion<=a.data.currentVersion;return(0,$.jsxs)(B,{open:e,onOpenChange:t,title:r(`providers.templateUpdate`),description:a.data?r(`providers.templateVersions`,{current:a.data.currentVersion,latest:a.data.latestVersion}):void 0,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(l,{variant:`primary`,disabled:!a.data||c,loading:o.isPending,onClick:()=>o.mutate(void 0,{onSuccess:()=>{t(!1),i(r(`providers.templateApplied`),`success`)},onError:e=>i(L(e),`error`)}),children:r(`common.apply`)})]}),children:[a.isLoading&&(0,$.jsx)(F,{}),a.isError&&(0,$.jsx)(D,{tone:`danger`,title:r(`common.error`),children:L(a.error)}),c&&(0,$.jsx)(D,{tone:`success`,title:r(`providers.templateUpToDate`)}),a.data&&!c&&(0,$.jsx)(`ul`,{className:`list-disc pl-5 text-[12px]`,children:a.data.changes.map((e,t)=>(0,$.jsx)(`li`,{children:e},t))})]})}function an({provider:e,models:t,loading:n,selected:r,onSelect:a}){let{t:o}=k(),{toast:s}=V(),[c,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(!1),[p,h]=(0,Q.useState)(!1),g=T(e.id),_=(t??[]).filter(e=>!c||e.modelId.toLowerCase().includes(c.toLowerCase())||e.effective.displayName.toLowerCase().includes(c.toLowerCase()));return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(te,{className:`w-56`,value:c,onChange:u,placeholder:o(`providers.searchModels`)}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(l,{icon:(0,$.jsx)(G,{className:`size-3.5`}),onClick:()=>h(!0),children:o(`providers.addModels`)}),(0,$.jsx)(l,{variant:`primary`,icon:(0,$.jsx)(Ve,{className:`size-3.5`}),onClick:()=>f(!0),children:o(`providers.fetchRemote`)})]})]}),n&&(0,$.jsx)(F,{lines:4}),t?.length===0&&(0,$.jsx)(`div`,{className:`card`,children:(0,$.jsx)(Fe,{title:o(`providers.noModels`),detail:o(`providers.noModelsDetail`)})}),_.length>0&&(0,$.jsx)(j,{footer:o(`providers.modelsFooter`),children:_.map(e=>(0,$.jsxs)(m,{selected:e.id===r,onClick:()=>a(e.id),label:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:i(`font-mono text-[12.5px]`,!e.enabled&&`text-[var(--text-muted)]`),children:e.modelId}),!e.systemModelId&&(0,$.jsx)(O,{tone:`orange`,children:o(`providers.unlinked`)})]}),detail:[e.effective.displayName===e.modelId?null:e.effective.displayName,e.effective.contextWindow?_e(e.effective.contextWindow):null,Ne(e.effectivePricing)].filter(Boolean).join(` · `),children:[(0,$.jsx)(Xe,{source:e.pricingSource,priceKey:e.priceKey}),(0,$.jsx)(P,{checked:e.enabled,label:o(`common.enabled`),onChange:t=>g.mutate({pmId:e.id,enabled:t},{onError:e=>s(L(e),`error`)})})]},e.id))}),t&&(0,$.jsx)(on,{provider:e,models:t}),(0,$.jsx)(cn,{open:p,onOpenChange:h,provider:e}),(0,$.jsx)(ln,{open:d,onOpenChange:f,provider:e})]})}function on({provider:e,models:t}){let{t:n}=k(),{toast:r}=V(),a=ge(e.id),[o,s]=(0,Q.useState)(!1),c=$t(e.settings),u=Object.entries(c),d=new Set(t.map(e=>e.modelId)),f=(e,t)=>a.mutate(e,{onSuccess:()=>{t?.(),r(n(`providers.modelMap.saved`),`success`)},onError:e=>r(L(e),`error`)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(j,{title:n(`providers.modelMap.title`),footer:n(`providers.modelMap.footer`),children:[u.map(([e,t])=>(0,$.jsx)(m,{label:(0,$.jsxs)(`span`,{className:`flex items-center gap-2 font-mono text-[12.5px]`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e}),(0,$.jsx)(Je,{className:`size-3.5 shrink-0 text-[var(--text-muted)]`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:i(`truncate`,!d.has(t)&&`text-[var(--text-muted)]`),children:t}),!d.has(t)&&(0,$.jsx)(O,{tone:`orange`,children:n(`providers.modelMap.missingTarget`)})]}),children:(0,$.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(W,{className:`size-3.5`}),"aria-label":n(`providers.modelMap.remove`,{from:e}),title:n(`providers.modelMap.remove`,{from:e}),disabled:a.isPending,onClick:()=>f(Object.fromEntries(u.filter(([t])=>t!==e)))})},e)),(0,$.jsx)(m,{icon:(0,$.jsx)(G,{className:`size-4 text-[var(--text-secondary)]`}),label:n(`providers.modelMap.add`),detail:t.length===0?n(`providers.modelMap.needModels`):void 0,onClick:t.length===0?void 0:()=>s(!0)})]}),(0,$.jsx)(sn,{open:o,onOpenChange:s,models:t,saving:a.isPending,onSave:(e,t)=>f({...c,[e]:t},()=>s(!1))})]})}function sn({open:e,onOpenChange:t,models:n,saving:r,onSave:i}){let{t:a}=k(),[o,s]=(0,Q.useState)(``),[c,u]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&(s(``),u(``))},[e]);let d=o.trim();return(0,$.jsx)(B,{open:e,onOpenChange:t,title:a(`providers.modelMap.add`),description:a(`providers.modelMap.addDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{onClick:()=>t(!1),children:a(`common.cancel`)}),(0,$.jsx)(l,{variant:`primary`,disabled:!d||!c||d===c,loading:r,onClick:()=>i(d,c),children:a(`common.save`)})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(h,{autoFocus:!0,mono:!0,label:a(`providers.modelMap.from`),placeholder:`deepseek-v4.1`,spellCheck:!1,value:o,onChange:e=>s(e.target.value)}),(0,$.jsx)(U,{label:a(`providers.modelMap.to`),value:c,onChange:u,placeholder:a(`providers.modelMap.toPlaceholder`),options:n.map(e=>({value:e.modelId,label:e.modelId}))})]})})}function cn({open:e,onOpenChange:t,provider:n}){let{t:r}=k(),{toast:i}=V(),a=f(n.id),[o,s]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&s(``)},[e]);let c=[...new Set(o.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean))];return(0,$.jsx)(B,{open:e,onOpenChange:t,title:r(`providers.addModels`),description:r(`providers.addModelsDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(l,{variant:`primary`,disabled:c.length===0,loading:a.isPending,onClick:()=>a.mutate(c,{onSuccess:e=>{t(!1),i(r(`providers.modelsAdded`,{count:e.length}),`success`)},onError:e=>i(L(e),`error`)}),children:r(`providers.addSelected`,{count:c.length})})]}),children:(0,$.jsx)(I,{autoFocus:!0,label:r(`providers.modelIds`),rows:6,spellCheck:!1,className:`w-full font-mono text-[12px]`,placeholder:`deepseek-v4-pro
3
- claude-sonnet-4-6`,value:o,onChange:e=>s(e.target.value)})})}function ln({open:t,onOpenChange:n,provider:r}){let{t:i}=k(),{toast:a}=V(),o=e(r.id,t),s=f(r.id),[c,u]=(0,Q.useState)(new Set),[d,p]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{t&&u(new Set)},[t]);let h=(o.data??[]).filter(e=>!d||e.id.toLowerCase().includes(d.toLowerCase())),g=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,$.jsxs)(B,{open:t,onOpenChange:n,width:560,title:i(`providers.fetchRemote`),description:i(`providers.fetchRemoteDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{variant:`plain`,className:`mr-auto`,onClick:()=>u(new Set(h.filter(e=>!e.alreadyAdded).map(e=>e.id))),disabled:h.length===0,children:i(`common.selectAll`)}),(0,$.jsx)(l,{onClick:()=>n(!1),children:i(`common.cancel`)}),(0,$.jsx)(l,{variant:`primary`,disabled:c.size===0,loading:s.isPending,onClick:()=>s.mutate([...c],{onSuccess:e=>{n(!1),a(i(`providers.modelsAdded`,{count:e.length}),`success`)},onError:e=>a(L(e),`error`)}),children:i(`providers.addSelected`,{count:c.size})})]}),children:[(0,$.jsx)(te,{className:`mb-3`,value:d,onChange:p,placeholder:i(`providers.searchModels`)}),o.isLoading&&(0,$.jsx)(F,{lines:4}),o.isError&&(0,$.jsx)(D,{tone:`danger`,title:i(`common.error`),children:L(o.error)}),(0,$.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:h.map(e=>(0,$.jsx)(m,{onClick:e.alreadyAdded?void 0:()=>g(e.id),label:(0,$.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.id}),detail:e.linkedSystemModelId?i(`providers.linksTo`,{id:e.linkedSystemModelId}):i(`providers.noLink`),children:e.alreadyAdded?(0,$.jsx)(O,{children:i(`providers.added`)}):(0,$.jsx)(`span`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(Y,{"aria-label":e.id,checked:c.has(e.id),onCheckedChange:()=>g(e.id)})})},e.id))})]})}function un({origin:e}){let{t}=k();return e===`overridden`?(0,$.jsx)(O,{tone:`orange`,children:t(`origin.overridden`)}):e===`inherited`?(0,$.jsx)(O,{children:t(`origin.inherited`)}):(0,$.jsx)(O,{tone:`red`,children:t(`origin.unset`)})}function dn({provider:e,pm:t,onClose:n}){let{t:r}=k(),{toast:i}=V(),a=T(e.id),o=Se(e.id),s=je(),[c,u]=(0,Q.useState)({}),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{t&&(u(t.overrides),f(t.systemModelId??``),m(t.overrides.pricing!=null))},[t]),!t)return(0,$.jsx)(B,{open:!1,onOpenChange:()=>n(),title:r(`providers.tab.models`)});let _={...c,pricing:p?c.pricing??null:null},v=JSON.stringify(_)!==JSON.stringify({...t.overrides,pricing:t.overrides.pricing??null})||d!==(t.systemModelId??``),y=()=>a.mutate({pmId:t.id,overrides:_,systemModelId:d||null},{onSuccess:()=>{i(r(`common.saved`),`success`),n()},onError:e=>i(L(e),`error`)}),b=(e,n,i)=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[13px] font-medium`,children:n}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(un,{origin:c[e]==null?t.origins[e]===`overridden`?`inherited`:t.origins[e]:`overridden`}),c[e]!=null&&(0,$.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(qe,{className:`size-3`}),title:r(`origin.reset`),"aria-label":r(`origin.reset`),onClick:()=>u({...c,[e]:null})})]})]}),i]});return(0,$.jsx)(B,{open:!0,onOpenChange:e=>!e&&n(),width:720,title:t.modelId,description:e.name,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mr-auto`,children:(0,$.jsx)(nt,{label:r(`providers.removeModelShort`),icon:(0,$.jsx)(X,{className:`size-4`}),prompt:r(`providers.removeModel`,{id:t.modelId}),confirmLabel:r(`common.delete`),cancelLabel:r(`common.cancel`),pendingLabel:r(`common.deleting`),doneLabel:r(`common.deleted`),errorLabel:r(`common.error`),retryLabel:r(`common.retry`),onConfirm:async()=>{await o.mutateAsync(t.id),n()}})}),(0,$.jsx)(l,{onClick:n,children:r(`common.cancel`)}),(0,$.jsx)(l,{variant:`primary`,disabled:!v,loading:a.isPending,onClick:y,children:r(`common.save`)})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(Xe,{source:t.pricingSource,priceKey:t.priceKey}),t.multiplier!==1&&t.pricingSource!==`provider_override`&&(0,$.jsxs)(O,{children:[`×`,t.multiplier]})]}),(0,$.jsxs)(w,{title:r(`providers.linkedModel`),children:[(0,$.jsx)(U,{className:`w-full`,ariaLabel:r(`providers.linkedModel`),value:d,onChange:f,options:[{value:``,label:r(`providers.noLink`)},...(s.data??[]).map(e=>({value:e.id,label:e.id,detail:e.displayName}))]}),(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-[var(--text-muted)]`,children:r(`providers.linkedModelHint`)})]}),(0,$.jsx)(w,{title:r(`providers.overrides`),children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[b(`displayName`,r(`models.field.displayName`),(0,$.jsx)(h,{className:`w-full`,"aria-label":r(`models.field.displayName`),placeholder:t.effective.displayName,value:c.displayName??``,onChange:e=>u({...c,displayName:e.target.value||null})})),b(`contextWindow`,r(`models.field.contextWindow`),(0,$.jsx)(M,{className:`w-full`,label:r(`models.field.contextWindow`),placeholder:String(t.effective.contextWindow??``),value:c.contextWindow,onChange:e=>u({...c,contextWindow:e})})),b(`maxOutputTokens`,r(`models.field.maxOutputTokens`),(0,$.jsx)(M,{className:`w-full`,label:r(`models.field.maxOutputTokens`),placeholder:String(t.effective.maxOutputTokens??``),value:c.maxOutputTokens,onChange:e=>u({...c,maxOutputTokens:e})}))]})}),(0,$.jsxs)(w,{title:r(`providers.price`),action:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[r(`providers.customPrice`),(0,$.jsx)(P,{checked:p,label:r(`providers.customPrice`),onChange:e=>{m(e),e&&c.pricing==null&&u({...c,pricing:t.effectivePricing??{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}}})}})]}),children:[(0,$.jsx)(`p`,{className:`mb-3 text-[11px] text-[var(--text-muted)]`,children:r(p?`providers.customPriceHint`:`providers.inheritedPriceHint`)}),p?(0,$.jsx)(`div`,{className:`card p-4`,children:(0,$.jsx)(Qe,{value:c.pricing??null,onChange:e=>u({...c,pricing:e})})}):t.effectivePricing?(0,$.jsx)(g,{maxHeight:220,children:ke(t.effectivePricing)}):(0,$.jsx)(D,{tone:`warning`,title:r(`pricingSource.none`)})]})]})})}function fn({provider:e}){let{t}=k(),{toast:n}=V(),r=d(e.id),[i,a]=(0,Q.useState)(``);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(j,{title:t(`providers.section.auth`),footer:t(`providers.apiKeyStored`),children:(0,$.jsx)(m,{label:t(`providers.apiKey`),detail:e.hasApiKey?e.apiKeyMasked??`••••`:t(`providers.noKey`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(h,{type:`password`,autoComplete:`off`,className:`w-64 font-mono`,"aria-label":t(`providers.apiKey`),placeholder:t(`providers.replaceKey`),value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(l,{variant:`primary`,disabled:i.trim().length===0,loading:r.isPending,onClick:()=>r.mutate({apiKey:i},{onSuccess:()=>{a(``),n(t(`common.saved`),`success`)},onError:e=>n(L(e),`error`)}),children:t(`common.save`)})]})})}),(0,$.jsx)(ot,{provider:e})]})}function pn(e){return{name:e.name,apiKey:``,endpoints:e.endpoints,preferredUpstreamProtocols:e.preferredUpstreamProtocols,authScheme:e.authScheme,extraHeaders:e.extraHeaders,httpProxy:e.httpProxy??null,priceMultiplier:e.priceMultiplier,priceKey:e.priceKey??null,settings:e.settings,enabled:e.enabled,notes:e.notes??null}}function mn({provider:e}){let{t}=k(),{toast:n}=V(),r=d(e.id),i=ue(),a=(0,Q.useMemo)(()=>pn(e),[e]),[o,s]=(0,Q.useState)(a),[c,u]=(0,Q.useState)(Object.entries(e.extraHeaders)),[f,p]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{s(a),u(Object.entries(a.extraHeaders))},[a]);let v=e=>s(t=>({...t,...e})),y={...o,extraHeaders:Object.fromEntries(c.filter(([e])=>e.trim()))},b=JSON.stringify(y)!==JSON.stringify(a),x=()=>{let e={};for(let t of Object.keys(y))t!==`apiKey`&&JSON.stringify(y[t])!==JSON.stringify(a[t])&&(e[t]=y[t]);o.apiKey&&(e.apiKey=o.apiKey),r.mutate(e,{onSuccess:()=>n(t(`common.saved`),`success`),onError:e=>n(L(e),`error`)})},S=(e,t)=>v({endpoints:o.endpoints.map((n,r)=>r===e?{...n,...t}:n)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(j,{title:t(`providers.section.basic`),children:[(0,$.jsx)(m,{label:t(`providers.name`),children:(0,$.jsx)(h,{className:`w-64`,"aria-label":t(`providers.name`),value:o.name,onChange:e=>v({name:e.target.value})})}),(0,$.jsx)(m,{label:t(`common.enabled`),children:(0,$.jsx)(P,{checked:o.enabled,label:t(`common.enabled`),onChange:e=>v({enabled:e})})}),(0,$.jsx)(m,{label:t(`providers.notes`),children:(0,$.jsx)(h,{className:`w-64`,"aria-label":t(`providers.notes`),value:o.notes??``,onChange:e=>v({notes:e.target.value||null})})})]}),(0,$.jsx)(j,{title:t(`providers.section.auth`),children:(0,$.jsx)(m,{label:t(`providers.authScheme`),children:(0,$.jsx)(U,{className:`w-48`,value:o.authScheme,onChange:e=>v({authScheme:e}),options:rt})})}),(0,$.jsxs)(j,{title:t(`providers.section.endpoints`),footer:t(`providers.endpointsFooter`),children:[o.endpoints.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 py-3`,children:[(0,$.jsx)(U,{className:`w-48`,value:e.protocol,onChange:e=>S(n,{protocol:e}),options:it}),(0,$.jsx)(h,{className:`min-w-60 flex-1 font-mono`,"aria-label":t(`providers.baseUrl`),value:e.baseUrl,onChange:e=>S(n,{baseUrl:e.target.value})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(P,{checked:!!e.fullUrl,label:t(`providers.fullUrl`),onChange:e=>S(n,{fullUrl:e})}),t(`providers.fullUrl`)]}),(0,$.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(X,{className:`size-3.5`}),"aria-label":t(`common.delete`),onClick:()=>v({endpoints:o.endpoints.filter((e,t)=>t!==n)})})]},n)),(0,$.jsx)(`div`,{className:`px-4 py-2`,children:(0,$.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(G,{className:`size-3.5`}),onClick:()=>p(!0),children:t(`providers.addEndpoint`)})}),(0,$.jsx)(m,{label:t(`providers.preferred`),detail:(0,$.jsxs)($.Fragment,{children:[t(`providers.preferredHint`),o.preferredUpstreamProtocols.filter(e=>!o.endpoints.some(t=>t.protocol===e)).map(e=>(0,$.jsx)(`span`,{className:`mt-1 block text-[var(--warning)]`,children:t(`providers.preferredMissing`,{protocol:it.find(t=>t.value===e)?.label??e})},e))]}),children:(0,$.jsx)(Z,{label:t(`providers.preferred`),options:it.map(e=>{let t=o.preferredUpstreamProtocols.indexOf(e.value);return{value:e.value,label:t>=0?`${t+1}. ${e.label}`:e.label}}),value:o.preferredUpstreamProtocols,onValueChange:e=>{let t=o.preferredUpstreamProtocols.filter(t=>e.includes(t)),n=e.filter(e=>!t.includes(e));v({preferredUpstreamProtocols:[...t,...n]})}})})]}),(0,$.jsxs)(j,{title:t(`providers.section.billing`),footer:t(`providers.billingFooter`),children:[(0,$.jsx)(m,{label:t(`providers.priceKey`),detail:t(`providers.priceKeyHint`),children:(0,$.jsx)(U,{className:`w-56`,value:o.priceKey==null?`inherit`:`price:${o.priceKey}`,onChange:e=>v({priceKey:e===`inherit`?null:e.slice(6)}),options:[{value:`inherit`,label:t(`providers.priceKeyDefault`,{id:e.templateId??`—`})},{value:`price:`,label:t(`providers.priceKeyNone`)},...(i.data??[]).map(e=>({value:`price:${e.priceKey}`,label:e.label,detail:e.priceKey}))]})}),(0,$.jsx)(m,{label:t(`providers.multiplier`),detail:t(`providers.multiplierHint`),children:(0,$.jsx)(M,{className:`w-28`,label:t(`providers.multiplier`),step:.01,min:0,value:o.priceMultiplier,onChange:e=>v({priceMultiplier:e??1})})})]}),(0,$.jsxs)(j,{title:t(`providers.section.advanced`),children:[(0,$.jsx)(m,{label:t(`providers.proxy`),detail:t(`providers.proxyHint`),children:(0,$.jsx)(h,{className:`w-64 font-mono`,"aria-label":t(`providers.proxy`),placeholder:`http://127.0.0.1:7890`,value:o.httpProxy??``,onChange:e=>v({httpProxy:e.target.value||null})})}),(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-[13px]`,children:t(`providers.headers`)}),c.map(([e,n],r)=>(0,$.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,$.jsx)(h,{className:`w-48 font-mono`,"aria-label":t(`providers.headerName`),placeholder:`Header`,value:e,onChange:e=>u(c.map((t,n)=>n===r?[e.target.value,t[1]]:t))}),(0,$.jsx)(h,{className:`flex-1 font-mono`,"aria-label":t(`providers.headerValue`),placeholder:`value`,value:n,onChange:e=>u(c.map((t,n)=>n===r?[t[0],e.target.value]:t))}),(0,$.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(X,{className:`size-3.5`}),"aria-label":t(`common.delete`),onClick:()=>u(c.filter((e,t)=>t!==r))})]},r)),(0,$.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(G,{className:`size-3.5`}),onClick:()=>_(!0),children:t(`providers.addHeader`)})]}),Object.keys(e.settings).length>0&&(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsx)(I,{label:t(`providers.adapterSettings`),rows:4,className:`w-full font-mono`,defaultValue:ke(o.settings),onBlur:e=>{try{v({settings:JSON.parse(e.target.value)})}catch{n(t(`common.invalidJson`),`error`)}}})})]}),(0,$.jsx)(j,{title:t(`providers.section.info`),children:(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(A,{label:`ID`,children:e.id}),e.adapterId&&(0,$.jsx)(A,{label:t(`providers.adapter`),children:e.adapterId}),(0,$.jsx)(A,{label:t(`providers.boundClients`),children:e.boundClients.map(e=>$e[e]?.name??e).join(`, `)||`—`})]})}),(0,$.jsx)(hn,{open:f,onOpenChange:p,onAdd:e=>v({endpoints:[...o.endpoints,e]})}),(0,$.jsx)(gn,{open:g,onOpenChange:_,onAdd:e=>u([...c.filter(([t])=>t.toLowerCase()!==e[0].toLowerCase()),e])}),(0,$.jsx)(`div`,{className:`sticky bottom-2 flex justify-end`,children:b&&(0,$.jsxs)(`div`,{className:`glass flex items-center gap-2 rounded-full p-1 pl-4 text-[12px]`,children:[(0,$.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:t(`common.unsaved`)}),(0,$.jsx)(l,{size:`sm`,onClick:()=>{s(a),u(Object.entries(a.extraHeaders))},children:t(`common.revert`)}),(0,$.jsx)(l,{size:`sm`,variant:`primary`,loading:r.isPending,onClick:x,children:t(`common.save`)})]})})]})}function hn({open:e,onOpenChange:n,onAdd:r}){let{t:i}=k(),[a,o]=(0,Q.useState)(`openai-chat`),[s,c]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{e&&(c(``),d(!1))},[e]);let f=/^https?:\/\/\S+$/.test(s.trim());return(0,$.jsx)(B,{open:e,onOpenChange:n,title:i(`providers.addEndpoint`),description:i(`providers.addEndpointDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{onClick:()=>n(!1),children:i(`common.cancel`)}),(0,$.jsx)(l,{variant:`primary`,disabled:!f,onClick:()=>{r({protocol:a,baseUrl:s.trim(),...u?{fullUrl:!0}:{}}),n(!1)},children:i(`common.add`)})]}),children:(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsx)(t,{label:i(`providers.protocol`),children:(0,$.jsx)(U,{value:a,onChange:o,options:it})}),(0,$.jsx)(t,{label:i(`providers.baseUrl`),hint:i(u?`providers.fullUrlHint`:`providers.baseUrlHint`),children:(0,$.jsx)(h,{autoFocus:!0,className:`font-mono`,placeholder:`https://api.example.com/v1`,value:s,invalid:s!==``&&!f,onChange:e=>c(e.target.value)})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(P,{checked:u,onChange:d,label:i(`providers.fullUrl`)}),i(`providers.fullUrl`)]})]})})}function gn({open:e,onOpenChange:n,onAdd:r}){let{t:i}=k(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&(o(``),c(``))},[e]);let u=/^[A-Za-z0-9-]+$/.test(a.trim());return(0,$.jsx)(B,{open:e,onOpenChange:n,title:i(`providers.addHeader`),description:i(`providers.addHeaderDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{onClick:()=>n(!1),children:i(`common.cancel`)}),(0,$.jsx)(l,{variant:`primary`,disabled:!u,onClick:()=>{r([a.trim(),s]),n(!1)},children:i(`common.add`)})]}),children:(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsx)(t,{label:i(`providers.headerName`),children:(0,$.jsx)(h,{autoFocus:!0,className:`font-mono`,placeholder:`X-Custom-Header`,value:a,invalid:a!==``&&!u,onChange:e=>o(e.target.value)})}),(0,$.jsx)(t,{label:i(`providers.headerValue`),children:(0,$.jsx)(h,{className:`font-mono`,value:s,onChange:e=>c(e.target.value)})})]})})}export{en as ProviderDetailPage};
@@ -1,2 +0,0 @@
1
- import{$t as e,A as t,An as n,B as r,C as i,Cn as a,D as o,Di as s,E as c,F as l,Fa as u,Fi as d,G as f,H as p,I as m,Ia as h,J as g,Jr as _,K as v,N as y,O as b,Oi as x,P as S,Pa as C,R as w,T,Tn as E,U as D,V as O,Vr as k,W as A,Wi as j,X as M,Xn as N,Xr as P,Y as F,Yr as ee,Z as I,Zt as L,a as R,aa as te,cr as z,di as B,dn as ne,dt as V,en as H,et as re,gr as U,hr as ie,i as ae,ia as W,k as oe,ki as se,lt as ce,mn as le,na as ue,nn as de,nt as G,o as fe,oa as K,r as pe,ra as me,rn as he,rt as ge,sn as _e,ta as q,tn as ve,w as ye,z as be,za as xe,zt as Se}from"./overlays-D1ZtG8Qn.js";import{t as Ce}from"./use-transform-DvOb1h9g.js";import{S as we,a as Te,b as Ee,f as De,n as Oe,s as ke,t as Ae}from"./Page-CnSErb_N.js";import{n as je,t as Me}from"./checkbox-RGYPqY5w.js";import{t as Ne}from"./download-CMr38kbd.js";import{C as Pe,O as Fe,h as Ie,k as Le,m as Re,p as ze,u as Be,x as Ve}from"./index-PfVyiY3J.js";import{t as He}from"./radio-cards-QHFaDooy.js";var J=xe(h(),1);function Ue(e,t,n){(0,J.useInsertionEffect)(()=>e.on(t,n),[e,t,n])}var We={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};We.node;var Ge=V(We),Ke={name:`flask-conical`,size:24,node:[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]};Ke.node;var qe=V(Ke),Je={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};Je.node;var Ye=V(Je),Xe={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Xe.node;var Ze=V(Xe),Y={card:`_card_i7fo0_3`,trigger:`_trigger_i7fo0_6`,media:`_media_i7fo0_7`,zoom:`_zoom_i7fo0_8`,content:`_content_i7fo0_9`,description:`_description_i7fo0_12`,footer:`_footer_i7fo0_13`,title:`_title_i7fo0_15`,byline:`_byline_i7fo0_22`,avatar:`_avatar_i7fo0_23`,bylineText:`_bylineText_i7fo0_26`,meta:`_meta_i7fo0_27`,status:`_status_i7fo0_28`,roll:`_roll_i7fo0_30`,line:`_line_i7fo0_31`,word:`_word_i7fo0_32`,srOnly:`_srOnly_i7fo0_33`,action:`_action_i7fo0_34`,overlay:`_overlay_i7fo0_36`,panel:`_panel_i7fo0_38`,closeSlot:`_closeSlot_i7fo0_48`,close:`_close_i7fo0_48`,details:`_details_i7fo0_51`},X=u(),{blur:Qe,duration:Z,ease:$e,spring:et,stagger:tt}=G,nt={...et.smooth,visualDuration:.3},rt={...et.smooth,visualDuration:.26},it=300,at={duration:Z.instant},ot=1.04,st={duration:Z.considered*2,ease:[...$e.standard]},ct={duration:Z.considered,ease:[...$e.standard]},lt={delay:Z.instant,duration:Z.standard,ease:[...$e.enter]},ut={delay:Z.instant,duration:Z.fast,ease:[...$e.enter]},dt={enter:{},center:{},exit:{opacity:0,y:`-.3em`,filter:`blur(${Qe.subtle}px)`,transition:{duration:Z.fast,ease:[...$e.standard]}}},ft={enter:{opacity:0,y:`.3em`,filter:`blur(${Qe.soft}px)`},center:e=>({opacity:1,y:0,filter:`blur(0px)`,transition:{duration:Z.standard,ease:[...$e.enter],delay:e*tt.word}})};function pt({text:e,reduced:t}){return(0,X.jsxs)(`span`,{className:Y.status,role:`status`,children:[(0,X.jsx)(`span`,{className:Y.srOnly,children:e}),(0,X.jsx)(`span`,{className:Y.roll,"aria-hidden":`true`,children:(0,X.jsx)(K,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(q.span,{className:Y.line,variants:dt,initial:!t&&`enter`,animate:`center`,exit:t?void 0:`exit`,children:e.split(/(\s+)/).map((e,t)=>(0,X.jsx)(q.span,{className:Y.word,custom:t/2,variants:ft,children:e},t))},e)})})]})}function mt(e,t){let n=parseFloat(t);if(Number.isFinite(n))return t.trim().endsWith(`rem`)?n*parseFloat(getComputedStyle(e.ownerDocument.documentElement).fontSize):n}function ht({title:e,description:n,media:r,action:a,avatar:s,meta:l,status:u,details:d,open:f,defaultOpen:p=!1,onOpenChange:m,children:h,className:g,style:_,...v}){let y=me()??!1,x=(0,J.useId)(),S=(0,J.useRef)(null),C=(0,J.useRef)(null),[w,E]=(0,J.useState)(p),[D,O]=(0,J.useState)(!1),[k,A]=(0,J.useState)({}),[j,M]=(0,J.useState)(null),N=d?f??w:!1,P=!!d&&!y,F=!N&&j!==null,ee=!!n,I=(0,J.useCallback)(e=>{f===void 0&&E(e),m?.(e)},[f,m]);(0,J.useEffect)(()=>{let e=S.current,t=C.current;if(!P||!e||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>{let n=getComputedStyle(e),r=mt(e,n.borderTopLeftRadius),i=mt(e,n.getPropertyValue(`--radius-surface`)),a=t?.offsetWidth||void 0;A(e=>e.card!==void 0&&e.measure===a?e:{card:e.card??r,panel:e.panel??i,measure:a})});return n.observe(e),t&&n.observe(t),()=>n.disconnect()},[P,ee]);let L=(0,J.useRef)(N);(0,J.useLayoutEffect)(()=>{let e=L.current&&!N;L.current=N;let t=S.current;if(N)M(null);else if(e&&P&&t){let e=t.getBoundingClientRect();M({top:e.top,left:e.left,width:e.width,height:e.height})}},[N,P]),(0,J.useEffect)(()=>{if(!F)return;let e=window.setTimeout(()=>M(null),it);return()=>window.clearTimeout(e)},[F]);let R=(e,t,n=!0)=>P?{layoutId:e,layout:n,layoutCrossfade:!1,layoutDependency:t===`card`?N:F?`return`:`panel`,transition:{layout:t===`card`?rt:nt}}:{},z=e=>s||l||u||a?(0,X.jsxs)(`div`,{className:Y.footer,children:[s||l||u?(0,X.jsxs)(q.div,{className:Y.byline,...R(`byline`,e,`position`),children:[s?(0,X.jsx)(`span`,{className:Y.avatar,children:s}):null,(0,X.jsxs)(`span`,{className:Y.bylineText,children:[l?(0,X.jsx)(`span`,{className:Y.meta,children:l}):null,u?(0,X.jsx)(pt,{text:u,reduced:y}):null]})]}):null,a?(0,X.jsx)(q.div,{className:Y.action,...R(`action`,e,`position`),children:a}):null]}):null,B=(0,X.jsxs)(q.article,{...v,ref:S,className:[Y.card,g].filter(Boolean).join(` `),style:{..._,borderRadius:k.card??_?.borderRadius},"data-hover":D||void 0,whileHover:y?void 0:{y:-2},onHoverStart:()=>O(!0),onHoverEnd:()=>O(!1),...R(`card`,`card`),transition:{default:et.snappy,layout:rt},children:[r?(0,X.jsx)(q.div,{className:Y.media,...R(`media`,`card`),children:(0,X.jsx)(q.div,{className:Y.zoom,initial:!1,animate:{scale:D&&!y?ot:1},transition:D?st:ct,children:r})}):null,(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(q.h3,{className:Y.title,...R(`title`,`card`),children:d?(0,X.jsx)(t,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:Y.trigger,children:e})}):e}),n?(0,X.jsx)(q.p,{ref:C,className:Y.description,...R(`description`,`card`,`position`),children:n}):null,h,z(`card`)]})]});return d?(0,X.jsx)(i,{open:N,onOpenChange:I,children:(0,X.jsxs)(te,{id:x,children:[B,(0,X.jsx)(K,{children:(N||F)&&(0,X.jsxs)(b,{forceMount:!0,children:[(0,X.jsx)(K,{children:N&&(0,X.jsx)(o,{asChild:!0,forceMount:!0,children:(0,X.jsx)(q.div,{className:Y.overlay,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:y?at:{duration:Z.exit,ease:[...$e.standard]}},transition:y?at:{duration:Z.standard,ease:[...$e.enter]}})},`overlay`)}),(0,X.jsx)(T,{asChild:!0,forceMount:!0,...n?{}:{"aria-describedby":void 0},children:(0,X.jsxs)(q.div,{className:Y.panel,"data-framer-portal-id":x,"data-returning":F||void 0,layoutScroll:!0,style:{borderRadius:k.panel,"--card-measure":k.measure?`${k.measure}px`:void 0,...j&&F?{"--landing-top":`${j.top}px`,"--landing-left":`${j.left}px`,"--landing-width":`${j.width}px`,"--landing-height":`${j.height}px`}:{}},...P?{...R(`card`,`panel`),initial:!1,animate:k.card!==void 0&&k.panel!==void 0?{borderRadius:F?k.card:k.panel}:void 0,transition:{layout:F?rt:nt,borderRadius:F?rt:nt},exit:{opacity:0,transition:{duration:0}}}:{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:at},transition:at},children:[r?(0,X.jsx)(q.div,{className:Y.media,...R(`media`,`panel`),children:(0,X.jsx)(q.div,{className:Y.zoom,initial:{scale:D&&!y?ot:1},animate:{scale:1},transition:nt,children:r})}):null,(0,X.jsx)(q.span,{className:Y.closeSlot,initial:y?{opacity:0}:{opacity:0,scale:.9},animate:F?{opacity:0,scale:.9}:{opacity:1,scale:1},transition:F||y?at:ut,children:(0,X.jsx)(ye,{asChild:!0,children:(0,X.jsx)(q.button,{type:`button`,className:Y.close,"aria-label":`Close quick look`,whileTap:y?void 0:{scale:.94},transition:et.snappy,children:(0,X.jsx)(ge,{width:16,height:16,strokeWidth:1.75,"aria-hidden":`true`})})})}),(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(oe,{asChild:!0,children:(0,X.jsx)(q.h2,{className:Y.title,...R(`title`,`panel`),children:e})}),n?(0,X.jsx)(c,{asChild:!0,children:(0,X.jsx)(q.p,{className:Y.description,...R(`description`,`panel`,`position`),children:n})}):null,h,z(`panel`),(0,X.jsx)(q.div,{className:Y.details,initial:!y&&{opacity:0,y:6},animate:F?{opacity:0,y:0}:{opacity:1,y:0},exit:{opacity:0,transition:at},transition:F||y?at:lt,children:d})]})]})})]},`quick-look`)})]})}):B}var Q={figure:`_figure_1clu4_1`,caption:`_caption_1clu4_1`,label:`_label_1clu4_1`,accent:`_accent_1clu4_2`,success:`_success_1clu4_2`,warning:`_warning_1clu4_2`,danger:`_danger_1clu4_2`,point:`_point_1clu4_4`,roll:`_roll_1clu4_7`,track:`_track_1clu4_9`,slot:`_slot_1clu4_9`,glyph:`_glyph_1clu4_9`,sizer:`_sizer_1clu4_11`,plot:`_plot_1clu4_14`,chart:`_chart_1clu4_17`,baseline:`_baseline_1clu4_18`,area:`_area_1clu4_20`,line:`_line_1clu4_21`,trail:`_trail_1clu4_21`,cursor:`_cursor_1clu4_24`,end:`_end_1clu4_25`},gt={hidden:e=>({opacity:0,y:`${.3*e}em`,filter:`blur(${G.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:G.duration.standard,ease:[...G.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${G.blur.subtle}px)`,transition:{duration:G.duration.fast,ease:[...G.ease.standard]}})},_t={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:G.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:G.duration.instant}}},vt=e=>Number(e.replace(/,/g,``).replace(/−/g,`-`).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN),yt=new Intl.NumberFormat(`en-US`),bt={duration:G.duration.considered*1.75,ease:[...G.ease.inOut]},xt={duration:G.duration.fast,ease:[...G.ease.standard]};function St(e,t){if(!e)return[];if(t)return[{slot:`all`,key:e,text:e}];if(!/\p{L}/u.test(e))return[...e].map((e,t,n)=>({slot:`n${n.length-t}`,key:e,text:e}));let n=e.split(/(?<=\s)/);return n.map((e,t)=>({slot:`w${t}`,key:n.slice(0,t+1).join(``),text:e}))}function Ct({text:e,direction:t,whole:n=!1,morph:r=!1,tone:i}){let a=!!me(),o=(0,J.useRef)(null),s=W(`auto`),[c,l]=(0,J.useState)({text:e,direction:1});c.text!==e&&l({text:e,direction:t??(vt(e)<vt(c.text)?-1:1)}),(0,J.useEffect)(()=>{let e=o.current;if(!e||typeof ResizeObserver>`u`)return;let t=null,n=new ResizeObserver(([n])=>{if(!n)return;let r=n.borderBoxSize?.[0]?.inlineSize??e.offsetWidth;t!==null&&t!==e.textContent&&!a?ue(s,r,G.spring.morph):s.jump(r),t=e.textContent});return n.observe(e),()=>n.disconnect()},[r,a,s]);let u=!n&&!/\p{L}/u.test(e),d=a?_t:gt,f=u?`right`:`left`;return(0,X.jsxs)(q.span,{className:Q.roll,"data-end":u||void 0,"data-whole":n||void 0,style:r?{width:s}:void 0,children:[r&&(0,X.jsx)(`span`,{ref:o,className:Q.sizer,"aria-hidden":`true`,children:e}),(0,X.jsx)(`span`,{className:Q.track,children:(0,X.jsx)(K,{mode:`popLayout`,initial:!1,custom:c.direction,anchorX:f,children:St(e,n).map(e=>(0,X.jsx)(q.span,{className:Q.slot,custom:c.direction,variants:d,initial:`hidden`,animate:`shown`,exit:`gone`,children:(0,X.jsx)(K,{mode:`popLayout`,initial:!1,custom:c.direction,anchorX:f,children:(0,X.jsx)(q.span,{className:i?`${Q.glyph} ${i}`:Q.glyph,custom:c.direction,variants:d,initial:`hidden`,animate:`shown`,exit:`gone`,children:e.text},`${i??``}${e.key}`)})},e.slot))})})]})}var wt=5,Tt=1.25,Et=Array.from({length:161},(e,t)=>t/160);function Dt(e){let t=Math.min(...e),n=Math.max(...e)-t,r=e.map(e=>n?(e-t)/n:.5),i=r.length-1,a=1/i,o=r.slice(1).map((e,t)=>(e-r[t])/a),s=r.map((e,t)=>t===0||t===i?o[0]:(Math.sign(o[t-1])+Math.sign(o[t]))*Math.min(Math.abs(o[t-1]),Math.abs(o[t]),Math.abs(o[t-1]+o[t])/4)||0);i>1&&(s[0]=(3*o[0]-s[1])/2,s[i]=(3*o[i-1]-s[i-1])/2);let c=Math.max(1,Math.min(16,Math.round(128/i))),l=[];for(let e=0;e<i;e++)for(let t=0;t<c;t++){let n=t/c,i=n*n,o=i*n,u=(2*o-3*i+1)*r[e]+(o-2*i+n)*a*s[e]+(3*i-2*o)*r[e+1]+(o-i)*a*s[e+1];l.push([(e+n)*a,Math.min(1,Math.max(0,u))])}return l.push([1,r[i]]),l}function Ot(e,t){let n=0,r=e.length-1;if(t<=e[n][0])return e[n][1];if(t>=e[r][0])return e[r][1];for(;r-n>1;){let i=n+r>>1;e[i][0]<t?n=i:r=i}let[i,a]=e[n],[o,s]=e[r];return o===i?s:a+(s-a)*(t-i)/(o-i)}function kt(e,t,n,r){let i=e=>wt+(1-e)*(n-10),a=e.map(([e,n])=>[e*t,i(n)]),o=a.map(([e,t])=>`${e.toFixed(2)},${t.toFixed(2)}`),s=r*t,c=i(Ot(e,r));return{points:a,line:o.join(` `),trail:`M${o.join(`L`)}`,fill:`M${o.join(`L`)}L${t},${n}L0,${n}Z`,dot:`${s},${c} ${s},${c}`,cx:s}}function At(e,t){let n=e.slice(1).map(([t,n],r)=>Math.hypot(t-e[r][0],n-e[r][1])),r=t*n.reduce((e,t)=>e+t,0);for(let t=0;t<n.length;t++){let i=n[t],a=e[t][0];if(r<=i)return a+(e[t+1][0]-a)*(i?r/i:1);r-=i}return e[e.length-1][0]}function jt({data:e,label:t,value:n,change:r,tone:i=`accent`,width:a=160,height:o=52,labels:s,formatValue:c,area:l=!0,interactive:u=!0}){let d=e.length>1?e:[e[0]??0,e[0]??0],f=d.length-1,p=d.join(`,`),m=(0,J.useMemo)(()=>Dt(p.split(`,`).map(Number)),[p]),h=`${t}: ${n??d[f]}. ${r??``}`.trim(),g=`sparkline${(0,J.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,_=(0,J.useRef)(null),v=(0,J.useRef)(null),y=Le(_,{once:!0,amount:.5}),b=!!me(),[x,S]=(0,J.useState)({w:a,h:o}),[C,w]=(0,J.useState)(null),[T,E]=(0,J.useState)(!1),D=C===null?null:Math.min(C,f),[O,k]=(0,J.useState)({index:D,direction:1});O.index!==D&&k({index:D,direction:D===null||O.index===null?1:Math.sign(D-O.index)||1});let[A]=(0,J.useState)(()=>kt(m,a,o,1)),j=(0,J.useRef)(m),M=(0,J.useRef)(x),N=W(0),P=W(1),F=W(A.line),ee=W(A.trail),I=W(A.fill),L=W(A.dot),R=W(A.cx),te=W(A.cx+Tt+16),z=W(A.cx+Tt),B=W(0),ne=Ce(N,e=>+(e>.001)),V=(0,J.useCallback)(()=>{let{w:e,h:t}=M.current,n=N.get(),r=kt(j.current,e,t,P.get());F.set(r.line),ee.set(r.trail),I.set(r.fill),L.set(r.dot),R.set(r.cx),te.set(r.cx+Tt+16),z.set(r.cx+Tt),B.set(n>=1?e+32:At(r.points,n)+16)},[P,R,z,L,N,I,F,te,B,ee]);Ue(P,`change`,V),Ue(N,`change`,V),(0,J.useLayoutEffect)(()=>{let e=v.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=e.clientWidth;t&&S(e=>Math.abs(e.w-t)<.5?e:{w:t,h:t*o/a})});return t.observe(e),()=>t.disconnect()},[o,a]),(0,J.useLayoutEffect)(()=>{M.current=x,V()},[x,V]),(0,J.useEffect)(()=>{if(b){N.jump(1);let e=requestAnimationFrame(()=>E(!0));return()=>cancelAnimationFrame(e)}if(!y)return;let e=ue(N,1,{...bt,onComplete:()=>E(!0)});return()=>e.stop()},[N,y,b]),(0,J.useEffect)(()=>{let e=j.current;if(e===m)return;if(b){j.current=m,V();return}let t=[...new Set([...Et,...m.map(([e])=>e)])].sort((e,t)=>e-t),n=t.map(t=>Ot(e,t)),r=t.map(e=>Ot(m,e)),i=ue(0,1,{...G.spring.smooth,onUpdate:e=>{j.current=t.map((t,i)=>[t,n[i]+(r[i]-n[i])*e]),V()},onComplete:()=>{j.current=m,V()}});return()=>i.stop()},[V,b,m]),(0,J.useEffect)(()=>{let e=D===null?1:D/f;if(b){P.jump(e);return}let t=ue(P,e,G.spring.snappy);return()=>t.stop()},[P,D,f,b]);let H=D!==null,re=(e=>c?c(d[e],e):yt.format(d[e]))(D??f),U=s?.[D??f],ie=n===void 0?void 0:H?re:n,ae=D===null?r??``:n===void 0?[re,U].filter(Boolean).join(` · `):U??`${D+1} of ${f+1}`,oe=e=>{let t=v.current?.getBoundingClientRect();return t?.width?Math.max(0,Math.min(f,Math.round((e-t.left)/t.width*f))):f},se=u?{role:`slider`,tabIndex:0,"aria-label":`${t}, explore values`,"aria-valuemin":1,"aria-valuemax":f+1,"aria-valuenow":(D??f)+1,"aria-valuetext":`${U??(D===null?`Latest`:`Point ${D+1} of ${f+1}`)}: ${re}`,onPointerDown:e=>w(oe(e.clientX)),onPointerMove:e=>{(e.pointerType===`mouse`||e.buttons)&&w(oe(e.clientX))},onPointerUp:e=>{e.pointerType!==`mouse`&&w(null)},onPointerLeave:()=>w(null),onPointerCancel:()=>w(null),onBlur:()=>w(null),onKeyDown:e=>{if(e.key===`Escape`&&H){e.preventDefault(),w(null);return}let t=D??f,n=Math.max(1,Math.round((f+1)/6)),r={ArrowLeft:t-1,ArrowDown:t-1,ArrowRight:t+1,ArrowUp:t+1,PageDown:t-n,PageUp:t+n,Home:0,End:f}[e.key];r!==void 0&&(e.preventDefault(),w(Math.max(0,Math.min(f,r))))}}:{};return(0,X.jsxs)(`figure`,{ref:_,className:Q.figure,"aria-label":h,children:[(0,X.jsxs)(`figcaption`,{className:Q.caption,children:[(0,X.jsx)(`span`,{className:Q.label,children:(0,X.jsx)(Ct,{text:t,whole:!0})}),ie!==void 0&&(0,X.jsx)(`strong`,{children:(0,X.jsx)(Ct,{text:ie,morph:!0})}),(0,X.jsx)(`small`,{className:Q[i],children:(0,X.jsx)(Ct,{text:ae,direction:H?O.direction:void 0,tone:H?Q.point:void 0,morph:!0})})]}),(0,X.jsx)(`div`,{ref:v,className:Q.plot,"data-interactive":u||void 0,...se,children:(0,X.jsxs)(`svg`,{className:Q.chart,viewBox:`0 0 ${x.w} ${x.h}`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(`clipPath`,{id:`${g}-lit`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(q.rect,{x:-16,y:-16,width:te,height:x.h+32})}),(0,X.jsx)(`clipPath`,{id:`${g}-dim`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(q.rect,{x:z,y:-16,width:x.w+32,height:x.h+32})}),(0,X.jsx)(`clipPath`,{id:`${g}-fill`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(q.rect,{x:-16,y:-16,width:B,height:x.h+32})})]}),l&&(0,X.jsx)(q.path,{className:`${Q.area} ${Q[i]}`,d:I,clipPath:`url(#${g}-fill)`}),(0,X.jsx)(`line`,{className:Q.baseline,x1:`0`,y1:x.h-.5,x2:x.w,y2:x.h-.5}),(0,X.jsx)(q.path,{className:Q.trail,d:ee,clipPath:`url(#${g}-dim)`,initial:!1,animate:{opacity:H&&T?1:0},transition:b?{duration:0}:xt}),(0,X.jsx)(q.polyline,{className:[Q.line,Q[i]].join(` `),points:F,clipPath:`url(#${g}-lit)`,style:{pathLength:N,opacity:ne}}),(0,X.jsx)(q.line,{className:Q.cursor,x1:R,x2:R,y1:0,y2:x.h,initial:!1,animate:{opacity:+!!H},transition:b?{duration:0}:xt}),(0,X.jsx)(q.polyline,{className:[Q.end,Q[i]].join(` `),points:L,initial:!1,animate:{opacity:+!!T,strokeWidth:T?H?10:7:0},transition:b?{duration:0}:{opacity:xt,strokeWidth:G.spring.snappy},fill:`none`,strokeLinecap:`round`})]})})]})}var $={root:`_root_1cea8_1`,horizontal:`_horizontal_1cea8_3`,list:`_list_1cea8_4`,item:`_item_1cea8_5`,vertical:`_vertical_1cea8_7`,compact:`_compact_1cea8_8`,head:`_head_1cea8_11`,marker:`_marker_1cea8_20`,ring:`_ring_1cea8_21`,disc:`_disc_1cea8_22`,glyph:`_glyph_1cea8_23`,icon:`_icon_1cea8_24`,connector:`_connector_1cea8_31`,fill:`_fill_1cea8_35`,text:`_text_1cea8_40`,label:`_label_1cea8_43`,slot:`_slot_1cea8_47`,slotInner:`_slotInner_1cea8_48`,description:`_description_1cea8_49`,error:`_error_1cea8_49`,caption:`_caption_1cea8_53`,captionLabel:`_captionLabel_1cea8_54`,srOnly:`_srOnly_1cea8_63`},Mt=e=>`blur(${e}px)`,Nt={duration:0},Pt={duration:G.duration.fast,ease:[...G.ease.standard]},Ft={duration:G.duration.standard,ease:[...G.ease.enter]},It={opacity:0,y:`0.3em`,filter:Mt(G.blur.soft)},Lt={opacity:1,y:0,filter:Mt(0)},Rt={opacity:0,y:`-0.3em`,filter:Mt(G.blur.subtle)},zt={opacity:0,scale:.5,filter:Mt(G.blur.subtle)},Bt={opacity:1,scale:1,filter:Mt(0)};function Vt({text:e,className:t,reduced:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(0),a=W(`auto`);return(0,J.useLayoutEffect)(()=>{i.current=performance.now()+700},[e]),(0,J.useEffect)(()=>{let e=r.current,t=e?.parentElement;if(!e||!t||typeof ResizeObserver>`u`)return;let o=!1,s=new ResizeObserver(()=>{let t=e.offsetHeight;if(!o||n||performance.now()>i.current){o=!0,a.jump(t);return}ue(a,t,G.spring.smooth)});return s.observe(e),()=>s.disconnect()},[a,n]),(0,X.jsx)(q.span,{className:$.slot,style:{height:a},children:(0,X.jsx)(`span`,{ref:r,className:$.slotInner,children:(0,X.jsx)(K,{mode:`popLayout`,initial:!1,children:e?(0,X.jsx)(q.span,{className:t,initial:It,animate:Lt,exit:{...Rt,transition:n?Nt:Pt},transition:n?Nt:Ft,children:e},`${t}:${e}`):null})})})}function Ht({kind:e,number:t,delay:n,reduced:r}){let i=r?Nt:{scale:{...G.spring.snappy,delay:n},opacity:{duration:G.duration.fast,delay:n},filter:{duration:G.duration.fast,delay:n}},a={...zt,transition:r?Nt:Pt},o=r?Nt:{duration:G.duration.standard,ease:G.ease.enter,delay:n+.04};return e===`number`?(0,X.jsx)(q.span,{className:$.glyph,initial:zt,animate:Bt,exit:a,transition:i,children:t}):(0,X.jsx)(q.svg,{className:`${$.glyph} ${$.icon}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2.5,strokeLinecap:`round`,strokeLinejoin:`round`,initial:zt,animate:Bt,exit:a,transition:i,children:e===`check`?(0,X.jsx)(q.path,{d:`M5.5 12.5l4.25 4.25L18.5 8`,initial:{pathLength:0},animate:{pathLength:1},transition:o}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q.path,{d:`M12 6.75v6.5`,initial:{pathLength:0},animate:{pathLength:1},transition:o}),(0,X.jsx)(q.circle,{cx:12,cy:17.4,r:1.4,fill:`currentColor`,stroke:`none`,initial:{scale:0},animate:{scale:1},transition:r?Nt:{...G.spring.snappy,delay:n+.16}})]})})}function Ut({number:e,kind:t,current:n,glyphDelay:r,ringDelay:i,reduced:a}){return(0,X.jsxs)(`span`,{className:$.marker,"aria-hidden":`true`,children:[(0,X.jsx)(K,{initial:!1,children:n?(0,X.jsx)(q.span,{className:$.ring,initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:a?Nt:Pt},transition:a?Nt:{scale:{...G.spring.snappy,delay:i},opacity:{duration:G.duration.fast,delay:i}}},`ring`):null}),(0,X.jsx)(`span`,{className:$.disc,children:(0,X.jsx)(K,{initial:!1,children:(0,X.jsx)(Ht,{kind:t,number:e,delay:r,reduced:a},t)})})]})}var Wt={complete:`Completed`,current:``,upcoming:`Not started`,error:`Error`};function Gt({steps:e,current:t,orientation:n=`horizontal`,onStepSelect:r,details:i=`all`,compact:a=!1,label:o=`Progress`,completeLabel:s=`All steps complete`,className:c}){let l=me()??!1,u=e.length,d=Math.min(Math.max(Math.round(t),0),u),[f,p]=(0,J.useState)({to:d,from:d});f.to!==d&&p({to:d,from:f.to});let m=f.from,h=G.stagger.line,g=e=>l?0:d>m?e>=m&&e<d?(e-m)*h:0:e>=d&&e<m?(m-1-e)*h:0,_=l?0:Math.max(0,Math.abs(d-m)-1)*h+.12,v=!!r,y=n===`vertical`,b=d>=u?void 0:e[d];function x(e){let t=!y&&getComputedStyle(e.currentTarget).direction===`rtl`,n=[`ArrowUp`,t?`ArrowRight`:`ArrowLeft`],r=[`ArrowDown`,t?`ArrowLeft`:`ArrowRight`];if(![...n,...r,`Home`,`End`].includes(e.key))return;let i=Array.from(e.currentTarget.querySelectorAll(`button[data-reachable]`)),a=i.indexOf(e.target);a<0||(e.preventDefault(),i[e.key===`Home`?0:e.key===`End`?i.length-1:n.includes(e.key)?Math.max(0,a-1):Math.min(i.length-1,a+1)]?.focus())}let S=v?`nav`:`div`,C=[$.root,y?$.vertical:$.horizontal,a?$.compact:``,c].filter(Boolean).join(` `);return(0,X.jsxs)(S,{className:C,"aria-label":o,role:v?void 0:`group`,children:[(0,X.jsx)(`ol`,{className:$.list,style:y?void 0:{gridTemplateColumns:u>1?`repeat(${u-1}, minmax(0, 1fr)) auto`:`auto`},onKeyDown:v?x:void 0,children:e.map((e,t)=>{let a=t===d,o=e.error?`error`:t<d?`complete`:a?`current`:`upcoming`,s=v&&t<d,c=e.error??(i===`all`||a?e.description:void 0),f=e.error?`error`:t<d?`check`:`number`,p=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ut,{number:t+1,kind:f,current:a,glyphDelay:g(t),ringDelay:_,reduced:l}),(0,X.jsxs)(`span`,{className:$.text,children:[(0,X.jsx)(`span`,{className:$.label,children:e.label}),Wt[o]?(0,X.jsxs)(`span`,{className:$.srOnly,children:[`, `,Wt[o]]}):null,(0,X.jsx)(Vt,{text:c,className:e.error?$.error:$.description,reduced:l})]})]});return(0,X.jsxs)(`li`,{className:$.item,"data-status":o,children:[t<u-1?(0,X.jsx)(`span`,{className:$.connector,"aria-hidden":`true`,children:(0,X.jsx)(q.span,{className:$.fill,initial:!1,animate:y?{scaleY:+(t<d)}:{scaleX:+(t<d)},transition:l?Nt:{...G.spring.smooth,delay:g(t)}},n)}):null,v?(0,X.jsx)(`button`,{type:`button`,className:$.head,"data-clickable":s||void 0,"data-reachable":t<=d||void 0,"aria-current":a?`step`:void 0,"aria-disabled":!s||void 0,tabIndex:s?void 0:-1,onClick:s?()=>r?.(t):void 0,children:p}):(0,X.jsx)(`span`,{className:$.head,"aria-current":a?`step`:void 0,children:p})]},e.id)})}),y?null:(0,X.jsxs)(`span`,{className:$.caption,"aria-hidden":`true`,children:[(0,X.jsx)(Vt,{text:b?.label??s,className:$.captionLabel,reduced:l}),(0,X.jsx)(Vt,{text:b?.error??b?.description,className:b?.error?$.error:$.description,reduced:l})]}),(0,X.jsx)(`span`,{className:$.srOnly,"aria-live":`polite`,children:b?`Step ${d+1} of ${u}: ${b.label}`:s})]})}var Kt={"openai-chat":`Chat`,"openai-responses":`Responses`,anthropic:`Anthropic`,gemini:`Gemini`},qt={new:`green`,same:`neutral`,sameHost:`orange`,off:`neutral`,skip:`red`},Jt=e=>`${e.source}\u0000${e.ref}`,Yt=e=>e.status!==`skip`&&e.status!==`same`;function Xt(e){try{return new URL(e).host}catch{return e}}function Zt({open:e,onOpenChange:t}){let{t:n}=E(),{toast:r}=fe(),i=U(e),a=ie(),[o,s]=(0,J.useState)(``),[c,u]=(0,J.useState)(new Set),[d,f]=(0,J.useState)(null);(0,J.useEffect)(()=>{i.data&&u(new Set(i.data.flatMap(e=>e.items).filter(e=>e.status===`new`).map(Jt)))},[i.data]),(0,J.useEffect)(()=>{e&&(s(``),f(null))},[e]);let p=o.trim().toLowerCase(),m=e=>!p||e.name.toLowerCase().includes(p)||e.endpoints.some(e=>e.baseUrl.toLowerCase().includes(p)),h=(0,J.useMemo)(()=>(i.data??[]).flatMap(e=>e.items).filter(e=>c.has(Jt(e))&&Yt(e)),[i.data,c]),g=(e,t)=>u(n=>{let r=new Set(n);return t?r.add(Jt(e)):r.delete(Jt(e)),r});return(0,X.jsx)(ae,{open:e,onOpenChange:t,width:680,title:n(`import.title`),description:n(`import.detail`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{icon:(0,X.jsx)(Pe,{className:`size-3.5`}),onClick:()=>void i.refetch(),disabled:i.isFetching||a.isPending,children:n(`import.rescan`)}),(0,X.jsx)(l,{variant:`primary`,disabled:h.length===0||a.isPending,onClick:()=>{f(null),a.mutate(h.map(e=>({source:e.source,ref:e.ref})),{onSuccess:e=>{let i=e.skipped.length;r(i>0?n(`import.doneSkipped`,{count:e.added.length,skipped:i}):n(`import.done`,{count:e.added.length})),t(!1)},onError:e=>{f(R(e)),i.refetch()}})},children:n(`import.selected`,{count:h.length})})]}),children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(v,{value:o,onChange:s,placeholder:n(`import.search`)}),d&&(0,X.jsx)(y,{tone:`danger`,title:n(`common.error`),children:d}),i.isLoading&&(0,X.jsx)(F,{lines:3}),i.isError&&(0,X.jsx)(y,{tone:`danger`,title:n(`common.error`),children:R(i.error)}),(0,X.jsx)(`div`,{className:`grid max-h-[460px] gap-4 overflow-auto pr-1`,children:i.data?.map(e=>(0,X.jsx)(Qt,{source:e,matches:m,selected:c,onToggle:g,filtering:p.length>0},e.id))}),(0,X.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`import.footnote`)})]})})}function Qt({source:e,matches:t,selected:n,onToggle:r,filtering:i}){let{t:a}=E(),o=e.items.filter(t);return(0,X.jsxs)(`section`,{"aria-label":e.name,children:[(0,X.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 px-1`,children:[(0,X.jsx)(`h3`,{className:`text-[13px] font-medium`,children:e.name}),e.path&&(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-[var(--text-muted)]`,title:a(`import.path`,{path:e.path}),children:e.path})]}),e.error?(0,X.jsx)(y,{tone:`danger`,title:a(`import.sourceError`,{error:e.error})}):e.found?o.length===0?(0,X.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:a(i?`import.noMatch`:`import.noItems`)}):(0,X.jsx)(`ul`,{className:`card divide-y divide-[var(--border)]`,children:o.map(e=>(0,X.jsx)($t,{c:e,checked:n.has(Jt(e)),onToggle:t=>r(e,t)},Jt(e)))}):(0,X.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:a(`import.notFound`)})]})}function $t({c:e,checked:t,onToggle:n}){let{t:r}=E(),i=Yt(e),o=e.status===`skip`&&e.skipReason?r(`import.skip.${e.skipReason}`):e.status===`same`&&e.existing?r(`import.existing`,{name:e.existing.name}):e.status===`sameHost`&&e.existing?r(`import.sameHostHint`,{name:e.existing.name}):null,s=e.endpoints.map(e=>`${Kt[e.protocol]??e.protocol} · ${Xt(e.baseUrl)}`).join(` / `);return(0,X.jsxs)(`li`,{className:a(`flex items-start gap-3 px-4 py-3`,!i&&`opacity-60`),children:[(0,X.jsx)(Me,{checked:t&&i,disabled:!i,onCheckedChange:e=>n(e===!0),"aria-label":e.name}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,title:e.name,children:e.name}),(0,X.jsx)(S,{tone:qt[e.status],children:r(`import.status.${e.status}`)}),e.fromApp&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:e.fromApp})]}),s&&(0,X.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-[var(--text-muted)]`,title:s,children:s}),(0,X.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-3 text-[11px] text-[var(--text-muted)]`,children:[(0,X.jsx)(`span`,{className:`font-mono`,children:e.hasKey?e.keyMasked??`••••`:r(`import.noKey`)}),e.models.length>0&&(0,X.jsx)(`span`,{children:r(`import.models`,{count:e.models.length})}),e.templateId&&(0,X.jsx)(`span`,{children:r(`import.template`,{id:e.templateId})})]}),o&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--text-secondary,var(--text-muted))]`,children:o}),e.ignoredFields.length>0&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--warning)]`,children:r(`import.ignored`,{fields:e.ignoredFields.join(`, `)})})]})]})}var en=``,tn=`custom`,nn=[{name:`userId`,secret:!1,required:!1},{name:`accessToken`,secret:!0,required:!1}],rn={method:`GET`,url:`{{baseUrl}}/user/balance`,auth:`provider`,headers:{}},an={isValid:`is_active`,remaining:`balance`,unit:{$const:`USD`}},on=e=>JSON.stringify(e??{},null,2);function sn(e){return{enabled:e.enabled,template:e.template??en,intervalMinutes:e.intervalMinutes??null,timeoutSec:e.timeoutSec,baseUrl:e.baseUrl??``,params:{...e.params},secrets:{},method:e.request?.method??`GET`,url:e.request?.url??``,auth:e.request?.auth??`provider`,headers:on(e.request?.headers),extract:e.extract?on(e.extract):``}}function cn(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`&&!Array.isArray(t)?t:null}catch{return null}}function ln({provider:e}){let{t}=E(),{toast:n}=fe(),r=P(),i=B(e.id),a=x(e.id),o=z(),s=e.quotaConfig,c=(0,J.useMemo)(()=>sn(s),[s]),[u,d]=(0,J.useState)(c),[h,g]=(0,J.useState)(null);(0,J.useEffect)(()=>d(c),[c]);let _=r.data??[],v=_.find(e=>e.id===s.suggestedTemplate),b=u.template===en?v:_.find(e=>e.id===u.template),S=u.template===tn,C=S?nn:b?.params??[],w=e=>d(t=>({...t,...e})),T=JSON.stringify(u)!==JSON.stringify(c),k=e=>{if(e!==tn||u.url)return w({template:e});let t=b??v;w({template:e,method:t?.request.method??rn.method,url:t?.request.url??rn.url,auth:t?.request.auth??rn.auth,headers:on(t?.request.headers??rn.headers),extract:on(t?.extract??an)})},j=()=>{let e={enabled:u.enabled,template:u.template===en?null:u.template,intervalMinutes:u.intervalMinutes,timeoutSec:u.timeoutSec??10,baseUrl:u.baseUrl.trim()||null,params:Object.fromEntries(Object.entries(u.params).filter(([,e])=>e.trim()!==``).map(([e,t])=>[e,t.trim()])),secrets:Object.fromEntries(Object.entries(u.secrets).filter(([,e])=>e.trim()!==``))};if(S){let r=cn(u.headers),i=cn(u.extract);if(!r||!i)return n(t(`providers.quota.invalidJson`,{field:t(r?`providers.quota.extract`:`providers.quota.headers`)}),`error`),null;e.request={method:u.method,url:u.url.trim(),auth:u.auth,headers:r},e.extract=i}return e},N=()=>{let r=j();if(!r)return;let a=r.enabled&&!s.enabled;i.mutate(r,{onSuccess:()=>{n(t(`common.saved`),`success`),a&&o.mutate(e.id,{onError:e=>n(R(e),`error`)})},onError:e=>n(R(e),`error`)})},F=()=>{let e=j();e&&a.mutate(e,{onSuccess:g,onError:e=>n(R(e),`error`)})},ee=s.effectiveIntervalMinutes>0?t(`providers.quota.intervalEvery`,{minutes:s.effectiveIntervalMinutes}):t(`providers.quota.intervalOff`),te=[{value:en,label:v?t(`providers.quota.templateAuto`,{name:v.name}):t(`providers.quota.templateNone`)},..._.map(e=>({value:e.id,label:e.name,detail:t(`providers.quota.kind.${e.kind}`)})),{value:tn,label:t(`providers.quota.custom`)}];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(O,{title:t(`providers.quota.title`),footer:t(`providers.quota.footer`),children:[(0,X.jsx)(f,{label:t(`providers.quota.enable`),detail:t(`providers.quota.enableHint`),children:(0,X.jsx)(M,{checked:u.enabled,label:t(`providers.quota.enable`),onChange:e=>w({enabled:e})})}),(0,X.jsx)(f,{label:t(`providers.quota.template`),children:(0,X.jsx)(pe,{className:`w-64`,ariaLabel:t(`providers.quota.template`),value:u.template,onChange:k,options:te})}),C.map(e=>{let n=t(`providers.quota.param.${e.name}`),r=s.secrets.includes(e.name);return e.secret?(0,X.jsx)(f,{label:n,detail:r?t(`providers.quota.secretStored`):void 0,children:(0,X.jsx)(p,{type:`password`,autoComplete:`off`,className:`w-64 font-mono`,"aria-label":n,placeholder:r?`••••••••`:``,value:u.secrets[e.name]??``,onChange:t=>w({secrets:{...u.secrets,[e.name]:t.target.value}})})},e.name):(0,X.jsx)(f,{label:n,children:(0,X.jsx)(p,{className:`w-64 font-mono`,"aria-label":n,value:u.params[e.name]??``,onChange:t=>w({params:{...u.params,[e.name]:t.target.value}})})},e.name)}),C.length>0&&(0,X.jsx)(`div`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.paramsHint`)}),S&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(pe,{className:`w-28`,ariaLabel:t(`providers.quota.method`),value:u.method,onChange:e=>w({method:e}),options:[{value:`GET`,label:`GET`},{value:`POST`,label:`POST`}]}),(0,X.jsx)(p,{className:`min-w-60 flex-1 font-mono`,"aria-label":t(`providers.quota.url`),value:u.url,onChange:e=>w({url:e.target.value})}),(0,X.jsx)(pe,{className:`w-52`,ariaLabel:t(`providers.quota.auth`),value:u.auth,onChange:e=>w({auth:e}),options:[{value:`provider`,label:t(`providers.quota.auth.provider`)},{value:`none`,label:t(`providers.quota.auth.none`)}]})]}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.urlHint`)}),(0,X.jsx)(I,{label:t(`providers.quota.headers`),mono:!0,rows:3,value:u.headers,onChange:e=>w({headers:e.target.value})}),(0,X.jsx)(I,{label:t(`providers.quota.extract`),mono:!0,rows:8,value:u.extract,onChange:e=>w({extract:e.target.value})}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.extractHint`)})]}),(0,X.jsx)(f,{label:t(`providers.quota.interval`),detail:t(`providers.quota.intervalHint`,{value:ee}),children:(0,X.jsx)(A,{className:`w-28`,label:t(`providers.quota.interval`),min:0,step:1,value:u.intervalMinutes,onChange:e=>w({intervalMinutes:e})})}),(0,X.jsx)(f,{label:t(`providers.quota.timeout`),children:(0,X.jsx)(A,{className:`w-28`,label:t(`providers.quota.timeout`),min:1,step:1,value:u.timeoutSec,onChange:e=>w({timeoutSec:e})})}),(0,X.jsx)(f,{label:t(`providers.quota.baseUrl`),detail:t(`providers.quota.baseUrlHint`),children:(0,X.jsx)(p,{className:`w-64 font-mono`,"aria-label":t(`providers.quota.baseUrl`),placeholder:e.endpoints[0]?.baseUrl,value:u.baseUrl,onChange:e=>w({baseUrl:e.target.value})})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 py-3`,children:[(0,X.jsx)(l,{size:`sm`,variant:`primary`,disabled:!T,loading:i.isPending,onClick:N,children:t(`common.save`)}),(0,X.jsx)(l,{size:`sm`,icon:(0,X.jsx)(qe,{className:`size-3.5`}),loading:a.isPending,onClick:F,title:t(`providers.quota.testDesc`),children:t(`providers.quota.test`)}),(0,X.jsx)(l,{size:`sm`,icon:(0,X.jsx)(Ye,{className:`size-3.5`}),disabled:T,loading:o.isPending,onClick:()=>o.mutate(e.id,{onError:e=>n(R(e),`error`)}),children:t(`providers.quota.fetch`)})]}),(0,X.jsx)(`div`,{className:`px-4 pb-4`,children:(0,X.jsx)(un,{snapshot:e.quota,checkedAtUtc:e.quotaCheckedAtUtc})})]}),(0,X.jsx)(ae,{open:h!==null,onOpenChange:e=>!e&&g(null),title:t(`providers.quota.test`),description:t(`providers.quota.testDesc`),width:560,children:h&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(y,{tone:h.ok?`success`:`danger`,title:h.ok?t(`providers.quota.testOk`):t(`providers.quota.testFailed`),children:[!h.ok&&L({code:h.errorCode??null,message:h.error??``},t),!h.ok&&h.error&&h.errorCode&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] opacity-80`,children:h.error})]}),h.url&&(0,X.jsx)(D,{label:t(`providers.quota.requestUrl`),mono:!0,children:h.url}),h.httpStatus!=null&&(0,X.jsx)(D,{label:t(`providers.quota.httpStatus`),children:h.httpStatus}),h.snapshot&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[12px] text-[var(--text-secondary)]`,children:t(`providers.quota.extracted`)}),(0,X.jsx)(un,{snapshot:h.snapshot})]}),h.raw!==void 0&&h.raw!==null&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[12px] text-[var(--text-secondary)]`,children:t(`providers.quota.rawResponse`)}),(0,X.jsx)(m,{children:on(h.raw)})]})]})})]})}function un({snapshot:t,checkedAtUtc:n}){let{t:r,locale:i}=E(),a=de(t),o=t?.plans??[],s=t?.fetchedAtUtc?new Date(t.fetchedAtUtc).getTime():0;return!t&&!n?(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`providers.quota.never`)}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a&&(0,X.jsxs)(y,{tone:`warning`,title:r(`providers.quota.failed`,{error:L(a,r)}),children:[(0,X.jsx)(`span`,{className:`text-[11px]`,children:a.message}),o.length>0&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px]`,children:r(`providers.quota.lastGood`)})]}),t?.isValid===!1&&(0,X.jsx)(y,{tone:`warning`,title:r(`providers.quota.invalid`),children:t.invalidMessage}),o.length>0&&(0,X.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map((t,n)=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 text-[13px]`,children:[t.name&&(0,X.jsx)(S,{children:t.name}),(0,X.jsx)(`span`,{className:`num`,children:e(t,r,i)??`—`}),H(t,r,i)&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:H(t,r,i)}),t.extra&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:t.extra})]},n))}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-[var(--text-muted)]`,children:[t?.planLabel&&(0,X.jsx)(S,{tone:`accent`,children:t.planLabel}),s>0&&(0,X.jsx)(`span`,{children:r(`providers.quota.fetchedAt`,{time:Se(s,i,r(`tray.justNow`))??``})})]})]})}function dn({provider:e}){let{t,locale:n}=E(),{toast:r}=fe(),i=z();if(!ve(e))return null;let a=he(e.quota,t,n),o=de(e.quota);return(0,X.jsxs)(`div`,{className:`mt-3 flex min-w-0 items-center gap-2 text-[12px]`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a&&(0,X.jsx)(`div`,{className:`num truncate text-[var(--text-secondary)]`,title:a,children:a}),o&&(0,X.jsx)(`div`,{className:`truncate text-[var(--warning)]`,title:o.message,children:t(`providers.quota.failed`,{error:L(o,t)})}),!a&&!o&&(0,X.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:t(`providers.quota.never`)})]}),(0,X.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(Ye,{className:`size-3.5`}),"aria-label":t(`providers.quota.refresh`),title:t(`providers.quota.refresh`),loading:i.isPending,onClick:()=>i.mutate(e.id,{onError:e=>r(R(e),`error`)})})]})}var fn=[{value:`openai-chat`,label:`OpenAI Chat`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic`,label:`Anthropic Messages`},{value:`gemini`,label:`Gemini`}],pn=[{value:`bearer`,label:`Authorization: Bearer`},{value:`x-api-key`,label:`x-api-key`},{value:`x-goog-api-key`,label:`x-goog-api-key`},{value:`query-key`,label:`?key=`},{value:`none`,label:`—`},{value:`oauth-subscription`,label:`OAuth 订阅`}];function mn(){let{t:e}=E(),t=Ee(),[n,r]=we(),i=ee(),[a,o]=(0,J.useState)(n.get(`new`)===`1`),[s,c]=(0,J.useState)(!1);(0,J.useEffect)(()=>{n.get(`new`)===`1`&&(o(!0),n.delete(`new`),r(n,{replace:!0}))},[n,r]),De(e=>{e===`new-provider`&&o(!0)});let u=se(`7d`,`day`,`provider`),[d,f]=(0,J.useState)(null),p=(0,J.useMemo)(()=>{let e=gn(hn),t=new Map;for(let n of u.data??[]){let r=e.indexOf(n.bucket);if(r<0)continue;let i=t.get(n.key);i||t.set(n.key,i={requests:e.map(()=>0),costUsd:0}),i.requests[r]=(i.requests[r]??0)+n.requests,i.costUsd+=n.costUsd}return{days:e,byProvider:t}},[u.data]);return(0,X.jsxs)(Ae,{title:e(`nav.providers`),subtitle:i.data?e(`providers.count`,{count:i.data.length}):void 0,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{icon:(0,X.jsx)(Ne,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`providers.import`)}),(0,X.jsx)(l,{variant:`primary`,icon:(0,X.jsx)(ke,{className:`size-3.5`}),onClick:()=>o(!0),children:e(`providers.add`)})]}),children:[(0,X.jsxs)(`div`,{className:`mx-auto max-w-[1100px]`,children:[i.isLoading&&(0,X.jsx)(F,{lines:4}),i.isError&&(0,X.jsx)(y,{tone:`danger`,title:e(`common.error`),children:R(i.error)}),i.data?.length===0&&(0,X.jsx)(`div`,{className:`card`,children:(0,X.jsx)(be,{icon:(0,X.jsx)(Te,{className:`size-6`}),title:e(`providers.empty`),detail:e(`providers.emptyDetail`),action:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,X.jsx)(l,{variant:`primary`,icon:(0,X.jsx)(ke,{className:`size-3.5`}),onClick:()=>o(!0),children:e(`providers.add`)}),(0,X.jsx)(l,{icon:(0,X.jsx)(Ne,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`providers.import`)})]})})}),i.data&&i.data.length>0&&(0,X.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,260px),1fr))] gap-3`,children:i.data.map(e=>(0,X.jsx)(yn,{p:e,days:p.days,usage:p.byProvider.get(e.name),onOpen:()=>t(`/providers/${e.id}`),onTest:()=>f(e)},e.id))})]}),(0,X.jsx)(Zt,{open:s,onOpenChange:c}),(0,X.jsx)(Sn,{open:a,onOpenChange:o,onCreated:e=>t(`/providers/${e.id}`)}),d&&(0,X.jsx)(An,{provider:d,open:!0,onOpenChange:e=>!e&&f(null)})]})}var hn=7;function gn(e){let t=new Date;return Array.from({length:e},(n,r)=>{let i=new Date(t.getFullYear(),t.getMonth(),t.getDate()-(e-1-r));return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,`0`)}-${String(i.getDate()).padStart(2,`0`)}`})}function _n(e){if(!e)return null;try{return new URL(e).host}catch{return e}}var vn=e=>e.stopPropagation();function yn({p:e,days:t,usage:n,onOpen:r,onTest:i}){let{t:o}=E(),s=d(e.id),{toast:c}=fe(),u=[...new Set(e.endpoints.map(e=>e.protocol))],f=!e.hasApiKey&&e.authScheme!==`none`&&e.authScheme!==`oauth-subscription`&&e.authScheme!==`plugin`,p=[e.priceKey?o(`providers.priceKeyShort`,{key:e.priceKey}):null,e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `),m=e.authScheme===`plugin`?o(`providers.card.plugin`):e.authScheme===`oauth-subscription`?o(`providers.card.subscription`):e.authScheme===`none`?o(`providers.card.noAuth`):e.hasApiKey?e.apiKeyMasked??`••••`:o(`providers.noKey`),h=e.enabled?f?{tone:`orange`,label:o(`providers.noKey`)}:{tone:`green`,label:o(`providers.card.active`)}:{tone:`neutral`,label:o(`providers.card.disabled`)},g=n?.requests??t.map(()=>0),_=g.reduce((e,t)=>e+t,0),v=e.templateUpdateAvailable?5:8;return(0,X.jsxs)(ht,{className:`flex flex-col [&>div:first-child>div]:min-h-0! [&>div:last-child]:flex [&>div:last-child]:flex-1 [&>div:last-child]:flex-col [&>div:last-child]:p-3 [&>div:last-child>:last-child]:mt-auto! [&>div:last-child>:last-child]:min-h-[44px] [&>div:last-child>:last-child]:pt-2 [&>div:last-child>h3]:line-clamp-1 [&>div:last-child>h3]:text-[15px] [&>div:last-child>p]:line-clamp-2 [&>div:last-child>p]:min-h-[2lh] [&>div:last-child>p]:text-[12px]`,"data-density":`compact`,role:`button`,tabIndex:0,"aria-label":e.name,onClick:r,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},style:{backgroundColor:`var(--surface)`},title:e.name,description:u.map(e=>fn.find(t=>t.value===e)?.label??e).join(` / `),media:(0,X.jsxs)(`div`,{className:`flex flex-col justify-between gap-1.5 self-stretch justify-self-stretch px-3 py-2.5`,style:{background:`linear-gradient(135deg, color-mix(in oklab, var(--accent) 12%, transparent), transparent 70%)`},children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:a(`transition-[filter,opacity]`,!e.enabled&&`opacity-50 grayscale`),children:(0,X.jsx)(Re,{name:e.name,icon:e.icon,colorKey:e.templateId,size:28})}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-[var(--border)] bg-[color-mix(in_oklab,var(--surface)_80%,transparent)] px-2 py-0.5 text-[11px] text-[var(--text-secondary)]`,children:[(0,X.jsx)(w,{tone:h.tone}),h.label]})]}),(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[11px] text-[var(--text-muted)]`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:e.endpoints[0]?.baseUrl,children:_n(e.endpoints[0]?.baseUrl)??`—`}),(0,X.jsx)(`span`,{className:`shrink-0`,children:o(`providers.modelCount`,{count:e.modelCount})})]})]}),meta:(0,X.jsx)(`span`,{className:a(e.hasApiKey&&e.authScheme!==`oauth-subscription`&&`font-mono`),children:m}),status:p||void 0,action:(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,onClick:vn,children:[(0,X.jsx)(l,{variant:`plain`,size:`sm`,icon:(0,X.jsx)(qe,{className:`size-3.5`}),"aria-label":o(`providers.test`),title:o(`providers.test`),onClick:i}),(0,X.jsx)(`span`,{className:`ml-1 inline-flex`,children:(0,X.jsx)(M,{checked:e.enabled,label:o(`common.enabled`),onChange:e=>s.mutate({enabled:e},{onError:e=>c(R(e),`error`)})})})]}),children:[(0,X.jsxs)(`div`,{className:`mt-1.5 flex h-5 flex-nowrap items-center gap-1 overflow-hidden`,children:[e.templateUpdateAvailable&&(0,X.jsx)(S,{tone:`accent`,children:o(`providers.templateUpdate`)}),e.boundClients.slice(0,v).map(e=>e in Be?(0,X.jsx)(`span`,{title:Ie(e),className:`inline-flex shrink-0`,children:(0,X.jsx)(ze,{kind:e,size:18})},e):(0,X.jsx)(S,{tone:`green`,children:e},e)),e.boundClients.length>v&&(0,X.jsxs)(`span`,{title:e.boundClients.slice(v).map(e=>Be[e]?.name??e).join(`, `),className:`shrink-0 text-[11px] text-[var(--text-muted)]`,children:[`+`,e.boundClients.length-v]})]}),(0,X.jsx)(`div`,{className:`min-h-[32px] [&>div]:mt-1`,onClick:vn,children:(0,X.jsx)(dn,{provider:e})}),(0,X.jsx)(`div`,{className:`mt-2`,onClick:vn,children:_>0?(0,X.jsx)(jt,{label:o(`providers.card.requests7d`),data:g,labels:t.map(e=>e.slice(5)),value:ne(_,!0),change:le(n?.costUsd??0),width:320,height:28,formatValue:e=>ne(e,!0)}):(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(`div`,{className:`text-[13px] text-[var(--text-secondary)]`,children:o(`providers.card.requests7d`)}),(0,X.jsx)(`div`,{className:`grid aspect-[320/28] place-items-center border-b border-dashed border-[var(--border)] text-[11px] text-[var(--text-muted)]`,children:o(`providers.card.noRequests`)})]})})]})}var bn=`plugin:`,xn=[`recommended`,`official`,`subscription`,`cn`,`aggregator`,`local`,`custom`];function Sn({open:e,onOpenChange:t,onCreated:n}){let{t:i}=E(),{toast:a}=fe(),o=s(),c=k(),u=N(),d=ee(),f=(0,J.useMemo)(()=>new Set((d.data??[]).filter(e=>e.authScheme===`oauth-subscription`&&e.templateId).map(e=>e.templateId)),[d.data]),m=Ee(),[h,g]=(0,J.useState)(``),[_,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(null),[C,w]=(0,J.useState)(``),[T,D]=(0,J.useState)(``),[O,A]=(0,J.useState)(``),[j,M]=(0,J.useState)(``),[P,I]=(0,J.useState)(``),[L,te]=(0,J.useState)(`openai-chat`),[z,B]=(0,J.useState)(`bearer`);(0,J.useEffect)(()=>{e||(b(null),S(null),g(``),w(``),D(``),A(``),M(``),I(``))},[e]);let ne=(0,J.useMemo)(()=>{let e=h.trim().toLowerCase(),t=(o.data??[]).filter(t=>!e||t.name.toLowerCase().includes(e)||t.id.includes(e));return xn.map(e=>({category:e,items:t.filter(t=>t.category===e)})).filter(e=>e.items.length)},[o.data,h]),V=(0,J.useMemo)(()=>{let e=h.trim().toLowerCase();return(d.data??[]).filter(t=>t.authScheme===`plugin`&&!t.settings.plugin?.absent&&(!e||t.name.toLowerCase().includes(e)||t.id.includes(e)))},[d.data,h]),H=e=>{b(e),e===`custom`?(w(``),M(``),A(``)):(w(e.name),M(e.priceKey??e.id),A(``),B(e.auth.scheme))},re=()=>{let e=_===`custom`;u.mutate({templateId:e?null:_.id,variantId:O||null,name:C.trim()||null,apiKey:T.trim()||null,priceKey:j,...e?{endpoints:[{protocol:L,baseUrl:P.trim()}],authScheme:z}:{}},{onSuccess:e=>{t(!1),a(i(`providers.created`,{name:e.name}),`success`),n(e)},onError:e=>a(R(e),`error`)})},U=_&&_!==`custom`?_:null,ie=()=>{if(x===`custom`)H(`custom`);else if(x?.startsWith(bn)){let e=V.find(e=>bn+e.id===x);e&&(t(!1),n(e))}else{let e=(o.data??[]).find(e=>e.id===x);e&&!f.has(e.id)&&H(e)}},W=_!==null&&(_===`custom`?/^https?:\/\//.test(P.trim())&&C.trim()!==``:!U.requiresApiKey||T.trim()!==``);return(0,X.jsxs)(ae,{open:e,onOpenChange:t,width:640,title:i(_?`providers.addTitleDetails`:`providers.addTitle`),description:_?U?U.name:i(`providers.custom`):i(`providers.addDetail`),footer:_?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{className:`mr-auto`,variant:`plain`,onClick:()=>b(null),children:i(`common.back`)}),(0,X.jsx)(l,{onClick:()=>t(!1),children:i(`common.cancel`)}),(0,X.jsx)(l,{variant:`primary`,disabled:!W,loading:u.isPending,onClick:re,children:i(`providers.create`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{onClick:()=>t(!1),children:i(`common.cancel`)}),(0,X.jsx)(l,{variant:`primary`,disabled:!x,onClick:ie,children:i(`common.continue`)})]}),children:[(0,X.jsx)(Gt,{className:`mb-6`,label:i(`providers.addTitle`),current:+!!_,steps:[{id:`template`,label:i(`providers.step.template`)},{id:`details`,label:i(`providers.step.details`)}]}),_?(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(r,{label:i(`providers.name`),children:(0,X.jsx)(p,{value:C,onChange:e=>w(e.target.value)})}),U?.variants&&U.variants.length>0&&(0,X.jsx)(r,{label:i(`providers.variant`),children:(0,X.jsx)(pe,{value:O,onChange:e=>{A(e);let t=U.variants?.find(t=>t.id===e);M(t?.priceKey??U.priceKey??U.id)},options:[{value:``,label:i(`providers.variantDefault`)},...U.variants.map(e=>({value:e.id,label:e.name}))]})}),_===`custom`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{label:i(`providers.baseUrl`),hint:i(`providers.baseUrlHint`),children:(0,X.jsx)(p,{value:P,onChange:e=>I(e.target.value),placeholder:`https://api.example.com/v1`,className:`font-mono`})}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,X.jsx)(r,{label:i(`providers.protocol`),children:(0,X.jsx)(pe,{value:L,onChange:te,options:fn})}),(0,X.jsx)(r,{label:i(`providers.authScheme`),children:(0,X.jsx)(pe,{value:z,onChange:B,options:pn})})]})]}),U?.authScheme===`oauth-subscription`?(0,X.jsx)(y,{tone:`info`,title:i(`providers.subscriptionWizardHint`),children:i(`providers.subscriptionWizardDetail`)}):(0,X.jsxs)(`div`,{className:`font-mono`,children:[(0,X.jsx)(Ve,{label:i(`providers.apiKey`),description:i(`providers.apiKeyHint`),autoComplete:`off`,placeholder:`sk-…`,value:T,onChange:e=>D(e.target.value)}),U?.apiKeyUrl&&(0,X.jsx)(`a`,{className:`mt-2 inline-block font-sans text-[12px] text-[var(--accent)]`,href:U.apiKeyUrl,target:`_blank`,rel:`noreferrer`,children:i(`providers.getKey`)})]}),(0,X.jsx)(r,{label:i(`providers.priceKey`),hint:i(`providers.priceKeyHint`),children:(0,X.jsx)(pe,{value:j,onChange:M,options:[{value:``,label:i(`providers.priceKeyNone`)},...(c.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey}))]})}),U&&U.models.length>0&&(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:i(`providers.templateModels`,{count:U.models.length})})]}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsx)(v,{value:h,onChange:g,placeholder:i(`providers.searchTemplates`)}),o.isLoading&&(0,X.jsx)(F,{lines:4}),o.isError&&(0,X.jsx)(y,{tone:`danger`,title:i(`common.error`),children:R(o.error)}),ne.map(e=>(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:i(`providers.category.${e.category}`)}),(0,X.jsx)(He,{name:`provider-template`,"aria-label":i(`providers.category.${e.category}`),minColumnWidth:170,value:e.items.some(e=>e.id===x)?x:null,onValueChange:S,options:e.items.map(e=>({value:e.id,label:e.name,description:[...new Set(e.endpoints.map(e=>e.protocol))].join(` · `),icon:(0,X.jsx)(Re,{name:e.name,icon:e.icon,colorKey:e.id,size:24}),disabled:f.has(e.id),disabledReason:i(`providers.subscriptionAdded`)}))})]},e.category)),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:i(`providers.category.plugin`)}),V.length>0?(0,X.jsx)(He,{name:`provider-template-plugin`,"aria-label":i(`providers.category.plugin`),minColumnWidth:170,value:x?.startsWith(bn)?x:null,onValueChange:S,options:V.map(e=>({value:bn+e.id,label:e.name,description:i(`providers.pluginProvided`),icon:(0,X.jsx)(Re,{name:e.name,icon:e.icon,colorKey:e.id,size:24})}))}):(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-[var(--radius-md)] border border-dashed border-[var(--border)] px-3 py-2.5`,children:[(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-[12px] text-[var(--text-secondary)]`,children:i(`providers.pluginHint`)}),(0,X.jsx)(l,{size:`sm`,onClick:()=>{t(!1),m(`/plugins/market`)},children:i(`plugins.browseMarket`)})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:i(`providers.custom`)}),(0,X.jsx)(He,{name:`provider-template-custom`,"aria-label":i(`providers.custom`),layout:`list`,value:x===`custom`?`custom`:null,onValueChange:S,options:[{value:`custom`,label:i(`providers.custom`),description:i(`providers.customDetail`),icon:(0,X.jsx)(ke,{className:`size-4`})}]})]})]})]})}var Cn=3,wn=256,Tn=4096,En={idle:`providers.testDialog.status.idle`,queued:`providers.testDialog.status.queued`,running:`providers.testDialog.status.running`,success:`providers.testDialog.status.success`,failed:`providers.testDialog.status.failed`,cancelled:`providers.testDialog.status.cancelled`};function Dn(e){let t=e.endpoints.map(e=>e.protocol);return e.preferredUpstreamProtocols.find(e=>t.includes(e))??t[0]??`openai-chat`}var On=e=>typeof e==`number`?e:null,kn=e=>typeof e==`string`?e:null;function An({provider:e,open:t,onOpenChange:n}){let{t:i}=E(),a=C(),o=_(t?e.id:void 0),s=e.endpoints.map(e=>e.protocol),[c,u]=(0,J.useState)(`single`),[d,f]=(0,J.useState)(()=>Dn(e)),[p,m]=(0,J.useState)(!0),[h,v]=(0,J.useState)(``),[y,b]=(0,J.useState)(wn),[x,S]=(0,J.useState)(``),[w,T]=(0,J.useState)(null),[D,O]=(0,J.useState)({}),[k,A]=(0,J.useState)([]),[j,M]=(0,J.useState)(new Set),[N,P]=(0,J.useState)([]),[F,ee]=(0,J.useState)(``),[I,L]=(0,J.useState)(null),[R,te]=(0,J.useState)(!1),z=(0,J.useRef)(null),B=(0,J.useRef)(new Map),ne=(0,J.useRef)(!1),V=(0,J.useRef)(!1),H=(0,J.useMemo)(()=>{let e=[...o.data??[]].sort((e,t)=>Number(t.enabled)-Number(e.enabled)||e.sortOrder-t.sortOrder).map(e=>e.modelId);return[...e,...N.filter(t=>!e.includes(t))]},[o.data,N]);(0,J.useEffect)(()=>{if(t){S(e=>e||(o.data??[]).find(e=>e.enabled)?.modelId||(o.data??[])[0]?.modelId||``);return}V.current=!1,z.current?.abort();for(let e of B.current.values())e.abort();B.current.clear(),T(null),O({}),A([]),M(new Set),P([]),ee(``),L(null)},[t,o.data]);let re=(0,J.useCallback)(e=>({modelId:e,protocol:d,stream:p,prompt:h.trim()||null,maxOutputTokens:y??wn}),[d,p,h,y]),U=(0,J.useCallback)((t,n,r)=>zn(e.id,t,re(t),n,r),[e.id,re]),ie=()=>{let e=x.trim();if(!e)return;z.current?.abort();let t=new AbortController;z.current=t,V.current=!0,L(null),T({modelId:e,status:`running`,text:``,reasoning:``}),U(e,t.signal,e=>{e.status!==`running`&&e.status!==`queued`&&oe(),T(e)})},W=e=>{if(e.length===0)return;V.current=!0,ne.current=!1,L(null),A(e),O(Object.fromEntries(e.map(e=>[e,{modelId:e,status:`queued`,text:``,reasoning:``}])));let t=0;Promise.all(Array.from({length:Math.min(Cn,e.length)},async()=>{for(;;){if(!V.current)return;let n=e[t++];if(n===void 0)return;if(ne.current){O(e=>({...e,[n]:{...e[n],status:`cancelled`}}));continue}let r=new AbortController;B.current.set(n,r),await U(n,r.signal,e=>O(t=>({...t,[n]:e}))),B.current.delete(n),oe()}}))},oe=()=>void a.invalidateQueries({queryKey:[`requests`]}),se=()=>{ne.current=!0,O(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.status===`queued`?{...t,status:`cancelled`}:t])))},ce=w?.status===`running`||k.some(e=>D[e]?.status===`running`||D[e]?.status===`queued`&&!ne.current),le=k.filter(e=>D[e]&&D[e].status!==`queued`&&D[e].status!==`running`).length,ue=k.filter(e=>D[e]?.status===`success`).length,de=k.filter(e=>D[e]?.status===`failed`).length,G=(e,t)=>M(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),fe=()=>{ce||n(!1)},K=e=>e.stopPropagation();return(0,X.jsx)(`span`,{onClick:K,onKeyDown:K,children:(0,X.jsxs)(ae,{open:t,onOpenChange:e=>e?n(!0):fe(),width:1040,title:i(`providers.testDialog.title`,{name:e.name}),description:i(`providers.testDialog.subtitle`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mr-auto text-[11px] text-[var(--text-muted)]`,children:i(`providers.testDialog.realRequest`)}),(0,X.jsx)(l,{disabled:ce,onClick:()=>n(!1),icon:(0,X.jsx)(ge,{className:`size-3.5`}),children:i(`common.close`)}),c===`single`?ce?(0,X.jsx)(l,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:()=>z.current?.abort(),children:i(`providers.testDialog.stop`)}):(0,X.jsx)(l,{variant:`primary`,disabled:x.trim()===``,icon:(0,X.jsx)(qe,{className:`size-3.5`}),onClick:ie,children:i(w?`providers.testDialog.retest`:`providers.testDialog.start`)}):ce?(0,X.jsx)(l,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:se,children:i(`providers.testDialog.stopRest`)}):(0,X.jsx)(l,{variant:`primary`,disabled:j.size===0,icon:(0,X.jsx)(qe,{className:`size-3.5`}),onClick:()=>W([...j]),children:i(`providers.testDialog.testN`,{count:j.size})})]}),children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pb-4`,children:[(0,X.jsx)(Re,{name:e.name,icon:e.icon,colorKey:e.templateId,size:32}),(0,X.jsx)(g,{items:[{value:`single`,label:i(`providers.testDialog.modeSingle`)},{value:`batch`,label:i(`providers.testDialog.modeBatch`)}],value:c,onChange:e=>{u(e),L(null)},ariaLabel:i(`providers.testDialog.config`)})]}),c===`single`?(0,X.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,300px)_minmax(0,1fr)] gap-6`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 border-r border-[var(--border)] pr-6`,children:[(0,X.jsx)(`h3`,{className:`text-[13px] font-medium`,children:i(`providers.testDialog.config`)}),(0,X.jsx)(r,{label:i(`providers.testDialog.model`),children:(0,X.jsx)(jn,{value:x,models:H,onChange:S})}),(0,X.jsx)(Mn,{protocols:s,protocol:d,onProtocol:f,stream:p,onStream:m,maxTokens:y,onMaxTokens:b,prompt:h,onPrompt:v}),(0,X.jsx)(`p`,{className:`mt-auto text-[11px] text-[var(--text-muted)]`,children:i(`providers.testDialog.savedCredentials`)})]}),(0,X.jsx)(Nn,{run:w,onRetest:ie})]}):I===null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ln,{known:H,selected:j,onToggle:G,onSelectAll:e=>M(e?new Set(H):new Set),onClear:()=>M(new Set),search:F,onSearch:ee,onAdd:e=>{P(t=>t.includes(e)?t:[...t,e]),M(t=>new Set(t).add(e)),ee(``)},configOpen:R,onConfigOpen:te,protocols:s,protocol:d,onProtocol:f,stream:p,onStream:m,maxTokens:y,onMaxTokens:b,prompt:h,onPrompt:v}),k.length>0?(0,X.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:ce?i(`providers.testDialog.progress`,{done:le,total:k.length,ok:ue,failed:de}):i(`providers.testDialog.progressDone`,{total:k.length,ok:ue,failed:de})}),(0,X.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-strong)]`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full transition-[width]`,style:{width:`${le/k.length*100}%`,background:`var(--accent)`}})})]}):null,k.length>0?(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Rn,{order:k,runs:D,onView:L})}):null]}):(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(l,{variant:`plain`,icon:(0,X.jsx)(je,{className:`size-4`}),"aria-label":i(`common.back`),onClick:()=>L(null)}),(0,X.jsx)(`span`,{className:`font-mono text-[13px]`,children:I})]}),(0,X.jsx)(Nn,{run:D[I]??null})]})]})})}function jn({value:e,models:t,onChange:n}){let{t:r}=E(),[i,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(0),[l,u]=(0,J.useState)(null),d=l===null?t:t.filter(e=>e.toLowerCase().includes(l.trim().toLowerCase())),f=()=>{u(null),c(Math.max(0,t.indexOf(e))),o(!0)},m=e=>{n(e),u(null),o(!1)};return(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(p,{className:`pr-9 font-mono`,value:e,placeholder:r(`providers.testDialog.modelPlaceholder`),"aria-expanded":i,role:`combobox`,onFocus:f,onClick:f,onChange:e=>{n(e.target.value),u(e.target.value),c(0),o(!0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!i)return f();if(d.length===0)return;let t=e.key===`ArrowDown`?1:-1;c(e=>(e+t+d.length)%d.length)}else e.key===`Enter`&&i?(e.preventDefault(),d[s]&&m(d[s])):e.key===`Escape`&&o(!1)}}),(0,X.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 grid w-8 place-items-center text-[var(--text-muted)] hover:text-[var(--text)]`,"aria-label":r(`providers.testDialog.showModels`),onClick:()=>i?o(!1):f(),children:(0,X.jsx)(ce,{className:`size-4`})}),i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`fixed inset-0 z-40`,onMouseDown:()=>o(!1)}),(0,X.jsx)(`ul`,{className:`absolute inset-x-0 top-full z-50 mt-1 max-h-64 overflow-auto rounded-lg border border-[var(--border)] bg-[var(--surface-raised)] py-1 shadow-lg`,children:d.length===0?(0,X.jsx)(`li`,{className:`px-3 py-2 text-[12px] text-[var(--text-muted)]`,children:r(`providers.testDialog.noModels`)}):d.map((e,t)=>(0,X.jsx)(`li`,{children:(0,X.jsx)(`button`,{type:`button`,className:a(`block w-full truncate px-3 py-1.5 text-left font-mono text-[12px] hover:bg-[var(--surface-strong)]`,t===s&&`bg-[var(--surface-strong)]`),onMouseEnter:()=>c(t),onMouseDown:t=>{t.preventDefault(),m(e)},children:e})},e))})]})]})}function Mn({protocols:e,...t}){let{t:n}=E(),i=e.map(e=>({value:e,label:fn.find(t=>t.value===e)?.label??e}));return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{label:n(`providers.testDialog.protocol`),children:(0,X.jsx)(pe,{value:t.protocol,onChange:t.onProtocol,options:i})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:n(`providers.testDialog.stream`)}),(0,X.jsx)(M,{checked:t.stream,label:n(`providers.testDialog.stream`),onChange:t.onStream})]}),(0,X.jsx)(r,{label:n(`providers.testDialog.maxTokens`),children:(0,X.jsx)(A,{value:t.maxTokens,min:1,placeholder:String(wn),label:n(`providers.testDialog.maxTokens`),onChange:e=>t.onMaxTokens(e===null?null:Math.min(Tn,Math.max(1,Math.round(e))))})}),(0,X.jsx)(r,{label:n(`providers.testDialog.prompt`),hint:n(`providers.testDialog.promptHint`),children:(0,X.jsx)(I,{rows:4,value:t.prompt,placeholder:`Reply with OK.`,onChange:e=>t.onPrompt(e.target.value)})})]})}function Nn({run:e,onRetest:t}){let{t:n}=E(),[r,i]=(0,J.useState)(`preview`),a=e?.text??``,o=e?.raw??``,s=Object.entries(e?.headers??{}),c=e?.ttftMs!=null&&e?.httpMs!=null?Math.max(0,e.ttftMs-e.httpMs):null,u=r===`raw`?o:r===`headers`?s.map(([e,t])=>`${e}: ${t}`).join(`
2
- `):a;return(0,X.jsxs)(`div`,{className:`grid min-w-0 content-start gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[t&&e&&e.status!==`running`?(0,X.jsx)(l,{size:`sm`,icon:(0,X.jsx)(qe,{className:`size-3.5`}),onClick:t,children:n(`providers.testDialog.retest`)}):null,(0,X.jsx)(Oe,{content:n(`providers.testDialog.metricsHelp`),children:(0,X.jsx)(`span`,{className:`inline-flex size-4 items-center justify-center text-[var(--text-muted)]`,tabIndex:0,children:(0,X.jsx)(Ge,{className:`size-4`})})}),(0,X.jsx)(In,{run:e}),e?.httpStatus?(0,X.jsxs)(S,{tone:`neutral`,children:[`HTTP `,e.httpStatus]}):null]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-px overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--border)] sm:grid-cols-4`,children:[(0,X.jsx)(Fn,{label:n(`providers.testDialog.metrics.http`),value:e?.httpMs}),(0,X.jsx)(Fn,{label:n(`providers.testDialog.metrics.firstWait`),value:c}),(0,X.jsx)(Fn,{label:n(`providers.testDialog.metrics.ttft`),value:e?.ttftMs}),(0,X.jsx)(Fn,{label:n(`providers.testDialog.metrics.total`),value:e?.totalMs})]}),(0,X.jsxs)(`section`,{className:`card overflow-hidden`,children:[(0,X.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2 border-b border-[var(--border)] px-4 py-2.5`,children:[(0,X.jsx)(`h3`,{className:`text-[12px] font-medium`,children:n(`providers.testDialog.reply`)}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,X.jsx)(g,{items:[{value:`preview`,label:n(`providers.testDialog.preview`)},{value:`raw`,label:n(`providers.testDialog.raw`)},{value:`headers`,label:n(`providers.testDialog.headers`)}],value:r,onChange:i,ariaLabel:n(`providers.testDialog.reply`)}),(0,X.jsx)(re,{value:u,label:n(r===`headers`?`providers.testDialog.headers`:`providers.testDialog.reply`),iconOnly:!0})]})]}),(0,X.jsx)(`div`,{className:`h-[360px] overflow-auto px-4 py-3`,children:r===`headers`?s.length===0?(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`providers.testDialog.headersEmpty`)}):(0,X.jsx)(`table`,{className:`w-full text-[11px]`,children:(0,X.jsx)(`tbody`,{children:s.map(([e,t])=>(0,X.jsxs)(`tr`,{className:`border-b border-[var(--border)] last:border-0 align-top`,children:[(0,X.jsx)(`th`,{className:`w-[220px] py-1.5 pr-4 text-left font-mono font-normal text-[var(--text-secondary)]`,children:e}),(0,X.jsx)(`td`,{className:`py-1.5 font-mono break-all whitespace-pre-wrap selectable`,children:t})]},e))})}):r===`raw`?o?(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsxs)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:[n(`providers.testDialog.rawNote`),e?.contentType?` · ${e.contentType}`:``]}),(0,X.jsx)(`pre`,{className:`font-mono text-[11px] leading-[1.6] break-all whitespace-pre-wrap selectable`,children:o}),e?.rawTruncated?(0,X.jsx)(`p`,{className:`text-[11px] text-[var(--warning)]`,children:n(`providers.testDialog.rawTruncated`)}):null]}):(0,X.jsx)(Pn,{run:e}):e?.error?(0,X.jsx)(y,{tone:`danger`,title:n(`providers.testDialog.status.failed`),children:e.error}):a||e?.reasoning?(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[e?.reasoning?(0,X.jsxs)(`div`,{className:`rounded-md border border-[var(--border)] bg-[var(--surface-strong)] p-3`,children:[(0,X.jsx)(`div`,{className:`mb-1 text-[11px] text-[var(--text-muted)]`,children:n(`providers.testDialog.reasoning`)}),(0,X.jsx)(`pre`,{className:`font-mono text-[11px] leading-[1.6] whitespace-pre-wrap selectable`,children:e.reasoning})]}):null,a?(0,X.jsx)(`pre`,{className:`font-mono text-[12px] leading-[1.7] break-words whitespace-pre-wrap selectable`,children:a}):null]}):e?.status===`success`?(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`providers.testDialog.noText`)}):(0,X.jsx)(Pn,{run:e})})]})]})}function Pn({run:e}){let{t}=E();return e?.status===`running`||e?.status===`queued`?(0,X.jsx)(`div`,{className:`grid h-full place-items-center text-[12px] text-[var(--text-muted)]`,children:t(En[e.status])}):(0,X.jsxs)(`div`,{className:`grid h-full place-items-center content-center gap-2 text-center`,children:[(0,X.jsx)(Fe,{className:`mx-auto size-6 text-[var(--text-muted)]`}),(0,X.jsx)(`div`,{className:`text-[13px]`,children:t(`providers.testDialog.emptyTitle`)}),(0,X.jsx)(`p`,{className:`mx-auto max-w-[320px] text-[11px] text-[var(--text-muted)]`,children:t(`providers.testDialog.emptyDetail`)})]})}function Fn({label:e,value:t}){return(0,X.jsxs)(`div`,{className:`bg-[var(--surface)] px-4 py-3`,children:[(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:e}),(0,X.jsx)(`div`,{className:`mt-1 font-mono text-[15px] tabular-nums`,children:t==null?`—`:_e(t)})]})}function In({run:e}){let{t}=E(),n=e?.status??`idle`;return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[12px] text-[var(--text-secondary)]`,children:[(0,X.jsx)(w,{tone:n===`success`?`green`:n===`failed`?`red`:n===`running`?`orange`:`neutral`}),t(En[n])]})}function Ln({known:e,selected:t,onToggle:n,onSelectAll:r,onClear:i,search:a,onSearch:o,onAdd:s,configOpen:c,onConfigOpen:u,...d}){let{t:f}=E(),p=a.trim(),m=p.toLowerCase(),h=m?e.filter(e=>e.toLowerCase().includes(m)):e,g=p!==``&&!e.some(e=>e.toLowerCase()===m);return(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-[12px] text-[var(--text-secondary)]`,children:f(`providers.testDialog.selected`,{n:t.size,total:e.length})}),(0,X.jsx)(`div`,{className:`min-w-[220px] flex-1`,children:(0,X.jsx)(v,{value:a,onChange:o,placeholder:f(`providers.testDialog.searchModels`)})}),(0,X.jsx)(l,{variant:`plain`,disabled:t.size===0,onClick:i,children:f(`providers.testDialog.clearSelection`)}),(0,X.jsx)(l,{icon:(0,X.jsx)(qe,{className:`size-3.5`}),onClick:()=>u(!0),children:f(`providers.testDialog.config`)})]}),(0,X.jsx)(`div`,{className:`card max-h-[420px] overflow-auto`,children:h.length===0&&!g?(0,X.jsx)(`p`,{className:`px-4 py-6 text-center text-[12px] text-[var(--text-muted)]`,children:f(`providers.testDialog.noModels`)}):(0,X.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2`,children:[(0,X.jsx)(Me,{checked:t.size===e.length&&e.length>0||t.size!==0&&`indeterminate`,onCheckedChange:e=>r(e!==!1),"aria-label":f(`providers.testDialog.clearSelection`)}),(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:f(`providers.testDialog.ownFilter`)})]}),g?(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,X.jsx)(ke,{className:`size-3.5 shrink-0 text-[var(--accent)]`}),(0,X.jsx)(`button`,{type:`button`,className:`text-left font-mono text-[12px] text-[var(--accent)]`,onClick:()=>s(p),children:f(`providers.testDialog.addModel`,{id:p})})]}):null,h.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,X.jsx)(Me,{checked:t.has(e),onCheckedChange:t=>n(e,t!==!1),"aria-label":e}),(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[12px]`,title:e,children:e})]},e))]})}),(0,X.jsx)(ae,{open:c,onOpenChange:u,width:480,title:f(`providers.testDialog.config`),description:f(`providers.testDialog.savedCredentials`),children:(0,X.jsx)(`div`,{className:`grid gap-4`,children:(0,X.jsx)(Mn,{...d})})})]})}function Rn({order:e,runs:t,onView:n}){let{t:r}=E();return(0,X.jsx)(`div`,{className:`card overflow-hidden`,children:(0,X.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-[var(--border)] text-left text-[11px] text-[var(--text-muted)]`,children:[(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.model`)}),(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.statusColumn`)}),(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.metrics.ttft`)}),(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.metrics.total`)}),(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.reply`)})]})}),(0,X.jsx)(`tbody`,{children:e.map(e=>{let i=t[e];return(0,X.jsxs)(`tr`,{className:`border-b border-[var(--border)] last:border-0`,children:[(0,X.jsx)(`td`,{className:`px-4 py-2 font-mono`,children:e}),(0,X.jsx)(`td`,{className:`px-4 py-2`,children:(0,X.jsx)(In,{run:i??null})}),(0,X.jsx)(`td`,{className:`px-4 py-2 font-mono tabular-nums`,children:i?.ttftMs==null?`—`:_e(i.ttftMs)}),(0,X.jsx)(`td`,{className:`px-4 py-2 font-mono tabular-nums`,children:i?.totalMs==null?`—`:_e(i.totalMs)}),(0,X.jsx)(`td`,{className:`px-4 py-2`,children:(0,X.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] disabled:text-[var(--text-muted)]`,disabled:!i,onClick:()=>n(e),children:r(`providers.testDialog.view`)})})]},e)})})]})})}async function zn(e,t,r,i,a){let o={modelId:t,status:`running`,text:``,reasoning:``};a(o);let s=e=>{o={...o,...e},a(o)};try{await n(e,r,e=>{let t=e.data??{};switch(e.event){case`headers`:s({httpStatus:On(t.httpStatus),httpMs:On(t.httpMs),contentType:kn(t.contentType),headers:Bn(t.headers)});break;case`delta`:{let e=kn(t.text)??``;kn(t.kind)===`reasoning`?s({reasoning:o.reasoning+e}):s({text:o.text+e});break}case`done`:{let t=e.data;s({status:t.ok?`success`:`failed`,error:t.error??null,httpStatus:t.httpStatus??null,httpMs:t.httpMs??null,ttftMs:t.ttftMs??null,totalMs:t.totalMs??null,text:t.text??``,reasoning:t.reasoning??``,raw:t.raw??``,rawTruncated:t.rawTruncated??!1,contentType:t.contentType??null,headers:Bn(t.headers)});break}}},i)}catch(e){e?.name===`AbortError`?s({status:`cancelled`,error:null}):s({status:`failed`,error:e instanceof j?e.message:String(e)})}}function Bn(e){if(typeof e!=`object`||!e)return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`string`?t[n]=r:r!=null&&(t[n]=String(r));return t}export{pn as AUTH_OPTIONS,fn as PROTOCOL_OPTIONS,mn as ProvidersPage,qe as i,ln as n,Ye as r,An as t};
@@ -1 +0,0 @@
1
- import{Dn as e,Dt as t,Et as n,F as r,Fa as i,G as a,H as o,Ia as s,J as c,Ji as l,Ki as u,Ln as d,Ot as f,Pa as p,Ri as m,Sn as h,Tn as g,Tt as _,Ui as v,V as y,Vn as b,X as x,Y as ee,Yi as S,a as C,dt as te,gi as w,ia as T,kt as E,na as D,nt as O,o as k,oa as A,r as ne,ra as j,st as re,ta as M,wt as ie,xr as ae,za as oe,zi as se}from"./overlays-D1ZtG8Qn.js";import{t as ce}from"./use-transform-DvOb1h9g.js";import{b as le,s as ue,t as de,x as fe}from"./Page-CnSErb_N.js";import{t as pe}from"./TrayPanelView-BcmaqvCD.js";import{t as me}from"./download-CMr38kbd.js";import{t as he}from"./folder-open-Ce_7X0wN.js";import{t as ge}from"./log-out-CXVs8bJY.js";import{t as _e}from"./rotate-ccw-Dr0Xbikv.js";import{C as ve,_ as ye,g as N,n as be,t as P,v as xe,y as F}from"./index-PfVyiY3J.js";import{t as Se}from"./radio-cards-QHFaDooy.js";var Ce={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Ce.node;var we=te(Ce),I={name:`panel-top`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};I.node;var Te=te(I),Ee={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};Ee.node;var L=te(Ee),R=oe(s(),1),z={field:`_field_bhhp1_1`,head:`_head_bhhp1_6`,label:`_label_bhhp1_7`,limit:`_limit_bhhp1_9`,control:`_control_bhhp1_14`,step:`_step_bhhp1_22`,icon:`_icon_bhhp1_23`,valueWrap:`_valueWrap_bhhp1_34`,value:`_value_bhhp1_34`,affix:`_affix_bhhp1_38`,char:`_char_bhhp1_39`,number:`_number_bhhp1_42`,display:`_display_bhhp1_43`,mirror:`_mirror_bhhp1_45`,input:`_input_bhhp1_46`,column:`_column_bhhp1_52`,sizer:`_sizer_bhhp1_53`,glyph:`_glyph_bhhp1_54`,symbol:`_symbol_bhhp1_55`,messageSlot:`_messageSlot_bhhp1_57`,hint:`_hint_bhhp1_58`,words:`_words_bhhp1_60`,wordSlot:`_wordSlot_bhhp1_61`,wordSizer:`_wordSizer_bhhp1_62`,word:`_word_bhhp1_60`,srOnly:`_srOnly_bhhp1_64`},B=i(),{spring:V,duration:H,blur:U}=O,W=[...O.ease.enter],G=[...O.ease.standard],De=[0,1,2,3,4,5,6,7,8,9],Oe=6,ke=400,Ae=40,je=240,Me=1500,Ne=700,Pe=700,Fe=.22,Ie=4,Le=130,Re=(()=>{let e=2*Math.PI/(V.morph.visualDuration*1.2);return{type:`spring`,stiffness:e*e,damping:2*(1-V.morph.bounce)*e}})(),ze=e=>(String(e).split(`.`)[1]??``).length,Be=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,`\\$&`),Ve=(e,t)=>typeof e==`function`?e(t):e??``,He=(e,t=10)=>Math.sign(e)*(1-1/(Math.abs(e)*.55/t+1))*t;function Ue(e,t){let n=t.formatToParts(e),r=n.reduce((e,t)=>e+(t.type===`integer`?t.value.length:0),0),i=0;return n.flatMap((e,t)=>e.type===`integer`?[...e.value].map(e=>({key:`i${--r}`,digit:Number(e)})):e.type===`fraction`?[...e.value].map(e=>({key:`f${i++}`,digit:Number(e)})):[{key:e.type===`group`?`g${r}`:e.type===`decimal`?`d`:e.type===`minusSign`?`m`:`${e.type}${t}`,text:e.value}])}var We={enter:e=>({width:0,scale:.6,opacity:0,y:`${e*.3}em`,filter:`blur(${U.soft}px)`}),center:{width:`auto`,scale:1,opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`},transition:{width:V.morph,scale:V.morph,opacity:V.morph,y:V.snappy,filter:{duration:.3,ease:G}}},exit:e=>({width:0,scale:.6,opacity:0,y:`${e*-.3}em`,filter:`blur(${U.subtle}px)`,transition:{width:V.smooth,scale:V.smooth,y:{duration:H.fast,ease:G},opacity:{duration:H.instant},filter:{duration:H.instant}}})},K=e=>({width:`auto`,scale:1,opacity:e,y:0,filter:`none`}),q={enter:K(0),center:{...K(1),transition:{duration:H.instant}},exit:{width:0,opacity:0,transition:{duration:0}}},Ge={enter:K(1),center:{...K(1),transition:{duration:0}},exit:{width:0,opacity:0,transition:{duration:0}}};function Ke({position:e,digit:t}){let n=e=>((t-e)%10+15)%10-5,r=ce(e,e=>`${n(e)*1.05}em`),i=ce(e,e=>Math.max(0,1-Math.abs(n(e))**1.5*1.1)),a=ce(e,e=>Math.abs(n(e))>=1?`hidden`:`visible`),o=ce(e,e=>{let t=Math.abs(n(e));return t<.02||t>=1?`none`:`blur(${(t*U.soft*.75).toFixed(2)}px)`});return(0,B.jsx)(M.span,{className:z.glyph,style:{y:r,opacity:i,filter:o,visibility:a},children:t})}function qe({digit:e,direction:t,instant:n}){let r=j(),i=T(e),a=(0,R.useRef)({digit:e,target:e});return(0,R.useLayoutEffect)(()=>{let o=a.current;if(o.digit===e)return;let s=t>0?(e-o.digit+10)%10:-((o.digit-e+10)%10);Math.abs(s)>5&&(s-=Math.sign(s)*10),o.target+=s,o.digit=e,n||r?i.jump(o.target):D(i,o.target,V.snappy)},[e,t,n,i,r]),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:z.sizer,children:`0`}),De.map(e=>(0,B.jsx)(Ke,{position:i,digit:e},e))]})}function Je({value:e,format:t,direction:n,instant:r}){let i=j(),a=r?Ge:i?q:We;return(0,B.jsx)(A,{initial:!1,custom:n,children:Ue(e,t).map(e=>(0,B.jsx)(M.span,{className:`digit`in e?z.column:z.symbol,custom:n,variants:a,initial:`enter`,animate:`center`,exit:`exit`,children:`digit`in e?(0,B.jsx)(qe,{digit:e.digit,direction:n,instant:r}):e.text},e.key))})}function Ye({text:e,direction:t,className:n}){let r=j();return(0,B.jsx)(`span`,{className:n,children:(0,B.jsx)(A,{initial:!1,custom:t,children:[...e].map((e,n)=>(0,B.jsx)(M.span,{className:z.char,custom:t,variants:r?q:We,initial:`enter`,animate:`center`,exit:`exit`,children:e},`${n}:${e}`))})})}var Xe=e=>{let t=e?.replace(/[^\d.-]/g,``);return t&&/\d/.test(t)&&Number.isFinite(Number(t))?Number(t):null},J=(e,t)=>{let n=e.split(` `);return t.split(` `).map((e,t)=>{let r=Xe(n[t]),i=Xe(e);return r!==null&&i!==null&&i<r?-1:1})},Ze={enter:e=>({opacity:0,y:`${e*.3}em`,filter:`blur(${U.soft}px)`}),center:{opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`},transition:{duration:.22,ease:W,opacity:V.morph}},exit:e=>({opacity:0,y:`${e*-.3}em`,filter:`blur(${U.subtle}px)`,transition:{duration:.14,ease:G}})},Qe={enter:{opacity:0,y:0,filter:`none`},center:{opacity:1,y:0,filter:`none`,transition:{duration:H.instant}},exit:{opacity:0,transition:{duration:0}}};function Y({word:e,direction:t}){let n=j(),r=(0,R.useRef)(null),i=T(`auto`),a=(0,R.useRef)(!1);return(0,R.useLayoutEffect)(()=>{let e=r.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{!a.current||n?i.jump(e.offsetWidth):D(i,e.offsetWidth,V.morph),a.current=!0});return t.observe(e),()=>t.disconnect()},[n,i]),(0,B.jsxs)(M.span,{className:z.wordSlot,style:{width:i},children:[(0,B.jsx)(`span`,{ref:r,className:z.wordSizer,children:e}),(0,B.jsx)(A,{initial:!1,mode:`popLayout`,custom:t,children:(0,B.jsx)(M.span,{className:z.word,custom:t,variants:n?Qe:Ze,initial:`enter`,animate:`center`,exit:`exit`,children:e},e)})]})}function X({text:e}){let[t,n]=(0,R.useState)({text:e,directions:[]});t.text!==e&&n({text:e,directions:J(t.text,e)});let r=t.text===e?t.directions:J(t.text,e),i=e.split(` `);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:z.srOnly,children:e}),(0,B.jsx)(`span`,{className:z.words,"aria-hidden":`true`,children:i.map((e,t)=>(0,B.jsxs)(R.Fragment,{children:[t>0&&` `,(0,B.jsx)(Y,{word:e,direction:r[t]??1})]},t))})]})}function $e({id:e,text:t,className:n}){return(0,B.jsx)(A,{initial:!1,children:t?(0,B.jsx)(et,{id:e,text:t,className:n},`message`):null})}function et({id:e,text:t,className:n}){let r=j(),i=(0,R.useRef)(null),[a,o]=(0,R.useState)(`auto`);return(0,R.useLayoutEffect)(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(([t])=>o(t.borderBoxSize?.[0]?.blockSize??e.offsetHeight));return t.observe(e),()=>t.disconnect()},[]),(0,B.jsx)(M.span,{className:z.messageSlot,initial:{height:0,opacity:0},animate:{height:a,opacity:1},exit:{height:0,opacity:0,transition:r?{duration:0}:{height:V.smooth,opacity:{duration:H.instant}}},transition:r?{duration:0}:{height:V.smooth,opacity:{duration:H.fast}},children:(0,B.jsx)(M.span,{ref:i,id:e,className:n,initial:!r&&{y:`0.35em`,filter:`blur(${U.soft}px)`},animate:{y:0,filter:`blur(0px)`},transition:{duration:r?0:H.standard,ease:W},children:(0,B.jsx)(X,{text:t})})})}function tt({id:e,edge:t,text:n}){let r=j();return(0,B.jsx)(A,{initial:!1,children:t!==0&&(0,B.jsx)(M.span,{id:e,className:z.limit,initial:r?{opacity:0}:{opacity:0,y:`${t*.45}em`,filter:`blur(${U.subtle}px)`},animate:{opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`}},exit:{opacity:0,transition:{duration:r?H.instant:H.standard,ease:G}},transition:r?{duration:H.instant}:{y:V.snappy,opacity:{duration:H.fast},filter:{duration:H.fast}},children:n},`limit`)})}function nt({toward:e,label:t,disabled:n,controls:r,limit:i,pressed:a,iconRef:o,onPress:s,onRelease:c,onActivate:l}){let u=e>0?ue:we;return(0,B.jsx)(`button`,{type:`button`,className:z.step,disabled:n,"aria-controls":r,"aria-label":`${e>0?`Increase`:`Decrease`} ${t}`,"aria-disabled":i||void 0,"data-pressed":a||void 0,onPointerDown:e=>{e.button===0&&s()},onPointerUp:c,onPointerLeave:c,onPointerCancel:c,onMouseDown:e=>e.preventDefault(),onClick:e=>{e.detail===0&&l()},onContextMenu:e=>e.preventDefault(),children:(0,B.jsx)(`span`,{ref:o,className:z.icon,children:(0,B.jsx)(u,{size:16,strokeWidth:1.75,"aria-hidden":`true`})})})}function rt({label:e,value:t,defaultValue:n=0,onValueChange:r,min:i=0,max:a=2**53-1,step:o=1,largeStep:s,description:c,disabled:l,id:u,prefix:d,suffix:f,scrub:p=!1,locale:m=`en-US`,formatOptions:h,size:g=`md`,limitHint:_=!0}){let v=j(),y=(0,R.useId)(),b=u??y,x=c?`${b}-description`:void 0,ee=`${b}-limit`,S=o>0?o:1,[C,te]=(0,R.useState)(n),w=t??C,[E,O]=(0,R.useState)(``),[k,A]=(0,R.useState)(!1),[ne,re]=(0,R.useState)(0),[ie,ae]=(0,R.useState)(!1),[oe,se]=(0,R.useState)(``),[le,ue]=(0,R.useState)(0),[de,fe]=(0,R.useState)(!1),pe=(0,R.useRef)(null),me=(0,R.useRef)(null),he=(0,R.useRef)(null),ge=(0,R.useRef)(void 0),_e=(0,R.useRef)(void 0),ve=(0,R.useRef)(void 0),ye=(0,R.useRef)({edge:0,count:0,at:0}),N=(0,R.useRef)(null),be=(0,R.useRef)(null),P=(0,R.useRef)(w),xe=(0,R.useRef)(w),F=(0,R.useRef)(void 0),Se=(0,R.useRef)(null),Ce=(0,R.useRef)(!1),we=(0,R.useRef)(null),I=(0,R.useRef)(!1),Te=(0,R.useRef)(()=>!1),Ee=T(0),L=T(0),H=T(0),U=ce(()=>L.get()+H.get()),W=Number.isFinite(i)?i:0,G=Math.max(ze(S),ze(W)),De=h?.minimumFractionDigits??G,Ue=Math.max(De,h?.maximumFractionDigits??G),We=h?.useGrouping??!0,K=(0,R.useMemo)(()=>new Intl.NumberFormat(m,{minimumFractionDigits:De,maximumFractionDigits:Ue,useGrouping:We,numberingSystem:`latn`}),[m,De,Ue,We]),q=(0,R.useMemo)(()=>{let e=new Intl.NumberFormat(m).formatToParts(-1234.5);return{group:e.find(e=>e.type===`group`)?.value??`,`,decimal:e.find(e=>e.type===`decimal`)?.value??`.`}},[m]),Ge=e=>Number(e.toFixed(G))||0,Ke=e=>Math.min(a,Math.max(i,e)),qe=e=>Ge(W+Math.round((e-W)/S)*S),Xe=(e,t)=>{let n=(e-W)/S;return Ge(W+((t>0?Math.floor(n+1e-7):Math.ceil(n-1e-7))+t)*S)},J=e=>`${Ve(d,e)}${K.format(e)}${Ve(f,e)}`.trim();function Ze(e){let t=e.split(q.group).join(``).replace(q.decimal,`.`).replace(/[^\d.-]/g,``);if(!/\d/.test(t))return null;let n=Number(t);return Number.isFinite(n)?n:null}let Qe=k?Ze(E):null,Y=Qe??w,[X,et]=(0,R.useState)({value:Y,direction:1});X.value!==Y&&et({value:Y,direction:Y>X.value?1:-1});let rt=X.value===Y?X.direction:Y>X.value?1:-1;(0,R.useEffect)(()=>()=>{window.clearTimeout(F.current),window.clearTimeout(ge.current),window.clearTimeout(_e.current),window.clearTimeout(ve.current)},[]);function it(e,t){let n=performance.now(),r=ye.current;r.count=r.edge===e&&n-r.at<Pe?r.count+1:1,r.edge=e,r.at=n;let i=pe.current;if(i&&(i.dataset.strain=e>0?`max`:`min`,window.clearTimeout(ve.current),ve.current=window.setTimeout(()=>{delete i.dataset.strain},420)),!v){D(Ee,0,{...Re,velocity:-e*Le*(1+Math.min(r.count-1,Ie)*Fe)});let n=(e>0?he:me).current;n&&(t===`button`||t===`key`)&&D(n,{x:[0,-2.5,2.5,-1.5,1,0]},{duration:.32,ease:`easeOut`})}_&&(ue(e),window.clearTimeout(ge.current),ge.current=window.setTimeout(()=>ue(0),Me))}function Z(e,n){if(!Number.isFinite(e))return!1;let i=Ke(e),a=Math.sign(e-i);return a&&n!==`scrub`?(it(a>0?1:-1,n),se(`${J(i)}, ${a>0?`maximum`:`minimum`}`)):n===`button`&&i!==P.current&&se(J(i)),i!==P.current&&(P.current=i,t===void 0&&te(i),r?.(i),!0)}let Q=(e,t,n)=>Z(Xe(P.current,e*t),n);(0,R.useLayoutEffect)(()=>{P.current=w,Te.current=Q});function at(){let e=be.current;e&&we.current===null&&(we.current=e.getBoundingClientRect().left-L.get()-H.get())}(0,R.useLayoutEffect)(()=>{let e=we.current,t=be.current;if(we.current=null,I.current){I.current=!1;let e=N.current;if(e&&document.activeElement===e){let t=e.value.length;e.setSelectionRange(t,t)}}if(e===null||!t)return;let n=e-(t.getBoundingClientRect().left-L.get()-H.get());Math.abs(n)<.5||(H.set(H.get()+n),v?H.jump(0):D(H,0,V.morph))});function ot(){window.clearTimeout(_e.current),fe(!1)}function $(){if(!k)return;at(),A(!1),ot();let e=Ze(E);e!==null&&Z(qe(e),`type`)}function st(){window.clearTimeout(F.current),F.current=void 0,re(0)}function ct(e,t,n){st(),$();let r=Math.max(1,Math.round(t/S));n===`button`&&re(e);let i=0,a=()=>{let t=Te.current(e,r,n);F.current=window.setTimeout(a,t?Math.max(Ae,150*.86**++i):je)};F.current=window.setTimeout(a,Q(e,r,n)?ke:360)}function lt(e){let t=s??S*10,n={ArrowUp:[1,e.shiftKey?t:S],ArrowDown:[-1,e.shiftKey?t:S],PageUp:[1,t],PageDown:[-1,t]}[e.key];if(n){e.preventDefault(),e.repeat||ct(n[0],n[1],`key`);return}if(!k&&(e.key===`Home`&&Number.isFinite(i)||e.key===`End`&&a<2**53-1)){e.preventDefault(),Z(e.key===`Home`?i:a,`key`);return}e.key===`Enter`&&(e.preventDefault(),k?(I.current=!0,$()):e.currentTarget.select()),e.key===`Escape`&&k&&(e.preventDefault(),at(),A(!1),ot(),I.current=!0,Z(xe.current,`type`))}function ut(e){let t=RegExp(`[^0-9${Be(q.group)}${G||Ue?Be(q.decimal):``}${i<0?`\\-`:``}]`,`g`),n=e.replace(t,``);k||(xe.current=w),at(),O(n),A(!0);let r=Ze(n);r!==null&&r>=i&&r<=a&&qe(r)===r&&Z(r,`type`),ot(),r!==null&&r<i&&(_e.current=window.setTimeout(()=>fe(!0),Ne))}function dt(e){Ce.current=!1,p&&!l&&e.button===0&&($(),Se.current={pointer:e.pointerId,x:e.clientX,from:P.current,active:!1},e.currentTarget.setPointerCapture(e.pointerId))}function ft(e){let t=Se.current;if(!t||t.pointer!==e.pointerId)return;let n=e.clientX-t.x;if(!t.active){if(Math.abs(n)<3)return;t.active=!0,ae(!0)}let r=n/Oe,o=Math.trunc(r);Z(o?Xe(t.from,o):t.from,`scrub`);let s=t.from+r*S,c=s>a?(s-a)/S*Oe:s<i?(s-i)/S*Oe:0;L.set(v?0:He(c))}function pt(e){let t=Se.current;t&&t.pointer===e.pointerId&&(Se.current=null,t.active&&(Ce.current=!0,ae(!1),D(L,0,v?{duration:0}:V.snappy),se(J(P.current))))}let mt=t=>({toward:t,label:e,disabled:l,controls:b,limit:t>0?Y>=a:Y<=i,pressed:ne===t}),ht=Qe===null?0:Qe>a?1:Qe<i&&de?-1:0,gt=_?ht||le:0,_t=gt>0?a:i,vt=gt?typeof _==`function`?_(gt>0?`max`:`min`,_t):`${gt>0?`Max`:`Min`} ${J(_t)}`:``,yt=[x,ht&&_?ee:void 0].filter(Boolean).join(` `)||void 0;return(0,B.jsxs)(`div`,{className:z.field,"data-size":g,children:[(0,B.jsxs)(`div`,{className:z.head,children:[(0,B.jsx)(`label`,{htmlFor:b,className:z.label,"data-scrub":p&&!l||void 0,onPointerDown:dt,onPointerMove:ft,onPointerUp:pt,onPointerCancel:pt,onClick:e=>{Ce.current&&=(e.preventDefault(),!1)},children:e}),(0,B.jsx)(tt,{id:ee,edge:gt,text:vt})]}),(0,B.jsxs)(`div`,{ref:pe,className:z.control,"data-scrubbing":ie||void 0,"data-disabled":l||void 0,"data-warn":ht?ht>0?`max`:`min`:void 0,children:[(0,B.jsx)(nt,{...mt(-1),iconRef:me,onPress:()=>ct(-1,S,`button`),onRelease:st,onActivate:()=>{$(),Q(-1,1,`button`)}}),(0,B.jsx)(`div`,{className:z.valueWrap,onMouseDown:e=>{e.target!==N.current&&e.preventDefault()},onClick:e=>{!l&&e.target!==N.current&&(N.current?.focus(),N.current?.select())},children:(0,B.jsxs)(M.span,{ref:be,className:z.value,style:{x:U,y:Ee},children:[(0,B.jsx)(Ye,{text:Ve(d,Y),direction:rt,className:z.affix}),(0,B.jsxs)(`span`,{className:z.number,children:[(0,B.jsx)(`span`,{className:z.display,"data-hidden":k||void 0,"aria-hidden":`true`,children:(0,B.jsx)(Je,{value:Y,format:K,direction:rt,instant:k})}),k&&(0,B.jsx)(`span`,{className:z.mirror,"aria-hidden":`true`,children:E}),(0,B.jsx)(`input`,{ref:N,id:b,className:z.input,type:`text`,role:`spinbutton`,inputMode:i<0?`text`:G||Ue?`decimal`:`numeric`,autoComplete:`off`,spellCheck:!1,value:k?E:K.format(w),disabled:l,"aria-describedby":yt,"aria-invalid":ht?!0:void 0,"aria-valuenow":w,"aria-valuetext":J(w),"aria-valuemin":Number.isFinite(i)?i:void 0,"aria-valuemax":a<2**53-1?a:void 0,onChange:e=>ut(e.currentTarget.value),onKeyDown:lt,onKeyUp:e=>{/^(Arrow(Up|Down)|Page(Up|Down))$/.test(e.key)&&st()},onBlur:()=>{st(),$()}})]}),(0,B.jsx)(Ye,{text:Ve(f,Y),direction:rt,className:z.affix})]})}),(0,B.jsx)(nt,{...mt(1),iconRef:he,onPress:()=>ct(1,S,`button`),onRelease:st,onActivate:()=>{$(),Q(1,1,`button`)}})]}),(0,B.jsx)($e,{id:x,text:c,className:z.hint}),(0,B.jsx)(`span`,{className:z.srOnly,"aria-live":`polite`,"aria-atomic":`true`,children:oe})]})}var it=[`overview`,`cost`,`chart`,`topModel`,`compareYesterday`,`cacheHitRate`,`quota`];function Z(){let{t:e}=g(),n=p(),[i,o]=t(),s=f(),c=ie(i,{enabled:s.running,background:!1,live:!0}),l=t=>(0,B.jsx)(a,{label:e(`settings.tray.section.${t}`),detail:e(`settings.tray.section.${t}.hint`),children:(0,B.jsx)(x,{checked:i.sections[t],label:e(`settings.tray.section.${t}`),onChange:e=>o(E(i,t,e))})},t);return(0,B.jsxs)(`div`,{className:`mx-auto grid max-w-[1120px] items-start gap-4 lg:grid-cols-[minmax(0,1fr)_392px]`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,B.jsx)(Q,{title:e(`settings.tray.titleHeading`),hint:e(`settings.tray.titleHint`),children:(0,B.jsx)(`div`,{className:`p-4`,children:(0,B.jsx)(Se,{"aria-label":e(`settings.tray.titleHeading`),minColumnWidth:150,value:i.title,onValueChange:e=>o({...i,title:e}),options:u.map(t=>({value:t,label:e(`settings.tray.title.${t}`),description:e(`settings.tray.title.${t}.hint`)}))})})}),(0,B.jsx)(Q,{title:e(`settings.tray.usageHeading`),children:(0,B.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:it.map(l)})}),(0,B.jsx)(Q,{title:e(`settings.tray.clientsHeading`),children:(0,B.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:l(`clients`)})}),(0,B.jsx)(`div`,{children:(0,B.jsx)(r,{size:`sm`,variant:`plain`,icon:(0,B.jsx)(_e,{className:`size-3.5`}),onClick:()=>o(_),children:e(`settings.tray.reset`)})})]}),(0,B.jsx)(`div`,{className:`lg:sticky lg:top-0`,children:(0,B.jsxs)(Q,{title:e(`settings.tray.previewHeading`),hint:e(`settings.tray.previewHint`),children:[(0,B.jsx)(`div`,{className:`flex justify-center bg-[var(--surface-muted)] px-4 py-5`,children:(0,B.jsx)(pe,{preview:!0,className:`w-[360px] max-w-full shadow-[0_12px_40px_rgb(0_0_0/0.25)]`,prefs:i,state:s,data:c,onRefresh:()=>void n.invalidateQueries({queryKey:[`stats`]})})}),(0,B.jsx)(`p`,{className:`border-t border-[var(--border)] px-4 py-2.5 text-[11px] text-[var(--text-muted)]`,children:e(`settings.tray.previewFooter`)})]})})]})}function Q({title:e,hint:t,children:n}){let{t:r}=g();return(0,B.jsxs)(`section`,{className:`card`,children:[(0,B.jsxs)(`header`,{className:`border-b border-[var(--border)] px-4 py-3`,children:[(0,B.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`settings.tab.tray`)}),(0,B.jsx)(`h3`,{className:`text-[14px] font-semibold`,children:e}),t&&(0,B.jsx)(`p`,{className:`mt-0.5 text-[12px] text-[var(--text-secondary)]`,children:t})]}),n]})}var at=[`general`,`tray`];function ot(){let{t:e}=g(),{tab:t}=fe(),r=le(),i=n(),a=i&&at.includes(t)?t:`general`;return i?(0,B.jsx)(de,{title:e(`nav.settings`),children:(0,B.jsxs)(N,{value:a,onValueChange:e=>r(e===`general`?`/settings`:`/settings/${e}`,{replace:!0}),children:[(0,B.jsxs)(xe,{"aria-label":e(`nav.settings`),children:[(0,B.jsx)(F,{value:`general`,children:(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(L,{className:`size-3.5`}),e(`settings.tab.general`)]})}),(0,B.jsx)(F,{value:`tray`,children:(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Te,{className:`size-3.5`}),e(`settings.tab.tray`)]})})]}),(0,B.jsx)(ye,{value:`general`,className:`pt-5`,children:(0,B.jsx)($,{})}),(0,B.jsx)(ye,{value:`tray`,className:`pt-5`,children:(0,B.jsx)(Z,{})})]})}):(0,B.jsx)(de,{title:e(`nav.settings`),children:(0,B.jsx)($,{})})}function $(){let{t,locale:n,setLocale:i}=g(),o=be(),s=w(),u=m(),f=p(),_=v(),b=d(),te=ae(),{toast:T,confirm:E}=k(),D=s.data,O=e=>u.mutate(e,{onError:e=>T(C(e),`error`)}),A=e=>{i(e),O({locale:e})},j=async e=>{await h.copy(e)&&T(t(`common.copied`))};return(0,B.jsxs)(`div`,{className:`mx-auto max-w-[680px]`,children:[(0,B.jsxs)(y,{title:t(`settings.appearance`),children:[(0,B.jsx)(a,{label:t(`settings.theme`),children:(0,B.jsx)(c,{ariaLabel:t(`settings.theme`),value:o.theme,onChange:o.setTheme,items:[{value:`system`,label:t(`settings.theme.system`)},{value:`light`,label:t(`settings.theme.light`)},{value:`dark`,label:t(`settings.theme.dark`)}]})}),(0,B.jsx)(a,{label:t(`settings.accent`),detail:o.accentChoice===`system`?o.systemAccent?t(`settings.accent.followingSystem`):t(`settings.accent.systemUnavailable`):void 0,children:(0,B.jsx)(ne,{className:`w-40`,ariaLabel:t(`settings.accent`),value:o.accentChoice,onChange:o.setAccentChoice,options:[{value:`system`,label:t(`settings.accent.system`)},...P.map(e=>({value:e.color,label:t(`settings.accent.${e.id}`)}))]})}),(0,B.jsx)(a,{label:t(`settings.language`),detail:t(`settings.languageHint`),children:(0,B.jsx)(c,{ariaLabel:t(`settings.language`),value:n,onChange:A,items:[{value:`zh`,label:`中文`},{value:`en`,label:`English`}]})})]}),D?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(y,{title:t(`settings.gateway`),footer:t(`settings.gatewayFooter`),children:[(0,B.jsx)(a,{label:t(`settings.gatewayUrl`),detail:`${D.gatewayBaseUrl}/v1`,children:(0,B.jsx)(r,{size:`sm`,variant:`plain`,icon:(0,B.jsx)(re,{className:`size-3.5`}),"aria-label":t(`common.copy`),onClick:()=>void j(`${D.gatewayBaseUrl}/v1`)})}),(0,B.jsx)(a,{label:t(`settings.listen`),detail:`${D.host}:${D.port}`}),(0,B.jsx)(a,{label:t(`settings.dataDir`),detail:D.dataDir,children:h.canOpenPaths?(0,B.jsx)(r,{size:`sm`,variant:`plain`,icon:(0,B.jsx)(he,{className:`size-3.5`}),"aria-label":t(`settings.openFolder`),onClick:()=>void h.openPath(D.dataDir)}):(0,B.jsx)(r,{size:`sm`,variant:`plain`,icon:(0,B.jsx)(re,{className:`size-3.5`}),"aria-label":t(`common.copy`),onClick:()=>void j(D.dataDir)})}),(0,B.jsx)(a,{label:t(`settings.requireKey`),detail:t(`settings.requireKeyHint`),children:(0,B.jsx)(x,{checked:D.requireGatewayKey,label:t(`settings.requireKey`),onChange:async e=>{(e||await E({title:t(`settings.requireKeyOffConfirm`),detail:t(`settings.requireKeyOffDetail`),confirmLabel:t(`settings.requireKeyOff`),destructive:!0}))&&O({requireGatewayKey:e})}})}),(0,B.jsx)(a,{label:t(`settings.streamIdle`),detail:t(`settings.streamIdleHint`),children:(0,B.jsx)(ut,{label:t(`settings.streamIdle`),value:D.streamIdleTimeoutSec,onCommit:e=>O({streamIdleTimeoutSec:e??300}),suffix:` s`})})]}),(0,B.jsx)(ct,{settings:D}),(0,B.jsx)(lt,{settings:D}),(0,B.jsx)(y,{title:t(`settings.quota`),footer:t(`settings.quota.autoIntervalHint`),children:(0,B.jsx)(a,{label:t(`settings.quota.autoInterval`),children:(0,B.jsx)(ut,{label:t(`settings.quota.autoInterval`),value:D.quotaAutoIntervalMinutes,onCommit:t=>u.mutate({quotaAutoIntervalMinutes:t??30},{onSuccess:()=>void f.invalidateQueries({queryKey:e.providers}),onError:e=>T(C(e),`error`)}),suffix:` ${t(`settings.minutes`)}`})})}),(0,B.jsxs)(y,{title:t(`settings.logging`),footer:t(`settings.debugBodiesHint`),children:[(0,B.jsx)(a,{label:t(`settings.debugBodies`),children:(0,B.jsx)(x,{checked:D.debugBodies,label:t(`settings.debugBodies`),onChange:e=>O({debugBodies:e})})}),(0,B.jsx)(a,{label:t(`settings.bodyRetention`),children:(0,B.jsx)(ut,{label:t(`settings.bodyRetention`),value:D.bodyRetentionDays,onCommit:e=>O({bodyRetentionDays:e??7}),suffix:` ${t(`settings.days`)}`})}),(0,B.jsxs)(a,{label:t(`settings.requestRetention`),detail:D.requestRetentionDays==null?t(`settings.keepForever`):void 0,children:[(0,B.jsx)(x,{checked:D.requestRetentionDays!=null,label:t(`settings.requestRetention`),onChange:e=>O({requestRetentionDays:e?90:null})}),D.requestRetentionDays!=null&&(0,B.jsx)(ut,{label:t(`settings.requestRetention`),value:D.requestRetentionDays,onCommit:e=>O({requestRetentionDays:e??90}),suffix:` ${t(`settings.days`)}`})]})]}),(0,B.jsx)(y,{title:t(`settings.effort`),footer:t(`settings.effortHint`),children:[`low`,`medium`,`high`].map(e=>(0,B.jsx)(a,{label:t(`settings.effort.${e}`),children:(0,B.jsx)(ut,{label:t(`settings.effort.${e}`),value:D.effortBudgets[e],onCommit:t=>O({effortBudgets:{...D.effortBudgets,[e]:t??D.effortBudgets[e]}}),suffix:` tokens`,step:1024})},e))})]}):s.isError?(0,B.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:C(s.error)}):(0,B.jsx)(ee,{className:`mx-auto my-8`}),(0,B.jsxs)(y,{title:t(`settings.about`),children:[(0,B.jsx)(a,{label:t(`settings.serverVersion`),detail:_.data?`${_.data.version} · API ${_.data.apiVersion}`:`—`}),S&&(0,B.jsx)(a,{label:t(`settings.desktopVersion`),detail:l()?.version||`—`}),(0,B.jsx)(st,{}),S&&(0,B.jsx)(a,{label:t(`settings.logs`),onClick:()=>void h.revealLogs(),children:(0,B.jsx)(he,{className:`size-4 text-[var(--text-secondary)]`})}),b.data?.required&&(0,B.jsx)(a,{label:t(`settings.logout`),onClick:()=>te.mutate(),children:(0,B.jsx)(ge,{className:`size-4 text-[var(--text-secondary)]`})})]})]})}function st(){let{t}=g(),{toast:n}=k(),i=p(),o=m(),s=se(),c=b(),u=s.data,d=l()?.updates??null,[f,h]=(0,R.useState)(!1),_=()=>c.mutate(void 0,{onSuccess:e=>n(e.available?t(`settings.updateAvailable`,{version:e.available}):t(`settings.upToDate`)),onError:e=>n(C(e),`error`)}),v=()=>{d&&!f&&(h(!0),d.apply().then(r=>{r===`server`?(n(t(`settings.updateApplied`)),i.invalidateQueries({queryKey:e.version}),i.invalidateQueries({queryKey:e.update})):n(t(r===`desktop`?`settings.updateDesktopRelaunch`:`settings.upToDate`))}).catch(e=>n(C(e),`error`)).finally(()=>h(!1)))},y=u?.lastCheckAt?new Date(u.lastCheckAt).toLocaleString():void 0,S=u?.available?d?t(`settings.updateAvailable`,{version:u.available}):`${t(`settings.updateAvailable`,{version:u.available})} ${t(`settings.updateApplyHint`)}`:void 0;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(a,{label:t(`settings.autoCheck`),detail:u&&!u.feedConfigured?t(`settings.updateCheckFailed`,{error:`feed-not-configured`}):void 0,children:(0,B.jsx)(x,{checked:u?.autoCheck??!0,label:t(`settings.autoCheck`),onChange:e=>o.mutate({updateAutoCheck:e},{onError:e=>n(C(e),`error`)})})}),(0,B.jsxs)(a,{label:t(`settings.checkUpdates`),detail:c.isError?t(`settings.updateCheckFailed`,{error:C(c.error)}):u?.available?S:y?t(`settings.lastChecked`,{time:y}):void 0,children:[(0,B.jsx)(r,{size:`sm`,variant:`plain`,disabled:c.isPending,onClick:_,children:c.isPending?(0,B.jsx)(ee,{className:`size-3.5`}):(0,B.jsx)(ve,{className:`size-3.5`})}),d&&u?.available&&(0,B.jsx)(r,{size:`sm`,variant:`plain`,disabled:f,"aria-label":t(`settings.updateApply`),onClick:v,children:f?(0,B.jsx)(ee,{className:`size-3.5`}):(0,B.jsx)(me,{className:`size-3.5`})})]})]})}function ct({settings:e}){let{t}=g(),{toast:n}=k(),i=m(),[s,l]=(0,R.useState)(e.proxyMode),[u,d]=(0,R.useState)({url:e.proxyUrl??``,username:e.proxyUsername??``,password:``,bypass:e.proxyBypass??``});(0,R.useEffect)(()=>l(e.proxyMode),[e.proxyMode]),(0,R.useEffect)(()=>d({url:e.proxyUrl??``,username:e.proxyUsername??``,password:``,bypass:e.proxyBypass??``}),[e.proxyUrl,e.proxyUsername,e.proxyBypass,e.hasProxyPassword]);let f=t=>{l(t),(t!==`custom`||e.proxyUrl)&&i.mutate({proxyMode:t},{onError:e=>n(C(e),`error`)})},p=()=>i.mutate({proxyMode:`custom`,proxyUrl:u.url.trim()||null,proxyUsername:u.username.trim()||null,proxyBypass:u.bypass.trim()||null,...u.password?{proxyPassword:u.password}:{}},{onSuccess:()=>n(t(`settings.proxy.saved`)),onError:e=>n(C(e),`error`)}),h=s!==e.proxyMode||u.url!==(e.proxyUrl??``)||u.username!==(e.proxyUsername??``)||u.password!==``||u.bypass!==(e.proxyBypass??``);return(0,B.jsxs)(y,{title:t(`settings.proxy`),footer:t(`settings.proxy.footer`),children:[(0,B.jsx)(a,{label:t(`settings.proxy.mode`),detail:t(`settings.proxy.mode.${s}.hint`),children:(0,B.jsx)(c,{ariaLabel:t(`settings.proxy.mode`),value:s,onChange:f,items:[{value:`system`,label:t(`settings.proxy.mode.system`)},{value:`custom`,label:t(`settings.proxy.mode.custom`)},{value:`direct`,label:t(`settings.proxy.mode.direct`)}]})}),s===`custom`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(a,{label:t(`settings.proxy.url`),detail:t(`settings.proxy.urlHint`),children:(0,B.jsx)(o,{className:`w-64`,mono:!0,"aria-label":t(`settings.proxy.url`),placeholder:`http://127.0.0.1:7890`,value:u.url,onChange:e=>d({...u,url:e.target.value})})}),(0,B.jsx)(a,{label:t(`settings.proxy.username`),detail:t(`settings.proxy.optional`),children:(0,B.jsx)(o,{className:`w-64`,autoComplete:`off`,"aria-label":t(`settings.proxy.username`),value:u.username,onChange:e=>d({...u,username:e.target.value})})}),(0,B.jsx)(a,{label:t(`settings.proxy.password`),detail:e.hasProxyPassword?t(`settings.proxy.passwordSaved`):t(`settings.proxy.optional`),children:(0,B.jsx)(o,{className:`w-64`,type:`password`,autoComplete:`new-password`,"aria-label":t(`settings.proxy.password`),placeholder:e.hasProxyPassword?`••••••••`:void 0,value:u.password,onChange:e=>d({...u,password:e.target.value})})}),(0,B.jsx)(a,{label:t(`settings.proxy.bypass`),detail:t(`settings.proxy.bypassHint`),children:(0,B.jsx)(o,{className:`w-64`,mono:!0,"aria-label":t(`settings.proxy.bypass`),placeholder:`example.com, *.lan`,value:u.bypass,onChange:e=>d({...u,bypass:e.target.value})})}),(0,B.jsx)(`div`,{className:`flex justify-end px-4 py-2`,children:(0,B.jsx)(r,{size:`sm`,disabled:!h||!u.url.trim()||i.isPending,onClick:p,children:t(`common.save`)})})]})]})}function lt({settings:e}){let{t}=g(),{toast:n}=k(),i=m(),s=e.pluginMarketUrl===``,[c,l]=(0,R.useState)(e.pluginMarketUrl??``);(0,R.useEffect)(()=>l(e.pluginMarketUrl??``),[e.pluginMarketUrl]);let u=(e,r=!1)=>i.mutate({pluginMarketUrl:e},{onSuccess:()=>r&&n(t(`settings.pluginMarket.saved`)),onError:e=>n(C(e),`error`)});return(0,B.jsxs)(y,{title:t(`settings.pluginMarket`),footer:t(`settings.pluginMarket.footer`),children:[(0,B.jsx)(a,{label:t(`settings.pluginMarket.offline`),detail:t(`settings.pluginMarket.offlineHint`),children:(0,B.jsx)(x,{checked:s,label:t(`settings.pluginMarket.offline`),onChange:e=>u(e?``:null)})}),!s&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(a,{label:t(`settings.pluginMarket.url`),detail:t(`settings.pluginMarket.urlHint`),children:(0,B.jsx)(o,{className:`w-80`,mono:!0,"aria-label":t(`settings.pluginMarket.url`),placeholder:e.pluginMarketDefaultUrl,value:c,onChange:e=>l(e.target.value)})}),(0,B.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-2`,children:[e.pluginMarketUrl!==null&&(0,B.jsx)(r,{size:`sm`,disabled:i.isPending,onClick:()=>u(null,!0),children:t(`settings.pluginMarket.reset`)}),(0,B.jsx)(r,{size:`sm`,disabled:i.isPending||c.trim()===(e.pluginMarketUrl??``),onClick:()=>u(c.trim()||null,!0),children:t(`common.save`)})]})]})]})}function ut({label:e,value:t,onCommit:n,suffix:r,step:i=1}){let[a,o]=(0,R.useState)(t);(0,R.useEffect)(()=>o(t),[t]);let s=(0,R.useRef)(n);return(0,R.useEffect)(()=>{s.current=n}),(0,R.useEffect)(()=>{if(a===t)return;let e=setTimeout(()=>s.current(a),600);return()=>clearTimeout(e)},[a,t]),(0,B.jsx)(`div`,{className:`astra-label-hidden w-36`,children:(0,B.jsx)(rt,{label:e,size:`sm`,value:a,onValueChange:o,min:0,step:i,suffix:r})})}export{ot as SettingsPage};
@@ -1 +0,0 @@
1
- import{Ai as e,B as t,F as n,Fa as r,H as i,Ia as a,N as o,P as s,Sn as c,Tn as l,Vi as u,Y as d,Yr as f,Zn as p,a as m,an as h,ci as g,dn as _,fn as v,gi as y,i as b,ln as x,mn as S,n as C,o as w,qr as T,r as E,rr as D,st as O,ui as k,un as A,z as j,za as M}from"./overlays-D1ZtG8Qn.js";import{c as N,s as P,t as F}from"./Page-CnSErb_N.js";import{t as I}from"./ellipsis-zTWIrsa4.js";import{t as L}from"./pencil-DyidL-8l.js";import{t as R}from"./power-CJZylS33.js";import{t as z}from"./rotate-ccw-Dr0Xbikv.js";import{S as B,T as V,f as H,u as U}from"./index-PfVyiY3J.js";var W=M(a(),1),G=r();function K(){let{t}=l(),r=e(),i=y(),[a,s]=(0,W.useState)(!1),[c,u]=(0,W.useState)(null);return(0,G.jsxs)(F,{title:t(`nav.tokens`),subtitle:t(`tokens.subtitle`),actions:(0,G.jsx)(n,{variant:`primary`,icon:(0,G.jsx)(P,{className:`size-3.5`}),onClick:()=>s(!0),children:t(`tokens.add`)}),children:[(0,G.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col gap-4`,children:[i.data&&(0,G.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-secondary)]`,children:t(`tokens.directHint`,{url:`${i.data.gatewayBaseUrl}/v1`})}),r.isLoading&&(0,G.jsx)(d,{lines:4}),r.isError&&(0,G.jsx)(o,{tone:`danger`,title:t(`common.error`),children:m(r.error)}),r.data?.length===0&&(0,G.jsx)(`div`,{className:`card`,children:(0,G.jsx)(j,{icon:(0,G.jsx)(N,{className:`size-6`}),title:t(`tokens.empty`)})}),r.data&&r.data.length>0&&(0,G.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] overflow-hidden p-0`,children:r.data.map(e=>(0,G.jsx)(q,{token:e,defaultOpen:r.data.length===1,onEdit:()=>u(e)},e.id))})]}),(0,G.jsx)(Z,{open:a,onOpenChange:s}),(0,G.jsx)(Q,{token:c,onClose:()=>u(null)})]})}function q({token:e,defaultOpen:t,onEdit:r}){let{t:i,locale:a}=l(),{toast:o,confirm:d}=w(),p=f(),v=k(),y=u(),b=g(),x=D(),[T,E]=(0,W.useState)(t),j=(p.data??[]).find(t=>t.id===e.providerId),M=`token-detail-${e.id}`,N=(e,t)=>{o(t,`success`),e.skipped.length>0&&o(i(`tokens.skipped`,{clients:e.skipped.map(e=>U[e]?.name??e).join(`, `)}),`error`)},P=()=>v.mutate(e.id,{onSuccess:async({token:e})=>{await c.copy(e)&&o(i(`tokens.copied`))},onError:e=>o(m(e),`error`)}),F=async()=>{(!e.enabled||await d({title:i(`tokens.disableConfirm`,{name:e.name}),detail:i(`tokens.disableDetail`),confirmLabel:i(`tokens.disable`),destructive:!0}))&&y.mutate({id:e.id,enabled:!e.enabled},{onError:e=>o(m(e),`error`)})},K=async()=>{await d({title:i(`tokens.resetConfirm`,{name:e.name}),detail:i(`tokens.resetDetail`),confirmLabel:i(`tokens.reset`),destructive:!0})&&b.mutate(e.id,{onSuccess:e=>N(e,i(`tokens.resetDone`,{count:e.rewritten.length})),onError:e=>o(m(e),`error`)})},q=async()=>{await d({title:i(`tokens.deleteConfirm`,{name:e.name}),detail:i(`tokens.deleteDetail`),confirmLabel:i(`common.delete`),destructive:!0})&&x.mutate(e.id,{onSuccess:t=>N(t,i(`tokens.deleted`,{name:e.name})),onError:e=>o(m(e),`error`)})},X=e.lastUsedAt?h(e.lastUsedAt,a):i(`tokens.neverUsed`);return(0,G.jsxs)(`article`,{children:[(0,G.jsxs)(`div`,{className:`flex cursor-pointer flex-wrap items-center gap-x-5 gap-y-2 px-4 py-3 hover:bg-[var(--surface-muted)]`,onClick:()=>E(e=>!e),children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-56 items-start gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,className:`mt-0.5 rounded text-[var(--text-muted)]`,"aria-expanded":T,"aria-controls":M,"aria-label":i(`tokens.details`),onClick:e=>{e.stopPropagation(),E(e=>!e)},children:(0,G.jsx)(V,{className:`size-4 transition-transform ${T?`rotate-90`:``}`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`truncate text-[14px] font-medium ${e.enabled?``:`text-[var(--text-muted)]`}`,children:e.name}),e.isDefault&&(0,G.jsx)(s,{tone:`accent`,children:i(`tokens.default`)}),!e.enabled&&(0,G.jsx)(s,{tone:`orange`,children:i(`tokens.disabledBadge`)})]}),(0,G.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--text-secondary)] selectable`,children:e.keyMasked}),(0,G.jsx)(n,{size:`sm`,variant:`plain`,icon:(0,G.jsx)(O,{className:`size-3.5`}),"aria-label":i(`tokens.copy`),title:i(`tokens.copy`),loading:v.isPending,onClick:P})]})]})]}),(0,G.jsx)(`div`,{className:`hidden w-16 items-center gap-1.5 md:flex`,title:e.clients.map(e=>U[e]?.name??e).join(`, `)||i(`tokens.noClients`),children:e.clients.length===0?(0,G.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:`—`}):e.clients.map(e=>(0,G.jsx)(H,{kind:e,size:16},e))}),(0,G.jsx)(J,{label:i(`tokens.today`),value:S(e.today.costUsd),context:i(`tokens.requestsContext`,{count:_(e.today.requests)})}),(0,G.jsx)(J,{label:i(`tokens.total`),value:S(e.total.costUsd),context:`${_(e.total.totalTokens,!0)} Token`}),(0,G.jsx)(J,{label:i(`tokens.lastUsedTitle`),value:e.lastUsedAt?A(e.lastUsedAt,a):`—`,context:e.lastUsedAt?``:i(`tokens.neverUsed`),title:X}),(0,G.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,G.jsx)(C,{label:i(`common.more`),icon:(0,G.jsx)(I,{className:`size-4`}),items:[{id:`settings`,label:i(`tokens.settings`),icon:(0,G.jsx)(L,{className:`size-3.5`}),onSelect:r},{id:`toggle`,label:e.enabled?i(`tokens.disable`):i(`tokens.enable`),icon:(0,G.jsx)(R,{className:`size-3.5`}),onSelect:()=>void F()},{id:`reset`,label:i(`tokens.reset`),icon:(0,G.jsx)(z,{className:`size-3.5`}),onSelect:()=>void K()},...e.isDefault?[]:[{id:`delete`,label:i(`tokens.delete`),icon:(0,G.jsx)(B,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void q()}]]})})]}),T&&(0,G.jsxs)(`div`,{id:M,className:`border-t border-[var(--border-subtle)] bg-[var(--surface-muted)] px-4 py-3 md:pl-10`,children:[(0,G.jsxs)(`dl`,{className:`flex flex-wrap gap-x-8 gap-y-2 text-[12px]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:i(`tokens.clients`)}),(0,G.jsx)(`dd`,{className:`mt-0.5 flex min-h-5 flex-wrap items-center gap-x-3 gap-y-1 text-[var(--text-secondary)]`,children:e.clients.length===0?i(`tokens.noClients`):e.clients.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(H,{kind:e,size:14}),U[e]?.name??e]},e))})]}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:i(`tokens.directProvider`)}),(0,G.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:j?.name??(e.providerId?e.providerId:i(`tokens.directNone`))})]}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:i(`tokens.lastUsedTitle`)}),(0,G.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:X})]})]}),(0,G.jsx)(Y,{today:e.today,total:e.total})]})]})}function J({label:e,value:t,context:n,title:r}){return(0,G.jsxs)(`div`,{className:`w-24 min-w-0`,title:r,children:[(0,G.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,G.jsx)(`div`,{className:`num truncate text-[14px] leading-tight font-semibold`,children:t}),(0,G.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:n||`\xA0`})]})}function Y({today:e,total:t}){let{t:n}=l(),r=[[n(`tokens.today`),e],[n(`tokens.total`),t]],i=`px-3 py-1.5 text-right font-normal whitespace-nowrap text-[var(--text-muted)]`,a=`num px-3 py-1.5 text-right whitespace-nowrap`;return(0,G.jsx)(`div`,{className:`mt-3 overflow-x-auto rounded-[var(--radius-control)] bg-[var(--surface)]`,children:(0,G.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`border-b border-[var(--border-subtle)]`,children:[(0,G.jsx)(`th`,{className:`${i} text-left`}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.cost`)}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.requests`)}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.tokens`)}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.inOut`)}),(0,G.jsx)(`th`,{className:i,children:n(`tokens.cacheHit`)}),(0,G.jsx)(`th`,{className:i,title:n(`tokens.tpsContext`),children:n(`tokens.tps`)})]})}),(0,G.jsx)(`tbody`,{children:r.map(([e,t])=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`row`,className:`px-3 py-1.5 text-left font-medium whitespace-nowrap text-[var(--text-secondary)]`,children:e}),(0,G.jsx)(`td`,{className:`${a} font-semibold selectable`,children:S(t.costUsd)}),(0,G.jsx)(`td`,{className:a,children:_(t.requests)}),(0,G.jsx)(`td`,{className:a,children:_(t.totalTokens,!0)}),(0,G.jsxs)(`td`,{className:`${a} text-[var(--text-secondary)]`,children:[_(t.inputTokens,!0),` / `,_(t.outputTokens,!0)]}),(0,G.jsx)(`td`,{className:a,title:n(`usage.cacheAmounts`,{read:_(t.cacheReadTokens,!0),write:_(t.cacheWriteTokens,!0)}),children:t.cacheHitRate==null?`—`:x(t.cacheHitRate)}),(0,G.jsx)(`td`,{className:a,children:t.tps==null?`—`:v(t.tps)})]},e))})]})})}function X(){let{t:e}=l(),t=(f().data??[]).filter(e=>e.enabled);return{providers:t,options:[{value:``,label:e(`tokens.directNone`)},...t.map(e=>({value:e.id,label:e.name}))]}}function Z({open:e,onOpenChange:r}){let{t:a}=l(),{toast:o}=w(),s=p(),{options:c}=X(),[u,d]=(0,W.useState)(``),[f,h]=(0,W.useState)(``);return(0,W.useEffect)(()=>{e&&(d(``),h(``))},[e]),(0,G.jsx)(b,{open:e,onOpenChange:r,title:a(`tokens.createTitle`),footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(n,{onClick:()=>r(!1),children:a(`common.cancel`)}),(0,G.jsx)(n,{variant:`primary`,disabled:!u.trim(),loading:s.isPending,onClick:()=>s.mutate({name:u.trim(),providerId:f||null},{onSuccess:e=>{r(!1),o(a(`tokens.created`,{name:e.name}),`success`)},onError:e=>o(m(e),`error`)}),children:a(`common.create`)})]}),children:(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsx)(t,{label:a(`tokens.name`),children:(0,G.jsx)(i,{value:u,maxLength:64,placeholder:a(`tokens.namePlaceholder`),onChange:e=>d(e.target.value)})}),(0,G.jsx)(t,{label:a(`tokens.directProvider`),children:(0,G.jsx)(E,{value:f,onChange:h,options:c})})]})})}function Q({token:e,onClose:r}){let{t:a}=l(),{toast:o}=w(),s=u(),{providers:c,options:d}=X(),[f,p]=(0,W.useState)(``),[h,g]=(0,W.useState)(``),[_,v]=(0,W.useState)(``),y=c.find(e=>e.id===h),x=y?.authScheme===`oauth-subscription`||y?.authScheme===`plugin`,S=T(y?.id,x);return(0,W.useEffect)(()=>{e&&(p(e.name),g(e.providerId??``),v(e.accountId??``))},[e]),(0,G.jsx)(b,{open:e!==null,onOpenChange:e=>!e&&r(),title:a(`tokens.settingsTitle`,{name:e?.name??``}),footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(n,{onClick:r,children:a(`common.cancel`)}),(0,G.jsx)(n,{variant:`primary`,disabled:!f.trim(),loading:s.isPending,onClick:()=>{e&&s.mutate({id:e.id,name:f.trim(),providerId:h||null,accountId:x&&_||null},{onSuccess:()=>{r(),o(a(`common.saved`),`success`)},onError:e=>o(m(e),`error`)})},children:a(`common.save`)})]}),children:(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsx)(t,{label:a(`tokens.name`),children:(0,G.jsx)(i,{value:f,maxLength:64,onChange:e=>p(e.target.value)})}),(0,G.jsx)(t,{label:a(`tokens.directProvider`),children:(0,G.jsx)(E,{value:h,onChange:e=>{g(e),v(``)},options:d})}),x&&(0,G.jsx)(t,{label:a(`tokens.directAccount`),children:(0,G.jsx)(E,{value:_,onChange:v,options:[{value:``,label:a(`clients.accountDefault`)},...(S.data??[]).map(e=>({value:e.id,label:e.displayName||e.id}))]})})]})})}export{K as TokensPage};
@@ -1 +0,0 @@
1
- import{Ct as e,Dn as t,Dt as n,Fa as r,Ia as i,Ji as a,Ot as o,Pa as s,Sn as c,Tn as l,a as u,o as d,pi as f,wt as p,za as m}from"./overlays-D1ZtG8Qn.js";import{t as h}from"./TrayPanelView-BcmaqvCD.js";var g=m(i(),1),_=r(),v=new Set([`astra.theme`,`astra.accent`,`astra.locale`]);function y(){let{t:r}=l(),i=s(),{toast:m}=d(),y=a(),[b]=n(),x=o(),[S,C]=(0,g.useState)(!1),[w,T]=(0,g.useState)(`overview`),E=p(b,{enabled:x.running,background:!0,live:S}),D=f(),O=(0,g.useRef)(null);(0,g.useLayoutEffect)(()=>{let e=document.documentElement;e.dataset.view=`tray`,e.style.background=`transparent`,document.body.style.background=`transparent`},[]);let k=(0,g.useCallback)(()=>{i.invalidateQueries({queryKey:[`stats`]}),i.invalidateQueries({queryKey:t.providers}),i.invalidateQueries({queryKey:t.clients}),i.invalidateQueries({queryKey:[`provider-accounts`]})},[i]);(0,g.useEffect)(()=>y?.tray.onVisibilityChanged(e=>{C(e),e&&(T(`overview`),k())}),[y,k]),(0,g.useEffect)(()=>{x.running&&k()},[x.running,k]),(0,g.useEffect)(()=>{let e=e=>{e.key&&v.has(e.key)&&window.location.reload()};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&y?.tray.command(`hide`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y]),(0,g.useLayoutEffect)(()=>{let e=O.current;if(!e||!y)return;let t=[`header`,`tabs`,`body`,`footer`].map(t=>e.querySelector(`[data-tray-part="${t}"]`)),n=()=>{let n=e.offsetHeight-e.clientHeight,r=t.reduce((e,t)=>e+(t?.offsetHeight??0),0)+n;y.tray.resize(r)},r=new ResizeObserver(n);for(let e of t)e&&r.observe(e);return n(),()=>r.disconnect()},[y]),e(b,x,E.summary,E.plans);let A=e=>void y?.tray.command(e),j=async()=>{E.settings&&await c.copy(`${E.settings.gatewayBaseUrl}/v1`)&&m(r(`common.copied`))},M=async e=>{let t=E.providers;if(t.length===0)return;let n=await c.contextMenu(t.map(t=>({id:t.id,label:t.enabled?t.name:r(`tray.disabledProvider`,{name:t.name}),type:`checkbox`,checked:t.id===e.providerId})));n&&n!==e.providerId&&D.mutate({kind:e.kind,providerId:n},{onError:e=>m(u(e),`error`)})};return(0,_.jsx)(`div`,{className:`h-full`,children:(0,_.jsx)(h,{ref:O,className:`h-full`,prefs:b,state:x,data:E,tab:w,onTabChange:T,onCommand:A,onRefresh:k,onCopyAddress:()=>void j(),onSwitchClient:e=>void M(e)})})}export{y as TrayPanelPage};