import{C as e,E as t,Ht as n,Lt as r,Q as i,R as a,W as o,b as s,f as c,g as l,gt as u,ut as d,v as f,w as p,y as m}from"./vue.runtime.esm-bundler-56z_v_HH.js";import{i as h}from"./vue-router-_izWfDzq.js";import{t as g}from"./notification.store-EczSZ_VB.js";import{t as _}from"./abilities-CSdbnHpk.js";import{t as v}from"./user.store-DPFu8pQI.js";import{n as y}from"./vue-i18n-DhldrKy8.js";import{I as b,o as x}from"./main-CkEZzrzw.js";import{n as S,t as C}from"./NoteModal-BRQdwINI.js";var w=t({__name:`NoteDropdown`,props:{row:{},table:{},loadData:{type:[Function,null]}},setup(t){let r=t,s=x(),c=g(),{t:l}=y(),d=h(),C=v(),w=b();function T(e){w.openModal({title:l(`settings.customization.notes.edit_note`),componentName:`NoteModal`,size:`md`,data:e,refreshData:r.loadData??void 0})}function E(e){s.openDialog({title:l(`general.are_you_sure`),message:l(`settings.customization.notes.note_confirm_delete`),yesLabel:l(`general.yes`),noLabel:l(`general.no`),variant:`danger`,hideNoButton:!1,size:`lg`}).then(async t=>{t&&((await S.delete(e)).success?c.showNotification({type:`success`,message:l(`settings.customization.notes.deleted_message`)}):c.showNotification({type:`error`,message:l(`settings.customization.notes.already_in_use`)}),r.loadData?.())})}return(r,s)=>{let c=o(`BaseIcon`),l=o(`BaseButton`),h=o(`BaseDropdownItem`),g=o(`BaseDropdown`);return a(),f(g,null,{activator:i(()=>[u(d).name===`settings.notes`?(a(),f(l,{key:0,variant:`primary`},{default:i(()=>[p(c,{name:`EllipsisHorizontalIcon`,class:`h-5 text-white`})]),_:1})):(a(),f(c,{key:1,name:`EllipsisHorizontalIcon`,class:`h-5 text-muted`}))]),default:i(()=>[u(C).hasAbilities(u(_).MANAGE_NOTE)?(a(),f(h,{key:0,onClick:s[0]||=e=>T(t.row.id)},{default:i(()=>[p(c,{name:`PencilIcon`,class:`w-5 h-5 mr-3 text-subtle group-hover:text-muted`}),e(` `+n(r.$t(`general.edit`)),1)]),_:1})):m(``,!0),u(C).hasAbilities(u(_).MANAGE_NOTE)?(a(),f(h,{key:1,onClick:s[1]||=e=>E(t.row.id)},{default:i(()=>[p(c,{name:`TrashIcon`,class:`w-5 h-5 mr-3 text-subtle group-hover:text-muted`}),e(` `+n(r.$t(`general.delete`)),1)]),_:1})):m(``,!0)]),_:1})}}}),T=t({__name:`NotesView`,setup(t){let{t:h}=y(),g=b(),x=v(),T=d(null),E=l(()=>[{key:`name`,label:h(`settings.customization.notes.name`),thClass:`extra`,tdClass:`font-medium text-heading flex gap-1 items-center`},{key:`type`,label:h(`settings.customization.notes.type`),thClass:`extra`,tdClass:`font-medium text-heading`},{key:`actions`,label:``,tdClass:`text-right text-sm font-medium`,sortable:!1}]);async function D({page:e,sort:t}){let n={orderByField:t.fieldName||`created_at`,orderBy:t.order||`desc`,page:e},r=await S.list(n);return{data:r.data,pagination:{totalPages:r.meta.last_page,currentPage:e,totalCount:r.meta.total,limit:5}}}function O(){g.openModal({title:h(`settings.customization.notes.add_note`),componentName:`NoteModal`,size:`md`,refreshData:T.value?.refresh})}function k(){T.value?.refresh()}function A(e){switch(e){case`Estimate`:return h(`settings.customization.notes.types.estimate`);case`Invoice`:return h(`settings.customization.notes.types.invoice`);case`Payment`:return h(`settings.customization.notes.types.payment`);default:return e}}return(t,l)=>{let d=o(`BaseIcon`),h=o(`BaseButton`),g=o(`BaseTable`),v=o(`BaseSettingCard`);return a(),s(c,null,[p(C),p(v,{title:t.$t(`settings.customization.notes.title`),description:t.$t(`settings.customization.notes.description`)},{action:i(()=>[u(x).hasAbilities(u(_).MANAGE_NOTE)?(a(),f(h,{key:0,variant:`primary-outline`,onClick:O},{left:i(e=>[p(d,{class:r(e.class),name:`PlusIcon`},null,8,[`class`])]),default:i(()=>[e(` `+n(t.$t(`settings.customization.notes.add_note`)),1)]),_:1})):m(``,!0)]),default:i(()=>[p(g,{ref_key:`table`,ref:T,data:D,columns:E.value,class:`mt-14`},{"cell-actions":i(({row:e})=>[p(w,{row:e.data,table:T.value,"load-data":k},null,8,[`row`,`table`])]),"cell-name":i(({row:t})=>[e(n(t.data.name)+` `,1),t.data.is_default?(a(),f(d,{key:0,name:`StarIcon`,class:`w-3 h-3 text-primary-400`})):m(``,!0)]),"cell-type":i(({row:t})=>[e(n(A(t.data.type)),1)]),_:1},8,[`columns`])]),_:1},8,[`title`,`description`])],64)}}});export{T as default};