(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t){var o=function(t){if("object"!=e(t)||!t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var n=o.call(t,"string");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(o)?o:o+""}function o(e,o){for(var n=0;n<o.length;n++){var r=o[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,t(r.key),r)}}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}const s=window.wp.element,i=window.yoast.componentsNew,c=window.yoast.styleGuide,a=window.yoast.analysisReport,u=window.yoast.helpers;function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}var f=function(t){function s(){var t,o,r,i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),o=this,r=n(r=s),(t=function(t,o){if(o&&("object"==e(o)||"function"==typeof o))return o;if(void 0!==o)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(o,l()?Reflect.construct(r,[],n(o).constructor):r.apply(o,i))).state={statistics:null,feed:null,isDataFetched:!1},t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)}(s,t),f=s,d=[{key:"getColorFromScore",value:function(e){return c.colors["$color_".concat(e)]||c.colors.$color_grey}}],(p=[{key:"componentDidMount",value:function(){var e=this,t=jQuery("#wpseo-dashboard-overview-hide");t.is(":checked")&&this.fetchData(),t.on("click",function(){e.fetchData()})}},{key:"fetchData",value:function(){this.state.isDataFetched||(this.getStatistics(),this.getFeed(),this.setState({isDataFetched:!0}))}},{key:"getStatistics",value:function(){var e=this;wpseoApi.get("statistics",function(t){var o={};t&&t.seo_scores&&(o.seoScores=t.seo_scores.map(function(e){return{value:parseInt(e.count,10),color:s.getColorFromScore(e.seo_rank),html:'<a href="'.concat(e.link,'">').concat(e.label,"</a>")}}),o.header=jQuery("<div>".concat(t.header,"</div>")).text(),e.setState({statistics:o}))})}},{key:"getFeed",value:function(){var e=this;(0,u.getPostFeed)("https://yoast.com/feed/widget/?wp_version="+wpseoDashboardWidgetL10n.wp_version+"&php_version="+wpseoDashboardWidgetL10n.php_version,2).then(function(t){t.items=t.items.map(function(e){return e.description=jQuery("<div>".concat(e.description,"</div>")).text(),e.description=e.description.replace("The post ".concat(e.title," appeared first on Yoast."),"").trim(),e}),e.setState({feed:t})}).catch(function(e){return console.log(e)})}},{key:"getSeoAssessment",value:function(){return null===this.state.statistics?null:React.createElement(a.SiteSEOReport,{key:"yoast-seo-posts-assessment",seoAssessmentText:this.state.statistics.header,seoAssessmentItems:this.state.statistics.seoScores})}},{key:"getYoastFeed",value:function(){return null===this.state.feed?null:React.createElement(i.ArticleList,{className:"wordpress-feed",key:"yoast-seo-blog-feed",title:wpseoDashboardWidgetL10n.feed_header,feed:this.state.feed,footerLinkText:wpseoDashboardWidgetL10n.feed_footer})}},{key:"render",value:function(){var e=[this.getSeoAssessment(),this.getYoastFeed()].filter(function(e){return null!==e});return 0===e.length?null:React.createElement("div",null,e)}}])&&o(f.prototype,p),d&&o(f,d),Object.defineProperty(f,"prototype",{writable:!1}),f;var f,p,d}(s.Component),p=document.getElementById("yoast-seo-dashboard-widget");p&&(0,s.createRoot)(p).render(React.createElement(f,null))})();