import{ar as O,G as z,u as R,a9 as j,O as M,v as P,N as F,n as U,a7 as q,r as h,K as r,o as l,w as o,L as d,a as s,l as c,V as y,ae as H,q as v,t as m,af as W}from"./main-FAzQ_AST.js";const K={__name:"InvoiceIndexDropdown",props:{row:{type:Object,default:null},table:{type:Object,default:null},loadData:{type:Function,default:()=>{}}},setup(a){const f=a,p=O(),$=z(),D=R(),E=j(),g=M(),{t:i}=P.useI18n(),w=F(),S=U(),x=q("utils");function _(e){return(e.status=="SENT"||e.status=="VIEWED")&&g.hasAbilities(y.SEND_INVOICE)}function C(e){return e.status=="DRAFT"&&w.name!=="invoices.view"&&g.hasAbilities(y.SEND_INVOICE)}async function B(e){E.openDialog({title:i("general.are_you_sure"),message:i("invoices.confirm_delete"),yesLabel:i("general.ok"),noLabel:i("general.cancel"),variant:"danger",hideNoButton:!1,size:"lg"}).then(n=>{e=e,n&&p.deleteInvoice({ids:[e]}).then(t=>{t.data.success&&(S.push("/admin/invoices"),f.table&&f.table.refresh(),p.$patch(I=>{I.selectedInvoices=[],I.selectAllField=!1}))})})}async function A(e){E.openDialog({title:i("general.are_you_sure"),message:i("invoices.confirm_clone"),yesLabel:i("general.ok"),noLabel:i("general.cancel"),variant:"primary",hideNoButton:!1,size:"lg"}).then(n=>{n&&p.cloneInvoice(e).then(t=>{S.push(`/admin/invoices/${t.data.data.id}/edit`)})})}async function T(e){E.openDialog({title:i("general.are_you_sure"),message:i("invoices.invoice_mark_as_sent"),yesLabel:i("general.ok"),noLabel:i("general.cancel"),variant:"primary",hideNoButton:!1,size:"lg"}).then(n=>{const t={id:e,status:"SENT"};n&&p.markAsSent(t).then(I=>{f.table&&f.table.refresh()})})}async function N(e){$.openModal({title:i("invoices.send_invoice"),componentName:"SendInvoiceModal",id:e.id,data:e,variant:"sm"})}function V(){let e=`${window.location.origin}/invoices/pdf/${f.row.unique_hash}`;x.copyTextToClipboard(e),D.showNotification({type:"success",message:i("general.copied_pdf_url_clipboard")})}return(e,n)=>{const t=h("BaseIcon"),I=h("BaseButton"),u=h("BaseDropdownItem"),b=h("router-link"),L=h("BaseDropdown");return l(),r(L,null,{activator:o(()=>[c(w).name==="invoices.view"?(l(),r(I,{key:0,variant:"primary"},{default:o(()=>[s(t,{name:"EllipsisHorizontalIcon",class:"h-5 text-white"})]),_:1})):(l(),r(t,{key:1,name:"EllipsisHorizontalIcon",class:"h-5 text-gray-500"}))]),default:o(()=>[c(g).hasAbilities(c(y).EDIT_INVOICE)?(l(),r(b,{key:0,to:`/admin/invoices/${a.row.id}/edit`},{default:o(()=>[H(s(u,null,{default:o(()=>[s(t,{name:"PencilIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),v(" "+m(e.$t("general.edit")),1)]),_:1},512),[[W,a.row.allow_edit]])]),_:1},8,["to"])):d("",!0),c(w).name==="invoices.view"?(l(),r(u,{key:1,onClick:V},{default:o(()=>[s(t,{name:"LinkIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),v(" "+m(e.$t("general.copy_pdf_url")),1)]),_:1})):d("",!0),c(w).name!=="invoices.view"&&c(g).hasAbilities(c(y).VIEW_INVOICE)?(l(),r(b,{key:2,to:`/admin/invoices/${a.row.id}/view`},{default:o(()=>[s(u,null,{default:o(()=>[s(t,{name:"EyeIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),v(" "+m(e.$t("general.view")),1)]),_:1})]),_:1},8,["to"])):d("",!0),C(a.row)?(l(),r(u,{key:3,onClick:n[0]||(n[0]=k=>N(a.row))},{default:o(()=>[s(t,{name:"PaperAirplaneIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),v(" "+m(e.$t("invoices.send_invoice")),1)]),_:1})):d("",!0),_(a.row)?(l(),r(u,{key:4,onClick:n[1]||(n[1]=k=>N(a.row))},{default:o(()=>[s(t,{name:"PaperAirplaneIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),v(" "+m(e.$t("invoices.resend_invoice")),1)]),_:1})):d("",!0),s(b,{to:`/admin/payments/${a.row.id}/create`},{default:o(()=>[a.row.status=="SENT"&&c(w).name!=="invoices.view"?(l(),r(u,{key:0},{default:o(()=>[s(t,{name:"CreditCardIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),v(" "+m(e.$t("invoices.record_payment")),1)]),_:1})):d("",!0)]),_:1},8,["to"]),C(a.row)?(l(),r(u,{key:5,onClick:n[2]||(n[2]=k=>T(a.row.id))},{default:o(()=>[s(t,{name:"CheckCircleIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),v(" "+m(e.$t("invoices.mark_as_sent")),1)]),_:1})):d("",!0),c(g).hasAbilities(c(y).CREATE_INVOICE)?(l(),r(u,{key:6,onClick:n[3]||(n[3]=k=>A(a.row))},{default:o(()=>[s(t,{name:"DocumentTextIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),v(" "+m(e.$t("invoices.clone_invoice")),1)]),_:1})):d("",!0),c(g).hasAbilities(c(y).DELETE_INVOICE)?(l(),r(u,{key:7,onClick:n[4]||(n[4]=k=>B(a.row.id))},{default:o(()=>[s(t,{name:"TrashIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),v(" "+m(e.$t("general.delete")),1)]),_:1})):d("",!0)]),_:1})}}};export{K as _};
