import{r as Z,T as $,c as i,a as p,u as o,Z as H,w as v,b as t,o as a,h as S,t as l,g as u,d as c,F as x,e as f,v as y,j as E,k as P,f as U,m as K,p as V,q as A,N as Q}from"./app-z_grtNg1.js";import{_ as X}from"./AdminLayout-D8-5CkB9.js";import{_ as T}from"./AppCard-C2KBW1s0.js";import{_ as Y}from"./AppTable-7n8nNCI3.js";import{_ as F}from"./AppModal-DLkXyhIS.js";import{_ as ee}from"./AppTabs-CKS48M6t.js";import{_ as N}from"./StatusBadge-DAu0ZF3H.js";import{P as h}from"./PrimaryButton-i7WPAeR-.js";import"./ToastStack-xenoaUxd.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const te={class:"flex items-center justify-between gap-4"},se={class:"flex items-center gap-2"},oe=["disabled"],re={class:"mx-auto max-w-7xl space-y-6 px-4 py-6 sm:px-6 lg:px-8"},ne={class:"grid gap-3 md:grid-cols-2"},ae={class:"flex items-center justify-between gap-3 rounded-md border border-gray-200 bg-white px-3 py-3"},le={class:"text-xs text-gray-500"},ie={class:"flex items-center gap-2"},de={class:"text-xs font-medium text-gray-600"},ue={class:"flex items-center justify-between gap-3 rounded-md border border-gray-200 bg-white px-3 py-3"},me={class:"text-xs text-gray-500"},ce={class:"flex items-center gap-2"},pe={class:"text-xs font-medium text-gray-600"},ve={class:"flex gap-3"},xe=["value"],fe=["value"],ye={class:"divide-y divide-gray-100 text-sm"},be={class:"px-4 py-3"},ge={class:"font-medium text-gray-900"},_e={class:"text-xs text-gray-500"},ke={class:"px-4 py-3 capitalize"},we={class:"px-4 py-3"},Ce={class:"font-mono text-xs text-gray-700"},Pe={class:"px-4 py-3"},Ae={class:"px-4 py-3"},Se={class:"max-w-xs truncate text-xs text-gray-500"},Ue={class:"px-4 py-3 text-right"},Ve=["onClick"],Ne={class:"grid gap-4 sm:grid-cols-2"},he={class:"block"},je=["value"],Re={key:0,class:"mt-1 text-xs text-rose-600"},Be={class:"block"},Me=["value"],$e={key:0,class:"mt-1 text-xs text-rose-600"},Ee={class:"block sm:col-span-2"},Te={key:0,class:"mt-1 text-xs text-rose-600"},Fe={class:"block sm:col-span-2"},Oe=["value"],Ie={key:0,class:"mt-1 text-xs text-rose-600"},De={class:"block sm:col-span-2"},Je={key:0,class:"mt-1 text-xs text-rose-600"},Le={class:"flex justify-end gap-2"},We={class:"block"},qe=["value"],ze={key:0,class:"mt-1 text-xs text-rose-600"},Ge={class:"block"},Ze={key:0,class:"mt-1 text-xs text-rose-600"},He={class:"block"},Ke={key:0,class:"mt-1 text-xs text-rose-600"},Qe={key:0,class:"block"},Xe={key:0,class:"mt-1 text-xs text-rose-600"},Ye={key:1,class:"block"},et={key:0,class:"mt-1 text-xs text-rose-600"},tt={key:2,class:"flex items-start gap-3 rounded-md border border-gray-200 p-3"},st={key:3,class:"text-xs text-rose-600"},ot={class:"flex justify-end gap-2"},xt={__name:"Index",props:{reservedAccounts:Object,users:Array,filters:Object,statuses:Array,providers:Array,monnifyConfigured:Boolean,paymentpointConfigured:Boolean},setup(m){var j,R;const b=m,_=Z({status:((j=b.filters)==null?void 0:j.status)||"",provider:((R=b.filters)==null?void 0:R.provider)||""}),O=()=>{Q.get(route("admin.reserved-accounts.index"),_,{preserveState:!0,replace:!0})},g=A(!1),k=A(null),w=A(!1),C=A("accounts"),I=V(()=>{var d,e,s;return[{key:"accounts",label:"Reserved Accounts",count:((d=b.reservedAccounts)==null?void 0:d.total)??((s=(e=b.reservedAccounts)==null?void 0:e.data)==null?void 0:s.length)??0},{key:"overview",label:"Overview"}]}),n=$({user_id:"",provider:"monnify",account_reference:"",status:"active",accounts_json:`[
  {
    "bankName": "Wema Bank",
    "accountNumber": "1234567890",
    "accountName": "VTU USER"
  }
]`}),D=V(()=>k.value?"Edit Reserved Account":"Create Reserved Account"),r=$({user_id:"",provider:"monnify",account_reference:"",preferred_banks_csv:"",bank_codes_csv:"20946,20897",get_all_available_banks:!0}),J=()=>{k.value=null,n.reset(),n.user_id="",n.provider="monnify",n.status="active",n.accounts_json=`[
  {
    "bankName": "Wema Bank",
    "accountNumber": "1234567890",
    "accountName": "VTU USER"
  }
]`,n.clearErrors(),g.value=!0},L=d=>{k.value=d,n.user_id=String(d.user_id),n.provider=d.provider,n.account_reference=d.account_reference,n.status=d.status,n.accounts_json=JSON.stringify(d.accounts_json,null,2),n.clearErrors(),g.value=!0},W=()=>{const d={preserveScroll:!0,onSuccess:()=>{g.value=!1}};if(k.value){n.put(route("admin.reserved-accounts.update",k.value.id),d);return}n.post(route("admin.reserved-accounts.store"),d)},q=()=>{r.reset(),r.user_id="",r.provider="monnify",r.account_reference="",r.preferred_banks_csv="",r.bank_codes_csv="20946,20897",r.get_all_available_banks=!0,r.clearErrors(),w.value=!0},z=V(()=>r.provider==="paymentpoint"?!!b.paymentpointConfigured:!!b.monnifyConfigured),G=()=>{r.transform(d=>({user_id:d.user_id,provider:d.provider,account_reference:d.account_reference||null,get_all_available_banks:!!d.get_all_available_banks,preferred_banks:String(d.preferred_banks_csv||"").split(",").map(e=>e.trim()).filter(Boolean),bank_codes:String(d.bank_codes_csv||"").split(",").map(e=>e.trim()).filter(Boolean)})).post(route("admin.reserved-accounts.provision"),{preserveScroll:!0,onSuccess:()=>{w.value=!1},onFinish:()=>{r.transform(d=>d)}})};return(d,e)=>(a(),i(x,null,[p(o(H),{title:"Reserved Accounts"}),p(X,null,{header:v(()=>[t("div",te,[e[19]||(e[19]=t("div",null,[t("h2",{class:"text-xl font-semibold text-gray-800"},"Reserved Accounts"),t("p",{class:"mt-1 text-sm text-gray-500"},"Reserved-account provisioning + manual record management for webhook wallet funding.")],-1)),t("div",se,[t("button",{type:"button",class:"rounded-md border border-gray-300 px-3 py-2 text-sm font-medium text-gray-700 disabled:cursor-not-allowed disabled:opacity-50",disabled:!m.monnifyConfigured&&!m.paymentpointConfigured,onClick:q}," Provision Reserved Account ",8,oe),p(h,{type:"button",onClick:J},{default:v(()=>[...e[18]||(e[18]=[U("Add Reserved Account",-1)])]),_:1})])])]),default:v(()=>[t("div",re,[p(ee,{modelValue:C.value,"onUpdate:modelValue":e[0]||(e[0]=s=>C.value=s),tabs:I.value,"aria-label":"Reserved account sections"},null,8,["modelValue","tabs"]),C.value==="overview"?(a(),S(T,{key:0},{default:v(()=>[t("div",ne,[t("div",ae,[t("div",null,[e[20]||(e[20]=t("p",{class:"text-sm font-medium text-gray-900"},"Monnify API Configuration",-1)),t("p",le,l(m.monnifyConfigured?"Configured. Monnify provisioning is available.":"Missing Monnify credentials. Monnify provisioning is disabled."),1)]),t("div",ie,[p(N,{status:m.monnifyConfigured?"active":"inactive"},null,8,["status"]),t("span",de,l(m.monnifyConfigured?"Configured":"Not configured"),1)])]),t("div",ue,[t("div",null,[e[21]||(e[21]=t("p",{class:"text-sm font-medium text-gray-900"},"PaymentPoint API Configuration",-1)),t("p",me,l(m.paymentpointConfigured?"Configured. PaymentPoint provisioning is available.":"Missing PaymentPoint credentials. PaymentPoint provisioning is disabled."),1)]),t("div",ce,[p(N,{status:m.paymentpointConfigured?"active":"inactive"},null,8,["status"]),t("span",pe,l(m.paymentpointConfigured?"Configured":"Not configured"),1)])])])]),_:1})):u("",!0),C.value==="accounts"?(a(),S(T,{key:1,title:"Filter"},{default:v(()=>[t("div",ve,[c(t("select",{"onUpdate:modelValue":e[1]||(e[1]=s=>_.status=s),class:"rounded-md border-gray-300 text-sm shadow-sm"},[e[22]||(e[22]=t("option",{value:""},"All statuses",-1)),(a(!0),i(x,null,f(m.statuses,s=>(a(),i("option",{key:s,value:s},l(s),9,xe))),128))],512),[[y,_.status]]),c(t("select",{"onUpdate:modelValue":e[2]||(e[2]=s=>_.provider=s),class:"rounded-md border-gray-300 text-sm shadow-sm"},[e[23]||(e[23]=t("option",{value:""},"All providers",-1)),(a(!0),i(x,null,f(m.providers,s=>(a(),i("option",{key:s,value:s},l(s),9,fe))),128))],512),[[y,_.provider]]),t("button",{type:"button",class:"rounded-md border border-gray-300 px-3 py-2 text-sm",onClick:O},"Apply")])]),_:1})):u("",!0),C.value==="accounts"?(a(),S(Y,{key:2},{default:v(()=>[e[24]||(e[24]=t("thead",{class:"bg-gray-50"},[t("tr",{class:"text-left text-xs font-semibold uppercase tracking-wide text-gray-500"},[t("th",{class:"px-4 py-3"},"User"),t("th",{class:"px-4 py-3"},"Provider"),t("th",{class:"px-4 py-3"},"Reference"),t("th",{class:"px-4 py-3"},"Status"),t("th",{class:"px-4 py-3"},"Accounts"),t("th",{class:"px-4 py-3"})])],-1)),t("tbody",ye,[(a(!0),i(x,null,f(m.reservedAccounts.data,s=>{var B,M;return a(),i("tr",{key:s.id},[t("td",be,[t("div",ge,l((B=s.user)==null?void 0:B.name),1),t("div",_e,l((M=s.user)==null?void 0:M.email),1)]),t("td",ke,l(s.provider),1),t("td",we,[t("div",Ce,l(s.account_reference),1)]),t("td",Pe,[p(N,{status:s.status},null,8,["status"])]),t("td",Ae,[t("div",Se,l(JSON.stringify(s.accounts_json)),1)]),t("td",Ue,[t("button",{type:"button",class:"rounded border px-2.5 py-1 text-xs",onClick:rt=>L(s)},"Edit",8,Ve)])])}),128))])]),_:1})):u("",!0)]),p(F,{show:g.value,title:D.value,onClose:e[9]||(e[9]=s=>g.value=!1)},{default:v(()=>[t("form",{class:"space-y-4",onSubmit:E(W,["prevent"])},[t("div",Ne,[t("label",he,[e[26]||(e[26]=t("span",{class:"text-sm font-medium text-gray-700"},"User",-1)),c(t("select",{"onUpdate:modelValue":e[3]||(e[3]=s=>o(n).user_id=s),class:"mt-1 w-full rounded-md border-gray-300 text-sm shadow-sm"},[e[25]||(e[25]=t("option",{value:""},"Select user",-1)),(a(!0),i(x,null,f(m.users,s=>(a(),i("option",{key:s.id,value:String(s.id)},l(s.name)+" ("+l(s.email)+") ",9,je))),128))],512),[[y,o(n).user_id]]),o(n).errors.user_id?(a(),i("p",Re,l(o(n).errors.user_id),1)):u("",!0)]),t("label",Be,[e[27]||(e[27]=t("span",{class:"text-sm font-medium text-gray-700"},"Provider",-1)),c(t("select",{"onUpdate:modelValue":e[4]||(e[4]=s=>o(n).provider=s),class:"mt-1 w-full rounded-md border-gray-300 text-sm shadow-sm"},[(a(!0),i(x,null,f(m.providers,s=>(a(),i("option",{key:s,value:s},l(s),9,Me))),128))],512),[[y,o(n).provider]]),o(n).errors.provider?(a(),i("p",$e,l(o(n).errors.provider),1)):u("",!0)]),t("label",Ee,[e[28]||(e[28]=t("span",{class:"text-sm font-medium text-gray-700"},"Account Reference",-1)),c(t("input",{"onUpdate:modelValue":e[5]||(e[5]=s=>o(n).account_reference=s),class:"mt-1 w-full rounded-md border-gray-300 text-sm shadow-sm"},null,512),[[P,o(n).account_reference]]),o(n).errors.account_reference?(a(),i("p",Te,l(o(n).errors.account_reference),1)):u("",!0)]),t("label",Fe,[e[29]||(e[29]=t("span",{class:"text-sm font-medium text-gray-700"},"Status",-1)),c(t("select",{"onUpdate:modelValue":e[6]||(e[6]=s=>o(n).status=s),class:"mt-1 w-full rounded-md border-gray-300 text-sm shadow-sm"},[(a(!0),i(x,null,f(m.statuses,s=>(a(),i("option",{key:s,value:s},l(s),9,Oe))),128))],512),[[y,o(n).status]]),o(n).errors.status?(a(),i("p",Ie,l(o(n).errors.status),1)):u("",!0)]),t("label",De,[e[30]||(e[30]=t("span",{class:"text-sm font-medium text-gray-700"},"Accounts JSON",-1)),c(t("textarea",{"onUpdate:modelValue":e[7]||(e[7]=s=>o(n).accounts_json=s),rows:"8",class:"mt-1 w-full rounded-md border-gray-300 font-mono text-xs shadow-sm",placeholder:'[{"bankName":"Wema Bank","accountNumber":"1234567890","accountName":"User Name"}]'},null,512),[[P,o(n).accounts_json]]),e[31]||(e[31]=t("p",{class:"mt-1 text-xs text-gray-500"},"Stored structure used by wallet page display and webhook matching.",-1)),o(n).errors.accounts_json?(a(),i("p",Je,l(o(n).errors.accounts_json),1)):u("",!0)])]),t("div",Le,[t("button",{type:"button",class:"rounded border border-gray-300 px-3 py-2 text-sm",onClick:e[8]||(e[8]=s=>g.value=!1)},"Cancel"),p(h,{disabled:o(n).processing},{default:v(()=>[U(l(o(n).processing?"Saving...":"Save"),1)]),_:1},8,["disabled"])])],32)]),_:1},8,["show","title"]),p(F,{show:w.value,title:"Provision Reserved Account",onClose:e[17]||(e[17]=s=>w.value=!1)},{default:v(()=>[t("form",{class:"space-y-4",onSubmit:E(G,["prevent"])},[t("label",We,[e[33]||(e[33]=t("span",{class:"text-sm font-medium text-gray-700"},"User",-1)),c(t("select",{"onUpdate:modelValue":e[10]||(e[10]=s=>o(r).user_id=s),class:"mt-1 w-full rounded-md border-gray-300 text-sm shadow-sm"},[e[32]||(e[32]=t("option",{value:""},"Select user",-1)),(a(!0),i(x,null,f(m.users,s=>(a(),i("option",{key:s.id,value:String(s.id)},l(s.name)+" ("+l(s.email)+") ",9,qe))),128))],512),[[y,o(r).user_id]]),o(r).errors.user_id?(a(),i("p",ze,l(o(r).errors.user_id),1)):u("",!0)]),t("label",Ge,[e[35]||(e[35]=t("span",{class:"text-sm font-medium text-gray-700"},"Provider",-1)),c(t("select",{"onUpdate:modelValue":e[11]||(e[11]=s=>o(r).provider=s),class:"mt-1 w-full rounded-md border-gray-300 text-sm shadow-sm"},[...e[34]||(e[34]=[t("option",{value:"monnify"},"monnify",-1),t("option",{value:"paymentpoint"},"paymentpoint",-1)])],512),[[y,o(r).provider]]),o(r).errors.provider?(a(),i("p",Ze,l(o(r).errors.provider),1)):u("",!0)]),t("label",He,[e[36]||(e[36]=t("span",{class:"text-sm font-medium text-gray-700"},"Account Reference (optional)",-1)),c(t("input",{"onUpdate:modelValue":e[12]||(e[12]=s=>o(r).account_reference=s),class:"mt-1 w-full rounded-md border-gray-300 text-sm shadow-sm",placeholder:"Leave blank to auto-generate"},null,512),[[P,o(r).account_reference]]),e[37]||(e[37]=t("p",{class:"mt-1 text-xs text-gray-500"},"If left blank, the system generates a stable user-based reference.",-1)),o(r).errors.account_reference?(a(),i("p",Ke,l(o(r).errors.account_reference),1)):u("",!0)]),o(r).provider==="monnify"?(a(),i("label",Qe,[e[38]||(e[38]=t("span",{class:"text-sm font-medium text-gray-700"},"Preferred Banks (optional)",-1)),c(t("input",{"onUpdate:modelValue":e[13]||(e[13]=s=>o(r).preferred_banks_csv=s),class:"mt-1 w-full rounded-md border-gray-300 text-sm shadow-sm",placeholder:"035, 50515"},null,512),[[P,o(r).preferred_banks_csv]]),e[39]||(e[39]=t("p",{class:"mt-1 text-xs text-gray-500"},"Comma-separated Monnify bank codes. Leave empty to use all available banks.",-1)),o(r).errors.preferred_banks?(a(),i("p",Xe,l(o(r).errors.preferred_banks),1)):u("",!0)])):u("",!0),o(r).provider==="paymentpoint"?(a(),i("label",Ye,[e[40]||(e[40]=t("span",{class:"text-sm font-medium text-gray-700"},"Partner Bank Codes",-1)),c(t("input",{"onUpdate:modelValue":e[14]||(e[14]=s=>o(r).bank_codes_csv=s),class:"mt-1 w-full rounded-md border-gray-300 text-sm shadow-sm",placeholder:"20946,20897"},null,512),[[P,o(r).bank_codes_csv]]),e[41]||(e[41]=t("p",{class:"mt-1 text-xs text-gray-500"},"PaymentPoint partner bank codes (comma-separated).",-1)),o(r).errors.bank_codes?(a(),i("p",et,l(o(r).errors.bank_codes),1)):u("",!0)])):u("",!0),o(r).provider==="monnify"?(a(),i("label",tt,[c(t("input",{"onUpdate:modelValue":e[15]||(e[15]=s=>o(r).get_all_available_banks=s),type:"checkbox",class:"mt-0.5 rounded border-gray-300"},null,512),[[K,o(r).get_all_available_banks]]),e[42]||(e[42]=t("div",null,[t("p",{class:"text-sm font-medium text-gray-800"},"Get all available banks"),t("p",{class:"text-xs text-gray-500"},"Disable this if you want Monnify to restrict to the preferred bank codes only.")],-1))])):u("",!0),o(r).errors.get_all_available_banks?(a(),i("p",st,l(o(r).errors.get_all_available_banks),1)):u("",!0),t("div",ot,[t("button",{type:"button",class:"rounded border border-gray-300 px-3 py-2 text-sm",onClick:e[16]||(e[16]=s=>w.value=!1)},"Cancel"),p(h,{disabled:o(r).processing||!z.value},{default:v(()=>[U(l(o(r).processing?"Provisioning...":"Provision Account"),1)]),_:1},8,["disabled"])])],32)]),_:1},8,["show"])]),_:1})],64))}};export{xt as default};
