(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.domReady;var n=e.n(t);const o=window.wp.i18n;n()(()=>{const e=document.getElementById("vendor-tasks-dokan-clickup-create-task");e&&e.addEventListener("click",()=>{const t=e.dataset.vendorId,n=e.dataset.restUrl,a=e.dataset.nonce,s=document.getElementById("vendor-tasks-dokan-clickup-task-result");e.disabled=!0,s.textContent=(0,o.__)("Creating task…","vendor-tasks-dokan-clickup"),s.style.color="",fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":a},body:JSON.stringify({vendor_id:parseInt(t,10),force:!0})}).then(e=>e.json()).then(t=>{if(e.disabled=!1,t.success){if(s.textContent=(0,o.__)("Task created!","vendor-tasks-dokan-clickup"),s.style.color="green",e.textContent=(0,o.__)("Re-create ClickUp Task","vendor-tasks-dokan-clickup"),t.task_url){const e=document.createElement("a");e.href=t.task_url,e.target="_blank",e.rel="noopener noreferrer",e.textContent=` ${t.task_id}`,s.appendChild(e)}}else s.textContent=t.message||(0,o.__)("Task creation failed.","vendor-tasks-dokan-clickup"),s.style.color="red"}).catch(()=>{e.disabled=!1,s.textContent=(0,o.__)("Request failed. Check console for details.","vendor-tasks-dokan-clickup"),s.style.color="red"})})})})();