(()=>{"use strict";var e={567:e=>{e.exports=window.jQuery},989:e=>{e.exports=window.wp.apiFetch},736:e=>{e.exports=window.wp.i18n}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e=n(989),t=n.n(e),a=n(736),r=n(567),o=n.n(r);const _n=a._n,__=a.__,{ajaxUrl:s,connectionsUrl:i,isEnhancedPublishingEnabled:c,resharePath:p,isReshareSupported:d}=window.jetpackSocialClassicEditorOptions,l=["instagram-business"],u=(e,t)=>{const n=window.wp.media.featuredImage.get(),a=n&&-1!==n,r=e("#pub-connection-needs-media"),o=!!r.html();if(a!==o)return;if(t.forEach((t=>{e(".wpas-submit-"+t).each(((t,n)=>{const r=e(n);r.prop("disabled")||a||r.data("checkedVal",r.prop("checked")),r.prop("checked",a&&r.data("checkedVal")),r.prop("disabled",!a)}))})),a)return void r.removeClass().html("");const s=c?/* translators: %s is the link to the media upload best practices. */__('You need a featured image to share to Instagram. Use the block editor for more advanced media features! <a href="%s" rel="noopener noreferrer" target="_blank">Learn more</a>.',"jetpack-publicize-pkg"):/* translators: %s is the link to the media upload best practices. */__('You need a featured image to share to Instagram. <a href="%s" rel="noopener noreferrer" target="_blank">Learn more</a>.',"jetpack-publicize-pkg",0);r.addClass("notice-warning publicize__notice-media-warning publicize__notice-warning").append(s.replace("%s","https://jetpack.com/support/jetpack-social/sharing-to-instagram-with-jetpack-social"))};o()((function(e){const n=l.filter((t=>e(".wpas-submit-"+t).length));if(n.length>0){u(e,n);const t=window.wp.media.featuredImage.set;window.wp.media.featuredImage.set=function(a){t(a),u(e,n)}}let a=!1;const r=function(){a||(e.post(s,{action:"test_publicize_conns"},h),a=!0)};let o;window.addEventListener("focus",(()=>{o&&clearTimeout(o),o=setTimeout(r,2e3)}));const c=(t,n)=>n.data?n.data.reduce(((n,a)=>a.connectionTestPassed||t!==(a.connectionTestErrorCode??"broken")?n:(e("#wpas-submit-"+a.id).prop("checked",!1).prop("disabled",!0),n+1)),0):0,h=function(t){a=!1;const n=e("#pub-connection-tests");n.removeClass("test-in-progress").removeClass("below-h2").removeClass("error").removeClass("publicize-token-refresh-message").html("");const r=c("broken",t),o=c("unsupported",t);if(r){
/* translators: %s is the link to the connections page in Calypso */
const e=_n('One of your social connections is broken. Reconnect it on the <a href="%s" rel="noopener noreferrer" target="_blank">connection management</a> page.','Some of your social connections are broken. Reconnect them on the <a href="%s" rel="noopener noreferrer" target="_blank">connection management</a> page.',r,"jetpack-publicize-pkg");n.addClass("below-h2").addClass("error").addClass("publicize-token-refresh-message").append(e.replace("%s",i))}if(o){
/* translators: %s is the link to the connections page in Calypso */
const e=__('Twitter is not supported anymore. <a href="%s" rel="noopener noreferrer" target="_blank">Learn more</a>.',"jetpack-publicize-pkg");r?n.append("<hr />"):n.addClass("below-h2").addClass("error").addClass("publicize-token-refresh-message"),n.append(e.replace("%s",i))}};e("#pub-connection-tests").length&&r();const b=e("#publicize-share-now"),m=e("#publicize-share-now-notice"),g=e("#publicize-form").find('li input[type="checkbox"]'),f=(e,t="warning")=>{m.removeClass("notice-warning notice-success hidden").addClass("publicize__notice-warning notice-"+t).text(e)};b.on("click",(function(n){if(n.preventDefault(),!d)return;if(m.removeClass("publicize__notice-warning").addClass("hidden").text(""),!g.filter(((t,n)=>e(n).prop("checked"))).length)return void f(__("Please select at least one connection to share with.","jetpack-publicize-pkg"));const a=e('input[name="post_ID"]').val(),r=p.replace("{postId}",a),o=g.filter(((t,n)=>!e(n).prop("checked"))).map(((t,n)=>e(n).data("id"))).toArray(),s=e('textarea[name="wpas_title"]').val();b.prop("disabled",!0).text(__("Sharing…","jetpack-publicize-pkg")),t()({path:r,method:"POST",data:{message:s,skipped_connections:o}}).then((()=>{f(__("Your post has been shared!","jetpack-publicize-pkg"),"success")})).catch((()=>{f(__("An error occurred while sharing your post.","jetpack-publicize-pkg"))})).finally((()=>{b.prop("disabled",!1).text(__("Share now","jetpack-publicize-pkg"))}))}))}))})()})();