1import{j as e,r as I}from"./vendor-radix-_DSeAjJN.js";import{A as $}from"./AppNav-CqPkE87Z.js";import{b as M}from"./SettingsList-CSmNu0eG.js";import{P as B}from"./ProGate-F0bjkPPV.js";import{a as x,P as O}from"./index-kCmOl8t5.js";import{u as U,r as H,R as A,a as E,c as V,b as k,d as G,m as z,f as h,t as Z,e as q,s as K,S as u}from"./ResultsParts-q_L4f44A.js";import{ah as X,ai as Y,u as J,a9 as Q,A as ee,a7 as se}from"./vendor-icons-BrMlqT7e.js";import{R as te,A as ae,C as le,X as re,Y as ne,T as ie,a as de}from"./vendor-recharts-CyfsaX7h.js";import"./vendor-supabase-CJeKTvkw.js";const T={pending:96.5,completed:213.75},D="M0,70 C18,66 26,52 44,55 S72,40 90,44 S118,24 136,30 S164,36 182,18 S206,12 220,6",ce=[{name:"Produto de exemplo A",meta:"12 · 14",value:58.2},{name:"Produto de exemplo B",meta:"8 · 9",value:41.9},{name:"Produto de exemplo C",meta:"5 · 5",value:23.4}],oe=[{tone:"bg-warning",value:96.5},{tone:"bg-success",value:213.75},{tone:"bg-muted-foreground",value:12.3}],g="hsl(var(--primary))";function me(s,l){return new Intl.DateTimeFormat(l,{day:"2-digit",month:"2-digit",timeZone:"UTC"}).format(new Date(`${s}T00:00:00Z`))}function Ce(){var _,S,P,R,C;const{t:s,i18n:l}=x("app"),a=(_=l.resolvedLanguage)!=null&&_.startsWith("en")?"en-US":"pt-BR",{data:t,error:i,loading:r,refreshing:d,refresh:c,reload:j}=U("page"),n=H(t,i,r),o=(t==null?void 0:t.month)??null,f=n==="no_access"||n==="invalid_credentials",W=!!o&&(n==="ok"||n==="rate_limited"||n==="error"||f),y=d||r,m=(t==null?void 0:t.is_premium)===!0,p=m?(t==null?void 0:t.detail)??null:null,w=f?e.jsx("div",{className:"pl-dashboard-card rounded-2xl p-5 md:p-6 mb-4 md:mb-6",children:e.jsx(A,{kind:n,onRetry:c,busy:y,checkedAt:E((S=t==null?void 0:t.sync)==null?void 0:S.last_synced_at,Date.now(),a)})}):null;let b;if(n==="loading"||n==="syncing")b=e.jsx(ge,{syncing:n==="syncing"});else if(n==="not_connected")b=e.jsx("div",{className:"pl-dashboard-card pl-dashboard-card-featured rounded-2xl p-5 md:p-6",children:e.jsx(G,{})});else if(!W||!o)b=w??e.jsx("div",{className:"pl-dashboard-card rounded-2xl p-5 md:p-6",children:e.jsx(A,{kind:n==="rate_limited"?"rate_limited":"failed",onRetry:t!=null&&t.connected?c:j,busy:y})});else{const L=E((P=t==null?void 0:t.sync)==null?void 0:P.last_success_at,Date.now(),a);b=e.jsxs(e.Fragment,{children:[w,e.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:L?s("results.updated",{when:L}):s("results.neverUpdated")}),!f&&e.jsx(V,{onClick:c,busy:y})]}),(n==="rate_limited"||n==="error"||((R=t==null?void 0:t.sync)==null?void 0:R.partial))&&e.jsxs("div",{className:"-mt-2 mb-4",children:[n==="rate_limited"&&e.jsx(k,{children:s("results.hint.rateLimited")}),n==="error"&&e.jsx(k,{children:s("results.hint.error")}),((C=t==null?void 0:t.sync)==null?void 0:C.partial)&&e.jsx(k,{children:s("results.hint.partial")})]}),e.jsx(ue,{month:o,locale:a}),e.jsx(N,{title:s("results.split.title"),subtitle:s("results.split.subtitle"),locked:!m,className:"mb-4 md:mb-6",children:m?e.jsx(F,{pending:o.pending_total,completed:o.completed_total,locale:a}):e.jsx(v,{hint:s("results.pro.hint.split"),children:e.jsx(F,{pending:T.pending,completed:T.completed,locale:a})})}),e.jsxs("div",{className:"grid lg:grid-cols-5 gap-4 md:gap-6 mb-4 md:mb-6",children:[e.jsx(N,{title:s("results.chart.title"),subtitle:s("results.chart.subtitle"),locked:!m,className:"lg:col-span-3",children:m?p&&p.days.length>0?e.jsx(xe,{detail:p,locale:a}):e.jsx("p",{className:"text-sm text-muted-foreground",children:s("results.chart.empty")}):e.jsx(v,{hint:s("results.pro.hint.chart"),children:e.jsx(fe,{})})}),e.jsx(N,{title:s("results.status.title"),subtitle:s("results.status.subtitle"),locked:!m,className:"lg:col-span-2",children:m?p?e.jsx(pe,{detail:p,locale:a}):e.jsx("p",{className:"text-sm text-muted-foreground",children:s("results.chart.empty")}):e.jsx(v,{hint:s("results.pro.hint.status"),children:e.jsx(je,{locale:a})})})]}),e.jsx(N,{title:s("results.items.title"),subtitle:s("results.items.subtitle"),locked:!m,className:"mb-6",children:m?p&&p.items.length>0?e.jsx(he,{items:p.items,locale:a}):e.jsx("p",{className:"text-sm text-muted-foreground",children:s("results.items.empty")}):e.jsx(v,{hint:s("results.pro.hint.items"),children:e.jsx(be,{locale:a})})}),e.jsxs("div",{className:"space-y-1.5 px-1 text-xs text-muted-foreground",children:[e.jsx("p",{children:s("results.footnote.estimate")}),e.jsx("p",{children:s("results.footnote.scope")}),e.jsx("p",{children:s("results.footnote.clicks")})]})]})}return e.jsxs("div",{className:"min-h-screen pl-dashboard-canvas text-foreground",children:[e.jsx($,{}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-6 md:py-10",children:[e.jsx(M,{backTo:"/dashboard",backLabel:s("results.back"),title:s("results.title"),intro:s("results.subtitle")}),b]})]})}function N({title:s,subtitle:l,locked:a,className:t="",children:i}){const{t:r}=x("app");return e.jsxs("section",{className:`pl-dashboard-card rounded-2xl p-5 md:p-6 ${t}`,children:[e.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"font-semibold text-base md:text-lg",children:s}),l&&e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:l})]}),a&&e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-primary/30 bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary",children:[e.jsx(O,{className:"w-3 h-3"}),r("results.pro.badge")]})]}),i]})}
1function v({hint:s,children:l}){const{t:a}=x("app");return e.jsx(B,{isPremium:!1,label:a("results.pro.lockedLabel"),className:"block rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:e.jsxs("div",{className:"relative overflow-hidden rounded-xl",children:[e.jsx("div",{"aria-hidden":!0,className:"select-none opacity-60 blur-[5px]",children:l}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background/25 p-4 text-center",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-primary/30 bg-background/85 px-3 py-1 text-xs font-semibold",children:[e.jsx(Q,{className:"w-3.5 h-3.5 text-primary","aria-hidden":!0}),a("results.pro.locked")]}),e.jsx("p",{className:"max-w-xs text-sm font-medium leading-snug",children:s}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold text-primary",children:[a("results.pro.cta"),e.jsx(ee,{className:"w-3.5 h-3.5","aria-hidden":!0})]})]})]})})}function ue({month:s,locale:l}){const{t:a}=x("app"),t=z(s.from,l),i=s.sales_count===0&&s.commission_total===0;return e.jsx("section",{className:"pl-dashboard-card pl-dashboard-card-featured rounded-2xl p-5 md:p-6 mb-4 md:mb-6",children:e.jsxs("div",{className:"grid gap-4 sm:grid-cols-[1fr_auto] sm:items-end",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-xs font-medium text-primary",children:[e.jsx(X,{className:"w-4 h-4","aria-hidden":!0}),t?a("results.month.commission",{month:t}):a("results.month.commissionFallback")]}),e.jsx("p",{className:"mt-2 text-4xl md:text-5xl font-bold tracking-tight tabular-nums text-foreground",children:h(s.commission_total,l)}),i&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:a("dashboard.results.emptyMonthDesc")})]}),e.jsxs("div",{className:"border-t border-border/60 pt-4 sm:border-t-0 sm:border-l sm:pt-0 sm:pl-6 sm:text-right",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:t?a("results.month.sales",{month:t}):a("results.month.salesFallback")}),e.jsx("p",{className:"mt-1 text-2xl md:text-3xl font-bold tabular-nums",children:s.sales_count.toLocaleString(l)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("results.month.salesCaption")})]})]})})}function F({pending:s,completed:l,locale:a}){const{t}=x("app"),i=[{key:"pending",Icon:Y,tone:"text-warning",label:t("results.split.pending"),desc:t("results.split.pendingDesc"),value:s},{key:"completed",Icon:J,tone:"text-success",label:t("results.split.completed"),desc:t("results.split.completedDesc"),value:l}];return e.jsx("div",{className:"grid grid-cols-2 gap-3",children:i.map(({key:r,Icon:d,tone:c,label:j,desc:n,value:o})=>e.jsxs("div",{className:"pl-dashboard-panel rounded-xl p-3 md:p-4",children:[e.jsxs("p",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[e.jsx(d,{className:`w-3.5 h-3.5 shrink-0 ${c}`,"aria-hidden":!0}),j]}),e.jsx("p",{className:"mt-1.5 text-lg md:text-2xl font-bold tracking-tight tabular-nums",children:o==null?"â":h(o,a)}),e.jsx("p",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:n})]},r))})}function xe({detail:s,locale:l}){const{t:a}=x("app"),t=I.useMemo(()=>{var n,o;const r=Z(),d=(n=s.days[s.days.length-1])==null?void 0:n.date,c=d&&d>r?d:r,j=s.window_from||((o=s.days[0])==null?void 0:o.date)||c;return q(s.days,j,c).map(f=>({...f,label:me(f.date,l)}))},[s,l]),i=I.useMemo(()=>new Intl.NumberFormat(l,{notation:"compact",maximumFractionDigits:1}),[l]);return e.jsx("div",{className:"pl-dashboard-panel rounded-xl p-3 md:p-4",children:e.jsx("div",{className:"h-48 md:h-56 w-full",children:e.jsx(te,{width:"100%",height:"100%",children:e.jsxs(ae,{data:t,margin:{top:8,right:8,left:-12,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"resultsFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:g,stopOpacity:.45}),e.jsx("stop",{offset:"100%",stopColor:g,stopOpacity:0})]})}),e.jsx(le,{vertical:!1,stroke:"hsl(var(--border))",strokeOpacity:.4,strokeDasharray:"3 3"}
1),e.jsx(re,{dataKey:"label",tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:24,tick:{fontSize:10,fill:"hsl(var(--muted-foreground))"}}),e.jsx(ne,{width:36,tickLine:!1,axisLine:!1,tickFormatter:r=>i.format(r),tick:{fontSize:10,fill:"hsl(var(--muted-foreground))"}}),e.jsx(ie,{cursor:{stroke:g,strokeOpacity:.5,strokeDasharray:"4 4"},content:({active:r,payload:d})=>{if(!r||!(d!=null&&d.length))return null;const c=d[0].payload;return e.jsxs("div",{className:"pl-dashboard-card rounded-lg px-3 py-2 shadow-xl",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground",children:c.label}),e.jsx("p",{className:"text-sm font-semibold text-foreground",children:h(c.commission,l)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("results.items.sales",{count:c.sales})})]})}}),e.jsx(de,{type:"monotone",dataKey:"commission",stroke:g,strokeWidth:2,fill:"url(#resultsFill)",dot:!1,activeDot:{r:4,fill:g,stroke:"hsl(var(--background))",strokeWidth:2},animationDuration:500})]})})})})}function pe({detail:s,locale:l}){const{t:a}=x("app"),t=[{key:"pending",tone:"bg-warning",label:a("results.status.pending"),bucket:s.by_status.pending},{key:"completed",tone:"bg-success",label:a("results.status.completed"),bucket:s.by_status.completed},{key:"cancelled",tone:"bg-muted-foreground",label:a("results.status.cancelled"),bucket:s.by_status.cancelled}],i=t.reduce((r,d)=>r+Math.max(0,d.bucket.sales),0);return e.jsxs("div",{children:[i>0&&e.jsx("div",{className:"pl-dashboard-panel mb-5 flex h-3 w-full overflow-hidden rounded-full","aria-hidden":!0,children:t.map(r=>r.bucket.sales>0?e.jsx("div",{className:`h-full ${r.tone}`,style:{width:`${r.bucket.sales/i*100}%`}},r.key):null)}),e.jsx("ul",{className:"space-y-3",children:t.map(r=>e.jsxs("li",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 shrink-0 rounded-full ${r.tone}`,"aria-hidden":!0}),e.jsx("span",{className:"truncate text-sm font-medium",children:r.label})]}),e.jsxs("span",{className:"shrink-0 text-right",children:[e.jsx("span",{className:`block text-sm font-semibold tabular-nums ${r.key==="cancelled"?"text-muted-foreground line-through":""}`,children:h(r.bucket.commission,l)}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:a("results.status.sales",{count:r.bucket.sales})})]})]},r.key))}),e.jsx("p",{className:"mt-4 text-xs text-muted-foreground",children:a("results.status.cancelledNote")})]})}function he({items:s,locale:l}){const{t:a}=x("app");return e.jsx("ol",{className:"divide-y divide-border/60",children:s.map((t,i)=>{const r=K(t.image_url);return e.jsxs("li",{className:"flex items-start gap-3 py-3 first:pt-0 last:pb-0",children:[e.jsx("span",{className:"mt-3 w-4 shrink-0 text-center text-xs font-semibold tabular-nums text-muted-foreground",children:i+1}),r?e.jsx("img",{src:r,alt:"",loading:"lazy",referrerPolicy:"no-referrer",className:"h-10 w-10 shrink-0 rounded-lg bg-muted object-cover"}):e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted","aria-hidden":!0,children:e.jsx(se,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"line-clamp-2 text-sm leading-snug",children:t.item_name??a("results.items.unnamed")}),t.shop_name&&e.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:t.shop_name}),e.jsxs("div",{className:"mt-1 flex items-baseline justify-between gap-3",children:[e.jsxs("span",{className:"min-w-0 text-xs text-muted-foreground",children:[a("results.items.sales",{count:t.sales_count})," · ",a("results.items.qty",{count:t.qty})]}),e.jsx("span",{className:"shrink-0 text-sm font-semibold tabular-nums",children:h(t.commission_total,l)})]})]})]},t.item_id)})})}function fe(){return e.jsx("div",{className:"pl-dashboard-panel rounded-xl p-3 md:p-4",children:e.jsxs("svg",{viewBox:"0 0 220 80",preserveAspectRatio:"none",className:"h-40 md:h-48 w-full",children:[e.jsx("path",{d:`${D} L220,80 L0,80 Z`,fill:"hsl(var(--primary) / 0.25)"}),e.jsx("path",{d:D,fill:"none",stroke:"hsl(var(--primary))",strokeWidth:2,vectorEffect:"non-scaling-stroke"})]})})}function je({locale:s}){return e.jsxs("div",{children:[e.jsxs("div",{className:"pl-dashboard-panel mb-5 flex h-3 w-full overflow-hidden rounded-full",children:[e.jsx("div",{className:"h-full w-[30%] bg-warning"}),e.jsx("div",{className:"h-full w-[62%] bg-success"}),e.jsx("div",{className:"h-full w-[8%] bg-muted-foreground"})]}),e.jsx("ul",{className:"space-y-3",children:oe.map((l,a)=>e.jsxs("li",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${l.tone}`}),e.jsx("span",{className:"h-3 w-20 rounded bg-muted"})]}),e.jsx("span",{className:"text-sm font-semibold tabular-nums",children:h(l.value,s)})]},a))})]})}function be({locale:s}){return e.jsx("ol",{className:"divide-y divide-border/60",children:ce.map((l,a)=>e.jsxs("li",{className:"flex items-start gap-3 py-3 first:pt-0 last:pb-0",children:[e.jsx("span",{className:"mt-3 w-4 shrink-0 text-center text-xs font-semibold text-muted-foreground",children:a+1}),e.jsx("span",{className:"h-10 w-10 shrink-0 rounded-lg bg-muted"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm",children:l.name}),e.jsxs("div",{className:"mt-1 flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:l.meta}),e.jsx("span",{className:"shrink-0 text-sm font-semibold tabular-nums",children:h(l.value,s)})]})]})]},l.name))})}function ge({syncing:s}){const{t:l}=x("app");return e.jsxs("div",{"aria-busy":!0,children:[s&&e.jsx("p",{role:"status",className:"mb-4 text-sm text-muted-foreground",children:l("results.syncing")}
1),e.jsxs("div",{"aria-hidden":!0,children:[e.jsx(u,{className:"mb-4 h-4 w-40"}),e.jsxs("div",{className:"pl-dashboard-card rounded-2xl p-5 md:p-6 mb-4 md:mb-6",children:[e.jsx(u,{className:"h-4 w-48"}),e.jsx(u,{className:"mt-3 h-11 w-56 max-w-full"})]}),e.jsxs("div",{className:"grid lg:grid-cols-5 gap-4 md:gap-6",children:[e.jsxs("div",{className:"pl-dashboard-card rounded-2xl p-5 md:p-6 lg:col-span-3",children:[e.jsx(u,{className:"h-4 w-36"}),e.jsx(u,{className:"mt-4 h-40 w-full"})]}),e.jsxs("div",{className:"pl-dashboard-card rounded-2xl p-5 md:p-6 lg:col-span-2",children:[e.jsx(u,{className:"h-4 w-28"}),e.jsx(u,{className:"mt-4 h-4 w-full"}),e.jsx(u,{className:"mt-3 h-4 w-full"}),e.jsx(u,{className:"mt-3 h-4 w-3/4"})]})]})]})]})}export{Ce 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.