1import{r as n,j as e,L as c}from"./react-vendor-N5TEtgU9.js";import{h as K,S as X,H as V,C as m,B as r,t as W,G as J,v as Q,s as x,z as Z}from"./index-CefG7aBd.js";import{B as E}from"./badge-DBhP6oAe.js";import{F as ee}from"./Footer-D-Tp90SM.js";import{S as se}from"./StripeEmbeddedCheckout-DMXYb-y5.js";import{P as te}from"./PayPalCheckoutButton-DjKJwmxn.js";import{S as z,g as L}from"./referral-DdzTCBRb.js";import{R as ae}from"./RedeemPromoCard-mJzFtoP7.js";import{u as re}from"./i18n-vendor-CSxDejkk.js";import{A as ne}from"./arrow-left-BbIDdJmH.js";import{C as F}from"./clock-BmfnXZlW.js";import{P as ie}from"./puzzle-DZJa55G4.js";import{D as ce}from"./download-AhP4lG8J.js";import{C as oe}from"./circle-x-BiGNhhV1.js";import"./query-vendor-qf5k-6U3.js";import"./supabase-vendor-CrWRCqME.js";import"./locale-en-CUyC166T.js";import"./stripe-Bhy7m6z-.js";import"./credit-card-BoNS4EgP.js";import"./landmark-D43Fdqgt.js";import"./input-Bn_y3BjE.js";const f=i=>i?new Date(i).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):"â",y=1e3,Ee=()=>{const{t:i}=re(),{user:a}=K(),[B,g]=n.useState(!0),[s,I]=n.useState(null),[t,R]=n.useState(null),[b,M]=n.useState(0),[k,D]=n.useState(0),[N,h]=n.useState(null),[v,w]=n.useState("card"),[q,S]=n.useState(0);n.useEffect(()=>{(async()=>{var d;if(!a){g(!1);return}g(!0);try{const{data:{session:j}}=await x.auth.getSession();if(!j)return;const _={Authorization:`Bearer ${j.access_token}`},P=new Date,T=`${P.getFullYear()}-${String(P.getMonth()+1).padStart(2,"0")}-01`,[Y,$,H,U]=await Promise.all([x.functions.invoke("check-subscription",{headers:_}),x.functions.invoke("check-extension",{headers:_}),x.from("monthly_usage").select("used_count").eq("user_id",a.id).eq("kind","extension_check").eq("period_month",T).maybeSingle(),x.from("scan_credit_packs").select("credits, credits_used").eq("user_id",a.id).eq("kind","extension_check")]);I(Y.data??null),R($.data??null),M(Number(((d=H.data)==null?void 0:d.used_count)??0)),D((U.data??[]).reduce((G,A)=>G+Math.max(0,A.credits-A.credits_used),0))}catch(j){console.error("access check failed",j)}finally{g(!1)}})()},[a,q]);const u=!!(s!=null&&s.subscribed||s!=null&&s.isPremium),p=(s==null?void 0:s.subscription_end)??(s==null?void 0:s.expiresAt)??(s==null?void 0:s.expires_at)??null,o=!!(t!=null&&t.hasExtension),O=(t==null?void 0:t.expiresAt)??null,C=({active:l,label:d})=>l?e.jsxs(E,{className:"bg-success/15 text-success border-success/30 gap-1",children:[e.jsx(Z,{className:"w-3.5 h-3.5"})," ",d]}):e.jsxs(E,{variant:"outline",className:"text-destructive border-destructive/40 gap-1",children:[e.jsx(oe,{className:"w-3.5 h-3.5"})," ",d]});return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(X,{title:"Your access â Premium & Extension status | ScamsShield",description:"See at a glance whether your Premium plan and browser extension are active, when they expire, and why an extension download may be blocked."}),e.jsx(V,{}),e.jsxs("main",{className:"container max-w-3xl mx-auto px-4 py-10",children:[e.jsxs(c,{to:"/",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(ne,{className:"w-4 h-4"})," Back"]}),e.jsx("h1",{className:"text-3xl font-bold mb-2",children:"Your access"}),e.jsx("p",{className:"text-muted-foreground mb-8",children:"A live overview of what your account currently unlocks."}),a?B?e.jsx("div",{className:"h-24 flex items-center justify-center",children:e.jsx("div",{className:"w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs(m,{className:"p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(W,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold",children:"Premium (app)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Unlimited scans and premium tools on the website."})]})]}),e.jsx(C,{active:u,label:u?"Active":"Not active"})]}),e.jsxs("div",{className:"mt-4 text-sm flex items-center gap-2 text-muted-foreground",children:[e.jsx(F,{className:"w-4 h-4"}),u?p?e.jsxs(e.Fragment,{children:["Renews / expires: ",e.jsx("span",{className:"text-foreground",children:f(p)})]}):e.jsx(e.Fragment,{children:"Lifetime access"}):e.jsxs(e.Fragment,{children:["Expired or never purchased",p?e.jsxs(e.Fragment,{children:[" â ended ",f(p)]}):null]})]}),!u&&e.jsx(r,{asChild:!0,className:"mt-4",size:"sm",children:e.jsx(c,{to:"/pricing",children:"Get Premium"})})]}),e.jsxs(m,{className:"p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ie,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold",children:"Browser extension"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sold separately from Premium â a Premium plan alone does not unlock it."})]})]}),e.jsx(C,{active:o,label:o?"Active":"Blocked"})]}),e.jsxs("div",{className:"mt-4 text-sm flex items-center gap-2 text-muted-foreground",children:[e.jsx(F,{className:"w-4 h-4"}),o?e.jsxs(e.Fragment,{children:["Access until: ",e.jsx("span",{className:"text-foreground",children:f(O)})]}):e.jsxs(e.Fragment,{children:["No active extension plan",t!=null&&t.expiresAt?e.jsxs(e.Fragment,{children:[" â expired ",f(t.expiresAt)]}):null]})]}),!o&&e.jsxs("div",{className:"mt-4 rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm",children:[e.jsx("p",{className:"font-medium text-destructive mb-1",children:"Why the download is blocked"}),e.jsx("p",{className:"text-muted-foreground",children:t!=null&&t.expired?"Your extension plan lapsed. Downloads are verified on our servers, so the package stays locked until the plan is renewed.":"You do not have an active extension plan."})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx(r,{asChild:!0,size:"sm",variant:o?"default":"outline",children:e.jsxs(c,{to:"/extension",children:[e.jsx(ce,{className:"w-4 h-4 mr-1"}),o?"Download extension":"View extension plans"]})}),e.jsx(r,{asChild:!0,size:"sm",variant:"ghost",children:e.jsx(c,{to:"/billing",children:"Manage billing"})})]})]}),e.jsxs(m,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx(J,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold",children:"Extension site checks"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[y.toLocaleStr
1ing()," checks included every month."]})]})]}),e.jsx("div",{className:"h-2 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.min(100,b/y*100)}%`}})}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[b.toLocaleString()," / ",y.toLocaleString()," used this month",k>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-foreground",children:k.toLocaleString()})," extra checks in stock"]})]}),e.jsx(r,{asChild:!0,size:"sm",variant:"ghost",className:"mt-2 px-0 h-auto text-primary",children:e.jsx(c,{to:"/credits",children:"View credit history â"})}),e.jsxs("div",{className:"mt-4 rounded-lg border border-border bg-muted/30 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Need more checks?"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"One-off purchase, no subscription. Extra checks never expire and are used automatically once the monthly allowance runs out."}),N?e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(r,{size:"sm",variant:v==="card"?"default":"outline",onClick:()=>w("card"),children:i("checkout.payByCard")}),e.jsx(r,{size:"sm",variant:v==="paypal"?"default":"outline",onClick:()=>w("paypal"),children:i("checkout.payWithPaypal")})]}),v==="card"?e.jsx(se,{priceId:N,quantity:1,customerEmail:a==null?void 0:a.email,userId:a==null?void 0:a.id,referralCode:L(),returnUrl:`${window.location.origin}/checkout/return?session_id={CHECKOUT_SESSION_ID}`}):e.jsx(te,{planId:N,referralCode:L(),successLabel:i("checkout.creditsAdded"),onSuccess:()=>{h(null),S(l=>l+1)}}),e.jsx(r,{size:"sm",variant:"ghost",onClick:()=>h(null),children:i("common.cancel")})]}):e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(r,{size:"sm",variant:"outline",onClick:()=>h("extension_scan_pack_200"),children:[e.jsx(z,{className:"w-4 h-4 mr-1"})," 200 extra checks â â¬2.50"]}),e.jsxs(r,{size:"sm",onClick:()=>h("extension_scan_pack_1000"),children:[e.jsx(z,{className:"w-4 h-4 mr-1"})," 1,000 extra checks â â¬9.99"]})]})]})]}),e.jsxs(m,{className:"p-6",children:[e.jsx("div",{className:"flex items-start justify-between gap-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Q,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold",children:"Developer API"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Check sites from your own app. 1 credit per request â 1 credit is 1 cent, no monthly limit."})]})]})}),e.jsx(r,{asChild:!0,size:"sm",className:"mt-4",children:e.jsx(c,{to:"/api",children:"Open API dashboard"})})]}),e.jsx(ae,{onRedeemed:()=>S(l=>l+1)})]}):e.jsxs(m,{className:"p-6",children:[e.jsx("p",{className:"mb-4",children:"Sign in to see your Premium and extension status."}),e.jsx(r,{asChild:!0,children:e.jsx(c,{to:"/auth",children:"Sign in"})})]})]}),e.jsx(ee,{})]})};export{Ee 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.