@kaitranntt/ccs 7.54.0-dev.8 → 7.54.0-dev.9
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/dist/shared/provider-preset-catalog.d.ts.map +1 -1
- package/dist/shared/provider-preset-catalog.js +1 -0
- package/dist/shared/provider-preset-catalog.js.map +1 -1
- package/dist/ui/assets/{accounts-DwcZCyS5.js → accounts-v8ElDmpv.js} +1 -1
- package/dist/ui/assets/{alert-dialog-B2hyK6AP.js → alert-dialog-L5Ct0Tm9.js} +1 -1
- package/dist/ui/assets/{api-qU_bc9BM.js → api-C5CuNrT6.js} +1 -1
- package/dist/ui/assets/{auth-section-BPkTuOTf.js → auth-section-P8GsBk1u.js} +1 -1
- package/dist/ui/assets/{backups-section-CeYlXizh.js → backups-section-gBIJ2rQw.js} +1 -1
- package/dist/ui/assets/{checkbox-CpTns8kD.js → checkbox-DQ1oAx_4.js} +1 -1
- package/dist/ui/assets/{claude-extension-DON0t7Fm.js → claude-extension-CjEyjaGL.js} +1 -1
- package/dist/ui/assets/{cliproxy-CVg2BCbP.js → cliproxy-C0dWlSJs.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-7zmRoGkw.js → cliproxy-control-panel-CdCrzgLe.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-1fHP9ADM.js → confirm-dialog-DaydoeD7.js} +1 -1
- package/dist/ui/assets/{copilot-CgZIsLcU.js → copilot-SA3U22Y9.js} +1 -1
- package/dist/ui/assets/{cursor-3B9jIxVF.js → cursor-BfkF3VwC.js} +1 -1
- package/dist/ui/assets/{droid-3UY521J3.js → droid-BfSJyZXD.js} +1 -1
- package/dist/ui/assets/{globalenv-section-DHDrZkJ1.js → globalenv-section-rg8Ctc2R.js} +1 -1
- package/dist/ui/assets/{health-C2THW9ym.js → health-Cii2iTlp.js} +1 -1
- package/dist/ui/assets/{index-MPOI0EJ5.js → index-B4Qc134R.js} +1 -1
- package/dist/ui/assets/{index-C7jJyg77.js → index-CBleAyoZ.js} +1 -1
- package/dist/ui/assets/index-ClEn7Y7g.css +1 -0
- package/dist/ui/assets/{index-BnHfOIfl.js → index-D1CmdSLO.js} +1 -1
- package/dist/ui/assets/{index-DPWpIhxa.js → index-Gpb2Emvl.js} +1 -1
- package/dist/ui/assets/index-og5NMtJP.js +47 -0
- package/dist/ui/assets/providers/llama-cpp.svg +5 -0
- package/dist/ui/assets/{proxy-status-widget-BZfWhofZ.js → proxy-status-widget-CZnGc4zY.js} +1 -1
- package/dist/ui/assets/{searchable-select-CzYKeWKI.js → searchable-select-BHhY-dTx.js} +1 -1
- package/dist/ui/assets/{separator-dTvIQkrw.js → separator-7ggevEK6.js} +1 -1
- package/dist/ui/assets/{shared-Ccidnid7.js → shared-CoiUG_Qa.js} +1 -1
- package/dist/ui/assets/{switch-Bsk1Z1Fy.js → switch-3-7lTxFj.js} +1 -1
- package/dist/ui/assets/{updates-DmT2FBqm.js → updates-rQ3GVJIq.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +1 -1
- package/dist/ui/assets/index-Dz76Rk36.js +0 -47
- package/dist/ui/assets/index-OMV20t-1.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{bg as Oe,bh as Ve,Y as L,a as ae,I as B,r as He,s as Ue,t as ze,v as We,w as ue,d as H,bi as Ye,bj as Ge,bk as Xe,b1 as se,b3 as te,n as qe}from"./index-Dz76Rk36.js";import{S as D}from"./switch-Bsk1Z1Fy.js";import{C as U}from"./default-ports-1QQSffYX.js";import{aV as he,R as re,g as Je,v as fe,W as Qe,x as Ze,aW as es,aX as ss,T as ye,at as ts,o as rs,aY as as}from"./icons-DtwH984l.js";import{R as V,P as os}from"./proxy-status-widget-BZfWhofZ.js";import{t as T}from"./notifications-B2HqRBj7.js";import"./tanstack-B8i0evp-.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-B2hyK6AP.js";function ns(){const{state:s}=Oe(),t=Ve(),[g,o]=n.useState(null),[u,b]=n.useState(null),[y,j]=n.useState(null),[p,C]=n.useState(null),[S,P]=n.useState(null),w=n.useCallback(async()=>{try{t.setProxyLoading(!0),t.setProxyError(null);const d=await L.cliproxyServer.get();t.setProxyConfig(d)}catch(d){t.setProxyError(d.message)}finally{t.setProxyLoading(!1)}},[t]),A=n.useCallback(async d=>{const x=s.proxyConfig;if(!x)return;const h={remote:{...x.remote,...d.remote},fallback:{...x.fallback,...d.fallback},local:{...x.local,...d.local}};t.setProxyConfig(h),t.setProxyTestResult(null);try{t.setProxySaving(!0),t.setProxyError(null);const a=await L.cliproxyServer.update(d);t.setProxyConfig(a),t.setProxySuccess(!0),setTimeout(()=>t.setProxySuccess(!1),1500)}catch(a){t.setProxyConfig(x),t.setProxyError(a.message)}finally{t.setProxySaving(!1)}},[s.proxyConfig,t]),E=n.useCallback(async d=>{const{host:x,port:h,protocol:a,authToken:c}=d;if(!x){t.setProxyError("Host is required");return}try{t.setProxyTesting(!0),t.setProxyError(null),t.setProxyTestResult(null);const k=h?parseInt(h,10):void 0,l=await L.cliproxyServer.test({host:x,port:k||void 0,protocol:a,authToken:c||void 0});t.setProxyTestResult(l)}catch(k){t.setProxyError(k.message)}finally{t.setProxyTesting(!1)}},[t]);return{config:s.proxyConfig,loading:s.proxyLoading,saving:s.proxySaving,error:s.proxyError,success:s.proxySuccess,testResult:s.proxyTestResult,testing:s.proxyTesting,editedHost:g,setEditedHost:o,editedPort:u,setEditedPort:b,editedAuthToken:y,setEditedAuthToken:j,editedManagementKey:p,setEditedManagementKey:C,editedLocalPort:S,setEditedLocalPort:P,fetchConfig:w,saveConfig:A,testConnection:E}}function is({config:s,saving:t,displayLocalPort:g,setEditedLocalPort:o,onSaveLocalPort:u,onSaveConfig:b}){const{t:y}=ae(),j=s.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:y("settingsProxy.localProxy")}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:y("settingsProxy.port")}),e.jsx(B,{type:"text",inputMode:"numeric",value:g,onChange:p=>o(p.target.value.replace(/\D/g,"")),onBlur:u,placeholder:`${U}`,className:"font-mono max-w-32",disabled:t})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:y("settingsProxy.autoStart")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:y("settingsProxy.localAutoStartDesc")})]}),e.jsx(D,{checked:j.auto_start??!0,onCheckedChange:p=>b({local:{...j,auto_start:p}}),disabled:t})]})]})]})}function ls({config:s,saving:t,testing:g,testResult:o,displayHost:u,displayPort:b,displayAuthToken:y,displayManagementKey:j,setEditedHost:p,setEditedPort:C,setEditedAuthToken:S,setEditedManagementKey:P,onSaveHost:w,onSavePort:A,onSaveAuthToken:E,onSaveManagementKey:d,onSaveConfig:x,onTestConnection:h}){const{t:a}=ae(),c=s.remote,k=l=>l==="https"?443:U;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(he,{className:"w-4 h-4"}),a("settingsProxy.remoteConfigTitle")]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.host")}),e.jsx(B,{value:u,onChange:l=>p(l.target.value),onBlur:w,placeholder:a("settingsProxy.hostPlaceholder"),className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:[a("settingsProxy.port")," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(",a("settingsProxy.defaultPort",{value:k(s.remote.protocol||"http")}),")"]})]}),e.jsx(B,{type:"text",inputMode:"numeric",value:b,onChange:l=>C(l.target.value.replace(/\D/g,"")),onBlur:A,placeholder:a("settingsProxy.portPlaceholder",{value:k(s.remote.protocol||"http")}),className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.protocol")}),e.jsxs(He,{value:s.remote.protocol||"http",onValueChange:l=>x({remote:{...c,protocol:l}}),disabled:t,children:[e.jsx(Ue,{children:e.jsx(ze,{})}),e.jsxs(We,{children:[e.jsx(ue,{value:"http",children:a("settingsProxy.http")}),e.jsx(ue,{value:"https",children:a("settingsProxy.https")})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.apiKeyOptional")}),e.jsx(B,{type:"password",value:y,onChange:l=>S(l.target.value),onBlur:E,placeholder:a("settingsProxy.apiKeyPlaceholder"),className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settingsProxy.apiKeyDesc")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.managementKeyOptional")}),e.jsx(B,{type:"password",value:j,onChange:l=>P(l.target.value),onBlur:d,placeholder:a("settingsProxy.managementKeyPlaceholder"),className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settingsProxy.managementKeyDesc")})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(H,{onClick:h,disabled:g||!u,variant:"outline",className:"w-full",children:g?e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-4 h-4 mr-2 animate-spin"}),a("settingsProxy.testing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"w-4 h-4 mr-2"}),a("settingsProxy.testConnection")]})}),o&&e.jsx("div",{className:`p-3 rounded-md ${o.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:o.reachable?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsx("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:a("settingsProxy.connectedLatency",{value:o.latencyMs})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:o.error||a("settingsProxy.connectionFailed")})]})})})]})]})}const pe="ccs_debug_mode",cs=["kiro","ghcp"];function ds(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function Cs(){const{t:s}=ae(),{config:t,loading:g,saving:o,error:u,success:b,testResult:y,testing:j,editedHost:p,setEditedHost:C,editedPort:S,setEditedPort:P,editedAuthToken:w,setEditedAuthToken:A,editedManagementKey:E,setEditedManagementKey:d,editedLocalPort:x,setEditedLocalPort:h,fetchConfig:a,saveConfig:c,testConnection:k}=ns(),{fetchRawConfig:l}=Ye(),[_,be]=n.useState(()=>{try{return localStorage.getItem(pe)==="true"}catch{return!1}}),[je,z]=n.useState(!1),[Pe,oe]=n.useState(!0),[f,ne]=n.useState(!1),[ke,R]=n.useState(!1),[ie,I]=n.useState(""),K=n.useRef(!1),W=ds(ie)===V,ve=r=>{be(r);try{localStorage.setItem(pe,String(r))}catch{}},Y=n.useCallback(async()=>{try{oe(!0);const r=await fetch("/api/settings/auth/antigravity-risk");if(!r.ok)throw new Error(s("settingsProxy.failedLoadAgyMode"));const i=await r.json();z(i.antigravityAckBypass===!0)}catch(r){T.error(r instanceof Error?r.message:s("settingsProxy.failedLoadAgyMode")),z(!1)}finally{oe(!1)}},[s]),$=n.useCallback(async r=>{if(!(K.current||f||o))try{K.current=!0,ne(!0);const i=await fetch("/api/settings/auth/antigravity-risk",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravityAckBypass:r})}),O=await i.json();if(!i.ok)throw new Error(O.error||s("settingsProxy.failedUpdateAgyMode"));const Fe=O.antigravityAckBypass===!0,me=await fetch("/api/settings/auth/antigravity-risk",{cache:"no-store"});if(!me.ok)throw new Error(s("settingsProxy.failedVerifyAgyMode"));const ge=(await me.json()).antigravityAckBypass===!0;if(ge!==r)throw new Error(s("settingsProxy.notPersistedAgyMode"));z(ge&&Fe),R(!1),I(""),T.success(s(r?"settingsProxy.agyModeEnabled":"settingsProxy.agyModeDisabled")),await l()}catch(i){T.error(i instanceof Error?i.message:s("settingsProxy.failedUpdateAgyMode"))}finally{K.current=!1,ne(!1)}},[f,l,o,s]),Ne=n.useCallback(r=>{if(!(K.current||f||o)){if(r){R(!0);return}R(!1),I(""),$(!1)}},[f,$,o]),Ce=n.useCallback(()=>{if(!W){T.error(s("settingsProxy.typePhraseToContinue",{value:V}));return}$(!0)},[W,$,s]),[v,G]=n.useState("plus"),[Se,we]=n.useState(!1),X=Ge(),{data:Ae}=Xe(),le=Ae?.running??!1,q=n.useCallback(async()=>{try{const r=await L.cliproxyServer.getBackend();G(r.backend)}catch(r){console.error("[Proxy] Failed to fetch backend:",r)}},[]),J=n.useCallback(async()=>{try{const i=(await L.cliproxy.list()).variants.some(O=>cs.includes(O.provider));we(i)}catch(r){console.error("[Proxy] Failed to check variants:",r)}},[]),ce=r=>{const i=v;G(r),X.mutate({backend:r},{onError:()=>{G(i)}})};if(n.useEffect(()=>{if(_&&t){const r={...t,remote:{...t.remote,auth_token:t.remote.auth_token?"[REDACTED]":void 0,management_key:t.remote.management_key?"[REDACTED]":void 0}};console.log("[CCS Debug] Debug mode enabled - proxy config:",r)}},[_,t]),n.useEffect(()=>{a(),Y(),l(),q(),J()},[a,Y,l,q,J]),g||!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(re,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})});const m=t.remote.enabled??!1,F=!m&&le,N=t.remote,M=t.fallback,Ee=t.remote.host??"",Te=t.remote.port!==void 0?t.remote.port.toString():"",Be=t.remote.auth_token??"",Me=t.remote.management_key??"",De=(t.local.port??U).toString(),Q=p??Ee,Z=S??Te,ee=w??Be,de=E??Me,xe=x??De,Le=()=>{const r=p??Q;r!==t.remote.host&&c({remote:{...N,host:r}}),C(null)},_e=()=>{const r=(S??Z).trim();if(r===""){t.remote.port!==void 0&&c({remote:{...N,port:void 0}}),P(null);return}const i=Number(r);if(!Number.isInteger(i)||i<1||i>65535){T.error(s("settingsProxy.invalidPortOrEmpty")),P(null);return}i!==t.remote.port&&c({remote:{...N,port:i}}),P(null)},Re=()=>{const r=w??ee;r!==t.remote.auth_token&&c({remote:{...N,auth_token:r}}),A(null)},Ie=()=>{const r=E??de;r!==t.remote.management_key&&c({remote:{...N,management_key:r||void 0}}),d(null)},Ke=()=>{const r=(x??xe).trim(),i=r===""?U:Number(r);if(!Number.isInteger(i)||i<1||i>65535){T.error(s("settingsProxy.invalidLocalPort")),h(null);return}i!==t.local.port&&c({local:{...t.local,port:i}}),h(null)},$e=()=>{k({host:Q,port:Z,protocol:t.remote.protocol||"http",authToken:ee})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${u||b?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(se,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Ze,{className:"h-4 w-4"}),e.jsx(te,{children:u})]}),b&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(fe,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(qe,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsProxy.description",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})}),!m&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.instanceStatus")}),e.jsx(os,{})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.connectionMode")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>c({remote:{...N,enabled:!1}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(es,{className:`w-5 h-5 ${m?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:s("settingsProxy.local")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.localDesc",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})})]}),e.jsxs("button",{onClick:()=>c({remote:{...N,enabled:!0}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(he,{className:`w-5 h-5 ${m?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:s("settingsProxy.remote")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.remoteDesc",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),s("settingsProxy.backendBinary")]}),!m&&le&&e.jsxs(se,{className:"py-2 border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 [&>svg]:top-2.5",children:[e.jsx(ye,{className:"h-4 w-4 text-amber-600"}),e.jsx(te,{className:"text-amber-700 dark:text-amber-400",children:s("settingsProxy.stopProxyToSwitch")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>ce("plus"),disabled:X.isPending||F,className:`p-4 rounded-lg border-2 text-left transition-all ${v==="plus"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${F?"opacity-60 cursor-not-allowed":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"font-medium",children:s("settingsProxy.backendPlusApi")}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400",children:s("settingsProxy.default")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.plusDesc")})]}),e.jsxs("button",{onClick:()=>ce("original"),disabled:X.isPending||F,className:`p-4 rounded-lg border-2 text-left transition-all ${v==="original"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${F?"opacity-60 cursor-not-allowed":""}`,children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("span",{className:"font-medium",children:s("settingsProxy.backendApi")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.originalDesc")})]})]}),v==="original"&&Se&&e.jsxs(se,{variant:"destructive",className:"py-2",children:[e.jsx(ye,{className:"h-4 w-4"}),e.jsx(te,{children:s("settingsProxy.variantsIncompatible")})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(ts,{className:"w-4 h-4 text-amber-700 dark:text-amber-300"}),s("settingsProxy.safety")]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-amber-400/35 bg-amber-50/70 p-4 dark:border-amber-800/60 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.agyModeTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.agyModeDesc")})]}),e.jsx(D,{"aria-labelledby":"agy-power-user-mode-label","aria-describedby":"agy-power-user-mode-description",checked:je,disabled:Pe||f||o,onCheckedChange:Ne})]}),e.jsx("p",{id:"agy-power-user-mode-description",className:"text-xs text-amber-800/90 dark:text-amber-200/90",children:s("settingsProxy.agyWarning")}),ke&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/40 bg-rose-500/[0.08] p-3.5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs font-semibold tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.finalConfirm")}),e.jsx("p",{className:"text-xs leading-relaxed text-rose-800/95 dark:text-rose-200/90",children:s("settingsProxy.finalConfirmDesc")})]}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border border-rose-400/30 bg-rose-500/10 p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.step1")}),e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"mt-1 inline-flex items-center gap-1.5 text-xs font-medium text-rose-800 underline decoration-rose-500/60 underline-offset-2 transition-colors hover:text-rose-700 dark:text-rose-200",children:[s("settingsProxy.readIssue"),e.jsx(rs,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"rounded-md border border-rose-400/30 bg-rose-500/10 p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.step2")}),e.jsxs("p",{className:"mt-1 text-xs text-rose-800/95 dark:text-rose-200/90",children:[s("settingsProxy.typePrefix")," ",e.jsx("code",{className:"rounded bg-background/80 px-1 py-0.5 font-mono",children:V})," ",s("settingsProxy.typeSuffix")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{value:ie,onChange:r=>I(r.target.value),placeholder:V,disabled:f||o,className:"font-mono text-xs","aria-label":s("settingsProxy.typePhraseAria")}),e.jsx("p",{className:"text-[11px] text-rose-800/90 dark:text-rose-200/80",children:s("settingsProxy.exactPhrase")})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(H,{variant:"outline",size:"sm",onClick:()=>{R(!1),I("")},disabled:f||o,children:s("settingsBackups.cancel")}),e.jsx(H,{size:"sm",variant:"destructive",onClick:Ce,disabled:!W||f||o,children:s("settingsProxy.enableAgyMode")})]})]}),e.jsx("span",{id:"agy-power-user-mode-label",className:"sr-only",children:s("settingsProxy.toggleAgyMode")})]})]}),m&&e.jsx(ls,{config:t,saving:o,testing:j,testResult:y,displayHost:Q,displayPort:Z,displayAuthToken:ee,displayManagementKey:de,setEditedHost:C,setEditedPort:P,setEditedAuthToken:A,setEditedManagementKey:d,onSaveHost:Le,onSavePort:_e,onSaveAuthToken:Re,onSaveManagementKey:Ie,onSaveConfig:c,onTestConnection:$e}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.fallbackSettings")}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.enableFallback")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.enableFallbackDesc")})]}),e.jsx(D,{checked:M.enabled??!0,onCheckedChange:r=>c({fallback:{...M,enabled:r}}),disabled:o||!m})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.autoStartLocal")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.autoStartLocalDesc")})]}),e.jsx(D,{checked:M.auto_start??!1,onCheckedChange:r=>c({fallback:{...M,auto_start:r}}),disabled:o||!m||!M.enabled})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(as,{className:"w-4 h-4"}),s("settingsProxy.advanced")]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.debugMode")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.debugModeDesc")})]}),e.jsx(D,{checked:_,onCheckedChange:ve,disabled:o})]}),_&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 pl-0.5",children:s("settingsProxy.debugModeEnabled")})]})]}),!m&&e.jsx(is,{config:t,saving:o,displayLocalPort:xe,setEditedLocalPort:h,onSaveLocalPort:Ke,onSaveConfig:c})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(H,{variant:"outline",size:"sm",onClick:()=>{a(),Y(),l(),q(),J()},disabled:g||o||f,className:"w-full",children:[e.jsx(re,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{Cs as default};
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{bg as Oe,bh as Ve,Y as L,a as ae,I as B,r as He,s as Ue,t as ze,v as We,w as ue,d as H,bi as Ye,bj as Ge,bk as Xe,b1 as se,b3 as te,n as qe}from"./index-og5NMtJP.js";import{S as D}from"./switch-3-7lTxFj.js";import{C as U}from"./default-ports-1QQSffYX.js";import{aV as he,R as re,g as Je,v as fe,W as Qe,x as Ze,aW as es,aX as ss,T as ye,at as ts,o as rs,aY as as}from"./icons-DtwH984l.js";import{R as V,P as os}from"./proxy-status-widget-CZnGc4zY.js";import{t as T}from"./notifications-B2HqRBj7.js";import"./tanstack-B8i0evp-.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-L5Ct0Tm9.js";function ns(){const{state:s}=Oe(),t=Ve(),[g,o]=n.useState(null),[u,b]=n.useState(null),[y,j]=n.useState(null),[p,C]=n.useState(null),[S,P]=n.useState(null),w=n.useCallback(async()=>{try{t.setProxyLoading(!0),t.setProxyError(null);const d=await L.cliproxyServer.get();t.setProxyConfig(d)}catch(d){t.setProxyError(d.message)}finally{t.setProxyLoading(!1)}},[t]),A=n.useCallback(async d=>{const x=s.proxyConfig;if(!x)return;const h={remote:{...x.remote,...d.remote},fallback:{...x.fallback,...d.fallback},local:{...x.local,...d.local}};t.setProxyConfig(h),t.setProxyTestResult(null);try{t.setProxySaving(!0),t.setProxyError(null);const a=await L.cliproxyServer.update(d);t.setProxyConfig(a),t.setProxySuccess(!0),setTimeout(()=>t.setProxySuccess(!1),1500)}catch(a){t.setProxyConfig(x),t.setProxyError(a.message)}finally{t.setProxySaving(!1)}},[s.proxyConfig,t]),E=n.useCallback(async d=>{const{host:x,port:h,protocol:a,authToken:c}=d;if(!x){t.setProxyError("Host is required");return}try{t.setProxyTesting(!0),t.setProxyError(null),t.setProxyTestResult(null);const k=h?parseInt(h,10):void 0,l=await L.cliproxyServer.test({host:x,port:k||void 0,protocol:a,authToken:c||void 0});t.setProxyTestResult(l)}catch(k){t.setProxyError(k.message)}finally{t.setProxyTesting(!1)}},[t]);return{config:s.proxyConfig,loading:s.proxyLoading,saving:s.proxySaving,error:s.proxyError,success:s.proxySuccess,testResult:s.proxyTestResult,testing:s.proxyTesting,editedHost:g,setEditedHost:o,editedPort:u,setEditedPort:b,editedAuthToken:y,setEditedAuthToken:j,editedManagementKey:p,setEditedManagementKey:C,editedLocalPort:S,setEditedLocalPort:P,fetchConfig:w,saveConfig:A,testConnection:E}}function is({config:s,saving:t,displayLocalPort:g,setEditedLocalPort:o,onSaveLocalPort:u,onSaveConfig:b}){const{t:y}=ae(),j=s.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:y("settingsProxy.localProxy")}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:y("settingsProxy.port")}),e.jsx(B,{type:"text",inputMode:"numeric",value:g,onChange:p=>o(p.target.value.replace(/\D/g,"")),onBlur:u,placeholder:`${U}`,className:"font-mono max-w-32",disabled:t})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:y("settingsProxy.autoStart")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:y("settingsProxy.localAutoStartDesc")})]}),e.jsx(D,{checked:j.auto_start??!0,onCheckedChange:p=>b({local:{...j,auto_start:p}}),disabled:t})]})]})]})}function ls({config:s,saving:t,testing:g,testResult:o,displayHost:u,displayPort:b,displayAuthToken:y,displayManagementKey:j,setEditedHost:p,setEditedPort:C,setEditedAuthToken:S,setEditedManagementKey:P,onSaveHost:w,onSavePort:A,onSaveAuthToken:E,onSaveManagementKey:d,onSaveConfig:x,onTestConnection:h}){const{t:a}=ae(),c=s.remote,k=l=>l==="https"?443:U;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(he,{className:"w-4 h-4"}),a("settingsProxy.remoteConfigTitle")]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.host")}),e.jsx(B,{value:u,onChange:l=>p(l.target.value),onBlur:w,placeholder:a("settingsProxy.hostPlaceholder"),className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:[a("settingsProxy.port")," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(",a("settingsProxy.defaultPort",{value:k(s.remote.protocol||"http")}),")"]})]}),e.jsx(B,{type:"text",inputMode:"numeric",value:b,onChange:l=>C(l.target.value.replace(/\D/g,"")),onBlur:A,placeholder:a("settingsProxy.portPlaceholder",{value:k(s.remote.protocol||"http")}),className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.protocol")}),e.jsxs(He,{value:s.remote.protocol||"http",onValueChange:l=>x({remote:{...c,protocol:l}}),disabled:t,children:[e.jsx(Ue,{children:e.jsx(ze,{})}),e.jsxs(We,{children:[e.jsx(ue,{value:"http",children:a("settingsProxy.http")}),e.jsx(ue,{value:"https",children:a("settingsProxy.https")})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.apiKeyOptional")}),e.jsx(B,{type:"password",value:y,onChange:l=>S(l.target.value),onBlur:E,placeholder:a("settingsProxy.apiKeyPlaceholder"),className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settingsProxy.apiKeyDesc")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.managementKeyOptional")}),e.jsx(B,{type:"password",value:j,onChange:l=>P(l.target.value),onBlur:d,placeholder:a("settingsProxy.managementKeyPlaceholder"),className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settingsProxy.managementKeyDesc")})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(H,{onClick:h,disabled:g||!u,variant:"outline",className:"w-full",children:g?e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-4 h-4 mr-2 animate-spin"}),a("settingsProxy.testing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"w-4 h-4 mr-2"}),a("settingsProxy.testConnection")]})}),o&&e.jsx("div",{className:`p-3 rounded-md ${o.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:o.reachable?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsx("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:a("settingsProxy.connectedLatency",{value:o.latencyMs})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:o.error||a("settingsProxy.connectionFailed")})]})})})]})]})}const pe="ccs_debug_mode",cs=["kiro","ghcp"];function ds(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function Cs(){const{t:s}=ae(),{config:t,loading:g,saving:o,error:u,success:b,testResult:y,testing:j,editedHost:p,setEditedHost:C,editedPort:S,setEditedPort:P,editedAuthToken:w,setEditedAuthToken:A,editedManagementKey:E,setEditedManagementKey:d,editedLocalPort:x,setEditedLocalPort:h,fetchConfig:a,saveConfig:c,testConnection:k}=ns(),{fetchRawConfig:l}=Ye(),[_,be]=n.useState(()=>{try{return localStorage.getItem(pe)==="true"}catch{return!1}}),[je,z]=n.useState(!1),[Pe,oe]=n.useState(!0),[f,ne]=n.useState(!1),[ke,R]=n.useState(!1),[ie,I]=n.useState(""),K=n.useRef(!1),W=ds(ie)===V,ve=r=>{be(r);try{localStorage.setItem(pe,String(r))}catch{}},Y=n.useCallback(async()=>{try{oe(!0);const r=await fetch("/api/settings/auth/antigravity-risk");if(!r.ok)throw new Error(s("settingsProxy.failedLoadAgyMode"));const i=await r.json();z(i.antigravityAckBypass===!0)}catch(r){T.error(r instanceof Error?r.message:s("settingsProxy.failedLoadAgyMode")),z(!1)}finally{oe(!1)}},[s]),$=n.useCallback(async r=>{if(!(K.current||f||o))try{K.current=!0,ne(!0);const i=await fetch("/api/settings/auth/antigravity-risk",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravityAckBypass:r})}),O=await i.json();if(!i.ok)throw new Error(O.error||s("settingsProxy.failedUpdateAgyMode"));const Fe=O.antigravityAckBypass===!0,me=await fetch("/api/settings/auth/antigravity-risk",{cache:"no-store"});if(!me.ok)throw new Error(s("settingsProxy.failedVerifyAgyMode"));const ge=(await me.json()).antigravityAckBypass===!0;if(ge!==r)throw new Error(s("settingsProxy.notPersistedAgyMode"));z(ge&&Fe),R(!1),I(""),T.success(s(r?"settingsProxy.agyModeEnabled":"settingsProxy.agyModeDisabled")),await l()}catch(i){T.error(i instanceof Error?i.message:s("settingsProxy.failedUpdateAgyMode"))}finally{K.current=!1,ne(!1)}},[f,l,o,s]),Ne=n.useCallback(r=>{if(!(K.current||f||o)){if(r){R(!0);return}R(!1),I(""),$(!1)}},[f,$,o]),Ce=n.useCallback(()=>{if(!W){T.error(s("settingsProxy.typePhraseToContinue",{value:V}));return}$(!0)},[W,$,s]),[v,G]=n.useState("plus"),[Se,we]=n.useState(!1),X=Ge(),{data:Ae}=Xe(),le=Ae?.running??!1,q=n.useCallback(async()=>{try{const r=await L.cliproxyServer.getBackend();G(r.backend)}catch(r){console.error("[Proxy] Failed to fetch backend:",r)}},[]),J=n.useCallback(async()=>{try{const i=(await L.cliproxy.list()).variants.some(O=>cs.includes(O.provider));we(i)}catch(r){console.error("[Proxy] Failed to check variants:",r)}},[]),ce=r=>{const i=v;G(r),X.mutate({backend:r},{onError:()=>{G(i)}})};if(n.useEffect(()=>{if(_&&t){const r={...t,remote:{...t.remote,auth_token:t.remote.auth_token?"[REDACTED]":void 0,management_key:t.remote.management_key?"[REDACTED]":void 0}};console.log("[CCS Debug] Debug mode enabled - proxy config:",r)}},[_,t]),n.useEffect(()=>{a(),Y(),l(),q(),J()},[a,Y,l,q,J]),g||!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(re,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})});const m=t.remote.enabled??!1,F=!m&&le,N=t.remote,M=t.fallback,Ee=t.remote.host??"",Te=t.remote.port!==void 0?t.remote.port.toString():"",Be=t.remote.auth_token??"",Me=t.remote.management_key??"",De=(t.local.port??U).toString(),Q=p??Ee,Z=S??Te,ee=w??Be,de=E??Me,xe=x??De,Le=()=>{const r=p??Q;r!==t.remote.host&&c({remote:{...N,host:r}}),C(null)},_e=()=>{const r=(S??Z).trim();if(r===""){t.remote.port!==void 0&&c({remote:{...N,port:void 0}}),P(null);return}const i=Number(r);if(!Number.isInteger(i)||i<1||i>65535){T.error(s("settingsProxy.invalidPortOrEmpty")),P(null);return}i!==t.remote.port&&c({remote:{...N,port:i}}),P(null)},Re=()=>{const r=w??ee;r!==t.remote.auth_token&&c({remote:{...N,auth_token:r}}),A(null)},Ie=()=>{const r=E??de;r!==t.remote.management_key&&c({remote:{...N,management_key:r||void 0}}),d(null)},Ke=()=>{const r=(x??xe).trim(),i=r===""?U:Number(r);if(!Number.isInteger(i)||i<1||i>65535){T.error(s("settingsProxy.invalidLocalPort")),h(null);return}i!==t.local.port&&c({local:{...t.local,port:i}}),h(null)},$e=()=>{k({host:Q,port:Z,protocol:t.remote.protocol||"http",authToken:ee})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${u||b?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(se,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Ze,{className:"h-4 w-4"}),e.jsx(te,{children:u})]}),b&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(fe,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(qe,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsProxy.description",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})}),!m&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.instanceStatus")}),e.jsx(os,{})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.connectionMode")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>c({remote:{...N,enabled:!1}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(es,{className:`w-5 h-5 ${m?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:s("settingsProxy.local")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.localDesc",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})})]}),e.jsxs("button",{onClick:()=>c({remote:{...N,enabled:!0}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(he,{className:`w-5 h-5 ${m?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:s("settingsProxy.remote")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.remoteDesc",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),s("settingsProxy.backendBinary")]}),!m&&le&&e.jsxs(se,{className:"py-2 border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 [&>svg]:top-2.5",children:[e.jsx(ye,{className:"h-4 w-4 text-amber-600"}),e.jsx(te,{className:"text-amber-700 dark:text-amber-400",children:s("settingsProxy.stopProxyToSwitch")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>ce("plus"),disabled:X.isPending||F,className:`p-4 rounded-lg border-2 text-left transition-all ${v==="plus"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${F?"opacity-60 cursor-not-allowed":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"font-medium",children:s("settingsProxy.backendPlusApi")}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400",children:s("settingsProxy.default")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.plusDesc")})]}),e.jsxs("button",{onClick:()=>ce("original"),disabled:X.isPending||F,className:`p-4 rounded-lg border-2 text-left transition-all ${v==="original"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${F?"opacity-60 cursor-not-allowed":""}`,children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("span",{className:"font-medium",children:s("settingsProxy.backendApi")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.originalDesc")})]})]}),v==="original"&&Se&&e.jsxs(se,{variant:"destructive",className:"py-2",children:[e.jsx(ye,{className:"h-4 w-4"}),e.jsx(te,{children:s("settingsProxy.variantsIncompatible")})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(ts,{className:"w-4 h-4 text-amber-700 dark:text-amber-300"}),s("settingsProxy.safety")]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-amber-400/35 bg-amber-50/70 p-4 dark:border-amber-800/60 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.agyModeTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.agyModeDesc")})]}),e.jsx(D,{"aria-labelledby":"agy-power-user-mode-label","aria-describedby":"agy-power-user-mode-description",checked:je,disabled:Pe||f||o,onCheckedChange:Ne})]}),e.jsx("p",{id:"agy-power-user-mode-description",className:"text-xs text-amber-800/90 dark:text-amber-200/90",children:s("settingsProxy.agyWarning")}),ke&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/40 bg-rose-500/[0.08] p-3.5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs font-semibold tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.finalConfirm")}),e.jsx("p",{className:"text-xs leading-relaxed text-rose-800/95 dark:text-rose-200/90",children:s("settingsProxy.finalConfirmDesc")})]}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border border-rose-400/30 bg-rose-500/10 p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.step1")}),e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"mt-1 inline-flex items-center gap-1.5 text-xs font-medium text-rose-800 underline decoration-rose-500/60 underline-offset-2 transition-colors hover:text-rose-700 dark:text-rose-200",children:[s("settingsProxy.readIssue"),e.jsx(rs,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"rounded-md border border-rose-400/30 bg-rose-500/10 p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.step2")}),e.jsxs("p",{className:"mt-1 text-xs text-rose-800/95 dark:text-rose-200/90",children:[s("settingsProxy.typePrefix")," ",e.jsx("code",{className:"rounded bg-background/80 px-1 py-0.5 font-mono",children:V})," ",s("settingsProxy.typeSuffix")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{value:ie,onChange:r=>I(r.target.value),placeholder:V,disabled:f||o,className:"font-mono text-xs","aria-label":s("settingsProxy.typePhraseAria")}),e.jsx("p",{className:"text-[11px] text-rose-800/90 dark:text-rose-200/80",children:s("settingsProxy.exactPhrase")})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(H,{variant:"outline",size:"sm",onClick:()=>{R(!1),I("")},disabled:f||o,children:s("settingsBackups.cancel")}),e.jsx(H,{size:"sm",variant:"destructive",onClick:Ce,disabled:!W||f||o,children:s("settingsProxy.enableAgyMode")})]})]}),e.jsx("span",{id:"agy-power-user-mode-label",className:"sr-only",children:s("settingsProxy.toggleAgyMode")})]})]}),m&&e.jsx(ls,{config:t,saving:o,testing:j,testResult:y,displayHost:Q,displayPort:Z,displayAuthToken:ee,displayManagementKey:de,setEditedHost:C,setEditedPort:P,setEditedAuthToken:A,setEditedManagementKey:d,onSaveHost:Le,onSavePort:_e,onSaveAuthToken:Re,onSaveManagementKey:Ie,onSaveConfig:c,onTestConnection:$e}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.fallbackSettings")}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.enableFallback")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.enableFallbackDesc")})]}),e.jsx(D,{checked:M.enabled??!0,onCheckedChange:r=>c({fallback:{...M,enabled:r}}),disabled:o||!m})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.autoStartLocal")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.autoStartLocalDesc")})]}),e.jsx(D,{checked:M.auto_start??!1,onCheckedChange:r=>c({fallback:{...M,auto_start:r}}),disabled:o||!m||!M.enabled})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(as,{className:"w-4 h-4"}),s("settingsProxy.advanced")]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.debugMode")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.debugModeDesc")})]}),e.jsx(D,{checked:_,onCheckedChange:ve,disabled:o})]}),_&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 pl-0.5",children:s("settingsProxy.debugModeEnabled")})]})]}),!m&&e.jsx(is,{config:t,saving:o,displayLocalPort:xe,setEditedLocalPort:h,onSaveLocalPort:Ke,onSaveConfig:c})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(H,{variant:"outline",size:"sm",onClick:()=>{a(),Y(),l(),q(),J()},disabled:g||o||f,className:"w-full",children:[e.jsx(re,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{Cs as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as f,c as pe}from"./react-vendor-CNOkPC89.js";import{u as M,a as ee,C as p,b as g,S as h,c,P as N,B as I,d as H,e as se,f as ge,g as te,h as je,i as ae,j as y,k as D,l as ye,m as Ne,n as we,o as be}from"./index-Dz76Rk36.js";import{$ as ve,ab as re,ac as z,ad as ne,Y as le,a4 as ke,G as Ce,ae as Se,R as De,Q,U as Le,Z as ie,u as $e,a6 as G,af as Te,N as Fe,C as Re,ag as Me,ah as Pe}from"./icons-DtwH984l.js";import{a as Be,u as P}from"./tanstack-B8i0evp-.js";import{K as $,L as Y,f as k,H as Ae}from"./utils-CzKF5WmX.js";import{R as oe,A as Ue,C as qe,X as Ie,Y as V,T as ce,a as Z,P as Oe,b as Ke,c as Ee}from"./charts-BBPXh0Ar.js";import"./notifications-B2HqRBj7.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Ge({data:s,isLoading:t}){const{privacyMode:r}=M(),{t:n}=ee();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:[1,2,3,4,5].map(a=>e.jsx(p,{children:e.jsx(g,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-8 w-[80px]"})]}),e.jsx(h,{className:"h-8 w-8 rounded-lg"})]})})},a))});const l=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),i=s?.totalCost?Math.round(l/s.totalCost*100):0,x=[{title:n("analyticsSummary.totalTokens"),value:s?.totalTokens??0,icon:ve,format:a=>R(a),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:n("analyticsSummary.totalTokensSubtitle",{input:R(s?.totalInputTokens??0),output:R(s?.totalOutputTokens??0)})},{title:n("analyticsSummary.totalCost"),value:s?.totalCost??0,icon:re,format:a=>`$${a.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:n("analyticsSummary.totalCostSubtitle",{value:s?.averageCostPerDay?.toFixed(2)??"0.00"})},{title:n("analyticsSummary.cacheTokens"),value:s?.totalCacheTokens??0,icon:z,format:a=>R(a),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:n("analyticsSummary.cacheTokensSubtitle",{cost:l.toFixed(2),percent:i})},{title:n("analyticsSummary.inputCost"),value:s?.tokenBreakdown?.input?.cost??0,icon:ne,format:a=>`$${a.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:R(s?.tokenBreakdown?.input?.tokens??0)})},{title:n("analyticsSummary.outputCost"),value:s?.tokenBreakdown?.output?.cost??0,icon:le,format:a=>`$${a.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:R(s?.tokenBreakdown?.output?.tokens??0)})}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:x.map((a,o)=>{const d=a.icon;return e.jsx(p,{className:"hover:shadow-md transition-shadow",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:a.title}),e.jsx("p",{className:c("text-xl font-bold truncate",r&&N),children:a.format(a.value)}),a.subtitle&&e.jsx("p",{className:c("text-[10px] text-muted-foreground truncate",r&&N),children:a.subtitle})]}),e.jsx("div",{className:c("p-2 rounded-lg shrink-0",a.bgColor),children:e.jsx(d,{className:c("h-4 w-4",a.color)})})]})})},o)})})}function R(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function We({model:s}){const{privacyMode:t}=M(),r=He(s.ioRatio);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(I,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(I,{variant:r.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:c("text-lg font-bold",t&&N),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Cost"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:c("text-lg font-bold",t&&N),children:ze(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Tokens"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:c("space-y-1",t&&N),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:ne}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:le}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:z}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:z})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Input/Output Ratio"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:r.description})]})]})}function W({label:s,tokens:t,cost:r,color:n,icon:l}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:n}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",r.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(l,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:_e(t)})]})]})]})}function He(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function _e(s){return s.toLocaleString()}function ze(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const Ye="/api";function b(s){const t=s.getFullYear(),r=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${t}${r}${n}`}const T={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),L(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),L(`/usage/sessions?${t}`)},monthly:(s,t)=>{const r=new URLSearchParams;return s&&r.append("months",s.toString()),t&&r.append("profile",t),L(`/usage/monthly?${r}`)},refresh:async()=>{if(!(await fetch(`${Ye}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>L("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/insights?${t}`)}};async function L(s){const r=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!r.ok){const l=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(l.error||r.statusText)}const n=await r.json();return n.data||n}function Qe(s){return P({queryKey:["usage","summary",s],queryFn:()=>T.summary(s),staleTime:60*1e3})}function Ve(s){return P({queryKey:["usage","trends",s],queryFn:()=>T.trends(s),staleTime:60*1e3})}function Ze(s){return P({queryKey:["usage","hourly",s],queryFn:()=>T.hourly(s),staleTime:60*1e3})}function Xe(s){return P({queryKey:["usage","models",s],queryFn:()=>T.models(s),staleTime:60*1e3})}function Je(){const s=Be();return f.useCallback(async()=>{await T.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function es(){return P({queryKey:["usage","status"],queryFn:()=>T.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function ss(s){return P({queryKey:["usage","sessions",s],queryFn:()=>T.sessions(s),staleTime:60*1e3})}function ts(){const[s,t]=f.useState({from:$(new Date,30),to:new Date}),[r,n]=f.useState(!1),[l,i]=f.useState(null),[x,a]=f.useState(null),[o,d]=f.useState("daily"),u=Je(),m=f.useCallback(async()=>{n(!0);try{await u()}finally{n(!1)}},[u]),j=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:w,isLoading:v}=Qe(j),{data:C,isLoading:S}=Ve(j),{data:B,isLoading:A}=Ze(j),{data:U,isLoading:q}=Xe(j),{data:_,isLoading:O}=ss({...j,limit:3}),{data:K}=es(),de=f.useCallback(()=>{const F=new Date;t({from:$(F,1),to:F}),d("hourly")},[]),xe=f.useCallback(F=>{t(F),d("daily")},[]),ue=f.useMemo(()=>K?.lastFetch?Y(new Date(K.lastFetch),{addSuffix:!0}):null,[K?.lastFetch]),me=f.useCallback((F,fe)=>{const E=fe.currentTarget.getBoundingClientRect();a({x:E.left+E.width/2,y:E.top+E.height/2}),i(F)},[]),he=f.useCallback(()=>{i(null),a(null)},[]);return{dateRange:s,isRefreshing:r,viewMode:o,selectedModel:l,popoverPosition:x,summary:w,trends:C,hourlyData:B,models:U,sessions:_,status:K,isSummaryLoading:v,isTrendsLoading:S,isHourlyLoading:A,isModelsLoading:q,isSessionsLoading:O,isLoading:v||S||q||O,handleRefresh:m,handleTodayClick:de,handleDateRangeChange:xe,handleModelClick:me,handlePopoverClose:he,lastUpdatedText:ue}}function as({value:s,onChange:t,presets:r=[{label:"Last 7 days",range:{from:$(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:$(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:$(new Date,90),to:new Date}}],className:n}){const[l,i]=pe.useState(!1),x=a=>!s||!s.from||!s.to||!a.from||!a.to?!1:k(s.from,"yyyy-MM-dd")===k(a.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(a.to,"yyyy-MM-dd");return e.jsxs("div",{className:c("flex flex-wrap items-center gap-2",n),children:[r.map(a=>e.jsx(H,{variant:x(a.range)?"default":"outline",size:"sm",onClick:()=>t(a.range),children:a.label},a.label)),e.jsxs(se,{open:l,onOpenChange:i,children:[e.jsx(ge,{asChild:!0,children:e.jsxs(H,{id:"date",variant:"outline",className:c("w-auto min-w-[200px] sm:min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Se,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[k(s.from,"LLL dd, y")," - ",k(s.to,"LLL dd, y")]}):k(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(te,{className:"w-auto p-0",align:"end",children:e.jsx(je,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function rs({dateRange:s,onDateRangeChange:t,onTodayClick:r,onRefresh:n,isRefreshing:l,lastUpdatedText:i,viewMode:x}){const{t:a}=ee();return e.jsxs("div",{className:"flex flex-col gap-3 shrink-0 xl:flex-row xl:items-center xl:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:a("analytics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("analytics.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 xl:justify-end",children:[e.jsx(H,{variant:x==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:r,children:"24H"}),e.jsx(as,{className:"flex-wrap",value:s,onChange:t,presets:[{label:"7D",range:{from:$(new Date,7),to:new Date}},{label:"30D",range:{from:$(new Date,30),to:new Date}},{label:a("analytics.month"),range:{from:Ae(new Date),to:new Date}},{label:a("analytics.allTime"),range:{from:void 0,to:new Date}}]}),i&&e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:a("analytics.updated",{value:i})}),e.jsx(H,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:n,disabled:l,children:e.jsx(De,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})]})}function ns({data:s,isLoading:t,granularity:r="daily",className:n}){const{privacyMode:l}=M(),i=f.useMemo(()=>!s||s.length===0?[]:(r==="hourly"?s:[...s].reverse()).map(o=>{const d="hour"in o?o.hour:o.date;return{...o,dateFormatted:ls(d,r),costRounded:Number(o.cost.toFixed(4))}}),[s,r]);if(t)return e.jsx(h,{className:c("h-full w-full",n)});if(!s||s.length===0)return e.jsx("div",{className:c("h-full flex items-center justify-center",n),children:e.jsx("p",{className:"text-muted-foreground",children:r==="hourly"?"No usage data for today":"No usage data available"})});const x=({x:a,y:o,payload:d,isRight:u})=>{const m=u?`$${d.value}`:X(Number(d.value));return e.jsx("text",{x:a,y:o,dy:4,textAnchor:u?"start":"end",fontSize:12,fill:"currentColor",className:c("fill-muted-foreground",l&&"blur-[4px]"),children:m})};return e.jsx("div",{className:c("w-full h-full",n),children:e.jsx(oe,{width:"100%",height:"100%",children:e.jsxs(Ue,{data:i,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(qe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Ie,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"left",orientation:"left",tick:a=>e.jsx(x,{...a,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:a=>e.jsx(x,{...a,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(ce,{content:({active:a,payload:o,label:d})=>{if(!a||!o||!o.length)return null;const u=o[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:d}),o.map((m,j)=>e.jsxs("p",{className:c("text-sm",l&&N),style:{color:m.color},children:[m.name,":"," ",m.name==="Tokens"?X(Number(m.value)||0):`$${m.value}`]},j)),"requests"in u&&e.jsxs("p",{className:c("text-sm text-muted-foreground mt-1",l&&N),children:["Requests: ",u.requests]})]})}}),e.jsx(Z,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(Z,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ls(s,t){if(t==="hourly"){const[n,l]=s.split(" ");if(n&&l){const i=new Date(`${n}T${l}:00Z`);return k(i,"HH:mm")}return s}const r=new Date(s);return t==="monthly"?k(r,"MMM yyyy"):k(r,"MMM dd")}function X(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function is({data:s,isLoading:t,className:r}){const{privacyMode:n}=M(),l=f.useMemo(()=>!s||s.length===0?[]:s.map(a=>({name:a.model,value:a.tokens,cost:a.cost,percentage:a.percentage,fill:ae(a.model)})),[s]);if(t)return e.jsx(h,{className:c("h-full min-h-[100px] w-full",r)});if(!s||s.length===0)return e.jsx("div",{className:c("h-full min-h-[100px] flex items-center justify-center",r),children:e.jsx("p",{className:"text-muted-foreground",children:"No model data available"})});const i=({active:a,payload:o})=>{if(!a||!o)return null;const d=o;if(!d.length)return null;const u=d[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:u.name}),e.jsxs("p",{className:c("text-muted-foreground",n&&N),children:[os(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:c("text-muted-foreground",n&&N),children:["$",u.cost.toFixed(4)]})]})},x=a=>a.percentage>5?`${a.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:c("w-full h-full min-h-[100px]",r),children:e.jsx(oe,{width:"100%",height:"100%",children:e.jsxs(Oe,{children:[e.jsx(Ke,{data:l,cx:"50%",cy:"50%",labelLine:!1,label:x,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((a,o)=>e.jsx(Ee,{fill:a.fill,strokeWidth:1},`cell-${o}`))}),e.jsx(ce,{content:i})]})})})}function os(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function cs(s){if(!s)return"";const r=s.replace(/^\/|\/$/g,"").split("/").filter(n=>n.length>0);return r[r.length-1]||""}function ds({data:s,isLoading:t,className:r}){const{privacyMode:n}=M(),l=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,x=s.total,a=i.reduce((w,v)=>w+(v.inputTokens+v.outputTokens),0),o=Math.round(a/i.length),u=i.reduce((w,v)=>w+v.cost,0)/i.length,m=i[0],j=m?Y(new Date(m.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:x,avgTokens:o,avgCost:u,lastActive:j,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",r),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsx(h,{className:"h-5 w-32"})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}):l?e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm",r),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0 flex flex-col gap-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Le,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:l.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(ie,{className:"w-4 h-4"}),e.jsxs("span",{className:c("text-xl font-bold",n&&N),children:["$",l.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx($e,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5 max-h-full overflow-y-auto pr-1",children:l.recentSessions.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:cs(i.projectPath)}),(i.target??"claude")!=="claude"&&e.jsx("span",{className:"shrink-0 px-1 py-0 text-[9px] font-medium rounded bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300 uppercase",children:i.target})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Y(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:c("text-right shrink-0 ml-2",n&&N),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[xs(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",r),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No session data available"})})]})}function xs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function us({className:s,isLoading:t}){const{data:r,isLoading:n}=ye(),{data:l,isLoading:i,error:x}=Ne(r?.running);if(t||n||r?.running&&i)return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-16 w-full"})]})})]});if(!r?.running)return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-dashed",s),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"secondary",className:"text-[10px] h-5",children:"Offline"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Start a CLIProxy session (gemini, codex, agy) to collect stats."})})]});if(x)return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-destructive/50",s),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:x.message})})]});const o=l?.totalRequests??0,d=l?.quotaExceededCount??0,u=o-d,m=o>0?Math.round(u/o*100):100,j=l?.tokens?.total??0,w=Object.entries(l?.requestsByModel??{}).sort((C,S)=>S[1]-C[1]).slice(0,4),v=w.length>0?w[0][1]:1;return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(y,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(I,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(ie,{className:"h-3 w-3 mr-0.5"}),"Running"]})]})}),e.jsx(g,{className:"p-0 flex-1 min-h-0",children:e.jsx(we,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${m*.88} 88`,strokeLinecap:"round",className:m>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[m,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(o)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:d>0?`${d} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(Te,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(j)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Total tokens"})]})]})]}),w.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Fe,{className:"h-3 w-3"}),"Models Used"]}),e.jsx("div",{className:"space-y-1",children:w.map(([C,S])=>{const B=Math.round(S/v*100),A=ms(C);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:C,children:A}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:S})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${B}%`}})})]},C)})})]})]})})})]})}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ms(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}function hs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function fs({models:s,isLoading:t,onModelClick:r,privacyMode:n}){return e.jsxs(p,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-4",children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(re,{className:"w-4 h-4"}),"Cost by Model"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(h,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((l,i)=>i.cost-l.cost).map(l=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:i=>r(l,i),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:ae(l.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:l.model})]}),e.jsx(ps,{model:l}),e.jsx("span",{className:c("text-[10px] text-muted-foreground w-14 text-right shrink-0",n&&N),children:hs(l.tokens)}),e.jsxs("span",{className:c("font-mono font-medium w-16 text-right shrink-0",n&&N),children:["$",l.cost.toFixed(2)]}),e.jsx(Re,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},l.model)),e.jsx(gs,{})]})})]})}function ps({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},r=n=>s.cost>0?n/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:t.input,width:`${r(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${r(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${r(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${r(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function gs(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:r,hasBorder:n})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:c("w-2 h-2 rounded-full",n&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),r]},r))})}function js({viewMode:s,trends:t,hourlyData:r,models:n,sessions:l,isTrendsLoading:i,isHourlyLoading:x,isModelsLoading:a,isSessionsLoading:o,isSummaryLoading:d,onModelClick:u}){const{privacyMode:m}=M();return e.jsxs("div",{className:"min-h-0 grid gap-4 lg:grid-rows-[minmax(260px,1.2fr)_minmax(220px,0.9fr)]",children:[e.jsxs(p,{className:"flex flex-col h-full min-h-[220px] lg:min-h-[240px] overflow-hidden gap-0 py-0 shadow-sm",children:[e.jsx(y,{className:"px-3 py-2 shrink-0",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Me,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(ns,{data:s==="hourly"?r||[]:t||[],isLoading:s==="hourly"?x:i,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto min-h-[220px] lg:h-full lg:min-h-[220px] lg:grid-rows-[minmax(0,1fr)] lg:[&>*]:min-h-0",children:[e.jsx(fs,{models:n,isLoading:a,onModelClick:u,privacyMode:m}),e.jsxs(p,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-2",children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(is,{data:n||[],isLoading:a,className:"h-full w-full"})})]}),e.jsx(ds,{data:l,isLoading:o,className:"lg:col-span-2"}),e.jsx(us,{isLoading:d,className:"lg:col-span-2"})]})]})}function $s(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(p,{className:"flex flex-col min-h-[300px]",children:[e.jsx(y,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-32"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(y,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(h,{className:"h-3 w-24"})]}),e.jsx(h,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(y,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(h,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2 h-2 rounded-full"}),e.jsx(h,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Ts(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:r,handleTodayClick:n,handleRefresh:l,isRefreshing:i,lastUpdatedText:x,viewMode:a,summary:o,isSummaryLoading:d,trends:u,hourlyData:m,models:j,sessions:w,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:S,isSessionsLoading:B,handleModelClick:A,selectedModel:U,popoverPosition:q,handlePopoverClose:_}=ts();return e.jsxs("div",{className:"grid h-full min-h-0 grid-rows-[auto_auto_minmax(0,1fr)] gap-4 overflow-y-auto px-4 py-4",children:[e.jsx(rs,{dateRange:t,onDateRangeChange:r,onTodayClick:n,onRefresh:l,isRefreshing:i,lastUpdatedText:x,viewMode:a}),e.jsx(Ge,{data:o,isLoading:d}),e.jsx(js,{viewMode:a,trends:u,hourlyData:m,models:j,sessions:w,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:S,isSessionsLoading:B,isSummaryLoading:d,onModelClick:A}),e.jsxs(se,{open:!!U,onOpenChange:O=>!O&&_(),children:[e.jsx(be,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:q?.x??0,top:q?.y??0,width:1,height:1}})}),e.jsx(te,{className:"w-80 p-3",side:"top",align:"center",children:U&&e.jsx(We,{model:U})})]})]})}export{Ts as AnalyticsPage,$s as AnalyticsSkeleton};
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as f,c as pe}from"./react-vendor-CNOkPC89.js";import{u as M,a as ee,C as p,b as g,S as h,c,P as N,B as I,d as H,e as se,f as ge,g as te,h as je,i as ae,j as y,k as D,l as ye,m as Ne,n as we,o as be}from"./index-og5NMtJP.js";import{$ as ve,ab as re,ac as z,ad as ne,Y as le,a4 as ke,G as Ce,ae as Se,R as De,Q,U as Le,Z as ie,u as $e,a6 as G,af as Te,N as Fe,C as Re,ag as Me,ah as Pe}from"./icons-DtwH984l.js";import{a as Be,u as P}from"./tanstack-B8i0evp-.js";import{K as $,L as Y,f as k,H as Ae}from"./utils-CzKF5WmX.js";import{R as oe,A as Ue,C as qe,X as Ie,Y as V,T as ce,a as Z,P as Oe,b as Ke,c as Ee}from"./charts-BBPXh0Ar.js";import"./notifications-B2HqRBj7.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Ge({data:s,isLoading:t}){const{privacyMode:r}=M(),{t:n}=ee();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:[1,2,3,4,5].map(a=>e.jsx(p,{children:e.jsx(g,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-8 w-[80px]"})]}),e.jsx(h,{className:"h-8 w-8 rounded-lg"})]})})},a))});const l=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),i=s?.totalCost?Math.round(l/s.totalCost*100):0,x=[{title:n("analyticsSummary.totalTokens"),value:s?.totalTokens??0,icon:ve,format:a=>R(a),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:n("analyticsSummary.totalTokensSubtitle",{input:R(s?.totalInputTokens??0),output:R(s?.totalOutputTokens??0)})},{title:n("analyticsSummary.totalCost"),value:s?.totalCost??0,icon:re,format:a=>`$${a.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:n("analyticsSummary.totalCostSubtitle",{value:s?.averageCostPerDay?.toFixed(2)??"0.00"})},{title:n("analyticsSummary.cacheTokens"),value:s?.totalCacheTokens??0,icon:z,format:a=>R(a),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:n("analyticsSummary.cacheTokensSubtitle",{cost:l.toFixed(2),percent:i})},{title:n("analyticsSummary.inputCost"),value:s?.tokenBreakdown?.input?.cost??0,icon:ne,format:a=>`$${a.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:R(s?.tokenBreakdown?.input?.tokens??0)})},{title:n("analyticsSummary.outputCost"),value:s?.tokenBreakdown?.output?.cost??0,icon:le,format:a=>`$${a.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:R(s?.tokenBreakdown?.output?.tokens??0)})}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:x.map((a,o)=>{const d=a.icon;return e.jsx(p,{className:"hover:shadow-md transition-shadow",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:a.title}),e.jsx("p",{className:c("text-xl font-bold truncate",r&&N),children:a.format(a.value)}),a.subtitle&&e.jsx("p",{className:c("text-[10px] text-muted-foreground truncate",r&&N),children:a.subtitle})]}),e.jsx("div",{className:c("p-2 rounded-lg shrink-0",a.bgColor),children:e.jsx(d,{className:c("h-4 w-4",a.color)})})]})})},o)})})}function R(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function We({model:s}){const{privacyMode:t}=M(),r=He(s.ioRatio);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(I,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(I,{variant:r.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:c("text-lg font-bold",t&&N),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Cost"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:c("text-lg font-bold",t&&N),children:ze(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Tokens"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:c("space-y-1",t&&N),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:ne}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:le}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:z}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:z})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Input/Output Ratio"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:r.description})]})]})}function W({label:s,tokens:t,cost:r,color:n,icon:l}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:n}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",r.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(l,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:_e(t)})]})]})]})}function He(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function _e(s){return s.toLocaleString()}function ze(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const Ye="/api";function b(s){const t=s.getFullYear(),r=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${t}${r}${n}`}const T={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),L(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),L(`/usage/sessions?${t}`)},monthly:(s,t)=>{const r=new URLSearchParams;return s&&r.append("months",s.toString()),t&&r.append("profile",t),L(`/usage/monthly?${r}`)},refresh:async()=>{if(!(await fetch(`${Ye}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>L("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/insights?${t}`)}};async function L(s){const r=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!r.ok){const l=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(l.error||r.statusText)}const n=await r.json();return n.data||n}function Qe(s){return P({queryKey:["usage","summary",s],queryFn:()=>T.summary(s),staleTime:60*1e3})}function Ve(s){return P({queryKey:["usage","trends",s],queryFn:()=>T.trends(s),staleTime:60*1e3})}function Ze(s){return P({queryKey:["usage","hourly",s],queryFn:()=>T.hourly(s),staleTime:60*1e3})}function Xe(s){return P({queryKey:["usage","models",s],queryFn:()=>T.models(s),staleTime:60*1e3})}function Je(){const s=Be();return f.useCallback(async()=>{await T.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function es(){return P({queryKey:["usage","status"],queryFn:()=>T.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function ss(s){return P({queryKey:["usage","sessions",s],queryFn:()=>T.sessions(s),staleTime:60*1e3})}function ts(){const[s,t]=f.useState({from:$(new Date,30),to:new Date}),[r,n]=f.useState(!1),[l,i]=f.useState(null),[x,a]=f.useState(null),[o,d]=f.useState("daily"),u=Je(),m=f.useCallback(async()=>{n(!0);try{await u()}finally{n(!1)}},[u]),j=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:w,isLoading:v}=Qe(j),{data:C,isLoading:S}=Ve(j),{data:B,isLoading:A}=Ze(j),{data:U,isLoading:q}=Xe(j),{data:_,isLoading:O}=ss({...j,limit:3}),{data:K}=es(),de=f.useCallback(()=>{const F=new Date;t({from:$(F,1),to:F}),d("hourly")},[]),xe=f.useCallback(F=>{t(F),d("daily")},[]),ue=f.useMemo(()=>K?.lastFetch?Y(new Date(K.lastFetch),{addSuffix:!0}):null,[K?.lastFetch]),me=f.useCallback((F,fe)=>{const E=fe.currentTarget.getBoundingClientRect();a({x:E.left+E.width/2,y:E.top+E.height/2}),i(F)},[]),he=f.useCallback(()=>{i(null),a(null)},[]);return{dateRange:s,isRefreshing:r,viewMode:o,selectedModel:l,popoverPosition:x,summary:w,trends:C,hourlyData:B,models:U,sessions:_,status:K,isSummaryLoading:v,isTrendsLoading:S,isHourlyLoading:A,isModelsLoading:q,isSessionsLoading:O,isLoading:v||S||q||O,handleRefresh:m,handleTodayClick:de,handleDateRangeChange:xe,handleModelClick:me,handlePopoverClose:he,lastUpdatedText:ue}}function as({value:s,onChange:t,presets:r=[{label:"Last 7 days",range:{from:$(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:$(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:$(new Date,90),to:new Date}}],className:n}){const[l,i]=pe.useState(!1),x=a=>!s||!s.from||!s.to||!a.from||!a.to?!1:k(s.from,"yyyy-MM-dd")===k(a.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(a.to,"yyyy-MM-dd");return e.jsxs("div",{className:c("flex flex-wrap items-center gap-2",n),children:[r.map(a=>e.jsx(H,{variant:x(a.range)?"default":"outline",size:"sm",onClick:()=>t(a.range),children:a.label},a.label)),e.jsxs(se,{open:l,onOpenChange:i,children:[e.jsx(ge,{asChild:!0,children:e.jsxs(H,{id:"date",variant:"outline",className:c("w-auto min-w-[200px] sm:min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Se,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[k(s.from,"LLL dd, y")," - ",k(s.to,"LLL dd, y")]}):k(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(te,{className:"w-auto p-0",align:"end",children:e.jsx(je,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function rs({dateRange:s,onDateRangeChange:t,onTodayClick:r,onRefresh:n,isRefreshing:l,lastUpdatedText:i,viewMode:x}){const{t:a}=ee();return e.jsxs("div",{className:"flex flex-col gap-3 shrink-0 xl:flex-row xl:items-center xl:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:a("analytics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("analytics.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 xl:justify-end",children:[e.jsx(H,{variant:x==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:r,children:"24H"}),e.jsx(as,{className:"flex-wrap",value:s,onChange:t,presets:[{label:"7D",range:{from:$(new Date,7),to:new Date}},{label:"30D",range:{from:$(new Date,30),to:new Date}},{label:a("analytics.month"),range:{from:Ae(new Date),to:new Date}},{label:a("analytics.allTime"),range:{from:void 0,to:new Date}}]}),i&&e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:a("analytics.updated",{value:i})}),e.jsx(H,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:n,disabled:l,children:e.jsx(De,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})]})}function ns({data:s,isLoading:t,granularity:r="daily",className:n}){const{privacyMode:l}=M(),i=f.useMemo(()=>!s||s.length===0?[]:(r==="hourly"?s:[...s].reverse()).map(o=>{const d="hour"in o?o.hour:o.date;return{...o,dateFormatted:ls(d,r),costRounded:Number(o.cost.toFixed(4))}}),[s,r]);if(t)return e.jsx(h,{className:c("h-full w-full",n)});if(!s||s.length===0)return e.jsx("div",{className:c("h-full flex items-center justify-center",n),children:e.jsx("p",{className:"text-muted-foreground",children:r==="hourly"?"No usage data for today":"No usage data available"})});const x=({x:a,y:o,payload:d,isRight:u})=>{const m=u?`$${d.value}`:X(Number(d.value));return e.jsx("text",{x:a,y:o,dy:4,textAnchor:u?"start":"end",fontSize:12,fill:"currentColor",className:c("fill-muted-foreground",l&&"blur-[4px]"),children:m})};return e.jsx("div",{className:c("w-full h-full",n),children:e.jsx(oe,{width:"100%",height:"100%",children:e.jsxs(Ue,{data:i,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(qe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Ie,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"left",orientation:"left",tick:a=>e.jsx(x,{...a,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:a=>e.jsx(x,{...a,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(ce,{content:({active:a,payload:o,label:d})=>{if(!a||!o||!o.length)return null;const u=o[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:d}),o.map((m,j)=>e.jsxs("p",{className:c("text-sm",l&&N),style:{color:m.color},children:[m.name,":"," ",m.name==="Tokens"?X(Number(m.value)||0):`$${m.value}`]},j)),"requests"in u&&e.jsxs("p",{className:c("text-sm text-muted-foreground mt-1",l&&N),children:["Requests: ",u.requests]})]})}}),e.jsx(Z,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(Z,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ls(s,t){if(t==="hourly"){const[n,l]=s.split(" ");if(n&&l){const i=new Date(`${n}T${l}:00Z`);return k(i,"HH:mm")}return s}const r=new Date(s);return t==="monthly"?k(r,"MMM yyyy"):k(r,"MMM dd")}function X(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function is({data:s,isLoading:t,className:r}){const{privacyMode:n}=M(),l=f.useMemo(()=>!s||s.length===0?[]:s.map(a=>({name:a.model,value:a.tokens,cost:a.cost,percentage:a.percentage,fill:ae(a.model)})),[s]);if(t)return e.jsx(h,{className:c("h-full min-h-[100px] w-full",r)});if(!s||s.length===0)return e.jsx("div",{className:c("h-full min-h-[100px] flex items-center justify-center",r),children:e.jsx("p",{className:"text-muted-foreground",children:"No model data available"})});const i=({active:a,payload:o})=>{if(!a||!o)return null;const d=o;if(!d.length)return null;const u=d[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:u.name}),e.jsxs("p",{className:c("text-muted-foreground",n&&N),children:[os(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:c("text-muted-foreground",n&&N),children:["$",u.cost.toFixed(4)]})]})},x=a=>a.percentage>5?`${a.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:c("w-full h-full min-h-[100px]",r),children:e.jsx(oe,{width:"100%",height:"100%",children:e.jsxs(Oe,{children:[e.jsx(Ke,{data:l,cx:"50%",cy:"50%",labelLine:!1,label:x,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((a,o)=>e.jsx(Ee,{fill:a.fill,strokeWidth:1},`cell-${o}`))}),e.jsx(ce,{content:i})]})})})}function os(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function cs(s){if(!s)return"";const r=s.replace(/^\/|\/$/g,"").split("/").filter(n=>n.length>0);return r[r.length-1]||""}function ds({data:s,isLoading:t,className:r}){const{privacyMode:n}=M(),l=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,x=s.total,a=i.reduce((w,v)=>w+(v.inputTokens+v.outputTokens),0),o=Math.round(a/i.length),u=i.reduce((w,v)=>w+v.cost,0)/i.length,m=i[0],j=m?Y(new Date(m.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:x,avgTokens:o,avgCost:u,lastActive:j,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",r),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsx(h,{className:"h-5 w-32"})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}):l?e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm",r),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0 flex flex-col gap-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Le,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:l.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(ie,{className:"w-4 h-4"}),e.jsxs("span",{className:c("text-xl font-bold",n&&N),children:["$",l.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx($e,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5 max-h-full overflow-y-auto pr-1",children:l.recentSessions.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:cs(i.projectPath)}),(i.target??"claude")!=="claude"&&e.jsx("span",{className:"shrink-0 px-1 py-0 text-[9px] font-medium rounded bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300 uppercase",children:i.target})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Y(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:c("text-right shrink-0 ml-2",n&&N),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[xs(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",r),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No session data available"})})]})}function xs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function us({className:s,isLoading:t}){const{data:r,isLoading:n}=ye(),{data:l,isLoading:i,error:x}=Ne(r?.running);if(t||n||r?.running&&i)return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-16 w-full"})]})})]});if(!r?.running)return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-dashed",s),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"secondary",className:"text-[10px] h-5",children:"Offline"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Start a CLIProxy session (gemini, codex, agy) to collect stats."})})]});if(x)return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-destructive/50",s),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:x.message})})]});const o=l?.totalRequests??0,d=l?.quotaExceededCount??0,u=o-d,m=o>0?Math.round(u/o*100):100,j=l?.tokens?.total??0,w=Object.entries(l?.requestsByModel??{}).sort((C,S)=>S[1]-C[1]).slice(0,4),v=w.length>0?w[0][1]:1;return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(y,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(I,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(ie,{className:"h-3 w-3 mr-0.5"}),"Running"]})]})}),e.jsx(g,{className:"p-0 flex-1 min-h-0",children:e.jsx(we,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${m*.88} 88`,strokeLinecap:"round",className:m>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[m,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(o)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:d>0?`${d} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(Te,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(j)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Total tokens"})]})]})]}),w.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Fe,{className:"h-3 w-3"}),"Models Used"]}),e.jsx("div",{className:"space-y-1",children:w.map(([C,S])=>{const B=Math.round(S/v*100),A=ms(C);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:C,children:A}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:S})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${B}%`}})})]},C)})})]})]})})})]})}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ms(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}function hs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function fs({models:s,isLoading:t,onModelClick:r,privacyMode:n}){return e.jsxs(p,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-4",children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(re,{className:"w-4 h-4"}),"Cost by Model"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(h,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((l,i)=>i.cost-l.cost).map(l=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:i=>r(l,i),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:ae(l.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:l.model})]}),e.jsx(ps,{model:l}),e.jsx("span",{className:c("text-[10px] text-muted-foreground w-14 text-right shrink-0",n&&N),children:hs(l.tokens)}),e.jsxs("span",{className:c("font-mono font-medium w-16 text-right shrink-0",n&&N),children:["$",l.cost.toFixed(2)]}),e.jsx(Re,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},l.model)),e.jsx(gs,{})]})})]})}function ps({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},r=n=>s.cost>0?n/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:t.input,width:`${r(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${r(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${r(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${r(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function gs(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:r,hasBorder:n})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:c("w-2 h-2 rounded-full",n&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),r]},r))})}function js({viewMode:s,trends:t,hourlyData:r,models:n,sessions:l,isTrendsLoading:i,isHourlyLoading:x,isModelsLoading:a,isSessionsLoading:o,isSummaryLoading:d,onModelClick:u}){const{privacyMode:m}=M();return e.jsxs("div",{className:"min-h-0 grid gap-4 lg:grid-rows-[minmax(260px,1.2fr)_minmax(220px,0.9fr)]",children:[e.jsxs(p,{className:"flex flex-col h-full min-h-[220px] lg:min-h-[240px] overflow-hidden gap-0 py-0 shadow-sm",children:[e.jsx(y,{className:"px-3 py-2 shrink-0",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Me,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(ns,{data:s==="hourly"?r||[]:t||[],isLoading:s==="hourly"?x:i,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto min-h-[220px] lg:h-full lg:min-h-[220px] lg:grid-rows-[minmax(0,1fr)] lg:[&>*]:min-h-0",children:[e.jsx(fs,{models:n,isLoading:a,onModelClick:u,privacyMode:m}),e.jsxs(p,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-2",children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(is,{data:n||[],isLoading:a,className:"h-full w-full"})})]}),e.jsx(ds,{data:l,isLoading:o,className:"lg:col-span-2"}),e.jsx(us,{isLoading:d,className:"lg:col-span-2"})]})]})}function $s(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(p,{className:"flex flex-col min-h-[300px]",children:[e.jsx(y,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-32"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(y,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(h,{className:"h-3 w-24"})]}),e.jsx(h,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(y,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(h,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2 h-2 rounded-full"}),e.jsx(h,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Ts(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:r,handleTodayClick:n,handleRefresh:l,isRefreshing:i,lastUpdatedText:x,viewMode:a,summary:o,isSummaryLoading:d,trends:u,hourlyData:m,models:j,sessions:w,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:S,isSessionsLoading:B,handleModelClick:A,selectedModel:U,popoverPosition:q,handlePopoverClose:_}=ts();return e.jsxs("div",{className:"grid h-full min-h-0 grid-rows-[auto_auto_minmax(0,1fr)] gap-4 overflow-y-auto px-4 py-4",children:[e.jsx(rs,{dateRange:t,onDateRangeChange:r,onTodayClick:n,onRefresh:l,isRefreshing:i,lastUpdatedText:x,viewMode:a}),e.jsx(Ge,{data:o,isLoading:d}),e.jsx(js,{viewMode:a,trends:u,hourlyData:m,models:j,sessions:w,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:S,isSessionsLoading:B,isSummaryLoading:d,onModelClick:A}),e.jsxs(se,{open:!!U,onOpenChange:O=>!O&&_(),children:[e.jsx(be,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:q?.x??0,top:q?.y??0,width:1,height:1}})}),e.jsx(te,{className:"w-80 p-3",side:"top",align:"center",children:U&&e.jsx(We,{model:U})})]})]})}export{Ts as AnalyticsPage,$s as AnalyticsSkeleton};
|