PageSourceSearch

https://app.upmetrics.co/chunks/CDrERE1x.js

js upmetrics.co collected 2026-10-01 11:52:12 UTC 13,226 bytes, 1 lines download raw bytes

1import{r as x,j as r}from"./Dem1e8VV.js";import{d as X}from"./dWhdajSv.js";import{u as z,ay as Ee,cC as me,cD as pe,ch as he,y as G,c3 as Y,g4 as fe,cl as q,aK as Ne,aL as _e}from"../entry/CcVTEBpa.js";import"./BnZNklX7.js";import{C as K}from"./CHWXHrH4.js";import"./phrJN640.js";import{g as Z,a as ee,A as Re,b as ge,P as xe,t as Ae,c as te,d as ne,G as se,E as ye,R as ae,s as be,F as Le,e as Ce,f as Te}from"./D4uaOMhM.js";import{u as Oe,F as de}from"./CTibiPUG.js";import{b as re,r as Ie,o as W,T as B,V as oe,a as ie}from"./BdhxqbeK.js";import{u as Se,r as De}from"./CJcZnSSQ.js";import{g as Pe}from"./B6JQPiWR.js";import"./Dh95b2SR.js";import"./Cscm7JI5.js";const je=7;function Ue(e,_,a=je){if(e.length<=a+1)return e;const i=[...e].sort((m,E)=>{const g=h=>h.data.reduce((c,s)=>c+Math.abs(s||0),0);return g(E)-g(m)}),t=i.slice(0,a),n=i.slice(a),u=n.reduce((m,E)=>Math.max(m,E.data.length),0),N=new Array(u).fill(0);return n.forEach(m=>m.data.forEach((E,g)=>{var h;N[g]=((h=N[g])!=null?h:0)+(E||0)})),[...t,{id:"__other__",name:`${_} (${n.length})`,color:"var(--color-muted-foreground)",data:N}]}const ce=be("revenue","netRevenue",K);function ve(){const{businessId:e,projection:_,year:a}=X(),i=z(),{humanizeCompactInteger:t}=Ee(),n=me(),u=pe(),m=he().isActualEnabled(e),[E,g]=x.useState("byStream"),h=G(()=>{var f;return(f=Y.find({businessId:e}))==null?void 0:f.fetch()},[e]),c=G(()=>fe.findOne({businessId:e},{fields:{"plannedData.netRevenue":1,"actualData.netRevenue":1}}),[e]);x.useEffect(()=>{e&&g(ce.get(e))},[e]);const s=x.useMemo(()=>n.getDataFilterMeta(e,_,a),[e,_,a]),o=x.useMemo(()=>u.getColumnAndKeys(e,s),[e,s,u]),l=x.useMemo(()=>(h!=null?h:[]).map(f=>f._id),[h]),p=Oe({collection:q,seriesKey:de.revenue.seriesKey},l),A=x.useMemo(()=>{var b,T,I;if(!m)return[];const f=E==="byStream"?p.recordedIndices:re(s.chart.dataKeys,[(b=c==null?void 0:c.actualData)==null?void 0:b.netRevenue]);if(!f.length)return[];const R=(T=o.columns)!=null?T:[],C=i("FORECAST_OVERVIEW.RECORDED_BOUNDARY",{period:(I=R[Math.max(...f)])!=null?I:"",raw:!0});return Ie(f,C,R.length)},[m,E,p,s.chart.dataKeys,c,o,i]),L=x.useMemo(()=>{var T,I,V;if(E==="byStream"){const v=(h!=null?h:[]).filter(d=>{var D,M;const O=(D=p.seriesByGroup[d._id])!=null?D:[],F=(M=p.actualSeriesByGroup[d._id])!=null?M:[];return O.some(P=>P!==0)||F.some(P=>P!==0)}),w=Ue(v.map(d=>{var O;return{id:d._id,name:d.title,color:d.color,data:(O=p.seriesByGroup[d._id])!=null?O:[]}}),i("REVENUE_PLAN.OTHER_STREAMS",{raw:!0})),J=new Set(w.map(d=>d.id)),S=w.find(d=>d.id==="__other__"),ue=v.filter(d=>!J.has(d._id)).reduce((d,O)=>{var D;const F=(D=p.actualSeriesByGroup[O._id])!=null?D:[];return d.map((M,P)=>{var $;return M+(($=F[P])!=null?$:0)})},new Array((T=S==null?void 0:S.data.length)!=null?T:0).fill(0));return[...v.filter(d=>J.has(d._id)),...S?[null]:[]].flatMap(d=>{var P,$;if(!d){const Q=(P=S.color)!=null?P:"var(--color-muted-foreground)",H={name:S.name,data:S.data,dataType:"plannedData",key:"__other__",color:Q,fillColor:void 0,stack:"planned",legendName:S.name};return!m||!p.recordedIndices.length?[H]:[H,{...H,data:W(ue,p.recordedIndices),dataType:"actualData",color:Z(Q),stack:"actual",linkedTo:":previous"}]}const O=d.color||ee,F={name:d.title,data:($=p.seriesByGroup[d._id])!=null?$:[],dataType:"plannedData",key:d._id,color:O,fillColor:void 0,stack:"planned",legendName:d.title},D=p.actualSeriesByGroup[d._id],M=m&&D&&p.recordedIndices.length?[{name:d.title,data:W(D,p.recordedIndices),dataType:"actualData",key:d._id,color:Z(O),fillColor:void 0,stack:"actual",linkedTo:":previous",legendName:d.title}]:[];return[F,...M]})}const f={name:`${i(K[E])}`,data:u.getSeriesData(s.chart.dataKeys,(I=c==null?void 0:c.plannedData)==null?void 0:I.netRevenue),dataType:"plannedData",color:ee,fillColor:xe,stack:"planned",legendName:i("COMP_REVENUE.PLANNED")},R=(V=c==null?void 0:c.actualData)==null?void 0:V.netRevenue,C=re(s.chart.dataKeys,[R]),b=m&&C.length?[{name:`${i(K[E])} (${i("COMP_REVENUE.ACTUAL")})`,data:W(u.getSeriesData(s.chart.dataKeys,R),C),dataType:"actualData",color:ge,fillColor:Re,stack:"actual",legendName:i("COMP_REVENUE.ACTUAL")}]:[];return[f,...b]},[s.chart.dataKeys,c,m,E,i,h,p]),y=x.useMemo(()=>
1{if(!o.columns)return{};const f=E==="byStream"?"column":"areaspline",R=Ae(L,f);return{chart:{type:f,spacingBottom:0},title:{text:void 0},xAxis:{categories:o.columns,gridLineWidth:1,gridLineColor:se,gridLineDashStyle:"Dash",lineWidth:0,labels:{style:{color:ne}},plotLines:A},yAxis:{gridLineWidth:1,gridLineColor:se,gridLineDashStyle:"Dash",lineWidth:0,labels:{formatter:function(){return t(this.value,2,!0)},style:{color:ne}},title:{text:""}},tooltip:{useHTML:!0,shared:!0,backgroundColor:"transparent",borderWidth:0,shadow:!1,padding:0,formatter:function(){if(!this.points||this.points.length===0)return"";const C=this.points[0].category,b=ye(this.points);if(E!=="byStream")return ae(C,b,m,i,t);let T=0,I=0,V=!1;return Object.values(b).forEach(v=>{var w;T+=(w=v.planned)!=null?w:0,v.actual!=null&&(I+=v.actual,V=!0)}),ae(C,b,m,i,t,{label:i("REVENUE_PLAN.TOTAL_REVENUE"),planned:T,actual:V?I:void 0})}},legend:{enabled:!0,margin:6,padding:4,itemDistance:18,labelFormatter:function(){return this.userOptions.legendName||this.name}},credits:{enabled:!1},plotOptions:{areaspline:{fillOpacity:.2},column:{borderWidth:2,borderColor:te,borderRadius:2,groupPadding:.1,stacking:"normal"},series:{lineWidth:2,marker:{enabled:!1,states:{hover:{enabled:!0,radius:4,lineWidth:2,lineColor:te}}},clip:!0}},series:R,accessibility:{enabled:!1}}},[L,o,E,A,m,i,t]),j=x.useCallback(f=>{g(f),e&&ce.set(e,f)},[e]),U=`${e}-${_}-${a}`;return{selectedOption:E,handleOptionChange:j,chartOptions:y,chartKey:U}}function Me(){const e=Se({groupCollection:Y,itemCollection:q,seriesKey:de.revenue.seriesKey,itemFields:{isSetupPending:1}}),_=x.useMemo(()=>e.items.filter(t=>t.isSetupPending).length,[e.items]),a=x.useMemo(()=>De(e.items,{nameOf:t=>{var n;return((n=t.metaInfo)==null?void 0:n.name)||""},valueOf:t=>{var n;return(n=e.totalByItem[t._id])!=null?n:0},colorOf:t=>{var n;return(n=e.groups.find(u=>u.id===t.groupId))==null?void 0:n.color}}),[e.items,e.totalByItem,e.groups]),i=x.useMemo(()=>{var c;const{opening:t,ending:n,firstActiveIndex:u,labels:N,actualSeriesByGroup:m,recordedIndices:E}=e,g=s=>Object.keys(s).reduce((o,l)=>{var p;return((p=s[l])!=null?p:[]).forEach((A,L)=>{var y;o[L]=((y=o[L])!=null?y:0)+A}),o},[]),h=E.length>=2?Pe(g(m),E):null;return t>0?{percent:(n-t)/t*100,actual:h,startsAt:null}:n>0&&u>=0?{percent:null,actual:h,startsAt:(c=N[u])!=null?c:null}:{percent:null,actual:h,startsAt:null}},[e]);return{...e,streams:e.groups,rows:a,growth:i,unfinished:_}}function Ve({total:e,scopeLabel:_,largest:a,leadingActual:i,growth:t,openingLabel:n,itemCount:u,ending:N,actualEnding:m,endingLabel:E,endingTitle:g,isActualEnabled:h,actual:c,plannedToDate:s,recordedPeriods:o}){var j,U,f;const l=z(),{formatCompactNumber:p}=Ne(),A=R=>p(R,1,!0),L=R=>`${R.toFixed(R%1===0?0:1)}%`,y=((j=a==null?void 0:a.share)!=null?j:0)>60;return r.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[r.jsxs(B,{label:`${l("REVENUE_PLAN.TOTAL_REVENUE")} · ${_}`,note:h&&o||!u?void 0:l("REVENUE_PLAN.ACROSS_STREAMS",{count:u}),children:[r.jsx("span",{className:"text-2xl font-bold tabular-nums tracking-tight text-foreground",children:u?A(e):"—"}),h&&!!o&&(()=>{const R=s?((c!=null?c:0)-s)/s*100:null;return r.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[r.jsxs("span",{className:"text-xs text-muted-foreground",children:[l("COMP_EXPENSE.ACTUAL")," ",r.jsx("span",{className:"font-semibold tabular-nums text-foreground",children:c!=null?A(c):"—"})]}),r.jsx(oe,{value:R,higherIsBetter:!0}),!!o&&r.jsx("span",{className:"text-xs text-muted-foreground",children:l("REVENUE_PLAN.RECORDED_PERIODS",{count:o})})]})})()]}),r.jsx(B,{label:l("REVENUE_PLAN.LARGEST_STREAM"),note:a?r.jsxs("span",{className:"flex flex-col gap-0.5",children:[r.jsxs("span",{className:y?"font-semibold text-amber-700":"font-semibold text-green-600",children:[L(a.share)," ",l(h?"REVENUE_PLAN.OF_PLANNED_REVENUE":"REVENUE_PLAN.OF_REVENUE"),y?` · ${l("REVENUE_PLAN.CONCENTRATED")}`:` · ${l("REVENUE_PLAN.WELL_SPREAD")}`]}),i&&i.id!==a.id&&r.jsx("span",{children:l("REVENUE_PLAN.LEADS_ON_ACTUALS",{name:i.name})})]}):void 0,children:r.jsxs("span",{className:"flex items-center gap-2 truncate text-lg font-semibold text-foreground",children:[(a==null?void 0:a.color)&&r.jsx("span",{className:"size-2.5 shrink-0 rounded-full",style:{backgroundColor:a.color}}),r.jsx("span",{className:"truncate",title:(U=a==null?void 0:a.name)!=null?U:void 0,children:(f=a==null?void 0:a.name)!=null?f:"—"})]})}),r.jsx(B,{label:l("REVENUE_PLAN.GROWTH"),note:t.actual!=null?r.jsxs("span",{className:"flex flex-wrap items-center gap-x-2",children:[r.jsxs("span",{children:[n," → ",E]}),r.jsxs("span",{className:"flex items-center gap-1",children:[l("COMP_EXPENSE.ACTUAL"),r.jsx("span",{className:"text-xs",children:r.jsx(ie,{value:t.actual,higherIsBetter:!0})}),!!o&&r.jsx("span",{children:l("REVENUE_PLAN.RECORDED_PERIODS",{count:o})})]})]}):t.percent!=null?`${n} → ${E}`:t.startsAt?l("REVENUE_PLAN.GROWTH_STARTS",{month:t.startsAt}):l("REVENUE_PLAN.GROWTH_NONE"),children:r.jsx(ie,{value:t.percent,higherIsBetter:!0})}),r.jsxs(B,{label:g,note:E,children:[r.jsx("span",{className:"text-lg font-semibold tabular-nums text-foreground",children:A(N)}),h&&m!=null&&r.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[r.jsxs("span",{className:"text-xs text-muted-foreground",children:[l("COMP_EXPENSE.ACTUAL")," ",r.jsx("span",{className:"font-semibold tabular-nums text-foreground",children:A(m)})]}),r.jsx(oe,{value:N?(m-N)/N*100:null,higherIsBetter:!0})]})]})]})}function k(e){if(!e)return;if(typeof e=="string")return e.slice(0,7);const _=e instanceof Date?e:new Date(e);if(!Number.isNaN(_.getTime()))return`${_.getFullYear()}
1-${String(_.getMonth()+1).padStart(2,"0")}`}function le(e,_){if(!e||!_)return 0;const[a,i]=e.split("-").map(Number),[t,n]=_.split("-").map(Number);return(t-a)*12+(n-i)+1}function we(){const{businessId:e}=X(),_=_e(),a=G(()=>{var n;return(n=Y.find({businessId:e},{fields:{title:1,isExcluded:1}}))==null?void 0:n.fetch()},[e]),i=G(()=>{var n;return(n=q.find({businessId:e},{fields:{groupId:1,metaInfo:1,isExcluded:1,isSetupPending:1}}))==null?void 0:n.fetch()},[e]),t=(i!=null?i:[]).map(n=>{var u;return`${n._id}:${JSON.stringify((u=n.metaInfo)!=null?u:{})}:${n.isExcluded}`}).join("|");return x.useMemo(()=>{const n=_.getPlanningDates(e),u=k(n==null?void 0:n.startDate),N=k(n==null?void 0:n.endDate),m=le(u,N)||12,E=(i!=null?i:[]).filter(s=>!s.isExcluded),g=E.filter(s=>!s.isSetupPending);if(!E.length)return[];const h=s=>{var o,l;return((o=s.metaInfo)==null?void 0:o.name)||((l=(a!=null?a:[]).find(p=>p._id===s.groupId))==null?void 0:l.title)||""},c=[];return E.filter(s=>s.isSetupPending).forEach(s=>{var o;c.push({id:`unfinished:${s._id}`,rowId:s._id,subject:((o=s.metaInfo)==null?void 0:o.name)||"",message:"NOTE_NEEDS_PRICE"})}),g.forEach(s=>{var U,f,R,C,b;const o=(U=s.metaInfo)!=null?U:{},l=h(s),p=(f=k(o.startDate))!=null?f:u,A=(R=k(o.endDate))!=null?R:N,L=le(p,A)||m,y=Number((C=o.growth)!=null?C:0),j=o.unitsConst!==!1&&o.priceConst!==!1;j&&!y&&L>=12&&o.type!=="fixed"&&c.push({id:`flat:${s._id}`,rowId:s._id,subject:l,message:"NOTE_FLAT"}),j&&y>0&&o.growthDirection!=="minus"&&Math.pow(1+y/100,Math.max(0,L-1))>=10&&c.push({id:`growth:${s._id}`,rowId:s._id,subject:l,message:"NOTE_GROWTH"}),o.type==="subscription"&&!Number((b=o.churnRate)!=null?b:0)&&c.push({id:`churn:${s._id}`,rowId:s._id,subject:l,message:"NOTE_NO_CHURN"})}),g.length>1&&u&&g.every(o=>{var l,p;return((p=k((l=o.metaInfo)==null?void 0:l.startDate))!=null?p:u)===u})&&c.push({id:"all-at-once",subject:"",message:"NOTE_ALL_AT_ONCE"}),c},[e,t,a])}const Ze=()=>{const{selectedOption:e,handleOptionChange:_,chartOptions:a,chartKey:i}=ve(),t=Me(),n=we(),{projection:u}=X(),N=z(),m=N(u==="yearly"?"REVENUE_PLAN.ENDING_YEAR":u==="quarterly"?"REVENUE_PLAN.ENDING_QUARTER":"REVENUE_PLAN.ENDING_MONTH",{raw:!0});return t.isUnstarted?null:r.jsxs("div",{className:"space-y-4",children:[r.jsx(Ve,{total:t.total,scopeLabel:t.scopeLabel,largest:t.largest,leadingActual:t.leadingActual,growth:t.growth,openingLabel:t.openingLabel,ending:t.ending,actualEnding:t.actualEnding,endingLabel:t.endingLabel,endingTitle:m,itemCount:t.itemCount,isActualEnabled:t.hasActuals,actual:t.actualTotal,plannedToDate:t.plannedToDateTotal,recordedPeriods:t.recordedPeriods}),r.jsx(Le,{notes:n,i18n:"REVENUE_PLAN"}),r.jsxs("div",{className:"grid grid-cols-1 gap-4 xl:grid-cols-[2fr_1fr] [&>*]:min-w-0",children:[r.jsx(Ce,{isEmpty:!t.hasRows,chartOptions:a,options:K,selectedOption:e,onOptionChange:_,chartKey:`${i}:${e}`,subtitle:t.hasRecordedFigures&&e==="byStream"?N("REVENUE_PLAN.CHART_RECORDED_HINT"):void 0}),r.jsx(Te,{className:"xl:h-0 xl:min-h-full",groups:t.streams,alternate:{rows:t.rows,groupLabel:N("REVENUE_PLAN.MIX_BY_GROUP",{raw:!0}),rowLabel:N("REVENUE_PLAN.MIX_BY_ITEM",{raw:!0})},title:N("REVENUE_PLAN.REVENUE_MIX"),scopeLabel:t.scopeLabel,emptyLabel:N("REVENUE_PLAN.MIX_EMPTY",{raw:!0})})]})]})};export{Ze as OverviewComponent};

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.