tokentracker-cli 0.37.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/dist/assets/{ActivityHeatmap-CHyQx8kb.js → ActivityHeatmap-DN2mmuWt.js} +1 -1
- package/dashboard/dist/assets/{Card-DnFsEPmk.js → Card-eNDH0TxH.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-C7Ec-LrI.js → DashboardPage-CzS5TxMe.js} +1 -1
- package/dashboard/dist/assets/{DevicePage-DFp21WlU.js → DevicePage-DEVImOIW.js} +1 -1
- package/dashboard/dist/assets/{DialogTitle-C7CwLbYz.js → DialogTitle-BJKAi66j.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-CmqK4vog.js → FadeIn-DFk4dbUG.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-Cu0-A7WB.js → HeaderGithubStar-D-r1KB-R.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-Ct9pgqbB.js → IpCheckPage-D4FmaQyH.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-Bb4n4XoT.js → LandingPage-DLwmI1xA.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardAvatar-snuxOX5K.js → LeaderboardAvatar-DDZO2W2u.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-B-kigZ8J.js → LeaderboardPage-DcdnX8ha.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfileModal-OqodFCGv.js → LeaderboardProfileModal-D3PwKHWY.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfilePage-BspW68Xd.js → LeaderboardProfilePage-CnAg45qs.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-CS2NBEIP.js → LimitsPage-onwdR9lM.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-D0XXnH8l.js → LocalOnlyNotice-CbVonMVs.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-8S9O3Gsb.js → LoginPage-DZpN9E7q.js} +1 -1
- package/dashboard/dist/assets/{PopoverPopup-BJb6Du8x.js → PopoverPopup-DCGh4euQ.js} +1 -1
- package/dashboard/dist/assets/{Select-DksFSHRb.js → Select-aIEVSJVR.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-DmE9ZyEL.js → SelectItemText-BH_vsFMS.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-BDRMT04n.js → SettingsPage-D2jlgb1x.js} +1 -1
- package/dashboard/dist/assets/{SkillsPage-DPHemuRK.js → SkillsPage-CTVaKIo2.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-BOX3tPr8.js → WidgetsPage-B67l27g8.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-DWVJ6uf1.js → WrappedPage-wY4L8E_D.js} +1 -1
- package/dashboard/dist/assets/{agent-logos-C2IT3yLV.js → agent-logos-Bfb8Gcna.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-CnvG5D97.js → arrow-up-right-RH7MeYHL.js} +1 -1
- package/dashboard/dist/assets/{download-C1zysMDD.js → download-Ds1ViaQ9.js} +1 -1
- package/dashboard/dist/assets/{info-DnI8z26t.js → info-DD3Xh30V.js} +1 -1
- package/dashboard/dist/assets/{main-BpChBpB7.js → main-BZBATt4l.js} +2 -2
- package/dashboard/dist/assets/{use-limits-display-prefs-sb2nFpV_.js → use-limits-display-prefs-C9k19eUo.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-DWh-bpfp.js → use-native-settings-HjLLYUkn.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-DLSUBzW9.js → use-usage-limits-iJ3HJWfz.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-B1Aa7Unc.js → useCurrency-Cr1NSPgK.js} +1 -1
- package/dashboard/dist/assets/{useOpenInteractionType-2Q4xhr62.js → useOpenInteractionType-B65bQ4-n.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
- package/src/commands/init.js +3 -3
- package/src/commands/status.js +9 -4
- package/src/commands/sync.js +26 -0
- package/src/lib/pricing/curated-overrides.json +1 -0
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +208 -0
- package/src/lib/usage-limits.js +15 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as y,r as l,ah as Q,ab as q,aD as L,j as n,m as A,N as v,A as s,Q as X,ao as ee,aE as te,as as ne,at as ae,au as O,aF as ie,aG as se,O as oe,R as re,K as le,M as ce,W as ue,aH as de,aI as ge,aJ as he,aK as pe,E as me,aL as be,aM as fe,aN as xe,aO as ye,aP as ve,aQ as je,aR as ke,a9 as Ne}from"./main-BpChBpB7.js";import{a as Se,b as E,u as we,L as G}from"./use-limits-display-prefs-sb2nFpV_.js";import{S as j,T as k,a as b,b as _,u as P}from"./use-native-settings-DWh-bpfp.js";import{C as Ce}from"./useOpenInteractionType-2Q4xhr62.js";import{u as Le}from"./useCurrency-B1Aa7Unc.js";import{S as D}from"./Select-DksFSHRb.js";import{I as Ee}from"./info-DnI8z26t.js";import{D as Ge}from"./download-C1zysMDD.js";import"./Card-DnFsEPmk.js";import"./SelectItemText-DmE9ZyEL.js";const Ie=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ae=y("activity",Ie);const Oe=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],_e=y("copy",Oe);const Pe=[["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"}]],De=y("grip-vertical",Pe);const Te=[["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"}]],Me=y("languages",Te);const Ue=[["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"}]],Re=y("log-out",Ue);const Fe=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],He=y("pencil",Fe),$e=e=>!e.isLayoutDirty&&e.willUpdate(!1);function I(){const e=new Set,t=new WeakMap,a=()=>e.forEach($e);return{add:i=>{e.add(i),t.set(i,i.addEventListener("willUpdate",a))},remove:i=>{e.delete(i);const o=t.get(i);o&&(o(),t.delete(i)),a()},dirty:a}}const Be=l.createContext(null);function ze(){const e=l.useRef(!1);return Q(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function Ve(){const e=ze(),[t,a]=l.useState(0),i=l.useCallback(()=>{e.current&&a(t+1)},[t]);return[l.useCallback(()=>q.postRender(i),[i]),t]}const T=e=>e===!0,Ke=e=>T(e===!0)||e==="id",We=({children:e,id:t,inherit:a=!0})=>{const i=l.useContext(L),o=l.useContext(Be),[r,c]=Ve(),u=l.useRef(null),g=i.id||o;u.current===null&&(Ke(a)&&g&&(t=t?g+"-"+t:g),u.current={id:t,group:T(a)&&i.group||I()});const h=l.useMemo(()=>({...u.current,forceRender:r}),[c]);return n.jsx(L.Provider,{value:h,children:e})},Ze=new Set(["cursor","kiro","copilot","kimi"]);function Ye({checked:e,onChange:t,ariaLabel:a}){return n.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":a,onClick:t,className:v("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:n.jsx("span",{className:v("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function Je({prefs:e}){const{order:t,visibility:a,toggle:i,moveToward:o}=e,[r,c]=l.useState(null),[u,g]=l.useState(null),h=d=>p=>{c(d),p.dataTransfer.effectAllowed="move",p.dataTransfer.setData("text/plain",d)},m=d=>p=>{p.preventDefault(),p.dataTransfer.dropEffect="move",r&&r!==d&&u!==d&&(g(d),o(r,d))},f=()=>{c(null),g(null)},x=d=>{d.preventDefault(),c(null),g(null)};return n.jsx(We,{children:n.jsx("div",{className:"flex flex-col",children:t.map(d=>{const p=a[d]!==!1,N=r===d;return n.jsxs(A.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:h(d),onDragOver:m(d),onDragEnd:f,onDrop:x,className:v("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",N&&"opacity-40"),style:{cursor:N?"grabbing":"grab"},children:[n.jsx(De,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),n.jsx("img",{src:Se[d],alt:"",width:18,height:18,className:v("h-[18px] w-[18px] shrink-0 pointer-events-none",Ze.has(d)&&"dark:invert"),draggable:!1}),n.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:E[d]}),n.jsx("div",{onMouseDown:S=>S.stopPropagation(),draggable:!1,children:n.jsx(Ye,{checked:p,onChange:()=>i(d),ariaLabel:`${s("limits.settings.toggle_visible")}: ${E[d]}`})})]},d)})})})}function Qe(e){if(!e||typeof e!="object")return"";const t=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},a=e.profile&&typeof e.profile=="object"?e.profile:{},i=t.full_name||t.name||a.name||t.user_name||t.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 qe(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function Xe(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const a=t.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=t.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=a?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function w(e,t){console.warn(`[tokentracker] settings ${e}:`,t)}function et(e,t,a){const[i,o]=l.useState(()=>ee()),r=t&&a&&te(),c=l.useCallback(async()=>{const u=!i;if(ne(u),o(u),!!u)try{await ae(()=>e())}catch(g){w("cloud sync",g)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:c,showLocalCloudSync:r}}function tt(e){const[t,a]=l.useState(!1),[i,o]=l.useState(!1),[r,c]=l.useState(!1),[u,g]=l.useState(!1),[h,m]=l.useState(null),[f,x]=l.useState(!1),[d,p]=l.useState(""),[N,S]=l.useState(!1),[F,C]=l.useState(""),[H,$]=l.useState(""),[B,z]=l.useState(!1),[V,K]=l.useState(null),W=l.useMemo(()=>Qe(e),[e]),Z=l.useMemo(()=>qe(e),[e]),Y=l.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),J=l.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:m,setGithubUrl:C,setProfileLoading:c,setPublicProfileOn:a,setShowGithubOn:S}),[]);return{anonymousOn:i,customDisplayName:h,displayName:W,editingGithub:B,editingName:f,email:Z,githubError:V,githubInput:H,githubUrl:F,loadSetters:J,nameInput:d,profileLoading:r,profileSaving:u,publicProfileOn:t,setAnonymousOn:o,setCustomDisplayName:m,setEditingGithub:z,setEditingName:x,setGithubError:K,setGithubInput:$,setGithubUrl:C,setNameInput:p,setProfileLoading:c,setProfileSaving:g,setPublicProfileOn:a,setShowGithubOn:S,showGithubOn:N,userId:Y}}function nt(e,t,a){l.useEffect(()=>{if(!t)return;let i=!0;return a.setProfileLoading(!0),(async()=>{try{const o=await O({getAccessToken:e});if(!i||!o)return;const r=await ie({accessToken:o});if(!i)return;a.setPublicProfileOn(!!r?.enabled),a.setAnonymousOn(!!r?.anonymous),r?.display_name&&a.setCustomDisplayName(r.display_name),a.setShowGithubOn(!!r?.show_github_url),a.setGithubUrl(r?.github_url||"")}catch(o){w("load public profile",o)}finally{i&&a.setProfileLoading(!1)}})(),()=>{i=!1}},[e,t,a])}function at(e,t){return l.useCallback(async(a,{label:i,onError:o,onSuccess:r}={})=>{if(t.profileSaving)return!1;t.setProfileSaving(!0);try{const c=await O({getAccessToken:e});if(!c)return!1;const u=await se({accessToken:c,...a});return r?.(u),!0}catch(c){return o?o(c):w(i||"mutate profile",c),!1}finally{t.setProfileSaving(!1)}},[e,t])}function it(e,t){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:t.handleAnonymousToggle,handleSaveName:t.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:t.startEditingName}}function st(e,t){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:t.handleSaveGithub,handleShowGithubToggle:t.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:t.startEditingGithub}}function ot(e,t){const a=l.useCallback(async()=>{const o=!e.publicProfileOn;await t({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[t,e]);return{handleAnonymousToggle:l.useCallback(async()=>{const o=!e.anonymousOn;await t({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[t,e]),handlePublicProfileToggle:a}}function rt(e,t,a){const i=l.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await t({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),a?.()}})},[t,e,a]),o=l.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function lt(e,t){const a=l.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await t({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[t,e]),i=l.useCallback(async()=>{const r=Xe(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(s("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await t({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:c=>e.setGithubError(c?.message||s("settings.account.githubUrlInvalid")),onSuccess:c=>{e.setGithubUrl(c?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[t,e]),o=l.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:a,startEditingGithub:o}}function ct(){const e=X(),t=tt(e.user),a=et(e.getAccessToken,e.enabled,e.signedIn);nt(e.getAccessToken,e.signedIn,t.loadSetters);const i=at(e.getAccessToken,t),o=ot(t,i),r=rt(t,i,e.refreshDisplayName),c=lt(t,i);return{...e,...a,email:t.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:t.userId,name:it(t,{...o,...r}),github:st(t,c),profileLoading:t.profileLoading,profileSaving:t.profileSaving,publicProfileOn:t.publicProfileOn}}function M({disabled:e,onCancel:t,onSave:a,saveLabel:i=s("settings.account.save")}){return n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:a,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}),n.jsx("button",{type:"button",onClick:t,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:s("settings.account.cancel")})]})}function ut({nameInput:e,setEditingName:t,setNameInput:a,profileSaving:i,handleSaveName:o}){return n.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[n.jsx("input",{type:"text",value:e,onChange:r=>a(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&t(!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:s("settings.account.displayName")}),n.jsx(M,{disabled:i||!e.trim(),onCancel:()=>t(!1),onSave:o,saveLabel:i?s("settings.account.saving"):void 0})]})}function dt({githubError:e,githubInput:t,handleSaveGithub:a,profileSaving:i,setEditingGithub:o,setGithubError:r,setGithubInput:c}){return n.jsxs("div",{className:"mt-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"text",value:t,onChange:u=>{c(u.target.value),e&&r(null)},onKeyDown:u=>{u.key==="Enter"&&a(),u.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:s("settings.account.githubUrlPlaceholder")}),n.jsx(M,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:a,saveLabel:i?s("settings.account.saving"):void 0})]}),e?n.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function U({disabled:e=!1,label:t,onClick:a,title:i}){return n.jsxs("button",{type:"button",onClick:a,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:[n.jsx(He,{className:"h-3.5 w-3.5","aria-hidden":!0}),t]})}function R({actions:e,editing:t,editor:a,hint:i,label:o}){return n.jsx("div",{className:"py-3",children:n.jsxs("div",{className:"flex items-start justify-between gap-4",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),t?a:n.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),t?null:e]})})}function gt({name:e}){const t=e.anonymousOn?s("settings.account.displayNameDisabledWhileAnon"):void 0;return n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(U,{disabled:e.anonymousOn,label:s("settings.account.edit"),onClick:e.startEditingName,title:t}),n.jsx(k,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:s("settings.account.displayName")})]})}function ht({name:e}){const{anonymousOn:t,customDisplayName:a,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:c,nameInput:u,profileLoading:g,profileSaving:h,setEditingName:m,setNameInput:f,startEditingName:x}=e,d=t?s("settings.account.displayNameAnonymousHint"):a||i;return n.jsx(R,{label:s("settings.account.displayName"),editing:o,hint:d,editor:n.jsx(ut,{nameInput:u,setEditingName:m,setNameInput:f,profileSaving:h,handleSaveName:c}),actions:n.jsx(gt,{name:e})})}function pt({github:e}){const{editingGithub:t,githubError:a,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:c,profileLoading:u,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:f,showGithubOn:x,startEditingGithub:d}=e;return n.jsx(R,{label:s("settings.account.githubUrl"),editing:t,hint:o||s("settings.account.githubUrlHint"),editor:n.jsx(dt,{githubError:a,githubInput:i,handleSaveGithub:r,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:f}),actions:n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(U,{label:s("settings.account.edit"),onClick:d}),n.jsx(k,{checked:x,onChange:c,disabled:u||g,ariaLabel:s("settings.account.githubUrl")})]})})}function mt(){const{openLoginModal:e}=oe();return n.jsx(j,{title:s("settings.section.account"),children:n.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[n.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("settings.account.signedOutHint")}),n.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:s("settings.account.signIn")})]})})}function bt({name:e,github:t}){return n.jsxs(n.Fragment,{children:[n.jsx(ht,{name:e}),n.jsx(pt,{github:t})]})}function ft(){const e=ct();return e.enabled?e.signedIn?n.jsxs(j,{title:s("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:n.jsx(yt,{onSignOut:e.signOut}),children:[n.jsx(xt,{userId:e.userId}),n.jsx(vt,{settings:e}),n.jsx(jt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),n.jsx(kt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):n.jsx(mt,{}):null}function xt({userId:e}){const[t,a]=re.useState(!1);if(!e)return null;const i=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),a(!0),globalThis.setTimeout(()=>a(!1),1200)}catch{a(!1)}};return n.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:s("settings.account.userId")}),n.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),n.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":s("settings.account.copyUserId"),children:[t?n.jsx(Ce,{className:"h-3.5 w-3.5","aria-hidden":!0}):n.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0}),t?s("settings.account.copied"):s("settings.account.copy")]})]})}function yt({onSignOut:e}){return n.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:[n.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.account.signOut")]})}function vt({settings:e}){return e.showLocalCloudSync?n.jsx(b,{label:s("settings.account.cloudSync"),hint:s("settings.account.cloudSyncHint"),control:n.jsx(k,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:s("settings.account.cloudSync")})}):null}function jt({checked:e,disabled:t,onChange:a}){return n.jsx(b,{label:s("settings.account.publicProfile"),hint:s("settings.account.publicProfileHint"),control:n.jsx(k,{checked:e,onChange:a,disabled:t,ariaLabel:s("settings.account.publicProfile")})})}function kt({visible:e,name:t,github:a}){return n.jsx(le,{initial:!1,children:e?n.jsx(A.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:n.jsx(bt,{name:t,github:a})},"public-profile-fields"):null})}function Nt(){return[{value:"light",label:s("settings.appearance.theme.light"),Icon:de},{value:"dark",label:s("settings.appearance.theme.dark"),Icon:ge},{value:"system",label:s("settings.appearance.theme.system"),Icon:he}]}function St(){return[{value:be,label:s("settings.appearance.language.system")},{value:fe,label:s("settings.appearance.language.english")},{value:xe,label:s("settings.appearance.language.chinese")},{value:ye,label:s("settings.appearance.language.traditional_chinese")},{value:ve,label:s("settings.appearance.language.japanese")},{value:je,label:s("settings.appearance.language.korean")}]}function wt(e){if(!e)return null;try{const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleString()}catch{return null}}function Ct(e,t){const a=s(`settings.appearance.currency.rate_source.${e}`),i=wt(t),o=i?s("settings.appearance.currency.rate_updated",{when:i}):s("settings.appearance.currency.rate_never");return`${a} · ${o}`}function Lt({locale:e,setLocale:t}){const a=St();return n.jsx(D,{value:e,onValueChange:t,options:a,ariaLabel:s("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:n.jsx(Me,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function Et({currency:e,setCurrency:t}){const a=pe().map(i=>({value:i.code,label:s(i.labelKey)}));return n.jsx(D,{value:e,onValueChange:t,options:a,ariaLabel:s("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function Gt({currency:e,rate:t,rateSource:a,rateFetchedAt:i}){if(e===me)return n.jsx(n.Fragment,{children:s("settings.appearance.currency.hint")});const o=Ct(a,i);return n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{children:`1 USD = ${t.toFixed(4)} ${e}`}),n.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:n.jsx(Ee,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function It(){const{theme:e,setTheme:t}=ce(),{locale:a,setLocale:i}=ue(),{currency:o,rate:r,rateSource:c,rateFetchedAt:u,setCurrency:g}=Le();return n.jsxs(j,{title:s("settings.section.appearance"),children:[n.jsx(b,{label:s("settings.appearance.theme.label"),hint:s("settings.appearance.theme.hint"),control:n.jsx(_,{options:Nt(),value:e,onChange:t})}),n.jsx(b,{label:s("settings.appearance.language.label"),hint:s("settings.appearance.language.hint"),control:n.jsx(Lt,{locale:a,setLocale:i})}),n.jsx(b,{label:s("settings.appearance.currency.label"),hint:n.jsx(Gt,{currency:o,rate:r,rateSource:c,rateFetchedAt:u}),control:n.jsx(Et,{currency:o,setCurrency:g})})]})}function At(){const{available:e,settings:t,setSetting:a,runAction:i}=P();if(!e)return null;const o=!!t?.launchAtLogin,r=t?.launchAtLoginSupported!==!1,c=t?.updateStatus||null,u=!!t?.updateBusy,g=!!t?.isSyncing;return n.jsxs(j,{title:s("settings.section.menubar"),children:[r?n.jsx(b,{label:s("settings.menubar.launchAtLogin"),hint:s("settings.menubar.launchAtLoginHint"),control:n.jsx(k,{checked:o,onChange:()=>a("launchAtLogin",!o),ariaLabel:s("settings.menubar.launchAtLogin")})}):null,n.jsx(b,{label:s("settings.menubar.syncNow"),hint:s("settings.menubar.syncNowHint"),control:n.jsxs("button",{type:"button",onClick:()=>i("syncNow"),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:[n.jsx(ke,{className:v("h-3.5 w-3.5",g&&"animate-spin"),"aria-hidden":!0}),g?s("settings.menubar.syncing"):s("settings.menubar.syncNow")]})}),n.jsx(b,{label:s("settings.menubar.updates"),hint:c||void 0,control:n.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:u,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:[n.jsx(Ge,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.menubar.checkUpdates")]})})]})}function Ot(){const{available:e,settings:t,runAction:a}=P(),i=e&&t?.version;return n.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-2 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[i?n.jsxs(n.Fragment,{children:[n.jsxs("span",{children:["TokenTrackerBar v",t.version]}),n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsx("button",{type:"button",onClick:()=>a("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),n.jsx("span",{"aria-hidden":!0,children:"·"})]}):null,n.jsxs("a",{href:Ne,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:[n.jsx(Ae,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.footer.statusPage")]})]})}function _t({prefs:e}){return n.jsx(_,{options:[{value:G.USED,label:s("limits.settings.display_mode_used")},{value:G.REMAINING,label:s("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function zt(){const e=we();return n.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:n.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:n.jsxs("div",{className:"mx-auto max-w-3xl px-4 sm:px-6",children:[n.jsxs("div",{className:"mb-8",children:[n.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:s("settings.page.title")}),n.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("settings.page.subtitle")})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsx(It,{}),n.jsx(At,{}),n.jsx(ft,{}),n.jsx(j,{title:s("settings.section.limits"),action:n.jsx(_t,{prefs:e}),children:n.jsx(Je,{prefs:e})})]}),n.jsx(Ot,{})]})})})}export{zt as SettingsPage};
|
|
1
|
+
import{c as y,r as l,ah as Q,ab as q,aD as L,j as n,m as A,N as v,A as s,Q as X,ao as ee,aE as te,as as ne,at as ae,au as O,aF as ie,aG as se,O as oe,R as re,K as le,M as ce,W as ue,aH as de,aI as ge,aJ as he,aK as pe,E as me,aL as be,aM as fe,aN as xe,aO as ye,aP as ve,aQ as je,aR as ke,a9 as Ne}from"./main-BZBATt4l.js";import{a as Se,b as E,u as we,L as G}from"./use-limits-display-prefs-C9k19eUo.js";import{S as j,T as k,a as b,b as _,u as P}from"./use-native-settings-HjLLYUkn.js";import{C as Ce}from"./useOpenInteractionType-B65bQ4-n.js";import{u as Le}from"./useCurrency-Cr1NSPgK.js";import{S as D}from"./Select-aIEVSJVR.js";import{I as Ee}from"./info-DD3Xh30V.js";import{D as Ge}from"./download-Ds1ViaQ9.js";import"./Card-eNDH0TxH.js";import"./SelectItemText-BH_vsFMS.js";const Ie=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ae=y("activity",Ie);const Oe=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],_e=y("copy",Oe);const Pe=[["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"}]],De=y("grip-vertical",Pe);const Te=[["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"}]],Me=y("languages",Te);const Ue=[["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"}]],Re=y("log-out",Ue);const Fe=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],He=y("pencil",Fe),$e=e=>!e.isLayoutDirty&&e.willUpdate(!1);function I(){const e=new Set,t=new WeakMap,a=()=>e.forEach($e);return{add:i=>{e.add(i),t.set(i,i.addEventListener("willUpdate",a))},remove:i=>{e.delete(i);const o=t.get(i);o&&(o(),t.delete(i)),a()},dirty:a}}const Be=l.createContext(null);function ze(){const e=l.useRef(!1);return Q(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function Ve(){const e=ze(),[t,a]=l.useState(0),i=l.useCallback(()=>{e.current&&a(t+1)},[t]);return[l.useCallback(()=>q.postRender(i),[i]),t]}const T=e=>e===!0,Ke=e=>T(e===!0)||e==="id",We=({children:e,id:t,inherit:a=!0})=>{const i=l.useContext(L),o=l.useContext(Be),[r,c]=Ve(),u=l.useRef(null),g=i.id||o;u.current===null&&(Ke(a)&&g&&(t=t?g+"-"+t:g),u.current={id:t,group:T(a)&&i.group||I()});const h=l.useMemo(()=>({...u.current,forceRender:r}),[c]);return n.jsx(L.Provider,{value:h,children:e})},Ze=new Set(["cursor","kiro","copilot","kimi"]);function Ye({checked:e,onChange:t,ariaLabel:a}){return n.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":a,onClick:t,className:v("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:n.jsx("span",{className:v("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function Je({prefs:e}){const{order:t,visibility:a,toggle:i,moveToward:o}=e,[r,c]=l.useState(null),[u,g]=l.useState(null),h=d=>p=>{c(d),p.dataTransfer.effectAllowed="move",p.dataTransfer.setData("text/plain",d)},m=d=>p=>{p.preventDefault(),p.dataTransfer.dropEffect="move",r&&r!==d&&u!==d&&(g(d),o(r,d))},f=()=>{c(null),g(null)},x=d=>{d.preventDefault(),c(null),g(null)};return n.jsx(We,{children:n.jsx("div",{className:"flex flex-col",children:t.map(d=>{const p=a[d]!==!1,N=r===d;return n.jsxs(A.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:h(d),onDragOver:m(d),onDragEnd:f,onDrop:x,className:v("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",N&&"opacity-40"),style:{cursor:N?"grabbing":"grab"},children:[n.jsx(De,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),n.jsx("img",{src:Se[d],alt:"",width:18,height:18,className:v("h-[18px] w-[18px] shrink-0 pointer-events-none",Ze.has(d)&&"dark:invert"),draggable:!1}),n.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:E[d]}),n.jsx("div",{onMouseDown:S=>S.stopPropagation(),draggable:!1,children:n.jsx(Ye,{checked:p,onChange:()=>i(d),ariaLabel:`${s("limits.settings.toggle_visible")}: ${E[d]}`})})]},d)})})})}function Qe(e){if(!e||typeof e!="object")return"";const t=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},a=e.profile&&typeof e.profile=="object"?e.profile:{},i=t.full_name||t.name||a.name||t.user_name||t.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 qe(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function Xe(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const a=t.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=t.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=a?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function w(e,t){console.warn(`[tokentracker] settings ${e}:`,t)}function et(e,t,a){const[i,o]=l.useState(()=>ee()),r=t&&a&&te(),c=l.useCallback(async()=>{const u=!i;if(ne(u),o(u),!!u)try{await ae(()=>e())}catch(g){w("cloud sync",g)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:c,showLocalCloudSync:r}}function tt(e){const[t,a]=l.useState(!1),[i,o]=l.useState(!1),[r,c]=l.useState(!1),[u,g]=l.useState(!1),[h,m]=l.useState(null),[f,x]=l.useState(!1),[d,p]=l.useState(""),[N,S]=l.useState(!1),[F,C]=l.useState(""),[H,$]=l.useState(""),[B,z]=l.useState(!1),[V,K]=l.useState(null),W=l.useMemo(()=>Qe(e),[e]),Z=l.useMemo(()=>qe(e),[e]),Y=l.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),J=l.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:m,setGithubUrl:C,setProfileLoading:c,setPublicProfileOn:a,setShowGithubOn:S}),[]);return{anonymousOn:i,customDisplayName:h,displayName:W,editingGithub:B,editingName:f,email:Z,githubError:V,githubInput:H,githubUrl:F,loadSetters:J,nameInput:d,profileLoading:r,profileSaving:u,publicProfileOn:t,setAnonymousOn:o,setCustomDisplayName:m,setEditingGithub:z,setEditingName:x,setGithubError:K,setGithubInput:$,setGithubUrl:C,setNameInput:p,setProfileLoading:c,setProfileSaving:g,setPublicProfileOn:a,setShowGithubOn:S,showGithubOn:N,userId:Y}}function nt(e,t,a){l.useEffect(()=>{if(!t)return;let i=!0;return a.setProfileLoading(!0),(async()=>{try{const o=await O({getAccessToken:e});if(!i||!o)return;const r=await ie({accessToken:o});if(!i)return;a.setPublicProfileOn(!!r?.enabled),a.setAnonymousOn(!!r?.anonymous),r?.display_name&&a.setCustomDisplayName(r.display_name),a.setShowGithubOn(!!r?.show_github_url),a.setGithubUrl(r?.github_url||"")}catch(o){w("load public profile",o)}finally{i&&a.setProfileLoading(!1)}})(),()=>{i=!1}},[e,t,a])}function at(e,t){return l.useCallback(async(a,{label:i,onError:o,onSuccess:r}={})=>{if(t.profileSaving)return!1;t.setProfileSaving(!0);try{const c=await O({getAccessToken:e});if(!c)return!1;const u=await se({accessToken:c,...a});return r?.(u),!0}catch(c){return o?o(c):w(i||"mutate profile",c),!1}finally{t.setProfileSaving(!1)}},[e,t])}function it(e,t){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:t.handleAnonymousToggle,handleSaveName:t.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:t.startEditingName}}function st(e,t){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:t.handleSaveGithub,handleShowGithubToggle:t.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:t.startEditingGithub}}function ot(e,t){const a=l.useCallback(async()=>{const o=!e.publicProfileOn;await t({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[t,e]);return{handleAnonymousToggle:l.useCallback(async()=>{const o=!e.anonymousOn;await t({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[t,e]),handlePublicProfileToggle:a}}function rt(e,t,a){const i=l.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await t({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),a?.()}})},[t,e,a]),o=l.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function lt(e,t){const a=l.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await t({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[t,e]),i=l.useCallback(async()=>{const r=Xe(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(s("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await t({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:c=>e.setGithubError(c?.message||s("settings.account.githubUrlInvalid")),onSuccess:c=>{e.setGithubUrl(c?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[t,e]),o=l.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:a,startEditingGithub:o}}function ct(){const e=X(),t=tt(e.user),a=et(e.getAccessToken,e.enabled,e.signedIn);nt(e.getAccessToken,e.signedIn,t.loadSetters);const i=at(e.getAccessToken,t),o=ot(t,i),r=rt(t,i,e.refreshDisplayName),c=lt(t,i);return{...e,...a,email:t.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:t.userId,name:it(t,{...o,...r}),github:st(t,c),profileLoading:t.profileLoading,profileSaving:t.profileSaving,publicProfileOn:t.publicProfileOn}}function M({disabled:e,onCancel:t,onSave:a,saveLabel:i=s("settings.account.save")}){return n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:a,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}),n.jsx("button",{type:"button",onClick:t,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:s("settings.account.cancel")})]})}function ut({nameInput:e,setEditingName:t,setNameInput:a,profileSaving:i,handleSaveName:o}){return n.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[n.jsx("input",{type:"text",value:e,onChange:r=>a(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&t(!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:s("settings.account.displayName")}),n.jsx(M,{disabled:i||!e.trim(),onCancel:()=>t(!1),onSave:o,saveLabel:i?s("settings.account.saving"):void 0})]})}function dt({githubError:e,githubInput:t,handleSaveGithub:a,profileSaving:i,setEditingGithub:o,setGithubError:r,setGithubInput:c}){return n.jsxs("div",{className:"mt-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"text",value:t,onChange:u=>{c(u.target.value),e&&r(null)},onKeyDown:u=>{u.key==="Enter"&&a(),u.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:s("settings.account.githubUrlPlaceholder")}),n.jsx(M,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:a,saveLabel:i?s("settings.account.saving"):void 0})]}),e?n.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function U({disabled:e=!1,label:t,onClick:a,title:i}){return n.jsxs("button",{type:"button",onClick:a,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:[n.jsx(He,{className:"h-3.5 w-3.5","aria-hidden":!0}),t]})}function R({actions:e,editing:t,editor:a,hint:i,label:o}){return n.jsx("div",{className:"py-3",children:n.jsxs("div",{className:"flex items-start justify-between gap-4",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),t?a:n.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),t?null:e]})})}function gt({name:e}){const t=e.anonymousOn?s("settings.account.displayNameDisabledWhileAnon"):void 0;return n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(U,{disabled:e.anonymousOn,label:s("settings.account.edit"),onClick:e.startEditingName,title:t}),n.jsx(k,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:s("settings.account.displayName")})]})}function ht({name:e}){const{anonymousOn:t,customDisplayName:a,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:c,nameInput:u,profileLoading:g,profileSaving:h,setEditingName:m,setNameInput:f,startEditingName:x}=e,d=t?s("settings.account.displayNameAnonymousHint"):a||i;return n.jsx(R,{label:s("settings.account.displayName"),editing:o,hint:d,editor:n.jsx(ut,{nameInput:u,setEditingName:m,setNameInput:f,profileSaving:h,handleSaveName:c}),actions:n.jsx(gt,{name:e})})}function pt({github:e}){const{editingGithub:t,githubError:a,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:c,profileLoading:u,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:f,showGithubOn:x,startEditingGithub:d}=e;return n.jsx(R,{label:s("settings.account.githubUrl"),editing:t,hint:o||s("settings.account.githubUrlHint"),editor:n.jsx(dt,{githubError:a,githubInput:i,handleSaveGithub:r,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:f}),actions:n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(U,{label:s("settings.account.edit"),onClick:d}),n.jsx(k,{checked:x,onChange:c,disabled:u||g,ariaLabel:s("settings.account.githubUrl")})]})})}function mt(){const{openLoginModal:e}=oe();return n.jsx(j,{title:s("settings.section.account"),children:n.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[n.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("settings.account.signedOutHint")}),n.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:s("settings.account.signIn")})]})})}function bt({name:e,github:t}){return n.jsxs(n.Fragment,{children:[n.jsx(ht,{name:e}),n.jsx(pt,{github:t})]})}function ft(){const e=ct();return e.enabled?e.signedIn?n.jsxs(j,{title:s("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:n.jsx(yt,{onSignOut:e.signOut}),children:[n.jsx(xt,{userId:e.userId}),n.jsx(vt,{settings:e}),n.jsx(jt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),n.jsx(kt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):n.jsx(mt,{}):null}function xt({userId:e}){const[t,a]=re.useState(!1);if(!e)return null;const i=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),a(!0),globalThis.setTimeout(()=>a(!1),1200)}catch{a(!1)}};return n.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:s("settings.account.userId")}),n.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),n.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":s("settings.account.copyUserId"),children:[t?n.jsx(Ce,{className:"h-3.5 w-3.5","aria-hidden":!0}):n.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0}),t?s("settings.account.copied"):s("settings.account.copy")]})]})}function yt({onSignOut:e}){return n.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:[n.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.account.signOut")]})}function vt({settings:e}){return e.showLocalCloudSync?n.jsx(b,{label:s("settings.account.cloudSync"),hint:s("settings.account.cloudSyncHint"),control:n.jsx(k,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:s("settings.account.cloudSync")})}):null}function jt({checked:e,disabled:t,onChange:a}){return n.jsx(b,{label:s("settings.account.publicProfile"),hint:s("settings.account.publicProfileHint"),control:n.jsx(k,{checked:e,onChange:a,disabled:t,ariaLabel:s("settings.account.publicProfile")})})}function kt({visible:e,name:t,github:a}){return n.jsx(le,{initial:!1,children:e?n.jsx(A.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:n.jsx(bt,{name:t,github:a})},"public-profile-fields"):null})}function Nt(){return[{value:"light",label:s("settings.appearance.theme.light"),Icon:de},{value:"dark",label:s("settings.appearance.theme.dark"),Icon:ge},{value:"system",label:s("settings.appearance.theme.system"),Icon:he}]}function St(){return[{value:be,label:s("settings.appearance.language.system")},{value:fe,label:s("settings.appearance.language.english")},{value:xe,label:s("settings.appearance.language.chinese")},{value:ye,label:s("settings.appearance.language.traditional_chinese")},{value:ve,label:s("settings.appearance.language.japanese")},{value:je,label:s("settings.appearance.language.korean")}]}function wt(e){if(!e)return null;try{const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleString()}catch{return null}}function Ct(e,t){const a=s(`settings.appearance.currency.rate_source.${e}`),i=wt(t),o=i?s("settings.appearance.currency.rate_updated",{when:i}):s("settings.appearance.currency.rate_never");return`${a} · ${o}`}function Lt({locale:e,setLocale:t}){const a=St();return n.jsx(D,{value:e,onValueChange:t,options:a,ariaLabel:s("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:n.jsx(Me,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function Et({currency:e,setCurrency:t}){const a=pe().map(i=>({value:i.code,label:s(i.labelKey)}));return n.jsx(D,{value:e,onValueChange:t,options:a,ariaLabel:s("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function Gt({currency:e,rate:t,rateSource:a,rateFetchedAt:i}){if(e===me)return n.jsx(n.Fragment,{children:s("settings.appearance.currency.hint")});const o=Ct(a,i);return n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{children:`1 USD = ${t.toFixed(4)} ${e}`}),n.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:n.jsx(Ee,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function It(){const{theme:e,setTheme:t}=ce(),{locale:a,setLocale:i}=ue(),{currency:o,rate:r,rateSource:c,rateFetchedAt:u,setCurrency:g}=Le();return n.jsxs(j,{title:s("settings.section.appearance"),children:[n.jsx(b,{label:s("settings.appearance.theme.label"),hint:s("settings.appearance.theme.hint"),control:n.jsx(_,{options:Nt(),value:e,onChange:t})}),n.jsx(b,{label:s("settings.appearance.language.label"),hint:s("settings.appearance.language.hint"),control:n.jsx(Lt,{locale:a,setLocale:i})}),n.jsx(b,{label:s("settings.appearance.currency.label"),hint:n.jsx(Gt,{currency:o,rate:r,rateSource:c,rateFetchedAt:u}),control:n.jsx(Et,{currency:o,setCurrency:g})})]})}function At(){const{available:e,settings:t,setSetting:a,runAction:i}=P();if(!e)return null;const o=!!t?.launchAtLogin,r=t?.launchAtLoginSupported!==!1,c=t?.updateStatus||null,u=!!t?.updateBusy,g=!!t?.isSyncing;return n.jsxs(j,{title:s("settings.section.menubar"),children:[r?n.jsx(b,{label:s("settings.menubar.launchAtLogin"),hint:s("settings.menubar.launchAtLoginHint"),control:n.jsx(k,{checked:o,onChange:()=>a("launchAtLogin",!o),ariaLabel:s("settings.menubar.launchAtLogin")})}):null,n.jsx(b,{label:s("settings.menubar.syncNow"),hint:s("settings.menubar.syncNowHint"),control:n.jsxs("button",{type:"button",onClick:()=>i("syncNow"),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:[n.jsx(ke,{className:v("h-3.5 w-3.5",g&&"animate-spin"),"aria-hidden":!0}),g?s("settings.menubar.syncing"):s("settings.menubar.syncNow")]})}),n.jsx(b,{label:s("settings.menubar.updates"),hint:c||void 0,control:n.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:u,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:[n.jsx(Ge,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.menubar.checkUpdates")]})})]})}function Ot(){const{available:e,settings:t,runAction:a}=P(),i=e&&t?.version;return n.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-2 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[i?n.jsxs(n.Fragment,{children:[n.jsxs("span",{children:["TokenTrackerBar v",t.version]}),n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsx("button",{type:"button",onClick:()=>a("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),n.jsx("span",{"aria-hidden":!0,children:"·"})]}):null,n.jsxs("a",{href:Ne,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:[n.jsx(Ae,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.footer.statusPage")]})]})}function _t({prefs:e}){return n.jsx(_,{options:[{value:G.USED,label:s("limits.settings.display_mode_used")},{value:G.REMAINING,label:s("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function zt(){const e=we();return n.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:n.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:n.jsxs("div",{className:"mx-auto max-w-3xl px-4 sm:px-6",children:[n.jsxs("div",{className:"mb-8",children:[n.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:s("settings.page.title")}),n.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("settings.page.subtitle")})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsx(It,{}),n.jsx(At,{}),n.jsx(ft,{}),n.jsx(j,{title:s("settings.section.limits"),action:n.jsx(_t,{prefs:e}),children:n.jsx(Je,{prefs:e})})]}),n.jsx(Ot,{})]})})})}export{zt as SettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as Le,r as n,a as We,j as e,F as U,N as X,X as Me,A as r,aW as fa,aX as Ya,u as Ja,aY as oa,aZ as Za,a_ as et,a$ as at,b0 as tt,b1 as rt,b2 as st,b as it,b3 as nt,b4 as ot,b5 as lt,K as dt,e as ct,m as la,a6 as ut,C as gt,P as xe,b6 as mt,b7 as xt,b8 as ht,b9 as pt,ba as yt,bb as ft,i as bt,aR as kt,bc as da,R as wt,bd as jt,be as ca,bf as fe,bg as ua,bh as ga,bi as vt,bj as ma,bk as xa,bl as Nt,bm as Ct}from"./main-BpChBpB7.js";import{L as St}from"./LocalOnlyNotice-D0XXnH8l.js";import{C as _t}from"./Card-DnFsEPmk.js";import{u as Rt,D as Pt,a as $t,b as It,c as Lt,d as Mt,e as Et}from"./DialogTitle-C7CwLbYz.js";import{u as ta,a as Bt,t as Tt,b as Dt,C as be}from"./useOpenInteractionType-2Q4xhr62.js";import{I as ba}from"./info-DnI8z26t.js";import{u as Ot}from"./useCurrency-B1Aa7Unc.js";import{L as Q,P as ka,a as wa,b as ja,c as va,d as Na,C as Ut}from"./PopoverPopup-BJb6Du8x.js";import{u as zt,s as Ft,f as Ca,a as Vt,b as At,c as Kt,d as qt,e as Gt,g as Ht,S as Sa,h as _a,i as Ra,C as ia,j as Pa,k as $a,l as Ia,m as qe,n as Ge,o as He}from"./SelectItemText-DmE9ZyEL.js";import{D as La}from"./download-C1zysMDD.js";import"./arrow-up-right-CnvG5D97.js";const Wt=[["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"}]],Ma=Le("circle-arrow-up",Wt);const Xt=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ra=Le("external-link",Xt);const Qt=[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]],Yt=Le("flame",Qt);const Jt=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ea=Le("plus",Jt);const Zt=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],na=Le("trash-2",Zt),er=n.forwardRef(function(i,o){const{render:m,className:g,id:h,...c}=i,{store:u}=Rt(),x=ta(h);return u.useSyncedValueWithCleanup("descriptionElementId",x),We("p",i,{ref:o,props:[{id:x},c]})});function ha({open:t,title:i,description:o,confirmLabel:m,cancelLabel:g,destructive:h=!1,busy:c=!1,onConfirm:u,onCancel:x}){return e.jsx(Pt,{open:t,onOpenChange:j=>{!j&&!c&&x?.()},children:e.jsxs($t,{children:[e.jsx(It,{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),e.jsx(Lt,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:e.jsxs(Mt,{className:"relative w-full max-w-md rounded-2xl bg-white p-6 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] ring-1 ring-oai-gray-200 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.96] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0 dark:bg-oai-gray-950 dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] dark:ring-oai-gray-800",children:[e.jsx(Et,{className:"text-base font-semibold text-oai-black dark:text-white",children:i}),o?e.jsx(er,{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:o}):null,e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx(U,{type:"button",variant:"secondary",size:"sm",disabled:c,onClick:()=>x?.(),children:g}),e.jsx(U,{type:"button",size:"sm",disabled:c,onClick:()=>u?.(),className:X(h&&"!bg-red-600 hover:!bg-red-700 focus-visible:!outline-red-600 dark:!bg-red-600 dark:hover:!bg-red-500"),children:m})]})]})})]})})}function Ba({id:t,value:i,onChange:o,placeholder:m,disabled:g=!1,type:h="text",label:c,error:u,className:x="",...j}){const l=n.useId(),k=t||l,y=u?`${k}-error`:void 0,w=`w-full bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md text-oai-black dark:text-oai-white placeholder-oai-gray-400 dark:placeholder-oai-gray-500 transition-all duration-200 focus:outline-none focus:border-oai-brand dark:focus:border-oai-brand focus:ring-1 focus:ring-oai-brand/30 ${g?"bg-oai-gray-50 dark:bg-oai-gray-800 text-oai-gray-400 dark:text-oai-gray-400 cursor-not-allowed":""} ${u?"border-oai-error focus:border-oai-error focus:ring-oai-error/30":""} h-10 px-3 text-sm ${x}`;return e.jsxs("div",{className:"w-full",children:[c&&e.jsx("label",{htmlFor:k,className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5 transition-colors duration-200",children:c}),e.jsx("input",{id:k,type:h,value:i,onChange:o,placeholder:m,disabled:g,"aria-invalid":u?!0:void 0,"aria-describedby":y,className:w,...j}),u&&e.jsx("p",{id:y,className:"mt-1.5 text-sm text-oai-error",children:u})]})}const Ta=n.forwardRef(function(i,o){const{className:m,render:g,...h}=i,{store:c}=zt(),u=Bt(c,Ft.open),x=n.useMemo(()=>({open:u}),[u]);return We("span",i,{state:x,ref:o,props:[{"aria-hidden":!0,children:"▼"},h],stateAttributesMapping:Tt})}),ar="tt:hint:dismissed:";function Da(t){return ar+t}function tr(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Da(t))==="1"}catch{return!1}}function rr({id:t,children:i,className:o,ariaLabel:m}){const[g,h]=n.useState(()=>tr(t)),c=n.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(Da(t),"1")}catch{}h(!0)},[t]);return g?null:e.jsxs("div",{role:"note","aria-label":m||r("hint.dismissible_aria"),className:X("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",o),children:[e.jsx("button",{type:"button",onClick:c,"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(Me,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(ba,{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:i})]})]})}let pa=(function(t){return t.checked="data-checked",t.unchecked="data-unchecked",t.indeterminate="data-indeterminate",t.disabled="data-disabled",t.readonly="data-readonly",t.required="data-required",t.valid="data-valid",t.invalid="data-invalid",t.touched="data-touched",t.dirty="data-dirty",t.filled="data-filled",t.focused="data-focused",t})({});function Oa(t){return n.useMemo(()=>({checked(i){return t.indeterminate?{}:i?{[pa.checked]:""}:{[pa.unchecked]:""}},...Ca}),[t.indeterminate])}const sr=n.createContext({disabled:!1});function ir(){return n.useContext(sr)}const nr=n.createContext(void 0);function or(t=!0){const i=n.useContext(nr);if(i===void 0&&!t)throw new Error(fa(3));return i}const Ua=n.createContext(void 0);function lr(){const t=n.useContext(Ua);if(t===void 0)throw new Error(fa(14));return t}const dr="data-parent",cr=n.forwardRef(function(i,o){const{checked:m,className:g,defaultChecked:h=!1,disabled:c=!1,id:u,indeterminate:x=!1,inputRef:j,name:l,onCheckedChange:k,parent:y=!1,readOnly:b=!1,render:P,required:f=!1,uncheckedValue:w,value:B,nativeButton:T=!1,...I}=i,{clearErrors:q}=Vt(),{disabled:he,name:C,setDirty:z,setFilled:v,setFocused:M,setTouched:ie,state:ke,validationMode:we,validityData:Ee,shouldValidateOnChange:Be,validation:D}=At(),Y=ir(),{labelId:je,controlId:ve,setControlId:ae,getDescriptionProps:te}=Kt(),N=or(),J=N?.parent,ne=J&&N.allValues,A=he||Y.disabled||N?.disabled||c,G=C??l,S=B??G,Te=ta(),Ne=ta();let Z=ve;ne?Z=y?Ne:`${J.id}-${S}`:u&&(Z=u);let oe={};ne&&(y?oe=N.parent.getParentProps():S&&(oe=N.parent.getChildProps(S)));const Ce=Ya(k),{checked:le=m,indeterminate:ee=x,onCheckedChange:re,...pe}=oe,F=N?.value,de=N?.setValue,ce=N?.defaultValue,Se=n.useRef(null),{getButtonProps:De,buttonRef:Oe}=Ja({disabled:A,native:T}),R=N?.validation??D,[$,Xe]=qt({controlled:S&&F&&!y?F.includes(S):le,default:S&&ce&&!y?ce.includes(S):h,name:"Checkbox",state:"checked"});oa(()=>{if(ae!==Za)return ae(Z),()=>{ae(void 0)}},[Z,N,ae,y]),Gt({enabled:!N,id:Te,commit:R.commit,value:$,controlRef:Se,name:G,getValue:()=>$});const ue=n.useRef(null),Ue=et(j,ue,R.inputRef);oa(()=>{ue.current&&(ue.current.indeterminate=ee,$&&v(!0))},[$,ee,v]),Ht($,()=>{N&&!y||(q(G),v($),z($!==Ee.initialValue),Be()?R.commit($):R.commit($,!0))});const _e=at({checked:$,disabled:A,name:y?void 0:G,id:T?void 0:Z??void 0,required:f,ref:Ue,style:G?rt:st,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(H){if(H.nativeEvent.defaultPrevented)return;const ge=H.target.checked,ye=it(nt,H.nativeEvent);if(re?.(ge,ye),Ce(ge,ye),!ye.isCanceled&&(Xe(ge),S&&F&&de&&!y)){const Je=ge?[...F,S]:F.filter(K=>K!==S);de(Je,ye)}},onFocus(){Se.current?.focus()}},B!==void 0?{value:(N?$&&B:B)||""}:tt,te,N?R.getValidationProps:R.getInputValidationProps),ze=ne?!!le:$,Re=ne&&ee||x;n.useEffect(()=>{J&&S&&J.disabledStatesRef.current.set(S,A)},[J,A,S]);const Pe=n.useMemo(()=>({...ke,checked:ze,disabled:A,readOnly:b,required:f,indeterminate:Re}),[ke,ze,A,b,f,Re]),Qe=Oa(Pe),Ye=We("span",i,{state:Pe,ref:[Oe,Se,o,N?.registerControlRef],props:[{id:T?Z??void 0:Te,role:"checkbox","aria-checked":ee?"mixed":$,"aria-readonly":b||void 0,"aria-required":f||void 0,"aria-labelledby":je,[dr]:y?"":void 0,onFocus(){M(!0)},onBlur(){const H=ue.current;H&&(ie(!0),M(!1),we==="onBlur"&&R.commit(N?F:H.checked))},onClick(H){b||A||(H.preventDefault(),ue.current?.click())}},te,R.getValidationProps,I,pe,De],stateAttributesMapping:Qe});return e.jsxs(Ua.Provider,{value:Pe,children:[Ye,!$&&!N&&G&&!y&&w!==void 0&&e.jsx("input",{type:"hidden",name:G,value:w}),e.jsx("input",{..._e})]})}),ur=n.forwardRef(function(i,o){const{render:m,className:g,keepMounted:h=!1,...c}=i,u=lr(),x=u.checked||u.indeterminate,{transitionStatus:j,setMounted:l}=Dt(x),k=n.useRef(null),y=n.useMemo(()=>({...u,transitionStatus:j}),[u,j]);ot({open:x,ref:k,onComplete(){x||l(!1)}});const b=Oa(u),P=n.useMemo(()=>({...b,...lt,...Ca}),[b]),f=h||x,w=We("span",i,{enabled:f,ref:[o,k],state:y,stateAttributesMapping:P,props:c});return f?w:null});function gr(t,i){return`target:${t}:${i}`}function mr(t){return`remove:${t.id||t.directory}`}function za(t){if(!t)return null;const i=new Date(t).getTime();return Number.isFinite(i)?Math.floor((Date.now()-i)/864e5):null}function xr(t){const i=za(t);if(i==null)return null;if(i<=0)return r("skills.usage.today");if(i<30)return r("skills.usage.days_ago",{days:i});const o=Math.max(1,Math.floor(i/30));return r("skills.usage.months_ago",{months:o})}function hr(t){const i=za(t);return i==null?"bg-oai-gray-300 dark:bg-oai-gray-600":i<=7?"bg-emerald-500":i<=30?"bg-amber-500":"bg-oai-gray-300 dark:bg-oai-gray-600"}function ea({label:t,children:i}){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:t}),e.jsx("dd",{className:"text-right font-medium tabular-nums text-oai-black dark:text-white",children:i})]})}function pr({skill:t,targets:i,busyKey:o,usage:m,hasUpdate:g,updating:h,onUpdate:c,onClose:u,onToggleTarget:x,onRemove:j}){return e.jsx(dt,{children:t?e.jsx(yr,{skill:t,targets:i,busyKey:o,usage:m,hasUpdate:g,updating:h,onUpdate:c,onClose:u,onToggleTarget:x,onRemove:j},t.id||t.directory):null})}function yr({skill:t,targets:i,busyKey:o,usage:m,hasUpdate:g,updating:h,onUpdate:c,onClose:u,onToggleTarget:x,onRemove:j}){const l=ct(),{currency:k,rate:y}=Ot(),b=n.useRef(null);n.useEffect(()=>{const C=v=>{v.key==="Escape"&&(v.stopPropagation(),u?.())},z=v=>{const M=v.target;M instanceof Element&&(b.current?.contains(M)||M.closest('[data-skill-row="1"]')||u?.())};return document.addEventListener("keydown",C),document.addEventListener("mousedown",z),()=>{document.removeEventListener("keydown",C),document.removeEventListener("mousedown",z)}},[u]);const P=t.name||t.directory,f=!!(t.repoOwner&&t.repoName),w=f?`https://github.com/${t.repoOwner}/${t.repoName}`:null,B=new Set(t.targets||[]),T=o===mr(t),I=xr(m?.lastUsedAt),q=!!(m&&m.invocations>0),he=l?{duration:0}:{type:"spring",stiffness:320,damping:30,mass:.7};return e.jsxs(e.Fragment,{children:[e.jsx(la.div,{className:"fixed inset-0 z-20 bg-oai-black/30 backdrop-blur-[2px] lg:hidden",initial:l?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:l?0:.15},onClick:u,"aria-hidden":!0}),e.jsxs(la.aside,{ref:b,role:"complementary","aria-label":P,initial:l?!1:{opacity:0,x:24,scale:.98},animate:{opacity:1,x:0,scale:1},exit:l?{opacity:0}:{opacity:0,x:24,scale:.98},transition:he,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:P,children:P}),f?e.jsxs("a",{href:w,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:w,children:[e.jsxs("span",{className:"truncate",children:[t.repoOwner,"/",t.repoName]}),e.jsx(ra,{className:"h-3 w-3 shrink-0","aria-hidden":!0})]}):t.directory&&t.directory!==P?e.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",title:t.directory,children:t.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(Me,{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:[g?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(Ma,{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:()=>c?.(t),disabled:h,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(Q,{className:"h-3 w-3 animate-spin","aria-hidden":!0}):null,r("skills.update.action")]})]}):null,t.description?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:t.description}):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.usage.section_title")}),e.jsxs("dl",{className:"divide-y divide-oai-gray-200/60 dark:divide-white/[0.06]",children:[e.jsx(ea,{label:r("skills.usage.invocations"),children:ut(m?.invocations||0)}),e.jsx(ea,{label:r("skills.usage.last_used"),children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:X("h-1.5 w-1.5 rounded-full",hr(m?.lastUsedAt)),"aria-hidden":!0}),q?I||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(ea,{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(ba,{className:"h-3 w-3","aria-label":r("skills.usage.disclaimer")})})]}),children:gt(m?.cost||0,{currency:k,rate:y})})]}),q?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")})]}),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:(i||[]).map(C=>{const z=B.has(C.id),v=o===gr(t.id,C.id),M=`skill-detail-sync-${t.id||t.directory}-${C.id}`;return e.jsxs("label",{htmlFor:M,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(cr,{id:M,checked:z,disabled:v,onCheckedChange:ie=>x?.(t,C.id,!!ie),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(ur,{className:"flex items-center justify-center text-white dark:text-oai-black",children:e.jsx(be,{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(xe,{provider:C.id,size:16})}),e.jsx("span",{className:"flex-1",children:C.label}),v?e.jsx(Q,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},C.id)})})]})]}),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:()=>j?.(t),disabled:T,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:[T?e.jsx(Q,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(na,{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"),aa=["claude","codex"],O="popular",br={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"},se="all",E="skillssh";function sa(t){return`${t.repoOwner||"local"}/${t.repoName||"local"}:${t.directory}`}function Ke(t){return`install:${sa(t)}`}function ya(t){return`remove:${t.id||t.directory}`}function Fa(t,i){return`target:${t}:${i}`}function kr({target:t,state:i,busy:o,onToggle:m}){const g=i==="synced",h=i==="orphan",c=h?r("skills.dot.orphan_aria",{agent:t.label}):g?r("skills.dot.synced_aria",{agent:t.label}):r("skills.dot.off_aria",{agent:t.label});return e.jsxs("button",{type:"button",title:c,"aria-label":c,"aria-pressed":g,disabled:o,onClick:u=>{u.stopPropagation(),m?.(t.id,!g)},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:[o?e.jsx(Q,{className:"h-4 w-4 animate-spin text-oai-gray-400","aria-hidden":!0}):e.jsx("span",{className:X("flex h-[18px] w-[18px] items-center justify-center transition",g&&br[t.id],!g&&!h&&"opacity-35 grayscale"),"aria-hidden":!0,children:e.jsx(xe,{provider:t.id,size:18})}),h&&!o?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 wr({skill:t,targets:i,onToggleTarget:o,busyKey:m}){return e.jsx("div",{className:"flex items-center gap-1",onClick:g=>g.stopPropagation(),children:i.map(g=>e.jsx(kr,{target:g,state:t.targetStates?.[g.id]||"off",busy:m===Fa(t.id,g.id),onToggle:(h,c)=>o?.(t,h,c)},g.id))})}function jr({skill:t,targets:i,selected:o,onSelect:m,selectable:g,checked:h,onToggleSelect:c,onToggleTarget:u,hasUpdate:x,busyKey:j}){const l=t.repoOwner&&t.repoName?`${t.repoOwner}/${t.repoName}`:null,k=l?`${t.directory} · ${l}`:t.directory,y=b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),m?.(t))};return e.jsxs("div",{"data-skill-row":"1",role:"button",tabIndex:0,"aria-pressed":o,"aria-label":r("skills.row.open_details",{name:t.name||t.directory}),onClick:()=>m?.(t),onKeyDown:y,className:X("cursor-pointer rounded-md py-3 pr-2 transition focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30",o?"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:[g?e.jsx("label",{className:"flex shrink-0 items-center",onClick:b=>b.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:h,onChange:b=>c?.(t,b.target.checked),"aria-label":r("skills.select.row_aria",{name:t.name||t.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:k,children:t.name||t.directory}),x?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(Ma,{className:"h-2.5 w-2.5","aria-hidden":!0}),r("skills.update.badge")]}):null,e.jsx(wr,{skill:t,targets:i,onToggleTarget:u,busyKey:j}),e.jsx(Ut,{className:X("hidden h-4 w-4 shrink-0 text-oai-gray-300 transition-colors dark:text-oai-gray-600 lg:block",o&&"text-oai-gray-500 dark:text-oai-gray-300"),"aria-hidden":!0})]}),t.description?e.jsx("p",{className:X("mt-1 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",g&&"pl-7"),children:t.description}):null]})}function vr({agentFilter:t,agentOptions:i,onAgentFilter:o,filteredCount:m,totalCount:g,anyFilter:h,onClearFilters:c}){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(Sa,{value:t,onValueChange:o,children:[e.jsxs(_a,{"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(Ra,{children:u=>u==="all"?r("skills.filter.agent_all"):i.find(x=>x.id===u)?.label||u}),e.jsx(Ta,{className:"text-oai-gray-400",children:e.jsx(ia,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Pa,{children:e.jsx($a,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ia,{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(qe,{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(Ge,{children:r("skills.filter.agent_all")}),e.jsx(He,{children:e.jsx(be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),i.map(u=>e.jsxs(qe,{value:u.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(xe,{provider:u.id,size:14}),e.jsx(Ge,{children:u.label})]}),e.jsx(He,{children:e.jsx(be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},u.id))]})})})]}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.filter.result_count",{filtered:m,total:g})}),h?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(Me,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]})}function Nr({count:t,targets:i,busy:o,onBulkSync:m,onBulkRemove:g,onClear:h}){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:t})}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs(ka,{children:[e.jsxs(wa,{disabled:o,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(La,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_sync"),e.jsx(ia,{className:"h-3 w-3","aria-hidden":!0})]}),e.jsx(ja,{children:e.jsx(va,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(Na,{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")}),i.map(c=>e.jsxs("button",{type:"button",onClick:()=>m(c.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(xe,{provider:c.id,size:16}),e.jsx("span",{className:"flex-1",children:c.label})]},c.id))]})})})]}),e.jsxs(U,{type:"button",variant:"ghost",size:"sm",disabled:o,onClick:g,children:[e.jsx(na,{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(Me,{className:"h-3 w-3","aria-hidden":!0}),r("skills.select.clear")]})]})]})}function Cr({items:t,totalCount:i,targets:o,agentOptions:m,agentFilter:g,onAgentFilter:h,anyFilter:c,onClearFilters:u,selectedId:x,onSelect:j,onToggleTarget:l,busyKey:k,updates:y,selectedIds:b,onToggleSelect:P,onClearSelection:f,onBulkSync:w,onBulkRemove:B}){const T=b.size;return e.jsxs("div",{children:[T>0?e.jsx(Nr,{count:T,targets:o,busy:k==="batch",onBulkSync:w,onBulkRemove:B,onClear:f}):e.jsx(vr,{agentFilter:g,agentOptions:m,onAgentFilter:h,filteredCount:t.length,totalCount:i,anyFilter:c,onClearFilters:u}),t.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(U,{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:t.map(I=>e.jsx(jr,{skill:I,targets:o,selected:x===(I.id||I.directory),onSelect:j,selectable:!0,checked:b.has(I.id),onToggleSelect:P,onToggleTarget:l,hasUpdate:!!(I.id&&y?.[I.id]),busyKey:k},I.id||I.key))})]})}const Sr={contentVisibility:"auto",containIntrinsicSize:"0 240px"},_r=wt.memo(function({skill:i,installed:o,installing:m,allTargets:g,defaultTargets:h,onInstall:c,onManage:u}){const[x,j]=n.useState(()=>(h||[]).filter(f=>g.some(w=>w.id===f))),l=f=>{j(w=>w.includes(f)?w.filter(B=>B!==f):[...w,f])},k=i.repoOwner&&i.repoName?`${i.repoOwner}/${i.repoName}`:null,y=k?`https://github.com/${i.repoOwner}/${i.repoName}`:null,b=i.installs!=null?r("skills.card.installs",{count:Number(i.installs||0).toLocaleString()}):null,P=x.length?x.map(f=>g.find(w=>w.id===f)?.label||f).join(", "):r("skills.action.choose_targets");return e.jsxs(_t,{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:[i.readmeUrl?e.jsxs("a",{href:i.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:i.readmeUrl,children:[e.jsx("span",{className:"truncate",children:i.name||i.directory}),e.jsx(ra,{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:i.name||i.directory}),k||b?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:[y?e.jsxs("a",{href:y,target:"_blank",rel:"noopener noreferrer",onClick:f=>f.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:y,children:[e.jsx("span",{className:"truncate",children:k}),e.jsx(ra,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,k&&b?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,b?e.jsx("span",{className:"truncate",children:b}):null]}):null]})}),i.description?e.jsx("p",{className:"mt-3 line-clamp-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:i.description}):null,e.jsx("div",{className:"mt-auto pt-5",children:o?e.jsxs(U,{type:"button",variant:"secondary",size:"sm",onClick:()=>u?.(i),className:"w-full",children:[e.jsx(be,{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:x.length?P:r("skills.target.none")}),e.jsxs(ka,{children:[e.jsx(wa,{disabled:m,"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(ja,{children:e.jsx(va,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(Na,{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")}),g.map(f=>{const w=x.includes(f.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:w,onChange:()=>l(f.id)}),e.jsx(xe,{provider:f.id,size:16}),e.jsx("span",{className:"flex-1 text-left",children:f.label})]},f.id)})]})})})]})]}),e.jsxs(U,{type:"button",size:"sm",onClick:()=>c(i,x),disabled:m||x.length===0,className:"w-full",children:[m?e.jsx(Q,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(La,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.action.install")]})]})})]})});function Rr({repos:t,repoInput:i,onRepoInput:o,busyKey:m,onAdd:g,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(Ba,{value:i,onChange:c=>o(c.target.value),placeholder:r("skills.repo.placeholder"),className:"min-w-0 flex-1"}),e.jsxs(U,{type:"button",variant:"secondary",size:"md",onClick:g,disabled:m==="repo:add",className:"shrink-0 whitespace-nowrap",children:[m==="repo:add"?e.jsx(Q,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(Ea,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.repo.add")]})]}),t.length?e.jsx("div",{className:"mt-3 divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:t.map(c=>{const u=m===`repo:${c.owner}/${c.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:[c.owner,"/",c.name]}),e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:c.branch})]}),e.jsxs(U,{type:"button",variant:"ghost",size:"sm",disabled:u,onClick:()=>h(c),className:"shrink-0",children:[u?e.jsx(Q,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(na,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:r("skills.repo.remove")})]})]},`${c.owner}/${c.name}`)})}):null]})}function Pr(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Fr(){const[t,i]=n.useState(Pr),[o,m]=n.useState({skills:[],targets:[]}),[g,h]=n.useState([]),[c,u]=n.useState([]),[x,j]=n.useState([]),[l,k]=n.useState(se),[y,b]=n.useState(""),[P,f]=n.useState(""),[w,B]=n.useState(""),[T,I]=n.useState(!1),[q,he]=n.useState("all"),[C,z]=n.useState(null),[v,M]=n.useState(""),[ie,ke]=n.useState(!0),[we,Ee]=n.useState(!1),[Be,D]=n.useState(""),[Y,je]=n.useState(null),[ve,ae]=n.useState(null),[te,N]=n.useState(()=>new Set),[J,ne]=n.useState({}),[A,G]=n.useState({}),[S,Te]=n.useState([]),[Ne,Z]=n.useState(!1),oe=n.useRef(!1),Ce=n.useMemo(()=>{const a=new Set;for(const s of o.skills||[]){a.add(sa(s).toLowerCase()),s.repoOwner&&s.repoName&&a.add(`${s.repoOwner}/${s.repoName}:${s.sourceDirectory||s.directory}`.toLowerCase());const d=String(s.directory||"").split(/[\\/]/).pop().toLowerCase();d&&a.add(`dir:${d}`)}return a},[o.skills]),le=n.useCallback(async()=>{const a=await mt();m({skills:a.skills||[],targets:a.targets||[]})},[]),ee=n.useCallback(async()=>{const a=await xt();j(a.repos||[])},[]),re=n.useCallback(async({force:a=!1}={})=>{Ee(!0);try{const s=await ht({force:a});h(s.skills||[])}finally{Ee(!1)}},[]),pe=n.useCallback(async({force:a=!1}={})=>{Z(!0);try{const s=await pt({force:a});Te(s.skills||[])}finally{Z(!1)}},[]),F=n.useCallback(async()=>{try{const a=await yt();ne(a?.updates||{})}catch{ne({})}},[]),de=n.useCallback(async()=>{try{const a=await ft(),s={};for(const d of a?.skills||[])d.installed&&(d.directory&&(s[String(d.directory).toLowerCase()]=d),s[String(d.skill).toLowerCase()]=d);G(s)}catch{G({})}},[]),ce=n.useCallback(async()=>{ke(!0),D("");try{await Promise.all([le(),ee()])}catch(a){D(a?.message||r("skills.error.generic"))}finally{ke(!1)}},[le,ee]),Se=n.useCallback(async()=>{await ce();const a=s=>D(s?.message||r("skills.error.generic"));t==="my"?(F(),de()):l===O?pe({force:!0}).catch(a):l!==E&&re({force:!0}).catch(a)},[re,ce,pe,F,de,l,t]);n.useEffect(()=>{ce()},[ce]),n.useEffect(()=>{if(oe.current||typeof window>"u")return;const a=new URLSearchParams(window.location.search),s=a.get("skill");if(!s){oe.current=!0;return}const d=o.skills||[];if(!d.length)return;const p=d.find(_=>_.directory===s||_.id===s);p&&(i("my"),z(p.id||p.directory)),oe.current=!0,a.delete("skill");const L=a.toString();window.history.replaceState({},"",`${window.location.pathname}${L?`?${L}`:""}${window.location.hash}`)},[o.skills]),n.useEffect(()=>{t==="browse"&&(l===E||l===O||g.length===0&&re().catch(a=>D(a?.message||r("skills.error.generic"))))},[g.length,re,l,t]),n.useEffect(()=>{t!=="browse"||l!==O||S.length===0&&pe().catch(a=>D(a?.message||r("skills.error.generic")))},[pe,S.length,l,t]);const De=Object.keys(J).length>0,Oe=Object.keys(A).length>0;if(n.useEffect(()=>{t==="my"&&(De||F(),Oe||de())},[t,De,Oe,F,de]),n.useEffect(()=>{const a=setTimeout(()=>f(y),200);return()=>clearTimeout(a)},[y]),n.useEffect(()=>{if(typeof window>"u")return;const a=new URLSearchParams(window.location.search),s=a.get("tab");if(t==="my"){if(!s)return;a.delete("tab")}else{if(s===t)return;a.set("tab",t)}const d=a.toString(),p=`${window.location.pathname}${d?`?${d}`:""}${window.location.hash}`;window.history.replaceState({},"",p)},[t]),!fr&&!bt())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(St,{})});const R=async(a,s)=>{M(a),D("");try{await s(),await le()}catch(d){D(d?.message||r("skills.error.generic"))}finally{M("")}},$=(a,s)=>{const d=(s&&s.length?s:aa).filter(p=>(o.targets||[]).some(L=>L.id===p));R(Ke(a),async()=>{await ca(a,d);const p=d.map(L=>(o.targets||[]).find(_=>_.id===L)?.label||L).join(", ");fe({title:r("skills.toast.installed",{name:a.name||a.directory,targets:p||r("skills.target.none")}),timeout:4e3})})},Xe=a=>{je(a)},ue=()=>{const a=Y;a&&(je(null),R(ya(a),async()=>{let s=null;a.managed?s=await ua(a.id):await ga(a.directory,a.targets||[]);const d=!!(s?.trashed&&a.managed&&a.id);fe({title:r("skills.toast.removed",{name:a.name||a.directory}),timeout:6e3,data:d?{onUndo:async()=>{try{await vt(a.id),await le()}catch(p){D(p?.message||r("skills.error.generic"))}}}:void 0})}))},Ue=(a,s,d)=>R(Fa(a.id,s),async()=>{const p=new Set(a.targets||[]);d?p.add(s):p.delete(s),a.managed?await ma(a.id,Array.from(p)):await xa(a.directory,Array.from(p));const L={name:a.name||a.directory,agent:Re(s)};fe({title:d?r("skills.toast.synced_one",L):r("skills.toast.unsynced_one",L),timeout:3e3})}),_e=n.useCallback(()=>N(new Set),[]),ze=n.useCallback((a,s)=>{N(d=>{const p=new Set(d);return s?p.add(a.id):p.delete(a.id),p})},[]),Re=a=>(o.targets||[]).find(s=>s.id===a)?.label||a,Pe=a=>{const s=(o.skills||[]).filter(d=>te.has(d.id));s.length&&R("batch",async()=>{for(const d of s){const p=new Set(d.targets||[]);p.add(a),d.managed?await ma(d.id,Array.from(p)):await xa(d.directory,Array.from(p))}_e(),fe({title:r("skills.toast.bulk_synced",{count:s.length,agent:Re(a)}),timeout:4e3})})},Qe=()=>{const a=(o.skills||[]).filter(s=>te.has(s.id));a.length&&ae(a)},Ye=()=>{const a=ve;a&&(ae(null),R("batch",async()=>{for(const s of a)s.managed?await ua(s.id):await ga(s.directory,s.targets||[]);_e(),fe({title:r("skills.toast.bulk_removed",{count:a.length}),timeout:4e3})}))},H=a=>{!a?.repoOwner||!a?.repoName||R(Ke(a),async()=>{await ca({key:a.key,name:a.name,description:a.description,directory:a.sourceDirectory||a.directory,repoOwner:a.repoOwner,repoName:a.repoName,repoBranch:a.repoBranch,readmeUrl:a.readmeUrl},a.targets&&a.targets.length?a.targets:aa),await F(),fe({title:r("skills.toast.updated",{name:a.name||a.directory}),timeout:4e3})})},ge=async()=>{const a=y.trim();if(!(a.length<2)){M("search"),D("");try{const s=await jt(a);u(s.skills||[])}catch(s){D(s?.message||r("skills.error.generic"))}finally{M("")}}},ye=async()=>{const a=w.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[s,d]=a.split("/");if(!s||!d){D(r("skills.repo.invalid"));return}await R("repo:add",async()=>{await Ct({owner:s,name:d,branch:"main",enabled:!0}),B(""),await ee(),await re()})},Je=async a=>{await R(`repo:${a.owner}/${a.name}`,async()=>{await Nt(a.owner,a.name),await ee(),await re()})},K=o.targets||[],me=o.skills||[],Va=n.useMemo(()=>q==="all"?me:me.filter(a=>(a.targets||[]).includes(q)),[me,q]),Aa=q!=="all",W=n.useMemo(()=>C&&me.find(a=>(a.id||a.directory)===C)||null,[me,C]),Ka=n.useCallback(()=>{he("all")},[]),qa=n.useCallback(a=>{z(s=>{const d=a?.id||a?.directory||null;return s===d?null:d})},[]),Ga=n.useCallback(()=>z(null),[]),Ha=n.useCallback(a=>{const s=String(a.directory||"").split(/[\\/]/).pop().toLowerCase(),d=(o.skills||[]).find(p=>String(p.directory||"").toLowerCase()===s);d&&z(d.id||d.directory)},[o.skills]);n.useEffect(()=>{t!=="my"&&te.size&&N(new Set)},[t,te.size]),n.useEffect(()=>{C&&!W&&z(null)},[W,C]);const $e=n.useMemo(()=>{const a=l===E?c:l===O?S:g,d=l===E||l===O||l===se?a:a.filter(_=>`${_.repoOwner}/${_.repoName}`===l),p=P.trim().toLowerCase();return(l===E||!p?d:d.filter(_=>(_.name||"").toLowerCase().includes(p)||(_.directory||"").toLowerCase().includes(p)||(_.description||"").toLowerCase().includes(p))).map(_=>{const Ze=sa(_).toLowerCase(),V=String(_.directory||"").split(/[\\/]/).pop().toLowerCase(),Ae=V?`dir:${V}`:"";return{..._,installed:Ce.has(Ze)||Ae&&Ce.has(Ae)}})},[P,g,Ce,S,c,l]),Wa=e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(Q,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),Xa=e.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[e.jsx(Q,{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")})]}),Fe=(a,s=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(a)}),s]});let Ve;if(ie)Ve=Wa;else if(t==="my")Ve=me.length?e.jsx(Cr,{items:Va,totalCount:me.length,targets:K,agentOptions:K,agentFilter:q,onAgentFilter:he,anyFilter:Aa,onClearFilters:Ka,selectedId:C,onSelect:qa,onToggleTarget:Ue,busyKey:v,updates:J,selectedIds:te,onToggleSelect:ze,onClearSelection:_e,onBulkSync:Pe,onBulkRemove:Qe}):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:[K.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:[...K,...K].map((a,s)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(xe,{provider:a.id,size:30})},`b-${s}`))})}),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:[...K,...K].map((a,s)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(xe,{provider:a.id,size:30})},`c-${s}`))})}),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(U,{type:"button",size:"sm",onClick:()=>i("browse"),children:r("skills.empty.my_cta")})]});else{const a=l===E,s=l===O,d=x.length===0&&!a&&!s,p=we&&!a&&!s||s&&Ne,L=!a&&!s&&(P.trim()!==""||l!==se),_=()=>{b(""),k(se)},Ze=!d&&!p&&($e.length>0||L)?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:$e.length})}),L?e.jsxs("button",{type:"button",onClick:_,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(Me,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]}):null;let V;d?V=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")})}):p?V=Xa:a&&y.trim().length<2?V=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")}):$e.length?V=e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:$e.map(Ie=>e.jsx("div",{style:Sr,children:e.jsx(_r,{skill:Ie,installed:!!Ie.installed,installing:v===Ke(Ie),allTargets:K,defaultTargets:aa,onInstall:$,onManage:Ha})},Ie.id||Ie.key))}):L?V=Fe("skills.empty.no_match",e.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:_,children:r("skills.filter.clear")})):a?V=Fe("skills.empty.search"):s?V=Fe("skills.empty.popular"):V=Fe("skills.empty.browse");const Ae=d||T?e.jsx("div",{className:"mb-5",children:e.jsx(Rr,{repos:x,repoInput:w,onRepoInput:B,busyKey:v,onAdd:ye,onRemove:Je})}):null,Qa=!T&&!a&&!s&&x.length<=1&&$e.length>0?e.jsx(rr,{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:()=>I(!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;Ve=e.jsxs(e.Fragment,{children:[Ae,Ze,V,Qa]})}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(U,{type:"button",variant:"secondary",size:"sm",onClick:Se,disabled:ie||we||Ne,children:[e.jsx(kt,{className:X("mr-1.5 h-3.5 w-3.5",(ie||we||Ne)&&"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(([a,s])=>e.jsx("button",{type:"button","aria-pressed":t===a,onClick:()=>i(a),className:X("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",t===a?"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:s},a))}),Be?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:Be}):null,t==="browse"?e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx("div",{role:"tablist","aria-label":r("skills.source.label"),className:"inline-flex h-10 shrink-0 items-center rounded-md border border-oai-gray-200 bg-oai-white p-1 dark:border-oai-gray-800 dark:bg-oai-gray-900",children:[["repo",r("skills.mode.repo"),l!==E&&l!==O],["popular",r("skills.mode.popular"),l===O],["skillssh",r("skills.mode.skillssh"),l===E]].map(([a,s,d])=>e.jsxs("button",{type:"button",role:"tab","aria-selected":d,onClick:()=>{a==="skillssh"?k(E):a==="popular"?k(O):(l===E||l===O)&&k(se)},className:X("inline-flex items-center gap-1.5 rounded px-3 py-1 text-sm font-medium transition-colors",d?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-700 dark:text-white":"text-oai-gray-500 hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200"),children:[a==="popular"?e.jsx(Yt,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,s]},a))}),l!==E&&l!==O?e.jsxs(Sa,{value:l,onValueChange:k,children:[e.jsxs(_a,{"aria-label":r("skills.source.label"),className:"inline-flex h-10 w-44 shrink-0 items-center justify-between gap-2 rounded-md border border-oai-gray-200 bg-oai-white px-3 text-sm 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(Ra,{children:a=>a===se?r("skills.source.all"):a}),e.jsx(Ta,{className:"text-oai-gray-400",children:e.jsx(ia,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsx(Pa,{children:e.jsx($a,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ia,{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(qe,{value:se,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(Ge,{children:r("skills.source.all")}),e.jsx(He,{children:e.jsx(be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),x.map(a=>{const s=`${a.owner}/${a.name}`;return e.jsxs(qe,{value:s,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(Ge,{children:s}),e.jsx(He,{children:e.jsx(be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},s)})]})})})]}):null,e.jsxs("div",{className:"relative flex-1",children:[e.jsx(da,{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(Ba,{type:"search",value:y,onChange:a=>b(a.target.value),onKeyDown:a=>{a.key==="Enter"&&l===E&&ge()},"aria-label":r("skills.action.search_aria"),placeholder:l===E?r("skills.browse.placeholder_skillssh"):l===O?r("skills.browse.placeholder_popular"):l===se?r("skills.browse.placeholder_all"):r("skills.browse.placeholder_repo",{repo:l}),className:"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"})]}),l===E?e.jsxs(U,{type:"button",onClick:ge,disabled:y.trim().length<2||v==="search",className:"focus:!ring-oai-gray-400/30",children:[v==="search"?e.jsx(Q,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(da,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.action.search")]}):l===O?null:e.jsxs(U,{type:"button",variant:"secondary",size:"sm",onClick:()=>I(a=>!a),"aria-expanded":T,className:"!h-10 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(Ea,{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:x.length})]})]}):null,Ve,e.jsx(pr,{skill:W,targets:K,busyKey:v,usage:W&&(A[String(W.directory||"").toLowerCase()]||A[String(W.name||"").toLowerCase()])||null,hasUpdate:!!(W?.id&&J?.[W.id]),updating:W?v===Ke(W):!1,onUpdate:H,onClose:Ga,onToggleTarget:Ue,onRemove:Xe})]})}),e.jsx(ha,{open:!!Y,title:r("skills.confirm.remove_title",{name:Y?.name||Y?.directory||""}),description:Y?Y.managed?r("skills.confirm.remove_managed"):r("skills.confirm.remove_local"):"",confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:v===ya(Y||{}),onCancel:()=>je(null),onConfirm:ue}),e.jsx(ha,{open:!!ve,title:r("skills.confirm.bulk_remove_title",{count:ve?.length||0}),description:r("skills.confirm.bulk_remove_desc"),confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:v==="batch",onCancel:()=>ae(null),onConfirm:Ye})]})}export{Fr as SkillsPage};
|
|
1
|
+
import{c as Le,r as n,a as We,j as e,F as U,N as X,X as Me,A as r,aW as fa,aX as Ya,u as Ja,aY as oa,aZ as Za,a_ as et,a$ as at,b0 as tt,b1 as rt,b2 as st,b as it,b3 as nt,b4 as ot,b5 as lt,K as dt,e as ct,m as la,a6 as ut,C as gt,P as xe,b6 as mt,b7 as xt,b8 as ht,b9 as pt,ba as yt,bb as ft,i as bt,aR as kt,bc as da,R as wt,bd as jt,be as ca,bf as fe,bg as ua,bh as ga,bi as vt,bj as ma,bk as xa,bl as Nt,bm as Ct}from"./main-BZBATt4l.js";import{L as St}from"./LocalOnlyNotice-CbVonMVs.js";import{C as _t}from"./Card-eNDH0TxH.js";import{u as Rt,D as Pt,a as $t,b as It,c as Lt,d as Mt,e as Et}from"./DialogTitle-BJKAi66j.js";import{u as ta,a as Bt,t as Tt,b as Dt,C as be}from"./useOpenInteractionType-B65bQ4-n.js";import{I as ba}from"./info-DD3Xh30V.js";import{u as Ot}from"./useCurrency-Cr1NSPgK.js";import{L as Q,P as ka,a as wa,b as ja,c as va,d as Na,C as Ut}from"./PopoverPopup-DCGh4euQ.js";import{u as zt,s as Ft,f as Ca,a as Vt,b as At,c as Kt,d as qt,e as Gt,g as Ht,S as Sa,h as _a,i as Ra,C as ia,j as Pa,k as $a,l as Ia,m as qe,n as Ge,o as He}from"./SelectItemText-BH_vsFMS.js";import{D as La}from"./download-Ds1ViaQ9.js";import"./arrow-up-right-RH7MeYHL.js";const Wt=[["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"}]],Ma=Le("circle-arrow-up",Wt);const Xt=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ra=Le("external-link",Xt);const Qt=[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]],Yt=Le("flame",Qt);const Jt=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ea=Le("plus",Jt);const Zt=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],na=Le("trash-2",Zt),er=n.forwardRef(function(i,o){const{render:m,className:g,id:h,...c}=i,{store:u}=Rt(),x=ta(h);return u.useSyncedValueWithCleanup("descriptionElementId",x),We("p",i,{ref:o,props:[{id:x},c]})});function ha({open:t,title:i,description:o,confirmLabel:m,cancelLabel:g,destructive:h=!1,busy:c=!1,onConfirm:u,onCancel:x}){return e.jsx(Pt,{open:t,onOpenChange:j=>{!j&&!c&&x?.()},children:e.jsxs($t,{children:[e.jsx(It,{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),e.jsx(Lt,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:e.jsxs(Mt,{className:"relative w-full max-w-md rounded-2xl bg-white p-6 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] ring-1 ring-oai-gray-200 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.96] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0 dark:bg-oai-gray-950 dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] dark:ring-oai-gray-800",children:[e.jsx(Et,{className:"text-base font-semibold text-oai-black dark:text-white",children:i}),o?e.jsx(er,{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:o}):null,e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx(U,{type:"button",variant:"secondary",size:"sm",disabled:c,onClick:()=>x?.(),children:g}),e.jsx(U,{type:"button",size:"sm",disabled:c,onClick:()=>u?.(),className:X(h&&"!bg-red-600 hover:!bg-red-700 focus-visible:!outline-red-600 dark:!bg-red-600 dark:hover:!bg-red-500"),children:m})]})]})})]})})}function Ba({id:t,value:i,onChange:o,placeholder:m,disabled:g=!1,type:h="text",label:c,error:u,className:x="",...j}){const l=n.useId(),k=t||l,y=u?`${k}-error`:void 0,w=`w-full bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md text-oai-black dark:text-oai-white placeholder-oai-gray-400 dark:placeholder-oai-gray-500 transition-all duration-200 focus:outline-none focus:border-oai-brand dark:focus:border-oai-brand focus:ring-1 focus:ring-oai-brand/30 ${g?"bg-oai-gray-50 dark:bg-oai-gray-800 text-oai-gray-400 dark:text-oai-gray-400 cursor-not-allowed":""} ${u?"border-oai-error focus:border-oai-error focus:ring-oai-error/30":""} h-10 px-3 text-sm ${x}`;return e.jsxs("div",{className:"w-full",children:[c&&e.jsx("label",{htmlFor:k,className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5 transition-colors duration-200",children:c}),e.jsx("input",{id:k,type:h,value:i,onChange:o,placeholder:m,disabled:g,"aria-invalid":u?!0:void 0,"aria-describedby":y,className:w,...j}),u&&e.jsx("p",{id:y,className:"mt-1.5 text-sm text-oai-error",children:u})]})}const Ta=n.forwardRef(function(i,o){const{className:m,render:g,...h}=i,{store:c}=zt(),u=Bt(c,Ft.open),x=n.useMemo(()=>({open:u}),[u]);return We("span",i,{state:x,ref:o,props:[{"aria-hidden":!0,children:"▼"},h],stateAttributesMapping:Tt})}),ar="tt:hint:dismissed:";function Da(t){return ar+t}function tr(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Da(t))==="1"}catch{return!1}}function rr({id:t,children:i,className:o,ariaLabel:m}){const[g,h]=n.useState(()=>tr(t)),c=n.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(Da(t),"1")}catch{}h(!0)},[t]);return g?null:e.jsxs("div",{role:"note","aria-label":m||r("hint.dismissible_aria"),className:X("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",o),children:[e.jsx("button",{type:"button",onClick:c,"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(Me,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(ba,{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:i})]})]})}let pa=(function(t){return t.checked="data-checked",t.unchecked="data-unchecked",t.indeterminate="data-indeterminate",t.disabled="data-disabled",t.readonly="data-readonly",t.required="data-required",t.valid="data-valid",t.invalid="data-invalid",t.touched="data-touched",t.dirty="data-dirty",t.filled="data-filled",t.focused="data-focused",t})({});function Oa(t){return n.useMemo(()=>({checked(i){return t.indeterminate?{}:i?{[pa.checked]:""}:{[pa.unchecked]:""}},...Ca}),[t.indeterminate])}const sr=n.createContext({disabled:!1});function ir(){return n.useContext(sr)}const nr=n.createContext(void 0);function or(t=!0){const i=n.useContext(nr);if(i===void 0&&!t)throw new Error(fa(3));return i}const Ua=n.createContext(void 0);function lr(){const t=n.useContext(Ua);if(t===void 0)throw new Error(fa(14));return t}const dr="data-parent",cr=n.forwardRef(function(i,o){const{checked:m,className:g,defaultChecked:h=!1,disabled:c=!1,id:u,indeterminate:x=!1,inputRef:j,name:l,onCheckedChange:k,parent:y=!1,readOnly:b=!1,render:P,required:f=!1,uncheckedValue:w,value:B,nativeButton:T=!1,...I}=i,{clearErrors:q}=Vt(),{disabled:he,name:C,setDirty:z,setFilled:v,setFocused:M,setTouched:ie,state:ke,validationMode:we,validityData:Ee,shouldValidateOnChange:Be,validation:D}=At(),Y=ir(),{labelId:je,controlId:ve,setControlId:ae,getDescriptionProps:te}=Kt(),N=or(),J=N?.parent,ne=J&&N.allValues,A=he||Y.disabled||N?.disabled||c,G=C??l,S=B??G,Te=ta(),Ne=ta();let Z=ve;ne?Z=y?Ne:`${J.id}-${S}`:u&&(Z=u);let oe={};ne&&(y?oe=N.parent.getParentProps():S&&(oe=N.parent.getChildProps(S)));const Ce=Ya(k),{checked:le=m,indeterminate:ee=x,onCheckedChange:re,...pe}=oe,F=N?.value,de=N?.setValue,ce=N?.defaultValue,Se=n.useRef(null),{getButtonProps:De,buttonRef:Oe}=Ja({disabled:A,native:T}),R=N?.validation??D,[$,Xe]=qt({controlled:S&&F&&!y?F.includes(S):le,default:S&&ce&&!y?ce.includes(S):h,name:"Checkbox",state:"checked"});oa(()=>{if(ae!==Za)return ae(Z),()=>{ae(void 0)}},[Z,N,ae,y]),Gt({enabled:!N,id:Te,commit:R.commit,value:$,controlRef:Se,name:G,getValue:()=>$});const ue=n.useRef(null),Ue=et(j,ue,R.inputRef);oa(()=>{ue.current&&(ue.current.indeterminate=ee,$&&v(!0))},[$,ee,v]),Ht($,()=>{N&&!y||(q(G),v($),z($!==Ee.initialValue),Be()?R.commit($):R.commit($,!0))});const _e=at({checked:$,disabled:A,name:y?void 0:G,id:T?void 0:Z??void 0,required:f,ref:Ue,style:G?rt:st,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(H){if(H.nativeEvent.defaultPrevented)return;const ge=H.target.checked,ye=it(nt,H.nativeEvent);if(re?.(ge,ye),Ce(ge,ye),!ye.isCanceled&&(Xe(ge),S&&F&&de&&!y)){const Je=ge?[...F,S]:F.filter(K=>K!==S);de(Je,ye)}},onFocus(){Se.current?.focus()}},B!==void 0?{value:(N?$&&B:B)||""}:tt,te,N?R.getValidationProps:R.getInputValidationProps),ze=ne?!!le:$,Re=ne&&ee||x;n.useEffect(()=>{J&&S&&J.disabledStatesRef.current.set(S,A)},[J,A,S]);const Pe=n.useMemo(()=>({...ke,checked:ze,disabled:A,readOnly:b,required:f,indeterminate:Re}),[ke,ze,A,b,f,Re]),Qe=Oa(Pe),Ye=We("span",i,{state:Pe,ref:[Oe,Se,o,N?.registerControlRef],props:[{id:T?Z??void 0:Te,role:"checkbox","aria-checked":ee?"mixed":$,"aria-readonly":b||void 0,"aria-required":f||void 0,"aria-labelledby":je,[dr]:y?"":void 0,onFocus(){M(!0)},onBlur(){const H=ue.current;H&&(ie(!0),M(!1),we==="onBlur"&&R.commit(N?F:H.checked))},onClick(H){b||A||(H.preventDefault(),ue.current?.click())}},te,R.getValidationProps,I,pe,De],stateAttributesMapping:Qe});return e.jsxs(Ua.Provider,{value:Pe,children:[Ye,!$&&!N&&G&&!y&&w!==void 0&&e.jsx("input",{type:"hidden",name:G,value:w}),e.jsx("input",{..._e})]})}),ur=n.forwardRef(function(i,o){const{render:m,className:g,keepMounted:h=!1,...c}=i,u=lr(),x=u.checked||u.indeterminate,{transitionStatus:j,setMounted:l}=Dt(x),k=n.useRef(null),y=n.useMemo(()=>({...u,transitionStatus:j}),[u,j]);ot({open:x,ref:k,onComplete(){x||l(!1)}});const b=Oa(u),P=n.useMemo(()=>({...b,...lt,...Ca}),[b]),f=h||x,w=We("span",i,{enabled:f,ref:[o,k],state:y,stateAttributesMapping:P,props:c});return f?w:null});function gr(t,i){return`target:${t}:${i}`}function mr(t){return`remove:${t.id||t.directory}`}function za(t){if(!t)return null;const i=new Date(t).getTime();return Number.isFinite(i)?Math.floor((Date.now()-i)/864e5):null}function xr(t){const i=za(t);if(i==null)return null;if(i<=0)return r("skills.usage.today");if(i<30)return r("skills.usage.days_ago",{days:i});const o=Math.max(1,Math.floor(i/30));return r("skills.usage.months_ago",{months:o})}function hr(t){const i=za(t);return i==null?"bg-oai-gray-300 dark:bg-oai-gray-600":i<=7?"bg-emerald-500":i<=30?"bg-amber-500":"bg-oai-gray-300 dark:bg-oai-gray-600"}function ea({label:t,children:i}){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:t}),e.jsx("dd",{className:"text-right font-medium tabular-nums text-oai-black dark:text-white",children:i})]})}function pr({skill:t,targets:i,busyKey:o,usage:m,hasUpdate:g,updating:h,onUpdate:c,onClose:u,onToggleTarget:x,onRemove:j}){return e.jsx(dt,{children:t?e.jsx(yr,{skill:t,targets:i,busyKey:o,usage:m,hasUpdate:g,updating:h,onUpdate:c,onClose:u,onToggleTarget:x,onRemove:j},t.id||t.directory):null})}function yr({skill:t,targets:i,busyKey:o,usage:m,hasUpdate:g,updating:h,onUpdate:c,onClose:u,onToggleTarget:x,onRemove:j}){const l=ct(),{currency:k,rate:y}=Ot(),b=n.useRef(null);n.useEffect(()=>{const C=v=>{v.key==="Escape"&&(v.stopPropagation(),u?.())},z=v=>{const M=v.target;M instanceof Element&&(b.current?.contains(M)||M.closest('[data-skill-row="1"]')||u?.())};return document.addEventListener("keydown",C),document.addEventListener("mousedown",z),()=>{document.removeEventListener("keydown",C),document.removeEventListener("mousedown",z)}},[u]);const P=t.name||t.directory,f=!!(t.repoOwner&&t.repoName),w=f?`https://github.com/${t.repoOwner}/${t.repoName}`:null,B=new Set(t.targets||[]),T=o===mr(t),I=xr(m?.lastUsedAt),q=!!(m&&m.invocations>0),he=l?{duration:0}:{type:"spring",stiffness:320,damping:30,mass:.7};return e.jsxs(e.Fragment,{children:[e.jsx(la.div,{className:"fixed inset-0 z-20 bg-oai-black/30 backdrop-blur-[2px] lg:hidden",initial:l?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:l?0:.15},onClick:u,"aria-hidden":!0}),e.jsxs(la.aside,{ref:b,role:"complementary","aria-label":P,initial:l?!1:{opacity:0,x:24,scale:.98},animate:{opacity:1,x:0,scale:1},exit:l?{opacity:0}:{opacity:0,x:24,scale:.98},transition:he,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:P,children:P}),f?e.jsxs("a",{href:w,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:w,children:[e.jsxs("span",{className:"truncate",children:[t.repoOwner,"/",t.repoName]}),e.jsx(ra,{className:"h-3 w-3 shrink-0","aria-hidden":!0})]}):t.directory&&t.directory!==P?e.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",title:t.directory,children:t.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(Me,{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:[g?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(Ma,{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:()=>c?.(t),disabled:h,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(Q,{className:"h-3 w-3 animate-spin","aria-hidden":!0}):null,r("skills.update.action")]})]}):null,t.description?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:t.description}):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.usage.section_title")}),e.jsxs("dl",{className:"divide-y divide-oai-gray-200/60 dark:divide-white/[0.06]",children:[e.jsx(ea,{label:r("skills.usage.invocations"),children:ut(m?.invocations||0)}),e.jsx(ea,{label:r("skills.usage.last_used"),children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:X("h-1.5 w-1.5 rounded-full",hr(m?.lastUsedAt)),"aria-hidden":!0}),q?I||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(ea,{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(ba,{className:"h-3 w-3","aria-label":r("skills.usage.disclaimer")})})]}),children:gt(m?.cost||0,{currency:k,rate:y})})]}),q?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")})]}),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:(i||[]).map(C=>{const z=B.has(C.id),v=o===gr(t.id,C.id),M=`skill-detail-sync-${t.id||t.directory}-${C.id}`;return e.jsxs("label",{htmlFor:M,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(cr,{id:M,checked:z,disabled:v,onCheckedChange:ie=>x?.(t,C.id,!!ie),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(ur,{className:"flex items-center justify-center text-white dark:text-oai-black",children:e.jsx(be,{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(xe,{provider:C.id,size:16})}),e.jsx("span",{className:"flex-1",children:C.label}),v?e.jsx(Q,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},C.id)})})]})]}),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:()=>j?.(t),disabled:T,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:[T?e.jsx(Q,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(na,{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"),aa=["claude","codex"],O="popular",br={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"},se="all",E="skillssh";function sa(t){return`${t.repoOwner||"local"}/${t.repoName||"local"}:${t.directory}`}function Ke(t){return`install:${sa(t)}`}function ya(t){return`remove:${t.id||t.directory}`}function Fa(t,i){return`target:${t}:${i}`}function kr({target:t,state:i,busy:o,onToggle:m}){const g=i==="synced",h=i==="orphan",c=h?r("skills.dot.orphan_aria",{agent:t.label}):g?r("skills.dot.synced_aria",{agent:t.label}):r("skills.dot.off_aria",{agent:t.label});return e.jsxs("button",{type:"button",title:c,"aria-label":c,"aria-pressed":g,disabled:o,onClick:u=>{u.stopPropagation(),m?.(t.id,!g)},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:[o?e.jsx(Q,{className:"h-4 w-4 animate-spin text-oai-gray-400","aria-hidden":!0}):e.jsx("span",{className:X("flex h-[18px] w-[18px] items-center justify-center transition",g&&br[t.id],!g&&!h&&"opacity-35 grayscale"),"aria-hidden":!0,children:e.jsx(xe,{provider:t.id,size:18})}),h&&!o?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 wr({skill:t,targets:i,onToggleTarget:o,busyKey:m}){return e.jsx("div",{className:"flex items-center gap-1",onClick:g=>g.stopPropagation(),children:i.map(g=>e.jsx(kr,{target:g,state:t.targetStates?.[g.id]||"off",busy:m===Fa(t.id,g.id),onToggle:(h,c)=>o?.(t,h,c)},g.id))})}function jr({skill:t,targets:i,selected:o,onSelect:m,selectable:g,checked:h,onToggleSelect:c,onToggleTarget:u,hasUpdate:x,busyKey:j}){const l=t.repoOwner&&t.repoName?`${t.repoOwner}/${t.repoName}`:null,k=l?`${t.directory} · ${l}`:t.directory,y=b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),m?.(t))};return e.jsxs("div",{"data-skill-row":"1",role:"button",tabIndex:0,"aria-pressed":o,"aria-label":r("skills.row.open_details",{name:t.name||t.directory}),onClick:()=>m?.(t),onKeyDown:y,className:X("cursor-pointer rounded-md py-3 pr-2 transition focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30",o?"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:[g?e.jsx("label",{className:"flex shrink-0 items-center",onClick:b=>b.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:h,onChange:b=>c?.(t,b.target.checked),"aria-label":r("skills.select.row_aria",{name:t.name||t.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:k,children:t.name||t.directory}),x?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(Ma,{className:"h-2.5 w-2.5","aria-hidden":!0}),r("skills.update.badge")]}):null,e.jsx(wr,{skill:t,targets:i,onToggleTarget:u,busyKey:j}),e.jsx(Ut,{className:X("hidden h-4 w-4 shrink-0 text-oai-gray-300 transition-colors dark:text-oai-gray-600 lg:block",o&&"text-oai-gray-500 dark:text-oai-gray-300"),"aria-hidden":!0})]}),t.description?e.jsx("p",{className:X("mt-1 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",g&&"pl-7"),children:t.description}):null]})}function vr({agentFilter:t,agentOptions:i,onAgentFilter:o,filteredCount:m,totalCount:g,anyFilter:h,onClearFilters:c}){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(Sa,{value:t,onValueChange:o,children:[e.jsxs(_a,{"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(Ra,{children:u=>u==="all"?r("skills.filter.agent_all"):i.find(x=>x.id===u)?.label||u}),e.jsx(Ta,{className:"text-oai-gray-400",children:e.jsx(ia,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Pa,{children:e.jsx($a,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ia,{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(qe,{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(Ge,{children:r("skills.filter.agent_all")}),e.jsx(He,{children:e.jsx(be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),i.map(u=>e.jsxs(qe,{value:u.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(xe,{provider:u.id,size:14}),e.jsx(Ge,{children:u.label})]}),e.jsx(He,{children:e.jsx(be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},u.id))]})})})]}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.filter.result_count",{filtered:m,total:g})}),h?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(Me,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]})}function Nr({count:t,targets:i,busy:o,onBulkSync:m,onBulkRemove:g,onClear:h}){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:t})}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs(ka,{children:[e.jsxs(wa,{disabled:o,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(La,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_sync"),e.jsx(ia,{className:"h-3 w-3","aria-hidden":!0})]}),e.jsx(ja,{children:e.jsx(va,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(Na,{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")}),i.map(c=>e.jsxs("button",{type:"button",onClick:()=>m(c.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(xe,{provider:c.id,size:16}),e.jsx("span",{className:"flex-1",children:c.label})]},c.id))]})})})]}),e.jsxs(U,{type:"button",variant:"ghost",size:"sm",disabled:o,onClick:g,children:[e.jsx(na,{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(Me,{className:"h-3 w-3","aria-hidden":!0}),r("skills.select.clear")]})]})]})}function Cr({items:t,totalCount:i,targets:o,agentOptions:m,agentFilter:g,onAgentFilter:h,anyFilter:c,onClearFilters:u,selectedId:x,onSelect:j,onToggleTarget:l,busyKey:k,updates:y,selectedIds:b,onToggleSelect:P,onClearSelection:f,onBulkSync:w,onBulkRemove:B}){const T=b.size;return e.jsxs("div",{children:[T>0?e.jsx(Nr,{count:T,targets:o,busy:k==="batch",onBulkSync:w,onBulkRemove:B,onClear:f}):e.jsx(vr,{agentFilter:g,agentOptions:m,onAgentFilter:h,filteredCount:t.length,totalCount:i,anyFilter:c,onClearFilters:u}),t.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(U,{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:t.map(I=>e.jsx(jr,{skill:I,targets:o,selected:x===(I.id||I.directory),onSelect:j,selectable:!0,checked:b.has(I.id),onToggleSelect:P,onToggleTarget:l,hasUpdate:!!(I.id&&y?.[I.id]),busyKey:k},I.id||I.key))})]})}const Sr={contentVisibility:"auto",containIntrinsicSize:"0 240px"},_r=wt.memo(function({skill:i,installed:o,installing:m,allTargets:g,defaultTargets:h,onInstall:c,onManage:u}){const[x,j]=n.useState(()=>(h||[]).filter(f=>g.some(w=>w.id===f))),l=f=>{j(w=>w.includes(f)?w.filter(B=>B!==f):[...w,f])},k=i.repoOwner&&i.repoName?`${i.repoOwner}/${i.repoName}`:null,y=k?`https://github.com/${i.repoOwner}/${i.repoName}`:null,b=i.installs!=null?r("skills.card.installs",{count:Number(i.installs||0).toLocaleString()}):null,P=x.length?x.map(f=>g.find(w=>w.id===f)?.label||f).join(", "):r("skills.action.choose_targets");return e.jsxs(_t,{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:[i.readmeUrl?e.jsxs("a",{href:i.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:i.readmeUrl,children:[e.jsx("span",{className:"truncate",children:i.name||i.directory}),e.jsx(ra,{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:i.name||i.directory}),k||b?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:[y?e.jsxs("a",{href:y,target:"_blank",rel:"noopener noreferrer",onClick:f=>f.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:y,children:[e.jsx("span",{className:"truncate",children:k}),e.jsx(ra,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,k&&b?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,b?e.jsx("span",{className:"truncate",children:b}):null]}):null]})}),i.description?e.jsx("p",{className:"mt-3 line-clamp-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:i.description}):null,e.jsx("div",{className:"mt-auto pt-5",children:o?e.jsxs(U,{type:"button",variant:"secondary",size:"sm",onClick:()=>u?.(i),className:"w-full",children:[e.jsx(be,{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:x.length?P:r("skills.target.none")}),e.jsxs(ka,{children:[e.jsx(wa,{disabled:m,"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(ja,{children:e.jsx(va,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(Na,{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")}),g.map(f=>{const w=x.includes(f.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:w,onChange:()=>l(f.id)}),e.jsx(xe,{provider:f.id,size:16}),e.jsx("span",{className:"flex-1 text-left",children:f.label})]},f.id)})]})})})]})]}),e.jsxs(U,{type:"button",size:"sm",onClick:()=>c(i,x),disabled:m||x.length===0,className:"w-full",children:[m?e.jsx(Q,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(La,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.action.install")]})]})})]})});function Rr({repos:t,repoInput:i,onRepoInput:o,busyKey:m,onAdd:g,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(Ba,{value:i,onChange:c=>o(c.target.value),placeholder:r("skills.repo.placeholder"),className:"min-w-0 flex-1"}),e.jsxs(U,{type:"button",variant:"secondary",size:"md",onClick:g,disabled:m==="repo:add",className:"shrink-0 whitespace-nowrap",children:[m==="repo:add"?e.jsx(Q,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(Ea,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.repo.add")]})]}),t.length?e.jsx("div",{className:"mt-3 divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:t.map(c=>{const u=m===`repo:${c.owner}/${c.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:[c.owner,"/",c.name]}),e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:c.branch})]}),e.jsxs(U,{type:"button",variant:"ghost",size:"sm",disabled:u,onClick:()=>h(c),className:"shrink-0",children:[u?e.jsx(Q,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(na,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:r("skills.repo.remove")})]})]},`${c.owner}/${c.name}`)})}):null]})}function Pr(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Fr(){const[t,i]=n.useState(Pr),[o,m]=n.useState({skills:[],targets:[]}),[g,h]=n.useState([]),[c,u]=n.useState([]),[x,j]=n.useState([]),[l,k]=n.useState(se),[y,b]=n.useState(""),[P,f]=n.useState(""),[w,B]=n.useState(""),[T,I]=n.useState(!1),[q,he]=n.useState("all"),[C,z]=n.useState(null),[v,M]=n.useState(""),[ie,ke]=n.useState(!0),[we,Ee]=n.useState(!1),[Be,D]=n.useState(""),[Y,je]=n.useState(null),[ve,ae]=n.useState(null),[te,N]=n.useState(()=>new Set),[J,ne]=n.useState({}),[A,G]=n.useState({}),[S,Te]=n.useState([]),[Ne,Z]=n.useState(!1),oe=n.useRef(!1),Ce=n.useMemo(()=>{const a=new Set;for(const s of o.skills||[]){a.add(sa(s).toLowerCase()),s.repoOwner&&s.repoName&&a.add(`${s.repoOwner}/${s.repoName}:${s.sourceDirectory||s.directory}`.toLowerCase());const d=String(s.directory||"").split(/[\\/]/).pop().toLowerCase();d&&a.add(`dir:${d}`)}return a},[o.skills]),le=n.useCallback(async()=>{const a=await mt();m({skills:a.skills||[],targets:a.targets||[]})},[]),ee=n.useCallback(async()=>{const a=await xt();j(a.repos||[])},[]),re=n.useCallback(async({force:a=!1}={})=>{Ee(!0);try{const s=await ht({force:a});h(s.skills||[])}finally{Ee(!1)}},[]),pe=n.useCallback(async({force:a=!1}={})=>{Z(!0);try{const s=await pt({force:a});Te(s.skills||[])}finally{Z(!1)}},[]),F=n.useCallback(async()=>{try{const a=await yt();ne(a?.updates||{})}catch{ne({})}},[]),de=n.useCallback(async()=>{try{const a=await ft(),s={};for(const d of a?.skills||[])d.installed&&(d.directory&&(s[String(d.directory).toLowerCase()]=d),s[String(d.skill).toLowerCase()]=d);G(s)}catch{G({})}},[]),ce=n.useCallback(async()=>{ke(!0),D("");try{await Promise.all([le(),ee()])}catch(a){D(a?.message||r("skills.error.generic"))}finally{ke(!1)}},[le,ee]),Se=n.useCallback(async()=>{await ce();const a=s=>D(s?.message||r("skills.error.generic"));t==="my"?(F(),de()):l===O?pe({force:!0}).catch(a):l!==E&&re({force:!0}).catch(a)},[re,ce,pe,F,de,l,t]);n.useEffect(()=>{ce()},[ce]),n.useEffect(()=>{if(oe.current||typeof window>"u")return;const a=new URLSearchParams(window.location.search),s=a.get("skill");if(!s){oe.current=!0;return}const d=o.skills||[];if(!d.length)return;const p=d.find(_=>_.directory===s||_.id===s);p&&(i("my"),z(p.id||p.directory)),oe.current=!0,a.delete("skill");const L=a.toString();window.history.replaceState({},"",`${window.location.pathname}${L?`?${L}`:""}${window.location.hash}`)},[o.skills]),n.useEffect(()=>{t==="browse"&&(l===E||l===O||g.length===0&&re().catch(a=>D(a?.message||r("skills.error.generic"))))},[g.length,re,l,t]),n.useEffect(()=>{t!=="browse"||l!==O||S.length===0&&pe().catch(a=>D(a?.message||r("skills.error.generic")))},[pe,S.length,l,t]);const De=Object.keys(J).length>0,Oe=Object.keys(A).length>0;if(n.useEffect(()=>{t==="my"&&(De||F(),Oe||de())},[t,De,Oe,F,de]),n.useEffect(()=>{const a=setTimeout(()=>f(y),200);return()=>clearTimeout(a)},[y]),n.useEffect(()=>{if(typeof window>"u")return;const a=new URLSearchParams(window.location.search),s=a.get("tab");if(t==="my"){if(!s)return;a.delete("tab")}else{if(s===t)return;a.set("tab",t)}const d=a.toString(),p=`${window.location.pathname}${d?`?${d}`:""}${window.location.hash}`;window.history.replaceState({},"",p)},[t]),!fr&&!bt())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(St,{})});const R=async(a,s)=>{M(a),D("");try{await s(),await le()}catch(d){D(d?.message||r("skills.error.generic"))}finally{M("")}},$=(a,s)=>{const d=(s&&s.length?s:aa).filter(p=>(o.targets||[]).some(L=>L.id===p));R(Ke(a),async()=>{await ca(a,d);const p=d.map(L=>(o.targets||[]).find(_=>_.id===L)?.label||L).join(", ");fe({title:r("skills.toast.installed",{name:a.name||a.directory,targets:p||r("skills.target.none")}),timeout:4e3})})},Xe=a=>{je(a)},ue=()=>{const a=Y;a&&(je(null),R(ya(a),async()=>{let s=null;a.managed?s=await ua(a.id):await ga(a.directory,a.targets||[]);const d=!!(s?.trashed&&a.managed&&a.id);fe({title:r("skills.toast.removed",{name:a.name||a.directory}),timeout:6e3,data:d?{onUndo:async()=>{try{await vt(a.id),await le()}catch(p){D(p?.message||r("skills.error.generic"))}}}:void 0})}))},Ue=(a,s,d)=>R(Fa(a.id,s),async()=>{const p=new Set(a.targets||[]);d?p.add(s):p.delete(s),a.managed?await ma(a.id,Array.from(p)):await xa(a.directory,Array.from(p));const L={name:a.name||a.directory,agent:Re(s)};fe({title:d?r("skills.toast.synced_one",L):r("skills.toast.unsynced_one",L),timeout:3e3})}),_e=n.useCallback(()=>N(new Set),[]),ze=n.useCallback((a,s)=>{N(d=>{const p=new Set(d);return s?p.add(a.id):p.delete(a.id),p})},[]),Re=a=>(o.targets||[]).find(s=>s.id===a)?.label||a,Pe=a=>{const s=(o.skills||[]).filter(d=>te.has(d.id));s.length&&R("batch",async()=>{for(const d of s){const p=new Set(d.targets||[]);p.add(a),d.managed?await ma(d.id,Array.from(p)):await xa(d.directory,Array.from(p))}_e(),fe({title:r("skills.toast.bulk_synced",{count:s.length,agent:Re(a)}),timeout:4e3})})},Qe=()=>{const a=(o.skills||[]).filter(s=>te.has(s.id));a.length&&ae(a)},Ye=()=>{const a=ve;a&&(ae(null),R("batch",async()=>{for(const s of a)s.managed?await ua(s.id):await ga(s.directory,s.targets||[]);_e(),fe({title:r("skills.toast.bulk_removed",{count:a.length}),timeout:4e3})}))},H=a=>{!a?.repoOwner||!a?.repoName||R(Ke(a),async()=>{await ca({key:a.key,name:a.name,description:a.description,directory:a.sourceDirectory||a.directory,repoOwner:a.repoOwner,repoName:a.repoName,repoBranch:a.repoBranch,readmeUrl:a.readmeUrl},a.targets&&a.targets.length?a.targets:aa),await F(),fe({title:r("skills.toast.updated",{name:a.name||a.directory}),timeout:4e3})})},ge=async()=>{const a=y.trim();if(!(a.length<2)){M("search"),D("");try{const s=await jt(a);u(s.skills||[])}catch(s){D(s?.message||r("skills.error.generic"))}finally{M("")}}},ye=async()=>{const a=w.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[s,d]=a.split("/");if(!s||!d){D(r("skills.repo.invalid"));return}await R("repo:add",async()=>{await Ct({owner:s,name:d,branch:"main",enabled:!0}),B(""),await ee(),await re()})},Je=async a=>{await R(`repo:${a.owner}/${a.name}`,async()=>{await Nt(a.owner,a.name),await ee(),await re()})},K=o.targets||[],me=o.skills||[],Va=n.useMemo(()=>q==="all"?me:me.filter(a=>(a.targets||[]).includes(q)),[me,q]),Aa=q!=="all",W=n.useMemo(()=>C&&me.find(a=>(a.id||a.directory)===C)||null,[me,C]),Ka=n.useCallback(()=>{he("all")},[]),qa=n.useCallback(a=>{z(s=>{const d=a?.id||a?.directory||null;return s===d?null:d})},[]),Ga=n.useCallback(()=>z(null),[]),Ha=n.useCallback(a=>{const s=String(a.directory||"").split(/[\\/]/).pop().toLowerCase(),d=(o.skills||[]).find(p=>String(p.directory||"").toLowerCase()===s);d&&z(d.id||d.directory)},[o.skills]);n.useEffect(()=>{t!=="my"&&te.size&&N(new Set)},[t,te.size]),n.useEffect(()=>{C&&!W&&z(null)},[W,C]);const $e=n.useMemo(()=>{const a=l===E?c:l===O?S:g,d=l===E||l===O||l===se?a:a.filter(_=>`${_.repoOwner}/${_.repoName}`===l),p=P.trim().toLowerCase();return(l===E||!p?d:d.filter(_=>(_.name||"").toLowerCase().includes(p)||(_.directory||"").toLowerCase().includes(p)||(_.description||"").toLowerCase().includes(p))).map(_=>{const Ze=sa(_).toLowerCase(),V=String(_.directory||"").split(/[\\/]/).pop().toLowerCase(),Ae=V?`dir:${V}`:"";return{..._,installed:Ce.has(Ze)||Ae&&Ce.has(Ae)}})},[P,g,Ce,S,c,l]),Wa=e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(Q,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),Xa=e.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[e.jsx(Q,{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")})]}),Fe=(a,s=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(a)}),s]});let Ve;if(ie)Ve=Wa;else if(t==="my")Ve=me.length?e.jsx(Cr,{items:Va,totalCount:me.length,targets:K,agentOptions:K,agentFilter:q,onAgentFilter:he,anyFilter:Aa,onClearFilters:Ka,selectedId:C,onSelect:qa,onToggleTarget:Ue,busyKey:v,updates:J,selectedIds:te,onToggleSelect:ze,onClearSelection:_e,onBulkSync:Pe,onBulkRemove:Qe}):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:[K.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:[...K,...K].map((a,s)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(xe,{provider:a.id,size:30})},`b-${s}`))})}),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:[...K,...K].map((a,s)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(xe,{provider:a.id,size:30})},`c-${s}`))})}),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(U,{type:"button",size:"sm",onClick:()=>i("browse"),children:r("skills.empty.my_cta")})]});else{const a=l===E,s=l===O,d=x.length===0&&!a&&!s,p=we&&!a&&!s||s&&Ne,L=!a&&!s&&(P.trim()!==""||l!==se),_=()=>{b(""),k(se)},Ze=!d&&!p&&($e.length>0||L)?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:$e.length})}),L?e.jsxs("button",{type:"button",onClick:_,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(Me,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]}):null;let V;d?V=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")})}):p?V=Xa:a&&y.trim().length<2?V=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")}):$e.length?V=e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:$e.map(Ie=>e.jsx("div",{style:Sr,children:e.jsx(_r,{skill:Ie,installed:!!Ie.installed,installing:v===Ke(Ie),allTargets:K,defaultTargets:aa,onInstall:$,onManage:Ha})},Ie.id||Ie.key))}):L?V=Fe("skills.empty.no_match",e.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:_,children:r("skills.filter.clear")})):a?V=Fe("skills.empty.search"):s?V=Fe("skills.empty.popular"):V=Fe("skills.empty.browse");const Ae=d||T?e.jsx("div",{className:"mb-5",children:e.jsx(Rr,{repos:x,repoInput:w,onRepoInput:B,busyKey:v,onAdd:ye,onRemove:Je})}):null,Qa=!T&&!a&&!s&&x.length<=1&&$e.length>0?e.jsx(rr,{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:()=>I(!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;Ve=e.jsxs(e.Fragment,{children:[Ae,Ze,V,Qa]})}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(U,{type:"button",variant:"secondary",size:"sm",onClick:Se,disabled:ie||we||Ne,children:[e.jsx(kt,{className:X("mr-1.5 h-3.5 w-3.5",(ie||we||Ne)&&"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(([a,s])=>e.jsx("button",{type:"button","aria-pressed":t===a,onClick:()=>i(a),className:X("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",t===a?"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:s},a))}),Be?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:Be}):null,t==="browse"?e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx("div",{role:"tablist","aria-label":r("skills.source.label"),className:"inline-flex h-10 shrink-0 items-center rounded-md border border-oai-gray-200 bg-oai-white p-1 dark:border-oai-gray-800 dark:bg-oai-gray-900",children:[["repo",r("skills.mode.repo"),l!==E&&l!==O],["popular",r("skills.mode.popular"),l===O],["skillssh",r("skills.mode.skillssh"),l===E]].map(([a,s,d])=>e.jsxs("button",{type:"button",role:"tab","aria-selected":d,onClick:()=>{a==="skillssh"?k(E):a==="popular"?k(O):(l===E||l===O)&&k(se)},className:X("inline-flex items-center gap-1.5 rounded px-3 py-1 text-sm font-medium transition-colors",d?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-700 dark:text-white":"text-oai-gray-500 hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200"),children:[a==="popular"?e.jsx(Yt,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,s]},a))}),l!==E&&l!==O?e.jsxs(Sa,{value:l,onValueChange:k,children:[e.jsxs(_a,{"aria-label":r("skills.source.label"),className:"inline-flex h-10 w-44 shrink-0 items-center justify-between gap-2 rounded-md border border-oai-gray-200 bg-oai-white px-3 text-sm 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(Ra,{children:a=>a===se?r("skills.source.all"):a}),e.jsx(Ta,{className:"text-oai-gray-400",children:e.jsx(ia,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsx(Pa,{children:e.jsx($a,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ia,{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(qe,{value:se,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(Ge,{children:r("skills.source.all")}),e.jsx(He,{children:e.jsx(be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),x.map(a=>{const s=`${a.owner}/${a.name}`;return e.jsxs(qe,{value:s,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(Ge,{children:s}),e.jsx(He,{children:e.jsx(be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},s)})]})})})]}):null,e.jsxs("div",{className:"relative flex-1",children:[e.jsx(da,{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(Ba,{type:"search",value:y,onChange:a=>b(a.target.value),onKeyDown:a=>{a.key==="Enter"&&l===E&&ge()},"aria-label":r("skills.action.search_aria"),placeholder:l===E?r("skills.browse.placeholder_skillssh"):l===O?r("skills.browse.placeholder_popular"):l===se?r("skills.browse.placeholder_all"):r("skills.browse.placeholder_repo",{repo:l}),className:"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"})]}),l===E?e.jsxs(U,{type:"button",onClick:ge,disabled:y.trim().length<2||v==="search",className:"focus:!ring-oai-gray-400/30",children:[v==="search"?e.jsx(Q,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(da,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.action.search")]}):l===O?null:e.jsxs(U,{type:"button",variant:"secondary",size:"sm",onClick:()=>I(a=>!a),"aria-expanded":T,className:"!h-10 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(Ea,{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:x.length})]})]}):null,Ve,e.jsx(pr,{skill:W,targets:K,busyKey:v,usage:W&&(A[String(W.directory||"").toLowerCase()]||A[String(W.name||"").toLowerCase()])||null,hasUpdate:!!(W?.id&&J?.[W.id]),updating:W?v===Ke(W):!1,onUpdate:H,onClose:Ga,onToggleTarget:Ue,onRemove:Xe})]})}),e.jsx(ha,{open:!!Y,title:r("skills.confirm.remove_title",{name:Y?.name||Y?.directory||""}),description:Y?Y.managed?r("skills.confirm.remove_managed"):r("skills.confirm.remove_local"):"",confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:v===ya(Y||{}),onCancel:()=>je(null),onConfirm:ue}),e.jsx(ha,{open:!!ve,title:r("skills.confirm.bulk_remove_title",{count:ve?.length||0}),description:r("skills.confirm.bulk_remove_desc"),confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:v==="batch",onCancel:()=>ae(null),onConfirm:Ye})]})}export{Fr as SkillsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,A as o,bQ as _,aJ as P,r as u,aS as I,R as B,N as M}from"./main-BpChBpB7.js";import{S as D}from"./Select-DksFSHRb.js";import{u as E,T as K}from"./use-native-settings-DWh-bpfp.js";import{F as j,S as $,a as G}from"./FadeIn-CmqK4vog.js";import{A as z}from"./arrow-up-right-CnvG5D97.js";import{D as R}from"./download-C1zysMDD.js";import"./SelectItemText-DmE9ZyEL.js";import"./useOpenInteractionType-2Q4xhr62.js";import"./Card-DnFsEPmk.js";const H=["todayTokens","todayCost"],F=[{id:"todayTokens",label:"Today Tokens",shortLabel:"Tokens",category:"tokens"},{id:"todayCost",label:"Today Cost",shortLabel:"Cost",category:"cost"},{id:"last7dTokens",label:"Last 7 Days",shortLabel:"7d",category:"tokens"},{id:"totalTokens",label:"Total Tokens",shortLabel:"Total",category:"tokens"},{id:"totalCost",label:"Total Cost",shortLabel:"All $",category:"cost"},{id:"claude5h",label:"Claude 5h Limit",shortLabel:"Cl 5h",category:"limits"},{id:"claude7d",label:"Claude 7d Limit",shortLabel:"Cl 7d",category:"limits"},{id:"codex5h",label:"Codex 5h Limit",shortLabel:"Cx 5h",category:"limits"},{id:"codex7d",label:"Codex 7d Limit",shortLabel:"Cx 7d",category:"limits"},{id:"cursorPlan",label:"Cursor Plan Limit",shortLabel:"Cu Plan",category:"limits"},{id:"cursorAuto",label:"Cursor Auto Limit",shortLabel:"Cu Auto",category:"limits"},{id:"cursorAPI",label:"Cursor API Limit",shortLabel:"Cu API",category:"limits"},{id:"geminiPro",label:"Gemini Pro Limit",shortLabel:"Gm Pro",category:"limits"},{id:"geminiFlash",label:"Gemini Flash Limit",shortLabel:"Gm Flash",category:"limits"},{id:"geminiLite",label:"Gemini Lite Limit",shortLabel:"Gm Lite",category:"limits"},{id:"kimiWeekly",label:"Kimi Weekly Limit",shortLabel:"Km Wk",category:"limits"},{id:"kimi5h",label:"Kimi 5h Limit",shortLabel:"Km 5h",category:"limits"},{id:"kimiTotal",label:"Kimi Total Limit",shortLabel:"Km Tot",category:"limits"},{id:"kiroMonth",label:"Kiro Monthly Limit",shortLabel:"Kr Mo",category:"limits"},{id:"kiroBonus",label:"Kiro Bonus Limit",shortLabel:"Kr Bn",category:"limits"},{id:"copilotPremium",label:"Copilot Premium Limit",shortLabel:"Co Prem",category:"limits"},{id:"copilotChat",label:"Copilot Chat Limit",shortLabel:"Co Chat",category:"limits"},{id:"antigravityClaude",label:"Antigravity Claude Limit",shortLabel:"Ag Cl",category:"limits"},{id:"antigravityGPro",label:"Antigravity Gemini Pro Limit",shortLabel:"Ag GPro",category:"limits"},{id:"antigravityFlash",label:"Antigravity Flash Limit",shortLabel:"Ag Fl",category:"limits"}];function v(t,i=F,r=2){const a=new Set(i.map(n=>n.id)),l=new Set,s=Array.isArray(t)?t.filter(n=>!a.has(n)||l.has(n)?!1:(l.add(n),!0)):[];return(s.length>0?s:H).slice(0,Math.max(1,Number(r)||2))}const O=264,U=124,g="ui-rounded, -apple-system, system-ui",L=["#5A8CF2","#9973E6","#4DB8A6","#E68C59"],X={claude:"#C77DFF",codex:"#34C759",cursor:"#FFCC00",gemini:"#0A84FF"};function V(t){return t>=.9?"#E64D4D":t>=.7?"#D9A633":"#33B866"}function b({size:t="sm",children:i}){const r=t==="lg",a=r?560:264,l=r?32:22;return e.jsx("div",{className:M("flex w-full items-center justify-center rounded-xl bg-oai-gray-100 dark:bg-oai-gray-950/60",r?"py-10 sm:py-14 px-6":"py-6 px-4"),children:e.jsx("div",{className:"overflow-hidden bg-white dark:bg-oai-gray-800 shadow-oai-md dark:shadow-[0_2px_4px_rgba(0,0,0,0.4),0_8px_24px_rgba(0,0,0,0.5)]",style:{width:"100%",maxWidth:a,aspectRatio:`${O} / ${U}`,borderRadius:l},children:i})})}function Y({size:t="sm"}){const i="M0,104 L14,104 C26,98 34,100 44,96 S58,88 68,92 80,100 90,94 102,80 112,82 126,92 136,88 150,74 162,76 178,88 188,86 204,72 216,74 236,84 250,80 L264,80",r=`${i} L264,124 L0,124 Z`,a=`sparkArea-${t}`;return e.jsx(b,{size:t,children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:a,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#0A84FF",stopOpacity:"0.18"}),e.jsx("stop",{offset:"100%",stopColor:"#0A84FF",stopOpacity:"0"})]})}),e.jsx("text",{x:"14",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"TODAY"}),e.jsx("text",{x:"14",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:g,children:"203.2M"}),e.jsx("text",{x:"14",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:g,children:"$129.56 ±0%"}),e.jsx("text",{x:"134",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"7 DAYS"}),e.jsx("text",{x:"134",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:g,children:"880.9M"}),e.jsx("text",{x:"134",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:g,children:"$673.61"}),e.jsx("path",{d:r,fill:`url(#${a})`,stroke:"none"}),e.jsx("path",{d:i,fill:"none",stroke:"#0A84FF",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const N=(()=>{const r=[];for(let a=0;a<26;a++)for(let l=0;l<7;l++){const s=Math.sin((a+1)*12.9898+(l+1)*78.233+17)*43758.5453,c=Math.floor(Math.abs(s-Math.floor(s))*100);r.push({w:a,d:l,v:c})}return r})();function C(t,i){return t<18?i?"#262626":"#e5e5e5":t<38?"rgba(10, 132, 255, 0.28)":t<58?"rgba(10, 132, 255, 0.50)":t<80?"rgba(10, 132, 255, 0.75)":"#0A84FF"}function J(){return e.jsx(b,{children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"hidden dark:inline",children:N.map(s=>e.jsx("rect",{x:s.w*(7.5+1.2),y:s.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:C(s.v,!0)},`d-${s.w}-${s.d}`))}),e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"dark:hidden",children:N.map(s=>e.jsx("rect",{x:s.w*(7.5+1.2),y:s.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:C(s.v,!1)},`l-${s.w}-${s.d}`))}),e.jsx("text",{x:19.5,y:"102",className:"fill-oai-black dark:fill-white",fontSize:"10",fontWeight:"700",fontFamily:g,children:"10.3B"}),e.jsx("text",{x:19.5+30,y:"102",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"500",children:"tokens · 202 active days"})]})})}function Q(){const t=[{name:"claude-opus-4-6",value:"586.4M",pct:59},{name:"claude-sonnet-4-5-20250929",value:"218.7M",pct:22},{name:"gpt-5.4",value:"80.6M",pct:8},{name:"composer-2-fast",value:"52.1M",pct:5}],i=22,r=28,a=14,l=236;return e.jsx(b,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((s,c)=>{const n=r+c*i,h=L[c%L.length];return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:n-3,r:"2.5",fill:h}),e.jsx("text",{x:"26",y:n,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:s.name}),e.jsx("text",{x:"218",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"600",fontFamily:g,children:s.value}),e.jsxs("text",{x:"250",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"600",fontFamily:g,children:[s.pct,"%"]}),e.jsx("rect",{x:a,y:n+4,width:l,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:a,y:n+4,width:Math.max(l*(s.pct/100),4),height:"2.8",rx:"1.4",fill:h})]},s.name)})})})}function Z(){const t=[{label:"Claude · 7d",source:"claude",reset:"in 1d",pct:61},{label:"Claude · 5h",source:"claude",reset:"in 4h 28m",pct:4},{label:"Cursor",source:"cursor",reset:"in 25d",pct:51},{label:"Codex · weekly",source:"codex",reset:"in 1d",pct:32}],i=22,r=28,a=14,l=236;return e.jsx(b,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((s,c)=>{const n=r+c*i,h=X[s.source],y=V(s.pct/100);return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:n-3,r:"2.5",fill:h}),e.jsx("text",{x:"26",y:n,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:s.label}),e.jsx("text",{x:"218",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:g,children:s.reset}),e.jsxs("text",{x:"250",y:n,textAnchor:"end",className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"700",fontFamily:g,children:[s.pct,"%"]}),e.jsx("rect",{x:a,y:n+4,width:l,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:a,y:n+4,width:Math.max(l*(s.pct/100),4),height:"2.8",rx:"1.4",fill:y})]},s.label)})})})}function q(t){switch(t.category){case"cost":return"$8.42";case"limits":return"62%";default:return t.id==="last7dTokens"?"1.8B":"203M"}}function ee(t,i){switch(t){case"todayTokens":return o("menubar.metric.today_tokens");case"todayCost":return o("menubar.metric.today_cost");case"last7dTokens":return o("menubar.metric.last_7d_tokens");case"totalTokens":return o("menubar.metric.total_tokens");case"totalCost":return o("menubar.metric.total_cost");case"claude5h":return o("menubar.metric.claude_5h");case"claude7d":return o("menubar.metric.claude_7d");case"codex5h":return o("menubar.metric.codex_5h");case"codex7d":return o("menubar.metric.codex_7d");default:return i}}function te(t,i){const r=new Set(i.map(l=>l.id)),a=t.filter(l=>r.has(l));for(const l of i){if(a.length>=2)break;a.includes(l.id)||a.push(l.id)}return a.slice(0,2)}function ae({slotConfigs:t,showStats:i}){return e.jsx("div",{className:"flex justify-center rounded-xl bg-gradient-to-b from-oai-gray-100 to-oai-gray-200 px-6 py-8 dark:from-oai-gray-950/80 dark:to-oai-gray-900/80",children:e.jsxs("div",{className:"inline-flex items-stretch rounded-md shadow-[0_1px_3px_rgba(0,0,0,0.18)] ring-1 ring-black/10 dark:ring-white/10 px-3",style:{background:"linear-gradient(180deg, #2c2c2e 0%, #1c1c1e 100%)"},children:[e.jsx("div",{className:"flex items-center pl-2 pr-1 py-2.5",children:e.jsx("img",{src:"/clawd/mini/idle-tight.svg",alt:"","aria-hidden":"true",className:"block shrink-0",style:{height:22,width:"auto"},draggable:"false"})}),i?t.map(({slot:r,item:a},l)=>e.jsxs(B.Fragment,{children:[l>0?e.jsx("span",{className:"my-1 w-px bg-white/20","aria-hidden":"true"}):null,e.jsxs("div",{className:M("flex min-w-[52px] flex-col items-center justify-center py-1.5",l===0?"pl-1 pr-2":"px-2"),children:[e.jsx("span",{className:"text-[13px] font-semibold leading-none tabular-nums text-white",children:a?.previewValue||"--"}),e.jsx("span",{className:"mt-[2px] text-[6px] font-semibold uppercase leading-none text-white/75",children:a?.shortLabel||"Metric"})]})]},r)):null]})})}function ie({slot:t,value:i,options:r,disabled:a,onChange:l}){const s=t===0?o("menubar.slot.primary"):o("menubar.slot.secondary");return e.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400",children:s}),e.jsx(D,{value:i,disabled:a,ariaLabel:s,onValueChange:c=>l(t,c),options:r.map(c=>({value:c.id,label:c.displayLabel})),matchTriggerWidth:!0,className:"w-full px-3 py-2 text-sm font-medium"})]})}function S({label:t,hint:i,checked:r,disabled:a,onChange:l}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),i?e.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i}):null]}),e.jsx(K,{checked:r,disabled:a,onChange:l,ariaLabel:t})]})}function se(){const{available:t,settings:i,setSetting:r}=E(),a=u.useMemo(()=>(Array.isArray(i?.menuBarAvailableItems)?i.menuBarAvailableItems:F).map(m=>({...m,displayLabel:ee(m.id,m.label),previewValue:q(m)})),[i?.menuBarAvailableItems]),l=Number(i?.menuBarMaxItems)||2,s=u.useMemo(()=>v(i?.menuBarItems,a,l),[a,l,i?.menuBarItems]),c=u.useMemo(()=>te(s,a),[a,s]),n=i?.showStats!==!1,h=d=>{r("menuBarItems",v(d,a,l))},y=(d,m)=>{const x=[...c];x[d===0?1:0]!==m&&(x[d]=m,h(x))},p=[0,1].map(d=>{const m=c[d]||a[d]?.id||"",k=c[d===0?1:0],W=a.filter(f=>f.id===m||f.id!==k),T=a.find(f=>f.id===m);return{slot:d,currentValue:m,options:W,item:T}}),w=i?.animatedIcon!==!1;return e.jsxs("article",{className:"rounded-xl border border-oai-gray-200 bg-white p-5 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-6",children:[e.jsx(ae,{slotConfigs:p,showStats:n}),e.jsx("div",{className:"mt-5 grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:p.map(({slot:d,currentValue:m,options:x})=>e.jsx(ie,{slot:d,value:m,options:x,disabled:!t||!n,onChange:y},d))}),e.jsxs("div",{className:"mt-5 divide-y divide-oai-gray-100 border-t border-oai-gray-100 dark:divide-oai-gray-800 dark:border-oai-gray-800",children:[e.jsx(S,{label:o("settings.menubar.showStats"),hint:t?o("settings.menubar.showStatsHint"):o("menubar.native_only"),checked:n,disabled:!t,onChange:()=>r("showStats",!n)}),e.jsx(S,{label:o("settings.menubar.animatedIcon"),hint:o("settings.menubar.animatedIconHint"),checked:w,disabled:!t,onChange:()=>r("animatedIcon",!w)})]})]})}function re(){const[t,i]=u.useState("loading");return u.useEffect(()=>{if(typeof window>"u")return;if(I()){i("native");return}const r=(navigator.userAgent||"").toLowerCase(),a=/mac/.test(r)&&!/iphone|ipad/.test(r);i(a?"mac-web":"other")},[]),t}function le(){const t=re();return t==="loading"?e.jsx("div",{className:"h-10 w-40","aria-hidden":"true"}):t==="native"?e.jsxs("button",{type:"button",onClick:()=>_("openWidgetGallery"),className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[o("widgets.cta.open_gallery"),e.jsx(z,{className:"h-4 w-4","aria-hidden":"true"})]}):t==="mac-web"?e.jsxs("a",{href:"https://github.com/mm7894215/TokenTracker/releases/latest",target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white no-underline transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[e.jsx(R,{className:"h-4 w-4","aria-hidden":"true"}),o("widgets.cta.download")]}):e.jsxs("span",{className:"inline-flex h-10 items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 text-sm font-medium text-oai-gray-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-400",children:[e.jsx(P,{className:"h-4 w-4","aria-hidden":"true"}),o("widgets.cta.macos_only")]})}const oe=[{id:"summary",Preview:Y,nameKey:"widgets.summary.name",descKey:"widgets.summary.description"},{id:"heatmap",Preview:J,nameKey:"widgets.heatmap.name",descKey:"widgets.heatmap.description"},{id:"topModels",Preview:Q,nameKey:"widgets.topModels.name",descKey:"widgets.topModels.description"},{id:"limits",Preview:Z,nameKey:"widgets.limits.name",descKey:"widgets.limits.description"}];function ne({Preview:t,nameKey:i,descKey:r}){return e.jsxs("article",{className:"flex h-full flex-col rounded-xl border border-oai-gray-200 bg-white p-4 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-5",children:[e.jsx(t,{}),e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:o(i)}),e.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:o(r)})]})]})}function A({titleKey:t}){return e.jsx("h2",{className:"mb-4 text-xl font-semibold tracking-tight text-oai-black dark:text-white sm:mb-5 sm:text-2xl",children:o(t)})}function ye(){return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[e.jsx(j,{y:12,children:e.jsxs("header",{className:"mb-10 flex items-start justify-between gap-4 sm:mb-12",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:o("widgets.page.title")}),e.jsx("div",{className:"shrink-0",children:e.jsx(le,{})})]})}),e.jsx(j,{y:12,delay:.06,children:e.jsxs("section",{"aria-label":o("widgets.menubar.section.title"),className:"mb-12 sm:mb-14",children:[e.jsx(A,{titleKey:"widgets.menubar.section.title"}),e.jsx(se,{})]})}),e.jsxs("section",{"aria-label":o("widgets.gallery.section.title"),children:[e.jsx(A,{titleKey:"widgets.gallery.section.title"}),e.jsx($,{staggerDelay:.08,initialDelay:.04,children:e.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-5",children:oe.map(({id:t,Preview:i,nameKey:r,descKey:a})=>e.jsx(G,{children:e.jsx(ne,{Preview:i,nameKey:r,descKey:a})},t))})})]})]})})})}export{ye as WidgetsPage};
|
|
1
|
+
import{j as e,A as o,bQ as _,aJ as P,r as u,aS as I,R as B,N as M}from"./main-BZBATt4l.js";import{S as D}from"./Select-aIEVSJVR.js";import{u as E,T as K}from"./use-native-settings-HjLLYUkn.js";import{F as j,S as $,a as G}from"./FadeIn-DFk4dbUG.js";import{A as z}from"./arrow-up-right-RH7MeYHL.js";import{D as R}from"./download-Ds1ViaQ9.js";import"./SelectItemText-BH_vsFMS.js";import"./useOpenInteractionType-B65bQ4-n.js";import"./Card-eNDH0TxH.js";const H=["todayTokens","todayCost"],F=[{id:"todayTokens",label:"Today Tokens",shortLabel:"Tokens",category:"tokens"},{id:"todayCost",label:"Today Cost",shortLabel:"Cost",category:"cost"},{id:"last7dTokens",label:"Last 7 Days",shortLabel:"7d",category:"tokens"},{id:"totalTokens",label:"Total Tokens",shortLabel:"Total",category:"tokens"},{id:"totalCost",label:"Total Cost",shortLabel:"All $",category:"cost"},{id:"claude5h",label:"Claude 5h Limit",shortLabel:"Cl 5h",category:"limits"},{id:"claude7d",label:"Claude 7d Limit",shortLabel:"Cl 7d",category:"limits"},{id:"codex5h",label:"Codex 5h Limit",shortLabel:"Cx 5h",category:"limits"},{id:"codex7d",label:"Codex 7d Limit",shortLabel:"Cx 7d",category:"limits"},{id:"cursorPlan",label:"Cursor Plan Limit",shortLabel:"Cu Plan",category:"limits"},{id:"cursorAuto",label:"Cursor Auto Limit",shortLabel:"Cu Auto",category:"limits"},{id:"cursorAPI",label:"Cursor API Limit",shortLabel:"Cu API",category:"limits"},{id:"geminiPro",label:"Gemini Pro Limit",shortLabel:"Gm Pro",category:"limits"},{id:"geminiFlash",label:"Gemini Flash Limit",shortLabel:"Gm Flash",category:"limits"},{id:"geminiLite",label:"Gemini Lite Limit",shortLabel:"Gm Lite",category:"limits"},{id:"kimiWeekly",label:"Kimi Weekly Limit",shortLabel:"Km Wk",category:"limits"},{id:"kimi5h",label:"Kimi 5h Limit",shortLabel:"Km 5h",category:"limits"},{id:"kimiTotal",label:"Kimi Total Limit",shortLabel:"Km Tot",category:"limits"},{id:"kiroMonth",label:"Kiro Monthly Limit",shortLabel:"Kr Mo",category:"limits"},{id:"kiroBonus",label:"Kiro Bonus Limit",shortLabel:"Kr Bn",category:"limits"},{id:"copilotPremium",label:"Copilot Premium Limit",shortLabel:"Co Prem",category:"limits"},{id:"copilotChat",label:"Copilot Chat Limit",shortLabel:"Co Chat",category:"limits"},{id:"antigravityClaude",label:"Antigravity Claude Limit",shortLabel:"Ag Cl",category:"limits"},{id:"antigravityGPro",label:"Antigravity Gemini Pro Limit",shortLabel:"Ag GPro",category:"limits"},{id:"antigravityFlash",label:"Antigravity Flash Limit",shortLabel:"Ag Fl",category:"limits"}];function v(t,i=F,r=2){const a=new Set(i.map(n=>n.id)),l=new Set,s=Array.isArray(t)?t.filter(n=>!a.has(n)||l.has(n)?!1:(l.add(n),!0)):[];return(s.length>0?s:H).slice(0,Math.max(1,Number(r)||2))}const O=264,U=124,g="ui-rounded, -apple-system, system-ui",L=["#5A8CF2","#9973E6","#4DB8A6","#E68C59"],X={claude:"#C77DFF",codex:"#34C759",cursor:"#FFCC00",gemini:"#0A84FF"};function V(t){return t>=.9?"#E64D4D":t>=.7?"#D9A633":"#33B866"}function b({size:t="sm",children:i}){const r=t==="lg",a=r?560:264,l=r?32:22;return e.jsx("div",{className:M("flex w-full items-center justify-center rounded-xl bg-oai-gray-100 dark:bg-oai-gray-950/60",r?"py-10 sm:py-14 px-6":"py-6 px-4"),children:e.jsx("div",{className:"overflow-hidden bg-white dark:bg-oai-gray-800 shadow-oai-md dark:shadow-[0_2px_4px_rgba(0,0,0,0.4),0_8px_24px_rgba(0,0,0,0.5)]",style:{width:"100%",maxWidth:a,aspectRatio:`${O} / ${U}`,borderRadius:l},children:i})})}function Y({size:t="sm"}){const i="M0,104 L14,104 C26,98 34,100 44,96 S58,88 68,92 80,100 90,94 102,80 112,82 126,92 136,88 150,74 162,76 178,88 188,86 204,72 216,74 236,84 250,80 L264,80",r=`${i} L264,124 L0,124 Z`,a=`sparkArea-${t}`;return e.jsx(b,{size:t,children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:a,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#0A84FF",stopOpacity:"0.18"}),e.jsx("stop",{offset:"100%",stopColor:"#0A84FF",stopOpacity:"0"})]})}),e.jsx("text",{x:"14",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"TODAY"}),e.jsx("text",{x:"14",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:g,children:"203.2M"}),e.jsx("text",{x:"14",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:g,children:"$129.56 ±0%"}),e.jsx("text",{x:"134",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"7 DAYS"}),e.jsx("text",{x:"134",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:g,children:"880.9M"}),e.jsx("text",{x:"134",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:g,children:"$673.61"}),e.jsx("path",{d:r,fill:`url(#${a})`,stroke:"none"}),e.jsx("path",{d:i,fill:"none",stroke:"#0A84FF",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const N=(()=>{const r=[];for(let a=0;a<26;a++)for(let l=0;l<7;l++){const s=Math.sin((a+1)*12.9898+(l+1)*78.233+17)*43758.5453,c=Math.floor(Math.abs(s-Math.floor(s))*100);r.push({w:a,d:l,v:c})}return r})();function C(t,i){return t<18?i?"#262626":"#e5e5e5":t<38?"rgba(10, 132, 255, 0.28)":t<58?"rgba(10, 132, 255, 0.50)":t<80?"rgba(10, 132, 255, 0.75)":"#0A84FF"}function J(){return e.jsx(b,{children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"hidden dark:inline",children:N.map(s=>e.jsx("rect",{x:s.w*(7.5+1.2),y:s.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:C(s.v,!0)},`d-${s.w}-${s.d}`))}),e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"dark:hidden",children:N.map(s=>e.jsx("rect",{x:s.w*(7.5+1.2),y:s.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:C(s.v,!1)},`l-${s.w}-${s.d}`))}),e.jsx("text",{x:19.5,y:"102",className:"fill-oai-black dark:fill-white",fontSize:"10",fontWeight:"700",fontFamily:g,children:"10.3B"}),e.jsx("text",{x:19.5+30,y:"102",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"500",children:"tokens · 202 active days"})]})})}function Q(){const t=[{name:"claude-opus-4-6",value:"586.4M",pct:59},{name:"claude-sonnet-4-5-20250929",value:"218.7M",pct:22},{name:"gpt-5.4",value:"80.6M",pct:8},{name:"composer-2-fast",value:"52.1M",pct:5}],i=22,r=28,a=14,l=236;return e.jsx(b,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((s,c)=>{const n=r+c*i,h=L[c%L.length];return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:n-3,r:"2.5",fill:h}),e.jsx("text",{x:"26",y:n,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:s.name}),e.jsx("text",{x:"218",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"600",fontFamily:g,children:s.value}),e.jsxs("text",{x:"250",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"600",fontFamily:g,children:[s.pct,"%"]}),e.jsx("rect",{x:a,y:n+4,width:l,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:a,y:n+4,width:Math.max(l*(s.pct/100),4),height:"2.8",rx:"1.4",fill:h})]},s.name)})})})}function Z(){const t=[{label:"Claude · 7d",source:"claude",reset:"in 1d",pct:61},{label:"Claude · 5h",source:"claude",reset:"in 4h 28m",pct:4},{label:"Cursor",source:"cursor",reset:"in 25d",pct:51},{label:"Codex · weekly",source:"codex",reset:"in 1d",pct:32}],i=22,r=28,a=14,l=236;return e.jsx(b,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((s,c)=>{const n=r+c*i,h=X[s.source],y=V(s.pct/100);return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:n-3,r:"2.5",fill:h}),e.jsx("text",{x:"26",y:n,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:s.label}),e.jsx("text",{x:"218",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:g,children:s.reset}),e.jsxs("text",{x:"250",y:n,textAnchor:"end",className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"700",fontFamily:g,children:[s.pct,"%"]}),e.jsx("rect",{x:a,y:n+4,width:l,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:a,y:n+4,width:Math.max(l*(s.pct/100),4),height:"2.8",rx:"1.4",fill:y})]},s.label)})})})}function q(t){switch(t.category){case"cost":return"$8.42";case"limits":return"62%";default:return t.id==="last7dTokens"?"1.8B":"203M"}}function ee(t,i){switch(t){case"todayTokens":return o("menubar.metric.today_tokens");case"todayCost":return o("menubar.metric.today_cost");case"last7dTokens":return o("menubar.metric.last_7d_tokens");case"totalTokens":return o("menubar.metric.total_tokens");case"totalCost":return o("menubar.metric.total_cost");case"claude5h":return o("menubar.metric.claude_5h");case"claude7d":return o("menubar.metric.claude_7d");case"codex5h":return o("menubar.metric.codex_5h");case"codex7d":return o("menubar.metric.codex_7d");default:return i}}function te(t,i){const r=new Set(i.map(l=>l.id)),a=t.filter(l=>r.has(l));for(const l of i){if(a.length>=2)break;a.includes(l.id)||a.push(l.id)}return a.slice(0,2)}function ae({slotConfigs:t,showStats:i}){return e.jsx("div",{className:"flex justify-center rounded-xl bg-gradient-to-b from-oai-gray-100 to-oai-gray-200 px-6 py-8 dark:from-oai-gray-950/80 dark:to-oai-gray-900/80",children:e.jsxs("div",{className:"inline-flex items-stretch rounded-md shadow-[0_1px_3px_rgba(0,0,0,0.18)] ring-1 ring-black/10 dark:ring-white/10 px-3",style:{background:"linear-gradient(180deg, #2c2c2e 0%, #1c1c1e 100%)"},children:[e.jsx("div",{className:"flex items-center pl-2 pr-1 py-2.5",children:e.jsx("img",{src:"/clawd/mini/idle-tight.svg",alt:"","aria-hidden":"true",className:"block shrink-0",style:{height:22,width:"auto"},draggable:"false"})}),i?t.map(({slot:r,item:a},l)=>e.jsxs(B.Fragment,{children:[l>0?e.jsx("span",{className:"my-1 w-px bg-white/20","aria-hidden":"true"}):null,e.jsxs("div",{className:M("flex min-w-[52px] flex-col items-center justify-center py-1.5",l===0?"pl-1 pr-2":"px-2"),children:[e.jsx("span",{className:"text-[13px] font-semibold leading-none tabular-nums text-white",children:a?.previewValue||"--"}),e.jsx("span",{className:"mt-[2px] text-[6px] font-semibold uppercase leading-none text-white/75",children:a?.shortLabel||"Metric"})]})]},r)):null]})})}function ie({slot:t,value:i,options:r,disabled:a,onChange:l}){const s=t===0?o("menubar.slot.primary"):o("menubar.slot.secondary");return e.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400",children:s}),e.jsx(D,{value:i,disabled:a,ariaLabel:s,onValueChange:c=>l(t,c),options:r.map(c=>({value:c.id,label:c.displayLabel})),matchTriggerWidth:!0,className:"w-full px-3 py-2 text-sm font-medium"})]})}function S({label:t,hint:i,checked:r,disabled:a,onChange:l}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),i?e.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i}):null]}),e.jsx(K,{checked:r,disabled:a,onChange:l,ariaLabel:t})]})}function se(){const{available:t,settings:i,setSetting:r}=E(),a=u.useMemo(()=>(Array.isArray(i?.menuBarAvailableItems)?i.menuBarAvailableItems:F).map(m=>({...m,displayLabel:ee(m.id,m.label),previewValue:q(m)})),[i?.menuBarAvailableItems]),l=Number(i?.menuBarMaxItems)||2,s=u.useMemo(()=>v(i?.menuBarItems,a,l),[a,l,i?.menuBarItems]),c=u.useMemo(()=>te(s,a),[a,s]),n=i?.showStats!==!1,h=d=>{r("menuBarItems",v(d,a,l))},y=(d,m)=>{const x=[...c];x[d===0?1:0]!==m&&(x[d]=m,h(x))},p=[0,1].map(d=>{const m=c[d]||a[d]?.id||"",k=c[d===0?1:0],W=a.filter(f=>f.id===m||f.id!==k),T=a.find(f=>f.id===m);return{slot:d,currentValue:m,options:W,item:T}}),w=i?.animatedIcon!==!1;return e.jsxs("article",{className:"rounded-xl border border-oai-gray-200 bg-white p-5 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-6",children:[e.jsx(ae,{slotConfigs:p,showStats:n}),e.jsx("div",{className:"mt-5 grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:p.map(({slot:d,currentValue:m,options:x})=>e.jsx(ie,{slot:d,value:m,options:x,disabled:!t||!n,onChange:y},d))}),e.jsxs("div",{className:"mt-5 divide-y divide-oai-gray-100 border-t border-oai-gray-100 dark:divide-oai-gray-800 dark:border-oai-gray-800",children:[e.jsx(S,{label:o("settings.menubar.showStats"),hint:t?o("settings.menubar.showStatsHint"):o("menubar.native_only"),checked:n,disabled:!t,onChange:()=>r("showStats",!n)}),e.jsx(S,{label:o("settings.menubar.animatedIcon"),hint:o("settings.menubar.animatedIconHint"),checked:w,disabled:!t,onChange:()=>r("animatedIcon",!w)})]})]})}function re(){const[t,i]=u.useState("loading");return u.useEffect(()=>{if(typeof window>"u")return;if(I()){i("native");return}const r=(navigator.userAgent||"").toLowerCase(),a=/mac/.test(r)&&!/iphone|ipad/.test(r);i(a?"mac-web":"other")},[]),t}function le(){const t=re();return t==="loading"?e.jsx("div",{className:"h-10 w-40","aria-hidden":"true"}):t==="native"?e.jsxs("button",{type:"button",onClick:()=>_("openWidgetGallery"),className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[o("widgets.cta.open_gallery"),e.jsx(z,{className:"h-4 w-4","aria-hidden":"true"})]}):t==="mac-web"?e.jsxs("a",{href:"https://github.com/mm7894215/TokenTracker/releases/latest",target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white no-underline transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[e.jsx(R,{className:"h-4 w-4","aria-hidden":"true"}),o("widgets.cta.download")]}):e.jsxs("span",{className:"inline-flex h-10 items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 text-sm font-medium text-oai-gray-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-400",children:[e.jsx(P,{className:"h-4 w-4","aria-hidden":"true"}),o("widgets.cta.macos_only")]})}const oe=[{id:"summary",Preview:Y,nameKey:"widgets.summary.name",descKey:"widgets.summary.description"},{id:"heatmap",Preview:J,nameKey:"widgets.heatmap.name",descKey:"widgets.heatmap.description"},{id:"topModels",Preview:Q,nameKey:"widgets.topModels.name",descKey:"widgets.topModels.description"},{id:"limits",Preview:Z,nameKey:"widgets.limits.name",descKey:"widgets.limits.description"}];function ne({Preview:t,nameKey:i,descKey:r}){return e.jsxs("article",{className:"flex h-full flex-col rounded-xl border border-oai-gray-200 bg-white p-4 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-5",children:[e.jsx(t,{}),e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:o(i)}),e.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:o(r)})]})]})}function A({titleKey:t}){return e.jsx("h2",{className:"mb-4 text-xl font-semibold tracking-tight text-oai-black dark:text-white sm:mb-5 sm:text-2xl",children:o(t)})}function ye(){return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[e.jsx(j,{y:12,children:e.jsxs("header",{className:"mb-10 flex items-start justify-between gap-4 sm:mb-12",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:o("widgets.page.title")}),e.jsx("div",{className:"shrink-0",children:e.jsx(le,{})})]})}),e.jsx(j,{y:12,delay:.06,children:e.jsxs("section",{"aria-label":o("widgets.menubar.section.title"),className:"mb-12 sm:mb-14",children:[e.jsx(A,{titleKey:"widgets.menubar.section.title"}),e.jsx(se,{})]})}),e.jsxs("section",{"aria-label":o("widgets.gallery.section.title"),children:[e.jsx(A,{titleKey:"widgets.gallery.section.title"}),e.jsx($,{staggerDelay:.08,initialDelay:.04,children:e.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-5",children:oe.map(({id:t,Preview:i,nameKey:r,descKey:a})=>e.jsx(G,{children:e.jsx(ne,{Preview:i,nameKey:r,descKey:a})},t))})})]})]})})})}export{ye as WidgetsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,j as e,D as y}from"./main-
|
|
1
|
+
import{r as l,j as e,D as y}from"./main-BZBATt4l.js";function o(a){return Number.isFinite(a)?Math.abs(a)>=1e12?(a/1e12).toFixed(2).replace(/\.?0+$/,"")+"T":y(a,{decimals:2}):"0"}function r({children:a,accent:n=!1,className:i=""}){const c="rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 p-6 bg-white dark:bg-oai-gray-900",d=n?"bg-gradient-to-br from-emerald-50 to-cyan-50 dark:from-emerald-900/30 dark:to-cyan-900/30 border-transparent":"";return e.jsx("div",{className:`${c} ${d} ${i}`,children:a})}function u(){const[a,n]=l.useState(null),[i,c]=l.useState("loading"),[d,g]=l.useState("");if(l.useEffect(()=>{let t=!1;const h=new URLSearchParams(window.location.search).get("year"),p=h?`/functions/tokentracker-wrapped?year=${encodeURIComponent(h)}`:"/functions/tokentracker-wrapped";return fetch(p).then(async s=>{if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}).then(s=>{t||(n(s),c(s.totals&&s.totals.tokens>0?"ready":"empty"))}).catch(s=>{t||(g(String(s?.message||s)),c("error"))}),()=>{t=!0}},[]),i==="loading")return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center",children:e.jsx("p",{className:"text-oai-gray-500",children:"Loading…"})});if(i==="error")return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center px-6",children:e.jsx(r,{children:e.jsxs("p",{className:"text-red-600 dark:text-red-300",children:["Couldn't load Wrapped: ",d]})})});if(i==="empty"||!a)return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center px-6",children:e.jsx(r,{children:e.jsxs("p",{className:"text-oai-gray-500",children:["No data for that year yet. Run ",e.jsx("code",{children:"tracker sync"})," first."]})})});const x=t=>`${(t*100).toFixed(0)}%`;return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-white to-oai-gray-50 dark:from-oai-gray-950 dark:to-oai-gray-900 px-6 py-12",children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[e.jsxs("header",{className:"text-center pb-6",children:[e.jsx("p",{className:"text-sm uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:"TokenTracker Wrapped"}),e.jsx("h1",{className:"text-6xl font-bold text-oai-gray-900 dark:text-white mt-2",children:a.year})]}),e.jsxs(r,{accent:!0,className:"text-center",children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-600 dark:text-oai-gray-300",children:"Total tokens"}),e.jsx("p",{className:"text-7xl font-bold text-emerald-700 dark:text-emerald-300 mt-2",children:o(a.totals.tokens)}),e.jsxs("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-4",children:["across ",e.jsx("strong",{children:a.totals.conversations.toLocaleString("en-US")})," conversations,"," ",e.jsx("strong",{children:a.totals.active_days})," active days, and"," ",e.jsx("strong",{children:a.totals.sources})," tools"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs(r,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:"Top tools"}),e.jsx("ul",{className:"space-y-3",children:a.top.sources.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white",children:t.source}),e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm",children:[o(t.tokens)," · ",x(t.share)]})]},t.source))})]}),e.jsxs(r,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:"Top models"}),e.jsx("ul",{className:"space-y-3",children:a.top.models.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white truncate pr-3",children:t.model}),e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm whitespace-nowrap",children:[o(t.tokens)," · ",x(t.share)]})]},t.model))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.peak_hour&&e.jsxs(r,{children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:"Peak hour"}),e.jsxs("p",{className:"text-4xl font-semibold text-oai-gray-900 dark:text-white mt-2",children:[String(a.peak_hour.hour).padStart(2,"0"),":00 UTC"]}),e.jsxs("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-1",children:[o(a.peak_hour.tokens)," tokens"]})]}),a.longest_streak&&a.longest_streak.days>0&&e.jsxs(r,{children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:"Longest streak"}),e.jsxs("p",{className:"text-4xl font-semibold text-oai-gray-900 dark:text-white mt-2",children:[a.longest_streak.days," days"]}),e.jsxs("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-1",children:[a.longest_streak.from," → ",a.longest_streak.to]})]})]}),a.top.days.length>0&&e.jsxs(r,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:"Top days"}),e.jsx("ul",{className:"space-y-2",children:a.top.days.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white font-mono text-sm",children:t.day}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm",children:o(t.tokens)})]},t.day))})]}),a.highlights.length>0&&e.jsxs(r,{accent:!0,children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-600 dark:text-oai-gray-300 mb-3",children:"Highlights"}),e.jsx("ul",{className:"space-y-2 text-oai-gray-800 dark:text-oai-gray-200",children:a.highlights.map((t,m)=>e.jsxs("li",{className:"text-base",children:["· ",t]},m))})]}),e.jsxs("footer",{className:"text-center text-xs text-oai-gray-400 dark:text-oai-gray-500 pt-6",children:["Generated from local queue.jsonl · share with"," ",e.jsx("code",{className:"font-mono",children:"tracker wrapped --json"})]})]})})}export{u as default};
|