@juejin-opensource/jusage 0.1.6-beta.0 → 0.1.7

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 (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/dist/args.d.ts +20 -0
  4. package/dist/args.js +121 -0
  5. package/dist/daemon.d.ts +2 -2
  6. package/dist/daemon.js +8 -7
  7. package/dist/dashboard/assets/Check-C6Vp6SAU.js +1 -0
  8. package/dist/dashboard/assets/click-idle-CXAVCmiH.png +0 -0
  9. package/dist/dashboard/assets/dashboard-CW-mCwMR.js +55 -0
  10. package/dist/dashboard/assets/download-_xhCt7jY.js +1 -0
  11. package/dist/dashboard/assets/downloads-63AG5C_E.js +1 -0
  12. package/dist/dashboard/assets/hawking-idle-QoXt5bST.png +0 -0
  13. package/dist/dashboard/assets/index-3miiAdwH.js +143 -0
  14. package/dist/dashboard/assets/{index-I_ub2jqy.css → index-C1vokUY2.css} +1 -1
  15. package/dist/dashboard/assets/{index-C28OANM4.js → index-DikHz9Xg.js} +1 -1
  16. package/dist/dashboard/assets/{pricing-C1AgdgdM.js → pricing-Btfm94JM.js} +1 -1
  17. package/dist/dashboard/assets/rank-LoqZH6uK.js +16 -0
  18. package/dist/dashboard/assets/{settings-BA_UlPf3.js → settings-BzyD7YMM.js} +1 -1
  19. package/dist/dashboard/assets/useLocalStorage-C_Z-N_8Q.js +1 -0
  20. package/dist/dashboard/assets/yoyo-idle-DDvV3ieO.png +0 -0
  21. package/dist/dashboard/index.html +2 -2
  22. package/dist/index.d.ts +1 -10
  23. package/dist/index.js +21 -93
  24. package/dist/service-linux.js +6 -1
  25. package/dist/service.d.ts +4 -1
  26. package/dist/service.js +19 -8
  27. package/package.json +13 -13
  28. package/dist/dashboard/assets/ChevronDown-raqOGGZY.js +0 -1
  29. package/dist/dashboard/assets/click-idle-6pQvdt8N.png +0 -0
  30. package/dist/dashboard/assets/dashboard-2aS4UXAq.js +0 -55
  31. package/dist/dashboard/assets/download-w1_SlsVA.js +0 -1
  32. package/dist/dashboard/assets/downloads-DRt36RTZ.js +0 -1
  33. package/dist/dashboard/assets/env-Bahc-RuR.js +0 -1
  34. package/dist/dashboard/assets/hawking-idle-C6M3ZvDm.png +0 -0
  35. package/dist/dashboard/assets/index-DpG68XJd.js +0 -143
  36. package/dist/dashboard/assets/rank-DNpmekT1.js +0 -16
  37. package/dist/dashboard/assets/yoyo-idle-DmXh5tLT.png +0 -0
@@ -1 +0,0 @@
1
- import{r,j as e,k as l,B as S,bb as F}from"./index-DpG68XJd.js";import{r as E,d as T,a as O,g as $,f as q,D as y,m as K,b as Y,G as Q,L as X,c as ee}from"./downloads-DRt36RTZ.js";import{P as i,C as M,a as v}from"./ChevronDown-raqOGGZY.js";const se=a=>r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},a),r.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"})),ae={new_user:{badge:"Juejin Usage",headline:["Cursor、Claude、Codex","多工具 Token 与费用","本地面板一张表看完。"],description:"汇总你实际在用的 AI 编码工具用量与趋势,安装后即可查看。"},uninstalled:{badge:"客户端暂未连接",headline:["客户端暂未连接","启动后继续","同步本机用量。"],description:"下载并打开 Juejin Usage,即可把本机 AI 用量同步回这块面板。"}},te="/e1.png",j=[{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"}],D="tud.downloadTarget";function H(){try{const a=sessionStorage.getItem(D);if(a&&y.some(o=>o.id===a))return a}catch{}return null}function ne(a){try{sessionStorage.setItem(D,a)}catch{}}function re({reason:a}){const o=ae[a],[m,k]=r.useState(()=>{const s=H();return s||(typeof navigator>"u"?"macos-arm":E(O(navigator.userAgent,navigator.platform),T(navigator.userAgent)))}),[_,L]=r.useState({}),[P,G]=r.useState(),[h,C]=r.useState(!1),[p,A]=r.useState(!1),[z,B]=r.useState("npx"),[d,g]=r.useState(!1),I=r.useRef(H()!==null),u=$(m),U=ee(P),b=j.find(s=>s.id===z)??j[0];r.useEffect(()=>{var c,f;let s=!1;const t=navigator,n=(x,W)=>{var R;s||I.current||k(E(O(t.userAgent,t.platform,W??((R=t.userAgentData)==null?void 0:R.platform)??""),T(t.userAgent,x)))};return n(),(f=(c=t.userAgentData)==null?void 0:c.getHighEntropyValues)==null||f.call(c,["architecture","platform"]).then(x=>{n(x.architecture,x.platform)}).catch(()=>{}),()=>{s=!0}},[]),r.useEffect(()=>{let s=!1;return q().then(t=>{if(s)return;const n={};for(const c of y){const f=K(t.assets,c.id);f&&(n[c.id]=f)}L(n),G(t.source)}).catch(()=>{}),()=>{s=!0}},[]),r.useEffect(()=>{if(!d)return;const s=window.setTimeout(()=>g(!1),1600);return()=>window.clearTimeout(s)},[d]);const Z=s=>{const t=_[s]??U,n=document.createElement("a");n.href=t,n.rel="noopener noreferrer",n.target="_blank",_[s]&&(n.download=""),document.body.append(n),n.click(),n.remove()},J=async()=>{try{await navigator.clipboard.writeText(b.command),g(!0)}catch{g(!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:o.badge}),e.jsx("span",{"aria-hidden":"true",className:"text-foreground/25",children:"·"}),u.os==="windows"?e.jsx(N,{className:"size-4 text-foreground/70"}):e.jsx(w,{className:"size-4 text-foreground/70"}),e.jsxs("span",{children:["适用于 ",u.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:[o.headline[0],e.jsx("br",{}),o.headline[1],e.jsx("br",{}),o.headline[2]]}),e.jsx("p",{className:"mt-5 max-w-xl text-lg leading-8 text-muted",children:o.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:l(V,"rounded-l-full ps-6 pe-5"),type:"button",onClick:()=>Z(m),children:[u.os==="windows"?e.jsx(N,{className:"size-4.5"}):e.jsx(w,{className:"size-4.5"}),u.label]}),e.jsxs(i,{isOpen:h,onOpenChange:C,children:[e.jsx(S,{"aria-expanded":h,"aria-haspopup":"menu","aria-label":"选择其它系统",className:l(V,"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(M,{"aria-hidden":"true",className:l("size-4.5 transition-transform duration-200 motion-reduce:transition-none",h&&"rotate-180")})}),e.jsx(i.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(i.Dialog,{className:"p-0 outline-none",children:[e.jsx(i.Heading,{className:"sr-only",children:"选择下载平台"}),e.jsx("div",{className:"flex flex-col py-1",role:"menu",children:y.map(s=>{const t=s.id===m;return e.jsxs("button",{"aria-current":t?"true":void 0,className:l("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",t?"text-foreground":"text-foreground/80"),role:"menuitem",type:"button",onClick:()=>{I.current=!0,ne(s.id),k(s.id),C(!1)},children:[s.os==="windows"?e.jsx(N,{className:"size-4 text-foreground/70"}):e.jsx(w,{className:"size-4 text-foreground/70"}),e.jsx("span",{className:"min-w-0 flex-1",children:s.menuLabel}),t?e.jsx(v,{"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(i,{isOpen:p,onOpenChange:A,children:[e.jsxs(S,{"aria-expanded":p,"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:b.label}),e.jsx(M,{"aria-hidden":"true",className:l("size-3.5 transition-transform duration-200 motion-reduce:transition-none",p&&"rotate-180")})]}),e.jsx(i.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(i.Dialog,{className:"p-0 outline-none",children:[e.jsx(i.Heading,{className:"sr-only",children:"选择 CLI 启动方式"}),e.jsx("div",{className:"flex flex-col py-1",role:"menu",children:j.map(s=>{const t=s.id===z;return e.jsxs("button",{"aria-current":t?"true":void 0,className:l("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",t?"text-foreground":"text-foreground/80"),role:"menuitem",type:"button",onClick:()=>{B(s.id),A(!1)},children:[e.jsx("span",{className:"min-w-0 flex-1",children:s.label}),t?e.jsx(v,{"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:["$ ",b.command]})}),e.jsx("button",{"aria-label":d?"安装命令已复制":"复制 CLI 安装命令",className:l("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:()=>{J()},children:d?e.jsx(v,{"aria-hidden":"true",className:"size-4 text-[#1e80ff] dark:text-[#4b9cff]"}):e.jsx(se,{"aria-hidden":"true",className:"size-4"})})]})]}),e.jsx("p",{"aria-live":"polite",className:"sr-only",children:d?"安装命令已复制":""}),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:Y,rel:"noopener noreferrer",target:"_blank",children:e.jsx(oe,{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:Q,rel:"noopener noreferrer",target:"_blank",children:e.jsx(X,{"aria-hidden":"true",className:"size-4.5"})})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:u.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:te,width:2102})})})]})})}const V=l("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 w({className:a}){return e.jsx("svg",{"aria-hidden":"true",className:a,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 oe({className:a}){return e.jsx("svg",{"aria-hidden":"true",className:a,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 N({className:a}){return e.jsx("svg",{"aria-hidden":"true",className:a,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 de(){const a=F(),o=(a==null?void 0:a.reason)==="uninstalled"?"uninstalled":"new_user";return e.jsx(re,{reason:o})}export{de as component};
@@ -1 +0,0 @@
1
- import{r as u}from"./index-DpG68XJd.js";const T=e=>u.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},e),u.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"})),f="https://gitee.com/juejin-cn/juejin-usage",p=`${f}/releases`,h="https://gitee.com/api/v5/repos/juejin-cn/juejin-usage/releases?per_page=8",b="https://github.com/juejin-cn/juejin-usage",g=`${b}/releases`,E="https://api.github.com/repos/juejin-cn/juejin-usage/releases?per_page=8",_=8e3,d=[{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+"}],R=new Map(d.map(e=>[e.id,e]));function O(e){return R.get(e)??d[0]}function $(e,n="",t=""){const s=`${t} ${n} ${e}`.toLowerCase();return/\bwin(?:dows|32|64|ce)?\b/.test(s)||s.includes("windows")?"windows":s.includes("mac")||s.includes("darwin")||s.includes("iphone")||s.includes("ipad")||s.includes("ipod")?"macos":"other"}function I(e,n=""){const t=n.toLowerCase();return t.includes("arm")?"arm":t.includes("x86")||t.includes("x64")||t.includes("amd64")||/\bintel\b/i.test(e)?"x64":"unknown"}function x(e,n="unknown"){return e==="windows"?"windows":e==="macos"&&n==="x64"?"macos-intel":"macos-arm"}function S(e){return e.find(n=>!n.draft)??null}function w(e){return!/\.(blockmap|yml|yaml|zip|tar\.gz)$/i.test(e)}function c(e){return e.some(n=>w(n.name)&&/\.(dmg|exe)$/i.test(n.name))}function v(e,n){var s,r,l,o;const t=e.filter(a=>w(a.name));if(n==="windows"){const a=t.find(i=>/\.exe$/i.test(i.name)&&/setup/i.test(i.name)&&!/portable/i.test(i.name));return a?a.browser_download_url:((s=t.find(i=>/\.exe$/i.test(i.name)&&!/portable/i.test(i.name)))==null?void 0:s.browser_download_url)??null}return n==="macos-arm"?((r=t.find(a=>/arm64\.dmg$/i.test(a.name)))==null?void 0:r.browser_download_url)??null:((l=t.find(a=>/x64\.dmg$/i.test(a.name)))==null?void 0:l.browser_download_url)??((o=t.find(a=>/\.dmg$/i.test(a.name)&&!/arm64/i.test(a.name)))==null?void 0:o.browser_download_url)??null}function k(e){return e==="github"?g:p}function j(e,n){return{source:e,tagName:n.tag_name,assets:n.assets??[]}}function A(e,n){if(e&&c(e.assets))return e;if(n&&c(n.assets))return n;throw new Error("No published desktop release")}async function m(e,n){const t=new AbortController,s=setTimeout(()=>t.abort(),_);try{const r=await fetch(e,{headers:{Accept:n==="github"?"application/vnd.github+json":"application/json"},signal:t.signal});if(!r.ok)throw new Error(`${n} releases ${r.status}`);const l=await r.json(),o=S(l);if(!o)throw new Error(`No published ${n} release`);return j(n,o)}finally{clearTimeout(s)}}async function G(){let e=null;try{e=await m(h,"gitee")}catch{e=null}if(e&&c(e.assets))return e;const n=await m(E,"github");return A(e,n)}export{d as D,b as G,T as L,$ as a,f as b,k as c,I as d,G as f,O as g,v as m,x as r};
@@ -1 +0,0 @@
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-DpG68XJd.js";import{u as z}from"./index-C28OANM4.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};