!function(t,e,s){t(function(){if(void 0!==e){window.wcTracks=window.wcTracks||{},window.wcTracks.recordEvent=window.wcTracks.recordEvent||function(){};var a,n,o=!1;e.suggestions_data&&(a=e.suggestions_data,n=[],t(".marketplace-suggestions-container").each(function(){var s=this.dataset.marketplaceSuggestionsContext,i=function(t,s){var a=_.filter(t,function(t){return _.isArray(t.context)?_.contains(t.context,s):s===t.context});return a=_.filter(a,function(t){return!_.contains(e.dismissed_suggestions,t.slug)}),a=_.filter(a,function(t){return!_.contains(e.active_plugins,t.product)}),a=_.filter(a,function(t){return!t["show-if-active"]||_.intersection(e.active_plugins,t["show-if-active"]).length>0})}(a,s),r=_.sample(i,5);for(var d in r){var l=r[d]["link-text"],p=!0;r[d]["link-text"]&&(l=r[d]["link-text"],p=!1);var g=!0;!1===r[d]["allow-dismiss"]&&(g=!1);var m=c(s,r[d].product,r[d].promoted,r[d].slug,r[d].icon,r[d].title,r[d].copy,r[d].url,l,p,g);t(this).append(m),t(this).addClass("showing-suggestion"),n.push(s),u(s)||window.wcTracks.recordEvent("marketplace_suggestion_displayed",{suggestion_slug:r[d].slug,context:s,product:r[d].product||"",promoted:r[d].promoted||"",target:r[d].url||""})}t("ul.product_data_tabs li.marketplace-suggestions_options a").on("click",function(t){if(t.preventDefault(),"#marketplace_suggestions"!==o&&u(s))for(var e in r)window.wcTracks.recordEvent("marketplace_suggestion_displayed",{suggestion_slug:r[e].slug,context:s,product:r[e].product||"",promoted:r[e].promoted||"",target:r[e].url||""})})}),function(e){var s=_.intersection(e,["products-list-empty-body","orders-list-empty-body"]).length>0;s&&(t("#screen-meta-links").hide(),t("#wpfooter").hide()),s||(t('.marketplace-suggestions-container[data-marketplace-suggestions-context="products-list-empty-header"]').hide(),t('.marketplace-suggestions-container[data-marketplace-suggestions-context="products-list-empty-footer"]').hide(),t('.marketplace-suggestions-container[data-marketplace-suggestions-context="orders-list-empty-header"]').hide(),t('.marketplace-suggestions-container[data-marketplace-suggestions-context="orders-list-empty-footer"]').hide())}(n),d(),t("ul.product_data_tabs").on("click","li a",function(e){e.preventDefault(),o=t(this).attr("href")})),t("a.marketplace-suggestion-manage-link").on("click",function(){window.wcTracks.recordEvent("marketplace_suggestions_manage_clicked")})}function i(a,n,o,i,r){var c=document.createElement("a");return c.classList.add("suggestion-dismiss"),c.setAttribute("title",e.i18n_marketplace_suggestions_dismiss_tooltip),c.setAttribute("href","#"),c.onclick=function(c){c.preventDefault(),function(a,n,o,i,r){if(t("[data-suggestion-slug="+r+"]").fadeOut(function(){t(this).remove(),d()}),jQuery.post(s,{action:"woocommerce_add_dismissed_marketplace_suggestion",_wpnonce:e.dismiss_suggestion_nonce,slug:r}),_.contains(["products-list-inline"],a)){var c="woocommerce_snooze_suggestions__"+a;Cookies.set(c,"true",{expires:2});var u="woocommerce_dismissed_suggestions__"+a,l=parseInt(Cookies.get(u),10)||0;Cookies.set(u,l+1,{expires:31})}window.wcTracks.recordEvent("marketplace_suggestion_dismissed",{suggestion_slug:r,context:a,product:n||"",promoted:o||"",target:i||""})}(a,n,o,i,r)},c}function r(t,s,a,n,o,i,r){var c=document.createElement("a"),d=function(t,s){var a=e.in_app_purchase_params;a.utm_source="unknown",a.utm_campaign="marketplacesuggestions",a.utm_medium="product";var n=_.findKey({productstable:["products-list-inline"],productsempty:["products-list-empty-header","products-list-empty-footer","products-list-empty-body"],ordersempty:["orders-list-empty-header","orders-list-empty-footer","orders-list-empty-body"],editproduct:["product-edit-meta-tab-header","product-edit-meta-tab-footer","product-edit-meta-tab-body"]},function(e){return _.contains(e,t)});return n&&(a.utm_source=n),s+"?"+jQuery.param(a)}(t,o);c.setAttribute("href",d);if(_.includes(["product-edit-meta-tab-header","product-edit-meta-tab-footer","product-edit-meta-tab-body","products-list-empty-footer"],t)&&c.setAttribute("target","blank"),c.textContent=i,c.onclick=function(){window.wcTracks.recordEvent("marketplace_suggestion_clicked",{suggestion_slug:n,context:t,product:s||"",promoted:a||"",target:o||""})},r)c.classList.add("button");else{c.classList.add("linkout");var u=document.createElement("span");u.classList.add("dashicons","dashicons-external"),c.appendChild(u)}return c}function c(t,s,a,n,o,c,d,u,l,p,g){var m=document.createElement("div");m.classList.add("marketplace-suggestion-container"),m.dataset.suggestionSlug=n;var _=function(t){if(!t)return null;var e=document.createElement("img");return e.src=t,e.classList.add("marketplace-suggestion-icon"),e}(o);return _&&m.appendChild(_),m.appendChild(function(t,s,a){var n=document.createElement("div");if(n.classList.add("marketplace-suggestion-container-content"),s){var o=document.createElement("h4");o.textContent=s,n.appendChild(o)}if(a){var i=document.createElement("p");i.textContent=a,n.appendChild(i)}if(-1!==["product-edit-empty-footer-browse-all","product-edit-meta-tab-footer-browse-all"].indexOf(t)){n.classList.add("has-manage-link");var r=document.createElement("a");r.classList.add("marketplace-suggestion-manage-link","linkout"),r.setAttribute("href",e.manage_suggestions_url),r.textContent=e.i18n_marketplace_suggestions_manage_suggestions,n.appendChild(r)}return n}(n,c,d)),m.appendChild(function(t,s,a,n,o,c,d,u){var l=document.createElement("div");if(c||(c=e.i18n_marketplace_suggestions_default_cta),l.classList.add("marketplace-suggestion-container-cta"),o&&c){var p=r(t,s,a,n,o,c,d);l.appendChild(p)}return u&&l.appendChild(i(t,s,a,o,n)),l}(t,s,a,n,u,l,p,g)),m}function d(){if(0>=t('.marketplace-suggestions-container[data-marketplace-suggestions-context="product-edit-meta-tab-body"]').children().length){var e='.marketplace-suggestions-container[data-marketplace-suggestions-context="product-edit-meta-tab-body"]';e+=', .marketplace-suggestions-container[data-marketplace-suggestions-context="product-edit-meta-tab-header"]',t(e+=', .marketplace-suggestions-container[data-marketplace-suggestions-context="product-edit-meta-tab-footer"]').fadeOut({complete:function(){t(".marketplace-suggestions-metabox-nosuggestions-placeholder").fadeIn()}})}}function u(t){return _.includes(["product-edit-meta-tab-header","product-edit-meta-tab-body","product-edit-meta-tab-footer"],t)}})}(jQuery,marketplace_suggestions,ajaxurl);