@hasna/economy 0.2.40 → 0.2.42
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/CHANGELOG.md +30 -0
- package/CODE_OF_CONDUCT.md +23 -0
- package/CONTRIBUTING.md +39 -0
- package/README.md +4 -0
- package/SECURITY.md +31 -0
- package/dashboard/dist/assets/charts-BtCbslx4.js +36 -0
- package/dashboard/dist/assets/index-BDmtt3RI.css +1 -0
- package/dashboard/dist/assets/index-BFwRLqg7.js +6 -0
- package/dashboard/dist/assets/vendor-Cz8jb743.js +53 -0
- package/dashboard/dist/index.html +16 -0
- package/dashboard/dist/logo.jpg +0 -0
- package/dashboard/dist/vite.svg +1 -0
- package/dist/cli/commands/extras.d.ts.map +1 -1
- package/dist/cli/index.js +379 -77
- package/dist/db/database.d.ts +4 -3
- package/dist/db/database.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +299 -49
- package/dist/lib/fleet-sync.d.ts +61 -0
- package/dist/lib/fleet-sync.d.ts.map +1 -0
- package/dist/mcp/index.js +66 -16
- package/dist/otel/index.js +41 -5
- package/dist/server/index.js +68 -17
- package/dist/server/serve.d.ts.map +1 -1
- package/dist/storage.js +2746 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +15 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-space-x-reverse:0}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-red-950:oklch(25.8% .092 26.042);--color-orange-100:oklch(95.4% .038 75.164);--color-orange-200:oklch(90.1% .076 70.697);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-800:oklch(47% .157 37.304);--color-orange-900:oklch(40.8% .123 38.172);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-800:oklch(47.3% .137 46.201);--color-amber-900:oklch(41.4% .112 45.904);--color-amber-950:oklch(27.9% .077 45.635);--color-yellow-100:oklch(97.3% .071 103.193);--color-yellow-200:oklch(94.5% .129 101.54);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-yellow-600:oklch(68.1% .162 75.834);--color-yellow-800:oklch(47.6% .114 61.907);--color-yellow-900:oklch(42.1% .095 57.708);--color-green-100:oklch(96.2% .044 156.743);--color-green-200:oklch(92.5% .084 155.995);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-800:oklch(44.8% .119 151.328);--color-green-900:oklch(39.3% .095 152.535);--color-emerald-100:oklch(95% .052 163.051);--color-emerald-200:oklch(90.5% .093 164.15);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-800:oklch(43.2% .095 166.913);--color-emerald-900:oklch(37.8% .077 168.94);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-800:oklch(42.4% .199 265.638);--color-blue-900:oklch(37.9% .146 265.522);--color-violet-100:oklch(94.3% .029 294.588);--color-violet-200:oklch(89.4% .057 293.283);--color-violet-800:oklch(43.2% .232 292.759);--color-violet-900:oklch(38% .189 293.745);--color-purple-500:oklch(62.7% .265 303.9);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-md:28rem;--container-lg:32rem;--container-3xl:48rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tight:-.025em;--animate-spin:spin 1s linear infinite;--aspect-video:16 / 9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-primary:var(--primary);--color-border:var(--border)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{border-color:var(--border)}body{background-color:var(--background);color:var(--foreground);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}}@layer components;@layer utilities{.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.inset-0{inset:calc(var(--spacing) * 0)}.end{inset-inline-end:var(--spacing)}.top-2\.5{top:calc(var(--spacing) * 2.5)}.top-4{top:calc(var(--spacing) * 4)}.top-\[50\%\]{top:50%}.right-2{right:calc(var(--spacing) * 2)}.right-4{right:calc(var(--spacing) * 4)}.bottom-6{bottom:calc(var(--spacing) * 6)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing) * 2)}.left-2\.5{left:calc(var(--spacing) * 2.5)}.left-\[50\%\]{left:50%}.z-10{z-index:10}.z-50{z-index:50}.m-4{margin:calc(var(--spacing) * 4)}.-mx-1{margin-inline:calc(var(--spacing) * -1)}.mx-auto{margin-inline:auto}.my-1{margin-block:calc(var(--spacing) * 1)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mr-1{margin-right:calc(var(--spacing) * 1)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.ml-1{margin-left:calc(var(--spacing) * 1)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline-flex{display:inline-flex}.table{display:table}.aspect-auto{aspect-ratio:auto}.aspect-video{aspect-ratio:var(--aspect-video)}.size-3{width:calc(var(--spacing) * 3);height:calc(var(--spacing) * 3)}.size-3\.5{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.size-4{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.size-5{width:calc(var(--spacing) * 5);height:calc(var(--spacing) * 5)}.size-7{width:calc(var(--spacing) * 7);height:calc(var(--spacing) * 7)}.size-8{width:calc(var(--spacing) * 8);height:calc(var(--spacing) * 8)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-10{height:calc(var(--spacing) * 10)}.h-14{height:calc(var(--spacing) * 14)}.h-24{height:calc(var(--spacing) * 24)}.h-\[280px\]{height:280px}.h-\[300px\]{height:300px}.h-\[var\(--radix-select-trigger-height\)\]{height:var(--radix-select-trigger-height)}.h-full{height:100%}.h-px{height:1px}.max-h-96{max-height:calc(var(--spacing) * 96)}.max-h-\[80vh\]{max-height:80vh}.min-h-screen{min-height:100vh}.w-0{width:calc(var(--spacing) * 0)}.w-1{width:calc(var(--spacing) * 1)}.w-2{width:calc(var(--spacing) * 2)}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-4{width:calc(var(--spacing) * 4)}.w-8{width:calc(var(--spacing) * 8)}.w-9{width:calc(var(--spacing) * 9)}.w-10{width:calc(var(--spacing) * 10)}.w-16{width:calc(var(--spacing) * 16)}.w-20{width:calc(var(--spacing) * 20)}.w-48{width:calc(var(--spacing) * 48)}.w-52{width:calc(var(--spacing) * 52)}.w-auto{width:auto}.w-full{width:100%}.w-max{width:max-content}.max-w-3xl{max-width:var(--container-3xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-\[200px\]{max-width:200px}.max-w-\[280px\]{max-width:280px}.max-w-lg{max-width:var(--container-lg)}.max-w-max{max-width:max-content}.max-w-xs{max-width:var(--container-xs)}.min-w-\[8rem\]{min-width:8rem}.min-w-\[44px\]{min-width:44px}.min-w-\[80px\]{min-width:80px}.min-w-\[var\(--radix-select-trigger-width\)\]{min-width:var(--radix-select-trigger-width)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.caption-bottom{caption-side:bottom}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-\[-50\%\]{--tw-translate-x:-50%;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-1{--tw-translate-y:calc(var(--spacing) * 1);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-\[-50\%\]{--tw-translate-y:-50%;translate:var(--tw-translate-x) var(--tw-translate-y)}.scale-0{--tw-scale-x:0%;--tw-scale-y:0%;--tw-scale-z:0%;scale:var(--tw-scale-x) var(--tw-scale-y)}.scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x) var(--tw-scale-y)}.rotate-0{rotate:none}.rotate-90{rotate:90deg}.animate-in{animation:.2s ease-out enter}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-0>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 0) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 0) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.rounded{border-radius:.25rem}.rounded-\[2px\]{border-radius:2px}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.rounded-l-md{border-top-left-radius:calc(var(--radius) - 2px);border-bottom-left-radius:calc(var(--radius) - 2px)}.rounded-r-md{border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-\[1\.5px\]{border-style:var(--tw-border-style);border-width:1.5px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-\[--color-border\]{border-color:--color-border}.border-amber-200{border-color:var(--color-amber-200)}.border-border\/50{border-color:var(--border)}@supports (color:color-mix(in lab,red,red)){.border-border\/50{border-color:color-mix(in oklab,var(--border) 50%,transparent)}}.border-input{border-color:var(--input)}.border-muted-foreground{border-color:var(--muted-foreground)}.border-primary{border-color:var(--primary)}.border-red-200{border-color:var(--color-red-200)}.border-transparent{border-color:#0000}.border-t-transparent{border-top-color:#0000}.bg-\[--color-bg\]{background-color:--color-bg}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-100{background-color:var(--color-amber-100)}.bg-background{background-color:var(--background)}.bg-black\/80{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.bg-black\/80{background-color:color-mix(in oklab,var(--color-black) 80%,transparent)}}.bg-blue-100{background-color:var(--color-blue-100)}.bg-card{background-color:var(--card)}.bg-destructive{background-color:var(--destructive)}.bg-emerald-100{background-color:var(--color-emerald-100)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-green-100{background-color:var(--color-green-100)}.bg-green-500{background-color:var(--color-green-500)}.bg-muted,.bg-muted\/50{background-color:var(--muted)}@supports (color:color-mix(in lab,red,red)){.bg-muted\/50{background-color:color-mix(in oklab,var(--muted) 50%,transparent)}}.bg-orange-100{background-color:var(--color-orange-100)}.bg-popover{background-color:var(--popover)}.bg-primary{background-color:var(--primary)}.bg-red-50{background-color:var(--color-red-50)}.bg-red-100{background-color:var(--color-red-100)}.bg-red-500{background-color:var(--color-red-500)}.bg-secondary{background-color:var(--secondary)}.bg-transparent{background-color:#0000}.bg-violet-100{background-color:var(--color-violet-100)}.bg-yellow-100{background-color:var(--color-yellow-100)}.bg-yellow-500{background-color:var(--color-yellow-500)}.p-1{padding:calc(var(--spacing) * 1)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-6{padding-inline:calc(var(--spacing) * 6)}.px-8{padding-inline:calc(var(--spacing) * 8)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-12{padding-block:calc(var(--spacing) * 12)}.pt-0{padding-top:calc(var(--spacing) * 0)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-6{padding-top:calc(var(--spacing) * 6)}.pr-2{padding-right:calc(var(--spacing) * 2)}.pr-8{padding-right:calc(var(--spacing) * 8)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pl-2{padding-left:calc(var(--spacing) * 2)}.pl-8{padding-left:calc(var(--spacing) * 8)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.leading-none{--tw-leading:1;line-height:1}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.whitespace-nowrap{white-space:nowrap}.text-amber-500{color:var(--color-amber-500)}.text-amber-800{color:var(--color-amber-800)}.text-amber-900{color:var(--color-amber-900)}.text-blue-500{color:var(--color-blue-500)}.text-blue-800{color:var(--color-blue-800)}.text-card-foreground{color:var(--card-foreground)}.text-current{color:currentColor}.text-emerald-500{color:var(--color-emerald-500)}.text-emerald-800{color:var(--color-emerald-800)}.text-foreground{color:var(--foreground)}.text-gray-700{color:var(--color-gray-700)}.text-green-500{color:var(--color-green-500)}.text-green-600{color:var(--color-green-600)}.text-green-800{color:var(--color-green-800)}.text-muted-foreground,.text-muted-foreground\/60{color:var(--muted-foreground)}@supports (color:color-mix(in lab,red,red)){.text-muted-foreground\/60{color:color-mix(in oklab,var(--muted-foreground) 60%,transparent)}}.text-orange-500{color:var(--color-orange-500)}.text-orange-800{color:var(--color-orange-800)}.text-popover-foreground{color:var(--popover-foreground)}.text-primary{color:var(--primary)}.text-primary-foreground{color:var(--primary-foreground)}.text-purple-500{color:var(--color-purple-500)}.text-red-600{color:var(--color-red-600)}.text-red-800{color:var(--color-red-800)}.text-secondary-foreground{color:var(--secondary-foreground)}.text-violet-800{color:var(--color-violet-800)}.text-white{color:var(--color-white)}.text-yellow-600{color:var(--color-yellow-600)}.text-yellow-800{color:var(--color-yellow-800)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.underline-offset-4{text-underline-offset:4px}.opacity-50{opacity:.5}.opacity-70{opacity:.7}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-offset-background{--tw-ring-offset-color:var(--background)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.file\:border-0::file-selector-button{border-style:var(--tw-border-style);border-width:0}.file\:bg-transparent::file-selector-button{background-color:#0000}.file\:text-sm::file-selector-button{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.file\:font-medium::file-selector-button{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.file\:text-foreground::file-selector-button{color:var(--foreground)}.placeholder\:text-muted-foreground::placeholder{color:var(--muted-foreground)}@media(hover:hover){.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-destructive\/90:hover{background-color:var(--destructive)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-destructive\/90:hover{background-color:color-mix(in oklab,var(--destructive) 90%,transparent)}}.hover\:bg-muted:hover,.hover\:bg-muted\/50:hover{background-color:var(--muted)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-muted\/50:hover{background-color:color-mix(in oklab,var(--muted) 50%,transparent)}}.hover\:bg-primary\/90:hover{background-color:var(--primary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-primary\/90:hover{background-color:color-mix(in oklab,var(--primary) 90%,transparent)}}.hover\:bg-secondary\/80:hover{background-color:var(--secondary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-secondary\/80:hover{background-color:color-mix(in oklab,var(--secondary) 80%,transparent)}}.hover\:text-accent-foreground:hover{color:var(--accent-foreground)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-80:hover{opacity:.8}.hover\:opacity-100:hover{opacity:1}}.focus\:bg-accent:focus{background-color:var(--accent)}.focus\:text-accent-foreground:focus{color:var(--accent-foreground)}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-ring:focus{--tw-ring-color:var(--ring)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-1:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-ring:focus-visible{--tw-ring-color:var(--ring)}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}.focus-visible\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.data-\[active\]\:bg-accent\/50[data-active]{background-color:var(--accent)}@supports (color:color-mix(in lab,red,red)){.data-\[active\]\:bg-accent\/50[data-active]{background-color:color-mix(in oklab,var(--accent) 50%,transparent)}}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[state\=checked\]\:bg-primary[data-state=checked]{background-color:var(--primary)}.data-\[state\=checked\]\:text-primary-foreground[data-state=checked]{color:var(--primary-foreground)}.data-\[state\=closed\]\:animate-out[data-state=closed]{animation:.15s ease-in exit}.data-\[state\=open\]\:animate-in[data-state=open]{animation:.2s ease-out enter}.data-\[state\=open\]\:bg-accent[data-state=open],.data-\[state\=open\]\:bg-accent\/50[data-state=open]{background-color:var(--accent)}@supports (color:color-mix(in lab,red,red)){.data-\[state\=open\]\:bg-accent\/50[data-state=open]{background-color:color-mix(in oklab,var(--accent) 50%,transparent)}}.data-\[state\=open\]\:text-muted-foreground[data-state=open]{color:var(--muted-foreground)}.data-\[state\=selected\]\:bg-muted[data-state=selected]{background-color:var(--muted)}@media(min-width:40rem){.sm\:inline{display:inline}.sm\:max-w-md{max-width:var(--container-md)}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:justify-end{justify-content:flex-end}:where(.sm\:space-x-2>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(calc(var(--spacing) * 2) * var(--tw-space-x-reverse));margin-inline-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-x-reverse)))}.sm\:rounded-lg{border-radius:var(--radius)}.sm\:text-left{text-align:left}}@media(min-width:48rem){.md\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}@media(min-width:64rem){.lg\:col-span-2{grid-column:span 2/span 2}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}}@media(prefers-color-scheme:dark){.dark\:scale-0{--tw-scale-x:0%;--tw-scale-y:0%;--tw-scale-z:0%;scale:var(--tw-scale-x) var(--tw-scale-y)}.dark\:scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x) var(--tw-scale-y)}.dark\:-rotate-90{rotate:-90deg}.dark\:rotate-0{rotate:none}.dark\:border-amber-900{border-color:var(--color-amber-900)}.dark\:border-red-900{border-color:var(--color-red-900)}.dark\:bg-amber-900\/40{background-color:#7b330666}@supports (color:color-mix(in lab,red,red)){.dark\:bg-amber-900\/40{background-color:color-mix(in oklab,var(--color-amber-900) 40%,transparent)}}.dark\:bg-amber-950{background-color:var(--color-amber-950)}.dark\:bg-blue-900{background-color:var(--color-blue-900)}.dark\:bg-emerald-900{background-color:var(--color-emerald-900)}.dark\:bg-gray-800{background-color:var(--color-gray-800)}.dark\:bg-green-900{background-color:var(--color-green-900)}.dark\:bg-input\/30{background-color:var(--input)}@supports (color:color-mix(in lab,red,red)){.dark\:bg-input\/30{background-color:color-mix(in oklab,var(--input) 30%,transparent)}}.dark\:bg-orange-900{background-color:var(--color-orange-900)}.dark\:bg-red-900{background-color:var(--color-red-900)}.dark\:bg-red-950{background-color:var(--color-red-950)}.dark\:bg-violet-900{background-color:var(--color-violet-900)}.dark\:bg-yellow-900{background-color:var(--color-yellow-900)}.dark\:text-amber-200{color:var(--color-amber-200)}.dark\:text-amber-300{color:var(--color-amber-300)}.dark\:text-blue-200{color:var(--color-blue-200)}.dark\:text-emerald-200{color:var(--color-emerald-200)}.dark\:text-gray-300{color:var(--color-gray-300)}.dark\:text-green-200{color:var(--color-green-200)}.dark\:text-green-400{color:var(--color-green-400)}.dark\:text-orange-200{color:var(--color-orange-200)}.dark\:text-red-200{color:var(--color-red-200)}.dark\:text-red-400{color:var(--color-red-400)}.dark\:text-violet-200{color:var(--color-violet-200)}.dark\:text-yellow-200{color:var(--color-yellow-200)}.dark\:text-yellow-400{color:var(--color-yellow-400)}}.\[\&_\.recharts-cartesian-axis-tick_text\]\:fill-muted-foreground .recharts-cartesian-axis-tick text{fill:var(--muted-foreground)}.\[\&_\.recharts-cartesian-grid_line\[stroke\=\'\#ccc\'\]\]\:stroke-border\/50 .recharts-cartesian-grid line[stroke="#ccc"]{stroke:var(--border)}@supports (color:color-mix(in lab,red,red)){.\[\&_\.recharts-cartesian-grid_line\[stroke\=\'\#ccc\'\]\]\:stroke-border\/50 .recharts-cartesian-grid line[stroke="#ccc"]{stroke:color-mix(in oklab,var(--border) 50%,transparent)}}.\[\&_\.recharts-curve\.recharts-tooltip-cursor\]\:stroke-border .recharts-curve.recharts-tooltip-cursor,.\[\&_\.recharts-polar-grid_\[stroke\=\'\#ccc\'\]\]\:stroke-border .recharts-polar-grid [stroke="#ccc"]{stroke:var(--border)}.\[\&_\.recharts-rectangle\.recharts-tooltip-cursor\]\:fill-muted\/50 .recharts-rectangle.recharts-tooltip-cursor{fill:var(--muted)}@supports (color:color-mix(in lab,red,red)){.\[\&_\.recharts-rectangle\.recharts-tooltip-cursor\]\:fill-muted\/50 .recharts-rectangle.recharts-tooltip-cursor{fill:color-mix(in oklab,var(--muted) 50%,transparent)}}.\[\&_\.recharts-reference-line_\[stroke\=\'\#ccc\'\]\]\:stroke-border .recharts-reference-line [stroke="#ccc"]{stroke:var(--border)}.\[\&_\.recharts-sector\]\:outline-none .recharts-sector{--tw-outline-style:none;outline-style:none}.\[\&_\.recharts-sector\[stroke\=\'\#fff\'\]\]\:stroke-transparent .recharts-sector[stroke="#fff"]{stroke:#0000}.\[\&_\.recharts-surface\]\:outline-none .recharts-surface{--tw-outline-style:none;outline-style:none}.\[\&_svg\]\:pointer-events-none svg{pointer-events:none}.\[\&_svg\]\:size-4 svg{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.\[\&_svg\]\:shrink-0 svg{flex-shrink:0}.\[\&_tr\]\:border-b tr{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-style:var(--tw-border-style);border-width:0}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:calc(var(--spacing) * 0)}.\[\&\>\[role\=checkbox\]\]\:translate-y-\[2px\]>[role=checkbox]{--tw-translate-y:2px;translate:var(--tw-translate-x) var(--tw-translate-y)}.\[\&\>span\]\:line-clamp-1>span{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.\[\&\>svg\]\:size-4>svg{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.\[\&\>svg\]\:h-2\.5>svg{height:calc(var(--spacing) * 2.5)}.\[\&\>svg\]\:h-3>svg{height:calc(var(--spacing) * 3)}.\[\&\>svg\]\:w-2\.5>svg{width:calc(var(--spacing) * 2.5)}.\[\&\>svg\]\:w-3>svg{width:calc(var(--spacing) * 3)}.\[\&\>svg\]\:shrink-0>svg{flex-shrink:0}.\[\&\>svg\]\:text-muted-foreground>svg{color:var(--muted-foreground)}.\[\&\>tr\]\:last\:border-b-0>tr:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}}@keyframes enter{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes exit{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}:root{--radius:.625rem;--background:oklch(100% 0 0);--foreground:oklch(14.5% 0 0);--card:oklch(100% 0 0);--card-foreground:oklch(14.5% 0 0);--popover:oklch(100% 0 0);--popover-foreground:oklch(14.5% 0 0);--primary:oklch(20.5% 0 0);--primary-foreground:oklch(98.5% 0 0);--secondary:oklch(96.5% 0 0);--secondary-foreground:oklch(20.5% 0 0);--muted:oklch(96.5% 0 0);--muted-foreground:oklch(55.6% 0 0);--accent:oklch(96.5% 0 0);--accent-foreground:oklch(20.5% 0 0);--destructive:oklch(57.7% .245 27.325);--border:oklch(92.1% 0 0);--input:oklch(92.1% 0 0);--ring:oklch(70.8% 0 0);--chart-1:221 83% 53%;--chart-2:24 95% 53%;--chart-3:142 76% 36%;--chart-4:262 83% 58%;--chart-5:0 84% 60%}.dark{--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(17.5% 0 0);--card-foreground:oklch(98.5% 0 0);--popover:oklch(17.5% 0 0);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(98.5% 0 0);--primary-foreground:oklch(20.5% 0 0);--secondary:oklch(26.9% 0 0);--secondary-foreground:oklch(98.5% 0 0);--muted:oklch(26.9% 0 0);--muted-foreground:oklch(70.8% 0 0);--accent:oklch(26.9% 0 0);--accent-foreground:oklch(98.5% 0 0);--destructive:oklch(39.6% .141 25.723);--border:oklch(26.9% 0 0);--input:oklch(26.9% 0 0);--ring:oklch(43.9% 0 0);--chart-1:221 83% 53%;--chart-2:24 95% 53%;--chart-3:142 76% 36%;--chart-4:262 83% 58%;--chart-5:0 84% 60%}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-space-x-reverse{syntax:"*";inherits:false;initial-value:0}@keyframes spin{to{transform:rotate(360deg)}}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a3 as ws,c as Cs,r as t,a4 as e,a5 as Ds,a6 as $s,a7 as Ls,a8 as Ts,a9 as Es,aa as Ps,ab as qe,ac as Ms,ad as Rs,ae as Fs,af as As,ag as Xe,ah as Ye,ai as zs,aj as ne,ak as Is,al as Us,am as Ze,an as qs,ao as is,ap as _e,aq as Bs,ar as Os,as as Gs,at as Ks,au as Ws,av as Hs,aw as Vs,ax as Js,ay as Xs,az as Ys,aA as Zs,aB as Qs,aC as et,aD as st,aE as tt,aF as at,aG as rt,aH as nt,aI as lt,aJ as it,aK as Be,aL as cs,aM as os,aN as ct,aO as ot,aP as dt,aQ as ut,aR as mt,aS as xt,aT as ht,aU as we,aV as Oe,aW as Ce,aX as gt,aY as ds,aZ as ft,a_ as pt,a$ as jt,b0 as bt,b1 as Nt,b2 as vt,b3 as yt,b4 as St}from"./vendor-Cz8jb743.js";import{R as kt,T as _t,L as wt,a as Ct,C as ve,X as ye,Y as Se,b as Dt,B as Ge,c as Ke}from"./charts-BtCbslx4.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))c(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const x of u.addedNodes)x.tagName==="LINK"&&x.rel==="modulepreload"&&c(x)}).observe(document,{childList:!0,subtree:!0});function r(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function c(l){if(l.ep)return;l.ep=!0;const u=r(l);fetch(l.href,u)}})();function S(...s){return ws(Cs(s))}const $t=Ds("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-white shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),C=t.forwardRef(({className:s,variant:a,size:r,...c},l)=>e.jsx("button",{className:S($t({variant:a,size:r,className:s})),ref:l,...c}));C.displayName="Button";const us=Fs,ms=As,We=t.forwardRef(({className:s,sideOffset:a=4,...r},c)=>e.jsx($s,{children:e.jsx(Ls,{ref:c,sideOffset:a,className:S("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in",s),...r})}));We.displayName="DropdownMenuContent";const ue=t.forwardRef(({className:s,inset:a,...r},c)=>e.jsx(Ts,{ref:c,className:S("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",a&&"pl-8",s),...r}));ue.displayName="DropdownMenuItem";const Lt=t.forwardRef(({className:s,children:a,checked:r,...c},l)=>e.jsxs(Es,{ref:l,className:S("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:r,...c,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ps,{children:e.jsx(qe,{className:"h-4 w-4"})})}),a]}));Lt.displayName="DropdownMenuCheckboxItem";const Tt=t.forwardRef(({className:s,inset:a,...r},c)=>e.jsx(Ms,{ref:c,className:S("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",s),...r}));Tt.displayName="DropdownMenuLabel";const Et=t.forwardRef(({className:s,...a},r)=>e.jsx(Rs,{ref:r,className:S("-mx-1 my-1 h-px bg-muted",s),...a}));Et.displayName="DropdownMenuSeparator";const xs=t.createContext(void 0);function Pt(){const s=t.useContext(xs);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s}function Mt(){const{setTheme:s}=Pt();return e.jsxs(us,{children:[e.jsx(ms,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"icon",className:"size-8",children:[e.jsx(Xe,{className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(Ye,{className:"absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),e.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),e.jsxs(We,{align:"end",children:[e.jsxs(ue,{onClick:()=>s("light"),children:[e.jsx(Xe,{className:"mr-2 h-4 w-4"})," Light"]}),e.jsxs(ue,{onClick:()=>s("dark"),children:[e.jsx(Ye,{className:"mr-2 h-4 w-4"})," Dark"]}),e.jsxs(ue,{onClick:()=>s("system"),children:[e.jsx(zs,{className:"mr-2 h-4 w-4"})," System"]})]})]})}function Rt({children:s,defaultTheme:a="system",storageKey:r="economy-dashboard-theme",...c}){const[l,u]=t.useState(()=>localStorage.getItem(r)||a);t.useEffect(()=>{const m=window.document.documentElement;if(m.classList.remove("light","dark"),l==="system"){const d=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";m.classList.add(d);return}m.classList.add(l)},[l]);const x={theme:l,setTheme:m=>{localStorage.setItem(r,m),u(m)}};return e.jsx(xs.Provider,{...c,value:x,children:s})}const Ft="http://localhost:3456",Qe=["claude","takumi","codex","gemini","opencode","cursor","pi","hermes"];async function T(s,a){const r=`${Ft}${s}`,c=await fetch(r,{headers:{"Content-Type":"application/json"},...a});if(!c.ok){const l=await c.text();throw new Error(`API error ${c.status}: ${l}`)}return c.json()}const Me=s=>T(`/api/summary?period=${s}`),At=(s=30)=>T(`/api/daily?days=${s}`),zt=s=>{const a=new URLSearchParams;return s.agent&&a.set("agent",s.agent),s.search&&a.set("search",s.search),s.account&&a.set("account",s.account),s.limit!=null&&a.set("limit",String(s.limit)),s.offset!=null&&a.set("offset",String(s.offset)),s.since&&a.set("since",s.since),T(`/api/sessions?${a}`)},It=s=>T(`/api/sessions/${encodeURIComponent(s)}/requests`),Ut=()=>T("/api/models"),qt=(s="all")=>T(`/api/projects?period=${s}`),hs=(s="all")=>T(`/api/accounts?period=${s}`),Bt=()=>T("/api/budgets"),Ot=s=>T("/api/budgets",{method:"POST",body:JSON.stringify(s)}),Gt=s=>T(`/api/budgets/${encodeURIComponent(s)}`,{method:"DELETE"}),Kt=()=>T("/api/pricing"),Wt=(s="month")=>T(`/api/billing?period=${s}`),Ht=(s="month",a=15)=>T(`/api/billing/diff?period=${s}&threshold=${a}`),gs=s=>T("/api/billing/sync",{method:"POST",body:JSON.stringify(s)}),Vt=s=>T("/api/pricing",{method:"POST",body:JSON.stringify(s)}),Jt=s=>T(`/api/pricing/${encodeURIComponent(s)}`,{method:"DELETE"}),Xt=(s="month",a)=>{const r=new URLSearchParams({period:s});return T(`/api/usage?${r}`)},Yt=(s="month",a)=>{const r=new URLSearchParams({period:s});return T(`/api/savings?${r}`)},Zt=()=>T("/api/subscriptions"),Qt=s=>T("/api/subscriptions",{method:"POST",body:JSON.stringify(s)}),ea=s=>T(`/api/subscriptions/${encodeURIComponent(s)}`,{method:"DELETE"}),sa=(s="month")=>T(`/api/fleet?period=${s}`),ta=(s="all")=>T("/api/sync",{method:"POST",body:JSON.stringify({sources:s})}),aa=()=>T("/api/goals"),ra=s=>T("/api/goals",{method:"POST",body:JSON.stringify(s)}),na=s=>T(`/api/goals/${encodeURIComponent(s)}`,{method:"DELETE"}),q=t.forwardRef(({className:s,...a},r)=>e.jsx("div",{ref:r,className:S("rounded-xl border bg-card text-card-foreground",s),...a}));q.displayName="Card";const B=t.forwardRef(({className:s,...a},r)=>e.jsx("div",{ref:r,className:S("flex flex-col space-y-1.5 p-6",s),...a}));B.displayName="CardHeader";const O=t.forwardRef(({className:s,...a},r)=>e.jsx("div",{ref:r,className:S("font-semibold leading-none tracking-tight",s),...a}));O.displayName="CardTitle";const la=t.forwardRef(({className:s,...a},r)=>e.jsx("div",{ref:r,className:S("text-sm text-muted-foreground",s),...a}));la.displayName="CardDescription";const G=t.forwardRef(({className:s,...a},r)=>e.jsx("div",{ref:r,className:S("p-6 pt-0",s),...a}));G.displayName="CardContent";const ia=t.forwardRef(({className:s,...a},r)=>e.jsx("div",{ref:r,className:S("flex items-center p-6 pt-0",s),...a}));ia.displayName="CardFooter";const fs=t.createContext(null);function ps(){const s=t.useContext(fs);if(!s)throw new Error("useChart must be used within a <ChartContainer />");return s}const De=t.forwardRef(({id:s,className:a,children:r,config:c,...l},u)=>{const x=t.useId(),m=`chart-${s||x.replace(/:/g,"")}`;return e.jsx(fs.Provider,{value:{config:c},children:e.jsxs("div",{"data-chart":m,ref:u,className:S("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted/50 [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",a),...l,children:[e.jsx(ca,{id:m,config:c}),e.jsx(kt,{children:r})]})})});De.displayName="ChartContainer";const ca=({id:s,config:a})=>{const r=Object.entries(a).filter(([,c])=>c.color);return r.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
2
|
+
[data-chart="${s}"] {
|
|
3
|
+
${r.map(([c,l])=>` --color-${c}: ${l.color};`).join(`
|
|
4
|
+
`)}
|
|
5
|
+
}
|
|
6
|
+
`}}):null},ke=_t,me=t.forwardRef(({active:s,payload:a,className:r,indicator:c="dot",hideLabel:l=!1,hideIndicator:u=!1,label:x,labelKey:m,nameKey:d,formatter:o},n)=>{const{config:f}=ps();return!s||!a?.length?null:e.jsxs("div",{ref:n,className:S("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[!l&&e.jsx("div",{className:"font-medium",children:m&&a[0]?.payload?String(a[0].payload[m]):x}),e.jsx("div",{className:"grid gap-1.5",children:a.map(v=>{const k=d?v.payload?.[d]:v.dataKey,w=f[k]||{label:k,color:v.color||"var(--color-primary)"},A=v.color||w.color;return e.jsxs("div",{className:"flex items-center gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",children:[!u&&e.jsx("div",{className:S("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":c==="dot","w-1 h-full":c==="line","w-0 border-[1.5px] border-dashed bg-transparent h-full":c==="dashed"}),style:{"--color-bg":A,"--color-border":A}}),e.jsxs("div",{className:"flex flex-1 justify-between items-center leading-none gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:w.label}),e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:o?o(v.value,k):v.value?.toLocaleString()})]})]},v.dataKey)})})]})});me.displayName="ChartTooltipContent";const es=wt,Ie=t.forwardRef(({className:s,payload:a,nameKey:r,...c},l)=>{const{config:u}=ps();return a?.length?e.jsx("div",{ref:l,className:S("flex items-center justify-center gap-4 pt-3",s),...c,children:a.map(x=>{const m=r?x.value:x.dataKey||x.value,d=u[m]||{label:m,color:x.color||"var(--color-primary)"};return e.jsxs("div",{className:"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground",children:[e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:x.color||d.color}}),e.jsx("span",{className:"text-muted-foreground",children:d.label})]},m)})}):null});Ie.displayName="ChartLegendContent";function de(s){return s==null?"$0.00":s>=.01?"$"+s.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):"$"+s.toFixed(6)}function oa(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}k`:s.toLocaleString("en-US")}function ge(s){return s.toLocaleString("en-US")}function da(s){return s.slice(5)}const ua={claude:"Claude",takumi:"Takumi",codex:"Codex",gemini:"Gemini",opencode:"OpenCode",cursor:"Cursor",pi:"Pi",hermes:"Hermes"},ss=["hsl(var(--chart-1, 221 83% 53%))","hsl(var(--chart-2, 24 95% 53%))","hsl(var(--chart-3, 142 71% 45%))","hsl(var(--chart-4, 262 83% 58%))","hsl(var(--chart-5, 340 75% 55%))","hsl(var(--chart-1, 221 83% 53%))","hsl(var(--chart-2, 24 95% 53%))","hsl(var(--chart-3, 142 71% 45%))"];function ma(s){const a=new Set,r=new Map;for(const u of s){a.add(u.agent);const x=u.date;r.has(x)||r.set(x,{date:da(x),rawDate:x});const m=r.get(x);m[u.agent]=Number(m[u.agent]??0)+u.cost_usd}const c=[...a].sort((u,x)=>{const m=Qe.indexOf(u),d=Qe.indexOf(x);return(m===-1?99:m)-(d===-1?99:d)});for(const u of r.values())for(const x of c)u[x]==null&&(u[x]=0);return{rows:Array.from(r.values()).sort((u,x)=>u.rawDate.localeCompare(x.rawDate)),agents:c}}function xa(s){const a={};return s.forEach((r,c)=>{a[r]={label:ua[r]??r,color:ss[c%ss.length]}}),a}function ha(s){const a=new Map;for(const l of s)a.set(l.date,(a.get(l.date)??0)+l.cost_usd);const r=[...a.entries()].sort((l,u)=>l[0].localeCompare(u[0])),c=new Set;for(let l=7;l<r.length;l++){const u=r.slice(l-7,l).map(m=>m[1]),x=u.reduce((m,d)=>m+d,0)/u.length;r[l][1]>x*2&&x>0&&c.add(r[l][0])}return{spikeDates:c,spikeCount:c.size}}function ga(){const[s,a]=t.useState(null),[r,c]=t.useState(null),[l,u]=t.useState(null),[x,m]=t.useState([]),[d,o]=t.useState([]),[n,f]=t.useState([]),[v,k]=t.useState(!0),[w,A]=t.useState(null),[_,M]=t.useState(!1),[R,E]=t.useState(null),[$,L]=t.useState("line"),[J,H]=t.useState(new Date),[z,i]=t.useState(""),[b,P]=t.useState(""),F=t.useRef(null),ae=t.useCallback(async()=>{k(!0),A(null);try{const[y,ce,Ee,he]=await Promise.all([Me("today"),Me("week"),Me("month"),At(30)]);a(y.data),c(ce.data),u(Ee.data),f(he.data);const ie=ma(he.data);m(ie.rows),o(ie.agents),H(new Date)}catch(y){A(y instanceof Error?y.message:"Failed to load data")}finally{k(!1)}},[]),te=t.useMemo(()=>!z&&!b?x:x.filter(y=>!(z&&y.rawDate<z||b&&y.rawDate>b)),[x,z,b]),se=t.useMemo(()=>xa(d),[d]),{spikeCount:ee}=t.useMemo(()=>ha(n),[n]);t.useEffect(()=>{const y=()=>ae();return queueMicrotask(y),F.current=setInterval(y,3e4),()=>{F.current&&clearInterval(F.current)}},[ae]);const N=async()=>{M(!0),E(null);try{await ta("all"),E("Sync complete"),ae()}catch(y){E(y instanceof Error?y.message:"Sync failed")}finally{M(!1),setTimeout(()=>E(null),3e3)}};if(v)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ne,{className:"size-5 animate-spin text-muted-foreground"})});if(w)return e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:w});const V=[{label:"Today",value:de(s?.total_usd??0),sub:`${ge(s?.sessions??0)} sessions`,icon:Is,color:"text-blue-500"},{label:"This Week",value:de(r?.total_usd??0),sub:`${ge(r?.sessions??0)} sessions`,icon:Us,color:"text-green-500"},{label:"This Month",value:de(l?.total_usd??0),sub:`${ge(l?.sessions??0)} sessions`,icon:Ze,color:"text-purple-500"},{label:"Monthly Requests",value:ge(l?.requests??0),sub:`${oa(l?.tokens??0)} tokens`,icon:qs,color:"text-orange-500"}],p=Math.round((Date.now()-J.getTime())/1e3),W=p<5?"just now":`${p}s ago`;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-2",children:ee>0&&e.jsxs("div",{className:"flex items-center gap-1.5 rounded-full bg-amber-100 px-3 py-1 text-xs font-medium text-amber-800 dark:bg-amber-900/40 dark:text-amber-300",children:[e.jsx(is,{className:"size-3.5"}),ee," spike ",ee===1?"day":"days"," detected"]})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last updated: ",W]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:V.map(y=>e.jsxs(q,{children:[e.jsxs(B,{className:"flex flex-row items-center justify-between space-y-0 pb-2 p-4",children:[e.jsx(O,{className:"text-sm font-medium text-muted-foreground",children:y.label}),e.jsx(y.icon,{className:`size-4 ${y.color}`})]}),e.jsxs(G,{className:"p-4 pt-0",children:[e.jsx("div",{className:"text-2xl font-bold",children:y.value}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:y.sub})]})]},y.label))}),e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(O,{className:"text-sm flex items-center gap-2",children:[e.jsx(Ze,{className:"size-4 text-blue-500"}),"Daily Cost — Last 30 Days"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"From:"}),e.jsx("input",{type:"date",value:z,onChange:y=>i(y.target.value),className:"h-7 rounded-md border border-input bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"To:"}),e.jsx("input",{type:"date",value:b,onChange:y=>P(y.target.value),className:"h-7 rounded-md border border-input bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(z||b)&&e.jsxs(C,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>{i(""),P("")},children:[e.jsx(_e,{className:"size-3 mr-1"}),"Clear"]})]}),e.jsxs("div",{className:"flex rounded-md border",children:[e.jsx("button",{className:`px-2.5 py-1 text-xs font-medium rounded-l-md transition-colors ${$==="line"?"bg-primary text-primary-foreground":"hover:bg-muted"}`,onClick:()=>L("line"),children:"Line"}),e.jsx("button",{className:`px-2.5 py-1 text-xs font-medium rounded-r-md transition-colors ${$==="bar"?"bg-primary text-primary-foreground":"hover:bg-muted"}`,onClick:()=>L("bar"),children:"Bar"})]}),R&&e.jsx("span",{className:"text-xs text-green-600 dark:text-green-400",children:R}),e.jsxs(C,{variant:"outline",size:"sm",onClick:N,disabled:_,children:[e.jsx(ne,{className:`size-3.5 ${_?"animate-spin":""}`}),_?"Syncing...":"Sync Now"]})]})]})}),e.jsx(G,{children:te.length===0?e.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No data available"}):e.jsx(De,{config:se,className:"aspect-auto h-[280px] w-full",children:$==="line"?e.jsxs(Ct,{data:te,margin:{top:4,right:16,left:0,bottom:4},children:[e.jsx(ve,{strokeDasharray:"3 3",vertical:!1}),e.jsx(ye,{dataKey:"date",tickLine:!1,axisLine:!1}),e.jsx(Se,{axisLine:!1,tickLine:!1,tickFormatter:y=>"$"+Number(y).toLocaleString("en-US",{maximumFractionDigits:0}),width:60}),e.jsx(ke,{content:e.jsx(me,{formatter:y=>de(y)})}),e.jsx(es,{content:e.jsx(Ie,{})}),d.map(y=>e.jsx(Dt,{type:"monotone",dataKey:y,stroke:`var(--color-${y})`,strokeWidth:2,dot:!1},y))]}):e.jsxs(Ge,{data:te,margin:{top:4,right:16,left:0,bottom:4},children:[e.jsx(ve,{strokeDasharray:"3 3",vertical:!1}),e.jsx(ye,{dataKey:"date",tickLine:!1,axisLine:!1}),e.jsx(Se,{axisLine:!1,tickLine:!1,tickFormatter:y=>"$"+Number(y).toLocaleString("en-US",{maximumFractionDigits:0}),width:60}),e.jsx(ke,{content:e.jsx(me,{formatter:y=>de(y)})}),e.jsx(es,{content:e.jsx(Ie,{})}),d.map((y,ce)=>e.jsx(Ke,{dataKey:y,fill:`var(--color-${y})`,radius:ce===d.length-1?[4,4,0,0]:[0,0,0,0],stackId:"cost"},y))]})})})]})]})}const U=t.forwardRef(({className:s,type:a,...r},c)=>e.jsx("input",{type:a,className:S("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30",s),ref:c,...r}));U.displayName="Input";const He=Vs,fa=Js,pa=Os,js=t.forwardRef(({className:s,...a},r)=>e.jsx(Bs,{ref:r,className:S("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out",s),...a}));js.displayName="DialogOverlay";const $e=t.forwardRef(({className:s,children:a,...r},c)=>e.jsxs(pa,{children:[e.jsx(js,{}),e.jsxs(Gs,{ref:c,className:S("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out sm:rounded-lg",s),...r,children:[a,e.jsxs(Ks,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(_e,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));$e.displayName="DialogContent";const Le=({className:s,...a})=>e.jsx("div",{className:S("flex flex-col space-y-1.5 text-center sm:text-left",s),...a});Le.displayName="DialogHeader";const bs=({className:s,...a})=>e.jsx("div",{className:S("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...a});bs.displayName="DialogFooter";const Te=t.forwardRef(({className:s,...a},r)=>e.jsx(Ws,{ref:r,className:S("text-lg font-semibold leading-none tracking-tight",s),...a}));Te.displayName="DialogTitle";const Ve=t.forwardRef(({className:s,...a},r)=>e.jsx(Hs,{ref:r,className:S("text-sm text-muted-foreground",s),...a}));Ve.displayName="DialogDescription";const ja=lt,ba=it,Ns=t.forwardRef(({className:s,children:a,...r},c)=>e.jsxs(Xs,{ref:c,className:S("flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...r,children:[a,e.jsx(Ys,{asChild:!0,children:e.jsx(Zs,{className:"size-4 opacity-50"})})]}));Ns.displayName="SelectTrigger";const vs=t.forwardRef(({className:s,children:a,position:r="popper",...c},l)=>e.jsx(Qs,{children:e.jsx(et,{ref:l,className:S("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md animate-in",r==="popper"&&"translate-y-1",s),position:r,...c,children:e.jsx(st,{className:S("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a})})}));vs.displayName="SelectContent";const Ne=t.forwardRef(({className:s,children:a,...r},c)=>e.jsxs(tt,{ref:c,className:S("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...r,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(at,{children:e.jsx(qe,{className:"h-4 w-4"})})}),e.jsx(rt,{children:a})]}));Ne.displayName="SelectItem";const Na=t.forwardRef(({className:s,...a},r)=>e.jsx(nt,{ref:r,className:S("-mx-1 my-1 h-px bg-muted",s),...a}));Na.displayName="SelectSeparator";const Y=t.forwardRef(({className:s,...a},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:S("w-full caption-bottom text-sm",s),...a})}));Y.displayName="Table";const Z=t.forwardRef(({className:s,...a},r)=>e.jsx("thead",{ref:r,className:S("[&_tr]:border-b",s),...a}));Z.displayName="TableHeader";const Q=t.forwardRef(({className:s,...a},r)=>e.jsx("tbody",{ref:r,className:S("[&_tr:last-child]:border-0",s),...a}));Q.displayName="TableBody";const va=t.forwardRef(({className:s,...a},r)=>e.jsx("tfoot",{ref:r,className:S("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...a}));va.displayName="TableFooter";const D=t.forwardRef(({className:s,...a},r)=>e.jsx("tr",{ref:r,className:S("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...a}));D.displayName="TableRow";const g=t.forwardRef(({className:s,...a},r)=>e.jsx("th",{ref:r,className:S("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...a}));g.displayName="TableHead";const h=t.forwardRef(({className:s,...a},r)=>e.jsx("td",{ref:r,className:S("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...a}));h.displayName="TableCell";const ya=t.forwardRef(({className:s,...a},r)=>e.jsx("caption",{ref:r,className:S("mt-4 text-sm text-muted-foreground",s),...a}));ya.displayName="TableCaption";const Sa=50;function Re(s,a){return s?s.length>a?s.slice(0,a)+"…":s:""}function Fe(s){return s==null?"$0.0000":`$${s.toFixed(4)}`}function ts(s){return s?new Date(s).toLocaleString():""}function ka(s){return s?s>=1e3?`${(s/1e3).toFixed(1)}s`:`${s}ms`:"—"}function as({agent:s}){const a={claude:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",codex:"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200",gemini:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-200",takumi:"bg-violet-100 text-violet-800 dark:bg-violet-900 dark:text-violet-200"};return e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${a[s]??"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"}`,children:s})}function _a(){const[s,a]=t.useState([]),[r,c]=t.useState(!0),[l,u]=t.useState(null),[x,m]=t.useState(""),[d,o]=t.useState(""),[n,f]=t.useState(0),[v,k]=t.useState(Sa),[w,A]=t.useState(""),[_,M]=t.useState(""),[R,E]=t.useState(null),[$,L]=t.useState([]),[J,H]=t.useState(!1),[z,i]=t.useState(null),b=t.useRef(null),P=t.useCallback(async()=>{c(!0),u(null);try{const p=await zt({search:x||void 0,account:d||void 0,limit:v,offset:n*v,since:w||void 0});a(p.data)}catch(p){u(p instanceof Error?p.message:"Failed to load sessions")}finally{c(!1)}},[x,d,n,v,w]);t.useEffect(()=>{const p=setTimeout(()=>P(),300);return()=>clearTimeout(p)},[P]),t.useEffect(()=>(b.current=setInterval(()=>P(),3e4),()=>{b.current&&clearInterval(b.current)}),[P]);const F=async p=>{E(p),L([]),i(null),H(!0);try{const W=await It(p.id);L(W.data)}catch(W){i(W instanceof Error?W.message:"Failed to load requests")}finally{H(!1)}},ae=()=>{A(""),M(""),f(0)},te=n>0,se=s.length===v,ee=n*v+1,N=n*v+s.length,V=_?s.filter(p=>(p.started_at?.slice(0,10)??"")<=_):s;return e.jsxs(e.Fragment,{children:[e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsx(O,{className:"text-sm",children:"Sessions"})}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(U,{placeholder:"Search by project, agent, or session...",value:x,onChange:p=>{m(p.target.value),f(0)},className:"h-8 w-48 text-sm"}),e.jsx(U,{placeholder:"Account key, name, or email",value:d,onChange:p=>{o(p.target.value),f(0)},className:"h-8 w-52 text-sm"}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"From:"}),e.jsx("input",{type:"date",value:w,onChange:p=>{A(p.target.value),f(0)},className:"h-8 rounded-md border border-input bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"To:"}),e.jsx("input",{type:"date",value:_,onChange:p=>M(p.target.value),className:"h-8 rounded-md border border-input bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(w||_)&&e.jsxs(C,{variant:"ghost",size:"sm",onClick:ae,className:"h-8 px-2 text-xs",children:[e.jsx(_e,{className:"size-3 mr-1"}),"Clear"]})]})]}),l?e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:l}):r?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ne,{className:"size-5 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border",children:e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(D,{children:[e.jsx(g,{className:"text-xs",children:"Session ID"}),e.jsx(g,{className:"text-xs",children:"Agent"}),e.jsx(g,{className:"text-xs",children:"Project"}),e.jsx(g,{className:"text-xs text-right",children:"Cost"}),e.jsx(g,{className:"text-xs text-right",children:"Tokens"}),e.jsx(g,{className:"text-xs text-right",children:"Requests"}),e.jsx(g,{className:"text-xs",children:"Started"}),e.jsx(g,{className:"w-8"})]})}),e.jsx(Q,{children:V.length===0?e.jsx(D,{children:e.jsx(h,{colSpan:8,className:"py-8 text-center text-sm text-muted-foreground",children:"No sessions found."})}):V.map(p=>e.jsxs(D,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>F(p),children:[e.jsx(h,{children:e.jsx("code",{className:"text-xs text-muted-foreground",children:Re(p.id,16)})}),e.jsx(h,{children:e.jsx(as,{agent:p.agent})}),e.jsx(h,{children:e.jsx("span",{className:"text-sm truncate block max-w-[200px]",children:Re(String(p.project_name||p.project_path||""),30)})}),e.jsx(h,{className:"text-right",children:e.jsx("span",{className:"font-medium text-sm",children:Fe(p.total_cost_usd)})}),e.jsx(h,{className:"text-right",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:(p.total_tokens??0).toLocaleString()})}),e.jsx(h,{className:"text-right",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:p.request_count})}),e.jsx(h,{children:e.jsx("span",{className:"text-xs text-muted-foreground",children:ts(p.started_at)})}),e.jsx(h,{children:e.jsx(C,{variant:"ghost",size:"icon",className:"size-7",onClick:W=>{W.stopPropagation(),navigator.clipboard.writeText(p.id)},title:"Copy session ID",children:e.jsx(Be,{className:"size-3.5"})})})]},p.id))})]})}),!r&&!l&&e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:[V.length>0?`Showing ${ee}–${N}`:"No results",se?"+":""]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{children:"Show:"}),e.jsxs(ja,{value:String(v),onValueChange:p=>{k(Number(p)),f(0)},children:[e.jsx(Ns,{className:"h-7 w-16 text-xs",children:e.jsx(ba,{})}),e.jsxs(vs,{children:[e.jsx(Ne,{value:"25",children:"25"}),e.jsx(Ne,{value:"50",children:"50"}),e.jsx(Ne,{value:"100",children:"100"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(C,{variant:"outline",size:"icon",className:"size-7",onClick:()=>f(p=>Math.max(0,p-1)),disabled:!te,children:e.jsx(cs,{className:"size-3.5"})}),e.jsxs("span",{className:"px-2",children:["Page ",n+1]}),e.jsx(C,{variant:"outline",size:"icon",className:"size-7",onClick:()=>f(p=>p+1),disabled:!se,children:e.jsx(os,{className:"size-3.5"})})]})]})]})]})]}),e.jsx(He,{open:!!R,onOpenChange:p=>!p&&E(null),children:e.jsxs($e,{className:"max-w-3xl max-h-[80vh] overflow-auto",children:[e.jsxs(Le,{children:[e.jsxs(Te,{className:"text-sm",children:["Session:"," ",e.jsx("code",{className:"font-mono text-xs",children:R?.id})]}),e.jsx(Ve,{className:"text-xs",children:R&&e.jsxs(e.Fragment,{children:[e.jsx(as,{agent:R.agent})," ",e.jsx("span",{className:"ml-1",children:Re(String(R.project_name||R.project_path||""),50)}),e.jsxs("span",{className:"ml-2 text-muted-foreground",children:["· ",Fe(R.total_cost_usd)," total · ",R.request_count," requests"]})]})})]}),J?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ne,{className:"size-5 animate-spin text-muted-foreground"})}):z?e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:z}):$.length===0?e.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No request data available for this session."}):e.jsx("div",{className:"rounded-md border",children:e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(D,{children:[e.jsx(g,{className:"text-xs",children:"Time"}),e.jsx(g,{className:"text-xs",children:"Model"}),e.jsx(g,{className:"text-xs text-right",children:"Input"}),e.jsx(g,{className:"text-xs text-right",children:"Output"}),e.jsx(g,{className:"text-xs text-right",children:"Cache read"}),e.jsx(g,{className:"text-xs text-right",children:"5m write"}),e.jsx(g,{className:"text-xs text-right",children:"1h write"}),e.jsx(g,{className:"text-xs text-right",children:"Cost"}),e.jsx(g,{className:"text-xs text-right",children:"Duration"})]})}),e.jsx(Q,{children:$.map(p=>e.jsxs(D,{children:[e.jsx(h,{className:"text-xs text-muted-foreground whitespace-nowrap",children:ts(p.timestamp)}),e.jsx(h,{className:"text-xs",children:e.jsx("code",{className:"text-xs",children:p.model})}),e.jsx(h,{className:"text-right text-xs text-muted-foreground",children:p.input_tokens.toLocaleString()}),e.jsx(h,{className:"text-right text-xs text-muted-foreground",children:p.output_tokens.toLocaleString()}),e.jsx(h,{className:"text-right text-xs text-muted-foreground",children:p.cache_read_tokens.toLocaleString()}),e.jsx(h,{className:"text-right text-xs text-muted-foreground",children:(p.cache_create_5m_tokens??p.cache_create_tokens).toLocaleString()}),e.jsx(h,{className:"text-right text-xs text-muted-foreground",children:(p.cache_create_1h_tokens??0).toLocaleString()}),e.jsx(h,{className:"text-right text-xs font-medium",children:Fe(p.cost_usd)}),e.jsx(h,{className:"text-right text-xs text-muted-foreground",children:ka(p.duration_ms)})]},p.id))})]})})]})})]})}const Ue=t.forwardRef(({className:s,...a},r)=>e.jsx(ct,{ref:r,className:S("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",s),...a,children:e.jsx(ot,{className:S("flex items-center justify-center text-current"),children:e.jsx(qe,{className:"h-3.5 w-3.5"})})}));Ue.displayName="Checkbox";function fe(s,a){return typeof a=="function"?a(s):s[a]}function xe({columns:s,data:a,searchPlaceholder:r="Search...",actions:c,bulkActions:l,pageSize:u=25,getRowId:x,loading:m,error:d,emptyMessage:o="No data found.",onSearchChange:n,searchValue:f,totalCount:v,onPageChange:k,currentPage:w}){const[A,_]=t.useState(""),[M,R]=t.useState(null),[E,$]=t.useState(null),[L,J]=t.useState(new Set),[H,z]=t.useState(0),i=n!==void 0,b=k!==void 0,P=i?f??"":A,F=b?w??0:H,ae=j=>{i?n(j):(_(j),z(0))},te=j=>{if(b){const I=typeof j=="function"?j(w??0):j;k(I)}else z(typeof j=="function"?j:()=>j)},se=t.useCallback((j,I)=>x?x(j,I):String(I),[x]),ee=t.useMemo(()=>{if(i||!P)return a;const j=P.toLowerCase();return a.filter(I=>s.some(X=>{const K=fe(I,X.accessor);return K!=null&&String(K).toLowerCase().includes(j)}))},[a,P,s,i]),N=t.useMemo(()=>{if(M===null||E===null)return ee;const j=s[M];return j?[...ee].sort((I,X)=>{const K=fe(I,j.accessor),le=fe(X,j.accessor);if(K==null&&le==null)return 0;if(K==null)return 1;if(le==null)return-1;if(typeof K=="number"&&typeof le=="number")return E==="asc"?K-le:le-K;const oe=String(K),Je=String(le);return E==="asc"?oe.localeCompare(Je):Je.localeCompare(oe)}):ee},[ee,M,E,s]),V=b?v??a.length:N.length,p=Math.max(1,Math.ceil(V/u)),W=b?N:N.slice(F*u,(F+1)*u),y=j=>{s[j].sortable&&(M===j?E==="asc"?$("desc"):E==="desc"?(R(null),$(null)):$("asc"):(R(j),$("asc")))},ce=j=>{J(I=>{const X=new Set(I);return X.has(j)?X.delete(j):X.add(j),X})},Ee=()=>{L.size===W.length?J(new Set):J(new Set(W.map((j,I)=>se(j,F*u+I))))},he=t.useMemo(()=>W.filter((j,I)=>L.has(se(j,F*u+I))),[W,L,F,u,se]),ie=l&&l.length>0,Pe=c&&c.length>0;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-xs",children:[e.jsx(dt,{className:"absolute left-2.5 top-2.5 size-4 text-muted-foreground"}),e.jsx(U,{placeholder:r,value:P,onChange:j=>ae(j.target.value),className:"pl-8 h-9"})]}),e.jsx("div",{className:"rounded-md border",children:m?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"size-5 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}):d?e.jsx("div",{className:"p-4 m-4 rounded-lg border border-red-200 bg-red-50 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:d}):e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(D,{children:[ie&&e.jsx(g,{className:"w-10",children:e.jsx(Ue,{checked:W.length>0&&L.size===W.length,onCheckedChange:Ee})}),s.map((j,I)=>e.jsx(g,{className:j.sortable?"cursor-pointer select-none":"",onClick:()=>j.sortable&&y(I),children:e.jsxs("div",{className:"flex items-center gap-1",children:[j.header,j.sortable&&M===I&&(E==="asc"?e.jsx(ut,{className:"size-3"}):e.jsx(mt,{className:"size-3"}))]})},I)),Pe&&e.jsx(g,{className:"w-10"})]})}),e.jsx(Q,{children:W.length===0?e.jsx(D,{children:e.jsx(h,{colSpan:s.length+(ie?1:0)+(Pe?1:0),className:"h-24 text-center text-muted-foreground",children:o})}):W.map((j,I)=>{const X=se(j,F*u+I);return e.jsxs(D,{"data-state":L.has(X)?"selected":void 0,children:[ie&&e.jsx(h,{children:e.jsx(Ue,{checked:L.has(X),onCheckedChange:()=>ce(X)})}),s.map((K,le)=>{const oe=fe(j,K.accessor);return e.jsx(h,{className:K.className,children:K.render?K.render(oe,j):oe},le)}),Pe&&e.jsx(h,{children:e.jsxs(us,{children:[e.jsx(ms,{asChild:!0,children:e.jsx(C,{variant:"ghost",size:"icon",className:"size-7",children:e.jsx(xt,{className:"size-4"})})}),e.jsx(We,{align:"end",children:c.map(K=>e.jsxs(ue,{onClick:()=>K.onClick(j),children:[K.icon,K.label]},K.label))})]})})]},X)})})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:V>0?`Showing ${F*u+1}-${Math.min((F+1)*u,V)} of ${V}`:"No results"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>te(j=>Math.max(0,j-1)),disabled:F===0,children:e.jsx(cs,{className:"size-4"})}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",F+1," of ",p]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>te(j=>Math.min(p-1,j+1)),disabled:F>=p-1,children:e.jsx(os,{className:"size-4"})})]})]}),ie&&L.size>0&&e.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-50 flex items-center gap-3 rounded-lg border bg-background px-4 py-2.5 shadow-lg",children:[e.jsxs("span",{className:"text-sm font-medium",children:[L.size," selected"]}),l.map(j=>e.jsx(C,{size:"sm",variant:j.variant==="destructive"?"destructive":"default",onClick:()=>j.onClick(he),children:j.label},j.label)),e.jsx(C,{size:"sm",variant:"ghost",onClick:()=>J(new Set),children:e.jsx(_e,{className:"size-3.5"})})]})]})}function ys(s){return`$${(s??0).toFixed(4)}`}function wa({agent:s}){const a={claude:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",codex:"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200",gemini:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-200",takumi:"bg-violet-100 text-violet-800 dark:bg-violet-900 dark:text-violet-200"};return e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${a[s]??"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"}`,children:s})}const Ca={cost_usd:{label:"Cost (USD)",color:"hsl(var(--chart-1, 221 83% 53%))"}},Da=[{header:"Model",accessor:"model",sortable:!0,render:s=>e.jsx("code",{className:"text-xs",children:String(s)})},{header:"Agent",accessor:"agent",sortable:!0,render:s=>e.jsx(wa,{agent:String(s)})},{header:"Requests",accessor:"requests",sortable:!0,render:s=>e.jsx("span",{className:"text-muted-foreground",children:(s??0).toLocaleString()})},{header:"Tokens",accessor:"total_tokens",sortable:!0,render:s=>e.jsx("span",{className:"text-muted-foreground",children:(s??0).toLocaleString()})},{header:"Cost",accessor:"cost_usd",sortable:!0,render:s=>e.jsx("span",{className:"font-semibold",children:ys(s)})}];function $a(){const[s,a]=t.useState([]),[r,c]=t.useState(!0),[l,u]=t.useState(null),x=t.useRef(null),m=t.useCallback(()=>{c(!0),Ut().then(n=>{const f=[...n.data].sort((v,k)=>k.cost_usd-v.cost_usd);a(f)}).catch(n=>u(n instanceof Error?n.message:"Failed to load")).finally(()=>c(!1))},[]);t.useEffect(()=>{const n=()=>m();return queueMicrotask(n),x.current=setInterval(n,3e4),()=>{x.current&&clearInterval(x.current)}},[m]);const d=(()=>{const n=new Map;for(const f of s)n.set(f.model,(n.get(f.model)??0)+f.cost_usd);return Array.from(n.entries()).sort((f,v)=>v[1]-f[1]).slice(0,10).map(([f,v])=>({model:f,cost_usd:v}))})();if(r&&s.length===0)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ne,{className:"size-5 animate-spin text-muted-foreground"})});if(l&&s.length===0)return e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:l});const o=[{label:"Copy model name",icon:e.jsx(Be,{className:"size-4"}),onClick:n=>{navigator.clipboard.writeText(n.model)}}];return e.jsxs("div",{className:"space-y-6",children:[d.length>0&&e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsx(O,{className:"text-sm",children:"Cost by Model (Top 10)"})}),e.jsx(G,{children:e.jsx(De,{config:Ca,className:"aspect-auto h-[300px] w-full",children:e.jsxs(Ge,{data:d,layout:"vertical",margin:{top:4,right:16,left:0,bottom:4},children:[e.jsx(ve,{strokeDasharray:"3 3",horizontal:!1}),e.jsx(ye,{type:"number",axisLine:!1,tickLine:!1,tickFormatter:n=>`$${Number(n).toFixed(2)}`}),e.jsx(Se,{type:"category",dataKey:"model",axisLine:!1,tickLine:!1,width:180,tick:{fontSize:11}}),e.jsx(ke,{content:e.jsx(me,{formatter:n=>ys(n)})}),e.jsx(Ke,{dataKey:"cost_usd",fill:"var(--color-cost_usd)",radius:[0,4,4,0]})]})})})]}),e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsx(O,{className:"text-sm",children:"Model Breakdown"})}),e.jsx(G,{children:e.jsx(xe,{columns:Da,data:s,searchPlaceholder:"Search models...",actions:o,getRowId:(n,f)=>`${n.model}-${n.agent}-${f}`,loading:!1,error:null,emptyMessage:"No model data."})})]})]})}function La(s,a){return s?s.length>a?"…"+s.slice(-a):s:""}function Ss(s){return`$${(s??0).toFixed(4)}`}function Ta(s){return s?new Date(s).toLocaleDateString():""}const Ea={cost_usd:{label:"Cost (USD)",color:"hsl(var(--chart-1, 221 83% 53%))"}},Pa=[{header:"Project Name",accessor:"project_name",sortable:!0,render:s=>e.jsx("span",{className:"font-medium",children:s||"—"})},{header:"Path",accessor:"project_path",sortable:!0,className:"max-w-[280px]",render:(s,a)=>e.jsx("code",{className:"text-xs text-muted-foreground",title:a.project_path,children:La(String(s),40)})},{header:"Sessions",accessor:"sessions",sortable:!0,render:s=>e.jsx("span",{className:"text-muted-foreground",children:s})},{header:"Cost",accessor:"cost_usd",sortable:!0,render:s=>e.jsx("span",{className:"font-semibold",children:Ss(s)})},{header:"Last Active",accessor:"last_active",sortable:!0,render:s=>e.jsx("span",{className:"text-xs text-muted-foreground",children:Ta(String(s))})}];function Ma(){const[s,a]=t.useState([]),[r,c]=t.useState(!0),[l,u]=t.useState(null),x=t.useRef(null),m=t.useCallback(()=>{c(!0),qt().then(n=>{const f=[...n.data].sort((v,k)=>k.cost_usd-v.cost_usd);a(f)}).catch(n=>u(n instanceof Error?n.message:"Failed to load")).finally(()=>c(!1))},[]);t.useEffect(()=>{const n=()=>m();return queueMicrotask(n),x.current=setInterval(n,3e4),()=>{x.current&&clearInterval(x.current)}},[m]);const d=s.slice(0,10).map(n=>({name:n.project_name||n.project_path.split("/").pop()||"unknown",cost_usd:n.cost_usd}));if(r&&s.length===0)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ne,{className:"size-5 animate-spin text-muted-foreground"})});if(l&&s.length===0)return e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:l});const o=[{label:"Set budget",icon:e.jsx(ht,{className:"size-4"}),onClick:n=>{alert(`Navigate to Budgets tab to set a budget for: ${n.project_path}`)}},{label:"Copy path",icon:e.jsx(Be,{className:"size-4"}),onClick:n=>{navigator.clipboard.writeText(n.project_path)}}];return e.jsxs("div",{className:"space-y-6",children:[d.length>0&&e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsx(O,{className:"text-sm",children:"Top 10 Projects by Cost"})}),e.jsx(G,{children:e.jsx(De,{config:Ea,className:"aspect-auto h-[300px] w-full",children:e.jsxs(Ge,{data:d,margin:{top:4,right:16,left:0,bottom:4},children:[e.jsx(ve,{strokeDasharray:"3 3",vertical:!1}),e.jsx(ye,{dataKey:"name",tickLine:!1,axisLine:!1,tick:{fontSize:11},interval:0,angle:-30,textAnchor:"end",height:60}),e.jsx(Se,{axisLine:!1,tickLine:!1,tickFormatter:n=>`$${Number(n).toFixed(2)}`,width:60}),e.jsx(ke,{content:e.jsx(me,{formatter:n=>Ss(n)})}),e.jsx(Ke,{dataKey:"cost_usd",fill:"var(--color-cost_usd)",radius:[4,4,0,0]})]})})})]}),e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsx(O,{className:"text-sm",children:"Projects"})}),e.jsx(G,{children:e.jsx(xe,{columns:Pa,data:s,searchPlaceholder:"Search projects...",actions:o,getRowId:(n,f)=>String(f),loading:!1,error:null,emptyMessage:"No projects found."})})]})]})}function Ra({percent:s,isOver:a}){const r=Math.min(100,s),c=a||s>90?"bg-red-500":s>60?"bg-yellow-500":"bg-green-500",l=a||s>90?"text-red-600 dark:text-red-400":s>60?"text-yellow-600 dark:text-yellow-400":"text-green-600 dark:text-green-400";return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 h-2 rounded-full bg-muted overflow-hidden min-w-[80px]",children:e.jsx("div",{className:`h-full rounded-full transition-all ${c}`,style:{width:`${r}%`}})}),e.jsxs("span",{className:`text-xs font-semibold min-w-[44px] text-right ${l}`,children:[s.toFixed(1),"%"]})]})}const Fa=[{header:"Project",accessor:"project_path",sortable:!0,render:s=>e.jsx("span",{className:"font-medium",children:s||"Global"})},{header:"Agent",accessor:"agent",sortable:!0,render:s=>e.jsx("span",{className:"capitalize",children:s||"All"})},{header:"Period",accessor:"period",sortable:!0,render:s=>e.jsx("span",{className:"inline-flex items-center rounded-full bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200 px-2 py-0.5 text-xs font-medium uppercase",children:s})},{header:"Usage",accessor:"percent_used",sortable:!0,render:(s,a)=>e.jsx(Ra,{percent:a.percent_used,isOver:a.is_over_alert})},{header:"Spend",accessor:"current_spend_usd",sortable:!0,render:(s,a)=>e.jsxs("span",{className:"text-sm text-muted-foreground",children:["$",a.current_spend_usd.toFixed(4)," / $",a.limit_usd.toFixed(2)]})}];function Aa(){const[s,a]=t.useState([]),[r,c]=t.useState(!0),[l,u]=t.useState(null),[x,m]=t.useState(""),[d,o]=t.useState(""),[n,f]=t.useState("monthly"),[v,k]=t.useState(""),[w,A]=t.useState("80"),[_,M]=t.useState(!1),[R,E]=t.useState(null),$=t.useRef(null),L=t.useCallback(()=>{c(!0),Bt().then(i=>a(i.data)).catch(i=>u(i instanceof Error?i.message:"Failed to load")).finally(()=>c(!1))},[]);t.useEffect(()=>{const i=()=>L();return queueMicrotask(i),$.current=setInterval(i,3e4),()=>{$.current&&clearInterval($.current)}},[L]);const J=async i=>{try{await Gt(i),L()}catch(b){alert(b instanceof Error?b.message:"Delete failed")}},H=async i=>{if(i.preventDefault(),!v||isNaN(Number(v))){E("Enter a valid limit amount");return}M(!0),E(null);try{await Ot({project_path:x||void 0,agent:d||void 0,period:n,limit_usd:Number(v),alert_at_percent:Number(w)}),m(""),o(""),k(""),L()}catch(b){E(b instanceof Error?b.message:"Failed to create budget")}finally{M(!1)}},z=[{label:"Edit",icon:e.jsx(Oe,{className:"size-4"}),onClick:i=>{m(i.project_path||""),o(i.agent||""),f(i.period),k(String(i.limit_usd))}},{label:"Delete",icon:e.jsx(Ce,{className:"size-4"}),onClick:i=>J(i.id)}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsx(O,{className:"text-sm",children:"Active Budgets"})}),e.jsx(G,{children:e.jsx(xe,{columns:Fa,data:s,searchPlaceholder:"Search budgets...",actions:z,getRowId:i=>String(i.id),loading:r,error:l,emptyMessage:"No budgets configured"})})]}),e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs(O,{className:"text-sm flex items-center gap-2",children:[e.jsx(we,{className:"size-4"}),"Add Budget"]})}),e.jsx(G,{children:e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-5",children:[e.jsxs("div",{className:"space-y-1.5 lg:col-span-2",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Project Path (optional)"}),e.jsx(U,{type:"text",placeholder:"Leave blank for global budget",value:x,onChange:i=>m(i.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Agent"}),e.jsxs("select",{value:d,onChange:i=>o(i.target.value),className:"h-9 w-full rounded-md border border-input bg-background px-3 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[e.jsx("option",{value:"",children:"All agents"}),e.jsx("option",{value:"claude",children:"Claude"}),e.jsx("option",{value:"takumi",children:"Takumi"}),e.jsx("option",{value:"codex",children:"Codex"}),e.jsx("option",{value:"gemini",children:"Gemini"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Period"}),e.jsxs("select",{value:n,onChange:i=>f(i.target.value),className:"h-9 w-full rounded-md border border-input bg-background px-3 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Limit (USD)"}),e.jsx(U,{type:"number",step:"0.01",min:"0",placeholder:"10.00",value:v,onChange:i=>k(i.target.value),required:!0})]})]}),e.jsxs("div",{className:"max-w-xs space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Alert at %"}),e.jsx(U,{type:"number",step:"1",min:"1",max:"100",value:w,onChange:i=>A(i.target.value)})]}),R&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:R}),e.jsx(C,{type:"submit",disabled:_,children:_?"Adding...":"Add Budget"})]})})]})]})}function za({percent:s}){const a=Math.min(100,s),r=s>100?"bg-red-500":s>=70?"bg-yellow-500":"bg-green-500";return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-muted overflow-hidden min-w-[80px]",children:e.jsx("div",{className:`h-full rounded-full transition-all ${r}`,style:{width:`${a}%`}})}),e.jsxs("span",{className:"text-xs font-medium text-muted-foreground min-w-[44px] text-right",children:[s.toFixed(1),"%"]})]})}function Ia({goal:s}){return s.is_over?e.jsx("span",{className:"inline-flex items-center rounded-full bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200 px-2 py-0.5 text-xs font-semibold uppercase",children:"OVER"}):s.is_at_risk?e.jsx("span",{className:"inline-flex items-center rounded-full bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200 px-2 py-0.5 text-xs font-semibold uppercase",children:"AT RISK"}):e.jsx("span",{className:"inline-flex items-center rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 py-0.5 text-xs font-semibold uppercase",children:"ON TRACK"})}function Ua(s){return s.agent&&s.project_path?`${s.project_path} / ${s.agent}`:s.agent?s.agent:s.project_path?s.project_path:"Global"}const qa=[{header:"Period",accessor:"period",sortable:!0,render:s=>e.jsx("span",{className:"inline-flex items-center rounded-full bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200 px-2 py-0.5 text-xs font-medium uppercase",children:s})},{header:"Scope",accessor:"project_path",sortable:!0,render:(s,a)=>e.jsx("span",{className:"font-medium",children:Ua(a)})},{header:"Limit",accessor:"limit_usd",sortable:!0,render:s=>e.jsxs("span",{children:["$",s.toFixed(2)]})},{header:"Spent",accessor:"current_spend_usd",sortable:!0,render:s=>e.jsxs("span",{className:"text-sm text-muted-foreground",children:["$",s.toFixed(4)]})},{header:"Progress",accessor:"percent_used",sortable:!0,render:(s,a)=>e.jsx(za,{percent:a.percent_used})},{header:"Status",accessor:"is_on_track",sortable:!1,render:(s,a)=>e.jsx(Ia,{goal:a})}];function Ba({onCreated:s}){const[a,r]=t.useState(!1),[c,l]=t.useState("month"),[u,x]=t.useState(""),[m,d]=t.useState(""),[o,n]=t.useState(""),[f,v]=t.useState(!1),[k,w]=t.useState(null),A=async()=>{if(!u||isNaN(Number(u))||Number(u)<=0){w("Enter a valid limit amount");return}v(!0),w(null);try{await ra({period:c,limit_usd:Number(u),project_path:m||void 0,agent:o||void 0}),x(""),d(""),n(""),l("month"),r(!1),s()}catch(_){w(_ instanceof Error?_.message:"Failed to create goal")}finally{v(!1)}};return e.jsxs(He,{open:a,onOpenChange:r,children:[e.jsx(fa,{asChild:!0,children:e.jsxs(C,{size:"sm",className:"gap-1.5",children:[e.jsx(we,{className:"size-4"}),"Add Goal"]})}),e.jsxs($e,{className:"sm:max-w-md",children:[e.jsx(Le,{children:e.jsx(Te,{children:"Add Spending Goal"})}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Period"}),e.jsxs("select",{value:c,onChange:_=>l(_.target.value),className:"h-9 w-full rounded-md border border-input bg-background px-3 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[e.jsx("option",{value:"day",children:"Day"}),e.jsx("option",{value:"week",children:"Week"}),e.jsx("option",{value:"month",children:"Month"}),e.jsx("option",{value:"year",children:"Year"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Limit (USD)"}),e.jsx(U,{type:"number",step:"0.01",min:"0.01",placeholder:"10.00",value:u,onChange:_=>x(_.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:"text-xs font-medium text-muted-foreground",children:["Project Path ",e.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e.jsx(U,{type:"text",placeholder:"Leave blank for global goal",value:m,onChange:_=>d(_.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:"text-xs font-medium text-muted-foreground",children:["Agent ",e.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e.jsxs("select",{value:o,onChange:_=>n(_.target.value),className:"h-9 w-full rounded-md border border-input bg-background px-3 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[e.jsx("option",{value:"",children:"All agents"}),e.jsx("option",{value:"claude",children:"Claude"}),e.jsx("option",{value:"takumi",children:"Takumi"}),e.jsx("option",{value:"codex",children:"Codex"}),e.jsx("option",{value:"gemini",children:"Gemini"})]})]}),k&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:k}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(C,{variant:"outline",onClick:()=>r(!1),disabled:f,children:"Cancel"}),e.jsx(C,{onClick:A,disabled:f,children:f?"Saving...":"Save"})]})]})]})]})}function Oa(){const[s,a]=t.useState([]),[r,c]=t.useState(!0),[l,u]=t.useState(null),x=t.useRef(null),m=t.useCallback(()=>{c(!0),aa().then(n=>a(n.data)).catch(n=>u(n instanceof Error?n.message:"Failed to load")).finally(()=>c(!1))},[]);t.useEffect(()=>{const n=()=>m();return queueMicrotask(n),x.current=setInterval(n,3e4),()=>{x.current&&clearInterval(x.current)}},[m]);const d=async n=>{try{await na(n),m()}catch(f){alert(f instanceof Error?f.message:"Delete failed")}},o=[{label:"Delete",icon:e.jsx(Ce,{className:"size-4"}),onClick:n=>d(n.id)}];return e.jsx("div",{className:"space-y-6",children:e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(O,{className:"text-sm",children:"Spending Goals"}),e.jsx(Ba,{onCreated:m})]})}),e.jsx(G,{children:e.jsx(xe,{columns:qa,data:s,searchPlaceholder:"Search goals...",actions:o,getRowId:n=>n.id,loading:r,error:l,emptyMessage:"No goals configured"})})]})})}const Ga=[{header:"Model",accessor:"model",sortable:!0,render:s=>e.jsx("code",{className:"text-xs",children:String(s)})},{header:"Input / 1M",accessor:"input_per_1m",sortable:!0,render:s=>e.jsxs("span",{className:"text-muted-foreground",children:["$",(s??0).toFixed(4)]})},{header:"Output / 1M",accessor:"output_per_1m",sortable:!0,render:s=>e.jsxs("span",{className:"text-muted-foreground",children:["$",(s??0).toFixed(4)]})},{header:"Cache Read / 1M",accessor:"cache_read_per_1m",sortable:!0,render:s=>e.jsx("span",{className:"text-muted-foreground",children:s!=null?`$${s.toFixed(4)}`:"—"})},{header:"Cache Write / 1M",accessor:"cache_write_per_1m",sortable:!0,render:s=>e.jsx("span",{className:"text-muted-foreground",children:s!=null?`$${s.toFixed(4)}`:"—"})},{header:"1h Cache Write / 1M",accessor:"cache_write_1h_per_1m",sortable:!0,render:s=>e.jsx("span",{className:"text-muted-foreground",children:s!=null?`$${s.toFixed(4)}`:"—"})}];function Ka(){const[s,a]=t.useState([]),[r,c]=t.useState(!0),[l,u]=t.useState(null),[x,m]=t.useState(!1),[d,o]=t.useState(""),[n,f]=t.useState(""),[v,k]=t.useState(""),[w,A]=t.useState(""),[_,M]=t.useState(""),[R,E]=t.useState(""),[$,L]=t.useState(!1),[J,H]=t.useState(null),[z,i]=t.useState(null),b=t.useRef(null),P=t.useCallback(()=>{c(!0),Kt().then(N=>a(N.data)).catch(N=>u(N instanceof Error?N.message:"Failed to load")).finally(()=>c(!1))},[]);t.useEffect(()=>{const N=()=>P();return queueMicrotask(N),b.current=setInterval(N,3e4),()=>{b.current&&clearInterval(b.current)}},[P]);const F=async N=>{try{await Jt(N),P()}catch(V){alert(V instanceof Error?V.message:"Delete failed")}},ae=()=>{o(""),f(""),k(""),A(""),M(""),E(""),H(null),i(null),m(!0)},te=N=>{o(N.model),f(String(N.input_per_1m??"")),k(String(N.output_per_1m??"")),A(N.cache_read_per_1m!=null?String(N.cache_read_per_1m):""),M(N.cache_write_per_1m!=null?String(N.cache_write_per_1m):""),E(N.cache_write_1h_per_1m!=null?String(N.cache_write_1h_per_1m):""),H(null),i(N.model),m(!0)},se=async N=>{if(N.preventDefault(),!d){H("Model name is required");return}L(!0),H(null);try{await Vt({model:d,input_per_1m:Number(n)||0,output_per_1m:Number(v)||0,cache_read_per_1m:Number(w)||0,cache_write_per_1m:Number(_)||0,cache_write_1h_per_1m:Number(R)||0}),m(!1),P()}catch(V){H(V instanceof Error?V.message:"Failed to save pricing")}finally{L(!1)}},ee=[{label:"Edit",icon:e.jsx(Oe,{className:"size-4"}),onClick:N=>te(N)},{label:"Delete",icon:e.jsx(Ce,{className:"size-4"}),onClick:N=>F(N.model)}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(O,{className:"text-sm",children:"Model Pricing"}),e.jsxs(C,{size:"sm",onClick:ae,children:[e.jsx(we,{className:"size-3.5 mr-1"}),"Add Pricing"]})]})}),e.jsx(G,{children:e.jsx(xe,{columns:Ga,data:s,searchPlaceholder:"Search models...",actions:ee,getRowId:N=>N.model,loading:r,error:l,emptyMessage:"No pricing data."})})]}),e.jsx(He,{open:x,onOpenChange:m,children:e.jsxs($e,{children:[e.jsxs(Le,{children:[e.jsx(Te,{children:z?"Edit Pricing":"Add Pricing"}),e.jsx(Ve,{children:z?`Update pricing for ${z}`:"Configure pricing per 1M tokens for a model."})]}),e.jsxs("form",{onSubmit:se,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Model Name"}),e.jsx(U,{type:"text",placeholder:"e.g. claude-opus-4-5",value:d,onChange:N=>o(N.target.value),required:!0,disabled:!!z})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Input / 1M ($)"}),e.jsx(U,{type:"number",step:"0.0001",min:"0",placeholder:"3.00",value:n,onChange:N=>f(N.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Output / 1M ($)"}),e.jsx(U,{type:"number",step:"0.0001",min:"0",placeholder:"15.00",value:v,onChange:N=>k(N.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Cache Read / 1M ($)"}),e.jsx(U,{type:"number",step:"0.0001",min:"0",placeholder:"0.30",value:w,onChange:N=>A(N.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Cache Write / 1M ($)"}),e.jsx(U,{type:"number",step:"0.0001",min:"0",placeholder:"3.75",value:_,onChange:N=>M(N.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"1h Cache Write / 1M ($)"}),e.jsx(U,{type:"number",step:"0.0001",min:"0",placeholder:"6.00",value:R,onChange:N=>E(N.target.value)})]})]}),J&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:J}),e.jsxs(bs,{children:[e.jsx(C,{type:"button",variant:"outline",onClick:()=>m(!1),children:"Cancel"}),e.jsx(C,{type:"submit",disabled:$,children:$?"Saving...":"Save"})]})]})]})})]})}function rs(s){return"$"+(s??0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}function Wa(){const[s,a]=t.useState(null),[r,c]=t.useState(!0),[l,u]=t.useState(!1),[x,m]=t.useState(null),d=t.useCallback(()=>{c(!0),m(null),Wt("month").then(f=>a(f.data)).catch(f=>m(f instanceof Error?f.message:"Failed to load billing")).finally(()=>c(!1))},[]);t.useEffect(()=>{queueMicrotask(d)},[d]);const o=async()=>{u(!0),m(null);try{await gs({days:31,providers:["anthropic","openai","gemini"]}),d()}catch(f){m(f instanceof Error?f.message:"Billing sync failed")}finally{u(!1)}},n=Object.entries(s?.by_provider??{}).sort(([f],[v])=>f.localeCompare(v));return e.jsx("div",{className:"space-y-6",children:e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(O,{className:"text-sm",children:"Provider Billing"}),e.jsxs(C,{size:"sm",onClick:o,disabled:l,children:[e.jsx(ne,{className:`size-3.5 mr-1 ${l?"animate-spin":""}`}),"Sync Billing"]})]})}),e.jsxs(G,{className:"space-y-4",children:[x&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:x}),e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:"Month To Date"}),e.jsx("div",{className:"mt-1 text-2xl font-semibold",children:r?"Loading...":rs(s?.total_usd??0)})]}),e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(D,{children:[e.jsx(g,{children:"Provider"}),e.jsx(g,{className:"text-right",children:"Actual Billed"})]})}),e.jsx(Q,{children:n.length===0?e.jsx(D,{children:e.jsx(h,{colSpan:2,className:"text-muted-foreground",children:"No billing data synced."})}):n.map(([f,v])=>e.jsxs(D,{children:[e.jsx(h,{className:"font-medium capitalize",children:f}),e.jsx(h,{className:"text-right",children:rs(v)})]},f))})]})]})]})})}function pe(s){return"$"+(s??0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}function Ha(s){return s.account_email||s.account_name||s.account_key||"Unknown account"}function Va(s){return s?s.slice(0,1).toUpperCase()+s.slice(1):"Unknown"}function Ja(){const[s,a]=t.useState(null),[r,c]=t.useState([]),[l,u]=t.useState(!0),[x,m]=t.useState(null),d=t.useCallback(()=>{u(!0),m(null),Promise.all([Xt("month"),hs("month")]).then(([n,f])=>{a(n.data),c(f.data)}).catch(n=>m(n instanceof Error?n.message:"Failed to load usage")).finally(()=>u(!1))},[]);t.useEffect(()=>{queueMicrotask(d);const n=setInterval(d,3e4);return()=>clearInterval(n)},[d]);const o=s?.snapshots??[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs(O,{className:"text-sm flex items-center gap-2",children:[e.jsx(gt,{className:"size-4 text-blue-500"}),"Subscription Usage — This Month"]})}),e.jsxs(G,{className:"space-y-4",children:[x&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:x}),e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:"Fleet API-equivalent spend"}),e.jsx("div",{className:"mt-1 text-2xl font-semibold",children:l?"Loading...":pe(s?.summary?.total_usd??0)})]}),o.length===0&&!l?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["No usage snapshots yet. Run ",e.jsx("code",{className:"text-xs",children:"economy sync --cursor"})," to ingest Cursor quotas."]}):e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(D,{children:[e.jsx(g,{children:"Agent"}),e.jsx(g,{children:"Metric"}),e.jsx(g,{className:"text-right",children:"Value"}),e.jsx(g,{children:"Date"}),e.jsx(g,{children:"Machine"})]})}),e.jsx(Q,{children:o.map(n=>e.jsxs(D,{children:[e.jsx(h,{className:"font-medium capitalize",children:n.agent}),e.jsx(h,{children:n.metric}),e.jsxs(h,{className:"text-right",children:[n.value.toLocaleString("en-US"),n.unit?` ${n.unit}`:""]}),e.jsx(h,{className:"text-muted-foreground",children:n.date}),e.jsx(h,{className:"text-muted-foreground",children:n.machine_id||"—"})]},n.id))})]})]})]}),e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs(O,{className:"text-sm flex items-center gap-2",children:[e.jsx(ds,{className:"size-4 text-emerald-500"}),"Account Attribution"]})}),e.jsx(G,{children:r.length===0&&!l?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No account-attributed sessions yet."}):e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(D,{children:[e.jsx(g,{children:"Account"}),e.jsx(g,{children:"Agent"}),e.jsx(g,{children:"Source"}),e.jsx(g,{className:"text-right",children:"API Eq"}),e.jsx(g,{className:"text-right",children:"Billable"}),e.jsx(g,{className:"text-right",children:"Included"}),e.jsx(g,{className:"text-right",children:"Requests"}),e.jsx(g,{className:"text-right",children:"Tokens"})]})}),e.jsx(Q,{children:r.map(n=>e.jsxs(D,{children:[e.jsxs(h,{children:[e.jsx("div",{className:"font-medium",children:Ha(n)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:n.account_key})]}),e.jsx(h,{children:Va(n.account_tool)}),e.jsx(h,{className:"text-muted-foreground",children:n.account_source}),e.jsx(h,{className:"text-right tabular-nums",children:pe(n.api_equivalent_usd??n.cost_usd)}),e.jsx(h,{className:"text-right tabular-nums",children:pe(n.billable_usd??n.metered_api_usd??0)}),e.jsx(h,{className:"text-right tabular-nums",children:pe(n.subscription_included_usd??0)}),e.jsx(h,{className:"text-right tabular-nums",children:n.requests.toLocaleString("en-US")}),e.jsx(h,{className:"text-right tabular-nums",children:n.total_tokens.toLocaleString("en-US")})]},n.account_key))})]})})]})]})}const Xa=[{key:"today",label:"Today"},{key:"week",label:"Week"},{key:"month",label:"Month"},{key:"all",label:"All"}];function Ae(s){return"$"+(s??0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}function Ya(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}k`:s.toLocaleString("en-US")}function Za(s){return s?s.slice(0,1).toUpperCase()+s.slice(1):"Unknown"}function Qa(s){return s.account_email||s.account_name||s.account_key||"Unknown account"}function er(){const[s,a]=t.useState("month"),[r,c]=t.useState([]),[l,u]=t.useState(!0),[x,m]=t.useState(null),d=t.useCallback(()=>{u(!0),m(null),hs(s).then(o=>c(o.data)).catch(o=>m(o instanceof Error?o.message:"Failed to load accounts")).finally(()=>u(!1))},[s]);return t.useEffect(()=>{queueMicrotask(d);const o=setInterval(d,3e4);return()=>clearInterval(o)},[d]),e.jsx("div",{className:"space-y-6",children:e.jsxs(q,{children:[e.jsxs(B,{className:"flex flex-row items-center justify-between gap-3 pb-3",children:[e.jsxs(O,{className:"flex items-center gap-2 text-sm",children:[e.jsx(ds,{className:"size-4 text-emerald-500"}),"Accounts"]}),e.jsx("div",{className:"flex items-center gap-1 rounded-md border p-1",children:Xa.map(o=>e.jsx(C,{variant:s===o.key?"secondary":"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>a(o.key),children:o.label},o.key))})]}),e.jsxs(G,{children:[x&&e.jsx("div",{className:"mb-4 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:x}),l?e.jsxs("div",{className:"flex items-center gap-2 py-8 text-sm text-muted-foreground",children:[e.jsx(ne,{className:"size-4 animate-spin"}),"Loading accounts"]}):r.length===0?e.jsx("p",{className:"py-8 text-sm text-muted-foreground",children:"No account-attributed sessions yet."}):e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(D,{children:[e.jsx(g,{children:"Account"}),e.jsx(g,{children:"Agent"}),e.jsx(g,{children:"Source"}),e.jsx(g,{className:"text-right",children:"API Eq"}),e.jsx(g,{className:"text-right",children:"Billable"}),e.jsx(g,{className:"text-right",children:"Included"}),e.jsx(g,{className:"text-right",children:"Sessions"}),e.jsx(g,{className:"text-right",children:"Requests"}),e.jsx(g,{className:"text-right",children:"Tokens"})]})}),e.jsx(Q,{children:r.map(o=>e.jsxs(D,{children:[e.jsxs(h,{children:[e.jsx("div",{className:"font-medium",children:Qa(o)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:o.account_key})]}),e.jsx(h,{children:Za(o.account_tool)}),e.jsx(h,{className:"text-muted-foreground",children:o.account_source}),e.jsx(h,{className:"text-right tabular-nums",children:Ae(o.api_equivalent_usd??o.cost_usd)}),e.jsx(h,{className:"text-right tabular-nums",children:Ae(o.billable_usd??o.metered_api_usd??0)}),e.jsx(h,{className:"text-right tabular-nums",children:Ae(o.subscription_included_usd??0)}),e.jsx(h,{className:"text-right tabular-nums",children:o.sessions.toLocaleString("en-US")}),e.jsx(h,{className:"text-right tabular-nums",children:o.requests.toLocaleString("en-US")}),e.jsx(h,{className:"text-right tabular-nums",children:Ya(o.total_tokens)})]},o.account_key))})]})]})]})})}const sr=[{value:"claude",label:"Claude"},{value:"takumi",label:"Takumi"},{value:"codex",label:"Codex"},{value:"gemini",label:"Gemini"},{value:"opencode",label:"OpenCode"},{value:"cursor",label:"Cursor"},{value:"pi",label:"Pi"},{value:"hermes",label:"Hermes"}],ns={id:"",provider:"",plan:"",agent:"all",monthly_fee_usd:"",included_usage_usd:"",billing_cycle_start:"",reset_policy:"monthly",active:!0};function re(s){return"$"+(s??0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}function ze(s){return`${s.provider} / ${s.plan}`}function tr(){const[s,a]=t.useState(null),[r,c]=t.useState([]),[l,u]=t.useState(!0),[x,m]=t.useState(null),[d,o]=t.useState(ns),[n,f]=t.useState(!1),[v,k]=t.useState(null),w=t.useCallback(()=>{u(!0),m(null),Promise.all([Yt("month"),Zt()]).then(([i,b])=>{a(i.data),c(b.data)}).catch(i=>m(i instanceof Error?i.message:"Failed to load savings")).finally(()=>u(!1))},[]);t.useEffect(()=>{queueMicrotask(w);const i=setInterval(w,3e4);return()=>clearInterval(i)},[w]);const A=Object.entries(s?.by_agent??{}).sort(([i],[b])=>i.localeCompare(b)),_=[...r].sort((i,b)=>ze(i).localeCompare(ze(b))),M=r.filter(i=>i.active!==0),R=M.reduce((i,b)=>i+(b.monthly_fee_usd??0),0),E=M.reduce((i,b)=>i+(b.included_usage_usd??0),0),$=(i,b)=>{o(P=>({...P,[i]:b}))},L=()=>{o(ns),k(null)},J=i=>{o({id:i.id,provider:i.provider,plan:i.plan,agent:i.agent??"all",monthly_fee_usd:String(i.monthly_fee_usd??0),included_usage_usd:String(i.included_usage_usd??0),billing_cycle_start:i.billing_cycle_start??"",reset_policy:i.reset_policy||"monthly",active:i.active!==0}),k(null)},H=async i=>{try{await ea(i),d.id===i&&L(),w()}catch(b){k(b instanceof Error?b.message:"Delete failed")}},z=async i=>{i.preventDefault();const b=Number(d.monthly_fee_usd||0),P=Number(d.included_usage_usd||0);if(!d.provider.trim()){k("Provider is required");return}if(!d.plan.trim()){k("Plan is required");return}if(!Number.isFinite(b)||b<0){k("Monthly fee must be non-negative");return}if(!Number.isFinite(P)||P<0){k("Included usage must be non-negative");return}f(!0),k(null);try{await Qt({id:d.id||void 0,provider:d.provider.trim(),plan:d.plan.trim(),agent:d.agent==="all"?null:d.agent,monthly_fee_usd:b,included_usage_usd:P,billing_cycle_start:d.billing_cycle_start||null,reset_policy:d.reset_policy||"monthly",active:d.active}),L(),w()}catch(F){k(F instanceof Error?F.message:"Failed to save subscription")}finally{f(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs(O,{className:"text-sm flex items-center gap-2",children:[e.jsx(ft,{className:"size-4 text-green-500"}),"Subscription vs API Savings — This Month"]})}),e.jsxs(G,{className:"space-y-4",children:[x&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:x}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[{label:"API Equivalent",value:s?.api_equivalent_usd},{label:"Subscription Fee",value:s?.subscription_fee_usd},{label:"On-demand",value:s?.on_demand_usd},{label:"Saved",value:s?.saved_usd}].map(i=>e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:i.label}),e.jsx("div",{className:"mt-1 text-xl font-semibold",children:l?"...":re(i.value??0)})]},i.label))}),A.length>0&&e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(D,{children:[e.jsx(g,{children:"Agent"}),e.jsx(g,{className:"text-right",children:"API Equiv."}),e.jsx(g,{className:"text-right",children:"Included"}),e.jsx(g,{className:"text-right",children:"Fee"}),e.jsx(g,{className:"text-right",children:"Saved"})]})}),e.jsx(Q,{children:A.map(([i,b])=>e.jsxs(D,{children:[e.jsx(h,{className:"font-medium capitalize",children:i}),e.jsx(h,{className:"text-right",children:re(b.api_equivalent_usd??0)}),e.jsx(h,{className:"text-right",children:re(b.included_consumed_usd??0)}),e.jsx(h,{className:"text-right",children:re(b.subscription_fee_usd??0)}),e.jsx(h,{className:"text-right text-green-600 dark:text-green-400",children:re(b.saved_usd??0)})]},i))})]})]})]}),e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs(O,{className:"text-sm flex items-center gap-2",children:[e.jsx(we,{className:"size-4"}),"Subscription Plans"]})}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:"Active Plans"}),e.jsx("div",{className:"mt-1 text-xl font-semibold",children:l?"...":M.length})]}),e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:"Monthly Fee"}),e.jsx("div",{className:"mt-1 text-xl font-semibold",children:l?"...":re(R)})]}),e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:"Included Cap"}),e.jsx("div",{className:"mt-1 text-xl font-semibold",children:l?"...":re(E)})]})]}),_.length===0&&!l?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No subscription plans configured."}):e.jsx("div",{className:"rounded-md border",children:e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(D,{children:[e.jsx(g,{children:"Plan"}),e.jsx(g,{children:"Agent"}),e.jsx(g,{className:"text-right",children:"Fee"}),e.jsx(g,{className:"text-right",children:"Included"}),e.jsx(g,{children:"Reset"}),e.jsx(g,{children:"Status"}),e.jsx(g,{className:"w-20"})]})}),e.jsx(Q,{children:_.map(i=>e.jsxs(D,{children:[e.jsxs(h,{children:[e.jsx("div",{className:"font-medium",children:ze(i)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:i.id})]}),e.jsx(h,{className:"capitalize",children:i.agent??"All"}),e.jsx(h,{className:"text-right tabular-nums",children:re(i.monthly_fee_usd??0)}),e.jsx(h,{className:"text-right tabular-nums",children:re(i.included_usage_usd??0)}),e.jsx(h,{className:"text-muted-foreground",children:i.reset_policy||"monthly"}),e.jsx(h,{children:i.active===0?"Inactive":"Active"}),e.jsx(h,{children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(C,{type:"button",variant:"ghost",size:"icon",className:"size-7",title:"Edit subscription",onClick:()=>J(i),children:e.jsx(Oe,{className:"size-3.5"})}),e.jsx(C,{type:"button",variant:"ghost",size:"icon",className:"size-7",title:"Delete subscription",onClick:()=>H(i.id),children:e.jsx(Ce,{className:"size-3.5"})})]})})]},i.id))})]})}),e.jsxs("form",{onSubmit:z,className:"space-y-4 rounded-md border p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium",children:d.id?"Edit Subscription":"Add Subscription"}),d.id&&e.jsx(C,{type:"button",variant:"outline",size:"sm",onClick:L,children:"Clear"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Provider"}),e.jsx(U,{value:d.provider,onChange:i=>$("provider",i.target.value),placeholder:"anthropic",required:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Plan"}),e.jsx(U,{value:d.plan,onChange:i=>$("plan",i.target.value),placeholder:"claude max",required:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Agent"}),e.jsxs("select",{value:d.agent,onChange:i=>$("agent",i.target.value),className:"h-9 w-full rounded-md border border-input bg-background px-3 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[e.jsx("option",{value:"all",children:"All agents"}),sr.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Reset Policy"}),e.jsxs("select",{value:d.reset_policy,onChange:i=>$("reset_policy",i.target.value),className:"h-9 w-full rounded-md border border-input bg-background px-3 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[e.jsx("option",{value:"monthly",children:"Monthly"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"manual",children:"Manual"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Monthly Fee (USD)"}),e.jsx(U,{type:"number",step:"0.01",min:"0",value:d.monthly_fee_usd,onChange:i=>$("monthly_fee_usd",i.target.value),placeholder:"20.00"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Included Usage (USD)"}),e.jsx(U,{type:"number",step:"0.01",min:"0",value:d.included_usage_usd,onChange:i=>$("included_usage_usd",i.target.value),placeholder:"20.00"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Billing Cycle Start"}),e.jsx(U,{type:"date",value:d.billing_cycle_start,onChange:i=>$("billing_cycle_start",i.target.value)})]}),e.jsxs("label",{className:"flex items-center gap-2 pt-6 text-sm",children:[e.jsx("input",{type:"checkbox",checked:d.active,onChange:i=>$("active",i.target.checked),className:"size-4"}),"Active"]})]}),v&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:v}),e.jsx(C,{type:"submit",disabled:n,children:n?"Saving...":d.id?"Update Subscription":"Add Subscription"})]})]})]})]})}function ls(s){return"$"+(s??0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}function je(s){return s?new Date(s).toLocaleString():"—"}function ar(){const[s,a]=t.useState(null),[r,c]=t.useState(!0),[l,u]=t.useState(null),x=t.useCallback(()=>{c(!0),u(null),sa("month").then(o=>a(o.data)).catch(o=>u(o instanceof Error?o.message:"Failed to load fleet")).finally(()=>c(!1))},[]);t.useEffect(()=>{queueMicrotask(x);const o=setInterval(x,3e4);return()=>clearInterval(o)},[x]);const m=s?.machines??[],d=s?.registry??[];return e.jsx("div",{className:"space-y-6",children:e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs(O,{className:"text-sm flex items-center gap-2",children:[e.jsx(pt,{className:"size-4 text-purple-500"}),"Fleet — All Machines",s?.current_machine&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(this machine: ",s.current_machine,")"]})]})}),e.jsxs(G,{className:"space-y-6",children:[l&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:l}),e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:"Month-to-date (all machines)"}),e.jsx("div",{className:"mt-1 text-2xl font-semibold",children:r?"Loading...":ls(s?.summary?.total_usd??0)}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:[s?.summary?.sessions??0," sessions · ",s?.summary?.requests??0," requests"]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-2 text-sm font-medium",children:"Spend by machine"}),m.length===0&&!r?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No machine data yet."}):e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(D,{children:[e.jsx(g,{children:"Machine"}),e.jsx(g,{className:"text-right",children:"Cost"}),e.jsx(g,{className:"text-right",children:"Sessions"}),e.jsx(g,{className:"text-right",children:"Requests"}),e.jsx(g,{children:"Last active"})]})}),e.jsx(Q,{children:m.map(o=>e.jsxs(D,{children:[e.jsx(h,{className:"font-medium",children:o.machine_id}),e.jsx(h,{className:"text-right",children:ls(o.total_cost_usd)}),e.jsx(h,{className:"text-right",children:o.sessions}),e.jsx(h,{className:"text-right",children:o.requests}),e.jsx(h,{className:"text-muted-foreground",children:je(o.last_active)})]},o.machine_id))})]})]}),d.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"mb-2 text-sm font-medium",children:"Sync registry"}),e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(D,{children:[e.jsx(g,{children:"Machine"}),e.jsx(g,{children:"Version"}),e.jsx(g,{children:"Last seen"}),e.jsx(g,{children:"Last push"}),e.jsx(g,{children:"Last pull"})]})}),e.jsx(Q,{children:d.map(o=>e.jsxs(D,{children:[e.jsx(h,{className:"font-medium",children:o.machine_id}),e.jsx(h,{className:"text-muted-foreground",children:o.economy_version??"—"}),e.jsx(h,{className:"text-muted-foreground",children:je(o.last_seen_at)}),e.jsx(h,{className:"text-muted-foreground",children:je(o.last_push_at)}),e.jsx(h,{className:"text-muted-foreground",children:je(o.last_pull_at)})]},o.machine_id))})]})]})]})]})})}function be(s){return"$"+(s??0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}function rr(){const[s,a]=t.useState(null),[r,c]=t.useState(!0),[l,u]=t.useState(!1),[x,m]=t.useState(null),d=t.useCallback(()=>{c(!0),m(null),Ht("month").then(n=>a(n.data)).catch(n=>m(n instanceof Error?n.message:"Failed to load reconciliation")).finally(()=>c(!1))},[]);t.useEffect(()=>{queueMicrotask(d);const n=setInterval(d,6e4);return()=>clearInterval(n)},[d]);const o=async()=>{u(!0),m(null);try{await gs({days:31,providers:["anthropic","openai","gemini"]}),d()}catch(n){m(n instanceof Error?n.message:"Billing sync failed")}finally{u(!1)}};return e.jsx("div",{className:"space-y-6",children:e.jsxs(q,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(O,{className:"text-sm flex items-center gap-2",children:[e.jsx(jt,{className:"size-4 text-amber-500"}),"Billing Reconciliation — This Month"]}),e.jsx(C,{size:"sm",onClick:o,disabled:l,children:l?"Syncing...":"Sync Billing"})]})}),e.jsxs(G,{className:"space-y-4",children:[x&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:x}),s?.is_alert&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-amber-200 bg-amber-50 p-3 text-sm text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200",children:[e.jsx(is,{className:"size-4 shrink-0"}),"Estimated spend differs from provider billing by more than ",s.threshold_pct,"%."]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[{label:"Estimated (telemetry)",value:s?.estimated_usd},{label:"Actual (billing)",value:s?.actual_usd},{label:"Delta",value:s?.delta_usd},{label:"Delta %",value:s?.delta_pct,isPct:!0}].map(n=>e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:n.label}),e.jsx("div",{className:"mt-1 text-xl font-semibold",children:r?"…":n.isPct?`${(n.value??0).toFixed(1)}%`:be(n.value??0)})]},n.label))}),(s?.by_agent?.length??0)>0&&e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(D,{children:[e.jsx(g,{children:"Agent"}),e.jsx(g,{className:"text-right",children:"Estimated"}),e.jsx(g,{className:"text-right",children:"Actual"}),e.jsx(g,{className:"text-right",children:"Delta"})]})}),e.jsx(Q,{children:s.by_agent.map(n=>e.jsxs(D,{children:[e.jsx(h,{className:"font-medium capitalize",children:n.agent}),e.jsx(h,{className:"text-right",children:be(n.estimated_usd)}),e.jsx(h,{className:"text-right",children:be(n.actual_usd)}),e.jsxs(h,{className:"text-right",children:[be(n.delta_usd)," (",n.delta_pct.toFixed(1),"%)"]})]},n.agent))})]})]})]})})}const ks=t.forwardRef(({className:s,children:a,...r},c)=>e.jsx(bt,{ref:c,className:S("relative z-10 flex max-w-max flex-1 items-center justify-center",s),...r,children:a}));ks.displayName="NavigationMenu";const _s=t.forwardRef(({className:s,...a},r)=>e.jsx(Nt,{ref:r,className:S("group flex flex-1 list-none items-center justify-center gap-1",s),...a}));_s.displayName="NavigationMenuList";const nr=vt,lr=yt,ir=()=>"group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50",cr=[{key:"overview",label:"Overview"},{key:"sessions",label:"Sessions"},{key:"models",label:"Models"},{key:"projects",label:"Projects"},{key:"budgets",label:"Budgets"},{key:"goals",label:"Goals"},{key:"usage",label:"Usage"},{key:"accounts",label:"Accounts"},{key:"savings",label:"Savings"},{key:"fleet",label:"Fleet"},{key:"reconciliation",label:"Reconcile"},{key:"pricing",label:"Pricing"},{key:"billing",label:"Billing"}];function or(){const[s,a]=t.useState(0),[r,c]=t.useState(0);t.useEffect(()=>{const m=Date.now();a(m),c(m);const d=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(d)},[]);const l=t.useCallback(()=>{const m=Date.now();a(m),c(m)},[]),u=Math.round((s-r)/1e3);return{text:u<5?"just now":`${u}s ago`,markReloaded:l}}function dr(){const[s,a]=t.useState("overview"),[r,c]=t.useState(!1),[l,u]=t.useState(0),{text:x,markReloaded:m}=or(),d=t.useCallback(()=>{c(!0),u(o=>o+1),m(),setTimeout(()=>c(!1),500)},[m]);return t.useEffect(()=>{const o=setInterval(()=>m(),3e4);return()=>clearInterval(o)},[m]),t.useEffect(()=>{function o(n){const f=n.target?.tagName;f==="INPUT"||f==="TEXTAREA"||f==="SELECT"||n.key==="r"&&!n.ctrlKey&&!n.metaKey&&d()}return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[d]),e.jsxs("div",{className:"min-h-screen",children:[e.jsx("header",{className:"border-b",children:e.jsxs("div",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("button",{className:"flex items-center gap-3 hover:opacity-80 transition-opacity",onClick:()=>a("overview"),children:[e.jsx("img",{src:"/logo.jpg",alt:"Hasna",className:"h-7 w-auto rounded"}),e.jsx("h1",{className:"text-base font-semibold",children:"Economy"})]}),e.jsx(ks,{children:e.jsx(_s,{children:cr.map(o=>e.jsx(nr,{children:e.jsx(lr,{className:ir(),"data-active":s===o.key?"":void 0,onClick:()=>a(o.key),style:{cursor:"pointer"},children:o.label})},o.key))})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground hidden sm:inline",children:["Updated ",x]}),e.jsx(C,{variant:"outline",size:"icon",className:"size-8",onClick:d,disabled:r,title:"Reload (r)",children:e.jsx(ne,{className:`size-4 ${r?"animate-spin":""}`})}),e.jsx(Mt,{})]})]})}),e.jsxs("main",{className:"mx-auto max-w-6xl space-y-6 px-6 py-6",children:[s==="overview"&&e.jsx(ga,{},l),s==="sessions"&&e.jsx(_a,{},l),s==="models"&&e.jsx($a,{},l),s==="projects"&&e.jsx(Ma,{},l),s==="budgets"&&e.jsx(Aa,{},l),s==="goals"&&e.jsx(Oa,{},l),s==="usage"&&e.jsx(Ja,{},l),s==="accounts"&&e.jsx(er,{},l),s==="savings"&&e.jsx(tr,{},l),s==="fleet"&&e.jsx(ar,{},l),s==="reconciliation"&&e.jsx(rr,{},l),s==="pricing"&&e.jsx(Ka,{},l),s==="billing"&&e.jsx(Wa,{},l)]})]})}function ur(){return e.jsx(Rt,{defaultTheme:"system",storageKey:"economy-dashboard-theme",children:e.jsx(dr,{})})}St.createRoot(document.getElementById("root")).render(e.jsx(t.StrictMode,{children:e.jsx(ur,{})}));
|