%PDF- %PDF-
| Direktori : /home2/rezakur1/ai.rezakurnia.com/assets/ |
| Current File : //home2/rezakur1/ai.rezakurnia.com/assets/PaketPage-DpUEULnr.js |
import{r as n,a as W,j as e}from"./index-Bu042oJp.js";import{B as g}from"./Button-CsqZL9Xc.js";import{C as _,a as $,b as S}from"./Card-TlRU04W7.js";import{B as w}from"./Badge-BhTU663i.js";import{M as G}from"./Modal-D2xuPxb5.js";import{u as V}from"./useWallet-B_uHC_7Y.js";import{p as Y,d as R,f as C,g as p,h as f}from"./format-CjhWL3Ta.js";import"./index-Cfl-v9NS.js";function J(){const[s,a]=n.useState([]),[d,m]=n.useState(null),[u,L]=n.useState([]),[k,b]=n.useState(!0),[q,B]=n.useState(null),o=n.useCallback(async()=>{try{const r=await W("/me/packages");a(r.catalog);const h=Date.now(),l=c=>new Date(c.expires_at).getTime()<=h,v=r.active&&!l(r.active)?r.active:null,y=r.purchases.map(c=>c.status==="active"&&l(c)?{...c,status:"expired"}:c);m(v),L(y),B(null)}catch(r){B(r instanceof Error?r.message:"Gagal memuat paket")}finally{b(!1)}},[]);n.useEffect(()=>{o()},[o]);const j=n.useCallback(async r=>{const h=await W(`/me/packages/${r}/buy`,{method:"POST"});return await o(),h},[o]),N=n.useCallback(async r=>{const h=await W(`/me/packages/${r}/claim`,{method:"POST"});return await o(),h},[o]);return{catalog:s,active:d,purchases:u,loading:k,error:q,buy:j,claim:N,refresh:o}}const M=1e4;function x(s){return s===null?"Unlimited":s.toLocaleString("id-ID")}function X(s){const a=new Date(s).getTime()-Date.now();return Math.max(0,Math.ceil(a/864e5))}function T({className:s="h-5 w-5"}){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:s,"aria-hidden":!0,children:[e.jsx("path",{d:"M12 6v13m0-13c0-1.657-1.343-3-3-3s-3 1.343-3 3c0 1.657 3 3 3 3h3m0-3c0-1.657 1.343-3 3-3s3 1.343 3 3c0 1.657-3 3-3 3h-3M5 11h14v8H5v-8z",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M5 15h14M5 8h14",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function A({className:s="h-5 w-5"}){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:s,"aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"1.6"}),e.jsx("path",{d:"m8.5 12.2 2.4 2.4 4.6-5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}function I({className:s="h-5 w-5"}){return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:s,"aria-hidden":!0,children:e.jsx("path",{d:"M13 3 5 13.5h6L11 21l8-10.5h-6L13 3z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})})}function D({className:s="h-5 w-5"}){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:s,"aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"12",r:"8.5",stroke:"currentColor",strokeWidth:"1.6"}),e.jsx("path",{d:"M12 7v5l3.2 2",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})}function E({className:s="h-5 w-5"}){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:s,"aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"12",r:"8.5",stroke:"currentColor",strokeWidth:"1.6"}),e.jsx("path",{d:"M12 7.5V12l3 2",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})}function H({className:s="h-5 w-5"}){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:s,"aria-hidden":!0,children:[e.jsx("path",{d:"M4 7.5A2.5 2.5 0 0 1 6.5 5H18a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6.5A2.5 2.5 0 0 1 4 16.5v-9z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),e.jsx("path",{d:"M15 12.5h3.5a1.5 1.5 0 0 1 0 3H15a1.5 1.5 0 0 1 0-3z",fill:"currentColor"})]})}function Z({className:s="h-5 w-5"}){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:s,"aria-hidden":!0,children:[e.jsx("path",{d:"M12 3.5 5 6v5.5c0 4.2 2.9 7.6 7 9 4.1-1.4 7-4.8 7-9V6l-7-2.5z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),e.jsx("path",{d:"m9 11.8 2.2 2.2 3.8-4.2",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})]})}function K({className:s="h-5 w-5"}){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:s,"aria-hidden":!0,children:[e.jsx("path",{d:"M4 8.5 12 4l8 4.5v7L12 20l-8-4.5v-7z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),e.jsx("path",{d:"m4 8.5 8 4.5 8-4.5M12 13v7",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})]})}function ee({className:s="h-5 w-5"}){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:s,"aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"1.6"}),e.jsx("path",{d:"M12 8v5m0 3h.01",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]})}function z({label:s,total:a,remaining:d}){if(a===null)return e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[e.jsx("span",{className:"text-slate-400",children:s}),e.jsx("span",{className:"font-semibold text-white",children:"Unlimited"})]});const m=Math.max(0,a-(d??0)),u=a>0?Math.min(100,m/a*100):0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[e.jsx("span",{className:"text-slate-400",children:s}),e.jsxs("span",{className:"tabular-nums text-slate-400",children:["Terpakai"," ",e.jsx("span",{className:"font-semibold text-white",children:m.toLocaleString("id-ID")})," ","dari ",a.toLocaleString("id-ID")]})]}),e.jsx("div",{className:"mt-1.5 h-1.5 overflow-hidden rounded-full bg-white/[0.06]",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-emerald-400 to-teal-400",style:{width:`${u}%`}})}),e.jsxs("p",{className:"mt-1 text-right text-[10px] tabular-nums text-slate-500",children:[u.toFixed(0),"% terpakai"]})]})}function P({icon:s,label:a,value:d,sub:m}){return e.jsxs("div",{className:"flex items-center gap-2.5 rounded-xl border border-white/[0.06] bg-white/[0.02] px-3 py-2.5",children:[e.jsx("span",{className:"shrink-0 text-slate-500",children:s}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:a}),e.jsx("p",{className:"truncate text-sm font-semibold tabular-nums text-white",children:d}),m&&e.jsx("p",{className:"text-[10px] text-slate-500",children:m})]})]})}function se({pkg:s,hasActive:a,claimed:d,onBuy:m,onClaim:u}){if(Number(s.claim_free)===1)return e.jsxs(_,{className:"relative flex flex-col overflow-hidden",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_80%_60%_at_50%_-10%,rgba(251,191,36,0.14),transparent)]"}),e.jsx("div",{className:"absolute inset-x-0 top-0 h-1 bg-gradient-to-r from-amber-400 via-orange-400 to-emerald-400"}),e.jsx("div",{className:"absolute right-0 top-4 rounded-l-full bg-gradient-to-r from-amber-400 to-orange-400 px-3 py-1 text-[10px] font-bold uppercase tracking-wider text-ink-950 shadow-lg shadow-amber-500/20",children:"Gratis"}),e.jsxs(S,{className:"relative flex flex-1 flex-col",children:[e.jsxs("div",{className:"flex items-start gap-3 pr-16",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-gradient-to-br from-amber-400/20 to-emerald-400/20 text-amber-300 ring-1 ring-amber-400/25",children:e.jsx(T,{})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-base font-semibold text-white",children:s.name}),s.description&&e.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-slate-400",children:s.description})]})]}),e.jsxs("div",{className:"mt-4 flex items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-extrabold tracking-tight text-transparent bg-clip-text bg-gradient-to-r from-amber-300 to-emerald-300",children:"Gratis"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:f(s)})]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-slate-500",children:[e.jsx(E,{className:"h-3.5 w-3.5"}),f(s)]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2.5",children:[e.jsx(P,{icon:e.jsx(I,{className:"h-4.5 w-4.5"}),label:"Request",value:x(s.request_quota)}),e.jsx(P,{icon:e.jsx(D,{className:"h-4.5 w-4.5"}),label:"Token",value:x(s.token_quota)})]}),e.jsx("div",{className:"mt-4 flex-1"}),d?e.jsxs(g,{variant:"ghost",className:"w-full",disabled:!0,children:[e.jsx(A,{className:"h-4 w-4 text-emerald-400"}),"Sudah diklaim"]}):a?e.jsx(g,{variant:"ghost",className:"w-full",disabled:!0,children:"Tunggu paket aktif berakhir"}):e.jsxs(g,{className:"w-full bg-gradient-to-r from-amber-500 to-orange-500 text-white shadow-lg shadow-amber-500/20 hover:from-amber-400 hover:to-orange-400",onClick:()=>u(s),children:[e.jsx(T,{className:"h-4 w-4"}),"Klaim Gratis"]})]})]});const k=a;return e.jsxs(_,{className:"relative flex flex-col overflow-hidden",children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-1 bg-gradient-to-r from-blue-500 via-blue-600 to-indigo-500"}),e.jsxs(S,{className:"flex flex-1 flex-col",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-blue-500/10 text-blue-300 ring-1 ring-blue-400/20",children:e.jsx(K,{})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-base font-semibold text-white",children:s.name}),s.description&&e.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-slate-400",children:s.description})]})]}),e.jsxs("div",{className:"mt-4 flex items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-extrabold tracking-tight tabular-nums text-white",children:p(Number(s.price))}),e.jsx("p",{className:"text-[11px] text-slate-500",children:f(s)})]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-slate-500",children:[e.jsx(E,{className:"h-3.5 w-3.5"}),f(s)]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2.5",children:[e.jsx(P,{icon:e.jsx(I,{className:"h-4.5 w-4.5"}),label:"Request",value:x(s.request_quota)}),e.jsx(P,{icon:e.jsx(D,{className:"h-4.5 w-4.5"}),label:"Token",value:x(s.token_quota)})]}),e.jsx("div",{className:"mt-4 flex-1"}),e.jsx(g,{className:"w-full",disabled:k,onClick:()=>m(s),children:k?"Sudah ada paket aktif":"Beli Paket"})]})]})}function oe(){const{catalog:s,active:a,purchases:d,loading:m,error:u,buy:L,claim:k}=J(),{data:b,refresh:q}=V(),[B,o]=n.useState(null),[j,N]=n.useState(null),[r,h]=n.useState(null),[l,v]=n.useState(null);n.useEffect(()=>{if(!j)return;const t=setTimeout(()=>N(null),5e3);return()=>clearTimeout(t)},[j]);const y=(t,i)=>N({id:Date.now(),type:t,text:i}),c=b?Y(b.wallet.balance):0,F=!!a,O=new Set(d.filter(t=>Number(t.package_price)===0).map(t=>t.package_id)),Q=async t=>{o(t.id),N(null);try{const i=await L(t.id);await q(),v(null),y("success",`Paket "${i.user_package.package_name}" aktif! Berakhir ${C(i.user_package.expires_at)}.`)}catch(i){y("error",i instanceof Error?i.message:"Gagal membeli paket")}finally{o(null)}},U=async t=>{o(t.id),N(null);try{const i=await k(t.id);await q(),h(null),y("success",`Paket gratis "${i.user_package.package_name}" berhasil diklaim! Aktif sampai ${C(i.user_package.expires_at)}.`)}catch(i){y("error",i instanceof Error?i.message:"Gagal mengklaim paket")}finally{o(null)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight text-white sm:text-2xl",children:"Paket"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Pilih paket kuota, atau klaim paket gratis langsung dari kartu."})]}),e.jsxs("div",{className:"panel flex items-center gap-3 px-4 py-2.5",children:[e.jsx(H,{className:"h-4.5 w-4.5 text-slate-400"}),e.jsx("span",{className:"text-xs text-slate-500",children:"Saldo wallet"}),e.jsx("span",{className:"text-base font-bold tabular-nums text-white",children:b?R(b.wallet.balance):"…"})]})]}),j&&e.jsxs("div",{role:"alert",className:`flex items-start gap-3 rounded-xl border px-4 py-3 text-sm ${j.type==="success"?"border-emerald-500/25 bg-emerald-500/10 text-emerald-300":"border-red-500/25 bg-red-500/10 text-red-300"}`,children:[j.type==="success"?e.jsx(A,{className:"mt-0.5 h-4.5 w-4.5 shrink-0"}):e.jsx(ee,{className:"mt-0.5 h-4.5 w-4.5 shrink-0"}),e.jsx("span",{className:"flex-1 leading-relaxed",children:j.text}),e.jsx("button",{type:"button",onClick:()=>N(null),"aria-label":"Tutup notifikasi",className:"shrink-0 rounded-lg p-1 text-current opacity-60 transition hover:bg-white/[0.06] hover:opacity-100",children:e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},j.id),a&&e.jsxs(_,{className:"relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-1 bg-gradient-to-r from-emerald-400 to-teal-400"}),e.jsx($,{title:"Paket Aktif",subtitle:`${a.name} · berakhir ${C(a.expires_at)}`,action:e.jsx(w,{tone:"success",children:"Aktif"})}),e.jsx(S,{children:e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-slate-400",children:[e.jsx(I,{className:"h-4 w-4 text-slate-500"}),"Request"]}),e.jsx("div",{className:"mt-2.5",children:e.jsx(z,{label:"Sisa request",total:a.request_quota,remaining:a.request_remaining})})]}),e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-slate-400",children:[e.jsx(D,{className:"h-4 w-4 text-slate-500"}),"Token"]}),e.jsx("div",{className:"mt-2.5",children:e.jsx(z,{label:"Sisa token",total:a.token_quota,remaining:a.token_remaining})})]}),e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-slate-400",children:[e.jsx(E,{className:"h-4 w-4 text-slate-500"}),"Masa Aktif"]}),e.jsxs("p",{className:"mt-2 text-2xl font-bold tabular-nums text-white",children:[X(a.expires_at)," hari"]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-slate-500",children:["berakhir ",C(a.expires_at)]})]}),e.jsxs("div",{className:"rounded-xl border border-emerald-500/20 bg-emerald-500/[0.06] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-emerald-300",children:[e.jsx(A,{className:"h-4 w-4"}),"Status"]}),e.jsxs("div",{className:"mt-2.5 space-y-1.5 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-slate-400",children:"Paket"}),e.jsx("span",{className:"truncate font-medium text-white",children:a.name})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-slate-400",children:"Diklaim"}),e.jsx("span",{className:"tabular-nums text-slate-300",children:Number(a.package_price)===0?"Ya":p(Number(a.package_price))})]})]})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 text-sm font-semibold text-white",children:"Katalog Paket"}),m?e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:[...Array(3)].map((t,i)=>e.jsx("div",{className:"h-60 animate-pulse rounded-2xl border border-white/[0.04] bg-white/[0.02]"},i))}):u?e.jsx(_,{children:e.jsx(S,{children:e.jsx("p",{className:"text-sm text-red-300",children:u})})}):s.length===0?e.jsx(_,{children:e.jsx(S,{children:e.jsx("p",{className:"text-sm text-slate-500",children:"Belum ada paket tersedia."})})}):e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:s.map(t=>e.jsx(se,{pkg:t,hasActive:F,claimed:O.has(t.id),onBuy:i=>v(i),onClaim:i=>h(i)},t.id))})]}),e.jsxs(_,{children:[e.jsx($,{title:"Riwayat",subtitle:"Paket yang dibeli atau diklaim"}),e.jsx(S,{className:"p-0",children:d.length===0?e.jsx("div",{className:"px-5 py-10 text-center text-sm text-slate-500",children:"Belum ada pembelian/klaim paket."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"divide-y divide-white/[0.04] md:hidden",children:d.map(t=>e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-white",children:t.name}),e.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:[f(t)," ·"," ",Number(t.package_price)===0?"Klaim gratis":p(Number(t.package_price))]})]}),t.status==="active"?e.jsx(w,{tone:"success",children:"Aktif"}):t.status==="exhausted"?e.jsx(w,{tone:"warning",children:"Kuota Habis"}):e.jsx(w,{tone:"default",children:"Berakhir"})]}),e.jsxs("div",{className:"mt-2.5 grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] px-2.5 py-1.5",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"Sisa Request"}),e.jsx("p",{className:"font-medium tabular-nums text-slate-300",children:x(t.request_remaining)})]}),e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] px-2.5 py-1.5",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"Sisa Token"}),e.jsx("p",{className:"font-medium tabular-nums text-slate-300",children:x(t.token_remaining)})]})]}),e.jsx("p",{className:"mt-2 text-[10px] tabular-nums text-slate-600",children:C(t.purchased_at)})]},t.id))}),e.jsx("div",{className:"hidden overflow-x-auto md:block",children:e.jsxs("table",{className:"w-full min-w-[640px] text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/[0.06] bg-white/[0.02] text-[11px] uppercase tracking-wider text-slate-500",children:[e.jsx("th",{className:"px-5 py-3 font-semibold",children:"Paket"}),e.jsx("th",{className:"px-4 py-3 text-right font-semibold",children:"Harga"}),e.jsx("th",{className:"px-4 py-3 text-right font-semibold",children:"Sisa Request"}),e.jsx("th",{className:"px-4 py-3 text-right font-semibold",children:"Sisa Token"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Status"}),e.jsx("th",{className:"px-5 py-3 text-right font-semibold",children:"Dibeli"})]})}),e.jsx("tbody",{children:d.map(t=>e.jsxs("tr",{className:"border-b border-white/[0.04] transition-colors last:border-0 hover:bg-white/[0.02]",children:[e.jsxs("td",{className:"px-5 py-3.5",children:[e.jsx("p",{className:"font-medium text-white",children:t.name}),e.jsx("p",{className:"text-[11px] text-slate-500",children:f(t)})]}),e.jsx("td",{className:"px-4 py-3.5 text-right font-medium tabular-nums text-slate-300",children:Number(t.package_price)===0?"Gratis":p(Number(t.package_price))}),e.jsx("td",{className:"px-4 py-3.5 text-right tabular-nums text-slate-400",children:x(t.request_remaining)}),e.jsx("td",{className:"px-4 py-3.5 text-right tabular-nums text-slate-400",children:x(t.token_remaining)}),e.jsx("td",{className:"px-4 py-3.5",children:t.status==="active"?e.jsx(w,{tone:"success",children:"Aktif"}):t.status==="exhausted"?e.jsx(w,{tone:"warning",children:"Kuota Habis"}):e.jsx(w,{tone:"default",children:"Berakhir"})}),e.jsx("td",{className:"px-5 py-3.5 text-right text-xs tabular-nums text-slate-500",children:C(t.purchased_at)})]},t.id))})]})})]})})]}),e.jsx(G,{open:!!l,onClose:()=>v(null),title:"Konfirmasi Pembelian",subtitle:l?l.name:"",children:l&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-white/[0.06] bg-white/[0.02] p-3",children:[e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-blue-500/10 text-blue-300 ring-1 ring-blue-400/20",children:e.jsx(K,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-white",children:l.name}),e.jsxs("p",{className:"text-xs text-slate-500",children:[f(l)," ·"," ",x(l.request_quota)," request ·"," ",x(l.token_quota)," token"]})]}),e.jsx("p",{className:"ml-auto shrink-0 text-sm font-bold tabular-nums text-white",children:p(Number(l.price))})]}),e.jsxs("div",{className:"rounded-xl border border-amber-400/15 bg-amber-500/[0.06] p-3.5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-xs font-semibold text-amber-200",children:[e.jsx(H,{className:"h-4 w-4"}),"Akan memotong saldo wallet"]}),e.jsxs("div",{className:"mt-2 space-y-1.5 text-xs text-slate-400",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{children:"Saldo saat ini"}),e.jsx("span",{className:"font-medium tabular-nums text-slate-300",children:b?R(b.wallet.balance):"…"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{children:"Dipotong"}),e.jsxs("span",{className:"font-semibold tabular-nums text-red-300",children:["−",p(Number(l.price))]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-white/[0.06] pt-1.5",children:[e.jsx("span",{children:"Sisa setelah pembelian"}),e.jsx("span",{className:"font-semibold tabular-nums text-emerald-300",children:c>=Number(l.price)?p(c-Number(l.price)):"—"})]})]}),c<Number(l.price)&&e.jsx("p",{className:"mt-2.5 rounded-lg bg-red-500/10 px-2.5 py-1.5 text-[11px] font-medium text-red-300",children:"Saldo tidak cukup — isi saldo dulu sebelum membeli."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(g,{variant:"ghost",className:"flex-1",onClick:()=>v(null),children:"Batal"}),e.jsxs(g,{className:"flex-1",isLoading:B===l.id,disabled:c<Number(l.price),onClick:()=>Q(l),children:[e.jsx(K,{className:"h-4 w-4"}),"Konfirmasi Pembelian"]})]})]})}),e.jsx(G,{open:!!r,onClose:()=>h(null),title:"Klaim Paket Gratis",subtitle:r?r.name:"",children:r&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-white/[0.06] bg-white/[0.02] p-3",children:[e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-amber-400/20 to-emerald-400/20 text-amber-300 ring-1 ring-amber-400/25",children:e.jsx(T,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-white",children:r.name}),e.jsxs("p",{className:"text-xs text-slate-500",children:[f(r)," ·"," ",x(r.request_quota)," request ·"," ",x(r.token_quota)," token"]})]})]}),e.jsxs("div",{className:"rounded-xl border border-amber-400/15 bg-amber-500/[0.06] p-3.5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-xs font-semibold text-amber-200",children:[e.jsx(Z,{className:"h-4 w-4"}),"Syarat klaim"]}),e.jsx("ul",{className:"mt-2 space-y-1.5 text-xs leading-relaxed text-slate-400",children:e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"mt-0.5 h-1 w-1 shrink-0 rounded-full bg-amber-400"}),"Saldo wallet minimal ",p(M)," (tanpa potongan saldo)."]})}),c<M&&e.jsxs("p",{className:"mt-2.5 rounded-lg bg-red-500/10 px-2.5 py-1.5 text-[11px] font-medium text-red-300",children:["Saldo belum cukup — isi saldo minimal"," ",p(M),"."]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(g,{variant:"ghost",className:"flex-1",onClick:()=>h(null),children:"Batal"}),e.jsxs(g,{className:"flex-1 bg-gradient-to-r from-amber-500 to-orange-500 text-white shadow-lg shadow-amber-500/20 hover:from-amber-400 hover:to-orange-400",isLoading:B===r.id,disabled:c<M,onClick:()=>U(r),children:[e.jsx(T,{className:"h-4 w-4"}),"Konfirmasi Klaim"]})]})]})})]})}export{oe as default};