@aidotnet/server-darwin-arm64 0.11.6 → 0.11.7
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.
- package/bin/astra-server +2 -2
- package/bin/wwwroot/assets/ClientsPage-BkryyG2f.js +9 -0
- package/bin/wwwroot/assets/{KeyPage-CNp0pPiQ.js → KeyPage-Dvq7y7mN.js} +1 -1
- package/bin/wwwroot/assets/ModelDetailPage-C7_EPeUV.js +1 -0
- package/bin/wwwroot/assets/{ModelsPage-KeUV0kEe.js → ModelsPage-CecKPzmY.js} +1 -1
- package/bin/wwwroot/assets/{PluginsPage-D-Idp7rX.js → PluginsPage-D1aMay74.js} +2 -2
- package/bin/wwwroot/assets/PrivacyPage-0MkKjVWn.js +1 -0
- package/bin/wwwroot/assets/ProviderDetailPage-VBGL5ZrY.js +3 -0
- package/bin/wwwroot/assets/ProvidersPage-D5JY75MS.js +2 -0
- package/bin/wwwroot/assets/SettingsPage-DNie2n8k.js +2 -0
- package/bin/wwwroot/assets/{SmartRoutingPage-d7VpOJbs.js → SmartRoutingPage-B-aCfkfa.js} +2 -2
- package/bin/wwwroot/assets/TokenDetailPage-DGTEwfS_.js +1 -0
- package/bin/wwwroot/assets/{TokenPoolEditor-D1m8Jjy3.js → TokenPoolEditor-B9uZPbeG.js} +1 -1
- package/bin/wwwroot/assets/TokensPage-m2mErUTL.js +1 -0
- package/bin/wwwroot/assets/{TracesPage-D8KIKCul.js → TracesPage-CJZ-nJlq.js} +2 -2
- package/bin/wwwroot/assets/{TrayPanelPage-DaxLSbIE.js → TrayPanelPage-DGyB4UQp.js} +1 -1
- package/bin/wwwroot/assets/{TrayPanelView-D6QJsy-r.js → TrayPanelView-hLE52k5W.js} +1 -1
- package/bin/wwwroot/assets/{alert-BadMvy1R.js → alert-DNq6XGjw.js} +6 -6
- package/bin/wwwroot/assets/{arrow-down-Cv-6a_e3.js → arrow-down-BeKBqI8J.js} +1 -1
- package/bin/wwwroot/assets/{arrow-left-dS7bcLEo.js → arrow-left-raXRLTWx.js} +1 -1
- package/bin/wwwroot/assets/checkbox-B4QCx8vR.js +1 -0
- package/bin/wwwroot/assets/{cloud-download-CpuzW7lP.js → cloud-download-DCdlPad8.js} +1 -1
- package/bin/wwwroot/assets/confirm-morph-wPnl8JgZ.js +1 -0
- package/bin/wwwroot/assets/{download-DhWYUpCm.js → download-C7rkArJ1.js} +1 -1
- package/bin/wwwroot/assets/{ellipsis-DhDdch5j.js → ellipsis-fH6Z7dKK.js} +1 -1
- package/bin/wwwroot/assets/{external-link-D3yhOoFs.js → external-link-RRwePVkf.js} +1 -1
- package/bin/wwwroot/assets/{folder-open-Bggy7qkR.js → folder-open-D2dhOmB_.js} +1 -1
- package/bin/wwwroot/assets/{index-BUzE8kPN.css → index-Bw0Y3RgL.css} +1 -1
- package/bin/wwwroot/assets/{index-BUGU_FDT.js → index-XrDQKNHp.js} +10 -10
- package/bin/wwwroot/assets/{log-out-DV1PNbkn.js → log-out-DzqOZbat.js} +1 -1
- package/bin/wwwroot/assets/minus-jJwwqp0i.js +1 -0
- package/bin/wwwroot/assets/overlays-DvhyCmfZ.js +41 -0
- package/bin/wwwroot/assets/{pencil-TH_5IGXD.js → pencil-DQhF_n_3.js} +1 -1
- package/bin/wwwroot/assets/{power-DF2viDB7.js → power-CCGgTfLt.js} +1 -1
- package/bin/wwwroot/assets/radio-cards-C1r9wSvL.js +1 -0
- package/bin/wwwroot/assets/{rotate-ccw-BxvPRjim.js → rotate-ccw-DHnulJrY.js} +1 -1
- package/bin/wwwroot/assets/{sortable.esm-DYxWT0KU.js → sortable.esm-Bi_ISyN_.js} +1 -1
- package/bin/wwwroot/index.html +4 -4
- package/package.json +1 -1
- package/bin/wwwroot/assets/ClientsPage-TqHAFA25.js +0 -9
- package/bin/wwwroot/assets/ModelDetailPage-B61Xlxp4.js +0 -1
- package/bin/wwwroot/assets/PrivacyPage-C3YpZHD5.js +0 -1
- package/bin/wwwroot/assets/ProviderDetailPage-CeXebQjO.js +0 -3
- package/bin/wwwroot/assets/ProvidersPage-Ca7aGIQg.js +0 -2
- package/bin/wwwroot/assets/SettingsPage-CpD7hQB4.js +0 -2
- package/bin/wwwroot/assets/TokenDetailPage-TJa2J-N_.js +0 -1
- package/bin/wwwroot/assets/TokensPage-CnAympZG.js +0 -1
- package/bin/wwwroot/assets/checkbox-CaaP8Tue.js +0 -1
- package/bin/wwwroot/assets/confirm-morph-XE52Kxj6.js +0 -1
- package/bin/wwwroot/assets/minus-DxRH0N_9.js +0 -1
- package/bin/wwwroot/assets/overlays-D-LaJu2w.js +0 -41
- package/bin/wwwroot/assets/radio-cards-Geph_wiF.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$n as e,Bi as t,E as n,Gi as r,Hi as i,Ia as a,J as o,Ma as s,Na as c,Qn as l,Vi as u,Wi as d,Y as f,Yt as p,Zn as m,_ as h,b as g,bt as _,c as v,ct as y,d as b,dt as x,er as S,g as C,h as w,l as T,m as E,n as D,ot as O,r as k,t as ee,u as A,ui as j,v as M,xt as N,y as P,zi as F}from"./alert-BadMvy1R.js";import{a as I,i as te,o as L,r as R}from"./overlays-D-LaJu2w.js";import{$ as ne,C as z,D as B,E as re,F as ie,H as ae,M as oe,N as V,Q as se,R as H,T as ce,U as le,_ as ue,c as de,h as fe,nt as U,r as pe,tt as me,w as W,z as he}from"./index-BUGU_FDT.js";var ge={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`}]]};ge.node;var _e=N(ge),G=a(c(),1),K={toolbar:`_toolbar_1p5c5_1`,leading:`_leading_1p5c5_2`,frame:`_frame_1p5c5_4`,chips:`_chips_1p5c5_5`,slot:`_slot_1p5c5_7`,chip:`_chip_1p5c5_5`,chipLabel:`_chipLabel_1p5c5_10`,value:`_value_1p5c5_11`,separator:`_separator_1p5c5_12`,morphText:`_morphText_1p5c5_13`,morphValue:`_morphValue_1p5c5_14`,measure:`_measure_1p5c5_15`,empty:`_empty_1p5c5_18`,actions:`_actions_1p5c5_19`,clear:`_clear_1p5c5_20`,clearText:`_clearText_1p5c5_21`,srOnly:`_srOnly_1p5c5_23`,menu:`_menu_1p5c5_27`,trigger:`_trigger_1p5c5_29`,face:`_face_1p5c5_31`,surface:`_surface_1p5c5_34`,panel:`_panel_1p5c5_42`,head:`_head_1p5c5_45`,back:`_back_1p5c5_47`,title:`_title_1p5c5_49`,titleText:`_titleText_1p5c5_50`,stage:`_stage_1p5c5_51`,step:`_step_1p5c5_52`,list:`_list_1p5c5_53`,highlight:`_highlight_1p5c5_54`,item:`_item_1p5c5_55`,itemIcon:`_itemIcon_1p5c5_57`,itemLabel:`_itemLabel_1p5c5_58`,itemMeta:`_itemMeta_1p5c5_59`,metaValue:`_metaValue_1p5c5_60`,hint:`_hint_1p5c5_61`,check:`_check_1p5c5_62`,noOptions:`_noOptions_1p5c5_64`},q=s(),J={duration:n.duration.standard,ease:[...n.ease.enter]},ve={duration:n.duration.instant,ease:[...n.ease.standard]},Y={duration:0},ye={duration:n.duration.instant,ease:[...n.ease.standard]},X=e=>`blur(${e}px)`,be=e=>Math.min(1,Math.max(0,e)),xe=e=>typeof e==`string`?{value:e}:e,Se=e=>e.label??e.value,Ce=e=>({initial:e?{opacity:0}:{opacity:0,y:`0.3em`,filter:X(n.blur.soft)},animate:{opacity:1,y:0,filter:X(0)},exit:e?{opacity:0,transition:Y}:{opacity:0,y:`-0.3em`,filter:X(n.blur.subtle),transition:ve},transition:e?ye:J});function we({text:e}){let r=u()??!1,a=(0,G.useRef)(null),o=i(`auto`);return(0,G.useLayoutEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let i=null,s=new ResizeObserver(([a])=>{let s=Math.ceil(a.borderBoxSize?.[0]?.inlineSize??e.offsetWidth),c=i!==null&&i!==e.textContent;i=e.textContent,c&&!r?t(o,s,n.spring.morph):o.jump(s)});return s.observe(e),()=>s.disconnect()},[r,o]),(0,q.jsxs)(F.span,{className:K.morphText,style:{width:o},children:[(0,q.jsx)(`span`,{ref:a,className:K.measure,"aria-hidden":`true`,children:e}),(0,q.jsx)(d,{mode:`popLayout`,initial:!1,children:(0,q.jsx)(F.span,{className:K.morphValue,...Ce(r),children:e},e)})]})}function Te(e,r,a){let o=i(`auto`);return(0,G.useLayoutEffect)(()=>{let i=e.current;if(!i||typeof ResizeObserver>`u`)return;let s=!1,c=new ResizeObserver(()=>{let e=i.offsetHeight;if(!s||a||performance.now()>r.current){s=!0,o.jump(e);return}t(o,e,n.spring.smooth)});return c.observe(i),()=>c.disconnect()},[r,o,e,a]),o}function Ee(e,r,i){(0,G.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>r.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=t(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?.()}},[r,e,i])}var Z=e=>e.valueLabel??e.value,De=e=>Z(e)?`${e.label}: ${Z(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 ${De(e)}`,added:e=>`Added ${De(e)}`,changed:e=>`Changed ${De(e)}`,removed:e=>`Removed ${De(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:t,onChoose:i,onBack:a,onLeave:o,radio:s,emptyMessage:c}){let l=u()??!1,d=r(),f=(0,G.useRef)(null),p=(0,G.useRef)(!1),m=(0,G.useRef)({text:``,at:0}),[h,g]=(0,G.useState)(()=>Math.max(0,e.findIndex(e=>e.checked))),[_,v]=(0,G.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 S(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 C(e){f.current?.contains(e.relatedTarget)||v(e=>e&&{...e,glide:!1,ring:!1,shown:!1})}return(0,q.jsxs)(`div`,{ref:f,className:K.list,role:`menu`,"aria-labelledby":t,"data-current":d?``:void 0,onKeyDown:x,onFocus:S,onBlur:C,onPointerLeave:()=>{p.current&&f.current?.contains(document.activeElement)&&o()},children:[(0,q.jsx)(F.span,{className:K.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:Y,opacity:{duration:l?0:.08}}}),e.length===0?(0,q.jsx)(`p`,{className:K.noOptions,children:c}):null,e.map((e,t)=>(0,q.jsxs)(`button`,{type:`button`,className:K.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,q.jsx)(`span`,{className:K.itemIcon,"aria-hidden":`true`,children:e.icon}):null,(0,q.jsx)(`span`,{className:K.itemLabel,children:e.label}),e.meta?(0,q.jsx)(`span`,{className:K.itemMeta,children:e.meta}):null]},e.key))]})}function 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:e,onSelect:r,active:a=[],label:o=`Add filter`,align:s=`end`,messages:c}){let l={...Oe,...c},f=u()??!1,p=(0,G.useId)(),m=`${p}panel`,h=`${p}title`,g=(0,G.useRef)(null),v=(0,G.useRef)(null),y=(0,G.useRef)(null),b=(0,G.useRef)(`closed`),x=(0,G.useRef)(0),S=(0,G.useRef)(null),[C,w]=(0,G.useState)(`closed`),[T,E]=(0,G.useState)(null),[D,O]=(0,G.useState)(1),[k,ee]=(0,G.useState)(!1),[A,j]=(0,G.useState)(`100% 0`),M=i(`100%`),N=i(`100%`),P=i(0),I=i(0),te=U(()=>I.get()-P.get()),L=i(0),R=i(0),ne=U(()=>{let e=M.get(),t=L.get(),n=R.get();return typeof e==`number`?n>t?be((e-t)/(n-t)):1:0}),z=U(()=>be(ne.get()/.35)),B=U(()=>be((ne.get()-.4)/.5)),re={opacity:U(()=>1-z.get()),scale:U(()=>1-z.get()*.04),filter:U(()=>z.get()?X(z.get()*n.blur.subtle):`none`)},ie={opacity:B,transformOrigin:A,scale:U(()=>.96+B.get()*.04),y:U(()=>(1-B.get())*(k?-6:6)),filter:U(()=>B.get()===1?`none`:X((1-B.get())*n.blur.soft))},oe=C===`open`,V=e.find(e=>e.id===T)??null,se=(0,G.useCallback)(e=>{let r=v.current,i=y.current;if(!r||!i)return;let a=r.getBoundingClientRect(),o=i.offsetWidth+2,c=i.offsetHeight+2,l=je(g.current??r),u=l.left+16-a.left,d=l.right-16-a.left-o,p=a.width-o,m=s===`end`?p>=u?p:0<=d?0:p:0<=d?0:p>=u?p:0;m=Math.round(Math.min(Math.max(m,u),Math.max(u,d)));let h=l.bottom-a.top,_=a.bottom-l.top,C=h<c+16&&_>h;b.current===`closed`&&(M.jump(a.width),N.jump(a.height),P.jump(0)),I.jump(m),L.jump(a.width),R.jump(o),b.current=`open`,x.current+=1,S.current=e,w(`open`),ee(C),E(null),O(-1),j(`${Math.round(a.width/2-m)}px ${C?`100%`:`0`}`);let T=f?Y:n.spring.morph;t(P,m,T),t(M,o,T),t(N,c,T)},[s,L,N,P,f,I,R,M]),H=(0,G.useCallback)(e=>{let r=v.current;if(b.current!==`open`||!r)return;b.current=`closing`;let i=x.current+=1;w(`closing`),e&&r.focus({preventScroll:!0,focusVisible:e===`keyboard`});let a=f?Y:n.spring.snappy;t(P,0,a);let o=r.getBoundingClientRect();t(N,o.height,a),t(M,o.width,{...a,onComplete:()=>{i===x.current&&(b.current=`closed`,M.jump(`100%`),N.jump(`100%`),w(`closed`),E(null))}})},[N,P,f,M]);(0,G.useLayoutEffect)(()=>{let e=y.current;if(!e||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{b.current===`open`&&t(N,e.offsetHeight+2,f?Y:n.spring.smooth)});return r.observe(e),()=>r.disconnect()},[N,f]),(0,G.useLayoutEffect)(()=>{let e=S.current,t=y.current;if(!e||!t||C!==`open`)return;if(S.current=null,e===`panel`){t.focus({preventScroll:!0});return}let n=Array.from(t.querySelectorAll(`[data-current] [data-row]`));(e===`first`?n[0]:e===`last`?n.at(-1):e===`checked`?n.find(e=>e.getAttribute(`aria-checked`)===`true`)??n[0]:n.find(t=>t.dataset.row===e.key)??n[0])?.focus({preventScroll:!0})},[C,T]),(0,G.useEffect)(()=>{if(C!==`open`)return;let e=e=>{let t=g.current,n=e.target;!t||n&&t.contains(n)||(H(!1),n?.closest?.(`button, a[href], input, select, textarea, [tabindex], [contenteditable]`)||window.setTimeout(()=>{let e=document.activeElement;(!e||e===document.body||t.contains(e))&&v.current?.focus({preventScroll:!0,focusVisible:!1})},0))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[H,C]);function ce(e){if(e.defaultPrevented)return;let t=Array.from(y.current?.querySelectorAll(`[data-current] [data-row]`)??[]);(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),(e.key===`ArrowDown`?t[0]:t.at(-1))?.focus({preventScroll:!0})),e.key===`ArrowLeft`&&V&&(e.preventDefault(),ue(!0))}function ue(e){V&&(S.current=e?{key:V.id}:`panel`,O(-1),E(null))}function de(e,t){S.current=t?`checked`:`panel`,O(1),E(e.key)}function fe(e,t){V&&(r({id:V.id,label:V.label,value:e.key,valueLabel:e.label},V),H(t?`keyboard`:`pointer`))}let pe=e=>a.find(t=>t.id===e.id),me=e.map(e=>({key:e.id,label:e.label,icon:e.icon,drill:!0,meta:(0,q.jsxs)(q.Fragment,{children:[pe(e)?(0,q.jsx)(`span`,{className:K.metaValue,children:Z(pe(e))}):null,(0,q.jsx)(ae,{size:15,strokeWidth:1.8,"aria-hidden":`true`})]})})),W=V?V.options.map(xe).map(e=>{let t=Se(e),n=pe(V)?.value===e.value;return{key:e.value,label:t,icon:e.icon,checked:n,meta:e.hint!=null||n?(0,q.jsxs)(q.Fragment,{children:[e.hint==null?null:(0,q.jsx)(`span`,{className:K.hint,children:e.hint}),(0,q.jsx)(`span`,{className:K.check,"data-on":n||void 0,children:(0,q.jsx)(_,{size:15,strokeWidth:2,"aria-hidden":`true`})})]}):null}}):[],ge={enter:e=>f?{opacity:0}:{opacity:0,x:e*18,filter:X(n.blur.soft)},center:{opacity:1,x:0,filter:X(0),transition:f?ye:{...J,x:n.spring.smooth}},exit:e=>f?{opacity:0,transition:Y}:{opacity:0,x:e*-18,filter:X(n.blur.subtle),transition:ve}};return(0,q.jsxs)(`div`,{ref:g,className:K.menu,"data-state":C,"data-y":k?`up`:`down`,onKeyDown:e=>{e.key===`Escape`&&b.current===`open`&&(e.preventDefault(),e.stopPropagation(),H(`keyboard`))},onBlur:e=>{let t=e.relatedTarget;b.current===`open`&&t&&!g.current?.contains(t)&&H(!1)},children:[(0,q.jsx)(`button`,{ref:v,type:`button`,className:K.trigger,"data-filter-trigger":``,"aria-haspopup":`dialog`,"aria-expanded":oe,"aria-controls":m,tabIndex:oe?-1:void 0,onClick:e=>{b.current!==`open`&&se(e.detail===0?`first`:`panel`)},onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),se(e.key===`ArrowDown`?`first`:`last`))},children:(0,q.jsxs)(F.span,{className:K.face,style:re,children:[(0,q.jsx)(he,{size:15,strokeWidth:1.8,"aria-hidden":`true`}),o]})}),(0,q.jsx)(F.div,{className:K.surface,style:{left:P,width:M,height:N},children:(0,q.jsx)(F.div,{ref:y,id:m,className:K.panel,role:`dialog`,"aria-labelledby":h,tabIndex:-1,inert:!oe,style:{x:te},onKeyDown:ce,children:(0,q.jsxs)(F.div,{style:ie,children:[(0,q.jsxs)(`div`,{className:K.head,children:[(0,q.jsx)(d,{initial:!1,children:V?(0,q.jsx)(F.button,{type:`button`,className:K.back,"aria-label":l.back,onClick:e=>ue(e.detail===0),initial:f?{opacity:0,width:28,marginRight:2}:{opacity:0,width:0,marginRight:0,scale:.6},animate:{opacity:1,width:28,marginRight:2,scale:1},exit:f?{opacity:0,transition:Y}:{opacity:0,width:0,marginRight:0,scale:.6,transition:{...n.spring.snappy,opacity:ve}},transition:f?ye:{...n.spring.snappy,opacity:J},children:(0,q.jsx)(le,{size:16,strokeWidth:1.8,"aria-hidden":`true`})},`back`):null}),(0,q.jsx)(`span`,{className:K.title,id:h,children:(0,q.jsx)(d,{mode:`popLayout`,initial:!1,children:(0,q.jsx)(F.span,{className:K.titleText,...Ce(f),children:V?V.label:o},V?.id??`fields`)})})]}),(0,q.jsx)(`div`,{className:K.stage,children:(0,q.jsx)(d,{mode:`popLayout`,initial:!1,custom:D,children:(0,q.jsx)(F.div,{className:K.step,custom:D,variants:ge,initial:`enter`,animate:`center`,exit:`exit`,children:V?(0,q.jsx)(Ae,{rows:W,labelledBy:h,emptyMessage:l.noOptions,radio:!0,onChoose:fe,onBack:ue,onLeave:()=>y.current?.focus({preventScroll:!0})}):(0,q.jsx)(Ae,{rows:me,labelledBy:h,emptyMessage:l.noOptions,onChoose:de,onLeave:()=>y.current?.focus({preventScroll:!0})})},V?.id??`fields`)})})]})})})]})}function Ne({filters:e,onRemove:t,onClearAll:r,leading:i,children:a,label:o=`Active filters`,addFilter:s,messages:c}){let l={...Oe,...c},f=u()??!1,p=(0,G.useRef)(null),m=(0,G.useRef)(null),h=(0,G.useRef)(0),g=(0,G.useRef)(null),[_,v]=(0,G.useState)(e),[y,b]=(0,G.useState)(``);if(_!==e){v(e);let t=ke(_,e,l);t&&b(t)}let S=e.map(e=>`${e.id}:${e.value??``}`).join(`|`);(0,G.useLayoutEffect)(()=>{h.current=performance.now()+900},[S]);let C=Te(m,h,f);Ee(m,h,f),(0,G.useLayoutEffect)(()=>{let t=g.current,n=p.current;if(t===null||!n)return;g.current=null;let r=e[Math.min(t,e.length-1)];(r?n.querySelector(`[data-chip-remove="${CSS.escape(r.id)}"]`):n.querySelector(`[data-filter-trigger]`))?.focus({preventScroll:!0})},[e]);let w={duration:0},T=e=>({initial:!f&&{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1},animate:{width:`auto`,marginRight:0,transitionEnd:{overflow:`visible`,"--slot-moving":0}},exit:f?{opacity:0,transition:w}:{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1,pointerEvents:`none`,transition:{...n.spring.smooth,"--slot-moving":w}},transition:f?w:n.spring.smooth}),E={initial:!f&&{opacity:0,scale:.9,filter:X(n.blur.soft)},animate:{opacity:1,scale:1,filter:X(0)},exit:f?{opacity:0,transition:w}:{opacity:0,scale:.9,filter:X(n.blur.subtle),transition:ve},transition:f?w:{...J,scale:n.spring.snappy}},D=f?{...Ce(!0),initial:!1}:Ce(!1),O=f?D:{...D,transition:{...J,delay:n.duration.instant*.75}};return(0,q.jsxs)(`div`,{ref:p,className:K.toolbar,role:`group`,"aria-label":o,children:[i?(0,q.jsx)(`div`,{className:K.leading,children:i}):null,(0,q.jsx)(F.div,{className:K.frame,style:{height:C},children:(0,q.jsxs)(`div`,{ref:m,className:K.chips,children:[(0,q.jsx)(d,{initial:!1,children:e.map((e,n)=>(0,q.jsx)(F.span,{className:K.slot,...T(8),children:(0,q.jsxs)(F.span,{className:K.chip,...E,children:[(0,q.jsxs)(`span`,{className:K.chipLabel,title:De(e),children:[e.label,Z(e)?(0,q.jsxs)(`span`,{className:K.value,children:[(0,q.jsx)(`span`,{className:K.separator,children:` · `}),(0,q.jsx)(we,{text:Z(e)})]}):null]}),(0,q.jsx)(`button`,{type:`button`,"data-chip-remove":e.id,"aria-label":l.remove(e),onClick:r=>{document.activeElement===r.currentTarget&&(g.current=n),t(e.id)},children:(0,q.jsx)(x,{size:14,strokeWidth:1.8,"aria-hidden":`true`})})]})},e.id))}),(0,q.jsx)(d,{initial:!1,children:e.length?null:(0,q.jsx)(F.span,{className:K.empty,...O,children:l.empty},`empty`)})]})}),(0,q.jsxs)(`div`,{className:K.actions,children:[s?(0,q.jsx)(Me,{fields:s.fields,onSelect:s.onAdd,active:e,label:s.label,align:s.align,messages:l}):null,a,(0,q.jsx)(d,{initial:!1,children:e.length>0&&r?(0,q.jsx)(F.span,{className:K.slot,...T(12),children:(0,q.jsx)(`button`,{className:K.clear,type:`button`,onClick:()=>{g.current=-1,r?.()},children:(0,q.jsx)(F.span,{className:K.clearText,...D,children:l.clearAll})})},`clear`):null})]}),(0,q.jsx)(`span`,{className:K.srOnly,role:`status`,children:y})]})}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}=y();return t=>{let n=Pe[t];return n?e(n):t}}function Le({action:e}){let{t}=y();return(0,q.jsx)(D,{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}=y(),n=Ie(),[r,i]=(0,G.useState)(``),[a,s]=(0,G.useState)({client:``,category:``,action:``,blocked:``}),[c,l]=(0,G.useState)(1),[u,d]=(0,G.useState)(null),h=oe(r),g=p(),_=m(),b={model:h,...a,page:c,pageSize:Re},x=S(b,c===1),C=x.data,T=C?Math.max(1,Math.ceil(C.total/Re)):1,E=e=>e?ue[e]?.name??e:`—`,D=[...new Set((_.data?.rules??[]).map(e=>e.category))],A={client:(g.data??[]).map(e=>({value:e.kind,label:e.name})),category:D.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`)}]},j={client:e(`requests.col.client`),category:e(`privacy.stats.col.category`),action:e(`privacy.logs.col.action`),blocked:e(`privacy.logs.col.outcome`)},N=Object.keys(A).map(e=>({id:e,label:j[e],options:A[e].map(e=>e.label)})),P=Object.keys(a).filter(e=>a[e]).map(e=>({id:e,label:j[e],value:A[e].find(t=>t.value===a[e])?.label??a[e]})),F=(e,t)=>{s(n=>({...n,[e]:t})),l(1)},te=(C?.items??[]).map(e=>({id:e.id,time:Date.parse(e.startedAtUtc),client:E(e.clientKind),model:e.requestedModel??``,outcome:Ve(e),hits:e.hits.reduce((e,t)=>e+t.count,0),e})),L=[{key:`time`,label:e(`requests.col.time`),width:92,render:(e,n)=>(0,q.jsx)(`span`,{className:`num`,children:o(n.e.startedAtUtc,t)})},{key:`model`,label:e(`requests.col.model`),render:(t,n)=>(0,q.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>d(n.id),"aria-label":e(`privacy.logs.viewRequest`,{model:n.model||n.id}),children:[(0,q.jsx)(`span`,{className:`block truncate font-medium hover:text-[var(--accent)]`,children:n.model||`—`}),(0,q.jsx)(`span`,{className:`block truncate text-[11px] text-[var(--text-muted)]`,children:E(n.e.clientKind)})]})},{key:`outcome`,label:e(`privacy.logs.col.outcome`),width:130,render:(e,t)=>(0,q.jsx)(He,{event:t.e})},{key:`hits`,label:e(`privacy.logs.col.hits`),render:(e,t)=>(0,q.jsx)(Ue,{event:t.e})},{key:`client`,label:e(`requests.col.client`),width:110,render:e=>(0,q.jsx)(`span`,{className:`block truncate`,children:String(e||`—`)})}];return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,q.jsx)(w,{className:`w-52`,value:r,onChange:e=>{i(e),l(1)},placeholder:e(`requests.searchModel`)}),(0,q.jsx)(k,{variant:`plain`,icon:(0,q.jsx)(H,{className:O(`size-4`,x.isFetching&&`animate-spin`)}),"aria-label":e(`common.refresh`),onClick:()=>void x.refetch()})]}),(0,q.jsx)(`div`,{className:`mb-3`,children:(0,q.jsx)(Ne,{label:e(`requests.filters`),filters:P,onRemove:e=>F(e,``),onClearAll:()=>{s({client:``,category:``,action:``,blocked:``}),l(1)},addFilter:{fields:N,label:e(`requests.addFilter`),onAdd:e=>{let t=e.id,n=A[t].find(t=>t.label===e.value)?.value;n&&F(t,n)}}})}),x.isLoading&&(0,q.jsx)(M,{lines:4,className:`py-6`}),x.isError&&(0,q.jsx)(ee,{tone:`danger`,title:e(`common.error`),children:I(x.error)}),C&&C.items.length===0&&(0,q.jsx)(v,{icon:(0,q.jsx)(_e,{className:`size-6`}),title:e(`privacy.logs.empty`),detail:e(`privacy.logs.empty.detail`)}),C&&C.items.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mb-2 text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.total`,{count:f(C.total)})}),(0,q.jsx)(B,{caption:e(`privacy.tab.logs`),rows:te,columns:L,rowKey:`id`,emptyMessage:e(`privacy.logs.empty`)})]}),C&&T>1&&(0,q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,q.jsx)(de,{page:c,pageCount:T,onPageChange:l,label:e(`requests.page`,{page:c,pages:T})})}),(0,q.jsx)(pe,{id:u,onClose:()=>d(null)})]})}function Ve(e){return e.blocked?`blocked`:e.redactions>0?`redact`:e.dryRun?`dryRun`:`warn`}function He({event:e}){let{t}=y();return e.blocked?(0,q.jsx)(D,{tone:`red`,children:t(`privacy.logs.outcome.blocked`)}):e.redactions>0?(0,q.jsx)(D,{tone:`orange`,children:t(`privacy.logs.outcome.redacted`,{count:e.redactions})}):e.dryRun?(0,q.jsx)(D,{tone:`neutral`,children:t(`privacy.logs.outcome.dryRun`)}):(0,q.jsx)(D,{tone:`neutral`,children:t(`settings.privacy.action.warn`)})}function Ue({event:e}){let t=Ie(),{t:n}=y();if(e.hits.length===0)return(0,q.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`—`});let r=e.hits.slice(0,2),i=e.hits.length-r.length;return(0,q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px]`,children:[r.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,q.jsx)(Le,{action:e.action}),(0,q.jsxs)(`span`,{children:[t(e.category),` × `,e.count]}),e.samples&&e.samples.length>0&&(0,q.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:e.samples.slice(0,2).join(` `)})]},`${e.ruleId}:${e.action}`)),i>0&&(0,q.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:n(`privacy.logs.moreHits`,{count:i})})]})}var Q={counter:`_counter_dnoch_1`,label:`_label_dnoch_2`,value:`_value_dnoch_4`,column:`_column_dnoch_6`,sizer:`_sizer_dnoch_7`,glyph:`_glyph_dnoch_8`,labelText:`_labelText_dnoch_9`,labelSwap:`_labelSwap_dnoch_10`,symbol:`_symbol_dnoch_11`,srOnly:`_srOnly_dnoch_12`},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=U(e,e=>((t-e)%10+15)%10-5),i=U(r,e=>`${e}em`),a=U(r,e=>Math.max(0,1-Math.abs(e))),o=U(r,e=>Math.abs(e)>=1?`hidden`:`visible`),s=U(r,e=>Math.abs(e)<.02||Math.abs(e)>=1?`none`:`blur(${(Math.abs(e)*n.blur.subtle).toFixed(2)}px)`);return(0,q.jsx)(F.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:r,armed:a,delay:o,reduceMotion:s}){let c=i(a?0:e),l=(0,G.useRef)({digit:a?0:e,target:a?0:e,revealed:!a});return(0,G.useEffect)(()=>{let i=l.current;if(a||i.digit===e){a||(i.revealed=!0);return}i.target+=r<0&&i.revealed?-((i.digit-e+10)%10):(e-i.digit+10)%10,i.digit=e,s?c.jump(i.target):t(c,i.target,i.revealed?n.spring.smooth:{...qe,delay:o}),i.revealed=!0},[a,o,e,r,c,s]),(0,q.jsxs)(F.span,{className:Q.column,...Xe,transition:s?{duration:0}:n.spring.morph,children:[(0,q.jsx)(`span`,{className:Q.sizer,children:`0`}),We.map(e=>(0,q.jsx)(Ye,{position:c,digit:e},e))]})}function Qe({value:e,label:t,prefix:r=``,suffix:i=``,decimals:a=0,animateOnView:o=!1,locale:s=`en-US`}){let c=(0,G.useRef)(null),l=me(c,{once:!0,amount:.6}),f=!!u(),[p,m]=(0,G.useState)(e),[h,g]=(0,G.useState)(1);e!==p&&(m(e),g(e>p?1:-1));let _=Je(e,a,s),v=`${r}${_.map(e=>`text`in e?e.text:e.digit).join(``)}${i}`,y=o&&!l;return(0,q.jsxs)(`span`,{ref:c,className:Q.counter,children:[t&&(0,q.jsx)(`span`,{className:Q.label,children:(0,q.jsx)(`span`,{className:Q.labelSwap,children:(0,q.jsx)(d,{mode:`popLayout`,initial:!1,children:(0,q.jsx)(F.span,{className:Q.labelText,variants:f?Ke:Ge,initial:`hidden`,animate:`shown`,exit:`gone`,children:t},t)})})}),(0,q.jsx)(`span`,{className:Q.srOnly,children:v}),(0,q.jsxs)(`span`,{className:Q.value,"aria-hidden":`true`,children:[r&&(0,q.jsx)(`span`,{className:Q.symbol,children:r}),(0,q.jsx)(d,{initial:!1,children:_.map(e=>`digit`in e?(0,q.jsx)(Ze,{digit:e.digit,direction:h,armed:y,delay:Math.min(e.order*n.stagger.item,.25),reduceMotion:f},e.key):(0,q.jsx)(F.span,{className:Q.symbol,...Xe,transition:f?{duration:0}:n.spring.morph,children:e.text},e.key))}),i&&(0,q.jsx)(`span`,{className:Q.symbol,children:i})]})]})}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:e,morph:r=!1,block:a=!1}){let o=!!u(),s=(0,G.useRef)(null),c=i(`auto`),[l,f]=(0,G.useState)({text:e,direction:1});return l.text!==e&&f({text:e,direction:tt(e)<tt(l.text)?-1:1}),(0,G.useEffect)(()=>{let e=s.current;if(!e||typeof ResizeObserver>`u`)return;let r=null,i=new ResizeObserver(([i])=>{let a=i.borderBoxSize?.[0]?.inlineSize??e.offsetWidth;a&&r!==null&&r!==e.textContent&&!o?t(c,a,n.spring.morph):c.jump(a||`auto`),r=a?e.textContent:null});return i.observe(e),()=>i.disconnect()},[r,o,c]),(0,q.jsxs)(F.span,{className:a?$.swapBlock:$.swap,style:r?{width:c}:void 0,children:[r&&(0,q.jsx)(`span`,{ref:s,className:$.sizer,"aria-hidden":`true`,children:e}),(0,q.jsx)(d,{mode:`popLayout`,initial:!1,custom:l.direction,children:(0,q.jsx)(F.span,{className:$.text,custom:l.direction,variants:o?et:$e,initial:`hidden`,animate:`shown`,exit:`gone`,children:e},e)})]})}function rt({label:e,value:t,suffix:r,context:i,change:a}){let o=!!u();return(0,q.jsxs)(`article`,{className:$.card,children:[(0,q.jsxs)(`div`,{className:$.top,children:[(0,q.jsx)(`span`,{children:(0,q.jsx)(nt,{text:e,block:!0})}),(0,q.jsx)(d,{initial:!1,children:a&&(0,q.jsx)(F.small,{"data-trend":/^[+]/.test(a)?`up`:/^[-−]/.test(a)?`down`:void 0,initial:{opacity:0,scale:o?1:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:o?1:.96,transition:{duration:n.duration.fast,ease:[...n.ease.standard]}},transition:o?{duration:0}:n.spring.snappy,children:(0,q.jsx)(nt,{text:a,morph:!0})},`change`)})]}),(0,q.jsx)(Qe,{value:t,suffix:r,animateOnView:!0}),(0,q.jsx)(`p`,{children:(0,q.jsx)(nt,{text:i,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}=y(),{toast:t}=L(),n=m(),r=j(),i=n.data?.settings,a=e=>{i&&r.mutate({...i,...e},{onError:e=>t(I(e),`error`)})},o=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])}));return(0,q.jsxs)(A,{title:e(`settings.privacy`),footer:e(`settings.privacy.footer`),children:[n.isLoading&&(0,q.jsx)(M,{className:`my-4`}),n.isError&&(0,q.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--danger)]`,children:I(n.error)}),i&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(E,{label:e(`settings.privacy.enabled`),detail:e(`settings.privacy.enabledHint`),children:(0,q.jsx)(P,{checked:i.enabled,label:e(`settings.privacy.enabled`),onChange:e=>a({enabled:e})})}),(0,q.jsx)(E,{label:e(`settings.privacy.dryRun`),detail:e(`settings.privacy.dryRunHint`),children:(0,q.jsx)(P,{checked:i.dryRun,disabled:!i.enabled,label:e(`settings.privacy.dryRun`),onChange:e=>a({dryRun:e})})}),(0,q.jsx)(E,{label:e(`settings.privacy.restore`),detail:e(`settings.privacy.restoreHint`),children:(0,q.jsx)(P,{checked:i.restoreResponses,disabled:!i.enabled,label:e(`settings.privacy.restore`),onChange:e=>a({restoreResponses:e})})}),(0,q.jsx)(E,{label:e(`settings.privacy.recordSamples`),detail:e(`settings.privacy.recordSamplesHint`),children:(0,q.jsx)(P,{checked:i.recordSamples,disabled:!i.enabled,label:e(`settings.privacy.recordSamples`),onChange:e=>a({recordSamples:e})})}),(0,q.jsx)(E,{label:e(`settings.privacy.defaultAction`),children:(0,q.jsx)(R,{className:`w-36`,ariaLabel:e(`settings.privacy.defaultAction`),value:i.defaultAction,disabled:!i.enabled,onChange:e=>a({defaultAction:e}),options:o})})]})]})}function ct(){let{t:e}=y(),{toast:t}=L(),n=m(),r=j(),i=n.data?.settings,a=Ie(),o=e=>{i&&r.mutate({...i,...e},{onError:e=>t(I(e),`error`)})},s=(e,t)=>o({categoryActions:{...i?.categoryActions,[e]:t}}),c=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])})),l=[...new Set((n.data?.rules??[]).map(e=>e.category))],u=e=>n.data?.rules.find(t=>t.category===e)?.description;return n.isLoading?(0,q.jsx)(`div`,{className:`mx-auto max-w-[720px]`,children:(0,q.jsx)(M,{className:`my-4`})}):i?(0,q.jsxs)(`div`,{className:`mx-auto flex max-w-[720px] flex-col gap-4`,children:[(0,q.jsx)(A,{title:e(`settings.privacy.categories`),children:l.map(t=>{let n=i.categoryActions[t]??i.defaultAction,r=!i.enabled||n===`off`;return(0,q.jsxs)(E,{label:a(t),detail:u(t),children:[n===`off`?(0,q.jsx)(D,{children:e(`settings.privacy.action.off`)}):(0,q.jsx)(R,{className:`w-36`,ariaLabel:a(t),value:n,disabled:!i.enabled,onChange:e=>s(t,e),options:c.filter(e=>e.value!==`off`)}),r&&(0,q.jsx)(k,{size:`sm`,variant:`plain`,disabled:!i.enabled,onClick:()=>s(t,i.categoryActions[t]??i.defaultAction),children:e(`settings.privacy.enableCategory`)})]},t)})}),(0,q.jsx)(lt,{s:i,onPatch:o})]}):null}function lt({s:e,onPatch:t}){let{t:n}=y(),{confirm:r}=L(),[i,a]=(0,G.useState)(!1),o=(n,r)=>t({customRules:e.customRules.map(e=>e.id===n.id?{...e,enabled:r}:e)}),s=async i=>{await r({title:n(`settings.privacy.deleteRuleConfirm`,{name:i.name}),destructive:!0,confirmLabel:n(`common.delete`)})&&t({customRules:e.customRules.filter(e=>e.id!==i.id)})};return(0,q.jsxs)(A,{title:n(`settings.privacy.customRules`),children:[e.customRules.length===0&&(0,q.jsx)(`div`,{className:`px-4 py-4 text-[12px] text-[var(--text-secondary)]`,children:n(`settings.privacy.noCustomRules`)}),e.customRules.map(t=>(0,q.jsxs)(E,{label:t.name,detail:t.pattern,children:[(0,q.jsx)(P,{checked:t.enabled,disabled:!e.enabled,label:t.name,onChange:e=>o(t,e)}),(0,q.jsx)(k,{size:`sm`,variant:`plain`,icon:(0,q.jsx)(V,{className:`size-3.5`}),"aria-label":`${n(`common.delete`)} ${t.name}`,onClick:()=>void s(t)})]},t.id)),(0,q.jsx)(`div`,{className:`px-4 py-2`,children:(0,q.jsx)(k,{size:`sm`,icon:(0,q.jsx)(he,{className:`size-3.5`}),disabled:!e.enabled,onClick:()=>a(!0),children:n(`settings.privacy.addRule`)})}),(0,q.jsx)(ut,{open:i,onOpenChange:a,onAdd:n=>t({customRules:[...e.customRules,n]})})]})}function ut({open:e,onOpenChange:t,onAdd:n}){let{t:r}=y(),{toast:i}=L(),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(``);return(0,q.jsx)(te,{open:e,onOpenChange:t,title:r(`settings.privacy.addRule`),width:480,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(k,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,q.jsx)(k,{variant:`primary`,disabled:!a.trim()||!s.trim(),onClick:()=>{if(a.trim()&&s.trim()){try{new RegExp(s)}catch(e){i(`${r(`settings.privacy.invalidPattern`)}: ${I(e)}`,`error`);return}n({id:`custom-${Date.now().toString(36)}`,name:a.trim(),pattern:s.trim(),enabled:!0}),o(``),c(``),u(``),t(!1)}},children:r(`common.create`)})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(T,{label:r(`settings.privacy.ruleTemplates`),hint:r(`settings.privacy.ruleTemplatesHint`),children:(0,q.jsx)(R,{ariaLabel:r(`settings.privacy.ruleTemplates`),value:l,onChange:e=>{u(e);let t=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,q.jsx)(b,{label:r(`settings.privacy.ruleName`),value:a,onChange:e=>o(e.target.value),autoFocus:!0}),(0,q.jsx)(T,{label:r(`settings.privacy.rulePattern`),hint:r(`settings.privacy.rulePatternHint`),children:(0,q.jsx)(g,{mono:!0,rows:3,value:s,onChange:e=>c(e.target.value)})})]})})}function dt(){let{t:e}=y(),{toast:t}=L(),n=Ie(),r=m(),i=l(),[a,o]=(0,G.useState)(``),s=i.data,c=r.data?.settings.enabled??!1;return(0,q.jsx)(A,{title:e(`settings.privacy.tester`),footer:e(`settings.privacy.testerHint`),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,q.jsx)(g,{"aria-label":e(`settings.privacy.tester`),placeholder:e(`settings.privacy.testerPlaceholder`),rows:4,mono:!0,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(`div`,{children:(0,q.jsx)(k,{icon:(0,q.jsx)(ie,{className:`size-3.5`}),disabled:!c||!a.trim(),loading:i.isPending,onClick:()=>i.mutate({text:a},{onError:e=>t(I(e),`error`)}),children:e(`settings.privacy.runTest`)})}),s&&(0,q.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] px-3 py-2 text-[12px]`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s.blocked&&(0,q.jsx)(D,{tone:`red`,children:e(`settings.privacy.wouldBlock`)}),s.wouldRedact>0&&(0,q.jsx)(D,{tone:`orange`,children:e(`settings.privacy.wouldRedact`,{count:s.wouldRedact})}),!s.blocked&&s.wouldRedact===0&&(0,q.jsx)(D,{tone:`green`,children:e(`settings.privacy.noHits`)})]}),s.hits.length>0&&(0,q.jsx)(`ul`,{className:`mt-2 space-y-1`,children:s.hits.map(t=>(0,q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(D,{tone:t.action===`block`?`red`:t.action===`redact`?`orange`:`neutral`,children:e(ot[t.action])}),(0,q.jsxs)(`span`,{children:[n(t.category),` · `,t.ruleId,` × `,t.count]}),t.samples&&t.samples.length>0&&(0,q.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:t.samples.join(` `)})]},`${t.ruleId}:${t.action}`))})]})]})})}var ft=[`today`,`7d`,`30d`,`all`];function pt(){let{t}=y(),n=Ie(),[r,i]=(0,G.useState)(`7d`),a=e(r),o=a.data,s=[{key:`category`,label:t(`privacy.stats.col.category`),render:e=>n(String(e))},{key:`requests`,label:t(`privacy.stats.col.requests`),numeric:!0,width:110},{key:`hits`,label:t(`privacy.stats.col.hits`),numeric:!0,width:96},{key:`warnHits`,label:t(`privacy.stats.col.warn`),numeric:!0,width:84},{key:`blockHits`,label:t(`privacy.stats.col.block`),numeric:!0,width:84},{key:`redactHits`,label:t(`privacy.stats.col.redact`),numeric:!0,width:84}],c=(o?.categories??[]).map(e=>({...e}));return(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`section`,{children:[(0,q.jsx)(C,{action:(0,q.jsx)(h,{ariaLabel:t(`overview.range`),value:r,onChange:i,items:ft.map(e=>({value:e,label:t(`range.${e}`)}))}),children:t(`privacy.stats`)}),a.isLoading&&(0,q.jsx)(M,{lines:3,className:`py-4`}),a.isError&&(0,q.jsx)(ee,{tone:`danger`,title:t(`common.error`),children:I(a.error)}),o&&(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,q.jsx)(rt,{label:t(`privacy.stats.events`),value:o.events,context:t(`range.${r}`)}),(0,q.jsx)(rt,{label:t(`privacy.stats.blocked`),value:o.blocked,context:t(`range.${r}`)}),(0,q.jsx)(rt,{label:t(`privacy.stats.redactions`),value:o.redactions,context:t(`range.${r}`)}),(0,q.jsx)(rt,{label:t(`privacy.stats.dryRun`),value:o.dryRun,context:t(`range.${r}`)})]})]}),(0,q.jsxs)(`section`,{children:[(0,q.jsx)(C,{children:t(`privacy.stats.byCategory`)}),o&&o.categories.length===0&&(0,q.jsx)(`div`,{className:`card`,children:(0,q.jsx)(mt,{})}),o&&o.categories.length>0&&(0,q.jsx)(B,{caption:t(`privacy.stats.byCategory`),rows:c,columns:s,rowKey:`category`,defaultSort:{key:`hits`,direction:`desc`}})]}),(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-[720px]`,children:(0,q.jsx)(st,{})})]})}function mt(){let{t:e}=y();return(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-center`,children:[(0,q.jsx)(ie,{className:`size-6 text-[var(--text-muted)]`}),(0,q.jsx)(`div`,{className:`text-[13px]`,children:e(`privacy.logs.empty`)}),(0,q.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.empty.detail`)})]})}var ht=[`overview`,`logs`,`rules`,`tester`];function gt(){let{t:e}=y(),{tab:t}=ne(),n=se(),r=ht.includes(t)?t:`overview`;return(0,q.jsx)(fe,{title:e(`nav.privacy`),subtitle:e(`settings.privacy.footer`),children:(0,q.jsxs)(z,{value:r,onValueChange:e=>n(`/privacy/${e}`,{replace:!0}),children:[(0,q.jsx)(ce,{"aria-label":e(`nav.privacy`),children:ht.map(t=>(0,q.jsx)(re,{value:t,children:e(`privacy.tab.${t}`)},t))}),(0,q.jsx)(W,{value:`overview`,className:`pt-5`,children:(0,q.jsx)(pt,{})}),(0,q.jsx)(W,{value:`logs`,className:`pt-4`,children:(0,q.jsx)(Be,{})}),(0,q.jsx)(W,{value:`rules`,className:`pt-5`,children:(0,q.jsx)(ct,{})}),(0,q.jsx)(W,{value:`tester`,className:`pt-5 [&>div]:mx-auto [&>div]:max-w-[680px]`,children:(0,q.jsx)(dt,{})})]})})}export{gt as PrivacyPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{At as e,Dn as t,Dt as n,Et as r,Fn as i,Gn as a,Gr as o,H as s,Hr as c,Ia as l,In as u,Ln as d,Ma as f,Na as p,Nn as m,Nr as h,On as g,Ot as _,Pt as v,Q as y,Rr as b,Rt as x,Ti as S,Un as ee,V as C,Vn as te,Vr as ne,Wn as w,Xn as T,Xt as re,Y as ie,Zt as ae,_ as oe,_i as se,a as E,ar as ce,b as le,bn as ue,br as de,c as fe,cn as D,ct as O,d as k,di as A,dr as pe,dt as me,f as j,fi as he,gt as ge,h as _e,hn as ve,ht as ye,i as be,it as xe,ja as Se,jt as Ce,l as M,m as N,mr as we,n as P,nr as Te,nt as F,on as Ee,ot as I,p as L,pi as De,pn as Oe,qn as ke,r as R,rr as Ae,rt as je,sn as Me,t as z,tr as Ne,u as B,ur as Pe,v as V,xn as Fe,xt as H,y as U,yn as Ie,zr as Le}from"./alert-BadMvy1R.js";import{a as W,i as G,n as Re,o as K,r as q}from"./overlays-D-LaJu2w.js";import{a as ze,i as J,n as Y,o as Be,t as Ve}from"./ProvidersPage-Ca7aGIQg.js";import{t as He}from"./arrow-down-Cv-6a_e3.js";import{t as Ue}from"./arrow-left-dS7bcLEo.js";import{t as We}from"./cloud-download-CpuzW7lP.js";import{t as Ge}from"./download-DhWYUpCm.js";import{t as Ke}from"./ellipsis-DhDdch5j.js";import{t as qe}from"./external-link-D3yhOoFs.js";import{n as Je}from"./radio-cards-Geph_wiF.js";import{t as Ye}from"./log-out-DV1PNbkn.js";import{t as Xe}from"./power-DF2viDB7.js";import{t as Ze}from"./rotate-ccw-BxvPRjim.js";import{$ as Qe,C as X,E as $e,K as et,N as Z,Q as tt,T as nt,V as rt,_ as it,a as at,h as ot,o as st,q as ct,s as lt,w as ut,z as dt}from"./index-BUGU_FDT.js";import{t as ft}from"./checkbox-CaaP8Tue.js";import{t as pt}from"./confirm-morph-XE52Kxj6.js";var mt={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`}]]};mt.node;var ht=H(mt),gt={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`}]]};gt.node;var _t=H(gt),vt={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`}]]};vt.node;var yt=H(vt),bt={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`}]]};bt.node;var xt=H(bt),St={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`}]]};St.node;var Ct=H(St),wt={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`]};wt.node;var Tt=H(wt),Et={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`}]]};Et.node;var Dt=H(Et),Q=l(p(),1),$=f();function Ot({usage:e,compact:t=!1}){let{t:n}=O(),r=[{label:n(`providers.usage.requests`),values:[e?.today.requests,e?.total.requests],format:(e,n=t)=>ie(e,n)},{label:n(`providers.usage.tokens`),values:[e?.today.tokens,e?.total.tokens],format:(e,n=t)=>ie(e,n)},{label:n(`providers.usage.cost`),values:[e?.today.costNanoUsd,e?.total.costNanoUsd],format:(e,n=t)=>y(xe(e),{compact:n})}];return(0,$.jsxs)(`table`,{className:I(`w-full table-fixed text-right tabular-nums`,t?`text-[11px]`:`text-[12px]`),"aria-label":n(`providers.usage.title`),children:[(0,$.jsx)(`thead`,{className:`text-[var(--text-muted)]`,children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{scope:`col`,className:`w-[34%] pb-1 text-left font-normal`,children:(0,$.jsx)(`span`,{className:`sr-only`,children:n(`providers.usage.title`)})}),(0,$.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:n(`providers.usage.today`)}),(0,$.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:n(`providers.usage.total`)})]})}),(0,$.jsx)(`tbody`,{children:r.map(e=>(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{scope:`row`,className:`py-0.5 text-left font-normal text-[var(--text-secondary)]`,children:e.label}),e.values.map((t,n)=>(0,$.jsx)(`td`,{className:`truncate py-0.5 pl-1 font-mono`,title:t==null?void 0:e.format(t,!1),children:t==null?`—`:e.format(t)},n))]},e.label))})]})}function kt({timeZone:e}){let{t}=O();return(0,$.jsxs)(`p`,{className:`text-[11px] leading-relaxed text-[var(--text-muted)]`,children:[t(`providers.usage.hint`),e&&(0,$.jsxs)($.Fragment,{children:[` `,t(`providers.usage.dayHint`,{zone:e})]})]})}var At={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`},jt={imported:`green`,updated:`accent`,ready:`accent`,duplicate:`neutral`,invalid_format:`orange`,failed:`red`},Mt={batch:`providers.accounts.import.batchTitle`,token:`providers.accounts.import.tokenTitle`,apiKey:`providers.accounts.import.apiKeyTitle`};function Nt(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 Pt(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:Nt(e))}return n}function Ft({providerId:e,info:t,mode:n,providerProxy:r,onClose:i}){let{t:a}=O(),{toast:o}=K(),s=Ie(e),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(null),m=(0,Q.useMemo)(()=>Pt(c),[c]);if((0,Q.useEffect)(()=>{n!==null&&(l(``),p(null))},[n]),n===null)return(0,$.jsx)(G,{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`),y=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(W(e),`error`)});return(0,$.jsx)(G,{open:!0,onOpenChange:e=>!e&&i(),title:a(Mt[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)(le,{mono:!0,rows:n===`batch`?8:3,value:c,onChange:e=>l(e.target.value),"aria-label":v,placeholder:v,spellCheck:!1}),(0,$.jsx)(k,{mono:!0,label:a(`providers.accounts.import.proxy`),placeholder:r||a(`providers.accounts.proxyFallbackSystem`),value:u,onChange:e=>d(e.target.value)}),_&&(0,$.jsx)(z,{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)(R,{disabled:m===0,loading:s.isPending&&s.variables?.dryRun===!0,onClick:()=>y(!0),children:a(`providers.accounts.import.preview`)}),(0,$.jsx)(R,{variant:`primary`,disabled:m===0||m>t.maxBatch,loading:s.isPending&&!s.variables?.dryRun,onClick:()=>y(!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)(P,{tone:jt[e.status],children:a(At[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 It(e,t=Date.now()){return e.enabled?e.status===`active`?e.cooldownUntilUtc&&new Date(e.cooldownUntilUtc).getTime()>t?`cooling`:`usable`:`dead`:`disabled`}var Lt={usable:`var(--success)`,cooling:`var(--warning)`,dead:`var(--danger)`,disabled:`var(--text-muted)`},Rt={active:`providers.subscription.status.active`,expired:`providers.subscription.status.expired`,revoked:`providers.subscription.status.revoked`};function zt(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 Bt({account:e,index:t,actions:n,selected:r,selecting:i,onToggleSelect:a,onMove:o,quotaPending:c,usage:l}){let{t:u,locale:d}=O(),f=It(e),p=e.displayName||e.accountEmail||e.keyMasked||e.id,m=e.kind===`api_key`,h=e.plan?.trim(),g=f===`cooling`?{text:u(`providers.subscription.cooldown`,{when:s(e.cooldownUntilUtc,d)}),tone:`var(--warning)`}:f===`dead`?{text:e.lastError||u(Rt[e.status]),tone:`var(--danger)`}:m?{text:e.keyMasked??u(`providers.accounts.neverExpires`),tone:void 0}:e.expiresAtUtc?{text:u(`providers.accounts.expiresAt`,{when:s(e.expiresAtUtc,d)}),tone:void 0}:null,_=[{id:`activate`,label:u(`providers.subscription.activate`),icon:(0,$.jsx)(ht,{className:`size-3.5`}),disabled:e.isCurrent||f===`dead`,onSelect:()=>n.activate(e)},{id:`toggle`,label:u(e.enabled?`providers.subscription.disable`:`providers.subscription.enable`),icon:(0,$.jsx)(Xe,{className:`size-3.5`}),onSelect:()=>n.toggleEnabled(e)},...o?[{id:`up`,label:u(`providers.subscription.moveUp`),icon:(0,$.jsx)(et,{className:`size-3.5`}),disabled:!o.up,onSelect:()=>o.up?.()},{id:`down`,label:u(`providers.subscription.moveDown`),icon:(0,$.jsx)(He,{className:`size-3.5`}),disabled:!o.down,onSelect:()=>o.down?.()}]:[],{id:`quota`,separatorBefore:!0,label:u(`providers.subscription.quotaRefresh`),icon:(0,$.jsx)(Be,{className:`size-3.5`}),disabled:f===`dead`,onSelect:()=>n.refreshQuota(e)},...m?[]:[{id:`refresh`,label:u(`providers.subscription.refreshToken`),icon:(0,$.jsx)(Ze,{className:`size-3.5`}),disabled:e.status===`revoked`,onSelect:()=>n.refreshToken(e)},{id:`relogin`,label:u(`providers.subscription.relogin`),disabled:e.status===`active`,onSelect:()=>n.relogin(e)}],{id:`remove`,label:u(`providers.subscription.logout`),icon:(0,$.jsx)(Z,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>n.remove(e)}],v=u(f===`disabled`?`providers.subscription.disabled`:Rt[e.status]),y=u(m?`providers.accounts.kind.api_key`:`providers.accounts.kind.oauth`),b=e.quota?.session?.usedPercent!=null||e.quota?.weekly?.usedPercent!=null||e.quota?.credits?.usedPercent!=null;return(0,$.jsxs)(`div`,{"data-testid":`account-card`,className:I(`group card relative flex min-h-[292px] min-w-0 cursor-pointer flex-col overflow-hidden transition-colors hover:bg-[var(--fill)]`,e.isCurrent&&`ring-1 ring-[var(--accent)]`,r&&`bg-[var(--accent-subtle)]`,f===`disabled`&&`opacity-55`),onClick:()=>i?a(e.id):n.open(e),children:[(0,$.jsxs)(`div`,{className:`relative shrink-0 px-3 pb-3 pt-2.5`,style:{background:zt(h,m)},children:[(f===`cooling`||f===`dead`)&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-y-0 left-0 w-[3px]`,style:{background:Lt[f]}}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:I(`flex size-5 items-center justify-center`,!i&&!r&&`hidden group-hover:flex`),onClick:e=>e.stopPropagation(),children:(0,$.jsx)(ft,{checked:r,onCheckedChange:()=>a(e.id),"aria-label":u(`providers.accounts.select`,{name:p})})}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(`span`,{role:`img`,"aria-label":v,className:`size-1.5 shrink-0 rounded-full`,style:{background:Lt[f]}}),(0,$.jsx)(`span`,{"aria-hidden":!0,children:v})]}),e.httpProxy&&(0,$.jsx)(`span`,{title:`${u(`providers.accounts.proxyBadge`)}: ${e.httpProxy}`,className:`shrink-0 text-[var(--text-muted)]`,children:(0,$.jsx)(ye,{className:`size-3.5`,"aria-label":u(`providers.accounts.proxyBadge`)})}),(0,$.jsx)(`span`,{className:`-mr-1.5 ml-auto shrink-0`,onClick:e=>e.stopPropagation(),children:(0,$.jsx)(Re,{iconOnly:!0,label:u(`common.more`),icon:(0,$.jsx)(Ke,{className:`size-4`}),items:_})})]}),(0,$.jsx)(`div`,{className:`mt-1.5 truncate text-[17px] font-bold tracking-[.01em]`,title:h||y,children:h||y})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pb-3 pt-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-[13px] font-medium outline-none focus-visible:underline`,title:p,onClick:t=>{t.stopPropagation(),i?a(e.id):n.open(e)},children:p}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 items-center gap-1 whitespace-nowrap text-[11px] text-[var(--text-muted)]`,children:[e.isCurrent&&(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[var(--success)]`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`●`}),(0,$.jsx)(`span`,{children:u(`providers.subscription.current`)})]}),e.isCurrent&&(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0`,children:y}),e.source&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{className:`truncate`,children:u(`providers.accounts.source.${e.source}`)})]}),(0,$.jsx)(`span`,{className:`ml-auto shrink-0 pl-1 opacity-0 group-hover:opacity-100`,children:u(`providers.accounts.order`,{n:t+1})})]}),(0,$.jsx)(`div`,{className:`mt-1.5 min-h-[28px]`,children:g&&(f===`cooling`||f===`dead`||!b)&&(0,$.jsx)(`div`,{className:`line-clamp-2 text-[11px] leading-snug`,style:{color:g.tone??`var(--text-muted)`},title:g.text,children:g.text})}),(0,$.jsx)(`div`,{className:`mt-3 shrink-0 border-t border-[var(--border-subtle)] pt-2`,children:(0,$.jsx)(Ot,{usage:l,compact:!0})}),f===`dead`?(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:u(`providers.accounts.signedOut`)}),!m&&(0,$.jsx)(R,{size:`sm`,className:`ml-auto`,onClick:t=>{t.stopPropagation(),n.relogin(e)},children:u(`providers.subscription.relogin`)})]}):(0,$.jsx)(Ht,{quota:e.quota??null,pending:c})]})]})}var Vt=10;function Ht({quota:e,pending:t}){let{t:n,locale:r}=O(),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:I(`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*Vt),o=e.reset?n(`providers.subscription.quotaResets`,{when:s(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:Vt},(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 Ut({quota:e,className:t}){let{t:n,locale:r}=O(),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:I(`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)(Wt,{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 Wt({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 Gt={available:`green`,redeemed:`neutral`,expired:`orange`};function Kt({account:e,providerId:t}){let{t:n}=O(),{toast:r,confirm:i}=K(),a=de(e.id,e.status===`active`),o=ae(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 S&&e.status===409?W(e):`${n(`providers.subscription.credits.consumeFailed`)}:${W(e)}`,`error`)})};return(0,$.jsxs)(B,{title:n(`providers.subscription.credits.title`),footer:n(`providers.subscription.credits.footer`),children:[a.isLoading&&(0,$.jsx)(V,{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)(N,{className:I(t&&`opacity-55`),label:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(_t,{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)(P,{tone:Gt[e.status]??`neutral`,children:n(`providers.subscription.credits.status.${e.status}`)}),(0,$.jsx)(R,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(Dt,{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 qt={active:`providers.subscription.status.active`,expired:`providers.subscription.status.expired`,revoked:`providers.subscription.status.revoked`};function Jt({provider:e,account:t,index:n,actions:r,onClose:i,usage:a,usageTimeZone:o}){let{t:c,locale:l}=O(),{toast:u}=K(),d=he(e.id),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``);if((0,Q.useEffect)(()=>{p(t?.displayName??``),h(t?.httpProxy??``)},[t?.id,t?.displayName,t?.httpProxy]),!t)return(0,$.jsx)(G,{open:!1,onOpenChange:i,title:``});let g=It(t),_=t.kind===`api_key`,v=e.templateId===`openai-subscription`,y=e.httpProxy||c(`providers.accounts.proxyFallbackSystem`),b=e=>e?s(e,l):`—`,x=(e,n)=>d.mutate({id:t.id,...e},{onSuccess:()=>u(c(n),`success`),onError:e=>u(W(e),`error`)});return(0,$.jsx)(G,{open:!0,onOpenChange:e=>!e&&i(),title:t.displayName||t.keyMasked||t.id,description:[t.plan,c(_?`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)(R,{size:`sm`,icon:(0,$.jsx)(ht,{className:`size-3.5`}),disabled:t.isCurrent||g===`dead`,onClick:()=>r.activate(t),children:c(`providers.subscription.activate`)}),(0,$.jsx)(R,{size:`sm`,icon:(0,$.jsx)(Be,{className:`size-3.5`}),disabled:g===`dead`,onClick:()=>r.refreshQuota(t),children:c(`providers.subscription.quotaRefresh`)}),!_&&(0,$.jsx)(R,{size:`sm`,icon:(0,$.jsx)(Ze,{className:`size-3.5`}),disabled:t.status===`revoked`,onClick:()=>r.refreshToken(t),children:c(`providers.subscription.refreshToken`)}),!_&&t.status!==`active`&&(0,$.jsx)(R,{size:`sm`,variant:`primary`,onClick:()=>r.relogin(t),children:c(`providers.subscription.relogin`)}),(0,$.jsx)(R,{size:`sm`,variant:`plain`,className:`ml-auto text-[var(--danger)]`,icon:(0,$.jsx)(Z,{className:`size-3.5`}),onClick:()=>r.remove(t),children:c(`providers.subscription.logout`)})]}),g===`dead`&&t.lastError&&(0,$.jsx)(z,{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:c(`providers.usage.title`)}),(0,$.jsx)(`div`,{className:`card px-3 py-2`,children:(0,$.jsx)(Ot,{usage:a})}),(0,$.jsx)(kt,{timeZone:o})]}),(0,$.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h4`,{className:`text-[11px] font-medium text-[var(--text-secondary)]`,children:c(`providers.accounts.detail.identity`)}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,$.jsx)(k,{className:`flex-1`,label:c(`providers.accounts.detail.name`),value:f,onChange:e=>p(e.target.value)}),(0,$.jsx)(R,{disabled:f.trim().length===0||f.trim()===t.displayName,loading:d.isPending&&d.variables?.displayName!==void 0,onClick:()=>x({displayName:f.trim()},`providers.accounts.renamed`),children:c(`common.save`)})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,$.jsx)(k,{className:`flex-1`,mono:!0,label:c(`providers.accounts.detail.proxy`),placeholder:y,value:m,onChange:e=>h(e.target.value)}),(0,$.jsx)(R,{disabled:m.trim()===(t.httpProxy??``),loading:d.isPending&&d.variables?.httpProxy!==void 0,onClick:()=>x({httpProxy:m.trim()},`providers.accounts.proxySaved`),children:c(`common.save`)})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:c(`providers.accounts.detail.proxyHint`,{fallback:y})})]}),t.quota&&(0,$.jsxs)(`section`,{className:`-mx-4 flex flex-col gap-1`,children:[(0,$.jsx)(`h4`,{className:`px-4 text-[11px] font-medium text-[var(--text-secondary)]`,children:c(`providers.accounts.detail.quota`)}),(0,$.jsx)(Ut,{quota:t.quota})]}),v&&g!==`dead`&&(0,$.jsx)(`div`,{className:`-mx-4`,children:(0,$.jsx)(Kt,{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:c(`providers.accounts.detail.credentials`)}),(0,$.jsxs)(`div`,{className:`card divide-y divide-[var(--border)] px-3`,children:[(0,$.jsx)(j,{label:c(`providers.accounts.detail.status`),children:(0,$.jsx)(P,{tone:g===`usable`?`green`:g===`cooling`?`orange`:g===`dead`?`red`:`neutral`,children:c(g===`disabled`?`providers.subscription.disabled`:qt[t.status])})}),t.source&&(0,$.jsx)(j,{label:c(`providers.accounts.detail.source`),children:c(`providers.accounts.source.${t.source}`)}),_?(0,$.jsx)(j,{label:c(`providers.accounts.detail.key`),mono:!0,children:t.keyMasked??`••••`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(j,{label:c(`providers.accounts.detail.expires`),children:b(t.expiresAtUtc)}),(0,$.jsx)(j,{label:c(`providers.accounts.detail.lastRefresh`),children:b(t.lastRefreshAtUtc)})]}),g===`cooling`&&(0,$.jsx)(j,{label:c(`providers.accounts.filter.cooling`),children:b(t.cooldownUntilUtc)}),(0,$.jsx)(j,{label:c(`providers.accounts.detail.order`),children:c(`providers.accounts.order`,{n:n+1})}),(0,$.jsx)(j,{label:c(`providers.accounts.detail.created`),children:b(t.createdAt)}),t.lastError&&g!==`dead`&&(0,$.jsx)(j,{label:c(`providers.accounts.detail.lastError`),children:t.lastError})]})]})]})})}function Yt({provider:e}){let{t}=O(),{toast:n}=K(),r=e.authScheme===`oauth-subscription`,i=c(e.id,r),a=se(e.id);if(!r||!i.data)return null;let o=i.data,s=e=>a.mutate(e,{onError:e=>n(W(e),`error`)}),l=o.claudeSubscription||o.clientPolicy===`claude-code-only`;return!l&&!o.claudeSubscription?null:(0,$.jsxs)(B,{title:t(`providers.subscription.policy.title`),footer:t(`providers.subscription.policy.footer`),children:[l&&(0,$.jsx)(N,{label:t(`providers.subscription.policy.claudeCodeOnly`),detail:t(`providers.subscription.policy.claudeCodeOnlyDetail`),children:(0,$.jsx)(U,{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)(N,{label:t(`providers.subscription.policy.mimic`),detail:t(`providers.subscription.policy.mimicDetail`),children:(0,$.jsx)(U,{label:t(`providers.subscription.policy.mimic`),checked:o.mimicClaudeCode,disabled:a.isPending,onChange:e=>s({mimicClaudeCode:e})})}),l&&o.clientPolicy===`any`&&(0,$.jsx)(`div`,{className:`px-4 py-3`,children:o.mimicClaudeCode?(0,$.jsx)(z,{tone:`warning`,title:t(`providers.subscription.policy.mimicWarning`)}):(0,$.jsx)(z,{tone:`warning`,title:t(`providers.subscription.policy.anyWarning`)})})]})}var Xt=[{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`}],Zt=3e5;function Qt({provider:n}){let{t:i}=O(),{toast:a,confirm:o}=K(),s=Se(),l=n.authScheme===`oauth-subscription`,u=Te(n.id,l),d=ce(n.id,l),f=c(n.id,l),p=se(n.id),m=e(n.id,l),h=Le(n.id),_=ke(n.id),v=re(n.id),y=ve(n.id),b=Pe(n.id),x=Me(n.id),ee=Ce(n.id),C=he(n.id),te=we(n.id),ne=n.templateId===`openai-subscription`,w=t(l&&ne),T=ue(n.id),ie=n.templateId===`github-copilot-subscription`,ae=g(l&&ie),oe=Fe(n.id),[E,le]=(0,Q.useState)(`all`),[de,fe]=(0,Q.useState)(``),[D,A]=(0,Q.useState)(new Set),[pe,me]=(0,Q.useState)(null),[j,ge]=(0,Q.useState)(null),[ye,be]=(0,Q.useState)(!1),[xe,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(!1),[F,Ee]=(0,Q.useState)(!1),[L,De]=(0,Q.useState)(null),[Oe,Ae]=(0,Q.useState)(null),[je,Ne]=(0,Q.useState)(!1),[B,H]=(0,Q.useState)(``),U=(0,Q.useRef)(new Set),Ie=(0,Q.useRef)(new Set),q=(0,Q.useMemo)(()=>u.data??[],[u.data]);if((0,Q.useEffect)(()=>{if(l)for(let e of q){if(e.status!==`active`||Ie.current.has(e.id))continue;let t=e.quota?.fetchedAtUtc?new Date(e.quota.fetchedAtUtc).getTime():0;Number.isFinite(t)&&Date.now()-t<Zt||(Ie.current.add(e.id),y.mutate(e.id,{onError:()=>{}}))}},[q,l]),(0,Q.useEffect)(()=>{let e=new Set(q.map(e=>e.id));A(t=>Array.from(t).every(t=>e.has(t))?t:new Set(Array.from(t).filter(t=>e.has(t)))),pe&&!e.has(pe)&&me(null)},[q,pe]),(0,Q.useEffect)(()=>{if(!F||L?.mode!==`pkce`)return;let e=setInterval(()=>void u.refetch(),3e3);return()=>clearInterval(e)},[F,L,u]),(0,Q.useEffect)(()=>{if(!F||L?.mode!==`pkce`)return;let e=q.find(e=>!U.current.has(e.id));e&&J(!0,e.displayName||e.accountEmail||e.id)},[q,F,L]),(0,Q.useEffect)(()=>{if(!F||L?.mode!==`device`&&L?.mode!==`cli`)return;let e=!1,t=0,n=async()=>{try{let n=await _.mutateAsync(L.state);if(e)return;t=0,n.status===`done`?J(!0,n.account.displayName||n.account.accountEmail||n.account.id):n.status!==`pending`&&n.status!==`slow_down`&&J(!1,void 0,`error`in n?n.error??n.status:n.status)}catch(n){if(e)return;if(n instanceof S&&(n.status===404||n.status===400)){J(!1,void 0,W(n));return}++t>=5&&J(!1,void 0,W(n))}},r=setInterval(()=>void n(),Math.max(L.interval||5,3)*1e3);return()=>{e=!0,clearInterval(r)}},[F,L]),!l)return null;let ze=e=>e.displayName||e.accountEmail||e.keyMasked||e.id,J=(e,t,o)=>{if(s.invalidateQueries({queryKey:r.providerAccounts(n.id)}),e){De(null),Ae(null),Ee(!1),a(i(`providers.subscription.loginOk`,{name:t??``}),`success`);return}o&&Ae(o)},Y=(e,t)=>{U.current=new Set(q.map(e=>e.id)),Ae(null),h.mutate({accountId:e,httpProxy:t},{onSuccess:e=>{be(!1),De(e),Ee(!0),e.mode!==`device`&&window.open(e.authorizeUrl,`_blank`,`noopener`)},onError:e=>{e instanceof S&&e.details?.needsVerification?a(i(`providers.subscription.needsVerification`),`error`):a(W(e),`error`)}})},Be=async()=>{if(L){Ne(!0);try{let e=await _.mutateAsync(L.state);e.status===`done`?J(!0,e.account.displayName||e.account.accountEmail||e.account.id):e.status===`pending`||e.status===`slow_down`?a(i(`providers.subscription.stillWaiting`),`info`):J(!1,void 0,`error`in e?e.error??e.status:e.status)}catch(e){if(e instanceof S&&e.status===404){let t=((await u.refetch()).data??[]).find(e=>!U.current.has(e.id));t?J(!0,t.displayName||t.accountEmail||t.id):J(!1,void 0,W(e))}else J(!1,void 0,W(e))}finally{Ne(!1)}}},Ve=async()=>{if(L&&L.mode===`paste`&&B.trim().length!==0){Ne(!0);try{let e=await v.mutateAsync({state:L.state,code:B.trim()});e.status===`done`?(H(``),J(!0,e.account.displayName||e.account.accountEmail||e.account.id)):J(!1,void 0,`error`in e?e.error??e.status:e.status)}catch(e){J(!1,void 0,W(e))}finally{Ne(!1)}}},He=()=>T.mutate(void 0,{onSuccess:e=>{a(i(`providers.subscription.importOk`,{name:ze(e.account)}),e.warning?`info`:`success`),e.warning&&a(e.warning,`error`),w.refetch()},onError:e=>a(W(e),`error`)}),Ue=()=>oe.mutate(``,{onSuccess:e=>{a(i(`providers.subscription.importOk`,{name:ze(e.account)}),e.warning?`info`:`success`),e.warning&&a(e.warning,`error`)},onError:e=>a(W(e),`error`)}),We=(e,t)=>{let n=q.map(e=>e.id),r=e+t;r<0||r>=n.length||([n[e],n[r]]=[n[r],n[e]],te.mutate(n,{onError:e=>a(W(e),`error`)}))},Ke=async e=>{let t=ze(e);await o({title:i(`providers.subscription.logoutConfirm`,{name:t}),destructive:!0,confirmLabel:i(`providers.subscription.logout`)})&&x.mutate(e.id,{onError:e=>a(W(e),`error`)})},qe={open:e=>me(e.id),activate:e=>ee.mutate(e.id,{onSuccess:()=>a(i(`providers.subscription.activated`,{name:ze(e)}),`success`),onError:e=>a(W(e),`error`)}),toggleEnabled:e=>C.mutate({id:e.id,enabled:!e.enabled},{onError:e=>a(W(e),`error`)}),refreshQuota:e=>y.mutate(e.id,{onError:e=>{e instanceof S&&e.status===501?a(i(`providers.subscription.quotaUnsupported`),`error`):a(W(e),`error`)}}),refreshToken:e=>b.mutate(e.id,{onSuccess:()=>a(i(`providers.subscription.tokenRefreshed`),`success`),onError:e=>a(W(e),`error`)}),relogin:e=>Y(e.id),remove:e=>void Ke(e)},Je=e=>A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Ye=async e=>{let t=q.filter(e=>D.has(e.id));P(!0);let o=0;for(let n of t)try{await e(n),o++}catch(e){a(`${ze(n)}: ${W(e)}`,`error`)}P(!1),A(new Set),s.invalidateQueries({queryKey:r.providerAccounts(n.id)}),o>0&&a(i(`providers.accounts.bulkDone`,{n:o}),`success`)},Ze=async()=>{await o({title:i(`providers.accounts.bulkDeleteConfirm`,{n:D.size}),detail:i(`providers.accounts.bulkDeleteDetail`),destructive:!0,confirmLabel:i(`common.delete`)})&&await Ye(e=>x.mutateAsync(e.id))},Qe=q.map(e=>It(e)),X=e=>e===`all`?q.length:Qe.filter(t=>t===e).length,$e=de.trim().toLowerCase(),et=q.map((e,t)=>({a:e,index:t,state:Qe[t]})).filter(({a:e,state:t})=>(E===`all`||t===E)&&($e.length===0||[e.displayName,e.accountEmail,e.keyMasked,e.plan].some(e=>e?.toLowerCase().includes($e)))),tt=q.find(e=>e.id===pe)??null,nt=m.data,it=D.size>0,at=[{id:`login`,label:i(`providers.accounts.addLogin`),icon:(0,$.jsx)(xt,{className:`size-3.5`}),onSelect:()=>Y()},{id:`login-proxy`,label:i(`providers.accounts.addLoginProxy`),onSelect:()=>be(!0)},...ne&&w.data?.available?[{id:`codex`,separatorBefore:!0,label:i(`providers.subscription.importCodex`),icon:(0,$.jsx)(Ge,{className:`size-3.5`}),onSelect:He}]:[],...ie?[{id:`copilot`,separatorBefore:!0,label:i(`providers.subscription.importCopilot`),icon:(0,$.jsx)(Ge,{className:`size-3.5`}),onSelect:Ue}]:[],...nt?.supported?[{id:`token`,separatorBefore:!(ne&&w.data?.available)&&!ie,label:i(`providers.accounts.addToken`),onSelect:()=>ge(`token`)}]:[],...nt?.apiKey?[{id:`apikey`,label:i(`providers.accounts.addApiKey`),icon:(0,$.jsx)(rt,{className:`size-3.5`}),onSelect:()=>ge(`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:i(`providers.accounts.statTotal`,{n:q.length})}),(0,$.jsx)(`span`,{style:{color:`var(--success)`},children:i(`providers.accounts.statUsable`,{n:X(`usable`)})}),X(`cooling`)>0&&(0,$.jsx)(`span`,{style:{color:`var(--warning)`},children:i(`providers.accounts.statCooling`,{n:X(`cooling`)})}),X(`dead`)>0&&(0,$.jsx)(`span`,{style:{color:`var(--danger)`},children:i(`providers.accounts.statDead`,{n:X(`dead`)})}),(0,$.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`providers.accounts.providerProxy`,{proxy:n.httpProxy||i(`providers.accounts.proxyFallbackSystem`)})})]}),f.data&&(0,$.jsx)($t,{policy:f.data,onChange:e=>p.mutate({switchMode:e},{onError:e=>a(W(e),`error`)})})]}),f.data&&(0,$.jsx)(`p`,{className:`-mt-1 mb-3 px-1 text-[11px] text-[var(--text-muted)]`,children:i(f.data.switchMode===`balanced`?`providers.subscription.policy.balancedDetail`:f.data.switchMode===`failover`?`providers.subscription.policy.failoverDetail`:`providers.subscription.policy.manualDetail`)}),(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(_e,{className:`w-52`,value:de,onChange:fe,placeholder:i(`providers.accounts.search`)}),(0,$.jsx)(`div`,{role:`group`,"aria-label":i(`providers.accounts.filterLabel`),className:`mr-auto flex flex-wrap gap-1`,children:Xt.filter(e=>e.value===`all`||X(e.value)>0).map(e=>(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":E===e.value,onClick:()=>le(e.value),className:I(`rounded-full px-2.5 py-0.5 text-[11.5px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--fill)]`,E===e.value&&`bg-[var(--fill)] text-[var(--text)]`),children:[i(e.label),(0,$.jsx)(`span`,{className:`ml-1 text-[var(--text-muted)]`,children:X(e.value)})]},e.value))}),nt?.supported&&(0,$.jsx)(R,{size:`sm`,icon:(0,$.jsx)(yt,{className:`size-3.5`}),onClick:()=>ge(`batch`),children:i(`providers.accounts.batchImport`)}),(0,$.jsx)(Re,{label:i(`providers.accounts.add`),icon:(0,$.jsx)(dt,{className:`size-3.5`}),items:at})]}),ne&&w.data?.available&&(0,$.jsxs)(`p`,{className:`mb-2 px-1 text-[11px] text-[var(--text-muted)]`,children:[i(`providers.subscription.localCodexFound`,{who:w.data.accountEmail??w.data.plan??i(`providers.subscription.unknownAccount`)}),w.data.detail?` · ${w.data.detail}`:``]}),ie&&(0,$.jsxs)(`p`,{className:`mb-2 px-1 text-[11px] text-[var(--text-muted)]`,children:[ae.data?.available?i(`providers.subscription.localCopilotFound`,{source:ae.data.source??``}):i(`providers.subscription.localCopilotHint`),ae.data?.detail?` · ${ae.data.detail}`:``]}),u.isLoading?(0,$.jsx)(V,{className:`my-4`}):q.length===0?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Y(),className:`flex w-full flex-col items-center gap-1 rounded-[var(--radius-card,12px)] border border-dashed border-[var(--border)] px-4 py-6 text-[12px] text-[var(--text-secondary)] hover:border-[var(--accent)] hover:text-[var(--text)]`,children:[(0,$.jsx)(`span`,{children:i(`providers.subscription.none`)}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[var(--accent)]`,children:[(0,$.jsx)(dt,{className:`size-3.5`}),` `,i(`providers.subscription.login`)]})]}):et.length===0?(0,$.jsx)(`div`,{className:`px-4 py-5 text-center text-[12px] text-[var(--text-secondary)]`,children:i(`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)(Bt,{account:e,usage:d.data?.accounts.find(t=>t.accountId===e.id),index:t,actions:qe,selected:D.has(e.id),selecting:it,onToggleSelect:Je,quotaPending:y.isPending&&y.variables===e.id,onMove:q.length>1?{up:t>0?()=>We(t,-1):void 0,down:t<q.length-1?()=>We(t,1):void 0}:void 0},e.id))}),d.isError&&(0,$.jsx)(z,{tone:`danger`,title:i(`providers.usage.error`),children:W(d.error)}),q.length>0&&(0,$.jsx)(kt,{timeZone:d.data?.timeZone}),(0,$.jsx)(`p`,{className:`mt-2 px-1 text-[11px] text-[var(--text-muted)]`,children:i(`providers.subscription.footer`)}),it&&(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:i(`providers.accounts.selected`,{n:D.size})}),(0,$.jsx)(R,{size:`sm`,icon:(0,$.jsx)(Xe,{className:`size-3.5`}),disabled:N,onClick:()=>void Ye(e=>C.mutateAsync({id:e.id,enabled:!0})),children:i(`providers.subscription.enable`)}),(0,$.jsx)(R,{size:`sm`,disabled:N,onClick:()=>void Ye(e=>C.mutateAsync({id:e.id,enabled:!1})),children:i(`providers.subscription.disable`)}),(0,$.jsx)(R,{size:`sm`,disabled:N,onClick:()=>void Ye(e=>y.mutateAsync(e.id)),children:i(`providers.subscription.quotaRefresh`)}),(0,$.jsx)(R,{size:`sm`,className:`text-[var(--danger)]`,icon:(0,$.jsx)(Z,{className:`size-3.5`}),disabled:N,onClick:()=>void Ze(),children:i(`common.delete`)}),(0,$.jsx)(R,{size:`sm`,variant:`plain`,onClick:()=>A(new Set),children:i(`providers.accounts.clearSelection`)})]}),(0,$.jsx)(`div`,{className:`mt-5`,children:(0,$.jsx)(Yt,{provider:n})}),(0,$.jsx)(Jt,{provider:n,account:tt,usage:d.data?.accounts.find(e=>e.accountId===tt?.id),usageTimeZone:d.data?.timeZone,index:tt?q.indexOf(tt):0,actions:qe,onClose:()=>me(null)}),nt&&(0,$.jsx)(Ft,{providerId:n.id,info:nt,mode:j,providerProxy:n.httpProxy,onClose:()=>ge(null)}),(0,$.jsx)(G,{open:ye,onOpenChange:be,title:i(`providers.accounts.loginProxyTitle`),description:i(`providers.accounts.loginProxyDesc`),footer:(0,$.jsx)(R,{variant:`primary`,loading:h.isPending,disabled:xe.trim().length===0,onClick:()=>Y(void 0,xe),children:i(`providers.accounts.loginProxyStart`)}),children:(0,$.jsx)(k,{mono:!0,label:i(`providers.accounts.detail.proxy`),placeholder:`socks5://127.0.0.1:1080`,value:xe,onChange:e=>M(e.target.value)})}),(0,$.jsxs)(G,{open:F,onOpenChange:e=>{Ee(e),e||(De(null),Ae(null))},title:i(`providers.subscription.login`),description:i(`providers.subscription.loginDesc`),children:[Oe&&(0,$.jsx)(z,{tone:`danger`,title:i(`providers.subscription.loginFailed`),children:Oe}),L?.mode===`paste`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(z,{tone:`info`,title:i(`providers.subscription.pasteTitle`),children:i(`providers.subscription.pasteDetail`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsx)(R,{onClick:()=>window.open(L.authorizeUrl,`_blank`,`noopener`),children:i(`providers.subscription.openAuthorize`)})}),(0,$.jsx)(k,{mono:!0,value:B,onChange:e=>H(e.target.value),placeholder:i(`providers.subscription.pastePlaceholder`),"aria-label":i(`providers.subscription.pasteCode`)}),(0,$.jsx)(R,{variant:`primary`,loading:je,onClick:()=>void Ve(),children:i(`providers.subscription.pasteSubmit`)})]}),L?.mode===`pkce`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(z,{tone:`info`,title:i(`providers.subscription.waiting`),children:i(`providers.subscription.waitingDetail`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(R,{onClick:()=>window.open(L.authorizeUrl,`_blank`,`noopener`),children:i(`providers.subscription.openAuthorize`)}),(0,$.jsx)(R,{variant:`primary`,onClick:()=>{s.invalidateQueries({queryKey:r.providerAccounts(n.id)}),u.refetch()},children:i(`providers.subscription.doneAuthorize`)})]})]}),L?.mode===`cli`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(z,{tone:`info`,title:i(`providers.subscription.waiting`),children:i(`providers.subscription.cliDetail`)}),(0,$.jsx)(R,{onClick:()=>window.open(L.authorizeUrl,`_blank`,`noopener`),children:i(`providers.subscription.openAuthorize`)})]}),L?.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:i(`providers.subscription.deviceCode`)}),(0,$.jsx)(`div`,{className:`selectable font-mono text-[18px] font-medium tracking-wide`,children:L.userCode})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[L.verificationUrl&&(0,$.jsx)(R,{onClick:()=>window.open(L.verificationUrl??void 0,`_blank`,`noopener`),children:i(`providers.subscription.visitPage`)}),(0,$.jsx)(R,{variant:`primary`,loading:je,onClick:()=>void Be(),children:i(`providers.subscription.checkNow`)})]}),(0,$.jsx)(z,{tone:`info`,title:i(`providers.subscription.waiting`),children:i(`providers.subscription.checkNowHint`)})]})]})]})}function $t({policy:e,onChange:t}){let{t:n}=O();return(0,$.jsx)(oe,{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 en({provider:e}){let{t}=O(),n=Te(e.id),r=ce(e.id),i=te(e.id),a=c(e.id,!0),o=se(e.id),{toast:s}=K(),[l,u]=(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:[i.isLoading&&(0,$.jsx)(V,{lines:1}),i.isError&&(0,$.jsx)(z,{tone:`danger`,title:t(`pluginAccounts.noPlugin`),children:W(i.error)}),i.data?.map(e=>(0,$.jsx)(R,{variant:e.index===0?`primary`:void 0,icon:e.type===`api`?(0,$.jsx)(rt,{className:`size-3.5`}):(0,$.jsx)(xt,{className:`size-3.5`}),onClick:()=>u(e),children:e.label||t(e.type===`api`?`pluginAccounts.apiKey`:`pluginAccounts.browser`)},e.index))]}),n.isLoading&&(0,$.jsx)(V,{lines:3}),n.data?.length===0&&(0,$.jsx)(`div`,{className:`card`,children:(0,$.jsx)(fe,{icon:(0,$.jsx)(Ct,{className:`size-6`}),title:t(`pluginAccounts.empty`),detail:t(`pluginAccounts.emptyDetail`)})}),n.data&&n.data.length>1&&a.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(a.data.switchMode===`balanced`?`providers.subscription.policy.balancedDetail`:a.data.switchMode===`failover`?`providers.subscription.policy.failoverDetail`:`providers.subscription.policy.manualDetail`)}),(0,$.jsx)($t,{policy:a.data,onChange:e=>o.mutate({switchMode:e},{onError:e=>s(W(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)(nn,{provider:e,account:t,gatewayUsage:r.data?.accounts.find(e=>e.accountId===t.id)},t.id))}),r.isError&&(0,$.jsx)(z,{tone:`danger`,title:t(`providers.usage.error`),children:W(r.error)}),n.data&&n.data.length>0&&(0,$.jsx)(kt,{timeZone:r.data?.timeZone}),(0,$.jsx)(tn,{provider:e}),l&&(0,$.jsx)(rn,{provider:e,method:l,onClose:()=>u(null)})]})}function tn({provider:e}){let{t,locale:n}=O(),{toast:r}=K(),i=u(e.id),a=d(e.id);if(!i.data?.supported)return null;let o=e=>a.mutate(e,{onError:e=>r(W(e),`error`)}),c={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)(U,{checked:i.data.on,label:t(`pluginAccounts.checkinOn`),onChange:e=>o(e)}),(0,$.jsx)(R,{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?s(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)(P,{tone:c[e.outcome]??`neutral`,children:t(`pluginAccounts.outcome.${e.outcome}`)}):(0,$.jsx)(P,{children:t(`pluginAccounts.checkinNever`)})]},e.accountId)})]})}function nn({provider:e,account:t,gatewayUsage:n}){let{t:r,locale:i}=O(),{toast:o,confirm:c}=K(),l=w(e.id),[u,d]=(0,Q.useState)(!1),f=e.settings?.plugin?.usage===!0,p=a(e.id,t.id,u),m=async()=>{await c({title:r(`pluginAccounts.signOutConfirm`,{name:t.displayName}),confirmLabel:r(`pluginAccounts.signOut`),destructive:!0})&&l.mutate(t.id,{onError:e=>o(W(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)(P,{tone:`accent`,children:r(`pluginAccounts.current`)}),(0,$.jsx)(P,{tone:t.status===`active`?`green`:`red`,children:r(t.status===`active`?`pluginAccounts.active`:`pluginAccounts.lapsed`)}),f&&(0,$.jsx)(R,{size:`sm`,onClick:()=>d(e=>!e),children:r(`pluginAccounts.usage`)}),(0,$.jsx)(R,{size:`sm`,variant:`destructive`,icon:(0,$.jsx)(Ye,{className:`size-3.5`}),onClick:()=>void m(),children:r(`pluginAccounts.signOut`)})]}),t.status!==`active`&&(0,$.jsx)(`p`,{className:`text-[12px] text-[var(--danger)]`,children:r(`pluginAccounts.lapsedDetail`)}),(0,$.jsx)(Ot,{usage:n}),u&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md bg-[var(--surface-muted)] px-3 py-2`,children:[p.isLoading&&(0,$.jsx)(V,{lines:2}),p.isError&&(0,$.jsx)(`span`,{className:`text-[12px] text-[var(--danger)]`,children:W(p.error)}),p.data?.error&&(0,$.jsx)(`span`,{className:`text-[12px] text-[var(--danger)]`,children:p.data.error}),p.data?.plan&&(0,$.jsx)(j,{label:r(`pluginAccounts.plan`),children:p.data.plan}),p.data?.until&&(0,$.jsx)(j,{label:r(`pluginAccounts.until`),children:s(p.data.until,i)}),p.data?.windows?.map(e=>(0,$.jsxs)(j,{label:e.name,children:[e.display??(e.limit?`${e.amount??e.used??0} / ${e.limit} ${e.unit??``}`:`${e.used??0}%`),e.resetsAt?` · ${r(`pluginAccounts.resets`,{at:s(new Date(e.resetsAt>0xe8d4a51000?e.resetsAt:e.resetsAt*1e3).toISOString(),i)})}`:``]},e.name))]})]})}function rn({provider:e,method:t,onClose:r}){let{t:a}=O(),{toast:o}=K(),[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)(``),[x,S]=(0,Q.useState)(null),C=b(e.id),te=i(e.id),w=ne(e.id),T=ee(e.id,x).data;(0,Q.useEffect)(()=>{let r=!0;return n(e.id,t.index,s).then(e=>{r&&(u(e.prompt),f(e.prompt?.type===`select`?e.prompt.options?.[0]?.value??``:``))}).catch(e=>r&&o(W(e),`error`)),()=>{r=!1}},[e.id,t.index,s,o]),(0,Q.useEffect)(()=>{T?.state===`done`&&(o(a(`pluginAccounts.signedIn`),`success`),r())},[T?.state,r,a,o]);let re=async()=>{if(!l)return;let n=await _(e.id,t.index,l.key,d).catch(()=>({error:null}));if(n.error)return m(n.error);m(null),c(e=>({...e,[l.key]:d}))};return(0,$.jsxs)(G,{open:!0,onOpenChange:e=>!e&&r(),title:a(`pluginAccounts.signInTitle`,{name:e.name}),description:t.label,width:520,children:[l===void 0&&(0,$.jsx)(V,{lines:2}),l&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(M,{label:l.message,error:p??void 0,children:l.type===`select`?(0,$.jsx)(q,{value:d,onChange:f,options:(l.options??[]).map(e=>({value:e.value,label:e.label,description:e.hint??void 0}))}):(0,$.jsx)(k,{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)(R,{variant:`primary`,onClick:()=>void re(),children:a(`pluginAccounts.continue`)})})]}),l===null&&t.type===`api`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(M,{label:a(`pluginAccounts.key`),children:(0,$.jsx)(k,{mono:!0,type:`password`,value:h,placeholder:t.placeholder??void 0,onChange:e=>g(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(R,{variant:`primary`,disabled:!h.trim()||te.isPending,onClick:()=>te.mutate({method:t.index,inputs:s,key:h},{onSuccess:()=>(o(a(`pluginAccounts.signedIn`),`success`),r()),onError:e=>o(W(e),`error`)}),children:a(`pluginAccounts.signIn`)})})]}),l===null&&t.type!==`api`&&!T&&(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(R,{variant:`primary`,icon:(0,$.jsx)(qe,{className:`size-3.5`}),disabled:C.isPending,onClick:()=>C.mutate({method:t.index,inputs:s},{onSuccess:e=>{S(e.id),e.url&&window.open(e.url,`_blank`,`noopener`)},onError:e=>o(W(e),`error`)}),children:a(`pluginAccounts.openPage`)})}),T&&T.state!==`done`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[T.instructions&&(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[12px] text-[var(--text-secondary)]`,children:T.instructions}),T.deviceCode&&(0,$.jsx)(j,{label:a(`pluginAccounts.deviceCode`),mono:!0,children:T.deviceCode}),T.url&&(0,$.jsx)(R,{icon:(0,$.jsx)(qe,{className:`size-3.5`}),onClick:()=>window.open(T.url,`_blank`,`noopener`),children:a(`pluginAccounts.openAgain`)}),T.state===`waiting`&&T.pasteCode&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(M,{label:a(`pluginAccounts.code`),children:(0,$.jsx)(k,{mono:!0,value:v,onChange:e=>y(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(R,{variant:`primary`,disabled:!v.trim()||w.isPending,onClick:()=>w.mutate({flow:T.id,code:v.trim()},{onError:e=>o(W(e),`error`)}),children:a(`pluginAccounts.signIn`)})})]}),T.state===`waiting`&&!T.pasteCode&&(0,$.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:a(`pluginAccounts.waiting`)}),T.state===`failed`&&(0,$.jsx)(z,{tone:`danger`,title:a(`pluginAccounts.failed`),children:T.error})]})]})}function an(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 on(){let{t:e}=O(),{id:t=``}=Qe(),n=tt(),r=Ne(t),[i,a]=(0,Q.useState)(`models`),[o,s]=(0,Q.useState)(null),c=Ae(t),l=c.data?.find(e=>e.id===o)??null;if(r.isError)return(0,$.jsx)(ot,{title:e(`nav.providers`),leading:(0,$.jsx)(sn,{onClick:()=>n(`/providers`)}),children:(0,$.jsx)(z,{tone:`danger`,title:e(`common.error`),children:W(r.error)})});let u=r.data;return(0,$.jsx)(ot,{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)(sn,{onClick:()=>n(`/providers`)}),actions:u&&(0,$.jsx)(cn,{p:u}),children:u?(0,$.jsxs)(X,{className:`mx-auto max-w-[860px]`,value:i,onValueChange:e=>a(e),children:[(0,$.jsxs)(nt,{"aria-label":u.name,children:[(0,$.jsx)($e,{value:`models`,children:e(`providers.tab.models`)}),(0,$.jsx)($e,{value:`accounts`,children:e(u.authScheme===`oauth-subscription`||u.authScheme===`plugin`?`providers.tab.accounts`:`providers.tab.apiKey`)}),(0,$.jsx)($e,{value:`settings`,children:e(`providers.tab.settings`)})]}),(0,$.jsx)(ut,{value:`models`,className:`pt-4`,children:(0,$.jsx)(un,{provider:u,models:c.data,loading:c.isLoading,selected:o,onSelect:s})}),(0,$.jsx)(ut,{value:`accounts`,className:`pt-4`,children:u.authScheme===`plugin`?(0,$.jsx)(en,{provider:u}):u.authScheme===`oauth-subscription`?(0,$.jsx)(Qt,{provider:u}):(0,$.jsx)(_n,{provider:u})}),(0,$.jsx)(ut,{value:`settings`,className:`pt-4`,children:(0,$.jsx)(yn,{provider:u})}),(0,$.jsx)(gn,{provider:u,pm:i===`models`?l:null,onClose:()=>s(null)})]}):(0,$.jsx)(V,{lines:4,className:`mx-auto mt-6 max-w-[860px]`})})}function sn({onClick:e}){let{t}=O();return(0,$.jsx)(R,{variant:`glass`,icon:(0,$.jsx)(Ue,{className:`size-4`}),"aria-label":t(`common.back`),onClick:e})}function cn({p:e}){let{t}=O(),n=tt(),{toast:r,confirm:i}=K(),a=Oe(),o=Ee(),[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 S&&e.status===409?e.details?.boundClients??[]:[];r(n.length?t(`providers.deleteBound`,{clients:n.map(e=>it[e]?.name??e).join(`, `)}):W(e),`error`)}})};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{icon:(0,$.jsx)(Je,{className:`size-3.5`}),onClick:()=>u(!0),children:t(`providers.test`)}),(0,$.jsx)(Re,{label:t(`common.more`),icon:(0,$.jsx)(Ke,{className:`size-4`}),items:[{id:`dup`,label:t(`providers.duplicate`),icon:(0,$.jsx)(ge,{className:`size-3.5`}),onSelect:()=>a.mutate(e.id,{onSuccess:e=>n(`/providers/${e.id}`),onError:e=>r(W(e),`error`)})},{id:`tpl`,label:t(`providers.templateUpdate`),icon:(0,$.jsx)(Tt,{className:`size-3.5`}),disabled:!e.templateId,onSelect:()=>c(!0)},{id:`del`,label:t(`common.delete`),icon:(0,$.jsx)(Z,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void d()}]}),(0,$.jsx)(ln,{open:s,onOpenChange:c,provider:e}),(0,$.jsx)(J,{provider:e,open:l,onOpenChange:u})]})}function ln({open:e,onOpenChange:t,provider:n}){let{t:r}=O(),{toast:i}=K(),a=o(n.id,e),s=x(n.id),c=a.data&&a.data.latestVersion<=a.data.currentVersion;return(0,$.jsxs)(G,{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)(R,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(R,{variant:`primary`,disabled:!a.data||c,loading:s.isPending,onClick:()=>s.mutate(void 0,{onSuccess:()=>{t(!1),i(r(`providers.templateApplied`),`success`)},onError:e=>i(W(e),`error`)}),children:r(`common.apply`)})]}),children:[a.isLoading&&(0,$.jsx)(V,{}),a.isError&&(0,$.jsx)(z,{tone:`danger`,title:r(`common.error`),children:W(a.error)}),c&&(0,$.jsx)(z,{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 un({provider:e,models:t,loading:n,selected:r,onSelect:i}){let{t:a}=O(),{toast:o}=K(),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),p=De(e.id),m=(t??[]).filter(e=>!s||e.modelId.toLowerCase().includes(s.toLowerCase())||e.effective.displayName.toLowerCase().includes(s.toLowerCase()));return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(_e,{className:`w-56`,value:s,onChange:c,placeholder:a(`providers.searchModels`)}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(R,{icon:(0,$.jsx)(dt,{className:`size-3.5`}),onClick:()=>f(!0),children:a(`providers.addModels`)}),(0,$.jsx)(R,{variant:`primary`,icon:(0,$.jsx)(We,{className:`size-3.5`}),onClick:()=>u(!0),children:a(`providers.fetchRemote`)})]})]}),n&&(0,$.jsx)(V,{lines:4}),t?.length===0&&(0,$.jsx)(`div`,{className:`card`,children:(0,$.jsx)(fe,{title:a(`providers.noModels`),detail:a(`providers.noModelsDetail`)})}),m.length>0&&(0,$.jsx)(B,{footer:a(`providers.modelsFooter`),children:m.map(e=>(0,$.jsxs)(N,{selected:e.id===r,onClick:()=>i(e.id),label:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:I(`font-mono text-[12.5px]`,!e.enabled&&`text-[var(--text-muted)]`),children:e.modelId}),!e.systemModelId&&(0,$.jsx)(P,{tone:`orange`,children:a(`providers.unlinked`)})]}),detail:[e.effective.displayName===e.modelId?null:e.effective.displayName,e.effective.contextWindow?C(e.effective.contextWindow):null,je(e.effectivePricing)].filter(Boolean).join(` · `),children:[(0,$.jsx)(at,{source:e.pricingSource,priceKey:e.priceKey}),(0,$.jsx)(U,{checked:e.enabled,label:a(`common.enabled`),onChange:t=>p.mutate({pmId:e.id,enabled:t},{onError:e=>o(W(e),`error`)})})]},e.id))}),t&&(0,$.jsx)(dn,{provider:e,models:t}),(0,$.jsx)(pn,{open:d,onOpenChange:f,provider:e}),(0,$.jsx)(mn,{open:l,onOpenChange:u,provider:e})]})}function dn({provider:e,models:t}){let{t:n}=O(),{toast:r}=K(),i=h(e.id),[a,o]=(0,Q.useState)(!1),s=an(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(W(e),`error`)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(B,{title:n(`providers.modelMap.title`),footer:n(`providers.modelMap.footer`),children:[c.map(([e,t])=>(0,$.jsx)(N,{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)(ct,{className:`size-3.5 shrink-0 text-[var(--text-muted)]`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:I(`truncate`,!l.has(t)&&`text-[var(--text-muted)]`),children:t}),!l.has(t)&&(0,$.jsx)(P,{tone:`orange`,children:n(`providers.modelMap.missingTarget`)})]}),children:(0,$.jsx)(R,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(me,{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)(N,{icon:(0,$.jsx)(dt,{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)(fn,{open:a,onOpenChange:o,models:t,saving:i.isPending,onSave:(e,t)=>u({...s,[e]:t},()=>o(!1))})]})}function fn({open:e,onOpenChange:t,models:n,saving:r,onSave:i}){let{t:a}=O(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&(s(``),l(``))},[e]);let u=o.trim();return(0,$.jsx)(G,{open:e,onOpenChange:t,title:a(`providers.modelMap.add`),description:a(`providers.modelMap.addDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{onClick:()=>t(!1),children:a(`common.cancel`)}),(0,$.jsx)(R,{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)(k,{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)(q,{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 pn({open:e,onOpenChange:t,provider:n}){let{t:r}=O(),{toast:i}=K(),a=v(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)(G,{open:e,onOpenChange:t,title:r(`providers.addModels`),description:r(`providers.addModelsDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(R,{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(W(e),`error`)}),children:r(`providers.addSelected`,{count:c.length})})]}),children:(0,$.jsx)(le,{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 mn({open:e,onOpenChange:t,provider:n}){let{t:r}=O(),{toast:i}=K(),a=pe(n.id,e),o=v(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)(G,{open:e,onOpenChange:t,width:560,title:r(`providers.fetchRemote`),description:r(`providers.fetchRemoteDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{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)(R,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(R,{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(W(e),`error`)}),children:r(`providers.addSelected`,{count:s.size})})]}),children:[(0,$.jsx)(_e,{className:`mb-3`,value:l,onChange:u,placeholder:r(`providers.searchModels`)}),a.isLoading&&(0,$.jsx)(V,{lines:4}),a.isError&&(0,$.jsx)(z,{tone:`danger`,title:r(`common.error`),children:W(a.error)}),(0,$.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:d.map(e=>(0,$.jsx)(N,{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)(P,{children:r(`providers.added`)}):(0,$.jsx)(`span`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(ft,{"aria-label":e.id,checked:s.has(e.id),onCheckedChange:()=>f(e.id)})})},e.id))})]})}function hn({origin:e}){let{t}=O();return e===`overridden`?(0,$.jsx)(P,{tone:`orange`,children:t(`origin.overridden`)}):e===`inherited`?(0,$.jsx)(P,{children:t(`origin.inherited`)}):(0,$.jsx)(P,{tone:`red`,children:t(`origin.unset`)})}function gn({provider:e,pm:t,onClose:n}){let{t:r}=O(),{toast:i}=K(),a=De(e.id),o=D(e.id),s=m(),[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)(G,{open:!1,onOpenChange:()=>n(),title:r(`providers.tab.models`)});let h={...c,pricing:f?c.pricing??null:null},g=JSON.stringify(h)!==JSON.stringify({...t.overrides,pricing:t.overrides.pricing??null})||u!==(t.systemModelId??``),_=()=>a.mutate({pmId:t.id,overrides:h,systemModelId:u||null},{onSuccess:()=>{i(r(`common.saved`),`success`),n()},onError:e=>i(W(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)(hn,{origin:c[e]==null?t.origins[e]===`overridden`?`inherited`:t.origins[e]:`overridden`}),c[e]!=null&&(0,$.jsx)(R,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(Ze,{className:`size-3`}),title:r(`origin.reset`),"aria-label":r(`origin.reset`),onClick:()=>l({...c,[e]:null})})]})]}),i]});return(0,$.jsx)(G,{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)(pt,{label:r(`providers.removeModelShort`),icon:(0,$.jsx)(Z,{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)(R,{onClick:n,children:r(`common.cancel`)}),(0,$.jsx)(R,{variant:`primary`,disabled:!g,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)(at,{source:t.pricingSource,priceKey:t.priceKey}),t.multiplier!==1&&t.pricingSource!==`provider_override`&&(0,$.jsxs)(P,{children:[`×`,t.multiplier]})]}),(0,$.jsxs)(E,{title:r(`providers.linkedModel`),children:[(0,$.jsx)(q,{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)(E,{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)(k,{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)(L,{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)(L,{className:`w-full`,label:r(`models.field.maxOutputTokens`),placeholder:String(t.effective.maxOutputTokens??``),value:c.maxOutputTokens,onChange:e=>l({...c,maxOutputTokens:e})}))]})}),(0,$.jsxs)(E,{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)(U,{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)(st,{value:c.pricing??null,onChange:e=>l({...c,pricing:e})})}):t.effectivePricing?(0,$.jsx)(be,{maxHeight:220,children:F(t.effectivePricing)}):(0,$.jsx)(z,{tone:`warning`,title:r(`pricingSource.none`)})]})]})})}function _n({provider:e}){let{t}=O(),{toast:n}=K(),r=A(e.id),i=ce(e.id),[a,o]=(0,Q.useState)(``);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(B,{title:t(`providers.section.auth`),footer:t(`providers.apiKeyStored`),children:(0,$.jsx)(N,{label:t(`providers.apiKey`),detail:e.hasApiKey?e.apiKeyMasked??`••••`:t(`providers.noKey`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(k,{type:`password`,autoComplete:`off`,className:`w-64 font-mono`,"aria-label":t(`providers.apiKey`),placeholder:t(`providers.replaceKey`),value:a,onChange:e=>o(e.target.value)}),(0,$.jsx)(R,{variant:`primary`,disabled:a.trim().length===0,loading:r.isPending,onClick:()=>r.mutate({apiKey:a},{onSuccess:()=>{o(``),n(t(`common.saved`),`success`)},onError:e=>n(W(e),`error`)}),children:t(`common.save`)})]})})}),(0,$.jsxs)(`section`,{className:`card my-4 flex flex-col gap-2 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-[13px] font-medium`,children:t(`providers.usage.title`)}),i.isError&&(0,$.jsx)(z,{tone:`danger`,title:t(`providers.usage.error`),children:W(i.error)}),(0,$.jsx)(Ot,{usage:i.data?.accounts.find(e=>!e.accountId)}),(0,$.jsx)(kt,{timeZone:i.data?.timeZone})]}),(0,$.jsx)(ze,{provider:e})]})}function vn(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 yn({provider:e}){let{t}=O(),{toast:n}=K(),r=A(e.id),i=T(),a=(0,Q.useMemo)(()=>vn(e),[e]),[o,s]=(0,Q.useState)(a),[c,l]=(0,Q.useState)(Object.entries(e.extraHeaders)),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{s(a),l(Object.entries(a.extraHeaders))},[a]);let m=e=>s(t=>({...t,...e})),h={...o,extraHeaders:Object.fromEntries(c.filter(([e])=>e.trim()))},g=JSON.stringify(h)!==JSON.stringify(a),_=()=>{let e={};for(let t of Object.keys(h))t!==`apiKey`&&JSON.stringify(h[t])!==JSON.stringify(a[t])&&(e[t]=h[t]);o.apiKey&&(e.apiKey=o.apiKey),r.mutate(e,{onSuccess:()=>n(t(`common.saved`),`success`),onError:e=>n(W(e),`error`)})},v=(e,t)=>m({endpoints:o.endpoints.map((n,r)=>r===e?{...n,...t}:n)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(B,{title:t(`providers.section.basic`),children:[(0,$.jsx)(N,{label:t(`providers.name`),children:(0,$.jsx)(k,{className:`w-64`,"aria-label":t(`providers.name`),value:o.name,onChange:e=>m({name:e.target.value})})}),(0,$.jsx)(N,{label:t(`common.enabled`),children:(0,$.jsx)(U,{checked:o.enabled,label:t(`common.enabled`),onChange:e=>m({enabled:e})})}),(0,$.jsx)(N,{label:t(`providers.notes`),children:(0,$.jsx)(k,{className:`w-64`,"aria-label":t(`providers.notes`),value:o.notes??``,onChange:e=>m({notes:e.target.value||null})})})]}),(0,$.jsx)(B,{title:t(`providers.section.auth`),children:(0,$.jsx)(N,{label:t(`providers.authScheme`),children:(0,$.jsx)(q,{className:`w-48`,value:o.authScheme,onChange:e=>m({authScheme:e}),options:Ve})})}),(0,$.jsxs)(B,{title:t(`providers.section.endpoints`),footer:t(`providers.endpointsFooter`),children:[o.endpoints.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 py-3`,children:[(0,$.jsx)(q,{className:`w-48`,value:e.protocol,onChange:e=>v(n,{protocol:e}),options:Y}),(0,$.jsx)(k,{className:`min-w-60 flex-1 font-mono`,"aria-label":t(`providers.baseUrl`),value:e.baseUrl,onChange:e=>v(n,{baseUrl:e.target.value})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(U,{checked:!!e.fullUrl,label:t(`providers.fullUrl`),onChange:e=>v(n,{fullUrl:e})}),t(`providers.fullUrl`)]}),(0,$.jsx)(R,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(Z,{className:`size-3.5`}),"aria-label":t(`common.delete`),onClick:()=>m({endpoints:o.endpoints.filter((e,t)=>t!==n)})})]},n)),(0,$.jsx)(`div`,{className:`px-4 py-2`,children:(0,$.jsx)(R,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(dt,{className:`size-3.5`}),onClick:()=>d(!0),children:t(`providers.addEndpoint`)})}),(0,$.jsx)(N,{label:t(`providers.preferred`),detail:(0,$.jsxs)($.Fragment,{children:[t(`providers.preferredHint`),o.preferredUpstreamProtocols.filter(e=>!o.endpoints.some(t=>t.protocol===e)).map(e=>(0,$.jsx)(`span`,{className:`mt-1 block text-[var(--warning)]`,children:t(`providers.preferredMissing`,{protocol:Y.find(t=>t.value===e)?.label??e})},e))]}),children:(0,$.jsx)(lt,{label:t(`providers.preferred`),options:Y.map(e=>{let t=o.preferredUpstreamProtocols.indexOf(e.value);return{value:e.value,label:t>=0?`${t+1}. ${e.label}`:e.label}}),value:o.preferredUpstreamProtocols,onValueChange:e=>{let t=o.preferredUpstreamProtocols.filter(t=>e.includes(t)),n=e.filter(e=>!t.includes(e));m({preferredUpstreamProtocols:[...t,...n]})}})})]}),(0,$.jsxs)(B,{title:t(`providers.section.billing`),footer:t(`providers.billingFooter`),children:[(0,$.jsx)(N,{label:t(`providers.priceKey`),detail:t(`providers.priceKeyHint`),children:(0,$.jsx)(q,{className:`w-56`,value:o.priceKey==null?`inherit`:`price:${o.priceKey}`,onChange:e=>m({priceKey:e===`inherit`?null:e.slice(6)}),options:[{value:`inherit`,label:t(`providers.priceKeyDefault`,{id:e.templateId??`—`})},{value:`price:`,label:t(`providers.priceKeyNone`)},...(i.data??[]).map(e=>({value:`price:${e.priceKey}`,label:e.label,detail:e.priceKey}))]})}),(0,$.jsx)(N,{label:t(`providers.multiplier`),detail:t(`providers.multiplierHint`),children:(0,$.jsx)(L,{className:`w-28`,label:t(`providers.multiplier`),step:.01,min:0,value:o.priceMultiplier,onChange:e=>m({priceMultiplier:e??1})})})]}),(0,$.jsxs)(B,{title:t(`providers.section.advanced`),children:[(0,$.jsx)(N,{label:t(`providers.proxy`),detail:t(`providers.proxyHint`),children:(0,$.jsx)(k,{className:`w-64 font-mono`,"aria-label":t(`providers.proxy`),placeholder:`http://127.0.0.1:7890`,value:o.httpProxy??``,onChange:e=>m({httpProxy:e.target.value||null})})}),(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-[13px]`,children:t(`providers.headers`)}),c.map(([e,n],r)=>(0,$.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,$.jsx)(k,{className:`w-48 font-mono`,"aria-label":t(`providers.headerName`),placeholder:`Header`,value:e,onChange:e=>l(c.map((t,n)=>n===r?[e.target.value,t[1]]:t))}),(0,$.jsx)(k,{className:`flex-1 font-mono`,"aria-label":t(`providers.headerValue`),placeholder:`value`,value:n,onChange:e=>l(c.map((t,n)=>n===r?[t[0],e.target.value]:t))}),(0,$.jsx)(R,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(Z,{className:`size-3.5`}),"aria-label":t(`common.delete`),onClick:()=>l(c.filter((e,t)=>t!==r))})]},r)),(0,$.jsx)(R,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(dt,{className:`size-3.5`}),onClick:()=>p(!0),children:t(`providers.addHeader`)})]}),Object.keys(e.settings).length>0&&(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsx)(le,{label:t(`providers.adapterSettings`),rows:4,className:`w-full font-mono`,defaultValue:F(o.settings),onBlur:e=>{try{m({settings:JSON.parse(e.target.value)})}catch{n(t(`common.invalidJson`),`error`)}}})})]}),(0,$.jsx)(B,{title:t(`providers.section.info`),children:(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(j,{label:`ID`,children:e.id}),e.adapterId&&(0,$.jsx)(j,{label:t(`providers.adapter`),children:e.adapterId}),(0,$.jsx)(j,{label:t(`providers.boundClients`),children:e.boundClients.map(e=>it[e]?.name??e).join(`, `)||`—`})]})}),(0,$.jsx)(bn,{open:u,onOpenChange:d,onAdd:e=>m({endpoints:[...o.endpoints,e]})}),(0,$.jsx)(xn,{open:f,onOpenChange:p,onAdd:e=>l([...c.filter(([t])=>t.toLowerCase()!==e[0].toLowerCase()),e])}),(0,$.jsx)(`div`,{className:`sticky bottom-2 flex justify-end`,children:g&&(0,$.jsxs)(`div`,{className:`glass flex items-center gap-2 rounded-full p-1 pl-4 text-[12px]`,children:[(0,$.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:t(`common.unsaved`)}),(0,$.jsx)(R,{size:`sm`,onClick:()=>{s(a),l(Object.entries(a.extraHeaders))},children:t(`common.revert`)}),(0,$.jsx)(R,{size:`sm`,variant:`primary`,loading:r.isPending,onClick:_,children:t(`common.save`)})]})})]})}function bn({open:e,onOpenChange:t,onAdd:n}){let{t:r}=O(),[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)(G,{open:e,onOpenChange:t,title:r(`providers.addEndpoint`),description:r(`providers.addEndpointDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(R,{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)(M,{label:r(`providers.protocol`),children:(0,$.jsx)(q,{value:i,onChange:a,options:Y})}),(0,$.jsx)(M,{label:r(`providers.baseUrl`),hint:r(c?`providers.fullUrlHint`:`providers.baseUrlHint`),children:(0,$.jsx)(k,{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)(U,{checked:c,onChange:l,label:r(`providers.fullUrl`)}),r(`providers.fullUrl`)]})]})})}function xn({open:e,onOpenChange:t,onAdd:n}){let{t:r}=O(),[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)(G,{open:e,onOpenChange:t,title:r(`providers.addHeader`),description:r(`providers.addHeaderDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(R,{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)(M,{label:r(`providers.headerName`),children:(0,$.jsx)(k,{autoFocus:!0,className:`font-mono`,placeholder:`X-Custom-Header`,value:i,invalid:i!==``&&!c,onChange:e=>a(e.target.value)})}),(0,$.jsx)(M,{label:r(`providers.headerValue`),children:(0,$.jsx)(k,{className:`font-mono`,value:o,onChange:e=>s(e.target.value)})})]})})}export{on as ProviderDetailPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Bi as e,Cn as t,Dr as n,E as r,Fa as i,G as a,Hi as o,Ia as s,Kr as c,Ma as l,Na as u,Q as d,Ti as f,Ui as p,Vi as m,Wi as h,Xn as g,Xr as _,Y as v,_ as y,b,c as x,ct as S,d as C,di as w,dt as T,en as E,f as D,gn as O,h as k,i as A,ja as j,kt as M,l as N,m as P,n as F,or as I,ot as L,p as R,qr as ee,r as z,rr as te,s as B,sr as V,t as H,u as U,v as ne,w as re,wn as W,xt as G,y as ie,yt as ae,zi as K}from"./alert-BadMvy1R.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-D-LaJu2w.js";import{t as we}from"./arrow-left-dS7bcLEo.js";import{t as Te}from"./download-DhWYUpCm.js";import{n as Ee,t as De}from"./radio-cards-Geph_wiF.js";import{I as Oe,Q as ke,R as Ae,S as je,Y as Me,_ as Ne,b as Pe,et as Fe,g as Ie,h as Le,j as Re,k as ze,nt as Be,tt as Ve,x as He,z as Ue}from"./index-BUGU_FDT.js";import{t as We}from"./checkbox-CaaP8Tue.js";var J=s(u(),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=G(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=G(Je),Xe={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Xe.node;var Ze=G(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=l(),{blur:Qe,duration:Z,ease:$e,spring:et,stagger:tt}=r,nt={...et.smooth,visualDuration:.3},rt={...et.smooth,visualDuration:.26},it=300,at={duration:Z.instant},ot=1.04,st={duration:Z.considered*2,ease:[...$e.standard]},ct={duration:Z.considered,ease:[...$e.standard]},lt={delay:Z.instant,duration:Z.standard,ease:[...$e.enter]},ut={delay:Z.instant,duration:Z.fast,ease:[...$e.enter]},dt={enter:{},center:{},exit:{opacity:0,y:`-.3em`,filter:`blur(${Qe.subtle}px)`,transition:{duration:Z.fast,ease:[...$e.standard]}}},ft={enter:{opacity:0,y:`.3em`,filter:`blur(${Qe.soft}px)`},center:e=>({opacity:1,y:0,filter:`blur(0px)`,transition:{duration:Z.standard,ease:[...$e.enter],delay:e*tt.word}})};function pt({text:e,reduced:t}){return(0,X.jsxs)(`span`,{className:Y.status,role:`status`,children:[(0,X.jsx)(`span`,{className:Y.srOnly,children:e}),(0,X.jsx)(`span`,{className:Y.roll,"aria-hidden":`true`,children:(0,X.jsx)(h,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(K.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)(K.span,{className:Y.word,custom:t/2,variants:ft,children:e},t))},e)})})]})}function mt(e,t){let n=parseFloat(t);if(Number.isFinite(n))return t.trim().endsWith(`rem`)?n*parseFloat(getComputedStyle(e.ownerDocument.documentElement).fontSize):n}function ht({title:e,description:t,media:n,action:r,avatar:i,meta:a,status:o,details:s,open:c,defaultOpen:l=!1,onOpenChange:u,children:d,className:f,style:g,..._}){let v=m()??!1,y=(0,J.useId)(),b=(0,J.useRef)(null),x=(0,J.useRef)(null),[S,C]=(0,J.useState)(l),[w,E]=(0,J.useState)(!1),[D,O]=(0,J.useState)({}),[k,A]=(0,J.useState)(null),j=s?c??S:!1,M=!!s&&!v,N=!j&&k!==null,P=!!t,F=(0,J.useCallback)(e=>{c===void 0&&C(e),u?.(e)},[c,u]);(0,J.useEffect)(()=>{let e=b.current,t=x.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=>i||a||o||r?(0,X.jsxs)(`div`,{className:Y.footer,children:[i||a||o?(0,X.jsxs)(K.div,{className:Y.byline,...L(`byline`,e,`position`),children:[i?(0,X.jsx)(`span`,{className:Y.avatar,children:i}):null,(0,X.jsxs)(`span`,{className:Y.bylineText,children:[a?(0,X.jsx)(`span`,{className:Y.meta,children:a}):null,o?(0,X.jsx)(pt,{text:o,reduced:v}):null]})]}):null,r?(0,X.jsx)(K.div,{className:Y.action,...L(`action`,e,`position`),children:r}):null]}):null,ee=(0,X.jsxs)(K.article,{..._,ref:b,className:[Y.card,f].filter(Boolean).join(` `),style:{...g,borderRadius:D.card??g?.borderRadius},"data-hover":w||void 0,whileHover:v?void 0:{y:-2},onHoverStart:()=>E(!0),onHoverEnd:()=>E(!1),...L(`card`,`card`),transition:{default:et.snappy,layout:rt},children:[n?(0,X.jsx)(K.div,{className:Y.media,...L(`media`,`card`),children:(0,X.jsx)(K.div,{className:Y.zoom,initial:!1,animate:{scale:w&&!v?ot:1},transition:w?st:ct,children:n})}):null,(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(K.h3,{className:Y.title,...L(`title`,`card`),children:s?(0,X.jsx)(oe,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:Y.trigger,children:e})}):e}),t?(0,X.jsx)(K.p,{ref:x,className:Y.description,...L(`description`,`card`,`position`),children:t}):null,d,R(`card`)]})]});return s?(0,X.jsx)(se,{open:j,onOpenChange:F,children:(0,X.jsxs)(p,{id:y,children:[ee,(0,X.jsx)(h,{children:(j||N)&&(0,X.jsxs)(ue,{forceMount:!0,children:[(0,X.jsx)(h,{children:j&&(0,X.jsx)(ce,{asChild:!0,forceMount:!0,children:(0,X.jsx)(K.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)(K.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:[n?(0,X.jsx)(K.div,{className:Y.media,...L(`media`,`panel`),children:(0,X.jsx)(K.div,{className:Y.zoom,initial:{scale:w&&!v?ot:1},animate:{scale:1},transition:nt,children:n})}):null,(0,X.jsx)(K.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)(K.button,{type:`button`,className:Y.close,"aria-label":`Close quick look`,whileTap:v?void 0:{scale:.94},transition:et.snappy,children:(0,X.jsx)(T,{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)(K.h2,{className:Y.title,...L(`title`,`panel`),children:e})}),t?(0,X.jsx)(le,{asChild:!0,children:(0,X.jsx)(K.p,{className:Y.description,...L(`description`,`panel`,`position`),children:t})}):null,d,R(`panel`),(0,X.jsx)(K.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:s})]})]})})]},`quick-look`)})]})}):ee}var Q={figure:`_figure_1clu4_1`,caption:`_caption_1clu4_1`,label:`_label_1clu4_1`,accent:`_accent_1clu4_2`,success:`_success_1clu4_2`,warning:`_warning_1clu4_2`,danger:`_danger_1clu4_2`,point:`_point_1clu4_4`,roll:`_roll_1clu4_7`,track:`_track_1clu4_9`,slot:`_slot_1clu4_9`,glyph:`_glyph_1clu4_9`,sizer:`_sizer_1clu4_11`,plot:`_plot_1clu4_14`,chart:`_chart_1clu4_17`,baseline:`_baseline_1clu4_18`,area:`_area_1clu4_20`,line:`_line_1clu4_21`,trail:`_trail_1clu4_21`,cursor:`_cursor_1clu4_24`,end:`_end_1clu4_25`},gt={hidden:e=>({opacity:0,y:`${.3*e}em`,filter:`blur(${r.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:r.duration.standard,ease:[...r.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${r.blur.subtle}px)`,transition:{duration:r.duration.fast,ease:[...r.ease.standard]}})},_t={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:r.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:r.duration.instant}}},vt=e=>Number(e.replace(/,/g,``).replace(/−/g,`-`).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN),yt=new Intl.NumberFormat(`en-US`),bt={duration:r.duration.considered*1.75,ease:[...r.ease.inOut]},xt={duration:r.duration.fast,ease:[...r.ease.standard]};function St(e,t){if(!e)return[];if(t)return[{slot:`all`,key:e,text:e}];if(!/\p{L}/u.test(e))return[...e].map((e,t,n)=>({slot:`n${n.length-t}`,key:e,text:e}));let n=e.split(/(?<=\s)/);return n.map((e,t)=>({slot:`w${t}`,key:n.slice(0,t+1).join(``),text:e}))}function Ct({text:t,direction:n,whole:i=!1,morph:a=!1,tone:s}){let c=!!m(),l=(0,J.useRef)(null),u=o(`auto`),[d,f]=(0,J.useState)({text:t,direction:1});d.text!==t&&f({text:t,direction:n??(vt(t)<vt(d.text)?-1:1)}),(0,J.useEffect)(()=>{let t=l.current;if(!t||typeof ResizeObserver>`u`)return;let n=null,i=new ResizeObserver(([i])=>{if(!i)return;let a=i.borderBoxSize?.[0]?.inlineSize??t.offsetWidth;n!==null&&n!==t.textContent&&!c?e(u,a,r.spring.morph):u.jump(a),n=t.textContent});return i.observe(t),()=>i.disconnect()},[a,c,u]);let p=!i&&!/\p{L}/u.test(t),g=c?_t:gt,_=p?`right`:`left`;return(0,X.jsxs)(K.span,{className:Q.roll,"data-end":p||void 0,"data-whole":i||void 0,style:a?{width:u}:void 0,children:[a&&(0,X.jsx)(`span`,{ref:l,className:Q.sizer,"aria-hidden":`true`,children:t}),(0,X.jsx)(`span`,{className:Q.track,children:(0,X.jsx)(h,{mode:`popLayout`,initial:!1,custom:d.direction,anchorX:_,children:St(t,i).map(e=>(0,X.jsx)(K.span,{className:Q.slot,custom:d.direction,variants:g,initial:`hidden`,animate:`shown`,exit:`gone`,children:(0,X.jsx)(h,{mode:`popLayout`,initial:!1,custom:d.direction,anchorX:_,children:(0,X.jsx)(K.span,{className:s?`${Q.glyph} ${s}`:Q.glyph,custom:d.direction,variants:g,initial:`hidden`,animate:`shown`,exit:`gone`,children:e.text},`${s??``}${e.key}`)})},e.slot))})})]})}var wt=5,Tt=1.25,Et=Array.from({length:161},(e,t)=>t/160);function Dt(e){let t=Math.min(...e),n=Math.max(...e)-t,r=e.map(e=>n?(e-t)/n:.5),i=r.length-1,a=1/i,o=r.slice(1).map((e,t)=>(e-r[t])/a),s=r.map((e,t)=>t===0||t===i?o[0]:(Math.sign(o[t-1])+Math.sign(o[t]))*Math.min(Math.abs(o[t-1]),Math.abs(o[t]),Math.abs(o[t-1]+o[t])/4)||0);i>1&&(s[0]=(3*o[0]-s[1])/2,s[i]=(3*o[i-1]-s[i-1])/2);let c=Math.max(1,Math.min(16,Math.round(128/i))),l=[];for(let e=0;e<i;e++)for(let t=0;t<c;t++){let n=t/c,i=n*n,o=i*n,u=(2*o-3*i+1)*r[e]+(o-2*i+n)*a*s[e]+(3*i-2*o)*r[e+1]+(o-i)*a*s[e+1];l.push([(e+n)*a,Math.min(1,Math.max(0,u))])}return l.push([1,r[i]]),l}function Ot(e,t){let n=0,r=e.length-1;if(t<=e[n][0])return e[n][1];if(t>=e[r][0])return e[r][1];for(;r-n>1;){let i=n+r>>1;e[i][0]<t?n=i:r=i}let[i,a]=e[n],[o,s]=e[r];return o===i?s:a+(s-a)*(t-i)/(o-i)}function kt(e,t,n,r){let i=e=>wt+(1-e)*(n-10),a=e.map(([e,n])=>[e*t,i(n)]),o=a.map(([e,t])=>`${e.toFixed(2)},${t.toFixed(2)}`),s=r*t,c=i(Ot(e,r));return{points:a,line:o.join(` `),trail:`M${o.join(`L`)}`,fill:`M${o.join(`L`)}L${t},${n}L0,${n}Z`,dot:`${s},${c} ${s},${c}`,cx:s}}function At(e,t){let n=e.slice(1).map(([t,n],r)=>Math.hypot(t-e[r][0],n-e[r][1])),r=t*n.reduce((e,t)=>e+t,0);for(let t=0;t<n.length;t++){let i=n[t],a=e[t][0];if(r<=i)return a+(e[t+1][0]-a)*(i?r/i:1);r-=i}return e[e.length-1][0]}function jt({data:t,label:n,value:i,change:a,tone:s=`accent`,width:c=160,height:l=52,labels:u,formatValue:d,area:f=!0,interactive:p=!0}){let h=t.length>1?t:[t[0]??0,t[0]??0],g=h.length-1,_=h.join(`,`),v=(0,J.useMemo)(()=>Dt(_.split(`,`).map(Number)),[_]),y=`${n}: ${i??h[g]}. ${a??``}`.trim(),b=`sparkline${(0,J.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,x=(0,J.useRef)(null),S=(0,J.useRef)(null),C=Ve(x,{once:!0,amount:.5}),w=!!m(),[T,E]=(0,J.useState)({w:c,h:l}),[D,O]=(0,J.useState)(null),[k,A]=(0,J.useState)(!1),j=D===null?null:Math.min(D,g),[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(v,c,l,1)),F=(0,J.useRef)(v),I=(0,J.useRef)(T),L=o(0),R=o(1),ee=o(P.line),z=o(P.trail),te=o(P.fill),B=o(P.dot),V=o(P.cx),H=o(P.cx+Tt+16),U=o(P.cx+Tt),ne=o(0),re=Be(L,e=>+(e>.001)),W=(0,J.useCallback)(()=>{let{w:e,h:t}=I.current,n=L.get(),r=kt(F.current,e,t,R.get());ee.set(r.line),z.set(r.trail),te.set(r.fill),B.set(r.dot),V.set(r.cx),H.set(r.cx+Tt+16),U.set(r.cx+Tt),ne.set(n>=1?e+32:At(r.points,n)+16)},[R,V,U,B,L,te,ee,H,ne,z]);Ge(R,`change`,W),Ge(L,`change`,W),(0,J.useLayoutEffect)(()=>{let e=S.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=e.clientWidth;t&&E(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=T,W()},[T,W]),(0,J.useEffect)(()=>{if(w){L.jump(1);let e=requestAnimationFrame(()=>A(!0));return()=>cancelAnimationFrame(e)}if(!C)return;let t=e(L,1,{...bt,onComplete:()=>A(!0)});return()=>t.stop()},[L,C,w]),(0,J.useEffect)(()=>{let t=F.current;if(t===v)return;if(w){F.current=v,W();return}let n=[...new Set([...Et,...v.map(([e])=>e)])].sort((e,t)=>e-t),i=n.map(e=>Ot(t,e)),a=n.map(e=>Ot(v,e)),o=e(0,1,{...r.spring.smooth,onUpdate:e=>{F.current=n.map((t,n)=>[t,i[n]+(a[n]-i[n])*e]),W()},onComplete:()=>{F.current=v,W()}});return()=>o.stop()},[W,w,v]),(0,J.useEffect)(()=>{let t=j===null?1:j/g;if(w){R.jump(t);return}let n=e(R,t,r.spring.snappy);return()=>n.stop()},[R,j,g,w]);let G=j!==null,ie=(e=>d?d(h[e],e):yt.format(h[e]))(j??g),ae=u?.[j??g],oe=i===void 0?void 0:G?ie:i,se=j===null?a??``:i===void 0?[ie,ae].filter(Boolean).join(` · `):ae??`${j+1} of ${g+1}`,ce=e=>{let t=S.current?.getBoundingClientRect();return t?.width?Math.max(0,Math.min(g,Math.round((e-t.left)/t.width*g))):g},le=p?{role:`slider`,tabIndex:0,"aria-label":`${n}, explore values`,"aria-valuemin":1,"aria-valuemax":g+1,"aria-valuenow":(j??g)+1,"aria-valuetext":`${ae??(j===null?`Latest`:`Point ${j+1} of ${g+1}`)}: ${ie}`,onPointerDown:e=>O(ce(e.clientX)),onPointerMove:e=>{(e.pointerType===`mouse`||e.buttons)&&O(ce(e.clientX))},onPointerUp:e=>{e.pointerType!==`mouse`&&O(null)},onPointerLeave:()=>O(null),onPointerCancel:()=>O(null),onBlur:()=>O(null),onKeyDown:e=>{if(e.key===`Escape`&&G){e.preventDefault(),O(null);return}let t=j??g,n=Math.max(1,Math.round((g+1)/6)),r={ArrowLeft:t-1,ArrowDown:t-1,ArrowRight:t+1,ArrowUp:t+1,PageDown:t-n,PageUp:t+n,Home:0,End:g}[e.key];r!==void 0&&(e.preventDefault(),O(Math.max(0,Math.min(g,r))))}}:{};return(0,X.jsxs)(`figure`,{ref:x,className:Q.figure,"aria-label":y,children:[(0,X.jsxs)(`figcaption`,{className:Q.caption,children:[(0,X.jsx)(`span`,{className:Q.label,children:(0,X.jsx)(Ct,{text:n,whole:!0})}),oe!==void 0&&(0,X.jsx)(`strong`,{children:(0,X.jsx)(Ct,{text:oe,morph:!0})}),(0,X.jsx)(`small`,{className:Q[s],children:(0,X.jsx)(Ct,{text:se,direction:G?M.direction:void 0,tone:G?Q.point:void 0,morph:!0})})]}),(0,X.jsx)(`div`,{ref:S,className:Q.plot,"data-interactive":p||void 0,...le,children:(0,X.jsxs)(`svg`,{className:Q.chart,viewBox:`0 0 ${T.w} ${T.h}`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(`clipPath`,{id:`${b}-lit`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(K.rect,{x:-16,y:-16,width:H,height:T.h+32})}),(0,X.jsx)(`clipPath`,{id:`${b}-dim`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(K.rect,{x:U,y:-16,width:T.w+32,height:T.h+32})}),(0,X.jsx)(`clipPath`,{id:`${b}-fill`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(K.rect,{x:-16,y:-16,width:ne,height:T.h+32})})]}),f&&(0,X.jsx)(K.path,{className:`${Q.area} ${Q[s]}`,d:te,clipPath:`url(#${b}-fill)`}),(0,X.jsx)(`line`,{className:Q.baseline,x1:`0`,y1:T.h-.5,x2:T.w,y2:T.h-.5}),(0,X.jsx)(K.path,{className:Q.trail,d:z,clipPath:`url(#${b}-dim)`,initial:!1,animate:{opacity:G&&k?1:0},transition:w?{duration:0}:xt}),(0,X.jsx)(K.polyline,{className:[Q.line,Q[s]].join(` `),points:ee,clipPath:`url(#${b}-lit)`,style:{pathLength:L,opacity:re}}),(0,X.jsx)(K.line,{className:Q.cursor,x1:V,x2:V,y1:0,y2:T.h,initial:!1,animate:{opacity:+!!G},transition:w?{duration:0}:xt}),(0,X.jsx)(K.polyline,{className:[Q.end,Q[s]].join(` `),points:B,initial:!1,animate:{opacity:+!!k,strokeWidth:k?G?10:7:0},transition:w?{duration:0}:{opacity:xt,strokeWidth:r.spring.snappy},fill:`none`,strokeLinecap:`round`})]})})]})}var $={root:`_root_1cea8_1`,horizontal:`_horizontal_1cea8_3`,list:`_list_1cea8_4`,item:`_item_1cea8_5`,vertical:`_vertical_1cea8_7`,compact:`_compact_1cea8_8`,head:`_head_1cea8_11`,marker:`_marker_1cea8_20`,ring:`_ring_1cea8_21`,disc:`_disc_1cea8_22`,glyph:`_glyph_1cea8_23`,icon:`_icon_1cea8_24`,connector:`_connector_1cea8_31`,fill:`_fill_1cea8_35`,text:`_text_1cea8_40`,label:`_label_1cea8_43`,slot:`_slot_1cea8_47`,slotInner:`_slotInner_1cea8_48`,description:`_description_1cea8_49`,error:`_error_1cea8_49`,caption:`_caption_1cea8_53`,captionLabel:`_captionLabel_1cea8_54`,srOnly:`_srOnly_1cea8_63`},Mt=e=>`blur(${e}px)`,Nt={duration:0},Pt={duration:r.duration.fast,ease:[...r.ease.standard]},Ft={duration:r.duration.standard,ease:[...r.ease.enter]},It={opacity:0,y:`0.3em`,filter:Mt(r.blur.soft)},Lt={opacity:1,y:0,filter:Mt(0)},Rt={opacity:0,y:`-0.3em`,filter:Mt(r.blur.subtle)},zt={opacity:0,scale:.5,filter:Mt(r.blur.subtle)},Bt={opacity:1,scale:1,filter:Mt(0)};function Vt({text:t,className:n,reduced:i}){let a=(0,J.useRef)(null),s=(0,J.useRef)(0),c=o(`auto`);return(0,J.useLayoutEffect)(()=>{s.current=performance.now()+700},[t]),(0,J.useEffect)(()=>{let t=a.current,n=t?.parentElement;if(!t||!n||typeof ResizeObserver>`u`)return;let o=!1,l=new ResizeObserver(()=>{let n=t.offsetHeight;if(!o||i||performance.now()>s.current){o=!0,c.jump(n);return}e(c,n,r.spring.smooth)});return l.observe(t),()=>l.disconnect()},[c,i]),(0,X.jsx)(K.span,{className:$.slot,style:{height:c},children:(0,X.jsx)(`span`,{ref:a,className:$.slotInner,children:(0,X.jsx)(h,{mode:`popLayout`,initial:!1,children:t?(0,X.jsx)(K.span,{className:n,initial:It,animate:Lt,exit:{...Rt,transition:i?Nt:Pt},transition:i?Nt:Ft,children:t},`${n}:${t}`):null})})})}function Ht({kind:e,number:t,delay:n,reduced:i}){let a=i?Nt:{scale:{...r.spring.snappy,delay:n},opacity:{duration:r.duration.fast,delay:n},filter:{duration:r.duration.fast,delay:n}},o={...zt,transition:i?Nt:Pt},s=i?Nt:{duration:r.duration.standard,ease:r.ease.enter,delay:n+.04};return e===`number`?(0,X.jsx)(K.span,{className:$.glyph,initial:zt,animate:Bt,exit:o,transition:a,children:t}):(0,X.jsx)(K.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)(K.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)(K.path,{d:`M12 6.75v6.5`,initial:{pathLength:0},animate:{pathLength:1},transition:s}),(0,X.jsx)(K.circle,{cx:12,cy:17.4,r:1.4,fill:`currentColor`,stroke:`none`,initial:{scale:0},animate:{scale:1},transition:i?Nt:{...r.spring.snappy,delay:n+.16}})]})})}function Ut({number:e,kind:t,current:n,glyphDelay:i,ringDelay:a,reduced:o}){return(0,X.jsxs)(`span`,{className:$.marker,"aria-hidden":`true`,children:[(0,X.jsx)(h,{initial:!1,children:n?(0,X.jsx)(K.span,{className:$.ring,initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:o?Nt:Pt},transition:o?Nt:{scale:{...r.spring.snappy,delay:a},opacity:{duration:r.duration.fast,delay:a}}},`ring`):null}),(0,X.jsx)(`span`,{className:$.disc,children:(0,X.jsx)(h,{initial:!1,children:(0,X.jsx)(Ht,{kind:t,number:e,delay:i,reduced:o},t)})})]})}var Wt={complete:`Completed`,current:``,upcoming:`Not started`,error:`Error`};function Gt({steps:e,current:t,orientation:n=`horizontal`,onStepSelect:i,details:a=`all`,compact:o=!1,label:s=`Progress`,completeLabel:c=`All steps complete`,className:l}){let u=m()??!1,d=e.length,f=Math.min(Math.max(Math.round(t),0),d),[p,h]=(0,J.useState)({to:f,from:f});p.to!==f&&h({to:f,from:p.to});let g=p.from,_=r.stagger.line,v=e=>u?0:f>g?e>=g&&e<f?(e-g)*_:0:e>=f&&e<g?(g-1-e)*_:0,y=u?0:Math.max(0,Math.abs(f-g)-1)*_+.12,b=!!i,x=n===`vertical`,S=f>=d?void 0:e[f];function C(e){let t=!x&&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 w=b?`nav`:`div`,T=[$.root,x?$.vertical:$.horizontal,o?$.compact:``,l].filter(Boolean).join(` `);return(0,X.jsxs)(w,{className:T,"aria-label":s,role:b?void 0:`group`,children:[(0,X.jsx)(`ol`,{className:$.list,style:x?void 0:{gridTemplateColumns:d>1?`repeat(${d-1}, minmax(0, 1fr)) auto`:`auto`},onKeyDown:b?C:void 0,children:e.map((e,t)=>{let o=t===f,s=e.error?`error`:t<f?`complete`:o?`current`:`upcoming`,c=b&&t<f,l=e.error??(a===`all`||o?e.description:void 0),p=e.error?`error`:t<f?`check`:`number`,m=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ut,{number:t+1,kind:p,current:o,glyphDelay:v(t),ringDelay:y,reduced:u}),(0,X.jsxs)(`span`,{className:$.text,children:[(0,X.jsx)(`span`,{className:$.label,children:e.label}),Wt[s]?(0,X.jsxs)(`span`,{className:$.srOnly,children:[`, `,Wt[s]]}):null,(0,X.jsx)(Vt,{text:l,className:e.error?$.error:$.description,reduced:u})]})]});return(0,X.jsxs)(`li`,{className:$.item,"data-status":s,children:[t<d-1?(0,X.jsx)(`span`,{className:$.connector,"aria-hidden":`true`,children:(0,X.jsx)(K.span,{className:$.fill,initial:!1,animate:x?{scaleY:+(t<f)}:{scaleX:+(t<f)},transition:u?Nt:{...r.spring.smooth,delay:v(t)}},n)}):null,b?(0,X.jsx)(`button`,{type:`button`,className:$.head,"data-clickable":c||void 0,"data-reachable":t<=f||void 0,"aria-current":o?`step`:void 0,"aria-disabled":!c||void 0,tabIndex:c?void 0:-1,onClick:c?()=>i?.(t):void 0,children:m}):(0,X.jsx)(`span`,{className:$.head,"aria-current":o?`step`:void 0,children:m})]},e.id)})}),x?null:(0,X.jsxs)(`span`,{className:$.caption,"aria-hidden":`true`,children:[(0,X.jsx)(Vt,{text:S?.label??c,className:$.captionLabel,reduced:u}),(0,X.jsx)(Vt,{text:S?.error??S?.description,className:S?.error?$.error:$.description,reduced:u})]}),(0,X.jsx)(`span`,{className:$.srOnly,"aria-live":`polite`,children:S?`Step ${f+1} of ${d}: ${S.label}`:c})]})}var Kt={"openai-chat":`Chat`,"openai-responses":`Responses`,anthropic:`Anthropic`,gemini:`Gemini`},qt={new:`green`,same:`neutral`,sameHost:`orange`,off:`neutral`,skip:`red`},Jt=e=>`${e.source}\u0000${e.ref}`,Yt=e=>e.status!==`skip`&&e.status!==`same`;function Xt(e){try{return new URL(e).host}catch{return e}}function Zt({open:e,onOpenChange:n}){let{t:r}=S(),{toast:i}=ye(),a=W(e),o=t(),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(new Set),[d,f]=(0,J.useState)(null);(0,J.useEffect)(()=>{a.data&&u(new Set(a.data.flatMap(e=>e.items).filter(e=>e.status===`new`).map(Jt)))},[a.data]),(0,J.useEffect)(()=>{e&&(c(``),f(null))},[e]);let p=s.trim().toLowerCase(),m=e=>!p||e.name.toLowerCase().includes(p)||e.endpoints.some(e=>e.baseUrl.toLowerCase().includes(p)),h=(0,J.useMemo)(()=>(a.data??[]).flatMap(e=>e.items).filter(e=>l.has(Jt(e))&&Yt(e)),[a.data,l]),g=(e,t)=>u(n=>{let r=new Set(n);return t?r.add(Jt(e)):r.delete(Jt(e)),r});return(0,X.jsx)(ge,{open:e,onOpenChange:n,width:680,title:r(`import.title`),description:r(`import.detail`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{icon:(0,X.jsx)(Ae,{className:`size-3.5`}),onClick:()=>void a.refetch(),disabled:a.isFetching||o.isPending,children:r(`import.rescan`)}),(0,X.jsx)(z,{variant:`primary`,disabled:h.length===0||o.isPending,onClick:()=>{f(null),o.mutate(h.map(e=>({source:e.source,ref:e.ref})),{onSuccess:e=>{let t=e.skipped.length;i(t>0?r(`import.doneSkipped`,{count:e.added.length,skipped:t}):r(`import.done`,{count:e.added.length})),n(!1)},onError:e=>{f(q(e)),a.refetch()}})},children:r(`import.selected`,{count:h.length})})]}),children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(k,{value:s,onChange:c,placeholder:r(`import.search`)}),d&&(0,X.jsx)(H,{tone:`danger`,title:r(`common.error`),children:d}),a.isLoading&&(0,X.jsx)(ne,{lines:3}),a.isError&&(0,X.jsx)(H,{tone:`danger`,title:r(`common.error`),children:q(a.error)}),(0,X.jsx)(`div`,{className:`grid max-h-[460px] gap-4 overflow-auto pr-1`,children:a.data?.map(e=>(0,X.jsx)(Qt,{source:e,matches:m,selected:l,onToggle:g,filtering:p.length>0},e.id))}),(0,X.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`import.footnote`)})]})})}function Qt({source:e,matches:t,selected:n,onToggle:r,filtering:i}){let{t:a}=S(),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)(H,{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}=S(),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:L(`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)(F,{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}=S(),{toast:r}=ye(),i=V(),a=n(e.id),o=ee(e.id),s=O(),c=e.quotaConfig,l=(0,J.useMemo)(()=>sn(c),[c]),[u,d]=(0,J.useState)(l),[f,p]=(0,J.useState)(null);(0,J.useEffect)(()=>d(l),[l]);let m=i.data??[],h=m.find(e=>e.id===c.suggestedTemplate),g=u.template===en?h:m.find(e=>e.id===u.template),_=u.template===tn,v=_?nn:g?.params??[],y=e=>d(t=>({...t,...e})),x=JSON.stringify(u)!==JSON.stringify(l),w=e=>{if(e!==tn||u.url)return y({template:e});let t=g??h;y({template:e,method:t?.request.method??rn.method,url:t?.request.url??rn.url,auth:t?.request.auth??rn.auth,headers:on(t?.request.headers??rn.headers),extract:on(t?.extract??an)})},T=()=>{let e={enabled:u.enabled,template:u.template===en?null:u.template,intervalMinutes:u.intervalMinutes,timeoutSec:u.timeoutSec??10,baseUrl:u.baseUrl.trim()||null,params:Object.fromEntries(Object.entries(u.params).filter(([,e])=>e.trim()!==``).map(([e,t])=>[e,t.trim()])),secrets:Object.fromEntries(Object.entries(u.secrets).filter(([,e])=>e.trim()!==``))};if(_){let n=cn(u.headers),i=cn(u.extract);if(!n||!i)return r(t(`providers.quota.invalidJson`,{field:t(n?`providers.quota.extract`:`providers.quota.headers`)}),`error`),null;e.request={method:u.method,url:u.url.trim(),auth:u.auth,headers:n},e.extract=i}return e},E=()=>{let n=T();if(!n)return;let i=n.enabled&&!c.enabled;a.mutate(n,{onSuccess:()=>{r(t(`common.saved`),`success`),i&&s.mutate(e.id,{onError:e=>r(q(e),`error`)})},onError:e=>r(q(e),`error`)})},k=()=>{let e=T();e&&o.mutate(e,{onSuccess:p,onError:e=>r(q(e),`error`)})},j=c.effectiveIntervalMinutes>0?t(`providers.quota.intervalEvery`,{minutes:c.effectiveIntervalMinutes}):t(`providers.quota.intervalOff`),M=[{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)(U,{title:t(`providers.quota.title`),footer:t(`providers.quota.footer`),children:[(0,X.jsx)(P,{label:t(`providers.quota.enable`),detail:t(`providers.quota.enableHint`),children:(0,X.jsx)(ie,{checked:u.enabled,label:t(`providers.quota.enable`),onChange:e=>y({enabled:e})})}),(0,X.jsx)(P,{label:t(`providers.quota.template`),children:(0,X.jsx)(xe,{className:`w-64`,ariaLabel:t(`providers.quota.template`),value:u.template,onChange:w,options:M})}),v.map(e=>{let n=t(`providers.quota.param.${e.name}`),r=c.secrets.includes(e.name);return e.secret?(0,X.jsx)(P,{label:n,detail:r?t(`providers.quota.secretStored`):void 0,children:(0,X.jsx)(C,{type:`password`,autoComplete:`off`,className:`w-64 font-mono`,"aria-label":n,placeholder:r?`••••••••`:``,value:u.secrets[e.name]??``,onChange:t=>y({secrets:{...u.secrets,[e.name]:t.target.value}})})},e.name):(0,X.jsx)(P,{label:n,children:(0,X.jsx)(C,{className:`w-64 font-mono`,"aria-label":n,value:u.params[e.name]??``,onChange:t=>y({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=>y({method:e}),options:[{value:`GET`,label:`GET`},{value:`POST`,label:`POST`}]}),(0,X.jsx)(C,{className:`min-w-60 flex-1 font-mono`,"aria-label":t(`providers.quota.url`),value:u.url,onChange:e=>y({url:e.target.value})}),(0,X.jsx)(xe,{className:`w-52`,ariaLabel:t(`providers.quota.auth`),value:u.auth,onChange:e=>y({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)(b,{label:t(`providers.quota.headers`),mono:!0,rows:3,value:u.headers,onChange:e=>y({headers:e.target.value})}),(0,X.jsx)(b,{label:t(`providers.quota.extract`),mono:!0,rows:8,value:u.extract,onChange:e=>y({extract:e.target.value})}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.extractHint`)})]}),(0,X.jsx)(P,{label:t(`providers.quota.interval`),detail:t(`providers.quota.intervalHint`,{value:j}),children:(0,X.jsx)(R,{className:`w-28`,label:t(`providers.quota.interval`),min:0,step:1,value:u.intervalMinutes,onChange:e=>y({intervalMinutes:e})})}),(0,X.jsx)(P,{label:t(`providers.quota.timeout`),children:(0,X.jsx)(R,{className:`w-28`,label:t(`providers.quota.timeout`),min:1,step:1,value:u.timeoutSec,onChange:e=>y({timeoutSec:e})})}),(0,X.jsx)(P,{label:t(`providers.quota.baseUrl`),detail:t(`providers.quota.baseUrlHint`),children:(0,X.jsx)(C,{className:`w-64 font-mono`,"aria-label":t(`providers.quota.baseUrl`),placeholder:e.endpoints[0]?.baseUrl,value:u.baseUrl,onChange:e=>y({baseUrl:e.target.value})})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 py-3`,children:[(0,X.jsx)(z,{size:`sm`,variant:`primary`,disabled:!x,loading:a.isPending,onClick:E,children:t(`common.save`)}),(0,X.jsx)(z,{size:`sm`,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),loading:o.isPending,onClick:k,title:t(`providers.quota.testDesc`),children:t(`providers.quota.test`)}),(0,X.jsx)(z,{size:`sm`,icon:(0,X.jsx)(Ye,{className:`size-3.5`}),disabled:x,loading:s.isPending,onClick:()=>s.mutate(e.id,{onError:e=>r(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)(H,{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)(D,{label:t(`providers.quota.requestUrl`),mono:!0,children:f.url}),f.httpStatus!=null&&(0,X.jsx)(D,{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)(A,{children:on(f.raw)})]})]})})]})}function un({snapshot:e,checkedAtUtc:t}){let{t:n,locale:r}=S(),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)(H,{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)(H,{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)(F,{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)(F,{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}=S(),{toast:r}=ye(),i=O();if(!he(e))return null;let a=ve(e.quota,t,n),o=be(e.quota);return(0,X.jsxs)(`div`,{className:`mt-3 flex min-w-0 items-center gap-2 text-[12px]`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a&&(0,X.jsx)(`div`,{className:`num truncate text-[var(--text-secondary)]`,title:a,children:a}),o&&(0,X.jsx)(`div`,{className:`truncate text-[var(--warning)]`,title:o.message,children:t(`providers.quota.failed`,{error:pe(o,t)})}),!a&&!o&&(0,X.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:t(`providers.quota.never`)})]}),(0,X.jsx)(z,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(Ye,{className:`size-3.5`}),"aria-label":t(`providers.quota.refresh`),title:t(`providers.quota.refresh`),loading:i.isPending,onClick:()=>i.mutate(e.id,{onError:e=>r(q(e),`error`)})})]})}var fn=3,pn=256,mn=4096,hn={idle:`providers.testDialog.status.idle`,queued:`providers.testDialog.status.queued`,running:`providers.testDialog.status.running`,success:`providers.testDialog.status.success`,failed:`providers.testDialog.status.failed`,cancelled:`providers.testDialog.status.cancelled`};function gn(e){let t=e.endpoints.map(e=>e.protocol);return e.preferredUpstreamProtocols.find(e=>t.includes(e))??t[0]??`openai-chat`}var _n=e=>typeof e==`number`?e:null,vn=e=>typeof e==`string`?e:null;function yn({provider:e,open:t,onOpenChange:n}){let{t:r}=S(),i=j(),a=te(t?e.id:void 0),o=e.endpoints.map(e=>e.protocol),[s,c]=(0,J.useState)(`single`),[l,u]=(0,J.useState)(()=>gn(e)),[d,f]=(0,J.useState)(!0),[p,m]=(0,J.useState)(``),[h,g]=(0,J.useState)(pn),[_,v]=(0,J.useState)(``),[b,x]=(0,J.useState)(null),[C,w]=(0,J.useState)({}),[E,D]=(0,J.useState)([]),[O,k]=(0,J.useState)(new Set),[A,M]=(0,J.useState)([]),[P,F]=(0,J.useState)(``),[I,L]=(0,J.useState)(null),[R,ee]=(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),ne=(0,J.useMemo)(()=>{let e=[...a.data??[]].sort((e,t)=>Number(t.enabled)-Number(e.enabled)||e.sortOrder-t.sortOrder).map(e=>e.modelId);return[...e,...A.filter(t=>!e.includes(t))]},[a.data,A]);(0,J.useEffect)(()=>{if(t){v(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(),x(null),w({}),D([]),k(new Set),M([]),F(``),L(null)},[t,a.data]);let re=(0,J.useCallback)(e=>({modelId:e,protocol:l,stream:d,prompt:p.trim()||null,maxOutputTokens:h??pn}),[l,d,p,h]),W=(0,J.useCallback)((t,n,r)=>On(e.id,t,re(t),n,r),[e.id,re]),G=()=>{let e=_.trim();if(!e)return;B.current?.abort();let t=new AbortController;B.current=t,U.current=!0,L(null),x({modelId:e,status:`running`,text:``,reasoning:``}),W(e,t.signal,e=>{e.status!==`running`&&e.status!==`queued`&&ae(),x(e)})},ie=e=>{if(e.length===0)return;U.current=!0,H.current=!1,L(null),D(e),w(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){w(e=>({...e,[n]:{...e[n],status:`cancelled`}}));continue}let r=new AbortController;V.current.set(n,r),await W(n,r.signal,e=>w(t=>({...t,[n]:e}))),V.current.delete(n),ae()}}))},ae=()=>void i.invalidateQueries({queryKey:[`requests`]}),K=()=>{H.current=!0,w(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.status===`queued`?{...t,status:`cancelled`}:t])))},oe=b?.status===`running`||E.some(e=>C[e]?.status===`running`||C[e]?.status===`queued`&&!H.current),se=E.filter(e=>C[e]&&C[e].status!==`queued`&&C[e].status!==`running`).length,ce=E.filter(e=>C[e]?.status===`success`).length,le=E.filter(e=>C[e]?.status===`failed`).length,ue=(e,t)=>k(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),de=()=>{oe||n(!1)},fe=e=>e.stopPropagation();return(0,X.jsx)(`span`,{onClick:fe,onKeyDown:fe,children:(0,X.jsxs)(ge,{open:t,onOpenChange:e=>e?n(!0):de(),width:1040,title:r(`providers.testDialog.title`,{name:e.name}),description:r(`providers.testDialog.subtitle`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mr-auto text-[11px] text-[var(--text-muted)]`,children:r(`providers.testDialog.realRequest`)}),(0,X.jsx)(z,{disabled:oe,onClick:()=>n(!1),icon:(0,X.jsx)(T,{className:`size-3.5`}),children:r(`common.close`)}),s===`single`?oe?(0,X.jsx)(z,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:()=>B.current?.abort(),children:r(`providers.testDialog.stop`)}):(0,X.jsx)(z,{variant:`primary`,disabled:_.trim()===``,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:G,children:r(b?`providers.testDialog.retest`:`providers.testDialog.start`)}):oe?(0,X.jsx)(z,{variant:`primary`,icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onClick:K,children:r(`providers.testDialog.stopRest`)}):(0,X.jsx)(z,{variant:`primary`,disabled:O.size===0,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:()=>ie([...O]),children:r(`providers.testDialog.testN`,{count:O.size})})]}),children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pb-4`,children:[(0,X.jsx)(He,{name:e.name,icon:e.icon,colorKey:e.templateId,size:32}),(0,X.jsx)(y,{items:[{value:`single`,label:r(`providers.testDialog.modeSingle`)},{value:`batch`,label:r(`providers.testDialog.modeBatch`)}],value:s,onChange:e=>{c(e),L(null)},ariaLabel:r(`providers.testDialog.config`)})]}),s===`single`?(0,X.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,300px)_minmax(0,1fr)] gap-6`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 border-r border-[var(--border)] pr-6`,children:[(0,X.jsx)(`h3`,{className:`text-[13px] font-medium`,children:r(`providers.testDialog.config`)}),(0,X.jsx)(N,{label:r(`providers.testDialog.model`),children:(0,X.jsx)(bn,{value:_,models:ne,onChange:v})}),(0,X.jsx)(xn,{protocols:o,protocol:l,onProtocol:u,stream:d,onStream:f,maxTokens:h,onMaxTokens:g,prompt:p,onPrompt:m}),(0,X.jsx)(`p`,{className:`mt-auto text-[11px] text-[var(--text-muted)]`,children:r(`providers.testDialog.savedCredentials`)})]}),(0,X.jsx)(Sn,{run:b,onRetest:G})]}):I===null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(En,{known:ne,selected:O,onToggle:ue,onSelectAll:e=>k(e?new Set(ne):new Set),onClear:()=>k(new Set),search:P,onSearch:F,onAdd:e=>{M(t=>t.includes(e)?t:[...t,e]),k(t=>new Set(t).add(e)),F(``)},configOpen:R,onConfigOpen:ee,protocols:o,protocol:l,onProtocol:u,stream:d,onStream:f,maxTokens:h,onMaxTokens:g,prompt:p,onPrompt:m}),E.length>0?(0,X.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:oe?r(`providers.testDialog.progress`,{done:se,total:E.length,ok:ce,failed:le}):r(`providers.testDialog.progressDone`,{total:E.length,ok:ce,failed:le})}),(0,X.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-strong)]`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full transition-[width]`,style:{width:`${se/E.length*100}%`,background:`var(--accent)`}})})]}):null,E.length>0?(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Dn,{order:E,runs:C,onView:L})}):null]}):(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(z,{variant:`plain`,icon:(0,X.jsx)(we,{className:`size-4`}),"aria-label":r(`common.back`),onClick:()=>L(null)}),(0,X.jsx)(`span`,{className:`font-mono text-[13px]`,children:I})]}),(0,X.jsx)(Sn,{run:C[I]??null})]})]})})}function bn({value:e,models:t,onChange:n}){let{t:r}=S(),[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)(C,{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)(ae,{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:L(`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}=S(),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)(N,{label:n(`providers.testDialog.protocol`),children:(0,X.jsx)(xe,{value:t.protocol,onChange:t.onProtocol,options:r})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:n(`providers.testDialog.stream`)}),(0,X.jsx)(ie,{checked:t.stream,label:n(`providers.testDialog.stream`),onChange:t.onStream})]}),(0,X.jsx)(N,{label:n(`providers.testDialog.maxTokens`),children:(0,X.jsx)(R,{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)(N,{label:n(`providers.testDialog.prompt`),hint:n(`providers.testDialog.promptHint`),children:(0,X.jsx)(b,{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}=S(),[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)(z,{size:`sm`,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:t,children:n(`providers.testDialog.retest`)}):null,(0,X.jsx)(Ie,{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)(F,{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)(y,{items:[{value:`preview`,label:n(`providers.testDialog.preview`)},{value:`raw`,label:n(`providers.testDialog.raw`)},{value:`headers`,label:n(`providers.testDialog.headers`)}],value:r,onChange:i,ariaLabel:n(`providers.testDialog.reply`)}),(0,X.jsx)(re,{value: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)(H,{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}=S();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)(Me,{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?`—`:a(t)})]})}function Tn({run:e}){let{t}=S(),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)(B,{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}=S(),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)(k,{value:a,onChange:o,placeholder:d(`providers.testDialog.searchModels`)})}),(0,X.jsx)(z,{variant:`plain`,disabled:t.size===0,onClick:i,children:d(`providers.testDialog.clearSelection`)}),(0,X.jsx)(z,{icon:(0,X.jsx)(Ee,{className:`size-3.5`}),onClick:()=>l(!0),children:d(`providers.testDialog.config`)})]}),(0,X.jsx)(`div`,{className:`card max-h-[420px] overflow-auto`,children:m.length===0&&!h?(0,X.jsx)(`p`,{className:`px-4 py-6 text-center text-[12px] text-[var(--text-muted)]`,children:d(`providers.testDialog.noModels`)}):(0,X.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2`,children:[(0,X.jsx)(We,{checked:t.size===e.length&&e.length>0||t.size!==0&&`indeterminate`,onCheckedChange:e=>r(e!==!1),"aria-label":d(`providers.testDialog.clearSelection`)}),(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:d(`providers.testDialog.ownFilter`)})]}),h?(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,X.jsx)(Ue,{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}=S();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?`—`:a(i.ttftMs)}),(0,X.jsx)(`td`,{className:`px-4 py-2 font-mono tabular-nums`,children:i?.totalMs==null?`—`:a(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 M(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 f?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=i({AUTH_OPTIONS:()=>Mn,PROTOCOL_OPTIONS:()=>jn,ProvidersPage:()=>Nn}),jn=[{value:`openai-chat`,label:`OpenAI Chat`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic`,label:`Anthropic Messages`},{value:`gemini`,label:`Gemini`}],Mn=[{value:`bearer`,label:`Authorization: Bearer`},{value:`x-api-key`,label:`x-api-key`},{value:`x-goog-api-key`,label:`x-goog-api-key`},{value:`query-key`,label:`?key=`},{value:`none`,label:`—`},{value:`oauth-subscription`,label:`OAuth 订阅`}];function Nn(){let{t:e}=S(),t=ke(),[n,r]=Fe(),i=I(),[a,o]=(0,J.useState)(n.get(`new`)===`1`),[s,c]=(0,J.useState)(!1);(0,J.useEffect)(()=>{n.get(`new`)===`1`&&(o(!0),n.delete(`new`),r(n,{replace:!0}))},[n,r]),Re(e=>{e===`new-provider`&&o(!0)});let l=_(`7d`,`day`,`provider`),[u,d]=(0,J.useState)(null),f=(0,J.useMemo)(()=>{let e=Fn(Pn),t=new Map;for(let n of l.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}},[l.data]);return(0,X.jsxs)(Le,{title:e(`nav.providers`),subtitle:i.data?e(`providers.count`,{count:i.data.length}):void 0,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{icon:(0,X.jsx)(Te,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`providers.import`)}),(0,X.jsx)(z,{variant:`primary`,icon:(0,X.jsx)(Ue,{className:`size-3.5`}),onClick:()=>o(!0),children:e(`providers.add`)})]}),children:[(0,X.jsxs)(`div`,{className:`mx-auto max-w-[1100px]`,children:[i.isLoading&&(0,X.jsx)(ne,{lines:4}),i.isError&&(0,X.jsx)(H,{tone:`danger`,title:e(`common.error`),children:q(i.error)}),i.data?.length===0&&(0,X.jsx)(`div`,{className:`card`,children:(0,X.jsx)(x,{icon:(0,X.jsx)(Oe,{className:`size-6`}),title:e(`providers.empty`),detail:e(`providers.emptyDetail`),action:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,X.jsx)(z,{variant:`primary`,icon:(0,X.jsx)(Ue,{className:`size-3.5`}),onClick:()=>o(!0),children:e(`providers.add`)}),(0,X.jsx)(z,{icon:(0,X.jsx)(Te,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`providers.import`)})]})})}),i.data&&i.data.length>0&&(0,X.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,260px),1fr))] gap-3`,children:i.data.map(e=>(0,X.jsx)(Rn,{p:e,days:f.days,usage:f.byProvider.get(e.name),onOpen:()=>t(`/providers/${e.id}`),onTest:()=>d(e)},e.id))})]}),(0,X.jsx)(Zt,{open:s,onOpenChange:c}),(0,X.jsx)(Gn,{open:a,onOpenChange:o,onCreated:e=>t(`/providers/${e.id}`)}),u&&(0,X.jsx)(yn,{provider:u,open:!0,onOpenChange:e=>!e&&d(null)})]})}var Pn=7;function Fn(e){let t=new Date;return Array.from({length:e},(n,r)=>{let i=new Date(t.getFullYear(),t.getMonth(),t.getDate()-(e-1-r));return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,`0`)}-${String(i.getDate()).padStart(2,`0`)}`})}function In(e){if(!e)return null;try{return new URL(e).host}catch{return e}}var Ln=e=>e.stopPropagation();function Rn({p:e,days:t,usage:n,onOpen:r,onTest:i}){let{t:a}=S(),o=w(e.id),{toast:s}=ye(),c=[...new Set(e.endpoints.map(e=>e.protocol))],l=!e.hasApiKey&&e.authScheme!==`none`&&e.authScheme!==`oauth-subscription`&&e.authScheme!==`plugin`,u=[e.priceKey?a(`providers.priceKeyShort`,{key:e.priceKey}):null,e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `),f=e.authScheme===`plugin`?a(`providers.card.plugin`):e.authScheme===`oauth-subscription`?a(`providers.card.subscription`):e.authScheme===`none`?a(`providers.card.noAuth`):e.hasApiKey?e.apiKeyMasked??`••••`:a(`providers.noKey`),p=e.enabled?l?{tone:`orange`,label:a(`providers.noKey`)}:{tone:`green`,label:a(`providers.card.active`)}:{tone:`neutral`,label:a(`providers.card.disabled`)},m=n?.requests??t.map(()=>0),h=m.reduce((e,t)=>e+t,0),g=e.templateUpdateAvailable?5:8;return(0,X.jsxs)(ht,{className:`flex flex-col [&>div:first-child>div]:min-h-0! [&>div:last-child]:flex [&>div:last-child]:flex-1 [&>div:last-child]:flex-col [&>div:last-child]:p-3 [&>div:last-child>:last-child]:mt-auto! [&>div:last-child>:last-child]:min-h-[44px] [&>div:last-child>:last-child]:pt-2 [&>div:last-child>h3]:line-clamp-1 [&>div:last-child>h3]:text-[15px] [&>div:last-child>p]:line-clamp-2 [&>div:last-child>p]:min-h-[2lh] [&>div:last-child>p]:text-[12px]`,"data-density":`compact`,role:`button`,tabIndex:0,"aria-label":e.name,onClick:r,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},style:{backgroundColor:`var(--surface)`},title:e.name,description:c.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:L(`transition-[filter,opacity]`,!e.enabled&&`opacity-50 grayscale`),children:(0,X.jsx)(He,{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)(B,{tone:p.tone}),p.label]})]}),(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[11px] text-[var(--text-muted)]`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:e.endpoints[0]?.baseUrl,children:In(e.endpoints[0]?.baseUrl)??`—`}),(0,X.jsx)(`span`,{className:`shrink-0`,children:a(`providers.modelCount`,{count:e.modelCount})})]})]}),meta:(0,X.jsx)(`span`,{className:L(e.hasApiKey&&e.authScheme!==`oauth-subscription`&&`font-mono`),children:f}),status:u||void 0,action:(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,onClick:Ln,children:[(0,X.jsx)(z,{variant:`plain`,size:`sm`,icon:(0,X.jsx)(Ee,{className:`size-3.5`}),"aria-label":a(`providers.test`),title:a(`providers.test`),onClick:i}),(0,X.jsx)(`span`,{className:`ml-1 inline-flex`,children:(0,X.jsx)(ie,{checked:e.enabled,label:a(`common.enabled`),onChange:e=>o.mutate({enabled:e},{onError:e=>s(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)(F,{tone:`accent`,children:a(`providers.templateUpdate`)}),e.boundClients.slice(0,g).map(e=>e in Ne?(0,X.jsx)(`span`,{title:je(e),className:`inline-flex shrink-0`,children:(0,X.jsx)(Pe,{kind:e,size:18})},e):(0,X.jsx)(F,{tone:`green`,children:e},e)),e.boundClients.length>g&&(0,X.jsxs)(`span`,{title:e.boundClients.slice(g).map(e=>Ne[e]?.name??e).join(`, `),className:`shrink-0 text-[11px] text-[var(--text-muted)]`,children:[`+`,e.boundClients.length-g]})]}),(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:h>0?(0,X.jsx)(jt,{label:a(`providers.card.requests7d`),data:m,labels:t.map(e=>e.slice(5)),value:v(h,!0),change:d(n?.costUsd??0),width:320,height:28,formatValue:e=>v(e,!0)}):(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(`div`,{className:`text-[13px] text-[var(--text-secondary)]`,children:a(`providers.card.requests7d`)}),(0,X.jsx)(`div`,{className:`grid aspect-[320/28] place-items-center border-b border-dashed border-[var(--border)] text-[11px] text-[var(--text-muted)]`,children:a(`providers.card.noRequests`)})]})})]})}var zn=`plugin:`,Bn=[`recommended`,`official`,`subscription`,`coding`,`cn`,`aggregator`,`inference`,`local`,`custom`],Vn={"openai-chat":`Chat`,"openai-responses":`Responses`,anthropic:`Anthropic`,gemini:`Gemini`},Hn=e=>jn.find(t=>t.value===e)?.label??e,Un=e=>(0,X.jsx)(`span`,{title:e,children:e}),Wn=e=>{let t=/^(.+?)\s*[((]([^()()]+)[))]$/.exec(e);return t?[t[1],t[2]]:[e,null]};function Gn({open:e,onOpenChange:t,onCreated:n}){let{t:r}=S(),{toast:i}=ye(),a=c(),o=g(),s=E(),l=I(),u=(0,J.useMemo)(()=>new Set((l.data??[]).filter(e=>e.authScheme===`oauth-subscription`&&e.templateId).map(e=>e.templateId)),[l.data]),d=ke(),[f,p]=(0,J.useState)(``),[m,h]=(0,J.useState)(null),[_,v]=(0,J.useState)(null),[y,b]=(0,J.useState)(``),[x,w]=(0,J.useState)(``),[T,D]=(0,J.useState)(``),[O,A]=(0,J.useState)(``),[j,M]=(0,J.useState)(``),[P,F]=(0,J.useState)(`openai-chat`),[L,R]=(0,J.useState)(`bearer`);(0,J.useEffect)(()=>{e||(h(null),v(null),p(``),b(``),w(``),D(``),A(``),M(``))},[e]);let ee=(0,J.useMemo)(()=>{let e=f.trim().toLowerCase(),t=(a.data??[]).filter(t=>!e||t.name.toLowerCase().includes(e)||t.id.includes(e));return Bn.map(e=>({category:e,items:t.filter(t=>t.category===e)})).filter(e=>e.items.length)},[a.data,f]),te=(0,J.useMemo)(()=>{let e=f.trim().toLowerCase();return(l.data??[]).filter(t=>t.authScheme===`plugin`&&!t.settings.plugin?.absent&&(!e||t.name.toLowerCase().includes(e)||t.id.includes(e)))},[l.data,f]),B=e=>{h(e),e===`custom`?(b(``),A(``),D(``)):(b(e.name),A(e.priceKey??e.id),D(``),R(e.auth.scheme))},V=()=>{let e=m===`custom`;s.mutate({templateId:e?null:m.id,variantId:T||null,name:y.trim()||null,apiKey:x.trim()||null,priceKey:O,...e?{endpoints:[{protocol:P,baseUrl:j.trim()}],authScheme:L}:{}},{onSuccess:e=>{t(!1),i(r(`providers.created`,{name:e.name}),`success`),n(e)},onError:e=>i(q(e),`error`)})},U=m&&m!==`custom`?m:null,re=()=>{if(_===`custom`)B(`custom`);else if(_?.startsWith(zn)){let e=te.find(e=>zn+e.id===_);e&&(t(!1),n(e))}else{let e=(a.data??[]).find(e=>e.id===_);e&&!u.has(e.id)&&B(e)}},W=m!==null&&(m===`custom`?/^https?:\/\//.test(j.trim())&&y.trim()!==``:!U.requiresApiKey||x.trim()!==``);return(0,X.jsxs)(ge,{open:e,onOpenChange:t,width:640,title:r(m?`providers.addTitleDetails`:`providers.addTitle`),description:m?U?U.name:r(`providers.custom`):r(`providers.addDetail`),footer:m?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{className:`mr-auto`,variant:`plain`,onClick:()=>h(null),children:r(`common.back`)}),(0,X.jsx)(z,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,X.jsx)(z,{variant:`primary`,disabled:!W,loading:s.isPending,onClick:V,children:r(`providers.create`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,X.jsx)(z,{variant:`primary`,disabled:!_,onClick:re,children:r(`common.continue`)})]}),children:[(0,X.jsx)(Gt,{className:`mb-6`,label:r(`providers.addTitle`),current:+!!m,steps:[{id:`template`,label:r(`providers.step.template`)},{id:`details`,label:r(`providers.step.details`)}]}),m?(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(N,{label:r(`providers.name`),children:(0,X.jsx)(C,{value:y,onChange:e=>b(e.target.value)})}),U?.variants&&U.variants.length>0&&(0,X.jsx)(N,{label:r(`providers.variant`),children:(0,X.jsx)(xe,{value:T,onChange:e=>{D(e);let t=U.variants?.find(t=>t.id===e);A(t?.priceKey??U.priceKey??U.id)},options:[{value:``,label:r(`providers.variantDefault`)},...U.variants.map(e=>({value:e.id,label:e.name}))]})}),m===`custom`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:r(`providers.baseUrl`),hint:r(`providers.baseUrlHint`),children:(0,X.jsx)(C,{value:j,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)(N,{label:r(`providers.protocol`),children:(0,X.jsx)(xe,{value:P,onChange:F,options:jn})}),(0,X.jsx)(N,{label:r(`providers.authScheme`),children:(0,X.jsx)(xe,{value:L,onChange:R,options:Mn})})]})]}),U?.authScheme===`oauth-subscription`?(0,X.jsx)(H,{tone:`info`,title:r(`providers.subscriptionWizardHint`),children:r(`providers.subscriptionWizardDetail`)}):(0,X.jsxs)(`div`,{className:`font-mono`,children:[(0,X.jsx)(ze,{label:r(`providers.apiKey`),description:r(`providers.apiKeyHint`),autoComplete:`off`,placeholder:`sk-…`,value:x,onChange:e=>w(e.target.value)}),U?.apiKeyUrl&&(0,X.jsx)(`a`,{className:`mt-2 inline-block font-sans text-[12px] text-[var(--accent)]`,href:U.apiKeyUrl,target:`_blank`,rel:`noreferrer`,children:r(`providers.getKey`)})]}),(0,X.jsx)(N,{label:r(`providers.priceKey`),hint:r(`providers.priceKeyHint`),children:(0,X.jsx)(xe,{value:O,onChange:A,options:[{value:``,label:r(`providers.priceKeyNone`)},...(o.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey}))]})}),U&&U.models.length>0&&(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`providers.templateModels`,{count:U.models.length})})]}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(k,{value:f,onChange:p,placeholder:r(`providers.searchTemplates`)}),a.isLoading&&(0,X.jsx)(ne,{lines:4}),a.isError&&(0,X.jsx)(H,{tone:`danger`,title:r(`common.error`),children:q(a.error)}),ee.map(e=>(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:r(`providers.category.${e.category}`)}),(0,X.jsx)(De,{name:`provider-template`,"aria-label":r(`providers.category.${e.category}`),density:`compact`,minColumnWidth:168,value:e.items.some(e=>e.id===_)?_:null,onValueChange:v,options:e.items.map(e=>{let t=[...new Set(e.endpoints.map(e=>e.protocol))],[n,i]=Wn(e.name);return{value:e.id,label:(0,X.jsx)(`span`,{title:e.name,children:n}),description:(0,X.jsx)(`span`,{title:t.map(Hn).join(` · `),children:i??t.map(e=>Vn[e]).join(` · `)}),icon:(0,X.jsx)(He,{name:e.name,icon:e.icon,colorKey:e.id,size:28}),disabled:u.has(e.id),disabledReason:Un(r(`providers.subscriptionAdded`))}})})]},e.category)),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:r(`providers.category.plugin`)}),te.length>0?(0,X.jsx)(De,{name:`provider-template-plugin`,"aria-label":r(`providers.category.plugin`),density:`compact`,minColumnWidth:168,value:_?.startsWith(zn)?_:null,onValueChange:v,options:te.map(e=>({value:zn+e.id,label:Un(e.name),description:Un(r(`providers.pluginProvided`)),icon:(0,X.jsx)(He,{name:e.name,icon:e.icon,colorKey:e.id,size:28})}))}):(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-[var(--radius-md)] border border-dashed border-[var(--border)] px-3 py-2.5`,children:[(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-[12px] text-[var(--text-secondary)]`,children:r(`providers.pluginHint`)}),(0,X.jsx)(z,{size:`sm`,onClick:()=>{t(!1),d(`/plugins/market`)},children:r(`plugins.browseMarket`)})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:r(`providers.custom`)}),(0,X.jsx)(De,{name:`provider-template-custom`,"aria-label":r(`providers.custom`),layout:`list`,density:`compact`,value:_===`custom`?`custom`:null,onValueChange:v,options:[{value:`custom`,label:r(`providers.custom`),description:r(`providers.customDetail`),icon:(0,X.jsx)(`span`,{className:`inline-flex size-7 items-center justify-center rounded-[8px] border border-dashed border-[var(--border-strong)] text-[var(--text-secondary)]`,children:(0,X.jsx)(Ue,{className:`size-4`})})}]})]})]})]})}export{ln as a,yn as i,jn as n,Ye as o,An as r,Mn as t};
|