1import{a as K,o as le,z as e,r as v,q as z,s as S,j as t,I as te,v as F,D as j,w as T,P as B,S as Y,x as se,y as D,A as ie,B as W,C as N,H,E as Q,F as k,M as q,G as I,J as M,K as V,N as oe,O as ce,U as ue,V as de,W as me,X as pe,Y as O,h as _e}from"./root-C9LVyve2.js";import{u as be}from"./useMutation-CBnyrxiv.js";import{S as ne}from"./react-select.esm-7mg1mVKs.js";import{E as ae,g as J,a as xe,C as ge,b as he}from"./ColumnChart-BcMl2Raq.js";import{e as ve,a as fe}from"./hooks-Dmcz0DDD.js";import{g as L}from"./helpers-GDoOn1BT.js";import{R as je}from"./ReactHighcharts-C4G_YM4p.js";import{m as ye}from"./makeChartConfig-BYK9Pi48.js";import"./Select-49a62830.esm-BDaaeTRQ.js";import"./more-C-D7RsQv.js";import"./queryOptions-BQvTFV_-.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};n.SENTRY_RELEASE={id:"distillery-frontend"};var l=new n.Error().stack;l&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[l]="63e70773-ed35-4bcf-8eca-4d0959912385",n._sentryDebugIdIdentifier="sentry-dbid-63e70773-ed35-4bcf-8eca-4d0959912385")}catch{}})();const Ce=n=>n.status>=200&&n.status<=299?n.json():n.json().then(l=>{throw{data:l,statusCode:n.status}}),we=async n=>le("/api/webapp/client_dashboard/request_client_experiment_export/",n).then(Ce),G=n=>be({mutationFn:we,onSuccess:l=>{window.open(l.url,"_blank","noreferrer"),n({message:"Export file has been downloaded.",status:"success"})},onError:l=>{l.statusCode===403&&l.data.detail==="Authentication credentials were not provided."&&window.location.assign("/accounts/login/?next=/accounts/2fa"),n({message:"Something went wrong.",status:"error"})}}),Ne=e.object({count:e.number(),next:e.string().nullable(),previous:e.string().nullable(),results:e.array(e.object({id:e.number(),name:e.string()}))}),Ee=async n=>{const l=await K.get("/api/webapp/client_dashboard/list_all_tags/",{params:n});return Ne.parse(l.data)},X=(n,l)=>({queryKey:["clientDashboardListAllTags",n,l],queryFn:()=>Ee({client_slug:n,status:l}),staleTime:1/0}),re=e.object({id:e.number(),name:e.string()}),Te=e.object({count:e.number(),next:e.string().nullable(),previous:e.string().nullable(),results:e.array(e.object({id:e.number(),test_id:e.number(),account_name:e.string(),account_slug:e.string(),name:e.string(),test_type:e.string(),published_section_name:e.string(),status:e.string(),section_type:e.string(),main_lever:e.string(),change_type:e.object({description:e.string()}).nullable(),page_type:e.object({description:e.string()}).nullable(),strong_hypothesis:e.boolean().nullable(),expected_direction:e.string(),start_date:e.string().nullable(),preferred_result:e.object({observed_percentage_change:e.number().nullable(),series_dates:e.array(e.string()),series_variant:e.array(e.number()),series_variant_forecast:e.array(e.number()),series_cumulative_diff:e.array(e.number()),series_cumulative_diff_lower:e.array(e.number()),series_cumulative_diff_upper:e.array(e.number()),series_intervention_date:e.string(),won_sessions:e.number().nullable(),rescued_sessions:e.number().nullable(),recommendation:e.string()}).nullable(),preferred_cro_result:e.object({goal_id:e.string(),goal_name:e.string(),leader:e.string(),observed_lift:e.number(),observed_control_sessions:e.number(),observed_control_conversions:e.number(),observed_control_rate:e.number(),observed_variant_sessions:e.number(),observed_variant_conversions:e.number(),observed_variant_rate:e.number(),prob_variant_higher_exact:e.number(),expected_loss_control:e.number(),expected_loss_variant:e.number(),status:e.string()}).nullable(),lff_cro_experiment:e.object({test_id:e.number(),test_type:e.string(),status:e.string(),preferred_result:e.object({observed_percentage_change:e.number().nullable(),series_dates:e.array(e.string()),series_variant:e.array(e.number()),series_variant_forecast:e.array(e.number()),series_cumulative_diff:e.array(e.number()),series_cumulative_diff_lower:e.array(e.number()),series_cumulative_diff_upper:e.array(e.number()),series_intervention_date:e.string(),won_sessions:e.number().nullable(),rescued_sessions:e.number().nullable(),recommendation:e.string()}).nullable(),preferred_cro_result:e.object({goal_id:e.string(),goal_name:e.string(),leader:e.string(),observed_lift:e.number(),observed_control_sessions:e.number(),observed_control_conversions:e.number(),observed_control_rate:e.number(),observed_variant_sessions:e.number(),observed_variant_conversions:e.number(),observed_variant_rate:e.number(),prob_variant_higher_exact:e.number(),expected_loss_control:e.number(),expected_loss_variant:e.number(),status:e.string()}).nullable(),start_date:e.string().nullable()}).nullable(),lff_seo_experiment:e.object({test_id:e.number(),test_type:e.string(),status:e.string(),preferred_result:e.object({observed_percentage_change:e.number().nullable(),series_dates:e.array(e.string()),series_variant:e.array(e.number()),series_variant_forecast:e.array(e.number()),series_cumulative_diff:e.array(e.number()),series_cumulative_diff_lower:e.array(e.number()),series_cumulative_diff_upper:e.array(e.number()),series_intervention_date:e.string(),won_sessions:e.number().nullable(),rescued_sessions:e.number().nullable(),recommendation:e.string()}).nullable(),preferred_cro_result:e.object({goal_id:e.string(),goal_name:e.string(),leader:e.string(),observed_lift:e.number(),observed_control_sessions:e.number(),observed_control_conversions:e.number(),observed_control_rate:e.number(),observed_variant_sessions:e.number(),observed_variant_conversions:e.number(),observed_variant_rate:e.number(),prob_variant_higher_exact:e.number(),expected_loss_control:e.number(),expected_loss_variant:e.number(),status:e.string()}).nullable(),start_date:e.string().nullable()}).nullable(),tags:e.array(re)}))}),Fe=async(n,l)=>{const o=await K.get("/api/webapp/client_dashboard/list_running_experiments/",{params:{client_slug:n,...l},paramsSerializer:{indexes:null}});return Te.parse(o.data)},De=e.object({count:e.number(),next:e.string().nullable(),previous:e.string().nullable(),results:e.array(e.object({test_id:e.number(),name:e.string(),test_type:e.string(),published_section_name:e.string(),status:e.string(),complete_state:e.string().nullable(),preferred_result:e.object({observed_percentage_change:e.number().nullable(),series_dates:e.array(e.string()),series_variant:e.array(e.number()),series_variant_forecast:e.array(e.number()),series_cumulative_diff:e.array(e.number()),series_cumulative_diff_lower:e.array(e.number()),series_cumulative_diff_upper:e.array(e.number()),series_intervention_date:e.string(),won_sessions:e.number().nullable(),rescued_sessions:e.number().nullable(),recommendation:e.string()}).nullable(),preferred_cro_result:e.object({goal_id:e.string(),goal_name:e.string(),leader:e.string(),observed_lift:e.number(),observed_control_sessions:e.number(),observed_control_conversions:e.number(),observed_control_rate:e.number(),observed_variant_sessions:e.number(),observed_variant_conversions:e.number(),observed_variant_rate:e.number(),prob_variant_higher_exact:e.number(),expected_loss_control:e.number(),expected_loss_variant:e.number(),status:e.string()}).nullable(),account_name:e.string(),account_slug:e.string(),start_date:e.string().nullable(),end_date:e.string().nullable(),lff_cro_experiment:e.object({test_id:e.number(),test_type:e.string(),complete_state:e.string().nullable(),status:e.string(),preferred_result:e.object({observed_percentage_change:e.number().nullable(),series_dates:e.array(e.string()),series_variant:e.array(e.number()),series_variant_forecast:e.array(e.number()),series_cumulative_diff:e.array(e.number()),series_cumulative_diff_lower:e.array(e.number()),series_cumulative_diff_upper:e.array(e.number()),series_intervention_date:e.string(),won_sessions:e.number().nullable(),rescued_sessions:e.number().nullable(),recommendation:e.string()}).nullable(),preferred_cro_result:e.object({goal_id:e.string(),goal_name:e.string(),leader:e.string(),observed_lift:e.number(),observed_control_sessions:e.number(),observed_control_conversions:e.number(),observed_control_rate:e.number(),observed_variant_sessions:e.number(),observed_variant_conversions:e.number(),observed_variant_rate:e.number(),prob_variant_higher_exact:e.number(),expected_loss_control:e.number(),expected_loss_variant:e.number(),status:e.string()}).nullable(),start_date:e.string().nullable(),end_date:e.string().nullable()}).nullable(),lff_seo_experiment:e.object({test_id:e.number(),test_type:e.string(),complete_state:e.string().nullable(),status:e.string(),preferred_result:e.object({observed_percentage_change:e.number().nullable(),series_dates:e.array(e.string()),series_variant:e.array(e.number()),series_variant_forecast:e.array(e.number()),series_cumulative_diff:e.array(e.number()),series_cumulative_diff_lower:e.array(e.number()),series_cumulative_diff_upper:e.array(e.number()),series_intervention_date:e.string(),won_sessions:e.number().nullable(),rescued_sessions:e.number().nullable(),recommendation:e.string()}).nullable(),preferred_cro_result:e.object({goal_id:e.string(),goal_name:e.string(),leader:e.string(),observed_lift:e.number(),observed_control_sessions:e.number(),observed_control_conversions:e.number(),observed_control_rate:e.number(),observed_variant_sessions:e.number(),observed_variant_conversions:e.number(),observed_variant_rate:e.number(),prob_variant_higher_exact:e.number(),expected_loss_control:e.number(),expected_loss_variant:e.number(),status:e.string()}).nullable(),start_date:e.string().nullable(),end_date:e.string().nullable()}).nullable(),main_lever:e.string(),change_type:e.object({description:e.string()}).nullable(),page_type:e.object({description:e.string()}).nullable(),strong_hypothesis:e.boolean().nullable(),expected_direction:e.string(),tags:e.array(re)}))}),Se=async(n,l)=>{const o=await K.get("/api/webapp/client_dashboard/list_completed_experiments/",{params:{client_slug:n,...l},paramsSerializer:{indexes:null}});return De.parse(o.data)},Re="10",Z="0",Pe=({clientSlug:n,accounts:l,tags:o})=>{const _={limit:Re,offset:Z,query:""},[s,h]=v.useState(""),[m,r]=v.useState(_),[b,d]=v.useState(null),[x,u]=v.useState([]),c=z();v.useEffect(()=>{b&&(c[b.status](b.message),d(null))},[b,c]);const{data:f,isPending:y}=S({queryKey:["clientCompletedExperiments",n,m],queryFn:()=>Se(n,m),enabled:!!n}),g=(i,a)=>{r(i==="offset"?{...m,[i]:a}:{...m,[i]:a,offset:Z})},C=i=>{h(i),g("query",i)},R=G(d),$=()=>{const{query:i,...a}=m;D(n,"Customer Dashboard Experiments Export",{export_tab:"completed_experiments",active_filters:J(a,i)}),R.mutate({client_slug:n,name_contains:i||void 0,experiment_status:"completed",...a,tags:x.map(p=>p.value)})},P=JSON.stringify(m)===JSON.stringify({..._,query:s}),A=v.useMemo(()=>o.map(i=>({value:i.id,label:i.name})),[o]);v.useEffect(()=>{if(m.tags&&m.tags.length>0&&o.length){const i=m.tags.map(a=>A.find(p=>
1p.value===a)).filter(Boolean);u(i)}else u([])},[m.tags,o,A]);const w=i=>{u(i),g("tags",i.map(a=>a.value))},U=(i,a)=>{if(!x.some(p=>p.value===i)){const p=[...x,{value:i,label:a}];w(p)}};return t.jsxs("div",{className:"flex flex-col gap-8",children:[t.jsxs("div",{className:"flex flex-col",children:[t.jsx(te,{label:"Search",placeholder:"Search by name",leadingIcon:t.jsx(F,{name:"search"}),onChangeFunction:C,value:s,onChangeParameters:[]}),t.jsx("div",{className:"mt-4 w-full",children:t.jsx(ne,{isMulti:!0,isClearable:!0,options:A,value:x,onChange:i=>{const a=i?[...i]:[];u(a),g("tags",a.map(p=>p.value))},placeholder:"Filter by tagsâ¦",className:"w-full",size:"md",styles:{container:i=>({...i,width:"100%"})}})}),t.jsxs("div",{className:"mt-4 grid gap-2 md:grid-cols-5 md:grid-rows-2 md:gap-x-8 md:gap-y-2",children:[t.jsxs(j,{label:"Site Name",onChangeFunction:g,onChangeParameters:["account_slug"],value:m.account_slug,children:[t.jsx("option",{value:"",children:"All"}),l.map(({name:i,slug:a},p)=>t.jsx("option",{value:a,children:i},`${a}-${p}`))]}),t.jsxs(j,{label:"Test Type",onChangeFunction:g,onChangeParameters:["test_type"],value:m.test_type,children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"seo",children:"SEO"}),t.jsx("option",{value:"cro",children:"CRO"}),t.jsx("option",{value:"all_full_funnel",children:"Full Funnel"})]}),t.jsxs(j,{label:"Result",onChangeFunction:g,onChangeParameters:["complete_state"],value:m.complete_state,children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"accepted",children:"Positive"}),t.jsx("option",{value:"rejected",children:"Negative"}),t.jsx("option",{value:"null",children:"Inconclusive"})]}),t.jsx(T,{id:"start-date-from",label:"Start Date From",initialDate:"",updateDate:i=>g("start_date_after",i)}),t.jsx(T,{id:"start-date-to",label:"Start Date From To",initialDate:"",updateDate:i=>g("start_date_before",i)}),t.jsx(T,{id:"end-date-from",label:"End Date From",initialDate:"",updateDate:i=>g("end_date_after",i)}),t.jsx(T,{id:"end-date-to",label:"End Date From To",initialDate:"",updateDate:i=>g("end_date_before",i)})]}),t.jsx("div",{className:"self-end",children:t.jsx(B,{leftIcon:t.jsx(F,{name:"closeCross"}),size:"sm",variant:"primary",disabled:P,onClick:()=>r({..._,limit:m.limit,offset:m.offset,query:s}),children:"Clear Filters"})})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 flex justify-end",children:t.jsx(Y,{variant:"primary",leftIcon:t.jsx(F,{name:"download",color:"white"}),onClick:$,disabled:R.isPending,loading:R.isPending,children:"Export Data"})}),t.jsx("div",{children:f&&f.results.length!==0?f.results.map(i=>t.jsx(ae,{experiment:i,onTagClick:U},i.test_id)):t.jsx("div",{className:"border-sp-warning-300 mb-2 rounded-md border border-l-4 bg-white p-2",children:y?"Loading":"No experiments found"})})]}),t.jsx(se,{totalCount:f?.count||0,listItems:f?.results??[],setLimit:i=>g("limit",i),setOffset:i=>g("offset",i),offset:Number(m.offset),limit:Number(m.limit)})]})},Ae=({clientSlug:n,accounts:l})=>{const[o,_]=v.useState(null),[s,h]=v.useState({}),m=z();v.useEffect(()=>{o&&(m[o.status](o.message),_(null))},[o,m]);const{data:r}=S(ve()),{data:b}=S(fe()),d=(c,f)=>{h({...s,[c]:f})},x=G(_),u=()=>{D(n,"Customer Dashboard Experiments Export",{export_tab:"all_experiments",active_filters:J(s)}),x.mutate({client_slug:n,...s})};return t.jsx("div",{className:"flex flex-col gap-8",children:t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(ie,{variant:"info",message:"Note: Some filters are only applicable to Running or Completed experiments. If you use these filters, only experiments in the corresponding category will be exported."}),t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("div",{className:"mt-4 grid gap-2 md:grid-cols-5 md:grid-rows-2 md:gap-x-8 md:gap-y-2",children:[t.jsxs(j,{label:"Site Name",onChangeFunction:d,onChangeParameters:["account_slug"],value:s.account_slug,children:[t.jsx("option",{value:"",children:"All"}),l.map(({name:c,slug:f},y)=>t.jsx("option",{value:f,children:c},`${f}-${y}`))]}),t.jsxs(j,{label:"Test Type",onChangeFunction:d,onChangeParameters:["test_type"],value:s.test_type,children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"seo",children:"SEO"}),t.jsx("option",{value:"cro",children:"CRO"}),t.jsx("option",{value:"all_full_funnel",children:"Full Funnel"})]}),t.jsxs(j,{label:"Recommendation",onChangeFunction:d,onChangeParameters:["recommendation"],value:s.recommendation,tooltipMessage:"This filter will only apply to Running Experiments",children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"deploy",children:"Deploy"}),t.jsx("option",{value:"keep_running",children:"Keep Running"}),t.jsx("option",{value:"roll_back",children:"Roll back"}),t.jsx("option",{value:"too_early",children:"Too Early"}),t.jsx("option",{value:"end_test",children:"End Test"}),t.jsx("option",{value:"unlikely_to_reach_significance",children:"Unlikely to Reach Significance"})]}),t.jsxs(j,{label:"Result",onChangeFunction:d,onChangeParameters:["complete_state"],value:s.complete_state,tooltipMessage:"This filter will only apply to Completed Experiments",children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"accepted",children:"Positive"}),t.jsx("option",{value:"rejected",children:"Negative"}),t.jsx("option",{value:"null",children:"Inconclusive"})]}),t.jsx(T,{initialDate:s.start_date_after,id:"start-date-after",label:"Start Date From",updateDate:c=>d("start_date_after",c)}),t.jsx(T,{initialDate:s.start_date_before,id:"start-date-before",label:"Start Date To",updateDate:c=>d("start_date_before",c)}),t.jsx(T,{initialDate:s.end_date_after,id:"end-date-after",label:"End Date From",tooltipMessage:"This filter will only apply to Completed Experiments",updateDate:c=>d("end_date_after",c)}),t.jsx(T,{initialDate:s.end_date_before,id:"end-date-before",label:"End Date To",tooltipMessage:"This filter will only apply to Completed Experiments",updateDate:c=>d("end_date_before",c)}),t.jsxs(j,{label:"Main Lever",onChangeFunction:d,onChangeParameters:["main_lever"],value:s.main_lever,children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"ctr",children:"Clickthrough Rate"}),t.jsx("option",{value:"rankings",children:"Rankings"}),t.jsx("option",{value:"keywords",children:"Keywords"})]}),t.jsxs(j,{label:"Change Type",onChangeFunction:d,onChangeParameters:["change_type"],value:s.change_type,children:[t.jsx("option",{value:"",children:"All"}),r&&r.results.map(c=>t.jsx("option",{value:c.id,children:c.description},c.id))]}),t.jsxs(j,{label:"Page Type",onChangeFunction:d,onChangeParameters:["page_type"],value:s.page_type,children:[t.jsx("option",{value:"",children:"All"}),b&&b.results.map(c=>t.jsx("option",{value:c.id,children:c.description},c.id))]}),t.jsxs(j,{label:"Strong Hypothesis",onChangeFunction:d,onChangeParameters:["strong_hypothesis"],value:s.strong_hypothesis,children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"true",children:"Yes"}),t.jsx("option",{value:"false",children:"No"})]}),t.jsxs(j,{label:"Expected Direction",onChangeFunction:d,onChangeParameters:["expected_direction"],value:s.expected_direction,children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"positive",children:"Positive"}),t.jsx("option",{value:"negative",children:"Negative"}),t.jsx("option",{value:"neutral",children:"Neutral"})]})]}),t.jsx("div",{className:"self-end",children:t.jsx(B,{leftIcon:t.jsx(F,{name:"closeCross"}),size:"sm",variant:"primary",onClick:()=>h({main_lever:""}),children:"Clear Filters"})})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("p",{className:"text-sm text-gray-500",children:["Filters applied to the data: ",xe(s)]}),t.jsx("div",{className:"mb-2 flex justify-end",children:t.jsx(Y,{variant:"primary",leftIcon:t.jsx(F,{name:"download",color:"white"}),onClick:u,disabled:x.isPending,loading:x.isPending,children:"Export Data"})})]})]})})},ke="10",ee="0",qe=({clientSlug:n,initialAccountSlug:l,accounts:o,tags:_})=>{const s={account_slug:l||"",limit:ke,offset:ee,query:""},[h,m]=v.useState(""),[r,b]=v.useState(s),[d,x]=v.useState(null),u=z();v.useEffect(()=>{d&&(u[d.status](d.message),x(null))},[d,u]);const{data:c,isPending:f}=S({queryKey:["clientRunningExperiments",n,r],queryFn:()=>Fe(n,r),enabled:!!n}),y=v.useMemo(()=>_.map(a=>({value:a.id,label:a.name})),[_]),[g,C]=v.useState([]);v.useEffect(()=>{if(r.tags&&r.tags.length>0&&_.length){const a=r.tags.map(p=>y.find(E=>
1E.value===p)).filter(Boolean);C(a)}else C([])},[r.tags,_,y]);const R=a=>{C(a),w("tags",a.map(p=>p.value))},$=(a,p)=>{if(!g.some(E=>E.value===a)){const E=[...g,{value:a,label:p}];R(E)}},P=G(x),A=()=>{const{query:a,...p}=r;D(n,"Customer Dashboard Experiments Export",{export_tab:"running_experiments",active_filters:J(p,a)}),P.mutate({client_slug:n,name_contains:a||void 0,experiment_status:"running",...p,tags:g.map(E=>E.value)})},w=(a,p)=>{b(a==="offset"?{...r,[a]:p}:{...r,[a]:p,offset:ee})},U=a=>{m(a),w("query",a)},i=JSON.stringify(r)===JSON.stringify({...s,query:h});return t.jsxs("div",{className:"flex flex-col gap-8",children:[t.jsxs("div",{className:"flex flex-col",children:[t.jsx("div",{className:"flex items-end justify-between gap-10",children:t.jsx("div",{className:"flex-1",children:t.jsx(te,{label:"Search",placeholder:"Search by name",leadingIcon:t.jsx(F,{name:"search"}),onChangeFunction:U,value:h,onChangeParameters:[]})})}),t.jsx("div",{className:"mt-4 w-full",children:t.jsx(ne,{isMulti:!0,isClearable:!0,options:y,value:g,onChange:a=>{const p=a?[...a]:[];C(p),w("tags",p.map(E=>E.value))},placeholder:"Filter by tagsâ¦",className:"w-full",size:"md",styles:{container:a=>({...a,width:"100%"})}})}),t.jsxs("div",{className:"mt-4 grid gap-2 md:grid-cols-5 md:gap-x-8 md:gap-y-2",children:[t.jsxs(j,{label:"Site Name",onChangeFunction:w,onChangeParameters:["account_slug"],value:r.account_slug,children:[t.jsx("option",{value:"",children:"All"}),o.map(({name:a,slug:p},E)=>t.jsx("option",{value:p,children:a},`${p}-${E}`))]}),t.jsxs(j,{label:"Test Type",onChangeFunction:w,onChangeParameters:["test_type"],value:r.test_type,children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"seo",children:"SEO"}),t.jsx("option",{value:"cro",children:"CRO"}),t.jsx("option",{value:"all_full_funnel",children:"Full Funnel"})]}),t.jsxs(j,{label:"Recommendation",onChangeFunction:w,onChangeParameters:["recommendation"],value:r.recommendation,children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"deploy",children:"Deploy"}),t.jsx("option",{value:"keep_running",children:"Keep Running"}),t.jsx("option",{value:"roll_back",children:"Roll back"}),t.jsx("option",{value:"too_early",children:"Too Early"}),t.jsx("option",{value:"end_test",children:"End Test"}),t.jsx("option",{value:"unlikely_to_reach_significance",children:"Unlikely to Reach Significance"})]}),t.jsx(T,{id:"start-date-from",label:"Start Date From",initialDate:r.start_date_after,updateDate:a=>w("start_date_after",a)}),t.jsx(T,{id:"start-date-to",label:"Start Date From To",initialDate:r.start_date_before,updateDate:a=>w("start_date_before",a)})]}),t.jsx("div",{className:"self-end",children:t.jsx(B,{leftIcon:t.jsx(F,{name:"closeCross"}),size:"sm",variant:"primary",disabled:i,onClick:()=>b({...s,limit:r.limit,offset:r.offset,query:h}),children:"Clear Filters"})})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 flex justify-end",children:t.jsx(Y,{variant:"primary",leftIcon:t.jsx(F,{name:"download",color:"white"}),onClick:A,disabled:P.isPending,loading:P.isPending,children:"Export Data"})}),t.jsx("div",{className:"mb-2 flex flex-col gap-8",children:t.jsx("div",{children:c&&c.results.length!==0?c.results.map(a=>t.jsx(ae,{experiment:a,onTagClick:$},a.test_id)):t.jsx("div",{className:"border-sp-warning-300 mb-2 rounded-md border border-l-4 bg-white p-2",children:f?"Loading":"No experiments found"})})})]}),c&&c.results.length!==0?t.jsx(se,{totalCount:c?.count||0,listItems:c?.results??[],setLimit:a=>w("limit",a),setOffset:a=>w("offset",a),offset:Number(r.offset),limit:Number(r.limit)}):null]})},Le=({data:n,start_date_gte:l})=>{const{number:o,number_accepted:_,number_rejected:s,number_null:h,month_by_month:m}=n.completed_experiments_summary,r=m.reduce((u,c)=>{const f=(u.length>0?u[u.length-1].cumulativeAccepted:0)+c.number_accepted,y=(u.length>0?u[u.length-1].cumulativeRejected:0)+c.number_rejected,g=(u.length>0?u[u.length-1].cumulativeNull:0)+c.number_null,C=f+y+g;return u.push({winRate:[Date.UTC(c.year,c.month-1,1),C>0?f/C*100:0],lossRate:[Date.UTC(c.year,c.month-1,1),C>0?y/C*100:0],inconclusiveRate:[Date.UTC(c.year,c.month-1,1),C>0?g/C*100:0],cumulativeAccepted:f,cumulativeRejected:y,cumulativeNull:g}),u},[]),b={title:"",y_axis_label:"Completed Tests Rate",series:[{name:"Win Rate",data:r.map(u=>u.winRate)},{name:"Loss Rate",data:r.map(u=>u.lossRate)},{name:"Inconclusive Rate",data:r.map(u=>u.inconclusiveRate)}]},d=ye(b),x={...d,yAxis:{...d.yAxis,labels:{format:"{value}%"}},colors:[Q.success[400],Q.primary[400],Q.secondary[400]]};return t.jsx("div",{children:t.jsxs(W,{className:"w-full flex-initial",children:[t.jsx("div",{className:"bg-sp-secondary-400 h-2 rounded-t-lg"}),t.jsx(N,{children:t.jsxs(N.Content,{children:[t.jsx(N.Title,{children:"Win & Loss Rate Summary"}),t.jsx(N.Description,{children:l===""?"All Time":`From ${l}`})]})}),t.jsx(H,{classes:"grow",children:t.jsxs("div",{className:"flex flex-row flex-wrap items-center",children:[t.jsx("div",{className:"mx-auto w-4/5",children:t.jsx(je,{config:x})}),t.jsxs("div",{className:"flex w-1/5 flex-initial flex-col gap-4 pl-8",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sp-neutral-500 text-sm",children:"Win Rate"}),t.jsx("p",{className:"text-sp-neutral-900 text-3xl",children:o>0?`${(_/o*100).toFixed(1)} %`:"No data"})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sp-neutral-500 text-sm",children:"Loss Rate"}),t.jsx("p",{className:"text-sp-neutral-900 text-3xl",children:o>0?`${(s/o*100).toFixed(1)} %`:"No data"})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sp-neutral-500 text-sm",children:"Inconclusive Rate"}),t.jsx("p",{className:"text-sp-neutral-900 text-3xl",children:o>0?`${(h/o*100).toFixed(1)} %`:"No data"})]})]})]})})]})})},Ie=({slides:n})=>{const[l,o]=v.useState(0),_=n.length,s=()=>o(l==_-1?0:l+1),h=()=>o(l===0?_-1:l-1),m=n.map((r,b)=>
1t.jsx("div",{className:`inline-block h-2 w-2 cursor-pointer ${b===l?"bg-sp-neutral-900":"bg-sp-neutral-300"} mr-2 rounded-full`,onClick:()=>o(b)},b));return t.jsxs("div",{className:"",children:[n.map((r,b)=>t.jsx("div",{children:b===l?t.jsxs("div",{className:"flex flex-row flex-wrap items-center",children:[t.jsxs("div",{className:"w-4/5 flex-initial",children:[t.jsxs("h3",{className:"text-sp-neutral-900 text-lg font-medium",children:[t.jsx("b",{children:"Test: "}),t.jsx("a",{href:`/${r.account_slug}/testing/results/${r.test_id}/`,className:"text-sp-primary-800",children:r.name})]}),t.jsx("div",{className:"my-5 flex-auto",children:t.jsx(he,{data:r.seo_result,id:r.test_id,hideTitle:!0},r.test_id)})]}),t.jsxs("div",{className:"flex w-1/5 flex-initial flex-col pl-8",children:[t.jsxs("span",{className:"mb-5",children:[t.jsx("h4",{className:"text-sp-neutral-500 text-sm",children:"Uplift"}),t.jsx("p",{className:"text-sp-neutral-900 text-3xl",children:r.seo_result.observed_percentage_change?`${r.seo_result.observed_percentage_change} %`:"No data"})]}),t.jsx("h4",{className:"text-sp-neutral-500 text-sm",children:r.seo_result.won_sessions?"Won Sessions":"Rescued Sessions"}),t.jsxs("p",{className:"text-sp-neutral-900 text-3xl",children:[r.seo_result.won_sessions?r.seo_result.won_sessions:r.seo_result.rescued_sessions," ",t.jsx("span",{className:"text-sp-neutral-900 text-sm",children:"daily"})]})]})]}):null},b)),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(V.Ghost,{size:"md",iconName:"arrowBackward",onClick:h}),t.jsx("div",{children:m}),t.jsx(V.Ghost,{size:"md",iconName:"arrowForward",onClick:s})]})]})},Me=({data:n})=>{const{most_recent_significant_experiments:l}=n;let o,_;return l.length===0?(o="",_=t.jsx("div",{className:"h-full w-full items-center justify-center",children:t.jsx("p",{children:"No recent significant experiments found."})})):l.length>=1&&(l.map(s=>{o=s.account_name}),_=t.jsx(Ie,{slides:l})),t.jsxs(W,{className:"w-full flex-initial md:w-3/5",children:[t.jsx("div",{className:"bg-sp-success-400 h-2 rounded-t-lg"}),t.jsx(N,{children:t.jsxs(N.Content,{children:[t.jsx(N.Title,{children:"Most recent significant experiment results"}),t.jsx(N.Description,{children:o})]})}),t.jsx(H,{classes:"h-max",children:_})]})},Oe=({clientSlug:n,accounts:l})=>{const[o,_]=v.useState({account_slug:"",start_date_gte:L(k(3))}),{data:s,isPending:h}=S({queryKey:["clientsSummary",o],queryFn:async()=>await oe(`/api/webapp/client_dashboard/experiments_summary/cl-${n}/`,o)}),m=(d,x)=>{_({...o,[d]:x})},r=s&&s.completed_experiments_summary.number+s.running_experiments_summary.number,b=[{name:"Last 3 months",value:L(k(3))},{name:"Last 6 months",value:L(k(6))},{name:"Last 12 months",value:L(k(12))},{name:"Last 24 months",value:L(k(24))},{name:"All time",value:""}];return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-8",children:[t.jsxs(j,{label:"Site Name",onChangeFunction:m,onChangeParameters:["account_slug"],value:o.account_slug,children:[t.jsx("option",{value:"",children:"All"}),l.map(({name:d,slug:x},u)=>t.jsx("option",{value:x,children:d},`${x}-${u}`))]}),t.jsx(j,{label:"Time",onChangeFunction:m,onChangeParameters:["start_date_gte"],value:o.start_date_gte,children:b.map(({name:d,value:x},u)=>t.jsx("option",{value:x,children:d},`${x}-${u}`))})]}),t.jsxs(q.Group,{children:[t.jsx(q,{loading:h,type:"simple",title:"Total Won Sessions",value:s&&M(s.total_won_sessions),infoTooltip:'Aggregated across all tests marked as "positive" by the user, this is the estimated organic sessions won per day, on average, had those tests been rolled out globally.',pill:t.jsx(I,{colour:"green",text:"daily"})}),t.jsx(q,{loading:h,type:"simple",title:"Total Rescued Sessions",value:s&&M(s.total_rescued_sessions),infoTooltip:'Aggregated across all tests marked as "negative," this is the estimated number of sessions lost per day on average, had those tests been rolled out globally. The absolute value is taken to
1show how many sessions have been rescued by not rolling out negative changes.',pill:t.jsx(I,{colour:"green",text:"daily"})}),t.jsx(q,{loading:h,type:"simple",title:"Completed Tests",value:s&&M(s.completed_experiments_summary.number),pill:t.jsx(I,{colour:"green",text:`Out of ${r}`})}),t.jsx(q,{loading:h,type:"simple",title:"Running Tests",value:s&&M(s.running_experiments_summary.number),pill:t.jsx(I,{colour:"green",text:`Out of ${r}`})})]}),t.jsxs("div",{className:"flex w-auto flex-col gap-6 md:flex-row ",children:[s&&t.jsx(Me,{data:s}),t.jsxs(W,{className:"w-full flex-initial md:w-2/5",children:[t.jsx("div",{className:"bg-sp-primary-400 h-2 rounded-t-lg"}),t.jsx(N,{children:t.jsxs(N.Content,{children:[t.jsx(N.Title,{children:"Completed Tests Summary"}),t.jsx(N.Description,{children:o.start_date_gte===""?"All Time":`From ${o.start_date_gte}`})]})}),t.jsx(H,{classes:"grow",children:s&&t.jsx(ge,{data:s})}),t.jsx("div",{className:"bg-sp-neutral-50 rounded-b-lg p-6",children:t.jsxs("p",{children:[t.jsxs("span",{className:"font-bold",children:[s&&s.running_experiments_summary.number_with_deploy_recommendation," ","of ",s&&s.running_experiments_summary.number," "]}),"running tests are predicted to have a",t.jsx("span",{className:"text-sp-success-500 font-bold",children:" positive "}),"outcome if rolled out"]})})]})]}),s&&t.jsx(Le,{data:s,start_date_gte:o.start_date_gte})]})},$e=n=>{const l=de("client-overview-dashboard-react-target","available-accounts-b64",null),o=new URLSearchParams(n.location.search).get("tab"),_=new URLSearchParams(n.location.search).get("site"),{clientSlug:s}=me(),{queryKey:h,queryFn:m,...r}=X(s,"running"),{data:b}=S({queryKey:h,queryFn:m,...r}),{queryKey:d,queryFn:x,...u}=X(s,"completed"),{data:c}=S({queryKey:d,queryFn:x,...u}),f=b?.results||[],y=c?.results||[];return t.jsxs("section",{className:"py-4",children:[t.jsx("h2",{className:"text-sp-neutral mb-8 font-medium",children:"Customer Dashboard"}),t.jsxs(pe,{fullWidth:!0,size:"sm",route:`cl-${s}/dashboard/`,linked:"rr",defaultTab:o??"",children:[t.jsx(O,{label:"summary",tabName:"Summary",trackClick:()=>D(s,"Experiment Overview Clicked",{tab:"Summary"}),children:t.jsx(Oe,{clientSlug:s,accounts:l})}),t.jsx(O,{label:"running-experiments",tabName:"Running Experiments",trackClick:()=>D(s,"Experiment Overview Clicked",{tab:"Running Experiments"}),children:t.jsx(qe,{clientSlug:s,initialAccountSlug:_,accounts:l,tags:f})}),t.jsx(O,{label:"completed-experiments",tabName:"Completed Experiments",trackClick:()=>D(s,"Experiment Overview Clicked",{tab:"Completed Experiments"}),children:t.jsx(Pe,{clientSlug:s,accounts:l,tags:y})}),t.jsx(O,{label:"export-data",tabName:"Export Data",trackClick:()=>D(s,"Experiment Overview Clicked",{tab:"Export Data"}),children:t.jsx(Ae,{clientSlug:s,accounts:l})})]}),t.jsxs("p",{className:"my-4",children:["For more information on these metrics, please see the"," ",t.jsx("a",{href:"/docs/searchpilot/overview-dashboard",target:"_blank",className:"text-sp-primary underline",children:"documentation"}),"."]})]})},Ue=()=>t.jsx(ce,{children:t.jsx(ue,{path:"/cl-:clientSlug/dashboard/",render:n=>t.jsx($e,{...n})})}),Ze=()=>{const n=document.getElementById("client-overview-dashboard-react-target");return n?_e.createPortal(t.jsx(Ue,{}),n):null};export{Ze as default}; 2//# sourceMappingURL=index-BaK9doOX.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.