import{An as e,D as t,F as n,Ht as r,L as i,Lt as a,N as o,Nn as s,Qt as c,Zt as l,_n as u,an as d,en as f,g as p,nn as m,on as h,rn as g,tt as _,wn as v,wt as y}from"./app-4kCgdoJR.js";var b={class:`border-b border-gray-200 px-6 py-4 dark:border-gray-700`},x={class:`sm:flex sm:items-baseline sm:justify-between`},S={class:`sm:w-0 sm:flex-1`},C={class:`text-focus text-base font-semibold`},w={class:`text-mute mt-1 truncate text-sm`},T={class:`grid grid-cols-6 gap-6 p-6`},E={class:`col-span-6 sm:col-span-3`},D={class:`col-span-6 sm:col-span-3`},O={class:`col-span-6 sm:col-span-3`},k={class:`col-span-6 sm:col-span-3`},A={class:`col-span-full`},j={class:`col-span-full`},M={class:`col-span-6 sm:col-span-3`},N={class:`col-span-6 sm:col-span-3`},P={class:`col-span-6 sm:col-span-3`},F={class:`col-span-full`},I={class:`col-span-full`},L={class:`flex flex-row justify-end bg-gray-100 px-6 py-4 text-end dark:bg-gray-950`},R={__name:`Form`,props:[`current`,`types`],emits:[`close`,`done`],setup(R,{emit:z}){let B=z,V=R,H=r({_method:V.current?.id?`put`:`post`,account_type_id:V.current?.account_type_id,title:V.current?.title,details:V.current?.details,reference:V.current?.reference,opening_balance:_(V.current?.opening_balance),offline:V.current?.offline==1,fees:V.current?.fees==1,fixed:V.current?.fixed,percentage:V.current?.percentage,apply_to:V.current?.apply_to,active:V.current?.id?V.current?.active==1:!0});function U(){H.post(V.current?.id?a(`accounts.update`,V.current.id):a(`accounts.store`),{onSuccess:()=>{B(`done`),B(`close`)}})}return(r,a)=>(u(),g(`form`,{onSubmit:l(U,[`prevent`])},[f(`div`,b,[f(`div`,x,[f(`div`,S,[f(`h1`,C,s(R.current?.id?r.$t(`Edit {x}`,{x:r.$t(`Account`)}):r.$t(`Add {x}`,{x:r.$t(`Account`)})),1),f(`p`,w,s(r.$t(`Please fill the form below to {action} {record}.`,{record:r.$t(`account`),action:R.current?.id?r.$t(`edit`):r.$t(`add`)})),1)])])]),f(`div`,T,[f(`div`,E,[h(e(i),{id:`type`,json:!0,searchable:!1,label:r.$t(`Type`),modelValue:e(H).account_type_id,"onUpdate:modelValue":a[0]||=t=>e(H).account_type_id=t,error:e(H).errors.account_type_id,suggestions:R.types.map(e=>({label:e.name,value:e.id}))},null,8,[`label`,`modelValue`,`error`,`suggestions`])]),f(`div`,D,[h(e(t),{id:`title`,label:r.$t(`Title`),modelValue:e(H).title,"onUpdate:modelValue":a[1]||=t=>e(H).title=t,error:e(H).errors.title},null,8,[`label`,`modelValue`,`error`])]),f(`div`,O,[h(e(t),{type:`number`,id:`opening_balance`,readonly:R.current?.id,label:r.$t(`Opening Balance`),modelValue:e(H).opening_balance,"onUpdate:modelValue":a[2]||=t=>e(H).opening_balance=t,error:e(H).errors.opening_balance},null,8,[`readonly`,`label`,`modelValue`,`error`])]),f(`div`,k,[h(e(t),{id:`reference`,label:r.$t(`Reference`),modelValue:e(H).reference,"onUpdate:modelValue":a[3]||=t=>e(H).reference=t,error:e(H).errors.reference},null,8,[`label`,`modelValue`,`error`])]),f(`div`,A,[h(e(p),{id:`details`,label:r.$t(`Details`),modelValue:e(H).details,"onUpdate:modelValue":a[4]||=t=>e(H).details=t,error:e(H).errors.details},null,8,[`label`,`modelValue`,`error`])]),f(`div`,j,[h(e(o),{id:`fees`,error:e(H).errors.fees,checked:e(H).fees,"onUpdate:checked":a[5]||=t=>e(H).fees=t,label:r.$t(`Apply transaction fees`)},null,8,[`error`,`checked`,`label`])]),e(H).fees?(u(),g(c,{key:0},[f(`div`,M,[h(e(t),{type:`number`,id:`fixed`,label:r.$t(`Fixed Fees`),modelValue:e(H).fixed,"onUpdate:modelValue":a[6]||=t=>e(H).fixed=t,error:e(H).errors.fixed},null,8,[`label`,`modelValue`,`error`])]),f(`div`,N,[h(e(t),{type:`number`,id:`percentage`,label:r.$t(`Percentage Fees`),modelValue:e(H).percentage,"onUpdate:modelValue":a[7]||=t=>e(H).percentage=t,error:e(H).errors.percentage},null,8,[`label`,`modelValue`,`error`])]),f(`div`,P,[h(e(i),{json:!0,id:`apply_to`,searchable:!1,label:r.$t(`Apply to`),modelValue:e(H).apply_to,"onUpdate:modelValue":a[8]||=t=>e(H).apply_to=t,error:e(H).errors.apply_to,suggestions:[{value:`Credit`,label:r.$t(`Credit`)},{value:`Debit`,label:r.$t(`Debit`)},{value:`Both`,label:r.$t(`Both (credit & debit)`)}]},null,8,[`label`,`modelValue`,`error`,`suggestions`])])],64)):m(``,!0),f(`div`,F,[h(e(o),{id:`offline`,label:r.$t(`Show this in offline payments`),checked:e(H).offline,"onUpdate:checked":a[9]||=t=>e(H).offline=t,error:e(H).errors.offline},null,8,[`label`,`checked`,`error`])]),f(`div`,I,[h(e(o),{id:`active`,error:e(H).errors.active,checked:e(H).active,"onUpdate:checked":a[10]||=t=>e(H).active=t,label:r.$t(`Active`)},null,8,[`error`,`checked`,`label`])])]),f(`div`,L,[h(e(y),{onClick:a[11]||=e=>B(`close`)},{default:v(()=>[d(s(r.$t(`Cancel`)),1)]),_:1}),h(e(n),{class:`ms-3`,loading:e(H).processing},{default:v(()=>[d(s(r.$t(`Save`)),1)]),_:1},8,[`loading`])])],32))}};export{R as default};