(()=>{"use strict";var t,e={997(t,e,a){const n=window.wp.apiFetch;!function(t){const e=()=>{document&&document.body&&document.querySelectorAll(".moap-ai-tagging__generate:not([data-moap-ready])").forEach(e=>function(t,e){if(t.dataset.moapReady)return;t.dataset.moapReady="1";const a=t.closest(".moap-ai-tagging"),n=a?a.querySelector(".moap-ai-tagging__status"):null,o=parseInt(t.dataset.attachmentId,10);t.addEventListener("click",async()=>{t.disabled=!0,n&&(n.textContent="Generating…");try{const t=await e.tagAttachment(e.apiFetch,o),r=function(t){return document.getElementById("attachment_alt")||document.getElementById(`attachments-${t}-alt`)}(o);r&&t.alt&&(r.value=t.alt);const i=a?a.querySelector(".moap-ai-tagging__tag-list"):null;if(i&&Array.isArray(t.tags)&&(i.textContent="",t.tags.forEach(t=>{const e=document.createElement("span");e.className="moap-ai-tagging__chip",e.textContent=t,i.appendChild(e)})),n){const e=Array.isArray(t.tags)?t.tags.length:0;n.textContent=`Done — ${e} tags added`}}catch(t){if(window.console&&window.console.error("Media on Autopilot: AI tagging failed",t),n){const e=t&&t.message?t.message:"";n.textContent=e?`Failed — ${e}`:"Failed — try again"}}t.disabled=!1})}(e,t))};e(),new MutationObserver(e).observe(document.body,{childList:!0,subtree:!0})}({apiFetch:a.n(n)(),tagAttachment:function(t,e){return t({path:`/moap/v1/ai-tagging/${e}`,method:"POST"})}})}},a={};function n(t){var o=a[t];if(void 0!==o)return o.exports;var r=a[t]={exports:{}};return e[t](r,r.exports,n),r.exports}n.m=e,t=[],n.O=(e,a,o,r)=>{if(!a){var i=1/0;for(d=0;d<t.length;d++){for(var[a,o,r]=t[d],s=!0,c=0;c<a.length;c++)(!1&r||i>=r)&&Object.keys(n.O).every(t=>n.O[t](a[c]))?a.splice(c--,1):(s=!1,r<i&&(i=r));if(s){t.splice(d--,1);var l=o();void 0!==l&&(e=l)}}return e}r=r||0;for(var d=t.length;d>0&&t[d-1][2]>r;d--)t[d]=t[d-1];t[d]=[a,o,r]},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var a in e)n.o(e,a)&&!n.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t={39:0,10:0};n.O.j=e=>0===t[e];var e=(e,a)=>{var o,r,[i,s,c]=a,l=0;if(i.some(e=>0!==t[e])){for(o in s)n.o(s,o)&&(n.m[o]=s[o]);if(c)var d=c(n)}for(e&&e(a);l<i.length;l++)r=i[l],n.o(t,r)&&t[r]&&t[r][0](),t[r]=0;return n.O(d)},a=globalThis.webpackChunkmedia_on_autopilot=globalThis.webpackChunkmedia_on_autopilot||[];a.forEach(e.bind(null,0)),a.push=e.bind(null,a.push.bind(a))})();var o=n.O(void 0,[10],()=>n(997));o=n.O(o)})();