import{n as w,d as v,u as x,j as e,B as u,I as C,k as m,c as S,l as j}from"./index-O0BQoyzo.js";import{r as o}from"./react-Cb2sDjhD.js";import{E as k}from"./empty-state-C-qjOHyu.js";import{D as L,a as D,b as F,c as H,d as R}from"./dialog-bAIDaO-6.js";import{u as E}from"./useQuery-PdiC7-sY.js";import{E as M}from"./external-link-DRVp9-lb.js";import{L as T}from"./loader-circle-9VUMGitw.js";import{R as z}from"./refresh-ccw-D2CWiyU_.js";import{S as I}from"./search-B4fHilZ0.js";import{D as A}from"./download-OhsGtnO-.js";import{C as B}from"./copy-DxSHRdbc.js";import"./x-DG-JKVw_.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const N=w("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const $=w("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]),q={remoteHot:["skills","remote","hot"]};function K(){return E({queryKey:q.remoteHot,queryFn:()=>v.getSkillsRemoteHot(),staleTime:6e4})}function ae(){const{t:s}=x(["skills","common"]),{data:l,isLoading:a,isFetching:r,refetch:i}=K(),n=l?.skills??[],[h,b]=o.useState(""),[p,f]=o.useState(null),g=o.useMemo(()=>{const t=h.trim().toLowerCase();return t?n.filter(d=>d.slug.toLowerCase().includes(t)||(d.name||"").toLowerCase().includes(t)||(d.description||"").toLowerCase().includes(t)||(d.category||"").toLowerCase().includes(t)):n},[n,h]),y=p?n.find(t=>t.slug===p)??null:null;return e.jsxs("div",{className:"mx-auto flex max-w-5xl flex-col gap-4",children:[e.jsxs("header",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("h1",{className:"text-xl font-semibold inline-flex items-center gap-2",children:[e.jsx(N,{className:"h-5 w-5 text-warning"}),s("hot.title")]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx(u,{asChild:!0,variant:"ghost",size:"sm",children:e.jsxs("a",{href:"https://skillhub.cn",target:"_blank",rel:"noopener noreferrer",children:[e.jsx(M,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:s("hot.openHub")})]})}),e.jsxs(u,{variant:"ghost",size:"sm",onClick:()=>i(),disabled:r,"aria-label":s("actions.refresh",{ns:"common"}),children:[r?e.jsx(T,{className:"h-4 w-4 animate-spin"}):e.jsx(z,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:s("actions.refresh",{ns:"common"})})]})]})]}),e.jsx("p",{className:"text-sm text-text-dim",children:s("hot.subtitle")}),l&&e.jsx(O,{cached:!!l.cached,stale:!!l.stale,fetchedAt:l.fetchedAt})]}),n.length>0&&e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[e.jsxs("div",{className:"relative flex-1 min-w-[180px] max-w-md",children:[e.jsx(I,{className:"pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 h-4 w-4 text-text-muted"}),e.jsx(C,{value:h,onChange:t=>b(t.target.value),placeholder:s("actions.search",{ns:"common"}),className:"pl-7"})]}),e.jsxs(m,{variant:"secondary",className:"ml-auto",children:[g.length," / ",n.length]})]}),a?e.jsx("div",{className:"h-48 w-full rounded-md bg-surface-2 animate-pulse"}):n.length===0?e.jsx(k,{icon:e.jsx(N,{}),title:s("hot.empty")}):e.jsx("ul",{className:"flex flex-col gap-2",children:g.map(t=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>f(t.slug),className:S("flex w-full flex-col gap-1 rounded-md border border-border bg-surface px-3 py-2 text-left","transition-colors hover:border-border-strong hover:bg-surface-hover"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium text-text",children:t.name||t.slug}),t.version&&e.jsxs("span",{className:"text-text-muted text-xs font-mono",children:["v",t.version]}),t.category&&e.jsx(m,{variant:"outline",children:t.category}),e.jsxs("div",{className:"ml-auto flex items-center gap-3 text-xs text-text-dim tabular-nums",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx($,{className:"h-3 w-3"}),c(t.stars)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(A,{className:"h-3 w-3"}),c(t.installs)]})]})]}),e.jsx("code",{className:"text-text-muted text-xs font-mono",children:t.slug}),t.description&&e.jsx("p",{className:"line-clamp-2 text-sm text-text-dim",children:t.description})]})},t.slug))}),e.jsx(Q,{skill:y,onOpenChange:t=>{t||f(null)}})]})}function O({cached:s,stale:l,fetchedAt:a}){const{t:r}=x("skills"),i=o.useMemo(()=>{try{const n=new Date(a);return Number.isNaN(n.getTime())?"":n.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return""}},[a]);return e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-text-muted",children:[e.jsx("span",{children:r("hot.updatedAt",{at:i})}),s&&e.jsx(m,{variant:"outline",children:r("hot.cached")}),l&&e.jsx(m,{variant:"warning",children:r("hot.stale")})]})}function Q({skill:s,onOpenChange:l}){const{t:a}=x("skills"),r=o.useMemo(()=>s?[{key:"cliInstall",cmd:`skillhub install ${s.slug}`},{key:"cliSearch",cmd:`skillhub search ${s.slug}`},{key:"imAsk",cmd:`请用 skillhub 安装 ${s.slug} 技能`}]:[],[s]);return e.jsx(L,{open:s!=null,onOpenChange:l,children:e.jsxs(D,{className:"sm:max-w-2xl",children:[e.jsxs(F,{children:[e.jsx(H,{children:s?.name||s?.slug||""}),s?.description&&e.jsx(R,{children:s.description})]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-xs",children:[e.jsx("dt",{className:"text-text-dim",children:"slug"}),e.jsx("dd",{className:"font-mono",children:s.slug}),s.version&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-dim",children:a("hot.detail.version")}),e.jsxs("dd",{className:"font-mono",children:["v",s.version]})]}),s.category&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-dim",children:a("hot.detail.category")}),e.jsx("dd",{children:s.category})]}),e.jsx("dt",{className:"text-text-dim",children:a("hot.detail.stars")}),e.jsx("dd",{className:"tabular-nums",children:c(s.stars)}),e.jsx("dt",{className:"text-text-dim",children:a("hot.detail.installs")}),e.jsx("dd",{className:"tabular-nums",children:c(s.installs)}),s.downloads!=null&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-dim",children:a("hot.detail.downloads")}),e.jsx("dd",{className:"tabular-nums",children:c(s.downloads)})]})]}),e.jsxs("div",{className:"mt-4 border-t border-border pt-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("hot.detail.howInstall")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-2",children:r.map(i=>e.jsxs("li",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2",children:[e.jsx("span",{className:"text-xs text-text-dim sm:w-40 sm:shrink-0",children:a(`hot.detail.label.${i.key}`)}),e.jsx("code",{className:"flex-1 rounded bg-surface-2 px-2 py-1 font-mono text-xs break-all",children:i.cmd}),e.jsx(_,{text:i.cmd})]},i.key))}),e.jsx("p",{className:"mt-3 text-[11px] text-text-muted",children:a("hot.detail.hint")})]})]})]})})}function _({text:s}){const{t:l}=x("skills"),[a,r]=o.useState(!1);async function i(){try{await navigator.clipboard.writeText(s),r(!0),j.success(l("hot.detail.copied")),setTimeout(()=>r(!1),1500)}catch(n){j.error(String(n?.message??n))}}return e.jsxs(u,{type:"button",variant:"secondary",size:"sm",onClick:()=>void i(),className:"shrink-0",children:[e.jsx(B,{className:"h-3 w-3"}),l(a?"hot.detail.copied":"hot.detail.copy")]})}function c(s){return s==null||!Number.isFinite(s)?"—":s.toLocaleString()}export{ae as default};
//# sourceMappingURL=hot-BITDoax1.js.map
