1import{r as l,j as e,F as y,u as v}from"./index-BKInu8Gb.js";import{L as E,G as g}from"./LabShell-CtAzNwn_.js";import{t as F}from"./analyticsLab-BVZhLnw6.js";import{L as C}from"./lock-CE1yfIbJ.js";import{E as D}from"./eye-off-3tLSX1nQ.js";import{E as L}from"./eye-BiS9dtpN.js";/* empty css */import"./arrow-left-0nCR_9p3.js";import"./flask-conical-GIB7Ke0K.js";const w=[{key:"lab_conv_hub_viewed",label:"Hub viewed"},{key:"lab_conv_variant_viewed",label:"Variant viewed"},{key:"lab_conv_quickstart_started",label:"QuickStart started"},{key:"lab_conv_quickstart_completed",label:"QuickStart completed"},{key:"lab_conv_install_snippet_copied",label:"Snippet copied"},{key:"lab_conv_install_verified",label:"Install verified"},{key:"lab_conv_upgrade_prompt_shown",label:"Upgrade prompt shown"},{key:"lab_conv_upgrade_prompt_clicked",label:"Upgrade prompt clicked"}],j=[{id:"7d",label:"7d",days:7},{id:"30d",label:"30d",days:30}];function A({onVerified:o}){const[n,c]=l.useState(""),[a,d]=l.useState(!1),[p,x]=l.useState(!1),u=async i=>{if(i.preventDefault(),!!n.trim()){x(!0);try{const{data:m,error:s}=await y.functions.invoke("verify-admin-password",{body:{password:n}});s||!(m!=null&&m.verified)?v.error("Incorrect password"):o(n)}catch{v.error("Verification failed")}finally{x(!1)}}};return e.jsx("div",{className:"min-h-screen bg-[#0D0A1A] text-white flex items-center justify-center p-4",children:e.jsxs("form",{onSubmit:u,className:"w-full max-w-md rounded-2xl border border-white/[0.08] bg-white/[0.03] backdrop-blur-sm p-6 space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mx-auto h-12 w-12 rounded-xl grid place-items-center mb-3",style:{background:"rgba(124,58,237,0.18)",boxShadow:"0 0 24px rgba(124,58,237,0.4) inset"},children:e.jsx(C,{className:"h-5 w-5 text-[#E9D5FF]"})}),e.jsx("h1",{className:"text-xl font-semibold",children:"Conversion lab funnel"}),e.jsx("p",{className:"mt-1 text-sm text-white/55",children:"Admin password required"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:a?"text":"password",placeholder:"Password",value:n,onChange:i=>c(i.target.value),autoFocus:!0,className:"w-full px-4 py-3 rounded-lg bg-black/40 border border-white/[0.08] text-white text-sm focus:outline-none focus:border-[rgba(124,58,237,0.5)]"}),e.jsx("button",{type:"button",onClick:()=>d(i=>!i),className:"absolute right-3 top-1/2 -translate-y-1/2 text-white/40 hover:text-white","aria-label":"Toggle password visibility",children:a?e.jsx(D,{className:"h-4 w-4"}):e.jsx(L,{className:"h-4 w-4"})})]}),e.jsx("button",{type:"submit",disabled:p,className:"w-full px-4 py-3 rounded-lg text-sm font-medium disabled:opacity-60",style:{background:"linear-gradient(135deg, #7C3AED, #A855F7)",boxShadow:"0 0 24px rgba(124,58,237,0.5)",color:"white"},children:p?"Verifyingâ¦":"Open funnel"})]})})}function P({values:o}){const n=Math.max(1,...o);return e.jsx("div",{className:"flex items-end gap-0.5 h-6",children:o.map((c,a)=>{const d=Math.max(2,c/n*100);return e.jsx("div",{className:"w-1.5 rounded-sm",style:{height:`${d}%`,background:c>0?"linear-gradient(180deg, #7C3AED, #00D4FF)":"rgba(255,255,255,0.06)"},title:`${c} events`},a)})})}function M({password:o}){const[n,c]=l.useState(j[1]),[a,d]=l.useState(null),[p,x]=l.useState(!0),[u,i]=l.useState(null);l.useEffect(()=>{F("lab_conv_funnel_viewed",{range:n.id})},[n.id]),l.useEffect(()=>{let s=!1;return(async()=>{x(!0),i(null);try{const{data:t,error:r}=await y.functions.invoke("get-lab-funnel-counts",{body:{password:o,days:n.days}});if(s)return;if(r)throw r;if(!t||t.error)throw new Error((t==null?void 0:t.error)||"no data");d({counts:t.counts??{},sparklines:t.sparklines??{},cohort:t.cohort??{}})}catch(t){s||i(String((t==null?void 0:t.message)??t))}finally{s||x(!1)}})(),()=>{s=!0}},[n.days,o]);const m=l.useMemo(()=>{const s=(a==null?void 0:a.counts)??{},t=s[w[0].key]??0;let r=t;return w.map((b,N)=>{var f;const h=s[b.key]??0,k=r>0&&N>0?Math.max(0,Math.round((r-h)/r*100)):0,_=t>0?Math.round(h/t*100):0,S={...b,count:h,dropFromPrev:k,pctOfTop:_,spark:((f=a==null?void 0:a.sparklines)==null?void 0:f[b.key])??[]};return r=h,S})},[a]);return e.jsxs(E,{variantId:"funnel",title:"Activation funnel",subtitle:"lab_conv_* events with is_lab=true. Read-only â never affects production funnel reports.",children:[e.jsx("div",{className:"flex items-center justify-end mb-4 gap-1 p-1 rounded-full border border-white/[0.06] bg-white/[0.02] w-fit ml-auto",children:j.map(s=>{const t=s.id===n.id;return e.jsx("button",{onClick:()=>c(s),className:"px-3 py-1 rounded-full text-xs font-medium",style:{background:t?"rgba(124,58,237,0.18)":"transparent",boxShadow:t?"0 0 16px rgba(124,58,237,0.25) inset":"none",color:t?"#E9D5FF":"rgba(255,255,255,0.6)"},children:s.label},s.id)})}),e.jsx(g,{children:u?e.jsxs("div",{className:"py-12 text-center text-sm text-red-300/80",children:["Failed: ",u]}):p?e.jsx("div",{className:"py-12 text-center text-sm text-white/50",children:"Loading funnelâ¦"}):e.jsx("div",{className:"space-y-3",children:m.map((s,t)=>e.jsxs("div",{className:"grid grid-cols-12 gap-3 items-center",children:[e.jsxs("div",{className:"col-span-4 text-sm text-white/80 truncate",children:[e.jsxs("span",{className:"font-mono text-[10px] text-white/30 mr-2",children:["0",t+1]}),s.label]}),e.jsx("div",{className:"col-span-4",children:e.jsx("div",{className:"h-3 rounded-full",style:{background:"rgba(255,255,255,0.04)"},children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${s.pctOfTop}%`,background:"linear-gradient(90deg, #7C3AED, #00D4FF)",boxShadow:"0 0 12px rgba(124,58,237,0.4)"}})})}),e.jsx("div",{className:"col-span-2",children:e.jsx(P,{values:s.spark})}),e.jsx("div",{className:"col-span-1 text-right font-mono text-sm text-white",children:s.count}),e.jsx("div",{className:"col-span-1 text-right",children:t>0&&s.dropFromPrev>0?e.jsxs("span",{className:"text-[10px] text-red-300/80",children:["â",s.dropFromPrev,"%"]}):e.jsx("span",{className:"text-[10px] text-white/30",children:"â"})})]},s.key))})}),e.jsxs(g,{children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-white",children:"Canonical funnel · lab vs control"}),e.jsxs("span",{className:"text-[11px] text-white/40",children:["last ",n.days,"d · lift = (lab â control) / control"]})]}),!(a!=null&&a.cohort)||Object.keys(a.cohort).length===0?e.jsx("div",{className:"text-xs text-white/40 py-6 text-center",children:"No cohort data yet â events will populate after publish."}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"grid grid-cols-12 gap-3 text-[10px] uppercase tracking-[0.14em] text-white/40 pb-1.5 border-b border-white/[0.06]",children:[e.jsx("div",{className:"col-span-5",children:"Event"}),e.jsx("div",{className:"col-span-2 text-right",children:"Lab"}),e.jsx("div",{className:"col-span-2 text-right",children:"Control"}),e.jsx("div",{className:"col-span-2 text-right",children:"Unknown"}),e.jsx("div",{className:"col-span-1 text-right",children:"Lift"})]}),Object.entries(a.cohort).map(([s,t])=>{const r=t.control>0?Math.round((t.lab-t.control)/t.control*100):null;return e.jsxs("div",{className:"grid grid-cols-12 gap-3 items-center py-1 text-sm",children:[e.jsx("div",{className:"col-span-5 text-white/80 truncate font-mono text-[12px]",children:s}),e.jsx("div",{className:"col-span-2 text-right font-mono text-white",children:t.lab}),e.jsx("div",{className:"col-span-2 text-right font-mono text-white/70",children:t.control}),e.jsx("div",{className:"col-span-2 text-right font-mono text-white/40",children:t.unknown}),e.jsx("div",{className:"col-span-1 text-right font-mono text-[12px]",children:r===null?e.jsx("span",{className:"text-white/30",children:"â"}):e.jsxs("span",{style:{color:r>=0?"var(--v2-good)":"var(--v2-bad)"},children:[r>=0?"+":"",r,"%"]})})]},s)})]})]}),e.jsxs("p",{className:"mt-4 text-xs text-white/40",children:["Drop-off is computed stage-over-stage. Sparkline is 7d regardless of range. Counts come from a service-role edge function with server-side ",e.jsx("code",{children:"is_lab=true"})," filter â no client-side cap, no live funnel pollution."]})]})}function Q(){const[o,n]=l.useState(null);return o?e.jsx(M,{password:o}):e.jsx(A,{onVerified:n})}export{Q 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.