1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6637],{96637:(e,t,s)=>{s.r(t),s.d(t,{PostPerformanceDialog:()=>T});var a=s(7778),l=s(85418),n=s(94340),r=s(20389),i=s(62752),d=s(33483),o=s(13964),c=s(33727),u=s(41938),m=s(17739),x=s(13480),p=s(38035),h=s(3854),f=s(36311),v=s(5898),g=s(17987),j=s(96466),b=s(25065),N=s(33702),y=s(5853),w=s(12439),k=s(42844),M=s(1942),C=s(72997),S=s(53565);let L={r:5,stroke:"hsl(var(--background))",strokeWidth:2},z=[],D=[];function E(e){if(e<24){let t=Math.round(10*e)/10;return"".concat(t,"h")}let t=Math.round(e/24*10)/10;return"".concat(t,"d")}function T(e){var t,s,T,A,I,O,U,P,F,X,H,W,G;let{postId:_,initialMetric:B,onClose:q}=e,K=(0,r.useTranslations)("analytics.postPerformance"),Q=(0,r.useFormatter)(),{currentTheme:V}=(0,M.D)(),{data:R,error:J,isLoading:Y}=(0,w.vX)(_),[Z,$]=(0,l.useState)(B),[ee,et]=(0,l.useState)("total"),[es,ea]=(0,l.useState)(!1),el=(0,l.useRef)(null),en="post-performance-fill-".concat((0,l.useId)().replace(/:/g,"")),er="total"===ee?null:null!=(s=null==R||null==(t=R.thread)?void 0:t.segments.find(e=>e.providerPostId===ee))?s:null,ei=null!=(A=null!=(T=null==er?void 0:er.availableMetrics)?T:null==R?void 0:R.availableMetrics)?A:z,ed=null!==er?er.latestMetrics:null!=(I=null==R?void 0:R.latestMetrics)?I:null,eo=null!=(U=null!=(O=null==er?void 0:er.snapshots)?O:null==R?void 0:R.snapshots)?U:D,ec=null!==er?er.caption:null!=(P=null==R?void 0:R.post.caption)?P:null,eu=null!==er?er.thumbnailUrl:null!=(F=null==R?void 0:R.post.thumbnailUrl)?F:null,em=null!=(H=null!=(X=null==er?void 0:er.publishedAt)?X:null==R?void 0:R.post.publishedAt)?H:null,ex=null!==er&&!er.available,ep="overall"===Z?null:R?(0,k.if)(ei,Z):Z,eh=0===ei.length?null:"overall"===Z?"overall":ep;(0,l.useEffect)(()=>{let e=document.documentElement,t=()=>{ea(e.classList.contains("dark"))};t();let s=new MutationObserver(t);return s.observe(e,{attributes:!0,attributeFilter:["class"]}),()=>s.disconnect()},[]);let ef=(0,l.useMemo)(()=>{let e=es?V.button.darkColors:V.button.colors;return"gradient"===V.button.type?e:[e[0]]},[V,es]),ev=(0,l.useMemo)(()=>(0,S.aQ)(ef,{themeId:V.id,isDarkMode:es}),[V.id,es,ef]),eg=(0,l.useMemo)(()=>"minimal"!==V.id&&("dopost"!==V.id||es)?ef:ev,[ev,V.id,es,ef]),ej=(0,l.useMemo)(()=>{let e=(0,C.s)(eg,ei.length);return Object.fromEntries(ei.map((t,s)=>{var a;return[t,null!=(a=e[s])?a:eg[0]]}))},[eg,ei]),eb=null!=(G=null!=(W=ep?ej[ep]:void 0)?W:eg[0])?G:"hsl(var(--primary))",eN=(0,l.useMemo)(()=>{let e=ei.map(e=>ej[e]).filter(e=>!!e);return 0===e.length?eg[0]:1===e.length?e[0]:"linear-gradient(135deg, ".concat(e[0],", ").concat(e[Math.floor(e.length/2)],", ").concat(e[e.length-1],")")},[eg,ej,ei]),ey=(0,l.useMemo)(()=>R?"overall"===Z?eo.flatMap(e=>{let t=Object.fromEntries(ei.map(t=>[t,e.metrics[t]]));return Object.values(t).every(e=>null===e)?[]:[{elapsedHours:e.elapsedHours,elapsedLabel:E(e.elapsedHours),fetchedAt:e.fetchedAt,...t}]}):ep?(0,k.sf)(eo,ep).map(e=>({...e,elapsedLabel:E(e.elapsedHours)})):[]:[],[ep,R,Z,ei,eo]),ew=(0,l.useMemo)(()=>"overall"===Z?Object.fromEntries(ei.map(e=>[e,{label:K("metrics.".concat(e)),color:ej[e]}])):{value:{label:ep?K("metrics.".concat(ep)):"",color:eb}},[eb,ep,Z,ej,K,ei]);return(0,a.jsx)(h.lG,{open:!0,onOpenChange:e=>e?void 0:q(),children:(0,a.jsxs)(h.Cf,{className:"flex max-h-[90dvh] flex-col gap-0 overflow-hidden p-0 sm:max-w-3xl",onOpenAutoFocus:e=>{var t;e.preventDefault(),null==(t=el.current)||t.focus()},children:[(0,a.jsxs)(h.c7,{className:"shrink-0 px-5 py-4 pr-12 sm:px-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(h.L3,{ref:el,tabIndex:-1,className:"outline-none",children:K("detailTitle")}),(0,a.jsx)(g.TooltipProvider,{children:(0,a.jsxs)(g.Tooltip,{children:[(0,a.jsx)(g.TooltipTrigger,{asChild:!0,children:(0,a.jsx)("button",{type:"button","aria-label":K("detailDescription"),className:"rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,a.jsx)(m.A,{className:"h-4 w-4"})})}),(0,a.jsx)(j.X,{className:"max-w-xs",children:(0,a.jsx)("p",{children:K("detailDescription")})})]})})]}),(0,a.jsx)(h.rr,{className:"sr-only",children:K("detailDescription")})]}),(0,a.jsx)("div",{className:"min-h-0 overflow-y-auto px-4 py-5 sm:px-6 sm:py-6",children:Y?(0,a.jsxs)("div",{className:"space-y-5","aria-hidden":"true",children:[(0,a.jsx)(f.E,{className:"h-24 w-full rounded-lg"}),(0,a.jsxs)("div",{children:[(0,a.jsx)(f.E,{className:"h-14 w-full rounded-md"}),(0,a.jsx)(f.E,{className:"mt-5 h-[280px] w-full rounded-md"})]})]}):J||!R?(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive",children:[(0,a.jsx)(x.A,{className:"h-4 w-4 shrink-0"}),null!=J?J:K("detailError")]}):(0,a.jsxs)("div",{className:"space-y-5",children:[R.thread?(0,a.jsx)("div",{className:"overflow-x-auto pb-1",children:(0,a.jsx)(v.tU,{value:ee,onValueChange:et,children:(0,a.jsxs)(v.j7,{className:"h-9 w-max min-w-full justify-start gap-1 bg-muted/40 p-1",children:[(0,a.jsx)(v.Xi,{value:"total",className:"h-7 rounded px-2.5 text-xs data-[state=active]:bg-background",children:K("threadTotal")}),R.thread.segments.map(e=>(0,a.jsx)(v.Xi,{value:e.providerPostId,"aria-label":K("threadSegmentLabel",{current:e.index+1,total:R.thread.segmentCount}),className:"size-7 rounded p-0 text-xs tabular-nums data-[state=active]:bg-background",children:e.index+1},e.providerPostId))]})})}):null,(0,a.jsxs)("section",{className:"flex min-w-0 gap-3 rounded-lg border bg-card p-3 sm:gap-4 sm:p-4",children:[(0,a.jsx)("div",{className:"relative size-16 shrink-0 overflow-hidden rounded-md bg-muted sm:size-20",children:eu?(0,a.jsx)(n.default,{src:eu,alt:K("thumbnailAlt"),fill:!0,unoptimized:!0,className:"object-cover"}):(0,a.jsx)("div",{className:"flex h-full items-center justify-center bg-muted",children:(0,a.jsx)("svg",{className:"h-5 w-5 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 6h16M4 12h16M4 18h7"})})})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1.5",children:[(0,a.jsx)(y.u,{account:{id:R.post.socialAccountId,platform:R.post.platform,platformUsername:R.post.platformUsername,metadata:R.post.accountMetadata},size:"sm"}),(0,a.jsx)("span",{className:"min-w-0 truncate text-sm font-medium",children:R.post.platformUsername}),R.thread?(0,a.jsx)(p.Badge,{variant:"outline",size:"sm",className:"h-5 shrink-0 border-border/60 bg-muted/40 px-1.5 text-[10px] font-medium text-muted-foreground",children:K("threadShortLabel")}):null,(0,a.jsx)(p.Badge,{variant:"secondary",className:"shrink-0",children:ex?K("metricsUnavailable"):K("states.".concat(R.collection.state))})]}),(0,a.jsx)("p",{className:"mt-2 line-clamp-2 text-sm leading-5 text-foreground
1/90",children:null!=ec?ec:K("noCaption")}),em?(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:K("published",{date:Q.dateTime(new Date(em),{dateStyle:"medium",timeStyle:"short"})})}):null,"total"===ee&&R.thread&&R.thread.analyzedSegmentCount<R.thread.segmentCount?(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:K("threadCoverage",{analyzed:R.thread.analyzedSegmentCount,total:R.thread.segmentCount})}):null]})]}),eh?(0,a.jsx)("section",{className:"min-w-0",children:(0,a.jsxs)(v.tU,{value:eh,onValueChange:e=>$(e),children:[(0,a.jsx)("div",{className:"pb-1",children:(0,a.jsxs)(v.j7,{className:"grid h-auto w-full gap-1 bg-transparent p-0",style:{gridTemplateColumns:"repeat(".concat(ei.length+1,", minmax(0, 1fr))")},children:[(0,a.jsx)(v.Xi,{value:"overall",className:"h-auto min-w-0 justify-start gap-1 rounded-md px-1.5 py-2 text-left transition-colors hover:bg-muted/50 data-[state=active]:bg-muted data-[state=active]:text-foreground sm:gap-2 sm:px-3",children:(0,a.jsxs)("span",{className:"min-w-0",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,a.jsx)("span",{className:"size-2 shrink-0 rounded-full",style:{background:eN}}),(0,a.jsx)("span",{className:"truncate text-[11px] font-normal leading-4 text-muted-foreground",children:K("metrics.overall")})]}),(0,a.jsx)("span",{"aria-hidden":"true",className:"block h-5"})]})}),ei.map(e=>{var t;return(0,a.jsx)(v.Xi,{value:e,className:"h-auto min-w-0 justify-start gap-1 rounded-md px-1.5 py-2 text-left transition-colors hover:bg-muted/50 data-[state=active]:bg-muted data-[state=active]:text-foreground sm:gap-2 sm:px-3",children:(0,a.jsxs)("span",{className:"min-w-0",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,a.jsx)("span",{className:"size-2 shrink-0 rounded-full",style:{background:ej[e]}}),(0,a.jsx)("span",{className:"truncate text-[11px] font-normal leading-4 text-muted-foreground",children:K("metrics.".concat(e))})]}),(0,a.jsx)("span",{className:"block truncate text-sm font-semibold tabular-nums",children:Q.number(null!=(t=null==ed?void 0:ed[e])?t:0,{notation:"compact",maximumFractionDigits:1})})]})},e)})]})}),ey.length>0?(0,a.jsx)(N.at,{config:ew,className:"mt-5 h-[280px] w-full min-w-0",children:(0,a.jsxs)(i.Q,{accessibilityLayer:!0,data:ey,margin:{left:0,right:16,top:12,bottom:0},children:[(0,a.jsx)("defs",{children:("overall"===eh?ei:[ep]).map(e=>{var t;if(!e)return null;let s=null!=(t=ej[e])?t:eb;return(0,a.jsxs)("linearGradient",{id:"".concat(en,"-").concat(e),x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,a.jsx)("stop",{offset:"5%",stopColor:s,stopOpacity:.14}),(0,a.jsx)("stop",{offset:"95%",stopColor:s,stopOpacity:.01})]},e)})}),(0,a.jsx)(d.d,{vertical:!1}),(0,a.jsx)(o.W,{dataKey:"elapsedHours",type:"number",domain:["dataMin","dataMax"],tickFormatter:e=>E(Number(e)),tickLine:!1,axisLine:!1,tickMargin:8,minTickGap:32}),(0,a.jsx)(c.h,{tickFormatter:e=>Q.number(Number(e),{notation:"compact"}),tickLine:!1,axisLine:!1,tickMargin:8,width:48}),(0,a.jsx)(N.II,{cursor:{strokeDasharray:"3 3"},wrapperStyle:{zIndex:100,pointerEvents:"none"},content:e=>{var t,s;let{active:l,payload:n}=e;if(!l||!(null==n?void 0:n.length))return null;let r=null==(t=n[0])?void 0:t.payload;if(!r)return null;if("overall"===eh){let e=ei.flatMap(e=>{let t=r[e];return"number"==typeof t?[{item:e,value:t}]:[]});return(0,a.jsxs)("div",{className:(0,b.cn)(j.q,"min-w-52 max-w-60 p-2.5 text-xs"),children:[(0,a.jsx)("div",{className:"font-medium",children:K("milestone",{age:r.elapsedLabel})}),(0,a.jsx)("div",{className:"mt-2 space-y-1",children:e.map(e=>{let{item:t,value:s}=e;return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"size-2 shrink-0 rounded-full",style:{background:ej[t]}}),(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:K("metrics.".concat(t))}),(0,a.jsx)("span",{className:"font-semibold tabular-nums",children:Q.number(s)})]},t)})}),(0,a.jsx)("div",{className:"mt-1.5 border-t pt-1.5 text-muted-foreground",children:Q.dateTime(new Date(r.fetchedAt),{dateStyle:"medium",timeStyle:"short"})})]})}return(0,a.jsxs)("div",{className:(0,b.cn)(j.q,"min-w-52 max-w-60 p-2.5 text-xs"),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.jsx)("span",{className:"font-medium",children:K("milestone",{age:r.elapsedLabel})}),(0,a.jsx)("span",{className:"size-2 shrink-0 rounded-full",style:{background:eb}})]}),(0,a.jsxs)("div",{className:"mt-2 flex items-end justify-between gap-4",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:K("metrics.".concat(ep))}),(0,a.jsx)("span",{className:"text-base font-semibold tabular-nums",children:Q.number(null!=(s=r.value)?s:0)})]}),null!==r.delta&&void 0!==r.delta?(0,a.jsxs)("div",{className:"mt-1.5 flex justify-between gap-4 border-t pt-1.5",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:K("sincePrevious")}),(0,a.jsxs)("span",{className:"font-medium tabular-nums",children:[r.delta>0?"+":"",Q.number(r.delta)]})]}):null,(0,a.jsx)("div",{className:"mt-1 text-muted-foreground",children:Q.dateTime(new Date(r.fetchedAt),{dateStyle:"medium",timeStyle:"short"})})]})}}),("overall"===eh?ei:[ep]).map(e=>{var t;if(!e)return null;let s=null!=(t=ej[e])?t:eb;return(0,a.jsx)(u.G,{dataKey:"overall"===eh?e:"value",type:"monotone",stroke:s,strokeWidth:2,fill:"url(#".concat(en,"-").concat(e,")"),fillOpacity:1,dot:{r:3,fill:s,stroke:"hsl(var(--background))",strokeWidth:1.5},activeDot:{...L,fill:s}},e)})]})}):(0,a.jsx)("div",{className:"mt-5 flex h-[280px] items-center justify-center rounded-md border border-dashed px-6 text-center text-sm text-muted-foreground",children:K("awaitingSnapshots")})]})}):(0,a.jsx)("div",{className:"flex h-[356px] items-center justify-center px-6 text-center text-sm text-muted-foreground",children:ex?K("metricsUnavailable"):K("awaitingSnapshots")})]})})]})})}}}]);
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.