@meyicloud/meyi-cost-ui 1.5.6 → 1.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -11,11 +11,11 @@ React keys must be passed directly to JSX without using spread:
11
11
  `);return i===-1?"":r.stack.slice(i+1)})();try{if(!n.stack)n.stack=o;else if(o){const i=o.indexOf(`
12
12
  `),c=i===-1?-1:o.indexOf(`
13
13
  `,i+1),l=c===-1?"":o.slice(c+1);String(n.stack).endsWith(l)||(n.stack+=`
14
- `+o)}}catch{}}throw n}}_request(t,s){typeof t=="string"?(s=s||{},s.url=t):s=t||{},s=lt(this.defaults,s);const{transitional:n,paramsSerializer:r,headers:o}=s;n!==void 0&&ps.assertOptions(n,{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),r!=null&&(v.isFunction(r)?s.paramsSerializer={serialize:r}:ps.assertOptions(r,{encode:ge.function,serialize:ge.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),ps.assertOptions(s,{baseUrl:ge.spelling("baseURL"),withXsrfToken:ge.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let i=o&&v.merge(o.common,o[s.method]);o&&v.forEach(["delete","get","head","post","put","patch","query","common"],p=>{delete o[p]}),s.headers=be.concat(i,o);const c=[];let l=!0;this.interceptors.request.forEach(function(g){if(typeof g.runWhen=="function"&&g.runWhen(s)===!1)return;l=l&&g.synchronous;const b=s.transitional||Nn;b&&b.legacyInterceptorReqResOrdering?c.unshift(g.fulfilled,g.rejected):c.push(g.fulfilled,g.rejected)});const u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let f,d=0,h;if(!l){const p=[Ar.bind(this),void 0];for(p.unshift(...c),p.push(...u),h=p.length,f=Promise.resolve(s);d<h;)f=f.then(p[d++],p[d++]);return f}h=c.length;let m=s;for(;d<h;){const p=c[d++],g=c[d++];try{m=p(m)}catch(b){g.call(this,b);break}}try{f=Ar.call(this,m)}catch(p){return Promise.reject(p)}for(d=0,h=u.length;d<h;)f=f.then(u[d++],u[d++]);return f}getUri(t){t=lt(this.defaults,t);const s=Ho(t.baseURL,t.url,t.allowAbsoluteUrls,t);return $o(s,t.params,t.paramsSerializer)}};v.forEach(["delete","get","head","options"],function(t){at.prototype[t]=function(s,n){return this.request(lt(n||{},{method:t,url:s,data:n&&v.hasOwnProp(n,"data")?n.data:void 0}))}});v.forEach(["post","put","patch","query"],function(t){function s(n){return function(o,i,c){return this.request(lt(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}at.prototype[t]=s(),t!=="query"&&(at.prototype[t+"Form"]=s(!0))});let jd=class Yo{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(o){s=o});const n=this;this.promise.then(r=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](r);n._listeners=null}),this.promise.then=r=>{let o;const i=new Promise(c=>{n.subscribe(c),o=c}).then(r);return i.cancel=function(){n.unsubscribe(o)},i},t(function(o,i,c){n.reason||(n.reason=new Yt(o,i,c),s(n.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 s=this._listeners.indexOf(t);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const t=new AbortController,s=n=>{t.abort(n)};return this.subscribe(s),t.signal.unsubscribe=()=>this.unsubscribe(s),t.signal}static source(){let t;return{token:new Yo(function(r){t=r}),cancel:t}}};function Rd(e){return function(s){return e.apply(null,s)}}function Nd(e){return v.isObject(e)&&e.isAxiosError===!0}const mn={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(mn).forEach(([e,t])=>{mn[t]=e});function Jo(e){const t=new at(e),s=Co(at.prototype.request,t);return v.extend(s,at.prototype,t,{allOwnKeys:!0}),v.extend(s,t,null,{allOwnKeys:!0}),s.create=function(r){return Jo(lt(e,r))},s}const ae=Jo(Kt);ae.Axios=at;ae.CanceledError=Yt;ae.CancelToken=jd;ae.isCancel=Vo;ae.VERSION=_n;ae.toFormData=Os;ae.AxiosError=A;ae.Cancel=ae.CanceledError;ae.all=function(t){return Promise.all(t)};ae.spread=Rd;ae.isAxiosError=Nd;ae.mergeConfig=lt;ae.AxiosHeaders=be;ae.formToJSON=e=>zo(v.isHTMLForm(e)?new FormData(e):e);ae.getAdapter=Ko.getAdapter;ae.HttpStatusCode=mn;ae.default=ae;const{Axios:ih,AxiosError:ch,CanceledError:lh,isCancel:dh,CancelToken:uh,VERSION:fh,all:hh,Cancel:mh,isAxiosError:ph,spread:gh,toFormData:xh,AxiosHeaders:bh,HttpStatusCode:yh,formToJSON:vh,getAdapter:wh,mergeConfig:Sh,create:jh}=ae,se=ae.create({baseURL:"/api/v1/cost"});function Xo(e,t){se.defaults.baseURL=`${e.replace(/\/$/,"")}/cost`,t?se.defaults.headers.common.Authorization=`Bearer ${t}`:delete se.defaults.headers.common.Authorization}function Cd(e){e.interceptors.request.use(t=>{if(typeof window<"u"){const s=window.localStorage.getItem("access_token");s?(t.headers=t.headers||{},t.headers.Authorization=`Bearer ${s}`):t.headers&&delete t.headers.Authorization}return t})}const _d=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),kd=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,s,n)=>n?n.toUpperCase():s.toLowerCase()),Or=e=>{const t=kd(e);return t.charAt(0).toUpperCase()+t.slice(1)},Zo=(...e)=>e.filter((t,s,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===s).join(" ").trim(),Ed=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Pd={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 Ad=E.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:o,iconNode:i,...c},l)=>E.createElement("svg",{ref:l,...Pd,width:t,height:t,stroke:e,strokeWidth:n?Number(s)*24/Number(t):s,className:Zo("lucide",r),...!o&&!Ed(c)&&{"aria-hidden":"true"},...c},[...i.map(([u,f])=>E.createElement(u,f)),...Array.isArray(o)?o:[o]]));const ee=(e,t)=>{const s=E.forwardRef(({className:n,...r},o)=>E.createElement(Ad,{ref:o,iconNode:t,className:Zo(`lucide-${_d(Or(e))}`,`lucide-${e}`,n),...r}));return s.displayName=Or(e),s};const Td=[["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"}]],Qo=ee("building-2",Td);const Od=[["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"}]],ea=ee("calendar-clock",Od);const Ld=[["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"}]],Id=ee("chart-column",Ld);const Md=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Dd=ee("chevron-down",Md);const Fd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ud=ee("chevron-left",Fd);const $d=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Bd=ee("chevron-right",$d);const zd=[["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"}]],dt=ee("circle-alert",zd);const Vd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Wd=ee("circle-check",Vd);const Hd=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],Cs=ee("cloud",Hd);const qd=[["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"}]],ta=ee("database",qd);const Gd=[["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"}]],sa=ee("dollar-sign",Gd);const Kd=[["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"}]],En=ee("download",Kd);const Yd=[["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"}]],na=ee("external-link",Yd);const Jd=[["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"}]],Xd=ee("eye",Jd);const Zd=[["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"}]],Qd=ee("file-down",Zd);const eu=[["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"}]],ra=ee("file-text",eu);const tu=[["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"}]],su=ee("list",tu);const nu=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],st=ee("loader-circle",nu);const ru=[["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"}]],ou=ee("map-pin",ru);const au=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],iu=ee("plus",au);const cu=[["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"}]],St=ee("refresh-cw",cu);const lu=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Pn=ee("search",lu);const du=[["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"}]],oa=ee("server",du);const uu=[["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"}]],aa=ee("settings-2",uu);const fu=[["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"}]],Lr=ee("sparkles",fu);const hu=[["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"}]],ia=ee("trash-2",hu);const mu=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],pu=ee("trending-down",mu);const gu=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],ca=ee("trending-up",gu);const xu=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wt=ee("x",xu);function la(e){var t,s,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(s=la(e[t]))&&(n&&(n+=" "),n+=s)}else for(s in e)e[s]&&(n&&(n+=" "),n+=s);return n}function bu(){for(var e,t,s=0,n="",r=arguments.length;s<r;s++)(e=arguments[s])&&(t=la(e))&&(n&&(n+=" "),n+=t);return n}const yu=(e,t)=>{const s=new Array(e.length+t.length);for(let n=0;n<e.length;n++)s[n]=e[n];for(let n=0;n<t.length;n++)s[e.length+n]=t[n];return s},vu=(e,t)=>({classGroupId:e,validator:t}),da=(e=new Map,t=null,s)=>({nextPart:e,validators:t,classGroupId:s}),_s="-",Ir=[],wu="arbitrary..",Su=e=>{const t=Ru(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return ju(i);const c=i.split(_s),l=c[0]===""&&c.length>1?1:0;return ua(c,l,t)},getConflictingClassGroupIds:(i,c)=>{if(c){const l=n[i],u=s[i];return l?u?yu(u,l):l:u||Ir}return s[i]||Ir}}},ua=(e,t,s)=>{if(e.length-t===0)return s.classGroupId;const r=e[t],o=s.nextPart.get(r);if(o){const u=ua(e,t+1,o);if(u)return u}const i=s.validators;if(i===null)return;const c=t===0?e.join(_s):e.slice(t).join(_s),l=i.length;for(let u=0;u<l;u++){const f=i[u];if(f.validator(c))return f.classGroupId}},ju=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),s=t.indexOf(":"),n=t.slice(0,s);return n?wu+n:void 0})(),Ru=e=>{const{theme:t,classGroups:s}=e;return Nu(s,t)},Nu=(e,t)=>{const s=da();for(const n in e){const r=e[n];An(r,s,n,t)}return s},An=(e,t,s,n)=>{const r=e.length;for(let o=0;o<r;o++){const i=e[o];Cu(i,t,s,n)}},Cu=(e,t,s,n)=>{if(typeof e=="string"){_u(e,t,s);return}if(typeof e=="function"){ku(e,t,s,n);return}Eu(e,t,s,n)},_u=(e,t,s)=>{const n=e===""?t:fa(t,e);n.classGroupId=s},ku=(e,t,s,n)=>{if(Pu(e)){An(e(n),t,s,n);return}t.validators===null&&(t.validators=[]),t.validators.push(vu(s,e))},Eu=(e,t,s,n)=>{const r=Object.entries(e),o=r.length;for(let i=0;i<o;i++){const[c,l]=r[i];An(l,fa(t,c),s,n)}},fa=(e,t)=>{let s=e;const n=t.split(_s),r=n.length;for(let o=0;o<r;o++){const i=n[o];let c=s.nextPart.get(i);c||(c=da(),s.nextPart.set(i,c)),s=c}return s},Pu=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Au=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,s=Object.create(null),n=Object.create(null);const r=(o,i)=>{s[o]=i,t++,t>e&&(t=0,n=s,s=Object.create(null))};return{get(o){let i=s[o];if(i!==void 0)return i;if((i=n[o])!==void 0)return r(o,i),i},set(o,i){o in s?s[o]=i:r(o,i)}}},pn="!",Mr=":",Tu=[],Dr=(e,t,s,n,r)=>({modifiers:e,hasImportantModifier:t,baseClassName:s,maybePostfixModifierPosition:n,isExternal:r}),Ou=e=>{const{prefix:t,experimentalParseClassName:s}=e;let n=r=>{const o=[];let i=0,c=0,l=0,u;const f=r.length;for(let g=0;g<f;g++){const b=r[g];if(i===0&&c===0){if(b===Mr){o.push(r.slice(l,g)),l=g+1;continue}if(b==="/"){u=g;continue}}b==="["?i++:b==="]"?i--:b==="("?c++:b===")"&&c--}const d=o.length===0?r:r.slice(l);let h=d,m=!1;d.endsWith(pn)?(h=d.slice(0,-1),m=!0):d.startsWith(pn)&&(h=d.slice(1),m=!0);const p=u&&u>l?u-l:void 0;return Dr(o,m,h,p)};if(t){const r=t+Mr,o=n;n=i=>i.startsWith(r)?o(i.slice(r.length)):Dr(Tu,!1,i,void 0,!0)}if(s){const r=n;n=o=>s({className:o,parseClassName:r})}return n},Lu=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((s,n)=>{t.set(s,1e6+n)}),s=>{const n=[];let r=[];for(let o=0;o<s.length;o++){const i=s[o],c=i[0]==="[",l=t.has(i);c||l?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(i)):r.push(i)}return r.length>0&&(r.sort(),n.push(...r)),n}},Iu=e=>({cache:Au(e.cacheSize),parseClassName:Ou(e),sortModifiers:Lu(e),postfixLookupClassGroupIds:Mu(e),...Su(e)}),Mu=e=>{const t=Object.create(null),s=e.postfixLookupClassGroups;if(s)for(let n=0;n<s.length;n++)t[s[n]]=!0;return t},Du=/\s+/,Fu=(e,t)=>{const{parseClassName:s,getClassGroupId:n,getConflictingClassGroupIds:r,sortModifiers:o,postfixLookupClassGroupIds:i}=t,c=[],l=e.trim().split(Du);let u="";for(let f=l.length-1;f>=0;f-=1){const d=l[f],{isExternal:h,modifiers:m,hasImportantModifier:p,baseClassName:g,maybePostfixModifierPosition:b}=s(d);if(h){u=d+(u.length>0?" "+u:u);continue}let x=!!b,y;if(x){const j=g.substring(0,b);y=n(j);const w=y&&i[y]?n(g):void 0;w&&w!==y&&(y=w,x=!1)}else y=n(g);if(!y){if(!x){u=d+(u.length>0?" "+u:u);continue}if(y=n(g),!y){u=d+(u.length>0?" "+u:u);continue}x=!1}const S=m.length===0?"":m.length===1?m[0]:o(m).join(":"),N=p?S+pn:S,C=N+y;if(c.indexOf(C)>-1)continue;c.push(C);const _=r(y,x);for(let j=0;j<_.length;++j){const w=_[j];c.push(N+w)}u=d+(u.length>0?" "+u:u)}return u},Uu=(...e)=>{let t=0,s,n,r="";for(;t<e.length;)(s=e[t++])&&(n=ha(s))&&(r&&(r+=" "),r+=n);return r},ha=e=>{if(typeof e=="string")return e;let t,s="";for(let n=0;n<e.length;n++)e[n]&&(t=ha(e[n]))&&(s&&(s+=" "),s+=t);return s},$u=(e,...t)=>{let s,n,r,o;const i=l=>{const u=t.reduce((f,d)=>d(f),e());return s=Iu(u),n=s.cache.get,r=s.cache.set,o=c,c(l)},c=l=>{const u=n(l);if(u)return u;const f=Fu(l,s);return r(l,f),f};return o=i,(...l)=>o(Uu(...l))},Bu=[],ce=e=>{const t=s=>s[e]||Bu;return t.isThemeGetter=!0,t},ma=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,pa=/^\((?:(\w[\w-]*):)?(.+)\)$/i,zu=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Vu=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Wu=/\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$/,Hu=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,qu=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Gu=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Be=e=>zu.test(e),q=e=>!!e&&!Number.isNaN(Number(e)),Oe=e=>!!e&&Number.isInteger(Number(e)),en=e=>e.endsWith("%")&&q(e.slice(0,-1)),Me=e=>Vu.test(e),ga=()=>!0,Ku=e=>Wu.test(e)&&!Hu.test(e),Tn=()=>!1,Yu=e=>qu.test(e),Ju=e=>Gu.test(e),Xu=e=>!L(e)&&!M(e),Zu=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)),Qu=e=>Ge(e,ya,Tn),L=e=>ma.test(e),Je=e=>Ge(e,va,Ku),Fr=e=>Ge(e,cf,q),ef=e=>Ge(e,Sa,ga),tf=e=>Ge(e,wa,Tn),Ur=e=>Ge(e,xa,Tn),sf=e=>Ge(e,ba,Ju),rs=e=>Ge(e,ja,Yu),M=e=>pa.test(e),It=e=>ft(e,va),nf=e=>ft(e,wa),$r=e=>ft(e,xa),rf=e=>ft(e,ya),of=e=>ft(e,ba),os=e=>ft(e,ja,!0),af=e=>ft(e,Sa,!0),Ge=(e,t,s)=>{const n=ma.exec(e);return n?n[1]?t(n[1]):s(n[2]):!1},ft=(e,t,s=!1)=>{const n=pa.exec(e);return n?n[1]?t(n[1]):s:!1},xa=e=>e==="position"||e==="percentage",ba=e=>e==="image"||e==="url",ya=e=>e==="length"||e==="size"||e==="bg-size",va=e=>e==="length",cf=e=>e==="number",wa=e=>e==="family-name",Sa=e=>e==="number"||e==="weight",ja=e=>e==="shadow",lf=()=>{const e=ce("color"),t=ce("font"),s=ce("text"),n=ce("font-weight"),r=ce("tracking"),o=ce("leading"),i=ce("breakpoint"),c=ce("container"),l=ce("spacing"),u=ce("radius"),f=ce("shadow"),d=ce("inset-shadow"),h=ce("text-shadow"),m=ce("drop-shadow"),p=ce("blur"),g=ce("perspective"),b=ce("aspect"),x=ce("ease"),y=ce("animate"),S=()=>["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"],C=()=>[...N(),M,L],_=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],w=()=>[M,L,l],P=()=>[Be,"full","auto",...w()],I=()=>[Oe,"none","subgrid",M,L],k=()=>["auto",{span:["full",Oe,M,L]},Oe,M,L],T=()=>[Oe,"auto",M,L],Z=()=>["auto","min","max","fr",M,L],z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],J=()=>["start","end","center","stretch","center-safe","end-safe"],Y=()=>["auto",...w()],Q=()=>[Be,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...w()],he=()=>[Be,"screen","full","dvw","lvw","svw","min","max","fit",...w()],me=()=>[Be,"screen","full","lh","dvh","lvh","svh","min","max","fit",...w()],O=()=>[e,M,L],R=()=>[...N(),$r,Ur,{position:[M,L]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],H=()=>["auto","cover","contain",rf,Qu,{size:[M,L]}],G=()=>[en,It,Je],W=()=>["","none","full",u,M,L],U=()=>["",q,It,Je],D=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],V=()=>[q,en,$r,Ur],ie=()=>["","none",p,M,L],le=()=>["none",q,M,L],te=()=>["none",q,M,L],Ce=()=>[q,M,L],Ne=()=>[Be,"full",...w()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Me],breakpoint:[Me],color:[ga],container:[Me],"drop-shadow":[Me],ease:["in","out","in-out"],font:[Xu],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Me],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Me],shadow:[Me],spacing:["px",q],text:[Me],"text-shadow":[Me],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Be,L,M,b]}],container:["container"],"container-type":[{"@container":["","normal","size",M,L]}],"container-named":[Zu],columns:[{columns:[q,L,M,c]}],"break-after":[{"break-after":S()}],"break-before":[{"break-before":S()}],"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:C()}],overflow:[{overflow:_()}],"overflow-x":[{"overflow-x":_()}],"overflow-y":[{"overflow-y":_()}],overscroll:[{overscroll:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[Oe,"auto",M,L]}],basis:[{basis:[Be,"full","auto",c,...w()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[q,Be,"auto","initial","none",L]}],grow:[{grow:["",q,M,L]}],shrink:[{shrink:["",q,M,L]}],order:[{order:[Oe,"first","last","none",M,L]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:k()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:k()}],"row-start":[{"row-start":T()}],"row-end":[{"row-end":T()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Z()}],"auto-rows":[{"auto-rows":Z()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...z(),"normal"]}],"justify-items":[{"justify-items":[...J(),"normal"]}],"justify-self":[{"justify-self":["auto",...J()]}],"align-content":[{content:["normal",...z()]}],"align-items":[{items:[...J(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...J(),{baseline:["","last"]}]}],"place-content":[{"place-content":z()}],"place-items":[{"place-items":[...J(),"baseline"]}],"place-self":[{"place-self":["auto",...J()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],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":w()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":w()}],"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",s,It,Je]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,af,ef]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",en,L]}],"font-family":[{font:[nf,tf,t]}],"font-features":[{"font-features":[L]}],"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:[r,M,L]}],"line-clamp":[{"line-clamp":[q,"none",M,Fr]}],leading:[{leading:[o,...w()]}],"list-image":[{"list-image":["none",M,L]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",M,L]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:O()}],"text-color":[{text:O()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...D(),"wavy"]}],"text-decoration-thickness":[{decoration:[q,"from-font","auto",M,Je]}],"text-decoration-color":[{decoration:O()}],"underline-offset":[{"underline-offset":[q,"auto",M,L]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:w()}],"tab-size":[{tab:[Oe,M,L]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",M,L]}],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",M,L]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:R()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:H()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Oe,M,L],radial:["",M,L],conic:[Oe,M,L]},of,sf]}],"bg-color":[{bg:O()}],"gradient-from-pos":[{from:G()}],"gradient-via-pos":[{via:G()}],"gradient-to-pos":[{to:G()}],"gradient-from":[{from:O()}],"gradient-via":[{via:O()}],"gradient-to":[{to:O()}],rounded:[{rounded:W()}],"rounded-s":[{"rounded-s":W()}],"rounded-e":[{"rounded-e":W()}],"rounded-t":[{"rounded-t":W()}],"rounded-r":[{"rounded-r":W()}],"rounded-b":[{"rounded-b":W()}],"rounded-l":[{"rounded-l":W()}],"rounded-ss":[{"rounded-ss":W()}],"rounded-se":[{"rounded-se":W()}],"rounded-ee":[{"rounded-ee":W()}],"rounded-es":[{"rounded-es":W()}],"rounded-tl":[{"rounded-tl":W()}],"rounded-tr":[{"rounded-tr":W()}],"rounded-br":[{"rounded-br":W()}],"rounded-bl":[{"rounded-bl":W()}],"border-w":[{border:U()}],"border-w-x":[{"border-x":U()}],"border-w-y":[{"border-y":U()}],"border-w-s":[{"border-s":U()}],"border-w-e":[{"border-e":U()}],"border-w-bs":[{"border-bs":U()}],"border-w-be":[{"border-be":U()}],"border-w-t":[{"border-t":U()}],"border-w-r":[{"border-r":U()}],"border-w-b":[{"border-b":U()}],"border-w-l":[{"border-l":U()}],"divide-x":[{"divide-x":U()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":U()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...D(),"hidden","none"]}],"divide-style":[{divide:[...D(),"hidden","none"]}],"border-color":[{border:O()}],"border-color-x":[{"border-x":O()}],"border-color-y":[{"border-y":O()}],"border-color-s":[{"border-s":O()}],"border-color-e":[{"border-e":O()}],"border-color-bs":[{"border-bs":O()}],"border-color-be":[{"border-be":O()}],"border-color-t":[{"border-t":O()}],"border-color-r":[{"border-r":O()}],"border-color-b":[{"border-b":O()}],"border-color-l":[{"border-l":O()}],"divide-color":[{divide:O()}],"outline-style":[{outline:[...D(),"none","hidden"]}],"outline-offset":[{"outline-offset":[q,M,L]}],"outline-w":[{outline:["",q,It,Je]}],"outline-color":[{outline:O()}],shadow:[{shadow:["","none",f,os,rs]}],"shadow-color":[{shadow:O()}],"inset-shadow":[{"inset-shadow":["none",d,os,rs]}],"inset-shadow-color":[{"inset-shadow":O()}],"ring-w":[{ring:U()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:O()}],"ring-offset-w":[{"ring-offset":[q,Je]}],"ring-offset-color":[{"ring-offset":O()}],"inset-ring-w":[{"inset-ring":U()}],"inset-ring-color":[{"inset-ring":O()}],"text-shadow":[{"text-shadow":["none",h,os,rs]}],"text-shadow-color":[{"text-shadow":O()}],opacity:[{opacity:[q,M,L]}],"mix-blend":[{"mix-blend":[...X(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":X()}],"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":[q]}],"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":O()}],"mask-image-linear-to-color":[{"mask-linear-to":O()}],"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":O()}],"mask-image-t-to-color":[{"mask-t-to":O()}],"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":O()}],"mask-image-r-to-color":[{"mask-r-to":O()}],"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":O()}],"mask-image-b-to-color":[{"mask-b-to":O()}],"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":O()}],"mask-image-l-to-color":[{"mask-l-to":O()}],"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":O()}],"mask-image-x-to-color":[{"mask-x-to":O()}],"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":O()}],"mask-image-y-to-color":[{"mask-y-to":O()}],"mask-image-radial":[{"mask-radial":[M,L]}],"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":O()}],"mask-image-radial-to-color":[{"mask-radial-to":O()}],"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":[q]}],"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":O()}],"mask-image-conic-to-color":[{"mask-conic-to":O()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:R()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:H()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",M,L]}],filter:[{filter:["","none",M,L]}],blur:[{blur:ie()}],brightness:[{brightness:[q,M,L]}],contrast:[{contrast:[q,M,L]}],"drop-shadow":[{"drop-shadow":["","none",m,os,rs]}],"drop-shadow-color":[{"drop-shadow":O()}],grayscale:[{grayscale:["",q,M,L]}],"hue-rotate":[{"hue-rotate":[q,M,L]}],invert:[{invert:["",q,M,L]}],saturate:[{saturate:[q,M,L]}],sepia:[{sepia:["",q,M,L]}],"backdrop-filter":[{"backdrop-filter":["","none",M,L]}],"backdrop-blur":[{"backdrop-blur":ie()}],"backdrop-brightness":[{"backdrop-brightness":[q,M,L]}],"backdrop-contrast":[{"backdrop-contrast":[q,M,L]}],"backdrop-grayscale":[{"backdrop-grayscale":["",q,M,L]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[q,M,L]}],"backdrop-invert":[{"backdrop-invert":["",q,M,L]}],"backdrop-opacity":[{"backdrop-opacity":[q,M,L]}],"backdrop-saturate":[{"backdrop-saturate":[q,M,L]}],"backdrop-sepia":[{"backdrop-sepia":["",q,M,L]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",M,L]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[q,"initial",M,L]}],ease:[{ease:["linear","initial",x,M,L]}],delay:[{delay:[q,M,L]}],animate:[{animate:["none",y,M,L]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,M,L]}],"perspective-origin":[{"perspective-origin":C()}],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:Ce()}],"skew-x":[{"skew-x":Ce()}],"skew-y":[{"skew-y":Ce()}],transform:[{transform:[M,L,"","none","gpu","cpu"]}],"transform-origin":[{origin:C()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ne()}],"translate-x":[{"translate-x":Ne()}],"translate-y":[{"translate-y":Ne()}],"translate-z":[{"translate-z":Ne()}],"translate-none":["translate-none"],zoom:[{zoom:[Oe,M,L]}],accent:[{accent:O()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:O()}],"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",M,L]}],"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":O()}],"scrollbar-track-color":[{"scrollbar-track":O()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"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",M,L]}],fill:[{fill:["none",...O()]}],"stroke-w":[{stroke:[q,It,Je,Fr]}],stroke:[{stroke:["none",...O()]}],"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"]}},df=$u(lf);function Ct(...e){return df(bu(e))}function K(e,t="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:2}).format(e)}const de=$.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Ct("rounded-xl border bg-card text-card-foreground shadow",e),...t}));de.displayName="Card";const je=$.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Ct("flex flex-col space-y-1.5 p-6",e),...t}));je.displayName="CardHeader";const Pe=$.forwardRef(({className:e,...t},s)=>a.jsx("h3",{ref:s,className:Ct("font-semibold leading-none tracking-tight",e),...t}));Pe.displayName="CardTitle";const uf=$.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Ct("text-sm text-muted-foreground",e),...t}));uf.displayName="CardDescription";const ue=$.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Ct("p-6 pt-0",e),...t}));ue.displayName="CardContent";const ff=$.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Ct("flex items-center p-6 pt-0",e),...t}));ff.displayName="CardFooter";function ks({status:e,error:t}){const s=e?.action==="connect_source"||e?.state==="not_configured",n=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(dt,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"}):a.jsx(ta,{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:s?"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:n}),a.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[a.jsxs(Ss,{to:s?"/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(na,{className:"h-4 w-4"}),s?"Connect AWS source":"Review CUR discovery"]}),!s&&a.jsx(Ss,{to:"/sources",className:"rounded-md border px-3 py-2 text-sm font-medium hover:bg-muted",children:"Cost sources"})]})]})]})})}const oe={getOverview:e=>se.get("/overview",{params:e}).then(t=>t.data),getAccounts:e=>se.get("/accounts",{params:e}).then(t=>t.data),getReports:e=>se.get("/reports",{params:e}).then(t=>t.data),getFilterOptions:e=>se.get("/filter-options",{params:{start:e?.start,end:e?.end,tagKey:e?.filterTagKey,managementAccountId:e?.managementAccountId}}).then(t=>t.data),getTags:e=>se.get("/tags",{params:e}).then(t=>t.data),getDataStatus:e=>se.get("/data-status",{params:e}).then(t=>t.data),getAnalysisStatus:e=>se.get("/analysis/status",{params:e}).then(t=>t.data),getLatestAnalysis:e=>se.get("/analysis/latest",{params:e}).then(t=>t.data.analysis),getAnalysisSchedule:e=>se.get("/analysis/schedule",{params:e}).then(t=>t.data),updateAnalysisSchedule:(e,t)=>se.put("/analysis/schedule",e,{params:t}).then(s=>s.data),getAnalysisReports:e=>se.get("/analysis/reports",{params:e}).then(t=>t.data.reports),removeAnalysisReport:e=>se.delete(`/analysis/reports/${e}`).then(t=>t.data),downloadAnalysisPdf:e=>se.get(`/analysis/reports/${e}/pdf`,{responseType:"blob"}).then(t=>t.data),getSources:()=>se.get("/sources").then(e=>e.data),createSource:e=>se.post("/sources",e).then(t=>t.data),getSourceStatus:e=>se.get(`/sources/${e}/status`).then(t=>t.data),verifySource:e=>se.post(`/sources/${e}/verify`).then(t=>t.data),removeSource:(e,t)=>se.delete(`/sources/${e}`,{data:{deleteAwsResources:t}}).then(s=>s.data),downloadSourceTemplate:e=>se.get(`/sources/${e}/template`,{responseType:"blob"}).then(t=>t.data),getCurDiscovery:e=>se.get("/cur-discovery",{params:e}).then(t=>t.data)},Ra=E.createContext("user"),hf=Ra.Provider,mf=()=>E.useContext(Ra),Na=E.createContext(null);function pf({tenantId:e="default",children:t}){const s=`meyi-cost:selected-management-account:${e||"default"}`,[n,r]=E.useState([]),[o,i]=E.useState(""),[c,l]=E.useState(!0),u=E.useCallback(async()=>{l(!0);try{const m=((await oe.getSources()).sources||[]).filter(p=>!!p.managementAccountId);r(m),i(p=>{const b=window.localStorage.getItem(s)||""||p,x=m.some(y=>y.managementAccountId===b)?b:m[0]?.managementAccountId||"";return x?window.localStorage.setItem(s,x):window.localStorage.removeItem(s),x})}catch{r([]),i("")}finally{l(!1)}},[s]);E.useEffect(()=>{u()},[u]);const f=E.useCallback(h=>{/^\d{12}$/.test(h)&&(window.localStorage.setItem(s,h),i(h))},[s]),d=E.useMemo(()=>({sources:n,managementAccountId:o,loading:c,selectManagementAccount:f,refreshSources:u}),[n,o,c,f,u]);return a.jsx(Na.Provider,{value:d,children:t})}function _t(){const e=E.useContext(Na);if(!e)throw new Error("useCostAccount must be used inside CostAccountProvider");return e}function Is(){const{sources:e,managementAccountId:t,loading:s,selectManagementAccount:n}=_t();return e.length?a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx(Qo,{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:r=>n(r.target.value),disabled:s,className:"max-w-72 rounded-md border bg-background px-3 py-2 text-sm shadow-sm disabled:opacity-50",children:e.map(r=>a.jsxs("option",{value:r.managementAccountId||"",children:["Management account ",r.managementAccountId]},r.connectionId))})]}):null}function gf({points:e,currency:t="USD"}){const[s,n]=E.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 r=900,o=260,i=70,c=24,l=22,u=48,f=r-i-c,d=o-l-u,h=Math.max(...e.map(b=>b.value),1),m=e.map((b,x)=>({...b,x:i+(e.length===1?f/2:x*f/(e.length-1)),y:l+d-b.value/h*d})),p=s==null?null:m[s],g=b=>{const x=b.currentTarget.getBoundingClientRect(),y=(b.clientX-x.left)/x.width*r;let S=0;for(let N=1;N<m.length;N+=1)Math.abs(m[N].x-y)<Math.abs(m[S].x-y)&&(S=N);n(S)};return a.jsxs("div",{className:"relative w-full",children:[a.jsxs("svg",{viewBox:`0 0 ${r} ${o}`,className:"h-72 w-full",onMouseMove:g,onMouseLeave:()=>n(null),role:"img","aria-label":"Cost trend line chart",children:[[0,.25,.5,.75,1].map(b=>{const x=l+d*b;return a.jsxs("g",{children:[a.jsx("line",{x1:i,y1:x,x2:r-c,y2:x,stroke:"#d8e0e7",strokeDasharray:"4 4"}),a.jsx("text",{x:i-10,y:x+4,textAnchor:"end",fill:"currentColor",className:"text-[10px] text-muted-foreground",children:K(h*(1-b),t)})]},b)}),a.jsx("line",{x1:i,y1:l+d,x2:r-c,y2:l+d,stroke:"#aebbc5"}),a.jsx("polyline",{points:m.map(b=>`${b.x},${b.y}`).join(" "),fill:"none",stroke:"#1f5f85",strokeWidth:"4",strokeLinejoin:"round",strokeLinecap:"round"}),p&&a.jsx("line",{x1:p.x,y1:l,x2:p.x,y2:l+d,stroke:"#1f5f85",strokeDasharray:"3 4",opacity:"0.45"}),m.map((b,x)=>a.jsxs("g",{children:[a.jsx("circle",{cx:b.x,cy:b.y,r:s===x?7:5,fill:"#1f5f85",stroke:"white",strokeWidth:"2"}),a.jsx("text",{x:b.x,y:o-17,textAnchor:"middle",fill:"currentColor",className:"text-[11px] text-muted-foreground",children:b.label})]},b.key))]}),p&&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:`${p.x/r*100}%`,top:`${Math.max(p.y/o*100-4,2)}%`,transform:p.x>r*.75?"translate(-100%, -100%)":"translate(-50%, -100%)"},children:[a.jsx("p",{className:"text-xs font-semibold",children:p.label}),a.jsx("p",{className:"mt-1 text-sm font-bold text-primary",children:K(p.value,t)}),p.details?.slice(0,5).map(b=>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:b.label}),a.jsx("span",{children:K(b.value,t)})]},b.label))]})]})}const Br=e=>e.length>16?`${e.slice(0,14)}...`:e,xf=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t||"USD",notation:"compact",maximumFractionDigits:1}).format(e);function bf({title:e,items:t,currency:s}){const o={top:38,right:18,bottom:72,left:76},i=720-o.left-o.right,c=320-o.top-o.bottom,l=Math.max(...t.map(d=>d.amount),1),u=i/t.length,f=Math.min(56,u*.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(d=>{const h=o.top+c-d*c;return a.jsxs("g",{children:[a.jsx("line",{x1:o.left,y1:h,x2:720-o.right,y2:h,stroke:"currentColor",opacity:d===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:xf(l*d,s)})]},d)}),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((d,h)=>{const m=o.left+u*h+u/2,p=Math.max(d.amount/l*c,3),g=o.top+c-p;return a.jsxs("g",{tabIndex:0,"aria-label":`${d.label}: ${K(d.amount,s)}`,className:"outline-none focus-visible:opacity-75",children:[a.jsxs("title",{children:[d.label,": ",K(d.amount,s)]}),a.jsx("rect",{x:m-f/2,y:g,width:f,height:p,rx:"4",className:"fill-primary opacity-80 transition-opacity hover:opacity-100"}),a.jsx("text",{x:m,y:Math.max(g-8,16),textAnchor:"middle",fill:"currentColor",fontSize:"11",fontWeight:"600",children:K(d.amount,s)}),a.jsx("text",{x:m,y:278,textAnchor:"middle",fill:"currentColor",opacity:"0.72",fontSize:"11",children:Br(d.label)}),d.accountId&&a.jsx("text",{x:m,y:295,textAnchor:"middle",fill:"currentColor",opacity:"0.55",fontSize:"9",children:Br(d.accountId)})]},d.key||d.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 (",s,")"]})]})}const Ca="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 tn({title:e,icon:t,items:s,currency:n}){const[r,o]=E.useState("chart"),i=s.slice(0,6),c=Math.max(...i.map(l=>l.amount),1);return a.jsxs(de,{className:"min-w-0",children:[a.jsxs(je,{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":r==="chart",title:"Bar chart",className:`rounded p-1.5 ${r==="chart"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"}`,children:a.jsx(Id,{className:"h-4 w-4"})}),a.jsx("button",{type:"button",onClick:()=>o("list"),"aria-label":`Show ${e} as list`,"aria-pressed":r==="list",title:"List",className:`rounded p-1.5 ${r==="list"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"}`,children:a.jsx(su,{className:"h-4 w-4"})})]})]}),a.jsx(ue,{children:i.length?r==="chart"?a.jsx(bf,{title:e,items:i,currency:n}):a.jsx("div",{className:"space-y-3",children:i.map(l=>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:l.label,children:[l.label,l.accountId?a.jsxs("span",{className:"ml-1 text-xs",children:["(",l.accountId,")"]}):null]}),a.jsx("span",{className:"shrink-0 font-medium",children:K(l.amount,n)})]}),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:`${l.amount/c*100}%`}})})]},l.key||l.label))}):a.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No cost data for this period."})})]})}function yf(){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(de,{className:Ca,children:[a.jsx(je,{className:"pb-2",children:a.jsx("div",{className:"h-3 w-24 animate-pulse rounded bg-muted"})}),a.jsxs(ue,{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(de,{children:[a.jsx(je,{children:a.jsx("div",{className:"h-4 w-36 animate-pulse rounded bg-muted"})}),a.jsx(ue,{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(de,{children:[a.jsx(je,{children:a.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-muted"})}),a.jsx(ue,{className:"space-y-4",children:Array.from({length:5},(s,n)=>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"})]},n))})]},t))})]})}function vf({data:e,period:t,selectedMonth:s}){const n=e.topServices[0],r=e.topAccounts[0],o=new Date,[i,c]=s.split("-").map(Number),l=t==="monthly"?new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric"}).format(new Date(i,c-1,1)):String(o.getFullYear()),u=[{label:"Total cost",value:a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"block",children:K(e.totalCost,e.currency)}),a.jsxs("span",{className:"mt-1 block text-sm font-medium text-muted-foreground",children:["Accounts: ",e.activeAccounts]})]}),helper:l,icon:a.jsx(sa,{})},{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:`${l} across all accounts`,icon:a.jsx(Cs,{})},{label:"Highest cost service",value:n?a.jsx("span",{className:"whitespace-pre-line text-sm",children:`Service - ${n.label}
14
+ `+o)}}catch{}}throw n}}_request(t,s){typeof t=="string"?(s=s||{},s.url=t):s=t||{},s=lt(this.defaults,s);const{transitional:n,paramsSerializer:r,headers:o}=s;n!==void 0&&ps.assertOptions(n,{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),r!=null&&(v.isFunction(r)?s.paramsSerializer={serialize:r}:ps.assertOptions(r,{encode:ge.function,serialize:ge.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),ps.assertOptions(s,{baseUrl:ge.spelling("baseURL"),withXsrfToken:ge.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let i=o&&v.merge(o.common,o[s.method]);o&&v.forEach(["delete","get","head","post","put","patch","query","common"],p=>{delete o[p]}),s.headers=be.concat(i,o);const c=[];let l=!0;this.interceptors.request.forEach(function(g){if(typeof g.runWhen=="function"&&g.runWhen(s)===!1)return;l=l&&g.synchronous;const b=s.transitional||Nn;b&&b.legacyInterceptorReqResOrdering?c.unshift(g.fulfilled,g.rejected):c.push(g.fulfilled,g.rejected)});const u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let f,d=0,h;if(!l){const p=[Ar.bind(this),void 0];for(p.unshift(...c),p.push(...u),h=p.length,f=Promise.resolve(s);d<h;)f=f.then(p[d++],p[d++]);return f}h=c.length;let m=s;for(;d<h;){const p=c[d++],g=c[d++];try{m=p(m)}catch(b){g.call(this,b);break}}try{f=Ar.call(this,m)}catch(p){return Promise.reject(p)}for(d=0,h=u.length;d<h;)f=f.then(u[d++],u[d++]);return f}getUri(t){t=lt(this.defaults,t);const s=Ho(t.baseURL,t.url,t.allowAbsoluteUrls,t);return $o(s,t.params,t.paramsSerializer)}};v.forEach(["delete","get","head","options"],function(t){at.prototype[t]=function(s,n){return this.request(lt(n||{},{method:t,url:s,data:n&&v.hasOwnProp(n,"data")?n.data:void 0}))}});v.forEach(["post","put","patch","query"],function(t){function s(n){return function(o,i,c){return this.request(lt(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}at.prototype[t]=s(),t!=="query"&&(at.prototype[t+"Form"]=s(!0))});let jd=class Yo{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(o){s=o});const n=this;this.promise.then(r=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](r);n._listeners=null}),this.promise.then=r=>{let o;const i=new Promise(c=>{n.subscribe(c),o=c}).then(r);return i.cancel=function(){n.unsubscribe(o)},i},t(function(o,i,c){n.reason||(n.reason=new Yt(o,i,c),s(n.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 s=this._listeners.indexOf(t);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const t=new AbortController,s=n=>{t.abort(n)};return this.subscribe(s),t.signal.unsubscribe=()=>this.unsubscribe(s),t.signal}static source(){let t;return{token:new Yo(function(r){t=r}),cancel:t}}};function Rd(e){return function(s){return e.apply(null,s)}}function Nd(e){return v.isObject(e)&&e.isAxiosError===!0}const mn={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(mn).forEach(([e,t])=>{mn[t]=e});function Jo(e){const t=new at(e),s=Co(at.prototype.request,t);return v.extend(s,at.prototype,t,{allOwnKeys:!0}),v.extend(s,t,null,{allOwnKeys:!0}),s.create=function(r){return Jo(lt(e,r))},s}const ae=Jo(Kt);ae.Axios=at;ae.CanceledError=Yt;ae.CancelToken=jd;ae.isCancel=Vo;ae.VERSION=_n;ae.toFormData=Os;ae.AxiosError=A;ae.Cancel=ae.CanceledError;ae.all=function(t){return Promise.all(t)};ae.spread=Rd;ae.isAxiosError=Nd;ae.mergeConfig=lt;ae.AxiosHeaders=be;ae.formToJSON=e=>zo(v.isHTMLForm(e)?new FormData(e):e);ae.getAdapter=Ko.getAdapter;ae.HttpStatusCode=mn;ae.default=ae;const{Axios:ih,AxiosError:ch,CanceledError:lh,isCancel:dh,CancelToken:uh,VERSION:fh,all:hh,Cancel:mh,isAxiosError:ph,spread:gh,toFormData:xh,AxiosHeaders:bh,HttpStatusCode:yh,formToJSON:vh,getAdapter:wh,mergeConfig:Sh,create:jh}=ae,se=ae.create({baseURL:"/api/v1/cost"});function Xo(e,t){se.defaults.baseURL=`${e.replace(/\/$/,"")}/cost`,t?se.defaults.headers.common.Authorization=`Bearer ${t}`:delete se.defaults.headers.common.Authorization}function Cd(e){e.interceptors.request.use(t=>{if(typeof window<"u"){const s=window.localStorage.getItem("access_token");s?(t.headers=t.headers||{},t.headers.Authorization=`Bearer ${s}`):t.headers&&delete t.headers.Authorization}return t})}const _d=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),kd=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,s,n)=>n?n.toUpperCase():s.toLowerCase()),Or=e=>{const t=kd(e);return t.charAt(0).toUpperCase()+t.slice(1)},Zo=(...e)=>e.filter((t,s,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===s).join(" ").trim(),Ed=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Pd={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 Ad=E.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:o,iconNode:i,...c},l)=>E.createElement("svg",{ref:l,...Pd,width:t,height:t,stroke:e,strokeWidth:n?Number(s)*24/Number(t):s,className:Zo("lucide",r),...!o&&!Ed(c)&&{"aria-hidden":"true"},...c},[...i.map(([u,f])=>E.createElement(u,f)),...Array.isArray(o)?o:[o]]));const ee=(e,t)=>{const s=E.forwardRef(({className:n,...r},o)=>E.createElement(Ad,{ref:o,iconNode:t,className:Zo(`lucide-${_d(Or(e))}`,`lucide-${e}`,n),...r}));return s.displayName=Or(e),s};const Td=[["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"}]],Qo=ee("building-2",Td);const Od=[["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"}]],ea=ee("calendar-clock",Od);const Ld=[["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"}]],Id=ee("chart-column",Ld);const Md=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Dd=ee("chevron-down",Md);const Fd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ud=ee("chevron-left",Fd);const $d=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Bd=ee("chevron-right",$d);const zd=[["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"}]],dt=ee("circle-alert",zd);const Vd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Wd=ee("circle-check",Vd);const Hd=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],Cs=ee("cloud",Hd);const qd=[["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"}]],ta=ee("database",qd);const Gd=[["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"}]],sa=ee("dollar-sign",Gd);const Kd=[["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"}]],En=ee("download",Kd);const Yd=[["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"}]],na=ee("external-link",Yd);const Jd=[["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"}]],Xd=ee("eye",Jd);const Zd=[["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"}]],Qd=ee("file-down",Zd);const eu=[["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"}]],ra=ee("file-text",eu);const tu=[["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"}]],su=ee("list",tu);const nu=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],st=ee("loader-circle",nu);const ru=[["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"}]],ou=ee("map-pin",ru);const au=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],iu=ee("plus",au);const cu=[["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"}]],St=ee("refresh-cw",cu);const lu=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Pn=ee("search",lu);const du=[["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"}]],oa=ee("server",du);const uu=[["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"}]],aa=ee("settings-2",uu);const fu=[["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"}]],Lr=ee("sparkles",fu);const hu=[["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"}]],ia=ee("trash-2",hu);const mu=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],pu=ee("trending-down",mu);const gu=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],ca=ee("trending-up",gu);const xu=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wt=ee("x",xu);function la(e){var t,s,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(s=la(e[t]))&&(n&&(n+=" "),n+=s)}else for(s in e)e[s]&&(n&&(n+=" "),n+=s);return n}function bu(){for(var e,t,s=0,n="",r=arguments.length;s<r;s++)(e=arguments[s])&&(t=la(e))&&(n&&(n+=" "),n+=t);return n}const yu=(e,t)=>{const s=new Array(e.length+t.length);for(let n=0;n<e.length;n++)s[n]=e[n];for(let n=0;n<t.length;n++)s[e.length+n]=t[n];return s},vu=(e,t)=>({classGroupId:e,validator:t}),da=(e=new Map,t=null,s)=>({nextPart:e,validators:t,classGroupId:s}),_s="-",Ir=[],wu="arbitrary..",Su=e=>{const t=Ru(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return ju(i);const c=i.split(_s),l=c[0]===""&&c.length>1?1:0;return ua(c,l,t)},getConflictingClassGroupIds:(i,c)=>{if(c){const l=n[i],u=s[i];return l?u?yu(u,l):l:u||Ir}return s[i]||Ir}}},ua=(e,t,s)=>{if(e.length-t===0)return s.classGroupId;const r=e[t],o=s.nextPart.get(r);if(o){const u=ua(e,t+1,o);if(u)return u}const i=s.validators;if(i===null)return;const c=t===0?e.join(_s):e.slice(t).join(_s),l=i.length;for(let u=0;u<l;u++){const f=i[u];if(f.validator(c))return f.classGroupId}},ju=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),s=t.indexOf(":"),n=t.slice(0,s);return n?wu+n:void 0})(),Ru=e=>{const{theme:t,classGroups:s}=e;return Nu(s,t)},Nu=(e,t)=>{const s=da();for(const n in e){const r=e[n];An(r,s,n,t)}return s},An=(e,t,s,n)=>{const r=e.length;for(let o=0;o<r;o++){const i=e[o];Cu(i,t,s,n)}},Cu=(e,t,s,n)=>{if(typeof e=="string"){_u(e,t,s);return}if(typeof e=="function"){ku(e,t,s,n);return}Eu(e,t,s,n)},_u=(e,t,s)=>{const n=e===""?t:fa(t,e);n.classGroupId=s},ku=(e,t,s,n)=>{if(Pu(e)){An(e(n),t,s,n);return}t.validators===null&&(t.validators=[]),t.validators.push(vu(s,e))},Eu=(e,t,s,n)=>{const r=Object.entries(e),o=r.length;for(let i=0;i<o;i++){const[c,l]=r[i];An(l,fa(t,c),s,n)}},fa=(e,t)=>{let s=e;const n=t.split(_s),r=n.length;for(let o=0;o<r;o++){const i=n[o];let c=s.nextPart.get(i);c||(c=da(),s.nextPart.set(i,c)),s=c}return s},Pu=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Au=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,s=Object.create(null),n=Object.create(null);const r=(o,i)=>{s[o]=i,t++,t>e&&(t=0,n=s,s=Object.create(null))};return{get(o){let i=s[o];if(i!==void 0)return i;if((i=n[o])!==void 0)return r(o,i),i},set(o,i){o in s?s[o]=i:r(o,i)}}},pn="!",Mr=":",Tu=[],Dr=(e,t,s,n,r)=>({modifiers:e,hasImportantModifier:t,baseClassName:s,maybePostfixModifierPosition:n,isExternal:r}),Ou=e=>{const{prefix:t,experimentalParseClassName:s}=e;let n=r=>{const o=[];let i=0,c=0,l=0,u;const f=r.length;for(let g=0;g<f;g++){const b=r[g];if(i===0&&c===0){if(b===Mr){o.push(r.slice(l,g)),l=g+1;continue}if(b==="/"){u=g;continue}}b==="["?i++:b==="]"?i--:b==="("?c++:b===")"&&c--}const d=o.length===0?r:r.slice(l);let h=d,m=!1;d.endsWith(pn)?(h=d.slice(0,-1),m=!0):d.startsWith(pn)&&(h=d.slice(1),m=!0);const p=u&&u>l?u-l:void 0;return Dr(o,m,h,p)};if(t){const r=t+Mr,o=n;n=i=>i.startsWith(r)?o(i.slice(r.length)):Dr(Tu,!1,i,void 0,!0)}if(s){const r=n;n=o=>s({className:o,parseClassName:r})}return n},Lu=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((s,n)=>{t.set(s,1e6+n)}),s=>{const n=[];let r=[];for(let o=0;o<s.length;o++){const i=s[o],c=i[0]==="[",l=t.has(i);c||l?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(i)):r.push(i)}return r.length>0&&(r.sort(),n.push(...r)),n}},Iu=e=>({cache:Au(e.cacheSize),parseClassName:Ou(e),sortModifiers:Lu(e),postfixLookupClassGroupIds:Mu(e),...Su(e)}),Mu=e=>{const t=Object.create(null),s=e.postfixLookupClassGroups;if(s)for(let n=0;n<s.length;n++)t[s[n]]=!0;return t},Du=/\s+/,Fu=(e,t)=>{const{parseClassName:s,getClassGroupId:n,getConflictingClassGroupIds:r,sortModifiers:o,postfixLookupClassGroupIds:i}=t,c=[],l=e.trim().split(Du);let u="";for(let f=l.length-1;f>=0;f-=1){const d=l[f],{isExternal:h,modifiers:m,hasImportantModifier:p,baseClassName:g,maybePostfixModifierPosition:b}=s(d);if(h){u=d+(u.length>0?" "+u:u);continue}let x=!!b,y;if(x){const j=g.substring(0,b);y=n(j);const w=y&&i[y]?n(g):void 0;w&&w!==y&&(y=w,x=!1)}else y=n(g);if(!y){if(!x){u=d+(u.length>0?" "+u:u);continue}if(y=n(g),!y){u=d+(u.length>0?" "+u:u);continue}x=!1}const S=m.length===0?"":m.length===1?m[0]:o(m).join(":"),N=p?S+pn:S,C=N+y;if(c.indexOf(C)>-1)continue;c.push(C);const _=r(y,x);for(let j=0;j<_.length;++j){const w=_[j];c.push(N+w)}u=d+(u.length>0?" "+u:u)}return u},Uu=(...e)=>{let t=0,s,n,r="";for(;t<e.length;)(s=e[t++])&&(n=ha(s))&&(r&&(r+=" "),r+=n);return r},ha=e=>{if(typeof e=="string")return e;let t,s="";for(let n=0;n<e.length;n++)e[n]&&(t=ha(e[n]))&&(s&&(s+=" "),s+=t);return s},$u=(e,...t)=>{let s,n,r,o;const i=l=>{const u=t.reduce((f,d)=>d(f),e());return s=Iu(u),n=s.cache.get,r=s.cache.set,o=c,c(l)},c=l=>{const u=n(l);if(u)return u;const f=Fu(l,s);return r(l,f),f};return o=i,(...l)=>o(Uu(...l))},Bu=[],ce=e=>{const t=s=>s[e]||Bu;return t.isThemeGetter=!0,t},ma=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,pa=/^\((?:(\w[\w-]*):)?(.+)\)$/i,zu=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Vu=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Wu=/\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$/,Hu=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,qu=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Gu=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Be=e=>zu.test(e),q=e=>!!e&&!Number.isNaN(Number(e)),Oe=e=>!!e&&Number.isInteger(Number(e)),en=e=>e.endsWith("%")&&q(e.slice(0,-1)),Me=e=>Vu.test(e),ga=()=>!0,Ku=e=>Wu.test(e)&&!Hu.test(e),Tn=()=>!1,Yu=e=>qu.test(e),Ju=e=>Gu.test(e),Xu=e=>!L(e)&&!M(e),Zu=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)),Qu=e=>Ge(e,ya,Tn),L=e=>ma.test(e),Je=e=>Ge(e,va,Ku),Fr=e=>Ge(e,cf,q),ef=e=>Ge(e,Sa,ga),tf=e=>Ge(e,wa,Tn),Ur=e=>Ge(e,xa,Tn),sf=e=>Ge(e,ba,Ju),rs=e=>Ge(e,ja,Yu),M=e=>pa.test(e),It=e=>ft(e,va),nf=e=>ft(e,wa),$r=e=>ft(e,xa),rf=e=>ft(e,ya),of=e=>ft(e,ba),os=e=>ft(e,ja,!0),af=e=>ft(e,Sa,!0),Ge=(e,t,s)=>{const n=ma.exec(e);return n?n[1]?t(n[1]):s(n[2]):!1},ft=(e,t,s=!1)=>{const n=pa.exec(e);return n?n[1]?t(n[1]):s:!1},xa=e=>e==="position"||e==="percentage",ba=e=>e==="image"||e==="url",ya=e=>e==="length"||e==="size"||e==="bg-size",va=e=>e==="length",cf=e=>e==="number",wa=e=>e==="family-name",Sa=e=>e==="number"||e==="weight",ja=e=>e==="shadow",lf=()=>{const e=ce("color"),t=ce("font"),s=ce("text"),n=ce("font-weight"),r=ce("tracking"),o=ce("leading"),i=ce("breakpoint"),c=ce("container"),l=ce("spacing"),u=ce("radius"),f=ce("shadow"),d=ce("inset-shadow"),h=ce("text-shadow"),m=ce("drop-shadow"),p=ce("blur"),g=ce("perspective"),b=ce("aspect"),x=ce("ease"),y=ce("animate"),S=()=>["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"],C=()=>[...N(),M,L],_=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],w=()=>[M,L,l],P=()=>[Be,"full","auto",...w()],I=()=>[Oe,"none","subgrid",M,L],k=()=>["auto",{span:["full",Oe,M,L]},Oe,M,L],T=()=>[Oe,"auto",M,L],Z=()=>["auto","min","max","fr",M,L],z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],J=()=>["start","end","center","stretch","center-safe","end-safe"],Y=()=>["auto",...w()],Q=()=>[Be,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...w()],he=()=>[Be,"screen","full","dvw","lvw","svw","min","max","fit",...w()],me=()=>[Be,"screen","full","lh","dvh","lvh","svh","min","max","fit",...w()],O=()=>[e,M,L],R=()=>[...N(),$r,Ur,{position:[M,L]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],H=()=>["auto","cover","contain",rf,Qu,{size:[M,L]}],G=()=>[en,It,Je],W=()=>["","none","full",u,M,L],U=()=>["",q,It,Je],D=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],V=()=>[q,en,$r,Ur],ie=()=>["","none",p,M,L],le=()=>["none",q,M,L],te=()=>["none",q,M,L],Ce=()=>[q,M,L],Ne=()=>[Be,"full",...w()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Me],breakpoint:[Me],color:[ga],container:[Me],"drop-shadow":[Me],ease:["in","out","in-out"],font:[Xu],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Me],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Me],shadow:[Me],spacing:["px",q],text:[Me],"text-shadow":[Me],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Be,L,M,b]}],container:["container"],"container-type":[{"@container":["","normal","size",M,L]}],"container-named":[Zu],columns:[{columns:[q,L,M,c]}],"break-after":[{"break-after":S()}],"break-before":[{"break-before":S()}],"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:C()}],overflow:[{overflow:_()}],"overflow-x":[{"overflow-x":_()}],"overflow-y":[{"overflow-y":_()}],overscroll:[{overscroll:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[Oe,"auto",M,L]}],basis:[{basis:[Be,"full","auto",c,...w()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[q,Be,"auto","initial","none",L]}],grow:[{grow:["",q,M,L]}],shrink:[{shrink:["",q,M,L]}],order:[{order:[Oe,"first","last","none",M,L]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:k()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:k()}],"row-start":[{"row-start":T()}],"row-end":[{"row-end":T()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Z()}],"auto-rows":[{"auto-rows":Z()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...z(),"normal"]}],"justify-items":[{"justify-items":[...J(),"normal"]}],"justify-self":[{"justify-self":["auto",...J()]}],"align-content":[{content:["normal",...z()]}],"align-items":[{items:[...J(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...J(),{baseline:["","last"]}]}],"place-content":[{"place-content":z()}],"place-items":[{"place-items":[...J(),"baseline"]}],"place-self":[{"place-self":["auto",...J()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],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":w()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":w()}],"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",s,It,Je]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,af,ef]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",en,L]}],"font-family":[{font:[nf,tf,t]}],"font-features":[{"font-features":[L]}],"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:[r,M,L]}],"line-clamp":[{"line-clamp":[q,"none",M,Fr]}],leading:[{leading:[o,...w()]}],"list-image":[{"list-image":["none",M,L]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",M,L]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:O()}],"text-color":[{text:O()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...D(),"wavy"]}],"text-decoration-thickness":[{decoration:[q,"from-font","auto",M,Je]}],"text-decoration-color":[{decoration:O()}],"underline-offset":[{"underline-offset":[q,"auto",M,L]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:w()}],"tab-size":[{tab:[Oe,M,L]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",M,L]}],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",M,L]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:R()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:H()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Oe,M,L],radial:["",M,L],conic:[Oe,M,L]},of,sf]}],"bg-color":[{bg:O()}],"gradient-from-pos":[{from:G()}],"gradient-via-pos":[{via:G()}],"gradient-to-pos":[{to:G()}],"gradient-from":[{from:O()}],"gradient-via":[{via:O()}],"gradient-to":[{to:O()}],rounded:[{rounded:W()}],"rounded-s":[{"rounded-s":W()}],"rounded-e":[{"rounded-e":W()}],"rounded-t":[{"rounded-t":W()}],"rounded-r":[{"rounded-r":W()}],"rounded-b":[{"rounded-b":W()}],"rounded-l":[{"rounded-l":W()}],"rounded-ss":[{"rounded-ss":W()}],"rounded-se":[{"rounded-se":W()}],"rounded-ee":[{"rounded-ee":W()}],"rounded-es":[{"rounded-es":W()}],"rounded-tl":[{"rounded-tl":W()}],"rounded-tr":[{"rounded-tr":W()}],"rounded-br":[{"rounded-br":W()}],"rounded-bl":[{"rounded-bl":W()}],"border-w":[{border:U()}],"border-w-x":[{"border-x":U()}],"border-w-y":[{"border-y":U()}],"border-w-s":[{"border-s":U()}],"border-w-e":[{"border-e":U()}],"border-w-bs":[{"border-bs":U()}],"border-w-be":[{"border-be":U()}],"border-w-t":[{"border-t":U()}],"border-w-r":[{"border-r":U()}],"border-w-b":[{"border-b":U()}],"border-w-l":[{"border-l":U()}],"divide-x":[{"divide-x":U()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":U()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...D(),"hidden","none"]}],"divide-style":[{divide:[...D(),"hidden","none"]}],"border-color":[{border:O()}],"border-color-x":[{"border-x":O()}],"border-color-y":[{"border-y":O()}],"border-color-s":[{"border-s":O()}],"border-color-e":[{"border-e":O()}],"border-color-bs":[{"border-bs":O()}],"border-color-be":[{"border-be":O()}],"border-color-t":[{"border-t":O()}],"border-color-r":[{"border-r":O()}],"border-color-b":[{"border-b":O()}],"border-color-l":[{"border-l":O()}],"divide-color":[{divide:O()}],"outline-style":[{outline:[...D(),"none","hidden"]}],"outline-offset":[{"outline-offset":[q,M,L]}],"outline-w":[{outline:["",q,It,Je]}],"outline-color":[{outline:O()}],shadow:[{shadow:["","none",f,os,rs]}],"shadow-color":[{shadow:O()}],"inset-shadow":[{"inset-shadow":["none",d,os,rs]}],"inset-shadow-color":[{"inset-shadow":O()}],"ring-w":[{ring:U()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:O()}],"ring-offset-w":[{"ring-offset":[q,Je]}],"ring-offset-color":[{"ring-offset":O()}],"inset-ring-w":[{"inset-ring":U()}],"inset-ring-color":[{"inset-ring":O()}],"text-shadow":[{"text-shadow":["none",h,os,rs]}],"text-shadow-color":[{"text-shadow":O()}],opacity:[{opacity:[q,M,L]}],"mix-blend":[{"mix-blend":[...X(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":X()}],"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":[q]}],"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":O()}],"mask-image-linear-to-color":[{"mask-linear-to":O()}],"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":O()}],"mask-image-t-to-color":[{"mask-t-to":O()}],"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":O()}],"mask-image-r-to-color":[{"mask-r-to":O()}],"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":O()}],"mask-image-b-to-color":[{"mask-b-to":O()}],"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":O()}],"mask-image-l-to-color":[{"mask-l-to":O()}],"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":O()}],"mask-image-x-to-color":[{"mask-x-to":O()}],"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":O()}],"mask-image-y-to-color":[{"mask-y-to":O()}],"mask-image-radial":[{"mask-radial":[M,L]}],"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":O()}],"mask-image-radial-to-color":[{"mask-radial-to":O()}],"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":[q]}],"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":O()}],"mask-image-conic-to-color":[{"mask-conic-to":O()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:R()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:H()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",M,L]}],filter:[{filter:["","none",M,L]}],blur:[{blur:ie()}],brightness:[{brightness:[q,M,L]}],contrast:[{contrast:[q,M,L]}],"drop-shadow":[{"drop-shadow":["","none",m,os,rs]}],"drop-shadow-color":[{"drop-shadow":O()}],grayscale:[{grayscale:["",q,M,L]}],"hue-rotate":[{"hue-rotate":[q,M,L]}],invert:[{invert:["",q,M,L]}],saturate:[{saturate:[q,M,L]}],sepia:[{sepia:["",q,M,L]}],"backdrop-filter":[{"backdrop-filter":["","none",M,L]}],"backdrop-blur":[{"backdrop-blur":ie()}],"backdrop-brightness":[{"backdrop-brightness":[q,M,L]}],"backdrop-contrast":[{"backdrop-contrast":[q,M,L]}],"backdrop-grayscale":[{"backdrop-grayscale":["",q,M,L]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[q,M,L]}],"backdrop-invert":[{"backdrop-invert":["",q,M,L]}],"backdrop-opacity":[{"backdrop-opacity":[q,M,L]}],"backdrop-saturate":[{"backdrop-saturate":[q,M,L]}],"backdrop-sepia":[{"backdrop-sepia":["",q,M,L]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",M,L]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[q,"initial",M,L]}],ease:[{ease:["linear","initial",x,M,L]}],delay:[{delay:[q,M,L]}],animate:[{animate:["none",y,M,L]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,M,L]}],"perspective-origin":[{"perspective-origin":C()}],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:Ce()}],"skew-x":[{"skew-x":Ce()}],"skew-y":[{"skew-y":Ce()}],transform:[{transform:[M,L,"","none","gpu","cpu"]}],"transform-origin":[{origin:C()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ne()}],"translate-x":[{"translate-x":Ne()}],"translate-y":[{"translate-y":Ne()}],"translate-z":[{"translate-z":Ne()}],"translate-none":["translate-none"],zoom:[{zoom:[Oe,M,L]}],accent:[{accent:O()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:O()}],"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",M,L]}],"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":O()}],"scrollbar-track-color":[{"scrollbar-track":O()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"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",M,L]}],fill:[{fill:["none",...O()]}],"stroke-w":[{stroke:[q,It,Je,Fr]}],stroke:[{stroke:["none",...O()]}],"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"]}},df=$u(lf);function Ct(...e){return df(bu(e))}function K(e,t="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:2}).format(e)}const de=$.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Ct("rounded-xl border bg-card text-card-foreground shadow",e),...t}));de.displayName="Card";const je=$.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Ct("flex flex-col space-y-1.5 p-6",e),...t}));je.displayName="CardHeader";const Pe=$.forwardRef(({className:e,...t},s)=>a.jsx("h3",{ref:s,className:Ct("font-semibold leading-none tracking-tight",e),...t}));Pe.displayName="CardTitle";const uf=$.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Ct("text-sm text-muted-foreground",e),...t}));uf.displayName="CardDescription";const ue=$.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Ct("p-6 pt-0",e),...t}));ue.displayName="CardContent";const ff=$.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Ct("flex items-center p-6 pt-0",e),...t}));ff.displayName="CardFooter";function ks({status:e,error:t}){const s=e?.action==="connect_source"||e?.state==="not_configured",n=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(dt,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"}):a.jsx(ta,{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:s?"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:n}),a.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[a.jsxs(Ss,{to:s?"/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(na,{className:"h-4 w-4"}),s?"Connect AWS source":"Review CUR discovery"]}),!s&&a.jsx(Ss,{to:"/sources",className:"rounded-md border px-3 py-2 text-sm font-medium hover:bg-muted",children:"Cost sources"})]})]})]})})}const oe={getOverview:e=>se.get("/overview",{params:e}).then(t=>t.data),getAccounts:e=>se.get("/accounts",{params:e}).then(t=>t.data),getReports:e=>se.get("/reports",{params:e}).then(t=>t.data),getFilterOptions:e=>se.get("/filter-options",{params:{start:e?.start,end:e?.end,tagKey:e?.filterTagKey,managementAccountId:e?.managementAccountId}}).then(t=>t.data),getTags:e=>se.get("/tags",{params:e}).then(t=>t.data),getDataStatus:e=>se.get("/data-status",{params:e}).then(t=>t.data),getAnalysisStatus:e=>se.get("/analysis/status",{params:e}).then(t=>t.data),getLatestAnalysis:e=>se.get("/analysis/latest",{params:e}).then(t=>t.data.analysis),getAnalysisSchedule:e=>se.get("/analysis/schedule",{params:e}).then(t=>t.data),updateAnalysisSchedule:(e,t)=>se.put("/analysis/schedule",e,{params:t}).then(s=>s.data),getAnalysisReports:e=>se.get("/analysis/reports",{params:e}).then(t=>t.data.reports),removeAnalysisReport:e=>se.delete(`/analysis/reports/${e}`).then(t=>t.data),downloadAnalysisPdf:e=>se.get(`/analysis/reports/${e}/pdf`,{responseType:"blob"}).then(t=>t.data),getSources:()=>se.get("/sources").then(e=>e.data),createSource:e=>se.post("/sources",e).then(t=>t.data),getSourceStatus:e=>se.get(`/sources/${e}/status`).then(t=>t.data),verifySource:e=>se.post(`/sources/${e}/verify`).then(t=>t.data),removeSource:(e,t)=>se.delete(`/sources/${e}`,{data:{deleteAwsResources:t}}).then(s=>s.data),downloadSourceTemplate:e=>se.get(`/sources/${e}/template`,{responseType:"blob"}).then(t=>t.data),getCurDiscovery:e=>se.get("/cur-discovery",{params:e}).then(t=>t.data)},Ra=E.createContext("user"),hf=Ra.Provider,mf=()=>E.useContext(Ra),Na=E.createContext(null);function pf({tenantId:e="default",children:t}){const s=`meyi-cost:selected-management-account:${e||"default"}`,[n,r]=E.useState([]),[o,i]=E.useState(""),[c,l]=E.useState(!0),u=E.useCallback(async()=>{l(!0);try{const m=((await oe.getSources()).sources||[]).filter(p=>!!p.managementAccountId);r(m),i(p=>{const b=window.localStorage.getItem(s)||""||p,x=m.find(S=>S.status==="CONNECTED")||m[0],y=m.some(S=>S.managementAccountId===b)?b:x?.managementAccountId||"";return y?window.localStorage.setItem(s,y):window.localStorage.removeItem(s),y})}catch{r([]),i("")}finally{l(!1)}},[s]);E.useEffect(()=>{u()},[u]);const f=E.useCallback(h=>{/^\d{12}$/.test(h)&&(window.localStorage.setItem(s,h),i(h))},[s]),d=E.useMemo(()=>({sources:n,managementAccountId:o,loading:c,selectManagementAccount:f,refreshSources:u}),[n,o,c,f,u]);return a.jsx(Na.Provider,{value:d,children:t})}function _t(){const e=E.useContext(Na);if(!e)throw new Error("useCostAccount must be used inside CostAccountProvider");return e}function Is(){const{sources:e,managementAccountId:t,loading:s,selectManagementAccount:n}=_t();return e.length?a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx(Qo,{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:r=>n(r.target.value),disabled:s,className:"max-w-72 rounded-md border bg-background px-3 py-2 text-sm shadow-sm disabled:opacity-50",children:e.map(r=>a.jsxs("option",{value:r.managementAccountId||"",children:["Management account ",r.managementAccountId]},r.connectionId))})]}):null}function gf({points:e,currency:t="USD"}){const[s,n]=E.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 r=900,o=260,i=70,c=24,l=22,u=48,f=r-i-c,d=o-l-u,h=Math.max(...e.map(b=>b.value),1),m=e.map((b,x)=>({...b,x:i+(e.length===1?f/2:x*f/(e.length-1)),y:l+d-b.value/h*d})),p=s==null?null:m[s],g=b=>{const x=b.currentTarget.getBoundingClientRect(),y=(b.clientX-x.left)/x.width*r;let S=0;for(let N=1;N<m.length;N+=1)Math.abs(m[N].x-y)<Math.abs(m[S].x-y)&&(S=N);n(S)};return a.jsxs("div",{className:"relative w-full",children:[a.jsxs("svg",{viewBox:`0 0 ${r} ${o}`,className:"h-72 w-full",onMouseMove:g,onMouseLeave:()=>n(null),role:"img","aria-label":"Cost trend line chart",children:[[0,.25,.5,.75,1].map(b=>{const x=l+d*b;return a.jsxs("g",{children:[a.jsx("line",{x1:i,y1:x,x2:r-c,y2:x,stroke:"#d8e0e7",strokeDasharray:"4 4"}),a.jsx("text",{x:i-10,y:x+4,textAnchor:"end",fill:"currentColor",className:"text-[10px] text-muted-foreground",children:K(h*(1-b),t)})]},b)}),a.jsx("line",{x1:i,y1:l+d,x2:r-c,y2:l+d,stroke:"#aebbc5"}),a.jsx("polyline",{points:m.map(b=>`${b.x},${b.y}`).join(" "),fill:"none",stroke:"#1f5f85",strokeWidth:"4",strokeLinejoin:"round",strokeLinecap:"round"}),p&&a.jsx("line",{x1:p.x,y1:l,x2:p.x,y2:l+d,stroke:"#1f5f85",strokeDasharray:"3 4",opacity:"0.45"}),m.map((b,x)=>a.jsxs("g",{children:[a.jsx("circle",{cx:b.x,cy:b.y,r:s===x?7:5,fill:"#1f5f85",stroke:"white",strokeWidth:"2"}),a.jsx("text",{x:b.x,y:o-17,textAnchor:"middle",fill:"currentColor",className:"text-[11px] text-muted-foreground",children:b.label})]},b.key))]}),p&&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:`${p.x/r*100}%`,top:`${Math.max(p.y/o*100-4,2)}%`,transform:p.x>r*.75?"translate(-100%, -100%)":"translate(-50%, -100%)"},children:[a.jsx("p",{className:"text-xs font-semibold",children:p.label}),a.jsx("p",{className:"mt-1 text-sm font-bold text-primary",children:K(p.value,t)}),p.details?.slice(0,5).map(b=>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:b.label}),a.jsx("span",{children:K(b.value,t)})]},b.label))]})]})}const Br=e=>e.length>16?`${e.slice(0,14)}...`:e,xf=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t||"USD",notation:"compact",maximumFractionDigits:1}).format(e);function bf({title:e,items:t,currency:s}){const o={top:38,right:18,bottom:72,left:76},i=720-o.left-o.right,c=320-o.top-o.bottom,l=Math.max(...t.map(d=>d.amount),1),u=i/t.length,f=Math.min(56,u*.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(d=>{const h=o.top+c-d*c;return a.jsxs("g",{children:[a.jsx("line",{x1:o.left,y1:h,x2:720-o.right,y2:h,stroke:"currentColor",opacity:d===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:xf(l*d,s)})]},d)}),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((d,h)=>{const m=o.left+u*h+u/2,p=Math.max(d.amount/l*c,3),g=o.top+c-p;return a.jsxs("g",{tabIndex:0,"aria-label":`${d.label}: ${K(d.amount,s)}`,className:"outline-none focus-visible:opacity-75",children:[a.jsxs("title",{children:[d.label,": ",K(d.amount,s)]}),a.jsx("rect",{x:m-f/2,y:g,width:f,height:p,rx:"4",className:"fill-primary opacity-80 transition-opacity hover:opacity-100"}),a.jsx("text",{x:m,y:Math.max(g-8,16),textAnchor:"middle",fill:"currentColor",fontSize:"11",fontWeight:"600",children:K(d.amount,s)}),a.jsx("text",{x:m,y:278,textAnchor:"middle",fill:"currentColor",opacity:"0.72",fontSize:"11",children:Br(d.label)}),d.accountId&&a.jsx("text",{x:m,y:295,textAnchor:"middle",fill:"currentColor",opacity:"0.55",fontSize:"9",children:Br(d.accountId)})]},d.key||d.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 (",s,")"]})]})}const Ca="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 tn({title:e,icon:t,items:s,currency:n}){const[r,o]=E.useState("chart"),i=s.slice(0,6),c=Math.max(...i.map(l=>l.amount),1);return a.jsxs(de,{className:"min-w-0",children:[a.jsxs(je,{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":r==="chart",title:"Bar chart",className:`rounded p-1.5 ${r==="chart"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"}`,children:a.jsx(Id,{className:"h-4 w-4"})}),a.jsx("button",{type:"button",onClick:()=>o("list"),"aria-label":`Show ${e} as list`,"aria-pressed":r==="list",title:"List",className:`rounded p-1.5 ${r==="list"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"}`,children:a.jsx(su,{className:"h-4 w-4"})})]})]}),a.jsx(ue,{children:i.length?r==="chart"?a.jsx(bf,{title:e,items:i,currency:n}):a.jsx("div",{className:"space-y-3",children:i.map(l=>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:l.label,children:[l.label,l.accountId?a.jsxs("span",{className:"ml-1 text-xs",children:["(",l.accountId,")"]}):null]}),a.jsx("span",{className:"shrink-0 font-medium",children:K(l.amount,n)})]}),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:`${l.amount/c*100}%`}})})]},l.key||l.label))}):a.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No cost data for this period."})})]})}function yf(){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(de,{className:Ca,children:[a.jsx(je,{className:"pb-2",children:a.jsx("div",{className:"h-3 w-24 animate-pulse rounded bg-muted"})}),a.jsxs(ue,{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(de,{children:[a.jsx(je,{children:a.jsx("div",{className:"h-4 w-36 animate-pulse rounded bg-muted"})}),a.jsx(ue,{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(de,{children:[a.jsx(je,{children:a.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-muted"})}),a.jsx(ue,{className:"space-y-4",children:Array.from({length:5},(s,n)=>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"})]},n))})]},t))})]})}function vf({data:e,period:t,selectedMonth:s}){const n=e.topServices[0],r=e.topAccounts[0],o=new Date,[i,c]=s.split("-").map(Number),l=t==="monthly"?new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric"}).format(new Date(i,c-1,1)):String(o.getFullYear()),u=[{label:"Total cost",value:a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"block",children:K(e.totalCost,e.currency)}),a.jsxs("span",{className:"mt-1 block text-sm font-medium text-muted-foreground",children:["Accounts: ",e.activeAccounts]})]}),helper:l,icon:a.jsx(sa,{})},{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:`${l} across all accounts`,icon:a.jsx(Cs,{})},{label:"Highest cost service",value:n?a.jsx("span",{className:"whitespace-pre-line text-sm",children:`Service - ${n.label}
15
15
  Cost - ${K(n.amount,e.currency)}`}):"-",helper:l,icon:a.jsx(oa,{})},{label:"Highest cost account",value:r?a.jsx("span",{className:"whitespace-pre-line text-sm",children:`Account Name - ${r.label}
16
16
  Account Id - ${r.accountId||r.key||"Unknown"}
17
17
  Cost - ${K(r.amount,e.currency)}`}):"-",helper:l,icon:a.jsx(Cs,{})}];return a.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,240px),1fr))] gap-4",children:u.map(f=>a.jsxs(de,{className:Ca,children:[a.jsxs(je,{className:"flex flex-row items-center justify-between pb-2",children:[a.jsx(Pe,{className:"text-xs font-medium text-muted-foreground",children:f.label}),a.jsx("span",{className:"text-muted-foreground [&>svg]:h-4 [&>svg]:w-4",children:f.icon})]}),a.jsxs(ue,{children:[a.jsx("div",{className:"break-words text-base font-semibold leading-snug xl:text-lg",children:f.value}),a.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:f.helper})]})]},f.label))})}function wf(){const e=new Date,t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`,[s,n]=E.useState(null),[r,o]=E.useState(!0),[i,c]=E.useState(null),[l,u]=E.useState(null),[f,d]=E.useState("monthly"),[h,m]=E.useState(t),{managementAccountId:p,loading:g}=_t(),b=E.useRef(0),x=Array.from({length:e.getMonth()+1},(C,_)=>({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(C=f,_=h,j=p)=>{const w=++b.current;o(!0),n(null),c(null);try{let P;if(C==="yearly")P={period:C,start:`${e.getFullYear()}-01-01`};else{const[Z,z]=_.split("-").map(Number),J=_===t?e.getDate():new Date(Z,z,0).getDate();P={period:C,start:`${_}-01`,end:`${_}-${String(J).padStart(2,"0")}`}}const I=j?{managementAccountId:j}:void 0,k=await oe.getDataStatus(I);if(w===b.current&&u(k),!k.ready)return;const T=await oe.getOverview({...P,...I});w===b.current&&n(T)}catch(P){w===b.current&&c(P?.response?.data?.error||P.message||"Failed to load AWS costs")}finally{w===b.current&&o(!1)}};return E.useEffect(()=>{g||y(f,h,p)},[f,h,p,g]),{data:s,dataStatus:l,loading:r||g,error:i,period:f,selectedMonth:h,monthOptions:x,changePeriod:C=>{C!==f&&(o(!0),n(null),d(C))},changeMonth:C=>{C===h||!x.some(_=>_.value===C)||(o(!0),n(null),m(C))},refresh:()=>y(f,h,p)}}function Sf(){const{data:e,dataStatus:t,loading:s,error:n,period:r,selectedMonth:o,monthOptions:i,changePeriod:c,changeMonth:l,refresh:u}=wf();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(sa,{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(Is,{}),r==="monthly"&&a.jsx("select",{"aria-label":"Cost month",value:o,onChange:f=>l(f.target.value),disabled:s,className:"rounded-lg border bg-background px-3 py-2 text-sm shadow-sm disabled:opacity-50",children:i.map(f=>a.jsx("option",{value:f.value,children:f.label},f.value))}),a.jsx("div",{className:"flex rounded-lg border p-1",children:["monthly","yearly"].map(f=>a.jsx("button",{onClick:()=>c(f),className:`rounded-md px-3 py-1.5 text-sm capitalize transition-colors ${r===f?"bg-primary text-primary-foreground":"hover:bg-muted"}`,children:f},f))}),a.jsx("button",{onClick:()=>{u()},disabled:s,className:"rounded-lg border p-2 hover:bg-muted",children:a.jsx(St,{className:`h-4 w-4 ${s?"animate-spin":""}`})})]})]}),n&&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(dt,{className:"h-4 w-4"}),n]}),s?a.jsx(yf,{}):t&&!t.ready?a.jsx(ks,{status:t}):n&&!e?a.jsx(ks,{status:t,error:n}):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(vf,{data:e,period:r,selectedMonth:o}),e.message&&!/historical data beyond 14 months/i.test(e.message)&&a.jsx(de,{children:a.jsx(ue,{className:"py-8 text-center text-sm text-muted-foreground",children:e.message})}),a.jsxs(de,{children:[a.jsxs(je,{className:"flex flex-row items-center gap-2",children:[a.jsx(ca,{className:"h-4 w-4 text-primary"}),a.jsxs(Pe,{className:"text-sm",children:["Cost Trend - ",r==="monthly"?"Monthly":"Yearly"]})]}),a.jsx(ue,{children:a.jsx(gf,{points:e.trends.map(f=>({key:f.month,label:r==="yearly"?f.month.slice(0,4):new Date(`${f.month}T00:00:00Z`).toLocaleDateString(void 0,{month:"short",year:"2-digit"}),value:f.amount})),currency:e.currency})})]}),a.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[a.jsx(tn,{title:"Top services",icon:a.jsx(oa,{className:"h-4 w-4"}),items:e.topServices,currency:e.currency}),a.jsx(tn,{title:"AWS accounts",icon:a.jsx(Qo,{className:"h-4 w-4"}),items:e.topAccounts,currency:e.currency}),a.jsx(tn,{title:"Regional distribution",icon:a.jsx(ou,{className:"h-4 w-4"}),items:e.topRegions,currency:e.currency})]})]}):null]})}const as=["#6264e9","#eb67ad","#31c39a","#f29a05","#579bea","#9078ed","#f7842c","#24b9ad","#8ac926","#ffca3a","#6a4c93","#1982c4"];function zr(e,t){const s=new Date(e.length===10?`${e}T00:00:00Z`:e);return Number.isFinite(s.getTime())?s.toLocaleDateString(void 0,t?{month:"short",day:"numeric",year:"numeric"}:{month:"short",year:"numeric"}):e}function jf({timeline:e,currency:t="USD",daily:s=!1}){const[n,r]=E.useState(null),[o,i]=E.useState(null),c=E.useMemo(()=>{const h=new Map;for(const m of e)for(const p of m.groups)h.set(p.label,(h.get(p.label)||0)+p.amount);return[...h.entries()].sort((m,p)=>p[1]-m[1]).map(([m],p)=>({label:m,color:as[p%as.length]}))},[e]),l=new Map(c.map(h=>[h.label,h.color])),u=Math.max(...e.map(h=>h.total),1),f=n??o,d=f==null?null:e[f];return e.length?a.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_288px]",onMouseLeave:()=>r(null),children:[a.jsxs("div",{children:[a.jsxs("div",{className:"grid min-h-80 grid-cols-[64px_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(h=>a.jsx("span",{children:K(u*h,t)},h))}),a.jsxs("div",{children:[a.jsxs("div",{className:"relative flex h-64 items-end justify-around border-b px-4",children:[[0,25,50,75].map(h=>a.jsx("span",{className:"pointer-events-none absolute left-0 right-0 border-t border-dashed border-slate-200",style:{top:`${h}%`}},h)),e.map((h,m)=>a.jsx("button",{type:"button",onMouseEnter:()=>r(m),onMouseLeave:()=>r(null),onPointerDown:p=>p.preventDefault(),onFocus:()=>i(m),onBlur:()=>i(null),className:"group z-10 flex h-full min-w-10 flex-1 items-end justify-center px-2 outline-none focus-visible:ring-2 focus-visible:ring-primary",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(h.total/u*100,1)}%`},children:h.groups.map(p=>a.jsx("span",{style:{backgroundColor:l.get(p.label)||as[0],height:`${h.total?p.amount/h.total*100:0}%`}},p.key||p.label))})},`${h.start}-${m}`))]}),a.jsx("div",{className:"flex justify-around px-4 pt-2",children:e.map((h,m)=>a.jsx("span",{className:"min-w-10 flex-1 text-center text-[11px] text-muted-foreground",children:zr(h.start,s)},`${h.start}-label-${m}`))})]})]}),a.jsxs("div",{className:"mt-5 flex flex-wrap gap-x-4 gap-y-2",children:[c.slice(0,8).map(h=>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:h.color}}),h.label]},h.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:d?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:zr(d.start,s)}),a.jsxs("div",{className:"mt-3 space-y-2",children:[[...d.groups].sort((h,m)=>m.amount-h.amount).slice(0,5).map(h=>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:l.get(h.label)||as[0]}}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:h.label}),a.jsx("strong",{children:K(h.amount,t)})]},h.key||h.label)),d.groups.length>5&&a.jsxs("p",{className:"text-xs italic text-muted-foreground",children:["+ ",d.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:K(d.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 Rf({rows:e,currency:t}){const s=e.slice(0,8),n=Math.max(1,...s.flatMap(r=>[r.current?.amount||0,r.previous?.amount||0]));return a.jsxs(de,{className:"bg-primary/5",children:[a.jsx(je,{children:a.jsx(Pe,{className:"text-sm",children:"Comparison Overview"})}),a.jsx(ue,{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:s.map(r=>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: ${K(r.current?.amount||0,t)}`,className:"w-1/3 max-w-10 rounded-t bg-indigo-500",style:{height:`${Math.max((r.current?.amount||0)/n*100,r.current?.amount?1:0)}%`}}),a.jsx("div",{title:`Previous: ${K(r.previous?.amount||0,t)}`,className:"w-1/3 max-w-10 rounded-t bg-pink-400",style:{height:`${Math.max((r.previous?.amount||0)/n*100,r.previous?.amount?1:0)}%`}})]}),a.jsx("span",{title:r.label,className:"mt-2 w-full truncate text-center text-[10px] text-muted-foreground",children:r.label})]},r.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 Ie({label:e,value:t,helper:s,accent:n=!1,trend:r}){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:[r!=null&&(r<0?a.jsx(pu,{className:"h-4 w-4 text-red-500"}):a.jsx(ca,{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 ${n?"text-primary":r!=null&&r<0?"text-red-500":""}`,children:t}),s&&a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s})]})}function is({label:e,options:t,selected:s,onChange:n}){const r=s.length?`${s.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:r}),a.jsx(Dd,{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:s.includes(o.value),onChange:i=>n(i.target.checked?[...s,o.value]:s.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 Nf(){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(st,{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 qe=10,gn=new Date,Cf=new Date(Date.UTC(gn.getUTCFullYear(),gn.getUTCMonth()-2,1)).toISOString().slice(0,10),_f=gn.toISOString().slice(0,10),Mt={services:[],regions:[],accountIds:[],tagKey:"",tagValues:[]},it={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 Vr(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 Wr(e,t){const s=new Date(`${e}T00:00:00Z`);if(t==="monthly"){const r=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),0)),o=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),1)),i=new Date(o);i.setUTCDate(i.getUTCDate()-1);const c=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1));return{currentStart:o.toISOString().slice(0,10),currentEnd:r.toISOString().slice(0,10),previousStart:c.toISOString().slice(0,10),previousEnd:i.toISOString().slice(0,10)}}const n=new Date(s);return n.setUTCDate(n.getUTCDate()-1),{currentStart:e,currentEnd:e,previousStart:n.toISOString().slice(0,10),previousEnd:n.toISOString().slice(0,10)}}function jt(e,t,s){const n=new Date(`${e}T00:00:00Z`),r=new Date(`${t}T00:00:00Z`);if(s==="monthly"&&n.getUTCFullYear()===r.getUTCFullYear()&&n.getUTCMonth()===r.getUTCMonth())return new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric",timeZone:"UTC"}).format(n);const o=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"});return`${o.format(n)} – ${o.format(r)}`}function kf(e){const t=new Map;return e.current.summary.forEach(s=>t.set(s.key||s.label,{current:s})),e.previous.summary.forEach(s=>{const n=s.key||s.label;t.set(n,{...t.get(n),previous:s})}),[...t.entries()].map(([s,n])=>{const r=n.current?.amount||0,o=n.previous?.amount||0,i=r-o;return{key:s,label:n.current?.label||n.previous?.label||s,...n,difference:i,change:o?i/Math.abs(o)*100:0}}).sort((s,n)=>Math.max(n.current?.amount||0,n.previous?.amount||0)-Math.max(s.current?.amount||0,s.previous?.amount||0))}function Xe(e){return e?.length?e.map(t=>`${t.label}
18
18
  ${K(t.amount,"USD")}`).join(`
19
19
  `):"—"}function Hr({values:e}){const[t,s]=E.useState(!1);return a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>s(n=>!n),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:()=>s(!1),children:a.jsx(Wt,{className:"h-3.5 w-3.5"})})]}),e.length?e.map(n=>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:n.label,children:n.label}),a.jsx("strong",{children:K(n.amount,"USD")})]},n.key)):a.jsx("p",{className:"text-xs text-muted-foreground",children:"No related values."})]})]})}function _a({page:e,pages:t,total:s,onChange:n}){const r=s?(e-1)*qe+1:0,o=Math.min(e*qe,s);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 ",r,"–",o," of ",s]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{"aria-label":"Previous page",disabled:e<=1,onClick:()=>n(e-1),className:"rounded-md border p-1.5 disabled:opacity-40",children:a.jsx(Ud,{className:"h-4 w-4"})}),a.jsxs("span",{children:["Page ",e," of ",t]}),a.jsx("button",{"aria-label":"Next page",disabled:e>=t,onClick:()=>n(e+1),className:"rounded-md border p-1.5 disabled:opacity-40",children:a.jsx(Bd,{className:"h-4 w-4"})})]})]})}function Ef({groupBy:e,report:t}){const[s,n]=E.useState(""),[r,o]=E.useState(1),[i,c]=E.useState(null),[l,u]=E.useState({percentage:!0,accounts:!0,regions:!0}),f=it[e],d=E.useMemo(()=>{const g=s.trim().toLowerCase();return g?t.summary.filter(b=>`${b.label} ${b.accountId||""}`.toLowerCase().includes(g)):t.summary},[t,s]),h=Math.max(1,Math.ceil(d.length/qe)),m=d.slice((r-1)*qe,r*qe),p=3+Number(l.percentage)+Number(l.accounts)+Number(l.regions);return E.useEffect(()=>{o(1)},[t,s,e]),a.jsxs(de,{children:[a.jsxs(je,{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(Pn,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("input",{"aria-label":"Search breakdown",value:s,onChange:g=>n(g.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(aa,{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(l).map(([g,b])=>a.jsxs("label",{className:"flex gap-2 py-1 text-xs capitalize",children:[a.jsx("input",{type:"checkbox",checked:b,onChange:x=>u(y=>({...y,[g]:x.target.checked}))}),g]},g))})]})]})]}),a.jsx(ue,{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:f.item}),a.jsx("th",{className:"px-4",children:"Cost"}),l.percentage&&a.jsx("th",{className:"px-4",children:"Percentage"}),l.accounts&&a.jsx("th",{className:"px-4",children:"Accounts"}),l.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(g=>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:g.label,children:g.label}),e==="account"&&a.jsx("div",{className:"font-mono text-xs text-muted-foreground",children:g.accountId||g.key})]}),a.jsx("td",{className:"px-4 font-semibold",children:K(g.amount,t.currency)}),l.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(g.percentage||0,100)}%`}})}),a.jsxs("strong",{className:"text-primary",children:[g.percentage?.toFixed(2),"%"]})]}),l.accounts&&a.jsx("td",{className:"px-4",children:a.jsx(Hr,{values:g.accounts||[]})}),l.regions&&a.jsx("td",{className:"px-4",children:a.jsx(Hr,{values:g.regions||[]})}),a.jsx("td",{className:"px-4 text-center",children:a.jsx("button",{type:"button",onClick:()=>c(g),title:"View cost details",className:"text-primary hover:opacity-70",children:a.jsx(Xd,{className:"h-4 w-4"})})})]},g.key||g.label)):a.jsx("tr",{children:a.jsx("td",{colSpan:p,className:"py-12 text-center text-muted-foreground",children:f.empty})})})]})}),a.jsx(_a,{page:r,pages:h,total:d.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:g=>g.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:f.item}),a.jsx("h3",{className:"mt-1 text-lg font-semibold",children:i.label})]}),a.jsx("button",{onClick:()=>c(null),children:a.jsx(Wt,{})})]}),a.jsxs("div",{className:"mt-5 grid gap-3 sm:grid-cols-3",children:[a.jsx(Ie,{label:"Cost",value:K(i.amount,t.currency)}),a.jsx(Ie,{label:"Accounts",value:String(i.accounts?.length||0)}),a.jsx(Ie,{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(g=>a.jsxs("div",{className:"flex justify-between border-t py-2 text-xs",children:[a.jsx("span",{children:g.label}),a.jsx("strong",{children:K(g.amount,t.currency)})]},g.key))]}),a.jsxs("div",{children:[a.jsx("h4",{className:"mb-2 text-sm font-semibold",children:"Regions"}),(i.regions||[]).map(g=>a.jsxs("div",{className:"flex justify-between border-t py-2 text-xs",children:[a.jsx("span",{children:g.label}),a.jsx("strong",{children:K(g.amount,t.currency)})]},g.key))]})]})]})})]})}function Pf({rows:e,groupBy:t,comparison:s,granularity:n}){const[r,o]=E.useState(""),[i,c]=E.useState(1),l=E.useMemo(()=>{const m=r.trim().toLowerCase();return m?e.filter(p=>p.label.toLowerCase().includes(m)):e},[e,r]),u=Math.max(1,Math.ceil(l.length/qe)),f=l.slice((i-1)*qe,i*qe),d=jt(s.currentStart,s.currentEnd,n),h=jt(s.previousStart,s.previousEnd,n);return E.useEffect(()=>{c(1)},[r,t,s]),a.jsxs(de,{children:[a.jsxs(je,{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(Pn,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("input",{"aria-label":"Search comparison",value:r,onChange:m=>o(m.target.value),placeholder:"Search...",className:"w-48 bg-transparent outline-none"})]})]}),a.jsx(ue,{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:[it[t].item," name"]}),a.jsxs("th",{className:"px-4",children:[d,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:f.length?f.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:K(m.current?.amount||0,s.current.currency)}),a.jsx("td",{className:"px-4",children:K(m.previous?.amount||0,s.previous.currency)}),a.jsxs("td",{className:`px-4 font-medium ${m.difference<0?"text-red-500":"text-emerald-600"}`,children:[m.difference>=0?"+":"",K(m.difference,s.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(_a,{page:i,pages:u,total:l.length,onChange:c})]})}function Af(e){const{mode:t,groupBy:s,start:n,end:r,granularity:o,reportTagKey:i,options:c,filters:l,loading:u,filtersLoading:f,comparisonPeriods:d}=e;return a.jsxs("aside",{className:"space-y-4",children:[a.jsxs(de,{className:"bg-primary/5",children:[a.jsx(je,{children:a.jsx(Pe,{className:"text-sm uppercase text-primary",children:"Report parameters"})}),a.jsxs(ue,{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:n,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:r,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: ",d.currentStart," to ",d.currentEnd,a.jsx("br",{}),"Previous: ",d.previousStart," to ",d.previousEnd]}),s==="tag"&&a.jsxs("label",{className:"block text-xs text-muted-foreground",children:["Group by tag key",a.jsx("select",{value:i,onChange:h=>e.onReportTagKeyChange(h.target.value),className:"mt-1 w-full rounded-md border bg-background p-2 text-sm text-foreground",children:c.tagKeys.map(h=>a.jsx("option",{children:h},h))})]}),a.jsxs("button",{onClick:e.onRun,disabled:u,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(St,{className:`h-4 w-4 ${u?"animate-spin":""}`}),"Run report"]})]})]}),a.jsxs(de,{className:"bg-primary/5",children:[a.jsx(je,{children:a.jsx(Pe,{className:"text-sm uppercase text-primary",children:"Filter by"})}),a.jsxs(ue,{className:"space-y-3",children:[a.jsx(is,{label:"Services",options:c.services,selected:l.services,onChange:h=>e.onFiltersChange(m=>({...m,services:h}))}),a.jsx(is,{label:"Region",options:c.regions,selected:l.regions,onChange:h=>e.onFiltersChange(m=>({...m,regions:h}))}),a.jsx(is,{label:"Linked Account",options:c.accounts,selected:l.accountIds,onChange:h=>e.onFiltersChange(m=>({...m,accountIds:h}))}),a.jsxs("select",{value:l.tagKey,onChange:h=>{const m=h.target.value;e.onFiltersChange(p=>({...p,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))]}),l.tagKey&&a.jsx(is,{label:"Tag values",options:c.tagValues.map(h=>({value:h,label:h})),selected:l.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:f||u,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:u,className:"rounded-md border bg-background px-3 py-2 text-sm text-primary disabled:opacity-50",children:"Reset"})]})]})]})]})}function Tf(){const{managementAccountId:e,loading:t}=_t(),[s,n]=E.useState("service"),[r,o]=E.useState("standard"),[i,c]=E.useState(Cf),[l,u]=E.useState(_f),[f,d]=E.useState("monthly"),[h,m]=E.useState("Name"),[p,g]=E.useState({services:[],regions:[],accounts:[],tagKeys:[],tagValues:[]}),[b,x]=E.useState(Mt),[y,S]=E.useState(Mt),[N,C]=E.useState(null),[_,j]=E.useState(null),[w,P]=E.useState(!0),[I,k]=E.useState(!1),[T,Z]=E.useState(null),[z,J]=E.useState(null),Y=E.useRef(0),Q=E.useMemo(()=>_?kf(_):[],[_]),he=Wr(l,f),me=(D,X,V,ie)=>({start:X,end:V,groupBy:ie,granularity:f,tagKey:h,services:D.services.join(","),regions:D.regions.join(","),accountIds:D.accountIds.join(","),filterTagKey:D.tagKey||void 0,tagValues:D.tagValues.join(","),managementAccountId:e}),O=async(D="")=>{k(!0);try{const X=await oe.getDataStatus({managementAccountId:e});if(J(X),!X.ready)return;const V=await oe.getFilterOptions({start:i,end:l,filterTagKey:D||void 0,managementAccountId:e});g(ie=>D?{...ie,tagValues:V.tagValues}:V),!D&&V.tagKeys.length&&!V.tagKeys.includes(h)&&m(V.tagKeys[0])}catch(X){Z(X?.response?.data?.error||X.message||"Failed to load filter values")}finally{k(!1)}},R=async(D=y,X=r,V=s)=>{const ie=++Y.current;P(!0),Z(null),C(null),j(null);try{const le=await oe.getDataStatus({managementAccountId:e});if(ie===Y.current&&J(le),!le.ready)return;if(X==="compare"){const te=Wr(l,f),[Ce,Ne]=await Promise.all([oe.getReports(me(D,te.currentStart,te.currentEnd,V)),oe.getReports(me(D,te.previousStart,te.previousEnd,V))]);ie===Y.current&&(C(Ce),j({current:Ce,previous:Ne,...te}))}else{const te=await oe.getReports(me(D,i,l,V));ie===Y.current&&C(te)}}catch(le){ie===Y.current&&Z(le?.response?.data?.error||le.message||"Failed to generate cost report")}finally{ie===Y.current&&P(!1)}};return E.useEffect(()=>{t||(J(null),g({services:[],regions:[],accounts:[],tagKeys:[],tagValues:[]}),R(y,r,s),O())},[s,r,e,t]),{groupBy:s,mode:r,start:i,end:l,granularity:f,reportTagKey:h,options:p,draftFilters:b,report:N,comparison:_,loading:w||t,filtersLoading:I,error:T,dataStatus:z,comparedRows:Q,selectedComparisonPeriods:he,setStart:c,setEnd:u,setGranularity:d,setReportTagKey:m,setDraftFilters:x,changeGroup:D=>{D!==s&&(P(!0),C(null),j(null),n(D))},changeMode:D=>{D!==r&&(P(!0),C(null),j(null),o(D))},applyFilters:()=>{const D={...b,services:[...b.services],regions:[...b.regions],accountIds:[...b.accountIds],tagValues:[...b.tagValues]};S(D),R(D)},resetFilters:()=>{x(Mt),S(Mt),R(Mt)},runReport:()=>{O(),R()},loadOptions:O}}function Of(e){const{report:t,comparison:s,rows:n,groupBy:r,mode:o,start:i,end:c}=e,l=it[r];let u,f;o==="compare"&&s?(u=[[l.item,"Current Cost","Previous Cost","Difference","Change %"].join(","),...n.map(h=>[`"${h.label.replace(/"/g,'""')}"`,h.current?.amount||0,h.previous?.amount||0,h.difference,h.change.toFixed(2)].join(","))].join(`
20
20
  `),f=`comparison-report-${r}-${Date.now()}.csv`):(u=[[l.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
- `),f=`${r}-summary-report-${Date.now()}.csv`);const d=document.createElement("a");d.href=URL.createObjectURL(new Blob([u],{type:"text/csv"})),d.download=f,d.click(),URL.revokeObjectURL(d.href)}async function Lf(e){const{report:t,comparison:s,rows:n,groupBy:r,mode:o,start:i,end:c,granularity:l}=e,u=it[r],[{jsPDF:f},{default:d}]=await Promise.all([Promise.resolve().then(()=>require("./jspdf.es.min-C10id8ME.cjs")).then(g=>g.jspdf_es_min),Promise.resolve().then(()=>require("./jspdf.plugin.autotable-CvTok6mL.cjs"))]),h=new f({orientation:"landscape",unit:"pt",format:"a4"}),m=(g,b,x)=>{h.setFontSize(7),h.setTextColor(100),h.text(`Report generated · All costs in ${t.currency} · ${b} to ${x}`,40,h.internal.pageSize.height-18),h.text(`Page ${g.pageNumber}`,h.internal.pageSize.width-70,h.internal.pageSize.height-18)};if(o==="compare"&&s){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: ${s.previous.totalCost}`,40,82),h.text(`Current Cost: ${s.current.totalCost}`,220,82),h.text(`Granularity: ${l}`,400,82),d(h,{startY:100,head:[[`${u.item} Name`,"Current Cost","Previous Cost","Current Period","Previous Period","Change %","Current Accounts","Previous Accounts","Current Regions","Previous Regions"]],body:n.map(g=>[g.label,g.current?.amount?.toFixed(2)||"0.00",g.previous?.amount?.toFixed(2)||"0.00",jt(s.currentStart,s.currentEnd,l),jt(s.previousStart,s.previousEnd,l),`${g.change.toFixed(4)}%`,Xe(g.current?.accounts),Xe(g.previous?.accounts),Xe(g.current?.regions),Xe(g.previous?.regions)]),styles:{fontSize:6,cellPadding:3,overflow:"linebreak"},headStyles:{fillColor:[242,237,255],textColor:[82,35,190]},didDrawPage:g=>m(g,s.previousStart,s.currentEnd),margin:{bottom:32}}),h.save(`comparison-report-${r}-${Date.now()}.pdf`);return}h.setFontSize(18),h.setTextColor(25),h.text(u.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: ${K(t.totalCost,t.currency)}`,40,112),h.setTextColor(98,86,230),h.text("COST SUMMARY BREAKDOWN",40,136);const p=r==="account";d(h,{startY:146,head:[p?["Account ID","Account Name","Total Cost","Percentage","Regions"]:[`${u.item} Name`,"Total Cost","Percentage","Accounts","Regions"]],body:t.summary.map(g=>p?[g.accountId||g.key||"—",g.label,K(g.amount,t.currency),`${(g.percentage||0).toFixed(2)}%`,Xe(g.regions)]:[g.label,K(g.amount,t.currency),`${(g.percentage||0).toFixed(2)}%`,Xe(g.accounts),Xe(g.regions)]),styles:{fontSize:7,cellPadding:4,overflow:"linebreak"},headStyles:{fillColor:[242,237,255],textColor:[82,35,190]},didDrawPage:g=>m(g,i,c),margin:{bottom:32}}),h.save(`${r}-summary-report-${Date.now()}.pdf`)}function If(){const e=Tf(),{groupBy:t,mode:s,report:n,comparison:r,comparedRows:o,loading:i,error:c,dataStatus:l,granularity:u,start:f,end:d}=e,h=it[t],m=n?.summary[0],p=r?r.current.totalCost-r.previous.totalCost:0,g=r?.previous.totalCost?p/Math.abs(r.previous.totalCost)*100:0,b=n?{report:n,comparison:r,rows:o,groupBy:t,mode:s,start:f,end:d,granularity:u}:null,x=a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>b&&void Lf(b),disabled:!b||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(Qd,{className:"h-4 w-4"}),"PDF"]}),a.jsxs("button",{onClick:()=>b&&Of(b),disabled:!b||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(En,{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(ra,{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(Is,{})]}),!i&&(l&&!l.ready||c&&!l)?a.jsx(ks,{status:l,error:c}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex gap-1 overflow-x-auto border-b",children:Object.keys(it).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:it[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(dt,{className:"h-4 w-4"}),c]}),i?a.jsx(Nf,{}):s==="compare"&&r?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: ",Vr(r.current.updatedAt)]})]}),x]}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[a.jsx(Ie,{label:"Period accrued total",value:`${K(r.current.totalCost,r.current.currency)} vs ${K(r.previous.totalCost,r.previous.currency)}`,helper:`${g>=0?"+":""}${g.toFixed(1)}% from previous period`,trend:g}),a.jsx(Ie,{label:jt(r.currentStart,r.currentEnd,u),value:K(r.current.totalCost,r.current.currency),helper:"Current period spending"}),a.jsx(Ie,{label:jt(r.previousStart,r.previousEnd,u),value:K(r.previous.totalCost,r.previous.currency),helper:"Previous period spending"}),a.jsx(Ie,{label:u==="monthly"?"Monthly change":"Period change",value:`${p>=0?"+":""}${K(p,r.current.currency)}`,helper:`${g>=0?"+":""}${g.toFixed(1)}% from previous period`,trend:p})]})]}),a.jsx(Rf,{rows:o,currency:r.current.currency}),a.jsx(Pf,{rows:o,groupBy:t,comparison:r,granularity:u})]}):n?a.jsxs(a.Fragment,{children:[n.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(dt,{className:"h-4 w-4"}),n.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: ",Vr(n.updatedAt)]})]}),x]}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[a.jsx(Ie,{label:"Accrued cost",value:K(n.totalCost,n.currency)}),a.jsx(Ie,{label:h.top,value:m?K(m.amount,n.currency):"-",accent:!0}),a.jsx(Ie,{label:h.count,value:String(n.count||0),accent:!0})]})]}),a.jsxs(de,{children:[a.jsx(je,{children:a.jsx(Pe,{className:"text-sm",children:"Cost Trend"})}),a.jsx(ue,{children:a.jsx(jf,{timeline:n.timeline||[],currency:n.currency||"USD",daily:u==="daily"})})]}),a.jsx(Ef,{groupBy:t,report:n})]}):null]}),a.jsx(Af,{mode:s,groupBy:t,start:f,end:d,granularity:u,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 qr={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"},Mf={INFO:"text-muted-foreground",WARN:"text-amber-600",ERROR:"text-destructive"},cs=e=>e?new Date(e).toLocaleString():"—";function Df({status:e}){return a.jsx("span",{className:`rounded-full border px-2 py-0.5 text-xs font-medium ${qr[e]||qr.PENDING}`,children:e.replace(/_/g," ")})}function De({label:e,value:t,mono:s}){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 ${s?"font-mono text-xs":""}`,children:t||"—"})]})}function Ff(){const{managementAccountId:e,loading:t}=_t(),[s,n]=E.useState([]),[r,o]=E.useState([]),[i,c]=E.useState(!0),[l,u]=E.useState(null),f=E.useCallback(async()=>{c(!0),u(null);try{const d=await se.get("/cur-discovery",{params:{logLimit:100,managementAccountId:e}});n(d.data?.jobs||[]),o(d.data?.logs||[])}catch(d){u(d?.response?.data?.error||d?.message||"Unable to load CUR discovery status")}finally{c(!1)}},[e]);return E.useEffect(()=>{t||f()},[f,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(Pn,{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(Is,{}),a.jsx("button",{onClick:()=>{f()},disabled:i||t,className:"rounded-lg border p-2 hover:bg-muted disabled:opacity-50","aria-label":"Refresh",children:a.jsx(St,{className:`h-4 w-4 ${i||t?"animate-spin":""}`})})]})]}),l&&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(dt,{className:"h-4 w-4"}),l]}),!i&&!l&&!s.length&&a.jsx(de,{children:a.jsx(ue,{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."})}),s.map(d=>a.jsxs(de,{children:[a.jsxs(je,{className:"flex flex-row flex-wrap items-center gap-3",children:[a.jsx(ta,{className:"h-4 w-4 text-primary"}),a.jsxs(Pe,{className:"text-sm",children:["Management account ",d.managementAccountId]}),a.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["connection ",d.connectionId]}),a.jsx(Df,{status:d.status}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:["attempt ",d.attemptCount]}),a.jsxs("span",{className:"ms-auto text-xs text-muted-foreground",children:["next check ",cs(d.nextRunAt)]})]}),a.jsxs(ue,{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[a.jsx(De,{label:"Source",value:d.curS3Uri||`s3://${d.bucket}/${d.prefix}`,mono:!0}),a.jsx(De,{label:"Tenant partition",value:d.tenantPartition,mono:!0}),a.jsx(De,{label:"Region",value:d.region}),a.jsx(De,{label:"Glue database",value:d.database,mono:!0}),a.jsx(De,{label:"Discovered table",value:d.table,mono:!0}),a.jsx(De,{label:"Table location",value:d.tableLocation,mono:!0}),a.jsx(De,{label:"Sample object",value:d.sampleObjectKey,mono:!0}),a.jsx(De,{label:"Last data",value:cs(d.lastDataAt)}),a.jsx(De,{label:"Last checked",value:cs(d.lastFinishedAt||d.lastStartedAt)}),d.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:d.lastError})]})]},d.id)),s.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:s.map(d=>{const h=r.filter(m=>m.jobId===d.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:d.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:cs(m.createdAt)}),a.jsx("td",{className:`py-2 pe-4 text-xs font-medium ${Mf[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."})})]},d.id)})})]})]})}const Uf=e=>e.launchUrl||`https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create?stackName=${encodeURIComponent(e.stackName||`MeyiConnect-${e.connectionId}-Management`)}`,$f=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",Dt=e=>{const t=e?.response?.data?.error||e?.response?.data?.message||e?.message||"Request failed",s=e?.response?.data?.details;return s?`${t} ${s}`:t};function Bf(){const{selectManagementAccount:e,refreshSources:t}=_t(),[s,n]=E.useState([]),[r,o]=E.useState(!0),[i,c]=E.useState(!1),[l,u]=E.useState(null),[f,d]=E.useState(!1),[h,m]=E.useState(""),[p,g]=E.useState(!1),[b,x]=E.useState(null),[y,S]=E.useState(null),[N,C]=E.useState(null),_=E.useCallback(async()=>{o(!0),C(null);try{n((await oe.getSources()).sources||[])}catch(k){C(Dt(k))}finally{o(!1)}},[]);E.useEffect(()=>{_()},[_]);const j=async k=>{if(k.preventDefault(),!/^\d{12}$/.test(h)){C("AWS account ID must contain exactly 12 digits");return}S("create"),C(null);try{const T=await oe.createSource({managementAccountId:h,regionMode:p?"ALL":"SINGLE"});T.managementAccountId&&e(T.managementAccountId),await t(),x(T.connectionId),c(!1),m(""),g(!1),await _()}catch(T){C(Dt(T))}finally{S(null)}},w=async k=>{S(`download-${k}`),C(null);try{const T=await oe.downloadSourceTemplate(k),Z=URL.createObjectURL(T),z=document.createElement("a");z.href=Z,z.download=`meyi-connect-cost-${k}.yaml`,z.click(),URL.revokeObjectURL(Z),x(k)}catch(T){C(Dt(T))}finally{S(null)}},P=async k=>{S(`verify-${k}`),C(null);try{const T=await oe.verifySource(k);T.status==="FAILED"&&C(T.message||"AWS connection verification failed"),await _()}catch(T){C(Dt(T))}finally{S(null)}},I=async()=>{if(l){S(`remove-${l.connectionId}`),C(null);try{await oe.removeSource(l.connectionId,f),u(null),d(!1),await _(),await t()}catch(k){C(Dt(k))}finally{S(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(Cs,{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:()=>{_()},disabled:r,className:"rounded-md border p-2 hover:bg-muted disabled:opacity-50","aria-label":"Refresh sources",title:"Refresh sources",children:a.jsx(St,{className:`h-4 w-4 ${r?"animate-spin":""}`})}),a.jsxs("button",{type:"button",onClick:()=>{C(null),c(!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(iu,{className:"h-4 w-4"}),"Add AWS account"]})]})]}),N&&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(dt,{className:"mt-0.5 h-4 w-4 shrink-0"}),N]}),!r&&s.length===0&&a.jsxs("div",{className:"rounded-md border border-dashed py-14 text-center",children:[a.jsx(Cs,{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."})]}),s.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:s.map(k=>a.jsxs("tr",{className:`border-b last:border-0 ${b===k.connectionId?"bg-muted/30":""}`,children:[a.jsx("td",{className:"px-4 py-3 font-mono",children:k.managementAccountId||"Pending"}),a.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:k.connectionId}),a.jsxs("td",{className:"px-4 py-3",children:[k.accountScope," / ",k.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 ${$f(k.status)}`,children:k.status.replace(/_/g," ")}),k.stackSetStatus&&a.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:k.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:()=>{w(k.connectionId)},disabled:!!y,className:"rounded-md border p-2 hover:bg-muted disabled:opacity-50",title:"Download CloudFormation template","aria-label":"Download CloudFormation template",children:y===`download-${k.connectionId}`?a.jsx(st,{className:"h-4 w-4 animate-spin"}):a.jsx(En,{className:"h-4 w-4"})}),a.jsx("a",{href:Uf(k),target:"_blank",rel:"noreferrer",className:"rounded-md border p-2 hover:bg-muted",title:`Open AWS CloudFormation as ${k.stackName||`MeyiConnect-${k.connectionId}-Management`}`,"aria-label":"Open AWS CloudFormation",children:a.jsx(na,{className:"h-4 w-4"})}),a.jsxs("button",{type:"button",onClick:()=>{P(k.connectionId)},disabled:!!y||k.status==="CONNECTED",className:"flex items-center gap-2 rounded-md border px-3 py-2 font-medium hover:bg-muted disabled:opacity-50",children:[y===`verify-${k.connectionId}`?a.jsx(st,{className:"h-4 w-4 animate-spin"}):k.status==="CONNECTED"?a.jsx(Wd,{className:"h-4 w-4 text-emerald-600"}):a.jsx(St,{className:"h-4 w-4"}),k.status==="CONNECTED"?"Connected":"Verify"]}),a.jsx("button",{type:"button",onClick:()=>{d(!1),u(k)},disabled:!!y,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(ia,{className:"h-4 w-4"})})]})})]},k.connectionId))})]})}),i&&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:k=>{j(k)},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:()=>c(!1),className:"rounded-md p-1 hover:bg-muted","aria-label":"Close",children:a.jsx(Wt,{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:h,onChange:k=>m(k.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:p,onChange:k=>g(k.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:()=>c(!1),className:"rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"}),a.jsxs("button",{type:"submit",disabled:y==="create"||h.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:[y==="create"&&a.jsx(st,{className:"h-4 w-4 animate-spin"}),"Create source"]})]})]})}),l&&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:()=>u(null),disabled:!!y,className:"rounded-md p-1 hover:bg-muted","aria-label":"Close",children:a.jsx(Wt,{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:l.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:f,onChange:k=>d(k.target.checked),disabled:!!y,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:()=>u(null),disabled:!!y,className:"rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"}),a.jsxs("button",{type:"button",onClick:()=>{I()},disabled:!!y,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:[y===`remove-${l.connectionId}`&&a.jsx(st,{className:"h-4 w-4 animate-spin"}),"Remove"]})]})]})})]})}const zf=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Vf=["UTC","Asia/Kolkata","America/New_York","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];function Wf({open:e,schedule:t,saving:s,onClose:n,onSave:r}){const[o,i]=E.useState(t);if(E.useEffect(()=>i(t),[t,e]),!e)return null;const c=l=>i(u=>({...u,frequency:l}));return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4",role:"presentation",onMouseDown:l=>{l.target===l.currentTarget&&n()},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(ea,{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:n,className:"rounded-md p-1.5 hover:bg-muted","aria-label":"Close",children:a.jsx(Wt,{className:"h-4 w-4"})})]}),a.jsxs("form",{className:"space-y-5 p-5",onSubmit:l=>{l.preventDefault(),r({enabled:o.enabled,frequency:o.frequency,time:o.time,timezone:o.timezone,dayOfWeek:o.dayOfWeek,dayOfMonth:o.dayOfMonth}).then(n)},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:l=>i(u=>({...u,enabled:l.target.checked})),className:"h-4 w-4 accent-primary"})]}),a.jsxs("fieldset",{disabled:!o.enabled||s,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(l=>a.jsx("button",{type:"button",onClick:()=>c(l),className:`rounded-md px-3 py-2 text-sm capitalize ${o.frequency===l?"bg-primary text-primary-foreground":"hover:bg-muted"}`,children:l},l))})]}),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:l=>i(u=>({...u,time:l.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:l=>i(u=>({...u,timezone:l.target.value})),className:"mt-2 block h-10 w-full rounded-lg border bg-background px-3 font-normal",children:[...new Set([o.timezone,...Vf])].map(l=>a.jsx("option",{children:l},l))})]})]}),o.frequency==="weekly"&&a.jsxs("label",{className:"block text-sm font-medium",children:["Day of week",a.jsx("select",{value:o.dayOfWeek??1,onChange:l=>i(u=>({...u,dayOfWeek:Number(l.target.value)})),className:"mt-2 block h-10 w-full rounded-lg border bg-background px-3 font-normal",children:zf.map((l,u)=>a.jsx("option",{value:u,children:l},l))})]}),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:l=>i(u=>({...u,dayOfMonth:Number(l.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:n,className:"rounded-lg border px-4 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:s,className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50",children:s?"Saving":"Save schedule"})]})]})]})})}function Hf(){const{managementAccountId:e,loading:t}=_t(),[s,n]=E.useState(null),[r,o]=E.useState(null),[i,c]=E.useState(null),[l,u]=E.useState([]),[f,d]=E.useState(!0),[h,m]=E.useState(!1),[p,g]=E.useState(null),[b,x]=E.useState(null),y=E.useRef(!0),S=E.useCallback(async(j=!1)=>{j||d(!0);try{const[w,P,I,k]=await Promise.all([oe.getAnalysisStatus({managementAccountId:e}),oe.getDataStatus({managementAccountId:e}),oe.getAnalysisSchedule({managementAccountId:e}),oe.getAnalysisReports({managementAccountId:e})]);if(!y.current)return;n(w),o(P),c(I),u(k),x(null)}catch(w){y.current&&x(w?.response?.data?.error||w?.message||"Unable to load scheduled AI reports")}finally{y.current&&!j&&d(!1)}},[e]);return E.useEffect(()=>(y.current=!0,t||S(),()=>{y.current=!1}),[S,t]),E.useEffect(()=>{if(!l.some(w=>w.status==="PENDING"||w.status==="RUNNING"))return;const j=window.setInterval(()=>{S(!0)},15e3);return()=>window.clearInterval(j)},[S,l]),{status:s,dataStatus:r,schedule:i,reports:l,loading:f||t,saving:h,removingId:p,error:b,load:S,saveSchedule:async j=>{m(!0),x(null);try{const w=await oe.updateAnalysisSchedule(j,{managementAccountId:e});y.current&&c(w)}catch(w){throw x(w?.response?.data?.error||w?.message||"Unable to save the AI report schedule"),w}finally{y.current&&m(!1)}},download:async j=>{try{const w=await oe.downloadAnalysisPdf(j.id),P=URL.createObjectURL(w),I=document.createElement("a");I.href=P,I.download=`meyi-cost-analysis-${j.period.Start}.pdf`,I.click(),URL.revokeObjectURL(P)}catch(w){x(w?.response?.data?.error||w?.message||"Unable to download the PDF report")}},remove:async j=>{if(window.confirm(`Remove the AI cost report for ${j.period.Start} through ${j.period.End}?`)){g(j.id),x(null);try{await oe.removeAnalysisReport(j.id),y.current&&u(w=>w.filter(P=>P.id!==j.id))}catch(w){y.current&&x(w?.response?.data?.error||w?.message||"Unable to remove the AI report")}finally{y.current&&g(null)}}}}}const sn=e=>e?new Date(e).toLocaleString():"Not scheduled",qf=e=>new Date(`${e}T00:00:00Z`).toLocaleDateString(),Gf=e=>{const t=new Date(`${e}T00:00:00Z`);return t.setUTCDate(t.getUTCDate()-1),t.toLocaleDateString()},Kf={COMPLETED:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700",RUNNING:"border-blue-500/30 bg-blue-500/10 text-blue-700",PENDING:"border-amber-500/30 bg-amber-500/10 text-amber-700",FAILED:"border-destructive/30 bg-destructive/10 text-destructive"};function Yf(){const e=Hf(),t=mf(),[s,n]=E.useState(!1),r=t.toLowerCase()==="admin";return a.jsxs("div",{className:"flex min-w-0 max-w-full flex-col gap-6 overflow-x-hidden p-2 md:p-6",children:[a.jsxs("header",{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(Lr,{className:"h-6 w-6 text-primary"}),"AI Cost Analysis"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Scheduled Cost reports generated from AWS CUR data"})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(Is,{}),a.jsx("button",{type:"button",onClick:()=>{e.load()},disabled:e.loading,className:"rounded-lg border p-2.5 hover:bg-muted disabled:opacity-50",title:"Refresh reports","aria-label":"Refresh reports",children:a.jsx(St,{className:`h-4 w-4 ${e.loading?"animate-spin":""}`})}),r&&e.schedule&&a.jsxs("button",{type:"button",onClick:()=>n(!0),className:"inline-flex h-10 items-center gap-2 rounded-lg bg-primary px-4 text-sm font-medium text-primary-foreground",children:[a.jsx(aa,{className:"h-4 w-4"}),"Report settings"]})]})]}),e.error&&a.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive",children:[a.jsx(dt,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.error]}),e.loading?a.jsx("div",{className:"h-72 animate-pulse rounded-lg bg-muted"}):e.dataStatus&&!e.dataStatus.ready?a.jsx(ks,{status:e.dataStatus}):e.status&&!e.status.enabled?a.jsx(de,{children:a.jsxs(ue,{className:"flex min-h-64 flex-col items-center justify-center px-6 text-center",children:[a.jsx(Lr,{className:"h-8 w-8 text-muted-foreground"}),a.jsx("h2",{className:"mt-4 text-base font-semibold",children:e.status.reason==="AI_PROVIDER_REQUIRED"?"Configure an AI provider":"AI cost analysis is not enabled"}),a.jsx("p",{className:"mt-2 max-w-xl text-sm text-muted-foreground",children:e.status.reason==="AI_PROVIDER_REQUIRED"?"Configure and activate an AI provider in Meyi Connect before scheduled cost reports can run.":"An administrator must enable the Cost AI deployment setting before scheduled reports can run."})]})}):a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border bg-card px-4 py-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ea,{className:"h-5 w-5 text-primary"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-semibold",children:e.schedule?.enabled?`${e.schedule.frequency[0].toUpperCase()}${e.schedule.frequency.slice(1)} reports enabled`:"Scheduled reports disabled"}),a.jsx("p",{className:"text-xs text-muted-foreground",children:e.schedule?.enabled?`Next run ${sn(e.schedule.nextRunAt)} (${e.schedule.timezone})`:r?"Open report settings to configure a schedule":"An administrator can configure the report schedule"})]})]}),e.schedule?.lastRunAt&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last run ",sn(e.schedule.lastRunAt)]})]}),e.reports.length?a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full min-w-[960px] text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b bg-muted/40 text-left text-xs text-muted-foreground",children:[a.jsx("th",{className:"px-4 py-3 font-medium",children:"Report period"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Schedule"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"AI provider"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Generated"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Status"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Total cost"}),a.jsx("th",{className:"px-4 py-3 text-right font-medium",children:"Actions"})]})}),a.jsx("tbody",{children:e.reports.map(o=>a.jsxs("tr",{className:"border-b last:border-0",children:[a.jsxs("td",{className:"px-4 py-3 font-medium",children:[qf(o.period.Start)," - ",Gf(o.period.End)]}),a.jsx("td",{className:"px-4 py-3 capitalize text-muted-foreground",children:o.frequency}),a.jsxs("td",{className:"px-4 py-3",children:[a.jsx("span",{className:"capitalize",children:o.provider||"-"}),o.modelId&&a.jsx("p",{className:"max-w-48 truncate text-xs text-muted-foreground",title:o.modelId,children:o.modelId})]}),a.jsx("td",{className:"px-4 py-3 text-muted-foreground",children:sn(o.completedAt||o.startedAt||o.createdAt)}),a.jsxs("td",{className:"px-4 py-3",children:[a.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full border px-2 py-1 text-xs font-medium ${Kf[o.status]}`,children:[(o.status==="RUNNING"||o.status==="PENDING")&&a.jsx(st,{className:"h-3 w-3 animate-spin"}),o.status.toLowerCase()]}),o.error&&a.jsx("p",{className:"mt-1 max-w-xs truncate text-xs text-destructive",title:o.error,children:o.error})]}),a.jsx("td",{className:"px-4 py-3",children:o.facts?new Intl.NumberFormat(void 0,{style:"currency",currency:o.facts.currency}).format(o.facts.currentTotal):"-"}),a.jsx("td",{className:"px-4 py-3",children:a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>{e.download(o)},disabled:!o.pdfReady,className:"inline-flex h-9 items-center gap-2 rounded-lg border px-3 text-sm font-medium hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40",title:o.pdfReady?"Download PDF":"PDF not ready",children:[a.jsx(En,{className:"h-4 w-4"}),"Download"]}),r&&a.jsx("button",{type:"button",onClick:()=>{e.remove(o)},disabled:e.removingId===o.id||o.status==="RUNNING"||o.status==="PENDING",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg border text-destructive hover:bg-destructive/10 disabled:cursor-not-allowed disabled:opacity-40",title:"Remove report","aria-label":"Remove report",children:e.removingId===o.id?a.jsx(st,{className:"h-4 w-4 animate-spin"}):a.jsx(ia,{className:"h-4 w-4"})})]})})]},o.id))})]})})}):a.jsx(de,{children:a.jsxs(ue,{className:"flex min-h-64 flex-col items-center justify-center px-6 text-center",children:[a.jsx(ra,{className:"h-8 w-8 text-muted-foreground"}),a.jsx("h2",{className:"mt-4 text-base font-semibold",children:"No scheduled reports yet"}),a.jsx("p",{className:"mt-2 max-w-lg text-sm text-muted-foreground",children:"The first report will appear here after the configured schedule runs."})]})})]}),e.schedule&&a.jsx(Wf,{open:s,schedule:e.schedule,saving:e.saving,onClose:()=>n(!1),onSave:e.saveSchedule})]})}const kt=fc({component:Ro}),Jf=Ht({getParentRoute:()=>kt,path:"/",component:Sf}),Xf=Ht({getParentRoute:()=>kt,path:"/reports",component:If}),Zf=Ht({getParentRoute:()=>kt,path:"/cur-discovery",component:Ff}),Qf=Ht({getParentRoute:()=>kt,path:"/analysis",component:Yf}),eh=Ht({getParentRoute:()=>kt,path:"/sources",component:Bf});function On(){return kt.addChildren([Jf,Qf,Xf,eh,Zf])}function th(e="/cost"){return No({routeTree:On(),basepath:e})}function sh({apiBase:e,token:t,basePath:s="/cost",userRole:n="user",tenantId:r="default"}){Xo(e,t);const o=E.useMemo(()=>No({routeTree:On(),basepath:s}),[s]);return a.jsx(hf,{value:n,children:a.jsx(pf,{tenantId:r,children:a.jsx(_c,{router:o})})})}const nh=[{title:"Overview",url:"/",icon:"DollarSign",roles:["admin","user"]},{title:"AI Analysis",url:"/analysis",icon:"Sparkles",roles:["admin","user"]},{title:"Reports",url:"/reports",icon:"FileText",roles:["admin","user"]},{title:"Sources",url:"/sources",icon:"CloudCog",roles:["admin"]},{title:"CUR Discovery",url:"/cur-discovery",icon:"Search",roles:["admin"]}];exports.CostPage=sh;exports.api=se;exports.attachAuthInterceptors=Cd;exports.configureApi=Xo;exports.costNavItems=nh;exports.createCostRouter=th;exports.createRouteTree=On;
21
+ `),f=`${r}-summary-report-${Date.now()}.csv`);const d=document.createElement("a");d.href=URL.createObjectURL(new Blob([u],{type:"text/csv"})),d.download=f,d.click(),URL.revokeObjectURL(d.href)}async function Lf(e){const{report:t,comparison:s,rows:n,groupBy:r,mode:o,start:i,end:c,granularity:l}=e,u=it[r],[{jsPDF:f},{default:d}]=await Promise.all([Promise.resolve().then(()=>require("./jspdf.es.min-C10id8ME.cjs")).then(g=>g.jspdf_es_min),Promise.resolve().then(()=>require("./jspdf.plugin.autotable-CvTok6mL.cjs"))]),h=new f({orientation:"landscape",unit:"pt",format:"a4"}),m=(g,b,x)=>{h.setFontSize(7),h.setTextColor(100),h.text(`Report generated · All costs in ${t.currency} · ${b} to ${x}`,40,h.internal.pageSize.height-18),h.text(`Page ${g.pageNumber}`,h.internal.pageSize.width-70,h.internal.pageSize.height-18)};if(o==="compare"&&s){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: ${s.previous.totalCost}`,40,82),h.text(`Current Cost: ${s.current.totalCost}`,220,82),h.text(`Granularity: ${l}`,400,82),d(h,{startY:100,head:[[`${u.item} Name`,"Current Cost","Previous Cost","Current Period","Previous Period","Change %","Current Accounts","Previous Accounts","Current Regions","Previous Regions"]],body:n.map(g=>[g.label,g.current?.amount?.toFixed(2)||"0.00",g.previous?.amount?.toFixed(2)||"0.00",jt(s.currentStart,s.currentEnd,l),jt(s.previousStart,s.previousEnd,l),`${g.change.toFixed(4)}%`,Xe(g.current?.accounts),Xe(g.previous?.accounts),Xe(g.current?.regions),Xe(g.previous?.regions)]),styles:{fontSize:6,cellPadding:3,overflow:"linebreak"},headStyles:{fillColor:[242,237,255],textColor:[82,35,190]},didDrawPage:g=>m(g,s.previousStart,s.currentEnd),margin:{bottom:32}}),h.save(`comparison-report-${r}-${Date.now()}.pdf`);return}h.setFontSize(18),h.setTextColor(25),h.text(u.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: ${K(t.totalCost,t.currency)}`,40,112),h.setTextColor(98,86,230),h.text("COST SUMMARY BREAKDOWN",40,136);const p=r==="account";d(h,{startY:146,head:[p?["Account ID","Account Name","Total Cost","Percentage","Regions"]:[`${u.item} Name`,"Total Cost","Percentage","Accounts","Regions"]],body:t.summary.map(g=>p?[g.accountId||g.key||"—",g.label,K(g.amount,t.currency),`${(g.percentage||0).toFixed(2)}%`,Xe(g.regions)]:[g.label,K(g.amount,t.currency),`${(g.percentage||0).toFixed(2)}%`,Xe(g.accounts),Xe(g.regions)]),styles:{fontSize:7,cellPadding:4,overflow:"linebreak"},headStyles:{fillColor:[242,237,255],textColor:[82,35,190]},didDrawPage:g=>m(g,i,c),margin:{bottom:32}}),h.save(`${r}-summary-report-${Date.now()}.pdf`)}function If(){const e=Tf(),{groupBy:t,mode:s,report:n,comparison:r,comparedRows:o,loading:i,error:c,dataStatus:l,granularity:u,start:f,end:d}=e,h=it[t],m=n?.summary[0],p=r?r.current.totalCost-r.previous.totalCost:0,g=r?.previous.totalCost?p/Math.abs(r.previous.totalCost)*100:0,b=n?{report:n,comparison:r,rows:o,groupBy:t,mode:s,start:f,end:d,granularity:u}:null,x=a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>b&&void Lf(b),disabled:!b||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(Qd,{className:"h-4 w-4"}),"PDF"]}),a.jsxs("button",{onClick:()=>b&&Of(b),disabled:!b||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(En,{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(ra,{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(Is,{})]}),!i&&(l&&!l.ready||c&&!l)?a.jsx(ks,{status:l,error:c}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex gap-1 overflow-x-auto border-b",children:Object.keys(it).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:it[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(dt,{className:"h-4 w-4"}),c]}),i?a.jsx(Nf,{}):s==="compare"&&r?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: ",Vr(r.current.updatedAt)]})]}),x]}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[a.jsx(Ie,{label:"Period accrued total",value:`${K(r.current.totalCost,r.current.currency)} vs ${K(r.previous.totalCost,r.previous.currency)}`,helper:`${g>=0?"+":""}${g.toFixed(1)}% from previous period`,trend:g}),a.jsx(Ie,{label:jt(r.currentStart,r.currentEnd,u),value:K(r.current.totalCost,r.current.currency),helper:"Current period spending"}),a.jsx(Ie,{label:jt(r.previousStart,r.previousEnd,u),value:K(r.previous.totalCost,r.previous.currency),helper:"Previous period spending"}),a.jsx(Ie,{label:u==="monthly"?"Monthly change":"Period change",value:`${p>=0?"+":""}${K(p,r.current.currency)}`,helper:`${g>=0?"+":""}${g.toFixed(1)}% from previous period`,trend:p})]})]}),a.jsx(Rf,{rows:o,currency:r.current.currency}),a.jsx(Pf,{rows:o,groupBy:t,comparison:r,granularity:u})]}):n?a.jsxs(a.Fragment,{children:[n.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(dt,{className:"h-4 w-4"}),n.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: ",Vr(n.updatedAt)]})]}),x]}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[a.jsx(Ie,{label:"Accrued cost",value:K(n.totalCost,n.currency)}),a.jsx(Ie,{label:h.top,value:m?K(m.amount,n.currency):"-",accent:!0}),a.jsx(Ie,{label:h.count,value:String(n.count||0),accent:!0})]})]}),a.jsxs(de,{children:[a.jsx(je,{children:a.jsx(Pe,{className:"text-sm",children:"Cost Trend"})}),a.jsx(ue,{children:a.jsx(jf,{timeline:n.timeline||[],currency:n.currency||"USD",daily:u==="daily"})})]}),a.jsx(Ef,{groupBy:t,report:n})]}):null]}),a.jsx(Af,{mode:s,groupBy:t,start:f,end:d,granularity:u,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 qr={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"},Mf={INFO:"text-muted-foreground",WARN:"text-amber-600",ERROR:"text-destructive"},cs=e=>e?new Date(e).toLocaleString():"—";function Df({status:e}){return a.jsx("span",{className:`rounded-full border px-2 py-0.5 text-xs font-medium ${qr[e]||qr.PENDING}`,children:e.replace(/_/g," ")})}function De({label:e,value:t,mono:s}){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 ${s?"font-mono text-xs":""}`,children:t||"—"})]})}function Ff(){const{managementAccountId:e,loading:t}=_t(),[s,n]=E.useState([]),[r,o]=E.useState([]),[i,c]=E.useState(!0),[l,u]=E.useState(null),f=E.useCallback(async()=>{c(!0),u(null);try{const d=await se.get("/cur-discovery",{params:{logLimit:100,managementAccountId:e}});n(d.data?.jobs||[]),o(d.data?.logs||[])}catch(d){u(d?.response?.data?.error||d?.message||"Unable to load CUR discovery status")}finally{c(!1)}},[e]);return E.useEffect(()=>{t||f()},[f,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(Pn,{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(Is,{}),a.jsx("button",{onClick:()=>{f()},disabled:i||t,className:"rounded-lg border p-2 hover:bg-muted disabled:opacity-50","aria-label":"Refresh",children:a.jsx(St,{className:`h-4 w-4 ${i||t?"animate-spin":""}`})})]})]}),l&&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(dt,{className:"h-4 w-4"}),l]}),!i&&!l&&!s.length&&a.jsx(de,{children:a.jsx(ue,{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."})}),s.map(d=>a.jsxs(de,{children:[a.jsxs(je,{className:"flex flex-row flex-wrap items-center gap-3",children:[a.jsx(ta,{className:"h-4 w-4 text-primary"}),a.jsxs(Pe,{className:"text-sm",children:["Management account ",d.managementAccountId]}),a.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["connection ",d.connectionId]}),a.jsx(Df,{status:d.status}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:["attempt ",d.attemptCount]}),a.jsxs("span",{className:"ms-auto text-xs text-muted-foreground",children:["next check ",cs(d.nextRunAt)]})]}),a.jsxs(ue,{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[a.jsx(De,{label:"Source",value:d.curS3Uri||`s3://${d.bucket}/${d.prefix}`,mono:!0}),a.jsx(De,{label:"Tenant partition",value:d.tenantPartition,mono:!0}),a.jsx(De,{label:"Region",value:d.region}),a.jsx(De,{label:"Glue database",value:d.database,mono:!0}),a.jsx(De,{label:"Discovered table",value:d.table,mono:!0}),a.jsx(De,{label:"Table location",value:d.tableLocation,mono:!0}),a.jsx(De,{label:"Sample object",value:d.sampleObjectKey,mono:!0}),a.jsx(De,{label:"Last data",value:cs(d.lastDataAt)}),a.jsx(De,{label:"Last checked",value:cs(d.lastFinishedAt||d.lastStartedAt)}),d.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:d.lastError})]})]},d.id)),s.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:s.map(d=>{const h=r.filter(m=>m.jobId===d.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:d.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:cs(m.createdAt)}),a.jsx("td",{className:`py-2 pe-4 text-xs font-medium ${Mf[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."})})]},d.id)})})]})]})}const Uf=e=>e.launchUrl||`https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create?stackName=${encodeURIComponent(e.stackName||`MeyiConnect-${e.connectionId}-Management`)}`,$f=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",Dt=e=>{const t=e?.response?.data?.error||e?.response?.data?.message||e?.message||"Request failed",s=e?.response?.data?.details;return s?`${t} ${s}`:t};function Bf(){const{selectManagementAccount:e,refreshSources:t}=_t(),[s,n]=E.useState([]),[r,o]=E.useState(!0),[i,c]=E.useState(!1),[l,u]=E.useState(null),[f,d]=E.useState(!1),[h,m]=E.useState(""),[p,g]=E.useState(!1),[b,x]=E.useState(null),[y,S]=E.useState(null),[N,C]=E.useState(null),_=E.useCallback(async()=>{o(!0),C(null);try{n((await oe.getSources()).sources||[])}catch(k){C(Dt(k))}finally{o(!1)}},[]);E.useEffect(()=>{_()},[_]);const j=async k=>{if(k.preventDefault(),!/^\d{12}$/.test(h)){C("AWS account ID must contain exactly 12 digits");return}S("create"),C(null);try{const T=await oe.createSource({managementAccountId:h,regionMode:p?"ALL":"SINGLE"});T.managementAccountId&&e(T.managementAccountId),await t(),x(T.connectionId),c(!1),m(""),g(!1),await _()}catch(T){C(Dt(T))}finally{S(null)}},w=async k=>{S(`download-${k}`),C(null);try{const T=await oe.downloadSourceTemplate(k),Z=URL.createObjectURL(T),z=document.createElement("a");z.href=Z,z.download=`meyi-connect-cost-${k}.yaml`,z.click(),URL.revokeObjectURL(Z),x(k)}catch(T){C(Dt(T))}finally{S(null)}},P=async k=>{S(`verify-${k}`),C(null);try{const T=await oe.verifySource(k);T.status==="FAILED"&&C(T.message||"AWS connection verification failed"),await _()}catch(T){C(Dt(T))}finally{S(null)}},I=async()=>{if(l){S(`remove-${l.connectionId}`),C(null);try{await oe.removeSource(l.connectionId,f),u(null),d(!1),await _(),await t()}catch(k){C(Dt(k))}finally{S(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(Cs,{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:()=>{_()},disabled:r,className:"rounded-md border p-2 hover:bg-muted disabled:opacity-50","aria-label":"Refresh sources",title:"Refresh sources",children:a.jsx(St,{className:`h-4 w-4 ${r?"animate-spin":""}`})}),a.jsxs("button",{type:"button",onClick:()=>{C(null),c(!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(iu,{className:"h-4 w-4"}),"Add AWS account"]})]})]}),N&&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(dt,{className:"mt-0.5 h-4 w-4 shrink-0"}),N]}),!r&&s.length===0&&a.jsxs("div",{className:"rounded-md border border-dashed py-14 text-center",children:[a.jsx(Cs,{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."})]}),s.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:s.map(k=>a.jsxs("tr",{className:`border-b last:border-0 ${b===k.connectionId?"bg-muted/30":""}`,children:[a.jsx("td",{className:"px-4 py-3 font-mono",children:k.managementAccountId||"Pending"}),a.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:k.connectionId}),a.jsxs("td",{className:"px-4 py-3",children:[k.accountScope," / ",k.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 ${$f(k.status)}`,children:k.status.replace(/_/g," ")}),k.stackSetStatus&&a.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:k.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:()=>{w(k.connectionId)},disabled:!!y,className:"rounded-md border p-2 hover:bg-muted disabled:opacity-50",title:"Download CloudFormation template","aria-label":"Download CloudFormation template",children:y===`download-${k.connectionId}`?a.jsx(st,{className:"h-4 w-4 animate-spin"}):a.jsx(En,{className:"h-4 w-4"})}),a.jsx("a",{href:Uf(k),target:"_blank",rel:"noreferrer",className:"rounded-md border p-2 hover:bg-muted",title:`Open AWS CloudFormation as ${k.stackName||`MeyiConnect-${k.connectionId}-Management`}`,"aria-label":"Open AWS CloudFormation",children:a.jsx(na,{className:"h-4 w-4"})}),a.jsxs("button",{type:"button",onClick:()=>{P(k.connectionId)},disabled:!!y||k.status==="CONNECTED",className:"flex items-center gap-2 rounded-md border px-3 py-2 font-medium hover:bg-muted disabled:opacity-50",children:[y===`verify-${k.connectionId}`?a.jsx(st,{className:"h-4 w-4 animate-spin"}):k.status==="CONNECTED"?a.jsx(Wd,{className:"h-4 w-4 text-emerald-600"}):a.jsx(St,{className:"h-4 w-4"}),k.status==="CONNECTED"?"Connected":"Verify"]}),a.jsx("button",{type:"button",onClick:()=>{d(!1),u(k)},disabled:!!y,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(ia,{className:"h-4 w-4"})})]})})]},k.connectionId))})]})}),i&&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:k=>{j(k)},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:()=>c(!1),className:"rounded-md p-1 hover:bg-muted","aria-label":"Close",children:a.jsx(Wt,{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:h,onChange:k=>m(k.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:p,onChange:k=>g(k.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:()=>c(!1),className:"rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"}),a.jsxs("button",{type:"submit",disabled:y==="create"||h.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:[y==="create"&&a.jsx(st,{className:"h-4 w-4 animate-spin"}),"Create source"]})]})]})}),l&&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:()=>u(null),disabled:!!y,className:"rounded-md p-1 hover:bg-muted","aria-label":"Close",children:a.jsx(Wt,{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:l.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:f,onChange:k=>d(k.target.checked),disabled:!!y,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:()=>u(null),disabled:!!y,className:"rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"}),a.jsxs("button",{type:"button",onClick:()=>{I()},disabled:!!y,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:[y===`remove-${l.connectionId}`&&a.jsx(st,{className:"h-4 w-4 animate-spin"}),"Remove"]})]})]})})]})}const zf=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Vf=["UTC","Asia/Kolkata","America/New_York","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];function Wf({open:e,schedule:t,saving:s,onClose:n,onSave:r}){const[o,i]=E.useState(t);if(E.useEffect(()=>i(t),[t,e]),!e)return null;const c=l=>i(u=>({...u,frequency:l}));return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4",role:"presentation",onMouseDown:l=>{l.target===l.currentTarget&&n()},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(ea,{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:n,className:"rounded-md p-1.5 hover:bg-muted","aria-label":"Close",children:a.jsx(Wt,{className:"h-4 w-4"})})]}),a.jsxs("form",{className:"space-y-5 p-5",onSubmit:l=>{l.preventDefault(),r({enabled:o.enabled,frequency:o.frequency,time:o.time,timezone:o.timezone,dayOfWeek:o.dayOfWeek,dayOfMonth:o.dayOfMonth}).then(n)},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:l=>i(u=>({...u,enabled:l.target.checked})),className:"h-4 w-4 accent-primary"})]}),a.jsxs("fieldset",{disabled:!o.enabled||s,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(l=>a.jsx("button",{type:"button",onClick:()=>c(l),className:`rounded-md px-3 py-2 text-sm capitalize ${o.frequency===l?"bg-primary text-primary-foreground":"hover:bg-muted"}`,children:l},l))})]}),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:l=>i(u=>({...u,time:l.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:l=>i(u=>({...u,timezone:l.target.value})),className:"mt-2 block h-10 w-full rounded-lg border bg-background px-3 font-normal",children:[...new Set([o.timezone,...Vf])].map(l=>a.jsx("option",{children:l},l))})]})]}),o.frequency==="weekly"&&a.jsxs("label",{className:"block text-sm font-medium",children:["Day of week",a.jsx("select",{value:o.dayOfWeek??1,onChange:l=>i(u=>({...u,dayOfWeek:Number(l.target.value)})),className:"mt-2 block h-10 w-full rounded-lg border bg-background px-3 font-normal",children:zf.map((l,u)=>a.jsx("option",{value:u,children:l},l))})]}),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:l=>i(u=>({...u,dayOfMonth:Number(l.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:n,className:"rounded-lg border px-4 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:s,className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50",children:s?"Saving":"Save schedule"})]})]})]})})}function Hf(){const{managementAccountId:e,loading:t}=_t(),[s,n]=E.useState(null),[r,o]=E.useState(null),[i,c]=E.useState(null),[l,u]=E.useState([]),[f,d]=E.useState(!0),[h,m]=E.useState(!1),[p,g]=E.useState(null),[b,x]=E.useState(null),y=E.useRef(!0),S=E.useCallback(async(j=!1)=>{j||d(!0);try{const w=await oe.getDataStatus({managementAccountId:e});if(!y.current)return;if(o(w),!w.ready){n(null),c(null),u([]),x(null);return}const[P,I,k]=await Promise.all([oe.getAnalysisStatus({managementAccountId:e}),oe.getAnalysisSchedule({managementAccountId:e}),oe.getAnalysisReports({managementAccountId:e})]);if(!y.current)return;n(P),c(I),u(k),x(null)}catch(w){y.current&&x(w?.response?.data?.error||w?.message||"Unable to load scheduled AI reports")}finally{y.current&&!j&&d(!1)}},[e]);return E.useEffect(()=>(y.current=!0,t||S(),()=>{y.current=!1}),[S,t]),E.useEffect(()=>{if(!l.some(w=>w.status==="PENDING"||w.status==="RUNNING"))return;const j=window.setInterval(()=>{S(!0)},15e3);return()=>window.clearInterval(j)},[S,l]),{status:s,dataStatus:r,schedule:i,reports:l,loading:f||t,saving:h,removingId:p,error:b,load:S,saveSchedule:async j=>{m(!0),x(null);try{const w=await oe.updateAnalysisSchedule(j,{managementAccountId:e});y.current&&c(w)}catch(w){throw x(w?.response?.data?.error||w?.message||"Unable to save the AI report schedule"),w}finally{y.current&&m(!1)}},download:async j=>{try{const w=await oe.downloadAnalysisPdf(j.id),P=URL.createObjectURL(w),I=document.createElement("a");I.href=P,I.download=`meyi-cost-analysis-${j.period.Start}.pdf`,I.click(),URL.revokeObjectURL(P)}catch(w){x(w?.response?.data?.error||w?.message||"Unable to download the PDF report")}},remove:async j=>{if(window.confirm(`Remove the AI cost report for ${j.period.Start} through ${j.period.End}?`)){g(j.id),x(null);try{await oe.removeAnalysisReport(j.id),y.current&&u(w=>w.filter(P=>P.id!==j.id))}catch(w){y.current&&x(w?.response?.data?.error||w?.message||"Unable to remove the AI report")}finally{y.current&&g(null)}}}}}const sn=e=>e?new Date(e).toLocaleString():"Not scheduled",qf=e=>new Date(`${e}T00:00:00Z`).toLocaleDateString(),Gf=e=>{const t=new Date(`${e}T00:00:00Z`);return t.setUTCDate(t.getUTCDate()-1),t.toLocaleDateString()},Kf={COMPLETED:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700",RUNNING:"border-blue-500/30 bg-blue-500/10 text-blue-700",PENDING:"border-amber-500/30 bg-amber-500/10 text-amber-700",FAILED:"border-destructive/30 bg-destructive/10 text-destructive"};function Yf(){const e=Hf(),t=mf(),[s,n]=E.useState(!1),r=t.toLowerCase()==="admin";return a.jsxs("div",{className:"flex min-w-0 max-w-full flex-col gap-6 overflow-x-hidden p-2 md:p-6",children:[a.jsxs("header",{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(Lr,{className:"h-6 w-6 text-primary"}),"AI Cost Analysis"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Scheduled Cost reports generated from AWS CUR data"})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(Is,{}),a.jsx("button",{type:"button",onClick:()=>{e.load()},disabled:e.loading,className:"rounded-lg border p-2.5 hover:bg-muted disabled:opacity-50",title:"Refresh reports","aria-label":"Refresh reports",children:a.jsx(St,{className:`h-4 w-4 ${e.loading?"animate-spin":""}`})}),r&&e.schedule&&a.jsxs("button",{type:"button",onClick:()=>n(!0),className:"inline-flex h-10 items-center gap-2 rounded-lg bg-primary px-4 text-sm font-medium text-primary-foreground",children:[a.jsx(aa,{className:"h-4 w-4"}),"Report settings"]})]})]}),e.error&&a.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive",children:[a.jsx(dt,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.error]}),e.loading?a.jsx("div",{className:"h-72 animate-pulse rounded-lg bg-muted"}):e.dataStatus&&!e.dataStatus.ready?a.jsx(ks,{status:e.dataStatus}):e.status&&!e.status.enabled?a.jsx(de,{children:a.jsxs(ue,{className:"flex min-h-64 flex-col items-center justify-center px-6 text-center",children:[a.jsx(Lr,{className:"h-8 w-8 text-muted-foreground"}),a.jsx("h2",{className:"mt-4 text-base font-semibold",children:e.status.reason==="AI_PROVIDER_REQUIRED"?"Configure an AI provider":"AI cost analysis is not enabled"}),a.jsx("p",{className:"mt-2 max-w-xl text-sm text-muted-foreground",children:e.status.reason==="AI_PROVIDER_REQUIRED"?"Configure and activate an AI provider in Meyi Connect before scheduled cost reports can run.":"An administrator must enable the Cost AI deployment setting before scheduled reports can run."})]})}):a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border bg-card px-4 py-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ea,{className:"h-5 w-5 text-primary"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-semibold",children:e.schedule?.enabled?`${e.schedule.frequency[0].toUpperCase()}${e.schedule.frequency.slice(1)} reports enabled`:"Scheduled reports disabled"}),a.jsx("p",{className:"text-xs text-muted-foreground",children:e.schedule?.enabled?`Next run ${sn(e.schedule.nextRunAt)} (${e.schedule.timezone})`:r?"Open report settings to configure a schedule":"An administrator can configure the report schedule"})]})]}),e.schedule?.lastRunAt&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last run ",sn(e.schedule.lastRunAt)]})]}),e.reports.length?a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full min-w-[960px] text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b bg-muted/40 text-left text-xs text-muted-foreground",children:[a.jsx("th",{className:"px-4 py-3 font-medium",children:"Report period"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Schedule"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"AI provider"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Generated"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Status"}),a.jsx("th",{className:"px-4 py-3 font-medium",children:"Total cost"}),a.jsx("th",{className:"px-4 py-3 text-right font-medium",children:"Actions"})]})}),a.jsx("tbody",{children:e.reports.map(o=>a.jsxs("tr",{className:"border-b last:border-0",children:[a.jsxs("td",{className:"px-4 py-3 font-medium",children:[qf(o.period.Start)," - ",Gf(o.period.End)]}),a.jsx("td",{className:"px-4 py-3 capitalize text-muted-foreground",children:o.frequency}),a.jsxs("td",{className:"px-4 py-3",children:[a.jsx("span",{className:"capitalize",children:o.provider||"-"}),o.modelId&&a.jsx("p",{className:"max-w-48 truncate text-xs text-muted-foreground",title:o.modelId,children:o.modelId})]}),a.jsx("td",{className:"px-4 py-3 text-muted-foreground",children:sn(o.completedAt||o.startedAt||o.createdAt)}),a.jsxs("td",{className:"px-4 py-3",children:[a.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full border px-2 py-1 text-xs font-medium ${Kf[o.status]}`,children:[(o.status==="RUNNING"||o.status==="PENDING")&&a.jsx(st,{className:"h-3 w-3 animate-spin"}),o.status.toLowerCase()]}),o.error&&a.jsx("p",{className:"mt-1 max-w-xs truncate text-xs text-destructive",title:o.error,children:o.error})]}),a.jsx("td",{className:"px-4 py-3",children:o.facts?new Intl.NumberFormat(void 0,{style:"currency",currency:o.facts.currency}).format(o.facts.currentTotal):"-"}),a.jsx("td",{className:"px-4 py-3",children:a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>{e.download(o)},disabled:!o.pdfReady,className:"inline-flex h-9 items-center gap-2 rounded-lg border px-3 text-sm font-medium hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40",title:o.pdfReady?"Download PDF":"PDF not ready",children:[a.jsx(En,{className:"h-4 w-4"}),"Download"]}),r&&a.jsx("button",{type:"button",onClick:()=>{e.remove(o)},disabled:e.removingId===o.id||o.status==="RUNNING"||o.status==="PENDING",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg border text-destructive hover:bg-destructive/10 disabled:cursor-not-allowed disabled:opacity-40",title:"Remove report","aria-label":"Remove report",children:e.removingId===o.id?a.jsx(st,{className:"h-4 w-4 animate-spin"}):a.jsx(ia,{className:"h-4 w-4"})})]})})]},o.id))})]})})}):a.jsx(de,{children:a.jsxs(ue,{className:"flex min-h-64 flex-col items-center justify-center px-6 text-center",children:[a.jsx(ra,{className:"h-8 w-8 text-muted-foreground"}),a.jsx("h2",{className:"mt-4 text-base font-semibold",children:"No scheduled reports yet"}),a.jsx("p",{className:"mt-2 max-w-lg text-sm text-muted-foreground",children:"The first report will appear here after the configured schedule runs."})]})})]}),e.schedule&&a.jsx(Wf,{open:s,schedule:e.schedule,saving:e.saving,onClose:()=>n(!1),onSave:e.saveSchedule})]})}const kt=fc({component:Ro}),Jf=Ht({getParentRoute:()=>kt,path:"/",component:Sf}),Xf=Ht({getParentRoute:()=>kt,path:"/reports",component:If}),Zf=Ht({getParentRoute:()=>kt,path:"/cur-discovery",component:Ff}),Qf=Ht({getParentRoute:()=>kt,path:"/analysis",component:Yf}),eh=Ht({getParentRoute:()=>kt,path:"/sources",component:Bf});function On(){return kt.addChildren([Jf,Qf,Xf,eh,Zf])}function th(e="/cost"){return No({routeTree:On(),basepath:e})}function sh({apiBase:e,token:t,basePath:s="/cost",userRole:n="user",tenantId:r="default"}){Xo(e,t);const o=E.useMemo(()=>No({routeTree:On(),basepath:s}),[s]);return a.jsx(hf,{value:n,children:a.jsx(pf,{tenantId:r,children:a.jsx(_c,{router:o})})})}const nh=[{title:"Overview",url:"/",icon:"DollarSign",roles:["admin","user"]},{title:"AI Analysis",url:"/analysis",icon:"Sparkles",roles:["admin","user"]},{title:"Reports",url:"/reports",icon:"FileText",roles:["admin","user"]},{title:"Sources",url:"/sources",icon:"CloudCog",roles:["admin"]},{title:"CUR Discovery",url:"/cur-discovery",icon:"Search",roles:["admin"]}];exports.CostPage=sh;exports.api=se;exports.attachAuthInterceptors=Cd;exports.configureApi=Xo;exports.costNavItems=nh;exports.createCostRouter=th;exports.createRouteTree=On;