1import{j as e}from"./vendor-query-BBe9Uaw0.js";import{r as N}from"./vendor-react-62vuNXVr.js";import{g as k,e as K}from"./Analytics-BbSpdTDc.js";import{E as M}from"./eye-Crx7XhJ7.js";import{M as z}from"./mouse-pointer-DtjCxemE.js";import{y as I}from"./index-BXxlNWgv.js";import{D as V,R as C,B as U,d as w,X as S,Y as R,T as _,g as A,f as B}from"./ComposedChart-BJFeYPDs.js";import{L as P}from"./Legend-ChONakfF.js";import{L as O}from"./LineChart-C1Knf6vW.js";import{P as W}from"./percent-CSZYcTOu.js";import"./globe-BjlqjRR9.js";import"./file-text-BG1Ad3aF.js";import"./send-DY0bEqDa.js";import"./activity-ZpbCPTT-.js";import"./cpu-DVppUq4w.js";import"./user-check-D-N1JTXO.js";import"./chart-column-C10Vm6hA.js";import"./vendor-ui-BgyuxuNv.js";import"./calendar-HLwCNsJd.js";import"./trending-down-DuJEsAFI.js";import"./info-D7lDt-Pu.js";import"./users-Cb1ukrk8.js";import"./refresh-cw-CGXmcrtG.js";import"./useAdminAuth-CS_HwgCB.js";import"./shield-check-DSUzDoJe.js";import"./vendor-supabase-XMQjZQ6V.js";import"./vendor-zustand-CmnBNWkc.js";const X=[{param:"0-20",label:"ÎÏÏ -20%",color:"#0ea5e9"},{param:"21-30",label:"ÎÏÏ -30%",color:"#8b5cf6"},{param:"31-50",label:"ÎÏÏ -50%",color:"#f43f5e"}];function v(a){const s=a.payload;return s&&(s.discount_bucket||s.discount_bucket_origin)||null}function T(a){var n;const s=a.payload;if(!s)return 0;const r=((n=s==null?void 0:s.ecommerce)==null?void 0:n.value)||(s==null?void 0:s.price)||0;return typeof r=="number"?r:parseFloat(String(r))||0}function Y(a){var r,n,y;const s=a.payload;return s&&((s==null?void 0:s.item_name)||((y=(n=(r=s==null?void 0:s.ecommerce)==null?void 0:r.items)==null?void 0:n[0])==null?void 0:y.item_name))||"Unknown"}function f({label:a,value:s,icon:r,color:n}){return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-4 flex items-center gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${n}`,children:e.jsx(r,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-500 font-medium",children:a}),e.jsx("p",{className:"text-lg font-bold text-gray-900",children:s})]})]})}function Ne({events:a,granularity:s}){const r=N.useMemo(()=>{const t=a.filter(c=>c.event_type==="discount_banner_impression"),o=a.filter(c=>c.event_type==="discount_banner_click"),m=a.filter(c=>c.event_type==="discount_atc");return a.filter(c=>c.event_type==="begin_checkout"),X.map(c=>{const p=t.filter(l=>v(l)===c.param).length,h=o.filter(l=>v(l)===c.param).length,i=m.filter(l=>v(l)===c.param),d=i.length,g=i.reduce((l,x)=>l+T(x),0),u=p>0?h/p*100:0,L=h>0?d/h*100:0,E=d>0?g/d:0,j=new Map;for(const l of i){const x=Y(l),b=j.get(x)||{name:x,count:0,revenue:0};b.count++,b.revenue+=T(l),j.set(x,b)}const G=Array.from(j.values()).sort((l,x)=>x.revenue-l.revenue).slice(0,10);return{...c,impressions:p,clicks:h,atc:d,revenue:g,cr:u,atcRate:L,aov:E,topProducts:G}})},[a]),n=N.useMemo(()=>({impressions:r.reduce((t,o)=>t+o.impressions,0),clicks:r.reduce((t,o)=>t+o.clicks,0),atc:r.reduce((t,o)=>t+o.atc,0),revenue:r.reduce((t,o)=>t+o.revenue,0)}),[r]),y=N.useMemo(()=>{const t=a.filter(i=>i.event_type==="discount_banner_click"),o=a.filter(i=>i.event_type==="discount_atc"),m=k(t,s),c=k(o,s),p=new Set([...m.map(i=>i.date),...c.map(i=>i.date)]);return Array.from(p).sort().map(i=>{var d,g;return{date:i,clicks:((d=m.find(u=>u.date===i))==null?void 0:d.count)||0,atc:((g=c.find(u=>u.date===i))==null?void 0:g.count)||0}})},[a,s]),F=r.map(t=>({name:t.label,Clicks:t.clicks,"Add to Cart":t.atc,"Revenue (â¬)":Math.round(t.revenue*100)/100})),D=()=>{K(r.map(t=>({Bucket:t.label,Impressions:t.impressions,Clicks:t.clicks,ATC:t.atc,Revenue:t.revenue.toFixed(2),"CR%":t.cr.toFixed(1),"ATC Rate%":t.atcRate.toFixed(1),AOV:t.aov.toFixed(2)})),"discount-performance")};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900",children:"Discount Banner Performance"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Full funnel: Impression â Click â Add to Cart"})]}),e.jsx("button",{onClick:D,className:"px-3 py-1.5 rounded-lg text-xs font-medium bg-gray-100 text-gray-700 hover:bg-gray-200",children:"Export CSV"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(f,{label:"Impressions",value:n.impressions.toLocaleStr
1ing("el-GR"),icon:M,color:"bg-blue-500"}),e.jsx(f,{label:"Clicks",value:n.clicks.toLocaleString("el-GR"),icon:z,color:"bg-violet-500"}),e.jsx(f,{label:"Add to Cart",value:n.atc.toLocaleString("el-GR"),icon:I,color:"bg-emerald-500"}),e.jsx(f,{label:"Revenue",value:`â¬${n.revenue.toFixed(2)}`,icon:V,color:"bg-rose-500"})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-gray-100",children:e.jsx("h3",{className:"text-sm font-bold text-gray-800",children:"Performance by Bucket"})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-100 bg-gray-50",children:[e.jsx("th",{className:"text-left px-4 py-2.5 font-semibold text-gray-600",children:"Bucket"}),e.jsx("th",{className:"text-right px-4 py-2.5 font-semibold text-gray-600",children:"Impressions"}),e.jsx("th",{className:"text-right px-4 py-2.5 font-semibold text-gray-600",children:"Clicks"}),e.jsx("th",{className:"text-right px-4 py-2.5 font-semibold text-gray-600",children:"CTR"}),e.jsx("th",{className:"text-right px-4 py-2.5 font-semibold text-gray-600",children:"ATC"}),e.jsx("th",{className:"text-right px-4 py-2.5 font-semibold text-gray-600",children:"ATC Rate"}),e.jsx("th",{className:"text-right px-4 py-2.5 font-semibold text-gray-600",children:"Revenue"}),e.jsx("th",{className:"text-right px-4 py-2.5 font-semibold text-gray-600",children:"AOV"})]})}),e.jsx("tbody",{children:r.map(t=>e.jsxs("tr",{className:"border-b border-gray-50 hover:bg-gray-50/50",children:[e.jsx("td",{className:"px-4 py-2.5 font-medium",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:t.color}}),t.label]})}),e.jsx("td",{className:"text-right px-4 py-2.5 text-gray-700",children:t.impressions.toLocaleString("el-GR")}),e.jsx("td",{className:"text-right px-4 py-2.5 text-gray-700",children:t.clicks.toLocaleString("el-GR")}),e.jsxs("td",{className:"text-right px-4 py-2.5 text-gray-700",children:[t.cr.toFixed(1),"%"]}),e.jsx("td",{className:"text-right px-4 py-2.5 text-gray-700",children:t.atc.toLocaleString("el-GR")}),e.jsxs("td",{className:"text-right px-4 py-2.5 text-gray-700",children:[t.atcRate.toFixed(1),"%"]}),e.jsxs("td",{className:"text-right px-4 py-2.5 font-semibold text-gray-900",children:["â¬",t.revenue.toFixed(2)]}),e.jsxs("td",{className:"text-right px-4 py-2.5 text-gray-700",children:["â¬",t.aov.toFixed(2)]})]},t.param))})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-4",children:[e.jsx("h3",{className:"text-sm font-bold text-gray-800 mb-3",children:"Bucket Comparison"}),e.jsx(C,{width:"100%",height:260,children:e.jsxs(U,{data:F,barGap:4,children:[e.jsx(w,{strokeDasharray:"3 3",stroke:"#f0f0f0"}),e.jsx(S,{dataKey:"name",tick:{fontSize:11}}),e.jsx(R,{tick:{fontSize:11}}),e.jsx(_,{}),e.jsx(P,{wrapperStyle:{fontSize:11}}),e.jsx(A,{dataKey:"Clicks",fill:"#8b5cf6",radius:[4,4,0,0]}),e.jsx(A,{dataKey:"Add to Cart",fill:"#10b981",radius:[4,4,0,0]})]})})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-4",children:[e.jsx("h3",{className:"text-sm font-bold text-gray-800 mb-3",children:"Clicks vs ATC Trend"}),e.jsx(C,{width:"100%",height:260,children:e.jsxs(O,{data:y,children:[e.jsx(w,{strokeDasharray:"3 3",stroke:"#f0f0f0"}),e.jsx(S,{dataKey:"date",tick:{fontSize:10}}),e.jsx(R,{tick:{fontSize:11}}),e.jsx(_,{}),e.jsx(P,{wrapperStyle:{fontSize:11}}),e.jsx(B,{type:"monotone",dataKey:"clicks",stroke:"#8b5cf6",strokeWidth:2,dot:!1}),e.jsx(B,{type:"monotone",dataKey:"atc",stroke:"#10b981",strokeWidth:2,dot:!1})]})})]})]}),r.filter(t=>t.topProducts.length>0).map(t=>e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-gray-100 flex items-center gap-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:t.color}}),e.jsxs("h3",{className:"text-sm font-bold text-gray-800",children:["Top Products â ",t.label]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-100 bg-gray-50",children:[e.jsx("th",{className:"text-left px-4 py-2 font-semibold text-gray-600",children:"#"}),e.jsx("th",{className:"text-left px-4 py-2 font-semibold text-gray-600",children:"Product"}),e.jsx("th",{className:"text-right px-4 py-2 font-semibold text-gray-600",children:"ATC Count"}),e.jsx("th",{className:"text-right px-4 py-2 font-semibold text-gray-600",children:"Revenue"})]})}),e.jsx("tbody",{children:t.topProducts.map((o,m)=>e.jsxs("tr",{className:"border-b border-gray-50 hover:bg-gray-50/50",children:[e.jsx("td",{className:"px-4 py-2 text-gray-400",children:m+1}),e.jsx("td",{className:"px-4 py-2 font-medium text-gray-800 max-w-[250px] truncate",children:o.name}),e.jsx("td",{className:"text-right px-4 py-2 text-gray-700",children:o.count}),e.jsxs("td",{className:"text-right px-4 py-2 font-semibold text-gray-900",children:["â¬",o.revenue.toFixed(2)]})]},o.name))})]})})]},t.param)),n.impressions===0&&n.clicks===0&&e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-8 text-center",children:[e.jsx(W,{className:"w-10 h-10 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Îεν Ï
ÏάÏÏοÏ
ν δεδομÎÎ
1½Î± ακÏμα."}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Τα events θα εμÏανιÏÏοÏν μÏÎ»Î¹Ï ÏÏήÏÏÎµÏ Î±Î»Î»Î·Î»ÎµÏιδÏάÏοÏ
ν με Ïα discount banners."})]})]})}export{Ne 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.