@aidotnet/server-darwin-arm64 0.9.4 → 0.9.6

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 (54) hide show
  1. package/bin/astra-server +2 -2
  2. package/bin/wwwroot/assets/ClientsPage-DEetiYfc.js +9 -0
  3. package/bin/wwwroot/assets/KeyPage-cq7HprCR.js +1 -0
  4. package/bin/wwwroot/assets/ModelDetailPage-Uj6p-r8V.js +1 -0
  5. package/bin/wwwroot/assets/ModelsPage-B-l5oEGF.js +1 -0
  6. package/bin/wwwroot/assets/PluginsPage-BH9KjyfC.js +2 -0
  7. package/bin/wwwroot/assets/PrivacyPage-C5XhVKZd.js +1 -0
  8. package/bin/wwwroot/assets/ProviderDetailPage-uLPHWm2i.js +3 -0
  9. package/bin/wwwroot/assets/ProvidersPage-CNU_ji4e.js +2 -0
  10. package/bin/wwwroot/assets/SettingsPage-B3tbYdLW.js +2 -0
  11. package/bin/wwwroot/assets/TokenDetailPage-BVyb_-ev.js +1 -0
  12. package/bin/wwwroot/assets/TokenPoolEditor-7LX143SO.js +1 -0
  13. package/bin/wwwroot/assets/TokensPage-vRrXvqkK.js +1 -0
  14. package/bin/wwwroot/assets/{TracesPage-Bzy2gUvV.js → TracesPage-C9mYB_7E.js} +2 -2
  15. package/bin/wwwroot/assets/{TrayPanelPage-BZS_htv0.js → TrayPanelPage-NIkRrLCt.js} +1 -1
  16. package/bin/wwwroot/assets/{TrayPanelView-CYoAUUiY.js → TrayPanelView-BpQQa0qi.js} +1 -1
  17. package/bin/wwwroot/assets/alert-CN1yWco4.js +15 -0
  18. package/bin/wwwroot/assets/{arrow-down-7oFM4dM3.js → arrow-down-DP0xP3tk.js} +1 -1
  19. package/bin/wwwroot/assets/{arrow-left-Dn6_YDkh.js → arrow-left-UUQiUGQ1.js} +1 -1
  20. package/bin/wwwroot/assets/{checkbox-DzIMWhhw.js → checkbox-BEWRhO5r.js} +1 -1
  21. package/bin/wwwroot/assets/{cloud-download-Bvry8vmS.js → cloud-download-DebyBXx2.js} +1 -1
  22. package/bin/wwwroot/assets/confirm-morph-DwiVsert.js +1 -0
  23. package/bin/wwwroot/assets/{download-5xAFYJ6Q.js → download-C4--ZCHf.js} +1 -1
  24. package/bin/wwwroot/assets/{ellipsis-Dxds5r72.js → ellipsis-D250KISp.js} +1 -1
  25. package/bin/wwwroot/assets/{external-link-Bq_1v6I1.js → external-link-Bnshhxip.js} +1 -1
  26. package/bin/wwwroot/assets/{folder-open-BXsxEYtm.js → folder-open-BzVuhS53.js} +1 -1
  27. package/bin/wwwroot/assets/{index-mlmGhWY4.js → index-CBrXkG99.js} +10 -10
  28. package/bin/wwwroot/assets/index-DE_l9Wt4.css +1 -0
  29. package/bin/wwwroot/assets/{log-out-B9HHsF8m.js → log-out-DEZofPIg.js} +1 -1
  30. package/bin/wwwroot/assets/minus-BAoIEc33.js +1 -0
  31. package/bin/wwwroot/assets/overlays-D2pWmtov.js +41 -0
  32. package/bin/wwwroot/assets/{pencil-BAzRd1Ro.js → pencil-DuD1bQje.js} +1 -1
  33. package/bin/wwwroot/assets/{power-DrpargJA.js → power-LE8gLJKc.js} +1 -1
  34. package/bin/wwwroot/assets/radio-cards-D1yOuSfh.js +1 -0
  35. package/bin/wwwroot/assets/{rotate-ccw-D6r7Boub.js → rotate-ccw-Cx9vNOkF.js} +1 -1
  36. package/bin/wwwroot/assets/sortable.esm-B0eMzUNN.js +5 -0
  37. package/bin/wwwroot/index.html +4 -4
  38. package/package.json +1 -1
  39. package/bin/wwwroot/assets/ClientsPage-DzZnCU7V.js +0 -12
  40. package/bin/wwwroot/assets/KeyPage-CtHw5I7A.js +0 -1
  41. package/bin/wwwroot/assets/ModelDetailPage-KY2k0x3l.js +0 -1
  42. package/bin/wwwroot/assets/ModelsPage-Bo8oA3Zb.js +0 -1
  43. package/bin/wwwroot/assets/PluginsPage-BMP78mVY.js +0 -2
  44. package/bin/wwwroot/assets/PrivacyPage-BgldsSQj.js +0 -1
  45. package/bin/wwwroot/assets/ProviderDetailPage-B6EfUhXb.js +0 -3
  46. package/bin/wwwroot/assets/ProvidersPage-DclHIvR2.js +0 -2
  47. package/bin/wwwroot/assets/SettingsPage-D29CZiaV.js +0 -2
  48. package/bin/wwwroot/assets/TokensPage-CaF-wXlr.js +0 -1
  49. package/bin/wwwroot/assets/alert-CGUFPyGb.js +0 -15
  50. package/bin/wwwroot/assets/confirm-morph-DnwMPT3r.js +0 -1
  51. package/bin/wwwroot/assets/index-BXZibBui.css +0 -1
  52. package/bin/wwwroot/assets/minus-BVd6Aw9t.js +0 -1
  53. package/bin/wwwroot/assets/overlays-B1a0OZYb.js +0 -41
  54. package/bin/wwwroot/assets/radio-cards-Cr0tP9In.js +0 -1
@@ -1 +0,0 @@
1
- import{Ai as e,Di as t,E as n,Ei as r,J as i,Jn as a,Kn as o,Oi as s,Qr as c,Sa as l,Ti as u,Wt as d,Yn as f,_ as p,_t as m,b as h,c as g,ct as _,d as v,g as y,h as b,it as x,ji as S,l as C,m as w,n as T,ot as E,q as D,qn as O,r as k,t as ee,u as A,v as j,va as te,vt as M,y as N,ya as P}from"./alert-CGUFPyGb.js";import{a as F,i as ne,o as I,r as L}from"./overlays-B1a0OZYb.js";import{$ as re,B as ie,C as R,D as z,E as ae,I as oe,L as se,M as ce,N as B,T as le,V as ue,X as V,Z as de,_ as fe,c as pe,et as H,h as me,j as he,r as ge,w as U}from"./index-mlmGhWY4.js";var _e={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};_e.node;var ve=M(_e),W=l(P(),1),G={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`},K=te(),q={duration:n.duration.standard,ease:[...n.ease.enter]},ye={duration:n.duration.instant,ease:[...n.ease.standard]},J={duration:0},be={duration:n.duration.instant,ease:[...n.ease.standard]},Y=e=>`blur(${e}px)`,xe=e=>Math.min(1,Math.max(0,e)),Se=e=>typeof e==`string`?{value:e}:e,Ce=e=>e.label??e.value,we=e=>({initial:e?{opacity:0}:{opacity:0,y:`0.3em`,filter:Y(n.blur.soft)},animate:{opacity:1,y:0,filter:Y(0)},exit:e?{opacity:0,transition:J}:{opacity:0,y:`-0.3em`,filter:Y(n.blur.subtle),transition:ye},transition:e?be:q});function Te({text:i}){let a=t()??!1,o=(0,W.useRef)(null),c=s(`auto`);return(0,W.useLayoutEffect)(()=>{let e=o.current;if(!e||typeof ResizeObserver>`u`)return;let t=null,i=new ResizeObserver(([i])=>{let o=Math.ceil(i.borderBoxSize?.[0]?.inlineSize??e.offsetWidth),s=t!==null&&t!==e.textContent;t=e.textContent,s&&!a?r(c,o,n.spring.morph):c.jump(o)});return i.observe(e),()=>i.disconnect()},[a,c]),(0,K.jsxs)(u.span,{className:G.morphText,style:{width:c},children:[(0,K.jsx)(`span`,{ref:o,className:G.measure,"aria-hidden":`true`,children:i}),(0,K.jsx)(e,{mode:`popLayout`,initial:!1,children:(0,K.jsx)(u.span,{className:G.morphValue,...we(a),children:i},i)})]})}function Ee(e,t,i){let a=s(`auto`);return(0,W.useLayoutEffect)(()=>{let o=e.current;if(!o||typeof ResizeObserver>`u`)return;let s=!1,c=new ResizeObserver(()=>{let e=o.offsetHeight;if(!s||i||performance.now()>t.current){s=!0,a.jump(e);return}r(a,e,n.spring.smooth)});return c.observe(o),()=>c.disconnect()},[t,a,e,i]),a}function De(e,t,i){(0,W.useLayoutEffect)(()=>{let a=e.current;if(!a||typeof ResizeObserver>`u`)return;let o=new Map,s=()=>{let e=performance.now();for(let s of Array.from(a.children)){let a=s.offsetLeft,c=s.offsetTop,l=o.get(s);if(!l){o.set(s,{x:a,y:c,dx:0,dy:0});continue}let u=l.x-a,d=l.y-c;if(l.x=a,l.y=c,i||e>t.current||Math.abs(d)<1&&Math.abs(u)<40)continue;l.stop?.();let f=l.dx+u,p=l.dy+d,m=e=>{l.dx=f*(1-e),l.dy=p*(1-e),s.style.translate=e>=1?``:`${l.dx}px ${l.dy}px`};m(0),l.stop=r(0,1,{...n.spring.smooth,onUpdate:m,onComplete:()=>m(1)}).stop}for(let e of o.keys())e.parentElement!==a&&o.delete(e)},c=new ResizeObserver(s),l=()=>{for(let e of Array.from(a.children))c.observe(e)},u=new MutationObserver(()=>{l(),s()});return c.observe(a),l(),u.observe(a,{childList:!0}),()=>{c.disconnect(),u.disconnect();for(let e of o.values())e.stop?.()}},[t,e,i])}var X=e=>e.valueLabel??e.value,Z=e=>X(e)?`${e.label}: ${X(e)}`:e.label,Oe={empty:`No filters applied`,clearAll:`Clear all`,back:`Back to fields`,noOptions:`No options available`,cleared:`All filters cleared`,remove:e=>`Remove ${Z(e)}`,added:e=>`Added ${Z(e)}`,changed:e=>`Changed ${Z(e)}`,removed:e=>`Removed ${Z(e)}`};function ke(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 Ae({rows:e,labelledBy:r,onChoose:i,onBack:a,onLeave:o,radio:s,emptyMessage:c}){let l=t()??!1,d=S(),f=(0,W.useRef)(null),p=(0,W.useRef)(!1),m=(0,W.useRef)({text:``,at:0}),[h,g]=(0,W.useState)(()=>Math.max(0,e.findIndex(e=>e.checked))),[_,v]=(0,W.useState)(null),y=()=>Array.from(f.current?.querySelectorAll(`[data-row]`)??[]),b=e=>{let t=f.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 x(t){let n=y(),r=n.indexOf(document.activeElement),o=e=>{t.preventDefault(),p.current=!1,b(n[e])};if(t.key===`ArrowDown`)return o(r<0?0:(r+1)%n.length);if(t.key===`ArrowUp`)return o(r<0?n.length-1:(r-1+n.length)%n.length);if(t.key===`Home`)return o(0);if(t.key===`End`)return o(n.length-1);if(t.key===`ArrowRight`&&r>=0&&e[r]?.drill){t.preventDefault(),i(e[r],!0);return}if(t.key===`ArrowLeft`&&a){t.preventDefault(),a(!0);return}if(t.key.length===1&&/\S/.test(t.key)&&!t.metaKey&&!t.ctrlKey&&!t.altKey){let e=performance.now();m.current={text:e-m.current.at<700?m.current.text+t.key.toLowerCase():t.key.toLowerCase(),at:e};let i=[...n.slice(r+(m.current.text.length>1?0:1)),...n.slice(0,r+(m.current.text.length>1?0:1))].find(e=>(e.dataset.text??``).toLowerCase().startsWith(m.current.text));i&&o(n.indexOf(i))}}function C(e){let t=e.target.closest(`[data-row]`);if(!t)return;g(y().indexOf(t));let n=p.current&&!l,r=!p.current&&t.matches(`:focus-visible`);v(e=>({top:t.offsetTop,height:t.offsetHeight,glide:n&&!!e?.shown,ring:r,shown:!0}))}function w(e){f.current?.contains(e.relatedTarget)||v(e=>e&&{...e,glide:!1,ring:!1,shown:!1})}return(0,K.jsxs)(`div`,{ref:f,className:G.list,role:`menu`,"aria-labelledby":r,"data-current":d?``:void 0,onKeyDown:x,onFocus:C,onBlur:w,onPointerLeave:()=>{p.current&&f.current?.contains(document.activeElement)&&o()},children:[(0,K.jsx)(u.span,{className:G.highlight,"data-ring":_?.ring||void 0,"aria-hidden":`true`,initial:!1,animate:_?{y:_.top,height:_.height,opacity:+!!_.shown}:{opacity:0},transition:{default:_?.glide?n.spring.snappy:J,opacity:{duration:l?0:.08}}}),e.length===0?(0,K.jsx)(`p`,{className:G.noOptions,children:c}):null,e.map((e,t)=>(0,K.jsxs)(`button`,{type:`button`,className:G.item,role:s?`menuitemradio`:`menuitem`,"aria-checked":s?!!e.checked:void 0,tabIndex:t===h?0:-1,"data-row":e.key,"data-text":e.label,onPointerMove:e=>{p.current=!0,document.activeElement!==e.currentTarget&&e.currentTarget.focus({preventScroll:!0})},onClick:t=>i(e,t.detail===0),children:[e.icon?(0,K.jsx)(`span`,{className:G.itemIcon,"aria-hidden":`true`,children:e.icon}):null,(0,K.jsx)(`span`,{className:G.itemLabel,children:e.label}),e.meta?(0,K.jsx)(`span`,{className:G.itemMeta,children:e.meta}):null]},e.key))]})}function je(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 Me({fields:i,onSelect:a,active:o=[],label:c=`Add filter`,align:l=`end`,messages:d}){let f={...Oe,...d},p=t()??!1,h=(0,W.useId)(),g=`${h}panel`,_=`${h}title`,v=(0,W.useRef)(null),y=(0,W.useRef)(null),b=(0,W.useRef)(null),x=(0,W.useRef)(`closed`),S=(0,W.useRef)(0),C=(0,W.useRef)(null),[w,T]=(0,W.useState)(`closed`),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(1),[ee,A]=(0,W.useState)(!1),[j,te]=(0,W.useState)(`100% 0`),M=s(`100%`),N=s(`100%`),P=s(0),F=s(0),ne=H(()=>F.get()-P.get()),I=s(0),L=s(0),re=H(()=>{let e=M.get(),t=I.get(),n=L.get();return typeof e==`number`?n>t?xe((e-t)/(n-t)):1:0}),R=H(()=>xe(re.get()/.35)),z=H(()=>xe((re.get()-.4)/.5)),ae={opacity:H(()=>1-R.get()),scale:H(()=>1-R.get()*.04),filter:H(()=>R.get()?Y(R.get()*n.blur.subtle):`none`)},oe={opacity:z,transformOrigin:j,scale:H(()=>.96+z.get()*.04),y:H(()=>(1-z.get())*(ee?-6:6)),filter:H(()=>z.get()===1?`none`:Y((1-z.get())*n.blur.soft))},ce=w===`open`,B=i.find(e=>e.id===E)??null,le=(0,W.useCallback)(e=>{let t=y.current,i=b.current;if(!t||!i)return;let a=t.getBoundingClientRect(),o=i.offsetWidth+2,s=i.offsetHeight+2,c=je(v.current??t),u=c.left+16-a.left,d=c.right-16-a.left-o,f=a.width-o,m=l===`end`?f>=u?f:0<=d?0:f:0<=d?0:f>=u?f:0;m=Math.round(Math.min(Math.max(m,u),Math.max(u,d)));let h=c.bottom-a.top,g=a.bottom-c.top,_=h<s+16&&g>h;x.current===`closed`&&(M.jump(a.width),N.jump(a.height),P.jump(0)),F.jump(m),I.jump(a.width),L.jump(o),x.current=`open`,S.current+=1,C.current=e,T(`open`),A(_),D(null),k(-1),te(`${Math.round(a.width/2-m)}px ${_?`100%`:`0`}`);let w=p?J:n.spring.morph;r(P,m,w),r(M,o,w),r(N,s,w)},[l,I,N,P,p,F,L,M]),V=(0,W.useCallback)(e=>{let t=y.current;if(x.current!==`open`||!t)return;x.current=`closing`;let i=S.current+=1;T(`closing`),e&&t.focus({preventScroll:!0,focusVisible:e===`keyboard`});let a=p?J:n.spring.snappy;r(P,0,a);let o=t.getBoundingClientRect();r(N,o.height,a),r(M,o.width,{...a,onComplete:()=>{i===S.current&&(x.current=`closed`,M.jump(`100%`),N.jump(`100%`),T(`closed`),D(null))}})},[N,P,p,M]);(0,W.useLayoutEffect)(()=>{let e=b.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{x.current===`open`&&r(N,e.offsetHeight+2,p?J:n.spring.smooth)});return t.observe(e),()=>t.disconnect()},[N,p]),(0,W.useLayoutEffect)(()=>{let e=C.current,t=b.current;if(!e||!t||w!==`open`)return;if(C.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})},[w,E]),(0,W.useEffect)(()=>{if(w!==`open`)return;let e=e=>{let t=v.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))&&y.current?.focus({preventScroll:!0,focusVisible:!1})},0))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[V,w]);function de(e){if(e.defaultPrevented)return;let t=Array.from(b.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`&&B&&(e.preventDefault(),fe(!0))}function fe(e){B&&(C.current=e?{key:B.id}:`panel`,k(-1),D(null))}function pe(e,t){C.current=t?`checked`:`panel`,k(1),D(e.key)}function me(e,t){B&&(a({id:B.id,label:B.label,value:e.key,valueLabel:e.label},B),V(t?`keyboard`:`pointer`))}let he=e=>o.find(t=>t.id===e.id),ge=i.map(e=>({key:e.id,label:e.label,icon:e.icon,drill:!0,meta:(0,K.jsxs)(K.Fragment,{children:[he(e)?(0,K.jsx)(`span`,{className:G.metaValue,children:X(he(e))}):null,(0,K.jsx)(ie,{size:15,strokeWidth:1.8,"aria-hidden":`true`})]})})),U=B?B.options.map(Se).map(e=>{let t=Ce(e),n=he(B)?.value===e.value;return{key:e.value,label:t,icon:e.icon,checked:n,meta:e.hint!=null||n?(0,K.jsxs)(K.Fragment,{children:[e.hint==null?null:(0,K.jsx)(`span`,{className:G.hint,children:e.hint}),(0,K.jsx)(`span`,{className:G.check,"data-on":n||void 0,children:(0,K.jsx)(m,{size:15,strokeWidth:2,"aria-hidden":`true`})})]}):null}}):[],_e={enter:e=>p?{opacity:0}:{opacity:0,x:e*18,filter:Y(n.blur.soft)},center:{opacity:1,x:0,filter:Y(0),transition:p?be:{...q,x:n.spring.smooth}},exit:e=>p?{opacity:0,transition:J}:{opacity:0,x:e*-18,filter:Y(n.blur.subtle),transition:ye}};return(0,K.jsxs)(`div`,{ref:v,className:G.menu,"data-state":w,"data-y":ee?`up`:`down`,onKeyDown:e=>{e.key===`Escape`&&x.current===`open`&&(e.preventDefault(),e.stopPropagation(),V(`keyboard`))},onBlur:e=>{let t=e.relatedTarget;x.current===`open`&&t&&!v.current?.contains(t)&&V(!1)},children:[(0,K.jsx)(`button`,{ref:y,type:`button`,className:G.trigger,"data-filter-trigger":``,"aria-haspopup":`dialog`,"aria-expanded":ce,"aria-controls":g,tabIndex:ce?-1:void 0,onClick:e=>{x.current!==`open`&&le(e.detail===0?`first`:`panel`)},onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),le(e.key===`ArrowDown`?`first`:`last`))},children:(0,K.jsxs)(u.span,{className:G.face,style:ae,children:[(0,K.jsx)(se,{size:15,strokeWidth:1.8,"aria-hidden":`true`}),c]})}),(0,K.jsx)(u.div,{className:G.surface,style:{left:P,width:M,height:N},children:(0,K.jsx)(u.div,{ref:b,id:g,className:G.panel,role:`dialog`,"aria-labelledby":_,tabIndex:-1,inert:!ce,style:{x:ne},onKeyDown:de,children:(0,K.jsxs)(u.div,{style:oe,children:[(0,K.jsxs)(`div`,{className:G.head,children:[(0,K.jsx)(e,{initial:!1,children:B?(0,K.jsx)(u.button,{type:`button`,className:G.back,"aria-label":f.back,onClick:e=>fe(e.detail===0),initial:p?{opacity:0,width:28,marginRight:2}:{opacity:0,width:0,marginRight:0,scale:.6},animate:{opacity:1,width:28,marginRight:2,scale:1},exit:p?{opacity:0,transition:J}:{opacity:0,width:0,marginRight:0,scale:.6,transition:{...n.spring.snappy,opacity:ye}},transition:p?be:{...n.spring.snappy,opacity:q},children:(0,K.jsx)(ue,{size:16,strokeWidth:1.8,"aria-hidden":`true`})},`back`):null}),(0,K.jsx)(`span`,{className:G.title,id:_,children:(0,K.jsx)(e,{mode:`popLayout`,initial:!1,children:(0,K.jsx)(u.span,{className:G.titleText,...we(p),children:B?B.label:c},B?.id??`fields`)})})]}),(0,K.jsx)(`div`,{className:G.stage,children:(0,K.jsx)(e,{mode:`popLayout`,initial:!1,custom:O,children:(0,K.jsx)(u.div,{className:G.step,custom:O,variants:_e,initial:`enter`,animate:`center`,exit:`exit`,children:B?(0,K.jsx)(Ae,{rows:U,labelledBy:_,emptyMessage:f.noOptions,radio:!0,onChoose:me,onBack:fe,onLeave:()=>b.current?.focus({preventScroll:!0})}):(0,K.jsx)(Ae,{rows:ge,labelledBy:_,emptyMessage:f.noOptions,onChoose:pe,onLeave:()=>b.current?.focus({preventScroll:!0})})},B?.id??`fields`)})})]})})})]})}function Ne({filters:r,onRemove:i,onClearAll:a,leading:o,children:s,label:c=`Active filters`,addFilter:l,messages:d}){let f={...Oe,...d},p=t()??!1,m=(0,W.useRef)(null),h=(0,W.useRef)(null),g=(0,W.useRef)(0),v=(0,W.useRef)(null),[y,b]=(0,W.useState)(r),[x,S]=(0,W.useState)(``);if(y!==r){b(r);let e=ke(y,r,f);e&&S(e)}let C=r.map(e=>`${e.id}:${e.value??``}`).join(`|`);(0,W.useLayoutEffect)(()=>{g.current=performance.now()+900},[C]);let w=Ee(h,g,p);De(h,g,p),(0,W.useLayoutEffect)(()=>{let e=v.current,t=m.current;if(e===null||!t)return;v.current=null;let n=r[Math.min(e,r.length-1)];(n?t.querySelector(`[data-chip-remove="${CSS.escape(n.id)}"]`):t.querySelector(`[data-filter-trigger]`))?.focus({preventScroll:!0})},[r]);let T={duration:0},E=e=>({initial:!p&&{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1},animate:{width:`auto`,marginRight:0,transitionEnd:{overflow:`visible`,"--slot-moving":0}},exit:p?{opacity:0,transition:T}:{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1,pointerEvents:`none`,transition:{...n.spring.smooth,"--slot-moving":T}},transition:p?T:n.spring.smooth}),D={initial:!p&&{opacity:0,scale:.9,filter:Y(n.blur.soft)},animate:{opacity:1,scale:1,filter:Y(0)},exit:p?{opacity:0,transition:T}:{opacity:0,scale:.9,filter:Y(n.blur.subtle),transition:ye},transition:p?T:{...q,scale:n.spring.snappy}},O=p?{...we(!0),initial:!1}:we(!1),k=p?O:{...O,transition:{...q,delay:n.duration.instant*.75}};return(0,K.jsxs)(`div`,{ref:m,className:G.toolbar,role:`group`,"aria-label":c,children:[o?(0,K.jsx)(`div`,{className:G.leading,children:o}):null,(0,K.jsx)(u.div,{className:G.frame,style:{height:w},children:(0,K.jsxs)(`div`,{ref:h,className:G.chips,children:[(0,K.jsx)(e,{initial:!1,children:r.map((e,t)=>(0,K.jsx)(u.span,{className:G.slot,...E(8),children:(0,K.jsxs)(u.span,{className:G.chip,...D,children:[(0,K.jsxs)(`span`,{className:G.chipLabel,title:Z(e),children:[e.label,X(e)?(0,K.jsxs)(`span`,{className:G.value,children:[(0,K.jsx)(`span`,{className:G.separator,children:` · `}),(0,K.jsx)(Te,{text:X(e)})]}):null]}),(0,K.jsx)(`button`,{type:`button`,"data-chip-remove":e.id,"aria-label":f.remove(e),onClick:n=>{document.activeElement===n.currentTarget&&(v.current=t),i(e.id)},children:(0,K.jsx)(_,{size:14,strokeWidth:1.8,"aria-hidden":`true`})})]})},e.id))}),(0,K.jsx)(e,{initial:!1,children:r.length?null:(0,K.jsx)(u.span,{className:G.empty,...k,children:f.empty},`empty`)})]})}),(0,K.jsxs)(`div`,{className:G.actions,children:[l?(0,K.jsx)(Me,{fields:l.fields,onSelect:l.onAdd,active:r,label:l.label,align:l.align,messages:f}):null,s,(0,K.jsx)(e,{initial:!1,children:r.length>0&&a?(0,K.jsx)(u.span,{className:G.slot,...E(12),children:(0,K.jsx)(`button`,{className:G.clear,type:`button`,onClick:()=>{v.current=-1,a?.()},children:(0,K.jsx)(u.span,{className:G.clearText,...O,children:f.clearAll})})},`clear`):null})]}),(0,K.jsx)(`span`,{className:G.srOnly,role:`status`,children:x})]})}var Pe={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`},Fe={warn:`settings.privacy.action.warn`,block:`settings.privacy.action.block`,redact:`settings.privacy.action.redact`};function Ie(){let{t:e}=E();return t=>{let n=Pe[t];return n?e(n):t}}function Le({action:e}){let{t}=E();return(0,K.jsx)(T,{tone:e===`block`?`red`:e===`redact`?`orange`:`neutral`,children:t(Fe[e]??`settings.privacy.action.warn`)})}var Re=50,ze=[`block`,`redact`,`warn`];function Be(){let{t:e,locale:t}=E(),n=Ie(),[r,a]=(0,W.useState)(``),[s,c]=(0,W.useState)({client:``,category:``,action:``,blocked:``}),[l,u]=(0,W.useState)(1),[p,m]=(0,W.useState)(null),h=he(r),_=d(),v=o(),y={model:h,...s,page:l,pageSize:Re},S=f(y,l===1),C=S.data,w=C?Math.max(1,Math.ceil(C.total/Re)):1,T=e=>e?fe[e]?.name??e:`—`,O=[...new Set((v.data?.rules??[]).map(e=>e.category))],A={client:(_.data??[]).map(e=>({value:e.kind,label:e.name})),category:O.map(e=>({value:e,label:n(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`)}]},te={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:te[e],options:A[e].map(e=>e.label)})),N=Object.keys(s).filter(e=>s[e]).map(e=>({id:e,label:te[e],value:A[e].find(t=>t.value===s[e])?.label??s[e]})),P=(e,t)=>{c(n=>({...n,[e]:t})),u(1)},ne=(C?.items??[]).map(e=>({id:e.id,time:Date.parse(e.startedAtUtc),client:T(e.clientKind),model:e.requestedModel??``,outcome:Ve(e),hits:e.hits.reduce((e,t)=>e+t.count,0),e})),I=[{key:`time`,label:e(`requests.col.time`),width:92,render:(e,n)=>(0,K.jsx)(`span`,{className:`num`,children:D(n.e.startedAtUtc,t)})},{key:`model`,label:e(`requests.col.model`),render:(t,n)=>(0,K.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>m(n.id),"aria-label":e(`privacy.logs.viewRequest`,{model:n.model||n.id}),children:[(0,K.jsx)(`span`,{className:`block truncate font-medium hover:text-[var(--accent)]`,children:n.model||`—`}),(0,K.jsx)(`span`,{className:`block truncate text-[11px] text-[var(--text-muted)]`,children:T(n.e.clientKind)})]})},{key:`outcome`,label:e(`privacy.logs.col.outcome`),width:130,render:(e,t)=>(0,K.jsx)(He,{event:t.e})},{key:`hits`,label:e(`privacy.logs.col.hits`),render:(e,t)=>(0,K.jsx)(Ue,{event:t.e})},{key:`client`,label:e(`requests.col.client`),width:110,render:e=>(0,K.jsx)(`span`,{className:`block truncate`,children:String(e||`—`)})}];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,K.jsx)(b,{className:`w-52`,value:r,onChange:e=>{a(e),u(1)},placeholder:e(`requests.searchModel`)}),(0,K.jsx)(k,{variant:`plain`,icon:(0,K.jsx)(oe,{className:x(`size-4`,S.isFetching&&`animate-spin`)}),"aria-label":e(`common.refresh`),onClick:()=>void S.refetch()})]}),(0,K.jsx)(`div`,{className:`mb-3`,children:(0,K.jsx)(Ne,{label:e(`requests.filters`),filters:N,onRemove:e=>P(e,``),onClearAll:()=>{c({client:``,category:``,action:``,blocked:``}),u(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)}}})}),S.isLoading&&(0,K.jsx)(j,{lines:4,className:`py-6`}),S.isError&&(0,K.jsx)(ee,{tone:`danger`,title:e(`common.error`),children:F(S.error)}),C&&C.items.length===0&&(0,K.jsx)(g,{icon:(0,K.jsx)(ve,{className:`size-6`}),title:e(`privacy.logs.empty`),detail:e(`privacy.logs.empty.detail`)}),C&&C.items.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-2 text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.total`,{count:i(C.total)})}),(0,K.jsx)(z,{caption:e(`privacy.tab.logs`),rows:ne,columns:I,rowKey:`id`,emptyMessage:e(`privacy.logs.empty`)})]}),C&&w>1&&(0,K.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,K.jsx)(pe,{page:l,pageCount:w,onPageChange:u,label:e(`requests.page`,{page:l,pages:w})})}),(0,K.jsx)(ge,{id:p,onClose:()=>m(null)})]})}function Ve(e){return e.blocked?`blocked`:e.redactions>0?`redact`:e.dryRun?`dryRun`:`warn`}function He({event:e}){let{t}=E();return e.blocked?(0,K.jsx)(T,{tone:`red`,children:t(`privacy.logs.outcome.blocked`)}):e.redactions>0?(0,K.jsx)(T,{tone:`orange`,children:t(`privacy.logs.outcome.redacted`,{count:e.redactions})}):e.dryRun?(0,K.jsx)(T,{tone:`neutral`,children:t(`privacy.logs.outcome.dryRun`)}):(0,K.jsx)(T,{tone:`neutral`,children:t(`settings.privacy.action.warn`)})}function Ue({event:e}){let t=Ie(),{t:n}=E();if(e.hits.length===0)return(0,K.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`—`});let r=e.hits.slice(0,2),i=e.hits.length-r.length;return(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px]`,children:[r.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(Le,{action:e.action}),(0,K.jsxs)(`span`,{children:[t(e.category),` × `,e.count]}),e.samples&&e.samples.length>0&&(0,K.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,K.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(${n.blur.soft}px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.standard,ease:[...n.ease.enter]}},gone:{opacity:0,y:`-0.3em`,filter:`blur(${n.blur.subtle}px)`,transition:{duration:n.duration.fast,ease:[...n.ease.standard]}}},Ke={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}}},qe={...n.spring.smooth,visualDuration:n.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 r=H(e,e=>((t-e)%10+15)%10-5),i=H(r,e=>`${e}em`),a=H(r,e=>Math.max(0,1-Math.abs(e))),o=H(r,e=>Math.abs(e)>=1?`hidden`:`visible`),s=H(r,e=>Math.abs(e)<.02||Math.abs(e)>=1?`none`:`blur(${(Math.abs(e)*n.blur.subtle).toFixed(2)}px)`);return(0,K.jsx)(u.span,{className:Q.glyph,style:{y:i,opacity:a,filter:s,visibility:o},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:i,delay:a,reduceMotion:o}){let c=s(i?0:e),l=(0,W.useRef)({digit:i?0:e,target:i?0:e,revealed:!i});return(0,W.useEffect)(()=>{let s=l.current;if(i||s.digit===e){i||(s.revealed=!0);return}s.target+=t<0&&s.revealed?-((s.digit-e+10)%10):(e-s.digit+10)%10,s.digit=e,o?c.jump(s.target):r(c,s.target,s.revealed?n.spring.smooth:{...qe,delay:a}),s.revealed=!0},[i,a,e,t,c,o]),(0,K.jsxs)(u.span,{className:Q.column,...Xe,transition:o?{duration:0}:n.spring.morph,children:[(0,K.jsx)(`span`,{className:Q.sizer,children:`0`}),We.map(e=>(0,K.jsx)(Ye,{position:c,digit:e},e))]})}function Qe({value:r,label:i,prefix:a=``,suffix:o=``,decimals:s=0,animateOnView:c=!1,locale:l=`en-US`}){let d=(0,W.useRef)(null),f=re(d,{once:!0,amount:.6}),p=!!t(),[m,h]=(0,W.useState)(r),[g,_]=(0,W.useState)(1);r!==m&&(h(r),_(r>m?1:-1));let v=Je(r,s,l),y=`${a}${v.map(e=>`text`in e?e.text:e.digit).join(``)}${o}`,b=c&&!f;return(0,K.jsxs)(`span`,{ref:d,className:Q.counter,children:[i&&(0,K.jsx)(`span`,{className:Q.label,children:(0,K.jsx)(`span`,{className:Q.labelSwap,children:(0,K.jsx)(e,{mode:`popLayout`,initial:!1,children:(0,K.jsx)(u.span,{className:Q.labelText,variants:p?Ke:Ge,initial:`hidden`,animate:`shown`,exit:`gone`,children:i},i)})})}),(0,K.jsx)(`span`,{className:Q.srOnly,children:y}),(0,K.jsxs)(`span`,{className:Q.value,"aria-hidden":`true`,children:[a&&(0,K.jsx)(`span`,{className:Q.symbol,children:a}),(0,K.jsx)(e,{initial:!1,children:v.map(e=>`digit`in e?(0,K.jsx)(Ze,{digit:e.digit,direction:g,armed:b,delay:Math.min(e.order*n.stagger.item,.25),reduceMotion:p},e.key):(0,K.jsx)(u.span,{className:Q.symbol,...Xe,transition:p?{duration:0}:n.spring.morph,children:e.text},e.key))}),o&&(0,K.jsx)(`span`,{className:Q.symbol,children:o})]})]})}var $={card:`_card_1r6t9_1`,top:`_top_1r6t9_2`,swap:`_swap_1r6t9_8`,swapBlock:`_swapBlock_1r6t9_8`,text:`_text_1r6t9_11`,sizer:`_sizer_1r6t9_13`},$e={hidden:e=>({opacity:0,y:`${.3*e}em`,filter:`blur(${n.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.standard,ease:[...n.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${n.blur.subtle}px)`,transition:{duration:n.duration.fast,ease:[...n.ease.standard]}})},et={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}}},tt=e=>Number(e.replace(/,/g,``).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN);function nt({text:i,morph:a=!1,block:o=!1}){let c=!!t(),l=(0,W.useRef)(null),d=s(`auto`),[f,p]=(0,W.useState)({text:i,direction:1});return f.text!==i&&p({text:i,direction:tt(i)<tt(f.text)?-1:1}),(0,W.useEffect)(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=null,i=new ResizeObserver(([i])=>{let a=i.borderBoxSize?.[0]?.inlineSize??e.offsetWidth;a&&t!==null&&t!==e.textContent&&!c?r(d,a,n.spring.morph):d.jump(a||`auto`),t=a?e.textContent:null});return i.observe(e),()=>i.disconnect()},[a,c,d]),(0,K.jsxs)(u.span,{className:o?$.swapBlock:$.swap,style:a?{width:d}:void 0,children:[a&&(0,K.jsx)(`span`,{ref:l,className:$.sizer,"aria-hidden":`true`,children:i}),(0,K.jsx)(e,{mode:`popLayout`,initial:!1,custom:f.direction,children:(0,K.jsx)(u.span,{className:$.text,custom:f.direction,variants:c?et:$e,initial:`hidden`,animate:`shown`,exit:`gone`,children:i},i)})]})}function rt({label:r,value:i,suffix:a,context:o,change:s}){let c=!!t();return(0,K.jsxs)(`article`,{className:$.card,children:[(0,K.jsxs)(`div`,{className:$.top,children:[(0,K.jsx)(`span`,{children:(0,K.jsx)(nt,{text:r,block:!0})}),(0,K.jsx)(e,{initial:!1,children:s&&(0,K.jsx)(u.small,{"data-trend":/^[+]/.test(s)?`up`:/^[-−]/.test(s)?`down`:void 0,initial:{opacity:0,scale:c?1:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:c?1:.96,transition:{duration:n.duration.fast,ease:[...n.ease.standard]}},transition:c?{duration:0}:n.spring.snappy,children:(0,K.jsx)(nt,{text:s,morph:!0})},`change`)})]}),(0,K.jsx)(Qe,{value:i,suffix:a,animateOnView:!0}),(0,K.jsx)(`p`,{children:(0,K.jsx)(nt,{text:o,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=Fe;function st(){let{t:e}=E(),{toast:t}=I(),n=o(),r=c(),i=n.data?.settings,a=e=>{i&&r.mutate({...i,...e},{onError:e=>t(F(e),`error`)})},s=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])}));return(0,K.jsxs)(A,{title:e(`settings.privacy`),footer:e(`settings.privacy.footer`),children:[n.isLoading&&(0,K.jsx)(j,{className:`my-4`}),n.isError&&(0,K.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--danger)]`,children:F(n.error)}),i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(w,{label:e(`settings.privacy.enabled`),detail:e(`settings.privacy.enabledHint`),children:(0,K.jsx)(N,{checked:i.enabled,label:e(`settings.privacy.enabled`),onChange:e=>a({enabled:e})})}),(0,K.jsx)(w,{label:e(`settings.privacy.dryRun`),detail:e(`settings.privacy.dryRunHint`),children:(0,K.jsx)(N,{checked:i.dryRun,disabled:!i.enabled,label:e(`settings.privacy.dryRun`),onChange:e=>a({dryRun:e})})}),(0,K.jsx)(w,{label:e(`settings.privacy.restore`),detail:e(`settings.privacy.restoreHint`),children:(0,K.jsx)(N,{checked:i.restoreResponses,disabled:!i.enabled,label:e(`settings.privacy.restore`),onChange:e=>a({restoreResponses:e})})}),(0,K.jsx)(w,{label:e(`settings.privacy.recordSamples`),detail:e(`settings.privacy.recordSamplesHint`),children:(0,K.jsx)(N,{checked:i.recordSamples,disabled:!i.enabled,label:e(`settings.privacy.recordSamples`),onChange:e=>a({recordSamples:e})})}),(0,K.jsx)(w,{label:e(`settings.privacy.defaultAction`),children:(0,K.jsx)(L,{className:`w-36`,ariaLabel:e(`settings.privacy.defaultAction`),value:i.defaultAction,disabled:!i.enabled,onChange:e=>a({defaultAction:e}),options:s})})]})]})}function ct(){let{t:e}=E(),{toast:t}=I(),n=o(),r=c(),i=n.data?.settings,a=Ie(),s=e=>{i&&r.mutate({...i,...e},{onError:e=>t(F(e),`error`)})},l=(e,t)=>s({categoryActions:{...i?.categoryActions,[e]:t}}),u=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])})),d=[...new Set((n.data?.rules??[]).map(e=>e.category))],f=e=>n.data?.rules.find(t=>t.category===e)?.description;return n.isLoading?(0,K.jsx)(`div`,{className:`mx-auto max-w-[720px]`,children:(0,K.jsx)(j,{className:`my-4`})}):i?(0,K.jsxs)(`div`,{className:`mx-auto flex max-w-[720px] flex-col gap-4`,children:[(0,K.jsx)(A,{title:e(`settings.privacy.categories`),children:d.map(t=>{let n=i.categoryActions[t]??i.defaultAction,r=!i.enabled||n===`off`;return(0,K.jsxs)(w,{label:a(t),detail:f(t),children:[n===`off`?(0,K.jsx)(T,{children:e(`settings.privacy.action.off`)}):(0,K.jsx)(L,{className:`w-36`,ariaLabel:a(t),value:n,disabled:!i.enabled,onChange:e=>l(t,e),options:u.filter(e=>e.value!==`off`)}),r&&(0,K.jsx)(k,{size:`sm`,variant:`plain`,disabled:!i.enabled,onClick:()=>l(t,i.categoryActions[t]??i.defaultAction),children:e(`settings.privacy.enableCategory`)})]},t)})}),(0,K.jsx)(lt,{s:i,onPatch:s})]}):null}function lt({s:e,onPatch:t}){let{t:n}=E(),{confirm:r}=I(),[i,a]=(0,W.useState)(!1),o=(n,r)=>t({customRules:e.customRules.map(e=>e.id===n.id?{...e,enabled:r}:e)}),s=async i=>{await r({title:n(`settings.privacy.deleteRuleConfirm`,{name:i.name}),destructive:!0,confirmLabel:n(`common.delete`)})&&t({customRules:e.customRules.filter(e=>e.id!==i.id)})};return(0,K.jsxs)(A,{title:n(`settings.privacy.customRules`),children:[e.customRules.length===0&&(0,K.jsx)(`div`,{className:`px-4 py-4 text-[12px] text-[var(--text-secondary)]`,children:n(`settings.privacy.noCustomRules`)}),e.customRules.map(t=>(0,K.jsxs)(w,{label:t.name,detail:t.pattern,children:[(0,K.jsx)(N,{checked:t.enabled,disabled:!e.enabled,label:t.name,onChange:e=>o(t,e)}),(0,K.jsx)(k,{size:`sm`,variant:`plain`,icon:(0,K.jsx)(ce,{className:`size-3.5`}),"aria-label":`${n(`common.delete`)} ${t.name}`,onClick:()=>void s(t)})]},t.id)),(0,K.jsx)(`div`,{className:`px-4 py-2`,children:(0,K.jsx)(k,{size:`sm`,icon:(0,K.jsx)(se,{className:`size-3.5`}),disabled:!e.enabled,onClick:()=>a(!0),children:n(`settings.privacy.addRule`)})}),(0,K.jsx)(ut,{open:i,onOpenChange:a,onAdd:n=>t({customRules:[...e.customRules,n]})})]})}function ut({open:e,onOpenChange:t,onAdd:n}){let{t:r}=E(),{toast:i}=I(),[a,o]=(0,W.useState)(``),[s,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(``);return(0,K.jsx)(ne,{open:e,onOpenChange:t,title:r(`settings.privacy.addRule`),width:480,footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(k,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,K.jsx)(k,{variant:`primary`,disabled:!a.trim()||!s.trim(),onClick:()=>{if(a.trim()&&s.trim()){try{new RegExp(s)}catch(e){i(`${r(`settings.privacy.invalidPattern`)}: ${F(e)}`,`error`);return}n({id:`custom-${Date.now().toString(36)}`,name:a.trim(),pattern:s.trim(),enabled:!0}),o(``),c(``),u(``),t(!1)}},children:r(`common.create`)})]}),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(C,{label:r(`settings.privacy.ruleTemplates`),hint:r(`settings.privacy.ruleTemplatesHint`),children:(0,K.jsx)(L,{ariaLabel:r(`settings.privacy.ruleTemplates`),value:l,onChange:e=>{u(e);let t=it.find(t=>t.id===e);t&&(o(r(t.nameKey)),c(t.pattern))},options:[{value:``,label:r(`settings.privacy.ruleTemplateNone`)},...it.map(e=>({value:e.id,label:r(e.nameKey)}))]})}),(0,K.jsx)(v,{label:r(`settings.privacy.ruleName`),value:a,onChange:e=>o(e.target.value),autoFocus:!0}),(0,K.jsx)(C,{label:r(`settings.privacy.rulePattern`),hint:r(`settings.privacy.rulePatternHint`),children:(0,K.jsx)(h,{mono:!0,rows:3,value:s,onChange:e=>c(e.target.value)})})]})})}function dt(){let{t:e}=E(),{toast:t}=I(),n=Ie(),r=o(),i=O(),[a,s]=(0,W.useState)(``),c=i.data,l=r.data?.settings.enabled??!1;return(0,K.jsx)(A,{title:e(`settings.privacy.tester`),footer:e(`settings.privacy.testerHint`),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,K.jsx)(h,{"aria-label":e(`settings.privacy.tester`),placeholder:e(`settings.privacy.testerPlaceholder`),rows:4,mono:!0,value:a,onChange:e=>s(e.target.value)}),(0,K.jsx)(`div`,{children:(0,K.jsx)(k,{icon:(0,K.jsx)(B,{className:`size-3.5`}),disabled:!l||!a.trim(),loading:i.isPending,onClick:()=>i.mutate({text:a},{onError:e=>t(F(e),`error`)}),children:e(`settings.privacy.runTest`)})}),c&&(0,K.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] px-3 py-2 text-[12px]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c.blocked&&(0,K.jsx)(T,{tone:`red`,children:e(`settings.privacy.wouldBlock`)}),c.wouldRedact>0&&(0,K.jsx)(T,{tone:`orange`,children:e(`settings.privacy.wouldRedact`,{count:c.wouldRedact})}),!c.blocked&&c.wouldRedact===0&&(0,K.jsx)(T,{tone:`green`,children:e(`settings.privacy.noHits`)})]}),c.hits.length>0&&(0,K.jsx)(`ul`,{className:`mt-2 space-y-1`,children:c.hits.map(t=>(0,K.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(T,{tone:t.action===`block`?`red`:t.action===`redact`?`orange`:`neutral`,children:e(ot[t.action])}),(0,K.jsxs)(`span`,{children:[n(t.category),` · `,t.ruleId,` × `,t.count]}),t.samples&&t.samples.length>0&&(0,K.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}=E(),t=Ie(),[n,r]=(0,W.useState)(`7d`),i=a(n),o=i.data,s=[{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}],c=(o?.categories??[]).map(e=>({...e}));return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`section`,{children:[(0,K.jsx)(y,{action:(0,K.jsx)(p,{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,K.jsx)(j,{lines:3,className:`py-4`}),i.isError&&(0,K.jsx)(ee,{tone:`danger`,title:e(`common.error`),children:F(i.error)}),o&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,K.jsx)(rt,{label:e(`privacy.stats.events`),value:o.events,context:e(`range.${n}`)}),(0,K.jsx)(rt,{label:e(`privacy.stats.blocked`),value:o.blocked,context:e(`range.${n}`)}),(0,K.jsx)(rt,{label:e(`privacy.stats.redactions`),value:o.redactions,context:e(`range.${n}`)}),(0,K.jsx)(rt,{label:e(`privacy.stats.dryRun`),value:o.dryRun,context:e(`range.${n}`)})]})]}),(0,K.jsxs)(`section`,{children:[(0,K.jsx)(y,{children:e(`privacy.stats.byCategory`)}),o&&o.categories.length===0&&(0,K.jsx)(`div`,{className:`card`,children:(0,K.jsx)(mt,{})}),o&&o.categories.length>0&&(0,K.jsx)(z,{caption:e(`privacy.stats.byCategory`),rows:c,columns:s,rowKey:`category`,defaultSort:{key:`hits`,direction:`desc`}})]}),(0,K.jsx)(`div`,{className:`mx-auto w-full max-w-[720px]`,children:(0,K.jsx)(st,{})})]})}function mt(){let{t:e}=E();return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-center`,children:[(0,K.jsx)(B,{className:`size-6 text-[var(--text-muted)]`}),(0,K.jsx)(`div`,{className:`text-[13px]`,children:e(`privacy.logs.empty`)}),(0,K.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}=E(),{tab:t}=de(),n=V(),r=ht.includes(t)?t:`overview`;return(0,K.jsx)(me,{title:e(`nav.privacy`),subtitle:e(`settings.privacy.footer`),children:(0,K.jsxs)(R,{value:r,onValueChange:e=>n(`/privacy/${e}`,{replace:!0}),children:[(0,K.jsx)(le,{"aria-label":e(`nav.privacy`),children:ht.map(t=>(0,K.jsx)(ae,{value:t,children:e(`privacy.tab.${t}`)},t))}),(0,K.jsx)(U,{value:`overview`,className:`pt-5`,children:(0,K.jsx)(pt,{})}),(0,K.jsx)(U,{value:`logs`,className:`pt-4`,children:(0,K.jsx)(Be,{})}),(0,K.jsx)(U,{value:`rules`,className:`pt-5`,children:(0,K.jsx)(ct,{})}),(0,K.jsx)(U,{value:`tester`,className:`pt-5 [&>div]:mx-auto [&>div]:max-w-[680px]`,children:(0,K.jsx)(dt,{})})]})})}export{gt as PrivacyPage};
@@ -1,3 +0,0 @@
1
- import{$r as e,An as t,B as n,Bn as r,Cn as i,Ct as a,Et as o,Fr as s,Gn as c,Gt as l,Hn as u,In as d,Kt as f,Mn as p,Mr as m,Nt as h,On as g,Or as _,Qn as v,Rn as ee,Sa as y,Sn as te,St as ne,Tt as re,V as b,Xn as ie,Zn as ae,_ as x,_a as oe,a as S,b as se,c as C,cn as ce,ct as le,d as w,ei as ue,f as T,fi as E,fr as de,ft as fe,gn as pe,h as me,hn as he,i as ge,ii as _e,ir as D,it as O,jn as ve,jr as ye,kr as be,kt as xe,l as k,m as A,mn as Se,n as j,nn as Ce,nt as we,ot as M,p as Te,pt as Ee,r as N,rn as De,rr as Oe,sr as ke,t as P,ti as F,tn as Ae,tt as I,u as L,un as je,v as R,va as Me,vt as z,wr as Ne,xt as Pe,y as B,ya as Fe,zn as Ie}from"./alert-CGUFPyGb.js";import{a as V,i as H,n as Le,o as U,r as W}from"./overlays-B1a0OZYb.js";import{a as Re,i as G,n as K,o as q,t as ze}from"./ProvidersPage-DclHIvR2.js";import{t as Be}from"./arrow-down-7oFM4dM3.js";import{t as Ve}from"./arrow-left-Dn6_YDkh.js";import{t as He}from"./cloud-download-Bvry8vmS.js";import{t as Ue}from"./download-5xAFYJ6Q.js";import{t as We}from"./ellipsis-Dxds5r72.js";import{t as Ge}from"./external-link-Bq_1v6I1.js";import{n as Ke}from"./radio-cards-Cr0tP9In.js";import{t as qe}from"./log-out-B9HHsF8m.js";import{t as Je}from"./power-DrpargJA.js";import{t as Ye}from"./rotate-ccw-D6r7Boub.js";import{C as Xe,E as Ze,G as Qe,L as J,M as Y,T as X,W as $e,X as et,Z as tt,_ as Z,a as nt,h as rt,o as it,s as at,w as ot,z as st}from"./index-mlmGhWY4.js";import{t as ct}from"./checkbox-DzIMWhhw.js";import{t as lt}from"./confirm-morph-DnwMPT3r.js";var ut={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`}]]};ut.node;var dt=z(ut),ft={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`}]]};ft.node;var pt=z(ft),mt={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`}]]};mt.node;var ht=z(mt),gt={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`}]]};gt.node;var _t=z(gt),vt={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`}]]};vt.node;var yt=z(vt),bt={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`]};bt.node;var xt=z(bt),St={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`}]]};St.node;var Ct=z(St),Q=y(Fe(),1),$=Me(),wt={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`},Tt={imported:`green`,updated:`accent`,ready:`accent`,duplicate:`neutral`,invalid_format:`orange`,failed:`red`},Et={batch:`providers.accounts.import.batchTitle`,token:`providers.accounts.import.tokenTitle`,apiKey:`providers.accounts.import.apiKeyTitle`};function Dt(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 Ot(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:Dt(e))}return n}function kt({providerId:e,info:t,mode:n,providerProxy:r,onClose:i}){let{t:a}=M(),{toast:o}=U(),s=Se(e),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(null),m=(0,Q.useMemo)(()=>Ot(c),[c]);if((0,Q.useEffect)(()=>{n!==null&&(l(``),p(null))},[n]),n===null)return(0,$.jsx)(H,{open:!1,onOpenChange:i,title:``});let h=n===`apiKey`,g=h?t.formats.filter(e=>e.endsWith(`-api-key`)):t.formats,_=!h&&t.formats.some(e=>e.includes(`refresh-token`)||e.endsWith(`-json`)),v=a(h?`providers.accounts.import.apiKeyLabel`:`providers.accounts.import.label`),ee=e=>s.mutate({text:c,asApiKey:h||void 0,dryRun:e||void 0,httpProxy:u.trim()||void 0},{onSuccess:t=>{p({...t,dryRun:e}),!e&&(o(a(`providers.accounts.import.summary`,{ok:t.imported,dup:t.duplicates,fail:t.failed}),t.failed>0?`info`:`success`),!(t.failed>0)&&(n===`batch`?l(``):i()))},onError:e=>o(V(e),`error`)});return(0,$.jsx)(H,{open:!0,onOpenChange:e=>!e&&i(),title:a(Et[n]),description:a(`providers.accounts.import.desc`),width:560,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[g.length>0&&(0,$.jsx)(`p`,{className:`text-[11.5px] text-[var(--text-secondary)]`,children:a(`providers.accounts.import.formats`,{formats:g.map(e=>a(`providers.accounts.format.${e}`)).join(` · `)})}),(0,$.jsx)(se,{mono:!0,rows:n===`batch`?8:3,value:c,onChange:e=>l(e.target.value),"aria-label":v,placeholder:v,spellCheck:!1}),(0,$.jsx)(w,{mono:!0,label:a(`providers.accounts.import.proxy`),placeholder:r||a(`providers.accounts.proxyFallbackSystem`),value:u,onChange:e=>d(e.target.value)}),_&&(0,$.jsx)(P,{tone:`info`,title:a(`providers.accounts.import.rotateWarning`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:a(`providers.accounts.import.count`,{n:m})}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[n===`batch`&&(0,$.jsx)(N,{disabled:m===0,loading:s.isPending&&s.variables?.dryRun===!0,onClick:()=>ee(!0),children:a(`providers.accounts.import.preview`)}),(0,$.jsx)(N,{variant:`primary`,disabled:m===0||m>t.maxBatch,loading:s.isPending&&!s.variables?.dryRun,onClick:()=>ee(!1),children:a(`providers.accounts.import.run`)})]})]}),f&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`div`,{className:`text-[12px] font-medium`,children:a(f.dryRun?`providers.accounts.import.previewSummary`:`providers.accounts.import.summary`,{ok:f.imported,dup:f.duplicates,fail:f.failed})}),(0,$.jsx)(`ul`,{className:`card max-h-72 divide-y divide-[var(--border)] overflow-auto`,children:f.items.map(e=>(0,$.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-1.5 text-[12px]`,children:[(0,$.jsx)(`span`,{className:`w-6 shrink-0 text-[var(--text-muted)]`,children:e.index}),(0,$.jsx)(`span`,{className:`selectable w-28 shrink-0 truncate font-mono`,children:e.source}),(0,$.jsx)(j,{tone:Tt[e.status],children:a(wt[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 At(e,t=Date.now()){return e.enabled?e.status===`active`?e.cooldownUntilUtc&&new Date(e.cooldownUntilUtc).getTime()>t?`cooling`:`usable`:`dead`:`disabled`}var jt={usable:`var(--success)`,cooling:`var(--warning)`,dead:`var(--danger)`,disabled:`var(--text-muted)`},Mt={active:`providers.subscription.status.active`,expired:`providers.subscription.status.expired`,revoked:`providers.subscription.status.revoked`};function Nt(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 Pt({account:e,index:t,actions:n,selected:r,selecting:i,onToggleSelect:a,onMove:o,quotaPending:s}){let{t:c,locale:l}=M(),u=At(e),d=e.displayName||e.accountEmail||e.keyMasked||e.id,f=e.kind===`api_key`,p=e.plan?.trim(),m=u===`cooling`?{text:c(`providers.subscription.cooldown`,{when:b(e.cooldownUntilUtc,l)}),tone:`var(--warning)`}:u===`dead`?{text:e.lastError||c(Mt[e.status]),tone:`var(--danger)`}:f?{text:e.keyMasked??c(`providers.accounts.neverExpires`),tone:void 0}:e.expiresAtUtc?{text:c(`providers.accounts.expiresAt`,{when:b(e.expiresAtUtc,l)}),tone:void 0}:null,h=[{id:`activate`,label:c(`providers.subscription.activate`),icon:(0,$.jsx)(dt,{className:`size-3.5`}),disabled:e.isCurrent||u===`dead`,onSelect:()=>n.activate(e)},{id:`toggle`,label:c(e.enabled?`providers.subscription.disable`:`providers.subscription.enable`),icon:(0,$.jsx)(Je,{className:`size-3.5`}),onSelect:()=>n.toggleEnabled(e)},...o?[{id:`up`,label:c(`providers.subscription.moveUp`),icon:(0,$.jsx)($e,{className:`size-3.5`}),disabled:!o.up,onSelect:()=>o.up?.()},{id:`down`,label:c(`providers.subscription.moveDown`),icon:(0,$.jsx)(Be,{className:`size-3.5`}),disabled:!o.down,onSelect:()=>o.down?.()}]:[],{id:`quota`,separatorBefore:!0,label:c(`providers.subscription.quotaRefresh`),icon:(0,$.jsx)(q,{className:`size-3.5`}),disabled:u===`dead`,onSelect:()=>n.refreshQuota(e)},...f?[]:[{id:`refresh`,label:c(`providers.subscription.refreshToken`),icon:(0,$.jsx)(Ye,{className:`size-3.5`}),disabled:e.status===`revoked`,onSelect:()=>n.refreshToken(e)},{id:`relogin`,label:c(`providers.subscription.relogin`),disabled:e.status===`active`,onSelect:()=>n.relogin(e)}],{id:`remove`,label:c(`providers.subscription.logout`),icon:(0,$.jsx)(Y,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>n.remove(e)}],g=c(u===`disabled`?`providers.subscription.disabled`:Mt[e.status]),_=c(f?`providers.accounts.kind.api_key`:`providers.accounts.kind.oauth`),v=e.quota?.session?.usedPercent!=null||e.quota?.weekly?.usedPercent!=null||e.quota?.credits?.usedPercent!=null;return(0,$.jsxs)(`div`,{"data-testid":`account-card`,className:O(`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)]`,u===`disabled`&&`opacity-55`),onClick:()=>i?a(e.id):n.open(e),children:[(0,$.jsxs)(`div`,{className:`relative shrink-0 px-3 pb-3 pt-2.5`,style:{background:Nt(p,f)},children:[(u===`cooling`||u===`dead`)&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-y-0 left-0 w-[3px]`,style:{background:jt[u]}}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:O(`flex size-5 items-center justify-center`,!i&&!r&&`hidden group-hover:flex`),onClick:e=>e.stopPropagation(),children:(0,$.jsx)(ct,{checked:r,onCheckedChange:()=>a(e.id),"aria-label":c(`providers.accounts.select`,{name:d})})}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(`span`,{role:`img`,"aria-label":g,className:`size-1.5 shrink-0 rounded-full`,style:{background:jt[u]}}),(0,$.jsx)(`span`,{"aria-hidden":!0,children:g})]}),e.httpProxy&&(0,$.jsx)(`span`,{title:`${c(`providers.accounts.proxyBadge`)}: ${e.httpProxy}`,className:`shrink-0 text-[var(--text-muted)]`,children:(0,$.jsx)(fe,{className:`size-3.5`,"aria-label":c(`providers.accounts.proxyBadge`)})}),(0,$.jsx)(`span`,{className:`-mr-1.5 ml-auto shrink-0`,onClick:e=>e.stopPropagation(),children:(0,$.jsx)(Le,{iconOnly:!0,label:c(`common.more`),icon:(0,$.jsx)(We,{className:`size-4`}),items:h})})]}),(0,$.jsx)(`div`,{className:`mt-1.5 truncate text-[17px] font-bold tracking-[.01em]`,title:p||_,children:p||_})]}),(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:d,onClick:t=>{t.stopPropagation(),i?a(e.id):n.open(e)},children:d}),(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:c(`providers.subscription.current`)})]}),e.isCurrent&&(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0`,children:_}),e.source&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{className:`truncate`,children:c(`providers.accounts.source.${e.source}`)})]}),(0,$.jsx)(`span`,{className:`ml-auto shrink-0 pl-1 opacity-0 group-hover:opacity-100`,children:c(`providers.accounts.order`,{n:t+1})})]}),m&&(u===`cooling`||u===`dead`||!v)&&(0,$.jsx)(`div`,{className:`mt-1.5 line-clamp-2 text-[11px] leading-snug`,style:{color:m.tone??`var(--text-muted)`},title:m.text,children:m.text}),u===`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:c(`providers.accounts.signedOut`)}),!f&&(0,$.jsx)(N,{size:`sm`,className:`ml-auto`,onClick:t=>{t.stopPropagation(),n.relogin(e)},children:c(`providers.subscription.relogin`)})]}):(0,$.jsx)(It,{quota:e.quota??null,pending:s})]})]})}var Ft=10;function It({quota:e,pending:t}){let{t:n,locale:r}=M(),i=[];return e?.session?.usedPercent!=null&&i.push({key:`session`,label:e.session.windowMinutes?`${Math.round(e.session.windowMinutes/60)}h`:n(`providers.accounts.quotaShortSession`),percent:e.session.usedPercent,reset:e.session.resetsAtUtc}),e?.weekly?.usedPercent!=null&&i.push({key:`weekly`,label:n(`providers.accounts.quotaShortWeekly`),percent:e.weekly.usedPercent,reset:e.weekly.resetsAtUtc}),i.length<2&&e?.credits?.usedPercent!=null&&i.push({key:`credits`,label:n(e.entitlement==null?`providers.accounts.quotaShortCredits`:`providers.accounts.quotaShortPremium`),percent:e.credits.usedPercent,reset:e.credits.resetsAtUtc}),i.length===0?null:(0,$.jsx)(`div`,{className:O(`mt-auto flex flex-col gap-2 pt-2`,t&&`opacity-60`),children:i.slice(0,2).map(e=>{let t=Math.max(0,Math.min(100,Math.round(e.percent))),i=t>=90?`var(--danger)`:t>=70?`var(--warning)`:`var(--accent)`,a=Math.round(t/100*Ft),o=e.reset?n(`providers.subscription.quotaResets`,{when:b(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:Ft},(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 Lt({quota:e,className:t}){let{t:n,locale:r}=M(),i=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:n(`providers.subscription.quotaResets`,{when:t.toLocaleString(r)})},a=[];e.session?.usedPercent!=null&&a.push({key:`session`,label:n(`providers.subscription.quotaWindowSession`),window:e.session}),e.weekly?.usedPercent!=null&&a.push({key:`weekly`,label:n(`providers.subscription.quotaWindowWeekly`),window:e.weekly}),e.credits?.usedPercent!=null&&a.push({key:`credits`,label:e.entitlement==null?n(`providers.subscription.quotaWindowCredits`):n(`providers.subscription.quotaWindowPremium`),window:{usedPercent:e.credits.usedPercent,resetsAtUtc:e.credits.resetsAtUtc??null}});let o=e.credits?.prepaidBalance==null?null:n(`providers.subscription.quotaBalance`,{balance:e.credits.prepaidBalance}),s=e.entitlement!=null&&e.entitlement>=0?[n(`providers.subscription.quotaPremiumCount`,{used:Math.max(0,(e.entitlement??0)-(e.remaining??0)),total:e.entitlement}),e.overageUsed?n(`providers.subscription.quotaOverage`,{count:e.overageUsed}):null,e.overagePermitted===!1?n(`providers.subscription.quotaOverageOff`):null].filter(Boolean).join(` · `):null,c=e.planLabel??(e.fetchedAtUtc?n(`providers.subscription.quotaFetchedAt`,{when:new Date(e.fetchedAtUtc).toLocaleString(r)}):null);return(0,$.jsx)(`div`,{className:O(`px-4 py-1`,t),children:(0,$.jsxs)(`div`,{className:`card flex flex-col gap-3 p-3`,children:[(c||o)&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-[11px] text-[var(--text-secondary)]`,children:[c&&(0,$.jsx)(`span`,{children:c}),o&&(0,$.jsx)(`span`,{children:o})]}),a.length===0?(0,$.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`providers.subscription.quotaNoWindows`)}):a.map(e=>(0,$.jsx)(Rt,{label:e.label,window:e.window,reset:i(e.window.resetsAtUtc)},e.key)),s&&(0,$.jsx)(`div`,{className:`text-[10.5px] text-[var(--text-muted)]`,children:s})]})})}function Rt({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 zt={available:`green`,redeemed:`neutral`,expired:`orange`};function Bt({account:e,providerId:t}){let{t:n}=M(),{toast:r,confirm:i}=U(),a=de(e.id,e.status===`active`),o=f(t),s=a.data?.credits??[],c=a.data?.available_count??s.filter(e=>e.status===`available`).length,l=async t=>{await i({title:n(`providers.subscription.credits.consumeConfirm`,{title:t.title??t.reset_type??``}),detail:n(`providers.subscription.credits.consumeDetail`),confirmLabel:n(`providers.subscription.credits.consume`),destructive:!0})&&o.mutate({accountId:e.id,creditId:t.id},{onSuccess:()=>r(n(`providers.subscription.credits.consumed`),`success`),onError:e=>r(e instanceof E&&e.status===409?V(e):`${n(`providers.subscription.credits.consumeFailed`)}:${V(e)}`,`error`)})};return(0,$.jsxs)(L,{title:n(`providers.subscription.credits.title`),footer:n(`providers.subscription.credits.footer`),children:[a.isLoading&&(0,$.jsx)(R,{className:`my-4`}),a.isError&&(0,$.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--text-secondary)]`,children:n(`providers.subscription.credits.unavailable`)}),a.data&&s.length===0&&(0,$.jsx)(`div`,{className:`px-4 py-5 text-center text-[12px] text-[var(--text-secondary)]`,children:n(`providers.subscription.credits.none`)}),s.map(e=>{let t=e.status!==`available`;return(0,$.jsxs)(A,{className:O(t&&`opacity-55`),label:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(pt,{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)(j,{tone:zt[e.status]??`neutral`,children:n(`providers.subscription.credits.status.${e.status}`)}),(0,$.jsx)(N,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(Ct,{className:`size-3.5`}),disabled:t,loading:o.isPending&&o.variables?.creditId===e.id,onClick:()=>void l(e),children:n(`providers.subscription.credits.consume`)})]},e.id)}),a.data&&s.length>0&&(0,$.jsx)(`div`,{className:`px-4 py-2 text-[11px] text-[var(--text-muted)]`,children:n(`providers.subscription.credits.availableCount`,{count:c})})]})}var Vt={active:`providers.subscription.status.active`,expired:`providers.subscription.status.expired`,revoked:`providers.subscription.status.revoked`};function Ht({provider:e,account:t,index:n,actions:r,onClose:i}){let{t:a,locale:o}=M(),{toast:s}=U(),c=ue(e.id),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``);if((0,Q.useEffect)(()=>{u(t?.displayName??``),f(t?.httpProxy??``)},[t?.id,t?.displayName,t?.httpProxy]),!t)return(0,$.jsx)(H,{open:!1,onOpenChange:i,title:``});let p=At(t),m=t.kind===`api_key`,h=e.templateId===`openai-subscription`,g=e.httpProxy||a(`providers.accounts.proxyFallbackSystem`),_=e=>e?b(e,o):`—`,v=(e,n)=>c.mutate({id:t.id,...e},{onSuccess:()=>s(a(n),`success`),onError:e=>s(V(e),`error`)});return(0,$.jsx)(H,{open:!0,onOpenChange:e=>!e&&i(),title:t.displayName||t.keyMasked||t.id,description:[t.plan,a(m?`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)(N,{size:`sm`,icon:(0,$.jsx)(dt,{className:`size-3.5`}),disabled:t.isCurrent||p===`dead`,onClick:()=>r.activate(t),children:a(`providers.subscription.activate`)}),(0,$.jsx)(N,{size:`sm`,icon:(0,$.jsx)(q,{className:`size-3.5`}),disabled:p===`dead`,onClick:()=>r.refreshQuota(t),children:a(`providers.subscription.quotaRefresh`)}),!m&&(0,$.jsx)(N,{size:`sm`,icon:(0,$.jsx)(Ye,{className:`size-3.5`}),disabled:t.status===`revoked`,onClick:()=>r.refreshToken(t),children:a(`providers.subscription.refreshToken`)}),!m&&t.status!==`active`&&(0,$.jsx)(N,{size:`sm`,variant:`primary`,onClick:()=>r.relogin(t),children:a(`providers.subscription.relogin`)}),(0,$.jsx)(N,{size:`sm`,variant:`plain`,className:`ml-auto text-[var(--danger)]`,icon:(0,$.jsx)(Y,{className:`size-3.5`}),onClick:()=>r.remove(t),children:a(`providers.subscription.logout`)})]}),p===`dead`&&t.lastError&&(0,$.jsx)(P,{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)(w,{className:`flex-1`,label:a(`providers.accounts.detail.name`),value:l,onChange:e=>u(e.target.value)}),(0,$.jsx)(N,{disabled:l.trim().length===0||l.trim()===t.displayName,loading:c.isPending&&c.variables?.displayName!==void 0,onClick:()=>v({displayName:l.trim()},`providers.accounts.renamed`),children:a(`common.save`)})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,$.jsx)(w,{className:`flex-1`,mono:!0,label:a(`providers.accounts.detail.proxy`),placeholder:g,value:d,onChange:e=>f(e.target.value)}),(0,$.jsx)(N,{disabled:d.trim()===(t.httpProxy??``),loading:c.isPending&&c.variables?.httpProxy!==void 0,onClick:()=>v({httpProxy:d.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:g})})]}),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)(Lt,{quota:t.quota})]}),h&&p!==`dead`&&(0,$.jsx)(`div`,{className:`-mx-4`,children:(0,$.jsx)(Bt,{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)(T,{label:a(`providers.accounts.detail.status`),children:(0,$.jsx)(j,{tone:p===`usable`?`green`:p===`cooling`?`orange`:p===`dead`?`red`:`neutral`,children:a(p===`disabled`?`providers.subscription.disabled`:Vt[t.status])})}),t.source&&(0,$.jsx)(T,{label:a(`providers.accounts.detail.source`),children:a(`providers.accounts.source.${t.source}`)}),m?(0,$.jsx)(T,{label:a(`providers.accounts.detail.key`),mono:!0,children:t.keyMasked??`••••`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{label:a(`providers.accounts.detail.expires`),children:_(t.expiresAtUtc)}),(0,$.jsx)(T,{label:a(`providers.accounts.detail.lastRefresh`),children:_(t.lastRefreshAtUtc)})]}),p===`cooling`&&(0,$.jsx)(T,{label:a(`providers.accounts.filter.cooling`),children:_(t.cooldownUntilUtc)}),(0,$.jsx)(T,{label:a(`providers.accounts.detail.order`),children:a(`providers.accounts.order`,{n:n+1})}),(0,$.jsx)(T,{label:a(`providers.accounts.detail.created`),children:_(t.createdAt)}),t.lastError&&p!==`dead`&&(0,$.jsx)(T,{label:a(`providers.accounts.detail.lastError`),children:t.lastError})]})]})]})})}function Ut({provider:e}){let{t}=M(),{toast:n}=U(),r=e.authScheme===`oauth-subscription`,i=m(e.id,r),a=_e(e.id);if(!r||!i.data)return null;let o=i.data,s=e=>a.mutate(e,{onError:e=>n(V(e),`error`)}),c=o.claudeSubscription||o.clientPolicy===`claude-code-only`;return!c&&!o.claudeSubscription?null:(0,$.jsxs)(L,{title:t(`providers.subscription.policy.title`),footer:t(`providers.subscription.policy.footer`),children:[c&&(0,$.jsx)(A,{label:t(`providers.subscription.policy.claudeCodeOnly`),detail:t(`providers.subscription.policy.claudeCodeOnlyDetail`),children:(0,$.jsx)(B,{label:t(`providers.subscription.policy.claudeCodeOnly`),checked:o.clientPolicy===`claude-code-only`,disabled:a.isPending,onChange:e=>s({clientPolicy:e?`claude-code-only`:`any`})})}),o.claudeSubscription&&(0,$.jsx)(A,{label:t(`providers.subscription.policy.mimic`),detail:t(`providers.subscription.policy.mimicDetail`),children:(0,$.jsx)(B,{label:t(`providers.subscription.policy.mimic`),checked:o.mimicClaudeCode,disabled:a.isPending,onChange:e=>s({mimicClaudeCode:e})})}),c&&o.clientPolicy===`any`&&(0,$.jsx)(`div`,{className:`px-4 py-3`,children:o.mimicClaudeCode?(0,$.jsx)(P,{tone:`warning`,title:t(`providers.subscription.policy.mimicWarning`)}):(0,$.jsx)(P,{tone:`warning`,title:t(`providers.subscription.policy.anyWarning`)})})]})}var Wt=[{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`}],Gt=3e5;function Kt({provider:e}){let{t}=M(),{toast:n,confirm:r}=U(),a=oe(),s=e.authScheme===`oauth-subscription`,c=ae(e.id,s),d=m(e.id,s),f=_e(e.id),p=re(e.id,s),h=be(e.id),g=u(e.id),_=l(e.id),v=je(e.id),ee=Oe(e.id),y=Ce(e.id),ne=o(e.id),b=ue(e.id),ie=ke(e.id),x=e.templateId===`openai-subscription`,S=te(s&&x),se=he(e.id),C=e.templateId===`github-copilot-subscription`,ce=i(s&&C),le=pe(e.id),[T,de]=(0,Q.useState)(`all`),[fe,ge]=(0,Q.useState)(``),[D,ve]=(0,Q.useState)(new Set),[ye,xe]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),[Se,j]=(0,Q.useState)(!1),[we,Te]=(0,Q.useState)(``),[Ee,De]=(0,Q.useState)(!1),[F,Ae]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(null),[Me,z]=(0,Q.useState)(null),[Ne,B]=(0,Q.useState)(!1),[Fe,Ie]=(0,Q.useState)(``),W=(0,Q.useRef)(new Set),Re=(0,Q.useRef)(new Set),G=(0,Q.useMemo)(()=>c.data??[],[c.data]);if((0,Q.useEffect)(()=>{if(s)for(let e of G){if(e.status!==`active`||Re.current.has(e.id))continue;let t=e.quota?.fetchedAtUtc?new Date(e.quota.fetchedAtUtc).getTime():0;Number.isFinite(t)&&Date.now()-t<Gt||(Re.current.add(e.id),v.mutate(e.id,{onError:()=>{}}))}},[G,s]),(0,Q.useEffect)(()=>{let e=new Set(G.map(e=>e.id));ve(t=>Array.from(t).every(t=>e.has(t))?t:new Set(Array.from(t).filter(t=>e.has(t)))),ye&&!e.has(ye)&&xe(null)},[G,ye]),(0,Q.useEffect)(()=>{if(!F||I?.mode!==`pkce`)return;let e=setInterval(()=>void c.refetch(),3e3);return()=>clearInterval(e)},[F,I,c]),(0,Q.useEffect)(()=>{if(!F||I?.mode!==`pkce`)return;let e=G.find(e=>!W.current.has(e.id));e&&q(!0,e.displayName||e.accountEmail||e.id)},[G,F,I]),(0,Q.useEffect)(()=>{if(!F||I?.mode!==`device`&&I?.mode!==`cli`)return;let e=!1,t=0,n=async()=>{try{let n=await g.mutateAsync(I.state);if(e)return;t=0,n.status===`done`?q(!0,n.account.displayName||n.account.accountEmail||n.account.id):n.status!==`pending`&&n.status!==`slow_down`&&q(!1,void 0,`error`in n?n.error??n.status:n.status)}catch(n){if(e)return;if(n instanceof E&&(n.status===404||n.status===400)){q(!1,void 0,V(n));return}++t>=5&&q(!1,void 0,V(n))}},r=setInterval(()=>void n(),Math.max(I.interval||5,3)*1e3);return()=>{e=!0,clearInterval(r)}},[F,I]),!s)return null;let K=e=>e.displayName||e.accountEmail||e.keyMasked||e.id,q=(r,i,o)=>{if(a.invalidateQueries({queryKey:Pe.providerAccounts(e.id)}),r){L(null),z(null),Ae(!1),n(t(`providers.subscription.loginOk`,{name:i??``}),`success`);return}o&&z(o)},ze=(e,r)=>{W.current=new Set(G.map(e=>e.id)),z(null),h.mutate({accountId:e,httpProxy:r},{onSuccess:e=>{j(!1),L(e),Ae(!0),e.mode!==`device`&&window.open(e.authorizeUrl,`_blank`,`noopener`)},onError:e=>{e instanceof E&&e.details?.needsVerification?n(t(`providers.subscription.needsVerification`),`error`):n(V(e),`error`)}})},Be=async()=>{if(I){B(!0);try{let e=await g.mutateAsync(I.state);e.status===`done`?q(!0,e.account.displayName||e.account.accountEmail||e.account.id):e.status===`pending`||e.status===`slow_down`?n(t(`providers.subscription.stillWaiting`),`info`):q(!1,void 0,`error`in e?e.error??e.status:e.status)}catch(e){if(e instanceof E&&e.status===404){let t=((await c.refetch()).data??[]).find(e=>!W.current.has(e.id));t?q(!0,t.displayName||t.accountEmail||t.id):q(!1,void 0,V(e))}else q(!1,void 0,V(e))}finally{B(!1)}}},Ve=async()=>{if(I&&I.mode===`paste`&&Fe.trim().length!==0){B(!0);try{let e=await _.mutateAsync({state:I.state,code:Fe.trim()});e.status===`done`?(Ie(``),q(!0,e.account.displayName||e.account.accountEmail||e.account.id)):q(!1,void 0,`error`in e?e.error??e.status:e.status)}catch(e){q(!1,void 0,V(e))}finally{B(!1)}}},He=()=>se.mutate(void 0,{onSuccess:e=>{n(t(`providers.subscription.importOk`,{name:K(e.account)}),e.warning?`info`:`success`),e.warning&&n(e.warning,`error`),S.refetch()},onError:e=>n(V(e),`error`)}),We=()=>le.mutate(``,{onSuccess:e=>{n(t(`providers.subscription.importOk`,{name:K(e.account)}),e.warning?`info`:`success`),e.warning&&n(e.warning,`error`)},onError:e=>n(V(e),`error`)}),Ge=(e,t)=>{let r=G.map(e=>e.id),i=e+t;i<0||i>=r.length||([r[e],r[i]]=[r[i],r[e]],ie.mutate(r,{onError:e=>n(V(e),`error`)}))},Ke=async e=>{let i=K(e);await r({title:t(`providers.subscription.logoutConfirm`,{name:i}),destructive:!0,confirmLabel:t(`providers.subscription.logout`)})&&y.mutate(e.id,{onError:e=>n(V(e),`error`)})},qe={open:e=>xe(e.id),activate:e=>ne.mutate(e.id,{onSuccess:()=>n(t(`providers.subscription.activated`,{name:K(e)}),`success`),onError:e=>n(V(e),`error`)}),toggleEnabled:e=>b.mutate({id:e.id,enabled:!e.enabled},{onError:e=>n(V(e),`error`)}),refreshQuota:e=>v.mutate(e.id,{onError:e=>{e instanceof E&&e.status===501?n(t(`providers.subscription.quotaUnsupported`),`error`):n(V(e),`error`)}}),refreshToken:e=>ee.mutate(e.id,{onSuccess:()=>n(t(`providers.subscription.tokenRefreshed`),`success`),onError:e=>n(V(e),`error`)}),relogin:e=>ze(e.id),remove:e=>void Ke(e)},Ye=e=>ve(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Xe=async r=>{let i=G.filter(e=>D.has(e.id));De(!0);let o=0;for(let e of i)try{await r(e),o++}catch(t){n(`${K(e)}: ${V(t)}`,`error`)}De(!1),ve(new Set),a.invalidateQueries({queryKey:Pe.providerAccounts(e.id)}),o>0&&n(t(`providers.accounts.bulkDone`,{n:o}),`success`)},Ze=async()=>{await r({title:t(`providers.accounts.bulkDeleteConfirm`,{n:D.size}),detail:t(`providers.accounts.bulkDeleteDetail`),destructive:!0,confirmLabel:t(`common.delete`)})&&await Xe(e=>y.mutateAsync(e.id))},Qe=G.map(e=>At(e)),X=e=>e===`all`?G.length:Qe.filter(t=>t===e).length,$e=fe.trim().toLowerCase(),et=G.map((e,t)=>({a:e,index:t,state:Qe[t]})).filter(({a:e,state:t})=>(T===`all`||t===T)&&($e.length===0||[e.displayName,e.accountEmail,e.keyMasked,e.plan].some(e=>e?.toLowerCase().includes($e)))),tt=G.find(e=>e.id===ye)??null,Z=p.data,nt=D.size>0,rt=[{id:`login`,label:t(`providers.accounts.addLogin`),icon:(0,$.jsx)(_t,{className:`size-3.5`}),onSelect:()=>ze()},{id:`login-proxy`,label:t(`providers.accounts.addLoginProxy`),onSelect:()=>j(!0)},...x&&S.data?.available?[{id:`codex`,separatorBefore:!0,label:t(`providers.subscription.importCodex`),icon:(0,$.jsx)(Ue,{className:`size-3.5`}),onSelect:He}]:[],...C?[{id:`copilot`,separatorBefore:!0,label:t(`providers.subscription.importCopilot`),icon:(0,$.jsx)(Ue,{className:`size-3.5`}),onSelect:We}]:[],...Z?.supported?[{id:`token`,separatorBefore:!(x&&S.data?.available)&&!C,label:t(`providers.accounts.addToken`),onSelect:()=>A(`token`)}]:[],...Z?.apiKey?[{id:`apikey`,label:t(`providers.accounts.addApiKey`),icon:(0,$.jsx)(st,{className:`size-3.5`}),onSelect:()=>A(`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:G.length})}),(0,$.jsx)(`span`,{style:{color:`var(--success)`},children:t(`providers.accounts.statUsable`,{n:X(`usable`)})}),X(`cooling`)>0&&(0,$.jsx)(`span`,{style:{color:`var(--warning)`},children:t(`providers.accounts.statCooling`,{n:X(`cooling`)})}),X(`dead`)>0&&(0,$.jsx)(`span`,{style:{color:`var(--danger)`},children:t(`providers.accounts.statDead`,{n:X(`dead`)})}),(0,$.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`providers.accounts.providerProxy`,{proxy:e.httpProxy||t(`providers.accounts.proxyFallbackSystem`)})})]}),d.data&&(0,$.jsx)(qt,{policy:d.data,onChange:e=>f.mutate({switchMode:e},{onError:e=>n(V(e),`error`)})})]}),d.data&&(0,$.jsx)(`p`,{className:`-mt-1 mb-3 px-1 text-[11px] text-[var(--text-muted)]`,children:t(d.data.switchMode===`balanced`?`providers.subscription.policy.balancedDetail`:d.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)(me,{className:`w-52`,value:fe,onChange:ge,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:Wt.filter(e=>e.value===`all`||X(e.value)>0).map(e=>(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":T===e.value,onClick:()=>de(e.value),className:O(`rounded-full px-2.5 py-0.5 text-[11.5px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--fill)]`,T===e.value&&`bg-[var(--fill)] text-[var(--text)]`),children:[t(e.label),(0,$.jsx)(`span`,{className:`ml-1 text-[var(--text-muted)]`,children:X(e.value)})]},e.value))}),Z?.supported&&(0,$.jsx)(N,{size:`sm`,icon:(0,$.jsx)(ht,{className:`size-3.5`}),onClick:()=>A(`batch`),children:t(`providers.accounts.batchImport`)}),(0,$.jsx)(Le,{label:t(`providers.accounts.add`),icon:(0,$.jsx)(J,{className:`size-3.5`}),items:rt})]}),x&&S.data?.available&&(0,$.jsxs)(`p`,{className:`mb-2 px-1 text-[11px] text-[var(--text-muted)]`,children:[t(`providers.subscription.localCodexFound`,{who:S.data.accountEmail??S.data.plan??t(`providers.subscription.unknownAccount`)}),S.data.detail?` · ${S.data.detail}`:``]}),C&&(0,$.jsxs)(`p`,{className:`mb-2 px-1 text-[11px] text-[var(--text-muted)]`,children:[ce.data?.available?t(`providers.subscription.localCopilotFound`,{source:ce.data.source??``}):t(`providers.subscription.localCopilotHint`),ce.data?.detail?` · ${ce.data.detail}`:``]}),c.isLoading?(0,$.jsx)(R,{className:`my-4`}):G.length===0?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ze(),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)(J,{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)(Pt,{account:e,index:t,actions:qe,selected:D.has(e.id),selecting:nt,onToggleSelect:Ye,quotaPending:v.isPending&&v.variables===e.id,onMove:G.length>1?{up:t>0?()=>Ge(t,-1):void 0,down:t<G.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`)}),nt&&(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:D.size})}),(0,$.jsx)(N,{size:`sm`,icon:(0,$.jsx)(Je,{className:`size-3.5`}),disabled:Ee,onClick:()=>void Xe(e=>b.mutateAsync({id:e.id,enabled:!0})),children:t(`providers.subscription.enable`)}),(0,$.jsx)(N,{size:`sm`,disabled:Ee,onClick:()=>void Xe(e=>b.mutateAsync({id:e.id,enabled:!1})),children:t(`providers.subscription.disable`)}),(0,$.jsx)(N,{size:`sm`,disabled:Ee,onClick:()=>void Xe(e=>v.mutateAsync(e.id)),children:t(`providers.subscription.quotaRefresh`)}),(0,$.jsx)(N,{size:`sm`,className:`text-[var(--danger)]`,icon:(0,$.jsx)(Y,{className:`size-3.5`}),disabled:Ee,onClick:()=>void Ze(),children:t(`common.delete`)}),(0,$.jsx)(N,{size:`sm`,variant:`plain`,onClick:()=>ve(new Set),children:t(`providers.accounts.clearSelection`)})]}),(0,$.jsx)(`div`,{className:`mt-5`,children:(0,$.jsx)(Ut,{provider:e})}),(0,$.jsx)(Ht,{provider:e,account:tt,index:tt?G.indexOf(tt):0,actions:qe,onClose:()=>xe(null)}),Z&&(0,$.jsx)(kt,{providerId:e.id,info:Z,mode:k,providerProxy:e.httpProxy,onClose:()=>A(null)}),(0,$.jsx)(H,{open:Se,onOpenChange:j,title:t(`providers.accounts.loginProxyTitle`),description:t(`providers.accounts.loginProxyDesc`),footer:(0,$.jsx)(N,{variant:`primary`,loading:h.isPending,disabled:we.trim().length===0,onClick:()=>ze(void 0,we),children:t(`providers.accounts.loginProxyStart`)}),children:(0,$.jsx)(w,{mono:!0,label:t(`providers.accounts.detail.proxy`),placeholder:`socks5://127.0.0.1:1080`,value:we,onChange:e=>Te(e.target.value)})}),(0,$.jsxs)(H,{open:F,onOpenChange:e=>{Ae(e),e||(L(null),z(null))},title:t(`providers.subscription.login`),description:t(`providers.subscription.loginDesc`),children:[Me&&(0,$.jsx)(P,{tone:`danger`,title:t(`providers.subscription.loginFailed`),children:Me}),I?.mode===`paste`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(P,{tone:`info`,title:t(`providers.subscription.pasteTitle`),children:t(`providers.subscription.pasteDetail`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsx)(N,{onClick:()=>window.open(I.authorizeUrl,`_blank`,`noopener`),children:t(`providers.subscription.openAuthorize`)})}),(0,$.jsx)(w,{mono:!0,value:Fe,onChange:e=>Ie(e.target.value),placeholder:t(`providers.subscription.pastePlaceholder`),"aria-label":t(`providers.subscription.pasteCode`)}),(0,$.jsx)(N,{variant:`primary`,loading:Ne,onClick:()=>void Ve(),children:t(`providers.subscription.pasteSubmit`)})]}),I?.mode===`pkce`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(P,{tone:`info`,title:t(`providers.subscription.waiting`),children:t(`providers.subscription.waitingDetail`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(N,{onClick:()=>window.open(I.authorizeUrl,`_blank`,`noopener`),children:t(`providers.subscription.openAuthorize`)}),(0,$.jsx)(N,{variant:`primary`,onClick:()=>{a.invalidateQueries({queryKey:Pe.providerAccounts(e.id)}),c.refetch()},children:t(`providers.subscription.doneAuthorize`)})]})]}),I?.mode===`cli`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(P,{tone:`info`,title:t(`providers.subscription.waiting`),children:t(`providers.subscription.cliDetail`)}),(0,$.jsx)(N,{onClick:()=>window.open(I.authorizeUrl,`_blank`,`noopener`),children:t(`providers.subscription.openAuthorize`)})]}),I?.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:I.userCode})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I.verificationUrl&&(0,$.jsx)(N,{onClick:()=>window.open(I.verificationUrl??void 0,`_blank`,`noopener`),children:t(`providers.subscription.visitPage`)}),(0,$.jsx)(N,{variant:`primary`,loading:Ne,onClick:()=>void Be(),children:t(`providers.subscription.checkNow`)})]}),(0,$.jsx)(P,{tone:`info`,title:t(`providers.subscription.waiting`),children:t(`providers.subscription.checkNowHint`)})]})]})]})}function qt({policy:e,onChange:t}){let{t:n}=M();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 Jt({provider:e}){let{t}=M(),n=ae(e.id),r=d(e.id),i=m(e.id,!0),a=_e(e.id),{toast:o}=U(),[s,c]=(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:[r.isLoading&&(0,$.jsx)(R,{lines:1}),r.isError&&(0,$.jsx)(P,{tone:`danger`,title:t(`pluginAccounts.noPlugin`),children:V(r.error)}),r.data?.map(e=>(0,$.jsx)(N,{variant:e.index===0?`primary`:void 0,icon:e.type===`api`?(0,$.jsx)(st,{className:`size-3.5`}):(0,$.jsx)(_t,{className:`size-3.5`}),onClick:()=>c(e),children:e.label||t(e.type===`api`?`pluginAccounts.apiKey`:`pluginAccounts.browser`)},e.index))]}),n.isLoading&&(0,$.jsx)(R,{lines:3}),n.data?.length===0&&(0,$.jsx)(`div`,{className:`card`,children:(0,$.jsx)(C,{icon:(0,$.jsx)(yt,{className:`size-6`}),title:t(`pluginAccounts.empty`),detail:t(`pluginAccounts.emptyDetail`)})}),n.data&&n.data.length>1&&i.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(i.data.switchMode===`balanced`?`providers.subscription.policy.balancedDetail`:i.data.switchMode===`failover`?`providers.subscription.policy.failoverDetail`:`providers.subscription.policy.manualDetail`)}),(0,$.jsx)(qt,{policy:i.data,onChange:e=>a.mutate({switchMode:e},{onError:e=>o(V(e),`error`)})})]}),n.data&&n.data.length>0&&(0,$.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] overflow-hidden p-0`,children:n.data.map(t=>(0,$.jsx)(Xt,{provider:e,account:t},t.id))}),(0,$.jsx)(Yt,{provider:e}),s&&(0,$.jsx)(Zt,{provider:e,method:s,onClose:()=>c(null)})]})}function Yt({provider:e}){let{t,locale:n}=M(),{toast:r}=U(),i=ve(e.id),a=p(e.id);if(!i.data?.supported)return null;let o=e=>a.mutate(e,{onError:e=>r(V(e),`error`)}),s={claimed:`green`,done:`green`,ineligible:`neutral`,inactive:`neutral`,captcha:`orange`,failed:`red`};return(0,$.jsxs)(`section`,{className:`card divide-y divide-[var(--border-subtle)] overflow-hidden p-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-[13px] font-medium`,children:t(`pluginAccounts.checkin`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[12px] text-[var(--text-secondary)]`,children:t(`pluginAccounts.checkinDetail`)})]}),(0,$.jsx)(B,{checked:i.data.on,label:t(`pluginAccounts.checkinOn`),onChange:e=>o(e)}),(0,$.jsx)(N,{size:`sm`,loading:a.isPending,onClick:()=>o(),children:t(`pluginAccounts.checkinNow`)})]}),i.data.accounts.map(e=>{let r=[e.credit?t(`pluginAccounts.credit`,{credit:e.credit}):null,e.streak?t(`pluginAccounts.streak`,{days:e.streak}):null,e.message,e.at?b(e.at,n):null].filter(Boolean);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.account}),r.length>0&&(0,$.jsx)(`span`,{className:`min-w-0 truncate text-[12px] text-[var(--text-secondary)]`,children:r.join(` · `)}),e.outcome?(0,$.jsx)(j,{tone:s[e.outcome]??`neutral`,children:t(`pluginAccounts.outcome.${e.outcome}`)}):(0,$.jsx)(j,{children:t(`pluginAccounts.checkinNever`)})]},e.accountId)})]})}function Xt({provider:e,account:t}){let{t:n,locale:i}=M(),{toast:a,confirm:o}=U(),s=Ie(e.id),[c,l]=(0,Q.useState)(!1),u=e.settings?.plugin?.usage===!0,d=r(e.id,t.id,c),f=async()=>{await o({title:n(`pluginAccounts.signOutConfirm`,{name:t.displayName}),confirmLabel:n(`pluginAccounts.signOut`),destructive:!0})&&s.mutate(t.id,{onError:e=>a(V(e),`error`)})};return(0,$.jsxs)(`article`,{className:`flex flex-col gap-2 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:t.displayName}),t.isCurrent&&(0,$.jsx)(j,{tone:`accent`,children:n(`pluginAccounts.current`)}),(0,$.jsx)(j,{tone:t.status===`active`?`green`:`red`,children:n(t.status===`active`?`pluginAccounts.active`:`pluginAccounts.lapsed`)}),u&&(0,$.jsx)(N,{size:`sm`,onClick:()=>l(e=>!e),children:n(`pluginAccounts.usage`)}),(0,$.jsx)(N,{size:`sm`,variant:`destructive`,icon:(0,$.jsx)(qe,{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`)}),c&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md bg-[var(--surface-muted)] px-3 py-2`,children:[d.isLoading&&(0,$.jsx)(R,{lines:2}),d.isError&&(0,$.jsx)(`span`,{className:`text-[12px] text-[var(--danger)]`,children:V(d.error)}),d.data?.error&&(0,$.jsx)(`span`,{className:`text-[12px] text-[var(--danger)]`,children:d.data.error}),d.data?.plan&&(0,$.jsx)(T,{label:n(`pluginAccounts.plan`),children:d.data.plan}),d.data?.until&&(0,$.jsx)(T,{label:n(`pluginAccounts.until`),children:b(d.data.until,i)}),d.data?.windows?.map(e=>(0,$.jsxs)(T,{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:b(new Date(e.resetsAt>0xe8d4a51000?e.resetsAt:e.resetsAt*1e3).toISOString(),i)})}`:``]},e.name))]})]})}function Zt({provider:e,method:n,onClose:r}){let{t:i}=M(),{toast:o}=U(),[s,c]=(0,Q.useState)({}),[l,u]=(0,Q.useState)(void 0),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(``),[te,re]=(0,Q.useState)(null),b=_(e.id),ie=t(e.id),ae=ye(e.id),x=ee(e.id,te).data;(0,Q.useEffect)(()=>{let t=!0;return ne(e.id,n.index,s).then(e=>{t&&(u(e.prompt),f(e.prompt?.type===`select`?e.prompt.options?.[0]?.value??``:``))}).catch(e=>t&&o(V(e),`error`)),()=>{t=!1}},[e.id,n.index,s,o]),(0,Q.useEffect)(()=>{x?.state===`done`&&(o(i(`pluginAccounts.signedIn`),`success`),r())},[x?.state,r,i,o]);let oe=async()=>{if(!l)return;let t=await a(e.id,n.index,l.key,d).catch(()=>({error:null}));if(t.error)return m(t.error);m(null),c(e=>({...e,[l.key]:d}))};return(0,$.jsxs)(H,{open:!0,onOpenChange:e=>!e&&r(),title:i(`pluginAccounts.signInTitle`,{name:e.name}),description:n.label,width:520,children:[l===void 0&&(0,$.jsx)(R,{lines:2}),l&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(k,{label:l.message,error:p??void 0,children:l.type===`select`?(0,$.jsx)(W,{value:d,onChange:f,options:(l.options??[]).map(e=>({value:e.value,label:e.label,description:e.hint??void 0}))}):(0,$.jsx)(w,{value:d,placeholder:l.placeholder??void 0,onChange:e=>f(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(N,{variant:`primary`,onClick:()=>void oe(),children:i(`pluginAccounts.continue`)})})]}),l===null&&n.type===`api`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(k,{label:i(`pluginAccounts.key`),children:(0,$.jsx)(w,{mono:!0,type:`password`,value:h,placeholder:n.placeholder??void 0,onChange:e=>g(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(N,{variant:`primary`,disabled:!h.trim()||ie.isPending,onClick:()=>ie.mutate({method:n.index,inputs:s,key:h},{onSuccess:()=>(o(i(`pluginAccounts.signedIn`),`success`),r()),onError:e=>o(V(e),`error`)}),children:i(`pluginAccounts.signIn`)})})]}),l===null&&n.type!==`api`&&!x&&(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(N,{variant:`primary`,icon:(0,$.jsx)(Ge,{className:`size-3.5`}),disabled:b.isPending,onClick:()=>b.mutate({method:n.index,inputs:s},{onSuccess:e=>{re(e.id),e.url&&window.open(e.url,`_blank`,`noopener`)},onError:e=>o(V(e),`error`)}),children:i(`pluginAccounts.openPage`)})}),x&&x.state!==`done`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[x.instructions&&(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[12px] text-[var(--text-secondary)]`,children:x.instructions}),x.deviceCode&&(0,$.jsx)(T,{label:i(`pluginAccounts.deviceCode`),mono:!0,children:x.deviceCode}),x.url&&(0,$.jsx)(N,{icon:(0,$.jsx)(Ge,{className:`size-3.5`}),onClick:()=>window.open(x.url,`_blank`,`noopener`),children:i(`pluginAccounts.openAgain`)}),x.state===`waiting`&&x.pasteCode&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(k,{label:i(`pluginAccounts.code`),children:(0,$.jsx)(w,{mono:!0,value:v,onChange:e=>y(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(N,{variant:`primary`,disabled:!v.trim()||ae.isPending,onClick:()=>ae.mutate({flow:x.id,code:v.trim()},{onError:e=>o(V(e),`error`)}),children:i(`pluginAccounts.signIn`)})})]}),x.state===`waiting`&&!x.pasteCode&&(0,$.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:i(`pluginAccounts.waiting`)}),x.state===`failed`&&(0,$.jsx)(P,{tone:`danger`,title:i(`pluginAccounts.failed`),children:x.error})]})]})}function Qt(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 $t(){let{t:e}=M(),{id:t=``}=tt(),n=et(),r=ie(t),[i,a]=(0,Q.useState)(`models`),[o,s]=(0,Q.useState)(null),c=v(t),l=c.data?.find(e=>e.id===o)??null;if(r.isError)return(0,$.jsx)(rt,{title:e(`nav.providers`),leading:(0,$.jsx)(en,{onClick:()=>n(`/providers`)}),children:(0,$.jsx)(P,{tone:`danger`,title:e(`common.error`),children:V(r.error)})});let u=r.data;return(0,$.jsx)(rt,{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)(en,{onClick:()=>n(`/providers`)}),actions:u&&(0,$.jsx)(tn,{p:u}),children:u?(0,$.jsxs)(Xe,{className:`mx-auto max-w-[860px]`,value:i,onValueChange:e=>a(e),children:[(0,$.jsxs)(X,{"aria-label":u.name,children:[(0,$.jsx)(Ze,{value:`models`,children:e(`providers.tab.models`)}),(0,$.jsx)(Ze,{value:`accounts`,children:e(u.authScheme===`oauth-subscription`||u.authScheme===`plugin`?`providers.tab.accounts`:`providers.tab.apiKey`)}),(0,$.jsx)(Ze,{value:`settings`,children:e(`providers.tab.settings`)})]}),(0,$.jsx)(ot,{value:`models`,className:`pt-4`,children:(0,$.jsx)(rn,{provider:u,models:c.data,loading:c.isLoading,selected:o,onSelect:s})}),(0,$.jsx)(ot,{value:`accounts`,className:`pt-4`,children:u.authScheme===`plugin`?(0,$.jsx)(Jt,{provider:u}):u.authScheme===`oauth-subscription`?(0,$.jsx)(Kt,{provider:u}):(0,$.jsx)(dn,{provider:u})}),(0,$.jsx)(ot,{value:`settings`,className:`pt-4`,children:(0,$.jsx)(pn,{provider:u})}),(0,$.jsx)(un,{provider:u,pm:i===`models`?l:null,onClose:()=>s(null)})]}):(0,$.jsx)(R,{lines:4,className:`mx-auto mt-6 max-w-[860px]`})})}function en({onClick:e}){let{t}=M();return(0,$.jsx)(N,{variant:`glass`,icon:(0,$.jsx)(Ve,{className:`size-4`}),"aria-label":t(`common.back`),onClick:e})}function tn({p:e}){let{t}=M(),n=et(),{toast:r,confirm:i}=U(),a=ce(),o=Ae(),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),d=async()=>{await i({title:t(`providers.deleteConfirm`,{name:e.name}),detail:t(`providers.deleteDetail`),destructive:!0,confirmLabel:t(`common.delete`)})&&o.mutate(e.id,{onSuccess:()=>{r(t(`providers.deleted`)),n(`/providers`)},onError:e=>{let n=e instanceof E&&e.status===409?e.details?.boundClients??[]:[];r(n.length?t(`providers.deleteBound`,{clients:n.map(e=>Z[e]?.name??e).join(`, `)}):V(e),`error`)}})};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{icon:(0,$.jsx)(Ke,{className:`size-3.5`}),onClick:()=>u(!0),children:t(`providers.test`)}),(0,$.jsx)(Le,{label:t(`common.more`),icon:(0,$.jsx)(We,{className:`size-4`}),items:[{id:`dup`,label:t(`providers.duplicate`),icon:(0,$.jsx)(Ee,{className:`size-3.5`}),onSelect:()=>a.mutate(e.id,{onSuccess:e=>n(`/providers/${e.id}`),onError:e=>r(V(e),`error`)})},{id:`tpl`,label:t(`providers.templateUpdate`),icon:(0,$.jsx)(xt,{className:`size-3.5`}),disabled:!e.templateId,onSelect:()=>c(!0)},{id:`del`,label:t(`common.delete`),icon:(0,$.jsx)(Y,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void d()}]}),(0,$.jsx)(nn,{open:s,onOpenChange:c,provider:e}),(0,$.jsx)(G,{provider:e,open:l,onOpenChange:u})]})}function nn({open:e,onOpenChange:t,provider:n}){let{t:r}=M(),{toast:i}=U(),a=s(n.id,e),o=h(n.id),c=a.data&&a.data.latestVersion<=a.data.currentVersion;return(0,$.jsxs)(H,{open:e,onOpenChange:t,title:r(`providers.templateUpdate`),description:a.data?r(`providers.templateVersions`,{current:a.data.currentVersion,latest:a.data.latestVersion}):void 0,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(N,{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(V(e),`error`)}),children:r(`common.apply`)})]}),children:[a.isLoading&&(0,$.jsx)(R,{}),a.isError&&(0,$.jsx)(P,{tone:`danger`,title:r(`common.error`),children:V(a.error)}),c&&(0,$.jsx)(P,{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 rn({provider:e,models:t,loading:r,selected:i,onSelect:a}){let{t:o}=M(),{toast:s}=U(),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),m=F(e.id),h=(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)(me,{className:`w-56`,value:c,onChange:l,placeholder:o(`providers.searchModels`)}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(N,{icon:(0,$.jsx)(J,{className:`size-3.5`}),onClick:()=>p(!0),children:o(`providers.addModels`)}),(0,$.jsx)(N,{variant:`primary`,icon:(0,$.jsx)(He,{className:`size-3.5`}),onClick:()=>d(!0),children:o(`providers.fetchRemote`)})]})]}),r&&(0,$.jsx)(R,{lines:4}),t?.length===0&&(0,$.jsx)(`div`,{className:`card`,children:(0,$.jsx)(C,{title:o(`providers.noModels`),detail:o(`providers.noModelsDetail`)})}),h.length>0&&(0,$.jsx)(L,{footer:o(`providers.modelsFooter`),children:h.map(e=>(0,$.jsxs)(A,{selected:e.id===i,onClick:()=>a(e.id),label:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:O(`font-mono text-[12.5px]`,!e.enabled&&`text-[var(--text-muted)]`),children:e.modelId}),!e.systemModelId&&(0,$.jsx)(j,{tone:`orange`,children:o(`providers.unlinked`)})]}),detail:[e.effective.displayName===e.modelId?null:e.effective.displayName,e.effective.contextWindow?n(e.effective.contextWindow):null,we(e.effectivePricing)].filter(Boolean).join(` · `),children:[(0,$.jsx)(nt,{source:e.pricingSource,priceKey:e.priceKey}),(0,$.jsx)(B,{checked:e.enabled,label:o(`common.enabled`),onChange:t=>m.mutate({pmId:e.id,enabled:t},{onError:e=>s(V(e),`error`)})})]},e.id))}),t&&(0,$.jsx)(an,{provider:e,models:t}),(0,$.jsx)(sn,{open:f,onOpenChange:p,provider:e}),(0,$.jsx)(cn,{open:u,onOpenChange:d,provider:e})]})}function an({provider:e,models:t}){let{t:n}=M(),{toast:r}=U(),i=Ne(e.id),[a,o]=(0,Q.useState)(!1),s=Qt(e.settings),c=Object.entries(s),l=new Set(t.map(e=>e.modelId)),u=(e,t)=>i.mutate(e,{onSuccess:()=>{t?.(),r(n(`providers.modelMap.saved`),`success`)},onError:e=>r(V(e),`error`)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(L,{title:n(`providers.modelMap.title`),footer:n(`providers.modelMap.footer`),children:[c.map(([e,t])=>(0,$.jsx)(A,{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)(Qe,{className:`size-3.5 shrink-0 text-[var(--text-muted)]`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:O(`truncate`,!l.has(t)&&`text-[var(--text-muted)]`),children:t}),!l.has(t)&&(0,$.jsx)(j,{tone:`orange`,children:n(`providers.modelMap.missingTarget`)})]}),children:(0,$.jsx)(N,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(le,{className:`size-3.5`}),"aria-label":n(`providers.modelMap.remove`,{from:e}),title:n(`providers.modelMap.remove`,{from:e}),disabled:i.isPending,onClick:()=>u(Object.fromEntries(c.filter(([t])=>t!==e)))})},e)),(0,$.jsx)(A,{icon:(0,$.jsx)(J,{className:`size-4 text-[var(--text-secondary)]`}),label:n(`providers.modelMap.add`),detail:t.length===0?n(`providers.modelMap.needModels`):void 0,onClick:t.length===0?void 0:()=>o(!0)})]}),(0,$.jsx)(on,{open:a,onOpenChange:o,models:t,saving:i.isPending,onSave:(e,t)=>u({...s,[e]:t},()=>o(!1))})]})}function on({open:e,onOpenChange:t,models:n,saving:r,onSave:i}){let{t:a}=M(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&(s(``),l(``))},[e]);let u=o.trim();return(0,$.jsx)(H,{open:e,onOpenChange:t,title:a(`providers.modelMap.add`),description:a(`providers.modelMap.addDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{onClick:()=>t(!1),children:a(`common.cancel`)}),(0,$.jsx)(N,{variant:`primary`,disabled:!u||!c||u===c,loading:r,onClick:()=>i(u,c),children:a(`common.save`)})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(w,{autoFocus:!0,mono:!0,label:a(`providers.modelMap.from`),placeholder:`deepseek-v4.1`,spellCheck:!1,value:o,onChange:e=>s(e.target.value)}),(0,$.jsx)(W,{label:a(`providers.modelMap.to`),value:c,onChange:l,placeholder:a(`providers.modelMap.toPlaceholder`),options:n.map(e=>({value:e.modelId,label:e.modelId}))})]})})}function sn({open:e,onOpenChange:t,provider:n}){let{t:r}=M(),{toast:i}=U(),a=xe(n.id),[o,s]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&s(``)},[e]);let c=[...new Set(o.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean))];return(0,$.jsx)(H,{open:e,onOpenChange:t,title:r(`providers.addModels`),description:r(`providers.addModelsDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(N,{variant:`primary`,disabled:c.length===0,loading:a.isPending,onClick:()=>a.mutate(c,{onSuccess:e=>{t(!1),i(r(`providers.modelsAdded`,{count:e.length}),`success`)},onError:e=>i(V(e),`error`)}),children:r(`providers.addSelected`,{count:c.length})})]}),children:(0,$.jsx)(se,{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 cn({open:e,onOpenChange:t,provider:n}){let{t:r}=M(),{toast:i}=U(),a=D(n.id,e),o=xe(n.id),[s,c]=(0,Q.useState)(new Set),[l,u]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&c(new Set)},[e]);let d=(a.data??[]).filter(e=>!l||e.id.toLowerCase().includes(l.toLowerCase())),f=e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,$.jsxs)(H,{open:e,onOpenChange:t,width:560,title:r(`providers.fetchRemote`),description:r(`providers.fetchRemoteDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{variant:`plain`,className:`mr-auto`,onClick:()=>c(new Set(d.filter(e=>!e.alreadyAdded).map(e=>e.id))),disabled:d.length===0,children:r(`common.selectAll`)}),(0,$.jsx)(N,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(N,{variant:`primary`,disabled:s.size===0,loading:o.isPending,onClick:()=>o.mutate([...s],{onSuccess:e=>{t(!1),i(r(`providers.modelsAdded`,{count:e.length}),`success`)},onError:e=>i(V(e),`error`)}),children:r(`providers.addSelected`,{count:s.size})})]}),children:[(0,$.jsx)(me,{className:`mb-3`,value:l,onChange:u,placeholder:r(`providers.searchModels`)}),a.isLoading&&(0,$.jsx)(R,{lines:4}),a.isError&&(0,$.jsx)(P,{tone:`danger`,title:r(`common.error`),children:V(a.error)}),(0,$.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:d.map(e=>(0,$.jsx)(A,{onClick:e.alreadyAdded?void 0:()=>f(e.id),label:(0,$.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.id}),detail:e.linkedSystemModelId?r(`providers.linksTo`,{id:e.linkedSystemModelId}):r(`providers.noLink`),children:e.alreadyAdded?(0,$.jsx)(j,{children:r(`providers.added`)}):(0,$.jsx)(`span`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(ct,{"aria-label":e.id,checked:s.has(e.id),onCheckedChange:()=>f(e.id)})})},e.id))})]})}function ln({origin:e}){let{t}=M();return e===`overridden`?(0,$.jsx)(j,{tone:`orange`,children:t(`origin.overridden`)}):e===`inherited`?(0,$.jsx)(j,{children:t(`origin.inherited`)}):(0,$.jsx)(j,{tone:`red`,children:t(`origin.unset`)})}function un({provider:e,pm:t,onClose:n}){let{t:r}=M(),{toast:i}=U(),a=F(e.id),o=De(e.id),s=g(),[c,l]=(0,Q.useState)({}),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{t&&(l(t.overrides),d(t.systemModelId??``),p(t.overrides.pricing!=null))},[t]),!t)return(0,$.jsx)(H,{open:!1,onOpenChange:()=>n(),title:r(`providers.tab.models`)});let m={...c,pricing:f?c.pricing??null:null},h=JSON.stringify(m)!==JSON.stringify({...t.overrides,pricing:t.overrides.pricing??null})||u!==(t.systemModelId??``),_=()=>a.mutate({pmId:t.id,overrides:m,systemModelId:u||null},{onSuccess:()=>{i(r(`common.saved`),`success`),n()},onError:e=>i(V(e),`error`)}),v=(e,n,i)=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[13px] font-medium`,children:n}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ln,{origin:c[e]==null?t.origins[e]===`overridden`?`inherited`:t.origins[e]:`overridden`}),c[e]!=null&&(0,$.jsx)(N,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(Ye,{className:`size-3`}),title:r(`origin.reset`),"aria-label":r(`origin.reset`),onClick:()=>l({...c,[e]:null})})]})]}),i]});return(0,$.jsx)(H,{open:!0,onOpenChange:e=>!e&&n(),width:720,title:t.modelId,description:e.name,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mr-auto`,children:(0,$.jsx)(lt,{label:r(`providers.removeModelShort`),icon:(0,$.jsx)(Y,{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)(N,{onClick:n,children:r(`common.cancel`)}),(0,$.jsx)(N,{variant:`primary`,disabled:!h,loading:a.isPending,onClick:_,children:r(`common.save`)})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(nt,{source:t.pricingSource,priceKey:t.priceKey}),t.multiplier!==1&&t.pricingSource!==`provider_override`&&(0,$.jsxs)(j,{children:[`×`,t.multiplier]})]}),(0,$.jsxs)(S,{title:r(`providers.linkedModel`),children:[(0,$.jsx)(W,{className:`w-full`,ariaLabel:r(`providers.linkedModel`),value:u,onChange:d,options:[{value:``,label:r(`providers.noLink`)},...(s.data??[]).map(e=>({value:e.id,label:e.id,detail:e.displayName}))]}),(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-[var(--text-muted)]`,children:r(`providers.linkedModelHint`)})]}),(0,$.jsx)(S,{title:r(`providers.overrides`),children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[v(`displayName`,r(`models.field.displayName`),(0,$.jsx)(w,{className:`w-full`,"aria-label":r(`models.field.displayName`),placeholder:t.effective.displayName,value:c.displayName??``,onChange:e=>l({...c,displayName:e.target.value||null})})),v(`contextWindow`,r(`models.field.contextWindow`),(0,$.jsx)(Te,{className:`w-full`,label:r(`models.field.contextWindow`),placeholder:String(t.effective.contextWindow??``),value:c.contextWindow,onChange:e=>l({...c,contextWindow:e})})),v(`maxOutputTokens`,r(`models.field.maxOutputTokens`),(0,$.jsx)(Te,{className:`w-full`,label:r(`models.field.maxOutputTokens`),placeholder:String(t.effective.maxOutputTokens??``),value:c.maxOutputTokens,onChange:e=>l({...c,maxOutputTokens:e})}))]})}),(0,$.jsxs)(S,{title:r(`providers.price`),action:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[r(`providers.customPrice`),(0,$.jsx)(B,{checked:f,label:r(`providers.customPrice`),onChange:e=>{p(e),e&&c.pricing==null&&l({...c,pricing:t.effectivePricing??{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}}})}})]}),children:[(0,$.jsx)(`p`,{className:`mb-3 text-[11px] text-[var(--text-muted)]`,children:r(f?`providers.customPriceHint`:`providers.inheritedPriceHint`)}),f?(0,$.jsx)(`div`,{className:`card p-4`,children:(0,$.jsx)(it,{value:c.pricing??null,onChange:e=>l({...c,pricing:e})})}):t.effectivePricing?(0,$.jsx)(ge,{maxHeight:220,children:I(t.effectivePricing)}):(0,$.jsx)(P,{tone:`warning`,title:r(`pricingSource.none`)})]})]})})}function dn({provider:t}){let{t:n}=M(),{toast:r}=U(),i=e(t.id),[a,o]=(0,Q.useState)(``);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{title:n(`providers.section.auth`),footer:n(`providers.apiKeyStored`),children:(0,$.jsx)(A,{label:n(`providers.apiKey`),detail:t.hasApiKey?t.apiKeyMasked??`••••`:n(`providers.noKey`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(w,{type:`password`,autoComplete:`off`,className:`w-64 font-mono`,"aria-label":n(`providers.apiKey`),placeholder:n(`providers.replaceKey`),value:a,onChange:e=>o(e.target.value)}),(0,$.jsx)(N,{variant:`primary`,disabled:a.trim().length===0,loading:i.isPending,onClick:()=>i.mutate({apiKey:a},{onSuccess:()=>{o(``),r(n(`common.saved`),`success`)},onError:e=>r(V(e),`error`)}),children:n(`common.save`)})]})})}),(0,$.jsx)(Re,{provider:t})]})}function fn(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 pn({provider:t}){let{t:n}=M(),{toast:r}=U(),i=e(t.id),a=c(),o=(0,Q.useMemo)(()=>fn(t),[t]),[s,l]=(0,Q.useState)(o),[u,d]=(0,Q.useState)(Object.entries(t.extraHeaders)),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{l(o),d(Object.entries(o.extraHeaders))},[o]);let g=e=>l(t=>({...t,...e})),_={...s,extraHeaders:Object.fromEntries(u.filter(([e])=>e.trim()))},v=JSON.stringify(_)!==JSON.stringify(o),ee=()=>{let e={};for(let t of Object.keys(_))t!==`apiKey`&&JSON.stringify(_[t])!==JSON.stringify(o[t])&&(e[t]=_[t]);s.apiKey&&(e.apiKey=s.apiKey),i.mutate(e,{onSuccess:()=>r(n(`common.saved`),`success`),onError:e=>r(V(e),`error`)})},y=(e,t)=>g({endpoints:s.endpoints.map((n,r)=>r===e?{...n,...t}:n)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(L,{title:n(`providers.section.basic`),children:[(0,$.jsx)(A,{label:n(`providers.name`),children:(0,$.jsx)(w,{className:`w-64`,"aria-label":n(`providers.name`),value:s.name,onChange:e=>g({name:e.target.value})})}),(0,$.jsx)(A,{label:n(`common.enabled`),children:(0,$.jsx)(B,{checked:s.enabled,label:n(`common.enabled`),onChange:e=>g({enabled:e})})}),(0,$.jsx)(A,{label:n(`providers.notes`),children:(0,$.jsx)(w,{className:`w-64`,"aria-label":n(`providers.notes`),value:s.notes??``,onChange:e=>g({notes:e.target.value||null})})})]}),(0,$.jsx)(L,{title:n(`providers.section.auth`),children:(0,$.jsx)(A,{label:n(`providers.authScheme`),children:(0,$.jsx)(W,{className:`w-48`,value:s.authScheme,onChange:e=>g({authScheme:e}),options:ze})})}),(0,$.jsxs)(L,{title:n(`providers.section.endpoints`),footer:n(`providers.endpointsFooter`),children:[s.endpoints.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 py-3`,children:[(0,$.jsx)(W,{className:`w-48`,value:e.protocol,onChange:e=>y(t,{protocol:e}),options:K}),(0,$.jsx)(w,{className:`min-w-60 flex-1 font-mono`,"aria-label":n(`providers.baseUrl`),value:e.baseUrl,onChange:e=>y(t,{baseUrl:e.target.value})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(B,{checked:!!e.fullUrl,label:n(`providers.fullUrl`),onChange:e=>y(t,{fullUrl:e})}),n(`providers.fullUrl`)]}),(0,$.jsx)(N,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(Y,{className:`size-3.5`}),"aria-label":n(`common.delete`),onClick:()=>g({endpoints:s.endpoints.filter((e,n)=>n!==t)})})]},t)),(0,$.jsx)(`div`,{className:`px-4 py-2`,children:(0,$.jsx)(N,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(J,{className:`size-3.5`}),onClick:()=>p(!0),children:n(`providers.addEndpoint`)})}),(0,$.jsx)(A,{label:n(`providers.preferred`),detail:(0,$.jsxs)($.Fragment,{children:[n(`providers.preferredHint`),s.preferredUpstreamProtocols.filter(e=>!s.endpoints.some(t=>t.protocol===e)).map(e=>(0,$.jsx)(`span`,{className:`mt-1 block text-[var(--warning)]`,children:n(`providers.preferredMissing`,{protocol:K.find(t=>t.value===e)?.label??e})},e))]}),children:(0,$.jsx)(at,{label:n(`providers.preferred`),options:K.map(e=>{let t=s.preferredUpstreamProtocols.indexOf(e.value);return{value:e.value,label:t>=0?`${t+1}. ${e.label}`:e.label}}),value:s.preferredUpstreamProtocols,onValueChange:e=>{let t=s.preferredUpstreamProtocols.filter(t=>e.includes(t)),n=e.filter(e=>!t.includes(e));g({preferredUpstreamProtocols:[...t,...n]})}})})]}),(0,$.jsxs)(L,{title:n(`providers.section.billing`),footer:n(`providers.billingFooter`),children:[(0,$.jsx)(A,{label:n(`providers.priceKey`),detail:n(`providers.priceKeyHint`),children:(0,$.jsx)(W,{className:`w-56`,value:s.priceKey==null?`inherit`:`price:${s.priceKey}`,onChange:e=>g({priceKey:e===`inherit`?null:e.slice(6)}),options:[{value:`inherit`,label:n(`providers.priceKeyDefault`,{id:t.templateId??`—`})},{value:`price:`,label:n(`providers.priceKeyNone`)},...(a.data??[]).map(e=>({value:`price:${e.priceKey}`,label:e.label,detail:e.priceKey}))]})}),(0,$.jsx)(A,{label:n(`providers.multiplier`),detail:n(`providers.multiplierHint`),children:(0,$.jsx)(Te,{className:`w-28`,label:n(`providers.multiplier`),step:.01,min:0,value:s.priceMultiplier,onChange:e=>g({priceMultiplier:e??1})})})]}),(0,$.jsxs)(L,{title:n(`providers.section.advanced`),children:[(0,$.jsx)(A,{label:n(`providers.proxy`),detail:n(`providers.proxyHint`),children:(0,$.jsx)(w,{className:`w-64 font-mono`,"aria-label":n(`providers.proxy`),placeholder:`http://127.0.0.1:7890`,value:s.httpProxy??``,onChange:e=>g({httpProxy:e.target.value||null})})}),(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-[13px]`,children:n(`providers.headers`)}),u.map(([e,t],r)=>(0,$.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,$.jsx)(w,{className:`w-48 font-mono`,"aria-label":n(`providers.headerName`),placeholder:`Header`,value:e,onChange:e=>d(u.map((t,n)=>n===r?[e.target.value,t[1]]:t))}),(0,$.jsx)(w,{className:`flex-1 font-mono`,"aria-label":n(`providers.headerValue`),placeholder:`value`,value:t,onChange:e=>d(u.map((t,n)=>n===r?[t[0],e.target.value]:t))}),(0,$.jsx)(N,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(Y,{className:`size-3.5`}),"aria-label":n(`common.delete`),onClick:()=>d(u.filter((e,t)=>t!==r))})]},r)),(0,$.jsx)(N,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(J,{className:`size-3.5`}),onClick:()=>h(!0),children:n(`providers.addHeader`)})]}),Object.keys(t.settings).length>0&&(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsx)(se,{label:n(`providers.adapterSettings`),rows:4,className:`w-full font-mono`,defaultValue:I(s.settings),onBlur:e=>{try{g({settings:JSON.parse(e.target.value)})}catch{r(n(`common.invalidJson`),`error`)}}})})]}),(0,$.jsx)(L,{title:n(`providers.section.info`),children:(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(T,{label:`ID`,children:t.id}),t.adapterId&&(0,$.jsx)(T,{label:n(`providers.adapter`),children:t.adapterId}),(0,$.jsx)(T,{label:n(`providers.boundClients`),children:t.boundClients.map(e=>Z[e]?.name??e).join(`, `)||`—`})]})}),(0,$.jsx)(mn,{open:f,onOpenChange:p,onAdd:e=>g({endpoints:[...s.endpoints,e]})}),(0,$.jsx)(hn,{open:m,onOpenChange:h,onAdd:e=>d([...u.filter(([t])=>t.toLowerCase()!==e[0].toLowerCase()),e])}),(0,$.jsx)(`div`,{className:`sticky bottom-2 flex justify-end`,children:v&&(0,$.jsxs)(`div`,{className:`glass flex items-center gap-2 rounded-full p-1 pl-4 text-[12px]`,children:[(0,$.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:n(`common.unsaved`)}),(0,$.jsx)(N,{size:`sm`,onClick:()=>{l(o),d(Object.entries(o.extraHeaders))},children:n(`common.revert`)}),(0,$.jsx)(N,{size:`sm`,variant:`primary`,loading:i.isPending,onClick:ee,children:n(`common.save`)})]})})]})}function mn({open:e,onOpenChange:t,onAdd:n}){let{t:r}=M(),[i,a]=(0,Q.useState)(`openai-chat`),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{e&&(s(``),l(!1))},[e]);let u=/^https?:\/\/\S+$/.test(o.trim());return(0,$.jsx)(H,{open:e,onOpenChange:t,title:r(`providers.addEndpoint`),description:r(`providers.addEndpointDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(N,{variant:`primary`,disabled:!u,onClick:()=>{n({protocol:i,baseUrl:o.trim(),...c?{fullUrl:!0}:{}}),t(!1)},children:r(`common.add`)})]}),children:(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsx)(k,{label:r(`providers.protocol`),children:(0,$.jsx)(W,{value:i,onChange:a,options:K})}),(0,$.jsx)(k,{label:r(`providers.baseUrl`),hint:r(c?`providers.fullUrlHint`:`providers.baseUrlHint`),children:(0,$.jsx)(w,{autoFocus:!0,className:`font-mono`,placeholder:`https://api.example.com/v1`,value:o,invalid:o!==``&&!u,onChange:e=>s(e.target.value)})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(B,{checked:c,onChange:l,label:r(`providers.fullUrl`)}),r(`providers.fullUrl`)]})]})})}function hn({open:e,onOpenChange:t,onAdd:n}){let{t:r}=M(),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&(a(``),s(``))},[e]);let c=/^[A-Za-z0-9-]+$/.test(i.trim());return(0,$.jsx)(H,{open:e,onOpenChange:t,title:r(`providers.addHeader`),description:r(`providers.addHeaderDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(N,{variant:`primary`,disabled:!c,onClick:()=>{n([i.trim(),o]),t(!1)},children:r(`common.add`)})]}),children:(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsx)(k,{label:r(`providers.headerName`),children:(0,$.jsx)(w,{autoFocus:!0,className:`font-mono`,placeholder:`X-Custom-Header`,value:i,invalid:i!==``&&!c,onChange:e=>a(e.target.value)})}),(0,$.jsx)(k,{label:r(`providers.headerValue`),children:(0,$.jsx)(w,{className:`font-mono`,value:o,onChange:e=>s(e.target.value)})})]})})}export{$t as ProviderDetailPage};
@@ -1,2 +0,0 @@
1
- import{$n as e,$r as t,Ai as n,Di as r,E as i,Ei as a,Gn as o,Ir as s,J as c,Lr as l,Oi as u,Qn as d,Sa as f,Ti as p,W as m,Yt as h,Z as g,_,_a as v,b as y,c as b,ct as x,d as S,dn as C,er as w,f as T,fi as E,gt as D,h as O,i as k,it as A,ki as ee,l as j,m as M,n as N,ot as P,p as F,r as I,s as L,t as R,u as z,v as te,va as B,vn as V,vr as H,vt as U,w as W,wt as ne,xa as re,y as G,ya as K,yn as ie,zr as ae}from"./alert-CGUFPyGb.js";import{A as oe,C as se,D as ce,E as le,O as ue,T as de,X as fe,a as q,ct as pe,dt as me,ft as he,i as ge,k as _e,mt as ve,o as ye,pt as be,r as xe,ut as Se,w as Ce}from"./overlays-B1a0OZYb.js";import{t as we}from"./arrow-left-Dn6_YDkh.js";import{t as Te}from"./download-5xAFYJ6Q.js";import{n as Ee,t as De}from"./radio-cards-Cr0tP9In.js";import{$ as Oe,A as ke,I as Ae,L as je,O as Me,P as Ne,Q as Pe,S as Fe,X as Ie,_ as Le,b as Re,et as ze,g as Be,h as Ve,q as He,x as Ue}from"./index-mlmGhWY4.js";import{t as We}from"./checkbox-DzIMWhhw.js";var J=f(K(),1);function Ge(e,t,n){(0,J.useInsertionEffect)(()=>e.on(t,n),[e,t,n])}var Ke={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};Ke.node;var qe=U(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=U(Je),Xe={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Xe.node;var Ze=U(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=B(),{blur:Qe,duration:Z,ease:$e,spring:et,stagger:tt}=i,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)(n,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(p.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)(p.span,{className:Y.word,custom:t/2,variants:ft,children:e},t))},e)})})]})}function mt(e,t){let n=parseFloat(t);if(Number.isFinite(n))return t.trim().endsWith(`rem`)?n*parseFloat(getComputedStyle(e.ownerDocument.documentElement).fontSize):n}function ht({title:e,description:t,media:i,action:a,avatar:o,meta:s,status:c,details:l,open:u,defaultOpen:d=!1,onOpenChange:f,children:m,className:h,style:g,..._}){let v=r()??!1,y=(0,J.useId)(),b=(0,J.useRef)(null),S=(0,J.useRef)(null),[C,w]=(0,J.useState)(d),[T,E]=(0,J.useState)(!1),[D,O]=(0,J.useState)({}),[k,A]=(0,J.useState)(null),j=l?u??C:!1,M=!!l&&!v,N=!j&&k!==null,P=!!t,F=(0,J.useCallback)(e=>{u===void 0&&w(e),f?.(e)},[u,f]);(0,J.useEffect)(()=>{let e=b.current,t=S.current;if(!M||!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;O(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()},[M,P]);let I=(0,J.useRef)(j);(0,J.useLayoutEffect)(()=>{let e=I.current&&!j;I.current=j;let t=b.current;if(j)A(null);else if(e&&M&&t){let e=t.getBoundingClientRect();A({top:e.top,left:e.left,width:e.width,height:e.height})}},[j,M]),(0,J.useEffect)(()=>{if(!N)return;let e=window.setTimeout(()=>A(null),it);return()=>window.clearTimeout(e)},[N]);let L=(e,t,n=!0)=>M?{layoutId:e,layout:n,layoutCrossfade:!1,layoutDependency:t===`card`?j:N?`return`:`panel`,transition:{layout:t===`card`?rt:nt}}:{},R=e=>o||s||c||a?(0,X.jsxs)(`div`,{className:Y.footer,children:[o||s||c?(0,X.jsxs)(p.div,{className:Y.byline,...L(`byline`,e,`position`),children:[o?(0,X.jsx)(`span`,{className:Y.avatar,children:o}):null,(0,X.jsxs)(`span`,{className:Y.bylineText,children:[s?(0,X.jsx)(`span`,{className:Y.meta,children:s}):null,c?(0,X.jsx)(pt,{text:c,reduced:v}):null]})]}):null,a?(0,X.jsx)(p.div,{className:Y.action,...L(`action`,e,`position`),children:a}):null]}):null,z=(0,X.jsxs)(p.article,{..._,ref:b,className:[Y.card,h].filter(Boolean).join(` `),style:{...g,borderRadius:D.card??g?.borderRadius},"data-hover":T||void 0,whileHover:v?void 0:{y:-2},onHoverStart:()=>E(!0),onHoverEnd:()=>E(!1),...L(`card`,`card`),transition:{default:et.snappy,layout:rt},children:[i?(0,X.jsx)(p.div,{className:Y.media,...L(`media`,`card`),children:(0,X.jsx)(p.div,{className:Y.zoom,initial:!1,animate:{scale:T&&!v?ot:1},transition:T?st:ct,children:i})}):null,(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(p.h3,{className:Y.title,...L(`title`,`card`),children:l?(0,X.jsx)(oe,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:Y.trigger,children:e})}):e}),t?(0,X.jsx)(p.p,{ref:S,className:Y.description,...L(`description`,`card`,`position`),children:t}):null,m,R(`card`)]})]});return l?(0,X.jsx)(se,{open:j,onOpenChange:F,children:(0,X.jsxs)(ee,{id:y,children:[z,(0,X.jsx)(n,{children:(j||N)&&(0,X.jsxs)(ue,{forceMount:!0,children:[(0,X.jsx)(n,{children:j&&(0,X.jsx)(ce,{asChild:!0,forceMount:!0,children:(0,X.jsx)(p.div,{className:Y.overlay,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:v?at:{duration:Z.exit,ease:[...$e.standard]}},transition:v?at:{duration:Z.standard,ease:[...$e.enter]}})},`overlay`)}),(0,X.jsx)(de,{asChild:!0,forceMount:!0,...t?{}:{"aria-describedby":void 0},children:(0,X.jsxs)(p.div,{className:Y.panel,"data-framer-portal-id":y,"data-returning":N||void 0,layoutScroll:!0,style:{borderRadius:D.panel,"--card-measure":D.measure?`${D.measure}px`:void 0,...k&&N?{"--landing-top":`${k.top}px`,"--landing-left":`${k.left}px`,"--landing-width":`${k.width}px`,"--landing-height":`${k.height}px`}:{}},...M?{...L(`card`,`panel`),initial:!1,animate:D.card!==void 0&&D.panel!==void 0?{borderRadius:N?D.card:D.panel}:void 0,transition:{layout:N?rt:nt,borderRadius:N?rt:nt},exit:{opacity:0,transition:{duration:0}}}:{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:at},transition:at},children:[i?(0,X.jsx)(p.div,{className:Y.media,...L(`media`,`panel`),children:(0,X.jsx)(p.div,{className:Y.zoom,initial:{scale:T&&!v?ot:1},animate:{scale:1},transition:nt,children:i})}):null,(0,X.jsx)(p.span,{className:Y.closeSlot,initial:v?{opacity:0}:{opacity:0,scale:.9},animate:N?{opacity:0,scale:.9}:{opacity:1,scale:1},transition:N||v?at:ut,children:(0,X.jsx)(Ce,{asChild:!0,children:(0,X.jsx)(p.button,{type:`button`,className:Y.close,"aria-label":`Close quick look`,whileTap:v?void 0:{scale:.94},transition:et.snappy,children:(0,X.jsx)(x,{width:16,height:16,strokeWidth:1.75,"aria-hidden":`true`})})})}),(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(_e,{asChild:!0,children:(0,X.jsx)(p.h2,{className:Y.title,...L(`title`,`panel`),children:e})}),t?(0,X.jsx)(le,{asChild:!0,children:(0,X.jsx)(p.p,{className:Y.description,...L(`description`,`panel`,`position`),children:t})}):null,m,R(`panel`),(0,X.jsx)(p.div,{className:Y.details,initial:!v&&{opacity:0,y:6},animate:N?{opacity:0,y:0}:{opacity:1,y:0},exit:{opacity:0,transition:at},transition:N||v?at:lt,children:l})]})]})})]},`quick-look`)})]})}):z}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(${i.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:i.duration.standard,ease:[...i.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${i.blur.subtle}px)`,transition:{duration:i.duration.fast,ease:[...i.ease.standard]}})},_t={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:i.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:i.duration.instant}}},vt=e=>Number(e.replace(/,/g,``).replace(/−/g,`-`).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN),yt=new Intl.NumberFormat(`en-US`),bt={duration:i.duration.considered*1.75,ease:[...i.ease.inOut]},xt={duration:i.duration.fast,ease:[...i.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:o=!1,morph:s=!1,tone:c}){let l=!!r(),d=(0,J.useRef)(null),f=u(`auto`),[m,h]=(0,J.useState)({text:e,direction:1});m.text!==e&&h({text:e,direction:t??(vt(e)<vt(m.text)?-1:1)}),(0,J.useEffect)(()=>{let e=d.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&&!l?a(f,r,i.spring.morph):f.jump(r),t=e.textContent});return n.observe(e),()=>n.disconnect()},[s,l,f]);let g=!o&&!/\p{L}/u.test(e),_=l?_t:gt,v=g?`right`:`left`;return(0,X.jsxs)(p.span,{className:Q.roll,"data-end":g||void 0,"data-whole":o||void 0,style:s?{width:f}:void 0,children:[s&&(0,X.jsx)(`span`,{ref:d,className:Q.sizer,"aria-hidden":`true`,children:e}),(0,X.jsx)(`span`,{className:Q.track,children:(0,X.jsx)(n,{mode:`popLayout`,initial:!1,custom:m.direction,anchorX:v,children:St(e,o).map(e=>(0,X.jsx)(p.span,{className:Q.slot,custom:m.direction,variants:_,initial:`hidden`,animate:`shown`,exit:`gone`,children:(0,X.jsx)(n,{mode:`popLayout`,initial:!1,custom:m.direction,anchorX:v,children:(0,X.jsx)(p.span,{className:c?`${Q.glyph} ${c}`:Q.glyph,custom:m.direction,variants:_,initial:`hidden`,animate:`shown`,exit:`gone`,children:e.text},`${c??``}${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:o,tone:s=`accent`,width:c=160,height:l=52,labels:d,formatValue:f,area:m=!0,interactive:h=!0}){let g=e.length>1?e:[e[0]??0,e[0]??0],_=g.length-1,v=g.join(`,`),y=(0,J.useMemo)(()=>Dt(v.split(`,`).map(Number)),[v]),b=`${t}: ${n??g[_]}. ${o??``}`.trim(),x=`sparkline${(0,J.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,S=(0,J.useRef)(null),C=(0,J.useRef)(null),w=Oe(S,{once:!0,amount:.5}),T=!!r(),[E,D]=(0,J.useState)({w:c,h:l}),[O,k]=(0,J.useState)(null),[A,ee]=(0,J.useState)(!1),j=O===null?null:Math.min(O,_),[M,N]=(0,J.useState)({index:j,direction:1});M.index!==j&&N({index:j,direction:j===null||M.index===null?1:Math.sign(j-M.index)||1});let[P]=(0,J.useState)(()=>kt(y,c,l,1)),F=(0,J.useRef)(y),I=(0,J.useRef)(E),L=u(0),R=u(1),z=u(P.line),te=u(P.trail),B=u(P.fill),V=u(P.dot),H=u(P.cx),U=u(P.cx+Tt+16),W=u(P.cx+Tt),ne=u(0),re=ze(L,e=>+(e>.001)),G=(0,J.useCallback)(()=>{let{w:e,h:t}=I.current,n=L.get(),r=kt(F.current,e,t,R.get());z.set(r.line),te.set(r.trail),B.set(r.fill),V.set(r.dot),H.set(r.cx),U.set(r.cx+Tt+16),W.set(r.cx+Tt),ne.set(n>=1?e+32:At(r.points,n)+16)},[R,H,W,V,L,B,z,U,ne,te]);Ge(R,`change`,G),Ge(L,`change`,G),(0,J.useLayoutEffect)(()=>{let e=C.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=e.clientWidth;t&&D(e=>Math.abs(e.w-t)<.5?e:{w:t,h:t*l/c})});return t.observe(e),()=>t.disconnect()},[l,c]),(0,J.useLayoutEffect)(()=>{I.current=E,G()},[E,G]),(0,J.useEffect)(()=>{if(T){L.jump(1);let e=requestAnimationFrame(()=>ee(!0));return()=>cancelAnimationFrame(e)}if(!w)return;let e=a(L,1,{...bt,onComplete:()=>ee(!0)});return()=>e.stop()},[L,w,T]),(0,J.useEffect)(()=>{let e=F.current;if(e===y)return;if(T){F.current=y,G();return}let t=[...new Set([...Et,...y.map(([e])=>e)])].sort((e,t)=>e-t),n=t.map(t=>Ot(e,t)),r=t.map(e=>Ot(y,e)),o=a(0,1,{...i.spring.smooth,onUpdate:e=>{F.current=t.map((t,i)=>[t,n[i]+(r[i]-n[i])*e]),G()},onComplete:()=>{F.current=y,G()}});return()=>o.stop()},[G,T,y]),(0,J.useEffect)(()=>{let e=j===null?1:j/_;if(T){R.jump(e);return}let t=a(R,e,i.spring.snappy);return()=>t.stop()},[R,j,_,T]);let K=j!==null,ie=(e=>f?f(g[e],e):yt.format(g[e]))(j??_),ae=d?.[j??_],oe=n===void 0?void 0:K?ie:n,se=j===null?o??``:n===void 0?[ie,ae].filter(Boolean).join(` · `):ae??`${j+1} of ${_+1}`,ce=e=>{let t=C.current?.getBoundingClientRect();return t?.width?Math.max(0,Math.min(_,Math.round((e-t.left)/t.width*_))):_},le=h?{role:`slider`,tabIndex:0,"aria-label":`${t}, explore values`,"aria-valuemin":1,"aria-valuemax":_+1,"aria-valuenow":(j??_)+1,"aria-valuetext":`${ae??(j===null?`Latest`:`Point ${j+1} of ${_+1}`)}: ${ie}`,onPointerDown:e=>k(ce(e.clientX)),onPointerMove:e=>{(e.pointerType===`mouse`||e.buttons)&&k(ce(e.clientX))},onPointerUp:e=>{e.pointerType!==`mouse`&&k(null)},onPointerLeave:()=>k(null),onPointerCancel:()=>k(null),onBlur:()=>k(null),onKeyDown:e=>{if(e.key===`Escape`&&K){e.preventDefault(),k(null);return}let t=j??_,n=Math.max(1,Math.round((_+1)/6)),r={ArrowLeft:t-1,ArrowDown:t-1,ArrowRight:t+1,ArrowUp:t+1,PageDown:t-n,PageUp:t+n,Home:0,End:_}[e.key];r!==void 0&&(e.preventDefault(),k(Math.max(0,Math.min(_,r))))}}:{};return(0,X.jsxs)(`figure`,{ref:S,className:Q.figure,"aria-label":b,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})}),oe!==void 0&&(0,X.jsx)(`strong`,{children:(0,X.jsx)(Ct,{text:oe,morph:!0})}),(0,X.jsx)(`small`,{className:Q[s],children:(0,X.jsx)(Ct,{text:se,direction:K?M.direction:void 0,tone:K?Q.point:void 0,morph:!0})})]}),(0,X.jsx)(`div`,{ref:C,className:Q.plot,"data-interactive":h||void 0,...le,children:(0,X.jsxs)(`svg`,{className:Q.chart,viewBox:`0 0 ${E.w} ${E.h}`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(`clipPath`,{id:`${x}-lit`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(p.rect,{x:-16,y:-16,width:U,height:E.h+32})}),(0,X.jsx)(`clipPath`,{id:`${x}-dim`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(p.rect,{x:W,y:-16,width:E.w+32,height:E.h+32})}),(0,X.jsx)(`clipPath`,{id:`${x}-fill`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(p.rect,{x:-16,y:-16,width:ne,height:E.h+32})})]}),m&&(0,X.jsx)(p.path,{className:`${Q.area} ${Q[s]}`,d:B,clipPath:`url(#${x}-fill)`}),(0,X.jsx)(`line`,{className:Q.baseline,x1:`0`,y1:E.h-.5,x2:E.w,y2:E.h-.5}),(0,X.jsx)(p.path,{className:Q.trail,d:te,clipPath:`url(#${x}-dim)`,initial:!1,animate:{opacity:K&&A?1:0},transition:T?{duration:0}:xt}),(0,X.jsx)(p.polyline,{className:[Q.line,Q[s]].join(` `),points:z,clipPath:`url(#${x}-lit)`,style:{pathLength:L,opacity:re}}),(0,X.jsx)(p.line,{className:Q.cursor,x1:H,x2:H,y1:0,y2:E.h,initial:!1,animate:{opacity:+!!K},transition:T?{duration:0}:xt}),(0,X.jsx)(p.polyline,{className:[Q.end,Q[s]].join(` `),points:V,initial:!1,animate:{opacity:+!!A,strokeWidth:A?K?10:7:0},transition:T?{duration:0}:{opacity:xt,strokeWidth:i.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:i.duration.fast,ease:[...i.ease.standard]},Ft={duration:i.duration.standard,ease:[...i.ease.enter]},It={opacity:0,y:`0.3em`,filter:Mt(i.blur.soft)},Lt={opacity:1,y:0,filter:Mt(0)},Rt={opacity:0,y:`-0.3em`,filter:Mt(i.blur.subtle)},zt={opacity:0,scale:.5,filter:Mt(i.blur.subtle)},Bt={opacity:1,scale:1,filter:Mt(0)};function Vt({text:e,className:t,reduced:r}){let o=(0,J.useRef)(null),s=(0,J.useRef)(0),c=u(`auto`);return(0,J.useLayoutEffect)(()=>{s.current=performance.now()+700},[e]),(0,J.useEffect)(()=>{let e=o.current,t=e?.parentElement;if(!e||!t||typeof ResizeObserver>`u`)return;let n=!1,l=new ResizeObserver(()=>{let t=e.offsetHeight;if(!n||r||performance.now()>s.current){n=!0,c.jump(t);return}a(c,t,i.spring.smooth)});return l.observe(e),()=>l.disconnect()},[c,r]),(0,X.jsx)(p.span,{className:$.slot,style:{height:c},children:(0,X.jsx)(`span`,{ref:o,className:$.slotInner,children:(0,X.jsx)(n,{mode:`popLayout`,initial:!1,children:e?(0,X.jsx)(p.span,{className:t,initial:It,animate:Lt,exit:{...Rt,transition:r?Nt:Pt},transition:r?Nt:Ft,children:e},`${t}:${e}`):null})})})}function Ht({kind:e,number:t,delay:n,reduced:r}){let a=r?Nt:{scale:{...i.spring.snappy,delay:n},opacity:{duration:i.duration.fast,delay:n},filter:{duration:i.duration.fast,delay:n}},o={...zt,transition:r?Nt:Pt},s=r?Nt:{duration:i.duration.standard,ease:i.ease.enter,delay:n+.04};return e===`number`?(0,X.jsx)(p.span,{className:$.glyph,initial:zt,animate:Bt,exit:o,transition:a,children:t}):(0,X.jsx)(p.svg,{className:`${$.glyph} ${$.icon}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2.5,strokeLinecap:`round`,strokeLinejoin:`round`,initial:zt,animate:Bt,exit:o,transition:a,children:e===`check`?(0,X.jsx)(p.path,{d:`M5.5 12.5l4.25 4.25L18.5 8`,initial:{pathLength:0},animate:{pathLength:1},transition:s}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(p.path,{d:`M12 6.75v6.5`,initial:{pathLength:0},animate:{pathLength:1},transition:s}),(0,X.jsx)(p.circle,{cx:12,cy:17.4,r:1.4,fill:`currentColor`,stroke:`none`,initial:{scale:0},animate:{scale:1},transition:r?Nt:{...i.spring.snappy,delay:n+.16}})]})})}function Ut({number:e,kind:t,current:r,glyphDelay:a,ringDelay:o,reduced:s}){return(0,X.jsxs)(`span`,{className:$.marker,"aria-hidden":`true`,children:[(0,X.jsx)(n,{initial:!1,children:r?(0,X.jsx)(p.span,{className:$.ring,initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:s?Nt:Pt},transition:s?Nt:{scale:{...i.spring.snappy,delay:o},opacity:{duration:i.duration.fast,delay:o}}},`ring`):null}),(0,X.jsx)(`span`,{className:$.disc,children:(0,X.jsx)(n,{initial:!1,children:(0,X.jsx)(Ht,{kind:t,number:e,delay:a,reduced:s},t)})})]})}var Wt={complete:`Completed`,current:``,upcoming:`Not started`,error:`Error`};function Gt({steps:e,current:t,orientation:n=`horizontal`,onStepSelect:a,details:o=`all`,compact:s=!1,label:c=`Progress`,completeLabel:l=`All steps complete`,className:u}){let d=r()??!1,f=e.length,m=Math.min(Math.max(Math.round(t),0),f),[h,g]=(0,J.useState)({to:m,from:m});h.to!==m&&g({to:m,from:h.to});let _=h.from,v=i.stagger.line,y=e=>d?0:m>_?e>=_&&e<m?(e-_)*v:0:e>=m&&e<_?(_-1-e)*v:0,b=d?0:Math.max(0,Math.abs(m-_)-1)*v+.12,x=!!a,S=n===`vertical`,C=m>=f?void 0:e[m];function w(e){let t=!S&&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 T=x?`nav`:`div`,E=[$.root,S?$.vertical:$.horizontal,s?$.compact:``,u].filter(Boolean).join(` `);return(0,X.jsxs)(T,{className:E,"aria-label":c,role:x?void 0:`group`,children:[(0,X.jsx)(`ol`,{className:$.list,style:S?void 0:{gridTemplateColumns:f>1?`repeat(${f-1}, minmax(0, 1fr)) auto`:`auto`},onKeyDown:x?w:void 0,children:e.map((e,t)=>{let r=t===m,s=e.error?`error`:t<m?`complete`:r?`current`:`upcoming`,c=x&&t<m,l=e.error??(o===`all`||r?e.description:void 0),u=e.error?`error`:t<m?`check`:`number`,h=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ut,{number:t+1,kind:u,current:r,glyphDelay:y(t),ringDelay:b,reduced:d}),(0,X.jsxs)(`span`,{className:$.text,children:[(0,X.jsx)(`span`,{className:$.label,children:e.label}),Wt[s]?(0,X.jsxs)(`span`,{className:$.srOnly,children:[`, `,Wt[s]]}):null,(0,X.jsx)(Vt,{text:l,className:e.error?$.error:$.description,reduced:d})]})]});return(0,X.jsxs)(`li`,{className:$.item,"data-status":s,children:[t<f-1?(0,X.jsx)(`span`,{className:$.connector,"aria-hidden":`true`,children:(0,X.jsx)(p.span,{className:$.fill,initial:!1,animate:S?{scaleY:+(t<m)}:{scaleX:+(t<m)},transition:d?Nt:{...i.spring.smooth,delay:y(t)}},n)}):null,x?(0,X.jsx)(`button`,{type:`button`,className:$.head,"data-clickable":c||void 0,"data-reachable":t<=m||void 0,"aria-current":r?`step`:void 0,"aria-disabled":!c||void 0,tabIndex:c?void 0:-1,onClick:c?()=>a?.(t):void 0,children:h}):(0,X.jsx)(`span`,{className:$.head,"aria-current":r?`step`:void 0,children:h})]},e.id)})}),S?null:(0,X.jsxs)(`span`,{className:$.caption,"aria-hidden":`true`,children:[(0,X.jsx)(Vt,{text:C?.label??l,className:$.captionLabel,reduced:d}),(0,X.jsx)(Vt,{text:C?.error??C?.description,className:C?.error?$.error:$.description,reduced:d})]}),(0,X.jsx)(`span`,{className:$.srOnly,"aria-live":`polite`,children:C?`Step ${m+1} of ${f}: ${C.label}`:l})]})}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}=P(),{toast:r}=ye(),i=ie(e),a=V(),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(new Set),[u,d]=(0,J.useState)(null);(0,J.useEffect)(()=>{i.data&&l(new Set(i.data.flatMap(e=>e.items).filter(e=>e.status===`new`).map(Jt)))},[i.data]),(0,J.useEffect)(()=>{e&&(s(``),d(null))},[e]);let f=o.trim().toLowerCase(),p=e=>!f||e.name.toLowerCase().includes(f)||e.endpoints.some(e=>e.baseUrl.toLowerCase().includes(f)),m=(0,J.useMemo)(()=>(i.data??[]).flatMap(e=>e.items).filter(e=>c.has(Jt(e))&&Yt(e)),[i.data,c]),h=(e,t)=>l(n=>{let r=new Set(n);return t?r.add(Jt(e)):r.delete(Jt(e)),r});return(0,X.jsx)(ge,{open:e,onOpenChange:t,width:680,title:n(`import.title`),description:n(`import.detail`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{icon:(0,X.jsx)(Ae,{className:`size-3.5`}),onClick:()=>void i.refetch(),disabled:i.isFetching||a.isPending,children:n(`import.rescan`)}),(0,X.jsx)(I,{variant:`primary`,disabled:m.length===0||a.isPending,onClick:()=>{d(null),a.mutate(m.map(e=>({source:e.source,ref:e.ref})),{onSuccess:e=>{let i=e.skipped.length;r(i>0?n(`import.doneSkipped`,{count:e.added.length,skipped:i}):n(`import.done`,{count:e.added.length})),t(!1)},onError:e=>{d(q(e)),i.refetch()}})},children:n(`import.selected`,{count:m.length})})]}),children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(O,{value:o,onChange:s,placeholder:n(`import.search`)}),u&&(0,X.jsx)(R,{tone:`danger`,title:n(`common.error`),children:u}),i.isLoading&&(0,X.jsx)(te,{lines:3}),i.isError&&(0,X.jsx)(R,{tone:`danger`,title:n(`common.error`),children:q(i.error)}),(0,X.jsx)(`div`,{className:`grid max-h-[460px] gap-4 overflow-auto pr-1`,children:i.data?.map(e=>(0,X.jsx)(Qt,{source:e,matches:p,selected:c,onToggle:h,filtering:f.length>0},e.id))}),(0,X.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`import.footnote`)})]})})}function Qt({source:e,matches:t,selected:n,onToggle:r,filtering:i}){let{t:a}=P(),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)(R,{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}=P(),i=Yt(e),a=e.status===`skip`&&e.skipReason?r(`import.skip.${e.skipReason}`):e.status===`same`&&e.existing?r(`import.existing`,{name:e.existing.name}):e.status===`sameHost`&&e.existing?r(`import.sameHostHint`,{name:e.existing.name}):null,o=e.endpoints.map(e=>`${Kt[e.protocol]??e.protocol} · ${Xt(e.baseUrl)}`).join(` / `);return(0,X.jsxs)(`li`,{className:A(`flex items-start gap-3 px-4 py-3`,!i&&`opacity-60`),children:[(0,X.jsx)(We,{checked:t&&i,disabled:!i,onCheckedChange:e=>n(e===!0),"aria-label":e.name}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,title:e.name,children:e.name}),(0,X.jsx)(N,{tone:qt[e.status],children:r(`import.status.${e.status}`)}),e.fromApp&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:e.fromApp})]}),o&&(0,X.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-[var(--text-muted)]`,title:o,children:o}),(0,X.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-3 text-[11px] text-[var(--text-muted)]`,children:[(0,X.jsx)(`span`,{className:`font-mono`,children:e.hasKey?e.keyMasked??`••••`:r(`import.noKey`)}),e.models.length>0&&(0,X.jsx)(`span`,{children:r(`import.models`,{count:e.models.length})}),e.templateId&&(0,X.jsx)(`span`,{children:r(`import.template`,{id:e.templateId})})]}),a&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--text-secondary,var(--text-muted))]`,children:a}),e.ignoredFields.length>0&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--warning)]`,children:r(`import.ignored`,{fields:e.ignoredFields.join(`, `)})})]})]})}var en=``,tn=`custom`,nn=[{name:`userId`,secret:!1,required:!1},{name:`accessToken`,secret:!0,required:!1}],rn={method:`GET`,url:`{{baseUrl}}/user/balance`,auth:`provider`,headers:{}},an={isValid:`is_active`,remaining:`balance`,unit:{$const:`USD`}},on=e=>JSON.stringify(e??{},null,2);function sn(e){return{enabled:e.enabled,template:e.template??en,intervalMinutes:e.intervalMinutes??null,timeoutSec:e.timeoutSec,baseUrl:e.baseUrl??``,params:{...e.params},secrets:{},method:e.request?.method??`GET`,url:e.request?.url??``,auth:e.request?.auth??`provider`,headers:on(e.request?.headers),extract:e.extract?on(e.extract):``}}function cn(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`&&!Array.isArray(t)?t:null}catch{return null}}function ln({provider:e}){let{t}=P(),{toast:n}=ye(),r=w(),i=H(e.id),a=l(e.id),o=C(),s=e.quotaConfig,c=(0,J.useMemo)(()=>sn(s),[s]),[u,d]=(0,J.useState)(c),[f,p]=(0,J.useState)(null);(0,J.useEffect)(()=>d(c),[c]);let m=r.data??[],h=m.find(e=>e.id===s.suggestedTemplate),g=u.template===en?h:m.find(e=>e.id===u.template),_=u.template===tn,v=_?nn:g?.params??[],b=e=>d(t=>({...t,...e})),x=JSON.stringify(u)!==JSON.stringify(c),E=e=>{if(e!==tn||u.url)return b({template:e});let t=g??h;b({template:e,method:t?.request.method??rn.method,url:t?.request.url??rn.url,auth:t?.request.auth??rn.auth,headers:on(t?.request.headers??rn.headers),extract:on(t?.extract??an)})},D=()=>{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(_){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},O=()=>{let r=D();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(q(e),`error`)})},onError:e=>n(q(e),`error`)})},A=()=>{let e=D();e&&a.mutate(e,{onSuccess:p,onError:e=>n(q(e),`error`)})},ee=s.effectiveIntervalMinutes>0?t(`providers.quota.intervalEvery`,{minutes:s.effectiveIntervalMinutes}):t(`providers.quota.intervalOff`),j=[{value:en,label:h?t(`providers.quota.templateAuto`,{name:h.name}):t(`providers.quota.templateNone`)},...m.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)(z,{title:t(`providers.quota.title`),footer:t(`providers.quota.footer`),children:[(0,X.jsx)(M,{label:t(`providers.quota.enable`),detail:t(`providers.quota.enableHint`),children:(0,X.jsx)(G,{checked:u.enabled,label:t(`providers.quota.enable`),onChange:e=>b({enabled:e})})}),(0,X.jsx)(M,{label:t(`providers.quota.template`),children:(0,X.jsx)(xe,{className:`w-64`,ariaLabel:t(`providers.quota.template`),value:u.template,onChange:E,options:j})}),v.map(e=>{let n=t(`providers.quota.param.${e.name}`),r=s.secrets.includes(e.name);return e.secret?(0,X.jsx)(M,{label:n,detail:r?t(`providers.quota.secretStored`):void 0,children:(0,X.jsx)(S,{type:`password`,autoComplete:`off`,className:`w-64 font-mono`,"aria-label":n,placeholder:r?`••••••••`:``,value:u.secrets[e.name]??``,onChange:t=>b({secrets:{...u.secrets,[e.name]:t.target.value}})})},e.name):(0,X.jsx)(M,{label:n,children:(0,X.jsx)(S,{className:`w-64 font-mono`,"aria-label":n,value:u.params[e.name]??``,onChange:t=>b({params:{...u.params,[e.name]:t.target.value}})})},e.name)}),v.length>0&&(0,X.jsx)(`div`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.paramsHint`)}),_&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(xe,{className:`w-28`,ariaLabel:t(`providers.quota.method`),value:u.method,onChange:e=>b({method:e}),options:[{value:`GET`,label:`GET`},{value:`POST`,label:`POST`}]}),(0,X.jsx)(S,{className:`min-w-60 flex-1 font-mono`,"aria-label":t(`providers.quota.url`),value:u.url,onChange:e=>b({url:e.target.value})}),(0,X.jsx)(xe,{className:`w-52`,ariaLabel:t(`providers.quota.auth`),value:u.auth,onChange:e=>b({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)(y,{label:t(`providers.quota.headers`),mono:!0,rows:3,value:u.headers,onChange:e=>b({headers:e.target.value})}),(0,X.jsx)(y,{label:t(`providers.quota.extract`),mono:!0,rows:8,value:u.extract,onChange:e=>b({extract:e.target.value})}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.extractHint`)})]}),(0,X.jsx)(M,{label:t(`providers.quota.interval`),detail:t(`providers.quota.intervalHint`,{value:ee}),children:(0,X.jsx)(F,{className:`w-28`,label:t(`providers.quota.interval`),min:0,step:1,value:u.intervalMinutes,onChange:e=>b({intervalMinutes:e})})}),(0,X.jsx)(M,{label:t(`providers.quota.timeout`),children:(0,X.jsx)(F,{className:`w-28`,label:t(`providers.quota.timeout`),min:1,step:1,value:u.timeoutSec,onChange:e=>b({timeoutSec:e})})}),(0,X.jsx)(M,{label:t(`providers.quota.baseUrl`),detail:t(`providers.quota.baseUrlHint`),children:(0,X.jsx)(S,{className:`w-64 font-mono`,"aria-label":t(`providers.quota.baseUrl`),placeholder:e.endpoints[0]?.baseUrl,value:u.baseUrl,onChange:e=>b({baseUrl:e.target.value})})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 py-3`,children:[(0,X.jsx)(I,{size:`sm`,variant:`primary`,disabled:!x,loading:i.isPending,onClick:O,children:t(`common.save`)}),(0,X.jsx)(I,{size:`sm`,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),loading:a.isPending,onClick:A,title:t(`providers.quota.testDesc`),children:t(`providers.quota.test`)}),(0,X.jsx)(I,{size:`sm`,icon:(0,X.jsx)(Ye,{className:`size-3.5`}),disabled:x,loading:o.isPending,onClick:()=>o.mutate(e.id,{onError:e=>n(q(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)(ge,{open:f!==null,onOpenChange:e=>!e&&p(null),title:t(`providers.quota.test`),description:t(`providers.quota.testDesc`),width:560,children:f&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(R,{tone:f.ok?`success`:`danger`,title:f.ok?t(`providers.quota.testOk`):t(`providers.quota.testFailed`),children:[!f.ok&&pe({code:f.errorCode??null,message:f.error??``},t),!f.ok&&f.error&&f.errorCode&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] opacity-80`,children:f.error})]}),f.url&&(0,X.jsx)(T,{label:t(`providers.quota.requestUrl`),mono:!0,children:f.url}),f.httpStatus!=null&&(0,X.jsx)(T,{label:t(`providers.quota.httpStatus`),children:f.httpStatus}),f.snapshot&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[12px] text-[var(--text-secondary)]`,children:t(`providers.quota.extracted`)}),(0,X.jsx)(un,{snapshot:f.snapshot})]}),f.raw!==void 0&&f.raw!==null&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[12px] text-[var(--text-secondary)]`,children:t(`providers.quota.rawResponse`)}),(0,X.jsx)(k,{children:on(f.raw)})]})]})})]})}function un({snapshot:e,checkedAtUtc:t}){let{t:n,locale:r}=P(),i=be(e),a=e?.plans??[],o=e?.fetchedAtUtc?new Date(e.fetchedAtUtc).getTime():0;return!e&&!t?(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`providers.quota.never`)}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i&&(0,X.jsxs)(R,{tone:`warning`,title:n(`providers.quota.failed`,{error:pe(i,n)}),children:[(0,X.jsx)(`span`,{className:`text-[11px]`,children:i.message}),a.length>0&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px]`,children:n(`providers.quota.lastGood`)})]}),e?.isValid===!1&&(0,X.jsx)(R,{tone:`warning`,title:n(`providers.quota.invalid`),children:e.invalidMessage}),a.length>0&&(0,X.jsx)(`div`,{className:`flex flex-col gap-1`,children:a.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 text-[13px]`,children:[e.name&&(0,X.jsx)(N,{children:e.name}),(0,X.jsx)(`span`,{className:`num`,children:Se(e,n,r)??`—`}),me(e,n,r)&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:me(e,n,r)}),e.extra&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:e.extra})]},t))}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-[var(--text-muted)]`,children:[e?.planLabel&&(0,X.jsx)(N,{tone:`accent`,children:e.planLabel}),o>0&&(0,X.jsx)(`span`,{children:n(`providers.quota.fetchedAt`,{time:fe(o,r,n(`tray.justNow`))??``})})]})]})}function dn({provider:e}){let{t,locale:n}=P(),{toast:r}=ye(),i=C();if(!he(e))return null;let a=ve(e.quota,t,n),o=be(e.quota);return(0,X.jsxs)(`div`,{className:`mt-3 flex min-w-0 items-center gap-2 text-[12px]`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a&&(0,X.jsx)(`div`,{className:`num truncate text-[var(--text-secondary)]`,title:a,children:a}),o&&(0,X.jsx)(`div`,{className:`truncate text-[var(--warning)]`,title:o.message,children:t(`providers.quota.failed`,{error:pe(o,t)})}),!a&&!o&&(0,X.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:t(`providers.quota.never`)})]}),(0,X.jsx)(I,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(Ye,{className:`size-3.5`}),"aria-label":t(`providers.quota.refresh`),title:t(`providers.quota.refresh`),loading:i.isPending,onClick:()=>i.mutate(e.id,{onError:e=>r(q(e),`error`)})})]})}var fn=3,pn=256,mn=4096,hn={idle:`providers.testDialog.status.idle`,queued:`providers.testDialog.status.queued`,running:`providers.testDialog.status.running`,success:`providers.testDialog.status.success`,failed:`providers.testDialog.status.failed`,cancelled:`providers.testDialog.status.cancelled`};function gn(e){let t=e.endpoints.map(e=>e.protocol);return e.preferredUpstreamProtocols.find(e=>t.includes(e))??t[0]??`openai-chat`}var _n=e=>typeof e==`number`?e:null,vn=e=>typeof e==`string`?e:null;function yn({provider:e,open:t,onOpenChange:n}){let{t:r}=P(),i=v(),a=d(t?e.id:void 0),o=e.endpoints.map(e=>e.protocol),[s,c]=(0,J.useState)(`single`),[l,u]=(0,J.useState)(()=>gn(e)),[f,p]=(0,J.useState)(!0),[m,h]=(0,J.useState)(``),[g,y]=(0,J.useState)(pn),[b,S]=(0,J.useState)(``),[C,w]=(0,J.useState)(null),[T,E]=(0,J.useState)({}),[D,O]=(0,J.useState)([]),[k,A]=(0,J.useState)(new Set),[ee,M]=(0,J.useState)([]),[N,F]=(0,J.useState)(``),[L,R]=(0,J.useState)(null),[z,te]=(0,J.useState)(!1),B=(0,J.useRef)(null),V=(0,J.useRef)(new Map),H=(0,J.useRef)(!1),U=(0,J.useRef)(!1),W=(0,J.useMemo)(()=>{let e=[...a.data??[]].sort((e,t)=>Number(t.enabled)-Number(e.enabled)||e.sortOrder-t.sortOrder).map(e=>e.modelId);return[...e,...ee.filter(t=>!e.includes(t))]},[a.data,ee]);(0,J.useEffect)(()=>{if(t){S(e=>e||(a.data??[]).find(e=>e.enabled)?.modelId||(a.data??[])[0]?.modelId||``);return}U.current=!1,B.current?.abort();for(let e of V.current.values())e.abort();V.current.clear(),w(null),E({}),O([]),A(new Set),M([]),F(``),R(null)},[t,a.data]);let ne=(0,J.useCallback)(e=>({modelId:e,protocol:l,stream:f,prompt:m.trim()||null,maxOutputTokens:g??pn}),[l,f,m,g]),re=(0,J.useCallback)((t,n,r)=>On(e.id,t,ne(t),n,r),[e.id,ne]),G=()=>{let e=b.trim();if(!e)return;B.current?.abort();let t=new AbortController;B.current=t,U.current=!0,R(null),w({modelId:e,status:`running`,text:``,reasoning:``}),re(e,t.signal,e=>{e.status!==`running`&&e.status!==`queued`&&ie(),w(e)})},K=e=>{if(e.length===0)return;U.current=!0,H.current=!1,R(null),O(e),E(Object.fromEntries(e.map(e=>[e,{modelId:e,status:`queued`,text:``,reasoning:``}])));let t=0;Promise.all(Array.from({length:Math.min(fn,e.length)},async()=>{for(;;){if(!U.current)return;let n=e[t++];if(n===void 0)return;if(H.current){E(e=>({...e,[n]:{...e[n],status:`cancelled`}}));continue}let r=new AbortController;V.current.set(n,r),await re(n,r.signal,e=>E(t=>({...t,[n]:e}))),V.current.delete(n),ie()}}))},ie=()=>void i.invalidateQueries({queryKey:[`requests`]}),ae=()=>{H.current=!0,E(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.status===`queued`?{...t,status:`cancelled`}:t])))},oe=C?.status===`running`||D.some(e=>T[e]?.status===`running`||T[e]?.status===`queued`&&!H.current),se=D.filter(e=>T[e]&&T[e].status!==`queued`&&T[e].status!==`running`).length,ce=D.filter(e=>T[e]?.status===`success`).length,le=D.filter(e=>T[e]?.status===`failed`).length,ue=(e,t)=>A(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),de=()=>{oe||n(!1)},fe=e=>e.stopPropagation();return(0,X.jsx)(`span`,{onClick:fe,onKeyDown:fe,children:(0,X.jsxs)(ge,{open:t,onOpenChange:e=>e?n(!0):de(),width:1040,title:r(`providers.testDialog.title`,{name:e.name}),description:r(`providers.testDialog.subtitle`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mr-auto text-[11px] text-[var(--text-muted)]`,children:r(`providers.testDialog.realRequest`)}),(0,X.jsx)(I,{disabled:oe,onClick:()=>n(!1),icon:(0,X.jsx)(x,{className:`size-3.5`}),children:r(`common.close`)}),s===`single`?oe?(0,X.jsx)(I,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:()=>B.current?.abort(),children:r(`providers.testDialog.stop`)}):(0,X.jsx)(I,{variant:`primary`,disabled:b.trim()===``,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:G,children:r(C?`providers.testDialog.retest`:`providers.testDialog.start`)}):oe?(0,X.jsx)(I,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:ae,children:r(`providers.testDialog.stopRest`)}):(0,X.jsx)(I,{variant:`primary`,disabled:k.size===0,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:()=>K([...k]),children:r(`providers.testDialog.testN`,{count:k.size})})]}),children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pb-4`,children:[(0,X.jsx)(Ue,{name:e.name,icon:e.icon,colorKey:e.templateId,size:32}),(0,X.jsx)(_,{items:[{value:`single`,label:r(`providers.testDialog.modeSingle`)},{value:`batch`,label:r(`providers.testDialog.modeBatch`)}],value:s,onChange:e=>{c(e),R(null)},ariaLabel:r(`providers.testDialog.config`)})]}),s===`single`?(0,X.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,300px)_minmax(0,1fr)] gap-6`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 border-r border-[var(--border)] pr-6`,children:[(0,X.jsx)(`h3`,{className:`text-[13px] font-medium`,children:r(`providers.testDialog.config`)}),(0,X.jsx)(j,{label:r(`providers.testDialog.model`),children:(0,X.jsx)(bn,{value:b,models:W,onChange:S})}),(0,X.jsx)(xn,{protocols:o,protocol:l,onProtocol:u,stream:f,onStream:p,maxTokens:g,onMaxTokens:y,prompt:m,onPrompt:h}),(0,X.jsx)(`p`,{className:`mt-auto text-[11px] text-[var(--text-muted)]`,children:r(`providers.testDialog.savedCredentials`)})]}),(0,X.jsx)(Sn,{run:C,onRetest:G})]}):L===null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(En,{known:W,selected:k,onToggle:ue,onSelectAll:e=>A(e?new Set(W):new Set),onClear:()=>A(new Set),search:N,onSearch:F,onAdd:e=>{M(t=>t.includes(e)?t:[...t,e]),A(t=>new Set(t).add(e)),F(``)},configOpen:z,onConfigOpen:te,protocols:o,protocol:l,onProtocol:u,stream:f,onStream:p,maxTokens:g,onMaxTokens:y,prompt:m,onPrompt:h}),D.length>0?(0,X.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:oe?r(`providers.testDialog.progress`,{done:se,total:D.length,ok:ce,failed:le}):r(`providers.testDialog.progressDone`,{total:D.length,ok:ce,failed:le})}),(0,X.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-strong)]`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full transition-[width]`,style:{width:`${se/D.length*100}%`,background:`var(--accent)`}})})]}):null,D.length>0?(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Dn,{order:D,runs:T,onView:R})}):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)(I,{variant:`plain`,icon:(0,X.jsx)(we,{className:`size-4`}),"aria-label":r(`common.back`),onClick:()=>R(null)}),(0,X.jsx)(`span`,{className:`font-mono text-[13px]`,children:L})]}),(0,X.jsx)(Sn,{run:T[L]??null})]})]})})}function bn({value:e,models:t,onChange:n}){let{t:r}=P(),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(0),[c,l]=(0,J.useState)(null),u=c===null?t:t.filter(e=>e.toLowerCase().includes(c.trim().toLowerCase())),d=()=>{l(null),s(Math.max(0,t.indexOf(e))),a(!0)},f=e=>{n(e),l(null),a(!1)};return(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(S,{className:`pr-9 font-mono`,value:e,placeholder:r(`providers.testDialog.modelPlaceholder`),"aria-expanded":i,role:`combobox`,onFocus:d,onClick:d,onChange:e=>{n(e.target.value),l(e.target.value),s(0),a(!0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!i)return d();if(u.length===0)return;let t=e.key===`ArrowDown`?1:-1;s(e=>(e+t+u.length)%u.length)}else e.key===`Enter`&&i?(e.preventDefault(),u[o]&&f(u[o])):e.key===`Escape`&&a(!1)}}),(0,X.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 grid w-8 place-items-center text-[var(--text-muted)] hover:text-[var(--text)]`,"aria-label":r(`providers.testDialog.showModels`),onClick:()=>i?a(!1):d(),children:(0,X.jsx)(D,{className:`size-4`})}),i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`fixed inset-0 z-40`,onMouseDown:()=>a(!1)}),(0,X.jsx)(`ul`,{className:`absolute inset-x-0 top-full z-50 mt-1 max-h-64 overflow-auto rounded-lg border border-[var(--border)] bg-[var(--surface-raised)] py-1 shadow-lg`,children:u.length===0?(0,X.jsx)(`li`,{className:`px-3 py-2 text-[12px] text-[var(--text-muted)]`,children:r(`providers.testDialog.noModels`)}):u.map((e,t)=>(0,X.jsx)(`li`,{children:(0,X.jsx)(`button`,{type:`button`,className:A(`block w-full truncate px-3 py-1.5 text-left font-mono text-[12px] hover:bg-[var(--surface-strong)]`,t===o&&`bg-[var(--surface-strong)]`),onMouseEnter:()=>s(t),onMouseDown:t=>{t.preventDefault(),f(e)},children:e})},e))})]})]})}function xn({protocols:e,...t}){let{t:n}=P(),r=e.map(e=>({value:e,label:jn.find(t=>t.value===e)?.label??e}));return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{label:n(`providers.testDialog.protocol`),children:(0,X.jsx)(xe,{value:t.protocol,onChange:t.onProtocol,options:r})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:n(`providers.testDialog.stream`)}),(0,X.jsx)(G,{checked:t.stream,label:n(`providers.testDialog.stream`),onChange:t.onStream})]}),(0,X.jsx)(j,{label:n(`providers.testDialog.maxTokens`),children:(0,X.jsx)(F,{value:t.maxTokens,min:1,placeholder:String(pn),label:n(`providers.testDialog.maxTokens`),onChange:e=>t.onMaxTokens(e===null?null:Math.min(mn,Math.max(1,Math.round(e))))})}),(0,X.jsx)(j,{label:n(`providers.testDialog.prompt`),hint:n(`providers.testDialog.promptHint`),children:(0,X.jsx)(y,{rows:4,value:t.prompt,placeholder:`Reply with OK.`,onChange:e=>t.onPrompt(e.target.value)})})]})}function Sn({run:e,onRetest:t}){let{t:n}=P(),[r,i]=(0,J.useState)(`preview`),a=e?.text??``,o=e?.raw??``,s=Object.entries(e?.headers??{}),c=e?.ttftMs!=null&&e?.httpMs!=null?Math.max(0,e.ttftMs-e.httpMs):null,l=r===`raw`?o:r===`headers`?s.map(([e,t])=>`${e}: ${t}`).join(`
2
- `):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)(I,{size:`sm`,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:t,children:n(`providers.testDialog.retest`)}):null,(0,X.jsx)(Be,{content:n(`providers.testDialog.metricsHelp`),children:(0,X.jsx)(`span`,{className:`inline-flex size-4 items-center justify-center text-[var(--text-muted)]`,tabIndex:0,children:(0,X.jsx)(qe,{className:`size-4`})})}),(0,X.jsx)(Tn,{run:e}),e?.httpStatus?(0,X.jsxs)(N,{tone:`neutral`,children:[`HTTP `,e.httpStatus]}):null]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-px overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--border)] sm:grid-cols-4`,children:[(0,X.jsx)(wn,{label:n(`providers.testDialog.metrics.http`),value:e?.httpMs}),(0,X.jsx)(wn,{label:n(`providers.testDialog.metrics.firstWait`),value:c}),(0,X.jsx)(wn,{label:n(`providers.testDialog.metrics.ttft`),value:e?.ttftMs}),(0,X.jsx)(wn,{label:n(`providers.testDialog.metrics.total`),value:e?.totalMs})]}),(0,X.jsxs)(`section`,{className:`card overflow-hidden`,children:[(0,X.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2 border-b border-[var(--border)] px-4 py-2.5`,children:[(0,X.jsx)(`h3`,{className:`text-[12px] font-medium`,children:n(`providers.testDialog.reply`)}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,X.jsx)(_,{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)(W,{value:l,label:n(r===`headers`?`providers.testDialog.headers`:`providers.testDialog.reply`),iconOnly:!0})]})]}),(0,X.jsx)(`div`,{className:`h-[360px] overflow-auto px-4 py-3`,children:r===`headers`?s.length===0?(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`providers.testDialog.headersEmpty`)}):(0,X.jsx)(`table`,{className:`w-full text-[11px]`,children:(0,X.jsx)(`tbody`,{children:s.map(([e,t])=>(0,X.jsxs)(`tr`,{className:`border-b border-[var(--border)] last:border-0 align-top`,children:[(0,X.jsx)(`th`,{className:`w-[220px] py-1.5 pr-4 text-left font-mono font-normal text-[var(--text-secondary)]`,children:e}),(0,X.jsx)(`td`,{className:`py-1.5 font-mono break-all whitespace-pre-wrap selectable`,children:t})]},e))})}):r===`raw`?o?(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsxs)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:[n(`providers.testDialog.rawNote`),e?.contentType?` · ${e.contentType}`:``]}),(0,X.jsx)(`pre`,{className:`font-mono text-[11px] leading-[1.6] break-all whitespace-pre-wrap selectable`,children:o}),e?.rawTruncated?(0,X.jsx)(`p`,{className:`text-[11px] text-[var(--warning)]`,children:n(`providers.testDialog.rawTruncated`)}):null]}):(0,X.jsx)(Cn,{run:e}):e?.error?(0,X.jsx)(R,{tone:`danger`,title:n(`providers.testDialog.status.failed`),children:e.error}):a||e?.reasoning?(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[e?.reasoning?(0,X.jsxs)(`div`,{className:`rounded-md border border-[var(--border)] bg-[var(--surface-strong)] p-3`,children:[(0,X.jsx)(`div`,{className:`mb-1 text-[11px] text-[var(--text-muted)]`,children:n(`providers.testDialog.reasoning`)}),(0,X.jsx)(`pre`,{className:`font-mono text-[11px] leading-[1.6] whitespace-pre-wrap selectable`,children:e.reasoning})]}):null,a?(0,X.jsx)(`pre`,{className:`font-mono text-[12px] leading-[1.7] break-words whitespace-pre-wrap selectable`,children:a}):null]}):e?.status===`success`?(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`providers.testDialog.noText`)}):(0,X.jsx)(Cn,{run:e})})]})]})}function Cn({run:e}){let{t}=P();return e?.status===`running`||e?.status===`queued`?(0,X.jsx)(`div`,{className:`grid h-full place-items-center text-[12px] text-[var(--text-muted)]`,children:t(hn[e.status])}):(0,X.jsxs)(`div`,{className:`grid h-full place-items-center content-center gap-2 text-center`,children:[(0,X.jsx)(He,{className:`mx-auto size-6 text-[var(--text-muted)]`}),(0,X.jsx)(`div`,{className:`text-[13px]`,children:t(`providers.testDialog.emptyTitle`)}),(0,X.jsx)(`p`,{className:`mx-auto max-w-[320px] text-[11px] text-[var(--text-muted)]`,children:t(`providers.testDialog.emptyDetail`)})]})}function wn({label:e,value:t}){return(0,X.jsxs)(`div`,{className:`bg-[var(--surface)] px-4 py-3`,children:[(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:e}),(0,X.jsx)(`div`,{className:`mt-1 font-mono text-[15px] tabular-nums`,children:t==null?`—`:m(t)})]})}function Tn({run:e}){let{t}=P(),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)(L,{tone:n===`success`?`green`:n===`failed`?`red`:n===`running`?`orange`:`neutral`}),t(hn[n])]})}function En({known:e,selected:t,onToggle:n,onSelectAll:r,onClear:i,search:a,onSearch:o,onAdd:s,configOpen:c,onConfigOpen:l,...u}){let{t:d}=P(),f=a.trim(),p=f.toLowerCase(),m=p?e.filter(e=>e.toLowerCase().includes(p)):e,h=f!==``&&!e.some(e=>e.toLowerCase()===p);return(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-[12px] text-[var(--text-secondary)]`,children:d(`providers.testDialog.selected`,{n:t.size,total:e.length})}),(0,X.jsx)(`div`,{className:`min-w-[220px] flex-1`,children:(0,X.jsx)(O,{value:a,onChange:o,placeholder:d(`providers.testDialog.searchModels`)})}),(0,X.jsx)(I,{variant:`plain`,disabled:t.size===0,onClick:i,children:d(`providers.testDialog.clearSelection`)}),(0,X.jsx)(I,{icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:()=>l(!0),children:d(`providers.testDialog.config`)})]}),(0,X.jsx)(`div`,{className:`card max-h-[420px] overflow-auto`,children:m.length===0&&!h?(0,X.jsx)(`p`,{className:`px-4 py-6 text-center text-[12px] text-[var(--text-muted)]`,children:d(`providers.testDialog.noModels`)}):(0,X.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2`,children:[(0,X.jsx)(We,{checked:t.size===e.length&&e.length>0||t.size!==0&&`indeterminate`,onCheckedChange:e=>r(e!==!1),"aria-label":d(`providers.testDialog.clearSelection`)}),(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:d(`providers.testDialog.ownFilter`)})]}),h?(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,X.jsx)(je,{className:`size-3.5 shrink-0 text-[var(--accent)]`}),(0,X.jsx)(`button`,{type:`button`,className:`text-left font-mono text-[12px] text-[var(--accent)]`,onClick:()=>s(f),children:d(`providers.testDialog.addModel`,{id:f})})]}):null,m.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,X.jsx)(We,{checked:t.has(e),onCheckedChange:t=>n(e,t!==!1),"aria-label":e}),(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[12px]`,title:e,children:e})]},e))]})}),(0,X.jsx)(ge,{open:c,onOpenChange:l,width:480,title:d(`providers.testDialog.config`),description:d(`providers.testDialog.savedCredentials`),children:(0,X.jsx)(`div`,{className:`grid gap-4`,children:(0,X.jsx)(xn,{...u})})})]})}function Dn({order:e,runs:t,onView:n}){let{t:r}=P();return(0,X.jsx)(`div`,{className:`card overflow-hidden`,children:(0,X.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-[var(--border)] text-left text-[11px] text-[var(--text-muted)]`,children:[(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.model`)}),(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.statusColumn`)}),(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.metrics.ttft`)}),(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.metrics.total`)}),(0,X.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.reply`)})]})}),(0,X.jsx)(`tbody`,{children:e.map(e=>{let i=t[e];return(0,X.jsxs)(`tr`,{className:`border-b border-[var(--border)] last:border-0`,children:[(0,X.jsx)(`td`,{className:`px-4 py-2 font-mono`,children:e}),(0,X.jsx)(`td`,{className:`px-4 py-2`,children:(0,X.jsx)(Tn,{run:i??null})}),(0,X.jsx)(`td`,{className:`px-4 py-2 font-mono tabular-nums`,children:i?.ttftMs==null?`—`:m(i.ttftMs)}),(0,X.jsx)(`td`,{className:`px-4 py-2 font-mono tabular-nums`,children:i?.totalMs==null?`—`:m(i.totalMs)}),(0,X.jsx)(`td`,{className:`px-4 py-2`,children:(0,X.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] disabled:text-[var(--text-muted)]`,disabled:!i,onClick:()=>n(e),children:r(`providers.testDialog.view`)})})]},e)})})]})})}async function On(e,t,n,r,i){let a={modelId:t,status:`running`,text:``,reasoning:``};i(a);let o=e=>{a={...a,...e},i(a)};try{await ne(e,n,e=>{let t=e.data??{};switch(e.event){case`headers`:o({httpStatus:_n(t.httpStatus),httpMs:_n(t.httpMs),contentType:vn(t.contentType),headers:kn(t.headers)});break;case`delta`:{let e=vn(t.text)??``;vn(t.kind)===`reasoning`?o({reasoning:a.reasoning+e}):o({text:a.text+e});break}case`done`:{let t=e.data;o({status:t.ok?`success`:`failed`,error:t.error??null,httpStatus:t.httpStatus??null,httpMs:t.httpMs??null,ttftMs:t.ttftMs??null,totalMs:t.totalMs??null,text:t.text??``,reasoning:t.reasoning??``,raw:t.raw??``,rawTruncated:t.rawTruncated??!1,contentType:t.contentType??null,headers:kn(t.headers)});break}}},r)}catch(e){e?.name===`AbortError`?o({status:`cancelled`,error:null}):o({status:`failed`,error:e instanceof E?e.message:String(e)})}}function kn(e){if(typeof e!=`object`||!e)return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`string`?t[n]=r:r!=null&&(t[n]=String(r));return t}var An=re({AUTH_OPTIONS:()=>Mn,PROTOCOL_OPTIONS:()=>jn,ProvidersPage:()=>Nn}),jn=[{value:`openai-chat`,label:`OpenAI Chat`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic`,label:`Anthropic Messages`},{value:`gemini`,label:`Gemini`}],Mn=[{value:`bearer`,label:`Authorization: Bearer`},{value:`x-api-key`,label:`x-api-key`},{value:`x-goog-api-key`,label:`x-goog-api-key`},{value:`query-key`,label:`?key=`},{value:`none`,label:`—`},{value:`oauth-subscription`,label:`OAuth 订阅`}];function Nn(){let{t}=P(),n=Ie(),[r,i]=Pe(),a=e(),[o,s]=(0,J.useState)(r.get(`new`)===`1`),[c,l]=(0,J.useState)(!1);(0,J.useEffect)(()=>{r.get(`new`)===`1`&&(s(!0),r.delete(`new`),i(r,{replace:!0}))},[r,i]),ke(e=>{e===`new-provider`&&s(!0)});let u=ae(`7d`,`day`,`provider`),[d,f]=(0,J.useState)(null),p=(0,J.useMemo)(()=>{let e=Fn(Pn),t=new Map;for(let n of u.data??[]){let r=e.indexOf(n.bucket);if(r<0)continue;let i=t.get(n.key);i||t.set(n.key,i={requests:e.map(()=>0),costUsd:0}),i.requests[r]=(i.requests[r]??0)+n.requests,i.costUsd+=n.costUsd}return{days:e,byProvider:t}},[u.data]);return(0,X.jsxs)(Ve,{title:t(`nav.providers`),subtitle:a.data?t(`providers.count`,{count:a.data.length}):void 0,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{icon:(0,X.jsx)(Te,{className:`size-3.5`}),onClick:()=>l(!0),children:t(`providers.import`)}),(0,X.jsx)(I,{variant:`primary`,icon:(0,X.jsx)(je,{className:`size-3.5`}),onClick:()=>s(!0),children:t(`providers.add`)})]}),children:[(0,X.jsxs)(`div`,{className:`mx-auto max-w-[1100px]`,children:[a.isLoading&&(0,X.jsx)(te,{lines:4}),a.isError&&(0,X.jsx)(R,{tone:`danger`,title:t(`common.error`),children:q(a.error)}),a.data?.length===0&&(0,X.jsx)(`div`,{className:`card`,children:(0,X.jsx)(b,{icon:(0,X.jsx)(Ne,{className:`size-6`}),title:t(`providers.empty`),detail:t(`providers.emptyDetail`),action:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,X.jsx)(I,{variant:`primary`,icon:(0,X.jsx)(je,{className:`size-3.5`}),onClick:()=>s(!0),children:t(`providers.add`)}),(0,X.jsx)(I,{icon:(0,X.jsx)(Te,{className:`size-3.5`}),onClick:()=>l(!0),children:t(`providers.import`)})]})})}),a.data&&a.data.length>0&&(0,X.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,260px),1fr))] gap-3`,children:a.data.map(e=>(0,X.jsx)(Rn,{p:e,days:p.days,usage:p.byProvider.get(e.name),onOpen:()=>n(`/providers/${e.id}`),onTest:()=>f(e)},e.id))})]}),(0,X.jsx)(Zt,{open:c,onOpenChange:l}),(0,X.jsx)(Gn,{open:o,onOpenChange:s,onCreated:e=>n(`/providers/${e.id}`)}),d&&(0,X.jsx)(yn,{provider:d,open:!0,onOpenChange:e=>!e&&f(null)})]})}var Pn=7;function Fn(e){let t=new Date;return Array.from({length:e},(n,r)=>{let i=new Date(t.getFullYear(),t.getMonth(),t.getDate()-(e-1-r));return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,`0`)}-${String(i.getDate()).padStart(2,`0`)}`})}function In(e){if(!e)return null;try{return new URL(e).host}catch{return e}}var Ln=e=>e.stopPropagation();function Rn({p:e,days:n,usage:r,onOpen:i,onTest:a}){let{t:o}=P(),s=t(e.id),{toast:l}=ye(),u=[...new Set(e.endpoints.map(e=>e.protocol))],d=!e.hasApiKey&&e.authScheme!==`none`&&e.authScheme!==`oauth-subscription`&&e.authScheme!==`plugin`,f=[e.priceKey?o(`providers.priceKeyShort`,{key:e.priceKey}):null,e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `),p=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`),m=e.enabled?d?{tone:`orange`,label:o(`providers.noKey`)}:{tone:`green`,label:o(`providers.card.active`)}:{tone:`neutral`,label:o(`providers.card.disabled`)},h=r?.requests??n.map(()=>0),_=h.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:i,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},style:{backgroundColor:`var(--surface)`},title:e.name,description:u.map(e=>jn.find(t=>t.value===e)?.label??e).join(` / `),media:(0,X.jsxs)(`div`,{className:`flex flex-col justify-between gap-1.5 self-stretch justify-self-stretch px-3 py-2.5`,style:{background:`linear-gradient(135deg, color-mix(in oklab, var(--accent) 12%, transparent), transparent 70%)`},children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:A(`transition-[filter,opacity]`,!e.enabled&&`opacity-50 grayscale`),children:(0,X.jsx)(Ue,{name:e.name,icon:e.icon,colorKey:e.templateId,size:28})}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-[var(--border)] bg-[color-mix(in_oklab,var(--surface)_80%,transparent)] px-2 py-0.5 text-[11px] text-[var(--text-secondary)]`,children:[(0,X.jsx)(L,{tone:m.tone}),m.label]})]}),(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[11px] text-[var(--text-muted)]`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:e.endpoints[0]?.baseUrl,children:In(e.endpoints[0]?.baseUrl)??`—`}),(0,X.jsx)(`span`,{className:`shrink-0`,children:o(`providers.modelCount`,{count:e.modelCount})})]})]}),meta:(0,X.jsx)(`span`,{className:A(e.hasApiKey&&e.authScheme!==`oauth-subscription`&&`font-mono`),children:p}),status:f||void 0,action:(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,onClick:Ln,children:[(0,X.jsx)(I,{variant:`plain`,size:`sm`,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),"aria-label":o(`providers.test`),title:o(`providers.test`),onClick:a}),(0,X.jsx)(`span`,{className:`ml-1 inline-flex`,children:(0,X.jsx)(G,{checked:e.enabled,label:o(`common.enabled`),onChange:e=>s.mutate({enabled:e},{onError:e=>l(q(e),`error`)})})})]}),children:[(0,X.jsxs)(`div`,{className:`mt-1.5 flex h-5 flex-nowrap items-center gap-1 overflow-hidden`,children:[e.templateUpdateAvailable&&(0,X.jsx)(N,{tone:`accent`,children:o(`providers.templateUpdate`)}),e.boundClients.slice(0,v).map(e=>e in Le?(0,X.jsx)(`span`,{title:Fe(e),className:`inline-flex shrink-0`,children:(0,X.jsx)(Re,{kind:e,size:18})},e):(0,X.jsx)(N,{tone:`green`,children:e},e)),e.boundClients.length>v&&(0,X.jsxs)(`span`,{title:e.boundClients.slice(v).map(e=>Le[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:Ln,children:(0,X.jsx)(dn,{provider:e})}),(0,X.jsx)(`div`,{className:`mt-2`,onClick:Ln,children:_>0?(0,X.jsx)(jt,{label:o(`providers.card.requests7d`),data:h,labels:n.map(e=>e.slice(5)),value:c(_,!0),change:g(r?.costUsd??0),width:320,height:28,formatValue:e=>c(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 zn=`plugin:`,Bn=[`recommended`,`official`,`subscription`,`coding`,`cn`,`aggregator`,`inference`,`local`,`custom`],Vn={"openai-chat":`Chat`,"openai-responses":`Responses`,anthropic:`Anthropic`,gemini:`Gemini`},Hn=e=>jn.find(t=>t.value===e)?.label??e,Un=e=>(0,X.jsx)(`span`,{title:e,children:e}),Wn=e=>{let t=/^(.+?)\s*[((]([^()()]+)[))]$/.exec(e);return t?[t[1],t[2]]:[e,null]};function Gn({open:t,onOpenChange:n,onCreated:r}){let{t:i}=P(),{toast:a}=ye(),c=s(),l=o(),u=h(),d=e(),f=(0,J.useMemo)(()=>new Set((d.data??[]).filter(e=>e.authScheme===`oauth-subscription`&&e.templateId).map(e=>e.templateId)),[d.data]),p=Ie(),[m,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(null),[y,b]=(0,J.useState)(null),[x,C]=(0,J.useState)(``),[w,T]=(0,J.useState)(``),[E,D]=(0,J.useState)(``),[k,A]=(0,J.useState)(``),[ee,M]=(0,J.useState)(``),[N,F]=(0,J.useState)(`openai-chat`),[L,z]=(0,J.useState)(`bearer`);(0,J.useEffect)(()=>{t||(v(null),b(null),g(``),C(``),T(``),D(``),A(``),M(``))},[t]);let B=(0,J.useMemo)(()=>{let e=m.trim().toLowerCase(),t=(c.data??[]).filter(t=>!e||t.name.toLowerCase().includes(e)||t.id.includes(e));return Bn.map(e=>({category:e,items:t.filter(t=>t.category===e)})).filter(e=>e.items.length)},[c.data,m]),V=(0,J.useMemo)(()=>{let e=m.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,m]),H=e=>{v(e),e===`custom`?(C(``),A(``),D(``)):(C(e.name),A(e.priceKey??e.id),D(``),z(e.auth.scheme))},U=()=>{let e=_===`custom`;u.mutate({templateId:e?null:_.id,variantId:E||null,name:x.trim()||null,apiKey:w.trim()||null,priceKey:k,...e?{endpoints:[{protocol:N,baseUrl:ee.trim()}],authScheme:L}:{}},{onSuccess:e=>{n(!1),a(i(`providers.created`,{name:e.name}),`success`),r(e)},onError:e=>a(q(e),`error`)})},W=_&&_!==`custom`?_:null,ne=()=>{if(y===`custom`)H(`custom`);else if(y?.startsWith(zn)){let e=V.find(e=>zn+e.id===y);e&&(n(!1),r(e))}else{let e=(c.data??[]).find(e=>e.id===y);e&&!f.has(e.id)&&H(e)}},re=_!==null&&(_===`custom`?/^https?:\/\//.test(ee.trim())&&x.trim()!==``:!W.requiresApiKey||w.trim()!==``);return(0,X.jsxs)(ge,{open:t,onOpenChange:n,width:640,title:i(_?`providers.addTitleDetails`:`providers.addTitle`),description:_?W?W.name:i(`providers.custom`):i(`providers.addDetail`),footer:_?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{className:`mr-auto`,variant:`plain`,onClick:()=>v(null),children:i(`common.back`)}),(0,X.jsx)(I,{onClick:()=>n(!1),children:i(`common.cancel`)}),(0,X.jsx)(I,{variant:`primary`,disabled:!re,loading:u.isPending,onClick:U,children:i(`providers.create`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{onClick:()=>n(!1),children:i(`common.cancel`)}),(0,X.jsx)(I,{variant:`primary`,disabled:!y,onClick:ne,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)(j,{label:i(`providers.name`),children:(0,X.jsx)(S,{value:x,onChange:e=>C(e.target.value)})}),W?.variants&&W.variants.length>0&&(0,X.jsx)(j,{label:i(`providers.variant`),children:(0,X.jsx)(xe,{value:E,onChange:e=>{D(e);let t=W.variants?.find(t=>t.id===e);A(t?.priceKey??W.priceKey??W.id)},options:[{value:``,label:i(`providers.variantDefault`)},...W.variants.map(e=>({value:e.id,label:e.name}))]})}),_===`custom`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{label:i(`providers.baseUrl`),hint:i(`providers.baseUrlHint`),children:(0,X.jsx)(S,{value:ee,onChange:e=>M(e.target.value),placeholder:`https://api.example.com/v1`,className:`font-mono`})}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,X.jsx)(j,{label:i(`providers.protocol`),children:(0,X.jsx)(xe,{value:N,onChange:F,options:jn})}),(0,X.jsx)(j,{label:i(`providers.authScheme`),children:(0,X.jsx)(xe,{value:L,onChange:z,options:Mn})})]})]}),W?.authScheme===`oauth-subscription`?(0,X.jsx)(R,{tone:`info`,title:i(`providers.subscriptionWizardHint`),children:i(`providers.subscriptionWizardDetail`)}):(0,X.jsxs)(`div`,{className:`font-mono`,children:[(0,X.jsx)(Me,{label:i(`providers.apiKey`),description:i(`providers.apiKeyHint`),autoComplete:`off`,placeholder:`sk-…`,value:w,onChange:e=>T(e.target.value)}),W?.apiKeyUrl&&(0,X.jsx)(`a`,{className:`mt-2 inline-block font-sans text-[12px] text-[var(--accent)]`,href:W.apiKeyUrl,target:`_blank`,rel:`noreferrer`,children:i(`providers.getKey`)})]}),(0,X.jsx)(j,{label:i(`providers.priceKey`),hint:i(`providers.priceKeyHint`),children:(0,X.jsx)(xe,{value:k,onChange:A,options:[{value:``,label:i(`providers.priceKeyNone`)},...(l.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey}))]})}),W&&W.models.length>0&&(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:i(`providers.templateModels`,{count:W.models.length})})]}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(O,{value:m,onChange:g,placeholder:i(`providers.searchTemplates`)}),c.isLoading&&(0,X.jsx)(te,{lines:4}),c.isError&&(0,X.jsx)(R,{tone:`danger`,title:i(`common.error`),children:q(c.error)}),B.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)(De,{name:`provider-template`,"aria-label":i(`providers.category.${e.category}`),density:`compact`,minColumnWidth:168,value:e.items.some(e=>e.id===y)?y:null,onValueChange:b,options:e.items.map(e=>{let t=[...new Set(e.endpoints.map(e=>e.protocol))],[n,r]=Wn(e.name);return{value:e.id,label:(0,X.jsx)(`span`,{title:e.name,children:n}),description:(0,X.jsx)(`span`,{title:t.map(Hn).join(` · `),children:r??t.map(e=>Vn[e]).join(` · `)}),icon:(0,X.jsx)(Ue,{name:e.name,icon:e.icon,colorKey:e.id,size:28}),disabled:f.has(e.id),disabledReason:Un(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)(De,{name:`provider-template-plugin`,"aria-label":i(`providers.category.plugin`),density:`compact`,minColumnWidth:168,value:y?.startsWith(zn)?y:null,onValueChange:b,options:V.map(e=>({value:zn+e.id,label:Un(e.name),description:Un(i(`providers.pluginProvided`)),icon:(0,X.jsx)(Ue,{name:e.name,icon:e.icon,colorKey:e.id,size:28})}))}):(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-[var(--radius-md)] border border-dashed border-[var(--border)] px-3 py-2.5`,children:[(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-[12px] text-[var(--text-secondary)]`,children:i(`providers.pluginHint`)}),(0,X.jsx)(I,{size:`sm`,onClick:()=>{n(!1),p(`/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)(De,{name:`provider-template-custom`,"aria-label":i(`providers.custom`),layout:`list`,density:`compact`,value:y===`custom`?`custom`:null,onValueChange:b,options:[{value:`custom`,label:i(`providers.custom`),description:i(`providers.customDetail`),icon:(0,X.jsx)(`span`,{className:`inline-flex size-7 items-center justify-center rounded-[8px] border border-dashed border-[var(--border-strong)] text-[var(--text-secondary)]`,children:(0,X.jsx)(je,{className:`size-4`})})}]})]})]})]})}export{ln as a,yn as i,jn as n,Ye as o,An as r,Mn as t};