"use strict";(globalThis.webpackChunk_automattic_jetpack_forms=globalThis.webpackChunk_automattic_jetpack_forms||[]).push([[420],{329(t,e,r){var a=r(4715),o=r(7143),s=r(3656),c=r(2619),i=r(7723),n=r(692),u=r(1435),l=r(2441);const __=i.__;async function f(t,e){if("jetpack/contact-form"!==e)return;const r=(0,o.select)(s.store);if(r.getCurrentPostType()===u.$8)return;const c=(0,o.select)(a.store),i=c.getBlock(t);if(!i||!i.innerBlocks?.length)return;if(i.attributes?.ref)return;const f=r.getCurrentPostId()||0,k=r.getEditedPostAttribute("title")||__("Generated Form","jetpack-forms");try{const e=await(0,l.r)({attributes:i.attributes,innerBlocks:i.innerBlocks},k,Number(f)||0);if(!e)return;const r=c.getBlock(t);if(!r||r.attributes?.ref)return;(0,o.dispatch)(a.store).updateBlockAttributes(t,{ref:e})}catch(t){console.error("Failed to create synced form:",t),(0,o.dispatch)(n.store).createErrorNotice(__("Failed to save the Generated form. Your form is still available but not synced.","jetpack-forms"),{type:"snackbar"})}}(0,c.hasAction)("jetpack_ai_assistant_generation_complete","jetpack-forms/ai-integration")||(0,c.addAction)("jetpack_ai_assistant_generation_complete","jetpack-forms/ai-integration",f)}},t=>{var e;e=329,t(t.s=e)}]);