import{$ as e,A as t,C as n,G as r,S as i,Wt as a,_ as o,d as s,dt as c,h as l,ut as u,v as d,vt as f,y as p,z as m,zt as h}from"./vue.runtime.esm-bundler-DAWRyTnP.js";import{i as g}from"./vue-router-Bna4o8ws.js";import{t as _}from"./notification-BM55Quw3.js";import{t as v}from"./user-gWi04hVo.js";import{n as y}from"./vue-i18n-C4HYJWrq.js";import{t as b}from"./note-B4dahHSq.js";import{Pn as x,b as S,tt as C}from"./main-CgSmSYZA.js";import{t as w}from"./NoteModal-DHq9YIRT.js";var T={__name:`NoteIndexDropdown`,props:{row:{type:Object,default:null},table:{type:Object,default:null},loadData:{type:Function,default:null}},setup(s){let c=s,l=S(),u=_(),{t:p}=y(),h=b(),w=g(),T=v(),E=C();t(`utils`);function D(e){h.fetchNote(e),E.openModal({title:p(`settings.customization.notes.edit_note`),componentName:`NoteModal`,size:`md`,refreshData:c.loadData})}function O(e){l.openDialog({title:p(`general.are_you_sure`),message:p(`settings.customization.notes.note_confirm_delete`),yesLabel:p(`general.yes`),noLabel:p(`general.no`),variant:`danger`,hideNoButton:!1,size:`lg`}).then(async()=>{(await h.deleteNote(e)).data.success?u.showNotification({type:`success`,message:p(`settings.customization.notes.deleted_message`)}):u.showNotification({type:`error`,message:p(`settings.customization.notes.already_in_use`)}),c.loadData&&c.loadData()})}return(t,c)=>{let l=r(`BaseIcon`),u=r(`BaseButton`),p=r(`BaseDropdownItem`),h=r(`BaseDropdown`);return m(),o(h,null,{activator:e(()=>[f(w).name===`notes.view`?(m(),o(u,{key:0,variant:`primary`},{default:e(()=>[n(l,{name:`EllipsisHorizontalIcon`,class:`h-5 text-white`})]),_:1})):(m(),o(l,{key:1,name:`EllipsisHorizontalIcon`,class:`h-5 text-gray-500`}))]),default:e(()=>[f(T).hasAbilities(f(x).MANAGE_NOTE)?(m(),o(p,{key:0,onClick:c[0]||=e=>D(s.row.id)},{default:e(()=>[n(l,{name:`PencilIcon`,class:`w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500`}),i(` `+a(t.$t(`general.edit`)),1)]),_:1})):d(``,!0),f(T).hasAbilities(f(x).MANAGE_NOTE)?(m(),o(p,{key:1,onClick:c[1]||=e=>O(s.row.id)},{default:e(()=>[n(l,{name:`TrashIcon`,class:`w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500`}),i(` `+a(t.$t(`general.delete`)),1)]),_:1})):d(``,!0)]),_:1})}}},E={__name:`NotesSetting`,setup(t){let{t:g}=y(),_=C(),S=b(),E=v(),D=c(``),O=l(()=>[{key:`name`,label:g(`settings.customization.notes.name`),thClass:`extra`,tdClass:`font-medium text-gray-900 flex gap-1 items-center`},{key:`type`,label:g(`settings.customization.notes.type`),thClass:`extra`,tdClass:`font-medium text-gray-900`},{key:`actions`,label:``,tdClass:`text-right text-sm font-medium`,sortable:!1}]);async function k({page:e,filter:t,sort:n}){let r=u({orderByField:n.fieldName||`created_at`,orderBy:n.order||`desc`,page:e}),i=await S.fetchNotes(r);return{data:i.data.data,pagination:{totalPages:i.data.meta.last_page,currentPage:e,totalCount:i.data.meta.total,limit:5}}}async function A(){await _.openModal({title:g(`settings.customization.notes.add_note`),componentName:`NoteModal`,size:`md`,refreshData:D.value&&D.value.refresh})}async function j(){D.value&&D.value.refresh()}function M(e){switch(e){case`Estimate`:return g(`settings.customization.notes.types.estimate`);case`Invoice`:return g(`settings.customization.notes.types.invoice`);case`Payment`:return g(`settings.customization.notes.types.payment`);default:return e}}return(t,c)=>{let l=r(`BaseIcon`),u=r(`BaseButton`),g=r(`BaseTable`),_=r(`BaseSettingCard`);return m(),p(s,null,[n(w),n(_,{title:t.$t(`settings.customization.notes.title`),description:t.$t(`settings.customization.notes.description`)},{action:e(()=>[f(E).hasAbilities(f(x).MANAGE_NOTE)?(m(),o(u,{key:0,variant:`primary-outline`,onClick:A},{left:e(e=>[n(l,{class:h(e.class),name:`PlusIcon`},null,8,[`class`])]),default:e(()=>[i(` `+a(t.$t(`settings.customization.notes.add_note`)),1)]),_:1})):d(``,!0)]),default:e(()=>[n(g,{ref_key:`table`,ref:D,data:k,columns:O.value,class:`mt-14`},{"cell-actions":e(({row:e})=>[n(T,{row:e.data,table:D.value,"load-data":j},null,8,[`row`,`table`])]),"cell-name":e(({row:e})=>[i(a(e.data.name)+` `,1),e.data.is_default?(m(),o(l,{key:0,name:`StarIcon`,class:`w-3 h-3 text-primary-400`})):d(``,!0)]),"cell-type":e(({row:e})=>[i(a(M(e.data.type)),1)]),_:1},8,[`columns`])]),_:1},8,[`title`,`description`])],64)}}};export{E as default};