tokentracker-cli 0.95.1 → 0.95.2

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 (96) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-Cyju9OnL.js → AchievementBadge-DtB1MwFe.js} +1 -1
  2. package/dashboard/dist/assets/{AchievementsPage-Bh2dQR-I.js → AchievementsPage--vddu0dC.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-DSFAM0Zp.js → AchievementsSection-CDl9hsbj.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-CgVF0VI0.js → BadgeDetailModal-C7WsIRy9.js} +1 -1
  5. package/dashboard/dist/assets/{BotAnimated-DI-rTxI9.js → BotAnimated-CmXyzIhX.js} +1 -1
  6. package/dashboard/dist/assets/{Card-DAlV-PSI.js → Card-SUbC3VNS.js} +1 -1
  7. package/dashboard/dist/assets/{ClawdAnimated-oOYKgcpq.js → ClawdAnimated-BdEbs8Me.js} +2 -2
  8. package/dashboard/dist/assets/{CommandPalette-bYE5uD63.js → CommandPalette-D1RLLeHB.js} +1 -1
  9. package/dashboard/dist/assets/{CommunityStatsModal-DCx0sQjk.js → CommunityStatsModal-5ESGJgZQ.js} +1 -1
  10. package/dashboard/dist/assets/{ConfirmModal-DrYf9m15.js → ConfirmModal-DsCd51b2.js} +1 -1
  11. package/dashboard/dist/assets/{Controls-DAift9Z4.js → Controls-BVrLC_QD.js} +1 -1
  12. package/dashboard/dist/assets/{DashboardPage-CLswnOil.js → DashboardPage-DtUOG6og.js} +1 -1
  13. package/dashboard/dist/assets/{DevicePage-uWLgMC4Z.js → DevicePage-zYjj-m5V.js} +1 -1
  14. package/dashboard/dist/assets/{DialogClose-NitVrdVC.js → DialogClose-D66yBqkd.js} +1 -1
  15. package/dashboard/dist/assets/DialogDescription-BVlaoajd.js +1 -0
  16. package/dashboard/dist/assets/{DialogTitle-CA_ZstJL.js → DialogTitle-C4ia00lc.js} +1 -1
  17. package/dashboard/dist/assets/{FadeIn-CIkYDamA.js → FadeIn-DF2c8XaR.js} +1 -1
  18. package/dashboard/dist/assets/{HeaderGithubStar-CYTJNLpL.js → HeaderGithubStar-Cnr3aqcX.js} +1 -1
  19. package/dashboard/dist/assets/{HoverTooltip-jh3sI8NC.js → HoverTooltip-DBOpxlH7.js} +1 -1
  20. package/dashboard/dist/assets/{IpCheckPage-Brpe-N7B.js → IpCheckPage-CUY6KBaV.js} +1 -1
  21. package/dashboard/dist/assets/{LandingPage-D4PjaNcN.js → LandingPage-DKL8hZEq.js} +2 -2
  22. package/dashboard/dist/assets/{LeaderboardAvatar-D9dc6frq.js → LeaderboardAvatar-DRYeMNlq.js} +1 -1
  23. package/dashboard/dist/assets/{LeaderboardPage-CEuqopiC.js → LeaderboardPage-DpD9Az3k.js} +2 -2
  24. package/dashboard/dist/assets/{LeaderboardProfileModal-TeYdXeIA.js → LeaderboardProfileModal-Dfg0V13F.js} +3 -3
  25. package/dashboard/dist/assets/{LeaderboardProfilePage-DmtuwJkL.js → LeaderboardProfilePage-DH-jcVDu.js} +1 -1
  26. package/dashboard/dist/assets/{LimitsPage-BJW3teYA.js → LimitsPage-CVCKPScf.js} +1 -1
  27. package/dashboard/dist/assets/{LocalOnlyNotice-V8_KFKOD.js → LocalOnlyNotice-Bj_m0hw7.js} +1 -1
  28. package/dashboard/dist/assets/{LoginCard-ud0lCY_u.js → LoginCard-BVKvtx60.js} +1 -1
  29. package/dashboard/dist/assets/{LoginModal-Bnemx4UD.js → LoginModal-mUGiSIJN.js} +1 -1
  30. package/dashboard/dist/assets/{LoginPage-v89BHssa.js → LoginPage-BORCuCUt.js} +1 -1
  31. package/dashboard/dist/assets/{PetPage-Bg9kEi7o.js → PetPage-D1JfEOVA.js} +1 -1
  32. package/dashboard/dist/assets/{PopoverPopup-CCHVwh0w.js → PopoverPopup-DK3et-HG.js} +1 -1
  33. package/dashboard/dist/assets/{ProviderIcon-BecpRylD.js → ProviderIcon-By8FAjxR.js} +1 -1
  34. package/dashboard/dist/assets/{ResetPasswordPage-CsUtFeUr.js → ResetPasswordPage-DPa81jqa.js} +1 -1
  35. package/dashboard/dist/assets/{SegmentedControl-3rBqbzW_.js → SegmentedControl-DLzS-2eZ.js} +1 -1
  36. package/dashboard/dist/assets/{Select-DZ2ll7Qv.js → Select-C05W6XEM.js} +1 -1
  37. package/dashboard/dist/assets/{SelectItemText-Dr1W47W6.js → SelectItemText-CcfB3blP.js} +1 -1
  38. package/dashboard/dist/assets/{ServiceStatusPage-Cc1LXdAh.js → ServiceStatusPage-ByqLbHv1.js} +1 -1
  39. package/dashboard/dist/assets/{SessionsPage-ytOFN1h9.js → SessionsPage-CEDv1thj.js} +1 -1
  40. package/dashboard/dist/assets/{SettingsPage-2wYQ2ly6.js → SettingsPage-DAcndJZQ.js} +2 -2
  41. package/dashboard/dist/assets/{SkillsPage-BEDAwBTN.js → SkillsPage-BuuqQuNU.js} +1 -1
  42. package/dashboard/dist/assets/{TokenGalaxy-DxG0dBeG.js → TokenGalaxy-DzccxkXW.js} +1 -1
  43. package/dashboard/dist/assets/{ToolbarRootContext-DG1pr5UP.js → ToolbarRootContext-XUDMp5uy.js} +1 -1
  44. package/dashboard/dist/assets/{TrendMonitor-CeuEQ0XC.js → TrendMonitor-B-yYabbz.js} +1 -1
  45. package/dashboard/dist/assets/{WidgetsPage-ALDlZ5aR.js → WidgetsPage-CwUDjEFo.js} +1 -1
  46. package/dashboard/dist/assets/{WrappedPage-BF59ouR-.js → WrappedPage-Dr9ow3gH.js} +1 -1
  47. package/dashboard/dist/assets/{__vite-browser-external-DXtgoDkV.js → __vite-browser-external-DPOlUkcY.js} +2 -2
  48. package/dashboard/dist/assets/{agent-logos-D6Ya1qw1.js → agent-logos-Cqc_suYk.js} +1 -1
  49. package/dashboard/dist/assets/{arrow-up-right-DUR69elJ.js → arrow-up-right-DSsR3Ntr.js} +1 -1
  50. package/dashboard/dist/assets/{check-9_1xp5h5.js → check-Cy35lAKh.js} +1 -1
  51. package/dashboard/dist/assets/{composite-CEzovOpb.js → composite-BDwOlhhX.js} +1 -1
  52. package/dashboard/dist/assets/{copy-DEoLQqJE.js → copy-4szu5cYh.js} +1 -1
  53. package/dashboard/dist/assets/{download-BNjfcJ1g.js → download-DdGW6Krz.js} +1 -1
  54. package/dashboard/dist/assets/{external-link-fV_WJ5f_.js → external-link-DwSt83cq.js} +1 -1
  55. package/dashboard/dist/assets/{flame-DqpuFJ14.js → flame-DubukWqK.js} +1 -1
  56. package/dashboard/dist/assets/{format-tokens-CatddjmK.js → format-tokens-B70EdQcN.js} +1 -1
  57. package/dashboard/dist/assets/{icons-CBT1KI7V.js → icons-B86TLdAj.js} +1 -1
  58. package/dashboard/dist/assets/{index-_2LEUZTl.js → index-B_KMoBeK.js} +1 -1
  59. package/dashboard/dist/assets/{index-BK3SzL7v.js → index-DI-W-pun.js} +1 -1
  60. package/dashboard/dist/assets/{index-tK7s2SeO.js → index-DzEMcUwI.js} +1 -1
  61. package/dashboard/dist/assets/{info-DBotcfT9.js → info-BzFpLbl6.js} +1 -1
  62. package/dashboard/dist/assets/{limits-providers-CjMU709b.js → limits-providers-DxZOjiXQ.js} +1 -1
  63. package/dashboard/dist/assets/{link-2-Wc54x2fh.js → link-2-BQp7-3T7.js} +1 -1
  64. package/dashboard/dist/assets/{loader-circle-nRhGIddE.js → loader-circle-lrDmbIg5.js} +1 -1
  65. package/dashboard/dist/assets/{maximize-2-Dw3_GuKW.js → maximize-2-Cnd_Oth8.js} +1 -1
  66. package/dashboard/dist/assets/{modifiers.esm-rTZ5BUxp.js → modifiers.esm-CPTpZdHU.js} +1 -1
  67. package/dashboard/dist/assets/{monitor-smartphone-CNVAqV_N.js → monitor-smartphone-C7UY1zRx.js} +1 -1
  68. package/dashboard/dist/assets/{plus-B5oPOXhp.js → plus-Bglp9N_7.js} +1 -1
  69. package/dashboard/dist/assets/{provider-display-DhAUWfC6.js → provider-display-CGsFySs6.js} +1 -1
  70. package/dashboard/dist/assets/{react-BKACWrsB.js → react-DKXriBSF.js} +1 -1
  71. package/dashboard/dist/assets/{search-DgddmV09.js → search-D_LLDRdU.js} +1 -1
  72. package/dashboard/dist/assets/{skills-api-BT1uiqeq.js → skills-api-CJWjKIco.js} +1 -1
  73. package/dashboard/dist/assets/{sortable.esm-UCoNfZ6z.js → sortable.esm-zlY09tye.js} +1 -1
  74. package/dashboard/dist/assets/{store-ZswY8Voz.js → store-8e16Ac2h.js} +1 -1
  75. package/dashboard/dist/assets/{terminal-BtQyotJS.js → terminal-CR228ekj.js} +1 -1
  76. package/dashboard/dist/assets/{trash-2-Dc_NLbWs.js → trash-2-BjLWewOp.js} +1 -1
  77. package/dashboard/dist/assets/{use-community-stats-yOKag_ou.js → use-community-stats-DhOJPaVg.js} +1 -1
  78. package/dashboard/dist/assets/{use-latest-request-guard-BEiszvlI.js → use-latest-request-guard-lcGhb-NC.js} +1 -1
  79. package/dashboard/dist/assets/{use-limits-display-prefs-C-l_Mxvy.js → use-limits-display-prefs-DJIImtLN.js} +1 -1
  80. package/dashboard/dist/assets/{use-ordered-list-CKjRaO6K.js → use-ordered-list-BJZfZuoJ.js} +1 -1
  81. package/dashboard/dist/assets/use-reduced-motion-DdpxZQoh.js +1 -0
  82. package/dashboard/dist/assets/{use-session-efficiency-pref-DPI_--W2.js → use-session-efficiency-pref-C-l4b1cD.js} +1 -1
  83. package/dashboard/dist/assets/{use-transform-BQUem5OA.js → use-transform-UjIt477N.js} +1 -1
  84. package/dashboard/dist/assets/{use-usage-limits-lvkMBnNR.js → use-usage-limits-DqoTZrqT.js} +1 -1
  85. package/dashboard/dist/assets/{useCurrency-C5xhS1QV.js → useCurrency-CnM8aB4v.js} +1 -1
  86. package/dashboard/dist/assets/{useTokenFormat-FBMikfEq.js → useTokenFormat-D4pAK2ld.js} +1 -1
  87. package/dashboard/dist/assets/{zap-BsCNYelz.js → zap-Du1IyEtj.js} +1 -1
  88. package/dashboard/dist/index.html +1 -1
  89. package/dashboard/dist/ip-check.html +1 -1
  90. package/dashboard/dist/leaderboard.html +1 -1
  91. package/dashboard/dist/share.html +1 -1
  92. package/package.json +1 -1
  93. package/src/lib/pricing/curated-overrides.json +18 -0
  94. package/src/lib/pricing/seed-snapshot.json +1 -1
  95. package/dashboard/dist/assets/DialogDescription-CQuJCP4L.js +0 -1
  96. package/dashboard/dist/assets/use-reduced-motion-BlOkflqU.js +0 -1
@@ -1 +1 @@
1
- import{bU as xn,aI as $e,aF as Z,be as Yt,bX as $t,bV as Rn,r as o,bd as Q,by as Mt,ch as Ht,ci as Et,cj as kt,b_ as Ct,bf as tt,aE as De,A as Ie,ck as Ut,bx as Bt,cl as st,aD as bn,bo as Gt,c0 as Xt,cm as ht,cn as xt,co as Jt,cp as Ot,bc as ft,c5 as yn,cq as In,cr as wt,ay as Rt,aJ as xe,Z as Qt,j as be,V as A,aA as Vt,aL as Pt,aK as Sn,aO as En,aP as Cn,aQ as gt,aG as Tn,b$ as vn,aN as dt,bR as Mn,y as Zt,z as Xe,cs as wn,aB as Pn,ct as An,aC as On,bh as Vn,cu as Fn,az as en,cv as Tt}from"./__vite-browser-external-DXtgoDkV.js";import{q as tn,F as Ln,P as Dn,v as ke,o as Nn,E as Hn,G as we,H as nn,D as kn,u as Un,m as rn,e as Bn,d as _n,z as Wn,I as jn,b as zn,a as Kn,C as qn}from"./composite-CEzovOpb.js";import{h as Yn,u as $n,a as Gn,d as Xn,c as Jn,e as Qn,f as Zn,i as er,p as tr,r as nr,g as rr}from"./ToolbarRootContext-DG1pr5UP.js";function Ze(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function or(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,c=xn(),i=tn()!=null,s=$e(()=>new Ln({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Dn,floatingId:c,syncOnly:!1,nested:i})).current;return Z(()=>{const a={open:t,floatingId:c};r.reference!==void 0&&(a.referenceElement=r.reference,a.domReferenceElement=Yt(r.reference)?r.reference:null),r.floating!==void 0&&(a.floatingElement=r.floating),s.update(a)},[t,c,r.reference,r.floating,s]),s.context.onOpenChange=n,s.context.nested=i,s}const sr="Escape";function _t(e){return Xt&&e.movementX===0&&e.movementY===0}function bt(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function it(e,t){return bt(t,e===Jt||e===Ot,e===ht||e===xt)}function vt(e,t,n){return bt(t,e===Ot,n?e===ht:e===xt)||e==="Enter"||e===" "||e===""}function ir(e,t,n){return bt(t,n?e===ht:e===xt,e===Ot)}function lr(e,t,n,r){const c=n?e===xt:e===ht,i=e===Jt;return t==="both"||t==="horizontal"&&r?e===sr:bt(t,c,i)}function cr(e,t){const{listRef:n,activeIndex:r,onNavigate:c=()=>{},enabled:i=!0,selectedIndex:s=null,allowEscape:a=!1,loopFocus:d=!1,nested:m=!1,rtl:C=!1,virtual:p=!1,focusItemOnOpen:g="auto",focusItemOnHover:S=!0,openOnArrowKeyDown:T=!0,disabledIndices:U=void 0,orientation:u="vertical",parentOrientation:z,id:K,resetOnPointerLeave:V=!0,externalTree:b,grid:I}=t,j=I!=null,h="rootStore"in e?e.rootStore:e,y=h.useState("open"),O=h.useState("floatingElement"),X=h.useState("domReferenceElement"),ee=h.context.dataRef,me=$t(O),te=Rn(X),w=ke(me),N=tn(),ne=Nn(b),B=o.useRef(g),P=o.useRef(s??-1),q=o.useRef(null),F=o.useRef(!0),l=Q(f=>{c(P.current===-1?null:P.current,f)}),v=o.useRef(!!O),ce=o.useRef(y),_=o.useRef(!1),ue=o.useRef(!1),E=o.useRef(null),L=ke(U),Y=ke(y),ie=ke(s),ye=ke(V),H=Mt(),re=Mt(),J=Q(()=>{function f(k){p?ne?.events.emit("virtualfocus",k):E.current=Hn(k,{sync:_.current,preventScroll:!0})}const R=n.current[P.current],$=ue.current;R&&f(R),(_.current?k=>k():k=>H.request(k))(()=>{const k=n.current[P.current]||R;if(!k)return;R||f(k),he&&($||!F.current)&&k.scrollIntoView?.({block:"nearest",inline:"nearest"})})});Z(()=>{ee.current.orientation=u},[ee,u]),Z(()=>{i&&(y&&O?(P.current=s??-1,B.current&&s!=null&&(ue.current=!0,l())):v.current&&(P.current=-1,l()))},[i,y,O,s,l]),Z(()=>{if(i){if(!y){_.current=!1;return}if(O)if(r==null){if(_.current=!1,ie.current!=null)return;if(v.current&&(P.current=-1,J()),(!ce.current||!v.current)&&B.current&&(q.current!=null||B.current===!0&&q.current==null)){let f=0;const R=()=>{n.current[0]==null?(f<2&&(f?x=>re.request(x):queueMicrotask)(R),f+=1):(P.current=q.current==null||vt(q.current,u,C)||m?Et(n):kt(n),q.current=null,l())};R()}}else Ht(n.current,r)||(P.current=r,J(),ue.current=!1)}},[i,y,O,r,ie,m,n,u,C,l,J,re]),Z(()=>{if(!i||O||!ne||p||!v.current)return;const f=ne.nodesRef.current,R=f.find(k=>k.id===N)?.context?.elements.floating,$=Ct(tt(X??R??null)),x=f.some(k=>k.context&&De(k.context.elements.floating,$));R&&!x&&F.current&&R.focus({preventScroll:!0})},[i,O,X,ne,N,p]),Z(()=>{ce.current=y,v.current=!!O}),Z(()=>{y||(q.current=null,B.current=g)},[y,g]);const Re=r!=null,le=Q(f=>{if(!Y.current)return;const R=n.current.indexOf(f.currentTarget);R!==-1&&(P.current!==R||r!==R)&&(P.current=R,l(f))}),ae=Q(()=>z??ne?.nodesRef.current.find(f=>f.id===N)?.context?.dataRef?.current.orientation),ge=Q(()=>Et(n,L.current)),fe=Q(f=>{if(F.current=!1,_.current=!0,f.which===229||!Y.current&&f.currentTarget===w.current)return;if(m&&lr(f.key,u,C,j)){it(f.key,ae())||we(f),h.setOpen(!1,Ie(Ut,f.nativeEvent)),Bt(X)&&(p?ne?.events.emit("virtualfocus",X):X.focus());return}const R=P.current,$=Et(n,U),x=kt(n,U);if(te||(f.key==="Home"&&(we(f),P.current=$,l(f)),f.key==="End"&&(we(f),P.current=x,l(f))),I!=null){const k=I(f,P.current,n,u,d,C,U,$,x);if(k!=null&&(P.current=k,l(f)),u==="both")return}if(it(f.key,u)){if(we(f),y&&!p&&Ct(f.currentTarget.ownerDocument)===f.currentTarget){P.current=vt(f.key,u,C)?$:x,l(f);return}vt(f.key,u,C)?d?R>=x?a&&R!==n.current.length?P.current=-1:(_.current=!1,P.current=$):P.current=st(n.current,{startingIndex:R,disabledIndices:U}):P.current=Math.min(x,st(n.current,{startingIndex:R,disabledIndices:U})):d?R<=$?a&&R!==-1?P.current=n.current.length:(_.current=!1,P.current=x):P.current=st(n.current,{startingIndex:R,decrement:!0,disabledIndices:U}):P.current=Math.max($,st(n.current,{startingIndex:R,decrement:!0,disabledIndices:U})),Ht(n.current,P.current)&&(P.current=-1),l(f)}}),he=o.useMemo(()=>({onFocus(R){_.current=!0,le(R)},onClick:({currentTarget:R})=>R.focus({preventScroll:!0}),onMouseMove(R){_t(R)||(_.current=!0,ue.current=!1,S&&le(R))},onPointerLeave(R){if(!Y.current||!F.current||R.pointerType==="touch")return;_.current=!0;const $=R.relatedTarget;if(!(!S||n.current.includes($))&&ye.current&&(E.current?.(),E.current=null,P.current=-1,l(R),!p)){const x=w.current,k=Ct(tt(x));x&&De(x,k)&&x.focus({preventScroll:!0})}}}),[le,Y,w,S,n,l,ye,p]),G=o.useMemo(()=>p&&y&&Re&&{"aria-activedescendant":`${K}-${r}`},[p,y,Re,K,r]),oe=o.useMemo(()=>({"aria-orientation":u==="both"?void 0:u,...te?{}:G,onKeyDown(f){if(f.key==="Tab"&&f.shiftKey&&y&&!p){const R=bn(f.nativeEvent);if(R&&!De(w.current,R))return;we(f),h.setOpen(!1,Ie(Gt,f.nativeEvent)),Bt(X)&&X.focus();return}fe(f)},onPointerMove(f){_t(f)||(F.current=!0)}}),[G,fe,w,u,te,h,y,p,X]),pe=o.useMemo(()=>{function f(x){h.setOpen(!0,Ie(Ut,x.nativeEvent,x.currentTarget))}function R(x){g==="auto"&&nn(x.nativeEvent)&&(B.current=!p)}function $(x){B.current=g,g==="auto"&&kn(x.nativeEvent)&&(B.current=!0)}return{onKeyDown(x){const k=h.select("open");F.current=!1;const Ce=x.key.startsWith("Arrow"),de=ir(x.key,ae(),C),Be=it(x.key,u),_e=(m?de:Be)||x.key==="Enter"||x.key.trim()==="";if(p&&k)return fe(x);if(!(!k&&!T&&Ce)){if(_e){const Se=it(x.key,ae());q.current=m&&Se?null:x.key}if(m){de&&(we(x),k?(P.current=ge(),l(x)):f(x));return}Be&&(ie.current!=null&&(P.current=ie.current),we(x),!k&&T?f(x):fe(x),k&&l(x))}},onFocus(x){h.select("open")&&!p&&(P.current=-1,l(x))},onPointerDown:$,onPointerEnter:$,onMouseDown:R,onClick:R}},[fe,g,ge,m,l,h,T,u,ae,C,ie,p]),D=o.useMemo(()=>({...G,...pe}),[G,pe]);return o.useMemo(()=>i?{reference:D,floating:oe,item:he,trigger:pe}:{},[i,D,oe,pe,he])}function ur(e,t){const{listRef:n,elementsRef:r,activeIndex:c,onMatch:i,disabledIndices:s,onTyping:a,enabled:d=!0,resetMs:m=750,selectedIndex:C=null}=t,p="rootStore"in e?e.rootStore:e,g=p.useState("open"),S=ft(),T=o.useRef(""),U=o.useRef(C??c??-1),u=o.useRef(null),z=Q(b=>{function I(w){return r?.current[w]}function j(w){const N=I(w);return N&&!yn(N)||N?.matches(":disabled")?!1:s==null||!In(wt,w,s)}function h(w,N,ne=0){if(w.length===0)return-1;const B=(ne%w.length+w.length)%w.length,P=N.toLowerCase();for(let q=0;q<w.length;q+=1){const F=(B+q)%w.length;if(!(!w[F]?.toLowerCase().startsWith(P)||!j(F)))return F}return-1}const y=n.current;if(T.current.length>0&&b.key===" "&&(we(b),a?.(!0)),T.current.length>0&&T.current[0]!==" "&&h(y,T.current)===-1&&b.key!==" "&&a?.(!1),y==null||b.key.length!==1||b.ctrlKey||b.metaKey||b.altKey)return;g&&b.key!==" "&&(we(b),a?.(!0));const O=T.current==="";O&&(U.current=C??c??-1),y.every((w,N)=>w&&j(N)?w[0]?.toLowerCase()!==w[1]?.toLowerCase():!0)&&T.current===b.key&&(T.current="",U.current=u.current),T.current+=b.key,S.start(m,()=>{T.current="",U.current=u.current,a?.(!1)});const me=((O?C??c??-1:U.current)??0)+1,te=h(y,T.current,me);te!==-1?(i?.(te),u.current=te):b.key!==" "&&(T.current="",a?.(!1))}),K=Q(b=>{const I=b.relatedTarget,j=p.select("domReferenceElement"),h=p.select("floatingElement");De(j,I)||De(h,I)||(S.clear(),T.current="",U.current=u.current,a?.(!1))});Z(()=>{!g&&C!==null||(S.clear(),u.current=null,T.current!==""&&(T.current=""))},[g,C,S]);const V=o.useMemo(()=>({onKeyDown:z,onBlur:K}),[z,K]);return o.useMemo(()=>d?{reference:V,floating:V}:{},[d,V])}function ar(e){const[t,n]=o.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function fr(e){const t=o.useRef(!0);t.current&&(t.current=!1,e())}function dr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Wt({controlled:e,default:t,name:n,state:r="value"}){const{current:c}=o.useRef(e!==void 0),[i,s]=o.useState(t),a=c?e:i,d=o.useCallback(m=>{c||s(m)},[]);return[a,d]}const on=o.createContext(null);function Ue(){const e=o.useContext(on);if(e===null)throw new Error(Rt(60));return e}const pr={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},gr={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},mr={disabled:!1,...gr},hr={valid(e){return e===null?null:e?{"data-valid":""}:{"data-invalid":""}}},xr={invalid:void 0,name:void 0,validityData:{state:pr,errors:[],error:"",value:"",initialValue:null},setValidityData:xe,disabled:void 0,setTouched:xe,setDirty:xe,setFilled:xe,setFocused:xe,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:mr,registerFieldControl:xe,validation:{getValidationProps:(e,t=Qt)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:xe,getInputControl:()=>null,commit:async()=>{},change:xe}},Rr=o.createContext(xr);function Ft(e=!0){const t=o.useContext(Rr);if(t.setValidityData===xe&&!e)throw new Error(Rt(28));return t}function br(e,t,n,r,c=!0,i){const{registerFieldControl:s}=Ft(),a=$e(()=>Symbol());Z(()=>{const d=a.current;if(!c){s(d,void 0);return}s(d,{controlRef:e,getValue:r,id:t,name:i,value:n})},[e,c,r,t,i,s,a,n]),Z(()=>{const d=a.current;return()=>{s(d,void 0)}},[s,a])}const yr=o.createContext({controlId:void 0,registerControlId:xe,labelId:void 0,setLabelId:xe,messageIds:[],setMessageIds:xe,getDescriptionProps:e=>e});function sn(){return o.useContext(yr)}function ln(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:c,registerControlId:i}=sn(),s=Un(t),a=n?c:void 0,d=$e(()=>Symbol()),m=o.useRef(!1),C=o.useRef(t!=null),p=Q(()=>{!m.current||i===xe||(m.current=!1,i(d.current,void 0))});return Z(()=>{if(i===xe)return;let g;if(n){const S=r?.current;Yt(S)&&S.closest("label")!=null?g=t??null:g=a??s}else if(t!=null)C.current=!0,g=t;else if(C.current)g=s;else{p();return}if(g===void 0){p();return}m.current=!0,i(d.current,g)},[t,r,a,i,n,s,d,p]),o.useEffect(()=>p,[p]),c??s}const Ir=(e,t)=>Object.is(e,t);function Ge(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function pt(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:Ge(r,t,n))}function Sr(e,t,n){return e.filter(r=>!Ge(t,r,n))}function At(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function cn(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Er(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(cn(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function un(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return At(e)}function Ye(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?At(e.value):At(e)}function an(e,t,n){function r(){return un(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){const c=t,i=cn(c)?c.flatMap(s=>s.items):c;if(e==null||typeof e!="object"){const s=i.find(a=>a.value===e);return s&&s.label!=null?s.label:r()}if("value"in e){const s=i.find(a=>a&&a.value===e.value);if(s&&s.label!=null)return s.label}}return r()}function Cr(e,t,n){return e.reduce((r,c,i)=>(i>0&&r.push(", "),r.push(be.jsx(o.Fragment,{children:an(c,t,n)},i)),r),[])}const M={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{const{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Ye(t,r)!==""},hasNullItemLabel:(e,t)=>t?Er(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(c=>Ge(t,c,n)):Ge(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},Tr=o.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:xe,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function vr(){return o.useContext(Tr)}function Mr(e,t,n=(r,c)=>r===c){return e.length===t.length&&e.every((r,c)=>n(r,t[c]))}const Pe=1;function fn(e,t){return Math.max(0,e-t)}function wr(e,t){if(t<=0)return 0;const n=Ze(e,0,t),r=n,c=t-n,i=r<=Pe,s=c<=Pe;return i&&s?r<=c?0:t:i?0:s?t:n}function to(e){const{id:t,value:n,defaultValue:r=null,onValueChange:c,open:i,defaultOpen:s=!1,onOpenChange:a,name:d,form:m,autoComplete:C,disabled:p=!1,readOnly:g=!1,required:S=!1,modal:T=!0,actionsRef:U,inputRef:u,onOpenChangeComplete:z,items:K,multiple:V=!1,itemToStringLabel:b,itemToStringValue:I,isItemEqualToValue:j=Ir,highlightItemOnHover:h=!0,children:y}=e,{clearErrors:O}=vr(),{setDirty:X,setTouched:ee,setFocused:me,validityData:te,setFilled:w,name:N,disabled:ne,validation:B,validationMode:P}=Ft(),q=ln({id:t}),F=ne||p,l=N??d,[v,ce]=Wt({controlled:n,default:V?r??wt:r,name:"Select",state:"value"}),[_,ue]=Wt({controlled:i,default:s,name:"Select",state:"open"}),E=o.useRef([]),L=o.useRef([]),Y=o.useRef(null),ie=o.useRef(null),ye=o.useRef(0),H=o.useRef(null),re=o.useRef([]),J=o.useRef(!1),Re=o.useRef(null),le=o.useRef(null),ae=o.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ge=o.useRef(!1),{mounted:fe,setMounted:he,transitionStatus:G}=rn(_),{openMethod:oe,triggerProps:pe}=Yn(_),D=$e(()=>new Tn({id:q,labelId:void 0,modal:T,multiple:V,itemToStringLabel:b,itemToStringValue:I,isItemEqualToValue:j,value:v,open:_,mounted:fe,transitionStatus:G,items:K,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,f=A(D,M.activeIndex),R=A(D,M.selectedIndex),$=A(D,M.triggerElement),x=A(D,M.positionerElement),k=ar(oe),Ce=oe??k,de=o.useMemo(()=>V?"":Ye(v,I),[V,v,I]),Be=o.useMemo(()=>V&&Array.isArray(v)?v.map(W=>Ye(W,I)):Ye(v,I),[V,v,I]),_e=ke($),Se=Q(()=>Be);br(_e,q,v,Se,!F,d);const yt=o.useRef(v),Je=V?Array.isArray(v)&&v.length>0:v!=null&&de!=="";Z(()=>{w(Je)},[Je,w]),Z(function(){let se=v,Me=!1;if(V){const He=Array.isArray(v)?v:[];Me=He.length===0,se=He[He.length-1]}const Fe=Me?-1:pt(re.current,se,j),Le=Fe===-1?null:Fe;Le===null&&(le.current=null),!_&&D.set("selectedIndex",Le)},[V,_,v,j,D]);function Te(W){const se=te.initialValue;return Array.isArray(W)&&Array.isArray(se)?!Mr(W,se,(Me,Fe)=>Ge(Me,Fe,j)):W!==se}$n(v,()=>{O(l),X(Te(v)),B.change(v)});const We=Q((W,se)=>{a?.(W,se),!se.isCanceled&&(ue(W),!W&&(se.reason===Gt||se.reason===vn)&&(ee(!0),me(!1),P==="onBlur"&&B.commit(v)))}),je=Q(()=>{he(!1),D.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),z?.(!1)});Vt({enabled:!U,open:_,ref:Y,onComplete(){_||je()}}),o.useImperativeHandle(U,()=>({unmount:je}),[je]);const Ae=Q((W,se)=>{c?.(W,se),!se.isCanceled&&ce(W)}),ve=Q(W=>{const se=fn(W.scrollHeight,W.clientHeight),Me=wr(W.scrollTop,se),Fe=Me>0,Le=Me<se;D.set("scrollUpArrowVisible",Fe),D.set("scrollDownArrowVisible",Le)}),Oe=or({open:_,onOpenChange:We,elements:{reference:$,floating:x}}),ze=Gn(Oe,{enabled:!g&&!F,event:"mousedown"}),Ke=Bn(Oe),Ve=cr(Oe,{enabled:!g&&!F,listRef:E,activeIndex:f,selectedIndex:R,disabledIndices:wt,onNavigate(W){W===null&&!_||D.set("activeIndex",W)},focusItemOnHover:h}),Ne=ur(Oe,{enabled:!g&&!F&&(_||!V),listRef:L,activeIndex:f,selectedIndex:R,disabledIndices:W=>dr(E.current[W]),onMatch(W){_?D.set("activeIndex",W):Ae(re.current[W],Ie(gt))},onTyping(W){J.current=W}}),nt=o.useMemo(()=>Pt(Ne.reference,Ve.reference,Ke.reference,ze.reference,pe),[ze.reference,Ne.reference,Ve.reference,Ke.reference,pe]),rt=o.useMemo(()=>Pt(_n,Ne.floating,Ve.floating,Ke.floating),[Ne.floating,Ve.floating,Ke.floating]),ot=Ve.item??Qt;fr(()=>{D.update({popupProps:rt,triggerProps:nt})}),D.useSyncedValues({id:q,modal:T,multiple:V,value:v,open:_,mounted:fe,transitionStatus:G,popupProps:rt,triggerProps:nt,items:K,itemToStringLabel:b,itemToStringValue:I,isItemEqualToValue:j,openMethod:Ce});const Ee=o.useMemo(()=>({store:D,floatingContext:Oe,required:S,disabled:F,readOnly:g,multiple:V,highlightItemOnHover:h,setValue:Ae,setOpen:We,listRef:E,popupRef:Y,scrollHandlerRef:ie,handleScrollArrowVisibility:ve,scrollArrowsMountedCountRef:ye,itemProps:ot,valueRef:H,valuesRef:re,labelsRef:L,typingRef:J,selectionRef:ae,firstItemTextRef:Re,selectedItemTextRef:le,validation:B,onOpenChangeComplete:z,alignItemWithTriggerActiveRef:ge,initialValueRef:yt}),[D,Oe,S,F,g,V,h,Ae,We,ot,B,z,ve]),qe=Sn(u,B.inputRef),Qe=V?void 0:l,It=o.useMemo(()=>!V||!Array.isArray(v)||!l?null:v.map(W=>{const se=Ye(W,I);return be.jsx("input",{type:"hidden",form:m,name:l,value:se,disabled:F},se)}),[V,v,m,l,I,F]);return be.jsxs(on.Provider,{value:Ee,children:[y,be.jsx("input",{...B.getValidationProps(F,{onFocus(){D.state.triggerElement?.focus({focusVisible:!0})},onChange(W){if(W.nativeEvent.defaultPrevented||F||g)return;const se=W.currentTarget.value,Me=Ie(gt,W.nativeEvent);function Fe(){if(V)return;const Le=se.toLowerCase();let He=re.current.findIndex(St=>Ye(St,I).toLowerCase()===Le||un(St,b).toLowerCase()===Le);He===-1&&(He=re.current.findIndex((St,hn)=>{const Nt=L.current[hn];return Nt!=null&&Nt.toLowerCase()===Le}));const Dt=re.current[He];Dt!=null&&Ae(Dt,Me)}D.set("forceMount",!0),queueMicrotask(Fe)}}),id:q&&Qe==null?`${q}-hidden-input`:void 0,form:m,name:Qe,autoComplete:C,value:de,disabled:F,required:S&&!(V&&Je),readOnly:g,ref:qe,style:l?En:Cn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),It]})}function Pr(e,t){return e??t}const lt=5;function Ar(e,t){const n=Or(t);return e.clientX>=n.left-lt&&e.clientX<=n.right+lt&&e.clientY>=n.top-lt&&e.clientY<=n.bottom+lt}function Or(e){const t=e.getBoundingClientRect(),n=dt(e);if(Mn)return t;const r=n.getComputedStyle(e,"::before"),c=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||c.content!=="none"))return t;const s=parseFloat(r.width)||0,a=parseFloat(r.height)||0,d=parseFloat(c.width)||0,m=parseFloat(c.height)||0,C=Math.max(t.width,s,d),p=Math.max(t.height,a,m),g=C-t.width,S=p-t.height;return{left:t.left-g/2,right:t.right+g/2,top:t.top-S/2,bottom:t.bottom+S/2}}const Vr=400,Fr={...Wn,...hr,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},no=o.forwardRef(function(t,n){const{render:r,className:c,id:i,disabled:s=!1,nativeButton:a=!0,style:d,...m}=t,{setTouched:C,setFocused:p,validationMode:g,state:S,disabled:T}=Ft(),{labelId:U}=sn(),{store:u,setOpen:z,selectionRef:K,validation:V,readOnly:b,required:I,alignItemWithTriggerActiveRef:j,disabled:h}=Ue(),y=T||h||s,O=A(u,M.open),X=A(u,M.mounted),ee=A(u,M.value),me=A(u,M.triggerProps),te=A(u,M.positionerElement),w=A(u,M.listElement),N=A(u,M.popupSide),ne=A(u,M.id),B=A(u,M.labelId),P=A(u,M.hasSelectedValue),q=X&&te?N:null,F=i??ne,l=Pr(U,B);ln({id:F});const v=ke(te),ce=o.useRef(null),{getButtonProps:_,buttonRef:ue}=Zt({disabled:y,native:a}),E=u.useStateSetter("triggerElement"),L=ft(),Y=ft(),ie=ft();o.useEffect(()=>{if(O)return ie.start(Vr,()=>{K.current.allowUnselectedMouseUp=!0,K.current.allowSelectedMouseUp=!0}),()=>{ie.clear()};K.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},Y.clear()},[O,K,Y,ie]);const ye=Pt(me,{id:F,role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-controls":O?w?.id??$t(te)?.id:void 0,"aria-labelledby":l,"aria-readonly":b||void 0,"aria-required":I||void 0,tabIndex:y?-1:0,onFocus(J){p(!0),O&&j.current&&z(!1,Ie(gt,J.nativeEvent)),L.start(0,()=>{u.set("forceMount",!0)})},onBlur(J){De(te,J.relatedTarget)||(C(!0),p(!1),g==="onBlur"&&V.commit(ee))},onMouseDown(J){if(O)return;const Re=tt(J.currentTarget);function le(ae){if(!ce.current)return;const ge=ae.target;De(ce.current,ge)||De(v.current,ge)||Ar(ae,ce.current)||z(!1,Ie(wn,ae))}Y.start(0,()=>{Re.addEventListener("mouseup",le,{once:!0})})}},m,_),H=V.getValidationProps(y,ye);H.role="combobox";const re={...S,open:O,disabled:y,value:ee,readOnly:b,popupSide:q,placeholder:!P};return Xe("button",t,{ref:[n,ce,ue,E],state:re,stateAttributesMapping:Fr,props:H})}),Lr={value:()=>null},ro=o.forwardRef(function(t,n){const{className:r,render:c,children:i,placeholder:s,style:a,...d}=t,{store:m,valueRef:C}=Ue(),p=A(m,M.value),g=A(m,M.items),S=A(m,M.itemToStringLabel),T=A(m,M.hasSelectedValue),U=!T&&s!=null&&i==null,u=A(m,M.hasNullItemLabel,U),z={value:p,placeholder:!T};let K=null;return typeof i=="function"?K=i(p):i!=null?K=i:U&&!u?K=s:Array.isArray(p)?K=Cr(p,g,S):K=an(p,g,S),Xe("span",t,{state:z,ref:[n,C],props:[{children:K},d],stateAttributesMapping:Lr})}),oo=o.forwardRef(function(t,n){const{store:r}=Ue(),c=A(r,M.mounted),i=A(r,M.forceMount);return c||i?be.jsx(Pn,{ref:n,...t}):null}),dn=o.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Dr(){return o.useContext(dn)}function Nr(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:c}=e,i=Q(c),[,s]=o.useState(!1),a=$e(kr).current,d=$e(Hr).current,m=o.useRef(0),C=o.useRef(!0),p=o.useRef([]),g=o.useRef(null),S=Q(()=>{C.current||(C.current=!0,s(I=>!I))}),T=Q((I,j)=>{d.set(I,j),S()}),U=Q(I=>{d.delete(I),S()}),u=Q(I=>{const j=new Map;return n.current.length=0,r&&(r.current.length=0),I.forEach(h=>{j.set(h.element,{...h.registration.metadata??{},index:h.index}),n.current[h.index]=h.element,r&&(r.current[h.index]=h.registration.label!==void 0?h.registration.label:h.registration.textRef?.current?.textContent??h.element.textContent)}),m.current=n.current.length,j});function z(I){if(g.current?.disconnect(),g.current=null,typeof MutationObserver!="function"||I.length<2)return;const j=new MutationObserver(y=>{if(!_r(y))return;let O=null;for(const X of I)if(X.isConnected){if(O&&pn(O,X)>0){j.disconnect(),S();return}O=X}});g.current=j;const h=new Set;for(let y=1;y<I.length;y+=1){const O=Br(I[y-1],I[y]);O&&h.add(O)}h.forEach(y=>j.observe(y,{childList:!0}))}const K=Q(()=>{const[I,j]=Ur(d),h=u(I);z(j),p.current=I,C.current=!1,a.forEach(y=>y(h)),i(h)});Z(()=>(C.current||u(p.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,u]),Z(()=>{C.current&&K()}),Z(()=>()=>{g.current?.disconnect(),C.current=!0},[]);const V=Q(I=>(a.add(I),()=>{a.delete(I)})),b=o.useMemo(()=>({register:T,unregister:U,subscribeMapChange:V,nextIndexRef:m}),[T,U,V,m]);return be.jsx(dn.Provider,{value:b,children:t})}function Hr(){return new Map}function kr(){return new Set}function Ur(e){const t=new Set,n=[],r=[];e.forEach((i,s)=>{if(!s.isConnected)return;const a=i.index,d={index:a??-1,element:s,registration:i};a===null?r.push(d):a>=0&&(t.add(a),n.push(d))});let c=0;return r.sort((i,s)=>pn(i.element,s.element)),r.forEach(i=>{for(;t.has(c);)c+=1;i.index=c,n.push(i),c+=1}),t.size>0&&n.sort((i,s)=>i.index-s.index),[n,r.map(i=>i.element)]}function Br(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function _r(e){for(const t of e)for(let n=0;n<t.removedNodes.length;n+=1)if(t.removedNodes[n].isConnected)return!0;return!1}function pn(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}const gn=o.createContext(void 0);function Wr(){const e=o.useContext(gn);if(!e)throw new Error(Rt(59));return e}function mt(e,t){e&&Object.assign(e.style,t)}const jr={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},zr={position:"fixed"},so=o.forwardRef(function(t,n){const{anchor:r,className:c,render:i,positionMethod:s,side:a,align:d,sideOffset:m,alignOffset:C,collisionBoundary:p="clipping-ancestors",collisionPadding:g,arrowPadding:S,sticky:T,disableAnchorTracking:U,alignItemWithTrigger:u=!0,collisionAvoidance:z=An,style:K,...V}=t,{store:b,listRef:I,labelsRef:j,alignItemWithTriggerActiveRef:h,selectedItemTextRef:y,valuesRef:O,initialValueRef:X,popupRef:ee,setValue:me,floatingContext:te}=Ue(),w=A(b,M.open),N=A(b,M.mounted),ne=A(b,M.modal),B=A(b,M.value),P=A(b,M.openMethod),q=A(b,M.positionerElement),F=A(b,M.triggerElement),l=A(b,M.isItemEqualToValue),v=A(b,M.transitionStatus),ce=o.useRef(null),_=o.useRef(null),[ue,E]=o.useState(u),L=N&&ue&&P!=="touch";!N&&ue!==u&&E(u),o.useImperativeHandle(h,()=>L),Xn((L||ne)&&w,P==="touch",q,F);const Y=Jn({anchor:r,floatingRootContext:te,positionMethod:s,mounted:N,side:a,sideOffset:m,align:d,alignOffset:C,arrowPadding:S,collisionBoundary:p,collisionPadding:g,sticky:T,disableAnchorTracking:U??L,collisionAvoidance:z,keepMounted:!0}),ie=L?"none":Y.side,ye=L?zr:Y.positionerStyles,H={open:w,side:ie,align:Y.align,anchorHidden:Y.anchorHidden};Z(()=>{b.set("popupSide",Y.side)},[b,Y.side]);const re=b.useStateSetter("positionerElement"),J=Qn(t,H,{styles:ye,transitionStatus:v,props:V,refs:[n,re],hidden:!N,inert:!w}),Re=o.useRef(0),le=Q(ge=>{if(O.current.length===0)return;const fe=Re.current;if(Re.current=ge.size,ge.size===fe)return;const he=Ie(gt);if(fe!==0&&!b.state.multiple&&B!==null&&pt(O.current,B,l)===-1){const oe=X.current,D=oe!=null&&pt(O.current,oe,l)!==-1?oe:null;me(D,he),D===null&&(b.set("selectedIndex",null),y.current=null)}if(fe!==0&&b.state.multiple&&Array.isArray(B)){const G=B.filter(oe=>pt(O.current,oe,l)!==-1);G.length!==B.length&&(me(G,he),G.length===0&&(b.set("selectedIndex",null),y.current=null))}if(w&&L){b.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const G={height:""};mt(q,G),mt(ee.current,G)}}),ae=o.useMemo(()=>({...Y,side:ie,alignItemWithTriggerActive:L,setControlledAlignItemWithTrigger:E,scrollUpArrowRef:ce,scrollDownArrowRef:_}),[Y,ie,L,E]);return be.jsx(Nr,{elementsRef:I,labelsRef:j,onMapChange:le,children:be.jsxs(gn.Provider,{value:ae,children:[N&&ne&&be.jsx(jn,{inert:On(!w),cutout:F}),J]})})}),ct="base-ui-disable-scrollbar",jt={className:ct,getElement(e){return be.jsx("style",{nonce:e,href:ct,precedence:"base-ui:low",children:`.${ct}{scrollbar-width:none}.${ct}::-webkit-scrollbar{display:none}`})}},Kr=o.createContext(void 0),qr={disableStyleElements:!1};function Yr(){return o.useContext(Kr)??qr}const $r={...Kn,...en},io=o.forwardRef(function(t,n){const{render:r,className:c,style:i,finalFocus:s,...a}=t,{store:d,popupRef:m,onOpenChangeComplete:C,setOpen:p,valueRef:g,firstItemTextRef:S,selectedItemTextRef:T,multiple:U,handleScrollArrowVisibility:u,scrollHandlerRef:z,listRef:K,highlightItemOnHover:V,floatingContext:b}=Ue(),{side:I,align:j,alignItemWithTriggerActive:h,isPositioned:y,setControlledAlignItemWithTrigger:O}=Wr(),X=Zn()!=null,ee=er(),{nonce:me,disableStyleElements:te}=Yr(),w=A(d,M.id),N=A(d,M.open),ne=A(d,M.openMethod),B=A(d,M.mounted),P=A(d,M.popupProps),q=A(d,M.transitionStatus),F=A(d,M.triggerElement),l=A(d,M.positionerElement),v=A(d,M.listElement),ce=o.useRef(!1),_=o.useRef(!1),ue=o.useRef({}),E=Mt(),L=Q(H=>{if(!l||!m.current||!_.current)return;const re=l.style.top==="0px",J=l.style.bottom==="0px";if(ce.current||!h||!re&&!J){u(H);return}const Re=Kt(l),le=et(l.getBoundingClientRect().height,"y",Re),ae=tt(l),ge=dt(l),fe=ge.getComputedStyle(l),he=parseFloat(fe.marginTop),G=parseFloat(fe.marginBottom),oe=zt(ge.getComputedStyle(m.current)),pe=Math.min(ae.documentElement.clientHeight-he-G,oe),D=H.scrollTop,f=ut(H);let R=null;const $=de=>{l.style.height=`${de}px`},x=re?f-D:D,k=Math.min(le+x,pe);if(x<=Pe){const de=Ze(x,0,pe-le);de>0&&$(le+de),H.scrollTop=re?f:0,pe-(le+de)<=Pe&&(ce.current=!0),u(H);return}if(pe-k>Pe)R=re?1/0:0;else if(J&&D<f){const de=le+x-pe;R=D-(x-de)}const Ce=Math.ceil(k);if(Ce!==0&&$(Ce),R!=null){const de=Ze(R,0,ut(H));Math.abs(H.scrollTop-de)>Pe&&(H.scrollTop=de)}Ce>=pe-Pe&&(ce.current=!0),u(H)});o.useImperativeHandle(z,()=>L,[L]),Vt({open:N,ref:m,onComplete(){N&&C?.(!0)}});const Y={open:N,transitionStatus:q,side:I,align:j};Z(()=>{!l||!m.current||Object.keys(ue.current).length||(ue.current={top:l.style.top||"0",left:l.style.left||"0",right:l.style.right,height:l.style.height,bottom:l.style.bottom,minHeight:l.style.minHeight,maxHeight:l.style.maxHeight,marginTop:l.style.marginTop,marginBottom:l.style.marginBottom})},[m,l]),Z(()=>{N||h||(_.current=!1,ce.current=!1,mt(l,ue.current))},[N,h,l,m]),Z(()=>{const H=m.current;if(!N||!F||!l||!H||h&&!y||d.state.transitionStatus==="ending")return;if(_.current=!0,H.style.removeProperty("--transform-origin"),!h){E.request(()=>u(v||H));return}const re=Gr(H);try{let J=T.current;J?.isConnected||(J=!M.hasSelectedValue(d.state)&&S.current?.isConnected?S.current:null);const Re=g.current,le=dt(l),ae=le.getComputedStyle(l),ge=le.getComputedStyle(H),fe=tt(F),he=Kt(F),G=at(F.getBoundingClientRect(),he),oe=at(l.getBoundingClientRect(),he),pe=G.height,D=v||H,f=D.scrollHeight,R=parseFloat(ge.borderBottomWidth),$=parseFloat(ae.marginTop)||10,x=parseFloat(ae.marginBottom)||10,k=parseFloat(ae.minHeight)||100,Ce=zt(ge),de=5,Be=5,_e=20,Se=fe.documentElement.clientHeight-$-x,yt=fe.documentElement.clientWidth,Je=Se-G.bottom+pe;let Te,We=ee==="rtl"?G.right-oe.width:G.left,je=0;if(J&&Re){const Ee=at(Re.getBoundingClientRect(),he);Te=at(J.getBoundingClientRect(),he),We=oe.left+(ee==="rtl"?Ee.right-Te.right:Ee.left-Te.left);const qe=Ee.top-G.top+Ee.height/2;je=Te.top-oe.top+Te.height/2-qe}const Ae=Je+je+x+R;let ve=Math.min(Se,Ae);const Oe=Se-$-x,ze=Ae-ve,Ke=yt-Be;l.style.left=`${Ze(We,de,Ke-oe.width)}px`,l.style.height=`${ve}px`,l.style.maxHeight="none",l.style.marginTop=`${$}px`,l.style.marginBottom=`${x}px`,H.style.height="100%";const Ve=ut(D),Ne=ze>=Ve-Pe;Ne&&(ve=Math.min(Se,oe.height)-(ze-Ve));const nt=G.top<_e||G.bottom>Se-_e||Math.ceil(ve)+Pe<Math.min(f,k),rt=(le.visualViewport?.scale??1)!==1&&Xt;if(nt||rt){mt(l,ue.current),O(!1);return}const ot=Math.max(k,ve);if(Ne){const Ee=Math.max(0,Se-Ae);l.style.top=oe.height>=Oe?"0":`${Ee}px`,l.style.height=`${ve}px`,D.scrollTop=ut(D)}else l.style.bottom="0",D.scrollTop=ze;if(Te){const Ee=oe.top,qe=oe.height,Qe=Te.top+Te.height/2,It=Ze(qe>0?(Qe-Ee)/qe*100:50,0,100);H.style.setProperty("--transform-origin",`50% ${It}%`)}(ot===Se||ve>=Ce)&&(ce.current=!0),u(D),V&&d.state.selectedIndex===null&&d.state.activeIndex===null&&K.current[0]!=null&&d.set("activeIndex",0)}finally{re()}},[d,N,l,F,g,S,T,m,u,h,O,E,v,K,V,ee,y]),o.useEffect(()=>{if(!h||!l||!N)return;const H=dt(l);function re(J){p(!1,Ie(Fn,J))}return Vn(H,"resize",re)},[p,h,l,N]);const ie={...v?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":U||void 0,id:`${w}-list`},onKeyDown(H){X&&qn.has(H.key)&&H.stopPropagation()},onScroll(H){v||L(H.currentTarget)},...h&&{style:v?{height:"100%"}:jr},className:!v&&h?jt.className:void 0},ye=Xe("div",t,{ref:[n,m],state:Y,stateAttributesMapping:$r,props:[P,ie,rr(q),a]});return be.jsxs(o.Fragment,{children:[!te&&jt.getElement(me),be.jsx(zn,{context:b,modal:!1,disabled:!B,openInteractionType:ne,returnFocus:s,restoreFocus:!0,children:ye})]})});function zt(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function ut(e){return fn(e.scrollHeight,e.clientHeight)}function Kt(e){return tr.getScale(e)}function et(e,t,n){return e/n[t]}function at(e,t){return nr({x:et(e.x,"x",t),y:et(e.y,"y",t),width:et(e.width,"x",t),height:et(e.height,"y",t)})}const qt=[["transform","none"],["scale","1"],["translate","0 0"]];function Gr(e){const{style:t}=e,n={};for(const[r,c]of qt)n[r]=t.getPropertyValue(r),t.setProperty(r,c,"important");return()=>{for(const[r]of qt){const c=n[r];c?t.setProperty(r,c):t.removeProperty(r)}}}function Xr(e={}){const{guess:t,label:n,metadata:r,textRef:c,index:i}=e,{register:s,unregister:a,subscribeMapChange:d,nextIndexRef:m}=Dr(),C=o.useRef(-1),[p,g]=o.useState(i==null&&t?()=>{if(C.current===-1){const u=m.current;m.current+=1,C.current=u}return C.current}:-1),S=i??p,T=o.useRef(null),U=o.useCallback(u=>{const z=T.current;z&&a(z),T.current=u,u&&s(u,{metadata:r??null,index:i??null,label:n,textRef:c})},[i,s,a,r,n,c]);return Z(()=>{if(i==null)return d(u=>{const z=T.current?u.get(T.current)?.index:null;z!=null&&g(z)})},[i,d]),{ref:U,index:S}}const mn=o.createContext(void 0);function Lt(){const e=o.useContext(mn);if(!e)throw new Error(Rt(57));return e}const lo=o.memo(o.forwardRef(function(t,n){const{render:r,className:c,style:i,value:s=null,label:a,disabled:d=!1,nativeButton:m=!1,...C}=t,p=o.useRef(null),g=Xr({guess:!0,label:a,textRef:p}),{store:S,itemProps:T,setOpen:U,setValue:u,selectionRef:z,typingRef:K,valuesRef:V,multiple:b,selectedItemTextRef:I,disabled:j,readOnly:h}=Ue(),y=j||d,O=A(S,M.isActive,g.index),X=A(S,M.open),ee=A(S,M.isSelected,s),me=A(S,M.isSelectedByFocus,g.index),te=A(S,M.isItemEqualToValue),w=g.index,N=o.useRef(null);Z(()=>{const E=V.current;return E[w]=s,()=>{delete E[w]}},[w,s,V]),Z(()=>{const E=S.state.value;let L=E;b&&Array.isArray(E)&&(L=E.length>0?E[E.length-1]:void 0),L!==void 0&&Ge(s,L,te)&&(S.set("selectedIndex",w),p.current&&(I.current=p.current))},[w,b,te,S,s,I]);const ne=o.useRef("mouse"),B=o.useRef(!1),{getButtonProps:P,buttonRef:q}=Zt({disabled:y,focusableWhenDisabled:!0,native:m,composite:!0}),F={disabled:y,selected:ee,highlighted:O};function l(E){if(j||h)return;const L=S.state.value;if(b){const Y=Array.isArray(L)?L:[],ie=ee?Sr(Y,s,te):[...Y,s];u(ie,Ie(Tt,E))}else u(s,Ie(Tt,E)),U(!1,Ie(Tt,E))}function v(){z.current.dragY=0}const ce={role:"option","aria-selected":ee,tabIndex:X&&O?0:-1,onKeyDown(E){S.set("activeIndex",w),E.key===" "&&K.current&&E.preventDefault()},onClick(E){const L=ne.current!=="touch",Y=E.nativeEvent.pointerType,ie=L&&nn(E.nativeEvent)&&(Y!==void 0||O),ye=L&&!ie&&!B.current;B.current=!1,!(y||ye)&&l(E.nativeEvent)},onPointerEnter(E){ne.current=E.pointerType},onPointerMove(E){if(E.pointerType==="mouse"&&E.buttons===1){const L=z.current;L.dragY+=E.movementY,L.dragY**2>=64&&(L.allowUnselectedMouseUp=!0)}},onPointerDown(E){ne.current=E.pointerType,B.current=!0,v()},onMouseUp(){if(v(),y||ne.current==="touch"||B.current)return;const E=!z.current.allowSelectedMouseUp&&ee,L=!z.current.allowUnselectedMouseUp&&!ee;E||L||(B.current=!0,N.current?.click(),B.current=!1)}},_=Xe("div",t,{ref:[q,n,g.ref,N],state:F,props:[T,ce,C,P]}),ue=o.useMemo(()=>({selected:ee,index:w,textRef:p,selectedByFocus:me}),[ee,w,p,me]);return be.jsx(mn.Provider,{value:ue,children:_})})),co=o.forwardRef(function(t,n){const{selected:r}=Lt();return t.keepMounted||r?be.jsx(Jr,{...t,ref:n}):null}),Jr=o.memo(o.forwardRef((e,t)=>{const{render:n,className:r,style:c,keepMounted:i,...s}=e,{selected:a}=Lt(),d=o.useRef(null),{transitionStatus:m,setMounted:C}=rn(a),g=Xe("span",e,{ref:[t,d],state:{selected:a,transitionStatus:m},props:[{"aria-hidden":!0,children:"✔️"},s],stateAttributesMapping:en});return Vt({open:a,ref:d,onComplete(){a||C(!1)}}),g})),uo=o.memo(o.forwardRef(function(t,n){const{index:r,textRef:c,selectedByFocus:i}=Lt(),{firstItemTextRef:s,selectedItemTextRef:a}=Ue(),{render:d,className:m,style:C,...p}=t,g=o.useCallback(T=>{T&&(r===0&&(s.current=T),i&&(a.current=T))},[s,a,r,i]);return Xe("div",t,{ref:[g,n,c],props:p})}));export{jr as L,to as S,Wr as a,jt as b,no as c,ro as d,oo as e,so as f,io as g,lo as h,co as i,uo as j,hr as k,vr as l,Ft as m,sn as n,Wt as o,br as p,M as s,Ue as u};
1
+ import{bU as xn,aI as $e,aF as Z,be as Yt,bX as $t,bV as Rn,r as o,bd as Q,by as Mt,ch as Ht,ci as Et,cj as kt,b_ as Ct,bf as tt,aE as De,A as Ie,ck as Ut,bx as Bt,cl as st,aD as bn,bo as Gt,c0 as Xt,cm as ht,cn as xt,co as Jt,cp as Ot,bc as ft,c5 as yn,cq as In,cr as wt,ay as Rt,aJ as xe,Z as Qt,j as be,V as A,aA as Vt,aL as Pt,aK as Sn,aO as En,aP as Cn,aQ as gt,aG as Tn,b$ as vn,aN as dt,bR as Mn,y as Zt,z as Xe,cs as wn,aB as Pn,ct as An,aC as On,bh as Vn,cu as Fn,az as en,cv as Tt}from"./__vite-browser-external-DPOlUkcY.js";import{q as tn,F as Ln,P as Dn,v as ke,o as Nn,E as Hn,G as we,H as nn,D as kn,u as Un,m as rn,e as Bn,d as _n,z as Wn,I as jn,b as zn,a as Kn,C as qn}from"./composite-BDwOlhhX.js";import{h as Yn,u as $n,a as Gn,d as Xn,c as Jn,e as Qn,f as Zn,i as er,p as tr,r as nr,g as rr}from"./ToolbarRootContext-XUDMp5uy.js";function Ze(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function or(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,c=xn(),i=tn()!=null,s=$e(()=>new Ln({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Dn,floatingId:c,syncOnly:!1,nested:i})).current;return Z(()=>{const a={open:t,floatingId:c};r.reference!==void 0&&(a.referenceElement=r.reference,a.domReferenceElement=Yt(r.reference)?r.reference:null),r.floating!==void 0&&(a.floatingElement=r.floating),s.update(a)},[t,c,r.reference,r.floating,s]),s.context.onOpenChange=n,s.context.nested=i,s}const sr="Escape";function _t(e){return Xt&&e.movementX===0&&e.movementY===0}function bt(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function it(e,t){return bt(t,e===Jt||e===Ot,e===ht||e===xt)}function vt(e,t,n){return bt(t,e===Ot,n?e===ht:e===xt)||e==="Enter"||e===" "||e===""}function ir(e,t,n){return bt(t,n?e===ht:e===xt,e===Ot)}function lr(e,t,n,r){const c=n?e===xt:e===ht,i=e===Jt;return t==="both"||t==="horizontal"&&r?e===sr:bt(t,c,i)}function cr(e,t){const{listRef:n,activeIndex:r,onNavigate:c=()=>{},enabled:i=!0,selectedIndex:s=null,allowEscape:a=!1,loopFocus:d=!1,nested:m=!1,rtl:C=!1,virtual:p=!1,focusItemOnOpen:g="auto",focusItemOnHover:S=!0,openOnArrowKeyDown:T=!0,disabledIndices:U=void 0,orientation:u="vertical",parentOrientation:z,id:K,resetOnPointerLeave:V=!0,externalTree:b,grid:I}=t,j=I!=null,h="rootStore"in e?e.rootStore:e,y=h.useState("open"),O=h.useState("floatingElement"),X=h.useState("domReferenceElement"),ee=h.context.dataRef,me=$t(O),te=Rn(X),w=ke(me),N=tn(),ne=Nn(b),B=o.useRef(g),P=o.useRef(s??-1),q=o.useRef(null),F=o.useRef(!0),l=Q(f=>{c(P.current===-1?null:P.current,f)}),v=o.useRef(!!O),ce=o.useRef(y),_=o.useRef(!1),ue=o.useRef(!1),E=o.useRef(null),L=ke(U),Y=ke(y),ie=ke(s),ye=ke(V),H=Mt(),re=Mt(),J=Q(()=>{function f(k){p?ne?.events.emit("virtualfocus",k):E.current=Hn(k,{sync:_.current,preventScroll:!0})}const R=n.current[P.current],$=ue.current;R&&f(R),(_.current?k=>k():k=>H.request(k))(()=>{const k=n.current[P.current]||R;if(!k)return;R||f(k),he&&($||!F.current)&&k.scrollIntoView?.({block:"nearest",inline:"nearest"})})});Z(()=>{ee.current.orientation=u},[ee,u]),Z(()=>{i&&(y&&O?(P.current=s??-1,B.current&&s!=null&&(ue.current=!0,l())):v.current&&(P.current=-1,l()))},[i,y,O,s,l]),Z(()=>{if(i){if(!y){_.current=!1;return}if(O)if(r==null){if(_.current=!1,ie.current!=null)return;if(v.current&&(P.current=-1,J()),(!ce.current||!v.current)&&B.current&&(q.current!=null||B.current===!0&&q.current==null)){let f=0;const R=()=>{n.current[0]==null?(f<2&&(f?x=>re.request(x):queueMicrotask)(R),f+=1):(P.current=q.current==null||vt(q.current,u,C)||m?Et(n):kt(n),q.current=null,l())};R()}}else Ht(n.current,r)||(P.current=r,J(),ue.current=!1)}},[i,y,O,r,ie,m,n,u,C,l,J,re]),Z(()=>{if(!i||O||!ne||p||!v.current)return;const f=ne.nodesRef.current,R=f.find(k=>k.id===N)?.context?.elements.floating,$=Ct(tt(X??R??null)),x=f.some(k=>k.context&&De(k.context.elements.floating,$));R&&!x&&F.current&&R.focus({preventScroll:!0})},[i,O,X,ne,N,p]),Z(()=>{ce.current=y,v.current=!!O}),Z(()=>{y||(q.current=null,B.current=g)},[y,g]);const Re=r!=null,le=Q(f=>{if(!Y.current)return;const R=n.current.indexOf(f.currentTarget);R!==-1&&(P.current!==R||r!==R)&&(P.current=R,l(f))}),ae=Q(()=>z??ne?.nodesRef.current.find(f=>f.id===N)?.context?.dataRef?.current.orientation),ge=Q(()=>Et(n,L.current)),fe=Q(f=>{if(F.current=!1,_.current=!0,f.which===229||!Y.current&&f.currentTarget===w.current)return;if(m&&lr(f.key,u,C,j)){it(f.key,ae())||we(f),h.setOpen(!1,Ie(Ut,f.nativeEvent)),Bt(X)&&(p?ne?.events.emit("virtualfocus",X):X.focus());return}const R=P.current,$=Et(n,U),x=kt(n,U);if(te||(f.key==="Home"&&(we(f),P.current=$,l(f)),f.key==="End"&&(we(f),P.current=x,l(f))),I!=null){const k=I(f,P.current,n,u,d,C,U,$,x);if(k!=null&&(P.current=k,l(f)),u==="both")return}if(it(f.key,u)){if(we(f),y&&!p&&Ct(f.currentTarget.ownerDocument)===f.currentTarget){P.current=vt(f.key,u,C)?$:x,l(f);return}vt(f.key,u,C)?d?R>=x?a&&R!==n.current.length?P.current=-1:(_.current=!1,P.current=$):P.current=st(n.current,{startingIndex:R,disabledIndices:U}):P.current=Math.min(x,st(n.current,{startingIndex:R,disabledIndices:U})):d?R<=$?a&&R!==-1?P.current=n.current.length:(_.current=!1,P.current=x):P.current=st(n.current,{startingIndex:R,decrement:!0,disabledIndices:U}):P.current=Math.max($,st(n.current,{startingIndex:R,decrement:!0,disabledIndices:U})),Ht(n.current,P.current)&&(P.current=-1),l(f)}}),he=o.useMemo(()=>({onFocus(R){_.current=!0,le(R)},onClick:({currentTarget:R})=>R.focus({preventScroll:!0}),onMouseMove(R){_t(R)||(_.current=!0,ue.current=!1,S&&le(R))},onPointerLeave(R){if(!Y.current||!F.current||R.pointerType==="touch")return;_.current=!0;const $=R.relatedTarget;if(!(!S||n.current.includes($))&&ye.current&&(E.current?.(),E.current=null,P.current=-1,l(R),!p)){const x=w.current,k=Ct(tt(x));x&&De(x,k)&&x.focus({preventScroll:!0})}}}),[le,Y,w,S,n,l,ye,p]),G=o.useMemo(()=>p&&y&&Re&&{"aria-activedescendant":`${K}-${r}`},[p,y,Re,K,r]),oe=o.useMemo(()=>({"aria-orientation":u==="both"?void 0:u,...te?{}:G,onKeyDown(f){if(f.key==="Tab"&&f.shiftKey&&y&&!p){const R=bn(f.nativeEvent);if(R&&!De(w.current,R))return;we(f),h.setOpen(!1,Ie(Gt,f.nativeEvent)),Bt(X)&&X.focus();return}fe(f)},onPointerMove(f){_t(f)||(F.current=!0)}}),[G,fe,w,u,te,h,y,p,X]),pe=o.useMemo(()=>{function f(x){h.setOpen(!0,Ie(Ut,x.nativeEvent,x.currentTarget))}function R(x){g==="auto"&&nn(x.nativeEvent)&&(B.current=!p)}function $(x){B.current=g,g==="auto"&&kn(x.nativeEvent)&&(B.current=!0)}return{onKeyDown(x){const k=h.select("open");F.current=!1;const Ce=x.key.startsWith("Arrow"),de=ir(x.key,ae(),C),Be=it(x.key,u),_e=(m?de:Be)||x.key==="Enter"||x.key.trim()==="";if(p&&k)return fe(x);if(!(!k&&!T&&Ce)){if(_e){const Se=it(x.key,ae());q.current=m&&Se?null:x.key}if(m){de&&(we(x),k?(P.current=ge(),l(x)):f(x));return}Be&&(ie.current!=null&&(P.current=ie.current),we(x),!k&&T?f(x):fe(x),k&&l(x))}},onFocus(x){h.select("open")&&!p&&(P.current=-1,l(x))},onPointerDown:$,onPointerEnter:$,onMouseDown:R,onClick:R}},[fe,g,ge,m,l,h,T,u,ae,C,ie,p]),D=o.useMemo(()=>({...G,...pe}),[G,pe]);return o.useMemo(()=>i?{reference:D,floating:oe,item:he,trigger:pe}:{},[i,D,oe,pe,he])}function ur(e,t){const{listRef:n,elementsRef:r,activeIndex:c,onMatch:i,disabledIndices:s,onTyping:a,enabled:d=!0,resetMs:m=750,selectedIndex:C=null}=t,p="rootStore"in e?e.rootStore:e,g=p.useState("open"),S=ft(),T=o.useRef(""),U=o.useRef(C??c??-1),u=o.useRef(null),z=Q(b=>{function I(w){return r?.current[w]}function j(w){const N=I(w);return N&&!yn(N)||N?.matches(":disabled")?!1:s==null||!In(wt,w,s)}function h(w,N,ne=0){if(w.length===0)return-1;const B=(ne%w.length+w.length)%w.length,P=N.toLowerCase();for(let q=0;q<w.length;q+=1){const F=(B+q)%w.length;if(!(!w[F]?.toLowerCase().startsWith(P)||!j(F)))return F}return-1}const y=n.current;if(T.current.length>0&&b.key===" "&&(we(b),a?.(!0)),T.current.length>0&&T.current[0]!==" "&&h(y,T.current)===-1&&b.key!==" "&&a?.(!1),y==null||b.key.length!==1||b.ctrlKey||b.metaKey||b.altKey)return;g&&b.key!==" "&&(we(b),a?.(!0));const O=T.current==="";O&&(U.current=C??c??-1),y.every((w,N)=>w&&j(N)?w[0]?.toLowerCase()!==w[1]?.toLowerCase():!0)&&T.current===b.key&&(T.current="",U.current=u.current),T.current+=b.key,S.start(m,()=>{T.current="",U.current=u.current,a?.(!1)});const me=((O?C??c??-1:U.current)??0)+1,te=h(y,T.current,me);te!==-1?(i?.(te),u.current=te):b.key!==" "&&(T.current="",a?.(!1))}),K=Q(b=>{const I=b.relatedTarget,j=p.select("domReferenceElement"),h=p.select("floatingElement");De(j,I)||De(h,I)||(S.clear(),T.current="",U.current=u.current,a?.(!1))});Z(()=>{!g&&C!==null||(S.clear(),u.current=null,T.current!==""&&(T.current=""))},[g,C,S]);const V=o.useMemo(()=>({onKeyDown:z,onBlur:K}),[z,K]);return o.useMemo(()=>d?{reference:V,floating:V}:{},[d,V])}function ar(e){const[t,n]=o.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function fr(e){const t=o.useRef(!0);t.current&&(t.current=!1,e())}function dr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Wt({controlled:e,default:t,name:n,state:r="value"}){const{current:c}=o.useRef(e!==void 0),[i,s]=o.useState(t),a=c?e:i,d=o.useCallback(m=>{c||s(m)},[]);return[a,d]}const on=o.createContext(null);function Ue(){const e=o.useContext(on);if(e===null)throw new Error(Rt(60));return e}const pr={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},gr={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},mr={disabled:!1,...gr},hr={valid(e){return e===null?null:e?{"data-valid":""}:{"data-invalid":""}}},xr={invalid:void 0,name:void 0,validityData:{state:pr,errors:[],error:"",value:"",initialValue:null},setValidityData:xe,disabled:void 0,setTouched:xe,setDirty:xe,setFilled:xe,setFocused:xe,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:mr,registerFieldControl:xe,validation:{getValidationProps:(e,t=Qt)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:xe,getInputControl:()=>null,commit:async()=>{},change:xe}},Rr=o.createContext(xr);function Ft(e=!0){const t=o.useContext(Rr);if(t.setValidityData===xe&&!e)throw new Error(Rt(28));return t}function br(e,t,n,r,c=!0,i){const{registerFieldControl:s}=Ft(),a=$e(()=>Symbol());Z(()=>{const d=a.current;if(!c){s(d,void 0);return}s(d,{controlRef:e,getValue:r,id:t,name:i,value:n})},[e,c,r,t,i,s,a,n]),Z(()=>{const d=a.current;return()=>{s(d,void 0)}},[s,a])}const yr=o.createContext({controlId:void 0,registerControlId:xe,labelId:void 0,setLabelId:xe,messageIds:[],setMessageIds:xe,getDescriptionProps:e=>e});function sn(){return o.useContext(yr)}function ln(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:c,registerControlId:i}=sn(),s=Un(t),a=n?c:void 0,d=$e(()=>Symbol()),m=o.useRef(!1),C=o.useRef(t!=null),p=Q(()=>{!m.current||i===xe||(m.current=!1,i(d.current,void 0))});return Z(()=>{if(i===xe)return;let g;if(n){const S=r?.current;Yt(S)&&S.closest("label")!=null?g=t??null:g=a??s}else if(t!=null)C.current=!0,g=t;else if(C.current)g=s;else{p();return}if(g===void 0){p();return}m.current=!0,i(d.current,g)},[t,r,a,i,n,s,d,p]),o.useEffect(()=>p,[p]),c??s}const Ir=(e,t)=>Object.is(e,t);function Ge(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function pt(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:Ge(r,t,n))}function Sr(e,t,n){return e.filter(r=>!Ge(t,r,n))}function At(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function cn(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Er(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(cn(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function un(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return At(e)}function Ye(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?At(e.value):At(e)}function an(e,t,n){function r(){return un(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){const c=t,i=cn(c)?c.flatMap(s=>s.items):c;if(e==null||typeof e!="object"){const s=i.find(a=>a.value===e);return s&&s.label!=null?s.label:r()}if("value"in e){const s=i.find(a=>a&&a.value===e.value);if(s&&s.label!=null)return s.label}}return r()}function Cr(e,t,n){return e.reduce((r,c,i)=>(i>0&&r.push(", "),r.push(be.jsx(o.Fragment,{children:an(c,t,n)},i)),r),[])}const M={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{const{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Ye(t,r)!==""},hasNullItemLabel:(e,t)=>t?Er(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(c=>Ge(t,c,n)):Ge(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},Tr=o.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:xe,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function vr(){return o.useContext(Tr)}function Mr(e,t,n=(r,c)=>r===c){return e.length===t.length&&e.every((r,c)=>n(r,t[c]))}const Pe=1;function fn(e,t){return Math.max(0,e-t)}function wr(e,t){if(t<=0)return 0;const n=Ze(e,0,t),r=n,c=t-n,i=r<=Pe,s=c<=Pe;return i&&s?r<=c?0:t:i?0:s?t:n}function to(e){const{id:t,value:n,defaultValue:r=null,onValueChange:c,open:i,defaultOpen:s=!1,onOpenChange:a,name:d,form:m,autoComplete:C,disabled:p=!1,readOnly:g=!1,required:S=!1,modal:T=!0,actionsRef:U,inputRef:u,onOpenChangeComplete:z,items:K,multiple:V=!1,itemToStringLabel:b,itemToStringValue:I,isItemEqualToValue:j=Ir,highlightItemOnHover:h=!0,children:y}=e,{clearErrors:O}=vr(),{setDirty:X,setTouched:ee,setFocused:me,validityData:te,setFilled:w,name:N,disabled:ne,validation:B,validationMode:P}=Ft(),q=ln({id:t}),F=ne||p,l=N??d,[v,ce]=Wt({controlled:n,default:V?r??wt:r,name:"Select",state:"value"}),[_,ue]=Wt({controlled:i,default:s,name:"Select",state:"open"}),E=o.useRef([]),L=o.useRef([]),Y=o.useRef(null),ie=o.useRef(null),ye=o.useRef(0),H=o.useRef(null),re=o.useRef([]),J=o.useRef(!1),Re=o.useRef(null),le=o.useRef(null),ae=o.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ge=o.useRef(!1),{mounted:fe,setMounted:he,transitionStatus:G}=rn(_),{openMethod:oe,triggerProps:pe}=Yn(_),D=$e(()=>new Tn({id:q,labelId:void 0,modal:T,multiple:V,itemToStringLabel:b,itemToStringValue:I,isItemEqualToValue:j,value:v,open:_,mounted:fe,transitionStatus:G,items:K,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,f=A(D,M.activeIndex),R=A(D,M.selectedIndex),$=A(D,M.triggerElement),x=A(D,M.positionerElement),k=ar(oe),Ce=oe??k,de=o.useMemo(()=>V?"":Ye(v,I),[V,v,I]),Be=o.useMemo(()=>V&&Array.isArray(v)?v.map(W=>Ye(W,I)):Ye(v,I),[V,v,I]),_e=ke($),Se=Q(()=>Be);br(_e,q,v,Se,!F,d);const yt=o.useRef(v),Je=V?Array.isArray(v)&&v.length>0:v!=null&&de!=="";Z(()=>{w(Je)},[Je,w]),Z(function(){let se=v,Me=!1;if(V){const He=Array.isArray(v)?v:[];Me=He.length===0,se=He[He.length-1]}const Fe=Me?-1:pt(re.current,se,j),Le=Fe===-1?null:Fe;Le===null&&(le.current=null),!_&&D.set("selectedIndex",Le)},[V,_,v,j,D]);function Te(W){const se=te.initialValue;return Array.isArray(W)&&Array.isArray(se)?!Mr(W,se,(Me,Fe)=>Ge(Me,Fe,j)):W!==se}$n(v,()=>{O(l),X(Te(v)),B.change(v)});const We=Q((W,se)=>{a?.(W,se),!se.isCanceled&&(ue(W),!W&&(se.reason===Gt||se.reason===vn)&&(ee(!0),me(!1),P==="onBlur"&&B.commit(v)))}),je=Q(()=>{he(!1),D.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),z?.(!1)});Vt({enabled:!U,open:_,ref:Y,onComplete(){_||je()}}),o.useImperativeHandle(U,()=>({unmount:je}),[je]);const Ae=Q((W,se)=>{c?.(W,se),!se.isCanceled&&ce(W)}),ve=Q(W=>{const se=fn(W.scrollHeight,W.clientHeight),Me=wr(W.scrollTop,se),Fe=Me>0,Le=Me<se;D.set("scrollUpArrowVisible",Fe),D.set("scrollDownArrowVisible",Le)}),Oe=or({open:_,onOpenChange:We,elements:{reference:$,floating:x}}),ze=Gn(Oe,{enabled:!g&&!F,event:"mousedown"}),Ke=Bn(Oe),Ve=cr(Oe,{enabled:!g&&!F,listRef:E,activeIndex:f,selectedIndex:R,disabledIndices:wt,onNavigate(W){W===null&&!_||D.set("activeIndex",W)},focusItemOnHover:h}),Ne=ur(Oe,{enabled:!g&&!F&&(_||!V),listRef:L,activeIndex:f,selectedIndex:R,disabledIndices:W=>dr(E.current[W]),onMatch(W){_?D.set("activeIndex",W):Ae(re.current[W],Ie(gt))},onTyping(W){J.current=W}}),nt=o.useMemo(()=>Pt(Ne.reference,Ve.reference,Ke.reference,ze.reference,pe),[ze.reference,Ne.reference,Ve.reference,Ke.reference,pe]),rt=o.useMemo(()=>Pt(_n,Ne.floating,Ve.floating,Ke.floating),[Ne.floating,Ve.floating,Ke.floating]),ot=Ve.item??Qt;fr(()=>{D.update({popupProps:rt,triggerProps:nt})}),D.useSyncedValues({id:q,modal:T,multiple:V,value:v,open:_,mounted:fe,transitionStatus:G,popupProps:rt,triggerProps:nt,items:K,itemToStringLabel:b,itemToStringValue:I,isItemEqualToValue:j,openMethod:Ce});const Ee=o.useMemo(()=>({store:D,floatingContext:Oe,required:S,disabled:F,readOnly:g,multiple:V,highlightItemOnHover:h,setValue:Ae,setOpen:We,listRef:E,popupRef:Y,scrollHandlerRef:ie,handleScrollArrowVisibility:ve,scrollArrowsMountedCountRef:ye,itemProps:ot,valueRef:H,valuesRef:re,labelsRef:L,typingRef:J,selectionRef:ae,firstItemTextRef:Re,selectedItemTextRef:le,validation:B,onOpenChangeComplete:z,alignItemWithTriggerActiveRef:ge,initialValueRef:yt}),[D,Oe,S,F,g,V,h,Ae,We,ot,B,z,ve]),qe=Sn(u,B.inputRef),Qe=V?void 0:l,It=o.useMemo(()=>!V||!Array.isArray(v)||!l?null:v.map(W=>{const se=Ye(W,I);return be.jsx("input",{type:"hidden",form:m,name:l,value:se,disabled:F},se)}),[V,v,m,l,I,F]);return be.jsxs(on.Provider,{value:Ee,children:[y,be.jsx("input",{...B.getValidationProps(F,{onFocus(){D.state.triggerElement?.focus({focusVisible:!0})},onChange(W){if(W.nativeEvent.defaultPrevented||F||g)return;const se=W.currentTarget.value,Me=Ie(gt,W.nativeEvent);function Fe(){if(V)return;const Le=se.toLowerCase();let He=re.current.findIndex(St=>Ye(St,I).toLowerCase()===Le||un(St,b).toLowerCase()===Le);He===-1&&(He=re.current.findIndex((St,hn)=>{const Nt=L.current[hn];return Nt!=null&&Nt.toLowerCase()===Le}));const Dt=re.current[He];Dt!=null&&Ae(Dt,Me)}D.set("forceMount",!0),queueMicrotask(Fe)}}),id:q&&Qe==null?`${q}-hidden-input`:void 0,form:m,name:Qe,autoComplete:C,value:de,disabled:F,required:S&&!(V&&Je),readOnly:g,ref:qe,style:l?En:Cn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),It]})}function Pr(e,t){return e??t}const lt=5;function Ar(e,t){const n=Or(t);return e.clientX>=n.left-lt&&e.clientX<=n.right+lt&&e.clientY>=n.top-lt&&e.clientY<=n.bottom+lt}function Or(e){const t=e.getBoundingClientRect(),n=dt(e);if(Mn)return t;const r=n.getComputedStyle(e,"::before"),c=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||c.content!=="none"))return t;const s=parseFloat(r.width)||0,a=parseFloat(r.height)||0,d=parseFloat(c.width)||0,m=parseFloat(c.height)||0,C=Math.max(t.width,s,d),p=Math.max(t.height,a,m),g=C-t.width,S=p-t.height;return{left:t.left-g/2,right:t.right+g/2,top:t.top-S/2,bottom:t.bottom+S/2}}const Vr=400,Fr={...Wn,...hr,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},no=o.forwardRef(function(t,n){const{render:r,className:c,id:i,disabled:s=!1,nativeButton:a=!0,style:d,...m}=t,{setTouched:C,setFocused:p,validationMode:g,state:S,disabled:T}=Ft(),{labelId:U}=sn(),{store:u,setOpen:z,selectionRef:K,validation:V,readOnly:b,required:I,alignItemWithTriggerActiveRef:j,disabled:h}=Ue(),y=T||h||s,O=A(u,M.open),X=A(u,M.mounted),ee=A(u,M.value),me=A(u,M.triggerProps),te=A(u,M.positionerElement),w=A(u,M.listElement),N=A(u,M.popupSide),ne=A(u,M.id),B=A(u,M.labelId),P=A(u,M.hasSelectedValue),q=X&&te?N:null,F=i??ne,l=Pr(U,B);ln({id:F});const v=ke(te),ce=o.useRef(null),{getButtonProps:_,buttonRef:ue}=Zt({disabled:y,native:a}),E=u.useStateSetter("triggerElement"),L=ft(),Y=ft(),ie=ft();o.useEffect(()=>{if(O)return ie.start(Vr,()=>{K.current.allowUnselectedMouseUp=!0,K.current.allowSelectedMouseUp=!0}),()=>{ie.clear()};K.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},Y.clear()},[O,K,Y,ie]);const ye=Pt(me,{id:F,role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-controls":O?w?.id??$t(te)?.id:void 0,"aria-labelledby":l,"aria-readonly":b||void 0,"aria-required":I||void 0,tabIndex:y?-1:0,onFocus(J){p(!0),O&&j.current&&z(!1,Ie(gt,J.nativeEvent)),L.start(0,()=>{u.set("forceMount",!0)})},onBlur(J){De(te,J.relatedTarget)||(C(!0),p(!1),g==="onBlur"&&V.commit(ee))},onMouseDown(J){if(O)return;const Re=tt(J.currentTarget);function le(ae){if(!ce.current)return;const ge=ae.target;De(ce.current,ge)||De(v.current,ge)||Ar(ae,ce.current)||z(!1,Ie(wn,ae))}Y.start(0,()=>{Re.addEventListener("mouseup",le,{once:!0})})}},m,_),H=V.getValidationProps(y,ye);H.role="combobox";const re={...S,open:O,disabled:y,value:ee,readOnly:b,popupSide:q,placeholder:!P};return Xe("button",t,{ref:[n,ce,ue,E],state:re,stateAttributesMapping:Fr,props:H})}),Lr={value:()=>null},ro=o.forwardRef(function(t,n){const{className:r,render:c,children:i,placeholder:s,style:a,...d}=t,{store:m,valueRef:C}=Ue(),p=A(m,M.value),g=A(m,M.items),S=A(m,M.itemToStringLabel),T=A(m,M.hasSelectedValue),U=!T&&s!=null&&i==null,u=A(m,M.hasNullItemLabel,U),z={value:p,placeholder:!T};let K=null;return typeof i=="function"?K=i(p):i!=null?K=i:U&&!u?K=s:Array.isArray(p)?K=Cr(p,g,S):K=an(p,g,S),Xe("span",t,{state:z,ref:[n,C],props:[{children:K},d],stateAttributesMapping:Lr})}),oo=o.forwardRef(function(t,n){const{store:r}=Ue(),c=A(r,M.mounted),i=A(r,M.forceMount);return c||i?be.jsx(Pn,{ref:n,...t}):null}),dn=o.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Dr(){return o.useContext(dn)}function Nr(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:c}=e,i=Q(c),[,s]=o.useState(!1),a=$e(kr).current,d=$e(Hr).current,m=o.useRef(0),C=o.useRef(!0),p=o.useRef([]),g=o.useRef(null),S=Q(()=>{C.current||(C.current=!0,s(I=>!I))}),T=Q((I,j)=>{d.set(I,j),S()}),U=Q(I=>{d.delete(I),S()}),u=Q(I=>{const j=new Map;return n.current.length=0,r&&(r.current.length=0),I.forEach(h=>{j.set(h.element,{...h.registration.metadata??{},index:h.index}),n.current[h.index]=h.element,r&&(r.current[h.index]=h.registration.label!==void 0?h.registration.label:h.registration.textRef?.current?.textContent??h.element.textContent)}),m.current=n.current.length,j});function z(I){if(g.current?.disconnect(),g.current=null,typeof MutationObserver!="function"||I.length<2)return;const j=new MutationObserver(y=>{if(!_r(y))return;let O=null;for(const X of I)if(X.isConnected){if(O&&pn(O,X)>0){j.disconnect(),S();return}O=X}});g.current=j;const h=new Set;for(let y=1;y<I.length;y+=1){const O=Br(I[y-1],I[y]);O&&h.add(O)}h.forEach(y=>j.observe(y,{childList:!0}))}const K=Q(()=>{const[I,j]=Ur(d),h=u(I);z(j),p.current=I,C.current=!1,a.forEach(y=>y(h)),i(h)});Z(()=>(C.current||u(p.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,u]),Z(()=>{C.current&&K()}),Z(()=>()=>{g.current?.disconnect(),C.current=!0},[]);const V=Q(I=>(a.add(I),()=>{a.delete(I)})),b=o.useMemo(()=>({register:T,unregister:U,subscribeMapChange:V,nextIndexRef:m}),[T,U,V,m]);return be.jsx(dn.Provider,{value:b,children:t})}function Hr(){return new Map}function kr(){return new Set}function Ur(e){const t=new Set,n=[],r=[];e.forEach((i,s)=>{if(!s.isConnected)return;const a=i.index,d={index:a??-1,element:s,registration:i};a===null?r.push(d):a>=0&&(t.add(a),n.push(d))});let c=0;return r.sort((i,s)=>pn(i.element,s.element)),r.forEach(i=>{for(;t.has(c);)c+=1;i.index=c,n.push(i),c+=1}),t.size>0&&n.sort((i,s)=>i.index-s.index),[n,r.map(i=>i.element)]}function Br(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function _r(e){for(const t of e)for(let n=0;n<t.removedNodes.length;n+=1)if(t.removedNodes[n].isConnected)return!0;return!1}function pn(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}const gn=o.createContext(void 0);function Wr(){const e=o.useContext(gn);if(!e)throw new Error(Rt(59));return e}function mt(e,t){e&&Object.assign(e.style,t)}const jr={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},zr={position:"fixed"},so=o.forwardRef(function(t,n){const{anchor:r,className:c,render:i,positionMethod:s,side:a,align:d,sideOffset:m,alignOffset:C,collisionBoundary:p="clipping-ancestors",collisionPadding:g,arrowPadding:S,sticky:T,disableAnchorTracking:U,alignItemWithTrigger:u=!0,collisionAvoidance:z=An,style:K,...V}=t,{store:b,listRef:I,labelsRef:j,alignItemWithTriggerActiveRef:h,selectedItemTextRef:y,valuesRef:O,initialValueRef:X,popupRef:ee,setValue:me,floatingContext:te}=Ue(),w=A(b,M.open),N=A(b,M.mounted),ne=A(b,M.modal),B=A(b,M.value),P=A(b,M.openMethod),q=A(b,M.positionerElement),F=A(b,M.triggerElement),l=A(b,M.isItemEqualToValue),v=A(b,M.transitionStatus),ce=o.useRef(null),_=o.useRef(null),[ue,E]=o.useState(u),L=N&&ue&&P!=="touch";!N&&ue!==u&&E(u),o.useImperativeHandle(h,()=>L),Xn((L||ne)&&w,P==="touch",q,F);const Y=Jn({anchor:r,floatingRootContext:te,positionMethod:s,mounted:N,side:a,sideOffset:m,align:d,alignOffset:C,arrowPadding:S,collisionBoundary:p,collisionPadding:g,sticky:T,disableAnchorTracking:U??L,collisionAvoidance:z,keepMounted:!0}),ie=L?"none":Y.side,ye=L?zr:Y.positionerStyles,H={open:w,side:ie,align:Y.align,anchorHidden:Y.anchorHidden};Z(()=>{b.set("popupSide",Y.side)},[b,Y.side]);const re=b.useStateSetter("positionerElement"),J=Qn(t,H,{styles:ye,transitionStatus:v,props:V,refs:[n,re],hidden:!N,inert:!w}),Re=o.useRef(0),le=Q(ge=>{if(O.current.length===0)return;const fe=Re.current;if(Re.current=ge.size,ge.size===fe)return;const he=Ie(gt);if(fe!==0&&!b.state.multiple&&B!==null&&pt(O.current,B,l)===-1){const oe=X.current,D=oe!=null&&pt(O.current,oe,l)!==-1?oe:null;me(D,he),D===null&&(b.set("selectedIndex",null),y.current=null)}if(fe!==0&&b.state.multiple&&Array.isArray(B)){const G=B.filter(oe=>pt(O.current,oe,l)!==-1);G.length!==B.length&&(me(G,he),G.length===0&&(b.set("selectedIndex",null),y.current=null))}if(w&&L){b.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const G={height:""};mt(q,G),mt(ee.current,G)}}),ae=o.useMemo(()=>({...Y,side:ie,alignItemWithTriggerActive:L,setControlledAlignItemWithTrigger:E,scrollUpArrowRef:ce,scrollDownArrowRef:_}),[Y,ie,L,E]);return be.jsx(Nr,{elementsRef:I,labelsRef:j,onMapChange:le,children:be.jsxs(gn.Provider,{value:ae,children:[N&&ne&&be.jsx(jn,{inert:On(!w),cutout:F}),J]})})}),ct="base-ui-disable-scrollbar",jt={className:ct,getElement(e){return be.jsx("style",{nonce:e,href:ct,precedence:"base-ui:low",children:`.${ct}{scrollbar-width:none}.${ct}::-webkit-scrollbar{display:none}`})}},Kr=o.createContext(void 0),qr={disableStyleElements:!1};function Yr(){return o.useContext(Kr)??qr}const $r={...Kn,...en},io=o.forwardRef(function(t,n){const{render:r,className:c,style:i,finalFocus:s,...a}=t,{store:d,popupRef:m,onOpenChangeComplete:C,setOpen:p,valueRef:g,firstItemTextRef:S,selectedItemTextRef:T,multiple:U,handleScrollArrowVisibility:u,scrollHandlerRef:z,listRef:K,highlightItemOnHover:V,floatingContext:b}=Ue(),{side:I,align:j,alignItemWithTriggerActive:h,isPositioned:y,setControlledAlignItemWithTrigger:O}=Wr(),X=Zn()!=null,ee=er(),{nonce:me,disableStyleElements:te}=Yr(),w=A(d,M.id),N=A(d,M.open),ne=A(d,M.openMethod),B=A(d,M.mounted),P=A(d,M.popupProps),q=A(d,M.transitionStatus),F=A(d,M.triggerElement),l=A(d,M.positionerElement),v=A(d,M.listElement),ce=o.useRef(!1),_=o.useRef(!1),ue=o.useRef({}),E=Mt(),L=Q(H=>{if(!l||!m.current||!_.current)return;const re=l.style.top==="0px",J=l.style.bottom==="0px";if(ce.current||!h||!re&&!J){u(H);return}const Re=Kt(l),le=et(l.getBoundingClientRect().height,"y",Re),ae=tt(l),ge=dt(l),fe=ge.getComputedStyle(l),he=parseFloat(fe.marginTop),G=parseFloat(fe.marginBottom),oe=zt(ge.getComputedStyle(m.current)),pe=Math.min(ae.documentElement.clientHeight-he-G,oe),D=H.scrollTop,f=ut(H);let R=null;const $=de=>{l.style.height=`${de}px`},x=re?f-D:D,k=Math.min(le+x,pe);if(x<=Pe){const de=Ze(x,0,pe-le);de>0&&$(le+de),H.scrollTop=re?f:0,pe-(le+de)<=Pe&&(ce.current=!0),u(H);return}if(pe-k>Pe)R=re?1/0:0;else if(J&&D<f){const de=le+x-pe;R=D-(x-de)}const Ce=Math.ceil(k);if(Ce!==0&&$(Ce),R!=null){const de=Ze(R,0,ut(H));Math.abs(H.scrollTop-de)>Pe&&(H.scrollTop=de)}Ce>=pe-Pe&&(ce.current=!0),u(H)});o.useImperativeHandle(z,()=>L,[L]),Vt({open:N,ref:m,onComplete(){N&&C?.(!0)}});const Y={open:N,transitionStatus:q,side:I,align:j};Z(()=>{!l||!m.current||Object.keys(ue.current).length||(ue.current={top:l.style.top||"0",left:l.style.left||"0",right:l.style.right,height:l.style.height,bottom:l.style.bottom,minHeight:l.style.minHeight,maxHeight:l.style.maxHeight,marginTop:l.style.marginTop,marginBottom:l.style.marginBottom})},[m,l]),Z(()=>{N||h||(_.current=!1,ce.current=!1,mt(l,ue.current))},[N,h,l,m]),Z(()=>{const H=m.current;if(!N||!F||!l||!H||h&&!y||d.state.transitionStatus==="ending")return;if(_.current=!0,H.style.removeProperty("--transform-origin"),!h){E.request(()=>u(v||H));return}const re=Gr(H);try{let J=T.current;J?.isConnected||(J=!M.hasSelectedValue(d.state)&&S.current?.isConnected?S.current:null);const Re=g.current,le=dt(l),ae=le.getComputedStyle(l),ge=le.getComputedStyle(H),fe=tt(F),he=Kt(F),G=at(F.getBoundingClientRect(),he),oe=at(l.getBoundingClientRect(),he),pe=G.height,D=v||H,f=D.scrollHeight,R=parseFloat(ge.borderBottomWidth),$=parseFloat(ae.marginTop)||10,x=parseFloat(ae.marginBottom)||10,k=parseFloat(ae.minHeight)||100,Ce=zt(ge),de=5,Be=5,_e=20,Se=fe.documentElement.clientHeight-$-x,yt=fe.documentElement.clientWidth,Je=Se-G.bottom+pe;let Te,We=ee==="rtl"?G.right-oe.width:G.left,je=0;if(J&&Re){const Ee=at(Re.getBoundingClientRect(),he);Te=at(J.getBoundingClientRect(),he),We=oe.left+(ee==="rtl"?Ee.right-Te.right:Ee.left-Te.left);const qe=Ee.top-G.top+Ee.height/2;je=Te.top-oe.top+Te.height/2-qe}const Ae=Je+je+x+R;let ve=Math.min(Se,Ae);const Oe=Se-$-x,ze=Ae-ve,Ke=yt-Be;l.style.left=`${Ze(We,de,Ke-oe.width)}px`,l.style.height=`${ve}px`,l.style.maxHeight="none",l.style.marginTop=`${$}px`,l.style.marginBottom=`${x}px`,H.style.height="100%";const Ve=ut(D),Ne=ze>=Ve-Pe;Ne&&(ve=Math.min(Se,oe.height)-(ze-Ve));const nt=G.top<_e||G.bottom>Se-_e||Math.ceil(ve)+Pe<Math.min(f,k),rt=(le.visualViewport?.scale??1)!==1&&Xt;if(nt||rt){mt(l,ue.current),O(!1);return}const ot=Math.max(k,ve);if(Ne){const Ee=Math.max(0,Se-Ae);l.style.top=oe.height>=Oe?"0":`${Ee}px`,l.style.height=`${ve}px`,D.scrollTop=ut(D)}else l.style.bottom="0",D.scrollTop=ze;if(Te){const Ee=oe.top,qe=oe.height,Qe=Te.top+Te.height/2,It=Ze(qe>0?(Qe-Ee)/qe*100:50,0,100);H.style.setProperty("--transform-origin",`50% ${It}%`)}(ot===Se||ve>=Ce)&&(ce.current=!0),u(D),V&&d.state.selectedIndex===null&&d.state.activeIndex===null&&K.current[0]!=null&&d.set("activeIndex",0)}finally{re()}},[d,N,l,F,g,S,T,m,u,h,O,E,v,K,V,ee,y]),o.useEffect(()=>{if(!h||!l||!N)return;const H=dt(l);function re(J){p(!1,Ie(Fn,J))}return Vn(H,"resize",re)},[p,h,l,N]);const ie={...v?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":U||void 0,id:`${w}-list`},onKeyDown(H){X&&qn.has(H.key)&&H.stopPropagation()},onScroll(H){v||L(H.currentTarget)},...h&&{style:v?{height:"100%"}:jr},className:!v&&h?jt.className:void 0},ye=Xe("div",t,{ref:[n,m],state:Y,stateAttributesMapping:$r,props:[P,ie,rr(q),a]});return be.jsxs(o.Fragment,{children:[!te&&jt.getElement(me),be.jsx(zn,{context:b,modal:!1,disabled:!B,openInteractionType:ne,returnFocus:s,restoreFocus:!0,children:ye})]})});function zt(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function ut(e){return fn(e.scrollHeight,e.clientHeight)}function Kt(e){return tr.getScale(e)}function et(e,t,n){return e/n[t]}function at(e,t){return nr({x:et(e.x,"x",t),y:et(e.y,"y",t),width:et(e.width,"x",t),height:et(e.height,"y",t)})}const qt=[["transform","none"],["scale","1"],["translate","0 0"]];function Gr(e){const{style:t}=e,n={};for(const[r,c]of qt)n[r]=t.getPropertyValue(r),t.setProperty(r,c,"important");return()=>{for(const[r]of qt){const c=n[r];c?t.setProperty(r,c):t.removeProperty(r)}}}function Xr(e={}){const{guess:t,label:n,metadata:r,textRef:c,index:i}=e,{register:s,unregister:a,subscribeMapChange:d,nextIndexRef:m}=Dr(),C=o.useRef(-1),[p,g]=o.useState(i==null&&t?()=>{if(C.current===-1){const u=m.current;m.current+=1,C.current=u}return C.current}:-1),S=i??p,T=o.useRef(null),U=o.useCallback(u=>{const z=T.current;z&&a(z),T.current=u,u&&s(u,{metadata:r??null,index:i??null,label:n,textRef:c})},[i,s,a,r,n,c]);return Z(()=>{if(i==null)return d(u=>{const z=T.current?u.get(T.current)?.index:null;z!=null&&g(z)})},[i,d]),{ref:U,index:S}}const mn=o.createContext(void 0);function Lt(){const e=o.useContext(mn);if(!e)throw new Error(Rt(57));return e}const lo=o.memo(o.forwardRef(function(t,n){const{render:r,className:c,style:i,value:s=null,label:a,disabled:d=!1,nativeButton:m=!1,...C}=t,p=o.useRef(null),g=Xr({guess:!0,label:a,textRef:p}),{store:S,itemProps:T,setOpen:U,setValue:u,selectionRef:z,typingRef:K,valuesRef:V,multiple:b,selectedItemTextRef:I,disabled:j,readOnly:h}=Ue(),y=j||d,O=A(S,M.isActive,g.index),X=A(S,M.open),ee=A(S,M.isSelected,s),me=A(S,M.isSelectedByFocus,g.index),te=A(S,M.isItemEqualToValue),w=g.index,N=o.useRef(null);Z(()=>{const E=V.current;return E[w]=s,()=>{delete E[w]}},[w,s,V]),Z(()=>{const E=S.state.value;let L=E;b&&Array.isArray(E)&&(L=E.length>0?E[E.length-1]:void 0),L!==void 0&&Ge(s,L,te)&&(S.set("selectedIndex",w),p.current&&(I.current=p.current))},[w,b,te,S,s,I]);const ne=o.useRef("mouse"),B=o.useRef(!1),{getButtonProps:P,buttonRef:q}=Zt({disabled:y,focusableWhenDisabled:!0,native:m,composite:!0}),F={disabled:y,selected:ee,highlighted:O};function l(E){if(j||h)return;const L=S.state.value;if(b){const Y=Array.isArray(L)?L:[],ie=ee?Sr(Y,s,te):[...Y,s];u(ie,Ie(Tt,E))}else u(s,Ie(Tt,E)),U(!1,Ie(Tt,E))}function v(){z.current.dragY=0}const ce={role:"option","aria-selected":ee,tabIndex:X&&O?0:-1,onKeyDown(E){S.set("activeIndex",w),E.key===" "&&K.current&&E.preventDefault()},onClick(E){const L=ne.current!=="touch",Y=E.nativeEvent.pointerType,ie=L&&nn(E.nativeEvent)&&(Y!==void 0||O),ye=L&&!ie&&!B.current;B.current=!1,!(y||ye)&&l(E.nativeEvent)},onPointerEnter(E){ne.current=E.pointerType},onPointerMove(E){if(E.pointerType==="mouse"&&E.buttons===1){const L=z.current;L.dragY+=E.movementY,L.dragY**2>=64&&(L.allowUnselectedMouseUp=!0)}},onPointerDown(E){ne.current=E.pointerType,B.current=!0,v()},onMouseUp(){if(v(),y||ne.current==="touch"||B.current)return;const E=!z.current.allowSelectedMouseUp&&ee,L=!z.current.allowUnselectedMouseUp&&!ee;E||L||(B.current=!0,N.current?.click(),B.current=!1)}},_=Xe("div",t,{ref:[q,n,g.ref,N],state:F,props:[T,ce,C,P]}),ue=o.useMemo(()=>({selected:ee,index:w,textRef:p,selectedByFocus:me}),[ee,w,p,me]);return be.jsx(mn.Provider,{value:ue,children:_})})),co=o.forwardRef(function(t,n){const{selected:r}=Lt();return t.keepMounted||r?be.jsx(Jr,{...t,ref:n}):null}),Jr=o.memo(o.forwardRef((e,t)=>{const{render:n,className:r,style:c,keepMounted:i,...s}=e,{selected:a}=Lt(),d=o.useRef(null),{transitionStatus:m,setMounted:C}=rn(a),g=Xe("span",e,{ref:[t,d],state:{selected:a,transitionStatus:m},props:[{"aria-hidden":!0,children:"✔️"},s],stateAttributesMapping:en});return Vt({open:a,ref:d,onComplete(){a||C(!1)}}),g})),uo=o.memo(o.forwardRef(function(t,n){const{index:r,textRef:c,selectedByFocus:i}=Lt(),{firstItemTextRef:s,selectedItemTextRef:a}=Ue(),{render:d,className:m,style:C,...p}=t,g=o.useCallback(T=>{T&&(r===0&&(s.current=T),i&&(a.current=T))},[s,a,r,i]);return Xe("div",t,{ref:[g,n,c],props:p})}));export{jr as L,to as S,Wr as a,jt as b,no as c,ro as d,oo as e,so as f,io as g,lo as h,co as i,uo as j,hr as k,vr as l,Ft as m,sn as n,Wt as o,br as p,M as s,Ue as u};
@@ -1 +1 @@
1
- import{r as d,c as n,j as t,R as h}from"./__vite-browser-external-DXtgoDkV.js";import{P as f}from"./ProviderIcon-BecpRylD.js";import{E as b}from"./external-link-fV_WJ5f_.js";const x=[{id:"claude",name:"Claude",icon:"CLAUDE",apiUrl:"https://status.claude.com/api/v2/status.json",pageUrl:"https://status.claude.com"},{id:"openai",name:"OpenAI / Codex",icon:"CODEX",apiUrl:"https://status.openai.com/api/v2/status.json",pageUrl:"https://status.openai.com"},{id:"cursor",name:"Cursor",icon:"CURSOR",apiUrl:"https://status.cursor.com/api/v2/status.json",pageUrl:"https://status.cursor.com"},{id:"github",name:"GitHub / Copilot",icon:"GITHUB",apiUrl:"https://www.githubstatus.com/api/v2/status.json",pageUrl:"https://www.githubstatus.com"},{id:"gemini",name:"Gemini",icon:"GEMINI",kind:"google",serviceName:"Gemini",apiUrl:"https://www.google.com/appsstatus/dashboard/incidents.json",pageUrl:"https://www.google.com/appsstatus/dashboard"},{id:"kimi",name:"Kimi / Moonshot",icon:"KIMI",apiUrl:"https://status.moonshot.cn/api/v2/status.json",pageUrl:"https://status.moonshot.cn"},{id:"minimax",name:"MiniMax",icon:"MINIMAX",apiUrl:"https://status.minimaxi.com/api/v2/status.json",pageUrl:"https://status.minimaxi.com"},{id:"zed",name:"Zed",icon:"ZED",kind:"instatus",apiUrl:"https://status.zed.dev/summary.json",pageUrl:"https://status.zed.dev"}],w=6e4,y=8e3,j=new Set(["none","minor","major","critical"]),g={none:{dot:"bg-emerald-500",text:"text-emerald-600 dark:text-emerald-400"},minor:{dot:"bg-yellow-500",text:"text-yellow-600 dark:text-yellow-400"},major:{dot:"bg-orange-500",text:"text-orange-600 dark:text-orange-400"},critical:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400"},unknown:{dot:"bg-oai-gray-400",text:"text-oai-gray-500 dark:text-oai-gray-400"}};function k(e){switch(e){case"none":return n("status.state.none");case"minor":return n("status.state.minor");case"major":return n("status.state.major");case"critical":return n("status.state.critical");default:return n("status.state.unknown")}}const v={low:"minor",medium:"major",high:"critical"},N={MAJOROUTAGE:"critical",PARTIALOUTAGE:"major",DEGRADEDPERFORMANCE:"minor"};function A(e){const a=e?.page?.status;if(typeof a!="string")throw new Error("Unexpected payload");if(a==="UP")return{indicator:"none",description:"",updatedAt:null};const s=Array.isArray(e?.activeIncidents)?e.activeIncidents:[],r={critical:3,major:2,minor:1};let o=null;for(const i of s){const c=N[i?.impact]||"minor";(!o||r[c]>r[o.indicator])&&(o={indicator:c,description:i?.name||"",updatedAt:i?.updated||null})}return o||{indicator:"minor",description:"",updatedAt:null}}function I(e,a){if(!Array.isArray(e))throw new Error("Unexpected payload");const s=e.filter(i=>i&&!i.end&&(i.service_name===a||Array.isArray(i.affected_products)&&i.affected_products.some(c=>c?.title===a)));if(s.length===0)return{indicator:"none",description:"",updatedAt:null};const r={critical:3,major:2,minor:1};let o=null;for(const i of s){const c=v[i.severity]||"minor";(!o||r[c]>r[o.indicator])&&(o={indicator:c,description:i.external_desc||"",updatedAt:i.modified||null})}return o}async function E(e){try{const a=await fetch(e.apiUrl,{cache:"no-store",signal:AbortSignal.timeout(y)});if(!a.ok)throw new Error(`HTTP ${a.status}`);const s=await a.json();if(e.kind==="google")return I(s,e.serviceName);if(e.kind==="instatus")return A(s);const r=s?.status?.indicator;if(!j.has(r))throw new Error("Unexpected payload");return{indicator:r,description:typeof s?.status?.description=="string"?s.status.description:"",updatedAt:typeof s?.page?.updated_at=="string"?s.page.updated_at:null}}catch{return{indicator:"unknown",description:"",updatedAt:null}}}function U({provider:e,result:a}){const s=g[a?.indicator]||g.unknown,r=a==null;return t.jsxs("a",{href:e.pageUrl,target:"_blank",rel:"noreferrer","aria-label":n("status.open_page",{provider:e.name}),title:n("status.open_page",{provider:e.name}),className:"group block no-underline text-inherit rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4 sm:p-5 transition-colors hover:border-oai-gray-300 dark:hover:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(f,{provider:e.icon,size:20}),t.jsx("span",{className:"font-medium text-sm sm:text-base truncate",children:e.name})]}),t.jsx("span",{"aria-hidden":!0,className:"shrink-0 inline-flex h-8 w-8 items-center justify-center rounded-lg text-oai-gray-400 transition-colors group-hover:text-oai-black dark:group-hover:text-white",children:t.jsx(b,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[r?t.jsx("span",{className:"h-2 w-2 rounded-full bg-oai-gray-300 dark:bg-oai-gray-700 animate-pulse","aria-hidden":!0}):t.jsxs("span",{className:"relative flex h-2 w-2","aria-hidden":!0,children:[a.indicator!=="none"&&a.indicator!=="unknown"?t.jsx("span",{className:`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75 ${s.dot}`}):null,t.jsx("span",{className:`relative inline-flex h-2 w-2 rounded-full ${s.dot}`})]}),t.jsx("span",{className:`text-sm font-medium ${r?"text-oai-gray-400":s.text}`,children:r?n("status.state.checking"):k(a.indicator)})]}),!r&&a.description&&a.indicator!=="none"?t.jsx("p",{className:"mt-2 text-xs text-oai-gray-500 dark:text-oai-gray-400 break-words",children:a.description}):null]})}function T(){const[e,a]=d.useState({}),[s,r]=d.useState(null),[o,i]=d.useState(!1),c=d.useRef(!0),u=d.useCallback(async()=>{i(!0);const l=await Promise.all(x.map(async p=>[p.id,await E(p)]));c.current&&(a(Object.fromEntries(l)),r(new Date),i(!1))},[]);d.useEffect(()=>{c.current=!0,u();const l=setInterval(()=>{u()},w);return()=>{c.current=!1,clearInterval(l)}},[u]);const m=d.useMemo(()=>s?n("status.last_checked",{time:s.toLocaleTimeString()}):null,[s]);return t.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:t.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:t.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[t.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:n("nav.service_status")}),t.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:n("status.page.subtitle")})]}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[m?t.jsx("span",{className:"hidden sm:inline text-xs text-oai-gray-400 dark:text-oai-gray-500",children:m}):null,t.jsx("button",{type:"button",onClick:()=>{u()},disabled:o,"aria-label":n("status.refresh"),title:n("status.refresh"),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50",children:t.jsx(h,{className:`h-4 w-4 ${o?"animate-spin":""}`,"aria-hidden":!0})})]})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:x.map(l=>t.jsx(U,{provider:l,result:e[l.id]??null},l.id))}),t.jsx("p",{className:"mt-6 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:n("status.page.source_note")})]})})})}export{x as STATUS_PROVIDERS,T as ServiceStatusPage,T as default};
1
+ import{r as d,c as n,j as t,R as h}from"./__vite-browser-external-DPOlUkcY.js";import{P as f}from"./ProviderIcon-By8FAjxR.js";import{E as b}from"./external-link-DwSt83cq.js";const x=[{id:"claude",name:"Claude",icon:"CLAUDE",apiUrl:"https://status.claude.com/api/v2/status.json",pageUrl:"https://status.claude.com"},{id:"openai",name:"OpenAI / Codex",icon:"CODEX",apiUrl:"https://status.openai.com/api/v2/status.json",pageUrl:"https://status.openai.com"},{id:"cursor",name:"Cursor",icon:"CURSOR",apiUrl:"https://status.cursor.com/api/v2/status.json",pageUrl:"https://status.cursor.com"},{id:"github",name:"GitHub / Copilot",icon:"GITHUB",apiUrl:"https://www.githubstatus.com/api/v2/status.json",pageUrl:"https://www.githubstatus.com"},{id:"gemini",name:"Gemini",icon:"GEMINI",kind:"google",serviceName:"Gemini",apiUrl:"https://www.google.com/appsstatus/dashboard/incidents.json",pageUrl:"https://www.google.com/appsstatus/dashboard"},{id:"kimi",name:"Kimi / Moonshot",icon:"KIMI",apiUrl:"https://status.moonshot.cn/api/v2/status.json",pageUrl:"https://status.moonshot.cn"},{id:"minimax",name:"MiniMax",icon:"MINIMAX",apiUrl:"https://status.minimaxi.com/api/v2/status.json",pageUrl:"https://status.minimaxi.com"},{id:"zed",name:"Zed",icon:"ZED",kind:"instatus",apiUrl:"https://status.zed.dev/summary.json",pageUrl:"https://status.zed.dev"}],w=6e4,y=8e3,j=new Set(["none","minor","major","critical"]),g={none:{dot:"bg-emerald-500",text:"text-emerald-600 dark:text-emerald-400"},minor:{dot:"bg-yellow-500",text:"text-yellow-600 dark:text-yellow-400"},major:{dot:"bg-orange-500",text:"text-orange-600 dark:text-orange-400"},critical:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400"},unknown:{dot:"bg-oai-gray-400",text:"text-oai-gray-500 dark:text-oai-gray-400"}};function k(e){switch(e){case"none":return n("status.state.none");case"minor":return n("status.state.minor");case"major":return n("status.state.major");case"critical":return n("status.state.critical");default:return n("status.state.unknown")}}const v={low:"minor",medium:"major",high:"critical"},N={MAJOROUTAGE:"critical",PARTIALOUTAGE:"major",DEGRADEDPERFORMANCE:"minor"};function A(e){const a=e?.page?.status;if(typeof a!="string")throw new Error("Unexpected payload");if(a==="UP")return{indicator:"none",description:"",updatedAt:null};const s=Array.isArray(e?.activeIncidents)?e.activeIncidents:[],r={critical:3,major:2,minor:1};let o=null;for(const i of s){const c=N[i?.impact]||"minor";(!o||r[c]>r[o.indicator])&&(o={indicator:c,description:i?.name||"",updatedAt:i?.updated||null})}return o||{indicator:"minor",description:"",updatedAt:null}}function I(e,a){if(!Array.isArray(e))throw new Error("Unexpected payload");const s=e.filter(i=>i&&!i.end&&(i.service_name===a||Array.isArray(i.affected_products)&&i.affected_products.some(c=>c?.title===a)));if(s.length===0)return{indicator:"none",description:"",updatedAt:null};const r={critical:3,major:2,minor:1};let o=null;for(const i of s){const c=v[i.severity]||"minor";(!o||r[c]>r[o.indicator])&&(o={indicator:c,description:i.external_desc||"",updatedAt:i.modified||null})}return o}async function E(e){try{const a=await fetch(e.apiUrl,{cache:"no-store",signal:AbortSignal.timeout(y)});if(!a.ok)throw new Error(`HTTP ${a.status}`);const s=await a.json();if(e.kind==="google")return I(s,e.serviceName);if(e.kind==="instatus")return A(s);const r=s?.status?.indicator;if(!j.has(r))throw new Error("Unexpected payload");return{indicator:r,description:typeof s?.status?.description=="string"?s.status.description:"",updatedAt:typeof s?.page?.updated_at=="string"?s.page.updated_at:null}}catch{return{indicator:"unknown",description:"",updatedAt:null}}}function U({provider:e,result:a}){const s=g[a?.indicator]||g.unknown,r=a==null;return t.jsxs("a",{href:e.pageUrl,target:"_blank",rel:"noreferrer","aria-label":n("status.open_page",{provider:e.name}),title:n("status.open_page",{provider:e.name}),className:"group block no-underline text-inherit rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4 sm:p-5 transition-colors hover:border-oai-gray-300 dark:hover:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(f,{provider:e.icon,size:20}),t.jsx("span",{className:"font-medium text-sm sm:text-base truncate",children:e.name})]}),t.jsx("span",{"aria-hidden":!0,className:"shrink-0 inline-flex h-8 w-8 items-center justify-center rounded-lg text-oai-gray-400 transition-colors group-hover:text-oai-black dark:group-hover:text-white",children:t.jsx(b,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[r?t.jsx("span",{className:"h-2 w-2 rounded-full bg-oai-gray-300 dark:bg-oai-gray-700 animate-pulse","aria-hidden":!0}):t.jsxs("span",{className:"relative flex h-2 w-2","aria-hidden":!0,children:[a.indicator!=="none"&&a.indicator!=="unknown"?t.jsx("span",{className:`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75 ${s.dot}`}):null,t.jsx("span",{className:`relative inline-flex h-2 w-2 rounded-full ${s.dot}`})]}),t.jsx("span",{className:`text-sm font-medium ${r?"text-oai-gray-400":s.text}`,children:r?n("status.state.checking"):k(a.indicator)})]}),!r&&a.description&&a.indicator!=="none"?t.jsx("p",{className:"mt-2 text-xs text-oai-gray-500 dark:text-oai-gray-400 break-words",children:a.description}):null]})}function T(){const[e,a]=d.useState({}),[s,r]=d.useState(null),[o,i]=d.useState(!1),c=d.useRef(!0),u=d.useCallback(async()=>{i(!0);const l=await Promise.all(x.map(async p=>[p.id,await E(p)]));c.current&&(a(Object.fromEntries(l)),r(new Date),i(!1))},[]);d.useEffect(()=>{c.current=!0,u();const l=setInterval(()=>{u()},w);return()=>{c.current=!1,clearInterval(l)}},[u]);const m=d.useMemo(()=>s?n("status.last_checked",{time:s.toLocaleTimeString()}):null,[s]);return t.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:t.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:t.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[t.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:n("nav.service_status")}),t.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:n("status.page.subtitle")})]}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[m?t.jsx("span",{className:"hidden sm:inline text-xs text-oai-gray-400 dark:text-oai-gray-500",children:m}):null,t.jsx("button",{type:"button",onClick:()=>{u()},disabled:o,"aria-label":n("status.refresh"),title:n("status.refresh"),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50",children:t.jsx(h,{className:`h-4 w-4 ${o?"animate-spin":""}`,"aria-hidden":!0})})]})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:x.map(l=>t.jsx(U,{provider:l,result:e[l.id]??null},l.id))}),t.jsx("p",{className:"mt-6 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:n("status.page.source_note")})]})})})}export{x as STATUS_PROVIDERS,T as ServiceStatusPage,T as default};
@@ -1,2 +1,2 @@
1
- import{m as Y,r as i,j as e,e as P,c as a,M as ce,J as W,R as de,X as ue,d as ee,l as m,a4 as xe,a5 as U}from"./__vite-browser-external-DXtgoDkV.js";import{L as me,I as he}from"./LocalOnlyNotice-V8_KFKOD.js";import{S as Z}from"./SegmentedControl-3rBqbzW_.js";import{C as ge}from"./ToolbarRootContext-DG1pr5UP.js";import{S as te}from"./search-DgddmV09.js";import{C as pe}from"./check-9_1xp5h5.js";import{P as fe,a as be,b as ye,c as ke,d as _e}from"./PopoverPopup-CCHVwh0w.js";import{P as ve}from"./ProviderIcon-BecpRylD.js";import{H as je}from"./HoverTooltip-jh3sI8NC.js";import{u as we}from"./useCurrency-C5xhS1QV.js";import{i as Ne}from"./host-mode-Bc_iTzHk.js";import{L as Ce}from"./loader-circle-nRhGIddE.js";import{T as Se}from"./terminal-BtQyotJS.js";import"./arrow-up-right-DUR69elJ.js";import"./download-BNjfcJ1g.js";import"./composite-CEzovOpb.js";import"./store-ZswY8Voz.js";const Me=[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]],Le=Y("calendar",Me);const Te=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Re=Y("folder",Te),De="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm text-oai-black outline-none hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800";function Ie({options:s,value:t,onChange:o,allValue:x="all",allLabel:g,searchPlaceholder:k,emptyLabel:u,ariaLabel:w,disabled:p=!1,className:_=""}){const[b,f]=i.useState(!1),[y,R]=i.useState(""),[h,v]=i.useState(-1),N=i.useRef(null),C=`${i.useId()}-listbox`,A=t===x?g:s.find(l=>l.value===t)?.label??t,S=y.trim().toLowerCase(),D=i.useMemo(()=>S?s.filter(l=>l.label.toLowerCase().includes(S)):s,[s,S]),I=i.useMemo(()=>[{value:x,label:g},...D],[x,g,D]),M=h>=0&&h<I.length?I[h]:null,E=l=>{o(l),f(!1),R(""),v(-1)};i.useEffect(()=>{b&&N.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[b,h]);const L=l=>{if(l.key==="ArrowDown"||l.key==="ArrowUp"){l.preventDefault();const j=l.key==="ArrowDown";v(F=>{const T=I.length;return T?j?F>=T-1?0:F+1:F<=0?T-1:F-1:-1});return}if(l.key==="Enter"){const j=M||(S&&D.length?D[0]:null);if(!j)return;l.preventDefault(),E(j.value)}};return e.jsxs(fe,{open:b,onOpenChange:l=>{f(l),v(-1),l||R("")},children:[e.jsxs(be,{disabled:p,"aria-label":w,className:P("inline-flex h-8 max-w-[12rem] shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:hover:border-oai-gray-700",t!==x?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",_),children:[e.jsx(Re,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:A}),e.jsx(ge,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(ye,{children:e.jsx(ke,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(_e,{className:"w-56 overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"relative mb-1",children:[e.jsx(te,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{type:"text",role:"combobox","aria-expanded":!0,"aria-controls":C,"aria-activedescendant":M?`${C}-${h}`:void 0,value:y,onChange:l=>{R(l.target.value),v(-1)},onKeyDown:L,placeholder:k,className:"h-8 w-full rounded border border-oai-gray-200 bg-transparent pl-8 pr-2 text-xs text-oai-black outline-none placeholder:text-oai-gray-400 focus:border-oai-gray-400 dark:border-oai-gray-800 dark:text-white dark:focus:border-oai-gray-500"})]}),e.jsxs("div",{ref:N,id:C,role:"listbox","aria-label":w,className:"max-h-64 overflow-y-auto",children:[I.map((l,j)=>e.jsxs("button",{id:`${C}-${j}`,type:"button",role:"option","aria-selected":t===l.value,"data-active":j===h?"true":void 0,onMouseEnter:()=>v(j),onClick:()=>E(l.value),className:P(De,t===l.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",j===h&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:l.label}),t===l.value?e.jsx(pe,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},l.value)),D.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:u}):null]})]})})})]})}const Ee="tokentracker-sessions";async function Pe(s={}){const t=new URL(`/functions/${Ee}`,window.location.origin);s.from&&t.searchParams.set("from",s.from),s.to&&t.searchParams.set("to",s.to),s.limit&&t.searchParams.set("limit",String(s.limit)),s.refresh&&t.searchParams.set("refresh","1");const o=await fetch(t.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),x=await o.json().catch(()=>null);if(!o.ok){const g=o.status===404?a("sessions.error.outdated_app"):`Request failed with HTTP ${o.status}`,k=new Error(x?.error||g);throw k.status=o.status,k}return x}const J=Ne(),Fe=[],G=100,$e=[{id:"all",label:()=>a("sessions.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"grok",label:()=>"Grok"}],ae=[{id:"all",days:0,label:()=>a("sessions.filter.range_all")},{id:"7d",days:7,label:()=>a("sessions.filter.range_7d")},{id:"30d",days:30,label:()=>a("sessions.filter.range_30d")},{id:"90d",days:90,label:()=>a("sessions.filter.range_90d")}];function Oe(s){const t=ae.find(x=>x.id===s)?.days||0;if(!t)return 0;const o=new Date;return o.setDate(o.getDate()-(t-1)),o.setHours(0,0,0,0),o.getTime()}function Ae(s,t){if(!t)return!0;const o=Date.parse(s.ended_at||s.started_at||"");return Number.isFinite(o)?o>=t:!0}function qe(s,t){if(!s)return"—";const o=Date.parse(s);if(!Number.isFinite(o))return"—";try{return new Date(o).toLocaleString(t||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return new Date(o).toISOString().slice(0,16).replace("T"," ")}}function Ue(s){const t=Number(s);if(!Number.isFinite(t)||t<=0)return null;const o=Math.round(t/6e4);if(o<60)return a("sessions.duration.minutes",{minutes:o});const x=Math.floor(o/60),g=o%60;return a("sessions.duration.hours",{hours:x,minutes:g})}async function V(s){if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(s),!0;const t=document.createElement("textarea");t.value=s,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const o=document.execCommand("copy");return document.body.removeChild(t),o}const X=ee.memo(function({session:t,locale:o,nested:x=!1,childCount:g=0,expanded:k=!1,onToggle:u}){const{currency:w,rate:p}=we(),_=String(t.source||"").toUpperCase(),b=Ue(t.duration_ms),f=t.resume_command,y=t.project_key||a("sessions.project.unknown"),R=x||t.thread_kind==="subagent",h=R?t.agent_nickname||t.agent_role||t.title||y:t.title||y,v=!!(t.title&&t.project_key),N=String(t.source||"").toLowerCase()==="grok",C=N&&t.usage_precision?a("sessions.grok.token_breakdown",{input:m(t.input_tokens),cacheRead:m(t.cached_input_tokens),cacheWrite:m(t.cache_creation_input_tokens),output:m(t.output_tokens),reasoning:m(t.reasoning_output_tokens)}):null,A=N&&t.usage_precision?a("sessions.grok.runtime_breakdown",{calls:m(t.model_calls),seconds:(Number(t.api_duration_ms||0)/1e3).toFixed(1),tools:m(t.tool_calls),errors:m(t.error_count)}):null,S=N&&Number(t.context_window_tokens)>0?a("sessions.grok.context_breakdown",{used:m(t.context_tokens_used),window:m(t.context_window_tokens),percent:Number(t.context_usage_percent||0).toFixed(0)}):null,D=t.project_ref?`${t.project_ref}
1
+ import{m as Y,r as i,j as e,e as P,c as a,M as ce,J as W,R as de,X as ue,d as ee,l as m,a4 as xe,a5 as U}from"./__vite-browser-external-DPOlUkcY.js";import{L as me,I as he}from"./LocalOnlyNotice-Bj_m0hw7.js";import{S as Z}from"./SegmentedControl-DLzS-2eZ.js";import{C as ge}from"./ToolbarRootContext-XUDMp5uy.js";import{S as te}from"./search-D_LLDRdU.js";import{C as pe}from"./check-Cy35lAKh.js";import{P as fe,a as be,b as ye,c as ke,d as _e}from"./PopoverPopup-DK3et-HG.js";import{P as ve}from"./ProviderIcon-By8FAjxR.js";import{H as je}from"./HoverTooltip-DBOpxlH7.js";import{u as we}from"./useCurrency-CnM8aB4v.js";import{i as Ne}from"./host-mode-Bc_iTzHk.js";import{L as Ce}from"./loader-circle-lrDmbIg5.js";import{T as Se}from"./terminal-CR228ekj.js";import"./arrow-up-right-DSsR3Ntr.js";import"./download-DdGW6Krz.js";import"./composite-BDwOlhhX.js";import"./store-8e16Ac2h.js";const Me=[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]],Le=Y("calendar",Me);const Te=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Re=Y("folder",Te),De="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm text-oai-black outline-none hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800";function Ie({options:s,value:t,onChange:o,allValue:x="all",allLabel:g,searchPlaceholder:k,emptyLabel:u,ariaLabel:w,disabled:p=!1,className:_=""}){const[b,f]=i.useState(!1),[y,R]=i.useState(""),[h,v]=i.useState(-1),N=i.useRef(null),C=`${i.useId()}-listbox`,A=t===x?g:s.find(l=>l.value===t)?.label??t,S=y.trim().toLowerCase(),D=i.useMemo(()=>S?s.filter(l=>l.label.toLowerCase().includes(S)):s,[s,S]),I=i.useMemo(()=>[{value:x,label:g},...D],[x,g,D]),M=h>=0&&h<I.length?I[h]:null,E=l=>{o(l),f(!1),R(""),v(-1)};i.useEffect(()=>{b&&N.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[b,h]);const L=l=>{if(l.key==="ArrowDown"||l.key==="ArrowUp"){l.preventDefault();const j=l.key==="ArrowDown";v(F=>{const T=I.length;return T?j?F>=T-1?0:F+1:F<=0?T-1:F-1:-1});return}if(l.key==="Enter"){const j=M||(S&&D.length?D[0]:null);if(!j)return;l.preventDefault(),E(j.value)}};return e.jsxs(fe,{open:b,onOpenChange:l=>{f(l),v(-1),l||R("")},children:[e.jsxs(be,{disabled:p,"aria-label":w,className:P("inline-flex h-8 max-w-[12rem] shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:hover:border-oai-gray-700",t!==x?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",_),children:[e.jsx(Re,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:A}),e.jsx(ge,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(ye,{children:e.jsx(ke,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(_e,{className:"w-56 overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"relative mb-1",children:[e.jsx(te,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{type:"text",role:"combobox","aria-expanded":!0,"aria-controls":C,"aria-activedescendant":M?`${C}-${h}`:void 0,value:y,onChange:l=>{R(l.target.value),v(-1)},onKeyDown:L,placeholder:k,className:"h-8 w-full rounded border border-oai-gray-200 bg-transparent pl-8 pr-2 text-xs text-oai-black outline-none placeholder:text-oai-gray-400 focus:border-oai-gray-400 dark:border-oai-gray-800 dark:text-white dark:focus:border-oai-gray-500"})]}),e.jsxs("div",{ref:N,id:C,role:"listbox","aria-label":w,className:"max-h-64 overflow-y-auto",children:[I.map((l,j)=>e.jsxs("button",{id:`${C}-${j}`,type:"button",role:"option","aria-selected":t===l.value,"data-active":j===h?"true":void 0,onMouseEnter:()=>v(j),onClick:()=>E(l.value),className:P(De,t===l.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",j===h&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:l.label}),t===l.value?e.jsx(pe,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},l.value)),D.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:u}):null]})]})})})]})}const Ee="tokentracker-sessions";async function Pe(s={}){const t=new URL(`/functions/${Ee}`,window.location.origin);s.from&&t.searchParams.set("from",s.from),s.to&&t.searchParams.set("to",s.to),s.limit&&t.searchParams.set("limit",String(s.limit)),s.refresh&&t.searchParams.set("refresh","1");const o=await fetch(t.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),x=await o.json().catch(()=>null);if(!o.ok){const g=o.status===404?a("sessions.error.outdated_app"):`Request failed with HTTP ${o.status}`,k=new Error(x?.error||g);throw k.status=o.status,k}return x}const J=Ne(),Fe=[],G=100,$e=[{id:"all",label:()=>a("sessions.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"grok",label:()=>"Grok"}],ae=[{id:"all",days:0,label:()=>a("sessions.filter.range_all")},{id:"7d",days:7,label:()=>a("sessions.filter.range_7d")},{id:"30d",days:30,label:()=>a("sessions.filter.range_30d")},{id:"90d",days:90,label:()=>a("sessions.filter.range_90d")}];function Oe(s){const t=ae.find(x=>x.id===s)?.days||0;if(!t)return 0;const o=new Date;return o.setDate(o.getDate()-(t-1)),o.setHours(0,0,0,0),o.getTime()}function Ae(s,t){if(!t)return!0;const o=Date.parse(s.ended_at||s.started_at||"");return Number.isFinite(o)?o>=t:!0}function qe(s,t){if(!s)return"—";const o=Date.parse(s);if(!Number.isFinite(o))return"—";try{return new Date(o).toLocaleString(t||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return new Date(o).toISOString().slice(0,16).replace("T"," ")}}function Ue(s){const t=Number(s);if(!Number.isFinite(t)||t<=0)return null;const o=Math.round(t/6e4);if(o<60)return a("sessions.duration.minutes",{minutes:o});const x=Math.floor(o/60),g=o%60;return a("sessions.duration.hours",{hours:x,minutes:g})}async function V(s){if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(s),!0;const t=document.createElement("textarea");t.value=s,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const o=document.execCommand("copy");return document.body.removeChild(t),o}const X=ee.memo(function({session:t,locale:o,nested:x=!1,childCount:g=0,expanded:k=!1,onToggle:u}){const{currency:w,rate:p}=we(),_=String(t.source||"").toUpperCase(),b=Ue(t.duration_ms),f=t.resume_command,y=t.project_key||a("sessions.project.unknown"),R=x||t.thread_kind==="subagent",h=R?t.agent_nickname||t.agent_role||t.title||y:t.title||y,v=!!(t.title&&t.project_key),N=String(t.source||"").toLowerCase()==="grok",C=N&&t.usage_precision?a("sessions.grok.token_breakdown",{input:m(t.input_tokens),cacheRead:m(t.cached_input_tokens),cacheWrite:m(t.cache_creation_input_tokens),output:m(t.output_tokens),reasoning:m(t.reasoning_output_tokens)}):null,A=N&&t.usage_precision?a("sessions.grok.runtime_breakdown",{calls:m(t.model_calls),seconds:(Number(t.api_duration_ms||0)/1e3).toFixed(1),tools:m(t.tool_calls),errors:m(t.error_count)}):null,S=N&&Number(t.context_window_tokens)>0?a("sessions.grok.context_breakdown",{used:m(t.context_tokens_used),window:m(t.context_window_tokens),percent:Number(t.context_usage_percent||0).toFixed(0)}):null,D=t.project_ref?`${t.project_ref}
2
2
  ${a("sessions.project.copy_hint")}`:void 0,I=async()=>{if(t.project_ref)try{await V(t.project_ref)?U({title:a("sessions.project.copied")}):U({title:a("sessions.project.copy_failed")})}catch{U({title:a("sessions.project.copy_failed")})}},M=L=>e.jsxs("span",{className:"group relative inline-flex min-w-0 max-w-full",children:[e.jsx(je,{text:D,placement:"bottom"}),e.jsx("button",{type:"button",onClick:I,"aria-label":a("sessions.project.copy_aria",{project:y}),className:P("max-w-full truncate rounded text-left underline decoration-dotted decoration-oai-gray-300 underline-offset-4 hover:decoration-oai-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:decoration-oai-gray-600 dark:hover:decoration-oai-gray-400",L),children:y})]}),E=async()=>{if(f)try{await V(f)?U({title:a("sessions.resume.copied")}):U({title:a("sessions.resume.copy_failed")})}catch{U({title:a("sessions.resume.copy_failed")})}};return e.jsxs("li",{className:P("flex flex-col gap-3 py-4 sm:flex-row sm:items-start",x&&"ml-6 border-l-2 border-oai-gray-200 pl-4 dark:border-oai-gray-800"),children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5",children:[e.jsx("span",{className:"mt-0.5 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",children:e.jsx(ve,{provider:_,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[!R&&!t.title&&t.project_ref?M("font-medium text-oai-black dark:text-white"):e.jsx("span",{className:"truncate font-medium text-oai-black dark:text-white",children:h}),R?e.jsxs("span",{className:"inline-flex items-center rounded-full bg-sky-50 px-2 py-0.5 text-[11px] font-medium text-sky-700 dark:bg-sky-500/10 dark:text-sky-300",children:[a("sessions.badge.subagent"),t.agent_role?` · ${t.agent_role}`:""]}):null,t.first_pass?e.jsx("span",{className:"inline-flex items-center rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-300",children:a("sessions.badge.first_pass")}):null,N&&t.usage_precision?e.jsx("span",{className:P("inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium",t.usage_is_incomplete||t.cost_is_partial?"bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-300":"bg-sky-50 text-sky-700 dark:bg-sky-500/10 dark:text-sky-300"),children:t.usage_is_incomplete||t.cost_is_partial?a("sessions.badge.partial_usage"):t.cost_source==="provider_reported"?a("sessions.badge.reported_cost"):a("sessions.badge.reported_usage")}):null,g?e.jsx("button",{type:"button",onClick:u,"aria-expanded":k,className:"inline-flex items-center rounded-full border border-oai-gray-200 px-2 py-0.5 text-[11px] font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:k?a("sessions.thread.collapse",{count:g}):a("sessions.thread.expand",{count:g})}):null]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[v?e.jsxs(e.Fragment,{children:[t.project_ref?M("hover:text-oai-black dark:hover:text-white"):e.jsx("span",{className:"truncate",children:y}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}):null,e.jsx("span",{className:"truncate",children:t.model||a("sessions.model.unknown")}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:qe(t.started_at,o)}),b?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:b})]}):null]}),C?e.jsx("div",{className:"mt-1 text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:C}):null,A?e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 text-[11px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("span",{children:A}),S?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:S})]}):null]}):null]})]}),e.jsxs("div",{className:"flex items-start gap-5 pl-[30px] sm:pl-0",children:[e.jsxs("dl",{className:"flex items-start gap-6 text-right",children:[e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.tokens")}),e.jsxs("dd",{title:Number(t.subagent_total_tokens)?a("sessions.thread.tokens_summary",{own:m(t.own_total_tokens),subagents:m(t.subagent_total_tokens),combined:m(t.combined_total_tokens)}):void 0,className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:[m(t.total_tokens),Number(t.subagent_total_tokens)?e.jsxs("span",{className:"block text-[9px] font-normal text-oai-gray-400 dark:text-oai-gray-500",children:["Σ ",m(t.combined_total_tokens)]}):null]})]}),e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.cost")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:xe(t.cost_usd,{currency:w,rate:p})})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.turns")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:m(t.turns)})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.edits")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:m(t.edit_turns)})]})]}),e.jsxs("button",{type:"button",onClick:E,disabled:!f,title:f||a("sessions.resume.unavailable"),"aria-label":f?a("sessions.resume.copy_aria",{command:f}):a("sessions.resume.unavailable"),className:P("-mt-0.5 inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",f?"text-oai-gray-500 hover:bg-oai-gray-100 hover:text-oai-black dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white":"cursor-not-allowed text-oai-gray-300 dark:text-oai-gray-600"),children:[e.jsx(Se,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"hidden sm:inline",children:a("sessions.resume.copy")})]})]})]})});function Be({sessions:s,selectedModel:t,onSelect:o}){const{groups:x,totalTokens:g}=i.useMemo(()=>{const u=new Map;let w=0;for(const p of s){const _=p.model||a("sessions.model.unknown"),b=Number(p.own_total_tokens||p.total_tokens||0),f=u.get(_)||{model:_,count:0,tokens:0};f.count+=1,f.tokens+=b,w+=b,u.set(_,f)}return{groups:[...u.values()].sort((p,_)=>_.tokens-p.tokens),totalTokens:w}},[s]);function k(u){return P("rounded-full border px-2.5 py-1 text-xs tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u?"border-oai-brand-500 bg-oai-brand-50 text-oai-brand-700 dark:bg-oai-brand-500/10 dark:text-oai-brand-300":"border-oai-gray-200 text-oai-gray-600 hover:bg-oai-gray-100 dark:border-oai-gray-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800")}return e.jsx("li",{className:"ml-6 border-l-2 border-oai-gray-200 py-3 pl-4 dark:border-oai-gray-800",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"mr-1 text-xs font-medium text-oai-gray-500 dark:text-oai-gray-400",children:a("sessions.thread.model_usage")}),e.jsx("button",{type:"button","aria-pressed":t==="all",onClick:()=>o("all"),className:k(t==="all"),children:a("sessions.thread.model_all",{count:s.length,tokens:m(g)})}),x.map(u=>e.jsx("button",{type:"button","aria-pressed":t===u.model,onClick:()=>o(u.model),className:k(t===u.model),children:a("sessions.thread.model_item",{model:u.model,count:u.count,tokens:m(u.tokens)})},u.model))]})})}function nt(){const[s,t]=i.useState(null),[o,x]=i.useState(null),[g,k]=i.useState(!0),[u,w]=i.useState(!1),[p,_]=i.useState("all"),[b,f]=i.useState("all"),[y,R]=i.useState("all"),[h,v]=i.useState(""),[N,C]=i.useState(G),[A,S]=i.useState(()=>new Set),[D,I]=i.useState(()=>new Map),M=i.useRef(0),{resolvedLocale:E}=ce(),L=i.useCallback(async(r=!1)=>{const c=++M.current;r?w(!0):k(!0),x(null);try{const n=await Pe({refresh:r});c===M.current&&t(n)}catch(n){c===M.current&&x(n?.message||String(n))}finally{c===M.current&&(k(!1),w(!1))}},[]);i.useEffect(()=>{J||W()?L(!1):k(!1)},[L]);const l=s?.sessions||Fe,j=i.useMemo(()=>{const r=new Set,c=[];for(const n of l){const d=n.project_key;!d||r.has(d)||(r.add(d),c.push({value:d,label:d}))}return c.sort((n,d)=>n.label.localeCompare(d.label))},[l]),F=i.useDeferredValue(h),T=i.useMemo(()=>{const r=F.trim().toLowerCase(),c=Oe(b);return l.filter(n=>p!=="all"&&n.source!==p||y!=="all"&&n.project_key!==y||!Ae(n,c)?!1:r?`${n.title||""} ${n.project_key||""} ${n.model||""} ${n.agent_nickname||""} ${n.agent_role||""} ${n.project_ref||""} ${n.session_id||""}`.toLowerCase().includes(r):!0)},[l,p,y,b,F]),O=i.useMemo(()=>{const r=new Set(T.map(d=>d.session_hash)),c=new Map,n=[];for(const d of T){const q=d.root_session_hash||d.parent_session_hash;if(d.parent_session_hash&&q&&r.has(q)){const $=c.get(q)||[];$.push(d),c.set(q,$)}else n.push(d)}return{roots:n,childrenByRoot:c,foldedCount:T.length-n.length}},[T]),Q=p!=="all"||b!=="all"||y!=="all"||h.trim()!=="";i.useEffect(()=>{C(G),S(new Set),I(new Map)},[p,y,b,F,l]);const K=i.useMemo(()=>O.roots.slice(0,N),[O.roots,N]),B=O.roots.length>K.length,H=i.useCallback(()=>C(r=>r+G),[]),re=i.useCallback(r=>{S(c=>{const n=new Set(c);return n.has(r)?n.delete(r):n.add(r),n})},[]),se=i.useCallback((r,c)=>{I(n=>{const d=new Map(n);return c==="all"?d.delete(r):d.set(r,c),d})},[]),z=i.useRef(null);i.useEffect(()=>{if(!B||typeof IntersectionObserver>"u")return;const r=z.current;if(!r)return;const c=new IntersectionObserver(n=>{n.some(d=>d.isIntersecting)&&H()},{rootMargin:"400px"});return c.observe(r),()=>c.disconnect()},[B,H]);const oe=i.useMemo(()=>$e.map(r=>({id:r.id,label:r.label()})),[E]),ne=i.useMemo(()=>ae.map(r=>({id:r.id,label:r.label()})),[E]),ie=Number(s?.session_count)>Number(s?.returned_count);return!J&&!W()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(me,{})}):e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-8 flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"mb-3 text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("nav.sessions")}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:a("sessions.page.subtitle")})]}),e.jsx("button",{type:"button",onClick:()=>{L(!0)},disabled:u||g,"aria-label":a("sessions.page.refresh"),title:a("sessions.page.refresh"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(de,{className:P("h-4 w-4",u&&"animate-spin"),"aria-hidden":!0})})]}),e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 pt-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx(Z,{ariaLabel:a("sessions.filter.source_aria"),options:oe,value:p,onChange:_}),e.jsx(Z,{className:"pl-2",ariaLabel:a("sessions.filter.range_aria"),leading:e.jsx(Le,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),options:ne,value:b,onChange:f}),e.jsx(Ie,{options:j,value:y,onChange:R,allLabel:a("sessions.filter.project_all"),searchPlaceholder:a("sessions.filter.project_search"),emptyLabel:a("sessions.filter.project_empty"),ariaLabel:a("sessions.filter.project_aria")}),e.jsxs("div",{className:"relative w-72 max-w-full",children:[e.jsx(te,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(he,{type:"search",value:h,onChange:r=>v(r.target.value),onKeyDown:r=>{r.key==="Escape"&&h&&(r.preventDefault(),v(""))},"aria-label":a("sessions.action.search_aria"),placeholder:a("sessions.search.placeholder"),className:"h-8 pl-9 pr-8 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20 [&::-webkit-search-cancel-button]:appearance-none"}),e.jsx("button",{type:"button",onMouseDown:r=>r.preventDefault(),onClick:()=>v(""),"aria-label":a("sessions.action.search_clear"),"aria-hidden":!h,tabIndex:h?0:-1,className:P("absolute right-2 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full text-oai-gray-400 transition duration-150 ease-out hover:bg-oai-gray-100 hover:text-oai-gray-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",h?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(ue,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:O.foldedCount>0?a("sessions.thread.result_count",{roots:O.roots.length,subagents:O.foldedCount}):a("sessions.filter.result_count",{filtered:T.length,total:l.length})})]}),ie?e.jsx("p",{className:"mb-4 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a("sessions.truncated",{shown:s.returned_count,total:s.session_count})}):null,o&&!s?e.jsxs("div",{className:"rounded-xl border border-dashed border-red-300 py-16 text-center dark:border-red-500/40",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:a("sessions.error.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:o}),e.jsx("button",{type:"button",onClick:()=>{L(!1)},className:"mt-4 inline-flex h-8 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-200 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:a("sessions.error.retry")})]}):g?e.jsxs("div",{className:"flex items-center gap-2 py-16 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(Ce,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),a("sessions.loading")]}):T.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-oai-gray-200 py-16 text-center dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:Q?a("sessions.empty.filtered_title"):a("sessions.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:Q?a("sessions.empty.filtered_body"):a("sessions.empty.body")})]}):e.jsxs(e.Fragment,{children:[o?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:a("shared.error.prefix",{error:o})}):null,e.jsx("ul",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:K.map(r=>{const c=O.childrenByRoot.get(r.session_hash)||[],n=A.has(r.session_hash),d=D.get(r.session_hash)||"all",q=d==="all"?c:c.filter(function(le){return(le.model||a("sessions.model.unknown"))===d});return e.jsxs(ee.Fragment,{children:[e.jsx(X,{session:r,locale:E,childCount:c.length,expanded:n,onToggle:()=>re(r.session_hash)}),n&&c.length?e.jsx(Be,{sessions:c,selectedModel:d,onSelect:$=>se(r.session_hash,$)}):null,n?q.map($=>e.jsx(X,{session:$,locale:E,nested:!0},$.session_hash)):null]},r.session_hash)})}),B?e.jsx("div",{ref:z,className:"flex justify-center pt-6",children:e.jsx("button",{type:"button",onClick:H,className:"inline-flex h-8 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:a("sessions.action.load_more")})}):null]}),e.jsx("p",{className:"mt-6 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.privacy")})]})})})}export{nt as SessionsPage};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-DXtgoDkV.js","assets/__vite-browser-external-CCMdjCX2.css"])))=>i.map(i=>d[i]);
2
- import{m as O,j as t,e as L,c as n,a as ce,r as g,ao as ue,aU as de,au as ge,av as pe,a8 as W,aV as he,aW as me,u as be,d as R,a0 as fe,M as Z,n as M,aX as xe,aY as ye,U as Y,aZ as ve,x as ke,a_ as je,a$ as Se,b0 as we,b1 as Ne,b2 as Ce,b3 as Ee,b4 as Ae,L as Le,R as Oe,b5 as Pe,b6 as _e,a5 as H,_ as Te,h as Ie,f as Ge,b7 as Re,b8 as Ue,ax as De}from"./__vite-browser-external-DXtgoDkV.js";import{a as Me,b as F,s as He,K as Fe,P as $e,D as Be,c as Ve,S as Ke,v as ze,u as qe,C as We}from"./sortable.esm-UCoNfZ6z.js";import{a as Ze}from"./modifiers.esm-rTZ5BUxp.js";import{u as Ye,L as $}from"./use-limits-display-prefs-C-l_Mxvy.js";import{P as Je}from"./ProviderIcon-BecpRylD.js";import{a as B,l as V}from"./limits-providers-CjMU709b.js";import{m as J}from"./react-BKACWrsB.js";import{a as A,T as j,b,S as _,u as T}from"./Controls-DAift9Z4.js";import{P as Xe,u as Qe,a as et}from"./use-session-efficiency-pref-DPI_--W2.js";import{C as tt}from"./check-9_1xp5h5.js";import{C as nt}from"./copy-DEoLQqJE.js";import{A as X}from"./index-BK3SzL7v.js";import{u as at}from"./useCurrency-C5xhS1QV.js";import{u as st}from"./useTokenFormat-FBMikfEq.js";import{S as U}from"./Select-DZ2ll7Qv.js";import{I as it}from"./info-DBotcfT9.js";import{C as ot}from"./ConfirmModal-DrYf9m15.js";import{A as rt}from"./arrow-up-right-DUR69elJ.js";import{D as lt}from"./download-BNjfcJ1g.js";import{i as ct}from"./host-mode-Bc_iTzHk.js";import"./Card-DAlV-PSI.js";import"./ToolbarRootContext-DG1pr5UP.js";import"./composite-CEzovOpb.js";import"./SelectItemText-Dr1W47W6.js";import"./DialogTitle-CA_ZstJL.js";import"./store-ZswY8Voz.js";import"./DialogDescription-CQuJCP4L.js";const ut=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],dt=O("flask-conical",ut);const gt=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],pt=O("grip-vertical",gt);const ht=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],mt=O("languages",ht);const bt=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],ft=O("log-out",bt);const xt=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],yt=O("palette",xt);const vt=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],kt=O("user-round",vt),jt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function St({checked:e,onChange:a,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:a,className:L("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:t.jsx("span",{className:L("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function wt({id:e,visible:a,onToggle:s}){const{attributes:i,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:u}=qe({id:e}),p={transform:We.Transform.toString(l)||void 0,transition:c,zIndex:u?20:void 0};return t.jsxs("div",{ref:r,style:p,className:L("flex items-center gap-3 py-2 rounded-md select-none touch-none","cursor-grab active:cursor-grabbing","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u&&"relative bg-oai-gray-100 dark:bg-oai-gray-800"),...i,...o,children:[t.jsx(pt,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),B(e)?t.jsx(Je,{provider:B(e),size:18,className:L("pointer-events-none",jt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:V(e)}),t.jsx("div",{onPointerDown:h=>h.stopPropagation(),children:t.jsx(St,{checked:a,onChange:s,ariaLabel:`${n("limits.settings.toggle_visible")}: ${V(e)}`})})]})}function Nt({prefs:e}){const{order:a,visibility:s,toggle:i,moveToward:o}=e,r=Me(F($e,{activationConstraint:{distance:6}}),F(Fe,{coordinateGetter:He})),l=({active:c,over:u})=>{u&&c.id!==u.id&&o(c.id,u.id)};return t.jsx(Be,{sensors:r,collisionDetection:Ve,modifiers:[Ze],onDragEnd:l,children:t.jsx(Ke,{items:a,strategy:ze,children:t.jsx("div",{className:"flex flex-col",children:a.map(c=>t.jsx(wt,{id:c,visible:s[c]!==!1,onToggle:()=>i(c)},c))})})})}function Ct(e){if(!e||typeof e!="object")return"";const a=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},s=e.profile&&typeof e.profile=="object"?e.profile:{},i=a.full_name||a.name||s.name||a.user_name||a.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function Et(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function At(e){const a=typeof e=="string"?e.trim():"";if(!a)return null;const s=a.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=a.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=s?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function D(e,a){console.warn(`[tokentracker] settings ${e}:`,a)}function Lt(e,a,s){const[i,o]=g.useState(()=>ue()),r=a&&s&&de(),l=g.useCallback(async()=>{const c=!i;if(ge(c),o(c),!!c)try{await pe(()=>e())}catch(u){D("cloud sync",u)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function Ot(e){const[a,s]=g.useState(!1),[i,o]=g.useState(!1),[r,l]=g.useState(!1),[c,u]=g.useState(!1),[p,h]=g.useState(null),[d,y]=g.useState(!1),[x,S]=g.useState(""),[k,m]=g.useState(!1),[v,C]=g.useState(""),[N,P]=g.useState(""),[I,f]=g.useState(!1),[E,se]=g.useState(null),ie=g.useMemo(()=>Ct(e),[e]),oe=g.useMemo(()=>Et(e),[e]),re=g.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),le=g.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:h,setGithubUrl:C,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:m}),[]);return{anonymousOn:i,customDisplayName:p,displayName:ie,editingGithub:I,editingName:d,email:oe,githubError:E,githubInput:N,githubUrl:v,loadSetters:le,nameInput:x,profileLoading:r,profileSaving:c,publicProfileOn:a,setAnonymousOn:o,setCustomDisplayName:h,setEditingGithub:f,setEditingName:y,setGithubError:se,setGithubInput:P,setGithubUrl:C,setNameInput:S,setProfileLoading:l,setProfileSaving:u,setPublicProfileOn:s,setShowGithubOn:m,showGithubOn:k,userId:re}}function Pt(e,a,s){g.useEffect(()=>{if(!a)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await W({getAccessToken:e});if(!i||!o)return;const r=await he({accessToken:o});if(!i)return;s.setPublicProfileOn(!!r?.enabled),s.setAnonymousOn(!!r?.anonymous),r?.display_name&&s.setCustomDisplayName(r.display_name),s.setShowGithubOn(!!r?.show_github_url),s.setGithubUrl(r?.github_url||"")}catch(o){D("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,a,s])}function _t(e,a){return g.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(a.profileSaving)return!1;a.setProfileSaving(!0);try{const l=await W({getAccessToken:e});if(!l)return!1;const c=await me({accessToken:l,...s});return r?.(c),!0}catch(l){return o?o(l):D(i||"mutate profile",l),!1}finally{a.setProfileSaving(!1)}},[e,a])}function Tt(e,a){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:a.handleAnonymousToggle,handleSaveName:a.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:a.startEditingName}}function It(e,a){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:a.handleSaveGithub,handleShowGithubToggle:a.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:a.startEditingGithub}}function Gt(e,a){const s=g.useCallback(async()=>{const o=!e.publicProfileOn;await a({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[a,e]);return{handleAnonymousToggle:g.useCallback(async()=>{const o=!e.anonymousOn;await a({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[a,e]),handlePublicProfileToggle:s}}function Rt(e,a,s){const i=g.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await a({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),s?.()}})},[a,e,s]),o=g.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function Ut(e,a){const s=g.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await a({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[a,e]),i=g.useCallback(async()=>{const r=At(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(n("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await a({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||n("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[a,e]),o=g.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function Dt(){const e=ce(),a=Ot(e.user),s=Lt(e.getAccessToken,e.enabled,e.signedIn);Pt(e.getAccessToken,e.signedIn,a.loadSetters);const i=_t(e.getAccessToken,a),o=Gt(a,i),r=Rt(a,i,e.refreshDisplayName),l=Ut(a,i);return{...e,...s,email:a.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:a.userId,name:Tt(a,{...o,...r}),github:It(a,l),profileLoading:a.profileLoading,profileSaving:a.profileSaving,publicProfileOn:a.publicProfileOn}}function Q({disabled:e,onCancel:a,onSave:s,saveLabel:i=n("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:s,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:i}),t.jsx("button",{type:"button",onClick:a,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:n("settings.account.cancel")})]})}function Mt({nameInput:e,setEditingName:a,setNameInput:s,profileSaving:i,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>s(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&a(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.displayName")}),t.jsx(Q,{disabled:i||!e.trim(),onCancel:()=>a(!1),onSave:o,saveLabel:i?n("settings.account.saving"):void 0})]})}function Ht({githubError:e,githubInput:a,handleSaveGithub:s,profileSaving:i,setEditingGithub:o,setGithubError:r,setGithubInput:l}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:a,onChange:c=>{l(c.target.value),e&&r(null)},onKeyDown:c=>{c.key==="Enter"&&s(),c.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.githubUrlPlaceholder")}),t.jsx(Q,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:s,saveLabel:i?n("settings.account.saving"):void 0})]}),e?t.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function ee({disabled:e=!1,label:a,onClick:s,title:i}){return t.jsxs("button",{type:"button",onClick:s,disabled:e,title:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Xe,{className:"h-3.5 w-3.5","aria-hidden":!0}),a]})}function te({actions:e,editing:a,editor:s,hint:i,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),a?s:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),a?null:e]})})}function Ft({name:e}){const a=e.anonymousOn?n("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ee,{disabled:e.anonymousOn,label:n("settings.account.edit"),onClick:e.startEditingName,title:a}),t.jsx(j,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:n("settings.account.displayName")})]})}function $t({name:e}){const{anonymousOn:a,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:u,profileSaving:p,setEditingName:h,setNameInput:d,startEditingName:y}=e,x=a?n("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(te,{label:n("settings.account.displayName"),editing:o,hint:x,editor:t.jsx(Mt,{nameInput:c,setEditingName:h,setNameInput:d,profileSaving:p,handleSaveName:l}),actions:t.jsx(Ft,{name:e})})}function Bt({github:e}){const{editingGithub:a,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:u,setEditingGithub:p,setGithubError:h,setGithubInput:d,showGithubOn:y,startEditingGithub:x}=e;return t.jsx(t.Fragment,{children:t.jsx(te,{label:n("settings.account.githubUrl"),editing:a,hint:o||n("settings.account.githubUrlHint"),editor:t.jsx(Ht,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:u,setEditingGithub:p,setGithubError:h,setGithubInput:d}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ee,{label:n("settings.account.edit"),onClick:x}),t.jsx(j,{checked:y,onChange:l,disabled:c||u,ariaLabel:n("settings.account.githubUrl")})]})})})}function Vt(){const{openLoginModal:e}=be();return t.jsx(A,{title:n("settings.section.account"),children:t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.account.signedOutHint")}),t.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:n("settings.account.signIn")})]})})}function Kt({name:e,github:a}){return t.jsxs(t.Fragment,{children:[t.jsx($t,{name:e}),t.jsx(Bt,{github:a})]})}function zt(){const e=Dt();return e.enabled?e.signedIn?t.jsxs(A,{title:n("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Wt,{onSignOut:e.signOut}),children:[t.jsx(qt,{userId:e.userId}),t.jsx(Zt,{settings:e}),t.jsx(Yt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(Jt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(Vt,{}):null}function qt({userId:e}){const[a,s]=R.useState(!1);if(!e)return null;const i=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),s(!0),globalThis.setTimeout(()=>s(!1),1200)}catch{s(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:n("settings.account.userId")}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),t.jsxs("button",{type:"button",onClick:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":n("settings.account.copyUserId"),children:[a?t.jsx(tt,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(nt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a?n("settings.account.copied"):n("settings.account.copy")]})]})}function Wt({onSignOut:e}){return t.jsxs("button",{type:"button",onClick:()=>e(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[t.jsx(ft,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.signOut")]})}function Zt({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:n("settings.account.cloudSync"),hint:n("settings.account.cloudSyncHint"),control:t.jsx(j,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:n("settings.account.cloudSync")})}):null}function Yt({checked:e,disabled:a,onChange:s}){return t.jsx(b,{label:n("settings.account.publicProfile"),hint:n("settings.account.publicProfileHint"),control:t.jsx(j,{checked:e,onChange:s,disabled:a,ariaLabel:n("settings.account.publicProfile")})})}function Jt({visible:e,name:a,github:s}){return t.jsx(X,{initial:!1,children:e?t.jsx(J.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:t.jsx(Kt,{name:a,github:s})},"public-profile-fields"):null})}function Xt(){return[{value:"light",label:n("settings.appearance.theme.light"),Icon:xe},{value:"dark",label:n("settings.appearance.theme.dark"),Icon:ye},{value:"system",label:n("settings.appearance.theme.system"),Icon:Y}]}function Qt(){return[{value:je,label:n("settings.appearance.language.system")},{value:Se,label:n("settings.appearance.language.english")},{value:we,label:n("settings.appearance.language.chinese")},{value:Ne,label:n("settings.appearance.language.traditional_chinese")},{value:Ce,label:n("settings.appearance.language.japanese")},{value:Ee,label:n("settings.appearance.language.korean")},{value:Ae,label:n("settings.appearance.language.german")}]}function en(e){if(!e)return null;try{const a=new Date(e);return Number.isNaN(a.getTime())?null:a.toLocaleString()}catch{return null}}function tn(e,a){const s=n(`settings.appearance.currency.rate_source.${e}`),i=en(a),o=i?n("settings.appearance.currency.rate_updated",{when:i}):n("settings.appearance.currency.rate_never");return`${s} · ${o}`}function nn({locale:e,setLocale:a}){const s=Qt();return t.jsx(U,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(mt,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function an({currency:e,setCurrency:a}){const s=ve().map(i=>({value:i.code,label:n(i.labelKey)}));return t.jsx(U,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function sn({currency:e,rate:a,rateSource:s,rateFetchedAt:i}){if(e===ke)return t.jsx(t.Fragment,{children:n("settings.appearance.currency.hint")});const o=tn(s,i);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${a.toFixed(4)} ${e}`}),t.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:t.jsx(it,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function on(){const{theme:e,setTheme:a}=fe(),{locale:s,setLocale:i}=Z(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:u}=at(),{mode:p,setMode:h}=st();return t.jsxs(A,{title:n("settings.section.appearance"),children:[t.jsx(b,{label:n("settings.appearance.theme.label"),hint:n("settings.appearance.theme.hint"),control:t.jsx(_,{options:Xt(),value:e,onChange:a})}),t.jsx(b,{label:n("settings.appearance.language.label"),hint:n("settings.appearance.language.hint"),control:t.jsx(nn,{locale:s,setLocale:i})}),t.jsx(b,{label:n("settings.appearance.currency.label"),hint:t.jsx(sn,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(an,{currency:o,setCurrency:u})}),t.jsx(b,{label:n("settings.appearance.token_format.label"),hint:n("settings.appearance.token_format.hint"),control:t.jsx(_,{options:[{value:M.COMPACT,label:n("settings.appearance.token_format.compact")},{value:M.FULL,label:n("settings.appearance.token_format.full")}],value:p,onChange:h})})]})}function G({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:n(e)}),t.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-semibold tracking-wider text-oai-gray-500 bg-oai-gray-100 dark:text-oai-gray-400 dark:bg-oai-gray-800/80 rounded uppercase scale-90 origin-left",children:n("qpd.card.badge")})]})}function rn(){const{enabled:e,toggle:a}=Qe(),{enabled:s,toggle:i}=et(),{available:o,settings:r,setSetting:l}=T(),c=o&&!!r?.dynamicIslandSupported,u=!!r?.dynamicIslandEnabled;return t.jsxs(A,{title:n("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.island.label"}),hint:n("settings.labs.island.hint"),control:t.jsx(j,{checked:u,onChange:()=>l("dynamicIslandEnabled",!u),ariaLabel:n("settings.labs.island.aria")})}),u&&t.jsx(b,{label:n("settings.labs.island_hide_menubar.label"),hint:n("settings.labs.island_hide_menubar.hint"),control:t.jsx(j,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:n("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.qpd.label"}),hint:n("settings.labs.qpd.hint"),control:t.jsx(j,{checked:e,onChange:a,ariaLabel:n("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.sessions.label"}),hint:n("settings.labs.sessions.hint"),control:t.jsx(j,{checked:s,onChange:i,ariaLabel:n("settings.labs.sessions.aria")})})]})}function ln(){const{available:e,settings:a,setSetting:s,runAction:i}=T();if(!e)return null;const o=!!a?.launchAtLogin,r=a?.toastOnReset!==!1,l=a?.confettiOnReset!==!1,c=a?.launchAtLoginSupported!==!1,u=a?.autoUpdateEnabled!==!1,p=a?.updateStatus||null,h=!!a?.updateBusy,d=!!a?.isSyncing;return t.jsxs(A,{title:n("settings.section.menubar"),children:[t.jsx(b,{label:n("settings.menubar.appearance"),hint:n("settings.menubar.appearanceHint"),control:t.jsxs(Le,{to:"/widgets",className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 no-underline transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n("settings.menubar.appearanceLink"),t.jsx(rt,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(j,{checked:r,onChange:()=>s("toastOnReset",!r),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(j,{checked:l,onChange:()=>s("confettiOnReset",!l),ariaLabel:n("settings.menubar.confettiOnReset")})}),c?t.jsx(b,{label:n("settings.menubar.launchAtLogin"),hint:n("settings.menubar.launchAtLoginHint"),control:t.jsx(j,{checked:o,onChange:()=>s("launchAtLogin",!o),ariaLabel:n("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:n("settings.menubar.syncNow"),hint:n("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Oe,{className:L("h-3.5 w-3.5",d&&"animate-spin"),"aria-hidden":!0}),d?n("settings.menubar.syncing"):n("settings.menubar.syncNow")]})}),t.jsx(b,{label:n("settings.menubar.autoUpdate"),hint:n("settings.menubar.autoUpdateHint"),control:t.jsx(j,{checked:u,onChange:()=>s("autoUpdateEnabled",!u),ariaLabel:n("settings.menubar.autoUpdate")})}),t.jsx(b,{label:n("settings.menubar.updates"),hint:p||void 0,control:t.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:h,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(lt,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.menubar.checkUpdates")]})})]})}function cn(e,a){function s(r){return r.replace(/^v/,"").split(".").map(Number)}const i=s(e),o=s(a);for(let r=0;r<Math.max(i.length,o.length);r++){const l=i[r]||0,c=o[r]||0;if(l<c)return!0;if(l>c)return!1}return!1}function un(){const{available:e,settings:a,runAction:s}=T(),i=e&&a?.version,[o,r]=R.useState(!1),[l,c]=R.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:u}=Z(),p="0.95.1",h=async()=>{r(!0);try{const k=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!k.ok)throw new Error("Failed to fetch");const m=await k.json(),v=m.tag_name;cn(p,v)?c({open:!0,latestVersion:v,htmlUrl:m.html_url}):H({title:n("settings.menubar.updates.upToDate")})}catch(k){console.error("Check updates failed:",k),H({title:n("settings.menubar.updates.failed")})}finally{r(!1)}},d=n("settings.menubar.updates.modalTitle"),y=n("settings.menubar.updates.modalDescription",{version:l.latestVersion}),x=n("settings.menubar.updates.modalConfirm"),S=n("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCombined",{barVersion:a.version,coreVersion:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>s("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCore",{version:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:h,disabled:o,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:o?n("settings.menubar.updates.checking"):n("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Pe,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:[t.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.footer.statusPage")]})]}),t.jsx(ot,{open:l.open,title:d,description:y,confirmLabel:x,cancelLabel:S,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),c(k=>({...k,open:!1}))},onCancel:()=>c(k=>({...k,open:!1}))})]})}const dn=()=>[{value:"system",label:n("settings.network.mode.system")},{value:"manual",label:n("settings.network.mode.manual")},{value:"off",label:n("settings.network.mode.off")}],gn=()=>[{value:"http",label:n("settings.network.protocol.http")},{value:"https",label:n("settings.network.protocol.https")},{value:"socks5",label:n("settings.network.protocol.socks5")}],K="w-full rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white";function z(e){const a={},s=String(e.host||"").trim();(!s||/:\/\//.test(s)||s.includes("/"))&&(a.host=n("settings.network.error.host"));const i=String(e.port??"").trim(),o=Number(i);return(!i||!/^\d+$/.test(i)||!Number.isInteger(o)||o<1||o>65535)&&(a.port=n("settings.network.error.port")),a}function pn({proxySettings:e}){const{config:a,save:s,testConnection:i}=e,[o,r]=g.useState(()=>({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})),[l,c]=g.useState({}),[u,p]=g.useState(!1),[h,d]=g.useState(""),[y,x]=g.useState(null),[S,k]=g.useState(!1),[m,v]=g.useState(null);g.useEffect(()=>{r({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})},[a.mode,a.protocol,a.host,a.port]);const C=g.useMemo(()=>a.effective==="manual"?n("settings.network.effective.manual"):a.effective==="env"?n("settings.network.effective.env"):a.effective==="system"?n("settings.network.effective.system"):a.effective==="blocked"?n("settings.network.effective.blocked"):n("settings.network.effective.none"),[a.effective]),N=f=>{r(E=>({...E,...f})),c({}),d(""),x(null),v(null)},P=async()=>{if(o.mode==="manual"){const f=z(o);if(Object.keys(f).length){c(f);return}}p(!0),d(""),x(null);try{await s(o),d("saved")}catch(f){d("error"),x(f)}finally{p(!1)}},I=async()=>{const f=z(o);if(Object.keys(f).length){c(f);return}k(!0),v(null);try{const E=await i(o);v(E)}catch(E){v({ok:!1,error:E?.message||String(E)})}finally{k(!1)}};return t.jsxs(A,{title:n("settings.section.network"),subtitle:C,children:[a.applyError?t.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:n("settings.network.apply_error",{error:a.applyError})}):null,t.jsx(b,{label:n("settings.network.mode.label"),hint:n("settings.network.mode.hint"),control:t.jsx(_,{options:dn(),value:o.mode,onChange:f=>N({mode:f})})}),t.jsx(X,{initial:!1,children:o.mode==="manual"?t.jsxs(J.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:[t.jsx(b,{label:n("settings.network.protocol.label"),control:t.jsx(U,{value:o.protocol,onValueChange:f=>N({protocol:f}),options:gn(),ariaLabel:n("settings.network.protocol.label"),className:"px-2.5 py-1.5 text-xs font-medium"})}),t.jsx(b,{label:n("settings.network.host.label"),hint:l.host,control:t.jsx("input",{type:"text",value:o.host,onChange:f=>N({host:f.target.value}),placeholder:n("settings.network.host.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.host?!0:void 0,"aria-label":n("settings.network.host.label"),className:K})}),t.jsx(b,{label:n("settings.network.port.label"),hint:l.port,control:t.jsx("input",{type:"text",inputMode:"numeric",value:o.port,onChange:f=>N({port:f.target.value}),placeholder:n("settings.network.port.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.port?!0:void 0,"aria-label":n("settings.network.port.label"),className:K})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[t.jsx("button",{type:"button",onClick:I,disabled:S||u,className:"rounded-md border border-oai-gray-200 px-3 py-1.5 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:S?n("settings.network.test.testing"):n("settings.network.test")}),t.jsx("button",{type:"button",onClick:P,disabled:u||S,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})]}),m?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:m.ok?n("settings.network.test.ok",{status:String(m.status??"")}):n("settings.network.test.fail",{error:m.error||""})}):null]},"manual-proxy-fields"):t.jsx("div",{className:"flex justify-end py-3",children:t.jsx("button",{type:"button",onClick:P,disabled:u,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})},"non-manual-save")}),h==="saved"?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.network.saved")}):null,h==="error"?t.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:y?.unprotected?n("settings.network.save_error_unprotected",{error:y?.message||String(y||"")}):n("settings.network.save_error",{error:y?.message||String(y||"")})}):null]})}const ne="/functions/tokentracker-proxy-config",hn="/functions/tokentracker-proxy-test",mn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function ae(e){return!e||typeof e.mode!="string"?null:{mode:e.mode,protocol:typeof e.protocol=="string"?e.protocol:"http",host:typeof e.host=="string"?e.host:"",port:e.port==null||e.port===0?"":String(e.port),effective:typeof e.effective=="string"?e.effective:"none",applyError:typeof e.applyError=="string"&&e.applyError.trim()?e.applyError:null}}async function bn(){const e=await fetch(ne,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!e.ok)return null;const a=await e.json().catch(()=>null);return ae(a)}async function q(){const{getLocalApiAuthHeaders:e}=await Te(async()=>{const{getLocalApiAuthHeaders:a}=await import("./__vite-browser-external-DXtgoDkV.js").then(s=>s.d8);return{getLocalApiAuthHeaders:a}},__vite__mapDeps([0,1]));return e()}function fn(){const[e,a]=g.useState(!1),[s,i]=g.useState(!0),[o,r]=g.useState(mn);g.useEffect(()=>{if(!ct()){a(!1),i(!1);return}let u=!1;return(async()=>{try{const p=await bn();if(u)return;if(!p){a(!1),i(!1);return}r(p),a(!0),i(!1)}catch{u||(a(!1),i(!1))}})(),()=>{u=!0}},[]);const l=g.useCallback(async u=>{const p=await q(),h=await fetch(ne,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({mode:u.mode,protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),d=await h.json().catch(()=>null);if(!h.ok){const x=d&&typeof d.error=="string"?d.error:`HTTP ${h.status}`;throw new Error(x)}const y=ae(d);if(y&&r(y),d&&d.ok===!1){const x=d&&typeof d.applyError=="string"&&d.applyError||d&&typeof d.error=="string"&&d.error||`HTTP ${h.status}`,S=new Error(x);throw d.unprotected===!0&&(S.unprotected=!0),S}return y||d},[]),c=g.useCallback(async u=>{const p=await q(),h=await fetch(hn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),d=await h.json().catch(()=>null);if(!d||typeof d.ok!="boolean")throw new Error(d&&typeof d.error=="string"?d.error:`HTTP ${h.status}`);return d},[]);return{available:e,loading:s,config:o,save:l,testConnection:c}}const w={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"};function xn({prefs:e}){return t.jsx(_,{options:[{value:$.USED,label:n("limits.settings.display_mode_used")},{value:$.REMAINING,label:n("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function zn(){const e=Ye(),{available:a,settings:s,setSetting:i}=T(),o=fn(),{available:r}=o,l=s?.toastOnReset!==!1,c=s?.confettiOnReset!==!1,[u,p]=Ie(),h=Ge(),d=u.get("section"),x=Object.values(w).includes(d)&&(d!==w.NATIVE_APP||a)&&(d!==w.NETWORK||r)?d:w.APPEARANCE,S=m=>{const v=new URLSearchParams(u);m===w.APPEARANCE?v.delete("section"):v.set("section",m),p(v,{replace:!0})},k=[{id:w.APPEARANCE,label:n("settings.section.appearance"),Icon:yt,content:t.jsx(on,{})},...a?[{id:w.NATIVE_APP,label:n("settings.section.menubar"),Icon:Y,content:t.jsx(ln,{})}]:[],...r?[{id:w.NETWORK,label:n("settings.section.network"),Icon:Re,content:t.jsx(pn,{proxySettings:o})}]:[],{id:w.ACCOUNT,label:n("settings.section.account"),Icon:kt,content:t.jsx(zt,{})},{id:w.LIMITS,label:n("settings.section.limits"),Icon:Ue,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(A,{title:n("settings.section.limits"),children:[t.jsx(b,{label:n("limits.settings.display_mode_label"),control:t.jsx(xn,{prefs:e})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(j,{checked:l,disabled:!a,onChange:()=>i("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(j,{checked:c,disabled:!a,onChange:()=>i("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})}),t.jsx(b,{label:n("settings.limits.showSubscriptions"),hint:n("settings.limits.showSubscriptionsHint"),control:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>h("/limits?openSubscriptions=1"),"aria-label":n("limits.page.openSubscriptions"),title:n("limits.page.openSubscriptions"),className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-white dark:bg-oai-gray-900 text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:t.jsx(De,{size:14,"aria-hidden":!0})}),t.jsx(j,{checked:e.showSubscriptions!==!1,onChange:()=>e.setShowSubscriptions(!e.showSubscriptions),ariaLabel:n("settings.limits.showSubscriptions")})]})})]}),t.jsx(A,{title:n("settings.limits.providers"),children:t.jsx(Nt,{prefs:e})})]})},{id:w.LABS,label:n("settings.section.labs"),Icon:dt,content:t.jsx(rn,{})}];return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto w-full max-w-5xl px-4 sm:px-6",children:[t.jsx("div",{className:"mb-7",children:t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:n("settings.page.title")})}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[12rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[13.5rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 border-b border-oai-gray-200 pb-3 dark:border-oai-gray-800 md:border-b-0 md:border-r md:pb-0 md:pr-5",children:t.jsx("nav",{"aria-label":n("settings.page.title"),className:"flex gap-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-1 md:overflow-visible",children:k.map(({id:m,label:v,Icon:C})=>{const N=x===m;return t.jsxs("button",{id:`settings-nav-${m}`,type:"button","aria-current":N?"page":void 0,"aria-controls":`settings-panel-${m}`,onClick:()=>S(m),className:L("inline-flex min-h-10 min-w-max shrink-0 items-center gap-1.5 rounded-md px-2 py-2 text-left text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500 md:w-full md:min-w-0 md:gap-2 md:px-3",N?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-500 hover:bg-oai-gray-50 hover:text-oai-gray-900 dark:text-oai-gray-400 dark:hover:bg-oai-gray-900 dark:hover:text-oai-gray-200"),children:[t.jsx(C,{className:L("h-4 w-4 shrink-0",N?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:v})]},m)})})}),t.jsxs("div",{className:"min-w-0",children:[k.map(({id:m,label:v,content:C})=>t.jsx("section",{id:`settings-panel-${m}`,"aria-labelledby":`settings-nav-${m}`,"aria-label":v,"data-settings-panel":m,hidden:x!==m,children:C},m)),t.jsx(un,{})]})]})]})})})}export{zn as SettingsPage};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-DPOlUkcY.js","assets/__vite-browser-external-CCMdjCX2.css"])))=>i.map(i=>d[i]);
2
+ import{m as O,j as t,e as L,c as n,a as ce,r as g,ao as ue,aU as de,au as ge,av as pe,a8 as W,aV as he,aW as me,u as be,d as R,a0 as fe,M as Z,n as M,aX as xe,aY as ye,U as Y,aZ as ve,x as ke,a_ as je,a$ as Se,b0 as we,b1 as Ne,b2 as Ce,b3 as Ee,b4 as Ae,L as Le,R as Oe,b5 as Pe,b6 as _e,a5 as H,_ as Te,h as Ie,f as Ge,b7 as Re,b8 as Ue,ax as De}from"./__vite-browser-external-DPOlUkcY.js";import{a as Me,b as F,s as He,K as Fe,P as $e,D as Be,c as Ve,S as Ke,v as ze,u as qe,C as We}from"./sortable.esm-zlY09tye.js";import{a as Ze}from"./modifiers.esm-CPTpZdHU.js";import{u as Ye,L as $}from"./use-limits-display-prefs-DJIImtLN.js";import{P as Je}from"./ProviderIcon-By8FAjxR.js";import{a as B,l as V}from"./limits-providers-DxZOjiXQ.js";import{m as J}from"./react-DKXriBSF.js";import{a as A,T as j,b,S as _,u as T}from"./Controls-BVrLC_QD.js";import{P as Xe,u as Qe,a as et}from"./use-session-efficiency-pref-C-l4b1cD.js";import{C as tt}from"./check-Cy35lAKh.js";import{C as nt}from"./copy-4szu5cYh.js";import{A as X}from"./index-DI-W-pun.js";import{u as at}from"./useCurrency-CnM8aB4v.js";import{u as st}from"./useTokenFormat-D4pAK2ld.js";import{S as U}from"./Select-C05W6XEM.js";import{I as it}from"./info-BzFpLbl6.js";import{C as ot}from"./ConfirmModal-DsCd51b2.js";import{A as rt}from"./arrow-up-right-DSsR3Ntr.js";import{D as lt}from"./download-DdGW6Krz.js";import{i as ct}from"./host-mode-Bc_iTzHk.js";import"./Card-SUbC3VNS.js";import"./ToolbarRootContext-XUDMp5uy.js";import"./composite-BDwOlhhX.js";import"./SelectItemText-CcfB3blP.js";import"./DialogTitle-C4ia00lc.js";import"./store-8e16Ac2h.js";import"./DialogDescription-BVlaoajd.js";const ut=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],dt=O("flask-conical",ut);const gt=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],pt=O("grip-vertical",gt);const ht=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],mt=O("languages",ht);const bt=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],ft=O("log-out",bt);const xt=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],yt=O("palette",xt);const vt=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],kt=O("user-round",vt),jt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function St({checked:e,onChange:a,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:a,className:L("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:t.jsx("span",{className:L("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function wt({id:e,visible:a,onToggle:s}){const{attributes:i,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:u}=qe({id:e}),p={transform:We.Transform.toString(l)||void 0,transition:c,zIndex:u?20:void 0};return t.jsxs("div",{ref:r,style:p,className:L("flex items-center gap-3 py-2 rounded-md select-none touch-none","cursor-grab active:cursor-grabbing","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u&&"relative bg-oai-gray-100 dark:bg-oai-gray-800"),...i,...o,children:[t.jsx(pt,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),B(e)?t.jsx(Je,{provider:B(e),size:18,className:L("pointer-events-none",jt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:V(e)}),t.jsx("div",{onPointerDown:h=>h.stopPropagation(),children:t.jsx(St,{checked:a,onChange:s,ariaLabel:`${n("limits.settings.toggle_visible")}: ${V(e)}`})})]})}function Nt({prefs:e}){const{order:a,visibility:s,toggle:i,moveToward:o}=e,r=Me(F($e,{activationConstraint:{distance:6}}),F(Fe,{coordinateGetter:He})),l=({active:c,over:u})=>{u&&c.id!==u.id&&o(c.id,u.id)};return t.jsx(Be,{sensors:r,collisionDetection:Ve,modifiers:[Ze],onDragEnd:l,children:t.jsx(Ke,{items:a,strategy:ze,children:t.jsx("div",{className:"flex flex-col",children:a.map(c=>t.jsx(wt,{id:c,visible:s[c]!==!1,onToggle:()=>i(c)},c))})})})}function Ct(e){if(!e||typeof e!="object")return"";const a=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},s=e.profile&&typeof e.profile=="object"?e.profile:{},i=a.full_name||a.name||s.name||a.user_name||a.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function Et(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function At(e){const a=typeof e=="string"?e.trim():"";if(!a)return null;const s=a.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=a.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=s?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function D(e,a){console.warn(`[tokentracker] settings ${e}:`,a)}function Lt(e,a,s){const[i,o]=g.useState(()=>ue()),r=a&&s&&de(),l=g.useCallback(async()=>{const c=!i;if(ge(c),o(c),!!c)try{await pe(()=>e())}catch(u){D("cloud sync",u)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function Ot(e){const[a,s]=g.useState(!1),[i,o]=g.useState(!1),[r,l]=g.useState(!1),[c,u]=g.useState(!1),[p,h]=g.useState(null),[d,y]=g.useState(!1),[x,S]=g.useState(""),[k,m]=g.useState(!1),[v,C]=g.useState(""),[N,P]=g.useState(""),[I,f]=g.useState(!1),[E,se]=g.useState(null),ie=g.useMemo(()=>Ct(e),[e]),oe=g.useMemo(()=>Et(e),[e]),re=g.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),le=g.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:h,setGithubUrl:C,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:m}),[]);return{anonymousOn:i,customDisplayName:p,displayName:ie,editingGithub:I,editingName:d,email:oe,githubError:E,githubInput:N,githubUrl:v,loadSetters:le,nameInput:x,profileLoading:r,profileSaving:c,publicProfileOn:a,setAnonymousOn:o,setCustomDisplayName:h,setEditingGithub:f,setEditingName:y,setGithubError:se,setGithubInput:P,setGithubUrl:C,setNameInput:S,setProfileLoading:l,setProfileSaving:u,setPublicProfileOn:s,setShowGithubOn:m,showGithubOn:k,userId:re}}function Pt(e,a,s){g.useEffect(()=>{if(!a)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await W({getAccessToken:e});if(!i||!o)return;const r=await he({accessToken:o});if(!i)return;s.setPublicProfileOn(!!r?.enabled),s.setAnonymousOn(!!r?.anonymous),r?.display_name&&s.setCustomDisplayName(r.display_name),s.setShowGithubOn(!!r?.show_github_url),s.setGithubUrl(r?.github_url||"")}catch(o){D("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,a,s])}function _t(e,a){return g.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(a.profileSaving)return!1;a.setProfileSaving(!0);try{const l=await W({getAccessToken:e});if(!l)return!1;const c=await me({accessToken:l,...s});return r?.(c),!0}catch(l){return o?o(l):D(i||"mutate profile",l),!1}finally{a.setProfileSaving(!1)}},[e,a])}function Tt(e,a){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:a.handleAnonymousToggle,handleSaveName:a.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:a.startEditingName}}function It(e,a){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:a.handleSaveGithub,handleShowGithubToggle:a.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:a.startEditingGithub}}function Gt(e,a){const s=g.useCallback(async()=>{const o=!e.publicProfileOn;await a({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[a,e]);return{handleAnonymousToggle:g.useCallback(async()=>{const o=!e.anonymousOn;await a({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[a,e]),handlePublicProfileToggle:s}}function Rt(e,a,s){const i=g.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await a({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),s?.()}})},[a,e,s]),o=g.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function Ut(e,a){const s=g.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await a({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[a,e]),i=g.useCallback(async()=>{const r=At(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(n("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await a({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||n("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[a,e]),o=g.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function Dt(){const e=ce(),a=Ot(e.user),s=Lt(e.getAccessToken,e.enabled,e.signedIn);Pt(e.getAccessToken,e.signedIn,a.loadSetters);const i=_t(e.getAccessToken,a),o=Gt(a,i),r=Rt(a,i,e.refreshDisplayName),l=Ut(a,i);return{...e,...s,email:a.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:a.userId,name:Tt(a,{...o,...r}),github:It(a,l),profileLoading:a.profileLoading,profileSaving:a.profileSaving,publicProfileOn:a.publicProfileOn}}function Q({disabled:e,onCancel:a,onSave:s,saveLabel:i=n("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:s,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:i}),t.jsx("button",{type:"button",onClick:a,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:n("settings.account.cancel")})]})}function Mt({nameInput:e,setEditingName:a,setNameInput:s,profileSaving:i,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>s(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&a(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.displayName")}),t.jsx(Q,{disabled:i||!e.trim(),onCancel:()=>a(!1),onSave:o,saveLabel:i?n("settings.account.saving"):void 0})]})}function Ht({githubError:e,githubInput:a,handleSaveGithub:s,profileSaving:i,setEditingGithub:o,setGithubError:r,setGithubInput:l}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:a,onChange:c=>{l(c.target.value),e&&r(null)},onKeyDown:c=>{c.key==="Enter"&&s(),c.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.githubUrlPlaceholder")}),t.jsx(Q,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:s,saveLabel:i?n("settings.account.saving"):void 0})]}),e?t.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function ee({disabled:e=!1,label:a,onClick:s,title:i}){return t.jsxs("button",{type:"button",onClick:s,disabled:e,title:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Xe,{className:"h-3.5 w-3.5","aria-hidden":!0}),a]})}function te({actions:e,editing:a,editor:s,hint:i,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),a?s:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),a?null:e]})})}function Ft({name:e}){const a=e.anonymousOn?n("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ee,{disabled:e.anonymousOn,label:n("settings.account.edit"),onClick:e.startEditingName,title:a}),t.jsx(j,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:n("settings.account.displayName")})]})}function $t({name:e}){const{anonymousOn:a,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:u,profileSaving:p,setEditingName:h,setNameInput:d,startEditingName:y}=e,x=a?n("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(te,{label:n("settings.account.displayName"),editing:o,hint:x,editor:t.jsx(Mt,{nameInput:c,setEditingName:h,setNameInput:d,profileSaving:p,handleSaveName:l}),actions:t.jsx(Ft,{name:e})})}function Bt({github:e}){const{editingGithub:a,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:u,setEditingGithub:p,setGithubError:h,setGithubInput:d,showGithubOn:y,startEditingGithub:x}=e;return t.jsx(t.Fragment,{children:t.jsx(te,{label:n("settings.account.githubUrl"),editing:a,hint:o||n("settings.account.githubUrlHint"),editor:t.jsx(Ht,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:u,setEditingGithub:p,setGithubError:h,setGithubInput:d}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ee,{label:n("settings.account.edit"),onClick:x}),t.jsx(j,{checked:y,onChange:l,disabled:c||u,ariaLabel:n("settings.account.githubUrl")})]})})})}function Vt(){const{openLoginModal:e}=be();return t.jsx(A,{title:n("settings.section.account"),children:t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.account.signedOutHint")}),t.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:n("settings.account.signIn")})]})})}function Kt({name:e,github:a}){return t.jsxs(t.Fragment,{children:[t.jsx($t,{name:e}),t.jsx(Bt,{github:a})]})}function zt(){const e=Dt();return e.enabled?e.signedIn?t.jsxs(A,{title:n("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Wt,{onSignOut:e.signOut}),children:[t.jsx(qt,{userId:e.userId}),t.jsx(Zt,{settings:e}),t.jsx(Yt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(Jt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(Vt,{}):null}function qt({userId:e}){const[a,s]=R.useState(!1);if(!e)return null;const i=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),s(!0),globalThis.setTimeout(()=>s(!1),1200)}catch{s(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:n("settings.account.userId")}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),t.jsxs("button",{type:"button",onClick:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":n("settings.account.copyUserId"),children:[a?t.jsx(tt,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(nt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a?n("settings.account.copied"):n("settings.account.copy")]})]})}function Wt({onSignOut:e}){return t.jsxs("button",{type:"button",onClick:()=>e(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[t.jsx(ft,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.signOut")]})}function Zt({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:n("settings.account.cloudSync"),hint:n("settings.account.cloudSyncHint"),control:t.jsx(j,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:n("settings.account.cloudSync")})}):null}function Yt({checked:e,disabled:a,onChange:s}){return t.jsx(b,{label:n("settings.account.publicProfile"),hint:n("settings.account.publicProfileHint"),control:t.jsx(j,{checked:e,onChange:s,disabled:a,ariaLabel:n("settings.account.publicProfile")})})}function Jt({visible:e,name:a,github:s}){return t.jsx(X,{initial:!1,children:e?t.jsx(J.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:t.jsx(Kt,{name:a,github:s})},"public-profile-fields"):null})}function Xt(){return[{value:"light",label:n("settings.appearance.theme.light"),Icon:xe},{value:"dark",label:n("settings.appearance.theme.dark"),Icon:ye},{value:"system",label:n("settings.appearance.theme.system"),Icon:Y}]}function Qt(){return[{value:je,label:n("settings.appearance.language.system")},{value:Se,label:n("settings.appearance.language.english")},{value:we,label:n("settings.appearance.language.chinese")},{value:Ne,label:n("settings.appearance.language.traditional_chinese")},{value:Ce,label:n("settings.appearance.language.japanese")},{value:Ee,label:n("settings.appearance.language.korean")},{value:Ae,label:n("settings.appearance.language.german")}]}function en(e){if(!e)return null;try{const a=new Date(e);return Number.isNaN(a.getTime())?null:a.toLocaleString()}catch{return null}}function tn(e,a){const s=n(`settings.appearance.currency.rate_source.${e}`),i=en(a),o=i?n("settings.appearance.currency.rate_updated",{when:i}):n("settings.appearance.currency.rate_never");return`${s} · ${o}`}function nn({locale:e,setLocale:a}){const s=Qt();return t.jsx(U,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(mt,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function an({currency:e,setCurrency:a}){const s=ve().map(i=>({value:i.code,label:n(i.labelKey)}));return t.jsx(U,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function sn({currency:e,rate:a,rateSource:s,rateFetchedAt:i}){if(e===ke)return t.jsx(t.Fragment,{children:n("settings.appearance.currency.hint")});const o=tn(s,i);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${a.toFixed(4)} ${e}`}),t.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:t.jsx(it,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function on(){const{theme:e,setTheme:a}=fe(),{locale:s,setLocale:i}=Z(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:u}=at(),{mode:p,setMode:h}=st();return t.jsxs(A,{title:n("settings.section.appearance"),children:[t.jsx(b,{label:n("settings.appearance.theme.label"),hint:n("settings.appearance.theme.hint"),control:t.jsx(_,{options:Xt(),value:e,onChange:a})}),t.jsx(b,{label:n("settings.appearance.language.label"),hint:n("settings.appearance.language.hint"),control:t.jsx(nn,{locale:s,setLocale:i})}),t.jsx(b,{label:n("settings.appearance.currency.label"),hint:t.jsx(sn,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(an,{currency:o,setCurrency:u})}),t.jsx(b,{label:n("settings.appearance.token_format.label"),hint:n("settings.appearance.token_format.hint"),control:t.jsx(_,{options:[{value:M.COMPACT,label:n("settings.appearance.token_format.compact")},{value:M.FULL,label:n("settings.appearance.token_format.full")}],value:p,onChange:h})})]})}function G({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:n(e)}),t.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-semibold tracking-wider text-oai-gray-500 bg-oai-gray-100 dark:text-oai-gray-400 dark:bg-oai-gray-800/80 rounded uppercase scale-90 origin-left",children:n("qpd.card.badge")})]})}function rn(){const{enabled:e,toggle:a}=Qe(),{enabled:s,toggle:i}=et(),{available:o,settings:r,setSetting:l}=T(),c=o&&!!r?.dynamicIslandSupported,u=!!r?.dynamicIslandEnabled;return t.jsxs(A,{title:n("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.island.label"}),hint:n("settings.labs.island.hint"),control:t.jsx(j,{checked:u,onChange:()=>l("dynamicIslandEnabled",!u),ariaLabel:n("settings.labs.island.aria")})}),u&&t.jsx(b,{label:n("settings.labs.island_hide_menubar.label"),hint:n("settings.labs.island_hide_menubar.hint"),control:t.jsx(j,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:n("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.qpd.label"}),hint:n("settings.labs.qpd.hint"),control:t.jsx(j,{checked:e,onChange:a,ariaLabel:n("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.sessions.label"}),hint:n("settings.labs.sessions.hint"),control:t.jsx(j,{checked:s,onChange:i,ariaLabel:n("settings.labs.sessions.aria")})})]})}function ln(){const{available:e,settings:a,setSetting:s,runAction:i}=T();if(!e)return null;const o=!!a?.launchAtLogin,r=a?.toastOnReset!==!1,l=a?.confettiOnReset!==!1,c=a?.launchAtLoginSupported!==!1,u=a?.autoUpdateEnabled!==!1,p=a?.updateStatus||null,h=!!a?.updateBusy,d=!!a?.isSyncing;return t.jsxs(A,{title:n("settings.section.menubar"),children:[t.jsx(b,{label:n("settings.menubar.appearance"),hint:n("settings.menubar.appearanceHint"),control:t.jsxs(Le,{to:"/widgets",className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 no-underline transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n("settings.menubar.appearanceLink"),t.jsx(rt,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(j,{checked:r,onChange:()=>s("toastOnReset",!r),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(j,{checked:l,onChange:()=>s("confettiOnReset",!l),ariaLabel:n("settings.menubar.confettiOnReset")})}),c?t.jsx(b,{label:n("settings.menubar.launchAtLogin"),hint:n("settings.menubar.launchAtLoginHint"),control:t.jsx(j,{checked:o,onChange:()=>s("launchAtLogin",!o),ariaLabel:n("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:n("settings.menubar.syncNow"),hint:n("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Oe,{className:L("h-3.5 w-3.5",d&&"animate-spin"),"aria-hidden":!0}),d?n("settings.menubar.syncing"):n("settings.menubar.syncNow")]})}),t.jsx(b,{label:n("settings.menubar.autoUpdate"),hint:n("settings.menubar.autoUpdateHint"),control:t.jsx(j,{checked:u,onChange:()=>s("autoUpdateEnabled",!u),ariaLabel:n("settings.menubar.autoUpdate")})}),t.jsx(b,{label:n("settings.menubar.updates"),hint:p||void 0,control:t.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:h,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(lt,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.menubar.checkUpdates")]})})]})}function cn(e,a){function s(r){return r.replace(/^v/,"").split(".").map(Number)}const i=s(e),o=s(a);for(let r=0;r<Math.max(i.length,o.length);r++){const l=i[r]||0,c=o[r]||0;if(l<c)return!0;if(l>c)return!1}return!1}function un(){const{available:e,settings:a,runAction:s}=T(),i=e&&a?.version,[o,r]=R.useState(!1),[l,c]=R.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:u}=Z(),p="0.95.2",h=async()=>{r(!0);try{const k=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!k.ok)throw new Error("Failed to fetch");const m=await k.json(),v=m.tag_name;cn(p,v)?c({open:!0,latestVersion:v,htmlUrl:m.html_url}):H({title:n("settings.menubar.updates.upToDate")})}catch(k){console.error("Check updates failed:",k),H({title:n("settings.menubar.updates.failed")})}finally{r(!1)}},d=n("settings.menubar.updates.modalTitle"),y=n("settings.menubar.updates.modalDescription",{version:l.latestVersion}),x=n("settings.menubar.updates.modalConfirm"),S=n("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCombined",{barVersion:a.version,coreVersion:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>s("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCore",{version:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:h,disabled:o,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:o?n("settings.menubar.updates.checking"):n("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Pe,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:[t.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.footer.statusPage")]})]}),t.jsx(ot,{open:l.open,title:d,description:y,confirmLabel:x,cancelLabel:S,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),c(k=>({...k,open:!1}))},onCancel:()=>c(k=>({...k,open:!1}))})]})}const dn=()=>[{value:"system",label:n("settings.network.mode.system")},{value:"manual",label:n("settings.network.mode.manual")},{value:"off",label:n("settings.network.mode.off")}],gn=()=>[{value:"http",label:n("settings.network.protocol.http")},{value:"https",label:n("settings.network.protocol.https")},{value:"socks5",label:n("settings.network.protocol.socks5")}],K="w-full rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white";function z(e){const a={},s=String(e.host||"").trim();(!s||/:\/\//.test(s)||s.includes("/"))&&(a.host=n("settings.network.error.host"));const i=String(e.port??"").trim(),o=Number(i);return(!i||!/^\d+$/.test(i)||!Number.isInteger(o)||o<1||o>65535)&&(a.port=n("settings.network.error.port")),a}function pn({proxySettings:e}){const{config:a,save:s,testConnection:i}=e,[o,r]=g.useState(()=>({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})),[l,c]=g.useState({}),[u,p]=g.useState(!1),[h,d]=g.useState(""),[y,x]=g.useState(null),[S,k]=g.useState(!1),[m,v]=g.useState(null);g.useEffect(()=>{r({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})},[a.mode,a.protocol,a.host,a.port]);const C=g.useMemo(()=>a.effective==="manual"?n("settings.network.effective.manual"):a.effective==="env"?n("settings.network.effective.env"):a.effective==="system"?n("settings.network.effective.system"):a.effective==="blocked"?n("settings.network.effective.blocked"):n("settings.network.effective.none"),[a.effective]),N=f=>{r(E=>({...E,...f})),c({}),d(""),x(null),v(null)},P=async()=>{if(o.mode==="manual"){const f=z(o);if(Object.keys(f).length){c(f);return}}p(!0),d(""),x(null);try{await s(o),d("saved")}catch(f){d("error"),x(f)}finally{p(!1)}},I=async()=>{const f=z(o);if(Object.keys(f).length){c(f);return}k(!0),v(null);try{const E=await i(o);v(E)}catch(E){v({ok:!1,error:E?.message||String(E)})}finally{k(!1)}};return t.jsxs(A,{title:n("settings.section.network"),subtitle:C,children:[a.applyError?t.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:n("settings.network.apply_error",{error:a.applyError})}):null,t.jsx(b,{label:n("settings.network.mode.label"),hint:n("settings.network.mode.hint"),control:t.jsx(_,{options:dn(),value:o.mode,onChange:f=>N({mode:f})})}),t.jsx(X,{initial:!1,children:o.mode==="manual"?t.jsxs(J.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:[t.jsx(b,{label:n("settings.network.protocol.label"),control:t.jsx(U,{value:o.protocol,onValueChange:f=>N({protocol:f}),options:gn(),ariaLabel:n("settings.network.protocol.label"),className:"px-2.5 py-1.5 text-xs font-medium"})}),t.jsx(b,{label:n("settings.network.host.label"),hint:l.host,control:t.jsx("input",{type:"text",value:o.host,onChange:f=>N({host:f.target.value}),placeholder:n("settings.network.host.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.host?!0:void 0,"aria-label":n("settings.network.host.label"),className:K})}),t.jsx(b,{label:n("settings.network.port.label"),hint:l.port,control:t.jsx("input",{type:"text",inputMode:"numeric",value:o.port,onChange:f=>N({port:f.target.value}),placeholder:n("settings.network.port.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.port?!0:void 0,"aria-label":n("settings.network.port.label"),className:K})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[t.jsx("button",{type:"button",onClick:I,disabled:S||u,className:"rounded-md border border-oai-gray-200 px-3 py-1.5 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:S?n("settings.network.test.testing"):n("settings.network.test")}),t.jsx("button",{type:"button",onClick:P,disabled:u||S,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})]}),m?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:m.ok?n("settings.network.test.ok",{status:String(m.status??"")}):n("settings.network.test.fail",{error:m.error||""})}):null]},"manual-proxy-fields"):t.jsx("div",{className:"flex justify-end py-3",children:t.jsx("button",{type:"button",onClick:P,disabled:u,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})},"non-manual-save")}),h==="saved"?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.network.saved")}):null,h==="error"?t.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:y?.unprotected?n("settings.network.save_error_unprotected",{error:y?.message||String(y||"")}):n("settings.network.save_error",{error:y?.message||String(y||"")})}):null]})}const ne="/functions/tokentracker-proxy-config",hn="/functions/tokentracker-proxy-test",mn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function ae(e){return!e||typeof e.mode!="string"?null:{mode:e.mode,protocol:typeof e.protocol=="string"?e.protocol:"http",host:typeof e.host=="string"?e.host:"",port:e.port==null||e.port===0?"":String(e.port),effective:typeof e.effective=="string"?e.effective:"none",applyError:typeof e.applyError=="string"&&e.applyError.trim()?e.applyError:null}}async function bn(){const e=await fetch(ne,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!e.ok)return null;const a=await e.json().catch(()=>null);return ae(a)}async function q(){const{getLocalApiAuthHeaders:e}=await Te(async()=>{const{getLocalApiAuthHeaders:a}=await import("./__vite-browser-external-DPOlUkcY.js").then(s=>s.d8);return{getLocalApiAuthHeaders:a}},__vite__mapDeps([0,1]));return e()}function fn(){const[e,a]=g.useState(!1),[s,i]=g.useState(!0),[o,r]=g.useState(mn);g.useEffect(()=>{if(!ct()){a(!1),i(!1);return}let u=!1;return(async()=>{try{const p=await bn();if(u)return;if(!p){a(!1),i(!1);return}r(p),a(!0),i(!1)}catch{u||(a(!1),i(!1))}})(),()=>{u=!0}},[]);const l=g.useCallback(async u=>{const p=await q(),h=await fetch(ne,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({mode:u.mode,protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),d=await h.json().catch(()=>null);if(!h.ok){const x=d&&typeof d.error=="string"?d.error:`HTTP ${h.status}`;throw new Error(x)}const y=ae(d);if(y&&r(y),d&&d.ok===!1){const x=d&&typeof d.applyError=="string"&&d.applyError||d&&typeof d.error=="string"&&d.error||`HTTP ${h.status}`,S=new Error(x);throw d.unprotected===!0&&(S.unprotected=!0),S}return y||d},[]),c=g.useCallback(async u=>{const p=await q(),h=await fetch(hn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),d=await h.json().catch(()=>null);if(!d||typeof d.ok!="boolean")throw new Error(d&&typeof d.error=="string"?d.error:`HTTP ${h.status}`);return d},[]);return{available:e,loading:s,config:o,save:l,testConnection:c}}const w={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"};function xn({prefs:e}){return t.jsx(_,{options:[{value:$.USED,label:n("limits.settings.display_mode_used")},{value:$.REMAINING,label:n("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function zn(){const e=Ye(),{available:a,settings:s,setSetting:i}=T(),o=fn(),{available:r}=o,l=s?.toastOnReset!==!1,c=s?.confettiOnReset!==!1,[u,p]=Ie(),h=Ge(),d=u.get("section"),x=Object.values(w).includes(d)&&(d!==w.NATIVE_APP||a)&&(d!==w.NETWORK||r)?d:w.APPEARANCE,S=m=>{const v=new URLSearchParams(u);m===w.APPEARANCE?v.delete("section"):v.set("section",m),p(v,{replace:!0})},k=[{id:w.APPEARANCE,label:n("settings.section.appearance"),Icon:yt,content:t.jsx(on,{})},...a?[{id:w.NATIVE_APP,label:n("settings.section.menubar"),Icon:Y,content:t.jsx(ln,{})}]:[],...r?[{id:w.NETWORK,label:n("settings.section.network"),Icon:Re,content:t.jsx(pn,{proxySettings:o})}]:[],{id:w.ACCOUNT,label:n("settings.section.account"),Icon:kt,content:t.jsx(zt,{})},{id:w.LIMITS,label:n("settings.section.limits"),Icon:Ue,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(A,{title:n("settings.section.limits"),children:[t.jsx(b,{label:n("limits.settings.display_mode_label"),control:t.jsx(xn,{prefs:e})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(j,{checked:l,disabled:!a,onChange:()=>i("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(j,{checked:c,disabled:!a,onChange:()=>i("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})}),t.jsx(b,{label:n("settings.limits.showSubscriptions"),hint:n("settings.limits.showSubscriptionsHint"),control:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>h("/limits?openSubscriptions=1"),"aria-label":n("limits.page.openSubscriptions"),title:n("limits.page.openSubscriptions"),className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-white dark:bg-oai-gray-900 text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:t.jsx(De,{size:14,"aria-hidden":!0})}),t.jsx(j,{checked:e.showSubscriptions!==!1,onChange:()=>e.setShowSubscriptions(!e.showSubscriptions),ariaLabel:n("settings.limits.showSubscriptions")})]})})]}),t.jsx(A,{title:n("settings.limits.providers"),children:t.jsx(Nt,{prefs:e})})]})},{id:w.LABS,label:n("settings.section.labs"),Icon:dt,content:t.jsx(rn,{})}];return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto w-full max-w-5xl px-4 sm:px-6",children:[t.jsx("div",{className:"mb-7",children:t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:n("settings.page.title")})}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[12rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[13.5rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 border-b border-oai-gray-200 pb-3 dark:border-oai-gray-800 md:border-b-0 md:border-r md:pb-0 md:pr-5",children:t.jsx("nav",{"aria-label":n("settings.page.title"),className:"flex gap-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-1 md:overflow-visible",children:k.map(({id:m,label:v,Icon:C})=>{const N=x===m;return t.jsxs("button",{id:`settings-nav-${m}`,type:"button","aria-current":N?"page":void 0,"aria-controls":`settings-panel-${m}`,onClick:()=>S(m),className:L("inline-flex min-h-10 min-w-max shrink-0 items-center gap-1.5 rounded-md px-2 py-2 text-left text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500 md:w-full md:min-w-0 md:gap-2 md:px-3",N?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-500 hover:bg-oai-gray-50 hover:text-oai-gray-900 dark:text-oai-gray-400 dark:hover:bg-oai-gray-900 dark:hover:text-oai-gray-200"),children:[t.jsx(C,{className:L("h-4 w-4 shrink-0",N?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:v})]},m)})})}),t.jsxs("div",{className:"min-w-0",children:[k.map(({id:m,label:v,content:C})=>t.jsx("section",{id:`settings-panel-${m}`,"aria-labelledby":`settings-nav-${m}`,"aria-label":v,"data-settings-panel":m,hidden:x!==m,children:C},m)),t.jsx(un,{})]})]})]})})})}export{zn as SettingsPage};