(()=>{"use strict";const e=window.wp.element,n=window.wp.components,t=window.wp.editor,r=window.ReactJSXRuntime;window.DrupalGutenberg=window.DrupalGutenberg||{},window.DrupalGutenberg.Plugins=window.DrupalGutenberg.Plugins||{},window.DrupalGutenberg.Plugins.AdditionalFieldsPluginSidebar=function(){return(0,r.jsxs)(e.Fragment,{children:[(0,r.jsx)(t.PluginSidebarMoreMenuItem,{target:"gutenberg-boilerplate-sidebar",children:"Gutenberg Boilerplate"}),(0,r.jsx)(t.PluginSidebar,{name:"additional-fields",title:"Additional fields",icons:"forms",isPinnable:"false",children:(0,r.jsx)(n.PanelBody,{})})]})};const i=window.wp.data,o=window.wp.plugins,s=window.wp.i18n,a=()=>{const o=(0,i.useSelect)(e=>e("core").__experimentalGetDirtyEntityRecords()).filter(e=>"wp_block"===e.name),{createNotice:a}=(0,i.useDispatch)("core/notices"),{saveEditedEntityRecord:l}=(0,i.useDispatch)("core"),{setEntitiesToSave:d}=(0,i.useDispatch)("drupal"),[c,u]=(0,e.useState)([]);function p(){return o.filter(({kind:e,name:n,key:t,property:r})=>!c.some(i=>i.kind===e&&i.name===n&&i.key===t&&i.property===r))}return(0,e.useEffect)(()=>{d(p())}),(0,r.jsx)(e.Fragment,{children:o.length>0&&(0,r.jsx)(t.PluginSidebar,{name:"state",title:(0,s.__)("Synced Patterns"),icon:"block-default",children:(0,r.jsxs)(n.PanelBody,{children:[(0,r.jsx)(n.BaseControl,{help:(0,s.__)("Saving synced patterns will affect other places where they are being used. You can de-select to not save."),children:(0,r.jsx)(n.BaseControl.VisualLabel,{children:(0,s.__)('The selected synced patterns will be saved when saving the content. Press "Save now" button to save immediately.')})}),o.map(e=>(0,r.jsx)(n.PanelRow,{children:(0,r.jsx)(n.CheckboxControl,{label:e.title,checked:!c.some(n=>n.kind===e.kind&&n.name===e.name&&n.key===e.key&&n.property===e.property),onChange:n=>(({kind:e,name:n,key:t,property:r},i)=>{u(i?c.filter(i=>i.kind!==e||i.name!==n||i.key!==t||i.property!==r):[...c,{kind:e,name:n,key:t,property:r}])})(e,n)},e.key)})),(0,r.jsx)(n.PanelRow,{children:(0,r.jsx)(n.Button,{isPrimary:!0,onClick:()=>(p().forEach(({kind:e,name:n,key:t,property:r})=>{l(e,n,t,r)}),void a("success",(0,s.__)("Synced pattern saved!"),{type:"snackbar"})),children:(0,s.__)("Save now")})})]})})})};(0,o.registerPlugin)("reusable-blocks-save",{render:()=>(0,r.jsx)(a,{})});const l=window.DrupalGutenberg.components;(0,o.registerPlugin)("drupal-back-button",{render:function(){const n=(0,i.useSelect)(e=>e("core/edit-post").isFeatureActive("fullscreenMode"),[]),[t,o]=(0,e.useState)(null);return(0,e.useEffect)(()=>{if(!n)return void o(null);const e=document.querySelector(".editor-header__back-button");if(e)return e.innerHTML="",void o(e);const t=new MutationObserver(()=>{const e=document.querySelector(".editor-header__back-button");e&&(e.innerHTML="",o(e),t.disconnect())});return t.observe(document.body,{childList:!0,subtree:!0}),()=>t.disconnect()},[n]),t?(0,e.createPortal)((0,r.jsx)(l.BackButton,{}),t):null},icon:null}),(window.DrupalGutenberg=window.DrupalGutenberg||{}).plugins={}})();