tokentracker-cli 1.2.1 → 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.
- package/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/dashboard/dist/assets/AchievementBadge-BaqdyZaV.js +1 -0
- package/dashboard/dist/assets/AchievementsPage-B4Ju0guv.js +2 -0
- package/dashboard/dist/assets/{AchievementsSection-DoYMz2Rr.js → AchievementsSection-CDUUEfIi.js} +1 -1
- package/dashboard/dist/assets/BadgeDetailModal-B-XMJAvL.js +1 -0
- package/dashboard/dist/assets/{BotAnimated-C21PdYSf.js → BotAnimated-Dx_vvTtC.js} +1 -1
- package/dashboard/dist/assets/Card-D-5mABVt.js +1 -0
- package/dashboard/dist/assets/CloudCheckoutPage-BELoh56h.js +1 -0
- package/dashboard/dist/assets/CloudPage-CfBruNxe.js +1 -0
- package/dashboard/dist/assets/CloudUsageExport-BoFU7xCT.js +4 -0
- package/dashboard/dist/assets/CommandPalette-BmmKZWn-.js +1 -0
- package/dashboard/dist/assets/CommunityStatsModal-BF77zVhN.js +1 -0
- package/dashboard/dist/assets/{ConfirmModal-zUljpLNe.js → ConfirmModal-BQ-xB1S_.js} +1 -1
- package/dashboard/dist/assets/Controls-BnTeX7T4.js +1 -0
- package/dashboard/dist/assets/DashboardPage-BWulHa5J.js +1 -0
- package/dashboard/dist/assets/{DevicePage-CCIyAYH3.js → DevicePage-Dg6XkIaY.js} +1 -1
- package/dashboard/dist/assets/DialogClose-DAyilsH-.js +1 -0
- package/dashboard/dist/assets/DialogDescription-j4XnRy6y.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-6q0jyME6.js → DialogTitle-B1iNGD2S.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-BUm1z22V.js → FadeIn-ChVf45WW.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-CxdmloMy.js → HeaderGithubStar-B740_G7a.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-CrMdGYZj.js → HoverTooltip-BzP5FudR.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-w6UUK_1K.js → IpCheckPage-BuZH3F14.js} +1 -1
- package/dashboard/dist/assets/LandingPage-Dtgq_caz.js +2 -0
- package/dashboard/dist/assets/LeaderboardPage-Di1kEg2O.js +2 -0
- package/dashboard/dist/assets/LeaderboardProBadge-h8FfR0au.js +1 -0
- package/dashboard/dist/assets/LeaderboardProfileModal-OUZvO6u-.js +73 -0
- package/dashboard/dist/assets/{LeaderboardProfilePage-Fljho5RP.js → LeaderboardProfilePage-bHI1oTEK.js} +2 -2
- package/dashboard/dist/assets/{LimitsPage-Do_uJqdQ.js → LimitsPage-DKojB73_.js} +2 -2
- package/dashboard/dist/assets/{LocalOnlyNotice-RIj2XT_X.js → LocalOnlyNotice-BaEq6qN7.js} +1 -1
- package/dashboard/dist/assets/LoginCard-Dn5Xy4If.js +1 -0
- package/dashboard/dist/assets/LoginModal-C5h-5GOA.js +1 -0
- package/dashboard/dist/assets/LoginPage-BpX8Tgjj.js +1 -0
- package/dashboard/dist/assets/PetPage-BPBsUHyL.js +1 -0
- package/dashboard/dist/assets/PopoverPopup-CVTiEVHs.js +1 -0
- package/dashboard/dist/assets/{ProviderIcon-BSI-1Cy8.js → ProviderIcon-BshO2uER.js} +1 -1
- package/dashboard/dist/assets/ResetPasswordPage-RTFTD8Dr.js +1 -0
- package/dashboard/dist/assets/{Select-B6CM0ico.js → Select-CtTceC4T.js} +1 -1
- package/dashboard/dist/assets/SelectItemText-C7xi8iGp.js +1 -0
- package/dashboard/dist/assets/SelfHostPage-BlwTt8XM.js +1 -0
- package/dashboard/dist/assets/{ServiceStatusPage-B4lIs2fc.js → ServiceStatusPage-BkIcJpYK.js} +1 -1
- package/dashboard/dist/assets/SessionsPage-okHobk_L.js +3 -0
- package/dashboard/dist/assets/SettingsPage-C-cc6wcF.js +2 -0
- package/dashboard/dist/assets/SkillsPage-D2LlKKJN.js +1 -0
- package/dashboard/dist/assets/{TokenGalaxy-Bk3kGSGi.js → TokenGalaxy-DiXUpXKF.js} +2 -2
- package/dashboard/dist/assets/TrendMonitor-C88S-5aa.js +19 -0
- package/dashboard/dist/assets/WidgetsPage-WsEFPNwp.js +1 -0
- package/dashboard/dist/assets/{WrappedPage-DHRmP4Ey.js → WrappedPage-ClEo-RmR.js} +1 -1
- package/dashboard/dist/assets/__vite-browser-external-DFRX9dp-.css +1 -0
- package/dashboard/dist/assets/__vite-browser-external-DUJeOWgd.js +45 -0
- package/dashboard/dist/assets/agent-logos-BM9jlReI.js +1 -0
- package/dashboard/dist/assets/arrow-left-BEM-HVmC.js +1 -0
- package/dashboard/dist/assets/arrow-right-CwBz5dwb.js +1 -0
- package/dashboard/dist/assets/{arrow-up-right-c39fdiDQ.js → arrow-up-right-jPmRN562.js} +1 -1
- package/dashboard/dist/assets/{check-8LQ7IvkH.js → check-CKwHc4Hv.js} +1 -1
- package/dashboard/dist/assets/cloud-checkout-nYNHDFoR.js +1 -0
- package/dashboard/dist/assets/composite-B4Z3F65o.js +1 -0
- package/dashboard/dist/assets/{download-x3Gmv-wu.js → download-CJUnX1Bs.js} +1 -1
- package/dashboard/dist/assets/{external-link-daw-XTjZ.js → external-link-B5yXxdPy.js} +1 -1
- package/dashboard/dist/assets/{flame-B9o0_EF8.js → flame-CKjAluj_.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-o9atQGtV.js → format-tokens-mk49THtv.js} +1 -1
- package/dashboard/dist/assets/{host-mode-GPY2DxE4.js → host-mode-efKlSYjX.js} +1 -1
- package/dashboard/dist/assets/{icons-CmM2z-Jt.js → icons-ZB1ZthjH.js} +1 -1
- package/dashboard/dist/assets/{index-CPcJP0uH.js → index-BImBG3eS.js} +1 -1
- package/dashboard/dist/assets/{index-CtQOew7C.js → index-BgdM7kBl.js} +1 -1
- package/dashboard/dist/assets/{index-Bfgblk6o.js → index-DweUMAUD.js} +1 -1
- package/dashboard/dist/assets/{info-BaK8Hoi2.js → info-CyDY7NYM.js} +1 -1
- package/dashboard/dist/assets/{link-2-CV3uvMH3.js → link-2-Dn2soiyd.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-DYpa-xTZ.js → loader-circle-CNT630zn.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-Ds4Uh7JO.js → modifiers.esm-WPx0bc2K.js} +1 -1
- package/dashboard/dist/assets/{monitor-smartphone-BbeYHvY-.js → monitor-smartphone-C-qC0RAt.js} +1 -1
- package/dashboard/dist/assets/os-DMmhX9tk.js +1 -0
- package/dashboard/dist/assets/{plus-C9qGVLFv.js → plus-Cx82jb7o.js} +1 -1
- package/dashboard/dist/assets/{provider-display-BWYNyitK.js → provider-display-CodMmiRb.js} +2 -2
- package/dashboard/dist/assets/{react-CO1HovF5.js → react-B7SkZTgg.js} +1 -1
- package/dashboard/dist/assets/safePolygon-CKpREa4K.js +1 -0
- package/dashboard/dist/assets/{search-DBnhkzG_.js → search-Ol3OZBm4.js} +1 -1
- package/dashboard/dist/assets/server-DFCbznC7.js +1 -0
- package/dashboard/dist/assets/shield-check-YcmLwVZ6.js +1 -0
- package/dashboard/dist/assets/skills-api-C-9vK884.js +1 -0
- package/dashboard/dist/assets/{sortable.esm-SVl6OixH.js → sortable.esm-CKC9NuR-.js} +1 -1
- package/dashboard/dist/assets/store-C9yWYHfg.js +1 -0
- package/dashboard/dist/assets/{terminal-kUMdPZhq.js → terminal-B3_fCLFs.js} +1 -1
- package/dashboard/dist/assets/{trash-Dd_vbrYo.js → trash-CZGfgbFa.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-Bmlmv4H-.js → use-community-stats-CW-qkYn7.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-CqZwzrCW.js → use-latest-request-guard-DHv7vfFE.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-CDC0MZRY.js → use-limits-display-prefs-NZ-AAYD5.js} +1 -1
- package/dashboard/dist/assets/use-native-settings-CWiLqfZh.js +1 -0
- package/dashboard/dist/assets/{use-ordered-list-DvBI7mUU.js → use-ordered-list-Df8pw-WJ.js} +1 -1
- package/dashboard/dist/assets/use-pet-settings-Bg2CDprr.js +2 -0
- package/dashboard/dist/assets/use-reduced-motion-iDZEUyua.js +1 -0
- package/dashboard/dist/assets/{use-transform-uSKYTYaW.js → use-transform-BHwEAfmO.js} +1 -1
- package/dashboard/dist/assets/use-usage-limits-CSxFFn3_.js +1 -0
- package/dashboard/dist/assets/{useCurrency-t1iy_pC3.js → useCurrency-pwClnCZ5.js} +1 -1
- package/dashboard/dist/assets/usePositioner-B0j1orGj.js +1 -0
- package/dashboard/dist/assets/useTokenFormat-BMvVAe6V.js +1 -0
- package/dashboard/dist/assets/{zap-DFM6AsYo.js → zap-DvX2aYx5.js} +1 -1
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/ip-check.html +2 -2
- package/dashboard/dist/leaderboard.html +2 -2
- package/dashboard/dist/pricing.html +6 -5
- package/dashboard/dist/privacy.html +3 -3
- package/dashboard/dist/share.html +2 -2
- package/dashboard/dist/terms.html +6 -6
- package/package.json +6 -2
- package/src/commands/device-login.js +60 -33
- package/src/commands/init.js +26 -7
- package/src/commands/serve.js +3 -3
- package/src/commands/sync.js +43 -22
- package/src/lib/atomic-json.js +27 -0
- package/src/lib/bearer-token.js +11 -0
- package/src/lib/cloud-account.js +4 -1
- package/src/lib/local-api.js +282 -69
- package/src/lib/openclaw-cli.js +104 -0
- package/src/lib/openclaw-hook.js +1 -46
- package/src/lib/openclaw-session-plugin.js +1 -59
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/proxy-env.js +8 -3
- package/src/lib/rollout.js +15 -10
- package/src/lib/runtime-config.js +84 -14
- package/src/lib/skills-manager.js +8 -1
- package/src/lib/static-server.js +19 -4
- package/src/lib/upload-throttle.js +18 -4
- package/dashboard/dist/assets/AchievementBadge-DPlXNqoK.js +0 -1
- package/dashboard/dist/assets/AchievementsPage-B49wjdK_.js +0 -2
- package/dashboard/dist/assets/BadgeDetailModal-DUCS6K1n.js +0 -1
- package/dashboard/dist/assets/Card-BU2CqxfU.js +0 -1
- package/dashboard/dist/assets/CommandPalette-O3pOLyJo.js +0 -1
- package/dashboard/dist/assets/CommunityStatsModal-Bt82neQ7.js +0 -1
- package/dashboard/dist/assets/Controls-D56v-YJw.js +0 -1
- package/dashboard/dist/assets/DashboardPage-CKEuFzuc.js +0 -1
- package/dashboard/dist/assets/DialogClose-C-QK97qp.js +0 -1
- package/dashboard/dist/assets/DialogDescription-COXweCuc.js +0 -1
- package/dashboard/dist/assets/LandingPage-DLDE7wdR.js +0 -2
- package/dashboard/dist/assets/LeaderboardAvatar-BqD4dEvQ.js +0 -1
- package/dashboard/dist/assets/LeaderboardPage-kgHSryiT.js +0 -2
- package/dashboard/dist/assets/LeaderboardProfileModal-zLdeOiA3.js +0 -73
- package/dashboard/dist/assets/LoginCard-Dx6MmGjU.js +0 -1
- package/dashboard/dist/assets/LoginModal-BWaZVRnT.js +0 -1
- package/dashboard/dist/assets/LoginPage-BNkU-riS.js +0 -1
- package/dashboard/dist/assets/PetPage-CyEgU2Vm.js +0 -1
- package/dashboard/dist/assets/PopoverPopup-CmUIY8lF.js +0 -1
- package/dashboard/dist/assets/ResetPasswordPage-CUXKkLb4.js +0 -1
- package/dashboard/dist/assets/SelectItemText-CZ7puxuB.js +0 -1
- package/dashboard/dist/assets/SessionsPage-D99UfBgy.js +0 -3
- package/dashboard/dist/assets/SettingsPage-DT3rld91.js +0 -2
- package/dashboard/dist/assets/SkillsPage-Dv47kVCB.js +0 -1
- package/dashboard/dist/assets/TrendMonitor-mB1x3c_o.js +0 -19
- package/dashboard/dist/assets/WidgetsPage-BhUArowe.js +0 -1
- package/dashboard/dist/assets/__vite-browser-external-BW1rxvYq.js +0 -45
- package/dashboard/dist/assets/__vite-browser-external-gKkiQad5.css +0 -1
- package/dashboard/dist/assets/agent-logos-D7f7AMF-.js +0 -1
- package/dashboard/dist/assets/composite-BgLSXWKA.js +0 -1
- package/dashboard/dist/assets/skills-api-BSkbxC8-.js +0 -1
- package/dashboard/dist/assets/store-DrEEdO_u.js +0 -1
- package/dashboard/dist/assets/use-pet-settings-C_FrqySO.js +0 -2
- package/dashboard/dist/assets/use-reduced-motion-BEOENqBa.js +0 -1
- package/dashboard/dist/assets/use-session-efficiency-pref-D8cAb4A9.js +0 -1
- package/dashboard/dist/assets/use-usage-limits-DFgOKTtv.js +0 -1
- package/dashboard/dist/assets/useTokenFormat-0bPjtaaM.js +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{q as Te,r as n,j as e,e as B,c as s,J as Le,X as Fe,l as _,ac as be,H as ke,R as cs,d as pe,aB as ds,ak as Z}from"./__vite-browser-external-BW1rxvYq.js";import{L as us,I as ms}from"./LocalOnlyNotice-RIj2XT_X.js";import{S as ne}from"./Select-B6CM0ico.js";import{C as xs}from"./SelectItemText-CZ7puxuB.js";import{S as Re}from"./search-DBnhkzG_.js";import{C as gs}from"./check-8LQ7IvkH.js";import{P as Oe,a as Ee,b as Ie,c as $e,d as Pe}from"./PopoverPopup-CmUIY8lF.js";import{P as Ae}from"./ProviderIcon-BSI-1Cy8.js";import{H as hs}from"./HoverTooltip-CrMdGYZj.js";import{u as ye}from"./useCurrency-t1iy_pC3.js";import{i as ps,C as fs}from"./host-mode-GPY2DxE4.js";import{I as bs}from"./info-BaK8Hoi2.js";import{L as ys}from"./loader-circle-DYpa-xTZ.js";import"./arrow-up-right-c39fdiDQ.js";import"./download-x3Gmv-wu.js";import"./composite-BgLSXWKA.js";import"./store-DrEEdO_u.js";const qe={name:"calendar",size:24,node:[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]]};qe.node;const _s=Te(qe);const Ke={name:"folder",size:24,node:[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};Ke.node;const ks=Te(Ke),js="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm text-oai-black outline-none hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800";function je({options:a,value:t,onChange:r,allValue:o="all",allLabel:d,searchPlaceholder:g,emptyLabel:m,ariaLabel:b,disabled:y=!1,className:j=""}){const[v,w]=n.useState(!1),[N,f]=n.useState(""),[k,p]=n.useState(-1),L=n.useRef(null),C=`${n.useId()}-listbox`,P=t===o?d:a.find(u=>u.value===t)?.label??t,M=N.trim().toLowerCase(),T=n.useMemo(()=>M?a.filter(u=>u.label.toLowerCase().includes(M)):a,[a,M]),S=n.useMemo(()=>[{value:o,label:d},...T],[o,d,T]),O=k>=0&&k<S.length?S[k]:null,A=u=>{r(u),w(!1),f(""),p(-1)};n.useEffect(()=>{v&&L.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[v,k]);const J=u=>{if(u.key==="ArrowDown"||u.key==="ArrowUp"){u.preventDefault();const D=u.key==="ArrowDown";p(R=>{const l=S.length;return l?D?R>=l-1?0:R+1:R<=0?l-1:R-1:-1});return}if(u.key==="Enter"){const D=O||(M&&T.length?T[0]:null);if(!D)return;u.preventDefault(),A(D.value)}};return e.jsxs(Oe,{open:v,onOpenChange:u=>{w(u),p(-1),u||f("")},children:[e.jsxs(Ee,{disabled:y,"aria-label":b,className:B("inline-flex h-8 max-w-[12rem] shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:hover:border-oai-gray-700",t!==o?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",j),children:[e.jsx(ks,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:P}),e.jsx(xs,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(Ie,{children:e.jsx($e,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(Pe,{className:"w-56 overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"relative mb-1",children:[e.jsx(Re,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{type:"text",role:"combobox","aria-expanded":!0,"aria-controls":C,"aria-activedescendant":O?`${C}-${k}`:void 0,value:N,onChange:u=>{f(u.target.value),p(-1)},onKeyDown:J,placeholder:g,className:"h-8 w-full rounded border border-oai-gray-200 bg-transparent pl-8 pr-2 text-xs text-oai-black outline-none placeholder:text-oai-gray-400 focus:border-oai-gray-400 dark:border-oai-gray-800 dark:text-white dark:focus:border-oai-gray-500"})]}),e.jsxs("div",{ref:L,id:C,role:"listbox","aria-label":b,className:"max-h-64 overflow-y-auto",children:[S.map((u,D)=>e.jsxs("button",{id:`${C}-${D}`,type:"button",role:"option","aria-selected":t===u.value,"data-active":D===k?"true":void 0,onMouseEnter:()=>p(D),onClick:()=>A(u.value),className:B(js,t===u.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",D===k&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:u.label}),t===u.value?e.jsx(gs,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},u.value)),T.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:m}):null]})]})})})]})}const vs="tokentracker-sessions";async function ws(a={}){const t=new URL(`/functions/${vs}`,window.location.origin);a.from&&t.searchParams.set("from",a.from),a.to&&t.searchParams.set("to",a.to),a.limit&&t.searchParams.set("limit",String(a.limit)),a.refresh&&t.searchParams.set("refresh","1");const r=await fetch(t.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),o=await r.json().catch(()=>null);if(!r.ok){const d=r.status===404?s("sessions.error.outdated_app"):`Request failed with HTTP ${r.status}`,g=new Error(o?.error||d);throw g.status=r.status,g}return o}function Ue(a,t,{timeOnly:r=!1}={}){if(!a)return"—";const o=Date.parse(a);if(!Number.isFinite(o))return"—";const d=r?{hour:"2-digit",minute:"2-digit"}:{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"};try{return new Date(o).toLocaleString(t||void 0,d)}catch{const g=new Date(o).toISOString();return r?g.slice(11,16):g.slice(0,16).replace("T"," ")}}function ze(a){const t=Number(a);if(!Number.isFinite(t)||t<=0)return null;const r=Math.round(t/6e4);if(r<60)return s("sessions.duration.minutes",{minutes:r});const o=Math.floor(r/60),d=r%60;return s("sessions.duration.hours",{hours:o,minutes:d})}function te(a){return W(a?.own_total_tokens??a?.total_tokens)}function ae(a){return W(a?.own_cost_usd??a?.cost_usd)}function W(a){const t=Number(a);return Number.isFinite(t)&&t>=0?t:0}function V(a){const t=Array.isArray(a?.model_usage)?a.model_usage.filter(r=>r&&typeof r.model=="string"&&r.model):[];return t.length?t:[{model:a?.model||"",total_tokens:te(a),cost_usd:ae(a),performance:a?.performance}]}function Ns(a){const t={estimated_output_tokens:0,estimated_duration_ms:0,estimated_request_count:0,estimated_tokens_per_second:null,first_response_total_ms:0,first_response_sample_count:0,first_response_ms:null};for(const r of a){const o=r?.performance;if(!o)continue;const d=W(o.estimated_duration_ms),g=W(o.estimated_output_tokens),m=W(o.estimated_request_count);d>0&&g>0&&m>0&&(t.estimated_output_tokens+=g,t.estimated_duration_ms+=d,t.estimated_request_count+=m);const b=W(o.first_response_sample_count),y=W(o.first_response_total_ms);b>0&&y>0&&(t.first_response_total_ms+=y,t.first_response_sample_count+=b)}return t.estimated_duration_ms>0&&(t.estimated_tokens_per_second=t.estimated_output_tokens*1e3/t.estimated_duration_ms),t.first_response_sample_count>0&&(t.first_response_ms=t.first_response_total_ms/t.first_response_sample_count),t}function Ge(a){const t=new Set,r=a.filter(o=>t.has(o.session_hash)?!1:(t.add(o.session_hash),!0));return{count:r.length,tokens:r.reduce((o,d)=>o+te(d),0),cost:r.reduce((o,d)=>o+ae(d),0),costIsPartial:r.some(o=>o.cost_is_partial),performance:Ns(r)}}function fe(a){const t=Date.parse(a?.ended_at||a?.started_at||"");return Number.isFinite(t)?t:0}function Ss(a,t){return[...a].sort((r,o)=>(t==="cost"?ae(o)-ae(r):t==="tokens"?te(o)-te(r):0)||fe(o)-fe(r))}function le(a){const t=fe(a);if(!t)return"";const r=new Date(t);return`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function Cs(a,t){const r=new Map;for(const o of a){const d=t==="project"?o.project_key||"":le(o),g=r.get(d)||{key:d,sessions:[]};g.sessions.push(o),r.set(d,g)}return[...r.values()]}function Ms(a){const t=new URLSearchParams(a),r=t.get("source"),o=m=>{const b=t.get(m)||"";if(!/^\d{4}-\d{2}-\d{2}$/.test(b))return"";const y=new Date(`${b}T00:00:00`);return Number.isFinite(y.getTime())&&le({ended_at:y.toISOString()})===b?b:""},d=o("from"),g=o("to");return{source:["claude","codex","grok"].includes(r)?r:"all",model:t.get("model")||"all",from:d,to:g}}function Ds(a,t,r){let o=t?new Date(`${t}T00:00:00`).getTime():0,d=r?new Date(`${r}T23:59:59.999`).getTime():1/0;o>d&&(o=new Date(`${r}T00:00:00`).getTime(),d=new Date(`${t}T23:59:59.999`).getTime());const g=Date.parse(a.ended_at||a.started_at||""),m=Date.parse(a.started_at||a.ended_at||"");return(!Number.isFinite(g)||g>=o)&&(!Number.isFinite(m)||m<=d)}function se({performance:a,className:t=""}){const r=Number(a?.estimated_tokens_per_second),o=Number(a?.estimated_request_count||0);return!Number.isFinite(r)||r<=0||o<=0?null:e.jsx("span",{className:t,title:`${s("sessions.performance.samples",{count:o})}
|
|
2
|
-
${s("sessions.performance.method")}`,children:s("sessions.performance.speed",{speed:Number(r.toFixed(1))})})}const Ts=[{key:"input_tokens",label:()=>s("dashboard.projects.detail.comp_input")},{key:"cached_input_tokens",label:()=>s("dashboard.projects.detail.comp_cached")},{key:"cache_creation_input_tokens",label:()=>s("dashboard.projects.detail.comp_cache_write")},{key:"output_tokens",label:()=>s("dashboard.projects.detail.comp_output")},{key:"reasoning_output_tokens",label:()=>s("dashboard.projects.detail.comp_reasoning")}],Ls=[{key:"turns",label:()=>s("sessions.col.turns")},{key:"edit_turns",label:()=>s("sessions.col.edits")},{key:"retry_turns",label:()=>s("sessions.detail.retries")},{key:"subagent_calls",label:()=>s("sessions.card.subagents")},{key:"tool_calls",grokOnly:!0,label:()=>s("sessions.detail.tools")},{key:"tool_failures",grokOnly:!0,label:()=>s("sessions.detail.tool_failures")},{key:"error_count",grokOnly:!0,label:()=>s("sessions.detail.errors")},{key:"model_calls",grokOnly:!0,label:()=>s("sessions.detail.model_calls")},{key:"compaction_count",grokOnly:!0,label:()=>s("sessions.detail.compactions")}];function Fs(a){return a==="provider_reported"?s("sessions.detail.cost_reported"):a==="model_pricing"?s("sessions.detail.cost_estimated"):a==="mixed"?s("sessions.detail.cost_mixed"):s("sessions.detail.cost_unknown")}function ve(a){return String(a||"").startsWith("litellm")?s("sessions.detail.pricing_litellm"):String(a||"").startsWith("curated")?s("sessions.detail.pricing_curated"):null}function Rs(a,t){return t||Number(a)>0}function we({label:a,children:t}){return e.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:a}),e.jsx("dd",{className:"min-w-0 break-words text-right text-sm tabular-nums text-oai-black dark:text-white",children:t})]})}function ie({label:a,title:t,className:r="",children:o}){return e.jsxs("div",{className:`min-w-0 border-oai-gray-200 px-3 py-2.5 dark:border-oai-gray-800 ${r}`,title:t,children:[e.jsx("dt",{className:"truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"mt-0.5 truncate text-base font-medium tabular-nums text-oai-black dark:text-white",children:o})]})}function Os({session:a,subagents:t=[],onClose:r}){const o=n.useRef(null),d=n.useRef(null),{currency:g,rate:m}=ye(),{resolvedLocale:b}=Le(),y=l=>be(l,{currency:g,rate:m}),j=V(a),v=n.useMemo(()=>Ge(t),[t]),w=te(a),N=ae(a),f=Number(a.subagent_total_tokens??v.tokens),k=Number(a.subagent_cost_usd??v.cost),p=a.performance,L=Number(p?.estimated_tokens_per_second)>0&&Number(p?.estimated_request_count)>0,C=Number(p?.first_response_sample_count)>0&&p?.first_response_ms!=null&&Number.isFinite(Number(p.first_response_ms)),P=C?{seconds:(Number(p.first_response_ms)/1e3).toFixed(2),count:p.first_response_sample_count}:null,M=Number(a.reasoning_output_tokens)>0,T=a.source==="grok",S=T&&Number(a.context_window_tokens)>0;n.useEffect(()=>{const l=document.activeElement,E=document.body.style.overflow;document.body.style.overflow="hidden",o.current?.focus();const I=F=>{if(F.key==="Escape"&&(F.preventDefault(),r()),F.key!=="Tab")return;const K=Array.from(d.current?.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), summary, [tabindex="0"]')||[]),X=K[0],Y=K[K.length-1];X?F.shiftKey&&(document.activeElement===X||!d.current?.contains(document.activeElement))?(F.preventDefault(),Y.focus()):!F.shiftKey&&(document.activeElement===Y||!d.current?.contains(document.activeElement))&&(F.preventDefault(),X.focus()):(F.preventDefault(),d.current?.focus())};return window.addEventListener("keydown",I),()=>{window.removeEventListener("keydown",I),document.body.style.overflow=E,l instanceof HTMLElement&&l.isConnected&&l.focus()}},[r]);const O=f>0||k>0,A=a.cost_is_partial||O&&v.costIsPartial,J=[{label:s("sessions.detail.own"),tokens:w,cost:N,partial:a.cost_is_partial},{label:s("sessions.detail.subagents"),tokens:f,cost:k,partial:v.costIsPartial}],u=a.agent_nickname||a.title||a.project_key||s("sessions.project.unknown"),D=ze(a.duration_ms),R=[a.project_key&&a.project_key!==u?a.project_key:null,Ue(a.started_at,b),D].filter(Boolean);return e.jsx("div",{className:"fixed inset-0 z-50 flex justify-end bg-black/20 dark:bg-black/40",onClick:l=>{l.target===l.currentTarget&&r()},children:e.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-label":s("sessions.detail.title"),tabIndex:-1,className:"flex h-full w-full max-w-[36rem] flex-col border-l border-oai-gray-200 bg-white dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[e.jsxs("header",{className:"flex shrink-0 items-start gap-3 border-b border-oai-gray-200 px-5 py-4 dark:border-oai-gray-800",children:[e.jsx("span",{className:"shrink-0 pt-0.5 text-oai-gray-600 dark:text-oai-gray-300",children:e.jsx(Ae,{provider:String(a.source||"").toUpperCase(),size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"break-words text-base font-semibold leading-6 text-oai-black dark:text-white",children:u}),e.jsx("p",{className:"mt-0.5 break-words text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:R.join(" · ")})]}),e.jsx("button",{ref:o,type:"button",onClick:r,"aria-label":s("sessions.detail.close"),className:"-mr-2 -mt-1 flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-oai-gray-500 hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white sm:h-9 sm:w-9",children:e.jsx(Fe,{size:18,"aria-hidden":!0})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 py-5",children:[e.jsxs("section",{"aria-label":s("sessions.detail.consumption"),children:[e.jsxs("dl",{className:"grid grid-cols-2 overflow-hidden rounded-lg border border-oai-gray-200 dark:border-oai-gray-800",children:[e.jsx(ie,{label:s("sessions.col.tokens"),children:_(w+f)}),e.jsxs(ie,{label:s("sessions.col.cost"),className:"border-l",children:[A?"≥":"",y(N+k)]}),e.jsx(ie,{label:s("sessions.summary.speed"),className:"border-t",title:L?s("sessions.performance.samples",{count:p.estimated_request_count}):s("sessions.detail.no_speed"),children:L?e.jsx(se,{performance:p}):"—"}),e.jsx(ie,{label:s("sessions.performance.first_response"),className:"border-l border-t",title:s("sessions.performance.first_response_method"),children:C?Number(p.first_response_sample_count)===1?s("sessions.performance.first_response_value_single",P):s("sessions.performance.first_response_value",P):"—"})]}),O?e.jsx("dl",{className:"mt-3 space-y-1.5",children:J.map(l=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_80px_88px] items-baseline gap-3 text-sm",children:[e.jsx("dt",{className:"text-oai-gray-600 dark:text-oai-gray-300",children:l.label}),e.jsx("dd",{className:"text-right tabular-nums",children:_(l.tokens)}),e.jsxs("dd",{className:"text-right tabular-nums",children:[l.partial?"≥":"",y(l.cost)]})]},l.label))}):null,e.jsxs("p",{className:"mt-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:[s("sessions.detail.cost_source")," · ",Fs(a.cost_source),a.cost_is_partial?e.jsxs("span",{className:"text-amber-700 dark:text-amber-300",children:[" · ",s("sessions.cost.partial_title")]}):null,a.usage_is_incomplete?e.jsxs("span",{className:"text-amber-700 dark:text-amber-300",children:[" · ",s("sessions.badge.partial_usage")]}):null]})]}),e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-black dark:text-white",children:s("sessions.detail.tokens")}),e.jsx("dl",{className:"mt-2 grid grid-cols-1 gap-x-8 gap-y-1.5 sm:grid-cols-2",children:Ts.map(({key:l,label:E})=>e.jsx(we,{label:E(),children:a[l]==null?"—":_(a[l])},l))})]}),e.jsxs("section",{className:"mt-6",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_80px_88px] items-baseline gap-3",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-black dark:text-white",children:s("sessions.detail.models")}),e.jsx("span",{className:"text-right text-xs text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0,children:s("sessions.col.tokens")}),e.jsx("span",{className:"text-right text-xs text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0,children:s("sessions.col.cost")})]}),e.jsx("ul",{className:"mt-1 divide-y divide-oai-gray-100 dark:divide-oai-gray-800/70",children:j.map(l=>{const E=l.pricing?.status==="unpriced",I=a.cost_source==="provider_reported"&&j.length===1,F=I?N:l.cost_usd,K=Rs(F,I);return e.jsxs("li",{className:"py-2.5",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_80px_88px] items-baseline gap-3 text-sm",children:[e.jsx("span",{className:"min-w-0 break-words text-oai-black dark:text-white",children:l.model||s("sessions.model.unknown")}),e.jsx("span",{className:"text-right tabular-nums",children:_(l.total_tokens)}),e.jsx("span",{className:"text-right tabular-nums",children:E&&!K?"—":y(F)})]}),l.pricing?e.jsxs("details",{className:"group text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsxs("summary",{className:"flex min-h-10 cursor-pointer list-none items-center gap-2 rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 sm:min-h-0 sm:pt-1 [&::-webkit-details-marker]:hidden",children:[e.jsx(se,{performance:l.performance,className:"tabular-nums"}),e.jsx("span",{className:"underline decoration-dotted underline-offset-4 group-open:no-underline",children:s("sessions.detail.pricing_details")})]}),e.jsxs("div",{className:"space-y-1 pt-1.5 leading-5",children:[E?e.jsx("p",{children:s("sessions.detail.pricing_unpriced")}):null,l.pricing.status==="free"?e.jsx("p",{children:s("sessions.detail.pricing_free")}):null,l.pricing.status==="priced"?e.jsx("p",{children:s("sessions.detail.pricing_rates",{input:l.pricing.input,output:l.pricing.output,cacheRead:l.pricing.cache_read,cacheWrite:l.pricing.cache_write})}):null,ve(l.pricing.source)?e.jsx("p",{children:ve(l.pricing.source)}):null]})]}):e.jsx(se,{performance:l.performance,className:"block pt-1 text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400"})]},l.model)})})]}),e.jsxs("details",{className:"mt-5 border-t border-oai-gray-200 dark:border-oai-gray-800",children:[e.jsx("summary",{className:"flex min-h-11 cursor-pointer items-center rounded text-sm font-medium text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-white",children:s("sessions.detail.signals")}),e.jsx("dl",{className:"grid grid-cols-1 gap-x-8 gap-y-1.5 pb-4 sm:grid-cols-2",children:Ls.map(({key:l,label:E,grokOnly:I})=>e.jsx(we,{label:E(),children:typeof a[l]=="number"&&(!I||T)?_(a[l]):s("sessions.detail.not_recorded")},l))}),T&&a.usage_precision?e.jsx("p",{className:"pb-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.grok.runtime_breakdown",{calls:_(a.model_calls),seconds:(Number(a.api_duration_ms||0)/1e3).toFixed(1),tools:_(a.tool_calls),errors:_(a.error_count)})}):null,S?e.jsx("p",{className:"pb-3 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.grok.context_breakdown",{used:_(a.context_tokens_used),window:_(a.context_window_tokens),percent:Number(a.context_usage_percent||0).toFixed(0)})}):null]}),e.jsxs("details",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800",children:[e.jsx("summary",{className:"flex min-h-11 cursor-pointer items-center rounded text-sm font-medium text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-white",children:s("sessions.detail.identifiers")}),e.jsxs("dl",{className:"space-y-3 pb-4",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:s("sessions.detail.session_id")}),e.jsx("dd",{className:"mt-1 break-all font-mono text-xs leading-5",children:a.session_id||a.session_hash})]}),a.project_ref?e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:s("sessions.detail.local_path")}),e.jsx("dd",{className:"mt-1 break-all font-mono text-xs leading-5",children:a.project_ref})]}):null,a.resume_command?e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:s("sessions.detail.resume_command")}),e.jsx("dd",{className:"mt-1 break-all font-mono text-xs leading-5",children:a.resume_command})]}):null]})]}),e.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-oai-gray-200 pt-4 text-xs leading-5 text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[L?e.jsx("p",{children:s("sessions.performance.method")}):null,M?e.jsx("p",{children:s("sessions.detail.reasoning_note")}):null,e.jsx("p",{children:s("sessions.privacy")})]})]})]})})}const Ne=ps(),Se=[],he=100,Es=[{id:"all",label:()=>s("usage.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"grok",label:()=>"Grok"}],He=[{id:"all",days:0,label:()=>s("sessions.filter.range_label_all")},{id:"7d",days:7,label:()=>s("sessions.filter.range_7d")},{id:"30d",days:30,label:()=>s("sessions.filter.range_30d")},{id:"90d",days:90,label:()=>s("sessions.filter.range_90d")}];function Is(a){const t=He.find(o=>o.id===a)?.days||0;if(!t)return 0;const r=new Date;return r.setDate(r.getDate()-(t-1)),r.setHours(0,0,0,0),r.getTime()}function $s(a,t){if(!t)return!0;const r=Date.parse(a.ended_at||a.started_at||"");return Number.isFinite(r)?r>=t:!0}function Ps(a){const t=Date.parse(a.started_at||"");return!Number.isFinite(t)||le({started_at:a.started_at})===le(a)}function Ce(a){const t=V(a);return t.length===1?t[0].model||s("sessions.model.unknown"):t.map(r=>`${r.model} ${_(Number(r.total_tokens||0))}`).join(" · ")}async function Me(a){if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(a),!0;const t=document.createElement("textarea");t.value=a,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const r=document.execCommand("copy");return document.body.removeChild(t),r}const De=pe.memo(function({session:t,locale:r,nested:o=!1,timeOnly:d=!1,childCount:g=0,expanded:m=!1,onToggle:b,onDetail:y}){const{currency:j,rate:v}=ye(),w=String(t.source||"").toUpperCase(),N=ze(t.duration_ms),f=t.resume_command,k=t.project_key||s("sessions.project.unknown"),p=o||t.thread_kind==="subagent",L=p?t.agent_nickname||t.agent_role||t.title||k:t.title||k,C=t.usage_is_incomplete?s("sessions.badge.partial_usage"):t.cost_is_partial?s("sessions.badge.partial_cost"):null,P=t.project_ref?`${t.project_ref}
|
|
3
|
-
${s("sessions.project.copy_hint")}`:void 0,M=async()=>{if(t.project_ref)try{await Me(t.project_ref)?Z({title:s("sessions.project.copied")}):Z({title:s("sessions.project.copy_failed")})}catch{Z({title:s("sessions.project.copy_failed")})}},T=O=>e.jsxs("span",{className:"group relative inline-flex min-w-0 max-w-full",children:[e.jsx(hs,{text:P,placement:"bottom"}),e.jsx("button",{type:"button",onClick:M,"aria-label":s("sessions.project.copy_aria",{project:k}),className:B("max-w-full truncate rounded text-left underline decoration-dotted decoration-oai-gray-300 underline-offset-4 hover:decoration-oai-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:decoration-oai-gray-600 dark:hover:decoration-oai-gray-400",O),children:k})]}),S=async()=>{if(f)try{await Me(f)?Z({title:s("sessions.resume.copied")}):Z({title:s("sessions.resume.copy_failed")})}catch{Z({title:s("sessions.resume.copy_failed")})}};return e.jsxs("li",{className:B("sessions-row sessions-row-grid py-3",o&&"sessions-row-nested"),children:[e.jsxs("div",{className:"sessions-row-identity flex min-w-0 items-start gap-3",children:[e.jsx("span",{className:"shrink-0 pt-2 text-oai-gray-600 dark:text-oai-gray-300 md:pt-0.5",children:e.jsx(Ae,{provider:w,size:o?16:18})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>y(t),"aria-label":s("sessions.detail.open_aria",{title:L}),title:L,className:"min-h-9 max-w-full truncate rounded text-left text-sm font-medium text-oai-black underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-white md:min-h-0",children:L}),e.jsxs("div",{className:"sessions-row-meta mt-0.5 flex min-w-0 flex-wrap items-center gap-y-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{className:"sessions-meta-item min-w-0 max-w-full",children:t.project_ref?T("min-h-6 inline-flex items-center md:min-h-0"):e.jsx("span",{className:"truncate",children:k})}),e.jsx("span",{className:"sessions-meta-item min-w-0 max-w-full truncate",title:Ce(t),children:Ce(t)}),e.jsx("span",{className:"sessions-meta-item tabular-nums",children:Ue(t.started_at,r,{timeOnly:d&&Ps(t)})}),N?e.jsx("span",{className:"sessions-meta-item tabular-nums",children:N}):null,p?e.jsxs("span",{className:"sessions-meta-item",children:[s("sessions.badge.subagent"),t.agent_role?` · ${t.agent_role}`:""]}):null,t.first_pass?e.jsx("span",{className:"sessions-meta-item text-emerald-700 dark:text-emerald-300",children:s("sessions.badge.first_pass")}):null,C?e.jsx("span",{className:"sessions-meta-item text-amber-700 dark:text-amber-300",children:C}):null,t.cost_source==="provider_reported"?e.jsx("span",{className:"sessions-meta-item",children:s("sessions.badge.reported_cost")}):null,g?e.jsxs("button",{type:"button",onClick:()=>b(t.session_hash),"aria-expanded":m,className:"-mx-1.5 inline-flex min-h-8 items-center md:-my-1 md:ml-2 md:mr-0 gap-0.5 rounded px-1.5 font-medium text-oai-gray-700 hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-200 dark:hover:bg-oai-gray-800 dark:hover:text-white md:min-h-6",children:[e.jsx(ds,{className:B("h-3.5 w-3.5 transition-transform",m&&"rotate-90"),"aria-hidden":!0}),m?s("sessions.thread.collapse",{count:g}):s("sessions.thread.expand",{count:g})]}):null]})]})]}),e.jsxs("dl",{className:"sessions-row-metrics",children:[e.jsxs("div",{className:"sessions-row-value",children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 md:sr-only",children:s("sessions.col.tokens")}),e.jsxs("dd",{title:Number(t.subagent_total_tokens)?s("sessions.thread.tokens_summary",{own:_(t.own_total_tokens),subagents:_(t.subagent_total_tokens),combined:_(t.combined_total_tokens)}):void 0,className:"mt-1 text-sm tabular-nums text-oai-black dark:text-white md:mt-0",children:[_(t.total_tokens),Number(t.subagent_total_tokens)?e.jsxs("span",{className:"mt-0.5 block text-xs text-oai-gray-500 dark:text-oai-gray-400",children:["Σ ",_(t.combined_total_tokens)]}):null]})]}),e.jsxs("div",{className:"sessions-row-value",children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 md:sr-only",children:s("sessions.col.cost")}),e.jsxs("dd",{className:"mt-1 text-sm tabular-nums text-oai-black dark:text-white md:mt-0",title:t.cost_is_partial?s("sessions.cost.partial_title"):void 0,children:[t.cost_is_partial?"≥":"",be(t.cost_usd,{currency:j,rate:v})]})]}),e.jsxs("div",{className:"sessions-row-value",children:[e.jsx("dt",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 md:sr-only",children:s("sessions.col.speed")}),e.jsx("dd",{className:"mt-1 min-h-5 text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 md:mt-0",children:e.jsx(se,{performance:t.performance})})]})]}),e.jsx("button",{type:"button",onClick:S,disabled:!f,title:f||s("sessions.resume.unavailable"),"aria-label":f?s("sessions.resume.copy_aria",{command:f}):s("sessions.resume.unavailable"),className:"sessions-row-action inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-oai-gray-500 transition hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:cursor-not-allowed dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white md:h-8 md:w-8",children:e.jsx(fs,{className:"h-4 w-4","aria-hidden":!0})})]})});function As({sessions:a,selectedModel:t,onSelect:r}){const{groups:o,totalTokens:d}=n.useMemo(()=>{const m=new Map;let b=0;for(const y of a)for(const j of V(y)){const v=j.model||s("sessions.model.unknown"),w=Number(j.total_tokens||0),N=m.get(v)||{model:v,count:0,tokens:0};N.count+=1,N.tokens+=w,b+=w,m.set(v,N)}return{groups:[...m.values()].sort((y,j)=>j.tokens-y.tokens),totalTokens:b}},[a]);function g(m){return B("min-h-10 rounded-md border px-2.5 text-xs tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 md:min-h-7",m?"border-oai-brand-500 bg-oai-brand-50 text-oai-brand-700 dark:bg-oai-brand-500/10 dark:text-oai-brand-300":"border-oai-gray-200 text-oai-gray-600 hover:bg-oai-gray-100 dark:border-oai-gray-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800")}return e.jsx("li",{className:"sessions-thread-models py-2.5",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"mr-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.thread.model_usage")}),e.jsx("button",{type:"button","aria-pressed":t==="all",onClick:()=>r("all"),className:g(t==="all"),children:s("sessions.thread.model_all",{count:a.length,tokens:_(d)})}),o.map(m=>e.jsx("button",{type:"button","aria-pressed":t===m.model,onClick:()=>r(m.model),className:g(t===m.model),children:s("sessions.thread.model_item",{model:m.model,count:m.count,tokens:_(m.tokens)})},m.model))]})})}function at(){const[a]=n.useState(()=>Ms(window.location.search)),[t,r]=n.useState(null),[o,d]=n.useState(null),[g,m]=n.useState(!0),[b,y]=n.useState(!1),[j,v]=n.useState(a.source),[w,N]=n.useState(a.model),[f,k]=n.useState(a.from||a.to?"custom":"all"),[p,L]=n.useState(a.from),[C,P]=n.useState(a.to),[M,T]=n.useState("all"),[S,O]=n.useState("time"),[A,J]=n.useState("recent"),[u,D]=n.useState(null),[R,l]=n.useState(""),[E,I]=n.useState(he),[F,K]=n.useState(()=>new Set),[X,Y]=n.useState(()=>new Map),re=n.useRef(0),{resolvedLocale:G}=Le(),{currency:We,rate:Ve}=ye(),oe=n.useCallback(async(i=!1)=>{const x=++re.current;i?y(!0):m(!0),d(null);try{const c=await ws({refresh:i});x===re.current&&r(c)}catch(c){x===re.current&&d(c?.message||String(c))}finally{x===re.current&&(m(!1),y(!1))}},[]);n.useEffect(()=>{Ne||ke()?oe(!1):m(!1)},[oe]);const $=t?.sessions||Se,Be=n.useMemo(()=>{const i=new Set,x=[];for(const c of $){const h=c.project_key;!h||i.has(h)||(i.add(h),x.push({value:h,label:h}))}return x.sort((c,h)=>c.label.localeCompare(h.label))},[$]),Qe=n.useMemo(()=>{const i=new Set;for(const x of $)for(const c of V(x))c.model&&i.add(c.model);return[...i].sort().map(x=>({value:x,label:x}))},[$]),ce=n.useDeferredValue(R),U=n.useMemo(()=>{const i=ce.trim().toLowerCase(),x=Is(f);return $.filter(c=>{if(j!=="all"&&c.source!==j||M!=="all"&&c.project_key!==M||w!=="all"&&!V(c).some(z=>z.model===w))return!1;if(f==="custom"){if(!Ds(c,p,C))return!1}else if(!$s(c,x))return!1;if(!i)return!0;const h=V(c).map(z=>z.model).join(" ");return`${c.title||""} ${c.project_key||""} ${h} ${c.agent_nickname||""} ${c.agent_role||""} ${c.project_ref||""} ${c.session_id||""}`.toLowerCase().includes(i)})},[$,j,M,w,f,p,C,ce]),Q=n.useMemo(()=>Ge(U),[U]),H=n.useMemo(()=>{const i=new Set(U.map(h=>h.session_hash)),x=new Map,c=[];for(const h of Ss(U,A)){const q=h.root_session_hash||h.parent_session_hash;if(h.parent_session_hash&&q&&i.has(q)){const z=x.get(q)||[];z.push(h),x.set(q,z)}else c.push(h)}return{roots:c,childrenByRoot:x,foldedCount:U.length-c.length}},[U,A]),de=j!=="all"||w!=="all"||f!=="all"||M!=="all"||R.trim()!=="";n.useEffect(()=>{I(he),K(new Set),Y(new Map)},[j,M,w,f,p,C,ce,A,S,$]);const ue=n.useMemo(()=>H.roots.slice(0,E),[H.roots,E]),Ze=n.useMemo(()=>Cs(ue,S),[ue,S]),Je=n.useMemo(()=>u?$.filter(i=>i.session_hash!==u.session_hash&&(i.root_session_hash===u.session_hash||i.parent_session_hash===u.session_hash)):Se,[$,u]),Xe=n.useCallback(()=>D(null),[]),me=n.useCallback(i=>{k(i),i!=="custom"&&(L(""),P(""))},[]),Ye=n.useCallback(()=>{v("all"),N("all"),T("all"),l(""),me("all")},[me]),xe=H.roots.length>ue.length,ge=n.useCallback(()=>I(i=>i+he),[]),es=n.useCallback(i=>{K(x=>{const c=new Set(x);return c.has(i)?c.delete(i):c.add(i),c})},[]),ss=n.useCallback((i,x)=>{Y(c=>{const h=new Map(c);return x==="all"?h.delete(i):h.set(i,x),h})},[]),_e=n.useRef(null);n.useEffect(()=>{if(!xe||typeof IntersectionObserver>"u")return;const i=_e.current;if(!i)return;const x=new IntersectionObserver(c=>{c.some(h=>h.isIntersecting)&&ge()},{rootMargin:"400px"});return x.observe(i),()=>x.disconnect()},[xe,ge]);const ts=n.useMemo(()=>Es.map(i=>({value:i.id,label:i.label()})),[G]),as=n.useMemo(()=>[...He.map(i=>({value:i.id,label:i.label()})),{value:"custom",label:s("sessions.filter.range_custom")}],[G]),rs=n.useMemo(()=>[{value:"time",label:s("sessions.group.time")},{value:"project",label:s("sessions.group.project")}],[G]),os=n.useMemo(()=>[{value:"recent",label:s("sessions.sort.recent")},{value:"cost",label:s("sessions.sort.cost")},{value:"tokens",label:s("sessions.sort.tokens")}],[G]),ns=Number(t?.session_count)>Number(t?.returned_count);return!Ne&&!ke()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(us,{})}):e.jsxs("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:[e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("header",{className:"mb-8 flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"mb-3 text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:s("nav.sessions")}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:s("sessions.page.summary")})]}),e.jsx("button",{type:"button",onClick:()=>{oe(!0)},disabled:b||g,"aria-label":s("sessions.page.refresh"),title:s("sessions.page.refresh"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(cs,{className:B("h-4 w-4",b&&"animate-spin"),"aria-hidden":!0})})]}),e.jsxs("div",{className:"mb-6 space-y-3",children:[e.jsxs("div",{className:"sessions-toolbar",children:[e.jsxs("div",{className:"sessions-toolbar-search relative",children:[e.jsx(Re,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0}),e.jsx(ms,{type:"search",value:R,onChange:i=>l(i.target.value),onKeyDown:i=>{i.key==="Escape"&&R&&(i.preventDefault(),l(""))},"aria-label":s("sessions.action.search_aria"),placeholder:s("sessions.search.placeholder"),className:"h-11 pl-10 pr-12 text-sm !bg-white dark:!bg-oai-gray-900 !border-oai-gray-200 placeholder:!text-oai-gray-500 dark:!border-oai-gray-800 dark:placeholder:!text-oai-gray-400 sm:h-9 [&::-webkit-search-cancel-button]:appearance-none"}),R?e.jsx("button",{type:"button",onMouseDown:i=>i.preventDefault(),onClick:()=>l(""),"aria-label":s("sessions.action.search_clear"),className:"absolute right-0 top-0 flex h-11 w-11 items-center justify-center rounded-md text-oai-gray-600 hover:bg-oai-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 sm:h-9 sm:w-9",children:e.jsx(Fe,{className:"h-4 w-4","aria-hidden":!0})}):null]}),e.jsx(ne,{ariaLabel:s("sessions.filter.source_aria"),options:ts,value:j,onValueChange:v,className:"sessions-filter-trigger h-11 min-w-0 px-3 text-sm sm:h-9",matchTriggerWidth:!0}),e.jsx(ne,{ariaLabel:s("sessions.filter.range_aria"),options:as,value:f,onValueChange:me,leadingIcon:e.jsx(_s,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0}),className:"sessions-filter-trigger h-11 min-w-0 px-3 text-sm sm:h-9",matchTriggerWidth:!0}),e.jsx(je,{options:Be,value:M,onChange:T,allLabel:s("sessions.filter.project_all"),searchPlaceholder:s("sessions.filter.project_search"),emptyLabel:s("sessions.filter.project_empty"),ariaLabel:s("sessions.filter.project_aria"),className:"sessions-filter-trigger !h-11 !w-full !max-w-none !px-3 !text-sm !font-normal sm:!h-9 !bg-white !text-oai-black dark:!bg-oai-gray-900 dark:!text-white [&>svg]:!text-oai-gray-500 dark:[&>svg]:!text-oai-gray-400"}),e.jsx(je,{options:Qe,value:w,onChange:N,allLabel:s("sessions.filter.model_all"),searchPlaceholder:s("sessions.filter.model_search"),emptyLabel:s("sessions.filter.model_empty"),ariaLabel:s("sessions.filter.model_aria"),className:"sessions-filter-trigger sessions-model-filter !h-11 !w-full !max-w-none !px-3 !text-sm !font-normal sm:!h-9 !bg-white !text-oai-black dark:!bg-oai-gray-900 dark:!text-white [&>svg]:!text-oai-gray-500 dark:[&>svg]:!text-oai-gray-400"})]}),f==="custom"?e.jsxs("div",{className:"grid max-w-lg grid-cols-2 gap-3",children:[e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"mb-1 block",children:s("sessions.filter.from")}),e.jsx("input",{type:"date","aria-label":s("sessions.filter.from"),value:p,onChange:i=>L(i.target.value),className:"h-11 w-full min-w-0 rounded-md border border-oai-gray-200 bg-white px-3 text-sm outline-none focus:ring-2 focus:ring-oai-brand-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:h-10"})]}),e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"mb-1 block",children:s("sessions.filter.to")}),e.jsx("input",{type:"date","aria-label":s("sessions.filter.to"),value:C,onChange:i=>P(i.target.value),className:"h-11 w-full min-w-0 rounded-md border border-oai-gray-200 bg-white px-3 text-sm outline-none focus:ring-2 focus:ring-oai-brand-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:h-10"})]})]}):null]}),!g&&t?e.jsxs("section",{className:"mb-6 flex items-start gap-3 rounded-lg border border-oai-gray-200 px-4 py-3 dark:border-oai-gray-800",children:[e.jsxs("dl",{className:"sessions-kpis grid min-w-0 flex-1 grid-cols-2 gap-y-3 sm:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.summary.count")}),e.jsx("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:_(Q.count)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.col.tokens")}),e.jsx("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:_(Q.tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.col.cost")}),e.jsxs("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:[Q.costIsPartial?"≥":"",be(Q.cost,{currency:We,rate:Ve})]})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.summary.speed")}),e.jsxs("dd",{className:"mt-1 text-lg font-medium tabular-nums",children:[e.jsx(se,{performance:Q.performance}),Q.performance.estimated_tokens_per_second==null?"—":null]})]})]}),e.jsxs(Oe,{children:[e.jsx(Ee,{"aria-label":s("sessions.summary.scope_help"),className:"-mr-2 flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-oai-gray-500 hover:bg-oai-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 sm:h-8 sm:w-8",children:e.jsx(bs,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Ie,{children:e.jsx($e,{side:"bottom",align:"end",sideOffset:8,className:"z-[60]",children:e.jsx(Pe,{className:"max-w-xs rounded-lg border border-oai-gray-200 bg-white p-4 text-sm leading-6 text-oai-gray-700 outline-none dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-gray-200",children:s("sessions.summary.scope")})})})]})]}):null,e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-x-3 gap-y-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 text-xs tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:H.foldedCount>0?s("sessions.thread.result_count",{roots:H.roots.length,subagents:H.foldedCount}):s("sessions.filter.result_count",{filtered:U.length,total:$.length})}),de?e.jsx("button",{type:"button",onClick:Ye,className:"inline-flex min-h-10 items-center rounded text-oai-gray-700 underline decoration-oai-gray-300 underline-offset-4 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-200 dark:decoration-oai-gray-600 dark:hover:text-white sm:min-h-0",children:s("sessions.filter.clear")}):null]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(ne,{ariaLabel:s("sessions.group.aria"),options:rs,value:S,onValueChange:O,className:"sessions-filter-trigger h-11 min-w-0 max-w-40 px-2.5 text-xs sm:h-8"}),e.jsx(ne,{ariaLabel:s("sessions.sort.aria"),options:os,value:A,onValueChange:J,className:"sessions-filter-trigger h-11 min-w-0 max-w-44 px-2.5 text-xs sm:h-8",align:"end"})]})]}),ns?e.jsx("p",{className:"mb-4 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s("sessions.truncated",{shown:t.returned_count,total:t.session_count})}):null,o&&!t?e.jsxs("div",{className:"rounded-xl border border-dashed border-red-300 py-16 text-center dark:border-red-500/40",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:s("sessions.error.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:o}),e.jsx("button",{type:"button",onClick:()=>{oe(!1)},className:"mt-4 inline-flex h-11 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-200 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:s("sessions.error.retry")})]}):g?e.jsxs("div",{className:"flex items-center gap-2 py-16 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(ys,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),s("sessions.loading")]}):U.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-oai-gray-200 py-16 text-center dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:de?s("sessions.empty.filtered_title"):s("sessions.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:de?s("sessions.empty.filtered_body"):s("sessions.empty.body")})]}):e.jsxs(e.Fragment,{children:[o?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:s("shared.error.prefix",{error:o})}):null,e.jsxs("div",{className:"sessions-row-grid sessions-list-header border-b border-oai-gray-200 py-2 text-xs text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400","aria-hidden":!0,children:[e.jsx("span",{children:s("sessions.col.session")}),e.jsx("span",{className:"text-right",children:s("sessions.col.tokens")}),e.jsx("span",{className:"text-right",children:s("sessions.col.cost")}),e.jsx("span",{className:"text-right",children:s("sessions.col.speed")}),e.jsx("span",{className:"sr-only",children:s("sessions.col.actions")})]}),e.jsx("ul",{className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:Ze.map(i=>e.jsxs(pe.Fragment,{children:[e.jsx("li",{className:"pb-2 pt-5",children:e.jsx("h2",{className:"break-words text-xs font-medium text-oai-gray-900 dark:text-oai-gray-100",children:S==="project"?i.key||s("sessions.project.unknown"):i.key?new Date(`${i.key}T12:00:00`).toLocaleDateString(G||void 0,{year:"numeric",month:"short",day:"numeric"}):s("sessions.group.unknown_date")})}),i.sessions.map(x=>{const c=H.childrenByRoot.get(x.session_hash)||[],h=F.has(x.session_hash),q=X.get(x.session_hash)||"all",z=q==="all"?c:c.filter(function(is){return V(is).some(ls=>ls.model===q)});return e.jsxs(pe.Fragment,{children:[e.jsx(De,{session:x,locale:G,timeOnly:S==="time",childCount:c.length,expanded:h,onToggle:es,onDetail:D}),h&&c.length?e.jsx(As,{sessions:c,selectedModel:q,onSelect:ee=>ss(x.session_hash,ee)}):null,h?z.map(ee=>e.jsx(De,{session:ee,locale:G,nested:!0,timeOnly:S==="time",onDetail:D},ee.session_hash)):null]},x.session_hash)})]},i.key))}),xe?e.jsx("div",{ref:_e,className:"flex justify-center pt-6",children:e.jsx("button",{type:"button",onClick:ge,className:"inline-flex h-11 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:s("sessions.action.load_more")})}):null]}),e.jsx("p",{className:"mt-8 max-w-3xl text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:s("sessions.privacy")})]})}),u?e.jsx(Os,{session:u,subagents:Je,onClose:Xe}):null]})}export{at as SessionsPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-BW1rxvYq.js","assets/__vite-browser-external-gKkiQad5.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{q as I,j as t,e as _,c as n,a as ye,r as d,at as ve,az as ke,aA as je,a9 as X,aY as Se,aZ as we,a_ as Ne,u as Ce,d as H,a2 as Ee,J as ee,n as U,a$ as V,m as B,b0 as Ae,b1 as Pe,Z as te,b2 as Oe,t as Le,b3 as _e,b4 as Te,b5 as Ie,b6 as Ge,b7 as Re,b8 as De,b9 as Ue,ba as ne,L as Me,R as He,bb as Fe,bc as $e,ak as z,_ as Ve,h as Be,f as ze,bd as Ke,be as qe,aD as We}from"./__vite-browser-external-BW1rxvYq.js";import{a as Ze,b as K,s as Ye,K as Je,P as Qe,D as Xe,c as et,S as tt,v as nt,u as at,C as st}from"./sortable.esm-SVl6OixH.js";import{a as it}from"./modifiers.esm-Ds4Uh7JO.js";import{d as q,l as W,u as ot,b as Z}from"./use-limits-display-prefs-CDC0MZRY.js";import{P as rt}from"./ProviderIcon-BSI-1Cy8.js";import{m as ae}from"./react-CO1HovF5.js";import{a as O,T as j,b,S as T,u as R}from"./Controls-D56v-YJw.js";import{P as lt,u as ct,a as ut}from"./use-session-efficiency-pref-D8cAb4A9.js";import{C as dt}from"./check-8LQ7IvkH.js";import{C as gt,i as pt}from"./host-mode-GPY2DxE4.js";import{A as se}from"./index-CPcJP0uH.js";import{u as ht}from"./useCurrency-t1iy_pC3.js";import{u as mt}from"./useTokenFormat-0bPjtaaM.js";import{S as F}from"./Select-B6CM0ico.js";import{I as bt}from"./info-BaK8Hoi2.js";import{C as ft}from"./ConfirmModal-zUljpLNe.js";import{A as xt}from"./arrow-up-right-c39fdiDQ.js";import{D as yt}from"./download-x3Gmv-wu.js";import"./Card-BU2CqxfU.js";import"./SelectItemText-CZ7puxuB.js";import"./composite-BgLSXWKA.js";import"./DialogTitle-6q0jyME6.js";import"./store-DrEEdO_u.js";import"./DialogDescription-COXweCuc.js";const ie={name:"flask-conical",size:24,node:[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]};ie.node;const vt=I(ie);const oe={name:"grip-vertical",size:24,node:[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]};oe.node;const kt=I(oe);const re={name:"languages",size:24,node:[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]};re.node;const jt=I(re);const le={name:"log-out",size:24,node:[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]};le.node;const St=I(le);const ce={name:"palette",size:24,node:[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]};ce.node;const wt=I(ce);const ue={name:"user-round",size:24,node:[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],aliases:["user-2"]};ue.node;const Nt=I(ue),Ct="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function Et({checked:e,onChange:a,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:a,className:_("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:t.jsx("span",{className:_("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function At({id:e,visible:a,onToggle:s}){const{attributes:i,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:u}=at({id:e}),h={transform:st.Transform.toString(l)||void 0,transition:c,zIndex:u?20:void 0};return t.jsxs("div",{ref:r,style:h,className:_("flex items-center gap-3 py-2 rounded-md select-none touch-none","cursor-grab active:cursor-grabbing","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u&&"relative bg-oai-gray-100 dark:bg-oai-gray-800"),...i,...o,children:[t.jsx(kt,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),q(e)?t.jsx(rt,{provider:q(e),size:18,className:_("pointer-events-none",Ct)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:W(e)}),t.jsx("div",{onPointerDown:p=>p.stopPropagation(),children:t.jsx(Et,{checked:a,onChange:s,ariaLabel:`${n("limits.settings.toggle_visible")}: ${W(e)}`})})]})}function Pt({prefs:e}){const{order:a,visibility:s,toggle:i,moveToward:o}=e,r=Ze(K(Qe,{activationConstraint:{distance:6}}),K(Je,{coordinateGetter:Ye})),l=({active:c,over:u})=>{u&&c.id!==u.id&&o(c.id,u.id)};return t.jsx(Xe,{sensors:r,collisionDetection:et,modifiers:[it],onDragEnd:l,children:t.jsx(tt,{items:a,strategy:nt,children:t.jsx("div",{className:"flex flex-col",children:a.map(c=>t.jsx(At,{id:c,visible:s[c]!==!1,onToggle:()=>i(c)},c))})})})}function Ot(e){if(!e||typeof e!="object")return"";const a=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},s=e.profile&&typeof e.profile=="object"?e.profile:{},i=a.full_name||a.name||s.name||a.user_name||a.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function Lt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function _t(e){const a=typeof e=="string"?e.trim():"";if(!a)return null;const s=a.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=a.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=s?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function $(e,a){console.warn(`[tokentracker] settings ${e}:`,a)}function Tt(e,a,s){const[i,o]=d.useState(()=>ve()),r=a&&s&&Ne(),l=d.useCallback(async()=>{const c=!i;if(ke(c),o(c),!!c)try{await je(()=>e())}catch(u){$("cloud sync",u)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function It(e){const[a,s]=d.useState(!1),[i,o]=d.useState(!1),[r,l]=d.useState(!1),[c,u]=d.useState(!1),[h,p]=d.useState(null),[g,m]=d.useState(!1),[v,k]=d.useState(""),[P,y]=d.useState(!1),[w,N]=d.useState(""),[f,S]=d.useState(""),[L,x]=d.useState(!1),[E,D]=d.useState(null),G=d.useMemo(()=>Ot(e),[e]),be=d.useMemo(()=>Lt(e),[e]),fe=d.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),xe=d.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:p,setGithubUrl:N,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:y}),[]);return{anonymousOn:i,customDisplayName:h,displayName:G,editingGithub:L,editingName:g,email:be,githubError:E,githubInput:f,githubUrl:w,loadSetters:xe,nameInput:v,profileLoading:r,profileSaving:c,publicProfileOn:a,setAnonymousOn:o,setCustomDisplayName:p,setEditingGithub:x,setEditingName:m,setGithubError:D,setGithubInput:S,setGithubUrl:N,setNameInput:k,setProfileLoading:l,setProfileSaving:u,setPublicProfileOn:s,setShowGithubOn:y,showGithubOn:P,userId:fe}}function Gt(e,a,s){d.useEffect(()=>{if(!a)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await X({getAccessToken:e});if(!i||!o)return;const r=await Se({accessToken:o});if(!i)return;s.setPublicProfileOn(!!r?.enabled),s.setAnonymousOn(!!r?.anonymous),r?.display_name&&s.setCustomDisplayName(r.display_name),s.setShowGithubOn(!!r?.show_github_url),s.setGithubUrl(r?.github_url||"")}catch(o){$("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,a,s])}function Rt(e,a){return d.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(a.profileSaving)return!1;a.setProfileSaving(!0);try{const l=await X({getAccessToken:e});if(!l)return!1;const c=await we({accessToken:l,...s});return r?.(c),!0}catch(l){return o?o(l):$(i||"mutate profile",l),!1}finally{a.setProfileSaving(!1)}},[e,a])}function Dt(e,a){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:a.handleAnonymousToggle,handleSaveName:a.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:a.startEditingName}}function Ut(e,a){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:a.handleSaveGithub,handleShowGithubToggle:a.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:a.startEditingGithub}}function Mt(e,a){const s=d.useCallback(async()=>{const o=!e.publicProfileOn;await a({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[a,e]);return{handleAnonymousToggle:d.useCallback(async()=>{const o=!e.anonymousOn;await a({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[a,e]),handlePublicProfileToggle:s}}function Ht(e,a,s){const i=d.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await a({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),s?.()}})},[a,e,s]),o=d.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function Ft(e,a){const s=d.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await a({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[a,e]),i=d.useCallback(async()=>{const r=_t(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(n("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await a({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||n("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[a,e]),o=d.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function $t(){const e=ye(),a=It(e.user),s=Tt(e.getAccessToken,e.enabled,e.signedIn);Gt(e.getAccessToken,e.signedIn,a.loadSetters);const i=Rt(e.getAccessToken,a),o=Mt(a,i),r=Ht(a,i,e.refreshDisplayName),l=Ft(a,i);return{...e,...s,email:a.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:a.userId,name:Dt(a,{...o,...r}),github:Ut(a,l),profileLoading:a.profileLoading,profileSaving:a.profileSaving,publicProfileOn:a.publicProfileOn}}function de({disabled:e,onCancel:a,onSave:s,saveLabel:i=n("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:s,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:i}),t.jsx("button",{type:"button",onClick:a,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:n("settings.account.cancel")})]})}function Vt({nameInput:e,setEditingName:a,setNameInput:s,profileSaving:i,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>s(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&a(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.displayName")}),t.jsx(de,{disabled:i||!e.trim(),onCancel:()=>a(!1),onSave:o,saveLabel:i?n("settings.account.saving"):void 0})]})}function Bt({githubError:e,githubInput:a,handleSaveGithub:s,profileSaving:i,setEditingGithub:o,setGithubError:r,setGithubInput:l}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:a,onChange:c=>{l(c.target.value),e&&r(null)},onKeyDown:c=>{c.key==="Enter"&&s(),c.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.githubUrlPlaceholder")}),t.jsx(de,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:s,saveLabel:i?n("settings.account.saving"):void 0})]}),e?t.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function ge({disabled:e=!1,label:a,onClick:s,title:i}){return t.jsxs("button",{type:"button",onClick:s,disabled:e,title:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(lt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a]})}function pe({actions:e,editing:a,editor:s,hint:i,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),a?s:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),a?null:e]})})}function zt({name:e}){const a=e.anonymousOn?n("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ge,{disabled:e.anonymousOn,label:n("settings.account.edit"),onClick:e.startEditingName,title:a}),t.jsx(j,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:n("settings.account.displayName")})]})}function Kt({name:e}){const{anonymousOn:a,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:u,profileSaving:h,setEditingName:p,setNameInput:g,startEditingName:m}=e,v=a?n("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(pe,{label:n("settings.account.displayName"),editing:o,hint:v,editor:t.jsx(Vt,{nameInput:c,setEditingName:p,setNameInput:g,profileSaving:h,handleSaveName:l}),actions:t.jsx(zt,{name:e})})}function qt({github:e}){const{editingGithub:a,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:u,setEditingGithub:h,setGithubError:p,setGithubInput:g,showGithubOn:m,startEditingGithub:v}=e;return t.jsx(t.Fragment,{children:t.jsx(pe,{label:n("settings.account.githubUrl"),editing:a,hint:o||n("settings.account.githubUrlHint"),editor:t.jsx(Bt,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:u,setEditingGithub:h,setGithubError:p,setGithubInput:g}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ge,{label:n("settings.account.edit"),onClick:v}),t.jsx(j,{checked:m,onChange:l,disabled:c||u,ariaLabel:n("settings.account.githubUrl")})]})})})}function Wt(){const{openLoginModal:e}=Ce();return t.jsx(O,{title:n("settings.section.account"),children:t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.account.signedOutHint")}),t.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:n("settings.account.signIn")})]})})}function Zt({name:e,github:a}){return t.jsxs(t.Fragment,{children:[t.jsx(Kt,{name:e}),t.jsx(qt,{github:a})]})}function Yt(){const e=$t();return e.enabled?e.signedIn?t.jsxs(O,{title:n("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Qt,{onSignOut:e.signOut}),children:[t.jsx(Jt,{userId:e.userId}),t.jsx(Xt,{settings:e}),t.jsx(en,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(tn,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(Wt,{}):null}function Jt({userId:e}){const[a,s]=H.useState(!1);if(!e)return null;const i=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),s(!0),globalThis.setTimeout(()=>s(!1),1200)}catch{s(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:n("settings.account.userId")}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),t.jsxs("button",{type:"button",onClick:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":n("settings.account.copyUserId"),children:[a?t.jsx(dt,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(gt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a?n("settings.account.copied"):n("settings.account.copy")]})]})}function Qt({onSignOut:e}){return t.jsxs("button",{type:"button",onClick:()=>e(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[t.jsx(St,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.signOut")]})}function Xt({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:n("settings.account.cloudSync"),hint:n("settings.account.cloudSyncHint"),control:t.jsx(j,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:n("settings.account.cloudSync")})}):null}function en({checked:e,disabled:a,onChange:s}){return t.jsx(b,{label:n("settings.account.publicProfile"),hint:n("settings.account.publicProfileHint"),control:t.jsx(j,{checked:e,onChange:s,disabled:a,ariaLabel:n("settings.account.publicProfile")})})}function tn({visible:e,name:a,github:s}){return t.jsx(se,{initial:!1,children:e?t.jsx(ae.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:t.jsx(Zt,{name:a,github:s})},"public-profile-fields"):null})}function nn(){return[{value:"light",label:n("settings.appearance.theme.light"),Icon:Ae},{value:"dark",label:n("settings.appearance.theme.dark"),Icon:Pe},{value:"system",label:n("settings.appearance.theme.system"),Icon:te}]}function an(){return[{value:_e,label:n("settings.appearance.language.system")},{value:Te,label:n("settings.appearance.language.english")},{value:Ie,label:n("settings.appearance.language.chinese")},{value:Ge,label:n("settings.appearance.language.traditional_chinese")},{value:Re,label:n("settings.appearance.language.japanese")},{value:De,label:n("settings.appearance.language.korean")},{value:Ue,label:n("settings.appearance.language.german")}]}function sn(e){if(!e)return null;try{const a=new Date(e);return Number.isNaN(a.getTime())?null:a.toLocaleString()}catch{return null}}function on(e,a){const s=n(`settings.appearance.currency.rate_source.${e}`),i=sn(a),o=i?n("settings.appearance.currency.rate_updated",{when:i}):n("settings.appearance.currency.rate_never");return`${s} · ${o}`}function rn({locale:e,setLocale:a}){const s=an();return t.jsx(F,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(jt,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function ln({currency:e,setCurrency:a}){const s=Oe().map(i=>({value:i.code,label:n(i.labelKey)}));return t.jsx(F,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function cn({currency:e,rate:a,rateSource:s,rateFetchedAt:i}){if(e===Le)return t.jsx(t.Fragment,{children:n("settings.appearance.currency.hint")});const o=on(s,i);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${a.toFixed(4)} ${e}`}),t.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:t.jsx(bt,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function un(){const{theme:e,setTheme:a}=Ee(),{locale:s,setLocale:i}=ee(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:u}=ht(),{mode:h,setMode:p,unitSystem:g,setUnitSystem:m,grouping:v,setGrouping:k}=mt();return t.jsxs(O,{title:n("settings.section.appearance"),children:[t.jsx(b,{label:n("settings.appearance.theme.label"),hint:n("settings.appearance.theme.hint"),control:t.jsx(T,{options:nn(),value:e,onChange:a})}),t.jsx(b,{label:n("settings.appearance.language.label"),hint:n("settings.appearance.language.hint"),control:t.jsx(rn,{locale:s,setLocale:i})}),t.jsx(b,{label:n("settings.appearance.currency.label"),hint:t.jsx(cn,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(ln,{currency:o,setCurrency:u})}),t.jsx(b,{label:n("settings.appearance.token_format.label"),hint:n("settings.appearance.token_format.hint"),control:t.jsx(T,{options:[{value:U.COMPACT,label:n("settings.appearance.token_format.compact")},{value:U.FULL,label:n("settings.appearance.token_format.full")}],value:h,onChange:p})}),t.jsx(b,{label:n("settings.appearance.token_unit.label"),hint:n("settings.appearance.token_unit.hint"),control:t.jsx(T,{disabled:h!==U.COMPACT,options:[{value:V.ENGLISH,label:n("settings.appearance.token_unit.english")},{value:V.CHINESE,label:n("settings.appearance.token_unit.chinese")}],value:g,onChange:m})}),t.jsx(b,{label:n("settings.appearance.token_grouping.label"),hint:n("settings.appearance.token_grouping.hint"),control:t.jsx(T,{options:[{value:B.THOUSAND,label:n("settings.appearance.token_grouping.thousand")},{value:B.WAN,label:n("settings.appearance.token_grouping.wan")}],value:v,onChange:k})})]})}function M({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:n(e)}),t.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-semibold tracking-wider text-oai-gray-500 bg-oai-gray-100 dark:text-oai-gray-400 dark:bg-oai-gray-800/80 rounded uppercase scale-90 origin-left",children:n("qpd.card.badge")})]})}function dn(){const{enabled:e,toggle:a}=ct(),{enabled:s,toggle:i}=ut(),{available:o,settings:r,setSetting:l}=R(),c=o&&!!r?.dynamicIslandSupported,u=!!r?.dynamicIslandEnabled;return t.jsxs(O,{title:n("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.island.label"}),hint:n("settings.labs.island.hint"),control:t.jsx(j,{checked:u,onChange:()=>l("dynamicIslandEnabled",!u),ariaLabel:n("settings.labs.island.aria")})}),u&&t.jsx(b,{label:n("settings.labs.island_hide_menubar.label"),hint:n("settings.labs.island_hide_menubar.hint"),control:t.jsx(j,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:n("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.qpd.label"}),hint:n("settings.labs.qpd.hint"),control:t.jsx(j,{checked:e,onChange:a,ariaLabel:n("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.sessions.label"}),hint:n("settings.labs.sessions.hint"),control:t.jsx(j,{checked:s,onChange:i,ariaLabel:n("settings.labs.sessions.aria")})})]})}function gn(){const{available:e,settings:a,setSetting:s,runAction:i}=R();if(!e)return null;const o=ne(),r=!!a?.launchAtLogin,l=a?.toastOnReset!==!1,c=a?.confettiOnReset!==!1,u=a?.launchAtLoginSupported!==!1,h=a?.autoUpdateEnabled!==!1,p=a?.updateStatus||null,g=!!a?.updateBusy,m=!!a?.isSyncing;return t.jsxs(O,{title:n("settings.section.menubar"),children:[o?null:t.jsxs(t.Fragment,{children:[t.jsx(b,{label:n("settings.menubar.appearance"),hint:n("settings.menubar.appearanceHint"),control:t.jsxs(Me,{to:"/widgets",className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 no-underline transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n("settings.menubar.appearanceLink"),t.jsx(xt,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(j,{checked:l,onChange:()=>s("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(j,{checked:c,onChange:()=>s("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),u?t.jsx(b,{label:n("settings.menubar.launchAtLogin"),hint:n("settings.menubar.launchAtLoginHint"),control:t.jsx(j,{checked:r,onChange:()=>s("launchAtLogin",!r),ariaLabel:n("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:n("settings.menubar.syncNow"),hint:n("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:m,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(He,{className:_("h-3.5 w-3.5",m&&"animate-spin"),"aria-hidden":!0}),m?n("settings.menubar.syncing"):n("settings.menubar.syncNow")]})}),t.jsx(b,{label:n("settings.menubar.autoUpdate"),hint:n("settings.menubar.autoUpdateHint"),control:t.jsx(j,{checked:h,onChange:()=>s("autoUpdateEnabled",!h),ariaLabel:n("settings.menubar.autoUpdate")})}),t.jsx(b,{label:n("settings.menubar.updates"),hint:p||void 0,control:t.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(yt,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.menubar.checkUpdates")]})})]})}function pn(e,a){function s(r){return r.replace(/^v/,"").split(".").map(Number)}const i=s(e),o=s(a);for(let r=0;r<Math.max(i.length,o.length);r++){const l=i[r]||0,c=o[r]||0;if(l<c)return!0;if(l>c)return!1}return!1}function hn(){const{available:e,settings:a,runAction:s}=R(),i=e&&a?.version,o=a?.platform||"macos",[r,l]=H.useState(!1),[c,u]=H.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:h}=ee(),p="1.2.1",g=async()=>{l(!0);try{const y=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!y.ok)throw new Error("Failed to fetch");const w=await y.json(),N=w.tag_name;pn(p,N)?u({open:!0,latestVersion:N,htmlUrl:w.html_url}):z({title:n("settings.menubar.updates.upToDate")})}catch(y){console.error("Check updates failed:",y),z({title:n("settings.menubar.updates.failed")})}finally{l(!1)}},m=n("settings.menubar.updates.modalTitle"),v=n("settings.menubar.updates.modalDescription",{version:c.latestVersion}),k=n("settings.menubar.updates.modalConfirm"),P=n("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:o==="windows"?n("settings.menubar.updates.footerCore",{version:a.version}):n("settings.menubar.updates.footerCombined",{barVersion:a.version,coreVersion:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>s("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCore",{version:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:g,disabled:r,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:r?n("settings.menubar.updates.checking"):n("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Fe,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:[t.jsx($e,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.footer.statusPage")]})]}),t.jsx(ft,{open:c.open,title:m,description:v,confirmLabel:k,cancelLabel:P,onConfirm:()=>{window.open(c.htmlUrl,"_blank"),u(y=>({...y,open:!1}))},onCancel:()=>u(y=>({...y,open:!1}))})]})}const mn=()=>[{value:"system",label:n("settings.network.mode.system")},{value:"manual",label:n("settings.network.mode.manual")},{value:"off",label:n("settings.network.mode.off")}],bn=()=>[{value:"http",label:n("settings.network.protocol.http")},{value:"https",label:n("settings.network.protocol.https")},{value:"socks5",label:n("settings.network.protocol.socks5")}],Y="w-full rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white";function J(e){const a={},s=String(e.host||"").trim();(!s||/:\/\//.test(s)||s.includes("/"))&&(a.host=n("settings.network.error.host"));const i=String(e.port??"").trim(),o=Number(i);return(!i||!/^\d+$/.test(i)||!Number.isInteger(o)||o<1||o>65535)&&(a.port=n("settings.network.error.port")),a}function fn({proxySettings:e}){const{config:a,save:s,testConnection:i}=e,[o,r]=d.useState(()=>({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})),[l,c]=d.useState({}),[u,h]=d.useState(!1),[p,g]=d.useState(""),[m,v]=d.useState(null),[k,P]=d.useState(!1),[y,w]=d.useState(null);d.useEffect(()=>{r({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})},[a.mode,a.protocol,a.host,a.port]);const N=d.useMemo(()=>a.effective==="manual"?n("settings.network.effective.manual"):a.effective==="env"?n("settings.network.effective.env"):a.effective==="system"?n("settings.network.effective.system"):a.effective==="blocked"?n("settings.network.effective.blocked"):n("settings.network.effective.none"),[a.effective]),f=x=>{r(E=>({...E,...x})),c({}),g(""),v(null),w(null)},S=async()=>{if(o.mode==="manual"){const x=J(o);if(Object.keys(x).length){c(x);return}}h(!0),g(""),v(null);try{await s(o),g("saved")}catch(x){g("error"),v(x)}finally{h(!1)}},L=async()=>{const x=J(o);if(Object.keys(x).length){c(x);return}P(!0),w(null);try{const E=await i(o);w(E)}catch(E){w({ok:!1,error:E?.message||String(E)})}finally{P(!1)}};return t.jsxs(O,{title:n("settings.section.network"),subtitle:N,children:[a.applyError?t.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:n("settings.network.apply_error",{error:a.applyError})}):null,t.jsx(b,{label:n("settings.network.mode.label"),hint:n("settings.network.mode.hint"),control:t.jsx(T,{options:mn(),value:o.mode,onChange:x=>f({mode:x})})}),t.jsx(se,{initial:!1,children:o.mode==="manual"?t.jsxs(ae.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:[t.jsx(b,{label:n("settings.network.protocol.label"),control:t.jsx(F,{value:o.protocol,onValueChange:x=>f({protocol:x}),options:bn(),ariaLabel:n("settings.network.protocol.label"),className:"px-2.5 py-1.5 text-xs font-medium"})}),t.jsx(b,{label:n("settings.network.host.label"),hint:l.host,control:t.jsx("input",{type:"text",value:o.host,onChange:x=>f({host:x.target.value}),placeholder:n("settings.network.host.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.host?!0:void 0,"aria-label":n("settings.network.host.label"),className:Y})}),t.jsx(b,{label:n("settings.network.port.label"),hint:l.port,control:t.jsx("input",{type:"text",inputMode:"numeric",value:o.port,onChange:x=>f({port:x.target.value}),placeholder:n("settings.network.port.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.port?!0:void 0,"aria-label":n("settings.network.port.label"),className:Y})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[t.jsx("button",{type:"button",onClick:L,disabled:k||u,className:"rounded-md border border-oai-gray-200 px-3 py-1.5 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:k?n("settings.network.test.testing"):n("settings.network.test")}),t.jsx("button",{type:"button",onClick:S,disabled:u||k,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})]}),y?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:y.ok?n("settings.network.test.ok",{status:String(y.status??"")}):n("settings.network.test.fail",{error:y.error||""})}):null]},"manual-proxy-fields"):t.jsx("div",{className:"flex justify-end py-3",children:t.jsx("button",{type:"button",onClick:S,disabled:u,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})},"non-manual-save")}),p==="saved"?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.network.saved")}):null,p==="error"?t.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:m?.unprotected?n("settings.network.save_error_unprotected",{error:m?.message||String(m||"")}):n("settings.network.save_error",{error:m?.message||String(m||"")})}):null]})}const he="/functions/tokentracker-proxy-config",xn="/functions/tokentracker-proxy-test",yn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function me(e){return!e||typeof e.mode!="string"?null:{mode:e.mode,protocol:typeof e.protocol=="string"?e.protocol:"http",host:typeof e.host=="string"?e.host:"",port:e.port==null||e.port===0?"":String(e.port),effective:typeof e.effective=="string"?e.effective:"none",applyError:typeof e.applyError=="string"&&e.applyError.trim()?e.applyError:null}}async function vn(){const e=await fetch(he,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!e.ok)return null;const a=await e.json().catch(()=>null);return me(a)}async function Q(){const{getLocalApiAuthHeaders:e}=await Ve(async()=>{const{getLocalApiAuthHeaders:a}=await import("./__vite-browser-external-BW1rxvYq.js").then(s=>s.dg);return{getLocalApiAuthHeaders:a}},__vite__mapDeps([0,1]));return e()}function kn(){const[e,a]=d.useState(!1),[s,i]=d.useState(!0),[o,r]=d.useState(yn);d.useEffect(()=>{if(!pt()){a(!1),i(!1);return}let u=!1;return(async()=>{try{const h=await vn();if(u)return;if(!h){a(!1),i(!1);return}r(h),a(!0),i(!1)}catch{u||(a(!1),i(!1))}})(),()=>{u=!0}},[]);const l=d.useCallback(async u=>{const h=await Q(),p=await fetch(he,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...h},cache:"no-store",body:JSON.stringify({mode:u.mode,protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),g=await p.json().catch(()=>null);if(!p.ok){const v=g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`;throw new Error(v)}const m=me(g);if(m&&r(m),g&&g.ok===!1){const v=g&&typeof g.applyError=="string"&&g.applyError||g&&typeof g.error=="string"&&g.error||`HTTP ${p.status}`,k=new Error(v);throw g.unprotected===!0&&(k.unprotected=!0),k}return m||g},[]),c=d.useCallback(async u=>{const h=await Q(),p=await fetch(xn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...h},cache:"no-store",body:JSON.stringify({protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),g=await p.json().catch(()=>null);if(!g||typeof g.ok!="boolean")throw new Error(g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`);return g},[]);return{available:e,loading:s,config:o,save:l,testConnection:c}}const C={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"},A={PERSONAL:"personal",APP:"app",DEVELOPER:"developer"};function jn({prefs:e}){return t.jsx(T,{options:[{value:Z.USED,label:n("limits.settings.display_mode_used")},{value:Z.REMAINING,label:n("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function qn(){const e=ot(),{available:a,settings:s,setSetting:i}=R(),o=kn(),{available:r}=o,l=s?.toastOnReset!==!1,c=s?.confettiOnReset!==!1,u=ne()||s?.platform==="windows",[h,p]=Be(),g=ze(),m=h.get("section"),k=Object.values(C).includes(m)&&(m!==C.NATIVE_APP||a)&&(m!==C.NETWORK||r)?m:C.APPEARANCE,P=f=>{const S=new URLSearchParams(h);f===C.APPEARANCE?S.delete("section"):S.set("section",f),p(S,{replace:!0})},y=[{id:C.APPEARANCE,label:n("settings.section.appearance"),description:n("settings.section.appearance.description"),group:A.PERSONAL,Icon:wt,content:t.jsx(un,{})},...a?[{id:C.NATIVE_APP,label:n("settings.section.menubar"),description:n("settings.section.menubar.description"),group:A.APP,Icon:te,content:t.jsx(gn,{})}]:[],...r?[{id:C.NETWORK,label:n("settings.section.network"),description:n("settings.section.network.description"),group:A.APP,Icon:Ke,content:t.jsx(fn,{proxySettings:o})}]:[],{id:C.ACCOUNT,label:n("settings.section.account"),description:n("settings.section.account.description"),group:A.PERSONAL,Icon:Nt,content:t.jsx(Yt,{})},{id:C.LIMITS,label:n("settings.section.limits"),description:n("settings.section.limits.description"),group:A.APP,Icon:qe,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(O,{title:n("settings.section.limits"),children:[t.jsx(b,{label:n("limits.settings.display_mode_label"),control:t.jsx(jn,{prefs:e})}),u?null:t.jsxs(t.Fragment,{children:[t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(j,{checked:l,disabled:!a,onChange:()=>i("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(j,{checked:c,disabled:!a,onChange:()=>i("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),t.jsx(b,{label:n("settings.limits.showSubscriptions"),hint:n("settings.limits.showSubscriptionsHint"),control:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>g("/limits?openSubscriptions=1"),"aria-label":n("limits.page.openSubscriptions"),title:n("limits.page.openSubscriptions"),className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-white dark:bg-oai-gray-900 text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:t.jsx(We,{size:14,"aria-hidden":!0})}),t.jsx(j,{checked:e.showSubscriptions!==!1,onChange:()=>e.setShowSubscriptions(!e.showSubscriptions),ariaLabel:n("settings.limits.showSubscriptions")})]})})]}),t.jsx(O,{title:n("settings.limits.providers"),children:t.jsx(Pt,{prefs:e})})]})},{id:C.LABS,label:n("settings.section.labs"),description:n("settings.section.labs.description"),group:A.DEVELOPER,Icon:vt,content:t.jsx(dn,{})}],w=[{id:A.PERSONAL,label:n("settings.nav.group.personal")},{id:A.APP,label:n("settings.nav.group.app")},{id:A.DEVELOPER,label:n("settings.nav.group.developer")}].map(f=>({...f,sections:y.filter(S=>S.group===f.id)})).filter(f=>f.sections.length>0);let N=y[0];for(const f of y)if(f.id===k){N=f;break}return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto w-full max-w-5xl px-4 sm:px-6",children:[t.jsxs("div",{className:"mb-7 max-w-2xl",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:n("settings.page.title")}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:n("settings.page.subtitle")})]}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[14rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 rounded-xl border border-oai-gray-200 bg-oai-gray-50/70 p-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/60 md:border-0 md:bg-transparent md:p-0 md:dark:bg-transparent",children:t.jsx("nav",{"aria-label":n("settings.page.title"),className:"flex gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-4 md:overflow-visible",children:w.map(({id:f,label:S,sections:L})=>t.jsxs("div",{className:"flex shrink-0 gap-1 md:block",children:[t.jsx("div",{className:"hidden px-3 pb-1 text-[10px] font-semibold uppercase tracking-[0.16em] text-oai-gray-400 dark:text-oai-gray-500 md:block",children:S}),t.jsx("div",{className:"flex gap-1 md:flex-col",children:L.map(({id:x,label:E,Icon:D})=>{const G=k===x;return t.jsxs("button",{id:`settings-nav-${x}`,type:"button","aria-current":G?"page":void 0,"aria-controls":`settings-panel-${x}`,onClick:()=>P(x),className:_("inline-flex min-h-10 min-w-max shrink-0 items-center gap-1.5 rounded-md px-2 py-2 text-left text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500 md:w-full md:min-w-0 md:gap-2 md:px-3",G?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-500 hover:bg-oai-gray-50 hover:text-oai-gray-900 dark:text-oai-gray-400 dark:hover:bg-oai-gray-900 dark:hover:text-oai-gray-200"),children:[t.jsx(D,{className:_("h-4 w-4 shrink-0",G?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:E})]},x)})})]},f))})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"mb-4 border-b border-oai-gray-200 pb-4 dark:border-oai-gray-800",children:[t.jsx("h2",{className:"text-xl font-semibold tracking-tight text-oai-black dark:text-white",children:N.label}),t.jsx("p",{className:"mt-1 text-sm leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:N.description})]}),y.map(({id:f,label:S,content:L})=>t.jsx("section",{id:`settings-panel-${f}`,"aria-labelledby":`settings-nav-${f}`,"aria-label":S,"data-settings-panel":f,hidden:k!==f,children:L},f)),t.jsx(hn,{})]})]})]})})})}export{qn as SettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{q as yt,r as i,w as ha,j as e,e as Y,X as Le,c as r,aL as ua,aE as bt,v as kt,aP as wt,aQ as vt,E as jt,aR as Nt,aS as Ct,aT as St,aU as _t,x as Rt,aV as Lt,aG as It,aF as Pt,aW as Bt,ac as Dt,a as Tt,aX as Et,at as At,H as Ot,B as X,R as $t,d as Ut,aB as Mt,ak as G}from"./__vite-browser-external-BW1rxvYq.js";import{L as zt,I as xa}from"./LocalOnlyNotice-RIj2XT_X.js";import{C as Ft}from"./Card-BU2CqxfU.js";import{C as da}from"./ConfirmModal-zUljpLNe.js";import{I as Ia}from"./info-BaK8Hoi2.js";import{P as ve}from"./ProviderIcon-BSI-1Cy8.js";import{m as wa}from"./react-CO1HovF5.js";import{u as Vt}from"./useCurrency-t1iy_pC3.js";import{E as ma}from"./external-link-daw-XTjZ.js";import{L as Z}from"./loader-circle-DYpa-xTZ.js";import{M as Pa}from"./monitor-smartphone-BbeYHvY-.js";import{C as Ie}from"./check-8LQ7IvkH.js";import{T as fa}from"./trash-Dd_vbrYo.js";import{A as Kt}from"./index-CPcJP0uH.js";import{u as Ht}from"./use-reduced-motion-BEOENqBa.js";import{u as Wt,k as qt,l as Gt,m as Qt,n as Xt,o as Yt,p as Jt,q as Zt,r as er,S as Ba,c as Da,d as Ta,C as pa,e as Ea,f as Aa,g as Oa,h as ta,j as ra,i as sa}from"./SelectItemText-CZ7puxuB.js";import{t as ar,u as $a,n as tr}from"./composite-BgLSXWKA.js";import{g as rr,a as sr,p as nr,m as ir,b as or,d as lr,c as dr,e as cr,f as ur,s as mr,i as gr,u as va,h as ja,r as hr,j as Na,k as Ca,l as Sa,n as xr,o as fr}from"./skills-api-BSkbxC8-.js";import{F as pr}from"./flame-B9o0_EF8.js";import{S as ga}from"./search-DBnhkzG_.js";import{P as Ua}from"./plus-C9qGVLFv.js";import{D as Ma}from"./download-x3Gmv-wu.js";import{P as za,a as Fa,b as Va,c as Ka,d as Ha}from"./PopoverPopup-CmUIY8lF.js";import"./arrow-up-right-c39fdiDQ.js";import"./DialogTitle-6q0jyME6.js";import"./store-DrEEdO_u.js";import"./DialogDescription-COXweCuc.js";const Wa={name:"circle-arrow-up",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],aliases:["arrow-up-circle"]};Wa.node;const ya=yt(Wa),qa=i.forwardRef(function(s,d){const{render:l,className:p,style:h,...x}=s,w={open:Wt().useState("open")};return ha("span",s,{state:w,ref:d,props:[{"aria-hidden":!0,children:"▼"},x],stateAttributesMapping:ar})});function yr({options:a,value:s,onChange:d,leading:l=null,disabled:p=!1,ariaLabel:h,className:x=""}){const u=i.useRef(null),y=i.useRef(new Map),[w,b]=i.useState(null),S=(k,c)=>{const g=a.filter(_=>!p&&!_.disabled),m=g.findIndex(_=>_.id===c);if(m<0)return;let v=null;k.key==="ArrowRight"||k.key==="ArrowDown"?v=g[(m+1)%g.length]:k.key==="ArrowLeft"||k.key==="ArrowUp"?v=g[(m-1+g.length)%g.length]:k.key==="Home"?v=g[0]:k.key==="End"&&(v=g[g.length-1]),!(!v||v.id===c)&&(k.preventDefault(),d(v.id),y.current.get(v.id)?.focus())};return i.useLayoutEffect(()=>{const k=()=>{const g=y.current.get(s);if(!g||g.offsetWidth===0)return;const m={left:g.offsetLeft,top:g.offsetTop,width:g.offsetWidth,height:g.offsetHeight};b(v=>v&&v.left===m.left&&v.top===m.top&&v.width===m.width&&v.height===m.height?v:m)};if(k(),typeof ResizeObserver>"u"||!u.current)return;const c=new ResizeObserver(k);c.observe(u.current);for(const g of y.current.values())c.observe(g);return()=>c.disconnect()},[s,a]),e.jsxs("div",{ref:u,role:"tablist","aria-label":h,className:Y("relative inline-flex h-8 items-center gap-1 rounded-md border border-oai-gray-200 bg-oai-gray-100 p-[3px] dark:border-oai-gray-700 dark:bg-oai-gray-800",x),children:[l,w?e.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute left-0 top-0 rounded-sm bg-white shadow-sm transition-[transform,width] duration-200 ease-out motion-reduce:transition-none dark:bg-oai-gray-700",style:{transform:`translate(${w.left}px, ${w.top}px)`,width:`${w.width}px`,height:`${w.height}px`}}):null,a.map(k=>{const c=k.id===s;return e.jsxs("button",{ref:g=>{g?y.current.set(k.id,g):y.current.delete(k.id)},type:"button",role:"tab","aria-selected":c,tabIndex:c?0:-1,disabled:p||k.disabled,onClick:()=>d(k.id),onKeyDown:g=>S(g,k.id),className:Y("relative z-10 inline-flex h-6 items-center gap-1.5 rounded px-2.5 text-xs font-medium transition-colors disabled:opacity-50",c?"text-oai-black dark:text-white":"text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:[k.icon,k.label]},k.id)})]})}const br="tt:hint:dismissed:";function Ga(a){return br+a}function kr(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ga(a))==="1"}catch{return!1}}function wr({id:a,children:s,className:d,ariaLabel:l}){const[p,h]=i.useState(()=>kr(a)),x=i.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(Ga(a),"1")}catch{}h(!0)},[a]);return p?null:e.jsxs("div",{role:"note","aria-label":l||r("hint.dismissible_aria"),className:Y("relative rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 py-3 text-sm text-oai-gray-700","dark:border-oai-gray-800 dark:bg-oai-gray-900/40 dark:text-oai-gray-300",d),children:[e.jsx("button",{type:"button",onClick:x,"aria-label":r("hint.dismiss"),className:"absolute top-2 right-2 inline-flex h-7 w-7 items-center justify-center rounded-md text-oai-gray-500 transition-colors hover:bg-oai-gray-200/70 hover:text-oai-gray-700 focus:outline-none focus:ring-2 focus:ring-oai-blue/30 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800/70 dark:hover:text-oai-gray-200",children:e.jsx(Le,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(Ia,{className:"mt-0.5 h-4 w-4 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:s})]})]})}function vr(a){if(!a)return null;for(const s of a.elements){const d=s.tagName;if(d==="BUTTON"||d==="INPUT"){const l=s;if(l.type==="submit")return l}}return null}const jr="data-checked",Nr="data-unchecked";function Qa(a){return{checked(s){return a.indeterminate?{}:s?{[jr]:""}:{[Nr]:""}},...qt}}const Cr=i.createContext({disabled:!1});function Sr(){return i.useContext(Cr)}function _r(a,s,d,l=!0,p){const[h,x]=i.useState(),u=$a(p?`${p}-label`:void 0),y=a??s??h;return ua(()=>{const w=a||s||!l?void 0:Rr(d.current,u);h!==w&&x(w)}),y}function Rr(a,s){const d=Lr(a);if(d)return!d.id&&s&&(d.id=s),d.id||void 0}function Lr(a){if(!a)return;const s=a.parentElement;if(s&&s.tagName==="LABEL")return s;const d=a.id;if(d){const p=a.nextElementSibling;if(p&&p.htmlFor===d)return p}const l=a.labels;return l&&l[0]}const Ir=i.createContext(void 0);function Pr(){return i.useContext(Ir)}const Xa=i.createContext(void 0);function Br(){const a=i.useContext(Xa);if(a===void 0)throw new Error(bt(14));return a}const Dr="data-parent",Tr=i.forwardRef(function(s,d){const{checked:l,className:p,defaultChecked:h=!1,"aria-labelledby":x,disabled:u=!1,form:y,id:w,indeterminate:b=!1,inputRef:S,name:k,onCheckedChange:c,parent:g=!1,readOnly:m=!1,render:v,required:_=!1,uncheckedValue:$,value:U,nativeButton:K=!1,style:de,...fe}=s,{clearErrors:ne}=Gt(),{disabled:B,name:pe,setDirty:L,setFilled:M,setFocused:H,setTouched:T,state:ee,validationMode:J,validityData:je,validation:ce}=Qt(),Pe=Sr(),{labelId:We,registerControlId:Be,getDescriptionProps:De}=Xt(),R=Pr(),I=R?.allValues===void 0?void 0:R.parent,W=I!==void 0,D=B||Pe.disabled||R?.disabled||u,ae=pe??k,P=U??ae,Ne=$a(),Te=R?.registerControlId!==Be,ie=Yt({id:w||void 0,enabled:Te}),Ee=K?ie:Ne;let ue={};W&&(g?ue=I.getParentProps():P!==void 0&&(ue=I.getChildProps(P)));const{checked:Ae=l,indeterminate:Oe=b,onCheckedChange:qe,...Ce}=ue,$e=R?.value,me=i.useRef(null),{getButtonProps:Ge,buttonRef:Ue}=kt({disabled:D,native:K}),te=R?.validation??ce,[E,Se]=Jt({controlled:P!==void 0&&$e!==void 0&&!g?$e.includes(P):Ae,default:h,name:"Checkbox",state:"checked"}),ge=W?!!Ae:E,q=W&&Oe||b;Zt(me,Ne,E,void 0,!R&&!D,k);const he=I?.registerChildId,A=i.useRef(null),Me=te.registerInput,ye=R?P:void 0,_e=i.useCallback(N=>Me(N,{controlRef:me,value:ye}),[Me,ye]),ia=wt(S,A,g?void 0:_e),Qe=_r(x,We,A,!K,ie);ua(()=>{A.current&&(A.current.indeterminate=q),R||M(E)},[E,q,R,M]),er(E,()=>{R||(ne(ae),L(E!==je.initialValue),te.change(E))});const Xe=vt({checked:E,disabled:D,form:y,name:g?void 0:ae,id:K?void 0:ie,required:_,ref:ia,style:ae?St:_t,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(N){if(N.nativeEvent.defaultPrevented)return;if(m){N.preventDefault();return}const F=N.currentTarget.checked,oe=Rt(Lt,N.nativeEvent);if(c?.(F,oe),!oe.isCanceled&&(qe?.(F,oe),!oe.isCanceled&&(Se(F),P!==void 0&&R!==void 0&&!g&&!W))){const re=F?[...R.value,P]:R.value.filter(Re=>Re!==P);R.setValue(re,oe)}},onClick(N){N.stopPropagation()},onFocus(){me.current?.focus()}},U!==void 0?{value:(R?E&&U:U)||""}:jt,De,N=>te.getValidationProps(D,N));i.useEffect(()=>{if(!I||P===void 0)return;const N=I.disabledStatesRef.current;return N.set(P,D),()=>{N.delete(P)}},[I,D,P]);const z=i.useMemo(()=>({...ee,checked:ge,disabled:D,readOnly:m,required:_,indeterminate:q}),[ee,ge,D,m,_,q]),oa=Qa(z),Ye=ha("span",s,{state:z,ref:[Ue,me,d],props:[{id:Ee,role:"checkbox","aria-checked":q?"mixed":ge,"aria-readonly":m||void 0,"aria-required":_||void 0,"aria-labelledby":Qe,[Dr]:g?"":void 0,onFocus(){D||H(!0)},onBlur(){const N=A.current;N&&(T(!0),H(!1),J==="onBlur"&&te.commit(R?$e:N.checked))},onKeyDown(N){if(N.key!=="Enter"||(N.preventBaseUIHandler(),N.defaultPrevented))return;const F=A.current?.form??null,oe=N.currentTarget,re=N.nativeEvent,Re=N.preventDefault,Fe=re.preventDefault;let Ve=!1;N.preventDefault=()=>{Ve=!0,Re.call(N)},re.preventDefault=()=>{Ve=!0,Fe.call(re)},Fe.call(re),Ct(oe).queueMicrotask(()=>{N.preventDefault=Re,re.preventDefault=Fe,Ve||vr(F)?.click()})},onClick(N){if(m||D)return;N.preventDefault();const F=A.current;F&&Nt(F,N)}},fe,Ce,Ge,De,N=>te.getValidationProps(D,N)],stateAttributesMapping:oa}),ze=Ye.props.id;return ua(()=>{if(!(!he||g||P===void 0||ze===void 0))return he(P,ze)},[he,g,P,ze]),e.jsxs(Xa.Provider,{value:z,children:[Ye,!E&&!R&&ae&&!g&&$!==void 0&&e.jsx("input",{type:"hidden",form:y,name:ae,value:$,disabled:D}),e.jsx("input",{...Xe,suppressHydrationWarning:!0})]})}),Er=i.forwardRef(function(s,d){const{render:l,className:p,style:h,keepMounted:x=!1,...u}=s,y=Br(),w=y.checked||y.indeterminate,{mounted:b,transitionStatus:S,setMounted:k}=tr(w),c=i.useRef(null),g={...y,transitionStatus:S};It({batch:!0,enabled:!w,open:w,ref:c,onComplete(){w||k(!1)}});const v={...Qa(y),...Pt},_=x||b,$=ha("span",s,{ref:[d,c],state:g,stateAttributesMapping:v,props:u});return _?$:null});function Ar(a,s){return`target:${a}:${s}`}function Or(a){return`remove:${a.id||a.directory}`}function Ya(a){if(!a)return null;const s=new Date(a).getTime();return Number.isFinite(s)?Math.floor((Date.now()-s)/864e5):null}function $r(a){const s=Ya(a);if(s==null)return null;if(s<=0)return r("skills.usage.today");if(s<30)return r("skills.usage.days_ago",{days:s});const d=Math.max(1,Math.floor(s/30));return r("skills.usage.months_ago",{months:d})}function Ur(a){const s=Ya(a);return s==null?"bg-oai-gray-300 dark:bg-oai-gray-600":s<=7?"bg-emerald-500":s<=30?"bg-amber-500":"bg-oai-gray-300 dark:bg-oai-gray-600"}function ca({label:a,children:s}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2 text-sm",children:[e.jsx("dt",{className:"flex items-center gap-1 text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"text-right font-medium tabular-nums text-oai-black dark:text-white",children:s})]})}function Mr({skill:a,targets:s,busyKey:d,usage:l,hasUpdate:p,updating:h,onUpdate:x,onClose:u,onToggleTarget:y,onRemove:w}){return e.jsx(Kt,{children:a?e.jsx(zr,{skill:a,targets:s,busyKey:d,usage:l,hasUpdate:p,updating:h,onUpdate:x,onClose:u,onToggleTarget:y,onRemove:w},a.id||a.directory):null})}function zr({skill:a,targets:s,busyKey:d,usage:l,hasUpdate:p,updating:h,onUpdate:x,onClose:u,onToggleTarget:y,onRemove:w}){const b=Ht(),{currency:S,rate:k}=Vt(),c=i.useRef(null);i.useEffect(()=>{const L=H=>{H.key==="Escape"&&(H.stopPropagation(),u?.())},M=H=>{const T=H.target;T instanceof Element&&(c.current?.contains(T)||T.closest('[data-skill-row="1"]')||u?.())};return document.addEventListener("keydown",L),document.addEventListener("pointerdown",M),()=>{document.removeEventListener("keydown",L),document.removeEventListener("pointerdown",M)}},[u]);const g=a.name||a.directory,m=!!(a.repoOwner&&a.repoName),v=m?`https://github.com/${a.repoOwner}/${a.repoName}`:null,_=new Set(a.targets||[]),$=!!(a.readOnly||a.remote),U=!!a.remote,K=Array.isArray(a.deviceSources)?a.deviceSources:[],de=!U&&(!$||_.has("claude")),fe=d===Or(a),ne=$r(l?.lastUsedAt),B=!!(l&&l.invocations>0),pe=b?{duration:0}:{type:"spring",stiffness:320,damping:30,mass:.7};return e.jsxs(e.Fragment,{children:[e.jsx(wa.div,{className:"fixed inset-0 z-20 bg-oai-black/30 backdrop-blur-[2px] lg:hidden",initial:b?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:b?0:.15},onClick:u,"aria-hidden":!0}),e.jsxs(wa.aside,{ref:c,role:"complementary","aria-label":g,initial:b?!1:{opacity:0,x:24,scale:.98},animate:{opacity:1,x:0,scale:1},exit:b?{opacity:0}:{opacity:0,x:24,scale:.98},transition:pe,className:"fixed inset-x-3 bottom-3 top-20 z-30 flex flex-col overflow-hidden rounded-2xl border border-white/40 bg-white/75 shadow-[0_24px_60px_-20px_rgba(15,23,42,0.25)] backdrop-blur-xl backdrop-saturate-150 supports-[backdrop-filter]:bg-white/65 dark:border-white/10 dark:bg-oai-gray-950/70 dark:shadow-[0_24px_60px_-20px_rgba(0,0,0,0.7)] dark:supports-[backdrop-filter]:bg-oai-gray-950/55 lg:inset-auto lg:right-6 lg:top-24 lg:bottom-6 lg:w-[22rem] lg:max-h-[calc(100vh-7.5rem)]",children:[e.jsxs("header",{className:"flex items-center gap-3 border-b border-white/40 bg-gradient-to-b from-white/30 to-transparent px-5 pb-4 pt-5 dark:border-white/10 dark:from-white/[0.04]",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",title:g,children:g}),m?e.jsxs("a",{href:v,target:"_blank",rel:"noreferrer noopener",className:"mt-1 inline-flex max-w-full items-center gap-1 truncate text-xs text-oai-gray-500 transition-colors hover:text-oai-black hover:underline dark:text-oai-gray-400 dark:hover:text-white",title:v,children:[e.jsxs("span",{className:"truncate",children:[a.repoOwner,"/",a.repoName]}),e.jsx(ma,{className:"h-3 w-3 shrink-0","aria-hidden":!0})]}):a.directory&&a.directory!==g?e.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",title:a.directory,children:a.directory}):null]}),e.jsx("button",{type:"button",onClick:u,"aria-label":r("skills.detail.close"),className:"-mr-1 inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-oai-gray-500 transition hover:bg-oai-gray-100 hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(Le,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-5",children:[p?e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-xl bg-sky-50/80 px-3 py-2.5 ring-1 ring-sky-200 dark:bg-sky-950/30 dark:ring-sky-800/60",children:[e.jsx(ya,{className:"h-4 w-4 shrink-0 text-sky-600 dark:text-sky-300","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1 text-xs text-sky-800 dark:text-sky-200",children:r("skills.update.available")}),e.jsxs("button",{type:"button",onClick:()=>x?.(a),disabled:h||!!d,className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-md bg-sky-600 px-2.5 text-xs font-semibold text-white transition hover:bg-sky-700 focus:outline-none focus:ring-2 focus:ring-sky-400/40 disabled:cursor-not-allowed disabled:opacity-60 dark:bg-sky-500 dark:hover:bg-sky-400",children:[h?e.jsx(Z,{className:"h-3 w-3 animate-spin","aria-hidden":!0}):null,r("skills.update.action")]})]}):null,a.description?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a.description}):null,$?e.jsx("div",{className:"mt-4 rounded-xl bg-oai-gray-50 px-3 py-2.5 text-xs leading-5 text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-900/60 dark:text-oai-gray-300 dark:ring-oai-gray-800",children:r(U?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed")}):null,a.sourceName?e.jsx("div",{className:"mt-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.source",{source:a.sourceName})}):null,K.length?e.jsxs("section",{className:"mt-5",children:[e.jsx("h3",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.devices_title")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:K.map(L=>e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 rounded-full bg-oai-gray-100 px-2.5 py-1 text-xs text-oai-gray-700 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-200 dark:ring-oai-gray-700",children:[e.jsx(Pa,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"max-w-52 truncate",children:L.name})]},L.id))})]}):null,de?e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.usage.section_title")}),e.jsxs("dl",{className:"divide-y divide-oai-gray-200/60 dark:divide-white/[0.06]",children:[e.jsx(ca,{label:r("skills.usage.invocations"),children:Bt(l?.invocations||0)}),e.jsx(ca,{label:r("skills.usage.last_used"),children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:Y("h-1.5 w-1.5 rounded-full",Ur(l?.lastUsedAt)),"aria-hidden":!0}),B?ne||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(ca,{label:e.jsxs(e.Fragment,{children:[r("skills.usage.cost"),e.jsx("span",{title:r("skills.usage.disclaimer"),className:"inline-flex cursor-help text-oai-gray-400 dark:text-oai-gray-500",children:e.jsx(Ia,{className:"h-3 w-3","aria-label":r("skills.usage.disclaimer")})})]}),children:Dt(l?.cost||0,{currency:S,rate:k})})]}),B?null:e.jsx("p",{className:"mt-2 text-[11px] leading-4 text-oai-gray-400 dark:text-oai-gray-500",children:r("skills.usage.unused")})]}):null,$?null:e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.detail.sync_section_title")}),e.jsx("div",{children:(s||[]).filter(L=>L.manageable!==!1).map(L=>{const M=_.has(L.id),H=d===Ar(a.id||a.directory,L.id),T=`skill-detail-sync-${a.id||a.directory}-${L.id}`;return e.jsxs("label",{htmlFor:T,className:"-mx-2 flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 text-sm text-oai-black transition-colors hover:bg-oai-gray-100/70 dark:text-white dark:hover:bg-white/[0.05]",children:[e.jsx(Tr,{id:T,checked:M,disabled:!!d,onCheckedChange:ee=>y?.(a,L.id,!!ee),className:"peer flex h-4 w-4 shrink-0 items-center justify-center rounded-[4px] border border-oai-gray-300/80 bg-white/80 shadow-sm transition-colors hover:border-oai-gray-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 focus-visible:ring-offset-1 focus-visible:ring-offset-transparent disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:border-oai-black data-[checked]:bg-oai-black dark:border-oai-gray-500/60 dark:bg-oai-gray-900/60 dark:hover:border-oai-gray-400 dark:data-[checked]:border-white dark:data-[checked]:bg-white",children:e.jsx(Er,{className:"flex items-center justify-center text-white dark:text-oai-black",children:e.jsx(Ie,{className:"h-3 w-3",strokeWidth:3.5,"aria-hidden":!0})})}),e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center","aria-hidden":!0,children:e.jsx(ve,{provider:L.id,size:16})}),e.jsx("span",{className:"flex-1",children:L.label}),H?e.jsx(Z,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},L.id)})})]})]}),$?null:e.jsxs("footer",{className:"border-t border-white/40 bg-white/30 px-5 py-4 dark:border-white/10 dark:bg-white/[0.02]",children:[e.jsxs("button",{type:"button",onClick:()=>w?.(a),disabled:!!d,className:"inline-flex w-full items-center justify-center gap-2 rounded-lg border border-red-200/70 bg-white px-3 py-2 text-sm font-medium text-red-600 transition hover:border-red-300 hover:bg-red-50 focus:outline-none focus:ring-2 focus:ring-red-400/30 disabled:cursor-not-allowed disabled:opacity-60 dark:border-red-900/60 dark:bg-oai-gray-950 dark:text-red-300 dark:hover:border-red-800 dark:hover:bg-red-950/30",children:[fe?e.jsx(Z,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(fa,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.detail.remove_button")]}),e.jsx("p",{className:"mt-2 text-center text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.detail.remove_confirm_hint")})]})]})]})}const Fr=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),_a=["claude","codex"],Q="popular",Vr={claude:"text-orange-500 dark:text-orange-300",codex:"text-emerald-600 dark:text-emerald-300",grok:"text-zinc-700 dark:text-zinc-200",antigravity:"text-violet-600 dark:text-violet-300",gemini:"text-sky-600 dark:text-sky-300",opencode:"text-amber-600 dark:text-amber-300",hermes:"text-indigo-500 dark:text-indigo-300"},xe="all",V="skillssh";function na(a){return`${a.repoOwner||"local"}/${a.repoName||"local"}:${a.directory}`}function Ja(a){return String(a||"").replace(/\\/g,"/").trim().toLowerCase()}function Kr(a){return Ja(a).split("/").filter(Boolean).pop()||""}function Hr(a){if(a.repoOwner||a.repoName)return"";const s=Ja(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function Ra(a){const s=Kr(a.directory);return s?`dir:${s}`:""}function Za(a){const s=new Set([na(a).toLowerCase()]);a.repoOwner&&a.repoName&&s.add(`${a.repoOwner}/${a.repoName}:${a.sourceDirectory||a.directory}`.toLowerCase());const d=Hr(a);return d&&s.add(d),s}function Wr(a){return!a?.remote&&!a?.inventoryOnly&&!a?.readOnly}function qr(a){const s=new Set;for(const d of Array.isArray(a)?a:[])if(Wr(d))for(const l of Za(d))s.add(l);return s}function aa(a){return`install:${na(a)}`}function La(a){return`remove:${a.id||a.directory}`}function et(a,s){return`target:${a}:${s}`}function we(a){return a.id||a.directory}function ba(a){return a.manageable!==!1}function Gr({target:a,state:s,busy:d,disabled:l,disabledLabel:p,onToggle:h}){const x=s==="synced",u=s==="orphan",y=u?r("skills.dot.orphan_aria",{agent:a.label}):x?r("skills.dot.synced_aria",{agent:a.label}):r("skills.dot.off_aria",{agent:a.label}),w=l&&p?`${y} — ${p}`:y;return e.jsxs("button",{type:"button",title:w,"aria-label":w,"aria-pressed":x,disabled:d||l,onClick:b=>{b.stopPropagation(),h?.(a.id,!x)},className:"relative flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-oai-gray-100 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/40 disabled:cursor-not-allowed dark:hover:bg-oai-gray-800/60",children:[d?e.jsx(Z,{className:"h-4 w-4 animate-spin text-oai-gray-400","aria-hidden":!0}):e.jsx("span",{className:Y("flex h-[18px] w-[18px] items-center justify-center transition",x&&Vr[a.id],!x&&!u&&"opacity-35 grayscale"),"aria-hidden":!0,children:e.jsx(ve,{provider:a.id,size:18})}),u&&!d?e.jsx("span",{className:"absolute -bottom-px -right-px h-2 w-2 rounded-full bg-amber-500 ring-2 ring-oai-white dark:ring-oai-gray-900","aria-hidden":!0}):null]})}function Qr({skill:a,targets:s,onToggleTarget:d,busyKey:l}){const p=new Set(a.targets||[]),h=!!(a.readOnly||a.remote),x=[];for(const u of s)(h?p.has(u.id):ba(u))&&x.push(u);return e.jsx("div",{className:"flex items-center gap-1",onClick:u=>u.stopPropagation(),children:x.map(u=>e.jsx(Gr,{target:u,state:a.targetStates?.[u.id]||"off",busy:l===et(we(a),u.id),disabled:h||u.manageable===!1,disabledLabel:r(a.remote?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed"),onToggle:(y,w)=>d?.(a,y,w)},u.id))})}function Xr({skill:a,targets:s,selected:d,onSelect:l,selectable:p,checked:h,onToggleSelect:x,onToggleTarget:u,hasUpdate:y,busyKey:w}){const b=a.repoOwner&&a.repoName?`${a.repoOwner}/${a.repoName}`:null,S=[a.directory,b,a.sourceName].filter(Boolean).join(" · "),k=Array.isArray(a.deviceSources)?a.deviceSources:[],c=[a.remote?r("skills.inventory.remote"):null,a.scope==="plugin"?r("skills.inventory.plugin"):null].filter(Boolean),g=m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),l?.(a))};return e.jsxs("div",{"data-skill-row":"1",role:"button",tabIndex:0,"aria-pressed":d,"aria-label":r("skills.row.open_details",{name:a.name||a.directory}),onClick:()=>l?.(a),onKeyDown:g,className:Y("cursor-pointer rounded-md py-3 pr-2 transition focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30",d?"bg-oai-gray-100 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800/60 dark:ring-oai-gray-800":h?"bg-oai-gray-50 dark:bg-oai-gray-900/40":"hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/40"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[p?e.jsx("label",{className:"flex shrink-0 items-center",onClick:m=>m.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:h,onChange:m=>x?.(a,m.target.checked),"aria-label":r("skills.select.row_aria",{name:a.name||a.directory}),className:"h-4 w-4 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white"})}):null,e.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-oai-black dark:text-white",title:S,children:a.name||a.directory}),c.map(m=>e.jsx("span",{className:"inline-flex shrink-0 rounded-full bg-oai-gray-100 px-1.5 py-0.5 text-[10px] font-semibold text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-300 dark:ring-oai-gray-700",children:m},m)),y?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-semibold text-sky-700 ring-1 ring-sky-200 dark:bg-sky-950/40 dark:text-sky-300 dark:ring-sky-800/60",children:[e.jsx(ya,{className:"h-2.5 w-2.5","aria-hidden":!0}),r("skills.update.badge")]}):null,e.jsx(Qr,{skill:a,targets:s,onToggleTarget:u,busyKey:w}),e.jsx(Mt,{className:Y("hidden h-4 w-4 shrink-0 text-oai-gray-300 transition-colors dark:text-oai-gray-600 lg:block",d&&"text-oai-gray-500 dark:text-oai-gray-300"),"aria-hidden":!0})]}),a.description?e.jsx("p",{className:Y("mt-1 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",p&&"pl-7"),children:a.description}):null,a.sourceName||k.length?e.jsxs("div",{className:Y("mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-oai-gray-400 dark:text-oai-gray-500",p&&"pl-7"),children:[a.sourceName?e.jsx("span",{className:"truncate",children:a.sourceName}):null,k.length?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:k.map(m=>m.name).join(", "),children:[e.jsx(Pa,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r("skills.inventory.on_devices",{devices:k.map(m=>m.name).join(", ")})})]}):null]}):null]})}function Yr({agentFilter:a,agentOptions:s,onAgentFilter:d,filteredCount:l,totalCount:p,anyFilter:h,onClearFilters:x,searchQuery:u,onSearchQuery:y,searchPlaceholder:w}){return e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 pt-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsxs(Ba,{value:a,onValueChange:d,children:[e.jsxs(Da,{"aria-label":r("skills.filter.agent_label"),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200 dark:hover:border-oai-gray-700",children:[e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:[r("skills.filter.agent_label"),":"]}),e.jsx(Ta,{children:b=>b==="all"?r("skills.filter.agent_all"):s.find(S=>S.id===b)?.label||b}),e.jsx(qa,{className:"text-oai-gray-400",children:e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Ea,{children:e.jsx(Aa,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Oa,{className:"min-w-[var(--anchor-width)] overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs(ta,{value:"all",className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ra,{children:r("skills.filter.agent_all")}),e.jsx(sa,{children:e.jsx(Ie,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),s.map(b=>e.jsxs(ta,{value:b.id,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{provider:b.id,size:14}),e.jsx(ra,{children:b.label})]}),e.jsx(sa,{children:e.jsx(Ie,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},b.id))]})})})]}),e.jsxs("div",{className:"relative w-56 max-w-full",children:[e.jsx(ga,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(xa,{type:"search",value:u,onChange:b=>y(b.target.value),onKeyDown:b=>{b.key==="Escape"&&u&&(b.preventDefault(),y(""))},"aria-label":r("skills.action.search_aria"),placeholder:w,className:"h-8 pl-9 pr-8 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20 [&::-webkit-search-cancel-button]:appearance-none"}),e.jsx("button",{type:"button",onMouseDown:b=>b.preventDefault(),onClick:()=>y(""),"aria-label":r("skills.action.search_clear"),"aria-hidden":!u,tabIndex:u?0:-1,className:Y("absolute right-2 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full text-oai-gray-400 transition duration-150 ease-out before:absolute before:-inset-1.5 before:content-[''] hover:bg-oai-gray-100 hover:text-oai-gray-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 motion-reduce:transition-none dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",u?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{role:"status","aria-live":"polite",className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.filter.result_count",{filtered:l,total:p})}),h?e.jsxs("button",{type:"button",onClick:x,className:"shrink-0 inline-flex h-7 items-center gap-1 rounded-full bg-oai-gray-100 px-2.5 text-[11px] font-medium text-oai-gray-700 transition hover:bg-oai-gray-200 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:bg-oai-gray-800/70 dark:text-oai-gray-200 dark:hover:bg-oai-gray-700",children:[e.jsx(Le,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]})}function Jr({count:a,targets:s,busy:d,onBulkSync:l,onBulkRemove:p,onClear:h}){const x=s.filter(ba);return e.jsxs("div",{role:"toolbar","aria-label":r("skills.select.toolbar_aria"),className:"mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-3 py-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/50",children:[e.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200","aria-live":"polite",children:r("skills.select.count",{count:a})}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs(za,{children:[e.jsxs(Fa,{disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200",children:[e.jsx(Ma,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_sync"),e.jsx(pa,{className:"h-3 w-3","aria-hidden":!0})]}),e.jsx(Va,{children:e.jsx(Ka,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(Ha,{className:"min-w-[200px] rounded-lg bg-white p-1.5 shadow-lg ring-1 ring-oai-gray-200 dark:bg-oai-gray-950 dark:ring-oai-gray-800",children:[e.jsx("div",{className:"px-2 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.select.bulk_sync_hint")}),x.map(u=>e.jsxs("button",{type:"button",onClick:()=>l(u.id),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-oai-black hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800",children:[e.jsx(ve,{provider:u.id,size:16}),e.jsx("span",{className:"flex-1",children:u.label})]},u.id))]})})})]}),e.jsxs(X,{type:"button",variant:"ghost",size:"sm",disabled:d,onClick:p,children:[e.jsx(fa,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_remove")]}),e.jsxs("button",{type:"button",onClick:h,className:"inline-flex h-7 items-center gap-1 rounded-full px-2 text-[11px] font-medium text-oai-gray-500 transition hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:text-white",children:[e.jsx(Le,{className:"h-3 w-3","aria-hidden":!0}),r("skills.select.clear")]})]})]})}function Zr({items:a,totalCount:s,targets:d,agentOptions:l,agentFilter:p,onAgentFilter:h,anyFilter:x,onClearFilters:u,searchQuery:y,onSearchQuery:w,searchPlaceholder:b,selectedId:S,onSelect:k,onToggleTarget:c,busyKey:g,updates:m,selectedIds:v,onToggleSelect:_,onClearSelection:$,onBulkSync:U,onBulkRemove:K,updateCount:de,onUpdateAll:fe}){const ne=v.size;return e.jsxs("div",{children:[ne>0?e.jsx(Jr,{count:ne,targets:d,busy:g==="batch",onBulkSync:U,onBulkRemove:K,onClear:$}):e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx(Yr,{agentFilter:p,agentOptions:l,onAgentFilter:h,filteredCount:a.length,totalCount:s,anyFilter:x,onClearFilters:u,searchQuery:y,onSearchQuery:w,searchPlaceholder:b}),de?e.jsxs(X,{type:"button",variant:"secondary",size:"sm",className:"mb-2 shrink-0",disabled:!!g,onClick:fe,children:[g==="update-all"?e.jsx(Z,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(ya,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.update.all_action",{count:de})]}):null]}),a.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r("skills.empty.no_match")}),e.jsx(X,{type:"button",variant:"secondary",size:"sm",onClick:u,children:r("skills.filter.clear")})]}):e.jsx("div",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(B=>e.jsx(Xr,{skill:B,targets:d,selected:S===(B.id||B.directory),onSelect:k,selectable:!B.readOnly&&!B.remote,checked:v.has(we(B)),onToggleSelect:_,onToggleTarget:c,hasUpdate:!!(B.id&&m?.[B.id]),busyKey:g},we(B)))})]})}const es={contentVisibility:"auto",containIntrinsicSize:"0 240px"},as=Ut.memo(function({skill:s,installed:d,installing:l,allTargets:p,defaultTargets:h,onInstall:x,onManage:u}){const[y,w]=i.useState(()=>(h||[]).filter(m=>p.some(v=>v.id===m))),b=m=>{w(v=>v.includes(m)?v.filter(_=>_!==m):[...v,m])},S=s.repoOwner&&s.repoName?`${s.repoOwner}/${s.repoName}`:null,k=S?`https://github.com/${s.repoOwner}/${s.repoName}`:null,c=s.installs!=null?r("skills.card.installs",{count:Number(s.installs||0).toLocaleString()}):null,g=y.length?y.map(m=>p.find(v=>v.id===m)?.label||m).join(", "):r("skills.action.choose_targets");return e.jsxs(Ft,{className:"h-full rounded-lg",bodyClassName:"flex h-full flex-col",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[s.readmeUrl?e.jsxs("a",{href:s.readmeUrl,target:"_blank",rel:"noopener noreferrer",className:"group inline-flex max-w-full items-center gap-1 truncate text-base font-semibold text-oai-black hover:underline dark:text-white",title:s.readmeUrl,children:[e.jsx("span",{className:"truncate",children:s.name||s.directory}),e.jsx(ma,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:s.name||s.directory}),S||c?e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-1.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[k?e.jsxs("a",{href:k,target:"_blank",rel:"noopener noreferrer",onClick:m=>m.stopPropagation(),className:"inline-flex items-center gap-1 truncate rounded text-oai-gray-500 hover:text-oai-black hover:underline focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:text-white",title:k,children:[e.jsx("span",{className:"truncate",children:S}),e.jsx(ma,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,S&&c?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,c?e.jsx("span",{className:"truncate",children:c}):null]}):null]})}),s.description?e.jsx("p",{className:"mt-3 line-clamp-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:s.description}):null,e.jsx("div",{className:"mt-auto pt-5",children:d?e.jsxs(X,{type:"button",variant:"secondary",size:"sm",onClick:()=>u?.(s),className:"w-full",children:[e.jsx(Ie,{className:"mr-1.5 h-3.5 w-3.5 text-emerald-500 dark:text-emerald-400","aria-hidden":!0}),r("skills.card.manage")]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.card.targets_prefix")}),e.jsx("span",{className:"min-w-0 truncate font-medium text-oai-black dark:text-white",children:y.length?g:r("skills.target.none")}),e.jsxs(za,{children:[e.jsx(Fa,{disabled:l,"aria-label":r("skills.action.choose_targets"),className:"rounded text-xs font-medium text-oai-gray-500 underline decoration-oai-gray-300 decoration-dotted underline-offset-2 transition hover:text-oai-black hover:decoration-oai-gray-500 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:cursor-not-allowed disabled:opacity-60 dark:text-oai-gray-400 dark:decoration-oai-gray-600 dark:hover:text-white dark:hover:decoration-oai-gray-400",children:r("skills.card.targets_change")}),e.jsx(Va,{children:e.jsx(Ka,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(Ha,{className:"min-w-[220px] rounded-lg bg-white p-1.5 shadow-lg ring-1 ring-oai-gray-200 dark:bg-oai-gray-950 dark:ring-oai-gray-800",children:[e.jsx("div",{className:"px-2 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.target.menu_label")}),p.map(m=>{const v=y.includes(m.id);return e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm text-oai-black hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 shrink-0 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white",checked:v,onChange:()=>b(m.id)}),e.jsx(ve,{provider:m.id,size:16}),e.jsx("span",{className:"flex-1 text-left",children:m.label})]},m.id)})]})})})]})]}),e.jsxs(X,{type:"button",size:"sm",onClick:()=>x(s,y),disabled:l||y.length===0,className:"w-full",children:[l?e.jsx(Z,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(Ma,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.action.install")]})]})})]})});function ts({repos:a,repoInput:s,onRepoInput:d,busyKey:l,onAdd:p,onRemove:h}){return e.jsxs("div",{className:"rounded-lg border border-oai-gray-200 bg-white p-4 dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx(xa,{value:s,onChange:x=>d(x.target.value),placeholder:r("skills.repo.placeholder"),className:"min-w-0 flex-1"}),e.jsxs(X,{type:"button",variant:"secondary",size:"md",onClick:p,disabled:l==="repo:add",className:"shrink-0 whitespace-nowrap",children:[l==="repo:add"?e.jsx(Z,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(Ua,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.repo.add")]})]}),a.length?e.jsx("div",{className:"mt-3 divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(x=>{const u=l===`repo:${x.owner}/${x.name}`;return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"truncate text-sm font-medium text-oai-black dark:text-white",children:[x.owner,"/",x.name]}),e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:x.branch})]}),e.jsxs(X,{type:"button",variant:"ghost",size:"sm",disabled:u,onClick:()=>h(x),className:"shrink-0",children:[u?e.jsx(Z,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(fa,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:r("skills.repo.remove")})]})]},`${x.owner}/${x.name}`)})}):null]})}function rs(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Ps(){const a=Tt()||{},s=!!a.signedIn,d=a.getAccessToken,[l,p]=i.useState(rs),[h,x]=i.useState({skills:[],targets:[]}),[u,y]=i.useState([]),[w,b]=i.useState([]),[S,k]=i.useState([]),[c,g]=i.useState(xe),[m,v]=i.useState(""),[_,$]=i.useState(""),[U,K]=i.useState(""),[de,fe]=i.useState(""),[ne,B]=i.useState(""),[pe,L]=i.useState(!1),[M,H]=i.useState("all"),[T,ee]=i.useState(null),[J,je]=i.useState(""),ce=i.useRef(!1),[Pe,We]=i.useState(!0),[Be,De]=i.useState(!1),[R,I]=i.useState(""),[W,D]=i.useState(null),[ae,P]=i.useState(null),[Ne,Te]=i.useState(null),[ie,Ee]=i.useState(()=>new Set),[ue,Ae]=i.useState({}),[Oe,qe]=i.useState({}),[Ce,$e]=i.useState([]),[me,Ge]=i.useState(!1),Ue=i.useRef(!1),te=i.useRef(0),E=i.useMemo(()=>qr(h.skills),[h.skills]),Se=i.useCallback(async()=>{const t=++te.current,n=await rr();if(te.current!==t)return;const o={skills:n.skills||[],targets:n.targets||[]};x(o);const f=Et();!s||!At()||!f||typeof d!="function"||(async()=>{try{const j=await d();if(!j||te.current!==t)return;const[C]=await Promise.allSettled([sr(j),nr({accessToken:j,deviceId:f,skills:o.skills})]);if(C.status!=="fulfilled")return;const ke=C.value;if(te.current!==t)return;x({targets:o.targets,skills:ir(o.skills,ke,f)})}catch{}})()},[d,s]),ge=i.useCallback(async()=>{const t=await or();k(t.repos||[])},[]),q=i.useCallback(async({force:t=!1}={})=>{De(!0);try{const n=await lr({force:t});y(n.skills||[])}finally{De(!1)}},[]),he=i.useCallback(async({force:t=!1}={})=>{Ge(!0);try{const n=await dr({force:t});$e(n.skills||[])}finally{Ge(!1)}},[]),A=i.useCallback(async()=>{try{const t=await cr();Ae(t?.updates||{})}catch{}},[]),Me=i.useCallback(t=>{const n=new Set((t||[]).filter(Boolean));n.size&&Ae(o=>{if(!Object.keys(o).some(j=>n.has(j)))return o;const f={};for(const[j,C]of Object.entries(o))n.has(j)||(f[j]=C);return f})},[]),ye=i.useCallback(async()=>{try{const t=await ur(),n={};for(const o of t?.skills||[])o.installed&&(o.directory&&(n[String(o.directory).toLowerCase()]=o),n[String(o.skill).toLowerCase()]=o);qe(n)}catch{qe({})}},[]),_e=i.useCallback(async()=>{We(!0),I("");try{await Promise.all([Se(),ge()])}catch(t){I(t?.message||r("skills.error.generic"))}finally{We(!1)}},[Se,ge]),ia=i.useCallback(async()=>{await _e();const t=n=>I(n?.message||r("skills.error.generic"));l==="my"?(A(),ye()):c===Q?he({force:!0}).catch(t):c!==V&&q({force:!0}).catch(t)},[q,_e,he,A,ye,c,l]);i.useEffect(()=>{_e()},[_e]),i.useEffect(()=>{if(Ue.current||typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("skill");if(!n){Ue.current=!0;return}const o=h.skills||[];if(!o.length)return;const f=o.find(C=>C.directory===n||C.id===n);f&&(p("my"),ee(f.id||f.directory)),Ue.current=!0,t.delete("skill");const j=t.toString();window.history.replaceState({},"",`${window.location.pathname}${j?`?${j}`:""}${window.location.hash}`)},[h.skills]),i.useEffect(()=>{l==="browse"&&(c===V||c===Q||u.length===0&&q().catch(t=>I(t?.message||r("skills.error.generic"))))},[u.length,q,c,l]),i.useEffect(()=>{l!=="browse"||c!==Q||Ce.length===0&&he().catch(t=>I(t?.message||r("skills.error.generic")))},[he,Ce.length,c,l]);const Qe=Object.keys(ue).length>0,Xe=Object.keys(Oe).length>0;if(i.useEffect(()=>{l==="my"&&(Qe||A(),Xe||ye())},[l,Qe,Xe,A,ye]),i.useEffect(()=>{const t=setTimeout(()=>$(m),200);return()=>clearTimeout(t)},[m]),i.useEffect(()=>{const t=setTimeout(()=>fe(U),120);return()=>clearTimeout(t)},[U]),i.useEffect(()=>{if(typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("tab");if(l==="my"){if(!n)return;t.delete("tab")}else{if(n===l)return;t.set("tab",l)}const o=t.toString(),f=`${window.location.pathname}${o?`?${o}`:""}${window.location.hash}`;window.history.replaceState({},"",f)},[l]),!Fr&&!Ot())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(zt,{})});const z=async(t,n)=>{if(!ce.current){ce.current=!0,je(t),I("");try{await n(),await Se()}catch(o){I(o?.message||r("skills.error.generic"))}finally{ce.current=!1,je("")}}},oa=(t,n)=>{const o=(n&&n.length?n:_a).filter(f=>(h.targets||[]).some(j=>j.id===f));z(aa(t),async()=>{await gr(t,o);const f=o.map(j=>(h.targets||[]).find(C=>C.id===j)?.label||j).join(", ");G({title:r("skills.toast.installed",{name:t.name||t.directory,targets:f||r("skills.target.none")}),timeout:4e3})})},Ye=t=>{t?.readOnly||t?.remote||D(t)},ze=()=>{const t=W;t&&(D(null),z(La(t),async()=>{let n=null;t.managed?n=await va(t.id):await ja(t.directory,t.targets||[]),Me([t.id]);const o=!!(n?.trashed&&t.managed&&t.id);G({title:r("skills.toast.removed",{name:t.name||t.directory}),timeout:6e3,data:o?{onUndo:async()=>{try{await hr(t.id),await Se()}catch(f){I(f?.message||r("skills.error.generic"))}}}:void 0})}))},N=(t,n,o)=>t?.readOnly||t?.remote?Promise.resolve():z(et(we(t),n),async()=>{const f=new Set(t.targets||[]);o?f.add(n):f.delete(n),t.managed?await Na(t.id,Array.from(f)):await Ca(t.directory,Array.from(f));const j={name:t.name||t.directory,agent:re(n)};G({title:o?r("skills.toast.synced_one",j):r("skills.toast.unsynced_one",j),timeout:3e3})}),F=i.useCallback(()=>Ee(new Set),[]),oe=i.useCallback((t,n)=>{if(t?.readOnly||t?.remote)return;const o=we(t);Ee(f=>{const j=new Set(f);return n?j.add(o):j.delete(o),j})},[]),re=t=>(h.targets||[]).find(n=>n.id===t)?.label||t,Re=t=>{const n=(h.skills||[]).filter(o=>ie.has(we(o))&&!o.readOnly&&!o.remote);n.length&&z("batch",async()=>{for(const o of n){const f=new Set(o.targets||[]);f.add(t),o.managed?await Na(o.id,Array.from(f)):await Ca(o.directory,Array.from(f))}F(),G({title:r("skills.toast.bulk_synced",{count:n.length,agent:re(t)}),timeout:4e3})})},Fe=()=>{const t=(h.skills||[]).filter(n=>ie.has(we(n))&&!n.readOnly&&!n.remote);t.length&&P(t)},Ve=()=>{const t=ae;t&&(P(null),z("batch",async()=>{for(const n of t)n.managed?await va(n.id):await ja(n.directory,n.targets||[]);Me(t.map(n=>n.id)),F(),G({title:r("skills.toast.bulk_removed",{count:t.length}),timeout:4e3})}))},at=t=>{!t?.id||!t?.repoOwner||!t?.repoName||z(aa(t),async()=>{const n=await Sa([t.id]);await A();const{results:o=[],rateLimited:f=null,updated:j=0}=n||{};if(f){G({title:r("skills.update.rate_limited",{count:j}),timeout:6e3});return}const C=o[0];if(!C||!C.ok)throw new Error(C?.error||r("skills.error.generic"));G({title:r("skills.toast.updated",{name:t.name||t.directory}),timeout:4e3})})},tt=new Set((h.skills||[]).map(t=>t.id).filter(Boolean)),la=Object.entries(ue).filter(([t,n])=>n&&tt.has(t)).map(([t])=>t),rt=la.length,st=()=>{la.length&&Te(la)},nt=()=>{const t=Ne;Te(null),!(!t||!t.length)&&z("update-all",async()=>{const n=await Sa(t);await A();const{updated:o=0,failed:f=0,rateLimited:j=null,results:C=[]}=n||{},ke=C.length;if(j)G({title:r("skills.update.rate_limited",{count:o}),timeout:6e3});else if(f>0)G({title:r("skills.toast.updated_partial",{count:o,total:ke,failed:f}),timeout:6e3});else if(o===0)G({title:r("skills.toast.updated_none"),timeout:4e3});else if(o===1){const O=C.find(ea=>ea.ok&&!ea.skipped);G({title:r("skills.toast.updated",{name:O?.name||""}),timeout:4e3})}else G({title:r("skills.toast.updated_many",{count:o}),timeout:4e3})})},ka=async()=>{const t=m.trim();if(!(t.length<2||ce.current)){ce.current=!0,je("search"),I("");try{const n=await mr(t);b(n.skills||[])}catch(n){I(n?.message||r("skills.error.generic"))}finally{ce.current=!1,je("")}}},it=async()=>{const t=ne.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[n,o]=t.split("/");if(!n||!o){I(r("skills.repo.invalid"));return}await z("repo:add",async()=>{await fr({owner:n,name:o,branch:"main",enabled:!0}),B(""),await ge(),await q()})},ot=async t=>{await z(`repo:${t.owner}/${t.name}`,async()=>{await xr(t.owner,t.name),await ge(),await q()})},le=h.targets||[],lt=le.filter(ba),be=h.skills||[],dt=i.useMemo(()=>{const t=M==="all"?be:be.filter(o=>(o.targets||[]).includes(M)),n=de.trim().toLowerCase();return n?t.filter(o=>(o.name||"").toLowerCase().includes(n)||(o.directory||"").toLowerCase().includes(n)||(o.description||"").toLowerCase().includes(n)):t},[be,M,de]),ct=M!=="all",se=i.useMemo(()=>T&&be.find(t=>(t.id||t.directory)===T)||null,[be,T]),ut=i.useCallback(()=>{H("all"),K("")},[]),mt=i.useCallback(t=>{ee(n=>{const o=t?.id||t?.directory||null;return n===o?null:o})},[]),gt=i.useCallback(()=>ee(null),[]),ht=i.useCallback(t=>{const n=na(t).toLowerCase(),o=Ra(t),f=(h.skills||[]).find(j=>{const C=Za(j);return C.has(n)||o&&C.has(o)});f&&ee(f.id||f.directory)},[h.skills]);i.useEffect(()=>{l!=="my"&&ie.size&&Ee(new Set)},[l,ie.size]),i.useEffect(()=>{T&&!se&&ee(null)},[se,T]);const Ke=i.useMemo(()=>{const t=c===V?w:c===Q?Ce:u,o=c===V||c===Q||c===xe?t:t.filter(C=>`${C.repoOwner}/${C.repoName}`===c),f=_.trim().toLowerCase();return(c===V||!f?o:o.filter(C=>(C.name||"").toLowerCase().includes(f)||(C.directory||"").toLowerCase().includes(f)||(C.description||"").toLowerCase().includes(f))).map(C=>{const ke=na(C).toLowerCase(),O=Ra(C);return{...C,installed:E.has(ke)||O&&E.has(O)}})},[_,u,E,Ce,w,c]),xt=e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(Z,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),ft=e.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[e.jsx(Z,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0}),e.jsx("p",{className:"max-w-md text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.browse.loading_hint")})]}),Je=(t,n=null)=>e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r(t)}),n]});let Ze;if(Pe)Ze=xt;else if(l==="my")Ze=be.length?e.jsx(Zr,{items:dt,totalCount:be.length,targets:le,agentOptions:le,agentFilter:M,onAgentFilter:H,anyFilter:ct,onClearFilters:ut,searchQuery:U,onSearchQuery:K,searchPlaceholder:r("skills.my.placeholder"),selectedId:T,onSelect:mt,onToggleTarget:N,busyKey:J,updates:ue,selectedIds:ie,onToggleSelect:oe,onClearSelection:F,onBulkSync:Re,onBulkRemove:Fe,updateCount:rt,onUpdateAll:st}):e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-800",children:[le.length>0?e.jsxs("div",{className:"relative h-11 w-80 overflow-hidden","aria-hidden":!0,children:[e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)",WebkitMaskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",style:{filter:"blur(2.5px)"},children:[...le,...le].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(ve,{provider:t.id,size:30})},`b-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)",WebkitMaskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",children:[...le,...le].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(ve,{provider:t.id,size:30})},`c-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 w-20 bg-gradient-to-r from-oai-white to-transparent dark:from-oai-gray-900"}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 w-20 bg-gradient-to-l from-oai-white to-transparent dark:from-oai-gray-900"})]}):null,e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.empty.my")}),e.jsx(X,{type:"button",size:"sm",onClick:()=>p("browse"),children:r("skills.empty.my_cta")})]});else{const t=c===V,n=c===Q,o=S.length===0&&!t&&!n,f=Be&&!t&&!n||n&&me,j=!t&&!n&&(_.trim()!==""||c!==xe),C=()=>{v(""),g(xe)},ke=!o&&!f&&(Ke.length>0||j)?e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 px-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:r("skills.filter.result_count_browse",{count:Ke.length})}),j?e.jsxs("button",{type:"button",onClick:C,className:"ml-auto inline-flex h-7 items-center gap-1 rounded-full bg-oai-gray-100 px-2.5 text-[11px] font-medium text-oai-gray-700 transition hover:bg-oai-gray-200 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:bg-oai-gray-800/70 dark:text-oai-gray-200 dark:hover:bg-oai-gray-700",children:[e.jsx(Le,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]}):null;let O;o?O=e.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 p-6 text-center dark:border-oai-gray-800",children:e.jsx("p",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:r("skills.browse.empty_sources")})}):f?O=ft:t&&m.trim().length<2?O=e.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 px-4 py-6 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:r("skills.browse.hint_skillssh")}):Ke.length?O=e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:Ke.map(He=>e.jsx("div",{style:es,children:e.jsx(as,{skill:He,installed:!!He.installed,installing:J===aa(He),allTargets:lt,defaultTargets:_a,onInstall:oa,onManage:ht})},He.id||He.key))}):j?O=Je("skills.empty.no_match",e.jsx(X,{type:"button",variant:"secondary",size:"sm",onClick:C,children:r("skills.filter.clear")})):t?O=Je("skills.empty.search"):n?O=Je("skills.empty.popular"):O=Je("skills.empty.browse");const ea=o||pe?e.jsx("div",{className:"mb-5",children:e.jsx(ts,{repos:S,repoInput:ne,onRepoInput:B,busyKey:J,onAdd:it,onRemove:ot})}):null,pt=!pe&&!t&&!n&&S.length<=1&&Ke.length>0?e.jsx(wr,{id:"skills-browse-intro",className:"mt-6",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{children:r("skills.browse.add_repo_hint")}),e.jsx("button",{type:"button",onClick:()=>L(!0),className:"rounded font-medium text-oai-gray-700 underline decoration-dotted underline-offset-2 transition hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-200 dark:hover:text-white",children:r("skills.browse.manage_sources")})]})}):null;Ze=e.jsxs(e.Fragment,{children:[ea,ke,O,pt]})}return e.jsxs("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-12 pt-8 sm:pb-16 sm:pt-10",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-6 flex items-end justify-between gap-4",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:r("skills.page.title")}),e.jsxs(X,{type:"button",variant:"secondary",size:"sm",onClick:ia,disabled:Pe||Be||me,children:[e.jsx($t,{className:Y("mr-1.5 h-3.5 w-3.5",(Pe||Be||me)&&"animate-spin"),"aria-hidden":!0}),r("skills.action.refresh")]})]}),e.jsx("div",{className:"mb-5 flex gap-6 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[["my",r("skills.tab.my")],["browse",r("skills.tab.browse")]].map(([t,n])=>e.jsx("button",{type:"button","aria-pressed":l===t,onClick:()=>p(t),className:Y("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",l===t?"border-oai-black text-oai-black dark:border-white dark:text-white":"border-transparent text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:n},t))}),R?e.jsx("div",{className:"mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-200",children:R}):null,l==="browse"?e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx(yr,{className:"shrink-0",ariaLabel:r("skills.source.label"),options:[{id:"repo",label:r("skills.mode.repo")},{id:"popular",label:r("skills.mode.popular"),icon:e.jsx(pr,{className:"h-3.5 w-3.5","aria-hidden":!0})},{id:"skillssh",label:r("skills.mode.skillssh")}],value:c===V?"skillssh":c===Q?"popular":"repo",onChange:t=>{t==="skillssh"?g(V):t==="popular"?g(Q):(c===V||c===Q)&&g(xe)}}),c!==V&&c!==Q?e.jsxs(Ba,{value:c,onValueChange:g,children:[e.jsxs(Da,{"aria-label":r("skills.source.label"),className:"inline-flex h-8 w-44 shrink-0 items-center justify-between gap-2 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs text-oai-black focus:outline-none data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:data-[popup-open]:border-oai-gray-700",children:[e.jsx(Ta,{children:t=>t===xe?r("skills.source.all"):t}),e.jsx(qa,{className:"text-oai-gray-400",children:e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Ea,{children:e.jsx(Aa,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Oa,{className:"min-w-[var(--anchor-width)] overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none transition-[opacity,transform] duration-150 ease-out data-[ending-style]:scale-[0.97] data-[ending-style]:opacity-0 data-[starting-style]:scale-[0.97] data-[starting-style]:opacity-0 dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs(ta,{value:xe,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ra,{children:r("skills.source.all")}),e.jsx(sa,{children:e.jsx(Ie,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),S.map(t=>{const n=`${t.owner}/${t.name}`;return e.jsxs(ta,{value:n,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ra,{children:n}),e.jsx(sa,{children:e.jsx(Ie,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},n)})]})})})]}):null,e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ga,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(xa,{type:"search",value:m,onChange:t=>v(t.target.value),onKeyDown:t=>{t.key==="Enter"&&c===V&&ka()},"aria-label":r("skills.action.search_aria"),placeholder:c===V?r("skills.browse.placeholder_skillssh"):c===Q?r("skills.browse.placeholder_popular"):c===xe?r("skills.browse.placeholder_all"):r("skills.browse.placeholder_repo",{repo:c}),className:"h-8 pl-9 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20"})]}),c===V?e.jsxs(X,{type:"button",size:"sm",onClick:ka,disabled:m.trim().length<2||J==="search",className:"focus:!ring-oai-gray-400/30",children:[J==="search"?e.jsx(Z,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(ga,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.action.search")]}):c===Q?null:e.jsxs(X,{type:"button",variant:"secondary",size:"sm",onClick:()=>L(t=>!t),"aria-expanded":pe,className:"!h-8 shrink-0 whitespace-nowrap !border-oai-gray-200 dark:!border-oai-gray-800 hover:!border-oai-gray-300 dark:hover:!border-oai-gray-700 hover:!text-oai-black dark:hover:!text-white focus:!ring-oai-gray-400/30",children:[e.jsx(Ua,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.browse.manage_sources"),e.jsx("span",{className:"ml-1.5 rounded bg-oai-gray-100 px-1.5 py-0.5 text-xs font-medium text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:S.length})]})]}):null,Ze,e.jsx(Mr,{skill:se,targets:le,busyKey:J,usage:se&&(Oe[String(se.directory||"").toLowerCase()]||Oe[String(se.name||"").toLowerCase()])||null,hasUpdate:!!(se?.id&&ue?.[se.id]),updating:se?J===aa(se):!1,onUpdate:at,onClose:gt,onToggleTarget:N,onRemove:Ye})]})}),e.jsx(da,{open:!!W,title:r("skills.confirm.remove_title",{name:W?.name||W?.directory||""}),description:W?W.managed?r("skills.confirm.remove_managed"):r("skills.confirm.remove_local"):"",confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:J===La(W||{}),onCancel:()=>D(null),onConfirm:ze}),e.jsx(da,{open:!!ae,title:r("skills.confirm.bulk_remove_title",{count:ae?.length||0}),description:r("skills.confirm.bulk_remove_desc"),confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:J==="batch",onCancel:()=>P(null),onConfirm:Ve}),e.jsx(da,{open:!!Ne,title:r("skills.confirm.update_all_title",{count:Ne?.length||0}),description:r("skills.confirm.update_all_desc"),confirmLabel:r("skills.update.action"),cancelLabel:r("shared.action.cancel"),onCancel:()=>Te(null),onConfirm:nt})]})}export{Ps as SkillsPage,qr as buildLocallyInstalledKeys};
|