1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[45170],{45170:(e,t,r)=>{r.r(t),r.d(t,{ConcentrationSection:()=>em,default:()=>ep});var n=r(95155),a=r(12115),s=r(81477),l=r(29991),o=r(42763),i=r(89239),u=r(60529),c=r(33807),d=r(36256),m=r(56137),p=r(63119),v=r(80946),g=r(83573),f=r(13506),h=r(47273),b=r(3951),y=r(70037),w=r(75709),x=r(88061),C=r(90568),P=r(13132),E=r(34466),j=r(80265);let N=e=>({concentrationARRPeriod:e.concentrationARRPeriod,concentrationUpsellPeriod:e.concentrationUpsellPeriod,concentrationNewPeriod:e.concentrationNewPeriod,concentrationChurnPeriod:e.concentrationChurnPeriod,concentrationDownsellPeriod:e.concentrationDownsellPeriod,concentrationTopEventsPeriod:e.concentrationTopEventsPeriod,concentrationTopEventsRowCount:e.concentrationTopEventsRowCount}),M=e=>({setConcentrationARRPeriod:e.setConcentrationARRPeriod,setConcentrationUpsellPeriod:e.setConcentrationUpsellPeriod,setConcentrationNewPeriod:e.setConcentrationNewPeriod,setConcentrationChurnPeriod:e.setConcentrationChurnPeriod,setConcentrationDownsellPeriod:e.setConcentrationDownsellPeriod,setConcentrationTopEventsPeriod:e.setConcentrationTopEventsPeriod,setConcentrationTopEventsRowCount:e.setConcentrationTopEventsRowCount});var T=r(60933),k=r(10480),S=r(43426),D=r(5606),_=r(55235),R=r(22837),I=r(3033),A=r(87698),$=r(75215),O=r(75801),W=r(4550),F=r(93208),L=r(95494),V=r(66645),B=r(47420),z=r(36443),U=r(76415);function q(e,t,r){if(!(r<=0)){if(e.length<r){e.push(t),e.sort((e,t)=>e.value-t.value);return}t.value<=e[0].value||(e[0]=t,e.sort((e,t)=>e.value-t.value))}}var K=r(2288),G=r(2467),X=r(65453),H=r(20464);function Q(e){let t="unavailable"===e.failure?"top_events_resident_rpc_unavailable":"top_events_resident_rpc_failed",r=void 0===e.error?{}:{error:e.error instanceof Error?e.error.message:String(e.error)};return(0,H.Q7)()?(V.vF.error("[TopEventsOfAllTimeCard] Resident-RPC recovery gated at single-copy scale; preserving the stable empty state",{fallback_state:"top_events_resident_rpc_recovery_gated_at_scale",resident_rpc_failure_state:t,period:e.period,rowCount:e.rowCount,...r}),"gated-at-scale"):(V.vF.error(`[TopEventsOfAllTimeCard] fallback_state: resident-RPC top events ${e.failure} â self-healing the envelope`,{fallback_state:t,period:e.period,rowCount:e.rowCount,...r}),H.sO.getState().ensureBaseAggregatedCustomerData("unavailable"===e.failure?"TopEventsOfAllTimeCard:rpc-unavailable":"TopEventsOfAllTimeCard:rpc-failed"),"below-scale-self-heal-started")}var J=r(92513);let Z={newEvents:[],upsellEvents:[],downsellEvents:[],churnEvents:[]},Y=[10,15,20,25],ee=Object.freeze([]),et=Object.freeze([]),er=Object.freeze([]),en=Object.freeze([]);function ea(e){return"new"===e||"upsell"===e}let es=/^(?:|n\/?a|na|null|undefined|\(blank\)|unknown)$/i;function el(e,t){let r=t.flatMap(e=>e.rows);return e.map((e,t)=>{let n=r.map(t=>{var r;let n,a;return r=e.label,n=(0,O.s)(r),a=Object.entries(t.attributes??{}).find(([e])=>(0,O.s)(e)===n),String(a?.[1]??"").trim()}).filter(e=>!es.test(e));return{column:e,index:t,coverage:r.length>0?n.length/r.length:0,variation:new Set(n).size}}).filter(e=>e.coverage>=.5&&e.variation>1).sort((e,t)=>t.coverage-e.coverage||t.variation-e.variation||e.index-t.index).slice(0,2).map(e=>e.column)}function eo(e){let{row:t}=e,r=e.aggregatedData[t.period]?.data?.[t.customerId]??e.aggregatedData[t.prevPeriod]?.data?.[t.customerId],n=new Map(Object.entries(t.attributes??r?.attributes??{}).map(([e,t])=>[(0,O.s)(e),t]));return{descriptorValues:Object.fromEntries(e.descriptorColumns.map(e=>{let t=n.get((0,O.s)(e)),r=Array.isArray(t)?t.filter(e=>null!=e&&String(e).trim()).join(", "):t;return[e,null==r||0===String(r).trim().length?"â":String(r)]})),metricValues:Object.fromEntries((e.metricColumns??[]).map(r=>{let n=(0,G.jW)({column:r,customerId:t.customerId,period:t.period,prevPerio
1d:t.prevPeriod});return[r.columnKey,(0,G.HW)({delta:n,valueKind:r.valueKind,formatCurrency:e.formatValue,decimalPoints:e.decimalPoints,currency:e.currency})]}))}}let ei="monthly";function eu(e){return e.category.items.map(t=>{let r=t.period??"",n=t.comparisonPeriod??"",a=t.customerId??"",s=e.aggregatedData[r]?.data?.[a]??e.aggregatedData[n]?.data?.[a];return{type:e.category.eventType,customerId:a,customerName:t.name,period:r,prevPeriod:n,value:Math.abs(t.value),attributes:s?.attributes}})}function ec({title:e,eventType:t,rows:r,headerColor:s,columnWidthPlan:l,descriptorColumns:o=ee,useExcelColumnOrder:i=!1,metricColumns:u=[],renderedMetricBases:c=[],primaryMetricLabel:m="Value"}){let g=(0,p.U_)(),f=(0,d.t)(),h=g&&!f,y=a.useMemo(()=>{try{let e=(0,K.ry)({tableId:t,rows:r,headerColor:s,emptyState:"No events found.",descriptorColumns:o,periodColumnPlacement:i?"afterValue":"beforeValue",periodHeaderLabel:i?"Date":"Period",columnWidthPlan:l,metricColumns:u,valueLabel:m});return{artifacts:(0,w.SY)(e,{validationMode:"throw"}),error:null}}catch(e){return V.vF.error("[TopEventsOfAllTimeCard] Failed to build worksheet renderer artifacts",{error:e,eventType:t}),{artifacts:null,error:e}}},[l,o,t,s,u,m,r,i]),x=`top-events-${t}-worksheet`,P=(0,K.JP)(l);return(0,n.jsxs)("div",{className:(0,C.cn)("w-fit rounded-none bg-white",h?"overflow-visible":"max-w-full overflow-hidden"),"data-testid":`top-events-${t}-section`,style:{width:P},children:[(0,n.jsx)("div",{className:(0,C.cn)("flex items-center justify-between py-1 pl-0 pr-0",!f&&"border-b border-gray-200/60"),"data-testid":`top-events-${t}-header`,children:(0,n.jsx)("div",{className:(0,C.cn)("font-semibold text-gray-900",h?"font-body text-[12px]":"text-sm"),children:e})}),y.error||!y.artifacts?(0,n.jsx)("div",{className:"flex min-h-28 items-center justify-center border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-950","data-testid":`${x}-error`,role:"alert",children:"Unable to render top events worksheet."}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(J.zO,{renderedMetricBases:c}),(0,n.jsx)(v.Ay,{artifacts:y.artifacts,className:"w-full flex-none",canvasClassName:b.aV.tableTextClassName,workbookDensity:!0,viewportClassName:"overflow-x-auto overflow-y-hidden overscroll-x-contain overscroll-y-auto",rootTestId:x,viewportTestId:`${x}-viewport`})]})]})}function ed({presentationEventScope:e=null,presentationEventScopePeriod:t=null,presentationEventRowCount:v=null,presentationEventGovernedCategories:w=null,presentationEventType:O=null}={}){var H;let{outputUnits:J}=(0,T.n2)(),es=(0,g.tL)(),em=(0,p.U_)(),ep=(0,d.t)(),ev=em&&!ep,eg=(0,p.n2)(),{onElementRef:ef,widthPx:eh}=(0,f.gZ)(),{concentrationTopEventsPeriod:eb,concentrationTopEventsRowCount:ey}=(0,j.useNavigationStore)((0,E.k)(N)),{setConcentrationTopEventsPeriod:ew,setConcentrationTopEventsRowCount:ex}=(0,j.useNavigationStore)((0,E.k)(M)),eC=(0,m.m)(),eP=(0,D.useExcelExportStore)(e=>{let t=e.currentAnalysisId;return t?e.analysisStates[t]?.settings.customerEventsSettings??null:null}),eE=a.useMemo(()=>O?new Set([O]):ev&&eP?new Set((0,R.Xx)(eP.eventTypes)):null,[ev,O,eP]);a.useEffect(()=>{ev&&eP&&((0,R.u$)(eP.eventTypes)||V.vF.error("[TopEventsOfAllTimeCard] Live workbook Customer Events had no event types; defaulted to all event types",{fallback_state:"customer_events_empty_types_defaulted",eventTypes:(0,R.Xx)(eP.eventTypes)}))},[ev,eP]);let ej=(0,$.useFilterStore)(e=>{let t=e.currentAnalysisId;return t?e.analysisStates[t]?.selectedFilterAttributes??ee:ee}),eN=(0,$.useFilterStore)(e=>{let t=e.currentAnalysisId;return t?e.analysisStates[t]?.productCategoryKey??null:null}),eM=a.useMemo(()=>(0,X.b)({configuredDescriptorColumns:ej,productCategoryKey:eN}),[ej,eN]),eT=eP?.period,ek=ev?"monthly"===eT||"quarterly"===eT||"annual"===eT?eT:eb:"monthly"===eC||"quarterly"===eC||"annual"===eC?eC:eb,eS=(null!=e?Math.max(1,Math.floor(v??W.$9)):null)??(ev?Math.max(1,Math.floor(eP?.topN??ey)):ey),[eD,e_]=a.useState(!1),[eR,eI]=a.useState(""),eA="revenue",e$=(0,D.useExcelExportStore)(D.selectCurrentTableHeaderFillColor),{aggregatedCustomerData:eO,residentRpcServable:eW}=(0,I._)({preferResidentRpcWhenBaseAbsent:!0}),eF=a.useMemo(()=>
1{if(!eO)return{};switch(ek){case"monthly":return eO.monthlyAggregatedData;case"quarterly":return eO.quarterlyAggregatedData;default:return eO.yearlyAggregatedData}},[eO,ek]),eL=(0,B.Yt)(),{decimalPoints:eV}=(0,T.n2)(),{currency:eB}=(0,P.R)(),ez=(0,_.SS)(),eU=(0,z.useProcessedDataStore)(e=>e.processedData),eq=(0,z.useProcessedDataStore)(e=>e.artifactInstallGeneration),eK=a.useMemo(()=>({processedData:eU,artifactInstallGeneration:eq,period:ek,rowCount:eS}),[eU,eq,ek,eS]),[eG,eX]=a.useState(null),eH=eG?.identity===eK?eG.result:null,[eQ,eJ]=a.useState(!1),eZ=a.useMemo(()=>(0,G.dE)({source:eU,periodType:ek,revenueAggregatedData:eF,metricValues:eH?.metricValues,profitPresentation:ez}),[eF,eU,ek,ez,eH]),eY=a.useMemo(()=>(0,G.xW)({revenueLabel:eL,revenueAggregatedData:eF,metricColumns:eZ}),[eF,eZ,eL]),e0=eY.find(e=>e.basis===eA)??eY[0],e1=e0?.periodAggregatedData??eF,e2=a.useMemo(()=>eZ.filter(e=>e.basis!==eA),[eZ]),e5=a.useMemo(()=>e2.map(e=>({key:e.columnKey,label:e.label})),[e2]);a.useEffect(()=>{eY.some(e=>e.basis===eA)||V.vF.error("[TopEventsOfAllTimeCard] Primary event basis is unavailable",{fallback_state:"customer_events_primary_basis_unavailable",primaryBasis:eA,availableBases:eY.map(e=>e.basis)})},[eY]);let e3=(0,F.b)({useParenthesesForNegatives:!0,displayUnitSuffix:!1}),e6=a.useCallback(e=>{if(e0?.valueKind!=="volume")return e3(e);let t=Math.round(e),r=(0,L.Sm)(Math.abs(t));return t<0?`(${r})`:r},[e3,e0?.valueKind]),{data:e4}=(0,A.J)(),e7=a.useMemo(()=>{if(!e)return null;let r=t??"";return(0,W.Lg)({scope:e,governedPeriodLabel:r,inputs:{componentMetrics:e4?.componentMetrics??null,processedData:e4??null,aggregatedByGranularity:eO?{monthly:eO.monthlyAggregatedData,quarterly:eO.quarterlyAggregatedData,annual:eO.yearlyAggregatedData}:null,expectedGovernedCategories:w,maxRows:eS}})},[eO,e4,e,t,w,eS]);a.useEffect(()=>{e&&e7&&(e7.ok||V.vF.error("[TopEventsOfAllTimeCard] No loaded substrate reproduces the governed customer-event window; refusing to render a different computation",{eventScope:e,governedPeriodLabel:t??null,blocker:e7.blocker,fallback_state:`presentation_customer_events_scope_${e7.blocker}`}))},[e7,e,t]);let e9=e7?.ok===!0?e7.categories:null,e8=e7?.ok===!0&&"customer-snapshots"===e7.substrate.kind?e7.substrate.granularity:null,te=a.useMemo(()=>{if(!e8||!eO)return null;switch(e8){case"monthly":return eO.monthlyAggregatedData;case"quarterly":return eO.quarterlyAggregatedData;default:return eO.yearlyAggregatedData}},[eO,e8]),tt=a.useMemo(()=>e8&&te?(0,G.dE)({source:eU,periodType:e8,revenueAggregatedData:te,profitPresentation:ez}):en,[te,e8,eU,ez]),tr=a.useMemo(()=>tt.filter(e=>e.basis!==eA),[tt]),tn=a.useMemo(()=>e9&&te?e9.filter(e=>e.items.length>0).map(e=>({type:e.eventType,rows:eu({category:e,aggregatedData:te})})):null,[e9,te]),ta=a.useMemo(()=>e||!e1||0===Object.keys(e1).length?null:function(e,t){let r=Math.max(0,Math.floor(t));if(!e||0===r)return{newEvents:[],upsellEvents:[],downsellEvents:[],churnEvents:[]};let n=Object.keys(e).filter(t=>{let r=e[t];return r&&!r.isComparisonPeriod}).sort();if(n.length<2)return{newEvents:[],upsellEvents:[],downsellEvents:[],churnEvents:[]};let a=[],s=[],l=[],o=[];for(let t=1;t<n.length;t++){let i=n[t],u=n[t-1],c=e[i]?.data??{},d=e[u]?.data??{};for(let[e,t]of Object.entries(c)){let n=t.arr??0,o=d[e]?.arr??0;if(!(n<=0)){if(0===o){q(a,{type:"new",customerId:e,customerName:t.customerName,period:i,prevPeriod:u,value:n,attributes:t.attributes},r);continue}if(n>o&&o>0){q(s,{type:"upsell",customerId:e,customerName:t.customerName,period:i,prevPeriod:u,value:n-o,attributes:t.attributes},r);continue}o>0&&n<o&&q(l,{type:"downsell",customerId:e,customerName:t.customerName,period:i,prevPeriod:u,value:o-n,attributes:t.attributes},r)}}for(let[e,t]of Object.entries(d)){let n=t.arr??0;n<=0||0===(c[e]?.arr??0)&&q(o,{type:"churn",customerId:e,customerName:t.customerName,period:i,prevPeriod:u,value:n,attributes:t.attributes},r)}}let i=(e,t)=>t.value-e.value;return{newEvents:[...a].sort(i),upsellEvents:[...s].sort(i),downsellEvents:[...l].sort(i),churnEvents:[...o].sort(i)}}(e1,eS),[e1,e,eS]);a.useEffect(()=>{if(e||ta||!eW)return;let t=!1;return eJ(!0),eX(null),(async()=>{try{let{waterfallWorker:e}=await Promise.resolve().then(r.bind(r,90529)),n=await e.allTimeTopEventsResident({granularity:ek,rowCount:eS});if(t)return;if(null===n)return void Q({failure:"unavailable",period:ek,rowCount:eS});eX({identity:eK,result:n})}catch(e){if(t)return;Q({failure:"failed",period:ek,rowCount:eS,error:e})}finally{t||eJ(!1)}})(),()=>{t=!0}},[ta,eK,e,eW,ek,eS]);let ts=ta??eH??Z,tl=a.useMemo(()=>Y.includes(eS),[eS]),to=tl?String(eS):"custom",ti=a.useCallback(e=>{ex(Math.max(1,Math.floor(e||1)))},[ex]),tu=a.useCallback(()=>{let e=Number(eR);Number.isFinite(e)&&(ti(e),e_(!1))},[ti,eR]),tc=a.useMemo(()=>{var e=[{type:"new",rows:ts.newEvents},{type:"upsell",rows:ts.upsellEvents},{type:"downsell",rows:ts.downsellEvents},{type:"churn",rows:ts.churnEvents}].filter(e=>!eE||eE.has(e.type));if(!ep)return e;let t=e.filter(e=>e.rows.length>0),r=t.length<=1?10:2===t.length?8:3===t.length?6:5;return t.map(e=>({...e,rows:e.rows.slice(0,r)}))},[ep,ts,eE]),td=a.useMemo(()=>e9?tn?el(eM.map(e=>({key:`desc:${e}`,label:e})),tn).map(e=>e.label):ee:ep?el(eM.map(e=>({key:`desc:${e}`,label:e})),tc).map(e=>e.label):eM,[eM,e9,tn,ep,tc]),tm=a.useMemo(()=>(function(e){let t=new Map;for(let r of e)for(let e of r.items){let n=e.name.trim().toLowerCase();if(!n)continue;let a=t.get(n)??new Set;a.add(r.eventType),t.set(n,a)}return new Set(Array.from(t.entries()).filter(([,e])=>e.size>=2).map(([e])=>e))})(e9??[]),[e9]),tp=a.useMemo(()=>
1e8&&te?{granularity:e8,aggregatedData:te,descriptorColumns:td,metricColumns:tr,decimalPoints:eV,currency:eB}:null,[eB,eV,td,tr,te,e8]),tv=a.useMemo(()=>{if(!e9)return null;let e=t??"";return e9.filter(e=>e.items.length>0).map(t=>{var r;let n,a,s,l;return{type:t.eventType,rows:(r={category:t,scopePeriod:e,formatValue:e3,crossCategoryCustomerNames:tm,substrate:tp},n=r.substrate?.granularity??ei,a=function(e,t=ei){let r=e.split(" through ");return 2===r.length&&r[0].trim()&&r[1].trim()?(0,U.Q)(r[0].trim(),r[1].trim(),t):(0,U.P)(e,t)}(r.scopePeriod,n),l=(s=r.substrate)?eu({category:r.category,aggregatedData:s.aggregatedData}).map(e=>eo({row:e,aggregatedData:s.aggregatedData,descriptorColumns:s.descriptorColumns,metricColumns:s.metricColumns,formatValue:r.formatValue,decimalPoints:s.decimalPoints,currency:s.currency})):null,r.category.items.map((e,t)=>{let o=e.name.trim().toLowerCase(),i=r.category.items.findIndex(e=>e.name.trim().toLowerCase()===o)===t,u="new"===r.category.eventType?3:2,c=e.rank<=u,d="upsell"===r.category.eventType&&e.rank<=5&&i&&r.crossCategoryCustomerNames?.has(o),m=ea(r.category.eventType)?Math.abs(e.value):-Math.abs(e.value),p=e.period&&e.comparisonPeriod?(0,U.Q)(e.comparisonPeriod,e.period,n):e.period?(0,U.P)(e.period,n):a,v=l?.[t];return{key:`${r.category.eventType}-${e.rank}-${e.name}`,rank:e.rank,customerName:e.name,descriptorValues:v?.descriptorValues??{},...v&&s?.metricColumns.length?{metricValues:v.metricValues}:{},periodLabel:p,value:r.formatValue(m),eventType:r.category.eventType,customerId:e.customerId??"",period:e.period??r.scopePeriod,emphasis:c?"largest":d?"cross-category":void 0}}))}})},[tm,e3,e9,tp,t]),tg=a.useMemo(()=>tc.map(e=>{var t;return{type:e.type,rows:(t={rows:e.rows,periodType:ek,formatValue:e6,aggregatedData:e1,descriptorColumns:td,metricColumns:e2,decimalPoints:eV,currency:eB,eventDateOnly:ev}).rows.map((e,r)=>{let n=ea(e.type)?Math.abs(e.value):-Math.abs(e.value),{descriptorValues:a,metricValues:s}=eo({row:e,aggregatedData:t.aggregatedData,descriptorColumns:t.descriptorColumns,metricColumns:t.metricColumns,formatValue:t.formatValue,decimalPoints:t.decimalPoints,currency:t.currency});return{key:`${e.type}-${e.customerId}-${e.period}-${r}`,rank:r+1,customerName:e.customerName,descriptorValues:a,periodLabel:t.eventDateOnly?(0,U.P)(e.period,"monthly"):(0,U.Q)(e.prevPeriod,e.period,t.periodType),value:t.formatValue(n),eventType:e.type,customerId:e.customerId,period:e.period,...t.metricColumns?.length?{metricValues:s}:{}}})}}),[e2,eB,eV,td,e1,e6,ev,ek,tc]),tf=tv??tg,th=a.useMemo(()=>tr.map(e=>({key:e.columnKey,label:e.label})),[tr]),tb=tv?tp?th:et:e5,ty=a.useMemo(()=>tv?tp?tt.map(e=>e.basis):er:eZ.map(e=>e.basis),[tv,tp,tt,eZ]),tw=ev?(0,y.xW)({containerWidthPx:eg,scrollbarGutterPx:0}):(0,y.xW)({containerWidthPx:eh,leadingInsetPx:16,trailingInsetPx:16}),tx=(H={visibleCount:tf.length,descriptorColumnCount:td.length,presentation:ep}).presentation?H.visibleCount<=1||H.descriptorColumnCount>=3?{columns:1,gridColsClassName:"grid-cols-1",fullSpanIndices:new Set}:{columns:2,gridColsClassName:"grid-cols-2",fullSpanIndices:H.visibleCount%2==1?new Set([H.visibleCount-1]):new Set}:{columns:2,gridColsClassName:"grid-cols-1 lg:grid-cols-2",fullSpanIndices:new Set},tC=a.useMemo(()=>{let e=(0,K.GB)({rows:tf.flatMap(e=>e.rows),descriptorColumns:td,metricColumns:tb});return ep&&2===tx.columns?(0,K.qB)({targetWidthPx:K.Wd,descriptorColumns:td,columnWidthPlan:e}):(0,K.i)({availableWidthPx:null==tw?null:Math.max(1,Math.floor(tw)),descriptorColumns:td,columnWidthPlan:e})},[td,ep,tx.columns,tb,tw,tf]),tP=(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(k.$,{value:ek,onChange:e=>{"rolling-ltm"!==e&&ew(e)},includeRollingLTM:!1}),(0,n.jsxs)(l.l6,{value:to,onValueChange:e=>{if("custom"===e){eI(String(eS)),e_(!0);return}let t=Number(e);Number.isFinite(t)&&ti(t)},children:[(0,n.jsx)(l.bq,{className:"h-8 w-[110px] border-gray-200 bg-white",children:(0,n.jsx)(l.yv,{placeholder:"Rows"})}),(0,n.jsxs)(l.gC,{children:[Y.map(e=>(0,n.jsxs)(l.eb,{value:String(e),children:[e," rows"]},e)),(0,n.jsx)(l.eb,{value:"custom",children:tl?"Customâ¦":`Custom (${eS})â¦`})]})]})]}),tE=(0,n.jsx)("div",{className:(0,C.cn)(ep?(0,C.cn)("grid w-fit max-w-full items-start gap-3",tx.gridColsClassName):(0,C.cn)("flex flex-col items-start gap-3",ev?"w-max":"w-fit max-w-full")),"data-testid":"top-events-table-stack",children:tf.map((e,t)=>{let r=(0,n.jsx)(ec,{title:function(e){switch(e){case"new":return"Top New Events";case"upsell":return"Top Upsell Events";case"downsell":return"Top Downsell Events";case"churn":return"Top Churn Events";default:return"Top Events"}}(e.type),eventType:e.type,rows:e.rows,headerColor:e$,columnWidthPlan:tC,descriptorColumns:td,useExcelColumnOrder:ev,metricColumns:tb,renderedMetricBases:ty,primaryMetricLabel:e0?.label??eL},e.type);if(!ep)return r;let a=tx.fullSpanIndices.has(t);return(0,n.jsx)("div",{className:(0,C.cn)(a&&"col-span-2 flex justify-center"),children:r},e.type)})}),tj=(0,n.jsxs)(s.Zp,{className:(0,C.cn)(ev?"w-full rounded-none border-0 bg-transparent shadow-none":(0,C.cn)(x._U.elevated,"w-fit max-w-full")),"data-testid":"top-customer-events-card",children:[es?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(g.rb,{titleHeader:es,testId:"top-events-workbook-title-rows"}),(0,n.jsx)("div",{"aria-hidden":"true",className:"w-full flex-none bg-white","data-testid":"top-events-workbook-title-spacer",style:{height:b.aV.bodyRowHeightPx}})]}):(0,n.jsx)(s.aR,{className:"p-4 pb-2",children:(0,n.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,n.jsxs)("div",{className:"flex flex-col items-start gap-1",children:[(0,n.jsx)(s.ZB,{className:"text-lg font-semibold text-gray-900",children:"Top Customer Events of All Time"}),(0,n.jsx)(S.E,{units:J})]}),tP]})}),(0,n.jsxs)(s.Wu,{className:(0,C.cn)("px-4 pb-4 pt-0",ev&&"px-0"),children:[ep&&tv?(0,n.jsxs)("div",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-gray-600","data-testid":"top-events-presentation-emphasis-legend","aria-label":"Customer event row highlighting",children:[(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"h-3 w-3 border-l-2 border-[#2563FF] bg-[#EEF4FF]"}),"Blue marks the largest movements in each event type"]}),tm.size>0?(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"h-3 w-3 border border-[#D59B16] bg-[#FFF7D6]"}),"Gold marks a customer appearing in multiple event types"]}):null]}):null,ev?(0,n.jsx)(h.R,{ariaLabel:"Customer events columns",hint:"Scroll right for more â",testId:"top-events-columns-scroller",viewportWidthPx:tw,children:tE}):tE]}),!ev&&(0,n.jsx)(o.lG,{open:eD,onOpenChange:e_,children:(0,n.jsxs)(o.Cf,{className:"max-w-sm",children:[(0,n.jsxs)(o.c7,{children:[(0,n.jsx)(o.L3,{children:"Custom row count"}),(0,n.jsx)(o.rr,{children:"Choose how many events to show per table."})]}),(0,n.jsxs)("div",{className:"grid gap-2",children:[(0,n.jsx)(c.J,{htmlFor:"top-events-custom-rows",children:"Rows"}),(0,n.jsx)(u.p,{id:"top-events-custom-rows",inputMode:"numeric",value:eR,onChange:e=>eI(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),tu())},placeholder:"e.g. 12"})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,n.jsx)(i.$,{variant:"outline",onClick:()=>e_(!1),children:"Cancel"}),(0,n.jsx)(i.$,{onClick:tu,children:"Apply"})]})]})})]});return ev?(0,n.jsx)(g.$Q,{leadingInsetPx:y.aV,bottomInsetPx:0,className:"w-full flex-none",testId:"top-events-workbook-body-inset",children:tj}):ep?tj:(0,n.jsx)("div",{ref:ef,className:"w-full min-w-0","data-testid":"top-events-analysis-width-host",children:tj})}function em({presentationEventScope:e=null,presentationEventScopePeriod:t=null,presentationEventRowCount:r=null,presentationEventGovernedCategories:a=null,presentationEventType:s=null}={}){return(0,n.jsx)("div",{className:"pb-4",children:(0,n.jsx)(ed,{presentationEventScope:e,presentationEventScopePeriod:t,presentationEventRowCount:r,presentationEventGovernedCategories:a,presentationEventType:s})})}let ep=em},47273:(e,t,r)=>{r.d(t,{R:()=>i});var n=r(95155),a=r(12115),s=r(14175),l=r(90568);let o={contentWidthPx:0,viewportWidthPx:0,scrollLeftPx:0};function i({ariaLabel:e,hint:t,testId:r,viewportWidthPx:u=null,className:c,bodyClassName:d,linkedViewport:m,showLeftFade:p=!0,children:v}){let g=(0,a.useRef)(null),f=(0,a.useRef)(null),h=(0,a.useRef)(null),[b,y]=(0,a.useState)(o),[w,x]=(0,a.useState)(0),C=m?.node??null,P=null!=m,E=(0,a.useCallback)(e=>{f.current=e,x(e?e.clientWidth:0)},[]),j=(0,a.useCallback)(e=>{let t={contentWidthPx:e.scrollWidth,viewportWidthPx:e.clientWidth,scrollLeftPx:e.scrollLeft};y(e=>e.contentWidthPx===t.contentWidthPx&&e.viewportWidthPx===t.viewportWidthPx&&e.scrollLeftPx===t.scrollLeftPx?e:t)},[]),N=(0,a.useCallback)(()=>{let e=g.current;e&&j(e)},[j]);(0,a.useEffect)(()=>{let e=P?C:g.current;if(g.current=e,!e){y(o),x(0),h.current=null;return}let t=()=>j(e);t(),e.addEventListener("scroll",t,{passive:!0});let r="u"<typeof ResizeObserver?null:new ResizeObserver(t);r?.observe(e);let n=e.firstElementChild;return n&&r?.observe(n),()=>{e.removeEventListener("scroll",t),r?.disconnect(),P&&g.current===e&&(g.current=null)}},[C,P,j]);let{contentWidthPx:M,viewportWidthPx:T,scrollLeftPx:k}=b,S=Math.max(0,M-T),D=S>1,_=D&&k>1,R=D&&k<S-1,I=D&&w>0?Math.max(40,Math.round(T/M*w)):0,A=Math.max(0,w-I),$=S>0?Math.round(k/S*A):0;(0,a.useEffect)(()=>{let e=f.current;if(!e||"u"<typeof ResizeObserver)return;let t=new ResizeObserver(()=>x(e.clientWidth));return t.observe(e),()=>t.disconnect()},[D]);let{isPanning:O}=(0,s.e)({viewportRef:g,enabled:!P}),W=(0,a.useCallback)(e=>{let t=g.current;t&&(t.scrollLeft=e,N())},[N]),F=e=>{let t=h.current;t&&t.pointerId===e.pointerId&&(h.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},L="number"==typeof u&&Number.isFinite(u)?Math.max(1,Math.floor(u)):null;return(0,n.jsxs)("div",{className:(0,l.cn)("relative w-full min-w-0",c),"data-testid":r,"data-viewport-width-px":L??void 0,style:null==L?void 0:{width:L,maxWidth:L},children:[D?(0,n.jsxs)("div",{className:"mb-1 flex items-center gap-2","data-testid":`${r}-rail`,children:[(0,n.jsx)("div",{className:"relative h-2 w-full cursor-pointer rounded-full bg-gray-200","data-testid":`${r}-track`,onPointerDown:e=>{if(!D)return;let t=e.currentTarget.getBoundingClientRect();W(Math.min(S,Math.max(0,e.clientX-t.left>$+I/2?k+T:k-T)))},ref:E,children:(0,n.jsx)("div",{className:"absolute inset-y-0 rounded-full bg-gray-400 transition-colors hover:bg-gray-500","data-testid":`${r}-thumb`,onPointerCancel:F,onPointerDown:e=>{let t=g.current;t&&!(A<=0)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),h.current={pointerId:e.pointerId,startX:e.clientX,startScrollLeft:t.scrollLeft})},onPointerMove:e=>{let t=h.current;if(!t||t.pointerId!==e.pointerId)return;let r=e.clientX-t.startX,n=S/Math.max(1,A);W(Math.min(S,Math.max(0,t.startScrollLeft+r*n)))},onPointerUp:F,style:{left:$,width:I||void 0}})}),t&&R?(0,n.jsx)("span",{className:"whitespace-nowrap text-[11px] text-gray-400","data-testid":`${r}-hint`,children:t}):null]}):null,P?v:(0,n.jsx)("div",{"aria-label":e,className:(0,l.cn)("w-full min-w-0 overflow-x-auto",O?"cursor-grabbing select-none":"cursor-grab",d),"data-drag-to-pan":"true","data-panning":O?"true":void 0,"data-testid":`${r}-body`,ref:g,role:"region",tabIndex:0,children:v}),_&&p?(0,n.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 left-0 top-6 w-8 bg-gradient-to-r from-white to-transparent","data-testid":`${r}-fade-left`}):null,R?(0,n.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 right-0 top-6 w-8 bg-gradient-to-l from-white to-transparent","data-testid":`${r}-fade-right`}):null]})}}}]);
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.