import{r as e}from"./chunk-qMK8H_w0.js";import{A as t,An as n,B as r,D as i,F as a,Ht as o,L as s,Lt as c,Nn as l,O as u,On as d,Qt as f,Zt as p,_n as m,an as h,en as g,g as _,k as v,kt as y,nn as b,on as x,pt as S,rn as C,rt as w,wn as T,wt as E}from"./app-4kCgdoJR.js";import{n as D}from"./Form-CQxFG6Go.js";var O=e(S()),k={class:`border-b border-gray-200 px-6 py-4 dark:border-gray-700`},A={class:`sm:flex sm:items-baseline sm:justify-between`},j={class:`sm:w-0 sm:flex-1`},M={class:`text-focus text-base font-semibold`},N={class:`text-mute mt-1 truncate text-sm`},P={class:`grid grid-cols-6 gap-6 p-6`},F={class:`col-span-6 sm:col-span-3`},I={class:`col-span-6 sm:col-span-3`},L={class:`col-span-6 sm:col-span-3`},R={class:`col-span-6 sm:col-span-3`},z={class:`col-span-6 sm:col-span-3`},B={class:`col-span-6 sm:col-span-3`},V={key:0,class:`col-span-full`},H={class:`col-span-full flex flex-col gap-6`},U={class:`flex flex-row justify-end bg-gray-100 px-6 py-4 text-end dark:bg-gray-950`},W={__name:`Form`,props:[`current`,`custom_fields`,`countries`,`customer_fields`,`accounts`],emits:[`close`,`done`],setup(e,{emit:S}){let W=d(!1),G=S,K=e,q=o({_method:K.current?.id?`put`:`post`,attachments:null,reference:K.current?.reference,details:K.current?.details,account_id:K.current?.account_id,customer_id:K.current?.customer_id,amount:K.current?Number(K.current.amount):null,date:(0,O.default)(K.current?.date).format(`YYYY-MM-DD`),extra_attributes:K.current?w(K.custom_fields,K.current.extra_attributes):w(K.custom_fields)}),J=()=>{q.reset(),G(`close`)};function Y(){q.post(K.current?.id?c(`incomes.update`,K.current.id):c(`incomes.store`),{onSuccess:()=>{q.reset(),G(`done`),G(`close`)}})}return(o,d)=>(m(),C(f,null,[g(`form`,{onSubmit:p(Y,[`prevent`])},[g(`div`,k,[g(`div`,A,[g(`div`,j,[g(`h1`,M,l(e.current?.id?o.$t(`Edit {x}`,{x:o.$t(`Income`)}):o.$t(`Add {x}`,{x:o.$t(`Income`)})),1),g(`p`,N,l(o.$t(`Please fill the form below to {action} {record}.`,{record:o.$t(`income`),action:e.current?.id?o.$t(`edit`):o.$t(`add`)})),1)])])]),g(`div`,P,[g(`div`,F,[x(n(v),{type:`date`,id:`date`,onChange:o.saveForm,label:o.$t(`Date`),modelValue:n(q).date,"onUpdate:modelValue":d[0]||=e=>n(q).date=e,error:n(q).errors.date},null,8,[`onChange`,`label`,`modelValue`,`error`])]),g(`div`,I,[x(n(i),{id:`reference`,onChange:o.saveForm,label:o.$t(`Reference`),modelValue:n(q).reference,"onUpdate:modelValue":d[1]||=e=>n(q).reference=e,error:n(q).errors.reference},null,8,[`onChange`,`label`,`modelValue`,`error`])]),g(`div`,L,[x(n(s),{json:!0,valueKey:`id`,id:`customer_id`,labelKey:`company`,onChange:o.saveForm,searchable:!0,label:o.$t(`Customer`),modelValue:n(q).customer_id,"onUpdate:modelValue":d[2]||=e=>n(q).customer_id=e,action:()=>W.value=!0,error:o.$page.props.errors.customer_id,suggestions:n(c)(`search.customers`),"action-text":o.$t(`Add {x}`,{x:o.$t(`Customer`)})},null,8,[`onChange`,`label`,`modelValue`,`action`,`error`,`suggestions`,`action-text`])]),g(`div`,R,[x(n(s),{json:!0,id:`account_id`,searchable:!1,label:o.$t(`Account`),suggestions:e.accounts,modelValue:n(q).account_id,"onUpdate:modelValue":d[3]||=e=>n(q).account_id=e,error:n(q).errors.account_id},null,8,[`label`,`suggestions`,`modelValue`,`error`])]),g(`div`,z,[x(n(i),{type:`number`,id:`amount`,label:o.$t(`Amount`),modelValue:n(q).amount,"onUpdate:modelValue":d[4]||=e=>n(q).amount=e,error:n(q).errors.amount},null,8,[`label`,`modelValue`,`error`])]),g(`div`,B,[x(n(u),{multiple:``,id:`attachments`,label:o.$t(`Attachments`),modelValue:n(q).attachments,"onUpdate:modelValue":d[5]||=e=>n(q).attachments=e,error:n(q).errors.attachments,accept:o.$page.props.settings?.attachment_exts||`.jpg,.png,.pdf,.xlsx,.docx,.zip`},null,8,[`label`,`modelValue`,`error`,`accept`])]),e.current&&e.current.attachments&&e.current.attachments.length?(m(),C(`div`,V,[x(n(r),{attachments:e.current.attachments||[]},null,8,[`attachments`])])):b(``,!0),g(`div`,H,[x(n(t),{errors:n(q).errors,custom_fields:e.custom_fields,extra_attributes:n(q).extra_attributes},null,8,[`errors`,`custom_fields`,`extra_attributes`]),x(n(_),{label:o.$t(`Details`),modelValue:n(q).details,"onUpdate:modelValue":d[6]||=e=>n(q).details=e,error:o.$page.props.errors.details},null,8,[`label`,`modelValue`,`error`])])]),g(`div`,U,[x(n(E),{onClick:J},{default:T(()=>[h(l(o.$t(`Cancel`)),1)]),_:1}),x(n(a),{class:`ms-3`,loading:n(q).processing},{default:T(()=>[h(l(o.$t(`Save`)),1)]),_:1},8,[`loading`])])],32),x(n(y),{show:W.value,backdrop:!1,overflow:!0,"max-width":`2xl`,closeable:!0,onClose:d[9]||=e=>W.value=!1},{default:T(()=>[x(D,{countries:e.countries,custom_fields:e.customer_fields,onClose:d[7]||=e=>W.value=!1,onDone:d[8]||=e=>{n(q).customer_id=e?.id,W.value=!1}},null,8,[`countries`,`custom_fields`])]),_:1},8,[`show`])],64))}};export{W as default};