1import{c as S,j as s,r as ye}from"./vendor-react-core-C1Dw5D_W.js";import{s as Q,U as $e,v as Le,a6 as Te,h as ue,aC as he,bv as Me,aL as Oe,a4 as Ae,bd as L,bc as T,ba as I,b8 as ae,b9 as ge,aA as Ie,bE as Re,b7 as E,B as pe,G as ve,dv as we,dw as qe,cL as je,bH as ne,dx as de,d as fe,dl as ke,dy as Pe,T as Be,by as Ke,cK as De,cn as Fe,bk as Ge,aT as Ue,c as Se,cM as Ve}from"./seo-leaves-BMSG-wqE.js";import{d as Ce,a as He,b as ze,c as Qe,S as Xe}from"./select-DQg47it4.js";import{S as y}from"./skeleton-Bu4kpPtk.js";import{P as Je,u as We}from"./index-DLA-Kcn6.js";import{u as X}from"./vendor-query-DrkdRe4t.js";import{S as J}from"./queryConfig-CsjrHe95.js";import{b as _e,T as A,c as v,a as p,d as be,e as Ne}from"./table-D7PYtuvh.js";import{u as Ye,b as Ze}from"./vendor-router-aghDRLMw.js";import"./vendor-supabase-Ds0jIvEe.js";import"./vendor-utils-DRU7gPsF.js";import"./vendor-motion-QAyZxYtn.js";import"./mistake-diagnostic-tags-D-s5KNjj.js";async function et(t){try{const{data:e,error:l}=await Q.rpc("get_sequence_analytics_summary",{p_sequence_slug:t.sequenceSlug,p_date_from:t.dateFrom?.toISOString()??null,p_date_to:t.dateTo?.toISOString()??null});return l?(console.error("Error fetching sequence summary:",l),null):e?.error?(console.error("Sequence not found:",e.error),null):e}catch(e){return console.error("Exception in getSequenceAnalyticsSummary:",e),null}}async function tt(t){try{const{data:e,error:l}=await Q.rpc("get_sequence_email_stats",{p_sequence_slug:t.sequenceSlug,p_date_from:t.dateFrom?.toISOString()??null,p_date_to:t.dateTo?.toISOString()??null});return l?(console.error("Error fetching email stats:",l),[]):e||[]}catch(e){return console.error("Exception in getSequenceEmailStats:",e),[]}}async function st(t){try{const{data:e,error:l}=await Q.rpc("get_sequence_link_clicks",{p_sequence_slug:t.sequenceSlug,p_step_number:t.stepNumber,p_date_from:t.dateFrom?.toISOString()??null,p_date_to:t.dateTo?.toISOString()??null});return l?(console.error("Error fetching link clicks:",l),[]):e||[]}catch(e){return console.error("Exception in getSequenceLinkClicks:",e),[]}}async function lt(t){try{const{data:e,error:l}=await Q.rpc("get_sequence_exits",{p_sequence_slug:t.sequenceSlug,p_date_from:t.dateFrom?.toISOString()??null,p_date_to:t.dateTo?.toISOString()??null});return l?(console.error("Error fetching exits:",l),[]):e||[]}catch(e){return console.error("Exception in getSequenceExits:",e),[]}}async function ct(t){try{const{data:e,error:l}=await Q.rpc("get_sequence_success_metrics",{p_sequence_slug:t.sequenceSlug,p_date_from:t.dateFrom?.toISOString()??null,p_date_to:t.dateTo?.toISOString()??null});return l?(console.error("Error fetching success metrics:",l),null):e?.error?(console.error("Sequence not found:",e.error),null):e}catch(e){return console.error("Exception in getSequenceSuccessMetrics:",e),null}}async function nt(){try{const{data:t,error:e}=await Q.from("email_sequences").select("slug, name").order("name");return e?(console.error("Error fetching sequences:",e),[]):t||[]}catch(t){return console.error("Exception in getAvailableSequences:",t),[]}}const $={all:["sequence-analytics"],sequences:()=>[...$.all,"sequences"],summary:t=>[...$.all,"summary",t],emailStats:t=>[...$.all,"email-stats",t],linkClicks:t=>[...$.all,"link-clicks",t],exits:t=>[...$.all,"exits",t],successMetrics:t=>[...$.all,"success-metrics",t]};function at(){const t=S.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e={queryKey:$.sequences(),queryFn:nt,staleTime:J.IMMUTABLE},t[0]=e):e=t[0],X(e)}function rt(t){const e=S.c(8);let l;e[0]!==t?(l=$.summary(t),e[0]=t,e[1]=l):l=e[1];let n;e[2]!==t?(n=()=>et(t),e[2]=t,e[3]=n):n=e[3];const a=!!t.sequenceSlug;let c;return e[4]!==l||e[5]!==n||e[6]!==a?(c={queryKey:l,queryFn:n,staleTime:J.LONG,enabled:a},e[4]=l,e[5]=n,e[6]=a,e[7]=c):c=e[7],X(c)}function it(t){const e=S.c(8);let l;e[0]!==t?(l=$.emailStats(t),e[0]=t,e[1]=l):l=e[1];let n;e[2]!==t?(n=()=>tt(t),e[2]=t,e[3]=n):n=e[3];const a=!!t.sequenceSlug;let c;return e[4]!==l||e[5]!==n||e[6]!==a?(c={queryKey:l,queryFn:n,staleTime:J.LONG,enabled:a},e[4]=l,e[5]=n,e[6]=a,e[7]=c):c=e[7],X(c)}function ot(t){const e=S.c(8);let l;e[0]!==t?(l=$.linkClicks(t),e[0]=t,e[1]=l):l=e[1];let n;e[2]!==t?(n=()=>st(t),e[2]=t,e[3]=n):n=e[3];const a=!!t.sequenceSlug&&t.stepNumber>0;let c;return e[4]!==l||e[5]!==n||e[6]!==a?(c={queryKey:l,queryFn:n,staleTime:J.LONG,enabled:a},e[4]=l,e[5]=n,e[6]=a,e[7]=c):c=e[7],X(c)}function mt(t){const e=S.c(8);let l;e[0]!==t?(l=$.exits(t),e[0]=t,e[1]=l):l=e[1];let n;e[2]!==t?(n=()=>lt(t),e[2]=t,e[3]=n):n=e[3];const a=!!t.sequenceSlug;let c;return e[4]!==l||e[5]!==n||e[6]!==a?(c={queryKey:l,queryFn:n,staleTime:J.LONG,enabled:a},e[4]=l,e[5]=n,e[6]=a,e[7]=c):c=e[7],X(c)}function dt(t){const e=S.c(8);let l;e[0]!==t?(l=$.successMetrics(t),e[0]=t,e[1]=l):l=e[1];let n;e[2]!==t?(n=()=>ct(t),e[2]=t,e[3]=n):n=e[3];const a=!!t.sequenceSlug;let c;return e[4]!==l||e[5]!==n||e[6]!==a?(c={queryKey:l,queryFn:n,staleTime:J.LONG,enabled:a},e[4]=l,e[5]=n,e[6]=a,e[7]=c):c=e[7],X(c)}function xt(t){const e=S.c(32),{data:l,isLoading:n}=t;if(n){let C;return e[0]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(ut,{}),e[0]=C):C=e[0],C}if(!l)return null;const a=`${l.active_enrollments} active`;
1let c;e[1]!==l.total_enrolled||e[2]!==a?(c=s.jsx(O,{title:"Total Enrolled",value:l.total_enrolled,icon:$e,subtitle:a}),e[1]=l.total_enrolled,e[2]=a,e[3]=c):c=e[3];const m=`${l.completion_rate??0}% rate`;let i;e[4]!==l.total_completed||e[5]!==m?(i=s.jsx(O,{title:"Completed",value:l.total_completed,icon:Le,subtitle:m,variant:"green"}),e[4]=l.total_completed,e[5]=m,e[6]=i):i=e[6];const o=`${l.conversion_rate??0}% rate`;let d;e[7]!==l.total_converted||e[8]!==o?(d=s.jsx(O,{title:"Converted",value:l.total_converted,icon:Te,subtitle:o,variant:"purple"}),e[7]=l.total_converted,e[8]=o,e[9]=d):d=e[9];const x=l.avg_engagement_score??0;let g;e[10]!==x?(g=s.jsx(O,{title:"Engagement",value:x,icon:he,subtitle:"Avg score",variant:"blue"}),e[10]=x,e[11]=g):g=e[11];let j;e[12]!==l.total_emails_sent?(j=s.jsx(O,{title:"Emails Sent",value:l.total_emails_sent,icon:ue,subtitle:"Total"}),e[12]=l.total_emails_sent,e[13]=j):j=e[13];const f=`${l.overall_open_rate??0}%`,_=`${l.total_emails_opened} opens`;let u;e[14]!==f||e[15]!==_?(u=s.jsx(O,{title:"Open Rate",value:f,icon:Me,subtitle:_,variant:"blue"}),e[14]=f,e[15]=_,e[16]=u):u=e[16];const h=`${l.overall_click_rate??0}%`,r=`${l.total_emails_clicked} clicks`;let b;e[17]!==h||e[18]!==r?(b=s.jsx(O,{title:"Click Rate",value:h,icon:Oe,subtitle:r,variant:"green"}),e[17]=h,e[18]=r,e[19]=b):b=e[19];const N=`${l.overall_reply_rate??0}%`,k=`${l.total_emails_replied} replies`;let w;e[20]!==N||e[21]!==k?(w=s.jsx(O,{title:"Reply Rate",value:N,icon:Ae,subtitle:k,variant:"purple"}),e[20]=N,e[21]=k,e[22]=w):w=e[22];let q;return e[23]!==u||e[24]!==b||e[25]!==w||e[26]!==c||e[27]!==i||e[28]!==d||e[29]!==g||e[30]!==j?(q=s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[c,i,d,g,j,u,b,w]}),e[23]=u,e[24]=b,e[25]=w,e[26]=c,e[27]=i,e[28]=d,e[29]=g,e[30]=j,e[31]=q):q=e[31],q}function O(t){const e=S.c(20),{title:l,value:n,icon:a,subtitle:c,variant:m}=t,i=m===void 0?"default":m;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={default:"text-foreground",blue:"text-blue-500",green:"text-green-500",purple:"text-purple-500",red:"text-red-500",orange:"text-orange-500"},e[0]=o):o=e[0];const d=o;let x;e[1]!==l?(x=s.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:l}),e[1]=l,e[2]=x):x=e[2];const g=`text-2xl font-bold ${d[i]}`;let j;e[3]!==n?(j=typeof n=="number"?n.toLocaleString():n,e[3]=n,e[4]=j):j=e[4];let f;e[5]!==g||e[6]!==j?(f=s.jsx("p",{className:g,children:j}),e[5]=g,e[6]=j,e[7]=f):f=e[7];let _;e[8]!==c?(_=c&&s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:c}),e[8]=c,e[9]=_):_=e[9];let u;e[10]!==x||e[11]!==f||e[12]!==_?(u=s.jsxs("div",{children:[x,f,_]}),e[10]=x,e[11]=f,e[12]=_,e[13]=u):u=e[13];const h=`h-8 w-8 opacity-20 ${d[i]}`;let r;e[14]!==a||e[15]!==h?(r=s.jsx(a,{className:h}),e[14]=a,e[15]=h,e[16]=r):r=e[16];let b;return e[17]!==r||e[18]!==u?(b=s.jsx(L,{children:s.jsx(T,{className:"pt-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[u,r]})})}),e[17]=r,e[18]=u,e[19]=b):b=e[19],b}function ut(){const t=S.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[...Array(8)].map(ht)}),t[0]=e):e=t[0],e}function ht(t,e){return s.jsx(L,{children:s.jsxs(T,{className:"pt-6",children:[s.jsx(y,{className:"h-4 w-24 mb-2"}),s.jsx(y,{className:"h-8 w-16 mb-1"}),s.jsx(y,{className:"h-3 w-20"})]})},e)}function ft(t){const e=S.c(18),{data:l,isLoading:n,sequenceSlug:a}=t,[c,m]=ye.useState(null);if(n){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(_t,{}),e[0]=h):h=e[0],h}if(!l||l.length===0){let h;return e[1]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(L,{children:s.jsxs(T,{className:"py-8 text-center text-muted-foreground",children:[s.jsx(ue,{className:"h-12 w-12 mx-auto mb-4 opacity-20"}),s.jsx("p",{children:"No email sends yet"}),s.jsx("p",{className:"text-sm",children:"Metrics will appear once emails are sent"})]})}),e[1]=h):h=e[1],h}const i=gt;let o;e[2]!==c?(o=h=>{m(c===h?null:h)},e[2]=c,e[3]=o):o=e[3];const d=o;let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x={A:"bg-blue-100 text-blue-700 border-blue-300",B:"bg-green-100 text-green-700 border-green-300",C:"bg-purple-100 text-purple-700 border-purple-300",D:"bg-orange-100 text-orange-700 border-orange-300",default:"bg-gray-100 text-gray-700 border-gray-300"},e[4]=x):x=e[4];const g=x;let j;e[5]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsxs(I,{children:[s.jsxs(ae,{className:"flex items-center gap-2",children:[s.jsx(ue,{className:"h-5 w-5"}),"Email Performance"]}),s.jsx(ge,{children:"Click a row to see link-level details"})]}),e[5]=j):j=e[5];let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(_e,{children:s.jsxs(A,{children:[s.jsx(v,{className:"w-8"}),s.jsx(v,{children:"Email"}),s.jsx(v,{className:"text-right",children:"Sent"}),s.jsx(v,{className:"text-right",children:"Opens"}),s.jsx(v,{className:"text-right",children:"Clicks"}),s.jsx(v,{className:"text-right",children:"Replies"}),s.jsx(v,{className:"text-right",children:"Unsub"}),s.jsx(v,{className:"text-right",children:"Bounce"}),s.jsx(v,{className:"text-center",children:"CTA Clicks"}),s.jsx(v,{className:"text-center",children:"Exits"})]})}),e[6]=f):f=e[6];let _;if(e[7]!==l||e[8]!==c||e[9]!==a||e[10]!==d){let h;e[12]!==c||e[13]!==a||e[14]!==d?(h=r=>{const b=i(r);return s.jsxs(ye.Fragment,{children:[s.jsxs(A,{className:"cursor-pointer hover:bg-slate-50",onClick:()=>d(b),children:[s.jsx(p,{children:c===b?s.jsx(Ie,{className:"h-4 w-4"}):s.jsx(Re,{className:"h-4 w-4"})}),s.jsx(p,{children:s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-medium",children:r.step_name}),r.ab_enabled&&r.ab_variant!=="default"&&s.jsxs(E,{variant:"outline",className:`text-xs font-semibold ${g[r.ab_variant]||g.default}`,children:["Variant ",r.ab_variant]})]}),s.jsx("span",{className:"text-xs text-muted-foreground",children:r.subject_template})]})}),s.jsx(p,{className:"text-right",children:r.sent_count}),s.jsx(p,{className:"text-right",children:s.jsxs("div",{className:"flex flex-col items-end",children:[s.jsx("span",{children:r.open_count}),s.jsxs(E,{variant:"outline",className:"text-xs",children:[r.open_rate??0,"%"]})]})}),s.jsx(p,{className:"text-right",children:s.jsxs("div",{className:"flex flex-col items-end",children:[s.jsx("span",{children:r.click_count}),s.jsxs(E,{variant:"outline",className:"text-xs",children:[r.click_rate??0,"%"]})]})}),s.jsx(p,{className:"text-right",children:s.jsxs("div",{className:"flex flex-col items-end",children:[s.jsx("span",{children:r.reply_count}),s.jsxs(E,{variant:"outline",className:"text-xs",children:[r.reply_rate??0,"%"]})]})}),s.jsx(p,{className:"text-right",children:s.jsxs("div",{className:"flex flex-col items-end",children:[s.jsx("span",{className:r.unsub_count>0?"text-orange-500":"",children:r.unsub_count}),r.unsub_count>0&&s.jsxs(E,{variant:"outline",className:"text-xs text-orange-500",children:[r.unsub_rate,"%"]})]})}),s.jsx(p,{className:"text-right",children:s.jsxs("div",{className:"flex flex-col items-end",children:[s.jsx("span",{className:r.bounce_count>0?"text-red-500":"",children:r.bounce_count}),r.bounce_count>0&&s.jsxs(E,{variant:"outline",className:"text-xs text-red-500",children:[r.bounce_rate,"%"]})]})}),s.jsx(p,{children:s.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs",children:[r.lesson_clicks>0&&s.jsxs("span",{className:"flex items-center gap-1",title:"Lesson clicks",children:[s.jsx(pe,{className:"h-3 w-3"}),r.lesson_clicks]}),r.test_clicks>0&&s.jsxs("span",{className:"flex items-center gap-1",title:"Test clicks",children:[s.jsx(ve,{className:"h-3 w-3"}),r.test_clicks]}),r.consultation_clicks>0&&s.jsxs("span",{className:"flex items-center gap-1 text-green-600",title:"Consultation clicks",children:[s.jsx(we,{className:"h-3 w-3"}),r.consultation_clicks]}),r.ebook_clicks>0&&s.jsxs("span",{className:"flex items-center gap-1",title:"Ebook clicks",children:[s.jsx(qe,{className:"h-3 w-3"}),r.ebook_clicks]})]})}),s.jsx(p,{children:s.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs",children:[r.conversion_exits>0&&s.jsxs("span",{className:"flex items-center gap-1 text-green-600",title:"Consultation exits",children:[s.jsx(je,{className:"h-3 w-3"}),r.conversion_exits]}),r.payment_exits>0&&s.jsxs("span",{className:"flex items-center gap-1 text-purple-600",title:"Payment exits",children:[s.jsx(ne,{className:"h-3 w-3"}),r.payment_exits]})]})})]}),c===b&&s.jsx(A,{children:s.jsx(p,{colSpan:10,className:"bg-slate-50 p-0",children:s.jsx(jt,{sequenceSlug:a,stepNumber:r.step_number})})})]},b)},e[12]=c,e[13]=a,e[14]=d,e[15]=h):h=e[15],_=l.map(h),e[7]=l,e[8]=c,e[9]=a,e[10]=d,e[11]=_}else _=e[11];let u;return e[16]!==_?(u=s.jsxs(L,{children:[j,s.jsx(T,{children:s.jsxs(be,{children:[f,s.jsx(Ne,{children:_})]})})]}),e[16]=_,e[17]=u):u=e[17],u}function gt(t){return`${t.step_number}-${t.ab_variant}`}function jt(t){const e=S.c(14),{sequenceSlug:l,stepNumber:n}=t;let a;e[0]!==l||e[1]!==n?(a={sequenceSlug:l,stepNumber:n},e[0]=l,e[1]=n,e[2]=a):a=e[2];const{data:c,isLoading:m}=ot(a);if(m){let u;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("div",{className:"p-4",children:s.jsx(y,{className:"h-20 w-full"})}),e[3]=u):u=e[3],u}if(!c||c.length===0){let u;return e[4]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No link clicks recorded for this email"}),e[4]=u):u=e[4],u}let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i={lesson:pe,test:ve,consultation:we,ebook:qe,other:de},e[5]=i):i=e[5];const o=i;let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d={lesson:"text-blue-600",test:"text-purple-600",consultation:"text-green-600",ebook:"text-orange-600",other:"text-gray-600"},e[6]=d):d=e[6];const x=d;let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsxs("h4",{className:"text-sm font-medium mb-3 flex items-center gap-2",children:[s.jsx(de,{className:"h-4 w-4"}),"Link Clicks Detail"]}),e[7]=g):g=e[7];let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(_e,{children:s.jsxs(A,{children:[s.jsx(v,{children:"Category"}),s.jsx(v,{children:"URL"}),s.jsx(v,{className:"text-right",children:"Clicks"}),s.jsx(v,{className:"text-right",children:"Unique"}),s.jsx(v,{className:"text-right",children:"Converted"})]})}),e[8]=j):j=e[8];let f;if(e[9]!==c){let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=(h,r)=>{const b=o[h.link_category]||de,N=x[h.link_category]||"";return s.jsxs(A,{children:[s.jsx(p,{children:s.jsxs("span",{className:`flex items-center gap-2 ${N}`,children:[s.jsx(b,{className:"h-4 w-4"}),h.link_category]})}),s.jsx(p,{className:"max-w-xs truncate text-xs",children:h.original_url}),s.jsx(p,{className:"text-right",children:h.click_count}),s.jsx(p,{className:"text-right",children:h.unique_clickers}),s.jsx(p,{className:"text-right",children:h.converted_count>0&&s.jsx(E,{variant:"outline",className:"text-green-600",children:h.converted_count})})]},r)}
1,e[11]=u):u=e[11],f=c.map(u),e[9]=c,e[10]=f}else f=e[10];let _;return e[12]!==f?(_=s.jsxs("div",{className:"p-4",children:[g,s.jsxs(be,{children:[j,s.jsx(Ne,{children:f})]})]}),e[12]=f,e[13]=_):_=e[13],_}function _t(){const t=S.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs(I,{children:[s.jsx(y,{className:"h-6 w-40"}),s.jsx(y,{className:"h-4 w-60"})]}),t[0]=e):e=t[0];let l;return t[1]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsxs(L,{children:[e,s.jsx(T,{children:s.jsx(y,{className:"h-64 w-full"})})]}),t[1]=l):l=t[1],l}function bt(t){const e=S.c(25),{data:l,isLoading:n}=t;let a;if(e[0]!==l){a={totalPositive:0,totalNegative:0,totalOther:0};for(const N of l??[])N.exit_category==="positive"?a.totalPositive=a.totalPositive+N.exit_count:N.exit_category==="negative"?a.totalNegative=a.totalNegative+N.exit_count:a.totalOther=a.totalOther+N.exit_count;e[0]=l,e[1]=a}else a=e[1];const{totalPositive:c,totalNegative:m,totalOther:i}=a;if(n){let N;return e[2]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(vt,{}),e[2]=N):N=e[2],N}if(!l||l.length===0){let N;return e[3]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(L,{children:s.jsxs(T,{className:"py-8 text-center text-muted-foreground",children:[s.jsx(fe,{className:"h-12 w-12 mx-auto mb-4 opacity-20"}),s.jsx("p",{children:"No exits recorded yet"})]})}),e[3]=N):N=e[3],N}let o;e[4]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsxs(I,{children:[s.jsxs(ae,{className:"flex items-center gap-2",children:[s.jsx(fe,{className:"h-5 w-5"}),"Exit Analysis"]}),s.jsx(ge,{children:"Understanding why and when users leave the sequence"})]}),e[4]=o):o=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(je,{className:"h-3 w-3 mr-1"}),e[5]=d):d=e[5];let x;e[6]!==c?(x=s.jsxs(E,{className:"bg-green-100 text-green-800 hover:bg-green-100",children:[d,"Positive: ",c]}),e[6]=c,e[7]=x):x=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(ke,{className:"h-3 w-3 mr-1"}),e[8]=g):g=e[8];let j;e[9]!==m?(j=s.jsxs(E,{className:"bg-red-100 text-red-800 hover:bg-red-100",children:[g,"Negative: ",m]}),e[9]=m,e[10]=j):j=e[10];let f;e[11]!==i?(f=i>0&&s.jsxs(E,{variant:"outline",children:["Other: ",i]}),e[11]=i,e[12]=f):f=e[12];let _;e[13]!==x||e[14]!==j||e[15]!==f?(_=s.jsxs("div",{className:"flex gap-4",children:[x,j,f]}),e[13]=x,e[14]=j,e[15]=f,e[16]=_):_=e[16];let u;e[17]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(_e,{children:s.jsxs(A,{children:[s.jsx(v,{children:"Exit Reason"}),s.jsx(v,{children:"Category"}),s.jsx(v,{children:"After Email"}),s.jsx(v,{className:"text-right",children:"Count"}),s.jsx(v,{className:"text-right",children:"% of Exits"})]})}),e[17]=u):u=e[17];let h;e[18]!==l?(h=l.map(Nt),e[18]=l,e[19]=h):h=e[19];let r;e[20]!==h?(r=s.jsxs(be,{children:[u,s.jsx(Ne,{children:h})]}),e[20]=h,e[21]=r):r=e[21];let b;return e[22]!==r||e[23]!==_?(b=s.jsxs(L,{children:[o,s.jsxs(T,{className:"space-y-6",children:[_,r]})]}),e[22]=r,e[23]=_,e[24]=b):b=e[24],b}function Nt(t,e){return s.jsxs(A,{children:[s.jsxs(p,{className:"flex items-center gap-2",children:[s.jsx(yt,{reason:t.exit_reason}),s.jsx("span",{className:"font-medium",children:pt(t.exit_reason)})]}),s.jsx(p,{children:s.jsx(St,{category:t.exit_category})}),s.jsx(p,{children:s.jsx("span",{className:"text-sm",children:t.exit_after_step_name||`Step ${t.exit_after_step}`})}),s.jsx(p,{className:"text-right font-medium",children:t.exit_count}),s.jsx(p,{className:"text-right",children:s.jsxs(E,{variant:"outline",children:[t.pct_of_total??0,"%"]})})]},e)}function yt(t){const e=S.c(3),{reason:l}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={"form.consultation.requested":je,"payment.completed":ne,"course.prerecorded.purchased":ne,"course.coaching.purchased":ne,"email.unsubscribed":ke,"email.bounced":Be,"email.complained":Pe},e[0]=n):n=e[0];const c=n[l]||fe;let m;return e[1]!==c?(m=s.jsx(c,{className:"h-4 w-4"}),e[1]=c,e[2]=m):m=e[2],m}function St(t){const e=S.c(4),{category:l}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={positive:{variant:"default",className:"bg-green-100 text-green-800 hover:bg-green-100",label:"Positive"},negative:{variant:"default",className:"bg-red-100 text-red-800 hover:bg-red-100",label:"Negative"},other:{variant:"outline",className:"",label:"Other"}},e[0]=n):n=e[0];const a=n,{className:c,label:m}=a[l]||a.other;let i;return e[1]!==c||e[2]!==m?(i=s.jsx(E,{className:c,children:m}),e[1]=c,e[2]=m,e[3]=i):i=e[3],i}function pt(t){return{"form.consultation.requested":"Consultation Requested","payment.completed":"Payment Completed","course.prerecorded.purchased":"Course Purchased","course.coaching.purchased":"Coaching Purchased","email.unsubscribed":"Unsubscribed","email.bounced":"Email Bounced","email.complained":"Marked as Spam"}[t]||t}function vt(){const t=S.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs(I,{children:[s.jsx(y,{className:"h-6 w-40"}),s.jsx(y,{className:"h-4 w-60"})]}),t[0]=e):e=t[0];let l;return t[1]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsxs(L,{children:[e,s.jsxs(T,{children:[s.jsxs("div",{className:"flex gap-4 mb-4",children:[s.jsx(y,{className:"h-6 w-24"}),s.jsx(y,{className:"h-6 w-24"})]}),s.jsx(y,{className:"h-40 w-full"})]})]}),t[1]=l):l=t[1],l}function wt(t){const e=S.c(12),{data:l,isLoading:n}=t;if(n){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx($t,{}),e[0]=d):d=e[0],d}if(!l)return null;let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsxs("div",{children:[s.jsxs(ae,{className:"flex items-center gap-2",children:[s.jsx(Ke,{className:"h-5 w-5"}),"Success Scorecard"]}),s.jsx(ge,{children:"Performance against targets"})]}),e[1]=a):a=e[1];let c;e[2]!==l.overall_grade||e[3]!==l.overall_score?(c=s.jsx(I,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[a,s.jsx(Et,{grade:l.overall_grade,score:l.overall_score})]})}),e[2]=l.overall_grade,e[3]=l.overall_score,e[4]=c):c=e[4];let m;e[5]!==l.metrics?(m=l.metrics.map(qt),e[5]=l.metrics,e[6]=m):m=e[6];let i;e[7]!==m?(i=s.jsx(T,{className:"space-y-6",children:m}),e[7]=m,e[8]=i):i=e[8];let o;
1return e[9]!==c||e[10]!==i?(o=s.jsxs(L,{children:[c,i]}),e[9]=c,e[10]=i,e[11]=o):o=e[11],o}function qt(t){return s.jsx(kt,{metric:t},t.name)}function kt(t){const e=S.c(39),{metric:l}=t,n=l.actual??0,a=l.excellent_threshold*1.2,c=Math.min(n/a*100,100);let m;e[0]!==l.label?(m=s.jsx("span",{className:"text-sm font-medium",children:l.label}),e[0]=l.label,e[1]=m):m=e[1];let i;e[2]!==n?(i=s.jsxs("span",{className:"text-lg font-bold",children:[n,"%"]}),e[2]=n,e[3]=i):i=e[3];let o;e[4]!==l.status?(o=s.jsx(Ct,{status:l.status}),e[4]=l.status,e[5]=o):o=e[5];let d;e[6]!==i||e[7]!==o?(d=s.jsxs("div",{className:"flex items-center gap-2",children:[i,o]}),e[6]=i,e[7]=o,e[8]=d):d=e[8];let x;e[9]!==m||e[10]!==d?(x=s.jsxs("div",{className:"flex items-center justify-between",children:[m,d]}),e[9]=m,e[10]=d,e[11]=x):x=e[11];let g;e[12]!==c?(g=s.jsx(Je,{value:c,className:"h-3"}),e[12]=c,e[13]=g):g=e[13];const j=l.min_threshold/a*100;let f;e[14]!==j?(f=s.jsx(xe,{position:j,label:"Min",color:"red"}),e[14]=j,e[15]=f):f=e[15];const _=l.good_threshold/a*100;let u;e[16]!==_?(u=s.jsx(xe,{position:_,label:"Good",color:"yellow"}),e[16]=_,e[17]=u):u=e[17];const h=l.excellent_threshold/a*100;let r;e[18]!==h?(r=s.jsx(xe,{position:h,label:"Excellent",color:"green"}),e[18]=h,e[19]=r):r=e[19];let b;e[20]!==u||e[21]!==r||e[22]!==g||e[23]!==f?(b=s.jsxs("div",{className:"relative",children:[g,f,u,r]}),e[20]=u,e[21]=r,e[22]=g,e[23]=f,e[24]=b):b=e[24];let N;e[25]!==l.min_threshold?(N=s.jsxs("span",{children:["Min: ",l.min_threshold,"%"]}),e[25]=l.min_threshold,e[26]=N):N=e[26];let k;e[27]!==l.good_threshold?(k=s.jsxs("span",{children:["Good: ",l.good_threshold,"%"]}),e[27]=l.good_threshold,e[28]=k):k=e[28];let w;e[29]!==l.excellent_threshold?(w=s.jsxs("span",{children:["Excellent: ",l.excellent_threshold,"%"]}),e[29]=l.excellent_threshold,e[30]=w):w=e[30];let q;e[31]!==N||e[32]!==k||e[33]!==w?(q=s.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[N,k,w]}),e[31]=N,e[32]=k,e[33]=w,e[34]=q):q=e[34];let C;return e[35]!==b||e[36]!==q||e[37]!==x?(C=s.jsxs("div",{className:"space-y-2",children:[x,b,q]}),e[35]=b,e[36]=q,e[37]=x,e[38]=C):C=e[38],C}function xe(t){const e=S.c(8),{position:l,color:n}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={red:"bg-red-500",yellow:"bg-yellow-500",green:"bg-green-500"},e[0]=a):a=e[0];const c=a,m=`${Math.min(l,100)}%`;let i;e[1]!==m?(i={left:m},e[1]=m,e[2]=i):i=e[2];const o=`h-full w-full ${c[n]}`;let d;e[3]!==o?(d=s.jsx("div",{className:o}),e[3]=o,e[4]=d):d=e[4];let x;return e[5]!==i||e[6]!==d?(x=s.jsx("div",{className:"absolute top-0 h-3 w-0.5 opacity-70",style:i,children:d}),e[5]=i,e[6]=d,e[7]=x):x=e[7],x}function Ct(t){const e=S.c(7),{status:l}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={excellent:{icon:he,className:"text-green-600",label:"Excellent"},good:{icon:he,className:"text-blue-600",label:"Good"},ok:{icon:Fe,className:"text-yellow-600",label:"OK"},below:{icon:De,className:"text-red-600",label:"Below"}},e[0]=n):n=e[0];const a=n,{icon:c,className:m,label:i}=a[l];let o;e[1]!==c?(o=s.jsx(c,{className:"h-3 w-3 mr-1"}),e[1]=c,e[2]=o):o=e[2];let d;return e[3]!==m||e[4]!==i||e[5]!==o?(d=s.jsxs(E,{variant:"outline",className:m,children:[o,i]}),e[3]=m,e[4]=i,e[5]=o,e[6]=d):d=e[6],d}function Et(t){const e=S.c(12),{grade:l,score:n}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={"A+":"bg-green-500",A:"bg-green-400","B+":"bg-blue-500",B:"bg-blue-400","C+":"bg-yellow-500",C:"bg-yellow-400",D:"bg-orange-500",F:"bg-red-500"},e[0]=a):a=e[0];const c=a;let m;e[1]!==n?(m=s.jsx("div",{className:"text-2xl font-bold",children:n}),e[1]=n,e[2]=m):m=e[2];let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("div",{className:"text-xs text-muted-foreground",children:"Score"}),e[3]=i):i=e[3];let o;e[4]!==m?(o=s.jsxs("div",{className:"text-right",children:[m,i]}),e[4]=m,e[5]=o):o=e[5];const d=`w-14 h-14 rounded-full flex items-center justify-center text-white text-2xl font-bold ${c[l]||"bg-gray-400"}`;let x;e[6]!==l||e[7]!==d?(x=s.jsx("div",{className:d,children:l}),e[6]=l,e[7]=d,e[8]=x):x=e[8];let g;return e[9]!==o||e[10]!==x?(g=s.jsxs("div",{className:"flex items-center gap-3",children:[o,x]}),e[9]=o,e[10]=x,e[11]=g):g=e[11],g}function $t(){const t=S.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(I,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx(y,{className:"h-6 w-40"}),s.jsx(y,{className:"h-4 w-60 mt-2"})]}
1),s.jsx(y,{className:"h-14 w-14 rounded-full"})]})}),t[0]=e):e=t[0];let l;return t[1]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsxs(L,{children:[e,s.jsx(T,{className:"space-y-6",children:[1,2,3,4].map(Lt)})]}),t[1]=l):l=t[1],l}function Lt(t){return s.jsxs("div",{className:"space-y-2",children:[s.jsx(y,{className:"h-4 w-full"}),s.jsx(y,{className:"h-3 w-full"}),s.jsx(y,{className:"h-3 w-3/4"})]},t)}function zt(){const t=S.c(58),e=Ye(),[l,n]=Ze(),{hasMinimumRole:a,isLoading:c}=We();let m;t[0]!==l?(m=l.get("sequence")||"",t[0]=l,t[1]=m):m=t[1];const i=m,{data:o,isLoading:d}=at(),x=i||o?.[0]?.slug||"";let g;t[2]!==x?(g={sequenceSlug:x},t[2]=x,t[3]=g):g=t[3];const j=g,{data:f,isLoading:_,refetch:u}=rt(j),{data:h,isLoading:r,refetch:b}=it(j),{data:N,isLoading:k,refetch:w}=mt(j),{data:q,isLoading:C,refetch:re}=dt(j);if(c){let M;return t[4]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(Mt,{}),t[4]=M):M=t[4],M}if(!a("staff"))return e("/"),null;let W;t[5]!==n?(W=M=>{n({sequence:M})},t[5]=n,t[6]=W):W=t[6];const ie=W;let Y;t[7]!==b||t[8]!==w||t[9]!==re||t[10]!==u?(Y=()=>{u(),b(),w(),re()},t[7]=b,t[8]=w,t[9]=re,t[10]=u,t[11]=Y):Y=t[11];const oe=Y;let Z;t[12]!==x||t[13]!==o?(Z=o?.find(M=>M.slug===x),t[12]=x,t[13]=o,t[14]=Z):Z=t[14];const Ee=Z;let R;t[15]!==e?(R=()=>e("/admin/email"),t[15]=e,t[16]=R):R=t[16];let ee;t[17]===Symbol.for("react.memo_cache_sentinel")?(ee=s.jsx(Ue,{className:"h-5 w-5"}),t[17]=ee):ee=t[17];let P;t[18]!==R?(P=s.jsx(Se,{variant:"ghost",size:"icon",onClick:R,children:ee}),t[18]=R,t[19]=P):P=t[19];let te;t[20]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx("h1",{className:"text-3xl font-bold",children:"Sequence Analytics"}),t[20]=te):te=t[20];const me=Ee?.name||"Select a sequence";let B;t[21]!==me?(B=s.jsxs("div",{children:[te,s.jsx("p",{className:"text-muted-foreground",children:me})]}),t[21]=me,t[22]=B):B=t[22];let K;t[23]!==B||t[24]!==P?(K=s.jsxs("div",{className:"flex items-center gap-4",children:[P,B]}),t[23]=B,t[24]=P,t[25]=K):K=t[25];let se;t[26]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx(He,{className:"w-[280px]",children:s.jsx(ze,{placeholder:"Select sequence..."})}),t[26]=se):se=t[26];let D;t[27]!==o||t[28]!==d?(D=d?s.jsx(Ce,{value:"loading",disabled:!0,children:"Loading..."}):o?.map(Tt),t[27]=o,t[28]=d,t[29]=D):D=t[29];let F;t[30]!==D?(F=s.jsx(Qe,{children:D}),t[30]=D,t[31]=F):F=t[31];let G;t[32]!==x||t[33]!==ie||t[34]!==F?(G=s.jsxs(Xe,{value:x,onValueChange:ie,children:[se,F]}),t[32]=x,t[33]=ie,t[34]=F,t[35]=G):G=t[35];let le;t[36]===Symbol.for("react.memo_cache_sentinel")?(le=s.jsx(Ve,{className:"h-4 w-4 mr-2"}),t[36]=le):le=t[36];let U;t[37]!==oe?(U=s.jsxs(Se,{variant:"outline",onClick:oe,children:[le,"Refresh"]}),t[37]=oe,t[38]=U):U=t[38];let V;t[39]!==G||t[40]!==U?(V=s.jsxs("div",{className:"flex items-center gap-3",children:[G,U]}),t[39]=G,t[40]=U,t[41]=V):V=t[41];let H;t[42]!==K||t[43]!==V?(H=s.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 mb-8",children:[K,V]}),t[42]=K,t[43]=V,t[44]=H):H=t[44];let z;t[45]!==x||t[46]!==h||t[47]!==r||t[48]!==N||t[49]!==k||t[50]!==q||t[51]!==C||t[52]!==f||t[53]!==_?(z=x?s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[s.jsx("div",{className:"lg:col-span-1",children:s.jsx(wt,{data:q,isLoading:C})}),s.jsx("div",{className:"lg:col-span-2",children:s.jsxs(L,{children:[s.jsx(I,{children:s.jsx(ae,{children:"Key Performance Indicators"})}),s.jsx(T,{children:s.jsx(xt,{data:f,isLoading:_})})]})})]}),s.jsx(ft,{data:h||[],isLoading:r,sequenceSlug:x}),s.jsx(bt,{data:N||[],isLoading:k}),f&&s.jsxs("div",{className:"text-sm text-muted-foreground text-center",children:["Data from ",new Date(f.date_from).toLocaleDateString()," to"," ",new Date(f.date_to).toLocaleDateString()]})]}):s.jsx(L,{children:s.jsxs(T,{className:"py-12 text-center text-muted-foreground",children:[s.jsx(Ge,{className:"h-12 w-12 mx-auto mb-4 opacity-20"}),s.jsx("p",{className:"text-lg",children:"Select a sequence to view analytics"})]})}),t[45]=x,t[46]=h,t[47]=r,t[48]=N,t[49]=k,t[50]=q,t[51]=C,t[52]=f,t[53]=_,t[54]=z):z=t[54];let ce;return t[55]!==H||t[56]!==z?(ce=s.jsxs("div",{className:"container mx-auto py-8 px-4 max-w-7xl",children:[H,z]}),t[55]=H,t[56]=z,t[57]=ce):ce=t[57],ce}function Tt(t){return s.jsx(Ce,{value:t.slug,children:t.name},t.slug)}function Mt(){const t=S.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsxs("div",{children:[s.jsx(y,{className:"h-8 w-48 mb-2"}),s.jsx(y,{className:"h-4 w-32"})]}),s.jsx(y,{className:"h-10 w-64"})]}),t[0]=e):e=t[0];let l;return t[1]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsxs("div",{className:"container mx-auto py-8 px-4 max-w-7xl",children:[e,s.jsxs("div",{className:"grid lg:grid-cols-3 gap-6 mb-8",children:[s.jsx(y,{className:"h-64"}),s.jsx(y,{className:"h-64 lg:col-span-2"})]}),s.jsx(y,{className:"h-96"})]}),t[1]=l):l=t[1],l}export{zt as default};
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.