import{C as e,E as t,Ht as n,Q as r,R as i,W as a,g as o,gt as s,v as c,w as l,y as u}from"./vue.runtime.esm-bundler-56z_v_HH.js";import{i as d}from"./vue-router-_izWfDzq.js";import{t as f}from"./user.store-DPFu8pQI.js";import{n as p}from"./vue-i18n-DhldrKy8.js";import{L as m,o as h}from"./main-CkEZzrzw.js";var g=t({__name:`CustomerDropdown`,props:{row:{default:null},table:{default:null},loadData:{type:[Function,null],default:null}},emits:[`deleted`],setup(t,{emit:g}){let _={EDIT_CUSTOMER:`edit-customer`,VIEW_CUSTOMER:`view-customer`,DELETE_CUSTOMER:`delete-customer`},v=t,y=m(),b=h(),x=f(),{t:S}=p(),C=d(),w=o(()=>C.name===`customers.view`),T=o(()=>{let e=E(v.row?.id);return e===null?w.value?E(C.params.id):null:e});function E(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return null}function D(e){b.openDialog({title:S(`general.are_you_sure`),message:S(`customers.confirm_delete`,1),yesLabel:S(`general.ok`),noLabel:S(`general.cancel`),variant:`danger`,hideNoButton:!1,size:`lg`}).then(t=>{t&&y.deleteCustomer({ids:[e]}).then(e=>{e.success&&v.loadData?.()})})}function O(){T.value!==null&&D(T.value)}return(t,o)=>{let d=a(`BaseIcon`),f=a(`BaseButton`),p=a(`BaseDropdownItem`),m=a(`router-link`),h=a(`BaseDropdown`);return i(),c(h,{"content-loading":s(y).isFetchingViewData},{activator:r(()=>[w.value?(i(),c(f,{key:0,variant:`primary`},{default:r(()=>[l(d,{name:`EllipsisHorizontalIcon`,class:`h-5 text-white`})]),_:1})):(i(),c(d,{key:1,name:`EllipsisHorizontalIcon`,class:`h-5 text-muted`}))]),default:r(()=>[s(x).hasAbilities(_.EDIT_CUSTOMER)&&T.value!==null?(i(),c(m,{key:0,to:`/admin/customers/${T.value}/edit`},{default:r(()=>[l(p,null,{default:r(()=>[l(d,{name:`PencilIcon`,class:`w-5 h-5 mr-3 text-subtle group-hover:text-muted`}),e(` `+n(t.$t(`general.edit`)),1)]),_:1})]),_:1},8,[`to`])):u(``,!0),!w.value&&s(x).hasAbilities(_.VIEW_CUSTOMER)&&T.value!==null?(i(),c(m,{key:1,to:`/admin/customers/${T.value}/view`},{default:r(()=>[l(p,null,{default:r(()=>[l(d,{name:`EyeIcon`,class:`w-5 h-5 mr-3 text-subtle group-hover:text-muted`}),e(` `+n(t.$t(`general.view`)),1)]),_:1})]),_:1},8,[`to`])):u(``,!0),s(x).hasAbilities(_.DELETE_CUSTOMER)&&T.value!==null?(i(),c(p,{key:2,onClick:O},{default:r(()=>[l(d,{name:`TrashIcon`,class:`w-5 h-5 mr-3 text-subtle group-hover:text-muted`}),e(` `+n(t.$t(`general.delete`)),1)]),_:1})):u(``,!0)]),_:1},8,[`content-loading`])}}});export{g as t};