1(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`5.638.0-7ddb52834a`}}catch{}})();try{(function(){var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`0507c9b3-5fbe-4c17-ae98-b2f68d8c4adf`,e._sentryDebugIdIdentifier=`sentry-dbid-0507c9b3-5fbe-4c17-ae98-b2f68d8c4adf`)})()}catch{}import{o as e}from"./chunk-CgkbBqyz.js";import{t}from"./react-BlBPBdOl.js";import{n,t as r}from"./logger-bFGQVteH.js";import{t as i}from"./useMutation-CV0zZABy.js";import{t as a}from"./useQuery-C5tYMBqG.js";import{t as o}from"./queryOptions-DaTClOKF.js";import{_ as s,h as c,l,n as u}from"./mobx.esm-5VjLEOXB.js";import{t as d}from"./Notification-Bb_4A3v-.js";import{o as f}from"./ThemeStore-jyD44g22.js";import{i as ee}from"./numbers-whfLEtHd.js";import{L as p}from"./dates-D9u2Q0LP.js";import{t as m}from"./queryKeys-CM36kvq0.js";import{n as h}from"./dashApi-Drpr9tog.js";import{n as g}from"./getStatusUsageQuery-CJSGx9JY.js";import{t as _}from"./capitalize-K5EtFwm7.js";import{t as v}from"./moment-timezone-DusdgvtF.js";import{n as y,r as b}from"./StoreBase-XhQdiY6M.js";import{t as x}from"./getOrgQuery-CSMHkpiW.js";import{t as S}from"./pretty-bytes-B_wO1cXj.js";var C=e=>e.status===`draft`,w=`subscription_threshold`,te=e=>e.billingReason===w,T=e(_(),1);l();var E=e(t(),1),D=e=>({periodEndDate:p(e.periodEndDate),creditsLastPurchased:e.creditsLastPurchased,periodStartDate:p(e.periodStartDate),lineItems:e.lineItems,totalUsd:e.totalUsd,subtotalUsd:e.subTotalUsd,creditUsd:e.creditUsd}),O=e=>({id:e.id,metaCreated:e.metaCreated?p(e.metaCreated):void 0,metaModified:e.metaModified?p(e.metaModified):void 0,metaVersion:e.metaVersion,name:e.name,plan:e.plan,planCreated:p(e.planCreated),lastUsageSync:p(e.lastUsageSync),startupProgram:e.startupProgram}),k=`axiomCloud`,A=`personal`,j=`basic`,M=`basicDirect`,N=`enterprise`,P=`comped`,F=`teamMonthly`,I=`teamMonthlyDirect`,L=`teamMonthlyAws`,R=`teamPlus`,z=`accelerator`,B=e=>e,V=e=>e?![L,R].includes(e):!1,H=(e,t)=>{if((e===`comped`||e===`enterprise`||e===`accelerator`)&&t===`axiomCloud`)return!1;let n=[A,F,I,j,M,k,z,N,P];return n.indexOf(e)>n.indexOf(t)},U=async(e,t,n)=>{n&&e.setQueryData(m.org(t),n),await Promise.allSettled([e.invalidateQueries({queryKey:m.org(t),refetchType:`all`}),e.invalidateQueries({queryKey:m.orgLicense(t),refetchType:`all`}),e.invalidateQueries({queryKey:m.userStatus(t),refetchType:`all`}),e.invalidateQueries({queryKey:m.userStatus(),refetchType:`all`}),g(e)])},W=class extends b{downgradePlanOps=new y(this,`downgradePlan`);getBillingDetailsOps;getInvoicesOps=new y(this,`getInvoices`);getPaymentMethodOps=new y(this,`getPaymentMethod`);getStripeBillingIntentOps=new y(this,`getStripeBillingIntent`);getStripePortalOps=new y(this,`getStripePortal`);getUsageOps=new y(this,`getUsage`);upgradePlanOps=new y(this,`upgradePlan`);billingDetails;invoices=[];paymentMethod;stripeSetupIntent;usage;ctx;constructor(e){super(),this.ctx=e,this.getBillingDetailsOps=new y(this,m.org(this.ctx.orgId)),c(this),e.axiom.stripePubKey||n.warn(r.GENERAL,`Stripe Publishable Key not set.`)}getBillingDetails(){this.operateRQ(this.ctx.queryClient,this.getBillingDetailsOps.operation,async()=>h.getOrg({id:this.ctx.orgId}),e=>{this.billingDetails=O(e)},!0,void 0,void 0,void 0,{queryKey:m.org(this.ctx.orgId)})}getInvoices(){this.operate(this.getInvoicesOps.operation,h.getInvoices({id:this.ctx.orgId}),e=>{this.invoices=this.mapInvoices(e||[])},!0)}async getPaymentMethod(){await this.operate(this.getPaymentMethodOps.operation,h.getPaymentMethod({id:this.ctx.orgId}),e=>{this.paymentMethod=e||void 0},!0)}async getStripeBillingIntent(){await this.operate(this.getStripeBillingIntentOps.operation,h.getStripeBillingIntent({id:this.ctx.orgId}),e=>{this.stripeSetupIntent=e})}getStripePortal(e=`billing`){this.operate(this.getStripePortalOps.operation,h.getStripePortal({id:this.ctx.orgId,mode:e}),e=>{e.uri?window.location.href=e.uri:d.error({message:`Failed to connect to Stripe Portal.`,description:`You may not have a Stripe Customer Id.`},{duration:1/0,id:`getStripePortal`})})}async downgradePlan(e,t){if(!V(this.billingDetails?.plan)||e===`teamMonthlyAws`)return Promise.resolve();let i=B(e),a=`downgradePlan`;this.dismissError(a);let{reason:o,vendor:s,improvements:c}=t||{reason:``,vendor:``,improvements:``};await this.operate(this.downgradePlanOps.operation,h.downgradePlan({id:this.ctx.orgId},{targetPlan:i,improvements:c,reason:o,vendor:s}),e=>{let t=this.ctx.orgId;this.billingDetails=O(e),U(this.ctx.queryClient,t,e),this.ctx.queryClient.invali
1dateQueries({queryKey:m.orgLicense(t)})},!1,(e,t)=>{n.error(r.GENERAL,`Downgrade failed`,{error:e,op:t}),d.error({message:`Failed to downgrade your plan`,description:`Your plan failed to downgrade. Please contact [email protected]\n\n${t.error}`},{duration:1/0,id:a})},a)}async upgradePlan(e,t){if(!V(this.billingDetails?.plan)||e===`teamMonthlyAws`)return Promise.resolve();let i=`upgradePlan`;this.dismissError(i);let a=B(e);await this.operate(this.upgradePlanOps.operation,h.upgradePlan({id:this.ctx.orgId},{paymentMethodID:t,targetPlan:a}),e=>{let t=this.ctx.orgId;this.billingDetails=O(e),U(this.ctx.queryClient,t,e),this.ctx.queryClient.invalidateQueries({queryKey:m.orgLicense(t)})},!1,(e,t)=>{n.error(r.GENERAL,`Upgrade failed`,{error:e,op:t}),d.error({message:`Failed to upgrade your plan`,description:`Your payment information has been saved, but your plan failed to upgrade. Please contact [email protected]\n\n${t.error}`},{duration:1/0,id:i})},i)}getUsage(){let e=`getUsage`;this.dismissError(e),this.operate(this.getUsageOps.operation,h.getUsage({id:this.ctx.orgId}),e=>{this.usage=D(e)},!1,(t,i)=>
1{n.error(r.GENERAL,`Get usage failed`,{error:t,op:i}),d.error({message:`Failed to get usage information`,description:`Could not get usage information at this time. Please try again later or contact [email protected]`},{duration:1/0,id:e})},e)}mapInvoices=e=>e.map(e=>({issuedDate:p(e.issuedDate),paid:e.paid,receiptUrl:e.receipt,total:e.total,status:e.status}))};f([s],W.prototype,`billingDetails`,void 0),f([s],W.prototype,`invoices`,void 0),f([s],W.prototype,`paymentMethod`,void 0),f([s],W.prototype,`stripeSetupIntent`,void 0),f([s],W.prototype,`usage`,void 0),f([u.bound],W.prototype,`getBillingDetails`,null),f([u.bound],W.prototype,`getInvoices`,null),f([u.bound],W.prototype,`getPaymentMethod`,null),f([u.bound],W.prototype,`getStripeBillingIntent`,null),f([u.bound],W.prototype,`getStripePortal`,null),f([u.bound],W.prototype,`downgradePlan`,null),f([u.bound],W.prototype,`upgradePlan`,null),f([u.bound],W.prototype,`getUsage`,null);var G=e=>o({queryKey:m.getUsage(e),queryFn:async()=>h.getUsage({id:e}),select:e=>D(e),meta:{toast:!0,id:`getUsage`},staleTime:1e3*60*5});function K(e){return e===`teamMonthlyAws`?`AWS Team`:e===`basicDirect`?`Basic (Legacy)`:e===`teamMonthlyDirect`?`Team (Legacy)`:e===`teamPlus`?`Enterprise`:e===`accelerator`?`Accelerator`:e===`axiomCloud`?`Axiom Cloud`:(0,T.default)(e.replace(`Monthly`,``))}var q=(0,E.createContext)(null);q.displayName=`BillingStoreContext`;var J=e=>o({...x(e),select:e=>O(e),meta:{toast:!0,id:`getBillingDetails`}}),Y=(e=``)=>a({...J(e),enabled:!!e}),X=(e=``,t)=>i({mutationFn:async()=>h.getStripePortal({id:e,mode:t}),meta:{toast:!0,id:`getStripePortal`}}),Z=e=>{switch(e){case A:return 0;case z:case N:case P:return;case j:case M:return 99;default:return 25}},ne=e=>`$${e.toLocaleString()}/mo`,re=e=>ee(e/100,0,`USD`),ie=e=>{let t=e/100;return new Intl.NumberFormat(navigator.language||`en-US`,{style:`currency`,currency:`USD`,minimumFractionDigits:2}).format(t)},ae=e=>{let t=e/100;return new Intl.NumberFormat(navigator.language||`en-US`,{style:`decimal`,minimumFractionDigits:0}).format(t)},oe=e=>{let t=e.replace(/\.00/,``).replace(/[^0-9.]/g,``);try{return parseFloat(t)}catch{return}};function se(e){let t=v.default.duration(e,`seconds`);if(e<=86400)return`${t.hours()} ${t.hours()===1?`hour`:`hours`}`;if(e>=31536e3){let e=Math.max(Math.floor(t.asYears()),1);return`${e} ${e===1?`year`:`years`}`}let n=Math.floor(t.asDays());return`${n} ${n===1?`day`:`days`}`}var Q=e=>e!==A,ce=(e,t)=>Q(e.plan)?!0:t?.some(e=>!C(e))===!0,$=e=>{switch(e){case z:case N:case A:case P:return!1;default:return!0}},le=e=>{switch(e){case A:case z:case P:case N:return!1;default:return!0}},ue=e=>{switch(e){case k:case P:return!1;default:return!0}},de=e=>e===k,fe=e=>{switch(e){case P:case N:return!0;default:return!1}},pe=(e,t)=>{if(!t)return`hard`;switch(t){case k:case N:case P:switch(e){case`maxDatasets`:case`maxUsers`:case`maxMonitors`:return`soft`;case`monthlyIngestGb`:case`monthlyQueryGbHours`:case`monthlyStorageGb`:return`allowance`;default:return`hard`}default:return`hard`}},me=1e9,he=e=>S(e*me);export{ue as A,te as B,pe as C,Q as D,U as E,he as F,ce as I,Y as L,$ as M,B as N,fe as O,oe as P,X as R,re as S,Z as T,ae as _,j as a,K as b,N as c,L as d,I as f,de as g,V as h,k as i,le as j,H as k,A as l,J as m,q as n,M as o,R as p,z as r,P as s,W as t,F as u,ie as v,G as w,se as x,ne as y,C as z}; 2//# sourceMappingURL=BillingStore-BGNeHTvx.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.