(()=>{"use strict";var e={428:e=>{e.exports=window.jQuery},455:e=>{e.exports=window.wp.apiFetch},723: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 a=n(455),r=n.n(a),o=n(723),s=n(428),i=n.n(s);const _n=o._n,__=o.__,{ajaxUrl:c,connectionsUrl:p,isEnhancedPublishingEnabled:d,resharePath:l,isReshareSupported:u}=window.jetpackSocialClassicEditorOptions,h=["instagram-business"],b=(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=d?/* 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"))};i()((function(e){const t=h.filter((t=>e(".wpas-submit-"+t).length));if(t.length>0){b(e,t);const n=window.wp.media.featuredImage.set;window.wp.media.featuredImage.set=function(a){n(a),b(e,t)}}let n=!1;const a=function(){n||(e.post(c,{action:"test_publicize_conns"},i),n=!0)};let o;window.addEventListener("focus",(()=>{o&&clearTimeout(o),o=setTimeout(a,2e3)}));const s=(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,i=function(t){n=!1;const a=e("#pub-connection-tests");a.removeClass("test-in-progress").removeClass("below-h2").removeClass("error").removeClass("publicize-token-refresh-message").html("");const r=s("broken",t),o=s("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");a.addClass("below-h2").addClass("error").addClass("publicize-token-refresh-message").append(e.replace("%s",p))}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?a.append("<hr />"):a.addClass("below-h2").addClass("error").addClass("publicize-token-refresh-message"),a.append(e.replace("%s",p))}};e("#pub-connection-tests").length&&a();const d=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)};d.on("click",(function(t){if(t.preventDefault(),!u)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 n=e('input[name="post_ID"]').val(),a=l.replace("{postId}",n),o=g.filter(((t,n)=>!e(n).prop("checked"))).map(((t,n)=>e(n).data("id"))).toArray(),s=e('textarea[name="wpas_title"]').val();d.prop("disabled",!0).text(__("Sharing…","jetpack-publicize-pkg")),r()({path:a,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((()=>{d.prop("disabled",!1).text(__("Share now","jetpack-publicize-pkg"))}))}))}))})();