import{r as m,j as e,s as C,_ as s,d as le}from"./wp-i18n-shim-DUX0OV_V.js";import{C as K}from"./CrudLayout-DRSWmVk9.js";import"./apiConfig-BA13wrqF.js";import{a as A}from"./index-CLZ4-rw6.js";import{f as q}from"./priceFormatter-Dg4GlACg.js";import{f as T,a as E}from"./dateTimeFormat-yH4yHSCh.js";import{c as D,X as de}from"./utils-Bl0WAcve.js";import{U as ce}from"./user-bjdz1CQT.js";import{b as me,C as z,d as Q,c as Z}from"./CalenderCheck-2TB2QVYq.js";import{C as xe}from"./Combination-BuKwnoTc.js";import{C as ue}from"./copy-CujkJL51.js";import{k as W,j as B,W as ee,l as se,R as pe,e as X}from"./index-D01LF5Le.js";import{C as ge}from"./circle-check-big-Bxgqw2u9.js";import{D as G}from"./dollar-sign-Bnksw8VW.js";import{e as y,s as I}from"./toast-1-c8k_LJ.js";import{S as R}from"./skeleton-DfFmlQ5i.js";import{S as he,a as be,b as je,c as ye,f as fe}from"./select-BFNitOb0.js";import{L as Ne}from"./loader-circle-CcSu72zH.js";import{R as te}from"./refresh-cw-DB5brqih.js";import{E as ke}from"./eye-BNq7Nif8.js";import{P as ae}from"./ProUpgradeBanner-B_761Fa7.js";import"./vendor-DDjlQeP6.js";import"./ArrowLeftIcon-C8q2jgKs.js";import"./withIconDefaults-BJCqj2oX.js";import"./preload-helper-Dp1pzeXC.js";import"./calendar-Cz3-D5io.js";import"./tag-8m_NofXN.js";import"./shield-DVSNyXBB.js";import"./proxy-CtW-P0pQ.js";import"./index-Bl84CzKv.js";import"./crown-CcV7MJml.js";/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const _e=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],ve=D("arrow-down-right",_e);/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const we=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],Ce=D("arrow-up-right",we);/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Pe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],U=D("circle-pause",Pe);/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Se=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]],Ae=D("circle-play",Se),$="/radius-booking/v1/payouts",$e=(t={})=>{const n=new URLSearchParams(t).toString();return A({path:`${$}?${n}`,method:"GET"})},Fe=(t,n="")=>A({path:`${$}/${t}/approve`,method:"POST",data:{admin_note:n}}),Re=(t,n="")=>A({path:`${$}/${t}/complete`,method:"POST",data:{admin_note:n}}),Te=(t,n="")=>A({path:`${$}/${t}/reject`,method:"POST",data:{admin_note:n}}),Le=(t,n="")=>A({path:`${$}/${t}/hold`,method:"POST",data:{admin_note:n}}),Ie=(t,n="")=>A({path:`${$}/${t}/unhold`,method:"POST",data:{admin_note:n}}),Oe=(t={})=>{const n=new URLSearchParams(t).toString();return A({path:`${$}/admin-income${n?`?${n}`:""}`,method:"GET"})},Be={pending:"bg-yellow-100 text-yellow-800",processing:"bg-blue-100 text-blue-800",on_hold:"bg-orange-100 text-orange-800",paid:"bg-green-100 text-green-800",rejected:"bg-red-100 text-red-800"},De={pending:s("Pending","radius-booking"),processing:s("Processing","radius-booking"),on_hold:s("On Hold","radius-booking"),paid:s("Paid","radius-booking"),rejected:s("Rejected","radius-booking")};function Ee({payout:t,onClose:n,onApprove:l,onComplete:P,onReject:o,onHold:S,onUnhold:x,isProcessing:h}){var j,p,w;const[b,_]=m.useState(""),[f,u]=m.useState(null);if(!t)return null;const v=c=>q(parseFloat(c||0).toFixed(2),t==null?void 0:t.currency),r=c=>{h||(c==="approve"&&l(t.id,b),c==="complete"&&P(t.id,b),c==="reject"&&o(t.id,b),c==="hold"&&(S==null||S(t.id,b)),c==="unhold"&&(x==null||x(t.id,b)),_(""))};return e.jsx("div",{className:"fixed inset-0 z-[999] flex items-center justify-center bg-black/50",onClick:n,children:e.jsxs("div",{className:"bg-white rounded-xl shadow-2xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",onClick:c=>c.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-title",children:C(s("Payout #%s","radius-booking"),t.id)}),e.jsx("span",{className:`inline-block mt-1 text-xs font-medium px-2.5 py-0.5 rounded-full ${Be[t.status]}`,children:De[t.status]||t.status})]}),e.jsx("button",{onClick:n,className:"p-1 hover:bg-gray-100 rounded-lg transition-colors",children:e.jsx(de,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"px-6 py-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 rounded-lg",children:[e.jsx(ce,{className:"w-5 h-5 text-gray-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:s("Staff","radius-booking")}),e.jsx("p",{className:"font-medium text-title",children:t.employee_name})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg text-center",children:[e.jsx("p",{className:"text-xs text-gray-500 mb-1",children:s("Gross Amount","radius-booking")}),e.jsx("p",{className:"font-semibold text-title",children:v(t.amount)})]}),e.jsxs("div",{className:"p-3 bg-primary/5 rounded-lg text-center",children:[e.jsx("p",{className:"text-xs text-gray-500 mb-1",children:s("Net Amount","radius-booking")}),e.jsx("p",{className:"font-semibold text-primary",children:v(t.net_amount)})]})]}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[e.jsx("span",{className:"text-gray-500",children:s("Payout Method","radius-booking")}),e.jsx("span",{className:"font-medium text-title capitalize",children:t.payout_method_label||((j=t.payout_method)==null?void 0:j.replace("_"," "))})]}),e.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[e.jsx("span",{className:"text-gray-500",children:s("Requested","radius-booking")}),e.jsx("span",{className:"font-medium text-title",children:T(t.created_at)})]}),t.processed_at&&e.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[e.jsx("span",{className:"text-gray-500",children:s("Processed","radius-booking")}),e.jsx("span",{className:"font-medium text-title",children:T(t.processed_at)})]}),t.completed_at&&e.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[e.jsx("span",{className:"text-gray-500",children:s("Completed","radius-booking")}),e.jsx("span",{className:"font-medium text-title",children:T(t.completed_at)})]}),t.processed_by_name&&e.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[e.jsx("span",{className:"text-gray-500",children:s("Processed By","radius-booking")}),e.jsx("span",{className:"font-medium text-title",children:t.processed_by_name})]})]}),t.payment_info&&t.payment_info.length>0&&e.jsxs("div",{className:"p-3 bg-blue-50 rounded-lg border border-blue-100",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(me,{className:"w-4 h-4 text-blue-500"}),e.jsx("p",{className:"text-xs font-semibold text-blue-700",children:C(s("Payment Details — %s","radius-booking"),t.payout_method_label||((p=t.payout_method)==null?void 0:p.replace("_"," ")))})]}),e.jsx("div",{className:"space-y-1.5",children:t.payment_info.map((c,k)=>e.jsxs("div",{className:"flex items-center justify-between gap-2 py-1.5 px-2 bg-white rounded-md border border-blue-100",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] text-gray-400",children:c.label}),e.jsx("p",{className:"text-sm font-medium text-title break-all",children:c.value})]}),e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(c.value),u(k),setTimeout(()=>u(null),1500)},className:"p-1 text-gray-400 hover:text-blue-600 rounded transition-colors shrink-0",title:s("Copy","radius-booking"),children:f===k?e.jsx(xe,{className:"w-3.5 h-3.5 text-green-500"}):e.jsx(ue,{className:"w-3.5 h-3.5"})})]},k))})]}),(!t.payment_info||t.payment_info.length===0)&&(t.status==="pending"||t.status==="processing"||t.status==="on_hold")&&e.jsx("div",{className:"p-3 bg-amber-50 rounded-lg border border-amber-100",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4 text-amber-500"}),e.jsxs("p",{className:"text-xs text-amber-700",children:[s("Staff has not provided payment details for","radius-booking")," ",e.jsx("span",{className:"font-medium",children:t.payout_method_label||((w=t.payout_method)==null?void 0:w.replace("_"," "))}),"."]})]})}),t.employee_note&&e.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(W,{className:"w-4 h-4 text-gray-400"}),e.jsx("p",{className:"text-xs font-medium text-gray-500",children:s("Staff Note","radius-booking")})]}),e.jsx("p",{className:"text-sm text-title",children:t.employee_note})]}),t.admin_note&&e.jsxs("div",{className:"p-3 bg-blue-50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(W,{className:"w-4 h-4 text-blue-400"}),e.jsx("p",{className:"text-xs font-medium text-blue-600",children:s("Admin Note","radius-booking")})]}),e.jsx("p",{className:"text-sm text-title",children:t.admin_note})]}),(t.status==="pending"||t.status==="processing"||t.status==="on_hold")&&e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx("textarea",{value:b,onChange:c=>_(c.target.value),placeholder:s("Admin note (optional)","radius-booking"),className:"w-full p-3 text-sm border border-gray-200 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary",rows:2}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>r("approve"),disabled:h,className:"flex-1 min-w-[140px] flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors disabled:opacity-50",children:[e.jsx(ge,{className:"w-4 h-4"}),s("Move to Processing","radius-booking")]}),e.jsxs("button",{onClick:()=>r("hold"),disabled:h,className:"flex-1 min-w-[140px] flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-white bg-orange-500 hover:bg-orange-600 rounded-lg transition-colors disabled:opacity-50",children:[e.jsx(U,{className:"w-4 h-4"}),s("Put On Hold","radius-booking")]}),e.jsxs("button",{onClick:()=>r("reject"),disabled:h,className:"flex-1 min-w-[140px] flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors disabled:opacity-50",children:[e.jsx(B,{className:"w-4 h-4"}),s("Reject","radius-booking")]})]}),t.status==="processing"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>r("complete"),disabled:h,className:"flex-1 min-w-[140px] flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-lg transition-colors disabled:opacity-50",children:[e.jsx(G,{className:"w-4 h-4"}),s("Mark Paid","radius-booking")]}),e.jsxs("button",{onClick:()=>r("hold"),disabled:h,className:"flex-1 min-w-[140px] flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-white bg-orange-500 hover:bg-orange-600 rounded-lg transition-colors disabled:opacity-50",children:[e.jsx(U,{className:"w-4 h-4"}),s("Put On Hold","radius-booking")]}),e.jsxs("button",{onClick:()=>r("reject"),disabled:h,className:"flex-1 min-w-[140px] flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors disabled:opacity-50",children:[e.jsx(B,{className:"w-4 h-4"}),s("Reject","radius-booking")]})]}),t.status==="on_hold"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>r("unhold"),disabled:h,className:"flex-1 min-w-[140px] flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors disabled:opacity-50",children:[e.jsx(Ae,{className:"w-4 h-4"}),s("Resume","radius-booking")]}),e.jsxs("button",{onClick:()=>r("reject"),disabled:h,className:"flex-1 min-w-[140px] flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors disabled:opacity-50",children:[e.jsx(B,{className:"w-4 h-4"}),s("Reject","radius-booking")]})]})]})]})]})]})})}const M=[{key:"all",label:s("All","radius-booking")},{key:"pending",label:s("Pending","radius-booking"),icon:z,color:"text-yellow-600"},{key:"processing",label:s("Processing","radius-booking"),icon:Ne,color:"text-blue-600"},{key:"on_hold",label:s("On Hold","radius-booking"),icon:U,color:"text-orange-600"},{key:"paid",label:s("Paid","radius-booking"),icon:G,color:"text-green-600"},{key:"rejected",label:s("Rejected","radius-booking"),icon:B,color:"text-red-600"}],Y={pending:"bg-yellow-100 text-yellow-800",processing:"bg-blue-100 text-blue-800",on_hold:"bg-orange-100 text-orange-800",paid:"bg-green-100 text-green-800",rejected:"bg-red-100 text-red-800"},Me={pending:["processing","on_hold","rejected"],processing:["paid","on_hold","rejected"],on_hold:["processing","rejected"],paid:[],rejected:[]},re=8;function Ue({rows:t=8}){return e.jsx("tbody",{children:Array.from({length:t}).map((n,l)=>e.jsx("tr",{className:"border-b border-gray-50",children:Array.from({length:re}).map((P,o)=>e.jsx("td",{className:"px-4 py-3.5",children:e.jsx(R,{className:`h-5 ${o===1?"w-28":o===6?"w-16":"w-20"}`})},o))},l))})}function J(){const[t,n]=m.useState([]),[l,P]=m.useState({current_page:1,last_page:1,total:0}),[o,S]=m.useState({}),[x,h]=m.useState("all"),[b,_]=m.useState(!0),[f,u]=m.useState(null),[v,r]=m.useState(!1),j=(a,d)=>q(parseFloat(a||0).toFixed(2),d),p=m.useCallback(async(a=1,d=x)=>{var i,L;try{_(!0);const F={page:a,per_page:15};d&&d!=="all"&&(F.status=d);const g=await $e(F);g.success&&(n(g.data||[]),P(((i=g.meta)==null?void 0:i.pagination)||{current_page:1,last_page:1,total:0}),(L=g.meta)!=null&&L.status_counts&&S(g.meta.status_counts))}catch{y(s("Failed to load payouts","radius-booking"))}finally{_(!1)}},[x]);m.useEffect(()=>{p(1,x)},[x]);const w=async(a,d)=>{try{r(!0);const i=await Fe(a,d);i.success?(I(i.message||s("Payout approved","radius-booking")),u(null),p(l.current_page,x)):y(i.message||s("Failed to approve","radius-booking"))}catch{y(s("Failed to approve payout","radius-booking"))}finally{r(!1)}},c=async(a,d)=>{try{r(!0);const i=await Re(a,d);i.success?(I(i.message||s("Payout completed","radius-booking")),u(null),p(l.current_page,x)):y(i.message||s("Failed to complete","radius-booking"))}catch{y(s("Failed to complete payout","radius-booking"))}finally{r(!1)}},k=async(a,d)=>{try{r(!0);const i=await Te(a,d);i.success?(I(i.message||s("Payout rejected","radius-booking")),u(null),p(l.current_page,x)):y(i.message||s("Failed to reject","radius-booking"))}catch{y(s("Failed to reject payout","radius-booking"))}finally{r(!1)}},N=async(a,d)=>{try{r(!0);const i=await Le(a,d);i.success?(I(i.message||s("Payout placed on hold","radius-booking")),u(null),p(l.current_page,x)):y(i.message||s("Failed to place on hold","radius-booking"))}catch{y(s("Failed to place payout on hold","radius-booking"))}finally{r(!1)}},H=async(a,d)=>{try{r(!0);const i=await Ie(a,d);i.success?(I(i.message||s("Payout resumed","radius-booking")),u(null),p(l.current_page,x)):y(i.message||s("Failed to resume","radius-booking"))}catch{y(s("Failed to resume payout","radius-booking"))}finally{r(!1)}},ie=(a,d)=>{if(!(v||d===a.status))switch(d){case"processing":return a.status==="on_hold"?H(a.id,""):w(a.id,"");case"paid":return c(a.id,"");case"on_hold":return N(a.id,"");case"rejected":return k(a.id,"");default:return}};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[M.map(a=>{const d=o[a.key]||0,i=x===a.key;return e.jsxs("button",{onClick:()=>h(a.key),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg transition-colors ${i?"bg-primary text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[a.icon&&e.jsx(a.icon,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:a.label}),e.jsxs("span",{className:`text-xs font-medium ${i?"text-white/80":"text-gray-400"}`,children:["(",d,")"]})]},a.key)}),e.jsx("button",{onClick:()=>p(1,x),className:"ml-auto p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-lg transition-colors",title:s("Refresh","radius-booking"),children:e.jsx(te,{className:`w-4 h-4 ${b?"animate-spin":""}`})})]}),e.jsxs("div",{className:"bg-white border border-border rounded-xl overflow-hidden",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50 border-b border-border",children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("ID","radius-booking")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Staff","radius-booking")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Amount","radius-booking")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Net","radius-booking")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Method","radius-booking")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Status","radius-booking")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Date","radius-booking")}),e.jsx("th",{className:"text-center px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Actions","radius-booking")})]})}),b?e.jsx(Ue,{}):t.length===0?e.jsx("tbody",{children:e.jsx("tr",{children:e.jsx("td",{colSpan:re,className:"px-4 py-12 text-center text-sm text-gray-500",children:s("No payouts found","radius-booking")})})}):e.jsx("tbody",{className:"divide-y divide-gray-100",children:t.map(a=>{var d;return e.jsxs("tr",{className:"hover:bg-gray-50/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 text-sm font-medium text-title",children:C(s("#%s","radius-booking"),a.id)}),e.jsx("td",{className:"px-4 py-3 text-sm text-title",children:a.employee_name}),e.jsx("td",{className:"px-4 py-3 text-sm font-medium text-title",children:j(a.amount,a==null?void 0:a.currency)}),e.jsx("td",{className:"px-4 py-3 text-sm font-medium text-green-600",children:j(a.net_amount,a==null?void 0:a.currency)}),e.jsx("td",{className:"px-4 py-3 text-sm text-title capitalize",children:a.payout_method_label||((d=a.payout_method)==null?void 0:d.replace("_"," "))}),e.jsx("td",{className:"px-4 py-3",children:(()=>{var F;const i=Me[a.status]||[],L=((F=M.find(g=>g.key===a.status))==null?void 0:F.label)||a.status;return i.length===0?e.jsx("span",{className:`inline-block text-xs font-medium px-2.5 py-0.5 rounded-full ${Y[a.status]}`,children:L}):e.jsxs(he,{value:a.status,disabled:v,onValueChange:g=>ie(a,g),children:[e.jsx(be,{className:`min-h-[31px]  px-3 py-2 text-xs font-medium  border-0 shadow-none gap-1 w-auto ${Y[a.status]}`,children:e.jsx(je,{children:L})}),e.jsx(ye,{children:i.map(g=>{var V;const ne=((V=M.find(oe=>oe.key===g))==null?void 0:V.label)||g;return e.jsx(fe,{value:g,className:"text-sm",children:ne},g)})})]})})()}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500",children:T(a.created_at)}),e.jsx("td",{className:"px-4 py-3 text-center",children:e.jsx("button",{onClick:()=>u(a),className:"p-1.5 text-gray-500 hover:text-primary hover:bg-primary/5 rounded-lg transition-colors",title:s("View details","radius-booking"),children:e.jsx(ke,{className:"w-4 h-4"})})})]},a.id)})})]})}),l.last_page>1&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-border",children:[e.jsx("p",{className:"text-sm text-gray-500",children:C(s("Page %1$s of %2$s (%3$s total)","radius-booking"),l.current_page,l.last_page,l.total)}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>p(l.current_page-1,x),disabled:l.current_page<=1,className:"p-1.5 rounded-lg hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsx(Q,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>p(l.current_page+1,x),disabled:l.current_page>=l.last_page,className:"p-1.5 rounded-lg hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsx(Z,{className:"w-4 h-4"})})]})]})]}),f&&e.jsx(Ee,{payout:f,onClose:()=>u(null),onApprove:w,onComplete:c,onReject:k,onHold:N,onUnhold:H,isProcessing:v})]})}function qe(){var n;const t=!!((n=window.radius_booking_param)!=null&&n.is_pro);return e.jsx(K,{title:s("Payouts","radius-booking"),description:s("Manage employee payout requests","radius-booking"),icon:e.jsx(ee,{className:"w-5 h-5 text-primary-colordefault"}),children:t?e.jsx(J,{}):e.jsxs("div",{children:[e.jsx(ae,{title:s("Payouts","radius-booking"),type:"setting"}),e.jsx("div",{className:"pointer-events-none select-none opacity-50 mt-4",children:e.jsx(J,{})})]})})}const ze=m.memo(qe),Ge={paid:"bg-green-100 text-green-800",partial_payment:"bg-blue-100 text-blue-800"},He={paid:s("Paid","radius-booking"),partial_payment:s("Partial Payment","radius-booking")};function O(){return e.jsxs("div",{className:"bg-white border border-border rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx(R,{className:"w-11 h-11 rounded-xl"}),e.jsx(R,{className:"w-5 h-5 rounded"})]}),e.jsx(R,{className:"h-8 w-28 mb-2"}),e.jsx(R,{className:"h-3.5 w-36"})]})}function Ve({rows:t=8}){return e.jsx("tbody",{children:Array.from({length:t}).map((n,l)=>e.jsx("tr",{className:"border-b border-gray-50",children:Array.from({length:8}).map((P,o)=>e.jsx("td",{className:"px-4 py-3.5",children:e.jsx(R,{className:`h-5 ${o===2?"w-28":"w-20"}`})},o))},l))})}function We(){const[t,n]=m.useState(null),[l,P]=m.useState([]),[o,S]=m.useState({current_page:1,last_page:1,total:0}),[x,h]=m.useState(null),[b,_]=m.useState(!0),f=m.useCallback(async(r=1)=>{var j,p,w,c,k;try{_(!0);const N=await Oe({page:r,per_page:15});N.success&&(P(N.data||[]),n(((j=N.meta)==null?void 0:j.summary)||null),S(((p=N.meta)==null?void 0:p.pagination)||{current_page:1,last_page:1,total:0}),h(((w=N.meta)==null?void 0:w.currency)||((k=(c=N.meta)==null?void 0:c.summary)==null?void 0:k.currency)||null))}catch{}finally{_(!1)}},[]);m.useEffect(()=>{f(1)},[f]);const u=r=>q(parseFloat(r||0).toFixed(2),x||(t==null?void 0:t.currency)),v=t?[{label:s("Appointment Revenue","radius-booking"),value:u(t.total_appointment_revenue),desc:s("Total from all paid bookings","radius-booking"),icon:G,iconBg:"bg-slate-100",iconColor:"text-slate-600",badge:null},{label:s("Commission Income","radius-booking"),value:u(t.total_commission_earned),desc:t.commission_rate>0?t.commission_type==="percentage"?C(s("%s%% of revenue","radius-booking"),t.commission_rate):C(s("%s per booking","radius-booking"),u(t.commission_rate)):s("No commission set","radius-booking"),icon:se,iconBg:"bg-green-100",iconColor:"text-green-600",badge:e.jsx(Ce,{className:"w-4 h-4 text-green-500"})},{label:s("Paid to Employees","radius-booking"),value:u(t.total_paid_to_employees),desc:s("Completed payout transfers","radius-booking"),icon:ee,iconBg:"bg-blue-100",iconColor:"text-blue-600",badge:e.jsx(ve,{className:"w-4 h-4 text-blue-500"})},{label:s("Pending Payouts","radius-booking"),value:u(t.total_pending_payouts),desc:s("Awaiting approval or completion","radius-booking"),icon:z,iconBg:"bg-amber-100",iconColor:"text-amber-600",badge:null}]:[];return e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:t?v.map(r=>e.jsxs("div",{className:"bg-white border border-border rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:`w-11 h-11 rounded-xl ${r.iconBg} flex items-center justify-center`,children:e.jsx(r.icon,{className:`w-5 h-5 ${r.iconColor}`})}),r.badge]}),e.jsx("p",{className:"text-2xl font-bold text-title",children:r.value}),e.jsx("p",{className:"text-xs text-small-font mt-1",children:r.label}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:r.desc})]},r.label)):e.jsxs(e.Fragment,{children:[e.jsx(O,{}),e.jsx(O,{}),e.jsx(O,{}),e.jsx(O,{})]})}),e.jsxs("div",{className:"bg-white border border-border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-border flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-title",children:s("Appointment Commission","radius-booking")}),e.jsx("p",{className:"text-xs text-small-font mt-0.5",children:o.total>0?C(le("%s paid booking","%s paid bookings",o.total,"radius-booking"),o.total):s("Commission per appointment","radius-booking")})]}),e.jsx("button",{onClick:()=>f(o.current_page),className:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-colors",children:e.jsx(te,{className:`w-4 h-4 ${b?"animate-spin":""}`})})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50 border-b border-border",children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Appointment Date","radius-booking")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Service","radius-booking")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Staff","radius-booking")}),e.jsx("th",{className:"text-right px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Booking Amount","radius-booking")}),e.jsx("th",{className:"text-right px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Commission","radius-booking")}),e.jsx("th",{className:"text-right px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Staff Gets","radius-booking")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Payment","radius-booking")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 uppercase",children:s("Created At","radius-booking")})]})}),b?e.jsx(Ve,{}):l.length===0?e.jsx("tbody",{children:e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"px-4 py-12 text-center text-sm text-gray-500",children:s("No paid appointments found","radius-booking")})})}):e.jsx("tbody",{className:"divide-y divide-gray-100",children:l.map(r=>{var j;return e.jsxs("tr",{className:"hover:bg-gray-50/50 transition-colors",children:[e.jsxs("td",{className:"px-4 py-3 text-sm text-title whitespace-nowrap",children:[e.jsx("div",{children:T(r.appointment_date)}),e.jsxs("div",{className:"text-[11px] text-small-font",children:[E(r.start_time)," - ",E(r.end_time)]})]}),e.jsx("td",{className:"px-4 py-3 text-sm text-title",children:r.service_name}),e.jsx("td",{className:"px-4 py-3 text-sm text-title",children:r.employee_name}),e.jsx("td",{className:"px-4 py-3 text-sm font-medium text-title text-right",children:u(r.paid_amount)}),e.jsxs("td",{className:"px-4 py-3 text-sm font-semibold text-green-600 text-right",children:["+",u(r.commission)]}),e.jsx("td",{className:"px-4 py-3 text-sm text-small-font text-right",children:u(r.employee_earning)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-block text-xs font-medium px-2 py-0.5 rounded-full ${Ge[r.payment_status]||"bg-gray-100 text-gray-700"}`,children:He[r.payment_status]||((j=r.payment_status)==null?void 0:j.replace("_"," "))})}),e.jsx("td",{className:"px-4 py-3 text-sm text-title whitespace-nowrap",children:r.created_at?e.jsxs(e.Fragment,{children:[e.jsx("div",{children:T(r.created_at)}),e.jsx("div",{className:"text-[11px] text-small-font",children:E(r.created_at)})]}):e.jsx("span",{className:"text-small-font",children:"—"})})]},r.appointment_id)})})]})}),o.last_page>1&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-border",children:[e.jsx("p",{className:"text-sm text-gray-500",children:C(s("Page %1$s of %2$s (%3$s total)","radius-booking"),o.current_page,o.last_page,o.total)}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>f(o.current_page-1),disabled:o.current_page<=1,className:"p-1.5 rounded-lg hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsx(Q,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>f(o.current_page+1),disabled:o.current_page>=o.last_page,className:"p-1.5 rounded-lg hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsx(Z,{className:"w-4 h-4"})})]})]})]})]})}function Xe(){var n;const t=!!((n=window.radius_booking_param)!=null&&n.is_pro);return e.jsx(K,{title:s("Admin Income","radius-booking"),description:s("Commission income from appointments","radius-booking"),icon:e.jsx(se,{className:"w-5 h-5 text-primary-colordefault"}),children:t?e.jsx(We,{}):e.jsx(ae,{title:s("Admin Income","radius-booking"),type:"setting"})})}const Ye=m.memo(Xe);function Ps(){return e.jsxs(pe,{children:[e.jsx(X,{path:"/",element:e.jsx(ze,{})}),e.jsx(X,{path:"income",element:e.jsx(Ye,{})})]})}export{Ps as default};
//# sourceMappingURL=index-CN-kj7-P.js.map
