!function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var a in n)e.o(n,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:n[a]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=window.wp.i18n,n=window.wp.apiFetch,a=e.n(n);function o(e){const t=document.createElement("span");return t.className="hyve-add-post-error",t.style.color="red",t.style.marginLeft="8px",t.textContent=e,t}document.addEventListener("DOMContentLoaded",(function(){document.querySelectorAll(".hyve-row-action-btn").forEach((e=>function(e){if(!e.dataset.postId)return;let n=null;e.addEventListener("click",(async d=>{d.preventDefault();const r=e.parentElement;r&&n&&n?.parentNode&&(n?.remove(),n=null),e.disabled=!0,e.style.cursor="wait";const i=e.dataset.action,s=e.innerText;try{let d;e.innerText=(0,t.__)("Hyve is processing the post","hyve-lite"),d="delete"===i?await a()({path:`${window.hyveAddons.api}/data?id=${e.dataset.postId}`,method:"DELETE"}):await a()({path:`${window.hyveAddons.api}/data`,method:"POST",data:{action:"add",data:{ID:e.dataset.postId}}}),e.style.cursor="pointer",d&&d.error&&r?(n=o(d.error),r.appendChild(n),e.innerHTML=s,e.disabled=!1):d&&("delete"===i?(e.innerHTML=(0,t.__)("Add to Hyve","hyve-lite"),e.dataset.action="add",e.classList.remove("button-link-delete")):(e.innerHTML=(0,t.__)("Remove from Hyve","hyve-lite"),e.dataset.action="delete",e.classList.add("button-link-delete")),e.disabled=!1)}catch(a){r&&(n=o(a.message||(0,t.__)("Unknown error","hyve-lite")),r.appendChild(n)),e.innerHTML=s,e.disabled=!1,e.style.cursor="pointer"}}))}(e)))}))}();