(()=>{"use strict";var e={n:n=>{var t=n&&n.__esModule?()=>n.default:()=>n;return e.d(t,{a:t}),t},d:(n,t)=>{for(var o in t)e.o(t,o)&&!e.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:t[o]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)};const n=window.wp.i18n,t=window.wp.apiFetch;var o=e.n(t);const r=window.wp.domReady;function s(e){return`${e}-last-count`}function a(e){const n=document.getElementById(e);if(!n||n.querySelector(".amp-count-loading"))return;const t=sessionStorage.getItem(s(e));if(!t||"0"!==t){const e=document.createElement("span");e.classList.add("amp-count-loading"),n.append(e),n.classList.add("awaiting-mod")}}function i(e,n){const t=document.getElementById(e);if(t)if(isNaN(n)||0===n)t.parentNode.removeChild(t),sessionStorage.setItem(s(e),"0");else{const o=n.toLocaleString();t.textContent=o,t.classList.add("awaiting-mod"),sessionStorage.setItem(s(e),o)}}function c(e){const{validated_urls:n,errors:t}=e;i("amp-new-error-index-count",t),i("amp-new-validation-url-count",n)}function d(){o()({path:"/amp/v1/unreviewed-validation-counts"}).then((e=>{c(e)})).catch((e=>{c({validated_urls:0,errors:0});const t=e?.message||(0,n.__)("An unknown error occurred while retrieving the validation counts","amp");console.error(`[AMP Plugin] ${t}`)}))}e.n(r)()((()=>{const e=document.getElementById("toplevel_page_amp-options");e&&(a("amp-new-error-index-count"),a("amp-new-validation-url-count"),e.classList.contains("wp-menu-open")?d():function(e){if(!("IntersectionObserver"in window))return void c({validated_urls:0,errors:0});const n=e.querySelector("ul"),t=new IntersectionObserver((([e])=>{e&&e.isIntersecting&&(t.unobserve(n),d())}),{root:e});t.observe(n)}(e))}))})();