tokentracker-cli 0.91.3 → 0.93.0

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 (112) hide show
  1. package/README.de.md +7 -4
  2. package/README.ja.md +6 -3
  3. package/README.ko.md +6 -3
  4. package/README.md +8 -5
  5. package/README.zh-CN.md +6 -3
  6. package/dashboard/dist/assets/{AchievementBadge-LHOuekQ3.js → AchievementBadge-BJRW8Tr1.js} +1 -1
  7. package/dashboard/dist/assets/{AchievementsPage-DNzeYWBl.js → AchievementsPage-ChEJSRiQ.js} +2 -2
  8. package/dashboard/dist/assets/{AchievementsSection-Ch5dImt8.js → AchievementsSection-CUaUhyL6.js} +1 -1
  9. package/dashboard/dist/assets/{BadgeDetailModal-CuikWkUy.js → BadgeDetailModal-CN7MTGyp.js} +1 -1
  10. package/dashboard/dist/assets/BotAnimated-Dr4FOdii.js +1 -0
  11. package/dashboard/dist/assets/{Card-Chwjmxjz.js → Card-DMxCaW9y.js} +1 -1
  12. package/dashboard/dist/assets/ClawdAnimated-DpscEjzV.js +2 -0
  13. package/dashboard/dist/assets/{CommandPalette-BMwuSEWM.js → CommandPalette-CQGglOYQ.js} +1 -1
  14. package/dashboard/dist/assets/{CommunityStatsModal-eEDF-xn8.js → CommunityStatsModal-Venaet7m.js} +1 -1
  15. package/dashboard/dist/assets/{ConfirmModal-Be7f6XdL.js → ConfirmModal-BHoo6GZs.js} +1 -1
  16. package/dashboard/dist/assets/{Controls-CtBFPCBY.js → Controls-CaNOFGCk.js} +1 -1
  17. package/dashboard/dist/assets/{DashboardPage-M0p-SU-f.js → DashboardPage-Dw0RrlPj.js} +1 -1
  18. package/dashboard/dist/assets/{DevicePage-CAfcUond.js → DevicePage-21SUMJc6.js} +1 -1
  19. package/dashboard/dist/assets/{DialogClose-kd1wIljN.js → DialogClose-DnSGAKIz.js} +1 -1
  20. package/dashboard/dist/assets/DialogDescription-DyaMB47K.js +1 -0
  21. package/dashboard/dist/assets/{DialogTitle-DhB-tbnZ.js → DialogTitle-CiPqqI8_.js} +1 -1
  22. package/dashboard/dist/assets/{FadeIn-B8eRWBdy.js → FadeIn-Dfc9sjiG.js} +1 -1
  23. package/dashboard/dist/assets/{HeaderGithubStar-DmWep8uP.js → HeaderGithubStar-DXxjTnOW.js} +1 -1
  24. package/dashboard/dist/assets/{HoverTooltip-DDyTZli0.js → HoverTooltip-DjR_uW9N.js} +1 -1
  25. package/dashboard/dist/assets/{IpCheckPage-CN8hYm4o.js → IpCheckPage-CUoutDvP.js} +1 -1
  26. package/dashboard/dist/assets/{LandingPage-B3cHASqK.js → LandingPage-CFlAug6D.js} +2 -2
  27. package/dashboard/dist/assets/{LeaderboardAvatar-CEcLXrJL.js → LeaderboardAvatar-CYoNgJ16.js} +1 -1
  28. package/dashboard/dist/assets/{LeaderboardPage-H6HW9hon.js → LeaderboardPage-S9BvOGn-.js} +2 -2
  29. package/dashboard/dist/assets/{LeaderboardProfileModal-B_5PyjRA.js → LeaderboardProfileModal-D5Fd1T4y.js} +4 -4
  30. package/dashboard/dist/assets/{LeaderboardProfilePage-DR9KWLWv.js → LeaderboardProfilePage-DQ9OnTBZ.js} +1 -1
  31. package/dashboard/dist/assets/LimitsPage-CkW9RNDs.js +5 -0
  32. package/dashboard/dist/assets/{LocalOnlyNotice-DuTdva_n.js → LocalOnlyNotice-BC236cdv.js} +1 -1
  33. package/dashboard/dist/assets/{LoginCard-DOL3osrj.js → LoginCard-CKePPmoP.js} +1 -1
  34. package/dashboard/dist/assets/{LoginModal-DBmaQL2L.js → LoginModal-Z6HTE1rD.js} +1 -1
  35. package/dashboard/dist/assets/{LoginPage-Dk08VrkC.js → LoginPage-oCM0aV5_.js} +1 -1
  36. package/dashboard/dist/assets/PetPage-2vhNPBD2.js +1 -0
  37. package/dashboard/dist/assets/{PopoverPopup-C1fJZ4qt.js → PopoverPopup-BWZpTgX_.js} +1 -1
  38. package/dashboard/dist/assets/{ProviderIcon-FfLD-f73.js → ProviderIcon-DzpcY7dM.js} +1 -1
  39. package/dashboard/dist/assets/{ResetPasswordPage-Bg7eVc6L.js → ResetPasswordPage-CDXZRCcV.js} +1 -1
  40. package/dashboard/dist/assets/{SegmentedControl-CFNHcUz7.js → SegmentedControl-DTUalF_Q.js} +1 -1
  41. package/dashboard/dist/assets/{Select-B0Q0eDcJ.js → Select-Bh-c5WZM.js} +1 -1
  42. package/dashboard/dist/assets/{SelectItemText-BVbLYxSQ.js → SelectItemText-D7ecykkn.js} +1 -1
  43. package/dashboard/dist/assets/{ServiceStatusPage-DCZH2kz5.js → ServiceStatusPage-B-3Nj7Yw.js} +1 -1
  44. package/dashboard/dist/assets/{SessionsPage-DO5Et7ss.js → SessionsPage-C4XeRHCn.js} +1 -1
  45. package/dashboard/dist/assets/{SettingsPage-afgxGfzT.js → SettingsPage-B-2tu3Gx.js} +2 -2
  46. package/dashboard/dist/assets/{SkillsPage-DDKiHCF7.js → SkillsPage-CIjJkI3G.js} +1 -1
  47. package/dashboard/dist/assets/{TokenGalaxy-DV1Xoe5z.js → TokenGalaxy-CmhqWAxg.js} +1 -1
  48. package/dashboard/dist/assets/{ToolbarRootContext-DNckd9Qz.js → ToolbarRootContext-beEFe6Jn.js} +1 -1
  49. package/dashboard/dist/assets/{TrendMonitor-CliMJxCC.js → TrendMonitor-DUenZHaf.js} +1 -1
  50. package/dashboard/dist/assets/{WidgetsPage-BrwG6YMM.js → WidgetsPage-C5f1GlXu.js} +1 -1
  51. package/dashboard/dist/assets/{WrappedPage-Ft9YJd0D.js → WrappedPage-CbV2-x-X.js} +1 -1
  52. package/dashboard/dist/assets/{__vite-browser-external-C6_BtvDo.js → __vite-browser-external-BE7h4Ou0.js} +19 -10
  53. package/dashboard/dist/assets/__vite-browser-external-CiR9-j4L.css +1 -0
  54. package/dashboard/dist/assets/{agent-logos-yYNu1ZUy.js → agent-logos-ChlriZKC.js} +1 -1
  55. package/dashboard/dist/assets/{arrow-up-right-B_K57Vbg.js → arrow-up-right-CXeIA60k.js} +1 -1
  56. package/dashboard/dist/assets/{check-xH63o2xJ.js → check-B_20gPQX.js} +1 -1
  57. package/dashboard/dist/assets/{chevron-right-D3F2rAfr.js → chevron-right-CQCceB2r.js} +1 -1
  58. package/dashboard/dist/assets/{copy-WPfJGGI0.js → copy-Ba1Oh3iI.js} +1 -1
  59. package/dashboard/dist/assets/{download-BgtWtEXI.js → download-B5EQJQ9n.js} +1 -1
  60. package/dashboard/dist/assets/{external-link-DSHGoZRM.js → external-link-D9GSJ4tn.js} +1 -1
  61. package/dashboard/dist/assets/{flame-CNGl6Qac.js → flame-PKC57o-h.js} +1 -1
  62. package/dashboard/dist/assets/{format-tokens-jVm2UX7Y.js → format-tokens-E_eZCw2b.js} +1 -1
  63. package/dashboard/dist/assets/{icons-B1JZg-Id.js → icons-DXrj24F-.js} +1 -1
  64. package/dashboard/dist/assets/{index-CUFHknAy.js → index-CPbjzYzk.js} +1 -1
  65. package/dashboard/dist/assets/{index-BjD81Qce.js → index-ldDiPXbH.js} +1 -1
  66. package/dashboard/dist/assets/{index-BTZibjLi.js → index-pSCG6bXN.js} +1 -1
  67. package/dashboard/dist/assets/{info-CLM460KM.js → info-Dhj9LcZm.js} +1 -1
  68. package/dashboard/dist/assets/{limits-providers-CFO4O1qh.js → limits-providers-BWOIsV_O.js} +1 -1
  69. package/dashboard/dist/assets/{link-2-BHOsUnAI.js → link-2-Bbzo_bnV.js} +1 -1
  70. package/dashboard/dist/assets/{loader-circle-CgcIQi92.js → loader-circle-CfkDmJbH.js} +1 -1
  71. package/dashboard/dist/assets/{maximize-2-DvqfuJEA.js → maximize-2-BQkNBiZ-.js} +1 -1
  72. package/dashboard/dist/assets/{modifiers.esm-CNiwIkPh.js → modifiers.esm-BhhAKBAH.js} +1 -1
  73. package/dashboard/dist/assets/{monitor-smartphone-BLutpxrG.js → monitor-smartphone-BO4o9Fi6.js} +1 -1
  74. package/dashboard/dist/assets/{provider-display-BxIgWUEa.js → provider-display-DnMOck0l.js} +2 -2
  75. package/dashboard/dist/assets/{react-CM-ozVnh.js → react-DoVntgJI.js} +1 -1
  76. package/dashboard/dist/assets/{search-4T07INKt.js → search-CQOHSZGo.js} +1 -1
  77. package/dashboard/dist/assets/{skills-api-EXMD3LD1.js → skills-api-DldHXWSv.js} +1 -1
  78. package/dashboard/dist/assets/skins-C8EyB85e.js +1 -0
  79. package/dashboard/dist/assets/{sortable.esm-jC6mPJiL.js → sortable.esm-l0p6v-ts.js} +1 -1
  80. package/dashboard/dist/assets/{store-CvSEdgf2.js → store-D9UN_t1a.js} +1 -1
  81. package/dashboard/dist/assets/{terminal-D9fyE2pP.js → terminal-Cvwjd-k9.js} +1 -1
  82. package/dashboard/dist/assets/{trash-2-QLUsAY3l.js → trash-2-b2Z7B317.js} +1 -1
  83. package/dashboard/dist/assets/{use-community-stats-Chrt3kpU.js → use-community-stats-DDhp2Qat.js} +1 -1
  84. package/dashboard/dist/assets/{use-limits-display-prefs-BJJd750e.js → use-limits-display-prefs-Cqtye4Ji.js} +1 -1
  85. package/dashboard/dist/assets/{use-ordered-list-BBJp5lFv.js → use-ordered-list-CLogKuZq.js} +1 -1
  86. package/dashboard/dist/assets/use-reduced-motion-CkoMrH9Y.js +1 -0
  87. package/dashboard/dist/assets/{use-session-efficiency-pref-BXbvx2Ht.js → use-session-efficiency-pref-mSDx6-SO.js} +1 -1
  88. package/dashboard/dist/assets/{use-transform-BVp_MUsU.js → use-transform-Bt5K4W-2.js} +1 -1
  89. package/dashboard/dist/assets/{use-usage-limits-Dk3EkeIs.js → use-usage-limits-Cm2Bjsp0.js} +1 -1
  90. package/dashboard/dist/assets/{useCurrency-Bi88Sd__.js → useCurrency-DyJG5xmN.js} +1 -1
  91. package/dashboard/dist/assets/{useScrollLock-if34g2H-.js → useScrollLock-BEpIOp1F.js} +1 -1
  92. package/dashboard/dist/assets/{useTokenFormat-C2cz-5qJ.js → useTokenFormat-Cbj7RbpO.js} +1 -1
  93. package/dashboard/dist/assets/{zap-D1yHmcQR.js → zap-CUYx_JsZ.js} +1 -1
  94. package/dashboard/dist/brand-logos/dots.png +0 -0
  95. package/dashboard/dist/brand-logos/pi.svg +8 -15
  96. package/dashboard/dist/index.html +31 -28
  97. package/dashboard/dist/ip-check.html +2 -2
  98. package/dashboard/dist/leaderboard.html +2 -2
  99. package/dashboard/dist/llms.txt +3 -2
  100. package/dashboard/dist/share.html +2 -2
  101. package/package.json +5 -3
  102. package/src/commands/init.js +1 -0
  103. package/src/lib/opencode-go-limits.js +33 -15
  104. package/src/lib/pet-packages.js +45 -1
  105. package/src/lib/pricing/index.js +17 -0
  106. package/src/lib/pricing/seed-snapshot.json +1 -1
  107. package/dashboard/dist/assets/ClawdAnimated-BdB7aycS.js +0 -1
  108. package/dashboard/dist/assets/DialogDescription-CjJLpfCL.js +0 -1
  109. package/dashboard/dist/assets/LimitsPage-Da0hRxO_.js +0 -5
  110. package/dashboard/dist/assets/PetPage-BbCIdpzx.js +0 -1
  111. package/dashboard/dist/assets/__vite-browser-external-CRYifSM4.css +0 -1
  112. package/dashboard/dist/assets/use-reduced-motion-BvXZCGFC.js +0 -1
@@ -1 +0,0 @@
1
- import{r,j as f}from"./__vite-browser-external-C6_BtvDo.js";function p(e){const n=String(e||"").trim().toLowerCase();return/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/.test(n)?n:"clawd"}const C=.84;function L(e){return p(e)==="clawd"?C:1}const z={idle:{row:0,durations:[280,110,110,140,140,320]},"running-right":{row:1,durations:[120,120,120,120,120,120,120,220]},"running-left":{row:2,durations:[120,120,120,120,120,120,120,220]},waving:{row:3,durations:[140,140,140,280]},jumping:{row:4,durations:[140,140,140,140,280]},failed:{row:5,durations:[140,140,140,140,140,140,140,240]},waiting:{row:6,durations:[150,150,150,150,150,260]},running:{row:7,durations:[120,120,120,120,120,220]},review:{row:8,durations:[150,150,150,150,150,280]}};function T(e){return["error","disconnected","working-overheated"].includes(e)?"failed":["happy","waking","mini-happy","jumping"].includes(e)?"jumping":["working-typing","working-ultrathink","working-juggling","running"].includes(e)?"running":["working-thinking","working-wizard","review"].includes(e)?"review":["sleeping","idle-doze","mini-sleep","waiting"].includes(e)?"waiting":["mini-peek","waving"].includes(e)?"waving":e==="running-left"||e==="running-right"?e:"idle"}function V(){const[e,n]=r.useState(()=>typeof document>"u"?!0:document.visibilityState!=="hidden");return r.useEffect(()=>{if(typeof document>"u")return;const t=()=>n(document.visibilityState!=="hidden");return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),e}function _(){const[e,n]=r.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return r.useEffect(()=>{if(typeof window.matchMedia!="function")return;const t=window.matchMedia("(prefers-reduced-motion: reduce)"),i=o=>n(o.matches);return t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}function I({character:e,pet:n=null,state:t="idle-living",dragState:i=null,size:o=48,className:d="",lookDirectionIndex:u=null}){const l=p(e),g=i==="running-left"||i==="running-right"?i:T(t),a=z[g],s=n?.spriteVersionNumber===2?2:1,w=s===2?11:9,c=s===2&&g==="idle"&&Number.isInteger(u)?(u%16+16)%16:null,h=c==null?a.row:9+Math.floor(c/8),m=c==null?null:c%8,k=_(),y=V(),[b,S]=r.useState(0);r.useEffect(()=>{if(S(0),k||!y||c!=null)return;let M=!1,x=0;const E=$=>{x=window.setTimeout(()=>{if(M)return;const j=($+1)%a.durations.length;S(j),E(j)},a.durations[$])};return E(0),()=>{M=!0,window.clearTimeout(x)}},[c,k,y,a]);const A=r.useMemo(()=>({width:o*(192/208),height:o,backgroundImage:`url(${n?.assetUrl||`/pets/${l}/spritesheet.webp`})`,backgroundRepeat:"no-repeat",backgroundSize:`800% ${w*100}%`,backgroundPosition:`${(m??b)/7*100}% ${h/(w-1)*100}%`,imageRendering:"pixelated"}),[w,m,h,b,l,n?.assetUrl,o]);return f.jsx("div",{"aria-hidden":"true",className:`pet-atlas-animated ${d}`,style:A})}const R={"idle-living":"idle/living.svg","idle-doze":"idle/doze.svg","idle-follow":"idle/follow.svg","idle-look":"idle/look.svg","idle-yawn":"idle/yawn.svg","idle-collapse":"idle/collapse.svg","working-building":"working/building.svg","working-carrying":"working/carrying.svg","working-conducting":"working/conducting.svg","working-confused":"working/confused.svg","working-debugger":"working/debugger.svg","working-juggling":"working/juggling.svg","working-overheated":"working/overheated.svg","working-pushing":"working/pushing.svg","working-sweeping":"working/sweeping.svg","working-thinking":"working/thinking.svg","working-typing":"working/typing.svg","working-ultrathink":"working/ultrathink.svg","working-wizard":"working/wizard.svg","mini-alert":"mini/alert.svg","mini-crabwalk":"mini/crabwalk.svg","mini-enter":"mini/enter.svg","mini-enter-sleep":"mini/enter-sleep.svg","mini-happy":"mini/happy.svg","mini-idle":"mini/idle.svg","mini-peek":"mini/peek.svg","mini-sleep":"mini/sleep.svg","react-double":"react/double.svg","react-drag":"react/drag.svg","react-left":"react/left.svg","react-right":"react/right.svg","collapse-sleep":"sleep/collapse-sleep.svg",sleeping:"sleep/sleeping.svg",wake:"sleep/wake.svg",disconnected:"status/disconnected.svg",error:"status/error.svg",notification:"status/notification.svg",happy:"happy.svg","static-base":"static-base.svg"},v=new Map;async function P(e){if(v.has(e))return v.get(e);if(typeof fetch!="function")return null;let n;try{n=await fetch(`/clawd/${e}`)}catch{return null}if(!n.ok)return null;const i=(await n.text()).replace(/<svg([^>]*)>/,(o,d)=>`<svg${d.replace(/\s+width="[^"]*"/g,"").replace(/\s+height="[^"]*"/g,"")} width="100%" height="100%">`);return v.set(e,i),i}function H({state:e="idle-living",size:n=48,className:t=""}){const[i,o]=r.useState(""),d=r.useRef(null),l=N()?"static-base":e,g=R[l]||R["static-base"];return r.useEffect(()=>{let a=!1;return P(g).then(s=>{!a&&s&&o(s)}),()=>{a=!0}},[g]),r.useEffect(()=>{const a=d.current?.querySelector("svg");if(a)try{const s=a.getBBox();s.width>0&&s.height>0&&a.setAttribute("viewBox",`${s.x-2} ${s.y-2} ${s.width+4} ${s.height+4}`)}catch{}},[i]),f.jsx("div",{ref:d,"aria-hidden":"true",className:`clawd-animated ${t}`,style:{width:n,height:n,display:"inline-flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},dangerouslySetInnerHTML:{__html:i}})}function B({state:e="idle-living",size:n=48,className:t="",character:i="clawd",pet:o=null,lookDirectionIndex:d=null}){const u=p(i);return u!=="clawd"?f.jsx(I,{character:u,pet:o,state:e,size:n,className:t,lookDirectionIndex:d}):f.jsx(H,{state:e,size:n*L(u),className:t})}function N(){const[e,n]=r.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return r.useEffect(()=>{if(typeof window.matchMedia!="function")return;const t=window.matchMedia("(prefers-reduced-motion: reduce)"),i=o=>n(o.matches);return t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}export{B as C,p as n};
@@ -1 +0,0 @@
1
- import{r as n,z as a}from"./__vite-browser-external-C6_BtvDo.js";import{u as p}from"./DialogTitle-DhB-tbnZ.js";import{u as c}from"./useScrollLock-if34g2H-.js";const x=n.forwardRef(function(e,r){const{render:l,className:u,style:m,id:s,...t}=e,i=p(),o=c(s);return i.useSyncedValueWithCleanup("descriptionElementId",o),a("p",e,{ref:r,props:[{id:o},t]})});export{x as D};
@@ -1,5 +0,0 @@
1
- import{m as W,j as e,e as U,c as r,k as q,r as f,ac as oe,d as se,J as le,L as ce,ad as de,q as ue,ae as me}from"./__vite-browser-external-C6_BtvDo.js";import{m as H}from"./react-CM-ozVnh.js";import{P as C,c as xe,r as M,a as pe,u as ge,b as he,s as fe}from"./use-usage-limits-Dk3EkeIs.js";import{L as m,u as be}from"./use-limits-display-prefs-BJJd750e.js";import{C as K}from"./Card-Chwjmxjz.js";import{F as ye}from"./FadeIn-B8eRWBdy.js";import{L as ke,l as j,a as ve}from"./limits-providers-CFO4O1qh.js";import{P as je}from"./ProviderIcon-FfLD-f73.js";import{H as Ne}from"./HoverTooltip-DDyTZli0.js";import{L as _e}from"./LocalOnlyNotice-DuTdva_n.js";import{u as we}from"./use-reduced-motion-BvXZCGFC.js";import"./arrow-up-right-B_K57Vbg.js";import"./download-BgtWtEXI.js";const Pe=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],Me=W("bell-off",Pe);const Ee=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Ie=W("bell",Ee),Le=[3,2,3,3,2,2,3];function g({className:t}){return e.jsx("div",{className:U("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function Ce(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{className:"h-3 w-12 shrink-0"}),e.jsx(g,{className:"flex-1 h-1.5 rounded-full min-w-0"}),e.jsx(g,{className:"h-3 w-[30px] shrink-0"}),e.jsx(g,{className:"h-3 w-6 shrink-0"})]})}function Se({bars:t,index:a}){const i=a%3===0?"w-24":a%3===1?"w-20":"w-[4.5rem]";return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(g,{className:"h-[14px] w-[14px] rounded shrink-0"}),e.jsx(g,{className:U("h-4",i)})]}),Array.from({length:t},(o,n)=>e.jsx(Ce,{},n))]})}function Oe(){return e.jsx(K,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(g,{className:"h-3.5 w-28"}),Le.map((t,a)=>e.jsx(Se,{bars:t,index:a},a))]})})}const S=100;function F(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function Te(t){return Math.max(0,Math.min(S,Math.round(t)))}function Re(t){return new Intl.DateTimeFormat(q(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function Ae(t,a,i){if(t==null||t>=a)return S;const o=a-t,n=a-i;return Te(n/o*S)}function De(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function He(t,{now:a}={}){if(!t||typeof t!="object")return null;const i=De(t);if(i===void 0)return null;const o=Array.isArray(t.credits)?t.credits:[],n=a instanceof Date?a.getTime():Number(a??Date.now()),s=[];for(const d of o){const c=F(d?.expires_at);if(c==null)continue;const l=s.length+1;s.push({key:`reset-${l}`,label:r("limits.codex_reset_bank.row_label",{index:l}),expiresAt:Re(c),expiresMs:c,percent:Ae(F(d?.granted_at),c,n)})}return i===0?null:s.length>0?{kind:"rows",availableCount:i??s.length,rows:s}:i>0?{kind:"count_only",availableCount:i,rows:[]}:null}const Fe="shrink-0 text-oai-black dark:text-oai-white";function Ge(t){const a=M(t);if(!Number.isFinite(a))return null;const i=a-Date.now();if(i<=0)return r("shared.time.now");const o=Math.floor(i/6e4);if(o<60)return`${o}m`;const n=Math.floor(o/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function $e(t,a){const i=a===m.REMAINING?100-t:t;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function P(t,a="used_percent"){return t?a==="utilization"?t.utilization:t.used_percent:null}function E(t,a="reset_at"){return t?a==="resets_at"?t.resets_at:t.reset_at:null}function L(t){const a=Math.max(0,Math.min(100,Number(t)||0)),i=Math.round(a);return a>0&&i===0?r("limits.bar.sub_one_percent"):String(i)}function _(t,{useGrouping:a=!0,maximumFractionDigits:i}={}){const o=Number(t);return Number.isFinite(o)?new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:i??(o>=100?0:2),useGrouping:a}).format(o):null}function Be(t){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const a={useGrouping:t.unit!=="calls"},i=_(t.used_credits,a),o=_(t.limit_credits,a),n=_(t.remaining_credits,a);if(!i||!o||!n)return null;const s=t.unit==="calls"?"limits.qoder_calls.detail":"limits.codex_credits.detail";return r(s,{used:i,limit:o,remaining:n})}function We(t,a){return xe({usedPercent:P(t.window,t.pctField),windowSeconds:pe(t,t.window),resetMs:M(E(t.window,t.resetField)),mode:a})}function z(t){return Number.isFinite(t)?new Intl.DateTimeFormat(q(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):null}function Ue(t,a,i){const o=[X(t,a,i)],n=M(E(t.window,t.resetField)),s=z(n);s&&o.push(r(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:s}));const d=Be(t.window);return d&&o.push(d),o.join(`
2
- `)}const V=Ne;function qe({label:t,pct:a,reset:i,mode:o=m.USED,pacePercent:n=null,paceOver:s=!1,title:d=null}){const c=Math.max(0,Math.min(100,Number(a)||0)),l=o===m.REMAINING?100-c:c,u=Math.round(l),x=l>0&&u===0?Math.max(l,.35):l;let v=String(u);l>0&&u===0&&(v=r("limits.bar.sub_one_percent"));const y=n==null?null:Math.max(0,Math.min(100,n));return e.jsxs("div",{className:"group relative flex items-center gap-2",children:[e.jsx(V,{text:d}),e.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t}),e.jsxs("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[e.jsx("div",{className:`${$e(l,o)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${x}%`,minWidth:l>0?"3px":0}}),y!=null&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-0 h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{left:`calc(${y}% - 3px)`,width:"6px"}}),e.jsx("div",{className:`absolute top-0 h-full ${s?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${y}% - 1px)`,width:"2px"}})]})]}),e.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:[v,"%"]}),i&&e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:i})]})}function X(t,a,i){const o=t.label??r(t.labelKey),n=i===m.REMAINING,s=l=>n?100-l:l;if(a.expectedPercent==null){const l=Math.max(0,Math.min(100,Number(P(t.window,t.pctField))||0)),u=L(s(l));return n?r("limits.explain.remaining",{label:o,used:u}):r("limits.explain.used",{label:o,used:u})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:o,eta:a.runsOutEta});const l=L(s(a.projectedEnd??100));return r(n?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:o,pct:l})}const d=Math.max(0,Math.min(100,Number(P(t.window,t.pctField))||0)),c=L(s(a.projectedEnd??d));return r(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:o,pct:c})}function Ke({pace:t}){return t.pacePercent!=null}function ze({rows:t,mode:a}){if(t.length===0)return null;const i=a===m.REMAINING,o=t.some(Ke);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:n,pace:s})=>{const d=z(M(E(n.window,n.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[X(n,s,a),d?e.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:[" · ",r(n.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:d})]}):null]},n.key)}),o?e.jsx("div",{className:"mt-1 pt-1.5 border-t border-oai-gray-200/70 dark:border-oai-gray-700/50 text-[10.5px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:r(i?"limits.explain.body_remaining":"limits.explain.body")}):null]})}function N(t){if(!t)return null;const a=Date.now()-new Date(t).getTime();if(a<0)return null;const i=Math.floor(a/6e4);if(i<1)return r("shared.time.now");if(i<60)return r("shared.time.m_ago",{n:i});const o=Math.floor(i/60);if(o<24)return r("shared.time.h_ago",{n:o});const n=Math.floor(o/24);return r("shared.time.d_ago",{n})}const G={live:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-emerald-500",pulse:"bg-emerald-400"},stale:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"},cached:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"}},Ve={claude:"claude",codex:"codex"};function k({label:t,age:a=null,tone:i="live",tooltip:o=null}){const n=G[i]||G.live,s=i==="live";return e.jsxs("div",{className:"relative inline-flex items-center group cursor-help ml-1",onClick:d=>d.stopPropagation(),children:[e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-semibold uppercase tracking-wider border leading-normal ${n.surface}`,children:[s?e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${n.pulse} opacity-75`}),e.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${n.dot}`})]}):e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n.dot}`}),t,a?e.jsxs(e.Fragment,{children:[" · ",a]}):null]}),o?e.jsxs("span",{className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-2 -translate-x-1/2 w-48 rounded-md bg-oai-gray-900 dark:bg-oai-gray-800 px-2.5 py-1.5 text-[10px] font-normal text-white text-center opacity-0 scale-95 translate-y-1 group-hover:opacity-100 group-hover:scale-100 group-hover:translate-y-0 transition-all duration-200 cubic-bezier(0.16, 1, 0.3, 1) leading-normal shadow-lg origin-bottom border border-oai-gray-800 dark:border-oai-gray-700",children:[o,e.jsx("span",{className:"absolute left-1/2 top-full -translate-x-1/2 border-4 border-transparent border-t-oai-gray-900 dark:border-t-oai-gray-800"})]}):null]})}function w({name:t,providerId:a,children:i,expandable:o=!1,expanded:n=!1,onToggle:s,badge:d=null}){const c=ve(a),l=e.jsxs("div",{className:"flex items-center gap-1.5",children:[c?e.jsx(je,{provider:c,size:14,className:Fe}):null,e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:t}),d]});return o?e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,onClick:s,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),s?.())},className:"flex flex-col gap-1.5 -mx-1.5 px-1.5 py-1 rounded-lg cursor-pointer transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 aria-expanded:bg-oai-gray-50 dark:aria-expanded:bg-oai-gray-800/40",children:[l,i]}):e.jsxs("div",{className:"flex flex-col gap-1.5",children:[l,i]})}const Xe=ke;function h({children:t,tone:a="neutral"}){const i=a==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400";return e.jsx("div",{className:`text-[11px] leading-snug ${i}`,children:t})}function Ye({rows:t,mode:a,extra:i=null}){const o=t.length===0&&!i;return e.jsxs(e.Fragment,{children:[t.map(({spec:n,pace:s})=>e.jsx(qe,{label:n.label??r(n.labelKey),pct:P(n.window,n.pctField),reset:Ge(E(n.window,n.resetField)),mode:a,pacePercent:s.pacePercent,paceOver:s.paceOver,title:Ue(n,s,a)},n.key)),o?e.jsx(h,{children:r("limits.status.no_data")}):null,i]})}function Je(t){if(!Number.isFinite(t.expiresMs))return null;const a=Math.floor((t.expiresMs-Date.now())/864e5);return a<0?null:a===0?r("limits.reset_bank.hover_detail_today",{date:t.expiresAt}):r("limits.reset_bank.hover_detail",{date:t.expiresAt,days:a})}function Qe({row:t}){const a=Math.max(0,Math.min(100,Number(t.percent)||0));return e.jsxs("div",{className:"group relative flex items-center gap-2","data-reset-bank-row":"",children:[e.jsx(V,{text:Je(t)}),e.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t.label}),e.jsx("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-oai-gray-400 dark:bg-oai-gray-500 rounded-full h-full transition-[width] duration-500 ease-out",style:{width:`${a}%`,minWidth:a>0?"3px":0}})}),e.jsx("span",{className:"text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-[4.25rem] text-right shrink-0 whitespace-nowrap",children:t.expiresAt})]})}function Ze({model:t}){const a=t.kind==="count_only"?r("limits.codex_reset_bank.count_only",{count:t.availableCount}):null;return e.jsxs("div",{className:"mt-1 flex flex-col gap-1","data-reset-bank-section":t.kind,children:[e.jsx("div",{className:"text-[10.5px] font-medium uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.codex_reset_bank.title")}),a?e.jsx("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:a}):t.rows.map(i=>e.jsx(Qe,{row:i},i.key))]})}function Y(t,a){if(t==="codex_meta"){const i=He(a.reset_credits);return i?e.jsx(Ze,{model:i}):null}if(t==="kimi_parallel"&&a.parallel_limit)return e.jsx(h,{children:r("limits.label.kimi_parallel",{count:a.parallel_limit})});if(t==="kiro_credits"&&Number.isFinite(Number(a.tracked_credits))&&Number(a.tracked_credit_records)>0){const i=_(a.tracked_credits,{maximumFractionDigits:2});return e.jsx(h,{children:r("limits.label.kiro_tracked_credits",{credits:i,count:Number(a.tracked_credit_records)})})}return t==="copilot_otel"&&!a.otel_has_files&&!a.otel_enabled?e.jsx(at,{defaultDir:a.otel_default_dir}):null}function et(t,a,i,o,n,s,d=null){const c=C[t];if(!c)return null;const l=c.windows(a).filter(x=>x.window).map(x=>({spec:x,pace:We(x,o)})),u=Y(c.extra,a);return e.jsxs(w,{name:i,providerId:t,expandable:l.length>0,expanded:n,onToggle:s,badge:d,children:[e.jsx(Ye,{mode:o,rows:l,extra:u}),n?e.jsx(ze,{rows:l,mode:o}):null]},t)}function tt(t,a,i,o,n){if(!C[t])return null;if(!a?.configured)return e.jsxs(w,{name:j(t),providerId:t,children:[e.jsx(h,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx($,{}):null,t==="codingPlan"?e.jsx(B,{}):null]},t);if(t==="opencodeGo"&&a.subscription_status==="inactive")return e.jsx(w,{name:j(t),providerId:t,children:e.jsx(h,{children:r("limits.opencodeGo.status.inactive")})},t);if(a.error)return e.jsxs(w,{name:j(t),providerId:t,children:[e.jsx(h,{tone:"error",children:r("shared.error.prefix",{error:a.error})}),t==="kiro"?Y(C.kiro.extra,a):null,t==="opencodeGo"?e.jsx($,{}):null,t==="codingPlan"?e.jsx(B,{}):null]},t);const s=j(t),d=a.plan_label?`${s} ${a.plan_label}`:s;let c=null;if(t==="antigravity")if(a.cached){const u=N(a.cached_at);c=e.jsx(k,{label:r("limits.label.antigravity_cached"),age:u,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else c=e.jsx(k,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});if((t==="qoder"||t==="qoderCn"||t==="codingPlan")&&a.cached&&(c=e.jsx(k,{label:r("limits.label.antigravity_cached"),age:N(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),!c&&a.auth_action_required==="reauth"){const u=Ve[t];c=e.jsx(k,{label:r("limits.reauth.badge"),age:N(a.cached_at),tone:"stale",tooltip:u?r("limits.reauth.tooltip",{command:u}):null})}const l=a.provenance;return l?.stale&&!c&&(c=e.jsx(k,{label:r("limits.provenance.stale"),age:N(l.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:l.source,confidence:l.confidence})})),et(t,a,d,i,o,n,c)}function at({defaultDir:t}){const[a,i]=f.useState(!1),n=["export COPILOT_OTEL_ENABLED=true","export COPILOT_OTEL_EXPORTER_TYPE=file",`export COPILOT_OTEL_FILE_EXPORTER_PATH="${t||"$HOME/.copilot/otel"}/copilot-otel-$(date +%Y%m%d).jsonl"`].join(`
3
- `),s=async d=>{d.stopPropagation();try{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:r("limits.copilot.otelHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug",children:r("limits.copilot.otelHint.body")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-tight whitespace-pre",children:n}),e.jsx("button",{type:"button",onClick:s,className:"mt-1 inline-flex items-center gap-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 px-1.5 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:a?r("limits.copilot.otelHint.copied"):r("limits.copilot.otelHint.copy")})]})}function b({n:t,children:a}){return e.jsxs("li",{className:"flex gap-2.5",children:[e.jsx("span",{className:"mt-[1px] flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-oai-brand/15 text-[9px] font-semibold text-oai-brand",children:t}),e.jsx("div",{className:"min-w-0 flex-1 leading-snug",children:a})]})}function J(){return e.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":"true",className:"h-2.5 w-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M4.5 2.75h4.75V7.5M9.25 2.75 3 9"})})}function $(){const[t,a]=f.useState(!1),i=['export OPENCODE_GO_AUTH_COOKIE="..."','# Optional: export OPENCODE_GO_WORKSPACE_ID="wrk_..." (Only if auto-discovery fails)'].join(`
4
- `),o=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.opencodeGo.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.opencodeGo.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(b,{n:"1",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step1")}),e.jsxs("a",{href:"https://opencode.ai",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.opencodeGo.setupHint.cta"),e.jsx(J,{})]})]}),e.jsxs(b,{n:"2",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step2")}),e.jsxs("ul",{className:"mt-1 space-y-0.5 text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("li",{children:r("limits.opencodeGo.setupHint.step2_workspace")}),e.jsx("li",{children:r("limits.opencodeGo.setupHint.step2_cookie")})]})]}),e.jsxs(b,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.opencodeGo.setupHint.step3")}),e.jsx("button",{type:"button",onClick:o,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.opencodeGo.setupHint.copied"):r("limits.opencodeGo.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.opencodeGo.setupHint.note_app")})]})]})]})}function B(){const[t,a]=f.useState(!1),i=["npm install -g @volcengine/ark-cli","arkcli auth login volc-sso # browser SSO (recommended)","arkcli auth status # verify the session"].join(`
5
- `),o=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.codingPlan.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.codingPlan.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(b,{n:"1",children:[e.jsx("div",{children:r("limits.codingPlan.setupHint.step1")}),e.jsxs("a",{href:"https://www.volcengine.com/docs/82379/2536875",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.codingPlan.setupHint.cta"),e.jsx(J,{})]})]}),e.jsxs(b,{n:"2",children:[e.jsx("div",{children:r("limits.codingPlan.setupHint.step2")}),e.jsx("div",{className:"mt-0.5 text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.codingPlan.setupHint.step2_remote")})]}),e.jsxs(b,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.codingPlan.setupHint.step3")}),e.jsx("button",{type:"button",onClick:o,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.codingPlan.setupHint.copied"):r("limits.codingPlan.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.codingPlan.setupHint.note_app")})]})]})]})}function it(t){const[a,i]=f.useState(0);return f.useLayoutEffect(()=>{const o=t.current;if(!o)return;const n=o.querySelectorAll("[data-limit-label]");let s=0,d=null;if(n.length>0)try{d=document.createElement("canvas").getContext("2d")}catch{d=null}if(d){const l=window.getComputedStyle(n[0]);d.font=`${l.fontStyle} ${l.fontWeight} ${l.fontSize} ${l.fontFamily}`;for(const u of n)s=Math.max(s,d.measureText(u.textContent).width)}const c=Math.ceil(s);i(l=>l===c?l:c)}),a}function rt({claude:t,codex:a,cursor:i,gemini:o,kimi:n,kiro:s,grok:d,antigravity:c,copilot:l,zcode:u,opencodeGo:x,qoder:v,qoderCn:y,codingPlan:Q,order:I,visibility:O,displayMode:Z}){const ee={claude:t,codex:a,cursor:i,gemini:o,kimi:n,kiro:s,grok:d,antigravity:c,copilot:l,zcode:u,opencodeGo:x,qoder:v,qoderCn:y,codingPlan:Q},T=f.useRef(null),R=it(T),[te,ae]=f.useState(null),ie=Array.isArray(I)&&I.length>0?I:Xe,A=Z===m.REMAINING?m.REMAINING:m.USED,re=A===m.REMAINING?r("limits.settings.display_mode_remaining"):r("limits.settings.display_mode_used"),D=ie.filter(p=>!O||O[p]!==!1).map(p=>tt(p,ee[p],A,te===p,()=>ae(ne=>ne===p?null:p))).filter(Boolean);return e.jsx(ye,{delay:.15,children:e.jsx(K,{children:e.jsxs("div",{ref:T,className:"flex flex-col gap-3",style:R>0?{"--tt-limits-label-w":`${R}px`}:void 0,children:[e.jsxs("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:[r("limits.panel.title"),r("limits.panel.mode_separator"),re]}),D.length>0?D:e.jsx(h,{children:r("limits.status.all_hidden")})]})})})}const nt=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),ot="x-apple.systempreferences:com.apple.preference.notifications";function st(){const t=we(),a=ue(),i=r("limits.alert.blocked"),o=a?H.button:H.div;return e.jsxs(o,{type:a?"button":void 0,onClick:a?()=>me({type:"action",name:"openURL",value:ot}):void 0,initial:t?!1:{opacity:0,x:14,scale:.9},animate:{opacity:1,x:0,scale:1},transition:{type:"spring",stiffness:320,damping:18},title:i,className:`relative hidden sm:inline-flex min-w-0 max-w-[360px] items-center gap-1.5 rounded-full border border-amber-300/70 bg-amber-50 px-3 py-1.5 text-xs text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-300 ${a?"cursor-pointer transition-colors hover:bg-amber-100 dark:hover:bg-amber-500/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/60":""}`,children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"truncate",children:i}),e.jsx("span",{"aria-hidden":!0,className:"absolute left-full top-1/2 -translate-y-1/2 border-[5px] border-transparent border-l-amber-300/80 dark:border-l-amber-500/40"})]})}function vt(){const t=oe(),{data:a,error:i,isLoading:o}=ge(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),n=be(),s=he();return se.useEffect(()=>{s.enabled&&a&&fe(a)},[s.enabled,a]),!nt&&!le()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(_e,{})}):e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:r("nav.limits")}),e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:r("limits.page.subtitle")})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.enabled&&s.permissionBlocked?e.jsx(st,{}):null,e.jsx("button",{type:"button",onClick:()=>{s.setEnabled(!s.enabled)},"aria-label":s.enabled?r("limits.alert.disable"):r("limits.alert.enable"),title:s.enabled?r("limits.alert.disable"):r("limits.alert.enable"),className:`inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 ${s.enabled&&s.permissionBlocked?"text-amber-600 dark:text-amber-400":"text-oai-gray-600 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white"}`,children:s.enabled?e.jsx(Ie,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(Me,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(ce,{to:"/settings?section=limits","aria-label":r("limits.page.openSettings"),title:r("limits.page.openSettings"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:e.jsx(de,{className:"h-4 w-4","aria-hidden":!0})})]})]}),o?e.jsx(Oe,{}):e.jsxs(e.Fragment,{children:[i?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:r("shared.error.prefix",{error:i})}):null,e.jsx(rt,{claude:a?.claude,codex:a?.codex,cursor:a?.cursor,gemini:a?.gemini,kimi:a?.kimi,kiro:a?.kiro,grok:a?.grok,antigravity:a?.antigravity,copilot:a?.copilot,zcode:a?.zcode,opencodeGo:a?.opencodeGo,qoder:a?.qoder,qoderCn:a?.qoderCn,codingPlan:a?.codingPlan,order:n.order,visibility:n.visibility,displayMode:n.displayMode})]})]})})})}export{vt as LimitsPage};
@@ -1 +0,0 @@
1
- import{m as E,W as re,ai as ie,r as l,aj as se,ak as oe,al as le,Q as H,c as r,j as e,e as b,am as ne,a5 as U,X as de}from"./__vite-browser-external-C6_BtvDo.js";import{u as ce,T as O,S as me}from"./Controls-CtBFPCBY.js";import{P as pe}from"./ProviderIcon-FfLD-f73.js";import{n as xe,C as q}from"./ClawdAnimated-BdB7aycS.js";import{F}from"./FadeIn-B8eRWBdy.js";import{L as ue}from"./link-2-BHOsUnAI.js";import{L as W}from"./loader-circle-CgcIQi92.js";import{Z as ge}from"./zap-D1yHmcQR.js";import{T as be}from"./trash-2-QLUsAY3l.js";import{D as he,a as fe,b as ye,c as ke,d as ve,e as je}from"./DialogTitle-DhB-tbnZ.js";import{D as we}from"./DialogDescription-CjJLpfCL.js";import{D as Ne}from"./DialogClose-kd1wIljN.js";import"./Card-Chwjmxjz.js";import"./react-CM-ozVnh.js";import"./use-reduced-motion-BvXZCGFC.js";import"./useScrollLock-if34g2H-.js";import"./store-CvSEdgf2.js";const Se=[["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"}]],Ce=E("file-archive",Se);const Pe=[["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"}]],Ie=E("monitor-up",Pe);const ze=[["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"}]],Ae=E("upload",ze),De={visible:!1,character:"clawd",size:"medium"};function Te(){const t=re()&&ie(),[a,o]=l.useState(De);l.useEffect(()=>{if(!t)return;const m=se(s=>{o({visible:!!s.visible,character:xe(s.character),size:["small","medium","large"].includes(s.size)?s.size:"medium"})});return oe(),m},[t]);const d=l.useCallback((m,s)=>{o(x=>({...x,[m]:s})),t&&le(m,s)},[t]);return{available:t,settings:a,setSetting:d}}const k=[{id:"clawd",displayName:"Clawd",nameKey:"pet.character.clawd",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 C(t){const a=await t.json().catch(()=>null);if(!t.ok||a?.ok===!1)throw new Error(a?.error||`Pet request failed with HTTP ${t.status}`);return a}async function Ee(){const t=await fetch("/functions/tokentracker-pets",{headers:{Accept:"application/json"},cache:"no-store"}),a=await C(t),o=new Set(Array.isArray(a.hiddenBuiltinIds)?a.hiddenBuiltinIds:[]);return[...k.filter(d=>d.id==="clawd"||!o.has(d.id)),...Array.isArray(a.pets)?a.pets:[]]}async function M(t){const a=await H();return C(await fetch("/functions/tokentracker-pets",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...a},cache:"no-store",body:JSON.stringify(t)}))}function Me(t){return M({action:"install_url",url:t})}async function $(t){const a=await H();return C(await fetch("/api/pets/import",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/zip",...a},cache:"no-store",body:t}))}function Be(t){return M({action:"remove",id:t})}async function Le(){const t=await fetch("/functions/tokentracker-pets?scope=codex",{headers:{Accept:"application/json"},cache:"no-store"}),a=await C(t);return{importable:Array.isArray(a.importable)?a.importable:[],codexDetected:a.codexDetected===!0}}function _e(t){return M({action:"import_codex",ids:t})}let T=k;function Ke(){const[t,a]=l.useState(T),[o,d]=l.useState(!0),[m,s]=l.useState(!1),x=l.useCallback(async()=>{d(!0);try{const u=await Ee();return T=u,a(u),s(!0),u}catch{return T=k,a(k),s(!1),k}finally{d(!1)}},[]);return l.useEffect(()=>{x()},[x]),{pets:t,loading:o,available:m,refresh:x}}const Ve={clawd:"from-oai-amber-50 dark:from-orange-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 Re(){const t=r("pet.import.subtitle"),a="codex-pets.net",o=t.indexOf(a);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:a}),t.slice(o+a.length)]})}const v=[{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 X({character:t,selected:a,onSelect:o,onRemove:d,removeDisabled:m}){const s=t.nameKey?r(t.nameKey):t.displayName;return e.jsxs("div",{className:"group relative",children:[e.jsxs("button",{type:"button",onClick:o,"aria-pressed":a,className:b("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",a?"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:b("absolute inset-0 bg-gradient-to-br to-transparent opacity-80 dark:opacity-55",Ve[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(q,{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:s}),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:r("pet.format.v2")}):null,a?e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-oai-brand-500","aria-hidden":!0}):null]})]})]}),d?e.jsx("button",{type:"button",disabled:m,onClick:d,"aria-label":`${r("pet.import.remove")} · ${s}`,className:b("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(be,{className:"h-3 w-3","aria-hidden":!0})}):null]})}function Ue({pet:t,state:a,onStateChange:o}){const[d,m]=l.useState(null),s=l.useRef(null),x=v.find(function(n){return n.id===a}),u=r(x?.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||!s.current)return;const n=s.current.getBoundingClientRect(),h=p.clientX-(n.left+n.width/2),c=p.clientY-(n.top+n.height/2),j=(Math.atan2(h,-c)*180/Math.PI+360)%360;m(Math.round(j/22.5)%16)},onPointerLeave:()=>m(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:r("pet.preview.states")}),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}),u]})]}),e.jsx("div",{className:"relative flex flex-1 items-center justify-center px-6 py-5",children:e.jsx("div",{ref:s,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(q,{state:a,character:t?.id||"clawd",pet:t,size:190,lookDirectionIndex:d})})})}),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":r("pet.preview.states"),children:v.map(p=>e.jsxs("button",{type:"button",onClick:()=>o(p.id),"aria-pressed":a===p.id,className:b("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",a===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:r(p.labelKey)}),e.jsx("span",{className:b("h-1 w-1 rounded-full transition-colors duration-200",a===p.id?"bg-oai-black dark:bg-white":"bg-transparent"),"aria-hidden":!0})]},p.id))})})]})}function Oe({pets:t,busy:a,error:o,onImport:d,onClose:m}){const[s,x]=l.useState(()=>new Set),u=n=>x(h=>{const c=new Set(h);return c.has(n)?c.delete(n):c.add(n),c}),p=t.length!==0&&s.size===t.length;return e.jsx(he,{open:!0,onOpenChange:n=>{!n&&!a&&m()},children:e.jsxs(fe,{children:[e.jsx(ye,{className:"fixed inset-0 z-50 bg-black/15 backdrop-blur-md dark:bg-black/40 animate-tt-fade-in"}),e.jsx(ke,{className:"fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6",children:e.jsxs(ve,{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(je,{className:"text-base font-semibold",children:r("pet.codex.title")}),e.jsx(we,{className:"mt-0.5 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.codex.subtitle")})]}),e.jsx(Ne,{type:"button",disabled:a,"aria-label":r("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(de,{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:r("pet.codex.empty")}):e.jsx("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-3",children:t.map(n=>e.jsx(X,{character:n,selected:s.has(n.id),onSelect:()=>u(n.id)},n.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:a||t.length===0,onClick:()=>x(p?new Set:new Set(t.map(n=>n.id))),className:"text-xs font-medium text-oai-gray-500 underline-offset-2 hover:underline disabled:opacity-40 dark:text-oai-gray-400",children:r("pet.codex.select_all")}),e.jsxs("button",{type:"button",disabled:a||s.size===0,onClick:()=>d([...s]),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:[a?e.jsx(W,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,s.size>0?`${r("pet.codex.import")} · ${s.size}`:r("pet.codex.import")]})]})]})})]})})}function ot(){const{available:t,settings:a,setSetting:o}=Te(),{pets:d,loading:m,available:s,refresh:x}=Ke(),[u,p]=l.useState(""),[n,h]=l.useState(""),[c,j]=l.useState(!1),[B,P]=l.useState([]),[Z,I]=l.useState(!1),[w,L]=l.useState(!1),[J,z]=l.useState(""),[Q,_]=l.useState("idle-living"),[K,Y]=l.useState(!0),y=a.character||"clawd",A=ce(),V=A.settings?.menuBarIconStyle==="pet",G=d.find(i=>i.id===y)||d[0],N=c?{kind:"busy",text:r("pet.import.busy")}:n?{kind:"error",text:n}:null,R=B.length!==0;l.useEffect(()=>{!m&&d.length>0&&!d.some(i=>i.id===y)&&o("character","clawd")},[m,d,y,o]);async function S(i,g=r("pet.import.success")){j(!0),h("");try{const f=await i();await x(),ne(),f?.pet?.id&&o("character",f.pet.id),U({title:g,timeout:4e3}),p("")}catch(f){h(f?.message||r("pet.import.failed"))}finally{j(!1)}}const D=l.useCallback(async()=>{if(!s){P([]);return}try{const i=await Le();P(i.importable)}catch{P([])}},[s]);l.useEffect(()=>{D()},[D]);async function ee(i){L(!0),z("");try{return await _e(i),await x(),await D(),U({title:r("pet.codex.imported"),timeout:4e3}),!0}catch(g){return z(g?.message||r("pet.import.failed")),!1}finally{L(!1)}}l.useEffect(()=>{if(!K)return;const i=window.setInterval(()=>{_(g=>{const f=v.findIndex(ae=>ae.id===g);return v[(f+1)%v.length].id})},5e3);return()=>window.clearInterval(i)},[K]);const te=[{value:"small",label:r("pet.size.small")},{value:"medium",label:r("pet.size.medium")},{value:"large",label:r("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:r("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:r("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(Ue,{pet:G,state:Q,onStateChange:i=>{Y(!1),_(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:r("pet.characters.title")}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("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:d.map(i=>e.jsx(X,{character:i,selected:y===i.id,onSelect:()=>o("character",i.id),removeDisabled:c,onRemove:s&&i.id!=="clawd"?()=>S(async()=>(await Be(i.id),y===i.id&&o("character","clawd"),null),r("pet.import.removed")):void 0},i.id))}),A.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:r("pet.menubar.title")}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.menubar.hint")})]}),e.jsx(O,{checked:V,onChange:()=>A.setSetting("menuBarIconStyle",V?"clawd":"pet"),ariaLabel:r("pet.menubar.title")})]}):null]}),s?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(Ae,{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:r("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(Re,{})}),e.jsxs("form",{className:"mt-3 flex gap-2",onSubmit:i=>{i.preventDefault(),!c&&u.trim()&&S(()=>Me(u))},children:[e.jsxs("label",{className:"relative flex min-w-0 flex-1 items-center",children:[e.jsx(ue,{className:"pointer-events-none absolute left-3 h-3.5 w-3.5 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{value:u,onChange:i=>p(i.target.value),"aria-label":r("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:c||!u.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:[c?e.jsx(W,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,r("pet.import.add")]})]}),e.jsxs("div",{className:b("mt-2 grid gap-2",R?"grid-cols-2":"grid-cols-1"),children:[R?e.jsxs("button",{type:"button",disabled:c||w,onClick:()=>{z(""),I(!0)},className:b("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",(c||w)&&"pointer-events-none opacity-40"),children:[e.jsx(pe,{provider:"codex",size:14,className:"fill-current"}),r("pet.codex.browse")]}):null,e.jsxs("label",{onDragOver:i=>i.preventDefault(),onDrop:i=>{if(i.preventDefault(),c)return;const g=i.dataTransfer?.files?.[0];g&&S(()=>$(g))},className:b("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",c&&"pointer-events-none opacity-40"),children:[e.jsx(Ce,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("pet.import.zip"),e.jsx("input",{type:"file",accept:".zip,.codex-pet.zip,application/zip",className:"sr-only",disabled:c,onChange:i=>{const g=i.target.files?.[0];g&&S(()=>$(g)),i.target.value=""}})]})]}),N?e.jsx("p",{role:N.kind==="error"?"alert":"status",className:b("mt-2 text-xs",N.kind==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400"),children:N.text}):null,Z?e.jsx(Oe,{pets:B,busy:w,error:J,onClose:()=>{w||I(!1)},onImport:async i=>{await ee(i)&&I(!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(Ie,{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:r("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:r("pet.controls.show")}),e.jsx(O,{checked:a.visible,onChange:()=>o("visible",!a.visible),disabled:!t,ariaLabel:r("pet.controls.show")})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"text-sm font-medium",children:r("pet.controls.size")}),e.jsx("div",{className:"shrink-0",children:e.jsx(me,{options:te,value:a.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(ge,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),r("pet.controls.native_only")]})]})]})})]})})})}export{ot as PetPage};