@meyicloud/meyi-cost-ui 1.5.9 → 1.5.11

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/README.md CHANGED
@@ -1,17 +1,17 @@
1
1
  # Meyi Insight Cost UI
2
2
 
3
3
  Reusable React UI package for AWS cost overview, monthly/yearly trends,
4
- service/account/region breakdowns, standard and comparison reports, scheduled
5
- AI report history and downloads plus standard CSV/PDF cost exports.
4
+ service/account/region breakdowns, standard and comparison reports, scheduled
5
+ AI report history and downloads plus standard CSV/PDF cost exports.
6
6
 
7
7
  The package is intended to run inside an authenticated host application. It
8
8
  does not contain AWS credentials, query AWS directly, perform login, or decide
9
9
  whether a plugin is enabled for a tenant. Those responsibilities remain with
10
- the host and `@meyicloud/meyi-cost-server`.
10
+ the host and `@meyicloud/meyi-cost-server`.
11
11
 
12
12
  ## Package contract
13
13
 
14
- - Package name: `@meyicloud/meyi-cost-ui`
14
+ - Package name: `@meyicloud/meyi-cost-ui`
15
15
  - Runtime: React 19 and React DOM 19, supplied by the consuming application
16
16
  - Module outputs: ESM, CommonJS, TypeScript declarations, and CSS
17
17
  - Default UI route: `/cost`
@@ -24,7 +24,7 @@ flowchart LR
24
24
  Host[External React application] --> Route[Authenticated /cost/* route]
25
25
  Route --> Page[CostPage]
26
26
  Page --> Router[Package router]
27
- Router --> Features[Overview / AI Analysis / Reports / Sources]
27
+ Router --> Features[Overview / AI Analysis / Reports / Sources]
28
28
  Features --> Hooks[Feature hooks]
29
29
  Hooks --> Service[costService]
30
30
  Service --> API[Configured Axios client]
@@ -90,7 +90,7 @@ For a local package installation test:
90
90
 
91
91
  ```bash
92
92
  npm pack
93
- npm install /path/to/meyicloud-meyi-cost-ui-1.4.0.tgz
93
+ npm install /path/to/meyicloud-meyi-cost-ui-1.4.0.tgz
94
94
  ```
95
95
 
96
96
  ## Publish to npm
@@ -113,8 +113,8 @@ that semantic-version change. The `prepublishOnly` script automatically runs
113
113
  After publishing, verify from a clean consumer project:
114
114
 
115
115
  ```bash
116
- npm view @meyicloud/meyi-cost-ui version
117
- npm install @meyicloud/meyi-cost-ui@<published-version>
116
+ npm view @meyicloud/meyi-cost-ui version
117
+ npm install @meyicloud/meyi-cost-ui@<published-version>
118
118
  ```
119
119
 
120
120
  ## Integrate with an external React application
@@ -122,7 +122,7 @@ npm install @meyicloud/meyi-cost-ui@<published-version>
122
122
  Install the published package:
123
123
 
124
124
  ```bash
125
- npm install @meyicloud/meyi-cost-ui
125
+ npm install @meyicloud/meyi-cost-ui
126
126
  ```
127
127
 
128
128
  For local development before publishing, add a file dependency:
@@ -130,7 +130,7 @@ For local development before publishing, add a file dependency:
130
130
  ```json
131
131
  {
132
132
  "dependencies": {
133
- "@meyicloud/meyi-cost-ui": "file:../../meyi-market-places/insight-cost-ui"
133
+ "@meyicloud/meyi-cost-ui": "file:../../meyi-market-places/insight-cost-ui"
134
134
  }
135
135
  }
136
136
  ```
@@ -139,12 +139,12 @@ Build the UI package before building the host when using a file dependency.
139
139
 
140
140
  ### 1. Add an authenticated wildcard route
141
141
 
142
- The route must accept child paths such as `/cost/reports` and `/cost/analysis`.
142
+ The route must accept child paths such as `/cost/reports` and `/cost/analysis`.
143
143
  The exact wildcard syntax depends on the host router.
144
144
 
145
145
  ```tsx
146
- import { CostPage } from "@meyicloud/meyi-cost-ui";
147
- import "@meyicloud/meyi-cost-ui/style.css";
146
+ import { CostPage } from "@meyicloud/meyi-cost-ui";
147
+ import "@meyicloud/meyi-cost-ui/style.css";
148
148
 
149
149
  export function CostPluginRoute() {
150
150
  const token = getCurrentAccessToken();
@@ -171,7 +171,7 @@ or use the included local-storage helper:
171
171
  import {
172
172
  api as costApi,
173
173
  attachAuthInterceptors,
174
- } from "@meyicloud/meyi-cost-ui";
174
+ } from "@meyicloud/meyi-cost-ui";
175
175
 
176
176
  attachAuthInterceptors(costApi);
177
177
  ```
@@ -188,8 +188,8 @@ apply authentication and tenant resolution before the cost endpoints.
188
188
 
189
189
  ### 4. Add navigation and plugin enablement
190
190
 
191
- The package exports `costNavItems` for Overview, AI Analysis, Reports, Sources,
192
- and CUR Discovery. The host
191
+ The package exports `costNavItems` for Overview, AI Analysis, Reports, Sources,
192
+ and CUR Discovery. The host
193
193
  may map these entries into its sidebar. Tenant-level installation, role checks,
194
194
  and dynamic menu visibility remain host responsibilities.
195
195
 
@@ -200,7 +200,7 @@ and dynamic menu visibility remain host responsibilities.
200
200
  | `apiBase` | Yes | None | Base API prefix. `/cost` is appended automatically. |
201
201
  | `basePath` | No | `/cost` | Router base path where the host mounts the UI. |
202
202
  | `token` | No | None | Bearer token added to cost API requests. |
203
- | `userRole` | No | `user` | Controls visibility of AI report schedule settings. The server independently requires the admin role when saving. |
203
+ | `userRole` | No | `user` | Controls visibility of AI report schedule settings. The server independently requires the admin role when saving. |
204
204
 
205
205
  ## Environment variables
206
206
 
@@ -220,7 +220,7 @@ VITE_API_BASE=/api/v1
220
220
  ```
221
221
 
222
222
  `VITE_API_BASE` is only an example host variable; it is not consumed by
223
- `@meyicloud/meyi-cost-ui` itself. Never define `AWS_ACCESS_KEY_ID`,
223
+ `@meyicloud/meyi-cost-ui` itself. Never define `AWS_ACCESS_KEY_ID`,
224
224
  `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`, database credentials, or other
225
225
  secrets in the frontend environment because browser build variables are
226
226
  visible to users.
@@ -234,8 +234,8 @@ The UI consumes these routes below `${apiBase}/cost`:
234
234
  - `GET /data-status`
235
235
  - `GET /filter-options`
236
236
  - `GET /reports`
237
- - `GET /tags`
238
- - `GET /analysis/status`, `GET /analysis/latest`, and `POST /analysis`
237
+ - `GET /tags`
238
+ - `GET /analysis/status`, `GET /analysis/latest`, and `POST /analysis`
239
239
  - `GET /budget-alert-dismissals` and `POST /budget-alert-dismissals`
240
240
 
241
241
  Use the matching cost server version whenever API response contracts change.
@@ -248,11 +248,11 @@ Use the matching cost server version whenever API response contracts change.
248
248
 
249
249
  ## Consumer validation checklist
250
250
 
251
- 1. Build `@meyicloud/meyi-cost-ui`.
251
+ 1. Build `@meyicloud/meyi-cost-ui`.
252
252
  2. Install or refresh the package in the host.
253
253
  3. Build the host frontend.
254
254
  4. Verify direct navigation and refresh for `/cost`, `/cost/reports`, and
255
- `/cost/analysis`.
255
+ `/cost/analysis`.
256
256
  5. Verify authenticated requests reach `/api/v1/cost` with the correct tenant.
257
257
  6. Test loading, empty, error, monthly/yearly, graph/list, report filters,
258
258
  compare mode, pagination, and PDF/CSV export states.
package/dist/index.js CHANGED
@@ -14,11 +14,11 @@ React keys must be passed directly to JSX without using spread:
14
14
  `+o)}}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=pt(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Dn.assertOptions(r,{silentJSONParsing:ge.transitional(ge.boolean),forcedJSONParsing:ge.transitional(ge.boolean),clarifyTimeoutError:ge.transitional(ge.boolean),legacyInterceptorReqResOrdering:ge.transitional(ge.boolean),advertiseZstdAcceptEncoding:ge.transitional(ge.boolean),validateStatusUndefinedResolves:ge.transitional(ge.boolean)},!1),s!=null&&(w.isFunction(s)?n.paramsSerializer={serialize:s}:Dn.assertOptions(s,{encode:ge.function,serialize:ge.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Dn.assertOptions(n,{baseUrl:ge.spelling("baseURL"),withXsrfToken:ge.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&w.merge(o.common,o[n.method]);o&&w.forEach(["delete","get","head","post","put","patch","query","common"],g=>{delete o[g]}),n.headers=be.concat(i,o);const c=[];let u=!0;this.interceptors.request.forEach(function(p){if(typeof p.runWhen=="function"&&p.runWhen(n)===!1)return;u=u&&p.synchronous;const x=n.transitional||cs;x&&x.legacyInterceptorReqResOrdering?c.unshift(p.fulfilled,p.rejected):c.push(p.fulfilled,p.rejected)});const f=[];this.interceptors.response.forEach(function(p){f.push(p.fulfilled,p.rejected)});let d,l=0,h;if(!u){const g=[bo.bind(this),void 0];for(g.unshift(...c),g.push(...f),h=g.length,d=Promise.resolve(n);l<h;)d=d.then(g[l++],g[l++]);return d}h=c.length;let m=n;for(;l<h;){const g=c[l++],p=c[l++];try{m=g(m)}catch(x){p.call(this,x);break}}try{d=bo.call(this,m)}catch(g){return Promise.reject(g)}for(l=0,h=f.length;l<h;)d=d.then(f[l++],f[l++]);return d}getUri(t){t=pt(this.defaults,t);const n=Ja(t.baseURL,t.url,t.allowAbsoluteUrls,t);return Ha(n,t.params,t.paramsSerializer)}};w.forEach(["delete","get","head","options"],function(t){ft.prototype[t]=function(n,r){return this.request(pt(r||{},{method:t,url:n,data:r&&w.hasOwnProp(r,"data")?r.data:void 0}))}});w.forEach(["post","put","patch","query"],function(t){function n(r){return function(o,i,c){return this.request(pt(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}ft.prototype[t]=n(),t!=="query"&&(ft.prototype[t+"Form"]=n(!0))});let tf=class ei{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new dn(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new ei(function(s){t=s}),cancel:t}}};function nf(e){return function(n){return e.apply(null,n)}}function rf(e){return w.isObject(e)&&e.isAxiosError===!0}const Kr={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Kr).forEach(([e,t])=>{Kr[t]=e});function ti(e){const t=new ft(e),n=Aa(ft.prototype.request,t);return w.extend(n,ft.prototype,t,{allOwnKeys:!0}),w.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return ti(pt(e,s))},n}const ae=ti(un);ae.Axios=ft;ae.CanceledError=dn;ae.CancelToken=tf;ae.isCancel=Ka;ae.VERSION=us;ae.toFormData=sr;ae.AxiosError=T;ae.Cancel=ae.CanceledError;ae.all=function(t){return Promise.all(t)};ae.spread=nf;ae.isAxiosError=rf;ae.mergeConfig=pt;ae.AxiosHeaders=be;ae.formToJSON=e=>Ga(w.isHTMLForm(e)?new FormData(e):e);ae.getAdapter=Qa.getAdapter;ae.HttpStatusCode=Kr;ae.default=ae;const{Axios:wg,AxiosError:Sg,CanceledError:Rg,isCancel:Ng,CancelToken:Cg,VERSION:jg,all:Eg,Cancel:_g,isAxiosError:kg,spread:Pg,toFormData:Ag,AxiosHeaders:Og,HttpStatusCode:Tg,formToJSON:Lg,getAdapter:Ig,mergeConfig:Mg,create:Dg}=ae,ne=ae.create({baseURL:"/api/v1/cost"});function ni(e,t){ne.defaults.baseURL=`${e.replace(/\/$/,"")}/cost`,t?ne.defaults.headers.common.Authorization=`Bearer ${t}`:delete ne.defaults.headers.common.Authorization}function sf(e){e.interceptors.request.use(t=>{if(typeof window<"u"){const n=window.localStorage.getItem("access_token");n?(t.headers=t.headers||{},t.headers.Authorization=`Bearer ${n}`):t.headers&&delete t.headers.Authorization}return t})}const of=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),af=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),vo=e=>{const t=af(e);return t.charAt(0).toUpperCase()+t.slice(1)},ri=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),cf=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var lf={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const uf=P.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:i,...c},u)=>P.createElement("svg",{ref:u,...lf,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:ri("lucide",s),...!o&&!cf(c)&&{"aria-hidden":"true"},...c},[...i.map(([f,d])=>P.createElement(f,d)),...Array.isArray(o)?o:[o]]));const ee=(e,t)=>{const n=P.forwardRef(({className:r,...s},o)=>P.createElement(uf,{ref:o,iconNode:t,className:ri(`lucide-${of(vo(e))}`,`lucide-${e}`,r),...s}));return n.displayName=vo(e),n};const df=[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],si=ee("building-2",df);const ff=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],oi=ee("calendar-clock",ff);const hf=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],mf=ee("chart-column",hf);const pf=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],gf=ee("chevron-down",pf);const xf=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],bf=ee("chevron-left",xf);const yf=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],vf=ee("chevron-right",yf);const wf=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ze=ee("circle-alert",wf);const Sf=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Rf=ee("circle-check",Sf);const Nf=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],Jn=ee("cloud",Nf);const Cf=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],ai=ee("database",Cf);const jf=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],ii=ee("dollar-sign",jf);const Ef=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],fs=ee("download",Ef);const _f=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ci=ee("external-link",_f);const kf=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Pf=ee("eye",kf);const Af=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],Of=ee("file-down",Af);const Tf=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],li=ee("file-text",Tf);const Lf=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],If=ee("list",Lf);const Mf=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ct=ee("loader-circle",Mf);const Df=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Ff=ee("map-pin",Df);const Uf=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],$f=ee("plus",Uf);const Bf=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Tt=ee("refresh-cw",Bf);const zf=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],hs=ee("search",zf);const Wf=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],ui=ee("server",Wf);const Vf=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],di=ee("settings-2",Vf);const Hf=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],wo=ee("sparkles",Hf);const qf=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],fi=ee("trash-2",qf);const Gf=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],Kf=ee("trending-down",Gf);const Yf=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],hi=ee("trending-up",Yf);const Jf=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Lt=ee("x",Jf);function mi(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=mi(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Xf(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=mi(e))&&(r&&(r+=" "),r+=t);return r}const Zf=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Qf=(e,t)=>({classGroupId:e,validator:t}),pi=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Xn="-",So=[],eh="arbitrary..",th=e=>{const t=rh(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return nh(i);const c=i.split(Xn),u=c[0]===""&&c.length>1?1:0;return gi(c,u,t)},getConflictingClassGroupIds:(i,c)=>{if(c){const u=r[i],f=n[i];return u?f?Zf(f,u):u:f||So}return n[i]||So}}},gi=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const s=e[t],o=n.nextPart.get(s);if(o){const f=gi(e,t+1,o);if(f)return f}const i=n.validators;if(i===null)return;const c=t===0?e.join(Xn):e.slice(t).join(Xn),u=i.length;for(let f=0;f<u;f++){const d=i[f];if(d.validator(c))return d.classGroupId}},nh=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?eh+r:void 0})(),rh=e=>{const{theme:t,classGroups:n}=e;return sh(n,t)},sh=(e,t)=>{const n=pi();for(const r in e){const s=e[r];ms(s,n,r,t)}return n},ms=(e,t,n,r)=>{const s=e.length;for(let o=0;o<s;o++){const i=e[o];oh(i,t,n,r)}},oh=(e,t,n,r)=>{if(typeof e=="string"){ah(e,t,n);return}if(typeof e=="function"){ih(e,t,n,r);return}ch(e,t,n,r)},ah=(e,t,n)=>{const r=e===""?t:xi(t,e);r.classGroupId=n},ih=(e,t,n,r)=>{if(lh(e)){ms(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Qf(n,e))},ch=(e,t,n,r)=>{const s=Object.entries(e),o=s.length;for(let i=0;i<o;i++){const[c,u]=s[i];ms(u,xi(t,c),n,r)}},xi=(e,t)=>{let n=e;const r=t.split(Xn),s=r.length;for(let o=0;o<s;o++){const i=r[o];let c=n.nextPart.get(i);c||(c=pi(),n.nextPart.set(i,c)),n=c}return n},lh=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,uh=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const s=(o,i)=>{n[o]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(o){let i=n[o];if(i!==void 0)return i;if((i=r[o])!==void 0)return s(o,i),i},set(o,i){o in n?n[o]=i:s(o,i)}}},Yr="!",Ro=":",dh=[],No=(e,t,n,r,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:s}),fh=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=s=>{const o=[];let i=0,c=0,u=0,f;const d=s.length;for(let p=0;p<d;p++){const x=s[p];if(i===0&&c===0){if(x===Ro){o.push(s.slice(u,p)),u=p+1;continue}if(x==="/"){f=p;continue}}x==="["?i++:x==="]"?i--:x==="("?c++:x===")"&&c--}const l=o.length===0?s:s.slice(u);let h=l,m=!1;l.endsWith(Yr)?(h=l.slice(0,-1),m=!0):l.startsWith(Yr)&&(h=l.slice(1),m=!0);const g=f&&f>u?f-u:void 0;return No(o,m,h,g)};if(t){const s=t+Ro,o=r;r=i=>i.startsWith(s)?o(i.slice(s.length)):No(dh,!1,i,void 0,!0)}if(n){const s=r;r=o=>n({className:o,parseClassName:s})}return r},hh=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let s=[];for(let o=0;o<n.length;o++){const i=n[o],c=i[0]==="[",u=t.has(i);c||u?(s.length>0&&(s.sort(),r.push(...s),s=[]),r.push(i)):s.push(i)}return s.length>0&&(s.sort(),r.push(...s)),r}},mh=e=>({cache:uh(e.cacheSize),parseClassName:fh(e),sortModifiers:hh(e),postfixLookupClassGroupIds:ph(e),...th(e)}),ph=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},gh=/\s+/,xh=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:o,postfixLookupClassGroupIds:i}=t,c=[],u=e.trim().split(gh);let f="";for(let d=u.length-1;d>=0;d-=1){const l=u[d],{isExternal:h,modifiers:m,hasImportantModifier:g,baseClassName:p,maybePostfixModifierPosition:x}=n(l);if(h){f=l+(f.length>0?" "+f:f);continue}let b=!!x,y;if(b){const C=p.substring(0,x);y=r(C);const R=y&&i[y]?r(p):void 0;R&&R!==y&&(y=R,b=!1)}else y=r(p);if(!y){if(!b){f=l+(f.length>0?" "+f:f);continue}if(y=r(p),!y){f=l+(f.length>0?" "+f:f);continue}b=!1}const v=m.length===0?"":m.length===1?m[0]:o(m).join(":"),N=g?v+Yr:v,j=N+y;if(c.indexOf(j)>-1)continue;c.push(j);const _=s(y,b);for(let C=0;C<_.length;++C){const R=_[C];c.push(N+R)}f=l+(f.length>0?" "+f:f)}return f},bh=(...e)=>{let t=0,n,r,s="";for(;t<e.length;)(n=e[t++])&&(r=bi(n))&&(s&&(s+=" "),s+=r);return s},bi=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=bi(e[r]))&&(n&&(n+=" "),n+=t);return n},yh=(e,...t)=>{let n,r,s,o;const i=u=>{const f=t.reduce((d,l)=>l(d),e());return n=mh(f),r=n.cache.get,s=n.cache.set,o=c,c(u)},c=u=>{const f=r(u);if(f)return f;const d=xh(u,n);return s(u,d),d};return o=i,(...u)=>o(bh(...u))},vh=[],ce=e=>{const t=n=>n[e]||vh;return t.isThemeGetter=!0,t},yi=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,vi=/^\((?:(\w[\w-]*):)?(.+)\)$/i,wh=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Sh=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Rh=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Nh=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Ch=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,jh=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,He=e=>wh.test(e),G=e=>!!e&&!Number.isNaN(Number(e)),Le=e=>!!e&&Number.isInteger(Number(e)),_r=e=>e.endsWith("%")&&G(e.slice(0,-1)),Fe=e=>Sh.test(e),wi=()=>!0,Eh=e=>Rh.test(e)&&!Nh.test(e),ps=()=>!1,_h=e=>Ch.test(e),kh=e=>jh.test(e),Ph=e=>!M(e)&&!F(e),Ah=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),Oh=e=>Qe(e,Ni,ps),M=e=>yi.test(e),nt=e=>Qe(e,Ci,Eh),Co=e=>Qe(e,$h,G),Th=e=>Qe(e,Ei,wi),Lh=e=>Qe(e,ji,ps),jo=e=>Qe(e,Si,ps),Ih=e=>Qe(e,Ri,kh),vn=e=>Qe(e,_i,_h),F=e=>vi.test(e),Kt=e=>xt(e,Ci),Mh=e=>xt(e,ji),Eo=e=>xt(e,Si),Dh=e=>xt(e,Ni),Fh=e=>xt(e,Ri),wn=e=>xt(e,_i,!0),Uh=e=>xt(e,Ei,!0),Qe=(e,t,n)=>{const r=yi.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},xt=(e,t,n=!1)=>{const r=vi.exec(e);return r?r[1]?t(r[1]):n:!1},Si=e=>e==="position"||e==="percentage",Ri=e=>e==="image"||e==="url",Ni=e=>e==="length"||e==="size"||e==="bg-size",Ci=e=>e==="length",$h=e=>e==="number",ji=e=>e==="family-name",Ei=e=>e==="number"||e==="weight",_i=e=>e==="shadow",Bh=()=>{const e=ce("color"),t=ce("font"),n=ce("text"),r=ce("font-weight"),s=ce("tracking"),o=ce("leading"),i=ce("breakpoint"),c=ce("container"),u=ce("spacing"),f=ce("radius"),d=ce("shadow"),l=ce("inset-shadow"),h=ce("text-shadow"),m=ce("drop-shadow"),g=ce("blur"),p=ce("perspective"),x=ce("aspect"),b=ce("ease"),y=ce("animate"),v=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],j=()=>[...N(),F,M],_=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],R=()=>[F,M,u],k=()=>[He,"full","auto",...R()],L=()=>[Le,"none","subgrid",F,M],A=()=>["auto",{span:["full",Le,F,M]},Le,F,M],D=()=>[Le,"auto",F,M],O=()=>["auto","min","max","fr",F,M],$=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],J=()=>["start","end","center","stretch","center-safe","end-safe"],Y=()=>["auto",...R()],Q=()=>[He,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],he=()=>[He,"screen","full","dvw","lvw","svw","min","max","fit",...R()],me=()=>[He,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],I=()=>[e,F,M],E=()=>[...N(),Eo,jo,{position:[F,M]}],B=()=>["no-repeat",{repeat:["","x","y","space","round"]}],q=()=>["auto","cover","contain",Dh,Oh,{size:[F,M]}],K=()=>[_r,Kt,nt],H=()=>["","none","full",f,F,M],z=()=>["",G,Kt,nt],U=()=>["solid","dashed","dotted","double"],Z=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],V=()=>[G,_r,Eo,jo],ie=()=>["","none",g,F,M],le=()=>["none",G,F,M],te=()=>["none",G,F,M],je=()=>[G,F,M],Ce=()=>[He,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Fe],breakpoint:[Fe],color:[wi],container:[Fe],"drop-shadow":[Fe],ease:["in","out","in-out"],font:[Ph],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Fe],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Fe],shadow:[Fe],spacing:["px",G],text:[Fe],"text-shadow":[Fe],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",He,M,F,x]}],container:["container"],"container-type":[{"@container":["","normal","size",F,M]}],"container-named":[Ah],columns:[{columns:[G,M,F,c]}],"break-after":[{"break-after":v()}],"break-before":[{"break-before":v()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:j()}],overflow:[{overflow:_()}],"overflow-x":[{"overflow-x":_()}],"overflow-y":[{"overflow-y":_()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:k()}],"inset-x":[{"inset-x":k()}],"inset-y":[{"inset-y":k()}],start:[{"inset-s":k(),start:k()}],end:[{"inset-e":k(),end:k()}],"inset-bs":[{"inset-bs":k()}],"inset-be":[{"inset-be":k()}],top:[{top:k()}],right:[{right:k()}],bottom:[{bottom:k()}],left:[{left:k()}],visibility:["visible","invisible","collapse"],z:[{z:[Le,"auto",F,M]}],basis:[{basis:[He,"full","auto",c,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[G,He,"auto","initial","none",M]}],grow:[{grow:["",G,F,M]}],shrink:[{shrink:["",G,F,M]}],order:[{order:[Le,"first","last","none",F,M]}],"grid-cols":[{"grid-cols":L()}],"col-start-end":[{col:A()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":L()}],"row-start-end":[{row:A()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":O()}],"auto-rows":[{"auto-rows":O()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...$(),"normal"]}],"justify-items":[{"justify-items":[...J(),"normal"]}],"justify-self":[{"justify-self":["auto",...J()]}],"align-content":[{content:["normal",...$()]}],"align-items":[{items:[...J(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...J(),{baseline:["","last"]}]}],"place-content":[{"place-content":$()}],"place-items":[{"place-items":[...J(),"baseline"]}],"place-self":[{"place-self":["auto",...J()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:Y()}],mx:[{mx:Y()}],my:[{my:Y()}],ms:[{ms:Y()}],me:[{me:Y()}],mbs:[{mbs:Y()}],mbe:[{mbe:Y()}],mt:[{mt:Y()}],mr:[{mr:Y()}],mb:[{mb:Y()}],ml:[{ml:Y()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:Q()}],"inline-size":[{inline:["auto",...he()]}],"min-inline-size":[{"min-inline":["auto",...he()]}],"max-inline-size":[{"max-inline":["none",...he()]}],"block-size":[{block:["auto",...me()]}],"min-block-size":[{"min-block":["auto",...me()]}],"max-block-size":[{"max-block":["none",...me()]}],w:[{w:[c,"screen",...Q()]}],"min-w":[{"min-w":[c,"screen","none",...Q()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},...Q()]}],h:[{h:["screen","lh",...Q()]}],"min-h":[{"min-h":["screen","lh","none",...Q()]}],"max-h":[{"max-h":["screen","lh",...Q()]}],"font-size":[{text:["base",n,Kt,nt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Uh,Th]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",_r,M]}],"font-family":[{font:[Mh,Lh,t]}],"font-features":[{"font-features":[M]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,F,M]}],"line-clamp":[{"line-clamp":[G,"none",F,Co]}],leading:[{leading:[o,...R()]}],"list-image":[{"list-image":["none",F,M]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",F,M]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:[G,"from-font","auto",F,nt]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[G,"auto",F,M]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"tab-size":[{tab:[Le,F,M]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",F,M]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",F,M]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:E()}],"bg-repeat":[{bg:B()}],"bg-size":[{bg:q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Le,F,M],radial:["",F,M],conic:[Le,F,M]},Fh,Ih]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:K()}],"gradient-via-pos":[{via:K()}],"gradient-to-pos":[{to:K()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:H()}],"rounded-s":[{"rounded-s":H()}],"rounded-e":[{"rounded-e":H()}],"rounded-t":[{"rounded-t":H()}],"rounded-r":[{"rounded-r":H()}],"rounded-b":[{"rounded-b":H()}],"rounded-l":[{"rounded-l":H()}],"rounded-ss":[{"rounded-ss":H()}],"rounded-se":[{"rounded-se":H()}],"rounded-ee":[{"rounded-ee":H()}],"rounded-es":[{"rounded-es":H()}],"rounded-tl":[{"rounded-tl":H()}],"rounded-tr":[{"rounded-tr":H()}],"rounded-br":[{"rounded-br":H()}],"rounded-bl":[{"rounded-bl":H()}],"border-w":[{border:z()}],"border-w-x":[{"border-x":z()}],"border-w-y":[{"border-y":z()}],"border-w-s":[{"border-s":z()}],"border-w-e":[{"border-e":z()}],"border-w-bs":[{"border-bs":z()}],"border-w-be":[{"border-be":z()}],"border-w-t":[{"border-t":z()}],"border-w-r":[{"border-r":z()}],"border-w-b":[{"border-b":z()}],"border-w-l":[{"border-l":z()}],"divide-x":[{"divide-x":z()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":z()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...U(),"hidden","none"]}],"divide-style":[{divide:[...U(),"hidden","none"]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-bs":[{"border-bs":I()}],"border-color-be":[{"border-be":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...U(),"none","hidden"]}],"outline-offset":[{"outline-offset":[G,F,M]}],"outline-w":[{outline:["",G,Kt,nt]}],"outline-color":[{outline:I()}],shadow:[{shadow:["","none",d,wn,vn]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":["none",l,wn,vn]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[G,nt]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":z()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":["none",h,wn,vn]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[G,F,M]}],"mix-blend":[{"mix-blend":[...Z(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Z()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[G]}],"mask-image-linear-from-pos":[{"mask-linear-from":V()}],"mask-image-linear-to-pos":[{"mask-linear-to":V()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":V()}],"mask-image-t-to-pos":[{"mask-t-to":V()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":V()}],"mask-image-r-to-pos":[{"mask-r-to":V()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":V()}],"mask-image-b-to-pos":[{"mask-b-to":V()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":V()}],"mask-image-l-to-pos":[{"mask-l-to":V()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":V()}],"mask-image-x-to-pos":[{"mask-x-to":V()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":V()}],"mask-image-y-to-pos":[{"mask-y-to":V()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[F,M]}],"mask-image-radial-from-pos":[{"mask-radial-from":V()}],"mask-image-radial-to-pos":[{"mask-radial-to":V()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":N()}],"mask-image-conic-pos":[{"mask-conic":[G]}],"mask-image-conic-from-pos":[{"mask-conic-from":V()}],"mask-image-conic-to-pos":[{"mask-conic-to":V()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:E()}],"mask-repeat":[{mask:B()}],"mask-size":[{mask:q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",F,M]}],filter:[{filter:["","none",F,M]}],blur:[{blur:ie()}],brightness:[{brightness:[G,F,M]}],contrast:[{contrast:[G,F,M]}],"drop-shadow":[{"drop-shadow":["","none",m,wn,vn]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:["",G,F,M]}],"hue-rotate":[{"hue-rotate":[G,F,M]}],invert:[{invert:["",G,F,M]}],saturate:[{saturate:[G,F,M]}],sepia:[{sepia:["",G,F,M]}],"backdrop-filter":[{"backdrop-filter":["","none",F,M]}],"backdrop-blur":[{"backdrop-blur":ie()}],"backdrop-brightness":[{"backdrop-brightness":[G,F,M]}],"backdrop-contrast":[{"backdrop-contrast":[G,F,M]}],"backdrop-grayscale":[{"backdrop-grayscale":["",G,F,M]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[G,F,M]}],"backdrop-invert":[{"backdrop-invert":["",G,F,M]}],"backdrop-opacity":[{"backdrop-opacity":[G,F,M]}],"backdrop-saturate":[{"backdrop-saturate":[G,F,M]}],"backdrop-sepia":[{"backdrop-sepia":["",G,F,M]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",F,M]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[G,"initial",F,M]}],ease:[{ease:["linear","initial",b,F,M]}],delay:[{delay:[G,F,M]}],animate:[{animate:["none",y,F,M]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[p,F,M]}],"perspective-origin":[{"perspective-origin":j()}],rotate:[{rotate:le()}],"rotate-x":[{"rotate-x":le()}],"rotate-y":[{"rotate-y":le()}],"rotate-z":[{"rotate-z":le()}],scale:[{scale:te()}],"scale-x":[{"scale-x":te()}],"scale-y":[{"scale-y":te()}],"scale-z":[{"scale-z":te()}],"scale-3d":["scale-3d"],skew:[{skew:je()}],"skew-x":[{"skew-x":je()}],"skew-y":[{"skew-y":je()}],transform:[{transform:[F,M,"","none","gpu","cpu"]}],"transform-origin":[{origin:j()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ce()}],"translate-x":[{"translate-x":Ce()}],"translate-y":[{"translate-y":Ce()}],"translate-z":[{"translate-z":Ce()}],"translate-none":["translate-none"],zoom:[{zoom:[Le,F,M]}],accent:[{accent:I()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:I()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",F,M]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":I()}],"scrollbar-track-color":[{"scrollbar-track":I()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",F,M]}],fill:[{fill:["none",...I()]}],"stroke-w":[{stroke:[G,Kt,nt,Co]}],stroke:[{stroke:["none",...I()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},zh=yh(Bh);function Ut(...e){return zh(Xf(e))}function X(e,t="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:2}).format(e)}const ue=S.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:Ut("rounded-xl border bg-card text-card-foreground shadow",e),...t}));ue.displayName="Card";const Re=S.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:Ut("flex flex-col space-y-1.5 p-6",e),...t}));Re.displayName="CardHeader";const Pe=S.forwardRef(({className:e,...t},n)=>a.jsx("h3",{ref:n,className:Ut("font-semibold leading-none tracking-tight",e),...t}));Pe.displayName="CardTitle";const Wh=S.forwardRef(({className:e,...t},n)=>a.jsx("p",{ref:n,className:Ut("text-sm text-muted-foreground",e),...t}));Wh.displayName="CardDescription";const de=S.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:Ut("p-6 pt-0",e),...t}));de.displayName="CardContent";const Vh=S.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:Ut("flex items-center p-6 pt-0",e),...t}));Vh.displayName="CardFooter";function Zn({status:e,error:t}){const n=e?.action==="connect_source"||e?.state==="not_configured",r=e?.message||t||"CUR status could not be loaded. Verify the cost source, discovery job, and Athena configuration.";return a.jsx("section",{className:"rounded-md border bg-card p-6","aria-live":"polite",children:a.jsxs("div",{className:"flex items-start gap-3",children:[e?.state==="unavailable"||t?a.jsx(ze,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"}):a.jsx(ai,{className:"mt-0.5 h-5 w-5 shrink-0 text-primary"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"font-semibold",children:n?"Enable AWS Cost and Usage Reports":"CUR data is not ready"}),a.jsx("p",{className:"mt-1 max-w-3xl text-sm text-muted-foreground",children:r}),a.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[a.jsxs(qn,{to:n?"/sources":"/cur-discovery",className:"inline-flex items-center gap-2 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground",children:[a.jsx(ci,{className:"h-4 w-4"}),n?"Connect AWS source":"Review CUR discovery"]}),!n&&a.jsx(qn,{to:"/sources",className:"rounded-md border px-3 py-2 text-sm font-medium hover:bg-muted",children:"Cost sources"})]})]})]})})}const oe={getOverview:e=>ne.get("/overview",{params:e}).then(t=>t.data),getAccounts:e=>ne.get("/accounts",{params:e}).then(t=>t.data),getReports:e=>ne.get("/reports",{params:e}).then(t=>t.data),getFilterOptions:e=>ne.get("/filter-options",{params:{start:e?.start,end:e?.end,tagKey:e?.filterTagKey,managementAccountId:e?.managementAccountId}}).then(t=>t.data),getTags:e=>ne.get("/tags",{params:e}).then(t=>t.data),getDataStatus:e=>ne.get("/data-status",{params:e}).then(t=>t.data),getAnalysisStatus:e=>ne.get("/analysis/status",{params:e}).then(t=>t.data),getLatestAnalysis:e=>ne.get("/analysis/latest",{params:e}).then(t=>t.data.analysis),getAnalysisSchedule:e=>ne.get("/analysis/schedule",{params:e}).then(t=>t.data),updateAnalysisSchedule:(e,t)=>ne.put("/analysis/schedule",e,{params:t}).then(n=>n.data),getAnalysisReports:e=>ne.get("/analysis/reports",{params:e}).then(t=>t.data.reports),removeAnalysisReport:e=>ne.delete(`/analysis/reports/${e}`).then(t=>t.data),downloadAnalysisPdf:e=>ne.get(`/analysis/reports/${e}/pdf`,{responseType:"blob"}).then(t=>t.data),getSources:()=>ne.get("/sources").then(e=>e.data),createSource:e=>ne.post("/sources",e).then(t=>t.data),getSourceStatus:e=>ne.get(`/sources/${e}/status`).then(t=>t.data),verifySource:e=>ne.post(`/sources/${e}/verify`).then(t=>t.data),removeSource:(e,t)=>ne.delete(`/sources/${e}`,{data:{deleteAwsResources:t}}).then(n=>n.data),downloadSourceTemplate:e=>ne.get(`/sources/${e}/template`,{responseType:"blob"}).then(t=>t.data),getCurDiscovery:e=>ne.get("/cur-discovery",{params:e}).then(t=>t.data)},ki=P.createContext("user"),Hh=ki.Provider,qh=()=>P.useContext(ki),Pi=P.createContext(null);function Gh({tenantId:e="default",children:t}){const n=`meyi-cost:selected-management-account:${e||"default"}`,[r,s]=P.useState([]),[o,i]=P.useState(""),[c,u]=P.useState(!0),f=P.useCallback(async()=>{u(!0);try{const m=((await oe.getSources()).sources||[]).filter(g=>!!g.managementAccountId);s(m),i(g=>{const x=window.localStorage.getItem(n)||""||g,b=m.find(v=>v.status==="CONNECTED")||m[0],y=m.some(v=>v.managementAccountId===x)?x:b?.managementAccountId||"";return y?window.localStorage.setItem(n,y):window.localStorage.removeItem(n),y})}catch{s([]),i("")}finally{u(!1)}},[n]);P.useEffect(()=>{f()},[f]);const d=P.useCallback(h=>{/^\d{12}$/.test(h)&&(window.localStorage.setItem(n,h),i(h))},[n]),l=P.useMemo(()=>({sources:r,managementAccountId:o,loading:c,selectManagementAccount:d,refreshSources:f}),[r,o,c,d,f]);return a.jsx(Pi.Provider,{value:l,children:t})}function $t(){const e=P.useContext(Pi);if(!e)throw new Error("useCostAccount must be used inside CostAccountProvider");return e}function ar(){const{sources:e,managementAccountId:t,loading:n,selectManagementAccount:r}=$t();return e.length<=1?null:a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx(si,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"sr-only",children:"Management account"}),a.jsx("select",{"aria-label":"Management account",value:t,onChange:s=>r(s.target.value),disabled:n,className:"max-w-72 rounded-md border bg-background px-3 py-2 text-sm shadow-sm disabled:opacity-50",children:e.map(s=>a.jsxs("option",{value:s.managementAccountId||"",children:["Management account ",s.managementAccountId]},s.connectionId))})]})}function Kh({points:e,currency:t="USD"}){const[n,r]=P.useState(null);if(!e.length)return a.jsx("p",{className:"py-20 text-center text-sm text-muted-foreground",children:"No trend data for this period."});const s=900,o=260,i=70,c=24,u=22,f=48,d=s-i-c,l=o-u-f,h=Math.max(...e.map(x=>x.value),1),m=e.map((x,b)=>({...x,x:i+(e.length===1?d/2:b*d/(e.length-1)),y:u+l-x.value/h*l})),g=n==null?null:m[n],p=x=>{const b=x.currentTarget.getBoundingClientRect(),y=(x.clientX-b.left)/b.width*s;let v=0;for(let N=1;N<m.length;N+=1)Math.abs(m[N].x-y)<Math.abs(m[v].x-y)&&(v=N);r(v)};return a.jsxs("div",{className:"relative w-full",children:[a.jsxs("svg",{viewBox:`0 0 ${s} ${o}`,className:"h-72 w-full",onMouseMove:p,onMouseLeave:()=>r(null),role:"img","aria-label":"Cost trend line chart",children:[[0,.25,.5,.75,1].map(x=>{const b=u+l*x;return a.jsxs("g",{children:[a.jsx("line",{x1:i,y1:b,x2:s-c,y2:b,stroke:"#d8e0e7",strokeDasharray:"4 4"}),a.jsx("text",{x:i-10,y:b+4,textAnchor:"end",fill:"currentColor",className:"text-[10px] text-muted-foreground",children:X(h*(1-x),t)})]},x)}),a.jsx("line",{x1:i,y1:u+l,x2:s-c,y2:u+l,stroke:"#aebbc5"}),a.jsx("polyline",{points:m.map(x=>`${x.x},${x.y}`).join(" "),fill:"none",stroke:"#1f5f85",strokeWidth:"4",strokeLinejoin:"round",strokeLinecap:"round"}),g&&a.jsx("line",{x1:g.x,y1:u,x2:g.x,y2:u+l,stroke:"#1f5f85",strokeDasharray:"3 4",opacity:"0.45"}),m.map((x,b)=>a.jsxs("g",{children:[a.jsx("circle",{cx:x.x,cy:x.y,r:n===b?7:5,fill:"#1f5f85",stroke:"white",strokeWidth:"2"}),a.jsx("text",{x:x.x,y:o-17,textAnchor:"middle",fill:"currentColor",className:"text-[11px] text-muted-foreground",children:x.label})]},x.key))]}),g&&a.jsxs("div",{className:"pointer-events-none absolute z-20 min-w-44 rounded-lg border bg-popover p-3 text-popover-foreground shadow-xl",style:{left:`${g.x/s*100}%`,top:`${Math.max(g.y/o*100-4,2)}%`,transform:g.x>s*.75?"translate(-100%, -100%)":"translate(-50%, -100%)"},children:[a.jsx("p",{className:"text-xs font-semibold",children:g.label}),a.jsx("p",{className:"mt-1 text-sm font-bold text-primary",children:X(g.value,t)}),g.details?.slice(0,5).map(x=>a.jsxs("div",{className:"mt-1 flex justify-between gap-4 text-xs",children:[a.jsx("span",{className:"max-w-40 truncate text-muted-foreground",children:x.label}),a.jsx("span",{children:X(x.value,t)})]},x.label))]})]})}const _o=e=>e.length>16?`${e.slice(0,14)}...`:e,Yh=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t||"USD",notation:"compact",maximumFractionDigits:1}).format(e);function Jh({title:e,items:t,currency:n}){const o={top:38,right:18,bottom:72,left:76},i=720-o.left-o.right,c=320-o.top-o.bottom,u=Math.max(...t.map(l=>l.amount),1),f=i/t.length,d=Math.min(56,f*.58);return a.jsxs("svg",{viewBox:"0 0 720 320",className:"h-80 w-full",role:"img","aria-label":`${e} cost bar chart`,children:[[0,.25,.5,.75,1].map(l=>{const h=o.top+c-l*c;return a.jsxs("g",{children:[a.jsx("line",{x1:o.left,y1:h,x2:720-o.right,y2:h,stroke:"currentColor",opacity:l===0?.3:.12,vectorEffect:"non-scaling-stroke"}),a.jsx("text",{x:o.left-12,y:h+4,textAnchor:"end",fill:"currentColor",opacity:"0.7",fontSize:"11",children:Yh(u*l,n)})]},l)}),a.jsx("line",{x1:o.left,y1:o.top,x2:o.left,y2:o.top+c,stroke:"currentColor",opacity:"0.3",vectorEffect:"non-scaling-stroke"}),t.map((l,h)=>{const m=o.left+f*h+f/2,g=Math.max(l.amount/u*c,3),p=o.top+c-g;return a.jsxs("g",{tabIndex:0,"aria-label":`${l.label}: ${X(l.amount,n)}`,className:"outline-none focus-visible:opacity-75",children:[a.jsxs("title",{children:[l.label,": ",X(l.amount,n)]}),a.jsx("rect",{x:m-d/2,y:p,width:d,height:g,rx:"4",className:"fill-primary opacity-80 transition-opacity hover:opacity-100"}),a.jsx("text",{x:m,y:Math.max(p-8,16),textAnchor:"middle",fill:"currentColor",fontSize:"11",fontWeight:"600",children:X(l.amount,n)}),a.jsx("text",{x:m,y:278,textAnchor:"middle",fill:"currentColor",opacity:"0.72",fontSize:"11",children:_o(l.label)}),l.accountId&&a.jsx("text",{x:m,y:295,textAnchor:"middle",fill:"currentColor",opacity:"0.55",fontSize:"9",children:_o(l.accountId)})]},l.key||l.label)}),a.jsxs("text",{x:"18",y:o.top+c/2,transform:`rotate(-90 18 ${o.top+c/2})`,textAnchor:"middle",fill:"currentColor",opacity:"0.65",fontSize:"11",children:["Cost (",n,")"]})]})}const Ai="min-h-32 transition-all duration-200 ease-out hover:-translate-y-1 hover:scale-[1.01] hover:border-primary/30 hover:shadow-lg";function kr({title:e,icon:t,items:n,currency:r}){const[s,o]=P.useState("chart"),i=n.slice(0,6),c=Math.max(...i.map(u=>u.amount),1);return a.jsxs(ue,{className:"min-w-0",children:[a.jsxs(Re,{className:"flex flex-row items-center justify-between gap-3 pb-3",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[a.jsx("span",{className:"text-primary",children:t}),a.jsx(Pe,{className:"truncate text-sm",children:e})]}),a.jsxs("div",{className:"flex rounded-md border p-0.5","aria-label":`${e} view`,children:[a.jsx("button",{type:"button",onClick:()=>o("chart"),"aria-label":`Show ${e} as bar chart`,"aria-pressed":s==="chart",title:"Bar chart",className:`rounded p-1.5 ${s==="chart"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"}`,children:a.jsx(mf,{className:"h-4 w-4"})}),a.jsx("button",{type:"button",onClick:()=>o("list"),"aria-label":`Show ${e} as list`,"aria-pressed":s==="list",title:"List",className:`rounded p-1.5 ${s==="list"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"}`,children:a.jsx(If,{className:"h-4 w-4"})})]})]}),a.jsx(de,{children:i.length?s==="chart"?a.jsx(Jh,{title:e,items:i,currency:r}):a.jsx("div",{className:"space-y-3",children:i.map(u=>a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[a.jsxs("span",{className:"truncate text-muted-foreground",title:u.label,children:[u.label,u.accountId?a.jsxs("span",{className:"ml-1 text-xs",children:["(",u.accountId,")"]}):null]}),a.jsx("span",{className:"shrink-0 font-medium",children:X(u.amount,r)})]}),a.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted",children:a.jsx("div",{className:"h-full rounded-full bg-primary/75",style:{width:`${u.amount/c*100}%`}})})]},u.key||u.label))}):a.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No cost data for this period."})})]})}function Xh(){return a.jsxs("div",{"aria-live":"polite","aria-busy":"true",className:"contents",children:[a.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,240px),1fr))] gap-4",children:Array.from({length:4},(e,t)=>a.jsxs(ue,{className:Ai,children:[a.jsx(Re,{className:"pb-2",children:a.jsx("div",{className:"h-3 w-24 animate-pulse rounded bg-muted"})}),a.jsxs(de,{children:[a.jsx("div",{className:"h-6 w-3/4 animate-pulse rounded bg-muted"}),a.jsx("div",{className:"mt-3 h-3 w-1/2 animate-pulse rounded bg-muted/80"})]})]},t))}),a.jsxs(ue,{children:[a.jsx(Re,{children:a.jsx("div",{className:"h-4 w-36 animate-pulse rounded bg-muted"})}),a.jsx(de,{children:a.jsx("div",{className:"h-72 animate-pulse rounded-lg bg-muted/70"})})]}),a.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:Array.from({length:3},(e,t)=>a.jsxs(ue,{children:[a.jsx(Re,{children:a.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-muted"})}),a.jsx(de,{className:"space-y-4",children:Array.from({length:5},(n,r)=>a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("div",{className:"h-3 w-2/5 animate-pulse rounded bg-muted"}),a.jsx("div",{className:"h-3 w-20 animate-pulse rounded bg-muted"})]}),a.jsx("div",{className:"mt-2 h-1.5 animate-pulse rounded bg-muted/80"})]},r))})]},t))})]})}function Zh({data:e,period:t,selectedMonth:n}){const r=e.topServices[0],s=e.topAccounts[0],o=new Date,[i,c]=n.split("-").map(Number),u=t==="monthly"?new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric"}).format(new Date(i,c-1,1)):String(o.getFullYear()),f=[{label:"Total cost",value:a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"block",children:X(e.totalCost,e.currency)}),a.jsxs("span",{className:"mt-1 block text-sm font-medium text-muted-foreground",children:["Accounts: ",e.activeAccounts]})]}),helper:u,icon:a.jsx(ii,{})},{label:"Active resources",value:e.activeResources==null?a.jsx("span",{className:"text-sm",title:e.activeResourcesMessage,children:"CUR access required"}):Number(e.activeResources).toLocaleString(),helper:`${u} across all accounts`,icon:a.jsx(Jn,{})},{label:"Highest cost service",value:r?a.jsx("span",{className:"whitespace-pre-line text-sm",children:`Service - ${r.label}
15
15
  Cost - ${X(r.amount,e.currency)}`}):"-",helper:u,icon:a.jsx(ui,{})},{label:"Highest cost account",value:s?a.jsx("span",{className:"whitespace-pre-line text-sm",children:`Account Name - ${s.label}
16
16
  Account Id - ${s.accountId||s.key||"Unknown"}
17
- Cost - ${X(s.amount,e.currency)}`}):"-",helper:u,icon:a.jsx(Jn,{})}];return a.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,240px),1fr))] gap-4",children:f.map(d=>a.jsxs(ue,{className:Ai,children:[a.jsxs(Re,{className:"flex flex-row items-center justify-between pb-2",children:[a.jsx(Pe,{className:"text-xs font-medium text-muted-foreground",children:d.label}),a.jsx("span",{className:"text-muted-foreground [&>svg]:h-4 [&>svg]:w-4",children:d.icon})]}),a.jsxs(de,{children:[a.jsx("div",{className:"break-words text-base font-semibold leading-snug xl:text-lg",children:d.value}),a.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:d.helper})]})]},d.label))})}function Qh(){const e=new Date,t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`,[n,r]=P.useState(null),[s,o]=P.useState(!0),[i,c]=P.useState(null),[u,f]=P.useState(null),[d,l]=P.useState("monthly"),[h,m]=P.useState(t),{managementAccountId:g,loading:p}=$t(),x=P.useRef(0),b=Array.from({length:e.getMonth()+1},(j,_)=>({value:`${e.getFullYear()}-${String(_+1).padStart(2,"0")}`,label:new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric"}).format(new Date(e.getFullYear(),_,1))})),y=async(j=d,_=h,C=g)=>{const R=++x.current;o(!0),r(null),c(null);try{let k;if(j==="yearly")k={period:j,start:`${e.getFullYear()}-01-01`};else{const[O,$]=_.split("-").map(Number),J=_===t?e.getDate():new Date(O,$,0).getDate();k={period:j,start:`${_}-01`,end:`${_}-${String(J).padStart(2,"0")}`}}const L=C?{managementAccountId:C}:void 0,A=await oe.getDataStatus(L);if(R===x.current&&f(A),!A.ready)return;const D=await oe.getOverview({...k,...L});R===x.current&&r(D)}catch(k){R===x.current&&c(k?.response?.data?.error||k.message||"Failed to load AWS costs")}finally{R===x.current&&o(!1)}};return P.useEffect(()=>{p||y(d,h,g)},[d,h,g,p]),{data:n,dataStatus:u,loading:s||p,error:i,period:d,selectedMonth:h,monthOptions:b,changePeriod:j=>{j!==d&&(o(!0),r(null),l(j))},changeMonth:j=>{j===h||!b.some(_=>_.value===j)||(o(!0),r(null),m(j))},refresh:()=>y(d,h,g)}}function em(){const{data:e,dataStatus:t,loading:n,error:r,period:s,selectedMonth:o,monthOptions:i,changePeriod:c,changeMonth:u,refresh:f}=Qh();return a.jsxs("div",{className:"flex w-full flex-col gap-6 p-2 md:p-6",children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold",children:[a.jsx(ii,{className:"h-6 w-6 text-primary"}),"Cloud Cost Management"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Costs for the selected AWS management account and its member accounts"})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(ar,{}),s==="monthly"&&a.jsx("select",{"aria-label":"Cost month",value:o,onChange:d=>u(d.target.value),disabled:n,className:"rounded-lg border bg-background px-3 py-2 text-sm shadow-sm disabled:opacity-50",children:i.map(d=>a.jsx("option",{value:d.value,children:d.label},d.value))}),a.jsx("div",{className:"flex rounded-lg border p-1",children:["monthly","yearly"].map(d=>a.jsx("button",{onClick:()=>c(d),className:`rounded-md px-3 py-1.5 text-sm capitalize transition-colors ${s===d?"bg-primary text-primary-foreground":"hover:bg-muted"}`,children:d},d))}),a.jsx("button",{onClick:()=>{f()},disabled:n,className:"rounded-lg border p-2 hover:bg-muted",children:a.jsx(Tt,{className:`h-4 w-4 ${n?"animate-spin":""}`})})]})]}),r&&e&&a.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:[a.jsx(ze,{className:"h-4 w-4"}),r]}),n?a.jsx(Xh,{}):t&&!t.ready?a.jsx(Zn,{status:t}):r&&!e?a.jsx(Zn,{status:t,error:r}):e?a.jsxs(a.Fragment,{children:[e.dataSource&&a.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[a.jsx("span",{children:"Source: AWS CUR via SaaS Athena - gross positive unblended charges"}),a.jsxs("span",{children:["CUR: Ready",t?.lastDataAt?`, updated ${new Date(t.lastDataAt).toLocaleString()}`:""]})]}),a.jsx(Zh,{data:e,period:s,selectedMonth:o}),e.message&&!/historical data beyond 14 months/i.test(e.message)&&a.jsx(ue,{children:a.jsx(de,{className:"py-8 text-center text-sm text-muted-foreground",children:e.message})}),a.jsxs(ue,{children:[a.jsxs(Re,{className:"flex flex-row items-center gap-2",children:[a.jsx(hi,{className:"h-4 w-4 text-primary"}),a.jsxs(Pe,{className:"text-sm",children:["Cost Trend - ",s==="monthly"?"Monthly":"Yearly"]})]}),a.jsx(de,{children:a.jsx(Kh,{points:e.trends.map(d=>({key:d.month,label:s==="yearly"?d.month.slice(0,4):new Date(`${d.month}T00:00:00Z`).toLocaleDateString(void 0,{month:"short",year:"2-digit"}),value:d.amount})),currency:e.currency})})]}),a.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[a.jsx(kr,{title:"Top services",icon:a.jsx(ui,{className:"h-4 w-4"}),items:e.topServices,currency:e.currency}),a.jsx(kr,{title:"AWS accounts",icon:a.jsx(si,{className:"h-4 w-4"}),items:e.topAccounts,currency:e.currency}),a.jsx(kr,{title:"Regional distribution",icon:a.jsx(Ff,{className:"h-4 w-4"}),items:e.topRegions,currency:e.currency})]})]}):null]})}const Sn=["#6264e9","#eb67ad","#31c39a","#f29a05","#579bea","#9078ed","#f7842c","#24b9ad","#8ac926","#ffca3a","#6a4c93","#1982c4"];function ko(e,t){const n=new Date(e.length===10?`${e}T00:00:00Z`:e);return Number.isFinite(n.getTime())?n.toLocaleDateString(void 0,t?{month:"short",day:"numeric",year:"numeric"}:{month:"short",year:"numeric"}):e}function tm({timeline:e,currency:t="USD",daily:n=!1}){const[r,s]=P.useState(null),[o,i]=P.useState(null),c=P.useMemo(()=>{const g=new Map;for(const p of e)for(const x of p.groups)g.set(x.label,(g.get(x.label)||0)+x.amount);return[...g.entries()].sort((p,x)=>x[1]-p[1]).map(([p],x)=>({label:p,color:Sn[x%Sn.length]}))},[e]),u=new Map(c.map(g=>[g.label,g.color])),f=Math.max(...e.map(g=>g.total),1),d=r??o,l=d==null?null:e[d],h=n?52:80,m=Math.max(520,e.length*h);return e.length?a.jsxs("div",{className:"grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1fr)_288px]",onMouseLeave:()=>s(null),children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"grid min-h-80 min-w-0 grid-cols-[72px_minmax(0,1fr)] gap-3",children:[a.jsx("div",{className:"flex h-64 flex-col justify-between pb-1 text-right text-[11px] text-muted-foreground",children:[1,.75,.5,.25,0].map(g=>a.jsx("span",{children:X(f*g,t)},g))}),a.jsx("div",{className:"min-w-0 overflow-x-auto pb-2",children:a.jsxs("div",{style:{width:m},children:[a.jsxs("div",{className:"relative flex h-64 items-end border-b px-4",children:[[0,25,50,75].map(g=>a.jsx("span",{className:"pointer-events-none absolute left-0 right-0 border-t border-dashed border-slate-200",style:{top:`${g}%`}},g)),e.map((g,p)=>a.jsx("button",{type:"button",onMouseEnter:()=>s(p),onMouseLeave:()=>s(null),onPointerDown:x=>x.preventDefault(),onFocus:()=>i(p),onBlur:()=>i(null),className:"group z-10 flex h-full shrink-0 items-end justify-center px-2 outline-none focus-visible:ring-2 focus-visible:ring-primary",style:{width:h},children:a.jsx("span",{className:"flex w-full max-w-16 flex-col-reverse overflow-hidden rounded-t-sm shadow-sm transition group-hover:brightness-95",style:{height:`${Math.max(g.total/f*100,1)}%`},children:g.groups.map(x=>a.jsx("span",{style:{backgroundColor:u.get(x.label)||Sn[0],height:`${g.total?x.amount/g.total*100:0}%`}},x.key||x.label))})},`${g.start}-${p}`))]}),a.jsx("div",{className:"flex px-4 pt-2",children:e.map((g,p)=>a.jsx("span",{className:"shrink-0 whitespace-nowrap text-center text-[11px] text-muted-foreground",style:{width:h},children:ko(g.start,n)},`${g.start}-label-${p}`))})]})})]}),a.jsxs("div",{className:"mt-5 flex flex-wrap gap-x-4 gap-y-2",children:[c.slice(0,8).map(g=>a.jsxs("span",{className:"flex items-center gap-1.5 text-xs",children:[a.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:g.color}}),g.label]},g.label)),c.length>8&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",c.length-8," more"]})]})]}),a.jsx("aside",{"aria-live":"polite",className:"min-h-44",children:l?a.jsxs("div",{role:"tooltip",className:"rounded-2xl border bg-popover p-4 text-popover-foreground shadow-lg",children:[a.jsx("p",{className:"font-semibold",children:ko(l.start,n)}),a.jsxs("div",{className:"mt-3 space-y-2",children:[[...l.groups].sort((g,p)=>p.amount-g.amount).slice(0,5).map(g=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:u.get(g.label)||Sn[0]}}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.label}),a.jsx("strong",{children:X(g.amount,t)})]},g.key||g.label)),l.groups.length>5&&a.jsxs("p",{className:"text-xs italic text-muted-foreground",children:["+ ",l.groups.length-5," others"]})]}),a.jsxs("div",{className:"mt-3 flex justify-between border-t pt-3 text-sm",children:[a.jsx("strong",{children:"Total"}),a.jsx("strong",{className:"text-primary",children:X(l.total,t)})]})]}):a.jsx("div",{className:"flex min-h-44 items-center justify-center rounded-2xl border border-dashed p-4 text-center text-xs text-muted-foreground",children:"Hover over a bar to view its cost details."})})]}):a.jsx("p",{className:"py-24 text-center text-sm text-muted-foreground",children:"No trend data for this period."})}function nm({rows:e,currency:t}){const n=e.slice(0,8),r=Math.max(1,...n.flatMap(s=>[s.current?.amount||0,s.previous?.amount||0]));return a.jsxs(ue,{className:"bg-primary/5",children:[a.jsx(Re,{children:a.jsx(Pe,{className:"text-sm",children:"Comparison Overview"})}),a.jsx(de,{children:a.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[a.jsx("div",{className:"flex h-72 items-end gap-4 border-b border-l px-4 pt-4",children:n.map(s=>a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col items-center",children:[a.jsxs("div",{className:"flex h-56 w-full items-end justify-center gap-1",children:[a.jsx("div",{title:`Current: ${X(s.current?.amount||0,t)}`,className:"w-1/3 max-w-10 rounded-t bg-indigo-500",style:{height:`${Math.max((s.current?.amount||0)/r*100,s.current?.amount?1:0)}%`}}),a.jsx("div",{title:`Previous: ${X(s.previous?.amount||0,t)}`,className:"w-1/3 max-w-10 rounded-t bg-pink-400",style:{height:`${Math.max((s.previous?.amount||0)/r*100,s.previous?.amount?1:0)}%`}})]}),a.jsx("span",{title:s.label,className:"mt-2 w-full truncate text-center text-[10px] text-muted-foreground",children:s.label})]},s.key))}),a.jsxs("div",{className:"mt-4 flex gap-5 text-xs",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-indigo-500"}),"Current Period"]}),a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-pink-400"}),"Previous Period"]})]})]})})]})}function Me({label:e,value:t,helper:n,accent:r=!1,trend:s}){return a.jsxs("div",{className:"rounded-xl border bg-card p-5 shadow-sm",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[s!=null&&(s<0?a.jsx(Kf,{className:"h-4 w-4 text-red-500"}):a.jsx(hi,{className:"h-4 w-4 text-emerald-500"})),a.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:e})]}),a.jsx("p",{className:`mt-2 text-2xl font-bold ${r?"text-primary":s!=null&&s<0?"text-red-500":""}`,children:t}),n&&a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n})]})}function Rn({label:e,options:t,selected:n,onChange:r}){const s=n.length?`${n.length} selected`:e;return a.jsxs("details",{className:"group relative",children:[a.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between rounded-lg border bg-background px-3 py-3 text-sm text-primary",children:[a.jsx("span",{children:s}),a.jsx(gf,{className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),a.jsx("div",{className:"absolute z-30 mt-1 max-h-64 w-full overflow-auto rounded-lg border bg-popover p-2 shadow-xl",children:t.length?t.map(o=>a.jsxs("label",{className:"flex cursor-pointer items-start gap-2 rounded px-2 py-2 text-xs hover:bg-muted",children:[a.jsx("input",{type:"checkbox",checked:n.includes(o.value),onChange:i=>r(i.target.checked?[...n,o.value]:n.filter(c=>c!==o.value))}),a.jsx("span",{className:"min-w-0 break-words",children:o.label})]},o.value)):a.jsx("p",{className:"p-2 text-xs text-muted-foreground",children:"No values available."})})]})}function rm(){return a.jsxs("div",{"aria-live":"polite","aria-busy":"true",className:"space-y-5",children:[a.jsxs("section",{className:"rounded-xl bg-primary/5 p-5",children:[a.jsxs("div",{className:"flex items-center gap-3 text-sm font-medium text-primary",children:[a.jsx(ct,{className:"h-5 w-5 animate-spin"}),"Loading live AWS cost report..."]}),a.jsx("div",{className:"mt-5 grid gap-3 sm:grid-cols-3",children:[1,2,3].map(e=>a.jsx("div",{className:"h-28 animate-pulse rounded-xl border bg-card/70"},e))})]}),a.jsx("div",{className:"h-80 animate-pulse rounded-xl border bg-muted/40"}),a.jsx("div",{className:"h-64 animate-pulse rounded-xl border bg-muted/40"})]})}const Xe=10,Jr=new Date,Oi=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,sm=Oi(new Date(Jr.getFullYear(),Jr.getMonth()-2,1)),om=Oi(Jr),Yt={services:[],regions:[],accountIds:[],tagKey:"",tagValues:[]},ht={service:{tab:"Services",title:"Service Cost Summary",pdfTitle:"Service Cost Report",top:"Top service cost",count:"Service count",item:"Service",empty:"No service cost data found."},account:{tab:"Accounts",title:"Account Cost Summary",pdfTitle:"Account Cost Report",top:"Top account cost",count:"Account count",item:"Linked account",empty:"No linked account cost data found."},region:{tab:"Regions",title:"Regional Cost Summary",pdfTitle:"Region Cost Report",top:"Top region cost",count:"Region count",item:"Region",empty:"No regional cost data found."},resource:{tab:"Resources",title:"Resource Cost Summary",pdfTitle:"Resource Cost Report",top:"Top resource cost",count:"Resource count",item:"Resource",empty:"Resource-level cost data requires resource IDs in the CUR export."},tag:{tab:"Tags",title:"Tag Cost Summary",pdfTitle:"Tag Cost Report",top:"Top tag value cost",count:"Tag value count",item:"Tag value",empty:"No cost allocation tag data found."}};function Po(e){return e?new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"longOffset"}).format(new Date(e)).replace("GMT","UTC"):"Not updated yet"}function Ao(e,t){const n=new Date(`${e}T00:00:00Z`);if(t==="monthly"){const s=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),1)),o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)),i=new Date(s);i.setUTCDate(i.getUTCDate()-1);const c=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1));return{currentStart:s.toISOString().slice(0,10),currentEnd:o.toISOString().slice(0,10),previousStart:c.toISOString().slice(0,10),previousEnd:i.toISOString().slice(0,10)}}const r=new Date(n);return r.setUTCDate(r.getUTCDate()-1),{currentStart:e,currentEnd:e,previousStart:r.toISOString().slice(0,10),previousEnd:r.toISOString().slice(0,10)}}function It(e,t,n){const r=new Date(`${e}T00:00:00Z`),s=new Date(`${t}T00:00:00Z`);if(n==="monthly"&&r.getUTCFullYear()===s.getUTCFullYear()&&r.getUTCMonth()===s.getUTCMonth())return new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric",timeZone:"UTC"}).format(r);const o=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"});return`${o.format(r)} – ${o.format(s)}`}function am(e){const t=new Map;return e.current.summary.forEach(n=>t.set(n.key||n.label,{current:n})),e.previous.summary.forEach(n=>{const r=n.key||n.label;t.set(r,{...t.get(r),previous:n})}),[...t.entries()].map(([n,r])=>{const s=r.current?.amount||0,o=r.previous?.amount||0,i=s-o;return{key:n,label:r.current?.label||r.previous?.label||n,...r,difference:i,change:o?i/Math.abs(o)*100:0}}).sort((n,r)=>Math.max(r.current?.amount||0,r.previous?.amount||0)-Math.max(n.current?.amount||0,n.previous?.amount||0))}function rt(e){return e?.length?e.map(t=>`${t.label}
17
+ Cost - ${X(s.amount,e.currency)}`}):"-",helper:u,icon:a.jsx(Jn,{})}];return a.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,240px),1fr))] gap-4",children:f.map(d=>a.jsxs(ue,{className:Ai,children:[a.jsxs(Re,{className:"flex flex-row items-center justify-between pb-2",children:[a.jsx(Pe,{className:"text-xs font-medium text-muted-foreground",children:d.label}),a.jsx("span",{className:"text-muted-foreground [&>svg]:h-4 [&>svg]:w-4",children:d.icon})]}),a.jsxs(de,{children:[a.jsx("div",{className:"break-words text-base font-semibold leading-snug xl:text-lg",children:d.value}),a.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:d.helper})]})]},d.label))})}function Qh(){const e=new Date,t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`,[n,r]=P.useState(null),[s,o]=P.useState(!0),[i,c]=P.useState(null),[u,f]=P.useState(null),[d,l]=P.useState("monthly"),[h,m]=P.useState(t),{managementAccountId:g,loading:p}=$t(),x=P.useRef(0),b=Array.from({length:e.getMonth()+1},(j,_)=>({value:`${e.getFullYear()}-${String(_+1).padStart(2,"0")}`,label:new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric"}).format(new Date(e.getFullYear(),_,1))})),y=async(j=d,_=h,C=g)=>{const R=++x.current;o(!0),r(null),c(null);try{let k;if(j==="yearly")k={period:j,start:`${e.getFullYear()}-01-01`};else{const[O,$]=_.split("-").map(Number),J=_===t?e.getDate():new Date(O,$,0).getDate();k={period:j,start:`${_}-01`,end:`${_}-${String(J).padStart(2,"0")}`}}const L=C?{managementAccountId:C}:void 0,A=await oe.getDataStatus(L);if(R===x.current&&f(A),!A.ready)return;const D=await oe.getOverview({...k,...L});R===x.current&&r(D)}catch(k){R===x.current&&c(k?.response?.data?.error||k.message||"Failed to load AWS costs")}finally{R===x.current&&o(!1)}};return P.useEffect(()=>{p||y(d,h,g)},[d,h,g,p]),{data:n,dataStatus:u,loading:s||p,error:i,period:d,selectedMonth:h,monthOptions:b,changePeriod:j=>{j!==d&&(o(!0),r(null),l(j))},changeMonth:j=>{j===h||!b.some(_=>_.value===j)||(o(!0),r(null),m(j))},refresh:()=>y(d,h,g)}}function em(){const{data:e,dataStatus:t,loading:n,error:r,period:s,selectedMonth:o,monthOptions:i,changePeriod:c,changeMonth:u,refresh:f}=Qh();return a.jsxs("div",{className:"flex w-full flex-col gap-6 p-2 md:p-6",children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold",children:[a.jsx(ii,{className:"h-6 w-6 text-primary"}),"Cloud Cost Management"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Costs for the selected AWS management account and its member accounts"})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(ar,{}),s==="monthly"&&a.jsx("select",{"aria-label":"Cost month",value:o,onChange:d=>u(d.target.value),disabled:n,className:"rounded-lg border bg-background px-3 py-2 text-sm shadow-sm disabled:opacity-50",children:i.map(d=>a.jsx("option",{value:d.value,children:d.label},d.value))}),a.jsx("div",{className:"flex rounded-lg border p-1",children:["monthly","yearly"].map(d=>a.jsx("button",{onClick:()=>c(d),className:`rounded-md px-3 py-1.5 text-sm capitalize transition-colors ${s===d?"bg-primary text-primary-foreground":"hover:bg-muted"}`,children:d},d))}),a.jsx("button",{onClick:()=>{f()},disabled:n,className:"rounded-lg border p-2 hover:bg-muted",children:a.jsx(Tt,{className:`h-4 w-4 ${n?"animate-spin":""}`})})]})]}),r&&e&&a.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:[a.jsx(ze,{className:"h-4 w-4"}),r]}),n?a.jsx(Xh,{}):t&&!t.ready?a.jsx(Zn,{status:t}):r&&!e?a.jsx(Zn,{status:t,error:r}):e?a.jsxs(a.Fragment,{children:[e.dataSource&&a.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[a.jsx("span",{children:"Source: AWS CUR via SaaS Athena - gross positive unblended charges"}),a.jsxs("span",{children:["CUR: Ready",t?.lastDataAt?`, updated ${new Date(t.lastDataAt).toLocaleString()}`:""]})]}),a.jsx(Zh,{data:e,period:s,selectedMonth:o}),e.message&&!/historical data beyond 14 months/i.test(e.message)&&a.jsx(ue,{children:a.jsx(de,{className:"py-8 text-center text-sm text-muted-foreground",children:e.message})}),a.jsxs(ue,{children:[a.jsxs(Re,{className:"flex flex-row items-center gap-2",children:[a.jsx(hi,{className:"h-4 w-4 text-primary"}),a.jsxs(Pe,{className:"text-sm",children:["Cost Trend - ",s==="monthly"?"Monthly":"Yearly"]})]}),a.jsx(de,{children:a.jsx(Kh,{points:e.trends.map(d=>({key:d.month,label:s==="yearly"?d.month.slice(0,4):new Date(`${d.month}T00:00:00Z`).toLocaleDateString(void 0,{month:"short",year:"2-digit"}),value:d.amount})),currency:e.currency})})]}),a.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[a.jsx(kr,{title:"Top services",icon:a.jsx(ui,{className:"h-4 w-4"}),items:e.topServices,currency:e.currency}),a.jsx(kr,{title:"AWS accounts",icon:a.jsx(si,{className:"h-4 w-4"}),items:e.topAccounts,currency:e.currency}),a.jsx(kr,{title:"Regional distribution",icon:a.jsx(Ff,{className:"h-4 w-4"}),items:e.topRegions,currency:e.currency})]})]}):null]})}const Sn=["#6264e9","#eb67ad","#31c39a","#f29a05","#579bea","#9078ed","#f7842c","#24b9ad","#8ac926","#ffca3a","#6a4c93","#1982c4"];function ko(e,t){const n=new Date(e.length===10?`${e}T00:00:00Z`:e);return Number.isFinite(n.getTime())?n.toLocaleDateString(void 0,t?{month:"short",day:"numeric"}:{month:"short",year:"numeric"}):e}function tm({timeline:e,currency:t="USD",daily:n=!1}){const[r,s]=P.useState(null),[o,i]=P.useState(null),c=P.useMemo(()=>{const g=new Map;for(const p of e)for(const x of p.groups)g.set(x.label,(g.get(x.label)||0)+x.amount);return[...g.entries()].sort((p,x)=>x[1]-p[1]).map(([p],x)=>({label:p,color:Sn[x%Sn.length]}))},[e]),u=new Map(c.map(g=>[g.label,g.color])),f=Math.max(...e.map(g=>g.total),1),d=r??o,l=d==null?null:e[d],h=n?52:80,m=Math.max(520,e.length*h);return e.length?a.jsxs("div",{className:"grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1fr)_288px]",onMouseLeave:()=>s(null),children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"grid min-h-80 min-w-0 grid-cols-[72px_minmax(0,1fr)] gap-3",children:[a.jsx("div",{className:"flex h-64 flex-col justify-between pb-1 text-right text-[11px] text-muted-foreground",children:[1,.75,.5,.25,0].map(g=>a.jsx("span",{children:X(f*g,t)},g))}),a.jsx("div",{className:"min-w-0 overflow-x-auto pb-2",children:a.jsxs("div",{style:{width:m},children:[a.jsxs("div",{className:"relative flex h-64 items-end border-b px-4",children:[[0,25,50,75].map(g=>a.jsx("span",{className:"pointer-events-none absolute left-0 right-0 border-t border-dashed border-slate-200",style:{top:`${g}%`}},g)),e.map((g,p)=>a.jsx("button",{type:"button",onMouseEnter:()=>s(p),onMouseLeave:()=>s(null),onPointerDown:x=>x.preventDefault(),onFocus:()=>i(p),onBlur:()=>i(null),className:"group z-10 flex h-full shrink-0 items-end justify-center px-2 outline-none focus-visible:ring-2 focus-visible:ring-primary",style:{width:h},children:a.jsx("span",{className:"flex w-full max-w-16 flex-col-reverse overflow-hidden rounded-t-sm shadow-sm transition group-hover:brightness-95",style:{height:`${Math.max(g.total/f*100,1)}%`},children:g.groups.map(x=>a.jsx("span",{style:{backgroundColor:u.get(x.label)||Sn[0],height:`${g.total?x.amount/g.total*100:0}%`}},x.key||x.label))})},`${g.start}-${p}`))]}),a.jsx("div",{className:"flex px-4 pt-2",children:e.map((g,p)=>a.jsx("span",{className:"shrink-0 whitespace-nowrap text-center text-[11px] text-muted-foreground",style:{width:h},children:ko(g.start,n)},`${g.start}-label-${p}`))})]})})]}),a.jsxs("div",{className:"mt-5 flex min-w-0 flex-wrap gap-x-4 gap-y-2",children:[c.slice(0,8).map(g=>a.jsxs("span",{className:"flex max-w-full min-w-0 items-center gap-1.5 text-xs",children:[a.jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-full",style:{backgroundColor:g.color}}),a.jsx("span",{className:"min-w-0 truncate",title:g.label,children:g.label})]},g.label)),c.length>8&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",c.length-8," more"]})]})]}),a.jsx("aside",{"aria-live":"polite",className:"min-h-44",children:l?a.jsxs("div",{role:"tooltip",className:"rounded-2xl border bg-popover p-4 text-popover-foreground shadow-lg",children:[a.jsx("p",{className:"font-semibold",children:ko(l.start,n)}),a.jsxs("div",{className:"mt-3 space-y-2",children:[[...l.groups].sort((g,p)=>p.amount-g.amount).slice(0,5).map(g=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:u.get(g.label)||Sn[0]}}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.label}),a.jsx("strong",{children:X(g.amount,t)})]},g.key||g.label)),l.groups.length>5&&a.jsxs("p",{className:"text-xs italic text-muted-foreground",children:["+ ",l.groups.length-5," others"]})]}),a.jsxs("div",{className:"mt-3 flex justify-between border-t pt-3 text-sm",children:[a.jsx("strong",{children:"Total"}),a.jsx("strong",{className:"text-primary",children:X(l.total,t)})]})]}):a.jsx("div",{className:"flex min-h-44 items-center justify-center rounded-2xl border border-dashed p-4 text-center text-xs text-muted-foreground",children:"Hover over a bar to view its cost details."})})]}):a.jsx("p",{className:"py-24 text-center text-sm text-muted-foreground",children:"No trend data for this period."})}function nm({rows:e,currency:t}){const n=e.slice(0,8),r=Math.max(1,...n.flatMap(s=>[s.current?.amount||0,s.previous?.amount||0]));return a.jsxs(ue,{className:"bg-primary/5",children:[a.jsx(Re,{children:a.jsx(Pe,{className:"text-sm",children:"Comparison Overview"})}),a.jsx(de,{children:a.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[a.jsx("div",{className:"flex h-72 items-end gap-4 border-b border-l px-4 pt-4",children:n.map(s=>a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col items-center",children:[a.jsxs("div",{className:"flex h-56 w-full items-end justify-center gap-1",children:[a.jsx("div",{title:`Current: ${X(s.current?.amount||0,t)}`,className:"w-1/3 max-w-10 rounded-t bg-indigo-500",style:{height:`${Math.max((s.current?.amount||0)/r*100,s.current?.amount?1:0)}%`}}),a.jsx("div",{title:`Previous: ${X(s.previous?.amount||0,t)}`,className:"w-1/3 max-w-10 rounded-t bg-pink-400",style:{height:`${Math.max((s.previous?.amount||0)/r*100,s.previous?.amount?1:0)}%`}})]}),a.jsx("span",{title:s.label,className:"mt-2 w-full truncate text-center text-[10px] text-muted-foreground",children:s.label})]},s.key))}),a.jsxs("div",{className:"mt-4 flex gap-5 text-xs",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-indigo-500"}),"Current Period"]}),a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-pink-400"}),"Previous Period"]})]})]})})]})}function Me({label:e,value:t,helper:n,accent:r=!1,trend:s}){return a.jsxs("div",{className:"rounded-xl border bg-card p-5 shadow-sm",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[s!=null&&(s<0?a.jsx(Kf,{className:"h-4 w-4 text-red-500"}):a.jsx(hi,{className:"h-4 w-4 text-emerald-500"})),a.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:e})]}),a.jsx("p",{className:`mt-2 text-2xl font-bold ${r?"text-primary":s!=null&&s<0?"text-red-500":""}`,children:t}),n&&a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n})]})}function Rn({label:e,options:t,selected:n,onChange:r}){const s=n.length?`${n.length} selected`:e;return a.jsxs("details",{className:"group relative",children:[a.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between rounded-lg border bg-background px-3 py-3 text-sm text-primary",children:[a.jsx("span",{children:s}),a.jsx(gf,{className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),a.jsx("div",{className:"absolute z-30 mt-1 max-h-64 w-full overflow-auto rounded-lg border bg-popover p-2 shadow-xl",children:t.length?t.map(o=>a.jsxs("label",{className:"flex cursor-pointer items-start gap-2 rounded px-2 py-2 text-xs hover:bg-muted",children:[a.jsx("input",{type:"checkbox",checked:n.includes(o.value),onChange:i=>r(i.target.checked?[...n,o.value]:n.filter(c=>c!==o.value))}),a.jsx("span",{className:"min-w-0 break-words",children:o.label})]},o.value)):a.jsx("p",{className:"p-2 text-xs text-muted-foreground",children:"No values available."})})]})}function rm(){return a.jsxs("div",{"aria-live":"polite","aria-busy":"true",className:"space-y-5",children:[a.jsxs("section",{className:"rounded-xl bg-primary/5 p-5",children:[a.jsxs("div",{className:"flex items-center gap-3 text-sm font-medium text-primary",children:[a.jsx(ct,{className:"h-5 w-5 animate-spin"}),"Loading live AWS cost report..."]}),a.jsx("div",{className:"mt-5 grid gap-3 sm:grid-cols-3",children:[1,2,3].map(e=>a.jsx("div",{className:"h-28 animate-pulse rounded-xl border bg-card/70"},e))})]}),a.jsx("div",{className:"h-80 animate-pulse rounded-xl border bg-muted/40"}),a.jsx("div",{className:"h-64 animate-pulse rounded-xl border bg-muted/40"})]})}const Xe=10,Jr=new Date,Oi=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,sm=Oi(new Date(Jr.getFullYear(),Jr.getMonth()-2,1)),om=Oi(Jr),Yt={services:[],regions:[],accountIds:[],tagKey:"",tagValues:[]},ht={service:{tab:"Services",title:"Service Cost Summary",pdfTitle:"Service Cost Report",top:"Top service cost",count:"Service count",item:"Service",empty:"No service cost data found."},account:{tab:"Accounts",title:"Account Cost Summary",pdfTitle:"Account Cost Report",top:"Top account cost",count:"Account count",item:"Linked account",empty:"No linked account cost data found."},region:{tab:"Regions",title:"Regional Cost Summary",pdfTitle:"Region Cost Report",top:"Top region cost",count:"Region count",item:"Region",empty:"No regional cost data found."},resource:{tab:"Resources",title:"Resource Cost Summary",pdfTitle:"Resource Cost Report",top:"Top resource cost",count:"Resource count",item:"Resource",empty:"Resource-level cost data requires resource IDs in the CUR export."},tag:{tab:"Tags",title:"Tag Cost Summary",pdfTitle:"Tag Cost Report",top:"Top tag value cost",count:"Tag value count",item:"Tag value",empty:"No cost allocation tag data found."}};function Po(e){return e?new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"longOffset"}).format(new Date(e)).replace("GMT","UTC"):"Not updated yet"}function Ao(e,t){const n=new Date(`${e}T00:00:00Z`);if(t==="monthly"){const s=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),1)),o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)),i=new Date(s);i.setUTCDate(i.getUTCDate()-1);const c=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1));return{currentStart:s.toISOString().slice(0,10),currentEnd:o.toISOString().slice(0,10),previousStart:c.toISOString().slice(0,10),previousEnd:i.toISOString().slice(0,10)}}const r=new Date(n);return r.setUTCDate(r.getUTCDate()-1),{currentStart:e,currentEnd:e,previousStart:r.toISOString().slice(0,10),previousEnd:r.toISOString().slice(0,10)}}function It(e,t,n){const r=new Date(`${e}T00:00:00Z`),s=new Date(`${t}T00:00:00Z`);if(n==="monthly"&&r.getUTCFullYear()===s.getUTCFullYear()&&r.getUTCMonth()===s.getUTCMonth())return new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric",timeZone:"UTC"}).format(r);const o=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"});return`${o.format(r)} – ${o.format(s)}`}function am(e){const t=new Map;return e.current.summary.forEach(n=>t.set(n.key||n.label,{current:n})),e.previous.summary.forEach(n=>{const r=n.key||n.label;t.set(r,{...t.get(r),previous:n})}),[...t.entries()].map(([n,r])=>{const s=r.current?.amount||0,o=r.previous?.amount||0,i=s-o;return{key:n,label:r.current?.label||r.previous?.label||n,...r,difference:i,change:o?i/Math.abs(o)*100:0}}).sort((n,r)=>Math.max(r.current?.amount||0,r.previous?.amount||0)-Math.max(n.current?.amount||0,n.previous?.amount||0))}function rt(e){return e?.length?e.map(t=>`${t.label}
18
18
  ${X(t.amount,"USD")}`).join(`
19
19
  `):"—"}function Oo({values:e}){const[t,n]=P.useState(!1);return a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"inline-flex items-center gap-2 text-primary",children:[a.jsx("span",{className:"rounded-full bg-primary/10 px-2 py-1 text-xs font-semibold",children:e.length}),a.jsx("span",{children:"›"})]}),t&&a.jsxs("div",{className:"absolute right-0 top-8 z-20 w-72 rounded-lg border bg-popover p-3 shadow-xl",children:[a.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[a.jsx("strong",{className:"text-xs",children:"Cost distribution"}),a.jsx("button",{onClick:()=>n(!1),children:a.jsx(Lt,{className:"h-3.5 w-3.5"})})]}),e.length?e.map(r=>a.jsxs("div",{className:"flex justify-between gap-3 border-t py-2 text-xs",children:[a.jsx("span",{className:"min-w-0 truncate",title:r.label,children:r.label}),a.jsx("strong",{children:X(r.amount,"USD")})]},r.key)):a.jsx("p",{className:"text-xs text-muted-foreground",children:"No related values."})]})]})}function Ti({page:e,pages:t,total:n,onChange:r}){const s=n?(e-1)*Xe+1:0,o=Math.min(e*Xe,n);return a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t px-4 py-4 text-xs text-muted-foreground",children:[a.jsxs("span",{children:["Showing ",s,"–",o," of ",n]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{"aria-label":"Previous page",disabled:e<=1,onClick:()=>r(e-1),className:"rounded-md border p-1.5 disabled:opacity-40",children:a.jsx(bf,{className:"h-4 w-4"})}),a.jsxs("span",{children:["Page ",e," of ",t]}),a.jsx("button",{"aria-label":"Next page",disabled:e>=t,onClick:()=>r(e+1),className:"rounded-md border p-1.5 disabled:opacity-40",children:a.jsx(vf,{className:"h-4 w-4"})})]})]})}function im({groupBy:e,report:t}){const[n,r]=P.useState(""),[s,o]=P.useState(1),[i,c]=P.useState(null),[u,f]=P.useState({percentage:!0,accounts:!0,regions:!0}),d=ht[e],l=P.useMemo(()=>{const p=n.trim().toLowerCase();return p?t.summary.filter(x=>`${x.label} ${x.accountId||""}`.toLowerCase().includes(p)):t.summary},[t,n]),h=Math.max(1,Math.ceil(l.length/Xe)),m=l.slice((s-1)*Xe,s*Xe),g=3+Number(u.percentage)+Number(u.accounts)+Number(u.regions);return P.useEffect(()=>{o(1)},[t,n,e]),a.jsxs(ue,{children:[a.jsxs(Re,{className:"flex flex-row flex-wrap items-center justify-between gap-3",children:[a.jsx(Pe,{className:"text-sm text-primary",children:"Cost and usage breakdown"}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs("label",{className:"flex items-center gap-2 rounded-full border bg-background px-4 py-2 text-sm",children:[a.jsx(hs,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("input",{"aria-label":"Search breakdown",value:n,onChange:p=>r(p.target.value),placeholder:"Search...",className:"w-48 bg-transparent outline-none"})]}),a.jsxs("details",{className:"relative",children:[a.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 rounded-md border px-3 py-2 text-sm text-primary",children:[a.jsx(di,{className:"h-4 w-4"}),"Column visibility"]}),a.jsx("div",{className:"absolute right-0 z-20 mt-1 w-48 rounded-md border bg-popover p-3 shadow-xl",children:Object.entries(u).map(([p,x])=>a.jsxs("label",{className:"flex gap-2 py-1 text-xs capitalize",children:[a.jsx("input",{type:"checkbox",checked:x,onChange:b=>f(y=>({...y,[p]:b.target.checked}))}),p]},p))})]})]})]}),a.jsx(de,{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b bg-primary/5 text-left text-xs uppercase text-primary",children:[a.jsx("th",{className:"px-4 py-4",children:d.item}),a.jsx("th",{className:"px-4",children:"Cost"}),u.percentage&&a.jsx("th",{className:"px-4",children:"Percentage"}),u.accounts&&a.jsx("th",{className:"px-4",children:"Accounts"}),u.regions&&a.jsx("th",{className:"px-4",children:"Regions"}),a.jsx("th",{className:"px-4 text-center",children:"Actions"})]})}),a.jsx("tbody",{children:m.length?m.map(p=>a.jsxs("tr",{className:"border-b last:border-0",children:[a.jsxs("td",{className:"max-w-72 px-4 py-4 font-medium",children:[a.jsx("div",{className:"truncate",title:p.label,children:p.label}),e==="account"&&a.jsx("div",{className:"font-mono text-xs text-muted-foreground",children:p.accountId||p.key})]}),a.jsx("td",{className:"px-4 font-semibold",children:X(p.amount,t.currency)}),u.percentage&&a.jsxs("td",{className:"px-4",children:[a.jsx("span",{className:"mr-2 inline-block h-1.5 w-12 overflow-hidden rounded-full bg-primary/15 align-middle",children:a.jsx("span",{className:"block h-full bg-primary",style:{width:`${Math.min(p.percentage||0,100)}%`}})}),a.jsxs("strong",{className:"text-primary",children:[p.percentage?.toFixed(2),"%"]})]}),u.accounts&&a.jsx("td",{className:"px-4",children:a.jsx(Oo,{values:p.accounts||[]})}),u.regions&&a.jsx("td",{className:"px-4",children:a.jsx(Oo,{values:p.regions||[]})}),a.jsx("td",{className:"px-4 text-center",children:a.jsx("button",{type:"button",onClick:()=>c(p),title:"View cost details",className:"text-primary hover:opacity-70",children:a.jsx(Pf,{className:"h-4 w-4"})})})]},p.key||p.label)):a.jsx("tr",{children:a.jsx("td",{colSpan:g,className:"py-12 text-center text-muted-foreground",children:d.empty})})})]})}),a.jsx(Ti,{page:s,pages:h,total:l.length,onChange:o}),i&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",onClick:()=>c(null),children:a.jsxs("div",{className:"max-h-[80vh] w-full max-w-2xl overflow-auto rounded-xl bg-card p-6 shadow-2xl",onClick:p=>p.stopPropagation(),children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs uppercase text-muted-foreground",children:d.item}),a.jsx("h3",{className:"mt-1 text-lg font-semibold",children:i.label})]}),a.jsx("button",{onClick:()=>c(null),children:a.jsx(Lt,{})})]}),a.jsxs("div",{className:"mt-5 grid gap-3 sm:grid-cols-3",children:[a.jsx(Me,{label:"Cost",value:X(i.amount,t.currency)}),a.jsx(Me,{label:"Accounts",value:String(i.accounts?.length||0)}),a.jsx(Me,{label:"Regions",value:String(i.regions?.length||0)})]}),a.jsxs("div",{className:"mt-5 grid gap-5 sm:grid-cols-2",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"mb-2 text-sm font-semibold",children:"Accounts"}),(i.accounts||[]).map(p=>a.jsxs("div",{className:"flex justify-between border-t py-2 text-xs",children:[a.jsx("span",{children:p.label}),a.jsx("strong",{children:X(p.amount,t.currency)})]},p.key))]}),a.jsxs("div",{children:[a.jsx("h4",{className:"mb-2 text-sm font-semibold",children:"Regions"}),(i.regions||[]).map(p=>a.jsxs("div",{className:"flex justify-between border-t py-2 text-xs",children:[a.jsx("span",{children:p.label}),a.jsx("strong",{children:X(p.amount,t.currency)})]},p.key))]})]})]})})]})}function cm({rows:e,groupBy:t,comparison:n,granularity:r}){const[s,o]=P.useState(""),[i,c]=P.useState(1),u=P.useMemo(()=>{const m=s.trim().toLowerCase();return m?e.filter(g=>g.label.toLowerCase().includes(m)):e},[e,s]),f=Math.max(1,Math.ceil(u.length/Xe)),d=u.slice((i-1)*Xe,i*Xe),l=It(n.currentStart,n.currentEnd,r),h=It(n.previousStart,n.previousEnd,r);return P.useEffect(()=>{c(1)},[s,t,n]),a.jsxs(ue,{children:[a.jsxs(Re,{className:"flex flex-row flex-wrap items-center justify-between gap-3",children:[a.jsx(Pe,{className:"text-sm text-primary",children:"Comparison Details"}),a.jsxs("label",{className:"flex items-center gap-2 rounded-full border bg-background px-4 py-2 text-sm",children:[a.jsx(hs,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("input",{"aria-label":"Search comparison",value:s,onChange:m=>o(m.target.value),placeholder:"Search...",className:"w-48 bg-transparent outline-none"})]})]}),a.jsx(de,{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b bg-primary/5 text-left text-xs uppercase text-primary",children:[a.jsxs("th",{className:"px-4 py-4",children:[ht[t].item," name"]}),a.jsxs("th",{className:"px-4",children:[l,a.jsx("small",{className:"block font-normal",children:"Cost"})]}),a.jsxs("th",{className:"px-4",children:[h,a.jsx("small",{className:"block font-normal",children:"Cost"})]}),a.jsx("th",{className:"px-4",children:"Difference"}),a.jsx("th",{className:"px-4",children:"Change %"})]})}),a.jsx("tbody",{children:d.length?d.map(m=>a.jsxs("tr",{className:"border-b",children:[a.jsx("td",{className:"max-w-80 px-4 py-4 font-medium",children:a.jsx("div",{className:"truncate",title:m.label,children:m.label})}),a.jsx("td",{className:"px-4",children:X(m.current?.amount||0,n.current.currency)}),a.jsx("td",{className:"px-4",children:X(m.previous?.amount||0,n.previous.currency)}),a.jsxs("td",{className:`px-4 font-medium ${m.difference<0?"text-red-500":"text-emerald-600"}`,children:[m.difference>=0?"+":"",X(m.difference,n.current.currency)]}),a.jsxs("td",{className:`px-4 font-medium ${m.change<0?"text-red-500":m.change>0?"text-emerald-600":"text-muted-foreground"}`,children:[m.change>0?"+":"",m.change.toFixed(1),"%"]})]},m.key)):a.jsx("tr",{children:a.jsx("td",{colSpan:5,className:"py-12 text-center text-muted-foreground",children:"No comparison data found."})})})]})}),a.jsx(Ti,{page:i,pages:f,total:u.length,onChange:c})]})}function lm(e){const{mode:t,groupBy:n,start:r,end:s,granularity:o,reportTagKey:i,options:c,filters:u,loading:f,filtersLoading:d,comparisonPeriods:l}=e;return a.jsxs("aside",{className:"space-y-4",children:[a.jsxs(ue,{className:"bg-primary/5",children:[a.jsx(Re,{children:a.jsx(Pe,{className:"text-sm uppercase text-primary",children:"Report parameters"})}),a.jsxs(de,{className:"space-y-4",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>e.onModeChange("standard"),className:`rounded-md px-4 py-2 text-xs font-semibold ${t==="standard"?"bg-primary text-primary-foreground":"border text-primary"}`,children:"Standard"}),a.jsx("button",{onClick:()=>e.onModeChange("compare"),className:`rounded-md px-4 py-2 text-xs font-semibold ${t==="compare"?"bg-primary text-primary-foreground":"border text-primary"}`,children:"Compare"})]}),t==="standard"&&a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"block text-xs text-muted-foreground",children:["Start date",a.jsx("input",{type:"date",value:r,onChange:h=>e.onStartChange(h.target.value),className:"mt-1 w-full rounded-md border bg-background p-2 text-sm text-foreground"})]}),a.jsxs("label",{className:"block text-xs text-muted-foreground",children:["End date",a.jsx("input",{type:"date",value:s,onChange:h=>e.onEndChange(h.target.value),className:"mt-1 w-full rounded-md border bg-background p-2 text-sm text-foreground"})]})]}),a.jsxs("label",{className:"block text-xs text-muted-foreground",children:["Granularity",a.jsxs("select",{value:o,onChange:h=>e.onGranularityChange(h.target.value),className:"mt-1 w-full rounded-md border bg-background p-2 text-sm text-foreground",children:[a.jsx("option",{value:"monthly",children:"Monthly"}),a.jsx("option",{value:"daily",children:"Daily"})]})]}),t==="compare"&&a.jsxs("p",{className:"rounded-md bg-background p-2 text-xs text-muted-foreground",children:["Current: ",l.currentStart," to ",l.currentEnd,a.jsx("br",{}),"Previous: ",l.previousStart," to ",l.previousEnd]}),n==="tag"&&a.jsxs("label",{className:"block text-xs text-muted-foreground",children:["Group by tag key",a.jsxs("select",{value:c.tagKeys.includes(i)?i:"",onChange:h=>e.onReportTagKeyChange(h.target.value),disabled:!c.tagKeys.length,className:"mt-1 w-full rounded-md border bg-background p-2 text-sm text-foreground disabled:opacity-60",children:[a.jsx("option",{value:"",children:d?"Loading tag keys...":"Select a tag key"}),c.tagKeys.map(h=>a.jsx("option",{children:h},h))]}),!d&&!c.tagKeys.length&&a.jsx("span",{className:"mt-2 block text-xs text-muted-foreground",children:"No activated AWS cost allocation tags are present in this CUR data."})]}),a.jsxs("button",{onClick:e.onRun,disabled:f||n==="tag"&&!c.tagKeys.length,className:"flex w-full items-center justify-center gap-2 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50",children:[a.jsx(Tt,{className:`h-4 w-4 ${f?"animate-spin":""}`}),"Run report"]})]})]}),a.jsxs(ue,{className:"bg-primary/5",children:[a.jsx(Re,{children:a.jsx(Pe,{className:"text-sm uppercase text-primary",children:"Filter by"})}),a.jsxs(de,{className:"space-y-3",children:[a.jsx(Rn,{label:"Services",options:c.services,selected:u.services,onChange:h=>e.onFiltersChange(m=>({...m,services:h}))}),a.jsx(Rn,{label:"Region",options:c.regions,selected:u.regions,onChange:h=>e.onFiltersChange(m=>({...m,regions:h}))}),a.jsx(Rn,{label:"Linked Account",options:c.accounts,selected:u.accountIds,onChange:h=>e.onFiltersChange(m=>({...m,accountIds:h}))}),a.jsxs("select",{value:u.tagKey,onChange:h=>{const m=h.target.value;e.onFiltersChange(g=>({...g,tagKey:m,tagValues:[]})),m&&e.onLoadTagValues(m)},className:"w-full rounded-lg border bg-background px-3 py-3 text-sm text-primary",children:[a.jsx("option",{value:"",children:"Tag key"}),c.tagKeys.map(h=>a.jsx("option",{children:h},h))]}),u.tagKey&&a.jsx(Rn,{label:"Tag values",options:c.tagValues.map(h=>({value:h,label:h})),selected:u.tagValues,onChange:h=>e.onFiltersChange(m=>({...m,tagValues:h}))}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 pt-2",children:[a.jsx("button",{onClick:e.onApply,disabled:d||f,className:"rounded-md bg-primary px-3 py-2 text-sm font-semibold text-primary-foreground disabled:opacity-50",children:"Apply Filters"}),a.jsx("button",{onClick:e.onReset,disabled:f,className:"rounded-md border bg-background px-3 py-2 text-sm text-primary disabled:opacity-50",children:"Reset"})]})]})]})]})}function um(){const{managementAccountId:e,loading:t}=$t(),[n,r]=P.useState("service"),[s,o]=P.useState("standard"),[i,c]=P.useState(sm),[u,f]=P.useState(om),[d,l]=P.useState("monthly"),[h,m]=P.useState("Name"),[g,p]=P.useState({services:[],regions:[],accounts:[],tagKeys:[],tagValues:[]}),[x,b]=P.useState(Yt),[y,v]=P.useState(Yt),[N,j]=P.useState(null),[_,C]=P.useState(null),[R,k]=P.useState(!0),[L,A]=P.useState(!1),[D,O]=P.useState(null),[$,J]=P.useState(null),Y=P.useRef(0),Q=P.useMemo(()=>_?am(_):[],[_]),he=Ao(u,d),me=(U,Z,V,ie)=>({start:Z,end:V,groupBy:ie,granularity:d,tagKey:h,services:U.services.join(","),regions:U.regions.join(","),accountIds:U.accountIds.join(","),filterTagKey:U.tagKey||void 0,tagValues:U.tagValues.join(","),managementAccountId:e}),I=async(U="")=>{A(!0);try{const Z=await oe.getDataStatus({managementAccountId:e});if(J(Z),!Z.ready)return;const V=await oe.getFilterOptions({start:i,end:u,filterTagKey:U||void 0,managementAccountId:e});p(ie=>U?{...ie,tagValues:V.tagValues}:V),!U&&V.tagKeys.length&&!V.tagKeys.includes(h)&&m(V.tagKeys[0])}catch(Z){O(Z?.response?.data?.error||Z.message||"Failed to load filter values")}finally{A(!1)}},E=async(U=y,Z=s,V=n)=>{const ie=++Y.current;k(!0),O(null),j(null),C(null);try{const le=await oe.getDataStatus({managementAccountId:e});if(ie===Y.current&&J(le),!le.ready)return;if(Z==="compare"){const te=Ao(u,d),[je,Ce]=await Promise.all([oe.getReports(me(U,te.currentStart,te.currentEnd,V)),oe.getReports(me(U,te.previousStart,te.previousEnd,V))]);ie===Y.current&&(j(je),C({current:je,previous:Ce,...te}))}else{const te=await oe.getReports(me(U,i,u,V));ie===Y.current&&j(te)}}catch(le){ie===Y.current&&O(le?.response?.data?.error||le.message||"Failed to generate cost report")}finally{ie===Y.current&&k(!1)}};return P.useEffect(()=>{t||(J(null),p({services:[],regions:[],accounts:[],tagKeys:[],tagValues:[]}),E(y,s,n),I())},[e,t]),{groupBy:n,mode:s,start:i,end:u,granularity:d,reportTagKey:h,options:g,draftFilters:x,report:N,comparison:_,loading:R||t,filtersLoading:L,error:D,dataStatus:$,comparedRows:Q,selectedComparisonPeriods:he,setStart:c,setEnd:f,setGranularity:l,setReportTagKey:m,setDraftFilters:b,changeGroup:U=>{U!==n&&(k(!0),j(null),C(null),r(U),E(y,s,U))},changeMode:U=>{U!==s&&(k(!0),j(null),C(null),o(U),E(y,U,n))},applyFilters:()=>{const U={...x,services:[...x.services],regions:[...x.regions],accountIds:[...x.accountIds],tagValues:[...x.tagValues]};v(U),E(U)},resetFilters:()=>{b(Yt),v(Yt),E(Yt)},runReport:()=>{I(),E()},loadOptions:I}}function dm(e){const{report:t,comparison:n,rows:r,groupBy:s,mode:o,start:i,end:c}=e,u=ht[s];let f,d;o==="compare"&&n?(f=[[u.item,"Current Cost","Previous Cost","Difference","Change %"].join(","),...r.map(h=>[`"${h.label.replace(/"/g,'""')}"`,h.current?.amount||0,h.previous?.amount||0,h.difference,h.change.toFixed(2)].join(","))].join(`
20
20
  `),d=`comparison-report-${s}-${Date.now()}.csv`):(f=[[u.item,"Cost","Percentage","Accounts","Regions"].join(","),...t.summary.map(h=>[`"${h.label.replace(/"/g,'""')}"`,h.amount,h.percentage||0,h.accounts?.length||0,h.regions?.length||0].join(","))].join(`
21
- `),d=`${s}-summary-report-${Date.now()}.csv`);const l=document.createElement("a");l.href=URL.createObjectURL(new Blob([f],{type:"text/csv"})),l.download=d,l.click(),URL.revokeObjectURL(l.href)}async function fm(e){const{report:t,comparison:n,rows:r,groupBy:s,mode:o,start:i,end:c,granularity:u}=e,f=ht[s],[{jsPDF:d},{default:l}]=await Promise.all([Promise.resolve().then(()=>require("./jspdf.es.min-C10id8ME.cjs")).then(p=>p.jspdf_es_min),Promise.resolve().then(()=>require("./jspdf.plugin.autotable-CvTok6mL.cjs"))]),h=new d({orientation:"landscape",unit:"pt",format:"a4"}),m=(p,x,b)=>{h.setFontSize(7),h.setTextColor(100),h.text(`Report generated · All costs in ${t.currency} · ${x} to ${b}`,40,h.internal.pageSize.height-18),h.text(`Page ${p.pageNumber}`,h.internal.pageSize.width-70,h.internal.pageSize.height-18)};if(o==="compare"&&n){h.setFontSize(18),h.setTextColor(25),h.text("Comparison Report",40,42),h.setFontSize(9),h.setTextColor(98,86,230),h.text("TOTAL COST",40,66),h.setTextColor(40),h.text(`Previous Cost: ${n.previous.totalCost}`,40,82),h.text(`Current Cost: ${n.current.totalCost}`,220,82),h.text(`Granularity: ${u}`,400,82),l(h,{startY:100,head:[[`${f.item} Name`,"Current Cost","Previous Cost","Current Period","Previous Period","Change %","Current Accounts","Previous Accounts","Current Regions","Previous Regions"]],body:r.map(p=>[p.label,p.current?.amount?.toFixed(2)||"0.00",p.previous?.amount?.toFixed(2)||"0.00",It(n.currentStart,n.currentEnd,u),It(n.previousStart,n.previousEnd,u),`${p.change.toFixed(4)}%`,rt(p.current?.accounts),rt(p.previous?.accounts),rt(p.current?.regions),rt(p.previous?.regions)]),styles:{fontSize:6,cellPadding:3,overflow:"linebreak"},headStyles:{fillColor:[242,237,255],textColor:[82,35,190]},didDrawPage:p=>m(p,n.previousStart,n.currentEnd),margin:{bottom:32}}),h.save(`comparison-report-${s}-${Date.now()}.pdf`);return}h.setFontSize(18),h.setTextColor(25),h.text(f.pdfTitle,40,42),h.setFontSize(9),h.setTextColor(98,86,230),h.text("REPORT METADATA",40,66),h.setTextColor(40),h.text(`Tenant ID: ${t.tenantId||"Current tenant"}`,40,82),h.text(`Date Range: ${i} to ${c}`,40,97),h.text(`Accrued Total Cost: ${X(t.totalCost,t.currency)}`,40,112),h.setTextColor(98,86,230),h.text("COST SUMMARY BREAKDOWN",40,136);const g=s==="account";l(h,{startY:146,head:[g?["Account ID","Account Name","Total Cost","Percentage","Regions"]:[`${f.item} Name`,"Total Cost","Percentage","Accounts","Regions"]],body:t.summary.map(p=>g?[p.accountId||p.key||"—",p.label,X(p.amount,t.currency),`${(p.percentage||0).toFixed(2)}%`,rt(p.regions)]:[p.label,X(p.amount,t.currency),`${(p.percentage||0).toFixed(2)}%`,rt(p.accounts),rt(p.regions)]),styles:{fontSize:7,cellPadding:4,overflow:"linebreak"},headStyles:{fillColor:[242,237,255],textColor:[82,35,190]},didDrawPage:p=>m(p,i,c),margin:{bottom:32}}),h.save(`${s}-summary-report-${Date.now()}.pdf`)}function hm(){const e=um(),{groupBy:t,mode:n,report:r,comparison:s,comparedRows:o,loading:i,error:c,dataStatus:u,granularity:f,start:d,end:l}=e,h=ht[t],m=r?.summary[0],g=s?s.current.totalCost-s.previous.totalCost:0,p=s?.previous.totalCost?g/Math.abs(s.previous.totalCost)*100:0,x=r?{report:r,comparison:s,rows:o,groupBy:t,mode:n,start:d,end:l,granularity:f}:null,b=a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>x&&void fm(x),disabled:!x||i,className:"flex items-center gap-2 rounded-md border bg-card px-3 py-1.5 text-sm disabled:opacity-50",children:[a.jsx(Of,{className:"h-4 w-4"}),"PDF"]}),a.jsxs("button",{onClick:()=>x&&dm(x),disabled:!x||i,className:"flex items-center gap-2 rounded-md border bg-card px-3 py-1.5 text-sm disabled:opacity-50",children:[a.jsx(fs,{className:"h-4 w-4"}),"CSV"]})]});return a.jsxs("div",{className:"flex w-full flex-col gap-5 p-2 md:p-6",children:[a.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold",children:[a.jsx(li,{className:"h-6 w-6 text-primary"}),"Cost reports"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Analyse live AWS cost by service, linked account, region, resource, or cost allocation tag"})]}),a.jsx(ar,{})]}),!i&&(u&&!u.ready||c&&!u)?a.jsx(Zn,{status:u,error:c}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex gap-1 overflow-x-auto border-b",children:Object.keys(ht).map(y=>a.jsx("button",{onClick:()=>e.changeGroup(y),className:`border-b-2 px-4 py-3 text-sm font-medium ${t===y?"border-primary text-primary":"border-transparent text-muted-foreground"}`,children:ht[y].tab},y))}),a.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1fr)_320px]",children:[a.jsxs("div",{className:"space-y-5",children:[c&&a.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:[a.jsx(ze,{className:"h-4 w-4"}),c]}),i?a.jsx(rm,{}):n==="compare"&&s?a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:"rounded-xl bg-primary/5 p-4",children:[a.jsxs("div",{className:"mb-4 flex flex-wrap items-start justify-between gap-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-sm font-semibold",children:"Comparison Cost Summary"}),a.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Updated On: ",Po(s.current.updatedAt)]})]}),b]}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[a.jsx(Me,{label:"Period accrued total",value:`${X(s.current.totalCost,s.current.currency)} vs ${X(s.previous.totalCost,s.previous.currency)}`,helper:`${p>=0?"+":""}${p.toFixed(1)}% from previous period`,trend:p}),a.jsx(Me,{label:It(s.currentStart,s.currentEnd,f),value:X(s.current.totalCost,s.current.currency),helper:"Current period spending"}),a.jsx(Me,{label:It(s.previousStart,s.previousEnd,f),value:X(s.previous.totalCost,s.previous.currency),helper:"Previous period spending"}),a.jsx(Me,{label:f==="monthly"?"Monthly change":"Period change",value:`${g>=0?"+":""}${X(g,s.current.currency)}`,helper:`${p>=0?"+":""}${p.toFixed(1)}% from previous period`,trend:g})]})]}),a.jsx(nm,{rows:o,currency:s.current.currency}),a.jsx(cm,{rows:o,groupBy:t,comparison:s,granularity:f})]}):r?a.jsxs(a.Fragment,{children:[r.message&&a.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-muted/50 p-3 text-sm text-muted-foreground",children:[a.jsx(ze,{className:"h-4 w-4"}),r.message]}),a.jsxs("section",{className:"rounded-xl bg-primary/5 p-4",children:[a.jsxs("div",{className:"mb-4 flex flex-wrap items-start justify-between gap-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-sm font-semibold",children:h.title}),a.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Updated On: ",Po(r.updatedAt)]})]}),b]}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[a.jsx(Me,{label:"Accrued cost",value:X(r.totalCost,r.currency)}),a.jsx(Me,{label:h.top,value:m?X(m.amount,r.currency):"-",accent:!0}),a.jsx(Me,{label:h.count,value:String(r.count||0),accent:!0})]})]}),a.jsxs(ue,{children:[a.jsx(Re,{children:a.jsx(Pe,{className:"text-sm",children:"Cost Trend"})}),a.jsx(de,{children:a.jsx(tm,{timeline:r.timeline||[],currency:r.currency||"USD",daily:f==="daily"})})]}),a.jsx(im,{groupBy:t,report:r})]}):null]}),a.jsx(lm,{mode:n,groupBy:t,start:d,end:l,granularity:f,reportTagKey:e.reportTagKey,options:e.options,filters:e.draftFilters,loading:i,filtersLoading:e.filtersLoading,comparisonPeriods:e.selectedComparisonPeriods,onModeChange:e.changeMode,onStartChange:e.setStart,onEndChange:e.setEnd,onGranularityChange:e.setGranularity,onReportTagKeyChange:e.setReportTagKey,onFiltersChange:e.setDraftFilters,onLoadTagValues:y=>{e.loadOptions(y)},onRun:e.runReport,onApply:e.applyFilters,onReset:e.resetFilters})]})]})]})}const To={READY:"bg-emerald-500/10 text-emerald-600 border-emerald-500/30",RUNNING:"bg-blue-500/10 text-blue-600 border-blue-500/30",WAITING_FOR_DATA:"bg-amber-500/10 text-amber-600 border-amber-500/30",WAITING_FOR_TABLE:"bg-amber-500/10 text-amber-600 border-amber-500/30",FAILED:"bg-destructive/10 text-destructive border-destructive/30",PENDING:"bg-muted text-muted-foreground border-border"},mm={INFO:"text-muted-foreground",WARN:"text-amber-600",ERROR:"text-destructive"},Nn=e=>e?new Date(e).toLocaleString():"—";function pm({status:e}){return a.jsx("span",{className:`rounded-full border px-2 py-0.5 text-xs font-medium ${To[e]||To.PENDING}`,children:e.replace(/_/g," ")})}function Ue({label:e,value:t,mono:n}){return a.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.jsx("span",{className:"text-xs text-muted-foreground",children:e}),a.jsx("span",{className:`break-all text-sm ${n?"font-mono text-xs":""}`,children:t||"—"})]})}function gm(){const{managementAccountId:e,loading:t}=$t(),[n,r]=P.useState([]),[s,o]=P.useState([]),[i,c]=P.useState(!0),[u,f]=P.useState(null),d=P.useCallback(async()=>{c(!0),f(null);try{const l=await ne.get("/cur-discovery",{params:{logLimit:100,managementAccountId:e}});r(l.data?.jobs||[]),o(l.data?.logs||[])}catch(l){f(l?.response?.data?.error||l?.message||"Unable to load CUR discovery status")}finally{c(!1)}},[e]);return P.useEffect(()=>{t||d()},[d,t]),a.jsxs("div",{className:"flex w-full flex-col gap-6 p-2 md:p-6",children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold",children:[a.jsx(hs,{className:"h-6 w-6 text-primary"}),"CUR Discovery"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Progress of the scheduled job that locates this tenant’s Cost and Usage Report table. Cost data becomes available after it reports Ready."})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(ar,{}),a.jsx("button",{onClick:()=>{d()},disabled:i||t,className:"rounded-lg border p-2 hover:bg-muted disabled:opacity-50","aria-label":"Refresh",children:a.jsx(Tt,{className:`h-4 w-4 ${i||t?"animate-spin":""}`})})]})]}),u&&a.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:[a.jsx(ze,{className:"h-4 w-4"}),u]}),!i&&!u&&!n.length&&a.jsx(ue,{children:a.jsx(de,{className:"py-10 text-center text-sm text-muted-foreground",children:"No discovery job exists for this tenant yet. One is created automatically once the AWS connection is verified and the Cost plugin is entitled."})}),n.map(l=>a.jsxs(ue,{children:[a.jsxs(Re,{className:"flex flex-row flex-wrap items-center gap-3",children:[a.jsx(ai,{className:"h-4 w-4 text-primary"}),a.jsxs(Pe,{className:"text-sm",children:["Management account ",l.managementAccountId]}),a.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["connection ",l.connectionId]}),a.jsx(pm,{status:l.status}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:["attempt ",l.attemptCount]}),a.jsxs("span",{className:"ms-auto text-xs text-muted-foreground",children:["next check ",Nn(l.nextRunAt)]})]}),a.jsxs(de,{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[a.jsx(Ue,{label:"Source",value:l.curS3Uri||`s3://${l.bucket}/${l.prefix}`,mono:!0}),a.jsx(Ue,{label:"Tenant partition",value:l.tenantPartition,mono:!0}),a.jsx(Ue,{label:"Region",value:l.region}),a.jsx(Ue,{label:"Glue database",value:l.database,mono:!0}),a.jsx(Ue,{label:"Discovered table",value:l.table,mono:!0}),a.jsx(Ue,{label:"Table location",value:l.tableLocation,mono:!0}),a.jsx(Ue,{label:"Sample object",value:l.sampleObjectKey,mono:!0}),a.jsx(Ue,{label:"Last data",value:Nn(l.lastDataAt)}),a.jsx(Ue,{label:"Last checked",value:Nn(l.lastFinishedAt||l.lastStartedAt)}),l.lastError&&a.jsx("div",{className:"md:col-span-2 lg:col-span-3 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:l.lastError})]})]},l.id)),n.length>0&&a.jsxs("section",{children:[a.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"Recent activity"}),a.jsx("div",{className:"space-y-2",children:n.map(l=>{const h=s.filter(m=>m.jobId===l.id);return a.jsxs("details",{open:!0,className:"rounded-md border bg-card",children:[a.jsxs("summary",{className:"cursor-pointer px-4 py-3 text-sm font-medium",children:["Management account ",a.jsx("span",{className:"font-mono",children:l.managementAccountId})]}),a.jsx("div",{className:"border-t px-4 py-2",children:h.length?a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b text-left text-xs uppercase text-muted-foreground",children:[a.jsx("th",{className:"py-2 pe-4 font-medium",children:"Time"}),a.jsx("th",{className:"py-2 pe-4 font-medium",children:"Level"}),a.jsx("th",{className:"py-2 pe-4 font-medium",children:"Event"}),a.jsx("th",{className:"py-2 font-medium",children:"Message"})]})}),a.jsx("tbody",{children:h.map(m=>a.jsxs("tr",{className:"border-b last:border-0 align-top",children:[a.jsx("td",{className:"whitespace-nowrap py-2 pe-4 text-xs text-muted-foreground",children:Nn(m.createdAt)}),a.jsx("td",{className:`py-2 pe-4 text-xs font-medium ${mm[m.level]||""}`,children:m.level}),a.jsx("td",{className:"whitespace-nowrap py-2 pe-4 font-mono text-xs",children:m.event}),a.jsx("td",{className:"py-2",children:m.message})]},m.id))})]})}):a.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"No log entries recorded yet."})})]},l.id)})})]})]})}const xm=e=>e.launchUrl||`https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create?stackName=${encodeURIComponent(e.stackName||`MeyiConnect-${e.connectionId}-Management`)}`,bm=e=>e==="CONNECTED"?"border-emerald-500/30 bg-emerald-500/10 text-emerald-600":e==="FAILED"?"border-destructive/30 bg-destructive/10 text-destructive":"border-amber-500/30 bg-amber-500/10 text-amber-700",Jt=e=>{const t=e?.response?.data?.error||e?.response?.data?.message||e?.message||"Request failed",n=e?.response?.data?.details;return n?`${t} ${n}`:t};function ym(){const{selectManagementAccount:e,refreshSources:t}=$t(),[n,r]=P.useState([]),[s,o]=P.useState(!1),[i,c]=P.useState(!0),[u,f]=P.useState(!1),[d,l]=P.useState(null),[h,m]=P.useState(!1),[g,p]=P.useState(""),[x,b]=P.useState(!1),[y,v]=P.useState(null),[N,j]=P.useState(null),[_,C]=P.useState(null),R=P.useCallback(async()=>{c(!0),C(null);try{const O=await oe.getSources();r(O.sources||[]),o(O.allowMultipleSources===!0)}catch(O){C(Jt(O))}finally{c(!1)}},[]);P.useEffect(()=>{R()},[R]);const k=async O=>{if(O.preventDefault(),!/^\d{12}$/.test(g)){C("AWS account ID must contain exactly 12 digits");return}j("create"),C(null);try{const $=await oe.createSource({managementAccountId:g,regionMode:x?"ALL":"SINGLE"});$.managementAccountId&&e($.managementAccountId),await t(),v($.connectionId),f(!1),p(""),b(!1),await R()}catch($){C(Jt($))}finally{j(null)}},L=async O=>{j(`download-${O}`),C(null);try{const $=await oe.downloadSourceTemplate(O),J=URL.createObjectURL($),Y=document.createElement("a");Y.href=J,Y.download=`meyi-connect-cost-${O}.yaml`,Y.click(),URL.revokeObjectURL(J),v(O)}catch($){C(Jt($))}finally{j(null)}},A=async O=>{j(`verify-${O}`),C(null);try{const $=await oe.verifySource(O);$.status==="FAILED"&&C($.message||"AWS connection verification failed"),await R()}catch($){C(Jt($))}finally{j(null)}},D=async()=>{if(d){j(`remove-${d.connectionId}`),C(null);try{await oe.removeSource(d.connectionId,h),l(null),m(!1),await R(),await t()}catch(O){C(Jt(O))}finally{j(null)}}};return a.jsxs("div",{className:"flex w-full flex-col gap-6 p-2 md:p-6",children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold",children:[a.jsx(Jn,{className:"h-6 w-6 text-primary"}),"Cost Sources"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"AWS accounts connected to this tenant for Cost and Usage Report data."})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{type:"button",onClick:()=>{R()},disabled:i,className:"rounded-md border p-2 hover:bg-muted disabled:opacity-50","aria-label":"Refresh sources",title:"Refresh sources",children:a.jsx(Tt,{className:`h-4 w-4 ${i?"animate-spin":""}`})}),(s||n.length===0)&&a.jsxs("button",{type:"button",onClick:()=>{C(null),f(!0)},className:"flex items-center gap-2 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:opacity-90",children:[a.jsx($f,{className:"h-4 w-4"}),"Add AWS account"]})]})]}),_&&a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:[a.jsx(ze,{className:"mt-0.5 h-4 w-4 shrink-0"}),_]}),!i&&n.length===0&&a.jsxs("div",{className:"rounded-md border border-dashed py-14 text-center",children:[a.jsx(Jn,{className:"mx-auto mb-3 h-8 w-8 text-muted-foreground"}),a.jsx("p",{className:"font-medium",children:"No AWS Cost source"}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Add an AWS account to begin collecting tenant cost data."})]}),n.length>0&&a.jsx("div",{className:"overflow-x-auto rounded-md border",children:a.jsxs("table",{className:"w-full min-w-[780px] text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b bg-muted/50 text-left text-xs uppercase text-muted-foreground",children:[a.jsx("th",{className:"px-4 py-3 font-medium",children:"AWS account"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Connection"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Scope"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Status"}),a.jsx("th",{className:"px-4 py-3 text-right font-medium",children:"Actions"})]})}),a.jsx("tbody",{children:n.map(O=>a.jsxs("tr",{className:`border-b last:border-0 ${y===O.connectionId?"bg-muted/30":""}`,children:[a.jsx("td",{className:"px-4 py-3 font-mono",children:O.managementAccountId||"Pending"}),a.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:O.connectionId}),a.jsxs("td",{className:"px-4 py-3",children:[O.accountScope," / ",O.regionMode]}),a.jsxs("td",{className:"px-4 py-3",children:[a.jsx("span",{className:`rounded-full border px-2 py-1 text-xs font-medium ${bm(O.status)}`,children:O.status.replace(/_/g," ")}),O.stackSetStatus&&a.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:O.stackSetStatus.replace(/_/g," ")})]}),a.jsx("td",{className:"px-4 py-3",children:a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{type:"button",onClick:()=>{L(O.connectionId)},disabled:!!N,className:"rounded-md border p-2 hover:bg-muted disabled:opacity-50",title:"Download CloudFormation template","aria-label":"Download CloudFormation template",children:N===`download-${O.connectionId}`?a.jsx(ct,{className:"h-4 w-4 animate-spin"}):a.jsx(fs,{className:"h-4 w-4"})}),a.jsx("a",{href:xm(O),target:"_blank",rel:"noreferrer",className:"rounded-md border p-2 hover:bg-muted",title:`Open AWS CloudFormation as ${O.stackName||`MeyiConnect-${O.connectionId}-Management`}`,"aria-label":"Open AWS CloudFormation",children:a.jsx(ci,{className:"h-4 w-4"})}),a.jsxs("button",{type:"button",onClick:()=>{A(O.connectionId)},disabled:!!N||O.status==="CONNECTED",className:"flex items-center gap-2 rounded-md border px-3 py-2 font-medium hover:bg-muted disabled:opacity-50",children:[N===`verify-${O.connectionId}`?a.jsx(ct,{className:"h-4 w-4 animate-spin"}):O.status==="CONNECTED"?a.jsx(Rf,{className:"h-4 w-4 text-emerald-600"}):a.jsx(Tt,{className:"h-4 w-4"}),O.status==="CONNECTED"?"Connected":"Verify"]}),a.jsx("button",{type:"button",onClick:()=>{m(!1),l(O)},disabled:!!N,className:"rounded-md border p-2 text-destructive hover:bg-destructive/10 disabled:opacity-50",title:"Remove Cost source","aria-label":"Remove Cost source",children:a.jsx(fi,{className:"h-4 w-4"})})]})})]},O.connectionId))})]})}),u&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",role:"dialog","aria-modal":"true","aria-labelledby":"add-source-title",children:a.jsxs("form",{onSubmit:O=>{k(O)},className:"w-full max-w-md rounded-md border bg-background p-5 shadow-xl",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("h2",{id:"add-source-title",className:"text-lg font-semibold",children:"Add AWS account"}),a.jsx("button",{type:"button",onClick:()=>f(!1),className:"rounded-md p-1 hover:bg-muted","aria-label":"Close",children:a.jsx(Lt,{className:"h-4 w-4"})})]}),a.jsx("label",{className:"mt-5 block text-sm font-medium",htmlFor:"aws-account-id",children:"AWS account ID"}),a.jsx("input",{id:"aws-account-id",value:g,onChange:O=>p(O.target.value.replace(/\D/g,"").slice(0,12)),inputMode:"numeric",autoComplete:"off",placeholder:"123456789012",className:"mt-2 h-10 w-full rounded-md border bg-background px-3 font-mono outline-none focus:ring-2 focus:ring-ring"}),a.jsxs("label",{className:"mt-4 flex items-start gap-3 rounded-md border p-3",children:[a.jsx("input",{type:"checkbox",checked:x,onChange:O=>b(O.target.checked),className:"mt-1 h-4 w-4"}),a.jsxs("span",{children:[a.jsx("span",{className:"block text-sm font-medium",children:"All enabled AWS regions"}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:"Use organization-wide StackSet deployment across enabled regions."})]})]}),a.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[a.jsx("button",{type:"button",onClick:()=>f(!1),className:"rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"}),a.jsxs("button",{type:"submit",disabled:N==="create"||g.length!==12,className:"flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50",children:[N==="create"&&a.jsx(ct,{className:"h-4 w-4 animate-spin"}),"Create source"]})]})]})}),d&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",role:"dialog","aria-modal":"true","aria-labelledby":"remove-source-title",children:a.jsxs("div",{className:"w-full max-w-md rounded-md border bg-background p-5 shadow-xl",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("h2",{id:"remove-source-title",className:"text-lg font-semibold",children:"Remove Cost source"}),a.jsx("button",{type:"button",onClick:()=>l(null),disabled:!!N,className:"rounded-md p-1 hover:bg-muted","aria-label":"Close",children:a.jsx(Lt,{className:"h-4 w-4"})})]}),a.jsxs("p",{className:"mt-4 text-sm",children:["Remove AWS account ",a.jsx("span",{className:"font-mono font-medium",children:d.managementAccountId})," from this tenant?"]}),a.jsxs("label",{className:"mt-4 flex items-start gap-3 rounded-md border border-destructive/30 p-3",children:[a.jsx("input",{type:"checkbox",checked:h,onChange:O=>m(O.target.checked),disabled:!!N,className:"mt-1 h-4 w-4"}),a.jsxs("span",{children:[a.jsx("span",{className:"block text-sm font-medium",children:"Also delete generated AWS resources"}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:"Deletes MeyiConnect StackSet instances, the StackSet, and the management stack before removing this source. CUR data already delivered to the central bucket is retained."})]})]}),a.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"If AWS cleanup fails, the source is preserved so you can retry or clean up manually."}),a.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[a.jsx("button",{type:"button",onClick:()=>l(null),disabled:!!N,className:"rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"}),a.jsxs("button",{type:"button",onClick:()=>{D()},disabled:!!N,className:"flex items-center gap-2 rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground disabled:opacity-50",children:[N===`remove-${d.connectionId}`&&a.jsx(ct,{className:"h-4 w-4 animate-spin"}),"Remove"]})]})]})})]})}const vm=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],wm=["UTC","Asia/Kolkata","America/New_York","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];function Sm({open:e,schedule:t,saving:n,onClose:r,onSave:s}){const[o,i]=P.useState(t);if(P.useEffect(()=>i(t),[t,e]),!e)return null;const c=u=>i(f=>({...f,frequency:u}));return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4",role:"presentation",onMouseDown:u=>{u.target===u.currentTarget&&r()},children:a.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"cost-ai-schedule-title",className:"w-full max-w-lg overflow-hidden rounded-lg border bg-background shadow-xl",children:[a.jsxs("div",{className:"flex items-start justify-between border-b px-5 py-4",children:[a.jsxs("div",{children:[a.jsxs("h2",{id:"cost-ai-schedule-title",className:"flex items-center gap-2 text-base font-semibold",children:[a.jsx(oi,{className:"h-4 w-4 text-primary"}),"AI report schedule"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Reports run automatically against completed AWS CUR periods."})]}),a.jsx("button",{type:"button",onClick:r,className:"rounded-md p-1.5 hover:bg-muted","aria-label":"Close",children:a.jsx(Lt,{className:"h-4 w-4"})})]}),a.jsxs("form",{className:"space-y-5 p-5",onSubmit:u=>{u.preventDefault(),s({enabled:o.enabled,frequency:o.frequency,time:o.time,timezone:o.timezone,dayOfWeek:o.dayOfWeek,dayOfMonth:o.dayOfMonth}).then(r)},children:[a.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-lg border p-3",children:[a.jsxs("span",{children:[a.jsx("span",{className:"block text-sm font-medium",children:"Scheduled reports"}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:"Generate reports without a manual action"})]}),a.jsx("input",{type:"checkbox",checked:o.enabled,onChange:u=>i(f=>({...f,enabled:u.target.checked})),className:"h-4 w-4 accent-primary"})]}),a.jsxs("fieldset",{disabled:!o.enabled||n,className:"space-y-5 disabled:opacity-60",children:[a.jsxs("div",{children:[a.jsx("span",{className:"mb-2 block text-sm font-medium",children:"Frequency"}),a.jsx("div",{className:"grid grid-cols-3 rounded-lg border p-1",children:["daily","weekly","monthly"].map(u=>a.jsx("button",{type:"button",onClick:()=>c(u),className:`rounded-md px-3 py-2 text-sm capitalize ${o.frequency===u?"bg-primary text-primary-foreground":"hover:bg-muted"}`,children:u},u))})]}),a.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.jsxs("label",{className:"text-sm font-medium",children:["Run time",a.jsx("input",{type:"time",required:!0,value:o.time,onChange:u=>i(f=>({...f,time:u.target.value})),className:"mt-2 block h-10 w-full rounded-lg border bg-background px-3 font-normal"})]}),a.jsxs("label",{className:"text-sm font-medium",children:["Timezone",a.jsx("select",{value:o.timezone,onChange:u=>i(f=>({...f,timezone:u.target.value})),className:"mt-2 block h-10 w-full rounded-lg border bg-background px-3 font-normal",children:[...new Set([o.timezone,...wm])].map(u=>a.jsx("option",{children:u},u))})]})]}),o.frequency==="weekly"&&a.jsxs("label",{className:"block text-sm font-medium",children:["Day of week",a.jsx("select",{value:o.dayOfWeek??1,onChange:u=>i(f=>({...f,dayOfWeek:Number(u.target.value)})),className:"mt-2 block h-10 w-full rounded-lg border bg-background px-3 font-normal",children:vm.map((u,f)=>a.jsx("option",{value:f,children:u},u))})]}),o.frequency==="monthly"&&a.jsxs("label",{className:"block text-sm font-medium",children:["Day of month",a.jsx("input",{type:"number",min:1,max:28,value:o.dayOfMonth??1,onChange:u=>i(f=>({...f,dayOfMonth:Number(u.target.value)})),className:"mt-2 block h-10 w-full rounded-lg border bg-background px-3 font-normal"})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Daily reports cover the previous day, weekly reports the previous seven complete days, and monthly reports the previous calendar month."})]}),a.jsxs("div",{className:"flex justify-end gap-2 border-t pt-4",children:[a.jsx("button",{type:"button",onClick:r,className:"rounded-lg border px-4 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:n,className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50",children:n?"Saving":"Save schedule"})]})]})]})})}function Ze(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e?.(s),n===!1||!s||!s.defaultPrevented)return t?.(s)}}function Lo(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Rm(...e){return t=>{let n=!1;const r=e.map(s=>{const o=Lo(s,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let s=0;s<r.length;s++){const o=r[s];typeof o=="function"?o():Lo(e[s],null)}}}}function bt(...e){return S.useCallback(Rm(...e),e)}function Nm(e,t=[]){let n=[];function r(o,i){const c=S.createContext(i);c.displayName=o+"Context";const u=n.length;n=[...n,i];const f=l=>{const{scope:h,children:m,...g}=l,p=h?.[e]?.[u]||c,x=S.useMemo(()=>g,Object.values(g));return a.jsx(p.Provider,{value:x,children:m})};f.displayName=o+"Provider";function d(l,h,m={}){const{optional:g=!1}=m,p=h?.[e]?.[u]||c,x=S.useContext(p);if(x)return x;if(i!==void 0)return i;if(!g)throw new Error(`\`${l}\` must be used within \`${o}\``)}return[f,d]}const s=()=>{const o=n.map(i=>S.createContext(i));return function(c){const u=c?.[e]||o;return S.useMemo(()=>({[`__scope${e}`]:{...c,[e]:u}}),[c,u])}};return s.scopeName=e,[r,Cm(s,...t)]}function Cm(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const i=r.reduce((c,{useScope:u,scopeName:f})=>{const l=u(o)[`__scope${f}`];return{...c,...l}},{});return S.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var sn=globalThis?.document?S.useLayoutEffect:()=>{},jm=S[" useId ".trim().toString()]||(()=>{}),Em=0;function Pr(e){const[t,n]=S.useState(jm());return sn(()=>{n(r=>r??String(Em++))},[e]),e||(t?`radix-${t}`:"")}var _m=S[" useInsertionEffect ".trim().toString()]||sn;function km({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[s,o,i]=Pm({defaultProp:t,onChange:n}),c=e!==void 0,u=c?e:s;{const d=S.useRef(e!==void 0);S.useEffect(()=>{const l=d.current;l!==c&&console.warn(`${r} is changing from ${l?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=c},[c,r])}const f=S.useCallback(d=>{if(c){const l=Am(d)?d(e):d;l!==e&&i.current?.(l)}else o(d)},[c,e,o,i]);return[u,f]}function Pm({defaultProp:e,onChange:t}){const[n,r]=S.useState(e),s=S.useRef(n),o=S.useRef(t);return _m(()=>{o.current=t},[t]),S.useEffect(()=>{s.current!==n&&(o.current?.(n),s.current=n)},[n,s]),[n,r,o]}function Am(e){return typeof e=="function"}function Li(e){const t=S.forwardRef((n,r)=>{let{children:s,...o}=n,i=null,c=!1;const u=[];Io(s)&&typeof Cn=="function"&&(s=Cn(s._payload)),S.Children.forEach(s,h=>{if(Mm(h)){c=!0;const m=h;let g="child"in m.props?m.props.child:m.props.children;Io(g)&&typeof Cn=="function"&&(g=Cn(g._payload)),i=Tm(m,g),u.push(i?.props?.children)}else u.push(h)}),i?i=S.cloneElement(i,void 0,u):!c&&S.Children.count(s)===1&&S.isValidElement(s)&&(i=s);const f=i?Im(i):void 0,d=bt(r,f);if(!i){if(s||s===0)throw new Error(c?$m(e):Um(e));return s}const l=Lm(o,i.props??{});return i.type!==S.Fragment&&(l.ref=r?d:f),S.cloneElement(i,l)});return t.displayName=`${e}.Slot`,t}var Om=Symbol.for("radix.slottable"),Tm=(e,t)=>{if("child"in e.props){const n=e.props.child;return S.isValidElement(n)?S.cloneElement(n,void 0,e.props.children(n.props.children)):null}return S.isValidElement(t)?t:null};function Lm(e,t){const n={...t};for(const r in t){const s=e[r],o=t[r];/^on[A-Z]/.test(r)?s&&o?n[r]=(...c)=>{const u=o(...c);return s(...c),u}:s&&(n[r]=s):r==="style"?n[r]={...s,...o}:r==="className"&&(n[r]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function Im(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Mm(e){return S.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Om}var Dm=Symbol.for("react.lazy");function Io(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Dm&&"_payload"in e&&Fm(e._payload)}function Fm(e){return typeof e=="object"&&e!==null&&"then"in e}var Um=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,$m=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,Cn=S[" use ".trim().toString()],Bm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],We=Bm.reduce((e,t)=>{const n=Li(`Primitive.${t}`),r=S.forwardRef((s,o)=>{const{asChild:i,...c}=s,u=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(u,{...c,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function zm(e,t){e&&Zo.flushSync(()=>e.dispatchEvent(t))}function on(e){const t=S.useRef(e);return S.useEffect(()=>{t.current=e}),S.useMemo(()=>((...n)=>t.current?.(...n)),[])}var Wm="DismissableLayer",Xr="dismissableLayer.update",Vm="dismissableLayer.pointerDownOutside",Hm="dismissableLayer.focusOutside",Mo,gs=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ii=S.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:c,onDismiss:u,...f}=e,d=S.useContext(gs),[l,h]=S.useState(null),m=l?.ownerDocument??globalThis?.document,[,g]=S.useState({}),p=bt(t,h),x=Array.from(d.layers),[b]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=b?x.indexOf(b):-1,v=l?x.indexOf(l):-1,N=d.layersWithOutsidePointerEventsDisabled.size>0,j=v>=y,_=S.useRef(!1),C=Jm(A=>{o?.(A),c?.(A),A.defaultPrevented||u?.()},{ownerDocument:m,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:_,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:S.useCallback(A=>{if(!(A instanceof Node))return!1;const D=[...d.branches].some(O=>O.contains(A));return j&&!D},[d.branches,j])}),R=Xm(A=>{if(r&&_.current)return;const D=A.target;[...d.branches].some($=>$.contains(D))||(i?.(A),c?.(A),A.defaultPrevented||u?.())},m),k=l?v===x.length-1:!1,L=on(A=>{A.key==="Escape"&&(s?.(A),!A.defaultPrevented&&u&&(A.preventDefault(),u()))});return S.useEffect(()=>{if(k)return m.addEventListener("keydown",L,{capture:!0}),()=>m.removeEventListener("keydown",L,{capture:!0})},[m,k,L]),S.useEffect(()=>{if(l)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(Mo=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(l)),d.layers.add(l),Do(),()=>{n&&(d.layersWithOutsidePointerEventsDisabled.delete(l),d.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=Mo))}},[l,m,n,d]),S.useEffect(()=>()=>{l&&(d.layers.delete(l),d.layersWithOutsidePointerEventsDisabled.delete(l),Do())},[l,d]),S.useEffect(()=>{const A=()=>g({});return document.addEventListener(Xr,A),()=>document.removeEventListener(Xr,A)},[]),a.jsx(We.div,{...f,ref:p,style:{pointerEvents:N?j?"auto":"none":void 0,...e.style},onFocusCapture:Ze(e.onFocusCapture,R.onFocusCapture),onBlurCapture:Ze(e.onBlurCapture,R.onBlurCapture),onPointerDownCapture:Ze(e.onPointerDownCapture,C.onPointerDownCapture)})});Ii.displayName=Wm;var qm="DismissableLayerBranch",Gm=S.forwardRef((e,t)=>{const n=S.useContext(gs),r=S.useRef(null),s=bt(t,r);return S.useEffect(()=>{const o=r.current;if(o)return n.branches.add(o),()=>{n.branches.delete(o)}},[n.branches]),a.jsx(We.div,{...e,ref:s})});Gm.displayName=qm;function Km(){const e=S.useContext(gs),[t,n]=S.useState(null);return S.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}var Ym=()=>!0;function Jm(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:s,dismissableSurfaces:o,shouldHandlePointerDownOutside:i=Ym}=t,c=on(e),u=S.useRef(!1),f=S.useRef(!1),d=S.useRef(new Map),l=S.useRef(()=>{});return S.useEffect(()=>{function h(){f.current=!1,s.current=!1,d.current.clear()}function m(){return Array.from(d.current.values()).some(Boolean)}function g(v){if(!f.current)return;const N=v.target;N instanceof Node&&[...o].some(_=>_.contains(N))||d.current.set(v.type,!0),v.type==="click"&&window.setTimeout(()=>{f.current&&l.current()},0)}function p(v){f.current&&d.current.set(v.type,!1)}const x=v=>{if(v.target&&!u.current){let N=function(){n.removeEventListener("click",l.current);const _=m();h(),_||Mi(Vm,c,j,{discrete:!0})};if(!i(v.target)){n.removeEventListener("click",l.current),h(),u.current=!1;return}const j={originalEvent:v};f.current=!0,s.current=r&&v.button===0,d.current.clear(),!r||v.button!==0?N():(n.removeEventListener("click",l.current),l.current=N,n.addEventListener("click",l.current,{once:!0}))}else n.removeEventListener("click",l.current),h();u.current=!1},b=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const v of b)n.addEventListener(v,g,!0),n.addEventListener(v,p);const y=window.setTimeout(()=>{n.addEventListener("pointerdown",x)},0);return()=>{window.clearTimeout(y),n.removeEventListener("pointerdown",x),n.removeEventListener("click",l.current);for(const v of b)n.removeEventListener(v,g,!0),n.removeEventListener(v,p)}},[n,c,r,s,o,i]),{onPointerDownCapture:()=>u.current=!0}}function Xm(e,t=globalThis?.document){const n=on(e),r=S.useRef(!1);return S.useEffect(()=>{const s=o=>{o.target&&!r.current&&Mi(Hm,n,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Do(){const e=new CustomEvent(Xr);document.dispatchEvent(e)}function Mi(e,t,n,{discrete:r}){const s=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?zm(s,o):s.dispatchEvent(o)}var Ar="focusScope.autoFocusOnMount",Or="focusScope.autoFocusOnUnmount",Fo={bubbles:!1,cancelable:!0},Zm="FocusScope",Di=S.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:o,...i}=e,[c,u]=S.useState(null),f=on(s),d=on(o),l=S.useRef(null),h=bt(t,u),m=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(r){let p=function(v){if(m.paused||!c)return;const N=v.target;c.contains(N)?l.current=N:qe(l.current,{select:!0})},x=function(v){if(m.paused||!c)return;const N=v.relatedTarget;N!==null&&(c.contains(N)||qe(l.current,{select:!0}))},b=function(v){if(document.activeElement===document.body)for(const j of v)j.removedNodes.length>0&&qe(c)};document.addEventListener("focusin",p),document.addEventListener("focusout",x);const y=new MutationObserver(b);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",x),y.disconnect()}}},[r,c,m.paused]),S.useEffect(()=>{if(c){$o.add(m);const p=document.activeElement;if(!c.contains(p)){const b=new CustomEvent(Ar,Fo);c.addEventListener(Ar,f),c.dispatchEvent(b),b.defaultPrevented||(Qm(sp(Fi(c)),{select:!0}),document.activeElement===p&&qe(c))}return()=>{c.removeEventListener(Ar,f),setTimeout(()=>{const b=new CustomEvent(Or,Fo);c.addEventListener(Or,d),c.dispatchEvent(b),b.defaultPrevented||qe(p??document.body,{select:!0}),c.removeEventListener(Or,d),$o.remove(m)},0)}}},[c,f,d,m]);const g=S.useCallback(p=>{if(!n&&!r||m.paused)return;const x=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,b=document.activeElement;if(x&&b){const y=p.currentTarget,[v,N]=ep(y);v&&N?!p.shiftKey&&b===N?(p.preventDefault(),n&&qe(v,{select:!0})):p.shiftKey&&b===v&&(p.preventDefault(),n&&qe(N,{select:!0})):b===y&&p.preventDefault()}},[n,r,m.paused]);return a.jsx(We.div,{tabIndex:-1,...i,ref:h,onKeyDown:g})});Di.displayName=Zm;function Qm(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(qe(r,{select:t}),document.activeElement!==n)return}function ep(e){const t=Fi(e),n=Uo(t,e),r=Uo(t.reverse(),e);return[n,r]}function Fi(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Uo(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):tp(r,{upTo:t})))return r}function tp(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function np(e){return e instanceof HTMLInputElement&&"select"in e}function qe(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&np(e)&&t&&e.select()}}var $o=rp();function rp(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Bo(e,t),e.unshift(t)},remove(t){e=Bo(e,t),e[0]?.resume()}}}function Bo(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function sp(e){return e.filter(t=>t.tagName!=="A")}var op="Portal",Ui=S.forwardRef((e,t)=>{const{container:n,...r}=e,[s,o]=S.useState(!1);sn(()=>o(!0),[]);const i=n||s&&globalThis?.document?.body;return i?Zo.createPortal(a.jsx(We.div,{...r,ref:t}),i):null});Ui.displayName=op;function ap(e,t){return S.useReducer((n,r)=>t[n][r]??n,e)}var ir=e=>{const{present:t,children:n}=e,r=ip(t),s=typeof n=="function"?n({present:r.isPresent}):S.Children.only(n),o=cp(r.ref,lp(s));return typeof n=="function"||r.isPresent?S.cloneElement(s,{ref:o}):null};ir.displayName="Presence";function ip(e){const[t,n]=S.useState(),r=S.useRef(null),s=S.useRef(e),o=S.useRef("none"),i=S.useRef(void 0),c=e?"mounted":"unmounted",[u,f]=ap(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return S.useEffect(()=>{u==="mounted"?(o.current=i.current??Xt(r.current),i.current=void 0):o.current="none"},[u]),sn(()=>{const d=r.current,l=s.current;if(l!==e){const m=o.current,g=Xt(d);e?(i.current=g,f("MOUNT")):g==="none"||d?.display==="none"?f("UNMOUNT"):f(l&&m!==g?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,f]),sn(()=>{if(t){let d;const l=t.ownerDocument.defaultView??window,h=g=>{const x=Xt(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&x&&(f("ANIMATION_END"),!s.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",d=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},m=g=>{g.target===t&&(o.current=Xt(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{l.clearTimeout(d),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else f("ANIMATION_END")},[t,f]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:S.useCallback(d=>{if(d){const l=getComputedStyle(d);r.current=l,i.current=Xt(l)}else r.current=null;n(d)},[])}}function zo(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function cp(...e){const t=S.useRef(e);return t.current=e,S.useCallback(n=>{const r=t.current;let s=!1;const o=r.map(i=>{const c=zo(i,n);return!s&&typeof c=="function"&&(s=!0),c});if(s)return()=>{for(let i=0;i<o.length;i++){const c=o[i];typeof c=="function"?c():zo(r[i],null)}}},[])}function Xt(e){return e?.animationName||"none"}function lp(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var jn=0,wt=null;function up(){S.useEffect(()=>{wt||(wt={start:Wo(),end:Wo()});const{start:e,end:t}=wt;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),jn++,()=>{jn===1&&(wt?.start.remove(),wt?.end.remove(),wt=null),jn=Math.max(0,jn-1)}},[])}function Wo(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var De=function(){return De=Object.assign||function(t){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},De.apply(this,arguments)};function $i(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n}function dp(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,o;r<s;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var Fn="right-scroll-bar-position",Un="width-before-scroll-bar",fp="with-scroll-bars-hidden",hp="--removed-body-scroll-bar-size";function Tr(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function mp(e,t){var n=P.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=t,n.facade}var pp=typeof window<"u"?S.useLayoutEffect:S.useEffect,Vo=new WeakMap;function gp(e,t){var n=mp(null,function(r){return e.forEach(function(s){return Tr(s,r)})});return pp(function(){var r=Vo.get(n);if(r){var s=new Set(r),o=new Set(e),i=n.current;s.forEach(function(c){o.has(c)||Tr(c,null)}),o.forEach(function(c){s.has(c)||Tr(c,i)})}Vo.set(n,e)},[e]),n}function xp(e){return e}function bp(e,t){t===void 0&&(t=xp);var n=[],r=!1,s={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(o){var i=t(o,r);return n.push(i),function(){n=n.filter(function(c){return c!==i})}},assignSyncMedium:function(o){for(r=!0;n.length;){var i=n;n=[],i.forEach(o)}n={push:function(c){return o(c)},filter:function(){return n}}},assignMedium:function(o){r=!0;var i=[];if(n.length){var c=n;n=[],c.forEach(o),i=n}var u=function(){var d=i;i=[],d.forEach(o)},f=function(){return Promise.resolve().then(u)};f(),n={push:function(d){i.push(d),f()},filter:function(d){return i=i.filter(d),n}}}};return s}function yp(e){e===void 0&&(e={});var t=bp(null);return t.options=De({async:!0,ssr:!1},e),t}var Bi=function(e){var t=e.sideCar,n=$i(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return S.createElement(r,De({},n))};Bi.isSideCarExport=!0;function vp(e,t){return e.useMedium(t),Bi}var zi=yp(),Lr=function(){},cr=S.forwardRef(function(e,t){var n=S.useRef(null),r=S.useState({onScrollCapture:Lr,onWheelCapture:Lr,onTouchMoveCapture:Lr}),s=r[0],o=r[1],i=e.forwardProps,c=e.children,u=e.className,f=e.removeScrollBar,d=e.enabled,l=e.shards,h=e.sideCar,m=e.noRelative,g=e.noIsolation,p=e.inert,x=e.allowPinchZoom,b=e.as,y=b===void 0?"div":b,v=e.gapMode,N=$i(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=h,_=gp([n,t]),C=De(De({},N),s);return S.createElement(S.Fragment,null,d&&S.createElement(j,{sideCar:zi,removeScrollBar:f,shards:l,noRelative:m,noIsolation:g,inert:p,setCallbacks:o,allowPinchZoom:!!x,lockRef:n,gapMode:v}),i?S.cloneElement(S.Children.only(c),De(De({},C),{ref:_})):S.createElement(y,De({},C,{className:u,ref:_}),c))});cr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};cr.classNames={fullWidth:Un,zeroRight:Fn};var wp=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Sp(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=wp();return t&&e.setAttribute("nonce",t),e}function Rp(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Np(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Cp=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Sp())&&(Rp(t,n),Np(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},jp=function(){var e=Cp();return function(t,n){S.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Wi=function(){var e=jp(),t=function(n){var r=n.styles,s=n.dynamic;return e(r,s),null};return t},Ep={left:0,top:0,right:0,gap:0},Ir=function(e){return parseInt(e||"",10)||0},_p=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[Ir(n),Ir(r),Ir(s)]},kp=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ep;var t=_p(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Pp=Wi(),kt="data-scroll-locked",Ap=function(e,t,n,r){var s=e.left,o=e.top,i=e.right,c=e.gap;return n===void 0&&(n="margin"),`
21
+ `),d=`${s}-summary-report-${Date.now()}.csv`);const l=document.createElement("a");l.href=URL.createObjectURL(new Blob([f],{type:"text/csv"})),l.download=d,l.click(),URL.revokeObjectURL(l.href)}async function fm(e){const{report:t,comparison:n,rows:r,groupBy:s,mode:o,start:i,end:c,granularity:u}=e,f=ht[s],[{jsPDF:d},{default:l}]=await Promise.all([Promise.resolve().then(()=>require("./jspdf.es.min-C10id8ME.cjs")).then(p=>p.jspdf_es_min),Promise.resolve().then(()=>require("./jspdf.plugin.autotable-CvTok6mL.cjs"))]),h=new d({orientation:"landscape",unit:"pt",format:"a4"}),m=(p,x,b)=>{h.setFontSize(7),h.setTextColor(100),h.text(`Report generated · All costs in ${t.currency} · ${x} to ${b}`,40,h.internal.pageSize.height-18),h.text(`Page ${p.pageNumber}`,h.internal.pageSize.width-70,h.internal.pageSize.height-18)};if(o==="compare"&&n){h.setFontSize(18),h.setTextColor(25),h.text("Comparison Report",40,42),h.setFontSize(9),h.setTextColor(98,86,230),h.text("TOTAL COST",40,66),h.setTextColor(40),h.text(`Previous Cost: ${n.previous.totalCost}`,40,82),h.text(`Current Cost: ${n.current.totalCost}`,220,82),h.text(`Granularity: ${u}`,400,82),l(h,{startY:100,head:[[`${f.item} Name`,"Current Cost","Previous Cost","Current Period","Previous Period","Change %","Current Accounts","Previous Accounts","Current Regions","Previous Regions"]],body:r.map(p=>[p.label,p.current?.amount?.toFixed(2)||"0.00",p.previous?.amount?.toFixed(2)||"0.00",It(n.currentStart,n.currentEnd,u),It(n.previousStart,n.previousEnd,u),`${p.change.toFixed(4)}%`,rt(p.current?.accounts),rt(p.previous?.accounts),rt(p.current?.regions),rt(p.previous?.regions)]),styles:{fontSize:6,cellPadding:3,overflow:"linebreak"},headStyles:{fillColor:[242,237,255],textColor:[82,35,190]},didDrawPage:p=>m(p,n.previousStart,n.currentEnd),margin:{bottom:32}}),h.save(`comparison-report-${s}-${Date.now()}.pdf`);return}h.setFontSize(18),h.setTextColor(25),h.text(f.pdfTitle,40,42),h.setFontSize(9),h.setTextColor(98,86,230),h.text("REPORT METADATA",40,66),h.setTextColor(40),h.text(`Tenant ID: ${t.tenantId||"Current tenant"}`,40,82),h.text(`Date Range: ${i} to ${c}`,40,97),h.text(`Accrued Total Cost: ${X(t.totalCost,t.currency)}`,40,112),h.setTextColor(98,86,230),h.text("COST SUMMARY BREAKDOWN",40,136);const g=s==="account";l(h,{startY:146,head:[g?["Account ID","Account Name","Total Cost","Percentage","Regions"]:[`${f.item} Name`,"Total Cost","Percentage","Accounts","Regions"]],body:t.summary.map(p=>g?[p.accountId||p.key||"—",p.label,X(p.amount,t.currency),`${(p.percentage||0).toFixed(2)}%`,rt(p.regions)]:[p.label,X(p.amount,t.currency),`${(p.percentage||0).toFixed(2)}%`,rt(p.accounts),rt(p.regions)]),styles:{fontSize:7,cellPadding:4,overflow:"linebreak"},headStyles:{fillColor:[242,237,255],textColor:[82,35,190]},didDrawPage:p=>m(p,i,c),margin:{bottom:32}}),h.save(`${s}-summary-report-${Date.now()}.pdf`)}function hm(){const e=um(),{groupBy:t,mode:n,report:r,comparison:s,comparedRows:o,loading:i,error:c,dataStatus:u,granularity:f,start:d,end:l}=e,h=ht[t],m=r?.summary[0],g=s?s.current.totalCost-s.previous.totalCost:0,p=s?.previous.totalCost?g/Math.abs(s.previous.totalCost)*100:0,x=r?{report:r,comparison:s,rows:o,groupBy:t,mode:n,start:d,end:l,granularity:f}:null,b=a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>x&&void fm(x),disabled:!x||i,className:"flex items-center gap-2 rounded-md border bg-card px-3 py-1.5 text-sm disabled:opacity-50",children:[a.jsx(Of,{className:"h-4 w-4"}),"PDF"]}),a.jsxs("button",{onClick:()=>x&&dm(x),disabled:!x||i,className:"flex items-center gap-2 rounded-md border bg-card px-3 py-1.5 text-sm disabled:opacity-50",children:[a.jsx(fs,{className:"h-4 w-4"}),"CSV"]})]});return a.jsxs("div",{className:"flex w-full flex-col gap-5 p-2 md:p-6",children:[a.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold",children:[a.jsx(li,{className:"h-6 w-6 text-primary"}),"Cost reports"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Analyse live AWS cost by service, linked account, region, resource, or cost allocation tag"})]}),a.jsx(ar,{})]}),!i&&(u&&!u.ready||c&&!u)?a.jsx(Zn,{status:u,error:c}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex gap-1 overflow-x-auto border-b",children:Object.keys(ht).map(y=>a.jsx("button",{onClick:()=>e.changeGroup(y),className:`border-b-2 px-4 py-3 text-sm font-medium ${t===y?"border-primary text-primary":"border-transparent text-muted-foreground"}`,children:ht[y].tab},y))}),a.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1fr)_320px]",children:[a.jsxs("div",{className:"space-y-5",children:[c&&a.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:[a.jsx(ze,{className:"h-4 w-4"}),c]}),i?a.jsx(rm,{}):n==="compare"&&s?a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:"rounded-xl bg-primary/5 p-4",children:[a.jsxs("div",{className:"mb-4 flex flex-wrap items-start justify-between gap-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-sm font-semibold",children:"Comparison Cost Summary"}),a.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Updated On: ",Po(s.current.updatedAt)]})]}),b]}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[a.jsx(Me,{label:"Period accrued total",value:`${X(s.current.totalCost,s.current.currency)} vs ${X(s.previous.totalCost,s.previous.currency)}`,helper:`${p>=0?"+":""}${p.toFixed(1)}% from previous period`,trend:p}),a.jsx(Me,{label:It(s.currentStart,s.currentEnd,f),value:X(s.current.totalCost,s.current.currency),helper:"Current period spending"}),a.jsx(Me,{label:It(s.previousStart,s.previousEnd,f),value:X(s.previous.totalCost,s.previous.currency),helper:"Previous period spending"}),a.jsx(Me,{label:f==="monthly"?"Monthly change":"Period change",value:`${g>=0?"+":""}${X(g,s.current.currency)}`,helper:`${p>=0?"+":""}${p.toFixed(1)}% from previous period`,trend:g})]})]}),a.jsx(nm,{rows:o,currency:s.current.currency}),a.jsx(cm,{rows:o,groupBy:t,comparison:s,granularity:f})]}):r?a.jsxs(a.Fragment,{children:[r.message&&a.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-muted/50 p-3 text-sm text-muted-foreground",children:[a.jsx(ze,{className:"h-4 w-4"}),r.message]}),a.jsxs("section",{className:"rounded-xl bg-primary/5 p-4",children:[a.jsxs("div",{className:"mb-4 flex flex-wrap items-start justify-between gap-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-sm font-semibold",children:h.title}),a.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Updated On: ",Po(r.updatedAt)]})]}),b]}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[a.jsx(Me,{label:"Accrued cost",value:X(r.totalCost,r.currency)}),a.jsx(Me,{label:h.top,value:m?X(m.amount,r.currency):"-",accent:!0}),a.jsx(Me,{label:h.count,value:String(r.count||0),accent:!0})]})]}),a.jsxs(ue,{children:[a.jsx(Re,{children:a.jsx(Pe,{className:"text-sm",children:"Cost Trend"})}),a.jsx(de,{children:a.jsx(tm,{timeline:r.timeline||[],currency:r.currency||"USD",daily:f==="daily"})})]}),a.jsx(im,{groupBy:t,report:r})]}):null]}),a.jsx(lm,{mode:n,groupBy:t,start:d,end:l,granularity:f,reportTagKey:e.reportTagKey,options:e.options,filters:e.draftFilters,loading:i,filtersLoading:e.filtersLoading,comparisonPeriods:e.selectedComparisonPeriods,onModeChange:e.changeMode,onStartChange:e.setStart,onEndChange:e.setEnd,onGranularityChange:e.setGranularity,onReportTagKeyChange:e.setReportTagKey,onFiltersChange:e.setDraftFilters,onLoadTagValues:y=>{e.loadOptions(y)},onRun:e.runReport,onApply:e.applyFilters,onReset:e.resetFilters})]})]})]})}const To={READY:"bg-emerald-500/10 text-emerald-600 border-emerald-500/30",RUNNING:"bg-blue-500/10 text-blue-600 border-blue-500/30",WAITING_FOR_DATA:"bg-amber-500/10 text-amber-600 border-amber-500/30",WAITING_FOR_TABLE:"bg-amber-500/10 text-amber-600 border-amber-500/30",FAILED:"bg-destructive/10 text-destructive border-destructive/30",PENDING:"bg-muted text-muted-foreground border-border"},mm={INFO:"text-muted-foreground",WARN:"text-amber-600",ERROR:"text-destructive"},Nn=e=>e?new Date(e).toLocaleString():"—";function pm({status:e}){return a.jsx("span",{className:`rounded-full border px-2 py-0.5 text-xs font-medium ${To[e]||To.PENDING}`,children:e.replace(/_/g," ")})}function Ue({label:e,value:t,mono:n}){return a.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.jsx("span",{className:"text-xs text-muted-foreground",children:e}),a.jsx("span",{className:`break-all text-sm ${n?"font-mono text-xs":""}`,children:t||"—"})]})}function gm(){const{managementAccountId:e,loading:t}=$t(),[n,r]=P.useState([]),[s,o]=P.useState([]),[i,c]=P.useState(!0),[u,f]=P.useState(null),d=P.useCallback(async()=>{c(!0),f(null);try{const l=await ne.get("/cur-discovery",{params:{logLimit:100,managementAccountId:e}});r(l.data?.jobs||[]),o(l.data?.logs||[])}catch(l){f(l?.response?.data?.error||l?.message||"Unable to load CUR discovery status")}finally{c(!1)}},[e]);return P.useEffect(()=>{t||d()},[d,t]),a.jsxs("div",{className:"flex w-full flex-col gap-6 p-2 md:p-6",children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold",children:[a.jsx(hs,{className:"h-6 w-6 text-primary"}),"CUR Discovery"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Progress of the scheduled job that locates this tenant’s Cost and Usage Report table. Cost data becomes available after it reports Ready."})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(ar,{}),a.jsx("button",{onClick:()=>{d()},disabled:i||t,className:"rounded-lg border p-2 hover:bg-muted disabled:opacity-50","aria-label":"Refresh",children:a.jsx(Tt,{className:`h-4 w-4 ${i||t?"animate-spin":""}`})})]})]}),u&&a.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:[a.jsx(ze,{className:"h-4 w-4"}),u]}),!i&&!u&&!n.length&&a.jsx(ue,{children:a.jsx(de,{className:"py-10 text-center text-sm text-muted-foreground",children:"No discovery job exists for this tenant yet. One is created automatically once the AWS connection is verified and the Cost plugin is entitled."})}),n.map(l=>a.jsxs(ue,{children:[a.jsxs(Re,{className:"flex flex-row flex-wrap items-center gap-3",children:[a.jsx(ai,{className:"h-4 w-4 text-primary"}),a.jsxs(Pe,{className:"text-sm",children:["Management account ",l.managementAccountId]}),a.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["connection ",l.connectionId]}),a.jsx(pm,{status:l.status}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:["attempt ",l.attemptCount]}),a.jsxs("span",{className:"ms-auto text-xs text-muted-foreground",children:["next check ",Nn(l.nextRunAt)]})]}),a.jsxs(de,{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[a.jsx(Ue,{label:"Source",value:l.curS3Uri||`s3://${l.bucket}/${l.prefix}`,mono:!0}),a.jsx(Ue,{label:"Tenant partition",value:l.tenantPartition,mono:!0}),a.jsx(Ue,{label:"Region",value:l.region}),a.jsx(Ue,{label:"Glue database",value:l.database,mono:!0}),a.jsx(Ue,{label:"Discovered table",value:l.table,mono:!0}),a.jsx(Ue,{label:"Table location",value:l.tableLocation,mono:!0}),a.jsx(Ue,{label:"Sample object",value:l.sampleObjectKey,mono:!0}),a.jsx(Ue,{label:"Last data",value:Nn(l.lastDataAt)}),a.jsx(Ue,{label:"Last checked",value:Nn(l.lastFinishedAt||l.lastStartedAt)}),l.lastError&&a.jsx("div",{className:"md:col-span-2 lg:col-span-3 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:l.lastError})]})]},l.id)),n.length>0&&a.jsxs("section",{children:[a.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"Recent activity"}),a.jsx("div",{className:"space-y-2",children:n.map(l=>{const h=s.filter(m=>m.jobId===l.id);return a.jsxs("details",{open:!0,className:"rounded-md border bg-card",children:[a.jsxs("summary",{className:"cursor-pointer px-4 py-3 text-sm font-medium",children:["Management account ",a.jsx("span",{className:"font-mono",children:l.managementAccountId})]}),a.jsx("div",{className:"border-t px-4 py-2",children:h.length?a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b text-left text-xs uppercase text-muted-foreground",children:[a.jsx("th",{className:"py-2 pe-4 font-medium",children:"Time"}),a.jsx("th",{className:"py-2 pe-4 font-medium",children:"Level"}),a.jsx("th",{className:"py-2 pe-4 font-medium",children:"Event"}),a.jsx("th",{className:"py-2 font-medium",children:"Message"})]})}),a.jsx("tbody",{children:h.map(m=>a.jsxs("tr",{className:"border-b last:border-0 align-top",children:[a.jsx("td",{className:"whitespace-nowrap py-2 pe-4 text-xs text-muted-foreground",children:Nn(m.createdAt)}),a.jsx("td",{className:`py-2 pe-4 text-xs font-medium ${mm[m.level]||""}`,children:m.level}),a.jsx("td",{className:"whitespace-nowrap py-2 pe-4 font-mono text-xs",children:m.event}),a.jsx("td",{className:"py-2",children:m.message})]},m.id))})]})}):a.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"No log entries recorded yet."})})]},l.id)})})]})]})}const xm=e=>e.launchUrl||`https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create?stackName=${encodeURIComponent(e.stackName||`MeyiConnect-${e.connectionId}-Management`)}`,bm=e=>e==="CONNECTED"?"border-emerald-500/30 bg-emerald-500/10 text-emerald-600":e==="FAILED"?"border-destructive/30 bg-destructive/10 text-destructive":"border-amber-500/30 bg-amber-500/10 text-amber-700",Jt=e=>{const t=e?.response?.data?.error||e?.response?.data?.message||e?.message||"Request failed",n=e?.response?.data?.details;return n?`${t} ${n}`:t};function ym(){const{selectManagementAccount:e,refreshSources:t}=$t(),[n,r]=P.useState([]),[s,o]=P.useState(!1),[i,c]=P.useState(!0),[u,f]=P.useState(!1),[d,l]=P.useState(null),[h,m]=P.useState(!1),[g,p]=P.useState(""),[x,b]=P.useState(!1),[y,v]=P.useState(null),[N,j]=P.useState(null),[_,C]=P.useState(null),R=P.useCallback(async()=>{c(!0),C(null);try{const O=await oe.getSources();r(O.sources||[]),o(O.allowMultipleSources===!0)}catch(O){C(Jt(O))}finally{c(!1)}},[]);P.useEffect(()=>{R()},[R]);const k=async O=>{if(O.preventDefault(),!/^\d{12}$/.test(g)){C("AWS account ID must contain exactly 12 digits");return}j("create"),C(null);try{const $=await oe.createSource({managementAccountId:g,regionMode:x?"ALL":"SINGLE"});$.managementAccountId&&e($.managementAccountId),await t(),v($.connectionId),f(!1),p(""),b(!1),await R()}catch($){C(Jt($))}finally{j(null)}},L=async O=>{j(`download-${O}`),C(null);try{const $=await oe.downloadSourceTemplate(O),J=URL.createObjectURL($),Y=document.createElement("a");Y.href=J,Y.download=`meyi-connect-cost-${O}.yaml`,Y.click(),URL.revokeObjectURL(J),v(O)}catch($){C(Jt($))}finally{j(null)}},A=async O=>{j(`verify-${O}`),C(null);try{const $=await oe.verifySource(O);$.status==="FAILED"&&C($.message||"AWS connection verification failed"),await R()}catch($){C(Jt($))}finally{j(null)}},D=async()=>{if(d){j(`remove-${d.connectionId}`),C(null);try{await oe.removeSource(d.connectionId,h),l(null),m(!1),await R(),await t()}catch(O){C(Jt(O))}finally{j(null)}}};return a.jsxs("div",{className:"flex w-full flex-col gap-6 p-2 md:p-6",children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold",children:[a.jsx(Jn,{className:"h-6 w-6 text-primary"}),"Cost Sources"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"AWS accounts connected to this tenant for Cost and Usage Report data."})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{type:"button",onClick:()=>{R()},disabled:i,className:"rounded-md border p-2 hover:bg-muted disabled:opacity-50","aria-label":"Refresh sources",title:"Refresh sources",children:a.jsx(Tt,{className:`h-4 w-4 ${i?"animate-spin":""}`})}),(s||n.length===0)&&a.jsxs("button",{type:"button",onClick:()=>{C(null),f(!0)},className:"flex items-center gap-2 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:opacity-90",children:[a.jsx($f,{className:"h-4 w-4"}),"Add AWS account"]})]})]}),_&&a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:[a.jsx(ze,{className:"mt-0.5 h-4 w-4 shrink-0"}),_]}),!i&&n.length===0&&a.jsxs("div",{className:"rounded-md border border-dashed py-14 text-center",children:[a.jsx(Jn,{className:"mx-auto mb-3 h-8 w-8 text-muted-foreground"}),a.jsx("p",{className:"font-medium",children:"No AWS Cost source"}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Add an AWS account to begin collecting tenant cost data."})]}),n.length>0&&a.jsx("div",{className:"overflow-x-auto rounded-md border",children:a.jsxs("table",{className:"w-full min-w-[780px] text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b bg-muted/50 text-left text-xs uppercase text-muted-foreground",children:[a.jsx("th",{className:"px-4 py-3 font-medium",children:"AWS account"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Connection"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Scope"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Status"}),a.jsx("th",{className:"px-4 py-3 text-right font-medium",children:"Actions"})]})}),a.jsx("tbody",{children:n.map(O=>a.jsxs("tr",{className:`border-b last:border-0 ${y===O.connectionId?"bg-muted/30":""}`,children:[a.jsx("td",{className:"px-4 py-3 font-mono",children:O.managementAccountId||"Pending"}),a.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:O.connectionId}),a.jsxs("td",{className:"px-4 py-3",children:[O.accountScope," / ",O.regionMode]}),a.jsxs("td",{className:"px-4 py-3",children:[a.jsx("span",{className:`rounded-full border px-2 py-1 text-xs font-medium ${bm(O.status)}`,children:O.status.replace(/_/g," ")}),O.stackSetStatus&&a.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:O.stackSetStatus.replace(/_/g," ")}),O.status==="FAILED"&&O.failureReason&&a.jsx("div",{className:"mt-1 max-w-md text-xs text-destructive",children:O.failureReason})]}),a.jsx("td",{className:"px-4 py-3",children:a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{type:"button",onClick:()=>{L(O.connectionId)},disabled:!!N,className:"rounded-md border p-2 hover:bg-muted disabled:opacity-50",title:"Download CloudFormation template","aria-label":"Download CloudFormation template",children:N===`download-${O.connectionId}`?a.jsx(ct,{className:"h-4 w-4 animate-spin"}):a.jsx(fs,{className:"h-4 w-4"})}),a.jsx("a",{href:xm(O),target:"_blank",rel:"noreferrer",className:"rounded-md border p-2 hover:bg-muted",title:`Open AWS CloudFormation as ${O.stackName||`MeyiConnect-${O.connectionId}-Management`}`,"aria-label":"Open AWS CloudFormation",children:a.jsx(ci,{className:"h-4 w-4"})}),a.jsxs("button",{type:"button",onClick:()=>{A(O.connectionId)},disabled:!!N||O.status==="CONNECTED",className:"flex items-center gap-2 rounded-md border px-3 py-2 font-medium hover:bg-muted disabled:opacity-50",children:[N===`verify-${O.connectionId}`?a.jsx(ct,{className:"h-4 w-4 animate-spin"}):O.status==="CONNECTED"?a.jsx(Rf,{className:"h-4 w-4 text-emerald-600"}):a.jsx(Tt,{className:"h-4 w-4"}),O.status==="CONNECTED"?"Connected":"Verify"]}),a.jsx("button",{type:"button",onClick:()=>{m(!1),l(O)},disabled:!!N,className:"rounded-md border p-2 text-destructive hover:bg-destructive/10 disabled:opacity-50",title:"Remove Cost source","aria-label":"Remove Cost source",children:a.jsx(fi,{className:"h-4 w-4"})})]})})]},O.connectionId))})]})}),u&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",role:"dialog","aria-modal":"true","aria-labelledby":"add-source-title",children:a.jsxs("form",{onSubmit:O=>{k(O)},className:"w-full max-w-md rounded-md border bg-background p-5 shadow-xl",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("h2",{id:"add-source-title",className:"text-lg font-semibold",children:"Add AWS account"}),a.jsx("button",{type:"button",onClick:()=>f(!1),className:"rounded-md p-1 hover:bg-muted","aria-label":"Close",children:a.jsx(Lt,{className:"h-4 w-4"})})]}),a.jsx("label",{className:"mt-5 block text-sm font-medium",htmlFor:"aws-account-id",children:"AWS account ID"}),a.jsx("input",{id:"aws-account-id",value:g,onChange:O=>p(O.target.value.replace(/\D/g,"").slice(0,12)),inputMode:"numeric",autoComplete:"off",placeholder:"123456789012",className:"mt-2 h-10 w-full rounded-md border bg-background px-3 font-mono outline-none focus:ring-2 focus:ring-ring"}),a.jsxs("label",{className:"mt-4 flex items-start gap-3 rounded-md border p-3",children:[a.jsx("input",{type:"checkbox",checked:x,onChange:O=>b(O.target.checked),className:"mt-1 h-4 w-4"}),a.jsxs("span",{children:[a.jsx("span",{className:"block text-sm font-medium",children:"All enabled AWS regions"}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:"Use organization-wide StackSet deployment across enabled regions."})]})]}),a.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[a.jsx("button",{type:"button",onClick:()=>f(!1),className:"rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"}),a.jsxs("button",{type:"submit",disabled:N==="create"||g.length!==12,className:"flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50",children:[N==="create"&&a.jsx(ct,{className:"h-4 w-4 animate-spin"}),"Create source"]})]})]})}),d&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",role:"dialog","aria-modal":"true","aria-labelledby":"remove-source-title",children:a.jsxs("div",{className:"w-full max-w-md rounded-md border bg-background p-5 shadow-xl",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("h2",{id:"remove-source-title",className:"text-lg font-semibold",children:"Remove Cost source"}),a.jsx("button",{type:"button",onClick:()=>l(null),disabled:!!N,className:"rounded-md p-1 hover:bg-muted","aria-label":"Close",children:a.jsx(Lt,{className:"h-4 w-4"})})]}),a.jsxs("p",{className:"mt-4 text-sm",children:["Remove AWS account ",a.jsx("span",{className:"font-mono font-medium",children:d.managementAccountId})," from this tenant?"]}),a.jsxs("label",{className:"mt-4 flex items-start gap-3 rounded-md border border-destructive/30 p-3",children:[a.jsx("input",{type:"checkbox",checked:h,onChange:O=>m(O.target.checked),disabled:!!N,className:"mt-1 h-4 w-4"}),a.jsxs("span",{children:[a.jsx("span",{className:"block text-sm font-medium",children:"Also delete generated AWS resources"}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:"Deletes MeyiConnect StackSet instances, the StackSet, and the management stack before removing this source. CUR data already delivered to the central bucket is retained."})]})]}),a.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"If AWS cleanup fails, the source is preserved so you can retry or clean up manually."}),a.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[a.jsx("button",{type:"button",onClick:()=>l(null),disabled:!!N,className:"rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"}),a.jsxs("button",{type:"button",onClick:()=>{D()},disabled:!!N,className:"flex items-center gap-2 rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground disabled:opacity-50",children:[N===`remove-${d.connectionId}`&&a.jsx(ct,{className:"h-4 w-4 animate-spin"}),"Remove"]})]})]})})]})}const vm=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],wm=["UTC","Asia/Kolkata","America/New_York","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];function Sm({open:e,schedule:t,saving:n,onClose:r,onSave:s}){const[o,i]=P.useState(t);if(P.useEffect(()=>i(t),[t,e]),!e)return null;const c=u=>i(f=>({...f,frequency:u}));return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4",role:"presentation",onMouseDown:u=>{u.target===u.currentTarget&&r()},children:a.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"cost-ai-schedule-title",className:"w-full max-w-lg overflow-hidden rounded-lg border bg-background shadow-xl",children:[a.jsxs("div",{className:"flex items-start justify-between border-b px-5 py-4",children:[a.jsxs("div",{children:[a.jsxs("h2",{id:"cost-ai-schedule-title",className:"flex items-center gap-2 text-base font-semibold",children:[a.jsx(oi,{className:"h-4 w-4 text-primary"}),"AI report schedule"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Reports run automatically against completed AWS CUR periods."})]}),a.jsx("button",{type:"button",onClick:r,className:"rounded-md p-1.5 hover:bg-muted","aria-label":"Close",children:a.jsx(Lt,{className:"h-4 w-4"})})]}),a.jsxs("form",{className:"space-y-5 p-5",onSubmit:u=>{u.preventDefault(),s({enabled:o.enabled,frequency:o.frequency,time:o.time,timezone:o.timezone,dayOfWeek:o.dayOfWeek,dayOfMonth:o.dayOfMonth}).then(r)},children:[a.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-lg border p-3",children:[a.jsxs("span",{children:[a.jsx("span",{className:"block text-sm font-medium",children:"Scheduled reports"}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:"Generate reports without a manual action"})]}),a.jsx("input",{type:"checkbox",checked:o.enabled,onChange:u=>i(f=>({...f,enabled:u.target.checked})),className:"h-4 w-4 accent-primary"})]}),a.jsxs("fieldset",{disabled:!o.enabled||n,className:"space-y-5 disabled:opacity-60",children:[a.jsxs("div",{children:[a.jsx("span",{className:"mb-2 block text-sm font-medium",children:"Frequency"}),a.jsx("div",{className:"grid grid-cols-3 rounded-lg border p-1",children:["daily","weekly","monthly"].map(u=>a.jsx("button",{type:"button",onClick:()=>c(u),className:`rounded-md px-3 py-2 text-sm capitalize ${o.frequency===u?"bg-primary text-primary-foreground":"hover:bg-muted"}`,children:u},u))})]}),a.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.jsxs("label",{className:"text-sm font-medium",children:["Run time",a.jsx("input",{type:"time",required:!0,value:o.time,onChange:u=>i(f=>({...f,time:u.target.value})),className:"mt-2 block h-10 w-full rounded-lg border bg-background px-3 font-normal"})]}),a.jsxs("label",{className:"text-sm font-medium",children:["Timezone",a.jsx("select",{value:o.timezone,onChange:u=>i(f=>({...f,timezone:u.target.value})),className:"mt-2 block h-10 w-full rounded-lg border bg-background px-3 font-normal",children:[...new Set([o.timezone,...wm])].map(u=>a.jsx("option",{children:u},u))})]})]}),o.frequency==="weekly"&&a.jsxs("label",{className:"block text-sm font-medium",children:["Day of week",a.jsx("select",{value:o.dayOfWeek??1,onChange:u=>i(f=>({...f,dayOfWeek:Number(u.target.value)})),className:"mt-2 block h-10 w-full rounded-lg border bg-background px-3 font-normal",children:vm.map((u,f)=>a.jsx("option",{value:f,children:u},u))})]}),o.frequency==="monthly"&&a.jsxs("label",{className:"block text-sm font-medium",children:["Day of month",a.jsx("input",{type:"number",min:1,max:28,value:o.dayOfMonth??1,onChange:u=>i(f=>({...f,dayOfMonth:Number(u.target.value)})),className:"mt-2 block h-10 w-full rounded-lg border bg-background px-3 font-normal"})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Daily reports cover the previous day, weekly reports the previous seven complete days, and monthly reports the previous calendar month."})]}),a.jsxs("div",{className:"flex justify-end gap-2 border-t pt-4",children:[a.jsx("button",{type:"button",onClick:r,className:"rounded-lg border px-4 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:n,className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50",children:n?"Saving":"Save schedule"})]})]})]})})}function Ze(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e?.(s),n===!1||!s||!s.defaultPrevented)return t?.(s)}}function Lo(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Rm(...e){return t=>{let n=!1;const r=e.map(s=>{const o=Lo(s,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let s=0;s<r.length;s++){const o=r[s];typeof o=="function"?o():Lo(e[s],null)}}}}function bt(...e){return S.useCallback(Rm(...e),e)}function Nm(e,t=[]){let n=[];function r(o,i){const c=S.createContext(i);c.displayName=o+"Context";const u=n.length;n=[...n,i];const f=l=>{const{scope:h,children:m,...g}=l,p=h?.[e]?.[u]||c,x=S.useMemo(()=>g,Object.values(g));return a.jsx(p.Provider,{value:x,children:m})};f.displayName=o+"Provider";function d(l,h,m={}){const{optional:g=!1}=m,p=h?.[e]?.[u]||c,x=S.useContext(p);if(x)return x;if(i!==void 0)return i;if(!g)throw new Error(`\`${l}\` must be used within \`${o}\``)}return[f,d]}const s=()=>{const o=n.map(i=>S.createContext(i));return function(c){const u=c?.[e]||o;return S.useMemo(()=>({[`__scope${e}`]:{...c,[e]:u}}),[c,u])}};return s.scopeName=e,[r,Cm(s,...t)]}function Cm(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const i=r.reduce((c,{useScope:u,scopeName:f})=>{const l=u(o)[`__scope${f}`];return{...c,...l}},{});return S.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var sn=globalThis?.document?S.useLayoutEffect:()=>{},jm=S[" useId ".trim().toString()]||(()=>{}),Em=0;function Pr(e){const[t,n]=S.useState(jm());return sn(()=>{n(r=>r??String(Em++))},[e]),e||(t?`radix-${t}`:"")}var _m=S[" useInsertionEffect ".trim().toString()]||sn;function km({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[s,o,i]=Pm({defaultProp:t,onChange:n}),c=e!==void 0,u=c?e:s;{const d=S.useRef(e!==void 0);S.useEffect(()=>{const l=d.current;l!==c&&console.warn(`${r} is changing from ${l?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=c},[c,r])}const f=S.useCallback(d=>{if(c){const l=Am(d)?d(e):d;l!==e&&i.current?.(l)}else o(d)},[c,e,o,i]);return[u,f]}function Pm({defaultProp:e,onChange:t}){const[n,r]=S.useState(e),s=S.useRef(n),o=S.useRef(t);return _m(()=>{o.current=t},[t]),S.useEffect(()=>{s.current!==n&&(o.current?.(n),s.current=n)},[n,s]),[n,r,o]}function Am(e){return typeof e=="function"}function Li(e){const t=S.forwardRef((n,r)=>{let{children:s,...o}=n,i=null,c=!1;const u=[];Io(s)&&typeof Cn=="function"&&(s=Cn(s._payload)),S.Children.forEach(s,h=>{if(Mm(h)){c=!0;const m=h;let g="child"in m.props?m.props.child:m.props.children;Io(g)&&typeof Cn=="function"&&(g=Cn(g._payload)),i=Tm(m,g),u.push(i?.props?.children)}else u.push(h)}),i?i=S.cloneElement(i,void 0,u):!c&&S.Children.count(s)===1&&S.isValidElement(s)&&(i=s);const f=i?Im(i):void 0,d=bt(r,f);if(!i){if(s||s===0)throw new Error(c?$m(e):Um(e));return s}const l=Lm(o,i.props??{});return i.type!==S.Fragment&&(l.ref=r?d:f),S.cloneElement(i,l)});return t.displayName=`${e}.Slot`,t}var Om=Symbol.for("radix.slottable"),Tm=(e,t)=>{if("child"in e.props){const n=e.props.child;return S.isValidElement(n)?S.cloneElement(n,void 0,e.props.children(n.props.children)):null}return S.isValidElement(t)?t:null};function Lm(e,t){const n={...t};for(const r in t){const s=e[r],o=t[r];/^on[A-Z]/.test(r)?s&&o?n[r]=(...c)=>{const u=o(...c);return s(...c),u}:s&&(n[r]=s):r==="style"?n[r]={...s,...o}:r==="className"&&(n[r]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function Im(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Mm(e){return S.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Om}var Dm=Symbol.for("react.lazy");function Io(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Dm&&"_payload"in e&&Fm(e._payload)}function Fm(e){return typeof e=="object"&&e!==null&&"then"in e}var Um=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,$m=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,Cn=S[" use ".trim().toString()],Bm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],We=Bm.reduce((e,t)=>{const n=Li(`Primitive.${t}`),r=S.forwardRef((s,o)=>{const{asChild:i,...c}=s,u=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(u,{...c,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function zm(e,t){e&&Zo.flushSync(()=>e.dispatchEvent(t))}function on(e){const t=S.useRef(e);return S.useEffect(()=>{t.current=e}),S.useMemo(()=>((...n)=>t.current?.(...n)),[])}var Wm="DismissableLayer",Xr="dismissableLayer.update",Vm="dismissableLayer.pointerDownOutside",Hm="dismissableLayer.focusOutside",Mo,gs=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ii=S.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:c,onDismiss:u,...f}=e,d=S.useContext(gs),[l,h]=S.useState(null),m=l?.ownerDocument??globalThis?.document,[,g]=S.useState({}),p=bt(t,h),x=Array.from(d.layers),[b]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=b?x.indexOf(b):-1,v=l?x.indexOf(l):-1,N=d.layersWithOutsidePointerEventsDisabled.size>0,j=v>=y,_=S.useRef(!1),C=Jm(A=>{o?.(A),c?.(A),A.defaultPrevented||u?.()},{ownerDocument:m,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:_,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:S.useCallback(A=>{if(!(A instanceof Node))return!1;const D=[...d.branches].some(O=>O.contains(A));return j&&!D},[d.branches,j])}),R=Xm(A=>{if(r&&_.current)return;const D=A.target;[...d.branches].some($=>$.contains(D))||(i?.(A),c?.(A),A.defaultPrevented||u?.())},m),k=l?v===x.length-1:!1,L=on(A=>{A.key==="Escape"&&(s?.(A),!A.defaultPrevented&&u&&(A.preventDefault(),u()))});return S.useEffect(()=>{if(k)return m.addEventListener("keydown",L,{capture:!0}),()=>m.removeEventListener("keydown",L,{capture:!0})},[m,k,L]),S.useEffect(()=>{if(l)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(Mo=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(l)),d.layers.add(l),Do(),()=>{n&&(d.layersWithOutsidePointerEventsDisabled.delete(l),d.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=Mo))}},[l,m,n,d]),S.useEffect(()=>()=>{l&&(d.layers.delete(l),d.layersWithOutsidePointerEventsDisabled.delete(l),Do())},[l,d]),S.useEffect(()=>{const A=()=>g({});return document.addEventListener(Xr,A),()=>document.removeEventListener(Xr,A)},[]),a.jsx(We.div,{...f,ref:p,style:{pointerEvents:N?j?"auto":"none":void 0,...e.style},onFocusCapture:Ze(e.onFocusCapture,R.onFocusCapture),onBlurCapture:Ze(e.onBlurCapture,R.onBlurCapture),onPointerDownCapture:Ze(e.onPointerDownCapture,C.onPointerDownCapture)})});Ii.displayName=Wm;var qm="DismissableLayerBranch",Gm=S.forwardRef((e,t)=>{const n=S.useContext(gs),r=S.useRef(null),s=bt(t,r);return S.useEffect(()=>{const o=r.current;if(o)return n.branches.add(o),()=>{n.branches.delete(o)}},[n.branches]),a.jsx(We.div,{...e,ref:s})});Gm.displayName=qm;function Km(){const e=S.useContext(gs),[t,n]=S.useState(null);return S.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}var Ym=()=>!0;function Jm(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:s,dismissableSurfaces:o,shouldHandlePointerDownOutside:i=Ym}=t,c=on(e),u=S.useRef(!1),f=S.useRef(!1),d=S.useRef(new Map),l=S.useRef(()=>{});return S.useEffect(()=>{function h(){f.current=!1,s.current=!1,d.current.clear()}function m(){return Array.from(d.current.values()).some(Boolean)}function g(v){if(!f.current)return;const N=v.target;N instanceof Node&&[...o].some(_=>_.contains(N))||d.current.set(v.type,!0),v.type==="click"&&window.setTimeout(()=>{f.current&&l.current()},0)}function p(v){f.current&&d.current.set(v.type,!1)}const x=v=>{if(v.target&&!u.current){let N=function(){n.removeEventListener("click",l.current);const _=m();h(),_||Mi(Vm,c,j,{discrete:!0})};if(!i(v.target)){n.removeEventListener("click",l.current),h(),u.current=!1;return}const j={originalEvent:v};f.current=!0,s.current=r&&v.button===0,d.current.clear(),!r||v.button!==0?N():(n.removeEventListener("click",l.current),l.current=N,n.addEventListener("click",l.current,{once:!0}))}else n.removeEventListener("click",l.current),h();u.current=!1},b=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const v of b)n.addEventListener(v,g,!0),n.addEventListener(v,p);const y=window.setTimeout(()=>{n.addEventListener("pointerdown",x)},0);return()=>{window.clearTimeout(y),n.removeEventListener("pointerdown",x),n.removeEventListener("click",l.current);for(const v of b)n.removeEventListener(v,g,!0),n.removeEventListener(v,p)}},[n,c,r,s,o,i]),{onPointerDownCapture:()=>u.current=!0}}function Xm(e,t=globalThis?.document){const n=on(e),r=S.useRef(!1);return S.useEffect(()=>{const s=o=>{o.target&&!r.current&&Mi(Hm,n,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Do(){const e=new CustomEvent(Xr);document.dispatchEvent(e)}function Mi(e,t,n,{discrete:r}){const s=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?zm(s,o):s.dispatchEvent(o)}var Ar="focusScope.autoFocusOnMount",Or="focusScope.autoFocusOnUnmount",Fo={bubbles:!1,cancelable:!0},Zm="FocusScope",Di=S.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:o,...i}=e,[c,u]=S.useState(null),f=on(s),d=on(o),l=S.useRef(null),h=bt(t,u),m=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(r){let p=function(v){if(m.paused||!c)return;const N=v.target;c.contains(N)?l.current=N:qe(l.current,{select:!0})},x=function(v){if(m.paused||!c)return;const N=v.relatedTarget;N!==null&&(c.contains(N)||qe(l.current,{select:!0}))},b=function(v){if(document.activeElement===document.body)for(const j of v)j.removedNodes.length>0&&qe(c)};document.addEventListener("focusin",p),document.addEventListener("focusout",x);const y=new MutationObserver(b);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",x),y.disconnect()}}},[r,c,m.paused]),S.useEffect(()=>{if(c){$o.add(m);const p=document.activeElement;if(!c.contains(p)){const b=new CustomEvent(Ar,Fo);c.addEventListener(Ar,f),c.dispatchEvent(b),b.defaultPrevented||(Qm(sp(Fi(c)),{select:!0}),document.activeElement===p&&qe(c))}return()=>{c.removeEventListener(Ar,f),setTimeout(()=>{const b=new CustomEvent(Or,Fo);c.addEventListener(Or,d),c.dispatchEvent(b),b.defaultPrevented||qe(p??document.body,{select:!0}),c.removeEventListener(Or,d),$o.remove(m)},0)}}},[c,f,d,m]);const g=S.useCallback(p=>{if(!n&&!r||m.paused)return;const x=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,b=document.activeElement;if(x&&b){const y=p.currentTarget,[v,N]=ep(y);v&&N?!p.shiftKey&&b===N?(p.preventDefault(),n&&qe(v,{select:!0})):p.shiftKey&&b===v&&(p.preventDefault(),n&&qe(N,{select:!0})):b===y&&p.preventDefault()}},[n,r,m.paused]);return a.jsx(We.div,{tabIndex:-1,...i,ref:h,onKeyDown:g})});Di.displayName=Zm;function Qm(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(qe(r,{select:t}),document.activeElement!==n)return}function ep(e){const t=Fi(e),n=Uo(t,e),r=Uo(t.reverse(),e);return[n,r]}function Fi(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Uo(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):tp(r,{upTo:t})))return r}function tp(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function np(e){return e instanceof HTMLInputElement&&"select"in e}function qe(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&np(e)&&t&&e.select()}}var $o=rp();function rp(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Bo(e,t),e.unshift(t)},remove(t){e=Bo(e,t),e[0]?.resume()}}}function Bo(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function sp(e){return e.filter(t=>t.tagName!=="A")}var op="Portal",Ui=S.forwardRef((e,t)=>{const{container:n,...r}=e,[s,o]=S.useState(!1);sn(()=>o(!0),[]);const i=n||s&&globalThis?.document?.body;return i?Zo.createPortal(a.jsx(We.div,{...r,ref:t}),i):null});Ui.displayName=op;function ap(e,t){return S.useReducer((n,r)=>t[n][r]??n,e)}var ir=e=>{const{present:t,children:n}=e,r=ip(t),s=typeof n=="function"?n({present:r.isPresent}):S.Children.only(n),o=cp(r.ref,lp(s));return typeof n=="function"||r.isPresent?S.cloneElement(s,{ref:o}):null};ir.displayName="Presence";function ip(e){const[t,n]=S.useState(),r=S.useRef(null),s=S.useRef(e),o=S.useRef("none"),i=S.useRef(void 0),c=e?"mounted":"unmounted",[u,f]=ap(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return S.useEffect(()=>{u==="mounted"?(o.current=i.current??Xt(r.current),i.current=void 0):o.current="none"},[u]),sn(()=>{const d=r.current,l=s.current;if(l!==e){const m=o.current,g=Xt(d);e?(i.current=g,f("MOUNT")):g==="none"||d?.display==="none"?f("UNMOUNT"):f(l&&m!==g?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,f]),sn(()=>{if(t){let d;const l=t.ownerDocument.defaultView??window,h=g=>{const x=Xt(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&x&&(f("ANIMATION_END"),!s.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",d=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},m=g=>{g.target===t&&(o.current=Xt(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{l.clearTimeout(d),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else f("ANIMATION_END")},[t,f]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:S.useCallback(d=>{if(d){const l=getComputedStyle(d);r.current=l,i.current=Xt(l)}else r.current=null;n(d)},[])}}function zo(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function cp(...e){const t=S.useRef(e);return t.current=e,S.useCallback(n=>{const r=t.current;let s=!1;const o=r.map(i=>{const c=zo(i,n);return!s&&typeof c=="function"&&(s=!0),c});if(s)return()=>{for(let i=0;i<o.length;i++){const c=o[i];typeof c=="function"?c():zo(r[i],null)}}},[])}function Xt(e){return e?.animationName||"none"}function lp(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var jn=0,wt=null;function up(){S.useEffect(()=>{wt||(wt={start:Wo(),end:Wo()});const{start:e,end:t}=wt;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),jn++,()=>{jn===1&&(wt?.start.remove(),wt?.end.remove(),wt=null),jn=Math.max(0,jn-1)}},[])}function Wo(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var De=function(){return De=Object.assign||function(t){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},De.apply(this,arguments)};function $i(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n}function dp(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,o;r<s;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var Fn="right-scroll-bar-position",Un="width-before-scroll-bar",fp="with-scroll-bars-hidden",hp="--removed-body-scroll-bar-size";function Tr(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function mp(e,t){var n=P.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=t,n.facade}var pp=typeof window<"u"?S.useLayoutEffect:S.useEffect,Vo=new WeakMap;function gp(e,t){var n=mp(null,function(r){return e.forEach(function(s){return Tr(s,r)})});return pp(function(){var r=Vo.get(n);if(r){var s=new Set(r),o=new Set(e),i=n.current;s.forEach(function(c){o.has(c)||Tr(c,null)}),o.forEach(function(c){s.has(c)||Tr(c,i)})}Vo.set(n,e)},[e]),n}function xp(e){return e}function bp(e,t){t===void 0&&(t=xp);var n=[],r=!1,s={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(o){var i=t(o,r);return n.push(i),function(){n=n.filter(function(c){return c!==i})}},assignSyncMedium:function(o){for(r=!0;n.length;){var i=n;n=[],i.forEach(o)}n={push:function(c){return o(c)},filter:function(){return n}}},assignMedium:function(o){r=!0;var i=[];if(n.length){var c=n;n=[],c.forEach(o),i=n}var u=function(){var d=i;i=[],d.forEach(o)},f=function(){return Promise.resolve().then(u)};f(),n={push:function(d){i.push(d),f()},filter:function(d){return i=i.filter(d),n}}}};return s}function yp(e){e===void 0&&(e={});var t=bp(null);return t.options=De({async:!0,ssr:!1},e),t}var Bi=function(e){var t=e.sideCar,n=$i(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return S.createElement(r,De({},n))};Bi.isSideCarExport=!0;function vp(e,t){return e.useMedium(t),Bi}var zi=yp(),Lr=function(){},cr=S.forwardRef(function(e,t){var n=S.useRef(null),r=S.useState({onScrollCapture:Lr,onWheelCapture:Lr,onTouchMoveCapture:Lr}),s=r[0],o=r[1],i=e.forwardProps,c=e.children,u=e.className,f=e.removeScrollBar,d=e.enabled,l=e.shards,h=e.sideCar,m=e.noRelative,g=e.noIsolation,p=e.inert,x=e.allowPinchZoom,b=e.as,y=b===void 0?"div":b,v=e.gapMode,N=$i(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=h,_=gp([n,t]),C=De(De({},N),s);return S.createElement(S.Fragment,null,d&&S.createElement(j,{sideCar:zi,removeScrollBar:f,shards:l,noRelative:m,noIsolation:g,inert:p,setCallbacks:o,allowPinchZoom:!!x,lockRef:n,gapMode:v}),i?S.cloneElement(S.Children.only(c),De(De({},C),{ref:_})):S.createElement(y,De({},C,{className:u,ref:_}),c))});cr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};cr.classNames={fullWidth:Un,zeroRight:Fn};var wp=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Sp(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=wp();return t&&e.setAttribute("nonce",t),e}function Rp(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Np(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Cp=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Sp())&&(Rp(t,n),Np(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},jp=function(){var e=Cp();return function(t,n){S.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Wi=function(){var e=jp(),t=function(n){var r=n.styles,s=n.dynamic;return e(r,s),null};return t},Ep={left:0,top:0,right:0,gap:0},Ir=function(e){return parseInt(e||"",10)||0},_p=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[Ir(n),Ir(r),Ir(s)]},kp=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ep;var t=_p(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Pp=Wi(),kt="data-scroll-locked",Ap=function(e,t,n,r){var s=e.left,o=e.top,i=e.right,c=e.gap;return n===void 0&&(n="margin"),`
22
22
  .`.concat(fp,` {
23
23
  overflow: hidden `).concat(r,`;
24
24
  padding-right: `).concat(c,"px ").concat(r,`;
package/dist/index.mjs CHANGED
@@ -10117,7 +10117,7 @@ function im() {
10117
10117
  const jn = ["#6264e9", "#eb67ad", "#31c39a", "#f29a05", "#579bea", "#9078ed", "#f7842c", "#24b9ad", "#8ac926", "#ffca3a", "#6a4c93", "#1982c4"];
10118
10118
  function Lo(e, t) {
10119
10119
  const n = new Date(e.length === 10 ? `${e}T00:00:00Z` : e);
10120
- return Number.isFinite(n.getTime()) ? n.toLocaleDateString(void 0, t ? { month: "short", day: "numeric", year: "numeric" } : { month: "short", year: "numeric" }) : e;
10120
+ return Number.isFinite(n.getTime()) ? n.toLocaleDateString(void 0, t ? { month: "short", day: "numeric" } : { month: "short", year: "numeric" }) : e;
10121
10121
  }
10122
10122
  function cm({ timeline: e, currency: t = "USD", daily: n = !1 }) {
10123
10123
  const [r, s] = U(null), [o, i] = U(null), c = un(() => {
@@ -10137,10 +10137,10 @@ function cm({ timeline: e, currency: t = "USD", daily: n = !1 }) {
10137
10137
  /* @__PURE__ */ a.jsx("div", { className: "flex px-4 pt-2", children: e.map((g, p) => /* @__PURE__ */ a.jsx("span", { className: "shrink-0 whitespace-nowrap text-center text-[11px] text-muted-foreground", style: { width: h }, children: Lo(g.start, n) }, `${g.start}-label-${p}`)) })
10138
10138
  ] }) })
10139
10139
  ] }),
10140
- /* @__PURE__ */ a.jsxs("div", { className: "mt-5 flex flex-wrap gap-x-4 gap-y-2", children: [
10141
- c.slice(0, 8).map((g) => /* @__PURE__ */ a.jsxs("span", { className: "flex items-center gap-1.5 text-xs", children: [
10142
- /* @__PURE__ */ a.jsx("span", { className: "h-2.5 w-2.5 rounded-full", style: { backgroundColor: g.color } }),
10143
- g.label
10140
+ /* @__PURE__ */ a.jsxs("div", { className: "mt-5 flex min-w-0 flex-wrap gap-x-4 gap-y-2", children: [
10141
+ c.slice(0, 8).map((g) => /* @__PURE__ */ a.jsxs("span", { className: "flex max-w-full min-w-0 items-center gap-1.5 text-xs", children: [
10142
+ /* @__PURE__ */ a.jsx("span", { className: "h-2.5 w-2.5 shrink-0 rounded-full", style: { backgroundColor: g.color } }),
10143
+ /* @__PURE__ */ a.jsx("span", { className: "min-w-0 truncate", title: g.label, children: g.label })
10144
10144
  ] }, g.label)),
10145
10145
  c.length > 8 && /* @__PURE__ */ a.jsxs("span", { className: "text-xs text-muted-foreground", children: [
10146
10146
  "+",
@@ -10981,7 +10981,8 @@ function jm() {
10981
10981
  ] }),
10982
10982
  /* @__PURE__ */ a.jsxs("td", { className: "px-4 py-3", children: [
10983
10983
  /* @__PURE__ */ a.jsx("span", { className: `rounded-full border px-2 py-1 text-xs font-medium ${Cm(A.status)}`, children: A.status.replace(/_/g, " ") }),
10984
- A.stackSetStatus && /* @__PURE__ */ a.jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: A.stackSetStatus.replace(/_/g, " ") })
10984
+ A.stackSetStatus && /* @__PURE__ */ a.jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: A.stackSetStatus.replace(/_/g, " ") }),
10985
+ A.status === "FAILED" && A.failureReason && /* @__PURE__ */ a.jsx("div", { className: "mt-1 max-w-md text-xs text-destructive", children: A.failureReason })
10985
10986
  ] }),
10986
10987
  /* @__PURE__ */ a.jsx("td", { className: "px-4 py-3", children: /* @__PURE__ */ a.jsxs("div", { className: "flex justify-end gap-2", children: [
10987
10988
  /* @__PURE__ */ a.jsx("button", { type: "button", onClick: () => {
package/package.json CHANGED
@@ -1,66 +1,66 @@
1
- {
2
- "name": "@meyicloud/meyi-cost-ui",
3
- "private": false,
4
- "version": "1.5.9",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.mjs",
8
- "types": "./dist/index.d.ts",
9
- "files": [
10
- "dist",
11
- "README.md"
12
- ],
13
- "exports": {
14
- ".": {
15
- "types": "./dist/index.d.ts",
16
- "import": "./dist/index.mjs",
17
- "require": "./dist/index.js"
18
- },
19
- "./style.css": "./dist/style.css",
20
- "./style": "./dist/style.css"
21
- },
22
- "scripts": {
23
- "dev": "vite",
24
- "build": "vite build",
25
- "prepublishOnly": "npm run build"
26
- },
27
- "peerDependencies": {
28
- "react": "^19.0.0",
29
- "react-dom": "^19.0.0"
30
- },
31
- "dependencies": {
32
- "@radix-ui/react-dialog": "^1.1.15",
33
- "@radix-ui/react-dropdown-menu": "^2.1.16",
34
- "@radix-ui/react-label": "^2.1.8",
35
- "@radix-ui/react-select": "^2.2.0",
36
- "@radix-ui/react-separator": "^1.1.0",
37
- "@radix-ui/react-slot": "^1.2.4",
38
- "@radix-ui/react-tabs": "^1.1.0",
39
- "@radix-ui/react-tooltip": "^1.2.0",
40
- "@tanstack/react-query": "^5.0.0",
41
- "@tanstack/react-router": "^1.132.0",
42
- "@tanstack/react-table": "^8.21.3",
43
- "axios": "^1.12.0",
44
- "class-variance-authority": "^0.7.0",
45
- "clsx": "^2.1.0",
46
- "date-fns": "^4.4.0",
47
- "jspdf": "^4.2.1",
48
- "jspdf-autotable": "^5.0.8",
49
- "lucide-react": "^0.545.0",
50
- "sonner": "^2.0.0",
51
- "tailwind-merge": "^3.3.0",
52
- "tailwindcss": "^4.1.0",
53
- "tw-animate-css": "^1.4.0",
54
- "zod": "^3.24.2"
55
- },
56
- "devDependencies": {
57
- "@tailwindcss/vite": "^4.1.0",
58
- "@types/node": "^20.0.0",
59
- "@types/react": "^19.0.0",
60
- "@types/react-dom": "^19.0.0",
61
- "@vitejs/plugin-react-swc": "^4.0.0",
62
- "typescript": "~5.9.0",
63
- "vite": "^7.0.0",
64
- "vite-plugin-dts": "^4.5.0"
65
- }
66
- }
1
+ {
2
+ "name": "@meyicloud/meyi-cost-ui",
3
+ "private": false,
4
+ "version": "1.5.11",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "README.md"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.mjs",
17
+ "require": "./dist/index.js"
18
+ },
19
+ "./style.css": "./dist/style.css",
20
+ "./style": "./dist/style.css"
21
+ },
22
+ "scripts": {
23
+ "dev": "vite",
24
+ "build": "vite build",
25
+ "prepublishOnly": "npm run build"
26
+ },
27
+ "peerDependencies": {
28
+ "react": "^19.0.0",
29
+ "react-dom": "^19.0.0"
30
+ },
31
+ "dependencies": {
32
+ "@radix-ui/react-dialog": "^1.1.15",
33
+ "@radix-ui/react-dropdown-menu": "^2.1.16",
34
+ "@radix-ui/react-label": "^2.1.8",
35
+ "@radix-ui/react-select": "^2.2.0",
36
+ "@radix-ui/react-separator": "^1.1.0",
37
+ "@radix-ui/react-slot": "^1.2.4",
38
+ "@radix-ui/react-tabs": "^1.1.0",
39
+ "@radix-ui/react-tooltip": "^1.2.0",
40
+ "@tanstack/react-query": "^5.0.0",
41
+ "@tanstack/react-router": "^1.132.0",
42
+ "@tanstack/react-table": "^8.21.3",
43
+ "axios": "^1.12.0",
44
+ "class-variance-authority": "^0.7.0",
45
+ "clsx": "^2.1.0",
46
+ "date-fns": "^4.4.0",
47
+ "jspdf": "^4.2.1",
48
+ "jspdf-autotable": "^5.0.8",
49
+ "lucide-react": "^0.545.0",
50
+ "sonner": "^2.0.0",
51
+ "tailwind-merge": "^3.3.0",
52
+ "tailwindcss": "^4.1.0",
53
+ "tw-animate-css": "^1.4.0",
54
+ "zod": "^3.24.2"
55
+ },
56
+ "devDependencies": {
57
+ "@tailwindcss/vite": "^4.1.0",
58
+ "@types/node": "^20.0.0",
59
+ "@types/react": "^19.0.0",
60
+ "@types/react-dom": "^19.0.0",
61
+ "@vitejs/plugin-react-swc": "^4.0.0",
62
+ "typescript": "~5.9.0",
63
+ "vite": "^7.0.0",
64
+ "vite-plugin-dts": "^4.5.0"
65
+ }
66
+ }