tokentracker-cli 0.95.2 → 0.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-DtB1MwFe.js → AchievementBadge-Bb2ljquW.js} +1 -1
  2. package/dashboard/dist/assets/{AchievementsPage--vddu0dC.js → AchievementsPage-ByUP2x8a.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-CDl9hsbj.js → AchievementsSection-_L6sCLTw.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-C7WsIRy9.js → BadgeDetailModal-B9n_-45B.js} +1 -1
  5. package/dashboard/dist/assets/{BotAnimated-CmXyzIhX.js → BotAnimated-lWmg-aZg.js} +1 -1
  6. package/dashboard/dist/assets/{Card-SUbC3VNS.js → Card-aSp259T0.js} +1 -1
  7. package/dashboard/dist/assets/{ClawdAnimated-BdEbs8Me.js → ClawdAnimated-Cy-XaTXW.js} +2 -2
  8. package/dashboard/dist/assets/{CommandPalette-D1RLLeHB.js → CommandPalette-CNwtKCUm.js} +1 -1
  9. package/dashboard/dist/assets/{CommunityStatsModal-5ESGJgZQ.js → CommunityStatsModal-DJSezaPV.js} +1 -1
  10. package/dashboard/dist/assets/{ConfirmModal-DsCd51b2.js → ConfirmModal-CVjmhZd6.js} +1 -1
  11. package/dashboard/dist/assets/{Controls-BVrLC_QD.js → Controls-BIj6yVxE.js} +1 -1
  12. package/dashboard/dist/assets/{DashboardPage-DtUOG6og.js → DashboardPage-BjYZLmqQ.js} +1 -1
  13. package/dashboard/dist/assets/{DevicePage-zYjj-m5V.js → DevicePage-ptsI2fZc.js} +1 -1
  14. package/dashboard/dist/assets/{DialogClose-D66yBqkd.js → DialogClose-D1pLoZ56.js} +1 -1
  15. package/dashboard/dist/assets/DialogDescription-KY7X94CG.js +1 -0
  16. package/dashboard/dist/assets/{DialogTitle-C4ia00lc.js → DialogTitle-DfSBUjWf.js} +1 -1
  17. package/dashboard/dist/assets/{FadeIn-DF2c8XaR.js → FadeIn-DBn4L_BV.js} +1 -1
  18. package/dashboard/dist/assets/{HeaderGithubStar-Cnr3aqcX.js → HeaderGithubStar-EJLBwEqp.js} +1 -1
  19. package/dashboard/dist/assets/{HoverTooltip-DBOpxlH7.js → HoverTooltip-DaSrZhYd.js} +1 -1
  20. package/dashboard/dist/assets/{IpCheckPage-CUY6KBaV.js → IpCheckPage-diQTVaYt.js} +1 -1
  21. package/dashboard/dist/assets/{LandingPage-DKL8hZEq.js → LandingPage-BqCxjwar.js} +2 -2
  22. package/dashboard/dist/assets/{LeaderboardAvatar-DRYeMNlq.js → LeaderboardAvatar-CQImCsPN.js} +1 -1
  23. package/dashboard/dist/assets/{LeaderboardPage-DpD9Az3k.js → LeaderboardPage-D2ZDUi_O.js} +2 -2
  24. package/dashboard/dist/assets/{LeaderboardProfileModal-Dfg0V13F.js → LeaderboardProfileModal-DHvADX1d.js} +3 -3
  25. package/dashboard/dist/assets/{LeaderboardProfilePage-DH-jcVDu.js → LeaderboardProfilePage-CJsedB28.js} +1 -1
  26. package/dashboard/dist/assets/LimitsPage-CAwff24b.js +6 -0
  27. package/dashboard/dist/assets/{LocalOnlyNotice-Bj_m0hw7.js → LocalOnlyNotice-Cmnvu9tI.js} +1 -1
  28. package/dashboard/dist/assets/{LoginCard-BVKvtx60.js → LoginCard-BQmKkD7X.js} +1 -1
  29. package/dashboard/dist/assets/{LoginModal-mUGiSIJN.js → LoginModal-2oPROePZ.js} +1 -1
  30. package/dashboard/dist/assets/{LoginPage-BORCuCUt.js → LoginPage-aqdUJoQK.js} +1 -1
  31. package/dashboard/dist/assets/{PetPage-D1JfEOVA.js → PetPage-Bn3p_o5r.js} +1 -1
  32. package/dashboard/dist/assets/{PopoverPopup-DK3et-HG.js → PopoverPopup-DXD_YdiB.js} +1 -1
  33. package/dashboard/dist/assets/{ProviderIcon-By8FAjxR.js → ProviderIcon-BZZ45-gY.js} +1 -1
  34. package/dashboard/dist/assets/{ResetPasswordPage-DPa81jqa.js → ResetPasswordPage-Bn5ITiHQ.js} +1 -1
  35. package/dashboard/dist/assets/{SegmentedControl-DLzS-2eZ.js → SegmentedControl-hGXboQZy.js} +1 -1
  36. package/dashboard/dist/assets/{Select-C05W6XEM.js → Select-BP8aVRZ1.js} +1 -1
  37. package/dashboard/dist/assets/{SelectItemText-CcfB3blP.js → SelectItemText-Odx47kND.js} +1 -1
  38. package/dashboard/dist/assets/{ServiceStatusPage-ByqLbHv1.js → ServiceStatusPage-DUueam0N.js} +1 -1
  39. package/dashboard/dist/assets/SessionsPage-BA9IFqQ1.js +2 -0
  40. package/dashboard/dist/assets/{SettingsPage-DAcndJZQ.js → SettingsPage-DLOHHB4f.js} +2 -2
  41. package/dashboard/dist/assets/{SkillsPage-BuuqQuNU.js → SkillsPage-Ds2vH_PG.js} +1 -1
  42. package/dashboard/dist/assets/{TokenGalaxy-DzccxkXW.js → TokenGalaxy-CWBR4jnB.js} +1 -1
  43. package/dashboard/dist/assets/{ToolbarRootContext-XUDMp5uy.js → ToolbarRootContext-Bmg56vYz.js} +1 -1
  44. package/dashboard/dist/assets/{TrendMonitor-B-yYabbz.js → TrendMonitor-BQzcllvg.js} +1 -1
  45. package/dashboard/dist/assets/{WidgetsPage-CwUDjEFo.js → WidgetsPage-Bu3tHDjO.js} +1 -1
  46. package/dashboard/dist/assets/{WrappedPage-Dr9ow3gH.js → WrappedPage-BrAMJhgy.js} +1 -1
  47. package/dashboard/dist/assets/{__vite-browser-external-DPOlUkcY.js → __vite-browser-external-4IGm4Djn.js} +12 -12
  48. package/dashboard/dist/assets/{agent-logos-Cqc_suYk.js → agent-logos-B8lT-HcI.js} +1 -1
  49. package/dashboard/dist/assets/{arrow-up-right-DSsR3Ntr.js → arrow-up-right-rpBCOTg2.js} +1 -1
  50. package/dashboard/dist/assets/{check-Cy35lAKh.js → check-DIKw7TYH.js} +1 -1
  51. package/dashboard/dist/assets/{composite-BDwOlhhX.js → composite-_NeXO0lv.js} +1 -1
  52. package/dashboard/dist/assets/{copy-4szu5cYh.js → copy-CsfAtL7P.js} +1 -1
  53. package/dashboard/dist/assets/{download-DdGW6Krz.js → download-DM1W9pIW.js} +1 -1
  54. package/dashboard/dist/assets/{external-link-DwSt83cq.js → external-link-CwbuMbeQ.js} +1 -1
  55. package/dashboard/dist/assets/{flame-DubukWqK.js → flame-DcYbLdhE.js} +1 -1
  56. package/dashboard/dist/assets/{format-tokens-B70EdQcN.js → format-tokens-CEvr3dNy.js} +1 -1
  57. package/dashboard/dist/assets/{icons-B86TLdAj.js → icons-DaGMVsJ5.js} +1 -1
  58. package/dashboard/dist/assets/{index-B_KMoBeK.js → index-BVVLPj3N.js} +1 -1
  59. package/dashboard/dist/assets/{index-DI-W-pun.js → index-ChZkJjpk.js} +1 -1
  60. package/dashboard/dist/assets/{index-DzEMcUwI.js → index-T7OjmEuX.js} +1 -1
  61. package/dashboard/dist/assets/{info-BzFpLbl6.js → info-CAjN3dX4.js} +1 -1
  62. package/dashboard/dist/assets/limits-providers-jn7Yln_V.js +1 -0
  63. package/dashboard/dist/assets/{link-2-BQp7-3T7.js → link-2-DaWH2Tyc.js} +1 -1
  64. package/dashboard/dist/assets/{loader-circle-lrDmbIg5.js → loader-circle-CnF8qPi1.js} +1 -1
  65. package/dashboard/dist/assets/{maximize-2-Cnd_Oth8.js → maximize-2-B-2Pnj6g.js} +1 -1
  66. package/dashboard/dist/assets/{modifiers.esm-CPTpZdHU.js → modifiers.esm-BoDOvUKl.js} +1 -1
  67. package/dashboard/dist/assets/{monitor-smartphone-C7UY1zRx.js → monitor-smartphone-DDgwxG_E.js} +1 -1
  68. package/dashboard/dist/assets/{plus-Bglp9N_7.js → plus-DIc1YUWB.js} +1 -1
  69. package/dashboard/dist/assets/{provider-display-CGsFySs6.js → provider-display-yeNsVCO_.js} +1 -1
  70. package/dashboard/dist/assets/{react-DKXriBSF.js → react-DZqS6YTX.js} +1 -1
  71. package/dashboard/dist/assets/{search-D_LLDRdU.js → search-D6tEppYJ.js} +1 -1
  72. package/dashboard/dist/assets/{skills-api-CJWjKIco.js → skills-api-vsA1rc1Z.js} +1 -1
  73. package/dashboard/dist/assets/{sortable.esm-zlY09tye.js → sortable.esm-DDCnS1HI.js} +1 -1
  74. package/dashboard/dist/assets/{store-8e16Ac2h.js → store-Crne4DqF.js} +1 -1
  75. package/dashboard/dist/assets/{terminal-CR228ekj.js → terminal-Ca7dkLMF.js} +1 -1
  76. package/dashboard/dist/assets/{trash-2-BjLWewOp.js → trash-2-CjEAS5ic.js} +1 -1
  77. package/dashboard/dist/assets/{use-community-stats-DhOJPaVg.js → use-community-stats-BHx2YxyK.js} +1 -1
  78. package/dashboard/dist/assets/{use-latest-request-guard-lcGhb-NC.js → use-latest-request-guard-BLGbXQdf.js} +1 -1
  79. package/dashboard/dist/assets/{use-limits-display-prefs-DJIImtLN.js → use-limits-display-prefs-DBkAp6ob.js} +1 -1
  80. package/dashboard/dist/assets/{use-ordered-list-BJZfZuoJ.js → use-ordered-list-BTfW5M9u.js} +1 -1
  81. package/dashboard/dist/assets/use-reduced-motion-D_kUnDs4.js +1 -0
  82. package/dashboard/dist/assets/{use-session-efficiency-pref-C-l4b1cD.js → use-session-efficiency-pref-DBmd-MqH.js} +1 -1
  83. package/dashboard/dist/assets/{use-transform-UjIt477N.js → use-transform-Bp5XrwaQ.js} +1 -1
  84. package/dashboard/dist/assets/{use-usage-limits-DqoTZrqT.js → use-usage-limits-BmqRcyhH.js} +1 -1
  85. package/dashboard/dist/assets/{useCurrency-CnM8aB4v.js → useCurrency-B0YsRDj-.js} +1 -1
  86. package/dashboard/dist/assets/{useTokenFormat-D4pAK2ld.js → useTokenFormat-PP3D0Ket.js} +1 -1
  87. package/dashboard/dist/assets/{zap-Du1IyEtj.js → zap-BVOm1aBH.js} +1 -1
  88. package/dashboard/dist/index.html +1 -1
  89. package/dashboard/dist/ip-check.html +1 -1
  90. package/dashboard/dist/leaderboard.html +1 -1
  91. package/dashboard/dist/share.html +1 -1
  92. package/package.json +1 -1
  93. package/src/lib/ark-agent-plan-limits.js +437 -0
  94. package/src/lib/ark-coding-plan-limits.js +104 -27
  95. package/src/lib/codex-model-attribution.js +128 -0
  96. package/src/lib/codex-rollout-parser.js +98 -4
  97. package/src/lib/pricing/curated-overrides.json +6 -6
  98. package/src/lib/pricing/index.js +38 -1
  99. package/src/lib/pricing/seed-snapshot.json +1 -1
  100. package/src/lib/rollout.js +50 -9
  101. package/src/lib/session-analytics.js +374 -110
  102. package/src/lib/usage-limits.js +19 -5
  103. package/dashboard/dist/assets/DialogDescription-BVlaoajd.js +0 -1
  104. package/dashboard/dist/assets/LimitsPage-CVCKPScf.js +0 -5
  105. package/dashboard/dist/assets/SessionsPage-CEDv1thj.js +0 -2
  106. package/dashboard/dist/assets/limits-providers-DxZOjiXQ.js +0 -1
  107. package/dashboard/dist/assets/use-reduced-motion-DdpxZQoh.js +0 -1
@@ -1 +1 @@
1
- import{m as dt,r as i,V as ct,z as ga,j as e,X as De,c as r,e as ae,aF as da,ay as ut,aI as mt,y as gt,aJ as ya,aK as xt,aL as ht,Z as pt,aM as ft,aN as yt,aO as bt,aP as kt,A as wt,aQ as vt,aA as jt,az as Nt,aR as Ct,a4 as St,a as _t,aS as Rt,ao as It,J as Lt,B as J,R as Pt,d as Dt,aT as Bt,a5 as Pe}from"./__vite-browser-external-DPOlUkcY.js";import{L as Tt,I as xa}from"./LocalOnlyNotice-Bj_m0hw7.js";import{C as Et}from"./Card-SUbC3VNS.js";import{C as ba}from"./ConfirmModal-DsCd51b2.js";import{S as Ot}from"./SegmentedControl-DLzS-2eZ.js";import{I as Ra}from"./info-BzFpLbl6.js";import{P as Ne}from"./ProviderIcon-By8FAjxR.js";import{m as ka}from"./react-DKXriBSF.js";import{u as At}from"./useCurrency-CnM8aB4v.js";import{E as ca}from"./external-link-DwSt83cq.js";import{L as te}from"./loader-circle-lrDmbIg5.js";import{M as Ia}from"./monitor-smartphone-C7UY1zRx.js";import{C as Be}from"./check-Cy35lAKh.js";import{T as ha}from"./trash-2-BjLWewOp.js";import{A as $t}from"./index-DI-W-pun.js";import{u as Mt}from"./use-reduced-motion-DdpxZQoh.js";import{u as Ut,s as Ft,k as zt,l as Kt,m as Vt,n as Wt,o as qt,p as Ht,S as La,c as Pa,d as Da,e as Ba,f as Ta,g as Ea,h as Ye,j as Ze,i as ea}from"./SelectItemText-CcfB3blP.js";import{t as Gt,u as ua,m as Qt}from"./composite-BDwOlhhX.js";import{u as Jt,C as pa}from"./ToolbarRootContext-XUDMp5uy.js";import{g as Xt,a as Yt,p as Zt,m as er,b as ar,d as tr,c as rr,e as sr,f as nr,s as ir,i as wa,u as va,h as ja,r as or,j as Na,k as Ca,l as lr,n as dr}from"./skills-api-CJWjKIco.js";import{F as cr}from"./flame-DubukWqK.js";import{S as ma}from"./search-D_LLDRdU.js";import{P as Oa}from"./plus-Bglp9N_7.js";import{D as Aa}from"./download-DdGW6Krz.js";import{P as $a,a as Ma,b as Ua,c as Fa,d as za}from"./PopoverPopup-DK3et-HG.js";import"./arrow-up-right-DSsR3Ntr.js";import"./DialogTitle-C4ia00lc.js";import"./store-8e16Ac2h.js";import"./DialogDescription-BVlaoajd.js";const ur=[["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"}]],Ka=dt("circle-arrow-up",ur),Va=i.forwardRef(function(s,d){const{render:o,className:h,style:x,...g}=s,{store:c}=Ut(),k={open:ct(c,Ft.open)};return ga("span",s,{state:k,ref:d,props:[{"aria-hidden":!0,children:"▼"},g],stateAttributesMapping:Gt})}),mr="tt:hint:dismissed:";function Wa(a){return mr+a}function gr(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Wa(a))==="1"}catch{return!1}}function xr({id:a,children:s,className:d,ariaLabel:o}){const[h,x]=i.useState(()=>gr(a)),g=i.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(Wa(a),"1")}catch{}x(!0)},[a]);return h?null:e.jsxs("div",{role:"note","aria-label":o||r("hint.dismissible_aria"),className:ae("relative rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 py-3 text-sm text-oai-gray-700","dark:border-oai-gray-800 dark:bg-oai-gray-900/40 dark:text-oai-gray-300",d),children:[e.jsx("button",{type:"button",onClick:g,"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(De,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(Ra,{className:"mt-0.5 h-4 w-4 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:s})]})]})}function hr(a){if(!a)return null;for(const s of a.elements){const d=s.tagName;if(d==="BUTTON"||d==="INPUT"){const o=s;if(o.type==="submit")return o}}return null}function qa(a){return{checked(s){return a.indeterminate?{}:s?{"data-checked":""}:{"data-unchecked":""}},...zt}}const pr=i.createContext({disabled:!1});function fr(){return i.useContext(pr)}function yr(a,s,d,o=!0,h){const[x,g]=i.useState(),c=ua(h?`${h}-label`:void 0),y=a??s??x;return da(()=>{const k=a||s||!o?void 0:br(d.current,c);x!==k&&g(k)}),y}function br(a,s){const d=kr(a);if(d)return!d.id&&s&&(d.id=s),d.id||void 0}function kr(a){if(!a)return;const s=a.parentElement;if(s&&s.tagName==="LABEL")return s;const d=a.id;if(d){const h=a.nextElementSibling;if(h&&h.htmlFor===d)return h}const o=a.labels;return o&&o[0]}const wr=i.createContext(void 0);function vr(){return i.useContext(wr)}const Ha=i.createContext(void 0);function jr(){const a=i.useContext(Ha);if(a===void 0)throw new Error(ut(14));return a}const Nr="data-parent",Cr=i.forwardRef(function(s,d){const{checked:o,className:h,defaultChecked:x=!1,"aria-labelledby":g,disabled:c=!1,form:y,id:k,indeterminate:p=!1,inputRef:C,name:R,onCheckedChange:u,parent:w=!1,readOnly:m=!1,render:S,required:L=!1,uncheckedValue:A,value:$,nativeButton:F=!1,style:de,...D}=s,{clearErrors:Ce}=Kt(),{disabled:he,name:pe,setDirty:_,setFilled:E,setFocused:M,setTouched:T,state:X,validationMode:q,validityData:Se,validation:Te}=Vt(),Ve=fr(),{labelId:Ee,controlId:We,registerControlId:re,getDescriptionProps:O}=Wt(),N=vr(),H=N?.allValues===void 0?void 0:N.parent,se=H!==void 0,B=he||Ve.disabled||N?.disabled||c,z=pe??R,I=$??z,_e=ua(),Oe=ua();let K=k||We;se&&(w?K=Oe:I!==void 0?K=`${H.id}-${I}`:K||=Oe);let Re={};se&&(w?Re=H.getParentProps():I!==void 0&&(Re=H.getChildProps(I)));const{checked:fe=o,indeterminate:ta=p,onCheckedChange:Ae,...qe}=Re,ye=N?.value,ne=i.useRef(null),ce=mt(()=>Symbol()),ue=i.useRef(!1),{getButtonProps:Ie,buttonRef:me}=gt({disabled:B,native:F}),Y=N?.validation??Te,[P,Le]=qt({controlled:I!==void 0&&ye!==void 0&&!w?ye.includes(I):fe,default:x,name:"Checkbox",state:"checked"}),ge=se?!!fe:P,be=se&&ta||p;da(()=>{re!==ya&&(ue.current=!0,re(ce.current,K))},[K,re,ce]),i.useEffect(()=>{const b=ce.current;return()=>{!ue.current||re===ya||(ue.current=!1,re(b,void 0))}},[re,ce]),Ht(ne,_e,P,void 0,!N&&!B,R);const Z=i.useRef(null),$e=Y.registerInput,G=N?I:void 0,ra=i.useCallback(b=>$e(b,{controlRef:ne,value:G}),[$e,G]),sa=xt(C,Z,w?void 0:ra),na=yr(g,Ee,Z,!F,K??void 0);da(()=>{Z.current&&(Z.current.indeterminate=be,P&&E(!0))},[P,be,E]),Jt(P,()=>{N||(Ce(z),E(P),_(P!==Se.initialValue),Y.change(P))});const He=ht({checked:P,disabled:B,form:y,name:w?void 0:z,id:F?void 0:K??void 0,required:L,ref:sa,style:z?bt:kt,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(b){if(b.nativeEvent.defaultPrevented)return;if(m){b.preventDefault();return}const Q=b.currentTarget.checked,ie=wt(vt,b.nativeEvent);if(u?.(Q,ie),!ie.isCanceled&&(Ae?.(Q,ie),!ie.isCanceled&&(Le(Q),I!==void 0&&N!==void 0&&!w&&!se))){const oe=Q?[...N.value,I]:N.value.filter(we=>we!==I);N.setValue(oe,ie)}},onClick(b){b.stopPropagation()},onFocus(){ne.current?.focus()}},$!==void 0?{value:(N?P&&$:$)||""}:pt,O,b=>Y.getValidationProps(B,b));i.useEffect(()=>{if(!H||I===void 0)return;const b=H.disabledStatesRef.current;return b.set(I,B),()=>{b.delete(I)}},[H,B,I]);const ke=i.useMemo(()=>({...X,checked:ge,disabled:B,readOnly:m,required:L,indeterminate:be}),[X,ge,B,m,L,be]),ia=qa(ke),Ge=ga("span",s,{state:ke,ref:[me,ne,d],props:[{id:F?K??void 0:_e,role:"checkbox","aria-checked":be?"mixed":ge,"aria-readonly":m||void 0,"aria-required":L||void 0,"aria-labelledby":na,[Nr]:w?"":void 0,onFocus(){B||M(!0)},onBlur(){const b=Z.current;b&&(T(!0),M(!1),q==="onBlur"&&Y.commit(N?ye:b.checked))},onKeyDown(b){if(b.key!=="Enter"||(b.preventBaseUIHandler(),b.defaultPrevented))return;const Q=Z.current?.form??null,ie=b.currentTarget,oe=b.nativeEvent,we=b.preventDefault,Me=oe.preventDefault;let Ue=!1;b.preventDefault=()=>{Ue=!0,we.call(b)},oe.preventDefault=()=>{Ue=!0,Me.call(oe)},Me.call(oe),yt(ie).queueMicrotask(()=>{b.preventDefault=we,oe.preventDefault=Me,Ue||hr(Q)?.click()})},onClick(b){if(m||B)return;b.preventDefault();const Q=Z.current;Q&&ft(Q,b)}},D,qe,Ie,O,b=>Y.getValidationProps(B,b)],stateAttributesMapping:ia});return e.jsxs(Ha.Provider,{value:ke,children:[Ge,!P&&!N&&z&&!w&&A!==void 0&&e.jsx("input",{type:"hidden",form:y,name:z,value:A,disabled:B}),e.jsx("input",{...He,suppressHydrationWarning:!0})]})}),Sr=i.forwardRef(function(s,d){const{render:o,className:h,style:x,keepMounted:g=!1,...c}=s,y=jr(),k=y.checked||y.indeterminate,{mounted:p,transitionStatus:C,setMounted:R}=Qt(k),u=i.useRef(null),w={...y,transitionStatus:C};jt({open:k,ref:u,onComplete(){k||R(!1)}});const S={...qa(y),...Nt},L=g||p,A=ga("span",s,{ref:[d,u],state:w,stateAttributesMapping:S,props:c});return L?A:null});function _r(a,s){return`target:${a}:${s}`}function Rr(a){return`remove:${a.id||a.directory}`}function Ga(a){if(!a)return null;const s=new Date(a).getTime();return Number.isFinite(s)?Math.floor((Date.now()-s)/864e5):null}function Ir(a){const s=Ga(a);if(s==null)return null;if(s<=0)return r("skills.usage.today");if(s<30)return r("skills.usage.days_ago",{days:s});const d=Math.max(1,Math.floor(s/30));return r("skills.usage.months_ago",{months:d})}function Lr(a){const s=Ga(a);return s==null?"bg-oai-gray-300 dark:bg-oai-gray-600":s<=7?"bg-emerald-500":s<=30?"bg-amber-500":"bg-oai-gray-300 dark:bg-oai-gray-600"}function oa({label:a,children:s}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2 text-sm",children:[e.jsx("dt",{className:"flex items-center gap-1 text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"text-right font-medium tabular-nums text-oai-black dark:text-white",children:s})]})}function Pr({skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k}){return e.jsx($t,{children:a?e.jsx(Dr,{skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k},a.id||a.directory):null})}function Dr({skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k}){const p=Mt(),{currency:C,rate:R}=At(),u=i.useRef(null);i.useEffect(()=>{const _=M=>{M.key==="Escape"&&(M.stopPropagation(),c?.())},E=M=>{const T=M.target;T instanceof Element&&(u.current?.contains(T)||T.closest('[data-skill-row="1"]')||c?.())};return document.addEventListener("keydown",_),document.addEventListener("pointerdown",E),()=>{document.removeEventListener("keydown",_),document.removeEventListener("pointerdown",E)}},[c]);const w=a.name||a.directory,m=!!(a.repoOwner&&a.repoName),S=m?`https://github.com/${a.repoOwner}/${a.repoName}`:null,L=new Set(a.targets||[]),A=!!(a.readOnly||a.remote),$=!!a.remote,F=Array.isArray(a.deviceSources)?a.deviceSources:[],de=!$&&(!A||L.has("claude")),D=d===Rr(a),Ce=Ir(o?.lastUsedAt),he=!!(o&&o.invocations>0),pe=p?{duration:0}:{type:"spring",stiffness:320,damping:30,mass:.7};return e.jsxs(e.Fragment,{children:[e.jsx(ka.div,{className:"fixed inset-0 z-20 bg-oai-black/30 backdrop-blur-[2px] lg:hidden",initial:p?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:p?0:.15},onClick:c,"aria-hidden":!0}),e.jsxs(ka.aside,{ref:u,role:"complementary","aria-label":w,initial:p?!1:{opacity:0,x:24,scale:.98},animate:{opacity:1,x:0,scale:1},exit:p?{opacity:0}:{opacity:0,x:24,scale:.98},transition:pe,className:"fixed inset-x-3 bottom-3 top-20 z-30 flex flex-col overflow-hidden rounded-2xl border border-white/40 bg-white/75 shadow-[0_24px_60px_-20px_rgba(15,23,42,0.25)] backdrop-blur-xl backdrop-saturate-150 supports-[backdrop-filter]:bg-white/65 dark:border-white/10 dark:bg-oai-gray-950/70 dark:shadow-[0_24px_60px_-20px_rgba(0,0,0,0.7)] dark:supports-[backdrop-filter]:bg-oai-gray-950/55 lg:inset-auto lg:right-6 lg:top-24 lg:bottom-6 lg:w-[22rem] lg:max-h-[calc(100vh-7.5rem)]",children:[e.jsxs("header",{className:"flex items-center gap-3 border-b border-white/40 bg-gradient-to-b from-white/30 to-transparent px-5 pb-4 pt-5 dark:border-white/10 dark:from-white/[0.04]",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",title:w,children:w}),m?e.jsxs("a",{href:S,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:S,children:[e.jsxs("span",{className:"truncate",children:[a.repoOwner,"/",a.repoName]}),e.jsx(ca,{className:"h-3 w-3 shrink-0","aria-hidden":!0})]}):a.directory&&a.directory!==w?e.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",title:a.directory,children:a.directory}):null]}),e.jsx("button",{type:"button",onClick:c,"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(De,{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:[h?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(Ka,{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:()=>g?.(a),disabled:x,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:[x?e.jsx(te,{className:"h-3 w-3 animate-spin","aria-hidden":!0}):null,r("skills.update.action")]})]}):null,a.description?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a.description}):null,A?e.jsx("div",{className:"mt-4 rounded-xl bg-oai-gray-50 px-3 py-2.5 text-xs leading-5 text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-900/60 dark:text-oai-gray-300 dark:ring-oai-gray-800",children:r($?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed")}):null,a.sourceName?e.jsx("div",{className:"mt-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.source",{source:a.sourceName})}):null,F.length?e.jsxs("section",{className:"mt-5",children:[e.jsx("h3",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.devices_title")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:F.map(_=>e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 rounded-full bg-oai-gray-100 px-2.5 py-1 text-xs text-oai-gray-700 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-200 dark:ring-oai-gray-700",children:[e.jsx(Ia,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"max-w-52 truncate",children:_.name})]},_.id))})]}):null,de?e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.usage.section_title")}),e.jsxs("dl",{className:"divide-y divide-oai-gray-200/60 dark:divide-white/[0.06]",children:[e.jsx(oa,{label:r("skills.usage.invocations"),children:Ct(o?.invocations||0)}),e.jsx(oa,{label:r("skills.usage.last_used"),children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:ae("h-1.5 w-1.5 rounded-full",Lr(o?.lastUsedAt)),"aria-hidden":!0}),he?Ce||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(oa,{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(Ra,{className:"h-3 w-3","aria-label":r("skills.usage.disclaimer")})})]}),children:St(o?.cost||0,{currency:C,rate:R})})]}),he?null:e.jsx("p",{className:"mt-2 text-[11px] leading-4 text-oai-gray-400 dark:text-oai-gray-500",children:r("skills.usage.unused")})]}):null,A?null:e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.detail.sync_section_title")}),e.jsx("div",{children:(s||[]).filter(_=>_.manageable!==!1).map(_=>{const E=L.has(_.id),M=d===_r(a.id||a.directory,_.id),T=`skill-detail-sync-${a.id||a.directory}-${_.id}`;return e.jsxs("label",{htmlFor:T,className:"-mx-2 flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 text-sm text-oai-black transition-colors hover:bg-oai-gray-100/70 dark:text-white dark:hover:bg-white/[0.05]",children:[e.jsx(Cr,{id:T,checked:E,disabled:M,onCheckedChange:X=>y?.(a,_.id,!!X),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(Sr,{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(Ne,{provider:_.id,size:16})}),e.jsx("span",{className:"flex-1",children:_.label}),M?e.jsx(te,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},_.id)})})]})]}),A?null:e.jsxs("footer",{className:"border-t border-white/40 bg-white/30 px-5 py-4 dark:border-white/10 dark:bg-white/[0.02]",children:[e.jsxs("button",{type:"button",onClick:()=>k?.(a),disabled:D,className:"inline-flex w-full items-center justify-center gap-2 rounded-lg border border-red-200/70 bg-white px-3 py-2 text-sm font-medium text-red-600 transition hover:border-red-300 hover:bg-red-50 focus:outline-none focus:ring-2 focus:ring-red-400/30 disabled:cursor-not-allowed disabled:opacity-60 dark:border-red-900/60 dark:bg-oai-gray-950 dark:text-red-300 dark:hover:border-red-800 dark:hover:bg-red-950/30",children:[D?e.jsx(te,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(ha,{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 Br=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),la=["claude","codex"],W="popular",Tr={claude:"text-orange-500 dark:text-orange-300",codex:"text-emerald-600 dark:text-emerald-300",grok:"text-zinc-700 dark:text-zinc-200",antigravity:"text-violet-600 dark:text-violet-300",gemini:"text-sky-600 dark:text-sky-300",opencode:"text-amber-600 dark:text-amber-300",hermes:"text-indigo-500 dark:text-indigo-300"},xe="all",U="skillssh";function aa(a){return`${a.repoOwner||"local"}/${a.repoName||"local"}:${a.directory}`}function Qa(a){return String(a||"").replace(/\\/g,"/").trim().toLowerCase()}function Er(a){return Qa(a).split("/").filter(Boolean).pop()||""}function Or(a){if(a.repoOwner||a.repoName)return"";const s=Qa(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function Sa(a){const s=Er(a.directory);return s?`dir:${s}`:""}function Ja(a){const s=new Set([aa(a).toLowerCase()]);a.repoOwner&&a.repoName&&s.add(`${a.repoOwner}/${a.repoName}:${a.sourceDirectory||a.directory}`.toLowerCase());const d=Or(a);return d&&s.add(d),s}function Ar(a){return!a?.remote&&!a?.inventoryOnly&&!a?.readOnly}function $r(a){const s=new Set;for(const d of Array.isArray(a)?a:[])if(Ar(d))for(const o of Ja(d))s.add(o);return s}function Xe(a){return`install:${aa(a)}`}function _a(a){return`remove:${a.id||a.directory}`}function Xa(a,s){return`target:${a}:${s}`}function je(a){return a.id||a.directory}function fa(a){return a.manageable!==!1}function Mr({target:a,state:s,busy:d,disabled:o,disabledLabel:h,onToggle:x}){const g=s==="synced",c=s==="orphan",y=c?r("skills.dot.orphan_aria",{agent:a.label}):g?r("skills.dot.synced_aria",{agent:a.label}):r("skills.dot.off_aria",{agent:a.label}),k=o&&h?`${y} — ${h}`:y;return e.jsxs("button",{type:"button",title:k,"aria-label":k,"aria-pressed":g,disabled:d||o,onClick:p=>{p.stopPropagation(),x?.(a.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:[d?e.jsx(te,{className:"h-4 w-4 animate-spin text-oai-gray-400","aria-hidden":!0}):e.jsx("span",{className:ae("flex h-[18px] w-[18px] items-center justify-center transition",g&&Tr[a.id],!g&&!c&&"opacity-35 grayscale"),"aria-hidden":!0,children:e.jsx(Ne,{provider:a.id,size:18})}),c&&!d?e.jsx("span",{className:"absolute -bottom-px -right-px h-2 w-2 rounded-full bg-amber-500 ring-2 ring-oai-white dark:ring-oai-gray-900","aria-hidden":!0}):null]})}function Ur({skill:a,targets:s,onToggleTarget:d,busyKey:o}){const h=new Set(a.targets||[]),x=!!(a.readOnly||a.remote),g=[];for(const c of s)(x?h.has(c.id):fa(c))&&g.push(c);return e.jsx("div",{className:"flex items-center gap-1",onClick:c=>c.stopPropagation(),children:g.map(c=>e.jsx(Mr,{target:c,state:a.targetStates?.[c.id]||"off",busy:o===Xa(je(a),c.id),disabled:x||c.manageable===!1,disabledLabel:r(a.remote?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed"),onToggle:(y,k)=>d?.(a,y,k)},c.id))})}function Fr({skill:a,targets:s,selected:d,onSelect:o,selectable:h,checked:x,onToggleSelect:g,onToggleTarget:c,hasUpdate:y,busyKey:k}){const p=a.repoOwner&&a.repoName?`${a.repoOwner}/${a.repoName}`:null,C=[a.directory,p,a.sourceName].filter(Boolean).join(" · "),R=Array.isArray(a.deviceSources)?a.deviceSources:[],u=[a.remote?r("skills.inventory.remote"):null,a.scope==="plugin"?r("skills.inventory.plugin"):null].filter(Boolean),w=m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),o?.(a))};return e.jsxs("div",{"data-skill-row":"1",role:"button",tabIndex:0,"aria-pressed":d,"aria-label":r("skills.row.open_details",{name:a.name||a.directory}),onClick:()=>o?.(a),onKeyDown:w,className:ae("cursor-pointer rounded-md py-3 pr-2 transition focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30",d?"bg-oai-gray-100 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800/60 dark:ring-oai-gray-800":x?"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:[h?e.jsx("label",{className:"flex shrink-0 items-center",onClick:m=>m.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:x,onChange:m=>g?.(a,m.target.checked),"aria-label":r("skills.select.row_aria",{name:a.name||a.directory}),className:"h-4 w-4 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white"})}):null,e.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-oai-black dark:text-white",title:C,children:a.name||a.directory}),u.map(m=>e.jsx("span",{className:"inline-flex shrink-0 rounded-full bg-oai-gray-100 px-1.5 py-0.5 text-[10px] font-semibold text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-300 dark:ring-oai-gray-700",children:m},m)),y?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-semibold text-sky-700 ring-1 ring-sky-200 dark:bg-sky-950/40 dark:text-sky-300 dark:ring-sky-800/60",children:[e.jsx(Ka,{className:"h-2.5 w-2.5","aria-hidden":!0}),r("skills.update.badge")]}):null,e.jsx(Ur,{skill:a,targets:s,onToggleTarget:c,busyKey:k}),e.jsx(Bt,{className:ae("hidden h-4 w-4 shrink-0 text-oai-gray-300 transition-colors dark:text-oai-gray-600 lg:block",d&&"text-oai-gray-500 dark:text-oai-gray-300"),"aria-hidden":!0})]}),a.description?e.jsx("p",{className:ae("mt-1 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",h&&"pl-7"),children:a.description}):null,a.sourceName||R.length?e.jsxs("div",{className:ae("mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-oai-gray-400 dark:text-oai-gray-500",h&&"pl-7"),children:[a.sourceName?e.jsx("span",{className:"truncate",children:a.sourceName}):null,R.length?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:R.map(m=>m.name).join(", "),children:[e.jsx(Ia,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r("skills.inventory.on_devices",{devices:R.map(m=>m.name).join(", ")})})]}):null]}):null]})}function zr({agentFilter:a,agentOptions:s,onAgentFilter:d,filteredCount:o,totalCount:h,anyFilter:x,onClearFilters:g,searchQuery:c,onSearchQuery:y,searchPlaceholder:k}){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(La,{value:a,onValueChange:d,children:[e.jsxs(Pa,{"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(Da,{children:p=>p==="all"?r("skills.filter.agent_all"):s.find(C=>C.id===p)?.label||p}),e.jsx(Va,{className:"text-oai-gray-400",children:e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Ba,{children:e.jsx(Ta,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ea,{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(Ye,{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(Ze,{children:r("skills.filter.agent_all")}),e.jsx(ea,{children:e.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),s.map(p=>e.jsxs(Ye,{value:p.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(Ne,{provider:p.id,size:14}),e.jsx(Ze,{children:p.label})]}),e.jsx(ea,{children:e.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},p.id))]})})})]}),e.jsxs("div",{className:"relative w-56 max-w-full",children:[e.jsx(ma,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(xa,{type:"search",value:c,onChange:p=>y(p.target.value),onKeyDown:p=>{p.key==="Escape"&&c&&(p.preventDefault(),y(""))},"aria-label":r("skills.action.search_aria"),placeholder:k,className:"h-8 pl-9 pr-8 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20 [&::-webkit-search-cancel-button]:appearance-none"}),e.jsx("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>y(""),"aria-label":r("skills.action.search_clear"),"aria-hidden":!c,tabIndex:c?0:-1,className:ae("absolute right-2 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full text-oai-gray-400 transition duration-150 ease-out before:absolute before:-inset-1.5 before:content-[''] hover:bg-oai-gray-100 hover:text-oai-gray-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 motion-reduce:transition-none dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",c?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(De,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{role:"status","aria-live":"polite",className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.filter.result_count",{filtered:o,total:h})}),x?e.jsxs("button",{type:"button",onClick:g,className:"shrink-0 inline-flex h-7 items-center gap-1 rounded-full bg-oai-gray-100 px-2.5 text-[11px] font-medium text-oai-gray-700 transition hover:bg-oai-gray-200 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:bg-oai-gray-800/70 dark:text-oai-gray-200 dark:hover:bg-oai-gray-700",children:[e.jsx(De,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]})}function Kr({count:a,targets:s,busy:d,onBulkSync:o,onBulkRemove:h,onClear:x}){const g=s.filter(fa);return e.jsxs("div",{role:"toolbar","aria-label":r("skills.select.toolbar_aria"),className:"mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-3 py-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/50",children:[e.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200","aria-live":"polite",children:r("skills.select.count",{count:a})}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs($a,{children:[e.jsxs(Ma,{disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200",children:[e.jsx(Aa,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_sync"),e.jsx(pa,{className:"h-3 w-3","aria-hidden":!0})]}),e.jsx(Ua,{children:e.jsx(Fa,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(za,{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")}),g.map(c=>e.jsxs("button",{type:"button",onClick:()=>o(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(Ne,{provider:c.id,size:16}),e.jsx("span",{className:"flex-1",children:c.label})]},c.id))]})})})]}),e.jsxs(J,{type:"button",variant:"ghost",size:"sm",disabled:d,onClick:h,children:[e.jsx(ha,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_remove")]}),e.jsxs("button",{type:"button",onClick:x,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(De,{className:"h-3 w-3","aria-hidden":!0}),r("skills.select.clear")]})]})]})}function Vr({items:a,totalCount:s,targets:d,agentOptions:o,agentFilter:h,onAgentFilter:x,anyFilter:g,onClearFilters:c,searchQuery:y,onSearchQuery:k,searchPlaceholder:p,selectedId:C,onSelect:R,onToggleTarget:u,busyKey:w,updates:m,selectedIds:S,onToggleSelect:L,onClearSelection:A,onBulkSync:$,onBulkRemove:F}){const de=S.size;return e.jsxs("div",{children:[de>0?e.jsx(Kr,{count:de,targets:d,busy:w==="batch",onBulkSync:$,onBulkRemove:F,onClear:A}):e.jsx(zr,{agentFilter:h,agentOptions:o,onAgentFilter:x,filteredCount:a.length,totalCount:s,anyFilter:g,onClearFilters:c,searchQuery:y,onSearchQuery:k,searchPlaceholder:p}),a.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r("skills.empty.no_match")}),e.jsx(J,{type:"button",variant:"secondary",size:"sm",onClick:c,children:r("skills.filter.clear")})]}):e.jsx("div",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(D=>e.jsx(Fr,{skill:D,targets:d,selected:C===(D.id||D.directory),onSelect:R,selectable:!D.readOnly&&!D.remote,checked:S.has(je(D)),onToggleSelect:L,onToggleTarget:u,hasUpdate:!!(D.id&&m?.[D.id]),busyKey:w},je(D)))})]})}const Wr={contentVisibility:"auto",containIntrinsicSize:"0 240px"},qr=Dt.memo(function({skill:s,installed:d,installing:o,allTargets:h,defaultTargets:x,onInstall:g,onManage:c}){const[y,k]=i.useState(()=>(x||[]).filter(m=>h.some(S=>S.id===m))),p=m=>{k(S=>S.includes(m)?S.filter(L=>L!==m):[...S,m])},C=s.repoOwner&&s.repoName?`${s.repoOwner}/${s.repoName}`:null,R=C?`https://github.com/${s.repoOwner}/${s.repoName}`:null,u=s.installs!=null?r("skills.card.installs",{count:Number(s.installs||0).toLocaleString()}):null,w=y.length?y.map(m=>h.find(S=>S.id===m)?.label||m).join(", "):r("skills.action.choose_targets");return e.jsxs(Et,{className:"h-full rounded-lg",bodyClassName:"flex h-full flex-col",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[s.readmeUrl?e.jsxs("a",{href:s.readmeUrl,target:"_blank",rel:"noopener noreferrer",className:"group inline-flex max-w-full items-center gap-1 truncate text-base font-semibold text-oai-black hover:underline dark:text-white",title:s.readmeUrl,children:[e.jsx("span",{className:"truncate",children:s.name||s.directory}),e.jsx(ca,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:s.name||s.directory}),C||u?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:[R?e.jsxs("a",{href:R,target:"_blank",rel:"noopener noreferrer",onClick:m=>m.stopPropagation(),className:"inline-flex items-center gap-1 truncate rounded text-oai-gray-500 hover:text-oai-black hover:underline focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:text-white",title:R,children:[e.jsx("span",{className:"truncate",children:C}),e.jsx(ca,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,C&&u?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,u?e.jsx("span",{className:"truncate",children:u}):null]}):null]})}),s.description?e.jsx("p",{className:"mt-3 line-clamp-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:s.description}):null,e.jsx("div",{className:"mt-auto pt-5",children:d?e.jsxs(J,{type:"button",variant:"secondary",size:"sm",onClick:()=>c?.(s),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:y.length?w:r("skills.target.none")}),e.jsxs($a,{children:[e.jsx(Ma,{disabled:o,"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(Ua,{children:e.jsx(Fa,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(za,{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")}),h.map(m=>{const S=y.includes(m.id);return e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm text-oai-black hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 shrink-0 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white",checked:S,onChange:()=>p(m.id)}),e.jsx(Ne,{provider:m.id,size:16}),e.jsx("span",{className:"flex-1 text-left",children:m.label})]},m.id)})]})})})]})]}),e.jsxs(J,{type:"button",size:"sm",onClick:()=>g(s,y),disabled:o||y.length===0,className:"w-full",children:[o?e.jsx(te,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(Aa,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.action.install")]})]})})]})});function Hr({repos:a,repoInput:s,onRepoInput:d,busyKey:o,onAdd:h,onRemove:x}){return e.jsxs("div",{className:"rounded-lg border border-oai-gray-200 bg-white p-4 dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx(xa,{value:s,onChange:g=>d(g.target.value),placeholder:r("skills.repo.placeholder"),className:"min-w-0 flex-1"}),e.jsxs(J,{type:"button",variant:"secondary",size:"md",onClick:h,disabled:o==="repo:add",className:"shrink-0 whitespace-nowrap",children:[o==="repo:add"?e.jsx(te,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(Oa,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.repo.add")]})]}),a.length?e.jsx("div",{className:"mt-3 divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(g=>{const c=o===`repo:${g.owner}/${g.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:[g.owner,"/",g.name]}),e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:g.branch})]}),e.jsxs(J,{type:"button",variant:"ghost",size:"sm",disabled:c,onClick:()=>x(g),className:"shrink-0",children:[c?e.jsx(te,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(ha,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:r("skills.repo.remove")})]})]},`${g.owner}/${g.name}`)})}):null]})}function Gr(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Ns(){const a=_t()||{},s=!!a.signedIn,d=a.getAccessToken,[o,h]=i.useState(Gr),[x,g]=i.useState({skills:[],targets:[]}),[c,y]=i.useState([]),[k,p]=i.useState([]),[C,R]=i.useState([]),[u,w]=i.useState(xe),[m,S]=i.useState(""),[L,A]=i.useState(""),[$,F]=i.useState(""),[de,D]=i.useState(""),[Ce,he]=i.useState(""),[pe,_]=i.useState(!1),[E,M]=i.useState("all"),[T,X]=i.useState(null),[q,Se]=i.useState(""),[Te,Ve]=i.useState(!0),[Ee,We]=i.useState(!1),[re,O]=i.useState(""),[N,H]=i.useState(null),[se,B]=i.useState(null),[z,I]=i.useState(()=>new Set),[_e,Oe]=i.useState({}),[K,Re]=i.useState({}),[fe,ta]=i.useState([]),[Ae,qe]=i.useState(!1),ye=i.useRef(!1),ne=i.useRef(0),ce=i.useMemo(()=>$r(x.skills),[x.skills]),ue=i.useCallback(async()=>{const t=++ne.current,n=await Xt();if(ne.current!==t)return;const l={skills:n.skills||[],targets:n.targets||[]};g(l);const f=Rt();!s||!It()||!f||typeof d!="function"||(async()=>{try{const v=await d();if(!v||ne.current!==t)return;const[j]=await Promise.allSettled([Yt(v),Zt({accessToken:v,deviceId:f,skills:l.skills})]);if(j.status!=="fulfilled")return;const ze=j.value;if(ne.current!==t)return;g({targets:l.targets,skills:er(l.skills,ze,f)})}catch{}})()},[d,s]),Ie=i.useCallback(async()=>{const t=await ar();R(t.repos||[])},[]),me=i.useCallback(async({force:t=!1}={})=>{We(!0);try{const n=await tr({force:t});y(n.skills||[])}finally{We(!1)}},[]),Y=i.useCallback(async({force:t=!1}={})=>{qe(!0);try{const n=await rr({force:t});ta(n.skills||[])}finally{qe(!1)}},[]),P=i.useCallback(async()=>{try{const t=await sr();Oe(t?.updates||{})}catch{Oe({})}},[]),Le=i.useCallback(async()=>{try{const t=await nr(),n={};for(const l of t?.skills||[])l.installed&&(l.directory&&(n[String(l.directory).toLowerCase()]=l),n[String(l.skill).toLowerCase()]=l);Re(n)}catch{Re({})}},[]),ge=i.useCallback(async()=>{Ve(!0),O("");try{await Promise.all([ue(),Ie()])}catch(t){O(t?.message||r("skills.error.generic"))}finally{Ve(!1)}},[ue,Ie]),be=i.useCallback(async()=>{await ge();const t=n=>O(n?.message||r("skills.error.generic"));o==="my"?(P(),Le()):u===W?Y({force:!0}).catch(t):u!==U&&me({force:!0}).catch(t)},[me,ge,Y,P,Le,u,o]);i.useEffect(()=>{ge()},[ge]),i.useEffect(()=>{if(ye.current||typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("skill");if(!n){ye.current=!0;return}const l=x.skills||[];if(!l.length)return;const f=l.find(j=>j.directory===n||j.id===n);f&&(h("my"),X(f.id||f.directory)),ye.current=!0,t.delete("skill");const v=t.toString();window.history.replaceState({},"",`${window.location.pathname}${v?`?${v}`:""}${window.location.hash}`)},[x.skills]),i.useEffect(()=>{o==="browse"&&(u===U||u===W||c.length===0&&me().catch(t=>O(t?.message||r("skills.error.generic"))))},[c.length,me,u,o]),i.useEffect(()=>{o!=="browse"||u!==W||fe.length===0&&Y().catch(t=>O(t?.message||r("skills.error.generic")))},[Y,fe.length,u,o]);const Z=Object.keys(_e).length>0,$e=Object.keys(K).length>0;if(i.useEffect(()=>{o==="my"&&(Z||P(),$e||Le())},[o,Z,$e,P,Le]),i.useEffect(()=>{const t=setTimeout(()=>A(m),200);return()=>clearTimeout(t)},[m]),i.useEffect(()=>{const t=setTimeout(()=>D($),120);return()=>clearTimeout(t)},[$]),i.useEffect(()=>{if(typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("tab");if(o==="my"){if(!n)return;t.delete("tab")}else{if(n===o)return;t.set("tab",o)}const l=t.toString(),f=`${window.location.pathname}${l?`?${l}`:""}${window.location.hash}`;window.history.replaceState({},"",f)},[o]),!Br&&!Lt())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Tt,{})});const G=async(t,n)=>{Se(t),O("");try{await n(),await ue()}catch(l){O(l?.message||r("skills.error.generic"))}finally{Se("")}},ra=(t,n)=>{const l=(n&&n.length?n:la).filter(f=>(x.targets||[]).some(v=>v.id===f));G(Xe(t),async()=>{await wa(t,l);const f=l.map(v=>(x.targets||[]).find(j=>j.id===v)?.label||v).join(", ");Pe({title:r("skills.toast.installed",{name:t.name||t.directory,targets:f||r("skills.target.none")}),timeout:4e3})})},sa=t=>{t?.readOnly||t?.remote||H(t)},na=()=>{const t=N;t&&(H(null),G(_a(t),async()=>{let n=null;t.managed?n=await va(t.id):await ja(t.directory,t.targets||[]);const l=!!(n?.trashed&&t.managed&&t.id);Pe({title:r("skills.toast.removed",{name:t.name||t.directory}),timeout:6e3,data:l?{onUndo:async()=>{try{await or(t.id),await ue()}catch(f){O(f?.message||r("skills.error.generic"))}}}:void 0})}))},He=(t,n,l)=>t?.readOnly||t?.remote?Promise.resolve():G(Xa(je(t),n),async()=>{const f=new Set(t.targets||[]);l?f.add(n):f.delete(n),t.managed?await Na(t.id,Array.from(f)):await Ca(t.directory,Array.from(f));const v={name:t.name||t.directory,agent:Ge(n)};Pe({title:l?r("skills.toast.synced_one",v):r("skills.toast.unsynced_one",v),timeout:3e3})}),ke=i.useCallback(()=>I(new Set),[]),ia=i.useCallback((t,n)=>{if(t?.readOnly||t?.remote)return;const l=je(t);I(f=>{const v=new Set(f);return n?v.add(l):v.delete(l),v})},[]),Ge=t=>(x.targets||[]).find(n=>n.id===t)?.label||t,b=t=>{const n=(x.skills||[]).filter(l=>z.has(je(l))&&!l.readOnly&&!l.remote);n.length&&G("batch",async()=>{for(const l of n){const f=new Set(l.targets||[]);f.add(t),l.managed?await Na(l.id,Array.from(f)):await Ca(l.directory,Array.from(f))}ke(),Pe({title:r("skills.toast.bulk_synced",{count:n.length,agent:Ge(t)}),timeout:4e3})})},Q=()=>{const t=(x.skills||[]).filter(n=>z.has(je(n))&&!n.readOnly&&!n.remote);t.length&&B(t)},ie=()=>{const t=se;t&&(B(null),G("batch",async()=>{for(const n of t)n.managed?await va(n.id):await ja(n.directory,n.targets||[]);ke(),Pe({title:r("skills.toast.bulk_removed",{count:t.length}),timeout:4e3})}))},oe=t=>{!t?.repoOwner||!t?.repoName||G(Xe(t),async()=>{await wa({key:t.key,name:t.name,description:t.description,directory:t.sourceDirectory||t.directory,repoOwner:t.repoOwner,repoName:t.repoName,repoBranch:t.repoBranch,readmeUrl:t.readmeUrl},t.targets&&t.targets.length?t.targets:la),await P(),Pe({title:r("skills.toast.updated",{name:t.name||t.directory}),timeout:4e3})})},we=async()=>{const t=m.trim();if(!(t.length<2)){Se("search"),O("");try{const n=await ir(t);p(n.skills||[])}catch(n){O(n?.message||r("skills.error.generic"))}finally{Se("")}}},Me=async()=>{const t=Ce.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[n,l]=t.split("/");if(!n||!l){O(r("skills.repo.invalid"));return}await G("repo:add",async()=>{await dr({owner:n,name:l,branch:"main",enabled:!0}),he(""),await Ie(),await me()})},Ue=async t=>{await G(`repo:${t.owner}/${t.name}`,async()=>{await lr(t.owner,t.name),await Ie(),await me()})},le=x.targets||[],Ya=le.filter(fa),ve=x.skills||[],Za=i.useMemo(()=>{const t=E==="all"?ve:ve.filter(l=>(l.targets||[]).includes(E)),n=de.trim().toLowerCase();return n?t.filter(l=>(l.name||"").toLowerCase().includes(n)||(l.directory||"").toLowerCase().includes(n)||(l.description||"").toLowerCase().includes(n)):t},[ve,E,de]),et=E!=="all",ee=i.useMemo(()=>T&&ve.find(t=>(t.id||t.directory)===T)||null,[ve,T]),at=i.useCallback(()=>{M("all"),F("")},[]),tt=i.useCallback(t=>{X(n=>{const l=t?.id||t?.directory||null;return n===l?null:l})},[]),rt=i.useCallback(()=>X(null),[]),st=i.useCallback(t=>{const n=aa(t).toLowerCase(),l=Sa(t),f=(x.skills||[]).find(v=>{const j=Ja(v);return j.has(n)||l&&j.has(l)});f&&X(f.id||f.directory)},[x.skills]);i.useEffect(()=>{o!=="my"&&z.size&&I(new Set)},[o,z.size]),i.useEffect(()=>{T&&!ee&&X(null)},[ee,T]);const Fe=i.useMemo(()=>{const t=u===U?k:u===W?fe:c,l=u===U||u===W||u===xe?t:t.filter(j=>`${j.repoOwner}/${j.repoName}`===u),f=L.trim().toLowerCase();return(u===U||!f?l:l.filter(j=>(j.name||"").toLowerCase().includes(f)||(j.directory||"").toLowerCase().includes(f)||(j.description||"").toLowerCase().includes(f))).map(j=>{const ze=aa(j).toLowerCase(),V=Sa(j);return{...j,installed:ce.has(ze)||V&&ce.has(V)}})},[L,c,ce,fe,k,u]),nt=e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(te,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),it=e.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[e.jsx(te,{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")})]}),Qe=(t,n=null)=>e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r(t)}),n]});let Je;if(Te)Je=nt;else if(o==="my")Je=ve.length?e.jsx(Vr,{items:Za,totalCount:ve.length,targets:le,agentOptions:le,agentFilter:E,onAgentFilter:M,anyFilter:et,onClearFilters:at,searchQuery:$,onSearchQuery:F,searchPlaceholder:r("skills.my.placeholder"),selectedId:T,onSelect:tt,onToggleTarget:He,busyKey:q,updates:_e,selectedIds:z,onToggleSelect:ia,onClearSelection:ke,onBulkSync:b,onBulkRemove:Q}):e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-800",children:[le.length>0?e.jsxs("div",{className:"relative h-11 w-80 overflow-hidden","aria-hidden":!0,children:[e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)",WebkitMaskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",style:{filter:"blur(2.5px)"},children:[...le,...le].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(Ne,{provider:t.id,size:30})},`b-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)",WebkitMaskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",children:[...le,...le].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(Ne,{provider:t.id,size:30})},`c-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 w-20 bg-gradient-to-r from-oai-white to-transparent dark:from-oai-gray-900"}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 w-20 bg-gradient-to-l from-oai-white to-transparent dark:from-oai-gray-900"})]}):null,e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.empty.my")}),e.jsx(J,{type:"button",size:"sm",onClick:()=>h("browse"),children:r("skills.empty.my_cta")})]});else{const t=u===U,n=u===W,l=C.length===0&&!t&&!n,f=Ee&&!t&&!n||n&&Ae,v=!t&&!n&&(L.trim()!==""||u!==xe),j=()=>{S(""),w(xe)},ze=!l&&!f&&(Fe.length>0||v)?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:Fe.length})}),v?e.jsxs("button",{type:"button",onClick:j,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(De,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]}):null;let V;l?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")})}):f?V=it:t&&m.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")}):Fe.length?V=e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:Fe.map(Ke=>e.jsx("div",{style:Wr,children:e.jsx(qr,{skill:Ke,installed:!!Ke.installed,installing:q===Xe(Ke),allTargets:Ya,defaultTargets:la,onInstall:ra,onManage:st})},Ke.id||Ke.key))}):v?V=Qe("skills.empty.no_match",e.jsx(J,{type:"button",variant:"secondary",size:"sm",onClick:j,children:r("skills.filter.clear")})):t?V=Qe("skills.empty.search"):n?V=Qe("skills.empty.popular"):V=Qe("skills.empty.browse");const ot=l||pe?e.jsx("div",{className:"mb-5",children:e.jsx(Hr,{repos:C,repoInput:Ce,onRepoInput:he,busyKey:q,onAdd:Me,onRemove:Ue})}):null,lt=!pe&&!t&&!n&&C.length<=1&&Fe.length>0?e.jsx(xr,{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:()=>_(!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;Je=e.jsxs(e.Fragment,{children:[ot,ze,V,lt]})}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(J,{type:"button",variant:"secondary",size:"sm",onClick:be,disabled:Te||Ee||Ae,children:[e.jsx(Pt,{className:ae("mr-1.5 h-3.5 w-3.5",(Te||Ee||Ae)&&"animate-spin"),"aria-hidden":!0}),r("skills.action.refresh")]})]}),e.jsx("div",{className:"mb-5 flex gap-6 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[["my",r("skills.tab.my")],["browse",r("skills.tab.browse")]].map(([t,n])=>e.jsx("button",{type:"button","aria-pressed":o===t,onClick:()=>h(t),className:ae("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",o===t?"border-oai-black text-oai-black dark:border-white dark:text-white":"border-transparent text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:n},t))}),re?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:re}):null,o==="browse"?e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx(Ot,{className:"shrink-0",ariaLabel:r("skills.source.label"),options:[{id:"repo",label:r("skills.mode.repo")},{id:"popular",label:r("skills.mode.popular"),icon:e.jsx(cr,{className:"h-3.5 w-3.5","aria-hidden":!0})},{id:"skillssh",label:r("skills.mode.skillssh")}],value:u===U?"skillssh":u===W?"popular":"repo",onChange:t=>{t==="skillssh"?w(U):t==="popular"?w(W):(u===U||u===W)&&w(xe)}}),u!==U&&u!==W?e.jsxs(La,{value:u,onValueChange:w,children:[e.jsxs(Pa,{"aria-label":r("skills.source.label"),className:"inline-flex h-8 w-44 shrink-0 items-center justify-between gap-2 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs text-oai-black focus:outline-none data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:data-[popup-open]:border-oai-gray-700",children:[e.jsx(Da,{children:t=>t===xe?r("skills.source.all"):t}),e.jsx(Va,{className:"text-oai-gray-400",children:e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Ba,{children:e.jsx(Ta,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ea,{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(Ye,{value:xe,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(Ze,{children:r("skills.source.all")}),e.jsx(ea,{children:e.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),C.map(t=>{const n=`${t.owner}/${t.name}`;return e.jsxs(Ye,{value:n,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(Ze,{children:n}),e.jsx(ea,{children:e.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},n)})]})})})]}):null,e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ma,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(xa,{type:"search",value:m,onChange:t=>S(t.target.value),onKeyDown:t=>{t.key==="Enter"&&u===U&&we()},"aria-label":r("skills.action.search_aria"),placeholder:u===U?r("skills.browse.placeholder_skillssh"):u===W?r("skills.browse.placeholder_popular"):u===xe?r("skills.browse.placeholder_all"):r("skills.browse.placeholder_repo",{repo:u}),className:"h-8 pl-9 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20"})]}),u===U?e.jsxs(J,{type:"button",size:"sm",onClick:we,disabled:m.trim().length<2||q==="search",className:"focus:!ring-oai-gray-400/30",children:[q==="search"?e.jsx(te,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(ma,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.action.search")]}):u===W?null:e.jsxs(J,{type:"button",variant:"secondary",size:"sm",onClick:()=>_(t=>!t),"aria-expanded":pe,className:"!h-8 shrink-0 whitespace-nowrap !border-oai-gray-200 dark:!border-oai-gray-800 hover:!border-oai-gray-300 dark:hover:!border-oai-gray-700 hover:!text-oai-black dark:hover:!text-white focus:!ring-oai-gray-400/30",children:[e.jsx(Oa,{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:C.length})]})]}):null,Je,e.jsx(Pr,{skill:ee,targets:le,busyKey:q,usage:ee&&(K[String(ee.directory||"").toLowerCase()]||K[String(ee.name||"").toLowerCase()])||null,hasUpdate:!!(ee?.id&&_e?.[ee.id]),updating:ee?q===Xe(ee):!1,onUpdate:oe,onClose:rt,onToggleTarget:He,onRemove:sa})]})}),e.jsx(ba,{open:!!N,title:r("skills.confirm.remove_title",{name:N?.name||N?.directory||""}),description:N?N.managed?r("skills.confirm.remove_managed"):r("skills.confirm.remove_local"):"",confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:q===_a(N||{}),onCancel:()=>H(null),onConfirm:na}),e.jsx(ba,{open:!!se,title:r("skills.confirm.bulk_remove_title",{count:se?.length||0}),description:r("skills.confirm.bulk_remove_desc"),confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:q==="batch",onCancel:()=>B(null),onConfirm:ie})]})}export{Ns as SkillsPage,$r as buildLocallyInstalledKeys};
1
+ import{m as dt,r as i,V as ct,z as ga,j as e,X as De,c as r,e as ae,aF as da,ay as ut,aI as mt,y as gt,aJ as ya,aK as xt,aL as ht,Z as pt,aM as ft,aN as yt,aO as bt,aP as kt,A as wt,aQ as vt,aA as jt,az as Nt,aR as Ct,a4 as St,a as _t,aS as Rt,ao as It,J as Lt,B as J,R as Pt,d as Dt,aT as Bt,a5 as Pe}from"./__vite-browser-external-4IGm4Djn.js";import{L as Tt,I as xa}from"./LocalOnlyNotice-Cmnvu9tI.js";import{C as Et}from"./Card-aSp259T0.js";import{C as ba}from"./ConfirmModal-CVjmhZd6.js";import{S as Ot}from"./SegmentedControl-hGXboQZy.js";import{I as Ra}from"./info-CAjN3dX4.js";import{P as Ne}from"./ProviderIcon-BZZ45-gY.js";import{m as ka}from"./react-DZqS6YTX.js";import{u as At}from"./useCurrency-B0YsRDj-.js";import{E as ca}from"./external-link-CwbuMbeQ.js";import{L as te}from"./loader-circle-CnF8qPi1.js";import{M as Ia}from"./monitor-smartphone-DDgwxG_E.js";import{C as Be}from"./check-DIKw7TYH.js";import{T as ha}from"./trash-2-CjEAS5ic.js";import{A as $t}from"./index-ChZkJjpk.js";import{u as Mt}from"./use-reduced-motion-D_kUnDs4.js";import{u as Ut,s as Ft,k as zt,l as Kt,m as Vt,n as Wt,o as qt,p as Ht,S as La,c as Pa,d as Da,e as Ba,f as Ta,g as Ea,h as Ye,j as Ze,i as ea}from"./SelectItemText-Odx47kND.js";import{t as Gt,u as ua,m as Qt}from"./composite-_NeXO0lv.js";import{u as Jt,C as pa}from"./ToolbarRootContext-Bmg56vYz.js";import{g as Xt,a as Yt,p as Zt,m as er,b as ar,d as tr,c as rr,e as sr,f as nr,s as ir,i as wa,u as va,h as ja,r as or,j as Na,k as Ca,l as lr,n as dr}from"./skills-api-vsA1rc1Z.js";import{F as cr}from"./flame-DcYbLdhE.js";import{S as ma}from"./search-D6tEppYJ.js";import{P as Oa}from"./plus-DIc1YUWB.js";import{D as Aa}from"./download-DM1W9pIW.js";import{P as $a,a as Ma,b as Ua,c as Fa,d as za}from"./PopoverPopup-DXD_YdiB.js";import"./arrow-up-right-rpBCOTg2.js";import"./DialogTitle-DfSBUjWf.js";import"./store-Crne4DqF.js";import"./DialogDescription-KY7X94CG.js";const ur=[["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"}]],Ka=dt("circle-arrow-up",ur),Va=i.forwardRef(function(s,d){const{render:o,className:h,style:x,...g}=s,{store:c}=Ut(),k={open:ct(c,Ft.open)};return ga("span",s,{state:k,ref:d,props:[{"aria-hidden":!0,children:"▼"},g],stateAttributesMapping:Gt})}),mr="tt:hint:dismissed:";function Wa(a){return mr+a}function gr(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Wa(a))==="1"}catch{return!1}}function xr({id:a,children:s,className:d,ariaLabel:o}){const[h,x]=i.useState(()=>gr(a)),g=i.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(Wa(a),"1")}catch{}x(!0)},[a]);return h?null:e.jsxs("div",{role:"note","aria-label":o||r("hint.dismissible_aria"),className:ae("relative rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 py-3 text-sm text-oai-gray-700","dark:border-oai-gray-800 dark:bg-oai-gray-900/40 dark:text-oai-gray-300",d),children:[e.jsx("button",{type:"button",onClick:g,"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(De,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(Ra,{className:"mt-0.5 h-4 w-4 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:s})]})]})}function hr(a){if(!a)return null;for(const s of a.elements){const d=s.tagName;if(d==="BUTTON"||d==="INPUT"){const o=s;if(o.type==="submit")return o}}return null}function qa(a){return{checked(s){return a.indeterminate?{}:s?{"data-checked":""}:{"data-unchecked":""}},...zt}}const pr=i.createContext({disabled:!1});function fr(){return i.useContext(pr)}function yr(a,s,d,o=!0,h){const[x,g]=i.useState(),c=ua(h?`${h}-label`:void 0),y=a??s??x;return da(()=>{const k=a||s||!o?void 0:br(d.current,c);x!==k&&g(k)}),y}function br(a,s){const d=kr(a);if(d)return!d.id&&s&&(d.id=s),d.id||void 0}function kr(a){if(!a)return;const s=a.parentElement;if(s&&s.tagName==="LABEL")return s;const d=a.id;if(d){const h=a.nextElementSibling;if(h&&h.htmlFor===d)return h}const o=a.labels;return o&&o[0]}const wr=i.createContext(void 0);function vr(){return i.useContext(wr)}const Ha=i.createContext(void 0);function jr(){const a=i.useContext(Ha);if(a===void 0)throw new Error(ut(14));return a}const Nr="data-parent",Cr=i.forwardRef(function(s,d){const{checked:o,className:h,defaultChecked:x=!1,"aria-labelledby":g,disabled:c=!1,form:y,id:k,indeterminate:p=!1,inputRef:C,name:R,onCheckedChange:u,parent:w=!1,readOnly:m=!1,render:S,required:L=!1,uncheckedValue:A,value:$,nativeButton:F=!1,style:de,...D}=s,{clearErrors:Ce}=Kt(),{disabled:he,name:pe,setDirty:_,setFilled:E,setFocused:M,setTouched:T,state:X,validationMode:q,validityData:Se,validation:Te}=Vt(),Ve=fr(),{labelId:Ee,controlId:We,registerControlId:re,getDescriptionProps:O}=Wt(),N=vr(),H=N?.allValues===void 0?void 0:N.parent,se=H!==void 0,B=he||Ve.disabled||N?.disabled||c,z=pe??R,I=$??z,_e=ua(),Oe=ua();let K=k||We;se&&(w?K=Oe:I!==void 0?K=`${H.id}-${I}`:K||=Oe);let Re={};se&&(w?Re=H.getParentProps():I!==void 0&&(Re=H.getChildProps(I)));const{checked:fe=o,indeterminate:ta=p,onCheckedChange:Ae,...qe}=Re,ye=N?.value,ne=i.useRef(null),ce=mt(()=>Symbol()),ue=i.useRef(!1),{getButtonProps:Ie,buttonRef:me}=gt({disabled:B,native:F}),Y=N?.validation??Te,[P,Le]=qt({controlled:I!==void 0&&ye!==void 0&&!w?ye.includes(I):fe,default:x,name:"Checkbox",state:"checked"}),ge=se?!!fe:P,be=se&&ta||p;da(()=>{re!==ya&&(ue.current=!0,re(ce.current,K))},[K,re,ce]),i.useEffect(()=>{const b=ce.current;return()=>{!ue.current||re===ya||(ue.current=!1,re(b,void 0))}},[re,ce]),Ht(ne,_e,P,void 0,!N&&!B,R);const Z=i.useRef(null),$e=Y.registerInput,G=N?I:void 0,ra=i.useCallback(b=>$e(b,{controlRef:ne,value:G}),[$e,G]),sa=xt(C,Z,w?void 0:ra),na=yr(g,Ee,Z,!F,K??void 0);da(()=>{Z.current&&(Z.current.indeterminate=be,P&&E(!0))},[P,be,E]),Jt(P,()=>{N||(Ce(z),E(P),_(P!==Se.initialValue),Y.change(P))});const He=ht({checked:P,disabled:B,form:y,name:w?void 0:z,id:F?void 0:K??void 0,required:L,ref:sa,style:z?bt:kt,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(b){if(b.nativeEvent.defaultPrevented)return;if(m){b.preventDefault();return}const Q=b.currentTarget.checked,ie=wt(vt,b.nativeEvent);if(u?.(Q,ie),!ie.isCanceled&&(Ae?.(Q,ie),!ie.isCanceled&&(Le(Q),I!==void 0&&N!==void 0&&!w&&!se))){const oe=Q?[...N.value,I]:N.value.filter(we=>we!==I);N.setValue(oe,ie)}},onClick(b){b.stopPropagation()},onFocus(){ne.current?.focus()}},$!==void 0?{value:(N?P&&$:$)||""}:pt,O,b=>Y.getValidationProps(B,b));i.useEffect(()=>{if(!H||I===void 0)return;const b=H.disabledStatesRef.current;return b.set(I,B),()=>{b.delete(I)}},[H,B,I]);const ke=i.useMemo(()=>({...X,checked:ge,disabled:B,readOnly:m,required:L,indeterminate:be}),[X,ge,B,m,L,be]),ia=qa(ke),Ge=ga("span",s,{state:ke,ref:[me,ne,d],props:[{id:F?K??void 0:_e,role:"checkbox","aria-checked":be?"mixed":ge,"aria-readonly":m||void 0,"aria-required":L||void 0,"aria-labelledby":na,[Nr]:w?"":void 0,onFocus(){B||M(!0)},onBlur(){const b=Z.current;b&&(T(!0),M(!1),q==="onBlur"&&Y.commit(N?ye:b.checked))},onKeyDown(b){if(b.key!=="Enter"||(b.preventBaseUIHandler(),b.defaultPrevented))return;const Q=Z.current?.form??null,ie=b.currentTarget,oe=b.nativeEvent,we=b.preventDefault,Me=oe.preventDefault;let Ue=!1;b.preventDefault=()=>{Ue=!0,we.call(b)},oe.preventDefault=()=>{Ue=!0,Me.call(oe)},Me.call(oe),yt(ie).queueMicrotask(()=>{b.preventDefault=we,oe.preventDefault=Me,Ue||hr(Q)?.click()})},onClick(b){if(m||B)return;b.preventDefault();const Q=Z.current;Q&&ft(Q,b)}},D,qe,Ie,O,b=>Y.getValidationProps(B,b)],stateAttributesMapping:ia});return e.jsxs(Ha.Provider,{value:ke,children:[Ge,!P&&!N&&z&&!w&&A!==void 0&&e.jsx("input",{type:"hidden",form:y,name:z,value:A,disabled:B}),e.jsx("input",{...He,suppressHydrationWarning:!0})]})}),Sr=i.forwardRef(function(s,d){const{render:o,className:h,style:x,keepMounted:g=!1,...c}=s,y=jr(),k=y.checked||y.indeterminate,{mounted:p,transitionStatus:C,setMounted:R}=Qt(k),u=i.useRef(null),w={...y,transitionStatus:C};jt({open:k,ref:u,onComplete(){k||R(!1)}});const S={...qa(y),...Nt},L=g||p,A=ga("span",s,{ref:[d,u],state:w,stateAttributesMapping:S,props:c});return L?A:null});function _r(a,s){return`target:${a}:${s}`}function Rr(a){return`remove:${a.id||a.directory}`}function Ga(a){if(!a)return null;const s=new Date(a).getTime();return Number.isFinite(s)?Math.floor((Date.now()-s)/864e5):null}function Ir(a){const s=Ga(a);if(s==null)return null;if(s<=0)return r("skills.usage.today");if(s<30)return r("skills.usage.days_ago",{days:s});const d=Math.max(1,Math.floor(s/30));return r("skills.usage.months_ago",{months:d})}function Lr(a){const s=Ga(a);return s==null?"bg-oai-gray-300 dark:bg-oai-gray-600":s<=7?"bg-emerald-500":s<=30?"bg-amber-500":"bg-oai-gray-300 dark:bg-oai-gray-600"}function oa({label:a,children:s}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2 text-sm",children:[e.jsx("dt",{className:"flex items-center gap-1 text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"text-right font-medium tabular-nums text-oai-black dark:text-white",children:s})]})}function Pr({skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k}){return e.jsx($t,{children:a?e.jsx(Dr,{skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k},a.id||a.directory):null})}function Dr({skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k}){const p=Mt(),{currency:C,rate:R}=At(),u=i.useRef(null);i.useEffect(()=>{const _=M=>{M.key==="Escape"&&(M.stopPropagation(),c?.())},E=M=>{const T=M.target;T instanceof Element&&(u.current?.contains(T)||T.closest('[data-skill-row="1"]')||c?.())};return document.addEventListener("keydown",_),document.addEventListener("pointerdown",E),()=>{document.removeEventListener("keydown",_),document.removeEventListener("pointerdown",E)}},[c]);const w=a.name||a.directory,m=!!(a.repoOwner&&a.repoName),S=m?`https://github.com/${a.repoOwner}/${a.repoName}`:null,L=new Set(a.targets||[]),A=!!(a.readOnly||a.remote),$=!!a.remote,F=Array.isArray(a.deviceSources)?a.deviceSources:[],de=!$&&(!A||L.has("claude")),D=d===Rr(a),Ce=Ir(o?.lastUsedAt),he=!!(o&&o.invocations>0),pe=p?{duration:0}:{type:"spring",stiffness:320,damping:30,mass:.7};return e.jsxs(e.Fragment,{children:[e.jsx(ka.div,{className:"fixed inset-0 z-20 bg-oai-black/30 backdrop-blur-[2px] lg:hidden",initial:p?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:p?0:.15},onClick:c,"aria-hidden":!0}),e.jsxs(ka.aside,{ref:u,role:"complementary","aria-label":w,initial:p?!1:{opacity:0,x:24,scale:.98},animate:{opacity:1,x:0,scale:1},exit:p?{opacity:0}:{opacity:0,x:24,scale:.98},transition:pe,className:"fixed inset-x-3 bottom-3 top-20 z-30 flex flex-col overflow-hidden rounded-2xl border border-white/40 bg-white/75 shadow-[0_24px_60px_-20px_rgba(15,23,42,0.25)] backdrop-blur-xl backdrop-saturate-150 supports-[backdrop-filter]:bg-white/65 dark:border-white/10 dark:bg-oai-gray-950/70 dark:shadow-[0_24px_60px_-20px_rgba(0,0,0,0.7)] dark:supports-[backdrop-filter]:bg-oai-gray-950/55 lg:inset-auto lg:right-6 lg:top-24 lg:bottom-6 lg:w-[22rem] lg:max-h-[calc(100vh-7.5rem)]",children:[e.jsxs("header",{className:"flex items-center gap-3 border-b border-white/40 bg-gradient-to-b from-white/30 to-transparent px-5 pb-4 pt-5 dark:border-white/10 dark:from-white/[0.04]",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",title:w,children:w}),m?e.jsxs("a",{href:S,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:S,children:[e.jsxs("span",{className:"truncate",children:[a.repoOwner,"/",a.repoName]}),e.jsx(ca,{className:"h-3 w-3 shrink-0","aria-hidden":!0})]}):a.directory&&a.directory!==w?e.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",title:a.directory,children:a.directory}):null]}),e.jsx("button",{type:"button",onClick:c,"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(De,{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:[h?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(Ka,{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:()=>g?.(a),disabled:x,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:[x?e.jsx(te,{className:"h-3 w-3 animate-spin","aria-hidden":!0}):null,r("skills.update.action")]})]}):null,a.description?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a.description}):null,A?e.jsx("div",{className:"mt-4 rounded-xl bg-oai-gray-50 px-3 py-2.5 text-xs leading-5 text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-900/60 dark:text-oai-gray-300 dark:ring-oai-gray-800",children:r($?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed")}):null,a.sourceName?e.jsx("div",{className:"mt-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.source",{source:a.sourceName})}):null,F.length?e.jsxs("section",{className:"mt-5",children:[e.jsx("h3",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.devices_title")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:F.map(_=>e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 rounded-full bg-oai-gray-100 px-2.5 py-1 text-xs text-oai-gray-700 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-200 dark:ring-oai-gray-700",children:[e.jsx(Ia,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"max-w-52 truncate",children:_.name})]},_.id))})]}):null,de?e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.usage.section_title")}),e.jsxs("dl",{className:"divide-y divide-oai-gray-200/60 dark:divide-white/[0.06]",children:[e.jsx(oa,{label:r("skills.usage.invocations"),children:Ct(o?.invocations||0)}),e.jsx(oa,{label:r("skills.usage.last_used"),children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:ae("h-1.5 w-1.5 rounded-full",Lr(o?.lastUsedAt)),"aria-hidden":!0}),he?Ce||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(oa,{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(Ra,{className:"h-3 w-3","aria-label":r("skills.usage.disclaimer")})})]}),children:St(o?.cost||0,{currency:C,rate:R})})]}),he?null:e.jsx("p",{className:"mt-2 text-[11px] leading-4 text-oai-gray-400 dark:text-oai-gray-500",children:r("skills.usage.unused")})]}):null,A?null:e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.detail.sync_section_title")}),e.jsx("div",{children:(s||[]).filter(_=>_.manageable!==!1).map(_=>{const E=L.has(_.id),M=d===_r(a.id||a.directory,_.id),T=`skill-detail-sync-${a.id||a.directory}-${_.id}`;return e.jsxs("label",{htmlFor:T,className:"-mx-2 flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 text-sm text-oai-black transition-colors hover:bg-oai-gray-100/70 dark:text-white dark:hover:bg-white/[0.05]",children:[e.jsx(Cr,{id:T,checked:E,disabled:M,onCheckedChange:X=>y?.(a,_.id,!!X),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(Sr,{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(Ne,{provider:_.id,size:16})}),e.jsx("span",{className:"flex-1",children:_.label}),M?e.jsx(te,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},_.id)})})]})]}),A?null:e.jsxs("footer",{className:"border-t border-white/40 bg-white/30 px-5 py-4 dark:border-white/10 dark:bg-white/[0.02]",children:[e.jsxs("button",{type:"button",onClick:()=>k?.(a),disabled:D,className:"inline-flex w-full items-center justify-center gap-2 rounded-lg border border-red-200/70 bg-white px-3 py-2 text-sm font-medium text-red-600 transition hover:border-red-300 hover:bg-red-50 focus:outline-none focus:ring-2 focus:ring-red-400/30 disabled:cursor-not-allowed disabled:opacity-60 dark:border-red-900/60 dark:bg-oai-gray-950 dark:text-red-300 dark:hover:border-red-800 dark:hover:bg-red-950/30",children:[D?e.jsx(te,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(ha,{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 Br=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),la=["claude","codex"],W="popular",Tr={claude:"text-orange-500 dark:text-orange-300",codex:"text-emerald-600 dark:text-emerald-300",grok:"text-zinc-700 dark:text-zinc-200",antigravity:"text-violet-600 dark:text-violet-300",gemini:"text-sky-600 dark:text-sky-300",opencode:"text-amber-600 dark:text-amber-300",hermes:"text-indigo-500 dark:text-indigo-300"},xe="all",U="skillssh";function aa(a){return`${a.repoOwner||"local"}/${a.repoName||"local"}:${a.directory}`}function Qa(a){return String(a||"").replace(/\\/g,"/").trim().toLowerCase()}function Er(a){return Qa(a).split("/").filter(Boolean).pop()||""}function Or(a){if(a.repoOwner||a.repoName)return"";const s=Qa(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function Sa(a){const s=Er(a.directory);return s?`dir:${s}`:""}function Ja(a){const s=new Set([aa(a).toLowerCase()]);a.repoOwner&&a.repoName&&s.add(`${a.repoOwner}/${a.repoName}:${a.sourceDirectory||a.directory}`.toLowerCase());const d=Or(a);return d&&s.add(d),s}function Ar(a){return!a?.remote&&!a?.inventoryOnly&&!a?.readOnly}function $r(a){const s=new Set;for(const d of Array.isArray(a)?a:[])if(Ar(d))for(const o of Ja(d))s.add(o);return s}function Xe(a){return`install:${aa(a)}`}function _a(a){return`remove:${a.id||a.directory}`}function Xa(a,s){return`target:${a}:${s}`}function je(a){return a.id||a.directory}function fa(a){return a.manageable!==!1}function Mr({target:a,state:s,busy:d,disabled:o,disabledLabel:h,onToggle:x}){const g=s==="synced",c=s==="orphan",y=c?r("skills.dot.orphan_aria",{agent:a.label}):g?r("skills.dot.synced_aria",{agent:a.label}):r("skills.dot.off_aria",{agent:a.label}),k=o&&h?`${y} — ${h}`:y;return e.jsxs("button",{type:"button",title:k,"aria-label":k,"aria-pressed":g,disabled:d||o,onClick:p=>{p.stopPropagation(),x?.(a.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:[d?e.jsx(te,{className:"h-4 w-4 animate-spin text-oai-gray-400","aria-hidden":!0}):e.jsx("span",{className:ae("flex h-[18px] w-[18px] items-center justify-center transition",g&&Tr[a.id],!g&&!c&&"opacity-35 grayscale"),"aria-hidden":!0,children:e.jsx(Ne,{provider:a.id,size:18})}),c&&!d?e.jsx("span",{className:"absolute -bottom-px -right-px h-2 w-2 rounded-full bg-amber-500 ring-2 ring-oai-white dark:ring-oai-gray-900","aria-hidden":!0}):null]})}function Ur({skill:a,targets:s,onToggleTarget:d,busyKey:o}){const h=new Set(a.targets||[]),x=!!(a.readOnly||a.remote),g=[];for(const c of s)(x?h.has(c.id):fa(c))&&g.push(c);return e.jsx("div",{className:"flex items-center gap-1",onClick:c=>c.stopPropagation(),children:g.map(c=>e.jsx(Mr,{target:c,state:a.targetStates?.[c.id]||"off",busy:o===Xa(je(a),c.id),disabled:x||c.manageable===!1,disabledLabel:r(a.remote?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed"),onToggle:(y,k)=>d?.(a,y,k)},c.id))})}function Fr({skill:a,targets:s,selected:d,onSelect:o,selectable:h,checked:x,onToggleSelect:g,onToggleTarget:c,hasUpdate:y,busyKey:k}){const p=a.repoOwner&&a.repoName?`${a.repoOwner}/${a.repoName}`:null,C=[a.directory,p,a.sourceName].filter(Boolean).join(" · "),R=Array.isArray(a.deviceSources)?a.deviceSources:[],u=[a.remote?r("skills.inventory.remote"):null,a.scope==="plugin"?r("skills.inventory.plugin"):null].filter(Boolean),w=m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),o?.(a))};return e.jsxs("div",{"data-skill-row":"1",role:"button",tabIndex:0,"aria-pressed":d,"aria-label":r("skills.row.open_details",{name:a.name||a.directory}),onClick:()=>o?.(a),onKeyDown:w,className:ae("cursor-pointer rounded-md py-3 pr-2 transition focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30",d?"bg-oai-gray-100 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800/60 dark:ring-oai-gray-800":x?"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:[h?e.jsx("label",{className:"flex shrink-0 items-center",onClick:m=>m.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:x,onChange:m=>g?.(a,m.target.checked),"aria-label":r("skills.select.row_aria",{name:a.name||a.directory}),className:"h-4 w-4 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white"})}):null,e.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-oai-black dark:text-white",title:C,children:a.name||a.directory}),u.map(m=>e.jsx("span",{className:"inline-flex shrink-0 rounded-full bg-oai-gray-100 px-1.5 py-0.5 text-[10px] font-semibold text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-300 dark:ring-oai-gray-700",children:m},m)),y?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-semibold text-sky-700 ring-1 ring-sky-200 dark:bg-sky-950/40 dark:text-sky-300 dark:ring-sky-800/60",children:[e.jsx(Ka,{className:"h-2.5 w-2.5","aria-hidden":!0}),r("skills.update.badge")]}):null,e.jsx(Ur,{skill:a,targets:s,onToggleTarget:c,busyKey:k}),e.jsx(Bt,{className:ae("hidden h-4 w-4 shrink-0 text-oai-gray-300 transition-colors dark:text-oai-gray-600 lg:block",d&&"text-oai-gray-500 dark:text-oai-gray-300"),"aria-hidden":!0})]}),a.description?e.jsx("p",{className:ae("mt-1 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",h&&"pl-7"),children:a.description}):null,a.sourceName||R.length?e.jsxs("div",{className:ae("mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-oai-gray-400 dark:text-oai-gray-500",h&&"pl-7"),children:[a.sourceName?e.jsx("span",{className:"truncate",children:a.sourceName}):null,R.length?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:R.map(m=>m.name).join(", "),children:[e.jsx(Ia,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r("skills.inventory.on_devices",{devices:R.map(m=>m.name).join(", ")})})]}):null]}):null]})}function zr({agentFilter:a,agentOptions:s,onAgentFilter:d,filteredCount:o,totalCount:h,anyFilter:x,onClearFilters:g,searchQuery:c,onSearchQuery:y,searchPlaceholder:k}){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(La,{value:a,onValueChange:d,children:[e.jsxs(Pa,{"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(Da,{children:p=>p==="all"?r("skills.filter.agent_all"):s.find(C=>C.id===p)?.label||p}),e.jsx(Va,{className:"text-oai-gray-400",children:e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Ba,{children:e.jsx(Ta,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ea,{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(Ye,{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(Ze,{children:r("skills.filter.agent_all")}),e.jsx(ea,{children:e.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),s.map(p=>e.jsxs(Ye,{value:p.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(Ne,{provider:p.id,size:14}),e.jsx(Ze,{children:p.label})]}),e.jsx(ea,{children:e.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},p.id))]})})})]}),e.jsxs("div",{className:"relative w-56 max-w-full",children:[e.jsx(ma,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(xa,{type:"search",value:c,onChange:p=>y(p.target.value),onKeyDown:p=>{p.key==="Escape"&&c&&(p.preventDefault(),y(""))},"aria-label":r("skills.action.search_aria"),placeholder:k,className:"h-8 pl-9 pr-8 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20 [&::-webkit-search-cancel-button]:appearance-none"}),e.jsx("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>y(""),"aria-label":r("skills.action.search_clear"),"aria-hidden":!c,tabIndex:c?0:-1,className:ae("absolute right-2 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full text-oai-gray-400 transition duration-150 ease-out before:absolute before:-inset-1.5 before:content-[''] hover:bg-oai-gray-100 hover:text-oai-gray-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 motion-reduce:transition-none dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",c?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(De,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{role:"status","aria-live":"polite",className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.filter.result_count",{filtered:o,total:h})}),x?e.jsxs("button",{type:"button",onClick:g,className:"shrink-0 inline-flex h-7 items-center gap-1 rounded-full bg-oai-gray-100 px-2.5 text-[11px] font-medium text-oai-gray-700 transition hover:bg-oai-gray-200 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:bg-oai-gray-800/70 dark:text-oai-gray-200 dark:hover:bg-oai-gray-700",children:[e.jsx(De,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]})}function Kr({count:a,targets:s,busy:d,onBulkSync:o,onBulkRemove:h,onClear:x}){const g=s.filter(fa);return e.jsxs("div",{role:"toolbar","aria-label":r("skills.select.toolbar_aria"),className:"mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-3 py-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/50",children:[e.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200","aria-live":"polite",children:r("skills.select.count",{count:a})}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs($a,{children:[e.jsxs(Ma,{disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200",children:[e.jsx(Aa,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_sync"),e.jsx(pa,{className:"h-3 w-3","aria-hidden":!0})]}),e.jsx(Ua,{children:e.jsx(Fa,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(za,{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")}),g.map(c=>e.jsxs("button",{type:"button",onClick:()=>o(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(Ne,{provider:c.id,size:16}),e.jsx("span",{className:"flex-1",children:c.label})]},c.id))]})})})]}),e.jsxs(J,{type:"button",variant:"ghost",size:"sm",disabled:d,onClick:h,children:[e.jsx(ha,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_remove")]}),e.jsxs("button",{type:"button",onClick:x,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(De,{className:"h-3 w-3","aria-hidden":!0}),r("skills.select.clear")]})]})]})}function Vr({items:a,totalCount:s,targets:d,agentOptions:o,agentFilter:h,onAgentFilter:x,anyFilter:g,onClearFilters:c,searchQuery:y,onSearchQuery:k,searchPlaceholder:p,selectedId:C,onSelect:R,onToggleTarget:u,busyKey:w,updates:m,selectedIds:S,onToggleSelect:L,onClearSelection:A,onBulkSync:$,onBulkRemove:F}){const de=S.size;return e.jsxs("div",{children:[de>0?e.jsx(Kr,{count:de,targets:d,busy:w==="batch",onBulkSync:$,onBulkRemove:F,onClear:A}):e.jsx(zr,{agentFilter:h,agentOptions:o,onAgentFilter:x,filteredCount:a.length,totalCount:s,anyFilter:g,onClearFilters:c,searchQuery:y,onSearchQuery:k,searchPlaceholder:p}),a.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r("skills.empty.no_match")}),e.jsx(J,{type:"button",variant:"secondary",size:"sm",onClick:c,children:r("skills.filter.clear")})]}):e.jsx("div",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(D=>e.jsx(Fr,{skill:D,targets:d,selected:C===(D.id||D.directory),onSelect:R,selectable:!D.readOnly&&!D.remote,checked:S.has(je(D)),onToggleSelect:L,onToggleTarget:u,hasUpdate:!!(D.id&&m?.[D.id]),busyKey:w},je(D)))})]})}const Wr={contentVisibility:"auto",containIntrinsicSize:"0 240px"},qr=Dt.memo(function({skill:s,installed:d,installing:o,allTargets:h,defaultTargets:x,onInstall:g,onManage:c}){const[y,k]=i.useState(()=>(x||[]).filter(m=>h.some(S=>S.id===m))),p=m=>{k(S=>S.includes(m)?S.filter(L=>L!==m):[...S,m])},C=s.repoOwner&&s.repoName?`${s.repoOwner}/${s.repoName}`:null,R=C?`https://github.com/${s.repoOwner}/${s.repoName}`:null,u=s.installs!=null?r("skills.card.installs",{count:Number(s.installs||0).toLocaleString()}):null,w=y.length?y.map(m=>h.find(S=>S.id===m)?.label||m).join(", "):r("skills.action.choose_targets");return e.jsxs(Et,{className:"h-full rounded-lg",bodyClassName:"flex h-full flex-col",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[s.readmeUrl?e.jsxs("a",{href:s.readmeUrl,target:"_blank",rel:"noopener noreferrer",className:"group inline-flex max-w-full items-center gap-1 truncate text-base font-semibold text-oai-black hover:underline dark:text-white",title:s.readmeUrl,children:[e.jsx("span",{className:"truncate",children:s.name||s.directory}),e.jsx(ca,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:s.name||s.directory}),C||u?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:[R?e.jsxs("a",{href:R,target:"_blank",rel:"noopener noreferrer",onClick:m=>m.stopPropagation(),className:"inline-flex items-center gap-1 truncate rounded text-oai-gray-500 hover:text-oai-black hover:underline focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:text-white",title:R,children:[e.jsx("span",{className:"truncate",children:C}),e.jsx(ca,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,C&&u?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,u?e.jsx("span",{className:"truncate",children:u}):null]}):null]})}),s.description?e.jsx("p",{className:"mt-3 line-clamp-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:s.description}):null,e.jsx("div",{className:"mt-auto pt-5",children:d?e.jsxs(J,{type:"button",variant:"secondary",size:"sm",onClick:()=>c?.(s),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:y.length?w:r("skills.target.none")}),e.jsxs($a,{children:[e.jsx(Ma,{disabled:o,"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(Ua,{children:e.jsx(Fa,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(za,{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")}),h.map(m=>{const S=y.includes(m.id);return e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm text-oai-black hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 shrink-0 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white",checked:S,onChange:()=>p(m.id)}),e.jsx(Ne,{provider:m.id,size:16}),e.jsx("span",{className:"flex-1 text-left",children:m.label})]},m.id)})]})})})]})]}),e.jsxs(J,{type:"button",size:"sm",onClick:()=>g(s,y),disabled:o||y.length===0,className:"w-full",children:[o?e.jsx(te,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(Aa,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.action.install")]})]})})]})});function Hr({repos:a,repoInput:s,onRepoInput:d,busyKey:o,onAdd:h,onRemove:x}){return e.jsxs("div",{className:"rounded-lg border border-oai-gray-200 bg-white p-4 dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx(xa,{value:s,onChange:g=>d(g.target.value),placeholder:r("skills.repo.placeholder"),className:"min-w-0 flex-1"}),e.jsxs(J,{type:"button",variant:"secondary",size:"md",onClick:h,disabled:o==="repo:add",className:"shrink-0 whitespace-nowrap",children:[o==="repo:add"?e.jsx(te,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(Oa,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.repo.add")]})]}),a.length?e.jsx("div",{className:"mt-3 divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(g=>{const c=o===`repo:${g.owner}/${g.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:[g.owner,"/",g.name]}),e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:g.branch})]}),e.jsxs(J,{type:"button",variant:"ghost",size:"sm",disabled:c,onClick:()=>x(g),className:"shrink-0",children:[c?e.jsx(te,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(ha,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:r("skills.repo.remove")})]})]},`${g.owner}/${g.name}`)})}):null]})}function Gr(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Ns(){const a=_t()||{},s=!!a.signedIn,d=a.getAccessToken,[o,h]=i.useState(Gr),[x,g]=i.useState({skills:[],targets:[]}),[c,y]=i.useState([]),[k,p]=i.useState([]),[C,R]=i.useState([]),[u,w]=i.useState(xe),[m,S]=i.useState(""),[L,A]=i.useState(""),[$,F]=i.useState(""),[de,D]=i.useState(""),[Ce,he]=i.useState(""),[pe,_]=i.useState(!1),[E,M]=i.useState("all"),[T,X]=i.useState(null),[q,Se]=i.useState(""),[Te,Ve]=i.useState(!0),[Ee,We]=i.useState(!1),[re,O]=i.useState(""),[N,H]=i.useState(null),[se,B]=i.useState(null),[z,I]=i.useState(()=>new Set),[_e,Oe]=i.useState({}),[K,Re]=i.useState({}),[fe,ta]=i.useState([]),[Ae,qe]=i.useState(!1),ye=i.useRef(!1),ne=i.useRef(0),ce=i.useMemo(()=>$r(x.skills),[x.skills]),ue=i.useCallback(async()=>{const t=++ne.current,n=await Xt();if(ne.current!==t)return;const l={skills:n.skills||[],targets:n.targets||[]};g(l);const f=Rt();!s||!It()||!f||typeof d!="function"||(async()=>{try{const v=await d();if(!v||ne.current!==t)return;const[j]=await Promise.allSettled([Yt(v),Zt({accessToken:v,deviceId:f,skills:l.skills})]);if(j.status!=="fulfilled")return;const ze=j.value;if(ne.current!==t)return;g({targets:l.targets,skills:er(l.skills,ze,f)})}catch{}})()},[d,s]),Ie=i.useCallback(async()=>{const t=await ar();R(t.repos||[])},[]),me=i.useCallback(async({force:t=!1}={})=>{We(!0);try{const n=await tr({force:t});y(n.skills||[])}finally{We(!1)}},[]),Y=i.useCallback(async({force:t=!1}={})=>{qe(!0);try{const n=await rr({force:t});ta(n.skills||[])}finally{qe(!1)}},[]),P=i.useCallback(async()=>{try{const t=await sr();Oe(t?.updates||{})}catch{Oe({})}},[]),Le=i.useCallback(async()=>{try{const t=await nr(),n={};for(const l of t?.skills||[])l.installed&&(l.directory&&(n[String(l.directory).toLowerCase()]=l),n[String(l.skill).toLowerCase()]=l);Re(n)}catch{Re({})}},[]),ge=i.useCallback(async()=>{Ve(!0),O("");try{await Promise.all([ue(),Ie()])}catch(t){O(t?.message||r("skills.error.generic"))}finally{Ve(!1)}},[ue,Ie]),be=i.useCallback(async()=>{await ge();const t=n=>O(n?.message||r("skills.error.generic"));o==="my"?(P(),Le()):u===W?Y({force:!0}).catch(t):u!==U&&me({force:!0}).catch(t)},[me,ge,Y,P,Le,u,o]);i.useEffect(()=>{ge()},[ge]),i.useEffect(()=>{if(ye.current||typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("skill");if(!n){ye.current=!0;return}const l=x.skills||[];if(!l.length)return;const f=l.find(j=>j.directory===n||j.id===n);f&&(h("my"),X(f.id||f.directory)),ye.current=!0,t.delete("skill");const v=t.toString();window.history.replaceState({},"",`${window.location.pathname}${v?`?${v}`:""}${window.location.hash}`)},[x.skills]),i.useEffect(()=>{o==="browse"&&(u===U||u===W||c.length===0&&me().catch(t=>O(t?.message||r("skills.error.generic"))))},[c.length,me,u,o]),i.useEffect(()=>{o!=="browse"||u!==W||fe.length===0&&Y().catch(t=>O(t?.message||r("skills.error.generic")))},[Y,fe.length,u,o]);const Z=Object.keys(_e).length>0,$e=Object.keys(K).length>0;if(i.useEffect(()=>{o==="my"&&(Z||P(),$e||Le())},[o,Z,$e,P,Le]),i.useEffect(()=>{const t=setTimeout(()=>A(m),200);return()=>clearTimeout(t)},[m]),i.useEffect(()=>{const t=setTimeout(()=>D($),120);return()=>clearTimeout(t)},[$]),i.useEffect(()=>{if(typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("tab");if(o==="my"){if(!n)return;t.delete("tab")}else{if(n===o)return;t.set("tab",o)}const l=t.toString(),f=`${window.location.pathname}${l?`?${l}`:""}${window.location.hash}`;window.history.replaceState({},"",f)},[o]),!Br&&!Lt())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Tt,{})});const G=async(t,n)=>{Se(t),O("");try{await n(),await ue()}catch(l){O(l?.message||r("skills.error.generic"))}finally{Se("")}},ra=(t,n)=>{const l=(n&&n.length?n:la).filter(f=>(x.targets||[]).some(v=>v.id===f));G(Xe(t),async()=>{await wa(t,l);const f=l.map(v=>(x.targets||[]).find(j=>j.id===v)?.label||v).join(", ");Pe({title:r("skills.toast.installed",{name:t.name||t.directory,targets:f||r("skills.target.none")}),timeout:4e3})})},sa=t=>{t?.readOnly||t?.remote||H(t)},na=()=>{const t=N;t&&(H(null),G(_a(t),async()=>{let n=null;t.managed?n=await va(t.id):await ja(t.directory,t.targets||[]);const l=!!(n?.trashed&&t.managed&&t.id);Pe({title:r("skills.toast.removed",{name:t.name||t.directory}),timeout:6e3,data:l?{onUndo:async()=>{try{await or(t.id),await ue()}catch(f){O(f?.message||r("skills.error.generic"))}}}:void 0})}))},He=(t,n,l)=>t?.readOnly||t?.remote?Promise.resolve():G(Xa(je(t),n),async()=>{const f=new Set(t.targets||[]);l?f.add(n):f.delete(n),t.managed?await Na(t.id,Array.from(f)):await Ca(t.directory,Array.from(f));const v={name:t.name||t.directory,agent:Ge(n)};Pe({title:l?r("skills.toast.synced_one",v):r("skills.toast.unsynced_one",v),timeout:3e3})}),ke=i.useCallback(()=>I(new Set),[]),ia=i.useCallback((t,n)=>{if(t?.readOnly||t?.remote)return;const l=je(t);I(f=>{const v=new Set(f);return n?v.add(l):v.delete(l),v})},[]),Ge=t=>(x.targets||[]).find(n=>n.id===t)?.label||t,b=t=>{const n=(x.skills||[]).filter(l=>z.has(je(l))&&!l.readOnly&&!l.remote);n.length&&G("batch",async()=>{for(const l of n){const f=new Set(l.targets||[]);f.add(t),l.managed?await Na(l.id,Array.from(f)):await Ca(l.directory,Array.from(f))}ke(),Pe({title:r("skills.toast.bulk_synced",{count:n.length,agent:Ge(t)}),timeout:4e3})})},Q=()=>{const t=(x.skills||[]).filter(n=>z.has(je(n))&&!n.readOnly&&!n.remote);t.length&&B(t)},ie=()=>{const t=se;t&&(B(null),G("batch",async()=>{for(const n of t)n.managed?await va(n.id):await ja(n.directory,n.targets||[]);ke(),Pe({title:r("skills.toast.bulk_removed",{count:t.length}),timeout:4e3})}))},oe=t=>{!t?.repoOwner||!t?.repoName||G(Xe(t),async()=>{await wa({key:t.key,name:t.name,description:t.description,directory:t.sourceDirectory||t.directory,repoOwner:t.repoOwner,repoName:t.repoName,repoBranch:t.repoBranch,readmeUrl:t.readmeUrl},t.targets&&t.targets.length?t.targets:la),await P(),Pe({title:r("skills.toast.updated",{name:t.name||t.directory}),timeout:4e3})})},we=async()=>{const t=m.trim();if(!(t.length<2)){Se("search"),O("");try{const n=await ir(t);p(n.skills||[])}catch(n){O(n?.message||r("skills.error.generic"))}finally{Se("")}}},Me=async()=>{const t=Ce.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[n,l]=t.split("/");if(!n||!l){O(r("skills.repo.invalid"));return}await G("repo:add",async()=>{await dr({owner:n,name:l,branch:"main",enabled:!0}),he(""),await Ie(),await me()})},Ue=async t=>{await G(`repo:${t.owner}/${t.name}`,async()=>{await lr(t.owner,t.name),await Ie(),await me()})},le=x.targets||[],Ya=le.filter(fa),ve=x.skills||[],Za=i.useMemo(()=>{const t=E==="all"?ve:ve.filter(l=>(l.targets||[]).includes(E)),n=de.trim().toLowerCase();return n?t.filter(l=>(l.name||"").toLowerCase().includes(n)||(l.directory||"").toLowerCase().includes(n)||(l.description||"").toLowerCase().includes(n)):t},[ve,E,de]),et=E!=="all",ee=i.useMemo(()=>T&&ve.find(t=>(t.id||t.directory)===T)||null,[ve,T]),at=i.useCallback(()=>{M("all"),F("")},[]),tt=i.useCallback(t=>{X(n=>{const l=t?.id||t?.directory||null;return n===l?null:l})},[]),rt=i.useCallback(()=>X(null),[]),st=i.useCallback(t=>{const n=aa(t).toLowerCase(),l=Sa(t),f=(x.skills||[]).find(v=>{const j=Ja(v);return j.has(n)||l&&j.has(l)});f&&X(f.id||f.directory)},[x.skills]);i.useEffect(()=>{o!=="my"&&z.size&&I(new Set)},[o,z.size]),i.useEffect(()=>{T&&!ee&&X(null)},[ee,T]);const Fe=i.useMemo(()=>{const t=u===U?k:u===W?fe:c,l=u===U||u===W||u===xe?t:t.filter(j=>`${j.repoOwner}/${j.repoName}`===u),f=L.trim().toLowerCase();return(u===U||!f?l:l.filter(j=>(j.name||"").toLowerCase().includes(f)||(j.directory||"").toLowerCase().includes(f)||(j.description||"").toLowerCase().includes(f))).map(j=>{const ze=aa(j).toLowerCase(),V=Sa(j);return{...j,installed:ce.has(ze)||V&&ce.has(V)}})},[L,c,ce,fe,k,u]),nt=e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(te,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),it=e.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[e.jsx(te,{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")})]}),Qe=(t,n=null)=>e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r(t)}),n]});let Je;if(Te)Je=nt;else if(o==="my")Je=ve.length?e.jsx(Vr,{items:Za,totalCount:ve.length,targets:le,agentOptions:le,agentFilter:E,onAgentFilter:M,anyFilter:et,onClearFilters:at,searchQuery:$,onSearchQuery:F,searchPlaceholder:r("skills.my.placeholder"),selectedId:T,onSelect:tt,onToggleTarget:He,busyKey:q,updates:_e,selectedIds:z,onToggleSelect:ia,onClearSelection:ke,onBulkSync:b,onBulkRemove:Q}):e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-800",children:[le.length>0?e.jsxs("div",{className:"relative h-11 w-80 overflow-hidden","aria-hidden":!0,children:[e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)",WebkitMaskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",style:{filter:"blur(2.5px)"},children:[...le,...le].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(Ne,{provider:t.id,size:30})},`b-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)",WebkitMaskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",children:[...le,...le].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(Ne,{provider:t.id,size:30})},`c-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 w-20 bg-gradient-to-r from-oai-white to-transparent dark:from-oai-gray-900"}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 w-20 bg-gradient-to-l from-oai-white to-transparent dark:from-oai-gray-900"})]}):null,e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.empty.my")}),e.jsx(J,{type:"button",size:"sm",onClick:()=>h("browse"),children:r("skills.empty.my_cta")})]});else{const t=u===U,n=u===W,l=C.length===0&&!t&&!n,f=Ee&&!t&&!n||n&&Ae,v=!t&&!n&&(L.trim()!==""||u!==xe),j=()=>{S(""),w(xe)},ze=!l&&!f&&(Fe.length>0||v)?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:Fe.length})}),v?e.jsxs("button",{type:"button",onClick:j,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(De,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]}):null;let V;l?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")})}):f?V=it:t&&m.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")}):Fe.length?V=e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:Fe.map(Ke=>e.jsx("div",{style:Wr,children:e.jsx(qr,{skill:Ke,installed:!!Ke.installed,installing:q===Xe(Ke),allTargets:Ya,defaultTargets:la,onInstall:ra,onManage:st})},Ke.id||Ke.key))}):v?V=Qe("skills.empty.no_match",e.jsx(J,{type:"button",variant:"secondary",size:"sm",onClick:j,children:r("skills.filter.clear")})):t?V=Qe("skills.empty.search"):n?V=Qe("skills.empty.popular"):V=Qe("skills.empty.browse");const ot=l||pe?e.jsx("div",{className:"mb-5",children:e.jsx(Hr,{repos:C,repoInput:Ce,onRepoInput:he,busyKey:q,onAdd:Me,onRemove:Ue})}):null,lt=!pe&&!t&&!n&&C.length<=1&&Fe.length>0?e.jsx(xr,{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:()=>_(!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;Je=e.jsxs(e.Fragment,{children:[ot,ze,V,lt]})}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(J,{type:"button",variant:"secondary",size:"sm",onClick:be,disabled:Te||Ee||Ae,children:[e.jsx(Pt,{className:ae("mr-1.5 h-3.5 w-3.5",(Te||Ee||Ae)&&"animate-spin"),"aria-hidden":!0}),r("skills.action.refresh")]})]}),e.jsx("div",{className:"mb-5 flex gap-6 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[["my",r("skills.tab.my")],["browse",r("skills.tab.browse")]].map(([t,n])=>e.jsx("button",{type:"button","aria-pressed":o===t,onClick:()=>h(t),className:ae("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",o===t?"border-oai-black text-oai-black dark:border-white dark:text-white":"border-transparent text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:n},t))}),re?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:re}):null,o==="browse"?e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx(Ot,{className:"shrink-0",ariaLabel:r("skills.source.label"),options:[{id:"repo",label:r("skills.mode.repo")},{id:"popular",label:r("skills.mode.popular"),icon:e.jsx(cr,{className:"h-3.5 w-3.5","aria-hidden":!0})},{id:"skillssh",label:r("skills.mode.skillssh")}],value:u===U?"skillssh":u===W?"popular":"repo",onChange:t=>{t==="skillssh"?w(U):t==="popular"?w(W):(u===U||u===W)&&w(xe)}}),u!==U&&u!==W?e.jsxs(La,{value:u,onValueChange:w,children:[e.jsxs(Pa,{"aria-label":r("skills.source.label"),className:"inline-flex h-8 w-44 shrink-0 items-center justify-between gap-2 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs text-oai-black focus:outline-none data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:data-[popup-open]:border-oai-gray-700",children:[e.jsx(Da,{children:t=>t===xe?r("skills.source.all"):t}),e.jsx(Va,{className:"text-oai-gray-400",children:e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Ba,{children:e.jsx(Ta,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ea,{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(Ye,{value:xe,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(Ze,{children:r("skills.source.all")}),e.jsx(ea,{children:e.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),C.map(t=>{const n=`${t.owner}/${t.name}`;return e.jsxs(Ye,{value:n,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(Ze,{children:n}),e.jsx(ea,{children:e.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},n)})]})})})]}):null,e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ma,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(xa,{type:"search",value:m,onChange:t=>S(t.target.value),onKeyDown:t=>{t.key==="Enter"&&u===U&&we()},"aria-label":r("skills.action.search_aria"),placeholder:u===U?r("skills.browse.placeholder_skillssh"):u===W?r("skills.browse.placeholder_popular"):u===xe?r("skills.browse.placeholder_all"):r("skills.browse.placeholder_repo",{repo:u}),className:"h-8 pl-9 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20"})]}),u===U?e.jsxs(J,{type:"button",size:"sm",onClick:we,disabled:m.trim().length<2||q==="search",className:"focus:!ring-oai-gray-400/30",children:[q==="search"?e.jsx(te,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(ma,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.action.search")]}):u===W?null:e.jsxs(J,{type:"button",variant:"secondary",size:"sm",onClick:()=>_(t=>!t),"aria-expanded":pe,className:"!h-8 shrink-0 whitespace-nowrap !border-oai-gray-200 dark:!border-oai-gray-800 hover:!border-oai-gray-300 dark:hover:!border-oai-gray-700 hover:!text-oai-black dark:hover:!text-white focus:!ring-oai-gray-400/30",children:[e.jsx(Oa,{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:C.length})]})]}):null,Je,e.jsx(Pr,{skill:ee,targets:le,busyKey:q,usage:ee&&(K[String(ee.directory||"").toLowerCase()]||K[String(ee.name||"").toLowerCase()])||null,hasUpdate:!!(ee?.id&&_e?.[ee.id]),updating:ee?q===Xe(ee):!1,onUpdate:oe,onClose:rt,onToggleTarget:He,onRemove:sa})]})}),e.jsx(ba,{open:!!N,title:r("skills.confirm.remove_title",{name:N?.name||N?.directory||""}),description:N?N.managed?r("skills.confirm.remove_managed"):r("skills.confirm.remove_local"):"",confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:q===_a(N||{}),onCancel:()=>H(null),onConfirm:na}),e.jsx(ba,{open:!!se,title:r("skills.confirm.bulk_remove_title",{count:se?.length||0}),description:r("skills.confirm.bulk_remove_desc"),confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:q==="batch",onCancel:()=>B(null),onConfirm:ie})]})}export{Ns as SkillsPage,$r as buildLocallyInstalledKeys};