"use strict";(self.webpackChunkwp_seopress=self.webpackChunkwp_seopress||[]).push([[240],{3553:(e,s,t)=>{t.r(s),t.d(s,{default:()=>y});var a=t(8948),n=t(6545),r=t(9196),i=t.n(r),o=t(4221),l=t(2497);t(5609);var c=t(1688),d=t(462),u=t(1792),p=t(9026);const _=({postId:e})=>`${SEOPRESS_DATA.REST_URL}seopress/v1/posts/${e}/google-news-settings`;var m=t(1928),b=t(2196);function v(){return v=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},v.apply(this,arguments)}const y=({mainBarRef:e})=>{const s=(0,l.y)(),{data:t,mutate:y,abort:E}=(({postId:e})=>(0,p.V)(_({postId:e}),{suspense:!0}))({postId:s});(0,r.useEffect)((()=>()=>{E()}),[]);const[f,w]=(0,r.useState)(!1),{actions:g}=(0,r.useContext)(o.u),k=async e=>{w(!0);try{await(async(e,s)=>{const t=await fetch(_({postId:e}),{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":(0,n.U2)(SEOPRESS_DATA,"NONCE",null)},body:JSON.stringify(s)});if(!t.ok){const e=new Error(`Save failed (${t.status})`);throw e.status=t.status,e}return await t.json()})(s,{...e,_seopress_news_disabled:e._seopress_news_disabled?"yes":""})}catch(e){return w(!1),void g.setMessage((0,b.i)({key:"generic.save_error"}),"error")}y(),w(!1),g.setMessage((0,b.i)({key:"generic.save_settings"}))},h=(0,n.Q8)((0,n.VS)(t,"key"),(e=>(0,n.U2)(e,"value",!1)));return i().createElement("div",{ref:e,tabIndex:"0"},i().createElement(a.J9,{enableReinitialize:!0,onSubmit:k,initialValues:h},(({values:e,...s})=>i().createElement(i().Fragment,null,i().createElement(c.Z,{values:{_seopress_news_disabled:e._seopress_news_disabled?"yes":""}}),i().createElement(d.Z,{values:{_seopress_news_disabled:e._seopress_news_disabled?"yes":""}}),i().createElement(a.l0,null,t.map(((t,a)=>{if(t.visible)return i().createElement(i().Fragment,{key:`social_form_${a}`},i().createElement("div",{className:"mt-3"},i().createElement(u.Z,v({item:t,values:e,checkboxLegacyValue:"_seopress_news_disabled"===t.key},s))))})),i().createElement("div",{className:"sp-fixed"},i().createElement(m.Z,{blue:!0,loading:f,onClick:()=>k(e)},(0,b.i)({key:"generic.save"}))))))))}}}]);