tokentracker-cli 1.5.6 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dashboard/dist/assets/{AchievementBadge-NKpY___e.js → AchievementBadge-Ck1DmXtu.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-9nXmSX72.js → AchievementsPage-DjvMoc2i.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-DttQciSY.js → AchievementsSection-DvTHE8Vd.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-bvWEdJbe.js → BadgeDetailModal-COa2Rd6M.js} +1 -1
- package/dashboard/dist/assets/{BotAnimated-ChuUfph8.js → BotAnimated-CeR3jSce.js} +1 -1
- package/dashboard/dist/assets/{Card-SWtLDXt1.js → Card-bQCEOe_K.js} +1 -1
- package/dashboard/dist/assets/{CloudCheckoutPage-c2fNl1Rl.js → CloudCheckoutPage-DDH-3QOd.js} +1 -1
- package/dashboard/dist/assets/{CloudPage-CfwDjZMS.js → CloudPage-RygH3R8b.js} +2 -2
- package/dashboard/dist/assets/{CommandPalette-tWgPa295.js → CommandPalette-E7YqsdAH.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-D7UaaUdM.js → CommunityStatsModal-B5heTDUE.js} +1 -1
- package/dashboard/dist/assets/{ConfirmModal-BrBcKhfW.js → ConfirmModal-D3vd882N.js} +1 -1
- package/dashboard/dist/assets/{Controls-CcvBkk7W.js → Controls-CK74JkE8.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-DwTrlQZQ.js +1 -0
- package/dashboard/dist/assets/{DateRangePopover-BkN_pird.js → DateRangePopover-BxVCPuEX.js} +1 -1
- package/dashboard/dist/assets/{DevicePage-BbUL7WwT.js → DevicePage-B6x5fBdU.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-BXO8SBFr.js → DialogClose-teXmwU1d.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-BSCcGkVT.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-Du332auj.js → DialogTitle-B3m-31sy.js} +1 -1
- package/dashboard/dist/assets/{ElectricLogo-CXLYfOt7.js → ElectricLogo-0wyvks4K.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-HSQBOc8B.js → FadeIn-C60pLKXu.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-D5tyQDGE.js → HeaderGithubStar-CCEUzMqo.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-BhidhbnD.js → HoverTooltip-D9RtbhSZ.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-WMEF1oS3.js → IpCheckPage-BCyW0SWY.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-BmO-59ZP.js → LandingPage-DCEofDST.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardPage-C2WyniEt.js → LeaderboardPage-CsTbalIm.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProBadge-DAZnMRNn.js → LeaderboardProBadge-Crun5RUJ.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfileModal-D1BxcloV.js → LeaderboardProfileModal-Bim9cms6.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-RPJDTwpG.js → LeaderboardProfilePage-D9pBE7f4.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-9ZOhKvn5.js → LimitsPage-CFhzwKzB.js} +6 -6
- package/dashboard/dist/assets/{LocalOnlyNotice-CH6w4hRw.js → LocalOnlyNotice-F_qczacX.js} +1 -1
- package/dashboard/dist/assets/{LoginCard-D24HsRjs.js → LoginCard-CQm_T5K2.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-sLvHyi9U.js → LoginModal-BUf4mPCT.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-PIvLEw1Y.js → LoginPage-njdEUQEX.js} +1 -1
- package/dashboard/dist/assets/{PetPage-DYcw_4P1.js → PetPage-COczIU1k.js} +2 -2
- package/dashboard/dist/assets/{PopoverPopup-D7ZCWq5f.js → PopoverPopup-DxB1k4g7.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-B0kB52K-.js → ProviderIcon-BQfkoaQE.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-B_NT4Xfl.js → ResetPasswordPage-PGRVaPTN.js} +1 -1
- package/dashboard/dist/assets/{Select-BtxjjP2Q.js → Select-CQVnpoBO.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-Co1M6XRC.js → SelectItemText-DmAn7osh.js} +1 -1
- package/dashboard/dist/assets/{SelfHostPage-XadfhFnd.js → SelfHostPage-BUURA-Vt.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-ZEJyAxsQ.js → ServiceStatusPage-DuzSen0Q.js} +1 -1
- package/dashboard/dist/assets/SessionsPage-DndGq61W.js +3 -0
- package/dashboard/dist/assets/{SettingsPage-D4qHgIxn.js → SettingsPage-CHh0yqsZ.js} +3 -3
- package/dashboard/dist/assets/{SkillsPage-CkQCk2uF.js → SkillsPage-CCaYXQWN.js} +1 -1
- package/dashboard/dist/assets/{TokenGalaxy-Bx1vr4b0.js → TokenGalaxy-CGxUtq9x.js} +1 -1
- package/dashboard/dist/assets/{TooltipPopup-DQW8FWJO.js → TooltipPopup-B_B4qQD-.js} +1 -1
- package/dashboard/dist/assets/{TrendMonitor-BMNcY3N8.js → TrendMonitor-CdRQTLZL.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-luRTge7O.js → WidgetsPage-DP_w32wh.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-B1j3WgXx.js → WrappedPage-C_DCqHUH.js} +1 -1
- package/dashboard/dist/assets/{__vite-browser-external-CvvpsW-U.js → __vite-browser-external-Lw3ipvYF.js} +3 -3
- package/dashboard/dist/assets/{agent-logos-DL4fdks6.js → agent-logos-DlnSKc2A.js} +1 -1
- package/dashboard/dist/assets/{arrow-left-DiOsjgdu.js → arrow-left-CjLKt_5C.js} +1 -1
- package/dashboard/dist/assets/{arrow-right-DBFXV7GU.js → arrow-right-Bh-Ezs8y.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-BIvpDQHo.js → arrow-up-right-C87CvEJ5.js} +1 -1
- package/dashboard/dist/assets/{calendar-days--psnXUPW.js → calendar-days-B5VHwV9j.js} +1 -1
- package/dashboard/dist/assets/{check-DLqbsN00.js → check-D2uclldH.js} +1 -1
- package/dashboard/dist/assets/{chevron-down-C0P0oLzP.js → chevron-down-Beacyoub.js} +1 -1
- package/dashboard/dist/assets/{cloud-checkout-NSmb7QNy.js → cloud-checkout-3Y7NDSG1.js} +1 -1
- package/dashboard/dist/assets/{composite-D7ahPHYQ.js → composite-B28yORTL.js} +1 -1
- package/dashboard/dist/assets/{copy-COD7vwd6.js → copy-C8fZJwms.js} +1 -1
- package/dashboard/dist/assets/{download-CpSUX4U-.js → download-IIXYYmyo.js} +1 -1
- package/dashboard/dist/assets/{external-link-DXUjrooT.js → external-link-BEb0dms0.js} +1 -1
- package/dashboard/dist/assets/{flame-Dl3ZT9oo.js → flame-gmfpE-PO.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-Ci49THbK.js → format-tokens-CKwy7NXi.js} +1 -1
- package/dashboard/dist/assets/{gift-DTHCN1Of.js → gift-twpInP_O.js} +1 -1
- package/dashboard/dist/assets/{icons-CB9s1e1k.js → icons-DQfkB5-5.js} +1 -1
- package/dashboard/dist/assets/{index-DFdfNKJM.js → index-ChVgw-dM.js} +1 -1
- package/dashboard/dist/assets/{index-Dozwi-Se.js → index-ClwErGKW.js} +1 -1
- package/dashboard/dist/assets/{index-BGT8ZQyn.js → index-D2-6Msd9.js} +1 -1
- package/dashboard/dist/assets/{index-DeX4t_5p.js → index-DzUxfO5e.js} +1 -1
- package/dashboard/dist/assets/{info-CqM2wmSI.js → info-BvndJDmD.js} +1 -1
- package/dashboard/dist/assets/{link-2-Byo7Rj3t.js → link-2-BhU_5JKG.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-CMxd78Na.js → loader-circle-BR_62BDE.js} +1 -1
- package/dashboard/dist/assets/{local-usage-transfer-CBjnoeck.js → local-usage-transfer-CfoyR0hM.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-Oowlk_FC.js → modifiers.esm-CnttlnRD.js} +1 -1
- package/dashboard/dist/assets/{monitor-smartphone-B2EgB_9q.js → monitor-smartphone-D4vzGxrq.js} +1 -1
- package/dashboard/dist/assets/{play-BSuP-UBL.js → play-BVWEKYTF.js} +1 -1
- package/dashboard/dist/assets/{plus-BWemSIuC.js → plus-B9GQ6VvV.js} +1 -1
- package/dashboard/dist/assets/{provider-display-BpzWuFDH.js → provider-display-DCFgR7FO.js} +1 -1
- package/dashboard/dist/assets/{react-cIJ4zx62.js → react-BKUD3UPr.js} +1 -1
- package/dashboard/dist/assets/{safePolygon-C_ZMtbgL.js → safePolygon-DPIi3FGf.js} +1 -1
- package/dashboard/dist/assets/{search-BK7eyNds.js → search-BBRJvYNz.js} +1 -1
- package/dashboard/dist/assets/{server-BqQHX-rd.js → server-Cg3zBK6a.js} +1 -1
- package/dashboard/dist/assets/{shield-check-CO5U6gRw.js → shield-check-BBzYplRb.js} +1 -1
- package/dashboard/dist/assets/{skills-api-CMye76ag.js → skills-api-CcAQ6fJX.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-Bvb61Lvj.js → sortable.esm-kNieGfR9.js} +1 -1
- package/dashboard/dist/assets/{store-CICV1KXb.js → store-DQpd_ZKv.js} +1 -1
- package/dashboard/dist/assets/{terminal-BKMWT1Ux.js → terminal-zj_c8_SG.js} +1 -1
- package/dashboard/dist/assets/{trash-D2Oqim4r.js → trash-Sl7eOlF7.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-CEqwmjct.js → use-community-stats-Bg-4yvQQ.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-CTuzzu3F.js → use-latest-request-guard-COF23Bfs.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-CA2BLWkY.js → use-limits-display-prefs-QOlhCOgQ.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-B54wHSj9.js → use-native-settings-CKDqyirL.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list--PU9ekxY.js → use-ordered-list-mFHPMcF_.js} +1 -1
- package/dashboard/dist/assets/use-reduced-motion-B4rpC-Zt.js +1 -0
- package/dashboard/dist/assets/{use-transform-BRyR8szg.js → use-transform-CO5wZ0ML.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-sufKdfDY.js → use-usage-limits-CeKjW8jG.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-6oy7kSX8.js → useCurrency-WruYNKxG.js} +1 -1
- package/dashboard/dist/assets/{usePositioner-ZtDdVdJg.js → usePositioner-C3NGxtZa.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-tiOJ-PeE.js → useTokenFormat-ObRZ_T9W.js} +1 -1
- package/dashboard/dist/assets/{zap-Dr1dXUjN.js → zap-CyZ3Tf1D.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/ip-check.html +1 -1
- package/dashboard/dist/leaderboard.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
- package/src/commands/init.js +9 -0
- package/src/commands/status.js +12 -6
- package/src/commands/sync.js +22 -4
- package/src/lib/claude-backend.js +291 -0
- package/src/lib/claude-config.js +1 -1
- package/src/lib/cursor-config.js +3 -1
- package/src/lib/devin-limits.js +65 -25
- package/src/lib/diagnostics.js +3 -0
- package/src/lib/doctor.js +13 -0
- package/src/lib/local-api.js +2 -0
- package/src/lib/local-usage-transfer.js +22 -1
- package/src/lib/pricing/index.js +12 -0
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +70 -15
- package/src/lib/session-analytics.js +20 -8
- package/src/lib/trae-cn-config.js +32 -2
- package/src/lib/usage-limits.js +601 -35
- package/dashboard/dist/assets/DashboardPage-DJSgRHGq.js +0 -1
- package/dashboard/dist/assets/DialogDescription-B1HyKP0x.js +0 -1
- package/dashboard/dist/assets/SessionsPage-Cte1taUu.js +0 -3
- package/dashboard/dist/assets/use-reduced-motion-CZ8_YWc2.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bK as Cn,r as o,cz as st,b0 as $e,b9 as Kt,c4 as qt,K as Ue,N as me,cw as Tn,aZ as _e,b2 as q,b3 as En,cA as zt,cx as wn,b1 as $,dm as Lt,dn as ht,dp as Vt,c2 as xt,b4 as Be,bc as ye,dq as Dt,bs as kt,dr as vn,bN as Yt,c0 as $t,ds as ct,dt as ut,du as Xt,dv as Et,cI as Mn,dw as On,dx as yt,cO as Pn,bI as Xe,aX as re,j as ge,c6 as It,cb as An,cd as Fn,ce as Ln,b_ as it,bJ as Vn,cC as Dn,bP as kn,bu as rt,cu as Hn,M as Gt,J as We,dy as Nn,bV as Un,dz as _n,bY as Bn,bZ as Jt,b7 as Wn,dA as jn,ca as Zt,dB as St}from"./__vite-browser-external-CvvpsW-U.js";import{i as Rt,E as Qt,b as en,F as Kn,P as qn,c as Fe,a as zn,G as Yn,H as Te,J as tn,B as $n,u as Xn,K as Gn,n as Jn,y as Zn,d as Qn,r as er,I as tr,x as nr,p as rr,C as or,D as sr}from"./composite-D7ahPHYQ.js";import{u as ir,a as lr,b as cr,p as ur,r as ar,g as fr}from"./usePositioner-ZtDdVdJg.js";function ze(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function dr(e,t={}){const{enabled:n=!0,event:r="click",toggle:s=!0,ignoreMouse:i=!1,stickIfOpen:l=!0,touchOpenDelay:d=0,reason:u=Cn}=t,C=e.context.dataRef,h=o.useRef(void 0),p=st(),T=$e(),g=o.useMemo(()=>{function P(c,v,U,E){const a=me(u,v,U);c&&E==="touch"&&d>0?T.start(d,()=>{e.setOpen(!0,a)}):e.setOpen(c,a)}function F(c,v,U){const E=C.current.openEvent,a=e.select("domReferenceElement")!==v;return c&&a||!c||!s?!0:E&&(typeof l=="function"?l():l)?!U(E.type):!1}return{onPointerDown(c){h.current=Rt(c.pointerType,!0)&&Qt(c.nativeEvent)?"virtual":c.pointerType},onMouseDown(c){const v=h.current,U=c.nativeEvent,E=e.select("open");if(c.button!==0||r==="click"||Rt(v,!0)&&i)return;const a=F(E,c.currentTarget,A=>A==="click"||A==="mousedown"),R=Kt(U),w=qt(R);if(w||v==="virtual"){P(a,U,w?R:c.currentTarget,v);return}const I=c.currentTarget;p.request(()=>{P(a,U,I,v)})},onClick(c){if(r==="mousedown-only")return;const v=h.current;if(r==="mousedown"&&v){h.current=void 0;return}if(Rt(v,!0)&&i)return;const U=e.select("open"),E=F(U,c.currentTarget,a=>a==="click"||a==="mousedown"||a==="keydown"||a==="keyup");P(E,c.nativeEvent,c.currentTarget,v)},onKeyDown(){h.current=void 0}}},[C,r,i,u,e,l,s,p,T,d]);return o.useMemo(()=>n?{reference:g}:Ue,[n,g])}function pr(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,s=Tn(),i=en()!=null,l=_e(()=>new Kn({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new qn,floatingId:s,syncOnly:!1,nested:i})).current;return q(()=>{const d={open:t,floatingId:s};r.reference!==void 0&&(d.referenceElement=r.reference,d.domReferenceElement=En(r.reference)?r.reference:null),r.floating!==void 0&&(d.floatingElement=r.floating),l.update(d)},[t,s,r.reference,r.floating,l]),l.context.onOpenChange=n,l.context.nested=i,l}function Ht(e){return $t&&e.movementX===0&&e.movementY===0}function at(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Ze(e,t){return at(t,e===Xt||e===Et,e===ct||e===ut)}function bt(e,t,n){return at(t,e===Et,n?e===ct:e===ut)||e==="Enter"||e===" "||e===""}function gr(e,t,n){return at(t,n?e===ct:e===ut,e===Et)}function mr(e,t,n,r){const s=n?e===ut:e===ct,i=e===Xt;return t==="both"||t==="horizontal"&&r?e==="Escape":at(t,s,i)}function hr(e,t){const{listRef:n,activeIndex:r,onNavigate:s=()=>{},enabled:i=!0,selectedIndex:l=null,allowEscape:d=!1,loopFocus:u=!1,nested:C=!1,rtl:h=!1,virtual:p=!1,focusItemOnOpen:T="auto",focusItemOnHover:g=!0,openOnArrowKeyDown:P=!0,disabledIndices:F=void 0,orientation:c="vertical",triggerOrientation:v=c,parentOrientation:U,id:E,resetOnPointerLeave:a=!0,externalTree:R,nestedReturnFocusRef:w,grid:I}=t,A=I!=null,O=e.useState("open"),H=e.useState("floatingElement"),z=e.useState("domReferenceElement"),X=e.context.dataRef,y=zt(H),k=wn(z),B=Fe(y),ie=en(),G=zn(R),J=o.useRef(T),x=o.useRef(l??-1),f=o.useRef(null),D=o.useRef(!0),b=$(m=>{s(x.current===-1?null:x.current,m)}),M=o.useRef(!!H),W=o.useRef(O),K=o.useRef(!1),te=o.useRef(!1),ee=o.useRef(null),fe=Fe(F),ue=Fe(O),Z=Fe(l),ae=Fe(a),j=st(),Y=st(),oe=$(()=>{j.cancel();function m(V){p||(ee.current=Yn(V,{sync:K.current,preventScroll:!0}))}const L=n.current[x.current],Q=te.current;L&&m(L),(K.current?V=>V():V=>j.request(V))(()=>{const V=n.current[x.current]||L;if(!V)return;L||m(V),xe&&(Q||!D.current)&&V.scrollIntoView?.({block:"nearest",inline:"nearest"})})});q(()=>{X.current.orientation=c},[X,c]),q(()=>{O||(f.current=null),(!O||T!=="auto")&&(J.current=T)},[O,T]),q(()=>{i&&(O&&H?(x.current=l??-1,J.current&&l!=null&&(te.current=!0,b())):M.current&&(x.current=-1,b()))},[i,O,H,l,b]),q(()=>{if(i){if(!O){K.current=!1;return}if(H)if(r==null){if(K.current=!1,Z.current!=null)return;if(M.current&&(x.current=-1,oe()),(!W.current||!M.current)&&J.current&&(f.current!=null||J.current===!0&&f.current==null)){let m=0;const L=()=>{n.current[0]==null?(m<2&&(m?S=>Y.request(S):queueMicrotask)(L),m+=1):(x.current=f.current==null||bt(f.current,v,h)||C?ht(n):Vt(n),f.current=null,b())};L()}}else Lt(n.current,r)||(x.current=r,oe(),te.current=!1)}},[i,O,H,r,Z,C,n,v,h,b,oe,Y]),q(()=>{if(!i||H||!G||p||!M.current)return;const m=G.nodesRef.current,L=m.find(V=>V.id===ie)?.context?.elements.floating,Q=xt(Be(z??L??null)),S=m.some(V=>V.context&&ye(V.context.elements.floating,Q));L&&!S&&D.current&&L.focus({preventScroll:!0})},[i,H,z,G,ie,p]),q(()=>{W.current=O,M.current=!!H});const ne=r!=null,Se=$(m=>{if(!ue.current)return;const L=n.current.indexOf(m.currentTarget);L!==-1&&(x.current!==L||r!==L)&&(x.current=L,b(m))}),he=$(()=>U??G?.nodesRef.current.find(m=>m.id===ie)?.context?.dataRef?.current.orientation),Re=$(()=>ht(n,fe.current)),se=$(m=>{if(D.current=!1,K.current=!0,m.which===229||!ue.current&&m.currentTarget===B.current)return;if(C&&mr(m.key,c,h,A)){Ze(m.key,he())||Te(m),e.setOpen(!1,me(Dt,m.nativeEvent));const V=w?.current??z;kt(V)&&V.focus();return}r!=null&&r!==x.current&&!Lt(n.current,r)&&(x.current=r);const L=x.current,Q=ht(n,F),S=Vt(n,F);if(k||(m.key==="Home"&&(Te(m),x.current=Q,b(m)),m.key==="End"&&(Te(m),x.current=S,b(m))),I!=null){const V=I(m,x.current,n,c,u,h,F,Q,S);if(V!=null&&V!==x.current&&(x.current=V,b(m)),c==="both")return}if(Ze(m.key,c)){Te(m);const V=xt(m.currentTarget.ownerDocument);if(O&&!p&&ye(m.currentTarget,V)&&!n.current.some(de=>de!=null&&ye(de,V))){x.current=bt(m.key,c,h)?Q:S,b(m),r===x.current&&oe();return}const{index:Ce,wrapped:be}=vn(n.current,L,{decrement:!bt(m.key,c,h),loopFocus:u,allowEscape:d,disabledIndices:F,minIndex:Q,maxIndex:S});be&&(K.current=!1),x.current=Ce,b(m)}}),xe=o.useMemo(()=>({onFocus(L){K.current=!0,Se(L)},onClick({currentTarget:L}){p||L.focus({preventScroll:!0})},onMouseMove(L){Ht(L)||(K.current=!0,te.current=!1,g&&Se(L))},onPointerLeave(L){if(!ue.current||!D.current||L.pointerType==="touch")return;K.current=!0;const Q=L.relatedTarget;if(!(!g||n.current.includes(Q))&&ae.current&&(ee.current?.(),ee.current=null,x.current=-1,b(L),!p)){const S=B.current,V=xt(Be(S));S&&ye(S,V)&&S.focus({preventScroll:!0})}}}),[Se,ue,B,g,n,b,ae,p]),N=o.useMemo(()=>p&&O&&ne&&{"aria-activedescendant":`${E}-${r}`},[p,O,ne,E,r]),ce=o.useMemo(()=>({...k?{}:N,onKeyDown(m){if(m.key==="Tab"&&m.shiftKey&&O&&!p){const L=Kt(m.nativeEvent);if(L&&!ye(B.current,L))return;Te(m);const Q=me(Yt,m.nativeEvent);e.setOpen(!1,Q);const S=w?.current??z;!Q.isCanceled&&kt(S)&&S.focus();return}se(m)},onPointerMove(m){Ht(m)||(D.current=!0)}}),[N,se,B,k,e,O,p,z,w]),Ie=o.useMemo(()=>{function m(S){e.setOpen(!0,me(Dt,S.nativeEvent,S.currentTarget))}function L(S){T==="auto"&&tn(S.nativeEvent)&&(J.current=!p)}function Q(S){J.current=T,T==="auto"&&Qt(S.nativeEvent)&&(J.current=!0)}return{onKeyDown(S){const V=e.select("open");D.current=!1;const Ce=S.key.startsWith("Arrow"),be=gr(S.key,he(),h),de=Ze(S.key,V?c:v),De=(C?be:de)||S.key==="Enter"||S.key.trim()==="";if(p&&V&&(!C||qt(S.currentTarget)))return se(S);if(!(!V&&!P&&Ce)){if(De){const ve=Ze(S.key,he());f.current=C&&ve?null:S.key}if(C){be&&(Te(S),V?(x.current=Re(),b(S),p&&B.current?.focus()):m(S));return}de&&(Z.current!=null&&(x.current=Z.current),Te(S),!V&&P?m(S):se(S),V&&b(S))}},onFocus(S){S.target===S.currentTarget&&e.select("open")&&!p&&(x.current=-1,b(S))},onPointerDown:Q,onPointerEnter:Q,onMouseDown:L,onClick:L}},[se,T,Re,C,b,e,P,c,v,he,h,Z,p,B]),we=o.useMemo(()=>({...N,...Ie}),[N,Ie]);return o.useMemo(()=>i?{reference:we,floating:ce,item:xe,trigger:Ie}:{},[i,we,ce,Ie,xe])}function xr(e,t){const{listRef:n,elementsRef:r,activeIndex:s,onMatch:i,disabledIndices:l,onTyping:d,enabled:u=!0,resetMs:C=750,selectedIndex:h=null}=t,p=$(d),T=e.useState("open"),g=$e(),P=o.useRef(""),F=o.useRef(h??s??-1),c=o.useRef(null),v=$(a=>{function R(k){return r?.current[k]}function w(k){const B=R(k);return B&&!Mn(B)||B?.matches(":disabled")?!1:l==null||!On(yt,k,l)}function I(k,B,ie=0){if(k.length===0)return-1;const G=(ie%k.length+k.length)%k.length,J=B.toLowerCase();for(let x=0;x<k.length;x+=1){const f=(G+x)%k.length;if(!(!k[f]?.toLowerCase().startsWith(J)||!w(f)))return f}return-1}const A=n.current;if(P.current.length>0&&a.key===" "&&(Te(a),p?.(!0)),P.current.length>0&&P.current[0]!==" "&&I(A,P.current)===-1&&a.key!==" "&&p?.(!1),A==null||a.key.length!==1||a.ctrlKey||a.metaKey||a.altKey)return;T&&a.key!==" "&&(Te(a),p?.(!0));const O=P.current==="";O&&(F.current=h??s??-1),A.every((k,B)=>k&&w(B)?k[0]?.toLowerCase()!==k[1]?.toLowerCase():!0)&&P.current===a.key&&(P.current="",F.current=c.current),P.current+=a.key,g.start(C,()=>{P.current="",F.current=c.current,p?.(!1)});const X=((O?h??s??-1:F.current)??0)+1,y=I(A,P.current,X);y!==-1?(i?.(y,a),c.current=y):a.key!==" "&&(P.current="",p?.(!1))}),U=$(a=>{const R=a.relatedTarget,w=e.select("domReferenceElement"),I=e.select("floatingElement");ye(w,R)||ye(I,R)||(g.clear(),P.current="",F.current=c.current,p?.(!1))});q(()=>{!T&&h!==null||(g.clear(),c.current=null,P.current!==""&&(P.current="",p?.(!1)))},[T,h,g,p]);const E=o.useMemo(()=>({onKeyDown:v,onBlur:U}),[v,U]);return o.useMemo(()=>u?{reference:E,floating:E}:{},[u,E])}function Sr(e){const t=o.useRef(""),n=o.useCallback(s=>{s.defaultPrevented||(t.current=s.pointerType,e(s,s.pointerType))},[e]);return{onClick:o.useCallback(s=>{if(s.detail===0){e(s,"keyboard");return}"pointerType"in s?e(s,s.pointerType):e(s,t.current),t.current=""},[e]),onPointerDown:n}}function nn(e,t){const n=o.useRef(e),r=$(t);q(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function Rr(e,t){const n=$((i,l)=>{(typeof e=="function"?e():e)||t(l||(Pn?"touch":""))}),{onClick:r,onPointerDown:s}=Sr(n);return o.useMemo(()=>({onClick:r,onPointerDown:s}),[r,s])}function br(e){const[t,n]=o.useState(null),r=Rr(e,n);return nn(e,s=>{s&&!e&&n(null)}),o.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}const yr=20;function Ir(e,t,n,r){const[s,i]=o.useState(!1);q(()=>{if(!e||!t||n==null){i(!1);return}const l=Be(n).documentElement.clientWidth,d=n.offsetWidth;i(l>0&&d>0&&d>=l-yr)},[e,t,n]),$n(e&&(!t||s),r)}const Cr=o.createContext(void 0);function Tr(e){return o.useContext(Cr)}function Er(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 wr(e){const t=o.useRef(!0);t.current&&(t.current=!1,e())}function vr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Nt({controlled:e,default:t,name:n,state:r="value"}){const{current:s}=o.useRef(e!==void 0),[i,l]=o.useState(()=>t),d=s&&e!==void 0?e:i,u=o.useCallback(C=>{s||l(C)},[]);return[d,u]}const rn=o.createContext(void 0),on=o.createContext(void 0);function Ve(){const e=o.useContext(rn);if(e===void 0)throw new Error(Xe(60));return e}function sn(){const e=o.useContext(on);if(e===void 0)throw new Error(Xe(61));return e}const Mr="data-valid",Or="data-invalid",Pr={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Ar={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Fr={disabled:!1,...Ar},Lr={valid(e){return e===null?null:e?{[Mr]:""}:{[Or]:""}}},Vr={invalid:void 0,name:void 0,validityData:{state:Pr,errors:[],error:"",value:"",initialValue:null},setValidityData:re,disabled:void 0,setTouched:re,setDirty:re,setFilled:re,setFocused:re,focusOwnerRef:{current:void 0},validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:Fr,registerFieldControl:re,validation:{getValidationProps:(e,t=Ue)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:re,getInputControl:()=>null,commit:async()=>{},change:re}},Dr=o.createContext(Vr);function ft(e=!0){const t=o.useContext(Dr);if(t.setValidityData===re&&!e)throw new Error(Xe(28));return t}function kr(e,t,n,r,s=!0,i){const{registerFieldControl:l}=ft(),d=_e(()=>Symbol());q(()=>{const u=d.current;if(!s){l(u,void 0);return}l(u,{controlRef:e,getValue:r,id:t,name:i,value:n})},[e,s,r,t,i,l,d,n]),q(()=>{const u=d.current;return()=>{l(u,void 0)}},[l,d])}const Hr=o.createContext({controlId:void 0,registerControlId:re,resetControlId:re,labelId:void 0,setLabelId:re,messageIds:[],setMessageIds:re,getDescriptionProps:e=>e});function ln(){return o.useContext(Hr)}function cn(e={}){const{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:s,resetControlId:i}=ln(),l=Xn(),d=_e(()=>Symbol()),u=o.useRef(!1),C=o.useRef(!1),h=$(()=>{!u.current||s===re||(u.current=!1,s(d.current,void 0))});return q(()=>{if(!n||s===re){h();return}let p;if(t!==void 0)C.current=!0,p=t;else if(C.current)p=l;else{i();return}if(p===void 0){h();return}u.current=!0,s(d.current,p)},[t,n,s,i,l,d,h]),q(()=>h,[h]),(n?r:void 0)??t??l}function Nr(e,t,n=Object.is){const{length:r}=e;if(r!==t.length)return!1;for(let s=0;s<r;s+=1)if(!n(e[s],t[s]))return!1;return!0}const un=(e,t)=>Object.is(e,t);function Le(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Ur(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Nr(e,t,(r,s)=>Le(r,s,n)):e!==t}function Ct(e,t,n){return e?e.some(r=>r===void 0?!1:Le(t,r,n)):!1}function ot(e,t,n){return e?e.findIndex(r=>r===void 0?!1:Le(r,t,n)):-1}function _r(e,t){if(t!==un)return r=>Ct(e,r,t);const n=new Set(e);return n.delete(void 0),r=>n.has(r)&&(r!==0||e.some(s=>Object.is(r,s)))}function an(e,t,n,r){const s=r&&Array.isArray(t)?e.findIndex(_r(t,n)):ot(e,t,n);return s===-1?null:s}function Br(e,t,n,r,s,i){return Ct(r,t,s)?i!=null&&e>i&&Ct(r,n[i],s)?i:e:e===i?an(n,r,s,!0):i}function Wr(e,t,n){return e.filter(r=>!Le(t,r,n))}function Tt(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function jr(e){return typeof e=="object"&&e!=null&&Array.isArray(e.items)}function fn(e){return jr(e?.[0])}function Kr(e){return fn(e)?e.flatMap(t=>t.items):e}function qr(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(fn(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 dn(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 Tt(e)}function Ne(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?Tt(e.value):Tt(e)}function pn(e,t,n){function r(){return dn(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(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){const i=Kr(t);if(e==null||typeof e!="object"){const l=i.find(d=>d.value===e);return l&&l.label!=null?l.label:r()}if("value"in e){const l=i.find(d=>d&&d.value===e.value);if(l&&l.label!=null)return l.label}}return r()}function zr(e,t,n){return e.reduce((r,s,i)=>(i>0&&r.push(", "),r.push(ge.jsx(o.Fragment,{children:pn(s,t,n)},i)),r),[])}const Yr={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,multiple:e=>e.multiple,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,highlightItemOnHover:e=>e.highlightItemOnHover,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:Ne(t,r)!==""},hasNullItemLabel:(e,t)=>t?qr(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(s=>Le(t,s,n)):Le(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,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},$r=o.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:re,validationMode:"onSubmit",submitCountRef:{current:0}});function Xr(){return o.useContext($r)}const Ee=1;function gn(e,t){return Math.max(0,e-t)}function Gr(e,t){if(t<=0)return 0;const n=ze(e,0,t),r=n,s=t-n,i=r<=Ee,l=s<=Ee;return i&&l?r<=s?0:t:i?0:l?t:n}function wo(e){const{id:t,value:n,defaultValue:r=null,onValueChange:s,open:i,defaultOpen:l=!1,onOpenChange:d,name:u,form:C,autoComplete:h,disabled:p=!1,readOnly:T=!1,required:g=!1,modal:P=!0,actionsRef:F,inputRef:c,onOpenChangeComplete:v,items:U,multiple:E=!1,itemToStringLabel:a,itemToStringValue:R,isItemEqualToValue:w=un,highlightItemOnHover:I=!0,children:A}=e,{clearErrors:O}=Xr(),{setDirty:H,setTouched:z,setFocused:X,validityData:y,setFilled:k,name:B,disabled:ie,validation:G,validationMode:J}=ft(),x=cn({id:t}),f=ie||p,D=B??u,[b,M]=Nt({controlled:n,default:E?r??yt:r,name:"Select",state:"value"}),[W,K]=Nt({controlled:i,default:l,name:"Select",state:"open"}),te=o.useRef([]),ee=o.useRef([]),fe=o.useRef(null),ue=o.useRef(null),Z=o.useRef(0),ae=o.useRef(null),j=o.useRef([]),Y=o.useRef(!1),oe=o.useRef(null),ne=o.useRef(null),Se=o.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),he=o.useRef(!1),Re=o.useRef(b),{openMethod:se,triggerProps:xe}=br(W),N=_e(()=>new Vn({id:x,labelId:void 0,modal:P,multiple:E,disabled:f,readOnly:T,required:g,highlightItemOnHover:I,itemToStringLabel:a,itemToStringValue:R,isItemEqualToValue:w,value:b,open:W,mounted:W,transitionStatus:void 0,items:U,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Ue,triggerProps:Ue,itemRoot:{props:Ue,multiple:E,disabled:f,readOnly:T,isItemEqualToValue:w},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:re,setOpen:re,handleScrollArrowVisibility:re,onOpenChangeComplete:re,listRef:te,popupRef:fe,scrollHandlerRef:ue,scrollArrowsMountedCountRef:Z,valueRef:ae,valuesRef:j,labelsRef:ee,typingRef:Y,selectionRef:Se,firstItemTextRef:oe,selectedItemTextRef:ne,alignItemWithTriggerActiveRef:he,initialValueRef:Re},Yr)).current,[ce,Ie]=o.useState(!1),{mounted:we,transitionStatus:m,forceUnmount:L}=Gn({open:W,ref:fe,preventUnmountOnClose:ce,setPreventUnmountOnClose:Ie,onUnmount(){N.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),v?.(!1)}}),Q=N.useState("activeIndex"),S=N.useState("selectedIndex"),V=N.useState("triggerElement"),Ce=N.useState("positionerElement"),be=Er(se),de=se??be,De=o.useMemo(()=>E?"":Ne(b,R),[E,b,R]),ve=o.useMemo(()=>E&&Array.isArray(b)?b.map(_=>Ne(_,R)):Ne(b,R),[E,b,R]),dt=Fe(V),Ge=$(()=>ve);kr(dt,x,b,Ge,!f,u);const ke=E?Array.isArray(b)&&b.length>0:b!=null&&De!=="";q(()=>{k(ke)},[ke,k]),q(function(){const le=an(j.current,b,w,E);le===null&&(ne.current=null),!W&&N.set("selectedIndex",le)},[E,W,b,w,N]),nn(b,()=>{O(D),H(Ur(b,y.initialValue,w)),G.change(b)});const He=$((_,le)=>{const Ae=le,Ke=Qn(Ae);d?.(_,Ae),!le.isCanceled&&(_||Ie(Ke()),K(_),!_&&(le.reason===Yt||le.reason===Dn)&&(z(!0),X(!1),J==="onBlur"&&G.commit(b)))});o.useImperativeHandle(F,()=>({unmount:L,close:()=>{N.state.open&&He(!1,me(kn))}}),[L,He,N]);const je=$((_,le)=>{s?.(_,le),!le.isCanceled&&M(_)}),pt=$(_=>{const le=gn(_.scrollHeight,_.clientHeight),Ae=Gr(_.scrollTop,le),Ke=Ae>0,qe=Ae<le;N.set("scrollUpArrowVisible",Ke),N.set("scrollDownArrowVisible",qe)}),pe=pr({open:W,onOpenChange:He,elements:{reference:V,floating:Ce}}),Me=dr(pe,{enabled:!f,event:"mousedown"}),Oe=Jn(pe),Pe=hr(pe,{enabled:!f,listRef:te,activeIndex:Q,selectedIndex:S,disabledIndices:yt,onNavigate(_){_===null&&!W||N.set("activeIndex",_)},focusItemOnHover:I}),Je=xr(pe,{enabled:!f&&(W||!T&&!E),listRef:ee,activeIndex:Q,selectedIndex:S,disabledIndices:_=>vr(te.current[_]),onMatch(_){W?N.set("activeIndex",_):je(j.current[_],me(it))},onTyping(_){Y.current=_}}),wt=o.useMemo(()=>It(Je.reference,Pe.reference,Oe.reference,Me.reference,xe),[Me.reference,Je.reference,Pe.reference,Oe.reference,xe]),vt=o.useMemo(()=>It(Zn,Je.floating,Pe.floating,Oe.floating),[Je.floating,Pe.floating,Oe.floating]),Mt=Pe.item??Ue,Ot=o.useMemo(()=>({props:Mt,multiple:E,disabled:f,readOnly:T,isItemEqualToValue:w}),[Mt,E,f,T,w]);N.useContextCallback("setValue",je),N.useContextCallback("setOpen",He),N.useContextCallback("handleScrollArrowVisibility",pt),N.useContextCallback("onOpenChangeComplete",v),wr(()=>{N.update({popupProps:vt,triggerProps:wt,itemRoot:Ot})}),N.useSyncedValues({id:x,modal:P,multiple:E,disabled:f,readOnly:T,required:g,highlightItemOnHover:I,value:b,open:W,mounted:we,transitionStatus:m,popupProps:vt,triggerProps:wt,itemRoot:Ot,items:U,itemToStringLabel:a,itemToStringValue:R,isItemEqualToValue:w,openMethod:de});const bn=An(c,G.inputRef),Pt=E?void 0:D,yn=o.useMemo(()=>!E||!Array.isArray(b)||!D?null:b.map(_=>{const le=Ne(_,R);return ge.jsx("input",{type:"hidden",form:C,name:D,value:le,disabled:f},le)}),[E,b,C,D,R,f]);return ge.jsxs(rn.Provider,{value:N,children:[ge.jsx(on.Provider,{value:pe,children:A}),ge.jsx("input",{...G.getValidationProps(f,{onFocus(){N.state.triggerElement?.focus({focusVisible:!0})},onChange(_){if(_.nativeEvent.defaultPrevented||f||T)return;const le=_.currentTarget.value,Ae=me(it,_.nativeEvent);function Ke(){if(E)return;const qe=le.toLowerCase();let gt=j.current.findIndex(mt=>Ne(mt,R).toLowerCase()===qe||dn(mt,a).toLowerCase()===qe);gt===-1&&(gt=j.current.findIndex((mt,In)=>{const Ft=ee.current[In];return Ft!=null&&Ft.toLowerCase()===qe}));const At=j.current[gt];At!=null&&je(At,Ae)}N.set("forceMount",!0),queueMicrotask(Ke)}}),id:x&&Pt==null?`${x}-hidden-input`:void 0,form:C,name:Pt,autoComplete:h,value:De,disabled:f,required:g&&!(E&&ke),readOnly:T,ref:bn,style:D?Fn:Ln,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),yn]})}function Jr(e,t){return e??t}function Zr(e,t,n){const{setFocused:r,focusOwnerRef:s}=ft(),i=$(l=>{(l?!e:s.current===i)&&(s.current=l&&i,r(l))});return q(()=>{const l=t.current;return l?.getRootNode()?.activeElement===l&&i(!0),()=>i(!1)},[e,t,i]),i}const Qe=5;function Qr(e,t){const n=eo(t);return e.clientX>=n.left-Qe&&e.clientX<=n.right+Qe&&e.clientY>=n.top-Qe&&e.clientY<=n.bottom+Qe}function eo(e){const t=e.getBoundingClientRect(),n=rt(e);if(Hn)return t;const r=n.getComputedStyle(e,"::before"),s=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||s.content!=="none"))return t;const l=parseFloat(r.width)||0,d=parseFloat(r.height)||0,u=parseFloat(s.width)||0,C=parseFloat(s.height)||0,h=Math.max(t.width,l,u),p=Math.max(t.height,d,C),T=h-t.width,g=p-t.height;return{left:t.left-T/2,right:t.right+T/2,top:t.top-g/2,bottom:t.bottom+g/2}}const to="data-popup-side",no=400,ro={...er,...Lr,popupSide:e=>e?{[to]:e}:null,value:()=>null},vo=o.forwardRef(function(t,n){const{render:r,className:s,id:i,disabled:l=!1,nativeButton:d=!0,style:u,...C}=t,{setTouched:h,validationMode:p,validation:T,state:g,disabled:P}=ft(),{labelId:F}=ln(),c=Ve(),v=c.useState("readOnly"),U=c.useState("required"),E=c.useState("disabled"),a=P||E||l,R=c.useState("open"),w=c.useState("mounted"),I=c.useState("value"),A=c.useState("triggerProps"),O=c.useState("positionerElement"),H=c.useState("listElement"),z=c.useState("popupSide"),X=c.useState("id"),y=c.useState("labelId"),k=c.useState("hasSelectedValue"),B=w&&O?z:null,ie=i??X,G=Jr(F,y);cn({id:i});const J=Fe(O),x=o.useRef(null),f=Zr(a,x),{getButtonProps:D,buttonRef:b}=Gt({disabled:a,native:d}),M=c.useStateSetter("triggerElement"),W=$e(),K=$e(),te=$e();o.useEffect(()=>{if(R)return te.start(no,()=>{c.context.selectionRef.current.allowUnselectedMouseUp=!0,c.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{te.clear()};c.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},K.clear()},[R,c,K,te]);const ee=It(A,{id:ie,role:"combobox","aria-expanded":R,"aria-haspopup":"listbox","aria-controls":R?H?.id??zt(O)?.id:void 0,"aria-labelledby":G,"aria-readonly":v||void 0,"aria-required":U||void 0,tabIndex:a?-1:0,onFocus(Z){f(!0),R&&c.context.alignItemWithTriggerActiveRef.current&&c.context.setOpen(!1,me(it,Z.nativeEvent)),W.start(0,()=>{c.set("forceMount",!0)})},onBlur(Z){ye(O,Z.relatedTarget)||(h(!0),f(!1),p==="onBlur"&&T.commit(I))},onMouseDown(Z){if(R)return;const ae=Be(Z.currentTarget);function j(Y){if(!x.current)return;const oe=Y.target;ye(x.current,oe)||ye(J.current,oe)||Qr(Y,x.current)||c.context.setOpen(!1,me(Nn,Y))}K.start(0,()=>{ae.addEventListener("mouseup",j,{once:!0})})}},C,D),fe=T.getValidationProps(a,ee);fe.role="combobox";const ue={...g,open:R,disabled:a,value:I,readOnly:v,popupSide:B,placeholder:!k};return We("button",t,{ref:[n,x,b,M],state:ue,stateAttributesMapping:ro,props:fe})}),oo={value:()=>null},Mo=o.forwardRef(function(t,n){const{className:r,render:s,children:i,placeholder:l,style:d,...u}=t,C=Ve(),h=C.useState("value"),p=C.useState("items"),T=C.useState("itemToStringLabel"),g=C.useState("hasSelectedValue"),P=!g&&l!=null&&i==null,F=C.useState("hasNullItemLabel",P),c={value:h,placeholder:!g};let v=null;return typeof i=="function"?v=i(h):i!=null?v=i:P&&!F?v=l:Array.isArray(h)?v=zr(h,p,T):v=pn(h,p,T),We("span",t,{state:c,ref:[n,C.context.valueRef],props:[{children:v},u],stateAttributesMapping:oo})}),Oo=o.forwardRef(function(t,n){const r=Ve(),s=r.useState("mounted"),i=r.useState("forceMount");return s||i?ge.jsx(Un,{ref:n,...t}):null}),mn=o.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function so(){return o.useContext(mn)}function io(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,i=$(s),[,l]=o.useState(0),d=_e(co).current,u=_e(lo).current,C=o.useRef(0),h=o.useRef(!0),p=o.useRef(null),T=o.useRef(null),g=$(()=>{h.current||(h.current=!0,l(R=>R+1))}),P=$((R,w)=>{u.set(R,w),g()}),F=$(R=>{u.delete(R),g()}),c=$(R=>{const w=new Map;return n.current.length=0,r&&(r.current.length=0),R.forEach(I=>{w.set(I.element,{...I.registration.metadata??{},index:I.index}),n.current[I.index]=I.element,r&&(r.current[I.index]=I.registration.label!==void 0?I.registration.label:I.registration.textRef?.current?.textContent??I.element.textContent)}),C.current=n.current.length,w});function v(R){if(T.current?.disconnect(),T.current=null,typeof MutationObserver!="function"||R.length<2)return;const w=new MutationObserver(A=>{if(!fo(A))return;let O=null;for(const H of R)if(H.isConnected){if(O&&hn(O,H)>0){w.disconnect(),g();return}O=H}});T.current=w;const I=new Set;for(let A=1;A<R.length;A+=1){const O=ao(R[A-1],R[A]);O&&I.add(O)}I.forEach(A=>w.observe(A,{childList:!0}))}const U=$(()=>{const[R,w]=uo(u),I=c(R),A=p.current,O=!A||A.length!==R.length||R.some((H,z)=>{const X=A[z];return H.index!==X.index||H.element!==X.element||H.registration.index!==X.registration.index||H.registration.metadata!==X.registration.metadata});v(w),p.current=R,h.current=!1,O&&(d.forEach(H=>H(I)),i(I))});q(()=>(!h.current&&p.current&&c(p.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,c]),q(()=>{h.current&&U()}),q(()=>()=>{T.current?.disconnect(),h.current=!0},[]);const E=$(R=>(d.add(R),()=>{d.delete(R)})),a=o.useMemo(()=>({register:P,unregister:F,subscribeMapChange:E,nextIndexRef:C}),[P,F,E,C]);return ge.jsx(mn.Provider,{value:a,children:t})}function lo(){return new Map}function co(){return new Set}function uo(e){const t=new Set,n=[],r=[];e.forEach((i,l)=>{if(!l.isConnected)return;const d=i.index,u={index:d??-1,element:l,registration:i};d===null?r.push(u):d>=0&&(t.add(d),n.push(u))});let s=0;return r.sort((i,l)=>hn(i.element,l.element)),r.forEach(i=>{for(;t.has(s);)s+=1;i.index=s,n.push(i),s+=1}),t.size>0&&n.sort((i,l)=>i.index-l.index),[n,r.map(i=>i.element)]}function ao(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function fo(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 hn(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}const xn=o.createContext(void 0);function po(){const e=o.useContext(xn);if(!e)throw new Error(Xe(59));return e}function lt(e,t){e&&Object.assign(e.style,t)}const go={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},mo={position:"fixed"},Po=o.forwardRef(function(t,n){const{anchor:r,className:s,render:i,positionMethod:l,side:d,align:u,sideOffset:C,alignOffset:h,collisionBoundary:p="clipping-ancestors",collisionPadding:T,arrowPadding:g,sticky:P,disableAnchorTracking:F,alignItemWithTrigger:c=!0,collisionAvoidance:v=_n,style:U,...E}=t,a=Ve(),R=sn(),w=a.useState("open"),I=a.useState("mounted"),A=a.useState("modal"),O=a.useState("value"),H=a.useState("openMethod"),z=a.useState("positionerElement"),X=a.useState("triggerElement"),y=a.useState("isItemEqualToValue"),k=a.useState("transitionStatus"),B=o.useRef(null),ie=o.useRef(null),[G,J]=o.useState(c),x=I&&G&&H!=="touch";!I&&G!==c&&J(c),o.useImperativeHandle(a.context.alignItemWithTriggerActiveRef,()=>x),Ir((x||A)&&w,H==="touch",z,X);const f=ir({anchor:r,floatingRootContext:R,positionMethod:l,mounted:I,side:d,sideOffset:C,align:u,alignOffset:h,arrowPadding:g,collisionBoundary:p,collisionPadding:T,sticky:P,disableAnchorTracking:F??x,collisionAvoidance:v,keepMounted:!0}),D=x?"none":f.side,b=x?mo:f.positionerStyles,M={open:w,side:D,align:f.align,anchorHidden:f.anchorHidden};q(()=>{a.set("popupSide",f.side)},[a,f.side]);const W=a.useStateSetter("positionerElement"),K=lr(t,M,{styles:b,transitionStatus:k,props:E,refs:[n,W],hidden:!I,inert:!w}),te=o.useRef(0),ee=$(ue=>{if(a.context.valuesRef.current.length===0)return;const Z=te.current;te.current=ue.size;const ae=me(it);if(Z!==0&&!a.state.multiple&&O!==null&&ot(a.context.valuesRef.current,O,y)===-1){const Y=a.context.initialValueRef.current,ne=Y!=null&&ot(a.context.valuesRef.current,Y,y)!==-1?Y:null;a.context.setValue(ne,ae),ne===null&&(a.set("selectedIndex",null),a.context.selectedItemTextRef.current=null)}if(Z!==0&&a.state.multiple&&Array.isArray(O)){const j=O.filter(Y=>ot(a.context.valuesRef.current,Y,y)!==-1);j.length!==O.length&&(a.context.setValue(j,ae),j.length===0&&(a.set("selectedIndex",null),a.context.selectedItemTextRef.current=null))}if(w&&x){a.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const j={height:""};lt(z,j),lt(a.context.popupRef.current,j)}}),fe=o.useMemo(()=>({...f,side:D,alignItemWithTriggerActive:x,setControlledAlignItemWithTrigger:J,scrollUpArrowRef:B,scrollDownArrowRef:ie}),[f,D,x,J]);return ge.jsx(io,{elementsRef:a.context.listRef,labelsRef:a.context.labelsRef,onMapChange:ee,children:ge.jsxs(xn.Provider,{value:fe,children:[I&&A&&ge.jsx(tr,{inert:Bn(!w),cutout:X}),K]})})}),et="base-ui-disable-scrollbar",Ut={className:et,getElement(e){return ge.jsx("style",{nonce:e,href:et,precedence:"base-ui:low",children:`.${et}{scrollbar-width:none}.${et}::-webkit-scrollbar{display:none}`})}},ho=o.createContext(void 0),xo={disableStyleElements:!1};function So(){return o.useContext(ho)??xo}const _t="--transform-origin",Ro={...rr,...Zt},Ao=o.forwardRef(function(t,n){const{render:r,className:s,style:i,finalFocus:l,...d}=t,u=Ve(),C=u.useState("multiple"),h=u.useState("readOnly"),p=u.useState("highlightItemOnHover"),T=sn(),{side:g,align:P,alignItemWithTriggerActive:F,isPositioned:c,setControlledAlignItemWithTrigger:v}=po(),U=Tr()!=null,E=cr(),{nonce:a,disableStyleElements:R}=So(),w=u.useState("id"),I=u.useState("open"),A=u.useState("openMethod"),O=u.useState("mounted"),H=u.useState("popupProps"),z=u.useState("transitionStatus"),X=u.useState("triggerElement"),y=u.useState("positionerElement"),k=u.useState("listElement"),B=o.useRef(!1),ie=o.useRef(!1),G=o.useRef({}),J=st(),x=$(M=>{if(!y||!u.context.popupRef.current||!ie.current)return;const W=y.style.top==="0px",K=y.style.bottom==="0px";if(B.current||!F||!W&&!K){u.context.handleScrollArrowVisibility(M);return}const te=Wt(y),ee=Ye(y.getBoundingClientRect().height,"y",te),fe=Be(y),ue=rt(y),Z=ue.getComputedStyle(y),ae=parseFloat(Z.marginTop),j=parseFloat(Z.marginBottom),Y=Bt(ue.getComputedStyle(u.context.popupRef.current)),oe=Math.min(fe.documentElement.clientHeight-ae-j,Y),ne=M.scrollTop,Se=tt(M);let he=null;const Re=ce=>{y.style.height=`${ce}px`},se=W?Se-ne:ne,xe=Math.min(ee+se,oe);if(se<=Ee){const ce=ze(se,0,oe-ee);ce>0&&Re(ee+ce),M.scrollTop=W?Se:0,oe-(ee+ce)<=Ee&&(B.current=!0),u.context.handleScrollArrowVisibility(M);return}if(oe-xe>Ee)he=W?1/0:0;else if(K&&ne<Se){const ce=ee+se-oe;he=ne-(se-ce)}const N=Math.ceil(xe);if(N!==0&&Re(N),he!=null){const ce=ze(he,0,tt(M));Math.abs(M.scrollTop-ce)>Ee&&(M.scrollTop=ce)}N>=oe-Ee&&(B.current=!0),u.context.handleScrollArrowVisibility(M)});o.useImperativeHandle(u.context.scrollHandlerRef,()=>x,[x]),Jt({open:I,ref:u.context.popupRef,onComplete(){I&&u.context.onOpenChangeComplete(!0)}});const f={open:I,transitionStatus:z,side:g,align:P};q(()=>{!y||!u.context.popupRef.current||Object.keys(G.current).length||(G.current={top:y.style.top||"0",left:y.style.left||"0",right:y.style.right,height:y.style.height,bottom:y.style.bottom,minHeight:y.style.minHeight,maxHeight:y.style.maxHeight,marginTop:y.style.marginTop,marginBottom:y.style.marginBottom})},[u,y]),q(()=>{I||F||(ie.current=!1,B.current=!1,lt(y,G.current))},[I,F,y]),q(()=>{const M=u.context.popupRef.current;if(!I||!X||!y||!M||F&&!c||u.state.transitionStatus==="ending")return;if(ie.current=!0,M.style.removeProperty(_t),!F){J.request(()=>u.context.handleScrollArrowVisibility(k||M));return}const W=bo(M);try{let K=u.context.selectedItemTextRef.current;K?.isConnected||(K=!u.select("hasSelectedValue")&&u.context.firstItemTextRef.current?.isConnected?u.context.firstItemTextRef.current:null);const te=u.context.valueRef.current,ee=rt(y),fe=ee.getComputedStyle(y),ue=ee.getComputedStyle(M),Z=Be(X),ae=Wt(X),j=nt(X.getBoundingClientRect(),ae),Y=nt(y.getBoundingClientRect(),ae),oe=j.height,ne=k||M,Se=ne.scrollHeight,he=parseFloat(ue.borderBottomWidth),Re=parseFloat(fe.marginTop)||10,se=parseFloat(fe.marginBottom)||10,xe=parseFloat(fe.minHeight)||100,N=Bt(ue),ce=5,Ie=5,we=20,m=Z.documentElement.clientHeight-Re-se,L=Z.documentElement.clientWidth,Q=m-j.bottom+oe;let S,V=E==="rtl"?j.right-Y.width:j.left,Ce=0;if(K&&te){const pe=nt(te.getBoundingClientRect(),ae);S=nt(K.getBoundingClientRect(),ae),V=Y.left+(E==="rtl"?pe.right-S.right:pe.left-S.left);const Me=pe.top-j.top+pe.height/2;Ce=S.top-Y.top+S.height/2-Me}const be=Q+Ce+se+he;let de=Math.min(m,be);const De=m-Re-se,ve=be-de,dt=L-Ie;y.style.left=`${ze(V,ce,dt-Y.width)}px`,y.style.height=`${de}px`,y.style.maxHeight="none",y.style.marginTop=`${Re}px`,y.style.marginBottom=`${se}px`,M.style.height="100%";const Ge=tt(ne),ke=ve>=Ge-Ee;ke&&(de=Math.min(m,Y.height)-(ve-Ge));const He=j.top<we||j.bottom>m-we||Math.ceil(de)+Ee<Math.min(Se,xe),je=(ee.visualViewport?.scale??1)!==1&&$t;if(He||je){lt(y,G.current),v(!1);return}const pt=Math.max(xe,de);if(ke){const pe=Math.max(0,m-be);y.style.top=Y.height>=De?"0":`${pe}px`,y.style.height=`${de}px`,ne.scrollTop=tt(ne)}else y.style.bottom="0",ne.scrollTop=ve;if(S){const pe=Y.top,Me=Y.height,Oe=S.top+S.height/2,Pe=ze(Me>0?(Oe-pe)/Me*100:50,0,100);M.style.setProperty(_t,`50% ${Pe}%`)}(pt===m||de>=N)&&(B.current=!0),u.context.handleScrollArrowVisibility(ne),p&&u.state.selectedIndex===null&&u.state.activeIndex===null&&u.context.listRef.current[0]!=null&&u.set("activeIndex",0)}finally{W()}},[u,I,y,X,F,v,J,k,p,E,c]),o.useEffect(()=>{if(!F||!y||!I)return;const M=rt(y);function W(K){u.context.setOpen(!1,me(jn,K))}return Wn(M,"resize",W)},[u,F,y,I]);const D={...k?{role:"presentation"}:{role:"listbox","aria-multiselectable":C||void 0,"aria-readonly":h||void 0,id:`${w}-list`},onKeyDown(M){U&&or.has(M.key)&&M.stopPropagation()},onScroll(M){k||x(M.currentTarget)},...F&&{style:k?{height:"100%"}:go},className:!k&&F?Ut.className:void 0},b=We("div",t,{ref:[n,u.context.popupRef],state:f,stateAttributesMapping:Ro,props:[H,D,fr(z),d]});return ge.jsxs(o.Fragment,{children:[!R&&Ut.getElement(a),ge.jsx(nr,{context:T,modal:!1,disabled:!O,openInteractionType:A,returnFocus:l,restoreFocus:!0,children:b})]})});function Bt(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function tt(e){return gn(e.scrollHeight,e.clientHeight)}function Wt(e){return ur.getScale(e)}function Ye(e,t,n){return e/n[t]}function nt(e,t){return ar({x:Ye(e.x,"x",t),y:Ye(e.y,"y",t),width:Ye(e.width,"x",t),height:Ye(e.height,"y",t)})}const jt=[["transform","none"],["scale","1"],["translate","0 0"]];function bo(e){const{style:t}=e,n={};for(const[r,s]of jt)n[r]=t.getPropertyValue(r),t.setProperty(r,s,"important");return()=>{for(const[r]of jt){const s=n[r];s?t.setProperty(r,s):t.removeProperty(r)}}}function yo(e={}){const{guess:t,label:n,metadata:r,textRef:s,index:i}=e,{register:l,unregister:d,subscribeMapChange:u,nextIndexRef:C}=so(),h=o.useRef(-1),[p,T]=o.useState(i==null&&t?()=>{if(h.current===-1){const c=C.current;C.current+=1,h.current=c}return h.current}:-1),g=i??p,P=o.useRef(null),F=o.useCallback(c=>{const v=P.current;v&&d(v),P.current=c,c&&l(c,{metadata:r??null,index:i??null,label:n,textRef:s})},[i,l,d,r,n,s]);return q(()=>{if(i==null)return u(c=>{const v=P.current?c.get(P.current)?.index:null;v!=null&&T(v)})},[i,u]),{ref:F,index:g}}const Sn=o.createContext(void 0);function Rn(){const e=o.useContext(Sn);if(!e)throw new Error(Xe(57));return e}const Fo=o.memo(o.forwardRef(function(t,n){const{render:r,className:s,style:i,value:l=null,label:d,disabled:u=!1,nativeButton:C=!1,...h}=t,p=o.useRef(null),T=yo({guess:!0,label:d,textRef:p}),g=Ve(),{props:P,multiple:F,disabled:c,readOnly:v,isItemEqualToValue:U}=g.useState("itemRoot"),E=c||u,a=g.useState("isActive",T.index),R=g.useState("open"),w=g.useState("isSelected",l),I=g.useState("isSelectedByFocus",T.index),A=T.index,O=o.useRef(null);q(()=>{const f=g.context.valuesRef.current;return f[A]=l,()=>{delete f[A]}},[A,l,g]),q(()=>{const f=g.state.value,D=g.state.selectedIndex;let b=D,M;F&&Array.isArray(f)?(b=Br(A,l,g.context.valuesRef.current,f,U,D),M=b===A,A===D&&!M&&(g.context.selectedItemTextRef.current=null)):(M=f!==void 0&&Le(l,f,U),M&&(b=A)),g.set("selectedIndex",b),M&&p.current&&(g.context.selectedItemTextRef.current=p.current)},[A,F,U,g,l]);const H=o.useRef("mouse"),z=o.useRef(!1),{getButtonProps:X,buttonRef:y}=Gt({disabled:E,focusableWhenDisabled:!0,native:C,composite:!0}),k={disabled:E,selected:w,highlighted:a};function B(f){if(c||v)return;const D=g.state.value;if(F){const b=Array.isArray(D)?D:[],M=w?Wr(b,l,U):[...b,l];g.context.setValue(M,me(St,f))}else g.context.setValue(l,me(St,f)),g.context.setOpen(!1,me(St,f))}function ie(){g.context.selectionRef.current.dragY=0}const G={role:"option","aria-selected":w,tabIndex:R&&a?0:-1,onKeyDown(f){g.set("activeIndex",A),f.key===" "&&g.context.typingRef.current&&f.preventDefault()},onClick(f){const D=H.current!=="touch",b=f.nativeEvent.pointerType,M=D&&tn(f.nativeEvent)&&(b!==void 0||a),W=D&&!M&&!z.current;z.current=!1,!(E||W)&&B(f.nativeEvent)},onPointerEnter(f){H.current=f.pointerType},onPointerMove(f){if(f.pointerType==="mouse"&&f.buttons===1){const D=g.context.selectionRef.current;D.dragY+=f.movementY,D.dragY**2>=64&&(D.allowUnselectedMouseUp=!0)}},onPointerDown(f){H.current=f.pointerType,z.current=!0,ie()},onMouseUp(){if(ie(),E||H.current==="touch"||z.current)return;const f=!g.context.selectionRef.current.allowSelectedMouseUp&&w,D=!g.context.selectionRef.current.allowUnselectedMouseUp&&!w;f||D||(z.current=!0,O.current?.click(),z.current=!1)}},J=We("div",t,{ref:[y,n,T.ref,O],state:k,props:[P,G,h,X]}),x=o.useMemo(()=>({selected:w,index:A,textRef:p,selectedByFocus:I}),[w,A,p,I]);return ge.jsx(Sn.Provider,{value:x,children:J})})),Io=o.memo(o.forwardRef(function(t,n){const{render:r,className:s,style:i,keepMounted:l,selected:d,...u}=t,C=o.useRef(null),{transitionStatus:h,setMounted:p}=sr(d),g=We("span",t,{ref:[n,C],state:{selected:d,transitionStatus:h},props:[{"aria-hidden":!0,children:"✔️"},u],stateAttributesMapping:Zt});return Jt({batch:!0,enabled:!d,open:d,ref:C,onComplete(){d||p(!1)}}),g})),Lo=o.forwardRef(function(t,n){const{selected:r}=Rn();return t.keepMounted||r?ge.jsx(Io,{...t,selected:r,ref:n}):null}),Vo=o.memo(o.forwardRef(function(t,n){const{index:r,textRef:s,selectedByFocus:i}=Rn(),l=Ve(),{render:d,className:u,style:C,...h}=t,p=o.useCallback(g=>{g&&(r===0&&(l.context.firstItemTextRef.current=g),i&&(l.context.selectedItemTextRef.current=g))},[l,r,i]);return We("div",t,{ref:[p,n,s],props:h})}));export{go as L,wo as S,po as a,vo as b,Mo as c,Oo as d,Po as e,Ao as f,Fo as g,Lo as h,Vo as i,dr as j,Rr as k,Ir as l,Tr as m,Lr as n,Xr as o,ft as p,ln as q,cn as r,Ut as s,Zr as t,Ve as u,Nt as v,kr as w,nn as x};
|
|
1
|
+
import{bK as Cn,r as o,cz as st,b0 as $e,b9 as Kt,c4 as qt,K as Ue,N as me,cw as Tn,aZ as _e,b2 as q,b3 as En,cA as zt,cx as wn,b1 as $,dm as Lt,dn as ht,dp as Vt,c2 as xt,b4 as Be,bc as ye,dq as Dt,bs as kt,dr as vn,bN as Yt,c0 as $t,ds as ct,dt as ut,du as Xt,dv as Et,cI as Mn,dw as On,dx as yt,cO as Pn,bI as Xe,aX as re,j as ge,c6 as It,cb as An,cd as Fn,ce as Ln,b_ as it,bJ as Vn,cC as Dn,bP as kn,bu as rt,cu as Hn,M as Gt,J as We,dy as Nn,bV as Un,dz as _n,bY as Bn,bZ as Jt,b7 as Wn,dA as jn,ca as Zt,dB as St}from"./__vite-browser-external-Lw3ipvYF.js";import{i as Rt,E as Qt,b as en,F as Kn,P as qn,c as Fe,a as zn,G as Yn,H as Te,J as tn,B as $n,u as Xn,K as Gn,n as Jn,y as Zn,d as Qn,r as er,I as tr,x as nr,p as rr,C as or,D as sr}from"./composite-B28yORTL.js";import{u as ir,a as lr,b as cr,p as ur,r as ar,g as fr}from"./usePositioner-C3NGxtZa.js";function ze(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function dr(e,t={}){const{enabled:n=!0,event:r="click",toggle:s=!0,ignoreMouse:i=!1,stickIfOpen:l=!0,touchOpenDelay:d=0,reason:u=Cn}=t,C=e.context.dataRef,h=o.useRef(void 0),p=st(),T=$e(),g=o.useMemo(()=>{function P(c,v,U,E){const a=me(u,v,U);c&&E==="touch"&&d>0?T.start(d,()=>{e.setOpen(!0,a)}):e.setOpen(c,a)}function F(c,v,U){const E=C.current.openEvent,a=e.select("domReferenceElement")!==v;return c&&a||!c||!s?!0:E&&(typeof l=="function"?l():l)?!U(E.type):!1}return{onPointerDown(c){h.current=Rt(c.pointerType,!0)&&Qt(c.nativeEvent)?"virtual":c.pointerType},onMouseDown(c){const v=h.current,U=c.nativeEvent,E=e.select("open");if(c.button!==0||r==="click"||Rt(v,!0)&&i)return;const a=F(E,c.currentTarget,A=>A==="click"||A==="mousedown"),R=Kt(U),w=qt(R);if(w||v==="virtual"){P(a,U,w?R:c.currentTarget,v);return}const I=c.currentTarget;p.request(()=>{P(a,U,I,v)})},onClick(c){if(r==="mousedown-only")return;const v=h.current;if(r==="mousedown"&&v){h.current=void 0;return}if(Rt(v,!0)&&i)return;const U=e.select("open"),E=F(U,c.currentTarget,a=>a==="click"||a==="mousedown"||a==="keydown"||a==="keyup");P(E,c.nativeEvent,c.currentTarget,v)},onKeyDown(){h.current=void 0}}},[C,r,i,u,e,l,s,p,T,d]);return o.useMemo(()=>n?{reference:g}:Ue,[n,g])}function pr(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,s=Tn(),i=en()!=null,l=_e(()=>new Kn({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new qn,floatingId:s,syncOnly:!1,nested:i})).current;return q(()=>{const d={open:t,floatingId:s};r.reference!==void 0&&(d.referenceElement=r.reference,d.domReferenceElement=En(r.reference)?r.reference:null),r.floating!==void 0&&(d.floatingElement=r.floating),l.update(d)},[t,s,r.reference,r.floating,l]),l.context.onOpenChange=n,l.context.nested=i,l}function Ht(e){return $t&&e.movementX===0&&e.movementY===0}function at(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Ze(e,t){return at(t,e===Xt||e===Et,e===ct||e===ut)}function bt(e,t,n){return at(t,e===Et,n?e===ct:e===ut)||e==="Enter"||e===" "||e===""}function gr(e,t,n){return at(t,n?e===ct:e===ut,e===Et)}function mr(e,t,n,r){const s=n?e===ut:e===ct,i=e===Xt;return t==="both"||t==="horizontal"&&r?e==="Escape":at(t,s,i)}function hr(e,t){const{listRef:n,activeIndex:r,onNavigate:s=()=>{},enabled:i=!0,selectedIndex:l=null,allowEscape:d=!1,loopFocus:u=!1,nested:C=!1,rtl:h=!1,virtual:p=!1,focusItemOnOpen:T="auto",focusItemOnHover:g=!0,openOnArrowKeyDown:P=!0,disabledIndices:F=void 0,orientation:c="vertical",triggerOrientation:v=c,parentOrientation:U,id:E,resetOnPointerLeave:a=!0,externalTree:R,nestedReturnFocusRef:w,grid:I}=t,A=I!=null,O=e.useState("open"),H=e.useState("floatingElement"),z=e.useState("domReferenceElement"),X=e.context.dataRef,y=zt(H),k=wn(z),B=Fe(y),ie=en(),G=zn(R),J=o.useRef(T),x=o.useRef(l??-1),f=o.useRef(null),D=o.useRef(!0),b=$(m=>{s(x.current===-1?null:x.current,m)}),M=o.useRef(!!H),W=o.useRef(O),K=o.useRef(!1),te=o.useRef(!1),ee=o.useRef(null),fe=Fe(F),ue=Fe(O),Z=Fe(l),ae=Fe(a),j=st(),Y=st(),oe=$(()=>{j.cancel();function m(V){p||(ee.current=Yn(V,{sync:K.current,preventScroll:!0}))}const L=n.current[x.current],Q=te.current;L&&m(L),(K.current?V=>V():V=>j.request(V))(()=>{const V=n.current[x.current]||L;if(!V)return;L||m(V),xe&&(Q||!D.current)&&V.scrollIntoView?.({block:"nearest",inline:"nearest"})})});q(()=>{X.current.orientation=c},[X,c]),q(()=>{O||(f.current=null),(!O||T!=="auto")&&(J.current=T)},[O,T]),q(()=>{i&&(O&&H?(x.current=l??-1,J.current&&l!=null&&(te.current=!0,b())):M.current&&(x.current=-1,b()))},[i,O,H,l,b]),q(()=>{if(i){if(!O){K.current=!1;return}if(H)if(r==null){if(K.current=!1,Z.current!=null)return;if(M.current&&(x.current=-1,oe()),(!W.current||!M.current)&&J.current&&(f.current!=null||J.current===!0&&f.current==null)){let m=0;const L=()=>{n.current[0]==null?(m<2&&(m?S=>Y.request(S):queueMicrotask)(L),m+=1):(x.current=f.current==null||bt(f.current,v,h)||C?ht(n):Vt(n),f.current=null,b())};L()}}else Lt(n.current,r)||(x.current=r,oe(),te.current=!1)}},[i,O,H,r,Z,C,n,v,h,b,oe,Y]),q(()=>{if(!i||H||!G||p||!M.current)return;const m=G.nodesRef.current,L=m.find(V=>V.id===ie)?.context?.elements.floating,Q=xt(Be(z??L??null)),S=m.some(V=>V.context&&ye(V.context.elements.floating,Q));L&&!S&&D.current&&L.focus({preventScroll:!0})},[i,H,z,G,ie,p]),q(()=>{W.current=O,M.current=!!H});const ne=r!=null,Se=$(m=>{if(!ue.current)return;const L=n.current.indexOf(m.currentTarget);L!==-1&&(x.current!==L||r!==L)&&(x.current=L,b(m))}),he=$(()=>U??G?.nodesRef.current.find(m=>m.id===ie)?.context?.dataRef?.current.orientation),Re=$(()=>ht(n,fe.current)),se=$(m=>{if(D.current=!1,K.current=!0,m.which===229||!ue.current&&m.currentTarget===B.current)return;if(C&&mr(m.key,c,h,A)){Ze(m.key,he())||Te(m),e.setOpen(!1,me(Dt,m.nativeEvent));const V=w?.current??z;kt(V)&&V.focus();return}r!=null&&r!==x.current&&!Lt(n.current,r)&&(x.current=r);const L=x.current,Q=ht(n,F),S=Vt(n,F);if(k||(m.key==="Home"&&(Te(m),x.current=Q,b(m)),m.key==="End"&&(Te(m),x.current=S,b(m))),I!=null){const V=I(m,x.current,n,c,u,h,F,Q,S);if(V!=null&&V!==x.current&&(x.current=V,b(m)),c==="both")return}if(Ze(m.key,c)){Te(m);const V=xt(m.currentTarget.ownerDocument);if(O&&!p&&ye(m.currentTarget,V)&&!n.current.some(de=>de!=null&&ye(de,V))){x.current=bt(m.key,c,h)?Q:S,b(m),r===x.current&&oe();return}const{index:Ce,wrapped:be}=vn(n.current,L,{decrement:!bt(m.key,c,h),loopFocus:u,allowEscape:d,disabledIndices:F,minIndex:Q,maxIndex:S});be&&(K.current=!1),x.current=Ce,b(m)}}),xe=o.useMemo(()=>({onFocus(L){K.current=!0,Se(L)},onClick({currentTarget:L}){p||L.focus({preventScroll:!0})},onMouseMove(L){Ht(L)||(K.current=!0,te.current=!1,g&&Se(L))},onPointerLeave(L){if(!ue.current||!D.current||L.pointerType==="touch")return;K.current=!0;const Q=L.relatedTarget;if(!(!g||n.current.includes(Q))&&ae.current&&(ee.current?.(),ee.current=null,x.current=-1,b(L),!p)){const S=B.current,V=xt(Be(S));S&&ye(S,V)&&S.focus({preventScroll:!0})}}}),[Se,ue,B,g,n,b,ae,p]),N=o.useMemo(()=>p&&O&&ne&&{"aria-activedescendant":`${E}-${r}`},[p,O,ne,E,r]),ce=o.useMemo(()=>({...k?{}:N,onKeyDown(m){if(m.key==="Tab"&&m.shiftKey&&O&&!p){const L=Kt(m.nativeEvent);if(L&&!ye(B.current,L))return;Te(m);const Q=me(Yt,m.nativeEvent);e.setOpen(!1,Q);const S=w?.current??z;!Q.isCanceled&&kt(S)&&S.focus();return}se(m)},onPointerMove(m){Ht(m)||(D.current=!0)}}),[N,se,B,k,e,O,p,z,w]),Ie=o.useMemo(()=>{function m(S){e.setOpen(!0,me(Dt,S.nativeEvent,S.currentTarget))}function L(S){T==="auto"&&tn(S.nativeEvent)&&(J.current=!p)}function Q(S){J.current=T,T==="auto"&&Qt(S.nativeEvent)&&(J.current=!0)}return{onKeyDown(S){const V=e.select("open");D.current=!1;const Ce=S.key.startsWith("Arrow"),be=gr(S.key,he(),h),de=Ze(S.key,V?c:v),De=(C?be:de)||S.key==="Enter"||S.key.trim()==="";if(p&&V&&(!C||qt(S.currentTarget)))return se(S);if(!(!V&&!P&&Ce)){if(De){const ve=Ze(S.key,he());f.current=C&&ve?null:S.key}if(C){be&&(Te(S),V?(x.current=Re(),b(S),p&&B.current?.focus()):m(S));return}de&&(Z.current!=null&&(x.current=Z.current),Te(S),!V&&P?m(S):se(S),V&&b(S))}},onFocus(S){S.target===S.currentTarget&&e.select("open")&&!p&&(x.current=-1,b(S))},onPointerDown:Q,onPointerEnter:Q,onMouseDown:L,onClick:L}},[se,T,Re,C,b,e,P,c,v,he,h,Z,p,B]),we=o.useMemo(()=>({...N,...Ie}),[N,Ie]);return o.useMemo(()=>i?{reference:we,floating:ce,item:xe,trigger:Ie}:{},[i,we,ce,Ie,xe])}function xr(e,t){const{listRef:n,elementsRef:r,activeIndex:s,onMatch:i,disabledIndices:l,onTyping:d,enabled:u=!0,resetMs:C=750,selectedIndex:h=null}=t,p=$(d),T=e.useState("open"),g=$e(),P=o.useRef(""),F=o.useRef(h??s??-1),c=o.useRef(null),v=$(a=>{function R(k){return r?.current[k]}function w(k){const B=R(k);return B&&!Mn(B)||B?.matches(":disabled")?!1:l==null||!On(yt,k,l)}function I(k,B,ie=0){if(k.length===0)return-1;const G=(ie%k.length+k.length)%k.length,J=B.toLowerCase();for(let x=0;x<k.length;x+=1){const f=(G+x)%k.length;if(!(!k[f]?.toLowerCase().startsWith(J)||!w(f)))return f}return-1}const A=n.current;if(P.current.length>0&&a.key===" "&&(Te(a),p?.(!0)),P.current.length>0&&P.current[0]!==" "&&I(A,P.current)===-1&&a.key!==" "&&p?.(!1),A==null||a.key.length!==1||a.ctrlKey||a.metaKey||a.altKey)return;T&&a.key!==" "&&(Te(a),p?.(!0));const O=P.current==="";O&&(F.current=h??s??-1),A.every((k,B)=>k&&w(B)?k[0]?.toLowerCase()!==k[1]?.toLowerCase():!0)&&P.current===a.key&&(P.current="",F.current=c.current),P.current+=a.key,g.start(C,()=>{P.current="",F.current=c.current,p?.(!1)});const X=((O?h??s??-1:F.current)??0)+1,y=I(A,P.current,X);y!==-1?(i?.(y,a),c.current=y):a.key!==" "&&(P.current="",p?.(!1))}),U=$(a=>{const R=a.relatedTarget,w=e.select("domReferenceElement"),I=e.select("floatingElement");ye(w,R)||ye(I,R)||(g.clear(),P.current="",F.current=c.current,p?.(!1))});q(()=>{!T&&h!==null||(g.clear(),c.current=null,P.current!==""&&(P.current="",p?.(!1)))},[T,h,g,p]);const E=o.useMemo(()=>({onKeyDown:v,onBlur:U}),[v,U]);return o.useMemo(()=>u?{reference:E,floating:E}:{},[u,E])}function Sr(e){const t=o.useRef(""),n=o.useCallback(s=>{s.defaultPrevented||(t.current=s.pointerType,e(s,s.pointerType))},[e]);return{onClick:o.useCallback(s=>{if(s.detail===0){e(s,"keyboard");return}"pointerType"in s?e(s,s.pointerType):e(s,t.current),t.current=""},[e]),onPointerDown:n}}function nn(e,t){const n=o.useRef(e),r=$(t);q(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function Rr(e,t){const n=$((i,l)=>{(typeof e=="function"?e():e)||t(l||(Pn?"touch":""))}),{onClick:r,onPointerDown:s}=Sr(n);return o.useMemo(()=>({onClick:r,onPointerDown:s}),[r,s])}function br(e){const[t,n]=o.useState(null),r=Rr(e,n);return nn(e,s=>{s&&!e&&n(null)}),o.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}const yr=20;function Ir(e,t,n,r){const[s,i]=o.useState(!1);q(()=>{if(!e||!t||n==null){i(!1);return}const l=Be(n).documentElement.clientWidth,d=n.offsetWidth;i(l>0&&d>0&&d>=l-yr)},[e,t,n]),$n(e&&(!t||s),r)}const Cr=o.createContext(void 0);function Tr(e){return o.useContext(Cr)}function Er(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 wr(e){const t=o.useRef(!0);t.current&&(t.current=!1,e())}function vr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Nt({controlled:e,default:t,name:n,state:r="value"}){const{current:s}=o.useRef(e!==void 0),[i,l]=o.useState(()=>t),d=s&&e!==void 0?e:i,u=o.useCallback(C=>{s||l(C)},[]);return[d,u]}const rn=o.createContext(void 0),on=o.createContext(void 0);function Ve(){const e=o.useContext(rn);if(e===void 0)throw new Error(Xe(60));return e}function sn(){const e=o.useContext(on);if(e===void 0)throw new Error(Xe(61));return e}const Mr="data-valid",Or="data-invalid",Pr={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Ar={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Fr={disabled:!1,...Ar},Lr={valid(e){return e===null?null:e?{[Mr]:""}:{[Or]:""}}},Vr={invalid:void 0,name:void 0,validityData:{state:Pr,errors:[],error:"",value:"",initialValue:null},setValidityData:re,disabled:void 0,setTouched:re,setDirty:re,setFilled:re,setFocused:re,focusOwnerRef:{current:void 0},validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:Fr,registerFieldControl:re,validation:{getValidationProps:(e,t=Ue)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:re,getInputControl:()=>null,commit:async()=>{},change:re}},Dr=o.createContext(Vr);function ft(e=!0){const t=o.useContext(Dr);if(t.setValidityData===re&&!e)throw new Error(Xe(28));return t}function kr(e,t,n,r,s=!0,i){const{registerFieldControl:l}=ft(),d=_e(()=>Symbol());q(()=>{const u=d.current;if(!s){l(u,void 0);return}l(u,{controlRef:e,getValue:r,id:t,name:i,value:n})},[e,s,r,t,i,l,d,n]),q(()=>{const u=d.current;return()=>{l(u,void 0)}},[l,d])}const Hr=o.createContext({controlId:void 0,registerControlId:re,resetControlId:re,labelId:void 0,setLabelId:re,messageIds:[],setMessageIds:re,getDescriptionProps:e=>e});function ln(){return o.useContext(Hr)}function cn(e={}){const{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:s,resetControlId:i}=ln(),l=Xn(),d=_e(()=>Symbol()),u=o.useRef(!1),C=o.useRef(!1),h=$(()=>{!u.current||s===re||(u.current=!1,s(d.current,void 0))});return q(()=>{if(!n||s===re){h();return}let p;if(t!==void 0)C.current=!0,p=t;else if(C.current)p=l;else{i();return}if(p===void 0){h();return}u.current=!0,s(d.current,p)},[t,n,s,i,l,d,h]),q(()=>h,[h]),(n?r:void 0)??t??l}function Nr(e,t,n=Object.is){const{length:r}=e;if(r!==t.length)return!1;for(let s=0;s<r;s+=1)if(!n(e[s],t[s]))return!1;return!0}const un=(e,t)=>Object.is(e,t);function Le(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Ur(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Nr(e,t,(r,s)=>Le(r,s,n)):e!==t}function Ct(e,t,n){return e?e.some(r=>r===void 0?!1:Le(t,r,n)):!1}function ot(e,t,n){return e?e.findIndex(r=>r===void 0?!1:Le(r,t,n)):-1}function _r(e,t){if(t!==un)return r=>Ct(e,r,t);const n=new Set(e);return n.delete(void 0),r=>n.has(r)&&(r!==0||e.some(s=>Object.is(r,s)))}function an(e,t,n,r){const s=r&&Array.isArray(t)?e.findIndex(_r(t,n)):ot(e,t,n);return s===-1?null:s}function Br(e,t,n,r,s,i){return Ct(r,t,s)?i!=null&&e>i&&Ct(r,n[i],s)?i:e:e===i?an(n,r,s,!0):i}function Wr(e,t,n){return e.filter(r=>!Le(t,r,n))}function Tt(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function jr(e){return typeof e=="object"&&e!=null&&Array.isArray(e.items)}function fn(e){return jr(e?.[0])}function Kr(e){return fn(e)?e.flatMap(t=>t.items):e}function qr(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(fn(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 dn(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 Tt(e)}function Ne(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?Tt(e.value):Tt(e)}function pn(e,t,n){function r(){return dn(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(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){const i=Kr(t);if(e==null||typeof e!="object"){const l=i.find(d=>d.value===e);return l&&l.label!=null?l.label:r()}if("value"in e){const l=i.find(d=>d&&d.value===e.value);if(l&&l.label!=null)return l.label}}return r()}function zr(e,t,n){return e.reduce((r,s,i)=>(i>0&&r.push(", "),r.push(ge.jsx(o.Fragment,{children:pn(s,t,n)},i)),r),[])}const Yr={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,multiple:e=>e.multiple,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,highlightItemOnHover:e=>e.highlightItemOnHover,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:Ne(t,r)!==""},hasNullItemLabel:(e,t)=>t?qr(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(s=>Le(t,s,n)):Le(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,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},$r=o.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:re,validationMode:"onSubmit",submitCountRef:{current:0}});function Xr(){return o.useContext($r)}const Ee=1;function gn(e,t){return Math.max(0,e-t)}function Gr(e,t){if(t<=0)return 0;const n=ze(e,0,t),r=n,s=t-n,i=r<=Ee,l=s<=Ee;return i&&l?r<=s?0:t:i?0:l?t:n}function wo(e){const{id:t,value:n,defaultValue:r=null,onValueChange:s,open:i,defaultOpen:l=!1,onOpenChange:d,name:u,form:C,autoComplete:h,disabled:p=!1,readOnly:T=!1,required:g=!1,modal:P=!0,actionsRef:F,inputRef:c,onOpenChangeComplete:v,items:U,multiple:E=!1,itemToStringLabel:a,itemToStringValue:R,isItemEqualToValue:w=un,highlightItemOnHover:I=!0,children:A}=e,{clearErrors:O}=Xr(),{setDirty:H,setTouched:z,setFocused:X,validityData:y,setFilled:k,name:B,disabled:ie,validation:G,validationMode:J}=ft(),x=cn({id:t}),f=ie||p,D=B??u,[b,M]=Nt({controlled:n,default:E?r??yt:r,name:"Select",state:"value"}),[W,K]=Nt({controlled:i,default:l,name:"Select",state:"open"}),te=o.useRef([]),ee=o.useRef([]),fe=o.useRef(null),ue=o.useRef(null),Z=o.useRef(0),ae=o.useRef(null),j=o.useRef([]),Y=o.useRef(!1),oe=o.useRef(null),ne=o.useRef(null),Se=o.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),he=o.useRef(!1),Re=o.useRef(b),{openMethod:se,triggerProps:xe}=br(W),N=_e(()=>new Vn({id:x,labelId:void 0,modal:P,multiple:E,disabled:f,readOnly:T,required:g,highlightItemOnHover:I,itemToStringLabel:a,itemToStringValue:R,isItemEqualToValue:w,value:b,open:W,mounted:W,transitionStatus:void 0,items:U,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Ue,triggerProps:Ue,itemRoot:{props:Ue,multiple:E,disabled:f,readOnly:T,isItemEqualToValue:w},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:re,setOpen:re,handleScrollArrowVisibility:re,onOpenChangeComplete:re,listRef:te,popupRef:fe,scrollHandlerRef:ue,scrollArrowsMountedCountRef:Z,valueRef:ae,valuesRef:j,labelsRef:ee,typingRef:Y,selectionRef:Se,firstItemTextRef:oe,selectedItemTextRef:ne,alignItemWithTriggerActiveRef:he,initialValueRef:Re},Yr)).current,[ce,Ie]=o.useState(!1),{mounted:we,transitionStatus:m,forceUnmount:L}=Gn({open:W,ref:fe,preventUnmountOnClose:ce,setPreventUnmountOnClose:Ie,onUnmount(){N.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),v?.(!1)}}),Q=N.useState("activeIndex"),S=N.useState("selectedIndex"),V=N.useState("triggerElement"),Ce=N.useState("positionerElement"),be=Er(se),de=se??be,De=o.useMemo(()=>E?"":Ne(b,R),[E,b,R]),ve=o.useMemo(()=>E&&Array.isArray(b)?b.map(_=>Ne(_,R)):Ne(b,R),[E,b,R]),dt=Fe(V),Ge=$(()=>ve);kr(dt,x,b,Ge,!f,u);const ke=E?Array.isArray(b)&&b.length>0:b!=null&&De!=="";q(()=>{k(ke)},[ke,k]),q(function(){const le=an(j.current,b,w,E);le===null&&(ne.current=null),!W&&N.set("selectedIndex",le)},[E,W,b,w,N]),nn(b,()=>{O(D),H(Ur(b,y.initialValue,w)),G.change(b)});const He=$((_,le)=>{const Ae=le,Ke=Qn(Ae);d?.(_,Ae),!le.isCanceled&&(_||Ie(Ke()),K(_),!_&&(le.reason===Yt||le.reason===Dn)&&(z(!0),X(!1),J==="onBlur"&&G.commit(b)))});o.useImperativeHandle(F,()=>({unmount:L,close:()=>{N.state.open&&He(!1,me(kn))}}),[L,He,N]);const je=$((_,le)=>{s?.(_,le),!le.isCanceled&&M(_)}),pt=$(_=>{const le=gn(_.scrollHeight,_.clientHeight),Ae=Gr(_.scrollTop,le),Ke=Ae>0,qe=Ae<le;N.set("scrollUpArrowVisible",Ke),N.set("scrollDownArrowVisible",qe)}),pe=pr({open:W,onOpenChange:He,elements:{reference:V,floating:Ce}}),Me=dr(pe,{enabled:!f,event:"mousedown"}),Oe=Jn(pe),Pe=hr(pe,{enabled:!f,listRef:te,activeIndex:Q,selectedIndex:S,disabledIndices:yt,onNavigate(_){_===null&&!W||N.set("activeIndex",_)},focusItemOnHover:I}),Je=xr(pe,{enabled:!f&&(W||!T&&!E),listRef:ee,activeIndex:Q,selectedIndex:S,disabledIndices:_=>vr(te.current[_]),onMatch(_){W?N.set("activeIndex",_):je(j.current[_],me(it))},onTyping(_){Y.current=_}}),wt=o.useMemo(()=>It(Je.reference,Pe.reference,Oe.reference,Me.reference,xe),[Me.reference,Je.reference,Pe.reference,Oe.reference,xe]),vt=o.useMemo(()=>It(Zn,Je.floating,Pe.floating,Oe.floating),[Je.floating,Pe.floating,Oe.floating]),Mt=Pe.item??Ue,Ot=o.useMemo(()=>({props:Mt,multiple:E,disabled:f,readOnly:T,isItemEqualToValue:w}),[Mt,E,f,T,w]);N.useContextCallback("setValue",je),N.useContextCallback("setOpen",He),N.useContextCallback("handleScrollArrowVisibility",pt),N.useContextCallback("onOpenChangeComplete",v),wr(()=>{N.update({popupProps:vt,triggerProps:wt,itemRoot:Ot})}),N.useSyncedValues({id:x,modal:P,multiple:E,disabled:f,readOnly:T,required:g,highlightItemOnHover:I,value:b,open:W,mounted:we,transitionStatus:m,popupProps:vt,triggerProps:wt,itemRoot:Ot,items:U,itemToStringLabel:a,itemToStringValue:R,isItemEqualToValue:w,openMethod:de});const bn=An(c,G.inputRef),Pt=E?void 0:D,yn=o.useMemo(()=>!E||!Array.isArray(b)||!D?null:b.map(_=>{const le=Ne(_,R);return ge.jsx("input",{type:"hidden",form:C,name:D,value:le,disabled:f},le)}),[E,b,C,D,R,f]);return ge.jsxs(rn.Provider,{value:N,children:[ge.jsx(on.Provider,{value:pe,children:A}),ge.jsx("input",{...G.getValidationProps(f,{onFocus(){N.state.triggerElement?.focus({focusVisible:!0})},onChange(_){if(_.nativeEvent.defaultPrevented||f||T)return;const le=_.currentTarget.value,Ae=me(it,_.nativeEvent);function Ke(){if(E)return;const qe=le.toLowerCase();let gt=j.current.findIndex(mt=>Ne(mt,R).toLowerCase()===qe||dn(mt,a).toLowerCase()===qe);gt===-1&&(gt=j.current.findIndex((mt,In)=>{const Ft=ee.current[In];return Ft!=null&&Ft.toLowerCase()===qe}));const At=j.current[gt];At!=null&&je(At,Ae)}N.set("forceMount",!0),queueMicrotask(Ke)}}),id:x&&Pt==null?`${x}-hidden-input`:void 0,form:C,name:Pt,autoComplete:h,value:De,disabled:f,required:g&&!(E&&ke),readOnly:T,ref:bn,style:D?Fn:Ln,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),yn]})}function Jr(e,t){return e??t}function Zr(e,t,n){const{setFocused:r,focusOwnerRef:s}=ft(),i=$(l=>{(l?!e:s.current===i)&&(s.current=l&&i,r(l))});return q(()=>{const l=t.current;return l?.getRootNode()?.activeElement===l&&i(!0),()=>i(!1)},[e,t,i]),i}const Qe=5;function Qr(e,t){const n=eo(t);return e.clientX>=n.left-Qe&&e.clientX<=n.right+Qe&&e.clientY>=n.top-Qe&&e.clientY<=n.bottom+Qe}function eo(e){const t=e.getBoundingClientRect(),n=rt(e);if(Hn)return t;const r=n.getComputedStyle(e,"::before"),s=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||s.content!=="none"))return t;const l=parseFloat(r.width)||0,d=parseFloat(r.height)||0,u=parseFloat(s.width)||0,C=parseFloat(s.height)||0,h=Math.max(t.width,l,u),p=Math.max(t.height,d,C),T=h-t.width,g=p-t.height;return{left:t.left-T/2,right:t.right+T/2,top:t.top-g/2,bottom:t.bottom+g/2}}const to="data-popup-side",no=400,ro={...er,...Lr,popupSide:e=>e?{[to]:e}:null,value:()=>null},vo=o.forwardRef(function(t,n){const{render:r,className:s,id:i,disabled:l=!1,nativeButton:d=!0,style:u,...C}=t,{setTouched:h,validationMode:p,validation:T,state:g,disabled:P}=ft(),{labelId:F}=ln(),c=Ve(),v=c.useState("readOnly"),U=c.useState("required"),E=c.useState("disabled"),a=P||E||l,R=c.useState("open"),w=c.useState("mounted"),I=c.useState("value"),A=c.useState("triggerProps"),O=c.useState("positionerElement"),H=c.useState("listElement"),z=c.useState("popupSide"),X=c.useState("id"),y=c.useState("labelId"),k=c.useState("hasSelectedValue"),B=w&&O?z:null,ie=i??X,G=Jr(F,y);cn({id:i});const J=Fe(O),x=o.useRef(null),f=Zr(a,x),{getButtonProps:D,buttonRef:b}=Gt({disabled:a,native:d}),M=c.useStateSetter("triggerElement"),W=$e(),K=$e(),te=$e();o.useEffect(()=>{if(R)return te.start(no,()=>{c.context.selectionRef.current.allowUnselectedMouseUp=!0,c.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{te.clear()};c.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},K.clear()},[R,c,K,te]);const ee=It(A,{id:ie,role:"combobox","aria-expanded":R,"aria-haspopup":"listbox","aria-controls":R?H?.id??zt(O)?.id:void 0,"aria-labelledby":G,"aria-readonly":v||void 0,"aria-required":U||void 0,tabIndex:a?-1:0,onFocus(Z){f(!0),R&&c.context.alignItemWithTriggerActiveRef.current&&c.context.setOpen(!1,me(it,Z.nativeEvent)),W.start(0,()=>{c.set("forceMount",!0)})},onBlur(Z){ye(O,Z.relatedTarget)||(h(!0),f(!1),p==="onBlur"&&T.commit(I))},onMouseDown(Z){if(R)return;const ae=Be(Z.currentTarget);function j(Y){if(!x.current)return;const oe=Y.target;ye(x.current,oe)||ye(J.current,oe)||Qr(Y,x.current)||c.context.setOpen(!1,me(Nn,Y))}K.start(0,()=>{ae.addEventListener("mouseup",j,{once:!0})})}},C,D),fe=T.getValidationProps(a,ee);fe.role="combobox";const ue={...g,open:R,disabled:a,value:I,readOnly:v,popupSide:B,placeholder:!k};return We("button",t,{ref:[n,x,b,M],state:ue,stateAttributesMapping:ro,props:fe})}),oo={value:()=>null},Mo=o.forwardRef(function(t,n){const{className:r,render:s,children:i,placeholder:l,style:d,...u}=t,C=Ve(),h=C.useState("value"),p=C.useState("items"),T=C.useState("itemToStringLabel"),g=C.useState("hasSelectedValue"),P=!g&&l!=null&&i==null,F=C.useState("hasNullItemLabel",P),c={value:h,placeholder:!g};let v=null;return typeof i=="function"?v=i(h):i!=null?v=i:P&&!F?v=l:Array.isArray(h)?v=zr(h,p,T):v=pn(h,p,T),We("span",t,{state:c,ref:[n,C.context.valueRef],props:[{children:v},u],stateAttributesMapping:oo})}),Oo=o.forwardRef(function(t,n){const r=Ve(),s=r.useState("mounted"),i=r.useState("forceMount");return s||i?ge.jsx(Un,{ref:n,...t}):null}),mn=o.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function so(){return o.useContext(mn)}function io(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,i=$(s),[,l]=o.useState(0),d=_e(co).current,u=_e(lo).current,C=o.useRef(0),h=o.useRef(!0),p=o.useRef(null),T=o.useRef(null),g=$(()=>{h.current||(h.current=!0,l(R=>R+1))}),P=$((R,w)=>{u.set(R,w),g()}),F=$(R=>{u.delete(R),g()}),c=$(R=>{const w=new Map;return n.current.length=0,r&&(r.current.length=0),R.forEach(I=>{w.set(I.element,{...I.registration.metadata??{},index:I.index}),n.current[I.index]=I.element,r&&(r.current[I.index]=I.registration.label!==void 0?I.registration.label:I.registration.textRef?.current?.textContent??I.element.textContent)}),C.current=n.current.length,w});function v(R){if(T.current?.disconnect(),T.current=null,typeof MutationObserver!="function"||R.length<2)return;const w=new MutationObserver(A=>{if(!fo(A))return;let O=null;for(const H of R)if(H.isConnected){if(O&&hn(O,H)>0){w.disconnect(),g();return}O=H}});T.current=w;const I=new Set;for(let A=1;A<R.length;A+=1){const O=ao(R[A-1],R[A]);O&&I.add(O)}I.forEach(A=>w.observe(A,{childList:!0}))}const U=$(()=>{const[R,w]=uo(u),I=c(R),A=p.current,O=!A||A.length!==R.length||R.some((H,z)=>{const X=A[z];return H.index!==X.index||H.element!==X.element||H.registration.index!==X.registration.index||H.registration.metadata!==X.registration.metadata});v(w),p.current=R,h.current=!1,O&&(d.forEach(H=>H(I)),i(I))});q(()=>(!h.current&&p.current&&c(p.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,c]),q(()=>{h.current&&U()}),q(()=>()=>{T.current?.disconnect(),h.current=!0},[]);const E=$(R=>(d.add(R),()=>{d.delete(R)})),a=o.useMemo(()=>({register:P,unregister:F,subscribeMapChange:E,nextIndexRef:C}),[P,F,E,C]);return ge.jsx(mn.Provider,{value:a,children:t})}function lo(){return new Map}function co(){return new Set}function uo(e){const t=new Set,n=[],r=[];e.forEach((i,l)=>{if(!l.isConnected)return;const d=i.index,u={index:d??-1,element:l,registration:i};d===null?r.push(u):d>=0&&(t.add(d),n.push(u))});let s=0;return r.sort((i,l)=>hn(i.element,l.element)),r.forEach(i=>{for(;t.has(s);)s+=1;i.index=s,n.push(i),s+=1}),t.size>0&&n.sort((i,l)=>i.index-l.index),[n,r.map(i=>i.element)]}function ao(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function fo(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 hn(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}const xn=o.createContext(void 0);function po(){const e=o.useContext(xn);if(!e)throw new Error(Xe(59));return e}function lt(e,t){e&&Object.assign(e.style,t)}const go={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},mo={position:"fixed"},Po=o.forwardRef(function(t,n){const{anchor:r,className:s,render:i,positionMethod:l,side:d,align:u,sideOffset:C,alignOffset:h,collisionBoundary:p="clipping-ancestors",collisionPadding:T,arrowPadding:g,sticky:P,disableAnchorTracking:F,alignItemWithTrigger:c=!0,collisionAvoidance:v=_n,style:U,...E}=t,a=Ve(),R=sn(),w=a.useState("open"),I=a.useState("mounted"),A=a.useState("modal"),O=a.useState("value"),H=a.useState("openMethod"),z=a.useState("positionerElement"),X=a.useState("triggerElement"),y=a.useState("isItemEqualToValue"),k=a.useState("transitionStatus"),B=o.useRef(null),ie=o.useRef(null),[G,J]=o.useState(c),x=I&&G&&H!=="touch";!I&&G!==c&&J(c),o.useImperativeHandle(a.context.alignItemWithTriggerActiveRef,()=>x),Ir((x||A)&&w,H==="touch",z,X);const f=ir({anchor:r,floatingRootContext:R,positionMethod:l,mounted:I,side:d,sideOffset:C,align:u,alignOffset:h,arrowPadding:g,collisionBoundary:p,collisionPadding:T,sticky:P,disableAnchorTracking:F??x,collisionAvoidance:v,keepMounted:!0}),D=x?"none":f.side,b=x?mo:f.positionerStyles,M={open:w,side:D,align:f.align,anchorHidden:f.anchorHidden};q(()=>{a.set("popupSide",f.side)},[a,f.side]);const W=a.useStateSetter("positionerElement"),K=lr(t,M,{styles:b,transitionStatus:k,props:E,refs:[n,W],hidden:!I,inert:!w}),te=o.useRef(0),ee=$(ue=>{if(a.context.valuesRef.current.length===0)return;const Z=te.current;te.current=ue.size;const ae=me(it);if(Z!==0&&!a.state.multiple&&O!==null&&ot(a.context.valuesRef.current,O,y)===-1){const Y=a.context.initialValueRef.current,ne=Y!=null&&ot(a.context.valuesRef.current,Y,y)!==-1?Y:null;a.context.setValue(ne,ae),ne===null&&(a.set("selectedIndex",null),a.context.selectedItemTextRef.current=null)}if(Z!==0&&a.state.multiple&&Array.isArray(O)){const j=O.filter(Y=>ot(a.context.valuesRef.current,Y,y)!==-1);j.length!==O.length&&(a.context.setValue(j,ae),j.length===0&&(a.set("selectedIndex",null),a.context.selectedItemTextRef.current=null))}if(w&&x){a.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const j={height:""};lt(z,j),lt(a.context.popupRef.current,j)}}),fe=o.useMemo(()=>({...f,side:D,alignItemWithTriggerActive:x,setControlledAlignItemWithTrigger:J,scrollUpArrowRef:B,scrollDownArrowRef:ie}),[f,D,x,J]);return ge.jsx(io,{elementsRef:a.context.listRef,labelsRef:a.context.labelsRef,onMapChange:ee,children:ge.jsxs(xn.Provider,{value:fe,children:[I&&A&&ge.jsx(tr,{inert:Bn(!w),cutout:X}),K]})})}),et="base-ui-disable-scrollbar",Ut={className:et,getElement(e){return ge.jsx("style",{nonce:e,href:et,precedence:"base-ui:low",children:`.${et}{scrollbar-width:none}.${et}::-webkit-scrollbar{display:none}`})}},ho=o.createContext(void 0),xo={disableStyleElements:!1};function So(){return o.useContext(ho)??xo}const _t="--transform-origin",Ro={...rr,...Zt},Ao=o.forwardRef(function(t,n){const{render:r,className:s,style:i,finalFocus:l,...d}=t,u=Ve(),C=u.useState("multiple"),h=u.useState("readOnly"),p=u.useState("highlightItemOnHover"),T=sn(),{side:g,align:P,alignItemWithTriggerActive:F,isPositioned:c,setControlledAlignItemWithTrigger:v}=po(),U=Tr()!=null,E=cr(),{nonce:a,disableStyleElements:R}=So(),w=u.useState("id"),I=u.useState("open"),A=u.useState("openMethod"),O=u.useState("mounted"),H=u.useState("popupProps"),z=u.useState("transitionStatus"),X=u.useState("triggerElement"),y=u.useState("positionerElement"),k=u.useState("listElement"),B=o.useRef(!1),ie=o.useRef(!1),G=o.useRef({}),J=st(),x=$(M=>{if(!y||!u.context.popupRef.current||!ie.current)return;const W=y.style.top==="0px",K=y.style.bottom==="0px";if(B.current||!F||!W&&!K){u.context.handleScrollArrowVisibility(M);return}const te=Wt(y),ee=Ye(y.getBoundingClientRect().height,"y",te),fe=Be(y),ue=rt(y),Z=ue.getComputedStyle(y),ae=parseFloat(Z.marginTop),j=parseFloat(Z.marginBottom),Y=Bt(ue.getComputedStyle(u.context.popupRef.current)),oe=Math.min(fe.documentElement.clientHeight-ae-j,Y),ne=M.scrollTop,Se=tt(M);let he=null;const Re=ce=>{y.style.height=`${ce}px`},se=W?Se-ne:ne,xe=Math.min(ee+se,oe);if(se<=Ee){const ce=ze(se,0,oe-ee);ce>0&&Re(ee+ce),M.scrollTop=W?Se:0,oe-(ee+ce)<=Ee&&(B.current=!0),u.context.handleScrollArrowVisibility(M);return}if(oe-xe>Ee)he=W?1/0:0;else if(K&&ne<Se){const ce=ee+se-oe;he=ne-(se-ce)}const N=Math.ceil(xe);if(N!==0&&Re(N),he!=null){const ce=ze(he,0,tt(M));Math.abs(M.scrollTop-ce)>Ee&&(M.scrollTop=ce)}N>=oe-Ee&&(B.current=!0),u.context.handleScrollArrowVisibility(M)});o.useImperativeHandle(u.context.scrollHandlerRef,()=>x,[x]),Jt({open:I,ref:u.context.popupRef,onComplete(){I&&u.context.onOpenChangeComplete(!0)}});const f={open:I,transitionStatus:z,side:g,align:P};q(()=>{!y||!u.context.popupRef.current||Object.keys(G.current).length||(G.current={top:y.style.top||"0",left:y.style.left||"0",right:y.style.right,height:y.style.height,bottom:y.style.bottom,minHeight:y.style.minHeight,maxHeight:y.style.maxHeight,marginTop:y.style.marginTop,marginBottom:y.style.marginBottom})},[u,y]),q(()=>{I||F||(ie.current=!1,B.current=!1,lt(y,G.current))},[I,F,y]),q(()=>{const M=u.context.popupRef.current;if(!I||!X||!y||!M||F&&!c||u.state.transitionStatus==="ending")return;if(ie.current=!0,M.style.removeProperty(_t),!F){J.request(()=>u.context.handleScrollArrowVisibility(k||M));return}const W=bo(M);try{let K=u.context.selectedItemTextRef.current;K?.isConnected||(K=!u.select("hasSelectedValue")&&u.context.firstItemTextRef.current?.isConnected?u.context.firstItemTextRef.current:null);const te=u.context.valueRef.current,ee=rt(y),fe=ee.getComputedStyle(y),ue=ee.getComputedStyle(M),Z=Be(X),ae=Wt(X),j=nt(X.getBoundingClientRect(),ae),Y=nt(y.getBoundingClientRect(),ae),oe=j.height,ne=k||M,Se=ne.scrollHeight,he=parseFloat(ue.borderBottomWidth),Re=parseFloat(fe.marginTop)||10,se=parseFloat(fe.marginBottom)||10,xe=parseFloat(fe.minHeight)||100,N=Bt(ue),ce=5,Ie=5,we=20,m=Z.documentElement.clientHeight-Re-se,L=Z.documentElement.clientWidth,Q=m-j.bottom+oe;let S,V=E==="rtl"?j.right-Y.width:j.left,Ce=0;if(K&&te){const pe=nt(te.getBoundingClientRect(),ae);S=nt(K.getBoundingClientRect(),ae),V=Y.left+(E==="rtl"?pe.right-S.right:pe.left-S.left);const Me=pe.top-j.top+pe.height/2;Ce=S.top-Y.top+S.height/2-Me}const be=Q+Ce+se+he;let de=Math.min(m,be);const De=m-Re-se,ve=be-de,dt=L-Ie;y.style.left=`${ze(V,ce,dt-Y.width)}px`,y.style.height=`${de}px`,y.style.maxHeight="none",y.style.marginTop=`${Re}px`,y.style.marginBottom=`${se}px`,M.style.height="100%";const Ge=tt(ne),ke=ve>=Ge-Ee;ke&&(de=Math.min(m,Y.height)-(ve-Ge));const He=j.top<we||j.bottom>m-we||Math.ceil(de)+Ee<Math.min(Se,xe),je=(ee.visualViewport?.scale??1)!==1&&$t;if(He||je){lt(y,G.current),v(!1);return}const pt=Math.max(xe,de);if(ke){const pe=Math.max(0,m-be);y.style.top=Y.height>=De?"0":`${pe}px`,y.style.height=`${de}px`,ne.scrollTop=tt(ne)}else y.style.bottom="0",ne.scrollTop=ve;if(S){const pe=Y.top,Me=Y.height,Oe=S.top+S.height/2,Pe=ze(Me>0?(Oe-pe)/Me*100:50,0,100);M.style.setProperty(_t,`50% ${Pe}%`)}(pt===m||de>=N)&&(B.current=!0),u.context.handleScrollArrowVisibility(ne),p&&u.state.selectedIndex===null&&u.state.activeIndex===null&&u.context.listRef.current[0]!=null&&u.set("activeIndex",0)}finally{W()}},[u,I,y,X,F,v,J,k,p,E,c]),o.useEffect(()=>{if(!F||!y||!I)return;const M=rt(y);function W(K){u.context.setOpen(!1,me(jn,K))}return Wn(M,"resize",W)},[u,F,y,I]);const D={...k?{role:"presentation"}:{role:"listbox","aria-multiselectable":C||void 0,"aria-readonly":h||void 0,id:`${w}-list`},onKeyDown(M){U&&or.has(M.key)&&M.stopPropagation()},onScroll(M){k||x(M.currentTarget)},...F&&{style:k?{height:"100%"}:go},className:!k&&F?Ut.className:void 0},b=We("div",t,{ref:[n,u.context.popupRef],state:f,stateAttributesMapping:Ro,props:[H,D,fr(z),d]});return ge.jsxs(o.Fragment,{children:[!R&&Ut.getElement(a),ge.jsx(nr,{context:T,modal:!1,disabled:!O,openInteractionType:A,returnFocus:l,restoreFocus:!0,children:b})]})});function Bt(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function tt(e){return gn(e.scrollHeight,e.clientHeight)}function Wt(e){return ur.getScale(e)}function Ye(e,t,n){return e/n[t]}function nt(e,t){return ar({x:Ye(e.x,"x",t),y:Ye(e.y,"y",t),width:Ye(e.width,"x",t),height:Ye(e.height,"y",t)})}const jt=[["transform","none"],["scale","1"],["translate","0 0"]];function bo(e){const{style:t}=e,n={};for(const[r,s]of jt)n[r]=t.getPropertyValue(r),t.setProperty(r,s,"important");return()=>{for(const[r]of jt){const s=n[r];s?t.setProperty(r,s):t.removeProperty(r)}}}function yo(e={}){const{guess:t,label:n,metadata:r,textRef:s,index:i}=e,{register:l,unregister:d,subscribeMapChange:u,nextIndexRef:C}=so(),h=o.useRef(-1),[p,T]=o.useState(i==null&&t?()=>{if(h.current===-1){const c=C.current;C.current+=1,h.current=c}return h.current}:-1),g=i??p,P=o.useRef(null),F=o.useCallback(c=>{const v=P.current;v&&d(v),P.current=c,c&&l(c,{metadata:r??null,index:i??null,label:n,textRef:s})},[i,l,d,r,n,s]);return q(()=>{if(i==null)return u(c=>{const v=P.current?c.get(P.current)?.index:null;v!=null&&T(v)})},[i,u]),{ref:F,index:g}}const Sn=o.createContext(void 0);function Rn(){const e=o.useContext(Sn);if(!e)throw new Error(Xe(57));return e}const Fo=o.memo(o.forwardRef(function(t,n){const{render:r,className:s,style:i,value:l=null,label:d,disabled:u=!1,nativeButton:C=!1,...h}=t,p=o.useRef(null),T=yo({guess:!0,label:d,textRef:p}),g=Ve(),{props:P,multiple:F,disabled:c,readOnly:v,isItemEqualToValue:U}=g.useState("itemRoot"),E=c||u,a=g.useState("isActive",T.index),R=g.useState("open"),w=g.useState("isSelected",l),I=g.useState("isSelectedByFocus",T.index),A=T.index,O=o.useRef(null);q(()=>{const f=g.context.valuesRef.current;return f[A]=l,()=>{delete f[A]}},[A,l,g]),q(()=>{const f=g.state.value,D=g.state.selectedIndex;let b=D,M;F&&Array.isArray(f)?(b=Br(A,l,g.context.valuesRef.current,f,U,D),M=b===A,A===D&&!M&&(g.context.selectedItemTextRef.current=null)):(M=f!==void 0&&Le(l,f,U),M&&(b=A)),g.set("selectedIndex",b),M&&p.current&&(g.context.selectedItemTextRef.current=p.current)},[A,F,U,g,l]);const H=o.useRef("mouse"),z=o.useRef(!1),{getButtonProps:X,buttonRef:y}=Gt({disabled:E,focusableWhenDisabled:!0,native:C,composite:!0}),k={disabled:E,selected:w,highlighted:a};function B(f){if(c||v)return;const D=g.state.value;if(F){const b=Array.isArray(D)?D:[],M=w?Wr(b,l,U):[...b,l];g.context.setValue(M,me(St,f))}else g.context.setValue(l,me(St,f)),g.context.setOpen(!1,me(St,f))}function ie(){g.context.selectionRef.current.dragY=0}const G={role:"option","aria-selected":w,tabIndex:R&&a?0:-1,onKeyDown(f){g.set("activeIndex",A),f.key===" "&&g.context.typingRef.current&&f.preventDefault()},onClick(f){const D=H.current!=="touch",b=f.nativeEvent.pointerType,M=D&&tn(f.nativeEvent)&&(b!==void 0||a),W=D&&!M&&!z.current;z.current=!1,!(E||W)&&B(f.nativeEvent)},onPointerEnter(f){H.current=f.pointerType},onPointerMove(f){if(f.pointerType==="mouse"&&f.buttons===1){const D=g.context.selectionRef.current;D.dragY+=f.movementY,D.dragY**2>=64&&(D.allowUnselectedMouseUp=!0)}},onPointerDown(f){H.current=f.pointerType,z.current=!0,ie()},onMouseUp(){if(ie(),E||H.current==="touch"||z.current)return;const f=!g.context.selectionRef.current.allowSelectedMouseUp&&w,D=!g.context.selectionRef.current.allowUnselectedMouseUp&&!w;f||D||(z.current=!0,O.current?.click(),z.current=!1)}},J=We("div",t,{ref:[y,n,T.ref,O],state:k,props:[P,G,h,X]}),x=o.useMemo(()=>({selected:w,index:A,textRef:p,selectedByFocus:I}),[w,A,p,I]);return ge.jsx(Sn.Provider,{value:x,children:J})})),Io=o.memo(o.forwardRef(function(t,n){const{render:r,className:s,style:i,keepMounted:l,selected:d,...u}=t,C=o.useRef(null),{transitionStatus:h,setMounted:p}=sr(d),g=We("span",t,{ref:[n,C],state:{selected:d,transitionStatus:h},props:[{"aria-hidden":!0,children:"✔️"},u],stateAttributesMapping:Zt});return Jt({batch:!0,enabled:!d,open:d,ref:C,onComplete(){d||p(!1)}}),g})),Lo=o.forwardRef(function(t,n){const{selected:r}=Rn();return t.keepMounted||r?ge.jsx(Io,{...t,selected:r,ref:n}):null}),Vo=o.memo(o.forwardRef(function(t,n){const{index:r,textRef:s,selectedByFocus:i}=Rn(),l=Ve(),{render:d,className:u,style:C,...h}=t,p=o.useCallback(g=>{g&&(r===0&&(l.context.firstItemTextRef.current=g),i&&(l.context.selectedItemTextRef.current=g))},[l,r,i]);return We("div",t,{ref:[p,n,s],props:h})}));export{go as L,wo as S,po as a,vo as b,Mo as c,Oo as d,Po as e,Ao as f,Fo as g,Lo as h,Vo as i,dr as j,Rr as k,Ir as l,Tr as m,Lr as n,Xr as o,ft as p,ln as q,cn as r,Ut as s,Zr as t,Ve as u,Nt as v,kr as w,nn as x};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,c as s,j as e,L as i,B as a}from"./__vite-browser-external-
|
|
1
|
+
import{r as l,c as s,j as e,L as i,B as a}from"./__vite-browser-external-Lw3ipvYF.js";import{A as c}from"./arrow-left-CjLKt_5C.js";import{S as m}from"./server-Cg3zBK6a.js";import{E as o}from"./external-link-BEb0dms0.js";function g(){const r=l.useRef(null);l.useLayoutEffect(()=>{const t=r.current?.parentElement;t&&(t.scrollTop=0)},[]);const n=[[s("self_host.step.backend_title"),s("self_host.step.backend_body")],[s("self_host.step.schema_title"),s("self_host.step.schema_body")],[s("self_host.step.client_title"),s("self_host.step.client_body")]];return e.jsx("div",{ref:r,className:"tt-cloud-theme flex flex-1 flex-col font-oai text-oai-black dark:text-oai-white",children:e.jsxs("main",{className:"mx-auto w-full max-w-3xl px-4 py-8 sm:px-6 sm:py-12",children:[e.jsxs(i,{to:"/cloud",className:"mb-7 inline-flex min-h-10 items-center gap-2 text-sm text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx(c,{size:16,"aria-hidden":!0}),s("self_host.back")]}),e.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx(m,{size:18,"aria-hidden":!0}),e.jsx("span",{children:s("self_host.status")})]}),e.jsx("h1",{className:"text-balance text-3xl font-semibold tracking-tight sm:text-4xl",children:s("self_host.title")}),e.jsx("p",{className:"mt-4 max-w-2xl text-base leading-7 text-oai-gray-600 dark:text-oai-gray-300",children:s("self_host.subtitle")}),e.jsxs("div",{className:"mt-7 rounded-lg border border-oai-gray-300 p-5 dark:border-oai-gray-700",children:[e.jsx("h2",{className:"text-sm font-semibold",children:s("self_host.preview_title")}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:s("self_host.preview_body")})]}),e.jsxs("section",{className:"mt-10",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("self_host.steps_title")}),e.jsx("ol",{className:"mt-5 list-decimal space-y-6 pl-5 marker:text-oai-gray-500",children:n.map(([t,d])=>e.jsxs("li",{className:"pl-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:t}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:d})]},t))})]}),e.jsxs("section",{className:"mt-9 border-t border-oai-gray-200 pt-7 dark:border-oai-gray-800",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("self_host.responsibility_title")}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:s("self_host.responsibility_body")}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:s("self_host.community")}),e.jsxs("div",{className:"mt-5 flex flex-wrap gap-3",children:[e.jsxs(a,{as:"a",href:"https://github.com/InsForge/InsForge#self-hosted-docker-compose",target:"_blank",rel:"noopener noreferrer",variant:"secondary",className:"no-underline",children:[s("self_host.link.insforge"),e.jsx(o,{size:14,className:"ml-2","aria-hidden":!0})]}),e.jsxs(a,{as:"a",href:"https://github.com/xiufengsun/TokenTracker/tree/main/dashboard/edge-patches",target:"_blank",rel:"noopener noreferrer",variant:"secondary",className:"no-underline",children:[s("self_host.link.source"),e.jsx(o,{size:14,className:"ml-2","aria-hidden":!0})]})]})]}),e.jsxs("section",{className:"mt-9 border-t border-oai-gray-200 pt-7 dark:border-oai-gray-800",children:[e.jsx("h2",{className:"text-base font-semibold",children:s("self_host.managed_title")}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:s("self_host.managed_body")}),e.jsx(a,{as:i,to:"/cloud",className:"mt-4 no-underline",children:s("self_host.link.cloud")})]})]})})}export{g as SelfHostPage};
|
package/dashboard/dist/assets/{ServiceStatusPage-ZEJyAxsQ.js → ServiceStatusPage-DuzSen0Q.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,c as n,j as t,R as h}from"./__vite-browser-external-
|
|
1
|
+
import{r as d,c as n,j as t,R as h}from"./__vite-browser-external-Lw3ipvYF.js";import{P as f}from"./ProviderIcon-BQfkoaQE.js";import{E as w}from"./external-link-BEb0dms0.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"},{id:"devin",name:"Devin / Cognition",icon:"DEVIN",apiUrl:"https://www.devinstatus.com/api/v2/status.json",pageUrl:"https://www.devinstatus.com"},{id:"factory",name:"Factory / Droid",icon:"DROID",apiUrl:"https://status.factory.ai/api/v2/status.json",pageUrl:"https://status.factory.ai"},{id:"deepseek",name:"DeepSeek",icon:"DEEPSEEK",apiUrl:"/api/deepseek-status",pageUrl:"https://status.deepseek.com"},{id:"opencode",name:"OpenCode",icon:"OPENCODE",apiUrl:"/api/opencode-status",pageUrl:"https://status.opencode.ai"}],b=6e4,y=8e3,k=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 j(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 U(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 E(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 A(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 E(s,e.serviceName);if(e.kind==="instatus")return U(s);const r=s?.status?.indicator;if(!k.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 I({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(w,{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"):j(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 O(){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 m=>[m.id,await A(m)]));c.current&&(a(Object.fromEntries(l)),r(new Date),i(!1))},[]);d.useEffect(()=>{c.current=!0,u();const l=setInterval(()=>{u()},b);return()=>{c.current=!1,clearInterval(l)}},[u]);const p=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:[p?t.jsx("span",{className:"hidden sm:inline text-xs text-oai-gray-400 dark:text-oai-gray-500",children:p}):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(I,{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,O as ServiceStatusPage,O as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{o as qe,r as i,j as e,y as $,Q as fs,U as bs,c as t,Z as Ue,X as Ge,i as S,aA as Ne,W as De,R as ys,V as we,aN as _s,bl as ee}from"./__vite-browser-external-Lw3ipvYF.js";import{L as ks,I as js}from"./LocalOnlyNotice-F_qczacX.js";import{S as de}from"./Select-CQVnpoBO.js";import{C as ws}from"./chevron-down-Beacyoub.js";import{S as Ke}from"./search-BBRJvYNz.js";import{C as vs}from"./check-D2uclldH.js";import{P as Ns,a as Ss,b as Cs,c as Ms,d as Ts}from"./PopoverPopup-DxB1k4g7.js";import{P as We}from"./ProviderIcon-BQfkoaQE.js";import{H as Ds}from"./HoverTooltip-D9RtbhSZ.js";import{u as Se}from"./useCurrency-WruYNKxG.js";import{i as Fs}from"./host-mode-Bc_iTzHk.js";import{I as Rs}from"./info-BvndJDmD.js";import{C as Is}from"./copy-C8fZJwms.js";import{a as Ls,b as Os,c as Es,d as Ps,e as $s}from"./TooltipPopup-B_B4qQD-.js";import"./arrow-up-right-C87CvEJ5.js";import"./download-IIXYYmyo.js";import"./SelectItemText-DmAn7osh.js";import"./composite-B28yORTL.js";import"./usePositioner-C3NGxtZa.js";import"./store-DQpd_ZKv.js";import"./safePolygon-DPIi3FGf.js";const Be={name:"calendar",size:24,node:[["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"}]]};Be.node;const As=qe(Be);const He={name:"folder",size:24,node:[["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"}]]};He.node;const zs=qe(He),qs="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 Fe({options:a,value:s,onChange:r,allValue:o="all",allLabel:u,searchPlaceholder:h,emptyLabel:l,ariaLabel:f,disabled:_=!1,className:k=""}){const[j,w]=i.useState(!1),[g,x]=i.useState(""),[b,y]=i.useState(-1),R=i.useRef(null),v=`${i.useId()}-listbox`,q=s===o?u:a.find(p=>p.value===s)?.label??s,M=g.trim().toLowerCase(),D=i.useMemo(()=>M?a.filter(p=>p.label.toLowerCase().includes(M)):a,[a,M]),C=i.useMemo(()=>[{value:o,label:u},...D],[o,u,D]),O=b>=0&&b<C.length?C[b]:null,A=p=>{r(p),w(!1),x(""),y(-1)};i.useEffect(()=>{j&&R.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[j,b]);const se=p=>{if(p.key==="ArrowDown"||p.key==="ArrowUp"){p.preventDefault();const T=p.key==="ArrowDown";y(L=>{const m=C.length;return m?T?L>=m-1?0:L+1:L<=0?m-1:L-1:-1});return}if(p.key==="Enter"){const T=O||(M&&D.length?D[0]:null);if(!T)return;p.preventDefault(),A(T.value)}};return e.jsxs(Ns,{open:j,onOpenChange:p=>{w(p),y(-1),p||x("")},children:[e.jsxs(Ss,{disabled:_,"aria-label":f,className:$("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",s!==o?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",k),children:[e.jsx(zs,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:q}),e.jsx(ws,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(Cs,{children:e.jsx(Ms,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(Ts,{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(Ke,{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":v,"aria-activedescendant":O?`${v}-${b}`:void 0,value:g,onChange:p=>{x(p.target.value),y(-1)},onKeyDown:se,placeholder:h,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:R,id:v,role:"listbox","aria-label":f,className:"max-h-64 overflow-y-auto",children:[C.map((p,T)=>e.jsxs("button",{id:`${v}-${T}`,type:"button",role:"option","aria-selected":s===p.value,"data-active":T===b?"true":void 0,onMouseEnter:()=>y(T),onClick:()=>A(p.value),className:$(qs,s===p.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",T===b&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:p.label}),s===p.value?e.jsx(vs,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},p.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:l}):null]})]})})})]})}const Us="tokentracker-sessions";async function Gs(a={}){const s=new URL(`/functions/${Us}`,window.location.origin);if(a.from&&s.searchParams.set("from",a.from),a.to&&s.searchParams.set("to",a.to),a.limit&&s.searchParams.set("limit",String(a.limit)),a.refresh&&s.searchParams.set("refresh","1"),a.includeBuckets===!1&&s.searchParams.set("include_buckets","0"),a.includeModelDetail===!1&&s.searchParams.set("include_model_detail","0"),a.from||a.to){const u=fs();u&&s.searchParams.set("tz",u),s.searchParams.set("tz_offset_minutes",String(bs()))}const r=await fetch(s.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),o=await r.json().catch(()=>null);if(!r.ok){const u=r.status===404?t("sessions.error.outdated_app"):`Request failed with HTTP ${r.status}`,h=new Error(o?.error||u);throw h.status=r.status,h}return o}function Ve(a,s,{timeOnly:r=!1}={}){if(!a)return"—";const o=Date.parse(a);if(!Number.isFinite(o))return"—";const u=r?{hour:"2-digit",minute:"2-digit"}:{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"};try{return new Date(o).toLocaleString(s||void 0,u)}catch{const h=new Date(o).toISOString();return r?h.slice(11,16):h.slice(0,16).replace("T"," ")}}function Qe(a){const s=Number(a);if(!Number.isFinite(s)||s<=0)return null;const r=Math.round(s/6e4);if(r<60)return t("sessions.duration.minutes",{minutes:r});const o=Math.floor(r/60),u=r%60;return t("sessions.duration.hours",{hours:o,minutes:u})}function V(a){return P(a?.own_total_tokens??a?.total_tokens)}function Ks(a,s=0,r=1/0){if(!s&&r===1/0)return a;const o=a.map(l=>{if(!Array.isArray(l.usage_buckets))return{...l};const f=l.usage_buckets.filter(g=>{const x=Date.parse(g.timestamp);return x>=s&&x<=r}),_=new Map,k=Object.fromEntries([...me,..._e].map(g=>[g,0]));let j=0,w=0;for(const g of f){j+=P(g.total_tokens),w+=P(g.cost_usd);const x=_.get(g.model)||{...(l.model_usage||[]).find(b=>b.model===g.model),model:g.model,...Object.fromEntries([...me,..._e].map(b=>[b,0])),cost_usd:0,selected_models:[],reroute_reasons:[],model_attribution:"selected"};for(const b of[...me,..._e]){const y=P(g[b]);k[b]+=y,x[b]+=y}x.cost_usd+=P(g.cost_usd);for(const b of["selected_models","reroute_reasons"])Array.isArray(g[b])&&(x[b]=[...new Set([...x[b],...g[b]])]);g.model_attribution==="effective"&&(x.model_attribution="effective"),_.set(g.model,x)}return{...l,...k,total_tokens:j,own_total_tokens:j,cost_usd:w,own_cost_usd:w,model_usage:[..._.values()]}}).filter(l=>!Array.isArray(l.usage_buckets)||V(l)>0),u=new Map;for(const l of o){if(!l.parent_session_hash)continue;const f=u.get(l.parent_session_hash)||[];f.push(l),u.set(l.parent_session_hash,f)}const h=(l,f=new Set)=>{if(f.has(l.session_hash))return{tokens:0,cost:0};const _=new Set(f).add(l.session_hash);let k=V(l),j=J(l);for(const w of u.get(l.session_hash)||[]){const g=h(w,_);k+=g.tokens,j+=g.cost}return{tokens:k,cost:j}};for(const l of o){const f=h(l);l.combined_total_tokens=f.tokens,l.combined_cost_usd=f.cost,l.subagent_total_tokens=f.tokens-V(l),l.subagent_cost_usd=f.cost-J(l)}return o}function J(a){return P(a?.own_cost_usd??a?.cost_usd)}function P(a){const s=Number(a);return Number.isFinite(s)&&s>=0?s:0}const me=["input_tokens","output_tokens","cached_input_tokens","cache_creation_input_tokens","reasoning_output_tokens","total_tokens"],_e=["long_context_","priority_","priority_long_context_","ultrafast_","ultrafast_long_context_"].flatMap(a=>me.filter(s=>s!=="total_tokens").map(s=>a+s));function X(a){const s=Array.isArray(a?.model_usage)?a.model_usage.filter(r=>r&&typeof r.model=="string"&&r.model):[];return s.length?s:[{model:a?.model||"",total_tokens:V(a),cost_usd:J(a),performance:a?.performance}]}function Ws(a){const s={estimated_output_tokens:0,estimated_duration_ms:0,estimated_request_count:0,estimated_tokens_per_second:null,first_response_total_ms:0,first_response_sample_count:0,first_response_ms:null};for(const r of a){const o=r?.performance;if(!o)continue;const u=P(o.estimated_duration_ms),h=P(o.estimated_output_tokens),l=P(o.estimated_request_count);u>0&&h>0&&l>0&&(s.estimated_output_tokens+=h,s.estimated_duration_ms+=u,s.estimated_request_count+=l);const f=P(o.first_response_sample_count),_=P(o.first_response_total_ms);f>0&&_>0&&(s.first_response_total_ms+=_,s.first_response_sample_count+=f)}return s.estimated_duration_ms>0&&(s.estimated_tokens_per_second=s.estimated_output_tokens*1e3/s.estimated_duration_ms),s.first_response_sample_count>0&&(s.first_response_ms=s.first_response_total_ms/s.first_response_sample_count),s}function Ze(a){const s=new Set,r=a.filter(o=>s.has(o.session_hash)?!1:(s.add(o.session_hash),!0));return{count:r.length,tokens:r.reduce((o,u)=>o+V(u),0),cost:r.reduce((o,u)=>o+J(u),0),costIsPartial:r.some(o=>o.cost_is_partial),performance:Ws(r)}}function ve(a){const s=Date.parse(a?.ended_at||a?.started_at||"");return Number.isFinite(s)?s:0}function Bs(a,s){return[...a].sort((r,o)=>(s==="cost"?J(o)-J(r):s==="tokens"?V(o)-V(r):0)||ve(o)-ve(r))}function xe(a){const s=ve(a);if(!s)return"";const r=new Date(s);return`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function Hs(a,s){const r=new Map;for(const o of a){const u=s==="project"?o.project_key||"":xe(o),h=r.get(u)||{key:u,sessions:[]};h.sessions.push(o),r.set(u,h)}return[...r.values()]}function Vs(a){const s=new URLSearchParams(a),r=s.get("source"),o=l=>{const f=s.get(l)||"";if(!/^\d{4}-\d{2}-\d{2}$/.test(f))return"";const _=new Date(`${f}T00:00:00`);return Number.isFinite(_.getTime())&&xe({ended_at:_.toISOString()})===f?f:""},u=o("from"),h=o("to");return{source:["claude","codex","grok","zcode","opencode","kimi","omp","dsh"].includes(r)?r:"all",model:s.get("model")||"all",from:u,to:h}}function Qs(a,s,r){let o=s?new Date(`${s}T00:00:00`).getTime():0,u=r?new Date(`${r}T23:59:59.999`).getTime():1/0;o>u&&(o=new Date(`${r}T00:00:00`).getTime(),u=new Date(`${s}T23:59:59.999`).getTime());const h=Date.parse(a.ended_at||a.started_at||""),l=Date.parse(a.started_at||a.ended_at||"");return(!Number.isFinite(h)||h>=o)&&(!Number.isFinite(l)||l<=u)}function oe({performance:a,className:s=""}){const r=Number(a?.estimated_tokens_per_second),o=Number(a?.estimated_request_count||0);return!Number.isFinite(r)||r<=0||o<=0?null:e.jsx("span",{className:s,title:`${t("sessions.performance.samples",{count:o})}
|
|
2
|
+
${t("sessions.performance.method")}`,children:t("sessions.performance.speed",{speed:Number(r.toFixed(1))})})}const Zs=[{key:"input_tokens",label:()=>t("dashboard.projects.detail.comp_input")},{key:"cached_input_tokens",label:()=>t("dashboard.projects.detail.comp_cached")},{key:"cache_creation_input_tokens",label:()=>t("dashboard.projects.detail.comp_cache_write")},{key:"output_tokens",label:()=>t("dashboard.projects.detail.comp_output")},{key:"reasoning_output_tokens",label:()=>t("dashboard.projects.detail.comp_reasoning")}],Ys=[{key:"turns",label:()=>t("sessions.col.turns")},{key:"edit_turns",label:()=>t("sessions.col.edits")},{key:"retry_turns",label:()=>t("sessions.detail.retries")},{key:"subagent_calls",label:()=>t("sessions.card.subagents")},{key:"tool_calls",grokOnly:!0,label:()=>t("sessions.detail.tools")},{key:"tool_failures",grokOnly:!0,label:()=>t("sessions.detail.tool_failures")},{key:"error_count",grokOnly:!0,label:()=>t("sessions.detail.errors")},{key:"model_calls",grokOnly:!0,label:()=>t("sessions.detail.model_calls")},{key:"compaction_count",grokOnly:!0,label:()=>t("sessions.detail.compactions")}];function Xs(a){return a==="provider_reported"?t("sessions.detail.cost_reported"):a==="model_pricing"?t("sessions.detail.cost_estimated"):a==="mixed"?t("sessions.detail.cost_mixed"):t("sessions.detail.cost_unknown")}function Re(a){return String(a||"").startsWith("litellm")?t("sessions.detail.pricing_litellm"):String(a||"").startsWith("curated")?t("sessions.detail.pricing_curated"):null}function Js(a,s){return s||Number(a)>0}function Ie({label:a,children:s}){return e.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:a}),e.jsx("dd",{className:"min-w-0 break-words text-right text-sm tabular-nums text-oai-black dark:text-white",children:s})]})}function ue({label:a,title:s,className:r="",children:o}){return e.jsxs("div",{className:`min-w-0 border-oai-gray-200 px-3 py-2.5 dark:border-oai-gray-800 ${r}`,title:s,children:[e.jsx("dt",{className:"truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"mt-0.5 truncate text-base font-medium tabular-nums text-oai-black dark:text-white",children:o})]})}function et({session:a,subagents:s=[],onClose:r}){const o=i.useRef(null),u=i.useRef(null),{currency:h,rate:l}=Se(),{resolvedLocale:f}=Ue(),_=m=>Ne(m,{currency:h,rate:l}),k=X(a),j=i.useMemo(()=>Ze(s),[s]),w=V(a),g=J(a),x=Number(a.subagent_total_tokens??j.tokens),b=Number(a.subagent_cost_usd??j.cost),y=a.performance,R=Number(y?.estimated_tokens_per_second)>0&&Number(y?.estimated_request_count)>0,v=Number(y?.first_response_sample_count)>0&&y?.first_response_ms!=null&&Number.isFinite(Number(y.first_response_ms)),q=v?{seconds:(Number(y.first_response_ms)/1e3).toFixed(2),count:y.first_response_sample_count}:null,M=Number(a.reasoning_output_tokens)>0,D=a.source==="grok",C=D&&Number(a.context_window_tokens)>0;i.useEffect(()=>{const m=document.activeElement,E=document.body.style.overflow;document.body.style.overflow="hidden",o.current?.focus();const z=I=>{if(I.key==="Escape"&&(I.preventDefault(),r()),I.key!=="Tab")return;const K=Array.from(u.current?.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), summary, [tabindex="0"]')||[]),te=K[0],ae=K[K.length-1];te?I.shiftKey&&(document.activeElement===te||!u.current?.contains(document.activeElement))?(I.preventDefault(),ae.focus()):!I.shiftKey&&(document.activeElement===ae||!u.current?.contains(document.activeElement))&&(I.preventDefault(),te.focus()):(I.preventDefault(),u.current?.focus())};return window.addEventListener("keydown",z),()=>{window.removeEventListener("keydown",z),document.body.style.overflow=E,m instanceof HTMLElement&&m.isConnected&&m.focus()}},[r]);const O=x>0||b>0,A=a.cost_is_partial||O&&j.costIsPartial,se=[{label:t("sessions.detail.own"),tokens:w,cost:g,partial:a.cost_is_partial},{label:t("sessions.detail.subagents"),tokens:x,cost:b,partial:j.costIsPartial}],p=a.agent_nickname||a.title||a.project_key||t("sessions.project.unknown"),T=Qe(a.duration_ms),L=[a.project_key&&a.project_key!==p?a.project_key:null,Ve(a.started_at,f),T].filter(Boolean);return e.jsx("div",{className:"fixed inset-0 z-50 flex justify-end bg-black/20 dark:bg-black/40",onClick:m=>{m.target===m.currentTarget&&r()},children:e.jsxs("div",{ref:u,role:"dialog","aria-modal":"true","aria-label":t("sessions.detail.title"),tabIndex:-1,className:"flex h-full w-full max-w-[36rem] flex-col border-l border-oai-gray-200 bg-white dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[e.jsxs("div",{className:"flex shrink-0 items-start gap-3 border-b border-oai-gray-200 px-5 py-4 dark:border-oai-gray-800",children:[e.jsx("span",{className:"shrink-0 pt-0.5 text-oai-gray-600 dark:text-oai-gray-300",children:e.jsx(We,{provider:String(a.source||"").toUpperCase(),size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"break-words text-base font-semibold leading-6 text-oai-black dark:text-white",children:p}),e.jsx("p",{className:"mt-0.5 break-words text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:L.join(" · ")})]}),e.jsx("button",{ref:o,type:"button",onClick:r,"aria-label":t("sessions.detail.close"),className:"-mr-2 -mt-1 flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-oai-gray-500 hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white sm:h-9 sm:w-9",children:e.jsx(Ge,{size:18,"aria-hidden":!0})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 py-5",children:[e.jsxs("section",{"aria-label":t("sessions.detail.consumption"),children:[e.jsxs("dl",{className:"grid grid-cols-2 overflow-hidden rounded-lg border border-oai-gray-200 dark:border-oai-gray-800",children:[e.jsx(ue,{label:t("sessions.col.tokens"),children:S(w+x)}),e.jsx(ue,{label:t("sessions.col.cost"),className:"border-l",children:A&&g+b===0?t("dashboard.cost_breakdown.unpriced_label"):e.jsxs(e.Fragment,{children:[A?"≥":"",_(g+b)]})}),e.jsx(ue,{label:t("sessions.summary.speed"),className:"border-t",title:R?t("sessions.performance.samples",{count:y.estimated_request_count}):t("sessions.detail.no_speed"),children:R?e.jsx(oe,{performance:y}):"—"}),e.jsx(ue,{label:t("sessions.performance.first_response"),className:"border-l border-t",title:t("sessions.performance.first_response_method"),children:v?Number(y.first_response_sample_count)===1?t("sessions.performance.first_response_value_single",q):t("sessions.performance.first_response_value",q):"—"})]}),O?e.jsx("dl",{className:"mt-3 space-y-1.5",children:se.map(m=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_80px_88px] items-baseline gap-3 text-sm",children:[e.jsx("dt",{className:"text-oai-gray-600 dark:text-oai-gray-300",children:m.label}),e.jsx("dd",{className:"text-right tabular-nums",children:S(m.tokens)}),e.jsx("dd",{className:"text-right tabular-nums",children:m.partial&&m.cost===0?t("dashboard.cost_breakdown.unpriced_label"):e.jsxs(e.Fragment,{children:[m.partial?"≥":"",_(m.cost)]})})]},m.label))}):null,e.jsxs("p",{className:"mt-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:[t("sessions.detail.cost_source")," · ",Xs(a.cost_source),a.cost_is_partial?e.jsxs("span",{className:"text-amber-700 dark:text-amber-300",children:[" · ",t("sessions.cost.partial_title")]}):null,a.usage_is_incomplete?e.jsxs("span",{className:"text-amber-700 dark:text-amber-300",children:[" · ",t("sessions.badge.partial_usage")]}):null]})]}),e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-black dark:text-white",children:t("sessions.detail.tokens")}),e.jsx("dl",{className:"mt-2 grid grid-cols-1 gap-x-8 gap-y-1.5 sm:grid-cols-2",children:Zs.map(({key:m,label:E})=>e.jsx(Ie,{label:E(),children:a[m]==null?"—":S(a[m])},m))})]}),e.jsxs("section",{className:"mt-6",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_80px_88px] items-baseline gap-3",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-black dark:text-white",children:t("sessions.detail.models")}),e.jsx("span",{className:"text-right text-xs text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0,children:t("sessions.col.tokens")}),e.jsx("span",{className:"text-right text-xs text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0,children:t("sessions.col.cost")})]}),e.jsx("ul",{className:"mt-1 divide-y divide-oai-gray-100 dark:divide-oai-gray-800/70",children:k.map(m=>{const E=m.pricing?.status==="unpriced",z=a.cost_source==="provider_reported"&&k.length===1,I=z?g:m.cost_usd,K=Js(I,z);return e.jsxs("li",{className:"py-2.5",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_80px_88px] items-baseline gap-3 text-sm",children:[e.jsx("span",{className:"min-w-0 break-words text-oai-black dark:text-white",children:m.model||t("sessions.model.unknown")}),e.jsx("span",{className:"text-right tabular-nums",children:S(m.total_tokens)}),e.jsx("span",{className:"text-right tabular-nums",children:E&&!K?"—":_(I)})]}),m.pricing?e.jsxs("details",{className:"group text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsxs("summary",{className:"flex min-h-10 cursor-pointer list-none items-center gap-2 rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 sm:min-h-0 sm:pt-1 [&::-webkit-details-marker]:hidden",children:[e.jsx(oe,{performance:m.performance,className:"tabular-nums"}),e.jsx("span",{className:"underline decoration-dotted underline-offset-4 group-open:no-underline",children:t("sessions.detail.pricing_details")})]}),e.jsxs("div",{className:"space-y-1 pt-1.5 leading-5",children:[E?e.jsx("p",{children:t("sessions.detail.pricing_unpriced")}):null,m.pricing.status==="free"?e.jsx("p",{children:t("sessions.detail.pricing_free")}):null,m.pricing.status==="priced"?e.jsx("p",{children:t("sessions.detail.pricing_rates",{input:m.pricing.input,output:m.pricing.output,cacheRead:m.pricing.cache_read,cacheWrite:m.pricing.cache_write})}):null,Re(m.pricing.source)?e.jsx("p",{children:Re(m.pricing.source)}):null]})]}):e.jsx(oe,{performance:m.performance,className:"block pt-1 text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400"})]},m.model)})})]}),e.jsxs("details",{className:"mt-5 border-t border-oai-gray-200 dark:border-oai-gray-800",children:[e.jsx("summary",{className:"flex min-h-11 cursor-pointer items-center rounded text-sm font-medium text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-white",children:t("sessions.detail.signals")}),e.jsx("dl",{className:"grid grid-cols-1 gap-x-8 gap-y-1.5 pb-4 sm:grid-cols-2",children:Ys.map(({key:m,label:E,grokOnly:z})=>e.jsx(Ie,{label:E(),children:typeof a[m]=="number"&&(!z||D)?S(a[m]):t("sessions.detail.not_recorded")},m))}),D&&a.usage_precision?e.jsx("p",{className:"pb-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:t("sessions.grok.runtime_breakdown",{calls:S(a.model_calls),seconds:(Number(a.api_duration_ms||0)/1e3).toFixed(1),tools:S(a.tool_calls),errors:S(a.error_count)})}):null,C?e.jsx("p",{className:"pb-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:t("sessions.grok.context_breakdown",{used:S(a.context_tokens_used),window:S(a.context_window_tokens),percent:Number(a.context_usage_percent||0).toFixed(0)})}):null]}),e.jsxs("details",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800",children:[e.jsx("summary",{className:"flex min-h-11 cursor-pointer items-center rounded text-sm font-medium text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-white",children:t("sessions.detail.identifiers")}),e.jsxs("dl",{className:"space-y-3 pb-4",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:t("sessions.detail.session_id")}),e.jsx("dd",{className:"mt-1 break-all font-mono text-xs leading-5",children:a.session_id||a.session_hash})]}),a.project_ref?e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:t("sessions.detail.local_path")}),e.jsx("dd",{className:"mt-1 break-all font-mono text-xs leading-5",children:a.project_ref})]}):null,a.resume_command?e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:t("sessions.detail.resume_command")}),e.jsx("dd",{className:"mt-1 break-all font-mono text-xs leading-5",children:a.resume_command})]}):null]})]}),e.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-oai-gray-200 pt-4 text-xs leading-5 text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[R?e.jsx("p",{children:t("sessions.performance.method")}):null,M?e.jsx("p",{children:t("sessions.detail.reasoning_note")}):null,e.jsx("p",{children:t("sessions.privacy")})]})]})]})})}const Le=Fs(),Oe=[],Ee=Object.freeze({}),ke=100,st=[{id:"all",label:()=>t("usage.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"opencode",label:()=>"OpenCode"},{id:"grok",label:()=>"Grok"},{id:"zcode",label:()=>"ZCode"},{id:"kimi",label:()=>t("leaderboard.column.kimi")},{id:"omp",label:()=>"oh-my-pi"},{id:"dsh",label:()=>t("provider.display.deepseek_harness")}],Ye=[{id:"all",days:0,label:()=>t("sessions.filter.range_label_all")},{id:"7d",days:7,label:()=>t("sessions.filter.range_7d")},{id:"30d",days:30,label:()=>t("sessions.filter.range_30d")},{id:"90d",days:90,label:()=>t("sessions.filter.range_90d")}];function je(a){const s=Ye.find(o=>o.id===a)?.days||0;if(!s)return 0;const r=new Date;return r.setDate(r.getDate()-(s-1)),r.setHours(0,0,0,0),r.getTime()}function Pe(a){const s=new Date(a),r=String(s.getMonth()+1).padStart(2,"0"),o=String(s.getDate()).padStart(2,"0");return`${s.getFullYear()}-${r}-${o}`}function tt(a,s){if(!s)return!0;const r=Date.parse(a.ended_at||a.started_at||"");return Number.isFinite(r)?r>=s:!0}function at(a){const s=Date.parse(a.started_at||"");return!Number.isFinite(s)||xe({started_at:a.started_at})===xe(a)}function $e(a){const s=X(a);return s.length===1?s[0].model||t("sessions.model.unknown"):s.map(r=>`${r.model} ${S(Number(r.total_tokens||0))}`).join(" · ")}async function Ae(a){if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(a),!0;const s=document.createElement("textarea");s.value=a,s.style.position="fixed",s.style.opacity="0",document.body.appendChild(s),s.select();const r=document.execCommand("copy");return document.body.removeChild(s),r}function rt(){const[a,s]=i.useState(!1),r=i.useId();return e.jsxs(Ls,{open:a,onOpenChange:s,children:[e.jsx(Os,{delay:150,closeDelay:100,closeOnClick:!1,onClick:()=>s(!0),"aria-label":t("sessions.summary.scope_help"),"aria-describedby":a?r:void 0,className:"sessions-summary-help relative inline-flex h-4 w-4 shrink-0 items-center justify-center rounded text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white before:absolute before:-inset-2 before:content-['']",children:e.jsx(Rs,{className:"h-3.5 w-3.5","aria-hidden":!0})}),e.jsx(Es,{children:e.jsx(Ps,{side:"bottom",align:"end",sideOffset:12,className:"z-[60]",children:e.jsx($s,{id:r,role:"tooltip",className:"max-w-xs rounded-lg border border-oai-gray-200 bg-white p-4 text-sm leading-6 text-oai-gray-700 outline-none dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-gray-200",children:t("sessions.summary.scope")})})})]})}function F({className:a}){return e.jsx("span",{className:$("block rounded bg-oai-gray-200/70 animate-pulse dark:bg-oai-gray-800/70",a),"aria-hidden":"true"})}function ot({index:a}){const s=["w-44","w-32","w-52","w-36","w-48","w-40"],r=["w-24","w-32","w-20"];return e.jsxs("li",{className:"sessions-row sessions-row-grid py-3","aria-hidden":"true",children:[e.jsxs("div",{className:"sessions-row-identity min-w-0",children:[e.jsx(F,{className:"h-4 w-4 rounded-full"}),e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx(F,{className:$("h-4",s[a%s.length])}),e.jsx("div",{className:"flex min-w-0 flex-wrap gap-2",children:r.map((o,u)=>e.jsx(F,{className:$("h-3",o)},u))})]})]}),e.jsxs("dl",{className:"sessions-row-metrics",children:[e.jsx("div",{className:"sessions-row-value",children:e.jsx(F,{className:"ml-auto h-4 w-14"})}),e.jsx("div",{className:"sessions-row-value",children:e.jsx(F,{className:"ml-auto h-4 w-12"})}),e.jsx("div",{className:"sessions-row-value",children:e.jsx(F,{className:"ml-auto h-4 w-16"})})]}),e.jsx(F,{className:"sessions-row-action h-8 w-8 rounded-md"})]})}function nt({rows:a=6}){return e.jsxs("div",{"data-testid":"sessions-skeleton",role:"status","aria-busy":"true","aria-live":"polite",children:[e.jsx("span",{className:"sr-only",children:t("sessions.loading")}),e.jsx("section",{className:"mb-6 flex items-start gap-3 rounded-lg border border-oai-gray-200 px-4 py-3 dark:border-oai-gray-800","aria-hidden":"true",children:e.jsx("dl",{className:"sessions-kpis grid min-w-0 flex-1 grid-cols-2 gap-y-3 sm:grid-cols-4",children:Array.from({length:4},(s,r)=>e.jsxs("div",{children:[e.jsx(F,{className:"h-3 w-16"}),e.jsx(F,{className:$("mt-2 h-6",r===2?"w-20":"w-14")})]},r))})}),e.jsxs("div",{className:"sessions-row-grid sessions-list-header border-b border-oai-gray-200 py-2 dark:border-oai-gray-800","aria-hidden":"true",children:[e.jsx(F,{className:"h-3 w-16"}),e.jsx(F,{className:"ml-auto h-3 w-10"}),e.jsx(F,{className:"ml-auto h-3 w-9"}),e.jsx(F,{className:"ml-auto h-3 w-10"}),e.jsx("span",{})]}),e.jsxs("ul",{className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800","aria-hidden":"true",children:[e.jsx("li",{className:"pb-2 pt-5",children:e.jsx(F,{className:"h-3 w-24"})}),Array.from({length:a},(s,r)=>e.jsx(ot,{index:r},r))]})]})}const ze=we.memo(function({session:s,locale:r,nested:o=!1,timeOnly:u=!1,childCount:h=0,expanded:l=!1,onToggle:f,onDetail:_}){const{currency:k,rate:j}=Se(),w=String(s.source||"").toUpperCase(),g=Qe(s.duration_ms),x=s.resume_command,b=s.project_key||t("sessions.project.unknown"),y=o||s.thread_kind==="subagent",R=y?s.agent_nickname||s.agent_role||s.title||b:s.title||b,v=s.usage_is_incomplete?t("sessions.badge.partial_usage"):s.cost_is_partial?t("sessions.badge.partial_cost"):null,q=s.project_ref?`${s.project_ref}
|
|
3
|
+
${t("sessions.project.copy_hint")}`:void 0,M=async()=>{if(s.project_ref)try{await Ae(s.project_ref)?ee({title:t("sessions.project.copied")}):ee({title:t("sessions.project.copy_failed")})}catch{ee({title:t("sessions.project.copy_failed")})}},D=O=>e.jsxs("span",{className:"group relative inline-flex min-w-0 max-w-full",children:[e.jsx(Ds,{text:q,placement:"bottom"}),e.jsx("button",{type:"button",onClick:M,"aria-label":t("sessions.project.copy_aria",{project:b}),className:$("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",O),children:b})]}),C=async()=>{if(x)try{await Ae(x)?ee({title:t("sessions.resume.copied")}):ee({title:t("sessions.resume.copy_failed")})}catch{ee({title:t("sessions.resume.copy_failed")})}};return e.jsxs("li",{className:$("sessions-row sessions-row-grid py-3",o&&"sessions-row-nested"),children:[e.jsxs("div",{className:"sessions-row-identity min-w-0",children:[e.jsx("span",{className:"sessions-row-provider inline-flex items-center justify-center text-oai-gray-600 dark:text-oai-gray-300","aria-hidden":"true",children:e.jsx(We,{provider:w,size:o?16:18})}),e.jsxs("div",{className:"contents",children:[e.jsx("button",{type:"button",onClick:()=>_(s),"aria-label":t("sessions.detail.open_aria",{title:R}),title:R,className:"sessions-row-title block min-h-9 min-w-0 max-w-full truncate rounded text-left text-sm font-medium text-oai-black underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-white md:min-h-5",children:R}),e.jsxs("div",{className:"sessions-row-meta flex min-w-0 flex-wrap items-center gap-y-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{className:"sessions-meta-item min-w-0 max-w-full",children:s.project_ref?D("min-h-6 inline-flex items-center md:min-h-0"):e.jsx("span",{className:"truncate",children:b})}),e.jsx("span",{className:"sessions-meta-item min-w-0 max-w-full truncate",title:$e(s),children:$e(s)}),e.jsx("span",{className:"sessions-meta-item tabular-nums",children:Ve(s.started_at,r,{timeOnly:u&&at(s)})}),g?e.jsx("span",{className:"sessions-meta-item tabular-nums",children:g}):null,Number.isFinite(s.session_store_bytes)?e.jsx("span",{className:"sessions-meta-item tabular-nums",title:t("sessions.storage.tooltip",{metric:t(s.session_store_metric==="allocated"?"sessions.storage.allocated":"sessions.storage.logical"),ratio:Math.round(s.bytes_per_1k_tokens||0).toLocaleString(r)}),children:t("sessions.storage.label",{size:t("sessions.storage.size",{value:(s.session_store_bytes/1024/1024).toLocaleString(r,{maximumFractionDigits:2})})})}):null,y?e.jsxs("span",{className:"sessions-meta-item",children:[t("sessions.badge.subagent"),s.agent_role?` · ${s.agent_role}`:""]}):null,s.first_pass?e.jsx("span",{className:"sessions-meta-item text-emerald-700 dark:text-emerald-300",children:t("sessions.badge.first_pass")}):null,v?e.jsx("span",{className:"sessions-meta-item text-amber-700 dark:text-amber-300",children:v}):null,s.cost_source==="provider_reported"?e.jsx("span",{className:"sessions-meta-item",children:t("sessions.badge.reported_cost")}):null,h?e.jsxs("button",{type:"button",onClick:()=>f(s.session_hash),"aria-expanded":l,className:"-mx-1.5 inline-flex min-h-8 items-center md:-my-1 md:ml-2 md:mr-0 gap-0.5 rounded px-1.5 font-medium text-oai-gray-700 hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-200 dark:hover:bg-oai-gray-800 dark:hover:text-white md:min-h-6",children:[e.jsx(_s,{className:$("h-3.5 w-3.5 transition-transform",l&&"rotate-90"),"aria-hidden":!0}),l?t("sessions.thread.collapse",{count:h}):t("sessions.thread.expand",{count:h})]}):null]})]})]}),e.jsxs("dl",{className:"sessions-row-metrics",children:[e.jsxs("div",{className:"sessions-row-value",children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 md:sr-only",children:t("sessions.col.tokens")}),e.jsxs("dd",{title:Number(s.subagent_total_tokens)?t("sessions.thread.tokens_summary",{own:S(s.own_total_tokens),subagents:S(s.subagent_total_tokens),combined:S(s.combined_total_tokens)}):void 0,className:"mt-1 text-sm tabular-nums text-oai-black dark:text-white md:mt-0",children:[S(s.total_tokens),Number(s.subagent_total_tokens)?e.jsxs("span",{className:"mt-0.5 block text-xs text-oai-gray-500 dark:text-oai-gray-400",children:["Σ ",S(s.combined_total_tokens)]}):null]})]}),e.jsxs("div",{className:"sessions-row-value",children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 md:sr-only",children:t("sessions.col.cost")}),e.jsx("dd",{className:"mt-1 text-sm tabular-nums text-oai-black dark:text-white md:mt-0",title:s.cost_is_partial?t("sessions.cost.partial_title"):void 0,children:s.cost_is_partial&&Number(s.cost_usd)===0?t("dashboard.cost_breakdown.unpriced_label"):e.jsxs(e.Fragment,{children:[s.cost_is_partial?"≥":"",Ne(s.cost_usd,{currency:k,rate:j})]})})]}),e.jsxs("div",{className:"sessions-row-value",children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 md:sr-only",children:t("sessions.col.speed")}),e.jsx("dd",{className:"mt-1 min-h-5 text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 md:mt-0",children:e.jsx(oe,{performance:s.performance})})]})]}),e.jsx("button",{type:"button",onClick:C,disabled:!x,title:x||t("sessions.resume.unavailable"),"aria-label":x?t("sessions.resume.copy_aria",{command:x}):t("sessions.resume.unavailable"),className:"sessions-row-action inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-oai-gray-500 transition hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:cursor-not-allowed dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white md:h-8 md:w-8",children:e.jsx(Is,{className:"h-4 w-4","aria-hidden":!0})})]})});function it({sessions:a,selectedModel:s,onSelect:r}){const{groups:o,totalTokens:u}=i.useMemo(()=>{const l=new Map;let f=0;for(const _ of a)for(const k of X(_)){const j=k.model||t("sessions.model.unknown"),w=Number(k.total_tokens||0),g=l.get(j)||{model:j,count:0,tokens:0};g.count+=1,g.tokens+=w,f+=w,l.set(j,g)}return{groups:[...l.values()].sort((_,k)=>k.tokens-_.tokens),totalTokens:f}},[a]);function h(l){return $("min-h-10 rounded-md border px-2.5 text-xs tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 md:min-h-7",l?"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:"sessions-thread-models py-2.5",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"mr-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("sessions.thread.model_usage")}),e.jsx("button",{type:"button","aria-pressed":s==="all",onClick:()=>r("all"),className:h(s==="all"),children:t("sessions.thread.model_all",{count:a.length,tokens:S(u)})}),o.map(l=>e.jsx("button",{type:"button","aria-pressed":s===l.model,onClick:()=>r(l.model),className:h(s===l.model),children:t("sessions.thread.model_item",{model:l.model,count:l.count,tokens:S(l.tokens)})},l.model))]})})}function Tt(){const[a]=i.useState(()=>Vs(window.location.search)),[s,r]=i.useState(null),[o,u]=i.useState(null),[h,l]=i.useState(!0),[f,_]=i.useState(!1),[k,j]=i.useState(a.source),[w,g]=i.useState(a.model),[x,b]=i.useState(a.from||a.to?"custom":"all"),[y,R]=i.useState(a.from),[v,q]=i.useState(a.to),[M,D]=i.useState("all"),[C,O]=i.useState("time"),[A,se]=i.useState("recent"),[p,T]=i.useState(null),[L,m]=i.useState(""),[E,z]=i.useState(ke),[I,K]=i.useState(()=>new Set),[te,ae]=i.useState(()=>new Map),ne=i.useRef(0),ie=i.useRef(null),Q=i.useRef({projects:[],models:[]}),{resolvedLocale:Z}=Ue(),{currency:Xe,rate:Je}=Se(),[Ce,es]=i.useState(0);i.useEffect(()=>{const n=new Date;n.setHours(24,0,0,250);const c=setTimeout(()=>es(d=>d+1),Math.max(1e3,n.getTime()-Date.now()));return()=>clearTimeout(c)},[Ce]);const Me=i.useMemo(()=>{if(x==="custom"){let c=y,d=v;return c&&d&&c>d&&([c,d]=[d,c]),!c&&!d?Ee:{...c?{from:c}:{},...d?{to:d}:{}}}const n=je(x);return n?{from:Pe(n),to:Pe(Date.now())}:Ee},[x,y,v,Ce]),le=i.useCallback(async(n=!1)=>{const c=++ne.current;n||ie.current?_(!0):l(!0),u(null);try{const d=await Gs({refresh:n,includeBuckets:!1,includeModelDetail:!1,...Me});c===ne.current&&(ie.current=d,r(d),u(null))}catch(d){if(c!==ne.current)return;const N=d?.message||String(d);u(N),ie.current&&(ie.current=null,r(null))}finally{c===ne.current&&(l(!1),_(!1))}},[Me]);i.useEffect(()=>{Le||De()?le(!1):l(!1)},[le]);const U=s?.sessions||Oe,ss=i.useMemo(()=>{if(Number.isFinite(Number(s?.lifetime_session_count))){const c=Number(s.lifetime_session_count);return Q.current.count=c,c}const n=Math.max(U.length,Q.current.count||0);return Q.current.count=n,n},[s,U]),ts=i.useMemo(()=>{if(Array.isArray(s?.facets?.projects))return s.facets.projects.map(c=>({value:c,label:c}));const n=new Set(Q.current.projects);for(const c of U){const d=c.project_key;d&&n.add(d)}return Q.current.projects=[...n],[...n].sort((c,d)=>c.localeCompare(d)).map(c=>({value:c,label:c}))},[s,U]),as=i.useMemo(()=>{if(Array.isArray(s?.facets?.models))return s.facets.models.map(c=>({value:c,label:c}));const n=new Set(Q.current.models);for(const c of U)for(const d of X(c))d.model&&n.add(d.model);return Q.current.models=[...n],[...n].sort().map(c=>({value:c,label:c}))},[s,U]),he=i.useDeferredValue(L),ce=i.useMemo(()=>{let c=je(x),d=1/0;return x==="custom"&&(c=y?new Date(`${y}T00:00:00`).getTime():0,d=v?new Date(`${v}T23:59:59.999`).getTime():1/0,c>d&&(c=new Date(`${v}T00:00:00`).getTime(),d=new Date(`${y}T23:59:59.999`).getTime())),Ks(U,c,d)},[U,x,y,v]),W=i.useMemo(()=>{const n=he.trim().toLowerCase(),c=je(x);return ce.filter(d=>{if(k!=="all"&&d.source!==k||M!=="all"&&d.project_key!==M||w!=="all"&&!X(d).some(H=>H.model===w))return!1;if(x==="custom"){if(!Qs(d,y,v))return!1}else if(!tt(d,c))return!1;if(!n)return!0;const N=X(d).map(H=>H.model).join(" ");return`${d.title||""} ${d.project_key||""} ${N} ${d.agent_nickname||""} ${d.agent_role||""} ${d.project_ref||""} ${d.session_id||""}`.toLowerCase().includes(n)})},[ce,k,M,w,x,y,v,he]),B=i.useMemo(()=>Ze(W),[W]),Y=i.useMemo(()=>{const n=new Set(W.map(N=>N.session_hash)),c=new Map,d=[];for(const N of Bs(W,A)){const G=N.root_session_hash||N.parent_session_hash;if(N.parent_session_hash&&G&&n.has(G)){const H=c.get(G)||[];H.push(N),c.set(G,H)}else d.push(N)}return{roots:d,childrenByRoot:c,foldedCount:W.length-d.length}},[W,A]),ge=k!=="all"||w!=="all"||x!=="all"||M!=="all"||L.trim()!=="";i.useEffect(()=>{z(ke),K(new Set),ae(new Map)},[k,M,w,x,y,v,he,A,C,U]);const pe=i.useMemo(()=>Y.roots.slice(0,E),[Y.roots,E]),rs=i.useMemo(()=>Hs(pe,C),[pe,C]),os=i.useMemo(()=>p?ce.filter(n=>n.session_hash!==p.session_hash&&(n.root_session_hash===p.session_hash||n.parent_session_hash===p.session_hash)):Oe,[ce,p]),ns=i.useCallback(()=>T(null),[]),fe=i.useCallback(n=>{b(n),n!=="custom"&&(R(""),q(""))},[]),is=i.useCallback(()=>{j("all"),g("all"),D("all"),m(""),fe("all")},[fe]),be=Y.roots.length>pe.length,ye=i.useCallback(()=>z(n=>n+ke),[]),ls=i.useCallback(n=>{K(c=>{const d=new Set(c);return d.has(n)?d.delete(n):d.add(n),d})},[]),cs=i.useCallback((n,c)=>{ae(d=>{const N=new Map(d);return c==="all"?N.delete(n):N.set(n,c),N})},[]),Te=i.useRef(null);i.useEffect(()=>{if(!be||typeof IntersectionObserver>"u")return;const n=Te.current;if(!n)return;const c=new IntersectionObserver(d=>{d.some(N=>N.isIntersecting)&&ye()},{rootMargin:"400px"});return c.observe(n),()=>c.disconnect()},[be,ye]);const ds=i.useMemo(()=>st.map(n=>({value:n.id,label:n.label()})),[Z]),us=i.useMemo(()=>[...Ye.map(n=>({value:n.id,label:n.label()})),{value:"custom",label:t("sessions.filter.range_custom")}],[Z]),ms=i.useMemo(()=>[{value:"time",label:t("sessions.group.time")},{value:"project",label:t("sessions.group.project")}],[Z]),xs=i.useMemo(()=>[{value:"recent",label:t("sessions.sort.recent")},{value:"cost",label:t("sessions.sort.cost")},{value:"tokens",label:t("sessions.sort.tokens")}],[Z]),hs=Number(s?.session_count)>Number(s?.returned_count);return!Le&&!De()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(ks,{})}):e.jsxs("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:t("nav.sessions")}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:t("sessions.page.summary")})]}),e.jsx("button",{type:"button",onClick:()=>{le(!0)},disabled:f||h,"aria-label":t("sessions.page.refresh"),title:t("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(ys,{className:$("h-4 w-4",f&&"animate-spin"),"aria-hidden":!0})})]}),e.jsxs("div",{className:"mb-6 space-y-3",children:[e.jsxs("div",{className:"sessions-toolbar",children:[e.jsxs("div",{className:"sessions-toolbar-search relative",children:[e.jsx(Ke,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0}),e.jsx(js,{type:"search",value:L,onChange:n=>m(n.target.value),onKeyDown:n=>{n.key==="Escape"&&L&&(n.preventDefault(),m(""))},"aria-label":t("sessions.action.search_aria"),placeholder:t("sessions.search.placeholder"),className:"h-11 pl-10 pr-12 text-sm !bg-white dark:!bg-oai-gray-900 !border-oai-gray-200 placeholder:!text-oai-gray-500 dark:!border-oai-gray-800 dark:placeholder:!text-oai-gray-400 sm:h-9 [&::-webkit-search-cancel-button]:appearance-none"}),L?e.jsx("button",{type:"button",onMouseDown:n=>n.preventDefault(),onClick:()=>m(""),"aria-label":t("sessions.action.search_clear"),className:"absolute right-0 top-0 flex h-11 w-11 items-center justify-center rounded-md text-oai-gray-600 hover:bg-oai-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 sm:h-9 sm:w-9",children:e.jsx(Ge,{className:"h-4 w-4","aria-hidden":!0})}):null]}),e.jsx(de,{ariaLabel:t("sessions.filter.source_aria"),options:ds,value:k,onValueChange:j,className:"sessions-filter-trigger h-11 min-w-0 px-3 text-sm sm:h-9",matchTriggerWidth:!0}),e.jsx(de,{ariaLabel:t("sessions.filter.range_aria"),options:us,value:x,onValueChange:fe,leadingIcon:e.jsx(As,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0}),className:"sessions-filter-trigger h-11 min-w-0 px-3 text-sm sm:h-9",matchTriggerWidth:!0}),e.jsx(Fe,{options:ts,value:M,onChange:D,allLabel:t("sessions.filter.project_all"),searchPlaceholder:t("sessions.filter.project_search"),emptyLabel:t("sessions.filter.project_empty"),ariaLabel:t("sessions.filter.project_aria"),className:"sessions-filter-trigger !h-11 !w-full !max-w-none !px-3 !text-sm !font-normal sm:!h-9 !bg-white !text-oai-black dark:!bg-oai-gray-900 dark:!text-white [&>svg]:!text-oai-gray-500 dark:[&>svg]:!text-oai-gray-400"}),e.jsx(Fe,{options:as,value:w,onChange:g,allLabel:t("sessions.filter.model_all"),searchPlaceholder:t("sessions.filter.model_search"),emptyLabel:t("sessions.filter.model_empty"),ariaLabel:t("sessions.filter.model_aria"),className:"sessions-filter-trigger sessions-model-filter !h-11 !w-full !max-w-none !px-3 !text-sm !font-normal sm:!h-9 !bg-white !text-oai-black dark:!bg-oai-gray-900 dark:!text-white [&>svg]:!text-oai-gray-500 dark:[&>svg]:!text-oai-gray-400"})]}),x==="custom"?e.jsxs("div",{className:"grid max-w-lg grid-cols-2 gap-3",children:[e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"mb-1 block",children:t("sessions.filter.from")}),e.jsx("input",{type:"date","aria-label":t("sessions.filter.from"),value:y,onChange:n=>R(n.target.value),className:"h-11 w-full min-w-0 rounded-md border border-oai-gray-200 bg-white px-3 text-sm outline-none focus:ring-2 focus:ring-oai-brand-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:h-10"})]}),e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"mb-1 block",children:t("sessions.filter.to")}),e.jsx("input",{type:"date","aria-label":t("sessions.filter.to"),value:v,onChange:n=>q(n.target.value),className:"h-11 w-full min-w-0 rounded-md border border-oai-gray-200 bg-white px-3 text-sm outline-none focus:ring-2 focus:ring-oai-brand-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:h-10"})]})]}):null]}),!h&&s?e.jsx("section",{className:"mb-6 flex items-start gap-3 rounded-lg border border-oai-gray-200 px-4 py-3 dark:border-oai-gray-800",children:e.jsxs("dl",{className:"sessions-kpis grid min-w-0 flex-1 grid-cols-2 gap-y-3 sm:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("sessions.summary.count")}),e.jsx("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:S(B.count)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("sessions.col.tokens")}),e.jsx("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:S(B.tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("sessions.col.cost")}),e.jsx("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:B.costIsPartial&&B.cost===0?t("dashboard.cost_breakdown.unpriced_label"):e.jsxs(e.Fragment,{children:[B.costIsPartial?"≥":"",Ne(B.cost,{currency:Xe,rate:Je})]})})]}),e.jsxs("div",{children:[e.jsxs("dt",{className:"flex items-center gap-1.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:t("sessions.summary.speed")}),e.jsx(rt,{})]}),e.jsxs("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:[e.jsx(oe,{performance:B.performance}),B.performance.estimated_tokens_per_second==null?"—":null]})]})]})}):null,!h&&s?e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-x-3 gap-y-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:Y.foldedCount>0?t("sessions.thread.result_count",{roots:Y.roots.length,subagents:Y.foldedCount}):t("sessions.filter.result_count",{filtered:W.length,total:ss})}),ge?e.jsx("button",{type:"button",onClick:is,className:"inline-flex min-h-10 items-center rounded text-oai-gray-700 underline decoration-oai-gray-300 underline-offset-4 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-200 dark:decoration-oai-gray-600 dark:hover:text-white sm:min-h-0",children:t("sessions.filter.clear")}):null]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(de,{ariaLabel:t("sessions.group.aria"),options:ms,value:C,onValueChange:O,className:"sessions-filter-trigger h-11 min-w-0 max-w-40 px-2.5 text-xs sm:h-8"}),e.jsx(de,{ariaLabel:t("sessions.sort.aria"),options:xs,value:A,onValueChange:se,className:"sessions-filter-trigger h-11 min-w-0 max-w-44 px-2.5 text-xs sm:h-8",align:"end"})]})]}):null,!h&&hs?e.jsx("p",{className:"mb-4 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("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:t("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:()=>{le(!1)},className:"mt-4 inline-flex h-11 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:t("sessions.error.retry")})]}):h?e.jsx(nt,{}):W.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:ge?t("sessions.empty.filtered_title"):t("sessions.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:ge?t("sessions.empty.filtered_body"):t("sessions.empty.body")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sessions-row-grid sessions-list-header border-b border-oai-gray-200 py-2 text-xs text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400","aria-hidden":!0,children:[e.jsx("span",{children:t("sessions.col.session")}),e.jsx("span",{className:"text-right",children:t("sessions.col.tokens")}),e.jsx("span",{className:"text-right",children:t("sessions.col.cost")}),e.jsx("span",{className:"text-right",children:t("sessions.col.speed")}),e.jsx("span",{className:"sr-only",children:t("sessions.col.actions")})]}),e.jsx("ul",{className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:rs.map(n=>e.jsxs(we.Fragment,{children:[e.jsx("li",{className:"pb-2 pt-5",children:e.jsx("h2",{className:"break-words text-xs font-medium text-oai-gray-900 dark:text-oai-gray-100",children:C==="project"?n.key||t("sessions.project.unknown"):n.key?new Date(`${n.key}T12:00:00`).toLocaleDateString(Z||void 0,{year:"numeric",month:"short",day:"numeric"}):t("sessions.group.unknown_date")})}),n.sessions.map(c=>{const d=Y.childrenByRoot.get(c.session_hash)||[],N=I.has(c.session_hash),G=te.get(c.session_hash)||"all",H=G==="all"?d:d.filter(function(gs){return X(gs).some(ps=>ps.model===G)});return e.jsxs(we.Fragment,{children:[e.jsx(ze,{session:c,locale:Z,timeOnly:C==="time",childCount:d.length,expanded:N,onToggle:ls,onDetail:T}),N&&d.length?e.jsx(it,{sessions:d,selectedModel:G,onSelect:re=>cs(c.session_hash,re)}):null,N?H.map(re=>e.jsx(ze,{session:re,locale:Z,nested:!0,timeOnly:C==="time",onDetail:T},re.session_hash)):null]},c.session_hash)})]},n.key))}),be?e.jsx("div",{ref:Te,className:"flex justify-center pt-6",children:e.jsx("button",{type:"button",onClick:ye,className:"inline-flex h-11 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:t("sessions.action.load_more")})}):null]}),h?null:e.jsx("p",{className:"mt-8 max-w-3xl text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:t("sessions.privacy")})]})}),p?e.jsx(et,{session:p,subagents:os,onClose:ns}):null]})}export{Tt as SessionsPage};
|