1import{u as y,g as x,j as e,k as F,B as h,r as _,t as C,A as I}from"./app-mqWwS7qW.js";import{B as N}from"./badge-DPRcOU6B.js";import{C as P,b as L,c as T,d as k,a as A,e as B}from"./card-BGOiKGWT.js";import{C as M}from"./calendar-days-CROTPJ8_.js";import{A as R}from"./arrow-right-Dx87QvB5.js";import{L as w}from"./loader-circle-BaJZwGsD.js";import{T as z,a as E,b as v,c as p,d as H,e as m}from"./table-BmCNivzv.js";import{D as S}from"./download-CrRpl61c.js";import{C as U}from"./credit-card-Di7byTd9.js";import{P as V,p as O}from"./pricing_plans-Cc4GCBx1.js";import{S as G}from"./settingsLayout-3uP7CohP.js";import"./tabs-CHQk3xKC.js";import"./gift-q24qUHwB.js";import"./rocket-B0ytucyO.js";import"./package-Clj1O6j5.js";import"./zap-gX04H5MZ.js";import"./separator-BsVZ8JuX.js";import"./user-Bd78EwGP.js";import"./settings-Mrs-ovUz.js";function Y(){const{props:i}=y(),{subscriptions:a,csrf_token:t,hasActiveSubscription:s}=i;if(!s)return null;const[r,c]=x.useState(!1),n=a?.[0],u=n?.price?.product?.name||"-",f=n?.currentPeriodStart?new Date(n.currentPeriodStart).toLocaleDateString("fr-FR",{day:"2-digit",month:"long",year:"numeric"}):"-",b=n?.currentPeriodEnd?new Date(n.currentPeriodEnd).toLocaleDateString("fr-FR",{day:"2-digit",month:"long",year:"numeric"}):"-",g=n?.price?.unitAmount?(n.price.unitAmount/100).toFixed(2):null,d=n?.price?.currency?.symbol||n?.price?.currency?.codeIso||"",l=n?.price?.interval||"mois";return e.jsxs(P,{className:"rounded-2xl border bg-background/80 shadow-lg",children:[e.jsxs(L,{children:[e.jsxs(T,{className:"flex items-center gap-2 text-2xl",children:[e.jsx(F,{className:"text-green-500"}),"Abonnement actuel"]}),e.jsx(k,{children:"Gérez votre abonnement Flippix et accédez à vos factures."})]}),e.jsx(A,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(N,{variant:"outline",className:"border-orange-200 bg-orange-50 px-3 py-1 text-base text-orange-600",children:u}),e.jsx("span",{className:"text-sm text-muted-foreground",children:g&&e.jsxs("span",{children:[g," ",d," / ",l]})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(M,{className:"h-4 w-4"}),e.jsx("span",{children:f}),e.jsx(R,{className:"h-4 w-4"}),e.jsx("span",{children:b})]})]})}),e.jsx(B,{className:"flex justify-end",children:e.jsxs("form",{method:"POST",action:"/stripe/subscriptions/manage",onSubmit:()=>c(!0),children:[e.jsx("input",{type:"hidden",name:"_csrf",value:t}),e.jsx(h,{variant:"outline",type:"submit",disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"mr-2 h-4 w-4 animate-spin"}),"Redirection"]}):"Gérer mon abonnement"})]})})]})}function $({invoices:i,loadingInvoiceId:a,setLoadingInvoiceId:t}){return e.jsxs(z,{children:[e.jsx(E,{children:e.jsxs(v,{children:[e.jsx(p,{className:"whitespace-nowrap",children:"Année"}),e.jsx(p,{className:"whitespace-nowrap",children:"Mois"}),e.jsx(p,{className:"whitespace-nowrap",children:"Numéro"}),e.jsx(p,{className:"whitespace-nowrap",children:"Montant"}),e.jsx(p,{className:"whitespace-nowrap",children:"Statut"}),e.jsx(p,{className:"whitespace-nowrap text-center",children:"Actions"})]})}),e.jsx(H,{children:i&&i.length>0?i.map(s=>{const r=s.invoice.status==="paid",c=s.invoice.status==="open";return e.jsxs(v,{children:[e.jsx(m,{className:"whitespace-nowrap font-medium",children:s.year}),e.jsx(m,{className:"whitespace-nowrap font-medium",children:s.monthName}),e.jsx(m,{className:"whitespace-nowrap",children:s.invoice.number}),e.jsxs(m,{className:"whitespace-nowrap",children:[(s.invoice.amount_due/100).toFixed(2)," ",s.invoice.currency.toUpperCase()]}),e.jsxs(m,{className:"whitespace-nowrap",children:[r&&e.jsx(N,{className:"border-green-500 bg-green-500 text-xs text-white",children:"Payée"}),c&&e.jsx(N,{className:"border-red-500 bg-red-500 text-xs text-white",children:"Impayée"})]}),e.jsxs(m,{className:"whitespace-nowrap",children:[c&&s.invoice.hosted_invoice_url&&e.jsx(h,{variant:"destructive",size:"sm",className:"w-full",asChild:!0,children:e.jsx("a",{href:s.invoice.hosted_invoice_url,target:"_blank",rel:"noopener noreferrer",children:"Payer"})}),r&&s.invoice.invoice_pdf&&e.jsx("form",{action:s.invoice.invoice_pdf,method:"get",onSubmit:()=>{t(s.invoice.id),setTimeout(()=>t(null),4500)},children:e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",type:"submit",disabled:a===s.invoice.id,children:[a===s.invoice.id?e.jsx(w,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(S,{className:"mr-2 h-4 w-4"}),"Télécharger"]})}),r&&!s.invoice.invoice_pdf&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Facture non disponible"})]})]},s.invoice.id)}):e.jsx(v,{children:e.jsx(m,{colSpan:6,className:"py-12",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 text-center text-muted-foreground",children:[e.jsx(S,{className:"h-8 w-8 op
1acity-40"}),e.jsx("p",{className:"text-base font-medium text-muted-foreground",children:"Aucune facture disponible"}),e.jsx("p",{className:"text-sm",children:"Vos factures apparaîtront ici après votre premier paiement."})]})})})})]})}function q(){const{props:i}=y(),{invoices:a,hasEverHadSubscription:t,hasActiveSubscription:s}=i,[r,c]=x.useState(null),[n,u]=x.useState(!1);if(!t)return null;const f=()=>{u(!0),_.post("/stripe/subscriptions/manage",{},{onFinish:()=>u(!1)})};return e.jsxs(P,{className:"rounded-2xl border bg-background/80 shadow-lg",children:[e.jsx(L,{children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx(T,{className:"text-2xl font-bold",children:"Factures"}),e.jsx(k,{children:"Téléchargez vos factures"})]}),!s&&e.jsx(h,{variant:"outline",size:"sm",disabled:n,className:"w-full sm:w-auto",onClick:f,children:n?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"mr-2 h-4 w-4 animate-spin"}),"Redirection"]}):e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"mr-2 h-4 w-4 shrink-0"}),e.jsx("span",{className:"sm:hidden",children:"Moyen de paiement"}),e.jsx("span",{className:"hidden sm:inline",children:"Modifier mon moyen de paiement"})]})})]})}),e.jsx(A,{children:e.jsx($,{invoices:a,loadingInvoiceId:r,setLoadingInvoiceId:c})})]})}function J(){x.useEffect(()=>{if(typeof window>"u")return;const i=new URL(window.location.href),a=i.searchParams.get("success"),t=i.searchParams.get("cancel");if(a==="true"||t==="true"){const s=setTimeout(()=>{a==="true"?C.success("Votre abonnement a été créé avec succès",{description:"Vous pouvez désormais accéder à vos factures.",duration:5e3}):t==="true"&&C.warning("Vous n'avez pas finalisé votre paiement",{description:"Vous pouvez réessayer de finaliser votre paiement.",duration:5e3});const r=new URL(window.location.href);r.searchParams.delete("success"),r.searchParams.delete("cancel"),window.history.replaceState({},document.title,r.pathname)},500);return()=>clearTimeout(s)}},[])}function K(){const{props:i}=y(),{hasActiveSubscription:a,csrf_token:t,products:s,hasEverHadSubscription:r}=i,[c,n]=x.useState(null),[u,f]=x.useState(!1),b=c!==null;J();const g=d=>{let l=null,j=null;return d.title.toLowerCase()==="scan"?l=s.find(o=>o.name.toLowerCase().includes("scan")):d.title.toLowerCase()==="expert"&&(l=s.find(o=>o.name.toLowerCase().includes("expert")||o.name.toLowerCase().includes("premium"))),l&&l.prices.length>0&&(j=l.prices.find(o=>u?o.interval==="year"||o.nickname?.toLowerCase().includes("an"):o.interval==="month"||o.nickname?.toLowerCase().includes("mois"))||l.prices[0]),j?e.jsxs("form",{method:"POST",action:"/stripe/subscriptions/checkout",onSubmit:()=>{n(j.stripeId)},children:[e.jsx(h,{type:"submit",className:`w-full ${d.type==="premium"?"bg-orange-500 font-bold text-white hover:bg-orange-600":"bg-black hover:bg-black/90"}`,disabled:b,children:c===j.stripeId?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"mr-2 h-4 w-4 animate-spin"}),"Redirection..."]}):r?"S'abonner":"Essayer gratuitement"}),e.jsx("input",{type:"hidden",name:"_csrf",value:t}),e.jsx("input",{type:"hidden",name:"priceId",value:j.stripeId})]}):e.jsx(h,{disabled:!0,className:"w-full",children:"Plan non disponible"})};return e.jsxs("div",{className:"space-y-8",children:[e.jsx(Y,{}),e.jsx(V,{plans:O,hasActiveSubscription:a,showTrialBanner:!r,onBillingPeriodChange:d=>f(d==="yearly"),renderButton:g,className:"lg:gap-6"}),e.jsx(q,{})]})}K.layout=i=>e.jsx(I,{children:e.jsx(G,{children:i})});export{K 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.