claude-session-dashboard 0.1.0
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/LICENSE +21 -0
- package/bin/cli.mjs +212 -0
- package/dist/client/assets/_dashboard-Oaur6UHf.js +1 -0
- package/dist/client/assets/_sessionId-CWavmGnC.js +12 -0
- package/dist/client/assets/createServerFn-Bmn60lX_.js +1 -0
- package/dist/client/assets/format-Bf-cSf6L.js +1 -0
- package/dist/client/assets/index-CN4cqOcf.js +1 -0
- package/dist/client/assets/main-Bssrw_E_.js +18 -0
- package/dist/client/assets/settings-Buc0ndXk.js +1 -0
- package/dist/client/assets/settings.types-4U9-Yxq3.js +1 -0
- package/dist/client/assets/stats-BEUCPbcP.js +4 -0
- package/dist/client/assets/useSessionCost-C7ox6YwA.js +61 -0
- package/dist/server/assets/_dashboard-CG6ub7j3.js +97 -0
- package/dist/server/assets/_sessionId-CcWGJarz.js +1582 -0
- package/dist/server/assets/_tanstack-start-manifest_v-DidrnaMJ.js +4 -0
- package/dist/server/assets/claude-path-CkuljM34.js +25 -0
- package/dist/server/assets/createServerRpc-Bd3B-Ah9.js +12 -0
- package/dist/server/assets/createSsrRpc-CVg2UDl0.js +17 -0
- package/dist/server/assets/format-CGmJnuhZ.js +57 -0
- package/dist/server/assets/index-DjrI63_C.js +409 -0
- package/dist/server/assets/router-ByIey__S.js +208 -0
- package/dist/server/assets/session-detail.server-azkRfON2.js +70 -0
- package/dist/server/assets/session-parser-CAEXxF1D.js +413 -0
- package/dist/server/assets/sessions.server-B8zbmvSM.js +187 -0
- package/dist/server/assets/settings-ko61yfVs.js +202 -0
- package/dist/server/assets/settings.queries-DSQd324O.js +33 -0
- package/dist/server/assets/settings.server-6B2PvLgf.js +89 -0
- package/dist/server/assets/settings.types-DntadCHo.js +111 -0
- package/dist/server/assets/start-HYkvq4Ni.js +4 -0
- package/dist/server/assets/stats-DItsFPp5.js +266 -0
- package/dist/server/assets/stats.server-BZWxV-mC.js +85 -0
- package/dist/server/assets/useSessionCost-EB0VxklP.js +76 -0
- package/dist/server/server.js +1428 -0
- package/package.json +69 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,r as g}from"./main-Bssrw_E_.js";import{u as f}from"./createServerFn-Bmn60lX_.js";import{S as j,D as p,u as v,a as b,s as N}from"./settings.types-4U9-Yxq3.js";function k({value:o,onChange:u}){return e.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:j.map(r=>{const d=o===r.id;return e.jsxs("button",{type:"button",onClick:()=>u(r.id),className:`rounded-lg border px-3 py-2 text-left transition-colors ${d?"border-blue-500 bg-blue-500/10 text-white":"border-gray-800 bg-gray-900/50 text-gray-400 hover:border-gray-700 hover:text-gray-300"}`,children:[e.jsx("div",{className:"text-sm font-medium",children:r.displayName}),e.jsx("div",{className:"mt-0.5 font-mono text-[10px] text-gray-500",children:r.monthlyUSD!==null?`$${r.monthlyUSD}/mo`:"Custom"})]},r.id)})})}const y=[{key:"inputPerMTok",label:"Input"},{key:"outputPerMTok",label:"Output"},{key:"cacheReadPerMTok",label:"Cache Read"},{key:"cacheWritePerMTok",label:"Cache Write"}];function T({overrides:o,onChange:u}){function r(t,s,i){const n=parseFloat(i);if(!Number.isFinite(n)||n<0||n>1e6)return;const a=p.find(l=>l.modelId===t);if(!a)return;const c=o[t]?{...o[t]}:{inputPerMTok:a.inputPerMTok,outputPerMTok:a.outputPerMTok,cacheReadPerMTok:a.cacheReadPerMTok,cacheWritePerMTok:a.cacheWritePerMTok};c[s]=n;const h=c.inputPerMTok===a.inputPerMTok&&c.outputPerMTok===a.outputPerMTok&&c.cacheReadPerMTok===a.cacheReadPerMTok&&c.cacheWritePerMTok===a.cacheWritePerMTok,m={...o};h?delete m[t]:m[t]=c,u(m)}function d(t,s){const i=o[t.modelId];return i?i[s]:t[s]}function x(t,s){const i=o[t];if(!i)return!1;const n=p.find(a=>a.modelId===t);return n?i[s]!==n[s]:!1}return e.jsxs("div",{className:"overflow-x-auto",children:[e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-800",children:[e.jsx("th",{className:"pb-2 pr-4 text-gray-400 font-medium",children:"Model"}),y.map(t=>e.jsx("th",{className:"pb-2 px-2 text-right text-gray-400 font-medium",children:t.label},t.key))]})}),e.jsx("tbody",{children:p.map(t=>e.jsxs("tr",{className:"border-b border-gray-800/50",children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-gray-300",children:t.displayName}),y.map(s=>{const i=d(t,s.key),n=x(t.modelId,s.key);return e.jsx("td",{className:"px-1 py-1.5",children:e.jsx("input",{type:"number",step:"0.01",min:"0",value:i,onChange:a=>r(t.modelId,s.key,a.target.value),className:`w-20 rounded border px-2 py-1 text-right font-mono text-xs ${n?"border-blue-500/50 bg-blue-500/10 text-blue-400":"border-gray-700 bg-gray-800 text-gray-300"} focus:border-blue-500 focus:outline-none`})},s.key)})]},t.modelId))})]}),e.jsx("p",{className:"mt-2 text-[10px] text-gray-600",children:"Prices in USD per million tokens. Overridden values shown in blue."})]})}function P(){const{data:o,isLoading:u}=f(N),r=v(),[d,x]=g.useState("pro"),[t,s]=g.useState({}),[i,n]=g.useState(!1);g.useEffect(()=>{o&&(x(o.subscriptionTier),s(o.pricingOverrides),n(!1))},[o]);function a(l){x(l),n(!0)}function c(l){s(l),n(!0)}function h(){x(b.subscriptionTier),s(b.pricingOverrides),n(!0)}function m(){const l={version:1,subscriptionTier:d,pricingOverrides:t};r.mutate(l,{onSuccess:()=>{n(!1)}})}return u?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-8 w-48 animate-pulse rounded bg-gray-800"}),e.jsx("div",{className:"h-64 animate-pulse rounded-xl bg-gray-900/50"})]}):e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-white",children:"Settings"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Configure your subscription tier and API pricing for cost estimation."}),e.jsxs("div",{className:"mt-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-300",children:"Subscription Tier"}),e.jsx("p",{className:"mt-1 text-[10px] text-gray-500",children:"Select your Claude subscription plan. This is informational only and does not affect cost calculations."}),e.jsx("div",{className:"mt-3",children:e.jsx(k,{value:d,onChange:a})})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-300",children:"API Pricing (per million tokens)"}),e.jsx("p",{className:"mt-1 text-[10px] text-gray-500",children:"Default prices from Anthropic. Override any value to match your negotiated rates."}),e.jsx("div",{className:"mt-3 rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:e.jsx(T,{overrides:t,onChange:c})})]}),e.jsxs("div",{className:"mt-6 flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:h,className:"rounded-lg border border-gray-700 px-3 py-1.5 text-xs text-gray-400 transition-colors hover:border-gray-600 hover:text-gray-300",children:"Reset to Defaults"}),e.jsxs("div",{className:"flex items-center gap-3",children:[r.isSuccess&&!i&&e.jsx("span",{className:"text-xs text-emerald-400",children:"Saved"}),r.isError&&e.jsxs("span",{className:"text-xs text-red-400",children:["Failed to save: ",r.error?.message??"Unknown error"]}),e.jsx("button",{type:"button",onClick:m,disabled:!i||r.isPending,className:`rounded-lg px-4 py-1.5 text-xs font-medium transition-colors ${i&&!r.isPending?"bg-blue-600 text-white hover:bg-blue-500":"cursor-not-allowed bg-gray-800 text-gray-500"}`,children:r.isPending?"Saving...":"Save"})]})]})]})}function R(){return e.jsx(P,{})}export{R as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as d,q as M}from"./createServerFn-Bmn60lX_.js";import{S as P,l as k,m as u,p as b,q as h,t as l,r,v as f,w as S,c as p,o as m,n as o,s as c,x as v,e as O,y as C}from"./main-Bssrw_E_.js";var g=class extends P{#t;#i=void 0;#e;#s;constructor(e,t){super(),this.#t=e,this.setOptions(t),this.bindMethods(),this.#a()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#t.defaultMutationOptions(e),k(this.options,t)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#e,observer:this}),t?.mutationKey&&this.options.mutationKey&&u(t.mutationKey)!==u(this.options.mutationKey)?this.reset():this.#e?.state.status==="pending"&&this.#e.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#e?.removeObserver(this)}onMutationUpdate(e){this.#a(),this.#r(e)}getCurrentResult(){return this.#i}reset(){this.#e?.removeObserver(this),this.#e=void 0,this.#a(),this.#r()}mutate(e,t){return this.#s=t,this.#e?.removeObserver(this),this.#e=this.#t.getMutationCache().build(this.#t,this.options),this.#e.addObserver(this),this.#e.execute(e)}#a(){const e=this.#e?.state??b();this.#i={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#r(e){h.batch(()=>{if(this.#s&&this.hasListeners()){const t=this.#i.variables,a=this.#i.context,s={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#s.onSuccess?.(e.data,t,a,s)}catch(i){Promise.reject(i)}try{this.#s.onSettled?.(e.data,null,t,a,s)}catch(i){Promise.reject(i)}}else if(e?.type==="error"){try{this.#s.onError?.(e.error,t,a,s)}catch(i){Promise.reject(i)}try{this.#s.onSettled?.(void 0,e.error,t,a,s)}catch(i){Promise.reject(i)}}}this.listeners.forEach(t=>{t(this.#i)})})}};function x(e,t){const a=l(),[s]=r.useState(()=>new g(a,e));r.useEffect(()=>{s.setOptions(e)},[s,e]);const i=r.useSyncExternalStore(r.useCallback(n=>s.subscribe(h.batchCalls(n)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),y=r.useCallback((n,T)=>{s.mutate(n,T).catch(f)},[s]);if(i.error&&S(s.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:y,mutateAsync:i.mutate}}const R=d({method:"GET"}).handler(p("810657681a273df5b4e58f0d8fcc6a5451598b489431b9bcaa98eea0ad815da8")),N=d({method:"POST"}).handler(p("3050115d92ca91ab1fd8fd698e33076328aae80dc64ca27c088eee16cebccc1a")),D=M({queryKey:["settings"],queryFn:()=>R(),staleTime:3e5,refetchOnWindowFocus:!1});function W(){const e=l();return x({mutationFn:t=>N({data:t}),onSuccess:()=>{e.invalidateQueries({queryKey:["settings"]})}})}const I=m({inputPerMTok:o().min(0),outputPerMTok:o().min(0),cacheReadPerMTok:o().min(0),cacheWritePerMTok:o().min(0)});m({version:C(1),subscriptionTier:O(["free","pro","max-5x","max-20x","teams","enterprise","api"]).default("pro"),pricingOverrides:v(c(),I).default({}),updatedAt:c().datetime().optional()});const q=[{modelId:"claude-opus-4-6",displayName:"Claude Opus 4.6",inputPerMTok:5,outputPerMTok:25,cacheReadPerMTok:.5,cacheWritePerMTok:6.25},{modelId:"claude-opus-4-5",displayName:"Claude Opus 4.5",inputPerMTok:5,outputPerMTok:25,cacheReadPerMTok:.5,cacheWritePerMTok:6.25},{modelId:"claude-opus-4-1",displayName:"Claude Opus 4.1",inputPerMTok:15,outputPerMTok:75,cacheReadPerMTok:1.5,cacheWritePerMTok:18.75},{modelId:"claude-opus-4",displayName:"Claude Opus 4",inputPerMTok:15,outputPerMTok:75,cacheReadPerMTok:1.5,cacheWritePerMTok:18.75},{modelId:"claude-sonnet-4-5",displayName:"Claude Sonnet 4.5",inputPerMTok:3,outputPerMTok:15,cacheReadPerMTok:.3,cacheWritePerMTok:3.75},{modelId:"claude-sonnet-4",displayName:"Claude Sonnet 4",inputPerMTok:3,outputPerMTok:15,cacheReadPerMTok:.3,cacheWritePerMTok:3.75},{modelId:"claude-haiku-4-5",displayName:"Claude Haiku 4.5",inputPerMTok:1,outputPerMTok:5,cacheReadPerMTok:.1,cacheWritePerMTok:1.25},{modelId:"claude-haiku-3-5",displayName:"Claude Haiku 3.5",inputPerMTok:.8,outputPerMTok:4,cacheReadPerMTok:.08,cacheWritePerMTok:1},{modelId:"claude-haiku-3",displayName:"Claude Haiku 3",inputPerMTok:.25,outputPerMTok:1.25,cacheReadPerMTok:.03,cacheWritePerMTok:.3}],K=[{id:"free",displayName:"Free",monthlyUSD:0},{id:"pro",displayName:"Pro",monthlyUSD:20},{id:"max-5x",displayName:"Max 5x",monthlyUSD:100},{id:"max-20x",displayName:"Max 20x",monthlyUSD:200},{id:"teams",displayName:"Teams",monthlyUSD:150},{id:"enterprise",displayName:"Enterprise",monthlyUSD:null},{id:"api",displayName:"API Only",monthlyUSD:null}],w={subscriptionTier:"pro",pricingOverrides:{}};function F(e){return e.replace(/-\d{8}$/,"")}export{q as D,K as S,w as a,F as n,D as s,W as u};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{c as yt,R as d,g as We,r as de,j as u}from"./main-Bssrw_E_.js";import{c as gt,q as bt,u as xt}from"./createServerFn-Bmn60lX_.js";import{f as At,a as qe,b as _e,c as Ot}from"./format-Bf-cSf6L.js";import{c as B,f as O,r as He,a as Pt,b as Ue,d as jt,i as I,T as Pe,p as D,L as $,g as Ye,e as je,h as Ze,D as kt,C as wt,j as Z,k as H,S as St,A as _t,l as Tt,m as Te,n as Et,o as w,q as Nt,u as Rt,G as $t,s as ae,t as It,v as Qe,w as Ct,x as ie,y as le,z as Lt,B as Dt,E as zt,F as Ft,H as Bt,I as Xe,J as Je,K as et,M as tt,N as rt,O as oe,X as nt,Y as it,P as Mt,Q as Kt,R as at,U as ot,V as Vt,W as Gt}from"./useSessionCost-C7ox6YwA.js";import"./settings.types-4U9-Yxq3.js";const Wt=gt({method:"GET"}).handler(yt("4b9a58c176f487b49800a372100037cdf33cf048f3592a449f115c7e3f5ea799")),qt=bt({queryKey:["stats"],queryFn:()=>Wt(),refetchInterval:6e4});var Ht=["points","className","baseLinePoints","connectNulls"];function U(){return U=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},U.apply(this,arguments)}function Ut(e,t){if(e==null)return{};var n=Yt(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Yt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function Ee(e){return Jt(e)||Xt(e)||Qt(e)||Zt()}function Zt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qt(e,t){if(e){if(typeof e=="string")return be(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return be(e,t)}}function Xt(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Jt(e){if(Array.isArray(e))return be(e)}function be(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ne=function(t){return t&&t.x===+t.x&&t.y===+t.y},er=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=[[]];return t.forEach(function(r){Ne(r)?n[n.length-1].push(r):n[n.length-1].length>0&&n.push([])}),Ne(t[0])&&n[n.length-1].push(t[0]),n[n.length-1].length<=0&&(n=n.slice(0,-1)),n},te=function(t,n){var r=er(t);n&&(r=[r.reduce(function(a,o){return[].concat(Ee(a),Ee(o))},[])]);var i=r.map(function(a){return a.reduce(function(o,c,f){return"".concat(o).concat(f===0?"M":"L").concat(c.x,",").concat(c.y)},"")}).join("");return r.length===1?"".concat(i,"Z"):i},tr=function(t,n,r){var i=te(t,r);return"".concat(i.slice(-1)==="Z"?i.slice(0,-1):i,"L").concat(te(n.reverse(),r).slice(1))},rr=function(t){var n=t.points,r=t.className,i=t.baseLinePoints,a=t.connectNulls,o=Ut(t,Ht);if(!n||!n.length)return null;var c=B("recharts-polygon",r);if(i&&i.length){var f=o.stroke&&o.stroke!=="none",l=tr(n,i,a);return d.createElement("g",{className:c},d.createElement("path",U({},O(o,!0),{fill:l.slice(-1)==="Z"?o.fill:"none",stroke:"none",d:l})),f?d.createElement("path",U({},O(o,!0),{fill:"none",d:te(n,a)})):null,f?d.createElement("path",U({},O(o,!0),{fill:"none",d:te(i,a)})):null)}var s=te(n,a);return d.createElement("path",U({},O(o,!0),{fill:s.slice(-1)==="Z"?o.fill:"none",className:c,d:s}))},ye,Re;function nr(){if(Re)return ye;Re=1;var e=He(),t=Pt(),n=Ue();function r(i,a){return i&&i.length?e(i,n(a,2),t):void 0}return ye=r,ye}var ir=nr();const ar=We(ir);var ge,$e;function or(){if($e)return ge;$e=1;var e=He(),t=Ue(),n=jt();function r(i,a){return i&&i.length?e(i,t(a,2),n):void 0}return ge=r,ge}var sr=or();const lr=We(sr);var cr=["cx","cy","angle","ticks","axisLine"],ur=["ticks","tick","angle","tickFormatter","stroke"];function Q(e){"@babel/helpers - typeof";return Q=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Q(e)}function re(){return re=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},re.apply(this,arguments)}function Ie(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function M(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ie(Object(n),!0).forEach(function(r){he(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ie(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Ce(e,t){if(e==null)return{};var n=fr(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function fr(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function dr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Le(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,lt(r.key),r)}}function hr(e,t,n){return t&&Le(e.prototype,t),n&&Le(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function pr(e,t,n){return t=ce(t),vr(e,st()?Reflect.construct(t,n||[],ce(e).constructor):t.apply(e,n))}function vr(e,t){if(t&&(Q(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return mr(e)}function mr(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function st(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(st=function(){return!!e})()}function ce(e){return ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ce(e)}function yr(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&xe(e,t)}function xe(e,t){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},xe(e,t)}function he(e,t,n){return t=lt(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lt(e){var t=gr(e,"string");return Q(t)=="symbol"?t:t+""}function gr(e,t){if(Q(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Q(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var pe=(function(e){function t(){return dr(this,t),pr(this,t,arguments)}return yr(t,e),hr(t,[{key:"getTickValueCoord",value:function(r){var i=r.coordinate,a=this.props,o=a.angle,c=a.cx,f=a.cy;return D(c,f,i,o)}},{key:"getTickTextAnchor",value:function(){var r=this.props.orientation,i;switch(r){case"left":i="end";break;case"right":i="start";break;default:i="middle";break}return i}},{key:"getViewBox",value:function(){var r=this.props,i=r.cx,a=r.cy,o=r.angle,c=r.ticks,f=ar(c,function(s){return s.coordinate||0}),l=lr(c,function(s){return s.coordinate||0});return{cx:i,cy:a,startAngle:o,endAngle:o,innerRadius:l.coordinate||0,outerRadius:f.coordinate||0}}},{key:"renderAxisLine",value:function(){var r=this.props,i=r.cx,a=r.cy,o=r.angle,c=r.ticks,f=r.axisLine,l=Ce(r,cr),s=c.reduce(function(m,h){return[Math.min(m[0],h.coordinate),Math.max(m[1],h.coordinate)]},[1/0,-1/0]),v=D(i,a,s[0],o),p=D(i,a,s[1],o),y=M(M(M({},O(l,!1)),{},{fill:"none"},O(f,!1)),{},{x1:v.x,y1:v.y,x2:p.x,y2:p.y});return d.createElement("line",re({className:"recharts-polar-radius-axis-line"},y))}},{key:"renderTicks",value:function(){var r=this,i=this.props,a=i.ticks,o=i.tick,c=i.angle,f=i.tickFormatter,l=i.stroke,s=Ce(i,ur),v=this.getTickTextAnchor(),p=O(s,!1),y=O(o,!1),m=a.map(function(h,g){var x=r.getTickValueCoord(h),A=M(M(M(M({textAnchor:v,transform:"rotate(".concat(90-c,", ").concat(x.x,", ").concat(x.y,")")},p),{},{stroke:"none",fill:l},y),{},{index:g},x),{},{payload:h});return d.createElement($,re({className:B("recharts-polar-radius-axis-tick",Ye(o)),key:"tick-".concat(h.coordinate)},je(r.props,h,g)),t.renderTickItem(o,A,f?f(h.value,g):h.value))});return d.createElement($,{className:"recharts-polar-radius-axis-ticks"},m)}},{key:"render",value:function(){var r=this.props,i=r.ticks,a=r.axisLine,o=r.tick;return!i||!i.length?null:d.createElement($,{className:B("recharts-polar-radius-axis",this.props.className)},a&&this.renderAxisLine(),o&&this.renderTicks(),Ze.renderCallByParent(this.props,this.getViewBox()))}}],[{key:"renderTickItem",value:function(r,i,a){var o;return d.isValidElement(r)?o=d.cloneElement(r,i):I(r)?o=r(i):o=d.createElement(Pe,re({},i,{className:"recharts-polar-radius-axis-tick-value"}),a),o}}])})(de.PureComponent);he(pe,"displayName","PolarRadiusAxis");he(pe,"axisType","radiusAxis");he(pe,"defaultProps",{type:"number",radiusAxisId:0,cx:0,cy:0,angle:0,orientation:"right",stroke:"#ccc",axisLine:!0,tick:!0,tickCount:5,allowDataOverflow:!1,scale:"auto",allowDuplicatedCategory:!0});function X(e){"@babel/helpers - typeof";return X=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},X(e)}function V(){return V=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},V.apply(this,arguments)}function De(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function K(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?De(Object(n),!0).forEach(function(r){ve(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):De(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function br(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ze(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,ut(r.key),r)}}function xr(e,t,n){return t&&ze(e.prototype,t),n&&ze(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ar(e,t,n){return t=ue(t),Or(e,ct()?Reflect.construct(t,n||[],ue(e).constructor):t.apply(e,n))}function Or(e,t){if(t&&(X(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Pr(e)}function Pr(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ct=function(){return!!e})()}function ue(e){return ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ue(e)}function jr(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ae(e,t)}function Ae(e,t){return Ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},Ae(e,t)}function ve(e,t,n){return t=ut(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ut(e){var t=kr(e,"string");return X(t)=="symbol"?t:t+""}function kr(e,t){if(X(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(X(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var wr=Math.PI/180,Fe=1e-5,me=(function(e){function t(){return br(this,t),Ar(this,t,arguments)}return jr(t,e),xr(t,[{key:"getTickLineCoord",value:function(r){var i=this.props,a=i.cx,o=i.cy,c=i.radius,f=i.orientation,l=i.tickSize,s=l||8,v=D(a,o,c,r.coordinate),p=D(a,o,c+(f==="inner"?-1:1)*s,r.coordinate);return{x1:v.x,y1:v.y,x2:p.x,y2:p.y}}},{key:"getTickTextAnchor",value:function(r){var i=this.props.orientation,a=Math.cos(-r.coordinate*wr),o;return a>Fe?o=i==="outer"?"start":"end":a<-Fe?o=i==="outer"?"end":"start":o="middle",o}},{key:"renderAxisLine",value:function(){var r=this.props,i=r.cx,a=r.cy,o=r.radius,c=r.axisLine,f=r.axisLineType,l=K(K({},O(this.props,!1)),{},{fill:"none"},O(c,!1));if(f==="circle")return d.createElement(kt,V({className:"recharts-polar-angle-axis-line"},l,{cx:i,cy:a,r:o}));var s=this.props.ticks,v=s.map(function(p){return D(i,a,o,p.coordinate)});return d.createElement(rr,V({className:"recharts-polar-angle-axis-line"},l,{points:v}))}},{key:"renderTicks",value:function(){var r=this,i=this.props,a=i.ticks,o=i.tick,c=i.tickLine,f=i.tickFormatter,l=i.stroke,s=O(this.props,!1),v=O(o,!1),p=K(K({},s),{},{fill:"none"},O(c,!1)),y=a.map(function(m,h){var g=r.getTickLineCoord(m),x=r.getTickTextAnchor(m),A=K(K(K({textAnchor:x},s),{},{stroke:"none",fill:l},v),{},{index:h,payload:m,x:g.x2,y:g.y2});return d.createElement($,V({className:B("recharts-polar-angle-axis-tick",Ye(o)),key:"tick-".concat(m.coordinate)},je(r.props,m,h)),c&&d.createElement("line",V({className:"recharts-polar-angle-axis-tick-line"},p,g)),o&&t.renderTickItem(o,A,f?f(m.value,h):m.value))});return d.createElement($,{className:"recharts-polar-angle-axis-ticks"},y)}},{key:"render",value:function(){var r=this.props,i=r.ticks,a=r.radius,o=r.axisLine;return a<=0||!i||!i.length?null:d.createElement($,{className:B("recharts-polar-angle-axis",this.props.className)},o&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(r,i,a){var o;return d.isValidElement(r)?o=d.cloneElement(r,i):I(r)?o=r(i):o=d.createElement(Pe,V({},i,{className:"recharts-polar-angle-axis-tick-value"}),a),o}}])})(de.PureComponent);ve(me,"displayName","PolarAngleAxis");ve(me,"axisType","angleAxis");ve(me,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var se;function J(e){"@babel/helpers - typeof";return J=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},J(e)}function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Y.apply(this,arguments)}function Be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function b(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Be(Object(n),!0).forEach(function(r){E(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Sr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Me(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,dt(r.key),r)}}function _r(e,t,n){return t&&Me(e.prototype,t),n&&Me(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Tr(e,t,n){return t=fe(t),Er(e,ft()?Reflect.construct(t,n||[],fe(e).constructor):t.apply(e,n))}function Er(e,t){if(t&&(J(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Nr(e)}function Nr(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ft(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ft=function(){return!!e})()}function fe(e){return fe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},fe(e)}function Rr(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Oe(e,t)}function Oe(e,t){return Oe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},Oe(e,t)}function E(e,t,n){return t=dt(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dt(e){var t=$r(e,"string");return J(t)=="symbol"?t:t+""}function $r(e,t){if(J(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(J(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var z=(function(e){function t(n){var r;return Sr(this,t),r=Tr(this,t,[n]),E(r,"pieRef",null),E(r,"sectorRefs",[]),E(r,"id",Rt("recharts-pie-")),E(r,"handleAnimationEnd",function(){var i=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),I(i)&&i()}),E(r,"handleAnimationStart",function(){var i=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),I(i)&&i()}),r.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},r}return Rr(t,e),_r(t,[{key:"isActiveIndex",value:function(r){var i=this.props.activeIndex;return Array.isArray(i)?i.indexOf(r)!==-1:r===i}},{key:"hasActiveIndex",value:function(){var r=this.props.activeIndex;return Array.isArray(r)?r.length!==0:r||r===0}},{key:"renderLabels",value:function(r){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var a=this.props,o=a.label,c=a.labelLine,f=a.dataKey,l=a.valueKey,s=O(this.props,!1),v=O(o,!1),p=O(c,!1),y=o&&o.offsetRadius||20,m=r.map(function(h,g){var x=(h.startAngle+h.endAngle)/2,A=D(h.cx,h.cy,h.outerRadius+y,x),P=b(b(b(b({},s),h),{},{stroke:"none"},v),{},{index:g,textAnchor:t.getTextAnchor(A.x,h.cx)},A),C=b(b(b(b({},s),h),{},{fill:"none",stroke:h.fill},p),{},{index:g,points:[D(h.cx,h.cy,h.outerRadius,x),A]}),S=f;return Z(f)&&Z(l)?S="value":Z(f)&&(S=l),d.createElement($,{key:"label-".concat(h.startAngle,"-").concat(h.endAngle,"-").concat(h.midAngle,"-").concat(g)},c&&t.renderLabelLineItem(c,C,"line"),t.renderLabelItem(o,P,H(h,S)))});return d.createElement($,{className:"recharts-pie-labels"},m)}},{key:"renderSectorsStatically",value:function(r){var i=this,a=this.props,o=a.activeShape,c=a.blendStroke,f=a.inactiveShape;return r.map(function(l,s){if(l?.startAngle===0&&l?.endAngle===0&&r.length!==1)return null;var v=i.isActiveIndex(s),p=f&&i.hasActiveIndex()?f:null,y=v?o:p,m=b(b({},l),{},{stroke:c?l.fill:l.stroke,tabIndex:-1});return d.createElement($,Y({ref:function(g){g&&!i.sectorRefs.includes(g)&&i.sectorRefs.push(g)},tabIndex:-1,className:"recharts-pie-sector"},je(i.props,l,s),{key:"sector-".concat(l?.startAngle,"-").concat(l?.endAngle,"-").concat(l.midAngle,"-").concat(s)}),d.createElement(St,Y({option:y,isActive:v,shapeType:"sector"},m)))})}},{key:"renderSectorsWithAnimation",value:function(){var r=this,i=this.props,a=i.sectors,o=i.isAnimationActive,c=i.animationBegin,f=i.animationDuration,l=i.animationEasing,s=i.animationId,v=this.state,p=v.prevSectors,y=v.prevIsAnimationActive;return d.createElement(_t,{begin:c,duration:f,isActive:o,easing:l,from:{t:0},to:{t:1},key:"pie-".concat(s,"-").concat(y),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(m){var h=m.t,g=[],x=a&&a[0],A=x.startAngle;return a.forEach(function(P,C){var S=p&&p[C],_=C>0?Tt(P,"paddingAngle",0):0;if(S){var N=Te(S.endAngle-S.startAngle,P.endAngle-P.startAngle),j=b(b({},P),{},{startAngle:A+_,endAngle:A+N(h)+_});g.push(j),A=j.endAngle}else{var R=P.endAngle,T=P.startAngle,L=Te(0,R-T),ne=L(h),F=b(b({},P),{},{startAngle:A+_,endAngle:A+ne+_});g.push(F),A=F.endAngle}}),d.createElement($,null,r.renderSectorsStatically(g))})}},{key:"attachKeyboardHandlers",value:function(r){var i=this;r.onkeydown=function(a){if(!a.altKey)switch(a.key){case"ArrowLeft":{var o=++i.state.sectorToFocus%i.sectorRefs.length;i.sectorRefs[o].focus(),i.setState({sectorToFocus:o});break}case"ArrowRight":{var c=--i.state.sectorToFocus<0?i.sectorRefs.length-1:i.state.sectorToFocus%i.sectorRefs.length;i.sectorRefs[c].focus(),i.setState({sectorToFocus:c});break}case"Escape":{i.sectorRefs[i.state.sectorToFocus].blur(),i.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var r=this.props,i=r.sectors,a=r.isAnimationActive,o=this.state.prevSectors;return a&&i&&i.length&&(!o||!Et(o,i))?this.renderSectorsWithAnimation():this.renderSectorsStatically(i)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var r=this,i=this.props,a=i.hide,o=i.sectors,c=i.className,f=i.label,l=i.cx,s=i.cy,v=i.innerRadius,p=i.outerRadius,y=i.isAnimationActive,m=this.state.isAnimationFinished;if(a||!o||!o.length||!w(l)||!w(s)||!w(v)||!w(p))return null;var h=B("recharts-pie",c);return d.createElement($,{tabIndex:this.props.rootTabIndex,className:h,ref:function(x){r.pieRef=x}},this.renderSectors(),f&&this.renderLabels(o),Ze.renderCallByParent(this.props,null,!1),(!y||m)&&Nt.renderCallByParent(this.props,o,!1))}}],[{key:"getDerivedStateFromProps",value:function(r,i){return i.prevIsAnimationActive!==r.isAnimationActive?{prevIsAnimationActive:r.isAnimationActive,prevAnimationId:r.animationId,curSectors:r.sectors,prevSectors:[],isAnimationFinished:!0}:r.isAnimationActive&&r.animationId!==i.prevAnimationId?{prevAnimationId:r.animationId,curSectors:r.sectors,prevSectors:i.curSectors,isAnimationFinished:!0}:r.sectors!==i.curSectors?{curSectors:r.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(r,i){return r>i?"start":r<i?"end":"middle"}},{key:"renderLabelLineItem",value:function(r,i,a){if(d.isValidElement(r))return d.cloneElement(r,i);if(I(r))return r(i);var o=B("recharts-pie-label-line",typeof r!="boolean"?r.className:"");return d.createElement(wt,Y({},i,{key:a,type:"linear",className:o}))}},{key:"renderLabelItem",value:function(r,i,a){if(d.isValidElement(r))return d.cloneElement(r,i);var o=a;if(I(r)&&(o=r(i),d.isValidElement(o)))return o;var c=B("recharts-pie-label-text",typeof r!="boolean"&&!I(r)?r.className:"");return d.createElement(Pe,Y({},i,{alignmentBaseline:"middle",className:c}),o)}}])})(de.PureComponent);se=z;E(z,"displayName","Pie");E(z,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!$t.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});E(z,"parseDeltaAngle",function(e,t){var n=ae(t-e),r=Math.min(Math.abs(t-e),360);return n*r});E(z,"getRealPieData",function(e){var t=e.data,n=e.children,r=O(e,!1),i=It(n,Qe);return t&&t.length?t.map(function(a,o){return b(b(b({payload:a},r),a),i&&i[o]&&i[o].props)}):i&&i.length?i.map(function(a){return b(b({},r),a.props)}):[]});E(z,"parseCoordinateOfPie",function(e,t){var n=t.top,r=t.left,i=t.width,a=t.height,o=Ct(i,a),c=r+ie(e.cx,i,i/2),f=n+ie(e.cy,a,a/2),l=ie(e.innerRadius,o,0),s=ie(e.outerRadius,o,o*.8),v=e.maxRadius||Math.sqrt(i*i+a*a)/2;return{cx:c,cy:f,innerRadius:l,outerRadius:s,maxRadius:v}});E(z,"getComposedData",function(e){var t=e.item,n=e.offset,r=t.type.defaultProps!==void 0?b(b({},t.type.defaultProps),t.props):t.props,i=se.getRealPieData(r);if(!i||!i.length)return null;var a=r.cornerRadius,o=r.startAngle,c=r.endAngle,f=r.paddingAngle,l=r.dataKey,s=r.nameKey,v=r.valueKey,p=r.tooltipType,y=Math.abs(r.minAngle),m=se.parseCoordinateOfPie(r,n),h=se.parseDeltaAngle(o,c),g=Math.abs(h),x=l;Z(l)&&Z(v)?(le(!1,`Use "dataKey" to specify the value of pie,
|
|
3
|
+
the props "valueKey" will be deprecated in 1.1.0`),x="value"):Z(l)&&(le(!1,`Use "dataKey" to specify the value of pie,
|
|
4
|
+
the props "valueKey" will be deprecated in 1.1.0`),x=v);var A=i.filter(function(j){return H(j,x,0)!==0}).length,P=(g>=360?A:A-1)*f,C=g-A*y-P,S=i.reduce(function(j,R){var T=H(R,x,0);return j+(w(T)?T:0)},0),_;if(S>0){var N;_=i.map(function(j,R){var T=H(j,x,0),L=H(j,s,R),ne=(w(T)?T:0)/S,F;R?F=N.endAngle+ae(h)*f*(T!==0?1:0):F=o;var ke=F+ae(h)*((T!==0?y:0)+ne*C),we=(F+ke)/2,Se=(m.innerRadius+m.outerRadius)/2,vt=[{name:L,value:T,payload:j,dataKey:x,type:p}],mt=D(m.cx,m.cy,Se,we);return N=b(b(b({percent:ne,cornerRadius:a,name:L,tooltipPayload:vt,midAngle:we,middleRadius:Se,tooltipPosition:mt},j),m),{},{value:H(j,x),startAngle:F,endAngle:ke,payload:j,paddingAngle:ae(h)*f}),N})}return b(b({},m),{},{sectors:_,data:i})});var Ir=["x1","y1","x2","y2","key"],Cr=["offset"];function W(e){"@babel/helpers - typeof";return W=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},W(e)}function Ke(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function k(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ke(Object(n),!0).forEach(function(r){Lr(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ke(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Lr(e,t,n){return t=Dr(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Dr(e){var t=zr(e,"string");return W(t)=="symbol"?t:t+""}function zr(e,t){if(W(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(W(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function G(){return G=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},G.apply(this,arguments)}function Ve(e,t){if(e==null)return{};var n=Fr(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Fr(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var Br=function(t){var n=t.fill;if(!n||n==="none")return null;var r=t.fillOpacity,i=t.x,a=t.y,o=t.width,c=t.height,f=t.ry;return d.createElement("rect",{x:i,y:a,ry:f,width:o,height:c,stroke:"none",fill:n,fillOpacity:r,className:"recharts-cartesian-grid-bg"})};function ht(e,t){var n;if(d.isValidElement(e))n=d.cloneElement(e,t);else if(I(e))n=e(t);else{var r=t.x1,i=t.y1,a=t.x2,o=t.y2,c=t.key,f=Ve(t,Ir),l=O(f,!1);l.offset;var s=Ve(l,Cr);n=d.createElement("line",G({},s,{x1:r,y1:i,x2:a,y2:o,fill:"none",key:c}))}return n}function Mr(e){var t=e.x,n=e.width,r=e.horizontal,i=r===void 0?!0:r,a=e.horizontalPoints;if(!i||!a||!a.length)return null;var o=a.map(function(c,f){var l=k(k({},e),{},{x1:t,y1:c,x2:t+n,y2:c,key:"line-".concat(f),index:f});return ht(i,l)});return d.createElement("g",{className:"recharts-cartesian-grid-horizontal"},o)}function Kr(e){var t=e.y,n=e.height,r=e.vertical,i=r===void 0?!0:r,a=e.verticalPoints;if(!i||!a||!a.length)return null;var o=a.map(function(c,f){var l=k(k({},e),{},{x1:c,y1:t,x2:c,y2:t+n,key:"line-".concat(f),index:f});return ht(i,l)});return d.createElement("g",{className:"recharts-cartesian-grid-vertical"},o)}function Vr(e){var t=e.horizontalFill,n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,c=e.horizontalPoints,f=e.horizontal,l=f===void 0?!0:f;if(!l||!t||!t.length)return null;var s=c.map(function(p){return Math.round(p+i-i)}).sort(function(p,y){return p-y});i!==s[0]&&s.unshift(0);var v=s.map(function(p,y){var m=!s[y+1],h=m?i+o-p:s[y+1]-p;if(h<=0)return null;var g=y%t.length;return d.createElement("rect",{key:"react-".concat(y),y:p,x:r,height:h,width:a,stroke:"none",fill:t[g],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return d.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},v)}function Gr(e){var t=e.vertical,n=t===void 0?!0:t,r=e.verticalFill,i=e.fillOpacity,a=e.x,o=e.y,c=e.width,f=e.height,l=e.verticalPoints;if(!n||!r||!r.length)return null;var s=l.map(function(p){return Math.round(p+a-a)}).sort(function(p,y){return p-y});a!==s[0]&&s.unshift(0);var v=s.map(function(p,y){var m=!s[y+1],h=m?a+c-p:s[y+1]-p;if(h<=0)return null;var g=y%r.length;return d.createElement("rect",{key:"react-".concat(y),x:p,y:o,width:h,height:f,stroke:"none",fill:r[g],fillOpacity:i,className:"recharts-cartesian-grid-bg"})});return d.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},v)}var Wr=function(t,n){var r=t.xAxis,i=t.width,a=t.height,o=t.offset;return Xe(Je(k(k(k({},tt.defaultProps),r),{},{ticks:et(r,!0),viewBox:{x:0,y:0,width:i,height:a}})),o.left,o.left+o.width,n)},qr=function(t,n){var r=t.yAxis,i=t.width,a=t.height,o=t.offset;return Xe(Je(k(k(k({},tt.defaultProps),r),{},{ticks:et(r,!0),viewBox:{x:0,y:0,width:i,height:a}})),o.top,o.top+o.height,n)},q={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function pt(e){var t,n,r,i,a,o,c=Lt(),f=Dt(),l=zt(),s=k(k({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:q.stroke,fill:(n=e.fill)!==null&&n!==void 0?n:q.fill,horizontal:(r=e.horizontal)!==null&&r!==void 0?r:q.horizontal,horizontalFill:(i=e.horizontalFill)!==null&&i!==void 0?i:q.horizontalFill,vertical:(a=e.vertical)!==null&&a!==void 0?a:q.vertical,verticalFill:(o=e.verticalFill)!==null&&o!==void 0?o:q.verticalFill,x:w(e.x)?e.x:l.left,y:w(e.y)?e.y:l.top,width:w(e.width)?e.width:l.width,height:w(e.height)?e.height:l.height}),v=s.x,p=s.y,y=s.width,m=s.height,h=s.syncWithTicks,g=s.horizontalValues,x=s.verticalValues,A=Ft(),P=Bt();if(!w(y)||y<=0||!w(m)||m<=0||!w(v)||v!==+v||!w(p)||p!==+p)return null;var C=s.verticalCoordinatesGenerator||Wr,S=s.horizontalCoordinatesGenerator||qr,_=s.horizontalPoints,N=s.verticalPoints;if((!_||!_.length)&&I(S)){var j=g&&g.length,R=S({yAxis:P?k(k({},P),{},{ticks:j?g:P.ticks}):void 0,width:c,height:f,offset:l},j?!0:h);le(Array.isArray(R),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(W(R),"]")),Array.isArray(R)&&(_=R)}if((!N||!N.length)&&I(C)){var T=x&&x.length,L=C({xAxis:A?k(k({},A),{},{ticks:T?x:A.ticks}):void 0,width:c,height:f,offset:l},T?!0:h);le(Array.isArray(L),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(W(L),"]")),Array.isArray(L)&&(N=L)}return d.createElement("g",{className:"recharts-cartesian-grid"},d.createElement(Br,{fill:s.fill,fillOpacity:s.fillOpacity,x:s.x,y:s.y,width:s.width,height:s.height,ry:s.ry}),d.createElement(Mr,G({},s,{offset:l,horizontalPoints:_,xAxis:A,yAxis:P})),d.createElement(Kr,G({},s,{offset:l,verticalPoints:N,xAxis:A,yAxis:P})),d.createElement(Vr,G({},s,{horizontalPoints:_})),d.createElement(Gr,G({},s,{verticalPoints:N})))}pt.displayName="CartesianGrid";var Hr=rt({chartName:"BarChart",GraphicalChild:oe,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:nt},{axisType:"yAxis",AxisComp:it}],formatAxisMap:Mt}),Ur=rt({chartName:"PieChart",GraphicalChild:z,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:me},{axisType:"radiusAxis",AxisComp:pe}],formatAxisMap:Kt,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});function Yr({data:e}){const t=e.map(n=>({...n,dateLabel:At(new Date(n.date),"MMM d")}));return u.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[u.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Daily Activity"}),u.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Messages, sessions, and tool calls per day"}),u.jsx("div",{className:"mt-4 h-64",children:u.jsx(at,{width:"100%",height:"100%",children:u.jsxs(Hr,{data:t,children:[u.jsx(pt,{strokeDasharray:"3 3",stroke:"#1f2937"}),u.jsx(nt,{dataKey:"dateLabel",tick:{fill:"#6b7280",fontSize:10},tickLine:!1}),u.jsx(it,{tick:{fill:"#6b7280",fontSize:10},tickLine:!1,axisLine:!1}),u.jsx(ot,{contentStyle:{backgroundColor:"#111827",border:"1px solid #374151",borderRadius:"8px",fontSize:"12px"}}),u.jsx(oe,{dataKey:"messageCount",name:"Messages",fill:"#3b82f6",radius:[2,2,0,0]}),u.jsx(oe,{dataKey:"toolCallCount",name:"Tool Calls",fill:"#8b5cf6",radius:[2,2,0,0]}),u.jsx(oe,{dataKey:"sessionCount",name:"Sessions",fill:"#10b981",radius:[2,2,0,0]})]})})})]})}const Ge=["#3b82f6","#8b5cf6","#10b981","#f59e0b","#ef4444","#6366f1"];function Zr({data:e}){const t=Object.entries(e).map(([n,r])=>({name:n.replace(/^claude-/,"").split("-202")[0],fullName:n,totalTokens:r.inputTokens+r.outputTokens,outputTokens:r.outputTokens}));return t.sort((n,r)=>r.totalTokens-n.totalTokens),u.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[u.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Model Usage"}),u.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Token usage by model"}),u.jsx("div",{className:"mt-4 h-64",children:u.jsx(at,{width:"100%",height:"100%",children:u.jsxs(Ur,{children:[u.jsx(z,{data:t,cx:"50%",cy:"50%",innerRadius:50,outerRadius:80,dataKey:"totalTokens",nameKey:"name",strokeWidth:0,children:t.map((n,r)=>u.jsx(Qe,{fill:Ge[r%Ge.length],opacity:.8},r))}),u.jsx(ot,{formatter:n=>qe(n),contentStyle:{backgroundColor:"#111827",border:"1px solid #374151",borderRadius:"8px",fontSize:"12px"}}),u.jsx(Vt,{wrapperStyle:{fontSize:"11px"}})]})})})]})}function Qr({hourCounts:e}){const t=Array.from({length:24},(r,i)=>({hour:i,label:`${i.toString().padStart(2,"0")}:00`,count:e[String(i)]??0})),n=Math.max(...t.map(r=>r.count),1);return u.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[u.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Hourly Distribution"}),u.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Session starts by hour of day"}),u.jsx("div",{className:"mt-4 flex items-end gap-0.5",style:{height:"120px"},children:t.map(r=>{const i=r.count>0?Math.max(r.count/n*100,4):0,a=r.count/n;return u.jsxs("div",{className:"group relative flex-1",style:{height:"100%"},children:[u.jsx("div",{className:"absolute bottom-0 w-full rounded-t transition-colors",style:{height:`${i}%`,backgroundColor:`rgba(59, 130, 246, ${.2+a*.6})`}}),u.jsxs("div",{className:"absolute -top-8 left-1/2 hidden -translate-x-1/2 whitespace-nowrap rounded bg-gray-800 px-1.5 py-0.5 text-[10px] text-gray-300 group-hover:block",children:[r.label,": ",r.count]})]},r.hour)})}),u.jsxs("div",{className:"mt-1 flex justify-between text-[10px] text-gray-600",children:[u.jsx("span",{children:"00:00"}),u.jsx("span",{children:"06:00"}),u.jsx("span",{children:"12:00"}),u.jsx("span",{children:"18:00"}),u.jsx("span",{children:"23:00"})]})]})}const Xr={};function an(){const{data:e,isLoading:t}=xt(qt),n=de.useMemo(()=>{if(!e)return Xr;const a={};for(const[o,c]of Object.entries(e.modelUsage))a[o]={inputTokens:c.inputTokens,outputTokens:c.outputTokens,cacheReadInputTokens:c.cacheReadInputTokens,cacheCreationInputTokens:c.cacheCreationInputTokens};return a},[e]),{cost:r}=Gt(n);if(t)return u.jsxs("div",{className:"space-y-4",children:[u.jsx("div",{className:"h-8 w-32 animate-pulse rounded bg-gray-800"}),Array.from({length:3}).map((a,o)=>u.jsx("div",{className:"h-64 animate-pulse rounded-xl bg-gray-900/50"},o))]});if(!e)return u.jsx("div",{className:"py-12 text-center text-sm text-gray-500",children:"No stats data found. Check ~/.claude/stats-cache.json"});const i=Object.values(e.modelUsage).reduce((a,o)=>a+o.inputTokens+o.outputTokens,0);return u.jsxs("div",{children:[u.jsx("h1",{className:"text-2xl font-bold text-white",children:"Stats"}),u.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:["Aggregate usage from ",e.firstSessionDate?.split("T")[0]," to"," ",e.lastComputedDate]}),u.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-3 md:grid-cols-5",children:[u.jsx(ee,{label:"Total Sessions",value:String(e.totalSessions)}),u.jsx(ee,{label:"Total Messages",value:e.totalMessages.toLocaleString()}),u.jsx(ee,{label:"Total Tokens",value:qe(i),sub:r?`~${_e(r.totalUSD)}`:void 0}),u.jsx(ee,{label:"Total Estimated Cost",value:r?`~${_e(r.totalUSD)}`:"N/A"}),u.jsx(ee,{label:"Longest Session",value:Ot(e.longestSession.duration),sub:`${e.longestSession.messageCount} messages`})]}),u.jsx("div",{className:"mt-6",children:u.jsx(Yr,{data:e.dailyActivity})}),u.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 md:grid-cols-2",children:[u.jsx(Zr,{data:e.modelUsage}),u.jsx(Qr,{hourCounts:e.hourCounts})]})]})}function ee({label:e,value:t,sub:n}){return u.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[u.jsx("p",{className:"text-xs text-gray-400",children:e}),u.jsx("p",{className:"mt-1 text-xl font-bold text-white",children:t}),n&&u.jsx("p",{className:"mt-0.5 text-xs text-gray-500",children:n})]})}export{an as component};
|