import{T as w}from"./bootstrap.esm-Bb7dPm-H.js";import{d as y}from"./datatables-I6jthWPb.js";import{s as u}from"./toastr-helper-Wdj0mZjX.js";import"./datatables-Bo82YvhT.js";/* empty css                                  */document.addEventListener("DOMContentLoaded",function(){const c=document.getElementById("ticketPredefinedReplies").getAttribute("data-records-url"),g=$("#ticketPredefinedReplies").DataTable({...y.getDefaultConfig(),serverSide:!0,dom:'<"d-flex justify-content-between align-items-center mb-3"<"d-flex align-items-center"l><"d-flex align-items-center"f>>t<"d-flex justify-content-between align-items-center mt-3"<"d-flex align-items-center"i><"d-flex align-items-center"p>>',ajax:{url:c,type:"GET",headers:{Authorization:"Bearer "+document.querySelector('meta[name="api-token"]').getAttribute("content")}},columns:[{data:"title",name:"title",render:function(e){return e||"-"}},{data:"content",name:"content",orderable:!1,render:function(e){return e||"-"}},{data:"departments",name:"departments",orderable:!1,render:function(e){return e||"-"}},{data:"roles",name:"roles",orderable:!1,render:function(e){return e||"-"}},{data:"status",name:"status",render:function(e){var o,l,t,s;return e===!0||e===1?`<span class="badge bg-success">${((l=(o=window.translations)==null?void 0:o.status)==null?void 0:l.active)||"Active"}</span>`:`<span class="badge bg-danger">${((s=(t=window.translations)==null?void 0:t.status)==null?void 0:s.inactive)||"Inactive"}</span>`}},{data:"created_at",name:"created_at"},{data:"id",name:"actions",orderable:!1,searchable:!1,render:function(e,o,l){var s,n,i,r,a,d,f,m;const t=[];if((n=(s=window.permissions)==null?void 0:s.ticketPredefinedReplies)!=null&&n.update){const b=window.routes.ticketPredefinedReplies.edit.replace(":id",e);t.push(`
                            <a href="${b}"
                               class="btn btn-sm btn-outline-primary d-inline-flex align-items-center justify-content-center ms-1"
                               style="width: 32px; height: 32px;"
                               data-bs-toggle="tooltip"
                               title="${((r=(i=window.translations)==null?void 0:i.buttons)==null?void 0:r.edit)||"Edit"}">
                                <i class="fas fa-edit"></i>
                            </a>`)}return(d=(a=window.permissions)==null?void 0:a.ticketPredefinedReplies)!=null&&d.delete&&t.push(`
                            <button type="button"
                                    class="btn btn-sm btn-outline-danger d-inline-flex align-items-center justify-content-center ms-1 delete-predefined-reply"
                                    style="width: 32px; height: 32px;"
                                    data-id="${e}"
                                    data-bs-toggle="tooltip"
                                    title="${((m=(f=window.translations)==null?void 0:f.buttons)==null?void 0:m.delete)||"Delete"}">
                                <i class="fas fa-trash"></i>
                            </button>`),t.length===0?'<span class="text-muted">-</span>':`<div class="d-inline-flex">${t.join("")}</div>`}}],drawCallback:function(){h()}});$(document).on("click",".delete-predefined-reply",async function(){var t,s;const e=$(this).data("id"),o=window.routes.ticketPredefinedReplies.delete.replace(":id",e);await window.showConfirm(((s=(t=window.translations)==null?void 0:t.messages)==null?void 0:s.delete_confirm)||"Are you sure you want to delete this record?",{confirmClass:"btn-danger",icon:"warning"})&&$.ajax({url:o,type:"DELETE",headers:{Authorization:"Bearer "+document.querySelector('meta[name="api-token"]').getAttribute("content")},success:function(n){var i,r,a,d;n.success?(u("success",((r=(i=window.translations)==null?void 0:i.messages)==null?void 0:r.delete_success)||"Record deleted successfully."),g.ajax.reload()):u("error",n.message||((d=(a=window.translations)==null?void 0:a.messages)==null?void 0:d.delete_error)||"Delete operation failed.")},error:function(n){var r,a;let i=((a=(r=window.translations)==null?void 0:r.messages)==null?void 0:a.delete_error)||"An error occurred while deleting.";n.responseJSON&&n.responseJSON.message&&(i=n.responseJSON.message),u("error",i)}})})});function h(){[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map(c=>new w(c,{boundary:document.body}))}
