PageSourceSearch

https://guestpostsoftware.com/_next/static/chunks/6438.7857456284ef56a9.js

js guestpostsoftware.com collected 2026-10-06 23:56:33 UTC 55,613 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6438],{18349:(e,a,s)=>{s.d(a,{T:()=>i});var t=s(95155),r=s(12115),l=s(40980);let i=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("textarea",{className:(0,l.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:s,...a}));i.displayName="Textarea"},29991:(e,a,s)=>{s.d(a,{bq:()=>u,eb:()=>f,gC:()=>p,l6:()=>o,yv:()=>m});var t=s(95155),r=s(12115),l=s(42695),i=s(66088),n=s(9921),d=s(94514),c=s(40980);let o=l.bL;l.YJ;let m=l.WT,u=r.forwardRef(({className:e,children:a,...s},r)=>(0,t.jsxs)(l.l9,{ref:r,className:(0,c.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...s,children:[a,(0,t.jsx)(l.In,{asChild:!0,children:(0,t.jsx)(i.A,{className:"h-4 w-4 opacity-50"})})]}));u.displayName=l.l9.displayName;let x=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)(l.PP,{ref:s,className:(0,c.cn)("flex cursor-default items-center justify-center py-1",e),...a,children:(0,t.jsx)(n.A,{className:"h-4 w-4"})}));x.displayName=l.PP.displayName;let h=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)(l.wn,{ref:s,className:(0,c.cn)("flex cursor-default items-center justify-center py-1",e),...a,children:(0,t.jsx)(i.A,{className:"h-4 w-4"})}));h.displayName=l.wn.displayName;let p=r.forwardRef(({className:e,children:a,position:s="popper",...r},i)=>(0,t.jsx)(l.ZL,{children:(0,t.jsxs)(l.UC,{ref:i,className:(0,c.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,...r,children:[(0,t.jsx)(x,{}),(0,t.jsx)(l.LM,{className:(0,c.cn)("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),(0,t.jsx)(h,{})]})}));p.displayName=l.UC.displayName,r.forwardRef(({className:e,...a},s)=>(0,t.jsx)(l.JU,{ref:s,className:(0,c.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...a})).displayName=l.JU.displayName;let f=r.forwardRef(({className:e,children:a,...s},r)=>(0,t.jsxs)(l.q7,{ref:r,className:(0,c.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...s,children:[(0,t.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,t.jsx)(l.VF,{children:(0,t.jsx)(d.A,{className:"h-4 w-4"})})}),(0,t.jsx)(l.p4,{children:a})]}));f.displayName=l.q7.displayName,r.forwardRef(({className:e,...a},s)=>(0,t.jsx)(l.wv,{ref:s,className:(0,c.cn)("-mx-1 my-1 h-px bg-muted",e),...a})).displayName=l.wv.displayName},33146:(e,a,s)=>{s.d(a,{N$:()=>m,PK:()=>c,QN:()=>o,T8:()=>u,tS:()=>d});var t=s(75873);let r="preferred_payment_method",l={code:"wallet",name:"Wallet Credit",description:"Pay using your wallet balance",source:"wallet"},i=["paypal","wallet","stripe","razorpay","bank_transfer","pay_later"];function n(e){return e.trim().toLowerCase()}async function d(e,a){let{data:s}=await e.from("orders").select("payment_method").eq("user_id",a).eq("payment_status","paid").order("created_at",{ascending:!1}).limit(100),t={};for(let e of s??[]){let a=n(String(e.payment_method||""));a&&(t[a]=(t[a]??0)+1)}return t}function c(e){let a=new Set(e.activeCodes.map(n));if(!a.size)return null;let s=e.savedPreference?n(e.savedPreference):"";if(s&&a.has(s))return s;let t=e.usageCounts??{},r=null,l=0;for(let e of a){let a=t[e]??0;a>l&&(l=a,r=e)}if(r&&l>0)return r;for(let e of i)if(a.has(e))return e;return e.activeCodes[0]?n(e.activeCodes[0]):null}async function o(e){let[a,s,r]=await Promise.all([e.from("payment_methods").select("*").eq("is_active",!0).order("display_order"),e.from("site_settings").select("key, value").eq("key","payment_environment").maybeSingle(),e.from("wallet_settings").select("wallet_enabled").maybeSingle()]),i=(0,t.y$)(s.data?.value),d=!!r.data?.wallet_enabled,c=(0,t.SF)((a.data??[]).filter(e=>(0,t.Nk)(e,i))).map(e=>({code:n(e.code),name:e.name,description:e.description||"",source:"payment_methods"}));return d&&!c.some(e=>"wallet"===e.code)&&c.unshift(l),{methods:c,checkoutMode:i,walletEnabled:d}}function m(){try{return localStorage.getItem(r)}catch{return null}}function u(e){try{localStorage.setItem(r,n(e))}catch{}}},35996:(e,a,s)=>{s.d(a,{Fw:()=>r,RC:()=>n,UZ:()=>l,XF:()=>t,b$:()=>i,rI:()=>d});let t=20;function r(e){let a=Array.isArray(e)?e[0]:e,s="number"==typeof a?a:Number.parseInt(String(a??""),10);return!Number.isFinite(s)||s<1?1:Math.floor(s)}function l(e){let a=(r(e)-1)*t;return{from:a,to:a+t-1}}function i(e){return Math.max(1,Math.ceil(Math.max(0,Number(e)||0)/t)||1)}function n(e,a){let s=i(a);return Math.min(Math.max(1,r(e)),s)}function d(e,a){let s=Math.max(0,Number(a)||0),r=i(s),l=n(e,s),d=(l-1)*t;return{page:l,total:s,totalPages:r,rangeStart:0===s?0:d+1,rangeEnd:Math.min(d+t,s)}}}
1,47567:(e,a,s)=>{s.d(a,{h:()=>m});var t=s(95155),r=s(98500),l=s.n(r),i=s(89239),n=s(41641),d=s(21362),c=s(40980),o=s(35996);function m({page:e,total:a,hrefForPage:s,onPageChange:r,noun:u="records",className:x,showPageNumbers:h=!0,maxPageButtons:p=5}){let{rangeStart:f,rangeEnd:j,totalPages:N,page:g}=(0,o.rI)(e,a);if(0===a)return(0,t.jsxs)("p",{className:(0,c.cn)("text-sm text-muted-foreground",x),children:["Showing 0 of 0 ",u]});let y=e=>{r&&r(e)},v=(()=>{if(!h||N<=1)return[];let e=Math.max(1,g-Math.floor(p/2)),a=Math.min(N,e+p-1);e=Math.max(1,a-p+1);let s=[];for(let t=e;t<=a;t++)s.push(t);return s})(),b=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.A,{className:"h-4 w-4"}),"Previous"]}),w=(0,t.jsxs)(t.Fragment,{children:["Next",(0,t.jsx)(d.A,{className:"h-4 w-4"})]});return(0,t.jsxs)("div",{className:(0,c.cn)("flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",x),children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Showing ",f,"–",j," of ",a," ",u,(0,t.jsxs)("span",{className:"sr-only",children:[" (",o.XF," per page)"]})]}),N>1&&(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[s?(0,t.jsx)(i.$,{asChild:!0,variant:"outline",size:"sm",className:"h-9 gap-1",disabled:g<=1,children:(0,t.jsx)(l(),{href:s(Math.max(1,g-1)),prefetch:!1,"aria-disabled":g<=1,className:g
1<=1?"pointer-events-none opacity-50":void 0,children:b})}):(0,t.jsx)(i.$,{type:"button",variant:"outline",size:"sm",className:"h-9 gap-1",disabled:g<=1,onClick:()=>y(g-1),children:b}),v.map(e=>s?(0,t.jsx)(i.$,{asChild:!0,variant:e===g?"default":"outline",size:"sm",className:"h-9 min-w-9",children:(0,t.jsx)(l(),{href:s(e),prefetch:!1,children:e})},e):(0,t.jsx)(i.$,{type:"button",variant:e===g?"default":"outline",size:"sm",className:"h-9 min-w-9",onClick:()=>y(e),children:e},e)),s?(0,t.jsx)(i.$,{asChild:!0,variant:"outline",size:"sm",className:"h-9 gap-1",disabled:g>=N,children:(0,t.jsx)(l(),{href:s(Math.min(N,g+1)),prefetch:!1,"aria-disabled":g>=N,className:g>=N?"pointer-events-none opacity-50":void 0,children:w})}):(0,t.jsx)(i.$,{type:"button",variant:"outline",size:"sm",className:"h-9 gap-1",disabled:g>=N,onClick:()=>y(g+1),children:w})]})]})}},47687:(e,a,s)=>{s.d(a,{Xi:()=>c,av:()=>o,j7:()=>d,tU:()=>n});var t=s(95155),r=s(12115),l=s(57518),i=s(40980);let n=l.bL,d=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)(l.B8,{ref:s,className:(0,i.cn)("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...a}));d.displayName=l.B8.displayName;let c=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)(l.l9,{ref:s,className:(0,i.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",e),...a}));c.displayName=l.l9.displayName;let o=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)(l.UC,{ref:s,className:(0,i.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a}));o.displayName=l.UC.displayName},53649:(e,a,s)=>{s.d(a,{V:()=>r});var t=s(56339);async function r(e,a){let s=a.replace(/^\/+/,"").replace(/\/+$/,"");if(!s)throw Error("Invalid upload path.");let{data:{session:r}}=await t.N.auth.getSession();if(!r?.user)throw Error("Sign in required to upload images.");if(!e.type.startsWith("image/"))throw Error("Please choose an image file.");let l=(e.name.split(".").pop()??"").replace(/[^a-z0-9]/gi,"").slice(0,8)||"jpg",i=`${Date.now()}-${Math.random().toString(36).slice(2,10)}.${l}`,n=`${s}/${i}`,{error:d}=await t.N.storage.from("pb-images").upload(n,e,{cacheControl:"3600",upsert:!1});if(d)throw d;let{data:{publicUrl:c}}=t.N.storage.from("pb-images").getPublicUrl(n);return c}},69613:(e,a,s)=>{s.d(a,{A0:()=>n,BF:()=>d,Hj:()=>c,XI:()=>i,nA:()=>m,nd:()=>o});var t=s(95155),r=s(12115),l=s(40980);let i=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("div",{className:"relative w-full overflow-auto",children:(0,t.jsx)("table",{ref:s,className:(0,l.cn)("w-full caption-bottom text-sm",e),...a})}));i.displayName="Table";let n=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("thead",{ref:s,className:(0,l.cn)("[&_tr]:border-b",e),...a}));n.displayName="TableHeader";let d=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("tbody",{ref:s,className:(0,l.cn)("[&_tr:last-child]:border-0",e),...a}));d.displayName="TableBody",r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("tfoot",{ref:s,className:(0,l.cn)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...a})).displayName="TableFooter";let c=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("tr",{ref:s,className:(0,l.cn)("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",e),...a}));c.displayName="TableRow";let o=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("th",{ref:s,className:(0,l.cn)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...a}));o.displayName="TableHead";let m=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("td",{ref:s,className:(0,l.cn)("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...a}));m.displayName="TableCell",r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("caption",{ref:s,className:(0,l.cn)("mt-4 text-sm text-muted-foreground",e),...a})).displayName="TableCaption"},73994:(e,a,s)=>{s.d(a,{C:()=>c,z:()=>d});var t=s(95155),r=s(12115),l=s(86033),i=s(16950),n=s(40980);let d=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)(l.bL,{className:(0,n.cn)("grid gap-2",e),...a,ref:s}));d.displayName=l.bL.displayName;let c=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)(l.q7,{ref:s,className:(0,n.cn)("aspect-square h-4 w-4 roun
1ded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:(0,t.jsx)(l.C1,{className:"flex items-center justify-center",children:(0,t.jsx)(i.A,{className:"h-2.5 w-2.5 fill-current text-current"})})}));c.displayName=l.q7.displayName},75873:(e,a,s)=>{function t(e){return function(e){if(null==e)return null;if("string"==typeof e){let a=e.trim().toLowerCase();return"live"===a||"sandbox"===a?a:null}if("object"==typeof e&&!Array.isArray(e)){let a=e.mode??e.environment??e.checkout_mode??e.payment_environment;if("string"==typeof a){let e=a.trim().toLowerCase();if("live"===e||"sandbox"===e)return e}}return null}(e)??"live"}function r(e,a){let s=(e.environment??"").trim().toLowerCase(),t=(e.checkout_environment??"").trim().toLowerCase();return("live"===s||"sandbox"===s)&&("live"===t||"sandbox"===t)&&s===t&&s===a}function l(e){let a=new Set,s=[];for(let t of e){let e=t.code.trim().toLowerCase();a.has(e)||(a.add(e),s.push(t))}return s}s.d(a,{Nk:()=>r,SF:()=>l,y$:()=>t})},76438:(e,a,s)=>{s.r(a),s.d(a,{default:()=>eN});var t=s(95155),r=s(12115),l=s(44005),i=s(26510),n=s(81477),d=s(47687),c=s(56339),o=s(6296),m=s(94338),u=s(71275),x=s(24538),h=s(79372),p=s(77012),f=s(61820),j=s(60529),N=s(18349),g=s(89239),y=s(33807),v=s(6695),b=s(21975),w=s(85359),_=s(53649);let C=({onSave:e})=>{let{toast:a}=(0,v.dj)(),s=(0,r.useRef)(null),[l,i]=(0,r.useState)(!0),[n,d]=(0,r.useState)(!1),[m,u]=(0,r.useState)(!1),[x,h]=(0,r.useState)(!1),[p,f]=(0,r.useState)({full_name:"",email:"",bio:"",avatar_url:"",created_at:"",customer_id:""});(0,r.useEffect)(()=>{C()},[]);let C=async()=>{try{let{data:{session:e}}=await c.N.auth.getSession();if(!e)return;let[{data:a,error:s},{data:t}]=await Promise.all([c.N.from("profiles").select("*").eq("id",e.user.id).maybeSingle(),c.N.from("user_roles").select("role").eq("user_id",e.user.id)]);if(s)throw s;h(t?.some(e=>"author"===e.role)??!1),a&&f({full_name:a.full_name||"",email:a.email||e.user.email||"",bio:a.bio||"",avatar_url:a.avatar_url||"",created_at:a.created_at,customer_id:a.customer_id||""})}catch(e){console.error("Error loading profile:",e),a({variant:"destructive",title:"Error",description:"Failed to load profile data."})}finally{i(!1)}},A=async()=>{try{d(!0);let{data:{session:s}}=await c.N.auth.getSession();if(!s)return;let t={bio:p.bio||null,avatar_url:p.avatar_url.trim()||null};x&&(t.full_name=p.full_name.trim()||null);let{error:r}=await c.N.from("profiles").update(t).eq("id",s.user.id);if(r)throw r;a({title:"Success",description:"Profile updated successfully."}),e?.()}catch(e){console.error("Error updating profile:",e),a({variant:"destructive",title:"Error",description:"Failed to update profile."})}finally{d(!1)}};return l?(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(o.A,{className:"h-6 w-6 animate-spin text-primary"})}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:"Personal Information"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Manage your personal information"})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.J,{htmlFor:"full_name",children:"Full Name"}),(0,t.jsx)(j.p,{id:"full_name",value:p.full_name,disabled:!x,className:x?"":"bg-muted",onChange:e=>f({...p,full_name:e.target.value})}),x?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Shown on blog bylines when you are the credited author (with your author profile)."}):null]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.J,{htmlFor:"email",children:"Email"}),(0,t.jsx)(j.p,{id:"email",type:"email",value:p.email,disabled:!0,className:"bg-muted"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.J,{htmlFor:"customer_id",children:"Customer ID"}),(0,t.jsx)(j.p,{id:"customer_id",value:p.customer_id,disabled:!0,className:"bg-muted font-mono"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.J,{htmlFor:"customer_since",children:"Customer Since"}),(0,t.jsx)(j.p,{id:"customer_since",value:p.created_at?(0,w.GP)(new Date(p.created_at),"MMMM dd, yyyy"):"N/A",disabled:!0,className:"bg-muted"})]}),x?null:(0,t.jsx)("div",{className:"text-sm text-muted-foreground bg-muted/50 p-3 rounded-md",children:"Name and email are managed by your account settings. Authors can edit display name here for blog bylines."}),(0,t.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,t.jsx)(y.J,{htmlFor:"avatar_url",children:"Profile photo URL"}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[(0,t.jsx)(j.p,{id:"avatar_url",placeholder:"https://…",value:p.avatar_url,onChange:e=>f({...p,avatar_url:e.target.value}),className:"flex-1"}
1),(0,t.jsx)("input",{ref:s,type:"file",accept:"image/*",className:"hidden",onChange:async e=>{let s=e.target.files?.[0];if(e.target.value="",s)try{u(!0);let{data:{session:e}}=await c.N.auth.getSession();if(!e)return;let t=await (0,_.V)(s,`profiles/${e.user.id}`);f(e=>({...e,avatar_url:t})),a({title:"Photo uploaded",description:"Save changes to keep it on your profile."})}catch(e){console.error(e),a({variant:"destructive",title:"Upload failed",description:e instanceof Error?e.message:"Could not upload image."})}finally{u(!1)}}}),(0,t.jsxs)(g.$,{type:"button",variant:"outline",disabled:m,onClick:()=>s.current?.click(),children:[m?(0,t.jsx)(o.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(b.A,{className:"mr-2 h-4 w-4"}),"Upload"]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Used on blog author boxes when you write posts."})]}),(0,t.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,t.jsx)(y.J,{htmlFor:"bio",children:"Bio / About"}),(0,t.jsx)(N.T,{id:"bio",placeholder:"Tell us about yourself...",value:p.bio,onChange:e=>f({...p,bio:e.target.value}),rows:4})]})]}),(0,t.jsx)(g.$,{onClick:A,disabled:n,className:"w-full",children:n?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})};var A=s(45160),S=s(73994),k=s(29991),$=s(51997),F=s(68459),R=s(51914),P=s(1930),E=s(2182);let M=["United States","United Kingdom","Canada","Australia","Germany","France","Italy","Spain","Netherlands","Belgium","Switzerland","Austria","Sweden","Norway","Denmark","Finland","Ireland","Portugal","Greece","Poland","Czech Republic","Hungary","Romania","Bulgaria","Croatia","Slovenia","Slovakia","Lithuania","Latvia","Estonia","Malta","Cyprus","Japan","China","India","South Korea","Singapore","Malaysia","Thailand","Indonesia","Philippines","Vietnam","Hong Kong","Taiwan","New Zealand","Brazil","Mexico","Argentina","Chile","Colombia","Peru","Venezuela","South Africa","Nigeria","Kenya","Egypt","Morocco","Israel","Saudi Arabia","UAE","Turkey","Russia","Ukraine","Other"].sort(),T=P.Ik({fullName:P.Yj().trim().min(2,"Name must be at least 2 characters").max(100,"Name is too long"),email:P.Yj().trim().email("Invalid email address").max(255,"Email is too long"),phone:P.Yj().trim().max(20,"Phone number is too long").optional().or(P.eu("")),address:P.Yj().trim().min(5,"Address must be at least 5 characters").max(500,"Address is too long"),city:P.Yj().trim().max(100,"City name is too long").optional().or(P.eu("")),zipCode:P.Yj().trim().max(20,"Zip code is too long").optional().or(P.eu("")),country:P.Yj().trim().max(100,"Country name is too long").optional().or(P.eu(""))}),z=({onAddressSelect:e,selectedAddressId:a,mode:s="manage",showTitle:l=!0})=>{let{toast:i}=(0,v.dj)(),[d,m]=(0,r.useState)(!0),[u,h]=(0,r.useState)(!1),[p,f]=(0,r.useState)([]),[N,b]=(0,r.useState)(!1),[w,_]=(0,r.useState)(null),[C,P]=(0,r.useState)({fullName:"",email:"",phone:"",address:"",city:"",zipCode:"",country:"",label:"HOME"});(0,r.useEffect)(()=>{z()},[]);let z=async()=>{try{let{data:{session:e}}=await c.N.auth.getSession();if(!e)return;let{data:a,error:s}=await c.N.from("billing_addresses").select("*").eq("user_id",e.user.id).order("is_default",{ascending:!1});if(s)throw s;if(a&&(f(a),0===a.length)){b(!0);let{data:a}=await c.N.from("profiles").select("email, full_name").eq("id",e.user.id).maybeSingle();a&&P(s=>({...s,email:a.email||e.user.email||"",fullName:a.full_name||""}))}}catch(e){console.error("Error loading addresses:",e),i({variant:"destructive",title:"Error",description:"Failed to load billing addresses"})}finally{m(!1)}},q=e=>{P({...C,[e.target.name]:e.target.value})},U=()=>{P({fullName:"",email:"",phone:"",address:"",city:"",zipCode:"",country:"",label:"HOME"}),_(null),b(!1)},D=async e=>{try{let{error:a}=await c.N.from("billing_addresses").delete().eq("id",e);if(a)throw a;i({title:"Success",description:"Address deleted"}),await z()}catch(e){console.error("Error deleting address:",e),i({variant:"destructive",title:"Error",description:"Failed to delete address"})}},I=async e=>{try{let{data:{session:a}}=await c.N.auth.getSession();if(!a)return;await c.N.from("billing_addresses").update({is_default:!1}).eq("user_id",a.user.id);let{error:s}=await c.N.from("billing_addresses").update({is_default:!0}).eq("id",e);if(s)throw s;i({title:"Success",description:"Default address updated"}),await z()}catch(e){console.error("Error setting default:",e),i({variant:"destructive",title:"Error",description:"Failed to update default address"})}},Z=async()=>{try{T.parse(C)}catch(e){e instanceof E.G&&i({variant:"destructive",title:"Validation Error",description:e.errors[0].message});return}h(!0);try{let{data:{session:e}}=await c.N.auth.getSession();if(!e)return;let a=0===p.length,s={user_id:e.user.id,full_name:C.fullName,email:C.email,phone:C.phone||null,address:C.address,city:C.city||null,zip_code:C.zipCode||null,country:C.country||null,label:C.label,is_default:a};if(w){let{error:e}=await c.N.from("billing_addresses").update(s).eq("id",w.id);if(e)throw e;i({title:"Success",description:"Address updated"})}else{let{error:e}=await c.N.from("billing_addresses").insert(s);if(e)throw e;i({title:"Success",description:"Address added"})}U(),await z()}catch(e){console.error("Error saving address:",e),i({variant:"destructive",title:"Error",description:"Failed to save address"})}finally{h(!1)}};return d?(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(o.A,{className:"h-6 w-6 animate-spin text-primary"})}):(0,t.jsxs)("div",{className:"space-y-4",children:[l&&(0,t.jsx)("div",{className:"flex items-center justify-between",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:"Billing Addresses"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Manage your billing addresses for orders and invoices"})]})}),p.length>0&&!N&&(0,t.jsx)("div",{className:"space-y-3",children:(0,t.jsx)(S.z,{value:a||p.find(e=>e.is_default)?.id||"",onValueChange:a=>{let s=p.find(e=>e.id===a);s&&e&&e(s)},children:p.map(e=>(0,t.jsxs)("div",{className:`flex items-start gap-3 p-4 border rounded-lg transition-colors ${a===e.id||!a&&e.is_default?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,children:["select"===s&&(0,t.jsx)(S.C,{value:e.id,id:e.id,className:"mt-1"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)("span",{className:"font-medium",children:e.full_name}),(0,t.jsx)(A.E,{variant:"secondary",className:"text-xs",children:e.label}),e.is_default&&(0,t.jsx)(A.E,{variant:"default",className:"text-xs",children:"Default"}),e.phone&&(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:e.phone})]}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground mt-1",children:[e.address,e.city&&`, ${e.city}`,e.zip_code&&` - ${e.zip_code}`]}),e.country&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e.country})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,t.jsx)(g.$,{variant:"ghost",size:"sm",onClick:()=>{_(e),P({fullName:e.full_name,email:e.email,phone:e.phone||"",address:e.address,city:e.city||"",zipCode:e.zip_code||"",country:e.country||"",label:e.label||"HOME"}),b(!0)},children:(0,t.jsx)($.A,{className:"h-4 w-4"})}),!e.is_default&&"manage"===s&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(g.$,{variant:"ghost",size:"sm",onClick:()=>I(e.id),title:"Set as default",children:(0,t.jsx)(x.A,{className:"h-4 w-4"})}),(0,t.jsx)(g.$,{variant:"ghost",size:"sm",onClick:()=>D(e.id),className:"text-destructive hover:text-destructive",children:(0,t.jsx)(F.A,{className:"h-4 w-4"})})]})]})]},e.id))})}),!N&&(0,t.jsxs)(g.$,{variant:"outline",className:"w-full justify-start text-primary",onClick:()=>
1{_(null),P({fullName:"",email:"",phone:"",address:"",city:"",zipCode:"",country:"",label:"HOME"}),b(!0)},children:[(0,t.jsx)(R.A,{className:"h-4 w-4 mr-2"}),"Add a new address"]}),N&&(0,t.jsxs)(n.Zp,{children:[(0,t.jsx)(n.aR,{className:"pb-4",children:(0,t.jsx)(n.ZB,{className:"text-base",children:w?"Edit Address":"Add New Address"})}),(0,t.jsxs)(n.Wu,{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.J,{htmlFor:"fullName",children:"Full Name *"}),(0,t.jsx)(j.p,{id:"fullName",name:"fullName",placeholder:"John Doe",value:C.fullName,onChange:q})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.J,{htmlFor:"email",children:"Email *"}),(0,t.jsx)(j.p,{id:"email",name:"email",type:"email",placeholder:"[email protected]",value:C.email,onChange:q})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.J,{htmlFor:"phone",children:"Phone"}),(0,t.jsx)(j.p,{id:"phone",name:"phone",placeholder:"+1 234 567 890",value:C.phone,onChange:q})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.J,{htmlFor:"label",children:"Label"}),(0,t.jsxs)(k.l6,{value:C.label,onValueChange:e=>P({...C,label:e}),children:[(0,t.jsx)(k.bq,{children:(0,t.jsx)(k.yv,{placeholder:"Select label"})}),(0,t.jsxs)(k.gC,{children:[(0,t.jsx)(k.eb,{value:"HOME",children:"Home"}),(0,t.jsx)(k.eb,{value:"WORK",children:"Work"}),(0,t.jsx)(k.eb,{value:"OTHER",children:"Other"})]})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.J,{htmlFor:"address",children:"Address *"}),(0,t.jsx)(j.p,{id:"address",name:"address",placeholder:"Street address",value:C.address,onChange:q})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.J,{htmlFor:"city",children:"City"}),(0,t.jsx)(j.p,{id:"city",name:"city",placeholder:"City",value:C.city,onChange:q})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.J,{htmlFor:"zipCode",children:"Postal Code"}),(0,t.jsx)(j.p,{id:"zipCode",name:"zipCode",placeholder:"Zip/Postal Code",value:C.zipCode,onChange:q})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.J,{htmlFor:"country",children:"Country"}),(0,t.jsxs)(k.l6,{value:C.country,onValueChange:e=>P({...C,country:e}),children:[(0,t.jsx)(k.bq,{children:(0,t.jsx)(k.yv,{placeholder:"Select country"})}),(0,t.jsx)(k.gC,{children:M.map(e=>(0,t.jsx)(k.eb,{value:e,children:e},e))})]})]})]}),(0,t.jsxs)("div",{className:"flex gap-2 pt-2",children:[(0,t.jsxs)(g.$,{onClick:Z,disabled:u,children:[u&&(0,t.jsx)(o.A,{className:"h-4 w-4 mr-2 animate-spin"}),w?"Update Address":"Save Address"]}),p.length>0&&(0,t.jsx)(g.$,{variant:"outline",onClick:U,children:"Cancel"})]})]})]})]})};var q=s(1610),U=s(77028),D=s(78697),I=s(77104),Z=s(33146);let B=({onMethodSelect:e,selectedMethod:a,showTitle:s=!0})=>{let{toast:l}=(0,v.dj)(),[i,d]=(0,r.useState)(!0),[m,x]=(0,r.useState)([]),[p,f]=(0,r.useState)(a||"");(0,r.useEffect)(()=>{j()},[]);let j=async()=>{try{let{data:{user:e}}=await c.N.auth.getUser(),{methods:s}=await (0,Z.QN)(c.N);if(x(s),0===s.length)return void f("");let t=e?await (0,Z.tS)(c.N,e.id):{},r=(0,Z.PK)({activeCodes:s.map(e=>e.code),savedPreference:(0,Z.N$)(),usageCounts:t}),l=r&&s.some(e=>e.code===r)?r:s[0].code;f(a||l)}catch(e){console.error("Error loading payment methods:",e),l({variant:"destructive",title:"Error",description:"Failed to load payment methods"})}finally{d(!1)}},N=async a=>{f(a),(0,Z.T8)(a),e&&e(a)};return i?(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(o.A,{className:"h-6 w-6 animate-spin text-primary"})}):0===m.length?(0,t.jsx)(n.Zp,{children:(0,t.jsx)(n.Wu,{className:"py-8 text-center text-muted-foreground",children:"No payment methods are currently available. Please contact support or try again later."})}):(0,t.jsxs)("div",{className:"space-y-4",children:[s&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:"Preferred Payment Method"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose your default payment option for checkout. Only active methods are shown."})]}),(0,t.jsx)(S.z,{value:p,onValueChange:N,className:"space-y-3",children:m.map(e=>(0,t.jsxs)("div",{className:`flex items-center gap-3 p-4 border rounded-lg cursor-pointer transition-colors ${p===e.code?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,onClick:()=>N(e.code),children:[(0,t.jsx)(S.C,{value:e.code,id:e.code}),(0,t.jsxs)("div",{className:"flex items-center gap-3 flex-1",children:[(0,t.jsx)("div",{className:"text-primary",children:(e=>{switch(e){case"paypal":case"credit_card":case"stripe":return(0,t.jsx)(h.A,{className:"h-5 w-5"});case"wallet":return(0,t.jsx)(u.A,{className:"h-5 w-5"});case"bank_transfer":return(0,t.jsx)(q.A,{className:"h-5 w-5"});case"crypto":return(0,t.jsx)(U.A,{className:"h-5 w-5"});case"pay_later":return(0,t.jsx)(D.A,{className:"h-5 w-5"});default:return(0,t.jsx)(I.A,{className:"h-5 w-5"})}})(e.code)}),(0,t.jsxs)("div",{children:[(0,t.jsx)(y.J,{htmlFor:e.code,className:"font-medium cursor-pointer",children:e.name}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description})]})]})]},e.code))}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground bg-muted/50 p-3 rounded-md",children:"Your preferred method is pre-selected at checkout when available. If wallet balance is insufficient, you can use another active method or split payment when enabled."})]})};var H=s(84980),L=s(52484),W=s(67635),J=s(23317),V=s(7810),O=s(67899),X=s(76498),Y=s(85106),G=s(69613);let K=()=>{let{referralCode:e,referralLink:a,stats:s,commissions:r,pendingEarnings:l,approvedEarnings:i,paidEarnings:d,isLoading:c}=(0,Y.V)(),o=async()=>
1{if(a)try{await navigator.clipboard.writeText(a),(0,v.oR)({title:"Link copied!",description:"Your referral link has been copied to clipboard."})}catch(e){(0,v.oR)({title:"Failed to copy",variant:"destructive"})}};return c?(0,t.jsx)("div",{className:"p-8 text-center",children:(0,t.jsx)("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"})}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)(n.Zp,{className:"p-6",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold mb-4",children:"Your Referral Link"}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsx)("div",{className:"flex-1 bg-muted rounded-lg p-3",children:(0,t.jsx)("code",{className:"text-sm break-all",children:a||"Loading..."})}),(0,t.jsxs)(g.$,{onClick:o,size:"sm",children:[(0,t.jsx)(W.A,{className:"h-4 w-4 mr-2"}),"Copy"]})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-2",children:"Share this link to earn commissions on referred purchases."})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,t.jsx)(n.Zp,{className:"p-4",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center",children:(0,t.jsx)(J.A,{className:"h-5 w-5 text-blue-600"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-2xl font-bold",children:s?.total_clicks||0}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Total Clicks"})]})]})}),(0,t.jsx)(n.Zp,{className:"p-4",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-full bg-green-100 flex items-center justify-center",children:(0,t.jsx)(V.A,{className:"h-5 w-5 text-green-600"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-2xl font-bold",children:s?.total_signups||0}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Total Signups"})]})]})}),(0,t.jsx)(n.Zp,{className:"p-4",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-full bg-purple-100 flex items-center justify-center",children:(0,t.jsx)(O.A,{className:"h-5 w-5 text-purple-600"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-2xl font-bold",children:s?.total_purchases||0}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Total Purchases"})]})]})}),(0,t.jsx)(n.Zp,{className:"p-4",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-full bg-yellow-100 flex items-center justify-center",children:(0,t.jsx)(X.A,{className:"h-5 w-5 text-yellow-600"})}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{className:"text-2xl font-bold",children:["$",(s?.total_earned||0).toFixed(2)]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Total Earned"})]})]})})]}),(0,t.jsxs)("div",{className:"grid md:grid-cols-3 gap-4",children:[(0,t.jsxs)(n.Zp,{className:"p-4 border-l-4 border-l-yellow-500",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Pending"}),(0,t.jsxs)("p",{className:"text-2xl font-bold",children:["$",l.toFixed(2)]})]}),(0,t.jsxs)(n.Zp,{className:"p-4 border-l-4 border-l-blue-500",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Approved"}),(0,t.jsxs)("p",{className:"text-2xl font-bold",children:["$",i.toFixed(2)]})]}),(0,t.jsxs)(n.Zp,{className:"p-4 border-l-4 border-l-green-500",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Paid"}),(0,t.jsxs)("p",{className:"text-2xl font-bold",children:["$",d.toFixed(2)]})]})]}),(0,t.jsxs)(n.Zp,{className:"p-6",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold mb-4",children:"Commission History"}),0===r.length?(0,t.jsx)("p",{className:"text-muted-foreground text-center py-8",children:"No commissions yet. Share your referral link to start earning!"}):(0,t.jsxs)(G.XI,{children:[(0,t.jsx)(G.A0,{children:(0,t.jsxs)(G.Hj,{children:[(0,t.jsx)(G.nd,{children:"Date"}),(0,t.jsx)(G.nd,{children:"Order Type"}),(0,t.jsx)(G.nd,{children:"Order Amount"}),(0,t.jsx)(G.nd,{children:"Commission %"}),(0,t.jsx)(G.nd,{children:"Commission"}),(0,t.jsx)(G.nd,{children:"Status"})]})}),(0,t.jsx)(G.BF,{children:r.map(e=>(0,t.jsxs)(G.Hj,{children:[(0,t.jsx)(G.nA,{children:(0,w.GP)(new Date(e.created_at),"MMM dd, yyyy")}),(0,t.jsx)(G.nA,{className:"capitalize",children:e.order_type.replace("_"," ")}),(0,t.jsxs)(G.nA,{children:["$",Number(e.order_amount).toFixed(2)]}),(0,t.jsxs)(G.nA,{children:[e.commission_percent,"%"]}),(0,t.jsxs)(G.nA,{className:"font-semibold",children:["$",Number(e.commission_amount).toFixed(2)]}),(0,t.jsx)(G.nA,{children:(e=>
1{switch(e){case"pending":return(0,t.jsxs)(A.E,{variant:"secondary",children:[(0,t.jsx)(H.A,{className:"h-3 w-3 mr-1"})," Pending"]});case"approved":return(0,t.jsxs)(A.E,{variant:"default",children:[(0,t.jsx)(L.A,{className:"h-3 w-3 mr-1"})," Approved"]});case"paid":return(0,t.jsxs)(A.E,{className:"bg-green-500",children:[(0,t.jsx)(u.A,{className:"h-3 w-3 mr-1"})," Paid"]});case"rejected":return(0,t.jsx)(A.E,{variant:"destructive",children:"Rejected"});default:return(0,t.jsx)(A.E,{variant:"outline",children:e})}})(e.status)})]},e.id))})]})]})]})};var Q=s(50538),ee=s(79468),ea=s(91958),es=s(17489);let et=({wallet:e,settings:a,onAddMoney:s,onWithdraw:r,onViewTransactions:l,onRefresh:i,loading:d})=>(0,t.jsxs)(n.Zp,{className:"bg-gradient-to-br from-primary/10 to-primary/5 border-primary/20",children:[(0,t.jsx)(n.aR,{className:"pb-2",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)("div",{className:"p-2 rounded-full bg-primary/10",children:(0,t.jsx)(u.A,{className:"h-5 w-5 text-primary"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ZB,{className:"text-lg",children:"Wallet Balance"}),(0,t.jsx)(n.BT,{children:"Available funds for purchases"})]})]}),(0,t.jsx)(g.$,{variant:"ghost",size:"icon",onClick:i,disabled:d,children:(0,t.jsx)(ea.A,{className:`h-4 w-4 ${d?"animate-spin":""}`})})]})}),(0,t.jsx)(n.Wu,{children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"text-center py-4",children:[(0,t.jsx)("p",{className:"text-4xl font-bold text-primary",children:e?((e,a="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:a}).format(e))(Number(e.balance),e.currency):"$0.00"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:e?.currency||"USD"})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 justify-center",children:[(0,t.jsxs)(g.$,{onClick:s,className:"gap-2",children:[(0,t.jsx)(R.A,{className:"h-4 w-4"}),"Add Money"]}),a?.withdrawal_enabled&&(0,t.jsxs)(g.$,{variant:"outline",onClick:r,className:"gap-2",children:[(0,t.jsx)(es.A,{className:"h-4 w-4"}),"Withdraw"]}),(0,t.jsxs)(g.$,{variant:"outline",onClick:l,className:"gap-2",children:[(0,t.jsx)(Q.A,{className:"h-4 w-4"}),"Transactions"]})]})]})})]});var er=s(6962),el=s(61878),ei=s(96708),en=s(42268),ed=s(47567),ec=s(35996);let eo=({loading:e,onRefresh:a})=>{let[s,l]=(0,r.useState)([]),[i,d]=(0,r.useState)(0),[o,m]=(0,r.useState)(1),[u,x]=(0,r.useState)(!0),[h,p]=(0,r.useState)(""),[f,N]=(0,r.useState)("all"),[y,v]=(0,r.useState)("all"),b=(0,r.useCallback)(async()=>{x(!0);try{let{data:{user:e}}=await c.N.auth.getUser();if(!e){l([]),d(0);return}let{from:a,to:s}=(0,ec.UZ)(o),t=c.N.from("wallet_transactions").select("*",{count:"exact"}).eq("user_id",e.id).order("created_at",{ascending:!1});"all"!==f&&(t=t.eq("type",f)),"all"!==y&&(t=t.eq("status",y));let r=h.trim();if(r){let e=`%${r}%`;t=t.or(`id.ilike.${e},reference_id.ilike.${e},description.ilike.${e}`)}let{data:i,error:n,count:m}=await t.range(a,s);if(n)throw n;l(i??[]),d(m??0)}catch(e){console.error("Error loading wallet transactions:",e),l([]),d(0)}finally{x(!1)}}
1,[o,h,f,y]);(0,r.useEffect)(()=>{b()},[b]),(0,r.useEffect)(()=>{m(1)},[h,f,y]);let _=(e,a="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:a}).format(e),C=e=>({topup:"Top-up",purchase:"Purchase",refund:"Refund",adjustment:"Adjustment",cashback:"Cashback",withdrawal:"Withdrawal"})[e]||e,S=e=>["topup","refund","cashback"].includes(e)||"adjustment"===e,$=async()=>{try{let{data:{user:e}}=await c.N.auth.getUser();if(!e)return;let a=c.N.from("wallet_transactions").select("*").eq("user_id",e.id).order("created_at",{ascending:!1});"all"!==f&&(a=a.eq("type",f)),"all"!==y&&(a=a.eq("status",y));let s=h.trim();if(s){let e=`%${s}%`;a=a.or(`id.ilike.${e},reference_id.ilike.${e},description.ilike.${e}`)}let{data:t,error:r}=await a;if(r)throw r;let l=["Date,Type,Transaction ID,Reference,Description,Amount,Balance After,Status,Gateway",...(t??[]).map(e=>[(0,w.GP)(new Date(e.created_at),"yyyy-MM-dd HH:mm"),C(e.type),e.id,e.reference_id||"-",e.description||"-",e.amount,e.balance_after??"-",e.status,e.gateway||"-"].join(","))].join("\n"),i=new Blob([l],{type:"text/csv"}),n=window.URL.createObjectURL(i),d=document.createElement("a");d.href=n,d.download=`wallet-transactions-${(0,w.GP)(new Date,"yyyy-MM-dd")}.csv`,d.click()}catch(e){console.error("Wallet export failed:",e)}},F=u||e;return(0,t.jsxs)(n.Zp,{children:[(0,t.jsx)(n.aR,{children:(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ZB,{children:"Transaction History"}),(0,t.jsx)(n.BT,{children:"View all your wallet transactions"})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)(g.$,{variant:"outline",size:"sm",onClick:()=>{b(),a()},disabled:F,children:[(0,t.jsx)(ea.A,{className:`h-4 w-4 mr-2 ${F?"animate-spin":""}`}),"Refresh"]}),(0,t.jsxs)(g.$,{variant:"outline",size:"sm",onClick:()=>void $(),children:[(0,t.jsx)(er.A,{className:"h-4 w-4 mr-2"}),"Export"]})]})]})}),(0,t.jsxs)(n.Wu,{children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row gap-4 mb-4",children:[(0,t.jsxs)("div",{className:"relative flex-1",children:[(0,t.jsx)(el.A,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,t.jsx)(j.p,{placeholder:"Search by reference or description...",value:h,onChange:e=>p(e.target.value),className:"pl-10"})]}),(0,t.jsxs)(k.l6,{value:f,onValueChange:N,children:[(0,t.jsx)(k.bq,{className:"w-[150px]",children:(0,t.jsx)(k.yv,{placeholder:"Type"})}),(0,t.jsxs)(k.gC,{children:[(0,t.jsx)(k.eb,{value:"all",children:"All Types"}),(0,t.jsx)(k.eb,{value:"topup",children:"Top-up"}),(0,t.jsx)(k.eb,{value:"purchase",children:"Purchase"}),(0,t.jsx)(k.eb,{value:"refund",children:"Refund"}),(0,t.jsx)(k.eb,{value:"adjustment",children:"Adjustment"}),(0,t.jsx)(k.eb,{value:"cashback",children:"Cashback"}),(0,t.jsx)(k.eb,{value:"withdrawal",children:"Withdrawal"})]})]}),(0,t.jsxs)(k.l6,{value:y,onValueChange:v,children:[(0,t.jsx)(k.bq,{className:"w-[150px]",children:(0,t.jsx)(k.yv,{placeholder:"Status"})}),(0,t.jsxs)(k.gC,{children:[(0,t.jsx)(k.eb,{value:"all",children:"All Status"}),(0,t.jsx)(k.eb,{value:"success",children:"Success"}),(0,t.jsx)(k.eb,{value:"pending",children:"Pending"}),(0,t.jsx)(k.eb,{value:"failed",children:"Failed"}),(0,t.jsx)(k.eb,{value:"cancelled",children:"Cancelled"})]})]})]}),(0,t.jsx)("div",{className:"border rounded-lg overflow-hidden",children:(0,t.jsxs)(G.XI,{children:[(0,t.jsx)(G.A0,{children:(0,t.jsxs)(G.Hj,{children:[(0,t.jsx)(G.nd,{children:"Date"}),(0,t.jsx)(G.nd,{children:"Type"}),(0,t.jsx)(G.nd,{children:"Description"}),(0,t.jsx)(G.nd,{children:"Transaction ID"}),(0,t.jsx)(G.nd,{children:"Order Ref"}),(0,t.jsx)(G.nd,{className:"text-right",children:"Amount"}),(0,t.jsx)(G.nd,{className:"text-right",children:"Balance After"}),(0,t.jsx)(G.nd,{children:"Status"})]})}),(0,t.jsx)(G.BF,{children:0===s.length?(0,t.jsx)(G.Hj,{children:(0,t.jsx)(G.nA,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:F?"Loading transactions...":"No transactions found"})}):s.map(e=>{var a;return(0,t.jsxs)(G.Hj,{children:[(0,t.jsx)(G.nA,{className:"whitespace-nowrap",children:(0,w.GP)(new Date(e.created_at),"MMM dd, yyyy HH:mm")}
1),(0,t.jsx)(G.nA,{children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[S(e.type)?(0,t.jsx)(ei.A,{className:"h-4 w-4 text-green-500"}):(0,t.jsx)(en.A,{className:"h-4 w-4 text-red-500"}),C(e.type)]})}),(0,t.jsx)(G.nA,{className:"max-w-[220px] truncate text-sm",title:e.description||void 0,children:e.description||"-"}),(0,t.jsx)(G.nA,{className:"font-mono text-xs",children:e.id}),(0,t.jsx)(G.nA,{className:"font-mono text-xs",children:e.reference_id?e.reference_id.slice(0,8):"-"}),(0,t.jsxs)(G.nA,{className:`text-right font-medium ${S(e.type)?"text-green-600":"text-red-600"}`,children:[S(e.type)?"+":"-",_(Number(e.amount),e.currency)]}),(0,t.jsx)(G.nA,{className:"text-right text-sm text-muted-foreground",children:null!=e.balance_after?_(Number(e.balance_after),e.currency):"-"}),(0,t.jsx)(G.nA,{children:(a=e.status,(0,t.jsx)(A.E,{variant:{success:"default",pending:"secondary",failed:"destructive",cancelled:"outline"}[a]||"outline",children:a}))})]},e.id)})})]})}),(0,t.jsx)(ed.h,{className:"mt-4",page:o,total:i,onPageChange:m,noun:"transactions"})]})]})};var em=s(62791),eu=s(13545);let ex=({topups:e})=>{let a=e.filter(e=>"pending"===e.status);return 0===a.length?null:(0,t.jsxs)(n.Zp,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20 dark:border-amber-800",children:[(0,t.jsxs)(n.aR,{className:"pb-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(H.A,{className:"h-5 w-5 text-amber-600"}),(0,t.jsx)(n.ZB,{className:"text-lg",children:"Pending Top-ups"})]}),(0,t.jsx)(n.BT,{children:"These top-up requests are awaiting processing"})]}),(0,t.jsx)(n.Wu,{children:(0,t.jsx)("div",{className:"space-y-3",children:a.map(e=>{var a;return(0,t.jsxs)("div",{className:"flex items-center justify-between p-3 bg-background rounded-lg border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(e=>{switch(e){case"pending":return(0,t.jsx)(H.A,{className:"h-4 w-4 text-amber-500"});case"approved":case"completed":return(0,t.jsx)(L.A,{className:"h-4 w-4 text-green-500"});case"rejected":case"failed":return(0,t.jsx)(em.A,{className:"h-4 w-4 text-red-500"});default:return(0,t.jsx)(eu.A,{className:"h-4 w-4 text-muted-foreground"})}})(e.status),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:((e,a="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:a}).format(e))(Number(e.amount),e.currency)}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:[{stripe:"Credit/Debit Card",paypal:"PayPal",bank_transfer:"Bank Transfer",crypto:"Cryptocurrency"}[a=e.method]||a," • ",(0,w.GP)(new Date(e.created_at),"MMM dd, HH:mm")]})]})]}),(0,t.jsx)(A.E,{variant:"secondary",className:"capitalize",children:e.status})]},e.id)})})})]})};var eh=s(90027),ep=s(38654);let ef=()=>{let{wallet:e,transactions:a,topups:s,settings:l,loading:i,refetch:n}=(0,ee.v)(),[c,m]=(0,r.useState)(!1),[x,h]=(0,r.useState)("overview"),{toast:p}=(0,v.dj)(),f=(0,r.useRef)(!1);if((0,r.useEffect)(()=>{if(f.current)return;let e=window.location.search;(e.includes("topup_id")||e.includes("paypal_return"))&&(f.current=!0,(async()=>{let a=await (0,ep.Tm)(e);window.history.replaceState({},"","/profile?tab=wallet"),"captured"===a.status?(p({title:"Wallet topped up",description:"Your PayPal payment was successful. Your balance has been updated."}),await n()):"cancelled"===a.status?(p({title:"Payment cancelled",description:"No money was added to your wallet.",variant:"destructive"}),await n()):"capture_failed"===a.status&&(p({title:"PayPal payment failed",description:a.message,variant:"destructive"}),await n())})())},[p,n]),i)return(0,t.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,t.jsx)(o.A,{className:"h-8 w-8 animate-spin text-primary"})});if(!l?.wallet_enabled)return(0,t.jsxs)("div",{className:"text-center py-12",children:[(0,t.jsx)(u.A,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),(0,t.jsx)("h3",{className:"text-lg font-medium",children:"Wallet Feature Disabled"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"The wallet feature is currently not available."})]});let j=s.filter(e=>"pending"===e.status).length;return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)(d.tU,{value:x,onValueChange:h,children:[(0,t.jsxs)(d.j7,{className:"grid w-full grid-cols-3 max-w-md",children:[(0,t.jsxs)(d.Xi,{value:"overview",className:"flex items-center gap-2",children:[(0,t.jsx)(u.A,{className:"h-4 w-4"}),"Overview"]}),(0,t.jsxs)(d.Xi,{value:"transactions",className:"flex items-center gap-2",children:[(0,t.jsx)(Q.A,{className:"h-4 w-4"}),"History"]}),(0,t.jsxs)(d.Xi,{value:"topups",className:"flex items-center gap-2 relative",children:[(0,t.jsx)(H.A,{className:"h-4 w-4"}),"Top-ups",j>0&&(0,t.jsx)("span",{className:"absolute -top-1 -right-1 h-5 w-5 rounded-full bg-amber-500 text-white text-xs flex items-center justify-center",children:j})]})]}),(0,t.jsxs)(d.av,{value:"overview",className:"mt-6 space-y-6",children:[(0,t.jsx)(et,{wallet:e,settings:l,onAddMoney:()=>m(!0),onWithdraw:()=>{},onViewTransactions:()=>h("transactions"),onRefresh:n,loading:i}),(0,t.jsx)(ex,{topups:s}),a.length>0&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"font-medium",children:"Recent Activity"}),(0,t.jsx)("div",{className:"space-y-2",children:a.slice(0,5).map(e=>(0,t.jsxs)("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded-lg",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium capitalize",children:e.type}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:new Date(e.created_at).toLocaleDateString()})]}),(0,t.jsxs)("span",{className:`font-medium ${["topup","refund","cashback"].includes(e.type)?"text-green-600":"text-red-600"}`,children:[["topup","refund","cashback"].includes(e.type)?"+":"-","$",
1Number(e.amount).toFixed(2)]})]},e.id))})]})]}),(0,t.jsx)(d.av,{value:"transactions",className:"mt-6",children:(0,t.jsx)(eo,{loading:i,onRefresh:n})}),(0,t.jsx)(d.av,{value:"topups",className:"mt-6",children:(0,t.jsx)("div",{className:"space-y-4",children:0===s.length?(0,t.jsxs)("div",{className:"text-center py-12 text-muted-foreground",children:[(0,t.jsx)(H.A,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,t.jsx)("p",{children:"No top-up requests yet"})]}):(0,t.jsx)("div",{className:"space-y-3",children:s.map(e=>(0,t.jsxs)("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{className:"font-medium",children:["$",Number(e.amount).toFixed(2)]}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground capitalize",children:[e.method.replace("_"," ")," • ",new Date(e.created_at).toLocaleDateString()]}),e.txn_reference&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground font-mono",children:["Ref: ",e.txn_reference]})]}),(0,t.jsx)("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${"completed"===e.status?"bg-green-100 text-green-700":"pending"===e.status?"bg-amber-100 text-amber-700":"rejected"===e.status?"bg-red-100 text-red-700":"bg-muted text-muted-foreground"}`,children:e.status})]},e.id))})})})]}),(0,t.jsx)(eh.m,{open:c,onOpenChange:m,settings:l,walletId:e?.id||null,onSuccess:n})]})},ej=()=>(0,t.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-background",children:(0,t.jsx)("div",{className:"w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin"})}),eN=()=>{let[e,a]=(0,r.useState)(!1);(0,r.useEffect)(()=>a(!0),[]);let s=(0,i.Zp)(),[j,N]=(0,i.ok)(),[g,y]=(0,r.useState)(!0),v=async()=>{let{data:{session:e}}=await c.N.auth.getSession();e?y(!1):s("/auth")};(0,r.useEffect)(()=>{v()},[]);let b=j.get("tab")||"profile";return e?g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(f.default,{}),(0,t.jsx)("div",{className:"min-h-screen flex items-center justify-center",children:(0,t.jsx)(o.A,{className:"h-8 w-8 animate-spin text-primary"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(l.mg,{children:[(0,t.jsx)("meta",{name:"robots",content:"noindex, nofollow"}),(0,t.jsx)("title",{children:"My Profile | Guestpost Software"})]}),(0,t.jsx)(f.default,{}),(0,t.jsx)("div",{className:"container mx-auto px-4 py-8 max-w-4xl",children:(0,t.jsxs)(n.Zp,{children:[(0,t.jsxs)(n.aR,{children:[(0,t.jsx)(n.ZB,{children:"My Profile"}),(0,t.jsx)(n.BT,{children:"Manage your account settings and preferences"})]}),(0,t.jsx)(n.Wu,{children:(0,t.jsxs)(d.tU,{value:b,onValueChange:e=>{N({tab:e})},className:"w-full",children:[(0,t.jsxs)(d.j7,{className:"grid w-full grid-cols-5 mb-6 h-auto",children:[(0,t.jsxs)(d.Xi,{value:"profile",className:"flex items-center gap-2 py-2.5",children:[(0,t.jsx)(m.A,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Profile Info"}),(0,t.jsx)("span",{className:"sm:hidden",children:"Profile"})]}),(0,t.jsxs)(d.Xi,{value:"wallet",className:"flex items-center gap-2",children:[(0,t.jsx)(u.A,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Wallet"}),(0,t.jsx)("span",{className:"sm:hidden",children:"Wallet"})]}),(0,t.jsxs)(d.Xi,{value:"addresses",className:"flex items-center gap-2",children:[(0,t.jsx)(x.A,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Addresses"}),(0,t.jsx)("span",{className:"sm:hidden",children:"Addresses"})]}),(0,t.jsxs)(d.Xi,{value:"payment",className:"flex items-center gap-2",children:[(0,t.jsx)(h.A,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Payment"}),(0,t.jsx)("span",{className:"sm:hidden",children:"Payment"})]}),(0,t.jsxs)(d.Xi,{value:"referral",className:"flex items-center gap-2",children:[(0,t.jsx)(p.A,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Referral"}),(0,t.jsx)("span",{className:"sm:hidden",children:"Referral"})]})]}),(0,t.jsx)(d.av,{value:"profile",className:"mt-0",children:(0,t.jsx)(C,{})}),(0,t.jsx)(d.av,{value:"wallet",className:"mt-0",children:(0,t.jsx)(ef,{})}),(0,t.jsx)(d.av,{value:"addresses",className:"mt-0",children:(0,t.jsx)(z,{mode:"manage"})}),(0,t.jsx)(d.av,{value:"payment",className:"mt-0",children:(0,t.jsx)(B,{})}),(0,t.jsx)(d.av,{value:"referral",className:"mt-0",children:(0,t.jsx)(K,{})})]})})]})})]}):(0,t.jsx)(ej,{})}},81477:(e,a,s)=>{s.d(a,{BT:()=>c,Wu:()=>o,ZB:()=>d,Zp:()=>i,aR:()=>n,wL:()=>m});var t=s(95155),r=s(12115),l=s(40980);let i=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("div",{ref:s,className:(0,l.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",e),...a}));
1i.displayName="Card";let n=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("div",{ref:s,className:(0,l.cn)("flex flex-col space-y-1.5 p-6",e),...a}));n.displayName="CardHeader";let d=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("h3",{ref:s,className:(0,l.cn)("text-2xl font-semibold leading-none tracking-tight",e),...a}));d.displayName="CardTitle";let c=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("p",{ref:s,className:(0,l.cn)("text-sm text-muted-foreground",e),...a}));c.displayName="CardDescription";let o=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("div",{ref:s,className:(0,l.cn)("p-6 pt-0",e),...a}));o.displayName="CardContent";let m=r.forwardRef(({className:e,...a},s)=>(0,t.jsx)("div",{ref:s,className:(0,l.cn)("flex items-center p-6 pt-0",e),...a}));m.displayName="CardFooter"},85106:(e,a,s)=>{s.d(a,{V:()=>i});var t=s(12115),r=s(56339),l=s(4109);let i=()=>{let[e,a]=(0,t.useState)(null);(0,t.useEffect)(()=>{r.N.auth.getSession().then(({data:{session:e}})=>{a(e?.user?.id||null)});let{data:{subscription:e}}=r.N.auth.onAuthStateChange((e,s)=>{a(s?.user?.id||null)});return()=>e.unsubscribe()},[]);let{data:s,isLoading:i,refetch:n}=(0,l.I)({queryKey:["user-referral-code",e],queryFn:async()=>{if(!e)return null;let{data:a,error:s}=await r.N.from("user_referral_codes").select("*").eq("user_id",e).single();if(a)return a;let{data:t,error:l}=await r.N.rpc("get_or_create_referral_code",{p_user_id:e});if(l)return console.error("Error creating referral code:",l),null;let{data:i}=await r.N.from("user_referral_codes").select("*").eq("user_id",e).single();return i},enabled:!!e}),{data:d}=(0,l.I)({queryKey:["user-referral-commissions",e],queryFn:async()=>{if(!e)return[];let{data:a,error:s}=await r.N.from("referral_commissions").select("*").eq("referrer_user_id",e).order("created_at",{ascending:!1});if(s)throw s;return a},enabled:!!e}),c=d?.filter(e=>"pending"===e.status).reduce((e,a)=>e+Number(a.commission_amount),0)||0,o=d?.filter(e=>"approved"===e.status).reduce((e,a)=>e+Number(a.commission_amount),0)||0,m=d?.filter(e=>"paid"===e.status).reduce((e,a)=>e+Number(a.commission_amount),0)||0,u=(0,t.useMemo)(()=>s?.ref_code?`${window.location.origin}?ref=${s.ref_code}`:null,[s?.ref_code]);return{referralCode:s?.ref_code||null,referralLink:u,stats:s||null,commissions:d||[],pendingEarnings:c,approvedEarnings:o,paidEarnings:m,isLoading:i,refetch:n,isLoggedIn:!!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.