PageSourceSearch

https://starrycbz-newapi.hf.space/static/js/async/6618.820cd02fd7.js

js starrycbz-newapi.hf.space collected 2026-10-04 17:27:41 UTC 70,253 bytes, 2 lines download raw bytes

1/*! LICENSE: 6618.820cd02fd7.js.LICENSE.txt */
2"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[6618],{92170(e,a,s){s.d(a,{i:()=>u});var t=s(72361),r=s(67834),n=s(99893),i=s(6702),l=s(81204),c=s(52606),o=s(46775),d=s(34126);function u(e){let{value:a,children:s,className:u,iconClassName:m,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===a,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",u),onClick:()=>N(a),"aria-label":b?_:y??v,children:[b?(0,t.jsx)(r.A,{className:(0,l.cn)("text-success",m)}):(0,t.jsx)(n.A,{className:(0,l.cn)(m)}),s]});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}},38525(e,a,s){s.d(a,{d:()=>l});var t=s(72361),r=s(6702),n=s(81204),i=s(3088);function l(e){var a;let{t:s}=(0,r.Bd)(),{group:l,label:c,ratio:o,copyable:d=!1,showDot:u,...m}=e,p=l?.trim(),x="auto"===p,h=!p,f=x||h,y=(a={labelOverride:c,groupName:p,isAutoGroup:x,isEmptyGroup:h,t:s}).labelOverride?a.labelOverride:a.isEmptyGroup?a.t("User Group"):a.isAutoGroup?a.t("Auto"):a.groupName??"",g=(0,t.jsx)(i.Wh,{...m,copyable:d,label:y,showDot:u??(!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.jsx)("span",{className:(0,n.cn)("inline-flex h-5 items-center rounded-full px-1.5 font-mono text-xs leading-none font-medium tabular-nums",o>1?"bg-warning/10 text-warning":o<1?"bg-info/10 text-info":"bg-muted text-muted-foreground"),children:(0,t.jsxs)("span",{children:[o,"x"]})})]})}},40758(e,a,s){s.d(a,{f:()=>i});var t=s(72361),r=s(81204),n=s(31005);function i(e){let{title:a,description:s,icon:i,action:l,children:c,className:o,headerClassName:d,contentClassName:u,iconClassName:m,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",m),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:a}),null!=s&&(0,t.jsx)(n.BT,{className:(0,r.cn)("text-xs sm:text-sm",x),children:s})]})]}),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",u),children:c})]})}},48144(e,a,s){s.d(a,{Ax:()=>h,Ay:()=>N,DG:()=>f,OX:()=>r,S$:()=>b,dW:()=>m,dh:()=>g,eW:()=>u,f:()=>v,gY:()=>d,l7:()=>o,mB:()=>p,oV:()=>l,pK:()=>j,qL:()=>c,qT:()=>n,td:()=>i,y8:()=>x,zE:()=>y});var t=s(64577);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,a){return(await t.FH.put(`/api/subscription/admin/plans/${e}`,a)).data}async function l(e,a){return(await t.FH.patch(`/api/subscription/admin/plans/${e}`,{enabled:a})).data}async function c(e){return(await t.FH.get(`/api/subscription/admin/users/${e}/subscriptions`)).data}async function o(e,a){return(await t.FH.post(`/api/subscription/admin/users/${e}/subscriptions`,a)).data}async function d(e){return(await t.FH.post(`/api/subscription/admin/user_subscriptions/${e}/invalidate`)).data}async function u(e){return(await t.FH.delete(`/api/subscription/admin/user_subscriptions/${e}`)).data}async function m(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){return(await t.FH.post("/api/subscription/waffo-pancake/
2pay",e)).data}async function h(e){return(await t.FH.post("/api/subscription/balance/pay",e)).data}async function f(e){return(await t.FH.post("/api/option/waffo-pancake/subscription-product",e)).data}async function y(){return(await t.FH.post("/api/option/waffo-pancake/subscription-product-options")).data}async function g(e){let a=await t.FH.post("/api/subscription/epay/pay",e);return{...a.data,url:a.data.url||a.url}}async function j(){return(await t.FH.get("/api/subscription/self")).data}async function N(){return(await t.FH.get("/api/subscription/plans")).data}async function b(e){return(await t.FH.put("/api/subscription/self/preference",{billing_preference:e})).data}async function v(){return(await t.FH.get("/api/group")).data}},78930(e,a,s){s.d(a,{sX:()=>u,Hc:()=>p,a3:()=>r,ak:()=>n,Ey:()=>i,vD:()=>d,jy:()=>m});var t=s(37936);function r(e,a){let s=e?.duration_unit||"month",t=e?.duration_value||1,r={year:a("years"),month:a("months"),day:a("days"),hour:a("hours"),custom:a("Custom (seconds)")};if("custom"===s){let s=e?.custom_seconds||0;return s>=86400?`${Math.floor(s/86400)} ${a("days")}`:s>=3600?`${Math.floor(s/3600)} ${a("hours")}`:`${s} ${a("seconds")}`}return`${t} ${r[s]||s}`}function n(e,a){let s=e?.quota_reset_period||"never";if("daily"===s)return a("Daily");if("weekly"===s)return a("Weekly");if("monthly"===s)return a("Monthly");if("custom"===s){let s=Number(e?.quota_reset_custom_seconds||0);return s>=86400?`${Math.floor(s/86400)} ${a("days")}`:s>=3600?`${Math.floor(s/3600)} ${a("hours")}`:s>=60?`${Math.floor(s/60)} ${a("minutes")}`:`${s} ${a("seconds")}`}return a("No Reset")}function i(e){return e?(0,t.A)(1e3*e).format("YYYY-MM-DD HH:mm:ss"):"-"}var l=s(25732),c=s(63859),o=s(3642);function d(e){return l.Ik({title:l.Yj().min(1,e("Please enter plan title")),subtitle:l.Yj().optional(),price_amount:c.ai().min(0,e("Please enter amount")),duration_unit:l.k5(["year","month","day","hour","custom"]),duration_value:c.ai().min(1),custom_seconds:c.ai().min(0).optional(),quota_reset_period:l.k5(["never","daily","weekly","monthly","custom"]),quota_reset_custom_seconds:c.ai().min(0).optional(),enabled:l.zM(),sort_order:c.ai(),allow_balance_pay:l.zM(),max_purchase_per_user:c.ai().min(0),total_amount:c.ai().min(0),upgrade_group:l.Yj().optional(),stripe_price_id:l.Yj().optional(),creem_product_id:l.Yj().optional(),waffo_pancake_product_id:l.Yj().optional()})}let u={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,allow_balance_pay:!0,max_purchase_per_user:0,total_amount:0,upgrade_group:"",stripe_price_id:"",creem_product_id:"",waffo_pancake_product_id:""};function m(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),allow_balance_pay:!1!==e.allow_balance_pay,max_purchase_per_user:Number(e.max_purchase_per_user||0),total_amount:(0,o.Sh)(Number(e.total_amount||0)),upgrade_group:e.upgrade_group||"",stripe_price_id:e.stripe_price_id||"",creem_product_id:e.creem_product_id||"",waffo_pancake_product_id:e.waffo_pancake_product_id||""}}function p(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:(0,o.dD)(Number(e.total_amount||0)),upgrade_group:e.upgrade_group||""}}}},26423(e,a,s){s.d(a,{h:()=>n});var t=s(20032),r=s(29760);function n(){let{user:e}=(0,t.n)(e=>e.auth);return(e?.role??0)>=r.z7.ADMIN}},47137(e,a,s){s.r(a),s.d(a,{component:()=>eJ});var t=s(72361),r=s(68413),n=s(6702),i=s(64577),l=s(30464),c=s(38610),o=s(86368),d=s(9781);let u=(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 m=s(3642),p=s(46775),x=s(31005),h=s(54023),f=s(18434),y=s(92170);function g(e){let{user:a,affiliateLink:s,onTransfer:r,complianceConfirmed:i=!0,loading:l}=e,{t:c}=(0,n.Bd)();if(l)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"})]}
2),(0,t.jsx)(f.E,{className:"h-14 rounded-lg"}),(0,t.jsx)(f.E,{className:"h-10 rounded-lg"})]})});let o=(a?.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)(u,{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:c("Referral Program")}),(0,t.jsx)("p",{className:"text-muted-foreground line-clamp-1 text-xs",children:c("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:[[c("Pending"),(0,m.eN)(a?.aff_quota??0)],[c("Total Earned"),(0,m.eN)(a?.aff_history_quota??0)],[c("Invites"),String(a?.aff_count??0)]].map(e=>{let[a,s]=e;return(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground truncate text-[10px] font-medium tracking-wider uppercase",children:a}),(0,t.jsx)("div",{className:"mt-0.5 truncate text-sm font-semibold tabular-nums",children:s})]},a)})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(h.p,{value:s,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:s,variant:"outline",className:"bg-background size-9 shrink-0",iconClassName:"size-4",tooltip:c("Copy referral link"),"aria-label":c("Copy referral link")}),o&&(0,t.jsx)(p.$,{onClick:r,disabled:!i,className:"h-9 shrink-0 px-3",size:"sm",children:c("Transfer to Balance")})]}),i?null:(0,t.jsx)("p",{className:"text-muted-foreground text-xs lg:col-span-3",children:c("Referral reward transfer is disabled until the administrator confirms compliance terms.")})]})})}var j=s(38766),N=s(67834),b=s(99893),v=s(24623),w=s(63162),_=s(52946),k=s(52606),A=s(18692),C=s(1755),S=s(61309),R=s(3676),P=s(82243),$=s(3088),M=s(19376),E=s(20598),F=s(26423);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 H(e){return(await i.FH.post("/api/user/topup",e)).data}async function O(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 a=await i.FH.post("/api/user/pay",e,{skipBusinessError:!0});return{...a.data,url:a.data.url||a.url}}async function L(e){return(await i.FH.post("/api/user/stripe/pay",e,{skipBusinessError:!0})).data}async function z(e){return(await i.FH.post("/api/user/creem/pay",e,{skipBusinessError:!0})).data}async function I(e){return(await i.FH.post("/api/user/waffo/pay",e,{skipBusinessError:!0})).data}async function U(e){return(await i.FH.post("/api/user/waffo-pancake/amount",e,{skipBusinessError:!0})).data}async function J(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,a,s){let t=new URLSearchParams({p:e.toString(),page_size:a.toString()});return s&&t.append("keyword",s),(await i.FH.get(`/api/user/topup/self?${t.toString()}`)).data}async function Y(e,a,s){let t=new URLSearchParams({p:e.toString(),page_size:a.toString()});return s&&t.append("keyword",s),(await i.FH.get(`/api/user/topup?${t.toString()}`)).data}async function Q(e){return(await i.FH.post("/api/user/topup/complete",e)).data}let G={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:a,onOpenChange:s}=e,{t:i}=(0,n.Bd)(),{records:l,total:c,page:o,pageSize:d,keyword:u,loading:x,completing:y,isAdmin:g,handlePageChange:T,handlePageSizeChange:H,handleSearch:O,handleCompleteOrder:W}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{initialPage:a=1,initialPageSize:s=10}=e,t=(0,F.h)(),[n,i]=(0,r.useState)([]),[l,c]=(0,r.useState)(0),[o,d]=(0,r.useState)(a),[u,m]=(0,r.useState)(s),[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 Y(o,u,p):await Z(o,u,p);q(e)&&e.data?(i(e.data.items||[]),c(e.data.total||0)):(E.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),E.oR.error(M.Ay.t("Failed to load billing history")),i([]),c(0)}finally{f(!1)}},[t,o,u,p]),N=(0,r.useCallback)(async e=>{if(!t)return E.oR.error(M.Ay.t("Admin access required")),!1;g(!0);try{let a=await Q({trade_no:e});if(q(a))return E.oR.success(M.Ay.t("Order completed successfully")),await j(),!0;return E.oR.error(a.message||M.Ay.t("Failed to complete order")),!1}catch(e){return console.error("Failed to complete order:",e),E.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=>{m(e),d(1)},[]),w=(0,r.useCallback)(e=>{x(e),d(1)},[]);return(0,r.useEffect)(()=>{j()},[j]),{records:n,total:l,page:o,pageSize:u,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:z,copiedText:I}=(0,k.C)({notify:!1}),U=Math.ceil(c/d),J=async()=>{B&&await W(B)&&L(null)};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(C.lG,{open:a,onOpenChange:s,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:u,onChange:e=>O(e.target.value),className:"h-9 pl-10"})]}),(0,t.jsxs)(P.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&&H(parseInt(e)),children:[(0,t.jsx)(P.bq,{className:"h-9 w-[92px] sm:w-32",children:(0,t.jsx)(P.yv,{})}),(0,t.jsx)(P.gC,{alignItemWithTrigger:!1,children:(0,t.jsxs)(P.s3,{children:[(0,t.jsx)(P.eb,{value:"10",children:i("10 / page")}),(0,t.jsx)(P.eb,{value:"20",children:i("20 / page")}),(0,t.jsx)(P.eb,{value:"50",children:i("50 / page")}),(0,t.jsx)(P.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,a)=>(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"})]})]},a))}):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 foun
2d")}),(0,t.jsx)("p",{className:"mt-1 text-xs",children:u?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 a,s;let r,n=G[e.status]||G.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:()=>z(e.trade_no),children:I===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)($.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:(a=e.create_time,(0,m.fk)(a))})]}),(0,t.jsx)($.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:(s=e.payment_method,r=K[s]||s,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,m.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:U})]}),(0,t.jsx)(p.$,{variant:"outline",size:"sm",onClick:()=>T(o+1),disabled:o>=U,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 with 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:J,disabled:y,children:y?i("Processing..."):i("Confirm")})]})]})})]})}var ee=s(55724),ea=s(42324);function es(e){let{open:a,onOpenChange:s,onConfirm:r,product:i,processing:l}=e,{t:c}=(0,n.Bd)();return i?(0,t.jsx)(C.lG,{open:a,onOpenChange:s,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,ea.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,m.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:()=>s(!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=s(99198);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>
20?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=s(97808);let eo=(0,d.A)("landmark",[["path",{d:"M10 18v-7",key:"wt116b"}],["path",{d:"M11.119 2.205a2 2 0 0 1 1.762 0l7.84 3.846A.5.5 0 0 1 20.5 7h-17a.5.5 0 0 1-.22-.949z",key:"yxxwt6"}],["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=s(93610);let eu="u">typeof globalThis&&"location"in globalThis;function em(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"h-4 w-4",s=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,n=function(e){let a;if(!e)return null;let s=e.trim();if(!s)return null;try{a=eu?new URL(s,globalThis.location.href):new URL(s)}catch{return null}return"http:"!==a.protocol&&"https:"!==a.protocol||a.username||a.password?null:a.toString()}(s);if(n)return(0,t.jsx)("img",{src:n,alt:r||e||"payment",className:a,style:{objectFit:"contain"},loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"});if(!e)return(0,t.jsx)(ec.A,{className:a});switch(e){case et.J1.ALIPAY:return(0,t.jsx)(ed.n4U,{className:a,style:{color:et.mi[et.J1.ALIPAY]}});case et.J1.WECHAT:return(0,t.jsx)(ed.tnV,{className:a,style:{color:et.mi[et.J1.WECHAT]}});case et.J1.STRIPE:return(0,t.jsx)(ed.kDV,{className:a,style:{color:et.mi[et.J1.STRIPE]}});case et.J1.CREEM:return(0,t.jsx)(eo,{className:a,style:{color:et.mi[et.J1.CREEM]}});case et.J1.WAFFO:return(0,t.jsx)(ec.A,{className:a,style:{color:et.mi[et.J1.WAFFO]}});case et.J1.WAFFO_PANCAKE:return(0,t.jsxs)("span",{className:`inline-flex items-center justify-center leading-none ${a}`,style:{transform:"scale(2)"},children:[(0,t.jsx)("img",{src:"/waffo-logo-light.svg",alt:M.Ay.t("Waffo"),className:"block h-full w-full object-contain dark:hidden"}),(0,t.jsx)("img",{src:"/waffo-logo-dark.svg",alt:M.Ay.t("Waffo"),className:"hidden h-full w-full object-contain dark:block"})]});default:return(0,t.jsx)(ec.A,{className:a})}}function ep(e){let{open:a,onOpenChange:s,onConfirm:r,topupAmount:i,paymentAmount:l,paymentMethod:c,calculating:o,processing:d,discountRate:u=1,usdExchangeRate:m=1}=e,{t:p}=(0,n.Bd)(),x=u>0&&u<1&&l>0,h=x?l/u:0,y=x?h-l:0;return(0,t.jsx)(A.Lt,{open:a,onOpenChange:s,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*m,{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,ea.vv)(l)}),x&&(0,t.jsx)("span",{className:"text-muted-foreground text-sm line-through",children:(0,ea.vv)(h)})]})]}),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,ea.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:[em(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:a,onOpenChange:s,onConfirm:i,availableQuota:l,transferring:c}=e,{t:o}=(0,n.Bd)(),[d,u]=(0,r.useState)(5e5);(0,r.useEffect)(()=>{a&&u(5e5)},[a]);let x=async()=>{await i(d)&&s(!1)};return(0,t.jsx)(C.lG,{open:a,onOpenChange:s,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 up
2percase",children:o("Available Rewards")}),(0,t.jsx)("div",{className:"text-2xl font-semibold",children:(0,m.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=>u(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,m.eN)(5e5)]})]})]}),(0,t.jsxs)(C.Es,{className:"grid grid-cols-2 gap-2 sm:flex",children:[(0,t.jsx)(p.$,{variant:"outline",onClick:()=>s(!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=s(567);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=s(66552),ej=s(81204),eN=s(77405),eb=s(40758),ev=s(34126);function ew(e){let{products:a,onProductSelect:s,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,a)=>(0,t.jsx)(f.E,{className:"h-24 rounded-lg"},a))}):Array.isArray(a)&&0!==a.length?(0,t.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-2 sm:gap-3 md:grid-cols-3",children:a.map(e=>
2(0,t.jsx)(x.Zp,{className:"hover:border-foreground/50 cursor-pointer transition-all hover:shadow-md",onClick:()=>s(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,m.ZV)(e.quota)]}),(0,t.jsx)("div",{className:"text-lg font-semibold text-indigo-600",children:(0,ea.Bg)(e.price,e.currency)})]})},e.productId))}):null}function e_(e){let{topupInfo:a,presetAmounts:s,selectedPreset:i,onSelectPreset:l,topupAmount:c,onTopupAmountChange:o,paymentAmount:d,calculating:u,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:P,onCreemProductSelect:$,enableWaffoTopup:M,waffoPayMethods:E,waffoMinTopup:F,onWaffoMethodSelect:q,enableWaffoPancakeTopup:T}=e,{t:H}=(0,n.Bd)(),[O,W]=(0,r.useState)(c.toString());(0,r.useEffect)(()=>{W(c.toString())},[c]);let B=a?.enable_online_topup||a?.enable_stripe_topup||M||T,L=B||P,z=Array.isArray(a?.pay_methods)&&a.pay_methods.length>0,I=Array.isArray(E)&&E.length>0,U=el(a),J=a?.enable_redemption!==!1;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,a)=>(0,t.jsx)(f.E,{className:"h-[72px] rounded-lg"},a))})]}),(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,a)=>(0,t.jsx)(f.E,{className:"h-10 w-24 rounded-lg"},a))})]})]}),(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:H("Add Funds"),description:H("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"}),H("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:[s.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:H("Amount")}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-1.5 sm:gap-3 md:grid-cols-4",children:s.map((e,s)=>{let r=e.discount||a?.discount?.[e.value]||1,{displayValue:n,actualPrice:c,savedAmount:o,hasDiscount:d}=(0,ea.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 dark:border-foreground dark:bg-foreground/10":"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,m.ZV)(n)}),d&&(0,t.jsx)("div",{className:"text-xs font-medium text-green-600",children:(0,ea.gU)(r)})]}),(0,t.jsxs)("div",{className:"text-muted-foreground mt-1.5 w-full text-xs sm:mt-2",children:["Pay ",(0,ea.vv)(c),d&&o>0&&(0,t.jsxs)("span",{className:"text-green-600",children:[" ","• Save ",(0,ea.vv)(o)]})]})]},s)})})]}),(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:H("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:O,onChange:e=>{var a;let s;return W(a=e.target.value),void((s=parseInt(a)||0)>=0&&o(s))},min:U,placeholder:`Minimum ${U}`,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:H("Amount to pay:")}),u?(0,t.jsx)(f.E,{className:"h-5 w-16"}):(0,t.jsx)("span",{className:"text-sm font-semibold",children:(0,ea.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:H("Payment Method")}),z?(0,t.jsx)("div",{className:"grid grid-cols-2 gap-1.5 sm:gap-3 lg:grid-cols-3",children:a?.pay_methods?.map(e=>{let a=e.min_topup||0,s=a>c,r=(0,t.jsxs)(p.$,{variant:"outline",onClick:()=>y(e),disabled:s||!!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"}):em(e.type,"h-4 w-4",e.icon,e.name),(0,t.jsx)("span",{className:"truncate",children:e.name})]},e.type);return s?(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:H("Minimum topup amount: {{amount}}",{amount:a})})]})},e.type):r})}):I?null:(0,t.jsx)(eN.Fc,{children:(0,t.jsx)(eN.TN,{children:H("No payment methods available. Please contact administrator.")})})]}),M&&I&&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:H("Waffo Payment")}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-1.5 sm:gap-3 lg:grid-cols-3",children:E?.map((e,a)=>{let s=`waffo-${a}`,r=F||0,n=r>c,i=(0,t.jsxs)(p.$,{variant:"outline",onClick:()=>q(e,a),disabled:n||!!g,className:"h-9 min-w-0 justify-start gap-2 rounded-lg px-3",children:[g===s?(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"}):em("waffo"),(0,t.jsx)("span",{className:"truncate",children:e.name})]},`${e.name}-${a}`);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:H("Minimum topup amount: {{amount}}",{amount:r})})]})},`${e.name}-${a}`):i})})]})]})}):(0,t.jsx)(eN.Fc,{children:(0,t.jsx)(eN.TN,{children:H("Online topup is not enabled. Please use redemption code or contact administrator.")})}),P&&Array.isArray(R)&&R.length>0&&$&&(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:H("Creem Payment")}),(0,t.jsx)(ew,{products:R,onProductSelect:$})]}),J?(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 up
2percase",children:H("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:H("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"}),H("Redeem")]})]}),w&&(0,t.jsxs)("p",{className:"text-muted-foreground text-xs",children:[H("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:[H("Get one here"),(0,t.jsx)(eg.A,{className:"h-3 w-3"})]})]})]}):(0,t.jsx)(eN.Fc,{className:"border-t",children:(0,t.jsx)(eN.TN,{children:H("Redemption codes are disabled until the administrator confirms compliance terms.")})})]})}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"}]]);var eA=s(54622),eC=s(40315),eS=s(59958),eR=s(72690),eP=s(48144),e$=s(92865);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 eE=s(76318),eF=s(38525),eq=s(78930);function eT(e){let{t:a}=(0,n.Bd)(),{currency:s}=(0,c.R)(),[i,l]=(0,r.useState)(!1),[o,d]=(0,r.useState)("");(0,r.useEffect)(()=>{e.open&&e.epayMethods&&e.epayMethods.length>0?d(e.epayMethods[0].type):e.open||d("")},[e.open,e.epayMethods]);let u=e.plan?.plan;if(!u)return null;let x=e.enableStripe&&!!u.stripe_price_id,h=e.enableCreem&&!!u.creem_product_id,f=e.enableWaffoPancake&&!!u.waffo_pancake_product_id,y=e.enableO
2nlineTopUp&&(e.epayMethods||[]).length>0,g=x||h||f||y,j=(e.epayMethods||[]).find(e=>e.type===o)?.name||o||a("Select payment method"),N=Number(u.total_amount||0),b=Number(u.price_amount||0).toFixed(2),v=s?.quotaPerUnit&&s.quotaPerUnit>0?s.quotaPerUnit:eE.tV.quotaPerUnit,w=Math.max(0,Math.ceil(Number(u.price_amount||0)*v)),_=Math.max(0,Number(e.userQuota||0)),k=!1!==u.allow_balance_pay,A=_<w,S=(e.purchaseLimit||0)>0&&(e.purchaseCount||0)>=(e.purchaseLimit||0),R=async()=>{l(!0);try{let s=await (0,eP.dW)({plan_id:u.id});"success"===s.message&&s.data?.pay_link?(window.open(s.data.pay_link,"_blank"),E.oR.success(a("Payment page opened")),e.onOpenChange(!1)):E.oR.error(s.message&&"success"!==s.message?s.message:a("Payment request failed"))}catch{E.oR.error(a("Payment request failed"))}finally{l(!1)}},$=async()=>{l(!0);try{let s=await (0,eP.mB)({plan_id:u.id});"success"===s.message&&s.data?.checkout_url?(window.open(s.data.checkout_url,"_blank"),E.oR.success(a("Payment page opened")),e.onOpenChange(!1)):E.oR.error(s.message&&"success"!==s.message?s.message:a("Payment request failed"))}catch{E.oR.error(a("Payment request failed"))}finally{l(!1)}},M=async()=>{l(!0);try{let e=await (0,eP.y8)({plan_id:u.id});"success"===e.message&&e.data?.checkout_url?(E.oR.success(a("Redirecting to payment page...")),window.location.href=e.data.checkout_url):E.oR.error(e.message&&"success"!==e.message?e.message:a("Payment request failed"))}catch{E.oR.error(a("Payment request failed"))}finally{l(!1)}},F="u">typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent),q=async()=>{if(!o)return void E.oR.error(a("Please select a payment method"));l(!0);try{let s=await (0,eP.dh)({plan_id:u.id,payment_method:o});if("success"===s.message&&s.url){let t=document.createElement("form");t.action=s.url,t.method="POST",F||(t.target="_blank"),Object.entries(s.data||{}).forEach(e=>{let[a,s]=e,r=document.createElement("input");r.type="hidden",r.name=a,r.value=String(s),t.appendChild(r)}),document.body.appendChild(t),t.submit(),document.body.removeChild(t),E.oR.success(a("Payment initiated")),e.onOpenChange(!1)}else E.oR.error(s.message&&"success"!==s.message?s.message:a("Payment request failed"))}catch{E.oR.error(a("Payment request failed"))}finally{l(!1)}},T=async()=>{if(!k)return void E.oR.error(a("This plan does not allow balance redemption"));l(!0);try{let s=await (0,eP.Ax)({plan_id:u.id});s.success?(E.oR.success(a("Subscription purchased successfully")),e.onPurchaseSuccess?.(),e.onOpenChange(!1)):E.oR.error(s.message&&"success"!==s.message?s.message:a("Payment request failed"))}catch{E.oR.error(a("Payment request failed"))}finally{l(!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"}),a("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:a("Plan Name")}),(0,t.jsx)("span",{className:"max-w-[200px] truncate text-sm font-medium",children:u.title})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:a("Validity Period")}),(0,t.jsxs)("span",{className:"flex items-center gap-1 text-sm",children:[(0,t.jsx)(e$.A,{className:"h-3.5 w-3.5"}),(0,eq.a3)(u,a)]})]}),(0,eq.ak)(u,a)!==a("No Reset")&&(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:a("Reset Period")}),(0,t.jsx)("span",{className:"text-sm",children:(0,eq.ak)(u,a)})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:a("Received amount")}),(0,t.jsxs)("span",{className:"flex items-center gap-1 text-sm",children:[(0,t.jsx)(eM,{className:"h-3.5 w-3.5"}),N>0?(0,m.eN)(N):a("Unlimited")]})]}),u.upgrade_group&&(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:a("Upgrade Group")}),(0,t.jsx)(eF.d,{group:u.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:a("Amount Due")}),(0,t.jsxs)("span",{className:"text-primary text-lg font-bold",children:["$",b]}
2)]})]}),S&&(0,t.jsx)(eN.Fc,{variant:"destructive",children:(0,t.jsxs)(eN.TN,{children:[a("Purchase limit reached")," (",e.purchaseCount,"/",e.purchaseLimit,")"]})}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 rounded-md border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Required")}),(0,t.jsx)("span",{children:(0,m.eN)(w)})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Available")}),(0,t.jsx)("span",{children:(0,m.eN)(_)})]}),k?A&&(0,t.jsx)(eN.Fc,{variant:"destructive",children:(0,t.jsx)(eN.TN,{children:a("Insufficient balance")})}):(0,t.jsx)(eN.Fc,{variant:"destructive",children:(0,t.jsx)(eN.TN,{children:a("This plan does not allow balance redemption")})}),(0,t.jsx)(p.$,{variant:"outline",onClick:T,disabled:i||S||!k||A,children:a("Pay with Balance")})]}),g&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:a("Select payment method")}),(x||h||f)&&(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:flex",children:[x&&(0,t.jsx)(p.$,{variant:"outline",className:"flex-1",onClick:R,disabled:i||S,children:"Stripe"}),h&&(0,t.jsx)(p.$,{variant:"outline",className:"flex-1",onClick:$,disabled:i||S,children:"Creem"}),f&&(0,t.jsx)(p.$,{variant:"outline",className:"flex-1",onClick:M,disabled:i||S,children:"Waffo Pancake"})]}),y&&(0,t.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-2",children:[(0,t.jsxs)(P.l6,{items:[...(e.epayMethods||[]).map(e=>({value:e.type,label:e.name||e.type}))],value:o,onValueChange:e=>null!==e&&d(e),disabled:S,children:[(0,t.jsx)(P.bq,{className:"flex-1",children:(0,t.jsx)(P.yv,{children:j})}),(0,t.jsx)(P.gC,{alignItemWithTrigger:!1,children:(0,t.jsx)(P.s3,{children:(e.epayMethods||[]).map(e=>(0,t.jsx)(P.eb,{value:e.type,children:e.name||e.type},e.type))})})]}),(0,t.jsx)(p.$,{onClick:q,disabled:i||!o||S,children:a("Pay")})]})]})]})]})})}function eH(e,a){switch(e){case"subscription_first":return a("Subscription First");case"wallet_first":return a("Wallet First");case"subscription_only":return a("Subscription Only");case"wallet_only":return a("Wallet Only");default:return e}}function eO(e){let{topupInfo:a,onAvailabilityChange:s,userQuota:i,onPurchaseSuccess:l}=e,{t:c}=(0,n.Bd)(),[o,d]=(0,r.useState)([]),[u,h]=(0,r.useState)([]),[y,g]=(0,r.useState)([]),[j,b]=(0,r.useState)("subscription_first"),[v,w]=(0,r.useState)(!0),[_,k]=(0,r.useState)(!1),[A,C]=(0,r.useState)(!1),[S,R]=(0,r.useState)(null),M=!!a?.enable_stripe_topup,F=!!a?.enable_creem_topup,q=!!a?.enable_waffo_pancake_topup,T=!!a?.enable_online_topup,H=(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)})(a?.pay_methods),[a?.pay_methods]),O=(0,r.useCallback)(async()=>{try{let e=await (0,eP.Ay)();e.success&&d(e.data||[])}catch{d([])}},[]),W=(0,r.useCallback)(async()=>{try{let e=await (0,eP.pK)();e.success&&e.data&&(b(e.data.billing_preference||"subscription_first"),h(e.data.subscriptions||[]),g(e.data.all_subscriptions||[]))}catch{}},[]);(0,r.useEffect)(()=>{(async()=>{w(!0),await Promise.all([O(),W()]),w(!1)})()},[O,W]);let B=async()=>{k(!0);try{await W()}finally{k(!1)}},L=async e=>{b(e);try{let a=await (0,eP.S$)(e);if(a.success){E.oR.success(c("Updated successfully"));let s=a.data?.billing_preference||e;b(s)}else E.oR.error(a.message||c("Update failed")),b(j)}catch{E.oR.error(c("Request failed")),b(j)}},z=u.length>0,I=y.length>0,U=v||o.length>0||I,J=!z,D="subscription_first"===j||"subscription_only"===j,V=J&&D?"wallet_first":j,Z=(0,r.useMemo)(()=>{let e=new Map;for(let a of y){let s=a?.subscription?.plan_id;s&&e.set(s,(e.get(s)||0)+1)}return e},[y]);(0,r.useEffect)(()=>{s?.(U)},[U,s]);let Y=(0,r.useMemo)(()=>{let e=new Map;for(let a of o)a?.plan?.id&&e.set(a.plan.id,a.plan.title||"");return e},[o]);return v?(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,a)=>(0,t.jsx)(f.E,{className:"h-48 w-full"},a))})]})]}):0!==o.length||I?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(eb.f,{title:c("Subscription Plans"),description:c("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:c("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",z?$.jk.success:$.jk.neutral),"aria-hidden":"true"}),z?(0,t.jsxs)("span",{className:(0,ej.cn)($.BQ.success),children:[u.length," ",c("active")]}):(0,t.jsx)("span",{className:"text-muted-foreground",children:c("No Active")}),y.length>u.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:[y.length-u.length," ",c("expired")]})]})]})]}),(0,t.jsxs)("div",{className:"flex w-full items-center gap-2 sm:w-auto",children:[(0,t.jsxs)(P.l6,{items:[{value:"subscription_first",label:(0,t.jsxs)(t.Fragment,{children:[eH("subscription_first",c),J?` (${c("No Active")})`:""]})},{value:"wallet_first",label:eH("wallet_first",c)},{value:"subscription_only",label:(0,t.jsxs)(t.Fragment,{children:[eH("subscription_only",c),J?` (${c("No Active")})`:""]})},{value:"wallet_only",label:eH("wallet_only",c)}],value:V,onValueChange:e=>null!==e&&L(e),children:[(0,t.jsx)(P.bq,{className:"h-8 flex-1 text-xs sm:w-[140px] sm:flex-none",children:(0,t.jsx)(P.yv,{children:eH(V,c)})}),(0,t.jsx)(P.gC,{alignItemWithTrigger:!1,children:(0,t.jsxs)(P.s3,{children:[(0,t.jsxs)(P.eb,{value:"subscription_first",disabled:J,children:[eH("subscription_first",c),J?` (${c("No Active")})`:""]}),(0,t.jsx)(P.eb,{value:"wallet_first",children:eH("wallet_first",c)}),(0,t.jsxs)(P.eb,{value:"subscription_only",disabled:J,children:[eH("subscription_only",c),J?` (${c("No Active")})`:""]}),(0,t.jsx)(P.eb,{value:"wallet_only",children:eH("wallet_only",c)})]})})]}),(0,t.jsx)(p.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:B,disabled:_,children:(0,t.jsx)(eA.A,{className:`h-3.5 w-3.5 ${_?"animate-spin":""}`})})]})]}),J&&D&&(0,t.jsx)("p",{className:"text-muted-foreground mt-2 text-xs",children:c("Preference saved as {{pref}}, but no active subscription. Wallet will be used automatically.",{pref:"subscription_only"===j?c("Subscription Only"):c("Subscription First")})}),I&&(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:y.map(e=>{let a,s,r,n=e.subscription,i=Number(n?.amount_total||0),l=Number(n?.amount_used||0),o=i>0?Math.max(0,i-l):0,d=Y.get(n?.plan_id)||"",u=(a=e?.subscription?.end_time||0)?Math.max(0,Math.ceil((a-Date.now()/1e3)/86400)):0,p=(s=Number(e?.subscription?.amount_total||0),r=Number(e?.subscription?.amount_used||0),s<=0?0:Math.round(r/s*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 ${c("Subscription")} #${n?.id}`:`${c("Subscription")} #${n?.id}`}),y?(0,t.jsx)($.Wh,{label:c("Active"),variant:"success",copyable:!1}):f?(0,t.jsx)($.Wh,{label:c("Cancelled"),variant:"neutral",copyable:!1}):(0,t.jsx)($.Wh,{label:c("Expired"),variant:"neutral",copyable:!1})]}),y&&(0,t.jsx)("span",{className:"text-muted-foreground",children:c("{{count}} days remaining",{count:u})})]}),(0,t.jsxs)("div",{className:"text-muted-foreground mt-1.5",children:[y?c("Until"):f?c("Cancelled at"):c("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:[c("Next reset"),":"," ",new Date(1e3*n.next_reset_time).toLocaleStr
2ing()]}),(0,t.jsxs)("div",{className:"text-muted-foreground mt-1",children:[c("Total Quota"),":"," ",i>0?(0,t.jsxs)(ev.m_,{children:[(0,t.jsxs)(ev.k$,{render:(0,t.jsx)("span",{className:"cursor-help"}),children:[(0,m.eN)(l),"/",(0,m.eN)(i)," · ",c("Remaining")," ",(0,m.eN)(o)]}),(0,t.jsxs)(ev.ZI,{children:[c("Raw Quota"),": ",l,"/",i," ·"," ",c("Remaining")," ",o]})]}):c("Unlimited"),i>0&&(0,t.jsxs)("span",{className:"ml-2",children:[c("Used")," ",p,"%"]})]}),i>0&&y&&(0,t.jsx)(eS.ke,{value:p,className:"mt-2 h-1.5"})]},n?.id)})})]}),!I&&(0,t.jsx)("p",{className:"text-muted-foreground mt-2 text-xs",children:c("Subscribe to a plan for model access")})]}),o.length>0?(0,t.jsx)("div",{className:"grid grid-cols-1 gap-3 2xl:grid-cols-2 2xl:gap-4",children:o.map((e,a)=>{let s=e?.plan;if(!s)return null;let r=Number(s.total_amount||0),n=Number(s.price_amount||0).toFixed(2),i=0===a&&o.length>1,l=Number(s.max_purchase_per_user||0),d=Z.get(s.id)||0,u=l>0&&d>=l,h=[`${c("Validity Period")}: ${(0,eq.a3)(s,c)}`,(0,eq.ak)(s,c)!==c("No Reset")?`${c("Quota Reset")}: ${(0,eq.ak)(s,c)}`:null,r>0?`${c("Total Quota")}: ${(0,m.eN)(r)}`:`${c("Total Quota")}: ${c("Unlimited")}`,l>0?`${c("Purchase Limit")}: ${l}`:null,s.upgrade_group?`${c("Upgrade Group")}: ${s.upgrade_group}`:null].filter(Boolean);return(0,t.jsx)(x.Zp,{className:(0,ej.cn)("transition-shadow hover:shadow-md",i&&"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:s.title||c("Subscription Plans")}),s.subtitle&&(0,t.jsx)("p",{className:"text-muted-foreground truncate text-xs",children:s.subtitle})]}),i&&(0,t.jsxs)($.Wh,{variant:"info",copyable:!1,className:"shrink-0",children:[(0,t.jsx)(eC.A,{className:"h-3 w-3"}),c("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"}),u?(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:c("Limit Reached")})}),(0,t.jsxs)(ev.ZI,{children:[c("Purchase limit reached")," (",d,"/",l,")"]})]}):(0,t.jsx)(p.$,{variant:"outline",className:"w-full",onClick:()=>{R(e),C(!0)},children:c("Subscribe Now")})]})},s.id)})}):(0,t.jsx)("p",{className:"text-muted-foreground py-4 text-center text-sm",children:c("No plans available")})]}),(0,t.jsx)(eT,{open:A,onOpenChange:e=>{C(e),e||W()},plan:S,enableStripe:M,enableCreem:F,enableWaffoPancake:q,enableOnlineTopUp:T,epayMethods:H,userQuota:i,onPurchaseSuccess:l,purchaseLimit:S?.plan?.max_purchase_per_user?Number(S.plan.max_purchase_per_user):void 0,purchaseCount:S?.plan?.id?Z.get(S.plan.id):void 0})]}):null}var eW=s(65253),eB=s(1333);function eL(e){let{t:a}=(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,a)=>(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"})]},a))})});let s=[{label:a("Current Balance"),value:(0,m.eN)(e.user?.quota??0),description:a("Remaining quota"),icon:eh.A},{label:a("Total Usage"),value:(0,m.eN)(e.user?.used_quota??0),description:a("Total consumed quota"),icon:eW.A},{label:a("API Requests"),value:(e.user?.request_count??0).toLocaleString(),description:a("Total requests made"),icon:eB.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:s.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 ez(e){if(Array.isArray(e))return e;if("string"==typeof e)try{let a=JSON.parse(e);return Array.isArray(a)?a:[]}catch{}return[]}function eI(e){let{t:a}=(0,n.Bd)(),[s,d]=(0,r.useState)(null),[u,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),[P,$]=(0,r.useState)(""),[F,Z]=(0,r.useState)(!1),[Y,Q]=(0,r.useState)(null),[G,K]=(0,r.useState)(!0),{status:ee}=(0,l.s)(),{currency:ea}=(0,c.R)(),{topupInfo:ec,presetAmounts:eo,loading:ed}=function(){let[e,a]=(0,r.useState)(null),[s,t]=(0,r.useState)([]),[n,i]=(0,r.useState)(!0),l=async()=>{try{var e,s,r,n,l,c,o,d;i(!0);let u=await T();if(!u.success||!u.data)return void console.error("Failed to fetch topup info:",u.message);let m={...u.data,pay_methods:(e=u.data.pay_methods,s=u.data.stripe_min_topup,ez(e).filter(e=>!!e&&"object"==typeof e).map(e=>{let a=Number(e.min_topup),t=Number.isFinite(a)?a: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?s:t}}).filter(e=>e.name&&e.type&&"waffo"!==e.type)),amount_options:(r=u.data.amount_options,ez(r).map(e=>Number(e)).filter(e=>Number.isFinite(e)&&e>0)),discount:function(e){if(!e)return{};let a=e;if("string"==typeof e)try{a=JSON.parse(e)}catch{return{}}return!a||"object"!=typeof a||Array.isArray(a)?{}:Object.entries(a).reduce((e,a)=>{let[s,t]=a,r=Number(s),n=Number(t);return Number.isFinite(r)&&Number.isFinite(n)&&(e[r]=n),e},{})}(u.data.discount),creem_products:(n=u.data.creem_products,ez(n).filter(e=>!!e&&"object"==typeof e).map(e=>{let a="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:a}}).filter(e=>e.name&&e.productId)),waffo_pay_methods:(l=u.data.waffo_pay_methods,ez(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(a(m),m.amount_options.length>0){let e=(c=m.amount_options,o=m.discount||{},c&&0!==c.length?c.map(e=>({value:e,discount:o[e]||1})):[]);t(e)}else{let e=(d=el(m),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:s,loading:n,refetch:l}}(),eu=(0,r.useMemo)(()=>ea?.quotaDisplayType==="USD"?1:ea?.usdExchangeRate||1,[ea?.quotaDisplayType,ea?.usdExchangeRate]),{amount:em,calculating:eh,processing:ef,calculatePaymentAmount:ey,processPayment:eg}=function(){let[e,a]=(0,r.useState)(0),[s,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)(!1);return{amount:e,calculating:s,processing:n,calculatePaymentAmount:(0,r.useCallback)(async(e,s)=>{try{t(!0);let r=er(s),n=en(s),i=r?await W({amount:e}):n?await U({amount:e}):await O({amount:e});if(q(i)&&i.data){let e=parseFloat(i.data);return a(e),e}return a(0),0}catch(e){return a(0),0}finally{t(!1)}},[]),processPayment:(0,r.useCallback)(async(e,a)=>{try{i(!0);let t=er(a),r=Math.floor(e),n=t?await L({amount:r,payment_method:"stripe"}):await B({amount:r,payment_method:a});if(!q(n))return E.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"),E.oR.success(M.Ay.t("Redirecting to payment page...")),!0;if(!t&&n.data){let e=n.url;if(e){var s;let a;return s=n.data,(a=document.createElement("form")).action=e,a.method="POST",navigator.userAgent.indexOf("Safari")>-1&&1>navigator.userAgent.indexOf("Chrome")||(a.target="_blank"),Object.entries(s).forEach(e=>{let[s,t]=e,r=document.createElement("input");r.type="hidden",r.name=s,r.value=String(t),a.appendChild(r)}),document.body.appendChild(a),a.submit(),document.body.removeChild(a),E.oR.success(M.Ay.t("Redirecting to payment page...")),!0}}return!1}catch(e){return E.oR.error(M.Ay.t("Payment request failed")),!1}finally{i(!1)}},[]),setAmount:a}}(),{affiliateLink:ej,loading:eN,transferQuota:eb,transferring:ev}=function(){let[e,a]=(0,r.useState)(""),[s,t]=(0,r.useState)(""),[n,l]=(0,r.useState)(!0),[c,o]=(0,r.useState)(!1),{copyToClipboard:d}=(0,k.C)(),u=(0,r.useCallback)(async()=>{try{l(!0);let s=await D();if(s.success&&s.data){var e;a(s.data);let r=(e=s.data,"u"<typeof window?"":`${window.location.origin}/sign-up?aff=${e}`);t(r)}}catch(e){console.error("Failed to fetch affiliate code:",e)}finally{l(!1)}},[]),m=(0,r.useCallback)(()=>{d(s)},[s,d]),p=(0,r.useCallback)(async e=>{try{o(!0);let a=await V({quota:e});if(a.success)return E.oR.success(a.message||M.Ay.t("Transfer successful")),await (0,i.Ng)(),!0;return E.oR.error(a.message||M.Ay.t("Transfer failed")),!1}catch(e){return E.oR.error(M.Ay.t("Transfer failed")),!1}finally{o(!1)}},[]);return(0,r.useEffect)(()=>{u()},[u]),{affiliateCode:e,affiliateLink:s,loading:n,transferring:c,copyAffiliateLink:m,transferQuota:p,refetch:u}}(),{redeeming:ew,redeemCode:ek}=function(){let[e,a]=(0,r.useState)(!1);return{redeeming:e,redeemCode:(0,r.useCallback)(async e=>{if(!e||""===e.trim())return E.oR.error(M.Ay.t("Please enter a redemption code")),!1;try{a(!0);let s=await H({key:e});if(s.success&&s.data){let e=s.data;return E.oR.success(M.Ay.t("Redemption successful! Added: {{quota}}",{quota:(0,m.eN)(e)})),await (0,i.Ng)(),!0}return E.oR.error(s.message||M.Ay.t("Redemption failed")),!1}catch(e){return E.oR.error(M.Ay.t("Redemption failed")),!1}finally{a(!1)}},[])}}(),{processing:eA,processCreemPayment:eC}=function(){let[e,a]=(0,r.useState)(!1);return{processing:e,processCreemPayment:(0,r.useCallback)(async e=>{a(!0);try{let a=await z({product_id:e,payment_method:"creem"});if(q(a)&&a.data?.checkout_url)return window.open(a.data.checkout_url,"_blank"),E.oR.success(M.Ay.t("Redirecting to Creem checkout...")),!0;return E.oR.error(a.message||M.Ay.t("Payment request failed")),!1}catch(e){return E.oR.error(M.Ay.t("Payment request failed")),!1}finally{a(!1)}},[])}}(),{processWaffoPayment:eS}=function(){let[e,a]=(0,r.useState)(!1);return{processing:e,processWaffoPayment:(0,r.useCallback)(async(e,s)=>{a(!0);try{var t,r,n;let a=await I({amount:Math.floor(e),pay_method_index:s});if(q(a)){let e=(t=a.data)&&"object"==typeof t&&"payment_url"in t&&"string"==typeof t.payment_url?t.payment_url:null;if(e)return window.open(e,"_blank"),E.oR.success(M.Ay.t("Redirecting to payment page...")),!0}return E.oR.error((r=a.message,n=a.data,"string"==typeof n&&n.trim()?n:r||M.Ay.t("Payment request failed"))),!1}catch(e){return E.oR.error(M.Ay.t("Payment request failed")),!1}finally{a(!1)}},[])}}(),{processing:eR,processWaffoPancakePayment:eP}=function(){let[e,a]=(0,r.useState)(!1);return{processing:e,processWaffoPancakePayment:(0,r.useCallback)(async e=>{a(!0);try{var s,t,r;let a=await J({amount:Math.floor(e)});if(q(a)){let e=(s=a.data)&&"object"==typeof s&&"checkout_url"in s&&"string"==typeof s.checkout_url?s.checkout_url:null;if(e){if(!function(e){let a=e.trim();if(!a)return!1;try{let e=new URL(a);return"http:"===e.protocol||"https:"===e.protocol}catch{return!1}}(e))return E.oR.error(M.Ay.t("Invalid payment redirect URL")),!1;return E.oR.success(M.Ay.t("Redirecting to payment page...")),window.location.href=e,!0}}return E.oR.error((t=a.message,r=a.data,"string"==typeof r&&r.trim()?r:t||M.Ay.t("Payment request failed"))),!1}catch(e){return E.oR.error(M.Ay.t("Payment request failed")),!1}finally{a(!1)}},[])}}(),e$=(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)(()=>{e$()},[e$]),(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]),eE=async e=>{N(e),v(e.type);try{let a=el(ec);if(x<a)return;await ey(x,e.type),_(!0)}finally{v(null)}},eF=async()=>{!j||(en(j.type)?await eP(x):await eg(x,j.type))&&(_(!1),await e$())},eq=async()=>{!P||await ek(P)&&($(""),await e$())},eT=async e=>{let a=await eb(e);return a&&await e$(),a},eH=async()=>{!Y||await eC(Y.productId)&&(Z(!1),Q(null),await e$())},eW=async(e,a)=>{v(`waffo-${a}`);try{await eS(x,a)}finally{v(null)}},eB=(0,r.useCallback)(()=>ec?.discount?.[x]||1,[ec,x]),eI=(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:a("Wallet")}),(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)(eL,{user:s,loading:u}),(0,t.jsxs)("div",{className:G?"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:em,calculating:eh,onPaymentMethodSelect:eE,paymentLoading:b,redemptionCode:P,onRedemptionCodeChange:$,onRedeem:eq,redeeming:ew,topupLink:ec?.topup_link,loading:ed,priceRatio:ee?.price||1,usdExchangeRate:eu,onOpenBilling:()=>R(!0),creemProducts:ec?.creem_products,enableCreemTopup:ec?.enable_creem_topup,onCreemProductSelect:e=>{Q(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:eI,userQuota:s?.quota,onPurchaseSuccess:e$})]}),(0,t.jsx)(g,{user:s,affiliateLink:ej,onTransfer:()=>C(!0),complianceConfirmed:ec?.payment_compliance_confirmed!==!1,loading:eN})]})})]}),(0,t.jsx)(ep,{open:w,onOpenChange:_,onConfirm:eF,topupAmount:x,paymentAmount:em,paymentMethod:j,calculating:eh,processing:ef||eR,discountRate:eB(),usdExchangeRate:eu}),(0,t.jsx)(ex,{open:A,onOpenChange:C,onConfirm:eT,availableQuota:s?.aff_quota??0,transferring:ev}),(0,t.jsx)(X,{open:S,onOpenChange:R}),(0,t.jsx)(es,{open:F,onOpenChange:Z,onConfirm:eH,product:Y,processing:eA})]})}var eU=s(83653);function eJ(){let{show_history:e}=eU.q.useSearch();return(0,t.jsx)(eI,{initialShowHistory:e})}},92865(e,a,s){s.d(a,{A:()=>t});let t=(0,s(9781).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"}]])},65253(e,a,s){s.d(a,{A:()=>t});let t=(0,s(9781).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"}]])},40315(e,a,s){s.d(a,{A:()=>t});let t=(0,s(9781).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"}]])},567(e,a,s){s.d(a,{A:()=>t});let t=(0,s(9781).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"}]])}}]);

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.