@aidotnet/server-linux-x64 0.13.5 → 0.13.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/astra-server +2 -2
- package/bin/wwwroot/assets/{ClientsPage-gRSh7_CV.js → ClientsPage-DdK1X-Ec.js} +1 -1
- package/bin/wwwroot/assets/{KeyPage-D77qfw6X.js → KeyPage-dJ_528w9.js} +1 -1
- package/bin/wwwroot/assets/{ModelDetailPage-9WGV08Ir.js → ModelDetailPage-DesYkEp0.js} +1 -1
- package/bin/wwwroot/assets/{ModelsPage-ONDK3J08.js → ModelsPage-CvBrKMJm.js} +1 -1
- package/bin/wwwroot/assets/{PluginsPage-nSzZ0q9J.js → PluginsPage-Czuxiksr.js} +1 -1
- package/bin/wwwroot/assets/{PrivacyPage-L2K6y0cS.js → PrivacyPage-CxAIxf_4.js} +1 -1
- package/bin/wwwroot/assets/{ProviderDetailPage-Cb_AXwQV.js → ProviderDetailPage-zjVraUzS.js} +1 -1
- package/bin/wwwroot/assets/{ProvidersPage-D4CaD0A4.js → ProvidersPage-D1GpUvNb.js} +1 -1
- package/bin/wwwroot/assets/{SettingsPage-DxaHksJO.js → SettingsPage-CDgCn_us.js} +1 -1
- package/bin/wwwroot/assets/{SmartRoutingPage-CAcrEtoz.js → SmartRoutingPage-C8UPuxod.js} +1 -1
- package/bin/wwwroot/assets/{TokenDetailPage-DQjS2Rfd.js → TokenDetailPage-ClqiNQNY.js} +1 -1
- package/bin/wwwroot/assets/{TokenPoolEditor-B_Z5aPHq.js → TokenPoolEditor-CSR-HDQz.js} +1 -1
- package/bin/wwwroot/assets/{TokensPage-DI5GW9jT.js → TokensPage-B62tF1Mb.js} +1 -1
- package/bin/wwwroot/assets/{TracesPage-BLhnQx6x.js → TracesPage-Dadx7Tfx.js} +1 -1
- package/bin/wwwroot/assets/{TrayPanelPage-BVygPKsx.js → TrayPanelPage-Ckj4lTgg.js} +1 -1
- package/bin/wwwroot/assets/{TrayPanelView-CxRkRjNA.js → TrayPanelView-bAOrJBs5.js} +1 -1
- package/bin/wwwroot/assets/{confirm-morph-DanmNnVF.js → confirm-morph-BPDPizy8.js} +1 -1
- package/bin/wwwroot/assets/{index-CN0EAD0q.js → index-DL_p8MKk.js} +2 -2
- package/bin/wwwroot/index.html +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fa as e,Pa as t,Ra as n,Y as r,ct as i,dt as a,ft as o,gt as s,ot as c,q as l,s as u,v as d,xt as f}from"./alert-BF0mCqUl.js";import{G as p,H as m,J as h,K as g,Q as _,U as v,V as y,W as b,X as x,Y as S,Z as C,_t as w,lt as T,q as E}from"./overlays-OPtjc9Yr.js";import{t as D}from"./arrow-up-right-6yJy6Xdl.js";import{t as O}from"./ellipsis-D10W7mYw.js";import{t as k}from"./rotate-ccw-DwTwYkU2.js";import{G as A,H as j,R as M,_ as N,m as P,x as F,y as I}from"./index-CN0EAD0q.js";var L={name:`arrow-down-right`,size:24,node:[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]};L.node;var R=f(L),z={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};z.node;var B=f(z),V={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};V.node;var H=f(V),U=n(e(),1),W=t(),G={green:`var(--success)`,orange:`var(--warning)`,red:`var(--danger)`},K=(0,U.forwardRef)(function({prefs:e,state:t,data:n,onCommand:r,onRefresh:l,onCopyAddress:d,onSwitchClient:f,preview:p,tab:m,onTabChange:h,className:g},_){let{t:v}=i(),[y,b]=(0,U.useState)(`overview`),x=t.activity!==null,S=t.running&&!x,C=e=>r?.(e),T=[`overview`];e.sections.quota&&(n.plans.length>0||n.hasSubscriptions)&&T.push(`quota`),e.sections.clients&&n.clients.some(e=>e.enabled)&&T.push(`clients`);let E=m??y,j=T.includes(E)?E:`overview`,M=e=>{b(e),h?.(e)},N=(t.running||x)&&T.length>1,P=n.settings?.gatewayBaseUrl.replace(/^https?:\/\//,``)??(t.port?`127.0.0.1:${t.port}`:``),F=t.activity?v(`tray.status.${t.activity}`):t.running?v(`tray.status.running`):v(`tray.status.stopped`);return(0,W.jsxs)(`div`,{ref:_,className:c(`chrome flex max-h-full flex-col overflow-hidden rounded-[14px] border border-[var(--border-strong)] bg-[var(--surface-raised)] text-[13px] text-[var(--foreground)]`,g),children:[(0,W.jsxs)(`header`,{"data-tray-part":`header`,className:`shrink-0 border-b border-[var(--border)] px-4 pt-3.5 pb-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(u,{tone:x?`orange`:t.running?`green`:`red`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[14px] font-semibold`,children:F}),(0,W.jsx)(q,{label:v(`tray.copyAddress`),onClick:d,disabled:!P,children:(0,W.jsx)(s,{className:`size-4`})}),(0,W.jsx)(q,{label:v(`tray.settings`),onClick:()=>C(`open-settings`),children:(0,W.jsx)(w,{className:`size-4`})}),(0,W.jsx)(q,{label:v(`tray.more`),onClick:()=>C(`menu`),children:(0,W.jsx)(O,{className:`size-4`})}),!p&&(0,W.jsx)(q,{label:v(`common.close`),onClick:()=>C(`hide`),children:(0,W.jsx)(a,{className:`size-4`})})]}),P&&(0,W.jsx)(`div`,{className:`selectable mt-0.5 truncate pl-4 font-mono text-[12px] text-[var(--text-secondary)]`,children:P}),(t.apiVersionMismatch||t.updateAvailable)&&(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 pl-4`,children:[t.apiVersionMismatch&&(0,W.jsxs)(J,{tone:`orange`,children:[(0,W.jsx)(o,{className:`size-3`}),v(`tray.mismatch`)]}),t.updateAvailable&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>C(`check-updates`),className:`cursor-default`,children:(0,W.jsx)(J,{tone:`accent`,children:v(`tray.update`)})})]})]}),(0,W.jsx)(`div`,{"data-tray-part":`tabs`,className:`shrink-0`,children:N&&(0,W.jsx)(ee,{tabs:T,active:j,onChange:M})}),(0,W.jsx)(`div`,{className:`scroll min-h-0 flex-1 overflow-y-auto`,children:(0,W.jsx)(`div`,{"data-tray-part":`body`,className:`flex flex-col gap-3 px-4 py-3.5`,children:!t.running&&!x?(0,W.jsx)(ne,{onStart:()=>C(`start`)}):(0,W.jsxs)(W.Fragment,{children:[j===`overview`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(te,{prefs:e,data:n,onViewQuota:()=>M(`quota`)}),(0,W.jsx)(ie,{prefs:e,data:n,onRefresh:l}),e.sections.quota&&(0,W.jsx)(oe,{data:n,onViewAll:()=>M(`quota`)})]}),j===`quota`&&(0,W.jsx)(se,{data:n,plain:!0}),j===`clients`&&(0,W.jsx)(le,{data:n,disabled:!S,onSwitch:f,plain:!0})]})})}),(0,W.jsxs)(`footer`,{"data-tray-part":`footer`,className:`flex shrink-0 items-center gap-1 border-t border-[var(--border)] px-3 py-2.5`,children:[t.running?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:v(`tray.restart`),onClick:()=>C(`restart`),disabled:x,children:(0,W.jsx)(k,{className:`size-4`})}),(0,W.jsx)(q,{label:v(`tray.stop`),onClick:()=>C(`stop`),disabled:x,children:(0,W.jsx)(A,{className:`size-4`})})]}):(0,W.jsx)(q,{label:v(`shell.startService`),onClick:()=>C(`start`),disabled:x,children:(0,W.jsx)(H,{className:`size-4`})}),(0,W.jsx)(`div`,{className:`flex-1`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>C(`quit`),className:`h-8 cursor-default rounded-[8px] px-2.5 text-[13px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-muted)] hover:text-[var(--foreground)]`,children:v(`tray.quit`)}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>C(`open`),className:`inline-flex h-8 cursor-default items-center gap-1.5 rounded-[8px] border border-[var(--border-strong)] px-3 text-[13px] font-medium transition-colors hover:bg-[var(--surface-muted)]`,children:[v(`tray.open`),(0,W.jsx)(D,{className:`size-3.5`})]})]})]})});function q({label:e,onClick:t,disabled:n,children:r}){return(0,W.jsx)(`button`,{type:`button`,title:e,"aria-label":e,disabled:n,onClick:t,className:`inline-flex size-8 shrink-0 cursor-default items-center justify-center rounded-[8px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-muted)] hover:text-[var(--foreground)] disabled:opacity-40 disabled:hover:bg-transparent`,children:r})}function J({tone:e,children:t,title:n}){let r={red:`var(--danger)`,orange:`var(--warning)`,accent:`var(--accent)`,neutral:`var(--text-secondary)`}[e];return(0,W.jsx)(`span`,{title:n,className:`inline-flex max-w-full items-center gap-1 rounded-[6px] border px-1.5 py-px text-[11.5px] leading-[18px] whitespace-nowrap`,style:{color:r,borderColor:`color-mix(in oklab, ${r} 45%, transparent)`,background:`color-mix(in oklab, ${r} 10%, transparent)`},children:t})}function ee({tabs:e,active:t,onChange:n}){let{t:r}=i(),a={overview:r(`tray.tab.overview`),quota:r(`tray.tab.quota`),clients:r(`tray.clients`)};return(0,W.jsx)(`div`,{role:`tablist`,className:`flex gap-1 px-3 pt-2.5`,children:e.map(e=>(0,W.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===t,onClick:()=>n(e),className:c(`h-7 cursor-default rounded-[7px] px-2.5 text-[12.5px] transition-colors`,e===t?`bg-[var(--surface-muted)] font-medium text-[var(--foreground)]`:`text-[var(--text-secondary)] hover:text-[var(--foreground)]`),children:a[e]},e))})}function Y({tone:e,onClick:t,children:n}){let r=e===`red`?`var(--danger)`:`var(--warning)`,i={color:r,borderColor:`color-mix(in oklab, ${r} 45%, transparent)`,background:`color-mix(in oklab, ${r} 10%, transparent)`},a=`flex w-full items-center gap-1.5 rounded-[8px] border px-2.5 py-1.5 text-left text-[12.5px]`,s=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(o,{className:`size-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n})]});return t?(0,W.jsxs)(`button`,{type:`button`,onClick:t,className:c(a,`cursor-default`),style:i,children:[s,(0,W.jsx)(j,{className:`size-3.5 shrink-0`})]}):(0,W.jsx)(`div`,{className:a,style:i,children:s})}function te({prefs:e,data:t,onViewQuota:n}){let{t:r,locale:a}=i(),o=t.summary,s=e.sections.overview&&o?m(o):0,c=e.sections.quota?E(t.plans):null,u=c&&c.row.remaining<30?c:null;return!o||s===0&&!u?null:(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s>0&&(0,W.jsx)(Y,{tone:`red`,children:r(`tray.alert.failures`,{count:s,share:l(s/o.requests)})}),u&&(0,W.jsx)(Y,{tone:u.row.remaining<10?`red`:`orange`,onClick:n,children:r(`tray.alert.quota`,{plan:u.plan.providerName,window:Q(u.row,r,a),remaining:`${Math.round(u.row.remaining)}%`})})]})}function ne({onStart:e}){let{t}=i();return(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-6 text-center`,children:[(0,W.jsx)(`div`,{className:`text-[13px] font-medium`,children:t(`tray.status.stopped`)}),(0,W.jsx)(`div`,{className:`max-w-[260px] text-[12px] text-[var(--text-secondary)]`,children:t(`tray.stoppedHint`)}),(0,W.jsxs)(`button`,{type:`button`,onClick:e,className:`mt-1 inline-flex h-8 cursor-default items-center gap-1.5 rounded-[8px] bg-[var(--accent)] px-3 text-[13px] font-medium text-[var(--on-accent)]`,children:[(0,W.jsx)(H,{className:`size-3.5`}),t(`shell.startService`)]})]})}function re(e=3e4){let[t,n]=(0,U.useState)(()=>Date.now());return(0,U.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function ie({prefs:e,data:t,onRefresh:n}){let{t:a,locale:o}=i(),s=re(),c=t.summary,u=e.sections,f=u.overview||u.cost,p=c?c.inputTokens+c.outputTokens:0,m=x(t.updatedAt,o,a(`tray.justNow`),s),h=u.topModel?S(t.top,p):null,g=u.cacheHitRate&&c?P(c.cacheReadTokens,c.inputTokens):null,b=u.compareYesterday&&c?y(p,_(t.daily,new Date(s))):null,C=u.topModel||u.cacheHitRate||u.compareYesterday;return!f&&!u.chart&&!C?null:(0,W.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[13px] text-[var(--text-secondary)]`,children:a(`tray.today`)}),(0,W.jsx)(`div`,{className:`flex-1`}),m&&(0,W.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:a(`tray.updated`,{time:m})}),(0,W.jsx)(q,{label:a(`common.refresh`),onClick:n,children:(0,W.jsx)(M,{className:`size-3.5`})})]}),c?(0,W.jsxs)(W.Fragment,{children:[f&&(0,W.jsxs)(`div`,{className:`grid auto-cols-fr grid-flow-col gap-px overflow-hidden rounded-[10px] bg-[var(--border)]`,children:[u.overview&&(0,W.jsx)(X,{label:a(`tray.requests`),value:r(c.requests,!0)}),u.overview&&(0,W.jsx)(X,{label:a(`tray.tokens`),value:r(p,!0)}),u.cost&&(0,W.jsx)(X,{label:a(`tray.cost`),value:v(c.costUsd)})]}),u.chart&&(0,W.jsx)(ae,{data:t,now:s}),C&&(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[h&&(0,W.jsxs)(Z,{label:a(`tray.topModel`),title:h.model,children:[(0,W.jsx)(`span`,{className:`truncate`,children:h.model}),(0,W.jsxs)(`span`,{className:`shrink-0`,children:[`· `,l(h.share)]})]}),u.cacheHitRate&&(0,W.jsx)(Z,{label:a(`tray.cacheHit`),children:(0,W.jsx)(`span`,{children:g==null?`—`:l(g)})}),u.compareYesterday&&(0,W.jsx)(Z,{label:a(`tray.vsYesterday`),children:b==null?(0,W.jsx)(`span`,{children:`—`}):(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[b>=0?(0,W.jsx)(D,{className:`size-3`}):(0,W.jsx)(R,{className:`size-3`}),l(Math.abs(b))]})})]})]}):t.error?(0,W.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:a(`tray.loadFailed`)}):(0,W.jsx)(d,{lines:2})]})}function X({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`min-w-0 bg-[var(--surface-muted)] px-3 py-2.5`,children:[(0,W.jsx)(`div`,{className:`truncate text-[12px] text-[var(--text-secondary)]`,children:e}),(0,W.jsx)(`div`,{className:`num mt-0.5 truncate text-[20px] leading-tight font-semibold`,title:t,children:t})]})}function Z({label:e,title:t,children:n}){return(0,W.jsxs)(`span`,{title:t,className:`inline-flex max-w-full min-w-0 items-center gap-1.5 rounded-[7px] border border-[var(--border)] px-2 py-0.5 text-[12px]`,children:[(0,W.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e}),(0,W.jsx)(`span`,{className:`flex min-w-0 items-center gap-1 font-medium`,children:n})]})}function ae({data:e,now:t}){let{t:n}=i(),r=b(e.hourly,new Date(t)),a=Math.max(1,...r.map(e=>e.value)),o=new Date(t).getHours();return(0,W.jsx)(`div`,{role:`img`,"aria-label":n(`tray.chartLabel`),className:`flex h-16 items-end gap-[3px]`,children:r.map((e,t)=>{let r=e.value>0?Math.max(4,Math.round(e.value/a*64)):2;return(0,W.jsx)(`span`,{title:n(`tray.hourBar`,{hour:`${String(t).padStart(2,`0`)}:00`,count:e.value}),className:`flex-1 rounded-[2px]`,style:{height:r,background:t===o?`var(--accent)`:e.value>0?`color-mix(in oklab, var(--foreground) 32%, transparent)`:`var(--border)`,opacity:t>o?.5:1}},e.bucket)})})}function oe({data:e,onViewAll:t}){let{t:n,locale:r}=i();if(e.plans.length===0)return e.hasSubscriptions?(0,W.jsx)(`div`,{className:`border-t border-[var(--border)] pt-3 text-[12px] text-[var(--text-muted)]`,children:n(`tray.quotaPending`)}):null;let a=h(e.plans,3),o=e.plans.reduce((e,t)=>e+t.rows.length,0);return(0,W.jsxs)(`section`,{className:`flex flex-col gap-2 border-t border-[var(--border)] pt-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center text-[12px] text-[var(--text-secondary)]`,children:[(0,W.jsx)(`span`,{className:`flex-1`,children:n(`tray.quotaTightest`)}),o>a.length&&(0,W.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex cursor-default items-center gap-0.5 hover:text-[var(--foreground)]`,children:[n(`tray.viewAll`),(0,W.jsx)(j,{className:`size-3`})]})]}),a.map(({plan:e,row:t},i)=>(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_64px_40px_60px] items-center gap-2 text-[12.5px]`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(F,{name:e.providerName,icon:e.providerIcon,size:14}),(0,W.jsx)(`span`,{className:`truncate font-medium`,children:e.providerName}),(0,W.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:Q(t,n,r)})]}),(0,W.jsx)($,{row:t,locale:r})]},`${e.accountId}-${t.kind}-${i}`))]})}function se({data:e,plain:t}){let{t:n}=i();if(e.plans.length===0&&!e.hasSubscriptions)return null;let r=new Map;for(let t of e.plans)r.set(t.providerId,(r.get(t.providerId)??0)+1);return(0,W.jsxs)(`section`,{className:c(`flex flex-col gap-2`,!t&&`border-t border-[var(--border)] pt-3`),children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-[1fr_48px_72px] items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,W.jsx)(`span`,{children:n(`tray.quota`)}),(0,W.jsx)(`span`,{className:`text-right`,children:n(`tray.quotaRemaining`)}),(0,W.jsx)(`span`,{className:`text-right`,children:n(`tray.quotaReset`)})]}),e.plans.length===0?(0,W.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`tray.quotaPending`)}):e.plans.map(e=>(0,W.jsx)(ce,{plan:e,showAccount:(r.get(e.providerId)??0)>1},e.accountId))]})}function Q(e,t,n){return e.kind===`balance`?e.label??t(`tray.quotaBalance`):e.kind===`credits`||e.windowMinutes==null?t(`tray.quotaCredits`):C(e.windowMinutes,n)}function $({row:e,locale:t}){let n=e.remaining,r=n===null?void 0:G[p(n)];return(0,W.jsxs)(W.Fragment,{children:[n===null?(0,W.jsx)(`span`,{}):(0,W.jsx)(`span`,{className:`h-1.5 overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,W.jsx)(`span`,{className:`block h-full rounded-full`,style:{width:`${n}%`,background:r}})}),e.amount?(0,W.jsx)(`span`,{className:`num col-span-2 truncate text-right font-medium`,children:T(e.amount.value,e.amount.unit,t)}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`num text-right font-medium`,children:n===null?`—`:`${Math.round(n)}%`}),(0,W.jsx)(`span`,{className:`truncate text-right text-[var(--text-secondary)]`,children:g(e.resetsAt,t)??`—`})]})]})}function ce({plan:e,showAccount:t}){let{t:n,locale:r}=i();return(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(F,{name:e.providerName,icon:e.providerIcon,size:16}),(0,W.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.providerName}),t&&(0,W.jsx)(`span`,{className:`truncate text-[12px] text-[var(--text-muted)]`,children:e.accountName})]}),e.rows.map((e,t)=>{let i=Q(e,n,r);return(0,W.jsxs)(`div`,{className:`grid grid-cols-[52px_1fr_48px_72px] items-center gap-2 pl-6 text-[12.5px]`,children:[(0,W.jsx)(`span`,{className:`truncate text-[var(--text-secondary)]`,title:i,children:i}),(0,W.jsx)($,{row:e,locale:r})]},`${e.kind}-${t}`)})]})}function le({data:e,disabled:t,onSwitch:n,plain:r}){let{t:a}=i(),o=e.clients.filter(e=>e.enabled);if(o.length===0)return null;let s=t=>e.providers.find(e=>e.id===t)?.name??a(`tray.unbound`);return(0,W.jsxs)(`section`,{className:c(`flex flex-col gap-1`,!r&&`border-t border-[var(--border)] pt-3`),children:[(0,W.jsx)(`div`,{className:`mb-0.5 text-[12px] text-[var(--text-secondary)]`,children:a(`tray.clients`)}),o.map(e=>(0,W.jsxs)(`button`,{type:`button`,disabled:t||!n,onClick:()=>n?.(e),"aria-label":a(`tray.switchProvider`,{client:e.name}),className:`-mx-2 flex h-8 cursor-default items-center gap-2 rounded-[8px] px-2 text-left transition-colors enabled:hover:bg-[var(--surface-muted)]`,children:[e.kind in N&&(0,W.jsx)(I,{kind:e.kind,size:16}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,W.jsx)(`span`,{className:`max-w-[45%] truncate text-[12px] text-[var(--text-secondary)]`,children:s(e.providerId)}),n&&(0,W.jsx)(B,{className:`size-3.5 shrink-0 text-[var(--text-muted)]`})]},e.kind))]})}export{K as t};
|
|
1
|
+
import{Fa as e,Pa as t,Ra as n,Y as r,ct as i,dt as a,ft as o,gt as s,ot as c,q as l,s as u,v as d,xt as f}from"./alert-BF0mCqUl.js";import{G as p,H as m,J as h,K as g,Q as _,U as v,V as y,W as b,X as x,Y as S,Z as C,_t as w,lt as T,q as E}from"./overlays-OPtjc9Yr.js";import{t as D}from"./arrow-up-right-6yJy6Xdl.js";import{t as O}from"./ellipsis-D10W7mYw.js";import{t as k}from"./rotate-ccw-DwTwYkU2.js";import{G as A,H as j,R as M,_ as N,m as P,x as F,y as I}from"./index-DL_p8MKk.js";var L={name:`arrow-down-right`,size:24,node:[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]};L.node;var R=f(L),z={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};z.node;var B=f(z),V={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};V.node;var H=f(V),U=n(e(),1),W=t(),G={green:`var(--success)`,orange:`var(--warning)`,red:`var(--danger)`},K=(0,U.forwardRef)(function({prefs:e,state:t,data:n,onCommand:r,onRefresh:l,onCopyAddress:d,onSwitchClient:f,preview:p,tab:m,onTabChange:h,className:g},_){let{t:v}=i(),[y,b]=(0,U.useState)(`overview`),x=t.activity!==null,S=t.running&&!x,C=e=>r?.(e),T=[`overview`];e.sections.quota&&(n.plans.length>0||n.hasSubscriptions)&&T.push(`quota`),e.sections.clients&&n.clients.some(e=>e.enabled)&&T.push(`clients`);let E=m??y,j=T.includes(E)?E:`overview`,M=e=>{b(e),h?.(e)},N=(t.running||x)&&T.length>1,P=n.settings?.gatewayBaseUrl.replace(/^https?:\/\//,``)??(t.port?`127.0.0.1:${t.port}`:``),F=t.activity?v(`tray.status.${t.activity}`):t.running?v(`tray.status.running`):v(`tray.status.stopped`);return(0,W.jsxs)(`div`,{ref:_,className:c(`chrome flex max-h-full flex-col overflow-hidden rounded-[14px] border border-[var(--border-strong)] bg-[var(--surface-raised)] text-[13px] text-[var(--foreground)]`,g),children:[(0,W.jsxs)(`header`,{"data-tray-part":`header`,className:`shrink-0 border-b border-[var(--border)] px-4 pt-3.5 pb-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(u,{tone:x?`orange`:t.running?`green`:`red`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[14px] font-semibold`,children:F}),(0,W.jsx)(q,{label:v(`tray.copyAddress`),onClick:d,disabled:!P,children:(0,W.jsx)(s,{className:`size-4`})}),(0,W.jsx)(q,{label:v(`tray.settings`),onClick:()=>C(`open-settings`),children:(0,W.jsx)(w,{className:`size-4`})}),(0,W.jsx)(q,{label:v(`tray.more`),onClick:()=>C(`menu`),children:(0,W.jsx)(O,{className:`size-4`})}),!p&&(0,W.jsx)(q,{label:v(`common.close`),onClick:()=>C(`hide`),children:(0,W.jsx)(a,{className:`size-4`})})]}),P&&(0,W.jsx)(`div`,{className:`selectable mt-0.5 truncate pl-4 font-mono text-[12px] text-[var(--text-secondary)]`,children:P}),(t.apiVersionMismatch||t.updateAvailable)&&(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 pl-4`,children:[t.apiVersionMismatch&&(0,W.jsxs)(J,{tone:`orange`,children:[(0,W.jsx)(o,{className:`size-3`}),v(`tray.mismatch`)]}),t.updateAvailable&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>C(`check-updates`),className:`cursor-default`,children:(0,W.jsx)(J,{tone:`accent`,children:v(`tray.update`)})})]})]}),(0,W.jsx)(`div`,{"data-tray-part":`tabs`,className:`shrink-0`,children:N&&(0,W.jsx)(ee,{tabs:T,active:j,onChange:M})}),(0,W.jsx)(`div`,{className:`scroll min-h-0 flex-1 overflow-y-auto`,children:(0,W.jsx)(`div`,{"data-tray-part":`body`,className:`flex flex-col gap-3 px-4 py-3.5`,children:!t.running&&!x?(0,W.jsx)(ne,{onStart:()=>C(`start`)}):(0,W.jsxs)(W.Fragment,{children:[j===`overview`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(te,{prefs:e,data:n,onViewQuota:()=>M(`quota`)}),(0,W.jsx)(ie,{prefs:e,data:n,onRefresh:l}),e.sections.quota&&(0,W.jsx)(oe,{data:n,onViewAll:()=>M(`quota`)})]}),j===`quota`&&(0,W.jsx)(se,{data:n,plain:!0}),j===`clients`&&(0,W.jsx)(le,{data:n,disabled:!S,onSwitch:f,plain:!0})]})})}),(0,W.jsxs)(`footer`,{"data-tray-part":`footer`,className:`flex shrink-0 items-center gap-1 border-t border-[var(--border)] px-3 py-2.5`,children:[t.running?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:v(`tray.restart`),onClick:()=>C(`restart`),disabled:x,children:(0,W.jsx)(k,{className:`size-4`})}),(0,W.jsx)(q,{label:v(`tray.stop`),onClick:()=>C(`stop`),disabled:x,children:(0,W.jsx)(A,{className:`size-4`})})]}):(0,W.jsx)(q,{label:v(`shell.startService`),onClick:()=>C(`start`),disabled:x,children:(0,W.jsx)(H,{className:`size-4`})}),(0,W.jsx)(`div`,{className:`flex-1`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>C(`quit`),className:`h-8 cursor-default rounded-[8px] px-2.5 text-[13px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-muted)] hover:text-[var(--foreground)]`,children:v(`tray.quit`)}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>C(`open`),className:`inline-flex h-8 cursor-default items-center gap-1.5 rounded-[8px] border border-[var(--border-strong)] px-3 text-[13px] font-medium transition-colors hover:bg-[var(--surface-muted)]`,children:[v(`tray.open`),(0,W.jsx)(D,{className:`size-3.5`})]})]})]})});function q({label:e,onClick:t,disabled:n,children:r}){return(0,W.jsx)(`button`,{type:`button`,title:e,"aria-label":e,disabled:n,onClick:t,className:`inline-flex size-8 shrink-0 cursor-default items-center justify-center rounded-[8px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-muted)] hover:text-[var(--foreground)] disabled:opacity-40 disabled:hover:bg-transparent`,children:r})}function J({tone:e,children:t,title:n}){let r={red:`var(--danger)`,orange:`var(--warning)`,accent:`var(--accent)`,neutral:`var(--text-secondary)`}[e];return(0,W.jsx)(`span`,{title:n,className:`inline-flex max-w-full items-center gap-1 rounded-[6px] border px-1.5 py-px text-[11.5px] leading-[18px] whitespace-nowrap`,style:{color:r,borderColor:`color-mix(in oklab, ${r} 45%, transparent)`,background:`color-mix(in oklab, ${r} 10%, transparent)`},children:t})}function ee({tabs:e,active:t,onChange:n}){let{t:r}=i(),a={overview:r(`tray.tab.overview`),quota:r(`tray.tab.quota`),clients:r(`tray.clients`)};return(0,W.jsx)(`div`,{role:`tablist`,className:`flex gap-1 px-3 pt-2.5`,children:e.map(e=>(0,W.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===t,onClick:()=>n(e),className:c(`h-7 cursor-default rounded-[7px] px-2.5 text-[12.5px] transition-colors`,e===t?`bg-[var(--surface-muted)] font-medium text-[var(--foreground)]`:`text-[var(--text-secondary)] hover:text-[var(--foreground)]`),children:a[e]},e))})}function Y({tone:e,onClick:t,children:n}){let r=e===`red`?`var(--danger)`:`var(--warning)`,i={color:r,borderColor:`color-mix(in oklab, ${r} 45%, transparent)`,background:`color-mix(in oklab, ${r} 10%, transparent)`},a=`flex w-full items-center gap-1.5 rounded-[8px] border px-2.5 py-1.5 text-left text-[12.5px]`,s=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(o,{className:`size-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n})]});return t?(0,W.jsxs)(`button`,{type:`button`,onClick:t,className:c(a,`cursor-default`),style:i,children:[s,(0,W.jsx)(j,{className:`size-3.5 shrink-0`})]}):(0,W.jsx)(`div`,{className:a,style:i,children:s})}function te({prefs:e,data:t,onViewQuota:n}){let{t:r,locale:a}=i(),o=t.summary,s=e.sections.overview&&o?m(o):0,c=e.sections.quota?E(t.plans):null,u=c&&c.row.remaining<30?c:null;return!o||s===0&&!u?null:(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s>0&&(0,W.jsx)(Y,{tone:`red`,children:r(`tray.alert.failures`,{count:s,share:l(s/o.requests)})}),u&&(0,W.jsx)(Y,{tone:u.row.remaining<10?`red`:`orange`,onClick:n,children:r(`tray.alert.quota`,{plan:u.plan.providerName,window:Q(u.row,r,a),remaining:`${Math.round(u.row.remaining)}%`})})]})}function ne({onStart:e}){let{t}=i();return(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-6 text-center`,children:[(0,W.jsx)(`div`,{className:`text-[13px] font-medium`,children:t(`tray.status.stopped`)}),(0,W.jsx)(`div`,{className:`max-w-[260px] text-[12px] text-[var(--text-secondary)]`,children:t(`tray.stoppedHint`)}),(0,W.jsxs)(`button`,{type:`button`,onClick:e,className:`mt-1 inline-flex h-8 cursor-default items-center gap-1.5 rounded-[8px] bg-[var(--accent)] px-3 text-[13px] font-medium text-[var(--on-accent)]`,children:[(0,W.jsx)(H,{className:`size-3.5`}),t(`shell.startService`)]})]})}function re(e=3e4){let[t,n]=(0,U.useState)(()=>Date.now());return(0,U.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function ie({prefs:e,data:t,onRefresh:n}){let{t:a,locale:o}=i(),s=re(),c=t.summary,u=e.sections,f=u.overview||u.cost,p=c?c.inputTokens+c.outputTokens:0,m=x(t.updatedAt,o,a(`tray.justNow`),s),h=u.topModel?S(t.top,p):null,g=u.cacheHitRate&&c?P(c.cacheReadTokens,c.inputTokens):null,b=u.compareYesterday&&c?y(p,_(t.daily,new Date(s))):null,C=u.topModel||u.cacheHitRate||u.compareYesterday;return!f&&!u.chart&&!C?null:(0,W.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[13px] text-[var(--text-secondary)]`,children:a(`tray.today`)}),(0,W.jsx)(`div`,{className:`flex-1`}),m&&(0,W.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:a(`tray.updated`,{time:m})}),(0,W.jsx)(q,{label:a(`common.refresh`),onClick:n,children:(0,W.jsx)(M,{className:`size-3.5`})})]}),c?(0,W.jsxs)(W.Fragment,{children:[f&&(0,W.jsxs)(`div`,{className:`grid auto-cols-fr grid-flow-col gap-px overflow-hidden rounded-[10px] bg-[var(--border)]`,children:[u.overview&&(0,W.jsx)(X,{label:a(`tray.requests`),value:r(c.requests,!0)}),u.overview&&(0,W.jsx)(X,{label:a(`tray.tokens`),value:r(p,!0)}),u.cost&&(0,W.jsx)(X,{label:a(`tray.cost`),value:v(c.costUsd)})]}),u.chart&&(0,W.jsx)(ae,{data:t,now:s}),C&&(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[h&&(0,W.jsxs)(Z,{label:a(`tray.topModel`),title:h.model,children:[(0,W.jsx)(`span`,{className:`truncate`,children:h.model}),(0,W.jsxs)(`span`,{className:`shrink-0`,children:[`· `,l(h.share)]})]}),u.cacheHitRate&&(0,W.jsx)(Z,{label:a(`tray.cacheHit`),children:(0,W.jsx)(`span`,{children:g==null?`—`:l(g)})}),u.compareYesterday&&(0,W.jsx)(Z,{label:a(`tray.vsYesterday`),children:b==null?(0,W.jsx)(`span`,{children:`—`}):(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[b>=0?(0,W.jsx)(D,{className:`size-3`}):(0,W.jsx)(R,{className:`size-3`}),l(Math.abs(b))]})})]})]}):t.error?(0,W.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:a(`tray.loadFailed`)}):(0,W.jsx)(d,{lines:2})]})}function X({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`min-w-0 bg-[var(--surface-muted)] px-3 py-2.5`,children:[(0,W.jsx)(`div`,{className:`truncate text-[12px] text-[var(--text-secondary)]`,children:e}),(0,W.jsx)(`div`,{className:`num mt-0.5 truncate text-[20px] leading-tight font-semibold`,title:t,children:t})]})}function Z({label:e,title:t,children:n}){return(0,W.jsxs)(`span`,{title:t,className:`inline-flex max-w-full min-w-0 items-center gap-1.5 rounded-[7px] border border-[var(--border)] px-2 py-0.5 text-[12px]`,children:[(0,W.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e}),(0,W.jsx)(`span`,{className:`flex min-w-0 items-center gap-1 font-medium`,children:n})]})}function ae({data:e,now:t}){let{t:n}=i(),r=b(e.hourly,new Date(t)),a=Math.max(1,...r.map(e=>e.value)),o=new Date(t).getHours();return(0,W.jsx)(`div`,{role:`img`,"aria-label":n(`tray.chartLabel`),className:`flex h-16 items-end gap-[3px]`,children:r.map((e,t)=>{let r=e.value>0?Math.max(4,Math.round(e.value/a*64)):2;return(0,W.jsx)(`span`,{title:n(`tray.hourBar`,{hour:`${String(t).padStart(2,`0`)}:00`,count:e.value}),className:`flex-1 rounded-[2px]`,style:{height:r,background:t===o?`var(--accent)`:e.value>0?`color-mix(in oklab, var(--foreground) 32%, transparent)`:`var(--border)`,opacity:t>o?.5:1}},e.bucket)})})}function oe({data:e,onViewAll:t}){let{t:n,locale:r}=i();if(e.plans.length===0)return e.hasSubscriptions?(0,W.jsx)(`div`,{className:`border-t border-[var(--border)] pt-3 text-[12px] text-[var(--text-muted)]`,children:n(`tray.quotaPending`)}):null;let a=h(e.plans,3),o=e.plans.reduce((e,t)=>e+t.rows.length,0);return(0,W.jsxs)(`section`,{className:`flex flex-col gap-2 border-t border-[var(--border)] pt-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center text-[12px] text-[var(--text-secondary)]`,children:[(0,W.jsx)(`span`,{className:`flex-1`,children:n(`tray.quotaTightest`)}),o>a.length&&(0,W.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex cursor-default items-center gap-0.5 hover:text-[var(--foreground)]`,children:[n(`tray.viewAll`),(0,W.jsx)(j,{className:`size-3`})]})]}),a.map(({plan:e,row:t},i)=>(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_64px_40px_60px] items-center gap-2 text-[12.5px]`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(F,{name:e.providerName,icon:e.providerIcon,size:14}),(0,W.jsx)(`span`,{className:`truncate font-medium`,children:e.providerName}),(0,W.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:Q(t,n,r)})]}),(0,W.jsx)($,{row:t,locale:r})]},`${e.accountId}-${t.kind}-${i}`))]})}function se({data:e,plain:t}){let{t:n}=i();if(e.plans.length===0&&!e.hasSubscriptions)return null;let r=new Map;for(let t of e.plans)r.set(t.providerId,(r.get(t.providerId)??0)+1);return(0,W.jsxs)(`section`,{className:c(`flex flex-col gap-2`,!t&&`border-t border-[var(--border)] pt-3`),children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-[1fr_48px_72px] items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,W.jsx)(`span`,{children:n(`tray.quota`)}),(0,W.jsx)(`span`,{className:`text-right`,children:n(`tray.quotaRemaining`)}),(0,W.jsx)(`span`,{className:`text-right`,children:n(`tray.quotaReset`)})]}),e.plans.length===0?(0,W.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`tray.quotaPending`)}):e.plans.map(e=>(0,W.jsx)(ce,{plan:e,showAccount:(r.get(e.providerId)??0)>1},e.accountId))]})}function Q(e,t,n){return e.kind===`balance`?e.label??t(`tray.quotaBalance`):e.kind===`credits`||e.windowMinutes==null?t(`tray.quotaCredits`):C(e.windowMinutes,n)}function $({row:e,locale:t}){let n=e.remaining,r=n===null?void 0:G[p(n)];return(0,W.jsxs)(W.Fragment,{children:[n===null?(0,W.jsx)(`span`,{}):(0,W.jsx)(`span`,{className:`h-1.5 overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,W.jsx)(`span`,{className:`block h-full rounded-full`,style:{width:`${n}%`,background:r}})}),e.amount?(0,W.jsx)(`span`,{className:`num col-span-2 truncate text-right font-medium`,children:T(e.amount.value,e.amount.unit,t)}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`num text-right font-medium`,children:n===null?`—`:`${Math.round(n)}%`}),(0,W.jsx)(`span`,{className:`truncate text-right text-[var(--text-secondary)]`,children:g(e.resetsAt,t)??`—`})]})]})}function ce({plan:e,showAccount:t}){let{t:n,locale:r}=i();return(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(F,{name:e.providerName,icon:e.providerIcon,size:16}),(0,W.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.providerName}),t&&(0,W.jsx)(`span`,{className:`truncate text-[12px] text-[var(--text-muted)]`,children:e.accountName})]}),e.rows.map((e,t)=>{let i=Q(e,n,r);return(0,W.jsxs)(`div`,{className:`grid grid-cols-[52px_1fr_48px_72px] items-center gap-2 pl-6 text-[12.5px]`,children:[(0,W.jsx)(`span`,{className:`truncate text-[var(--text-secondary)]`,title:i,children:i}),(0,W.jsx)($,{row:e,locale:r})]},`${e.kind}-${t}`)})]})}function le({data:e,disabled:t,onSwitch:n,plain:r}){let{t:a}=i(),o=e.clients.filter(e=>e.enabled);if(o.length===0)return null;let s=t=>e.providers.find(e=>e.id===t)?.name??a(`tray.unbound`);return(0,W.jsxs)(`section`,{className:c(`flex flex-col gap-1`,!r&&`border-t border-[var(--border)] pt-3`),children:[(0,W.jsx)(`div`,{className:`mb-0.5 text-[12px] text-[var(--text-secondary)]`,children:a(`tray.clients`)}),o.map(e=>(0,W.jsxs)(`button`,{type:`button`,disabled:t||!n,onClick:()=>n?.(e),"aria-label":a(`tray.switchProvider`,{client:e.name}),className:`-mx-2 flex h-8 cursor-default items-center gap-2 rounded-[8px] px-2 text-left transition-colors enabled:hover:bg-[var(--surface-muted)]`,children:[e.kind in N&&(0,W.jsx)(I,{kind:e.kind,size:16}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,W.jsx)(`span`,{className:`max-w-[45%] truncate text-[12px] text-[var(--text-secondary)]`,children:s(e.providerId)}),n&&(0,W.jsx)(B,{className:`size-3.5 shrink-0 text-[var(--text-muted)]`})]},e.kind))]})}export{K as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as e,Fa as t,Hi as n,Ki as r,Pa as i,Ra as a,Ui as o,Vi as s,Wi as c,qi as l,vt as ee}from"./alert-BF0mCqUl.js";import{B as te}from"./index-
|
|
1
|
+
import{E as e,Fa as t,Hi as n,Ki as r,Pa as i,Ra as a,Ui as o,Vi as s,Wi as c,qi as l,vt as ee}from"./alert-BF0mCqUl.js";import{B as te}from"./index-DL_p8MKk.js";var u=a(t(),1),d={root:`_root_8729c_1`,surface:`_surface_8729c_16`,trigger:`_trigger_8729c_39`,face:`_face_8729c_41`,icon:`_icon_8729c_64`,prompt:`_prompt_8729c_68`,secondary:`_secondary_8729c_70`,primary:`_primary_8729c_71`,status:`_status_8729c_90`,statusText:`_statusText_8729c_95`,check:`_check_8729c_97`,checkDisc:`_checkDisc_8729c_98`,checkTick:`_checkTick_8729c_99`,spinner:`_spinner_8729c_100`,spin:`_spin_8729c_100`,srOnly:`_srOnly_8729c_103`},f=i(),p=12,{blur:m}=e,h=[...e.ease.enter],g=[...e.ease.standard],_=(e,t)=>{let n=2*Math.PI/(e*1.2);return{type:`spring`,stiffness:n*n,damping:2*(1-t)*n,mass:1}},v=_(.44,.18),ne=_(.34,0),y=_(.36,.06),b=()=>()=>{};function re(){let e=(0,u.useSyncExternalStore)(b,()=>!0,()=>!1);return!!o()&&e}var x={hidden:e=>({opacity:0,x:e*p,filter:`blur(${m.soft}px)`}),shown:{opacity:1,x:0,filter:`blur(0px)`,transition:{x:y,opacity:{duration:.2,ease:h,delay:.04},filter:{duration:.22,ease:h,delay:.04}}},gone:e=>({opacity:0,x:e*-12*.6,filter:`blur(${m.soft}px)`,transition:{x:y,opacity:{duration:.12,ease:g},filter:{duration:.12,ease:g}}})},S={hidden:{opacity:0},shown:{opacity:1,transition:{duration:.14}},gone:{opacity:0,transition:{duration:.1}}};function ie({id:e,direction:t,reduced:n,onSize:r,children:i,labelledBy:a}){let o=(0,u.useRef)(null),c=l();return(0,u.useLayoutEffect)(()=>{let t=o.current;if(!t||!c)return;let n=()=>{let n=t.style.flex;t.style.flex=`none`;let i=t.offsetWidth;t.style.flex=n,r(e,i)};if(n(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(n);return i.observe(t),()=>i.disconnect()},[e,r,c]),(0,f.jsx)(s.div,{ref:o,className:d.face,"data-face":e,custom:t,role:a?`group`:void 0,"aria-labelledby":a,variants:n?S:x,initial:`hidden`,animate:`shown`,exit:`gone`,inert:!c||void 0,children:i})}function ae({reduced:e}){return(0,f.jsxs)(`svg`,{className:d.check,viewBox:`0 0 18 18`,fill:`none`,"aria-hidden":`true`,children:[(0,f.jsx)(s.circle,{className:d.checkDisc,cx:`9`,cy:`9`,r:`8`,style:{transformOrigin:`9px 9px`},initial:!e&&{scale:.4,opacity:0},animate:{scale:1,opacity:1},transition:{scale:_(.34,.3),opacity:{duration:.12}}}),(0,f.jsx)(s.path,{className:d.checkTick,d:`M5.6 9.3 7.8 11.4 12.4 6.7`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,initial:!e&&{pathLength:0},animate:{pathLength:1},transition:{duration:.28,ease:h,delay:.12}})]})}function C({label:e,icon:t,prompt:i,confirmLabel:a=`Delete`,cancelLabel:o=`Cancel`,pendingLabel:l=`Deleting`,doneLabel:p=`Deleted`,errorLabel:m=`Couldn’t finish`,retryLabel:h=`Retry`,undoLabel:g=`Undo`,undoingLabel:_=`Restoring`,tone:y=`danger`,onConfirm:b,onUndo:x,onCancel:S,state:C,defaultState:oe=`idle`,onStateChange:w,confirmTimeout:se=6e3,resultTimeout:ce=5e3,cancelOnOutsidePress:T=!0,disabled:E=!1,className:D,ref:O}){let k=re(),A=`${(0,u.useId)()}-prompt`,j=(0,u.useRef)(null);(0,u.useImperativeHandle)(O,()=>j.current,[]);let[le,ue]=(0,u.useState)(oe),M=C??le,[N,de]=(0,u.useState)(1),[P,fe]=(0,u.useState)(`confirm`),[pe,F]=(0,u.useState)(``),I=(0,u.useRef)({state:M,onStateChange:w,controlled:C!==void 0});(0,u.useLayoutEffect)(()=>{I.current={state:M,onStateChange:w,controlled:C!==void 0}});let L=(0,u.useRef)(!1),R=(0,u.useRef)(0),z=(0,u.useCallback)(e=>{if(e===I.current.state)return;let t=j.current;L.current=!!t&&(t.contains(document.activeElement)||document.activeElement===document.body),de(e===`idle`?-1:1),I.current.controlled||ue(e),I.current.state=e,I.current.onStateChange?.(e)},[]),B=(0,u.useCallback)(()=>{R.current++,z(`idle`)},[z]),V=(0,u.useCallback)(async e=>{let t=e===`confirm`?b:x,n=++R.current;fe(e);let r;try{r=t?.()}catch{z(`error`),F(m);return}if(r&&typeof r.then==`function`){z(`pending`),F(e===`confirm`?l:_);try{await r}catch{if(n!==R.current)return;z(`error`),F(m);return}if(n!==R.current)return}if(e===`undo`){z(`idle`),F(`Undone`);return}z(`done`),F(x?`${p}. ${g} is available.`:p)},[p,m,z,b,x,l,g,_]),H=(0,u.useCallback)(()=>{S?.(),B(),F(`Cancelled`)},[S,B]),U=(0,u.useRef)(()=>{});(0,u.useLayoutEffect)(()=>{U.current=()=>{I.current.state===`confirming`?H():B()}});let W=c(`auto`),G=(0,u.useRef)(0),K=(0,u.useRef)(0),q=(0,u.useCallback)((e,t)=>{if(e!==I.current.state||Math.abs(t-G.current)<.5)return;let r=G.current;if(G.current=t,!r||k){W.jump(`auto`);return}W.get()===`auto`&&W.jump(r);let i=++K.current;n(W,t,t>r?v:ne).then(()=>{i===K.current&&W.jump(`auto`)})},[k,W]),J=c(1),Y=(0,u.useRef)(null),X=(0,u.useRef)({hover:!1,hidden:!1}),Z=M===`confirming`?se:M===`done`||M===`error`?ce:0,Q=(0,u.useCallback)(()=>{let e=Y.current;e&&(X.current.hover||X.current.hidden?e.pause():e.play())},[]);(0,u.useEffect)(()=>{if(!Z)return;J.jump(1);let e=n(J,0,{duration:Z/1e3,ease:`linear`});return Y.current=e,e.then(()=>{Y.current===e&&(Y.current=null,U.current())}),Q(),()=>{Y.current===e&&(Y.current=null),e.stop()}},[J,M,Q,Z]),(0,u.useEffect)(()=>{let e=()=>{X.current.hidden=document.hidden,Q()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[Q]),(0,u.useEffect)(()=>{if(M!==`confirming`||!T)return;let e=e=>{j.current?.contains(e.target)||H()};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[H,T,M]),(0,u.useLayoutEffect)(()=>{if(!L.current)return;L.current=!1;let e=j.current;e&&(e.querySelector(`[data-face="${M}"]`)?.querySelector(`[data-autofocus]:not(:disabled)`)??e).focus({preventScroll:!0})},[M]);let me=e=>{e.key===`Escape`&&(M===`confirming`?(e.preventDefault(),e.stopPropagation(),H()):(M===`done`||M===`error`)&&(e.preventDefault(),e.stopPropagation(),B()))},$=i??(0,f.jsxs)(f.Fragment,{children:[e,`?`]}),he=(()=>{switch(M){case`confirming`:return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`span`,{id:A,className:d.prompt,children:$}),(0,f.jsx)(`button`,{type:`button`,className:d.secondary,"data-autofocus":!0,onClick:H,children:o}),(0,f.jsx)(`button`,{type:`button`,className:d.primary,onClick:()=>void V(`confirm`),children:a})]});case`pending`:return(0,f.jsxs)(`span`,{className:d.status,children:[(0,f.jsx)(te,{className:d.spinner,size:16,strokeWidth:1.75,"aria-hidden":`true`}),(0,f.jsx)(`span`,{children:P===`undo`?_:l})]});case`done`:return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`span`,{className:d.status,"data-tone":`success`,children:[(0,f.jsx)(ae,{reduced:k}),(0,f.jsx)(`span`,{className:d.statusText,children:p})]}),x&&(0,f.jsx)(`button`,{type:`button`,className:d.secondary,"data-autofocus":!0,onClick:()=>void V(`undo`),children:g})]});case`error`:return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`span`,{className:d.status,"data-tone":`danger`,children:[(0,f.jsx)(ee,{size:16,strokeWidth:1.75,"aria-hidden":`true`}),(0,f.jsx)(`span`,{className:d.statusText,children:m})]}),(0,f.jsx)(`button`,{type:`button`,className:d.secondary,"data-autofocus":!0,onClick:()=>void V(P),children:h})]});default:return(0,f.jsxs)(`button`,{type:`button`,className:d.trigger,"data-autofocus":!0,disabled:E,onClick:()=>{F(typeof $==`string`?$:``),z(`confirming`)},children:[t&&(0,f.jsx)(`span`,{className:d.icon,"aria-hidden":`true`,children:t}),(0,f.jsx)(`span`,{children:e})]})}})();return(0,f.jsxs)(`div`,{ref:j,className:[d.root,D].filter(Boolean).join(` `),"data-state":M,"data-tone":y,"data-disabled":E||void 0,tabIndex:-1,onKeyDown:me,"aria-busy":M===`pending`||void 0,onPointerEnter:()=>{X.current.hover=!0,Q()},onPointerLeave:()=>{X.current.hover=!1,Q()},onPointerCancel:()=>{X.current.hover=!1,Q()},children:[(0,f.jsx)(s.div,{className:d.surface,style:{width:W},children:(0,f.jsx)(r,{initial:!1,custom:N,children:(0,f.jsx)(ie,{id:M,direction:N,reduced:k,onSize:q,labelledBy:M===`confirming`?A:void 0,children:he},M)})}),(0,f.jsx)(`span`,{className:d.srOnly,role:`status`,"aria-live":`polite`,children:pe})]})}export{C as t};
|