import b from"jquery";import"./datatables-bbQliV7G.js";import{T as _}from"./bootstrap.esm-Bb7dPm-H.js";import{d as T}from"./datatables-CdFC5o1t.js";/* empty css                                  */function N(){[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map(t=>new _(t,{boundary:document.body}))}function p(e){return e?'<span class="badge bg-success"><i class="fas fa-check"></i></span>':'<span class="badge bg-danger"><i class="fas fa-times"></i></span>'}function v(e,t,r){return e||"-"}function h(e,t,r){return e?e.toLowerCase()==="public"?'<span class="badge bg-info" title="Public"><i class="fas fa-globe"></i></span>':e.toLowerCase()==="registrar"?'<span class="badge bg-primary" title="Registrar"><i class="fas fa-server"></i></span>':`<span class="badge bg-secondary">${e}</span>`:"-"}function A(e){var t,r,s,n,i,o;return e==="active"?`<span class="badge bg-success">${((s=(r=(t=window.translations)==null?void 0:t.global)==null?void 0:r.status)==null?void 0:s.active)||"Active"}</span>`:e==="inactive"?`<span class="badge bg-secondary">${((o=(i=(n=window.translations)==null?void 0:n.global)==null?void 0:i.status)==null?void 0:o.inactive)||"Inactive"}</span>`:`<span class="badge bg-secondary">${e||"-"}</span>`}function S(e,t,r){var n,i,o,c,a;const s=[];if((i=(n=window.permissions)==null?void 0:n.tlds)!=null&&i.update){const l=window.routes.tlds.edit.replace(":id",e);s.push(`<a href="${l}" 
               class="btn btn-sm btn-outline-primary d-inline-flex align-items-center justify-content-center" 
               style="width: 32px; height: 32px;" 
               data-bs-toggle="tooltip" 
               title="${((a=(c=(o=window.translations)==null?void 0:o.tlds)==null?void 0:c.buttons)==null?void 0:a.edit)||"Edit"}">
                <i class="fas fa-edit"></i>
            </a>`)}return s.length===0?'<span class="text-muted">-</span>':`<div class="d-inline-flex">${s.join("")}</div>`}const L=b("#tldsTable").DataTable({...T.getDefaultConfig(),responsive:!1,ajax:{url:b("#tldsTable").data("records-url"),type:"GET",headers:{Authorization:"Bearer "+document.querySelector('meta[name="api-token"]').getAttribute("content")}},columns:[{data:"tld",name:"tld"},{data:"status",name:"status",render:A,orderable:!1,className:"text-center"},{data:"min_years",name:"min_years",orderable:!1,className:"text-center"},{data:"max_years",name:"max_years",orderable:!1,className:"text-center"},{data:"min_chars",name:"min_chars",orderable:!1,className:"text-center"},{data:"max_chars",name:"max_chars",orderable:!1,className:"text-center"},{data:"dns_management",name:"dns_management",render:p,orderable:!1,className:"text-center"},{data:"id_protection",name:"id_protection",render:p,orderable:!1,className:"text-center"},{data:"epp_code",name:"epp_code",render:p,orderable:!1,className:"text-center"},{data:"email_forwarding",name:"email_forwarding",render:p,orderable:!1,className:"text-center"},{data:"grace_period",name:"grace_period",orderable:!1,className:"text-center"},{data:"redemption_period",name:"redemption_period",orderable:!1,className:"text-center"},{data:"registrar",name:"registrar",render:v,orderable:!1,className:"text-center"},{data:"premium",name:"premium",render:p,orderable:!1,className:"text-center"},{data:"whois_provider",name:"whois_provider",render:h,orderable:!1,className:"text-center"},{data:"lookup_provider",name:"lookup_provider",render:h,orderable:!1,className:"text-center"},{data:"id",name:"actions",render:S,orderable:!1,searchable:!1,className:"text-center"}],drawCallback:function(){N()}});b(document).on("click","#syncTldsBtn",function(){var r,s,n,i,o,c;if(!confirm(((n=(s=(r=window.translations)==null?void 0:r.tlds)==null?void 0:s.sync)==null?void 0:n.confirm)||"Sync TLD grace/redemption periods from registrars?"))return;const e=b(this),t=e.html();e.prop("disabled",!0).html('<i class="fas fa-spinner fa-spin me-1"></i>'+(((c=(o=(i=window.translations)==null?void 0:i.tlds)==null?void 0:o.sync)==null?void 0:c.syncing)||"Syncing...")),b.ajax({url:window.routes.tlds.sync,type:"POST",headers:{Authorization:"Bearer "+document.querySelector('meta[name="api-token"]').getAttribute("content")},success:function(a){var l,d,m,f,u,g,y,w,x;a.success?(typeof toastr<"u"?toastr.success(a.message||((m=(d=(l=window.translations)==null?void 0:l.tlds)==null?void 0:d.sync)==null?void 0:m.success)||"TLDs synced successfully."):window.showAlert?window.showAlert("success",a.message||((g=(u=(f=window.translations)==null?void 0:f.tlds)==null?void 0:u.sync)==null?void 0:g.success)||"TLDs synced successfully."):alert(a.message||"TLDs synced successfully."),L.ajax.reload()):typeof toastr<"u"?toastr.error(a.error||((x=(w=(y=window.translations)==null?void 0:y.tlds)==null?void 0:w.sync)==null?void 0:x.error)||"Sync failed."):alert(a.error||"Sync failed.")},error:function(a){var d,m,f,u;const l=((d=a.responseJSON)==null?void 0:d.error)||((u=(f=(m=window.translations)==null?void 0:m.tlds)==null?void 0:f.sync)==null?void 0:u.error)||"An error occurred during sync.";typeof toastr<"u"?toastr.error(l):alert(l)},complete:function(){e.prop("disabled",!1).html(t)}})});
