@juejin-opensource/jusage 0.1.1 → 0.1.2

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.
@@ -1 +1 @@
1
- import{r as i,j as e,k as m,B as L,b6 as Q}from"./index-DKJwDJt7.js";import{P as f,C as H,a as k}from"./ChevronDown-CBnDSnT1.js";const X=n=>i.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},n),i.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12 2.5H8A1.5 1.5 0 0 0 6.5 4v1H8a3 3 0 0 1 3 3v1.5h1A1.5 1.5 0 0 0 13.5 8V4A1.5 1.5 0 0 0 12 2.5M11 11h1a3 3 0 0 0 3-3V4a3 3 0 0 0-3-3H8a3 3 0 0 0-3 3v1H4a3 3 0 0 0-3 3v4a3 3 0 0 0 3 3h4a3 3 0 0 0 3-3zM4 6.5h4A1.5 1.5 0 0 1 9.5 8v4A1.5 1.5 0 0 1 8 13.5H4A1.5 1.5 0 0 1 2.5 12V8A1.5 1.5 0 0 1 4 6.5",clipRule:"evenodd"})),ee=n=>i.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},n),i.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M10.418 2.489c.9-1.196 2.382-1.724 3.154-1.391.852.367 1.539 2.08 1.054 3.702a4 4 0 0 1-2.616 5.559c.309.471.49 1.035.49 1.641v2.25a.75.75 0 0 1-1.5 0V12a1.5 1.5 0 0 0-3 0v2.25a.75.75 0 0 1-1.5 0v-.75h-.876a2.626 2.626 0 0 1-2.625-2.625c0-.621-.504-1.125-1.125-1.125h-.125a.75.75 0 0 1 0-1.5h.125a2.625 2.625 0 0 1 2.625 2.625c0 .621.504 1.125 1.125 1.125H6.5c0-.606.18-1.17.488-1.641A4 4 0 0 1 4.373 4.8c-.484-1.623.202-3.335 1.054-3.702.772-.333 2.254.195 3.155 1.39zm2.549.02a1.4 1.4 0 0 0-.35.098 2.5 2.5 0 0 0-1 .784l-.451.598H7.834l-.45-.598a2.5 2.5 0 0 0-1.001-.784 1.4 1.4 0 0 0-.352-.099c-.063.088-.14.231-.204.429a2.5 2.5 0 0 0-.016 1.434l.163.546-.242.517c-.13.279-.21.586-.228.913l-.004.142a2.5 2.5 0 0 0 2.5 2.5h3a2.5 2.5 0 0 0 2.267-3.555l-.242-.517.163-.547a2.5 2.5 0 0 0-.016-1.433 1.6 1.6 0 0 0-.205-.429",clipRule:"evenodd"})),B="https://gitee.com/juejin-cn/juejin-usage",ne=`${B}/releases`,te="https://gitee.com/api/v5/repos/juejin-cn/juejin-usage/releases?per_page=8",U="https://github.com/juejin-cn/juejin-usage",se=`${U}/releases`,ae="https://api.github.com/repos/juejin-cn/juejin-usage/releases?per_page=8",re=8e3,v=[{id:"macos-arm",os:"macos",label:"下载 macOS",menuLabel:"macOS(Apple Silicon)",badgePlatform:"macOS",requirement:"macOS 14+"},{id:"macos-intel",os:"macos",label:"下载 macOS(Intel)",menuLabel:"macOS(Intel)",badgePlatform:"macOS",requirement:"macOS 14+"},{id:"windows",os:"windows",label:"下载 Windows",menuLabel:"Windows",badgePlatform:"Windows",requirement:"Windows 10+"}],oe=new Map(v.map(n=>[n.id,n]));function ie(n){return oe.get(n)??v[0]}function M(n,t="",a=""){const o=`${a} ${t} ${n}`.toLowerCase();return/\bwin(?:dows|32|64|ce)?\b/.test(o)||o.includes("windows")?"windows":o.includes("mac")||o.includes("darwin")||o.includes("iphone")||o.includes("ipad")||o.includes("ipod")?"macos":"other"}function P(n,t=""){const a=t.toLowerCase();return a.includes("arm")?"arm":a.includes("x86")||a.includes("x64")||a.includes("amd64")||/\bintel\b/i.test(n)?"x64":"unknown"}function $(n,t="unknown"){return n==="windows"?"windows":n==="macos"&&t==="x64"?"macos-intel":"macos-arm"}function le(n){return n.find(t=>!t.draft)??null}function W(n){return!/\.(blockmap|yml|yaml|zip|tar\.gz)$/i.test(n)}function C(n){return n.some(t=>W(t.name)&&/\.(dmg|exe)$/i.test(t.name))}function ce(n,t){var o,u,p,h;const a=n.filter(l=>W(l.name));if(t==="windows"){const l=a.find(d=>/\.exe$/i.test(d.name)&&/setup/i.test(d.name)&&!/portable/i.test(d.name));return l?l.browser_download_url:((o=a.find(d=>/\.exe$/i.test(d.name)&&!/portable/i.test(d.name)))==null?void 0:o.browser_download_url)??null}return t==="macos-arm"?((u=a.find(l=>/arm64\.dmg$/i.test(l.name)))==null?void 0:u.browser_download_url)??null:((p=a.find(l=>/x64\.dmg$/i.test(l.name)))==null?void 0:p.browser_download_url)??((h=a.find(l=>/\.dmg$/i.test(l.name)&&!/arm64/i.test(l.name)))==null?void 0:h.browser_download_url)??null}function de(n){return n==="github"?se:ne}function ue(n,t){return{source:n,tagName:t.tag_name,assets:t.assets??[]}}function fe(n,t){if(n&&C(n.assets))return n;if(t&&C(t.assets))return t;throw new Error("No published desktop release")}async function V(n,t){const a=new AbortController,o=setTimeout(()=>a.abort(),re);try{const u=await fetch(n,{headers:{Accept:t==="github"?"application/vnd.github+json":"application/json"},signal:a.signal});if(!u.ok)throw new Error(`${t} releases ${u.status}`);const p=await u.json(),h=le(p);if(!h)throw new Error(`No published ${t} release`);return ue(t,h)}finally{clearTimeout(o)}}async function me(){let n=null;try{n=await V(te,"gitee")}catch{n=null}if(n&&C(n.assets))return n;const t=await V(ae,"github");return fe(n,t)}const he={new_user:{badge:"Juejin Usage",headline:["Cursor、Claude、Codex","多工具 Token 与费用","本地面板一张表看完。"],description:"汇总你实际在用的 AI 编码工具用量与趋势,安装后即可查看。"},uninstalled:{badge:"客户端暂未连接",headline:["客户端暂未连接","启动后继续","同步本机用量。"],description:"下载并打开 Juejin Usage,即可把本机 AI 用量同步回这块面板。"}},xe="/e1.png",E=[{id:"install-start",label:"npm",command:"npm i -g @juejin-opensource/jusage && jusage service start"},{id:"npx",label:"npx",command:"npx @juejin-opensource/jusage start"}],q="tud.downloadTarget";function D(){try{const n=sessionStorage.getItem(q);if(n&&v.some(t=>t.id===n))return n}catch{}return null}function pe(n){try{sessionStorage.setItem(q,n)}catch{}}function ge({reason:n}){const t=he[n],[a,o]=i.useState(()=>{const s=D();return s||(typeof navigator>"u"?"macos-arm":$(M(navigator.userAgent,navigator.platform),P(navigator.userAgent)))}),[u,p]=i.useState({}),[h,l]=i.useState(),[d,R]=i.useState(!1),[_,I]=i.useState(!1),[T,Z]=i.useState("npx"),[g,N]=i.useState(!1),O=i.useRef(D()!==null),b=ie(a),F=de(h),y=E.find(s=>s.id===T)??E[0];i.useEffect(()=>{var x,w;let s=!1;const r=navigator,c=(j,K)=>{var z;s||O.current||o($(M(r.userAgent,r.platform,K??((z=r.userAgentData)==null?void 0:z.platform)??""),P(r.userAgent,j)))};return c(),(w=(x=r.userAgentData)==null?void 0:x.getHighEntropyValues)==null||w.call(x,["architecture","platform"]).then(j=>{c(j.architecture,j.platform)}).catch(()=>{}),()=>{s=!0}},[]),i.useEffect(()=>{let s=!1;return me().then(r=>{if(s)return;const c={};for(const x of v){const w=ce(r.assets,x.id);w&&(c[x.id]=w)}p(c),l(r.source)}).catch(()=>{}),()=>{s=!0}},[]),i.useEffect(()=>{if(!g)return;const s=window.setTimeout(()=>N(!1),1600);return()=>window.clearTimeout(s)},[g]);const J=s=>{const r=u[s]??F,c=document.createElement("a");c.href=r,c.rel="noopener noreferrer",c.target="_blank",u[s]&&(c.download=""),document.body.append(c),c.click(),c.remove()},Y=async()=>{try{await navigator.clipboard.writeText(y.command),N(!0)}catch{N(!1)}};return e.jsx("section",{className:"flex min-h-[calc(100svh-9rem)] items-start pt-4 pb-10 sm:pt-6 sm:pb-14 lg:pt-8",children:e.jsxs("div",{className:"grid w-full items-start gap-10 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.15fr)] lg:gap-16 xl:gap-20",children:[e.jsxs("div",{className:"max-w-2xl motion-safe:animate-[fade-up_420ms_ease-out] lg:max-w-none",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-base text-muted",children:[e.jsx("span",{children:t.badge}),e.jsx("span",{"aria-hidden":"true",className:"text-foreground/25",children:"·"}),b.os==="windows"?e.jsx(S,{className:"size-4 text-foreground/70"}):e.jsx(A,{className:"size-4 text-foreground/70"}),e.jsxs("span",{children:["适用于 ",b.badgePlatform]})]}),e.jsxs("h1",{className:"mt-6 text-[2.15rem] leading-[1.15] font-semibold tracking-tight text-foreground sm:text-5xl sm:leading-[1.12] lg:text-[3.15rem] lg:leading-[1.1]",children:[t.headline[0],e.jsx("br",{}),t.headline[1],e.jsx("br",{}),t.headline[2]]}),e.jsx("p",{className:"mt-5 max-w-xl text-lg leading-8 text-muted",children:t.description}),e.jsxs("div",{className:"mt-9 flex flex-col gap-4",children:[e.jsxs("div",{"aria-label":"下载客户端",className:"inline-flex max-w-full shrink-0 overflow-hidden rounded-full shadow-[0_1px_2px_rgb(0_0_0/0.06)]",role:"group",children:[e.jsxs("button",{className:m(G,"rounded-l-full ps-6 pe-5"),type:"button",onClick:()=>J(a),children:[b.os==="windows"?e.jsx(S,{className:"size-4.5"}):e.jsx(A,{className:"size-4.5"}),b.label]}),e.jsxs(f,{isOpen:d,onOpenChange:R,children:[e.jsx(L,{"aria-expanded":d,"aria-haspopup":"menu","aria-label":"选择其它系统",className:m(G,"h-14! min-h-14! min-w-14 rounded-l-none rounded-r-full border-0 p-0 shadow-none","bg-[#1e80ff]! text-white! hover:bg-[#1171ee]!","relative before:absolute before:inset-y-2.5 before:left-0 before:w-px before:bg-white/30","dark:bg-[#4b9cff]! dark:hover:bg-[#3a8ff0]!"),isIconOnly:!0,variant:"primary",children:e.jsx(H,{"aria-hidden":"true",className:m("size-4.5 transition-transform duration-200 motion-reduce:transition-none",d&&"rotate-180")})}),e.jsx(f.Content,{className:"min-w-56 overflow-hidden rounded-[10px] border-0 bg-overlay p-0 text-overlay-foreground shadow-surface",placement:"bottom start",children:e.jsxs(f.Dialog,{className:"p-0 outline-none",children:[e.jsx(f.Heading,{className:"sr-only",children:"选择下载平台"}),e.jsx("div",{className:"flex flex-col py-1",role:"menu",children:v.map(s=>{const r=s.id===a;return e.jsxs("button",{"aria-current":r?"true":void 0,className:m("flex min-h-11 w-full cursor-pointer items-center gap-2 px-3 text-left text-sm","transition-colors duration-150","hover:bg-surface-secondary","focus-visible:bg-surface-secondary focus-visible:outline-none",r?"text-foreground":"text-foreground/80"),role:"menuitem",type:"button",onClick:()=>{O.current=!0,pe(s.id),o(s.id),R(!1)},children:[s.os==="windows"?e.jsx(S,{className:"size-4 text-foreground/70"}):e.jsx(A,{className:"size-4 text-foreground/70"}),e.jsx("span",{className:"min-w-0 flex-1",children:s.menuLabel}),r?e.jsx(k,{"aria-hidden":"true",className:"size-4 text-[#1e80ff] dark:text-[#4b9cff]"}):null]},s.id)})})]})})]})]}),e.jsxs("div",{className:"flex min-h-14 min-w-0 max-w-2xl items-center gap-2 rounded-2xl border border-border bg-surface-secondary/80 p-2 ps-3 dark:bg-overlay/60",children:[e.jsxs(f,{isOpen:_,onOpenChange:I,children:[e.jsxs(L,{"aria-expanded":_,"aria-haspopup":"menu","aria-label":"选择 CLI 启动方式",className:"h-10 min-h-10 shrink-0 gap-1 rounded-full bg-background/80 px-3 text-xs font-medium text-foreground shadow-none hover:bg-background dark:bg-black/10 dark:hover:bg-black/20",variant:"secondary",children:[e.jsx("span",{children:y.label}),e.jsx(H,{"aria-hidden":"true",className:m("size-3.5 transition-transform duration-200 motion-reduce:transition-none",_&&"rotate-180")})]}),e.jsx(f.Content,{className:"min-w-60 overflow-hidden rounded-[10px] border-0 bg-overlay p-0 text-overlay-foreground shadow-surface",placement:"bottom start",children:e.jsxs(f.Dialog,{className:"p-0 outline-none",children:[e.jsx(f.Heading,{className:"sr-only",children:"选择 CLI 启动方式"}),e.jsx("div",{className:"flex flex-col py-1",role:"menu",children:E.map(s=>{const r=s.id===T;return e.jsxs("button",{"aria-current":r?"true":void 0,className:m("flex min-h-11 w-full cursor-pointer items-center gap-2 px-3 text-left text-sm","transition-colors duration-150 hover:bg-surface-secondary","focus-visible:bg-surface-secondary focus-visible:outline-none",r?"text-foreground":"text-foreground/80"),role:"menuitem",type:"button",onClick:()=>{Z(s.id),I(!1)},children:[e.jsx("span",{className:"min-w-0 flex-1",children:s.label}),r?e.jsx(k,{"aria-hidden":"true",className:"size-4 text-[#1e80ff] dark:text-[#4b9cff]"}):null]},s.id)})})]})})]}),e.jsx("div",{className:"min-w-0 flex-1 overflow-hidden rounded-xl bg-background/75 px-3 py-2 dark:bg-black/10",children:e.jsxs("code",{className:"block overflow-x-auto whitespace-nowrap font-mono text-sm text-foreground/85 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:["$ ",y.command]})}),e.jsx("button",{"aria-label":g?"安装命令已复制":"复制 CLI 安装命令",className:m("inline-flex size-11 shrink-0 items-center justify-center rounded-full","text-muted transition-colors duration-150","hover:bg-background hover:text-foreground","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent","touch-manipulation"),type:"button",onClick:()=>{Y()},children:g?e.jsx(k,{"aria-hidden":"true",className:"size-4 text-[#1e80ff] dark:text-[#4b9cff]"}):e.jsx(X,{"aria-hidden":"true",className:"size-4"})})]})]}),e.jsx("p",{"aria-live":"polite",className:"sr-only",children:g?"安装命令已复制":""}),e.jsxs("p",{className:"mt-5 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted",children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx("a",{"aria-label":"前往 Gitee 仓库",className:"inline-flex size-8 items-center justify-center rounded-full text-foreground/70 transition-colors hover:bg-surface-secondary hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent",href:B,rel:"noopener noreferrer",target:"_blank",children:e.jsx(be,{className:"size-4.5"})}),e.jsx("a",{"aria-label":"前往 GitHub 仓库",className:"inline-flex size-8 items-center justify-center rounded-full text-foreground/70 transition-colors hover:bg-surface-secondary hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent",href:U,rel:"noopener noreferrer",target:"_blank",children:e.jsx(ee,{"aria-hidden":"true",className:"size-4.5"})})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:b.requirement}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:"CLI 需 Node.js 20+"})]})]}),e.jsx("div",{className:"min-w-0 motion-safe:animate-[fade-up_520ms_ease-out]",children:e.jsx("figure",{className:"overflow-hidden rounded-2xl border border-border/80 bg-surface shadow-[0_24px_48px_-28px_rgb(15_23_42/0.45)] dark:shadow-[0_24px_48px_-24px_rgb(0_0_0/0.65)]",children:e.jsx("img",{alt:"Juejin Usage 用量看板界面预览:费用、Token、热力图与趋势图",className:"h-auto w-full",decoding:"async",fetchPriority:"high",height:1560,src:xe,width:2102})})})]})})}const G=m("inline-flex h-14 min-h-14 cursor-pointer items-center justify-center gap-2.5","bg-[#1e80ff] text-base font-medium whitespace-nowrap text-white","transition-colors duration-200 motion-reduce:transition-none","hover:bg-[#1171ee] active:brightness-[0.96]","focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#1e80ff]","dark:bg-[#4b9cff] dark:hover:bg-[#3a8ff0] dark:focus-visible:outline-[#4b9cff]","touch-manipulation");function A({className:n}){return e.jsx("svg",{"aria-hidden":"true",className:n,fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})})}function be({className:n}){return e.jsx("svg",{"aria-hidden":"true",className:n,fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.016 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.592.592 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296z"})})}function S({className:n}){return e.jsx("svg",{"aria-hidden":"true",className:n,fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M3 5.2 11.2 4v7.4H3V5.2Zm8.9-1.4L21 2.6v8.8h-9.1V3.8ZM3 13.4h8.2V21L3 19.7v-6.3Zm8.9 0H21V21.4l-9.1-1.3v-6.7Z"})})}function je(){const n=Q(),t=(n==null?void 0:n.reason)==="uninstalled"?"uninstalled":"new_user";return e.jsx(ge,{reason:t})}export{je as component};
1
+ import{r as i,j as e,k as m,B as L,bb as Q}from"./index-CWecC3aA.js";import{P as f,C as H,a as k}from"./ChevronDown-BMySI3-K.js";const X=n=>i.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},n),i.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12 2.5H8A1.5 1.5 0 0 0 6.5 4v1H8a3 3 0 0 1 3 3v1.5h1A1.5 1.5 0 0 0 13.5 8V4A1.5 1.5 0 0 0 12 2.5M11 11h1a3 3 0 0 0 3-3V4a3 3 0 0 0-3-3H8a3 3 0 0 0-3 3v1H4a3 3 0 0 0-3 3v4a3 3 0 0 0 3 3h4a3 3 0 0 0 3-3zM4 6.5h4A1.5 1.5 0 0 1 9.5 8v4A1.5 1.5 0 0 1 8 13.5H4A1.5 1.5 0 0 1 2.5 12V8A1.5 1.5 0 0 1 4 6.5",clipRule:"evenodd"})),ee=n=>i.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},n),i.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M10.418 2.489c.9-1.196 2.382-1.724 3.154-1.391.852.367 1.539 2.08 1.054 3.702a4 4 0 0 1-2.616 5.559c.309.471.49 1.035.49 1.641v2.25a.75.75 0 0 1-1.5 0V12a1.5 1.5 0 0 0-3 0v2.25a.75.75 0 0 1-1.5 0v-.75h-.876a2.626 2.626 0 0 1-2.625-2.625c0-.621-.504-1.125-1.125-1.125h-.125a.75.75 0 0 1 0-1.5h.125a2.625 2.625 0 0 1 2.625 2.625c0 .621.504 1.125 1.125 1.125H6.5c0-.606.18-1.17.488-1.641A4 4 0 0 1 4.373 4.8c-.484-1.623.202-3.335 1.054-3.702.772-.333 2.254.195 3.155 1.39zm2.549.02a1.4 1.4 0 0 0-.35.098 2.5 2.5 0 0 0-1 .784l-.451.598H7.834l-.45-.598a2.5 2.5 0 0 0-1.001-.784 1.4 1.4 0 0 0-.352-.099c-.063.088-.14.231-.204.429a2.5 2.5 0 0 0-.016 1.434l.163.546-.242.517c-.13.279-.21.586-.228.913l-.004.142a2.5 2.5 0 0 0 2.5 2.5h3a2.5 2.5 0 0 0 2.267-3.555l-.242-.517.163-.547a2.5 2.5 0 0 0-.016-1.433 1.6 1.6 0 0 0-.205-.429",clipRule:"evenodd"})),B="https://gitee.com/juejin-cn/juejin-usage",ne=`${B}/releases`,te="https://gitee.com/api/v5/repos/juejin-cn/juejin-usage/releases?per_page=8",U="https://github.com/juejin-cn/juejin-usage",se=`${U}/releases`,ae="https://api.github.com/repos/juejin-cn/juejin-usage/releases?per_page=8",re=8e3,v=[{id:"macos-arm",os:"macos",label:"下载 macOS",menuLabel:"macOS(Apple Silicon)",badgePlatform:"macOS",requirement:"macOS 14+"},{id:"macos-intel",os:"macos",label:"下载 macOS(Intel)",menuLabel:"macOS(Intel)",badgePlatform:"macOS",requirement:"macOS 14+"},{id:"windows",os:"windows",label:"下载 Windows",menuLabel:"Windows",badgePlatform:"Windows",requirement:"Windows 10+"}],oe=new Map(v.map(n=>[n.id,n]));function ie(n){return oe.get(n)??v[0]}function M(n,t="",a=""){const o=`${a} ${t} ${n}`.toLowerCase();return/\bwin(?:dows|32|64|ce)?\b/.test(o)||o.includes("windows")?"windows":o.includes("mac")||o.includes("darwin")||o.includes("iphone")||o.includes("ipad")||o.includes("ipod")?"macos":"other"}function P(n,t=""){const a=t.toLowerCase();return a.includes("arm")?"arm":a.includes("x86")||a.includes("x64")||a.includes("amd64")||/\bintel\b/i.test(n)?"x64":"unknown"}function $(n,t="unknown"){return n==="windows"?"windows":n==="macos"&&t==="x64"?"macos-intel":"macos-arm"}function le(n){return n.find(t=>!t.draft)??null}function W(n){return!/\.(blockmap|yml|yaml|zip|tar\.gz)$/i.test(n)}function C(n){return n.some(t=>W(t.name)&&/\.(dmg|exe)$/i.test(t.name))}function ce(n,t){var o,u,p,h;const a=n.filter(l=>W(l.name));if(t==="windows"){const l=a.find(d=>/\.exe$/i.test(d.name)&&/setup/i.test(d.name)&&!/portable/i.test(d.name));return l?l.browser_download_url:((o=a.find(d=>/\.exe$/i.test(d.name)&&!/portable/i.test(d.name)))==null?void 0:o.browser_download_url)??null}return t==="macos-arm"?((u=a.find(l=>/arm64\.dmg$/i.test(l.name)))==null?void 0:u.browser_download_url)??null:((p=a.find(l=>/x64\.dmg$/i.test(l.name)))==null?void 0:p.browser_download_url)??((h=a.find(l=>/\.dmg$/i.test(l.name)&&!/arm64/i.test(l.name)))==null?void 0:h.browser_download_url)??null}function de(n){return n==="github"?se:ne}function ue(n,t){return{source:n,tagName:t.tag_name,assets:t.assets??[]}}function fe(n,t){if(n&&C(n.assets))return n;if(t&&C(t.assets))return t;throw new Error("No published desktop release")}async function V(n,t){const a=new AbortController,o=setTimeout(()=>a.abort(),re);try{const u=await fetch(n,{headers:{Accept:t==="github"?"application/vnd.github+json":"application/json"},signal:a.signal});if(!u.ok)throw new Error(`${t} releases ${u.status}`);const p=await u.json(),h=le(p);if(!h)throw new Error(`No published ${t} release`);return ue(t,h)}finally{clearTimeout(o)}}async function me(){let n=null;try{n=await V(te,"gitee")}catch{n=null}if(n&&C(n.assets))return n;const t=await V(ae,"github");return fe(n,t)}const he={new_user:{badge:"Juejin Usage",headline:["Cursor、Claude、Codex","多工具 Token 与费用","本地面板一张表看完。"],description:"汇总你实际在用的 AI 编码工具用量与趋势,安装后即可查看。"},uninstalled:{badge:"客户端暂未连接",headline:["客户端暂未连接","启动后继续","同步本机用量。"],description:"下载并打开 Juejin Usage,即可把本机 AI 用量同步回这块面板。"}},xe="/e1.png",E=[{id:"install-start",label:"npm",command:"npm i -g @juejin-opensource/jusage && jusage service start"},{id:"npx",label:"npx",command:"npx @juejin-opensource/jusage start"}],q="tud.downloadTarget";function D(){try{const n=sessionStorage.getItem(q);if(n&&v.some(t=>t.id===n))return n}catch{}return null}function pe(n){try{sessionStorage.setItem(q,n)}catch{}}function ge({reason:n}){const t=he[n],[a,o]=i.useState(()=>{const s=D();return s||(typeof navigator>"u"?"macos-arm":$(M(navigator.userAgent,navigator.platform),P(navigator.userAgent)))}),[u,p]=i.useState({}),[h,l]=i.useState(),[d,R]=i.useState(!1),[_,I]=i.useState(!1),[T,Z]=i.useState("npx"),[g,N]=i.useState(!1),O=i.useRef(D()!==null),b=ie(a),F=de(h),y=E.find(s=>s.id===T)??E[0];i.useEffect(()=>{var x,w;let s=!1;const r=navigator,c=(j,K)=>{var z;s||O.current||o($(M(r.userAgent,r.platform,K??((z=r.userAgentData)==null?void 0:z.platform)??""),P(r.userAgent,j)))};return c(),(w=(x=r.userAgentData)==null?void 0:x.getHighEntropyValues)==null||w.call(x,["architecture","platform"]).then(j=>{c(j.architecture,j.platform)}).catch(()=>{}),()=>{s=!0}},[]),i.useEffect(()=>{let s=!1;return me().then(r=>{if(s)return;const c={};for(const x of v){const w=ce(r.assets,x.id);w&&(c[x.id]=w)}p(c),l(r.source)}).catch(()=>{}),()=>{s=!0}},[]),i.useEffect(()=>{if(!g)return;const s=window.setTimeout(()=>N(!1),1600);return()=>window.clearTimeout(s)},[g]);const J=s=>{const r=u[s]??F,c=document.createElement("a");c.href=r,c.rel="noopener noreferrer",c.target="_blank",u[s]&&(c.download=""),document.body.append(c),c.click(),c.remove()},Y=async()=>{try{await navigator.clipboard.writeText(y.command),N(!0)}catch{N(!1)}};return e.jsx("section",{className:"flex min-h-[calc(100svh-9rem)] items-start pt-4 pb-10 sm:pt-6 sm:pb-14 lg:pt-8",children:e.jsxs("div",{className:"grid w-full items-start gap-10 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.15fr)] lg:gap-16 xl:gap-20",children:[e.jsxs("div",{className:"max-w-2xl motion-safe:animate-[fade-up_420ms_ease-out] lg:max-w-none",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-base text-muted",children:[e.jsx("span",{children:t.badge}),e.jsx("span",{"aria-hidden":"true",className:"text-foreground/25",children:"·"}),b.os==="windows"?e.jsx(S,{className:"size-4 text-foreground/70"}):e.jsx(A,{className:"size-4 text-foreground/70"}),e.jsxs("span",{children:["适用于 ",b.badgePlatform]})]}),e.jsxs("h1",{className:"mt-6 text-[2.15rem] leading-[1.15] font-semibold tracking-tight text-foreground sm:text-5xl sm:leading-[1.12] lg:text-[3.15rem] lg:leading-[1.1]",children:[t.headline[0],e.jsx("br",{}),t.headline[1],e.jsx("br",{}),t.headline[2]]}),e.jsx("p",{className:"mt-5 max-w-xl text-lg leading-8 text-muted",children:t.description}),e.jsxs("div",{className:"mt-9 flex flex-col gap-4",children:[e.jsxs("div",{"aria-label":"下载客户端",className:"inline-flex max-w-full shrink-0 overflow-hidden rounded-full shadow-[0_1px_2px_rgb(0_0_0/0.06)]",role:"group",children:[e.jsxs("button",{className:m(G,"rounded-l-full ps-6 pe-5"),type:"button",onClick:()=>J(a),children:[b.os==="windows"?e.jsx(S,{className:"size-4.5"}):e.jsx(A,{className:"size-4.5"}),b.label]}),e.jsxs(f,{isOpen:d,onOpenChange:R,children:[e.jsx(L,{"aria-expanded":d,"aria-haspopup":"menu","aria-label":"选择其它系统",className:m(G,"h-14! min-h-14! min-w-14 rounded-l-none rounded-r-full border-0 p-0 shadow-none","bg-[#1e80ff]! text-white! hover:bg-[#1171ee]!","relative before:absolute before:inset-y-2.5 before:left-0 before:w-px before:bg-white/30","dark:bg-[#4b9cff]! dark:hover:bg-[#3a8ff0]!"),isIconOnly:!0,variant:"primary",children:e.jsx(H,{"aria-hidden":"true",className:m("size-4.5 transition-transform duration-200 motion-reduce:transition-none",d&&"rotate-180")})}),e.jsx(f.Content,{className:"min-w-56 overflow-hidden rounded-[10px] border-0 bg-overlay p-0 text-overlay-foreground shadow-surface",placement:"bottom start",children:e.jsxs(f.Dialog,{className:"p-0 outline-none",children:[e.jsx(f.Heading,{className:"sr-only",children:"选择下载平台"}),e.jsx("div",{className:"flex flex-col py-1",role:"menu",children:v.map(s=>{const r=s.id===a;return e.jsxs("button",{"aria-current":r?"true":void 0,className:m("flex min-h-11 w-full cursor-pointer items-center gap-2 px-3 text-left text-sm","transition-colors duration-150","hover:bg-surface-secondary","focus-visible:bg-surface-secondary focus-visible:outline-none",r?"text-foreground":"text-foreground/80"),role:"menuitem",type:"button",onClick:()=>{O.current=!0,pe(s.id),o(s.id),R(!1)},children:[s.os==="windows"?e.jsx(S,{className:"size-4 text-foreground/70"}):e.jsx(A,{className:"size-4 text-foreground/70"}),e.jsx("span",{className:"min-w-0 flex-1",children:s.menuLabel}),r?e.jsx(k,{"aria-hidden":"true",className:"size-4 text-[#1e80ff] dark:text-[#4b9cff]"}):null]},s.id)})})]})})]})]}),e.jsxs("div",{className:"flex min-h-14 min-w-0 max-w-2xl items-center gap-2 rounded-2xl border border-border bg-surface-secondary/80 p-2 ps-3 dark:bg-overlay/60",children:[e.jsxs(f,{isOpen:_,onOpenChange:I,children:[e.jsxs(L,{"aria-expanded":_,"aria-haspopup":"menu","aria-label":"选择 CLI 启动方式",className:"h-10 min-h-10 shrink-0 gap-1 rounded-full bg-background/80 px-3 text-xs font-medium text-foreground shadow-none hover:bg-background dark:bg-black/10 dark:hover:bg-black/20",variant:"secondary",children:[e.jsx("span",{children:y.label}),e.jsx(H,{"aria-hidden":"true",className:m("size-3.5 transition-transform duration-200 motion-reduce:transition-none",_&&"rotate-180")})]}),e.jsx(f.Content,{className:"min-w-60 overflow-hidden rounded-[10px] border-0 bg-overlay p-0 text-overlay-foreground shadow-surface",placement:"bottom start",children:e.jsxs(f.Dialog,{className:"p-0 outline-none",children:[e.jsx(f.Heading,{className:"sr-only",children:"选择 CLI 启动方式"}),e.jsx("div",{className:"flex flex-col py-1",role:"menu",children:E.map(s=>{const r=s.id===T;return e.jsxs("button",{"aria-current":r?"true":void 0,className:m("flex min-h-11 w-full cursor-pointer items-center gap-2 px-3 text-left text-sm","transition-colors duration-150 hover:bg-surface-secondary","focus-visible:bg-surface-secondary focus-visible:outline-none",r?"text-foreground":"text-foreground/80"),role:"menuitem",type:"button",onClick:()=>{Z(s.id),I(!1)},children:[e.jsx("span",{className:"min-w-0 flex-1",children:s.label}),r?e.jsx(k,{"aria-hidden":"true",className:"size-4 text-[#1e80ff] dark:text-[#4b9cff]"}):null]},s.id)})})]})})]}),e.jsx("div",{className:"min-w-0 flex-1 overflow-hidden rounded-xl bg-background/75 px-3 py-2 dark:bg-black/10",children:e.jsxs("code",{className:"block overflow-x-auto whitespace-nowrap font-mono text-sm text-foreground/85 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:["$ ",y.command]})}),e.jsx("button",{"aria-label":g?"安装命令已复制":"复制 CLI 安装命令",className:m("inline-flex size-11 shrink-0 items-center justify-center rounded-full","text-muted transition-colors duration-150","hover:bg-background hover:text-foreground","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent","touch-manipulation"),type:"button",onClick:()=>{Y()},children:g?e.jsx(k,{"aria-hidden":"true",className:"size-4 text-[#1e80ff] dark:text-[#4b9cff]"}):e.jsx(X,{"aria-hidden":"true",className:"size-4"})})]})]}),e.jsx("p",{"aria-live":"polite",className:"sr-only",children:g?"安装命令已复制":""}),e.jsxs("p",{className:"mt-5 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted",children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx("a",{"aria-label":"前往 Gitee 仓库",className:"inline-flex size-8 items-center justify-center rounded-full text-foreground/70 transition-colors hover:bg-surface-secondary hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent",href:B,rel:"noopener noreferrer",target:"_blank",children:e.jsx(be,{className:"size-4.5"})}),e.jsx("a",{"aria-label":"前往 GitHub 仓库",className:"inline-flex size-8 items-center justify-center rounded-full text-foreground/70 transition-colors hover:bg-surface-secondary hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent",href:U,rel:"noopener noreferrer",target:"_blank",children:e.jsx(ee,{"aria-hidden":"true",className:"size-4.5"})})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:b.requirement}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:"CLI 需 Node.js 20+"})]})]}),e.jsx("div",{className:"min-w-0 motion-safe:animate-[fade-up_520ms_ease-out]",children:e.jsx("figure",{className:"overflow-hidden rounded-2xl border border-border/80 bg-surface shadow-[0_24px_48px_-28px_rgb(15_23_42/0.45)] dark:shadow-[0_24px_48px_-24px_rgb(0_0_0/0.65)]",children:e.jsx("img",{alt:"Juejin Usage 用量看板界面预览:费用、Token、热力图与趋势图",className:"h-auto w-full",decoding:"async",fetchPriority:"high",height:1560,src:xe,width:2102})})})]})})}const G=m("inline-flex h-14 min-h-14 cursor-pointer items-center justify-center gap-2.5","bg-[#1e80ff] text-base font-medium whitespace-nowrap text-white","transition-colors duration-200 motion-reduce:transition-none","hover:bg-[#1171ee] active:brightness-[0.96]","focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#1e80ff]","dark:bg-[#4b9cff] dark:hover:bg-[#3a8ff0] dark:focus-visible:outline-[#4b9cff]","touch-manipulation");function A({className:n}){return e.jsx("svg",{"aria-hidden":"true",className:n,fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})})}function be({className:n}){return e.jsx("svg",{"aria-hidden":"true",className:n,fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.016 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.592.592 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296z"})})}function S({className:n}){return e.jsx("svg",{"aria-hidden":"true",className:n,fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M3 5.2 11.2 4v7.4H3V5.2Zm8.9-1.4L21 2.6v8.8h-9.1V3.8ZM3 13.4h8.2V21L3 19.7v-6.3Zm8.9 0H21V21.4l-9.1-1.3v-6.7Z"})})}function je(){const n=Q(),t=(n==null?void 0:n.reason)==="uninstalled"?"uninstalled":"new_user";return e.jsx(ge,{reason:t})}export{je as component};
@@ -0,0 +1 @@
1
+ import{t as k,R as u,j as c,b4 as O,a9 as N,r as o,bE as ie,y as G,Z as ce,_ as de,aE as fe,aX as ue,bF as be,a1 as $e,F as _,L as I,G as B,H as C,a2 as Z,a4 as pe,a6 as he,E as me,z as F,bG as xe,a7 as V,bH as ve,bI as ge,aT as we,bJ as Pe,ac as Ce,J as Q,bK as ye,au as Re,bL as Te,bM as Ee,bN as Se,bO as Oe,bP as Ne,bQ as je,bp as De,T as R}from"./index-CWecC3aA.js";import{u as z}from"./index-C0e96pRE.js";const Ie=k({defaultVariants:{color:"default",variant:"secondary"},slots:{base:"chip",label:"chip__label"},variants:{color:{accent:{base:"chip--accent"},danger:{base:"chip--danger"},default:{base:"chip--default"},success:{base:"chip--success"},warning:{base:"chip--warning"}},size:{lg:{base:"chip--lg"},md:{base:"chip--md"},sm:{base:"chip--sm"}},variant:{primary:{base:"chip--primary"},secondary:{base:"chip--secondary"},soft:{base:"chip--soft"},tertiary:{base:"chip--tertiary"}}}}),Me=k({defaultVariants:{size:"md"},slots:{base:"switch",content:"switch__content",control:"switch__control",icon:"switch__icon",thumb:"switch__thumb"},variants:{size:{lg:{base:"switch--lg"},md:{base:"switch--md"},sm:{base:"switch--sm"}}}}),Ae=k({slots:{base:"tooltip",trigger:"tooltip__trigger"}}),X=o.createContext({}),U=({children:e,className:t,color:a,size:n,variant:r,...s})=>{const l=u.useMemo(()=>Ie({color:a,size:n,variant:r}),[a,n,r]),f=u.useMemo(()=>typeof e=="string"||typeof e=="number"?c.jsx(Y,{children:e}):e,[e]);return c.jsx(X,{value:{slots:l},children:c.jsx(O.span,{...s,className:N(l.base,t),"data-slot":"chip",children:f})})},Y=({children:e,className:t,...a})=>{const{slots:n}=o.use(X);return c.jsx(O.span,{className:N(n==null?void 0:n.label,t),"data-slot":"chip-label",...a,children:e})},st=Object.assign(U,{Root:U,Label:Y});function He(e,t,a){let{labelProps:n,inputProps:r,isSelected:s,...l}=ie(e,t,a);return{labelProps:n,inputProps:{...r,role:"switch",checked:s},isSelected:s,...l}}const ke=o.createContext(null),ee=o.createContext(null),te=o.createContext(null),_e=o.forwardRef(function(t,a){let{inputRef:n=null,...r}=t;[t,a]=G(r,a,ke);let{validationBehavior:s}=ce(de)||{},l=t.validationBehavior??s??"native",f=fe(ue(n,t.inputRef!==void 0?t.inputRef:null)),i=be(t),d=He({...$e(t),children:typeof t.children=="function"?!0:t.children,validationBehavior:l},i,f),{descriptionProps:$,errorMessageProps:h,isSelected:m,isDisabled:p,isReadOnly:x,isInvalid:w,validationDetails:b,validationErrors:y}=d,v=_({...t,defaultClassName:"react-aria-SwitchField",values:{isSelected:m,isDisabled:p,isReadOnly:x,isInvalid:w,isRequired:t.isRequired||!1,state:i}}),P=I(t,{global:!0});return delete P.id,delete P.onClick,u.createElement(B.div,{...C(P,v),ref:a,slot:t.slot||void 0,"data-selected":m||void 0,"data-disabled":p||void 0,"data-readonly":x||void 0,"data-invalid":w||void 0,"data-required":t.isRequired||void 0},u.createElement(Z,{values:[[ee,i],[te,{...d,inputRef:f,defaultClassName:"react-aria-SwitchButton",isRequired:t.isRequired}],[pe,{slots:{description:$,errorMessage:h}}],[he,{isInvalid:w,validationDetails:b,validationErrors:y}]]},v.children))}),Be=o.forwardRef(function(t,a){let{labelProps:n,inputProps:r,isSelected:s,isDisabled:l,isReadOnly:f,isPressed:i,isInvalid:d,inputRef:$,defaultClassName:h,isRequired:m}=o.useContext(te),{isFocused:p,isFocusVisible:x,focusProps:w}=me(),b=l||f,y=o.useContext(ee),{hoverProps:v,isHovered:P}=F({...t,isDisabled:b}),q=_({...t,defaultClassName:h,values:{isSelected:s,isPressed:i,isHovered:P,isFocused:p,isFocusVisible:x,isDisabled:l,isReadOnly:f,isInvalid:d,isRequired:m||!1,state:y}}),M=I(t,{global:!0});return delete M.id,delete M.onClick,u.createElement(B.label,{...C(M,n,v,q),ref:a,slot:t.slot||void 0,"data-selected":s||void 0,"data-pressed":i||void 0,"data-hovered":P||void 0,"data-focused":p||void 0,"data-focus-visible":x||void 0,"data-disabled":l||void 0,"data-readonly":f||void 0,"data-invalid":d||void 0,"data-required":m||void 0},u.createElement(xe,{elementType:"span"},u.createElement("input",{...C(r,w),ref:$})),q.children)}),D=o.createContext({}),A=({children:e,className:t,size:a,...n})=>{const r=u.useMemo(()=>Me({size:a}),[a]);return c.jsx(_e,{"data-slot":"switch",...n,className:V(t,r.base()),children:s=>c.jsx(D,{value:{slots:r,state:s},children:typeof e=="function"?e(s):e})})};A.displayName="HeroUI.Switch";const ae=({children:e,className:t,...a})=>{const{slots:n}=o.use(D);return c.jsx(Be,{"data-slot":"switch-content",...a,className:V(t,n==null?void 0:n.content()),children:e})};ae.displayName="HeroUI.Switch.Content";const ne=({children:e,className:t,...a})=>{const{slots:n}=o.use(D);return c.jsx(O.span,{className:N(n==null?void 0:n.control,t),"data-slot":"switch-control",...a,children:e})};ne.displayName="HeroUI.Switch.Control";const oe=({children:e,className:t,...a})=>{const{slots:n}=o.use(D);return c.jsx(O.span,{className:N(n==null?void 0:n.thumb,t),"data-slot":"switch-thumb",...a,children:e})};oe.displayName="HeroUI.Switch.Thumb";const re=({children:e,className:t,...a})=>{const{slots:n}=o.use(D);return c.jsx(O.span,{className:N(n==null?void 0:n.icon,t),"data-slot":"switch-icon",...a,children:e})};re.displayName="HeroUI.Switch.Icon";const lt=Object.assign(A,{Root:A,Content:ae,Control:ne,Thumb:oe,Icon:re}),H=u.createContext(null);function Fe(e){let{children:t}=e,a=o.useContext(H),[n,r]=o.useState(0),s=o.useMemo(()=>({parent:a,modalCount:n,addModal(){r(l=>l+1),a&&a.addModal()},removeModal(){r(l=>l-1),a&&a.removeModal()}}),[a,n]);return u.createElement(H.Provider,{value:s},t)}function Ve(){let e=o.useContext(H);return{modalProviderProps:{"aria-hidden":e&&e.modalCount>0?!0:void 0}}}function Le(e){let{modalProviderProps:t}=Ve();return u.createElement("div",{"data-overlay-container":!0,...e,...t})}function qe(e){return u.createElement(Fe,null,u.createElement(Le,e))}function ze(e){let t=ve(),{portalContainer:a=t?null:document.body,...n}=e,{getContainer:r}=ge();if(!e.portalContainer&&r&&(a=r()),u.useEffect(()=>{if(a!=null&&a.closest("[data-overlay-container]"))throw new Error("An OverlayContainer must not be inside another container. Please change the portalContainer prop.")},[a]),!a)return null;let s=u.createElement(qe,n);return we.createPortal(s,a)}const Ue=1500,W=500;let T={},We=0,S=!1,g=null,E=null;function se(e={}){let{delay:t=Ue,closeDelay:a=W}=e,{isOpen:n,open:r,close:s}=Pe(e),[l,f]=o.useState(!1),i=o.useMemo(()=>`${++We}`,[]),d=o.useRef(null),$=o.useRef(s),h=()=>{T[i]=x},m=()=>{for(let b in T)b!==i&&(T[b](!0,!0),delete T[b])},p=b=>{d.current&&clearTimeout(d.current),d.current=null,m(),h(),f(!!b),S=!0,r(),g&&(clearTimeout(g),g=null),E&&(clearTimeout(E),E=null)},x=(b,y)=>{f(!!y),b||a<=0?(d.current&&clearTimeout(d.current),d.current=null,$.current()):d.current||(d.current=setTimeout(()=>{d.current=null,$.current()},a)),g&&(clearTimeout(g),g=null),S&&(E&&clearTimeout(E),E=setTimeout(()=>{delete T[i],E=null,S=!1},Math.max(W,a)))},w=()=>{m(),h(),!n&&!S?(g&&clearTimeout(g),g=setTimeout(()=>{g=null,S=!0,p(!1)},t)):n||p(!0)};return o.useEffect(()=>{$.current=s},[s]),o.useEffect(()=>()=>{d.current&&clearTimeout(d.current),T[i]&&delete T[i]},[i]),{isOpen:n,shouldSkipAnimation:l,open:b=>{!b&&t>0&&!d.current?w():p(S)},close:x}}function Ke(e,t){let a=I(e,{labelable:!0}),{hoverProps:n}=F({onHoverStart:()=>t==null?void 0:t.open(!0),onHoverEnd:()=>t==null?void 0:t.close()});return{tooltipProps:C(a,n,{role:"tooltip"})}}function Je(e,t,a){let{isDisabled:n,trigger:r,shouldCloseOnPress:s=!0}=e,l=Ce(),f=o.useRef(!1),i=o.useRef(!1),d=()=>{(f.current||i.current)&&t.open(i.current)},$=v=>{!f.current&&!i.current&&t.close(v)};o.useEffect(()=>{let v=P=>{a&&a.current&&P.key==="Escape"&&(P.stopPropagation(),t.close(!0))};if(t.isOpen)return document.addEventListener("keydown",v,!0),()=>{document.removeEventListener("keydown",v,!0)}},[a,t]);let h=()=>{r!=="focus"&&(ye()==="pointer"?f.current=!0:f.current=!1,d())},m=()=>{r!=="focus"&&(i.current=!1,f.current=!1,$())},p=()=>{s&&(i.current=!1,f.current=!1,$(!0))},x=()=>{Re()&&(i.current=!0,d())},w=()=>{i.current=!1,f.current=!1,$(!0)},{hoverProps:b}=F({isDisabled:n,onHoverStart:h,onHoverEnd:m}),{focusableProps:y}=Q({isDisabled:n,onFocus:x,onBlur:w},a);return{triggerProps:{"aria-describedby":t.isOpen?l:void 0,...C(y,b,{onPointerDown:p,onKeyDown:p}),tabIndex:void 0},tooltipProps:{id:l}}}const j=o.createContext(null),le=o.createContext(null);function Ge(e){let t=se(e),a=o.useRef(null),{triggerProps:n,tooltipProps:r}=Je(e,t,a);return u.createElement(Z,{values:[[j,t],[le,{...r,triggerRef:a}]]},u.createElement(Te,{...n,ref:a},e.children))}const Ze=o.forwardRef(function({UNSTABLE_portalContainer:t,...a},n){[a,n]=G(a,n,le);let r=o.useContext(j),s=se(a),l=a.isOpen!=null||a.defaultOpen!=null||!r?s:r,f=Ee(n,l.isOpen),i=a.isExiting||!l.shouldSkipAnimation&&f||!1;return!l.isOpen&&!i?null:u.createElement(ze,{portalContainer:t},u.createElement(Qe,{...a,tooltipRef:n,isExiting:i}))});function Qe(e){let t=o.useContext(j),a=o.useRef(null),{overlayProps:n,arrowProps:r,placement:s,triggerAnchorPoint:l}=Se({placement:e.placement||"top",targetRef:e.triggerRef,overlayRef:e.tooltipRef,arrowRef:a,offset:e.offset,crossOffset:e.crossOffset,isOpen:t.isOpen,arrowBoundaryOffset:e.arrowBoundaryOffset,shouldFlip:e.shouldFlip,containerPadding:e.containerPadding,onClose:()=>t.close(!0)}),f=Oe(e.tooltipRef,!!s),i=e.isEntering||!t.shouldSkipAnimation&&f||!1,d=_({...e,defaultClassName:"react-aria-Tooltip",values:{placement:s,isEntering:i,isExiting:e.isExiting,state:t}});e=C(e,n);let{tooltipProps:$}=Ke(e,t),h=I(e,{global:!0});return u.createElement(B.div,{...C(h,d,$),ref:e.tooltipRef,style:{...n.style,"--trigger-anchor-point":l?`${l.x}px ${l.y}px`:void 0,...d.style},"data-placement":s??void 0,"data-entering":i||void 0,"data-exiting":e.isExiting||void 0},u.createElement(Ne.Provider,{value:{...r,placement:s,ref:a}},d.children))}const K=e=>{if(!e)return;const t=e.trim(),a=parseFloat(t);if(!Number.isNaN(a))return t.endsWith("ms")?a:t.endsWith("s")?a*1e3:a},L=o.createContext({}),Xe=({children:e,shouldSkipAnimation:t})=>{const a=o.use(j);return!a||t?e:c.jsx(j,{value:{...a,shouldSkipAnimation:!1},children:e})},J=({children:e,closeDelay:t,delay:a,shouldSkipAnimation:n=!1,...r})=>{const s=u.useMemo(()=>Ae(),[]),l=z("--tooltip-delay"),f=z("--tooltip-close-delay"),i=a??K(l),d=t??K(f);return c.jsx(L,{value:{slots:s},children:c.jsx(Ge,{closeDelay:d,"data-slot":"tooltip-root",delay:i,...r,children:c.jsx(Xe,{shouldSkipAnimation:n,children:e})})})},Ye=({children:e,className:t,offset:a,showArrow:n=!1,...r})=>{const{slots:s}=o.use(L),l=a||(n?7:3);return c.jsx(Ze,{...r,className:V(t,s==null?void 0:s.base()),offset:l,children:e})},et=({children:e,className:t,...a})=>{const n=c.jsx("svg",{"data-slot":"overlay-arrow",fill:"none",height:"12",viewBox:"0 0 12 12",width:"12",xmlns:"http://www.w3.org/2000/svg",children:c.jsx("path",{d:"M0 0C5.48483 8 6.5 8 12 0Z"})}),r=u.isValidElement(e)?u.cloneElement(e,{"data-slot":"overlay-arrow"}):n;return c.jsx(je,{"data-slot":"tooltip-arrow",...a,className:t,children:r})},tt=({children:e,className:t,...a})=>{const{slots:n}=o.use(L),r=o.useRef(null),{focusableProps:s}=Q({},r);return c.jsx(O.div,{ref:r,className:N(n==null?void 0:n.trigger,t),"data-slot":"tooltip-trigger",role:"button",...C(s,a),children:e})},it=Object.assign(J,{Root:J,Trigger:tt,Content:Ye,Arrow:et}),at=e=>o.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},e),o.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M8 13.5a5.5 5.5 0 0 0 2.263-10.514 5.5 5.5 0 0 1-7.278 7.278A5.5 5.5 0 0 0 8 13.5M1.045 8.795a7.001 7.001 0 1 0 7.75-7.75l-.028-.003A7 7 0 0 0 8 1c-.527 0-.59.842-.185 1.18a4 4 0 0 1 .342.322A4 4 0 1 1 2.18 7.814C1.842 7.41 1 7.474 1 8a7 7 0 0 0 .045.794",clipRule:"evenodd"})),nt=e=>o.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},e),o.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M8 3a.75.75 0 0 1-.75-.75V.75a.75.75 0 0 1 1.5 0v1.5A.75.75 0 0 1 8 3m0 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5M8 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8m-.75 3.25a.75.75 0 0 0 1.5 0v-1.5a.75.75 0 0 0-1.5 0zM13 8a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 0 1.5h-1.5A.75.75 0 0 1 13 8M.75 7.25a.75.75 0 0 0 0 1.5h1.5a.75.75 0 0 0 0-1.5zm10.786-2.786a.75.75 0 0 1 0-1.06l1.06-1.06a.75.75 0 0 1 1.06 1.06l-1.06 1.06a.75.75 0 0 1-1.06 0m-9.193 8.132a.75.75 0 0 0 1.06 1.06l1.062-1.06a.75.75 0 0 0-1.061-1.06zm9.193-1.06a.75.75 0 0 1 1.06 0l1.06 1.06a.75.75 0 0 1-1.06 1.06l-1.06-1.06a.75.75 0 0 1 0-1.06M3.404 2.343a.75.75 0 0 0-1.06 1.06l1.06 1.061a.75.75 0 1 0 1.06-1.06z",clipRule:"evenodd"}));function ct(){const{theme:e,setTheme:t}=De(),a=n=>{const r=n;(r==="light"||r==="dark")&&t(r)};return c.jsx(R,{className:"w-fit shrink-0 text-center",selectedKey:e,onSelectionChange:n=>a(String(n)),children:c.jsx(R.ListContainer,{children:c.jsxs(R.List,{"aria-label":"页面主题",className:"w-fit",children:[c.jsxs(R.Tab,{"aria-label":"使用亮色模式",className:"h-6 w-6 px-0 text-xs data-[selected=true]:text-accent-foreground",id:"light",children:[c.jsx(nt,{className:"size-3.5"}),c.jsx(R.Indicator,{className:"bg-accent"})]}),c.jsxs(R.Tab,{"aria-label":"使用暗色模式",className:"h-6 w-6 px-0 text-xs data-[selected=true]:text-accent-foreground",id:"dark",children:[c.jsx(at,{className:"size-3.5"}),c.jsx(R.Indicator,{className:"bg-accent"})]})]})})})}function dt(){return!1}export{st as C,lt as S,it as T,ct as a,dt as i};