tokentracker-cli 1.2.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +2 -0
  2. package/README.zh-CN.md +2 -0
  3. package/dashboard/dist/assets/AchievementBadge-BaqdyZaV.js +1 -0
  4. package/dashboard/dist/assets/AchievementsPage-B4Ju0guv.js +2 -0
  5. package/dashboard/dist/assets/{AchievementsSection-BDqKRGyL.js → AchievementsSection-CDUUEfIi.js} +1 -1
  6. package/dashboard/dist/assets/BadgeDetailModal-B-XMJAvL.js +1 -0
  7. package/dashboard/dist/assets/{BotAnimated-OQbsVw1O.js → BotAnimated-Dx_vvTtC.js} +1 -1
  8. package/dashboard/dist/assets/Card-D-5mABVt.js +1 -0
  9. package/dashboard/dist/assets/CloudCheckoutPage-BELoh56h.js +1 -0
  10. package/dashboard/dist/assets/CloudPage-CfBruNxe.js +1 -0
  11. package/dashboard/dist/assets/CloudUsageExport-BoFU7xCT.js +4 -0
  12. package/dashboard/dist/assets/CommandPalette-BmmKZWn-.js +1 -0
  13. package/dashboard/dist/assets/CommunityStatsModal-BF77zVhN.js +1 -0
  14. package/dashboard/dist/assets/{ConfirmModal-Dhu_qmiM.js → ConfirmModal-BQ-xB1S_.js} +1 -1
  15. package/dashboard/dist/assets/Controls-BnTeX7T4.js +1 -0
  16. package/dashboard/dist/assets/DashboardPage-BWulHa5J.js +1 -0
  17. package/dashboard/dist/assets/{DevicePage-Bvz7JJwt.js → DevicePage-Dg6XkIaY.js} +1 -1
  18. package/dashboard/dist/assets/DialogClose-DAyilsH-.js +1 -0
  19. package/dashboard/dist/assets/DialogDescription-j4XnRy6y.js +1 -0
  20. package/dashboard/dist/assets/{DialogTitle-C8vpXqg8.js → DialogTitle-B1iNGD2S.js} +1 -1
  21. package/dashboard/dist/assets/{FadeIn-DDF5PqTX.js → FadeIn-ChVf45WW.js} +1 -1
  22. package/dashboard/dist/assets/{HeaderGithubStar-CNzQFPol.js → HeaderGithubStar-B740_G7a.js} +1 -1
  23. package/dashboard/dist/assets/{HoverTooltip-BKg9Z6gg.js → HoverTooltip-BzP5FudR.js} +1 -1
  24. package/dashboard/dist/assets/{IpCheckPage-BTdrLt08.js → IpCheckPage-BuZH3F14.js} +1 -1
  25. package/dashboard/dist/assets/LandingPage-Dtgq_caz.js +2 -0
  26. package/dashboard/dist/assets/LeaderboardPage-Di1kEg2O.js +2 -0
  27. package/dashboard/dist/assets/LeaderboardProBadge-h8FfR0au.js +1 -0
  28. package/dashboard/dist/assets/LeaderboardProfileModal-OUZvO6u-.js +73 -0
  29. package/dashboard/dist/assets/{LeaderboardProfilePage-CoqcDSTw.js → LeaderboardProfilePage-bHI1oTEK.js} +2 -2
  30. package/dashboard/dist/assets/{LimitsPage-3RuSFnn-.js → LimitsPage-DKojB73_.js} +2 -2
  31. package/dashboard/dist/assets/{LocalOnlyNotice-D-OrIXty.js → LocalOnlyNotice-BaEq6qN7.js} +1 -1
  32. package/dashboard/dist/assets/LoginCard-Dn5Xy4If.js +1 -0
  33. package/dashboard/dist/assets/LoginModal-C5h-5GOA.js +1 -0
  34. package/dashboard/dist/assets/LoginPage-BpX8Tgjj.js +1 -0
  35. package/dashboard/dist/assets/PetPage-BPBsUHyL.js +1 -0
  36. package/dashboard/dist/assets/PopoverPopup-CVTiEVHs.js +1 -0
  37. package/dashboard/dist/assets/{ProviderIcon-BTYVbUti.js → ProviderIcon-BshO2uER.js} +1 -1
  38. package/dashboard/dist/assets/ResetPasswordPage-RTFTD8Dr.js +1 -0
  39. package/dashboard/dist/assets/{Select-D8N2TJz1.js → Select-CtTceC4T.js} +1 -1
  40. package/dashboard/dist/assets/SelectItemText-C7xi8iGp.js +1 -0
  41. package/dashboard/dist/assets/SelfHostPage-BlwTt8XM.js +1 -0
  42. package/dashboard/dist/assets/{ServiceStatusPage-Cb3k_C4g.js → ServiceStatusPage-BkIcJpYK.js} +1 -1
  43. package/dashboard/dist/assets/{SessionsPage-BtH5iLbi.js → SessionsPage-okHobk_L.js} +3 -3
  44. package/dashboard/dist/assets/SettingsPage-C-cc6wcF.js +2 -0
  45. package/dashboard/dist/assets/SkillsPage-D2LlKKJN.js +1 -0
  46. package/dashboard/dist/assets/{TokenGalaxy-BGRF4I_8.js → TokenGalaxy-DiXUpXKF.js} +2 -2
  47. package/dashboard/dist/assets/TrendMonitor-C88S-5aa.js +19 -0
  48. package/dashboard/dist/assets/WidgetsPage-WsEFPNwp.js +1 -0
  49. package/dashboard/dist/assets/{WrappedPage-BqyB7ezg.js → WrappedPage-ClEo-RmR.js} +1 -1
  50. package/dashboard/dist/assets/__vite-browser-external-DFRX9dp-.css +1 -0
  51. package/dashboard/dist/assets/__vite-browser-external-DUJeOWgd.js +45 -0
  52. package/dashboard/dist/assets/agent-logos-BM9jlReI.js +1 -0
  53. package/dashboard/dist/assets/arrow-left-BEM-HVmC.js +1 -0
  54. package/dashboard/dist/assets/arrow-right-CwBz5dwb.js +1 -0
  55. package/dashboard/dist/assets/{arrow-up-right-CdzAw406.js → arrow-up-right-jPmRN562.js} +1 -1
  56. package/dashboard/dist/assets/{check-DhEiHlwq.js → check-CKwHc4Hv.js} +1 -1
  57. package/dashboard/dist/assets/cloud-checkout-nYNHDFoR.js +1 -0
  58. package/dashboard/dist/assets/composite-B4Z3F65o.js +1 -0
  59. package/dashboard/dist/assets/{download-kGPw24XQ.js → download-CJUnX1Bs.js} +1 -1
  60. package/dashboard/dist/assets/{external-link-SOFbVRrH.js → external-link-B5yXxdPy.js} +1 -1
  61. package/dashboard/dist/assets/{flame-BRdc7HDz.js → flame-CKjAluj_.js} +1 -1
  62. package/dashboard/dist/assets/{format-tokens-DhIeweGK.js → format-tokens-mk49THtv.js} +1 -1
  63. package/dashboard/dist/assets/{host-mode-APftzzvz.js → host-mode-efKlSYjX.js} +1 -1
  64. package/dashboard/dist/assets/{icons-D-wu8eUg.js → icons-ZB1ZthjH.js} +1 -1
  65. package/dashboard/dist/assets/{index-D2g1tPGl.js → index-BImBG3eS.js} +1 -1
  66. package/dashboard/dist/assets/{index-CiWf_0mc.js → index-BgdM7kBl.js} +1 -1
  67. package/dashboard/dist/assets/{index-CZ3D1Q7c.js → index-DweUMAUD.js} +1 -1
  68. package/dashboard/dist/assets/{info-Qgc5VctK.js → info-CyDY7NYM.js} +1 -1
  69. package/dashboard/dist/assets/{link-2-Cg6bEvjQ.js → link-2-Dn2soiyd.js} +1 -1
  70. package/dashboard/dist/assets/{loader-circle-Cd7h4LcE.js → loader-circle-CNT630zn.js} +1 -1
  71. package/dashboard/dist/assets/{modifiers.esm-B7hOvflM.js → modifiers.esm-WPx0bc2K.js} +1 -1
  72. package/dashboard/dist/assets/{monitor-smartphone-wFv5VQQf.js → monitor-smartphone-C-qC0RAt.js} +1 -1
  73. package/dashboard/dist/assets/os-DMmhX9tk.js +1 -0
  74. package/dashboard/dist/assets/{plus-0xHQei42.js → plus-Cx82jb7o.js} +1 -1
  75. package/dashboard/dist/assets/{provider-display-DNqVkqfp.js → provider-display-CodMmiRb.js} +2 -2
  76. package/dashboard/dist/assets/{react-CfB5zBqR.js → react-B7SkZTgg.js} +1 -1
  77. package/dashboard/dist/assets/safePolygon-CKpREa4K.js +1 -0
  78. package/dashboard/dist/assets/{search-DMtc6bBy.js → search-Ol3OZBm4.js} +1 -1
  79. package/dashboard/dist/assets/server-DFCbznC7.js +1 -0
  80. package/dashboard/dist/assets/shield-check-YcmLwVZ6.js +1 -0
  81. package/dashboard/dist/assets/skills-api-C-9vK884.js +1 -0
  82. package/dashboard/dist/assets/{sortable.esm-O7ntEYCi.js → sortable.esm-CKC9NuR-.js} +1 -1
  83. package/dashboard/dist/assets/store-C9yWYHfg.js +1 -0
  84. package/dashboard/dist/assets/{terminal-Y3qDL50U.js → terminal-B3_fCLFs.js} +1 -1
  85. package/dashboard/dist/assets/{trash-D_PaPrXq.js → trash-CZGfgbFa.js} +1 -1
  86. package/dashboard/dist/assets/{use-community-stats-DGTBo_4v.js → use-community-stats-CW-qkYn7.js} +1 -1
  87. package/dashboard/dist/assets/{use-latest-request-guard-BpfCferm.js → use-latest-request-guard-DHv7vfFE.js} +1 -1
  88. package/dashboard/dist/assets/{use-limits-display-prefs-Drs82lSi.js → use-limits-display-prefs-NZ-AAYD5.js} +1 -1
  89. package/dashboard/dist/assets/use-native-settings-CWiLqfZh.js +1 -0
  90. package/dashboard/dist/assets/{use-ordered-list-CClTBWi0.js → use-ordered-list-Df8pw-WJ.js} +1 -1
  91. package/dashboard/dist/assets/use-pet-settings-Bg2CDprr.js +2 -0
  92. package/dashboard/dist/assets/use-reduced-motion-iDZEUyua.js +1 -0
  93. package/dashboard/dist/assets/{use-transform-CA5mW4u8.js → use-transform-BHwEAfmO.js} +1 -1
  94. package/dashboard/dist/assets/use-usage-limits-CSxFFn3_.js +1 -0
  95. package/dashboard/dist/assets/{useCurrency-CaOhUMcm.js → useCurrency-pwClnCZ5.js} +1 -1
  96. package/dashboard/dist/assets/usePositioner-B0j1orGj.js +1 -0
  97. package/dashboard/dist/assets/useTokenFormat-BMvVAe6V.js +1 -0
  98. package/dashboard/dist/assets/{zap-Cqur2X5s.js → zap-DvX2aYx5.js} +1 -1
  99. package/dashboard/dist/index.html +2 -2
  100. package/dashboard/dist/ip-check.html +2 -2
  101. package/dashboard/dist/leaderboard.html +2 -2
  102. package/dashboard/dist/pricing.html +6 -5
  103. package/dashboard/dist/privacy.html +3 -3
  104. package/dashboard/dist/share.html +2 -2
  105. package/dashboard/dist/terms.html +6 -6
  106. package/package.json +6 -2
  107. package/src/commands/device-login.js +60 -33
  108. package/src/commands/init.js +26 -7
  109. package/src/commands/serve.js +3 -3
  110. package/src/commands/sync.js +43 -22
  111. package/src/lib/atomic-json.js +27 -0
  112. package/src/lib/bearer-token.js +11 -0
  113. package/src/lib/cloud-account.js +4 -1
  114. package/src/lib/local-api.js +282 -69
  115. package/src/lib/openclaw-cli.js +104 -0
  116. package/src/lib/openclaw-hook.js +1 -46
  117. package/src/lib/openclaw-session-plugin.js +1 -59
  118. package/src/lib/pricing/seed-snapshot.json +1 -1
  119. package/src/lib/proxy-env.js +8 -3
  120. package/src/lib/rollout.js +15 -10
  121. package/src/lib/runtime-config.js +84 -14
  122. package/src/lib/skills-manager.js +8 -1
  123. package/src/lib/static-server.js +19 -4
  124. package/src/lib/upload-throttle.js +18 -4
  125. package/dashboard/dist/assets/AchievementBadge-B67_Cp1T.js +0 -1
  126. package/dashboard/dist/assets/AchievementsPage-DNJ5n0Bn.js +0 -2
  127. package/dashboard/dist/assets/BadgeDetailModal-DFL1MPcg.js +0 -1
  128. package/dashboard/dist/assets/Card-dqzakOoX.js +0 -1
  129. package/dashboard/dist/assets/CommandPalette-8B38qUs0.js +0 -1
  130. package/dashboard/dist/assets/CommunityStatsModal-DnbCiGms.js +0 -1
  131. package/dashboard/dist/assets/Controls-BgQflA-3.js +0 -1
  132. package/dashboard/dist/assets/DashboardPage-DeLRhWU_.js +0 -1
  133. package/dashboard/dist/assets/DialogClose-DUxjaRqf.js +0 -1
  134. package/dashboard/dist/assets/DialogDescription-h6XMtzIU.js +0 -1
  135. package/dashboard/dist/assets/LandingPage-cjoagPAb.js +0 -2
  136. package/dashboard/dist/assets/LeaderboardAvatar-CJdG51hR.js +0 -1
  137. package/dashboard/dist/assets/LeaderboardPage-D-yf2rOQ.js +0 -2
  138. package/dashboard/dist/assets/LeaderboardProfileModal--hrfpUPF.js +0 -73
  139. package/dashboard/dist/assets/LoginCard-BiMyV2Uf.js +0 -1
  140. package/dashboard/dist/assets/LoginModal-D79CMZmf.js +0 -1
  141. package/dashboard/dist/assets/LoginPage-BLyGuPlG.js +0 -1
  142. package/dashboard/dist/assets/PetPage-Bv0K4k2t.js +0 -1
  143. package/dashboard/dist/assets/PopoverPopup-3eucO8QU.js +0 -1
  144. package/dashboard/dist/assets/ResetPasswordPage-VYMl84_-.js +0 -1
  145. package/dashboard/dist/assets/SelectItemText-CoTR0Uwm.js +0 -1
  146. package/dashboard/dist/assets/SettingsPage-huGkex5G.js +0 -2
  147. package/dashboard/dist/assets/SkillsPage-B9usVOTU.js +0 -1
  148. package/dashboard/dist/assets/TrendMonitor-B8SKBsWO.js +0 -19
  149. package/dashboard/dist/assets/WidgetsPage-o_91L3Zi.js +0 -1
  150. package/dashboard/dist/assets/__vite-browser-external-Cj9D7QBh.js +0 -45
  151. package/dashboard/dist/assets/__vite-browser-external-gKkiQad5.css +0 -1
  152. package/dashboard/dist/assets/agent-logos-CEcgxIBU.js +0 -1
  153. package/dashboard/dist/assets/composite-DO7_ilHE.js +0 -1
  154. package/dashboard/dist/assets/skills-api-BeN184fz.js +0 -1
  155. package/dashboard/dist/assets/store-D-FZbBaC.js +0 -1
  156. package/dashboard/dist/assets/use-pet-settings-DvaQ7XrL.js +0 -2
  157. package/dashboard/dist/assets/use-reduced-motion-Dg10dVuu.js +0 -1
  158. package/dashboard/dist/assets/use-session-efficiency-pref-BiYRXVlN.js +0 -1
  159. package/dashboard/dist/assets/use-usage-limits-B0uafB4O.js +0 -1
  160. package/dashboard/dist/assets/useTokenFormat-JjQCKdIr.js +0 -1
@@ -1,73 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BadgeDetailModal-DFL1MPcg.js","assets/__vite-browser-external-Cj9D7QBh.js","assets/__vite-browser-external-gKkiQad5.css","assets/react-CfB5zBqR.js","assets/AchievementBadge-B67_Cp1T.js","assets/zap-Cqur2X5s.js","assets/flame-BRdc7HDz.js","assets/use-transform-CA5mW4u8.js","assets/use-reduced-motion-Dg10dVuu.js","assets/AchievementsSection-BDqKRGyL.js","assets/format-tokens-DhIeweGK.js","assets/DialogTitle-C8vpXqg8.js","assets/composite-DO7_ilHE.js","assets/store-D-FZbBaC.js"])))=>i.map(i=>d[i]);
2
- import{q as se,a as E,r as h,a7 as ie,j as e,c as o,a8 as oe,A as ne,G as le,a9 as de,aa as ce,e as c,Q as me,$ as xe,L as ge,d as W,a1 as pe,n as he,ab as ue,X as fe,l as be,_ as ye,ac as ke,ad as ve}from"./__vite-browser-external-Cj9D7QBh.js";import{A as je,f as Ne}from"./provider-display-DNqVkqfp.js";import{u as _e}from"./useCurrency-CaOhUMcm.js";import{u as G}from"./useTokenFormat-JjQCKdIr.js";import{L as Z}from"./LeaderboardAvatar-CJdG51hR.js";import{P as L}from"./ProviderIcon-BTYVbUti.js";import{H as we,A as X,s as Ae,c as Se,b as Me,t as ze,h as Ce}from"./AchievementBadge-B67_Cp1T.js";import{A as Ie}from"./AchievementsSection-BDqKRGyL.js";import{A as B}from"./arrow-up-right-CdzAw406.js";import{L as Pe}from"./link-2-Cg6bEvjQ.js";import{C as De}from"./check-DhEiHlwq.js";import{D as Te,a as $e,b as Le,c as Be,d as Ue,e as Fe}from"./DialogTitle-C8vpXqg8.js";import"./terminal-Y3qDL50U.js";import"./info-Qgc5VctK.js";import"./zap-Cqur2X5s.js";import"./flame-BRdc7HDz.js";import"./react-CfB5zBqR.js";import"./format-tokens-DhIeweGK.js";import"./use-reduced-motion-Dg10dVuu.js";import"./composite-DO7_ilHE.js";import"./store-D-FZbBaC.js";const Y={name:"code-xml",size:24,node:[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],aliases:["code-2"]};Y.node;const Re=se(Y),U="tokentracker_anon_id";let A=null;function F(){try{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const r=Math.random()*16|0;return(a==="x"?r:r&3|8).toString(16)})}function R(){if(A)return A;try{let a=localStorage.getItem(U);return a||(a=F(),localStorage.setItem(U,a)),A=a,a}catch{return A=F(),A}}function q({userId:a}){const{signedIn:r,getAccessToken:i}=E(),[t,s]=h.useState(!1),[l,g]=h.useState(0),[n,x]=h.useState(!1),[u,f]=h.useState(!1),[S,M]=h.useState(!1),[z,D]=h.useState([]),[j,N]=h.useState(!1),C=h.useRef(0),y=h.useCallback(async()=>{if(r)try{const d=await i();if(d)return{accessToken:d,anonId:R()}}catch{}return{anonId:R()}},[r,i]);h.useEffect(()=>{let d=!1;return a?(x(!1),(async()=>{const m=await y();try{const p=await ie({userId:a,...m});if(d)return;g(Number(p?.count)||0),s(!!p?.liked),x(!0)}catch{if(d)return;g(0),s(!1),x(!0)}})(),()=>{d=!0}):(x(!1),()=>{d=!0})},[a,y]);const k=()=>{M(!0),setTimeout(()=>M(!1),450),N(!0),setTimeout(()=>N(!1),500);const d=["#ff4757","#ff6b81","#ffa502","#70a1ff","#2ed573","#a29bfe"],m=["circle","heart"],p=[];for(let b=0;b<12;b++){const v=(b*30+Math.random()*20-10)*(Math.PI/180),I=45+Math.random()*45,V=Math.cos(v)*I,Q=Math.sin(v)*I-(10+Math.random()*15),J=Math.random()*360-180,ee=6+Math.random()*8,ae=d[Math.floor(Math.random()*d.length)],re=m[Math.floor(Math.random()*m.length)],te=++C.current;p.push({id:te,tx:V,ty:Q,rot:J,size:ee,color:ae,shape:re})}D(b=>[...b,...p]),setTimeout(()=>{D(b=>b.filter(v=>!p.find(I=>I.id===v.id)))},850)},_=async d=>{f(!0);try{const m=await y(),p=await oe({userId:a,action:d,...m});p&&Number.isFinite(Number(p.count))&&g(Number(p.count)),p&&typeof p.liked=="boolean"&&s(p.liked)}catch{s(m=>!m),g(m=>d==="like"?Math.max(0,m-1):m+1)}finally{f(!1)}},w=d=>{d.stopPropagation(),!(!a||!n||u)&&(t?(s(!1),g(m=>Math.max(0,m-1)),_("unlike")):(s(!0),g(m=>m+1),k(),_("like")))};return e.jsxs("div",{className:"relative inline-flex items-center select-none z-10",children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:`
3
- @keyframes tt-like-pop {
4
- 0% { transform: scale(1); }
5
- 25% { transform: scale(0.75); }
6
- 50% { transform: scale(1.35); }
7
- 75% { transform: scale(0.9); }
8
- 100% { transform: scale(1); }
9
- }
10
- @keyframes tt-particle-fly {
11
- 0% {
12
- transform: translate(0, 0) scale(1) rotate(0deg);
13
- opacity: 1;
14
- }
15
- 70% {
16
- opacity: 0.8;
17
- }
18
- 100% {
19
- transform: translate(var(--tx), var(--ty)) scale(0.2) rotate(var(--rot));
20
- opacity: 0;
21
- }
22
- }
23
- @keyframes tt-num-scroll {
24
- 0% { transform: translateY(8px); opacity: 0; }
25
- 100% { transform: translateY(0); opacity: 1; }
26
- }
27
- .tt-animate-pop {
28
- animation: tt-like-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
29
- }
30
- .tt-particle {
31
- position: absolute;
32
- top: 50%;
33
- left: 50%;
34
- margin-top: -6px;
35
- margin-left: -6px;
36
- pointer-events: none;
37
- z-index: 50;
38
- }
39
- .tt-num-anim {
40
- animation: tt-num-scroll 0.25s ease-out forwards;
41
- }
42
- `}}),z.map(d=>e.jsx("span",{className:"tt-particle",style:{"--tx":`${d.tx}px`,"--ty":`${d.ty}px`,"--rot":`${d.rot}deg`,width:`${d.size}px`,height:`${d.size}px`,backgroundColor:d.shape==="circle"?d.color:"transparent",borderRadius:d.shape==="circle"?"50%":"0",animation:"tt-particle-fly 0.8s cubic-bezier(0.1, 0.8, 0.3, 1) forwards"},children:d.shape==="heart"&&e.jsx("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:d.color,className:"w-full h-full",children:e.jsx("path",{d:"M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"})})},d.id)),e.jsxs("button",{type:"button",onClick:w,disabled:!n||u,"aria-label":t?o("leaderboard.profile.like.aria_unlike"):o("leaderboard.profile.like.aria_like"),className:`group flex items-center justify-center gap-1.5 h-8 min-w-[48px] px-2.5 rounded-full border transition-all duration-300 outline-none focus-visible:ring-2 focus-visible:ring-rose-500/50 disabled:opacity-60 disabled:cursor-default ${t?"bg-rose-50/60 border-rose-200/80 text-rose-500 dark:bg-rose-950/20 dark:border-rose-900/40 dark:text-rose-400 shadow-sm":"bg-white/80 border-oai-gray-200 text-oai-gray-500 hover:border-rose-200 hover:text-rose-500 hover:bg-rose-50/30 dark:bg-oai-gray-950/50 dark:border-white/10 dark:text-oai-gray-400 dark:hover:border-rose-900/50 dark:hover:text-rose-400 dark:hover:bg-rose-950/5"}`,children:[e.jsx("span",{className:S?"tt-animate-pop":"group-active:scale-90 transition-transform duration-100",children:e.jsx(we,{size:14,className:`transition-all duration-300 ${t?"fill-rose-500 text-rose-500 dark:fill-rose-400 dark:text-rose-400":"fill-transparent"}`})}),e.jsx("span",{className:`text-[12px] font-bold font-mono tabular-nums tracking-tight ${t?"text-rose-600 dark:text-rose-400":"text-oai-gray-600 dark:text-oai-gray-400"} ${j?"tt-num-anim":""}`,children:n?l:"·"})]})]})}function He({badge:a,badgeLabel:r,className:i="",...t}){return e.jsxs("div",{className:`relative inline-flex shrink-0 ${i}`,children:[e.jsx(Z,{...t}),a?e.jsx("span",{className:"absolute -bottom-1 -right-1 inline-flex rounded-full ring-2 ring-white dark:ring-oai-gray-950",children:e.jsx(X,{badgeId:a.id,tier:a.tier,size:"sm",label:r})}):null]})}function Oe({badges:a,isOwn:r=!1,onSelect:i,className:t=""}){const s=Ae((Array.isArray(a)?a:[]).filter(l=>l&&Se.has(l.id))).filter(l=>r||(l.tier||0)>=1);return s.length===0?null:e.jsx("div",{className:`flex flex-wrap items-center pr-2.5 ${t}`,children:s.map((l,g)=>{const n=(l.tier||0)>=1,x=o(Me(l.id,"name")),u=n?o(`achievements.tier.${ze(l.tier)}`):o("achievements.modal.locked");return e.jsx("button",{type:"button",onClick:i?()=>i(l):void 0,title:`${x} · ${u}`,"aria-label":o("achievements.badge.aria",{name:x,tier:u}),style:{zIndex:s.length-g},className:"group relative shrink-0 -mr-2.5 rounded-full transition-transform duration-200 ease-out hover:z-30 hover:-translate-y-1 active:scale-95 focus-visible:z-30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/60",children:e.jsx(X,{badgeId:l.id,tier:l.tier,locked:!n,size:"md",className:"rounded-full ring-2 ring-white transition-shadow duration-200 group-hover:shadow-md dark:ring-oai-gray-950"})},l.id)})})}const Ee=W.lazy(()=>ye(()=>import("./BadgeDetailModal-DFL1MPcg.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])));function We(a,r,i){const t=Number(a);return!Number.isFinite(t)||t<0?"—":t>0&&t<.01?`<${r==="USD"?"$":""}0.01`:ke(t,{decimals:2,currency:r,rate:i})}function H(a,r,i){const t=Number(a);if(!Number.isFinite(t)||t<0)return"—";if(t<1e3)return We(t,r,i);const s=r==="USD"?t:t*(i||1);return`${r==="USD"?"$":""}${be(s,{decimals:1})}`}function Ge(a){const r=Array.isArray(a)?a:[];if(r.length===0)return null;const i=r.map(s=>({day:s.date,total_tokens:s.total_tokens,models:s.models||null})),t=r[r.length-1]?.date;return ue({dailyRows:i,weeks:52,to:t})}const Ze=`
43
- @keyframes tt-shimmer {
44
- 100% { transform: translateX(100%); }
45
- }
46
- .tt-shimmer-bar {
47
- position: relative;
48
- overflow: hidden;
49
- }
50
- .tt-shimmer-bar::after {
51
- position: absolute;
52
- top: 0; right: 0; bottom: 0; left: 0;
53
- transform: translateX(-100%);
54
- background-image: linear-gradient(
55
- 90deg,
56
- rgba(0, 0, 0, 0) 0%,
57
- rgba(0, 0, 0, 0.02) 20%,
58
- rgba(0, 0, 0, 0.06) 60%,
59
- rgba(0, 0, 0, 0) 100%
60
- );
61
- animation: tt-shimmer 1.6s infinite;
62
- content: '';
63
- }
64
- .dark .tt-shimmer-bar::after {
65
- background-image: linear-gradient(
66
- 90deg,
67
- rgba(255, 255, 255, 0) 0%,
68
- rgba(255, 255, 255, 0.02) 20%,
69
- rgba(255, 255, 255, 0.06) 60%,
70
- rgba(255, 255, 255, 0) 100%
71
- );
72
- }
73
- `;function Xe({variant:a="modal"}){const r="rounded bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar",i=a==="page";return e.jsxs("div",{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:Ze}}),i?e.jsxs("div",{className:"flex items-start gap-5 px-6 sm:px-8 pt-8 pb-7 animate-fade-in",children:[e.jsx("div",{className:"h-[68px] w-[68px] rounded-full bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-start justify-between gap-4 pt-0.5",children:[e.jsxs("div",{className:"min-w-0 space-y-2.5",children:[e.jsx("div",{className:c(r,"h-7 w-48")}),e.jsx("div",{className:c(r,"h-3.5 w-32")})]}),e.jsxs("div",{className:"shrink-0 space-y-1.5 flex flex-col items-end",children:[e.jsx("div",{className:c(r,"h-2.5 w-8")}),e.jsx("div",{className:c(r,"h-7 w-12")})]})]})]}):e.jsxs("div",{className:"flex items-start gap-4 px-6 pt-6 pb-5 border-b border-oai-gray-200/80 dark:border-oai-gray-800/60 animate-fade-in",children:[e.jsx("div",{className:"h-14 w-14 rounded-full bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2 pt-1",children:[e.jsx("div",{className:c(r,"h-4 w-40")}),e.jsx("div",{className:c(r,"h-3 w-56")})]}),e.jsx("div",{className:c(r,"h-4 w-4 shrink-0 mt-1")})]}),e.jsxs("div",{className:c("space-y-6",i?"px-6 sm:px-8 pt-6 pb-8 border-t border-oai-gray-200/80 dark:border-oai-gray-800/60":"px-6 py-5"),children:[e.jsx("div",{className:"grid grid-cols-4 gap-x-6 gap-y-4",children:Array.from({length:4}).map((t,s)=>e.jsxs("div",{children:[e.jsx("div",{className:c(r,"h-6 w-20")}),e.jsx("div",{className:c(r,"mt-2 h-3 w-14")})]},s))}),e.jsx("div",{className:"space-y-3 border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:Array.from({length:3}).map((t,s)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-3 w-24")}),e.jsx("div",{className:c(r,"h-3 w-44")})]},s))}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(r,"h-3 w-44 mb-4")}),e.jsx("div",{className:"grid grid-cols-[repeat(52,1fr)] gap-[2px]",children:Array.from({length:364}).map((t,s)=>e.jsx("div",{className:"aspect-square rounded-[2px] bg-oai-gray-200/40 dark:bg-oai-gray-800/30 tt-shimmer-bar"},s))})]}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(r,"h-3 w-28 mb-3")}),e.jsx("div",{className:"space-y-2.5",children:Array.from({length:5}).map((t,s)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-4 w-4")}),e.jsx("div",{className:c(r,"h-3 w-16")}),e.jsx("div",{className:c(r,"h-[3px] flex-1")}),e.jsx("div",{className:c(r,"h-3 w-12")})]},s))})]})]})]})}function K(a){if(!a)return null;const r=String(a).match(/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})/i);return r?r[1]:null}function T({children:a}){return e.jsx("h3",{className:"text-[11px] uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400 mb-3",children:a})}function P({value:a,label:r,title:i}){return e.jsxs("div",{children:[e.jsx("div",{title:i,className:"text-2xl font-black tabular-nums tracking-tight leading-none text-oai-black dark:text-white",style:{fontFamily:'"DIN Alternate-Bold", "DIN Alternate", "DIN Condensed-Bold", "Impact", -apple-system, sans-serif',fontWeight:900},children:a}),e.jsx("div",{className:"mt-1.5 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:r})]})}function $({label:a,children:r}){return e.jsxs("div",{className:"flex items-baseline gap-3 text-sm",children:[e.jsx("dt",{className:"shrink-0 w-28 whitespace-nowrap text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"min-w-0 flex-1 text-oai-gray-900 dark:text-oai-gray-100 tabular-nums truncate flex items-baseline gap-2 flex-wrap",children:r})]})}function Ye({user:a,onClose:r}){const i=K(a?.github_url);return e.jsxs("div",{className:"flex items-center gap-4 px-6 pt-6 pb-5 border-b border-oai-gray-200/80 dark:border-oai-gray-800/60",children:[e.jsx(Z,{avatarUrl:a?.avatar_url,displayName:a?.display_name||"",seed:a?.user_id||a?.display_name,size:"lg",className:"shrink-0 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:a?.display_name||"—"}),a?.rank?e.jsx("span",{className:c("shrink-0 inline-flex items-center px-2 py-0.5 rounded text-xs font-bold font-mono uppercase tracking-wider border shadow-sm",a.rank===1&&"bg-amber-500/10 text-amber-600 border-amber-500/20 dark:text-amber-400 dark:bg-amber-400/10",a.rank===2&&"bg-slate-500/10 text-slate-600 border-slate-500/20 dark:text-slate-400 dark:bg-slate-400/10",a.rank===3&&"bg-orange-500/10 text-orange-700 border-orange-500/20 dark:text-orange-400 dark:bg-orange-400/10",a.rank>3&&"bg-oai-gray-100 dark:bg-oai-gray-900/60 text-oai-gray-500 dark:text-oai-gray-400 border-oai-gray-200/60 dark:border-oai-gray-800"),children:o("leaderboard.profile_modal.rank",{rank:a.rank})}):null]}),i&&e.jsxs("a",{href:a.github_url,target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-flex items-center gap-1 text-[12px] text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-200 transition-colors",children:[e.jsx(L,{provider:"GITHUB",size:11}),e.jsxs("span",{children:["@",i]})]})]}),a?.user_id&&e.jsx("div",{className:"shrink-0 flex items-center justify-center",children:e.jsx(q,{userId:a.user_id})}),r&&e.jsx("button",{type:"button",onClick:r,className:"shrink-0 -mr-1 -mt-1 flex h-8 w-8 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/50 transition-colors group","aria-label":o("leaderboard.profile_modal.close"),children:e.jsx(fe,{size:16,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:rotate-90 group-active:scale-90"})})]})}function qe({user:a,topBadge:r}){const i=K(a?.github_url),t=Number(a?.rank)||0,s=t===1?"text-amber-500 dark:text-amber-400":t===2?"text-slate-500 dark:text-slate-300":t===3?"text-orange-600 dark:text-orange-400":"text-oai-gray-400 dark:text-oai-gray-500";return e.jsxs("div",{className:"flex items-center gap-5 px-6 sm:px-8 pt-8 pb-7",children:[e.jsx(He,{badge:r,avatarUrl:a?.avatar_url,displayName:a?.display_name||"",seed:a?.user_id||a?.display_name,size:"xl",className:"shrink-0 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 rounded-full"}),e.jsxs("div",{className:"min-w-0 flex-1 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"truncate text-2xl sm:text-[28px] font-semibold tracking-tight leading-tight text-oai-black dark:text-white",children:a?.display_name||"—"}),a?.user_id&&e.jsx(q,{userId:a.user_id})]}),i?e.jsxs("a",{href:a.github_url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white transition-colors",children:[e.jsx(L,{provider:"GITHUB",size:13}),e.jsxs("span",{children:["@",i]})]}):null]}),t?e.jsxs("div",{className:"shrink-0 text-right leading-none",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-oai-gray-400 dark:text-oai-gray-500",children:o("leaderboard.profile.hero.rank_label")}),e.jsx("div",{className:c("mt-1.5 text-3xl font-black tabular-nums tracking-tight",s),children:o("leaderboard.profile_modal.rank",{rank:t})})]}):null]})]})}function Ke({data:a}){const{formatTokens:r,formatTokensTooltip:i}=G(),t=Array.isArray(a)?a:[];return t.length===0?e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:o("leaderboard.profile_modal.providers.none")}):e.jsx("ul",{className:"space-y-2",children:t.map(s=>{const l=Math.max(0,Math.min(1,Number(s?.percent)||0));return e.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[e.jsx("span",{className:"shrink-0 inline-flex items-center justify-center w-4 h-4",children:e.jsx(L,{provider:String(s.source).toUpperCase(),size:14})}),e.jsx("span",{className:"w-20 shrink-0 text-oai-gray-700 dark:text-oai-gray-300",children:Ne(s.source)}),e.jsx("span",{className:"flex-1 h-[3px] rounded-full bg-oai-gray-200/60 dark:bg-oai-gray-800/80 overflow-hidden",children:e.jsx("span",{className:"block h-full bg-oai-brand-500 dark:bg-oai-brand-400",style:{width:`${(l*100).toFixed(1)}%`}})}),e.jsx("span",{title:i(s.total_tokens),className:"shrink-0 w-14 text-right tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:r(s.total_tokens)}),e.jsxs("span",{className:"shrink-0 w-10 text-right tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:[(l*100).toFixed(0),"%"]})]},s.source)})})}function O({icon:a,label:r,value:i}){const[t,s]=h.useState(!1),l=async()=>{await ve(i)&&(s(!0),setTimeout(()=>s(!1),1600))};return e.jsxs("button",{type:"button",onClick:l,className:c("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium transition-colors",t?"border-emerald-500/30 text-emerald-600 dark:text-emerald-400 bg-emerald-500/[0.06]":"border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-300 hover:text-oai-gray-900 dark:hover:text-oai-gray-100 hover:border-oai-gray-300 dark:hover:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/40"),children:[t?e.jsx(De,{size:13,strokeWidth:2,"aria-hidden":!0}):e.jsx(a,{size:13,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:t?o("leaderboard.profile_modal.badge.copied"):r})]})}function Ve({data:a,currency:r,rate:i,onClose:t,variant:s="modal"}){const{formatTokens:l,formatTokensTooltip:g}=G(),{user:n,totals:x,streak:u,best_day:f,models:S,by_provider:M,heatmap:z,period:D}=a,j=s==="page",N=h.useMemo(()=>Ge(z),[z]),C=S?.favorite?.model_name,y=Number(S?.count)||0,k=Array.isArray(a.badges)?a.badges:[],[_,w]=h.useState(null),d=E(),m=!!(d?.user?.id&&n?.user_id&&d.user.id===n.user_id),p=n?.user_id?`https://www.tokentracker.cc/u/${n.user_id}`:null,b=n?.user_id?`[![My AI coding usage](${me()}/functions/tokentracker-embed-svg?user_id=${n.user_id}&theme=dark)](${p}?ref=readme)`:null;return e.jsxs(e.Fragment,{children:[j?e.jsx(qe,{user:n,topBadge:Ce(k)}):e.jsx(Ye,{user:n,onClose:t}),e.jsxs("div",{className:c("space-y-6",j?"px-6 sm:px-8 pt-6 pb-8 border-t border-oai-gray-200/80 dark:border-oai-gray-800/60":"flex-1 min-h-0 overflow-y-auto oai-scrollbar px-6 py-5"),children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-x-6 gap-y-4",children:[e.jsx(P,{value:l(x?.total_tokens),title:g(x?.total_tokens),label:o("leaderboard.profile_modal.stat.total_tokens")}),e.jsx(P,{value:H(x?.estimated_cost_usd,r,i),label:o("leaderboard.profile_modal.stat.total_cost")}),e.jsx(P,{value:String(x?.active_days??0),label:o("leaderboard.profile_modal.stat.active_days")}),e.jsx(P,{value:H(x?.avg_per_day_usd,r,i),label:o("leaderboard.profile_modal.stat.avg_per_day")})]}),e.jsxs("dl",{className:"space-y-2 border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsxs($,{label:o("leaderboard.profile_modal.streak.current"),children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30",children:o("leaderboard.profile_modal.streak.days",{count:u?.current_days??0})}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["(max ",u?.longest_days??0,")"]})]}),e.jsx($,{label:o("leaderboard.profile_modal.best_day.title"),children:f?e.jsxs(e.Fragment,{children:[e.jsx("span",{title:g(f.total_tokens),className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30",children:l(f.total_tokens)}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["on ",f.date]})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:o("leaderboard.profile_modal.best_day.none")})}),e.jsx($,{label:o("leaderboard.profile_modal.models.favorite"),children:C?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30 truncate max-w-[200px] inline-block align-bottom",children:C}),y>1&&e.jsx("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:o("leaderboard.profile_modal.models.count",{count:y})})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:o("leaderboard.profile_modal.models.none")})})]}),(m||k.some(v=>(v?.tier||0)>=1))&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(T,{children:o("achievements.section.title")}),j?e.jsx(Ie,{achievements:k,isOwn:m&&!!a.badges_include_unearned,scope:"cloud",onSelect:w}):e.jsx(Oe,{badges:k,isOwn:m&&!!a.badges_include_unearned,onSelect:w})]}),N&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(T,{children:o("leaderboard.profile_modal.heatmap.title")}),e.jsx("div",{className:"min-w-0",children:e.jsx(je,{heatmap:N,hideLegend:!0,embedded:!0})})]}),e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(T,{children:o("leaderboard.profile_modal.providers.title")}),e.jsx(Ke,{data:M})]}),n?.user_id&&(t||m)&&e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-4 flex flex-wrap items-center justify-between gap-x-4 gap-y-3",children:[t&&(xe()?e.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",onClick:t,className:"group inline-flex items-center gap-1 text-xs font-medium text-oai-gray-700 hover:text-oai-gray-950 dark:text-oai-gray-300 dark:hover:text-oai-white transition-colors",children:[e.jsx("span",{children:o("leaderboard.profile_modal.view_full")}),e.jsx(B,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]}):e.jsxs(ge,{to:`/u/${n.user_id}`,onClick:t,className:"group inline-flex items-center gap-1 text-xs font-medium text-oai-gray-700 hover:text-oai-gray-950 dark:text-oai-gray-300 dark:hover:text-oai-white transition-colors",children:[e.jsx("span",{children:o("leaderboard.profile_modal.view_full")}),e.jsx(B,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]})),m&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{icon:Pe,label:o("leaderboard.profile_modal.badge.copy_url"),value:p}),e.jsx(O,{icon:Re,label:o("leaderboard.profile_modal.badge.copy"),value:b})]})]})]}),_&&e.jsx(W.Suspense,{fallback:null,children:e.jsx(Ee,{badge:_,onClose:()=>w(null)})})]})}function Qe({userId:a,period:r,accessToken:i,enabled:t=!0}){const[s,l]=h.useState({loading:!1,error:null,data:null}),g=h.useMemo(()=>ne(),[]),n=h.useMemo(()=>le(),[]);return h.useEffect(()=>{if(!t||!a)return;let x=!0;return l({loading:!0,error:null,data:null}),(async()=>{try{const u=i?await de(i):null;if(!x)return;const f=await ce({accessToken:u,userId:a,period:r||"week",timeZone:g,tzOffsetMinutes:n});if(!x)return;l({loading:!1,error:null,data:f})}catch(u){if(!x)return;u?.status===404?l({loading:!1,error:null,data:null}):l({loading:!1,error:u?.message||String(u),data:null})}})(),()=>{x=!1}},[t,a,r,i,g,n]),s}function ka({isOpen:a,onClose:r,userId:i,period:t,accessToken:s}){const{currency:l,rate:g}=_e(),n=Qe({userId:i,period:t,accessToken:s,enabled:a});return e.jsx(Te,{open:a,onOpenChange:x=>{x||r?.()},children:e.jsxs($e,{children:[e.jsx(Le,{className:"cost-modal-backdrop"}),e.jsx(Be,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:e.jsxs(Ue,{className:c("cost-modal-popup","relative w-full max-w-[540px] max-h-[calc(100vh-2rem)] flex flex-col","rounded-2xl bg-white dark:bg-oai-gray-950","shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)]","ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden","dark:border-t dark:border-white/[0.08]"),children:[e.jsx(Fe,{render:e.jsx("h2",{className:"sr-only"}),children:n.data?.user?.display_name||o("leaderboard.profile_modal.loading")}),n.loading&&e.jsx(Xe,{}),!n.loading&&n.error&&e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-[280px]",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:o("leaderboard.profile_modal.error")})}),!n.loading&&!n.error&&!n.data&&e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-[280px]",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:o("leaderboard.profile_modal.empty")})}),!n.loading&&!n.error&&n.data&&e.jsx(pe,{mode:he.COMPACT,children:e.jsx(Ve,{data:n.data,currency:l,rate:g,onClose:r})})]})})]})})}export{ka as LeaderboardProfileModal,Ve as ProfileContent,Xe as ProfileSkeleton,Qe as useLeaderboardProfileData};
@@ -1 +0,0 @@
1
- import{q as re,J as ue,a as me,r as o,a5 as xe,c as a,j as e,e as h}from"./__vite-browser-external-Cj9D7QBh.js";const ae={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};ae.node;const he=re(ae);const te={name:"mail",size:24,node:[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]};te.node;const be=re(te),fe=e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1Z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23Z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18A10.96 10.96 0 0 0 1 12c0 1.77.42 3.44 1.18 4.93l3.66-2.84Z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53Z",fill:"#EA4335"})]}),pe=e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12Z"})}),ye={google:fe,github:pe},we={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",apple:"Apple"};function ke(i){return we[i]||String(i||"").replace(/-/g," ")}function ve(i){if(typeof i=="string"&&i.trim())return i.trim();if(i&&typeof i=="object"){if(typeof i.token=="string"&&i.token.trim())return i.token.trim();if(typeof i.otp=="string"&&i.otp.trim())return i.otp.trim()}return""}function Ne({title:i,subtitle:D,className:oe="",onSuccess:S,hideLogo:H=!1,initialMode:p="signin",tokenFromUrl:P="",initialEmail:y="",initialCode:v=""}){ue();const{enabled:w,signedIn:j,refreshUser:E,signInWithPassword:G,signUp:Z,signInWithOAuth:z,getPublicAuthConfig:T,sendResetPasswordEmail:V,exchangeResetPasswordToken:$,resetPassword:U}=me(),[n,u]=o.useState(p),[c,k]=o.useState(y),[m,N]=o.useState(""),[A,L]=o.useState(""),[q,se]=o.useState(""),[F,W]=o.useState(v),[_,x]=o.useState(!1),[J,s]=o.useState(null),[C,b]=o.useState(null),[M,O]=o.useState(!1),[ie,ne]=o.useState(!!(p!=="signin"||y)),[R,K]=o.useState(!0),[I,Q]=o.useState([]),[X,le]=o.useState(8);o.useEffect(()=>{p&&u(p)},[p]),o.useEffect(()=>{y&&k(y)},[y]),o.useEffect(()=>{v&&W(v)},[v]),o.useEffect(()=>{if(!w)return;let r=!0;return K(!0),(async()=>{const{data:t,error:l}=await T();if(r){if(l||!t)Q(["google","github"]);else{const d=Array.isArray(t.oAuthProviders)?t.oAuthProviders:[],f=Array.isArray(t.customOAuthProviders)?t.customOAuthProviders:[];Q([...d,...f]),typeof t.passwordMinLength=="number"&&t.passwordMinLength>0&&le(t.passwordMinLength)}K(!1)}})(),()=>{r=!1}},[w,T]),o.useEffect(()=>{j&&S&&S()},[j,S]);const Y=o.useCallback(()=>typeof window>"u"?"":xe()?`${window.location.origin}/auth/callback`:`${window.location.origin}/`,[]),ee=o.useMemo(()=>typeof window>"u"?"/reset-password":`${window.location.origin}/reset-password`,[]),B=o.useCallback(async r=>{s(null),x(!0);try{const{error:t}=await z(r,Y());t&&s(t.message||String(t))}finally{x(!1)}},[z,Y]);o.useEffect(()=>{if(!w||R||j||typeof window>"u")return;const r=window.location.search;if(!r)return;const t=new URLSearchParams(r),l=t.get("native")==="1",d=t.get("provider");l&&d&&[...I].includes(d)&&B(d)},[w,R,j,I,B]);const de=o.useCallback(async r=>{r.preventDefault(),s(null),x(!0);try{if(n==="signup"){const{data:l,error:d}=await Z({email:c.trim(),password:m,name:q.trim()||void 0});if(d){s(d.message||String(d));return}if(l?.requireEmailVerification){b(a("login.verify_email_pending")),u("signin");return}await E();return}const{error:t}=await G({email:c.trim(),password:m});if(t){s(t.message||String(t));return}await E()}finally{x(!1)}},[n,c,m,q,Z,G,E]),ce=o.useCallback(async r=>{r.preventDefault(),s(null),x(!0);try{const t=c.trim(),{error:l}=await V({email:t,redirectTo:ee});if(l){s(l.message||String(l));return}k(t),b(a("reset_password.request.sent")),u("reset_confirm")}finally{x(!1)}},[c,ee,V]),ge=o.useCallback(async r=>{if(r.preventDefault(),s(null),m!==A){s(a("reset_password.error.password_mismatch"));return}x(!0);try{let t=P;if(!t){const{data:d,error:f}=await $({email:c.trim(),code:F.trim()});if(f){s(f.message||String(f));return}if(t=ve(d),!t){s(a("reset_password.error.missing_token"));return}}const{error:l}=await U({newPassword:m,otp:t});if(l){s(l.message||String(l));return}O(!0),b(a("reset_password.success"))}finally{x(!1)}},[F,A,c,$,m,U,P]);if(!w)return null;const g=n==="reset_email"||n==="reset_confirm";return e.jsxs("div",{className:h("w-full bg-white dark:bg-oai-gray-950 p-6 transition-colors duration-200",oe),children:[g&&e.jsxs("button",{type:"button",onClick:()=>{u("signin"),b(null),s(null),O(!1),N(""),L("")},className:"flex items-center gap-1.5 text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors mb-4 focus:outline-none",children:[e.jsx(he,{className:"h-3.5 w-3.5"}),a("reset_password.back_to_sign_in")]}),e.jsxs("div",{className:h("mb-6",g?"text-left":"text-center"),children:[!H&&!g&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:28,height:28,className:"rounded-md"}),e.jsx("span",{className:"text-lg font-semibold text-oai-black dark:text-white font-oai tracking-tight",children:a("shared.app_name")})]}),e.jsx("h2",{className:h("text-sm font-semibold text-oai-black dark:text-white tracking-tight mb-1",(H||g)&&"text-base font-bold md:text-lg"),children:g?a("reset_password.title"):i||a("login_modal.subtitle")}),!g&&D&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px] mx-auto",children:D}),g&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px]",children:C&&n==="reset_confirm"&&!M?C:a("reset_password.subtitle")})]}),C&&(!g||M)&&e.jsx("div",{className:"mb-4 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900/50 px-3 py-2 text-xs text-oai-gray-700 dark:text-oai-gray-300",children:C}),J&&e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400 text-center",role:"alert",children:J}),n==="reset_email"&&e.jsxs("form",{onSubmit:ce,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email",type:"email",autoComplete:"email",required:!0,value:c,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.request.submit")})]}),n==="reset_confirm"&&(M?e.jsx("button",{type:"button",onClick:()=>{u("signin"),O(!1),b(null),s(null),N(""),L("")},className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors text-center shadow-sm",children:a("reset_password.success_cta")}):e.jsxs("form",{onSubmit:ge,className:"space-y-3",children:[!P&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email-confirm",type:"email",autoComplete:"email",required:!0,value:c,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-code",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.code")}),e.jsx("input",{id:"card-reset-code",type:"text",inputMode:"numeric",autoComplete:"one-time-code",required:!0,value:F,onChange:r=>W(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.new_password")}),e.jsx("input",{id:"card-reset-password",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:m,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.confirm_password")}),e.jsx("input",{id:"card-reset-password-confirm",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:A,onChange:r=>L(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.reset.submit")})]})),!g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2.5 mb-5",children:R?e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"}),e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"})]}):I.map(r=>e.jsxs("button",{type:"button",disabled:_,onClick:()=>B(r),className:h("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors disabled:opacity-50","flex items-center justify-center gap-2.5"),children:[ye[r]||null,a("login.oauth.continue",{provider:ke(r)})]},r))}),ie?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login_modal.divider_email")})})]}),e.jsxs("div",{className:"flex rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900/50 mb-4",children:[e.jsx("button",{type:"button",className:h("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",n==="signin"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{u("signin"),s(null)},children:a("login.tab.sign_in")}),e.jsx("button",{type:"button",className:h("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",n==="signup"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{u("signup"),s(null)},children:a("login.tab.sign_up")})]}),e.jsxs("form",{onSubmit:de,className:"space-y-3",children:[n==="signup"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.name")}),e.jsx("input",{id:"card-name",type:"text",autoComplete:"name",value:q,onChange:r=>se(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:a("login.field.name_placeholder")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-email",type:"email",autoComplete:"email",required:!0,value:c,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.password")}),e.jsx("input",{id:"card-password",type:"password",autoComplete:n==="signup"?"new-password":"current-password",required:!0,minLength:n==="signup"?X:void 0,value:m,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),n==="signup"&&e.jsx("p",{className:"mt-1 text-xs text-oai-gray-400 dark:text-oai-gray-600",children:a("login.password_hint",{min:String(X)})}),n==="signin"&&e.jsx("div",{className:"mt-1 text-right",children:e.jsx("button",{type:"button",onClick:()=>{u("reset_email"),s(null),b(null)},className:"text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white no-underline bg-transparent border-0 p-0 cursor-pointer focus:outline-none",children:a("login.forgot_password")})})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:n==="signup"?a("login.submit.sign_up"):a("login.submit.sign_in")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login.divider")})})]}),e.jsxs("button",{type:"button",onClick:()=>ne(!0),className:h("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors","flex items-center justify-center gap-2.5"),children:[e.jsx(be,{className:"h-[18px] w-[18px] text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75}),a("login_modal.continue_email")]})]})]})]})}export{Ne as L};
@@ -1 +0,0 @@
1
- import{u as s,a as c,r as l,j as e,X as d}from"./__vite-browser-external-Cj9D7QBh.js";import{m as o}from"./react-CfB5zBqR.js";import{L as m}from"./LoginCard-BiMyV2Uf.js";import{A as p}from"./index-D2g1tPGl.js";function b(){const{isOpen:i,closeLoginModal:a}=s(),{enabled:r}=c();return l.useEffect(()=>{if(!i)return;const t=n=>{n.key==="Escape"&&a()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[i,a]),r?e.jsx(p,{children:i&&e.jsxs(o.div,{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[e.jsx(o.div,{className:"absolute inset-0 bg-black/40 dark:bg-black/60",onClick:a,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}}),e.jsxs(o.div,{className:"relative w-full max-w-[420px] rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 shadow-2xl overflow-hidden",initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{duration:.2},onClick:t=>t.stopPropagation(),children:[e.jsx("button",{type:"button",onClick:a,className:"absolute right-4 top-4 z-10 text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",children:e.jsx(d,{className:"h-5 w-5"})}),e.jsx(m,{onSuccess:a,className:"p-6 bg-transparent"})]})]})}):null}export{b as LoginModal};
@@ -1 +0,0 @@
1
- import{f as p,h as w,a as v,r,c as s,j as e,L as y}from"./__vite-browser-external-Cj9D7QBh.js";import{L as j}from"./LoginCard-BiMyV2Uf.js";function N(i){const t=new URLSearchParams(i).get("next");return typeof t!="string"||t.length===0||!t.startsWith("/")||t.startsWith("//")?"/dashboard":t}function L(){const i=p(),[t,f]=w(),{enabled:n,loading:u,signedIn:x,refreshUser:g}=v(),c=r.useMemo(()=>N(t.toString()),[t]),[h,d]=r.useState(null);r.useEffect(()=>{const l=t.get("insforge_status"),a=t.get("insforge_type"),m=t.get("insforge_error");l==="success"&&a==="verify_email"?d(s("login.verify_email_success")):l==="error"&&a==="verify_email"&&m&&d(s("shared.error.prefix",{error:m}))},[t]);const o=r.useMemo(()=>t.get("native")==="1",[t]);r.useEffect(()=>{if(!(!n||u)&&x){if(o){window.location.href="/auth/native-callback";return}i(c,{replace:!0})}},[n,u,x,i,c,o]),r.useEffect(()=>{n&&g()},[n,g]),r.useEffect(()=>{if(o&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[o]);const b=r.useCallback(()=>{f(l=>{const a=new URLSearchParams(l);return a.delete("insforge_status"),a.delete("insforge_type"),a.delete("insforge_error"),a},{replace:!0}),d(null)},[f]);return n?e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:e.jsx(y,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 rounded",children:s("login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[h?e.jsxs("div",{className:"rounded-lg border border-oai-gray-800 bg-oai-gray-900/50 px-4 py-3 text-sm text-oai-gray-300 flex justify-between gap-3 items-start",role:"status",children:[e.jsx("span",{children:h}),e.jsx("button",{type:"button",onClick:b,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:s("login.dismiss")})]}):null,e.jsx("div",{className:"border border-oai-gray-900 bg-oai-gray-950 rounded-2xl overflow-hidden shadow-2xl",children:e.jsx(j,{hideLogo:!0,title:s("login.title"),subtitle:s("login.subtitle"),className:"p-8 bg-transparent",onSuccess:()=>{o?window.location.href="/auth/native-callback":i(c,{replace:!0})}})})]})})]}):e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:e.jsx(y,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:s("login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:e.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",children:s("login.cloud_only")})})]})}export{L as LoginPage};
@@ -1 +0,0 @@
1
- import{q as L,W as q,r as n,c as a,j as e,e as g,aj as le,ak as V,X as ne}from"./__vite-browser-external-Cj9D7QBh.js";import{u as de,T as $,S as ce}from"./Controls-BgQflA-3.js";import{P as pe}from"./ProviderIcon-BTYVbUti.js";import{u as me,p as xe,C as W,B as be,a as ue,b as ge}from"./use-pet-settings-DvaQ7XrL.js";import{C as A}from"./skins-Mc0sI20C.js";import{F}from"./FadeIn-DDF5PqTX.js";import{L as he}from"./link-2-Cg6bEvjQ.js";import{L as X}from"./loader-circle-Cd7h4LcE.js";import{Z as fe}from"./zap-Cqur2X5s.js";import{T as ye}from"./trash-D_PaPrXq.js";import{D as ke,a as ve,b as je,c as we,d as Ne,e as Ce}from"./DialogTitle-C8vpXqg8.js";import{D as Se}from"./DialogDescription-h6XMtzIU.js";import{D as Ie}from"./DialogClose-DUxjaRqf.js";import"./Card-dqzakOoX.js";import"./react-CfB5zBqR.js";import"./use-reduced-motion-Dg10dVuu.js";import"./composite-DO7_ilHE.js";import"./store-D-FZbBaC.js";const Y={name:"file-archive",size:24,node:[["path",{d:"M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5",key:"4pqfef"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 12v-1",key:"1ej8lb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M8 7V6",key:"1nbb54"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]]};Y.node;const Pe=L(Y);const Z={name:"monitor-up",size:24,node:[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]};Z.node;const De=L(Z);const G={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};G.node;const ze=L(G),v=[{id:"clawd",displayName:"Clawd",nameKey:"pet.character.clawd",spriteVersionNumber:1,custom:!1},{id:"bot",displayName:"Bot",nameKey:"pet.character.bot",spriteVersionNumber:1,custom:!1},{id:"sprout",displayName:"Sprout",nameKey:"pet.character.sprout",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/sprout/spritesheet.webp"},{id:"byte",displayName:"Byte",nameKey:"pet.character.byte",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/byte/spritesheet.webp"},{id:"ember",displayName:"Ember",nameKey:"pet.character.ember",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/ember/spritesheet.webp"}];async function P(t){const r=await t.json().catch(()=>null);if(!t.ok||r?.ok===!1)throw new Error(r?.error||`Pet request failed with HTTP ${t.status}`);return r}async function Te(){const t=await fetch("/functions/tokentracker-pets",{headers:{Accept:"application/json"},cache:"no-store"}),r=await P(t),o=new Set(Array.isArray(r.hiddenBuiltinIds)?r.hiddenBuiltinIds:[]);return[...v.filter(s=>!s.assetUrl||!o.has(s.id)),...Array.isArray(r.pets)?r.pets:[]]}async function O(t){const r=await q();return P(await fetch("/functions/tokentracker-pets",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...r},cache:"no-store",body:JSON.stringify(t)}))}function _e(t){return O({action:"install_url",url:t})}async function H(t){const r=await q();return P(await fetch("/api/pets/import",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/zip",...r},cache:"no-store",body:t}))}function Ae(t){return O({action:"remove",id:t})}async function Be(){const t=await fetch("/functions/tokentracker-pets?scope=codex",{headers:{Accept:"application/json"},cache:"no-store"}),r=await P(t);return{importable:Array.isArray(r.importable)?r.importable:[],codexDetected:r.codexDetected===!0}}function Le(t){return O({action:"import_codex",ids:t})}let B=v;function Oe(){const[t,r]=n.useState(B),[o,s]=n.useState(!0),[x,d]=n.useState(!1),b=n.useCallback(async()=>{s(!0);try{const m=await Te();return B=m,r(m),d(!0),m}catch{return B=v,r(v),d(!1),v}finally{s(!1)}},[]);return n.useEffect(()=>{b()},[b]),{pets:t,loading:o,available:x,refresh:b}}const Ee={clawd:"from-oai-amber-50 dark:from-orange-950/70",bot:"from-oai-brand-50 dark:from-teal-950/70",sprout:"from-oai-brand-100 dark:from-emerald-950/70",byte:"from-oai-gray-200 dark:from-slate-800/70",ember:"from-orange-100 dark:from-orange-950/80"};function Me(){const t=a("pet.import.subtitle"),r="codex-pets.net",o=t.indexOf(r);return o<0?t:e.jsxs(e.Fragment,{children:[t.slice(0,o),e.jsx("a",{href:"https://codex-pets.net",target:"_blank",rel:"noreferrer",className:"underline decoration-oai-gray-400 underline-offset-2 transition-colors hover:text-oai-black dark:decoration-oai-gray-500 dark:hover:text-white",children:r}),t.slice(o+r.length)]})}const j=[{id:"idle-living",labelKey:"pet.state.calm"},{id:"working-thinking",labelKey:"pet.state.focus"},{id:"working-juggling",labelKey:"pet.state.multitask"},{id:"working-wizard",labelKey:"pet.state.streak"},{id:"happy",labelKey:"pet.state.celebrate"},{id:"sleeping",labelKey:"pet.state.rest"}];function J({character:t,selected:r,onSelect:o,onRemove:s,removeDisabled:x}){const d=t.nameKey?a(t.nameKey):t.displayName;return e.jsxs("div",{className:"group relative",children:[e.jsxs("button",{type:"button",onClick:o,"aria-pressed":r,className:g("relative w-full overflow-hidden rounded-xl border p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",r?"border-oai-brand-500/40 bg-white dark:border-oai-brand-500/25 dark:bg-oai-gray-900/80":"border-oai-gray-200/80 bg-white/55 hover:border-oai-gray-400 dark:border-oai-gray-800 dark:bg-oai-gray-950/55 dark:hover:border-oai-gray-600"),children:[e.jsx("div",{className:g("absolute inset-0 bg-gradient-to-br to-transparent opacity-80 dark:opacity-55",Ee[t.id]||"from-oai-gray-200/80 dark:from-oai-gray-800/70")}),e.jsxs("div",{className:"relative flex items-center gap-2.5",children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center",children:e.jsx(W,{state:"idle-living",character:t.id,pet:t,size:44})}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-oai-black dark:text-white",children:d}),t.spriteVersionNumber===2?e.jsx("span",{className:"shrink-0 rounded border border-oai-gray-300/80 px-1 text-[9px] font-semibold text-oai-gray-500 dark:border-oai-gray-600 dark:text-oai-gray-400",children:a("pet.format.v2")}):null,r?e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-oai-brand-500","aria-hidden":!0}):null]})]})]}),s?e.jsx("button",{type:"button",disabled:x,onClick:s,"aria-label":`${a("pet.import.remove")} · ${d}`,className:g("absolute right-1.5 top-1.5 flex h-6 w-6 items-center justify-center rounded-md border border-oai-gray-200/90 bg-white/95 text-oai-gray-500 transition-opacity hover:text-red-600 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-40 dark:border-oai-gray-700 dark:bg-oai-gray-900/95 dark:text-oai-gray-400 dark:hover:text-red-400","opacity-0 group-hover:opacity-100"),children:e.jsx(ye,{className:"h-3 w-3","aria-hidden":!0})}):null]})}function Ke({value:t,onChange:r}){const o={auto:a("pet.bot.color.auto"),bleu:a("pet.bot.color.bleu"),turquoise:a("pet.bot.color.turquoise"),vert:a("pet.bot.color.vert"),ambre:a("pet.bot.color.ambre"),rose:a("pet.bot.color.rose"),violet:a("pet.bot.color.violet")};return e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-1.5 rounded-full border border-black/5 bg-white/65 px-2.5 py-1.5 backdrop-blur-md dark:border-white/10 dark:bg-black/20",role:"radiogroup","aria-label":a("pet.bot.color"),children:be.map(s=>{const x=(t||"auto")===s;return e.jsx("button",{type:"button",role:"radio","aria-checked":x,"aria-label":o[s],title:o[s],onClick:()=>r(s),className:g("h-4 w-4 rounded-full border transition-transform duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",x?"scale-125 border-oai-black shadow-sm dark:border-white":"border-black/15 hover:scale-110 dark:border-white/25"),style:s==="auto"?{background:`linear-gradient(135deg, ${A.get(ue).hex} 0 50%, ${A.get(ge).hex} 50% 100%)`}:{background:A.get(s)?.hex}},s)})})}function Re({pet:t,state:r,onStateChange:o,botColor:s,onBotColorChange:x}){const[d,b]=n.useState(null),m=n.useRef(null),h=j.find(function(l){return l.id===r}),c=a(h?.labelKey||"pet.state.calm");return e.jsxs("section",{className:"relative flex min-h-[400px] flex-col overflow-hidden bg-oai-gray-50 dark:bg-oai-gray-950 sm:min-h-[440px] lg:min-h-[480px]",onPointerMove:p=>{if(t?.spriteVersionNumber!==2||!m.current)return;const l=m.current.getBoundingClientRect(),w=p.clientX-(l.left+l.width/2),N=p.clientY-(l.top+l.height/2),y=(Math.atan2(w,-N)*180/Math.PI+360)%360;b(Math.round(y/22.5)%16)},onPointerLeave:()=>b(null),children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.16] dark:opacity-[0.12]",style:{backgroundImage:"radial-gradient(currentColor 0.7px, transparent 0.7px)",backgroundSize:"14px 14px"},"aria-hidden":!0}),e.jsxs("div",{className:"relative flex items-center justify-between gap-3 px-5 pt-5",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-oai-gray-500 dark:text-oai-gray-400",children:a("pet.preview.states")}),e.jsxs("div",{className:"flex items-center gap-2",children:[xe(t?.id)==="vector"?e.jsx(Ke,{value:s,onChange:x}):null,e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-black/5 bg-white/65 px-3 py-1.5 text-[11px] font-medium text-oai-gray-600 backdrop-blur-md dark:border-white/10 dark:bg-black/20 dark:text-oai-gray-300",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500","aria-hidden":!0}),c]})]})]}),e.jsx("div",{className:"relative flex flex-1 items-center justify-center px-6 py-5",children:e.jsx("div",{ref:m,className:"relative flex h-52 w-52 items-center justify-center sm:h-56 sm:w-56 lg:h-64 lg:w-64",children:e.jsx("div",{className:"origin-bottom lg:scale-[1.18]",children:e.jsx(W,{state:r,character:t?.id||"clawd",pet:t,size:190,lookDirectionIndex:d,botColor:s})})})}),e.jsx("div",{className:"relative border-t border-oai-gray-200/70 bg-white/85 px-3 py-2 dark:border-oai-gray-800 dark:bg-oai-gray-950/85",children:e.jsx("div",{className:"grid grid-cols-3 gap-1","aria-label":a("pet.preview.states"),children:j.map(p=>e.jsxs("button",{type:"button",onClick:()=>o(p.id),"aria-pressed":r===p.id,className:g("flex min-h-10 flex-col items-center justify-center gap-1 rounded-lg px-1.5 text-xs transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500",r===p.id?"font-semibold text-oai-black dark:text-white":"font-medium text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:[e.jsx("span",{children:a(p.labelKey)}),e.jsx("span",{className:g("h-1 w-1 rounded-full transition-colors duration-200",r===p.id?"bg-oai-black dark:bg-white":"bg-transparent"),"aria-hidden":!0})]},p.id))})})]})}function Ue({pets:t,busy:r,error:o,onImport:s,onClose:x}){const[d,b]=n.useState(()=>new Set),m=c=>b(p=>{const l=new Set(p);return l.has(c)?l.delete(c):l.add(c),l}),h=t.length!==0&&d.size===t.length;return e.jsx(ke,{open:!0,onOpenChange:c=>{!c&&!r&&x()},children:e.jsxs(ve,{children:[e.jsx(je,{className:"fixed inset-0 z-50 bg-black/15 backdrop-blur-md dark:bg-black/40 animate-tt-fade-in"}),e.jsx(we,{className:"fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6",children:e.jsxs(Ne,{className:"relative flex max-h-[86vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-oai-gray-200/50 bg-white/95 shadow-2xl backdrop-blur-2xl dark:border-white/10 dark:bg-oai-gray-900/95 animate-tt-modal",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-oai-gray-200/70 px-5 py-4 dark:border-oai-gray-800",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(Ce,{className:"text-base font-semibold",children:a("pet.codex.title")}),e.jsx(Se,{className:"mt-0.5 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:a("pet.codex.subtitle")})]}),e.jsx(Ie,{type:"button",disabled:r,"aria-label":a("pet.codex.close"),className:"shrink-0 rounded-full border border-oai-gray-200/60 p-1.5 text-oai-gray-500 transition-colors hover:text-oai-black disabled:opacity-40 dark:border-oai-gray-800/60 dark:text-oai-gray-400 dark:hover:text-white",children:e.jsx(ne,{size:16})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:[t.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-oai-gray-400 dark:text-oai-gray-500",children:a("pet.codex.empty")}):e.jsx("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-3",children:t.map(c=>e.jsx(J,{character:c,selected:d.has(c.id),onSelect:()=>m(c.id)},c.id))}),o?e.jsx("p",{role:"alert",className:"mt-3 text-xs text-red-600 dark:text-red-400",children:o}):null]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-oai-gray-200/70 px-5 py-3 dark:border-oai-gray-800",children:[e.jsx("button",{type:"button",disabled:r||t.length===0,onClick:()=>b(h?new Set:new Set(t.map(c=>c.id))),className:"text-xs font-medium text-oai-gray-500 underline-offset-2 hover:underline disabled:opacity-40 dark:text-oai-gray-400",children:a("pet.codex.select_all")}),e.jsxs("button",{type:"button",disabled:r||d.size===0,onClick:()=>s([...d]),className:"flex h-9 items-center gap-1.5 rounded-lg bg-oai-black px-4 text-xs font-semibold text-white transition-colors disabled:bg-oai-gray-200 disabled:text-oai-gray-400 dark:bg-white dark:text-black dark:disabled:bg-oai-gray-800 dark:disabled:text-oai-gray-500",children:[r?e.jsx(X,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,d.size>0?`${a("pet.codex.import")} · ${d.size}`:a("pet.codex.import")]})]})]})})]})})}function ot(){const{available:t,settings:r,setSetting:o}=me(),{pets:s,loading:x,available:d,refresh:b}=Oe(),[m,h]=n.useState(""),[c,p]=n.useState(""),[l,w]=n.useState(!1),[N,y]=n.useState([]),[Q,D]=n.useState(!1),[C,E]=n.useState(!1),[ee,z]=n.useState(""),[te,M]=n.useState("idle-living"),[K,ae]=n.useState(!0),k=r.character||"clawd",T=de(),R=T.settings?.menuBarIconStyle==="pet",re=s.find(i=>i.id===k)||s[0],S=l?{kind:"busy",text:a("pet.import.busy")}:c?{kind:"error",text:c}:null,U=N.length!==0;n.useEffect(()=>{!x&&s.length>0&&!s.some(i=>i.id===k)&&o("character","clawd")},[x,s,k,o]);async function I(i,u=a("pet.import.success")){w(!0),p("");try{const f=await i();await b(),le(),f?.pet?.id&&o("character",f.pet.id),V({title:u,timeout:4e3}),h("")}catch(f){p(f?.message||a("pet.import.failed"))}finally{w(!1)}}const _=n.useCallback(async()=>{if(!d){y([]);return}try{const i=await Be();y(i.importable)}catch{y([])}},[d]);n.useEffect(()=>{_()},[_]);async function ie(i){E(!0),z("");try{return await Le(i),await b(),await _(),V({title:a("pet.codex.imported"),timeout:4e3}),!0}catch(u){return z(u?.message||a("pet.import.failed")),!1}finally{E(!1)}}n.useEffect(()=>{if(!K)return;const i=window.setInterval(()=>{M(u=>{const f=j.findIndex(oe=>oe.id===u);return j[(f+1)%j.length].id})},5e3);return()=>window.clearInterval(i)},[K]);const se=[{value:"small",label:a("pet.size.small")},{value:"medium",label:a("pet.size.medium")},{value:"large",label:a("pet.size.large")}];return e.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:e.jsx("main",{className:"flex-1 pb-14 pt-8 sm:pt-10",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[e.jsx(F,{y:12,children:e.jsxs("header",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight sm:text-4xl",children:a("pet.page.title")}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:a("pet.page.subtitle")})]})}),e.jsx(F,{y:12,delay:.04,children:e.jsxs("div",{className:"overflow-hidden rounded-[28px] border border-oai-gray-200 bg-white/75 dark:border-oai-gray-800 dark:bg-oai-gray-900/60 lg:grid lg:grid-cols-[1.12fr_0.88fr]",children:[e.jsx(Re,{pet:re,state:te,onStateChange:i=>{ae(!1),M(i)},botColor:r.botColor,onBotColorChange:i=>o("botColor",i)}),e.jsxs("aside",{className:"flex flex-col border-t border-oai-gray-200 p-5 dark:border-oai-gray-800 lg:min-h-[480px] lg:border-l lg:border-t-0",children:[e.jsxs("section",{"aria-labelledby":"pet-character-title",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"pet-character-title",className:"text-sm font-semibold",children:a("pet.characters.title")}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:a("pet.characters.subtitle")})]}),e.jsx("div",{className:"mt-4 grid max-h-72 grid-cols-2 gap-2 overflow-y-auto pr-1 -mr-1",children:s.map(i=>e.jsx(J,{character:i,selected:k===i.id,onSelect:()=>o("character",i.id),removeDisabled:l,onRemove:d&&i.id!=="clawd"&&i.id!=="bot"?()=>I(async()=>(await Ae(i.id),k===i.id&&o("character","clawd"),null),a("pet.import.removed")):void 0},i.id))}),T.available?e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 rounded-xl border border-oai-gray-200/70 bg-oai-gray-50/60 px-3 py-2.5 dark:border-oai-gray-800 dark:bg-oai-gray-900/40",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold",children:a("pet.menubar.title")}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:a("pet.menubar.hint")})]}),e.jsx($,{checked:R,onChange:()=>T.setSetting("menuBarIconStyle",R?"clawd":"pet"),ariaLabel:a("pet.menubar.title")})]}):null]}),d?e.jsxs("section",{className:"mt-6 border-t border-oai-gray-200/70 pt-5 dark:border-oai-gray-800","aria-labelledby":"pet-import-title",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{className:"h-4 w-4 shrink-0 text-oai-gray-500","aria-hidden":!0}),e.jsx("h2",{id:"pet-import-title",className:"text-sm font-semibold",children:a("pet.import.title")})]}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:e.jsx(Me,{})}),e.jsxs("form",{className:"mt-3 flex gap-2",onSubmit:i=>{i.preventDefault(),!l&&m.trim()&&I(()=>_e(m))},children:[e.jsxs("label",{className:"relative flex min-w-0 flex-1 items-center",children:[e.jsx(he,{className:"pointer-events-none absolute left-3 h-3.5 w-3.5 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{value:m,onChange:i=>h(i.target.value),"aria-label":a("pet.import.url_label"),placeholder:"codex-pets.net/#/pets/…",className:"h-9 w-full rounded-lg border border-oai-gray-200 bg-white pl-9 pr-3 text-xs outline-none focus:border-oai-brand-500 dark:border-oai-gray-700 dark:bg-oai-gray-950"})]}),e.jsxs("button",{type:"submit",disabled:l||!m.trim(),className:"flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-oai-black px-3.5 text-xs font-semibold text-white transition-colors disabled:bg-oai-gray-200 disabled:text-oai-gray-400 dark:bg-white dark:text-black dark:disabled:bg-oai-gray-800 dark:disabled:text-oai-gray-500",children:[l?e.jsx(X,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,a("pet.import.add")]})]}),e.jsxs("div",{className:g("mt-2 grid gap-2",U?"grid-cols-2":"grid-cols-1"),children:[U?e.jsxs("button",{type:"button",disabled:l||C,onClick:()=>{z(""),D(!0)},className:g("flex h-9 cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-dashed border-oai-gray-300 text-xs font-medium text-oai-gray-500 transition-colors hover:border-oai-gray-500 hover:text-oai-black dark:border-oai-gray-600 dark:text-oai-gray-400 dark:hover:border-oai-gray-400 dark:hover:text-white",(l||C)&&"pointer-events-none opacity-40"),children:[e.jsx(pe,{provider:"codex",size:14,className:"fill-current"}),a("pet.codex.browse")]}):null,e.jsxs("label",{onDragOver:i=>i.preventDefault(),onDrop:i=>{if(i.preventDefault(),l)return;const u=i.dataTransfer?.files?.[0];u&&I(()=>H(u))},className:g("flex h-9 cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-dashed border-oai-gray-300 text-xs font-medium text-oai-gray-500 transition-colors hover:border-oai-gray-500 hover:text-oai-black dark:border-oai-gray-600 dark:text-oai-gray-400 dark:hover:border-oai-gray-400 dark:hover:text-white",l&&"pointer-events-none opacity-40"),children:[e.jsx(Pe,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("pet.import.zip"),e.jsx("input",{type:"file",accept:".zip,.codex-pet.zip,application/zip",className:"sr-only",disabled:l,onChange:i=>{const u=i.target.files?.[0];u&&I(()=>H(u)),i.target.value=""}})]})]}),S?e.jsx("p",{role:S.kind==="error"?"alert":"status",className:g("mt-2 text-xs",S.kind==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400"),children:S.text}):null,Q?e.jsx(Ue,{pets:N,busy:C,error:ee,onClose:()=>{C||D(!1)},onImport:async i=>{await ie(i)&&D(!1)}}):null]}):null,e.jsxs("section",{className:"mt-6 border-t border-oai-gray-200/70 pt-5 dark:border-oai-gray-800",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4 text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75,"aria-hidden":!0}),e.jsx("h2",{className:"text-sm font-semibold",children:a("pet.controls.title")})]}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"text-sm font-medium",children:a("pet.controls.show")}),e.jsx($,{checked:r.visible,onChange:()=>o("visible",!r.visible),disabled:!t,ariaLabel:a("pet.controls.show")})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"text-sm font-medium",children:a("pet.controls.size")}),e.jsx("div",{className:"shrink-0",children:e.jsx(ce,{options:se,value:r.size,onChange:i=>o("size",i),disabled:!t})})]})]})]}),t?null:e.jsxs("div",{className:"mt-6 flex gap-2 rounded-xl bg-oai-gray-100 p-3 text-xs leading-relaxed text-oai-gray-500 dark:bg-oai-gray-800/70 dark:text-oai-gray-400",children:[e.jsx(fe,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),a("pet.controls.native_only")]})]})]})})]})})})}export{ot as PetPage};
@@ -1 +0,0 @@
1
- import{r as S,bf as Ye,bg as Xe,bh as Ue,bi as Ve,bj as ce,bk as Ke,bl as ne,aL as pe,bm as Z,bn as ge,bo as me,bp as te,x as J,bq as Q,aJ as Ce,br as We,bs as Fe,aK as z,a6 as le,aE as de,aM as qe,bt as he,bu as ze,y as Qe,bv as $e,bw as Ee,j as X,aO as Je,aN as Ze,bx as et,by as tt,bz as nt,bA as ot,bB as st,v as rt,w as ke,bC as it,bD as Ie,aH as at,bE as ct,bF as lt,aI as ut,aG as ft,bG as dt}from"./__vite-browser-external-Cj9D7QBh.js";import{p as pt,c as gt}from"./store-D-FZbBaC.js";import{o as Te,q as we,r as mt,s as ve,v as oe,w as ht,h as Et,P as Tt,x as vt,j as Pt,k as Ct,l as St,m as bt,i as Rt,e as Ot,g as It,u as Mt,y as yt,z as xt,t as Ft,A as kt,I as wt,B as Ht,c as At,b as Lt,d as Dt,C as Bt,p as Nt}from"./composite-DO7_ilHE.js";import{t as jt,v as _t,w as Gt,x as Yt,y as Xt,z as Ut,A as Vt}from"./SelectItemText-CoTR0Uwm.js";function Kt(e,n){return n!=null&&!Te(n)?0:typeof e=="function"?e():e}function Pe(e,n,t){const a=Kt(e,t);return typeof a=="number"?a:a?.[n]}function Me(e){return typeof e=="function"?e():e}function He(e,n){return n||e==="click"||e==="mousedown"}function Wt(e){return e?.includes("mouse")&&e!=="mousedown"}function qt(e){const n=S.useCallback(a=>e===void 0?Ye:e.subscribeStore(a),[e]),t=S.useCallback(()=>e===void 0?void 0:e.store,[e]);return Xe.useSyncExternalStore(n,t,()=>e?.serverStore)}class Se{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new ce,this.restTimeout=new ce,this.handleCloseOptions=void 0}static create(){return new Se}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose}const ue=new WeakMap;function fe(e){if(!e.performedPointerEventsMutation)return;const n=e.pointerEventsScopeElement;n&&ue.get(n)===e&&(e.pointerEventsScopeElement?.style.removeProperty("pointer-events"),e.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),e.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),ue.delete(n)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Ae(e,n){const{scopeElement:t,referenceElement:a,floatingElement:r}=n,s=ue.get(t);s&&s!==e&&fe(s),fe(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=t,e.pointerEventsReferenceElement=a,e.pointerEventsFloatingElement=r,ue.set(t,e),t.style.pointerEvents="none",a.style.pointerEvents="auto",r.style.pointerEvents="auto"}function Le(e){const n=e.context.dataRef.current,t=Ue(()=>n.hoverInteractionState??Se.create()).current;return n.hoverInteractionState||(n.hoverInteractionState=t),Ve(n.hoverInteractionState.disposeEffect),n.hoverInteractionState}function zt(e,n={}){const{enabled:t=!0,closeDelay:a=0,nodeId:r}=n,s="rootStore"in e?e.rootStore:e,T=s.useState("open"),g=s.useState("floatingElement"),R=s.useState("domReferenceElement"),{dataRef:c}=s.context,u=we(),f=mt(),d=Le(s),N=Ke(),B=ne(()=>He(c.current.openEvent?.type,d.interactedInside)),l=ne(()=>Wt(c.current.openEvent?.type)),L=ne(()=>{fe(d)});pe(()=>{T||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,L())},[T,d,L]),S.useEffect(()=>L,[L]),pe(()=>{if(t&&T&&d.handleCloseOptions?.blockPointerEvents&&l()&&Z(R)&&g){const v=R,x=g,o=ge(g),k=u?.nodesRef.current.find(C=>C.id===f)?.context?.elements.floating;k&&(k.style.pointerEvents="");const A=d.pointerEventsScopeElement!==x?d.pointerEventsScopeElement:null,b=k!==x?k:null,m=d.handleCloseOptions?.getScope?.()??A??b??v.closest("[data-rootownerid]")??o.body;return Ae(d,{scopeElement:m,referenceElement:v,floatingElement:x}),()=>{L()}}},[t,T,R,g,d,l,u,f,L]),S.useEffect(()=>{if(!t)return;function v(){return!!(u&&f&&ve(u.nodesRef.current,f).length>0)}function x(C){const F=Pe(a,"close",d.pointerType),j=()=>{s.setOpen(!1,J(Q,C)),u?.events.emit("floating.closed",C)};F?d.openChangeTimeout.start(F,j):(d.openChangeTimeout.clear(),j())}function o(C){const F=Ce(C);if(!We(F)){d.interactedInside=!1;return}d.interactedInside=F?.closest("[aria-haspopup]")!=null}function k(){d.openChangeTimeout.clear(),N.clear(),u?.events.off("floating.closed",b),L()}function A(C){if(v()&&u){u.events.on("floating.closed",b);return}if(Fe(C.relatedTarget,s.context.triggerElements))return;const F=c.current.floatingContext?.nodeId??r,j=C.relatedTarget;if(!(u&&F&&Z(j)&&ve(u.nodesRef.current,F,!1).some(_=>z(_.context?.elements.floating,j)))){if(d.handler){d.handler(C);return}L(),l()&&!B()&&x(C)}}function b(C){!u||!f||v()||N.start(0,()=>{u.events.off("floating.closed",b),s.setOpen(!1,J(Q,C)),u.events.emit("floating.closed",C)})}const m=g;return me(m&&te(m,"mouseenter",k),m&&te(m,"mouseleave",A),m&&te(m,"pointerdown",o,!0),()=>{u?.events.off("floating.closed",b)})},[t,g,s,c,a,r,l,B,L,d,u,f,N])}const Qt={current:null};function $t(e,n={}){const{enabled:t=!0,delay:a=0,handleClose:r=null,mouseOnly:s=!1,restMs:T=0,move:g=!0,triggerElementRef:R=Qt,externalTree:c,isActiveTrigger:u=!0,getHandleCloseContext:f,isClosing:d,shouldOpen:N,guardStaleOpen:B=!1}=n,l="rootStore"in e?e.rootStore:e,{dataRef:L,events:v}=l.context,x=we(c),o=Le(l),k=S.useRef(!1),A=oe(r),b=oe(a),m=oe(T),C=oe(t),F=oe(N),j=oe(d),W=ne(()=>He(L.current.openEvent?.type,o.interactedInside)),_=ne(()=>F.current?.()!==!1),G=ne((I,h,M)=>{const E=l.context.triggerElements;if(E.hasElement(h))return!I||!z(I,h);if(!Z(M))return!1;const q=M;return E.hasMatchingElement(U=>z(U,q))&&(!I||!z(I,q))}),O=ne(()=>{if(!o.handler)return;ge(l.select("domReferenceElement")).removeEventListener("mousemove",o.handler),o.handler=void 0}),i=ne(()=>{fe(o)});return u&&(o.handleCloseOptions=r?.__options),S.useEffect(()=>O,[O]),S.useEffect(()=>{if(!t)return;function I(h){h.open?k.current=!1:(k.current=h.reason===Q,O(),o.openChangeTimeout.clear(),o.restTimeout.clear(),o.blockMouseMove=!0,o.restTimeoutPending=!1)}return v.on("openchange",I),()=>{v.off("openchange",I)}},[t,v,o,O]),S.useEffect(()=>{if(!t)return;function I(P,V=!0){const D=Pe(b.current,"close",o.pointerType);D?o.openChangeTimeout.start(D,()=>{l.setOpen(!1,J(Q,P)),x?.events.emit("floating.closed",P)}):V&&(o.openChangeTimeout.clear(),l.setOpen(!1,J(Q,P)),x?.events.emit("floating.closed",P))}const h=R.current??(u?l.select("domReferenceElement"):null);if(!Z(h))return;function M(P){if(o.openChangeTimeout.clear(),o.blockMouseMove=!1,s&&!Te(o.pointerType))return;const V=Me(m.current),D=Pe(b.current,"open",o.pointerType),w=Ce(P),p=P.currentTarget??null,H=l.select("domReferenceElement");let Y=p;if(Z(w)&&!l.context.triggerElements.hasElement(w)){for(const Oe of l.context.triggerElements.elements())if(z(Oe,w)){Y=Oe;break}}Z(p)&&Z(H)&&!l.context.triggerElements.hasElement(p)&&z(p,H)&&(Y=H);const K=Y==null?!1:G(H,Y,w),$=l.select("open"),ee=j.current?.()??l.select("transitionStatus")==="ending",be=!$&&ee&&k.current,je=!K&&Z(Y)&&Z(H)&&z(H,Y)&&be,_e=V>0&&!D,Ge=K&&($||be)||je,Re=!$||K;if(Ge){_()&&l.setOpen(!0,J(Q,P,Y));return}_e||(D?o.openChangeTimeout.start(D,()=>{Re&&_()&&l.setOpen(!0,J(Q,P,Y))}):Re&&_()&&l.setOpen(!0,J(Q,P,Y)))}function E(P){if(W()){i();return}O();const V=l.select("domReferenceElement"),D=ge(V);o.restTimeout.clear(),o.restTimeoutPending=!1;const w=L.current.floatingContext??f?.();if(Fe(P.relatedTarget,l.context.triggerElements))return;if(A.current&&w){l.select("open")||o.openChangeTimeout.clear();const H=R.current;o.handler=A.current({...w,tree:x,x:P.clientX,y:P.clientY,onClose(){i(),O(),C.current&&!W()&&H===l.select("domReferenceElement")&&I(P,!0)}}),D.addEventListener("mousemove",o.handler),o.handler(P);return}(o.pointerType!=="touch"||!z(l.select("floatingElement"),P.relatedTarget))&&I(P)}function q(P){z(h,P.relatedTarget)||(o.openChangeTimeout.clear(),o.restTimeout.clear(),o.restTimeoutPending=!1)}const U=B?te(h,"mouseout",q):void 0;return g?me(te(h,"mousemove",M,{once:!0}),te(h,"mouseenter",M),te(h,"mouseleave",E),U):me(te(h,"mouseenter",M),te(h,"mouseleave",E),U)},[O,i,L,b,l,t,A,o,u,G,W,s,g,m,R,x,C,f,j,_,B]),S.useMemo(()=>{if(!t)return;function I(h){o.pointerType=h.pointerType}return{onPointerDown:I,onPointerEnter:I,onMouseMove(h){const{nativeEvent:M}=h,E=h.currentTarget,q=l.select("domReferenceElement"),U=l.select("open"),P=G(q,E,h.target);if(s&&!Te(o.pointerType))return;if(U&&P&&o.handleCloseOptions?.blockPointerEvents){const w=l.select("floatingElement");if(w){const p=o.handleCloseOptions?.getScope?.()??E.ownerDocument.body;Ae(o,{scopeElement:p,referenceElement:E,floatingElement:w})}}const V=Me(m.current);if(U&&!P||V===0||!P&&o.restTimeoutPending&&h.movementX**2+h.movementY**2<2)return;o.restTimeout.clear();function D(){if(o.restTimeoutPending=!1,W())return;const w=l.select("open");!o.blockMouseMove&&(!w||P)&&_()&&l.setOpen(!0,J(Q,M,E))}o.pointerType==="touch"?le.flushSync(()=>{D()}):P&&U?D():(o.restTimeoutPending=!0,o.restTimeout.start(V,D))}}},[t,o,W,G,s,l,m,_])}const ye=.1,Jt=ye*ye,y=.5;function re(e,n,t,a,r,s){return a>=n!=s>=n&&e<=(r-t)*(n-a)/(s-a)+t}function ie(e,n,t,a,r,s,T,g,R,c){let u=!1;return re(e,n,t,a,r,s)&&(u=!u),re(e,n,r,s,T,g)&&(u=!u),re(e,n,T,g,R,c)&&(u=!u),re(e,n,R,c,t,a)&&(u=!u),u}function Zt(e,n,t){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function ae(e,n,t,a,r,s){const T=Math.min(t,r),g=Math.max(t,r),R=Math.min(a,s),c=Math.max(a,s);return e>=T&&e<=g&&n>=R&&n<=c}function en(e={}){const{blockPointerEvents:n=!1}=e,t=new ce,a=({x:r,y:s,placement:T,elements:g,onClose:R,nodeId:c,tree:u})=>{const f=T?.split("-")[0];let d=!1,N=null,B=null,l=typeof performance<"u"?performance.now():0;function L(x,o){const k=performance.now(),A=k-l;if(N===null||B===null||A===0)return N=x,B=o,l=k,!1;const b=x-N,m=o-B,C=b*b+m*m,F=A*A*Jt;return N=x,B=o,l=k,C<F}function v(){t.clear(),R()}return function(o){t.clear();const k=g.domReference,A=g.floating;if(!k||!A||f==null||r==null||s==null)return;const{clientX:b,clientY:m}=o,C=Ce(o),F=o.type==="mouseleave",j=z(A,C),W=z(k,C);if(j&&(d=!0,!F))return;if(W&&(d=!1,!F)){d=!0;return}if(F&&Z(o.relatedTarget)&&z(A,o.relatedTarget))return;function _(){return!!(u&&ve(u.nodesRef.current,c).length>0)}function G(){_()||v()}if(_())return;const O=k.getBoundingClientRect(),i=A.getBoundingClientRect(),I=r>i.right-i.width/2,h=s>i.bottom-i.height/2,M=i.width>O.width,E=i.height>O.height,q=(M?O:i).left,U=(M?O:i).right,P=(E?O:i).top,V=(E?O:i).bottom;if(f==="top"&&s>=O.bottom-1||f==="bottom"&&s<=O.top+1||f==="left"&&r>=O.right-1||f==="right"&&r<=O.left+1){G();return}let D=!1;switch(f){case"top":D=ae(b,m,q,O.top+1,U,i.bottom-1);break;case"bottom":D=ae(b,m,q,i.top+1,U,O.bottom-1);break;case"left":D=ae(b,m,i.right-1,V,O.left+1,P);break;case"right":D=ae(b,m,O.right-1,V,i.left+1,P);break}if(D)return;if(d&&!Zt(b,m,O)){G();return}if(!F&&L(b,m)){G();return}let w=!1;switch(f){case"top":{const p=M?y/2:y*4,H=M||I?r+p:r-p,Y=M?r-p:I?r+p:r-p,K=s+y+1,$=I||M?i.bottom-y:i.top,ee=I?M?i.bottom-y:i.top:i.bottom-y;w=ie(b,m,H,K,Y,K,i.left,$,i.right,ee);break}case"bottom":{const p=M?y/2:y*4,H=M||I?r+p:r-p,Y=M?r-p:I?r+p:r-p,K=s-y,$=I||M?i.top+y:i.bottom,ee=I?M?i.top+y:i.bottom:i.top+y;w=ie(b,m,H,K,Y,K,i.left,$,i.right,ee);break}case"left":{const p=E?y/2:y*4,H=E||h?s+p:s-p,Y=E?s-p:h?s+p:s-p,K=r+y+1,$=h||E?i.right-y:i.left,ee=h?E?i.right-y:i.left:i.right-y;w=ie(b,m,$,i.top,ee,i.bottom,K,H,K,Y);break}case"right":{const p=E?y/2:y*4,H=E||h?s+p:s-p,Y=E?s-p:h?s+p:s-p,K=r-y,$=h||E?i.left+y:i.right,ee=h?E?i.left+y:i.right:i.left+y;w=ie(b,m,K,H,K,Y,$,i.top,ee,i.bottom);break}}w?d||t.start(40,G):G()}};return a.__options={...e,blockPointerEvents:n},a}const De=S.createContext(void 0);function se(e){const n=S.useContext(De);if(n===void 0&&!e)throw new Error(de(47));return n}const tn={...pt,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class nn extends qe{constructor(n,t,a){const r=new Tt;super(on(n,r,t,a),sn(r),tn)}setOpen=(n,t)=>{const a=t.reason===Q,r=t.reason===he&&t.event.detail===0,s=!n&&(t.reason===ze||t.reason==null),T=ht(t),g=this.select("activeTriggerId");if(!n&&t.reason===Qe&&t.trigger==null&&g!=null&&(t.trigger=this.context.triggerElements.getById(g)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(n,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(n,t);const R=()=>{const u=Et(this.state,n,t.trigger,T());u.openChangeReason=t.reason,this.update(u)};a?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start($e,()=>{this.set("stickIfOpen",!1)}),le.flushSync(R)):R();let c;r?c="click":s?c="dismiss":t.reason===Ee&&(c="focus"),this.set("instantType",c)}}function on(e,n,t,a=!1){const r={...gt(n,t,a),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return r.open&&e?.mounted===void 0&&(r.mounted=!0),r}function sn(e){return{popupRef:S.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:S.createRef(),beforeContentFocusGuardRef:S.createRef(),stickIfOpenTimeout:new ce,triggerElements:e}}const xe=Je(function({props:n}){const{children:t,open:a,defaultOpen:r=!1,onOpenChange:s,onOpenChangeComplete:T,modal:g=!1,handle:R,triggerId:c,defaultTriggerId:u=null}=n,f=rn(R,{modal:g,open:r,openProp:a,activeTriggerId:u,triggerIdProp:c});f.useControlledProp("openProp",a),f.useControlledProp("triggerIdProp",c);const d=f.useState("open"),N=f.useState("mounted"),B=f.useState("payload");f.useContextCallback("onOpenChange",s),f.useContextCallback("onOpenChangeComplete",T),Pt(f,d),Ct(f);const{forceUnmount:l}=St(d,f,()=>{f.update({stickIfOpen:!0,openChangeReason:null})});f.useSyncedValues({modal:g}),S.useEffect(()=>{d||f.context.stickIfOpenTimeout.clear()},[f,d]),S.useImperativeHandle(n.actionsRef,()=>({unmount:l,close:()=>f.setOpen(!1,J(Ze))}),[l,f]);const L=d||N;return X.jsxs(De.Provider,{value:f,children:[R&&X.jsx(bt,{handle:R,store:f}),L&&X.jsx(an,{store:f,modal:g}),typeof t=="function"?t({payload:B}):t]})});function Tn(e){return se(!0)?X.jsx(xe,{props:e}):X.jsx(vt,{children:X.jsx(xe,{props:e})})}function rn(e,n){const t=Rt((a,r)=>new nn(n,a,r));return S.useEffect(()=>t.context.stickIfOpenTimeout.disposeEffect(),[t]),t}function an({store:e,modal:n}){const t=e.useState("floatingRootContext"),a=Ot(t,{outsidePressEvent:{mouse:n==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),r=a.reference,s=a.floating;return It(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:s}),null}const cn=300;function ln(e,n){const t=S.useRef(null);function a(s){le.flushSync(()=>{e.setOpen(!1,J(Ee,s.nativeEvent,s.currentTarget))}),ot(t.current)?.focus()}function r(s){const T=e.select("positionerElement");if(T&&et(s,T))e.context.beforeContentFocusGuardRef.current?.focus();else{le.flushSync(()=>{e.setOpen(!1,J(Ee,s.nativeEvent,s.currentTarget))});let g=tt(e.context.triggerFocusTargetRef.current||n.current);for(;g!==null&&z(T,g);){const R=g;if(g=nt(g),g===R)break}g?.focus()}}return{preFocusGuardRef:t,handlePreFocusGuardFocus:a,handleFocusTargetFocus:r}}const vn=st(function(n,t){const{render:a,className:r,style:s,disabled:T=!1,nativeButton:g=!0,handle:R,payload:c,openOnHover:u=!1,delay:f=cn,closeDelay:d=0,id:N,...B}=n,l=se(!0),v=qt(R)??l;if(!v)throw new Error(de(74));const x=Mt(N),o=v.useState("isTriggerActive",x),k=v.useState("floatingRootContext"),A=v.useState("isOpenedByTrigger",x),b=v.useState("triggerPopupId",x),m=S.useRef(null),{registerTrigger:C,isMountedByThisTrigger:F}=yt(x,m,v,{payload:c,disabled:T,openOnHover:u,closeDelay:d}),j=v.useState("openChangeReason"),W=v.useState("stickIfOpen"),_=v.useState("openMethod"),G=v.useState("focusManagerModal"),O=$t(k,{enabled:!T&&u&&(_!=="touch"||j!==he),mouseOnly:!0,move:!1,handleClose:en(),restMs:f,delay:{close:d},triggerElementRef:m,isActiveTrigger:o,isClosing:()=>v.select("transitionStatus")==="ending"}),i=jt(k,{stickIfOpen:W}),I=_t(()=>v.select("open"),H=>{v.set("openMethod",H)}),h=v.useState("triggerProps",F),{getButtonProps:M,buttonRef:E}=rt({disabled:T,native:g}),q={open(H){return H&&j===he?xt.open(H):Ft.open(H)}},{preFocusGuardRef:U,handlePreFocusGuardFocus:P,handleFocusTargetFocus:V}=ln(v,m),w=ke("button",n,{state:{disabled:T,open:A},ref:[E,t,C,m],props:[i.reference,O,h,I,{[it]:"",id:x,"aria-haspopup":"dialog","aria-expanded":A,"aria-controls":b},B,M],stateAttributesMapping:q}),p=X.jsx(S.Fragment,{children:w},x);return F&&!G?X.jsxs(S.Fragment,{children:[X.jsx(Ie,{ref:U,onFocus:P}),p,X.jsx(Ie,{ref:v.context.triggerFocusTargetRef,onFocus:V})]}):p}),Be=S.createContext(void 0);function un(){const e=S.useContext(Be);if(e===void 0)throw new Error(de(45));return e}const Pn=S.forwardRef(function(n,t){const{keepMounted:a=!1,...r}=n;return se().useState("mounted")||a?X.jsx(Be.Provider,{value:a,children:X.jsx(at,{ref:t,...r})}):null}),Ne=S.createContext(void 0);function fn(){const e=S.useContext(Ne);if(!e)throw new Error(de(46));return e}const Cn=S.forwardRef(function(n,t){const{render:a,className:r,style:s,anchor:T,positionMethod:g,side:R,align:c,sideOffset:u,alignOffset:f,collisionBoundary:d="clipping-ancestors",collisionPadding:N,arrowPadding:B,sticky:l,disableAnchorTracking:L=!1,collisionAvoidance:v=ct,...x}=n,o=se(),k=un(),A=kt(),b=o.useState("floatingRootContext"),m=o.useState("mounted"),C=o.useState("open"),F=o.useState("openChangeReason"),j=o.useState("activeTriggerElement"),W=o.useState("modal"),_=o.useState("openMethod"),G=o.useState("positionerElement"),O=o.useState("instantType"),i=o.useState("transitionStatus"),I=o.useState("adaptiveOrigin"),h=S.useRef(null),M=lt(G),E=Gt({anchor:T,floatingRootContext:b,positionMethod:g,mounted:m,side:R,sideOffset:u,align:c,alignOffset:f,arrowPadding:B,collisionBoundary:d,collisionPadding:N,sticky:l,disableAnchorTracking:L,keepMounted:k,nodeId:A,collisionAvoidance:v,adaptiveOrigin:I}),q=b.useState("domReferenceElement");pe(()=>{const w=q,p=h.current;if(w&&(h.current=w),p&&w&&w!==p){o.set("instantType",void 0);const H=new AbortController;return M(()=>{o.set("instantType","trigger-change")},H.signal),()=>{H.abort()}}},[q,M,o]);const U=W===!0&&F!==Q;Yt(C&&U,_==="touch",G,j);const P=o.useStateSetter("positionerElement"),V={open:C,side:E.side,align:E.align,anchorHidden:E.anchorHidden,instant:O},D=Xt(n,V,{styles:E.positionerStyles,transitionStatus:i,props:x,refs:[t,P],hidden:!m,inert:!C});return X.jsxs(Ne.Provider,{value:E,children:[m&&U&&X.jsx(wt,{inert:ut(!C),cutout:j}),X.jsx(Ht,{id:A,children:D})]})}),dn=S.createContext(void 0);function pn(){const[e,n]=S.useState(0),t=ne(()=>(n(r=>r+1),()=>{n(r=>Math.max(0,r-1))}));return{context:S.useMemo(()=>({register:t}),[t]),hasClosePart:e>0}}const Sn=S.forwardRef(function(n,t){const{render:a,className:r,style:s,initialFocus:T,finalFocus:g,...R}=n,c=se(),u=fn(),f=Ut()!=null,{context:d,hasClosePart:N}=pn(),B=c.useState("open"),l=c.useState("openMethod"),L=c.useState("instantType"),v=c.useState("transitionStatus"),x=c.useState("popupProps"),o=c.useState("titleElementId"),k=c.useState("descriptionElementId"),A=c.useState("modal"),b=c.useState("mounted"),m=c.useState("openChangeReason"),C=c.useState("activeTriggerElement"),F=c.useState("floatingRootContext"),j=F.useState("floatingId"),W=c.useState("disabled"),_=c.useState("openOnHover"),G=c.useState("closeDelay");ft({open:B,ref:c.context.popupRef,onComplete(){B&&c.context.onOpenChangeComplete?.(!0)}}),zt(F,{enabled:_&&!W,closeDelay:G});const O=T===void 0?At(c.context.popupRef):T,i=A!==!1&&N;c.useSyncedValue("focusManagerModal",i);const I=c.useStateSetter("popupElement"),h={open:B,side:u.side,align:u.align,instant:L,transitionStatus:v},M=ke("div",n,{state:h,ref:[t,c.context.popupRef,I],props:[x,{id:j,role:"dialog",...Dt,"aria-labelledby":o,"aria-describedby":k,onKeyDown(E){f&&Bt.has(E.key)&&E.stopPropagation()}},Vt(v),R],stateAttributesMapping:Nt});return X.jsx(Lt,{context:F,openInteractionType:l,modal:i,disabled:!b||m===Q,initialFocus:O,returnFocus:g,restoreFocus:"popup",previousFocusableElement:dt(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:X.jsx(dn.Provider,{value:d,children:M})})});export{Tn as P,vn as a,Pn as b,Cn as c,Sn as d};
@@ -1 +0,0 @@
1
- import{h as d,a as m,r as o,j as e,L as l,c as t}from"./__vite-browser-external-Cj9D7QBh.js";import{L as x}from"./LoginCard-BiMyV2Uf.js";function n(s,a){for(const i of a){const r=s.get(i);if(typeof r=="string"&&r.trim())return r.trim()}return""}function h(){const[s]=d(),{enabled:a}=m(),i=o.useMemo(()=>n(s,["otp","token","reset_token","insforge_token"]),[s]),r=o.useMemo(()=>n(s,["email"]),[s]),c=o.useMemo(()=>n(s,["code"]),[s]);return a?e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:e.jsx(l,{to:"/login",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 rounded",children:t("reset_password.back_to_sign_in")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsx("div",{className:"w-full max-w-md border border-oai-gray-900 bg-oai-gray-950 rounded-2xl overflow-hidden shadow-2xl",children:e.jsx(x,{hideLogo:!0,initialMode:i?"reset_confirm":"reset_email",tokenFromUrl:i,initialEmail:r,initialCode:c})})})]}):e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:e.jsx(l,{to:"/login",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:t("reset_password.back_to_sign_in")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:e.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",children:t("login.cloud_only")})})]})}export{h as ResetPasswordPage};
@@ -1 +0,0 @@
1
- import{q as Vo,bt as ko,r as a,bO as Pt,bk as bt,aJ as Wn,bV as Ho,E as dt,x as Ae,bm as Ee,cO as et,bG as Je,c3 as Qe,aS as Ie,cP as rn,c1 as Lt,c0 as Jt,cQ as _o,cR as Nn,cS as Bo,bK as sn,c7 as $n,cT as _t,cU as Qt,cV as yn,cW as Un,a6 as Wo,bL as No,bh as gt,aL as X,bP as zn,bM as $o,bl as te,cX as Rn,cY as zt,cZ as bn,bS as jt,bn as rt,aK as Ge,c_ as wn,c$ as St,bw as jn,bU as qn,d0 as Bt,d1 as Wt,d2 as Yn,d3 as cn,b_ as Uo,d4 as zo,d5 as Zt,d6 as jo,w as ct,c6 as qo,aE as ht,bf as ue,j as Re,aG as ln,aQ as en,aP as Yo,aT as Ko,aU as Xo,aV as Dt,aM as Go,bT as Jo,bI as Qo,v as Kn,d7 as Zo,aH as er,d8 as tr,aI as nr,bp as or,d9 as rr,aF as Xn,da as qt}from"./__vite-browser-external-Cj9D7QBh.js";import{o as Yt,D as Gn,r as Jn,F as sr,P as ir,q as Qn,v as De,E as cr,G as $e,H as Zn,a as eo,f as lr,u as ar,n as to,e as ur,d as fr,z as dr,I as pr,b as gr,C as mr}from"./composite-DO7_ilHE.js";const no={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};no.node;const Vi=Vo(no),mt=Math.min,ze=Math.max,Ft=Math.round,vt=Math.floor,je=e=>({x:e,y:e}),hr={left:"right",right:"left",bottom:"top",top:"bottom"};function oo(e,t,n){return ze(e,mt(t,n))}function Ze(e,t){return typeof e=="function"?e(t):e}function Pe(e){return e.split("-")[0]}function qe(e){return e.split("-")[1]}function an(e){return e==="x"?"y":"x"}function un(e){return e==="y"?"height":"width"}function Oe(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function fn(e){return an(Oe(e))}function xr(e,t,n){n===void 0&&(n=!1);const o=qe(e),r=fn(e),s=un(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Vt(i)),[i,Vt(i)]}function yr(e){const t=Vt(e);return[tn(e),t,tn(t)]}function tn(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Sn=["left","right"],vn=["right","left"],Rr=["top","bottom"],br=["bottom","top"];function wr(e,t,n){switch(e){case"top":case"bottom":return n?t?vn:Sn:t?Sn:vn;case"left":case"right":return t?Rr:br;default:return[]}}function Sr(e,t,n,o){const r=qe(e);let s=wr(Pe(e),n==="start",o);return r&&(s=s.map(i=>i+"-"+r),t&&(s=s.concat(s.map(tn)))),s}function Vt(e){const t=Pe(e);return hr[t]+e.slice(t.length)}function vr(e){var t,n,o,r;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(o=e.bottom)!=null?o:0,left:(r=e.left)!=null?r:0}}function ro(e){return typeof e!="number"?vr(e):{top:e,right:e,bottom:e,left:e}}function wt(e){const{x:t,y:n,width:o,height:r}=e;return{width:o,height:r,top:n,left:t,right:t+o,bottom:n+r,x:t,y:n}}function yt(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function Cr(e,t={}){const{enabled:n=!0,event:o="click",toggle:r=!0,ignoreMouse:s=!1,stickIfOpen:i=!0,touchOpenDelay:c=0,reason:l=ko}=t,f="rootStore"in e?e.rootStore:e,p=f.context.dataRef,d=a.useRef(void 0),m=Pt(),u=bt(),h=a.useMemo(()=>{function y(g,S,C,x){const b=Ae(l,S,C);g&&x==="touch"&&c>0?u.start(c,()=>{f.setOpen(!0,b)}):f.setOpen(g,b)}function R(g,S,C){const x=p.current.openEvent,b=f.select("domReferenceElement")!==S;return g&&b||!g||!r?!0:x&&i?!C(x.type):!1}return{onPointerDown(g){d.current=Yt(g.pointerType,!0)&&Gn(g.nativeEvent)?"virtual":g.pointerType},onMouseDown(g){const S=d.current,C=g.nativeEvent,x=f.select("open");if(g.button!==0||o==="click"||Yt(S,!0)&&s)return;const b=R(x,g.currentTarget,v=>v==="click"||v==="mousedown"),E=Wn(C);if(Ho(E)){y(b,C,E,S);return}const w=g.currentTarget;m.request(()=>{y(b,C,w,S)})},onClick(g){if(o==="mousedown-only")return;const S=d.current;if(o==="mousedown"&&S){d.current=void 0;return}if(Yt(S,!0)&&s)return;const C=f.select("open"),x=R(C,g.currentTarget,b=>b==="click"||b==="mousedown"||b==="keydown"||b==="keyup");y(x,g.nativeEvent,g.currentTarget,S)},onKeyDown(){d.current=void 0}}},[p,o,s,l,f,i,r,m,u,c]);return a.useMemo(()=>n?{reference:h}:dt,[n,h])}function Cn(e,t,n){let{reference:o,floating:r}=e;const s=Oe(t),i=fn(t),c=un(i),l=Pe(t),f=s==="y",p=o.x+o.width/2-r.width/2,d=o.y+o.height/2-r.height/2,m=o[c]/2-r[c]/2;let u;switch(l){case"top":u={x:p,y:o.y-r.height};break;case"bottom":u={x:p,y:o.y+o.height};break;case"right":u={x:o.x+o.width,y:d};break;case"left":u={x:o.x-r.width,y:d};break;default:u={x:o.x,y:o.y}}const h=qe(t);return h&&(u[i]+=m*(h==="end"?1:-1)*(n&&f?-1:1)),u}async function Er(e,t){var n;t===void 0&&(t={});const{x:o,y:r,platform:s,rects:i,elements:c,strategy:l}=e,{boundary:f="clippingAncestors",rootBoundary:p="viewport",elementContext:d="floating",altBoundary:m=!1,padding:u=0}=Ze(t,e),h=ro(u),R=c[m?d==="floating"?"reference":"floating":d],g=wt(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(R)))==null||n?R:R.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:f,rootBoundary:p,strategy:l})),S=d==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),x=await(s.isElement==null?void 0:s.isElement(C))&&await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1},b=wt(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:S,offsetParent:C,strategy:l}):S);return{top:(g.top-b.top+h.top)/x.y,bottom:(b.bottom-g.bottom+h.bottom)/x.y,left:(g.left-b.left+h.left)/x.x,right:(b.right-g.right+h.right)/x.x}}const Ar=50,Ir=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:s=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:Er},l=await(i.isRTL==null?void 0:i.isRTL(t));let f=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:p,y:d}=Cn(f,o,l),m=o,u=0;const h={};for(let y=0;y<s.length;y++){const R=s[y];if(!R)continue;const{name:g,fn:S}=R,{x:C,y:x,data:b,reset:E}=await S({x:p,y:d,initialPlacement:o,placement:m,strategy:r,middlewareData:h,rects:f,platform:c,elements:{reference:e,floating:t}});p=C??p,d=x??d,h[g]={...h[g],...b},E&&u<Ar&&(u++,typeof E=="object"&&(E.placement&&(m=E.placement),E.rects&&(f=E.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):E.rects),{x:p,y:d}=Cn(f,m,l)),y=-1)}return{x:p,y:d,placement:m,strategy:r,middlewareData:h}},Tr=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:r,middlewareData:s,rects:i,initialPlacement:c,platform:l,elements:f}=t,{mainAxis:p=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:y=!0,...R}=Ze(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const g=Pe(r),S=Oe(c),C=Pe(c)===c,x=await(l.isRTL==null?void 0:l.isRTL(f.floating)),b=m||(C||!y?[Vt(c)]:yr(c)),E=h!=="none";!m&&E&&b.push(...Sr(c,y,h,x));const w=[c,...b],v=await l.detectOverflow(t,R),D=[];let O=((o=s.flip)==null?void 0:o.overflows)||[];if(p&&D.push(v[g]),d){const F=xr(r,i,x);D.push(v[F[0]],v[F[1]])}if(O=[...O,{placement:r,overflows:D}],!D.every(F=>F<=0)){var V,$;const F=(((V=s.flip)==null?void 0:V.index)||0)+1,U=w[F];if(U&&(!(d==="alignment"?S!==Oe(U):!1)||O.every(I=>Oe(I.placement)===S?I.overflows[0]>0:!0)))return{data:{index:F,overflows:O},reset:{placement:U}};let z=($=O.filter(W=>W.overflows[0]<=0).sort((W,I)=>W.overflows[1]-I.overflows[1])[0])==null?void 0:$.placement;if(!z)switch(u){case"bestFit":{var M;const W=(M=O.filter(I=>{if(E){const H=Oe(I.placement);return H===S||H==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(H=>H>0).reduce((H,A)=>H+A,0)]).sort((I,H)=>I[1]-H[1])[0])==null?void 0:M[0];W&&(z=W);break}case"initialPlacement":z=c;break}if(r!==z)return{reset:{placement:z}}}return{}}}},so=new Set(["left","top"]);async function Mr(e,t){const{placement:n,platform:o,elements:r}=e,s=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Pe(n),c=qe(n),l=Oe(n)==="y",f=so.has(i)?-1:1,p=s&&l?-1:1,d=Ze(t,e);let{mainAxis:m,crossAxis:u,alignmentAxis:h}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return c&&typeof h=="number"&&(u=c==="end"?h*-1:h),l?{x:u*p,y:m*f}:{x:m*f,y:u*p}}const Or=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:r,y:s,placement:i,middlewareData:c}=t,l=await Mr(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:r+l.x,y:s+l.y,data:{...l,placement:i}}}}},Pr=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:r,platform:s}=t,{mainAxis:i=!0,crossAxis:c=!1,limiter:l={fn:S=>{let{x:C,y:x}=S;return{x:C,y:x}}},...f}=Ze(e,t),p={x:n,y:o},d=await s.detectOverflow(t,f),m=Oe(r),u=an(m);let h=p[u],y=p[m];const R=(S,C)=>oo(C+d[S==="y"?"top":"left"],C,C-d[S==="y"?"bottom":"right"]);i&&(h=R(u,h)),c&&(y=R(m,y));const g=l.fn({...t,[u]:h,[m]:y});return{...g,data:{x:g.x-n,y:g.y-o,enabled:{[u]:i,[m]:c}}}}}},Lr=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,o;const{x:r,y:s,placement:i,rects:c,middlewareData:l}=t,{offset:f=0,mainAxis:p=!0,crossAxis:d=!0}=Ze(e,t),m={x:r,y:s},u=Oe(i),h=an(u);let y=m[h],R=m[u];const g=Ze(f,t),S=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:(n=g.mainAxis)!=null?n:0,crossAxis:(o=g.crossAxis)!=null?o:0};if(p){const b=h==="y"?"height":"width",E=c.reference[h]-c.floating[b]+S.mainAxis,w=c.reference[h]+c.reference[b]-S.mainAxis;y<E?y=E:y>w&&(y=w)}if(d){var C,x;const b=h==="y"?"width":"height",E=so.has(Pe(i)),w=c.reference[u]-c.floating[b]+(E&&((C=l.offset)==null?void 0:C[u])||0)+(E?0:S.crossAxis),v=c.reference[u]+c.reference[b]+(E?0:((x=l.offset)==null?void 0:x[u])||0)-(E?S.crossAxis:0);R<w?R=w:R>v&&(R=v)}return{[h]:y,[u]:R}}}},Dr=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:o,platform:r,elements:s}=t,{apply:i=()=>{},...c}=Ze(e,t),l=await r.detectOverflow(t,c),f=Pe(n),p=qe(n),d=Oe(n)==="y",{width:m,height:u}=o.floating;let h,y;f==="top"||f==="bottom"?(h=f,y=p===(await(r.isRTL==null?void 0:r.isRTL(s.floating))?"start":"end")?"left":"right"):(y=f,h=p==="end"?"top":"bottom");const R=u-l.top-l.bottom,g=m-l.left-l.right,S=mt(u-l[h],R),C=mt(m-l[y],g),x=t.middlewareData.shift,b=!x;let E=S,w=C;x!=null&&x.enabled.x&&(w=g),x!=null&&x.enabled.y&&(E=R),b&&!p&&(d?w=m-2*ze(l.left,l.right):E=u-2*ze(l.top,l.bottom)),await i({...t,availableWidth:w,availableHeight:E});const v=await r.getDimensions(s.floating);return m!==v.width||u!==v.height?{reset:{rects:!0}}:{}}}};function io(e){const t=Qe(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=Je(e),s=r?e.offsetWidth:n,i=r?e.offsetHeight:o,c=Ft(n)!==s||Ft(o)!==i;return c&&(n=s,o=i),{width:n,height:o,$:c}}function dn(e){return Ee(e)?e:e.contextElement}function pt(e){const t=dn(e);if(!Je(t))return je(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:s}=io(t);let i=(s?Ft(n.width):n.width)/o,c=(s?Ft(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Fr=je(0);function co(e){const t=Ie(e);return!Un()||!t.visualViewport?Fr:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Vr(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Ie(e)}function st(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),s=dn(e);let i=je(1);t&&(o?Ee(o)&&(i=pt(o)):i=pt(e));const c=Vr(s,n,o)?co(s):je(0);let l=(r.left+c.x)/i.x,f=(r.top+c.y)/i.y,p=r.width/i.x,d=r.height/i.y;if(s&&o){const m=Ie(s),u=Ee(o)?Ie(o):o;let h=m,y=yn(h);for(;y&&u!==h;){const R=pt(y),g=y.getBoundingClientRect(),S=Qe(y),C=g.left+(y.clientLeft+parseFloat(S.paddingLeft))*R.x,x=g.top+(y.clientTop+parseFloat(S.paddingTop))*R.y;l*=R.x,f*=R.y,p*=R.x,d*=R.y,l+=C,f+=x,h=Ie(y),y=yn(h)}}return wt({width:p,height:d,x:l,y:f})}function Nt(e,t){const n=_t(e).scrollLeft;return t?t.left+n:st(et(e)).left+n}function lo(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-Nt(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function kr(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const s=r==="fixed",i=et(o),c=t?rn(t.floating):!1;if(o===i||c&&s)return n;let l={scrollLeft:0,scrollTop:0},f=je(1);const p=je(0),d=Je(o);if((d||!s)&&((sn(o)!=="body"||$n(i))&&(l=_t(o)),d)){const u=st(o);f=pt(o),p.x=u.x+o.clientLeft,p.y=u.y+o.clientTop}const m=i&&!d&&!s?lo(i,l):je(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-l.scrollLeft*f.x+p.x+m.x,y:n.y*f.y-l.scrollTop*f.y+p.y+m.y}}function Hr(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function _r(e){const t=_t(e),n=e.ownerDocument.body,o=ze(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),r=ze(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+Nt(e);const i=-t.scrollTop;return Qe(n).direction==="rtl"&&(s+=ze(e.clientWidth,n.clientWidth)-o),{width:o,height:r,x:s,y:i}}const Br=25;function Wr(e,t,n){n===void 0&&(n="viewport");const o=n==="layoutViewport",r=Ie(e),s=et(e),i=r.visualViewport;let c=s.clientWidth,l=s.clientHeight,f=0,p=0;if(i){const m=!Un()||t==="fixed";o?m||(f=-i.offsetLeft,p=-i.offsetTop):(c=i.width,l=i.height,m&&(f=i.offsetLeft,p=i.offsetTop))}if(Nt(s)<=0){const m=s.ownerDocument,u=m.body,h=getComputedStyle(u),y=m.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,R=Math.abs(s.clientWidth-u.clientWidth-y),g=getComputedStyle(s).scrollbarGutter==="stable both-edges"?R/2:R;g<=Br&&(c-=g)}return{width:c,height:l,x:f,y:p}}function Nr(e,t){const n=st(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,s=pt(e),i=e.clientWidth*s.x,c=e.clientHeight*s.y,l=r*s.x,f=o*s.y;return{width:i,height:c,x:l,y:f}}function En(e,t,n){let o;if(t==="viewport"||t==="layoutViewport")o=Wr(e,n,t);else if(t==="document")o=_r(et(e));else if(Ee(t))o=Nr(t,n);else{const r=co(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return wt(o)}function $r(e,t){const n=t.get(e);if(n)return n;let o=Qt(e,[],!1).filter(c=>Ee(c)&&sn(c)!=="body"),r=null;const s=Qe(e).position==="fixed";let i=s?Lt(e):e;for(;Ee(i)&&!Jt(i);){const c=Qe(i),l=Nn(i),f=r?r.position:s?"fixed":"";!l&&(f==="fixed"||f==="absolute"&&c.position==="static")?o=o.filter(d=>d!==i):r=c,i=Lt(i)}return t.set(e,o),o}function Ur(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?rn(t)?[]:$r(t,this._c):[].concat(n),o],c=En(t,i[0],r);let l=c.top,f=c.right,p=c.bottom,d=c.left;for(let m=1;m<i.length;m++){const u=En(t,i[m],r);l=ze(u.top,l),f=mt(u.right,f),p=mt(u.bottom,p),d=ze(u.left,d)}return{width:f-d,height:p-l,x:d,y:l}}function zr(e){const{width:t,height:n}=io(e);return{width:t,height:n}}function jr(e,t,n){const o=Je(t),r=et(t),s=n==="fixed",i=st(e,!0,s,t);let c={scrollLeft:0,scrollTop:0};const l=je(0);if((o||!s)&&((sn(t)!=="body"||$n(r))&&(c=_t(t)),o)){const m=st(t,!0,s,t);l.x=m.x+t.clientLeft,l.y=m.y+t.clientTop}!o&&r&&(l.x=Nt(r));const f=r&&!o&&!s?lo(r,c):je(0),p=i.left+c.scrollLeft-l.x-f.x,d=i.top+c.scrollTop-l.y-f.y;return{x:p,y:d,width:i.width,height:i.height}}function Kt(e){return Qe(e).position==="static"}function An(e,t){if(!Je(e)||Qe(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return et(e)===n&&(n=n.ownerDocument.body),n}function ao(e,t){const n=Ie(e);if(rn(e))return n;if(!Je(e)){let r=Lt(e);for(;r&&!Jt(r);){if(Ee(r)&&!Kt(r))return r;r=Lt(r)}return n}let o=An(e,t);for(;o&&_o(o)&&Kt(o);)o=An(o,t);return o&&Jt(o)&&Kt(o)&&!Nn(o)?n:o||Bo(e)||n}const qr=async function(e){const t=this.getOffsetParent||ao,n=this.getDimensions,o=await n(e.floating);return{reference:jr(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Yr(e){return Qe(e).direction==="rtl"}const uo={convertOffsetParentRelativeRectToViewportRelativeRect:kr,getDocumentElement:et,getClippingRect:Ur,getOffsetParent:ao,getElementRects:qr,getClientRects:Hr,getDimensions:zr,getScale:pt,isElement:Ee,isRTL:Yr};function fo(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Kr(e,t,n){let o=null,r;const s=et(e);function i(){var p;clearTimeout(r),(p=o)==null||p.disconnect(),o=null}function c(p,d){p===void 0&&(p=!1),d===void 0&&(d=1),i();const m=e.getBoundingClientRect(),{left:u,top:h,width:y,height:R}=m;if(p||t(),!y||!R)return;const g=vt(h),S=vt(s.clientWidth-(u+y)),C=vt(s.clientHeight-(h+R)),x=vt(u),E={rootMargin:-g+"px "+-S+"px "+-C+"px "+-x+"px",threshold:ze(0,mt(1,d))||1};let w=!0;function v(D){const O=D[0].intersectionRatio;if(!fo(m,e.getBoundingClientRect()))return c();if(O!==d){if(!w)return c();O?c(!1,O):r=setTimeout(()=>{c(!1,1e-7)},1e3)}w=!1}try{o=new IntersectionObserver(v,{...E,root:s.ownerDocument})}catch{o=new IntersectionObserver(v,E)}o.observe(e)}const l=Ie(e),f=()=>c(n);return l.addEventListener("resize",f),c(!0),()=>{l.removeEventListener("resize",f),i()}}function In(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,f=dn(e),p=r||s?[...f?Qt(f):[],...t?Qt(t):[]]:[];p.forEach(g=>{r&&g.addEventListener("scroll",n),s&&g.addEventListener("resize",n)});const d=f&&c?Kr(f,n,s):null;let m=-1,u=null;i&&(u=new ResizeObserver(g=>{let[S]=g;S&&S.target===f&&u&&t&&(u.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=u)==null||C.observe(t)})),n()}),f&&!l&&u.observe(f),t&&u.observe(t));let h,y=l?st(e):null;l&&R();function R(){const g=st(e);y&&!fo(y,g)&&n(),y=g,h=requestAnimationFrame(R)}return n(),()=>{var g;p.forEach(S=>{r&&S.removeEventListener("scroll",n),s&&S.removeEventListener("resize",n)}),d?.(),(g=u)==null||g.disconnect(),u=null,l&&cancelAnimationFrame(h)}}const Xr=Or,Gr=Pr,Jr=Tr,Qr=Dr,Zr=Lr,es=(e,t,n)=>{const o=new Map,r=n??{},s={...uo,...r.platform,_c:o};return Ir(e,t,{...r,platform:s})};var ts=typeof document<"u",ns=function(){},Mt=ts?a.useLayoutEffect:ns;function kt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,o,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(o=n;o--!==0;)if(!kt(e[o],t[o]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(t).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(t,r[o]))return!1;for(o=n;o--!==0;){const s=r[o];if(!(s==="_owner"&&e.$$typeof)&&!kt(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function po(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Tn(e,t){const n=po(e);return Math.round(t*n)/n}function Xt(e){const t=a.useRef(e);return Mt(()=>{t.current=e}),t}function os(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:o=[],platform:r,elements:{reference:s,floating:i}={},transform:c=!0,whileElementsMounted:l,open:f}=e,[p,d]=a.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,u]=a.useState(o);kt(m,o)||u(o);const[h,y]=a.useState(null),[R,g]=a.useState(null),S=a.useCallback(I=>{I!==E.current&&(E.current=I,y(I))},[]),C=a.useCallback(I=>{I!==w.current&&(w.current=I,g(I))},[]),x=s||h,b=i||R,E=a.useRef(null),w=a.useRef(null),v=a.useRef(p),D=l!=null,O=Xt(l),V=Xt(r),$=Xt(f),M=a.useCallback(()=>{if(!E.current||!w.current)return;const I={placement:t,strategy:n,middleware:m};V.current&&(I.platform=V.current),es(E.current,w.current,I).then(H=>{const A={...H,isPositioned:$.current!==!1};F.current&&!kt(v.current,A)&&(v.current=A,Wo.flushSync(()=>{d(A)}))})},[m,t,n,V,$]);Mt(()=>{f===!1&&v.current.isPositioned&&(v.current.isPositioned=!1,d(I=>({...I,isPositioned:!1})))},[f]);const F=a.useRef(!1);Mt(()=>(F.current=!0,()=>{F.current=!1}),[]),Mt(()=>{if(x&&(E.current=x),b&&(w.current=b),x&&b){if(O.current)return O.current(x,b,M);M()}},[x,b,M,O,D]);const U=a.useMemo(()=>({reference:E,floating:w,setReference:S,setFloating:C}),[S,C]),z=a.useMemo(()=>({reference:x,floating:b}),[x,b]),W=a.useMemo(()=>{const I={position:n,left:0,top:0};if(!z.floating)return I;const H=Tn(z.floating,p.x),A=Tn(z.floating,p.y);return c?{...I,transform:"translate("+H+"px, "+A+"px)",...po(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:H,top:A}},[n,c,z.floating,p.x,p.y]);return a.useMemo(()=>({...p,update:M,refs:U,elements:z,floatingStyles:W}),[p,M,U,z,W])}const rs=(e,t)=>{const n=Xr(e);return{name:n.name,fn:n.fn,options:[e,t]}},ss=(e,t)=>{const n=Gr(e);return{name:n.name,fn:n.fn,options:[e,t]}},is=(e,t)=>({fn:Zr(e).fn,options:[e,t]}),cs=(e,t)=>{const n=Jr(e);return{name:n.name,fn:n.fn,options:[e,t]}},ls=(e,t)=>{const n=Qr(e);return{name:n.name,fn:n.fn,options:[e,t]}};function as(e){const{open:t=!1,onOpenChange:n,elements:o={}}=e,r=No(),s=Jn()!=null,i=gt(()=>new sr({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:o.reference??null,floatingElement:o.floating??null,triggerElements:new ir,floatingId:r,syncOnly:!1,nested:s})).current;return X(()=>{const c={open:t,floatingId:r};o.reference!==void 0&&(c.referenceElement=o.reference,c.domReferenceElement=Ee(o.reference)?o.reference:null),o.floating!==void 0&&(c.floatingElement=o.floating),i.update(c)},[t,r,o.reference,o.floating,i]),i.context.onOpenChange=n,i.context.nested=s,i}function us(e){return fs(e,e.rootContext)}function fs(e,t){const{nodeId:n,externalTree:o}=e,r=t.useState("referenceElement"),s=t.useState("floatingElement"),i=t.useState("domReferenceElement"),c=t.useState("open"),l=t.useState("floatingId"),[f,p]=a.useState(null),[d,m]=a.useState(void 0),[u,h]=a.useState(void 0),y=a.useRef(null),R=Qn(o),g=a.useMemo(()=>({reference:r,floating:s,domReference:i}),[r,s,i]),S=os({...e,elements:{...g,...f&&{reference:f}}}),C=Ee(d)?d:null,x=u===void 0?t.state.floatingElement:u;t.useSyncedValue("referenceElement",d??null),t.useSyncedValue("domReferenceElement",d===void 0?i:C),t.useSyncedValue("floatingElement",x);const b=a.useCallback(V=>{const $=Ee(V)?{getBoundingClientRect:()=>V.getBoundingClientRect(),getClientRects:()=>V.getClientRects(),contextElement:V}:V;p($),S.refs.setReference($)},[S.refs]),E=a.useCallback(V=>{(Ee(V)||V===null)&&(y.current=V,m(V)),(Ee(S.refs.reference.current)||S.refs.reference.current===null||V!==null&&!Ee(V))&&S.refs.setReference(V)},[S.refs,m]),w=a.useCallback(V=>{h(V),S.refs.setFloating(V)},[S.refs]),v=a.useMemo(()=>({...S.refs,setReference:E,setFloating:w,setPositionReference:b,domReference:y}),[S.refs,E,w,b]),D=a.useMemo(()=>({...S.elements,domReference:i}),[S.elements,i]),O=a.useMemo(()=>({...S,dataRef:t.context.dataRef,open:c,onOpenChange:t.setOpen,events:t.context.events,floatingId:l,refs:v,elements:D,nodeId:n,rootStore:t}),[S,v,D,n,t,c,l]);return X(()=>{i&&(y.current=i)},[i]),X(()=>{t.context.dataRef.current.floatingContext=O;const V=R?.nodesRef.current.find($=>$.id===n);V&&(V.context=O)}),a.useMemo(()=>({...S,context:O,refs:v,elements:D,rootStore:t}),[S,v,D,O,t])}const ds="Escape";function Mn(e){return qn&&e.movementX===0&&e.movementY===0}function $t(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Ct(e,t){return $t(t,e===Yn||e===cn,e===Bt||e===Wt)}function Gt(e,t,n){return $t(t,e===cn,n?e===Bt:e===Wt)||e==="Enter"||e===" "||e===""}function ps(e,t,n){return $t(t,n?e===Bt:e===Wt,e===cn)}function gs(e,t,n,o){const r=n?e===Wt:e===Bt,s=e===Yn;return t==="both"||t==="horizontal"&&o?e===ds:$t(t,r,s)}function ms(e,t){const{listRef:n,activeIndex:o,onNavigate:r=()=>{},enabled:s=!0,selectedIndex:i=null,allowEscape:c=!1,loopFocus:l=!1,nested:f=!1,rtl:p=!1,virtual:d=!1,focusItemOnOpen:m="auto",focusItemOnHover:u=!0,openOnArrowKeyDown:h=!0,disabledIndices:y=void 0,orientation:R="vertical",parentOrientation:g,id:S,resetOnPointerLeave:C=!0,externalTree:x,grid:b}=t,E=b!=null,w="rootStore"in e?e.rootStore:e,v=w.useState("open"),D=w.useState("floatingElement"),O=w.useState("domReferenceElement"),V=w.context.dataRef,$=zn(D),M=$o(O),F=De($),U=Jn(),z=Qn(x),W=a.useRef(m),I=a.useRef(i??-1),H=a.useRef(null),A=a.useRef(!0),k=te(T=>{r(I.current===-1?null:I.current,T)}),N=a.useRef(!!D),P=a.useRef(v),B=a.useRef(!1),ne=a.useRef(!1),ie=a.useRef(null),ce=De(y),le=De(v),re=De(i),Q=De(C),fe=Pt(),K=Pt(),G=te(()=>{function T(q){d?z?.events.emit("virtualfocus",q):ie.current=cr(q,{sync:B.current,preventScroll:!0})}const L=n.current[I.current],ee=ne.current;L&&T(L),(B.current?q=>q():q=>fe.request(q))(()=>{const q=n.current[I.current]||L;if(!q)return;L||T(q),ae&&(ee||!A.current)&&q.scrollIntoView?.({block:"nearest",inline:"nearest"})})});X(()=>{V.current.orientation=R},[V,R]),X(()=>{s&&(v&&D?(I.current=i??-1,W.current&&i!=null&&(ne.current=!0,k())):N.current&&(I.current=-1,k()))},[s,v,D,i,k]),X(()=>{if(s){if(!v){B.current=!1;return}if(D)if(o==null){if(B.current=!1,re.current!=null)return;if(N.current&&(I.current=-1,G()),(!P.current||!N.current)&&W.current&&(H.current!=null||W.current===!0&&H.current==null)){let T=0;const L=()=>{n.current[0]==null?(T<2&&(T?_=>K.request(_):queueMicrotask)(L),T+=1):(I.current=H.current==null||Gt(H.current,R,p)||f?zt(n):bn(n),H.current=null,k())};L()}}else Rn(n.current,o)||(I.current=o,G(),ne.current=!1)}},[s,v,D,o,re,f,n,R,p,k,G,K]),X(()=>{if(!s||D||!z||d||!N.current)return;const T=z.nodesRef.current,L=T.find(q=>q.id===U)?.context?.elements.floating,ee=jt(rt(O??L??null)),_=T.some(q=>q.context&&Ge(q.context.elements.floating,ee));L&&!_&&A.current&&L.focus({preventScroll:!0})},[s,D,O,z,U,d]),X(()=>{P.current=v,N.current=!!D}),X(()=>{v||(H.current=null,W.current=m)},[v,m]);const de=o!=null,J=te(T=>{if(!le.current)return;const L=n.current.indexOf(T.currentTarget);L!==-1&&(I.current!==L||o!==L)&&(I.current=L,k(T))}),be=te(()=>g??z?.nodesRef.current.find(T=>T.id===U)?.context?.dataRef?.current.orientation),Se=te(()=>zt(n,ce.current)),me=te(T=>{if(A.current=!1,B.current=!0,T.which===229||!le.current&&T.currentTarget===F.current)return;if(f&&gs(T.key,R,p,E)){Ct(T.key,be())||$e(T),w.setOpen(!1,Ae(wn,T.nativeEvent)),Je(O)&&(d?z?.events.emit("virtualfocus",O):O.focus());return}const L=I.current,ee=zt(n,y),_=bn(n,y);if(M||(T.key==="Home"&&($e(T),I.current=ee,k(T)),T.key==="End"&&($e(T),I.current=_,k(T))),b!=null){const q=b(T,I.current,n,R,l,p,y,ee,_);if(q!=null&&(I.current=q,k(T)),R==="both")return}if(Ct(T.key,R)){if($e(T),v&&!d&&jt(T.currentTarget.ownerDocument)===T.currentTarget){I.current=Gt(T.key,R,p)?ee:_,k(T);return}Gt(T.key,R,p)?l?L>=_?c&&L!==n.current.length?I.current=-1:(B.current=!1,I.current=ee):I.current=St(n.current,{startingIndex:L,disabledIndices:y}):I.current=Math.min(_,St(n.current,{startingIndex:L,disabledIndices:y})):l?L<=ee?c&&L!==-1?I.current=n.current.length:(B.current=!1,I.current=_):I.current=St(n.current,{startingIndex:L,decrement:!0,disabledIndices:y}):I.current=Math.max(ee,St(n.current,{startingIndex:L,decrement:!0,disabledIndices:y})),Rn(n.current,I.current)&&(I.current=-1),k(T)}}),ae=a.useMemo(()=>({onFocus(L){B.current=!0,J(L)},onClick:({currentTarget:L})=>L.focus({preventScroll:!0}),onMouseMove(L){Mn(L)||(B.current=!0,ne.current=!1,u&&J(L))},onPointerLeave(L){if(!le.current||!A.current||L.pointerType==="touch")return;B.current=!0;const ee=L.relatedTarget;if(!(!u||n.current.includes(ee))&&Q.current&&(ie.current?.(),ie.current=null,I.current=-1,k(L),!d)){const _=F.current,q=jt(rt(_));_&&Ge(_,q)&&_.focus({preventScroll:!0})}}}),[J,le,F,u,n,k,Q,d]),xe=a.useMemo(()=>d&&v&&de&&{"aria-activedescendant":`${S}-${o}`},[d,v,de,S,o]),ge=a.useMemo(()=>({...M?{}:xe,onKeyDown(T){if(T.key==="Tab"&&T.shiftKey&&v&&!d){const L=Wn(T.nativeEvent);if(L&&!Ge(F.current,L))return;$e(T),w.setOpen(!1,Ae(jn,T.nativeEvent)),Je(O)&&O.focus();return}me(T)},onPointerMove(T){Mn(T)||(A.current=!0)}}),[xe,me,F,M,w,v,d,O]),Z=a.useMemo(()=>{function T(_){w.setOpen(!0,Ae(wn,_.nativeEvent,_.currentTarget))}function L(_){m==="auto"&&Zn(_.nativeEvent)&&(W.current=!d)}function ee(_){W.current=m,m==="auto"&&Gn(_.nativeEvent)&&(W.current=!0)}return{onKeyDown(_){const q=w.select("open");A.current=!1;const ye=_.key.startsWith("Arrow"),Ve=ps(_.key,be(),p),Te=Ct(_.key,R),ve=(f?Ve:Te)||_.key==="Enter"||_.key.trim()==="";if(d&&q)return me(_);if(!(!q&&!h&&ye)){if(ve){const ke=Ct(_.key,be());H.current=f&&ke?null:_.key}if(f){Ve&&($e(_),q?(I.current=Se(),k(_)):T(_));return}Te&&(re.current!=null&&(I.current=re.current),$e(_),!q&&h?T(_):me(_),q&&k(_))}},onFocus(_){w.select("open")&&!d&&(I.current=-1,k(_))},onPointerDown:ee,onPointerEnter:ee,onMouseDown:L,onClick:L}},[me,m,Se,f,k,w,h,R,be,p,re,d]),Fe=a.useMemo(()=>({...xe,...Z}),[xe,Z]);return a.useMemo(()=>s?{reference:Fe,floating:ge,item:ae,trigger:Z}:{},[s,Fe,ge,Z,ae])}function hs(e,t){const{listRef:n,elementsRef:o,activeIndex:r,onMatch:s,disabledIndices:i,onTyping:c,enabled:l=!0,resetMs:f=750,selectedIndex:p=null}=t,d="rootStore"in e?e.rootStore:e,m=d.useState("open"),u=bt(),h=a.useRef(""),y=a.useRef(p??r??-1),R=a.useRef(null),g=te(x=>{function b(F){return o?.current[F]}function E(F){const U=b(F);return U&&!Uo(U)||U?.matches(":disabled")?!1:i==null||!zo(Zt,F,i)}function w(F,U,z=0){if(F.length===0)return-1;const W=(z%F.length+F.length)%F.length,I=U.toLowerCase();for(let H=0;H<F.length;H+=1){const A=(W+H)%F.length;if(!(!F[A]?.toLowerCase().startsWith(I)||!E(A)))return A}return-1}const v=n.current;if(h.current.length>0&&x.key===" "&&($e(x),c?.(!0)),h.current.length>0&&h.current[0]!==" "&&w(v,h.current)===-1&&x.key!==" "&&c?.(!1),v==null||x.key.length!==1||x.ctrlKey||x.metaKey||x.altKey)return;m&&x.key!==" "&&($e(x),c?.(!0));const D=h.current==="";D&&(y.current=p??r??-1),v.every((F,U)=>F&&E(U)?F[0]?.toLowerCase()!==F[1]?.toLowerCase():!0)&&h.current===x.key&&(h.current="",y.current=R.current),h.current+=x.key,u.start(f,()=>{h.current="",y.current=R.current,c?.(!1)});const $=((D?p??r??-1:y.current)??0)+1,M=w(v,h.current,$);M!==-1?(s?.(M),R.current=M):x.key!==" "&&(h.current="",c?.(!1))}),S=te(x=>{const b=x.relatedTarget,E=d.select("domReferenceElement"),w=d.select("floatingElement");Ge(E,b)||Ge(w,b)||(u.clear(),h.current="",y.current=R.current,c?.(!1))});X(()=>{!m&&p!==null||(u.clear(),R.current=null,h.current!==""&&(h.current=""))},[m,p,u]);const C=a.useMemo(()=>({onKeyDown:g,onBlur:S}),[g,S]);return a.useMemo(()=>l?{reference:C,floating:C}:{},[l,C])}const xs=a.createContext(void 0);function go(){return a.useContext(xs)?.direction??"ltr"}const ys=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:r,rects:s,platform:i,elements:c,middlewareData:l}=t,{element:f,padding:p=0,offsetParent:d="real"}=Ze(e,t)||{};if(f==null)return{};const m=ro(p),u={x:n,y:o},h=fn(r),y=un(h),R=await i.getDimensions(f),g=h==="y",S=g?"top":"left",C=g?"bottom":"right",x=g?"clientHeight":"clientWidth",b=s.reference[y]+s.reference[h]-u[h]-s.floating[y],E=u[h]-s.reference[h],w=d==="real"?await i.getOffsetParent?.(f):c.floating;let v=c.floating[x]||s.floating[y];(!v||!await i.isElement?.(w))&&(v=c.floating[x]||s.floating[y]);const D=b/2-E/2,O=v/2-R[y]/2-1,V=Math.min(m[S],O),$=Math.min(m[C],O),M=V,F=v-R[y]-$,U=v/2-R[y]/2+D,z=oo(M,U,F),W=!l.arrow&&qe(r)!=null&&U!==z&&s.reference[y]/2-(U<M?V:$)-R[y]/2<0,I=W?U<M?U-M:U-F:0;return{[h]:u[h]+I,data:{[h]:z,centerOffset:U-z-I,...W&&{alignmentOffset:I}},reset:W}}}),Rs=(e,t)=>{const{name:n,fn:o}=ys(e);return{name:n,fn:o,options:[e,t]}},bs={name:"hide",async fn(e){const{width:t,height:n,x:o,y:r}=e.rects.reference,s=t===0&&n===0&&o===0&&r===0,i=await e.platform.detectOverflow(e,{elementContext:"reference"});return{data:{referenceHidden:i.top-n>=0||i.right-t>=0||i.bottom-n>=0||i.left-t>=0||s}}}},ws={sideX:"left",sideY:"top"},Ss="--available-width",vs="--available-height",Cs="--anchor-width",Es="--anchor-height",As="--transform-origin",On=Ss,Pn=vs;function mo(e,t,n){const o=e==="inline-start"||e==="inline-end";return{top:"top",right:o?n?"inline-start":"inline-end":"right",bottom:"bottom",left:o?n?"inline-end":"inline-start":"left"}[t]}function Ln(e,t,n){const{rects:o,placement:r}=e;return{side:mo(t,Pe(r),n),align:qe(r)||"center",anchor:{width:o.reference.width,height:o.reference.height},positioner:{width:o.floating.width,height:o.floating.height}}}function Is(e){return Ts(e,us)}function Ts(e,t){const{anchor:n,positionMethod:o="absolute",side:r="bottom",sideOffset:s=0,align:i="center",alignOffset:c=0,collisionBoundary:l,collisionPadding:f=5,sticky:p=!1,arrowPadding:d=5,disableAnchorTracking:m=!1,inline:u,keepMounted:h=!1,floatingRootContext:y,mounted:R,collisionAvoidance:g,shift:S,nodeId:C,adaptiveOrigin:x,lazyFlip:b=!1,externalTree:E}=e,[w,v]=a.useState(null);!R&&w!==null&&v(null);const D=g.side||"flip",O=g.align||"flip",V=g.fallbackAxisSide||"end",$=S?.crossAxis??!1,M=S?.rootBoundary,F=typeof n=="function"?n:void 0,U=te(F),z=F?U:n,W=De(n),I=De(R),A=go()==="rtl",k=w||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":A?"left":"right","inline-start":A?"right":"left"}[r],N=i==="center"?k:`${k}-${i}`;let P=f;typeof P=="number"?P={top:P,right:P,bottom:P,left:P}:P&&(P={top:P.top||0,right:P.right||0,bottom:P.bottom||0,left:P.left||0});const B=1,ne=r==="bottom"?B:0,ie=r==="top"?B:0,ce=r==="right"?B:0,le=r==="left"?B:0,re={boundary:l==="clipping-ancestors"?"clippingAncestors":l,padding:P},Q=a.useRef(null),fe=De(s),K=De(c),G=typeof s!="function"?s:0,de=typeof c!="function"?c:0,J=[];u&&J.push(u),J.push(rs(j=>{const se=Ln(j,r,A),pe=typeof fe.current=="function"?fe.current(se):fe.current,he=typeof K.current=="function"?K.current(se):K.current;return{mainAxis:pe,crossAxis:he,alignmentAxis:he}},[G,de,A,r]));const be=O==="none"&&D!=="shift",Se=!be&&(p||$||D==="shift"),me=D==="none"?null:cs({...re,padding:{top:P.top+B+ne,right:P.right+B+le,bottom:P.bottom+B+ie,left:P.left+B+ce},mainAxis:!$&&D==="flip",crossAxis:O==="flip"?"alignment":!1,fallbackAxisSideDirection:V}),ae=be?null:ss({...re,rootBoundary:M,mainAxis:O!=="none",crossAxis:Se,limiter:p||$?void 0:is(j=>{if(!Q.current)return{};const{width:se,height:pe}=Q.current.getBoundingClientRect(),he=Oe(Pe(j.placement)),Le=he==="y"?se:pe,Ce=he==="y"?P.left+P.right:P.top+P.bottom;return{offset:Le/2+Ce/2}})},[re,p,$,M,P,O]);D==="shift"||O==="shift"||i==="center"?J.push(ae,me):J.push(me,ae),J.push(ls({...re,apply({elements:{floating:j},availableWidth:se,availableHeight:pe,rects:he}){if(!I.current)return;const Le=j.style;Le.setProperty(On,`${se}px`),Le.setProperty(Pn,`${pe}px`);const Ce=Ie(j).devicePixelRatio||1,{x:ut,y:Xe,width:tt,height:Be}=he.reference,Y=(Math.round((ut+tt)*Ce)-Math.round(ut*Ce))/Ce,oe=(Math.round((Xe+Be)*Ce)-Math.round(Xe*Ce))/Ce;Le.setProperty(Cs,`${Y}px`),Le.setProperty(Es,`${oe}px`)}}),Rs(j=>({element:Q.current||rt(j.elements.floating).createElement("div"),padding:Q.current?d:0,offsetParent:"floating"}),[d]),{name:"transformOrigin",fn(j){const{elements:{floating:se},middlewareData:pe,placement:he,platform:Le,rects:Ce,y:ut}=j,Xe=Pe(he),tt=qe(he),Be=Oe(Xe)==="y",Y=Q.current,oe=typeof s=="function"?s(Ln(j,r,A)):s;let Ne;if(!Y&&tt&&Math.abs(Be?pe.shift?.x||0:pe.shift?.y||0)<=1)Ne=tt==="start"===(Be&&Le.isRTL?.(se)===!0)?"100%":"0%";else{const ot=Be?pe.arrow?.x||0:pe.arrow?.y||0,xt=Be?Y?.clientWidth||0:Y?.clientHeight||0;Ne=`${ot+xt/2}px`}let nt=Xe==="top"||Xe==="left"?`calc(100% + ${oe}px)`:`${-oe}px`;return Se&&Be&&Math.abs(pe.shift?.y||0)>oe&&(nt=`${Ce.reference.y+Ce.reference.height/2-ut}px`),se.style.setProperty(As,Be?`${Ne} ${nt}`:`${nt} ${Ne}`),{}}},bs,x),X(()=>{!R&&y&&y.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[R,y]);const xe=a.useMemo(()=>({ancestorScroll:!m,elementResize:!m&&typeof ResizeObserver<"u",layoutShift:!m&&typeof IntersectionObserver<"u"}),[m]),{refs:ge,elements:Z,x:Fe,y:T,middlewareData:L,update:ee,placement:_,context:q,isPositioned:ye,floatingStyles:Ve}=t({rootContext:y,open:h?R:void 0,placement:N,middleware:J,strategy:o,whileElementsMounted:h?void 0:(...j)=>In(...j,xe),nodeId:C,externalTree:E}),{sideX:Te,sideY:ve}=L.adaptiveOrigin||ws,ke=ye?o:"fixed",Ye=a.useMemo(()=>{let j;return ye?x?j={position:ke,[Te]:Fe,[ve]:T}:j={...Ve,position:ke}:j={position:ke,top:0,left:0},j[On]="100vw",j[Pn]="100vh",ye||(j.opacity=0),j},[x,ke,Te,Fe,ve,T,Ve,ye]),He=a.useRef(null);X(()=>{if(!R)return;const j=W.current,se=typeof j=="function"?j():j,he=(Dn(se)?se.current:se)||null||null;he!==He.current&&(ge.setPositionReference(he),He.current=he)},[R,ge,z,W]),a.useEffect(()=>{if(!R)return;const j=W.current;typeof j!="function"&&Dn(j)&&j.current!==He.current&&(ge.setPositionReference(j.current),He.current=j.current)},[R,ge,z,W]),a.useEffect(()=>{if(h&&R&&Z.reference&&Z.floating)return In(Z.reference,Z.floating,ee,xe)},[h,R,Z,ee,xe]);const Me=Pe(_),We=mo(r,Me,A),Ke=qe(_)||"center",at=!!L.hide?.referenceHidden;X(()=>{b&&R&&ye&&Me!==k&&v(Me)},[b,R,ye,Me,k]);const _e=a.useMemo(()=>({position:"absolute",top:L.arrow?.y,left:L.arrow?.x}),[L.arrow]),we=L.arrow?.centerOffset!==0;return a.useMemo(()=>({positionerStyles:Ye,arrowStyles:_e,arrowRef:Q,arrowUncentered:we,side:We,align:Ke,physicalSide:Me,anchorHidden:at,refs:ge,context:q,isPositioned:ye,update:ee}),[Ye,_e,Q,we,We,Ke,Me,at,ge,q,ye,ee])}function Dn(e){return e!=null&&"current"in e}function ho(e){return e==="starting"?jo:dt}function Ms(e,t,{styles:n,transitionStatus:o,props:r,refs:s,hidden:i,inert:c=!1}){const l={...n};return c&&(l.pointerEvents="none"),ct("div",e,{state:t,ref:s,props:[{role:"presentation",hidden:i,style:l},ho(o),r],stateAttributesMapping:eo})}function Os(e){const t=a.useRef(""),n=a.useCallback(r=>{r.defaultPrevented||(t.current=r.pointerType,e(r,r.pointerType))},[e]);return{onClick:a.useCallback(r=>{if(r.detail===0){e(r,"keyboard");return}"pointerType"in r?e(r,r.pointerType):e(r,t.current),t.current=""},[e]),onPointerDown:n}}function xo(e,t){const n=a.useRef(e),o=te(t);X(()=>{n.current!==e&&o(n.current),n.current=e},[e,o])}function Ps(e,t){const n=te((s,i)=>{(typeof e=="function"?e():e)||t(i||(qo?"touch":""))}),{onClick:o,onPointerDown:r}=Os(n);return a.useMemo(()=>({onClick:o,onPointerDown:r}),[o,r])}function Ls(e){const[t,n]=a.useState(null),o=Ps(e,n);return xo(e,r=>{r&&!e&&n(null)}),a.useMemo(()=>({openMethod:t,triggerProps:o}),[t,o])}const Ds=20;function Fs(e,t,n,o){const[r,s]=a.useState(!1);X(()=>{if(!e||!t||n==null){s(!1);return}const i=rt(n).documentElement.clientWidth,c=n.offsetWidth;s(i>0&&c>0&&c>=i-Ds)},[e,t,n]),lr(e&&(!t||r),o)}const Vs=a.createContext(void 0);function ks(e){return a.useContext(Vs)}function Hs(e){const[t,n]=a.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function _s(e){const t=a.useRef(!0);t.current&&(t.current=!1,e())}function Bs(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Fn({controlled:e,default:t,name:n,state:o="value"}){const{current:r}=a.useRef(e!==void 0),[s,i]=a.useState(t),c=r&&e!==void 0?e:s,l=a.useCallback(f=>{r||i(f)},[]);return[c,l]}const yo=a.createContext(void 0),Ro=a.createContext(void 0),bo=a.createContext(void 0);function lt(){const e=a.useContext(yo);if(e===void 0)throw new Error(ht(60));return e}function pn(){const e=a.useContext(Ro);if(e===void 0)throw new Error(ht(101));return e}function wo(){const e=a.useContext(bo);if(e===void 0)throw new Error(ht(61));return e}const Ws="data-valid",Ns="data-invalid",$s={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Us={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},zs={disabled:!1,...Us},js={valid(e){return e===null?null:e?{[Ws]:""}:{[Ns]:""}}},qs={invalid:void 0,name:void 0,validityData:{state:$s,errors:[],error:"",value:"",initialValue:null},setValidityData:ue,disabled:void 0,setTouched:ue,setDirty:ue,setFilled:ue,setFocused:ue,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:zs,registerFieldControl:ue,validation:{getValidationProps:(e,t=dt)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:ue,getInputControl:()=>null,commit:async()=>{},change:ue}},Ys=a.createContext(qs);function gn(e=!0){const t=a.useContext(Ys);if(t.setValidityData===ue&&!e)throw new Error(ht(28));return t}function Ks(e,t,n,o,r=!0,s){const{registerFieldControl:i}=gn(),c=gt(()=>Symbol());X(()=>{const l=c.current;if(!r){i(l,void 0);return}i(l,{controlRef:e,getValue:o,id:t,name:s,value:n})},[e,r,o,t,s,i,c,n]),X(()=>{const l=c.current;return()=>{i(l,void 0)}},[i,c])}const Xs=a.createContext({controlId:void 0,registerControlId:ue,resetControlId:ue,labelId:void 0,setLabelId:ue,messageIds:[],setMessageIds:ue,getDescriptionProps:e=>e});function So(){return a.useContext(Xs)}function vo(e={}){const{id:t,enabled:n=!0}=e,{controlId:o,registerControlId:r,resetControlId:s}=So(),i=ar(),c=gt(()=>Symbol()),l=a.useRef(!1),f=a.useRef(!1),p=te(()=>{!l.current||r===ue||(l.current=!1,r(c.current,void 0))});return X(()=>{if(!n||r===ue){p();return}let d;if(t!==void 0)f.current=!0,d=t;else if(f.current)d=i;else{s();return}if(d===void 0){p();return}l.current=!0,r(c.current,d)},[t,n,r,s,i,c,p]),X(()=>p,[p]),(n?o:void 0)??t??i}function Gs(e,t,n=Object.is){const{length:o}=e;if(o!==t.length)return!1;for(let r=0;r<o;r+=1)if(!n(e[r],t[r]))return!1;return!0}const Co=(e,t)=>Object.is(e,t);function it(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Js(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Gs(e,t,(o,r)=>it(o,r,n)):e!==t}function nn(e,t,n){return e?e.some(o=>o===void 0?!1:it(t,o,n)):!1}function Ot(e,t,n){return e?e.findIndex(o=>o===void 0?!1:it(o,t,n)):-1}function Qs(e,t){if(t!==Co)return o=>nn(e,o,t);const n=new Set(e);return n.delete(void 0),o=>n.has(o)&&(o!==0||e.some(r=>Object.is(o,r)))}function Eo(e,t,n,o){const r=o&&Array.isArray(t)?e.findIndex(Qs(t,n)):Ot(e,t,n);return r===-1?null:r}function Zs(e,t,n,o,r,s){return nn(o,t,r)?s!=null&&e>s&&nn(o,n[s],r)?s:e:e===s?Eo(n,o,r,!0):s}function ei(e,t,n){return e.filter(o=>!it(t,o,n))}function on(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function ti(e){return typeof e=="object"&&e!=null&&Array.isArray(e.items)}function Ao(e){return ti(e?.[0])}function ni(e){return Ao(e)?e.flatMap(t=>t.items):e}function oi(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(Ao(t)){for(const n of t)for(const o of n.items)if(o&&o.value==null&&o.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function Io(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 on(e)}function ft(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?on(e.value):on(e)}function To(e,t,n){function o(){return Io(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)??o();if(Array.isArray(t)){const s=ni(t);if(e==null||typeof e!="object"){const i=s.find(c=>c.value===e);return i&&i.label!=null?i.label:o()}if("value"in e){const i=s.find(c=>c&&c.value===e.value);if(i&&i.label!=null)return i.label}}return o()}function ri(e,t,n){return e.reduce((o,r,s)=>(s>0&&o.push(", "),o.push(Re.jsx(a.Fragment,{children:To(r,t,n)},s)),o),[])}const si={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{const{value:t,multiple:n,itemToStringValue:o}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:ft(t,o)!==""},hasNullItemLabel:(e,t)=>t?oi(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,o=e.value;return e.multiple?Array.isArray(o)&&o.some(r=>it(t,r,n)):it(t,o,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},ii=a.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:ue,validationMode:"onSubmit",submitCountRef:{current:0}});function ci(){return a.useContext(ii)}const Ue=1;function Mo(e,t){return Math.max(0,e-t)}function li(e,t){if(t<=0)return 0;const n=yt(e,0,t),o=n,r=t-n,s=o<=Ue,i=r<=Ue;return s&&i?o<=r?0:t:s?0:i?t:n}function ki(e){const{id:t,value:n,defaultValue:o=null,onValueChange:r,open:s,defaultOpen:i=!1,onOpenChange:c,name:l,form:f,autoComplete:p,disabled:d=!1,readOnly:m=!1,required:u=!1,modal:h=!0,actionsRef:y,inputRef:R,onOpenChangeComplete:g,items:S,multiple:C=!1,itemToStringLabel:x,itemToStringValue:b,isItemEqualToValue:E=Co,highlightItemOnHover:w=!0,children:v}=e,{clearErrors:D}=ci(),{setDirty:O,setTouched:V,setFocused:$,validityData:M,setFilled:F,name:U,disabled:z,validation:W,validationMode:I}=gn(),H=vo({id:t}),A=z||d,k=U??l,[N,P]=Fn({controlled:n,default:C?o??Zt:o,name:"Select",state:"value"}),[B,ne]=Fn({controlled:s,default:i,name:"Select",state:"open"}),ie=a.useRef([]),ce=a.useRef([]),le=a.useRef(null),re=a.useRef(null),Q=a.useRef(0),fe=a.useRef(null),K=a.useRef([]),G=a.useRef(!1),de=a.useRef(null),J=a.useRef(null),be=a.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),Se=a.useRef(!1),me=a.useRef(N),{mounted:ae,setMounted:xe,transitionStatus:ge}=to(B),{openMethod:Z,triggerProps:Fe}=Ls(B),T=gt(()=>new Go({id:H,labelId:void 0,modal:h,multiple:C,itemToStringLabel:x,itemToStringValue:b,isItemEqualToValue:E,value:N,open:B,mounted:ae,transitionStatus:ge,items:S,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:dt,triggerProps:dt,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:ue,setOpen:ue,handleScrollArrowVisibility:ue,onOpenChangeComplete:ue,listRef:ie,popupRef:le,scrollHandlerRef:re,scrollArrowsMountedCountRef:Q,valueRef:fe,valuesRef:K,labelsRef:ce,typingRef:G,selectionRef:be,firstItemTextRef:de,selectedItemTextRef:J,alignItemWithTriggerActiveRef:Se,initialValueRef:me},si)).current,L=T.useState("activeIndex"),ee=T.useState("selectedIndex"),_=T.useState("triggerElement"),q=T.useState("positionerElement"),ye=Hs(Z),Ve=Z??ye,Te=a.useMemo(()=>C?"":ft(N,b),[C,N,b]),ve=a.useMemo(()=>C&&Array.isArray(N)?N.map(Y=>ft(Y,b)):ft(N,b),[C,N,b]),ke=De(_),Ye=te(()=>ve);Ks(ke,H,N,Ye,!A,l);const He=C?Array.isArray(N)&&N.length>0:N!=null&&Te!=="";X(()=>{F(He)},[He,F]),X(function(){const oe=Eo(K.current,N,E,C);oe===null&&(J.current=null),!B&&T.set("selectedIndex",oe)},[C,B,N,E,T]),xo(N,()=>{D(k),O(Js(N,M.initialValue,E)),W.change(N)});const Me=te((Y,oe)=>{c?.(Y,oe),!oe.isCanceled&&(ne(Y),!Y&&(oe.reason===jn||oe.reason===Jo)&&(V(!0),$(!1),I==="onBlur"&&W.commit(N)))}),We=te(()=>{xe(!1),T.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),g?.(!1)});ln({enabled:!y,open:B,ref:le,onComplete(){B||We()}}),a.useImperativeHandle(y,()=>({unmount:We}),[We]);const Ke=te((Y,oe)=>{r?.(Y,oe),!oe.isCanceled&&P(Y)}),at=te(Y=>{const oe=Mo(Y.scrollHeight,Y.clientHeight),Ne=li(Y.scrollTop,oe),nt=Ne>0,ot=Ne<oe;T.set("scrollUpArrowVisible",nt),T.set("scrollDownArrowVisible",ot)}),_e=as({open:B,onOpenChange:Me,elements:{reference:_,floating:q}}),we=Cr(_e,{enabled:!A,event:"mousedown"}),j=ur(_e),se=ms(_e,{enabled:!A,listRef:ie,activeIndex:L,selectedIndex:ee,disabledIndices:Zt,onNavigate(Y){Y===null&&!B||T.set("activeIndex",Y)},focusItemOnHover:w}),pe=hs(_e,{enabled:!A&&(B||!m&&!C),listRef:ce,activeIndex:L,selectedIndex:ee,disabledIndices:Y=>Bs(ie.current[Y]),onMatch(Y){B?T.set("activeIndex",Y):Ke(K.current[Y],Ae(Dt))},onTyping(Y){G.current=Y}}),he=a.useMemo(()=>en(pe.reference,se.reference,j.reference,we.reference,Fe),[we.reference,pe.reference,se.reference,j.reference,Fe]),Le=a.useMemo(()=>en(fr,pe.floating,se.floating,j.floating),[pe.floating,se.floating,j.floating]),Ce=se.item??dt;T.useContextCallback("setValue",Ke),T.useContextCallback("setOpen",Me),T.useContextCallback("handleScrollArrowVisibility",at),T.useContextCallback("onOpenChangeComplete",g),_s(()=>{T.update({popupProps:Le,triggerProps:he})}),T.useSyncedValues({id:H,modal:h,multiple:C,value:N,open:B,mounted:ae,transitionStatus:ge,popupProps:Le,triggerProps:he,items:S,itemToStringLabel:x,itemToStringValue:b,isItemEqualToValue:E,openMethod:Ve});const ut=a.useMemo(()=>({disabled:A,readOnly:m,required:u,multiple:C,highlightItemOnHover:w,itemProps:Ce}),[A,m,u,C,w,Ce]),Xe=Yo(R,W.inputRef),tt=C?void 0:k,Be=a.useMemo(()=>!C||!Array.isArray(N)||!k?null:N.map(Y=>{const oe=ft(Y,b);return Re.jsx("input",{type:"hidden",form:f,name:k,value:oe,disabled:A},oe)}),[C,N,f,k,b,A]);return Re.jsxs(yo.Provider,{value:T,children:[Re.jsx(Ro.Provider,{value:ut,children:Re.jsx(bo.Provider,{value:_e,children:v})}),Re.jsx("input",{...W.getValidationProps(A,{onFocus(){T.state.triggerElement?.focus({focusVisible:!0})},onChange(Y){if(Y.nativeEvent.defaultPrevented||A||m)return;const oe=Y.currentTarget.value,Ne=Ae(Dt,Y.nativeEvent);function nt(){if(C)return;const ot=oe.toLowerCase();let xt=K.current.findIndex(Ut=>ft(Ut,b).toLowerCase()===ot||Io(Ut,x).toLowerCase()===ot);xt===-1&&(xt=K.current.findIndex((Ut,Fo)=>{const xn=ce.current[Fo];return xn!=null&&xn.toLowerCase()===ot}));const hn=K.current[xt];hn!=null&&Ke(hn,Ne)}T.set("forceMount",!0),queueMicrotask(nt)}}),id:H&&tt==null?`${H}-hidden-input`:void 0,form:f,name:tt,autoComplete:p,value:Te,disabled:A,required:u&&!(C&&He),readOnly:m,ref:Xe,style:k?Ko:Xo,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Be]})}function ai(e,t){return e??t}const Et=5;function ui(e,t){const n=fi(t);return e.clientX>=n.left-Et&&e.clientX<=n.right+Et&&e.clientY>=n.top-Et&&e.clientY<=n.bottom+Et}function fi(e){const t=e.getBoundingClientRect(),n=Ie(e);if(Qo)return t;const o=n.getComputedStyle(e,"::before"),r=n.getComputedStyle(e,"::after");if(!(o.content!=="none"||r.content!=="none"))return t;const i=parseFloat(o.width)||0,c=parseFloat(o.height)||0,l=parseFloat(r.width)||0,f=parseFloat(r.height)||0,p=Math.max(t.width,i,l),d=Math.max(t.height,c,f),m=p-t.width,u=d-t.height;return{left:t.left-m/2,right:t.right+m/2,top:t.top-u/2,bottom:t.bottom+u/2}}const di="data-popup-side",pi=400,gi={...dr,...js,popupSide:e=>e?{[di]:e}:null,value:()=>null},Hi=a.forwardRef(function(t,n){const{render:o,className:r,id:s,disabled:i=!1,nativeButton:c=!0,style:l,...f}=t,{setTouched:p,setFocused:d,validationMode:m,validation:u,state:h,disabled:y}=gn(),{labelId:R}=So(),g=lt(),{readOnly:S,required:C,disabled:x}=pn(),b=y||x||i,E=g.useState("open"),w=g.useState("mounted"),v=g.useState("value"),D=g.useState("triggerProps"),O=g.useState("positionerElement"),V=g.useState("listElement"),$=g.useState("popupSide"),M=g.useState("id"),F=g.useState("labelId"),U=g.useState("hasSelectedValue"),z=w&&O?$:null,W=s??M,I=ai(R,F);vo({id:s});const H=De(O),A=a.useRef(null),{getButtonProps:k,buttonRef:N}=Kn({disabled:b,native:c}),P=g.useStateSetter("triggerElement"),B=bt(),ne=bt(),ie=bt();a.useEffect(()=>{if(E)return ie.start(pi,()=>{g.context.selectionRef.current.allowUnselectedMouseUp=!0,g.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{ie.clear()};g.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},ne.clear()},[E,g,ne,ie]);const ce=en(D,{id:W,role:"combobox","aria-expanded":E,"aria-haspopup":"listbox","aria-controls":E?V?.id??zn(O)?.id:void 0,"aria-labelledby":I,"aria-readonly":S||void 0,"aria-required":C||void 0,tabIndex:b?-1:0,onFocus(Q){d(!0),E&&g.context.alignItemWithTriggerActiveRef.current&&g.context.setOpen(!1,Ae(Dt,Q.nativeEvent)),B.start(0,()=>{g.set("forceMount",!0)})},onBlur(Q){Ge(O,Q.relatedTarget)||(p(!0),d(!1),m==="onBlur"&&u.commit(v))},onMouseDown(Q){if(E)return;const fe=rt(Q.currentTarget);function K(G){if(!A.current)return;const de=G.target;Ge(A.current,de)||Ge(H.current,de)||ui(G,A.current)||g.context.setOpen(!1,Ae(Zo,G))}ne.start(0,()=>{fe.addEventListener("mouseup",K,{once:!0})})}},f,k),le=u.getValidationProps(b,ce);le.role="combobox";const re={...h,open:E,disabled:b,value:v,readOnly:S,popupSide:z,placeholder:!U};return ct("button",t,{ref:[n,A,N,P],state:re,stateAttributesMapping:gi,props:le})}),mi={value:()=>null},_i=a.forwardRef(function(t,n){const{className:o,render:r,children:s,placeholder:i,style:c,...l}=t,f=lt(),p=f.useState("value"),d=f.useState("items"),m=f.useState("itemToStringLabel"),u=f.useState("hasSelectedValue"),h=!u&&i!=null&&s==null,y=f.useState("hasNullItemLabel",h),R={value:p,placeholder:!u};let g=null;return typeof s=="function"?g=s(p):s!=null?g=s:h&&!y?g=i:Array.isArray(p)?g=ri(p,d,m):g=To(p,d,m),ct("span",t,{state:R,ref:[n,f.context.valueRef],props:[{children:g},l],stateAttributesMapping:mi})}),Bi=a.forwardRef(function(t,n){const o=lt(),r=o.useState("mounted"),s=o.useState("forceMount");return r||s?Re.jsx(er,{ref:n,...t}):null}),Oo=a.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function hi(){return a.useContext(Oo)}function xi(e){const{children:t,elementsRef:n,labelsRef:o,onMapChange:r}=e,s=te(r),[,i]=a.useState(!1),c=gt(Ri).current,l=gt(yi).current,f=a.useRef(0),p=a.useRef(!0),d=a.useRef(null),m=a.useRef(null),u=te(()=>{p.current||(p.current=!0,i(b=>!b))}),h=te((b,E)=>{l.set(b,E),u()}),y=te(b=>{l.delete(b),u()}),R=te(b=>{const E=new Map;return n.current.length=0,o&&(o.current.length=0),b.forEach(w=>{E.set(w.element,{...w.registration.metadata??{},index:w.index}),n.current[w.index]=w.element,o&&(o.current[w.index]=w.registration.label!==void 0?w.registration.label:w.registration.textRef?.current?.textContent??w.element.textContent)}),f.current=n.current.length,E});function g(b){if(m.current?.disconnect(),m.current=null,typeof MutationObserver!="function"||b.length<2)return;const E=new MutationObserver(v=>{if(!Si(v))return;let D=null;for(const O of b)if(O.isConnected){if(D&&Po(D,O)>0){E.disconnect(),u();return}D=O}});m.current=E;const w=new Set;for(let v=1;v<b.length;v+=1){const D=wi(b[v-1],b[v]);D&&w.add(D)}w.forEach(v=>E.observe(v,{childList:!0}))}const S=te(()=>{const[b,E]=bi(l),w=R(b),v=d.current,D=!v||v.length!==b.length||b.some((O,V)=>{const $=v[V];return O.index!==$.index||O.element!==$.element||O.registration.index!==$.registration.index||O.registration.metadata!==$.registration.metadata});g(E),d.current=b,p.current=!1,D&&(c.forEach(O=>O(w)),s(w))});X(()=>(!p.current&&d.current&&R(d.current),()=>{n.current=[],o&&(o.current=[])}),[n,o,R]),X(()=>{p.current&&S()}),X(()=>()=>{m.current?.disconnect(),p.current=!0},[]);const C=te(b=>(c.add(b),()=>{c.delete(b)})),x=a.useMemo(()=>({register:h,unregister:y,subscribeMapChange:C,nextIndexRef:f}),[h,y,C,f]);return Re.jsx(Oo.Provider,{value:x,children:t})}function yi(){return new Map}function Ri(){return new Set}function bi(e){const t=new Set,n=[],o=[];e.forEach((s,i)=>{if(!i.isConnected)return;const c=s.index,l={index:c??-1,element:i,registration:s};c===null?o.push(l):c>=0&&(t.add(c),n.push(l))});let r=0;return o.sort((s,i)=>Po(s.element,i.element)),o.forEach(s=>{for(;t.has(r);)r+=1;s.index=r,n.push(s),r+=1}),t.size>0&&n.sort((s,i)=>s.index-i.index),[n,o.map(s=>s.element)]}function wi(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function Si(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 Po(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}const Lo=a.createContext(void 0);function vi(){const e=a.useContext(Lo);if(!e)throw new Error(ht(59));return e}function Ht(e,t){e&&Object.assign(e.style,t)}const Ci={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},Ei={position:"fixed"},Wi=a.forwardRef(function(t,n){const{anchor:o,className:r,render:s,positionMethod:i,side:c,align:l,sideOffset:f,alignOffset:p,collisionBoundary:d="clipping-ancestors",collisionPadding:m,arrowPadding:u,sticky:h,disableAnchorTracking:y,alignItemWithTrigger:R=!0,collisionAvoidance:g=tr,style:S,...C}=t,x=lt(),b=wo(),E=x.useState("open"),w=x.useState("mounted"),v=x.useState("modal"),D=x.useState("value"),O=x.useState("openMethod"),V=x.useState("positionerElement"),$=x.useState("triggerElement"),M=x.useState("isItemEqualToValue"),F=x.useState("transitionStatus"),U=a.useRef(null),z=a.useRef(null),[W,I]=a.useState(R),H=w&&W&&O!=="touch";!w&&W!==R&&I(R),a.useImperativeHandle(x.context.alignItemWithTriggerActiveRef,()=>H),Fs((H||v)&&E,O==="touch",V,$);const A=Is({anchor:o,floatingRootContext:b,positionMethod:i,mounted:w,side:c,sideOffset:f,align:l,alignOffset:p,arrowPadding:u,collisionBoundary:d,collisionPadding:m,sticky:h,disableAnchorTracking:y??H,collisionAvoidance:g,keepMounted:!0}),k=H?"none":A.side,N=H?Ei:A.positionerStyles,P={open:E,side:k,align:A.align,anchorHidden:A.anchorHidden};X(()=>{x.set("popupSide",A.side)},[x,A.side]);const B=x.useStateSetter("positionerElement"),ne=Ms(t,P,{styles:N,transitionStatus:F,props:C,refs:[n,B],hidden:!w,inert:!E}),ie=a.useRef(0),ce=te(re=>{if(x.context.valuesRef.current.length===0)return;const Q=ie.current;ie.current=re.size;const fe=Ae(Dt);if(Q!==0&&!x.state.multiple&&D!==null&&Ot(x.context.valuesRef.current,D,M)===-1){const G=x.context.initialValueRef.current,J=G!=null&&Ot(x.context.valuesRef.current,G,M)!==-1?G:null;x.context.setValue(J,fe),J===null&&(x.set("selectedIndex",null),x.context.selectedItemTextRef.current=null)}if(Q!==0&&x.state.multiple&&Array.isArray(D)){const K=D.filter(G=>Ot(x.context.valuesRef.current,G,M)!==-1);K.length!==D.length&&(x.context.setValue(K,fe),K.length===0&&(x.set("selectedIndex",null),x.context.selectedItemTextRef.current=null))}if(E&&H){x.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const K={height:""};Ht(V,K),Ht(x.context.popupRef.current,K)}}),le=a.useMemo(()=>({...A,side:k,alignItemWithTriggerActive:H,setControlledAlignItemWithTrigger:I,scrollUpArrowRef:U,scrollDownArrowRef:z}),[A,k,H,I]);return Re.jsx(xi,{elementsRef:x.context.listRef,labelsRef:x.context.labelsRef,onMapChange:ce,children:Re.jsxs(Lo.Provider,{value:le,children:[w&&v&&Re.jsx(pr,{inert:nr(!E),cutout:$}),ne]})})}),At="base-ui-disable-scrollbar",Vn={className:At,getElement(e){return Re.jsx("style",{nonce:e,href:At,precedence:"base-ui:low",children:`.${At}{scrollbar-width:none}.${At}::-webkit-scrollbar{display:none}`})}},Ai=a.createContext(void 0),Ii={disableStyleElements:!1};function Ti(){return a.useContext(Ai)??Ii}const kn="--transform-origin",Mi={...eo,...Xn},Ni=a.forwardRef(function(t,n){const{render:o,className:r,style:s,finalFocus:i,...c}=t,l=lt(),{multiple:f,readOnly:p,highlightItemOnHover:d}=pn(),m=wo(),{side:u,align:h,alignItemWithTriggerActive:y,isPositioned:R,setControlledAlignItemWithTrigger:g}=vi(),S=ks()!=null,C=go(),{nonce:x,disableStyleElements:b}=Ti(),E=l.useState("id"),w=l.useState("open"),v=l.useState("openMethod"),D=l.useState("mounted"),O=l.useState("popupProps"),V=l.useState("transitionStatus"),$=l.useState("triggerElement"),M=l.useState("positionerElement"),F=l.useState("listElement"),U=a.useRef(!1),z=a.useRef(!1),W=a.useRef({}),I=Pt(),H=te(P=>{if(!M||!l.context.popupRef.current||!z.current)return;const B=M.style.top==="0px",ne=M.style.bottom==="0px";if(U.current||!y||!B&&!ne){l.context.handleScrollArrowVisibility(P);return}const ie=_n(M),ce=Rt(M.getBoundingClientRect().height,"y",ie),le=rt(M),re=Ie(M),Q=re.getComputedStyle(M),fe=parseFloat(Q.marginTop),K=parseFloat(Q.marginBottom),G=Hn(re.getComputedStyle(l.context.popupRef.current)),de=Math.min(le.documentElement.clientHeight-fe-K,G),J=P.scrollTop,be=It(P);let Se=null;const me=Z=>{M.style.height=`${Z}px`},ae=B?be-J:J,xe=Math.min(ce+ae,de);if(ae<=Ue){const Z=yt(ae,0,de-ce);Z>0&&me(ce+Z),P.scrollTop=B?be:0,de-(ce+Z)<=Ue&&(U.current=!0),l.context.handleScrollArrowVisibility(P);return}if(de-xe>Ue)Se=B?1/0:0;else if(ne&&J<be){const Z=ce+ae-de;Se=J-(ae-Z)}const ge=Math.ceil(xe);if(ge!==0&&me(ge),Se!=null){const Z=yt(Se,0,It(P));Math.abs(P.scrollTop-Z)>Ue&&(P.scrollTop=Z)}ge>=de-Ue&&(U.current=!0),l.context.handleScrollArrowVisibility(P)});a.useImperativeHandle(l.context.scrollHandlerRef,()=>H,[H]),ln({open:w,ref:l.context.popupRef,onComplete(){w&&l.context.onOpenChangeComplete(!0)}});const A={open:w,transitionStatus:V,side:u,align:h};X(()=>{!M||!l.context.popupRef.current||Object.keys(W.current).length||(W.current={top:M.style.top||"0",left:M.style.left||"0",right:M.style.right,height:M.style.height,bottom:M.style.bottom,minHeight:M.style.minHeight,maxHeight:M.style.maxHeight,marginTop:M.style.marginTop,marginBottom:M.style.marginBottom})},[l,M]),X(()=>{w||y||(z.current=!1,U.current=!1,Ht(M,W.current))},[w,y,M]),X(()=>{const P=l.context.popupRef.current;if(!w||!$||!M||!P||y&&!R||l.state.transitionStatus==="ending")return;if(z.current=!0,P.style.removeProperty(kn),!y){I.request(()=>l.context.handleScrollArrowVisibility(F||P));return}const B=Oi(P);try{let ne=l.context.selectedItemTextRef.current;ne?.isConnected||(ne=!l.select("hasSelectedValue")&&l.context.firstItemTextRef.current?.isConnected?l.context.firstItemTextRef.current:null);const ie=l.context.valueRef.current,ce=Ie(M),le=ce.getComputedStyle(M),re=ce.getComputedStyle(P),Q=rt($),fe=_n($),K=Tt($.getBoundingClientRect(),fe),G=Tt(M.getBoundingClientRect(),fe),de=K.height,J=F||P,be=J.scrollHeight,Se=parseFloat(re.borderBottomWidth),me=parseFloat(le.marginTop)||10,ae=parseFloat(le.marginBottom)||10,xe=parseFloat(le.minHeight)||100,ge=Hn(re),Z=5,Fe=5,T=20,L=Q.documentElement.clientHeight-me-ae,ee=Q.documentElement.clientWidth,_=L-K.bottom+de;let q,ye=C==="rtl"?K.right-G.width:K.left,Ve=0;if(ne&&ie){const we=Tt(ie.getBoundingClientRect(),fe);q=Tt(ne.getBoundingClientRect(),fe),ye=G.left+(C==="rtl"?we.right-q.right:we.left-q.left);const j=we.top-K.top+we.height/2;Ve=q.top-G.top+q.height/2-j}const Te=_+Ve+ae+Se;let ve=Math.min(L,Te);const ke=L-me-ae,Ye=Te-ve,He=ee-Fe;M.style.left=`${yt(ye,Z,He-G.width)}px`,M.style.height=`${ve}px`,M.style.maxHeight="none",M.style.marginTop=`${me}px`,M.style.marginBottom=`${ae}px`,P.style.height="100%";const Me=It(J),We=Ye>=Me-Ue;We&&(ve=Math.min(L,G.height)-(Ye-Me));const Ke=K.top<T||K.bottom>L-T||Math.ceil(ve)+Ue<Math.min(be,xe),at=(ce.visualViewport?.scale??1)!==1&&qn;if(Ke||at){Ht(M,W.current),g(!1);return}const _e=Math.max(xe,ve);if(We){const we=Math.max(0,L-Te);M.style.top=G.height>=ke?"0":`${we}px`,M.style.height=`${ve}px`,J.scrollTop=It(J)}else M.style.bottom="0",J.scrollTop=Ye;if(q){const we=G.top,j=G.height,se=q.top+q.height/2,pe=yt(j>0?(se-we)/j*100:50,0,100);P.style.setProperty(kn,`50% ${pe}%`)}(_e===L||ve>=ge)&&(U.current=!0),l.context.handleScrollArrowVisibility(J),d&&l.state.selectedIndex===null&&l.state.activeIndex===null&&l.context.listRef.current[0]!=null&&l.set("activeIndex",0)}finally{B()}},[l,w,M,$,y,g,I,F,d,C,R]),a.useEffect(()=>{if(!y||!M||!w)return;const P=Ie(M);function B(ne){l.context.setOpen(!1,Ae(rr,ne))}return or(P,"resize",B)},[l,y,M,w]);const k={...F?{role:"presentation"}:{role:"listbox","aria-multiselectable":f||void 0,"aria-readonly":p||void 0,id:`${E}-list`},onKeyDown(P){S&&mr.has(P.key)&&P.stopPropagation()},onScroll(P){F||H(P.currentTarget)},...y&&{style:F?{height:"100%"}:Ci},className:!F&&y?Vn.className:void 0},N=ct("div",t,{ref:[n,l.context.popupRef],state:A,stateAttributesMapping:Mi,props:[O,k,ho(V),c]});return Re.jsxs(a.Fragment,{children:[!b&&Vn.getElement(x),Re.jsx(gr,{context:m,modal:!1,disabled:!D,openInteractionType:v,returnFocus:i,restoreFocus:!0,children:N})]})});function Hn(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function It(e){return Mo(e.scrollHeight,e.clientHeight)}function _n(e){return uo.getScale(e)}function Rt(e,t,n){return e/n[t]}function Tt(e,t){return wt({x:Rt(e.x,"x",t),y:Rt(e.y,"y",t),width:Rt(e.width,"x",t),height:Rt(e.height,"y",t)})}const Bn=[["transform","none"],["scale","1"],["translate","0 0"]];function Oi(e){const{style:t}=e,n={};for(const[o,r]of Bn)n[o]=t.getPropertyValue(o),t.setProperty(o,r,"important");return()=>{for(const[o]of Bn){const r=n[o];r?t.setProperty(o,r):t.removeProperty(o)}}}function Pi(e={}){const{guess:t,label:n,metadata:o,textRef:r,index:s}=e,{register:i,unregister:c,subscribeMapChange:l,nextIndexRef:f}=hi(),p=a.useRef(-1),[d,m]=a.useState(s==null&&t?()=>{if(p.current===-1){const R=f.current;f.current+=1,p.current=R}return p.current}:-1),u=s??d,h=a.useRef(null),y=a.useCallback(R=>{const g=h.current;g&&c(g),h.current=R,R&&i(R,{metadata:o??null,index:s??null,label:n,textRef:r})},[s,i,c,o,n,r]);return X(()=>{if(s==null)return l(R=>{const g=h.current?R.get(h.current)?.index:null;g!=null&&m(g)})},[s,l]),{ref:y,index:u}}const Do=a.createContext(void 0);function mn(){const e=a.useContext(Do);if(!e)throw new Error(ht(57));return e}const $i=a.memo(a.forwardRef(function(t,n){const{render:o,className:r,style:s,value:i=null,label:c,disabled:l=!1,nativeButton:f=!1,...p}=t,d=a.useRef(null),m=Pi({guess:!0,label:c,textRef:d}),u=lt(),{itemProps:h,multiple:y,disabled:R,readOnly:g}=pn(),S=R||l,C=u.useState("isActive",m.index),x=u.useState("open"),b=u.useState("isSelected",i),E=u.useState("isSelectedByFocus",m.index),w=u.useState("isItemEqualToValue"),v=m.index,D=a.useRef(null);X(()=>{const A=u.context.valuesRef.current;return A[v]=i,()=>{delete A[v]}},[v,i,u]),X(()=>{const A=u.state.value,k=u.state.selectedIndex;let N=k,P;y&&Array.isArray(A)?(N=Zs(v,i,u.context.valuesRef.current,A,w,k),P=N===v,v===k&&!P&&(u.context.selectedItemTextRef.current=null)):(P=A!==void 0&&it(i,A,w),P&&(N=v)),u.set("selectedIndex",N),P&&d.current&&(u.context.selectedItemTextRef.current=d.current)},[v,y,w,u,i]);const O=a.useRef("mouse"),V=a.useRef(!1),{getButtonProps:$,buttonRef:M}=Kn({disabled:S,focusableWhenDisabled:!0,native:f,composite:!0}),F={disabled:S,selected:b,highlighted:C};function U(A){if(R||g)return;const k=u.state.value;if(y){const N=Array.isArray(k)?k:[],P=b?ei(N,i,w):[...N,i];u.context.setValue(P,Ae(qt,A))}else u.context.setValue(i,Ae(qt,A)),u.context.setOpen(!1,Ae(qt,A))}function z(){u.context.selectionRef.current.dragY=0}const W={role:"option","aria-selected":b,tabIndex:x&&C?0:-1,onKeyDown(A){u.set("activeIndex",v),A.key===" "&&u.context.typingRef.current&&A.preventDefault()},onClick(A){const k=O.current!=="touch",N=A.nativeEvent.pointerType,P=k&&Zn(A.nativeEvent)&&(N!==void 0||C),B=k&&!P&&!V.current;V.current=!1,!(S||B)&&U(A.nativeEvent)},onPointerEnter(A){O.current=A.pointerType},onPointerMove(A){if(A.pointerType==="mouse"&&A.buttons===1){const k=u.context.selectionRef.current;k.dragY+=A.movementY,k.dragY**2>=64&&(k.allowUnselectedMouseUp=!0)}},onPointerDown(A){O.current=A.pointerType,V.current=!0,z()},onMouseUp(){if(z(),S||O.current==="touch"||V.current)return;const A=!u.context.selectionRef.current.allowSelectedMouseUp&&b,k=!u.context.selectionRef.current.allowUnselectedMouseUp&&!b;A||k||(V.current=!0,D.current?.click(),V.current=!1)}},I=ct("div",t,{ref:[M,n,m.ref,D],state:F,props:[h,W,p,$]}),H=a.useMemo(()=>({selected:b,index:v,textRef:d,selectedByFocus:E}),[b,v,d,E]);return Re.jsx(Do.Provider,{value:H,children:I})})),Ui=a.forwardRef(function(t,n){const{selected:o}=mn();return t.keepMounted||o?Re.jsx(Li,{...t,ref:n}):null}),Li=a.memo(a.forwardRef((e,t)=>{const{render:n,className:o,style:r,keepMounted:s,...i}=e,{selected:c}=mn(),l=a.useRef(null),{transitionStatus:f,setMounted:p}=to(c),m=ct("span",e,{ref:[t,l],state:{selected:c,transitionStatus:f},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:Xn});return ln({batch:!0,enabled:!c,open:c,ref:l,onComplete(){c||p(!1)}}),m})),zi=a.memo(a.forwardRef(function(t,n){const{index:o,textRef:r,selectedByFocus:s}=mn(),i=lt(),{render:c,className:l,style:f,...p}=t,d=a.useCallback(u=>{u&&(o===0&&(i.context.firstItemTextRef.current=u),s&&(i.context.selectedItemTextRef.current=u))},[i,o,s]);return ct("div",t,{ref:[d,n,r],props:p})}));export{ho as A,Vi as C,Ci as L,ki as S,pn as a,vi as b,Hi as c,_i as d,Bi as e,Wi as f,Ni as g,$i as h,Ui as i,zi as j,js as k,ci as l,gn as m,So as n,vo as o,Fn as p,Ks as q,xo as r,Vn as s,Cr as t,lt as u,Ps as v,Is as w,Fs as x,Ms as y,ks as z};