@aidotnet/server-linux-x64 0.13.1 → 0.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/bin/astra-server +2 -2
  2. package/bin/wwwroot/assets/{ClientsPage-21FrObYM.js → ClientsPage-CnHLR9_Q.js} +6 -6
  3. package/bin/wwwroot/assets/KeyPage-zIb63Of5.js +1 -0
  4. package/bin/wwwroot/assets/ModelDetailPage-BcXehC4E.js +1 -0
  5. package/bin/wwwroot/assets/{ModelsPage-WkYlY7Qd.js → ModelsPage-BWIb4L9N.js} +1 -1
  6. package/bin/wwwroot/assets/{PluginsPage-BqRvWqrx.js → PluginsPage-BaoJMLzq.js} +2 -2
  7. package/bin/wwwroot/assets/PrivacyPage-BmqVk2pi.js +1 -0
  8. package/bin/wwwroot/assets/{ProviderDetailPage-BpF5X0Bn.js → ProviderDetailPage-BLCMpahq.js} +3 -3
  9. package/bin/wwwroot/assets/ProvidersPage-CnBPj_Jb.js +2 -0
  10. package/bin/wwwroot/assets/SettingsPage-CcEs-Ivi.js +2 -0
  11. package/bin/wwwroot/assets/SmartRoutingPage-BEf8F6eE.js +2 -0
  12. package/bin/wwwroot/assets/{TokenDetailPage-BUFC4sTY.js → TokenDetailPage-CnwCepbj.js} +1 -1
  13. package/bin/wwwroot/assets/{TokenPoolEditor-CH3L-iQ5.js → TokenPoolEditor-B5YYbTBI.js} +1 -1
  14. package/bin/wwwroot/assets/{TokensPage-DqFNHl8B.js → TokensPage-IYF5mfUz.js} +1 -1
  15. package/bin/wwwroot/assets/TracesPage-RdQ1uzTo.js +8 -0
  16. package/bin/wwwroot/assets/{TracesPage-CIQ1PxNA.css → TracesPage-yYSP_wpw.css} +1 -1
  17. package/bin/wwwroot/assets/{TrayPanelPage-C-saKyBN.js → TrayPanelPage-DF3TZ-Mi.js} +1 -1
  18. package/bin/wwwroot/assets/TrayPanelView-ctysAPlQ.js +1 -0
  19. package/bin/wwwroot/assets/alert-CMMOyMsp.js +15 -0
  20. package/bin/wwwroot/assets/{arrow-down-wREAClBx.js → arrow-down-rd1gJD55.js} +1 -1
  21. package/bin/wwwroot/assets/{arrow-left-BwL0MdoM.js → arrow-left-BYi8J86q.js} +1 -1
  22. package/bin/wwwroot/assets/arrow-up-right-DNaPmTcJ.js +1 -0
  23. package/bin/wwwroot/assets/checkbox--x0D0yfB.js +1 -0
  24. package/bin/wwwroot/assets/{cloud-download-BCNvV9ef.js → cloud-download-BkOTPIzF.js} +1 -1
  25. package/bin/wwwroot/assets/{confirm-morph-DWp2gsoG.js → confirm-morph-BLco2mdX.js} +1 -1
  26. package/bin/wwwroot/assets/{download-BGSlqgxA.js → download-CSRdoXEJ.js} +1 -1
  27. package/bin/wwwroot/assets/{ellipsis-COWYoRP4.js → ellipsis-BI50R2Bc.js} +1 -1
  28. package/bin/wwwroot/assets/{external-link-OKfamryM.js → external-link-Bzx5-ExU.js} +1 -1
  29. package/bin/wwwroot/assets/{folder-open-BWX9PzRK.js → folder-open-BxXgq-F4.js} +1 -1
  30. package/bin/wwwroot/assets/{index-Bw0Y3RgL.css → index-CIeJgTvn.css} +1 -1
  31. package/bin/wwwroot/assets/{index-DorAVedK.js → index-Ck4Qlg9B.js} +8 -8
  32. package/bin/wwwroot/assets/{log-out-BrzYb7oI.js → log-out-DzOM9UKH.js} +1 -1
  33. package/bin/wwwroot/assets/minus-CYKTpU0K.js +1 -0
  34. package/bin/wwwroot/assets/overlays-BFrvqpMl.js +41 -0
  35. package/bin/wwwroot/assets/{pencil-DkOcGe5U.js → pencil-BMnmsFVj.js} +1 -1
  36. package/bin/wwwroot/assets/{power-eNwK6WyW.js → power-CznSHqkx.js} +1 -1
  37. package/bin/wwwroot/assets/radio-cards-DNOgi4px.js +1 -0
  38. package/bin/wwwroot/assets/{rotate-ccw-CkH5KeQH.js → rotate-ccw-Bhx85LK2.js} +1 -1
  39. package/bin/wwwroot/assets/{sortable.esm-yo5QAK_F.js → sortable.esm-BY9yO4Eq.js} +1 -1
  40. package/bin/wwwroot/index.html +4 -4
  41. package/package.json +1 -1
  42. package/bin/wwwroot/assets/KeyPage-8kx7w7Gr.js +0 -1
  43. package/bin/wwwroot/assets/ModelDetailPage-DQvXw1BZ.js +0 -1
  44. package/bin/wwwroot/assets/PrivacyPage-9-TLgfJ3.js +0 -1
  45. package/bin/wwwroot/assets/ProvidersPage-CEE09LSY.js +0 -2
  46. package/bin/wwwroot/assets/SettingsPage-7YVXpvQ_.js +0 -2
  47. package/bin/wwwroot/assets/SmartRoutingPage-Yi6ObQgs.js +0 -2
  48. package/bin/wwwroot/assets/TracesPage-Dyh2sMvS.js +0 -7
  49. package/bin/wwwroot/assets/TrayPanelView-BKhhqBGh.js +0 -1
  50. package/bin/wwwroot/assets/alert-DRuYOIBF.js +0 -15
  51. package/bin/wwwroot/assets/checkbox-BP7SY0L6.js +0 -1
  52. package/bin/wwwroot/assets/minus-CKLCHvmT.js +0 -1
  53. package/bin/wwwroot/assets/overlays-CHP5oojo.js +0 -41
  54. package/bin/wwwroot/assets/radio-cards-BXMylVDk.js +0 -1
@@ -1 +0,0 @@
1
- import{$n as e,Bi as t,E as n,Gi as r,Hi as i,J as a,Ki as o,La as s,Na as c,Pa as l,Qn as u,Ui as d,Vi as f,Y as p,Yt as m,Zn as h,_ as g,b as _,bt as v,c as y,ct as b,d as x,di as S,dt as C,er as w,g as T,h as E,l as D,m as O,n as k,ot as ee,r as A,t as te,u as j,v as M,xt as N,y as P}from"./alert-DRuYOIBF.js";import{a as F,i as ne,o as I,r as L}from"./overlays-CHP5oojo.js";import{$ as re,C as R,D as z,E as ie,F as ae,H as oe,M as se,N as B,Q as ce,R as V,T as le,U as ue,_ as de,c as fe,h as pe,nt as H,r as me,tt as he,w as U,z as ge}from"./index-DorAVedK.js";var _e={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};_e.node;var ve=N(_e),W=s(l(),1),G={toolbar:`_toolbar_1p5c5_1`,leading:`_leading_1p5c5_2`,frame:`_frame_1p5c5_4`,chips:`_chips_1p5c5_5`,slot:`_slot_1p5c5_7`,chip:`_chip_1p5c5_5`,chipLabel:`_chipLabel_1p5c5_10`,value:`_value_1p5c5_11`,separator:`_separator_1p5c5_12`,morphText:`_morphText_1p5c5_13`,morphValue:`_morphValue_1p5c5_14`,measure:`_measure_1p5c5_15`,empty:`_empty_1p5c5_18`,actions:`_actions_1p5c5_19`,clear:`_clear_1p5c5_20`,clearText:`_clearText_1p5c5_21`,srOnly:`_srOnly_1p5c5_23`,menu:`_menu_1p5c5_27`,trigger:`_trigger_1p5c5_29`,face:`_face_1p5c5_31`,surface:`_surface_1p5c5_34`,panel:`_panel_1p5c5_42`,head:`_head_1p5c5_45`,back:`_back_1p5c5_47`,title:`_title_1p5c5_49`,titleText:`_titleText_1p5c5_50`,stage:`_stage_1p5c5_51`,step:`_step_1p5c5_52`,list:`_list_1p5c5_53`,highlight:`_highlight_1p5c5_54`,item:`_item_1p5c5_55`,itemIcon:`_itemIcon_1p5c5_57`,itemLabel:`_itemLabel_1p5c5_58`,itemMeta:`_itemMeta_1p5c5_59`,metaValue:`_metaValue_1p5c5_60`,hint:`_hint_1p5c5_61`,check:`_check_1p5c5_62`,noOptions:`_noOptions_1p5c5_64`},K=c(),q={duration:n.duration.standard,ease:[...n.ease.enter]},ye={duration:n.duration.instant,ease:[...n.ease.standard]},J={duration:0},be={duration:n.duration.instant,ease:[...n.ease.standard]},Y=e=>`blur(${e}px)`,xe=e=>Math.min(1,Math.max(0,e)),Se=e=>typeof e==`string`?{value:e}:e,Ce=e=>e.label??e.value,we=e=>({initial:e?{opacity:0}:{opacity:0,y:`0.3em`,filter:Y(n.blur.soft)},animate:{opacity:1,y:0,filter:Y(0)},exit:e?{opacity:0,transition:J}:{opacity:0,y:`-0.3em`,filter:Y(n.blur.subtle),transition:ye},transition:e?be:q});function Te({text:e}){let a=i()??!1,o=(0,W.useRef)(null),s=d(`auto`);return(0,W.useLayoutEffect)(()=>{let e=o.current;if(!e||typeof ResizeObserver>`u`)return;let t=null,r=new ResizeObserver(([r])=>{let i=Math.ceil(r.borderBoxSize?.[0]?.inlineSize??e.offsetWidth),o=t!==null&&t!==e.textContent;t=e.textContent,o&&!a?f(s,i,n.spring.morph):s.jump(i)});return r.observe(e),()=>r.disconnect()},[a,s]),(0,K.jsxs)(t.span,{className:G.morphText,style:{width:s},children:[(0,K.jsx)(`span`,{ref:o,className:G.measure,"aria-hidden":`true`,children:e}),(0,K.jsx)(r,{mode:`popLayout`,initial:!1,children:(0,K.jsx)(t.span,{className:G.morphValue,...we(a),children:e},e)})]})}function Ee(e,t,r){let i=d(`auto`);return(0,W.useLayoutEffect)(()=>{let a=e.current;if(!a||typeof ResizeObserver>`u`)return;let o=!1,s=new ResizeObserver(()=>{let e=a.offsetHeight;if(!o||r||performance.now()>t.current){o=!0,i.jump(e);return}f(i,e,n.spring.smooth)});return s.observe(a),()=>s.disconnect()},[t,i,e,r]),i}function De(e,t,r){(0,W.useLayoutEffect)(()=>{let i=e.current;if(!i||typeof ResizeObserver>`u`)return;let a=new Map,o=()=>{let e=performance.now();for(let o of Array.from(i.children)){let i=o.offsetLeft,s=o.offsetTop,c=a.get(o);if(!c){a.set(o,{x:i,y:s,dx:0,dy:0});continue}let l=c.x-i,u=c.y-s;if(c.x=i,c.y=s,r||e>t.current||Math.abs(u)<1&&Math.abs(l)<40)continue;c.stop?.();let d=c.dx+l,p=c.dy+u,m=e=>{c.dx=d*(1-e),c.dy=p*(1-e),o.style.translate=e>=1?``:`${c.dx}px ${c.dy}px`};m(0),c.stop=f(0,1,{...n.spring.smooth,onUpdate:m,onComplete:()=>m(1)}).stop}for(let e of a.keys())e.parentElement!==i&&a.delete(e)},s=new ResizeObserver(o),c=()=>{for(let e of Array.from(i.children))s.observe(e)},l=new MutationObserver(()=>{c(),o()});return s.observe(i),c(),l.observe(i,{childList:!0}),()=>{s.disconnect(),l.disconnect();for(let e of a.values())e.stop?.()}},[t,e,r])}var X=e=>e.valueLabel??e.value,Z=e=>X(e)?`${e.label}: ${X(e)}`:e.label,Oe={empty:`No filters applied`,clearAll:`Clear all`,back:`Back to fields`,noOptions:`No options available`,cleared:`All filters cleared`,remove:e=>`Remove ${Z(e)}`,added:e=>`Added ${Z(e)}`,changed:e=>`Changed ${Z(e)}`,removed:e=>`Removed ${Z(e)}`};function ke(e,t,n){let r=e.filter(e=>!t.some(t=>t.id===e.id));if(!t.length&&r.length>1)return n.cleared;let i=t.filter(t=>!e.some(e=>e.id===t.id)),a=t.filter(t=>e.some(e=>e.id===t.id&&e.value!==t.value));return[...i.map(n.added),...a.map(n.changed),...r.map(n.removed)].join(`. `)}function Ae({rows:e,labelledBy:r,onChoose:a,onBack:s,onLeave:c,radio:l,emptyMessage:u}){let d=i()??!1,f=o(),p=(0,W.useRef)(null),m=(0,W.useRef)(!1),h=(0,W.useRef)({text:``,at:0}),[g,_]=(0,W.useState)(()=>Math.max(0,e.findIndex(e=>e.checked))),[v,y]=(0,W.useState)(null),b=()=>Array.from(p.current?.querySelectorAll(`[data-row]`)??[]),x=e=>{let t=p.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 S(t){let n=b(),r=n.indexOf(document.activeElement),i=e=>{t.preventDefault(),m.current=!1,x(n[e])};if(t.key===`ArrowDown`)return i(r<0?0:(r+1)%n.length);if(t.key===`ArrowUp`)return i(r<0?n.length-1:(r-1+n.length)%n.length);if(t.key===`Home`)return i(0);if(t.key===`End`)return i(n.length-1);if(t.key===`ArrowRight`&&r>=0&&e[r]?.drill){t.preventDefault(),a(e[r],!0);return}if(t.key===`ArrowLeft`&&s){t.preventDefault(),s(!0);return}if(t.key.length===1&&/\S/.test(t.key)&&!t.metaKey&&!t.ctrlKey&&!t.altKey){let e=performance.now();h.current={text:e-h.current.at<700?h.current.text+t.key.toLowerCase():t.key.toLowerCase(),at:e};let a=[...n.slice(r+(h.current.text.length>1?0:1)),...n.slice(0,r+(h.current.text.length>1?0:1))].find(e=>(e.dataset.text??``).toLowerCase().startsWith(h.current.text));a&&i(n.indexOf(a))}}function C(e){let t=e.target.closest(`[data-row]`);if(!t)return;_(b().indexOf(t));let n=m.current&&!d,r=!m.current&&t.matches(`:focus-visible`);y(e=>({top:t.offsetTop,height:t.offsetHeight,glide:n&&!!e?.shown,ring:r,shown:!0}))}function w(e){p.current?.contains(e.relatedTarget)||y(e=>e&&{...e,glide:!1,ring:!1,shown:!1})}return(0,K.jsxs)(`div`,{ref:p,className:G.list,role:`menu`,"aria-labelledby":r,"data-current":f?``:void 0,onKeyDown:S,onFocus:C,onBlur:w,onPointerLeave:()=>{m.current&&p.current?.contains(document.activeElement)&&c()},children:[(0,K.jsx)(t.span,{className:G.highlight,"data-ring":v?.ring||void 0,"aria-hidden":`true`,initial:!1,animate:v?{y:v.top,height:v.height,opacity:+!!v.shown}:{opacity:0},transition:{default:v?.glide?n.spring.snappy:J,opacity:{duration:d?0:.08}}}),e.length===0?(0,K.jsx)(`p`,{className:G.noOptions,children:u}):null,e.map((e,t)=>(0,K.jsxs)(`button`,{type:`button`,className:G.item,role:l?`menuitemradio`:`menuitem`,"aria-checked":l?!!e.checked:void 0,tabIndex:t===g?0:-1,"data-row":e.key,"data-text":e.label,onPointerMove:e=>{m.current=!0,document.activeElement!==e.currentTarget&&e.currentTarget.focus({preventScroll:!0})},onClick:t=>a(e,t.detail===0),children:[e.icon?(0,K.jsx)(`span`,{className:G.itemIcon,"aria-hidden":`true`,children:e.icon}):null,(0,K.jsx)(`span`,{className:G.itemLabel,children:e.label}),e.meta?(0,K.jsx)(`span`,{className:G.itemMeta,children:e.meta}):null]},e.key))]})}function je(e){let t={left:0,top:0,right:document.documentElement.clientWidth,bottom:window.innerHeight};for(let n=e.parentElement;n&&n!==document.body;n=n.parentElement){let e=getComputedStyle(n);if(e.overflowX===`visible`&&e.overflowY===`visible`)continue;let r=n.getBoundingClientRect();e.overflowX!==`visible`&&(t.left=Math.max(t.left,r.left),t.right=Math.min(t.right,r.right)),e.overflowY!==`visible`&&(t.top=Math.max(t.top,r.top),t.bottom=Math.min(t.bottom,r.bottom))}return t}function Me({fields:e,onSelect:a,active:o=[],label:s=`Add filter`,align:c=`end`,messages:l}){let u={...Oe,...l},p=i()??!1,m=(0,W.useId)(),h=`${m}panel`,g=`${m}title`,_=(0,W.useRef)(null),y=(0,W.useRef)(null),b=(0,W.useRef)(null),x=(0,W.useRef)(`closed`),S=(0,W.useRef)(0),C=(0,W.useRef)(null),[w,T]=(0,W.useState)(`closed`),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(1),[ee,A]=(0,W.useState)(!1),[te,j]=(0,W.useState)(`100% 0`),M=d(`100%`),N=d(`100%`),P=d(0),F=d(0),ne=H(()=>F.get()-P.get()),I=d(0),L=d(0),re=H(()=>{let e=M.get(),t=I.get(),n=L.get();return typeof e==`number`?n>t?xe((e-t)/(n-t)):1:0}),R=H(()=>xe(re.get()/.35)),z=H(()=>xe((re.get()-.4)/.5)),ie={opacity:H(()=>1-R.get()),scale:H(()=>1-R.get()*.04),filter:H(()=>R.get()?Y(R.get()*n.blur.subtle):`none`)},ae={opacity:z,transformOrigin:te,scale:H(()=>.96+z.get()*.04),y:H(()=>(1-z.get())*(ee?-6:6)),filter:H(()=>z.get()===1?`none`:Y((1-z.get())*n.blur.soft))},se=w===`open`,B=e.find(e=>e.id===E)??null,ce=(0,W.useCallback)(e=>{let t=y.current,r=b.current;if(!t||!r)return;let i=t.getBoundingClientRect(),a=r.offsetWidth+2,o=r.offsetHeight+2,s=je(_.current??t),l=s.left+16-i.left,u=s.right-16-i.left-a,d=i.width-a,m=c===`end`?d>=l?d:0<=u?0:d:0<=u?0:d>=l?d:0;m=Math.round(Math.min(Math.max(m,l),Math.max(l,u)));let h=s.bottom-i.top,g=i.bottom-s.top,v=h<o+16&&g>h;x.current===`closed`&&(M.jump(i.width),N.jump(i.height),P.jump(0)),F.jump(m),I.jump(i.width),L.jump(a),x.current=`open`,S.current+=1,C.current=e,T(`open`),A(v),D(null),k(-1),j(`${Math.round(i.width/2-m)}px ${v?`100%`:`0`}`);let w=p?J:n.spring.morph;f(P,m,w),f(M,a,w),f(N,o,w)},[c,I,N,P,p,F,L,M]),V=(0,W.useCallback)(e=>{let t=y.current;if(x.current!==`open`||!t)return;x.current=`closing`;let r=S.current+=1;T(`closing`),e&&t.focus({preventScroll:!0,focusVisible:e===`keyboard`});let i=p?J:n.spring.snappy;f(P,0,i);let a=t.getBoundingClientRect();f(N,a.height,i),f(M,a.width,{...i,onComplete:()=>{r===S.current&&(x.current=`closed`,M.jump(`100%`),N.jump(`100%`),T(`closed`),D(null))}})},[N,P,p,M]);(0,W.useLayoutEffect)(()=>{let e=b.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{x.current===`open`&&f(N,e.offsetHeight+2,p?J:n.spring.smooth)});return t.observe(e),()=>t.disconnect()},[N,p]),(0,W.useLayoutEffect)(()=>{let e=C.current,t=b.current;if(!e||!t||w!==`open`)return;if(C.current=null,e===`panel`){t.focus({preventScroll:!0});return}let n=Array.from(t.querySelectorAll(`[data-current] [data-row]`));(e===`first`?n[0]:e===`last`?n.at(-1):e===`checked`?n.find(e=>e.getAttribute(`aria-checked`)===`true`)??n[0]:n.find(t=>t.dataset.row===e.key)??n[0])?.focus({preventScroll:!0})},[w,E]),(0,W.useEffect)(()=>{if(w!==`open`)return;let e=e=>{let t=_.current,n=e.target;!t||n&&t.contains(n)||(V(!1),n?.closest?.(`button, a[href], input, select, textarea, [tabindex], [contenteditable]`)||window.setTimeout(()=>{let e=document.activeElement;(!e||e===document.body||t.contains(e))&&y.current?.focus({preventScroll:!0,focusVisible:!1})},0))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[V,w]);function le(e){if(e.defaultPrevented)return;let t=Array.from(b.current?.querySelectorAll(`[data-current] [data-row]`)??[]);(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),(e.key===`ArrowDown`?t[0]:t.at(-1))?.focus({preventScroll:!0})),e.key===`ArrowLeft`&&B&&(e.preventDefault(),de(!0))}function de(e){B&&(C.current=e?{key:B.id}:`panel`,k(-1),D(null))}function fe(e,t){C.current=t?`checked`:`panel`,k(1),D(e.key)}function pe(e,t){B&&(a({id:B.id,label:B.label,value:e.key,valueLabel:e.label},B),V(t?`keyboard`:`pointer`))}let me=e=>o.find(t=>t.id===e.id),he=e.map(e=>({key:e.id,label:e.label,icon:e.icon,drill:!0,meta:(0,K.jsxs)(K.Fragment,{children:[me(e)?(0,K.jsx)(`span`,{className:G.metaValue,children:X(me(e))}):null,(0,K.jsx)(oe,{size:15,strokeWidth:1.8,"aria-hidden":`true`})]})})),U=B?B.options.map(Se).map(e=>{let t=Ce(e),n=me(B)?.value===e.value;return{key:e.value,label:t,icon:e.icon,checked:n,meta:e.hint!=null||n?(0,K.jsxs)(K.Fragment,{children:[e.hint==null?null:(0,K.jsx)(`span`,{className:G.hint,children:e.hint}),(0,K.jsx)(`span`,{className:G.check,"data-on":n||void 0,children:(0,K.jsx)(v,{size:15,strokeWidth:2,"aria-hidden":`true`})})]}):null}}):[],_e={enter:e=>p?{opacity:0}:{opacity:0,x:e*18,filter:Y(n.blur.soft)},center:{opacity:1,x:0,filter:Y(0),transition:p?be:{...q,x:n.spring.smooth}},exit:e=>p?{opacity:0,transition:J}:{opacity:0,x:e*-18,filter:Y(n.blur.subtle),transition:ye}};return(0,K.jsxs)(`div`,{ref:_,className:G.menu,"data-state":w,"data-y":ee?`up`:`down`,onKeyDown:e=>{e.key===`Escape`&&x.current===`open`&&(e.preventDefault(),e.stopPropagation(),V(`keyboard`))},onBlur:e=>{let t=e.relatedTarget;x.current===`open`&&t&&!_.current?.contains(t)&&V(!1)},children:[(0,K.jsx)(`button`,{ref:y,type:`button`,className:G.trigger,"data-filter-trigger":``,"aria-haspopup":`dialog`,"aria-expanded":se,"aria-controls":h,tabIndex:se?-1:void 0,onClick:e=>{x.current!==`open`&&ce(e.detail===0?`first`:`panel`)},onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),ce(e.key===`ArrowDown`?`first`:`last`))},children:(0,K.jsxs)(t.span,{className:G.face,style:ie,children:[(0,K.jsx)(ge,{size:15,strokeWidth:1.8,"aria-hidden":`true`}),s]})}),(0,K.jsx)(t.div,{className:G.surface,style:{left:P,width:M,height:N},children:(0,K.jsx)(t.div,{ref:b,id:h,className:G.panel,role:`dialog`,"aria-labelledby":g,tabIndex:-1,inert:!se,style:{x:ne},onKeyDown:le,children:(0,K.jsxs)(t.div,{style:ae,children:[(0,K.jsxs)(`div`,{className:G.head,children:[(0,K.jsx)(r,{initial:!1,children:B?(0,K.jsx)(t.button,{type:`button`,className:G.back,"aria-label":u.back,onClick:e=>de(e.detail===0),initial:p?{opacity:0,width:28,marginRight:2}:{opacity:0,width:0,marginRight:0,scale:.6},animate:{opacity:1,width:28,marginRight:2,scale:1},exit:p?{opacity:0,transition:J}:{opacity:0,width:0,marginRight:0,scale:.6,transition:{...n.spring.snappy,opacity:ye}},transition:p?be:{...n.spring.snappy,opacity:q},children:(0,K.jsx)(ue,{size:16,strokeWidth:1.8,"aria-hidden":`true`})},`back`):null}),(0,K.jsx)(`span`,{className:G.title,id:g,children:(0,K.jsx)(r,{mode:`popLayout`,initial:!1,children:(0,K.jsx)(t.span,{className:G.titleText,...we(p),children:B?B.label:s},B?.id??`fields`)})})]}),(0,K.jsx)(`div`,{className:G.stage,children:(0,K.jsx)(r,{mode:`popLayout`,initial:!1,custom:O,children:(0,K.jsx)(t.div,{className:G.step,custom:O,variants:_e,initial:`enter`,animate:`center`,exit:`exit`,children:B?(0,K.jsx)(Ae,{rows:U,labelledBy:g,emptyMessage:u.noOptions,radio:!0,onChoose:pe,onBack:de,onLeave:()=>b.current?.focus({preventScroll:!0})}):(0,K.jsx)(Ae,{rows:he,labelledBy:g,emptyMessage:u.noOptions,onChoose:fe,onLeave:()=>b.current?.focus({preventScroll:!0})})},B?.id??`fields`)})})]})})})]})}function Ne({filters:e,onRemove:a,onClearAll:o,leading:s,children:c,label:l=`Active filters`,addFilter:u,messages:d}){let f={...Oe,...d},p=i()??!1,m=(0,W.useRef)(null),h=(0,W.useRef)(null),g=(0,W.useRef)(0),_=(0,W.useRef)(null),[v,y]=(0,W.useState)(e),[b,x]=(0,W.useState)(``);if(v!==e){y(e);let t=ke(v,e,f);t&&x(t)}let S=e.map(e=>`${e.id}:${e.value??``}`).join(`|`);(0,W.useLayoutEffect)(()=>{g.current=performance.now()+900},[S]);let w=Ee(h,g,p);De(h,g,p),(0,W.useLayoutEffect)(()=>{let t=_.current,n=m.current;if(t===null||!n)return;_.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 T={duration:0},E=e=>({initial:!p&&{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1},animate:{width:`auto`,marginRight:0,transitionEnd:{overflow:`visible`,"--slot-moving":0}},exit:p?{opacity:0,transition:T}:{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1,pointerEvents:`none`,transition:{...n.spring.smooth,"--slot-moving":T}},transition:p?T:n.spring.smooth}),D={initial:!p&&{opacity:0,scale:.9,filter:Y(n.blur.soft)},animate:{opacity:1,scale:1,filter:Y(0)},exit:p?{opacity:0,transition:T}:{opacity:0,scale:.9,filter:Y(n.blur.subtle),transition:ye},transition:p?T:{...q,scale:n.spring.snappy}},O=p?{...we(!0),initial:!1}:we(!1),k=p?O:{...O,transition:{...q,delay:n.duration.instant*.75}};return(0,K.jsxs)(`div`,{ref:m,className:G.toolbar,role:`group`,"aria-label":l,children:[s?(0,K.jsx)(`div`,{className:G.leading,children:s}):null,(0,K.jsx)(t.div,{className:G.frame,style:{height:w},children:(0,K.jsxs)(`div`,{ref:h,className:G.chips,children:[(0,K.jsx)(r,{initial:!1,children:e.map((e,n)=>(0,K.jsx)(t.span,{className:G.slot,...E(8),children:(0,K.jsxs)(t.span,{className:G.chip,...D,children:[(0,K.jsxs)(`span`,{className:G.chipLabel,title:Z(e),children:[e.label,X(e)?(0,K.jsxs)(`span`,{className:G.value,children:[(0,K.jsx)(`span`,{className:G.separator,children:` · `}),(0,K.jsx)(Te,{text:X(e)})]}):null]}),(0,K.jsx)(`button`,{type:`button`,"data-chip-remove":e.id,"aria-label":f.remove(e),onClick:t=>{document.activeElement===t.currentTarget&&(_.current=n),a(e.id)},children:(0,K.jsx)(C,{size:14,strokeWidth:1.8,"aria-hidden":`true`})})]})},e.id))}),(0,K.jsx)(r,{initial:!1,children:e.length?null:(0,K.jsx)(t.span,{className:G.empty,...k,children:f.empty},`empty`)})]})}),(0,K.jsxs)(`div`,{className:G.actions,children:[u?(0,K.jsx)(Me,{fields:u.fields,onSelect:u.onAdd,active:e,label:u.label,align:u.align,messages:f}):null,c,(0,K.jsx)(r,{initial:!1,children:e.length>0&&o?(0,K.jsx)(t.span,{className:G.slot,...E(12),children:(0,K.jsx)(`button`,{className:G.clear,type:`button`,onClick:()=>{_.current=-1,o?.()},children:(0,K.jsx)(t.span,{className:G.clearText,...O,children:f.clearAll})})},`clear`):null})]}),(0,K.jsx)(`span`,{className:G.srOnly,role:`status`,children:b})]})}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}=b();return t=>{let n=Pe[t];return n?e(n):t}}function Le({action:e}){let{t}=b();return(0,K.jsx)(k,{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}=b(),n=Ie(),[r,i]=(0,W.useState)(``),[o,s]=(0,W.useState)({client:``,category:``,action:``,blocked:``}),[c,l]=(0,W.useState)(1),[u,d]=(0,W.useState)(null),f=se(r),g=m(),_=h(),v={model:f,...o,page:c,pageSize:Re},x=w(v,c===1),S=x.data,C=S?Math.max(1,Math.ceil(S.total/Re)):1,T=e=>e?de[e]?.name??e:`—`,D=[...new Set((_.data?.rules??[]).map(e=>e.category))],O={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`)}]},k={client:e(`requests.col.client`),category:e(`privacy.stats.col.category`),action:e(`privacy.logs.col.action`),blocked:e(`privacy.logs.col.outcome`)},j=Object.keys(O).map(e=>({id:e,label:k[e],options:O[e].map(e=>e.label)})),N=Object.keys(o).filter(e=>o[e]).map(e=>({id:e,label:k[e],value:O[e].find(t=>t.value===o[e])?.label??o[e]})),P=(e,t)=>{s(n=>({...n,[e]:t})),l(1)},ne=(S?.items??[]).map(e=>({id:e.id,time:Date.parse(e.startedAtUtc),client:T(e.clientKind),model:e.requestedModel??``,outcome:Ve(e),hits:e.hits.reduce((e,t)=>e+t.count,0),e})),I=[{key:`time`,label:e(`requests.col.time`),width:92,render:(e,n)=>(0,K.jsx)(`span`,{className:`num`,children:a(n.e.startedAtUtc,t)})},{key:`model`,label:e(`requests.col.model`),render:(t,n)=>(0,K.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>d(n.id),"aria-label":e(`privacy.logs.viewRequest`,{model:n.model||n.id}),children:[(0,K.jsx)(`span`,{className:`block truncate font-medium hover:text-[var(--accent)]`,children:n.model||`—`}),(0,K.jsx)(`span`,{className:`block truncate text-[11px] text-[var(--text-muted)]`,children:T(n.e.clientKind)})]})},{key:`outcome`,label:e(`privacy.logs.col.outcome`),width:130,render:(e,t)=>(0,K.jsx)(He,{event:t.e})},{key:`hits`,label:e(`privacy.logs.col.hits`),render:(e,t)=>(0,K.jsx)(Ue,{event:t.e})},{key:`client`,label:e(`requests.col.client`),width:110,render:e=>(0,K.jsx)(`span`,{className:`block truncate`,children:String(e||`—`)})}];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,K.jsx)(E,{className:`w-52`,value:r,onChange:e=>{i(e),l(1)},placeholder:e(`requests.searchModel`)}),(0,K.jsx)(A,{variant:`plain`,icon:(0,K.jsx)(V,{className:ee(`size-4`,x.isFetching&&`animate-spin`)}),"aria-label":e(`common.refresh`),onClick:()=>void x.refetch()})]}),(0,K.jsx)(`div`,{className:`mb-3`,children:(0,K.jsx)(Ne,{label:e(`requests.filters`),filters:N,onRemove:e=>P(e,``),onClearAll:()=>{s({client:``,category:``,action:``,blocked:``}),l(1)},addFilter:{fields:j,label:e(`requests.addFilter`),onAdd:e=>{let t=e.id,n=O[t].find(t=>t.label===e.value)?.value;n&&P(t,n)}}})}),x.isLoading&&(0,K.jsx)(M,{lines:4,className:`py-6`}),x.isError&&(0,K.jsx)(te,{tone:`danger`,title:e(`common.error`),children:F(x.error)}),S&&S.items.length===0&&(0,K.jsx)(y,{icon:(0,K.jsx)(ve,{className:`size-6`}),title:e(`privacy.logs.empty`),detail:e(`privacy.logs.empty.detail`)}),S&&S.items.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-2 text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.total`,{count:p(S.total)})}),(0,K.jsx)(z,{caption:e(`privacy.tab.logs`),rows:ne,columns:I,rowKey:`id`,emptyMessage:e(`privacy.logs.empty`)})]}),S&&C>1&&(0,K.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,K.jsx)(fe,{page:c,pageCount:C,onPageChange:l,label:e(`requests.page`,{page:c,pages:C})})}),(0,K.jsx)(me,{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}=b();return e.blocked?(0,K.jsx)(k,{tone:`red`,children:t(`privacy.logs.outcome.blocked`)}):e.redactions>0?(0,K.jsx)(k,{tone:`orange`,children:t(`privacy.logs.outcome.redacted`,{count:e.redactions})}):e.dryRun?(0,K.jsx)(k,{tone:`neutral`,children:t(`privacy.logs.outcome.dryRun`)}):(0,K.jsx)(k,{tone:`neutral`,children:t(`settings.privacy.action.warn`)})}function Ue({event:e}){let t=Ie(),{t:n}=b();if(e.hits.length===0)return(0,K.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`—`});let r=e.hits.slice(0,2),i=e.hits.length-r.length;return(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px]`,children:[r.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(Le,{action:e.action}),(0,K.jsxs)(`span`,{children:[t(e.category),` × `,e.count]}),e.samples&&e.samples.length>0&&(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:e.samples.slice(0,2).join(` `)})]},`${e.ruleId}:${e.action}`)),i>0&&(0,K.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:n(`privacy.logs.moreHits`,{count:i})})]})}var Q={counter:`_counter_dnoch_1`,label:`_label_dnoch_2`,value:`_value_dnoch_4`,column:`_column_dnoch_6`,sizer:`_sizer_dnoch_7`,glyph:`_glyph_dnoch_8`,labelText:`_labelText_dnoch_9`,labelSwap:`_labelSwap_dnoch_10`,symbol:`_symbol_dnoch_11`,srOnly:`_srOnly_dnoch_12`},We=[0,1,2,3,4,5,6,7,8,9],Ge={hidden:{opacity:0,y:`0.3em`,filter:`blur(${n.blur.soft}px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.standard,ease:[...n.ease.enter]}},gone:{opacity:0,y:`-0.3em`,filter:`blur(${n.blur.subtle}px)`,transition:{duration:n.duration.fast,ease:[...n.ease.standard]}}},Ke={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}}},qe={...n.spring.smooth,visualDuration:n.duration.considered};function Je(e,t,n){let r=new Intl.NumberFormat(n,{minimumFractionDigits:t,maximumFractionDigits:t,numberingSystem:`latn`}).formatToParts(e),i=r.reduce((e,t)=>e+(t.type===`integer`?t.value.length:0),0),a=0,o=0;return r.flatMap((e,t)=>e.type===`integer`?[...e.value].map(e=>({key:`i${--i}`,digit:Number(e),order:o++})):e.type===`fraction`?[...e.value].map(e=>({key:`f${a++}`,digit:Number(e),order:o++})):[{key:e.type===`group`?`g${i}`:e.type===`decimal`?`d`:`${e.type}${t}`,text:e.value}])}function Ye({position:e,digit:r}){let i=H(e,e=>((r-e)%10+15)%10-5),a=H(i,e=>`${e}em`),o=H(i,e=>Math.max(0,1-Math.abs(e))),s=H(i,e=>Math.abs(e)>=1?`hidden`:`visible`),c=H(i,e=>Math.abs(e)<.02||Math.abs(e)>=1?`none`:`blur(${(Math.abs(e)*n.blur.subtle).toFixed(2)}px)`);return(0,K.jsx)(t.span,{className:Q.glyph,style:{y:a,opacity:o,filter:c,visibility:s},children:r})}var Xe={initial:{width:0,opacity:0},animate:{width:`auto`,opacity:1},exit:{width:0,opacity:0}};function Ze({digit:e,direction:r,armed:i,delay:a,reduceMotion:o}){let s=d(i?0:e),c=(0,W.useRef)({digit:i?0:e,target:i?0:e,revealed:!i});return(0,W.useEffect)(()=>{let t=c.current;if(i||t.digit===e){i||(t.revealed=!0);return}t.target+=r<0&&t.revealed?-((t.digit-e+10)%10):(e-t.digit+10)%10,t.digit=e,o?s.jump(t.target):f(s,t.target,t.revealed?n.spring.smooth:{...qe,delay:a}),t.revealed=!0},[i,a,e,r,s,o]),(0,K.jsxs)(t.span,{className:Q.column,...Xe,transition:o?{duration:0}:n.spring.morph,children:[(0,K.jsx)(`span`,{className:Q.sizer,children:`0`}),We.map(e=>(0,K.jsx)(Ye,{position:s,digit:e},e))]})}function Qe({value:e,label:a,prefix:o=``,suffix:s=``,decimals:c=0,animateOnView:l=!1,locale:u=`en-US`}){let d=(0,W.useRef)(null),f=he(d,{once:!0,amount:.6}),p=!!i(),[m,h]=(0,W.useState)(e),[g,_]=(0,W.useState)(1);e!==m&&(h(e),_(e>m?1:-1));let v=Je(e,c,u),y=`${o}${v.map(e=>`text`in e?e.text:e.digit).join(``)}${s}`,b=l&&!f;return(0,K.jsxs)(`span`,{ref:d,className:Q.counter,children:[a&&(0,K.jsx)(`span`,{className:Q.label,children:(0,K.jsx)(`span`,{className:Q.labelSwap,children:(0,K.jsx)(r,{mode:`popLayout`,initial:!1,children:(0,K.jsx)(t.span,{className:Q.labelText,variants:p?Ke:Ge,initial:`hidden`,animate:`shown`,exit:`gone`,children:a},a)})})}),(0,K.jsx)(`span`,{className:Q.srOnly,children:y}),(0,K.jsxs)(`span`,{className:Q.value,"aria-hidden":`true`,children:[o&&(0,K.jsx)(`span`,{className:Q.symbol,children:o}),(0,K.jsx)(r,{initial:!1,children:v.map(e=>`digit`in e?(0,K.jsx)(Ze,{digit:e.digit,direction:g,armed:b,delay:Math.min(e.order*n.stagger.item,.25),reduceMotion:p},e.key):(0,K.jsx)(t.span,{className:Q.symbol,...Xe,transition:p?{duration:0}:n.spring.morph,children:e.text},e.key))}),s&&(0,K.jsx)(`span`,{className:Q.symbol,children:s})]})]})}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:a=!1,block:o=!1}){let s=!!i(),c=(0,W.useRef)(null),l=d(`auto`),[u,p]=(0,W.useState)({text:e,direction:1});return u.text!==e&&p({text:e,direction:tt(e)<tt(u.text)?-1:1}),(0,W.useEffect)(()=>{let e=c.current;if(!e||typeof ResizeObserver>`u`)return;let t=null,r=new ResizeObserver(([r])=>{let i=r.borderBoxSize?.[0]?.inlineSize??e.offsetWidth;i&&t!==null&&t!==e.textContent&&!s?f(l,i,n.spring.morph):l.jump(i||`auto`),t=i?e.textContent:null});return r.observe(e),()=>r.disconnect()},[a,s,l]),(0,K.jsxs)(t.span,{className:o?$.swapBlock:$.swap,style:a?{width:l}:void 0,children:[a&&(0,K.jsx)(`span`,{ref:c,className:$.sizer,"aria-hidden":`true`,children:e}),(0,K.jsx)(r,{mode:`popLayout`,initial:!1,custom:u.direction,children:(0,K.jsx)(t.span,{className:$.text,custom:u.direction,variants:s?et:$e,initial:`hidden`,animate:`shown`,exit:`gone`,children:e},e)})]})}function rt({label:e,value:a,suffix:o,context:s,change:c}){let l=!!i();return(0,K.jsxs)(`article`,{className:$.card,children:[(0,K.jsxs)(`div`,{className:$.top,children:[(0,K.jsx)(`span`,{children:(0,K.jsx)(nt,{text:e,block:!0})}),(0,K.jsx)(r,{initial:!1,children:c&&(0,K.jsx)(t.small,{"data-trend":/^[+]/.test(c)?`up`:/^[-−]/.test(c)?`down`:void 0,initial:{opacity:0,scale:l?1:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:l?1:.96,transition:{duration:n.duration.fast,ease:[...n.ease.standard]}},transition:l?{duration:0}:n.spring.snappy,children:(0,K.jsx)(nt,{text:c,morph:!0})},`change`)})]}),(0,K.jsx)(Qe,{value:a,suffix:o,animateOnView:!0}),(0,K.jsx)(`p`,{children:(0,K.jsx)(nt,{text:s,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}=b(),{toast:t}=I(),n=h(),r=S(),i=n.data?.settings,a=e=>{i&&r.mutate({...i,...e},{onError:e=>t(F(e),`error`)})},o=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])}));return(0,K.jsxs)(j,{title:e(`settings.privacy`),footer:e(`settings.privacy.footer`),children:[n.isLoading&&(0,K.jsx)(M,{className:`my-4`}),n.isError&&(0,K.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--danger)]`,children:F(n.error)}),i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(O,{label:e(`settings.privacy.enabled`),detail:e(`settings.privacy.enabledHint`),children:(0,K.jsx)(P,{checked:i.enabled,label:e(`settings.privacy.enabled`),onChange:e=>a({enabled:e})})}),(0,K.jsx)(O,{label:e(`settings.privacy.dryRun`),detail:e(`settings.privacy.dryRunHint`),children:(0,K.jsx)(P,{checked:i.dryRun,disabled:!i.enabled,label:e(`settings.privacy.dryRun`),onChange:e=>a({dryRun:e})})}),(0,K.jsx)(O,{label:e(`settings.privacy.restore`),detail:e(`settings.privacy.restoreHint`),children:(0,K.jsx)(P,{checked:i.restoreResponses,disabled:!i.enabled,label:e(`settings.privacy.restore`),onChange:e=>a({restoreResponses:e})})}),(0,K.jsx)(O,{label:e(`settings.privacy.recordSamples`),detail:e(`settings.privacy.recordSamplesHint`),children:(0,K.jsx)(P,{checked:i.recordSamples,disabled:!i.enabled,label:e(`settings.privacy.recordSamples`),onChange:e=>a({recordSamples:e})})}),(0,K.jsx)(O,{label:e(`settings.privacy.recordFullSamples`),detail:e(`settings.privacy.recordFullSamplesHint`),children:(0,K.jsx)(P,{checked:i.recordFullSamples,disabled:!i.enabled||!i.recordSamples,label:e(`settings.privacy.recordFullSamples`),onChange:e=>a({recordFullSamples:e})})}),(0,K.jsx)(O,{label:e(`settings.privacy.defaultAction`),children:(0,K.jsx)(L,{className:`w-36`,ariaLabel:e(`settings.privacy.defaultAction`),value:i.defaultAction,disabled:!i.enabled,onChange:e=>a({defaultAction:e}),options:o})})]})]})}function ct(){let{t:e}=b(),{toast:t}=I(),n=h(),r=S(),i=n.data?.settings,a=Ie(),o=e=>{i&&r.mutate({...i,...e},{onError:e=>t(F(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,K.jsx)(`div`,{className:`mx-auto max-w-[720px]`,children:(0,K.jsx)(M,{className:`my-4`})}):i?(0,K.jsxs)(`div`,{className:`mx-auto flex max-w-[720px] flex-col gap-4`,children:[(0,K.jsx)(j,{title:e(`settings.privacy.categories`),children:l.map(t=>{let n=i.categoryActions[t]??i.defaultAction,r=!i.enabled||n===`off`;return(0,K.jsxs)(O,{label:a(t),detail:u(t),children:[n===`off`?(0,K.jsx)(k,{children:e(`settings.privacy.action.off`)}):(0,K.jsx)(L,{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,K.jsx)(A,{size:`sm`,variant:`plain`,disabled:!i.enabled,onClick:()=>s(t,i.categoryActions[t]??i.defaultAction),children:e(`settings.privacy.enableCategory`)})]},t)})}),(0,K.jsx)(lt,{s:i,onPatch:o})]}):null}function lt({s:e,onPatch:t}){let{t:n}=b(),{confirm:r}=I(),[i,a]=(0,W.useState)(!1),o=(n,r)=>t({customRules:e.customRules.map(e=>e.id===n.id?{...e,enabled:r}:e)}),s=async i=>{await r({title:n(`settings.privacy.deleteRuleConfirm`,{name:i.name}),destructive:!0,confirmLabel:n(`common.delete`)})&&t({customRules:e.customRules.filter(e=>e.id!==i.id)})};return(0,K.jsxs)(j,{title:n(`settings.privacy.customRules`),children:[e.customRules.length===0&&(0,K.jsx)(`div`,{className:`px-4 py-4 text-[12px] text-[var(--text-secondary)]`,children:n(`settings.privacy.noCustomRules`)}),e.customRules.map(t=>(0,K.jsxs)(O,{label:t.name,detail:t.pattern,children:[(0,K.jsx)(P,{checked:t.enabled,disabled:!e.enabled,label:t.name,onChange:e=>o(t,e)}),(0,K.jsx)(A,{size:`sm`,variant:`plain`,icon:(0,K.jsx)(B,{className:`size-3.5`}),"aria-label":`${n(`common.delete`)} ${t.name}`,onClick:()=>void s(t)})]},t.id)),(0,K.jsx)(`div`,{className:`px-4 py-2`,children:(0,K.jsx)(A,{size:`sm`,icon:(0,K.jsx)(ge,{className:`size-3.5`}),disabled:!e.enabled,onClick:()=>a(!0),children:n(`settings.privacy.addRule`)})}),(0,K.jsx)(ut,{open:i,onOpenChange:a,onAdd:n=>t({customRules:[...e.customRules,n]})})]})}function ut({open:e,onOpenChange:t,onAdd:n}){let{t:r}=b(),{toast:i}=I(),[a,o]=(0,W.useState)(``),[s,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(``);return(0,K.jsx)(ne,{open:e,onOpenChange:t,title:r(`settings.privacy.addRule`),width:480,footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(A,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,K.jsx)(A,{variant:`primary`,disabled:!a.trim()||!s.trim(),onClick:()=>{if(a.trim()&&s.trim()){try{new RegExp(s)}catch(e){i(`${r(`settings.privacy.invalidPattern`)}: ${F(e)}`,`error`);return}n({id:`custom-${Date.now().toString(36)}`,name:a.trim(),pattern:s.trim(),enabled:!0}),o(``),c(``),u(``),t(!1)}},children:r(`common.create`)})]}),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(D,{label:r(`settings.privacy.ruleTemplates`),hint:r(`settings.privacy.ruleTemplatesHint`),children:(0,K.jsx)(L,{ariaLabel:r(`settings.privacy.ruleTemplates`),value:l,onChange:e=>{u(e);let t=it.find(t=>t.id===e);t&&(o(r(t.nameKey)),c(t.pattern))},options:[{value:``,label:r(`settings.privacy.ruleTemplateNone`)},...it.map(e=>({value:e.id,label:r(e.nameKey)}))]})}),(0,K.jsx)(x,{label:r(`settings.privacy.ruleName`),value:a,onChange:e=>o(e.target.value),autoFocus:!0}),(0,K.jsx)(D,{label:r(`settings.privacy.rulePattern`),hint:r(`settings.privacy.rulePatternHint`),children:(0,K.jsx)(_,{mono:!0,rows:3,value:s,onChange:e=>c(e.target.value)})})]})})}function dt(){let{t:e}=b(),{toast:t}=I(),n=Ie(),r=h(),i=u(),[a,o]=(0,W.useState)(``),s=i.data,c=r.data?.settings.enabled??!1;return(0,K.jsx)(j,{title:e(`settings.privacy.tester`),footer:e(`settings.privacy.testerHint`),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,K.jsx)(_,{"aria-label":e(`settings.privacy.tester`),placeholder:e(`settings.privacy.testerPlaceholder`),rows:4,mono:!0,value:a,onChange:e=>o(e.target.value)}),(0,K.jsx)(`div`,{children:(0,K.jsx)(A,{icon:(0,K.jsx)(ae,{className:`size-3.5`}),disabled:!c||!a.trim(),loading:i.isPending,onClick:()=>i.mutate({text:a},{onError:e=>t(F(e),`error`)}),children:e(`settings.privacy.runTest`)})}),s&&(0,K.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] px-3 py-2 text-[12px]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s.blocked&&(0,K.jsx)(k,{tone:`red`,children:e(`settings.privacy.wouldBlock`)}),s.wouldRedact>0&&(0,K.jsx)(k,{tone:`orange`,children:e(`settings.privacy.wouldRedact`,{count:s.wouldRedact})}),!s.blocked&&s.wouldRedact===0&&(0,K.jsx)(k,{tone:`green`,children:e(`settings.privacy.noHits`)})]}),s.hits.length>0&&(0,K.jsx)(`ul`,{className:`mt-2 space-y-1`,children:s.hits.map(t=>(0,K.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(k,{tone:t.action===`block`?`red`:t.action===`redact`?`orange`:`neutral`,children:e(ot[t.action])}),(0,K.jsxs)(`span`,{children:[n(t.category),` · `,t.ruleId,` × `,t.count]}),t.samples&&t.samples.length>0&&(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:t.samples.join(` `)})]},`${t.ruleId}:${t.action}`))})]})]})})}var ft=[`today`,`7d`,`30d`,`all`];function pt(){let{t}=b(),n=Ie(),[r,i]=(0,W.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,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`section`,{children:[(0,K.jsx)(T,{action:(0,K.jsx)(g,{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,K.jsx)(M,{lines:3,className:`py-4`}),a.isError&&(0,K.jsx)(te,{tone:`danger`,title:t(`common.error`),children:F(a.error)}),o&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,K.jsx)(rt,{label:t(`privacy.stats.events`),value:o.events,context:t(`range.${r}`)}),(0,K.jsx)(rt,{label:t(`privacy.stats.blocked`),value:o.blocked,context:t(`range.${r}`)}),(0,K.jsx)(rt,{label:t(`privacy.stats.redactions`),value:o.redactions,context:t(`range.${r}`)}),(0,K.jsx)(rt,{label:t(`privacy.stats.dryRun`),value:o.dryRun,context:t(`range.${r}`)})]})]}),(0,K.jsxs)(`section`,{children:[(0,K.jsx)(T,{children:t(`privacy.stats.byCategory`)}),o&&o.categories.length===0&&(0,K.jsx)(`div`,{className:`card`,children:(0,K.jsx)(mt,{})}),o&&o.categories.length>0&&(0,K.jsx)(z,{caption:t(`privacy.stats.byCategory`),rows:c,columns:s,rowKey:`category`,defaultSort:{key:`hits`,direction:`desc`}})]}),(0,K.jsx)(`div`,{className:`mx-auto w-full max-w-[720px]`,children:(0,K.jsx)(st,{})})]})}function mt(){let{t:e}=b();return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-center`,children:[(0,K.jsx)(ae,{className:`size-6 text-[var(--text-muted)]`}),(0,K.jsx)(`div`,{className:`text-[13px]`,children:e(`privacy.logs.empty`)}),(0,K.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.empty.detail`)})]})}var ht=[`overview`,`logs`,`rules`,`tester`];function gt(){let{t:e}=b(),{tab:t}=re(),n=ce(),r=ht.includes(t)?t:`overview`;return(0,K.jsx)(pe,{title:e(`nav.privacy`),subtitle:e(`settings.privacy.footer`),children:(0,K.jsxs)(R,{value:r,onValueChange:e=>n(`/privacy/${e}`,{replace:!0}),children:[(0,K.jsx)(le,{"aria-label":e(`nav.privacy`),children:ht.map(t=>(0,K.jsx)(ie,{value:t,children:e(`privacy.tab.${t}`)},t))}),(0,K.jsx)(U,{value:`overview`,className:`pt-5`,children:(0,K.jsx)(pt,{})}),(0,K.jsx)(U,{value:`logs`,className:`pt-4`,children:(0,K.jsx)(Be,{})}),(0,K.jsx)(U,{value:`rules`,className:`pt-5`,children:(0,K.jsx)(ct,{})}),(0,K.jsx)(U,{value:`tester`,className:`pt-5 [&>div]:mx-auto [&>div]:max-w-[680px]`,children:(0,K.jsx)(dt,{})})]})})}export{gt as PrivacyPage};
@@ -1,2 +0,0 @@
1
- import{Bi as e,Cn as t,Dr as n,E as r,Ei as i,G as a,Gi as o,Hi as s,Ia as c,Jr as l,La as u,Ma as d,Na as f,Pa as p,Q as m,Ui as h,Ur as g,Vi as _,Wi as v,Xn as y,Y as b,Zr as x,_ as S,b as C,c as w,ct as T,d as E,dt as ee,en as D,f as O,fi as k,gn as A,h as j,i as M,kt as N,l as P,m as F,n as I,o as L,or as te,ot as R,p as ne,qr as re,r as z,rr as ie,s as B,sr as ae,t as V,u as oe,v as H,w as U,wn as se,xt as ce,y as W,yt as le}from"./alert-DRuYOIBF.js";import{A as ue,C as de,D as fe,E as pe,O as G,T as me,X as he,a as K,ct as ge,dt as _e,ft as ve,i as ye,k as be,mt as xe,o as Se,pt as Ce,r as q,ut as we,w as Te}from"./overlays-CHP5oojo.js";import{t as Ee}from"./arrow-left-BwL0MdoM.js";import{t as De}from"./download-BGSlqgxA.js";import{n as Oe,t as ke}from"./radio-cards-BXMylVDk.js";import{I as Ae,N as je,Q as Me,R as Ne,S as Pe,Y as Fe,_ as Ie,b as Le,et as Re,g as ze,h as Be,j as Ve,k as He,nt as Ue,s as We,tt as Ge,x as Ke,z as qe}from"./index-DorAVedK.js";import{t as Je}from"./checkbox-BP7SY0L6.js";var J=u(p(),1);function Ye(e,t,n){(0,J.useInsertionEffect)(()=>e.on(t,n),[e,t,n])}var Xe={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`]};Xe.node;var Ze=ce(Xe),Qe={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`}]]};Qe.node;var $e=ce(Qe),et={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};et.node;var tt=ce(et),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=f(),{blur:nt,duration:Z,ease:rt,spring:it,stagger:at}=r,ot={...it.smooth,visualDuration:.3},st={...it.smooth,visualDuration:.26},ct=300,lt={duration:Z.instant},ut=1.04,dt={duration:Z.considered*2,ease:[...rt.standard]},ft={duration:Z.considered,ease:[...rt.standard]},pt={delay:Z.instant,duration:Z.standard,ease:[...rt.enter]},mt={delay:Z.instant,duration:Z.fast,ease:[...rt.enter]},ht={enter:{},center:{},exit:{opacity:0,y:`-.3em`,filter:`blur(${nt.subtle}px)`,transition:{duration:Z.fast,ease:[...rt.standard]}}},gt={enter:{opacity:0,y:`.3em`,filter:`blur(${nt.soft}px)`},center:e=>({opacity:1,y:0,filter:`blur(0px)`,transition:{duration:Z.standard,ease:[...rt.enter],delay:e*at.word}})};function _t({text:t,reduced:n}){return(0,X.jsxs)(`span`,{className:Y.status,role:`status`,children:[(0,X.jsx)(`span`,{className:Y.srOnly,children:t}),(0,X.jsx)(`span`,{className:Y.roll,"aria-hidden":`true`,children:(0,X.jsx)(o,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(e.span,{className:Y.line,variants:ht,initial:!n&&`enter`,animate:`center`,exit:n?void 0:`exit`,children:t.split(/(\s+)/).map((t,n)=>(0,X.jsx)(e.span,{className:Y.word,custom:n/2,variants:gt,children:t},n))},t)})})]})}function vt(e,t){let n=parseFloat(t);if(Number.isFinite(n))return t.trim().endsWith(`rem`)?n*parseFloat(getComputedStyle(e.ownerDocument.documentElement).fontSize):n}function yt({title:t,description:n,media:r,action:i,avatar:a,meta:c,status:l,details:u,open:d,defaultOpen:f=!1,onOpenChange:p,children:m,className:h,style:g,..._}){let y=s()??!1,b=(0,J.useId)(),x=(0,J.useRef)(null),S=(0,J.useRef)(null),[C,w]=(0,J.useState)(f),[T,E]=(0,J.useState)(!1),[D,O]=(0,J.useState)({}),[k,A]=(0,J.useState)(null),j=u?d??C:!1,M=!!u&&!y,N=!j&&k!==null,P=!!n,F=(0,J.useCallback)(e=>{d===void 0&&w(e),p?.(e)},[d,p]);(0,J.useEffect)(()=>{let e=x.current,t=S.current;if(!M||!e||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>{let n=getComputedStyle(e),r=vt(e,n.borderTopLeftRadius),i=vt(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=x.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),ct);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`?st:ot}}:{},te=t=>a||c||l||i?(0,X.jsxs)(`div`,{className:Y.footer,children:[a||c||l?(0,X.jsxs)(e.div,{className:Y.byline,...L(`byline`,t,`position`),children:[a?(0,X.jsx)(`span`,{className:Y.avatar,children:a}):null,(0,X.jsxs)(`span`,{className:Y.bylineText,children:[c?(0,X.jsx)(`span`,{className:Y.meta,children:c}):null,l?(0,X.jsx)(_t,{text:l,reduced:y}):null]})]}):null,i?(0,X.jsx)(e.div,{className:Y.action,...L(`action`,t,`position`),children:i}):null]}):null,R=(0,X.jsxs)(e.article,{..._,ref:x,className:[Y.card,h].filter(Boolean).join(` `),style:{...g,borderRadius:D.card??g?.borderRadius},"data-hover":T||void 0,whileHover:y?void 0:{y:-2},onHoverStart:()=>E(!0),onHoverEnd:()=>E(!1),...L(`card`,`card`),transition:{default:it.snappy,layout:st},children:[r?(0,X.jsx)(e.div,{className:Y.media,...L(`media`,`card`),children:(0,X.jsx)(e.div,{className:Y.zoom,initial:!1,animate:{scale:T&&!y?ut:1},transition:T?dt:ft,children:r})}):null,(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(e.h3,{className:Y.title,...L(`title`,`card`),children:u?(0,X.jsx)(ue,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:Y.trigger,children:t})}):t}),n?(0,X.jsx)(e.p,{ref:S,className:Y.description,...L(`description`,`card`,`position`),children:n}):null,m,te(`card`)]})]});return u?(0,X.jsx)(de,{open:j,onOpenChange:F,children:(0,X.jsxs)(v,{id:b,children:[R,(0,X.jsx)(o,{children:(j||N)&&(0,X.jsxs)(G,{forceMount:!0,children:[(0,X.jsx)(o,{children:j&&(0,X.jsx)(fe,{asChild:!0,forceMount:!0,children:(0,X.jsx)(e.div,{className:Y.overlay,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:y?lt:{duration:Z.exit,ease:[...rt.standard]}},transition:y?lt:{duration:Z.standard,ease:[...rt.enter]}})},`overlay`)}),(0,X.jsx)(me,{asChild:!0,forceMount:!0,...n?{}:{"aria-describedby":void 0},children:(0,X.jsxs)(e.div,{className:Y.panel,"data-framer-portal-id":b,"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?st:ot,borderRadius:N?st:ot},exit:{opacity:0,transition:{duration:0}}}:{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:lt},transition:lt},children:[r?(0,X.jsx)(e.div,{className:Y.media,...L(`media`,`panel`),children:(0,X.jsx)(e.div,{className:Y.zoom,initial:{scale:T&&!y?ut:1},animate:{scale:1},transition:ot,children:r})}):null,(0,X.jsx)(e.span,{className:Y.closeSlot,initial:y?{opacity:0}:{opacity:0,scale:.9},animate:N?{opacity:0,scale:.9}:{opacity:1,scale:1},transition:N||y?lt:mt,children:(0,X.jsx)(Te,{asChild:!0,children:(0,X.jsx)(e.button,{type:`button`,className:Y.close,"aria-label":`Close quick look`,whileTap:y?void 0:{scale:.94},transition:it.snappy,children:(0,X.jsx)(ee,{width:16,height:16,strokeWidth:1.75,"aria-hidden":`true`})})})}),(0,X.jsxs)(`div`,{className:Y.content,children:[(0,X.jsx)(be,{asChild:!0,children:(0,X.jsx)(e.h2,{className:Y.title,...L(`title`,`panel`),children:t})}),n?(0,X.jsx)(pe,{asChild:!0,children:(0,X.jsx)(e.p,{className:Y.description,...L(`description`,`panel`,`position`),children:n})}):null,m,te(`panel`),(0,X.jsx)(e.div,{className:Y.details,initial:!y&&{opacity:0,y:6},animate:N?{opacity:0,y:0}:{opacity:1,y:0},exit:{opacity:0,transition:lt},transition:N||y?lt:pt,children:u})]})]})})]},`quick-look`)})]})}):R}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`},bt={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]}})},xt={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}}},St=e=>Number(e.replace(/,/g,``).replace(/−/g,`-`).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN),Ct=new Intl.NumberFormat(`en-US`),wt={duration:r.duration.considered*1.75,ease:[...r.ease.inOut]},Tt={duration:r.duration.fast,ease:[...r.ease.standard]};function Et(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 Dt({text:t,direction:n,whole:i=!1,morph:a=!1,tone:c}){let l=!!s(),u=(0,J.useRef)(null),d=h(`auto`),[f,p]=(0,J.useState)({text:t,direction:1});f.text!==t&&p({text:t,direction:n??(St(t)<St(f.text)?-1:1)}),(0,J.useEffect)(()=>{let e=u.current;if(!e||typeof ResizeObserver>`u`)return;let t=null,n=new ResizeObserver(([n])=>{if(!n)return;let i=n.borderBoxSize?.[0]?.inlineSize??e.offsetWidth;t!==null&&t!==e.textContent&&!l?_(d,i,r.spring.morph):d.jump(i),t=e.textContent});return n.observe(e),()=>n.disconnect()},[a,l,d]);let m=!i&&!/\p{L}/u.test(t),g=l?xt:bt,v=m?`right`:`left`;return(0,X.jsxs)(e.span,{className:Q.roll,"data-end":m||void 0,"data-whole":i||void 0,style:a?{width:d}:void 0,children:[a&&(0,X.jsx)(`span`,{ref:u,className:Q.sizer,"aria-hidden":`true`,children:t}),(0,X.jsx)(`span`,{className:Q.track,children:(0,X.jsx)(o,{mode:`popLayout`,initial:!1,custom:f.direction,anchorX:v,children:Et(t,i).map(t=>(0,X.jsx)(e.span,{className:Q.slot,custom:f.direction,variants:g,initial:`hidden`,animate:`shown`,exit:`gone`,children:(0,X.jsx)(o,{mode:`popLayout`,initial:!1,custom:f.direction,anchorX:v,children:(0,X.jsx)(e.span,{className:c?`${Q.glyph} ${c}`:Q.glyph,custom:f.direction,variants:g,initial:`hidden`,animate:`shown`,exit:`gone`,children:t.text},`${c??``}${t.key}`)})},t.slot))})})]})}var Ot=5,kt=1.25,At=Array.from({length:161},(e,t)=>t/160);function jt(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 Mt(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 Nt(e,t,n,r){let i=e=>Ot+(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(Mt(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 Pt(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 Ft({data:t,label:n,value:i,change:a,tone:o=`accent`,width:c=160,height:l=52,labels:u,formatValue:d,area:f=!0,interactive:p=!0}){let m=t.length>1?t:[t[0]??0,t[0]??0],g=m.length-1,v=m.join(`,`),y=(0,J.useMemo)(()=>jt(v.split(`,`).map(Number)),[v]),b=`${n}: ${i??m[g]}. ${a??``}`.trim(),x=`sparkline${(0,J.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,S=(0,J.useRef)(null),C=(0,J.useRef)(null),w=Ge(S,{once:!0,amount:.5}),T=!!s(),[E,ee]=(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)(()=>Nt(y,c,l,1)),F=(0,J.useRef)(y),I=(0,J.useRef)(E),L=h(0),te=h(1),R=h(P.line),ne=h(P.trail),re=h(P.fill),z=h(P.dot),ie=h(P.cx),B=h(P.cx+kt+16),ae=h(P.cx+kt),V=h(0),oe=Ue(L,e=>+(e>.001)),H=(0,J.useCallback)(()=>{let{w:e,h:t}=I.current,n=L.get(),r=Nt(F.current,e,t,te.get());R.set(r.line),ne.set(r.trail),re.set(r.fill),z.set(r.dot),ie.set(r.cx),B.set(r.cx+kt+16),ae.set(r.cx+kt),V.set(n>=1?e+32:Pt(r.points,n)+16)},[te,ie,ae,z,L,re,R,B,V,ne]);Ye(te,`change`,H),Ye(L,`change`,H),(0,J.useLayoutEffect)(()=>{let e=C.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=e.clientWidth;t&&ee(e=>Math.abs(e.w-t)<.5?e:{w:t,h:t*l/c})});return t.observe(e),()=>t.disconnect()},[l,c]),(0,J.useLayoutEffect)(()=>{I.current=E,H()},[E,H]),(0,J.useEffect)(()=>{if(T){L.jump(1);let e=requestAnimationFrame(()=>A(!0));return()=>cancelAnimationFrame(e)}if(!w)return;let e=_(L,1,{...wt,onComplete:()=>A(!0)});return()=>e.stop()},[L,w,T]),(0,J.useEffect)(()=>{let e=F.current;if(e===y)return;if(T){F.current=y,H();return}let t=[...new Set([...At,...y.map(([e])=>e)])].sort((e,t)=>e-t),n=t.map(t=>Mt(e,t)),i=t.map(e=>Mt(y,e)),a=_(0,1,{...r.spring.smooth,onUpdate:e=>{F.current=t.map((t,r)=>[t,n[r]+(i[r]-n[r])*e]),H()},onComplete:()=>{F.current=y,H()}});return()=>a.stop()},[H,T,y]),(0,J.useEffect)(()=>{let e=j===null?1:j/g;if(T){te.jump(e);return}let t=_(te,e,r.spring.snappy);return()=>t.stop()},[te,j,g,T]);let U=j!==null,se=(e=>d?d(m[e],e):Ct.format(m[e]))(j??g),ce=u?.[j??g],W=i===void 0?void 0:U?se:i,le=j===null?a??``:i===void 0?[se,ce].filter(Boolean).join(` · `):ce??`${j+1} of ${g+1}`,ue=e=>{let t=C.current?.getBoundingClientRect();return t?.width?Math.max(0,Math.min(g,Math.round((e-t.left)/t.width*g))):g},de=p?{role:`slider`,tabIndex:0,"aria-label":`${n}, explore values`,"aria-valuemin":1,"aria-valuemax":g+1,"aria-valuenow":(j??g)+1,"aria-valuetext":`${ce??(j===null?`Latest`:`Point ${j+1} of ${g+1}`)}: ${se}`,onPointerDown:e=>O(ue(e.clientX)),onPointerMove:e=>{(e.pointerType===`mouse`||e.buttons)&&O(ue(e.clientX))},onPointerUp:e=>{e.pointerType!==`mouse`&&O(null)},onPointerLeave:()=>O(null),onPointerCancel:()=>O(null),onBlur:()=>O(null),onKeyDown:e=>{if(e.key===`Escape`&&U){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:S,className:Q.figure,"aria-label":b,children:[(0,X.jsxs)(`figcaption`,{className:Q.caption,children:[(0,X.jsx)(`span`,{className:Q.label,children:(0,X.jsx)(Dt,{text:n,whole:!0})}),W!==void 0&&(0,X.jsx)(`strong`,{children:(0,X.jsx)(Dt,{text:W,morph:!0})}),(0,X.jsx)(`small`,{className:Q[o],children:(0,X.jsx)(Dt,{text:le,direction:U?M.direction:void 0,tone:U?Q.point:void 0,morph:!0})})]}),(0,X.jsx)(`div`,{ref:C,className:Q.plot,"data-interactive":p||void 0,...de,children:(0,X.jsxs)(`svg`,{className:Q.chart,viewBox:`0 0 ${E.w} ${E.h}`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(`clipPath`,{id:`${x}-lit`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(e.rect,{x:-16,y:-16,width:B,height:E.h+32})}),(0,X.jsx)(`clipPath`,{id:`${x}-dim`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(e.rect,{x:ae,y:-16,width:E.w+32,height:E.h+32})}),(0,X.jsx)(`clipPath`,{id:`${x}-fill`,clipPathUnits:`userSpaceOnUse`,children:(0,X.jsx)(e.rect,{x:-16,y:-16,width:V,height:E.h+32})})]}),f&&(0,X.jsx)(e.path,{className:`${Q.area} ${Q[o]}`,d:re,clipPath:`url(#${x}-fill)`}),(0,X.jsx)(`line`,{className:Q.baseline,x1:`0`,y1:E.h-.5,x2:E.w,y2:E.h-.5}),(0,X.jsx)(e.path,{className:Q.trail,d:ne,clipPath:`url(#${x}-dim)`,initial:!1,animate:{opacity:U&&k?1:0},transition:T?{duration:0}:Tt}),(0,X.jsx)(e.polyline,{className:[Q.line,Q[o]].join(` `),points:R,clipPath:`url(#${x}-lit)`,style:{pathLength:L,opacity:oe}}),(0,X.jsx)(e.line,{className:Q.cursor,x1:ie,x2:ie,y1:0,y2:E.h,initial:!1,animate:{opacity:+!!U},transition:T?{duration:0}:Tt}),(0,X.jsx)(e.polyline,{className:[Q.end,Q[o]].join(` `),points:z,initial:!1,animate:{opacity:+!!k,strokeWidth:k?U?10:7:0},transition:T?{duration:0}:{opacity:Tt,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`},It=e=>`blur(${e}px)`,Lt={duration:0},Rt={duration:r.duration.fast,ease:[...r.ease.standard]},zt={duration:r.duration.standard,ease:[...r.ease.enter]},Bt={opacity:0,y:`0.3em`,filter:It(r.blur.soft)},Vt={opacity:1,y:0,filter:It(0)},Ht={opacity:0,y:`-0.3em`,filter:It(r.blur.subtle)},Ut={opacity:0,scale:.5,filter:It(r.blur.subtle)},Wt={opacity:1,scale:1,filter:It(0)};function Gt({text:t,className:n,reduced:i}){let a=(0,J.useRef)(null),s=(0,J.useRef)(0),c=h(`auto`);return(0,J.useLayoutEffect)(()=>{s.current=performance.now()+700},[t]),(0,J.useEffect)(()=>{let e=a.current,t=e?.parentElement;if(!e||!t||typeof ResizeObserver>`u`)return;let n=!1,o=new ResizeObserver(()=>{let t=e.offsetHeight;if(!n||i||performance.now()>s.current){n=!0,c.jump(t);return}_(c,t,r.spring.smooth)});return o.observe(e),()=>o.disconnect()},[c,i]),(0,X.jsx)(e.span,{className:$.slot,style:{height:c},children:(0,X.jsx)(`span`,{ref:a,className:$.slotInner,children:(0,X.jsx)(o,{mode:`popLayout`,initial:!1,children:t?(0,X.jsx)(e.span,{className:n,initial:Bt,animate:Vt,exit:{...Ht,transition:i?Lt:Rt},transition:i?Lt:zt,children:t},`${n}:${t}`):null})})})}function Kt({kind:t,number:n,delay:i,reduced:a}){let o=a?Lt:{scale:{...r.spring.snappy,delay:i},opacity:{duration:r.duration.fast,delay:i},filter:{duration:r.duration.fast,delay:i}},s={...Ut,transition:a?Lt:Rt},c=a?Lt:{duration:r.duration.standard,ease:r.ease.enter,delay:i+.04};return t===`number`?(0,X.jsx)(e.span,{className:$.glyph,initial:Ut,animate:Wt,exit:s,transition:o,children:n}):(0,X.jsx)(e.svg,{className:`${$.glyph} ${$.icon}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2.5,strokeLinecap:`round`,strokeLinejoin:`round`,initial:Ut,animate:Wt,exit:s,transition:o,children:t===`check`?(0,X.jsx)(e.path,{d:`M5.5 12.5l4.25 4.25L18.5 8`,initial:{pathLength:0},animate:{pathLength:1},transition:c}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(e.path,{d:`M12 6.75v6.5`,initial:{pathLength:0},animate:{pathLength:1},transition:c}),(0,X.jsx)(e.circle,{cx:12,cy:17.4,r:1.4,fill:`currentColor`,stroke:`none`,initial:{scale:0},animate:{scale:1},transition:a?Lt:{...r.spring.snappy,delay:i+.16}})]})})}function qt({number:t,kind:n,current:i,glyphDelay:a,ringDelay:s,reduced:c}){return(0,X.jsxs)(`span`,{className:$.marker,"aria-hidden":`true`,children:[(0,X.jsx)(o,{initial:!1,children:i?(0,X.jsx)(e.span,{className:$.ring,initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:c?Lt:Rt},transition:c?Lt:{scale:{...r.spring.snappy,delay:s},opacity:{duration:r.duration.fast,delay:s}}},`ring`):null}),(0,X.jsx)(`span`,{className:$.disc,children:(0,X.jsx)(o,{initial:!1,children:(0,X.jsx)(Kt,{kind:n,number:t,delay:a,reduced:c},n)})})]})}var Jt={complete:`Completed`,current:``,upcoming:`Not started`,error:`Error`};function Yt({steps:t,current:n,orientation:i=`horizontal`,onStepSelect:a,details:o=`all`,compact:c=!1,label:l=`Progress`,completeLabel:u=`All steps complete`,className:d}){let f=s()??!1,p=t.length,m=Math.min(Math.max(Math.round(n),0),p),[h,g]=(0,J.useState)({to:m,from:m});h.to!==m&&g({to:m,from:h.to});let _=h.from,v=r.stagger.line,y=e=>f?0:m>_?e>=_&&e<m?(e-_)*v:0:e>=m&&e<_?(_-1-e)*v:0,b=f?0:Math.max(0,Math.abs(m-_)-1)*v+.12,x=!!a,S=i===`vertical`,C=m>=p?void 0:t[m];function w(e){let t=!S&&getComputedStyle(e.currentTarget).direction===`rtl`,n=[`ArrowUp`,t?`ArrowRight`:`ArrowLeft`],r=[`ArrowDown`,t?`ArrowLeft`:`ArrowRight`];if(![...n,...r,`Home`,`End`].includes(e.key))return;let i=Array.from(e.currentTarget.querySelectorAll(`button[data-reachable]`)),a=i.indexOf(e.target);a<0||(e.preventDefault(),i[e.key===`Home`?0:e.key===`End`?i.length-1:n.includes(e.key)?Math.max(0,a-1):Math.min(i.length-1,a+1)]?.focus())}let T=x?`nav`:`div`,E=[$.root,S?$.vertical:$.horizontal,c?$.compact:``,d].filter(Boolean).join(` `);return(0,X.jsxs)(T,{className:E,"aria-label":l,role:x?void 0:`group`,children:[(0,X.jsx)(`ol`,{className:$.list,style:S?void 0:{gridTemplateColumns:p>1?`repeat(${p-1}, minmax(0, 1fr)) auto`:`auto`},onKeyDown:x?w:void 0,children:t.map((t,n)=>{let s=n===m,c=t.error?`error`:n<m?`complete`:s?`current`:`upcoming`,l=x&&n<m,u=t.error??(o===`all`||s?t.description:void 0),d=t.error?`error`:n<m?`check`:`number`,h=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qt,{number:n+1,kind:d,current:s,glyphDelay:y(n),ringDelay:b,reduced:f}),(0,X.jsxs)(`span`,{className:$.text,children:[(0,X.jsx)(`span`,{className:$.label,children:t.label}),Jt[c]?(0,X.jsxs)(`span`,{className:$.srOnly,children:[`, `,Jt[c]]}):null,(0,X.jsx)(Gt,{text:u,className:t.error?$.error:$.description,reduced:f})]})]});return(0,X.jsxs)(`li`,{className:$.item,"data-status":c,children:[n<p-1?(0,X.jsx)(`span`,{className:$.connector,"aria-hidden":`true`,children:(0,X.jsx)(e.span,{className:$.fill,initial:!1,animate:S?{scaleY:+(n<m)}:{scaleX:+(n<m)},transition:f?Lt:{...r.spring.smooth,delay:y(n)}},i)}):null,x?(0,X.jsx)(`button`,{type:`button`,className:$.head,"data-clickable":l||void 0,"data-reachable":n<=m||void 0,"aria-current":s?`step`:void 0,"aria-disabled":!l||void 0,tabIndex:l?void 0:-1,onClick:l?()=>a?.(n):void 0,children:h}):(0,X.jsx)(`span`,{className:$.head,"aria-current":s?`step`:void 0,children:h})]},t.id)})}),S?null:(0,X.jsxs)(`span`,{className:$.caption,"aria-hidden":`true`,children:[(0,X.jsx)(Gt,{text:C?.label??u,className:$.captionLabel,reduced:f}),(0,X.jsx)(Gt,{text:C?.error??C?.description,className:C?.error?$.error:$.description,reduced:f})]}),(0,X.jsx)(`span`,{className:$.srOnly,"aria-live":`polite`,children:C?`Step ${m+1} of ${p}: ${C.label}`:u})]})}var Xt={"openai-chat":`Chat`,"openai-responses":`Responses`,anthropic:`Anthropic`,gemini:`Gemini`},Zt={new:`green`,same:`neutral`,sameHost:`orange`,off:`neutral`,skip:`red`},Qt=e=>`${e.source}\u0000${e.ref}`,$t=e=>e.status!==`skip`&&e.status!==`same`;function en(e){try{return new URL(e).host}catch{return e}}function tn({open:e,onOpenChange:n}){let{t:r}=T(),{toast:i}=Se(),a=se(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(Qt)))},[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(Qt(e))&&$t(e)),[a.data,l]),g=(e,t)=>u(n=>{let r=new Set(n);return t?r.add(Qt(e)):r.delete(Qt(e)),r});return(0,X.jsx)(ye,{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)(Ne,{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(K(e)),a.refetch()}})},children:r(`import.selected`,{count:h.length})})]}),children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(j,{value:s,onChange:c,placeholder:r(`import.search`)}),d&&(0,X.jsx)(V,{tone:`danger`,title:r(`common.error`),children:d}),a.isLoading&&(0,X.jsx)(H,{lines:3}),a.isError&&(0,X.jsx)(V,{tone:`danger`,title:r(`common.error`),children:K(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)(nn,{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 nn({source:e,matches:t,selected:n,onToggle:r,filtering:i}){let{t:a}=T(),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)(V,{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)(rn,{c:e,checked:n.has(Qt(e)),onToggle:t=>r(e,t)},Qt(e)))}):(0,X.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:a(`import.notFound`)})]})}function rn({c:e,checked:t,onToggle:n}){let{t:r}=T(),i=$t(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=>`${Xt[e.protocol]??e.protocol} · ${en(e.baseUrl)}`).join(` / `);return(0,X.jsxs)(`li`,{className:R(`flex items-start gap-3 px-4 py-3`,!i&&`opacity-60`),children:[(0,X.jsx)(Je,{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)(I,{tone:Zt[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 an=``,on=`custom`,sn=[{name:`userId`,secret:!1,required:!1},{name:`accessToken`,secret:!0,required:!1}],cn={method:`GET`,url:`{{baseUrl}}/user/balance`,auth:`provider`,headers:{}},ln={isValid:`is_active`,remaining:`balance`,unit:{$const:`USD`}},un=e=>JSON.stringify(e??{},null,2);function dn(e){return{enabled:e.enabled,template:e.template??an,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:un(e.request?.headers),extract:e.extract?un(e.extract):``}}function fn(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`&&!Array.isArray(t)?t:null}catch{return null}}function pn({provider:e}){let{t}=T(),{toast:r}=Se(),i=ae(),a=n(e.id),o=l(e.id),s=A(),c=e.quotaConfig,u=(0,J.useMemo)(()=>dn(c),[c]),[d,f]=(0,J.useState)(u),[p,m]=(0,J.useState)(null);(0,J.useEffect)(()=>f(u),[u]);let h=i.data??[],g=h.find(e=>e.id===c.suggestedTemplate),_=d.template===an?g:h.find(e=>e.id===d.template),v=d.template===on,y=v?sn:_?.params??[],b=e=>f(t=>({...t,...e})),x=JSON.stringify(d)!==JSON.stringify(u),S=e=>{if(e!==on||d.url)return b({template:e});let t=_??g;b({template:e,method:t?.request.method??cn.method,url:t?.request.url??cn.url,auth:t?.request.auth??cn.auth,headers:un(t?.request.headers??cn.headers),extract:un(t?.extract??ln)})},w=()=>{let e={enabled:d.enabled,template:d.template===an?null:d.template,intervalMinutes:d.intervalMinutes,timeoutSec:d.timeoutSec??10,baseUrl:d.baseUrl.trim()||null,params:Object.fromEntries(Object.entries(d.params).filter(([,e])=>e.trim()!==``).map(([e,t])=>[e,t.trim()])),secrets:Object.fromEntries(Object.entries(d.secrets).filter(([,e])=>e.trim()!==``))};if(v){let n=fn(d.headers),i=fn(d.extract);if(!n||!i)return r(t(`providers.quota.invalidJson`,{field:t(n?`providers.quota.extract`:`providers.quota.headers`)}),`error`),null;e.request={method:d.method,url:d.url.trim(),auth:d.auth,headers:n},e.extract=i}return e},ee=()=>{let n=w();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(K(e),`error`)})},onError:e=>r(K(e),`error`)})},D=()=>{let e=w();e&&o.mutate(e,{onSuccess:m,onError:e=>r(K(e),`error`)})},k=c.effectiveIntervalMinutes>0?t(`providers.quota.intervalEvery`,{minutes:c.effectiveIntervalMinutes}):t(`providers.quota.intervalOff`),j=[{value:an,label:g?t(`providers.quota.templateAuto`,{name:g.name}):t(`providers.quota.templateNone`)},...h.map(e=>({value:e.id,label:e.name,detail:t(`providers.quota.kind.${e.kind}`)})),{value:on,label:t(`providers.quota.custom`)}];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(oe,{title:t(`providers.quota.title`),footer:t(`providers.quota.footer`),children:[(0,X.jsx)(F,{label:t(`providers.quota.enable`),detail:t(`providers.quota.enableHint`),children:(0,X.jsx)(W,{checked:d.enabled,label:t(`providers.quota.enable`),onChange:e=>b({enabled:e})})}),(0,X.jsx)(F,{label:t(`providers.quota.template`),children:(0,X.jsx)(q,{className:`w-64`,ariaLabel:t(`providers.quota.template`),value:d.template,onChange:S,options:j})}),y.map(e=>{let n=t(`providers.quota.param.${e.name}`),r=c.secrets.includes(e.name);return e.secret?(0,X.jsx)(F,{label:n,detail:r?t(`providers.quota.secretStored`):void 0,children:(0,X.jsx)(E,{type:`password`,autoComplete:`off`,className:`w-64 font-mono`,"aria-label":n,placeholder:r?`••••••••`:``,value:d.secrets[e.name]??``,onChange:t=>b({secrets:{...d.secrets,[e.name]:t.target.value}})})},e.name):(0,X.jsx)(F,{label:n,children:(0,X.jsx)(E,{className:`w-64 font-mono`,"aria-label":n,value:d.params[e.name]??``,onChange:t=>b({params:{...d.params,[e.name]:t.target.value}})})},e.name)}),y.length>0&&(0,X.jsx)(`div`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.paramsHint`)}),v&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(q,{className:`w-28`,ariaLabel:t(`providers.quota.method`),value:d.method,onChange:e=>b({method:e}),options:[{value:`GET`,label:`GET`},{value:`POST`,label:`POST`}]}),(0,X.jsx)(E,{className:`min-w-60 flex-1 font-mono`,"aria-label":t(`providers.quota.url`),value:d.url,onChange:e=>b({url:e.target.value})}),(0,X.jsx)(q,{className:`w-52`,ariaLabel:t(`providers.quota.auth`),value:d.auth,onChange:e=>b({auth:e}),options:[{value:`provider`,label:t(`providers.quota.auth.provider`)},{value:`none`,label:t(`providers.quota.auth.none`)}]})]}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.urlHint`)}),(0,X.jsx)(C,{label:t(`providers.quota.headers`),mono:!0,rows:3,value:d.headers,onChange:e=>b({headers:e.target.value})}),(0,X.jsx)(C,{label:t(`providers.quota.extract`),mono:!0,rows:8,value:d.extract,onChange:e=>b({extract:e.target.value})}),(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`providers.quota.extractHint`)})]}),(0,X.jsx)(F,{label:t(`providers.quota.interval`),detail:t(`providers.quota.intervalHint`,{value:k}),children:(0,X.jsx)(ne,{className:`w-28`,label:t(`providers.quota.interval`),min:0,step:1,value:d.intervalMinutes,onChange:e=>b({intervalMinutes:e})})}),(0,X.jsx)(F,{label:t(`providers.quota.timeout`),children:(0,X.jsx)(ne,{className:`w-28`,label:t(`providers.quota.timeout`),min:1,step:1,value:d.timeoutSec,onChange:e=>b({timeoutSec:e})})}),(0,X.jsx)(F,{label:t(`providers.quota.baseUrl`),detail:t(`providers.quota.baseUrlHint`),children:(0,X.jsx)(E,{className:`w-64 font-mono`,"aria-label":t(`providers.quota.baseUrl`),placeholder:e.endpoints[0]?.baseUrl,value:d.baseUrl,onChange:e=>b({baseUrl:e.target.value})})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 py-3`,children:[(0,X.jsx)(z,{size:`sm`,variant:`primary`,disabled:!x,loading:a.isPending,onClick:ee,children:t(`common.save`)}),(0,X.jsx)(z,{size:`sm`,icon:(0,X.jsx)(Oe,{className:`size-3.5`}),loading:o.isPending,onClick:D,title:t(`providers.quota.testDesc`),children:t(`providers.quota.test`)}),(0,X.jsx)(z,{size:`sm`,icon:(0,X.jsx)($e,{className:`size-3.5`}),disabled:x,loading:s.isPending,onClick:()=>s.mutate(e.id,{onError:e=>r(K(e),`error`)}),children:t(`providers.quota.fetch`)})]}),(0,X.jsx)(`div`,{className:`px-4 pb-4`,children:(0,X.jsx)(mn,{snapshot:e.quota,checkedAtUtc:e.quotaCheckedAtUtc})})]}),(0,X.jsx)(ye,{open:p!==null,onOpenChange:e=>!e&&m(null),title:t(`providers.quota.test`),description:t(`providers.quota.testDesc`),width:560,children:p&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(V,{tone:p.ok?`success`:`danger`,title:p.ok?t(`providers.quota.testOk`):t(`providers.quota.testFailed`),children:[!p.ok&&ge({code:p.errorCode??null,message:p.error??``},t),!p.ok&&p.error&&p.errorCode&&(0,X.jsx)(`div`,{className:`mt-1 text-[11px] opacity-80`,children:p.error})]}),p.url&&(0,X.jsx)(O,{label:t(`providers.quota.requestUrl`),mono:!0,children:p.url}),p.httpStatus!=null&&(0,X.jsx)(O,{label:t(`providers.quota.httpStatus`),children:p.httpStatus}),p.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)(mn,{snapshot:p.snapshot})]}),p.raw!==void 0&&p.raw!==null&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[12px] text-[var(--text-secondary)]`,children:t(`providers.quota.rawResponse`)}),(0,X.jsx)(M,{children:un(p.raw)})]})]})})]})}function mn({snapshot:e,checkedAtUtc:t}){let{t:n,locale:r}=T(),i=Ce(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)(V,{tone:`warning`,title:n(`providers.quota.failed`,{error:ge(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)(V,{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)(I,{children:e.name}),(0,X.jsx)(`span`,{className:`num`,children:we(e,n,r)??`—`}),_e(e,n,r)&&(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:_e(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)(I,{tone:`accent`,children:e.planLabel}),o>0&&(0,X.jsx)(`span`,{children:n(`providers.quota.fetchedAt`,{time:he(o,r,n(`tray.justNow`))??``})})]})]})}function hn({provider:e}){let{t,locale:n}=T(),{toast:r}=Se(),i=A();if(!ve(e))return null;let a=xe(e.quota,t,n),o=Ce(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:ge(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)($e,{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(K(e),`error`)})})]})}var gn=e=>e.authScheme!==`oauth-subscription`&&e.authScheme!==`plugin`,_n=e=>e.category!==`subscription`&&e.category!==`custom`&&e.authScheme!==`oauth-subscription`;function vn({open:e,onOpenChange:t,provider:n}){let{t:r}=T(),{toast:i}=Se(),a=re(),o=g(n.id),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),d=(a.data??[]).filter(_n);(0,J.useEffect)(()=>{e&&(c(n.templateId??``),u(``))},[e,n.templateId]);let f=d.find(e=>e.id===s),p=f?f.variants?.find(e=>e.id===l)?.endpointsOverride??f.endpoints:[],m=s===n.templateId&&!l;return(0,X.jsxs)(ye,{open:e,onOpenChange:t,title:r(`providers.templateSwitch`),description:r(`providers.templateSwitchDetail`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,X.jsx)(z,{variant:`primary`,disabled:!f||m,loading:o.isPending,onClick:()=>f&&o.mutate({templateId:f.id,variantId:l||null},{onSuccess:()=>{t(!1),i(r(`providers.templateSwitched`,{name:f.name}),`success`)},onError:e=>i(K(e),`error`)}),children:r(`common.apply`)})]}),children:[a.isLoading&&(0,X.jsx)(H,{}),a.isError&&(0,X.jsx)(V,{tone:`danger`,title:r(`common.error`),children:K(a.error)}),(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(P,{label:r(`providers.templateSwitchTarget`),children:(0,X.jsx)(q,{value:s,onChange:e=>{c(e),u(``)},options:d.map(e=>({value:e.id,label:e.id===n.templateId?r(`providers.templateSwitchCurrent`,{name:e.name}):e.name,detail:e.id}))})}),f?.variants&&f.variants.length>0&&(0,X.jsx)(P,{label:r(`providers.variant`),children:(0,X.jsx)(q,{value:l,onChange:u,options:[{value:``,label:r(`providers.variantDefault`)},...f.variants.map(e=>({value:e.id,label:e.name}))]})}),f&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-2 text-[13px] font-medium`,children:r(`providers.templateSwitchEndpoints`)}),(0,X.jsx)(`ul`,{className:`grid gap-1 text-[12px]`,children:p.map(e=>(0,X.jsxs)(`li`,{className:`flex gap-3`,children:[(0,X.jsx)(`span`,{className:`w-36 shrink-0 text-[var(--text-secondary)]`,children:Bn.find(t=>t.value===e.protocol)?.label??e.protocol}),(0,X.jsx)(`span`,{className:`min-w-0 font-mono break-all`,children:e.baseUrl})]},e.protocol))})]})]})]})}function yn({provider:e,httpStatus:t,className:n}){return t!==401&&t!==403||!e.templateId||!gn(e)?null:(0,X.jsx)(bn,{provider:e,className:n})}function bn({provider:e,className:t}){let{t:n}=T(),{toast:r,confirm:i}=Se(),a=re(),o=g(e.id),s=a.data?.find(t=>t.id===e.templateId),c=(s?.keyAlternatives??[]).flatMap(e=>a.data?.filter(t=>t.id===e)??[]);if(!s||c.length===0)return null;let l=async e=>{let t=[...new Set(e.endpoints.map(e=>e.baseUrl))].join(`, `);await i({title:n(`providers.templateSwitchConfirm`,{alt:e.name}),detail:n(`providers.templateSwitchConfirmDetail`,{urls:t}),confirmLabel:n(`providers.keyAlternative.switch`,{alt:e.name})})&&o.mutate({templateId:e.id},{onSuccess:()=>r(n(`providers.templateSwitched`,{name:e.name}),`success`),onError:e=>r(K(e),`error`)})};return(0,X.jsxs)(V,{className:t,tone:`warning`,title:n(`providers.keyAlternative.title`),children:[n(`providers.keyAlternative.rejected`,{name:s.name,alt:c.map(e=>e.name).join(` / `)}),(0,X.jsx)(`span`,{className:`mt-2 flex flex-wrap gap-2`,children:c.map(e=>(0,X.jsx)(z,{size:`sm`,loading:o.isPending,onClick:()=>void l(e),children:n(`providers.keyAlternative.switch`,{alt:e.name})},e.id))})]})}var xn=3,Sn=256,Cn=4096,wn={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 Tn(e){let t=e.endpoints.map(e=>e.protocol);return e.preferredUpstreamProtocols.find(e=>t.includes(e))??t[0]??`openai-chat`}var En=e=>typeof e==`number`?e:null,Dn=e=>typeof e==`string`?e:null;function On({provider:e,open:t,onOpenChange:n}){let{t:r}=T(),i=d(),a=ie(t?e.id:void 0),o=e.endpoints.map(e=>e.protocol),[s,c]=(0,J.useState)(`single`),[l,u]=(0,J.useState)(()=>Tn(e)),[f,p]=(0,J.useState)(!0),[m,h]=(0,J.useState)(``),[g,_]=(0,J.useState)(Sn),[v,y]=(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,j]=(0,J.useState)([]),[M,N]=(0,J.useState)(``),[F,I]=(0,J.useState)(null),[L,te]=(0,J.useState)(!1),R=(0,J.useRef)(null),ne=(0,J.useRef)(new Map),re=(0,J.useRef)(!1),B=(0,J.useRef)(!1),ae=(0,J.useMemo)(()=>{let e=[...a.data??[]].sort((e,t)=>Number(t.enabled)-Number(e.enabled)||e.sortOrder-t.sortOrder).map(e=>e.modelId);return[...e,...A.filter(t=>!e.includes(t))]},[a.data,A]);(0,J.useEffect)(()=>{if(t){y(e=>e||(a.data??[]).find(e=>e.enabled)?.modelId||(a.data??[])[0]?.modelId||``);return}B.current=!1,R.current?.abort();for(let e of ne.current.values())e.abort();ne.current.clear(),x(null),w({}),D([]),k(new Set),j([]),N(``),I(null)},[t,a.data]);let V=(0,J.useCallback)(e=>({modelId:e,protocol:l,stream:f,prompt:m.trim()||null,maxOutputTokens:g??Sn}),[l,f,m,g]),oe=(0,J.useCallback)((t,n,r)=>Ln(e.id,t,V(t),n,r),[e.id,V]),H=()=>{let e=v.trim();if(!e)return;R.current?.abort();let t=new AbortController;R.current=t,B.current=!0,I(null),x({modelId:e,status:`running`,text:``,reasoning:``}),oe(e,t.signal,e=>{e.status!==`running`&&e.status!==`queued`&&se(),x(e)})},U=e=>{if(e.length===0)return;B.current=!0,re.current=!1,I(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(xn,e.length)},async()=>{for(;;){if(!B.current)return;let n=e[t++];if(n===void 0)return;if(re.current){w(e=>({...e,[n]:{...e[n],status:`cancelled`}}));continue}let r=new AbortController;ne.current.set(n,r),await oe(n,r.signal,e=>w(t=>({...t,[n]:e}))),ne.current.delete(n),se()}}))},se=()=>void i.invalidateQueries({queryKey:[`requests`]}),ce=()=>{re.current=!0,w(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.status===`queued`?{...t,status:`cancelled`}:t])))},W=b?.status===`running`||E.some(e=>C[e]?.status===`running`||C[e]?.status===`queued`&&!re.current),le=E.filter(e=>C[e]&&C[e].status!==`queued`&&C[e].status!==`running`).length,ue=E.filter(e=>C[e]?.status===`success`).length,de=E.filter(e=>C[e]?.status===`failed`).length,fe=(e,t)=>k(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),pe=()=>{W||n(!1)},G=e=>e.stopPropagation();return(0,X.jsx)(`span`,{onClick:G,onKeyDown:G,children:(0,X.jsxs)(ye,{open:t,onOpenChange:e=>e?n(!0):pe(),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:W,onClick:()=>n(!1),icon:(0,X.jsx)(ee,{className:`size-3.5`}),children:r(`common.close`)}),s===`single`?W?(0,X.jsx)(z,{variant:`primary`,icon:(0,X.jsx)(tt,{className:`size-3.5`}),onClick:()=>R.current?.abort(),children:r(`providers.testDialog.stop`)}):(0,X.jsx)(z,{variant:`primary`,disabled:v.trim()===``,icon:(0,X.jsx)(Oe,{className:`size-3.5`}),onClick:H,children:r(b?`providers.testDialog.retest`:`providers.testDialog.start`)}):W?(0,X.jsx)(z,{variant:`primary`,icon:(0,X.jsx)(tt,{className:`size-3.5`}),onClick:ce,children:r(`providers.testDialog.stopRest`)}):(0,X.jsx)(z,{variant:`primary`,disabled:O.size===0,icon:(0,X.jsx)(Oe,{className:`size-3.5`}),onClick:()=>U([...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)(Ke,{name:e.name,icon:e.icon,colorKey:e.templateId,size:32}),(0,X.jsx)(S,{items:[{value:`single`,label:r(`providers.testDialog.modeSingle`)},{value:`batch`,label:r(`providers.testDialog.modeBatch`)}],value:s,onChange:e=>{c(e),I(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)(P,{label:r(`providers.testDialog.model`),children:(0,X.jsx)(kn,{value:v,models:ae,onChange:y})}),(0,X.jsx)(An,{protocols:o,protocol:l,onProtocol:u,stream:f,onStream:p,maxTokens:g,onMaxTokens:_,prompt:m,onPrompt:h}),(0,X.jsx)(`p`,{className:`mt-auto text-[11px] text-[var(--text-muted)]`,children:r(`providers.testDialog.savedCredentials`)})]}),(0,X.jsx)(jn,{provider:e,run:b,onRetest:H})]}):F===null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Fn,{known:ae,selected:O,onToggle:fe,onSelectAll:e=>k(e?new Set(ae):new Set),onClear:()=>k(new Set),search:M,onSearch:N,onAdd:e=>{j(t=>t.includes(e)?t:[...t,e]),k(t=>new Set(t).add(e)),N(``)},configOpen:L,onConfigOpen:te,protocols:o,protocol:l,onProtocol:u,stream:f,onStream:p,maxTokens:g,onMaxTokens:_,prompt:m,onPrompt:h}),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:W?r(`providers.testDialog.progress`,{done:le,total:E.length,ok:ue,failed:de}):r(`providers.testDialog.progressDone`,{total:E.length,ok:ue,failed:de})}),(0,X.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-strong)]`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full transition-[width]`,style:{width:`${le/E.length*100}%`,background:`var(--accent)`}})})]}):null,E.length>0?(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(In,{order:E,runs:C,onView:I})}):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)(Ee,{className:`size-4`}),"aria-label":r(`common.back`),onClick:()=>I(null)}),(0,X.jsx)(`span`,{className:`font-mono text-[13px]`,children:F})]}),(0,X.jsx)(jn,{provider:e,run:C[F]??null})]})]})})}function kn({value:e,models:t,onChange:n}){let{t:r}=T(),[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)(E,{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)(le,{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:R(`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 An({protocols:e,...t}){let{t:n}=T(),r=e.map(e=>({value:e,label:Bn.find(t=>t.value===e)?.label??e}));return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(P,{label:n(`providers.testDialog.protocol`),children:(0,X.jsx)(q,{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)(W,{checked:t.stream,label:n(`providers.testDialog.stream`),onChange:t.onStream})]}),(0,X.jsx)(P,{label:n(`providers.testDialog.maxTokens`),children:(0,X.jsx)(ne,{value:t.maxTokens,min:1,placeholder:String(Sn),label:n(`providers.testDialog.maxTokens`),onChange:e=>t.onMaxTokens(e===null?null:Math.min(Cn,Math.max(1,Math.round(e))))})}),(0,X.jsx)(P,{label:n(`providers.testDialog.prompt`),hint:n(`providers.testDialog.promptHint`),children:(0,X.jsx)(C,{rows:4,value:t.prompt,placeholder:`Reply with OK.`,onChange:e=>t.onPrompt(e.target.value)})})]})}function jn({provider:e,run:t,onRetest:n}){let{t:r}=T(),[i,a]=(0,J.useState)(`preview`),o=t?.text??``,s=t?.raw??``,c=Object.entries(t?.headers??{}),l=t?.ttftMs!=null&&t?.httpMs!=null?Math.max(0,t.ttftMs-t.httpMs):null,u=i===`raw`?s:i===`headers`?c.map(([e,t])=>`${e}: ${t}`).join(`
2
- `):o;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:[n&&t&&t.status!==`running`?(0,X.jsx)(z,{size:`sm`,icon:(0,X.jsx)(Oe,{className:`size-3.5`}),onClick:n,children:r(`providers.testDialog.retest`)}):null,(0,X.jsx)(ze,{content:r(`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)(Ze,{className:`size-4`})})}),(0,X.jsx)(Pn,{run:t}),t?.httpStatus?(0,X.jsxs)(I,{tone:`neutral`,children:[`HTTP `,t.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)(Nn,{label:r(`providers.testDialog.metrics.http`),value:t?.httpMs}),(0,X.jsx)(Nn,{label:r(`providers.testDialog.metrics.firstWait`),value:l}),(0,X.jsx)(Nn,{label:r(`providers.testDialog.metrics.ttft`),value:t?.ttftMs}),(0,X.jsx)(Nn,{label:r(`providers.testDialog.metrics.total`),value:t?.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:r(`providers.testDialog.reply`)}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,X.jsx)(S,{items:[{value:`preview`,label:r(`providers.testDialog.preview`)},{value:`raw`,label:r(`providers.testDialog.raw`)},{value:`headers`,label:r(`providers.testDialog.headers`)}],value:i,onChange:a,ariaLabel:r(`providers.testDialog.reply`)}),(0,X.jsx)(U,{value:u,label:r(i===`headers`?`providers.testDialog.headers`:`providers.testDialog.reply`),iconOnly:!0})]})]}),(0,X.jsx)(`div`,{className:`h-[360px] overflow-auto px-4 py-3`,children:i===`headers`?c.length===0?(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`providers.testDialog.headersEmpty`)}):(0,X.jsx)(`table`,{className:`w-full text-[11px]`,children:(0,X.jsx)(`tbody`,{children:c.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))})}):i===`raw`?s?(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsxs)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:[r(`providers.testDialog.rawNote`),t?.contentType?` · ${t.contentType}`:``]}),(0,X.jsx)(`pre`,{className:`font-mono text-[11px] leading-[1.6] break-all whitespace-pre-wrap selectable`,children:s}),t?.rawTruncated?(0,X.jsx)(`p`,{className:`text-[11px] text-[var(--warning)]`,children:r(`providers.testDialog.rawTruncated`)}):null]}):(0,X.jsx)(Mn,{run:t}):t?.error?(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[(0,X.jsx)(V,{tone:`danger`,title:r(`providers.testDialog.status.failed`),children:t.error}),(0,X.jsx)(yn,{provider:e,httpStatus:t.httpStatus})]}):o||t?.reasoning?(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[t?.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:r(`providers.testDialog.reasoning`)}),(0,X.jsx)(`pre`,{className:`font-mono text-[11px] leading-[1.6] whitespace-pre-wrap selectable`,children:t.reasoning})]}):null,o?(0,X.jsx)(`pre`,{className:`font-mono text-[12px] leading-[1.7] break-words whitespace-pre-wrap selectable`,children:o}):null]}):t?.status===`success`?(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`providers.testDialog.noText`)}):(0,X.jsx)(Mn,{run:t})})]})]})}function Mn({run:e}){let{t}=T();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(wn[e.status])}):(0,X.jsxs)(`div`,{className:`grid h-full place-items-center content-center gap-2 text-center`,children:[(0,X.jsx)(Fe,{className:`mx-auto size-6 text-[var(--text-muted)]`}),(0,X.jsx)(`div`,{className:`text-[13px]`,children:t(`providers.testDialog.emptyTitle`)}),(0,X.jsx)(`p`,{className:`mx-auto max-w-[320px] text-[11px] text-[var(--text-muted)]`,children:t(`providers.testDialog.emptyDetail`)})]})}function Nn({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 Pn({run:e}){let{t}=T(),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(wn[n])]})}function Fn({known:e,selected:t,onToggle:n,onSelectAll:r,onClear:i,search:a,onSearch:o,onAdd:s,configOpen:c,onConfigOpen:l,...u}){let{t:d}=T(),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)(j,{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)(Oe,{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)(Je,{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)(qe,{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)(Je,{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)(ye,{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)(An,{...u})})})]})}function In({order:e,runs:t,onView:n}){let{t:r}=T();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)(Pn,{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 Ln(e,t,n,r,a){let o={modelId:t,status:`running`,text:``,reasoning:``};a(o);let s=e=>{o={...o,...e},a(o)};try{await N(e,n,e=>{let t=e.data??{};switch(e.event){case`headers`:s({httpStatus:En(t.httpStatus),httpMs:En(t.httpMs),contentType:Dn(t.contentType),headers:Rn(t.headers)});break;case`delta`:{let e=Dn(t.text)??``;Dn(t.kind)===`reasoning`?s({reasoning:o.reasoning+e}):s({text:o.text+e});break}case`done`:{let t=e.data;s({status:t.ok?`success`:`failed`,error:t.error??null,httpStatus:t.httpStatus??null,httpMs:t.httpMs??null,ttftMs:t.ttftMs??null,totalMs:t.totalMs??null,text:t.text??``,reasoning:t.reasoning??``,raw:t.raw??``,rawTruncated:t.rawTruncated??!1,contentType:t.contentType??null,headers:Rn(t.headers)});break}}},r)}catch(e){e?.name===`AbortError`?s({status:`cancelled`,error:null}):s({status:`failed`,error:e instanceof i?e.message:String(e)})}}function Rn(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 zn=c({AUTH_OPTIONS:()=>Vn,PROTOCOL_OPTIONS:()=>Bn,ProvidersPage:()=>Hn}),Bn=[{value:`openai-chat`,label:`OpenAI Chat`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic`,label:`Anthropic Messages`},{value:`gemini`,label:`Gemini`}],Vn=[{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 Hn(){let{t:e}=T(),t=Me(),[n,r]=Re(),i=te(),[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]),Ve(e=>{e===`new-provider`&&o(!0)});let l=x(`7d`,`day`,`provider`),[u,d]=(0,J.useState)(null),f=(0,J.useMemo)(()=>{let e=Wn(Un),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)(Be,{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)(De,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`providers.import`)}),(0,X.jsx)(z,{variant:`primary`,icon:(0,X.jsx)(qe,{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)(H,{lines:4}),i.isError&&(0,X.jsx)(V,{tone:`danger`,title:e(`common.error`),children:K(i.error)}),i.data?.length===0&&(0,X.jsx)(`div`,{className:`card`,children:(0,X.jsx)(w,{icon:(0,X.jsx)(Ae,{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)(qe,{className:`size-3.5`}),onClick:()=>o(!0),children:e(`providers.add`)}),(0,X.jsx)(z,{icon:(0,X.jsx)(De,{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)(qn,{p:e,days:f.days,usage:f.byProvider.get(e.name),onOpen:()=>t(`/providers/${e.id}`),onTest:()=>d(e)},e.id))})]}),(0,X.jsx)(tn,{open:s,onOpenChange:c}),(0,X.jsx)(ar,{open:a,onOpenChange:o,onCreated:e=>t(`/providers/${e.id}`)}),u&&(0,X.jsx)(On,{provider:u,open:!0,onOpenChange:e=>!e&&d(null)})]})}var Un=7;function Wn(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 Gn(e){if(!e)return null;try{return new URL(e).host}catch{return e}}var Kn=e=>e.stopPropagation();function qn({p:e,days:t,usage:n,onOpen:r,onTest:i}){let{t:a}=T(),o=k(e.id),{toast:s}=Se(),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(` · `),d=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`),f=e.enabled?l?{tone:`orange`,label:a(`providers.noKey`)}:{tone:`green`,label:a(`providers.card.active`)}:{tone:`neutral`,label:a(`providers.card.disabled`)},p=n?.requests??t.map(()=>0),h=p.reduce((e,t)=>e+t,0),g=e.templateUpdateAvailable?5:8;return(0,X.jsxs)(yt,{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=>Bn.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:R(`transition-[filter,opacity]`,!e.enabled&&`opacity-50 grayscale`),children:(0,X.jsx)(Ke,{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:f.tone}),f.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:Gn(e.endpoints[0]?.baseUrl)??`—`}),(0,X.jsx)(`span`,{className:`shrink-0`,children:a(`providers.modelCount`,{count:e.modelCount})})]})]}),meta:(0,X.jsx)(`span`,{className:R(e.hasApiKey&&e.authScheme!==`oauth-subscription`&&`font-mono`),children:d}),status:u||void 0,action:(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,onClick:Kn,children:[(0,X.jsx)(z,{variant:`plain`,size:`sm`,icon:(0,X.jsx)(Oe,{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)(W,{checked:e.enabled,label:a(`common.enabled`),onChange:e=>o.mutate({enabled:e},{onError:e=>s(K(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)(I,{tone:`accent`,children:a(`providers.templateUpdate`)}),e.boundClients.slice(0,g).map(e=>e in Ie?(0,X.jsx)(`span`,{title:Pe(e),className:`inline-flex shrink-0`,children:(0,X.jsx)(Le,{kind:e,size:18})},e):(0,X.jsx)(I,{tone:`green`,children:e},e)),e.boundClients.length>g&&(0,X.jsxs)(`span`,{title:e.boundClients.slice(g).map(e=>Ie[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:Kn,children:(0,X.jsx)(hn,{provider:e})}),(0,X.jsx)(`div`,{className:`mt-2`,onClick:Kn,children:h>0?(0,X.jsx)(Ft,{label:a(`providers.card.requests7d`),data:p,labels:t.map(e=>e.slice(5)),value:b(h,!0),change:m(n?.costUsd??0),width:320,height:28,formatValue:e=>b(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 Jn=`plugin:`,Yn=[`recommended`,`official`,`subscription`,`coding`,`cn`,`aggregator`,`inference`,`local`,`custom`],Xn={"openai-chat":`Chat`,"openai-responses":`Responses`,anthropic:`Anthropic`,gemini:`Gemini`},Zn=e=>Bn.find(t=>t.value===e)?.label??e,Qn=e=>(0,X.jsx)(`span`,{title:e,children:e}),$n=e=>{let t=/^(.+?)\s*[((]([^()()]+)[))]$/.exec(e);return t?[t[1],t[2]]:[e,null]},er=/[\s,,]+/;function tr(e,t,n){let r=new Set(t.map(e=>e.protocol)),i=n.map(e=>e.protocol);return[...e.filter(e=>i.includes(e)),...i.filter(t=>!r.has(t)&&!e.includes(t))]}function nr({label:e,hint:t,children:n}){return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsx)(`div`,{className:`mb-2 text-[13px] font-medium`,children:e}),n,t&&(0,X.jsx)(`div`,{className:`mt-2 text-[11px] text-[var(--text-muted)]`,children:t})]})}function rr({value:e,onChange:t}){let{t:n}=T(),r=e.map(e=>e.protocol),i=Bn.filter(e=>!r.includes(e.value)),a=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e));return(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[e.map((i,o)=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(q,{className:`w-44`,ariaLabel:n(`providers.protocol`),value:i.protocol,onChange:e=>a(o,{protocol:e}),options:Bn.filter(e=>e.value===i.protocol||!r.includes(e.value))}),(0,X.jsx)(E,{className:`min-w-52 flex-1`,mono:!0,"aria-label":n(`providers.baseUrl`),placeholder:`https://api.example.com/v1`,value:i.baseUrl,onChange:e=>a(o,{baseUrl:e.target.value})}),(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,title:n(`providers.fullUrlHint`),children:[(0,X.jsx)(W,{checked:!!i.fullUrl,label:n(`providers.fullUrl`),onChange:e=>a(o,{fullUrl:e})}),n(`providers.fullUrl`)]}),(0,X.jsx)(z,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(je,{className:`size-3.5`}),"aria-label":n(`common.delete`),disabled:e.length===1,onClick:()=>t(e.filter((e,t)=>t!==o))})]},o)),i.length>0&&(0,X.jsx)(`div`,{children:(0,X.jsx)(z,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(qe,{className:`size-3.5`}),onClick:()=>t([...e,{protocol:i[0].value,baseUrl:e[0]?.baseUrl??``}]),children:n(`providers.addEndpoint`)})})]})}function ir({value:e,onChange:t}){let{t:n}=T(),r=(n,r)=>t(e.map((e,t)=>t===n?r:e));return(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[e.map(([i,a],o)=>(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(E,{className:`w-44`,mono:!0,"aria-label":n(`providers.headerName`),placeholder:`Header`,value:i,onChange:e=>r(o,[e.target.value,a])}),(0,X.jsx)(E,{className:`min-w-0 flex-1`,mono:!0,"aria-label":n(`providers.headerValue`),placeholder:`value`,value:a,onChange:e=>r(o,[i,e.target.value])}),(0,X.jsx)(z,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(je,{className:`size-3.5`}),"aria-label":n(`common.delete`),onClick:()=>t(e.filter((e,t)=>t!==o))})]},o)),(0,X.jsx)(`div`,{children:(0,X.jsx)(z,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(qe,{className:`size-3.5`}),onClick:()=>t([...e,[``,``]]),children:n(`providers.addHeader`)})})]})}function ar({open:e,onOpenChange:t,onCreated:n}){let{t:r}=T(),{toast:i}=Se(),a=re(),o=y(),s=D(),c=te(),l=(0,J.useMemo)(()=>new Set((c.data??[]).filter(e=>e.authScheme===`oauth-subscription`&&e.templateId).map(e=>e.templateId)),[c.data]),u=Me(),[d,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(``),[b,x]=(0,J.useState)(``),[S,w]=(0,J.useState)(``),[ee,O]=(0,J.useState)(``),[k,A]=(0,J.useState)(`bearer`),[M,N]=(0,J.useState)([]),[F,I]=(0,J.useState)([]),[R,ie]=(0,J.useState)([]),[B,ae]=(0,J.useState)(``),[oe,U]=(0,J.useState)(1),[se,ce]=(0,J.useState)(``),[W,le]=(0,J.useState)(``);(0,J.useEffect)(()=>{e||(m(null),g(null),f(``),v(``),x(``),w(``),O(``))},[e]);let ue=(0,J.useMemo)(()=>{let e=d.trim().toLowerCase(),t=(a.data??[]).filter(t=>!e||t.name.toLowerCase().includes(e)||t.id.includes(e));return Yn.map(e=>({category:e,items:t.filter(t=>t.category===e)})).filter(e=>e.items.length)},[a.data,d]),de=(0,J.useMemo)(()=>{let e=d.trim().toLowerCase();return(c.data??[]).filter(t=>t.authScheme===`plugin`&&!t.settings.plugin?.absent&&(!e||t.name.toLowerCase().includes(e)||t.id.includes(e)))},[c.data,d]),fe=e=>{m(e),w(``),ae(``),ce(``),le(``),e===`custom`?(v(``),O(``),A(`bearer`),N([{protocol:`openai-chat`,baseUrl:``}]),I([`openai-chat`]),ie([]),U(1)):(v(e.name),O(e.priceKey??e.id),A(e.auth.scheme),N(e.endpoints.map(e=>({...e}))),I([...e.preferredUpstreamProtocols]),ie(Object.entries(e.defaultHeaders??{})),U(e.defaultPriceMultiplier??1))},pe=e=>{I(t=>tr(t,M,e)),N(e)},G=p&&p!==`custom`?p:null,me=G?.authScheme===`oauth-subscription`,he=W.split(er).map(e=>e.trim()).filter(Boolean),ge=(G?.keyAlternatives??[]).flatMap(e=>(a.data??[]).filter(t=>t.id===e)),_e=()=>{let e=p===`custom`;s.mutate({templateId:e?null:p.id,variantId:S||null,name:_.trim()||null,apiKey:b.trim()||null,priceKey:ee,...me?{}:{endpoints:M.map(e=>({...e,baseUrl:e.baseUrl.trim()})),authScheme:k,preferredUpstreamProtocols:F.filter(e=>M.some(t=>t.protocol===e)),extraHeaders:Object.fromEntries(R.filter(([e])=>e.trim()).map(([e,t])=>[e.trim(),t])),httpProxy:B.trim()||null,priceMultiplier:oe,notes:se.trim()||null,...he.length>0?{models:he}:{}}},{onSuccess:e=>{t(!1),i(r(`providers.created`,{name:e.name}),`success`),n(e)},onError:e=>i(K(e),`error`)})},ve=()=>{if(h===`custom`)fe(`custom`);else if(h?.startsWith(Jn)){let e=de.find(e=>Jn+e.id===h);e&&(t(!1),n(e))}else{let e=(a.data??[]).find(e=>e.id===h);e&&!l.has(e.id)&&fe(e)}},be=me||M.length>0&&M.every(e=>/^https?:\/\//.test(e.baseUrl.trim())),xe=p!==null&&be&&(p===`custom`?_.trim()!==``:!G.requiresApiKey||k===`none`||b.trim()!==``);return(0,X.jsxs)(ye,{open:e,onOpenChange:t,width:640,title:r(p?`providers.addTitleDetails`:`providers.addTitle`),description:p?G?G.name:r(`providers.custom`):r(`providers.addDetail`),footer:p?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{className:`mr-auto`,variant:`plain`,onClick:()=>m(null),children:r(`common.back`)}),(0,X.jsx)(z,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,X.jsx)(z,{variant:`primary`,disabled:!xe,loading:s.isPending,onClick:_e,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:!h,onClick:ve,children:r(`common.continue`)})]}),children:[(0,X.jsx)(Yt,{className:`mb-6`,label:r(`providers.addTitle`),current:+!!p,steps:[{id:`template`,label:r(`providers.step.template`)},{id:`details`,label:r(`providers.step.details`)}]}),p?(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(P,{label:r(`providers.name`),children:(0,X.jsx)(E,{value:_,onChange:e=>v(e.target.value)})}),G?.variants&&G.variants.length>0&&(0,X.jsx)(P,{label:r(`providers.variant`),children:(0,X.jsx)(q,{value:S,onChange:e=>{w(e);let t=G.variants?.find(t=>t.id===e);O(t?.priceKey??G.priceKey??G.id),pe((t?.endpointsOverride??G.endpoints).map(e=>({...e})))},options:[{value:``,label:r(`providers.variantDefault`)},...G.variants.map(e=>({value:e.id,label:e.name}))]})}),p===`custom`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(nr,{label:r(`providers.section.endpoints`),hint:r(`providers.baseUrlHint`),children:(0,X.jsx)(rr,{value:M,onChange:pe})}),(0,X.jsx)(P,{label:r(`providers.authScheme`),children:(0,X.jsx)(q,{value:k,onChange:A,options:Vn})})]}),me?(0,X.jsx)(V,{tone:`info`,title:r(`providers.subscriptionWizardHint`),children:r(`providers.subscriptionWizardDetail`)}):(0,X.jsxs)(`div`,{className:`font-mono`,children:[(0,X.jsx)(He,{label:r(`providers.apiKey`),description:r(`providers.apiKeyHint`),autoComplete:`off`,placeholder:`sk-…`,value:b,onChange:e=>x(e.target.value)}),G?.apiKeyUrl&&(0,X.jsx)(`a`,{className:`mt-2 inline-block font-sans text-[12px] text-[var(--accent)]`,href:G.apiKeyUrl,target:`_blank`,rel:`noreferrer`,children:r(`providers.getKey`)})]}),G&&ge.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,X.jsx)(`span`,{children:r(`providers.keyAlternative.wizard`,{name:G.name,alt:ge.map(e=>e.name).join(` / `)})}),ge.map(e=>(0,X.jsx)(z,{size:`sm`,variant:`plain`,onClick:()=>{g(e.id),fe(e)},children:r(`providers.keyAlternative.pick`,{alt:e.name})},e.id))]}),(0,X.jsx)(P,{label:r(`providers.priceKey`),hint:r(`providers.priceKeyHint`),children:(0,X.jsx)(q,{value:ee,onChange:O,options:[{value:``,label:r(`providers.priceKeyNone`)},...(o.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey}))]})}),!me&&(0,X.jsx)(L,{title:r(`providers.moreOptions`),children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[G&&(0,X.jsx)(nr,{label:r(`providers.section.endpoints`),hint:r(`providers.endpointsFooter`),children:(0,X.jsx)(rr,{value:M,onChange:pe})}),new Set(M.map(e=>e.protocol)).size>1&&(0,X.jsx)(nr,{label:r(`providers.preferred`),hint:r(`providers.preferredHint`),children:(0,X.jsx)(We,{label:r(`providers.preferred`),options:Bn.filter(e=>M.some(t=>t.protocol===e.value)).map(e=>{let t=F.indexOf(e.value);return{value:e.value,label:t>=0?`${t+1}. ${e.label}`:e.label}}),value:F,onValueChange:e=>{let t=F.filter(t=>e.includes(t)),n=e.filter(e=>!t.includes(e));I([...t,...n])}})}),G&&(0,X.jsx)(P,{label:r(`providers.authScheme`),children:(0,X.jsx)(q,{value:k,onChange:A,options:Vn})}),(0,X.jsx)(nr,{label:r(`providers.headers`),children:(0,X.jsx)(ir,{value:R,onChange:ie})}),(0,X.jsx)(P,{label:r(`providers.proxy`),hint:r(`providers.proxyHint`),children:(0,X.jsx)(E,{mono:!0,placeholder:`http://127.0.0.1:7890`,value:B,onChange:e=>ae(e.target.value)})}),(0,X.jsx)(nr,{label:r(`providers.multiplier`),hint:r(`providers.multiplierHint`),children:(0,X.jsx)(ne,{className:`w-28`,label:r(`providers.multiplier`),step:.01,min:0,value:oe,onChange:e=>U(e??1)})}),(0,X.jsx)(P,{label:r(`providers.initialModels`),hint:G?r(`providers.initialModelsTemplateHint`,{count:G.models.length}):r(`providers.initialModelsCustomHint`),children:(0,X.jsx)(C,{rows:3,mono:!0,value:W,onChange:e=>le(e.target.value)})}),(0,X.jsx)(P,{label:r(`providers.notes`),children:(0,X.jsx)(E,{value:se,onChange:e=>ce(e.target.value)})}),(0,X.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`providers.moreOptionsDetail`)})]})}),G&&G.models.length>0&&he.length===0&&(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`providers.templateModels`,{count:G.models.length})})]}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(j,{value:d,onChange:f,placeholder:r(`providers.searchTemplates`)}),a.isLoading&&(0,X.jsx)(H,{lines:4}),a.isError&&(0,X.jsx)(V,{tone:`danger`,title:r(`common.error`),children:K(a.error)}),ue.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)(ke,{name:`provider-template`,"aria-label":r(`providers.category.${e.category}`),density:`compact`,minColumnWidth:168,value:e.items.some(e=>e.id===h)?h:null,onValueChange:g,options:e.items.map(e=>{let t=[...new Set(e.endpoints.map(e=>e.protocol))],[n,i]=$n(e.name);return{value:e.id,label:(0,X.jsx)(`span`,{title:e.name,children:n}),description:(0,X.jsx)(`span`,{title:t.map(Zn).join(` · `),children:i??t.map(e=>Xn[e]).join(` · `)}),icon:(0,X.jsx)(Ke,{name:e.name,icon:e.icon,colorKey:e.id,size:28}),disabled:l.has(e.id),disabledReason:Qn(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`)}),de.length>0?(0,X.jsx)(ke,{name:`provider-template-plugin`,"aria-label":r(`providers.category.plugin`),density:`compact`,minColumnWidth:168,value:h?.startsWith(Jn)?h:null,onValueChange:g,options:de.map(e=>({value:Jn+e.id,label:Qn(e.name),description:Qn(r(`providers.pluginProvided`)),icon:(0,X.jsx)(Ke,{name:e.name,icon:e.icon,colorKey:e.id,size:28})}))}):(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-[var(--radius-md)] border border-dashed border-[var(--border)] px-3 py-2.5`,children:[(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-[12px] text-[var(--text-secondary)]`,children:r(`providers.pluginHint`)}),(0,X.jsx)(z,{size:`sm`,onClick:()=>{t(!1),u(`/plugins/market`)},children:r(`plugins.browseMarket`)})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:r(`providers.custom`)}),(0,X.jsx)(ke,{name:`provider-template-custom`,"aria-label":r(`providers.custom`),layout:`list`,density:`compact`,value:h===`custom`?`custom`:null,onValueChange:g,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)(qe,{className:`size-4`})})}]})]})]})]})}export{yn as a,pn as c,On as i,$e as l,Bn as n,vn as o,zn as r,gn as s,Vn as t};
@@ -1,2 +0,0 @@
1
- import{An as e,Ar as t,Bi as n,Bt as r,Ci as i,Cr as a,Di as o,E as s,En as c,Et as l,Fi as u,Ft as d,Gi as f,H as p,Hi as m,It as h,La as g,Lt as _,Ma as v,Na as y,Ni as b,Pa as x,Pi as S,Pr as C,Qr as w,Qt as T,Ti as ee,Ui as te,Vi as E,W as ne,Wt as D,Xr as re,_ as ie,_i as O,bi as ae,ci as oe,ct as k,d as A,dn as se,ei as ce,gt as j,hi as le,ht as ue,i as de,ji as fe,ki as pe,kr as me,l as M,lr as he,m as N,n as P,nn as ge,o as _e,oi as ve,or as F,p as ye,r as I,rn as be,s as xe,si as Se,t as Ce,u as L,un as we,v as R,wi as z,xi as Te,xt as B,y as V,zt as H}from"./alert-DRuYOIBF.js";import{B as Ee,F as De,I as Oe,L as ke,R as Ae,a as U,gt as W,i as je,n as G,o as K,r as q,vt as J,z as Me}from"./overlays-CHP5oojo.js";import{t as Ne}from"./TrayPanelView-BKhhqBGh.js";import{t as Pe}from"./download-BGSlqgxA.js";import{t as Fe}from"./ellipsis-COWYoRP4.js";import{t as Ie}from"./external-link-OKfamryM.js";import{n as Le,t as Re}from"./radio-cards-BXMylVDk.js";import{t as ze}from"./folder-open-BWX9PzRK.js";import{t as Be}from"./log-out-BrzYb7oI.js";import{t as Ve}from"./minus-CKLCHvmT.js";import{t as He}from"./pencil-DkOcGe5U.js";import{t as Ue}from"./rotate-ccw-CkH5KeQH.js";import{$ as We,C as Ge,E as Ke,N as qe,Q as Je,R as Ye,T as Xe,V as Ze,h as Qe,n as $e,nt as et,s as tt,t as nt,w as rt,z as it}from"./index-DorAVedK.js";var at={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};at.node;var ot=B(at),st={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};st.node;var ct=B(st),lt={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};lt.node;var ut=B(lt),dt={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};dt.node;var ft=B(dt),pt={name:`panel-top`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};pt.node;var mt=B(pt),ht={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};ht.node;var gt=B(ht),_t={name:`webhook`,size:24,node:[[`path`,{d:`M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2`,key:`q3hayz`}],[`path`,{d:`m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06`,key:`1go1hn`}],[`path`,{d:`m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8`,key:`qlwsc0`}]]};_t.node;var vt=B(_t),Y=g(x(),1),X=y(),yt=`https://astra-gate.si/docs/guide/remote-access`,bt=`astra.remote.acknowledged`;function xt(e,t){return e.mode===`named`&&!e.hasToken?t(`settings.remote.block.token`):e.mode===`named`&&!e.hostname?t(`settings.remote.block.hostname`):e.allowAdmin&&!e.checks.passwordSet?t(`settings.remote.block.password`):e.checks.blocker??null}function St(e,t,n){return/can no longer be read/i.test(e)?n(`settings.remote.err.tokenLost`):/downloading cloudflared|checksum/i.test(e)?n(`settings.remote.err.download`):/unauthorized|invalid tunnel secret|token.*(invalid|not valid|malformed)/i.test(e)?n(`settings.remote.err.token`):/origin service|origin server/i.test(e)?n(`settings.remote.err.origin`,{origin:t.originUrl}):/429|too many requests|rate.?limit/i.test(e)?n(`settings.remote.err.rate`):/dial|timeout|timed out|no such host|unreachable|quic|edge/i.test(e)?n(`settings.remote.err.network`):n(`settings.remote.err.generic`)}function Ct(){try{return localStorage.getItem(bt)===`1`}catch{return!1}}function wt(){try{localStorage.setItem(bt,`1`)}catch{}}function Tt(){let{t:e}=k(),t=ve(),n=t.data;return n?n.supported?(0,X.jsxs)(`div`,{className:`mx-auto max-w-[680px]`,children:[(0,X.jsx)(Et,{s:n}),(0,X.jsx)(Dt,{s:n}),(0,X.jsx)(Ot,{s:n}),(0,X.jsx)(jt,{s:n}),(0,X.jsx)(_e,{title:n.cloudflared.path&&n.cloudflared.version?e(`settings.remote.logWithVersion`,{version:n.cloudflared.version}):e(`settings.remote.log`),children:n.log.length===0?(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:e(`settings.remote.logEmpty`)}):(0,X.jsx)(`pre`,{className:`max-h-72 overflow-auto font-mono text-[10.5px] leading-relaxed whitespace-pre-wrap text-[var(--text-secondary)] selectable`,children:n.log.join(`
2
- `)})})]}):(0,X.jsx)(`div`,{className:`mx-auto max-w-[680px]`,children:(0,X.jsx)(Ce,{tone:`info`,title:e(`settings.remote.unsupported`),children:e(`settings.remote.unsupportedDetail`)})}):(0,X.jsx)(`div`,{className:`mx-auto max-w-[680px]`,children:t.isError?(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:U(t.error)}):(0,X.jsx)(R,{className:`mx-auto my-8`})})}function Et({s:e}){let{t,locale:n}=k(),{toast:r,confirm:i}=K(),a=w(),o=H(),s=xt(e,t),c=async e=>{await W.copy(e)&&r(t(`common.copied`))},l=async e=>{if(e&&!Ct()){if(!await i({title:t(`settings.remote.enableConfirm`),detail:t(`settings.remote.enableDetail`),confirmLabel:t(`settings.remote.enableAction`)}))return;wt()}(e||!o.data?.remote||await i({title:t(`settings.remote.disableSelfConfirm`),detail:t(`settings.remote.disableSelfDetail`),confirmLabel:t(`settings.remote.disableAction`),destructive:!0}))&&a.mutate(e,{onError:e=>r(U(e),`error`)})},u=e.state===`connected`?`green`:e.state===`off`?`neutral`:`orange`,d=e.connectedAt?Date.now()-new Date(e.connectedAt).getTime():null,f=e.state===`connected`&&d!==null?d<6e4?t(`settings.remote.connectedJustNow`):t(`settings.remote.connectedFor`,{duration:ne(d,n)}):e.state===`downloading`&&e.cloudflared.source?t(`settings.remote.state.downloadingFrom`,{source:e.cloudflared.source}):t(`settings.remote.state.${e.state}`),m=e.cloudflared,h=m.downloading||m.path?null:m.asset?t(`settings.remote.cloudflaredMissing`,{version:m.version??``}):t(`settings.remote.cloudflaredUnsupported`),g=e.enabled?e.error??m.error??null:null,_=g!==null&&(e.state!==`connected`||/origin service|origin server/i.test(g)),v=e.publicUrl;return(0,X.jsxs)(L,{title:t(`settings.remote.status`),footer:t(`settings.remote.statusFooter`),children:[(0,X.jsx)(N,{label:t(`settings.remote.enable`),detail:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:e.connectedAt?p(e.connectedAt,n):void 0,children:[(0,X.jsx)(xe,{tone:u}),f,m.downloading&&m.progress!=null&&(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(m.progress*100),`%`]})]}),children:(0,X.jsx)(V,{checked:e.enabled,label:t(`settings.remote.enable`),disabled:a.isPending||!e.enabled&&s!==null,onChange:e=>void l(e)})}),!e.enabled&&s&&(0,X.jsx)(`p`,{className:`px-4 py-2 text-[12px] text-[var(--warning)]`,children:s}),!e.enabled&&!s&&h&&(0,X.jsx)(`p`,{className:`px-4 py-2 text-[12px] text-[var(--text-muted)]`,children:h}),e.enabled&&v&&(0,X.jsxs)(N,{label:t(`settings.remote.publicUrl`),detail:(0,X.jsx)(`span`,{className:`font-mono selectable`,children:`${v}/v1`}),children:[(0,X.jsx)(G,{label:t(`settings.remote.copyMenu`),icon:(0,X.jsx)(j,{className:`size-3.5`}),iconOnly:!0,items:[{id:`openai`,label:t(`settings.remote.copy.openai`),onSelect:()=>void c(`${v}/v1`)},{id:`anthropic`,label:t(`settings.remote.copy.anthropic`),onSelect:()=>void c(v)},{id:`key`,label:t(`settings.remote.copy.key`),onSelect:()=>void c(`${v}/key`),separatorBefore:!0}]}),(0,X.jsx)(I,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(Ie,{className:`size-3.5`}),"aria-label":t(`settings.remote.openPage`),title:t(`settings.remote.openPage`),onClick:()=>window.open(v,`_blank`,`noopener`)})]}),e.enabled&&v&&(0,X.jsx)(`p`,{className:`px-4 py-2 text-[11px] text-[var(--text-muted)]`,children:t(`settings.remote.publicUrlHint`)}),_&&(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(Ce,{tone:e.state===`connected`?`warning`:`danger`,title:St(g,e,t),children:g})})]})}function Dt({s:e}){let{t}=k(),{toast:n,confirm:r}=K(),i=ae(),[a,o]=(0,Y.useState)({token:``,hostname:e.hostname??``});(0,Y.useEffect)(()=>o(t=>({...t,hostname:e.hostname??``})),[e.hostname]);let s=async e=>{await W.copy(e)&&n(t(`common.copied`))},c=async a=>{if(e.enabled){let n=a===`named`&&(!e.hasToken||!e.hostname);if(!await r({title:t(`settings.remote.modeSwitchConfirm`),detail:t(n?`settings.remote.modeSwitchStopDetail`:`settings.remote.modeSwitchDetail`),confirmLabel:t(`settings.remote.modeSwitchAction`),destructive:n}))return}i.mutate({mode:a},{onError:e=>n(U(e),`error`)})},l=()=>i.mutate({hostname:a.hostname.trim()||null,...a.token.trim()?{token:a.token.trim()}:{}},{onSuccess:e=>{n(e.enabled?t(`settings.remote.savedRestart`):t(`settings.remote.saved`)),o(e=>({...e,token:``}))},onError:e=>n(U(e),`error`)}),u=a.token.trim()!==``||a.hostname.trim()!==(e.hostname??``);return(0,X.jsxs)(L,{title:t(`settings.remote.mode`),footer:e.mode===`named`?t(`settings.remote.namedFooter`):void 0,children:[(0,X.jsx)(N,{label:t(`settings.remote.modeLabel`),detail:t(`settings.remote.mode.${e.mode}.hint`),children:(0,X.jsx)(ie,{ariaLabel:t(`settings.remote.modeLabel`),value:e.mode,onChange:e=>void c(e),items:[{value:`quick`,label:t(`settings.remote.mode.quick`)},{value:`named`,label:t(`settings.remote.mode.named`)}]})}),e.mode===`quick`?(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(Ce,{tone:`warning`,title:t(`settings.remote.quickWarning`)})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:t(`settings.remote.token`),detail:e.hasToken?t(`settings.remote.tokenSaved`):t(`settings.remote.tokenHint`),children:(0,X.jsx)(A,{className:`w-64`,type:`password`,autoComplete:`off`,mono:!0,"aria-label":t(`settings.remote.token`),placeholder:e.hasToken?`••••••••`:`eyJhIjoi…`,value:a.token,onChange:e=>o({...a,token:e.target.value})})}),(0,X.jsx)(N,{label:t(`settings.remote.hostname`),detail:t(`settings.remote.hostnameHint`),children:(0,X.jsx)(A,{className:`w-64`,mono:!0,"aria-label":t(`settings.remote.hostname`),placeholder:`astra.example.com`,value:a.hostname,onChange:e=>o({...a,hostname:e.target.value})})}),(0,X.jsxs)(N,{label:t(`settings.remote.origin`),detail:t(`settings.remote.originHint`),children:[(0,X.jsx)(`span`,{className:`font-mono text-[12px] selectable`,children:e.originUrl}),(0,X.jsx)(I,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(j,{className:`size-3.5`}),"aria-label":t(`common.copy`),onClick:()=>void s(e.originUrl)})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2`,children:[(0,X.jsx)(I,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(ut,{className:`size-3.5`}),onClick:()=>window.open(yt,`_blank`,`noopener`),children:t(`settings.remote.guide`)}),(0,X.jsx)(I,{size:`sm`,disabled:!u||i.isPending,onClick:l,children:t(`common.save`)})]})]})]})}function Ot({s:e}){let{t}=k(),{toast:n,confirm:r}=K(),i=ae(),a=H(),o=async e=>{(!e||await r({title:t(`settings.remote.adminConfirm`),detail:t(`settings.remote.adminDetail`),confirmLabel:t(`settings.remote.adminAction`),destructive:!0}))&&(e||!a.data?.remote||await r({title:t(`settings.remote.adminOffSelfConfirm`),detail:t(`settings.remote.adminOffSelfDetail`),confirmLabel:t(`settings.remote.disableAction`),destructive:!0}))&&i.mutate({allowAdmin:e},{onError:e=>n(U(e),`error`)})};return(0,X.jsxs)(L,{title:t(`settings.remote.scope`),footer:t(`settings.remote.scopeFooter`),children:[(0,X.jsx)(N,{label:t(`settings.remote.scope.gateway`),detail:t(`settings.remote.scope.gatewayHint`),children:(0,X.jsx)(P,{tone:`green`,children:t(`settings.remote.scope.gatewayBadge`)})}),(0,X.jsx)(N,{label:t(`settings.remote.scope.admin`),detail:e.checks.passwordSet?t(`settings.remote.scope.adminHint`):t(`settings.remote.block.password`),children:(0,X.jsx)(V,{checked:e.allowAdmin,label:t(`settings.remote.scope.admin`),disabled:i.isPending||!e.allowAdmin&&!e.checks.passwordSet,onChange:e=>void o(e)})}),(0,X.jsx)(kt,{passwordSet:e.checks.passwordSet})]})}function kt({passwordSet:e}){let{t}=k(),{toast:n}=K(),r=H(),i=me(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(``);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:t(`settings.remote.password`),detail:t(e?`settings.remote.passwordSet`:`settings.remote.passwordMissing`),children:!a&&!r.data?.required&&(0,X.jsx)(I,{size:`sm`,onClick:()=>o(!0),children:t(e?`settings.remote.passwordChange`:`settings.remote.passwordSetAction`)})}),a&&(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 py-2`,children:[(0,X.jsx)(A,{className:`w-64`,type:`password`,autoComplete:`new-password`,autoFocus:!0,"aria-label":t(`settings.remote.passwordNew`),placeholder:t(`settings.remote.passwordNew`),value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(I,{size:`sm`,variant:`plain`,onClick:()=>o(!1),children:t(`common.cancel`)}),(0,X.jsx)(I,{size:`sm`,variant:`primary`,disabled:s.length<8,loading:i.isPending,onClick:()=>i.mutate(s,{onSuccess:()=>{n(t(`settings.remote.passwordSaved`)),o(!1),c(``)},onError:e=>n(U(e),`error`)}),children:t(`common.save`)})]})]})}var At=[`auto`,`github`,`astra`,`custom`];function jt({s:e}){let{t}=k(),{toast:n}=K(),r=ae(),i=se(),a=H(),o=e.cloudflared,[s,c]=(0,Y.useState)(e.download.downloadBaseUrl??``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(``);(0,Y.useEffect)(()=>c(e.download.downloadBaseUrl??``),[e.download.downloadBaseUrl]);let[p,m]=(0,Y.useState)(e.download.downloadSource);(0,Y.useEffect)(()=>m(e.download.downloadSource),[e.download.downloadSource]);let h=(e,i)=>r.mutate(e,{onSuccess:()=>{n(t(`settings.remote.cf.saved`)),i?.()},onError:e=>n(U(e),`error`)}),g=t=>{m(t),(t!==`custom`||e.download.downloadBaseUrl)&&h({downloadSource:t})},_=()=>i.mutate(void 0,{onSuccess:e=>e.path?f(e.path):n(t(`settings.remote.cf.detectNone`)),onError:e=>n(U(e),`error`)}),v=o.fromEnvironment?t(`settings.remote.cf.fromEnv`):o.installed?o.version?t(`settings.remote.cf.installedProgram`,{version:o.version}):t(`settings.remote.cf.installedUnknown`):o.path?t(`settings.remote.cf.downloaded`,{version:o.version??``}):o.asset?t(`settings.remote.cf.notDownloaded`,{version:o.version??``}):t(`settings.remote.cloudflaredUnsupported`);return(0,X.jsxs)(L,{title:`cloudflared`,footer:t(`settings.remote.cf.footer`),children:[(0,X.jsx)(N,{label:t(`settings.remote.cf.program`),detail:(0,X.jsx)(`span`,{title:o.path??void 0,children:v}),children:(0,X.jsx)(xe,{tone:o.path?`green`:o.asset?`neutral`:`red`})}),!e.download.cloudflaredPath&&!o.fromEnvironment&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:t(`settings.remote.cf.source`),detail:t(`settings.remote.cf.source.${p}.hint`),children:(0,X.jsx)(q,{className:`w-44`,ariaLabel:t(`settings.remote.cf.source`),value:p,onChange:g,options:At.map(e=>({value:e,label:t(`settings.remote.cf.source.${e}`)}))})}),p===`custom`&&(0,X.jsxs)(N,{label:t(`settings.remote.cf.baseUrl`),detail:t(`settings.remote.cf.baseUrlHint`),children:[(0,X.jsx)(A,{className:`w-64`,mono:!0,"aria-label":t(`settings.remote.cf.baseUrl`),placeholder:`https://…/cloudflare/cloudflared/releases/download`,value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(I,{size:`sm`,disabled:!s.trim()||r.isPending||s.trim()===(e.download.downloadBaseUrl??``)&&e.download.downloadSource===`custom`,onClick:()=>h({downloadSource:`custom`,downloadBaseUrl:s.trim()}),children:t(`common.save`)})]})]}),!a.data?.remote&&!o.fromEnvironment&&(0,X.jsx)(N,{label:t(`settings.remote.cf.installed`),detail:e.download.cloudflaredPath?(0,X.jsx)(`span`,{className:`font-mono selectable`,children:e.download.cloudflaredPath}):t(`settings.remote.cf.installedHint`),children:e.download.cloudflaredPath?(0,X.jsx)(I,{size:`sm`,disabled:r.isPending,onClick:()=>h({cloudflaredPath:``}),children:t(`settings.remote.cf.useDownloaded`)}):!l&&(0,X.jsx)(I,{size:`sm`,onClick:()=>{u(!0),_()},children:t(`settings.remote.cf.choose`)})}),l&&!e.download.cloudflaredPath&&(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 py-2`,children:[(0,X.jsx)(A,{className:`w-72`,mono:!0,autoFocus:!0,"aria-label":t(`settings.remote.cf.installedPath`),placeholder:t(`settings.remote.cf.installedPath`),value:d,onChange:e=>f(e.target.value)}),(0,X.jsx)(I,{size:`sm`,variant:`plain`,loading:i.isPending,onClick:_,children:t(`settings.remote.cf.detect`)}),(0,X.jsx)(I,{size:`sm`,variant:`plain`,onClick:()=>u(!1),children:t(`common.cancel`)}),(0,X.jsx)(I,{size:`sm`,variant:`primary`,disabled:!d.trim(),loading:r.isPending,onClick:()=>h({cloudflaredPath:d.trim()},()=>u(!1)),children:t(`settings.remote.cf.use`)})]})]})}var Mt=[`127.0.0.1`,`localhost`,`::1`,`[::1]`],Nt={local:`127.0.0.1`,lan:`0.0.0.0`},Pt=e=>Mt.includes(e)?`local`:`lan`;function Ft(){let{t:e}=k(),{toast:t,confirm:n}=K(),r=v(),i=c(),a=H(),o=oe(),[s,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),f=i.data;if(!f)return(0,X.jsx)(N,{label:e(`settings.listen`),detail:i.isError?U(i.error):void 0,children:i.isPending&&(0,X.jsx)(R,{className:`size-3.5`})});let p=`${f.host}:${f.port}`,m=Pt(f.configuredHost),h=f.configuredHost!==f.host,g=!!a.data?.required,_=async n=>{await W.copy(n)&&t(e(`common.copied`))},y=n=>o.mutate(Nt[n],{onSuccess:n=>n.configuredHost!==n.host&&t(e(`settings.listen.saved`)),onError:e=>t(U(e),`error`)}),b=async t=>{if(t!==m){if(t===`lan`){if(!f.passwordSet){l(!0);return}if(!await n({title:e(`settings.listen.lanConfirm`),detail:e(`settings.listen.lanDetail`),confirmLabel:e(`settings.listen.lanAction`)}))return}y(t)}},x=async()=>{d(!0);let n=await W.restartService();if(d(!1),n){if(!n.ok){t(n.error??e(`common.error`),`error`);return}t(e(`settings.listen.restarted`)),r.invalidateQueries()}},C=f.hostFromEnvironment?e(`settings.listen.env`,{address:p}):g?e(`settings.listen.localOnly`,{address:p}):h?`${e(`settings.listen.pending`,{host:f.configuredHost})}${S?``:` · ${e(`settings.listen.restartHint`)}`}`:p;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:e(`settings.listen`),detail:C,children:!f.hostFromEnvironment&&!g&&(0,X.jsxs)(X.Fragment,{children:[h&&S&&(0,X.jsx)(I,{size:`sm`,loading:u,onClick:()=>void x(),children:e(`settings.listen.restart`)}),(0,X.jsx)(ie,{ariaLabel:e(`settings.listen`),value:m,onChange:e=>void b(e),items:[{value:`local`,label:e(`settings.listen.local`)},{value:`lan`,label:e(`settings.listen.lan`)}]})]})}),f.networkUrls.map(t=>(0,X.jsx)(N,{label:e(`settings.listen.networkUrl`),detail:`${t}/v1`,children:(0,X.jsx)(I,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(j,{className:`size-3.5`}),"aria-label":e(`common.copy`),onClick:()=>void _(`${t}/v1`)})},t)),(m===`lan`||f.networkUrls.length>0)&&(0,X.jsx)(kt,{passwordSet:f.passwordSet}),(0,X.jsx)(It,{open:s,onOpenChange:l,onSaved:()=>y(`lan`)})]})}function It({open:e,onOpenChange:t,onSaved:n}){let{t:r}=k(),{toast:i}=K(),a=me(),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),u=c!==``&&c!==o,d=o.length>=8&&o===c,f=e=>{e||(s(``),l(``)),t(e)},p=()=>{d&&!a.isPending&&a.mutate(o,{onSuccess:()=>{i(r(`settings.remote.passwordSaved`)),f(!1),n()},onError:e=>i(U(e),`error`)})};return(0,X.jsx)(je,{open:e,onOpenChange:f,title:r(`settings.listen.passwordTitle`),description:r(`settings.listen.passwordDetail`),width:420,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{onClick:()=>f(!1),children:r(`common.cancel`)}),(0,X.jsx)(I,{variant:`primary`,disabled:!d,loading:a.isPending,onClick:p,children:r(`settings.listen.passwordAction`)})]}),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,X.jsx)(A,{type:`password`,autoComplete:`new-password`,autoFocus:!0,"aria-label":r(`settings.remote.passwordNew`),placeholder:r(`settings.remote.passwordNew`),value:o,onChange:e=>s(e.target.value)}),(0,X.jsx)(A,{type:`password`,autoComplete:`new-password`,"aria-label":r(`settings.listen.passwordRepeat`),placeholder:r(`settings.listen.passwordRepeat`),invalid:u,value:c,onChange:e=>l(e.target.value)}),u&&(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:r(`settings.listen.passwordMismatch`)}),(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`settings.listen.lanDetail`)}),(0,X.jsx)(`button`,{type:`submit`,hidden:!0})]})})}var Lt=[`generic`,`feishu`,`dingtalk`,`wecom`,`slack`,`discord`],Rt={generic:`https://`,feishu:`https://open.feishu.cn/open-apis/bot/v2/hook/…`,dingtalk:`https://oapi.dingtalk.com/robot/send?access_token=…`,wecom:`https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=…`,slack:`https://hooks.slack.com/services/…`,discord:`https://discord.com/api/webhooks/…`},zt=e=>e===`feishu`||e===`dingtalk`,Bt=(e,t)=>e(`alerts.event.${t}`),Vt=(e,t)=>e(`alerts.event.${t}.hint`);function Ht(){return(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(Ut,{}),(0,X.jsx)(Wt,{}),(0,X.jsx)(Yt,{})]})}function Ut(){let{t:e,locale:t}=k(),n=_(!0);return(0,X.jsxs)(L,{title:e(`alerts.firing`),children:[n.isLoading&&(0,X.jsx)(R,{}),n.data?.length===0&&(0,X.jsx)(N,{label:(0,X.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:e(`alerts.firing.empty`)})}),n.data?.map(n=>(0,X.jsx)(N,{icon:(0,X.jsx)(ot,{className:`size-4 text-[var(--danger)]`}),label:`${Bt(e,n.event)} · ${n.subjectName}`,detail:`${n.ruleName} · ${p(n.changedAt,t)}`},`${n.ruleId}:${n.subjectId}`))]})}function Wt(){let{t:e}=k(),{toast:t,confirm:n}=K(),r=ee(),i=we(),o=re(),s=a(),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null),m=n=>o.mutate(n.id,{onSuccess:n=>n.status===`success`?t(e(`alerts.webhooks.testOk`,{status:n.httpStatus??``}),`success`):t(e(`alerts.webhooks.testFailed`,{error:n.error??n.status}),`error`),onError:e=>t(U(e),`error`)}),h=async r=>{await n({title:e(`alerts.webhooks.resetSecretConfirm`,{name:r.name}),detail:e(`alerts.webhooks.resetSecretDetail`),confirmLabel:e(`alerts.webhooks.resetSecret`),destructive:!0})&&s.mutate(r.id,{onSuccess:e=>p(e.secret??null),onError:e=>t(U(e),`error`)})},g=async r=>{await n({title:e(`alerts.webhooks.deleteConfirm`,{name:r.name}),detail:e(`alerts.webhooks.deleteDetail`),confirmLabel:e(`common.delete`),destructive:!0})&&i.mutate(r.id,{onSuccess:()=>t(e(`alerts.webhooks.deleted`,{name:r.name})),onError:e=>t(U(e),`error`)})};return(0,X.jsxs)(L,{title:e(`alerts.webhooks`),footer:e(`alerts.webhooks.hint`),children:[r.isLoading&&(0,X.jsx)(R,{}),r.data?.length===0&&(0,X.jsx)(N,{label:(0,X.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:e(`alerts.webhooks.empty`)})}),r.data?.map(t=>(0,X.jsxs)(N,{icon:(0,X.jsx)(vt,{className:`size-4 text-[var(--text-muted)]`}),label:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[t.name,!t.enabled&&(0,X.jsx)(P,{tone:`orange`,children:e(`alerts.webhooks.disabledBadge`)}),t.format!==`generic`&&(0,X.jsx)(P,{tone:`accent`,children:e(`alerts.webhooks.format.${t.format}`)}),!t.hasSecret&&(t.format===`generic`||zt(t.format))&&(0,X.jsx)(P,{children:e(`alerts.webhooks.unsigned`)})]}),detail:(0,X.jsx)(`span`,{className:`font-mono selectable`,children:t.url}),children:[(0,X.jsx)(I,{size:`sm`,icon:(0,X.jsx)(Le,{className:`size-3.5`}),loading:o.isPending&&o.variables===t.id,onClick:()=>m(t),children:e(`alerts.webhooks.test`)}),(0,X.jsx)(G,{label:e(`common.more`),icon:(0,X.jsx)(Fe,{className:`size-4`}),items:[{id:`edit`,label:e(`alerts.webhooks.edit`),icon:(0,X.jsx)(He,{className:`size-3.5`}),onSelect:()=>l(t)},{id:`deliveries`,label:e(`alerts.webhooks.deliveries`),icon:(0,X.jsx)(ft,{className:`size-3.5`}),onSelect:()=>d(t)},{id:`secret`,label:e(`alerts.webhooks.resetSecret`),icon:(0,X.jsx)(Ze,{className:`size-3.5`}),onSelect:()=>void h(t)},{id:`delete`,label:e(`common.delete`),icon:(0,X.jsx)(qe,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void g(t)}]})]},t.id)),(0,X.jsx)(`div`,{className:`px-4 py-2`,children:(0,X.jsx)(I,{size:`sm`,icon:(0,X.jsx)(it,{className:`size-3.5`}),onClick:()=>l(`new`),children:e(`alerts.webhooks.add`)})}),(0,X.jsx)(Gt,{hook:c,onClose:()=>l(null),onSecret:p}),(0,X.jsx)(qt,{hook:u,onClose:()=>d(null)}),(0,X.jsx)(Kt,{secret:f,onClose:()=>p(null)})]})}function Gt({hook:e,onClose:t,onSecret:n}){let{t:r}=k(),{toast:i}=K(),a=ge(),o=Te(),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(10),[p,m]=(0,Y.useState)(!0),[h,g]=(0,Y.useState)(!0),[_,v]=(0,Y.useState)(!0),[y,b]=(0,Y.useState)(`generic`),[x,S]=(0,Y.useState)(``),[C,w]=(0,Y.useState)([]),T=e===`new`;return(0,Y.useEffect)(()=>{if(e===null)return;let t=e===`new`?null:e;c(t?.name??``),u(t?.url??``),f(t?.timeoutSec??10),m(t?.useProxy??!0),g(t?.enabled??!0),v(!t||t.hasSecret),b(t?.format??`generic`),S(``),w((t?.headerNames??[]).map(e=>({name:e,value:``,stored:!0})))},[e]),(0,X.jsx)(je,{open:e!==null,onOpenChange:e=>!e&&t(),title:r(T?`alerts.webhooks.add`:`alerts.webhooks.edit`),width:540,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{onClick:t,children:r(`common.cancel`)}),(0,X.jsx)(I,{variant:`primary`,disabled:!s.trim()||!l.trim(),loading:a.isPending||o.isPending,onClick:()=>{let c=Object.fromEntries(C.filter(e=>e.name.trim()).map(e=>[e.name.trim(),e.value])),u={name:s.trim(),url:l.trim(),timeoutSec:d??10,useProxy:p,enabled:h,headers:Object.keys(c).length>0?c:null},f={onError:e=>i(U(e),`error`)},m=!T&&e!==null&&e.format!==y,g=zt(y)?_?x.trim()||void 0:``:void 0;T?a.mutate({...u,format:y,...y===`generic`?{signed:_}:g?{secret:g}:{}},{...f,onSuccess:e=>{t(),e.secret&&n(e.secret)}}):e&&o.mutate({id:e.id,...u,...m?{format:y}:{},...y===`generic`?_||!e.hasSecret||m?{}:{signed:!1}:g===void 0?{}:{secret:g}},{...f,onSuccess:()=>{t(),i(r(`common.saved`),`success`)}})},children:r(`common.save`)})]}),children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(M,{label:r(`alerts.webhooks.name`),children:(0,X.jsx)(A,{value:s,maxLength:64,onChange:e=>c(e.target.value)})}),(0,X.jsx)(M,{label:r(`alerts.webhooks.format`),hint:r(`alerts.webhooks.format.${y}.hint`),children:(0,X.jsx)(q,{ariaLabel:r(`alerts.webhooks.format`),value:y,onChange:t=>{b(t),v(t===`generic`||e!==`new`&&e!==null&&e.format===t&&e.hasSecret||zt(t))},options:Lt.map(e=>({value:e,label:r(`alerts.webhooks.format.${e}`)}))})}),(0,X.jsx)(M,{label:r(`alerts.webhooks.url`),children:(0,X.jsx)(A,{mono:!0,value:l,placeholder:Rt[y],onChange:e=>u(e.target.value)})}),zt(y)&&_&&(0,X.jsx)(M,{label:r(`alerts.webhooks.botSecret`),hint:r(`alerts.webhooks.botSecretHint`),children:(0,X.jsx)(A,{mono:!0,type:`password`,autoComplete:`off`,value:x,placeholder:e!==`new`&&e!==null&&e.format===y&&e.hasSecret?r(`alerts.webhooks.headerKept`):`SEC…`,onChange:e=>S(e.target.value)})}),(0,X.jsx)(M,{label:r(`alerts.webhooks.timeout`),children:(0,X.jsx)(ye,{value:d,min:1,step:1,label:r(`alerts.webhooks.timeout`),onChange:f})}),(0,X.jsx)(M,{label:r(`alerts.webhooks.headers`),hint:r(`alerts.webhooks.headersHint`),children:(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[C.map((e,t)=>(0,X.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto] items-center gap-2`,children:[(0,X.jsx)(A,{mono:!0,"aria-label":r(`alerts.webhooks.headerName`),placeholder:r(`alerts.webhooks.headerName`),value:e.name,onChange:e=>w(C.map((n,r)=>r===t?{...n,name:e.target.value}:n))}),(0,X.jsx)(A,{mono:!0,"aria-label":r(`alerts.webhooks.headerValue`),placeholder:e.stored?r(`alerts.webhooks.headerKept`):r(`alerts.webhooks.headerValue`),value:e.value,onChange:e=>w(C.map((n,r)=>r===t?{...n,value:e.target.value}:n))}),(0,X.jsx)(I,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(qe,{className:`size-3.5`}),"aria-label":r(`common.delete`),onClick:()=>w(C.filter((e,n)=>n!==t))})]},t)),(0,X.jsx)(`div`,{children:(0,X.jsx)(I,{size:`sm`,icon:(0,X.jsx)(it,{className:`size-3.5`}),onClick:()=>w([...C,{name:``,value:``,stored:!1}]),children:r(`alerts.webhooks.addHeader`)})})]})}),(0,X.jsxs)(`div`,{className:`card divide-y divide-[var(--border)]`,children:[(0,X.jsx)(N,{label:r(`alerts.webhooks.enabled`),children:(0,X.jsx)(V,{checked:h,label:r(`alerts.webhooks.enabled`),onChange:g})}),(0,X.jsx)(N,{label:r(`alerts.webhooks.useProxy`),detail:r(`alerts.webhooks.useProxyHint`),children:(0,X.jsx)(V,{checked:p,label:r(`alerts.webhooks.useProxy`),onChange:m})}),(y===`generic`?T||e!==null&&e.format===`generic`&&e.hasSecret:zt(y))&&(0,X.jsx)(N,{label:r(`alerts.webhooks.signed`),detail:r(y===`generic`?`alerts.webhooks.signedHint`:`alerts.webhooks.botSignedHint`),children:(0,X.jsx)(V,{checked:_,label:r(`alerts.webhooks.signed`),onChange:v})})]})]})})}function Kt({secret:e,onClose:t}){let{t:n}=k(),{toast:r}=K();return(0,X.jsx)(je,{open:e!==null,onOpenChange:e=>!e&&t(),title:n(`alerts.webhooks.secretTitle`),description:n(`alerts.webhooks.secretShown`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{onClick:async()=>e&&await W.copy(e)&&r(n(`common.copied`)),children:n(`common.copy`)}),(0,X.jsx)(I,{variant:`primary`,onClick:t,children:n(`common.done`)})]}),children:(0,X.jsx)(`code`,{className:`block rounded-[var(--radius-control)] bg-[var(--surface-muted)] p-3 font-mono text-[12px] break-all selectable`,children:e})})}function qt({hook:e,onClose:t}){let{t:n,locale:r}=k(),{toast:i}=K(),a=z(e?.id),o=he(),s={success:`green`,pending:`orange`,failed:`red`};return(0,X.jsxs)(je,{open:e!==null,onOpenChange:e=>!e&&t(),title:`${n(`alerts.webhooks.deliveries`)} · ${e?.name??``}`,width:640,children:[a.isLoading&&(0,X.jsx)(R,{lines:4}),a.data?.length===0&&(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`alerts.delivery.empty`)}),(0,X.jsx)(`div`,{className:`grid max-h-[60vh] gap-2 overflow-y-auto`,children:a.data?.map(e=>(0,X.jsxs)(`details`,{className:`rounded-[var(--radius-control)] bg-[var(--surface-muted)] px-3 py-2 text-[12px]`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-default flex-wrap items-center gap-2`,children:[(0,X.jsx)(P,{tone:s[e.status],children:n(`alerts.delivery.status.${e.status}`)}),(0,X.jsx)(`span`,{children:e.event===`test`?n(`alerts.webhooks.test`):Bt(n,e.event)}),(0,X.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:p(e.createdAt,r)}),(0,X.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[e.httpStatus?`HTTP ${e.httpStatus}`:``,` `,e.error&&e.status!==`success`?e.error:``]}),(0,X.jsx)(`span`,{className:`ml-auto text-[var(--text-muted)]`,children:e.status===`pending`&&e.nextAttemptAt?n(`alerts.delivery.next`,{time:p(e.nextAttemptAt,r)}):n(`alerts.delivery.attempts`,{count:e.attempts})})]}),(0,X.jsxs)(`div`,{className:`mt-2 grid gap-2`,children:[(0,X.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:n(`alerts.delivery.payload`)}),(0,X.jsx)(de,{children:JSON.stringify(e.payload,null,2)}),e.responseSnippet&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:n(`alerts.delivery.response`)}),(0,X.jsx)(de,{language:`text`,children:e.responseSnippet})]}),e.status!==`pending`&&(0,X.jsx)(`div`,{children:(0,X.jsx)(I,{size:`sm`,loading:o.isPending&&o.variables===e.id,onClick:()=>o.mutate(e.id,{onSuccess:()=>i(n(`alerts.delivery.redelivered`)),onError:e=>i(U(e),`error`)}),children:n(`alerts.delivery.redeliver`)})})]})]},e.id))})]})}function Jt(e){let t=F(),n=ce(),r=(0,Y.useMemo)(()=>(t.data??[]).filter(e=>e.authScheme===`oauth-subscription`),[t.data]),i=J({queries:r.map(t=>({queryKey:l.providerAccounts(t.id),queryFn:()=>o(`GET`,`/api/providers/${pe(t.id)}/accounts`),enabled:e===`account`}))});return e===`provider`?(t.data??[]).filter(e=>e.authScheme!==`oauth-subscription`&&e.authScheme!==`plugin`).map(e=>({value:e.id,label:e.name})):e===`token`?(n.data??[]).map(e=>({value:e.id,label:e.name})):e===`account`?r.flatMap((e,t)=>(i[t]?.data??[]).map(t=>({value:t.id,label:`${e.name} / ${t.displayName||t.id}`}))):[]}function Yt(){let{t:e}=k(),{toast:t,confirm:n}=K(),r=h(),i=ee(),a=Se(),o=be(),[s,c]=(0,Y.useState)(null),l=e=>i.data?.find(t=>t.id===e)?.name??e,u=async r=>{await n({title:e(`alerts.rules.deleteConfirm`,{name:r.name}),confirmLabel:e(`common.delete`),destructive:!0})&&o.mutate(r.id,{onSuccess:()=>t(e(`alerts.rules.deleted`,{name:r.name})),onError:e=>t(U(e),`error`)})};return(0,X.jsxs)(L,{title:e(`alerts.rules`),footer:e(`alerts.rules.hint`),children:[r.isLoading&&(0,X.jsx)(R,{}),r.data?.length===0&&(0,X.jsx)(N,{label:(0,X.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:e(`alerts.rules.empty`)})}),r.data?.map(n=>(0,X.jsxs)(N,{icon:(0,X.jsx)(ot,{className:`size-4 text-[var(--text-muted)]`}),label:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[n.name,n.firing>0&&(0,X.jsx)(P,{tone:`red`,children:e(`alerts.rules.firing`,{count:n.firing})}),!n.enabled&&(0,X.jsx)(P,{tone:`orange`,children:e(`alerts.rules.disabledBadge`)})]}),detail:`${Bt(e,n.event)} → ${n.webhookIds.map(l).join(`, `)||`—`}`,children:[(0,X.jsx)(V,{checked:n.enabled,label:e(`alerts.rules.enabled`),onChange:e=>a.mutate({id:n.id,enabled:e},{onError:e=>t(U(e),`error`)})}),(0,X.jsx)(G,{label:e(`common.more`),icon:(0,X.jsx)(Fe,{className:`size-4`}),items:[{id:`edit`,label:e(`alerts.rules.edit`),icon:(0,X.jsx)(He,{className:`size-3.5`}),onSelect:()=>c(n)},{id:`delete`,label:e(`common.delete`),icon:(0,X.jsx)(qe,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void u(n)}]})]},n.id)),(0,X.jsx)(`div`,{className:`px-4 py-2`,children:(0,X.jsx)(I,{size:`sm`,icon:(0,X.jsx)(it,{className:`size-3.5`}),onClick:()=>c(`new`),children:e(`alerts.rules.add`)})}),(0,X.jsx)(Zt,{rule:s,onClose:()=>c(null)})]})}function Xt(e){let t={};for(let n of e?.params??[])t[n.name]=n.kind===`choice`?n.choices?.[0]??``:n.kind===`number`?n.default??null:``;return t}function Zt({rule:e,onClose:t}){let{t:n}=k(),{toast:r}=K(),i=d(),a=ee(),o=T(),s=Se(),[c,l]=(0,Y.useState)(``),[u,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)({}),[h,g]=(0,Y.useState)(`all`),[_,v]=(0,Y.useState)([]),[y,b]=(0,Y.useState)([]),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null),[te,E]=(0,Y.useState)(60),ne=i.data?.find(e=>e.id===u),D=Jt(ne?.subjectType),re=e===`new`;return(0,Y.useEffect)(()=>{if(e===null)return;let t=e===`new`?null:e,n=i.data?.[0];l(t?.name??``),f(t?.event??n?.id??``),m(t?{...Xt(i.data?.find(e=>e.id===t.event)),...t.condition}:Xt(n)),g(t?.subjects?`only`:`all`),v(t?.subjects??[]),b(t?.webhookIds??(a.data??[]).map(e=>e.id)),S(t?.notifyResolved??!1),w(t?.repeatMinutes??null),E(t?.cooldownMinutes??60)},[e]),(0,X.jsx)(je,{open:e!==null,onOpenChange:e=>!e&&t(),title:n(re?`alerts.rules.add`:`alerts.rules.edit`),width:560,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{onClick:t,children:n(`common.cancel`)}),(0,X.jsx)(I,{variant:`primary`,disabled:!c.trim()||!u,loading:o.isPending||s.isPending,onClick:()=>{let i=Object.fromEntries(Object.entries(p).filter(([,e])=>e!==null&&e!==``)),a={name:c.trim(),event:u,condition:i,subjects:h===`all`?null:_,webhookIds:y,notifyResolved:x,repeatMinutes:C&&C>0?Math.floor(C):null,cooldownMinutes:Math.max(0,Math.floor(te??0))},l={onSuccess:()=>{t(),r(n(`common.saved`),`success`)},onError:e=>r(U(e),`error`)};re?o.mutate(a,l):e&&s.mutate({id:e.id,...a},l)},children:n(`common.save`)})]}),children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(M,{label:n(`alerts.rules.name`),children:(0,X.jsx)(A,{value:c,maxLength:64,onChange:e=>l(e.target.value)})}),(0,X.jsx)(M,{label:n(`alerts.rules.event`),hint:u?Vt(n,u):void 0,children:(0,X.jsx)(q,{ariaLabel:n(`alerts.rules.event`),value:u,onChange:e=>{f(e),m(Xt(i.data?.find(t=>t.id===e))),v([])},options:(i.data??[]).map(e=>({value:e.id,label:Bt(n,e.id)}))})}),ne?.params.map(e=>(0,X.jsx)(M,{label:n(`alerts.param.${e.name}`),children:e.kind===`number`?(0,X.jsx)(ye,{value:typeof p[e.name]==`number`?p[e.name]:null,min:0,label:n(`alerts.param.${e.name}`),onChange:t=>m({...p,[e.name]:t})}):e.kind===`choice`?(0,X.jsx)(q,{ariaLabel:n(`alerts.param.${e.name}`),value:String(p[e.name]??``),onChange:t=>m({...p,[e.name]:t}),options:(e.choices??[]).map(t=>({value:t,label:n(`alerts.choice.${e.name}.${t}`)}))}):(0,X.jsx)(A,{mono:!0,value:String(p[e.name]??``),"aria-label":n(`alerts.param.${e.name}`),placeholder:n(`alerts.param.${e.name}.placeholder`),onChange:t=>m({...p,[e.name]:t.target.value})})},e.name)),ne&&(0,X.jsx)(M,{label:`${n(`alerts.rules.subjects`)} · ${n(`alerts.subject.${ne.subjectType}`)}`,children:(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(ie,{ariaLabel:n(`alerts.rules.subjects`),value:h,onChange:g,items:[{value:`all`,label:n(`alerts.rules.subjectsAll`)},{value:`only`,label:n(`alerts.rules.subjectsOnly`)}]}),h===`only`&&(0,X.jsx)(tt,{label:n(`alerts.rules.subjects`),value:_,onValueChange:v,options:[...D,..._.filter(e=>!D.some(t=>t.value===e)).map(e=>({value:e,label:e}))]})]})}),(0,X.jsx)(M,{label:n(`alerts.rules.webhooks`),children:(a.data??[]).length===0?(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`alerts.rules.noWebhooks`)}):(0,X.jsx)(tt,{label:n(`alerts.rules.webhooks`),value:y,onValueChange:b,options:(a.data??[]).map(e=>({value:e.id,label:e.name}))})}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,X.jsx)(M,{label:n(`alerts.rules.repeat`),hint:n(`alerts.rules.repeatHint`),children:(0,X.jsx)(ye,{value:C,min:1,step:1,label:n(`alerts.rules.repeat`),onChange:w})}),(0,X.jsx)(M,{label:n(`alerts.rules.cooldown`),hint:n(`alerts.rules.cooldownHint`),children:(0,X.jsx)(ye,{value:te,min:0,step:1,label:n(`alerts.rules.cooldown`),onChange:E})})]}),(0,X.jsx)(`div`,{className:`card`,children:(0,X.jsx)(N,{label:n(`alerts.rules.notifyResolved`),children:(0,X.jsx)(V,{checked:x,label:n(`alerts.rules.notifyResolved`),onChange:S})})})]})})}function Qt(){let{t:e}=k(),t=r(),n=b()?.loginItem,i=t.data?.mechanism===`launchd`||!!n&&u;return(0,X.jsxs)(L,{title:e(`settings.startup`),footer:i?e(`settings.startup.macFooter`):void 0,children:[n&&(0,X.jsx)($t,{loginItem:n}),(0,X.jsx)(en,{})]})}function $t({loginItem:e}){let{t}=k(),{toast:n}=K(),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{let t=!0;e.get().then(e=>{t&&i(e)});let n=e.onChanged(i);return()=>{t=!1,n()}},[e]),(0,X.jsx)(N,{label:t(`settings.startup.app`),detail:r&&!r.supported?t(`settings.startup.appUnsupported`):t(`settings.startup.appHint`),children:r?(0,X.jsx)(V,{checked:r.enabled,disabled:!r.supported||a,label:t(`settings.startup.app`),onChange:r=>{o(!0),e.set(r).then(e=>{i(e),e.enabled!==r&&n(t(`settings.startup.failed`),`error`)}).catch(e=>n(U(e),`error`)).finally(()=>o(!1))}}):(0,X.jsx)(R,{className:`size-3.5`})})}function en(){let{t:e}=k(),{toast:n}=K(),i=r(),a=t(),o=i.data;if(!o)return(0,X.jsx)(N,{label:e(`settings.startup.service`),detail:i.isError?U(i.error):void 0,children:i.isPending&&(0,X.jsx)(R,{className:`size-3.5`})});let s=!o.supported||o.mechanism===`none`?e(`settings.startup.unsupported.${o.unsupported??`platform`}`):o.canChange?o.enabled&&o.location?e(`settings.startup.entry`,{location:o.location}):e(`settings.startup.service.${o.mechanism}`):e(`settings.startup.localOnly`);return(0,X.jsx)(N,{label:e(`settings.startup.service`),detail:s,children:o.supported&&(0,X.jsx)(V,{checked:o.enabled,disabled:!o.canChange||a.isPending,label:e(`settings.startup.service`),onChange:t=>a.mutate(t,{onSuccess:t=>t.enabled&&n(e(`settings.startup.saved`)),onError:e=>n(U(e),`error`)})})})}var Z={field:`_field_bhhp1_1`,head:`_head_bhhp1_6`,label:`_label_bhhp1_7`,limit:`_limit_bhhp1_9`,control:`_control_bhhp1_14`,step:`_step_bhhp1_22`,icon:`_icon_bhhp1_23`,valueWrap:`_valueWrap_bhhp1_34`,value:`_value_bhhp1_34`,affix:`_affix_bhhp1_38`,char:`_char_bhhp1_39`,number:`_number_bhhp1_42`,display:`_display_bhhp1_43`,mirror:`_mirror_bhhp1_45`,input:`_input_bhhp1_46`,column:`_column_bhhp1_52`,sizer:`_sizer_bhhp1_53`,glyph:`_glyph_bhhp1_54`,symbol:`_symbol_bhhp1_55`,messageSlot:`_messageSlot_bhhp1_57`,hint:`_hint_bhhp1_58`,words:`_words_bhhp1_60`,wordSlot:`_wordSlot_bhhp1_61`,wordSizer:`_wordSizer_bhhp1_62`,word:`_word_bhhp1_60`,srOnly:`_srOnly_bhhp1_64`},{spring:Q,duration:$,blur:tn}=s,nn=[...s.ease.enter],rn=[...s.ease.standard],an=[0,1,2,3,4,5,6,7,8,9],on=6,sn=400,cn=40,ln=240,un=1500,dn=700,fn=700,pn=.22,mn=4,hn=130,gn=(()=>{let e=2*Math.PI/(Q.morph.visualDuration*1.2);return{type:`spring`,stiffness:e*e,damping:2*(1-Q.morph.bounce)*e}})(),_n=e=>(String(e).split(`.`)[1]??``).length,vn=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,`\\$&`),yn=(e,t)=>typeof e==`function`?e(t):e??``,bn=(e,t=10)=>Math.sign(e)*(1-1/(Math.abs(e)*.55/t+1))*t;function xn(e,t){let n=t.formatToParts(e),r=n.reduce((e,t)=>e+(t.type===`integer`?t.value.length:0),0),i=0;return n.flatMap((e,t)=>e.type===`integer`?[...e.value].map(e=>({key:`i${--r}`,digit:Number(e)})):e.type===`fraction`?[...e.value].map(e=>({key:`f${i++}`,digit:Number(e)})):[{key:e.type===`group`?`g${r}`:e.type===`decimal`?`d`:e.type===`minusSign`?`m`:`${e.type}${t}`,text:e.value}])}var Sn={enter:e=>({width:0,scale:.6,opacity:0,y:`${e*.3}em`,filter:`blur(${tn.soft}px)`}),center:{width:`auto`,scale:1,opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`},transition:{width:Q.morph,scale:Q.morph,opacity:Q.morph,y:Q.snappy,filter:{duration:.3,ease:rn}}},exit:e=>({width:0,scale:.6,opacity:0,y:`${e*-.3}em`,filter:`blur(${tn.subtle}px)`,transition:{width:Q.smooth,scale:Q.smooth,y:{duration:$.fast,ease:rn},opacity:{duration:$.instant},filter:{duration:$.instant}}})},Cn=e=>({width:`auto`,scale:1,opacity:e,y:0,filter:`none`}),wn={enter:Cn(0),center:{...Cn(1),transition:{duration:$.instant}},exit:{width:0,opacity:0,transition:{duration:0}}},Tn={enter:Cn(1),center:{...Cn(1),transition:{duration:0}},exit:{width:0,opacity:0,transition:{duration:0}}};function En({position:e,digit:t}){let r=e=>((t-e)%10+15)%10-5,i=et(e,e=>`${r(e)*1.05}em`),a=et(e,e=>Math.max(0,1-Math.abs(r(e))**1.5*1.1)),o=et(e,e=>Math.abs(r(e))>=1?`hidden`:`visible`),s=et(e,e=>{let t=Math.abs(r(e));return t<.02||t>=1?`none`:`blur(${(t*tn.soft*.75).toFixed(2)}px)`});return(0,X.jsx)(n.span,{className:Z.glyph,style:{y:i,opacity:a,filter:s,visibility:o},children:t})}function Dn({digit:e,direction:t,instant:n}){let r=m(),i=te(e),a=(0,Y.useRef)({digit:e,target:e});return(0,Y.useLayoutEffect)(()=>{let o=a.current;if(o.digit===e)return;let s=t>0?(e-o.digit+10)%10:-((o.digit-e+10)%10);Math.abs(s)>5&&(s-=Math.sign(s)*10),o.target+=s,o.digit=e,n||r?i.jump(o.target):E(i,o.target,Q.snappy)},[e,t,n,i,r]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:Z.sizer,children:`0`}),an.map(e=>(0,X.jsx)(En,{position:i,digit:e},e))]})}function On({value:e,format:t,direction:r,instant:i}){let a=m(),o=i?Tn:a?wn:Sn;return(0,X.jsx)(f,{initial:!1,custom:r,children:xn(e,t).map(e=>(0,X.jsx)(n.span,{className:`digit`in e?Z.column:Z.symbol,custom:r,variants:o,initial:`enter`,animate:`center`,exit:`exit`,children:`digit`in e?(0,X.jsx)(Dn,{digit:e.digit,direction:r,instant:i}):e.text},e.key))})}function kn({text:e,direction:t,className:r}){let i=m();return(0,X.jsx)(`span`,{className:r,children:(0,X.jsx)(f,{initial:!1,custom:t,children:[...e].map((e,r)=>(0,X.jsx)(n.span,{className:Z.char,custom:t,variants:i?wn:Sn,initial:`enter`,animate:`center`,exit:`exit`,children:e},`${r}:${e}`))})})}var An=e=>{let t=e?.replace(/[^\d.-]/g,``);return t&&/\d/.test(t)&&Number.isFinite(Number(t))?Number(t):null},jn=(e,t)=>{let n=e.split(` `);return t.split(` `).map((e,t)=>{let r=An(n[t]),i=An(e);return r!==null&&i!==null&&i<r?-1:1})},Mn={enter:e=>({opacity:0,y:`${e*.3}em`,filter:`blur(${tn.soft}px)`}),center:{opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`},transition:{duration:.22,ease:nn,opacity:Q.morph}},exit:e=>({opacity:0,y:`${e*-.3}em`,filter:`blur(${tn.subtle}px)`,transition:{duration:.14,ease:rn}})},Nn={enter:{opacity:0,y:0,filter:`none`},center:{opacity:1,y:0,filter:`none`,transition:{duration:$.instant}},exit:{opacity:0,transition:{duration:0}}};function Pn({word:e,direction:t}){let r=m(),i=(0,Y.useRef)(null),a=te(`auto`),o=(0,Y.useRef)(!1);return(0,Y.useLayoutEffect)(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{!o.current||r?a.jump(e.offsetWidth):E(a,e.offsetWidth,Q.morph),o.current=!0});return t.observe(e),()=>t.disconnect()},[r,a]),(0,X.jsxs)(n.span,{className:Z.wordSlot,style:{width:a},children:[(0,X.jsx)(`span`,{ref:i,className:Z.wordSizer,children:e}),(0,X.jsx)(f,{initial:!1,mode:`popLayout`,custom:t,children:(0,X.jsx)(n.span,{className:Z.word,custom:t,variants:r?Nn:Mn,initial:`enter`,animate:`center`,exit:`exit`,children:e},e)})]})}function Fn({text:e}){let[t,n]=(0,Y.useState)({text:e,directions:[]});t.text!==e&&n({text:e,directions:jn(t.text,e)});let r=t.text===e?t.directions:jn(t.text,e),i=e.split(` `);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:Z.srOnly,children:e}),(0,X.jsx)(`span`,{className:Z.words,"aria-hidden":`true`,children:i.map((e,t)=>(0,X.jsxs)(Y.Fragment,{children:[t>0&&` `,(0,X.jsx)(Pn,{word:e,direction:r[t]??1})]},t))})]})}function In({id:e,text:t,className:n}){return(0,X.jsx)(f,{initial:!1,children:t?(0,X.jsx)(Ln,{id:e,text:t,className:n},`message`):null})}function Ln({id:e,text:t,className:r}){let i=m(),a=(0,Y.useRef)(null),[o,s]=(0,Y.useState)(`auto`);return(0,Y.useLayoutEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(([t])=>s(t.borderBoxSize?.[0]?.blockSize??e.offsetHeight));return t.observe(e),()=>t.disconnect()},[]),(0,X.jsx)(n.span,{className:Z.messageSlot,initial:{height:0,opacity:0},animate:{height:o,opacity:1},exit:{height:0,opacity:0,transition:i?{duration:0}:{height:Q.smooth,opacity:{duration:$.instant}}},transition:i?{duration:0}:{height:Q.smooth,opacity:{duration:$.fast}},children:(0,X.jsx)(n.span,{ref:a,id:e,className:r,initial:!i&&{y:`0.35em`,filter:`blur(${tn.soft}px)`},animate:{y:0,filter:`blur(0px)`},transition:{duration:i?0:$.standard,ease:nn},children:(0,X.jsx)(Fn,{text:t})})})}function Rn({id:e,edge:t,text:r}){let i=m();return(0,X.jsx)(f,{initial:!1,children:t!==0&&(0,X.jsx)(n.span,{id:e,className:Z.limit,initial:i?{opacity:0}:{opacity:0,y:`${t*.45}em`,filter:`blur(${tn.subtle}px)`},animate:{opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`}},exit:{opacity:0,transition:{duration:i?$.instant:$.standard,ease:rn}},transition:i?{duration:$.instant}:{y:Q.snappy,opacity:{duration:$.fast},filter:{duration:$.fast}},children:r},`limit`)})}function zn({toward:e,label:t,disabled:n,controls:r,limit:i,pressed:a,iconRef:o,onPress:s,onRelease:c,onActivate:l}){let u=e>0?it:Ve;return(0,X.jsx)(`button`,{type:`button`,className:Z.step,disabled:n,"aria-controls":r,"aria-label":`${e>0?`Increase`:`Decrease`} ${t}`,"aria-disabled":i||void 0,"data-pressed":a||void 0,onPointerDown:e=>{e.button===0&&s()},onPointerUp:c,onPointerLeave:c,onPointerCancel:c,onMouseDown:e=>e.preventDefault(),onClick:e=>{e.detail===0&&l()},onContextMenu:e=>e.preventDefault(),children:(0,X.jsx)(`span`,{ref:o,className:Z.icon,children:(0,X.jsx)(u,{size:16,strokeWidth:1.75,"aria-hidden":`true`})})})}function Bn({label:e,value:t,defaultValue:r=0,onValueChange:i,min:a=0,max:o=2**53-1,step:s=1,largeStep:c,description:l,disabled:u,id:d,prefix:f,suffix:p,scrub:h=!1,locale:g=`en-US`,formatOptions:_,size:v=`md`,limitHint:y=!0}){let b=m(),x=(0,Y.useId)(),S=d??x,C=l?`${S}-description`:void 0,w=`${S}-limit`,T=s>0?s:1,[ee,ne]=(0,Y.useState)(r),D=t??ee,[re,ie]=(0,Y.useState)(``),[O,ae]=(0,Y.useState)(!1),[oe,k]=(0,Y.useState)(0),[A,se]=(0,Y.useState)(!1),[ce,j]=(0,Y.useState)(``),[le,ue]=(0,Y.useState)(0),[de,fe]=(0,Y.useState)(!1),pe=(0,Y.useRef)(null),me=(0,Y.useRef)(null),M=(0,Y.useRef)(null),he=(0,Y.useRef)(void 0),N=(0,Y.useRef)(void 0),P=(0,Y.useRef)(void 0),ge=(0,Y.useRef)({edge:0,count:0,at:0}),_e=(0,Y.useRef)(null),ve=(0,Y.useRef)(null),F=(0,Y.useRef)(D),ye=(0,Y.useRef)(D),I=(0,Y.useRef)(void 0),be=(0,Y.useRef)(null),xe=(0,Y.useRef)(!1),Se=(0,Y.useRef)(null),Ce=(0,Y.useRef)(!1),L=(0,Y.useRef)(()=>!1),we=te(0),R=te(0),z=te(0),Te=et(()=>R.get()+z.get()),B=Number.isFinite(a)?a:0,V=Math.max(_n(T),_n(B)),H=_?.minimumFractionDigits??V,Ee=Math.max(H,_?.maximumFractionDigits??V),De=_?.useGrouping??!0,Oe=(0,Y.useMemo)(()=>new Intl.NumberFormat(g,{minimumFractionDigits:H,maximumFractionDigits:Ee,useGrouping:De,numberingSystem:`latn`}),[g,H,Ee,De]),ke=(0,Y.useMemo)(()=>{let e=new Intl.NumberFormat(g).formatToParts(-1234.5);return{group:e.find(e=>e.type===`group`)?.value??`,`,decimal:e.find(e=>e.type===`decimal`)?.value??`.`}},[g]),Ae=e=>Number(e.toFixed(V))||0,U=e=>Math.min(o,Math.max(a,e)),W=e=>Ae(B+Math.round((e-B)/T)*T),je=(e,t)=>{let n=(e-B)/T;return Ae(B+((t>0?Math.floor(n+1e-7):Math.ceil(n-1e-7))+t)*T)},G=e=>`${yn(f,e)}${Oe.format(e)}${yn(p,e)}`.trim();function K(e){let t=e.split(ke.group).join(``).replace(ke.decimal,`.`).replace(/[^\d.-]/g,``);if(!/\d/.test(t))return null;let n=Number(t);return Number.isFinite(n)?n:null}let q=O?K(re):null,J=q??D,[Me,Ne]=(0,Y.useState)({value:J,direction:1});Me.value!==J&&Ne({value:J,direction:J>Me.value?1:-1});let Pe=Me.value===J?Me.direction:J>Me.value?1:-1;(0,Y.useEffect)(()=>()=>{window.clearTimeout(I.current),window.clearTimeout(he.current),window.clearTimeout(N.current),window.clearTimeout(P.current)},[]);function Fe(e,t){let n=performance.now(),r=ge.current;r.count=r.edge===e&&n-r.at<fn?r.count+1:1,r.edge=e,r.at=n;let i=pe.current;if(i&&(i.dataset.strain=e>0?`max`:`min`,window.clearTimeout(P.current),P.current=window.setTimeout(()=>{delete i.dataset.strain},420)),!b){E(we,0,{...gn,velocity:-e*hn*(1+Math.min(r.count-1,mn)*pn)});let n=(e>0?M:me).current;n&&(t===`button`||t===`key`)&&E(n,{x:[0,-2.5,2.5,-1.5,1,0]},{duration:.32,ease:`easeOut`})}y&&(ue(e),window.clearTimeout(he.current),he.current=window.setTimeout(()=>ue(0),un))}function Ie(e,n){if(!Number.isFinite(e))return!1;let r=U(e),a=Math.sign(e-r);return a&&n!==`scrub`?(Fe(a>0?1:-1,n),j(`${G(r)}, ${a>0?`maximum`:`minimum`}`)):n===`button`&&r!==F.current&&j(G(r)),r!==F.current&&(F.current=r,t===void 0&&ne(r),i?.(r),!0)}let Le=(e,t,n)=>Ie(je(F.current,e*t),n);(0,Y.useLayoutEffect)(()=>{F.current=D,L.current=Le});function Re(){let e=ve.current;e&&Se.current===null&&(Se.current=e.getBoundingClientRect().left-R.get()-z.get())}(0,Y.useLayoutEffect)(()=>{let e=Se.current,t=ve.current;if(Se.current=null,Ce.current){Ce.current=!1;let e=_e.current;if(e&&document.activeElement===e){let t=e.value.length;e.setSelectionRange(t,t)}}if(e===null||!t)return;let n=e-(t.getBoundingClientRect().left-R.get()-z.get());Math.abs(n)<.5||(z.set(z.get()+n),b?z.jump(0):E(z,0,Q.morph))});function ze(){window.clearTimeout(N.current),fe(!1)}function Be(){if(!O)return;Re(),ae(!1),ze();let e=K(re);e!==null&&Ie(W(e),`type`)}function Ve(){window.clearTimeout(I.current),I.current=void 0,k(0)}function He(e,t,n){Ve(),Be();let r=Math.max(1,Math.round(t/T));n===`button`&&k(e);let i=0,a=()=>{let t=L.current(e,r,n);I.current=window.setTimeout(a,t?Math.max(cn,150*.86**++i):ln)};I.current=window.setTimeout(a,Le(e,r,n)?sn:360)}function Ue(e){let t=c??T*10,n={ArrowUp:[1,e.shiftKey?t:T],ArrowDown:[-1,e.shiftKey?t:T],PageUp:[1,t],PageDown:[-1,t]}[e.key];if(n){e.preventDefault(),e.repeat||He(n[0],n[1],`key`);return}if(!O&&(e.key===`Home`&&Number.isFinite(a)||e.key===`End`&&o<2**53-1)){e.preventDefault(),Ie(e.key===`Home`?a:o,`key`);return}e.key===`Enter`&&(e.preventDefault(),O?(Ce.current=!0,Be()):e.currentTarget.select()),e.key===`Escape`&&O&&(e.preventDefault(),Re(),ae(!1),ze(),Ce.current=!0,Ie(ye.current,`type`))}function We(e){let t=RegExp(`[^0-9${vn(ke.group)}${V||Ee?vn(ke.decimal):``}${a<0?`\\-`:``}]`,`g`),n=e.replace(t,``);O||(ye.current=D),Re(),ie(n),ae(!0);let r=K(n);r!==null&&r>=a&&r<=o&&W(r)===r&&Ie(r,`type`),ze(),r!==null&&r<a&&(N.current=window.setTimeout(()=>fe(!0),dn))}function Ge(e){xe.current=!1,h&&!u&&e.button===0&&(Be(),be.current={pointer:e.pointerId,x:e.clientX,from:F.current,active:!1},e.currentTarget.setPointerCapture(e.pointerId))}function Ke(e){let t=be.current;if(!t||t.pointer!==e.pointerId)return;let n=e.clientX-t.x;if(!t.active){if(Math.abs(n)<3)return;t.active=!0,se(!0)}let r=n/on,i=Math.trunc(r);Ie(i?je(t.from,i):t.from,`scrub`);let s=t.from+r*T,c=s>o?(s-o)/T*on:s<a?(s-a)/T*on:0;R.set(b?0:bn(c))}function qe(e){let t=be.current;t&&t.pointer===e.pointerId&&(be.current=null,t.active&&(xe.current=!0,se(!1),E(R,0,b?{duration:0}:Q.snappy),j(G(F.current))))}let Je=t=>({toward:t,label:e,disabled:u,controls:S,limit:t>0?J>=o:J<=a,pressed:oe===t}),Ye=q===null?0:q>o?1:q<a&&de?-1:0,Xe=y?Ye||le:0,Ze=Xe>0?o:a,Qe=Xe?typeof y==`function`?y(Xe>0?`max`:`min`,Ze):`${Xe>0?`Max`:`Min`} ${G(Ze)}`:``,$e=[C,Ye&&y?w:void 0].filter(Boolean).join(` `)||void 0;return(0,X.jsxs)(`div`,{className:Z.field,"data-size":v,children:[(0,X.jsxs)(`div`,{className:Z.head,children:[(0,X.jsx)(`label`,{htmlFor:S,className:Z.label,"data-scrub":h&&!u||void 0,onPointerDown:Ge,onPointerMove:Ke,onPointerUp:qe,onPointerCancel:qe,onClick:e=>{xe.current&&=(e.preventDefault(),!1)},children:e}),(0,X.jsx)(Rn,{id:w,edge:Xe,text:Qe})]}),(0,X.jsxs)(`div`,{ref:pe,className:Z.control,"data-scrubbing":A||void 0,"data-disabled":u||void 0,"data-warn":Ye?Ye>0?`max`:`min`:void 0,children:[(0,X.jsx)(zn,{...Je(-1),iconRef:me,onPress:()=>He(-1,T,`button`),onRelease:Ve,onActivate:()=>{Be(),Le(-1,1,`button`)}}),(0,X.jsx)(`div`,{className:Z.valueWrap,onMouseDown:e=>{e.target!==_e.current&&e.preventDefault()},onClick:e=>{!u&&e.target!==_e.current&&(_e.current?.focus(),_e.current?.select())},children:(0,X.jsxs)(n.span,{ref:ve,className:Z.value,style:{x:Te,y:we},children:[(0,X.jsx)(kn,{text:yn(f,J),direction:Pe,className:Z.affix}),(0,X.jsxs)(`span`,{className:Z.number,children:[(0,X.jsx)(`span`,{className:Z.display,"data-hidden":O||void 0,"aria-hidden":`true`,children:(0,X.jsx)(On,{value:J,format:Oe,direction:Pe,instant:O})}),O&&(0,X.jsx)(`span`,{className:Z.mirror,"aria-hidden":`true`,children:re}),(0,X.jsx)(`input`,{ref:_e,id:S,className:Z.input,type:`text`,role:`spinbutton`,inputMode:a<0?`text`:V||Ee?`decimal`:`numeric`,autoComplete:`off`,spellCheck:!1,value:O?re:Oe.format(D),disabled:u,"aria-describedby":$e,"aria-invalid":Ye?!0:void 0,"aria-valuenow":D,"aria-valuetext":G(D),"aria-valuemin":Number.isFinite(a)?a:void 0,"aria-valuemax":o<2**53-1?o:void 0,onChange:e=>We(e.currentTarget.value),onKeyDown:Ue,onKeyUp:e=>{/^(Arrow(Up|Down)|Page(Up|Down))$/.test(e.key)&&Ve()},onBlur:()=>{Ve(),Be()}})]}),(0,X.jsx)(kn,{text:yn(p,J),direction:Pe,className:Z.affix})]})}),(0,X.jsx)(zn,{...Je(1),iconRef:M,onPress:()=>He(1,T,`button`),onRelease:Ve,onActivate:()=>{Be(),Le(1,1,`button`)}})]}),(0,X.jsx)(In,{id:C,text:l,className:Z.hint}),(0,X.jsx)(`span`,{className:Z.srOnly,"aria-live":`polite`,"aria-atomic":`true`,children:ce})]})}var Vn=[`overview`,`cost`,`chart`,`topModel`,`compareYesterday`,`cacheHitRate`,`quota`];function Hn(){let{t:e}=k(),t=v(),[n,r]=Ae(),i=Me(),a=De(n,{enabled:i.running,background:!1,live:!0}),o=t=>(0,X.jsx)(N,{label:e(`settings.tray.section.${t}`),detail:e(`settings.tray.section.${t}.hint`),children:(0,X.jsx)(V,{checked:n.sections[t],label:e(`settings.tray.section.${t}`),onChange:e=>r(Ee(n,t,e))})},t);return(0,X.jsxs)(`div`,{className:`mx-auto grid max-w-[1120px] items-start gap-4 lg:grid-cols-[minmax(0,1fr)_392px]`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,X.jsx)(Un,{title:e(`settings.tray.titleHeading`),hint:e(`settings.tray.titleHint`),children:(0,X.jsx)(`div`,{className:`p-4`,children:(0,X.jsx)(Re,{"aria-label":e(`settings.tray.titleHeading`),minColumnWidth:150,value:n.title,onValueChange:e=>r({...n,title:e}),options:fe.map(t=>({value:t,label:e(`settings.tray.title.${t}`),description:e(`settings.tray.title.${t}.hint`)}))})})}),(0,X.jsx)(Un,{title:e(`settings.tray.usageHeading`),children:(0,X.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:Vn.map(o)})}),(0,X.jsx)(Un,{title:e(`settings.tray.clientsHeading`),children:(0,X.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:o(`clients`)})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(I,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(Ue,{className:`size-3.5`}),onClick:()=>r(Oe),children:e(`settings.tray.reset`)})})]}),(0,X.jsx)(`div`,{className:`lg:sticky lg:top-0`,children:(0,X.jsxs)(Un,{title:e(`settings.tray.previewHeading`),hint:e(`settings.tray.previewHint`),children:[(0,X.jsx)(`div`,{className:`flex justify-center bg-[var(--surface-muted)] px-4 py-5`,children:(0,X.jsx)(Ne,{preview:!0,className:`w-[360px] max-w-full shadow-[0_12px_40px_rgb(0_0_0/0.25)]`,prefs:n,state:i,data:a,onRefresh:()=>void t.invalidateQueries({queryKey:[`stats`]})})}),(0,X.jsx)(`p`,{className:`border-t border-[var(--border)] px-4 py-2.5 text-[11px] text-[var(--text-muted)]`,children:e(`settings.tray.previewFooter`)})]})})]})}function Un({title:e,hint:t,children:n}){let{t:r}=k();return(0,X.jsxs)(`section`,{className:`card`,children:[(0,X.jsxs)(`header`,{className:`border-b border-[var(--border)] px-4 py-3`,children:[(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`settings.tab.tray`)}),(0,X.jsx)(`h3`,{className:`text-[14px] font-semibold`,children:e}),t&&(0,X.jsx)(`p`,{className:`mt-0.5 text-[12px] text-[var(--text-secondary)]`,children:t})]}),n]})}var Wn=[`general`,`notifications`,`remote`,`tray`],Gn=[`UTC`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Taipei`,`Asia/Tokyo`,`Asia/Singapore`,`Europe/London`,`Europe/Berlin`,`America/New_York`,`America/Los_Angeles`];function Kn(){let{t:e}=k(),{tab:t}=We(),n=Je(),r=ke(),i=Wn.includes(t)&&(t!==`tray`||r)?t:`general`;return(0,X.jsx)(Qe,{title:e(`nav.settings`),children:(0,X.jsxs)(Ge,{value:i,onValueChange:e=>n(e===`general`?`/settings`:`/settings/${e}`,{replace:!0}),children:[(0,X.jsxs)(Xe,{"aria-label":e(`nav.settings`),children:[(0,X.jsx)(Ke,{value:`general`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(gt,{className:`size-3.5`}),e(`settings.tab.general`)]})}),(0,X.jsx)(Ke,{value:`notifications`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(ct,{className:`size-3.5`}),e(`settings.tab.notifications`)]})}),(0,X.jsx)(Ke,{value:`remote`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(ue,{className:`size-3.5`}),e(`settings.tab.remote`)]})}),r&&(0,X.jsx)(Ke,{value:`tray`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(mt,{className:`size-3.5`}),e(`settings.tab.tray`)]})})]}),(0,X.jsx)(rt,{value:`general`,className:`pt-5`,children:(0,X.jsx)(qn,{})}),(0,X.jsx)(rt,{value:`notifications`,className:`pt-5`,children:(0,X.jsx)(Ht,{})}),(0,X.jsx)(rt,{value:`remote`,className:`pt-5`,children:(0,X.jsx)(Tt,{})}),r&&(0,X.jsx)(rt,{value:`tray`,className:`pt-5`,children:(0,X.jsx)(Hn,{})})]})})}function qn(){let{t,locale:n,setLocale:r}=k(),a=$e(),o=C(),s=le(),c=v(),u=i(),d=H(),f=e(),p=ve(),{toast:m,confirm:h}=K(),g=o.data,_=p.data?.state===`connected`&&p.data.publicUrl?`${p.data.publicUrl}/v1`:null,y=e=>s.mutate(e,{onError:e=>m(U(e),`error`)}),x=e=>{r(e),y({locale:e})},w=async e=>{await W.copy(e)&&m(t(`common.copied`))};return(0,X.jsxs)(`div`,{className:`mx-auto max-w-[680px]`,children:[(0,X.jsxs)(L,{title:t(`settings.appearance`),children:[(0,X.jsx)(N,{label:t(`settings.theme`),children:(0,X.jsx)(ie,{ariaLabel:t(`settings.theme`),value:a.theme,onChange:a.setTheme,items:[{value:`system`,label:t(`settings.theme.system`)},{value:`light`,label:t(`settings.theme.light`)},{value:`dark`,label:t(`settings.theme.dark`)}]})}),(0,X.jsx)(N,{label:t(`settings.accent`),detail:a.accentChoice===`system`?a.systemAccent?t(`settings.accent.followingSystem`):t(`settings.accent.systemUnavailable`):void 0,children:(0,X.jsx)(q,{className:`w-40`,ariaLabel:t(`settings.accent`),value:a.accentChoice,onChange:a.setAccentChoice,options:[{value:`system`,label:t(`settings.accent.system`)},...nt.map(e=>({value:e.color,label:t(`settings.accent.${e.id}`)}))]})}),(0,X.jsx)(N,{label:t(`settings.language`),detail:t(`settings.languageHint`),children:(0,X.jsx)(ie,{ariaLabel:t(`settings.language`),value:n,onChange:x,items:[{value:`zh`,label:`中文`},{value:`en`,label:`English`}]})})]}),(0,X.jsx)(Qt,{}),g?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(L,{title:t(`settings.gateway`),footer:t(`settings.gatewayFooter`),children:[(0,X.jsx)(N,{label:t(`settings.gatewayUrl`),detail:`${g.gatewayBaseUrl}/v1`,children:(0,X.jsx)(I,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(j,{className:`size-3.5`}),"aria-label":t(`common.copy`),onClick:()=>void w(`${g.gatewayBaseUrl}/v1`)})}),_&&(0,X.jsx)(N,{label:t(`settings.remote.publicUrl`),detail:_,children:(0,X.jsx)(I,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(j,{className:`size-3.5`}),"aria-label":t(`common.copy`),onClick:()=>void w(_)})}),(0,X.jsx)(Ft,{}),(0,X.jsx)(N,{label:t(`settings.dataDir`),detail:g.dataDir,children:W.canOpenPaths?(0,X.jsx)(I,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(ze,{className:`size-3.5`}),"aria-label":t(`settings.openFolder`),onClick:()=>void W.openPath(g.dataDir)}):(0,X.jsx)(I,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(j,{className:`size-3.5`}),"aria-label":t(`common.copy`),onClick:()=>void w(g.dataDir)})}),(0,X.jsx)(N,{label:t(`settings.requireKey`),detail:t(`settings.requireKeyHint`),children:(0,X.jsx)(V,{checked:g.requireGatewayKey,label:t(`settings.requireKey`),onChange:async e=>{(e||await h({title:t(`settings.requireKeyOffConfirm`),detail:t(`settings.requireKeyOffDetail`),confirmLabel:t(`settings.requireKeyOff`),destructive:!0}))&&y({requireGatewayKey:e})}})}),(0,X.jsx)(N,{label:t(`settings.streamIdle`),detail:t(`settings.streamIdleHint`),children:(0,X.jsx)(Zn,{label:t(`settings.streamIdle`),value:g.streamIdleTimeoutSec,onCommit:e=>y({streamIdleTimeoutSec:e??300}),suffix:` s`})}),(0,X.jsx)(N,{label:t(`settings.requestCompression`),detail:t(`settings.requestCompressionHint`),children:(0,X.jsx)(q,{className:`w-40`,ariaLabel:t(`settings.requestCompression`),value:g.requestCompression,onChange:e=>y({requestCompression:e}),options:[{value:`default`,label:t(`settings.requestCompression.default`)},{value:`zstd`,label:`zstd`},{value:`gzip`,label:`gzip`},{value:`br`,label:`Brotli (br)`},{value:`deflate`,label:`deflate`},{value:`none`,label:t(`settings.requestCompression.none`)}]})})]}),(0,X.jsx)(Yn,{settings:g}),(0,X.jsx)(Xn,{settings:g}),(0,X.jsxs)(L,{title:t(`settings.quota`),footer:t(`settings.quota.autoIntervalHint`),children:[(0,X.jsx)(N,{label:t(`settings.quota.autoInterval`),children:(0,X.jsx)(Zn,{label:t(`settings.quota.autoInterval`),value:g.quotaAutoIntervalMinutes,onCommit:e=>s.mutate({quotaAutoIntervalMinutes:e??30},{onSuccess:()=>void c.invalidateQueries({queryKey:l.providers}),onError:e=>m(U(e),`error`)}),suffix:` ${t(`settings.minutes`)}`})}),(0,X.jsx)(N,{label:t(`settings.quota.subscriptionInterval`),detail:t(`settings.quota.subscriptionIntervalHint`),children:(0,X.jsx)(Zn,{label:t(`settings.quota.subscriptionInterval`),value:g.subscriptionQuotaIntervalMinutes,onCommit:e=>y({subscriptionQuotaIntervalMinutes:e??30}),suffix:` ${t(`settings.minutes`)}`})})]}),(0,X.jsx)(L,{footer:t(`settings.usageTimeZone.hint`),children:(0,X.jsx)(N,{label:t(`settings.usageTimeZone`),children:(0,X.jsx)(q,{className:`w-56`,ariaLabel:t(`settings.usageTimeZone`),value:g.usageTimeZone??``,onChange:e=>y({usageTimeZone:e||null}),options:[{value:``,label:t(`settings.usageTimeZone.system`,{zone:g.effectiveUsageTimeZone})},...[...new Set([...Gn,...g.usageTimeZone?[g.usageTimeZone]:[]])].map(e=>({value:e,label:e}))]})})}),(0,X.jsxs)(L,{title:t(`settings.logging`),footer:t(`settings.debugBodiesHint`),children:[(0,X.jsx)(N,{label:t(`settings.debugBodies`),children:(0,X.jsx)(V,{checked:g.debugBodies,label:t(`settings.debugBodies`),onChange:e=>y({debugBodies:e})})}),(0,X.jsx)(N,{label:t(`settings.bodyRetention`),children:(0,X.jsx)(Zn,{label:t(`settings.bodyRetention`),value:g.bodyRetentionDays,onCommit:e=>y({bodyRetentionDays:e??7}),suffix:` ${t(`settings.days`)}`})}),(0,X.jsxs)(N,{label:t(`settings.requestRetention`),detail:g.requestRetentionDays==null?t(`settings.keepForever`):void 0,children:[(0,X.jsx)(V,{checked:g.requestRetentionDays!=null,label:t(`settings.requestRetention`),onChange:e=>y({requestRetentionDays:e?90:null})}),g.requestRetentionDays!=null&&(0,X.jsx)(Zn,{label:t(`settings.requestRetention`),value:g.requestRetentionDays,onCommit:e=>y({requestRetentionDays:e??90}),suffix:` ${t(`settings.days`)}`})]})]}),(0,X.jsx)(L,{title:t(`settings.effort`),footer:t(`settings.effortHint`),children:[`low`,`medium`,`high`].map(e=>(0,X.jsx)(N,{label:t(`settings.effort.${e}`),children:(0,X.jsx)(Zn,{label:t(`settings.effort.${e}`),value:g.effortBudgets[e],onCommit:t=>y({effortBudgets:{...g.effortBudgets,[e]:t??g.effortBudgets[e]}}),suffix:` tokens`,step:1024})},e))})]}):o.isError?(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:U(o.error)}):(0,X.jsx)(R,{className:`mx-auto my-8`}),(0,X.jsxs)(L,{title:t(`settings.about`),children:[(0,X.jsx)(N,{label:t(`settings.serverVersion`),detail:u.data?`${u.data.version} · API ${u.data.apiVersion}`:`—`}),S&&(0,X.jsx)(N,{label:t(`settings.desktopVersion`),detail:b()?.version||`—`}),(0,X.jsx)(Jn,{}),S&&(0,X.jsx)(N,{label:t(`settings.logs`),onClick:()=>void W.revealLogs(),children:(0,X.jsx)(ze,{className:`size-4 text-[var(--text-secondary)]`})}),d.data?.required&&(0,X.jsx)(N,{label:t(`settings.logout`),onClick:()=>f.mutate(),children:(0,X.jsx)(Be,{className:`size-4 text-[var(--text-secondary)]`})})]})]})}function Jn(){let{t:e}=k(),{toast:t}=K(),n=v(),r=le(),i=C(),a=O(),o=D(),s=a.data,c=i.data?.updateChannel??s?.channel,u=b()?.updates??null,[d,f]=(0,Y.useState)(!1),p=()=>o.mutate(void 0,{onSuccess:n=>n.error?t(e(`settings.updateCheckFailed`,{error:n.error}),`error`):t(n.available?e(`settings.updateAvailable`,{version:n.available}):e(`settings.upToDate`)),onError:e=>t(U(e),`error`)}),m=()=>{u&&!d&&(f(!0),u.apply().then(r=>{r===`server`?(t(e(`settings.updateApplied`)),n.invalidateQueries({queryKey:l.version}),n.invalidateQueries({queryKey:l.update})):t(e(r===`desktop`?`settings.updateDesktopRelaunch`:r===`download`?`settings.updateDownloadOpened`:r===`downloading`?`settings.updateDownloading`:`settings.upToDate`))}).catch(e=>t(U(e),`error`)).finally(()=>f(!1)))},h=s?.lastCheckAt?new Date(s.lastCheckAt).toLocaleString():void 0,g=s?.available?u?e(`settings.updateAvailable`,{version:s.available}):`${e(`settings.updateAvailable`,{version:s.available})} ${e(`settings.updateApplyHint`)}`:void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:e(`settings.autoCheck`),detail:s&&!s.feedConfigured?e(`settings.updateCheckFailed`,{error:`feed-not-configured`}):void 0,children:(0,X.jsx)(V,{checked:s?.autoCheck??!0,label:e(`settings.autoCheck`),onChange:e=>r.mutate({updateAutoCheck:e},{onError:e=>t(U(e),`error`)})})}),(0,X.jsx)(N,{label:e(`settings.previewUpdates`),detail:e(`settings.previewUpdatesHint`),children:(0,X.jsx)(V,{checked:c===`preview`,label:e(`settings.previewUpdates`),disabled:!c||r.isPending,onChange:e=>r.mutate({updateChannel:e?`preview`:`stable`},{onSuccess:p,onError:e=>t(U(e),`error`)})})}),(0,X.jsxs)(N,{label:e(`settings.checkUpdates`),detail:o.isError?e(`settings.updateCheckFailed`,{error:U(o.error)}):s?.available?g:h?e(`settings.lastChecked`,{time:h}):void 0,children:[(0,X.jsx)(I,{size:`sm`,variant:`plain`,disabled:o.isPending,onClick:p,children:o.isPending?(0,X.jsx)(R,{className:`size-3.5`}):(0,X.jsx)(Ye,{className:`size-3.5`})}),u&&s?.available&&(0,X.jsx)(I,{size:`sm`,variant:`plain`,disabled:d,"aria-label":e(`settings.updateApply`),onClick:m,children:d?(0,X.jsx)(R,{className:`size-3.5`}):(0,X.jsx)(Pe,{className:`size-3.5`})})]})]})}function Yn({settings:e}){let{t}=k(),{toast:n}=K(),r=le(),[i,a]=(0,Y.useState)(e.proxyMode),[o,s]=(0,Y.useState)({url:e.proxyUrl??``,username:e.proxyUsername??``,password:``,bypass:e.proxyBypass??``});(0,Y.useEffect)(()=>a(e.proxyMode),[e.proxyMode]),(0,Y.useEffect)(()=>s({url:e.proxyUrl??``,username:e.proxyUsername??``,password:``,bypass:e.proxyBypass??``}),[e.proxyUrl,e.proxyUsername,e.proxyBypass,e.hasProxyPassword]);let c=t=>{a(t),(t!==`custom`||e.proxyUrl)&&r.mutate({proxyMode:t},{onError:e=>n(U(e),`error`)})},l=()=>r.mutate({proxyMode:`custom`,proxyUrl:o.url.trim()||null,proxyUsername:o.username.trim()||null,proxyBypass:o.bypass.trim()||null,...o.password?{proxyPassword:o.password}:{}},{onSuccess:()=>n(t(`settings.proxy.saved`)),onError:e=>n(U(e),`error`)}),u=i!==e.proxyMode||o.url!==(e.proxyUrl??``)||o.username!==(e.proxyUsername??``)||o.password!==``||o.bypass!==(e.proxyBypass??``);return(0,X.jsxs)(L,{title:t(`settings.proxy`),footer:t(`settings.proxy.footer`),children:[(0,X.jsx)(N,{label:t(`settings.proxy.mode`),detail:t(`settings.proxy.mode.${i}.hint`),children:(0,X.jsx)(ie,{ariaLabel:t(`settings.proxy.mode`),value:i,onChange:c,items:[{value:`system`,label:t(`settings.proxy.mode.system`)},{value:`custom`,label:t(`settings.proxy.mode.custom`)},{value:`direct`,label:t(`settings.proxy.mode.direct`)}]})}),i===`custom`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:t(`settings.proxy.url`),detail:t(`settings.proxy.urlHint`),children:(0,X.jsx)(A,{className:`w-64`,mono:!0,"aria-label":t(`settings.proxy.url`),placeholder:`http://127.0.0.1:7890`,value:o.url,onChange:e=>s({...o,url:e.target.value})})}),(0,X.jsx)(N,{label:t(`settings.proxy.username`),detail:t(`settings.proxy.optional`),children:(0,X.jsx)(A,{className:`w-64`,autoComplete:`off`,"aria-label":t(`settings.proxy.username`),value:o.username,onChange:e=>s({...o,username:e.target.value})})}),(0,X.jsx)(N,{label:t(`settings.proxy.password`),detail:e.hasProxyPassword?t(`settings.proxy.passwordSaved`):t(`settings.proxy.optional`),children:(0,X.jsx)(A,{className:`w-64`,type:`password`,autoComplete:`new-password`,"aria-label":t(`settings.proxy.password`),placeholder:e.hasProxyPassword?`••••••••`:void 0,value:o.password,onChange:e=>s({...o,password:e.target.value})})}),(0,X.jsx)(N,{label:t(`settings.proxy.bypass`),detail:t(`settings.proxy.bypassHint`),children:(0,X.jsx)(A,{className:`w-64`,mono:!0,"aria-label":t(`settings.proxy.bypass`),placeholder:`example.com, *.lan`,value:o.bypass,onChange:e=>s({...o,bypass:e.target.value})})}),(0,X.jsx)(`div`,{className:`flex justify-end px-4 py-2`,children:(0,X.jsx)(I,{size:`sm`,disabled:!u||!o.url.trim()||r.isPending,onClick:l,children:t(`common.save`)})})]})]})}function Xn({settings:e}){let{t}=k(),{toast:n}=K(),r=le(),i=e.pluginMarketUrl===``,[a,o]=(0,Y.useState)(e.pluginMarketUrl??``);(0,Y.useEffect)(()=>o(e.pluginMarketUrl??``),[e.pluginMarketUrl]);let s=(e,i=!1)=>r.mutate({pluginMarketUrl:e},{onSuccess:()=>i&&n(t(`settings.pluginMarket.saved`)),onError:e=>n(U(e),`error`)});return(0,X.jsxs)(L,{title:t(`settings.pluginMarket`),footer:t(`settings.pluginMarket.footer`),children:[(0,X.jsx)(N,{label:t(`settings.pluginMarket.offline`),detail:t(`settings.pluginMarket.offlineHint`),children:(0,X.jsx)(V,{checked:i,label:t(`settings.pluginMarket.offline`),onChange:e=>s(e?``:null)})}),!i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:t(`settings.pluginMarket.url`),detail:t(`settings.pluginMarket.urlHint`),children:(0,X.jsx)(A,{className:`w-80`,mono:!0,"aria-label":t(`settings.pluginMarket.url`),placeholder:e.pluginMarketDefaultUrl,value:a,onChange:e=>o(e.target.value)})}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-2`,children:[e.pluginMarketUrl!==null&&(0,X.jsx)(I,{size:`sm`,disabled:r.isPending,onClick:()=>s(null,!0),children:t(`settings.pluginMarket.reset`)}),(0,X.jsx)(I,{size:`sm`,disabled:r.isPending||a.trim()===(e.pluginMarketUrl??``),onClick:()=>s(a.trim()||null,!0),children:t(`common.save`)})]})]})]})}function Zn({label:e,value:t,onCommit:n,suffix:r,step:i=1}){let[a,o]=(0,Y.useState)(t);(0,Y.useEffect)(()=>o(t),[t]);let s=(0,Y.useRef)(n);return(0,Y.useEffect)(()=>{s.current=n}),(0,Y.useEffect)(()=>{if(a===t)return;let e=setTimeout(()=>s.current(a),600);return()=>clearTimeout(e)},[a,t]),(0,X.jsx)(`div`,{className:`astra-label-hidden w-36`,children:(0,X.jsx)(Bn,{label:e,size:`sm`,value:a,onValueChange:o,min:0,step:i,suffix:r})})}export{Kn as SettingsPage};
@@ -1,2 +0,0 @@
1
- import{Ei as e,Er as t,Ir as n,J as r,La as i,Na as a,Pa as o,Yr as s,_ as c,b as l,ct as u,d,gi as f,gt as p,m,n as h,o as g,p as _,r as v,s as y,t as b,u as x,ut as S,v as C,y as w}from"./alert-DRuYOIBF.js";import{a as T,gt as E,o as D,r as O}from"./overlays-CHP5oojo.js";import{t as k}from"./arrow-down-wREAClBx.js";import{K as A,N as j,S as M,h as N,z as P}from"./index-DorAVedK.js";var F=i(o(),1),I=a(),L=2,R=6;function z({detail:e,...t}){return(0,I.jsx)(m,{...t,detail:e==null?void 0:(0,I.jsx)(`span`,{className:`block whitespace-normal`,children:e})})}var B={typesafe:[{id:`typesafe`,baseUrl:``,model:`jev-latest`},{id:`openrouter`,baseUrl:`https://openrouter.ai/api`,model:`~typesafe/jev-latest`},{id:`vercel`,baseUrl:`https://ai-gateway.vercel.sh/typesafe`,model:`typesafe-ai/jev`}],openai:[{id:`openai`,baseUrl:``}]},V=(e,t)=>`${e??``}\n${t}`;function H(e,t){let n=t.trim().replace(/\/+$/,``);return B[e].find(e=>e.baseUrl===n)?.id??`custom`}function U(e,t,n){let r=e.trim()||(n.find(e=>e.id===t)?.defaultBaseUrl??``);try{return new URL(r).origin.toLowerCase()}catch{return r}}function W(e){return{virtualModel:e.virtualModel,protocol:e.judge.protocol,baseUrl:e.judge.baseUrl??``,apiKey:``,model:e.judge.model,instructions:e.judge.instructions??``,timeoutMs:e.judge.timeoutMs,grades:e.grades.map(e=>({...e})),mode:e.rules.mode,sessionTtlMinutes:e.rules.sessionTtlMinutes,fallbackGrade:e.rules.fallbackGrade,minConfidence:e.rules.minConfidence,contextTurns:e.rules.contextTurns,maxChars:e.rules.maxChars}}var G=e=>[e.timeoutMs,e.sessionTtlMinutes,e.minConfidence,e.contextTurns,e.maxChars].every(e=>e!==null);function K(e){return{protocol:e.protocol,baseUrl:e.baseUrl,model:e.model,instructions:e.instructions,...e.timeoutMs!==null&&{timeoutMs:e.timeoutMs},...e.apiKey!==``&&{apiKey:e.apiKey}}}function q(e){return{virtualModel:e.virtualModel,judge:K(e),grades:e.grades,rules:{mode:e.mode,fallbackGrade:e.fallbackGrade,...e.sessionTtlMinutes!==null&&{sessionTtlMinutes:e.sessionTtlMinutes},...e.minConfidence!==null&&{minConfidence:e.minConfidence},...e.contextTurns!==null&&{contextTurns:e.contextTurns},...e.maxChars!==null&&{maxChars:e.maxChars}}}}function J(e,t,n){let r=`smartRouting.problem.${e.code}`;if(!(r in S))return e.message;let i=/^grades\[(\d+)\]/.exec(e.field??``),a=i?t.grades[Number(i[1])]:void 0;return n(r,{grade:a?a.name||a.id:``,field:e.field??``})}function Y(t,n,r){if(t instanceof e){let e=t.details?.problems;if(Array.isArray(e)&&e.length>0)return e.map(e=>J(e,n,r))}return[T(t)]}function X(e){let t=`smartRouting.unusable.${e}`;return e&&t in S?t:null}function Z(e,t){let n=`smartRouting.failure.${e}`;return n in S?t(n):e??``}function Q(){let{t:e}=u(),t=n();return t.data?(0,I.jsx)($,{saved:t.data}):(0,I.jsx)(`div`,{className:`mx-auto max-w-[760px]`,children:t.isError?(0,I.jsx)(b,{tone:`danger`,title:e(`smartRouting.loadFailed`),children:T(t.error)}):(0,I.jsx)(C,{className:`mx-auto my-8`})})}function $({saved:e}){let{t}=u(),{toast:n}=D(),r=f(),[i,a]=(0,F.useState)(()=>W(e)),[o,s]=(0,F.useState)([]),c=e=>a(t=>({...t,...e})),l=JSON.stringify(i)!==JSON.stringify(W(e)),d=G(i),p=e=>r.mutate({...q(i),...e!==void 0&&{enabled:e}},{onSuccess:r=>{s([]),a(W(r)),n(t(e===void 0?`common.saved`:e?`smartRouting.toast.on`:`smartRouting.toast.off`))},onError:e=>s(Y(e,i,t))});return(0,I.jsxs)(`div`,{className:`mx-auto max-w-[760px]`,children:[(0,I.jsx)(ee,{saved:e,busy:r.isPending,canSave:d,onToggle:e=>p(e),problems:o}),(0,I.jsx)(ne,{saved:e,draft:i,patch:c}),(0,I.jsx)(ie,{draft:i,patch:c}),(0,I.jsx)(ae,{draft:i,patch:c}),!d&&(0,I.jsx)(`p`,{className:`mb-3 px-1 text-[12px] text-[var(--warning)]`,children:t(`smartRouting.numberMissing`)}),(0,I.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[l&&(0,I.jsx)(v,{variant:`plain`,onClick:()=>a(W(e)),children:t(`smartRouting.discard`)}),(0,I.jsx)(v,{variant:`primary`,disabled:!l||!d,loading:r.isPending,onClick:()=>p(),children:t(`common.save`)})]})]})}function ee({saved:e,busy:t,canSave:n,onToggle:r,problems:i}){let{t:a}=u(),{toast:o}=D(),{status:s}=e,c=async e=>{await E.copy(e)&&o(a(`common.copied`))},l=(0,F.useRef)(null);return(0,F.useEffect)(()=>{i.length>0&&l.current?.scrollIntoView({behavior:`smooth`,block:`nearest`})},[i]),(0,I.jsxs)(x,{title:a(`smartRouting.status`),footer:a(`smartRouting.statusFooter`),children:[(0,I.jsx)(z,{label:a(`smartRouting.enable`),detail:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,I.jsx)(y,{tone:e.enabled?s.breakerOpen?`orange`:`green`:`neutral`}),e.enabled?s.breakerOpen?a(`smartRouting.state.breaker`):`${a(`smartRouting.state.on`)}${s.pins>0?` · ${a(`smartRouting.state.pins`,{count:s.pins})}`:``}`:a(`smartRouting.state.off`)]}),children:(0,I.jsx)(w,{checked:e.enabled,label:a(`smartRouting.enable`),disabled:t||!n,onChange:r})}),e.enabled&&(0,I.jsxs)(z,{label:a(`smartRouting.use`),detail:a(`smartRouting.useHint`),children:[(0,I.jsx)(`span`,{className:`font-mono text-[12px] selectable`,children:e.virtualModel}),(0,I.jsx)(v,{size:`sm`,variant:`plain`,icon:(0,I.jsx)(p,{className:`size-3.5`}),"aria-label":a(`common.copy`),onClick:()=>void c(e.virtualModel)})]}),e.enabled&&(0,I.jsx)(te,{saved:e}),i.length>0&&(0,I.jsx)(`div`,{ref:l,className:`px-3 py-2`,children:(0,I.jsx)(b,{tone:`danger`,title:a(`smartRouting.problems`),children:(0,I.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:i.map((e,t)=>(0,I.jsx)(`li`,{children:e},`${t}-${e}`))})})})]})}function te({saved:e}){let{t,locale:n}=u(),i=e.status.recent??{total:0,outcomes:{}},a=e.status.unreachable??[],o=t=>{let n=e.grades.find(e=>e.id===t);return n?n.name||n.id:t},s=i.outcomes.judge??0,c=Object.entries(i.outcomes).filter(([e])=>e!==`judge`).sort((e,t)=>t[1]-e[1]),l=i.total-s,d=[t(`smartRouting.recent.judged`,{count:s,total:i.total}),...c.map(([e,n])=>t(`smartRouting.recent.fallback`,{reason:Z(e,t),count:n})),...i.medianJudgeMs==null?[]:[t(`smartRouting.recent.median`,{ms:i.medianJudgeMs})]].join(` · `),f=`smartRouting.recent.hint.${c[0]?.[0]}`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{label:t(`smartRouting.recent`),detail:i.total===0?t(`smartRouting.recent.none`):d}),l>=2&&l*2>i.total&&(0,I.jsx)(`div`,{className:`px-3 py-2`,children:(0,I.jsxs)(b,{tone:`warning`,title:t(`smartRouting.recent.failing`,{grade:o(e.rules.fallbackGrade)}),children:[(0,I.jsx)(`p`,{children:t(f in S?f:`smartRouting.recent.hint.other`)}),i.lastFallbackAt&&(0,I.jsx)(`p`,{className:`mt-1 text-[var(--text-muted)]`,children:t(`smartRouting.recent.last`,{reason:Z(i.lastFallback,t),time:r(i.lastFallbackAt,n)})})]})}),a.length>0&&(0,I.jsx)(`div`,{className:`px-3 py-2`,children:(0,I.jsxs)(b,{tone:`warning`,title:t(`smartRouting.unreachable.title`),children:[(0,I.jsx)(`ul`,{className:`list-disc space-y-1.5 pl-4`,children:a.map(e=>{let i=X(e.reason),a={count:e.count,time:r(e.lastAt,n)};return(0,I.jsxs)(`li`,{children:[(0,I.jsxs)(`div`,{children:[t(`smartRouting.unreachable.item`,{caller:M(e.caller),grade:o(e.grade),where:e.providerName?t(`smartRouting.unreachable.where`,{provider:e.providerName,model:e.model}):e.model,reason:t(i??`smartRouting.unusable.unknown`)}),` `,e.usedGrade?t(`smartRouting.unreachable.used`,{...a,used:o(e.usedGrade)}):t(`smartRouting.unreachable.none`,a)]}),i&&(0,I.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:t(`${i}.fix`)})]},`${e.caller}\n${e.grade}`)})}),a.some(e=>!X(e.reason))&&(0,I.jsx)(`p`,{className:`mt-1`,children:t(`smartRouting.unreachable.hint`)})]})})]})}function ne({saved:e,draft:t,patch:n}){let{t:r}=u(),i=H(t.protocol,t.baseUrl),a=e.judge.hasApiKey&&t.apiKey===``&&U(t.baseUrl,t.protocol,e.protocols)!==U(e.judge.baseUrl??``,e.judge.protocol,e.protocols);return(0,I.jsxs)(x,{title:r(`smartRouting.judge.title`),footer:r(`smartRouting.judge.footer`),children:[(0,I.jsx)(z,{label:r(`smartRouting.judge.protocol`),detail:r(`smartRouting.judge.protocol.${t.protocol}.hint`),children:(0,I.jsx)(c,{ariaLabel:r(`smartRouting.judge.protocol`),value:t.protocol,onChange:t=>n({protocol:t,baseUrl:``,apiKey:``,model:e.protocols.find(e=>e.id===t)?.defaultModel??``}),items:[{value:`typesafe`,label:r(`smartRouting.judge.protocol.typesafe`)},{value:`openai`,label:r(`smartRouting.judge.protocol.openai`)}]})}),t.protocol===`openai`&&(0,I.jsx)(`div`,{className:`px-3 py-2`,children:(0,I.jsx)(b,{tone:`warning`,title:r(`smartRouting.judge.openaiDraft`)})}),(0,I.jsx)(z,{label:r(`smartRouting.judge.service`),children:(0,I.jsx)(O,{className:`w-52`,ariaLabel:r(`smartRouting.judge.service`),value:i,onChange:e=>{if(e===`custom`)return n({baseUrl:t.baseUrl||`https://`});let r=B[t.protocol].find(t=>t.id===e);r&&n({baseUrl:r.baseUrl,...r.model!==void 0&&{model:r.model}})},options:[...B[t.protocol].map(e=>({value:e.id,label:r(`smartRouting.preset.${e.id}`)})),{value:`custom`,label:r(`smartRouting.preset.custom`)}]})}),i===`custom`&&(0,I.jsx)(z,{label:r(`smartRouting.judge.baseUrl`),detail:r(`smartRouting.judge.baseUrlHint`),children:(0,I.jsx)(d,{className:`w-72`,mono:!0,"aria-label":r(`smartRouting.judge.baseUrl`),placeholder:`https://…`,value:t.baseUrl,onChange:e=>n({baseUrl:e.target.value})})}),(0,I.jsx)(z,{label:r(`smartRouting.judge.apiKey`),detail:a?r(`smartRouting.judge.keyReplace`):e.judge.hasApiKey?r(`smartRouting.judge.keySaved`,{mask:e.judge.apiKeyMasked??``}):r(`smartRouting.judge.keyMissing`),children:(0,I.jsx)(d,{className:`w-72`,type:`password`,autoComplete:`off`,mono:!0,"aria-label":r(`smartRouting.judge.apiKey`),placeholder:e.judge.hasApiKey&&!a?`••••••••`:`sk-…`,value:t.apiKey,onChange:e=>n({apiKey:e.target.value})})}),a&&(0,I.jsx)(`div`,{className:`px-3 py-2`,children:(0,I.jsx)(b,{tone:`warning`,title:r(`smartRouting.judge.keyDropped`)})}),(0,I.jsx)(z,{label:r(`smartRouting.judge.model`),detail:r(`smartRouting.judge.modelHint`),children:(0,I.jsx)(d,{className:`w-72`,mono:!0,"aria-label":r(`smartRouting.judge.model`),placeholder:e.protocols.find(e=>e.id===t.protocol)?.defaultModel||`model`,value:t.model,onChange:e=>n({model:e.target.value})})}),(0,I.jsx)(z,{label:r(`smartRouting.judge.timeout`),detail:r(`smartRouting.judge.timeoutHint`),children:(0,I.jsx)(_,{className:`w-28`,label:r(`smartRouting.judge.timeout`),step:100,min:200,value:t.timeoutMs,onChange:e=>n({timeoutMs:e})})}),(0,I.jsxs)(`div`,{className:`space-y-2 px-3 py-2`,children:[(0,I.jsx)(b,{tone:`info`,title:r(`smartRouting.privacy.title`),children:r(`smartRouting.privacy.body`,{turns:t.contextTurns??0,chars:t.maxChars??0})}),t.protocol===`typesafe`&&(0,I.jsx)(b,{tone:`warning`,title:r(`smartRouting.judge.nonEnglish`)}),(0,I.jsxs)(g,{title:r(`smartRouting.judge.instructions`),children:[(0,I.jsx)(`p`,{className:`mb-2 text-[11px] text-[var(--text-muted)]`,children:r(`smartRouting.judge.instructionsHint`)}),(0,I.jsx)(l,{rows:4,"aria-label":r(`smartRouting.judge.instructions`),placeholder:e.defaultInstructions,value:t.instructions,onChange:e=>n({instructions:e.target.value})})]})]}),(0,I.jsx)(re,{draft:t})]})}function re({draft:e}){let{t}=u(),n=s(),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(null),[c,d]=(0,F.useState)([]),f=()=>{o(null),d([]),n.mutate({text:r,judge:K(e),grades:e.grades},{onSuccess:o,onError:n=>d(Y(n,e,t))})},p=a!==null&&a.latencyMs>a.limitMs;return(0,I.jsxs)(`div`,{className:`space-y-2 px-4 py-3`,children:[(0,I.jsx)(`div`,{className:`text-[13px]`,children:t(`smartRouting.test.title`)}),(0,I.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`smartRouting.test.hint`)}),(0,I.jsx)(l,{rows:3,"aria-label":t(`smartRouting.test.title`),placeholder:t(`smartRouting.test.placeholder`),value:r,onChange:e=>i(e.target.value)}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsx)(v,{size:`sm`,disabled:r.trim()===``,loading:n.isPending,onClick:f,children:t(`smartRouting.test.run`)})}),c.length>0&&(0,I.jsx)(b,{tone:`danger`,title:t(`smartRouting.problems`),children:(0,I.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:c.map((e,t)=>(0,I.jsx)(`li`,{children:e},`${t}-${e}`))})}),a&&(a.ok?(0,I.jsx)(b,{tone:a.confident&&!p?`success`:`warning`,title:t(`smartRouting.test.result`,{grade:a.gradeName??a.grade??``}),children:(0,I.jsxs)(`div`,{className:`space-y-0.5 text-[12px]`,children:[(0,I.jsx)(`div`,{children:a.model?t(`smartRouting.test.model`,{model:a.model}):t(`smartRouting.test.noModel`)}),(0,I.jsxs)(`div`,{children:[t(`smartRouting.test.confidence`,{percent:Math.round((a.confidence??0)*100)}),` ·`,` `,a.confident?t(`smartRouting.test.confident`):t(`smartRouting.test.notConfident`)]}),p&&(0,I.jsxs)(`div`,{className:`text-[var(--warning)]`,children:[t(`smartRouting.test.slow`,{ms:a.latencyMs,limit:a.limitMs}),a.newConnection&&` ${t(`smartRouting.test.connecting`)}`]}),(0,I.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:t(`smartRouting.test.meta`,{ms:a.latencyMs,input:a.inputTokens,output:a.outputTokens,model:a.judgeModel??``})})]})}):(0,I.jsxs)(b,{tone:`danger`,title:t(`smartRouting.test.failed`,{reason:Z(a.failure,t)}),children:[a.message,a.failure===`timeout`&&a.newConnection&&(0,I.jsx)(`p`,{className:`mt-1`,children:t(`smartRouting.test.connecting`)})]}))]})}function ie({draft:e,patch:n}){let{t:r}=u(),i=t(),a=e.grades,o=(t,r=e.fallbackGrade)=>n({grades:t,fallbackGrade:t.some(e=>e.id===r)?r:t[Math.floor(t.length/2)]?.id??``}),s=(e,t)=>o(a.map((n,r)=>r===e?{...n,...t}:n)),c=(e,t)=>{let n=[...a];[n[e],n[e+t]]=[n[e+t],n[e]],o(n)},f=()=>{let e=a.length+1;for(;a.some(t=>t.id===`grade-${e}`);)e++;o([...a,{id:`grade-${e}`,name:``,description:``,model:``}])},p=i.data??[],m=new Set(p.filter((e,t)=>p.findIndex(t=>t.id===e.id)!==t).map(e=>e.id)),g=p.map(e=>({value:V(e.providerId,e.id),label:m.has(e.id)?`${e.id} · ${e.providerName}`:e.id,detail:m.has(e.id)?void 0:e.providerName})),_=e=>{let t=V(e.providerId,e.model);return e.model&&!g.some(e=>e.value===t)?[{value:t,label:r(`smartRouting.grade.unavailable`,{model:e.model})},...g]:g},y=(e,t)=>{let n=t.indexOf(`
2
- `);s(e,{providerId:t.slice(0,n)||null,model:t.slice(n+1)})};return(0,I.jsxs)(x,{title:r(`smartRouting.grades.title`),footer:r(`smartRouting.grades.footer`),children:[a.map((t,n)=>(0,I.jsxs)(`div`,{className:`space-y-2 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`w-4 text-center font-mono text-[11px] text-[var(--text-muted)]`,children:n+1}),(0,I.jsx)(d,{className:`flex-1`,"aria-label":r(`smartRouting.grade.name`),placeholder:t.id,value:t.name,onChange:e=>s(n,{name:e.target.value})}),e.fallbackGrade===t.id&&(0,I.jsx)(h,{tone:`accent`,children:r(`smartRouting.grade.fallbackBadge`)}),(0,I.jsx)(v,{size:`sm`,variant:`plain`,icon:(0,I.jsx)(A,{className:`size-3.5`}),"aria-label":r(`smartRouting.grade.up`),disabled:n===0,onClick:()=>c(n,-1)}),(0,I.jsx)(v,{size:`sm`,variant:`plain`,icon:(0,I.jsx)(k,{className:`size-3.5`}),"aria-label":r(`smartRouting.grade.down`),disabled:n===a.length-1,onClick:()=>c(n,1)}),(0,I.jsx)(v,{size:`sm`,variant:`plain`,icon:(0,I.jsx)(j,{className:`size-3.5`}),"aria-label":r(`smartRouting.grade.remove`),disabled:a.length<=L,onClick:()=>o(a.filter((e,t)=>t!==n))})]}),(0,I.jsx)(l,{rows:2,"aria-label":r(`smartRouting.grade.description`),placeholder:r(`smartRouting.grade.descriptionPlaceholder`),value:t.description,onChange:e=>s(n,{description:e.target.value})}),(0,I.jsx)(O,{ariaLabel:r(`smartRouting.grade.model`),placeholder:r(`smartRouting.grade.pickModel`),value:t.model?V(t.providerId,t.model):``,options:_(t),onChange:e=>y(n,e)})]},t.id)),i.data?.length===0&&(0,I.jsx)(`p`,{className:`px-4 py-2 text-[12px] text-[var(--warning)]`,children:r(`smartRouting.grade.noModels`)}),(0,I.jsx)(`div`,{className:`flex justify-end px-4 py-2`,children:(0,I.jsx)(v,{size:`sm`,icon:(0,I.jsx)(P,{className:`size-3.5`}),disabled:a.length>=R,onClick:f,children:r(`smartRouting.grade.add`)})})]})}function ae({draft:e,patch:t}){let{t:n}=u();return(0,I.jsxs)(x,{title:n(`smartRouting.rules.title`),footer:n(`smartRouting.rules.footer`),children:[(0,I.jsx)(z,{label:n(`smartRouting.rules.mode`),detail:n(`smartRouting.rules.mode.${e.mode}.hint`),children:(0,I.jsx)(c,{ariaLabel:n(`smartRouting.rules.mode`),value:e.mode,onChange:e=>t({mode:e}),items:[{value:`session`,label:n(`smartRouting.rules.mode.session`)},{value:`turn`,label:n(`smartRouting.rules.mode.turn`)}]})}),e.mode===`session`&&(0,I.jsx)(z,{label:n(`smartRouting.rules.ttl`),detail:n(`smartRouting.rules.ttlHint`),children:(0,I.jsx)(_,{className:`w-28`,label:n(`smartRouting.rules.ttl`),step:1,min:1,value:e.sessionTtlMinutes,onChange:e=>t({sessionTtlMinutes:e})})}),(0,I.jsx)(z,{label:n(`smartRouting.rules.fallback`),detail:n(`smartRouting.rules.fallbackHint`),children:(0,I.jsx)(O,{className:`w-44`,ariaLabel:n(`smartRouting.rules.fallback`),value:e.fallbackGrade,onChange:e=>t({fallbackGrade:e}),options:e.grades.map(e=>({value:e.id,label:e.name||e.id}))})}),(0,I.jsx)(z,{label:n(`smartRouting.rules.minConfidence`),detail:n(`smartRouting.rules.minConfidenceHint`),children:(0,I.jsx)(_,{className:`w-28`,label:n(`smartRouting.rules.minConfidence`),step:.05,min:0,value:e.minConfidence,onChange:e=>t({minConfidence:e})})}),(0,I.jsx)(z,{label:n(`smartRouting.rules.contextTurns`),detail:n(`smartRouting.rules.contextTurnsHint`),children:(0,I.jsx)(_,{className:`w-28`,label:n(`smartRouting.rules.contextTurns`),step:1,min:0,value:e.contextTurns,onChange:e=>t({contextTurns:e})})}),(0,I.jsx)(z,{label:n(`smartRouting.rules.maxChars`),detail:n(`smartRouting.rules.maxCharsHint`),children:(0,I.jsx)(_,{className:`w-28`,label:n(`smartRouting.rules.maxChars`),step:500,min:500,value:e.maxChars,onChange:e=>t({maxChars:e})})}),(0,I.jsx)(`div`,{className:`px-3 py-2`,children:(0,I.jsx)(g,{title:n(`smartRouting.rules.advanced`),children:(0,I.jsx)(z,{label:n(`smartRouting.rules.virtualModel`),detail:n(`smartRouting.rules.virtualModelHint`),children:(0,I.jsx)(d,{className:`w-56`,mono:!0,"aria-label":n(`smartRouting.rules.virtualModel`),value:e.virtualModel,onChange:e=>t({virtualModel:e.target.value})})})})})]})}function oe(){let{t:e}=u();return(0,I.jsx)(N,{title:e(`nav.smartRouting`),subtitle:e(`smartRouting.subtitle`),children:(0,I.jsx)(Q,{})})}export{oe as SmartRoutingPage};