PageSourceSearch

https://mazixuan69-new-api.hf.space/static/js/async/65.e2f0662b18.js

js mazixuan69-new-api.hf.space collected 2026-10-04 17:10:37 UTC 67,107 bytes, 2 lines download raw bytes

1/*! LICENSE: 65.e2f0662b18.js.LICENSE.txt */
2"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[65],{55514(e,s,a){a.d(s,{A:()=>t});let t=(0,a(5532).A)("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]])},9342(e,s,a){a.d(s,{A:()=>t});let t=(0,a(5532).A)("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]])},31824(e,s,a){a.d(s,{A:()=>t});let t=(0,a(5532).A)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}
2],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]])},54412(e,s,a){a.d(s,{A:()=>t});let t=(0,a(5532).A)("wallet-cards",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2",key:"4125el"}],["path",{d:"M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21",key:"1dpki6"}]])},67416(e,s,a){a.d(s,{i:()=>m});var t=a(39974),r=a(8031),n=a(30670),i=a(62519),l=a(39198),c=a(12968),o=a(93361),d=a(96456);function m(e){let{value:s,children:a,className:m,iconClassName:u,variant:p="ghost",size:x="icon",tooltip:h,successTooltip:f,"aria-label":y}=e,{t:g}=(0,i.Bd)(),{copiedText:j,copyToClipboard:N}=(0,c.C)({notify:!1}),b=j===s,v=h??g("Copy to clipboard"),w=f??g("Copied!"),_=g("Copied"),k=(0,t.jsxs)(o.$,{variant:p,size:x,className:(0,l.cn)("shrink-0",m),onClick:()=>N(s),"aria-label":b?_:y??v,children:[b?(0,t.jsx)(r.A,{className:(0,l.cn)("text-success",u)}):(0,t.jsx)(n.A,{className:(0,l.cn)(u)}),a]});return h||f?(0,t.jsxs)(d.m_,{children:[(0,t.jsx)(d.k$,{render:k}),(0,t.jsx)(d.ZI,{children:(0,t.jsx)("p",{children:b?w:v})})]}):k}},58635(e,s,a){a.d(s,{d:()=>l});var t=a(39974),r=a(62519),n=a(39198),i=a(48238);function l(e){var s;let{t:a}=(0,r.Bd)(),{group:l,label:c,ratio:o,copyable:d=!1,showDot:m,...u}=e,p=l?.trim(),x="auto"===p,h=!p,f=x||h,y=(s={labelOverride:c,groupName:p,isAutoGroup:x,isEmptyGroup:h,t:a}).labelOverride?s.labelOverride:s.isEmptyGroup?s.t("User Group"):s.isAutoGroup?s.t("Auto"):s.groupName??"",g=(0,t.jsx)(i.Wh,{...u,copyable:d,label:y,showDot:m??(!f&&void 0),variant:f?"neutral":void 0,autoColor:f?void 0:p});return null==o?g:(0,t.jsxs)("span",{className:"inline-flex items-center gap-2 text-xs",children:[g,(0,t.jsxs)("span",{className:(0,n.cn)("inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[11px] leading-none tabular-nums",o>1?"border-warning/25 bg-warning/10 text-warning":o<1?"border-info/25 bg-info/10 text-info":"border-border bg-muted text-muted-foreground"),children:[(0,t.jsx)("span",{className:"size-1 rounded-full bg-current opacity-60"}),(0,t.jsxs)("span",{children:[o,"x"]})]})]})}},61584(e,s,a){a.d(s,{f:()=>i});var t=a(39974),r=a(39198),n=a(21283);function i(e){let{title:s,description:a,icon:i,action:l,children:c,className:o,headerClassName:d,contentClassName:m,iconClassName:u,titleClassName:p,descriptionClassName:x}=e;return(0,t.jsxs)(n.Zp,{className:(0,r.cn)("gap-0 overflow-hidden py-0",o),children:[(0,t.jsx)(n.aR,{className:(0,r.cn)("border-b p-3 !pb-3 sm:p-5 sm:!pb-5",d),children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[null!=i&&(0,t.jsx)("div",{className:(0,r.cn)("bg-muted flex h-8 w-8 shrink-0 items-center justify-center rounded-lg sm:h-9 sm:w-9",u),children:i}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)(n.ZB,{className:(0,r.cn)("text-lg tracking-tight sm:text-xl",p),children:s}),null!=a&&(0,t.jsx)(n.BT,{className:(0,r.cn)("text-xs sm:text-sm",x),children:a})]})]}),null!=l&&(0,t.jsx)("div",{className:"w-full shrink-0 sm:w-auto",children:l})]})}),(0,t.jsx)(n.Wu,{className:(0,r.cn)("p-3 sm:p-5",m),children:c})]})}},32838(e,s,a){a.d(s,{Ay:()=>f,OX:()=>r,S$:()=>y,dW:()=>u,dh:()=>x,eW:()=>m,f:()=>g,gY:()=>d,l7:()=>o,mB:()=>p,oV:()=>l,pK:()=>h,qL:()=>c,qT:()=>n,td:()=>i});var t=a(98391);async function r(){return(await t.FH.get("/api/subscription/admin/plans")).data}async function n(e){return(await t.FH.post("/api/subscription/admin/plans",e)).data}async function i(e,s){return(await t.FH.put(`/api/subscription/admin/plans/${e}`,s)).data}async function l(e,s){return(await t.FH.patch(`/api/subscription/admin/plans/${e}`,{enabled:s})).data}async function c(e){return(await t.FH.get(`/api/subscription/admin/users/${e}/subscriptions`)).data}async function o(e,s){return(await t.FH.post(`/api/subscription/admin/users/${e}/subscriptions`,s)).data}async function d(e){return(await t.FH.post(`/api/subscription/admin/user_subscriptions/${e}/invalidate`)).data}async function m(e){return(await t.FH.delete(`/api/subscription/admin/user_subscriptions/${e}`)).data}async function u(e){return(await t.FH.post("/api/subscription/stripe/pay",e)).data}async function p(e){return(await t.FH.post("/api/subscription/creem/pay",e)).data}async function x(e){let s=await t.FH.post("/api/subscription/epay/pay",e);return{...s.data,url:s.data.url||s.url}}async function h(){return(await t.FH.get("/api/subscription/self")).data}async function f(){return(await t.FH.get("/api/subscription/plans")).data}async function y(e){return(await t.FH.put("/api/subscription/self/preference",{billing_preference:e})).data}async function g(){return(await t.FH.get("/api/group")).data}},92273(e,s,a){a.d(s,{vD:()=>c,jy:()=>d,sX:()=>o,ak:()=>n,Hc:()=>m,a3:()=>r,Ey:()=>i});var t=a(55686);function r(e,s){let a=e?.duration_unit||"month",t=e?.duration_value||1,r
2={year:s("years"),month:s("months"),day:s("days"),hour:s("hours"),custom:s("Custom (seconds)")};if("custom"===a){let a=e?.custom_seconds||0;return a>=86400?`${Math.floor(a/86400)} ${s("days")}`:a>=3600?`${Math.floor(a/3600)} ${s("hours")}`:`${a} ${s("seconds")}`}return`${t} ${r[a]||a}`}function n(e,s){let a=e?.quota_reset_period||"never";if("daily"===a)return s("Daily");if("weekly"===a)return s("Weekly");if("monthly"===a)return s("Monthly");if("custom"===a){let a=Number(e?.quota_reset_custom_seconds||0);return a>=86400?`${Math.floor(a/86400)} ${s("days")}`:a>=3600?`${Math.floor(a/3600)} ${s("hours")}`:a>=60?`${Math.floor(a/60)} ${s("minutes")}`:`${a} ${s("seconds")}`}return s("No Reset")}function i(e){return e?(0,t.A)(1e3*e).format("YYYY-MM-DD HH:mm:ss"):"-"}var l=a(65798);function c(e){return l.object({title:l.string().min(1,e("Please enter plan title")),subtitle:l.string().optional(),price_amount:l.coerce.number().min(0,e("Please enter amount")),duration_unit:l.enum(["year","month","day","hour","custom"]),duration_value:l.coerce.number().min(1),custom_seconds:l.coerce.number().min(0).optional(),quota_reset_period:l.enum(["never","daily","weekly","monthly","custom"]),quota_reset_custom_seconds:l.coerce.number().min(0).optional(),enabled:l.boolean(),sort_order:l.coerce.number(),max_purchase_per_user:l.coerce.number().min(0),total_amount:l.coerce.number().min(0),upgrade_group:l.string().optional(),stripe_price_id:l.string().optional(),creem_product_id:l.string().optional()})}let o={title:"",subtitle:"",price_amount:0,duration_unit:"month",duration_value:1,custom_seconds:0,quota_reset_period:"never",quota_reset_custom_seconds:0,enabled:!0,sort_order:0,max_purchase_per_user:0,total_amount:0,upgrade_group:"",stripe_price_id:"",creem_product_id:""};function d(e){return{title:e.title||"",subtitle:e.subtitle||"",price_amount:Number(e.price_amount||0),duration_unit:e.duration_unit||"month",duration_value:Number(e.duration_value||1),custom_seconds:Number(e.custom_seconds||0),quota_reset_period:e.quota_reset_period||"never",quota_reset_custom_seconds:Number(e.quota_reset_custom_seconds||0),enabled:!1!==e.enabled,sort_order:Number(e.sort_order||0),max_purchase_per_user:Number(e.max_purchase_per_user||0),total_amount:Number(e.total_amount||0),upgrade_group:e.upgrade_group||"",stripe_price_id:e.stripe_price_id||"",creem_product_id:e.creem_product_id||""}}function m(e){return{plan:{...e,price_amount:Number(e.price_amount||0),currency:"USD",duration_value:Number(e.duration_value||0),custom_seconds:Number(e.custom_seconds||0),quota_reset_period:e.quota_reset_period||"never",quota_reset_custom_seconds:"custom"===e.quota_reset_period?Number(e.quota_reset_custom_seconds||0):0,sort_order:Number(e.sort_order||0),max_purchase_per_user:Number(e.max_purchase_per_user||0),total_amount:Number(e.total_amount||0),upgrade_group:e.upgrade_group||""}}}},35297(e,s,a){a.d(s,{h:()=>n});var t=a(81910),r=a(21170);function n(){let{user:e}=(0,t.n)(e=>e.auth);return(e?.role??0)>=r.z7.ADMIN}},35021(e,s,a){a.r(s),a.d(s,{component:()=>eI});var t=a(39974),r=a(38390),n=a(62519),i=a(98391),l=a(11338),c=a(11948),o=a(38463),d=a(5532);let m=(0,d.A)("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);var u=a(95936),p=a(93361),x=a(21283),h=a(28357),f=a(21376),y=a(67416);function g(e){let{user:s,affiliateLink:a,onTransfer:r,loading:i}=e,{t:l}=(0,n.Bd)();if(i)return(0,t.jsx)(x.Zp,{className:"bg-muted/20 py-0",children:(0,t.jsxs)(x.Wu,{className:"grid gap-4 p-3 sm:p-4 lg:grid-cols-[minmax(220px,1fr)_minmax(220px,0.72fr)_minmax(320px,1.15fr)] lg:items-center",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(f.E,{className:"h-5 w-32"}),(0,t.jsx)(f.E,{className:"mt-2 h-4 w-48"})]}),(0,t.jsx)(f.E,{className:"h-14 rounded-lg"}),(0,t.jsx)(f.E,{className:"h-10 rounded-lg"})]})});let c=(s?.aff_quota??0)>0;return(0,t.jsx)(x.Zp,{className:"bg-muted/20 py-0",children:(0,t.jsxs)(x.Wu,{className:"grid gap-3 p-3 sm:gap-4 sm:p-4 lg:grid-cols-[minmax(200px,1fr)_minmax(180px,0.65fr)_minmax(280px,1fr)] lg:items-center",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,t.jsx)("div",{className:"bg-background flex size-8 shrink-0 items-center justify-center rounded-lg border",children:(0,t.jsx)(m,{className:"text-muted-foreground size-4"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h3",{className:"truncate text-sm font-semibold",children:l("Referral Program")}),(0,t.jsx)("p",{className:"text-muted-foreground line-clamp-1 text-xs",children:l("Earn rewards when your referrals add funds. Transfer accumulated rewards to your balance anytime.")})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-3 gap-1.5 text-center",children:[[l("Pending"),(0,u.eN)(s?.aff_quota??0)],[l("Total Earned"),(0,u.eN)(s?.aff_history_quota??0)],[l("Invites"),Str
2ing(s?.aff_count??0)]].map(e=>{let[s,a]=e;return(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground truncate text-[10px] font-medium tracking-wider uppercase",children:s}),(0,t.jsx)("div",{className:"mt-0.5 truncate text-sm font-semibold tabular-nums",children:a})]},s)})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(h.p,{value:a,readOnly:!0,className:"border-muted bg-background/70 h-9 min-w-0 flex-1 font-mono text-xs"}),(0,t.jsx)(y.i,{value:a,variant:"outline",className:"bg-background size-9 shrink-0",iconClassName:"size-4",tooltip:l("Copy referral link"),"aria-label":l("Copy referral link")}),c&&(0,t.jsx)(p.$,{onClick:r,className:"h-9 shrink-0 px-3",size:"sm",children:l("Transfer to Balance")})]})]})})}var j=a(61427),N=a(8031),b=a(30670),v=a(87268),w=a(58111),_=a(31632),k=a(12968),A=a(61318),C=a(68057),S=a(21731),R=a(18114),$=a(24513),E=a(48238),M=a(38843),P=a(65649),F=a(35297);function q(e){return!0===e.success||"success"===e.message}async function T(){return(await i.FH.get("/api/user/topup/info")).data}async function O(e){return(await i.FH.post("/api/user/topup",e)).data}async function H(e){return(await i.FH.post("/api/user/amount",e,{skipBusinessError:!0})).data}async function W(e){return(await i.FH.post("/api/user/stripe/amount",e,{skipBusinessError:!0})).data}async function B(e){let s=await i.FH.post("/api/user/pay",e,{skipBusinessError:!0});return{...s.data,url:s.data.url||s.url}}async function L(e){return(await i.FH.post("/api/user/stripe/pay",e,{skipBusinessError:!0})).data}async function J(e){return(await i.FH.post("/api/user/creem/pay",e,{skipBusinessError:!0})).data}async function z(e){return(await i.FH.post("/api/user/waffo/pay",e,{skipBusinessError:!0})).data}async function I(e){return(await i.FH.post("/api/user/waffo-pancake/amount",e,{skipBusinessError:!0})).data}async function U(e){return(await i.FH.post("/api/user/waffo-pancake/pay",e,{skipBusinessError:!0})).data}async function D(){return(await i.FH.get("/api/user/aff")).data}async function V(e){return(await i.FH.post("/api/user/aff_transfer",e)).data}async function Z(e,s,a){let t=new URLSearchParams({p:e.toString(),page_size:s.toString()});return a&&t.append("keyword",a),(await i.FH.get(`/api/user/topup/self?${t.toString()}`)).data}async function Q(e,s,a){let t=new URLSearchParams({p:e.toString(),page_size:s.toString()});return a&&t.append("keyword",a),(await i.FH.get(`/api/user/topup?${t.toString()}`)).data}async function G(e){return(await i.FH.post("/api/user/topup/complete",e)).data}let Y={success:{variant:"success",label:"Success"},pending:{variant:"warning",label:"Pending"},expired:{variant:"danger",label:"Expired"}},K={stripe:"Stripe",alipay:"Alipay",wxpay:"WeChat Pay",waffo:"Waffo"};function X(e){let{open:s,onOpenChange:a}=e,{t:i}=(0,n.Bd)(),{records:l,total:c,page:o,pageSize:d,keyword:m,loading:x,completing:y,isAdmin:g,handlePageChange:T,handlePageSizeChange:O,handleSearch:H,handleCompleteOrder:W}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{initialPage:s=1,initialPageSize:a=10}=e,t=(0,F.h)(),[n,i]=(0,r.useState)([]),[l,c]=(0,r.useState)(0),[o,d]=(0,r.useState)(s),[m,u]=(0,r.useState)(a),[p,x]=(0,r.useState)(""),[h,f]=(0,r.useState)(!1),[y,g]=(0,r.useState)(!1),j=(0,r.useCallback)(async()=>{f(!0);try{let e=t?await Q(o,m,p):await Z(o,m,p);q(e)&&e.data?(i(e.data.items||[]),c(e.data.total||0)):(P.oR.error(e.message||M.Ay.t("Failed to load billing history")),i([]),c(0))}catch(e){console.error("Failed to fetch billing history:",e),P.oR.error(M.Ay.t("Failed to load billing history")),i([]),c(0)}finally{f(!1)}},[t,o,m,p]),N=(0,r.useCallback)(async e=>{if(!t)return P.oR.error(M.Ay.t("Admin access required")),!1;g(!0);try{let s=await G({trade_no:e});if(q(s))return P.oR.success(M.Ay.t("Order completed successfully")),await j(),!0;return P.oR.error(s.message||M.Ay.t("Failed to complete order")),!1}catch(e){return console.error("Failed to complete order:",e),P.oR.error(M.Ay.t("Failed to complete order")),!1}finally{g(!1)}},[t,j]),b=(0,r.useCallback)(e=>{d(e)},[]),v=(0,r.useCallback)(e=>{u(e),d(1)},[]),w=(0,r.useCallback)(e=>{x(e),d(1)},[]);return(0,r.useEffect)(()=>{j()}
2,[j]),{records:n,total:l,page:o,pageSize:m,keyword:p,loading:h,completing:y,isAdmin:t,handlePageChange:b,handlePageSizeChange:v,handleSearch:w,handleCompleteOrder:N,refresh:j}}(),[B,L]=(0,r.useState)(null),{copyToClipboard:J,copiedText:z}=(0,k.C)({notify:!1}),I=Math.ceil(c/d),U=async()=>{B&&await W(B)&&L(null)};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(C.lG,{open:s,onOpenChange:a,children:(0,t.jsxs)(C.Cf,{className:"flex max-h-[calc(100dvh-2rem)] flex-col max-sm:h-dvh max-sm:w-screen max-sm:max-w-none max-sm:rounded-none max-sm:p-4 sm:max-w-4xl",children:[(0,t.jsxs)(C.c7,{children:[(0,t.jsx)(C.L3,{children:i("Billing History")}),(0,t.jsx)(C.rr,{children:i("View your topup transaction records and payment history")})]}),(0,t.jsxs)("div",{className:"min-h-0 flex-1 space-y-3 sm:space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("div",{className:"relative flex-1",children:[(0,t.jsx)(j.A,{className:"text-muted-foreground absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2"}),(0,t.jsx)(h.p,{placeholder:i("Search by order number..."),value:m,onChange:e=>H(e.target.value),className:"h-9 pl-10"})]}),(0,t.jsxs)($.l6,{items:[{value:"10",label:i("10 / page")},{value:"20",label:i("20 / page")},{value:"50",label:i("50 / page")},{value:"100",label:i("100 / page")}],value:d.toString(),onValueChange:e=>null!==e&&O(parseInt(e)),children:[(0,t.jsx)($.bq,{className:"h-9 w-[92px] sm:w-32",children:(0,t.jsx)($.yv,{})}),(0,t.jsx)($.gC,{alignItemWithTrigger:!1,children:(0,t.jsxs)($.s3,{children:[(0,t.jsx)($.eb,{value:"10",children:i("10 / page")}),(0,t.jsx)($.eb,{value:"20",children:i("20 / page")}),(0,t.jsx)($.eb,{value:"50",children:i("50 / page")}),(0,t.jsx)($.eb,{value:"100",children:i("100 / page")})]})})]})]}),(0,t.jsx)(R.F,{className:"h-[calc(100dvh-15rem)] pr-3 sm:h-[500px] sm:pr-4",children:x?(0,t.jsx)("div",{className:"space-y-3",children:Array.from({length:5}).map((e,s)=>(0,t.jsxs)("div",{className:"rounded-lg border p-3 sm:p-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between",children:[(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsx)(f.E,{className:"h-4 w-48"}),(0,t.jsx)(f.E,{className:"h-3 w-32"})]}),(0,t.jsx)(f.E,{className:"h-5 w-16"})]}),(0,t.jsxs)("div",{className:"mt-3 grid grid-cols-2 gap-3 sm:grid-cols-3 sm:gap-4",children:[(0,t.jsx)(f.E,{className:"h-3 w-full"}),(0,t.jsx)(f.E,{className:"h-3 w-full"}),(0,t.jsx)(f.E,{className:"h-3 w-full"})]})]},s))}):0===l.length?(0,t.jsxs)("div",{className:"text-muted-foreground flex h-[320px] flex-col items-center justify-center text-center sm:h-[400px]",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:i("No billing records found")}),(0,t.jsx)("p",{className:"mt-1 text-xs",children:m?i("Try adjusting your search"):i("Your transaction history will appear here")})]}):(0,t.jsx)("div",{className:"space-y-3",children:l.map(e=>{var s,a;let r,n=Y[e.status]||Y.pending;return(0,t.jsxs)("div",{className:"hover:bg-muted/50 rounded-lg border p-3 transition-colors sm:p-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)("code",{className:"text-foreground truncate font-mono text-sm",children:e.trade_no}),(0,t.jsx)(p.$,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>J(e.trade_no),children:z===e.trade_no?(0,t.jsx)(N.A,{className:"h-3 w-3"}):(0,t.jsx)(b.A,{className:"h-3 w-3"})}),g&&null!=e.user_id&&(0,t.jsx)(E.Wh,{label:`${i("User ID")}: ${e.user_id}`,variant:"neutral",size:"sm",copyText:String(e.user_id)})]}),(0,t.jsx)("div",{className:"text-muted-foreground text-xs",children:(s=e.create_time,(0,u.fk)(s))})]}),(0,t.jsx)(E.Wh,{label:n.label,variant:n.variant,showDot:!0,copyable:!1})]}),(0,t.jsxs)("div",{className:"mt-3 grid grid-cols-2 gap-3 sm:mt-4 sm:grid-cols-3 sm:gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(S.J,{className:"text-muted-foreground text-xs",children:i("Payment Method")}),(0,t.jsx)("div",{className:"text-sm font-medium",children:(a=e.payment_method,r=K[a]||a,i?i(r):r)})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(S.J,{className:"text-muted-foreground text-xs",children:i("Amount")}),(0,t.jsx)("div",{className:"text-sm font-semibold",children:(0,_.J5)(e.amount,{digitsLarge:2,digitsSmall:2,abbreviate:!1})})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(S.J,{className:"text-muted-foreground text-xs",children:i("Payment")}),(0,t.jsx)("div",{className:"text-sm font-semibold text-red-600",children:(0,u.ZV)(e.money)})]})]}),g&&"pending"===e.status&&(0,t.jsx)("div",{className:"mt-4 flex justify-end",children:(0,t.jsx)(p.$,{size:"sm",variant:"outline",onClick:()=>L(e.trade_no),disabled:y,children:i("Complete Order")})})]},e.id)})})}),!x&&l.length>0&&(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3 border-t pt-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsxs)("div",{className:"text-muted-foreground text-xs sm:text-sm",children:[i("Showing")," ",(o-1)*d+1,"-",Math.min(o*d,c)," ",i("of")," ",c]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.$,{variant:"outline",size:"sm",onClick:()=>T(o-1),disabled:o<=1,className:"h-8 w-8 p-0",children:(0,t.jsx)(v.A,{className:"h-4 w-4"})}),(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-1 text-sm",children:[(0,t.jsx)("span",{className:"font-medium",children:o}),(0,t.jsx)("span",{children:"/"}),(0,t.jsx)("span",{children:I})]}),(0,t.jsx)(p.$,{variant:"outline",size:"sm",onClick:()=>T(o+1),disabled:o>=I,className:"h-8 w-8 p-0",children:(0,t.jsx)(w.A,{className:"h-4 w-4"})})]})]})]})]})}),(0,t.jsx)(A.Lt,{open:!!B,onOpenChange:e=>!e&&L(null),children:(0,t.jsxs)(A.EO,{children:[(0,t.jsxs)(A.wd,{children:[(0,t.jsx)(A.r7,{children:i("Complete Order")}),(0,t.jsx)(A.$v,{children:i("Are you sure you want to manually complete this order? The user will be credited 
2with the corresponding quota.")})]}),(0,t.jsxs)(A.ck,{children:[(0,t.jsx)(A.Zr,{disabled:y,children:i("Cancel")}),(0,t.jsx)(A.Rx,{onClick:U,disabled:y,children:y?i("Processing..."):i("Confirm")})]})]})})]})}var ee=a(10933),es=a(93818);function ea(e){let{open:s,onOpenChange:a,onConfirm:r,product:i,processing:l}=e,{t:c}=(0,n.Bd)();return i?(0,t.jsx)(C.lG,{open:s,onOpenChange:a,children:(0,t.jsxs)(C.Cf,{className:"max-sm:w-[calc(100vw-1.5rem)] sm:max-w-[425px]",children:[(0,t.jsxs)(C.c7,{children:[(0,t.jsx)(C.L3,{children:c("Confirm Creem Purchase")}),(0,t.jsx)(C.rr,{children:c("Review your purchase details before proceeding.")})]}),(0,t.jsxs)("div",{className:"space-y-3 py-3 sm:space-y-4 sm:py-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:c("Product")}),(0,t.jsx)("span",{className:"font-medium",children:i.name})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:c("Price")}),(0,t.jsx)("span",{className:"font-medium text-indigo-600",children:(0,es.Bg)(i.price,i.currency)})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:c("Quota")}),(0,t.jsx)("span",{className:"font-medium",children:(0,u.ZV)(i.quota)})]})]}),(0,t.jsxs)(C.Es,{className:"grid grid-cols-2 gap-2 sm:flex",children:[(0,t.jsx)(p.$,{variant:"outline",onClick:()=>a(!1),disabled:l,children:c("Cancel")}),(0,t.jsxs)(p.$,{onClick:r,disabled:l,children:[l&&(0,t.jsx)(ee.A,{className:"mr-2 h-4 w-4 animate-spin"}),c("Confirm Payment")]})]})]})}):null}var et=a(10252);function er(e){return e===et.J1.STRIPE}function en(e){return e===et.J1.WAFFO_PANCAKE}function ei(e){return e?e.pay_methods?.length>0?e.pay_methods[0].type:e.enable_stripe_topup?et.J1.STRIPE:e.enable_waffo_topup?et.J1.WAFFO:e.enable_waffo_pancake_topup?et.J1.WAFFO_PANCAKE:et.Ar:et.Ar}function el(e){return e?e.enable_online_topup?e.min_topup:e.enable_stripe_topup?e.stripe_min_topup:e.enable_waffo_topup?e.waffo_min_topup||1:e.enable_waffo_pancake_topup&&e.waffo_pancake_min_topup||1:1}var ec=a(74889);let eo=(0,d.A)("landmark",[["path",{d:"M10 18v-7",key:"wt116b"}],["path",{d:"M11.12 2.198a2 2 0 0 1 1.76.006l7.866 3.847c.476.233.31.949-.22.949H3.474c-.53 0-.695-.716-.22-.949z",key:"1m329m"}],["path",{d:"M14 18v-7",key:"vav6t3"}],["path",{d:"M18 18v-7",key:"aexdmj"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M6 18v-7",key:"1ivflk"}]]);var ed=a(52173);let em="u">typeof globalThis&&"location"in globalThis;function eu(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"h-4 w-4",a=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,n=function(e){let s;if(!e)return null;let a=e.trim();if(!a)return null;try{s=em?new URL(a,globalThis.location.href):new URL(a)}catch{return null}return"http:"!==s.protocol&&"https:"!==s.protocol||s.username||s.password?null:s.toString()}(a);if(n)return(0,t.jsx)("img",{src:n,alt:r||e||"payment",className:s,style:{objectFit:"contain"},loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"});if(!e)return(0,t.jsx)(ec.A,{className:s});switch(e){case et.J1.ALIPAY:return(0,t.jsx)(ed.n4U,{className:s,style:{color:et.mi[et.J1.ALIPAY]}});case et.J1.WECHAT:return(0,t.jsx)(ed.tnV,{className:s,style:{color:et.mi[et.J1.WECHAT]}});case et.J1.STRIPE:return(0,t.jsx)(ed.kDV,{className:s,style:{color:et.mi[et.J1.STRIPE]}});case et.J1.CREEM:return(0,t.jsx)(eo,{className:s,style:{color:et.mi[et.J1.CREEM]}});case et.J1.WAFFO:return(0,t.jsx)(ec.A,{className:s,style:{color:et.mi[et.J1.WAFFO]}});case et.J1.WAFFO_PANCAKE:return(0,t.jsx)(ec.A,{className:s,style:{color:et.mi[et.J1.WAFFO_PANCAKE]}});default:return(0,t.jsx)(ec.A,{className:s})}}function ep(e){let{open:s,onOpenChange:a,onConfirm:r,topupAmount:i,paymentAmount:l,paymentMethod:c,calculating:o,processing:d,discountRate:m=1,usdExchangeRate:u=1}=e,{t:p}=(0,n.Bd)(),x=m>0&&m<1&&l>0,h=x?l/m:0,y=x?h-l:0;return(0,t.jsx)(A.Lt,{open:s,onOpenChange:a,children:(0,t.jsxs)(A.EO,{className:"max-sm:w-[calc(100vw-1.5rem)] sm:max-w-md",children:[(0,t.jsxs)(A.wd,{children:[(0,t.jsx)(A.r7,{className:"text-xl font-semibold",children:p("Confirm Payment")}),(0,t.jsx)(A.$v,{children:p("Review your payment details")})]}),(0,t.jsxs)("div",{className:"space-y-3 py-3 sm:space-y-4 sm:py-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:p("Topup Amount")}),(0,t.jsx)("span",{className:"text-lg font-semibold",children:(0,_.QO)(i*u,{digitsLarge:2,digitsSmall:2,abbreviate:!1})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:p("You Pay")}),o?(0,t.jsx)(f.E,{className:"h-6 w-24"}):(0,t.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,t.jsx)("span",{className:"text-2xl font-semibold",children:(0,es.vv)(l)}),x&&(0,t.jsx)("span",{className:"text-muted-foreground text-sm line-through",children:(0,es.vv)(h
2)})]})]}),x&&!o&&(0,t.jsx)("div",{className:"bg-muted/50 rounded-lg p-3",children:(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:p("You save")}),(0,t.jsx)("span",{className:"font-semibold text-green-600",children:(0,es.vv)(y)})]})}),(0,t.jsx)("div",{className:"border-t pt-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:p("Payment Method")}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[eu(c?.type,"h-4 w-4",c?.icon,c?.name),(0,t.jsx)("span",{className:"font-medium",children:c?.name})]})]})})]}),(0,t.jsxs)(A.ck,{className:"grid grid-cols-2 gap-2 sm:flex",children:[(0,t.jsx)(A.Zr,{disabled:d,children:p("Cancel")}),(0,t.jsxs)(A.Rx,{onClick:r,disabled:d,children:[d&&(0,t.jsx)(ee.A,{className:"mr-2 h-4 w-4 animate-spin"}),p("Confirm Payment")]})]})]})})}function ex(e){let{open:s,onOpenChange:a,onConfirm:i,availableQuota:l,transferring:c}=e,{t:o}=(0,n.Bd)(),[d,m]=(0,r.useState)(5e5);(0,r.useEffect)(()=>{s&&m(5e5)},[s]);let x=async()=>{await i(d)&&a(!1)};return(0,t.jsx)(C.lG,{open:s,onOpenChange:a,children:(0,t.jsxs)(C.Cf,{className:"max-sm:w-[calc(100vw-1.5rem)] sm:max-w-md",children:[(0,t.jsxs)(C.c7,{children:[(0,t.jsx)(C.L3,{className:"text-xl font-semibold",children:o("Transfer Rewards")}),(0,t.jsx)(C.rr,{children:o("Move affiliate rewards to your main balance")})]}),(0,t.jsxs)("div",{className:"space-y-4 py-3 sm:space-y-6 sm:py-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(S.J,{className:"text-muted-foreground text-xs font-medium tracking-wider uppercase",children:o("Available Rewards")}),(0,t.jsx)("div",{className:"text-2xl font-semibold",children:(0,u.eN)(l)})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(S.J,{htmlFor:"transfer-amount",className:"text-muted-foreground text-xs font-medium tracking-wider uppercase",children:o("Transfer Amount")}),(0,t.jsx)(h.p,{id:"transfer-amount",type:"number",value:d,onChange:e=>m(Number(e.target.value)),min:5e5,max:l,step:5e5,className:"font-mono text-lg"}),(0,t.jsxs)("p",{className:"text-muted-foreground text-xs",children:[o("Minimum:")," ",(0,u.eN)(5e5)]})]})]}),(0,t.jsxs)(C.Es,{className:"grid grid-cols-2 gap-2 sm:flex",children:[(0,t.jsx)(p.$,{variant:"outline",onClick:()=>a(!1),disabled:c,children:o("Cancel")}),(0,t.jsxs)(p.$,{onClick:x,disabled:c,children:[c&&(0,t.jsx)(ee.A,{className:"mr-2 h-4 w-4 animate-spin"}),o("Transfer")]})]})]})})}var eh=a(54412);let ef=(0,d.A)("receipt",[["path",{d:"M12 17V7",key:"pyj7ub"}],["path",{d:"M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8",key:"1elt7d"}],["path",{d:"M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z",key:"ycz6yz"}]]),ey=(0,d.A)("gift",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8",key:"1sqzm4"}],["path",{d:"M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5",key:"kc0143"}],["rect",{x:"3",y:"7",width:"18",height:"4",rx:"1",key:"1hberx"}]]);var eg=a(27953),ej=a(39198),eN=a(40427),eb=a(61584),ev=a(96456);function ew(e){let{products:s,onProductSelect:a,loading:r}=e,{t:i}=(0,n.Bd)();return r?(0,t.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-2 sm:gap-3 md:grid-cols-3",children:Array.from({length:3}).map((e,s)=>(0,t.jsx)(f.E,{className:"h-24 rounded-lg"},s))}):Array.isArray(s)&&0!==s.length?(0,t.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-2 sm:gap-3 md:grid-cols-3",children:s.map(e=>
2(0,t.jsx)(x.Zp,{className:"hover:border-foreground/50 cursor-pointer transition-all hover:shadow-md",onClick:()=>a(e),children:(0,t.jsxs)(x.Wu,{className:"p-3 text-center sm:p-4",children:[(0,t.jsx)("div",{className:"mb-2 text-lg font-medium",children:e.name}),(0,t.jsxs)("div",{className:"text-muted-foreground mb-2 text-sm",children:[i("Quota"),": ",(0,u.ZV)(e.quota)]}),(0,t.jsx)("div",{className:"text-lg font-semibold text-indigo-600",children:(0,es.Bg)(e.price,e.currency)})]})},e.productId))}):null}function e_(e){let{topupInfo:s,presetAmounts:a,selectedPreset:i,onSelectPreset:l,topupAmount:c,onTopupAmountChange:o,paymentAmount:d,calculating:m,onPaymentMethodSelect:y,paymentLoading:g,redemptionCode:j,onRedemptionCodeChange:N,onRedeem:b,redeeming:v,topupLink:w,loading:_,priceRatio:k=1,usdExchangeRate:A=1,onOpenBilling:C,creemProducts:R,enableCreemTopup:$,onCreemProductSelect:E,enableWaffoTopup:M,waffoPayMethods:P,waffoMinTopup:F,onWaffoMethodSelect:q,enableWaffoPancakeTopup:T}=e,{t:O}=(0,n.Bd)(),[H,W]=(0,r.useState)(c.toString());(0,r.useEffect)(()=>{W(c.toString())},[c]);let B=s?.enable_online_topup||s?.enable_stripe_topup||M||T,L=B||$,J=Array.isArray(s?.pay_methods)&&s.pay_methods.length>0,z=Array.isArray(P)&&P.length>0,I=el(s);return _?(0,t.jsxs)(x.Zp,{className:"gap-0 overflow-hidden py-0",children:[(0,t.jsxs)(x.aR,{className:"border-b p-3 !pb-3 sm:p-5 sm:!pb-5",children:[(0,t.jsx)(f.E,{className:"h-6 w-32"}),(0,t.jsx)(f.E,{className:"mt-2 h-4 w-48"})]}),(0,t.jsxs)(x.Wu,{className:"space-y-4 p-3 sm:space-y-6 sm:p-5",children:[(0,t.jsxs)("div",{className:"space-y-4 sm:space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(f.E,{className:"h-3 w-16"}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:Array.from({length:8}).map((e,s)=>(0,t.jsx)(f.E,{className:"h-[72px] rounded-lg"},s))})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(f.E,{className:"h-3 w-28"}),(0,t.jsx)(f.E,{className:"h-[42px] w-full"})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(f.E,{className:"h-3 w-32"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-3",children:Array.from({length:3}).map((e,s)=>(0,t.jsx)(f.E,{className:"h-10 w-24 rounded-lg"},s))})]})]}),(0,t.jsxs)("div",{className:"space-y-3 border-t pt-8",children:[(0,t.jsx)(f.E,{className:"h-3 w-24"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(f.E,{className:"h-10 flex-1"}),(0,t.jsx)(f.E,{className:"h-10 w-20"})]})]})]})]}):(0,t.jsxs)(eb.f,{title:O("Add Funds"),description:O("Choose an amount and payment method"),icon:(0,t.jsx)(eh.A,{className:"h-4 w-4"}),action:C?(0,t.jsxs)(p.$,{variant:"outline",size:"sm",onClick:C,className:"w-full gap-2 sm:w-auto",children:[(0,t.jsx)(ef,{className:"h-4 w-4"}),O("Order History")]}):null,contentClassName:"space-y-4 sm:space-y-6",children:[L?(0,t.jsx)("div",{className:"space-y-4 sm:space-y-6",children:B&&(0,t.jsxs)(t.Fragment,{children:[a.length>0&&(0,t.jsxs)("div",{className:"space-y-2.5 sm:space-y-3",children:[(0,t.jsx)(S.J,{className:"text-muted-foreground text-xs font-medium tracking-wider uppercase",children:O("Amount")}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-1.5 sm:gap-3 md:grid-cols-4",children:a.map((e,a)=>{let r=e.discount||s?.discount?.[e.value]||1,{displayValue:n,actualPrice:c,savedAmount:o,hasDiscount:d}=(0,es.k)(e.value,k,r,A);return(0,t.jsxs)(p.$,{variant:"outline",className:(0,ej.cn)("hover:border-foreground flex min-h-16 flex-col items-start rounded-lg px-3 py-2.5 text-left whitespace-normal sm:min-h-[72px] sm:p-4",i===e.value?"border-foreground bg-foreground
2/5":"border-muted"),onClick:()=>l(e),children:[(0,t.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,t.jsx)("div",{className:"text-base font-semibold sm:text-lg",children:(0,u.ZV)(n)}),d&&(0,t.jsx)("div",{className:"text-xs font-medium text-green-600",children:(0,es.gU)(r)})]}),(0,t.jsxs)("div",{className:"text-muted-foreground mt-1.5 w-full text-xs sm:mt-2",children:["Pay ",(0,es.vv)(c),d&&o>0&&(0,t.jsxs)("span",{className:"text-green-600",children:[" ","• Save ",(0,es.vv)(o)]})]})]},a)})})]}),(0,t.jsxs)("div",{className:"space-y-2.5 sm:space-y-3",children:[(0,t.jsx)(S.J,{htmlFor:"topup-amount",className:"text-muted-foreground text-xs font-medium tracking-wider uppercase",children:O("Custom Amount")}),(0,t.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(110px,0.55fr)] gap-2 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-center",children:[(0,t.jsx)(h.p,{id:"topup-amount",type:"number",value:H,onChange:e=>{var s;let a;return W(s=e.target.value),void((a=parseInt(s)||0)>=0&&o(a))},min:I,placeholder:`Minimum ${I}`,className:"h-9 text-base sm:h-10 sm:text-lg"}),(0,t.jsxs)("div",{className:"bg-muted/30 flex min-h-9 items-center justify-between gap-2 rounded-md border px-3 lg:min-w-52",children:[(0,t.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:O("Amount to pay:")}),m?(0,t.jsx)(f.E,{className:"h-5 w-16"}):(0,t.jsx)("span",{className:"text-sm font-semibold",children:(0,es.vv)(d)})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2.5 sm:space-y-3",children:[(0,t.jsx)(S.J,{className:"text-muted-foreground text-xs font-medium tracking-wider uppercase",children:O("Payment Method")}),J?(0,t.jsx)("div",{className:"grid grid-cols-2 gap-1.5 sm:gap-3 lg:grid-cols-3",children:s?.pay_methods?.map(e=>{let s=e.min_topup||0,a=s>c,r=(0,t.jsxs)(p.$,{variant:"outline",onClick:()=>y(e),disabled:a||!!g,className:"h-9 min-w-0 justify-start gap-2 rounded-lg px-3",children:[g===e.type?(0,t.jsx)(ee.A,{className:"h-4 w-4 animate-spin"}):eu(e.type,"h-4 w-4",e.icon,e.name),(0,t.jsx)("span",{className:"truncate",children:e.name})]},e.type);return a?(0,t.jsx)(ev.Bc,{children:(0,t.jsxs)(ev.m_,{children:[(0,t.jsx)(ev.k$,{render:r}),(0,t.jsx)(ev.ZI,{children:O("Minimum topup amount: {{amount}}",{amount:s})})]})},e.type):r})}):z?null:(0,t.jsx)(eN.Fc,{children:(0,t.jsx)(eN.TN,{children:O("No payment methods available. Please contact administrator.")})})]}),M&&z&&q&&(0,t.jsxs)("div",{className:"space-y-2.5 sm:space-y-3",children:[(0,t.jsx)(S.J,{className:"text-muted-foreground text-xs font-medium tracking-wider uppercase",children:O("Waffo Payment")}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-1.5 sm:gap-3 lg:grid-cols-3",children:P?.map((e,s)=>{let a=`waffo-${s}`,r=F||0,n=r>c,i=(0,t.jsxs)(p.$,{variant:"outline",onClick:()=>q(e,s),disabled:n||!!g,className:"h-9 min-w-0 justify-start gap-2 rounded-lg px-3",children:[g===a?(0,t.jsx)(ee.A,{className:"h-4 w-4 animate-spin"}):e.icon?(0,t.jsx)("img",{src:e.icon,alt:e.name,className:"h-4 w-4 object-contain"}):eu("waffo"),(0,t.jsx)("span",{className:"truncate",children:e.name})]},`${e.name}-${s}`);return n?(0,t.jsx)(ev.Bc,{children:(0,t.jsxs)(ev.m_,{children:[(0,t.jsx)(ev.k$,{render:i}),(0,t.jsx)(ev.ZI,{children:O("Minimum topup amount: {{amount}}",{amount:r})})]})},`${e.name}-${s}`):i})})]})]})}):(0,t.jsx)(eN.Fc,{children:(0,t.jsx)(eN.TN,{children:O("Online topup is not enabled. Please use redemption code or contact administrator.")})}),$&&Array.isArray(R)&&R.length>0&&E&&(0,t.jsxs)("div",{className:"space-y-2.5 border-t pt-4 sm:space-y-3 sm:pt-6",children:[(0,t.jsx)(S.J,{className:"text-muted-foreground text-xs font-medium tracking-wider uppercase",children:O("Creem Payment")}),(0,t.jsx)(ew,{products:R,onProductSelect:E})]}),(0,t.jsxs)("div",{className:"space-y-2.5 border-t pt-4 sm:space-y-3 sm:pt-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ey,{className:"text-muted-foreground h-4 w-4"}),(0,t.jsx)(S.J,{htmlFor:"redemption-code",className:"text-muted-foreground text-xs font-medium tracking-wider uppercase",children:O("Have a Code?")})]}),(0,t.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-2",children:[(0,t.jsx)(h.p,{id:"redemption-code",value:j,onChange:e=>N(e.target.value),placeholder:O("Enter your redemption code"),className:"h-9 min-w-0"}),(0,t.jsxs)(p.$,{onClick:b,disabled:v,variant:"outline",className:"h-9 px-4",children:[v&&(0,t.jsx)(ee.A,{className:"mr-2 h-4 w-4 animate-spin"}),O("Redeem")]})]}),w&&(0,t.jsxs)("p",{className:"text-muted-foreground text-xs",children:[O("Need a redemption code?")," ",(0,t.jsxs)("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 underline-offset-4 hover:underline",children:[O("Get one here"),(0,t.jsx)(eg.A,{className:"h-3 w-3"})]})]})]})]})}let ek=(0,d.A)("crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);
2var eA=a(64787),eC=a(31824),eS=a(20244),eR=a(55308),e$=a(32838),eE=a(55514);let eM=(0,d.A)("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);var eP=a(58635),eF=a(92273);function eq(e){let{t:s}=(0,n.Bd)(),[a,i]=(0,r.useState)(!1),[l,c]=(0,r.useState)("");(0,r.useEffect)(()=>{e.open&&e.epayMethods&&e.epayMethods.length>0?c(e.epayMethods[0].type):e.open||c("")},[e.open,e.epayMethods]);let o=e.plan?.plan;if(!o)return null;let d=e.enableStripe&&!!o.stripe_price_id,m=e.enableCreem&&!!o.creem_product_id,u=e.enableOnlineTopUp&&(e.epayMethods||[]).length>0,x=d||m||u,h=(e.epayMethods||[]).find(e=>e.type===l)?.name||l||s("Select payment method"),f=Number(o.total_amount||0),y=Number(o.price_amount||0).toFixed(2),g=(e.purchaseLimit||0)>0&&(e.purchaseCount||0)>=(e.purchaseLimit||0),j=async()=>{i(!0);try{let a=await (0,e$.dW)({plan_id:o.id});"success"===a.message&&a.data?.pay_link?(window.open(a.data.pay_link,"_blank"),P.oR.success(s("Payment page opened")),e.onOpenChange(!1)):P.oR.error(a.message&&"success"!==a.message?a.message:s("Payment request failed"))}catch{P.oR.error(s("Payment request failed"))}finally{i(!1)}},N=async()=>{i(!0);try{let a=await (0,e$.mB)({plan_id:o.id});"success"===a.message&&a.data?.checkout_url?(window.open(a.data.checkout_url,"_blank"),P.oR.success(s("Payment page opened")),e.onOpenChange(!1)):P.oR.error(a.message&&"success"!==a.message?a.message:s("Payment request failed"))}catch{P.oR.error(s("Payment request failed"))}finally{i(!1)}},b="u">typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent),v=async()=>{if(!l)return void P.oR.error(s("Please select a payment method"));i(!0);try{let a=await (0,e$.dh)({plan_id:o.id,payment_method:l});if("success"===a.message&&a.url){let t=document.createElement("form");t.action=a.url,t.method="POST",b||(t.target="_blank"),Object.entries(a.data||{}).forEach(e=>{let[s,a]=e,r=document.createElement("input");r.type="hidden",r.name=s,r.value=String(a),t.appendChild(r)}),document.body.appendChild(t),t.submit(),document.body.removeChild(t),P.oR.success(s("Payment initiated")),e.onOpenChange(!1)}else P.oR.error(a.message&&"success"!==a.message?a.message:s("Payment request failed"))}catch{P.oR.error(s("Payment request failed"))}finally{i(!1)}};return(0,t.jsx)(C.lG,{open:e.open,onOpenChange:e.onOpenChange,children:(0,t.jsxs)(C.Cf,{className:"max-sm:w-[calc(100vw-1.5rem)] sm:max-w-md",children:[(0,t.jsx)(C.c7,{children:(0,t.jsxs)(C.L3,{className:"flex items-center gap-2",children:[(0,t.jsx)(ek,{className:"h-5 w-5"}),s("Purchase Subscription")]})}),(0,t.jsxs)("div",{className:"space-y-3 sm:space-y-4",children:[(0,t.jsxs)("div",{className:"bg-muted/50 space-y-2.5 rounded-lg border p-3 sm:space-y-3 sm:p-4",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:s("Plan Name")}),(0,t.jsx)("span",{className:"max-w-[200px] truncate text-sm font-medium",children:o.title})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:s("Validity Period")}),(0,t.jsxs)("span",{className:"flex items-center gap-1 text-sm",children:[(0,t.jsx)(eE.A,{className:"h-3.5 w-3.5"}),(0,eF.a3)(o,s)]})]}),(0,eF.ak)(o,s)!==s("No Reset")&&(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:s("Reset Period")}),(0,t.jsx)("span",{className:"text-sm",children:(0,eF.ak)(o,s)})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:s("Total Quota")}),(0,t.jsxs)("span",{className:"flex items-center gap-1 text-sm",children:[(0,t.jsx)(eM,{className:"h-3.5 w-3.5"}),f>
20?f:s("Unlimited")]})]}),o.upgrade_group&&(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:s("Upgrade Group")}),(0,t.jsx)(eP.d,{group:o.upgrade_group})]}),(0,t.jsx)(eR.w,{}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:s("Amount Due")}),(0,t.jsxs)("span",{className:"text-primary text-lg font-bold",children:["$",y]})]})]}),g&&(0,t.jsx)(eN.Fc,{variant:"destructive",children:(0,t.jsxs)(eN.TN,{children:[s("Purchase limit reached")," (",e.purchaseCount,"/",e.purchaseLimit,")"]})}),x?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:s("Select payment method")}),(d||m)&&(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:flex",children:[d&&(0,t.jsx)(p.$,{variant:"outline",className:"flex-1",onClick:j,disabled:a||g,children:"Stripe"}),m&&(0,t.jsx)(p.$,{variant:"outline",className:"flex-1",onClick:N,disabled:a||g,children:"Creem"})]}),u&&(0,t.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-2",children:[(0,t.jsxs)($.l6,{items:[...(e.epayMethods||[]).map(e=>({value:e.type,label:e.name||e.type}))],value:l,onValueChange:e=>null!==e&&c(e),disabled:g,children:[(0,t.jsx)($.bq,{className:"flex-1",children:(0,t.jsx)($.yv,{children:h})}),(0,t.jsx)($.gC,{alignItemWithTrigger:!1,children:(0,t.jsx)($.s3,{children:(e.epayMethods||[]).map(e=>(0,t.jsx)($.eb,{value:e.type,children:e.name||e.type},e.type))})})]}),(0,t.jsx)(p.$,{onClick:v,disabled:a||!l||g,children:s("Pay")})]})]}):(0,t.jsx)(eN.Fc,{children:(0,t.jsx)(eN.TN,{children:s("Online payment is not enabled. Please contact the administrator.")})})]})]})})}function eT(e,s){switch(e){case"subscription_first":return s("Subscription First");case"wallet_first":return s("Wallet First");case"subscription_only":return s("Subscription Only");case"wallet_only":return s("Wallet Only");default:return e}}function eO(e){let{topupInfo:s,onAvailabilityChange:a}=e,{t:i}=(0,n.Bd)(),[l,c]=(0,r.useState)([]),[o,d]=(0,r.useState)([]),[m,h]=(0,r.useState)([]),[y,g]=(0,r.useState)("subscription_first"),[j,b]=(0,r.useState)(!0),[v,w]=(0,r.useState)(!1),[_,k]=(0,r.useState)(!1),[A,C]=(0,r.useState)(null),S=!!s?.enable_stripe_topup,R=!!s?.enable_creem_topup,M=!!s?.enable_online_topup,F=(0,r.useMemo)(()=>(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.filter(e=>e?.type&&"stripe"!==e.type&&"creem"!==e.type)})(s?.pay_methods),[s?.pay_methods]),q=(0,r.useCallback)(async()=>{try{let e=await (0,e$.Ay)();e.success&&c(e.data||[])}catch{c([])}},[]),T=(0,r.useCallback)(async()=>{try{let e=await (0,e$.pK)();e.success&&e.data&&(g(e.data.billing_preference||"subscription_first"),d(e.data.subscriptions||[]),h(e.data.all_subscriptions||[]))}catch{}},[]);(0,r.useEffect)(()=>{(async()=>{b(!0),await Promise.all([q(),T()]),b(!1)})()},[q,T]);let O=async()=>{w(!0);try{await T()}finally{w(!1)}},H=async e=>{g(e);try{let s=await (0,e$.S$)(e);if(s.success){P.oR.success(i("Updated successfully"));let a=s.data?.billing_preference||e;g(a)}else P.oR.error(s.message||i("Update failed")),g(y)}catch{P.oR.error(i("Request failed")),g(y)}},W=o.length>0,B=m.length>0,L=j||l.length>0||B,J=!W,z="subscription_first"===y||"subscription_only"===y,I=J&&z?"wallet_first":y,U=(0,r.useMemo)(()=>{let e=new Map;for(let s of m){let a=s?.subscription?.plan_id;a&&e.set(a,(e.get(a)||0)+1)}return e},[m]);(0,r.useEffect)(()=>{a?.(L)},[L,a]);let D=(0,r.useMemo)(()=>{let e=new Map;for(let s of l)s?.plan?.id&&e.set(s.plan.id,s.plan.title||"");return e},[l]);return j?(0,t.jsxs)(x.Zp,{className:"gap-0 overflow-hidden py-0",children:[(0,t.jsx)(x.aR,{className:"border-b p-3 !pb-3 sm:p-5 sm:!pb-5",children:(0,t.jsx)(f.E,{className:"h-6 w-32"})}),(0,t.jsxs)(x.Wu,{className:"space-y-4 p-3 sm:p-5",children:[(0,t.jsx)(f.E,{className:"h-20 w-full"}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3",children:Array.from({length:3}).map((e,s)=>(0,t.jsx)(f.E,{className:"h-48 w-full"},s))})]})]}):0!==l.length||B?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(eb.f,{title:i("Subscription Plans"),description:i("Subscribe to a plan for model access"),icon:(0,t.jsx)(ek,{className:"h-4 w-4"}
2),contentClassName:"space-y-4 sm:space-y-5",children:[(0,t.jsxs)("div",{className:"rounded-xl border p-3 sm:p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2.5 sm:gap-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:i("My Subscriptions")}),(0,t.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium",children:[(0,t.jsx)("span",{className:(0,ej.cn)("size-1.5 shrink-0 rounded-full",W?E.jk.success:E.jk.neutral),"aria-hidden":"true"}),W?(0,t.jsxs)("span",{className:(0,ej.cn)(E.BQ.success),children:[o.length," ",i("active")]}):(0,t.jsx)("span",{className:"text-muted-foreground",children:i("No Active")}),m.length>o.length&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-muted-foreground/30",children:"·"}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[m.length-o.length," ",i("expired")]})]})]})]}),(0,t.jsxs)("div",{className:"flex w-full items-center gap-2 sm:w-auto",children:[(0,t.jsxs)($.l6,{items:[{value:"subscription_first",label:(0,t.jsxs)(t.Fragment,{children:[eT("subscription_first",i),J?` (${i("No Active")})`:""]})},{value:"wallet_first",label:eT("wallet_first",i)},{value:"subscription_only",label:(0,t.jsxs)(t.Fragment,{children:[eT("subscription_only",i),J?` (${i("No Active")})`:""]})},{value:"wallet_only",label:eT("wallet_only",i)}],value:I,onValueChange:e=>null!==e&&H(e),children:[(0,t.jsx)($.bq,{className:"h-8 flex-1 text-xs sm:w-[140px] sm:flex-none",children:(0,t.jsx)($.yv,{children:eT(I,i)})}),(0,t.jsx)($.gC,{alignItemWithTrigger:!1,children:(0,t.jsxs)($.s3,{children:[(0,t.jsxs)($.eb,{value:"subscription_first",disabled:J,children:[eT("subscription_first",i),J?` (${i("No Active")})`:""]}),(0,t.jsx)($.eb,{value:"wallet_first",children:eT("wallet_first",i)}),(0,t.jsxs)($.eb,{value:"subscription_only",disabled:J,children:[eT("subscription_only",i),J?` (${i("No Active")})`:""]}),(0,t.jsx)($.eb,{value:"wallet_only",children:eT("wallet_only",i)})]})})]}),(0,t.jsx)(p.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:O,disabled:v,children:(0,t.jsx)(eA.A,{className:`h-3.5 w-3.5 ${v?"animate-spin":""}`})})]})]}),J&&z&&(0,t.jsx)("p",{className:"text-muted-foreground mt-2 text-xs",children:i("Preference saved as {{pref}}, but no active subscription. Wallet will be used automatically.",{pref:"subscription_only"===y?i("Subscription Only"):i("Subscription First")})}),B&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eR.w,{className:"my-3"}),(0,t.jsx)("div",{className:"max-h-64 space-y-3 overflow-y-auto pr-1",children:m.map(e=>{let s,a,r,n=e.subscription,l=Number(n?.amount_total||0),c=Number(n?.amount_used||0),o=l>0?Math.max(0,l-c):0,d=D.get(n?.plan_id)||"",m=(s=e?.subscription?.end_time||0)?Math.max(0,Math.ceil((s-Date.now()/1e3)/86400)):0,p=(a=Number(e?.subscription?.amount_total||0),r=Number(e?.subscription?.amount_used||0),a<=0?0:Math.round(r/a*100)),x=Date.now()/1e3,h=(n?.end_time||0)<x,f=n?.status==="cancelled",y=n?.status==="active"&&!h;return(0,t.jsxs)("div",{className:"bg-background rounded-md border p-3 text-xs",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"font-medium",children:d?`${d} \xb7 ${i("Subscription")} #${n?.id}`:`${i("Subscription")} #${n?.id}`}),y?(0,t.jsx)(E.Wh,{label:i("Active"),variant:"success",copyable:!1}):f?(0,t.jsx)(E.Wh,{label:i("Cancelled"),variant:"neutral",copyable:!1}):(0,t.jsx)(E.Wh,{label:i("Expired"),variant:"neutral",copyable:!1})]}),y&&(0,t.jsx)("span",{className:"text-muted-foreground",children:i("{{count}} days remaining",{count:m})})]}),(0,t.jsxs)("div",{className:"text-muted-foreground mt-1.5",children:[y?i("Until"):f?i("Cancelled at"):i("Expired at")," ",new Date(1e3*(n?.end_time||0)).toLocaleString()]}),y&&(n?.next_reset_time??0)>0&&(0,t.jsxs)("div",{className:"text-muted-foreground mt-1",children:[i("Next reset"),":"," ",new Date(1e3*n.next_reset_time).toLocaleStr
2ing()]}),(0,t.jsxs)("div",{className:"text-muted-foreground mt-1",children:[i("Total Quota"),":"," ",l>0?(0,t.jsxs)(ev.m_,{children:[(0,t.jsxs)(ev.k$,{render:(0,t.jsx)("span",{className:"cursor-help"}),children:[(0,u.eN)(c),"/",(0,u.eN)(l)," · ",i("Remaining")," ",(0,u.eN)(o)]}),(0,t.jsxs)(ev.ZI,{children:[i("Raw Quota"),": ",c,"/",l," ·"," ",i("Remaining")," ",o]})]}):i("Unlimited"),l>0&&(0,t.jsxs)("span",{className:"ml-2",children:[i("Used")," ",p,"%"]})]}),l>0&&y&&(0,t.jsx)(eS.ke,{value:p,className:"mt-2 h-1.5"})]},n?.id)})})]}),!B&&(0,t.jsx)("p",{className:"text-muted-foreground mt-2 text-xs",children:i("Subscribe to a plan for model access")})]}),l.length>0?(0,t.jsx)("div",{className:"grid grid-cols-1 gap-3 2xl:grid-cols-2 2xl:gap-4",children:l.map((e,s)=>{let a=e?.plan;if(!a)return null;let r=Number(a.total_amount||0),n=Number(a.price_amount||0).toFixed(2),c=0===s&&l.length>1,o=Number(a.max_purchase_per_user||0),d=U.get(a.id)||0,m=o>0&&d>=o,h=[`${i("Validity Period")}: ${(0,eF.a3)(a,i)}`,(0,eF.ak)(a,i)!==i("No Reset")?`${i("Quota Reset")}: ${(0,eF.ak)(a,i)}`:null,r>0?`${i("Total Quota")}: ${(0,u.eN)(r)}`:`${i("Total Quota")}: ${i("Unlimited")}`,o>0?`${i("Purchase Limit")}: ${o}`:null,a.upgrade_group?`${i("Upgrade Group")}: ${a.upgrade_group}`:null].filter(Boolean);return(0,t.jsx)(x.Zp,{className:(0,ej.cn)("transition-shadow hover:shadow-md",c&&"border-primary/70 shadow-sm"),children:(0,t.jsxs)(x.Wu,{className:"flex h-full flex-col p-3.5 sm:p-4",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h4",{className:"truncate font-semibold",children:a.title||i("Subscription Plans")}),a.subtitle&&(0,t.jsx)("p",{className:"text-muted-foreground truncate text-xs",children:a.subtitle})]}),c&&(0,t.jsxs)(E.Wh,{variant:"info",copyable:!1,className:"shrink-0",children:[(0,t.jsx)(eC.A,{className:"h-3 w-3"}),i("Recommended")]})]}),(0,t.jsx)("div",{className:"py-2",children:(0,t.jsxs)("span",{className:"text-primary text-2xl font-bold",children:["$",n]})}),(0,t.jsx)("div",{className:"flex-1 space-y-1.5 pb-3",children:h.map(e=>(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2 text-xs",children:[(0,t.jsx)(N.A,{className:"text-primary h-3 w-3 shrink-0"}),(0,t.jsx)("span",{children:e})]},e))}),(0,t.jsx)(eR.w,{className:"mb-3"}),m?(0,t.jsxs)(ev.m_,{children:[(0,t.jsx)(ev.k$,{render:(0,t.jsx)("div",{}),children:(0,t.jsx)(p.$,{variant:"outline",className:"w-full",disabled:!0,children:i("Limit Reached")})}),(0,t.jsxs)(ev.ZI,{children:[i("Purchase limit reached")," (",d,"/",o,")"]})]}):(0,t.jsx)(p.$,{variant:"outline",className:"w-full",onClick:()=>{C(e),k(!0)},children:i("Subscribe Now")})]})},a.id)})}):(0,t.jsx)("p",{className:"text-muted-foreground py-4 text-center text-sm",children:i("No plans available")})]}),(0,t.jsx)(eq,{open:_,onOpenChange:e=>{k(e),e||T()},plan:A,enableStripe:S,enableCreem:R,enableOnlineTopUp:M,epayMethods:F,purchaseLimit:A?.plan?.max_purchase_per_user?Number(A.plan.max_purchase_per_user):void 0,purchaseCount:A?.plan?.id?U.get(A.plan.id):void 0})]}):null}var eH=a(9342),eW=a(14302);function eB(e){let{t:s}=(0,n.Bd)();if(e.loading)return(0,t.jsx)("div",{className:"overflow-hidden rounded-lg border",children:(0,t.jsx)("div",{className:"divide-border/60 grid grid-cols-3 divide-x",children:Array.from({length:3}).map((e,s)=>(0,t.jsxs)("div",{className:"px-3 py-3 sm:px-5 sm:py-4",children:[(0,t.jsx)(f.E,{className:"h-3.5 w-20"}),(0,t.jsx)(f.E,{className:"mt-2 h-7 w-28"}),(0,t.jsx)(f.E,{className:"mt-1.5 h-3.5 w-24"})]},s))})});let a=[{label:s("Current Balance"),value:(0,u.eN)(e.user?.quota??0),description:s("Remaining quota"),icon:eh.A},{label:s("Total Usage"),value:(0,u.eN)(e.user?.used_quota??0),description:s("Total consumed quota"),icon:eH.A},{label:s("API Requests"),value:(e.user?.request_count??0).toLocaleString(),description:s("Total requests made"),icon:eW.A}];return(0,t.jsx)("div",{className:"overflow-hidden rounded-lg border",children:(0,t.jsx)("div",{className:"divide-border/60 grid grid-cols-3 divide-x",children:a.map(e=>(0,t.jsxs)("div",{className:"px-3 py-3 sm:px-5 sm:py-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(e.icon,{className:"text-muted-foreground
2/60 size-3.5 shrink-0"}),(0,t.jsx)("div",{className:"text-muted-foreground truncate text-xs font-medium tracking-wider uppercase",children:e.label})]}),(0,t.jsx)("div",{className:"text-foreground mt-1.5 font-mono text-base font-bold tracking-tight break-all tabular-nums sm:mt-2 sm:text-2xl",children:e.value}),(0,t.jsx)("div",{className:"text-muted-foreground/60 mt-1 hidden text-xs md:block",children:e.description})]},e.label))})})}function eL(e){if(Array.isArray(e))return e;if("string"==typeof e)try{let s=JSON.parse(e);return Array.isArray(s)?s:[]}catch{}return[]}function eJ(e){let{t:s}=(0,n.Bd)(),[a,d]=(0,r.useState)(null),[m,p]=(0,r.useState)(!0),[x,h]=(0,r.useState)(0),[f,y]=(0,r.useState)(null),[j,N]=(0,r.useState)(),[b,v]=(0,r.useState)(null),[w,_]=(0,r.useState)(!1),[A,C]=(0,r.useState)(!1),[S,R]=(0,r.useState)(!1),[$,E]=(0,r.useState)(""),[F,Z]=(0,r.useState)(!1),[Q,G]=(0,r.useState)(null),[Y,K]=(0,r.useState)(!0),{status:ee}=(0,l.s)(),{currency:es}=(0,c.R)(),{topupInfo:ec,presetAmounts:eo,loading:ed}=function(){let[e,s]=(0,r.useState)(null),[a,t]=(0,r.useState)([]),[n,i]=(0,r.useState)(!0),l=async()=>{try{var e,a,r,n,l,c,o,d;i(!0);let m=await T();if(!m.success||!m.data)return void console.error("Failed to fetch topup info:",m.message);let u={...m.data,pay_methods:(e=m.data.pay_methods,a=m.data.stripe_min_topup,eL(e).filter(e=>!!e&&"object"==typeof e).map(e=>{let s=Number(e.min_topup),t=Number.isFinite(s)?s:0,r="string"==typeof e.type?e.type:"";return{name:"string"==typeof e.name?e.name:"",type:r,color:"string"==typeof e.color?e.color:void 0,min_topup:"stripe"===r&&t<=0?a:t}}).filter(e=>e.name&&e.type&&"waffo"!==e.type)),amount_options:(r=m.data.amount_options,eL(r).map(e=>Number(e)).filter(e=>Number.isFinite(e)&&e>0)),discount:function(e){if(!e)return{};let s=e;if("string"==typeof e)try{s=JSON.parse(e)}catch{return{}}return!s||"object"!=typeof s||Array.isArray(s)?{}:Object.entries(s).reduce((e,s)=>{let[a,t]=s,r=Number(a),n=Number(t);return Number.isFinite(r)&&Number.isFinite(n)&&(e[r]=n),e},{})}(m.data.discount),creem_products:(n=m.data.creem_products,eL(n).filter(e=>!!e&&"object"==typeof e).map(e=>{let s="EUR"===e.currency?"EUR":"USD";return{name:"string"==typeof e.name?e.name:"",productId:"string"==typeof e.productId?e.productId:"",price:Number(e.price)||0,quota:Number(e.quota)||0,currency:s}}).filter(e=>e.name&&e.productId)),waffo_pay_methods:(l=m.data.waffo_pay_methods,eL(l).filter(e=>!!e&&"object"==typeof e).map(e=>({name:"string"==typeof e.name?e.name:"",icon:"string"==typeof e.icon?e.icon:void 0,payMethodType:"string"==typeof e.payMethodType?e.payMethodType:void 0,payMethodName:"string"==typeof e.payMethodName?e.payMethodName:void 0})).filter(e=>e.name))};if(s(u),u.amount_options.length>0){let e=(c=u.amount_options,o=u.discount||{},c&&0!==c.length?c.map(e=>({value:e,discount:o[e]||1})):[]);t(e)}else{let e=(d=el(u),et.r0.map(e=>({value:d*e})));t(e)}}catch(e){console.error("Failed to fetch topup info:",e)}finally{i(!1)}};return(0,r.useEffect)(()=>
2{l()},[]),{topupInfo:e,presetAmounts:a,loading:n,refetch:l}}(),em=(0,r.useMemo)(()=>es?.quotaDisplayType==="USD"?1:es?.usdExchangeRate||1,[es?.quotaDisplayType,es?.usdExchangeRate]),{amount:eu,calculating:eh,processing:ef,calculatePaymentAmount:ey,processPayment:eg}=function(){let[e,s]=(0,r.useState)(0),[a,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)(!1);return{amount:e,calculating:a,processing:n,calculatePaymentAmount:(0,r.useCallback)(async(e,a)=>{try{t(!0);let r=er(a),n=en(a),i=r?await W({amount:e}):n?await I({amount:e}):await H({amount:e});if(q(i)&&i.data){let e=parseFloat(i.data);return s(e),e}return s(0),0}catch(e){return s(0),0}finally{t(!1)}},[]),processPayment:(0,r.useCallback)(async(e,s)=>{try{i(!0);let t=er(s),r=Math.floor(e),n=t?await L({amount:r,payment_method:"stripe"}):await B({amount:r,payment_method:s});if(!q(n))return P.oR.error(n.message||M.Ay.t("Payment request failed")),!1;if(t&&n.data?.pay_link)return window.open(n.data.pay_link,"_blank"),P.oR.success(M.Ay.t("Redirecting to payment page...")),!0;if(!t&&n.data){let e=n.url;if(e){var a;let s;return a=n.data,(s=document.createElement("form")).action=e,s.method="POST",navigator.userAgent.indexOf("Safari")>-1&&1>navigator.userAgent.indexOf("Chrome")||(s.target="_blank"),Object.entries(a).forEach(e=>{let[a,t]=e,r=document.createElement("input");r.type="hidden",r.name=a,r.value=String(t),s.appendChild(r)}),document.body.appendChild(s),s.submit(),document.body.removeChild(s),P.oR.success(M.Ay.t("Redirecting to payment page...")),!0}}return!1}catch(e){return P.oR.error(M.Ay.t("Payment request failed")),!1}finally{i(!1)}},[]),setAmount:s}}(),{affiliateLink:ej,loading:eN,transferQuota:eb,transferring:ev}=function(){let[e,s]=(0,r.useState)(""),[a,t]=(0,r.useState)(""),[n,l]=(0,r.useState)(!0),[c,o]=(0,r.useState)(!1),{copyToClipboard:d}=(0,k.C)(),m=(0,r.useCallback)(async()=>{try{l(!0);let a=await D();if(a.success&&a.data){var e;s(a.data);let r=(e=a.data,"u"<typeof window?"":`${window.location.origin}/register?aff=${e}`);t(r)}}catch(e){console.error("Failed to fetch affiliate code:",e)}finally{l(!1)}},[]),u=(0,r.useCallback)(()=>{d(a)},[a,d]),p=(0,r.useCallback)(async e=>{try{o(!0);let s=await V({quota:e});if(s.success)return P.oR.success(s.message||M.Ay.t("Transfer successful")),await (0,i.Ng)(),!0;return P.oR.error(s.message||M.Ay.t("Transfer failed")),!1}catch(e){return P.oR.error(M.Ay.t("Transfer failed")),!1}finally{o(!1)}},[]);return(0,r.useEffect)(()=>{m()},[m]),{affiliateCode:e,affiliateLink:a,loading:n,transferring:c,copyAffiliateLink:u,transferQuota:p,refetch:m}}(),{redeeming:ew,redeemCode:ek}=function(){let[e,s]=(0,r.useState)(!1);return{redeeming:e,redeemCode:(0,r.useCallback)(async e=>{if(!e||""===e.trim())return P.oR.error(M.Ay.t("Please enter a redemption code")),!1;try{s(!0);let a=await O({key:e});if(a.success&&a.data){let e=a.data;return P.oR.success(M.Ay.t("Redemption successful! Added: {{quota}}",{quota:(0,u.eN)(e)})),await (0,i.Ng)(),!0}return P.oR.error(a.message||M.Ay.t("Redemption failed")),!1}catch(e){return P.oR.error(M.Ay.t("Redemption failed")),!1}finally{s(!1)}},[])}}(),{processing:eA,processCreemPayment:eC}=function(){let[e,s]=(0,r.useState)(!1);return{processing:e,processCreemPayment:(0,r.useCallback)(async e=>{s(!0);try{let s=await J({product_id:e,payment_method:"creem"});if(q(s)&&s.data?.checkout_url)return window.open(s.data.checkout_url,"_blank"),P.oR.success(M.Ay.t("Redirecting to Creem checkout...")),!0;return P.oR.error(s.message||M.Ay.t("Payment request failed")),!1}catch(e){return P.oR.error(M.Ay.t("Payment request failed")),!1}finally{s(!1)}},[])}}(),{processWaffoPayment:eS}=function(){let[e,s]=(0,r.useState)(!1);return{processing:e,processWaffoPayment:(0,r.useCallback)(async(e,a)=>{s(!0);try{var t,r,n;let s=await z({amount:Math.floor(e),pay_method_index:a});if(q(s)){let e=(t=s.data)&&"object"==typeof t&&"payment_url"in t&&"string"==typeof t.payment_url?t.payment_url:null;if(e)return window.open(e,"_blank"),P.oR.success(M.Ay.t("Redirecting to payment page...")),!0}return P.oR.error((r=s.message,n=s.data,"string"==typeof n&&n.trim()?n:r||M.Ay.t("Payment request failed"))),!1}catch(e){return P.oR.error(M.Ay.t("Payment request failed")),!1}finally{s(!1)}},[])}}(),{processing:eR,processWaffoPancakePayment:e$}=function(){let[e,s]=(0,r.useState)(!1);return{processing:e,processWaffoPancakePayment:(0,r.useCallback)(async e=>{s(!0);try{var a,t,r;let s=await U({amount:Math.floor(e)});if(q(s)){let e=(a=s.data)&&"object"==typeof a&&"checkout_url"in a&&"string"==typeof a.checkout_url?a.checkout_url:null;if(e){if(!function(e){let s=e.trim();if(!s)return!1;try{let e=new URL(s);return"http:"===e.protocol||"https:"===e.protocol}catch{return!1}}(e))return P.oR.error(M.Ay.t("Invalid payment redirect URL")),!1;return window.open(e,"_blank","noopener,noreferrer"),P.oR.success(M.Ay.t("Redirecting to payment page...")),!0}}return P.oR.error((t=s.message,r=s.data,"string"==typeof r&&r.trim()?r:t||M.Ay.t("Payment request failed"))),!1}catch(e){return P.oR.error(M.Ay.t("Payment request failed")),!1}finally{s(!1)}},[])}}(),eE=(0,r.useCallback)(async()=>{try{p(!0);let e=await (0,i.Ng)();e.success&&e.data&&d(e.data)}catch(e){console.error("Failed to fetch user data:",e)}finally{p(!1)}},[]);(0,r.useEffect)(()=>{eE()},[eE]),(0,r.useEffect)(()=>{e.initialShowHistory&&(R(!0),window.history.replaceState({},"",window.location.pathname))},[e.initialShowHistory]),(0,r.useEffect)(()=>
2{if(ec&&0===x){let e=el(ec);h(e),ey(e,ei(ec))}},[ec,x,ey]);let eM=(0,r.useCallback)(()=>j?.type||ei(ec),[j,ec]),eP=async e=>{N(e),v(e.type);try{let s=el(ec);if(x<s)return;await ey(x,e.type),_(!0)}finally{v(null)}},eF=async()=>{!j||(en(j.type)?await e$(x):await eg(x,j.type))&&(_(!1),await eE())},eq=async()=>{!$||await ek($)&&(E(""),await eE())},eT=async e=>{let s=await eb(e);return s&&await eE(),s},eH=async()=>{!Q||await eC(Q.productId)&&(Z(!1),G(null),await eE())},eW=async(e,s)=>{v(`waffo-${s}`);try{await eS(x,s)}finally{v(null)}},eJ=(0,r.useCallback)(()=>ec?.discount?.[x]||1,[ec,x]),ez=(0,r.useCallback)(e=>{K(e)},[]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(o.Ni,{children:[(0,t.jsx)(o.Ni.Title,{children:s("Wallet")}),(0,t.jsx)(o.Ni.Description,{children:s("Manage your balance and payment methods")}),(0,t.jsx)(o.Ni.Content,{children:(0,t.jsxs)("div",{className:"mx-auto flex w-full max-w-7xl flex-col gap-4 sm:gap-5",children:[(0,t.jsx)(eB,{user:a,loading:m}),(0,t.jsxs)("div",{className:Y?"grid gap-4 xl:grid-cols-[minmax(0,1.05fr)_minmax(360px,0.95fr)] xl:items-start":"grid gap-4",children:[(0,t.jsx)("div",{id:"wallet-add-funds",className:"scroll-mt-4",children:(0,t.jsx)(e_,{topupInfo:ec,presetAmounts:eo,selectedPreset:f,onSelectPreset:e=>{h(e.value),y(e.value),ey(e.value,eM())},topupAmount:x,onTopupAmountChange:e=>{h(e),y(null),ey(e,eM())},paymentAmount:eu,calculating:eh,onPaymentMethodSelect:eP,paymentLoading:b,redemptionCode:$,onRedemptionCodeChange:E,onRedeem:eq,redeeming:ew,topupLink:ec?.topup_link,loading:ed,priceRatio:ee?.price||1,usdExchangeRate:em,onOpenBilling:()=>R(!0),creemProducts:ec?.creem_products,enableCreemTopup:ec?.enable_creem_topup,onCreemProductSelect:e=>{G(e),Z(!0)},enableWaffoTopup:ec?.enable_waffo_topup,waffoPayMethods:ec?.waffo_pay_methods,waffoMinTopup:ec?.waffo_min_topup,onWaffoMethodSelect:eW,enableWaffoPancakeTopup:ec?.enable_waffo_pancake_topup})}),(0,t.jsx)(eO,{topupInfo:ec,onAvailabilityChange:ez})]}),(0,t.jsx)(g,{user:a,affiliateLink:ej,onTransfer:()=>C(!0),loading:eN})]})})]}),(0,t.jsx)(ep,{open:w,onOpenChange:_,onConfirm:eF,topupAmount:x,paymentAmount:eu,paymentMethod:j,calculating:eh,processing:ef||eR,discountRate:eJ(),usdExchangeRate:em}),(0,t.jsx)(ex,{open:A,onOpenChange:C,onConfirm:eT,availableQuota:a?.aff_quota??0,transferring:ev}),(0,t.jsx)(X,{open:S,onOpenChange:R}),(0,t.jsx)(ea,{open:F,onOpenChange:Z,onConfirm:eH,product:Q,processing:eA})]})}var ez=a(82887);function eI(){let{show_history:e}=ez.q.useSearch();return(0,t.jsx)(eJ,{initialShowHistory:e})}}}]);

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.